fern-api 3.22.2 → 3.22.3

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 @@ ${_Up.default.cursorShow}`)}releaseCursor(){this.extraLinesUnderPrompt>0&&n9s(th
1147
1147
  `+N7i.default.red(">> ")+t),this.screen.render(r,i)}getMaskedValue(t){return this.status==="answered"?this.opt.mask?N7i.default.cyan(PUp(t,this.opt.mask)):N7i.default.italic(N7i.default.dim("[hidden]")):this.opt.mask?PUp(t,this.opt.mask):N7i.default.italic(N7i.default.dim("[input is hidden] "))}getSpinningValue(t){return this.getMaskedValue(t)}filterInput(t){return t||(this.opt.default==null?"":this.opt.default)}onEnd(t){this.status="answered",this.answer=t.value,this.render(),this.screen.done(),this.done(t.value)}onError(t){this.render(t.isValid)}onKeypress(){this.opt.default&&=void 0,this.render()}};var t0o=ue(y1(),1);var P4p=ue(Q9s(),1),kmo=require("child_process"),aTn=require("fs"),Zmo=ue(require("path"),1),j4p=ue(require("os"),1),w4p=require("crypto"),PGs=ue(A4p(),1);var $mo=class extends Error{originalError;constructor(t){super(`Failed to create temporary file. ${t.message}`),this.originalError=t}};var Jga=class extends Error{originalError;constructor(t){super(`Failed to launch editor. ${t.message}`),this.originalError=t}};var Ymo=class extends Error{originalError;constructor(t){super(`Failed to read temporary file. ${t.message}`),this.originalError=t}};var Xmo=class extends Error{originalError;constructor(t){super(`Failed to remove temporary file. ${t.message}`),this.originalError=t}};function e0o(e="",t,r){let i=new jGs(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 m4p(e){return e?e.replace(/[^a-zA-Z0-9_.-]/g,"_"):""}function $vS(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 jGs=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=$vS(t).map(n=>n.replace("\\ "," ")),i=r.shift();this.editor={args:r,bin:i}}createTemporaryFile(){try{let t=this.fileOptions.dir??j4p.default.tmpdir(),r=(0,w4p.randomUUID)(),i=m4p(this.fileOptions.prefix),n=m4p(this.fileOptions.postfix),a=`${i}${r}${n}`,o=Zmo.default.resolve(t,a),c=Zmo.default.resolve(t)+Zmo.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,aTn.writeFileSync)(this.tempFile,this.text,f)}catch(t){throw new $mo(t)}}readTemporaryFile(){try{let t=(0,aTn.readFileSync)(this.tempFile);if(t.length===0)this.text="";else{let r=(0,P4p.detect)(t)??"utf8";PGs.default.encodingExists(r)||(r="utf8"),this.text=PGs.default.decode(t,r)}}catch(t){throw new Ymo(t)}}removeTemporaryFile(){try{(0,aTn.unlinkSync)(this.tempFile)}catch(t){throw new Xmo(t)}}launchEditor(){try{let t=(0,kmo.spawnSync)(this.editor.bin,this.editor.args.concat([this.tempFile]),{stdio:"inherit"});this.lastExitStatus=t.status??0}catch(t){throw new Jga(t)}}launchEditorAsync(t){try{(0,kmo.spawn)(this.editor.bin,this.editor.args.concat([this.tempFile]),{stdio:"inherit"}).on("exit",i=>{this.lastExitStatus=i,setImmediate(t)})}catch(r){throw new Jga(r)}}};var E4p=ue(Z_e(),1);var $ga=class extends b1{_run(t){this.done=t,this.editorResult=new E4p.Subject;let r=CQ(this.rl);this.lineSubscription=r.line.subscribe(this.startExternalEditor.bind(this));let i=this.opt.waitUserInput===void 0?!0:this.opt.waitUserInput,n=this.handleSubmitEvents(this.editorResult);return n.success.forEach(this.onEnd.bind(this)),n.error.forEach(this.onError.bind(this)),this.currentText=this.opt.default,this.opt.default=null,i?this.render():this.startExternalEditor(),this}render(t){let r="",i=this.getQuestion();i+=this.status==="answered"?t0o.default.dim("Received"):t0o.default.dim("Press <enter> to launch your preferred editor."),t&&(r=t0o.default.red(">> ")+t),this.screen.render(i,r)}startExternalEditor(){this.rl.pause(),e0o(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 I4p=require("stream");var D4p=ue(require("readline"),1),B4p=ue(M4p(),1),L7i=class{constructor(t){this.rl||=D4p.default.createInterface(XvS(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 XvS(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 B4p.default;return r.pipe(e.output||process.stdout),{terminal:!0,...e,input:t,output:r}}var Yga=class extends L7i{constructor(t={}){super(t),this.log=new I4p.Writable({write:(r,i,n)=>{this.writeLog(r),n()}}),this.bottomBar=t.bottomBar||"",this.render()}render(){return this.write(this.bottomBar),this}clean(){return qga(this.rl,this.bottomBar.split(`
1148
1148
  `).length),this}updateBottomBar(t){return qga(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&&Pmo(this.rl,t.length+this.rl.line.length),this.rl.output.write(t)}};var pO=ue(Z_e(),1),T4p=ue(ega(),1);var r0o=ue(Z_e(),1),C4p=ue(ega(),1),i0o=function(e,t,r){return typeof e[t]!="function"?(0,r0o.of)(e):(0,r0o.from)((0,C4p.default)(e[t])(r).then(i=>(e[t]=i,e)))};var q4p={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}},oTn=class extends L7i{constructor(t,r){super(r),this.prompts=t}run(t,r){this.answers=typeof r=="object"?{...r}:{};let i;return Array.isArray(t)?i=(0,pO.from)(t):(0,pO.isObservable)(t)?i=t:Object.values(t).every(n=>typeof n=="object"&&!Array.isArray(n)&&n!=null)?i=(0,pO.from)(Object.entries(t).map(([n,a])=>({name:n,...a}))):i=(0,pO.from)([t]),this.process=i.pipe((0,pO.concatMap)(this.processQuestion.bind(this)),(0,pO.publish)()),this.process.connect(),this.process.pipe((0,pO.reduce)((n,a)=>(q4p.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)(()=>i0o(t,"message",this.answers)),(0,pO.concatMap)(()=>i0o(t,"default",this.answers)),(0,pO.concatMap)(()=>i0o(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&&q4p.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,T4p.default)(t.when)(r).then(i=>{if(i)return t})).pipe((0,pO.filter)(i=>i!=null)))}};function R4p(e){let t=function(r,i){let n;try{n=new oTn(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",Rga),this.registerPrompt("input",z7i),this.registerPrompt("number",zga),this.registerPrompt("confirm",Nga),this.registerPrompt("rawlist",Fga),this.registerPrompt("expand",Qga),this.registerPrompt("checkbox",Uga),this.registerPrompt("password",Lga),this.registerPrompt("editor",$ga)},t.restoreDefaultPrompts(),t}var EGs=R4p();function kvS(e,t){EGs.registerPrompt(e,t)}function egS(){EGs.restoreDefaultPrompts()}var tgS={prompt:EGs,ui:{BottomBar:Yga,Prompt:oTn},createPromptModule:R4p,registerPrompt:kvS,restoreDefaultPrompts:egS,Separator:jH},n0o=tgS;var gTn=require("path"),_3p=require("fs"),h3p=require("readline"),QLp="posthog-node";function MAS(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[j0o.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 j0o=class{constructor(t,r,i,n){this.name=QLp,this.name=QLp,this.setupOnce=function(a,o){let c=o()?.getClient()?.getDsn()?.projectId;a(MAS(t,{organization:r,projectId:c,prefix:i,severityAllowList:n}))}}};j0o.POSTHOG_ID_TAG="posthog_distinct_id";var g0o="0123456789abcdef",w0o=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+=g0o.charAt(this.bytes[r]>>>4),t+=g0o.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+=g0o.charAt(this.bytes[r]>>>4),t+=g0o.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}},l7s=class{constructor(t){this.timestamp=0,this.counter=0,this.random=t??DAS()}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 w0o.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,w0o.ofInner(t)}},DAS=()=>({nextUint32:()=>Math.trunc(Math.random()*65536)*65536+Math.trunc(Math.random()*65536)}),ULp,f7s=()=>BAS().toString(),BAS=()=>(ULp||(ULp=new l7s)).generate();function IAS(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 CAS(e,t){global.process.on("uncaughtException",IAS(e,t))}function qAS(e){global.process.on("unhandledRejection",t=>{e(t,{mechanism:{type:"onunhandledrejection",handled:!1}})})}var O0o,LLp,A0o;function TAS(e){let t=globalThis._posthogChunkIds;if(!t)return console.error("No chunk id map found"),{};let r=Object.keys(t);return A0o&&r.length===LLp||(LLp=r.length,A0o=r.reduce((i,n)=>{O0o||(O0o={});let a=O0o[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,O0o[n]=[s,u];break}}}return i},{})),A0o}function RAS(e){return typeof Event<"u"&&y3p(e,Event)}function zAS(e){return b3p(e,"Object")}function g7s(e){switch(Object.prototype.toString.call(e)){case"[object Error]":case"[object Exception]":case"[object DOMException]":case"[object WebAssembly.Exception]":return!0;default:return y3p(e,Error)}}function y3p(e,t){try{return e instanceof t}catch{return!1}}function NAS(e){return b3p(e,"ErrorEvent")}function b3p(e,t){return Object.prototype.toString.call(e)===`[object ${t}]`}async function FAS(e,t,r,i){let a=i&&i.mechanism||{handled:!0,type:"generic"},o=v3p(a,r,i);return{$exception_list:await Promise.all(o.map(async s=>{let u=await GAS(e,t,s);return u.value=u.value||"",u.type=u.type||"Error",u.mechanism=a,u}))}}function v3p(e,t,r){let i=QAS(e,t,r);return i.cause?[i,...v3p(e,i.cause,r)]:[i]}function QAS(e,t,r){if(g7s(t))return t;if(e.synthetic=!0,zAS(t)){let n=UAS(t);if(n)return n;let a=LAS(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 UAS(e){for(let t in e)if(Object.prototype.hasOwnProperty.call(e,t)){let r=e[t];if(g7s(r))return r}}function LAS(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=WAS(e);if(NAS(e))return`Event \`ErrorEvent\` captured as exception with message \`${e.message}\``;let r=VAS(e);return`${r&&r!=="Object"?`'${r}'`:"Object"} captured as exception with keys: ${t}`}function VAS(e){try{let t=Object.getPrototypeOf(e);return t?t.constructor.name:void 0}catch{}}function WAS(e,t=40){let r=Object.keys(xAS(e));r.sort();let i=r[0];if(!i)return"[object has no keys]";if(i.length>=t)return VLp(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:VLp(a,t)}return""}function VLp(e,t=0){return typeof e!="string"||t===0||e.length<=t?e:`${e.slice(0,t)}...`}function xAS(e){return g7s(e)?{message:e.message,name:e.name,stack:e.stack,...WLp(e)}:RAS(e)?{type:e.type,target:xLp(e.target),currentTarget:xLp(e.currentTarget),...WLp(e)}:e}function WLp(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 xLp(e){try{return Object.prototype.toString.call(e)}catch{return"<unknown>"}}async function GAS(e,t,r){let i={type:r.name||r.constructor.name,value:r.message},n=HAS(e,r);for(let a of t)n=await a(n);return n.length&&(i.stacktrace={frames:n,type:"raw"}),i}function HAS(e,t){return KAS(e(t.stack||"",1),e)}function KAS(e,t){let r=TAS(t);return e.forEach(i=>{i.filename&&(i.chunk_id=r[i.filename])}),e}var JAS=2e3,yTn=class e{static async captureException(t,r,i,n,a){let o={...a};n||(o.$process_person_profile=!1);let c=await FAS(this.stackParser,this.frameModifiers,r,i);t.capture({event:"$exception",distinctId:n||f7s(),properties:{...c,...o}})}constructor(t,r){this.client=t,this._exceptionAutocaptureEnabled=r.enableExceptionAutocapture||!1,this.startAutocaptureIfEnabled()}startAutocaptureIfEnabled(){this.isEnabled()&&(CAS(this.onException.bind(this),this.onFatalError.bind(this)),qAS(this.onException.bind(this)))}onException(t,r){e.captureException(this.client,t,r)}async onFatalError(){await this.client.shutdown(JAS)}isEnabled(){return!this.client.isDisabled&&this._exceptionAutocaptureEnabled}};function $AS(e=process.argv[1]?(0,gTn.dirname)(process.argv[1]):process.cwd(),t=gTn.sep==="\\"){let r=t?GLp(e):e;return i=>{if(!i)return;let n=t?GLp(i):i,{dir:a,base:o,ext:c}=gTn.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 GLp(e){return e.replace(/^[A-Z]:/,"").replace(/\\/g,"/")}var E0o=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)}}},P0o=new E0o(25),g3p=new E0o(20),O7s=7,YAS=1e3,XAS=1e4;async function ZAS(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"||rmS(o)||imS(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(g3p.get(n))continue;let a=t[n];if(!a)continue;a.sort((f,s)=>f-s);let o=amS(a);if(o.every(f=>nmS(n,f)))continue;let c=omS(P0o,n,{});i.push(kAS(n,o,c))}return await Promise.all(i).catch(()=>{}),e&&e.length>0&&emS(e,P0o),P0o.reduce(),e}function kAS(e,t,r){return new Promise(i=>{let n=(0,_3p.createReadStream)(e),a=(0,h3p.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(){g3p.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]=umS(_,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 emS(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;tmS(r.lineno,r,i)}}function tmS(e,t,r){if(t.lineno===void 0||r===void 0)return;t.pre_context=[];for(let n=O3p(e);n<e;n++){let a=r[n];if(a===void 0){HLp(t);return}t.pre_context.push(a)}if(r[e]===void 0){HLp(t);return}t.context_line=r[e];let i=A3p(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 HLp(e){delete e.pre_context,delete e.context_line,delete e.post_context}function rmS(e){return e.startsWith("node:")||e.endsWith(".min.js")||e.endsWith(".min.cjs")||e.endsWith(".min.mjs")||e.startsWith("data:")}function imS(e){return e.lineno!==void 0&&e.lineno>XAS||e.colno!==void 0&&e.colno>YAS}function nmS(e,t){let r=P0o.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 amS(e){if(!e.length)return[];let t=0,r=e[0];if(typeof r!="number")return[];let i=KLp(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+O7s:(n.push(i),i=KLp(a)),t++}return n}function KLp(e){return[O3p(e),A3p(e)]}function O3p(e){return Math.max(1,e-O7s)}function A3p(e){return e+O7s}function omS(e,t,r){let i=e.get(t);return i===void 0?(e.set(t,r),r):i}function umS(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 smS="4.18.0",DH;(function(e){e.AnonymousId="anonymous_id",e.DistinctId="distinct_id",e.Props="props",e.FeatureFlagDetails="feature_flag_details",e.FeatureFlags="feature_flags",e.FeatureFlagPayloads="feature_flag_payloads",e.BootstrapFeatureFlagDetails="bootstrap_feature_flag_details",e.BootstrapFeatureFlags="bootstrap_feature_flags",e.BootstrapFeatureFlagPayloads="bootstrap_feature_flag_payloads",e.OverrideFeatureFlags="override_feature_flags",e.Queue="queue",e.OptedOut="opted_out",e.SessionId="session_id",e.SessionStartTimestamp="session_start_timestamp",e.SessionLastTimestamp="session_timestamp",e.PersonProperties="person_properties",e.GroupProperties="group_properties",e.InstalledAppBuild="installed_app_build",e.InstalledAppVersion="installed_app_version",e.SessionReplay="session_replay",e.DecideEndpointWasHit="decide_endpoint_was_hit",e.SurveyLastSeenDate="survey_last_seen_date",e.SurveysSeen="surveys_seen",e.Surveys="surveys",e.RemoteConfig="remote_config"})(DH||(DH={}));var JLp;(function(e){e.Left="left",e.Right="right",e.Center="center"})(JLp||(JLp={}));var $Lp;(function(e){e.Button="button",e.Tab="tab",e.Selector="selector"})($Lp||($Lp={}));var YLp;(function(e){e.Popover="popover",e.API="api",e.Widget="widget"})(YLp||(YLp={}));var XLp;(function(e){e.Html="html",e.Text="text"})(XLp||(XLp={}));var ZLp;(function(e){e.Number="number",e.Emoji="emoji"})(ZLp||(ZLp={}));var kLp;(function(e){e.Open="open",e.MultipleChoice="multiple_choice",e.SingleChoice="single_choice",e.Rating="rating",e.Link="link"})(kLp||(kLp={}));var e3p;(function(e){e.NextQuestion="next_question",e.End="end",e.ResponseBased="response_based",e.SpecificQuestion="specific_question"})(e3p||(e3p={}));var t3p;(function(e){e.Regex="regex",e.NotRegex="not_regex",e.Exact="exact",e.IsNot="is_not",e.Icontains="icontains",e.NotIcontains="not_icontains"})(t3p||(t3p={}));var r3p;(function(e){e.Contains="contains",e.Exact="exact",e.Regex="regex"})(r3p||(r3p={}));var cmS=e=>{if("flags"in e){let t=fmS(e.flags),r=dmS(e.flags);return{...e,featureFlags:t,featureFlagPayloads:r}}else{let t=e.featureFlags??{},r=Object.fromEntries(Object.entries(e.featureFlagPayloads||{}).map(([n,a])=>[n,m3p(a)])),i=Object.fromEntries(Object.entries(t).map(([n,a])=>[n,lmS(n,a,r[n])]));return{...e,featureFlags:t,featureFlagPayloads:r,flags:i}}};function lmS(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 fmS=e=>Object.fromEntries(Object.entries(e??{}).map(([t,r])=>[t,A7s(r)]).filter(([,t])=>t!==void 0)),dmS=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?m3p(i):void 0]}))},A7s=e=>e===void 0?void 0:e.variant??e.enabled,m3p=e=>{if(typeof e!="string")return e;try{return JSON.parse(e)}catch{return e}},pmS=1,_mS=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"]),hmS="utf8";function ymS(e,t){if(!e||typeof e!="string"||bmS(e))throw new Error(t)}function bmS(e){return e.trim().length===0}function vmS(e){return e?.replace(/\/+$/,"")}async function gmS(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 i3p(){return new Date().getTime()}function s7s(){return new Date().toISOString()}function S0o(e,t){let r=setTimeout(e,t);return r?.unref&&r?.unref(),r}function OmS(){return typeof fetch<"u"?fetch:typeof globalThis.fetch<"u"?globalThis.fetch:void 0}function AmS(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 mmS(e,t=0,r){let i=AmS(e);return r?.has(i)?!1:parseInt(i,16)/4294967295<t}function n3p(e){return Promise.all(e.map(t=>(t??Promise.resolve()).then(r=>({status:"fulfilled",value:r}),r=>({status:"rejected",reason:r}))))}var oOa=String.fromCharCode,a3p="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",m0o={};function PmS(e,t){if(!m0o[e]){m0o[e]={};for(let r=0;r<e.length;r++)m0o[e][e.charAt(r)]=r}return m0o[e][t]}var _Tn={compressToBase64:function(e){if(e==null)return"";let t=_Tn._compress(e,6,function(r){return a3p.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:_Tn._decompress(e.length,32,function(t){return PmS(a3p,e.charAt(t))})},compress:function(e){return _Tn._compress(e,16,function(t){return oOa(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:_Tn._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=oOa(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=oOa(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++]=oOa(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++]=oOa(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++)}}},d7s=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)}},bTn=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()}},uOa=class extends Error{constructor(t){super("Network error while fetching PostHog",t instanceof Error?{cause:t}:{}),this.error=t,this.name="PostHogFetchNetworkError"}};async function o3p(e){if(e instanceof bTn){let t="";try{t=await e.text}catch{}console.error(`Error while flushing PostHog: message=${e.message}, response body=${t}`,e)}else console.error("Error while flushing PostHog",e);return Promise.resolve()}function c7s(e){return typeof e=="object"&&(e instanceof bTn||e instanceof uOa)}function u3p(e){return typeof e=="object"&&e instanceof bTn&&e.status===413}var p7s;(function(e){e.FeatureFlags="feature_flags",e.Recordings="recordings"})(p7s||(p7s={}));var _7s=class{constructor(t,r){this.flushPromise=null,this.shutdownPromise=null,this.pendingPromises={},this._events=new d7s,this._isInitialized=!1,ymS(t,"You must pass your PostHog project's api key."),this.apiKey=t,this.host=vmS(r?.host||"https://us.i.posthog.com"),this.flushAt=r?.flushAt?Math.max(r?.flushAt,1):20,this.maxBatchSize=Math.max(this.flushAt,r?.maxBatchSize??100),this.maxQueueSize=Math.max(this.flushAt,r?.maxQueueSize??1e3),this.flushInterval=r?.flushInterval??1e4,this.captureMode=r?.captureMode||"json",this.preloadFeatureFlags=r?.preloadFeatureFlags??!0,this.defaultOptIn=r?.defaultOptIn??!0,this.disableSurveys=r?.disableSurveys??!1,this._retryOptions={retryCount:r?.fetchRetryCount??3,retryDelay:r?.fetchRetryDelay??3e3,retryCheck:c7s},this.requestTimeout=r?.requestTimeout??1e4,this.featureFlagsRequestTimeoutMs=r?.featureFlagsRequestTimeoutMs??3e3,this.remoteConfigRequestTimeoutMs=r?.remoteConfigRequestTimeoutMs??3e3,this.disableGeoip=r?.disableGeoip??!0,this.disabled=r?.disabled??!1,this.historicalMigration=r?.historicalMigration??!1,this._initPromise=Promise.resolve(),this._isInitialized=!0}logMsgIfDebug(t){this.isDebug&&t()}wrap(t){if(this.disabled){this.logMsgIfDebug(()=>console.warn("[PostHog] The client is disabled"));return}if(this._isInitialized)return t();this._initPromise.then(()=>t())}getCommonEventProperties(){return{$lib:this.getLibraryId(),$lib_version:this.getLibraryVersion()}}get optedOut(){return this.getPersistedProperty(DH.OptedOut)??!this.defaultOptIn}async optIn(){this.wrap(()=>{this.setPersistedProperty(DH.OptedOut,!1)})}async optOut(){this.wrap(()=>{this.setPersistedProperty(DH.OptedOut,!0)})}on(t,r){return this._events.on(t,r)}debug(t=!0){if(this.removeDebugCallback?.(),t){let r=this.on("*",(i,n)=>console.log("PostHog Debug",i,n));this.removeDebugCallback=()=>{r(),this.removeDebugCallback=void 0}}}get isDebug(){return!!this.removeDebugCallback}get isDisabled(){return this.disabled}buildPayload(t){return{distinct_id:t.distinct_id,event:t.event,properties:{...t.properties||{},...this.getCommonEventProperties()}}}addPendingPromise(t){let r=f7s();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=mmS(this.apiKey,pmS,_mS)?`${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=>cmS(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=A7s(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(p7s.FeatureFlags)?(console.warn("[FEATURE FLAGS] Feature flags quota limit exceeded - feature flags unavailable. Learn more about billing limits at https://posthog.com/docs/billing/limits-alerts"),{flags:{},featureFlags:{},featureFlagPayloads:{},requestId:f?.requestId}):f}async getSurveysStateless(){if(await this._initPromise,this.disableSurveys===!0)return this.logMsgIfDebug(()=>console.log("PostHog Debug","Loading surveys is disabled.")),[];let t=`${this.host}/api/surveys/?token=${this.apiKey}`,r={method:"GET",headers:{...this.getCustomHeaders(),"Content-Type":"application/json"}},n=(await this.fetchWithRetry(t,r).then(a=>{if(a.status!==200||!a.json){let o=`Surveys API could not be loaded: ${a.status}`,c=new Error(o);this.logMsgIfDebug(()=>console.error(c)),this._events.emit("error",new Error(o));return}return a.json()}).catch(a=>{this.logMsgIfDebug(()=>console.error("Surveys API could not be loaded",a)),this._events.emit("error",a)}))?.surveys;return n&&this.logMsgIfDebug(()=>console.log("PostHog Debug","Surveys fetched from API: ",JSON.stringify(n))),n??[]}get props(){return this._props||(this._props=this.getPersistedProperty(DH.Props)),this._props||{}}set props(t){this._props=t}async register(t){this.wrap(()=>{this.props={...this.props,...t},this.setPersistedProperty(DH.Props,this.props)})}async unregister(t){this.wrap(()=>{delete this.props[t],this.setPersistedProperty(DH.Props,this.props)})}enqueue(t,r,i){this.wrap(()=>{if(this.optedOut){this._events.emit(t,"Library is disabled. Not sending event. To re-enable, call posthog.optIn()");return}let n=this.prepareMessage(t,r,i),a=this.getPersistedProperty(DH.Queue)||[];a.length>=this.maxQueueSize&&(a.shift(),this.logMsgIfDebug(()=>console.info("Queue is full, the oldest event is dropped."))),a.push({message:n}),this.setPersistedProperty(DH.Queue,a),this._events.emit(t,n),a.length>=this.flushAt&&this.flushBackground(),this.flushInterval&&!this._flushTimer&&(this._flushTimer=S0o(()=>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:s7s()};this.historicalMigration&&(n.historical_migration=!0);let a=JSON.stringify(n),o=this.captureMode==="form"?`${this.host}/e/?ip=1&_=${i3p()}&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(_Tn.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:s7s(),uuid:i?.uuid?i.uuid:f7s()};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 o3p(t)})}async flush(){let t=n3p([this.flushPromise]).then(()=>this._flush());return this.flushPromise=t,this.addPendingPromise(t),n3p([t]).then(()=>{this.flushPromise===t&&(this.flushPromise=null)}),t}getCustomHeaders(){let t=this.getCustomUserAgent(),r={};return t&&t!==""&&(r["User-Agent"]=t),r}async _flush(){this.clearFlushTimer(),await this._initPromise;let t=this.getPersistedProperty(DH.Queue)||[];if(!t.length)return;let r=[],i=t.length;for(;t.length>0&&r.length<i;){let n=t.slice(0,this.maxBatchSize),a=n.map(p=>p.message),o=()=>{let _=(this.getPersistedProperty(DH.Queue)||[]).slice(n.length);this.setPersistedProperty(DH.Queue,_),t=_},c={api_key:this.apiKey,batch:a,sent_at:s7s()};this.historicalMigration&&(c.historical_migration=!0);let f=JSON.stringify(c),s=this.captureMode==="form"?`${this.host}/e/?ip=1&_=${i3p()}&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(_Tn.compressToBase64(f))}&compression=lz64`}:{method:"POST",headers:{...this.getCustomHeaders(),"Content-Type":"application/json"},body:f},l={retryCheck:p=>u3p(p)?!1:c7s(p)};try{await this.fetchWithRetry(s,u,l)}catch(p){if(u3p(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 uOa||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,hmS)}catch{c=new TextEncoder().encode(o).length}return await gmS(async()=>{let f=null;try{f=await this.fetch(t,{signal:AbortSignal.timeout(n??this.requestTimeout),...r})}catch(u){throw new uOa(u)}if(!(r.mode==="no-cors")&&(f.status<200||f.status>=400))throw new bTn(f,c);return f},{...this._retryOptions,...i})}async _shutdown(t=3e4){await this._initPromise;let r=!1;this.clearFlushTimer();let i=async()=>{try{for(await Promise.all(Object.values(this.pendingPromises));!((this.getPersistedProperty(DH.Queue)||[]).length===0||(await this.flush(),r)););}catch(n){if(!c7s(n))throw n;await o3p(n)}};return Promise.race([new Promise((n,a)=>{S0o(()=>{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}},h7s=OmS();if(!h7s){let e=FLp();h7s=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 P3p=h7s,M0o=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()}},j3p=new M0o(async()=>{try{return await import("crypto")}catch{return}});async function jmS(){return await j3p.getValue()}var wmS=new M0o(async()=>{if(typeof globalThis.crypto?.subtle<"u")return globalThis.crypto.subtle;try{let e=await j3p.getValue();if(e?.webcrypto?.subtle)return e.webcrypto.subtle}catch{}});async function EmS(){return await wmS.getValue()}async function SmS(e){let t=await jmS();if(t)return t.createHash("sha1").update(e).digest("hex");let r=await EmS();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 MmS=60*1e3,DmS=1152921504606847e3,BmS=["is_not"],hTn=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)}},y7s=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||P3p,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=E3p(c,n,this.cohorts,this.debugMode):s=w3p(c,n,o),!s)return!1}if(a==null)return!0}return!(a!=null&&await s3p(t.key,r)>a/100)}async getMatchingVariant(t,r){let i=await s3p(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(MmS,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 hTn(`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 hTn(`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 hTn(`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 hTn&&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=S0o(()=>{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=S0o(()=>{a.abort()},this.timeout),i.signal=a.signal}try{return this.fetch(r,i)}finally{clearTimeout(n)}}};async function s3p(e,t,r=""){let i=await SmS(`${e}.${t}${r}`);return parseInt(i.slice(0,15),16)/DmS}function w3p(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&&!BmS.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 c3p(String(n))&&String(o).match(String(n))!==null;case"not_regex":return c3p(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=ImS(String(n));if(s==null&&(s=l3p(n)),s==null)throw new v1(`Invalid date: ${n}`);let u=l3p(o);return["is_date_before"].includes(a)?u<s:u>s}default:throw new v1(`Unknown operator: ${a}`)}}function E3p(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 S3p(a,t,r,i)}function S3p(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=S3p(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=E3p(c,t,r,i):f=w3p(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 c3p(e){try{return new RegExp(e),!0}catch{return!1}}function l3p(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 ImS(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 b7s=class{constructor(){this._memoryStorage={}}getProperty(t){return this._memoryStorage[t]}setProperty(t,r){this._memoryStorage[t]=r!==null?r:void 0}},CmS=100,f3p=30*1e3,qmS=50*1e3,v7s=class extends _7s{constructor(t,r={}){if(super(t,r),this._memoryStorage=new b7s,this.options=r,this.options.featureFlagsPollingInterval=typeof r.featureFlagsPollingInterval=="number"?Math.max(r.featureFlagsPollingInterval,CmS):f3p,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 y7s({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 yTn(this,r),this.distinctIdHasSentFlagCalls={},this.maxCacheSize=r.maxCacheSize||qmS}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):P3p(t,r)}getLibraryVersion(){return smS}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=f3p){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=A7s(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");yTn.captureException(this,t,{syntheticException:n},r,i)}},d3p=/\(error: (.*)\)/,M3p=50,D3p="?";function TmS(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||D3p,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:p3p(n[3]),colno:p3p(n[4]),in_app:RmS(u||"",l),platform:"node:javascript"}}if(i.match(t))return{filename:i,platform:"node:javascript"}}}function RmS(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 p3p(e){return parseInt(e||"",10)||void 0}function zmS(e){return[90,TmS(e)]}function NmS(e){let r=[zmS(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=d3p.test(f)?f.replace(d3p,"$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>=M3p)break}}return FmS(a)}}function FmS(e){if(!e.length)return[];let t=Array.from(e);return t.reverse(),t.slice(0,M3p).map(r=>({...r,filename:r.filename||QmS(t).filename,function:r.function||D3p}))}function QmS(e){return e[e.length-1]||{}}yTn.stackParser=NmS($AS());yTn.frameModifiers=[ZAS];var vTn=class extends v7s{getLibraryId(){return"posthog-node"}};var D0o=class{posthog;constructor({posthogApiKey:t}){this.posthog=new vTn(t)}async identify(){}async sendEvent(t){t.orgId!=null&&this.posthog.capture({distinctId:t.orgId,event:"CLI",properties:{...t,...t.properties,version:"3.22.2",usingAccessToken:!0}})}async flush(){await this.posthog.flush()}};var sOa=class{async sendEvent(){}async identify(){}async flush(){}};var OTn=require("fs/promises"),q3p=require("os"),T3p=require("path");var B3p=ue(require("crypto")),I0o=new Uint8Array(256),B0o=I0o.length;function m7s(){return B0o>I0o.length-16&&(B3p.default.randomFillSync(I0o),B0o=0),I0o.slice(B0o,B0o+=16)}var TQ=[];for(let e=0;e<256;++e)TQ.push((e+256).toString(16).slice(1));function I3p(e,t=0){return TQ[e[t+0]]+TQ[e[t+1]]+TQ[e[t+2]]+TQ[e[t+3]]+"-"+TQ[e[t+4]]+TQ[e[t+5]]+"-"+TQ[e[t+6]]+TQ[e[t+7]]+"-"+TQ[e[t+8]]+TQ[e[t+9]]+"-"+TQ[e[t+10]]+TQ[e[t+11]]+TQ[e[t+12]]+TQ[e[t+13]]+TQ[e[t+14]]+TQ[e[t+15]]}var C3p=ue(require("crypto")),P7s={randomUUID:C3p.default.randomUUID};function UmS(e,t,r){if(P7s.randomUUID&&!t&&!e)return P7s.randomUUID();e=e||{};let i=e.random||(e.rng||m7s)();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 I3p(i)}var ehe=UmS;var LmS="id",VmS=".fern",cOa=class{posthog;userId;constructor({token:t,posthogApiKey:r}){this.posthog=new vTn(r),this.userId=t==null?void 0:x8s(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.22.2",...t,...t.properties}})}async flush(){await this.posthog.flush()}persistedDistinctId;async getPersistedDistinctId(){if(this.persistedDistinctId==null){let t=It(Rr.of((0,q3p.homedir)()),Ze.of(VmS),Ze.of(LmS));await qi(t)||(await(0,OTn.mkdir)((0,T3p.dirname)(t),{recursive:!0}),await(0,OTn.writeFile)(t,ehe())),this.persistedDistinctId=(await(0,OTn.readFile)(t)).toString()}return this.persistedDistinctId}};var j7s;async function ATn(){return j7s==null&&(j7s=await WmS()),j7s}async function WmS(){try{let e="phc_yQgAEdJJkVpI24NdSRID2mor1x1leRpDoC9yZ9mfXal",t=process.env.FERN_DISABLE_TELEMETRY==="true";if(e==null||t)return new sOa;let r=await Jyo();return r!=null?new cOa({token:r,posthogApiKey:e}):await jqn()!=null?new D0o({posthogApiKey:e}):new cOa({token:void 0,posthogApiKey:e})}catch{return new sOa}}function lOa(e,t){return function(){return e.apply(t,arguments)}}var{toString:xmS}=Object.prototype,{getPrototypeOf:E7s}=Object,{iterator:q0o,toStringTag:z3p}=Symbol,T0o=(e=>t=>{let r=xmS.call(t);return e[r]||(e[r]=r.slice(8,-1).toLowerCase())})(Object.create(null)),NNt=e=>(e=e.toLowerCase(),t=>T0o(t)===e),R0o=e=>t=>typeof t===e,{isArray:PTn}=Array,mTn=R0o("undefined");function fOa(e){return e!==null&&!mTn(e)&&e.constructor!==null&&!mTn(e.constructor)&&BH(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}var N3p=NNt("ArrayBuffer");function GmS(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&N3p(e.buffer),t}var HmS=R0o("string"),BH=R0o("function"),F3p=R0o("number"),dOa=e=>e!==null&&typeof e=="object",KmS=e=>e===!0||e===!1,C0o=e=>{if(T0o(e)!=="object")return!1;let t=E7s(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(z3p in e)&&!(q0o in e)},JmS=e=>{if(!dOa(e)||fOa(e))return!1;try{return Object.keys(e).length===0&&Object.getPrototypeOf(e)===Object.prototype}catch{return!1}},$mS=NNt("Date"),YmS=NNt("File"),XmS=NNt("Blob"),ZmS=NNt("FileList"),kmS=e=>dOa(e)&&BH(e.pipe),e0S=e=>{let t;return e&&(typeof FormData=="function"&&e instanceof FormData||BH(e.append)&&((t=T0o(e))==="formdata"||t==="object"&&BH(e.toString)&&e.toString()==="[object FormData]"))},t0S=NNt("URLSearchParams"),[r0S,i0S,n0S,a0S]=["ReadableStream","Request","Response","Headers"].map(NNt),o0S=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function pOa(e,t,{allOwnKeys:r=!1}={}){if(e===null||typeof e>"u")return;let i,n;if(typeof e!="object"&&(e=[e]),PTn(e))for(i=0,n=e.length;i<n;i++)t.call(null,e[i],i,e);else{if(fOa(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 Q3p(e,t){if(fOa(e))return null;t=t.toLowerCase();let r=Object.keys(e),i=r.length,n;for(;i-- >0;)if(n=r[i],t===n.toLowerCase())return n;return null}var K7i=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,U3p=e=>!mTn(e)&&e!==K7i;function w7s(){let{caseless:e,skipUndefined:t}=U3p(this)&&this||{},r={},i=(n,a)=>{let o=e&&Q3p(r,a)||a;C0o(r[o])&&C0o(n)?r[o]=w7s(r[o],n):C0o(n)?r[o]=w7s({},n):PTn(n)?r[o]=n.slice():(!t||!mTn(n))&&(r[o]=n)};for(let n=0,a=arguments.length;n<a;n++)arguments[n]&&pOa(arguments[n],i);return r}var u0S=(e,t,r,{allOwnKeys:i}={})=>(pOa(t,(n,a)=>{r&&BH(n)?e[a]=lOa(n,r):e[a]=n},{allOwnKeys:i}),e),s0S=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),c0S=(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)},l0S=(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&&E7s(e)}while(e&&(!r||r(e,t))&&e!==Object.prototype);return t},f0S=(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},d0S=e=>{if(!e)return null;if(PTn(e))return e;let t=e.length;if(!F3p(t))return null;let r=new Array(t);for(;t-- >0;)r[t]=e[t];return r},p0S=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&E7s(Uint8Array)),_0S=(e,t)=>{let i=(e&&e[q0o]).call(e),n;for(;(n=i.next())&&!n.done;){let a=n.value;t.call(e,a[0],a[1])}},h0S=(e,t)=>{let r,i=[];for(;(r=e.exec(t))!==null;)i.push(r);return i},y0S=NNt("HTMLFormElement"),b0S=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(r,i,n){return i.toUpperCase()+n}),R3p=(({hasOwnProperty:e})=>(t,r)=>e.call(t,r))(Object.prototype),v0S=NNt("RegExp"),L3p=(e,t)=>{let r=Object.getOwnPropertyDescriptors(e),i={};pOa(r,(n,a)=>{let o;(o=t(n,a,e))!==!1&&(i[a]=o||n)}),Object.defineProperties(e,i)},g0S=e=>{L3p(e,(t,r)=>{if(BH(e)&&["arguments","caller","callee"].indexOf(r)!==-1)return!1;let i=e[r];if(BH(i)){if(t.enumerable=!1,"writable"in t){t.writable=!1;return}t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+r+"'")})}})},O0S=(e,t)=>{let r={},i=n=>{n.forEach(a=>{r[a]=!0})};return PTn(e)?i(e):i(String(e).split(t)),r},A0S=()=>{},m0S=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t;function P0S(e){return!!(e&&BH(e.append)&&e[z3p]==="FormData"&&e[q0o])}var j0S=e=>{let t=new Array(10),r=(i,n)=>{if(dOa(i)){if(t.indexOf(i)>=0)return;if(fOa(i))return i;if(!("toJSON"in i)){t[n]=i;let a=PTn(i)?[]:{};return pOa(i,(o,c)=>{let f=r(o,n+1);!mTn(f)&&(a[c]=f)}),t[n]=void 0,a}}return i};return r(e,0)},w0S=NNt("AsyncFunction"),E0S=e=>e&&(dOa(e)||BH(e))&&BH(e.then)&&BH(e.catch),V3p=((e,t)=>e?setImmediate:t?((r,i)=>(K7i.addEventListener("message",({source:n,data:a})=>{n===K7i&&a===r&&i.length&&i.shift()()},!1),n=>{i.push(n),K7i.postMessage(r,"*")}))(`axios@${Math.random()}`,[]):r=>setTimeout(r))(typeof setImmediate=="function",BH(K7i.postMessage)),S0S=typeof queueMicrotask<"u"?queueMicrotask.bind(K7i):typeof process<"u"&&process.nextTick||V3p,M0S=e=>e!=null&&BH(e[q0o]),er={isArray:PTn,isArrayBuffer:N3p,isBuffer:fOa,isFormData:e0S,isArrayBufferView:GmS,isString:HmS,isNumber:F3p,isBoolean:KmS,isObject:dOa,isPlainObject:C0o,isEmptyObject:JmS,isReadableStream:r0S,isRequest:i0S,isResponse:n0S,isHeaders:a0S,isUndefined:mTn,isDate:$mS,isFile:YmS,isBlob:XmS,isRegExp:v0S,isFunction:BH,isStream:kmS,isURLSearchParams:t0S,isTypedArray:p0S,isFileList:ZmS,forEach:pOa,merge:w7s,extend:u0S,trim:o0S,stripBOM:s0S,inherits:c0S,toFlatObject:l0S,kindOf:T0o,kindOfTest:NNt,endsWith:f0S,toArray:d0S,forEachEntry:_0S,matchAll:h0S,isHTMLForm:y0S,hasOwnProperty:R3p,hasOwnProp:R3p,reduceDescriptors:L3p,freezeMethods:g0S,toObjectSet:O0S,toCamelCase:b0S,noop:A0S,toFiniteNumber:m0S,findKey:Q3p,global:K7i,isContextDefined:U3p,isSpecCompliantForm:P0S,toJSONObject:j0S,isAsyncFn:w0S,isThenable:E0S,setImmediate:V3p,asap:S0S,isIterable:M0S};function jTn(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(jTn,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 W3p=jTn.prototype,x3p={};["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=>{x3p[e]={value:e}});Object.defineProperties(jTn,x3p);Object.defineProperty(W3p,"isAxiosError",{value:!0});jTn.from=(e,t,r,i,n,a)=>{let o=Object.create(W3p);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 jTn.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=jTn;var G3p=ue(IGi(),1),z0o=G3p.default;function S7s(e){return er.isPlainObject(e)||er.isArray(e)}function K3p(e){return er.endsWith(e,"[]")?e.slice(0,-2):e}function H3p(e,t,r){return e?e.concat(t).map(function(n,a){return n=K3p(n),!r&&a?"["+n+"]":n}).join(r?".":""):t}function D0S(e){return er.isArray(e)&&!e.some(S7s)}var B0S=er.toFlatObject(er,{},null,function(t){return/^is[A-Z]/.test(t)});function I0S(e,t,r){if(!er.isObject(e))throw new TypeError("target must be an object");t=t||new(z0o||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)&&D0S(h)||(er.isFileList(h)||er.endsWith(y,"[]"))&&(v=er.toArray(h)))return y=K3p(y),v.forEach(function(A,g){!(er.isUndefined(A)||A===null)&&t.append(o===!0?H3p([y],g,a):o===null?y:y+"[]",s(A))}),!1}return S7s(h)?!0:(t.append(H3p(b,y,a),s(h)),!1)}let l=[],p=Object.assign(B0S,{defaultVisitor:u,convertValue:s,isVisitable:S7s});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 zBi=I0S;function J3p(e){let t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(i){return t[i]})}function $3p(e,t){this._pairs=[],e&&zBi(e,this,t)}var Y3p=$3p.prototype;Y3p.append=function(t,r){this._pairs.push([t,r])};Y3p.toString=function(t){let r=t?function(i){return t.call(this,i,J3p)}:J3p;return this._pairs.map(function(n){return r(n[0])+"="+r(n[1])},"").join("&")};var X3p=$3p;function C0S(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function J7i(e,t,r){if(!t)return e;let i=r&&r.encode||C0S;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 X3p(t,r).toString(i),a){let o=e.indexOf("#");o!==-1&&(e=e.slice(0,o)),e+=(e.indexOf("?")===-1?"?":"&")+a}return e}var M7s=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)})}},D7s=M7s;var wTn={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1};var t8p=ue(require("crypto"),1);var Z3p=ue(require("url"),1),k3p=Z3p.default.URLSearchParams;var B7s="abcdefghijklmnopqrstuvwxyz",e8p="0123456789",r8p={DIGIT:e8p,ALPHA:B7s,ALPHA_DIGIT:B7s+B7s.toUpperCase()+e8p},q0S=(e=16,t=r8p.ALPHA_DIGIT)=>{let r="",{length:i}=t,n=new Uint32Array(e);t8p.default.randomFillSync(n);for(let a=0;a<e;a++)r+=t[n[a]%i];return r},i8p={isNode:!0,classes:{URLSearchParams:k3p,FormData:z0o,Blob:typeof Blob<"u"&&Blob||null},ALPHABET:r8p,generateString:q0S,protocols:["http","https","file","data"]};var q7s={};Yt(q7s,{hasBrowserEnv:()=>C7s,hasStandardBrowserEnv:()=>T0S,hasStandardBrowserWebWorkerEnv:()=>R0S,navigator:()=>I7s,origin:()=>z0S});var C7s=typeof window<"u"&&typeof document<"u",I7s=typeof navigator=="object"&&navigator||void 0,T0S=C7s&&(!I7s||["ReactNative","NativeScript","NS"].indexOf(I7s.product)<0),R0S=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",z0S=C7s&&window.location.href||"http://localhost";var OA={...q7s,...i8p};function T7s(e,t){return zBi(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 N0S(e){return er.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function F0S(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 Q0S(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]=F0S(n[o])),!c)}if(er.isFormData(e)&&er.isFunction(e.entries)){let r={};return er.forEachEntry(e,(i,n)=>{t(N0S(i),n,r,0)}),r}return null}var N0o=Q0S;function U0S(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 R7s={transitional:wTn,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(N0o(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 T7s(t,this.formSerializer).toString();if((c=er.isFileList(t))||i.indexOf("multipart/form-data")>-1){let f=this.env&&this.env.FormData;return zBi(c?{"files[]":t}:t,f&&new f,this.formSerializer)}}return a||n?(r.setContentType("application/json",!1),U0S(t)):t}],transformResponse:[function(t){let r=this.transitional||R7s.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=>{R7s.headers[e]={}});var ETn=R7s;var L0S=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"]),n8p=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=d3p.test(f)?f.replace(d3p,"$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>=M3p)break}}return FmS(a)}}function FmS(e){if(!e.length)return[];let t=Array.from(e);return t.reverse(),t.slice(0,M3p).map(r=>({...r,filename:r.filename||QmS(t).filename,function:r.function||D3p}))}function QmS(e){return e[e.length-1]||{}}yTn.stackParser=NmS($AS());yTn.frameModifiers=[ZAS];var vTn=class extends v7s{getLibraryId(){return"posthog-node"}};var D0o=class{posthog;constructor({posthogApiKey:t}){this.posthog=new vTn(t)}async identify(){}async sendEvent(t){t.orgId!=null&&this.posthog.capture({distinctId:t.orgId,event:"CLI",properties:{...t,...t.properties,version:"3.22.3",usingAccessToken:!0}})}async flush(){await this.posthog.flush()}};var sOa=class{async sendEvent(){}async identify(){}async flush(){}};var OTn=require("fs/promises"),q3p=require("os"),T3p=require("path");var B3p=ue(require("crypto")),I0o=new Uint8Array(256),B0o=I0o.length;function m7s(){return B0o>I0o.length-16&&(B3p.default.randomFillSync(I0o),B0o=0),I0o.slice(B0o,B0o+=16)}var TQ=[];for(let e=0;e<256;++e)TQ.push((e+256).toString(16).slice(1));function I3p(e,t=0){return TQ[e[t+0]]+TQ[e[t+1]]+TQ[e[t+2]]+TQ[e[t+3]]+"-"+TQ[e[t+4]]+TQ[e[t+5]]+"-"+TQ[e[t+6]]+TQ[e[t+7]]+"-"+TQ[e[t+8]]+TQ[e[t+9]]+"-"+TQ[e[t+10]]+TQ[e[t+11]]+TQ[e[t+12]]+TQ[e[t+13]]+TQ[e[t+14]]+TQ[e[t+15]]}var C3p=ue(require("crypto")),P7s={randomUUID:C3p.default.randomUUID};function UmS(e,t,r){if(P7s.randomUUID&&!t&&!e)return P7s.randomUUID();e=e||{};let i=e.random||(e.rng||m7s)();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 I3p(i)}var ehe=UmS;var LmS="id",VmS=".fern",cOa=class{posthog;userId;constructor({token:t,posthogApiKey:r}){this.posthog=new vTn(r),this.userId=t==null?void 0:x8s(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.22.3",...t,...t.properties}})}async flush(){await this.posthog.flush()}persistedDistinctId;async getPersistedDistinctId(){if(this.persistedDistinctId==null){let t=It(Rr.of((0,q3p.homedir)()),Ze.of(VmS),Ze.of(LmS));await qi(t)||(await(0,OTn.mkdir)((0,T3p.dirname)(t),{recursive:!0}),await(0,OTn.writeFile)(t,ehe())),this.persistedDistinctId=(await(0,OTn.readFile)(t)).toString()}return this.persistedDistinctId}};var j7s;async function ATn(){return j7s==null&&(j7s=await WmS()),j7s}async function WmS(){try{let e="phc_yQgAEdJJkVpI24NdSRID2mor1x1leRpDoC9yZ9mfXal",t=process.env.FERN_DISABLE_TELEMETRY==="true";if(e==null||t)return new sOa;let r=await Jyo();return r!=null?new cOa({token:r,posthogApiKey:e}):await jqn()!=null?new D0o({posthogApiKey:e}):new cOa({token:void 0,posthogApiKey:e})}catch{return new sOa}}function lOa(e,t){return function(){return e.apply(t,arguments)}}var{toString:xmS}=Object.prototype,{getPrototypeOf:E7s}=Object,{iterator:q0o,toStringTag:z3p}=Symbol,T0o=(e=>t=>{let r=xmS.call(t);return e[r]||(e[r]=r.slice(8,-1).toLowerCase())})(Object.create(null)),NNt=e=>(e=e.toLowerCase(),t=>T0o(t)===e),R0o=e=>t=>typeof t===e,{isArray:PTn}=Array,mTn=R0o("undefined");function fOa(e){return e!==null&&!mTn(e)&&e.constructor!==null&&!mTn(e.constructor)&&BH(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}var N3p=NNt("ArrayBuffer");function GmS(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&N3p(e.buffer),t}var HmS=R0o("string"),BH=R0o("function"),F3p=R0o("number"),dOa=e=>e!==null&&typeof e=="object",KmS=e=>e===!0||e===!1,C0o=e=>{if(T0o(e)!=="object")return!1;let t=E7s(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(z3p in e)&&!(q0o in e)},JmS=e=>{if(!dOa(e)||fOa(e))return!1;try{return Object.keys(e).length===0&&Object.getPrototypeOf(e)===Object.prototype}catch{return!1}},$mS=NNt("Date"),YmS=NNt("File"),XmS=NNt("Blob"),ZmS=NNt("FileList"),kmS=e=>dOa(e)&&BH(e.pipe),e0S=e=>{let t;return e&&(typeof FormData=="function"&&e instanceof FormData||BH(e.append)&&((t=T0o(e))==="formdata"||t==="object"&&BH(e.toString)&&e.toString()==="[object FormData]"))},t0S=NNt("URLSearchParams"),[r0S,i0S,n0S,a0S]=["ReadableStream","Request","Response","Headers"].map(NNt),o0S=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function pOa(e,t,{allOwnKeys:r=!1}={}){if(e===null||typeof e>"u")return;let i,n;if(typeof e!="object"&&(e=[e]),PTn(e))for(i=0,n=e.length;i<n;i++)t.call(null,e[i],i,e);else{if(fOa(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 Q3p(e,t){if(fOa(e))return null;t=t.toLowerCase();let r=Object.keys(e),i=r.length,n;for(;i-- >0;)if(n=r[i],t===n.toLowerCase())return n;return null}var K7i=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,U3p=e=>!mTn(e)&&e!==K7i;function w7s(){let{caseless:e,skipUndefined:t}=U3p(this)&&this||{},r={},i=(n,a)=>{let o=e&&Q3p(r,a)||a;C0o(r[o])&&C0o(n)?r[o]=w7s(r[o],n):C0o(n)?r[o]=w7s({},n):PTn(n)?r[o]=n.slice():(!t||!mTn(n))&&(r[o]=n)};for(let n=0,a=arguments.length;n<a;n++)arguments[n]&&pOa(arguments[n],i);return r}var u0S=(e,t,r,{allOwnKeys:i}={})=>(pOa(t,(n,a)=>{r&&BH(n)?e[a]=lOa(n,r):e[a]=n},{allOwnKeys:i}),e),s0S=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),c0S=(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)},l0S=(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&&E7s(e)}while(e&&(!r||r(e,t))&&e!==Object.prototype);return t},f0S=(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},d0S=e=>{if(!e)return null;if(PTn(e))return e;let t=e.length;if(!F3p(t))return null;let r=new Array(t);for(;t-- >0;)r[t]=e[t];return r},p0S=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&E7s(Uint8Array)),_0S=(e,t)=>{let i=(e&&e[q0o]).call(e),n;for(;(n=i.next())&&!n.done;){let a=n.value;t.call(e,a[0],a[1])}},h0S=(e,t)=>{let r,i=[];for(;(r=e.exec(t))!==null;)i.push(r);return i},y0S=NNt("HTMLFormElement"),b0S=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(r,i,n){return i.toUpperCase()+n}),R3p=(({hasOwnProperty:e})=>(t,r)=>e.call(t,r))(Object.prototype),v0S=NNt("RegExp"),L3p=(e,t)=>{let r=Object.getOwnPropertyDescriptors(e),i={};pOa(r,(n,a)=>{let o;(o=t(n,a,e))!==!1&&(i[a]=o||n)}),Object.defineProperties(e,i)},g0S=e=>{L3p(e,(t,r)=>{if(BH(e)&&["arguments","caller","callee"].indexOf(r)!==-1)return!1;let i=e[r];if(BH(i)){if(t.enumerable=!1,"writable"in t){t.writable=!1;return}t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+r+"'")})}})},O0S=(e,t)=>{let r={},i=n=>{n.forEach(a=>{r[a]=!0})};return PTn(e)?i(e):i(String(e).split(t)),r},A0S=()=>{},m0S=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t;function P0S(e){return!!(e&&BH(e.append)&&e[z3p]==="FormData"&&e[q0o])}var j0S=e=>{let t=new Array(10),r=(i,n)=>{if(dOa(i)){if(t.indexOf(i)>=0)return;if(fOa(i))return i;if(!("toJSON"in i)){t[n]=i;let a=PTn(i)?[]:{};return pOa(i,(o,c)=>{let f=r(o,n+1);!mTn(f)&&(a[c]=f)}),t[n]=void 0,a}}return i};return r(e,0)},w0S=NNt("AsyncFunction"),E0S=e=>e&&(dOa(e)||BH(e))&&BH(e.then)&&BH(e.catch),V3p=((e,t)=>e?setImmediate:t?((r,i)=>(K7i.addEventListener("message",({source:n,data:a})=>{n===K7i&&a===r&&i.length&&i.shift()()},!1),n=>{i.push(n),K7i.postMessage(r,"*")}))(`axios@${Math.random()}`,[]):r=>setTimeout(r))(typeof setImmediate=="function",BH(K7i.postMessage)),S0S=typeof queueMicrotask<"u"?queueMicrotask.bind(K7i):typeof process<"u"&&process.nextTick||V3p,M0S=e=>e!=null&&BH(e[q0o]),er={isArray:PTn,isArrayBuffer:N3p,isBuffer:fOa,isFormData:e0S,isArrayBufferView:GmS,isString:HmS,isNumber:F3p,isBoolean:KmS,isObject:dOa,isPlainObject:C0o,isEmptyObject:JmS,isReadableStream:r0S,isRequest:i0S,isResponse:n0S,isHeaders:a0S,isUndefined:mTn,isDate:$mS,isFile:YmS,isBlob:XmS,isRegExp:v0S,isFunction:BH,isStream:kmS,isURLSearchParams:t0S,isTypedArray:p0S,isFileList:ZmS,forEach:pOa,merge:w7s,extend:u0S,trim:o0S,stripBOM:s0S,inherits:c0S,toFlatObject:l0S,kindOf:T0o,kindOfTest:NNt,endsWith:f0S,toArray:d0S,forEachEntry:_0S,matchAll:h0S,isHTMLForm:y0S,hasOwnProperty:R3p,hasOwnProp:R3p,reduceDescriptors:L3p,freezeMethods:g0S,toObjectSet:O0S,toCamelCase:b0S,noop:A0S,toFiniteNumber:m0S,findKey:Q3p,global:K7i,isContextDefined:U3p,isSpecCompliantForm:P0S,toJSONObject:j0S,isAsyncFn:w0S,isThenable:E0S,setImmediate:V3p,asap:S0S,isIterable:M0S};function jTn(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(jTn,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 W3p=jTn.prototype,x3p={};["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=>{x3p[e]={value:e}});Object.defineProperties(jTn,x3p);Object.defineProperty(W3p,"isAxiosError",{value:!0});jTn.from=(e,t,r,i,n,a)=>{let o=Object.create(W3p);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 jTn.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=jTn;var G3p=ue(IGi(),1),z0o=G3p.default;function S7s(e){return er.isPlainObject(e)||er.isArray(e)}function K3p(e){return er.endsWith(e,"[]")?e.slice(0,-2):e}function H3p(e,t,r){return e?e.concat(t).map(function(n,a){return n=K3p(n),!r&&a?"["+n+"]":n}).join(r?".":""):t}function D0S(e){return er.isArray(e)&&!e.some(S7s)}var B0S=er.toFlatObject(er,{},null,function(t){return/^is[A-Z]/.test(t)});function I0S(e,t,r){if(!er.isObject(e))throw new TypeError("target must be an object");t=t||new(z0o||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)&&D0S(h)||(er.isFileList(h)||er.endsWith(y,"[]"))&&(v=er.toArray(h)))return y=K3p(y),v.forEach(function(A,g){!(er.isUndefined(A)||A===null)&&t.append(o===!0?H3p([y],g,a):o===null?y:y+"[]",s(A))}),!1}return S7s(h)?!0:(t.append(H3p(b,y,a),s(h)),!1)}let l=[],p=Object.assign(B0S,{defaultVisitor:u,convertValue:s,isVisitable:S7s});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 zBi=I0S;function J3p(e){let t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(i){return t[i]})}function $3p(e,t){this._pairs=[],e&&zBi(e,this,t)}var Y3p=$3p.prototype;Y3p.append=function(t,r){this._pairs.push([t,r])};Y3p.toString=function(t){let r=t?function(i){return t.call(this,i,J3p)}:J3p;return this._pairs.map(function(n){return r(n[0])+"="+r(n[1])},"").join("&")};var X3p=$3p;function C0S(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function J7i(e,t,r){if(!t)return e;let i=r&&r.encode||C0S;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 X3p(t,r).toString(i),a){let o=e.indexOf("#");o!==-1&&(e=e.slice(0,o)),e+=(e.indexOf("?")===-1?"?":"&")+a}return e}var M7s=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)})}},D7s=M7s;var wTn={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1};var t8p=ue(require("crypto"),1);var Z3p=ue(require("url"),1),k3p=Z3p.default.URLSearchParams;var B7s="abcdefghijklmnopqrstuvwxyz",e8p="0123456789",r8p={DIGIT:e8p,ALPHA:B7s,ALPHA_DIGIT:B7s+B7s.toUpperCase()+e8p},q0S=(e=16,t=r8p.ALPHA_DIGIT)=>{let r="",{length:i}=t,n=new Uint32Array(e);t8p.default.randomFillSync(n);for(let a=0;a<e;a++)r+=t[n[a]%i];return r},i8p={isNode:!0,classes:{URLSearchParams:k3p,FormData:z0o,Blob:typeof Blob<"u"&&Blob||null},ALPHABET:r8p,generateString:q0S,protocols:["http","https","file","data"]};var q7s={};Yt(q7s,{hasBrowserEnv:()=>C7s,hasStandardBrowserEnv:()=>T0S,hasStandardBrowserWebWorkerEnv:()=>R0S,navigator:()=>I7s,origin:()=>z0S});var C7s=typeof window<"u"&&typeof document<"u",I7s=typeof navigator=="object"&&navigator||void 0,T0S=C7s&&(!I7s||["ReactNative","NativeScript","NS"].indexOf(I7s.product)<0),R0S=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",z0S=C7s&&window.location.href||"http://localhost";var OA={...q7s,...i8p};function T7s(e,t){return zBi(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 N0S(e){return er.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function F0S(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 Q0S(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]=F0S(n[o])),!c)}if(er.isFormData(e)&&er.isFunction(e.entries)){let r={};return er.forEachEntry(e,(i,n)=>{t(N0S(i),n,r,0)}),r}return null}var N0o=Q0S;function U0S(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 R7s={transitional:wTn,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(N0o(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 T7s(t,this.formSerializer).toString();if((c=er.isFileList(t))||i.indexOf("multipart/form-data")>-1){let f=this.env&&this.env.FormData;return zBi(c?{"files[]":t}:t,f&&new f,this.formSerializer)}}return a||n?(r.setContentType("application/json",!1),U0S(t)):t}],transformResponse:[function(t){let r=this.transitional||R7s.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=>{R7s.headers[e]={}});var ETn=R7s;var L0S=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"]),n8p=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]&&L0S[r])&&(r==="set-cookie"?t[r]?t[r].push(i):t[r]=[i]:t[r]=t[r]?t[r]+", "+i:i)}),t};var a8p=Symbol("internals");function _Oa(e){return e&&String(e).trim().toLowerCase()}function F0o(e){return e===!1||e==null?e:er.isArray(e)?e.map(F0o):String(e)}function V0S(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 W0S=e=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim());function z7s(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 x0S(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(t,r,i)=>r.toUpperCase()+i)}function G0S(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 STn=class{constructor(t){t&&this.set(t)}set(t,r,i){let n=this;function a(c,f,s){let u=_Oa(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]=F0o(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())&&!W0S(t))o(n8p(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=_Oa(t),t){let i=er.findKey(this,t);if(i){let n=this[i];if(!r)return n;if(r===!0)return V0S(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=_Oa(t),t){let i=er.findKey(this,t);return!!(i&&this[i]!==void 0&&(!r||z7s(this,this[i],i,r)))}return!1}delete(t,r){let i=this,n=!1;function a(o){if(o=_Oa(o),o){let c=er.findKey(i,o);c&&(!r||z7s(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||z7s(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]=F0o(n),delete r[a];return}let c=t?x0S(a):String(a).trim();c!==a&&delete r[a],r[c]=F0o(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[a8p]=this[a8p]={accessors:{}}).accessors,n=this.prototype;function a(o){let c=_Oa(o);i[c]||(G0S(n,o),i[c]=!0)}return er.isArray(t)?t.forEach(a):a(t),this}};STn.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]);er.reduceDescriptors(STn.prototype,({value:e},t)=>{let r=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(i){this[r]=i}}});er.freezeMethods(STn);var QS=STn;function hOa(e,t){let r=this||ETn,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 yOa(e){return!!(e&&e.__CANCEL__)}function o8p(e,t,r){ha.call(this,e??"canceled",ha.ERR_CANCELED,t,r),this.name="CanceledError"}er.inherits(o8p,ha,{__CANCEL__:!0});var the=o8p;function o6t(e,t,r){let i=r.config.validateStatus;!r.status||!i||i(r.status)?e(r):t(new ha("Request failed with status code "+r.status,[ha.ERR_BAD_REQUEST,ha.ERR_BAD_RESPONSE][Math.floor(r.status/100)-4],r.config,r.request,r))}function N7s(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function F7s(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}function $7i(e,t,r){let i=!N7s(t);return e&&(i||r==!1)?F7s(e,t):t}var m8p=ue(a0o(),1),P8p=ue(require("http"),1),j8p=ue(require("https"),1),w8p=ue(require("util"),1),E8p=ue(QGs(),1),Ubi=ue(require("zlib"),1);var Y7i="1.12.2";function bOa(e){let t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}var H0S=/^(?:([^;]+);)?(?:[^;]+;)?(base64|),([\s\S]*)$/;function Q7s(e,t,r){let i=r&&r.Blob||OA.classes.Blob,n=bOa(e);if(t===void 0&&i&&(t=!0),n==="data"){e=n.length?e.slice(n.length+1):e;let a=H0S.exec(e);if(!a)throw new ha("Invalid URL",ha.ERR_INVALID_URL);let o=a[1],c=a[2],f=a[3],s=Buffer.from(decodeURIComponent(f),c?"base64":"utf8");if(t){if(!i)throw new ha("Blob is not supported",ha.ERR_NOT_SUPPORT);return new i([s],{type:o})}return s}throw new ha("Unsupported protocol "+n,ha.ERR_NOT_SUPPORT)}var Z7i=ue(require("stream"),1);var u8p=ue(require("stream"),1);var U7s=Symbol("internals"),L7s=class extends u8p.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[U7s]={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[U7s];return r.onReadCallback&&r.onReadCallback(),super._read(t)}_transform(t,r,i){let n=this[U7s],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)})}},V7s=L7s;var S8p=require("events");var c8p=ue(require("util"),1),l8p=require("stream");var{asyncIterator:s8p}=Symbol,K0S=async function*(e){e.stream?yield*e.stream():e.arrayBuffer?yield await e.arrayBuffer():e[s8p]?yield*e[s8p]():yield e},Q0o=K0S;var J0S=OA.ALPHABET.ALPHA_DIGIT+"-_",vOa=typeof TextEncoder=="function"?new TextEncoder:new c8p.default.TextEncoder,X7i=`\r
1153
1153
  `,$0S=vOa.encode(X7i),Y0S=2,W7s=class{constructor(t,r){let{escapeName:i}=this.constructor,n=er.isString(r),a=`Content-Disposition: form-data; name="${i(t)}"${!n&&r.name?`; filename="${i(r.name)}"`:""}${X7i}`;n?r=vOa.encode(String(r).replace(/\r?\n|\r\n?/g,X7i)):a+=`Content-Type: ${r.type||"application/octet-stream"}${X7i}`,this.headers=vOa.encode(a+X7i),this.contentLength=n?r.byteLength:r.size,this.size=this.headers.byteLength+this.contentLength+Y0S,this.name=t,this.value=r}async*encode(){yield this.headers;let{value:t}=this;er.isTypedArray(t)?yield t:yield*Q0o(t),yield $0S}static escapeName(t){return String(t).replace(/[\r\n"]/g,r=>({"\r":"%0D","\n":"%0A",'"':"%22"})[r])}},X0S=(e,t,r)=>{let{tag:i="form-data-boundary",size:n=25,boundary:a=i+"-"+OA.generateString(n,J0S)}=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=vOa.encode("--"+a+X7i),c=vOa.encode("--"+a+"--"+X7i),f=c.byteLength,s=Array.from(e.entries()).map(([l,p])=>{let _=new W7s(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),l8p.Readable.from((async function*(){for(let l of s)yield o,yield*l.encode();yield c})())},f8p=X0S;var d8p=ue(require("stream"),1),x7s=class extends d8p.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)}},p8p=x7s;var Z0S=(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,_8p=Z0S;function k0S(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 h8p=k0S;function ePS(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 y8p=ePS;var Qbi=(e,t,r=3)=>{let i=0,n=h8p(50,250);return y8p(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)},MTn=(e,t)=>{let r=e!=null;return[i=>t[0]({lengthComputable:r,total:e,loaded:i}),t[1]]},DTn=e=>(...t)=>er.asap(()=>e(...t));function G7s(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 b8p={flush:Ubi.default.constants.Z_SYNC_FLUSH,finishFlush:Ubi.default.constants.Z_SYNC_FLUSH},tPS={flush:Ubi.default.constants.BROTLI_OPERATION_FLUSH,finishFlush:Ubi.default.constants.BROTLI_OPERATION_FLUSH},v8p=er.isFunction(Ubi.default.createBrotliDecompress),{http:rPS,https:iPS}=E8p.default,nPS=/https:?/,g8p=OA.protocols.map(e=>e+":"),O8p=(e,[t,r])=>(e.on("end",r).on("error",r),t);function aPS(e,t){e.beforeRedirects.proxy&&e.beforeRedirects.proxy(e),e.beforeRedirects.config&&e.beforeRedirects.config(e,t)}function M8p(e,t,r){let i=t;if(!i&&i!==!1){let n=m8p.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){M8p(a,t,a.href)}}var oPS=typeof process<"u"&&er.kindOf(process)==="process",uPS=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)}),sPS=({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)}},A8p=(e,t)=>sPS(er.isObject(e)?e:{address:e,family:t}),D8p=oPS&&function(t){return uPS(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=_8p(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=>A8p(Ke)):[A8p(Re,le)];pe.all?L(G,De):L(G,De[0].address,De[0].family)})}}let y=new S8p.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 the(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=$7i(t.baseURL,t.url,t.allowAbsoluteUrls),A=new URL(O,OA.hasBrowserEnv?OA.origin:void 0),g=A.protocol||g8p[0];if(g==="data:"){if(t.maxContentLength>-1){let fe=String(t.url||O||"");if(G7s(fe)>t.maxContentLength)return n(new ha("maxContentLength size of "+t.maxContentLength+" exceeded",ha.ERR_BAD_RESPONSE,t))}let K;if(l!=="GET")return o6t(i,n,{status:405,statusText:"method not allowed",headers:{},config:t});try{K=Q7s(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=Z7i.default.Readable.from(K)),o6t(i,n,{data:K,status:200,statusText:"OK",headers:new QS,config:t})}if(g8p.indexOf(g)===-1)return n(new ha("Unsupported protocol "+g,ha.ERR_BAD_REQUEST,t));let m=QS.from(t.headers).normalize();m.set("User-Agent","axios/"+Y7i,!1);let{onUploadProgress:j,onDownloadProgress:M}=t,E=t.maxRate,D,B;if(er.isSpecCompliantForm(o)){let K=m.getContentType(/boundary=([-_\w\d]{10,70})/i);o=f8p(o,fe=>{m.set(fe)},{tag:`axios-${Y7i}-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 w8p.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=Z7i.default.Readable.from(Q0o(o));else if(o&&!er.isStream(o)){if(!Buffer.isBuffer(o))if(er.isArrayBuffer(o))o=Buffer.from(new Uint8Array(o));else if(er.isString(o))o=Buffer.from(o,"utf-8");else return n(new ha("Data after transformation must be a string, an ArrayBuffer, a Buffer, or a Stream",ha.ERR_BAD_REQUEST,t));if(m.setContentLength(o.length,!1),t.maxBodyLength>-1&&o.length>t.maxBodyLength)return n(new ha("Request body larger than maxBodyLength limit",ha.ERR_BAD_REQUEST,t))}let F=er.toFiniteNumber(m.getContentLength());er.isArray(E)?(D=E[0],B=E[1]):D=B=E,o&&(j||D)&&(er.isStream(o)||(o=Z7i.default.Readable.from(o,{objectMode:!1})),o=Z7i.default.pipeline([o,new V7s({maxRate:er.toFiniteNumber(D)})],er.noop),j&&o.on("progress",O8p(o,MTn(F,Qbi(DTn(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=J7i(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"+(v8p?", 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:aPS,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,M8p(z,t.proxy,g+"//"+A.hostname+(A.port?":"+A.port:"")+z.path));let U,W=nPS.test(z.protocol);if(z.agent=W?t.httpsAgent:t.httpAgent,t.transport?U=t.transport:t.maxRedirects===0?U=W?j8p.default:P8p.default:(t.maxRedirects&&(z.maxRedirects=t.maxRedirects),t.beforeRedirect&&(z.beforeRedirects.config=t.beforeRedirect),U=W?iPS:rPS),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 V7s({maxRate:er.toFiniteNumber(B)});M&&Ke.on("progress",O8p(Ke,MTn(L,Qbi(DTn(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(Ubi.default.createUnzip(b8p)),delete fe.headers["content-encoding"];break;case"deflate":pe.push(new p8p),pe.push(Ubi.default.createUnzip(b8p)),delete fe.headers["content-encoding"];break;case"br":v8p&&(pe.push(Ubi.default.createBrotliDecompress(tPS)),delete fe.headers["content-encoding"])}G=pe.length>1?Z7i.default.pipeline(pe,er.noop):pe[0];let le=Z7i.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,o6t(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))}o6t(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||wTn;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 the("Request stream has been aborted",t,h))}),o.pipe(h)}else h.end(o)})};var B8p=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 I8p=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 C8p=e=>e instanceof QS?{...e}:e;function FNt(e,t){t=t||{};let r={};function i(s,u,l,p){return er.isPlainObject(s)&&er.isPlainObject(u)?er.merge.call({caseless:p},s,u):er.isPlainObject(u)?er.merge({},u):er.isArray(u)?u.slice():u}function n(s,u,l,p){if(er.isUndefined(u)){if(!er.isUndefined(s))return i(void 0,s,l,p)}else return i(s,u,l,p)}function a(s,u){if(!er.isUndefined(u))return i(void 0,u)}function o(s,u){if(er.isUndefined(u)){if(!er.isUndefined(s))return i(void 0,s)}else return i(void 0,u)}function c(s,u,l){if(l in t)return i(s,u);if(l in e)return i(void 0,s)}let f={url:a,method:a,data:a,baseURL:o,transformRequest:o,transformResponse:o,paramsSerializer:o,timeout:o,timeoutMessage:o,withCredentials:o,withXSRFToken:o,adapter:o,responseType:o,xsrfCookieName:o,xsrfHeaderName:o,onUploadProgress:o,onDownloadProgress:o,decompress:o,maxContentLength:o,maxBodyLength:o,beforeRedirect:o,transport:o,httpAgent:o,httpsAgent:o,cancelToken:o,socketPath:o,responseEncoding:o,validateStatus:c,headers:(s,u,l)=>n(C8p(s),C8p(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 U0o=e=>{let t=FNt({},e),{data:r,withXSRFToken:i,xsrfHeaderName:n,xsrfCookieName:a,headers:o,auth:c}=t;if(t.headers=o=QS.from(o),t.url=J7i($7i(t.baseURL,t.url,t.allowAbsoluteUrls),e.params,e.paramsSerializer),c&&o.set("Authorization","Basic "+btoa((c.username||"")+":"+(c.password?unescape(encodeURIComponent(c.password)):""))),er.isFormData(r)){if(OA.hasStandardBrowserEnv||OA.hasStandardBrowserWebWorkerEnv)o.setContentType(void 0);else if(er.isFunction(r.getHeaders)){let f=r.getHeaders(),s=["content-type","content-length"];Object.entries(f).forEach(([u,l])=>{s.includes(u.toLowerCase())&&o.set(u,l)})}}if(OA.hasStandardBrowserEnv&&(i&&er.isFunction(i)&&(i=i(t)),i||i!==!1&&B8p(t.url))){let f=n&&a&&I8p.read(a);f&&o.set(n,f)}return t};var cPS=typeof XMLHttpRequest<"u",q8p=cPS&&function(e){return new Promise(function(r,i){let n=U0o(e),a=n.data,o=QS.from(n.headers).normalize(),{responseType:c,onUploadProgress:f,onDownloadProgress:s}=n,u,l,p,_,h;function y(){_&&_(),h&&h(),n.cancelToken&&n.cancelToken.unsubscribe(u),n.signal&&n.signal.removeEventListener("abort",u)}let b=new XMLHttpRequest;b.open(n.method.toUpperCase(),n.url,!0),b.timeout=n.timeout;function v(){if(!b)return;let A=QS.from("getAllResponseHeaders"in b&&b.getAllResponseHeaders()),m={data:!c||c==="text"||c==="json"?b.responseText:b.response,status:b.status,statusText:b.statusText,headers:A,config:e,request:b};o6t(function(M){r(M),y()},function(M){i(M),y()},m),b=null}"onloadend"in b?b.onloadend=v:b.onreadystatechange=function(){!b||b.readyState!==4||b.status===0&&!(b.responseURL&&b.responseURL.indexOf("file:")===0)||setTimeout(v)},b.onabort=function(){b&&(i(new ha("Request aborted",ha.ECONNABORTED,e,b)),b=null)},b.onerror=function(g){let m=g&&g.message?g.message:"Network Error",j=new ha(m,ha.ERR_NETWORK,e,b);j.event=g||null,i(j),b=null},b.ontimeout=function(){let g=n.timeout?"timeout of "+n.timeout+"ms exceeded":"timeout exceeded",m=n.transitional||wTn;n.timeoutErrorMessage&&(g=n.timeoutErrorMessage),i(new ha(g,m.clarifyTimeoutError?ha.ETIMEDOUT:ha.ECONNABORTED,e,b)),b=null},a===void 0&&o.setContentType(null),"setRequestHeader"in b&&er.forEach(o.toJSON(),function(g,m){b.setRequestHeader(m,g)}),er.isUndefined(n.withCredentials)||(b.withCredentials=!!n.withCredentials),c&&c!=="json"&&(b.responseType=n.responseType),s&&([p,h]=Qbi(s,!0),b.addEventListener("progress",p)),f&&b.upload&&([l,_]=Qbi(f),b.upload.addEventListener("progress",l),b.upload.addEventListener("loadend",_)),(n.cancelToken||n.signal)&&(u=A=>{b&&(i(!A||A.type?new the(null,e,b):A),b.abort(),b=null)},n.cancelToken&&n.cancelToken.subscribe(u),n.signal&&(n.signal.aborted?u():n.signal.addEventListener("abort",u)));let O=bOa(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 lPS=(e,t)=>{let{length:r}=e=e?e.filter(Boolean):[];if(t||r){let i=new AbortController,n,a=function(s){if(!n){n=!0,c();let u=s instanceof Error?s:this.reason;i.abort(u instanceof ha?u:new the(u instanceof Error?u.message:u))}},o=t&&setTimeout(()=>{o=null,a(new ha(`timeout ${t} of ms exceeded`,ha.ETIMEDOUT))},t),c=()=>{e&&(o&&clearTimeout(o),o=null,e.forEach(s=>{s.unsubscribe?s.unsubscribe(a):s.removeEventListener("abort",a)}),e=null)};e.forEach(s=>s.addEventListener("abort",a));let{signal:f}=i;return f.unsubscribe=()=>er.asap(c),f}},T8p=lPS;var fPS=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},dPS=async function*(e,t){for await(let r of pPS(e))yield*fPS(r,t)},pPS=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()}},H7s=(e,t,r,i)=>{let n=dPS(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 R8p=64*1024,{isFunction:L0o}=er,_PS=(({Request:e,Response:t})=>({Request:e,Response:t}))(er.global),{ReadableStream:z8p,TextEncoder:N8p}=er.global,F8p=(e,...t)=>{try{return!!e(...t)}catch{return!1}},hPS=e=>{e=er.merge.call({skipUndefined:!0},_PS,e);let{fetch:t,Request:r,Response:i}=e,n=t?L0o(t):typeof fetch=="function",a=L0o(r),o=L0o(i);if(!n)return!1;let c=n&&L0o(z8p),f=n&&(typeof N8p=="function"?(h=>y=>h.encode(y))(new N8p):async h=>new Uint8Array(await new r(h).arrayBuffer())),s=a&&c&&F8p(()=>{let h=!1,y=new r(OA.origin,{body:new z8p,method:"POST",get duplex(){return h=!0,"half"}}).headers.has("Content-Type");return h&&!y}),u=o&&c&&F8p(()=>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}=U0o(h),F=t||fetch;M=M?(M+"").toLowerCase():"text";let N=T8p([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]=MTn(U,Qbi(DTn(j)));v=H7s(G.body,R8p,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&&MTn(Re,Qbi(DTn(m),!0))||[];fe=new i(H7s(fe.body,R8p,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)=>{o6t(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)}}},yPS=new Map,K7s=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=yPS;for(;c--;)f=a[c],s=u.get(f),s===void 0&&u.set(f,s=c?new Map:hPS(t)),u=s;return s},cg5=K7s();var J7s={http:D8p,xhr:q8p,fetch:{get:K7s}};er.forEach(J7s,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});var Q8p=e=>`- ${e}`,vPS=e=>er.isFunction(e)||e===null||e===!1,V0o={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,!vPS(i)&&(n=J7s[(c=String(i)).toLowerCase()],n===void 0))throw new ha(`Unknown adapter '${c}'`);if(n&&(er.isFunction(n)||(n=n.get(t))))break;a[c||"#"+o]=n}if(!n){let o=Object.entries(a).map(([f,s])=>`adapter ${f} `+(s===!1?"is not supported by the environment":"is not available in the build")),c=r?o.length>1?`since :
@@ -1391,7 +1391,7 @@ ${g}${O}${m}${AQn}`});function BQo({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.`),QBi(r,{padding:1,float:"center",textAlignment:"center",borderColor:"yellow",borderStyle:"round"})}async function Duc({generatorUpgradeInfo:e,header:t,limit:r,includeBoxen:i=!0}){if(!If_(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 nZS(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?QBi(n,{padding:1,float:"center",textAlignment:"center",borderColor:"yellow",borderStyle:"round"}):n}async function nZS(e){let r=await new Bf_.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 aZS({cliContext:e,project:{apiWorkspaces:t},generatorFilter:r,groupFilter:i,channel:n,includeMajor:a}){if(t.length===1){let c={type:"singleApi",versions:{}};return await qf_({cliContext:e,apiWorkspaces:t,perGeneratorAction:async(f,s,u,l)=>{c.versions[s]==null&&(c.versions[s]={});let p=NMi(u.name,l),_=await dNt({generatorName:p,cliVersion:e.environment.packageVersion,currentGeneratorVersion:u.version,channel:n,includeMajor:a,context:l});_!=null&&(c.versions[s][u.name]={previousVersion:u.version,latestVersion:_})},generatorFilter:r,groupFilter:i}),c}let o={type:"multiApi",versions:{}};return await qf_({cliContext:e,apiWorkspaces:t,perGeneratorAction:async(c,f,s,u)=>{if(c==null)return;o.versions[c]==null&&(o.versions[c]={}),o.versions[c][f]==null&&(o.versions[c][f]={});let l=NMi(s.name,u),p=await dNt({generatorName:l,cliVersion:e.environment.packageVersion,currentGeneratorVersion:s.version,channel:n,includeMajor:a,context:u});p!=null&&(o.versions[c][f][s.name]={previousVersion:s.version,latestVersion:p})},generatorFilter:r,groupFilter:i}),o}async function qf_({cliContext:e,apiWorkspaces:t,perGeneratorAction:r,generatorFilter:i,groupFilter:n}){await Promise.all(t.map(async a=>{await e.runTaskForWorkspace(a,async o=>{let c=await $_e({absolutePathToWorkspace:a.absoluteFilePath,context:o});if(!(c==null||c.groups==null)){for(let f of c.groups)if(!(n!=null&&f.groupName!==n))for(let s of f.generators)i!=null&&s.name!==i||await r(a.workspaceName,f.groupName,s,o)}})}))}function Tf_(e,t,r){let i=[];for(let[n,a]of Object.entries(e))for(let[o,c]of Object.entries(a)){r.debug(`Checking if ${o} in group ${n} has an upgrade available...`);let f=kH(c.latestVersion,c.previousVersion);r.debug(`Latest version: ${c.latestVersion}. `+(f?"Upgrade available.":"No upgrade available.")),i.push({generatorName:o,generatorGroup:n,apiName:t,isUpgradeAvailable:f,currentVersion:c.previousVersion,latestVersion:c.latestVersion})}return i}async function TQo({project:e,cliContext:t,generatorFilter:r,groupFilter:i,channel:n,includeMajor:a}){let o=[];if(e!=null){let c=await aZS({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(...Tf_(s,f,t.logger));else o.push(...Tf_(c.versions,void 0,t.logger))}return o}var IPa=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 wQn=class extends Error{request;constructor(t){super(`Request timed out: ${t.method} ${t.url}`),this.name="TimeoutError",this.request=t}};var Buc=(()=>{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})(),Rf_=typeof globalThis.AbortController=="function",zf_=typeof globalThis.AbortSignal=="function"&&typeof globalThis.AbortSignal.any=="function",Nf_=typeof globalThis.ReadableStream=="function",Ff_=typeof globalThis.FormData=="function",RQo=["get","post","put","patch","head","delete"],oZS=()=>{};oZS();var Qf_={json:"application/json",text:"text/*",formData:"multipart/form-data",arrayBuffer:"*/*",blob:"*/*",bytes:"*/*"},zQo=2147483647,Uf_=new TextEncoder().encode("------WebKitFormBoundaryaxpyiPgbbPti10Rw").length,NQo=Symbol("stop"),Lf_={json:!0,parseJson:!0,stringifyJson:!0,searchParams:!0,prefixUrl:!0,retry:!0,timeout:!0,hooks:!0,throwHttpErrors:!0,onDownloadProgress:!0,onUploadProgress:!0,fetch:!0},Vf_={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 uZS=e=>{if(!e)return 0;if(e instanceof FormData){let t=0;for(let[r,i]of e)t+=Uf_,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},Wf_=(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))}}))},xf_=(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(Wf_(e.body,r,t),{status:e.status,statusText:e.statusText,headers:e.headers})},Gf_=(e,t,r)=>{if(!e.body)return e;let i=uZS(r??e.body);return new Request(e,{duplex:"half",body:Wf_(e.body,i,t)})};var EQn=e=>e!==null&&typeof e=="object";var CPa=(...e)=>{for(let t of e)if((!EQn(t)||Array.isArray(t))&&t!==void 0)throw new TypeError("The `options` argument must be an object");return quc({},...e)},Iuc=(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 FQo(e,t,r){return Object.hasOwn(t,r)&&t[r]===void 0?[]:quc(e[r]??[],t[r]??[])}var Cuc=(e={},t={})=>({beforeRequest:FQo(e,t,"beforeRequest"),beforeRetry:FQo(e,t,"beforeRetry"),afterResponse:FQo(e,t,"afterResponse"),beforeError:FQo(e,t,"beforeError")}),quc=(...e)=>{let t={},r={},i={};for(let n of e)if(Array.isArray(n))Array.isArray(t)||(t=[]),t=[...t,...n];else if(EQn(n)){for(let[a,o]of Object.entries(n))EQn(o)&&a in t&&(o=quc(t[a],o)),t={...t,[a]:o};EQn(n.hooks)&&(i=Cuc(i,n.hooks),t.hooks=i),EQn(n.headers)&&(r=Iuc(r,n.headers),t.headers=r)}return t};var Kf_=e=>RQo.includes(e)?e.toUpperCase():e,sZS=["get","put","head","delete","options","trace"],cZS=[408,413,429,500,502,503,504],lZS=[413,429,503],Hf_={limit:2,methods:sZS,statusCodes:cZS,afterStatusCodes:lZS,maxRetryAfter:Number.POSITIVE_INFINITY,backoffLimit:Number.POSITIVE_INFINITY,delay:e=>.3*2**(e-1)*1e3},Jf_=(e={})=>{if(typeof e=="number")return{...Hf_,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{...Hf_,...e}};async function Tuc(e,t,r,i){return new Promise((n,a)=>{let o=setTimeout(()=>{r&&r.abort(),a(new wQn(e))},i.timeout);i.fetch(e,t).then(n).catch(a).then(()=>{clearTimeout(o)})})}async function Ruc(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 $f_=(e,t)=>{let r={};for(let i in t)!(i in Vf_)&&!(i in Lf_)&&!(i in e)&&(r[i]=t[i]);return r},Yf_=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 qPa=class e{static create(t,r){let i=new e(t,r),n=async()=>{if(typeof i._options.timeout=="number"&&i._options.timeout>zQo)throw new RangeError(`The \`timeout\` option cannot be greater than ${zQo}`);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 IPa(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(!Nf_)throw new Error("Streams are not supported in your environment. `ReadableStream` is missing.");return xf_(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(Qf_))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:Iuc(this._input.headers,r.headers),hooks:Cuc({beforeRequest:[],beforeRetry:[],beforeError:[],afterResponse:[]},r.hooks),method:Kf_(r.method??this._input.method??"GET"),prefixUrl:String(r.prefixUrl||""),retry:Jf_(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(Rf_&&zf_){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(Buc&&(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),Yf_(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);(Ff_&&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(!Buc)throw new Error("Request streams are not supported in your environment. The `duplex` option for `Request` is not available.");this.request.body&&(this.request=Gf_(this.request,this._options.onUploadProgress,this._options.body))}}_calculateRetryDelay(t){if(this._retryCount++,this._retryCount>this._options.retry.limit||t instanceof wQn)throw t;if(t instanceof IPa){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),zQo);if(this._retryCount<1)throw r;await Ruc(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})===NQo)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=$f_(this.request,this._options);return this._originalRequest=this.request,this.request=this._originalRequest.clone(),this._options.timeout===!1?this._options.fetch(this._originalRequest,t):Tuc(this._originalRequest,t,this.abortController,this._options)}};var zuc=e=>{let t=(r,i)=>qPa.create(r,CPa(e,i));for(let r of RQo)t[r]=(i,n)=>qPa.create(i,CPa(e,n,{method:r}));return t.create=r=>zuc(CPa(r)),t.extend=r=>(typeof r=="function"&&(r=r(e??{})),zuc(CPa(e,r))),t.stop=NQo,t},fZS=zuc(),Xf_=fZS;var Od_=ue(gd_(),1);function Luc(e){let t=(0,Od_.default)("npm",{registry:"https://registry.npmjs.org/"}),r=t[`${e}:registry`]||t.config_registry||t.registry;return r.slice(-1)==="/"?r:`${r}/`}var _p_=ue(pp_(),1),hp_=ue(m_e(),1),esc=class extends Error{constructor(t){super(`Package \`${t}\` could not be found`),this.name="PackageNotFoundError"}},tsc=class extends Error{constructor(t,r){super(`Version \`${r}\` for package \`${t}\` could not be found`),this.name="VersionNotFoundError"}};async function rsc(e,t={}){let{version:r="latest"}=t,{omitDeprecated:i=!0}=t,n=e.split("/")[0],a=t.registryUrl??Luc(n),o=new URL(encodeURIComponent(e).replace(/^%40/,"@"),a),c=(0,_p_.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 Xf_(o,{headers:f,keepalive:!0}).json()}catch(l){throw l?.response?.status===404?new esc(e):l}if(t.allVersions)return s;let u=new tsc(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=hp_.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 QPa(e,t){let{version:r}=await rsc(e.toLowerCase(),t);return r}async function qCi({cliEnvironment:e,includePreReleases:t=!1}){return e.packageName!=="fern-api"?e.packageVersion:QPa(e.packageName,{version:t?"prerelease":"latest"})}var yp_=["#2E86AB","#A23B72","#F18F01","#C73E1D","#CCE2A3"],YQo=class{environment;didSucceed=!0;numTasks=0;ttyAwareLogger;logLevel=$s.Info;isLocal;constructor(t,r,{isLocal:i}){this.ttyAwareLogger=new qQo(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.22.2"}getCliName(){return"fern"}setLogLevel(t){this.logLevel=t}logFernVersionDebug(){this.logger.debug(`Running ${Ut.bold(`${this.environment.cliName}`)} (${this.environment.packageName}@${this.environment.packageVersion})`)}failAndThrow(t,r){throw this.failWithoutThrowing(t,r),new TE}failWithoutThrowing(t,r){this.didSucceed=!1,BQo({message:t,error:r,logger:this.logger})}async exit({code:t}={}){!this._suppressUpgradeMessage&&!this.isLocal&&await this.nudgeUpgradeIfAvailable(),this.ttyAwareLogger.finish(),await(await ATn()).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 Cf_({cliEnvironment:this.environment,upgradeInfo:t});r!=null&&(r.endsWith(`
1394
+ `,i?QBi(n,{padding:1,float:"center",textAlignment:"center",borderColor:"yellow",borderStyle:"round"}):n}async function nZS(e){let r=await new Bf_.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 aZS({cliContext:e,project:{apiWorkspaces:t},generatorFilter:r,groupFilter:i,channel:n,includeMajor:a}){if(t.length===1){let c={type:"singleApi",versions:{}};return await qf_({cliContext:e,apiWorkspaces:t,perGeneratorAction:async(f,s,u,l)=>{c.versions[s]==null&&(c.versions[s]={});let p=NMi(u.name,l),_=await dNt({generatorName:p,cliVersion:e.environment.packageVersion,currentGeneratorVersion:u.version,channel:n,includeMajor:a,context:l});_!=null&&(c.versions[s][u.name]={previousVersion:u.version,latestVersion:_})},generatorFilter:r,groupFilter:i}),c}let o={type:"multiApi",versions:{}};return await qf_({cliContext:e,apiWorkspaces:t,perGeneratorAction:async(c,f,s,u)=>{if(c==null)return;o.versions[c]==null&&(o.versions[c]={}),o.versions[c][f]==null&&(o.versions[c][f]={});let l=NMi(s.name,u),p=await dNt({generatorName:l,cliVersion:e.environment.packageVersion,currentGeneratorVersion:s.version,channel:n,includeMajor:a,context:u});p!=null&&(o.versions[c][f][s.name]={previousVersion:s.version,latestVersion:p})},generatorFilter:r,groupFilter:i}),o}async function qf_({cliContext:e,apiWorkspaces:t,perGeneratorAction:r,generatorFilter:i,groupFilter:n}){await Promise.all(t.map(async a=>{await e.runTaskForWorkspace(a,async o=>{let c=await $_e({absolutePathToWorkspace:a.absoluteFilePath,context:o});if(!(c==null||c.groups==null)){for(let f of c.groups)if(!(n!=null&&f.groupName!==n))for(let s of f.generators)i!=null&&s.name!==i||await r(a.workspaceName,f.groupName,s,o)}})}))}function Tf_(e,t,r){let i=[];for(let[n,a]of Object.entries(e))for(let[o,c]of Object.entries(a)){r.debug(`Checking if ${o} in group ${n} has an upgrade available...`);let f=kH(c.latestVersion,c.previousVersion);r.debug(`Latest version: ${c.latestVersion}. `+(f?"Upgrade available.":"No upgrade available.")),i.push({generatorName:o,generatorGroup:n,apiName:t,isUpgradeAvailable:f,currentVersion:c.previousVersion,latestVersion:c.latestVersion})}return i}async function TQo({project:e,cliContext:t,generatorFilter:r,groupFilter:i,channel:n,includeMajor:a}){let o=[];if(e!=null){let c=await aZS({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(...Tf_(s,f,t.logger));else o.push(...Tf_(c.versions,void 0,t.logger))}return o}var IPa=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 wQn=class extends Error{request;constructor(t){super(`Request timed out: ${t.method} ${t.url}`),this.name="TimeoutError",this.request=t}};var Buc=(()=>{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})(),Rf_=typeof globalThis.AbortController=="function",zf_=typeof globalThis.AbortSignal=="function"&&typeof globalThis.AbortSignal.any=="function",Nf_=typeof globalThis.ReadableStream=="function",Ff_=typeof globalThis.FormData=="function",RQo=["get","post","put","patch","head","delete"],oZS=()=>{};oZS();var Qf_={json:"application/json",text:"text/*",formData:"multipart/form-data",arrayBuffer:"*/*",blob:"*/*",bytes:"*/*"},zQo=2147483647,Uf_=new TextEncoder().encode("------WebKitFormBoundaryaxpyiPgbbPti10Rw").length,NQo=Symbol("stop"),Lf_={json:!0,parseJson:!0,stringifyJson:!0,searchParams:!0,prefixUrl:!0,retry:!0,timeout:!0,hooks:!0,throwHttpErrors:!0,onDownloadProgress:!0,onUploadProgress:!0,fetch:!0},Vf_={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 uZS=e=>{if(!e)return 0;if(e instanceof FormData){let t=0;for(let[r,i]of e)t+=Uf_,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},Wf_=(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))}}))},xf_=(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(Wf_(e.body,r,t),{status:e.status,statusText:e.statusText,headers:e.headers})},Gf_=(e,t,r)=>{if(!e.body)return e;let i=uZS(r??e.body);return new Request(e,{duplex:"half",body:Wf_(e.body,i,t)})};var EQn=e=>e!==null&&typeof e=="object";var CPa=(...e)=>{for(let t of e)if((!EQn(t)||Array.isArray(t))&&t!==void 0)throw new TypeError("The `options` argument must be an object");return quc({},...e)},Iuc=(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 FQo(e,t,r){return Object.hasOwn(t,r)&&t[r]===void 0?[]:quc(e[r]??[],t[r]??[])}var Cuc=(e={},t={})=>({beforeRequest:FQo(e,t,"beforeRequest"),beforeRetry:FQo(e,t,"beforeRetry"),afterResponse:FQo(e,t,"afterResponse"),beforeError:FQo(e,t,"beforeError")}),quc=(...e)=>{let t={},r={},i={};for(let n of e)if(Array.isArray(n))Array.isArray(t)||(t=[]),t=[...t,...n];else if(EQn(n)){for(let[a,o]of Object.entries(n))EQn(o)&&a in t&&(o=quc(t[a],o)),t={...t,[a]:o};EQn(n.hooks)&&(i=Cuc(i,n.hooks),t.hooks=i),EQn(n.headers)&&(r=Iuc(r,n.headers),t.headers=r)}return t};var Kf_=e=>RQo.includes(e)?e.toUpperCase():e,sZS=["get","put","head","delete","options","trace"],cZS=[408,413,429,500,502,503,504],lZS=[413,429,503],Hf_={limit:2,methods:sZS,statusCodes:cZS,afterStatusCodes:lZS,maxRetryAfter:Number.POSITIVE_INFINITY,backoffLimit:Number.POSITIVE_INFINITY,delay:e=>.3*2**(e-1)*1e3},Jf_=(e={})=>{if(typeof e=="number")return{...Hf_,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{...Hf_,...e}};async function Tuc(e,t,r,i){return new Promise((n,a)=>{let o=setTimeout(()=>{r&&r.abort(),a(new wQn(e))},i.timeout);i.fetch(e,t).then(n).catch(a).then(()=>{clearTimeout(o)})})}async function Ruc(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 $f_=(e,t)=>{let r={};for(let i in t)!(i in Vf_)&&!(i in Lf_)&&!(i in e)&&(r[i]=t[i]);return r},Yf_=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 qPa=class e{static create(t,r){let i=new e(t,r),n=async()=>{if(typeof i._options.timeout=="number"&&i._options.timeout>zQo)throw new RangeError(`The \`timeout\` option cannot be greater than ${zQo}`);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 IPa(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(!Nf_)throw new Error("Streams are not supported in your environment. `ReadableStream` is missing.");return xf_(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(Qf_))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:Iuc(this._input.headers,r.headers),hooks:Cuc({beforeRequest:[],beforeRetry:[],beforeError:[],afterResponse:[]},r.hooks),method:Kf_(r.method??this._input.method??"GET"),prefixUrl:String(r.prefixUrl||""),retry:Jf_(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(Rf_&&zf_){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(Buc&&(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),Yf_(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);(Ff_&&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(!Buc)throw new Error("Request streams are not supported in your environment. The `duplex` option for `Request` is not available.");this.request.body&&(this.request=Gf_(this.request,this._options.onUploadProgress,this._options.body))}}_calculateRetryDelay(t){if(this._retryCount++,this._retryCount>this._options.retry.limit||t instanceof wQn)throw t;if(t instanceof IPa){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),zQo);if(this._retryCount<1)throw r;await Ruc(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})===NQo)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=$f_(this.request,this._options);return this._originalRequest=this.request,this.request=this._originalRequest.clone(),this._options.timeout===!1?this._options.fetch(this._originalRequest,t):Tuc(this._originalRequest,t,this.abortController,this._options)}};var zuc=e=>{let t=(r,i)=>qPa.create(r,CPa(e,i));for(let r of RQo)t[r]=(i,n)=>qPa.create(i,CPa(e,n,{method:r}));return t.create=r=>zuc(CPa(r)),t.extend=r=>(typeof r=="function"&&(r=r(e??{})),zuc(CPa(e,r))),t.stop=NQo,t},fZS=zuc(),Xf_=fZS;var Od_=ue(gd_(),1);function Luc(e){let t=(0,Od_.default)("npm",{registry:"https://registry.npmjs.org/"}),r=t[`${e}:registry`]||t.config_registry||t.registry;return r.slice(-1)==="/"?r:`${r}/`}var _p_=ue(pp_(),1),hp_=ue(m_e(),1),esc=class extends Error{constructor(t){super(`Package \`${t}\` could not be found`),this.name="PackageNotFoundError"}},tsc=class extends Error{constructor(t,r){super(`Version \`${r}\` for package \`${t}\` could not be found`),this.name="VersionNotFoundError"}};async function rsc(e,t={}){let{version:r="latest"}=t,{omitDeprecated:i=!0}=t,n=e.split("/")[0],a=t.registryUrl??Luc(n),o=new URL(encodeURIComponent(e).replace(/^%40/,"@"),a),c=(0,_p_.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 Xf_(o,{headers:f,keepalive:!0}).json()}catch(l){throw l?.response?.status===404?new esc(e):l}if(t.allVersions)return s;let u=new tsc(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=hp_.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 QPa(e,t){let{version:r}=await rsc(e.toLowerCase(),t);return r}async function qCi({cliEnvironment:e,includePreReleases:t=!1}){return e.packageName!=="fern-api"?e.packageVersion:QPa(e.packageName,{version:t?"prerelease":"latest"})}var yp_=["#2E86AB","#A23B72","#F18F01","#C73E1D","#CCE2A3"],YQo=class{environment;didSucceed=!0;numTasks=0;ttyAwareLogger;logLevel=$s.Info;isLocal;constructor(t,r,{isLocal:i}){this.ttyAwareLogger=new qQo(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.22.3"}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,BQo({message:t,error:r,logger:this.logger})}async exit({code:t}={}){!this._suppressUpgradeMessage&&!this.isLocal&&await this.nudgeUpgradeIfAvailable(),this.ttyAwareLogger.finish(),await(await ATn()).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 Cf_({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=sws(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 wPa(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 ATn()).sendEvent(t)}logger=$8t((t,...r)=>this.log(t,...r));stderr=$8t((t,...r)=>this.logStderr(t,...r));constructTaskInitForWorkspace(t){let r=bp_(t.type==="docs"?"docs":t.workspaceName??"api"),i=1+(this.longestWorkspaceName!=null?bp_(this.longestWorkspaceName):r).length,n=r.padEnd(i),a=yp_[this.numTasks++%yp_.length],o=Ut.hex(a)(n);return{...this.constructTaskInit(),logPrefix:o}}constructTaskInit(){return{logImmediately:t=>this.logImmediately(t),takeOverTerminal:t=>this.ttyAwareLogger.takeOverTerminal(t),onResult:t=>{t===yj.Failure&&(this.didSucceed=!1)},instrumentPostHogEvent:async t=>{await this.instrumentPostHogEvent(t)},shouldBufferLogs:!1}}log(t,...r){this.logImmediately([{parts:r,level:t,time:new Date}])}logStderr(t,...r){this.logImmediately([{parts:r,level:t,time:new Date}],{stderr:!0})}logImmediately(t,{stderr:r=!1}={}){let i=t.filter(n=>aMi.indexOf(n.level)>=aMi.indexOf(this.logLevel));this.ttyAwareLogger.log(i,{includeDebugInfo:this.logLevel===$s.Debug,stderr:r})}_suppressUpgradeMessage=!1;suppressUpgradeMessage(){this._suppressUpgradeMessage=!0}_isUpgradeAvailable;async isUpgradeAvailable({includePreReleases:t=!1}={}){if(this._isUpgradeAvailable==null){this.logger.debug(`Checking if ${this.environment.packageName} upgrade is available...`);let r=await qCi({cliEnvironment:this.environment,includePreReleases:t}),i=kH(r,this.environment.packageVersion);this.logger.debug(`Latest version: ${r}. `+(i?"Upgrade available.":"No upgrade available."));let n={isUpgradeAvailable:i,latestVersion:r},a=await TQo({project:this.project,cliContext:this});this._isUpgradeAvailable={cliUpgradeInfo:n,generatorUpgradeInfo:a}}return this._isUpgradeAvailable}async confirmPrompt(t,r=!1){try{return await buc({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 puc({message:t.message,default:t.default})}};function bp_(e){return`[${e}]:`}var hFt=class{generatorsConfiguration;workspaceName;cliVersion;absoluteFilePath;changelog;constructor({generatorsConfiguration:t,workspaceName:r,cliVersion:i,absoluteFilePath:n,changelog:a}){this.generatorsConfiguration=t,this.workspaceName=r,this.cliVersion=i,this.absoluteFilePath=n,this.changelog=a}};function XQo(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)=>XQo.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 vp_(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 gp_(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 Op_=Function.bind,Ap_=Op_.bind(Op_);function mp_(e,t,r){let i=Ap_(gp_,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]=Ap_(vp_,null).apply(null,a)})}function b2S(){let e=Symbol("Singular"),t={registry:{}},r=XQo.bind(null,t,e);return mp_(r,t,e),r}function v2S(){let e={registry:{}},t=XQo.bind(null,e);return mp_(t,e),t}var Pp_={Singular:b2S,Collection:v2S};var g2S="0.0.0-development",O2S=`octokit-endpoint.js/${g2S} ${qR()}`,A2S={method:"GET",baseUrl:"https://api.github.com",headers:{accept:"application/vnd.github.v3+json","user-agent":O2S},mediaType:{format:""}};function m2S(e){return e?Object.keys(e).reduce((t,r)=>(t[r.toLowerCase()]=e[r],t),{}):{}}function P2S(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 Ep_(e,t){let r=Object.assign({},e);return Object.keys(t).forEach(i=>{P2S(t[i])?i in e?r[i]=Ep_(e[i],t[i]):Object.assign(r,{[i]:t[i]}):Object.assign(r,{[i]:t[i]})}),r}function jp_(e){for(let t in e)e[t]===void 0&&delete e[t];return e}function nsc(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=m2S(r.headers),jp_(r),jp_(r.headers);let i=Ep_(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 j2S(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 w2S=/\{[^{}}]+\}/g;function E2S(e){return e.replace(/(?:^\W+)|(?:(?<!\W)\W+$)/g,"").split(/,/)}function S2S(e){let t=e.match(w2S);return t?t.map(E2S).reduce((r,i)=>r.concat(i),[]):[]}function wp_(e,t){let r={__proto__:null};for(let i of Object.keys(e))t.indexOf(i)===-1&&(r[i]=e[i]);return r}function Sp_(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 TQn(e){return encodeURIComponent(e).replace(/[!'()*]/g,function(t){return"%"+t.charCodeAt(0).toString(16).toUpperCase()})}function UPa(e,t,r){return t=e==="+"||e==="#"?Sp_(t):TQn(t),r?TQn(r)+"="+t:t}function qQn(e){return e!=null}function isc(e){return e===";"||e==="&"||e==="?"}function M2S(e,t,r,i){var n=e[r],a=[];if(qQn(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(UPa(t,n,isc(t)?r:""));else if(i==="*")Array.isArray(n)?n.filter(qQn).forEach(function(o){a.push(UPa(t,o,isc(t)?r:""))}):Object.keys(n).forEach(function(o){qQn(n[o])&&a.push(UPa(t,n[o],o))});else{let o=[];Array.isArray(n)?n.filter(qQn).forEach(function(c){o.push(UPa(t,c))}):Object.keys(n).forEach(function(c){qQn(n[c])&&(o.push(TQn(c)),o.push(UPa(t,n[c].toString())))}),isc(t)?a.push(TQn(r)+"="+o.join(",")):o.length!==0&&a.push(o.join(","))}else t===";"?qQn(n)&&a.push(TQn(r)):n===""&&(t==="&"||t==="?")?a.push(TQn(r)+"="):n===""&&a.push("");return a}function D2S(e){return{expand:B2S.bind(null,e)}}function B2S(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(M2S(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 Sp_(a)}),e==="/"?e:e.replace(/\/$/,"")}function Mp_(e){let t=e.method.toUpperCase(),r=(e.url||"/").replace(/:([a-z]\w+)/g,"{$1}"),i=Object.assign({},e.headers),n,a=wp_(e,["method","baseUrl","url","headers","request","mediaType"]),o=S2S(r);r=D2S(r).expand(a),/^http/.test(r)||(r=e.baseUrl+r);let c=Object.keys(e).filter(u=>o.includes(u)).concat("baseUrl"),f=wp_(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=j2S(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 I2S(e,t,r){return Mp_(nsc(e,t,r))}function Dp_(e,t){let r=nsc(e,t),i=I2S.bind(null,r);return Object.assign(i,{DEFAULTS:r,defaults:Dp_.bind(null,r),merge:nsc.bind(null,r),parse:Mp_})}var Bp_=Dp_(null,A2S);var zp_=ue(Tp_(),1);var yFt=class extends Error{name;status;request;response;constructor(t,r,i){super(t),this.name="HttpError",this.status=Number.parseInt(r),Number.isNaN(this.status)&&(this.status=0),"response"in i&&(this.response=i.response);let n=Object.assign({},i.request);i.request.headers.authorization&&(n.headers=Object.assign({},i.request.headers,{authorization:i.request.headers.authorization.replace(/(?<! ) .*$/," [REDACTED]")})),n.url=n.url.replace(/\bclient_secret=\w+/g,"client_secret=[REDACTED]").replace(/\baccess_token=\w+/g,"access_token=[REDACTED]"),this.request=n}};var C2S="10.0.6",q2S={headers:{"user-agent":`octokit-request.js/${C2S} ${qR()}`}};function T2S(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 Rp_(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=T2S(e.body)||Array.isArray(e.body)?JSON.stringify(e.body):e.body,a=Object.fromEntries(Object.entries(e.headers).map(([l,p])=>[l,String(p)])),o;try{o=await t(e.url,{method:e.method,body:n,redirect:e.request?.redirect,headers:a,signal:e.request?.signal,...e.body&&{duplex:"half"}})}catch(l){let p="Unknown Error";if(l instanceof Error){if(l.name==="AbortError")throw l.status=500,l;p=l.message,l.name==="TypeError"&&"cause"in l&&(l.cause instanceof Error?p=l.cause.message:typeof l.cause=="string"&&(p=l.cause))}let _=new yFt(p,500,{request:e});throw _.cause=l,_}let c=o.status,f=o.url,s={};for(let[l,p]of o.headers)s[l]=p;let u={url:f,status:c,headers:s,data:""};if("deprecation"in s){let l=s.link&&s.link.match(/<([^<>]+)>; rel="deprecation"/),p=l&&l.pop();r.warn(`[@octokit/request] "${e.method} ${e.url}" is deprecated. It is scheduled to be removed on ${s.sunset}${p?`. See ${p}`:""}`)}if(c===204||c===205)return u;if(e.method==="HEAD"){if(c<400)return u;throw new yFt(o.statusText,c,{response:u,request:e})}if(c===304)throw u.data=await asc(o),new yFt("Not modified",c,{response:u,request:e});if(c>=400)throw u.data=await asc(o),new yFt(z2S(u.data),c,{response:u,request:e});return u.data=i?await asc(o):o.body,u}async function asc(e){let t=e.headers.get("content-type");if(!t)return e.text().catch(()=>"");let r=(0,zp_.safeParse)(t);if(R2S(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 R2S(e){return e.type==="application/json"||e.type==="application/scim+json"}function z2S(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 osc(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 Rp_(r.parse(o));let c=(f,s)=>Rp_(r.parse(r.merge(f,s)));return Object.assign(c,{endpoint:r,defaults:osc.bind(null,r)}),o.request.hook(c,o)},{endpoint:r,defaults:osc.bind(null,r)})}var VO=osc(Bp_,q2S);var N2S="0.0.0-development";function F2S(e){return`Request failed due to following response errors:
@@ -1758,7 +1758,7 @@ ${l}
1758
1758
  `)}];let _=typeof p=="string"?p:p.type;if(typeof _!="string")return OR_(l);let h=i.resolveType({type:_,file:a});if(h==null)return[];let y=typeof t.extends>"u"?[]:typeof t.extends=="string"?[t.extends]:t.extends;if(t["base-properties"]!=null||y.length>0){let g={properties:t["base-properties"],extends:y},m=mPe({typeName:void 0,objectDeclaration:g,typeResolver:i,definitionFile:a.definitionFile,workspace:o,filepathOfDeclaration:a.relativeFilepath,smartCasing:!1}),j=new Set(m.map(D=>D.wireKey)),E=R$i({typeName:e,typeNameForBreadcrumb:e,rawObject:g,file:a,example:l,typeResolver:i,exampleResolver:n,workspace:o,breadcrumbs:c,depth:f+1}).filter(D=>{let B=D.message.toLowerCase();if(B.includes("unexpected property")){let F=B.match(/unexpected property "([^"]+)"/);if(F&&F[1]&&!j.has(F[1]))return!1}return!0});if(E.length>0)return E}if(h._type==="named"&&db(h.declaration)){let g=Object.fromEntries(Object.entries(l).filter(([M])=>!(t["base-properties"]?.[M]!=null||y.some(E=>{let D=i.resolveNamedType({referenceToNamedType:E,file:a});return D?._type==="named"&&db(D.declaration)?D.declaration.properties?.[M]!=null:!1})))),j=h.declaration.properties?.[s]!=null||(typeof h.declaration.extends>"u"?[]:typeof h.declaration.extends=="string"?[h.declaration.extends]:h.declaration.extends).some(E=>{let D=i.resolveNamedType({referenceToNamedType:E,file:h.file});return D?._type==="named"&&db(D.declaration)?D.declaration.properties?.[s]!=null:!1})?{[s]:u,...g}:g;return R$i({typeName:e,typeNameForBreadcrumb:e,rawObject:h.declaration,file:h.file,example:j,typeResolver:i,exampleResolver:n,workspace:o,breadcrumbs:c,depth:f+1})}let b=typeof p!="string"&&typeof p.key=="string"?p.key:void 0;if(b==null)return[];let{[b]:v,...O}=l,A=[];return typeof v>"u"?A.push({message:`Missing property "${b}"`}):A.push(...Sz({rawTypeReference:_,example:v,typeResolver:i,exampleResolver:n,file:a,workspace:o,breadcrumbs:c,depth:f+1})),A.push(...OR_(O)),A}function OR_(e){return Object.keys(e).map(t=>({severity:"fatal",message:`Unexpected property "${t}"`}))}function h9o({typeName:e,typeDeclaration:t,file:r,typeResolver:i,exampleResolver:n,example:a,workspace:o,breadcrumbs:c,depth:f}){return EB(t,{alias:s=>pR_({rawAlias:s,file:r,typeResolver:i,exampleResolver:n,example:a,workspace:o,breadcrumbs:c,depth:f}),enum:s=>_R_({rawEnum:s,example:a,breadcrumbs:c}),object:s=>R$i({typeName:e,typeNameForBreadcrumb:e,rawObject:s,example:a,file:r,typeResolver:i,exampleResolver:n,workspace:o,breadcrumbs:c,depth:f}),discriminatedUnion:s=>AR_({typeName:e,rawUnion:s,example:a,file:r,typeResolver:i,exampleResolver:n,workspace:o,breadcrumbs:c,depth:f}),undiscriminatedUnion:s=>hR_({rawUnion:s,example:a,file:r,typeResolver:i,exampleResolver:n,workspace:o,breadcrumbs:c,depth:f})})}var BR_=/^([+-]?\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)?)?)?)?$/,_zM=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/,hzM=/^\d{4}-\d{2}-\d{2}$/,yzM=128;function Sz({rawTypeReference:e,example:t,typeResolver:r,exampleResolver:i,file:n,workspace:a,breadcrumbs:o,depth:c}){if(c>yzM)return[{message:"Example is too deeply nested. This may indicate a circular reference. Example generation was truncated.",severity:"warning"}];if(typeof t=="string"&&t.startsWith("$")){let f=r.resolveType({type:e,file:n});if(f==null)return[];let s=i.parseExampleReference(t);if(s==null)return[];let u=r.resolveNamedType({referenceToNamedType:s.rawTypeReference,file:n});return u==null?[]:ILn({expected:f,actual:u})?[]:[{message:`Expected example to be: ${e}. Example is ${t}.`}]}return qKi({type:e,_default:void 0,validation:void 0,visitor:{primitive:f=>bzM({primitiveType:f,example:t}),named:f=>{let s=r.getDeclarationOfNamedType({referenceToNamedType:f,file:n});return s==null?[]:h9o({typeName:s.typeName,typeDeclaration:s.declaration,file:s.file,example:t,typeResolver:r,exampleResolver:i,workspace:a,breadcrumbs:o,depth:c+1})},map:({keyType:f,valueType:s})=>$c(t)?Object.entries(t).flatMap(([u,l])=>[...Sz({rawTypeReference:f,example:u,typeResolver:r,exampleResolver:i,file:n,workspace:a,breadcrumbs:[...o,u],depth:c+1}),...Sz({rawTypeReference:s,example:l,typeResolver:r,exampleResolver:i,file:n,workspace:a,breadcrumbs:[...o,u],depth:c+1})]):APe(t,"a map"),list:f=>Array.isArray(t)?t.flatMap((s,u)=>Sz({rawTypeReference:f,example:s,typeResolver:r,exampleResolver:i,file:n,workspace:a,breadcrumbs:[...o,`${u}`],depth:c+1})):APe(t,"a list"),set:f=>{if(!Array.isArray(t))return APe(t,"a list");let s=xjs(t);return s.length>0?[{severity:"fatal",message:`Set has duplicate elements:
1759
1759
  `+s.map(u=>` - ${JSON.stringify(u)}`).join(`
1760
1760
  `)}]:t.flatMap((u,l)=>Sz({rawTypeReference:f,example:u,typeResolver:r,exampleResolver:i,file:n,workspace:a,breadcrumbs:[...o,`${l}`],depth:c+1}))},optional:f=>t==null?[]:Sz({rawTypeReference:f,example:t,typeResolver:r,exampleResolver:i,file:n,workspace:a,breadcrumbs:o,depth:c+1}),nullable:f=>t===null?[]:Sz({rawTypeReference:f,example:t,typeResolver:r,exampleResolver:i,file:n,workspace:a,breadcrumbs:o,depth:c+1}),unknown:()=>[],literal:f=>{switch(f.type){case"boolean":return Khe(s=>s===f.boolean,f.boolean.toString())(t);case"string":return Khe(s=>s===f.string||mzM(f.string,s),`"${f.string}"`)(t);default:Ot(f)}}}})}function bzM({primitiveType:e,example:t}){return e.v2!=null?bn._visit(e.v2,{integer:r=>vzM({example:t,rules:r.validation}),long:()=>wR_(t),uint:()=>mR_(t),uint64:()=>PR_(t),double:r=>gzM({example:t,rules:r.validation}),float:()=>jR_(t),boolean:()=>ER_(t),string:r=>OzM({example:t,rules:r.validation}),uuid:()=>SR_(t),date:()=>DR_(t),dateTime:()=>MR_(t),base64:()=>BLn(t),bigInteger:()=>BLn(t),_other:()=>{throw new Error("Unknown primitive type v2: "+e.v2)}}):Su._visit(e.v1,{integer:()=>IR_(t),long:()=>wR_(t),uint:()=>mR_(t),uint64:()=>PR_(t),double:()=>CR_(t),float:()=>jR_(t),boolean:()=>ER_(t),string:()=>BLn(t),uuid:()=>SR_(t),dateTime:()=>MR_(t),date:()=>DR_(t),base64:()=>BLn(t),bigInteger:()=>BLn(t),_other:()=>{throw new Error("Unknown primitive type: "+e.v1)}})}function vzM({example:e,rules:t}){let r=IR_(e);if(r.length>0||t==null)return r;let i=e;return t.min!=null&&(t.exclusiveMin&&i<=t.min||!t.exclusiveMin&&i<t.min)?[{message:`Expected integer to be greater than or equal to ${t.min}. Example is ${e}.`}]:t.max!=null&&(t.exclusiveMax&&i>=t.max||!t.exclusiveMax&&i>t.max)?[{message:`Expected integer to be less than or equal to ${t.max}. Example is ${e}.`}]:t.multipleOf!=null&&i%t.multipleOf!==0?[{message:`Expected integer to be a multiple of ${t.multipleOf}. Example is ${e}.`}]:[]}function gzM({example:e,rules:t}){let r=CR_(e);if(r.length>0||t==null)return r;let i=e;return t.min!=null&&(t.exclusiveMin&&i<=t.min||!t.exclusiveMin&&i<t.min)?[{message:`Expected double to be greater than or equal to ${t.min}. Example is ${e}.`}]:t.max!=null&&(t.exclusiveMax&&i>=t.max||!t.exclusiveMax&&i>t.max)?[{message:`Expected double to be less than or equal to ${t.max}. Example is ${e}.`}]:t.multipleOf!=null&&i%t.multipleOf!==0?[{message:`Expected double to be a multiple of ${t.multipleOf}. Example is ${e}.`}]:[]}function OzM({example:e,rules:t}){let r=BLn(e);if(r.length>0||t==null)return r;let i=e;return t.minLength!=null&&i.length<t.minLength?[{message:`Expected string length to be greater than or equal to ${t.minLength}. Example is ${e}, which is of length ${i.length}.`}]:t.maxLength!=null&&i.length>t.maxLength?[{message:`Expected string length to be less than or equal to ${t.maxLength}. Example is ${e}, which is of length ${i.length}.`}]:t.pattern!=null&&!new RegExp(t.pattern).test(i)?[{message:`Expected string to match pattern ${t.pattern}. Example is ${e}.`}]:[]}var BLn=Khe(e=>typeof e=="string","a string"),IR_=Khe(e=>Number.isInteger(e),"an integer"),mR_=Khe(e=>Number.isInteger(e)&&typeof e=="number"&&e>=0,"a uint"),PR_=Khe(e=>Number.isInteger(e)&&typeof e=="number"&&e>=0,"a uint64"),jR_=Khe(e=>typeof e=="number","a float"),CR_=Khe(e=>typeof e=="number","a double"),wR_=Khe(e=>Number.isInteger(e),"an integer"),ER_=Khe(e=>typeof e=="boolean","a boolean"),SR_=Khe(e=>typeof e=="string"&&_zM.test(e),"a UUID"),MR_=Khe(e=>typeof e=="string"&&BR_.test(e),"an ISO 8601 timestamp"),DR_=Khe(e=>typeof e=="string"&&hzM.test(e)&&BR_.test(e),"a date");function Khe(e,t){return r=>e(r)?[]:APe(r,t)}function ILn({expected:e,actual:t}){if(e._type==="unknown")return!0;if(e._type==="primitive")return t._type==="primitive"&&e.primitive.v1===t.primitive.v1;if(e._type==="container")switch(e.container._type){case"list":case"set":return t._type==="container"&&t.container._type===e.container._type&&ILn({expected:e.container.itemType,actual:t.container.itemType});case"optional":return ILn({expected:e.container.itemType,actual:t._type==="container"&&t.container._type==="optional"?t.container.itemType:t});case"nullable":return ILn({expected:e.container.itemType,actual:t._type==="container"&&t.container._type==="nullable"?t.container.itemType:t});case"map":return t._type==="container"&&t.container._type===e.container._type&&ILn({expected:e.container.keyType,actual:t.container.keyType})&&ILn({expected:e.container.valueType,actual:t.container.valueType});case"literal":return t._type!=="container"||t.container._type!==e.container._type?!1:AzM({expected:e.container.literal,actual:t.container.literal});default:Ot(e.container)}if(e._type==="named")return t._type==="named"&&t.filepath===e.filepath&&t.rawName===e.rawName;Ot(e)}function AzM({expected:e,actual:t}){switch(e.type){case"boolean":return t.type==="boolean"?e.boolean===t.boolean:!1;case"string":return t.type==="string"?e.string===t.string:!1;default:Ot(e)}}function mzM(e,t){if(typeof t!="string")return!1;let r=oO.parse(e),i=oO.parse(t);return r==null||i==null?!1:!!(r.isJSON()&&i.isJSON())}function y9o({_enum:e,file:t}){let r=e.enum.map(n=>({...l8(n),name:t.casingsGenerator.generateNameAndWireValue({wireValue:typeof n=="string"?n:n.value,name:CLn(n).name,opts:{casingOverrides:typeof n!="string"?n.casing:void 0}})})),i;if(e.default!=null&&(i=r.find(n=>n.name.wireValue===e.default),i==null))throw new Error(`Default value ${e.default} not found in enum values`);return{default:i,values:r}}function qR_(e,t){let r=t.enum.find(i=>typeof i=="string"?!1:i.value===e);return{name:typeof r=="string"?e:r?.name??e,wasExplicitlySet:!1}}function CLn(e){return typeof e=="string"?{name:e,wasExplicitlySet:!1}:e.name==null?{name:e.value,wasExplicitlySet:!1}:{name:e.name,wasExplicitlySet:!0}}var PzM=128;function Rvc({typeName:e,typeDeclaration:t,example:r,typeResolver:i,exampleResolver:n,fileContainingType:a,fileContainingExample:o,workspace:c,recursionContext:f}){return EB(t,{alias:s=>Bh.alias({value:Rv({example:r,rawTypeBeingExemplified:typeof s=="string"?s:s.type,fileContainingRawTypeReference:a,fileContainingExample:o,typeResolver:i,exampleResolver:n,workspace:c,recursionContext:f})}),object:s=>TR_({typeName:e,rawObject:s,example:r,fileContainingType:a,fileContainingExample:o,typeResolver:i,exampleResolver:n,workspace:c,recursionContext:f}),discriminatedUnion:s=>{let u=z$i(s);if(!$c(r))throw new Error("Example is not an object");let l=r[u];if(l==null)throw new Error("Example is missing discriminant: "+u);if(typeof l!="string")throw new Error("Discriminant value is not a string");let p=s.union[l];if(p==null)throw new Error(`${l} is not one of the specified discriminant values.`);let _=typeof p=="string"?p:typeof p.type=="string"?p.type:void 0,h=Object.entries(s["base-properties"]??{}).map(([b,v])=>{let O=r[b];if(O!=null)return{name:o.casingsGenerator.generateNameAndWireValue({name:b,wireValue:b}),value:Rv({example:O,rawTypeBeingExemplified:typeof v=="string"?v:v.type,fileContainingRawTypeReference:a,fileContainingExample:o,typeResolver:i,exampleResolver:n,workspace:c,recursionContext:f})}}).filter(b=>b!=null),y=(typeof s.extends>"u"?[]:typeof s.extends=="string"?[s.extends]:s.extends).flatMap(b=>{let v=i.resolveNamedTypeOrThrow({file:a,referenceToNamedType:b});if(v._type!=="named"||!db(v.declaration))throw new Error("Extended type is not a named object");let O=v.declaration;return Object.entries(O.properties??{}).map(([g,m])=>{let j=r[g];if(j!=null)return{name:o.casingsGenerator.generateNameAndWireValue({name:typeof m=="string"?g:m.name??g,wireValue:g}),value:Rv({example:j,rawTypeBeingExemplified:typeof m=="string"?m:m.type,fileContainingRawTypeReference:a,fileContainingExample:o,typeResolver:i,exampleResolver:n,workspace:c,recursionContext:f}),propertyAccess:ELn({property:m}),originalTypeDeclaration:e}}).filter(g=>g!=null)});return Bh.union({discriminant:o.casingsGenerator.generateNameAndWireValue({name:MLn(s).name,wireValue:u}),singleUnionType:wzM({rawValueType:_,rawSingleUnionType:p,fileContainingType:a,fileContainingExample:o,typeResolver:i,exampleResolver:n,example:r,discriminantValueForExample:l,workspace:c,recursionContext:f}),baseProperties:h,extendProperties:y})},enum:s=>{if(typeof r!="string"){let u=s.enum.map(l=>typeof l=="string"?l:l.value).join(", ");throw new Error(`Expected one of ${u}. Received ${r}`)}return Bh.enum({value:o.casingsGenerator.generateNameAndWireValue({name:qR_(r,s).name,wireValue:r})})},undiscriminatedUnion:s=>{for(let[p,_]of s.union.entries())if(Sz({rawTypeReference:typeof _=="string"?_:_.type,example:r,typeResolver:i,exampleResolver:n,file:a,workspace:c,breadcrumbs:[],depth:0}).length===0)return Bh.undiscriminatedUnion({index:p,singleUnionType:Rv({example:r,rawTypeBeingExemplified:typeof _=="string"?_:_.type,fileContainingRawTypeReference:a,fileContainingExample:o,typeResolver:i,exampleResolver:n,workspace:c,recursionContext:f})});let l=s.union.map(p=>typeof p=="string"?p:p.type).join(", ");throw new Error(`Expected one of ${l}. Received ${r}`)}})}function Rv({example:e,fileContainingExample:t,rawTypeBeingExemplified:r,fileContainingRawTypeReference:i,typeResolver:n,exampleResolver:a,workspace:o,recursionContext:c}){let f=c??{depth:0,seenTypeIds:new Set},{resolvedExample:s,file:u}=a.resolveExampleOrThrow({example:e,file:t}),l=a.resolveAllReferencesInExampleOrThrow({example:e,file:t}).resolvedExample;return{shape:qKi({type:r,_default:void 0,validation:void 0,visitor:{primitive:_=>jzM({example:s,typeBeingExemplified:_.v1}),map:({keyType:_,valueType:h})=>{if(!$c(s))throw new Error("Example is not an object");let y={depth:f.depth+1,seenTypeIds:f.seenTypeIds};return lu.container(op.map({map:Object.entries(s).map(([b,v])=>({key:Rv({example:b,fileContainingExample:u,rawTypeBeingExemplified:_,fileContainingRawTypeReference:i,typeResolver:n,exampleResolver:a,workspace:o,recursionContext:y}),value:Rv({example:v,fileContainingExample:u,rawTypeBeingExemplified:h,fileContainingRawTypeReference:i,typeResolver:n,exampleResolver:a,workspace:o,recursionContext:y})})),keyType:i.parseTypeReference(_),valueType:i.parseTypeReference(h)}))},list:_=>{if(!Array.isArray(s))throw new Error("Example is not a list");let h={depth:f.depth+1,seenTypeIds:f.seenTypeIds};return lu.container(op.list({list:s.map(y=>Rv({example:y,fileContainingExample:u,rawTypeBeingExemplified:_,fileContainingRawTypeReference:i,typeResolver:n,exampleResolver:a,workspace:o,recursionContext:h})),itemType:i.parseTypeReference(_)}))},set:_=>{if(!Array.isArray(s))throw new Error("Example is not a list");let h={depth:f.depth+1,seenTypeIds:f.seenTypeIds};return lu.container(op.set({set:s.map(y=>Rv({example:y,fileContainingExample:u,rawTypeBeingExemplified:_,fileContainingRawTypeReference:i,typeResolver:n,exampleResolver:a,workspace:o,recursionContext:h})),itemType:i.parseTypeReference(_)}))},optional:_=>{let h={depth:f.depth+1,seenTypeIds:f.seenTypeIds};return lu.container(op.optional({optional:s!=null?Rv({example:s,fileContainingExample:u,rawTypeBeingExemplified:_,fileContainingRawTypeReference:i,typeResolver:n,exampleResolver:a,workspace:o,recursionContext:h}):void 0,valueType:i.parseTypeReference(_)}))},nullable:_=>{let h={depth:f.depth+1,seenTypeIds:f.seenTypeIds};return lu.container(op.nullable({nullable:s!=null?Rv({example:s,fileContainingExample:u,rawTypeBeingExemplified:_,fileContainingRawTypeReference:i,typeResolver:n,exampleResolver:a,workspace:o,recursionContext:h}):void 0,valueType:i.parseTypeReference(_)}))},literal:_=>{switch(_.type){case"boolean":return lu.container(op.literal({literal:Sn.boolean(_.boolean)}));case"string":return lu.container(op.literal({literal:Sn.string({original:_.string})}));default:Ot(_)}},named:_=>{let h=n.getDeclarationOfNamedTypeOrThrow({referenceToNamedType:r,file:i}),y=i.parseTypeReference(_);if(y.type!=="named")throw new Error("Type reference is not to a named type.");let b={typeId:y.typeId,fernFilepath:y.fernFilepath,name:y.name,displayName:y.displayName};if(f.depth>PzM||f.seenTypeIds.has(y.typeId))return lu.unknown(l);let v={depth:f.depth+1,seenTypeIds:new Set(f.seenTypeIds).add(y.typeId)};return lu.named({typeName:b,shape:Rvc({typeName:b,typeDeclaration:h.declaration,fileContainingType:h.file,fileContainingExample:u,example:s,typeResolver:n,exampleResolver:a,workspace:o,recursionContext:v})})},unknown:()=>lu.unknown(l)}}),jsonExample:l}}function zvc({example:e}){return lu.unknown(e)}function jzM({example:e,typeBeingExemplified:t}){return Su._visit(t,{string:()=>{if(typeof e!="string")return lu.primitive(Sn.string({original:Tn.STRING}));let r=e.startsWith(`\\${"$"}`)?e.slice(1):e;return lu.primitive(Sn.string({original:r}))},dateTime:()=>typeof e!="string"?lu.primitive(Sn.string({original:Tn.DATE_TIME})):lu.primitive(Sn.datetime({datetime:new Date(e),raw:e})),date:()=>typeof e!="string"?lu.primitive(Sn.string({original:Tn.DATE})):lu.primitive(Sn.date(e)),base64:()=>typeof e!="string"?lu.primitive(Sn.string({original:Tn.BASE64})):lu.primitive(Sn.string({original:e})),uint:()=>typeof e!="number"?lu.primitive(Sn.uint(Tn.UINT)):lu.primitive(Sn.uint(e)),uint64:()=>typeof e!="number"?lu.primitive(Sn.uint64(Tn.UINT64)):lu.primitive(Sn.uint64(e)),integer:()=>typeof e!="number"?lu.primitive(Sn.integer(Tn.INT)):lu.primitive(Sn.integer(e)),float:()=>typeof e!="number"?lu.primitive(Sn.float(Tn.FLOAT)):lu.primitive(Sn.float(e)),double:()=>typeof e!="number"?lu.primitive(Sn.double(Tn.DOUBLE)):lu.primitive(Sn.double(e)),long:()=>typeof e!="number"?lu.primitive(Sn.long(Tn.UINT)):lu.primitive(Sn.long(e)),boolean:()=>typeof e!="boolean"?lu.primitive(Sn.boolean(Tn.BOOLEAN)):lu.primitive(Sn.boolean(e)),uuid:()=>typeof e!="string"?lu.primitive(Sn.string({original:Tn.UUID})):lu.primitive(Sn.uuid(e)),bigInteger:()=>typeof e!="string"?lu.primitive(Sn.string({original:Tn.BIG_INTEGER})):lu.primitive(Sn.string({original:e})),_other:()=>{throw new Error("Unknown primitive type: "+t)}})}function TR_({typeName:e,rawObject:t,example:r,fileContainingType:i,fileContainingExample:n,typeResolver:a,exampleResolver:o,workspace:c,recursionContext:f}){if(!$c(r))throw new Error(`Example is not an object. Got: ${JSON.stringify(r)}`);let s=Object.entries(r).map(([p,_])=>{let h=RR_({typeName:e,wirePropertyKey:p,rawObject:t,typeResolver:a,file:i});return[p,_,h]}),u=s.filter(([,,p])=>p!=null),l=s.filter(([,,p])=>p==null);return Bh.object({properties:t.properties!=null||t.extends!=null?u.map(([p,_,h])=>{let y=Rv({example:_,fileContainingExample:n,rawTypeBeingExemplified:typeof h.rawPropertyType=="string"?h.rawPropertyType:h.rawPropertyType.type,fileContainingRawTypeReference:h.file,typeResolver:a,exampleResolver:o,workspace:c,recursionContext:f});return{name:n.casingsGenerator.generateNameAndWireValue({name:Ez({propertyKey:p,property:h.rawPropertyType}).name,wireValue:p}),value:y,originalTypeDeclaration:h.typeName,propertyAccess:ELn({property:h.rawPropertyType})}}):[],extraProperties:t["extra-properties"]!==!0||l.length===0?void 0:l.map(([p,_])=>({name:n.casingsGenerator.generateNameAndWireValue({name:p,wireValue:p}),value:{shape:zvc({example:_}),jsonExample:_}}))})}function RR_({typeName:e,wirePropertyKey:t,rawObject:r,typeResolver:i,file:n}){let a=r.properties?.[t];return a!=null?{typeName:e,rawPropertyType:a,file:n}:WEa({wirePropertyKey:t,extends_:r.extends,typeResolver:i,file:n})}function WEa({wirePropertyKey:e,extends_:t,typeResolver:r,file:i}){if(t!=null){let n=typeof t=="string"?[t]:t;for(let a of n){let o=r.resolveNamedTypeOrThrow({referenceToNamedType:a,file:i});if(o._type!=="named"||!db(o.declaration))throw new Error("Extension is not of a named object");let c=RR_({wirePropertyKey:e,rawObject:o.declaration,typeResolver:r,typeName:o.name,file:o.file});if(c!=null)return c}}}function wzM({rawValueType:e,rawSingleUnionType:t,fileContainingType:r,fileContainingExample:i,typeResolver:n,exampleResolver:a,example:o,discriminantValueForExample:c,workspace:f,recursionContext:s}){let u=i.casingsGenerator.generateNameAndWireValue({name:DLn({unionKey:c,rawSingleUnionType:t}).name,wireValue:c});if(e==null)return{wireDiscriminantValue:u,shape:jB.noProperties()};let l=Tvc({rawSingleUnionType:t,rawValueType:e,parsedValueType:r.parseTypeReference(e),file:r,typeResolver:n});switch(l.propertiesType){case"singleProperty":{if(!$c(o))throw new Error("Example is not an object");return{wireDiscriminantValue:u,shape:jB.singleProperty(Rv({example:o[l.name.wireValue],rawTypeBeingExemplified:e,typeResolver:n,exampleResolver:a,fileContainingRawTypeReference:r,fileContainingExample:i,workspace:f,recursionContext:s}))}}case"samePropertiesAsObject":{if(!$c(o))throw new Error("Example is not an object");let p=n.getDeclarationOfNamedTypeOrThrow({referenceToNamedType:e,file:r});for(;ACi(p.declaration);)p=n.getDeclarationOfNamedTypeOrThrow({referenceToNamedType:typeof p.declaration=="string"?p.declaration:p.declaration.type,file:r});if(!db(p.declaration))throw new Error(`${e} is not an object`);let _={typeId:l.typeId,fernFilepath:l.fernFilepath,name:l.name,displayName:l.displayName};return{wireDiscriminantValue:u,shape:jB.samePropertiesAsObject({typeId:up.generateTypeId(_),object:TR_({rawObject:p.declaration,example:o,fileContainingType:p.file,fileContainingExample:i,typeResolver:n,exampleResolver:a,typeName:_,workspace:f,recursionContext:s})})}}default:Ot(l)}}function b9o({file:e,queryParameterKey:t,queryParameter:r}){let{name:i}=Qgi({queryParameterKey:t,queryParameter:r}),n=e.parseTypeReference(r);return{...l8(r),name:e.casingsGenerator.generateNameAndWireValue({wireValue:t,name:i}),valueType:n,allowMultiple:typeof r!="string"&&r["allow-multiple"]!=null?r["allow-multiple"]:!1,v2Examples:{userSpecifiedExamples:{},autogeneratedExamples:{}},explode:void 0}}function Qgi({queryParameterKey:e,queryParameter:t}){return typeof t!="string"&&t.name!=null?{name:t.name,wasExplicitlySet:!0}:{name:e,wasExplicitlySet:!1}}function NR_({service:e,endpoint:t,example:r,typeResolver:i,errorResolver:n,exampleResolver:a,variableResolver:o,file:c,workspace:f}){let s=SzM({service:e,endpoint:t,example:r,typeResolver:i,exampleResolver:a,variableResolver:o,file:c,workspace:f});return{id:r.name??PCi(r),name:r.name!=null?c.casingsGenerator.generateName(r.name):void 0,docs:r.docs,url:CzM({file:c,service:e,endpoint:t,example:r,pathParams:s}),...s,...MzM({service:e,endpoint:t,example:r,typeResolver:i,exampleResolver:a,file:c,workspace:f}),queryParameters:r["query-parameters"]!=null?Object.entries(r["query-parameters"]).map(([u,l])=>{let p=typeof t.request!="string"?t.request?.["query-parameters"]?.[u]:void 0;if(p==null)throw new Error(`Query parameter ${u} does not exist`);return{name:c.casingsGenerator.generateNameAndWireValue({name:Qgi({queryParameterKey:u,queryParameter:p}).name,wireValue:u}),value:Rv({example:l,rawTypeBeingExemplified:typeof p=="string"?p:p.type,typeResolver:i,exampleResolver:a,fileContainingRawTypeReference:c,fileContainingExample:c,workspace:f}),shape:EzM({queryParameter:p})}}):[],request:DzM({endpoint:t,example:r,typeResolver:i,exampleResolver:a,file:c,workspace:f}),response:BzM({endpoint:t,example:r,typeResolver:i,errorResolver:n,exampleResolver:a,file:c,workspace:f})}}function EzM({queryParameter:e}){return(typeof e!="string"&&e["allow-multiple"]!=null?e["allow-multiple"]:!1)?M1.exploded():M1.single()}function SzM({service:e,endpoint:t,example:r,typeResolver:i,exampleResolver:n,variableResolver:a,file:o,workspace:c}){let f=[],s=[],u=[],l=({name:p,pathParameterDeclaration:_,examplePathParameter:h})=>{let y=xEa({parameter:_,variableResolver:a,file:o});return{name:p,value:Rv({example:h,rawTypeBeingExemplified:y.rawType,typeResolver:i,exampleResolver:n,fileContainingRawTypeReference:y.file,fileContainingExample:o,workspace:c})}};if(r["path-parameters"]!=null){let p=LFt(t);for(let[_,h]of Object.entries(r["path-parameters"])){let y=o.rootApiFile["path-parameters"]?.[_],b=e["path-parameters"]?.[_],v=p[_];if(y!=null)f.push(l({name:o.casingsGenerator.generateName(_),pathParameterDeclaration:y,examplePathParameter:h}));else if(v!=null)u.push(l({name:o.casingsGenerator.generateName(_),pathParameterDeclaration:v,examplePathParameter:h}));else if(b!=null)s.push(l({name:o.casingsGenerator.generateName(_),pathParameterDeclaration:b,examplePathParameter:h}));else throw new Error(`Path parameter ${_} does not exist`)}}return{rootPathParameters:f,endpointPathParameters:u,servicePathParameters:s}}function MzM({service:e,endpoint:t,example:r,typeResolver:i,exampleResolver:n,file:a,workspace:o}){let c=[],f=[];if(r.headers!=null)for(let[s,u]of Object.entries(r.headers)){let l=typeof t.request!="string"?t.request?.headers?.[s]:void 0,p=e.headers?.[s];l!=null?f.push({name:a.casingsGenerator.generateNameAndWireValue({name:Y9t({headerKey:s,header:l}).name,wireValue:s}),value:Rv({example:u,rawTypeBeingExemplified:typeof l=="string"?l:l.type,typeResolver:i,exampleResolver:n,fileContainingRawTypeReference:a,fileContainingExample:a,workspace:o})}):p!=null&&c.push({name:a.casingsGenerator.generateNameAndWireValue({name:Y9t({headerKey:s,header:p}).name,wireValue:s}),value:Rv({example:u,rawTypeBeingExemplified:typeof p=="string"?p:p.type,typeResolver:i,exampleResolver:n,fileContainingRawTypeReference:a,fileContainingExample:a,workspace:o})})}return{endpointHeaders:f,serviceHeaders:c}}function DzM({endpoint:e,example:t,typeResolver:r,exampleResolver:i,file:n,workspace:a}){let o=typeof e.request!="string"?e.request?.body:e.request;if(o==null||typeof o=="string"&&ePa(o)!=null)return;if(!HP(o))return R3.reference(Rv({example:t.request,rawTypeBeingExemplified:typeof o!="string"?o.type:o,typeResolver:r,exampleResolver:i,fileContainingRawTypeReference:n,fileContainingExample:n,workspace:a}));if(!t.request)return;if(!$c(t.request))throw new Error(`Example is not an object. Got: ${JSON.stringify(t.request)}`);let c=[],f=[];for(let[s,u]of Object.entries(t.request)){let l=o.properties?.[s],p=typeof l=="string"?l:l?.type;if(!(p!=null&&ZH(p)!=null))if(l!=null)c.push({name:n.casingsGenerator.generateNameAndWireValue({name:Ez({propertyKey:s,property:l}).name,wireValue:s}),value:Rv({example:u,rawTypeBeingExemplified:typeof l!="string"?l.type:l,typeResolver:r,exampleResolver:i,fileContainingRawTypeReference:n,fileContainingExample:n,workspace:a}),originalTypeDeclaration:void 0});else{let _=WEa({extends_:o.extends,wirePropertyKey:s,typeResolver:r,file:n});if(_==null){if(o["extra-properties"]===!0){f.push({name:n.casingsGenerator.generateNameAndWireValue({name:s,wireValue:s}),value:{jsonExample:u,shape:zvc({example:u})}});continue}throw new Error("Could not find original type declaration for property: "+s)}c.push({name:n.casingsGenerator.generateNameAndWireValue({name:Ez({propertyKey:s,property:_.rawPropertyType}).name,wireValue:s}),value:Rv({example:u,rawTypeBeingExemplified:typeof _.rawPropertyType=="string"?_.rawPropertyType:_.rawPropertyType.type,typeResolver:r,exampleResolver:i,fileContainingRawTypeReference:_.file,fileContainingExample:n,workspace:a}),originalTypeDeclaration:_.typeName})}}return R3.inlinedRequestBody({jsonExample:i.resolveAllReferencesInExampleOrThrow({example:t.request,file:n}).resolvedExample,properties:c,extraProperties:f.length>0?f:void 0})}function BzM({endpoint:e,example:t,typeResolver:r,errorResolver:i,exampleResolver:n,file:a,workspace:o}){return t.response==null?L0.ok(xP.body(void 0)):zKi(e,t.response,{body:c=>{if(c.error!=null){let f=i.getDeclarationOrThrow(c.error,a);return L0.error({error:l1i({errorName:c.error,file:a}),body:f.declaration.type!=null?Rv({example:c.body,rawTypeBeingExemplified:f.declaration.type,typeResolver:r,exampleResolver:n,fileContainingRawTypeReference:f.file,fileContainingExample:a,workspace:o}):void 0})}return L0.ok(xP.body(IzM({endpoint:e,example:c,typeResolver:r,exampleResolver:n,file:a,workspace:o})))},stream:c=>{let f=typeof e["response-stream"]=="string"?e["response-stream"]:e["response-stream"]?.type;return L0.ok(xP.stream(c.stream.map(s=>{if(f!=null)return Rv({example:s,rawTypeBeingExemplified:f,typeResolver:r,exampleResolver:n,fileContainingRawTypeReference:a,fileContainingExample:a,workspace:o})}).filter(Zu)))},events:c=>{let f=typeof e["response-stream"]=="string"?e["response-stream"]:e["response-stream"]?.type;return L0.ok(xP.sse(c.stream.map(({event:s,data:u})=>{if(f==null)return;let l=Rv({example:u,rawTypeBeingExemplified:f,typeResolver:r,exampleResolver:n,fileContainingRawTypeReference:a,fileContainingExample:a,workspace:o});return{event:s,data:l}}).filter(Zu)))}})}function IzM({endpoint:e,example:t,typeResolver:r,exampleResolver:i,file:n,workspace:a}){let o=typeof e.response!="string"?e.response?.type:e.response;if(o!=null&&t.body!=null)return Rv({example:t.body,rawTypeBeingExemplified:o,typeResolver:r,exampleResolver:i,fileContainingRawTypeReference:n,fileContainingExample:n,workspace:a})}function CzM({file:e,service:t,endpoint:r,example:i,pathParams:n}){let a=(0,zR_.default)(e.rootApiFile["base-path"]??"",t["base-path"],r.path);if(i["path-parameters"]!=null)for(let o of[...n.endpointPathParameters,...n.servicePathParameters,...n.rootPathParameters])a=a.replaceAll(`{${o.name.originalName}}`,encodeURIComponent(`${o.value.jsonExample}`));return a=a.replaceAll("//","/"),a.startsWith("/")||(a=`/${a}`),a}function FR_({endpoint:e,file:t,typeResolver:r}){let i=qzM({endpoint:e,file:t,typeResolver:r}),n=typeof e.response!="string"?e.response?.docs:void 0;return{body:i,statusCode:typeof e.response!="string"?e.response?.["status-code"]:void 0,isWildcardStatusCode:void 0,docs:n}}function qzM({endpoint:e,file:t,typeResolver:r}){let i=TzM({endpoint:e,file:t,typeResolver:r}),n=RzM({endpoint:e,file:t,typeResolver:r});if(i!=null&&n!=null){let a;switch(i.type){case"fileDownload":{a=QQ.fileDownload({...i});break}case"json":{a=QQ.json({...i.value});break}case"text":{a=QQ.text({...i});break}case"bytes":{a=QQ.bytes({...i});break}default:Ot(i)}return Xf.streamParameter({nonStreamResponse:a,streamResponse:n})}else{if(i!=null)return i;if(n!=null)return Xf.streaming(n)}}function TzM({endpoint:e,file:t,typeResolver:r}){let{response:i}=e;if(i!=null){let n=typeof i!="string"?i.docs:void 0,a=typeof i=="string"?i:i.type;if(a!=null)return ZH(a)!=null?Xf.fileDownload({docs:n,v2Examples:void 0}):RKi(a)!=null?Xf.text({docs:n,v2Examples:void 0}):z0e(a)!=null?Xf.bytes({docs:n,v2Examples:void 0}):zzM(i,n,t,r)}}function RzM({endpoint:e,file:t,typeResolver:r}){let{["response-stream"]:i}=e;if(i!=null){let n=typeof i!="string"?i.docs:void 0,a=typeof i=="string"?i:i.type,o=typeof i=="string"?"json":i.format??"json";return OCi(a)?AD.text({docs:n,v2Examples:void 0}):typeof i!="string"&&o==="sse"?AD.sse({docs:n,payload:t.parseTypeReference(a),terminator:typeof i!="string"?i.terminator:void 0,v2Examples:void 0}):AD.json({docs:n,payload:t.parseTypeReference(a),terminator:typeof i!="string"?i.terminator:void 0,v2Examples:void 0})}}function zzM(e,t,r,i){let n=typeof e!="string"?e.type:e;if(n==null)return;let a=r.parseTypeReference(typeof e=="string"?e:{...e,type:n}),o=i.resolveTypeOrThrow({type:n,file:r}),c=typeof e!="string"?e.property:void 0;return c!=null?Xf.json(mB.nestedPropertyAsResponse({docs:t,responseBodyType:a,responseProperty:T$i({typeResolver:i,file:r,resolvedType:o,property:c}),v2Examples:void 0})):Xf.json(mB.response({docs:t,responseBodyType:a,v2Examples:void 0}))}function QR_({propertyResolver:e,file:t,endpointName:r,endpointSchema:i,paginationPropertyComponents:n}){return T3.cursor({page:e.resolveRequestPropertyOrThrow({file:t,endpoint:r,propertyComponents:n.cursor}),next:e.resolveResponsePropertyOrThrow({file:t,endpoint:r,propertyComponents:n.next_cursor}),results:e.resolveResponsePropertyOrThrow({file:t,endpoint:r,propertyComponents:n.results})})}function UR_({propertyResolver:e,file:t,endpointName:r,paginationPropertyComponents:i}){return T3.custom({results:e.resolveResponsePropertyOrThrow({file:t,endpoint:r,propertyComponents:i.results})})}function LR_({propertyResolver:e,file:t,endpointName:r,endpointSchema:i,paginationPropertyComponents:n}){return T3.offset({page:e.resolveRequestPropertyOrThrow({file:t,endpoint:r,propertyComponents:n.offset}),results:e.resolveResponsePropertyOrThrow({file:t,endpoint:r,propertyComponents:n.results}),step:n.step!=null?e.resolveRequestPropertyOrThrow({file:t,endpoint:r,propertyComponents:n.step}):void 0,hasNextPage:n.hasNextPage!=null?e.resolveResponsePropertyOrThrow({file:t,endpoint:r,propertyComponents:n.hasNextPage}):void 0})}function VR_(e){if(FzM(e))return{type:"offset",offset:UFt(e.offset),results:Hhe(e.results),step:e.step!=null?UFt(e.step):void 0,hasNextPage:e["has-next-page"]!=null?Hhe(e["has-next-page"]):void 0};if(NzM(e))return{type:"cursor",cursor:UFt(e.cursor),next_cursor:Hhe(e.next_cursor),results:Hhe(e.results)};if(QzM(e))return{type:"custom",results:Hhe(e.results)};throw new Error("Invalid pagination schema")}function NzM(e){return e.cursor!=null}function FzM(e){return e.offset!=null&&e.results!=null}function QzM(e){return"type"in e&&e.type==="custom"}function WR_({propertyResolver:e,file:t,endpointName:r,endpointSchema:i}){let n=typeof i.pagination=="boolean"?t.rootApiFile.pagination:i.pagination;if(!n)return;let a=VR_(n);switch(a.type){case"cursor":return QR_({propertyResolver:e,file:t,endpointName:r,endpointSchema:i,paginationPropertyComponents:a});case"offset":return LR_({propertyResolver:e,file:t,endpointName:r,endpointSchema:i,paginationPropertyComponents:a});case"custom":return UR_({propertyResolver:e,file:t,endpointName:r,paginationPropertyComponents:a});default:Ot(a)}}function xR_({errors:e,file:t}){return e==null?[]:Object.values(e).map(r=>{let i=typeof r=="string"?r:r.error,n=l1i({errorName:i,file:t});return{docs:typeof r!="string"?r.docs:void 0,error:n}})}function GR_({endpointSchema:e}){if(e.retries&&e.retries.disabled!==void 0)return{disabled:e.retries.disabled}}function v9o({source:e}){return{filepath:e.relativeFilePath,packageName:e.packageName,options:e.csharpNamespace!=null?{csharp:{namespace:e.csharpNamespace}}:void 0}}function HR_({source:e,serviceNameOverride:t}){let r=t??e.serviceName;if(r!=null)return{file:v9o({source:e}),name:f1i.generateName(r)}}function KR_({file:e,serviceDeclaration:t,sourceResolver:r}){return i9t(t.source)?$R_(e,t.source,r,t.transport?.grpc?.["service-name"]):P0e.http()}function JR_({file:e,serviceTransport:t,endpointDeclaration:r,sourceResolver:i}){let n=t.type==="grpc",a=t.type==="http",o=i9t(r.source),c=!o;if(n){if(a&&o)throw new Error("Cannot have a grpc endpoint on an http service");if(n&&c)return P0e.http();if(n&&o){let f=r.source,s=r.transport?.grpc?.["service-name"];return s?$R_(e,f,i,s):void 0}throw new Error(`Internal error; failed to determine endpoint transport for
1761
- ${JSON.stringify(r)}"`)}}function $R_(e,t,r,i){let n=r.resolveSourceOrThrow({source:t,relativeFilepath:e.relativeFilepath});if(n==null||n.type!=="protobuf")throw new Error(`Expected a protobuf source for ${t.proto}.`);let a=HR_({source:n,serviceNameOverride:i});if(a==null)throw new Error(`Failed to resolve service name from ${n.relativeFilePath}.`);return P0e.grpc({service:a})}function YR_({rootDefaultUrl:e,rootPathParameters:t,serviceDefinition:r,file:i,errorResolver:n,typeResolver:a,propertyResolver:o,exampleResolver:c,variableResolver:f,sourceResolver:s,globalErrors:u,workspace:l,auth:p,irSettings:_}){let h=qLn({pathParameters:r["path-parameters"],location:j0e.Service,file:i,variableResolver:f}),y=_.pathParameterOrder,b=(()=>{switch(y){case hn.PathParameterOrder.UrlOrder:return r["base-path"]?_9o(r["base-path"],h):h;case hn.PathParameterOrder.SpecOrder:return h;default:Ot(y)}})(),v=KR_({file:i,serviceDeclaration:r,sourceResolver:s}),O={fernFilepath:i.fernFilepath};return{availability:vK(r.availability),name:O,displayName:r["display-name"]??void 0,basePath:PD(r["base-path"]),headers:r.headers!=null?Object.entries(r.headers).map(([g,m])=>PPe({headerKey:g,header:m,file:i})):[],pathParameters:b,encoding:WzM(v,r),transport:v,endpoints:Object.entries(r.endpoints).map(([g,m])=>{let j=m["base-path"]!=null?(0,g9o.default)(m["base-path"],m.path):i.rootApiFile["base-path"]!=null?(0,g9o.default)(i.rootApiFile["base-path"],r["base-path"],m.path):(0,g9o.default)(r["base-path"],m.path),M=qLn({pathParameters:LFt(m),location:j0e.Endpoint,file:i,variableResolver:f}),E=(()=>{switch(y){case hn.PathParameterOrder.UrlOrder:return _9o(m.path,M);case hn.PathParameterOrder.SpecOrder:return M;default:Ot(y)}})(),D=m["base-path"]!=null?E:[...t,...b,...E],B=(()=>{switch(y){case hn.PathParameterOrder.UrlOrder:return _9o(j,D);case hn.PathParameterOrder.SpecOrder:return D;default:Ot(y)}})(),F={...l8(m),id:"",name:i.casingsGenerator.generateName(g),displayName:m["display-name"],auth:typeof m.auth=="boolean"?m.auth:m.auth!=null?m.auth.length>0:r.auth,security:typeof m.auth>"u"||typeof m.auth=="boolean"?m.auth??r.auth===!0?C3._visit(p.requirement,{any:()=>p.schemes.map(N=>({[N.key]:[]})),all:()=>[p.schemes.reduce((N,R)=>({...N,[R.key]:[]}),{})],_other:()=>{}}):void 0:m.auth,docs:m.docs,idempotent:m.idempotent??r.idempotent??!1,baseUrl:m.url??r.url??e,v2BaseUrls:void 0,method:m.method!=null?VzM(m.method):WP.Post,basePath:m["base-path"]!=null?PD(m["base-path"]):void 0,path:PD(m.path),fullPath:PD(j),pathParameters:E,allPathParameters:B,queryParameters:typeof m.request!="string"&&m.request?.["query-parameters"]!=null?Object.entries(m.request["query-parameters"]).map(([N,R])=>b9o({file:i,queryParameterKey:N,queryParameter:R})):[],headers:typeof m.request!="string"&&m.request?.headers!=null?Object.entries(m.request.headers).map(([N,R])=>PPe({headerKey:N,header:R,file:i})):[],requestBody:oR_({request:m.request,file:i}),v2RequestBodies:void 0,sdkRequest:fR_({service:r,request:m.request,endpoint:m,endpointKey:g,file:i,typeResolver:a,propertyResolver:o}),response:FR_({endpoint:m,file:i,typeResolver:a}),v2Responses:void 0,errors:[...xR_({errors:m.errors,file:i}),...u],userSpecifiedExamples:m.examples!=null?m.examples.map(N=>{try{let R=NR_({service:r,endpoint:m,example:N,typeResolver:a,errorResolver:n,exampleResolver:c,variableResolver:f,file:i,workspace:l});return R===void 0?void 0:{example:R,codeSamples:N["code-samples"]?.map(z=>dR_({codeSample:z,file:i}))}}catch{return}}).filter(N=>N!==void 0):[],autogeneratedExamples:[],pagination:WR_({propertyResolver:o,file:i,endpointName:g,endpointSchema:m}),transport:JR_({file:i,serviceTransport:v,endpointDeclaration:m,sourceResolver:s}),v2Examples:void 0,source:void 0,audiences:m.audiences,retries:GR_({endpointSchema:m}),apiPlayground:void 0};return F.id=up.generateEndpointId(O,F),F}),audiences:r.audiences}}function qLn({pathParameters:e,location:t,file:r,variableResolver:i}){return e==null?[]:Object.entries(e).map(([n,a])=>UzM({parameterName:n,parameter:a,location:t,file:r,variableResolver:i}))}function UzM({parameterName:e,parameter:t,location:r,file:i,variableResolver:n}){return{...l8(t),name:i.casingsGenerator.generateName(e),valueType:LzM({parameter:t,variableResolver:n,file:i}),location:r,variable:YFn(t)?n.getVariableIdOrThrow(typeof t=="string"?t:t.variable):void 0,v2Examples:{userSpecifiedExamples:{},autogeneratedExamples:{}},explode:void 0}}function LzM({parameter:e,variableResolver:t,file:r}){let i=xEa({parameter:e,variableResolver:t,file:r});return i.file.parseTypeReference(i.rawType)}function xEa({parameter:e,variableResolver:t,file:r}){let i=O9o({parameter:e,variableResolver:t,file:r});if(i==null)throw new Error("Cannot resolve path parameter");return i}function O9o({parameter:e,variableResolver:t,file:r}){if(YFn(e)){let i=typeof e=="string"?e:e.variable,n=t.getDeclaration(i,r);return n==null?void 0:{rawType:typeof n.declaration=="string"?n.declaration:n.declaration.type,file:n.file}}else return{file:r,rawType:typeof e=="string"?e:e.type}}function VzM(e){switch(e){case"GET":return WP.Get;case"POST":return WP.Post;case"PUT":return WP.Put;case"PATCH":return WP.Patch;case"DELETE":return WP.Delete;case"HEAD":return WP.Head;default:Ot(e)}}function PPe({headerKey:e,header:t,file:r}){let{name:i}=Y9t({headerKey:e,header:t});return{...l8(t),name:r.casingsGenerator.generateNameAndWireValue({wireValue:e,name:i}),valueType:r.parseTypeReference(t),env:typeof t=="string"?void 0:t.env,v2Examples:{userSpecifiedExamples:{},autogeneratedExamples:{}}}}function Y9t({headerKey:e,header:t}){return typeof t!="string"&&t.name!=null?{name:t.name,wasExplicitlySet:!0}:{name:e,wasExplicitlySet:!1}}function WzM(e,t){switch(e.type){case"http":return{json:{},proto:void 0};case"grpc":return{json:void 0,proto:{}};default:Ot(e)}}var A9o=ue(Sv(),1);var XR_="1.0.0";var m9o=class{ir;casingsGenerator;auth;authValues;generatorConfig;extendedTypeIds;constructor(t){this.ir=t.ir,this.generatorConfig=t.generatorConfig,this.casingsGenerator=hx({generationLanguage:t.generationLanguage,smartCasing:t.smartCasing??!1,keywords:void 0}),this.auth=this.convertAuth(this.ir.auth),this.authValues=this.getAuthValues(this.ir.auth),this.extendedTypeIds=this.computeExtendedTypeIds()}computeExtendedTypeIds(){let t=new Set;for(let r of Object.values(this.ir.types))if(r.shape.type==="object")for(let i of r.shape.extends)t.add(i.typeId);return t}convert({disableExamples:t}){return{version:XR_,types:this.convertNamedTypes(),headers:this.convertHeaders(),endpoints:this.convertEndpoints({disableExamples:t}),pathParameters:this.convertPathParameters({pathParameters:this.ir.pathParameters}),environments:this.ir.environments,variables:this.convertVariables(),generatorConfig:this.generatorConfig}}convertNamedTypes(){return Object.fromEntries(Object.entries(this.ir.types).map(([t,r])=>[t,this.convertTypeDeclaration(r)]))}convertHeaders(){return this.convertWireValueParameters({wireValueParameters:this.ir.headers})}convertVariables(){if(this.ir.variables.length!==0)return this.ir.variables.map(t=>({id:t.id,name:t.name,typeReference:this.convertTypeReference(t.type)}))}convertEndpoints({disableExamples:t}){let r=this.getAllHttpEndpoints();return Object.fromEntries(r.map(i=>[i.id,this.convertEndpoint({endpoint:i,disableExamples:t})]))}convertEndpoint({endpoint:t,disableExamples:r}){let i=this.convertEndpointLocation({endpoint:t});return{auth:this.auth,declaration:this.convertDeclaration({name:t.name,fernFilepath:t.fernFilepath}),location:i,request:this.convertRequest({endpoint:t}),response:t.response?.body?._visit({json:()=>Kt.Response.json(),streaming:()=>Kt.Response.streaming(),streamParameter:()=>Kt.Response.streamParameter(),fileDownload:()=>Kt.Response.fileDownload(),text:()=>Kt.Response.text(),bytes:()=>Kt.Response.bytes(),_other:()=>Kt.Response.json()})??Kt.Response.json(),examples:r?void 0:this.getEndpointSnippetRequests({endpoint:t,location:i})}}convertRequest({endpoint:t}){let r=this.convertPathParameters({pathParameters:[...t.servicePathParameters,...t.pathParameters]});if(t.sdkRequest==null&&t.requestBody==null)return Kt.Request.body({pathParameters:r,body:void 0});if(t.sdkRequest==null)throw new Error(`Internal error; endpoint "${t.id}" has a request body but no SDK request`);switch(t.sdkRequest.shape.type){case"justRequestBody":return Kt.Request.body({pathParameters:r,body:this.convertReferencedRequestBodyType({body:t.sdkRequest.shape.value})});case"wrapper":return this.convertInlinedRequest({fernFilepath:t.fernFilepath,wrapper:t.sdkRequest.shape,pathParameters:r,queryParameters:this.convertQueryParameters({queryParameters:t.queryParameters}),headers:this.convertWireValueParameters({wireValueParameters:[...t.serviceHeaders,...t.headers]}),body:t.requestBody});default:Ot(t.sdkRequest.shape)}}convertReferencedRequestBodyType({body:t}){switch(t.type){case"bytes":return Kt.ReferencedRequestBodyType.bytes();case"typeReference":return Kt.ReferencedRequestBodyType.typeReference(this.convertTypeReference(t.requestBodyType));default:Ot(t)}}convertInlinedRequest({fernFilepath:t,wrapper:r,pathParameters:i,queryParameters:n,headers:a,body:o}){return Kt.Request.inlined({declaration:this.convertDeclaration({name:r.wrapperName,fernFilepath:t}),pathParameters:i,queryParameters:n,headers:a,body:o!=null?this.convertInlinedRequestBody({wrapper:r,body:o}):void 0,metadata:this.convertInlinedRequestMetadata({wrapper:r})})}convertInlinedRequestMetadata({wrapper:t}){return{includePathParameters:t.includePathParameters??!1,onlyPathParameters:t.onlyPathParameters??!1}}convertInlinedRequestBody({wrapper:t,body:r}){switch(r.type){case"inlinedRequestBody":{let i=[...r.extendedProperties??[],...r.properties];return Kt.InlinedRequestBody.properties(this.convertBodyPropertiesToParameters({properties:i}))}case"reference":return Kt.InlinedRequestBody.referenced({bodyKey:t.bodyKey,bodyType:Kt.ReferencedRequestBodyType.typeReference(this.convertTypeReference(r.requestBodyType))});case"bytes":return Kt.InlinedRequestBody.referenced({bodyKey:t.bodyKey,bodyType:Kt.ReferencedRequestBodyType.bytes()});case"fileUpload":return this.convertFileUploadRequestBody({properties:r.properties});default:Ot(r)}}convertFileUploadRequestBody({properties:t}){return Kt.InlinedRequestBody.fileUpload({properties:this.convertFileUploadRequestBodyProperties({properties:t})})}convertFileUploadRequestBodyProperties({properties:t}){return t.map(r=>{switch(r.type){case"file":return this.convertFileUploadRequestBodyFileProperty({fileProperty:r.value});case"bodyProperty":return Kt.FileUploadRequestBodyProperty.bodyProperty({name:r.name,typeReference:this.convertTypeReference(r.valueType),propertyAccess:r.propertyAccess,variable:void 0});default:Ot(r)}})}convertFileUploadRequestBodyFileProperty({fileProperty:t}){switch(t.type){case"file":return Kt.FileUploadRequestBodyProperty.file(t.key);case"fileArray":return Kt.FileUploadRequestBodyProperty.fileArray(t.key);default:Ot(t)}}convertPathParameters({pathParameters:t}){return t.map(r=>({name:{name:r.name,wireValue:r.name.originalName},typeReference:this.convertTypeReference(r.valueType),propertyAccess:void 0,variable:r.variable}))}convertBodyPropertiesToParameters({properties:t}){return t.map(r=>({name:{name:r.name.name,wireValue:r.name.wireValue},typeReference:this.convertTypeReference(r.valueType),propertyAccess:r.propertyAccess,variable:void 0}))}convertWireValueParameters({wireValueParameters:t}){return t.map(r=>({name:{name:r.name.name,wireValue:r.name.wireValue},typeReference:this.convertTypeReference(r.valueType),propertyAccess:void 0,variable:void 0}))}convertQueryParameters({queryParameters:t}){let r=[];for(let i of t){let n=this.convertTypeReference(i.valueType);i.allowMultiple&&(n=Kt.TypeReference.list(n)),r.push({name:{name:i.name.name,wireValue:i.name.wireValue},typeReference:n,propertyAccess:void 0,variable:void 0})}return r}convertTypeReference(t){switch(t.type){case"container":return this.convertContainerType(t.container);case"named":return this.convertNamedType(t);case"primitive":return this.convertPrimitiveType(t.primitive);case"unknown":return this.convertUnknownType();default:Ot(t)}}convertContainerType(t){switch(t.type){case"list":return Kt.TypeReference.list(this.convertTypeReference(t.list));case"map":return Kt.TypeReference.map({key:this.convertTypeReference(t.keyType),value:this.convertTypeReference(t.valueType)});case"optional":return Kt.TypeReference.optional(this.convertTypeReference(t.optional));case"nullable":return Kt.TypeReference.nullable(this.convertTypeReference(t.nullable));case"set":return Kt.TypeReference.set(this.convertTypeReference(t.set));case"literal":return Kt.TypeReference.literal(this.convertLiteral(t.literal));default:Ot(t)}}convertNamedType(t){return Kt.TypeReference.named(t.typeId)}convertTypeDeclaration(t){let r=this.convertDeclaration(t.name);switch(t.shape.type){case"alias":return this.convertAlias({declaration:r,alias:t.shape});case"enum":return this.convertEnum({declaration:r,enum_:t.shape});case"object":return this.convertObject({declaration:r,object:t.shape,typeId:t.name.typeId});case"union":return this.convertDiscriminatedUnion({declaration:r,union:t.shape});case"undiscriminatedUnion":return this.convertUndiscriminatedUnion({declaration:r,union:t.shape});default:Ot(t.shape)}}convertAlias({declaration:t,alias:r}){return Kt.NamedType.alias({declaration:t,typeReference:this.convertTypeReference(r.aliasOf)})}convertEnum({declaration:t,enum_:r}){return Kt.NamedType.enum({declaration:t,values:r.values.map(i=>i.name)})}convertObject({declaration:t,object:r,typeId:i}){let a=this.extendedTypeIds.has(i)?[...r.properties,...r.extendedProperties??[]]:[...r.extendedProperties??[],...r.properties];return this.convertObjectProperties({declaration:t,properties:a,additionalProperties:r.extraProperties})}convertObjectProperties({declaration:t,properties:r,additionalProperties:i}){return Kt.NamedType.object({declaration:t,properties:this.convertBodyPropertiesToParameters({properties:r}),additionalProperties:i})}convertDiscriminatedUnion({declaration:t,union:r}){let i=[...this.resolveProperties(r.extends),...r.baseProperties];return Kt.NamedType.discriminatedUnion({declaration:t,discriminant:r.discriminant,types:Object.fromEntries(r.types.map(n=>[n.discriminantValue.wireValue,this.convertDiscriminatedUnionType({inheritedProperties:i,discriminantValue:n.discriminantValue,singleUnionTypeProperties:n.shape})]))})}convertDiscriminatedUnionType({inheritedProperties:t,discriminantValue:r,singleUnionTypeProperties:i}){switch(i.propertiesType){case"samePropertiesAsObject":return this.convertDiscriminatedUnionTypeObject({inheritedProperties:t,discriminantValue:r,declaredTypeName:i});case"singleProperty":return this.convertDiscriminatedUnionTypeSingleProperty({inheritedProperties:t,discriminantValue:r,singleUnionTypeProperty:i});case"noProperties":return this.convertDiscriminatedUnionTypeNoProperties({inheritedProperties:t,discriminantValue:r});default:Ot(i)}}convertDiscriminatedUnionTypeObject({inheritedProperties:t,discriminantValue:r,declaredTypeName:i}){return Kt.SingleDiscriminatedUnionType.samePropertiesAsObject({typeId:i.typeId,discriminantValue:r,properties:this.convertBodyPropertiesToParameters({properties:t})})}convertDiscriminatedUnionTypeSingleProperty({inheritedProperties:t,discriminantValue:r,singleUnionTypeProperty:i}){return Kt.SingleDiscriminatedUnionType.singleProperty({typeReference:this.convertTypeReference(i.type),discriminantValue:r,properties:t.length>0?this.convertBodyPropertiesToParameters({properties:t}):void 0})}convertDiscriminatedUnionTypeNoProperties({inheritedProperties:t,discriminantValue:r}){return Kt.SingleDiscriminatedUnionType.noProperties({discriminantValue:r,properties:t.length>0?this.convertBodyPropertiesToParameters({properties:t}):void 0})}convertUndiscriminatedUnion({declaration:t,union:r}){return Kt.NamedType.undiscriminatedUnion({declaration:t,types:r.members.map(i=>this.convertTypeReference(i.type))})}convertLiteral(t){switch(t.type){case"boolean":return Kt.LiteralType.boolean(t.boolean);case"string":return Kt.LiteralType.string(t.string);default:Ot(t)}}convertPrimitiveType(t){return Kt.TypeReference.primitive(t.v1)}convertUnknownType(){return Kt.TypeReference.unknown()}convertAuth(t){if(t.schemes[0]==null)return;let r=t.schemes[0];switch(r.type){case"basic":return Kt.Auth.basic(r);case"bearer":return Kt.Auth.bearer(r);case"header":return Kt.Auth.header({header:{name:r.name,typeReference:this.convertTypeReference(r.valueType),propertyAccess:void 0,variable:void 0}});case"oauth":return Kt.Auth.oauth({clientId:this.casingsGenerator.generateName("clientId"),clientSecret:this.casingsGenerator.generateName("clientSecret")});case"inferred":return Kt.Auth.inferred({parameters:this.getInferredAuthParameters(r)});default:Ot(r)}}getAuthValues(t){let r=t.schemes[0];if(r!=null)switch(r.type){case"bearer":return Kt.AuthValues.bearer({token:"<token>"});case"basic":return Kt.AuthValues.basic({username:"<username>",password:"<password>"});case"header":return Kt.AuthValues.header({value:"<value>"});case"oauth":return Kt.AuthValues.oauth({clientId:"<clientId>",clientSecret:"<clientSecret>"});case"inferred":return Kt.AuthValues.inferred({values:this.getInferredAuthValues(r)});default:Ot(r)}}getInferredAuthParameters(t){let r=[],i=Object.values(this.ir.services).flatMap(n=>n.endpoints).find(n=>n.id===t.tokenEndpoint.endpoint.endpointId);if(i==null)return r;for(let n of i.headers)(n.valueType.type!=="container"||n.valueType.container.type!=="literal")&&r.push({name:{name:n.name.name,wireValue:n.name.wireValue},typeReference:this.convertTypeReference(n.valueType),propertyAccess:void 0,variable:void 0});if(i.requestBody!=null&&i.requestBody.type==="inlinedRequestBody")for(let n of i.requestBody.properties)(n.valueType.type!=="container"||n.valueType.container.type!=="literal")&&r.push({name:{name:n.name.name,wireValue:n.name.wireValue},typeReference:this.convertTypeReference(n.valueType),propertyAccess:void 0,variable:void 0});return r}getInferredAuthValues(t){let r={},i=Object.values(this.ir.services).flatMap(n=>n.endpoints).find(n=>n.id===t.tokenEndpoint.endpoint.endpointId);if(i==null)return r;for(let n of i.headers)(n.valueType.type!=="container"||n.valueType.container.type!=="literal")&&(r[n.name.wireValue]=n.name.wireValue);if(i.requestBody!=null&&i.requestBody.type==="inlinedRequestBody")for(let n of i.requestBody.properties)(n.valueType.type!=="container"||n.valueType.container.type!=="literal")&&(r[n.name.wireValue]=n.name.wireValue);return r}convertDeclaration({name:t,fernFilepath:r}){return{name:t,fernFilepath:r}}convertEndpointLocation({endpoint:t}){return{method:t.method,path:this.getFullPathForEndpoint(t)}}getAllHttpEndpoints(){return Object.values(this.ir.services).flatMap(t=>t.endpoints.map(r=>({...r,servicePathParameters:t.pathParameters,serviceHeaders:t.headers,fernFilepath:t.name.fernFilepath})))}resolveProperties(t){let r=[];for(let i of t){let n=this.resolveObjectTypeOrThrow(i.typeId);r.push(...this.resolveProperties(n.extends)),r.push(...n.properties)}return Object.values(r)}resolveObjectTypeOrThrow(t){let r=this.ir.types[t];if(r==null)throw new Error(`Internal error; type "${t}" not found`);if(r.shape.type!=="object")throw new Error(`Internal error; type "${t}" is not an object`);return r.shape}getFullPathForEndpoint(t){let r="";t.fullPath.head.length>0&&(r=(0,A9o.default)(r,t.fullPath.head));for(let i of t.fullPath.parts)r=(0,A9o.default)(r,"{"+i.pathParameter+"}"),i.tail.length>0&&(r=(0,A9o.default)(r,i.tail));return r.startsWith("/")?r:`/${r}`}getEndpointSnippetRequests({endpoint:t,location:r}){let i=[];for(let n of[...t.userSpecifiedExamples,...t.autogeneratedExamples]){let a=new Set;[...this.ir.pathParameters,...t.pathParameters].forEach(c=>{c.variable!=null&&a.add(c.name.originalName)});let o=[...n.example?.rootPathParameters??[],...n.example?.servicePathParameters??[],...n.example?.endpointPathParameters??[]].filter(c=>!a.has(c.name.originalName));i.push({id:n?.example?.id??ehe(),name:n?.example?.name?.originalName,endpoint:r,baseUrl:void 0,environment:void 0,auth:this.authValues,headers:Object.fromEntries([...n.example?.serviceHeaders??[],...n.example?.endpointHeaders??[]].map(c=>[c.name.wireValue,c.value.jsonExample])),pathParameters:Object.fromEntries(o.map(c=>[c.name.originalName,c.value.jsonExample])),queryParameters:Object.fromEntries([...n.example?.queryParameters??[]].map(c=>[c.name.wireValue,c.value.jsonExample])),requestBody:n.example?.request?.jsonExample})}return i}};function GEa({ir:e,generationLanguage:t,smartCasing:r,disableExamples:i,generatorConfig:n}){return new m9o({ir:e,generationLanguage:t,smartCasing:r,generatorConfig:n}).convert({disableExamples:i})}var f8={};Yt(f8,{validateObjectExample:()=>R$i,validateTypeExample:()=>h9o,validateTypeReferenceExample:()=>Sz});function ZR_(e){return{errorInstanceIdKey:e.generateNameAndWireValue({wireValue:"errorInstanceId",name:"errorInstanceId"})}}var P9o=e=>{let t=Ohe(e.file.fernFilepath),r=e.endpointId;return`endpoint_${t}.${r}`};function j9o({fernFilePath:e}){return e.packagePath.length===0&&e.file==null}function w9o({resolvedEndpoint:e}){return{endpointId:P9o(e),serviceId:up.generateServiceIdFromFernFilepath(e.file.fernFilepath),subpackageId:j9o({fernFilePath:e.file.fernFilepath})?void 0:up.generateSubpackageId(e.file.fernFilepath)}}function kR_({endpointResolver:e,propertyResolver:t,file:r,refreshTokenEndpoint:i}){let n=e.resolveEndpointOrThrow({endpoint:i.endpoint,file:r}),a;try{a=i.responseProperties.expires_in!=null?t.resolveResponsePropertyOrThrow({file:r,endpoint:i.endpoint,propertyComponents:i.responseProperties.expires_in}):void 0}catch{}return{endpointReference:{endpointId:P9o(n),serviceId:up.generateServiceIdFromFernFilepath(n.file.fernFilepath),subpackageId:j9o({fernFilePath:n.file.fernFilepath})?void 0:up.generateSubpackageId(n.file.fernFilepath)},requestProperties:{refreshToken:t.resolveRequestPropertyOrThrow({file:r,endpoint:i.endpoint,propertyComponents:i.requestProperties.refresh_token})},responseProperties:{accessToken:t.resolveResponsePropertyOrThrow({file:r,endpoint:i.endpoint,propertyComponents:i.responseProperties.access_token}),expiresIn:a,refreshToken:i.responseProperties.refresh_token!=null?t.resolveResponsePropertyOrThrow({file:r,endpoint:i.endpoint,propertyComponents:i.responseProperties.refresh_token}):void 0}}}function ez_({endpointResolver:e,propertyResolver:t,file:r,tokenEndpoint:i}){let n=e.resolveEndpointOrThrow({endpoint:i.endpoint,file:r}),a=typeof n.endpoint.request=="object"&&n.endpoint.request.body!=null&&typeof n.endpoint.request.body=="object"&&"properties"in n.endpoint.request.body?n.endpoint.request.body.properties??{}:{},o;try{o=i.responseProperties.expires_in!=null?t.resolveResponsePropertyOrThrow({file:r,endpoint:i.endpoint,propertyComponents:i.responseProperties.expires_in}):void 0}catch{}return{endpointReference:w9o({resolvedEndpoint:n}),requestProperties:{clientId:t.resolveRequestPropertyOrThrow({file:r,endpoint:i.endpoint,propertyComponents:i.requestProperties.client_id}),clientSecret:t.resolveRequestPropertyOrThrow({file:r,endpoint:i.endpoint,propertyComponents:i.requestProperties.client_secret}),scopes:i.requestProperties.scopes!=null?t.resolveRequestPropertyOrThrow({file:r,endpoint:i.endpoint,propertyComponents:i.requestProperties.scopes}):void 0,customProperties:xzM({requestBodyProperties:a,tokenEndpoint:i,file:r,propertyResolver:t})},responseProperties:{accessToken:t.resolveResponsePropertyOrThrow({file:r,endpoint:i.endpoint,propertyComponents:i.responseProperties.access_token}),expiresIn:o,refreshToken:i.responseProperties.refresh_token!=null?t.resolveResponsePropertyOrThrow({file:r,endpoint:i.endpoint,propertyComponents:i.responseProperties.refresh_token}):void 0}}}var xzM=({requestBodyProperties:e,tokenEndpoint:t,file:r,propertyResolver:i})=>{let n=Object.keys(e).filter(a=>!t.requestProperties.client_id.includes(a)&&!t.requestProperties.client_secret.includes(a)&&(t.requestProperties.scopes==null||!t.requestProperties.scopes.includes(a)));return n.length>0?n.map(a=>i.resolveRequestPropertyOrThrow({file:r,endpoint:t.endpoint,propertyComponents:[a]})):void 0};function tz_({propertyResolver:e,endpointResolver:t,file:r,oauthScheme:i,tokenEndpoint:n,refreshTokenEndpoint:a}){let o=ez_({propertyResolver:e,endpointResolver:t,file:r,tokenEndpoint:n});if(o==null)throw new Error("Failed to convert OAuth token endpoint.");let c=a!=null?kR_({propertyResolver:e,endpointResolver:t,file:r,refreshTokenEndpoint:a}):void 0;return{clientIdEnvVar:i["client-id-env"],clientSecretEnvVar:i["client-secret-env"],tokenPrefix:i["token-prefix"],tokenHeader:i["token-header"],scopes:i.scopes,tokenEndpoint:o,refreshEndpoint:c}}var HEa={requestProperties:{type:"access_token",client_id:["client_id"],client_secret:["client_secret"],scopes:void 0},responseProperties:{type:"access_token",access_token:["access_token"],expires_in:["expires_in"],refresh_token:void 0}},Nvc={requestProperties:{type:"refresh_token",refresh_token:["refresh_token"]},responseProperties:{type:"access_token",access_token:["access_token"],refresh_token:void 0,expires_in:["expires_in"]}};function rz_(e){return{endpoint:e["get-token"].endpoint,requestProperties:GzM({requestProperties:e["get-token"]?.["request-properties"]}),responseProperties:HzM({responseProperties:e["get-token"]?.["response-properties"]})}}function iz_(e){if(e["refresh-token"]!=null)return{endpoint:e["refresh-token"].endpoint,requestProperties:KzM({requestProperties:e["refresh-token"]?.["request-properties"]}),responseProperties:JzM({responseProperties:e["refresh-token"]?.["response-properties"]})}}function GzM({requestProperties:e}){if(e==null)return HEa.requestProperties;let t=e["client-id"],r=e["client-secret"],i=e.scopes;return{type:"access_token",client_id:t!=null?UFt(t):HEa.requestProperties.client_id,client_secret:r!=null?UFt(r):HEa.requestProperties.client_secret,scopes:i!=null?UFt(i):HEa.requestProperties.scopes}}function HzM({responseProperties:e}){return nz_({responseProperties:e,defaultValue:HEa.responseProperties})}function KzM({requestProperties:e}){if(e==null)return Nvc.requestProperties;let t=e["refresh-token"];return{type:"refresh_token",refresh_token:t!=null?UFt(t):Nvc.requestProperties.refresh_token}}function JzM({responseProperties:e}){return nz_({responseProperties:e,defaultValue:Nvc.responseProperties})}function nz_({responseProperties:e,defaultValue:t}){if(e==null)return t;let r=e["access-token"],i=e["expires-in"],n=e["refresh-token"];return{type:"access_token",access_token:r!=null?Hhe(r):t.access_token,expires_in:i!=null?Hhe(i):t.expires_in,refresh_token:n!=null?Hhe(n):t.refresh_token}}function cz_({rawApiFileSchema:e,file:t,propertyResolver:r,endpointResolver:i}){if(e.auth==null)return{docs:void 0,requirement:C3.All,schemes:[]};let n=typeof e.auth!="string"?e.auth.docs:void 0;return NKi(e.auth,{single:a=>{let o=az_({reference:a,authSchemeDeclarations:e["auth-schemes"],file:t,propertyResolver:r,endpointResolver:i});return{docs:n,requirement:C3.All,schemes:[o]}},any:({any:a})=>({docs:n,requirement:C3.Any,schemes:a.map(o=>az_({reference:o,authSchemeDeclarations:e["auth-schemes"],file:t,propertyResolver:r,endpointResolver:i}))})})}function az_({reference:e,authSchemeDeclarations:t,file:r,propertyResolver:i,endpointResolver:n}){let a=(c,f)=>{let s=t?.[c];if(s==null)throw new Error("Unknown auth scheme: "+c);return tPa(s,{header:u=>wA.header({key:c,docs:f,name:r.casingsGenerator.generateNameAndWireValue({name:u.name??c,wireValue:u.header}),valueType:r.parseTypeReference(u.type??"string"),prefix:u.prefix,headerEnvVar:u.env}),basic:u=>uz_({key:c,file:r,docs:f,rawScheme:u}),tokenBearer:u=>oz_({key:c,file:r,docs:f,rawScheme:u}),inferredBearer:u=>$zM({key:c,file:r,docs:f,rawScheme:u,propertyResolver:i,endpointResolver:n}),oauth:u=>sz_({key:c,file:r,docs:f,rawScheme:u,propertyResolver:i,endpointResolver:n})})},o=typeof e=="string"?e:e.scheme;switch(o){case"bearer":return oz_({key:o,file:r,docs:void 0,rawScheme:void 0});case"basic":return uz_({key:o,file:r,docs:void 0,rawScheme:void 0});case"oauth":return sz_({key:o,file:r,docs:void 0,rawScheme:void 0,propertyResolver:i,endpointResolver:n});default:return a(o,typeof e!="string"?e.docs:void 0)}}function oz_({key:e,file:t,docs:r,rawScheme:i}){return wA.bearer({key:e,docs:r,token:t.casingsGenerator.generateName(i?.token?.name??"token"),tokenEnvVar:i?.token?.env})}function uz_({key:e,file:t,docs:r,rawScheme:i}){return wA.basic({key:e,docs:r,username:t.casingsGenerator.generateName(i?.username?.name??"username"),usernameEnvVar:i?.username?.env,password:t.casingsGenerator.generateName(i?.password?.name??"password"),passwordEnvVar:i?.password?.env})}function sz_({key:e,file:t,docs:r,rawScheme:i,propertyResolver:n,endpointResolver:a}){switch(i?.type){case"client-credentials":return wA.oauth({key:e,docs:r,configuration:$Ii.clientCredentials(tz_({propertyResolver:n,endpointResolver:a,file:t,oauthScheme:i,tokenEndpoint:rz_(i),refreshTokenEndpoint:iz_(i)}))});default:throw new Error(`Unknown OAuth type: '${i?.type}'`)}}function $zM({key:e,file:t,docs:r,rawScheme:i,propertyResolver:n,endpointResolver:a}){return wA.inferred({key:e,docs:r,tokenEndpoint:YzM({file:t,rawScheme:i,propertyResolver:n,endpointResolver:a})})}function YzM({file:e,rawScheme:t,propertyResolver:r,endpointResolver:i}){let n=t["get-token"],a=typeof n=="string"?{endpoint:n}:n,o=i.resolveEndpointOrThrow({endpoint:a.endpoint,file:e});return{endpoint:w9o({resolvedEndpoint:o}),expiryProperty:tNM({tokenEndpoint:o,getTokenEndpointConfig:a,propertyResolver:r}),authenticatedRequestHeaders:ZzM({tokenEndpoint:o,getTokenEndpointConfig:a,propertyResolver:r})}}var XzM=["access_token","accessToken","AccessToken","token","Token","auth_token","authToken","AuthToken","bearer_token","bearerToken","BearerToken","jwt","Jwt","authentication_token","authenticationToken","AuthenticationToken"];function ZzM({tokenEndpoint:e,getTokenEndpointConfig:t,propertyResolver:r}){let i=new Map,n=t["authenticated-request-headers"]??[];if(n.length>0&&n.forEach(a=>{i.set(a["header-name"].toLowerCase(),{headerName:a["header-name"],responseProperty:r.resolveResponsePropertyOrThrow({file:e.file,endpoint:e.endpointId,propertyComponents:Hhe(a["response-property"])}),valuePrefix:a["value-prefix"]})}),!i.has("authorization")){let a=kzM({tokenEndpoint:e,propertyResolver:r});a&&i.set("authorization",{headerName:"Authorization",responseProperty:a,valuePrefix:"Bearer "})}return Array.from(i.values())}function kzM({tokenEndpoint:e,propertyResolver:t}){for(let r of XzM)try{let i=t.resolveResponseProperty({file:e.file,endpoint:e.endpointId,propertyComponents:[r]});if(i)return i}catch{}}var eNM=["expires_in","expiresIn","ExpiresIn","exp","Exp","expiry","Expiry","expires","Expires","expires_at","expiresAt","ExpiresAt","expiration","Expiration","valid_until","validUntil","ValidUntil"];function tNM({tokenEndpoint:e,getTokenEndpointConfig:t,propertyResolver:r}){if(t["expiry-response-property"])return r.resolveResponsePropertyOrThrow({file:e.file,endpoint:e.endpointId,propertyComponents:Hhe(t["expiry-response-property"])});for(let i of eNM)try{let n=r.resolveResponseProperty({file:e.file,endpoint:e.endpointId,propertyComponents:[i]});if(n)return n}catch{}}function lz_({file:e,rawApiFileSchema:t}){if(t.version!=null)return ZIi.header({header:rNM({file:e,header:t.version.header}),value:iNM({file:e,versionDeclaration:t.version})})}function rNM({file:e,header:t}){return typeof t=="string"?PPe({file:e,headerKey:t,header:{type:"string"}}):PPe({file:e,headerKey:t.value,header:{type:"string",name:t.name,env:t.env}})}function iNM({file:e,versionDeclaration:t}){return y9o({_enum:{default:t.default,enum:t.values},file:e})}function fz_({channel:e,typeResolver:t,exampleResolver:r,variableResolver:i,file:n,workspace:a}){let o=[];for(let[c,f]of Object.entries(e.messages??{}))o.push({type:c,availability:vK(f.availability),docs:f.docs,origin:f.origin,body:oNM({body:f.body,file:n}),displayName:f["display-name"]});return{availability:vK(e.availability),path:PD(e.path),baseUrl:e.url,auth:e.auth,name:n.fernFilepath.file??n.casingsGenerator.generateName(e["display-name"]??e.path),displayName:e["display-name"],headers:e.headers!=null?Object.entries(e.headers).map(([c,f])=>PPe({headerKey:c,header:f,file:n})):[],docs:e.docs,pathParameters:e["path-parameters"]!=null?qLn({pathParameters:e["path-parameters"],location:j0e.Endpoint,file:n,variableResolver:i}):[],queryParameters:e["query-parameters"]!=null?Object.entries(e["query-parameters"]).map(([c,f])=>{let{name:s}=Qgi({queryParameterKey:c,queryParameter:f}),u=n.parseTypeReference(f);return{...l8(f),name:n.casingsGenerator.generateNameAndWireValue({wireValue:c,name:s}),valueType:u,allowMultiple:typeof f!="string"&&f["allow-multiple"]!=null?f["allow-multiple"]:!1,v2Examples:{userSpecifiedExamples:{},autogeneratedExamples:{}},explode:void 0}}):[],messages:Object.values(o),examples:(e.examples??[]).map(c=>{let f=sNM({channel:e,example:c,typeResolver:t,exampleResolver:r,variableResolver:i,file:n,workspace:a});return{name:c.name!=null?n.casingsGenerator.generateName(c.name):void 0,docs:c.docs,url:lNM({channel:e,example:c,pathParams:f}),...f,...cNM({channel:e,example:c,typeResolver:t,exampleResolver:r,file:n,workspace:a}),queryParameters:c["query-parameters"]!=null?Object.entries(c["query-parameters"]).map(([s,u])=>{let l=e["query-parameters"]?.[s];if(l==null)throw new Error(`Query parameter ${s} does not exist`);return{name:n.casingsGenerator.generateNameAndWireValue({name:Qgi({queryParameterKey:s,queryParameter:l}).name,wireValue:s}),value:Rv({example:u,rawTypeBeingExemplified:typeof l=="string"?l:l.type,typeResolver:t,exampleResolver:r,fileContainingRawTypeReference:n,fileContainingExample:n,workspace:a}),shape:nNM({queryParameter:l})}}):[],messages:c.messages.map(s=>{let u=e.messages?.[s.type];if(u==null)throw new Error(`Message ${s.type} does not exist`);return{type:s.type,body:aNM({message:u,example:s.body,typeResolver:t,exampleResolver:r,file:n,workspace:a})}})}}),v2Examples:{userSpecifiedExamples:{},autogeneratedExamples:{}}}}function nNM({queryParameter:e}){return(typeof e!="string"&&e["allow-multiple"]!=null?e["allow-multiple"]:!1)?M1.exploded():M1.single()}function aNM({message:e,example:t,typeResolver:r,exampleResolver:i,file:n,workspace:a}){if(!fNM(e.body))return bhe.reference(Rv({example:t,rawTypeBeingExemplified:typeof e.body!="string"?e.body.type:e.body,typeResolver:r,exampleResolver:i,fileContainingRawTypeReference:n,fileContainingExample:n,workspace:a}));if(!$c(t))throw new Error("Example must be an object");let o=[];for(let[c,f]of Object.entries(t)){let s=e.body.properties?.[c];if(s!=null)o.push({name:n.casingsGenerator.generateNameAndWireValue({name:Ez({propertyKey:c,property:s}).name,wireValue:c}),value:Rv({example:f,rawTypeBeingExemplified:typeof s!="string"?s.type:s,typeResolver:r,exampleResolver:i,fileContainingRawTypeReference:n,fileContainingExample:n,workspace:a}),originalTypeDeclaration:void 0});else{let u=WEa({extends_:e.body.extends,wirePropertyKey:c,typeResolver:r,file:n});if(u==null)throw new Error("Could not find original type declaration for property: "+c);o.push({name:n.casingsGenerator.generateNameAndWireValue({name:Ez({propertyKey:c,property:u.rawPropertyType}).name,wireValue:c}),value:Rv({example:f,rawTypeBeingExemplified:typeof u.rawPropertyType=="string"?u.rawPropertyType:u.rawPropertyType.type,typeResolver:r,exampleResolver:i,fileContainingRawTypeReference:u.file,fileContainingExample:n,workspace:a}),originalTypeDeclaration:u.typeName})}}return bhe.inlinedBody({jsonExample:i.resolveAllReferencesInExampleOrThrow({example:t,file:n}).resolvedExample,properties:o,extraProperties:void 0})}function oNM({body:e,file:t}){return typeof e=="string"?nz.reference({docs:void 0,bodyType:t.parseTypeReference(e)}):uNM(e)?nz.reference({docs:void 0,bodyType:t.parseTypeReference(e.type)}):nz.inlinedBody({name:t.casingsGenerator.generateName(e.name),extends:QFt(e.extends??[]).map(r=>wz({typeName:r,file:t})),properties:Object.entries(e.properties??{}).map(([r,i])=>({name:t.casingsGenerator.generateNameAndWireValue({name:Ez({propertyKey:r,property:i}).name,wireValue:r}),value:t.parseTypeReference(i),valueType:t.parseTypeReference(i),availability:void 0,docs:void 0}))})}function uNM(e){return e.type!=null}function sNM({channel:e,example:t,typeResolver:r,exampleResolver:i,variableResolver:n,file:a,workspace:o}){let c=[],f=({name:s,pathParameterDeclaration:u,examplePathParameter:l})=>{let p=xEa({parameter:u,variableResolver:n,file:a});return{name:s,value:Rv({example:l,rawTypeBeingExemplified:p.rawType,typeResolver:r,exampleResolver:i,fileContainingRawTypeReference:p.file,fileContainingExample:a,workspace:o})}};if(t["path-parameters"]!=null){let s=LFt(e);for(let[u,l]of Object.entries(t["path-parameters"])){let p=s[u];if(p!=null)c.push(f({name:a.casingsGenerator.generateName(u),pathParameterDeclaration:p,examplePathParameter:l}));else throw new Error(`Path parameter ${u} does not exist`)}}return{pathParameters:c}}function cNM({channel:e,example:t,typeResolver:r,exampleResolver:i,file:n,workspace:a}){let o=[];if(t.headers!=null)for(let[c,f]of Object.entries(t.headers)){let s=e.headers?.[c];s!=null&&o.push({name:n.casingsGenerator.generateNameAndWireValue({name:Y9t({headerKey:c,header:s}).name,wireValue:c}),value:Rv({example:f,rawTypeBeingExemplified:typeof s=="string"?s:s.type,typeResolver:r,exampleResolver:i,fileContainingRawTypeReference:n,fileContainingExample:n,workspace:a})})}return{headers:o}}function lNM({channel:e,example:t,pathParams:r}){let i=e.path;if(t["path-parameters"]!=null)for(let n of[...r.pathParameters])i=i.replaceAll(`{${n.name.originalName}}`,encodeURIComponent(`${n.value.jsonExample}`));return i}function fNM(e){return typeof e=="string"?!1:e.extends!=null||e.properties!=null}function dz_({errorName:e,errorDeclaration:t,file:r,typeResolver:i,exampleResolver:n,workspace:a}){let o=[];if(t.type!=null&&t.examples!=null)for(let c of t.examples)o.push({name:c.name!=null?r.casingsGenerator.generateName(c.name):void 0,docs:c.docs,jsonExample:n.resolveAllReferencesInExampleOrThrow({example:c.value,file:r}).resolvedExample,shape:Rv({example:c.value,rawTypeBeingExemplified:t.type,fileContainingRawTypeReference:r,fileContainingExample:r,typeResolver:i,exampleResolver:n,workspace:a})});return{name:l1i({errorName:e,file:r}),discriminantValue:r.casingsGenerator.generateNameAndWireValue({wireValue:e,name:e}),docs:typeof t!="string"?t.docs:void 0,statusCode:t["status-code"],isWildcardStatusCode:void 0,type:t.type!=null?r.parseTypeReference(t.type):void 0,examples:o,v2Examples:void 0,displayName:void 0,headers:[]}}var pz_="content";function _z_(e,t){if(e==null||e.strategy==="status-code")return yhe.statusCode();switch(e.strategy){case"property":return yhe.property({discriminant:t.casingsGenerator.generateNameAndWireValue({name:e["property-name"],wireValue:e["property-name"]}),contentProperty:t.casingsGenerator.generateNameAndWireValue({name:pz_,wireValue:pz_})});default:Ot(e)}}var E9o=ue(Sv(),1);function hz_({readme:e,services:t}){let r=new Fvc(t);return{apiName:e.apiName,disabledFeatures:e.disabledSections?.map(i=>i.toUpperCase()),apiReferenceLink:e.apiReferenceLink,bannerLink:e.bannerLink,introduction:e.introduction,customSections:e.customSections,exampleStyle:e.exampleStyle,whiteLabel:!1,defaultEndpoint:e.defaultEndpoint!=null?r.getEndpointForReadmeOrThrow(e.defaultEndpoint).id:void 0,features:e.features!=null?Object.fromEntries(Object.entries(e.features).map(([i,n])=>[i,n.map(a=>r.getEndpointForReadmeOrThrow(a).id)])):void 0}}var Fvc=class{endpoints={};constructor(t){this.endpoints=this.buildEndpoints(t)}getEndpointForReadme(t){let r=pNM({endpoint:t}),i=this.getEndpointKeyForReadmeEndpoint(r);return this.endpoints[i]}getEndpointForReadmeOrThrow(t){let r=this.getEndpointForReadme(t);if(r==null)throw new Error(`Endpoint not found for ${JSON.stringify(t)}`);return r}buildEndpoints(t){let r={};for(let i of Object.values(t))for(let n of i.endpoints)r[this.getEndpointKeyForHttpEndpoint(n)]=n;return r}getEndpointKeyForReadmeEndpoint(t){return this.getEndpointKey({method:t.method,path:t.path,stream:t.stream??!1})}getEndpointKeyForHttpEndpoint(t){return this.getEndpointKey({method:t.method,path:dNM(t),stream:t.response?.body?.type==="streaming"})}getEndpointKey({method:t,path:r,stream:i}){return`${t}|${r}|${i}`}};function dNM(e){let t="";e.fullPath.head.length>0&&(t=(0,E9o.default)(t,e.fullPath.head));for(let r of e.fullPath.parts)t=(0,E9o.default)(t,"{"+r.pathParameter+"}"),r.tail.length>0&&(t=(0,E9o.default)(t,r.tail));return t.startsWith("/")?t:`/${t}`}function pNM({endpoint:e}){if(typeof e=="string"){let t=e.split(" ");if(t.length!==2||t[0]==null||t[1]==null)throw new Error(`invalid endpoint string: ${e}`);return{method:t[0],path:t[1]}}return e}function yz_({webhooks:e,file:t,typeResolver:r,exampleResolver:i,workspace:n}){let a=[];for(let[o,c]of Object.entries(e))a.push({id:up.generateWebhookId(t.fernFilepath,o),availability:vK(c.availability),displayName:c["display-name"],docs:c.docs,method:c.method,name:t.casingsGenerator.generateName(o),headers:c.headers!=null?Object.entries(c.headers).map(([f,s])=>PPe({headerKey:f,header:s,file:t})):[],payload:_NM({payload:c.payload,file:t}),responses:bNM({webhook:c,file:t,typeResolver:r}),examples:c.examples!=null?yNM({webhook:c,examples:c.examples,file:t,typeResolver:r,exampleResolver:i,workspace:n}):void 0,v2Examples:void 0});return a}function _NM({payload:e,file:t}){return typeof e=="string"?LQ.reference({docs:void 0,payloadType:t.parseTypeReference(e)}):rQn(e)?LQ.reference({docs:void 0,payloadType:t.parseTypeReference(e.type)}):LQ.inlinedPayload({name:t.casingsGenerator.generateName(e.name),extends:QFt(e.extends).map(r=>wz({typeName:r,file:t})),properties:e.properties!=null?Object.entries(e.properties).map(([r,i])=>hNM({propertyKey:r,propertyDefinition:i,docs:typeof i!="string"?i.docs:void 0,availability:typeof i!="string"?vK(i.availability):void 0,file:t})):[]})}function hNM({propertyKey:e,propertyDefinition:t,docs:r,availability:i,file:n}){return{docs:r,availability:i,name:n.casingsGenerator.generateNameAndWireValue({wireValue:e,name:Ez({propertyKey:e,property:t}).name}),valueType:n.parseTypeReference(t)}}function yNM({webhook:e,examples:t,file:r,typeResolver:i,exampleResolver:n,workspace:a}){let o=typeof e.payload=="string"?e.payload:rQn(e.payload)?e.payload.type:void 0;if(o!=null)return t.map(c=>({docs:e.docs,name:c.name!=null?r.casingsGenerator.generateName(c.name):void 0,payload:Rv({example:c.payload,rawTypeBeingExemplified:o,fileContainingRawTypeReference:r,fileContainingExample:r,typeResolver:i,exampleResolver:n,workspace:a})}));if(!$c(e.payload))throw new Error(`Example webhook payload is not an object. Got: ${JSON.stringify(e.payload)}`);return t.map(c=>({docs:e.docs,name:c.name!=null?r.casingsGenerator.generateName(c.name):void 0,payload:Rv({example:c.payload,rawTypeBeingExemplified:"map<string, unknown>",fileContainingRawTypeReference:r,fileContainingExample:r,typeResolver:i,exampleResolver:n,workspace:a})}))}function bNM({webhook:e,file:t,typeResolver:r}){let i=[];if(e.response!=null){let n=vNM({response:e.response,file:t,typeResolver:r}),a=typeof e.response!="string"?e.response["status-code"]:void 0,o=typeof e.response!="string"?e.response.docs:void 0;i.push({body:n,statusCode:a,isWildcardStatusCode:void 0,docs:o})}if(e["response-stream"]!=null){let n=gNM({responseStream:e["response-stream"],file:t,typeResolver:r});if(n!=null){let a=typeof e["response-stream"]!="string"?e["response-stream"].docs:void 0;i.push({body:Xf.streaming(n),statusCode:void 0,isWildcardStatusCode:void 0,docs:a})}}return i.length>0?i:void 0}function vNM({response:e,file:t,typeResolver:r}){let i=typeof e!="string"?e.docs:void 0,n=typeof e=="string"?e:e.type;if(n!=null)return ZH(n)!=null?Xf.fileDownload({docs:i,v2Examples:void 0}):RKi(n)!=null?Xf.text({docs:i,v2Examples:void 0}):z0e(n)!=null?Xf.bytes({docs:i,v2Examples:void 0}):ONM(e,i,t,r)}function gNM({responseStream:e,file:t,typeResolver:r}){let i=typeof e!="string"?e.docs:void 0,n=typeof e=="string"?e:e.type,a=typeof e=="string"?"json":e.format??"json";return OCi(n)?AD.text({docs:i,v2Examples:void 0}):typeof e!="string"&&a==="sse"?AD.sse({docs:i,payload:t.parseTypeReference(n),terminator:typeof e!="string"?e.terminator:void 0,v2Examples:void 0}):AD.json({docs:i,payload:t.parseTypeReference(n),terminator:typeof e!="string"?e.terminator:void 0,v2Examples:void 0})}function ONM(e,t,r,i){let n=typeof e!="string"?e.type:e;if(n==null)return;let a=r.parseTypeReference(typeof e=="string"?e:{...e,type:n}),o=i.resolveTypeOrThrow({type:n,file:r}),c=typeof e!="string"?e.property:void 0;return c!=null?Xf.json(mB.nestedPropertyAsResponse({docs:t,responseBodyType:a,responseProperty:T$i({typeResolver:i,file:r,resolvedType:o,property:c}),v2Examples:void 0})):Xf.json(mB.response({docs:t,responseBodyType:a,v2Examples:void 0}))}function bz_({name:e,source:t}){return Dh.userDefined({file:v9o({source:t}),name:f1i.generateName(e)})}function vz_({encoding:e}){if(e.proto!=null&&e.proto.type!=null){let t=ANM({type:e.proto.type});if(t!=null)return t}}function ANM({type:e}){switch(e){case"google.protobuf.Any":return Dh.wellKnown(sn.any());case"google.protobuf.Api":return Dh.wellKnown(sn.api());case"google.protobuf.BoolValue":return Dh.wellKnown(sn.boolValue());case"google.protobuf.BytesValue":return Dh.wellKnown(sn.bytesValue());case"google.protobuf.DoubleValue":return Dh.wellKnown(sn.doubleValue());case"google.protobuf.Duration":return Dh.wellKnown(sn.duration());case"google.protobuf.Empty":return Dh.wellKnown(sn.empty());case"google.protobuf.Enum":return Dh.wellKnown(sn.enum());case"google.protobuf.EnumValue":return Dh.wellKnown(sn.enumValue());case"google.protobuf.Field":return Dh.wellKnown(sn.field());case"google.protobuf.FieldCardinality":return Dh.wellKnown(sn.fieldCardinality());case"google.protobuf.FieldKind":return Dh.wellKnown(sn.fieldKind());case"google.protobuf.FieldMask":return Dh.wellKnown(sn.fieldMask());case"google.protobuf.FloatVlaue":return Dh.wellKnown(sn.floatValue());case"google.protobuf.Int32Value":return Dh.wellKnown(sn.int32Value());case"google.protobuf.Int64Value":return Dh.wellKnown(sn.int64Value());case"google.protobuf.ListValue":return Dh.wellKnown(sn.listValue());case"google.protobuf.Method":return Dh.wellKnown(sn.method());case"google.protobuf.Mixin":return Dh.wellKnown(sn.mixin());case"google.protobuf.NullValue":return Dh.wellKnown(sn.nullValue());case"google.protobuf.Option":return Dh.wellKnown(sn.option());case"google.protobuf.SourceContext":return Dh.wellKnown(sn.sourceContext());case"google.protobuf.StringValue":return Dh.wellKnown(sn.stringValue());case"google.protobuf.Struct":return Dh.wellKnown(sn.struct());case"google.protobuf.Syntax":return Dh.wellKnown(sn.syntax());case"google.protobuf.Timestamp":return Dh.wellKnown(sn.timestamp());case"google.protobuf.Type":return Dh.wellKnown(sn.type());case"google.protobuf.Uint32Value":return Dh.wellKnown(sn.uint32Value());case"google.protobuf.Uint64Value":return Dh.wellKnown(sn.uint64Value());case"google.protobuf.Value":return Dh.wellKnown(sn.value())}}function gz_({generic:e,file:t,typeResolver:r}){let i=typeof e=="string"?e:e.type,n=xS(i);if(n==null)throw new Error(`Invalid generic type definition: ${i}`);let a=r.getDeclarationOfNamedTypeOrThrow({referenceToNamedType:i,file:t});if(n.arguments&&db(a.declaration)){let o=xS(a.typeName)?.arguments??[],c=Object.entries(a.declaration.properties??{}).map(([f,s])=>{let u=s;return typeof s=="string"&&o?.includes(s)&&(u=n.arguments?.[o.indexOf(s)]??s),[f,u]});return Yc.object({extends:QFt(a.declaration.extends).map(f=>wz({typeName:f,file:t})),properties:QEa({properties:Object.fromEntries(c)},t),extraProperties:a.declaration["extra-properties"]??!1,extendedProperties:void 0})}throw new Error(`Generic type definition not supported: ${i}`)}function Oz_({alias:e,file:t,typeResolver:r}){let i=typeof e=="string"?e:e.type;return R0e(i)?gz_({generic:i,file:t,typeResolver:r}):Yc.alias({aliasOf:t.parseTypeReference(e),resolvedType:mNM({aliasOf:i,file:t,typeResolver:r})})}function mNM({aliasOf:e,file:t,typeResolver:r}){let i=r.resolveTypeOrThrow({type:e,file:t});switch(i._type){case"primitive":return UQ.primitive(i.originalTypeReference.primitive);case"container":return UQ.container(i.originalTypeReference.container);case"unknown":return UQ.unknown();case"named":{let n=db(i.declaration)?rFt.Object:mCi(i.declaration)?rFt.Union:oFt(i.declaration)?rFt.Enum:XFn(i.declaration)?rFt.UndiscriminatedUnion:Ot(i.declaration);return UQ.named({name:i.name,shape:n})}}}function Az_({union:e,file:t}){let r=e.union.filter((i,n)=>{let a=typeof i=="string"?i:i.type;return e.union.findIndex(o=>(typeof o=="string"?o:o.type)===a)===n});return Yc.undiscriminatedUnion({members:r.map(i=>{let n=t.parseTypeReference(typeof i=="string"?i:i.type);return{type:n.type==="named"?{...n,displayName:typeof i=="string"?Lro(n.name.originalName):i["display-name"]??Lro(n.name.originalName)}:n,docs:typeof i=="string"?void 0:i.docs}})})}function mz_(e){let t=[];if(e.extends!=null){let r=typeof e.extends=="string"?[e.extends]:e.extends;t.push(...r)}return e.properties!=null&&t.push(...Object.values(e.properties).map(r=>typeof r=="string"?r:r.type)),t}function Uvc({typeDeclaration:e,file:t,typeResolver:r,seenTypeNames:i=new Qvc}){let n=EB(e,{alias:o=>{let c=typeof o=="string"?o:o.type,f=xS(c);if(f!=null){let s=new Set(f.arguments??[]),u=r.getDeclarationOfNamedTypeOrThrow({referenceToNamedType:c,file:t}),l=xS(u.typeName)?.arguments;if(db(u.declaration)){let p=mz_(u.declaration);l&&p.filter(_=>!l.includes(_)).forEach(_=>s.add(_))}return Array.from(s)}return[c]},object:o=>mz_(o),discriminatedUnion:o=>{let c=[];return o["base-properties"]!=null&&c.push(...Object.values(o["base-properties"]).map(f=>typeof f=="string"?f:f.type)),c.push(...Object.values(o.union).reduce((f,s)=>{let u=typeof s=="string"?s:s.type;return typeof u=="string"&&f.push(u),f},[])),c},undiscriminatedUnion:o=>Object.values(o.union).reduce((c,f)=>{let s=typeof f=="string"?f:f.type;return typeof s=="string"&&c.push(s),c},[]),enum:()=>[]}),a=[];for(let o of n){let c=wB({type:o,_default:void 0,validation:void 0,visitor:{primitive:()=>[],map:({keyType:f,valueType:s})=>[...f,...s],list:f=>f,optional:f=>f,nullable:f=>f,set:f=>f,named:f=>[f],literal:()=>[],unknown:()=>[]}});for(let f of c){let s=wz({typeName:f,file:t});if(!i.hasTypeNameBeenSeen(s)){i.addTypeName(s),a.push(s);let u=r.getDeclarationOfNamedTypeOrThrow({referenceToNamedType:f,file:t});if(R0e(u.typeName))continue;a.push(...Uvc({typeDeclaration:u.declaration,file:u.file,typeResolver:r,seenTypeNames:i}))}}}return a}var Qvc=class{cache=new Set;addTypeName(t){this.cache.add(this.computeCacheKey(t))}hasTypeNameBeenSeen(t){return this.cache.has(this.computeCacheKey(t))}computeCacheKey(t){return t.fernFilepath.allParts.map(r=>r.originalName).join("/")+":"+t.name.originalName}};function Pz_({typeName:e,typeDeclaration:t,file:r,typeResolver:i,exampleResolver:n,sourceResolver:a,workspace:o}){let c=l8(t),f=wz({typeName:e,file:r}),s=Uvc({typeDeclaration:t,file:r,typeResolver:i}),u={};db(t)&&(u=UKi(t.properties??{}));let l=jNM({file:r,typeDeclaration:t,typeName:e,sourceResolver:a});return{propertiesByAudience:u,typeDeclaration:{...c,inline:MNM(t),name:f,shape:PNM({typeDeclaration:t,file:r,typeResolver:i}),referencedTypes:new Set(s.map(p=>p.typeId)),encoding:wNM({typeDeclaration:t,source:l}),source:l,userProvidedExamples:typeof t!="string"&&t.examples!=null?t.examples.map(p=>({name:p.name!=null?r.casingsGenerator.generateName(p.name):void 0,docs:p.docs,jsonExample:n.resolveAllReferencesInExampleOrThrow({example:p.value,file:r}).resolvedExample,shape:Rvc({typeName:f,example:p.value,typeResolver:i,exampleResolver:n,typeDeclaration:t,fileContainingType:r,fileContainingExample:r,workspace:o})})):[],autogeneratedExamples:[],v2Examples:void 0},descendantFilepaths:new Set(s.map(p=>p.fernFilepath))}}function PNM({typeDeclaration:e,file:t,typeResolver:r}){return EB(e,{alias:i=>Oz_({alias:i,file:t,typeResolver:r}),object:i=>nR_({object:i,file:t}),discriminatedUnion:i=>gR_({union:i,file:t,typeResolver:r}),undiscriminatedUnion:i=>Az_({union:i,file:t}),enum:i=>Yc.enum(y9o({_enum:i,file:t}))})}function jNM({file:e,typeDeclaration:t,typeName:r,sourceResolver:i}){if(typeof t=="string"||t.source==null&&t.encoding==null)return;if(t.encoding!=null){let a=vz_({encoding:t.encoding});if(a!=null)return Ivi.proto(a)}if(t.source==null)return;let n=i.resolveSourceOrThrow({source:t.source,relativeFilepath:e.relativeFilepath});if(!(n==null||n.type!=="protobuf"))return Ivi.proto(bz_({source:n,name:r}))}function wNM({typeDeclaration:e,source:t}){return typeof e!="string"&&e.encoding!=null?ENM(e.encoding):SNM(t)}function ENM(e){return e.proto!=null?{json:void 0,proto:{}}:{json:{},proto:void 0}}function SNM(e){return e!=null&&e.type==="proto"?{json:void 0,proto:{}}:{json:{},proto:void 0}}function MNM(e){if(typeof e!="string"&&"inline"in e)return e.inline}function jz_(e,t){let r=t[e];if(r==null)throw new Chi(`Illegal Error: Failed to load type declaration for type ${e}`);return r}function wz_(e){e.types=Object.fromEntries(Object.entries(e.types).map(([t,r])=>[t,BNM({typeDeclaration:r,ir:e})])),e.services=Object.fromEntries(Object.entries(e.services).map(([t,r])=>[t,{...r,endpoints:r.endpoints.map(i=>DNM({endpoint:i,ir:e}))}]))}function DNM({endpoint:e,ir:t}){return e.requestBody?.type!=="inlinedRequestBody"?e:{...e,requestBody:{...e.requestBody,extendedProperties:e.requestBody.extends.flatMap(r=>Ez_(r,t))}}}function BNM({typeDeclaration:e,ir:t}){switch(e.shape.type){case"object":return{...e,shape:{...e.shape,extendedProperties:e.shape.extends.flatMap(r=>Ez_(r,t))}}}return e}function Ez_(e,t){let r=Lvc(e.typeId,t);return Sz_({objectTypeDeclaration:r,ir:t})}function Lvc(e,t){let r=jz_(e,t.types);switch(r.shape.type){case"object":return r.shape;case"alias":if(r.shape.resolvedType.type==="named")return Lvc(r.shape.resolvedType.name.typeId,t)}throw new Chi(`Unexpected error: ${e} is extended but has shape ${r.shape.type}`)}function Sz_({objectTypeDeclaration:e,ir:t}){let r=e.extends.flatMap(i=>{let n=Lvc(i.typeId,t);return Sz_({objectTypeDeclaration:n,ir:t})});return[...e.properties,...r]}var S9o=class{subpackages={};rootPackage={docs:void 0,fernFilepath:{allParts:[],packagePath:[],file:void 0},websocket:void 0,service:void 0,types:[],errors:[],subpackages:[],webhooks:void 0,navigationConfig:void 0};addPackageRedirection({from:t,to:r}){let i=this.getPackageForFernFilepath(t);if(i.navigationConfig!=null)throw new Error("Found duplicate navigationConfig for package");i.navigationConfig={pointsTo:up.generateSubpackageId(r)}}addDocs(t,r){let i=this.getPackageForFernFilepath(t);if(i.docs!=null)throw new Error("Found duplicate docs for package");i.docs=r}addSubpackage(t){this.getPackageForFernFilepath(t)}addType(t,r){this.getPackageForFernFilepath(r.name.fernFilepath).types.push(t)}addError(t,r){this.getPackageForFernFilepath(r.name.fernFilepath).errors.push(t)}addService(t,r){let i=this.getPackageForFernFilepath(r.name.fernFilepath);if(i.service!=null)throw new Error("Found duplicate service for "+t);i.service=t}addWebhookGroup(t,r){let i=this.getPackageForFernFilepath(r);if(i.webhooks!=null)throw new Error("Found duplicate webhook group for "+t);i.webhooks=t}addWebSocketChannel(t,r){let i=this.getPackageForFernFilepath(r);if(i.webhooks!=null)throw new Error("Found duplicate webhook group for "+t);i.websocket=t}build(t){t!=null&&(Object.entries(this.subpackages).forEach(([i,n])=>{t.hasSubpackageId(i)?this.subpackages[i]={...n,types:n.types.filter(a=>t.hasTypeId(a)),errors:n.errors.filter(a=>t.hasErrorId(a)),service:n.service!=null&&t.hasServiceId(n.service)?n.service:void 0,websocket:n.websocket!=null&&t.hasChannel(n.websocket)?n.websocket:void 0,subpackages:n.subpackages.filter(a=>t.hasSubpackageId(a))}:delete this.subpackages[i]}),this.rootPackage={...this.rootPackage,types:this.rootPackage.types.filter(i=>t.hasTypeId(i)),errors:this.rootPackage.errors.filter(i=>t.hasErrorId(i)),service:this.rootPackage.service!=null&&t.hasServiceId(this.rootPackage.service)?this.rootPackage.service:void 0,subpackages:this.rootPackage.subpackages.filter(i=>t.hasSubpackageId(i)),webhooks:this.rootPackage.webhooks!=null?this.rootPackage.webhooks:void 0});let r=new Set(this.getAllChildrenWithEndpoints(this.rootPackage));return{subpackages:_n(this.subpackages,(i,n)=>({...i,hasEndpointsInTree:r.has(n)})),rootPackage:{...this.rootPackage,hasEndpointsInTree:r.size>0||this.rootPackage.service!=null}}}sortRootPackage(t){if(!Mz_(this.rootPackage.subpackages,t))throw new Error("Sorted subpackages differ from unsorted packages in root");this.rootPackage.subpackages=t}sortSubpackage(t,r){let i=this.subpackages[t];if(i==null)throw new Error("Subpackage does not exist: "+t);if(!Mz_(i.subpackages,r))throw new Error("Sorted subpackages differ from unsorted packages");i.subpackages=r}getAllSubpackagesWithEndpoints(t){let r=this.subpackages[t];if(r==null)throw new Error("Subpackage does not exist: "+t);let i=this.getAllChildrenWithEndpoints(r);return(i.length>0||r.service!=null)&&i.push(t),i}getAllChildrenWithEndpoints(t){return t.subpackages.flatMap(r=>[...this.getAllSubpackagesWithEndpoints(r)])}getPackageForFernFilepath(t,r=0,i=this.rootPackage){let n=t.allParts[r];if(n==null)return i;let a=i.subpackages.map(s=>{let u=this.subpackages[s];if(u==null)throw new Error("Subpackage ID is invalid: "+s);return u}),o=r+1,c={allParts:t.allParts.slice(0,o),packagePath:t.packagePath.slice(0,o),file:o===t.allParts.length?t.file:void 0},f=a.find(s=>s.name.originalName===n.originalName);if(f==null){let s=up.generateSubpackageId(c),u={docs:void 0,fernFilepath:c,name:n,displayName:void 0,service:void 0,types:[],errors:[],subpackages:[],navigationConfig:void 0,webhooks:void 0,websocket:void 0};this.subpackages[s]=u,i.subpackages.push(s),f=u}return this.getPackageForFernFilepath(t,o,f)}};function Mz_(e,t){if(e.length!==t.length)return!1;let r=new Set(e);for(let i of t)if(!r.has(i))return!1;return!0}function Dz_({reference:e,referencedIn:t,imports:r}){let[i,n,...a]=e.split(".");if(i==null||a.length>0)return;if(n==null)return{endpointName:i,relativeFilepath:t};let c=r[i];if(c!=null)return{endpointName:n,relativeFilepath:c1i({referencedIn:t,importPath:c})}}var N$i=class{workspace;constructor(t){this.workspace=t}resolveEndpointOrThrow({endpoint:t,file:r}){let i=this.resolveEndpoint({endpoint:t,file:r});if(i==null)throw new Error("Cannot resolve endpoint: "+t+" in file "+r.relativeFilepath);return i}resolveEndpointByMethodAndPath({method:t,path:r}){let i;return zB(this.workspace,(n,a,o)=>{let c=nf({relativeFilepath:n,definitionFile:a,casingsGenerator:f1i,rootApiFile:this.workspace.definition.rootApiFile.contents,defaultUrl:o.defaultUrl});for(let[f,s]of Object.entries(a.service?.endpoints??{}))s.method===t&&s.path===r&&(i={endpointId:f,endpoint:s,file:c})}),o$i(this.workspace,(n,a)=>{let o=nf({relativeFilepath:n,definitionFile:a,casingsGenerator:f1i,rootApiFile:this.workspace.definition.rootApiFile.contents});for(let[c,f]of Object.entries(a.service?.endpoints??{}))f.method===t&&f.path===r&&(i={endpointId:c,endpoint:f,file:o})}),i}resolveEndpoint({endpoint:t,file:r}){let n=new CKi().tryParse(t);if(n!=null)return this.resolveEndpointByMethodAndPath(n);let a=this.getDeclarationOfEndpoint({referenceToEndpoint:t,file:r});if(a==null)return;let o=a.file.definitionFile.service?.endpoints?.[a.endpointName];if(o!=null)return{endpointId:a.endpointName,endpoint:o,file:a.file}}getDeclarationOfEndpoint({referenceToEndpoint:t,file:r}){let i=Dz_({reference:t,referencedIn:r.relativeFilepath,imports:r.imports});if(i==null)return;let n=uPe(this.workspace,i.relativeFilepath);if(!(n==null||n.service?.endpoints?.[i.endpointName]==null))return{endpointName:i.endpointName,file:nf({relativeFilepath:i.relativeFilepath,definitionFile:n,casingsGenerator:r.casingsGenerator,rootApiFile:this.workspace.definition.rootApiFile.contents})}}};var F$i=class{workspace;constructor(t){this.workspace=t}getDeclarationOrThrow(t,r){let i=this.getDeclaration(t,r);if(i==null)throw new Error("Error does not exist: "+t);return i}getDeclaration(t,r){let i=Ghe({reference:t,referencedIn:r.relativeFilepath,imports:r.imports});if(i==null)return;let n=uPe(this.workspace,i.relativeFilepath);if(n==null)return;let a=n.errors?.[i.typeName];if(a!=null)return{declaration:a,file:nf({definitionFile:n,relativeFilepath:i.relativeFilepath,casingsGenerator:r.casingsGenerator,rootApiFile:this.workspace.definition.rootApiFile.contents})}}};var Jhe=class{typeResolver;constructor(t){this.typeResolver=t}resolveAllReferencesInExample({example:t,file:r}){if(typeof t=="string"){let i=this.resolveExample({example:t,file:r});return i==null?i:typeof i.resolvedExample=="string"?(i.resolvedExample.startsWith(`\\${"$"}`)&&(i.resolvedExample=i.resolvedExample.slice(1)),i):this.resolveAllReferencesInExample({example:i.resolvedExample,file:i.file})}else if($c(t)){let i={};for(let[n,a]of Object.entries(t)){let o=this.resolveAllReferencesInExample({example:a,file:r});if(o==null)return;i[n]=o.resolvedExample}return{resolvedExample:i}}else if(Array.isArray(t)){let i=[];for(let n of t){let a=this.resolveAllReferencesInExample({example:n,file:r});if(a==null)return;i.push(a.resolvedExample)}return{resolvedExample:i}}return{resolvedExample:t}}resolveAllReferencesInExampleOrThrow({example:t,file:r}){let i=this.resolveAllReferencesInExample({example:t,file:r});if(i==null)throw new Error("Failed to resolve examples");return i}resolveExample({example:t,file:r}){return typeof t!="string"?{resolvedExample:t,file:r}:t.startsWith("$")?this.resolveExampleReference(t,r):{resolvedExample:t,file:r}}resolveExampleReference(t,r){let i=this.parseExampleReference(t);if(i==null)return;let n=this.typeResolver.getDeclarationOfNamedType({referenceToNamedType:i.rawTypeReference,file:r});if(n==null||typeof n.declaration=="string"||n.declaration.examples==null)return;let a=n.declaration.examples.find(o=>o.name===i.exampleName);if(a!=null)return this.resolveExample({example:a.value,file:n.file})}resolveExampleOrThrow({example:t,file:r}){let i=this.resolveExample({example:t,file:r});if(i==null)throw new Error("Cannot resolve example: "+t);return i}parseExampleReference(t){let[r,i,n,...a]=t.split(".");if(!(r==null||i==null||a.length>0))return n==null?{rawTypeReference:r.slice("$".length),exampleName:i}:{rawTypeReference:`${r}.${i}`.slice("$".length),exampleName:n}}};var M9o=class{typeResolver;endpointResolver;constructor(t,r){this.typeResolver=t,this.endpointResolver=r,this.typeResolver=t,this.endpointResolver=r}resolveRequestPropertyOrThrow({file:t,endpoint:r,propertyComponents:i}){let n=this.resolveRequestProperty({file:t,endpoint:r,propertyComponents:i});if(n==null)throw new Error("Cannot resolve request property from endpoint: "+r+" in file "+t.relativeFilepath);return n}resolveRequestProperty({file:t,endpoint:r,propertyComponents:i}){let n=this.endpointResolver.resolveEndpointOrThrow({endpoint:r,file:t});if(n.endpoint.request==null)return;if(typeof n.endpoint.request!="string")return this.resolveRequestPropertyFromInlinedRequest({typeResolver:this.typeResolver,file:n.file,requestType:n.endpoint.request,propertyComponents:i});let a=this.typeResolver.resolveTypeOrThrow({type:n.endpoint.request,file:n.file}),o=this.resolveObjectProperty({file:n.file,resolvedType:a,propertyComponents:i});if(o!=null)return{propertyPath:this.propertyPathFromPropertyComponents({propertyComponents:i,file:t,resolvedType:a}),property:$H.body(o)}}resolveResponsePropertyOrThrow({file:t,endpoint:r,propertyComponents:i}){let n=this.resolveResponseProperty({file:t,endpoint:r,propertyComponents:i});if(n==null)throw new Error("Cannot resolve response property from endpoint: "+r+" in file "+t.relativeFilepath);return n}resolveResponseProperty({file:t,endpoint:r,propertyComponents:i}){let n=this.endpointResolver.resolveEndpointOrThrow({endpoint:r,file:t}),a=this.typeResolver.resolveTypeOrThrow({type:(typeof n.endpoint.response!="string"?n.endpoint.response?.type:n.endpoint.response)??"",file:n.file}),o=this.resolveObjectProperty({file:n.file,resolvedType:a,propertyComponents:i});if(o!=null)return{propertyPath:this.propertyPathFromPropertyComponents({propertyComponents:i,resolvedType:a,file:t}),property:o}}resolveRequestPropertyFromInlinedRequest({typeResolver:t,file:r,requestType:i,propertyComponents:n}){if(n.length===1){let a=n[0]??"",o=i["query-parameters"]?.[a]??void 0;if(o!=null)return{property:$H.query(b9o({file:r,queryParameterKey:a,queryParameter:o})),propertyPath:void 0}}return this.resolveRequestPropertyFromInlinedRequestBody({typeResolver:t,file:r,requestType:i,propertyComponents:n})}resolveRequestPropertyFromInlinedRequestBody({typeResolver:t,file:r,requestType:i,propertyComponents:n}){if(i.body==null)return;if(typeof i.body=="string"){let c=t.resolveTypeOrThrow({type:i.body,file:r}),f=this.resolveObjectProperty({file:r,resolvedType:c,propertyComponents:n});return f==null?void 0:{propertyPath:this.propertyPathFromPropertyComponents({propertyComponents:n,file:r,resolvedType:c}),property:$H.body(f)}}if(HP(i.body)){let c=f9o({typeResolver:t,file:r,objectSchema:i.body,propertyComponents:n});return c==null?void 0:{propertyPath:this.propertyPathFromPropertyComponentsFromInlineRequestBody({propertyComponents:n,file:r,body:i.body}),property:$H.body(c)}}let a=t.resolveTypeOrThrow({type:i.body.type,file:r}),o=l9o({typeResolver:t,file:SLn(a)??r,resolvedType:a,propertyComponents:n});if(o!=null)return{propertyPath:this.propertyPathFromPropertyComponents({propertyComponents:n,file:r,resolvedType:a}),property:$H.body(o)}}resolveObjectProperty({file:t,resolvedType:r,propertyComponents:i}){return l9o({typeResolver:this.typeResolver,file:SLn(r)??t,resolvedType:r,propertyComponents:i})}propertyPathFromPropertyComponents({propertyComponents:t,file:r,resolvedType:i}){if(t.length<=1)return[];let n=Q$i(i),a=i,o=[],c=[];for(let f of t.slice(0,-1))c.push(f),a=INM({typeResolver:this.typeResolver,file:r,resolvedType:a,propertyName:f,breadcrumbs:c,rootTypeTitle:n}),o.push({name:r.casingsGenerator.generateName(f),type:a.originalTypeReference});return o}propertyPathFromPropertyComponentsFromInlineRequestBody({propertyComponents:t,file:r,body:i}){if(t.length<=1)return[];let n=[],a=[];for(let o of t.slice(0,-1)){a.push(o);let c=f9o({typeResolver:this.typeResolver,file:r,objectSchema:i,propertyComponents:a});if(!c)throw new Error(`Cannot find property '${a.join(".")}' in inline request body in file ${r.relativeFilepath}`);n.push({name:r.casingsGenerator.generateName(o),type:c.valueType})}return n}};function INM({typeResolver:e,file:t,resolvedType:r,propertyName:i,breadcrumbs:n,rootTypeTitle:a}){let o=TLn({typeResolver:e,file:t,resolvedType:r,propertyName:i});if(!o)throw new Error(`Cannot find property '${n.join(".")}' in ${a}`);return o}function TLn({typeResolver:e,file:t,resolvedType:r,propertyName:i}){switch(r._type){case"container":switch(r.container._type){case"list":return;case"literal":return;case"map":return;case"nullable":{let n=TLn({typeResolver:e,file:t,resolvedType:r.container.itemType,propertyName:i});return n||void 0}case"optional":{let n=TLn({typeResolver:e,file:t,resolvedType:r.container.itemType,propertyName:i});return n||void 0}case"set":return;default:Ot(r.container)}break;case"primitive":return;case"unknown":return;case"named":{let n=r.declaration;if("properties"in n&&n.properties!=null){for(let[a,o]of Object.entries(n.properties))if(a===i)return e.resolveTypeOrThrow({type:typeof o=="string"?o:o.type,file:r.file})}if("base-properties"in n&&n["base-properties"]!=null){for(let[a,o]of Object.entries(n["base-properties"]))if(a===i)return e.resolveTypeOrThrow({type:typeof o=="string"?o:o.type,file:r.file})}if("extends"in n&&n.extends!=null){let a=Array.isArray(n.extends)?n.extends:[n.extends];for(let o of a){let c=e.resolveTypeOrThrow({type:o,file:r.file}),f=TLn({file:"file"in c?c.file:t,typeResolver:e,resolvedType:c,propertyName:i});if(f)return f}}if("union"in n&&n.union!=null)if(Array.isArray(n.union))for(let a of n.union){let o=e.resolveTypeOrThrow({type:typeof a=="string"?a:a.type,file:r.file}),c=TLn({file:"file"in o?o.file:t,typeResolver:e,resolvedType:o,propertyName:i});if(c)return c}else for(let[,a]of Object.entries(n.union)){let o=typeof a=="string"?a:a.type;if(!o)continue;let c=e.resolveTypeOrThrow({type:o,file:r.file}),f=TLn({file:"file"in c?c.file:t,typeResolver:e,resolvedType:c,propertyName:i});if(f)return f}return}default:Ot(r)}}function Q$i(e){switch(e._type){case"container":switch(e.container._type){case"list":return`list<${Q$i(e.container.itemType)}>}`;case"literal":return`literal<${e.container.literal._visit({boolean:t=>t.toString(),string:t=>t,_other:t=>t.type})}>`;case"map":return`map<${Q$i(e.container.keyType)}, ${Q$i(e.container.valueType)}>}`;case"nullable":return`nullable<${Q$i(e.container.itemType)}>}`;case"optional":return`optional<${Q$i(e.container.itemType)}>}`;case"set":return`set<${Q$i(e.container.itemType)}>}`;default:Ot(e.container)}break;case"named":return e.name.name.originalName;case"primitive":return e.primitive.v1;case"unknown":return"unknown";default:Ot(e)}}var pb=class{workspace;constructor(t){this.workspace=t}resolveTypeOrThrow({type:t,file:r}){let i=this.resolveType({type:t,file:r});if(i==null)throw new Error("Cannot resolve type: "+t+" in file "+r.relativeFilepath);return i}getDeclarationOfNamedTypeOrThrow({referenceToNamedType:t,file:r}){let i=this.getDeclarationOfNamedType({referenceToNamedType:t,file:r});if(i==null)throw new Error("Cannot find declaration of type: "+t+" in file "+r.relativeFilepath);return i}getDeclarationOfNamedType({referenceToNamedType:t,file:r}){let i=Ghe({reference:t,referencedIn:r.relativeFilepath,imports:r.imports});if(i==null)return;let n=uPe(this.workspace,i.relativeFilepath);if(n==null)return;let a=n.types?.[i.typeName];if(a==null){let o=xS(i.typeName);if(o!=null){for(let c of Object.keys(n.types??{})??[])if(o.name&&c.startsWith(o.name)&&c.endsWith(">")){let f=n.types?.[c];return f!=null?{typeName:c,declaration:f,file:nf({relativeFilepath:i.relativeFilepath,definitionFile:n,casingsGenerator:r.casingsGenerator,rootApiFile:this.workspace.definition.rootApiFile.contents})}:void 0}}return}return{typeName:i.typeName,declaration:a,file:nf({relativeFilepath:i.relativeFilepath,definitionFile:n,casingsGenerator:r.casingsGenerator,rootApiFile:this.workspace.definition.rootApiFile.contents})}}resolveType({type:t,file:r,objectPath:i=[]}){return wB({type:t,_default:void 0,validation:void 0,visitor:{primitive:n=>({_type:"primitive",primitive:n,originalTypeReference:ii.primitive(n)}),unknown:()=>({_type:"unknown",originalTypeReference:ii.unknown()}),map:({keyType:n,valueType:a})=>n!=null&&a!=null?{_type:"container",container:{_type:"map",keyType:n,valueType:a},originalTypeReference:ii.container(ns.map({keyType:n.originalTypeReference,valueType:a.originalTypeReference}))}:void 0,list:n=>n!=null?{_type:"container",container:{_type:"list",itemType:n},originalTypeReference:ii.container(ns.list(n.originalTypeReference))}:void 0,optional:n=>n!=null?{_type:"container",container:{_type:"optional",itemType:n},originalTypeReference:ii.container(ns.optional(n.originalTypeReference))}:void 0,nullable:n=>n!=null?{_type:"container",container:{_type:"nullable",itemType:n},originalTypeReference:ii.container(ns.nullable(n.originalTypeReference))}:void 0,set:n=>n!=null?{_type:"container",container:{_type:"set",itemType:n},originalTypeReference:ii.container(ns.set(n.originalTypeReference))}:void 0,literal:n=>({_type:"container",container:{_type:"literal",literal:n},originalTypeReference:ii.container(ns.literal(n))}),named:n=>{let a=this.getDeclarationOfNamedType({referenceToNamedType:n,file:r});if(a==null)return;let o={typeName:a.typeName,file:a.file.relativeFilepath,reference:n};if(!i.some(c=>c.file===o.file&&c.typeName===o.typeName))return this.resolveNamedTypeFromDeclaration({referenceToNamedType:n,referencedIn:r,rawDeclaration:a,objectPath:[...i,o]})}}})}resolveNamedTypeOrThrow({referenceToNamedType:t,file:r}){let i=this.resolveNamedType({referenceToNamedType:t,file:r});if(i==null)throw new Error("Cannot resolve type: "+t);return i}resolveNamedType({referenceToNamedType:t,file:r}){let i=this.getDeclarationOfNamedType({referenceToNamedType:t,file:r});if(i!=null)return this.resolveNamedTypeFromDeclaration({referenceToNamedType:t,referencedIn:r,rawDeclaration:i})}resolveNamedTypeFromDeclaration({referenceToNamedType:t,referencedIn:r,rawDeclaration:i,objectPath:n=[]}){let{declaration:a,file:o}=i;if(ACi(a))return this.resolveType({type:typeof a=="string"?a:a.type,file:o,objectPath:n});let c=LEa({type:t,_default:void 0,validation:void 0,file:r});if(!(c.type!=="named"||uPe(this.workspace,o.relativeFilepath)==null))return{_type:"named",rawName:i.typeName,name:c,declaration:a,filepath:o.relativeFilepath,objectPath:n,originalTypeReference:c,file:o}}};var VFt=class e{static VARIABLE_PREFIX="$";getDeclarationOrThrow(t,r){let i=this.getDeclaration(t,r);if(i==null)throw new Error("Variable does not exist: "+t);return i}getDeclaration(t,r){if(!t.startsWith(e.VARIABLE_PREFIX))return;let i=r.rootApiFile.variables?.[t.substring(1)];if(i!=null)return{declaration:i,file:Fgi({casingsGenerator:r.casingsGenerator,rootApiFile:r.rootApiFile})}}getVariableIdOrThrow(t){let r=this.getVariableId(t);if(r==null)throw new Error("Variable reference does not start with "+e.VARIABLE_PREFIX);return r}getVariableId(t){if(t.startsWith(e.VARIABLE_PREFIX))return t.substring(e.VARIABLE_PREFIX.length)}};function D9o(e,t){if(t){for(let[r,i]of Object.entries(t))if(typeof i!="string"&&r===e)return i.audiences}}var Bz_={pathParameterOrder:hn.PathParameterOrder.UrlOrder};function Iz_({workspace:e}){let t=e.generatorsConfiguration?.api?.settings,r={...Bz_};for(let i of Object.keys(Bz_)){let n=t?.[i];n!==void 0&&(r[i]=n)}return r}function kw({workspace:e,generationLanguage:t,keywords:r,smartCasing:i,exampleGeneration:n,audiences:a,readme:o,packageName:c,version:f,fdrApiDefinitionId:s,sourceResolver:u,disableDynamicExamples:l,dynamicGeneratorConfig:p,generationMetadata:_}){let h=Iz_({workspace:e}),y=hx({generationLanguage:t,keywords:r,smartCasing:i}),b=new LKi(a),v=Fgi({casingsGenerator:y,rootApiFile:e.definition.rootApiFile.contents}),O=(e.definition.rootApiFile.contents.errors??[]).map(ne=>({error:l1i({errorName:ne,file:v}),docs:void 0})),A=new pb(e),g=new N$i(e),m=new M9o(A,g),j=new F$i(e),M=new Jhe(A),E=new VFt,B=rPa({casingsGenerator:y,rawApiFileSchema:e.definition.rootApiFile.contents})?.environmentsConfig,F={selfHosted:!1,fdrApiDefinitionId:s,apiVersion:lz_({file:v,rawApiFileSchema:e.definition.rootApiFile.contents}),apiName:y.generateName(e.definition.rootApiFile.contents.name),apiDisplayName:e.definition.rootApiFile.contents["display-name"],apiDocs:FEa(e.definition.rootApiFile.contents.docs),auth:cz_({rawApiFileSchema:e.definition.rootApiFile.contents,file:v,propertyResolver:m,endpointResolver:g}),headers:e.definition.rootApiFile.contents.headers!=null?Object.entries(e.definition.rootApiFile.contents.headers).map(([ne,Je])=>PPe({headerKey:ne,header:Je,file:v})):[],idempotencyHeaders:e.definition.rootApiFile.contents["idempotency-headers"]!=null?Object.entries(e.definition.rootApiFile.contents["idempotency-headers"]).map(([ne,Je])=>PPe({headerKey:ne,header:Je,file:v})):[],types:{},errors:{},services:{},constants:ZR_(y),environments:B,errorDiscriminationStrategy:_z_(e.definition.rootApiFile.contents["error-discrimination"],v),basePath:e.definition.rootApiFile.contents["base-path"]!=null?PD(e.definition.rootApiFile.contents["base-path"]):void 0,pathParameters:qLn({pathParameters:e.definition.rootApiFile.contents["path-parameters"],file:v,location:j0e.Root,variableResolver:E}),variables:e.definition.rootApiFile.contents.variables!=null?Object.entries(e.definition.rootApiFile.contents.variables).map(([ne,Je])=>({docs:typeof Je!="string"?Je.docs:void 0,id:ne,name:v.casingsGenerator.generateName(ne),type:v.parseTypeReference(Je)})):[],serviceTypeReferenceInfo:{typesReferencedOnlyByService:{},sharedTypes:[]},webhookGroups:{},websocketChannels:{},readmeConfig:void 0,sourceConfig:void 0,publishConfig:void 0,dynamic:void 0,audiences:e.definition.rootApiFile.contents.audiences,generationMetadata:_,apiPlayground:!0},N=new S9o,R=ne=>{N.addSubpackage(ne.fernFilepath),uy(ne.definitionFile,{imports:Mt,docs:Je=>{Je!=null&&N.addDocs(ne.fernFilepath,Je)},types:Je=>{if(Je!=null)for(let[et,Dr]of Object.entries(Je)){if(R0e(et))continue;let Lt=Pz_({typeName:et,typeDeclaration:Dr,file:ne,typeResolver:A,exampleResolver:M,sourceResolver:u,workspace:e}),zt=Lt.typeDeclaration;n.disabled&&(zt.userProvidedExamples=[],zt.autogeneratedExamples=[]);let Qt=Lt.descendantFilepaths,Ht=up.generateTypeId(zt.name);F.types[Ht]=zt,N.addType(Ht,zt),b.addType({declaredTypeName:zt.name,descendantTypeIds:zt.referencedTypes,descendantTypeIdsByAudience:{},propertiesByAudience:Lt.propertiesByAudience,descendantFilepaths:Qt}),b.markTypeForAudiences(zt.name,iR_(Dr))}},errors:Je=>{if(Je==null)return;if(e.definition.rootApiFile.contents["error-discrimination"]==null)throw new Error("error-discrimination is missing in api.yml but there are declared errors.");for(let[Dr,Lt]of Object.entries(Je)){let zt=dz_({errorName:Dr,errorDeclaration:Lt,file:ne,typeResolver:A,exampleResolver:M,workspace:e}),Qt=up.generateErrorId(zt.name);F.errors[Qt]=zt,N.addError(Qt,zt),b.addError(zt)}},service:Je=>{if(Je==null)return;let et=YR_({rootDefaultUrl:ne.defaultUrl??e.definition.rootApiFile.contents["default-url"],rootPathParameters:F.pathParameters,serviceDefinition:Je,file:ne,errorResolver:j,typeResolver:A,propertyResolver:m,exampleResolver:M,sourceResolver:u,globalErrors:O,variableResolver:E,workspace:e,auth:F.auth,irSettings:h}),Dr=up.generateServiceId(et.name);F.services[Dr]=et,N.addService(Dr,et);let Lt={};et.endpoints.forEach(zt=>{n.disabled&&(zt.autogeneratedExamples=[],zt.userSpecifiedExamples=[]);let Qt=Je.endpoints[zt.name.originalName];b.addEndpoint(et,zt,Qt),Lt[zt.name.originalName]=zt}),Je.audiences!=null&&b.markEndpointForAudience(et.name,et.endpoints,Je.audiences),Object.entries(Je.endpoints).map(([zt,Qt])=>{let Ht=Lt[zt];Ht!=null&&Qt.audiences!=null&&b.markEndpointForAudience(et.name,[Ht],Qt.audiences)})},webhooks:Je=>{if(Je==null)return;let et=up.generateWebhookGroupId(ne.fernFilepath),Dr=yz_({webhooks:Je,file:ne,typeResolver:A,exampleResolver:M,workspace:e}),Lt={};for(let zt of Dr)Lt[zt.name.originalName]=zt;Object.entries(Je).forEach(([zt,Qt])=>{let Ht=Lt[zt];Ht!=null&&(b.addWebhook(ne.fernFilepath,Ht,Qt),Qt.audiences!=null&&b.markWebhookForAudiences(ne.fernFilepath,Ht,Qt.audiences))}),F.webhookGroups[et]=Dr,N.addWebhookGroup(et,ne.fernFilepath)},channel:Je=>{if(Je==null)return;let et=up.generateWebSocketChannelId(ne.fernFilepath),Dr=fz_({channel:Je,file:ne,variableResolver:E,typeResolver:A,exampleResolver:M,workspace:e});b.addChannel(ne.fernFilepath,et,Dr,Je),Je.audiences!=null&&b.markChannelForAudiences(ne.fernFilepath,et,Je.audiences),F.websocketChannels!=null&&(F.websocketChannels[et]=Dr,N.addWebSocketChannel(et,ne.fernFilepath))}})};zB(e,(ne,Je,et)=>{R(nf({relativeFilepath:ne,definitionFile:Je,casingsGenerator:y,rootApiFile:e.definition.rootApiFile.contents,defaultUrl:et.defaultUrl}))}),o$i(e,(ne,Je)=>{if(Je.navigation!=null)if(typeof Je.navigation=="string")N.addPackageRedirection({from:bK({relativeFilepath:ne,casingsGenerator:y}),to:bK({relativeFilepath:tD(_Ae(ne),Tu.of(Je.navigation)),casingsGenerator:y})});else{let et=Je.navigation.map(Dr=>up.generateSubpackageId(bK({relativeFilepath:tD(_Ae(ne),Tu.of(Dr)),casingsGenerator:y})));ne===nb?N.sortRootPackage(et):N.sortSubpackage(up.generateSubpackageId(bK({relativeFilepath:ne,casingsGenerator:y})),et)}}),F.serviceTypeReferenceInfo=qNM(b),wz_(F);let z=n.disabled?F:nPa({ir:F,exampleGeneration:n}),U=e.definition.rootApiFile.contents,W=B?.environments._visit({singleBaseUrl:ne=>ne.environments.filter(Je=>D9o(Je.id,U.environments)!=null).length===0,multipleBaseUrls:ne=>ne.environments.filter(Je=>D9o(Je.id,U.environments)!=null).length===0,_other:()=>!1});B?.environments.environments.forEach(ne=>{b.markEnvironmentForAudiences(ne,D9o(ne.id,U.environments)??[],W)});let K=b.hasNoAudiences()?void 0:b.build(),fe=Hac(z,K),pe=e.definition.rootApiFile.contents.auth!=null&&Object.values(fe.services).every(ne=>ne.endpoints.every(Je=>Je.auth)),L=Object.values(fe.services).some(ne=>ne.endpoints.some(Je=>Je.response?.body?.type==="streaming")),G=Object.values(fe.services).some(ne=>ne.endpoints.some(Je=>Je.pagination!=null)),Re=Object.values(fe.services).some(ne=>ne.endpoints.some(Je=>Je.response?.body?.type==="fileDownload")),le={isAuthMandatory:pe,hasStreamingEndpoints:L,hasPaginatedEndpoints:G,hasFileDownloadEndpoints:Re,platformHeaders:{language:"X-Fern-Language",sdkName:"X-Fern-SDK-Name",sdkVersion:"X-Fern-SDK-Version",userAgent:f!=null&&c!=null?{header:"User-Agent",value:`${c}/${f}`}:void 0}},De=o??e.generatorsConfiguration?.rawConfiguration.readme,Ke=De!=null?hz_({readme:De,services:F.services}):void 0,se=CNM({...fe,...N.build(K),sdkConfig:le,readmeConfig:Ke});return{...se,dynamic:GEa({ir:se,generatorConfig:p,disableExamples:l,generationLanguage:t,smartCasing:i})}}function CNM(e){let t=r=>{if(!r||typeof r!="object")return r;if(Array.isArray(r))return r.map(t);for(let i in r){let n=r[i];i==="docs"&&typeof n=="string"?r[i]=FEa(n):n&&typeof n=="object"&&t(n)}return r};return t(e)}function qNM(e){let t={},r=[],i=e.getTypesReferencedByService();for(let[n,a]of Object.entries(i)){if(a.size===1){let o=a.values().next().value;if(o==null)break;t[o]===void 0&&(t[o]=[]),t[o]?.push(n);continue}r.push(n)}return{typesReferencedOnlyByService:t,sharedTypes:r}}var _N_=ue(tco(),1),hN_=ue(rco(),1),V9o=require("fs/promises"),yN_=ue(Q_e(),1);function Cz_(e){throw new Error("Unexpected value: "+JSON.stringify(e))}var Tz_=ue(fda(),1);var qz_=["PII","PHI","PCI","GDPR","CCPA","HIPAA","COPPA","FERPA","GLBA","SOX","FISMA","NIST","CIS","ISO","IEC","ITAR","EAR","CMMC","CUI","CDI","FTC","FCC","SEC","FINRA","XSS","CSRF","SSRF","XSRF","TLS","SSL","SSH","API","OAuth","OAuth1","OAuth1.0","OAuth2","OAuth2.0","SAML","OpenID","OpenID Connect","CAPTCHA","reCAPTCHA","2FA","MFA","OTP","TOTP","HOTP","U2F","FIDO","FIDO2","PKI","HMAC","AES","RSA","SHA","MD5","BCrypt","PBKDF2","Argon2","SCrypt","JWT","JWE","JWS","JWK","JWA","JOSE","SKU","SKUs","UPC","EAN","ISBN","ASIN","MPN","MSRP","MAP","RRP","MSRP","AM","PM","UTC","GMT","PST","PDT","EST","EDT","CST","CDT","MST","MDT","USA","UK","EU","UAE","APAC","EMEA","LATAM","ANZ","SEA","MEA","MENA","NATO","NA","SA","CA","EU","AU","NZ","JP","KR","CN","HK","TW","SG","MY","TH","ID","PH","VN","IN","PK","BD","LK","NP","MM","KH","LA","MM","BT","MV","USD","EUR","GBP","JPY","CNY","RUB","INR","AUD","CAD","CHF","SGD","MYR","THB","IDR","KRW","PHP","VND","HKD","TWD","MXN","BRL","ARS","CLP","COP","PEN","ZAR","NGN","EGP","AED","SAR","ILS","TRY","SEK","NOK","DKK","ISK","HUF","PLN","CZK","RON","BGN","API","APIs","SDK","SDKs","AI","OCR","REST","SOAP","JSON","XML","HTTP","HTTPS","URI","URL","CRUD","RESTful","KYB","KYC","AML","HTML","CSS","JS","SQL","DB","UI","UX","SaaS","PaaS","IaaS","IP","TCP","UDP","DNS","FTP","SMTP","IMAP","POP3","CSV","MVC","MVP","MVVM","DOM","SPA","SSR","CSR","DDoS","CDN","IoT","ML","DL","NLP","CLI","GUI","BI","ETL","RDBMS","NoSQL","IDE","CMS","CCPA","POSIX","ABI","API","AST","COBOL","DDL","DML","NN","CNN","RNN","LSTM","GRU","ANN","GAN","RL","DL","ML","NLP","NLG","NLU","BERT","GPT","SVM","PCA","AI","CV","TF","TTS","ASR","HMM","DNN","MLP","RBM","CRF","PDF","PDFs","RTF","TXT","XLS","XLSX","PPT","JPG","JPEG","PNG","GIF","GIFs","SVG","TIFF","BMP","ICO","PSD","WebP","AVIF","HEIF","HEIC","EPS","MP3","WAV","AIFF","FLAC","WMA","AAC","OGG","AVI","WMV","MOV","M4V","MP4","MPG","MPEG","FLV","SWF","MKV","WebM","GCP","AWS","VM","VPC","S3","EC2","DynamoDB","CosmosDB","BigQuery","CI/CD","SOC1","SOC2","SOC3","PCI DSS","WAF","IAM","SDN","MPLS","BGP","Vue.js","Node.js",".NET"];function U$i(e){return e=e.replace(/([a-z])([A-Z])/g,"$1 $2"),e=e.replace(/_/g," "),e=e.replace(/-/g," "),(0,Tz_.default)(e,{special:qz_}).replace(/V\s(\d)/g,"V$1")}function Vvc(e,t="type"){return{_visit:r=>{let i=r[e[t]];return i!=null?i(e):(r._other==null&&Cz_(e),r._other(e))}}}var $z_=ue(Sv(),1);var Ugi=ue(Sv(),1);function WFt(e){return typeof e.subpackageId=="string"}function B9o(e,t){return`${e} ${d8(t)}`}function d8(e){return e.map(t=>t.type==="literal"?t.value:`{${t.value}}`).join("")}function L$i(e){return e.map(t=>t.type==="literal"?t.value:`:${t.value}`).join("")}var Wvc="__package__",p1i=class e{api;context;static create(t,r){return new e(t,r)}#e=new Map;#t=new Map;#r=new Map;#i=new Map;#n=new Map;#a=new Map;#o=new Map;#s=new Map;#u=new Map;#c=new Map;#f=new Map;#p=new Map;#d=new Map;#l=new Map;static getSubpackageId(t){return WFt(t)?t.subpackageId:Wvc}getSubpackageByIdOrLocator(t){if(t==null)return;let r=oQ.SubpackageId(t),i=oQ.SubpackageId(`subpackage_${Fo(t)}`);return r===Wvc?this.api.rootPackage:this.api.subpackages[r]??this.#l.get(r)??this.api.subpackages[i]??this.#l.get(i)}resolveSubpackage(t){if(t!=null){for(;t?.pointsTo!=null;)t=this.api.subpackages[t.pointsTo];return t}}constructor(t,r){this.api=t,this.context=r,[t.rootPackage,...Object.values(t.subpackages)].forEach(i=>{let n=oQ.SubpackageId(e.getSubpackageId(i)),a={endpoints:new Map,webSockets:new Map,webhooks:new Map,grpcs:new Map};this.#u.set(n,a),i.endpoints.forEach(o=>{if(o.protocol?.type==="grpc"){a.grpcs.set(o.id,o);let c=e.createGrpcId(o,n);this.#i.set(c,o)}else{a.endpoints.set(o.id,o);let c=e.createEndpointId(o,n);this.#e.set(c,o);let f=[],s=[o.method];o.response?.type.type==="stream"&&s.push("STREAM"),s.forEach(u=>{f.push(`${u} ${d8(o.path.parts)}`),f.push(`${u} ${L$i(o.path.parts)}`),o.environments.forEach(l=>{f.push(`${u} ${(0,Ugi.default)(l.baseUrl,d8(o.path.parts))}`),f.push(`${u} ${(0,Ugi.default)(l.baseUrl,L$i(o.path.parts))}`);let p=Rz_(l);p!=null&&(f.push(`${u} ${(0,Ugi.default)(p,d8(o.path.parts))}`),f.push(`${u} ${(0,Ugi.default)(p,L$i(o.path.parts))}`))})}),f.forEach(u=>{this.context?.logger.trace(`Registering endpoint locator: ${u}`),this.#c.set(u,o)})}}),i.websockets.forEach(o=>{a.webSockets.set(o.id,o);let c=e.createWebSocketId(o,n);this.#t.set(c,o);let f=[];["GET","WSS"].forEach(u=>{f.push(`${u} ${d8(o.path.parts)}`),f.push(`${u} ${L$i(o.path.parts)}`),o.environments.forEach(l=>{f.push(`${u} ${(0,Ugi.default)(l.baseUrl,d8(o.path.parts))}`),f.push(`${u} ${(0,Ugi.default)(l.baseUrl,L$i(o.path.parts))}`);let p=Rz_(l);p!=null&&(f.push(`${u} ${(0,Ugi.default)(p,d8(o.path.parts))}`),f.push(`${u} ${(0,Ugi.default)(p,L$i(o.path.parts))}`))})}),f.forEach(u=>{this.context?.logger.trace(`Registering websocket locator: ${u}`),this.#f.set(u,o)})}),i.webhooks.forEach(o=>{a.webhooks.set(o.id,o),this.#r.set(e.createWebhookId(o,n),o)})}),this.#e.forEach((i,n)=>{this.#n.set(i,n)}),this.#t.forEach((i,n)=>{this.#a.set(i,n)}),this.#r.forEach((i,n)=>{this.#o.set(i,n)}),this.#i.forEach((i,n)=>{this.#s.set(i,n)}),this.#_(t.rootPackage,[])}#_(t,r){if(t==null)return;let i=WFt(t)?[...r,t.name]:r,n=i.length===0?[Wvc]:i;if([n.join("."),n.join("/"),`${n.join(".")}.yml`].forEach(o=>{this.context?.logger.trace(`Registering subpackage locator: ${o}`),this.#l.set(o,t)}),t.pointsTo!=null)return this.#_(this.api.subpackages[t.pointsTo],i);t.endpoints.forEach(o=>{if(o.protocol?.type==="grpc")return;let c=[...i,o.id];[c.join("."),c.join("/")].forEach(s=>{this.context?.logger.trace(`Registering endpoint locator: ${s}`),this.#c.set(s,o)})}),t.websockets.forEach(o=>{let c=[...i,o.id];[c.join("."),c.join("/")].forEach(s=>{this.context?.logger.trace(`Registering websocket locator: ${s}`),this.#f.set(s,o)})}),t.webhooks.forEach(o=>{let c=[...i,o.id];[c.join("."),c.join("/")].forEach(s=>{this.context?.logger.trace(`Registering webhook locator: ${s}`),this.#p.set(s,o)})}),t.subpackages.forEach(o=>{this.#_(this.api.subpackages[o],i)})}get endpoints(){return this.#e}get webSockets(){return this.#t}get webhooks(){return this.#r}get grpcs(){return this.#i}get endpointsByLocator(){return this.#c}get webSocketsByLocator(){return this.#f}get webhooksByLocator(){return this.#p}get grpcsByLocator(){return this.#d}get subpackages(){return this.#u}get subpackagesByLocator(){return this.#l}get subpackageLocators(){return new Set(this.#l.keys())}getEndpointId(t){return this.#n.get(t)}getWebSocketId(t){return this.#a.get(t)}getWebhookId(t){return this.#o.get(t)}getGrpcId(t){return this.#s.get(t)}static createEndpointId(t,r){return Ct.EndpointId(t.originalEndpointId??`${r}.${t.id}`)}static createWebSocketId(t,r){return Ct.WebSocketId(`${r}.${t.id}`)}static createWebhookId(t,r){return Ct.WebhookId(`${r}.${t.id}`)}static createGrpcId(t,r){return Ct.GrpcId(`${r}.${t.id}`)}};function Rz_(e){if(e!=null){if(e.baseUrl.startsWith("/"))return e.baseUrl;if(e.baseUrl.startsWith("http")||e.baseUrl.startsWith("ws"))try{return new URL(e.baseUrl).pathname}catch{return}}}var RLn=ue(tco(),1),Nz_=ue(rco(),1);function zz_(e){let t=e.split(".")[0];if(t==null)return;let i=/(^\d{1,4})-(\d{1,2})-(\d{1,4})/.exec(t)?.[0];if(i!=null)try{return new Date(i)}catch{}}RLn.default.extend(Nz_.default);var TNM="Changelog",RNM=["summary","index","overview"],V$i=class{markdownToFullSlug;markdownToNoIndex;markdownToTags;changelogFiles;docsWorkspace;idgen;constructor(t,r,i,n,a,o){this.markdownToFullSlug=t,this.markdownToNoIndex=r,this.markdownToTags=i,this.changelogFiles=n,this.docsWorkspace=a,this.idgen=o}toChangelogNode(t){let r=t.title??TNM,i=[],n;for(let p of this.changelogFiles??[]){let _=iws(p.split("/"));if(_==null)continue;let h=zz_(_);if(h==null){let b=_.split(".")[0]?.toLowerCase();b!=null&&RNM.includes(b)&&(n=p);continue}let y=this.toRelativeFilepath(p);i.push({date:h,pageId:Ct.PageId(y),absoluteFilepath:p})}let a=t.parentSlug.apply({fullSlug:n!=null?this.markdownToFullSlug.get(n)?.split("/"):void 0,skipUrlSlug:!1,urlSlug:t.slug??Rw(r)}),o=n!=null?this.markdownToNoIndex.get(n):void 0,c=i.map(p=>{let _=RLn.default.utc(p.date);return{id:this.idgen.get(p.pageId),type:"changelogEntry",title:_.format("MMMM D, YYYY"),slug:a.apply({fullSlug:this.markdownToFullSlug.get(p.absoluteFilepath)?.split("/"),urlSlug:_.format("YYYY/M/D")}).get(),icon:void 0,hidden:void 0,date:p.date.toISOString(),pageId:p.pageId,noindex:this.markdownToNoIndex.get(p.absoluteFilepath),authed:void 0,viewers:void 0,orphaned:void 0,featureFlags:void 0,tags:this.markdownToTags.get(p.absoluteFilepath)}}),f=xvc(c,p=>p.date,"desc"),s=n!=null?Ct.PageId(this.toRelativeFilepath(n)):void 0,u=this.idgen.get(s??"changelog"),l=this.groupByYear(u,f,a);return{id:u,type:"changelog",title:r,slug:a.get(),icon:t.icon,hidden:t.hidden,children:l,overviewPageId:s,noindex:o,authed:void 0,viewers:t.viewers,orphaned:t.orphaned,featureFlags:void 0}}orUndefined(){return this.changelogFiles!=null&&this.changelogFiles.length>0?this:void 0}groupByYear(t,r,i){let n=new Map;for(let a of r){let o=RLn.default.utc(a.date).year(),c=n.get(o)??[];c.push(a),n.set(o,c)}return xvc(Array.from(n.entries()).map(([a,o])=>{let c=i.append(a.toString()).get(),f=this.idgen.get(`${t}/year/${a}`);return{id:f,type:"changelogYear",title:a.toString(),year:a,slug:c,icon:void 0,hidden:void 0,children:this.groupByMonth(f,o,i),authed:void 0,viewers:void 0,orphaned:void 0,featureFlags:void 0}}),"year","desc")}groupByMonth(t,r,i){let n=new Map;for(let a of r){let o=RLn.default.utc(a.date).month()+1,c=n.get(o)??[];c.push(a),n.set(o,c)}return xvc(Array.from(n.entries()).map(([a,o])=>{let c=(0,RLn.default)(new Date(0,a-1));return{id:this.idgen.get(`${t}/month/${a}`),type:"changelogMonth",title:c.format("MMMM YYYY"),month:a,slug:i.append(a.toString()).get(),icon:void 0,hidden:void 0,children:o,authed:void 0,viewers:void 0,orphaned:void 0,featureFlags:void 0}}),"month","desc")}toRelativeFilepath(t){if(t!=null)return ab(this.docsWorkspace.absoluteFilePath,t)}};function xvc(e,t,r="asc"){return e.concat().sort((i,n)=>{let a=typeof t=="function"?t(i):i[t],o=typeof t=="function"?t(n):n[t];return a<o?r==="asc"?-1:1:a>o?r==="asc"?1:-1:0})}function Fz_(e){if(e)return{environments:e.environments!=null&&e.environments.length>0?e.environments.map(t=>Ct.V1.EnvironmentId(t)):void 0,button:e.button!=null&&e.button.href?{href:Ct.V1.Url(e.button.href)}:void 0,"limit-websocket-messages-per-connection":e.limitWebsocketMessagesPerConnection!=null?e.limitWebsocketMessagesPerConnection:void 0,hidden:e.hidden!=null?e.hidden:void 0}}function Gvc({child:e,nodeIdToSubpackageId:t,convertApiDefinitionPackageId:r,mergeAndFilterChildren:i}){if(e.type==="apiPackage"){let n=Ct.V1.SlugGenerator.init(e.slug),o=(t.get(e.id)??[]).flatMap(s=>r(s,n,e.availability)),c=e.children.map(s=>Gvc({child:s,nodeIdToSubpackageId:t,convertApiDefinitionPackageId:r,mergeAndFilterChildren:i})),f=i(c,o);return{...e,children:f,pointsTo:void 0}}return e}var Gz_=ue(Vz_(),1);var W0=function(e,t,r,i){function n(a){return a instanceof r?a:new r(function(o){o(a)})}return new(r||(r=Promise))(function(a,o){function c(u){try{s(i.next(u))}catch(l){o(l)}}function f(u){try{s(i.throw(u))}catch(l){o(l)}}function s(u){u.done?a(u.value):n(u.value).then(c,f)}s((i=i.apply(e,t||[])).next())})},Zm=function(e,t){var r={label:0,sent:function(){if(a[0]&1)throw a[1];return a[1]},trys:[],ops:[]},i,n,a,o=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return o.next=c(0),o.throw=c(1),o.return=c(2),typeof Symbol=="function"&&(o[Symbol.iterator]=function(){return this}),o;function c(s){return function(u){return f([s,u])}}function f(s){if(i)throw new TypeError("Generator is already executing.");for(;o&&(o=0,s[0]&&(r=0)),r;)try{if(i=1,n&&(a=s[0]&2?n.return:s[0]?n.throw||((a=n.return)&&a.call(n),0):n.next)&&!(a=a.call(n,s[1])).done)return a;switch(n=0,a&&(s=[s[0]&2,a.value]),s[0]){case 0:case 1:a=s;break;case 4:return r.label++,{value:s[1],done:!1};case 5:r.label++,n=s[1],s=[0];continue;case 7:s=r.ops.pop(),r.trys.pop();continue;default:if(a=r.trys,!(a=a.length>0&&a[a.length-1])&&(s[0]===6||s[0]===2)){r=0;continue}if(s[0]===3&&(!a||s[1]>a[0]&&s[1]<a[3])){r.label=s[1];break}if(s[0]===6&&r.label<a[1]){r.label=a[1],a=s;break}if(a&&r.label<a[2]){r.label=a[2],r.ops.push(s);break}a[2]&&r.ops.pop(),r.trys.pop();continue}s=t.call(e,r)}catch(u){s=[6,u],n=0}finally{i=a=0}if(s[0]&5)throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}},$he=function(e,t){var r=typeof Symbol=="function"&&e[Symbol.iterator];if(!r)return e;var i=r.call(e),n,a=[],o;try{for(;(t===void 0||t-- >0)&&!(n=i.next()).done;)a.push(n.value)}catch(c){o={error:c}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return a},jPe=function(e,t,r){if(r||arguments.length===2)for(var i=0,n=t.length,a;i<n;i++)(a||!(i in t))&&(a||(a=Array.prototype.slice.call(t,0,i)),a[i]=t[i]);return e.concat(a||Array.prototype.slice.call(t))},Wz_=function(e){var t=typeof Symbol=="function"&&Symbol.iterator,r=t&&e[t],i=0;if(r)return r.call(e);if(e&&typeof e.length=="number")return{next:function(){return e&&i>=e.length&&(e=void 0),{value:e&&e[i++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")},HVx=(function(){function e(t){t===void 0&&(t=e.minComparator);var r=this;this.compare=t,this.heapArray=[],this._limit=0,this.offer=this.add,this.element=this.peek,this.poll=this.pop,this._invertedCompare=function(i,n){return r.compare(i,n).then(function(a){return-1*a})}}return e.getChildrenIndexOf=function(t){return[t*2+1,t*2+2]},e.getParentIndexOf=function(t){if(t<=0)return-1;var r=t%2?1:2;return Math.floor((t-r)/2)},e.getSiblingIndexOf=function(t){if(t<=0)return-1;var r=t%2?1:-1;return t+r},e.minComparator=function(t,r){return W0(this,void 0,void 0,function(){return Zm(this,function(i){return t>r?[2,1]:t<r?[2,-1]:[2,0]})})},e.maxComparator=function(t,r){return W0(this,void 0,void 0,function(){return Zm(this,function(i){return r>t?[2,1]:r<t?[2,-1]:[2,0]})})},e.minComparatorNumber=function(t,r){return W0(this,void 0,void 0,function(){return Zm(this,function(i){return[2,t-r]})})},e.maxComparatorNumber=function(t,r){return W0(this,void 0,void 0,function(){return Zm(this,function(i){return[2,r-t]})})},e.defaultIsEqual=function(t,r){return W0(this,void 0,void 0,function(){return Zm(this,function(i){return[2,t===r]})})},e.print=function(t){function r(u){var l=e.getParentIndexOf(u);return Math.floor(Math.log2(l+1))}function i(u,l){for(var p="";l>0;--l)p+=u;return p}for(var n=0,a=[],o=r(t.length-1)+2,c=0;n<t.length;){var f=r(n)+1;n===0&&(f=0);var s=String(t.get(n));s.length>c&&(c=s.length),a[f]=a[f]||[],a[f].push(s),n+=1}return a.map(function(u,l){var p=Math.pow(2,o-l)-1;return i(" ",Math.floor(p/2)*c)+u.map(function(_){var h=(c-_.length)/2;return i(" ",Math.ceil(h))+_+i(" ",Math.floor(h))}).join(i(" ",p*c))}).join(`
1761
+ ${JSON.stringify(r)}"`)}}function $R_(e,t,r,i){let n=r.resolveSourceOrThrow({source:t,relativeFilepath:e.relativeFilepath});if(n==null||n.type!=="protobuf")throw new Error(`Expected a protobuf source for ${t.proto}.`);let a=HR_({source:n,serviceNameOverride:i});if(a==null)throw new Error(`Failed to resolve service name from ${n.relativeFilePath}.`);return P0e.grpc({service:a})}function YR_({rootDefaultUrl:e,rootPathParameters:t,serviceDefinition:r,file:i,errorResolver:n,typeResolver:a,propertyResolver:o,exampleResolver:c,variableResolver:f,sourceResolver:s,globalErrors:u,workspace:l,auth:p,irSettings:_}){let h=qLn({pathParameters:r["path-parameters"],location:j0e.Service,file:i,variableResolver:f}),y=_.pathParameterOrder,b=(()=>{switch(y){case hn.PathParameterOrder.UrlOrder:return r["base-path"]?_9o(r["base-path"],h):h;case hn.PathParameterOrder.SpecOrder:return h;default:Ot(y)}})(),v=KR_({file:i,serviceDeclaration:r,sourceResolver:s}),O={fernFilepath:i.fernFilepath};return{availability:vK(r.availability),name:O,displayName:r["display-name"]??void 0,basePath:PD(r["base-path"]),headers:r.headers!=null?Object.entries(r.headers).map(([g,m])=>PPe({headerKey:g,header:m,file:i})):[],pathParameters:b,encoding:WzM(v,r),transport:v,endpoints:Object.entries(r.endpoints).map(([g,m])=>{let j=m["base-path"]!=null?(0,g9o.default)(m["base-path"],m.path):i.rootApiFile["base-path"]!=null?(0,g9o.default)(i.rootApiFile["base-path"],r["base-path"],m.path):(0,g9o.default)(r["base-path"],m.path),M=qLn({pathParameters:LFt(m),location:j0e.Endpoint,file:i,variableResolver:f}),E=(()=>{switch(y){case hn.PathParameterOrder.UrlOrder:return _9o(m.path,M);case hn.PathParameterOrder.SpecOrder:return M;default:Ot(y)}})(),D=m["base-path"]!=null?E:[...t,...b,...E],B=(()=>{switch(y){case hn.PathParameterOrder.UrlOrder:return _9o(j,D);case hn.PathParameterOrder.SpecOrder:return D;default:Ot(y)}})(),F={...l8(m),id:"",name:i.casingsGenerator.generateName(g),displayName:m["display-name"],auth:typeof m.auth=="boolean"?m.auth:m.auth!=null?m.auth.length>0:r.auth,security:typeof m.auth>"u"||typeof m.auth=="boolean"?m.auth??r.auth===!0?C3._visit(p.requirement,{any:()=>p.schemes.map(N=>({[N.key]:[]})),all:()=>[p.schemes.reduce((N,R)=>({...N,[R.key]:[]}),{})],_other:()=>{}}):void 0:m.auth,docs:m.docs,idempotent:m.idempotent??r.idempotent??!1,baseUrl:m.url??r.url??e,v2BaseUrls:void 0,method:m.method!=null?VzM(m.method):WP.Post,basePath:m["base-path"]!=null?PD(m["base-path"]):void 0,path:PD(m.path),fullPath:PD(j),pathParameters:E,allPathParameters:B,queryParameters:typeof m.request!="string"&&m.request?.["query-parameters"]!=null?Object.entries(m.request["query-parameters"]).map(([N,R])=>b9o({file:i,queryParameterKey:N,queryParameter:R})):[],headers:typeof m.request!="string"&&m.request?.headers!=null?Object.entries(m.request.headers).map(([N,R])=>PPe({headerKey:N,header:R,file:i})):[],requestBody:oR_({request:m.request,file:i}),v2RequestBodies:void 0,sdkRequest:fR_({service:r,request:m.request,endpoint:m,endpointKey:g,file:i,typeResolver:a,propertyResolver:o}),response:FR_({endpoint:m,file:i,typeResolver:a}),v2Responses:void 0,errors:[...xR_({errors:m.errors,file:i}),...u],userSpecifiedExamples:m.examples!=null?m.examples.map(N=>{try{let R=NR_({service:r,endpoint:m,example:N,typeResolver:a,errorResolver:n,exampleResolver:c,variableResolver:f,file:i,workspace:l});return R===void 0?void 0:{example:R,codeSamples:N["code-samples"]?.map(z=>dR_({codeSample:z,file:i}))}}catch{return}}).filter(N=>N!==void 0):[],autogeneratedExamples:[],pagination:WR_({propertyResolver:o,file:i,endpointName:g,endpointSchema:m}),transport:JR_({file:i,serviceTransport:v,endpointDeclaration:m,sourceResolver:s}),v2Examples:void 0,source:void 0,audiences:m.audiences,retries:GR_({endpointSchema:m}),apiPlayground:void 0};return F.id=up.generateEndpointId(O,F),F}),audiences:r.audiences}}function qLn({pathParameters:e,location:t,file:r,variableResolver:i}){return e==null?[]:Object.entries(e).map(([n,a])=>UzM({parameterName:n,parameter:a,location:t,file:r,variableResolver:i}))}function UzM({parameterName:e,parameter:t,location:r,file:i,variableResolver:n}){return{...l8(t),name:i.casingsGenerator.generateName(e),valueType:LzM({parameter:t,variableResolver:n,file:i}),location:r,variable:YFn(t)?n.getVariableIdOrThrow(typeof t=="string"?t:t.variable):void 0,v2Examples:{userSpecifiedExamples:{},autogeneratedExamples:{}},explode:void 0}}function LzM({parameter:e,variableResolver:t,file:r}){let i=xEa({parameter:e,variableResolver:t,file:r});return i.file.parseTypeReference(i.rawType)}function xEa({parameter:e,variableResolver:t,file:r}){let i=O9o({parameter:e,variableResolver:t,file:r});if(i==null)throw new Error("Cannot resolve path parameter");return i}function O9o({parameter:e,variableResolver:t,file:r}){if(YFn(e)){let i=typeof e=="string"?e:e.variable,n=t.getDeclaration(i,r);return n==null?void 0:{rawType:typeof n.declaration=="string"?n.declaration:n.declaration.type,file:n.file}}else return{file:r,rawType:typeof e=="string"?e:e.type}}function VzM(e){switch(e){case"GET":return WP.Get;case"POST":return WP.Post;case"PUT":return WP.Put;case"PATCH":return WP.Patch;case"DELETE":return WP.Delete;case"HEAD":return WP.Head;default:Ot(e)}}function PPe({headerKey:e,header:t,file:r}){let{name:i}=Y9t({headerKey:e,header:t});return{...l8(t),name:r.casingsGenerator.generateNameAndWireValue({wireValue:e,name:i}),valueType:r.parseTypeReference(t),env:typeof t=="string"?void 0:t.env,v2Examples:{userSpecifiedExamples:{},autogeneratedExamples:{}}}}function Y9t({headerKey:e,header:t}){return typeof t!="string"&&t.name!=null?{name:t.name,wasExplicitlySet:!0}:{name:e,wasExplicitlySet:!1}}function WzM(e,t){switch(e.type){case"http":return{json:{},proto:void 0};case"grpc":return{json:void 0,proto:{}};default:Ot(e)}}var A9o=ue(Sv(),1);var XR_="1.0.0";var m9o=class{ir;casingsGenerator;auth;authValues;generatorConfig;extendedTypeIds;constructor(t){this.ir=t.ir,this.generatorConfig=t.generatorConfig,this.casingsGenerator=hx({generationLanguage:t.generationLanguage,smartCasing:t.smartCasing??!1,keywords:void 0}),this.auth=this.convertAuth(this.ir.auth),this.authValues=this.getAuthValues(this.ir.auth),this.extendedTypeIds=this.computeExtendedTypeIds()}computeExtendedTypeIds(){let t=new Set;for(let r of Object.values(this.ir.types))if(r.shape.type==="object")for(let i of r.shape.extends)t.add(i.typeId);return t}convert({disableExamples:t}){return{version:XR_,types:this.convertNamedTypes(),headers:this.convertHeaders(),endpoints:this.convertEndpoints({disableExamples:t}),pathParameters:this.convertPathParameters({pathParameters:this.ir.pathParameters}),environments:this.ir.environments,variables:this.convertVariables(),generatorConfig:this.generatorConfig}}convertNamedTypes(){return Object.fromEntries(Object.entries(this.ir.types).map(([t,r])=>[t,this.convertTypeDeclaration(r)]))}convertHeaders(){return this.convertWireValueParameters({wireValueParameters:this.ir.headers})}convertVariables(){if(this.ir.variables.length!==0)return this.ir.variables.map(t=>({id:t.id,name:t.name,typeReference:this.convertTypeReference(t.type)}))}convertEndpoints({disableExamples:t}){let r=this.getAllHttpEndpoints();return Object.fromEntries(r.map(i=>[i.id,this.convertEndpoint({endpoint:i,disableExamples:t})]))}convertEndpoint({endpoint:t,disableExamples:r}){let i=this.convertEndpointLocation({endpoint:t});return{auth:this.auth,declaration:this.convertDeclaration({name:t.name,fernFilepath:t.fernFilepath}),location:i,request:this.convertRequest({endpoint:t}),response:t.response?.body?._visit({json:()=>Kt.Response.json(),streaming:()=>Kt.Response.streaming(),streamParameter:()=>Kt.Response.streamParameter(),fileDownload:()=>Kt.Response.fileDownload(),text:()=>Kt.Response.text(),bytes:()=>Kt.Response.bytes(),_other:()=>Kt.Response.json()})??Kt.Response.json(),examples:r?void 0:this.getEndpointSnippetRequests({endpoint:t,location:i})}}convertRequest({endpoint:t}){let r=this.convertPathParameters({pathParameters:[...t.servicePathParameters,...t.pathParameters]});if(t.sdkRequest==null&&t.requestBody==null)return Kt.Request.body({pathParameters:r,body:void 0});if(t.sdkRequest==null)throw new Error(`Internal error; endpoint "${t.id}" has a request body but no SDK request`);switch(t.sdkRequest.shape.type){case"justRequestBody":return Kt.Request.body({pathParameters:r,body:this.convertReferencedRequestBodyType({body:t.sdkRequest.shape.value})});case"wrapper":return this.convertInlinedRequest({fernFilepath:t.fernFilepath,wrapper:t.sdkRequest.shape,pathParameters:r,queryParameters:this.convertQueryParameters({queryParameters:t.queryParameters}),headers:this.convertWireValueParameters({wireValueParameters:[...t.serviceHeaders,...t.headers]}),body:t.requestBody});default:Ot(t.sdkRequest.shape)}}convertReferencedRequestBodyType({body:t}){switch(t.type){case"bytes":return Kt.ReferencedRequestBodyType.bytes();case"typeReference":return Kt.ReferencedRequestBodyType.typeReference(this.convertTypeReference(t.requestBodyType));default:Ot(t)}}convertInlinedRequest({fernFilepath:t,wrapper:r,pathParameters:i,queryParameters:n,headers:a,body:o}){return Kt.Request.inlined({declaration:this.convertDeclaration({name:r.wrapperName,fernFilepath:t}),pathParameters:i,queryParameters:n,headers:a,body:o!=null?this.convertInlinedRequestBody({wrapper:r,body:o}):void 0,metadata:this.convertInlinedRequestMetadata({wrapper:r})})}convertInlinedRequestMetadata({wrapper:t}){return{includePathParameters:t.includePathParameters??!1,onlyPathParameters:t.onlyPathParameters??!1}}convertInlinedRequestBody({wrapper:t,body:r}){switch(r.type){case"inlinedRequestBody":{let i=[...r.extendedProperties??[],...r.properties];return Kt.InlinedRequestBody.properties(this.convertBodyPropertiesToParameters({properties:i}))}case"reference":return Kt.InlinedRequestBody.referenced({bodyKey:t.bodyKey,bodyType:Kt.ReferencedRequestBodyType.typeReference(this.convertTypeReference(r.requestBodyType))});case"bytes":return Kt.InlinedRequestBody.referenced({bodyKey:t.bodyKey,bodyType:Kt.ReferencedRequestBodyType.bytes()});case"fileUpload":return this.convertFileUploadRequestBody({properties:r.properties});default:Ot(r)}}convertFileUploadRequestBody({properties:t}){return Kt.InlinedRequestBody.fileUpload({properties:this.convertFileUploadRequestBodyProperties({properties:t})})}convertFileUploadRequestBodyProperties({properties:t}){return t.map(r=>{switch(r.type){case"file":return this.convertFileUploadRequestBodyFileProperty({fileProperty:r.value});case"bodyProperty":return Kt.FileUploadRequestBodyProperty.bodyProperty({name:r.name,typeReference:this.convertTypeReference(r.valueType),propertyAccess:r.propertyAccess,variable:void 0});default:Ot(r)}})}convertFileUploadRequestBodyFileProperty({fileProperty:t}){switch(t.type){case"file":return Kt.FileUploadRequestBodyProperty.file(t.key);case"fileArray":return Kt.FileUploadRequestBodyProperty.fileArray(t.key);default:Ot(t)}}convertPathParameters({pathParameters:t}){return t.map(r=>({name:{name:r.name,wireValue:r.name.originalName},typeReference:this.convertTypeReference(r.valueType),propertyAccess:void 0,variable:r.variable}))}convertBodyPropertiesToParameters({properties:t}){return t.map(r=>({name:{name:r.name.name,wireValue:r.name.wireValue},typeReference:this.convertTypeReference(r.valueType),propertyAccess:r.propertyAccess,variable:void 0}))}convertWireValueParameters({wireValueParameters:t}){return t.map(r=>({name:{name:r.name.name,wireValue:r.name.wireValue},typeReference:this.convertTypeReference(r.valueType),propertyAccess:void 0,variable:void 0}))}convertQueryParameters({queryParameters:t}){let r=[];for(let i of t){let n=this.convertTypeReference(i.valueType);i.allowMultiple&&(n=Kt.TypeReference.list(n)),r.push({name:{name:i.name.name,wireValue:i.name.wireValue},typeReference:n,propertyAccess:void 0,variable:void 0})}return r}convertTypeReference(t){switch(t.type){case"container":return this.convertContainerType(t.container);case"named":return this.convertNamedType(t);case"primitive":return this.convertPrimitiveType(t.primitive);case"unknown":return this.convertUnknownType();default:Ot(t)}}convertContainerType(t){switch(t.type){case"list":return Kt.TypeReference.list(this.convertTypeReference(t.list));case"map":return Kt.TypeReference.map({key:this.convertTypeReference(t.keyType),value:this.convertTypeReference(t.valueType)});case"optional":return Kt.TypeReference.optional(this.convertTypeReference(t.optional));case"nullable":return Kt.TypeReference.nullable(this.convertTypeReference(t.nullable));case"set":return Kt.TypeReference.set(this.convertTypeReference(t.set));case"literal":return Kt.TypeReference.literal(this.convertLiteral(t.literal));default:Ot(t)}}convertNamedType(t){return Kt.TypeReference.named(t.typeId)}convertTypeDeclaration(t){let r=this.convertDeclaration(t.name);switch(t.shape.type){case"alias":return this.convertAlias({declaration:r,alias:t.shape});case"enum":return this.convertEnum({declaration:r,enum_:t.shape});case"object":return this.convertObject({declaration:r,object:t.shape,typeId:t.name.typeId});case"union":return this.convertDiscriminatedUnion({declaration:r,union:t.shape});case"undiscriminatedUnion":return this.convertUndiscriminatedUnion({declaration:r,union:t.shape});default:Ot(t.shape)}}convertAlias({declaration:t,alias:r}){return Kt.NamedType.alias({declaration:t,typeReference:this.convertTypeReference(r.aliasOf)})}convertEnum({declaration:t,enum_:r}){return Kt.NamedType.enum({declaration:t,values:r.values.map(i=>i.name)})}convertObject({declaration:t,object:r,typeId:i}){let a=this.extendedTypeIds.has(i)?[...r.properties,...r.extendedProperties??[]]:[...r.extendedProperties??[],...r.properties];return this.convertObjectProperties({declaration:t,properties:a,additionalProperties:r.extraProperties})}convertObjectProperties({declaration:t,properties:r,additionalProperties:i}){return Kt.NamedType.object({declaration:t,properties:this.convertBodyPropertiesToParameters({properties:r}),additionalProperties:i})}convertDiscriminatedUnion({declaration:t,union:r}){let i=[...this.resolveProperties(r.extends),...r.baseProperties];return Kt.NamedType.discriminatedUnion({declaration:t,discriminant:r.discriminant,types:Object.fromEntries(r.types.map(n=>[n.discriminantValue.wireValue,this.convertDiscriminatedUnionType({inheritedProperties:i,discriminantValue:n.discriminantValue,singleUnionTypeProperties:n.shape})]))})}convertDiscriminatedUnionType({inheritedProperties:t,discriminantValue:r,singleUnionTypeProperties:i}){switch(i.propertiesType){case"samePropertiesAsObject":return this.convertDiscriminatedUnionTypeObject({inheritedProperties:t,discriminantValue:r,declaredTypeName:i});case"singleProperty":return this.convertDiscriminatedUnionTypeSingleProperty({inheritedProperties:t,discriminantValue:r,singleUnionTypeProperty:i});case"noProperties":return this.convertDiscriminatedUnionTypeNoProperties({inheritedProperties:t,discriminantValue:r});default:Ot(i)}}convertDiscriminatedUnionTypeObject({inheritedProperties:t,discriminantValue:r,declaredTypeName:i}){return Kt.SingleDiscriminatedUnionType.samePropertiesAsObject({typeId:i.typeId,discriminantValue:r,properties:this.convertBodyPropertiesToParameters({properties:t})})}convertDiscriminatedUnionTypeSingleProperty({inheritedProperties:t,discriminantValue:r,singleUnionTypeProperty:i}){return Kt.SingleDiscriminatedUnionType.singleProperty({typeReference:this.convertTypeReference(i.type),discriminantValue:r,properties:t.length>0?this.convertBodyPropertiesToParameters({properties:t}):void 0})}convertDiscriminatedUnionTypeNoProperties({inheritedProperties:t,discriminantValue:r}){return Kt.SingleDiscriminatedUnionType.noProperties({discriminantValue:r,properties:t.length>0?this.convertBodyPropertiesToParameters({properties:t}):void 0})}convertUndiscriminatedUnion({declaration:t,union:r}){return Kt.NamedType.undiscriminatedUnion({declaration:t,types:r.members.map(i=>this.convertTypeReference(i.type))})}convertLiteral(t){switch(t.type){case"boolean":return Kt.LiteralType.boolean(t.boolean);case"string":return Kt.LiteralType.string(t.string);default:Ot(t)}}convertPrimitiveType(t){return Kt.TypeReference.primitive(t.v1)}convertUnknownType(){return Kt.TypeReference.unknown()}convertAuth(t){if(t.schemes[0]==null)return;let r=t.schemes[0];switch(r.type){case"basic":return Kt.Auth.basic(r);case"bearer":return Kt.Auth.bearer(r);case"header":return Kt.Auth.header({header:{name:r.name,typeReference:this.convertTypeReference(r.valueType),propertyAccess:void 0,variable:void 0}});case"oauth":return Kt.Auth.oauth({clientId:this.casingsGenerator.generateName("clientId"),clientSecret:this.casingsGenerator.generateName("clientSecret")});case"inferred":return Kt.Auth.inferred({parameters:this.getInferredAuthParameters(r)});default:Ot(r)}}getAuthValues(t){let r=t.schemes[0];if(r!=null)switch(r.type){case"bearer":return Kt.AuthValues.bearer({token:"<token>"});case"basic":return Kt.AuthValues.basic({username:"<username>",password:"<password>"});case"header":return Kt.AuthValues.header({value:"<value>"});case"oauth":return Kt.AuthValues.oauth({clientId:"<clientId>",clientSecret:"<clientSecret>"});case"inferred":return Kt.AuthValues.inferred({values:this.getInferredAuthValues(r)});default:Ot(r)}}getInferredAuthParameters(t){let r=[],i=Object.values(this.ir.services).flatMap(n=>n.endpoints).find(n=>n.id===t.tokenEndpoint.endpoint.endpointId);if(i==null)return r;for(let n of i.headers)(n.valueType.type!=="container"||n.valueType.container.type!=="literal")&&r.push({name:{name:n.name.name,wireValue:n.name.wireValue},typeReference:this.convertTypeReference(n.valueType),propertyAccess:void 0,variable:void 0});if(i.requestBody!=null){let n=this.getRequestBodyProperties(i.requestBody);for(let a of n)(a.valueType.type!=="container"||a.valueType.container.type!=="literal")&&r.push({name:{name:a.name.name,wireValue:a.name.wireValue},typeReference:this.convertTypeReference(a.valueType),propertyAccess:void 0,variable:void 0})}return r}getInferredAuthValues(t){let r={},i=Object.values(this.ir.services).flatMap(n=>n.endpoints).find(n=>n.id===t.tokenEndpoint.endpoint.endpointId);if(i==null)return r;for(let n of i.headers)(n.valueType.type!=="container"||n.valueType.container.type!=="literal")&&(r[n.name.wireValue]=n.name.wireValue);if(i.requestBody!=null){let n=this.getRequestBodyProperties(i.requestBody);for(let a of n)(a.valueType.type!=="container"||a.valueType.container.type!=="literal")&&(r[a.name.wireValue]=a.name.wireValue)}return r}getRequestBodyProperties(t){let r=[];if(t.type==="inlinedRequestBody")r.push(...t.properties);else if(t.type==="reference"){let i=t.requestBodyType;if(i.type==="named"){let n=this.ir.types[i.typeId];n!=null&&n.shape.type==="object"&&r.push(...n.shape.properties)}}return r}convertDeclaration({name:t,fernFilepath:r}){return{name:t,fernFilepath:r}}convertEndpointLocation({endpoint:t}){return{method:t.method,path:this.getFullPathForEndpoint(t)}}getAllHttpEndpoints(){return Object.values(this.ir.services).flatMap(t=>t.endpoints.map(r=>({...r,servicePathParameters:t.pathParameters,serviceHeaders:t.headers,fernFilepath:t.name.fernFilepath})))}resolveProperties(t){let r=[];for(let i of t){let n=this.resolveObjectTypeOrThrow(i.typeId);r.push(...this.resolveProperties(n.extends)),r.push(...n.properties)}return Object.values(r)}resolveObjectTypeOrThrow(t){let r=this.ir.types[t];if(r==null)throw new Error(`Internal error; type "${t}" not found`);if(r.shape.type!=="object")throw new Error(`Internal error; type "${t}" is not an object`);return r.shape}getFullPathForEndpoint(t){let r="";t.fullPath.head.length>0&&(r=(0,A9o.default)(r,t.fullPath.head));for(let i of t.fullPath.parts)r=(0,A9o.default)(r,"{"+i.pathParameter+"}"),i.tail.length>0&&(r=(0,A9o.default)(r,i.tail));return r.startsWith("/")?r:`/${r}`}getEndpointSnippetRequests({endpoint:t,location:r}){let i=[];for(let n of[...t.userSpecifiedExamples,...t.autogeneratedExamples]){let a=new Set;[...this.ir.pathParameters,...t.pathParameters].forEach(c=>{c.variable!=null&&a.add(c.name.originalName)});let o=[...n.example?.rootPathParameters??[],...n.example?.servicePathParameters??[],...n.example?.endpointPathParameters??[]].filter(c=>!a.has(c.name.originalName));i.push({id:n?.example?.id??ehe(),name:n?.example?.name?.originalName,endpoint:r,baseUrl:void 0,environment:void 0,auth:this.authValues,headers:Object.fromEntries([...n.example?.serviceHeaders??[],...n.example?.endpointHeaders??[]].map(c=>[c.name.wireValue,c.value.jsonExample])),pathParameters:Object.fromEntries(o.map(c=>[c.name.originalName,c.value.jsonExample])),queryParameters:Object.fromEntries([...n.example?.queryParameters??[]].map(c=>[c.name.wireValue,c.value.jsonExample])),requestBody:n.example?.request?.jsonExample})}return i}};function GEa({ir:e,generationLanguage:t,smartCasing:r,disableExamples:i,generatorConfig:n}){return new m9o({ir:e,generationLanguage:t,smartCasing:r,generatorConfig:n}).convert({disableExamples:i})}var f8={};Yt(f8,{validateObjectExample:()=>R$i,validateTypeExample:()=>h9o,validateTypeReferenceExample:()=>Sz});function ZR_(e){return{errorInstanceIdKey:e.generateNameAndWireValue({wireValue:"errorInstanceId",name:"errorInstanceId"})}}var P9o=e=>{let t=Ohe(e.file.fernFilepath),r=e.endpointId;return`endpoint_${t}.${r}`};function j9o({fernFilePath:e}){return e.packagePath.length===0&&e.file==null}function w9o({resolvedEndpoint:e}){return{endpointId:P9o(e),serviceId:up.generateServiceIdFromFernFilepath(e.file.fernFilepath),subpackageId:j9o({fernFilePath:e.file.fernFilepath})?void 0:up.generateSubpackageId(e.file.fernFilepath)}}function kR_({endpointResolver:e,propertyResolver:t,file:r,refreshTokenEndpoint:i}){let n=e.resolveEndpointOrThrow({endpoint:i.endpoint,file:r}),a;try{a=i.responseProperties.expires_in!=null?t.resolveResponsePropertyOrThrow({file:r,endpoint:i.endpoint,propertyComponents:i.responseProperties.expires_in}):void 0}catch{}return{endpointReference:{endpointId:P9o(n),serviceId:up.generateServiceIdFromFernFilepath(n.file.fernFilepath),subpackageId:j9o({fernFilePath:n.file.fernFilepath})?void 0:up.generateSubpackageId(n.file.fernFilepath)},requestProperties:{refreshToken:t.resolveRequestPropertyOrThrow({file:r,endpoint:i.endpoint,propertyComponents:i.requestProperties.refresh_token})},responseProperties:{accessToken:t.resolveResponsePropertyOrThrow({file:r,endpoint:i.endpoint,propertyComponents:i.responseProperties.access_token}),expiresIn:a,refreshToken:i.responseProperties.refresh_token!=null?t.resolveResponsePropertyOrThrow({file:r,endpoint:i.endpoint,propertyComponents:i.responseProperties.refresh_token}):void 0}}}function ez_({endpointResolver:e,propertyResolver:t,file:r,tokenEndpoint:i}){let n=e.resolveEndpointOrThrow({endpoint:i.endpoint,file:r}),a=typeof n.endpoint.request=="object"&&n.endpoint.request.body!=null&&typeof n.endpoint.request.body=="object"&&"properties"in n.endpoint.request.body?n.endpoint.request.body.properties??{}:{},o;try{o=i.responseProperties.expires_in!=null?t.resolveResponsePropertyOrThrow({file:r,endpoint:i.endpoint,propertyComponents:i.responseProperties.expires_in}):void 0}catch{}return{endpointReference:w9o({resolvedEndpoint:n}),requestProperties:{clientId:t.resolveRequestPropertyOrThrow({file:r,endpoint:i.endpoint,propertyComponents:i.requestProperties.client_id}),clientSecret:t.resolveRequestPropertyOrThrow({file:r,endpoint:i.endpoint,propertyComponents:i.requestProperties.client_secret}),scopes:i.requestProperties.scopes!=null?t.resolveRequestPropertyOrThrow({file:r,endpoint:i.endpoint,propertyComponents:i.requestProperties.scopes}):void 0,customProperties:xzM({requestBodyProperties:a,tokenEndpoint:i,file:r,propertyResolver:t})},responseProperties:{accessToken:t.resolveResponsePropertyOrThrow({file:r,endpoint:i.endpoint,propertyComponents:i.responseProperties.access_token}),expiresIn:o,refreshToken:i.responseProperties.refresh_token!=null?t.resolveResponsePropertyOrThrow({file:r,endpoint:i.endpoint,propertyComponents:i.responseProperties.refresh_token}):void 0}}}var xzM=({requestBodyProperties:e,tokenEndpoint:t,file:r,propertyResolver:i})=>{let n=Object.keys(e).filter(a=>!t.requestProperties.client_id.includes(a)&&!t.requestProperties.client_secret.includes(a)&&(t.requestProperties.scopes==null||!t.requestProperties.scopes.includes(a)));return n.length>0?n.map(a=>i.resolveRequestPropertyOrThrow({file:r,endpoint:t.endpoint,propertyComponents:[a]})):void 0};function tz_({propertyResolver:e,endpointResolver:t,file:r,oauthScheme:i,tokenEndpoint:n,refreshTokenEndpoint:a}){let o=ez_({propertyResolver:e,endpointResolver:t,file:r,tokenEndpoint:n});if(o==null)throw new Error("Failed to convert OAuth token endpoint.");let c=a!=null?kR_({propertyResolver:e,endpointResolver:t,file:r,refreshTokenEndpoint:a}):void 0;return{clientIdEnvVar:i["client-id-env"],clientSecretEnvVar:i["client-secret-env"],tokenPrefix:i["token-prefix"],tokenHeader:i["token-header"],scopes:i.scopes,tokenEndpoint:o,refreshEndpoint:c}}var HEa={requestProperties:{type:"access_token",client_id:["client_id"],client_secret:["client_secret"],scopes:void 0},responseProperties:{type:"access_token",access_token:["access_token"],expires_in:["expires_in"],refresh_token:void 0}},Nvc={requestProperties:{type:"refresh_token",refresh_token:["refresh_token"]},responseProperties:{type:"access_token",access_token:["access_token"],refresh_token:void 0,expires_in:["expires_in"]}};function rz_(e){return{endpoint:e["get-token"].endpoint,requestProperties:GzM({requestProperties:e["get-token"]?.["request-properties"]}),responseProperties:HzM({responseProperties:e["get-token"]?.["response-properties"]})}}function iz_(e){if(e["refresh-token"]!=null)return{endpoint:e["refresh-token"].endpoint,requestProperties:KzM({requestProperties:e["refresh-token"]?.["request-properties"]}),responseProperties:JzM({responseProperties:e["refresh-token"]?.["response-properties"]})}}function GzM({requestProperties:e}){if(e==null)return HEa.requestProperties;let t=e["client-id"],r=e["client-secret"],i=e.scopes;return{type:"access_token",client_id:t!=null?UFt(t):HEa.requestProperties.client_id,client_secret:r!=null?UFt(r):HEa.requestProperties.client_secret,scopes:i!=null?UFt(i):HEa.requestProperties.scopes}}function HzM({responseProperties:e}){return nz_({responseProperties:e,defaultValue:HEa.responseProperties})}function KzM({requestProperties:e}){if(e==null)return Nvc.requestProperties;let t=e["refresh-token"];return{type:"refresh_token",refresh_token:t!=null?UFt(t):Nvc.requestProperties.refresh_token}}function JzM({responseProperties:e}){return nz_({responseProperties:e,defaultValue:Nvc.responseProperties})}function nz_({responseProperties:e,defaultValue:t}){if(e==null)return t;let r=e["access-token"],i=e["expires-in"],n=e["refresh-token"];return{type:"access_token",access_token:r!=null?Hhe(r):t.access_token,expires_in:i!=null?Hhe(i):t.expires_in,refresh_token:n!=null?Hhe(n):t.refresh_token}}function cz_({rawApiFileSchema:e,file:t,propertyResolver:r,endpointResolver:i}){if(e.auth==null)return{docs:void 0,requirement:C3.All,schemes:[]};let n=typeof e.auth!="string"?e.auth.docs:void 0;return NKi(e.auth,{single:a=>{let o=az_({reference:a,authSchemeDeclarations:e["auth-schemes"],file:t,propertyResolver:r,endpointResolver:i});return{docs:n,requirement:C3.All,schemes:[o]}},any:({any:a})=>({docs:n,requirement:C3.Any,schemes:a.map(o=>az_({reference:o,authSchemeDeclarations:e["auth-schemes"],file:t,propertyResolver:r,endpointResolver:i}))})})}function az_({reference:e,authSchemeDeclarations:t,file:r,propertyResolver:i,endpointResolver:n}){let a=(c,f)=>{let s=t?.[c];if(s==null)throw new Error("Unknown auth scheme: "+c);return tPa(s,{header:u=>wA.header({key:c,docs:f,name:r.casingsGenerator.generateNameAndWireValue({name:u.name??c,wireValue:u.header}),valueType:r.parseTypeReference(u.type??"string"),prefix:u.prefix,headerEnvVar:u.env}),basic:u=>uz_({key:c,file:r,docs:f,rawScheme:u}),tokenBearer:u=>oz_({key:c,file:r,docs:f,rawScheme:u}),inferredBearer:u=>$zM({key:c,file:r,docs:f,rawScheme:u,propertyResolver:i,endpointResolver:n}),oauth:u=>sz_({key:c,file:r,docs:f,rawScheme:u,propertyResolver:i,endpointResolver:n})})},o=typeof e=="string"?e:e.scheme;switch(o){case"bearer":return oz_({key:o,file:r,docs:void 0,rawScheme:void 0});case"basic":return uz_({key:o,file:r,docs:void 0,rawScheme:void 0});case"oauth":return sz_({key:o,file:r,docs:void 0,rawScheme:void 0,propertyResolver:i,endpointResolver:n});default:return a(o,typeof e!="string"?e.docs:void 0)}}function oz_({key:e,file:t,docs:r,rawScheme:i}){return wA.bearer({key:e,docs:r,token:t.casingsGenerator.generateName(i?.token?.name??"token"),tokenEnvVar:i?.token?.env})}function uz_({key:e,file:t,docs:r,rawScheme:i}){return wA.basic({key:e,docs:r,username:t.casingsGenerator.generateName(i?.username?.name??"username"),usernameEnvVar:i?.username?.env,password:t.casingsGenerator.generateName(i?.password?.name??"password"),passwordEnvVar:i?.password?.env})}function sz_({key:e,file:t,docs:r,rawScheme:i,propertyResolver:n,endpointResolver:a}){switch(i?.type){case"client-credentials":return wA.oauth({key:e,docs:r,configuration:$Ii.clientCredentials(tz_({propertyResolver:n,endpointResolver:a,file:t,oauthScheme:i,tokenEndpoint:rz_(i),refreshTokenEndpoint:iz_(i)}))});default:throw new Error(`Unknown OAuth type: '${i?.type}'`)}}function $zM({key:e,file:t,docs:r,rawScheme:i,propertyResolver:n,endpointResolver:a}){return wA.inferred({key:e,docs:r,tokenEndpoint:YzM({file:t,rawScheme:i,propertyResolver:n,endpointResolver:a})})}function YzM({file:e,rawScheme:t,propertyResolver:r,endpointResolver:i}){let n=t["get-token"],a=typeof n=="string"?{endpoint:n}:n,o=i.resolveEndpointOrThrow({endpoint:a.endpoint,file:e});return{endpoint:w9o({resolvedEndpoint:o}),expiryProperty:tNM({tokenEndpoint:o,getTokenEndpointConfig:a,propertyResolver:r}),authenticatedRequestHeaders:ZzM({tokenEndpoint:o,getTokenEndpointConfig:a,propertyResolver:r})}}var XzM=["access_token","accessToken","AccessToken","token","Token","auth_token","authToken","AuthToken","bearer_token","bearerToken","BearerToken","jwt","Jwt","authentication_token","authenticationToken","AuthenticationToken"];function ZzM({tokenEndpoint:e,getTokenEndpointConfig:t,propertyResolver:r}){let i=new Map,n=t["authenticated-request-headers"]??[];if(n.length>0&&n.forEach(a=>{i.set(a["header-name"].toLowerCase(),{headerName:a["header-name"],responseProperty:r.resolveResponsePropertyOrThrow({file:e.file,endpoint:e.endpointId,propertyComponents:Hhe(a["response-property"])}),valuePrefix:a["value-prefix"]})}),!i.has("authorization")){let a=kzM({tokenEndpoint:e,propertyResolver:r});a&&i.set("authorization",{headerName:"Authorization",responseProperty:a,valuePrefix:"Bearer "})}return Array.from(i.values())}function kzM({tokenEndpoint:e,propertyResolver:t}){for(let r of XzM)try{let i=t.resolveResponseProperty({file:e.file,endpoint:e.endpointId,propertyComponents:[r]});if(i)return i}catch{}}var eNM=["expires_in","expiresIn","ExpiresIn","exp","Exp","expiry","Expiry","expires","Expires","expires_at","expiresAt","ExpiresAt","expiration","Expiration","valid_until","validUntil","ValidUntil"];function tNM({tokenEndpoint:e,getTokenEndpointConfig:t,propertyResolver:r}){if(t["expiry-response-property"])return r.resolveResponsePropertyOrThrow({file:e.file,endpoint:e.endpointId,propertyComponents:Hhe(t["expiry-response-property"])});for(let i of eNM)try{let n=r.resolveResponseProperty({file:e.file,endpoint:e.endpointId,propertyComponents:[i]});if(n)return n}catch{}}function lz_({file:e,rawApiFileSchema:t}){if(t.version!=null)return ZIi.header({header:rNM({file:e,header:t.version.header}),value:iNM({file:e,versionDeclaration:t.version})})}function rNM({file:e,header:t}){return typeof t=="string"?PPe({file:e,headerKey:t,header:{type:"string"}}):PPe({file:e,headerKey:t.value,header:{type:"string",name:t.name,env:t.env}})}function iNM({file:e,versionDeclaration:t}){return y9o({_enum:{default:t.default,enum:t.values},file:e})}function fz_({channel:e,typeResolver:t,exampleResolver:r,variableResolver:i,file:n,workspace:a}){let o=[];for(let[c,f]of Object.entries(e.messages??{}))o.push({type:c,availability:vK(f.availability),docs:f.docs,origin:f.origin,body:oNM({body:f.body,file:n}),displayName:f["display-name"]});return{availability:vK(e.availability),path:PD(e.path),baseUrl:e.url,auth:e.auth,name:n.fernFilepath.file??n.casingsGenerator.generateName(e["display-name"]??e.path),displayName:e["display-name"],headers:e.headers!=null?Object.entries(e.headers).map(([c,f])=>PPe({headerKey:c,header:f,file:n})):[],docs:e.docs,pathParameters:e["path-parameters"]!=null?qLn({pathParameters:e["path-parameters"],location:j0e.Endpoint,file:n,variableResolver:i}):[],queryParameters:e["query-parameters"]!=null?Object.entries(e["query-parameters"]).map(([c,f])=>{let{name:s}=Qgi({queryParameterKey:c,queryParameter:f}),u=n.parseTypeReference(f);return{...l8(f),name:n.casingsGenerator.generateNameAndWireValue({wireValue:c,name:s}),valueType:u,allowMultiple:typeof f!="string"&&f["allow-multiple"]!=null?f["allow-multiple"]:!1,v2Examples:{userSpecifiedExamples:{},autogeneratedExamples:{}},explode:void 0}}):[],messages:Object.values(o),examples:(e.examples??[]).map(c=>{let f=sNM({channel:e,example:c,typeResolver:t,exampleResolver:r,variableResolver:i,file:n,workspace:a});return{name:c.name!=null?n.casingsGenerator.generateName(c.name):void 0,docs:c.docs,url:lNM({channel:e,example:c,pathParams:f}),...f,...cNM({channel:e,example:c,typeResolver:t,exampleResolver:r,file:n,workspace:a}),queryParameters:c["query-parameters"]!=null?Object.entries(c["query-parameters"]).map(([s,u])=>{let l=e["query-parameters"]?.[s];if(l==null)throw new Error(`Query parameter ${s} does not exist`);return{name:n.casingsGenerator.generateNameAndWireValue({name:Qgi({queryParameterKey:s,queryParameter:l}).name,wireValue:s}),value:Rv({example:u,rawTypeBeingExemplified:typeof l=="string"?l:l.type,typeResolver:t,exampleResolver:r,fileContainingRawTypeReference:n,fileContainingExample:n,workspace:a}),shape:nNM({queryParameter:l})}}):[],messages:c.messages.map(s=>{let u=e.messages?.[s.type];if(u==null)throw new Error(`Message ${s.type} does not exist`);return{type:s.type,body:aNM({message:u,example:s.body,typeResolver:t,exampleResolver:r,file:n,workspace:a})}})}}),v2Examples:{userSpecifiedExamples:{},autogeneratedExamples:{}}}}function nNM({queryParameter:e}){return(typeof e!="string"&&e["allow-multiple"]!=null?e["allow-multiple"]:!1)?M1.exploded():M1.single()}function aNM({message:e,example:t,typeResolver:r,exampleResolver:i,file:n,workspace:a}){if(!fNM(e.body))return bhe.reference(Rv({example:t,rawTypeBeingExemplified:typeof e.body!="string"?e.body.type:e.body,typeResolver:r,exampleResolver:i,fileContainingRawTypeReference:n,fileContainingExample:n,workspace:a}));if(!$c(t))throw new Error("Example must be an object");let o=[];for(let[c,f]of Object.entries(t)){let s=e.body.properties?.[c];if(s!=null)o.push({name:n.casingsGenerator.generateNameAndWireValue({name:Ez({propertyKey:c,property:s}).name,wireValue:c}),value:Rv({example:f,rawTypeBeingExemplified:typeof s!="string"?s.type:s,typeResolver:r,exampleResolver:i,fileContainingRawTypeReference:n,fileContainingExample:n,workspace:a}),originalTypeDeclaration:void 0});else{let u=WEa({extends_:e.body.extends,wirePropertyKey:c,typeResolver:r,file:n});if(u==null)throw new Error("Could not find original type declaration for property: "+c);o.push({name:n.casingsGenerator.generateNameAndWireValue({name:Ez({propertyKey:c,property:u.rawPropertyType}).name,wireValue:c}),value:Rv({example:f,rawTypeBeingExemplified:typeof u.rawPropertyType=="string"?u.rawPropertyType:u.rawPropertyType.type,typeResolver:r,exampleResolver:i,fileContainingRawTypeReference:u.file,fileContainingExample:n,workspace:a}),originalTypeDeclaration:u.typeName})}}return bhe.inlinedBody({jsonExample:i.resolveAllReferencesInExampleOrThrow({example:t,file:n}).resolvedExample,properties:o,extraProperties:void 0})}function oNM({body:e,file:t}){return typeof e=="string"?nz.reference({docs:void 0,bodyType:t.parseTypeReference(e)}):uNM(e)?nz.reference({docs:void 0,bodyType:t.parseTypeReference(e.type)}):nz.inlinedBody({name:t.casingsGenerator.generateName(e.name),extends:QFt(e.extends??[]).map(r=>wz({typeName:r,file:t})),properties:Object.entries(e.properties??{}).map(([r,i])=>({name:t.casingsGenerator.generateNameAndWireValue({name:Ez({propertyKey:r,property:i}).name,wireValue:r}),value:t.parseTypeReference(i),valueType:t.parseTypeReference(i),availability:void 0,docs:void 0}))})}function uNM(e){return e.type!=null}function sNM({channel:e,example:t,typeResolver:r,exampleResolver:i,variableResolver:n,file:a,workspace:o}){let c=[],f=({name:s,pathParameterDeclaration:u,examplePathParameter:l})=>{let p=xEa({parameter:u,variableResolver:n,file:a});return{name:s,value:Rv({example:l,rawTypeBeingExemplified:p.rawType,typeResolver:r,exampleResolver:i,fileContainingRawTypeReference:p.file,fileContainingExample:a,workspace:o})}};if(t["path-parameters"]!=null){let s=LFt(e);for(let[u,l]of Object.entries(t["path-parameters"])){let p=s[u];if(p!=null)c.push(f({name:a.casingsGenerator.generateName(u),pathParameterDeclaration:p,examplePathParameter:l}));else throw new Error(`Path parameter ${u} does not exist`)}}return{pathParameters:c}}function cNM({channel:e,example:t,typeResolver:r,exampleResolver:i,file:n,workspace:a}){let o=[];if(t.headers!=null)for(let[c,f]of Object.entries(t.headers)){let s=e.headers?.[c];s!=null&&o.push({name:n.casingsGenerator.generateNameAndWireValue({name:Y9t({headerKey:c,header:s}).name,wireValue:c}),value:Rv({example:f,rawTypeBeingExemplified:typeof s=="string"?s:s.type,typeResolver:r,exampleResolver:i,fileContainingRawTypeReference:n,fileContainingExample:n,workspace:a})})}return{headers:o}}function lNM({channel:e,example:t,pathParams:r}){let i=e.path;if(t["path-parameters"]!=null)for(let n of[...r.pathParameters])i=i.replaceAll(`{${n.name.originalName}}`,encodeURIComponent(`${n.value.jsonExample}`));return i}function fNM(e){return typeof e=="string"?!1:e.extends!=null||e.properties!=null}function dz_({errorName:e,errorDeclaration:t,file:r,typeResolver:i,exampleResolver:n,workspace:a}){let o=[];if(t.type!=null&&t.examples!=null)for(let c of t.examples)o.push({name:c.name!=null?r.casingsGenerator.generateName(c.name):void 0,docs:c.docs,jsonExample:n.resolveAllReferencesInExampleOrThrow({example:c.value,file:r}).resolvedExample,shape:Rv({example:c.value,rawTypeBeingExemplified:t.type,fileContainingRawTypeReference:r,fileContainingExample:r,typeResolver:i,exampleResolver:n,workspace:a})});return{name:l1i({errorName:e,file:r}),discriminantValue:r.casingsGenerator.generateNameAndWireValue({wireValue:e,name:e}),docs:typeof t!="string"?t.docs:void 0,statusCode:t["status-code"],isWildcardStatusCode:void 0,type:t.type!=null?r.parseTypeReference(t.type):void 0,examples:o,v2Examples:void 0,displayName:void 0,headers:[]}}var pz_="content";function _z_(e,t){if(e==null||e.strategy==="status-code")return yhe.statusCode();switch(e.strategy){case"property":return yhe.property({discriminant:t.casingsGenerator.generateNameAndWireValue({name:e["property-name"],wireValue:e["property-name"]}),contentProperty:t.casingsGenerator.generateNameAndWireValue({name:pz_,wireValue:pz_})});default:Ot(e)}}var E9o=ue(Sv(),1);function hz_({readme:e,services:t}){let r=new Fvc(t);return{apiName:e.apiName,disabledFeatures:e.disabledSections?.map(i=>i.toUpperCase()),apiReferenceLink:e.apiReferenceLink,bannerLink:e.bannerLink,introduction:e.introduction,customSections:e.customSections,exampleStyle:e.exampleStyle,whiteLabel:!1,defaultEndpoint:e.defaultEndpoint!=null?r.getEndpointForReadmeOrThrow(e.defaultEndpoint).id:void 0,features:e.features!=null?Object.fromEntries(Object.entries(e.features).map(([i,n])=>[i,n.map(a=>r.getEndpointForReadmeOrThrow(a).id)])):void 0}}var Fvc=class{endpoints={};constructor(t){this.endpoints=this.buildEndpoints(t)}getEndpointForReadme(t){let r=pNM({endpoint:t}),i=this.getEndpointKeyForReadmeEndpoint(r);return this.endpoints[i]}getEndpointForReadmeOrThrow(t){let r=this.getEndpointForReadme(t);if(r==null)throw new Error(`Endpoint not found for ${JSON.stringify(t)}`);return r}buildEndpoints(t){let r={};for(let i of Object.values(t))for(let n of i.endpoints)r[this.getEndpointKeyForHttpEndpoint(n)]=n;return r}getEndpointKeyForReadmeEndpoint(t){return this.getEndpointKey({method:t.method,path:t.path,stream:t.stream??!1})}getEndpointKeyForHttpEndpoint(t){return this.getEndpointKey({method:t.method,path:dNM(t),stream:t.response?.body?.type==="streaming"})}getEndpointKey({method:t,path:r,stream:i}){return`${t}|${r}|${i}`}};function dNM(e){let t="";e.fullPath.head.length>0&&(t=(0,E9o.default)(t,e.fullPath.head));for(let r of e.fullPath.parts)t=(0,E9o.default)(t,"{"+r.pathParameter+"}"),r.tail.length>0&&(t=(0,E9o.default)(t,r.tail));return t.startsWith("/")?t:`/${t}`}function pNM({endpoint:e}){if(typeof e=="string"){let t=e.split(" ");if(t.length!==2||t[0]==null||t[1]==null)throw new Error(`invalid endpoint string: ${e}`);return{method:t[0],path:t[1]}}return e}function yz_({webhooks:e,file:t,typeResolver:r,exampleResolver:i,workspace:n}){let a=[];for(let[o,c]of Object.entries(e))a.push({id:up.generateWebhookId(t.fernFilepath,o),availability:vK(c.availability),displayName:c["display-name"],docs:c.docs,method:c.method,name:t.casingsGenerator.generateName(o),headers:c.headers!=null?Object.entries(c.headers).map(([f,s])=>PPe({headerKey:f,header:s,file:t})):[],payload:_NM({payload:c.payload,file:t}),responses:bNM({webhook:c,file:t,typeResolver:r}),examples:c.examples!=null?yNM({webhook:c,examples:c.examples,file:t,typeResolver:r,exampleResolver:i,workspace:n}):void 0,v2Examples:void 0});return a}function _NM({payload:e,file:t}){return typeof e=="string"?LQ.reference({docs:void 0,payloadType:t.parseTypeReference(e)}):rQn(e)?LQ.reference({docs:void 0,payloadType:t.parseTypeReference(e.type)}):LQ.inlinedPayload({name:t.casingsGenerator.generateName(e.name),extends:QFt(e.extends).map(r=>wz({typeName:r,file:t})),properties:e.properties!=null?Object.entries(e.properties).map(([r,i])=>hNM({propertyKey:r,propertyDefinition:i,docs:typeof i!="string"?i.docs:void 0,availability:typeof i!="string"?vK(i.availability):void 0,file:t})):[]})}function hNM({propertyKey:e,propertyDefinition:t,docs:r,availability:i,file:n}){return{docs:r,availability:i,name:n.casingsGenerator.generateNameAndWireValue({wireValue:e,name:Ez({propertyKey:e,property:t}).name}),valueType:n.parseTypeReference(t)}}function yNM({webhook:e,examples:t,file:r,typeResolver:i,exampleResolver:n,workspace:a}){let o=typeof e.payload=="string"?e.payload:rQn(e.payload)?e.payload.type:void 0;if(o!=null)return t.map(c=>({docs:e.docs,name:c.name!=null?r.casingsGenerator.generateName(c.name):void 0,payload:Rv({example:c.payload,rawTypeBeingExemplified:o,fileContainingRawTypeReference:r,fileContainingExample:r,typeResolver:i,exampleResolver:n,workspace:a})}));if(!$c(e.payload))throw new Error(`Example webhook payload is not an object. Got: ${JSON.stringify(e.payload)}`);return t.map(c=>({docs:e.docs,name:c.name!=null?r.casingsGenerator.generateName(c.name):void 0,payload:Rv({example:c.payload,rawTypeBeingExemplified:"map<string, unknown>",fileContainingRawTypeReference:r,fileContainingExample:r,typeResolver:i,exampleResolver:n,workspace:a})}))}function bNM({webhook:e,file:t,typeResolver:r}){let i=[];if(e.response!=null){let n=vNM({response:e.response,file:t,typeResolver:r}),a=typeof e.response!="string"?e.response["status-code"]:void 0,o=typeof e.response!="string"?e.response.docs:void 0;i.push({body:n,statusCode:a,isWildcardStatusCode:void 0,docs:o})}if(e["response-stream"]!=null){let n=gNM({responseStream:e["response-stream"],file:t,typeResolver:r});if(n!=null){let a=typeof e["response-stream"]!="string"?e["response-stream"].docs:void 0;i.push({body:Xf.streaming(n),statusCode:void 0,isWildcardStatusCode:void 0,docs:a})}}return i.length>0?i:void 0}function vNM({response:e,file:t,typeResolver:r}){let i=typeof e!="string"?e.docs:void 0,n=typeof e=="string"?e:e.type;if(n!=null)return ZH(n)!=null?Xf.fileDownload({docs:i,v2Examples:void 0}):RKi(n)!=null?Xf.text({docs:i,v2Examples:void 0}):z0e(n)!=null?Xf.bytes({docs:i,v2Examples:void 0}):ONM(e,i,t,r)}function gNM({responseStream:e,file:t,typeResolver:r}){let i=typeof e!="string"?e.docs:void 0,n=typeof e=="string"?e:e.type,a=typeof e=="string"?"json":e.format??"json";return OCi(n)?AD.text({docs:i,v2Examples:void 0}):typeof e!="string"&&a==="sse"?AD.sse({docs:i,payload:t.parseTypeReference(n),terminator:typeof e!="string"?e.terminator:void 0,v2Examples:void 0}):AD.json({docs:i,payload:t.parseTypeReference(n),terminator:typeof e!="string"?e.terminator:void 0,v2Examples:void 0})}function ONM(e,t,r,i){let n=typeof e!="string"?e.type:e;if(n==null)return;let a=r.parseTypeReference(typeof e=="string"?e:{...e,type:n}),o=i.resolveTypeOrThrow({type:n,file:r}),c=typeof e!="string"?e.property:void 0;return c!=null?Xf.json(mB.nestedPropertyAsResponse({docs:t,responseBodyType:a,responseProperty:T$i({typeResolver:i,file:r,resolvedType:o,property:c}),v2Examples:void 0})):Xf.json(mB.response({docs:t,responseBodyType:a,v2Examples:void 0}))}function bz_({name:e,source:t}){return Dh.userDefined({file:v9o({source:t}),name:f1i.generateName(e)})}function vz_({encoding:e}){if(e.proto!=null&&e.proto.type!=null){let t=ANM({type:e.proto.type});if(t!=null)return t}}function ANM({type:e}){switch(e){case"google.protobuf.Any":return Dh.wellKnown(sn.any());case"google.protobuf.Api":return Dh.wellKnown(sn.api());case"google.protobuf.BoolValue":return Dh.wellKnown(sn.boolValue());case"google.protobuf.BytesValue":return Dh.wellKnown(sn.bytesValue());case"google.protobuf.DoubleValue":return Dh.wellKnown(sn.doubleValue());case"google.protobuf.Duration":return Dh.wellKnown(sn.duration());case"google.protobuf.Empty":return Dh.wellKnown(sn.empty());case"google.protobuf.Enum":return Dh.wellKnown(sn.enum());case"google.protobuf.EnumValue":return Dh.wellKnown(sn.enumValue());case"google.protobuf.Field":return Dh.wellKnown(sn.field());case"google.protobuf.FieldCardinality":return Dh.wellKnown(sn.fieldCardinality());case"google.protobuf.FieldKind":return Dh.wellKnown(sn.fieldKind());case"google.protobuf.FieldMask":return Dh.wellKnown(sn.fieldMask());case"google.protobuf.FloatVlaue":return Dh.wellKnown(sn.floatValue());case"google.protobuf.Int32Value":return Dh.wellKnown(sn.int32Value());case"google.protobuf.Int64Value":return Dh.wellKnown(sn.int64Value());case"google.protobuf.ListValue":return Dh.wellKnown(sn.listValue());case"google.protobuf.Method":return Dh.wellKnown(sn.method());case"google.protobuf.Mixin":return Dh.wellKnown(sn.mixin());case"google.protobuf.NullValue":return Dh.wellKnown(sn.nullValue());case"google.protobuf.Option":return Dh.wellKnown(sn.option());case"google.protobuf.SourceContext":return Dh.wellKnown(sn.sourceContext());case"google.protobuf.StringValue":return Dh.wellKnown(sn.stringValue());case"google.protobuf.Struct":return Dh.wellKnown(sn.struct());case"google.protobuf.Syntax":return Dh.wellKnown(sn.syntax());case"google.protobuf.Timestamp":return Dh.wellKnown(sn.timestamp());case"google.protobuf.Type":return Dh.wellKnown(sn.type());case"google.protobuf.Uint32Value":return Dh.wellKnown(sn.uint32Value());case"google.protobuf.Uint64Value":return Dh.wellKnown(sn.uint64Value());case"google.protobuf.Value":return Dh.wellKnown(sn.value())}}function gz_({generic:e,file:t,typeResolver:r}){let i=typeof e=="string"?e:e.type,n=xS(i);if(n==null)throw new Error(`Invalid generic type definition: ${i}`);let a=r.getDeclarationOfNamedTypeOrThrow({referenceToNamedType:i,file:t});if(n.arguments&&db(a.declaration)){let o=xS(a.typeName)?.arguments??[],c=Object.entries(a.declaration.properties??{}).map(([f,s])=>{let u=s;return typeof s=="string"&&o?.includes(s)&&(u=n.arguments?.[o.indexOf(s)]??s),[f,u]});return Yc.object({extends:QFt(a.declaration.extends).map(f=>wz({typeName:f,file:t})),properties:QEa({properties:Object.fromEntries(c)},t),extraProperties:a.declaration["extra-properties"]??!1,extendedProperties:void 0})}throw new Error(`Generic type definition not supported: ${i}`)}function Oz_({alias:e,file:t,typeResolver:r}){let i=typeof e=="string"?e:e.type;return R0e(i)?gz_({generic:i,file:t,typeResolver:r}):Yc.alias({aliasOf:t.parseTypeReference(e),resolvedType:mNM({aliasOf:i,file:t,typeResolver:r})})}function mNM({aliasOf:e,file:t,typeResolver:r}){let i=r.resolveTypeOrThrow({type:e,file:t});switch(i._type){case"primitive":return UQ.primitive(i.originalTypeReference.primitive);case"container":return UQ.container(i.originalTypeReference.container);case"unknown":return UQ.unknown();case"named":{let n=db(i.declaration)?rFt.Object:mCi(i.declaration)?rFt.Union:oFt(i.declaration)?rFt.Enum:XFn(i.declaration)?rFt.UndiscriminatedUnion:Ot(i.declaration);return UQ.named({name:i.name,shape:n})}}}function Az_({union:e,file:t}){let r=e.union.filter((i,n)=>{let a=typeof i=="string"?i:i.type;return e.union.findIndex(o=>(typeof o=="string"?o:o.type)===a)===n});return Yc.undiscriminatedUnion({members:r.map(i=>{let n=t.parseTypeReference(typeof i=="string"?i:i.type);return{type:n.type==="named"?{...n,displayName:typeof i=="string"?Lro(n.name.originalName):i["display-name"]??Lro(n.name.originalName)}:n,docs:typeof i=="string"?void 0:i.docs}})})}function mz_(e){let t=[];if(e.extends!=null){let r=typeof e.extends=="string"?[e.extends]:e.extends;t.push(...r)}return e.properties!=null&&t.push(...Object.values(e.properties).map(r=>typeof r=="string"?r:r.type)),t}function Uvc({typeDeclaration:e,file:t,typeResolver:r,seenTypeNames:i=new Qvc}){let n=EB(e,{alias:o=>{let c=typeof o=="string"?o:o.type,f=xS(c);if(f!=null){let s=new Set(f.arguments??[]),u=r.getDeclarationOfNamedTypeOrThrow({referenceToNamedType:c,file:t}),l=xS(u.typeName)?.arguments;if(db(u.declaration)){let p=mz_(u.declaration);l&&p.filter(_=>!l.includes(_)).forEach(_=>s.add(_))}return Array.from(s)}return[c]},object:o=>mz_(o),discriminatedUnion:o=>{let c=[];return o["base-properties"]!=null&&c.push(...Object.values(o["base-properties"]).map(f=>typeof f=="string"?f:f.type)),c.push(...Object.values(o.union).reduce((f,s)=>{let u=typeof s=="string"?s:s.type;return typeof u=="string"&&f.push(u),f},[])),c},undiscriminatedUnion:o=>Object.values(o.union).reduce((c,f)=>{let s=typeof f=="string"?f:f.type;return typeof s=="string"&&c.push(s),c},[]),enum:()=>[]}),a=[];for(let o of n){let c=wB({type:o,_default:void 0,validation:void 0,visitor:{primitive:()=>[],map:({keyType:f,valueType:s})=>[...f,...s],list:f=>f,optional:f=>f,nullable:f=>f,set:f=>f,named:f=>[f],literal:()=>[],unknown:()=>[]}});for(let f of c){let s=wz({typeName:f,file:t});if(!i.hasTypeNameBeenSeen(s)){i.addTypeName(s),a.push(s);let u=r.getDeclarationOfNamedTypeOrThrow({referenceToNamedType:f,file:t});if(R0e(u.typeName))continue;a.push(...Uvc({typeDeclaration:u.declaration,file:u.file,typeResolver:r,seenTypeNames:i}))}}}return a}var Qvc=class{cache=new Set;addTypeName(t){this.cache.add(this.computeCacheKey(t))}hasTypeNameBeenSeen(t){return this.cache.has(this.computeCacheKey(t))}computeCacheKey(t){return t.fernFilepath.allParts.map(r=>r.originalName).join("/")+":"+t.name.originalName}};function Pz_({typeName:e,typeDeclaration:t,file:r,typeResolver:i,exampleResolver:n,sourceResolver:a,workspace:o}){let c=l8(t),f=wz({typeName:e,file:r}),s=Uvc({typeDeclaration:t,file:r,typeResolver:i}),u={};db(t)&&(u=UKi(t.properties??{}));let l=jNM({file:r,typeDeclaration:t,typeName:e,sourceResolver:a});return{propertiesByAudience:u,typeDeclaration:{...c,inline:MNM(t),name:f,shape:PNM({typeDeclaration:t,file:r,typeResolver:i}),referencedTypes:new Set(s.map(p=>p.typeId)),encoding:wNM({typeDeclaration:t,source:l}),source:l,userProvidedExamples:typeof t!="string"&&t.examples!=null?t.examples.map(p=>({name:p.name!=null?r.casingsGenerator.generateName(p.name):void 0,docs:p.docs,jsonExample:n.resolveAllReferencesInExampleOrThrow({example:p.value,file:r}).resolvedExample,shape:Rvc({typeName:f,example:p.value,typeResolver:i,exampleResolver:n,typeDeclaration:t,fileContainingType:r,fileContainingExample:r,workspace:o})})):[],autogeneratedExamples:[],v2Examples:void 0},descendantFilepaths:new Set(s.map(p=>p.fernFilepath))}}function PNM({typeDeclaration:e,file:t,typeResolver:r}){return EB(e,{alias:i=>Oz_({alias:i,file:t,typeResolver:r}),object:i=>nR_({object:i,file:t}),discriminatedUnion:i=>gR_({union:i,file:t,typeResolver:r}),undiscriminatedUnion:i=>Az_({union:i,file:t}),enum:i=>Yc.enum(y9o({_enum:i,file:t}))})}function jNM({file:e,typeDeclaration:t,typeName:r,sourceResolver:i}){if(typeof t=="string"||t.source==null&&t.encoding==null)return;if(t.encoding!=null){let a=vz_({encoding:t.encoding});if(a!=null)return Ivi.proto(a)}if(t.source==null)return;let n=i.resolveSourceOrThrow({source:t.source,relativeFilepath:e.relativeFilepath});if(!(n==null||n.type!=="protobuf"))return Ivi.proto(bz_({source:n,name:r}))}function wNM({typeDeclaration:e,source:t}){return typeof e!="string"&&e.encoding!=null?ENM(e.encoding):SNM(t)}function ENM(e){return e.proto!=null?{json:void 0,proto:{}}:{json:{},proto:void 0}}function SNM(e){return e!=null&&e.type==="proto"?{json:void 0,proto:{}}:{json:{},proto:void 0}}function MNM(e){if(typeof e!="string"&&"inline"in e)return e.inline}function jz_(e,t){let r=t[e];if(r==null)throw new Chi(`Illegal Error: Failed to load type declaration for type ${e}`);return r}function wz_(e){e.types=Object.fromEntries(Object.entries(e.types).map(([t,r])=>[t,BNM({typeDeclaration:r,ir:e})])),e.services=Object.fromEntries(Object.entries(e.services).map(([t,r])=>[t,{...r,endpoints:r.endpoints.map(i=>DNM({endpoint:i,ir:e}))}]))}function DNM({endpoint:e,ir:t}){return e.requestBody?.type!=="inlinedRequestBody"?e:{...e,requestBody:{...e.requestBody,extendedProperties:e.requestBody.extends.flatMap(r=>Ez_(r,t))}}}function BNM({typeDeclaration:e,ir:t}){switch(e.shape.type){case"object":return{...e,shape:{...e.shape,extendedProperties:e.shape.extends.flatMap(r=>Ez_(r,t))}}}return e}function Ez_(e,t){let r=Lvc(e.typeId,t);return Sz_({objectTypeDeclaration:r,ir:t})}function Lvc(e,t){let r=jz_(e,t.types);switch(r.shape.type){case"object":return r.shape;case"alias":if(r.shape.resolvedType.type==="named")return Lvc(r.shape.resolvedType.name.typeId,t)}throw new Chi(`Unexpected error: ${e} is extended but has shape ${r.shape.type}`)}function Sz_({objectTypeDeclaration:e,ir:t}){let r=e.extends.flatMap(i=>{let n=Lvc(i.typeId,t);return Sz_({objectTypeDeclaration:n,ir:t})});return[...e.properties,...r]}var S9o=class{subpackages={};rootPackage={docs:void 0,fernFilepath:{allParts:[],packagePath:[],file:void 0},websocket:void 0,service:void 0,types:[],errors:[],subpackages:[],webhooks:void 0,navigationConfig:void 0};addPackageRedirection({from:t,to:r}){let i=this.getPackageForFernFilepath(t);if(i.navigationConfig!=null)throw new Error("Found duplicate navigationConfig for package");i.navigationConfig={pointsTo:up.generateSubpackageId(r)}}addDocs(t,r){let i=this.getPackageForFernFilepath(t);if(i.docs!=null)throw new Error("Found duplicate docs for package");i.docs=r}addSubpackage(t){this.getPackageForFernFilepath(t)}addType(t,r){this.getPackageForFernFilepath(r.name.fernFilepath).types.push(t)}addError(t,r){this.getPackageForFernFilepath(r.name.fernFilepath).errors.push(t)}addService(t,r){let i=this.getPackageForFernFilepath(r.name.fernFilepath);if(i.service!=null)throw new Error("Found duplicate service for "+t);i.service=t}addWebhookGroup(t,r){let i=this.getPackageForFernFilepath(r);if(i.webhooks!=null)throw new Error("Found duplicate webhook group for "+t);i.webhooks=t}addWebSocketChannel(t,r){let i=this.getPackageForFernFilepath(r);if(i.webhooks!=null)throw new Error("Found duplicate webhook group for "+t);i.websocket=t}build(t){t!=null&&(Object.entries(this.subpackages).forEach(([i,n])=>{t.hasSubpackageId(i)?this.subpackages[i]={...n,types:n.types.filter(a=>t.hasTypeId(a)),errors:n.errors.filter(a=>t.hasErrorId(a)),service:n.service!=null&&t.hasServiceId(n.service)?n.service:void 0,websocket:n.websocket!=null&&t.hasChannel(n.websocket)?n.websocket:void 0,subpackages:n.subpackages.filter(a=>t.hasSubpackageId(a))}:delete this.subpackages[i]}),this.rootPackage={...this.rootPackage,types:this.rootPackage.types.filter(i=>t.hasTypeId(i)),errors:this.rootPackage.errors.filter(i=>t.hasErrorId(i)),service:this.rootPackage.service!=null&&t.hasServiceId(this.rootPackage.service)?this.rootPackage.service:void 0,subpackages:this.rootPackage.subpackages.filter(i=>t.hasSubpackageId(i)),webhooks:this.rootPackage.webhooks!=null?this.rootPackage.webhooks:void 0});let r=new Set(this.getAllChildrenWithEndpoints(this.rootPackage));return{subpackages:_n(this.subpackages,(i,n)=>({...i,hasEndpointsInTree:r.has(n)})),rootPackage:{...this.rootPackage,hasEndpointsInTree:r.size>0||this.rootPackage.service!=null}}}sortRootPackage(t){if(!Mz_(this.rootPackage.subpackages,t))throw new Error("Sorted subpackages differ from unsorted packages in root");this.rootPackage.subpackages=t}sortSubpackage(t,r){let i=this.subpackages[t];if(i==null)throw new Error("Subpackage does not exist: "+t);if(!Mz_(i.subpackages,r))throw new Error("Sorted subpackages differ from unsorted packages");i.subpackages=r}getAllSubpackagesWithEndpoints(t){let r=this.subpackages[t];if(r==null)throw new Error("Subpackage does not exist: "+t);let i=this.getAllChildrenWithEndpoints(r);return(i.length>0||r.service!=null)&&i.push(t),i}getAllChildrenWithEndpoints(t){return t.subpackages.flatMap(r=>[...this.getAllSubpackagesWithEndpoints(r)])}getPackageForFernFilepath(t,r=0,i=this.rootPackage){let n=t.allParts[r];if(n==null)return i;let a=i.subpackages.map(s=>{let u=this.subpackages[s];if(u==null)throw new Error("Subpackage ID is invalid: "+s);return u}),o=r+1,c={allParts:t.allParts.slice(0,o),packagePath:t.packagePath.slice(0,o),file:o===t.allParts.length?t.file:void 0},f=a.find(s=>s.name.originalName===n.originalName);if(f==null){let s=up.generateSubpackageId(c),u={docs:void 0,fernFilepath:c,name:n,displayName:void 0,service:void 0,types:[],errors:[],subpackages:[],navigationConfig:void 0,webhooks:void 0,websocket:void 0};this.subpackages[s]=u,i.subpackages.push(s),f=u}return this.getPackageForFernFilepath(t,o,f)}};function Mz_(e,t){if(e.length!==t.length)return!1;let r=new Set(e);for(let i of t)if(!r.has(i))return!1;return!0}function Dz_({reference:e,referencedIn:t,imports:r}){let[i,n,...a]=e.split(".");if(i==null||a.length>0)return;if(n==null)return{endpointName:i,relativeFilepath:t};let c=r[i];if(c!=null)return{endpointName:n,relativeFilepath:c1i({referencedIn:t,importPath:c})}}var N$i=class{workspace;constructor(t){this.workspace=t}resolveEndpointOrThrow({endpoint:t,file:r}){let i=this.resolveEndpoint({endpoint:t,file:r});if(i==null)throw new Error("Cannot resolve endpoint: "+t+" in file "+r.relativeFilepath);return i}resolveEndpointByMethodAndPath({method:t,path:r}){let i;return zB(this.workspace,(n,a,o)=>{let c=nf({relativeFilepath:n,definitionFile:a,casingsGenerator:f1i,rootApiFile:this.workspace.definition.rootApiFile.contents,defaultUrl:o.defaultUrl});for(let[f,s]of Object.entries(a.service?.endpoints??{}))s.method===t&&s.path===r&&(i={endpointId:f,endpoint:s,file:c})}),o$i(this.workspace,(n,a)=>{let o=nf({relativeFilepath:n,definitionFile:a,casingsGenerator:f1i,rootApiFile:this.workspace.definition.rootApiFile.contents});for(let[c,f]of Object.entries(a.service?.endpoints??{}))f.method===t&&f.path===r&&(i={endpointId:c,endpoint:f,file:o})}),i}resolveEndpoint({endpoint:t,file:r}){let n=new CKi().tryParse(t);if(n!=null)return this.resolveEndpointByMethodAndPath(n);let a=this.getDeclarationOfEndpoint({referenceToEndpoint:t,file:r});if(a==null)return;let o=a.file.definitionFile.service?.endpoints?.[a.endpointName];if(o!=null)return{endpointId:a.endpointName,endpoint:o,file:a.file}}getDeclarationOfEndpoint({referenceToEndpoint:t,file:r}){let i=Dz_({reference:t,referencedIn:r.relativeFilepath,imports:r.imports});if(i==null)return;let n=uPe(this.workspace,i.relativeFilepath);if(!(n==null||n.service?.endpoints?.[i.endpointName]==null))return{endpointName:i.endpointName,file:nf({relativeFilepath:i.relativeFilepath,definitionFile:n,casingsGenerator:r.casingsGenerator,rootApiFile:this.workspace.definition.rootApiFile.contents})}}};var F$i=class{workspace;constructor(t){this.workspace=t}getDeclarationOrThrow(t,r){let i=this.getDeclaration(t,r);if(i==null)throw new Error("Error does not exist: "+t);return i}getDeclaration(t,r){let i=Ghe({reference:t,referencedIn:r.relativeFilepath,imports:r.imports});if(i==null)return;let n=uPe(this.workspace,i.relativeFilepath);if(n==null)return;let a=n.errors?.[i.typeName];if(a!=null)return{declaration:a,file:nf({definitionFile:n,relativeFilepath:i.relativeFilepath,casingsGenerator:r.casingsGenerator,rootApiFile:this.workspace.definition.rootApiFile.contents})}}};var Jhe=class{typeResolver;constructor(t){this.typeResolver=t}resolveAllReferencesInExample({example:t,file:r}){if(typeof t=="string"){let i=this.resolveExample({example:t,file:r});return i==null?i:typeof i.resolvedExample=="string"?(i.resolvedExample.startsWith(`\\${"$"}`)&&(i.resolvedExample=i.resolvedExample.slice(1)),i):this.resolveAllReferencesInExample({example:i.resolvedExample,file:i.file})}else if($c(t)){let i={};for(let[n,a]of Object.entries(t)){let o=this.resolveAllReferencesInExample({example:a,file:r});if(o==null)return;i[n]=o.resolvedExample}return{resolvedExample:i}}else if(Array.isArray(t)){let i=[];for(let n of t){let a=this.resolveAllReferencesInExample({example:n,file:r});if(a==null)return;i.push(a.resolvedExample)}return{resolvedExample:i}}return{resolvedExample:t}}resolveAllReferencesInExampleOrThrow({example:t,file:r}){let i=this.resolveAllReferencesInExample({example:t,file:r});if(i==null)throw new Error("Failed to resolve examples");return i}resolveExample({example:t,file:r}){return typeof t!="string"?{resolvedExample:t,file:r}:t.startsWith("$")?this.resolveExampleReference(t,r):{resolvedExample:t,file:r}}resolveExampleReference(t,r){let i=this.parseExampleReference(t);if(i==null)return;let n=this.typeResolver.getDeclarationOfNamedType({referenceToNamedType:i.rawTypeReference,file:r});if(n==null||typeof n.declaration=="string"||n.declaration.examples==null)return;let a=n.declaration.examples.find(o=>o.name===i.exampleName);if(a!=null)return this.resolveExample({example:a.value,file:n.file})}resolveExampleOrThrow({example:t,file:r}){let i=this.resolveExample({example:t,file:r});if(i==null)throw new Error("Cannot resolve example: "+t);return i}parseExampleReference(t){let[r,i,n,...a]=t.split(".");if(!(r==null||i==null||a.length>0))return n==null?{rawTypeReference:r.slice("$".length),exampleName:i}:{rawTypeReference:`${r}.${i}`.slice("$".length),exampleName:n}}};var M9o=class{typeResolver;endpointResolver;constructor(t,r){this.typeResolver=t,this.endpointResolver=r,this.typeResolver=t,this.endpointResolver=r}resolveRequestPropertyOrThrow({file:t,endpoint:r,propertyComponents:i}){let n=this.resolveRequestProperty({file:t,endpoint:r,propertyComponents:i});if(n==null)throw new Error("Cannot resolve request property from endpoint: "+r+" in file "+t.relativeFilepath);return n}resolveRequestProperty({file:t,endpoint:r,propertyComponents:i}){let n=this.endpointResolver.resolveEndpointOrThrow({endpoint:r,file:t});if(n.endpoint.request==null)return;if(typeof n.endpoint.request!="string")return this.resolveRequestPropertyFromInlinedRequest({typeResolver:this.typeResolver,file:n.file,requestType:n.endpoint.request,propertyComponents:i});let a=this.typeResolver.resolveTypeOrThrow({type:n.endpoint.request,file:n.file}),o=this.resolveObjectProperty({file:n.file,resolvedType:a,propertyComponents:i});if(o!=null)return{propertyPath:this.propertyPathFromPropertyComponents({propertyComponents:i,file:t,resolvedType:a}),property:$H.body(o)}}resolveResponsePropertyOrThrow({file:t,endpoint:r,propertyComponents:i}){let n=this.resolveResponseProperty({file:t,endpoint:r,propertyComponents:i});if(n==null)throw new Error("Cannot resolve response property from endpoint: "+r+" in file "+t.relativeFilepath);return n}resolveResponseProperty({file:t,endpoint:r,propertyComponents:i}){let n=this.endpointResolver.resolveEndpointOrThrow({endpoint:r,file:t}),a=this.typeResolver.resolveTypeOrThrow({type:(typeof n.endpoint.response!="string"?n.endpoint.response?.type:n.endpoint.response)??"",file:n.file}),o=this.resolveObjectProperty({file:n.file,resolvedType:a,propertyComponents:i});if(o!=null)return{propertyPath:this.propertyPathFromPropertyComponents({propertyComponents:i,resolvedType:a,file:t}),property:o}}resolveRequestPropertyFromInlinedRequest({typeResolver:t,file:r,requestType:i,propertyComponents:n}){if(n.length===1){let a=n[0]??"",o=i["query-parameters"]?.[a]??void 0;if(o!=null)return{property:$H.query(b9o({file:r,queryParameterKey:a,queryParameter:o})),propertyPath:void 0}}return this.resolveRequestPropertyFromInlinedRequestBody({typeResolver:t,file:r,requestType:i,propertyComponents:n})}resolveRequestPropertyFromInlinedRequestBody({typeResolver:t,file:r,requestType:i,propertyComponents:n}){if(i.body==null)return;if(typeof i.body=="string"){let c=t.resolveTypeOrThrow({type:i.body,file:r}),f=this.resolveObjectProperty({file:r,resolvedType:c,propertyComponents:n});return f==null?void 0:{propertyPath:this.propertyPathFromPropertyComponents({propertyComponents:n,file:r,resolvedType:c}),property:$H.body(f)}}if(HP(i.body)){let c=f9o({typeResolver:t,file:r,objectSchema:i.body,propertyComponents:n});return c==null?void 0:{propertyPath:this.propertyPathFromPropertyComponentsFromInlineRequestBody({propertyComponents:n,file:r,body:i.body}),property:$H.body(c)}}let a=t.resolveTypeOrThrow({type:i.body.type,file:r}),o=l9o({typeResolver:t,file:SLn(a)??r,resolvedType:a,propertyComponents:n});if(o!=null)return{propertyPath:this.propertyPathFromPropertyComponents({propertyComponents:n,file:r,resolvedType:a}),property:$H.body(o)}}resolveObjectProperty({file:t,resolvedType:r,propertyComponents:i}){return l9o({typeResolver:this.typeResolver,file:SLn(r)??t,resolvedType:r,propertyComponents:i})}propertyPathFromPropertyComponents({propertyComponents:t,file:r,resolvedType:i}){if(t.length<=1)return[];let n=Q$i(i),a=i,o=[],c=[];for(let f of t.slice(0,-1))c.push(f),a=INM({typeResolver:this.typeResolver,file:r,resolvedType:a,propertyName:f,breadcrumbs:c,rootTypeTitle:n}),o.push({name:r.casingsGenerator.generateName(f),type:a.originalTypeReference});return o}propertyPathFromPropertyComponentsFromInlineRequestBody({propertyComponents:t,file:r,body:i}){if(t.length<=1)return[];let n=[],a=[];for(let o of t.slice(0,-1)){a.push(o);let c=f9o({typeResolver:this.typeResolver,file:r,objectSchema:i,propertyComponents:a});if(!c)throw new Error(`Cannot find property '${a.join(".")}' in inline request body in file ${r.relativeFilepath}`);n.push({name:r.casingsGenerator.generateName(o),type:c.valueType})}return n}};function INM({typeResolver:e,file:t,resolvedType:r,propertyName:i,breadcrumbs:n,rootTypeTitle:a}){let o=TLn({typeResolver:e,file:t,resolvedType:r,propertyName:i});if(!o)throw new Error(`Cannot find property '${n.join(".")}' in ${a}`);return o}function TLn({typeResolver:e,file:t,resolvedType:r,propertyName:i}){switch(r._type){case"container":switch(r.container._type){case"list":return;case"literal":return;case"map":return;case"nullable":{let n=TLn({typeResolver:e,file:t,resolvedType:r.container.itemType,propertyName:i});return n||void 0}case"optional":{let n=TLn({typeResolver:e,file:t,resolvedType:r.container.itemType,propertyName:i});return n||void 0}case"set":return;default:Ot(r.container)}break;case"primitive":return;case"unknown":return;case"named":{let n=r.declaration;if("properties"in n&&n.properties!=null){for(let[a,o]of Object.entries(n.properties))if(a===i)return e.resolveTypeOrThrow({type:typeof o=="string"?o:o.type,file:r.file})}if("base-properties"in n&&n["base-properties"]!=null){for(let[a,o]of Object.entries(n["base-properties"]))if(a===i)return e.resolveTypeOrThrow({type:typeof o=="string"?o:o.type,file:r.file})}if("extends"in n&&n.extends!=null){let a=Array.isArray(n.extends)?n.extends:[n.extends];for(let o of a){let c=e.resolveTypeOrThrow({type:o,file:r.file}),f=TLn({file:"file"in c?c.file:t,typeResolver:e,resolvedType:c,propertyName:i});if(f)return f}}if("union"in n&&n.union!=null)if(Array.isArray(n.union))for(let a of n.union){let o=e.resolveTypeOrThrow({type:typeof a=="string"?a:a.type,file:r.file}),c=TLn({file:"file"in o?o.file:t,typeResolver:e,resolvedType:o,propertyName:i});if(c)return c}else for(let[,a]of Object.entries(n.union)){let o=typeof a=="string"?a:a.type;if(!o)continue;let c=e.resolveTypeOrThrow({type:o,file:r.file}),f=TLn({file:"file"in c?c.file:t,typeResolver:e,resolvedType:c,propertyName:i});if(f)return f}return}default:Ot(r)}}function Q$i(e){switch(e._type){case"container":switch(e.container._type){case"list":return`list<${Q$i(e.container.itemType)}>}`;case"literal":return`literal<${e.container.literal._visit({boolean:t=>t.toString(),string:t=>t,_other:t=>t.type})}>`;case"map":return`map<${Q$i(e.container.keyType)}, ${Q$i(e.container.valueType)}>}`;case"nullable":return`nullable<${Q$i(e.container.itemType)}>}`;case"optional":return`optional<${Q$i(e.container.itemType)}>}`;case"set":return`set<${Q$i(e.container.itemType)}>}`;default:Ot(e.container)}break;case"named":return e.name.name.originalName;case"primitive":return e.primitive.v1;case"unknown":return"unknown";default:Ot(e)}}var pb=class{workspace;constructor(t){this.workspace=t}resolveTypeOrThrow({type:t,file:r}){let i=this.resolveType({type:t,file:r});if(i==null)throw new Error("Cannot resolve type: "+t+" in file "+r.relativeFilepath);return i}getDeclarationOfNamedTypeOrThrow({referenceToNamedType:t,file:r}){let i=this.getDeclarationOfNamedType({referenceToNamedType:t,file:r});if(i==null)throw new Error("Cannot find declaration of type: "+t+" in file "+r.relativeFilepath);return i}getDeclarationOfNamedType({referenceToNamedType:t,file:r}){let i=Ghe({reference:t,referencedIn:r.relativeFilepath,imports:r.imports});if(i==null)return;let n=uPe(this.workspace,i.relativeFilepath);if(n==null)return;let a=n.types?.[i.typeName];if(a==null){let o=xS(i.typeName);if(o!=null){for(let c of Object.keys(n.types??{})??[])if(o.name&&c.startsWith(o.name)&&c.endsWith(">")){let f=n.types?.[c];return f!=null?{typeName:c,declaration:f,file:nf({relativeFilepath:i.relativeFilepath,definitionFile:n,casingsGenerator:r.casingsGenerator,rootApiFile:this.workspace.definition.rootApiFile.contents})}:void 0}}return}return{typeName:i.typeName,declaration:a,file:nf({relativeFilepath:i.relativeFilepath,definitionFile:n,casingsGenerator:r.casingsGenerator,rootApiFile:this.workspace.definition.rootApiFile.contents})}}resolveType({type:t,file:r,objectPath:i=[]}){return wB({type:t,_default:void 0,validation:void 0,visitor:{primitive:n=>({_type:"primitive",primitive:n,originalTypeReference:ii.primitive(n)}),unknown:()=>({_type:"unknown",originalTypeReference:ii.unknown()}),map:({keyType:n,valueType:a})=>n!=null&&a!=null?{_type:"container",container:{_type:"map",keyType:n,valueType:a},originalTypeReference:ii.container(ns.map({keyType:n.originalTypeReference,valueType:a.originalTypeReference}))}:void 0,list:n=>n!=null?{_type:"container",container:{_type:"list",itemType:n},originalTypeReference:ii.container(ns.list(n.originalTypeReference))}:void 0,optional:n=>n!=null?{_type:"container",container:{_type:"optional",itemType:n},originalTypeReference:ii.container(ns.optional(n.originalTypeReference))}:void 0,nullable:n=>n!=null?{_type:"container",container:{_type:"nullable",itemType:n},originalTypeReference:ii.container(ns.nullable(n.originalTypeReference))}:void 0,set:n=>n!=null?{_type:"container",container:{_type:"set",itemType:n},originalTypeReference:ii.container(ns.set(n.originalTypeReference))}:void 0,literal:n=>({_type:"container",container:{_type:"literal",literal:n},originalTypeReference:ii.container(ns.literal(n))}),named:n=>{let a=this.getDeclarationOfNamedType({referenceToNamedType:n,file:r});if(a==null)return;let o={typeName:a.typeName,file:a.file.relativeFilepath,reference:n};if(!i.some(c=>c.file===o.file&&c.typeName===o.typeName))return this.resolveNamedTypeFromDeclaration({referenceToNamedType:n,referencedIn:r,rawDeclaration:a,objectPath:[...i,o]})}}})}resolveNamedTypeOrThrow({referenceToNamedType:t,file:r}){let i=this.resolveNamedType({referenceToNamedType:t,file:r});if(i==null)throw new Error("Cannot resolve type: "+t);return i}resolveNamedType({referenceToNamedType:t,file:r}){let i=this.getDeclarationOfNamedType({referenceToNamedType:t,file:r});if(i!=null)return this.resolveNamedTypeFromDeclaration({referenceToNamedType:t,referencedIn:r,rawDeclaration:i})}resolveNamedTypeFromDeclaration({referenceToNamedType:t,referencedIn:r,rawDeclaration:i,objectPath:n=[]}){let{declaration:a,file:o}=i;if(ACi(a))return this.resolveType({type:typeof a=="string"?a:a.type,file:o,objectPath:n});let c=LEa({type:t,_default:void 0,validation:void 0,file:r});if(!(c.type!=="named"||uPe(this.workspace,o.relativeFilepath)==null))return{_type:"named",rawName:i.typeName,name:c,declaration:a,filepath:o.relativeFilepath,objectPath:n,originalTypeReference:c,file:o}}};var VFt=class e{static VARIABLE_PREFIX="$";getDeclarationOrThrow(t,r){let i=this.getDeclaration(t,r);if(i==null)throw new Error("Variable does not exist: "+t);return i}getDeclaration(t,r){if(!t.startsWith(e.VARIABLE_PREFIX))return;let i=r.rootApiFile.variables?.[t.substring(1)];if(i!=null)return{declaration:i,file:Fgi({casingsGenerator:r.casingsGenerator,rootApiFile:r.rootApiFile})}}getVariableIdOrThrow(t){let r=this.getVariableId(t);if(r==null)throw new Error("Variable reference does not start with "+e.VARIABLE_PREFIX);return r}getVariableId(t){if(t.startsWith(e.VARIABLE_PREFIX))return t.substring(e.VARIABLE_PREFIX.length)}};function D9o(e,t){if(t){for(let[r,i]of Object.entries(t))if(typeof i!="string"&&r===e)return i.audiences}}var Bz_={pathParameterOrder:hn.PathParameterOrder.UrlOrder};function Iz_({workspace:e}){let t=e.generatorsConfiguration?.api?.settings,r={...Bz_};for(let i of Object.keys(Bz_)){let n=t?.[i];n!==void 0&&(r[i]=n)}return r}function kw({workspace:e,generationLanguage:t,keywords:r,smartCasing:i,exampleGeneration:n,audiences:a,readme:o,packageName:c,version:f,fdrApiDefinitionId:s,sourceResolver:u,disableDynamicExamples:l,dynamicGeneratorConfig:p,generationMetadata:_}){let h=Iz_({workspace:e}),y=hx({generationLanguage:t,keywords:r,smartCasing:i}),b=new LKi(a),v=Fgi({casingsGenerator:y,rootApiFile:e.definition.rootApiFile.contents}),O=(e.definition.rootApiFile.contents.errors??[]).map(ne=>({error:l1i({errorName:ne,file:v}),docs:void 0})),A=new pb(e),g=new N$i(e),m=new M9o(A,g),j=new F$i(e),M=new Jhe(A),E=new VFt,B=rPa({casingsGenerator:y,rawApiFileSchema:e.definition.rootApiFile.contents})?.environmentsConfig,F={selfHosted:!1,fdrApiDefinitionId:s,apiVersion:lz_({file:v,rawApiFileSchema:e.definition.rootApiFile.contents}),apiName:y.generateName(e.definition.rootApiFile.contents.name),apiDisplayName:e.definition.rootApiFile.contents["display-name"],apiDocs:FEa(e.definition.rootApiFile.contents.docs),auth:cz_({rawApiFileSchema:e.definition.rootApiFile.contents,file:v,propertyResolver:m,endpointResolver:g}),headers:e.definition.rootApiFile.contents.headers!=null?Object.entries(e.definition.rootApiFile.contents.headers).map(([ne,Je])=>PPe({headerKey:ne,header:Je,file:v})):[],idempotencyHeaders:e.definition.rootApiFile.contents["idempotency-headers"]!=null?Object.entries(e.definition.rootApiFile.contents["idempotency-headers"]).map(([ne,Je])=>PPe({headerKey:ne,header:Je,file:v})):[],types:{},errors:{},services:{},constants:ZR_(y),environments:B,errorDiscriminationStrategy:_z_(e.definition.rootApiFile.contents["error-discrimination"],v),basePath:e.definition.rootApiFile.contents["base-path"]!=null?PD(e.definition.rootApiFile.contents["base-path"]):void 0,pathParameters:qLn({pathParameters:e.definition.rootApiFile.contents["path-parameters"],file:v,location:j0e.Root,variableResolver:E}),variables:e.definition.rootApiFile.contents.variables!=null?Object.entries(e.definition.rootApiFile.contents.variables).map(([ne,Je])=>({docs:typeof Je!="string"?Je.docs:void 0,id:ne,name:v.casingsGenerator.generateName(ne),type:v.parseTypeReference(Je)})):[],serviceTypeReferenceInfo:{typesReferencedOnlyByService:{},sharedTypes:[]},webhookGroups:{},websocketChannels:{},readmeConfig:void 0,sourceConfig:void 0,publishConfig:void 0,dynamic:void 0,audiences:e.definition.rootApiFile.contents.audiences,generationMetadata:_,apiPlayground:!0},N=new S9o,R=ne=>{N.addSubpackage(ne.fernFilepath),uy(ne.definitionFile,{imports:Mt,docs:Je=>{Je!=null&&N.addDocs(ne.fernFilepath,Je)},types:Je=>{if(Je!=null)for(let[et,Dr]of Object.entries(Je)){if(R0e(et))continue;let Lt=Pz_({typeName:et,typeDeclaration:Dr,file:ne,typeResolver:A,exampleResolver:M,sourceResolver:u,workspace:e}),zt=Lt.typeDeclaration;n.disabled&&(zt.userProvidedExamples=[],zt.autogeneratedExamples=[]);let Qt=Lt.descendantFilepaths,Ht=up.generateTypeId(zt.name);F.types[Ht]=zt,N.addType(Ht,zt),b.addType({declaredTypeName:zt.name,descendantTypeIds:zt.referencedTypes,descendantTypeIdsByAudience:{},propertiesByAudience:Lt.propertiesByAudience,descendantFilepaths:Qt}),b.markTypeForAudiences(zt.name,iR_(Dr))}},errors:Je=>{if(Je==null)return;if(e.definition.rootApiFile.contents["error-discrimination"]==null)throw new Error("error-discrimination is missing in api.yml but there are declared errors.");for(let[Dr,Lt]of Object.entries(Je)){let zt=dz_({errorName:Dr,errorDeclaration:Lt,file:ne,typeResolver:A,exampleResolver:M,workspace:e}),Qt=up.generateErrorId(zt.name);F.errors[Qt]=zt,N.addError(Qt,zt),b.addError(zt)}},service:Je=>{if(Je==null)return;let et=YR_({rootDefaultUrl:ne.defaultUrl??e.definition.rootApiFile.contents["default-url"],rootPathParameters:F.pathParameters,serviceDefinition:Je,file:ne,errorResolver:j,typeResolver:A,propertyResolver:m,exampleResolver:M,sourceResolver:u,globalErrors:O,variableResolver:E,workspace:e,auth:F.auth,irSettings:h}),Dr=up.generateServiceId(et.name);F.services[Dr]=et,N.addService(Dr,et);let Lt={};et.endpoints.forEach(zt=>{n.disabled&&(zt.autogeneratedExamples=[],zt.userSpecifiedExamples=[]);let Qt=Je.endpoints[zt.name.originalName];b.addEndpoint(et,zt,Qt),Lt[zt.name.originalName]=zt}),Je.audiences!=null&&b.markEndpointForAudience(et.name,et.endpoints,Je.audiences),Object.entries(Je.endpoints).map(([zt,Qt])=>{let Ht=Lt[zt];Ht!=null&&Qt.audiences!=null&&b.markEndpointForAudience(et.name,[Ht],Qt.audiences)})},webhooks:Je=>{if(Je==null)return;let et=up.generateWebhookGroupId(ne.fernFilepath),Dr=yz_({webhooks:Je,file:ne,typeResolver:A,exampleResolver:M,workspace:e}),Lt={};for(let zt of Dr)Lt[zt.name.originalName]=zt;Object.entries(Je).forEach(([zt,Qt])=>{let Ht=Lt[zt];Ht!=null&&(b.addWebhook(ne.fernFilepath,Ht,Qt),Qt.audiences!=null&&b.markWebhookForAudiences(ne.fernFilepath,Ht,Qt.audiences))}),F.webhookGroups[et]=Dr,N.addWebhookGroup(et,ne.fernFilepath)},channel:Je=>{if(Je==null)return;let et=up.generateWebSocketChannelId(ne.fernFilepath),Dr=fz_({channel:Je,file:ne,variableResolver:E,typeResolver:A,exampleResolver:M,workspace:e});b.addChannel(ne.fernFilepath,et,Dr,Je),Je.audiences!=null&&b.markChannelForAudiences(ne.fernFilepath,et,Je.audiences),F.websocketChannels!=null&&(F.websocketChannels[et]=Dr,N.addWebSocketChannel(et,ne.fernFilepath))}})};zB(e,(ne,Je,et)=>{R(nf({relativeFilepath:ne,definitionFile:Je,casingsGenerator:y,rootApiFile:e.definition.rootApiFile.contents,defaultUrl:et.defaultUrl}))}),o$i(e,(ne,Je)=>{if(Je.navigation!=null)if(typeof Je.navigation=="string")N.addPackageRedirection({from:bK({relativeFilepath:ne,casingsGenerator:y}),to:bK({relativeFilepath:tD(_Ae(ne),Tu.of(Je.navigation)),casingsGenerator:y})});else{let et=Je.navigation.map(Dr=>up.generateSubpackageId(bK({relativeFilepath:tD(_Ae(ne),Tu.of(Dr)),casingsGenerator:y})));ne===nb?N.sortRootPackage(et):N.sortSubpackage(up.generateSubpackageId(bK({relativeFilepath:ne,casingsGenerator:y})),et)}}),F.serviceTypeReferenceInfo=qNM(b),wz_(F);let z=n.disabled?F:nPa({ir:F,exampleGeneration:n}),U=e.definition.rootApiFile.contents,W=B?.environments._visit({singleBaseUrl:ne=>ne.environments.filter(Je=>D9o(Je.id,U.environments)!=null).length===0,multipleBaseUrls:ne=>ne.environments.filter(Je=>D9o(Je.id,U.environments)!=null).length===0,_other:()=>!1});B?.environments.environments.forEach(ne=>{b.markEnvironmentForAudiences(ne,D9o(ne.id,U.environments)??[],W)});let K=b.hasNoAudiences()?void 0:b.build(),fe=Hac(z,K),pe=e.definition.rootApiFile.contents.auth!=null&&Object.values(fe.services).every(ne=>ne.endpoints.every(Je=>Je.auth)),L=Object.values(fe.services).some(ne=>ne.endpoints.some(Je=>Je.response?.body?.type==="streaming")),G=Object.values(fe.services).some(ne=>ne.endpoints.some(Je=>Je.pagination!=null)),Re=Object.values(fe.services).some(ne=>ne.endpoints.some(Je=>Je.response?.body?.type==="fileDownload")),le={isAuthMandatory:pe,hasStreamingEndpoints:L,hasPaginatedEndpoints:G,hasFileDownloadEndpoints:Re,platformHeaders:{language:"X-Fern-Language",sdkName:"X-Fern-SDK-Name",sdkVersion:"X-Fern-SDK-Version",userAgent:f!=null&&c!=null?{header:"User-Agent",value:`${c}/${f}`}:void 0}},De=o??e.generatorsConfiguration?.rawConfiguration.readme,Ke=De!=null?hz_({readme:De,services:F.services}):void 0,se=CNM({...fe,...N.build(K),sdkConfig:le,readmeConfig:Ke});return{...se,dynamic:GEa({ir:se,generatorConfig:p,disableExamples:l,generationLanguage:t,smartCasing:i})}}function CNM(e){let t=r=>{if(!r||typeof r!="object")return r;if(Array.isArray(r))return r.map(t);for(let i in r){let n=r[i];i==="docs"&&typeof n=="string"?r[i]=FEa(n):n&&typeof n=="object"&&t(n)}return r};return t(e)}function qNM(e){let t={},r=[],i=e.getTypesReferencedByService();for(let[n,a]of Object.entries(i)){if(a.size===1){let o=a.values().next().value;if(o==null)break;t[o]===void 0&&(t[o]=[]),t[o]?.push(n);continue}r.push(n)}return{typesReferencedOnlyByService:t,sharedTypes:r}}var _N_=ue(tco(),1),hN_=ue(rco(),1),V9o=require("fs/promises"),yN_=ue(Q_e(),1);function Cz_(e){throw new Error("Unexpected value: "+JSON.stringify(e))}var Tz_=ue(fda(),1);var qz_=["PII","PHI","PCI","GDPR","CCPA","HIPAA","COPPA","FERPA","GLBA","SOX","FISMA","NIST","CIS","ISO","IEC","ITAR","EAR","CMMC","CUI","CDI","FTC","FCC","SEC","FINRA","XSS","CSRF","SSRF","XSRF","TLS","SSL","SSH","API","OAuth","OAuth1","OAuth1.0","OAuth2","OAuth2.0","SAML","OpenID","OpenID Connect","CAPTCHA","reCAPTCHA","2FA","MFA","OTP","TOTP","HOTP","U2F","FIDO","FIDO2","PKI","HMAC","AES","RSA","SHA","MD5","BCrypt","PBKDF2","Argon2","SCrypt","JWT","JWE","JWS","JWK","JWA","JOSE","SKU","SKUs","UPC","EAN","ISBN","ASIN","MPN","MSRP","MAP","RRP","MSRP","AM","PM","UTC","GMT","PST","PDT","EST","EDT","CST","CDT","MST","MDT","USA","UK","EU","UAE","APAC","EMEA","LATAM","ANZ","SEA","MEA","MENA","NATO","NA","SA","CA","EU","AU","NZ","JP","KR","CN","HK","TW","SG","MY","TH","ID","PH","VN","IN","PK","BD","LK","NP","MM","KH","LA","MM","BT","MV","USD","EUR","GBP","JPY","CNY","RUB","INR","AUD","CAD","CHF","SGD","MYR","THB","IDR","KRW","PHP","VND","HKD","TWD","MXN","BRL","ARS","CLP","COP","PEN","ZAR","NGN","EGP","AED","SAR","ILS","TRY","SEK","NOK","DKK","ISK","HUF","PLN","CZK","RON","BGN","API","APIs","SDK","SDKs","AI","OCR","REST","SOAP","JSON","XML","HTTP","HTTPS","URI","URL","CRUD","RESTful","KYB","KYC","AML","HTML","CSS","JS","SQL","DB","UI","UX","SaaS","PaaS","IaaS","IP","TCP","UDP","DNS","FTP","SMTP","IMAP","POP3","CSV","MVC","MVP","MVVM","DOM","SPA","SSR","CSR","DDoS","CDN","IoT","ML","DL","NLP","CLI","GUI","BI","ETL","RDBMS","NoSQL","IDE","CMS","CCPA","POSIX","ABI","API","AST","COBOL","DDL","DML","NN","CNN","RNN","LSTM","GRU","ANN","GAN","RL","DL","ML","NLP","NLG","NLU","BERT","GPT","SVM","PCA","AI","CV","TF","TTS","ASR","HMM","DNN","MLP","RBM","CRF","PDF","PDFs","RTF","TXT","XLS","XLSX","PPT","JPG","JPEG","PNG","GIF","GIFs","SVG","TIFF","BMP","ICO","PSD","WebP","AVIF","HEIF","HEIC","EPS","MP3","WAV","AIFF","FLAC","WMA","AAC","OGG","AVI","WMV","MOV","M4V","MP4","MPG","MPEG","FLV","SWF","MKV","WebM","GCP","AWS","VM","VPC","S3","EC2","DynamoDB","CosmosDB","BigQuery","CI/CD","SOC1","SOC2","SOC3","PCI DSS","WAF","IAM","SDN","MPLS","BGP","Vue.js","Node.js",".NET"];function U$i(e){return e=e.replace(/([a-z])([A-Z])/g,"$1 $2"),e=e.replace(/_/g," "),e=e.replace(/-/g," "),(0,Tz_.default)(e,{special:qz_}).replace(/V\s(\d)/g,"V$1")}function Vvc(e,t="type"){return{_visit:r=>{let i=r[e[t]];return i!=null?i(e):(r._other==null&&Cz_(e),r._other(e))}}}var $z_=ue(Sv(),1);var Ugi=ue(Sv(),1);function WFt(e){return typeof e.subpackageId=="string"}function B9o(e,t){return`${e} ${d8(t)}`}function d8(e){return e.map(t=>t.type==="literal"?t.value:`{${t.value}}`).join("")}function L$i(e){return e.map(t=>t.type==="literal"?t.value:`:${t.value}`).join("")}var Wvc="__package__",p1i=class e{api;context;static create(t,r){return new e(t,r)}#e=new Map;#t=new Map;#r=new Map;#i=new Map;#n=new Map;#a=new Map;#o=new Map;#s=new Map;#u=new Map;#c=new Map;#f=new Map;#p=new Map;#d=new Map;#l=new Map;static getSubpackageId(t){return WFt(t)?t.subpackageId:Wvc}getSubpackageByIdOrLocator(t){if(t==null)return;let r=oQ.SubpackageId(t),i=oQ.SubpackageId(`subpackage_${Fo(t)}`);return r===Wvc?this.api.rootPackage:this.api.subpackages[r]??this.#l.get(r)??this.api.subpackages[i]??this.#l.get(i)}resolveSubpackage(t){if(t!=null){for(;t?.pointsTo!=null;)t=this.api.subpackages[t.pointsTo];return t}}constructor(t,r){this.api=t,this.context=r,[t.rootPackage,...Object.values(t.subpackages)].forEach(i=>{let n=oQ.SubpackageId(e.getSubpackageId(i)),a={endpoints:new Map,webSockets:new Map,webhooks:new Map,grpcs:new Map};this.#u.set(n,a),i.endpoints.forEach(o=>{if(o.protocol?.type==="grpc"){a.grpcs.set(o.id,o);let c=e.createGrpcId(o,n);this.#i.set(c,o)}else{a.endpoints.set(o.id,o);let c=e.createEndpointId(o,n);this.#e.set(c,o);let f=[],s=[o.method];o.response?.type.type==="stream"&&s.push("STREAM"),s.forEach(u=>{f.push(`${u} ${d8(o.path.parts)}`),f.push(`${u} ${L$i(o.path.parts)}`),o.environments.forEach(l=>{f.push(`${u} ${(0,Ugi.default)(l.baseUrl,d8(o.path.parts))}`),f.push(`${u} ${(0,Ugi.default)(l.baseUrl,L$i(o.path.parts))}`);let p=Rz_(l);p!=null&&(f.push(`${u} ${(0,Ugi.default)(p,d8(o.path.parts))}`),f.push(`${u} ${(0,Ugi.default)(p,L$i(o.path.parts))}`))})}),f.forEach(u=>{this.context?.logger.trace(`Registering endpoint locator: ${u}`),this.#c.set(u,o)})}}),i.websockets.forEach(o=>{a.webSockets.set(o.id,o);let c=e.createWebSocketId(o,n);this.#t.set(c,o);let f=[];["GET","WSS"].forEach(u=>{f.push(`${u} ${d8(o.path.parts)}`),f.push(`${u} ${L$i(o.path.parts)}`),o.environments.forEach(l=>{f.push(`${u} ${(0,Ugi.default)(l.baseUrl,d8(o.path.parts))}`),f.push(`${u} ${(0,Ugi.default)(l.baseUrl,L$i(o.path.parts))}`);let p=Rz_(l);p!=null&&(f.push(`${u} ${(0,Ugi.default)(p,d8(o.path.parts))}`),f.push(`${u} ${(0,Ugi.default)(p,L$i(o.path.parts))}`))})}),f.forEach(u=>{this.context?.logger.trace(`Registering websocket locator: ${u}`),this.#f.set(u,o)})}),i.webhooks.forEach(o=>{a.webhooks.set(o.id,o),this.#r.set(e.createWebhookId(o,n),o)})}),this.#e.forEach((i,n)=>{this.#n.set(i,n)}),this.#t.forEach((i,n)=>{this.#a.set(i,n)}),this.#r.forEach((i,n)=>{this.#o.set(i,n)}),this.#i.forEach((i,n)=>{this.#s.set(i,n)}),this.#_(t.rootPackage,[])}#_(t,r){if(t==null)return;let i=WFt(t)?[...r,t.name]:r,n=i.length===0?[Wvc]:i;if([n.join("."),n.join("/"),`${n.join(".")}.yml`].forEach(o=>{this.context?.logger.trace(`Registering subpackage locator: ${o}`),this.#l.set(o,t)}),t.pointsTo!=null)return this.#_(this.api.subpackages[t.pointsTo],i);t.endpoints.forEach(o=>{if(o.protocol?.type==="grpc")return;let c=[...i,o.id];[c.join("."),c.join("/")].forEach(s=>{this.context?.logger.trace(`Registering endpoint locator: ${s}`),this.#c.set(s,o)})}),t.websockets.forEach(o=>{let c=[...i,o.id];[c.join("."),c.join("/")].forEach(s=>{this.context?.logger.trace(`Registering websocket locator: ${s}`),this.#f.set(s,o)})}),t.webhooks.forEach(o=>{let c=[...i,o.id];[c.join("."),c.join("/")].forEach(s=>{this.context?.logger.trace(`Registering webhook locator: ${s}`),this.#p.set(s,o)})}),t.subpackages.forEach(o=>{this.#_(this.api.subpackages[o],i)})}get endpoints(){return this.#e}get webSockets(){return this.#t}get webhooks(){return this.#r}get grpcs(){return this.#i}get endpointsByLocator(){return this.#c}get webSocketsByLocator(){return this.#f}get webhooksByLocator(){return this.#p}get grpcsByLocator(){return this.#d}get subpackages(){return this.#u}get subpackagesByLocator(){return this.#l}get subpackageLocators(){return new Set(this.#l.keys())}getEndpointId(t){return this.#n.get(t)}getWebSocketId(t){return this.#a.get(t)}getWebhookId(t){return this.#o.get(t)}getGrpcId(t){return this.#s.get(t)}static createEndpointId(t,r){return Ct.EndpointId(t.originalEndpointId??`${r}.${t.id}`)}static createWebSocketId(t,r){return Ct.WebSocketId(`${r}.${t.id}`)}static createWebhookId(t,r){return Ct.WebhookId(`${r}.${t.id}`)}static createGrpcId(t,r){return Ct.GrpcId(`${r}.${t.id}`)}};function Rz_(e){if(e!=null){if(e.baseUrl.startsWith("/"))return e.baseUrl;if(e.baseUrl.startsWith("http")||e.baseUrl.startsWith("ws"))try{return new URL(e.baseUrl).pathname}catch{return}}}var RLn=ue(tco(),1),Nz_=ue(rco(),1);function zz_(e){let t=e.split(".")[0];if(t==null)return;let i=/(^\d{1,4})-(\d{1,2})-(\d{1,4})/.exec(t)?.[0];if(i!=null)try{return new Date(i)}catch{}}RLn.default.extend(Nz_.default);var TNM="Changelog",RNM=["summary","index","overview"],V$i=class{markdownToFullSlug;markdownToNoIndex;markdownToTags;changelogFiles;docsWorkspace;idgen;constructor(t,r,i,n,a,o){this.markdownToFullSlug=t,this.markdownToNoIndex=r,this.markdownToTags=i,this.changelogFiles=n,this.docsWorkspace=a,this.idgen=o}toChangelogNode(t){let r=t.title??TNM,i=[],n;for(let p of this.changelogFiles??[]){let _=iws(p.split("/"));if(_==null)continue;let h=zz_(_);if(h==null){let b=_.split(".")[0]?.toLowerCase();b!=null&&RNM.includes(b)&&(n=p);continue}let y=this.toRelativeFilepath(p);i.push({date:h,pageId:Ct.PageId(y),absoluteFilepath:p})}let a=t.parentSlug.apply({fullSlug:n!=null?this.markdownToFullSlug.get(n)?.split("/"):void 0,skipUrlSlug:!1,urlSlug:t.slug??Rw(r)}),o=n!=null?this.markdownToNoIndex.get(n):void 0,c=i.map(p=>{let _=RLn.default.utc(p.date);return{id:this.idgen.get(p.pageId),type:"changelogEntry",title:_.format("MMMM D, YYYY"),slug:a.apply({fullSlug:this.markdownToFullSlug.get(p.absoluteFilepath)?.split("/"),urlSlug:_.format("YYYY/M/D")}).get(),icon:void 0,hidden:void 0,date:p.date.toISOString(),pageId:p.pageId,noindex:this.markdownToNoIndex.get(p.absoluteFilepath),authed:void 0,viewers:void 0,orphaned:void 0,featureFlags:void 0,tags:this.markdownToTags.get(p.absoluteFilepath)}}),f=xvc(c,p=>p.date,"desc"),s=n!=null?Ct.PageId(this.toRelativeFilepath(n)):void 0,u=this.idgen.get(s??"changelog"),l=this.groupByYear(u,f,a);return{id:u,type:"changelog",title:r,slug:a.get(),icon:t.icon,hidden:t.hidden,children:l,overviewPageId:s,noindex:o,authed:void 0,viewers:t.viewers,orphaned:t.orphaned,featureFlags:void 0}}orUndefined(){return this.changelogFiles!=null&&this.changelogFiles.length>0?this:void 0}groupByYear(t,r,i){let n=new Map;for(let a of r){let o=RLn.default.utc(a.date).year(),c=n.get(o)??[];c.push(a),n.set(o,c)}return xvc(Array.from(n.entries()).map(([a,o])=>{let c=i.append(a.toString()).get(),f=this.idgen.get(`${t}/year/${a}`);return{id:f,type:"changelogYear",title:a.toString(),year:a,slug:c,icon:void 0,hidden:void 0,children:this.groupByMonth(f,o,i),authed:void 0,viewers:void 0,orphaned:void 0,featureFlags:void 0}}),"year","desc")}groupByMonth(t,r,i){let n=new Map;for(let a of r){let o=RLn.default.utc(a.date).month()+1,c=n.get(o)??[];c.push(a),n.set(o,c)}return xvc(Array.from(n.entries()).map(([a,o])=>{let c=(0,RLn.default)(new Date(0,a-1));return{id:this.idgen.get(`${t}/month/${a}`),type:"changelogMonth",title:c.format("MMMM YYYY"),month:a,slug:i.append(a.toString()).get(),icon:void 0,hidden:void 0,children:o,authed:void 0,viewers:void 0,orphaned:void 0,featureFlags:void 0}}),"month","desc")}toRelativeFilepath(t){if(t!=null)return ab(this.docsWorkspace.absoluteFilePath,t)}};function xvc(e,t,r="asc"){return e.concat().sort((i,n)=>{let a=typeof t=="function"?t(i):i[t],o=typeof t=="function"?t(n):n[t];return a<o?r==="asc"?-1:1:a>o?r==="asc"?1:-1:0})}function Fz_(e){if(e)return{environments:e.environments!=null&&e.environments.length>0?e.environments.map(t=>Ct.V1.EnvironmentId(t)):void 0,button:e.button!=null&&e.button.href?{href:Ct.V1.Url(e.button.href)}:void 0,"limit-websocket-messages-per-connection":e.limitWebsocketMessagesPerConnection!=null?e.limitWebsocketMessagesPerConnection:void 0,hidden:e.hidden!=null?e.hidden:void 0}}function Gvc({child:e,nodeIdToSubpackageId:t,convertApiDefinitionPackageId:r,mergeAndFilterChildren:i}){if(e.type==="apiPackage"){let n=Ct.V1.SlugGenerator.init(e.slug),o=(t.get(e.id)??[]).flatMap(s=>r(s,n,e.availability)),c=e.children.map(s=>Gvc({child:s,nodeIdToSubpackageId:t,convertApiDefinitionPackageId:r,mergeAndFilterChildren:i})),f=i(c,o);return{...e,children:f,pointsTo:void 0}}return e}var Gz_=ue(Vz_(),1);var W0=function(e,t,r,i){function n(a){return a instanceof r?a:new r(function(o){o(a)})}return new(r||(r=Promise))(function(a,o){function c(u){try{s(i.next(u))}catch(l){o(l)}}function f(u){try{s(i.throw(u))}catch(l){o(l)}}function s(u){u.done?a(u.value):n(u.value).then(c,f)}s((i=i.apply(e,t||[])).next())})},Zm=function(e,t){var r={label:0,sent:function(){if(a[0]&1)throw a[1];return a[1]},trys:[],ops:[]},i,n,a,o=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return o.next=c(0),o.throw=c(1),o.return=c(2),typeof Symbol=="function"&&(o[Symbol.iterator]=function(){return this}),o;function c(s){return function(u){return f([s,u])}}function f(s){if(i)throw new TypeError("Generator is already executing.");for(;o&&(o=0,s[0]&&(r=0)),r;)try{if(i=1,n&&(a=s[0]&2?n.return:s[0]?n.throw||((a=n.return)&&a.call(n),0):n.next)&&!(a=a.call(n,s[1])).done)return a;switch(n=0,a&&(s=[s[0]&2,a.value]),s[0]){case 0:case 1:a=s;break;case 4:return r.label++,{value:s[1],done:!1};case 5:r.label++,n=s[1],s=[0];continue;case 7:s=r.ops.pop(),r.trys.pop();continue;default:if(a=r.trys,!(a=a.length>0&&a[a.length-1])&&(s[0]===6||s[0]===2)){r=0;continue}if(s[0]===3&&(!a||s[1]>a[0]&&s[1]<a[3])){r.label=s[1];break}if(s[0]===6&&r.label<a[1]){r.label=a[1],a=s;break}if(a&&r.label<a[2]){r.label=a[2],r.ops.push(s);break}a[2]&&r.ops.pop(),r.trys.pop();continue}s=t.call(e,r)}catch(u){s=[6,u],n=0}finally{i=a=0}if(s[0]&5)throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}},$he=function(e,t){var r=typeof Symbol=="function"&&e[Symbol.iterator];if(!r)return e;var i=r.call(e),n,a=[],o;try{for(;(t===void 0||t-- >0)&&!(n=i.next()).done;)a.push(n.value)}catch(c){o={error:c}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return a},jPe=function(e,t,r){if(r||arguments.length===2)for(var i=0,n=t.length,a;i<n;i++)(a||!(i in t))&&(a||(a=Array.prototype.slice.call(t,0,i)),a[i]=t[i]);return e.concat(a||Array.prototype.slice.call(t))},Wz_=function(e){var t=typeof Symbol=="function"&&Symbol.iterator,r=t&&e[t],i=0;if(r)return r.call(e);if(e&&typeof e.length=="number")return{next:function(){return e&&i>=e.length&&(e=void 0),{value:e&&e[i++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")},HVx=(function(){function e(t){t===void 0&&(t=e.minComparator);var r=this;this.compare=t,this.heapArray=[],this._limit=0,this.offer=this.add,this.element=this.peek,this.poll=this.pop,this._invertedCompare=function(i,n){return r.compare(i,n).then(function(a){return-1*a})}}return e.getChildrenIndexOf=function(t){return[t*2+1,t*2+2]},e.getParentIndexOf=function(t){if(t<=0)return-1;var r=t%2?1:2;return Math.floor((t-r)/2)},e.getSiblingIndexOf=function(t){if(t<=0)return-1;var r=t%2?1:-1;return t+r},e.minComparator=function(t,r){return W0(this,void 0,void 0,function(){return Zm(this,function(i){return t>r?[2,1]:t<r?[2,-1]:[2,0]})})},e.maxComparator=function(t,r){return W0(this,void 0,void 0,function(){return Zm(this,function(i){return r>t?[2,1]:r<t?[2,-1]:[2,0]})})},e.minComparatorNumber=function(t,r){return W0(this,void 0,void 0,function(){return Zm(this,function(i){return[2,t-r]})})},e.maxComparatorNumber=function(t,r){return W0(this,void 0,void 0,function(){return Zm(this,function(i){return[2,r-t]})})},e.defaultIsEqual=function(t,r){return W0(this,void 0,void 0,function(){return Zm(this,function(i){return[2,t===r]})})},e.print=function(t){function r(u){var l=e.getParentIndexOf(u);return Math.floor(Math.log2(l+1))}function i(u,l){for(var p="";l>0;--l)p+=u;return p}for(var n=0,a=[],o=r(t.length-1)+2,c=0;n<t.length;){var f=r(n)+1;n===0&&(f=0);var s=String(t.get(n));s.length>c&&(c=s.length),a[f]=a[f]||[],a[f].push(s),n+=1}return a.map(function(u,l){var p=Math.pow(2,o-l)-1;return i(" ",Math.floor(p/2)*c)+u.map(function(_){var h=(c-_.length)/2;return i(" ",Math.ceil(h))+_+i(" ",Math.floor(h))}).join(i(" ",p*c))}).join(`
1762
1762
  `)},e.heapify=function(t,r){return W0(this,void 0,void 0,function(){var i;return Zm(this,function(n){switch(n.label){case 0:return i=new e(r),i.heapArray=t,[4,i.init()];case 1:return n.sent(),[2,i]}})})},e.heappop=function(t,r){var i=new e(r);return i.heapArray=t,i.pop()},e.heappush=function(t,r,i){return W0(this,void 0,void 0,function(){var n;return Zm(this,function(a){switch(a.label){case 0:return n=new e(i),n.heapArray=t,[4,n.push(r)];case 1:return a.sent(),[2]}})})},e.heappushpop=function(t,r,i){var n=new e(i);return n.heapArray=t,n.pushpop(r)},e.heapreplace=function(t,r,i){var n=new e(i);return n.heapArray=t,n.replace(r)},e.heaptop=function(t,r,i){r===void 0&&(r=1);var n=new e(i);return n.heapArray=t,n.top(r)},e.heapbottom=function(t,r,i){r===void 0&&(r=1);var n=new e(i);return n.heapArray=t,n.bottom(r)},e.nlargest=function(t,r,i){return W0(this,void 0,void 0,function(){var n;return Zm(this,function(a){switch(a.label){case 0:return n=new e(i),n.heapArray=jPe([],$he(r),!1),[4,n.init()];case 1:return a.sent(),[2,n.top(t)]}})})},e.nsmallest=function(t,r,i){return W0(this,void 0,void 0,function(){var n;return Zm(this,function(a){switch(a.label){case 0:return n=new e(i),n.heapArray=jPe([],$he(r),!1),[4,n.init()];case 1:return a.sent(),[2,n.bottom(t)]}})})},e.prototype.add=function(t){return W0(this,void 0,void 0,function(){return Zm(this,function(r){switch(r.label){case 0:return[4,this._sortNodeUp(this.heapArray.push(t)-1)];case 1:return r.sent(),this._applyLimit(),[2,!0]}})})},e.prototype.addAll=function(t){return W0(this,void 0,void 0,function(){var r,i,n;return Zm(this,function(a){switch(a.label){case 0:r=this.length,(n=this.heapArray).push.apply(n,jPe([],$he(t),!1)),i=this.length,a.label=1;case 1:return r<i?[4,this._sortNodeUp(r)]:[3,4];case 2:a.sent(),a.label=3;case 3:return++r,[3,1];case 4:return this._applyLimit(),[2,!0]}})})},e.prototype.bottom=function(){return W0(this,arguments,void 0,function(t){return t===void 0&&(t=1),Zm(this,function(r){return this.heapArray.length===0||t<=0?[2,[]]:this.heapArray.length===1?[2,[this.heapArray[0]]]:t>=this.heapArray.length?[2,jPe([],$he(this.heapArray),!1)]:[2,this._bottomN_push(~~t)]})})},e.prototype.check=function(){return W0(this,void 0,void 0,function(){var t,r,i,n,a,o,c,f,s;return Zm(this,function(u){switch(u.label){case 0:t=0,u.label=1;case 1:if(!(t<this.heapArray.length))return[3,10];r=this.heapArray[t],i=this.getChildrenOf(t),u.label=2;case 2:u.trys.push([2,7,8,9]),n=(f=void 0,Wz_(i)),a=n.next(),u.label=3;case 3:return a.done?[3,6]:(o=a.value,[4,this.compare(r,o)]);case 4:if(u.sent()>0)return[2,r];u.label=5;case 5:return a=n.next(),[3,3];case 6:return[3,9];case 7:return c=u.sent(),f={error:c},[3,9];case 8:try{a&&!a.done&&(s=n.return)&&s.call(n)}finally{if(f)throw f.error}return[7];case 9:return++t,[3,1];case 10:return[2]}})})},e.prototype.clear=function(){this.heapArray=[]},e.prototype.clone=function(){var t=new e(this.comparator());return t.heapArray=this.toArray(),t._limit=this._limit,t},e.prototype.comparator=function(){return this.compare},e.prototype.contains=function(t){return W0(this,arguments,void 0,function(r,i){var n,a,o,c,f,s;return i===void 0&&(i=e.defaultIsEqual),Zm(this,function(u){switch(u.label){case 0:u.trys.push([0,5,6,7]),n=Wz_(this.heapArray),a=n.next(),u.label=1;case 1:return a.done?[3,4]:(o=a.value,[4,i(o,r)]);case 2:if(u.sent())return[2,!0];u.label=3;case 3:return a=n.next(),[3,1];case 4:return[3,7];case 5:return c=u.sent(),f={error:c},[3,7];case 6:try{a&&!a.done&&(s=n.return)&&s.call(n)}finally{if(f)throw f.error}return[7];case 7:return[2,!1]}})})},e.prototype.init=function(t){return W0(this,void 0,void 0,function(){var r;return Zm(this,function(i){switch(i.label){case 0:t&&(this.heapArray=jPe([],$he(t),!1)),r=e.getParentIndexOf(this.length-1),i.label=1;case 1:return r>=0?[4,this._sortNodeDown(r)]:[3,4];case 2:i.sent(),i.label=3;case 3:return--r,[3,1];case 4:return this._applyLimit(),[2]}})})},e.prototype.isEmpty=function(){return this.length===0},e.prototype.leafs=function(){if(this.heapArray.length===0)return[];var t=e.getParentIndexOf(this.heapArray.length-1);return this.heapArray.slice(t+1)},Object.defineProperty(e.prototype,"length",{get:function(){return this.heapArray.length},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"limit",{get:function(){return this._limit},set:function(t){this._limit=~~t,this._applyLimit()},enumerable:!1,configurable:!0}),e.prototype.peek=function(){return this.heapArray[0]},e.prototype.pop=function(){return W0(this,void 0,void 0,function(){var t;return Zm(this,function(r){return t=this.heapArray.pop(),this.length>0&&t!==void 0?[2,this.replace(t)]:[2,t]})})},e.prototype.push=function(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];return W0(this,void 0,void 0,function(){return Zm(this,function(i){return t.length<1?[2,!1]:t.length===1?[2,this.add(t[0])]:[2,this.addAll(t)]})})},e.prototype.pushpop=function(t){return W0(this,void 0,void 0,function(){var r;return Zm(this,function(i){switch(i.label){case 0:return[4,this.compare(this.heapArray[0],t)];case 1:return i.sent()<0?(r=$he([this.heapArray[0],t],2),t=r[0],this.heapArray[0]=r[1],[4,this._sortNodeDown(0)]):[3,3];case 2:i.sent(),i.label=3;case 3:return[2,t]}})})},e.prototype.remove=function(t){return W0(this,arguments,void 0,function(r,i){var n,a,o,c=this;return i===void 0&&(i=e.defaultIsEqual),Zm(this,function(f){switch(f.label){case 0:return this.heapArray.length?r!==void 0?[3,2]:[4,this.pop()]:[2,!1];case 1:return f.sent(),[2,!0];case 2:n=[0],f.label=3;case 3:return n.length?(a=n.shift(),[4,i(this.heapArray[a],r)]):[3,13];case 4:return f.sent()?a!==0?[3,6]:[4,this.pop()]:[3,11];case 5:return f.sent(),[3,10];case 6:return a!==this.heapArray.length-1?[3,7]:(this.heapArray.pop(),[3,10]);case 7:return this.heapArray.splice(a,1,this.heapArray.pop()),[4,this._sortNodeUp(a)];case 8:return f.sent(),[4,this._sortNodeDown(a)];case 9:f.sent(),f.label=10;case 10:return[2,!0];case 11:o=e.getChildrenIndexOf(a).filter(function(s){return s<c.heapArray.length}),n.push.apply(n,jPe([],$he(o),!1)),f.label=12;case 12:return[3,3];case 13:return[2,!1]}})})},e.prototype.replace=function(t){return W0(this,void 0,void 0,function(){var r;return Zm(this,function(i){switch(i.label){case 0:return r=this.heapArray[0],this.heapArray[0]=t,[4,this._sortNodeDown(0)];case 1:return i.sent(),[2,r]}})})},e.prototype.size=function(){return this.length},e.prototype.top=function(){return W0(this,arguments,void 0,function(t){return t===void 0&&(t=1),Zm(this,function(r){return this.heapArray.length===0||t<=0?[2,[]]:this.heapArray.length===1||t===1?[2,[this.heapArray[0]]]:t>=this.heapArray.length?[2,jPe([],$he(this.heapArray),!1)]:[2,this._topN_push(~~t)]})})},e.prototype.toArray=function(){return jPe([],$he(this.heapArray),!1)},e.prototype.toString=function(){return this.heapArray.toString()},e.prototype.get=function(t){return this.heapArray[t]},e.prototype.getChildrenOf=function(t){var r=this;return e.getChildrenIndexOf(t).map(function(i){return r.heapArray[i]}).filter(function(i){return i!==void 0})},e.prototype.getParentOf=function(t){var r=e.getParentIndexOf(t);return this.heapArray[r]},e.prototype[Symbol.iterator]=function(){return Zm(this,function(t){switch(t.label){case 0:return this.length?[4,this.pop()]:[3,2];case 1:return t.sent(),[3,0];case 2:return[2]}})},e.prototype.iterator=function(){return this},e.prototype._applyLimit=function(){if(this._limit&&this._limit<this.heapArray.length)for(var t=this.heapArray.length-this._limit;t;)this.heapArray.pop(),--t},e.prototype._bottomN_push=function(t){return W0(this,void 0,void 0,function(){var r,i,n,a,c,o,c;return Zm(this,function(f){switch(f.label){case 0:return r=new e(this.compare),r.limit=t,r.heapArray=this.heapArray.slice(-t),[4,r.init()];case 1:for(f.sent(),i=this.heapArray.length-1-t,n=e.getParentIndexOf(i),a=[],c=i;c>n;--c)a.push(c);o=this.heapArray,f.label=2;case 2:return a.length?(c=a.shift(),[4,this.compare(o[c],r.peek())]):[3,6];case 3:return f.sent()>0?[4,r.replace(o[c])]:[3,5];case 4:f.sent(),c%2&&a.push(e.getParentIndexOf(c)),f.label=5;case 5:return[3,2];case 6:return[2,r.toArray()]}})})},e.prototype._moveNode=function(t,r){var i=this.heapArray[t];this.heapArray[t]=this.heapArray[r],this.heapArray[r]=i},e.prototype._sortNodeDown=function(t){return W0(this,void 0,void 0,function(){var r,i,n,a,o,c,f;return Zm(this,function(s){switch(s.label){case 0:r=this.heapArray.length,i=t,n=this.heapArray[t],a=2*t+1,s.label=1;case 1:return a<r?(o=a+1,f=o>=r,f?[3,3]:[4,this.compare(this.heapArray[a],this.heapArray[o])]):[3,5];case 2:f=s.sent()<0,s.label=3;case 3:return c=f?a:o,[4,this.compare(this.heapArray[c],n)];case 4:if(s.sent()<0)this.heapArray[t]=this.heapArray[c],t=c,a=2*t+1;else return[3,5];return[3,1];case 5:return t!==i&&(this.heapArray[t]=n),[2]}})})},e.prototype._sortNodeUp=function(t){return W0(this,void 0,void 0,function(){var r,i,n;return Zm(this,function(a){switch(a.label){case 0:r=this.heapArray[t],i=t,a.label=1;case 1:return t>0?(n=e.getParentIndexOf(t),[4,this.compare(r,this.heapArray[n])]):[3,3];case 2:if(a.sent()<0)this.heapArray[t]=this.heapArray[n],t=n;else return[3,3];return[3,1];case 3:return t!==i&&(this.heapArray[t]=r),[2]}})})},e.prototype._topN_push=function(t){return W0(this,void 0,void 0,function(){var r,i,n,a;return Zm(this,function(o){switch(o.label){case 0:r=new e(this._invertedCompare),r.limit=t,i=[0],n=this.heapArray,o.label=1;case 1:return i.length?(a=i.shift(),a<n.length?r.length<t?[4,r.push(n[a])]:[3,3]:[3,6]):[3,7];case 2:return o.sent(),i.push.apply(i,jPe([],$he(e.getChildrenIndexOf(a)),!1)),[3,6];case 3:return[4,this.compare(n[a],r.peek())];case 4:return o.sent()<0?[4,r.replace(n[a])]:[3,6];case 5:o.sent(),i.push.apply(i,jPe([],$he(e.getChildrenIndexOf(a)),!1)),o.label=6;case 6:return[3,1];case 7:return[2,r.toArray()]}})})},e.prototype._topN_fill=function(t){return W0(this,void 0,void 0,function(){var r,i,n,a,o,o;return Zm(this,function(c){switch(c.label){case 0:return r=this.heapArray,i=new e(this._invertedCompare),i.limit=t,i.heapArray=r.slice(0,t),[4,i.init()];case 1:for(c.sent(),n=e.getParentIndexOf(t-1)+1,a=[],o=n;o<t;++o)a.push.apply(a,jPe([],$he(e.getChildrenIndexOf(o).filter(function(f){return f<r.length})),!1));(t-1)%2&&a.push(t),c.label=2;case 2:return a.length?(o=a.shift(),o<r.length?[4,this.compare(r[o],i.peek())]:[3,5]):[3,6];case 3:return c.sent()<0?[4,i.replace(r[o])]:[3,5];case 4:c.sent(),a.push.apply(a,jPe([],$he(e.getChildrenIndexOf(o)),!1)),c.label=5;case 5:return[3,2];case 6:return[2,i.toArray()]}})})},e.prototype._topN_heap=function(t){return W0(this,void 0,void 0,function(){var r,i,n,a,o;return Zm(this,function(c){switch(c.label){case 0:r=this.clone(),i=[],n=0,c.label=1;case 1:return n<t?(o=(a=i).push,[4,r.pop()]):[3,4];case 2:o.apply(a,[c.sent()]),c.label=3;case 3:return++n,[3,1];case 4:return[2,i]}})})},e.prototype._topIdxOf=function(t){return W0(this,void 0,void 0,function(){var r,i,n,a;return Zm(this,function(o){switch(o.label){case 0:if(!t.length)return[2,-1];r=0,i=t[r],n=1,o.label=1;case 1:return n<t.length?[4,this.compare(t[n],i)]:[3,4];case 2:a=o.sent(),a<0&&(r=n,i=t[n]),o.label=3;case 3:return++n,[3,1];case 4:return[2,r]}})})},e.prototype._topOf=function(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];return W0(this,void 0,void 0,function(){var i;return Zm(this,function(n){switch(n.label){case 0:return i=new e(this.compare),[4,i.init(t)];case 1:return n.sent(),[2,i.peek()]}})})},e})(),QNM=function(e,t){var r={label:0,sent:function(){if(a[0]&1)throw a[1];return a[1]},trys:[],ops:[]},i,n,a,o=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return o.next=c(0),o.throw=c(1),o.return=c(2),typeof Symbol=="function"&&(o[Symbol.iterator]=function(){return this}),o;function c(s){return function(u){return f([s,u])}}function f(s){if(i)throw new TypeError("Generator is already executing.");for(;o&&(o=0,s[0]&&(r=0)),r;)try{if(i=1,n&&(a=s[0]&2?n.return:s[0]?n.throw||((a=n.return)&&a.call(n),0):n.next)&&!(a=a.call(n,s[1])).done)return a;switch(n=0,a&&(s=[s[0]&2,a.value]),s[0]){case 0:case 1:a=s;break;case 4:return r.label++,{value:s[1],done:!1};case 5:r.label++,n=s[1],s=[0];continue;case 7:s=r.ops.pop(),r.trys.pop();continue;default:if(a=r.trys,!(a=a.length>0&&a[a.length-1])&&(s[0]===6||s[0]===2)){r=0;continue}if(s[0]===3&&(!a||s[1]>a[0]&&s[1]<a[3])){r.label=s[1];break}if(s[0]===6&&r.label<a[1]){r.label=a[1],a=s;break}if(a&&r.label<a[2]){r.label=a[2],r.ops.push(s);break}a[2]&&r.ops.pop(),r.trys.pop();continue}s=t.call(e,r)}catch(u){s=[6,u],n=0}finally{i=a=0}if(s[0]&5)throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}},p8=function(e,t){var r=typeof Symbol=="function"&&e[Symbol.iterator];if(!r)return e;var i=r.call(e),n,a=[],o;try{for(;(t===void 0||t-- >0)&&!(n=i.next()).done;)a.push(n.value)}catch(c){o={error:c}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return a},Tx=function(e,t,r){if(r||arguments.length===2)for(var i=0,n=t.length,a;i<n;i++)(a||!(i in t))&&(a||(a=Array.prototype.slice.call(t,0,i)),a[i]=t[i]);return e.concat(a||Array.prototype.slice.call(t))};var xz_=(function(){function e(t){t===void 0&&(t=e.minComparator);var r=this;this.compare=t,this.heapArray=[],this._limit=0,this.offer=this.add,this.element=this.peek,this.poll=this.pop,this.removeAll=this.clear,this._invertedCompare=function(i,n){return-1*r.compare(i,n)}}return e.getChildrenIndexOf=function(t){return[t*2+1,t*2+2]},e.getParentIndexOf=function(t){return t<=0?-1:t-1>>1},e.getSiblingIndexOf=function(t){if(t<=0)return-1;var r=t%2?1:-1;return t+r},e.minComparator=function(t,r){return t>r?1:t<r?-1:0},e.maxComparator=function(t,r){return r>t?1:r<t?-1:0},e.minComparatorNumber=function(t,r){return t-r},e.maxComparatorNumber=function(t,r){return r-t},e.defaultIsEqual=function(t,r){return t===r},e.print=function(t){function r(u){var l=e.getParentIndexOf(u);return Math.floor(Math.log2(l+1))}function i(u,l){for(var p="";l>0;--l)p+=u;return p}for(var n=0,a=[],o=r(t.length-1)+2,c=0;n<t.length;){var f=r(n)+1;n===0&&(f=0);var s=String(t.get(n));s.length>c&&(c=s.length),a[f]=a[f]||[],a[f].push(s),n+=1}return a.map(function(u,l){var p=Math.pow(2,o-l)-1;return i(" ",Math.floor(p/2)*c)+u.map(function(_){var h=(c-_.length)/2;return i(" ",Math.ceil(h))+_+i(" ",Math.floor(h))}).join(i(" ",p*c))}).join(`
1763
1763
  `)},e.heapify=function(t,r){var i=new e(r);return i.heapArray=t,i.init(),i},e.heappop=function(t,r){var i=new e(r);return i.heapArray=t,i.pop()},e.heappush=function(t,r,i){var n=new e(i);n.heapArray=t,n.push(r)},e.heappushpop=function(t,r,i){var n=new e(i);return n.heapArray=t,n.pushpop(r)},e.heapreplace=function(t,r,i){var n=new e(i);return n.heapArray=t,n.replace(r)},e.heaptop=function(t,r,i){r===void 0&&(r=1);var n=new e(i);return n.heapArray=t,n.top(r)},e.heapbottom=function(t,r,i){r===void 0&&(r=1);var n=new e(i);return n.heapArray=t,n.bottom(r)},e.nlargest=function(t,r,i){var n=new e(i);return n.heapArray=Tx([],p8(r),!1),n.init(),n.top(t)},e.nsmallest=function(t,r,i){var n=new e(i);return n.heapArray=Tx([],p8(r),!1),n.init(),n.bottom(t)},e.prototype.add=function(t){return this._sortNodeUp(this.heapArray.push(t)-1),this._applyLimit(),!0},e.prototype.addAll=function(t){var r,i=this.length;(r=this.heapArray).push.apply(r,Tx([],p8(t),!1));for(var n=this.length;i<n;++i)this._sortNodeUp(i);return this._applyLimit(),!0},e.prototype.bottom=function(t){return t===void 0&&(t=1),this.heapArray.length===0||t<=0?[]:this.heapArray.length===1?[this.heapArray[0]]:t>=this.heapArray.length?Tx([],p8(this.heapArray),!1):this._bottomN_push(~~t)},e.prototype.check=function(){var t=this;return this.heapArray.find(function(r,i){return!!t.getChildrenOf(i).find(function(n){return t.compare(r,n)>0})})},e.prototype.clear=function(){this.heapArray=[]},e.prototype.clone=function(){var t=new e(this.comparator());return t.heapArray=this.toArray(),t._limit=this._limit,t},e.prototype.comparator=function(){return this.compare},e.prototype.contains=function(t,r){return r===void 0&&(r=e.defaultIsEqual),this.indexOf(t,r)!==-1},e.prototype.init=function(t){t&&(this.heapArray=Tx([],p8(t),!1));for(var r=e.getParentIndexOf(this.length-1);r>=0;--r)this._sortNodeDown(r);this._applyLimit()},e.prototype.isEmpty=function(){return this.length===0},e.prototype.indexOf=function(t,r){if(r===void 0&&(r=e.defaultIsEqual),this.heapArray.length===0)return-1;for(var i=[],n=0;n<this.heapArray.length;){var a=this.heapArray[n];if(r(a,t))return n;this.compare(a,t)<=0&&i.push.apply(i,Tx([],p8(e.getChildrenIndexOf(n)),!1)),n=i.shift()||this.heapArray.length}return-1},e.prototype.indexOfEvery=function(t,r){if(r===void 0&&(r=e.defaultIsEqual),this.heapArray.length===0)return[];for(var i=[],n=[],a=0;a<this.heapArray.length;){var o=this.heapArray[a];r(o,t)?(n.push(a),i.push.apply(i,Tx([],p8(e.getChildrenIndexOf(a)),!1))):this.compare(o,t)<=0&&i.push.apply(i,Tx([],p8(e.getChildrenIndexOf(a)),!1)),a=i.shift()||this.heapArray.length}return n},e.prototype.leafs=function(){if(this.heapArray.length===0)return[];var t=e.getParentIndexOf(this.heapArray.length-1);return this.heapArray.slice(t+1)},Object.defineProperty(e.prototype,"length",{get:function(){return this.heapArray.length},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"limit",{get:function(){return this._limit},set:function(t){t<0||isNaN(t)?this._limit=0:this._limit=~~t,this._applyLimit()},enumerable:!1,configurable:!0}),e.prototype.setLimit=function(t){return this.limit=t,t<0||isNaN(t)?NaN:this._limit},e.prototype.peek=function(){return this.heapArray[0]},e.prototype.pop=function(){var t=this.heapArray.pop();return this.length>0&&t!==void 0?this.replace(t):t},e.prototype.push=function(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];return t.length<1?!1:t.length===1?this.add(t[0]):this.addAll(t)},e.prototype.pushpop=function(t){var r;return this.compare(this.heapArray[0],t)<0&&(r=p8([this.heapArray[0],t],2),t=r[0],this.heapArray[0]=r[1],this._sortNodeDown(0)),t},e.prototype.remove=function(t,r){var i=this;if(r===void 0&&(r=e.defaultIsEqual),!this.heapArray.length)return!1;if(t===void 0)return this.pop(),!0;for(var n=[0];n.length;){var a=n.shift();if(r(this.heapArray[a],t))return a===0?this.pop():a===this.heapArray.length-1?this.heapArray.pop():(this.heapArray.splice(a,1,this.heapArray.pop()),this._sortNodeUp(a),this._sortNodeDown(a)),!0;if(this.compare(this.heapArray[a],t)<=0){var o=e.getChildrenIndexOf(a).filter(function(c){return c<i.heapArray.length});n.push.apply(n,Tx([],p8(o),!1))}}return!1},e.prototype.replace=function(t){var r=this.heapArray[0];return this.heapArray[0]=t,this._sortNodeDown(0),r},e.prototype.size=function(){return this.length},e.prototype.top=function(t){return t===void 0&&(t=1),this.heapArray.length===0||t<=0?[]:this.heapArray.length===1||t===1?[this.heapArray[0]]:t>=this.heapArray.length?Tx([],p8(this.heapArray),!1):this._topN_push(~~t)},e.prototype.toArray=function(){return Tx([],p8(this.heapArray),!1)},e.prototype.toString=function(){return this.heapArray.toString()},e.prototype.get=function(t){return this.heapArray[t]},e.prototype.getChildrenOf=function(t){var r=this;return e.getChildrenIndexOf(t).map(function(i){return r.heapArray[i]}).filter(function(i){return i!==void 0})},e.prototype.getParentOf=function(t){var r=e.getParentIndexOf(t);return this.heapArray[r]},e.prototype[Symbol.iterator]=function(){return QNM(this,function(t){switch(t.label){case 0:return this.length?[4,this.pop()]:[3,2];case 1:return t.sent(),[3,0];case 2:return[2]}})},e.prototype.iterator=function(){return this.toArray()},e.prototype._applyLimit=function(){if(this._limit>0&&this._limit<this.heapArray.length)for(var t=this.heapArray.length-this._limit;t;)this.heapArray.pop(),--t},e.prototype._bottomN_push=function(t){var r=new e(this.compare);r.limit=t,r.heapArray=this.heapArray.slice(-t),r.init();for(var i=this.heapArray.length-1-t,n=e.getParentIndexOf(i),a=[],o=i;o>n;--o)a.push(o);for(var c=this.heapArray;a.length;){var o=a.shift();this.compare(c[o],r.peek())>0&&(r.replace(c[o]),o%2&&a.push(e.getParentIndexOf(o)))}return r.toArray()},e.prototype._moveNode=function(t,r){var i=this.heapArray[t];this.heapArray[t]=this.heapArray[r],this.heapArray[r]=i},e.prototype._sortNodeDown=function(t){for(var r=this.heapArray.length,i=t,n=this.heapArray[t],a=2*t+1;a<r;){var o=a+1,c=o>=r||this.compare(this.heapArray[a],this.heapArray[o])<0?a:o;if(this.compare(this.heapArray[c],n)<0)this.heapArray[t]=this.heapArray[c],t=c,a=2*t+1;else break}t!==i&&(this.heapArray[t]=n)},e.prototype._sortNodeUp=function(t){for(var r=this.heapArray[t],i=t;t>0;){var n=e.getParentIndexOf(t);if(this.compare(r,this.heapArray[n])<0)this.heapArray[t]=this.heapArray[n],t=n;else break}t!==i&&(this.heapArray[t]=r)},e.prototype._topN_push=function(t){var r=new e(this._invertedCompare);r.limit=t;for(var i=[0],n=this.heapArray;i.length;){var a=i.shift();a<n.length&&(r.length<t?(r.push(n[a]),i.push.apply(i,Tx([],p8(e.getChildrenIndexOf(a)),!1))):this.compare(n[a],r.peek())<0&&(r.replace(n[a]),i.push.apply(i,Tx([],p8(e.getChildrenIndexOf(a)),!1))))}return r.toArray()},e.prototype._topN_fill=function(t){var r=this.heapArray,i=new e(this._invertedCompare);i.limit=t,i.heapArray=r.slice(0,t),i.init();for(var n=e.getParentIndexOf(t-1)+1,a=[],o=n;o<t;++o)a.push.apply(a,Tx([],p8(e.getChildrenIndexOf(o).filter(function(c){return c<r.length})),!1));for((t-1)%2&&a.push(t);a.length;){var o=a.shift();o<r.length&&this.compare(r[o],i.peek())<0&&(i.replace(r[o]),a.push.apply(a,Tx([],p8(e.getChildrenIndexOf(o)),!1)))}return i.toArray()},e.prototype._topN_heap=function(t){for(var r=this.clone(),i=[],n=0;n<t;++n)i.push(r.pop());return i},e.prototype._topIdxOf=function(t){if(!t.length)return-1;for(var r=0,i=t[r],n=1;n<t.length;++n){var a=this.compare(t[n],i);a<0&&(r=n,i=t[n])}return r},e.prototype._topOf=function(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];var i=new e(this.compare);return i.init(t),i.peek()},e})();function Hz_(e,t,r,i,n){if(r<=0)return[];let a=i??(c=>c),o=new xz_(UNM);for(let c of t){let f=Gz_.default.get(a(e),a(c));n!=null&&f>n||(o.push({neighbor:c,distance:f}),o.size()>r&&o.pop())}return LNM(o).reverse().map(c=>c.neighbor)}function UNM(e,t){return e.distance!==t.distance?t.distance-e.distance:t.neighbor.localeCompare(e.neighbor)}function LNM(e){let t=[];for(;e.size()>0;){let r=e.pop();r&&t.push(r)}return t}var VNM=3,WNM=5;function I9o(e,t){let r=Hz_(e,t,VNM,xNM,WNM),i=Array.from(t),n=`Failed to locate API section ${e}.`;switch(r.length){case 0:return n=`${n} No similar API sections found. Available API sections:`,i.length===0?`${n} []`:`${n} [
1764
1764
  ${i.map(a=>` ${a}`).join(`,
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "3.22.2",
2
+ "version": "3.22.3",
3
3
  "repository": {
4
4
  "type": "git",
5
5
  "url": "git+https://github.com/fern-api/fern.git",