fern-api 0.69.0 → 0.69.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cli.cjs +3 -3
- package/package.json +1 -1
package/cli.cjs
CHANGED
|
@@ -1710,7 +1710,7 @@ ${_$p.default.cursorShow}`)}releaseCursor(){this.extraLinesUnderPrompt>0&&yfc(th
|
|
|
1710
1710
|
`+xtn.default.red(">> ")+t),this.screen.render(r,i)}getMaskedValue(t){return this.status==="answered"?this.opt.mask?xtn.default.cyan(j$p(t,this.opt.mask)):xtn.default.italic(xtn.default.dim("[hidden]")):this.opt.mask?j$p(t,this.opt.mask):xtn.default.italic(xtn.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 BGo=ci(_5(),1),JGp=ci(sdc(),1),KGp=ci(rqe(),1);var U7a=class extends h5{_run(t){this.done=t,this.editorResult=new KGp.Subject;let r=c$(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"?BGo.default.dim("Received"):BGo.default.dim("Press <enter> to launch your preferred editor."),t&&(r=BGo.default.red(">> ")+t),this.screen.render(i,r)}startExternalEditor(){this.rl.pause(),(0,JGp.editAsync)(this.currentText,this.endExternalEditor.bind(this),{postfix:this.opt.postfix??".txt"})}endExternalEditor(t,r){this.rl.resume(),t?this.editorResult.error(t):this.editorResult.next(r)}onEnd(t){this.editorResult.unsubscribe(),this.lineSubscription.unsubscribe(),this.answer=t.value,this.status="answered",this.render(),this.screen.done(),this.done(this.answer)}onError(t){this.render(t.isValid)}};var eQp=require("stream");var ZGp=ci(require("readline"),1),kGp=ci(XGp(),1),Htn=class{constructor(t){this.rl||=ZGp.default.createInterface(T$D(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 T$D(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 kGp.default;return r.pipe(e.output||process.stdout),{terminal:!0,...e,input:t,output:r}}var V7a=class extends Htn{constructor(t={}){super(t),this.log=new eQp.Writable({write:(r,i,n)=>{this.writeLog(r),n()}}),this.bottomBar=t.bottomBar||"",this.render()}render(){return this.write(this.bottomBar),this}clean(){return j7a(this.rl,this.bottomBar.split(`
|
|
1711
1711
|
`).length),this}updateBottomBar(t){return j7a(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+`
|
|
1712
1712
|
`}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&&uGo(this.rl,t.length+this.rl.line.length),this.rl.output.write(t)}};var FM=ci(rqe(),1),iQp=ci(H3a(),1);var IGo=ci(rqe(),1),tQp=ci(H3a(),1),zGo=function(e,t,r){return typeof e[t]!="function"?(0,IGo.of)(e):(0,IGo.from)((0,tQp.default)(e[t])(r).then(i=>(e[t]=i,e)))};var rQp={set:(e,t="",r)=>{let i=e;t.split(".").forEach((n,a,u)=>{n==="__proto__"||n==="constructor"||(a===u.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((u,c)=>u!=null?u[c]:u,e),n=i(/[,[\]]+?/)||i(/[,.[\]]+?/);return n===void 0||n===e?r:n}},ZWn=class extends Htn{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,FM.from)(t):(0,FM.isObservable)(t)?i=t:Object.values(t).every(n=>typeof n=="object"&&!Array.isArray(n)&&n!=null)?i=(0,FM.from)(Object.entries(t).map(([n,a])=>({name:n,...a}))):i=(0,FM.from)([t]),this.process=i.pipe((0,FM.concatMap)(this.processQuestion.bind(this)),(0,FM.publish)()),this.process.connect(),this.process.pipe((0,FM.reduce)((n,a)=>(rQp.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,FM.defer)(()=>(0,FM.of)(t).pipe((0,FM.concatMap)(this.setDefaultType.bind(this)),(0,FM.concatMap)(this.filterIfRunnable.bind(this)),(0,FM.concatMap)(()=>zGo(t,"message",this.answers)),(0,FM.concatMap)(()=>zGo(t,"default",this.answers)),(0,FM.concatMap)(()=>zGo(t,"choices",this.answers)),(0,FM.concatMap)(this.fetchAnswer.bind(this))))}fetchAnswer(t){let r=this.prompts[t.type];return this.activePrompt=new r(t,this.rl,this.answers),(0,FM.defer)(()=>(0,FM.from)(this.activePrompt.run().then(i=>({name:t.name,answer:i}))))}setDefaultType(t){return this.prompts[t.type]||(t.type="input"),(0,FM.defer)(()=>(0,FM.of)(t))}filterIfRunnable(t){if(t.askAnswered!==!0&&rQp.get(this.answers,t.name)!==void 0)return FM.EMPTY;if(t.when===!1)return FM.EMPTY;if(typeof t.when!="function")return(0,FM.of)(t);let{answers:r}=this;return(0,FM.defer)(()=>(0,FM.from)((0,iQp.default)(t.when)(r).then(i=>{if(i)return t})).pipe((0,FM.filter)(i=>i!=null)))}};function nQp(e){let t=function(r,i){let n;try{n=new ZWn(t.prompts,e)}catch(u){return Promise.reject(u)}let a=n.run(r,i);return a.ui=n,a};return t.prompts={},t.registerPrompt=function(r,i){return t.prompts[r]=i,this},t.restoreDefaultPrompts=function(){this.registerPrompt("list",S7a),this.registerPrompt("input",ztn),this.registerPrompt("number",D7a),this.registerPrompt("confirm",E7a),this.registerPrompt("rawlist",M7a),this.registerPrompt("expand",A7a),this.registerPrompt("checkbox",q7a),this.registerPrompt("password",T7a),this.registerPrompt("editor",U7a)},t.restoreDefaultPrompts(),t}var ldc=nQp();function B$D(e,t){ldc.registerPrompt(e,t)}function I$D(){ldc.restoreDefaultPrompts()}var z$D={prompt:ldc,ui:{BottomBar:V7a,Prompt:ZWn},createPromptModule:nQp,registerPrompt:B$D,restoreDefaultPrompts:I$D,Separator:pue},xGo=z$D;var lHn=require("path"),NJp=require("fs"),FJp=require("readline"),cJp="posthog-node";function yJD(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[nQo.POSTHOG_ID_TAG];if(c===void 0)return a;let d=e.options.host??"https://us.i.posthog.com",s=new URL(`/project/${e.apiKey}/person/${c}`,d).toString();a.tags["PostHog Person URL"]=s;let o=a.exception?.values||[],l=o.map(g=>({...g,stacktrace:g.stacktrace?{...g.stacktrace,type:"raw",frames:(g.stacktrace.frames||[]).map(O=>({...O,platform:"node:javascript"}))}:void 0})),b={$exception_message:o[0]?.value||a.message,$exception_type:o[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:o[0]?.value||a.message,$sentry_exception_type:o[0]?.type,$sentry_tags:a.tags};return t&&r&&(b.$sentry_url=(i||"https://sentry.io/organizations/")+t+"/issues/?project="+r+"&query="+a.event_id),e.capture({event:"$exception",distinctId:c,properties:b}),a}}var nQo=class{constructor(t,r,i,n){this.name=cJp,this.name=cJp,this.setupOnce=function(a,u){let c=u()?.getClient()?.getDsn()?.projectId;a(yJD(t,{organization:r,projectId:c,prefix:i,severityAllowList:n}))}}};nQo.POSTHOG_ID_TAG="posthog_distinct_id";var kGo="0123456789abcdef",aQo=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+=kGo.charAt(this.bytes[r]>>>4),t+=kGo.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+=kGo.charAt(this.bytes[r]>>>4),t+=kGo.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}},kdc=class{constructor(t){this.timestamp=0,this.counter=0,this.random=t??vJD()}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 aQo.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,aQo.ofInner(t)}},vJD=()=>({nextUint32:()=>Math.trunc(Math.random()*65536)*65536+Math.trunc(Math.random()*65536)}),lJp,epc=()=>bJD().toString(),bJD=()=>(lJp||(lJp=new kdc)).generate();function gJD(e,t){let r=!1;return Object.assign(i=>{let a=global.process.listeners("uncaughtException").filter(u=>u.name!=="domainUncaughtExceptionClear"&&u._posthogErrorHandler!==!0).length===0;e(i,{mechanism:{type:"onuncaughtexception",handled:!1}}),!r&&a&&(r=!0,t())},{_posthogErrorHandler:!0})}function OJD(e,t){global.process.on("uncaughtException",gJD(e,t))}function mJD(e){global.process.on("unhandledRejection",t=>{e(t,{mechanism:{type:"onunhandledrejection",handled:!1}})})}var eQo,fJp,tQo;function PJD(e){let t=globalThis._posthogChunkIds;if(!t)return console.error("No chunk id map found"),{};let r=Object.keys(t);return tQo&&r.length===fJp||(fJp=r.length,tQo=r.reduce((i,n)=>{eQo||(eQo={});let a=eQo[n];if(a)i[a[0]]=a[1];else{let u=e(n);for(let c=u.length-1;c>=0;c--){let s=u[c]?.filename,o=t[n];if(s&&o){i[s]=o,eQo[n]=[s,o];break}}}return i},{})),tQo}function jJD(e){return typeof Event<"u"&&LJp(e,Event)}function wJD(e){return UJp(e,"Object")}function spc(e){switch(Object.prototype.toString.call(e)){case"[object Error]":case"[object Exception]":case"[object DOMException]":case"[object WebAssembly.Exception]":return!0;default:return LJp(e,Error)}}function LJp(e,t){try{return e instanceof t}catch{return!1}}function SJD(e){return UJp(e,"ErrorEvent")}function UJp(e,t){return Object.prototype.toString.call(e)===`[object ${t}]`}async function DJD(e,t,r,i){let a=i&&i.mechanism||{handled:!0,type:"generic"},u=VJp(a,r,i);return{$exception_list:await Promise.all(u.map(async s=>{let o=await BJD(e,t,s);return o.value=o.value||"",o.type=o.type||"Error",o.mechanism=a,o}))}}function VJp(e,t,r){let i=EJD(e,t,r);return i.cause?[i,...VJp(e,i.cause,r)]:[i]}function EJD(e,t,r){if(spc(t))return t;if(e.synthetic=!0,wJD(t)){let n=MJD(t);if(n)return n;let a=AJD(t),u=r?.syntheticException||new Error(a);return u.message=a,u}let i=r?.syntheticException||new Error(t);return i.message=`${t}`,i}function MJD(e){for(let t in e)if(Object.prototype.hasOwnProperty.call(e,t)){let r=e[t];if(spc(r))return r}}function AJD(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=TJD(e);if(SJD(e))return`Event \`ErrorEvent\` captured as exception with message \`${e.message}\``;let r=qJD(e);return`${r&&r!=="Object"?`'${r}'`:"Object"} captured as exception with keys: ${t}`}function qJD(e){try{let t=Object.getPrototypeOf(e);return t?t.constructor.name:void 0}catch{}}function TJD(e,t=40){let r=Object.keys(CJD(e));r.sort();let i=r[0];if(!i)return"[object has no keys]";if(i.length>=t)return dJp(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:dJp(a,t)}return""}function dJp(e,t=0){return typeof e!="string"||t===0||e.length<=t?e:`${e.slice(0,t)}...`}function CJD(e){return spc(e)?{message:e.message,name:e.name,stack:e.stack,...pJp(e)}:jJD(e)?{type:e.type,target:_Jp(e.target),currentTarget:_Jp(e.currentTarget),...pJp(e)}:e}function pJp(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 _Jp(e){try{return Object.prototype.toString.call(e)}catch{return"<unknown>"}}async function BJD(e,t,r){let i={type:r.name||r.constructor.name,value:r.message},n=IJD(e,r);for(let a of t)n=await a(n);return n.length&&(i.stacktrace={frames:n,type:"raw"}),i}function IJD(e,t){return zJD(e(t.stack||"",1),e)}function zJD(e,t){let r=PJD(t);return e.forEach(i=>{i.filename&&(i.chunk_id=r[i.filename])}),e}var xJD=2e3,uHn=class e{static async captureException(t,r,i,n,a){let u={...a};n||(u.$process_person_profile=!1);let c=await DJD(this.stackParser,this.frameModifiers,r,i);t.capture({event:"$exception",distinctId:n||epc(),properties:{...c,...u}})}constructor(t,r){this.client=t,this._exceptionAutocaptureEnabled=r.enableExceptionAutocapture||!1,this.startAutocaptureIfEnabled()}startAutocaptureIfEnabled(){this.isEnabled()&&(OJD(this.onException.bind(this),this.onFatalError.bind(this)),mJD(this.onException.bind(this)))}onException(t,r){e.captureException(this.client,t,r)}async onFatalError(){await this.client.shutdown(xJD)}isEnabled(){return!this.client.isDisabled&&this._exceptionAutocaptureEnabled}};function RJD(e=process.argv[1]?(0,lHn.dirname)(process.argv[1]):process.cwd(),t=lHn.sep==="\\"){let r=t?hJp(e):e;return i=>{if(!i)return;let n=t?hJp(i):i,{dir:a,base:u,ext:c}=lHn.posix.parse(n);(c===".js"||c===".mjs"||c===".cjs")&&(u=u.slice(0,c.length*-1));let d=decodeURIComponent(u);a||(a=".");let s=a.lastIndexOf("/node_modules");if(s>-1)return`${a.slice(s+14).replace(/\//g,".")}:${d}`;if(a.startsWith(r)){let o=a.slice(r.length+1).replace(/\//g,".");return o?`${o}:${d}`:d}return d}}function hJp(e){return e.replace(/^[A-Z]:/,"").replace(/\\/g,"/")}var oQo=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)}}},iQo=new oQo(25),WJp=new oQo(20),cpc=7,NJD=1e3,FJD=1e4;async function LJD(e){let t={};for(let n=e.length-1;n>=0;n--){let a=e[n],u=a?.filename;if(!a||typeof u!="string"||typeof a.lineno!="number"||HJD(u)||$JD(a))continue;t[u]||(t[u]=[]),t[u].push(a.lineno)}let r=Object.keys(t);if(r.length==0)return e;let i=[];for(let n of r){if(WJp.get(n))continue;let a=t[n];if(!a)continue;a.sort((d,s)=>d-s);let u=QJD(a);if(u.every(d=>GJD(n,d)))continue;let c=JJD(iQo,n,{});i.push(UJD(n,u,c))}return await Promise.all(i).catch(()=>{}),e&&e.length>0&&VJD(e,iQo),iQo.reduce(),e}function UJD(e,t,r){return new Promise(i=>{let n=(0,NJp.createReadStream)(e),a=(0,FJp.createInterface)({input:n});function u(){n.destroy(),i()}let c=0,d=0,s=t[d];if(s===void 0){u();return}let o=s[0],l=s[1];function b(){WJp.set(e,1),a.close(),a.removeAllListeners(),u()}n.on("error",b),a.on("error",b),a.on("close",u),a.on("line",g=>{if(c++,!(c<o)&&(r[c]=KJD(g,0),c>=l)){if(d===t.length-1){a.close(),a.removeAllListeners();return}d++;let O=t[d];if(O===void 0){a.close(),a.removeAllListeners();return}o=O[0],l=O[1]}})})}function VJD(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;WJD(r.lineno,r,i)}}function WJD(e,t,r){if(t.lineno===void 0||r===void 0)return;t.pre_context=[];for(let n=HJp(e);n<e;n++){let a=r[n];if(a===void 0){yJp(t);return}t.pre_context.push(a)}if(r[e]===void 0){yJp(t);return}t.context_line=r[e];let i=$Jp(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 yJp(e){delete e.pre_context,delete e.context_line,delete e.post_context}function HJD(e){return e.startsWith("node:")||e.endsWith(".min.js")||e.endsWith(".min.cjs")||e.endsWith(".min.mjs")||e.startsWith("data:")}function $JD(e){return e.lineno!==void 0&&e.lineno>FJD||e.colno!==void 0&&e.colno>NJD}function GJD(e,t){let r=iQo.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 QJD(e){if(!e.length)return[];let t=0,r=e[0];if(typeof r!="number")return[];let i=vJp(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+cpc:(n.push(i),i=vJp(a)),t++}return n}function vJp(e){return[HJp(e),$Jp(e)]}function HJp(e){return Math.max(1,e-cpc)}function $Jp(e){return e+cpc}function JJD(e,t,r){let i=e.get(t);return i===void 0?(e.set(t,r),r):i}function KJD(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 YJD="4.18.0",gue;(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"})(gue||(gue={}));var bJp;(function(e){e.Left="left",e.Right="right",e.Center="center"})(bJp||(bJp={}));var gJp;(function(e){e.Button="button",e.Tab="tab",e.Selector="selector"})(gJp||(gJp={}));var OJp;(function(e){e.Popover="popover",e.API="api",e.Widget="widget"})(OJp||(OJp={}));var mJp;(function(e){e.Html="html",e.Text="text"})(mJp||(mJp={}));var PJp;(function(e){e.Number="number",e.Emoji="emoji"})(PJp||(PJp={}));var jJp;(function(e){e.Open="open",e.MultipleChoice="multiple_choice",e.SingleChoice="single_choice",e.Rating="rating",e.Link="link"})(jJp||(jJp={}));var wJp;(function(e){e.NextQuestion="next_question",e.End="end",e.ResponseBased="response_based",e.SpecificQuestion="specific_question"})(wJp||(wJp={}));var SJp;(function(e){e.Regex="regex",e.NotRegex="not_regex",e.Exact="exact",e.IsNot="is_not",e.Icontains="icontains",e.NotIcontains="not_icontains"})(SJp||(SJp={}));var DJp;(function(e){e.Contains="contains",e.Exact="exact",e.Regex="regex"})(DJp||(DJp={}));var XJD=e=>{if("flags"in e){let t=kJD(e.flags),r=eKD(e.flags);return{...e,featureFlags:t,featureFlagPayloads:r}}else{let t=e.featureFlags??{},r=Object.fromEntries(Object.entries(e.featureFlagPayloads||{}).map(([n,a])=>[n,GJp(a)])),i=Object.fromEntries(Object.entries(t).map(([n,a])=>[n,ZJD(n,a,r[n])]));return{...e,featureFlags:t,featureFlagPayloads:r,flags:i}}};function ZJD(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 kJD=e=>Object.fromEntries(Object.entries(e??{}).map(([t,r])=>[t,lpc(r)]).filter(([,t])=>t!==void 0)),eKD=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?GJp(i):void 0]}))},lpc=e=>e===void 0?void 0:e.variant??e.enabled,GJp=e=>{if(typeof e!="string")return e;try{return JSON.parse(e)}catch{return e}},tKD=1,rKD=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"]),iKD="utf8";function nKD(e,t){if(!e||typeof e!="string"||aKD(e))throw new Error(t)}function aKD(e){return e.trim().length===0}function oKD(e){return e?.replace(/\/+$/,"")}async function uKD(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 EJp(){return new Date().getTime()}function Xdc(){return new Date().toISOString()}function uQo(e,t){let r=setTimeout(e,t);return r?.unref&&r?.unref(),r}function sKD(){return typeof fetch<"u"?fetch:typeof globalThis.fetch<"u"?globalThis.fetch:void 0}function cKD(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 lKD(e,t=0,r){let i=cKD(e);return r?.has(i)?!1:parseInt(i,16)/4294967295<t}function MJp(e){return Promise.all(e.map(t=>(t??Promise.resolve()).then(r=>({status:"fulfilled",value:r}),r=>({status:"rejected",reason:r}))))}var Z7a=String.fromCharCode,AJp="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",rQo={};function fKD(e,t){if(!rQo[e]){rQo[e]={};for(let r=0;r<e.length;r++)rQo[e][e.charAt(r)]=r}return rQo[e][t]}var aHn={compressToBase64:function(e){if(e==null)return"";let t=aHn._compress(e,6,function(r){return AJp.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:aHn._decompress(e.length,32,function(t){return fKD(AJp,e.charAt(t))})},compress:function(e){return aHn._compress(e,16,function(t){return Z7a(t)})},_compress:function(e,t,r){if(e==null)return"";let i={},n={},a=[],u,c,d="",s="",o="",l=2,b=3,g=2,O=0,m=0,P;for(P=0;P<e.length;P+=1)if(d=e.charAt(P),Object.prototype.hasOwnProperty.call(i,d)||(i[d]=b++,n[d]=!0),s=o+d,Object.prototype.hasOwnProperty.call(i,s))o=s;else{if(Object.prototype.hasOwnProperty.call(n,o)){if(o.charCodeAt(0)<256){for(u=0;u<g;u++)O=O<<1,m==t-1?(m=0,a.push(r(O)),O=0):m++;for(c=o.charCodeAt(0),u=0;u<8;u++)O=O<<1|c&1,m==t-1?(m=0,a.push(r(O)),O=0):m++,c=c>>1}else{for(c=1,u=0;u<g;u++)O=O<<1|c,m==t-1?(m=0,a.push(r(O)),O=0):m++,c=0;for(c=o.charCodeAt(0),u=0;u<16;u++)O=O<<1|c&1,m==t-1?(m=0,a.push(r(O)),O=0):m++,c=c>>1}l--,l==0&&(l=Math.pow(2,g),g++),delete n[o]}else for(c=i[o],u=0;u<g;u++)O=O<<1|c&1,m==t-1?(m=0,a.push(r(O)),O=0):m++,c=c>>1;l--,l==0&&(l=Math.pow(2,g),g++),i[s]=b++,o=String(d)}if(o!==""){if(Object.prototype.hasOwnProperty.call(n,o)){if(o.charCodeAt(0)<256){for(u=0;u<g;u++)O=O<<1,m==t-1?(m=0,a.push(r(O)),O=0):m++;for(c=o.charCodeAt(0),u=0;u<8;u++)O=O<<1|c&1,m==t-1?(m=0,a.push(r(O)),O=0):m++,c=c>>1}else{for(c=1,u=0;u<g;u++)O=O<<1|c,m==t-1?(m=0,a.push(r(O)),O=0):m++,c=0;for(c=o.charCodeAt(0),u=0;u<16;u++)O=O<<1|c&1,m==t-1?(m=0,a.push(r(O)),O=0):m++,c=c>>1}l--,l==0&&(l=Math.pow(2,g),g++),delete n[o]}else for(c=i[o],u=0;u<g;u++)O=O<<1|c&1,m==t-1?(m=0,a.push(r(O)),O=0):m++,c=c>>1;l--,l==0&&(l=Math.pow(2,g),g++)}for(c=2,u=0;u<g;u++)O=O<<1|c&1,m==t-1?(m=0,a.push(r(O)),O=0):m++,c=c>>1;for(;;)if(O=O<<1,m==t-1){a.push(r(O));break}else m++;return a.join("")},decompress:function(e){return e==null?"":e==""?null:aHn._decompress(e.length,32768,function(t){return e.charCodeAt(t)})},_decompress:function(e,t,r){let i=[],n=[],a={val:r(0),position:t,index:1},u=4,c=4,d=3,s="",o,l,b,g,O,m,P;for(o=0;o<3;o+=1)i[o]=o;for(b=0,O=Math.pow(2,2),m=1;m!=O;)g=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),b|=(g>0?1:0)*m,m<<=1;switch(b){case 0:for(b=0,O=Math.pow(2,8),m=1;m!=O;)g=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),b|=(g>0?1:0)*m,m<<=1;P=Z7a(b);break;case 1:for(b=0,O=Math.pow(2,16),m=1;m!=O;)g=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),b|=(g>0?1:0)*m,m<<=1;P=Z7a(b);break;case 2:return""}for(i[3]=P,l=P,n.push(P);;){if(a.index>e)return"";for(b=0,O=Math.pow(2,d),m=1;m!=O;)g=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),b|=(g>0?1:0)*m,m<<=1;switch(P=b){case 0:for(b=0,O=Math.pow(2,8),m=1;m!=O;)g=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),b|=(g>0?1:0)*m,m<<=1;i[c++]=Z7a(b),P=c-1,u--;break;case 1:for(b=0,O=Math.pow(2,16),m=1;m!=O;)g=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),b|=(g>0?1:0)*m,m<<=1;i[c++]=Z7a(b),P=c-1,u--;break;case 2:return n.join("")}if(u==0&&(u=Math.pow(2,d),d++),i[P])s=i[P];else if(P===c)s=l+l.charAt(0);else return null;n.push(s),i[c++]=l+s.charAt(0),u--,l=s,u==0&&(u=Math.pow(2,d),d++)}}},tpc=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)}},sHn=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()}},k7a=class extends Error{constructor(t){super("Network error while fetching PostHog",t instanceof Error?{cause:t}:{}),this.error=t,this.name="PostHogFetchNetworkError"}};async function qJp(e){if(e instanceof sHn){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 Zdc(e){return typeof e=="object"&&(e instanceof sHn||e instanceof k7a)}function TJp(e){return typeof e=="object"&&e instanceof sHn&&e.status===413}var rpc;(function(e){e.FeatureFlags="feature_flags",e.Recordings="recordings"})(rpc||(rpc={}));var ipc=class{constructor(t,r){this.flushPromise=null,this.shutdownPromise=null,this.pendingPromises={},this._events=new tpc,this._isInitialized=!1,nKD(t,"You must pass your PostHog project's api key."),this.apiKey=t,this.host=oKD(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:Zdc},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(gue.OptedOut)??!this.defaultOptIn}async optIn(){this.wrap(()=>{this.setPersistedProperty(gue.OptedOut,!1)})}async optOut(){this.wrap(()=>{this.setPersistedProperty(gue.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=epc();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,u){this.wrap(()=>{let c=this.buildPayload({distinct_id:a||`$${t}_${r}`,event:"$groupidentify",properties:{$group_type:t,$group_key:r,$group_set:i||{},...u||{}}});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=lKD(this.apiKey,tKD,rKD)?`${this.host}/flags/?v=2`:`${this.host}/decide/?v=4`,d={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,d,{retryCount:0},this.featureFlagsRequestTimeoutMs).then(s=>s.json()).then(s=>XJD(s)).catch(s=>{this._events.emit("error",s)})}async getFeatureFlagStateless(t,r,i={},n={},a={},u){await this._initPromise;let c=await this.getFeatureFlagDetailStateless(t,r,i,n,a,u);if(c===void 0)return{response:void 0,requestId:void 0};let d=lpc(c.response);return d===void 0&&(d=!1),{response:d,requestId:c.requestId}}async getFeatureFlagDetailStateless(t,r,i={},n={},a={},u){await this._initPromise;let c=await this.getFeatureFlagDetailsStateless(r,i,n,a,u,[t]);return c===void 0?void 0:{response:c.flags[t],requestId:c.requestId}}async getFeatureFlagPayloadStateless(t,r,i={},n={},a={},u){await this._initPromise;let c=await this.getFeatureFlagPayloadsStateless(r,i,n,a,u,[t]);if(!c)return;let d=c[t];return d===void 0?null:d}async getFeatureFlagPayloadsStateless(t,r={},i={},n={},a,u){return await this._initPromise,(await this.getFeatureFlagsAndPayloadsStateless(t,r,i,n,a,u)).payloads}async getFeatureFlagsStateless(t,r={},i={},n={},a,u){return await this._initPromise,await this.getFeatureFlagsAndPayloadsStateless(t,r,i,n,a,u)}async getFeatureFlagsAndPayloadsStateless(t,r={},i={},n={},a,u){await this._initPromise;let c=await this.getFeatureFlagDetailsStateless(t,r,i,n,a,u);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,u){await this._initPromise;let c={};(a??this.disableGeoip)&&(c.geoip_disable=!0),u&&(c.flag_keys_to_evaluate=u);let d=await this.getDecide(t,r,i,n,c);if(d!==void 0)return d.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"),d.quotaLimited?.includes(rpc.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:d?.requestId}):d}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 u=`Surveys API could not be loaded: ${a.status}`,c=new Error(u);this.logMsgIfDebug(()=>console.error(c)),this._events.emit("error",new Error(u));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(gue.Props)),this._props||{}}set props(t){this._props=t}async register(t){this.wrap(()=>{this.props={...this.props,...t},this.setPersistedProperty(gue.Props,this.props)})}async unregister(t){this.wrap(()=>{delete this.props[t],this.setPersistedProperty(gue.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(gue.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(gue.Queue,a),this._events.emit(t,n),a.length>=this.flushAt&&this.flushBackground(),this.flushInterval&&!this._flushTimer&&(this._flushTimer=uQo(()=>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:Xdc()};this.historicalMigration&&(n.historical_migration=!0);let a=JSON.stringify(n),u=this.captureMode==="form"?`${this.host}/e/?ip=1&_=${EJp()}&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(aHn.compressToBase64(a))}&compression=lz64`}:{method:"POST",headers:{...this.getCustomHeaders(),"Content-Type":"application/json"},body:a};try{await this.fetchWithRetry(u,c)}catch(d){this._events.emit("error",d)}}prepareMessage(t,r,i){let n={...r,type:t,library:this.getLibraryId(),library_version:this.getLibraryVersion(),timestamp:i?.timestamp?i?.timestamp:Xdc(),uuid:i?.uuid?i.uuid:epc()};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 qJp(t)})}async flush(){let t=MJp([this.flushPromise]).then(()=>this._flush());return this.flushPromise=t,this.addPendingPromise(t),MJp([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(gue.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(b=>b.message),u=()=>{let g=(this.getPersistedProperty(gue.Queue)||[]).slice(n.length);this.setPersistedProperty(gue.Queue,g),t=g},c={api_key:this.apiKey,batch:a,sent_at:Xdc()};this.historicalMigration&&(c.historical_migration=!0);let d=JSON.stringify(c),s=this.captureMode==="form"?`${this.host}/e/?ip=1&_=${EJp()}&v=${this.getLibraryVersion()}`:`${this.host}/batch/`,o=this.captureMode==="form"?{method:"POST",mode:"no-cors",credentials:"omit",headers:{...this.getCustomHeaders(),"Content-Type":"application/x-www-form-urlencoded"},body:`data=${encodeURIComponent(aHn.compressToBase64(d))}&compression=lz64`}:{method:"POST",headers:{...this.getCustomHeaders(),"Content-Type":"application/json"},body:d},l={retryCheck:b=>TJp(b)?!1:Zdc(b)};try{await this.fetchWithRetry(s,o,l)}catch(b){if(TJp(b)&&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 b instanceof k7a||u(),this._events.emit("error",b),b}u(),r.push(...a)}this._events.emit("flush",r)}async fetchWithRetry(t,r,i,n){var a;(a=AbortSignal).timeout??(a.timeout=function(s){let o=new AbortController;return setTimeout(()=>o.abort(),s),o.signal});let u=r.body?r.body:"",c=-1;try{c=Buffer.byteLength(u,iKD)}catch{c=new TextEncoder().encode(u).length}return await uKD(async()=>{let d=null;try{d=await this.fetch(t,{signal:AbortSignal.timeout(n??this.requestTimeout),...r})}catch(o){throw new k7a(o)}if(!(r.mode==="no-cors")&&(d.status<200||d.status>=400))throw new sHn(d,c);return d},{...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(gue.Queue)||[]).length===0||(await this.flush(),r)););}catch(n){if(!Zdc(n))throw n;await qJp(n)}};return Promise.race([new Promise((n,a)=>{uQo(()=>{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}},npc=sKD();if(!npc){let e=sJp();npc=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 QJp=npc,sQo=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()}},JJp=new sQo(async()=>{try{return await import("crypto")}catch{return}});async function dKD(){return await JJp.getValue()}var pKD=new sQo(async()=>{if(typeof globalThis.crypto?.subtle<"u")return globalThis.crypto.subtle;try{let e=await JJp.getValue();if(e?.webcrypto?.subtle)return e.webcrypto.subtle}catch{}});async function _KD(){return await pKD.getValue()}async function hKD(e){let t=await dKD();if(t)return t.createHash("sha1").update(e).digest("hex");let r=await _KD();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 yKD=60*1e3,vKD=1152921504606847e3,bKD=["is_not"],oHn=class e extends Error{constructor(t){super(),Error.captureStackTrace(this,this.constructor),this.name="ClientError",this.message=t,Object.setPrototypeOf(this,e.prototype)}},y5=class e extends Error{constructor(t){super(t),this.name=this.constructor.name,Error.captureStackTrace(this,this.constructor),Object.setPrototypeOf(this,e.prototype)}},apc=class{constructor({pollingInterval:t,personalApiKey:r,projectApiKey:i,timeout:n,host:a,customHeaders:u,...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||QJp,this.onError=c.onError,this.customHeaders=u,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 u,c;if(!this.loadedSuccessfullyOnce)return u;for(let d of this.featureFlags)if(t===d.key){c=d;break}if(c!==void 0)try{u=await this.computeFlagLocally(c,r,i,n,a),this.logMsgIfDebug(()=>console.debug(`Successfully computed flag locally: ${t} -> ${u}`))}catch(d){d instanceof y5?this.logMsgIfDebug(()=>console.debug(`InconclusiveMatchError when computing flag locally: ${t}: ${d}`)):d instanceof Error&&this.onError?.(new Error(`Error computing flag locally: ${t}: ${d}`))}return u}async computeFeatureFlagPayloadLocally(t,r){await this.loadFeatureFlags();let i;if(this.loadedSuccessfullyOnce){if(typeof r=="boolean"?i=this.featureFlagsByKey?.[t]?.filters?.payloads?.[r.toString()]:typeof r=="string"&&(i=this.featureFlagsByKey?.[t]?.filters?.payloads?.[r]),i==null)return null;try{return JSON.parse(i)}catch{return i}}}async getAllFlagsAndPayloads(t,r={},i={},n={}){await this.loadFeatureFlags();let a={},u={},c=this.featureFlags.length==0;return await Promise.all(this.featureFlags.map(async d=>{try{let s=await this.computeFlagLocally(d,t,r,i,n);a[d.key]=s;let o=await this.computeFeatureFlagPayloadLocally(d.key,s);o&&(u[d.key]=o)}catch(s){s instanceof y5||s instanceof Error&&this.onError?.(new Error(`Error computing flag locally: ${d.key}: ${s}`)),c=!0}})),{response:a,payloads:u,fallbackToDecide:c}}async computeFlagLocally(t,r,i={},n={},a={}){if(t.ensure_experience_continuity)throw new y5("Flag has experience continuity enabled");if(!t.active)return!1;let c=(t.filters||{}).aggregation_group_type_index;if(c!=null){let d=this.groupTypeMapping[String(c)];if(!d)throw this.logMsgIfDebug(()=>console.warn(`[FEATURE FLAGS] Unknown group type index ${c} for feature flag ${t.key}`)),new y5("Flag has unknown group type index");if(!(d 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[d];return await this.matchFeatureFlagProperties(t,i[d],s)}else return await this.matchFeatureFlagProperties(t,r,n)}async matchFeatureFlagProperties(t,r,i){let n=t.filters||{},a=n.groups||[],u=!1,c,d=[...a].sort((s,o)=>{let l=!!s.variant,b=!!o.variant;return l&&b?0:l?-1:b?1:0});for(let s of d)try{if(await this.isConditionMatch(t,r,s,i)){let o=s.variant,l=n.multivariate?.variants||[];o&&l.some(b=>b.key===o)?c=o:c=await this.getMatchingVariant(t,r)||!0;break}}catch(o){if(o instanceof y5)u=!0;else throw o}if(c!==void 0)return c;if(u)throw new y5("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,u=c=>{this.logMsgIfDebug(()=>console.warn(c))};if((i.properties||[]).length>0){for(let c of i.properties){let d=c.type,s=!1;if(d==="cohort"?s=YJp(c,n,this.cohorts,this.debugMode):s=KJp(c,n,u),!s)return!1}if(a==null)return!0}return!(a!=null&&await CJp(t.key,r)>a/100)}async getMatchingVariant(t,r){let i=await CJp(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(yKD,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 oHn(`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 oHn(`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 oHn(`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 oHn&&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=uQo(()=>{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=uQo(()=>{a.abort()},this.timeout),i.signal=a.signal}try{return this.fetch(r,i)}finally{clearTimeout(n)}}};async function CJp(e,t,r=""){let i=await hKD(`${e}.${t}${r}`);return parseInt(i.slice(0,15),16)/vKD}function KJp(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 y5("Operator is_not_set is not supported")}else throw new y5(`Property ${i} not found in propertyValues`);let u=t[i];if(u==null&&!bKD.includes(a))return r&&r(`Property ${i} cannot have a value of null/undefined with the ${a} operator`),!1;function c(s,o){return Array.isArray(s)?s.map(l=>String(l).toLowerCase()).includes(String(o).toLowerCase()):String(s).toLowerCase()===String(o).toLowerCase()}function d(s,o,l){if(l==="gt")return s>o;if(l==="gte")return s>=o;if(l==="lt")return s<o;if(l==="lte")return s<=o;throw new Error(`Invalid operator: ${l}`)}switch(a){case"exact":return c(n,u);case"is_not":return!c(n,u);case"is_set":return i in t;case"icontains":return String(u).toLowerCase().includes(String(n).toLowerCase());case"not_icontains":return!String(u).toLowerCase().includes(String(n).toLowerCase());case"regex":return BJp(String(n))&&String(u).match(String(n))!==null;case"not_regex":return BJp(String(n))&&String(u).match(String(n))===null;case"gt":case"gte":case"lt":case"lte":{let s=typeof n=="number"?n:null;if(typeof n=="string")try{s=parseFloat(n)}catch{}return s!=null&&u!=null?typeof u=="string"?d(u,String(n),a):d(u,s,a):d(String(u),String(n),a)}case"is_date_after":case"is_date_before":{let s=gKD(String(n));if(s==null&&(s=IJp(n)),s==null)throw new y5(`Invalid date: ${n}`);let o=IJp(u);return["is_date_before"].includes(a)?o<s:o>s}default:throw new y5(`Unknown operator: ${a}`)}}function YJp(e,t,r,i=!1){let n=String(e.value);if(!(n in r))throw new y5("can't match cohort without a given cohort property value");let a=r[n];return XJp(a,t,r,i)}function XJp(e,t,r,i=!1){if(!e)return!0;let n=e.type,a=e.values;if(!a||a.length===0)return!0;let u=!1;if("values"in a[0]){for(let c of a)try{let d=XJp(c,t,r,i);if(n==="AND"){if(!d)return!1}else if(d)return!0}catch(d){if(d instanceof y5)i&&console.debug(`Failed to compute property ${c} locally: ${d}`),u=!0;else throw d}if(u)throw new y5("Can't match cohort without a given cohort property value");return n==="AND"}else{for(let c of a)try{let d;c.type==="cohort"?d=YJp(c,t,r,i):d=KJp(c,t);let s=c.negation||!1;if(n==="AND"){if(!d&&!s||d&&s)return!1}else if(d&&!s||!d&&s)return!0}catch(d){if(d instanceof y5)i&&console.debug(`Failed to compute property ${c} locally: ${d}`),u=!0;else throw d}if(u)throw new y5("can't match cohort without a given cohort property value");return n==="AND"}}function BJp(e){try{return new RegExp(e),!0}catch{return!1}}function IJp(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 y5(`${e} is in an invalid date format`)}else throw new y5(`The date provided ${e} must be a string, number, or date object`)}function gKD(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 opc=class{constructor(){this._memoryStorage={}}getProperty(t){return this._memoryStorage[t]}setProperty(t,r){this._memoryStorage[t]=r!==null?r:void 0}},OKD=100,zJp=30*1e3,mKD=50*1e3,upc=class extends ipc{constructor(t,r={}){if(super(t,r),this._memoryStorage=new opc,this.options=r,this.options.featureFlagsPollingInterval=typeof r.featureFlagsPollingInterval=="number"?Math.max(r.featureFlagsPollingInterval,OKD):zJp,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 apc({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 uHn(this,r),this.distinctIdHasSentFlagCalls={},this.maxCacheSize=r.maxCacheSize||mKD}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):QJp(t,r)}getLibraryVersion(){return YJD}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:u,timestamp:c,disableGeoip:d,uuid:s}=t,o=g=>{super.captureStateless(r,i,g,{timestamp:c,disableGeoip:d,uuid:s})},l=async(g,O,m)=>(await super.getFeatureFlagsStateless(g,O,void 0,void 0,m)).flags,b=Promise.resolve().then(async()=>{if(u)return await l(r,a,d);if(i==="$feature_flag_called")return{};if((this.featureFlagsPoller?.featureFlags?.length||0)>0){let g={};for(let[O,m]of Object.entries(a||{}))g[O]=String(m);return await this.getAllFlags(r,{groups:g,disableGeoip:d,onlyEvaluateLocally:!0})}return{}}).then(g=>{let O={};if(g)for(let[P,D]of Object.entries(g))O[`$feature/${P}`]=D;let m=Object.keys(g||{}).filter(P=>g?.[P]!==!1).sort();return m.length>0&&(O.$active_feature_flags=m),O}).catch(()=>({})).then(g=>{o({...g,...n,$groups:a})});this.addPendingPromise(b)}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:u,timestamp:c,disableGeoip:d,uuid:s}=t,o=g=>super.captureStatelessImmediate(r,i,g,{timestamp:c,disableGeoip:d,uuid:s}),l=async(g,O,m)=>(await super.getFeatureFlagsStateless(g,O,void 0,void 0,m)).flags;await Promise.resolve().then(async()=>{if(u)return await l(r,a,d);if(i==="$feature_flag_called")return{};if((this.featureFlagsPoller?.featureFlags?.length||0)>0){let g={};for(let[O,m]of Object.entries(a||{}))g[O]=String(m);return await this.getAllFlags(r,{groups:g,disableGeoip:d,onlyEvaluateLocally:!0})}return{}}).then(g=>{let O={};if(g)for(let[P,D]of Object.entries(g))O[`$feature/${P}`]=D;let m=Object.keys(g||{}).filter(P=>g?.[P]!==!1).sort();return m.length>0&&(O.$active_feature_flags=m),O}).catch(()=>({})).then(g=>{o({...g,...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=zJp){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:u,sendFeatureFlagEvents:c,personProperties:d,groupProperties:s}=i||{},o=this.addLocalPersonAndGroupProperties(r,n,d,s);d=o.allPersonProperties,s=o.allGroupProperties,u==null&&(u=!1),c==null&&(c=!0);let l=await this.featureFlagsPoller?.getFeatureFlag(t,r,n,d,s),b=l!==void 0,g,O;if(!b&&!u){let P=await super.getFeatureFlagDetailStateless(t,r,n,d,s,a);if(P===void 0)return;O=P.response,l=lpc(O),g=P?.requestId}let m=`${t}_${l}`;return c&&(!(r in this.distinctIdHasSentFlagCalls)||!this.distinctIdHasSentFlagCalls[r].includes(m))&&(Object.keys(this.distinctIdHasSentFlagCalls).length>=this.maxCacheSize&&(this.distinctIdHasSentFlagCalls={}),Array.isArray(this.distinctIdHasSentFlagCalls[r])?this.distinctIdHasSentFlagCalls[r].push(m):this.distinctIdHasSentFlagCalls[r]=[m],this.capture({distinctId:r,event:"$feature_flag_called",properties:{$feature_flag:t,$feature_flag_response:l,$feature_flag_id:O?.metadata?.id,$feature_flag_version:O?.metadata?.version,$feature_flag_reason:O?.reason?.description??O?.reason?.code,locally_evaluated:b,[`$feature/${t}`]:l,$feature_flag_request_id:g},groups:n,disableGeoip:a})),l}async getFeatureFlagPayload(t,r,i,n){let{groups:a,disableGeoip:u}=n||{},{onlyEvaluateLocally:c,sendFeatureFlagEvents:d,personProperties:s,groupProperties:o}=n||{},l=this.addLocalPersonAndGroupProperties(r,a,s,o);s=l.allPersonProperties,o=l.allGroupProperties;let b;return this.featureFlagsPoller!==void 0&&(i||(i=await this.getFeatureFlag(t,r,{...n,onlyEvaluateLocally:!0,sendFeatureFlagEvents:!1})),i&&(b=await this.featureFlagsPoller?.computeFeatureFlagPayloadLocally(t,i))),c==null&&(c=!1),d==null&&(d=!0),c==null&&(c=!1),!(b!==void 0)&&!c&&(b=await super.getFeatureFlagPayloadStateless(t,r,a,s,o,u)),b}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:u,groupProperties:c}=r||{},d=this.addLocalPersonAndGroupProperties(t,i,u,c);u=d.allPersonProperties,c=d.allGroupProperties,a==null&&(a=!1);let s=await this.featureFlagsPoller?.getAllFlagsAndPayloads(t,i,u,c),o={},l={},b=!0;if(s&&(o=s.response,l=s.payloads,b=s.fallbackToDecide),b&&!a){let g=await super.getFeatureFlagsAndPayloadsStateless(t,i,u,c,n);o={...o,...g.flags||{}},l={...l,...g.payloads||{}}}return{featureFlags:o,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||{}},u={};if(r)for(let c of Object.keys(r))u[c]={$group_key:r[c],...n?.[c]||{}};return{allPersonProperties:a,allGroupProperties:u}}captureException(t,r,i){let n=new Error("PostHog syntheticException");uHn.captureException(this,t,{syntheticException:n},r,i)}},xJp=/\(error: (.*)\)/,ZJp=50,kJp="?";function PKD(e){let t=/^\s*[-]{4,}$/,r=/at (?:async )?(?:(.+?)\s+\()?(?:(.+):(\d+):(\d+)?|([^)]+))\)?/;return i=>{let n=i.match(r);if(n){let a,u,c,d,s;if(n[1]){c=n[1];let b=c.lastIndexOf(".");if(c[b-1]==="."&&b--,b>0){a=c.slice(0,b),u=c.slice(b+1);let g=a.indexOf(".Module");g>0&&(c=c.slice(g+1),a=a.slice(0,g))}d=void 0}u&&(d=a,s=u),u==="<anonymous>"&&(s=void 0,c=void 0),c===void 0&&(s=s||kJp,c=d?`${d}.${s}`:s);let o=n[2]?.startsWith("file://")?n[2].slice(7):n[2],l=n[5]==="native";return o?.match(/\/[A-Z]:/)&&(o=o.slice(1)),!o&&n[5]&&!l&&(o=n[5]),{filename:o?decodeURI(o):void 0,module:e?e(o):void 0,function:c,lineno:RJp(n[3]),colno:RJp(n[4]),in_app:jKD(o||"",l),platform:"node:javascript"}}if(i.match(t))return{filename:i,platform:"node:javascript"}}}function jKD(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 RJp(e){return parseInt(e||"",10)||void 0}function wKD(e){return[90,PKD(e)]}function SKD(e){let r=[wKD(e)].sort((i,n)=>i[0]-n[0]).map(i=>i[1]);return(i,n=0)=>{let a=[],u=i.split(`
|
|
1713
|
-
`);for(let c=n;c<u.length;c++){let d=u[c];if(d.length>1024)continue;let s=xJp.test(d)?d.replace(xJp,"$1"):d;if(!s.match(/\S*Error: /)){for(let o of r){let l=o(s);if(l){a.push(l);break}}if(a.length>=ZJp)break}}return DKD(a)}}function DKD(e){if(!e.length)return[];let t=Array.from(e);return t.reverse(),t.slice(0,ZJp).map(r=>({...r,filename:r.filename||EKD(t).filename,function:r.function||kJp}))}function EKD(e){return e[e.length-1]||{}}uHn.stackParser=SKD(RJD());uHn.frameModifiers=[LJD];var cHn=class extends upc{getLibraryId(){return"posthog-node"}};var cQo=class{posthog;constructor({posthogApiKey:t}){this.posthog=new cHn(t)}async identify(){}async sendEvent(t){t.orgId!=null&&this.posthog.capture({distinctId:t.orgId,event:"CLI",properties:{...t,...t.properties,version:"0.69.0",usingAccessToken:!0}})}async flush(){await this.posthog.flush()}};var eFa=class{async sendEvent(){}async identify(){}async flush(){}};var fHn=require("fs/promises"),iKp=require("os"),nKp=require("path");var eKp=ci(require("crypto")),fQo=new Uint8Array(256),lQo=fQo.length;function fpc(){return lQo>fQo.length-16&&(eKp.default.randomFillSync(fQo),lQo=0),fQo.slice(lQo,lQo+=16)}var d$=[];for(let e=0;e<256;++e)d$.push((e+256).toString(16).slice(1));function tKp(e,t=0){return d$[e[t+0]]+d$[e[t+1]]+d$[e[t+2]]+d$[e[t+3]]+"-"+d$[e[t+4]]+d$[e[t+5]]+"-"+d$[e[t+6]]+d$[e[t+7]]+"-"+d$[e[t+8]]+d$[e[t+9]]+"-"+d$[e[t+10]]+d$[e[t+11]]+d$[e[t+12]]+d$[e[t+13]]+d$[e[t+14]]+d$[e[t+15]]}var rKp=ci(require("crypto")),dpc={randomUUID:rKp.default.randomUUID};function MKD(e,t,r){if(dpc.randomUUID&&!t&&!e)return dpc.randomUUID();e=e||{};let i=e.random||(e.rng||fpc)();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 tKp(i)}var Oue=MKD;var AKD="id",qKD=".fern",tFa=class{posthog;userId;constructor({token:t,posthogApiKey:r}){this.posthog=new cHn(r),this.userId=t==null?void 0:Xac(t)}async identify(){this.userId!=null&&this.posthog.alias({distinctId:this.userId,alias:await this.getPersistedDistinctId()})}async sendEvent(t){this.posthog.capture({distinctId:this.userId??await this.getPersistedDistinctId(),event:"CLI",properties:{version:"0.69.0",...t,...t.properties}})}async flush(){await this.posthog.flush()}persistedDistinctId;async getPersistedDistinctId(){if(this.persistedDistinctId==null){let t=Bu($c.of((0,iKp.homedir)()),za.of(qKD),za.of(AKD));await Cf(t)||(await(0,fHn.mkdir)((0,nKp.dirname)(t),{recursive:!0}),await(0,fHn.writeFile)(t,Oue())),this.persistedDistinctId=(await(0,fHn.readFile)(t)).toString()}return this.persistedDistinctId}};var ppc;async function dHn(){return ppc==null&&(ppc=await TKD()),ppc}async function TKD(){try{let e="phc_yQgAEdJJkVpI24NdSRID2mor1x1leRpDoC9yZ9mfXal",t=process.env.FERN_DISABLE_TELEMETRY==="true";if(e==null||t)return new eFa;let r=await ELo();return r!=null?new tFa({token:r,posthogApiKey:e}):await sVn()!=null?new cQo({posthogApiKey:e}):new tFa({token:void 0,posthogApiKey:e})}catch{return new eFa}}function rFa(e,t){return function(){return e.apply(t,arguments)}}var{toString:CKD}=Object.prototype,{getPrototypeOf:hpc}=Object,{iterator:pQo,toStringTag:oKp}=Symbol,_Qo=(e=>t=>{let r=CKD.call(t);return e[r]||(e[r]=r.slice(8,-1).toLowerCase())})(Object.create(null)),kGt=e=>(e=e.toLowerCase(),t=>_Qo(t)===e),hQo=e=>t=>typeof t===e,{isArray:pHn}=Array,iFa=hQo("undefined");function BKD(e){return e!==null&&!iFa(e)&&e.constructor!==null&&!iFa(e.constructor)&&mue(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}var uKp=kGt("ArrayBuffer");function IKD(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&uKp(e.buffer),t}var zKD=hQo("string"),mue=hQo("function"),sKp=hQo("number"),yQo=e=>e!==null&&typeof e=="object",xKD=e=>e===!0||e===!1,dQo=e=>{if(_Qo(e)!=="object")return!1;let t=hpc(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(oKp in e)&&!(pQo in e)},RKD=kGt("Date"),NKD=kGt("File"),FKD=kGt("Blob"),LKD=kGt("FileList"),UKD=e=>yQo(e)&&mue(e.pipe),VKD=e=>{let t;return e&&(typeof FormData=="function"&&e instanceof FormData||mue(e.append)&&((t=_Qo(e))==="formdata"||t==="object"&&mue(e.toString)&&e.toString()==="[object FormData]"))},WKD=kGt("URLSearchParams"),[HKD,$KD,GKD,QKD]=["ReadableStream","Request","Response","Headers"].map(kGt),JKD=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function nFa(e,t,{allOwnKeys:r=!1}={}){if(e===null||typeof e>"u")return;let i,n;if(typeof e!="object"&&(e=[e]),pHn(e))for(i=0,n=e.length;i<n;i++)t.call(null,e[i],i,e);else{let a=r?Object.getOwnPropertyNames(e):Object.keys(e),u=a.length,c;for(i=0;i<u;i++)c=a[i],t.call(null,e[c],c,e)}}function cKp(e,t){t=t.toLowerCase();let r=Object.keys(e),i=r.length,n;for(;i-- >0;)if(n=r[i],t===n.toLowerCase())return n;return null}var Ytn=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,lKp=e=>!iFa(e)&&e!==Ytn;function _pc(){let{caseless:e}=lKp(this)&&this||{},t={},r=(i,n)=>{let a=e&&cKp(t,n)||n;dQo(t[a])&&dQo(i)?t[a]=_pc(t[a],i):dQo(i)?t[a]=_pc({},i):pHn(i)?t[a]=i.slice():t[a]=i};for(let i=0,n=arguments.length;i<n;i++)arguments[i]&&nFa(arguments[i],r);return t}var KKD=(e,t,r,{allOwnKeys:i}={})=>(nFa(t,(n,a)=>{r&&mue(n)?e[a]=rFa(n,r):e[a]=n},{allOwnKeys:i}),e),YKD=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),XKD=(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)},ZKD=(e,t,r,i)=>{let n,a,u,c={};if(t=t||{},e==null)return t;do{for(n=Object.getOwnPropertyNames(e),a=n.length;a-- >0;)u=n[a],(!i||i(u,e,t))&&!c[u]&&(t[u]=e[u],c[u]=!0);e=r!==!1&&hpc(e)}while(e&&(!r||r(e,t))&&e!==Object.prototype);return t},kKD=(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},eYD=e=>{if(!e)return null;if(pHn(e))return e;let t=e.length;if(!sKp(t))return null;let r=new Array(t);for(;t-- >0;)r[t]=e[t];return r},tYD=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&hpc(Uint8Array)),rYD=(e,t)=>{let i=(e&&e[pQo]).call(e),n;for(;(n=i.next())&&!n.done;){let a=n.value;t.call(e,a[0],a[1])}},iYD=(e,t)=>{let r,i=[];for(;(r=e.exec(t))!==null;)i.push(r);return i},nYD=kGt("HTMLFormElement"),aYD=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(r,i,n){return i.toUpperCase()+n}),aKp=(({hasOwnProperty:e})=>(t,r)=>e.call(t,r))(Object.prototype),oYD=kGt("RegExp"),fKp=(e,t)=>{let r=Object.getOwnPropertyDescriptors(e),i={};nFa(r,(n,a)=>{let u;(u=t(n,a,e))!==!1&&(i[a]=u||n)}),Object.defineProperties(e,i)},uYD=e=>{fKp(e,(t,r)=>{if(mue(e)&&["arguments","caller","callee"].indexOf(r)!==-1)return!1;let i=e[r];if(mue(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+"'")})}})},sYD=(e,t)=>{let r={},i=n=>{n.forEach(a=>{r[a]=!0})};return pHn(e)?i(e):i(String(e).split(t)),r},cYD=()=>{},lYD=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t;function fYD(e){return!!(e&&mue(e.append)&&e[oKp]==="FormData"&&e[pQo])}var dYD=e=>{let t=new Array(10),r=(i,n)=>{if(yQo(i)){if(t.indexOf(i)>=0)return;if(!("toJSON"in i)){t[n]=i;let a=pHn(i)?[]:{};return nFa(i,(u,c)=>{let d=r(u,n+1);!iFa(d)&&(a[c]=d)}),t[n]=void 0,a}}return i};return r(e,0)},pYD=kGt("AsyncFunction"),_YD=e=>e&&(yQo(e)||mue(e))&&mue(e.then)&&mue(e.catch),dKp=((e,t)=>e?setImmediate:t?((r,i)=>(Ytn.addEventListener("message",({source:n,data:a})=>{n===Ytn&&a===r&&i.length&&i.shift()()},!1),n=>{i.push(n),Ytn.postMessage(r,"*")}))(`axios@${Math.random()}`,[]):r=>setTimeout(r))(typeof setImmediate=="function",mue(Ytn.postMessage)),hYD=typeof queueMicrotask<"u"?queueMicrotask.bind(Ytn):typeof process<"u"&&process.nextTick||dKp,yYD=e=>e!=null&&mue(e[pQo]),hs={isArray:pHn,isArrayBuffer:uKp,isBuffer:BKD,isFormData:VKD,isArrayBufferView:IKD,isString:zKD,isNumber:sKp,isBoolean:xKD,isObject:yQo,isPlainObject:dQo,isReadableStream:HKD,isRequest:$KD,isResponse:GKD,isHeaders:QKD,isUndefined:iFa,isDate:RKD,isFile:NKD,isBlob:FKD,isRegExp:oYD,isFunction:mue,isStream:UKD,isURLSearchParams:WKD,isTypedArray:tYD,isFileList:LKD,forEach:nFa,merge:_pc,extend:KKD,trim:JKD,stripBOM:YKD,inherits:XKD,toFlatObject:ZKD,kindOf:_Qo,kindOfTest:kGt,endsWith:kKD,toArray:eYD,forEachEntry:rYD,matchAll:iYD,isHTMLForm:nYD,hasOwnProperty:aKp,hasOwnProp:aKp,reduceDescriptors:fKp,freezeMethods:uYD,toObjectSet:sYD,toCamelCase:aYD,noop:cYD,toFiniteNumber:lYD,findKey:cKp,global:Ytn,isContextDefined:lKp,isSpecCompliantForm:fYD,toJSONObject:dYD,isAsyncFn:pYD,isThenable:_YD,setImmediate:dKp,asap:hYD,isIterable:yYD};function _Hn(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)}hs.inherits(_Hn,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:hs.toJSONObject(this.config),code:this.code,status:this.status}}});var pKp=_Hn.prototype,_Kp={};["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=>{_Kp[e]={value:e}});Object.defineProperties(_Hn,_Kp);Object.defineProperty(pKp,"isAxiosError",{value:!0});_Hn.from=(e,t,r,i,n,a)=>{let u=Object.create(pKp);return hs.toFlatObject(e,u,function(d){return d!==Error.prototype},c=>c!=="isAxiosError"),_Hn.call(u,e.message,t,r,i,n),u.cause=e,u.name=e.name,a&&Object.assign(u,a),u};var o_=_Hn;var hKp=ci(RGo(),1),vQo=hKp.default;function ypc(e){return hs.isPlainObject(e)||hs.isArray(e)}function vKp(e){return hs.endsWith(e,"[]")?e.slice(0,-2):e}function yKp(e,t,r){return e?e.concat(t).map(function(n,a){return n=vKp(n),!r&&a?"["+n+"]":n}).join(r?".":""):t}function vYD(e){return hs.isArray(e)&&!e.some(ypc)}var bYD=hs.toFlatObject(hs,{},null,function(t){return/^is[A-Z]/.test(t)});function gYD(e,t,r){if(!hs.isObject(e))throw new TypeError("target must be an object");t=t||new(vQo||FormData),r=hs.toFlatObject(r,{metaTokens:!0,dots:!1,indexes:!1},!1,function(m,P){return!hs.isUndefined(P[m])});let i=r.metaTokens,n=r.visitor||o,a=r.dots,u=r.indexes,d=(r.Blob||typeof Blob<"u"&&Blob)&&hs.isSpecCompliantForm(t);if(!hs.isFunction(n))throw new TypeError("visitor must be a function");function s(O){if(O===null)return"";if(hs.isDate(O))return O.toISOString();if(hs.isBoolean(O))return O.toString();if(!d&&hs.isBlob(O))throw new o_("Blob is not supported. Use a Buffer instead.");return hs.isArrayBuffer(O)||hs.isTypedArray(O)?d&&typeof Blob=="function"?new Blob([O]):Buffer.from(O):O}function o(O,m,P){let D=O;if(O&&!P&&typeof O=="object"){if(hs.endsWith(m,"{}"))m=i?m:m.slice(0,-2),O=JSON.stringify(O);else if(hs.isArray(O)&&vYD(O)||(hs.isFileList(O)||hs.endsWith(m,"[]"))&&(D=hs.toArray(O)))return m=vKp(m),D.forEach(function(M,E){!(hs.isUndefined(M)||M===null)&&t.append(u===!0?yKp([m],E,a):u===null?m:m+"[]",s(M))}),!1}return ypc(O)?!0:(t.append(yKp(P,m,a),s(O)),!1)}let l=[],b=Object.assign(bYD,{defaultVisitor:o,convertValue:s,isVisitable:ypc});function g(O,m){if(!hs.isUndefined(O)){if(l.indexOf(O)!==-1)throw Error("Circular reference detected in "+m.join("."));l.push(O),hs.forEach(O,function(D,A){(!(hs.isUndefined(D)||D===null)&&n.call(t,D,hs.isString(A)?A.trim():A,m,b))===!0&&g(D,m?m.concat(A):[A])}),l.pop()}}if(!hs.isObject(e))throw new TypeError("data must be an object");return g(e),t}var Lxi=gYD;function bKp(e){let t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(i){return t[i]})}function gKp(e,t){this._pairs=[],e&&Lxi(e,this,t)}var OKp=gKp.prototype;OKp.append=function(t,r){this._pairs.push([t,r])};OKp.toString=function(t){let r=t?function(i){return t.call(this,i,bKp)}:bKp;return this._pairs.map(function(n){return r(n[0])+"="+r(n[1])},"").join("&")};var mKp=gKp;function OYD(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function Xtn(e,t,r){if(!t)return e;let i=r&&r.encode||OYD;hs.isFunction(r)&&(r={serialize:r});let n=r&&r.serialize,a;if(n?a=n(t,r):a=hs.isURLSearchParams(t)?t.toString():new mKp(t,r).toString(i),a){let u=e.indexOf("#");u!==-1&&(e=e.slice(0,u)),e+=(e.indexOf("?")===-1?"?":"&")+a}return e}var vpc=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){hs.forEach(this.handlers,function(i){i!==null&&t(i)})}},bpc=vpc;var hHn={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1};var SKp=ci(require("crypto"),1);var PKp=ci(require("url"),1),jKp=PKp.default.URLSearchParams;var gpc="abcdefghijklmnopqrstuvwxyz",wKp="0123456789",DKp={DIGIT:wKp,ALPHA:gpc,ALPHA_DIGIT:gpc+gpc.toUpperCase()+wKp},mYD=(e=16,t=DKp.ALPHA_DIGIT)=>{let r="",{length:i}=t,n=new Uint32Array(e);SKp.default.randomFillSync(n);for(let a=0;a<e;a++)r+=t[n[a]%i];return r},EKp={isNode:!0,classes:{URLSearchParams:jKp,FormData:vQo,Blob:typeof Blob<"u"&&Blob||null},ALPHABET:DKp,generateString:mYD,protocols:["http","https","file","data"]};var Ppc={};xa(Ppc,{hasBrowserEnv:()=>mpc,hasStandardBrowserEnv:()=>PYD,hasStandardBrowserWebWorkerEnv:()=>jYD,navigator:()=>Opc,origin:()=>wYD});var mpc=typeof window<"u"&&typeof document<"u",Opc=typeof navigator=="object"&&navigator||void 0,PYD=mpc&&(!Opc||["ReactNative","NativeScript","NS"].indexOf(Opc.product)<0),jYD=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",wYD=mpc&&window.location.href||"http://localhost";var lq={...Ppc,...EKp};function jpc(e,t){return Lxi(e,new lq.classes.URLSearchParams,Object.assign({visitor:function(r,i,n,a){return lq.isNode&&hs.isBuffer(r)?(this.append(i,r.toString("base64")),!1):a.defaultVisitor.apply(this,arguments)}},t))}function SYD(e){return hs.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function DYD(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 EYD(e){function t(r,i,n,a){let u=r[a++];if(u==="__proto__")return!0;let c=Number.isFinite(+u),d=a>=r.length;return u=!u&&hs.isArray(n)?n.length:u,d?(hs.hasOwnProp(n,u)?n[u]=[n[u],i]:n[u]=i,!c):((!n[u]||!hs.isObject(n[u]))&&(n[u]=[]),t(r,i,n[u],a)&&hs.isArray(n[u])&&(n[u]=DYD(n[u])),!c)}if(hs.isFormData(e)&&hs.isFunction(e.entries)){let r={};return hs.forEachEntry(e,(i,n)=>{t(SYD(i),n,r,0)}),r}return null}var bQo=EYD;function MYD(e,t,r){if(hs.isString(e))try{return(t||JSON.parse)(e),hs.trim(e)}catch(i){if(i.name!=="SyntaxError")throw i}return(r||JSON.stringify)(e)}var wpc={transitional:hHn,adapter:["xhr","http","fetch"],transformRequest:[function(t,r){let i=r.getContentType()||"",n=i.indexOf("application/json")>-1,a=hs.isObject(t);if(a&&hs.isHTMLForm(t)&&(t=new FormData(t)),hs.isFormData(t))return n?JSON.stringify(bQo(t)):t;if(hs.isArrayBuffer(t)||hs.isBuffer(t)||hs.isStream(t)||hs.isFile(t)||hs.isBlob(t)||hs.isReadableStream(t))return t;if(hs.isArrayBufferView(t))return t.buffer;if(hs.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 jpc(t,this.formSerializer).toString();if((c=hs.isFileList(t))||i.indexOf("multipart/form-data")>-1){let d=this.env&&this.env.FormData;return Lxi(c?{"files[]":t}:t,d&&new d,this.formSerializer)}}return a||n?(r.setContentType("application/json",!1),MYD(t)):t}],transformResponse:[function(t){let r=this.transitional||wpc.transitional,i=r&&r.forcedJSONParsing,n=this.responseType==="json";if(hs.isResponse(t)||hs.isReadableStream(t))return t;if(t&&hs.isString(t)&&(i&&!this.responseType||n)){let u=!(r&&r.silentJSONParsing)&&n;try{return JSON.parse(t)}catch(c){if(u)throw c.name==="SyntaxError"?o_.from(c,o_.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:lq.classes.FormData,Blob:lq.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};hs.forEach(["delete","get","head","post","put","patch"],e=>{wpc.headers[e]={}});var yHn=wpc;var AYD=hs.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"]),MKp=e=>{let t={},r,i,n;return e&&e.split(`
|
|
1713
|
+
`);for(let c=n;c<u.length;c++){let d=u[c];if(d.length>1024)continue;let s=xJp.test(d)?d.replace(xJp,"$1"):d;if(!s.match(/\S*Error: /)){for(let o of r){let l=o(s);if(l){a.push(l);break}}if(a.length>=ZJp)break}}return DKD(a)}}function DKD(e){if(!e.length)return[];let t=Array.from(e);return t.reverse(),t.slice(0,ZJp).map(r=>({...r,filename:r.filename||EKD(t).filename,function:r.function||kJp}))}function EKD(e){return e[e.length-1]||{}}uHn.stackParser=SKD(RJD());uHn.frameModifiers=[LJD];var cHn=class extends upc{getLibraryId(){return"posthog-node"}};var cQo=class{posthog;constructor({posthogApiKey:t}){this.posthog=new cHn(t)}async identify(){}async sendEvent(t){t.orgId!=null&&this.posthog.capture({distinctId:t.orgId,event:"CLI",properties:{...t,...t.properties,version:"0.69.1",usingAccessToken:!0}})}async flush(){await this.posthog.flush()}};var eFa=class{async sendEvent(){}async identify(){}async flush(){}};var fHn=require("fs/promises"),iKp=require("os"),nKp=require("path");var eKp=ci(require("crypto")),fQo=new Uint8Array(256),lQo=fQo.length;function fpc(){return lQo>fQo.length-16&&(eKp.default.randomFillSync(fQo),lQo=0),fQo.slice(lQo,lQo+=16)}var d$=[];for(let e=0;e<256;++e)d$.push((e+256).toString(16).slice(1));function tKp(e,t=0){return d$[e[t+0]]+d$[e[t+1]]+d$[e[t+2]]+d$[e[t+3]]+"-"+d$[e[t+4]]+d$[e[t+5]]+"-"+d$[e[t+6]]+d$[e[t+7]]+"-"+d$[e[t+8]]+d$[e[t+9]]+"-"+d$[e[t+10]]+d$[e[t+11]]+d$[e[t+12]]+d$[e[t+13]]+d$[e[t+14]]+d$[e[t+15]]}var rKp=ci(require("crypto")),dpc={randomUUID:rKp.default.randomUUID};function MKD(e,t,r){if(dpc.randomUUID&&!t&&!e)return dpc.randomUUID();e=e||{};let i=e.random||(e.rng||fpc)();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 tKp(i)}var Oue=MKD;var AKD="id",qKD=".fern",tFa=class{posthog;userId;constructor({token:t,posthogApiKey:r}){this.posthog=new cHn(r),this.userId=t==null?void 0:Xac(t)}async identify(){this.userId!=null&&this.posthog.alias({distinctId:this.userId,alias:await this.getPersistedDistinctId()})}async sendEvent(t){this.posthog.capture({distinctId:this.userId??await this.getPersistedDistinctId(),event:"CLI",properties:{version:"0.69.1",...t,...t.properties}})}async flush(){await this.posthog.flush()}persistedDistinctId;async getPersistedDistinctId(){if(this.persistedDistinctId==null){let t=Bu($c.of((0,iKp.homedir)()),za.of(qKD),za.of(AKD));await Cf(t)||(await(0,fHn.mkdir)((0,nKp.dirname)(t),{recursive:!0}),await(0,fHn.writeFile)(t,Oue())),this.persistedDistinctId=(await(0,fHn.readFile)(t)).toString()}return this.persistedDistinctId}};var ppc;async function dHn(){return ppc==null&&(ppc=await TKD()),ppc}async function TKD(){try{let e="phc_yQgAEdJJkVpI24NdSRID2mor1x1leRpDoC9yZ9mfXal",t=process.env.FERN_DISABLE_TELEMETRY==="true";if(e==null||t)return new eFa;let r=await ELo();return r!=null?new tFa({token:r,posthogApiKey:e}):await sVn()!=null?new cQo({posthogApiKey:e}):new tFa({token:void 0,posthogApiKey:e})}catch{return new eFa}}function rFa(e,t){return function(){return e.apply(t,arguments)}}var{toString:CKD}=Object.prototype,{getPrototypeOf:hpc}=Object,{iterator:pQo,toStringTag:oKp}=Symbol,_Qo=(e=>t=>{let r=CKD.call(t);return e[r]||(e[r]=r.slice(8,-1).toLowerCase())})(Object.create(null)),kGt=e=>(e=e.toLowerCase(),t=>_Qo(t)===e),hQo=e=>t=>typeof t===e,{isArray:pHn}=Array,iFa=hQo("undefined");function BKD(e){return e!==null&&!iFa(e)&&e.constructor!==null&&!iFa(e.constructor)&&mue(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}var uKp=kGt("ArrayBuffer");function IKD(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&uKp(e.buffer),t}var zKD=hQo("string"),mue=hQo("function"),sKp=hQo("number"),yQo=e=>e!==null&&typeof e=="object",xKD=e=>e===!0||e===!1,dQo=e=>{if(_Qo(e)!=="object")return!1;let t=hpc(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(oKp in e)&&!(pQo in e)},RKD=kGt("Date"),NKD=kGt("File"),FKD=kGt("Blob"),LKD=kGt("FileList"),UKD=e=>yQo(e)&&mue(e.pipe),VKD=e=>{let t;return e&&(typeof FormData=="function"&&e instanceof FormData||mue(e.append)&&((t=_Qo(e))==="formdata"||t==="object"&&mue(e.toString)&&e.toString()==="[object FormData]"))},WKD=kGt("URLSearchParams"),[HKD,$KD,GKD,QKD]=["ReadableStream","Request","Response","Headers"].map(kGt),JKD=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function nFa(e,t,{allOwnKeys:r=!1}={}){if(e===null||typeof e>"u")return;let i,n;if(typeof e!="object"&&(e=[e]),pHn(e))for(i=0,n=e.length;i<n;i++)t.call(null,e[i],i,e);else{let a=r?Object.getOwnPropertyNames(e):Object.keys(e),u=a.length,c;for(i=0;i<u;i++)c=a[i],t.call(null,e[c],c,e)}}function cKp(e,t){t=t.toLowerCase();let r=Object.keys(e),i=r.length,n;for(;i-- >0;)if(n=r[i],t===n.toLowerCase())return n;return null}var Ytn=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,lKp=e=>!iFa(e)&&e!==Ytn;function _pc(){let{caseless:e}=lKp(this)&&this||{},t={},r=(i,n)=>{let a=e&&cKp(t,n)||n;dQo(t[a])&&dQo(i)?t[a]=_pc(t[a],i):dQo(i)?t[a]=_pc({},i):pHn(i)?t[a]=i.slice():t[a]=i};for(let i=0,n=arguments.length;i<n;i++)arguments[i]&&nFa(arguments[i],r);return t}var KKD=(e,t,r,{allOwnKeys:i}={})=>(nFa(t,(n,a)=>{r&&mue(n)?e[a]=rFa(n,r):e[a]=n},{allOwnKeys:i}),e),YKD=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),XKD=(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)},ZKD=(e,t,r,i)=>{let n,a,u,c={};if(t=t||{},e==null)return t;do{for(n=Object.getOwnPropertyNames(e),a=n.length;a-- >0;)u=n[a],(!i||i(u,e,t))&&!c[u]&&(t[u]=e[u],c[u]=!0);e=r!==!1&&hpc(e)}while(e&&(!r||r(e,t))&&e!==Object.prototype);return t},kKD=(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},eYD=e=>{if(!e)return null;if(pHn(e))return e;let t=e.length;if(!sKp(t))return null;let r=new Array(t);for(;t-- >0;)r[t]=e[t];return r},tYD=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&hpc(Uint8Array)),rYD=(e,t)=>{let i=(e&&e[pQo]).call(e),n;for(;(n=i.next())&&!n.done;){let a=n.value;t.call(e,a[0],a[1])}},iYD=(e,t)=>{let r,i=[];for(;(r=e.exec(t))!==null;)i.push(r);return i},nYD=kGt("HTMLFormElement"),aYD=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(r,i,n){return i.toUpperCase()+n}),aKp=(({hasOwnProperty:e})=>(t,r)=>e.call(t,r))(Object.prototype),oYD=kGt("RegExp"),fKp=(e,t)=>{let r=Object.getOwnPropertyDescriptors(e),i={};nFa(r,(n,a)=>{let u;(u=t(n,a,e))!==!1&&(i[a]=u||n)}),Object.defineProperties(e,i)},uYD=e=>{fKp(e,(t,r)=>{if(mue(e)&&["arguments","caller","callee"].indexOf(r)!==-1)return!1;let i=e[r];if(mue(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+"'")})}})},sYD=(e,t)=>{let r={},i=n=>{n.forEach(a=>{r[a]=!0})};return pHn(e)?i(e):i(String(e).split(t)),r},cYD=()=>{},lYD=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t;function fYD(e){return!!(e&&mue(e.append)&&e[oKp]==="FormData"&&e[pQo])}var dYD=e=>{let t=new Array(10),r=(i,n)=>{if(yQo(i)){if(t.indexOf(i)>=0)return;if(!("toJSON"in i)){t[n]=i;let a=pHn(i)?[]:{};return nFa(i,(u,c)=>{let d=r(u,n+1);!iFa(d)&&(a[c]=d)}),t[n]=void 0,a}}return i};return r(e,0)},pYD=kGt("AsyncFunction"),_YD=e=>e&&(yQo(e)||mue(e))&&mue(e.then)&&mue(e.catch),dKp=((e,t)=>e?setImmediate:t?((r,i)=>(Ytn.addEventListener("message",({source:n,data:a})=>{n===Ytn&&a===r&&i.length&&i.shift()()},!1),n=>{i.push(n),Ytn.postMessage(r,"*")}))(`axios@${Math.random()}`,[]):r=>setTimeout(r))(typeof setImmediate=="function",mue(Ytn.postMessage)),hYD=typeof queueMicrotask<"u"?queueMicrotask.bind(Ytn):typeof process<"u"&&process.nextTick||dKp,yYD=e=>e!=null&&mue(e[pQo]),hs={isArray:pHn,isArrayBuffer:uKp,isBuffer:BKD,isFormData:VKD,isArrayBufferView:IKD,isString:zKD,isNumber:sKp,isBoolean:xKD,isObject:yQo,isPlainObject:dQo,isReadableStream:HKD,isRequest:$KD,isResponse:GKD,isHeaders:QKD,isUndefined:iFa,isDate:RKD,isFile:NKD,isBlob:FKD,isRegExp:oYD,isFunction:mue,isStream:UKD,isURLSearchParams:WKD,isTypedArray:tYD,isFileList:LKD,forEach:nFa,merge:_pc,extend:KKD,trim:JKD,stripBOM:YKD,inherits:XKD,toFlatObject:ZKD,kindOf:_Qo,kindOfTest:kGt,endsWith:kKD,toArray:eYD,forEachEntry:rYD,matchAll:iYD,isHTMLForm:nYD,hasOwnProperty:aKp,hasOwnProp:aKp,reduceDescriptors:fKp,freezeMethods:uYD,toObjectSet:sYD,toCamelCase:aYD,noop:cYD,toFiniteNumber:lYD,findKey:cKp,global:Ytn,isContextDefined:lKp,isSpecCompliantForm:fYD,toJSONObject:dYD,isAsyncFn:pYD,isThenable:_YD,setImmediate:dKp,asap:hYD,isIterable:yYD};function _Hn(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)}hs.inherits(_Hn,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:hs.toJSONObject(this.config),code:this.code,status:this.status}}});var pKp=_Hn.prototype,_Kp={};["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=>{_Kp[e]={value:e}});Object.defineProperties(_Hn,_Kp);Object.defineProperty(pKp,"isAxiosError",{value:!0});_Hn.from=(e,t,r,i,n,a)=>{let u=Object.create(pKp);return hs.toFlatObject(e,u,function(d){return d!==Error.prototype},c=>c!=="isAxiosError"),_Hn.call(u,e.message,t,r,i,n),u.cause=e,u.name=e.name,a&&Object.assign(u,a),u};var o_=_Hn;var hKp=ci(RGo(),1),vQo=hKp.default;function ypc(e){return hs.isPlainObject(e)||hs.isArray(e)}function vKp(e){return hs.endsWith(e,"[]")?e.slice(0,-2):e}function yKp(e,t,r){return e?e.concat(t).map(function(n,a){return n=vKp(n),!r&&a?"["+n+"]":n}).join(r?".":""):t}function vYD(e){return hs.isArray(e)&&!e.some(ypc)}var bYD=hs.toFlatObject(hs,{},null,function(t){return/^is[A-Z]/.test(t)});function gYD(e,t,r){if(!hs.isObject(e))throw new TypeError("target must be an object");t=t||new(vQo||FormData),r=hs.toFlatObject(r,{metaTokens:!0,dots:!1,indexes:!1},!1,function(m,P){return!hs.isUndefined(P[m])});let i=r.metaTokens,n=r.visitor||o,a=r.dots,u=r.indexes,d=(r.Blob||typeof Blob<"u"&&Blob)&&hs.isSpecCompliantForm(t);if(!hs.isFunction(n))throw new TypeError("visitor must be a function");function s(O){if(O===null)return"";if(hs.isDate(O))return O.toISOString();if(hs.isBoolean(O))return O.toString();if(!d&&hs.isBlob(O))throw new o_("Blob is not supported. Use a Buffer instead.");return hs.isArrayBuffer(O)||hs.isTypedArray(O)?d&&typeof Blob=="function"?new Blob([O]):Buffer.from(O):O}function o(O,m,P){let D=O;if(O&&!P&&typeof O=="object"){if(hs.endsWith(m,"{}"))m=i?m:m.slice(0,-2),O=JSON.stringify(O);else if(hs.isArray(O)&&vYD(O)||(hs.isFileList(O)||hs.endsWith(m,"[]"))&&(D=hs.toArray(O)))return m=vKp(m),D.forEach(function(M,E){!(hs.isUndefined(M)||M===null)&&t.append(u===!0?yKp([m],E,a):u===null?m:m+"[]",s(M))}),!1}return ypc(O)?!0:(t.append(yKp(P,m,a),s(O)),!1)}let l=[],b=Object.assign(bYD,{defaultVisitor:o,convertValue:s,isVisitable:ypc});function g(O,m){if(!hs.isUndefined(O)){if(l.indexOf(O)!==-1)throw Error("Circular reference detected in "+m.join("."));l.push(O),hs.forEach(O,function(D,A){(!(hs.isUndefined(D)||D===null)&&n.call(t,D,hs.isString(A)?A.trim():A,m,b))===!0&&g(D,m?m.concat(A):[A])}),l.pop()}}if(!hs.isObject(e))throw new TypeError("data must be an object");return g(e),t}var Lxi=gYD;function bKp(e){let t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(i){return t[i]})}function gKp(e,t){this._pairs=[],e&&Lxi(e,this,t)}var OKp=gKp.prototype;OKp.append=function(t,r){this._pairs.push([t,r])};OKp.toString=function(t){let r=t?function(i){return t.call(this,i,bKp)}:bKp;return this._pairs.map(function(n){return r(n[0])+"="+r(n[1])},"").join("&")};var mKp=gKp;function OYD(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function Xtn(e,t,r){if(!t)return e;let i=r&&r.encode||OYD;hs.isFunction(r)&&(r={serialize:r});let n=r&&r.serialize,a;if(n?a=n(t,r):a=hs.isURLSearchParams(t)?t.toString():new mKp(t,r).toString(i),a){let u=e.indexOf("#");u!==-1&&(e=e.slice(0,u)),e+=(e.indexOf("?")===-1?"?":"&")+a}return e}var vpc=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){hs.forEach(this.handlers,function(i){i!==null&&t(i)})}},bpc=vpc;var hHn={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1};var SKp=ci(require("crypto"),1);var PKp=ci(require("url"),1),jKp=PKp.default.URLSearchParams;var gpc="abcdefghijklmnopqrstuvwxyz",wKp="0123456789",DKp={DIGIT:wKp,ALPHA:gpc,ALPHA_DIGIT:gpc+gpc.toUpperCase()+wKp},mYD=(e=16,t=DKp.ALPHA_DIGIT)=>{let r="",{length:i}=t,n=new Uint32Array(e);SKp.default.randomFillSync(n);for(let a=0;a<e;a++)r+=t[n[a]%i];return r},EKp={isNode:!0,classes:{URLSearchParams:jKp,FormData:vQo,Blob:typeof Blob<"u"&&Blob||null},ALPHABET:DKp,generateString:mYD,protocols:["http","https","file","data"]};var Ppc={};xa(Ppc,{hasBrowserEnv:()=>mpc,hasStandardBrowserEnv:()=>PYD,hasStandardBrowserWebWorkerEnv:()=>jYD,navigator:()=>Opc,origin:()=>wYD});var mpc=typeof window<"u"&&typeof document<"u",Opc=typeof navigator=="object"&&navigator||void 0,PYD=mpc&&(!Opc||["ReactNative","NativeScript","NS"].indexOf(Opc.product)<0),jYD=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",wYD=mpc&&window.location.href||"http://localhost";var lq={...Ppc,...EKp};function jpc(e,t){return Lxi(e,new lq.classes.URLSearchParams,Object.assign({visitor:function(r,i,n,a){return lq.isNode&&hs.isBuffer(r)?(this.append(i,r.toString("base64")),!1):a.defaultVisitor.apply(this,arguments)}},t))}function SYD(e){return hs.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function DYD(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 EYD(e){function t(r,i,n,a){let u=r[a++];if(u==="__proto__")return!0;let c=Number.isFinite(+u),d=a>=r.length;return u=!u&&hs.isArray(n)?n.length:u,d?(hs.hasOwnProp(n,u)?n[u]=[n[u],i]:n[u]=i,!c):((!n[u]||!hs.isObject(n[u]))&&(n[u]=[]),t(r,i,n[u],a)&&hs.isArray(n[u])&&(n[u]=DYD(n[u])),!c)}if(hs.isFormData(e)&&hs.isFunction(e.entries)){let r={};return hs.forEachEntry(e,(i,n)=>{t(SYD(i),n,r,0)}),r}return null}var bQo=EYD;function MYD(e,t,r){if(hs.isString(e))try{return(t||JSON.parse)(e),hs.trim(e)}catch(i){if(i.name!=="SyntaxError")throw i}return(r||JSON.stringify)(e)}var wpc={transitional:hHn,adapter:["xhr","http","fetch"],transformRequest:[function(t,r){let i=r.getContentType()||"",n=i.indexOf("application/json")>-1,a=hs.isObject(t);if(a&&hs.isHTMLForm(t)&&(t=new FormData(t)),hs.isFormData(t))return n?JSON.stringify(bQo(t)):t;if(hs.isArrayBuffer(t)||hs.isBuffer(t)||hs.isStream(t)||hs.isFile(t)||hs.isBlob(t)||hs.isReadableStream(t))return t;if(hs.isArrayBufferView(t))return t.buffer;if(hs.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 jpc(t,this.formSerializer).toString();if((c=hs.isFileList(t))||i.indexOf("multipart/form-data")>-1){let d=this.env&&this.env.FormData;return Lxi(c?{"files[]":t}:t,d&&new d,this.formSerializer)}}return a||n?(r.setContentType("application/json",!1),MYD(t)):t}],transformResponse:[function(t){let r=this.transitional||wpc.transitional,i=r&&r.forcedJSONParsing,n=this.responseType==="json";if(hs.isResponse(t)||hs.isReadableStream(t))return t;if(t&&hs.isString(t)&&(i&&!this.responseType||n)){let u=!(r&&r.silentJSONParsing)&&n;try{return JSON.parse(t)}catch(c){if(u)throw c.name==="SyntaxError"?o_.from(c,o_.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:lq.classes.FormData,Blob:lq.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};hs.forEach(["delete","get","head","post","put","patch"],e=>{wpc.headers[e]={}});var yHn=wpc;var AYD=hs.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"]),MKp=e=>{let t={},r,i,n;return e&&e.split(`
|
|
1714
1714
|
`).forEach(function(u){n=u.indexOf(":"),r=u.substring(0,n).trim().toLowerCase(),i=u.substring(n+1).trim(),!(!r||t[r]&&AYD[r])&&(r==="set-cookie"?t[r]?t[r].push(i):t[r]=[i]:t[r]=t[r]?t[r]+", "+i:i)}),t};var AKp=Symbol("internals");function aFa(e){return e&&String(e).trim().toLowerCase()}function gQo(e){return e===!1||e==null?e:hs.isArray(e)?e.map(gQo):String(e)}function qYD(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 TYD=e=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim());function Spc(e,t,r,i,n){if(hs.isFunction(i))return i.call(this,t,r);if(n&&(t=r),!!hs.isString(t)){if(hs.isString(i))return t.indexOf(i)!==-1;if(hs.isRegExp(i))return i.test(t)}}function CYD(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(t,r,i)=>r.toUpperCase()+i)}function BYD(e,t){let r=hs.toCamelCase(" "+t);["get","set","has"].forEach(i=>{Object.defineProperty(e,i+r,{value:function(n,a,u){return this[i].call(this,t,n,a,u)},configurable:!0})})}var vHn=class{constructor(t){t&&this.set(t)}set(t,r,i){let n=this;function a(c,d,s){let o=aFa(d);if(!o)throw new Error("header name must be a non-empty string");let l=hs.findKey(n,o);(!l||n[l]===void 0||s===!0||s===void 0&&n[l]!==!1)&&(n[l||d]=gQo(c))}let u=(c,d)=>hs.forEach(c,(s,o)=>a(s,o,d));if(hs.isPlainObject(t)||t instanceof this.constructor)u(t,r);else if(hs.isString(t)&&(t=t.trim())&&!TYD(t))u(MKp(t),r);else if(hs.isObject(t)&&hs.isIterable(t)){let c={},d,s;for(let o of t){if(!hs.isArray(o))throw TypeError("Object iterator must return a key-value pair");c[s=o[0]]=(d=c[s])?hs.isArray(d)?[...d,o[1]]:[d,o[1]]:o[1]}u(c,r)}else t!=null&&a(r,t,i);return this}get(t,r){if(t=aFa(t),t){let i=hs.findKey(this,t);if(i){let n=this[i];if(!r)return n;if(r===!0)return qYD(n);if(hs.isFunction(r))return r.call(this,n,i);if(hs.isRegExp(r))return r.exec(n);throw new TypeError("parser must be boolean|regexp|function")}}}has(t,r){if(t=aFa(t),t){let i=hs.findKey(this,t);return!!(i&&this[i]!==void 0&&(!r||Spc(this,this[i],i,r)))}return!1}delete(t,r){let i=this,n=!1;function a(u){if(u=aFa(u),u){let c=hs.findKey(i,u);c&&(!r||Spc(i,i[c],c,r))&&(delete i[c],n=!0)}}return hs.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||Spc(this,this[a],a,t,!0))&&(delete this[a],n=!0)}return n}normalize(t){let r=this,i={};return hs.forEach(this,(n,a)=>{let u=hs.findKey(i,a);if(u){r[u]=gQo(n),delete r[a];return}let c=t?CYD(a):String(a).trim();c!==a&&delete r[a],r[c]=gQo(n),i[c]=!0}),this}concat(...t){return this.constructor.concat(this,...t)}toJSON(t){let r=Object.create(null);return hs.forEach(this,(i,n)=>{i!=null&&i!==!1&&(r[n]=t&&hs.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(`
|
|
1715
1715
|
`)}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[AKp]=this[AKp]={accessors:{}}).accessors,n=this.prototype;function a(u){let c=aFa(u);i[c]||(BYD(n,u),i[c]=!0)}return hs.isArray(t)?t.forEach(a):a(t),this}};vHn.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]);hs.reduceDescriptors(vHn.prototype,({value:e},t)=>{let r=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(i){this[r]=i}}});hs.freezeMethods(vHn);var mN=vHn;function oFa(e,t){let r=this||yHn,i=t||r,n=mN.from(i.headers),a=i.data;return hs.forEach(e,function(c){a=c.call(r,a,n.normalize(),t?t.status:void 0)}),n.normalize(),a}function uFa(e){return!!(e&&e.__CANCEL__)}function qKp(e,t,r){o_.call(this,e??"canceled",o_.ERR_CANCELED,t,r),this.name="CanceledError"}hs.inherits(qKp,o_,{__CANCEL__:!0});var nqe=qKp;function har(e,t,r){let i=r.config.validateStatus;!r.status||!i||i(r.status)?e(r):t(new o_("Request failed with status code "+r.status,[o_.ERR_BAD_REQUEST,o_.ERR_BAD_RESPONSE][Math.floor(r.status/100)-4],r.config,r.request,r))}function Dpc(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function Epc(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}function Ztn(e,t,r){let i=!Dpc(t);return e&&(i||r==!1)?Epc(e,t):t}var GKp=ci(W7a(),1),QKp=ci(require("http"),1),JKp=ci(require("https"),1),KKp=ci(require("util"),1),YKp=ci(Edc(),1),HOi=ci(require("zlib"),1);var ktn="1.10.0";function sFa(e){let t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}var IYD=/^(?:([^;]+);)?(?:[^;]+;)?(base64|),([\s\S]*)$/;function Mpc(e,t,r){let i=r&&r.Blob||lq.classes.Blob,n=sFa(e);if(t===void 0&&i&&(t=!0),n==="data"){e=n.length?e.slice(n.length+1):e;let a=IYD.exec(e);if(!a)throw new o_("Invalid URL",o_.ERR_INVALID_URL);let u=a[1],c=a[2],d=a[3],s=Buffer.from(decodeURIComponent(d),c?"base64":"utf8");if(t){if(!i)throw new o_("Blob is not supported",o_.ERR_NOT_SUPPORT);return new i([s],{type:u})}return s}throw new o_("Unsupported protocol "+n,o_.ERR_NOT_SUPPORT)}var trn=ci(require("stream"),1);var TKp=ci(require("stream"),1);var Apc=Symbol("internals"),qpc=class extends TKp.default.Transform{constructor(t){t=hs.toFlatObject(t,{maxRate:0,chunkSize:64*1024,minChunkSize:100,timeWindow:500,ticksRate:2,samplesCount:15},null,(i,n)=>!hs.isUndefined(n[i])),super({readableHighWaterMark:t.chunkSize});let r=this[Apc]={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[Apc];return r.onReadCallback&&r.onReadCallback(),super._read(t)}_transform(t,r,i){let n=this[Apc],a=n.maxRate,u=this.readableHighWaterMark,c=n.timeWindow,d=1e3/c,s=a/d,o=n.minChunkSize!==!1?Math.max(n.minChunkSize,s*.01):0,l=(g,O)=>{let m=Buffer.byteLength(g);n.bytesSeen+=m,n.bytes+=m,n.isCaptured&&this.emit("progress",n.bytesSeen),this.push(g)?process.nextTick(O):n.onReadCallback=()=>{n.onReadCallback=null,process.nextTick(O)}},b=(g,O)=>{let m=Buffer.byteLength(g),P=null,D=u,A,M=0;if(a){let E=Date.now();(!n.ts||(M=E-n.ts)>=c)&&(n.ts=E,A=s-n.bytes,n.bytes=A<0?-A:0,M=0),A=s-n.bytes}if(a){if(A<=0)return setTimeout(()=>{O(null,g)},c-M);A<D&&(D=A)}D&&m>D&&m-D>o&&(P=g.subarray(D),g=g.subarray(0,D)),l(g,P?()=>{process.nextTick(O,null,P)}:O)};b(t,function g(O,m){if(O)return i(O);m?b(m,g):i(null)})}},Tpc=qpc;var XKp=require("events");var BKp=ci(require("util"),1),IKp=require("stream");var{asyncIterator:CKp}=Symbol,zYD=async function*(e){e.stream?yield*e.stream():e.arrayBuffer?yield await e.arrayBuffer():e[CKp]?yield*e[CKp]():yield e},OQo=zYD;var xYD=lq.ALPHABET.ALPHA_DIGIT+"-_",cFa=typeof TextEncoder=="function"?new TextEncoder:new BKp.default.TextEncoder,ern=`\r
|
|
1716
1716
|
`,RYD=cFa.encode(ern),NYD=2,Cpc=class{constructor(t,r){let{escapeName:i}=this.constructor,n=hs.isString(r),a=`Content-Disposition: form-data; name="${i(t)}"${!n&&r.name?`; filename="${i(r.name)}"`:""}${ern}`;n?r=cFa.encode(String(r).replace(/\r?\n|\r\n?/g,ern)):a+=`Content-Type: ${r.type||"application/octet-stream"}${ern}`,this.headers=cFa.encode(a+ern),this.contentLength=n?r.byteLength:r.size,this.size=this.headers.byteLength+this.contentLength+NYD,this.name=t,this.value=r}async*encode(){yield this.headers;let{value:t}=this;hs.isTypedArray(t)?yield t:yield*OQo(t),yield RYD}static escapeName(t){return String(t).replace(/[\r\n"]/g,r=>({"\r":"%0D","\n":"%0A",'"':"%22"})[r])}},FYD=(e,t,r)=>{let{tag:i="form-data-boundary",size:n=25,boundary:a=i+"-"+lq.generateString(n,xYD)}=r||{};if(!hs.isFormData(e))throw TypeError("FormData instance required");if(a.length<1||a.length>70)throw Error("boundary must be 10-70 characters long");let u=cFa.encode("--"+a+ern),c=cFa.encode("--"+a+"--"+ern),d=c.byteLength,s=Array.from(e.entries()).map(([l,b])=>{let g=new Cpc(l,b);return d+=g.size,g});d+=u.byteLength*s.length,d=hs.toFiniteNumber(d);let o={"Content-Type":`multipart/form-data; boundary=${a}`};return Number.isFinite(d)&&(o["Content-Length"]=d),t&&t(o),IKp.Readable.from(async function*(){for(let l of s)yield u,yield*l.encode();yield c}())},zKp=FYD;var xKp=ci(require("stream"),1),Bpc=class extends xKp.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)}},RKp=Bpc;var LYD=(e,t)=>hs.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,NKp=LYD;function UYD(e,t){e=e||10;let r=new Array(e),i=new Array(e),n=0,a=0,u;return t=t!==void 0?t:1e3,function(d){let s=Date.now(),o=i[a];u||(u=s),r[n]=d,i[n]=s;let l=a,b=0;for(;l!==n;)b+=r[l++],l=l%e;if(n=(n+1)%e,n===a&&(a=(a+1)%e),s-u<t)return;let g=o&&s-o;return g?Math.round(b*1e3/g):void 0}}var FKp=UYD;function VYD(e,t){let r=0,i=1e3/t,n,a,u=(s,o=Date.now())=>{r=o,n=null,a&&(clearTimeout(a),a=null),e.apply(null,s)};return[(...s)=>{let o=Date.now(),l=o-r;l>=i?u(s,o):(n=s,a||(a=setTimeout(()=>{a=null,u(n)},i-l)))},()=>n&&u(n)]}var LKp=VYD;var WOi=(e,t,r=3)=>{let i=0,n=FKp(50,250);return LKp(a=>{let u=a.loaded,c=a.lengthComputable?a.total:void 0,d=u-i,s=n(d),o=u<=c;i=u;let l={loaded:u,total:c,progress:c?u/c:void 0,bytes:d,rate:s||void 0,estimated:s&&c&&o?(c-u)/s:void 0,event:a,lengthComputable:c!=null,[t?"download":"upload"]:!0};e(l)},r)},bHn=(e,t)=>{let r=e!=null;return[i=>t[0]({lengthComputable:r,total:e,loaded:i}),t[1]]},gHn=e=>(...t)=>hs.asap(()=>e(...t));var UKp={flush:HOi.default.constants.Z_SYNC_FLUSH,finishFlush:HOi.default.constants.Z_SYNC_FLUSH},WYD={flush:HOi.default.constants.BROTLI_OPERATION_FLUSH,finishFlush:HOi.default.constants.BROTLI_OPERATION_FLUSH},VKp=hs.isFunction(HOi.default.createBrotliDecompress),{http:HYD,https:$YD}=YKp.default,GYD=/https:?/,WKp=lq.protocols.map(e=>e+":"),HKp=(e,[t,r])=>(e.on("end",r).on("error",r),t);function QYD(e,t){e.beforeRedirects.proxy&&e.beforeRedirects.proxy(e),e.beforeRedirects.config&&e.beforeRedirects.config(e,t)}function ZKp(e,t,r){let i=t;if(!i&&i!==!1){let n=GKp.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){ZKp(a,t,a.href)}}var JYD=typeof process<"u"&&hs.kindOf(process)==="process",KYD=e=>new Promise((t,r)=>{let i,n,a=(d,s)=>{n||(n=!0,i&&i(d,s))},u=d=>{a(d),t(d)},c=d=>{a(d,!0),r(d)};e(u,c,d=>i=d).catch(c)}),YYD=({address:e,family:t})=>{if(!hs.isString(e))throw TypeError("address must be a string");return{address:e,family:t||(e.indexOf(".")<0?6:4)}},$Kp=(e,t)=>YYD(hs.isObject(e)?e:{address:e,family:t}),kKp=JYD&&function(t){return KYD(async function(i,n,a){let{data:u,lookup:c,family:d}=t,{responseType:s,responseEncoding:o}=t,l=t.method.toUpperCase(),b,g=!1,O;if(c){let me=NKp(c,Le=>hs.isArray(Le)?Le:[Le]);c=(Le,vt,De)=>{me(Le,vt,(Ae,Ct,Pe)=>{if(Ae)return De(Ae);let St=hs.isArray(Ct)?Ct.map(at=>$Kp(at)):[$Kp(Ct,Pe)];vt.all?De(Ae,St):De(Ae,St[0].address,St[0].family)})}}let m=new XKp.EventEmitter,P=()=>{t.cancelToken&&t.cancelToken.unsubscribe(D),t.signal&&t.signal.removeEventListener("abort",D),m.removeAllListeners()};a((me,Le)=>{b=!0,Le&&(g=!0,P())});function D(me){m.emit("abort",!me||me.type?new nqe(null,t,O):me)}m.once("abort",n),(t.cancelToken||t.signal)&&(t.cancelToken&&t.cancelToken.subscribe(D),t.signal&&(t.signal.aborted?D():t.signal.addEventListener("abort",D)));let A=Ztn(t.baseURL,t.url,t.allowAbsoluteUrls),M=new URL(A,lq.hasBrowserEnv?lq.origin:void 0),E=M.protocol||WKp[0];if(E==="data:"){let me;if(l!=="GET")return har(i,n,{status:405,statusText:"method not allowed",headers:{},config:t});try{me=Mpc(t.url,s==="blob",{Blob:t.env&&t.env.Blob})}catch(Le){throw o_.from(Le,o_.ERR_BAD_REQUEST,t)}return s==="text"?(me=me.toString(o),(!o||o==="utf8")&&(me=hs.stripBOM(me))):s==="stream"&&(me=trn.default.Readable.from(me)),har(i,n,{data:me,status:200,statusText:"OK",headers:new mN,config:t})}if(WKp.indexOf(E)===-1)return n(new o_("Unsupported protocol "+E,o_.ERR_BAD_REQUEST,t));let T=mN.from(t.headers).normalize();T.set("User-Agent","axios/"+ktn,!1);let{onUploadProgress:z,onDownloadProgress:$}=t,I=t.maxRate,N,U;if(hs.isSpecCompliantForm(u)){let me=T.getContentType(/boundary=([-_\w\d]{10,70})/i);u=zKp(u,Le=>{T.set(Le)},{tag:`axios-${ktn}-boundary`,boundary:me&&me[1]||void 0})}else if(hs.isFormData(u)&&hs.isFunction(u.getHeaders)){if(T.set(u.getHeaders()),!T.hasContentLength())try{let me=await KKp.default.promisify(u.getLength).call(u);Number.isFinite(me)&&me>=0&&T.setContentLength(me)}catch{}}else if(hs.isBlob(u)||hs.isFile(u))u.size&&T.setContentType(u.type||"application/octet-stream"),T.setContentLength(u.size||0),u=trn.default.Readable.from(OQo(u));else if(u&&!hs.isStream(u)){if(!Buffer.isBuffer(u))if(hs.isArrayBuffer(u))u=Buffer.from(new Uint8Array(u));else if(hs.isString(u))u=Buffer.from(u,"utf-8");else return n(new o_("Data after transformation must be a string, an ArrayBuffer, a Buffer, or a Stream",o_.ERR_BAD_REQUEST,t));if(T.setContentLength(u.length,!1),t.maxBodyLength>-1&&u.length>t.maxBodyLength)return n(new o_("Request body larger than maxBodyLength limit",o_.ERR_BAD_REQUEST,t))}let Y=hs.toFiniteNumber(T.getContentLength());hs.isArray(I)?(N=I[0],U=I[1]):N=U=I,u&&(z||N)&&(hs.isStream(u)||(u=trn.default.Readable.from(u,{objectMode:!1})),u=trn.default.pipeline([u,new Tpc({maxRate:hs.toFiniteNumber(N)})],hs.noop),z&&u.on("progress",HKp(u,bHn(Y,WOi(gHn(z),!1,3)))));let J;if(t.auth){let me=t.auth.username||"",Le=t.auth.password||"";J=me+":"+Le}if(!J&&M.username){let me=M.username,Le=M.password;J=me+":"+Le}J&&T.delete("authorization");let X;try{X=Xtn(M.pathname+M.search,t.params,t.paramsSerializer).replace(/^\?/,"")}catch(me){let Le=new Error(me.message);return Le.config=t,Le.url=t.url,Le.exists=!0,n(Le)}T.set("Accept-Encoding","gzip, compress, deflate"+(VKp?", br":""),!1);let oe={path:X,method:l,headers:T.toJSON(),agents:{http:t.httpAgent,https:t.httpsAgent},auth:J,protocol:E,family:d,beforeRedirect:QYD,beforeRedirects:{}};!hs.isUndefined(c)&&(oe.lookup=c),t.socketPath?oe.socketPath=t.socketPath:(oe.hostname=M.hostname.startsWith("[")?M.hostname.slice(1,-1):M.hostname,oe.port=M.port,ZKp(oe,t.proxy,E+"//"+M.hostname+(M.port?":"+M.port:"")+oe.path));let pe,de=GYD.test(oe.protocol);if(oe.agent=de?t.httpsAgent:t.httpAgent,t.transport?pe=t.transport:t.maxRedirects===0?pe=de?JKp.default:QKp.default:(t.maxRedirects&&(oe.maxRedirects=t.maxRedirects),t.beforeRedirect&&(oe.beforeRedirects.config=t.beforeRedirect),pe=de?$YD:HYD),t.maxBodyLength>-1?oe.maxBodyLength=t.maxBodyLength:oe.maxBodyLength=1/0,t.insecureHTTPParser&&(oe.insecureHTTPParser=t.insecureHTTPParser),O=pe.request(oe,function(Le){if(O.destroyed)return;let vt=[Le],De=+Le.headers["content-length"];if($||U){let at=new Tpc({maxRate:hs.toFiniteNumber(U)});$&&at.on("progress",HKp(at,bHn(De,WOi(gHn($),!0,3)))),vt.push(at)}let Ae=Le,Ct=Le.req||O;if(t.decompress!==!1&&Le.headers["content-encoding"])switch((l==="HEAD"||Le.statusCode===204)&&delete Le.headers["content-encoding"],(Le.headers["content-encoding"]||"").toLowerCase()){case"gzip":case"x-gzip":case"compress":case"x-compress":vt.push(HOi.default.createUnzip(UKp)),delete Le.headers["content-encoding"];break;case"deflate":vt.push(new RKp),vt.push(HOi.default.createUnzip(UKp)),delete Le.headers["content-encoding"];break;case"br":VKp&&(vt.push(HOi.default.createBrotliDecompress(WYD)),delete Le.headers["content-encoding"])}Ae=vt.length>1?trn.default.pipeline(vt,hs.noop):vt[0];let Pe=trn.default.finished(Ae,()=>{Pe(),P()}),St={status:Le.statusCode,statusText:Le.statusMessage,headers:new mN(Le.headers),config:t,request:Ct};if(s==="stream")St.data=Ae,har(i,n,St);else{let at=[],Oe=0;Ae.on("data",function(bt){at.push(bt),Oe+=bt.length,t.maxContentLength>-1&&Oe>t.maxContentLength&&(g=!0,Ae.destroy(),n(new o_("maxContentLength size of "+t.maxContentLength+" exceeded",o_.ERR_BAD_RESPONSE,t,Ct)))}),Ae.on("aborted",function(){if(g)return;let bt=new o_("stream has been aborted",o_.ERR_BAD_RESPONSE,t,Ct);Ae.destroy(bt),n(bt)}),Ae.on("error",function(bt){O.destroyed||n(o_.from(bt,null,t,Ct))}),Ae.on("end",function(){try{let bt=at.length===1?at[0]:Buffer.concat(at);s!=="arraybuffer"&&(bt=bt.toString(o),(!o||o==="utf8")&&(bt=hs.stripBOM(bt))),St.data=bt}catch(bt){return n(o_.from(bt,null,t,St.request,St))}har(i,n,St)})}m.once("abort",at=>{Ae.destroyed||(Ae.emit("error",at),Ae.destroy())})}),m.once("abort",me=>{n(me),O.destroy(me)}),O.on("error",function(Le){n(o_.from(Le,null,t,O))}),O.on("socket",function(Le){Le.setKeepAlive(!0,1e3*60)}),t.timeout){let me=parseInt(t.timeout,10);if(Number.isNaN(me)){n(new o_("error trying to parse `config.timeout` to int",o_.ERR_BAD_OPTION_VALUE,t,O));return}O.setTimeout(me,function(){if(b)return;let vt=t.timeout?"timeout of "+t.timeout+"ms exceeded":"timeout exceeded",De=t.transitional||hHn;t.timeoutErrorMessage&&(vt=t.timeoutErrorMessage),n(new o_(vt,De.clarifyTimeoutError?o_.ETIMEDOUT:o_.ECONNABORTED,t,O)),D()})}if(hs.isStream(u)){let me=!1,Le=!1;u.on("end",()=>{me=!0}),u.once("error",vt=>{Le=!0,O.destroy(vt)}),u.on("close",()=>{!me&&!Le&&D(new nqe("Request stream has been aborted",t,O))}),u.pipe(O)}else O.end(u)})};var eYp=lq.hasStandardBrowserEnv?((e,t)=>r=>(r=new URL(r,lq.origin),e.protocol===r.protocol&&e.host===r.host&&(t||e.port===r.port)))(new URL(lq.origin),lq.navigator&&/(msie|trident)/i.test(lq.navigator.userAgent)):()=>!0;var tYp=lq.hasStandardBrowserEnv?{write(e,t,r,i,n,a){let u=[e+"="+encodeURIComponent(t)];hs.isNumber(r)&&u.push("expires="+new Date(r).toGMTString()),hs.isString(i)&&u.push("path="+i),hs.isString(n)&&u.push("domain="+n),a===!0&&u.push("secure"),document.cookie=u.join("; ")},read(e){let t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove(e){this.write(e,"",Date.now()-864e5)}}:{write(){},read(){return null},remove(){}};var rYp=e=>e instanceof mN?{...e}:e;function eQt(e,t){t=t||{};let r={};function i(s,o,l,b){return hs.isPlainObject(s)&&hs.isPlainObject(o)?hs.merge.call({caseless:b},s,o):hs.isPlainObject(o)?hs.merge({},o):hs.isArray(o)?o.slice():o}function n(s,o,l,b){if(hs.isUndefined(o)){if(!hs.isUndefined(s))return i(void 0,s,l,b)}else return i(s,o,l,b)}function a(s,o){if(!hs.isUndefined(o))return i(void 0,o)}function u(s,o){if(hs.isUndefined(o)){if(!hs.isUndefined(s))return i(void 0,s)}else return i(void 0,o)}function c(s,o,l){if(l in t)return i(s,o);if(l in e)return i(void 0,s)}let d={url:a,method:a,data:a,baseURL:u,transformRequest:u,transformResponse:u,paramsSerializer:u,timeout:u,timeoutMessage:u,withCredentials:u,withXSRFToken:u,adapter:u,responseType:u,xsrfCookieName:u,xsrfHeaderName:u,onUploadProgress:u,onDownloadProgress:u,decompress:u,maxContentLength:u,maxBodyLength:u,beforeRedirect:u,transport:u,httpAgent:u,httpsAgent:u,cancelToken:u,socketPath:u,responseEncoding:u,validateStatus:c,headers:(s,o,l)=>n(rYp(s),rYp(o),l,!0)};return hs.forEach(Object.keys(Object.assign({},e,t)),function(o){let l=d[o]||n,b=l(e[o],t[o],o);hs.isUndefined(b)&&l!==c||(r[o]=b)}),r}var mQo=e=>{let t=eQt({},e),{data:r,withXSRFToken:i,xsrfHeaderName:n,xsrfCookieName:a,headers:u,auth:c}=t;t.headers=u=mN.from(u),t.url=Xtn(Ztn(t.baseURL,t.url,t.allowAbsoluteUrls),e.params,e.paramsSerializer),c&&u.set("Authorization","Basic "+btoa((c.username||"")+":"+(c.password?unescape(encodeURIComponent(c.password)):"")));let d;if(hs.isFormData(r)){if(lq.hasStandardBrowserEnv||lq.hasStandardBrowserWebWorkerEnv)u.setContentType(void 0);else if((d=u.getContentType())!==!1){let[s,...o]=d?d.split(";").map(l=>l.trim()).filter(Boolean):[];u.setContentType([s||"multipart/form-data",...o].join("; "))}}if(lq.hasStandardBrowserEnv&&(i&&hs.isFunction(i)&&(i=i(t)),i||i!==!1&&eYp(t.url))){let s=n&&a&&tYp.read(a);s&&u.set(n,s)}return t};var XYD=typeof XMLHttpRequest<"u",iYp=XYD&&function(e){return new Promise(function(r,i){let n=mQo(e),a=n.data,u=mN.from(n.headers).normalize(),{responseType:c,onUploadProgress:d,onDownloadProgress:s}=n,o,l,b,g,O;function m(){g&&g(),O&&O(),n.cancelToken&&n.cancelToken.unsubscribe(o),n.signal&&n.signal.removeEventListener("abort",o)}let P=new XMLHttpRequest;P.open(n.method.toUpperCase(),n.url,!0),P.timeout=n.timeout;function D(){if(!P)return;let M=mN.from("getAllResponseHeaders"in P&&P.getAllResponseHeaders()),T={data:!c||c==="text"||c==="json"?P.responseText:P.response,status:P.status,statusText:P.statusText,headers:M,config:e,request:P};har(function($){r($),m()},function($){i($),m()},T),P=null}"onloadend"in P?P.onloadend=D:P.onreadystatechange=function(){!P||P.readyState!==4||P.status===0&&!(P.responseURL&&P.responseURL.indexOf("file:")===0)||setTimeout(D)},P.onabort=function(){P&&(i(new o_("Request aborted",o_.ECONNABORTED,e,P)),P=null)},P.onerror=function(){i(new o_("Network Error",o_.ERR_NETWORK,e,P)),P=null},P.ontimeout=function(){let E=n.timeout?"timeout of "+n.timeout+"ms exceeded":"timeout exceeded",T=n.transitional||hHn;n.timeoutErrorMessage&&(E=n.timeoutErrorMessage),i(new o_(E,T.clarifyTimeoutError?o_.ETIMEDOUT:o_.ECONNABORTED,e,P)),P=null},a===void 0&&u.setContentType(null),"setRequestHeader"in P&&hs.forEach(u.toJSON(),function(E,T){P.setRequestHeader(T,E)}),hs.isUndefined(n.withCredentials)||(P.withCredentials=!!n.withCredentials),c&&c!=="json"&&(P.responseType=n.responseType),s&&([b,O]=WOi(s,!0),P.addEventListener("progress",b)),d&&P.upload&&([l,g]=WOi(d),P.upload.addEventListener("progress",l),P.upload.addEventListener("loadend",g)),(n.cancelToken||n.signal)&&(o=M=>{P&&(i(!M||M.type?new nqe(null,e,P):M),P.abort(),P=null)},n.cancelToken&&n.cancelToken.subscribe(o),n.signal&&(n.signal.aborted?o():n.signal.addEventListener("abort",o)));let A=sFa(n.url);if(A&&lq.protocols.indexOf(A)===-1){i(new o_("Unsupported protocol "+A+":",o_.ERR_BAD_REQUEST,e));return}P.send(a||null)})};var ZYD=(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 o=s instanceof Error?s:this.reason;i.abort(o instanceof o_?o:new nqe(o instanceof Error?o.message:o))}},u=t&&setTimeout(()=>{u=null,a(new o_(`timeout ${t} of ms exceeded`,o_.ETIMEDOUT))},t),c=()=>{e&&(u&&clearTimeout(u),u=null,e.forEach(s=>{s.unsubscribe?s.unsubscribe(a):s.removeEventListener("abort",a)}),e=null)};e.forEach(s=>s.addEventListener("abort",a));let{signal:d}=i;return d.unsubscribe=()=>hs.asap(c),d}},nYp=ZYD;var kYD=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},eXD=async function*(e,t){for await(let r of tXD(e))yield*kYD(r,t)},tXD=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()}},Ipc=(e,t,r,i)=>{let n=eXD(e,t),a=0,u,c=d=>{u||(u=!0,i&&i(d))};return new ReadableStream({async pull(d){try{let{done:s,value:o}=await n.next();if(s){c(),d.close();return}let l=o.byteLength;if(r){let b=a+=l;r(b)}d.enqueue(new Uint8Array(o))}catch(s){throw c(s),s}},cancel(d){return c(d),n.return()}},{highWaterMark:2})};var jQo=typeof fetch=="function"&&typeof Request=="function"&&typeof Response=="function",oYp=jQo&&typeof ReadableStream=="function",rXD=jQo&&(typeof TextEncoder=="function"?(e=>t=>e.encode(t))(new TextEncoder):async e=>new Uint8Array(await new Response(e).arrayBuffer())),uYp=(e,...t)=>{try{return!!e(...t)}catch{return!1}},iXD=oYp&&uYp(()=>{let e=!1,t=new Request(lq.origin,{body:new ReadableStream,method:"POST",get duplex(){return e=!0,"half"}}).headers.has("Content-Type");return e&&!t}),aYp=64*1024,zpc=oYp&&uYp(()=>hs.isReadableStream(new Response("").body)),PQo={stream:zpc&&(e=>e.body)};jQo&&(e=>{["text","arrayBuffer","blob","formData","stream"].forEach(t=>{!PQo[t]&&(PQo[t]=hs.isFunction(e[t])?r=>r[t]():(r,i)=>{throw new o_(`Response type '${t}' is not supported`,o_.ERR_NOT_SUPPORT,i)})})})(new Response);var nXD=async e=>{if(e==null)return 0;if(hs.isBlob(e))return e.size;if(hs.isSpecCompliantForm(e))return(await new Request(lq.origin,{method:"POST",body:e}).arrayBuffer()).byteLength;if(hs.isArrayBufferView(e)||hs.isArrayBuffer(e))return e.byteLength;if(hs.isURLSearchParams(e)&&(e=e+""),hs.isString(e))return(await rXD(e)).byteLength},aXD=async(e,t)=>{let r=hs.toFiniteNumber(e.getContentLength());return r??nXD(t)},sYp=jQo&&(async e=>{let{url:t,method:r,data:i,signal:n,cancelToken:a,timeout:u,onDownloadProgress:c,onUploadProgress:d,responseType:s,headers:o,withCredentials:l="same-origin",fetchOptions:b}=mQo(e);s=s?(s+"").toLowerCase():"text";let g=nYp([n,a&&a.toAbortSignal()],u),O,m=g&&g.unsubscribe&&(()=>{g.unsubscribe()}),P;try{if(d&&iXD&&r!=="get"&&r!=="head"&&(P=await aXD(o,i))!==0){let T=new Request(t,{method:"POST",body:i,duplex:"half"}),z;if(hs.isFormData(i)&&(z=T.headers.get("content-type"))&&o.setContentType(z),T.body){let[$,I]=bHn(P,WOi(gHn(d)));i=Ipc(T.body,aYp,$,I)}}hs.isString(l)||(l=l?"include":"omit");let D="credentials"in Request.prototype;O=new Request(t,{...b,signal:g,method:r.toUpperCase(),headers:o.normalize().toJSON(),body:i,duplex:"half",credentials:D?l:void 0});let A=await fetch(O,b),M=zpc&&(s==="stream"||s==="response");if(zpc&&(c||M&&m)){let T={};["status","statusText","headers"].forEach(N=>{T[N]=A[N]});let z=hs.toFiniteNumber(A.headers.get("content-length")),[$,I]=c&&bHn(z,WOi(gHn(c),!0))||[];A=new Response(Ipc(A.body,aYp,$,()=>{I&&I(),m&&m()}),T)}s=s||"text";let E=await PQo[hs.findKey(PQo,s)||"text"](A,e);return!M&&m&&m(),await new Promise((T,z)=>{har(T,z,{data:E,headers:mN.from(A.headers),status:A.status,statusText:A.statusText,config:e,request:O})})}catch(D){throw m&&m(),D&&D.name==="TypeError"&&/Load failed|fetch/i.test(D.message)?Object.assign(new o_("Network Error",o_.ERR_NETWORK,e,O),{cause:D.cause||D}):o_.from(D,D&&D.code,e,O)}});var xpc={http:kKp,xhr:iYp,fetch:sYp};hs.forEach(xpc,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});var cYp=e=>`- ${e}`,oXD=e=>hs.isFunction(e)||e===null||e===!1,wQo={getAdapter:e=>{e=hs.isArray(e)?e:[e];let{length:t}=e,r,i,n={};for(let a=0;a<t;a++){r=e[a];let u;if(i=r,!oXD(r)&&(i=xpc[(u=String(r)).toLowerCase()],i===void 0))throw new o_(`Unknown adapter '${u}'`);if(i)break;n[u||"#"+a]=i}if(!i){let a=Object.entries(n).map(([c,d])=>`adapter ${c} `+(d===!1?"is not supported by the environment":"is not available in the build")),u=t?a.length>1?`since :
|
|
@@ -1954,7 +1954,7 @@ ${M}${A}${E}${Vg_.default.cursorHide}`});function Cru({message:e,error:t,logger:
|
|
|
1954
1954
|
Run ${Bs.cyan("fern generator upgrade")} to upgrade your generators.`),n.length>2&&(r+=`
|
|
1955
1955
|
Run ${Bs.cyan("fern generator upgrade --list")} to see the full list of generator upgrades available.`),mHn(r,{padding:1,float:"center",textAlignment:"center",borderColor:"yellow",borderStyle:"round"})}async function Jwc({generatorUpgradeInfo:e,header:t,limit:r,includeBoxen:i=!0}){if(!fO_(e))return;let n=t??"",a=e.filter(c=>c.isUpgradeAvailable);r!=null&&(a=a.slice(0,r+1));let u=a.sort((c,d)=>c.generatorName.localeCompare(d.generatorName)||c.currentVersion.localeCompare(d.currentVersion));for(let c of u)n+=`
|
|
1956
1956
|
${await kAE(c.generatorName)} (${c.apiName!=null?"API: "+c.apiName+", ":""}Group: ${c.generatorGroup}) `+Bs.dim(c.currentVersion)+Bs.reset(" \u2192 ")+Bs.green(c.latestVersion);return n+=`
|
|
1957
|
-
`,i?mHn(n,{padding:1,float:"center",textAlignment:"center",borderColor:"yellow",borderStyle:"round"}):n}async function kAE(e){let r=await new lO_.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 eqE({cliContext:e,project:{apiWorkspaces:t},generatorFilter:r,groupFilter:i,channel:n,includeMajor:a}){if(t.length===1){let c={type:"singleApi",versions:{}};return await pO_({cliContext:e,apiWorkspaces:t,perGeneratorAction:async(d,s,o,l)=>{c.versions[s]==null&&(c.versions[s]={});let b=TIi(o.name,l),g=await uir({generatorName:b,cliVersion:e.environment.packageVersion,currentGeneratorVersion:o.version,channel:n,includeMajor:a,context:l});g!=null&&(c.versions[s][o.name]={previousVersion:o.version,latestVersion:g})},generatorFilter:r,groupFilter:i}),c}let u={type:"multiApi",versions:{}};return await pO_({cliContext:e,apiWorkspaces:t,perGeneratorAction:async(c,d,s,o)=>{if(c==null)return;u.versions[c]==null&&(u.versions[c]={}),u.versions[c][d]==null&&(u.versions[c][d]={});let l=TIi(s.name,o),b=await uir({generatorName:l,cliVersion:e.environment.packageVersion,currentGeneratorVersion:s.version,channel:n,includeMajor:a,context:o});b!=null&&(u.versions[c][d][s.name]={previousVersion:s.version,latestVersion:b})},generatorFilter:r,groupFilter:i}),u}async function pO_({cliContext:e,apiWorkspaces:t,perGeneratorAction:r,generatorFilter:i,groupFilter:n}){await Promise.all(t.map(async a=>{await e.runTaskForWorkspace(a,async u=>{let c=await AGt({absolutePathToWorkspace:a.absoluteFilePath,context:u});if(!(c==null||c.groups==null)){for(let d of c.groups)if(!(n!=null&&d.groupName!==n))for(let s of d.generators)i!=null&&s.name!==i||await r(a.workspaceName,d.groupName,s,u)}})}))}function _O_(e,t,r){let i=[];for(let[n,a]of Object.entries(e))for(let[u,c]of Object.entries(a)){r.debug(`Checking if ${u} in group ${n} has an upgrade available...`);let d=xue(c.latestVersion,c.previousVersion);r.debug(`Latest version: ${c.latestVersion}. `+(d?"Upgrade available.":"No upgrade available.")),i.push({generatorName:u,generatorGroup:n,apiName:t,isUpgradeAvailable:d,currentVersion:c.previousVersion,latestVersion:c.latestVersion})}return i}async function Rru({project:e,cliContext:t,generatorFilter:r,groupFilter:i,channel:n,includeMajor:a}){let u=[];if(e!=null){let c=await eqE({cliContext:t,project:e,generatorFilter:r,groupFilter:i,channel:n,includeMajor:a});if(c.type==="multiApi")for(let[d,s]of Object.entries(c.versions))u.push(..._O_(s,d,t.logger));else u.push(..._O_(c.versions,void 0,t.logger))}return u}var h5a=class extends Error{response;request;options;constructor(t,r,i){let n=t.status||t.status===0?t.status:"",a=t.statusText||"",u=`${n} ${a}`.trim(),c=u?`status code ${u}`:"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 BJn=class extends Error{request;constructor(t){super(`Request timed out: ${t.method} ${t.url}`),this.name="TimeoutError",this.request=t}};var Kwc=(()=>{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})(),hO_=typeof globalThis.AbortController=="function",yO_=typeof globalThis.ReadableStream=="function",vO_=typeof globalThis.FormData=="function",Nru=["get","post","put","patch","head","delete"],tqE=()=>{};tqE();var bO_={json:"application/json",text:"text/*",formData:"multipart/form-data",arrayBuffer:"*/*",blob:"*/*"},Fru=2147483647,gO_=new TextEncoder().encode("------WebKitFormBoundaryaxpyiPgbbPti10Rw").length,Lru=Symbol("stop"),OO_={json:!0,parseJson:!0,stringifyJson:!0,searchParams:!0,prefixUrl:!0,retry:!0,timeout:!0,hooks:!0,throwHttpErrors:!0,onDownloadProgress:!0,onUploadProgress:!0,fetch:!0},mO_={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 rqE=e=>{if(!e)return 0;if(e instanceof FormData){let t=0;for(let[r,i]of e)t+=gO_,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},PO_=(e,t)=>{let r=Number(e.headers.get("content-length"))||0,i=0;return e.status===204?(t&&t({percent:1,totalBytes:r,transferredBytes:i},new Uint8Array),new Response(null,{status:e.status,statusText:e.statusText,headers:e.headers})):new Response(new ReadableStream({async start(n){let a=e.body.getReader();t&&t({percent:0,transferredBytes:0,totalBytes:r},new Uint8Array);async function u(){let{done:c,value:d}=await a.read();if(c){n.close();return}if(t){i+=d.byteLength;let s=r===0?0:i/r;t({percent:s,transferredBytes:i,totalBytes:r},d)}n.enqueue(d),await u()}await u()}}),{status:e.status,statusText:e.statusText,headers:e.headers})},jO_=(e,t)=>{let r=rqE(e.body),i=0;return new Request(e,{duplex:"half",body:new ReadableStream({async start(n){let a=e.body instanceof ReadableStream?e.body.getReader():new Response("").body.getReader();async function u(){let{done:c,value:d}=await a.read();if(c){t&&t({percent:1,transferredBytes:i,totalBytes:Math.max(r,i)},new Uint8Array),n.close();return}i+=d.byteLength;let s=r===0?0:i/r;(r<i||s===1)&&(s=.99),t&&t({percent:Number(s.toFixed(2)),transferredBytes:i,totalBytes:r},d),n.enqueue(d),await u()}await u()}})})};var IJn=e=>e!==null&&typeof e=="object";var y5a=(...e)=>{for(let t of e)if((!IJn(t)||Array.isArray(t))&&t!==void 0)throw new TypeError("The `options` argument must be an object");return Zwc({},...e)},Ywc=(e={},t={})=>{let r=new globalThis.Headers(e),i=t instanceof globalThis.Headers,n=new globalThis.Headers(t);for(let[a,u]of n.entries())i&&u==="undefined"||u===void 0?r.delete(a):r.set(a,u);return r};function Uru(e,t,r){return Object.hasOwn(t,r)&&t[r]===void 0?[]:Zwc(e[r]??[],t[r]??[])}var Xwc=(e={},t={})=>({beforeRequest:Uru(e,t,"beforeRequest"),beforeRetry:Uru(e,t,"beforeRetry"),afterResponse:Uru(e,t,"afterResponse"),beforeError:Uru(e,t,"beforeError")}),Zwc=(...e)=>{let t={},r={},i={};for(let n of e)if(Array.isArray(n))Array.isArray(t)||(t=[]),t=[...t,...n];else if(IJn(n)){for(let[a,u]of Object.entries(n))IJn(u)&&a in t&&(u=Zwc(t[a],u)),t={...t,[a]:u};IJn(n.hooks)&&(i=Xwc(i,n.hooks),t.hooks=i),IJn(n.headers)&&(r=Ywc(r,n.headers),t.headers=r)}return t};var SO_=e=>Nru.includes(e)?e.toUpperCase():e,iqE=["get","put","head","delete","options","trace"],nqE=[408,413,429,500,502,503,504],aqE=[413,429,503],wO_={limit:2,methods:iqE,statusCodes:nqE,afterStatusCodes:aqE,maxRetryAfter:Number.POSITIVE_INFINITY,backoffLimit:Number.POSITIVE_INFINITY,delay:e=>.3*2**(e-1)*1e3},DO_=(e={})=>{if(typeof e=="number")return{...wO_,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{...wO_,...e}};async function kwc(e,t,r,i){return new Promise((n,a)=>{let u=setTimeout(()=>{r&&r.abort(),a(new BJn(e))},i.timeout);i.fetch(e,t).then(n).catch(a).then(()=>{clearTimeout(u)})})}async function e1c(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 EO_=(e,t)=>{let r={};for(let i in t)!(i in mO_)&&!(i in OO_)&&!(i in e)&&(r[i]=t[i]);return r};var v5a=class e{static create(t,r){let i=new e(t,r),n=async()=>{if(typeof i._options.timeout=="number"&&i._options.timeout>Fru)throw new RangeError(`The \`timeout\` option cannot be greater than ${Fru}`);await Promise.resolve();let c=await i._fetch();for(let d of i._options.hooks.afterResponse){let s=await d(i.request,i._options,i._decorateResponse(c.clone()));s instanceof globalThis.Response&&(c=s)}if(i._decorateResponse(c),!c.ok&&i._options.throwHttpErrors){let d=new h5a(c,i.request,i._options);for(let s of i._options.hooks.beforeError)d=await s(d);throw d}if(i._options.onDownloadProgress){if(typeof i._options.onDownloadProgress!="function")throw new TypeError("The `onDownloadProgress` option must be a function");if(!yO_)throw new Error("Streams are not supported in your environment. `ReadableStream` is missing.");return PO_(c.clone(),i._options.onDownloadProgress)}return c},u=(i._options.retry.methods.includes(i.request.method.toLowerCase())?i._retry(n):n()).finally(async()=>{i.request.bodyUsed||await i.request.body?.cancel()});for(let[c,d]of Object.entries(bO_))u[c]=async()=>{i.request.headers.set("accept",i.request.headers.get("accept")||d);let s=await u;if(c==="json"){if(s.status===204||(await s.clone().arrayBuffer()).byteLength===0)return"";if(r.parseJson)return r.parseJson(await s.text())}return s[c]()};return u}request;abortController;_retryCount=0;_input;_options;constructor(t,r={}){if(this._input=t,this._options={...r,headers:Ywc(this._input.headers,r.headers),hooks:Xwc({beforeRequest:[],beforeRetry:[],beforeError:[],afterResponse:[]},r.hooks),method:SO_(r.method??this._input.method??"GET"),prefixUrl:String(r.prefixUrl||""),retry:DO_(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(hO_){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(Kwc&&(this._options.duplex="half"),this._options.json!==void 0&&(this._options.body=this._options.stringifyJson?.(this._options.json)??JSON.stringify(this._options.json),this._options.headers.set("content-type",this._options.headers.get("content-type")??"application/json")),this.request=new globalThis.Request(this._input,this._options),this._options.searchParams){let n="?"+(typeof this._options.searchParams=="string"?this._options.searchParams.replace(/^\?/,""):new URLSearchParams(this._options.searchParams).toString()),a=this.request.url.replace(/(?:\?.*?)?(?=#|$)/,n);(vO_&&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(!Kwc)throw new Error("Request streams are not supported in your environment. The `duplex` option for `Request` is not available.");this.request.body&&(this.request=jO_(this.request,this._options.onUploadProgress))}}_calculateRetryDelay(t){if(this._retryCount++,this._retryCount>this._options.retry.limit||t instanceof BJn)throw t;if(t instanceof h5a){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),Fru);if(this._retryCount<1)throw r;await e1c(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})===Lru)return;return this._retry(t)}}async _fetch(){for(let i of this._options.hooks.beforeRequest){let n=await i(this.request,this._options);if(n instanceof Request){this.request=n;break}if(n instanceof Response)return n}let t=EO_(this.request,this._options),r=this.request;return this.request=r.clone(),this._options.timeout===!1?this._options.fetch(r,t):kwc(r,t,this.abortController,this._options)}};var t1c=e=>{let t=(r,i)=>v5a.create(r,y5a(e,i));for(let r of Nru)t[r]=(i,n)=>v5a.create(i,y5a(e,n,{method:r}));return t.create=r=>t1c(y5a(r)),t.extend=r=>(typeof r=="function"&&(r=r(e??{})),t1c(y5a(e,r))),t.stop=Lru,t},oqE=t1c(),MO_=oqE;var XO_=ci(YO_(),1);function o1c(e){let t=(0,XO_.default)("npm",{registry:"https://registry.npmjs.org/"}),r=t[`${e}:registry`]||t.config_registry||t.registry;return r.slice(-1)==="/"?r:`${r}/`}var $m_=ci(Hm_(),1),Gm_=ci(bgi(),1),g1c=class extends Error{constructor(t){super(`Package \`${t}\` could not be found`),this.name="PackageNotFoundError"}},O1c=class extends Error{constructor(t,r){super(`Version \`${r}\` for package \`${t}\` could not be found`),this.name="VersionNotFoundError"}};async function m1c(e,t={}){let{version:r="latest"}=t,{omitDeprecated:i=!0}=t,n=e.split("/")[0],a=t.registryUrl??o1c(n),u=new URL(encodeURIComponent(e).replace(/^%40/,"@"),a),c=(0,$m_.default)(a.toString(),{recursive:!0}),d={accept:"application/vnd.npm.install-v1+json; q=1.0, application/json; q=0.8, */*"};t.fullMetadata&&delete d.accept,c&&(d.authorization=`${c.type} ${c.token}`);let s;try{s=await MO_(u,{headers:d,keepalive:!0}).json()}catch(l){throw l?.response?.status===404?new g1c(e):l}if(t.allVersions)return s;let o=new O1c(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[g,O]of Object.entries(s.versions))O.deprecated&&delete s.versions[g];if(!l){let g=Object.keys(s.versions);if(r=Gm_.default.maxSatisfying(g,r),!r)throw o}let{time:b}=s;if(s=s.versions[r],s.time=b,!s)throw o}return s}async function j5a(e,t){let{version:r}=await m1c(e.toLowerCase(),t);return r}async function ONi({cliEnvironment:e,includePreReleases:t=!1}){return e.packageName!=="fern-api"?e.packageVersion:j5a(e.packageName,{version:t?"prerelease":"latest"})}var Qm_=["#2E86AB","#A23B72","#F18F01","#C73E1D","#CCE2A3"],kru=class{environment;didSucceed=!0;numTasks=0;ttyAwareLogger;logLevel=Ab.Info;isLocal;constructor(t,r,{isLocal:i}){this.ttyAwareLogger=new xru(t,r),this.isLocal=i??!1;let n=this.getPackageName(),a=this.getPackageVersion(),u=this.getCliName();(n==null||a==null||u==null)&&this.exitProgram(),this.environment={packageName:n,packageVersion:a,cliName:u}}getPackageName(){return"fern-api"}getPackageVersion(){return"0.69.0"}getCliName(){return"fern"}setLogLevel(t){this.logLevel=t}logDebugInfo(){this.logger.debug(`Running ${Bs.bold(`${this.environment.cliName}`)} (${this.environment.packageName}@${this.environment.packageVersion})`)}failAndThrow(t,r){throw this.failWithoutThrowing(t,r),new X8}failWithoutThrowing(t,r){this.didSucceed=!1,Cru({message:t,error:r,logger:this.logger})}async exit({code:t}={}){(!this._suppressUpgradeMessage||!this.isLocal)&&await this.nudgeUpgradeIfAvailable(),this.ttyAwareLogger.finish(),await(await dHn()).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 dO_({cliEnvironment:this.environment,upgradeInfo:t});r!=null&&(r.endsWith(`
|
|
1957
|
+
`,i?mHn(n,{padding:1,float:"center",textAlignment:"center",borderColor:"yellow",borderStyle:"round"}):n}async function kAE(e){let r=await new lO_.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 eqE({cliContext:e,project:{apiWorkspaces:t},generatorFilter:r,groupFilter:i,channel:n,includeMajor:a}){if(t.length===1){let c={type:"singleApi",versions:{}};return await pO_({cliContext:e,apiWorkspaces:t,perGeneratorAction:async(d,s,o,l)=>{c.versions[s]==null&&(c.versions[s]={});let b=TIi(o.name,l),g=await uir({generatorName:b,cliVersion:e.environment.packageVersion,currentGeneratorVersion:o.version,channel:n,includeMajor:a,context:l});g!=null&&(c.versions[s][o.name]={previousVersion:o.version,latestVersion:g})},generatorFilter:r,groupFilter:i}),c}let u={type:"multiApi",versions:{}};return await pO_({cliContext:e,apiWorkspaces:t,perGeneratorAction:async(c,d,s,o)=>{if(c==null)return;u.versions[c]==null&&(u.versions[c]={}),u.versions[c][d]==null&&(u.versions[c][d]={});let l=TIi(s.name,o),b=await uir({generatorName:l,cliVersion:e.environment.packageVersion,currentGeneratorVersion:s.version,channel:n,includeMajor:a,context:o});b!=null&&(u.versions[c][d][s.name]={previousVersion:s.version,latestVersion:b})},generatorFilter:r,groupFilter:i}),u}async function pO_({cliContext:e,apiWorkspaces:t,perGeneratorAction:r,generatorFilter:i,groupFilter:n}){await Promise.all(t.map(async a=>{await e.runTaskForWorkspace(a,async u=>{let c=await AGt({absolutePathToWorkspace:a.absoluteFilePath,context:u});if(!(c==null||c.groups==null)){for(let d of c.groups)if(!(n!=null&&d.groupName!==n))for(let s of d.generators)i!=null&&s.name!==i||await r(a.workspaceName,d.groupName,s,u)}})}))}function _O_(e,t,r){let i=[];for(let[n,a]of Object.entries(e))for(let[u,c]of Object.entries(a)){r.debug(`Checking if ${u} in group ${n} has an upgrade available...`);let d=xue(c.latestVersion,c.previousVersion);r.debug(`Latest version: ${c.latestVersion}. `+(d?"Upgrade available.":"No upgrade available.")),i.push({generatorName:u,generatorGroup:n,apiName:t,isUpgradeAvailable:d,currentVersion:c.previousVersion,latestVersion:c.latestVersion})}return i}async function Rru({project:e,cliContext:t,generatorFilter:r,groupFilter:i,channel:n,includeMajor:a}){let u=[];if(e!=null){let c=await eqE({cliContext:t,project:e,generatorFilter:r,groupFilter:i,channel:n,includeMajor:a});if(c.type==="multiApi")for(let[d,s]of Object.entries(c.versions))u.push(..._O_(s,d,t.logger));else u.push(..._O_(c.versions,void 0,t.logger))}return u}var h5a=class extends Error{response;request;options;constructor(t,r,i){let n=t.status||t.status===0?t.status:"",a=t.statusText||"",u=`${n} ${a}`.trim(),c=u?`status code ${u}`:"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 BJn=class extends Error{request;constructor(t){super(`Request timed out: ${t.method} ${t.url}`),this.name="TimeoutError",this.request=t}};var Kwc=(()=>{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})(),hO_=typeof globalThis.AbortController=="function",yO_=typeof globalThis.ReadableStream=="function",vO_=typeof globalThis.FormData=="function",Nru=["get","post","put","patch","head","delete"],tqE=()=>{};tqE();var bO_={json:"application/json",text:"text/*",formData:"multipart/form-data",arrayBuffer:"*/*",blob:"*/*"},Fru=2147483647,gO_=new TextEncoder().encode("------WebKitFormBoundaryaxpyiPgbbPti10Rw").length,Lru=Symbol("stop"),OO_={json:!0,parseJson:!0,stringifyJson:!0,searchParams:!0,prefixUrl:!0,retry:!0,timeout:!0,hooks:!0,throwHttpErrors:!0,onDownloadProgress:!0,onUploadProgress:!0,fetch:!0},mO_={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 rqE=e=>{if(!e)return 0;if(e instanceof FormData){let t=0;for(let[r,i]of e)t+=gO_,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},PO_=(e,t)=>{let r=Number(e.headers.get("content-length"))||0,i=0;return e.status===204?(t&&t({percent:1,totalBytes:r,transferredBytes:i},new Uint8Array),new Response(null,{status:e.status,statusText:e.statusText,headers:e.headers})):new Response(new ReadableStream({async start(n){let a=e.body.getReader();t&&t({percent:0,transferredBytes:0,totalBytes:r},new Uint8Array);async function u(){let{done:c,value:d}=await a.read();if(c){n.close();return}if(t){i+=d.byteLength;let s=r===0?0:i/r;t({percent:s,transferredBytes:i,totalBytes:r},d)}n.enqueue(d),await u()}await u()}}),{status:e.status,statusText:e.statusText,headers:e.headers})},jO_=(e,t)=>{let r=rqE(e.body),i=0;return new Request(e,{duplex:"half",body:new ReadableStream({async start(n){let a=e.body instanceof ReadableStream?e.body.getReader():new Response("").body.getReader();async function u(){let{done:c,value:d}=await a.read();if(c){t&&t({percent:1,transferredBytes:i,totalBytes:Math.max(r,i)},new Uint8Array),n.close();return}i+=d.byteLength;let s=r===0?0:i/r;(r<i||s===1)&&(s=.99),t&&t({percent:Number(s.toFixed(2)),transferredBytes:i,totalBytes:r},d),n.enqueue(d),await u()}await u()}})})};var IJn=e=>e!==null&&typeof e=="object";var y5a=(...e)=>{for(let t of e)if((!IJn(t)||Array.isArray(t))&&t!==void 0)throw new TypeError("The `options` argument must be an object");return Zwc({},...e)},Ywc=(e={},t={})=>{let r=new globalThis.Headers(e),i=t instanceof globalThis.Headers,n=new globalThis.Headers(t);for(let[a,u]of n.entries())i&&u==="undefined"||u===void 0?r.delete(a):r.set(a,u);return r};function Uru(e,t,r){return Object.hasOwn(t,r)&&t[r]===void 0?[]:Zwc(e[r]??[],t[r]??[])}var Xwc=(e={},t={})=>({beforeRequest:Uru(e,t,"beforeRequest"),beforeRetry:Uru(e,t,"beforeRetry"),afterResponse:Uru(e,t,"afterResponse"),beforeError:Uru(e,t,"beforeError")}),Zwc=(...e)=>{let t={},r={},i={};for(let n of e)if(Array.isArray(n))Array.isArray(t)||(t=[]),t=[...t,...n];else if(IJn(n)){for(let[a,u]of Object.entries(n))IJn(u)&&a in t&&(u=Zwc(t[a],u)),t={...t,[a]:u};IJn(n.hooks)&&(i=Xwc(i,n.hooks),t.hooks=i),IJn(n.headers)&&(r=Ywc(r,n.headers),t.headers=r)}return t};var SO_=e=>Nru.includes(e)?e.toUpperCase():e,iqE=["get","put","head","delete","options","trace"],nqE=[408,413,429,500,502,503,504],aqE=[413,429,503],wO_={limit:2,methods:iqE,statusCodes:nqE,afterStatusCodes:aqE,maxRetryAfter:Number.POSITIVE_INFINITY,backoffLimit:Number.POSITIVE_INFINITY,delay:e=>.3*2**(e-1)*1e3},DO_=(e={})=>{if(typeof e=="number")return{...wO_,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{...wO_,...e}};async function kwc(e,t,r,i){return new Promise((n,a)=>{let u=setTimeout(()=>{r&&r.abort(),a(new BJn(e))},i.timeout);i.fetch(e,t).then(n).catch(a).then(()=>{clearTimeout(u)})})}async function e1c(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 EO_=(e,t)=>{let r={};for(let i in t)!(i in mO_)&&!(i in OO_)&&!(i in e)&&(r[i]=t[i]);return r};var v5a=class e{static create(t,r){let i=new e(t,r),n=async()=>{if(typeof i._options.timeout=="number"&&i._options.timeout>Fru)throw new RangeError(`The \`timeout\` option cannot be greater than ${Fru}`);await Promise.resolve();let c=await i._fetch();for(let d of i._options.hooks.afterResponse){let s=await d(i.request,i._options,i._decorateResponse(c.clone()));s instanceof globalThis.Response&&(c=s)}if(i._decorateResponse(c),!c.ok&&i._options.throwHttpErrors){let d=new h5a(c,i.request,i._options);for(let s of i._options.hooks.beforeError)d=await s(d);throw d}if(i._options.onDownloadProgress){if(typeof i._options.onDownloadProgress!="function")throw new TypeError("The `onDownloadProgress` option must be a function");if(!yO_)throw new Error("Streams are not supported in your environment. `ReadableStream` is missing.");return PO_(c.clone(),i._options.onDownloadProgress)}return c},u=(i._options.retry.methods.includes(i.request.method.toLowerCase())?i._retry(n):n()).finally(async()=>{i.request.bodyUsed||await i.request.body?.cancel()});for(let[c,d]of Object.entries(bO_))u[c]=async()=>{i.request.headers.set("accept",i.request.headers.get("accept")||d);let s=await u;if(c==="json"){if(s.status===204||(await s.clone().arrayBuffer()).byteLength===0)return"";if(r.parseJson)return r.parseJson(await s.text())}return s[c]()};return u}request;abortController;_retryCount=0;_input;_options;constructor(t,r={}){if(this._input=t,this._options={...r,headers:Ywc(this._input.headers,r.headers),hooks:Xwc({beforeRequest:[],beforeRetry:[],beforeError:[],afterResponse:[]},r.hooks),method:SO_(r.method??this._input.method??"GET"),prefixUrl:String(r.prefixUrl||""),retry:DO_(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(hO_){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(Kwc&&(this._options.duplex="half"),this._options.json!==void 0&&(this._options.body=this._options.stringifyJson?.(this._options.json)??JSON.stringify(this._options.json),this._options.headers.set("content-type",this._options.headers.get("content-type")??"application/json")),this.request=new globalThis.Request(this._input,this._options),this._options.searchParams){let n="?"+(typeof this._options.searchParams=="string"?this._options.searchParams.replace(/^\?/,""):new URLSearchParams(this._options.searchParams).toString()),a=this.request.url.replace(/(?:\?.*?)?(?=#|$)/,n);(vO_&&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(!Kwc)throw new Error("Request streams are not supported in your environment. The `duplex` option for `Request` is not available.");this.request.body&&(this.request=jO_(this.request,this._options.onUploadProgress))}}_calculateRetryDelay(t){if(this._retryCount++,this._retryCount>this._options.retry.limit||t instanceof BJn)throw t;if(t instanceof h5a){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),Fru);if(this._retryCount<1)throw r;await e1c(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})===Lru)return;return this._retry(t)}}async _fetch(){for(let i of this._options.hooks.beforeRequest){let n=await i(this.request,this._options);if(n instanceof Request){this.request=n;break}if(n instanceof Response)return n}let t=EO_(this.request,this._options),r=this.request;return this.request=r.clone(),this._options.timeout===!1?this._options.fetch(r,t):kwc(r,t,this.abortController,this._options)}};var t1c=e=>{let t=(r,i)=>v5a.create(r,y5a(e,i));for(let r of Nru)t[r]=(i,n)=>v5a.create(i,y5a(e,n,{method:r}));return t.create=r=>t1c(y5a(r)),t.extend=r=>(typeof r=="function"&&(r=r(e??{})),t1c(y5a(e,r))),t.stop=Lru,t},oqE=t1c(),MO_=oqE;var XO_=ci(YO_(),1);function o1c(e){let t=(0,XO_.default)("npm",{registry:"https://registry.npmjs.org/"}),r=t[`${e}:registry`]||t.config_registry||t.registry;return r.slice(-1)==="/"?r:`${r}/`}var $m_=ci(Hm_(),1),Gm_=ci(bgi(),1),g1c=class extends Error{constructor(t){super(`Package \`${t}\` could not be found`),this.name="PackageNotFoundError"}},O1c=class extends Error{constructor(t,r){super(`Version \`${r}\` for package \`${t}\` could not be found`),this.name="VersionNotFoundError"}};async function m1c(e,t={}){let{version:r="latest"}=t,{omitDeprecated:i=!0}=t,n=e.split("/")[0],a=t.registryUrl??o1c(n),u=new URL(encodeURIComponent(e).replace(/^%40/,"@"),a),c=(0,$m_.default)(a.toString(),{recursive:!0}),d={accept:"application/vnd.npm.install-v1+json; q=1.0, application/json; q=0.8, */*"};t.fullMetadata&&delete d.accept,c&&(d.authorization=`${c.type} ${c.token}`);let s;try{s=await MO_(u,{headers:d,keepalive:!0}).json()}catch(l){throw l?.response?.status===404?new g1c(e):l}if(t.allVersions)return s;let o=new O1c(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[g,O]of Object.entries(s.versions))O.deprecated&&delete s.versions[g];if(!l){let g=Object.keys(s.versions);if(r=Gm_.default.maxSatisfying(g,r),!r)throw o}let{time:b}=s;if(s=s.versions[r],s.time=b,!s)throw o}return s}async function j5a(e,t){let{version:r}=await m1c(e.toLowerCase(),t);return r}async function ONi({cliEnvironment:e,includePreReleases:t=!1}){return e.packageName!=="fern-api"?e.packageVersion:j5a(e.packageName,{version:t?"prerelease":"latest"})}var Qm_=["#2E86AB","#A23B72","#F18F01","#C73E1D","#CCE2A3"],kru=class{environment;didSucceed=!0;numTasks=0;ttyAwareLogger;logLevel=Ab.Info;isLocal;constructor(t,r,{isLocal:i}){this.ttyAwareLogger=new xru(t,r),this.isLocal=i??!1;let n=this.getPackageName(),a=this.getPackageVersion(),u=this.getCliName();(n==null||a==null||u==null)&&this.exitProgram(),this.environment={packageName:n,packageVersion:a,cliName:u}}getPackageName(){return"fern-api"}getPackageVersion(){return"0.69.1"}getCliName(){return"fern"}setLogLevel(t){this.logLevel=t}logDebugInfo(){this.logger.debug(`Running ${Bs.bold(`${this.environment.cliName}`)} (${this.environment.packageName}@${this.environment.packageVersion})`)}failAndThrow(t,r){throw this.failWithoutThrowing(t,r),new X8}failWithoutThrowing(t,r){this.didSucceed=!1,Cru({message:t,error:r,logger:this.logger})}async exit({code:t}={}){(!this._suppressUpgradeMessage||!this.isLocal)&&await this.nudgeUpgradeIfAvailable(),this.ttyAwareLogger.finish(),await(await dHn()).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 dO_({cliEnvironment:this.environment,upgradeInfo:t});r!=null&&(r.endsWith(`
|
|
1958
1958
|
`)||(r+=`
|
|
1959
1959
|
`),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=DHs(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 s5a(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 X8}finally{i.finish()}return n}async instrumentPostHogEvent(t){this.isLocal||(await dHn()).sendEvent(t)}logger=Ptr((t,...r)=>this.log(t,...r));stderr=Ptr((t,...r)=>this.logStderr(t,...r));constructTaskInitForWorkspace(t){let r=Jm_(t.type==="docs"?"docs":t.workspaceName??"api"),i=1+(this.longestWorkspaceName!=null?Jm_(this.longestWorkspaceName):r).length,n=r.padEnd(i),a=Qm_[this.numTasks++%Qm_.length],u=Bs.hex(a)(n);return{...this.constructTaskInit(),logPrefix:u}}constructTaskInit(){return{logImmediately:t=>this.logImmediately(t),takeOverTerminal:t=>this.ttyAwareLogger.takeOverTerminal(t),onResult:t=>{t===LI.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=>WBi.indexOf(n.level)>=WBi.indexOf(this.logLevel));this.ttyAwareLogger.log(i,{includeDebugInfo:this.logLevel===Ab.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 ONi({cliEnvironment:this.environment,includePreReleases:t}),i=xue(r,this.environment.packageVersion);this.logger.debug(`Latest version: ${r}. `+(i?"Upgrade available.":"No upgrade available."));let n={isUpgradeAvailable:i,latestVersion:r},a=await Rru({project:this.project,cliContext:this});this._isUpgradeAvailable={cliUpgradeInfo:n,generatorUpgradeInfo:a}}return this._isUpgradeAvailable}async confirmPrompt(t,r=!1){return await Bwc({message:t,default:r})}async getInput(t){return await Iwc({message:t.message,default:t.default})}};function Jm_(e){return`[${e}]:`}var LQt=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}};var Tqe=class extends LQt{definition;sources;type="fern";constructor({definition:t,sources:r,...i}){super(i),this.definition=t,this.sources=r??[]}async getDefinition(){return this.definition}async toFernWorkspace(){return this}getSources(){return this.sources}getAbsoluteFilePaths(){return[this.absoluteFilePath]}};var Umi={enableUniqueErrorsPerEndpoint:!1,detectGlobalHeaders:!0,objectQueryParameters:!1,respectReadonlySchemas:!1,respectNullableSchemas:!1,onlyIncludeReferencedSchemas:!1,inlinePathParameters:!1,useBytesForBinaryResponse:!1,respectForwardCompatibleEnums:!1};function w5a({options:e,overrides:t}){return{enableUniqueErrorsPerEndpoint:t?.enableUniqueErrorsPerEndpoint??e?.enableUniqueErrorsPerEndpoint??Umi.enableUniqueErrorsPerEndpoint,detectGlobalHeaders:t?.detectGlobalHeaders??e?.detectGlobalHeaders??Umi.detectGlobalHeaders,objectQueryParameters:t?.objectQueryParameters??e?.objectQueryParameters??Umi.objectQueryParameters,respectReadonlySchemas:t?.respectReadonlySchemas??e?.respectReadonlySchemas??Umi.respectReadonlySchemas,respectNullableSchemas:t?.respectNullableSchemas??e?.respectNullableSchemas??Umi.respectNullableSchemas,onlyIncludeReferencedSchemas:t?.onlyIncludeReferencedSchemas??e?.onlyIncludeReferencedSchemas??Umi.onlyIncludeReferencedSchemas,inlinePathParameters:t?.inlinePathParameters??e?.inlinePathParameters??Umi.inlinePathParameters,useBytesForBinaryResponse:t?.useBytesForBinaryResponse??e?.useBytesForBinaryResponse??Umi.useBytesForBinaryResponse,respectForwardCompatibleEnums:t?.respectForwardCompatibleEnums??e?.respectForwardCompatibleEnums??Umi.respectForwardCompatibleEnums}}var RK={openapi:e=>({...e,type:"openapi",_visit:function(t){return RK._visit(this,t)}}),protobuf:e=>({...e,type:"protobuf",_visit:function(t){return RK._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"openapi":return t.openapi(e);case"protobuf":return t.protobuf(e);default:return t._other(e)}}};var UJn={protobuf:e=>({...e,type:"protobuf",_visit:function(t){return UJn._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"protobuf":return t.protobuf(e);default:return t._other(e)}}};var AU={basic:e=>({...e,type:"basic",_visit:function(t){return AU._visit(this,t)}}),bearer:e=>({...e,type:"bearer",_visit:function(t){return AU._visit(this,t)}}),header:e=>({...e,type:"header",_visit:function(t){return AU._visit(this,t)}}),query:e=>({...e,type:"query",_visit:function(t){return AU._visit(this,t)}}),oauth:e=>({...e,type:"oauth",_visit:function(t){return AU._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"basic":return t.basic(e);case"bearer":return t.bearer(e);case"header":return t.header(e);case"query":return t.query(e);case"oauth":return t.oauth(e);default:return t._other(e)}}};var rO={primitive:e=>({value:e,type:"primitive",_visit:function(t){return rO._visit(this,t)}}),object:e=>({...e,type:"object",_visit:function(t){return rO._visit(this,t)}}),array:e=>({value:e,type:"array",_visit:function(t){return rO._visit(this,t)}}),map:e=>({value:e,type:"map",_visit:function(t){return rO._visit(this,t)}}),enum:e=>({value:e,type:"enum",_visit:function(t){return rO._visit(this,t)}}),literal:e=>({value:e,type:"literal",_visit:function(t){return rO._visit(this,t)}}),oneOf:e=>({value:e,type:"oneOf",_visit:function(t){return rO._visit(this,t)}}),unknown:e=>({value:e,type:"unknown",_visit:function(t){return rO._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"primitive":return t.primitive(e.value);case"object":return t.object(e);case"array":return t.array(e.value);case"map":return t.map(e.value);case"enum":return t.enum(e.value);case"literal":return t.literal(e.value);case"oneOf":return t.oneOf(e.value);case"unknown":return t.unknown(e.value);default:return t._other(e)}}};var M_={int:e=>({value:e,type:"int",_visit:function(t){return M_._visit(this,t)}}),int64:e=>({value:e,type:"int64",_visit:function(t){return M_._visit(this,t)}}),uint:e=>({value:e,type:"uint",_visit:function(t){return M_._visit(this,t)}}),uint64:e=>({value:e,type:"uint64",_visit:function(t){return M_._visit(this,t)}}),float:e=>({value:e,type:"float",_visit:function(t){return M_._visit(this,t)}}),double:e=>({value:e,type:"double",_visit:function(t){return M_._visit(this,t)}}),string:e=>({value:e,type:"string",_visit:function(t){return M_._visit(this,t)}}),datetime:e=>({value:e,type:"datetime",_visit:function(t){return M_._visit(this,t)}}),date:e=>({value:e,type:"date",_visit:function(t){return M_._visit(this,t)}}),base64:e=>({value:e,type:"base64",_visit:function(t){return M_._visit(this,t)}}),boolean:e=>({value:e,type:"boolean",_visit:function(t){return M_._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"int":return t.int(e.value);case"int64":return t.int64(e.value);case"uint":return t.uint(e.value);case"uint64":return t.uint64(e.value);case"float":return t.float(e.value);case"double":return t.double(e.value);case"string":return t.string(e.value);case"datetime":return t.datetime(e.value);case"date":return t.date(e.value);case"base64":return t.base64(e.value);case"boolean":return t.boolean(e.value);default:return t._other(e)}}};var mNi={boolean:e=>({value:e,type:"boolean",_visit:function(t){return mNi._visit(this,t)}}),string:e=>({value:e,type:"string",_visit:function(t){return mNi._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"boolean":return t.boolean(e.value);case"string":return t.string(e.value);default:return t._other(e)}}};var PNi={discriminated:e=>({value:e,type:"discriminated",_visit:function(t){return PNi._visit(this,t)}}),undiscriminated:e=>({value:e,type:"undiscriminated",_visit:function(t){return PNi._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"discriminated":return t.discriminated(e.value);case"undiscriminated":return t.undiscriminated(e.value);default:return t._other(e)}}};var S$={GenerallyAvailable:"GenerallyAvailable",Beta:"Beta",Deprecated:"Deprecated",_visit:(e,t)=>{switch(e){case S$.GenerallyAvailable:return t.generallyAvailable();case S$.Beta:return t.beta();case S$.Deprecated:return t.deprecated();default:return t._other()}}};var DFe={cursor:e=>({...e,type:"cursor",_visit:function(t){return DFe._visit(this,t)}}),offset:e=>({...e,type:"offset",_visit:function(t){return DFe._visit(this,t)}}),custom:e=>({...e,type:"custom",_visit:function(t){return DFe._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"cursor":return t.cursor(e);case"offset":return t.offset(e);case"custom":return t.custom(e);default:return t._other(e)}}};var Vmi={language:e=>({...e,type:"language",_visit:function(t){return Vmi._visit(this,t)}}),sdk:e=>({...e,type:"sdk",_visit:function(t){return Vmi._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"language":return t.language(e);case"sdk":return t.sdk(e);default:return t._other(e)}}};var D$={Curl:"curl",Python:"python",Javascript:"javascript",Typescript:"typescript",Go:"go",Ruby:"ruby",Csharp:"csharp",Java:"java",Js:"js",Node:"node",Ts:"ts",Nodets:"nodets",Golang:"golang",Dotnet:"dotnet",Jvm:"jvm",_visit:(e,t)=>{switch(e){case D$.Curl:return t.curl();case D$.Python:return t.python();case D$.Javascript:return t.javascript();case D$.Typescript:return t.typescript();case D$.Go:return t.go();case D$.Ruby:return t.ruby();case D$.Csharp:return t.csharp();case D$.Java:return t.java();case D$.Js:return t.js();case D$.Node:return t.node();case D$.Ts:return t.ts();case D$.Nodets:return t.nodets();case D$.Golang:return t.golang();case D$.Dotnet:return t.dotnet();case D$.Jvm:return t.jvm();default:return t._other()}}};var UQt={unknown:e=>({value:e,type:"unknown",_visit:function(t){return UQt._visit(this,t)}}),full:e=>({...e,type:"full",_visit:function(t){return UQt._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"unknown":return t.unknown(e.value);case"full":return t.full(e);default:return t._other(e)}}};var VQt={withStreaming:e=>({...e,type:"withStreaming",_visit:function(t){return VQt._visit(this,t)}}),withoutStreaming:e=>({value:e,type:"withoutStreaming",_visit:function(t){return VQt._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"withStreaming":return t.withStreaming(e);case"withoutStreaming":return t.withoutStreaming(e.value);default:return t._other(e)}}};var E$={Get:"GET",Post:"POST",Put:"PUT",Patch:"PATCH",Delete:"DELETE",Head:"HEAD",Options:"OPTIONS",Trace:"TRACE",_visit:(e,t)=>{switch(e){case E$.Get:return t.get();case E$.Post:return t.post();case E$.Put:return t.put();case E$.Patch:return t.patch();case E$.Delete:return t.delete();case E$.Head:return t.head();case E$.Options:return t.options();case E$.Trace:return t.trace();default:return t._other()}}};var lor={octetStream:e=>({...e,type:"octetStream",_visit:function(t){return lor._visit(this,t)}}),multipart:e=>({...e,type:"multipart",_visit:function(t){return lor._visit(this,t)}}),json:e=>({...e,type:"json",_visit:function(t){return lor._visit(this,t)}}),formUrlEncoded:e=>({...e,type:"formUrlEncoded",_visit:function(t){return lor._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"octetStream":return t.octetStream(e);case"multipart":return t.multipart(e);case"json":return t.json(e);case"formUrlEncoded":return t.formUrlEncoded(e);default:return t._other(e)}}};var Wmi={file:e=>({...e,type:"file",_visit:function(t){return Wmi._visit(this,t)}}),json:e=>({value:e,type:"json",_visit:function(t){return Wmi._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"file":return t.file(e);case"json":return t.json(e.value);default:return t._other(e)}}};var NK={file:e=>({...e,type:"file",_visit:function(t){return NK._visit(this,t)}}),json:e=>({...e,type:"json",_visit:function(t){return NK._visit(this,t)}}),text:e=>({...e,type:"text",_visit:function(t){return NK._visit(this,t)}}),bytes:e=>({...e,type:"bytes",_visit:function(t){return NK._visit(this,t)}}),streamingSse:e=>({...e,type:"streamingSse",_visit:function(t){return NK._visit(this,t)}}),streamingText:e=>({...e,type:"streamingText",_visit:function(t){return NK._visit(this,t)}}),streamingJson:e=>({...e,type:"streamingJson",_visit:function(t){return NK._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"file":return t.file(e);case"json":return t.json(e);case"text":return t.text(e);case"bytes":return t.bytes(e);case"streamingSse":return t.streamingSse(e);case"streamingText":return t.streamingText(e);case"streamingJson":return t.streamingJson(e);default:return t._other(e)}}};var wv={primitive:e=>({...e,type:"primitive",_visit:function(t){return wv._visit(this,t)}}),object:e=>({...e,type:"object",_visit:function(t){return wv._visit(this,t)}}),array:e=>({...e,type:"array",_visit:function(t){return wv._visit(this,t)}}),map:e=>({...e,type:"map",_visit:function(t){return wv._visit(this,t)}}),optional:e=>({...e,type:"optional",_visit:function(t){return wv._visit(this,t)}}),enum:e=>({...e,type:"enum",_visit:function(t){return wv._visit(this,t)}}),reference:e=>({...e,type:"reference",_visit:function(t){return wv._visit(this,t)}}),literal:e=>({...e,type:"literal",_visit:function(t){return wv._visit(this,t)}}),oneOf:e=>({value:e,type:"oneOf",_visit:function(t){return wv._visit(this,t)}}),nullable:e=>({...e,type:"nullable",_visit:function(t){return wv._visit(this,t)}}),unknown:e=>({...e,type:"unknown",_visit:function(t){return wv._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"primitive":return t.primitive(e);case"object":return t.object(e);case"array":return t.array(e);case"map":return t.map(e);case"optional":return t.optional(e);case"enum":return t.enum(e);case"reference":return t.reference(e);case"literal":return t.literal(e);case"oneOf":return t.oneOf(e.value);case"nullable":return t.nullable(e);case"unknown":return t.unknown(e);default:return t._other(e)}}};var Ww={int:e=>({...e,type:"int",_visit:function(t){return Ww._visit(this,t)}}),int64:e=>({...e,type:"int64",_visit:function(t){return Ww._visit(this,t)}}),uint:()=>({type:"uint",_visit:function(e){return Ww._visit(this,e)}}),uint64:()=>({type:"uint64",_visit:function(e){return Ww._visit(this,e)}}),float:()=>({type:"float",_visit:function(e){return Ww._visit(this,e)}}),double:e=>({...e,type:"double",_visit:function(t){return Ww._visit(this,t)}}),string:e=>({...e,type:"string",_visit:function(t){return Ww._visit(this,t)}}),datetime:()=>({type:"datetime",_visit:function(e){return Ww._visit(this,e)}}),date:()=>({type:"date",_visit:function(e){return Ww._visit(this,e)}}),base64:()=>({type:"base64",_visit:function(e){return Ww._visit(this,e)}}),boolean:e=>({...e,type:"boolean",_visit:function(t){return Ww._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"int":return t.int(e);case"int64":return t.int64(e);case"uint":return t.uint();case"uint64":return t.uint64();case"float":return t.float();case"double":return t.double(e);case"string":return t.string(e);case"datetime":return t.datetime();case"date":return t.date();case"base64":return t.base64();case"boolean":return t.boolean(e);default:return t._other(e)}}};var mx={boolean:e=>({value:e,type:"boolean",_visit:function(t){return mx._visit(this,t)}}),string:e=>({value:e,type:"string",_visit:function(t){return mx._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"boolean":return t.boolean(e.value);case"string":return t.string(e.value);default:return t._other(e)}}};var Hmi={discriminated:e=>({...e,type:"discriminated",_visit:function(t){return Hmi._visit(this,t)}}),undiscriminated:e=>({...e,type:"undiscriminated",_visit:function(t){return Hmi._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"discriminated":return t.discriminated(e);case"undiscriminated":return t.undiscriminated(e);default:return t._other(e)}}};var zee={octetStream:e=>({...e,type:"octetStream",_visit:function(t){return zee._visit(this,t)}}),multipart:e=>({...e,type:"multipart",_visit:function(t){return zee._visit(this,t)}}),json:e=>({...e,type:"json",_visit:function(t){return zee._visit(this,t)}}),formUrlEncoded:e=>({...e,type:"formUrlEncoded",_visit:function(t){return zee._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"octetStream":return t.octetStream(e);case"multipart":return t.multipart(e);case"json":return t.json(e);case"formUrlEncoded":return t.formUrlEncoded(e);default:return t._other(e)}}};var EB={file:e=>({...e,type:"file",_visit:function(t){return EB._visit(this,t)}}),json:e=>({...e,type:"json",_visit:function(t){return EB._visit(this,t)}}),text:e=>({...e,type:"text",_visit:function(t){return EB._visit(this,t)}}),bytes:e=>({...e,type:"bytes",_visit:function(t){return EB._visit(this,t)}}),streamingSse:e=>({...e,type:"streamingSse",_visit:function(t){return EB._visit(this,t)}}),streamingText:e=>({...e,type:"streamingText",_visit:function(t){return EB._visit(this,t)}}),streamingJson:e=>({...e,type:"streamingJson",_visit:function(t){return EB._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"file":return t.file(e);case"json":return t.json(e);case"text":return t.text(e);case"bytes":return t.bytes(e);case"streamingSse":return t.streamingSse(e);case"streamingText":return t.streamingText(e);case"streamingJson":return t.streamingJson(e);default:return t._other(e)}}};var Nl={primitive:e=>({...e,type:"primitive",_visit:function(t){return Nl._visit(this,t)}}),object:e=>({...e,type:"object",_visit:function(t){return Nl._visit(this,t)}}),array:e=>({...e,type:"array",_visit:function(t){return Nl._visit(this,t)}}),map:e=>({...e,type:"map",_visit:function(t){return Nl._visit(this,t)}}),optional:e=>({...e,type:"optional",_visit:function(t){return Nl._visit(this,t)}}),enum:e=>({...e,type:"enum",_visit:function(t){return Nl._visit(this,t)}}),reference:e=>({...e,type:"reference",_visit:function(t){return Nl._visit(this,t)}}),literal:e=>({...e,type:"literal",_visit:function(t){return Nl._visit(this,t)}}),oneOf:e=>({value:e,type:"oneOf",_visit:function(t){return Nl._visit(this,t)}}),nullable:e=>({...e,type:"nullable",_visit:function(t){return Nl._visit(this,t)}}),unknown:e=>({...e,type:"unknown",_visit:function(t){return Nl._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"primitive":return t.primitive(e);case"object":return t.object(e);case"array":return t.array(e);case"map":return t.map(e);case"optional":return t.optional(e);case"enum":return t.enum(e);case"reference":return t.reference(e);case"literal":return t.literal(e);case"oneOf":return t.oneOf(e.value);case"nullable":return t.nullable(e);case"unknown":return t.unknown(e);default:return t._other(e)}}};var xee={discriminated:e=>({...e,type:"discriminated",_visit:function(t){return xee._visit(this,t)}}),undiscriminated:e=>({...e,type:"undiscriminated",_visit:function(t){return xee._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"discriminated":return t.discriminated(e);case"undiscriminated":return t.undiscriminated(e);default:return t._other(e)}}};var bp={int:e=>({...e,type:"int",_visit:function(t){return bp._visit(this,t)}}),int64:e=>({...e,type:"int64",_visit:function(t){return bp._visit(this,t)}}),uint:e=>({...e,type:"uint",_visit:function(t){return bp._visit(this,t)}}),uint64:e=>({...e,type:"uint64",_visit:function(t){return bp._visit(this,t)}}),float:e=>({...e,type:"float",_visit:function(t){return bp._visit(this,t)}}),double:e=>({...e,type:"double",_visit:function(t){return bp._visit(this,t)}}),string:e=>({...e,type:"string",_visit:function(t){return bp._visit(this,t)}}),datetime:e=>({...e,type:"datetime",_visit:function(t){return bp._visit(this,t)}}),date:e=>({...e,type:"date",_visit:function(t){return bp._visit(this,t)}}),base64:e=>({...e,type:"base64",_visit:function(t){return bp._visit(this,t)}}),boolean:e=>({...e,type:"boolean",_visit:function(t){return bp._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"int":return t.int(e);case"int64":return t.int64(e);case"uint":return t.uint(e);case"uint64":return t.uint64(e);case"float":return t.float(e);case"double":return t.double(e);case"string":return t.string(e);case"datetime":return t.datetime(e);case"date":return t.date(e);case"base64":return t.base64(e);case"boolean":return t.boolean(e);default:return t._other(e)}}};var Bv={};xa(Bv,{AllOfPropertyConflict:()=>lKn,ArraySchema:()=>ynu,ArraySchemaWithExample:()=>Qnu,Availability:()=>ciu,Base64WithExample:()=>Vnu,BasicSecurityScheme:()=>diu,BearerSecurityScheme:()=>piu,BooleanSchema:()=>lnu,BooleanWithExample:()=>Wnu,BytesResponse:()=>tKn,CasingOverrides:()=>yiu,CommonProperty:()=>wnu,CommonPropertyWithExample:()=>rau,CursorPagination:()=>Qiu,CustomCodeSample:()=>$iu,CustomCodeSampleLanguage:()=>Viu,CustomCodeSampleSdk:()=>Hiu,CustomPagination:()=>Kiu,DateWithExample:()=>Unu,DatetimeWithExample:()=>Lnu,DiscriminatedOneOfSchema:()=>Pnu,DiscriminatedOneOfSchemaWithExample:()=>eau,DoubleSchema:()=>snu,DoubleWithExample:()=>Nnu,Encoding:()=>siu,Endpoint:()=>Yiu,EndpointExample:()=>aKn,EndpointResponseExample:()=>Uiu,EndpointSdkName:()=>_or,EndpointWithExample:()=>wP_,EnumSchema:()=>$Jn,EnumSchemaWithExample:()=>$nu,EnumValue:()=>SNi,ErrorExample:()=>xiu,FernExample:()=>Niu,FileResponse:()=>kJn,FileSchema:()=>Miu,FloatWithExample:()=>Rnu,FormUrlEncodedRequest:()=>Biu,FullEndpointExample:()=>Giu,FullExample:()=>QT,FullObjectExample:()=>jiu,FullOneOfExample:()=>Siu,GlobalHeader:()=>dnu,Header:()=>ENi,HeaderExample:()=>nKn,HeaderSecurityScheme:()=>_iu,HeaderWithExample:()=>qNi,HttpEndpointServer:()=>rKn,HttpError:()=>Riu,HttpErrorWithExample:()=>Cnu,HttpMethod:()=>JJn,IdempotencyHeader:()=>pnu,Int64WithExample:()=>Inu,IntSchema:()=>onu,IntWithExample:()=>Bnu,JsonRequest:()=>Ciu,JsonRequestWithExample:()=>Mnu,JsonResponse:()=>eKn,JsonResponseWithExample:()=>pKn,KeyValuePair:()=>wiu,LiteralExample:()=>Piu,LiteralSchema:()=>cKn,LiteralSchemaValue:()=>_nu,LongSchema:()=>unu,MapSchema:()=>vnu,MapSchemaWithExample:()=>Jnu,MultipartRequest:()=>ZJn,MultipartRequestProperty:()=>Tiu,MultipartRequestPropertyEncoding:()=>qiu,MultipartSchema:()=>Aiu,NamedFullExample:()=>MFe,Namespace:()=>viu,NamespaceId:()=>miu,NullableSchema:()=>gnu,NullableSchemaWithExample:()=>Ynu,OauthSecurityScheme:()=>giu,ObjectProperty:()=>mnu,ObjectPropertyConflictInfo:()=>fKn,ObjectPropertyWithExample:()=>knu,ObjectSchema:()=>hnu,ObjectSchemaWithExample:()=>Xnu,OctetStreamRequest:()=>XJn,OffsetPagination:()=>Jiu,OneOfSchema:()=>Onu,OneOfSchemaWithExample:()=>Znu,OpenApiIntermediateRepresentation:()=>PP_,OpenApiSource:()=>niu,OptionalSchema:()=>bnu,OptionalSchemaWithExample:()=>Knu,Pagination:()=>oKn,ParseFormUrlEncodedRequest:()=>Anu,ParseMultipartRequest:()=>Enu,ParseOctetStreamRequest:()=>Dnu,PathParameter:()=>KJn,PathParameterExample:()=>Fiu,PathParameterWithExample:()=>Snu,PrimitiveExample:()=>QJn,PrimitiveSchema:()=>ANi,PrimitiveSchemaValue:()=>fnu,PrimitiveSchemaValueWithExample:()=>Hnu,PrimitiveSchemaWithExample:()=>_Kn,PropertyKey:()=>GJn,ProtobufEncoding:()=>uiu,ProtobufSource:()=>aiu,QueryParameter:()=>YJn,QueryParameterExample:()=>iKn,QueryParameterWithExample:()=>dKn,QuerySecurityScheme:()=>hiu,ReferencedSchema:()=>hor,Request:()=>Iiu,RequestWithExample:()=>qnu,Response:()=>ziu,ResponseWithExample:()=>Tnu,Schema:()=>um,SchemaId:()=>Ree,SchemaWithExample:()=>VM,Schemas:()=>anu,SdkGroup:()=>biu,SdkGroupInfo:()=>Diu,SdkGroupName:()=>DNi,SecurityScheme:()=>Oiu,SecuritySchemeId:()=>fiu,Server:()=>M5a,Source:()=>oiu,StatusCode:()=>dor,StreamingResponseExample:()=>Liu,StringSchema:()=>cnu,StringSchemaWithExample:()=>Fnu,SupportedSdkLanguage:()=>Wiu,Tag:()=>liu,TagId:()=>Nee,Tags:()=>Eiu,TextResponse:()=>MNi,Uint64WithExample:()=>xnu,UintWithExample:()=>znu,UnDiscriminatedOneOfSchema:()=>jnu,UnDiscriminatedOneOfSchemaWithExample:()=>tau,UnknownSchemaWithExample:()=>Gnu,Webhook:()=>Xiu,WebhookExampleCall:()=>sKn,WebhookHttpMethod:()=>uKn,WebhookWithExample:()=>SP_,WebsocketChannel:()=>nnu,WebsocketHandshake:()=>Ziu,WebsocketHandshakeWithExample:()=>jP_,WebsocketMessageExample:()=>rnu,WebsocketMessageOrigin:()=>kiu,WebsocketMessageSchema:()=>enu,WebsocketServer:()=>tnu,WebsocketSessionExample:()=>inu,WithAvailability:()=>cy,WithDescription:()=>Of,WithEncoding:()=>Nue,WithInline:()=>UM,WithName:()=>bg,WithNamespace:()=>L0,WithSdkGroupName:()=>Jm,WithSdkMethodName:()=>por,WithSource:()=>zh,WithStatusCode:()=>EFe,WithTitle:()=>Qm,commons:()=>D1c,example:()=>E1c,finalIr:()=>M1c,parseIr:()=>A1c});var D1c={};xa(D1c,{BasicSecurityScheme:()=>diu,BearerSecurityScheme:()=>piu,Encoding:()=>siu,HeaderSecurityScheme:()=>_iu,Namespace:()=>viu,NamespaceId:()=>miu,OauthSecurityScheme:()=>giu,OpenApiSource:()=>niu,ProtobufEncoding:()=>uiu,ProtobufSource:()=>aiu,QuerySecurityScheme:()=>hiu,SchemaId:()=>Ree,SdkGroup:()=>biu,SdkGroupName:()=>DNi,SecurityScheme:()=>Oiu,SecuritySchemeId:()=>fiu,Server:()=>M5a,Source:()=>oiu,StatusCode:()=>dor,Tag:()=>liu,TagId:()=>Nee,WithAvailability:()=>cy,WithDescription:()=>Of,WithEncoding:()=>Nue,WithInline:()=>UM,WithName:()=>bg,WithNamespace:()=>L0,WithSdkGroupName:()=>Jm,WithSdkMethodName:()=>por,WithSource:()=>zh,WithStatusCode:()=>EFe,WithTitle:()=>Qm});var gt={};xa(gt,{JsonError:()=>VJn,ParseError:()=>WJn,any:()=>cP_,bigint:()=>Ym_,boolean:()=>lP_,booleanLiteral:()=>sP_,date:()=>Xm_,discriminant:()=>gP_,enum_:()=>tiu,getObjectLikeUtils:()=>WQt,getObjectUtils:()=>Wnn,getSchemaUtils:()=>GT,isProperty:()=>wNi,lazy:()=>Zm_,lazyObject:()=>aP_,list:()=>iiu,number:()=>fP_,object:()=>riu,objectWithoutOptionalProperties:()=>nP_,optional:()=>P1c,property:()=>eP_,record:()=>hP_,set:()=>yP_,string:()=>dP_,stringLiteral:()=>uP_,transform:()=>j1c,undiscriminatedUnion:()=>bP_,union:()=>mP_,unknown:()=>pP_,withParsedProperties:()=>S1c});var vw={BIGINT:"bigint",DATE:"date",ENUM:"enum",LIST:"list",STRING_LITERAL:"stringLiteral",BOOLEAN_LITERAL:"booleanLiteral",OBJECT:"object",ANY:"any",BOOLEAN:"boolean",NUMBER:"number",STRING:"string",UNKNOWN:"unknown",RECORD:"record",SET:"set",UNION:"union",UNDISCRIMINATED_UNION:"undiscriminatedUnion",OPTIONAL:"optional"};function _q(e,t){return`Expected ${t}. Received ${dTE(e)}.`}function dTE(e){if(Array.isArray(e))return"list";if(e===null)return"null";if(e instanceof BigInt)return"BigInt";switch(typeof e){case"string":return`"${e}"`;case"bigint":case"number":case"boolean":case"undefined":return`${e}`}return typeof e}function qU(e){return{...e,json:Km_(e.json),parse:Km_(e.parse)}}function Km_(e){return(t,r)=>{let i=e(t,r),{skipValidation:n=!1}=r??{};return!i.ok&&n?(console.warn(["Failed to validate.",...i.errors.map(a=>" - "+(a.path.length>0?`${a.path.join(".")}: ${a.message}`:a.message))].join(`
|
|
1960
1960
|
`)),{ok:!0,value:t}):i}}function eiu(e){return e.path.length===0?e.message:`${e.path.join(" -> ")}: ${e.message}`}var VJn=class e extends Error{errors;constructor(t){super(t.map(eiu).join("; ")),this.errors=t,Object.setPrototypeOf(this,e.prototype)}};var WJn=class e extends Error{errors;constructor(t){super(t.map(eiu).join("; ")),this.errors=t,Object.setPrototypeOf(this,e.prototype)}};function GT(e){return{optional:()=>P1c(e),transform:t=>j1c(e,t),parseOrThrow:(t,r)=>{let i=e.parse(t,r);if(i.ok)return i.value;throw new WJn(i.errors)},jsonOrThrow:(t,r)=>{let i=e.json(t,r);if(i.ok)return i.value;throw new VJn(i.errors)}}}function P1c(e){let t={parse:(r,i)=>r==null?{ok:!0,value:void 0}:e.parse(r,i),json:(r,i)=>i?.omitUndefined&&r===void 0?{ok:!0,value:void 0}:r==null?{ok:!0,value:null}:e.json(r,i),getType:()=>vw.OPTIONAL};return{...t,...GT(t)}}function j1c(e,t){let r={parse:(i,n)=>{let a=e.parse(i,n);return a.ok?{ok:!0,value:t.transform(a.value)}:a},json:(i,n)=>{let a=t.untransform(i);return e.json(a,n)},getType:()=>e.getType()};return{...r,...GT(r)}}function Ym_(){let e={parse:(t,{breadcrumbsPrefix:r=[]}={})=>typeof t!="string"?{ok:!1,errors:[{path:r,message:_q(t,"string")}]}:{ok:!0,value:BigInt(t)},json:(t,{breadcrumbsPrefix:r=[]}={})=>typeof t=="bigint"?{ok:!0,value:t.toString()}:{ok:!1,errors:[{path:r,message:_q(t,"bigint")}]},getType:()=>vw.BIGINT};return{...qU(e),...GT(e)}}var pTE=/^([+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-2])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-3])((:?)[0-5]\d)?|24:?00)([.,]\d+(?!:))?)?(\17[0-5]\d([.,]\d+)?)?([zZ]|([+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/;function Xm_(){let e={parse:(t,{breadcrumbsPrefix:r=[]}={})=>typeof t!="string"?{ok:!1,errors:[{path:r,message:_q(t,"string")}]}:pTE.test(t)?{ok:!0,value:new Date(t)}:{ok:!1,errors:[{path:r,message:_q(t,"ISO 8601 date string")}]},json:(t,{breadcrumbsPrefix:r=[]}={})=>t instanceof Date?{ok:!0,value:t.toISOString()}:{ok:!1,errors:[{path:r,message:_q(t,"Date object")}]},getType:()=>vw.DATE};return{...qU(e),...GT(e)}}function FK(e,t){return()=>{let r={parse:t,json:t,getType:()=>e};return{...qU(r),...GT(r)}}}function tiu(e){let t=new Set(e);return FK(vw.ENUM,(i,{allowUnrecognizedEnumValues:n,breadcrumbsPrefix:a=[]}={})=>typeof i!="string"?{ok:!1,errors:[{path:a,message:_q(i,"string")}]}:!t.has(i)&&!n?{ok:!1,errors:[{path:a,message:_q(i,"enum")}]}:{ok:!0,value:i})()}function Zm_(e){let t=w1c(e);return{...t,...GT(t)}}function w1c(e){return{parse:(t,r)=>HJn(e).parse(t,r),json:(t,r)=>HJn(e).json(t,r),getType:()=>HJn(e).getType()}}function HJn(e){let t=e;return t.__zurg_memoized==null&&(t.__zurg_memoized=e()),t.__zurg_memoized}function S5a(e){return Object.entries(e)}function D5a(e,t){let r=new Set(t);return Object.entries(e).reduce((i,[n,a])=>(r.has(n)&&(i[n]=a),i),{})}function jNi(e){if(typeof e!="object"||e===null)return!1;if(Object.getPrototypeOf(e)===null)return!0;let t=e;for(;Object.getPrototypeOf(t)!==null;)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t}function E5a(e){return Object.keys(e)}function km_(e,t){let r=[],i=[];for(let n of e)t(n)?r.push(n):i.push(n);return[r,i]}function WQt(e){return{withParsedProperties:t=>S1c(e,t)}}function S1c(e,t){let r={parse:(i,n)=>{let a=e.parse(i,n);if(!a.ok)return a;let u=Object.entries(t).reduce((c,[d,s])=>({...c,[d]:typeof s=="function"?s(a.value):s}),{});return{ok:!0,value:{...a.value,...u}}},json:(i,n)=>{if(!jNi(i))return{ok:!1,errors:[{path:n?.breadcrumbsPrefix??[],message:_q(i,"object")}]};let a=new Set(Object.keys(t)),u=D5a(i,Object.keys(i).filter(c=>!a.has(c)));return e.json(u,n)},getType:()=>e.getType()};return{...r,...GT(r),...WQt(r)}}function eP_(e,t){return{rawKey:e,valueSchema:t,isProperty:!0}}function wNi(e){return e.isProperty}function riu(e){let t={_getRawProperties:()=>Object.entries(e).map(([r,i])=>wNi(i)?i.rawKey:r),_getParsedProperties:()=>E5a(e),parse:(r,i)=>{let n={},a=[];for(let[u,c]of S5a(e)){let d=wNi(c)?c.rawKey:u,s=wNi(c)?c.valueSchema:c,o={rawKey:d,parsedKey:u,valueSchema:s};n[d]=o,iP_(s)&&a.push(d)}return tP_({value:r,requiredKeys:a,getProperty:u=>{let c=n[u];if(c!=null)return{transformedKey:c.parsedKey,transform:d=>c.valueSchema.parse(d,{...i,breadcrumbsPrefix:[...i?.breadcrumbsPrefix??[],u]})}},unrecognizedObjectKeys:i?.unrecognizedObjectKeys,skipValidation:i?.skipValidation,breadcrumbsPrefix:i?.breadcrumbsPrefix,omitUndefined:i?.omitUndefined})},json:(r,i)=>{let n=[];for(let[a,u]of S5a(e)){let c=wNi(u)?u.valueSchema:u;iP_(c)&&n.push(a)}return tP_({value:r,requiredKeys:n,getProperty:a=>{let u=e[a];if(u!=null)return wNi(u)?{transformedKey:u.rawKey,transform:c=>u.valueSchema.json(c,{...i,breadcrumbsPrefix:[...i?.breadcrumbsPrefix??[],a]})}:{transformedKey:a,transform:c=>u.json(c,{...i,breadcrumbsPrefix:[...i?.breadcrumbsPrefix??[],a]})}},unrecognizedObjectKeys:i?.unrecognizedObjectKeys,skipValidation:i?.skipValidation,breadcrumbsPrefix:i?.breadcrumbsPrefix,omitUndefined:i?.omitUndefined})},getType:()=>vw.OBJECT};return{...qU(t),...GT(t),...WQt(t),...Wnn(t)}}function tP_({value:e,requiredKeys:t,getProperty:r,unrecognizedObjectKeys:i="fail",skipValidation:n=!1,breadcrumbsPrefix:a=[]}){if(!jNi(e))return{ok:!1,errors:[{path:a,message:_q(e,"object")}]};let u=new Set(t),c=[],d={};for(let[s,o]of Object.entries(e)){let l=r(s);if(l!=null){u.delete(s);let b=l.transform(o);b.ok?d[l.transformedKey]=b.value:(d[s]=o,c.push(...b.errors))}else switch(i){case"fail":c.push({path:[...a,s],message:`Unexpected key "${s}"`});break;case"strip":break;case"passthrough":d[s]=o;break}}return c.push(...t.filter(s=>u.has(s)).map(s=>({path:a,message:`Missing required key "${s}"`}))),c.length===0||n?{ok:!0,value:d}:{ok:!1,errors:c}}function Wnn(e){return{extend:t=>{let r={_getParsedProperties:()=>[...e._getParsedProperties(),...t._getParsedProperties()],_getRawProperties:()=>[...e._getRawProperties(),...t._getRawProperties()],parse:(i,n)=>rP_({extensionKeys:t._getRawProperties(),value:i,transformBase:a=>e.parse(a,n),transformExtension:a=>t.parse(a,n)}),json:(i,n)=>rP_({extensionKeys:t._getParsedProperties(),value:i,transformBase:a=>e.json(a,n),transformExtension:a=>t.json(a,n)}),getType:()=>vw.OBJECT};return{...r,...GT(r),...WQt(r),...Wnn(r)}},passthrough:()=>{let t={_getParsedProperties:()=>e._getParsedProperties(),_getRawProperties:()=>e._getRawProperties(),parse:(r,i)=>{let n=e.parse(r,{...i,unrecognizedObjectKeys:"passthrough"});return n.ok?{ok:!0,value:{...r,...n.value}}:n},json:(r,i)=>{let n=e.json(r,{...i,unrecognizedObjectKeys:"passthrough"});return n.ok?{ok:!0,value:{...r,...n.value}}:n},getType:()=>vw.OBJECT};return{...t,...GT(t),...WQt(t),...Wnn(t)}}}}function rP_({extensionKeys:e,value:t,transformBase:r,transformExtension:i}){let n=new Set(e),[a,u]=km_(E5a(t),s=>n.has(s)),c=r(D5a(t,u)),d=i(D5a(t,a));return c.ok&&d.ok?{ok:!0,value:{...c.value,...d.value}}:{ok:!1,errors:[...c.ok?[]:c.errors,...d.ok?[]:d.errors]}}function iP_(e){return!_TE(e)}function _TE(e){switch(e.getType()){case vw.ANY:case vw.UNKNOWN:case vw.OPTIONAL:return!0;default:return!1}}function nP_(e){return riu(e)}function aP_(e){let t={...w1c(e),_getRawProperties:()=>HJn(e)._getRawProperties(),_getParsedProperties:()=>HJn(e)._getParsedProperties()};return{...t,...GT(t),...WQt(t),...Wnn(t)}}function iiu(e){let t={parse:(r,i)=>oP_(r,(n,a)=>e.parse(n,{...i,breadcrumbsPrefix:[...i?.breadcrumbsPrefix??[],`[${a}]`]})),json:(r,i)=>oP_(r,(n,a)=>e.json(n,{...i,breadcrumbsPrefix:[...i?.breadcrumbsPrefix??[],`[${a}]`]})),getType:()=>vw.LIST};return{...qU(t),...GT(t)}}function oP_(e,t){return Array.isArray(e)?e.map((i,n)=>t(i,n)).reduce((i,n)=>{if(i.ok&&n.ok)return{ok:!0,value:[...i.value,n.value]};let a=[];return i.ok||a.push(...i.errors),n.ok||a.push(...n.errors),{ok:!1,errors:a}},{ok:!0,value:[]}):{ok:!1,errors:[{message:_q(e,"list"),path:[]}]}}function uP_(e){return FK(vw.STRING_LITERAL,(r,{breadcrumbsPrefix:i=[]}={})=>r===e?{ok:!0,value:e}:{ok:!1,errors:[{path:i,message:_q(r,`"${e}"`)}]})()}function sP_(e){return FK(vw.BOOLEAN_LITERAL,(r,{breadcrumbsPrefix:i=[]}={})=>r===e?{ok:!0,value:e}:{ok:!1,errors:[{path:i,message:_q(r,`${e.toString()}`)}]})()}var cP_=FK(vw.ANY,e=>({ok:!0,value:e}));var lP_=FK(vw.BOOLEAN,(e,{breadcrumbsPrefix:t=[]}={})=>typeof e=="boolean"?{ok:!0,value:e}:{ok:!1,errors:[{path:t,message:_q(e,"boolean")}]});var fP_=FK(vw.NUMBER,(e,{breadcrumbsPrefix:t=[]}={})=>typeof e=="number"?{ok:!0,value:e}:{ok:!1,errors:[{path:t,message:_q(e,"number")}]});var dP_=FK(vw.STRING,(e,{breadcrumbsPrefix:t=[]}={})=>typeof e=="string"?{ok:!0,value:e}:{ok:!1,errors:[{path:t,message:_q(e,"string")}]});var pP_=FK(vw.UNKNOWN,e=>({ok:!0,value:e}));function hP_(e,t){let r={parse:(i,n)=>_P_({value:i,isKeyNumeric:e.getType()===vw.NUMBER,transformKey:a=>e.parse(a,{...n,breadcrumbsPrefix:[...n?.breadcrumbsPrefix??[],`${a} (key)`]}),transformValue:(a,u)=>t.parse(a,{...n,breadcrumbsPrefix:[...n?.breadcrumbsPrefix??[],`${u}`]}),breadcrumbsPrefix:n?.breadcrumbsPrefix}),json:(i,n)=>_P_({value:i,isKeyNumeric:e.getType()===vw.NUMBER,transformKey:a=>e.json(a,{...n,breadcrumbsPrefix:[...n?.breadcrumbsPrefix??[],`${a} (key)`]}),transformValue:(a,u)=>t.json(a,{...n,breadcrumbsPrefix:[...n?.breadcrumbsPrefix??[],`${u}`]}),breadcrumbsPrefix:n?.breadcrumbsPrefix}),getType:()=>vw.RECORD};return{...qU(r),...GT(r)}}function _P_({value:e,isKeyNumeric:t,transformKey:r,transformValue:i,breadcrumbsPrefix:n=[]}){return jNi(e)?S5a(e).reduce((a,[u,c])=>{if(c==null)return a;let d=a,s=u;if(t){let g=u.length>0?Number(u):NaN;isNaN(g)||(s=g)}let o=r(s),l=i(c,s);if(d.ok&&o.ok&&l.ok)return{ok:!0,value:{...d.value,[o.value]:l.value}};let b=[];return d.ok||b.push(...d.errors),o.ok||b.push(...o.errors),l.ok||b.push(...l.errors),{ok:!1,errors:b}},{ok:!0,value:{}}):{ok:!1,errors:[{path:n,message:_q(e,"object")}]}}function yP_(e){let t=iiu(e),r={parse:(i,n)=>{let a=t.parse(i,n);return a.ok?{ok:!0,value:new Set(a.value)}:a},json:(i,n)=>i instanceof Set?t.json([...i],n):{ok:!1,errors:[{path:n?.breadcrumbsPrefix??[],message:_q(i,"Set")}]},getType:()=>vw.SET};return{...qU(r),...GT(r)}}function bP_(e){let t={parse:(r,i)=>vP_((n,a)=>n.parse(r,a),e,i),json:(r,i)=>vP_((n,a)=>n.json(r,a),e,i),getType:()=>vw.UNDISCRIMINATED_UNION};return{...qU(t),...GT(t)}}function vP_(e,t,r){let i=[];for(let[n,a]of t.entries()){let u=e(a,{...r,skipValidation:!1});if(u.ok)return u;for(let c of u.errors)i.push({path:c.path,message:`[Variant ${n}] ${c.message}`})}return{ok:!1,errors:i}}function gP_(e,t){return{parsedDiscriminant:e,rawDiscriminant:t}}function mP_(e,t){let r=typeof e=="string"?e:e.rawDiscriminant,i=typeof e=="string"?e:e.parsedDiscriminant,n=tiu(E5a(t)),a={parse:(u,c)=>OP_({value:u,discriminant:r,transformedDiscriminant:i,transformDiscriminantValue:d=>n.parse(d,{allowUnrecognizedEnumValues:c?.allowUnrecognizedUnionMembers,breadcrumbsPrefix:[...c?.breadcrumbsPrefix??[],r]}),getAdditionalPropertiesSchema:d=>t[d],allowUnrecognizedUnionMembers:c?.allowUnrecognizedUnionMembers,transformAdditionalProperties:(d,s)=>s.parse(d,c),breadcrumbsPrefix:c?.breadcrumbsPrefix}),json:(u,c)=>OP_({value:u,discriminant:i,transformedDiscriminant:r,transformDiscriminantValue:d=>n.json(d,{allowUnrecognizedEnumValues:c?.allowUnrecognizedUnionMembers,breadcrumbsPrefix:[...c?.breadcrumbsPrefix??[],i]}),getAdditionalPropertiesSchema:d=>t[d],allowUnrecognizedUnionMembers:c?.allowUnrecognizedUnionMembers,transformAdditionalProperties:(d,s)=>s.json(d,c),breadcrumbsPrefix:c?.breadcrumbsPrefix}),getType:()=>vw.UNION};return{...qU(a),...GT(a),...WQt(a)}}function OP_({value:e,discriminant:t,transformedDiscriminant:r,transformDiscriminantValue:i,getAdditionalPropertiesSchema:n,allowUnrecognizedUnionMembers:a=!1,transformAdditionalProperties:u,breadcrumbsPrefix:c=[]}){if(!jNi(e))return{ok:!1,errors:[{path:c,message:_q(e,"object")}]};let{[t]:d,...s}=e;if(d==null)return{ok:!1,errors:[{path:c,message:`Missing discriminant ("${t}")`}]};let o=i(d);if(!o.ok)return{ok:!1,errors:o.errors};let l=n(o.value);if(l==null)return a?{ok:!0,value:{[r]:o.value,...s}}:{ok:!1,errors:[{path:[...c,t],message:"Unexpected discriminant value"}]};let b=u(s,l);return b.ok?{ok:!0,value:{[r]:d,...b.value}}:b}var Qm=gt.objectWithoutOptionalProperties({title:gt.string().optional()});var niu=gt.objectWithoutOptionalProperties({file:gt.string()});var aiu=gt.objectWithoutOptionalProperties({file:gt.string()});var oiu=gt.union("type",{openapi:niu,protobuf:aiu}).transform({transform:e=>{switch(e.type){case"openapi":return RK.openapi(e);case"protobuf":return RK.protobuf(e);default:return e}},untransform:({_visit:e,...t})=>t});var zh=gt.objectWithoutOptionalProperties({source:oiu.optional()});var uiu=gt.objectWithoutOptionalProperties({typeName:gt.string()});var siu=gt.union("type",{protobuf:uiu}).transform({transform:e=>{switch(e.type){case"protobuf":return UJn.protobuf(e);default:return e}},untransform:({_visit:e,...t})=>t});var Nue=gt.objectWithoutOptionalProperties({encoding:siu.optional()});var Of=gt.objectWithoutOptionalProperties({description:gt.string().optional()});var ciu=gt.enum_(["GenerallyAvailable","Beta","Deprecated"]);var cy=gt.objectWithoutOptionalProperties({availability:ciu.optional()});var dor=gt.number();var EFe=gt.objectWithoutOptionalProperties({statusCode:dor.optional()});var bg=gt.objectWithoutOptionalProperties({nameOverride:gt.string().optional(),generatedName:gt.string()});var UM=gt.objectWithoutOptionalProperties({inline:gt.boolean().optional()});var Ree=gt.string();var Nee=gt.string();var liu=gt.objectWithoutOptionalProperties({id:Nee}).extend(Of);var fiu=gt.string();var diu=gt.objectWithoutOptionalProperties({usernameVariableName:gt.string().optional(),usernameEnvVar:gt.string().optional(),passwordVariableName:gt.string().optional(),passwordEnvVar:gt.string().optional()});var piu=gt.objectWithoutOptionalProperties({tokenVariableName:gt.string().optional(),tokenEnvVar:gt.string().optional()});var _iu=gt.objectWithoutOptionalProperties({headerName:gt.string(),prefix:gt.string().optional(),headerVariableName:gt.string().optional(),headerEnvVar:gt.string().optional()});var hiu=gt.objectWithoutOptionalProperties({queryParameterName:gt.string()});var yiu=gt.objectWithoutOptionalProperties({snake:gt.string().optional(),camel:gt.string().optional(),screamingSnake:gt.string().optional(),pascal:gt.string().optional()});var SNi=gt.objectWithoutOptionalProperties({nameOverride:gt.string().optional(),generatedName:gt.string(),value:gt.string(),casing:yiu.optional()}).extend(Of).extend(cy);var viu=gt.objectWithoutOptionalProperties({type:gt.stringLiteral("namespace"),name:gt.string()});var biu=gt.undiscriminatedUnion([gt.string(),viu]);var DNi=gt.list(biu);var Jm=gt.objectWithoutOptionalProperties({groupName:DNi.optional()});var L0=gt.objectWithoutOptionalProperties({namespace:gt.string().optional()});var $Jn=gt.objectWithoutOptionalProperties({default:SNi.optional(),values:gt.list(SNi)}).extend(Jm).extend(L0).extend(bg).extend(Of).extend(cy).extend(zh).extend(Qm).extend(UM);var giu=gt.objectWithoutOptionalProperties({scopesEnum:$Jn.optional()});var Oiu=gt.union("type",{basic:diu,bearer:piu,header:_iu,query:hiu,oauth:giu}).transform({transform:e=>{switch(e.type){case"basic":return AU.basic(e);case"bearer":return AU.bearer(e);case"header":return AU.header(e);case"query":return AU.query(e);case"oauth":return AU.oauth(e);default:return e}},untransform:({_visit:e,...t})=>t});var M5a=gt.objectWithoutOptionalProperties({name:gt.string().optional(),url:gt.string(),audiences:gt.list(gt.string()).optional()}).extend(Of);var miu=gt.string();var por=gt.objectWithoutOptionalProperties({sdkMethodName:gt.string().optional()});var E1c={};xa(E1c,{FullExample:()=>QT,FullObjectExample:()=>jiu,FullOneOfExample:()=>Siu,KeyValuePair:()=>wiu,LiteralExample:()=>Piu,PrimitiveExample:()=>QJn,PropertyKey:()=>GJn});var GJn=gt.string();var QJn=gt.union("type",{int:gt.object({value:gt.number()}),int64:gt.object({value:gt.number()}),uint:gt.object({value:gt.number()}),uint64:gt.object({value:gt.number()}),float:gt.object({value:gt.number()}),double:gt.object({value:gt.number()}),string:gt.object({value:gt.string()}),datetime:gt.object({value:gt.string()}),date:gt.object({value:gt.string()}),base64:gt.object({value:gt.string()}),boolean:gt.object({value:gt.boolean()})}).transform({transform:e=>{switch(e.type){case"int":return M_.int(e.value);case"int64":return M_.int64(e.value);case"uint":return M_.uint(e.value);case"uint64":return M_.uint64(e.value);case"float":return M_.float(e.value);case"double":return M_.double(e.value);case"string":return M_.string(e.value);case"datetime":return M_.datetime(e.value);case"date":return M_.date(e.value);case"base64":return M_.base64(e.value);case"boolean":return M_.boolean(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var Piu=gt.union("type",{boolean:gt.object({value:gt.boolean()}),string:gt.object({value:gt.string()})}).transform({transform:e=>{switch(e.type){case"boolean":return mNi.boolean(e.value);case"string":return mNi.string(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var QT=gt.union("type",{primitive:gt.object({value:QJn}),object:gt.lazyObject(()=>jiu),array:gt.object({value:gt.list(gt.lazy(()=>QT))}),map:gt.object({value:gt.list(gt.lazyObject(()=>wiu))}),enum:gt.object({value:gt.string()}),literal:gt.object({value:Piu}),oneOf:gt.object({value:gt.lazy(()=>Siu)}),unknown:gt.object({value:gt.lazy(()=>QT)})}).transform({transform:e=>{switch(e.type){case"primitive":return rO.primitive(e.value);case"object":return rO.object(e);case"array":return rO.array(e.value);case"map":return rO.map(e.value);case"enum":return rO.enum(e.value);case"literal":return rO.literal(e.value);case"oneOf":return rO.oneOf(e.value);case"unknown":return rO.unknown(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var jiu=gt.objectWithoutOptionalProperties({properties:gt.record(GJn,gt.lazy(()=>QT))});var wiu=gt.objectWithoutOptionalProperties({key:QJn,value:gt.lazy(()=>QT)});var Siu=gt.union("type",{discriminated:gt.object({value:gt.record(GJn,gt.lazy(()=>QT))}),undiscriminated:gt.object({value:gt.lazy(()=>QT)})}).transform({transform:e=>{switch(e.type){case"discriminated":return PNi.discriminated(e.value);case"undiscriminated":return PNi.undiscriminated(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var M1c={};xa(M1c,{AllOfPropertyConflict:()=>lKn,ArraySchema:()=>ynu,Availability:()=>ciu,BooleanSchema:()=>lnu,BytesResponse:()=>tKn,CasingOverrides:()=>yiu,CommonProperty:()=>wnu,CursorPagination:()=>Qiu,CustomCodeSample:()=>$iu,CustomCodeSampleLanguage:()=>Viu,CustomCodeSampleSdk:()=>Hiu,CustomPagination:()=>Kiu,DiscriminatedOneOfSchema:()=>Pnu,DoubleSchema:()=>snu,Endpoint:()=>Yiu,EndpointExample:()=>aKn,EndpointResponseExample:()=>Uiu,EndpointSdkName:()=>_or,EnumSchema:()=>$Jn,EnumValue:()=>SNi,ErrorExample:()=>xiu,FernExample:()=>Niu,FileResponse:()=>kJn,FileSchema:()=>Miu,FormUrlEncodedRequest:()=>Biu,FullEndpointExample:()=>Giu,GlobalHeader:()=>dnu,Header:()=>ENi,HeaderExample:()=>nKn,HttpEndpointServer:()=>rKn,HttpError:()=>Riu,HttpMethod:()=>JJn,IdempotencyHeader:()=>pnu,IntSchema:()=>onu,JsonRequest:()=>Ciu,JsonResponse:()=>eKn,LiteralSchema:()=>cKn,LiteralSchemaValue:()=>_nu,LongSchema:()=>unu,MapSchema:()=>vnu,MultipartRequest:()=>ZJn,MultipartRequestProperty:()=>Tiu,MultipartRequestPropertyEncoding:()=>qiu,MultipartSchema:()=>Aiu,NullableSchema:()=>gnu,ObjectProperty:()=>mnu,ObjectPropertyConflictInfo:()=>fKn,ObjectSchema:()=>hnu,OctetStreamRequest:()=>XJn,OffsetPagination:()=>Jiu,OneOfSchema:()=>Onu,OpenApiIntermediateRepresentation:()=>PP_,OptionalSchema:()=>bnu,Pagination:()=>oKn,PathParameter:()=>KJn,PathParameterExample:()=>Fiu,PrimitiveSchema:()=>ANi,PrimitiveSchemaValue:()=>fnu,QueryParameter:()=>YJn,QueryParameterExample:()=>iKn,ReferencedSchema:()=>hor,Request:()=>Iiu,Response:()=>ziu,Schema:()=>um,Schemas:()=>anu,SdkGroupInfo:()=>Diu,StreamingResponseExample:()=>Liu,StringSchema:()=>cnu,SupportedSdkLanguage:()=>Wiu,Tags:()=>Eiu,TextResponse:()=>MNi,UnDiscriminatedOneOfSchema:()=>jnu,Webhook:()=>Xiu,WebhookExampleCall:()=>sKn,WebhookHttpMethod:()=>uKn,WebsocketChannel:()=>nnu,WebsocketHandshake:()=>Ziu,WebsocketMessageExample:()=>rnu,WebsocketMessageOrigin:()=>kiu,WebsocketMessageSchema:()=>enu,WebsocketServer:()=>tnu,WebsocketSessionExample:()=>inu});var Diu=gt.objectWithoutOptionalProperties({summary:gt.string().optional(),description:gt.string().optional()});var Eiu=gt.objectWithoutOptionalProperties({tagsById:gt.record(Nee,liu),orderedTagIds:gt.list(Nee).optional()});var JJn=gt.enum_(["GET","POST","PUT","PATCH","DELETE","HEAD","OPTIONS","TRACE"]);var KJn=gt.objectWithoutOptionalProperties({name:gt.string(),schema:gt.lazy(()=>um),variableReference:gt.string().optional(),parameterNameOverride:gt.string().optional()}).extend(Of).extend(cy).extend(zh);var YJn=gt.objectWithoutOptionalProperties({name:gt.string(),schema:gt.lazy(()=>um),parameterNameOverride:gt.string().optional()}).extend(Of).extend(cy).extend(zh);var ENi=gt.objectWithoutOptionalProperties({name:gt.string(),schema:gt.lazy(()=>um),env:gt.string().optional(),parameterNameOverride:gt.string().optional()}).extend(Of).extend(cy).extend(zh);var _or=gt.objectWithoutOptionalProperties({groupName:DNi,methodName:gt.string()});var XJn=gt.objectWithoutOptionalProperties({contentType:gt.string().optional()}).extend(Of).extend(zh);var Miu=gt.objectWithoutOptionalProperties({isOptional:gt.boolean(),isArray:gt.boolean()}).extend(Of);var Aiu=gt.union("type",{file:Miu,json:gt.object({value:gt.lazy(()=>um)})}).transform({transform:e=>{switch(e.type){case"file":return Wmi.file(e);case"json":return Wmi.json(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var qiu=gt.enum_(["json","form"]);var Tiu=gt.objectWithoutOptionalProperties({key:gt.string(),schema:Aiu,contentType:gt.string().optional(),exploded:gt.boolean().optional(),encoding:qiu.optional()}).extend(Of);var ZJn=gt.objectWithoutOptionalProperties({name:gt.string().optional(),properties:gt.list(Tiu)}).extend(Of).extend(zh);var Ciu=gt.objectWithoutOptionalProperties({schema:gt.lazy(()=>um),contentType:gt.string().optional(),additionalProperties:gt.boolean()}).extend(Of).extend(zh);var Biu=gt.objectWithoutOptionalProperties({schema:gt.lazy(()=>um),contentType:gt.string().optional(),additionalProperties:gt.boolean()}).extend(Of).extend(zh);var Iiu=gt.union("type",{octetStream:XJn,multipart:ZJn,json:Ciu,formUrlEncoded:Biu}).transform({transform:e=>{switch(e.type){case"octetStream":return lor.octetStream(e);case"multipart":return lor.multipart(e);case"json":return lor.json(e);case"formUrlEncoded":return lor.formUrlEncoded(e);default:return e}},untransform:({_visit:e,...t})=>t});var kJn=gt.objectWithoutOptionalProperties({}).extend(Of).extend(zh).extend(EFe);var eKn=gt.objectWithoutOptionalProperties({schema:gt.lazy(()=>um),responseProperty:gt.string().optional()}).extend(Of).extend(zh).extend(EFe);var MNi=gt.objectWithoutOptionalProperties({}).extend(Of).extend(zh).extend(EFe);var tKn=gt.objectWithoutOptionalProperties({}).extend(Of).extend(zh).extend(EFe);var ziu=gt.union("type",{file:kJn,json:eKn,text:MNi,bytes:tKn,streamingSse:eKn,streamingText:MNi,streamingJson:eKn}).transform({transform:e=>{switch(e.type){case"file":return NK.file(e);case"json":return NK.json(e);case"text":return NK.text(e);case"bytes":return NK.bytes(e);case"streamingSse":return NK.streamingSse(e);case"streamingText":return NK.streamingText(e);case"streamingJson":return NK.streamingJson(e);default:return e}},untransform:({_visit:e,...t})=>t});var xiu=gt.objectWithoutOptionalProperties({name:gt.string().optional(),description:gt.string().optional(),example:gt.lazy(()=>QT)});var Riu=gt.objectWithoutOptionalProperties({schema:gt.lazy(()=>um).optional(),examples:gt.list(xiu).optional()}).extend(Of).extend(bg).extend(zh);var rKn=gt.objectWithoutOptionalProperties({name:gt.string().optional(),url:gt.string().optional(),audiences:gt.list(gt.string()).optional()});var Niu=gt.unknown();var Fiu=gt.objectWithoutOptionalProperties({name:gt.string(),parameterNameOverride:gt.string().optional(),value:gt.lazy(()=>QT)});var iKn=gt.objectWithoutOptionalProperties({name:gt.string(),value:gt.lazy(()=>QT)});var nKn=gt.objectWithoutOptionalProperties({name:gt.string(),value:gt.lazy(()=>QT)});var Liu=gt.objectWithoutOptionalProperties({sse:gt.boolean(),events:gt.list(gt.lazy(()=>QT))});var Uiu=gt.union("type",{withStreaming:Liu,withoutStreaming:gt.object({value:gt.lazy(()=>QT)})}).transform({transform:e=>{switch(e.type){case"withStreaming":return VQt.withStreaming(e);case"withoutStreaming":return VQt.withoutStreaming(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var Viu=gt.objectWithoutOptionalProperties({name:gt.string().optional(),language:gt.string(),code:gt.string(),install:gt.string().optional()}).extend(Of);var Wiu=gt.enum_(["curl","python","javascript","typescript","go","ruby","csharp","java","js","node","ts","nodets","golang","dotnet","jvm"]);var Hiu=gt.objectWithoutOptionalProperties({name:gt.string().optional(),sdk:Wiu,code:gt.string()}).extend(Of);var $iu=gt.union("type",{language:Viu,sdk:Hiu}).transform({transform:e=>{switch(e.type){case"language":return Vmi.language(e);case"sdk":return Vmi.sdk(e);default:return e}},untransform:({_visit:e,...t})=>t});var Giu=gt.objectWithoutOptionalProperties({name:gt.string().optional(),pathParameters:gt.list(Fiu).optional(),queryParameters:gt.list(iKn).optional(),headers:gt.list(nKn).optional(),request:gt.lazy(()=>QT).optional(),response:Uiu.optional(),codeSamples:gt.list($iu)}).extend(Of);var aKn=gt.union("type",{unknown:gt.object({value:Niu}),full:Giu}).transform({transform:e=>{switch(e.type){case"unknown":return UQt.unknown(e.value);case"full":return UQt.full(e);default:return e}},untransform:({_visit:e,...t})=>t});var Qiu=gt.objectWithoutOptionalProperties({cursor:gt.string(),nextCursor:gt.property("next_cursor",gt.string()),results:gt.string()});var Jiu=gt.objectWithoutOptionalProperties({offset:gt.string(),results:gt.string(),step:gt.string().optional(),hasNextPage:gt.string().optional()});var Kiu=gt.objectWithoutOptionalProperties({results:gt.string()});var oKn=gt.union("type",{cursor:Qiu,offset:Jiu,custom:Kiu}).transform({transform:e=>{switch(e.type){case"cursor":return DFe.cursor(e);case"offset":return DFe.offset(e);case"custom":return DFe.custom(e);default:return e}},untransform:({_visit:e,...t})=>t});var Yiu=gt.objectWithoutOptionalProperties({authed:gt.boolean(),internal:gt.boolean().optional(),idempotent:gt.boolean().optional(),method:JJn,audiences:gt.list(gt.string()),path:gt.string(),summary:gt.string().optional(),operationId:gt.string().optional(),tags:gt.list(Nee),pathParameters:gt.list(KJn),queryParameters:gt.list(YJn),headers:gt.list(ENi),sdkName:_or.optional(),generatedRequestName:gt.string(),requestNameOverride:gt.string().optional(),request:Iiu.optional(),response:ziu.optional(),errors:gt.record(dor,Riu),servers:gt.list(rKn),examples:gt.list(aKn),pagination:oKn.optional()}).extend(Of).extend(cy).extend(zh).extend(L0);var uKn=gt.enum_(["GET","POST"]);var sKn=gt.objectWithoutOptionalProperties({name:gt.string().optional(),payload:gt.lazy(()=>QT)}).extend(Of);var Xiu=gt.objectWithoutOptionalProperties({audiences:gt.list(gt.string()),sdkName:_or.optional(),method:uKn,summary:gt.string().optional(),operationId:gt.string(),tags:gt.list(Nee),headers:gt.list(ENi),generatedPayloadName:gt.string(),payload:gt.lazy(()=>um),examples:gt.list(sKn)}).extend(Of).extend(zh).extend(L0);var Ziu=gt.objectWithoutOptionalProperties({queryParameters:gt.list(YJn),headers:gt.list(ENi),pathParameters:gt.list(KJn)});var kiu=gt.enum_(["client","server"]);var enu=gt.objectWithoutOptionalProperties({name:gt.string(),origin:kiu,body:gt.lazy(()=>um)});var tnu=gt.objectWithoutOptionalProperties({name:gt.string(),url:gt.string()});var rnu=gt.objectWithoutOptionalProperties({messageType:gt.string(),payload:gt.lazy(()=>QT)}).extend(Of);var inu=gt.objectWithoutOptionalProperties({name:gt.string().optional(),queryParameters:gt.list(iKn).optional(),headers:gt.list(nKn).optional(),messages:gt.list(rnu)}).extend(Of);var nnu=gt.objectWithoutOptionalProperties({audiences:gt.list(gt.string()),path:gt.string(),groupName:DNi,summary:gt.string().optional(),handshake:Ziu,messages:gt.list(enu),servers:gt.list(tnu),examples:gt.list(inu)}).extend(Of).extend(zh);var anu=gt.objectWithoutOptionalProperties({rootSchemas:gt.record(Ree,gt.lazy(()=>um)),namespacedSchemas:gt.record(miu,gt.record(Ree,gt.lazy(()=>um)))});var onu=gt.objectWithoutOptionalProperties({default:gt.number().optional(),minimum:gt.number().optional(),maximum:gt.number().optional(),exclusiveMinimum:gt.boolean().optional(),exclusiveMaximum:gt.boolean().optional(),multipleOf:gt.number().optional()});var unu=gt.objectWithoutOptionalProperties({default:gt.number().optional()});var snu=gt.objectWithoutOptionalProperties({default:gt.number().optional(),minimum:gt.number().optional(),maximum:gt.number().optional(),exclusiveMinimum:gt.boolean().optional(),exclusiveMaximum:gt.boolean().optional(),multipleOf:gt.number().optional()});var cnu=gt.objectWithoutOptionalProperties({default:gt.string().optional(),pattern:gt.string().optional(),format:gt.string().optional(),minLength:gt.number().optional(),maxLength:gt.number().optional()});var lnu=gt.objectWithoutOptionalProperties({default:gt.boolean().optional()});var fnu=gt.union("type",{int:onu,int64:unu,uint:gt.object({}),uint64:gt.object({}),float:gt.object({}),double:snu,string:cnu,datetime:gt.object({}),date:gt.object({}),base64:gt.object({}),boolean:lnu}).transform({transform:e=>{switch(e.type){case"int":return Ww.int(e);case"int64":return Ww.int64(e);case"uint":return Ww.uint();case"uint64":return Ww.uint64();case"float":return Ww.float();case"double":return Ww.double(e);case"string":return Ww.string(e);case"datetime":return Ww.datetime();case"date":return Ww.date();case"base64":return Ww.base64();case"boolean":return Ww.boolean(e);default:return e}},untransform:({_visit:e,...t})=>t});var ANi=gt.objectWithoutOptionalProperties({schema:fnu}).extend(Jm).extend(L0).extend(bg).extend(Of).extend(cy).extend(Qm);var dnu=gt.objectWithoutOptionalProperties({header:gt.string(),name:gt.string().optional(),optional:gt.boolean().optional(),env:gt.string().optional(),schema:gt.lazy(()=>um).optional()});var pnu=gt.objectWithoutOptionalProperties({header:gt.string(),name:gt.string().optional(),env:gt.string().optional(),schema:gt.lazy(()=>um).optional()});var PP_=gt.objectWithoutOptionalProperties({apiVersion:gt.unknown().optional(),title:gt.string().optional(),description:gt.string().optional(),basePath:gt.string().optional(),servers:gt.list(M5a),websocketServers:gt.list(M5a),groups:gt.record(gt.string(),Diu),tags:Eiu,hasEndpointsMarkedInternal:gt.boolean(),endpoints:gt.list(Yiu),webhooks:gt.list(Xiu),channels:gt.record(gt.string(),nnu),groupedSchemas:anu,variables:gt.record(gt.string(),ANi),nonRequestReferencedSchemas:gt.set(Ree),securitySchemes:gt.record(fiu,Oiu),globalHeaders:gt.list(dnu).optional(),idempotencyHeaders:gt.list(pnu).optional()});var hor=gt.objectWithoutOptionalProperties({schema:Ree}).extend(Jm).extend(L0).extend(bg).extend(Of).extend(cy).extend(zh).extend(Qm);var _nu=gt.union("type",{boolean:gt.object({value:gt.boolean()}),string:gt.object({value:gt.string()})}).transform({transform:e=>{switch(e.type){case"boolean":return mx.boolean(e.value);case"string":return mx.string(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var cKn=gt.objectWithoutOptionalProperties({value:_nu}).extend(Jm).extend(L0).extend(bg).extend(Of).extend(cy).extend(Qm);var um=gt.union("type",{primitive:ANi,object:gt.lazyObject(()=>hnu),array:gt.lazyObject(()=>ynu),map:gt.lazyObject(()=>vnu),optional:gt.lazyObject(()=>bnu),enum:$Jn,reference:hor,literal:cKn,oneOf:gt.object({value:gt.lazy(()=>Onu)}),nullable:gt.lazyObject(()=>gnu),unknown:bg}).transform({transform:e=>{switch(e.type){case"primitive":return wv.primitive(e);case"object":return wv.object(e);case"array":return wv.array(e);case"map":return wv.map(e);case"optional":return wv.optional(e);case"enum":return wv.enum(e);case"reference":return wv.reference(e);case"literal":return wv.literal(e);case"oneOf":return wv.oneOf(e.value);case"nullable":return wv.nullable(e);case"unknown":return wv.unknown(e);default:return e}},untransform:({_visit:e,...t})=>t});var lKn=gt.objectWithoutOptionalProperties({propertyKey:gt.string(),allOfSchemaIds:gt.list(Ree),conflictingTypeSignatures:gt.boolean()});var hnu=gt.objectWithoutOptionalProperties({allOf:gt.list(hor),properties:gt.list(gt.lazyObject(()=>mnu)),allOfPropertyConflicts:gt.list(lKn),additionalProperties:gt.boolean()}).extend(Jm).extend(L0).extend(bg).extend(Of).extend(cy).extend(zh).extend(Qm).extend(UM);var fKn=gt.objectWithoutOptionalProperties({differentSchema:gt.boolean()});var mnu=gt.objectWithoutOptionalProperties({key:gt.string(),schema:gt.lazy(()=>um),readonly:gt.boolean().optional(),writeonly:gt.boolean().optional(),conflict:gt.record(Ree,fKn),generatedName:gt.string(),nameOverride:gt.string().optional(),audiences:gt.list(gt.string())}).extend(cy);var ynu=gt.objectWithoutOptionalProperties({value:gt.lazy(()=>um)}).extend(Jm).extend(L0).extend(bg).extend(Of).extend(cy).extend(Qm).extend(UM);var vnu=gt.objectWithoutOptionalProperties({key:ANi,value:gt.lazy(()=>um)}).extend(Jm).extend(L0).extend(bg).extend(Of).extend(cy).extend(Nue).extend(Qm).extend(UM);var bnu=gt.objectWithoutOptionalProperties({value:gt.lazy(()=>um)}).extend(Jm).extend(L0).extend(bg).extend(Of).extend(cy).extend(Qm).extend(UM);var gnu=gt.objectWithoutOptionalProperties({value:gt.lazy(()=>um)}).extend(Jm).extend(L0).extend(bg).extend(Of).extend(cy).extend(Qm).extend(UM);var Onu=gt.union("type",{discriminated:gt.lazyObject(()=>Pnu),undiscriminated:gt.lazyObject(()=>jnu)}).transform({transform:e=>{switch(e.type){case"discriminated":return Hmi.discriminated(e);case"undiscriminated":return Hmi.undiscriminated(e);default:return e}},untransform:({_visit:e,...t})=>t});var Pnu=gt.objectWithoutOptionalProperties({discriminantProperty:gt.string(),commonProperties:gt.list(gt.lazyObject(()=>wnu)),schemas:gt.record(gt.string(),gt.lazy(()=>um))}).extend(Jm).extend(L0).extend(bg).extend(Of).extend(cy).extend(Nue).extend(zh).extend(Qm).extend(UM);var wnu=gt.objectWithoutOptionalProperties({key:gt.string(),schema:gt.lazy(()=>um)});var jnu=gt.objectWithoutOptionalProperties({schemas:gt.list(gt.lazy(()=>um))}).extend(Jm).extend(L0).extend(bg).extend(Of).extend(cy).extend(Nue).extend(zh).extend(Qm).extend(UM);var A1c={};xa(A1c,{ArraySchemaWithExample:()=>Qnu,Base64WithExample:()=>Vnu,BooleanWithExample:()=>Wnu,CommonPropertyWithExample:()=>rau,DateWithExample:()=>Unu,DatetimeWithExample:()=>Lnu,DiscriminatedOneOfSchemaWithExample:()=>eau,DoubleWithExample:()=>Nnu,EndpointWithExample:()=>wP_,EnumSchemaWithExample:()=>$nu,FloatWithExample:()=>Rnu,HeaderWithExample:()=>qNi,HttpErrorWithExample:()=>Cnu,Int64WithExample:()=>Inu,IntWithExample:()=>Bnu,JsonRequestWithExample:()=>Mnu,JsonResponseWithExample:()=>pKn,MapSchemaWithExample:()=>Jnu,NamedFullExample:()=>MFe,NullableSchemaWithExample:()=>Ynu,ObjectPropertyWithExample:()=>knu,ObjectSchemaWithExample:()=>Xnu,OneOfSchemaWithExample:()=>Znu,OptionalSchemaWithExample:()=>Knu,ParseFormUrlEncodedRequest:()=>Anu,ParseMultipartRequest:()=>Enu,ParseOctetStreamRequest:()=>Dnu,PathParameterWithExample:()=>Snu,PrimitiveSchemaValueWithExample:()=>Hnu,PrimitiveSchemaWithExample:()=>_Kn,QueryParameterWithExample:()=>dKn,RequestWithExample:()=>qnu,ResponseWithExample:()=>Tnu,SchemaWithExample:()=>VM,StringSchemaWithExample:()=>Fnu,Uint64WithExample:()=>xnu,UintWithExample:()=>znu,UnDiscriminatedOneOfSchemaWithExample:()=>tau,UnknownSchemaWithExample:()=>Gnu,WebhookWithExample:()=>SP_,WebsocketHandshakeWithExample:()=>jP_});var MFe=gt.objectWithoutOptionalProperties({name:gt.string().optional(),value:gt.unknown()}).extend(Of);var dKn=gt.objectWithoutOptionalProperties({name:gt.string(),schema:gt.lazy(()=>VM),parameterNameOverride:gt.string().optional()}).extend(Of).extend(cy).extend(zh);var qNi=gt.objectWithoutOptionalProperties({name:gt.string(),schema:gt.lazy(()=>VM),env:gt.string().optional(),parameterNameOverride:gt.string().optional()}).extend(Of).extend(cy).extend(zh);var jP_=gt.objectWithoutOptionalProperties({queryParameters:gt.list(dKn),headers:gt.list(qNi)});var Snu=gt.objectWithoutOptionalProperties({name:gt.string(),schema:gt.lazy(()=>VM),variableReference:gt.string().optional(),parameterNameOverride:gt.string().optional()}).extend(Of).extend(cy).extend(zh);var Dnu=gt.objectWithoutOptionalProperties({}).extend(XJn).extend(por);var Enu=gt.objectWithoutOptionalProperties({}).extend(ZJn).extend(por);var Mnu=gt.objectWithoutOptionalProperties({schema:gt.lazy(()=>VM),contentType:gt.string().optional(),fullExamples:gt.list(MFe).optional(),additionalProperties:gt.boolean()}).extend(Of).extend(zh).extend(por);var Anu=gt.objectWithoutOptionalProperties({schema:gt.lazy(()=>VM),contentType:gt.string().optional(),fullExamples:gt.list(MFe).optional(),additionalProperties:gt.boolean()}).extend(Of).extend(zh).extend(por);var qnu=gt.union("type",{octetStream:Dnu,multipart:Enu,json:Mnu,formUrlEncoded:Anu}).transform({transform:e=>{switch(e.type){case"octetStream":return zee.octetStream(e);case"multipart":return zee.multipart(e);case"json":return zee.json(e);case"formUrlEncoded":return zee.formUrlEncoded(e);default:return e}},untransform:({_visit:e,...t})=>t});var pKn=gt.objectWithoutOptionalProperties({schema:gt.lazy(()=>VM),responseProperty:gt.string().optional(),fullExamples:gt.list(MFe).optional()}).extend(Of).extend(zh).extend(EFe);var Tnu=gt.union("type",{file:kJn,json:pKn,text:MNi,bytes:tKn,streamingSse:pKn,streamingText:MNi,streamingJson:pKn}).transform({transform:e=>{switch(e.type){case"file":return EB.file(e);case"json":return EB.json(e);case"text":return EB.text(e);case"bytes":return EB.bytes(e);case"streamingSse":return EB.streamingSse(e);case"streamingText":return EB.streamingText(e);case"streamingJson":return EB.streamingJson(e);default:return e}},untransform:({_visit:e,...t})=>t});var Cnu=gt.objectWithoutOptionalProperties({statusCode:dor,schema:gt.lazy(()=>VM),fullExamples:gt.list(MFe).optional()}).extend(Of).extend(bg).extend(zh);var wP_=gt.objectWithoutOptionalProperties({authed:gt.boolean(),internal:gt.boolean().optional(),idempotent:gt.boolean().optional(),method:JJn,audiences:gt.list(gt.string()),path:gt.string(),summary:gt.string().optional(),operationId:gt.string().optional(),tags:gt.list(Nee),pathParameters:gt.list(Snu),queryParameters:gt.list(dKn),headers:gt.list(qNi),sdkName:_or.optional(),generatedRequestName:gt.string(),requestNameOverride:gt.string().optional(),request:qnu.optional(),response:Tnu.optional(),errors:gt.record(dor,Cnu),servers:gt.list(rKn),examples:gt.list(aKn),pagination:oKn.optional()}).extend(Of).extend(cy).extend(zh).extend(L0);var SP_=gt.objectWithoutOptionalProperties({audiences:gt.list(gt.string()),sdkName:_or.optional(),method:uKn,summary:gt.string().optional(),operationId:gt.string(),tags:gt.list(Nee),headers:gt.list(qNi),generatedPayloadName:gt.string(),payload:gt.lazy(()=>VM),examples:gt.list(sKn)}).extend(Of).extend(zh).extend(L0);var Bnu=gt.objectWithoutOptionalProperties({default:gt.number().optional(),minimum:gt.number().optional(),maximum:gt.number().optional(),exclusiveMinimum:gt.boolean().optional(),exclusiveMaximum:gt.boolean().optional(),multipleOf:gt.number().optional(),example:gt.number().optional()});var Inu=gt.objectWithoutOptionalProperties({default:gt.number().optional(),example:gt.number().optional()});var znu=gt.objectWithoutOptionalProperties({default:gt.number().optional(),example:gt.number().optional()});var xnu=gt.objectWithoutOptionalProperties({default:gt.number().optional(),example:gt.number().optional()});var Rnu=gt.objectWithoutOptionalProperties({example:gt.number().optional()});var Nnu=gt.objectWithoutOptionalProperties({default:gt.number().optional(),minimum:gt.number().optional(),maximum:gt.number().optional(),exclusiveMinimum:gt.boolean().optional(),exclusiveMaximum:gt.boolean().optional(),multipleOf:gt.number().optional(),example:gt.number().optional()});var Fnu=gt.objectWithoutOptionalProperties({default:gt.string().optional(),pattern:gt.string().optional(),format:gt.string().optional(),minLength:gt.number().optional(),maxLength:gt.number().optional(),example:gt.string().optional()});var Lnu=gt.objectWithoutOptionalProperties({example:gt.string().optional()});var Unu=gt.objectWithoutOptionalProperties({example:gt.string().optional()});var Vnu=gt.objectWithoutOptionalProperties({example:gt.string().optional()});var Wnu=gt.objectWithoutOptionalProperties({default:gt.boolean().optional(),example:gt.boolean().optional()});var Hnu=gt.union("type",{int:Bnu,int64:Inu,uint:znu,uint64:xnu,float:Rnu,double:Nnu,string:Fnu,datetime:Lnu,date:Unu,base64:Vnu,boolean:Wnu}).transform({transform:e=>{switch(e.type){case"int":return bp.int(e);case"int64":return bp.int64(e);case"uint":return bp.uint(e);case"uint64":return bp.uint64(e);case"float":return bp.float(e);case"double":return bp.double(e);case"string":return bp.string(e);case"datetime":return bp.datetime(e);case"date":return bp.date(e);case"base64":return bp.base64(e);case"boolean":return bp.boolean(e);default:return e}},untransform:({_visit:e,...t})=>t});var _Kn=gt.objectWithoutOptionalProperties({schema:Hnu}).extend(Jm).extend(L0).extend(bg).extend(Of).extend(cy).extend(Qm);var $nu=gt.objectWithoutOptionalProperties({default:SNi.optional(),values:gt.list(SNi),example:gt.string().optional()}).extend(Jm).extend(L0).extend(bg).extend(Of).extend(cy).extend(zh).extend(Qm).extend(UM);var Gnu=gt.objectWithoutOptionalProperties({example:gt.unknown()}).extend(Jm).extend(L0).extend(bg).extend(Of).extend(cy).extend(Qm);var VM=gt.union("type",{primitive:_Kn,object:gt.lazyObject(()=>Xnu),array:gt.lazyObject(()=>Qnu),map:gt.lazyObject(()=>Jnu),optional:gt.lazyObject(()=>Knu),enum:$nu,reference:hor,literal:cKn,oneOf:gt.object({value:gt.lazy(()=>Znu)}),nullable:gt.lazyObject(()=>Ynu),unknown:Gnu}).transform({transform:e=>{switch(e.type){case"primitive":return Nl.primitive(e);case"object":return Nl.object(e);case"array":return Nl.array(e);case"map":return Nl.map(e);case"optional":return Nl.optional(e);case"enum":return Nl.enum(e);case"reference":return Nl.reference(e);case"literal":return Nl.literal(e);case"oneOf":return Nl.oneOf(e.value);case"nullable":return Nl.nullable(e);case"unknown":return Nl.unknown(e);default:return e}},untransform:({_visit:e,...t})=>t});var Qnu=gt.objectWithoutOptionalProperties({value:gt.lazy(()=>VM),example:gt.list(gt.unknown()).optional()}).extend(Jm).extend(L0).extend(bg).extend(Of).extend(cy).extend(Qm).extend(UM);var Jnu=gt.objectWithoutOptionalProperties({key:_Kn,value:gt.lazy(()=>VM),example:gt.unknown().optional()}).extend(Jm).extend(L0).extend(bg).extend(Of).extend(cy).extend(Nue).extend(Qm).extend(UM);var Knu=gt.objectWithoutOptionalProperties({value:gt.lazy(()=>VM)}).extend(Jm).extend(L0).extend(bg).extend(Of).extend(cy).extend(Qm).extend(UM);var Ynu=gt.objectWithoutOptionalProperties({value:gt.lazy(()=>VM)}).extend(Jm).extend(L0).extend(bg).extend(Of).extend(cy).extend(Qm).extend(UM);var Xnu=gt.objectWithoutOptionalProperties({allOf:gt.list(hor),properties:gt.list(gt.lazyObject(()=>knu)),allOfPropertyConflicts:gt.list(lKn),fullExamples:gt.list(MFe).optional(),additionalProperties:gt.boolean()}).extend(Jm).extend(L0).extend(bg).extend(Of).extend(cy).extend(zh).extend(Qm).extend(UM);var knu=gt.objectWithoutOptionalProperties({key:gt.string(),schema:gt.lazy(()=>VM),readonly:gt.boolean().optional(),writeonly:gt.boolean().optional(),audiences:gt.list(gt.string()),conflict:gt.record(Ree,fKn),nameOverride:gt.string().optional(),generatedName:gt.string()}).extend(cy);var Znu=gt.union("type",{discriminated:gt.lazyObject(()=>eau),undiscriminated:gt.lazyObject(()=>tau)}).transform({transform:e=>{switch(e.type){case"discriminated":return xee.discriminated(e);case"undiscriminated":return xee.undiscriminated(e);default:return e}},untransform:({_visit:e,...t})=>t});var eau=gt.objectWithoutOptionalProperties({discriminantProperty:gt.string(),commonProperties:gt.list(gt.lazyObject(()=>rau)),schemas:gt.record(gt.string(),gt.lazy(()=>VM))}).extend(Jm).extend(L0).extend(bg).extend(Of).extend(cy).extend(Nue).extend(zh).extend(Qm).extend(UM);var rau=gt.objectWithoutOptionalProperties({key:gt.string(),schema:gt.lazy(()=>VM)});var tau=gt.objectWithoutOptionalProperties({schemas:gt.list(gt.lazy(()=>VM))}).extend(Jm).extend(L0).extend(bg).extend(Of).extend(cy).extend(Nue).extend(zh).extend(Qm).extend(UM);var DP_=/^(\d+)/,hKn=/^[a-zA-Z][a-zA-Z0-9_]*$/,EP_={"<":"LESS_THAN",">":"GREATER_THAN",">=":"GREATER_THAN_OR_EQUAL_TO","<=":"LESS_THAN_OR_EQUAL_TO","!=":"NOT_EQUALS","=":"EQUAL_TO","==":"EQUAL_TO","*":"ALL","":"EMPTY",'""':"EMPTY_STRING","-":"HYPHEN","|":"PIPE",".":"DOT","/":"SLASH"};function TNi(e){let t=["zero","one","two","three","four","five","six","seven","eight","nine"],r=["ten","eleven","twelve","thirteen","fourteen","fifteen","sixteen","seventeen","eighteen","nineteen"],i=["","","twenty","thirty","forty","fifty","sixty","seventy","eighty","ninety"];if(e<0||e>9999)return;if(e<10)return t[e];if(e<20)return r[e-10];if(e<100){let u=Math.floor(e/10),c=e%10;return c===0?i[u]:`${i[u]}_${t[c]}`}if(e<1e3){let u=Math.floor(e/100),c=e%100;return c===0?`${t[u]}_hundred`:`${t[u]}_hundred_${TNi(c)}`}let n=Math.floor(e/1e3),a=e%1e3;return a===0?`${t[n]}_thousand`:`${t[n]}_thousand_${TNi(a)}`}function A5a(e){let t=e.match(DP_);if(t&&t[0]!=null){let r=t[0],i=e.substring(r.length),n=parseFloat(r);if(!isNaN(n)&&isFinite(n)){let a=TNi(n);return i.length>0?`${a}_${i}`:a}}}function yKn(e){let t=A5a(e),r=EP_[e];return t!=null?eI(F_(t)):r??(e.toLowerCase()==="n/a"?"NOT_APPLICABLE":eI(F_(e)))}function Fue(e,t){return e.type==="primitive"&&t.type==="primitive"?MP_(e.schema,t.schema):e.type==="enum"&&t.type==="enum"?hTE(e.values,t.values):e.type==="array"&&t.type==="array"?Fue(e.value,t.value):e.type==="unknown"&&t.type==="unknown"?!0:e.type==="reference"&&t.type==="reference"?e.schema===t.schema:e.type==="optional"&&t.type==="optional"?Fue(e.value,t.value):e.type==="oneOf"&&t.type==="oneOf"?yTE(e.value,t.value):e.type==="object"&&t.type==="object"?vTE(e,t):e.type==="map"&&t.type==="map"?MP_(e.key.schema,t.key.schema)&&Fue(e.value,t.value):e.type==="literal"&&t.type==="literal"?e.value===t.value:!1}function MP_(e,t){return e.type===t.type}function hTE(e,t){let r=new Set(...e.map(n=>n.value)),i=new Set(...t.map(n=>n.value));return Y8(r,i)}function yTE(e,t){return e.type==="discriminated"&&t.type==="discriminated"?e.discriminantProperty===t.discriminantProperty&&Object.keys(e.schemas).length===Object.keys(t.schemas).length&&Object.entries(e.schemas).every(([r,i])=>{let n=t.schemas[r];return n==null?!1:Fue(i,n)}):e.type==="undiscriminated"&&t.type==="undiscriminated"?e.schemas.length===t.schemas.length&&e.schemas.every((r,i)=>{let n=t.schemas[i];return n==null?!1:Fue(r,n)}):!1}function vTE(e,t){if(Object.keys(e.properties).length!==Object.keys(t.properties).length)return!1;let r=Object.fromEntries(e.properties.map(i=>[i.key,i.schema]));return Object.entries(t.properties).every(([i,n])=>{let a=r[i];return a==null?!1:Fue(a,n.schema)})}function ER(e){switch(e){case S$.Deprecated:return"deprecated";case S$.Beta:return"pre-release";case S$.GenerallyAvailable:return"generally-available";default:return}}function bTE(e){let t=e.find(i=>typeof i=="object"&&i.type==="namespace"),r=e.filter(i=>typeof i=="string"||i.type!=="namespace");return t?[t,...r]:r}function AP_(e){let t=e?bTE(e):void 0;if(t==null||t.length===0)return NZi;let r=[];for(let[i,n]of t.entries())if(typeof n=="string")r.push(F_(n));else if(typeof n=="object")switch(n.type){case"namespace":{i<t.length-1?r.push(F_(n.name)):r.push(n.name,NZi);break}default:Ao(n.type)}else Ao(n);return r.join("/")}function CNi(e){return Ey.of(`${AP_(e)}.yml`)}function q1c({sdkName:e,namespaceOverride:t}){let r;return e==null||e.groupName.length===0&&t==null?NZi:(t!=null?r=[{type:"namespace",name:t},...e.groupName.filter(i=>typeof i=="string"||i.type!=="namespace")]:r=e.groupName,AP_(r))}function qP_({sdkName:e,namespaceOverride:t}){return Ey.of(`${q1c({sdkName:e,namespaceOverride:t})}.yml`)}function TP_({location:e,namespaceOverride:t}){return t!=null?X3(Ey.of(t),e):e}function iau(e){switch(e.type){case"protobuf":return{proto:{type:e.typeName}};default:Ao(e.type)}}function vKn(e){switch(e.type){case"object":case"enum":case"array":case"map":case"reference":case"literal":case"optional":case"nullable":case"primitive":return e.groupName??void 0;case"oneOf":return e.value.groupName??void 0;case"unknown":return;default:Ao(e)}}function hq(e){return typeof e=="string"?e:e.type}function bKn(e){if(typeof e!="string")return e.docs}function q5a(e){if(typeof e!="string")return e.default}function T1c(e){if(typeof e!="string")return e.validation}var gTE=-2147483648,OTE=2147483647,mTE=-17976931348623157e292,PTE=17976931348623157e292;function iO({schema:e,fileContainingReference:t,declarationFile:r=t,context:i,namespace:n,declarationDepth:a}){switch(i.shouldMarkSchemaAsReferenced()&&i.markSchemaAsReferenced(e,n),e.type){case"primitive":return nau(e);case"array":return I1c({schema:e,fileContainingReference:t,context:i,declarationFile:r,namespace:n,declarationDepth:a});case"map":return z1c({schema:e,fileContainingReference:t,context:i,declarationFile:r,namespace:n,declarationDepth:a});case"reference":return B1c({schema:e,fileContainingReference:t,context:i,namespace:n});case"unknown":return R1c();case"optional":return aau({schema:e,fileContainingReference:t,context:i,declarationFile:r,namespace:n,declarationDepth:a});case"nullable":return x1c({schema:e,fileContainingReference:t,context:i,declarationFile:r,namespace:n,declarationDepth:a});case"enum":return TTE({schema:e,fileContainingReference:t,context:i,declarationFile:r,declarationDepth:a});case"literal":return e.value,N1c(e);case"object":return CTE({schema:e,fileContainingReference:t,context:i,declarationFile:r,namespace:n,declarationDepth:a});case"oneOf":return BTE({schema:e.value,fileContainingReference:t,context:i,declarationFile:r,namespace:n,declarationDepth:a});default:Ao(e)}}function nau(e){switch(e.schema.type){case"string":return STE({description:e.description,schema:e.schema});case"int":return DTE({description:e.description,schema:e.schema});case"float":return ETE({description:e.description,schema:e.schema});case"double":return MTE({description:e.description,schema:e.schema});case"boolean":return jTE({description:e.description,schema:e.schema});case"int64":return wTE({description:e.description,schema:e.schema})}let t=e.schema._visit({int:()=>"integer",int64:()=>"long",uint:()=>"uint",uint64:()=>"uint64",float:()=>"double",double:()=>"double",string:()=>"string",datetime:()=>"datetime",date:()=>"date",base64:()=>"base64",boolean:()=>"boolean",_other:()=>"unknown"});return e.description==null&&e.title==null?t:{type:t,...e.description!=null?{docs:e.description}:{},...e.availability!=null?{availability:ER(e.availability)}:{}}}function jTE({description:e,schema:t}){let r="boolean";if(e==null&&t.default==null)return r;let i={type:r};return e!=null&&(i.docs=e),t.default!=null&&(i.default=t.default),i}function wTE({description:e,schema:t}){let r="long";if(e==null&&t.default==null)return r;let i={type:r};return e!=null&&(i.docs=e),t.default!=null&&(i.default=t.default),i}function STE({description:e,schema:t}){let r="string",i=ATE(t);if(e==null&&t.default==null&&i==null)return r;let n={type:r};return e!=null&&(n.docs=e),t.default!=null&&(n.default=t.default),i!=null&&(n.validation=i),n}function DTE({description:e,schema:t}){let r="integer",i=BP_(t,r);if(e==null&&t.default==null&&i==null)return r;let n={type:r};return e!=null&&(n.docs=e),t.default!=null&&(n.default=t.default),i!=null&&(n.validation=i),n}function ETE({description:e,schema:t}){let r="float";if(e==null)return r;let i={type:r};return e!=null&&(i.docs=e),i}function MTE({description:e,schema:t}){let r="double",i=BP_(t,r);if(e==null&&t.default==null&&i==null)return r;let n={type:r};return e!=null&&(n.docs=e),t.default!=null&&(n.default=t.default),i!=null&&(n.validation=i),n}function ATE(e){if(e==null)return;let{format:t,pattern:r,minLength:i,maxLength:n}=e,a=qTE(t);if(!(a==null&&r==null&&i==null&&n==null))return{format:a,pattern:r,minLength:i,maxLength:n}}function qTE(e){switch(e){case"date":case"date-time":case"password":case"byte":case"bytes":case"binary":case"email":case"uuid":case"uri":case"hostname":case"ipv4":case"ipv6":return e;default:return}}function BP_(e,t){if(e==null)return;let{minimum:r,maximum:i,multipleOf:n}=e,{exclusiveMinimum:a,exclusiveMaximum:u}=e;if(r=C1c(r,t),i=C1c(i,t),n=C1c(n,t),!(r==null&&i==null&&a==null&&u==null&&n==null))return{min:r,max:i,exclusiveMin:a,exclusiveMax:u,multipleOf:n}}function C1c(e,t){if(e===void 0)return;let[r,i]=t==="integer"?[gTE,OTE]:[mTE,PTE];return e<r||e>i?void 0:e}function B1c({schema:e,fileContainingReference:t,context:r,namespace:i}){let n=r.getSchema(e.schema,i);if(n==null)return"unknown";let a=ITE(n)??e.schema,u=vKn(n),c=zTE(n),d=oau({context:r,fileContainingReference:t,declarationFile:CNi(u),type:a}),s=n.type==="nullable"?`optional<${d}>`:d;return e.description==null&&c==null?s:{type:n.type==="nullable"?`optional<${d}>`:d,...e.description!=null?{docs:e.description}:{},...e.availability!=null?{availability:ER(e.availability)}:{}}}function I1c({schema:e,fileContainingReference:t,declarationFile:r,context:i,namespace:n,declarationDepth:a}){let u=iO({schema:e.value,fileContainingReference:t,declarationFile:r,context:i,namespace:n,declarationDepth:a}),c=`list<${hq(u)}>`;return e.description==null&&e.title==null?c:{...e.description!=null?{docs:e.description}:{},...e.availability!=null?{availability:ER(e.availability)}:{},type:c}}function z1c({schema:e,fileContainingReference:t,declarationFile:r,context:i,namespace:n,declarationDepth:a}){let u=nau(e.key),c=iO({schema:e.value,fileContainingReference:t,declarationFile:r,context:i,namespace:n,declarationDepth:a}),d=e.encoding!=null?iau(e.encoding):void 0,s=`map<${hq(u)}, ${hq(c)}>`;if(e.description==null&&d==null&&e.title==null)return s;let o={type:s};return e.description!=null&&(o.docs=e.description),e.encoding!=null&&(o.encoding=d),e.availability!=null&&(o.availability=ER(e.availability)),o}function x1c({schema:e,fileContainingReference:t,declarationFile:r,context:i,namespace:n,declarationDepth:a}){if(!i.respectNullableSchemas)return aau({schema:e,fileContainingReference:t,context:i,declarationFile:r,namespace:n,declarationDepth:a});let u=iO({schema:e.value,fileContainingReference:t,declarationFile:r,context:i,namespace:n,declarationDepth:a}),c=hq(u),d=bKn(u),s=q5a(u),o=T1c(u),l=c.startsWith("nullable<")?c:`nullable<${c}>`;if(e.availability==null&&e.description==null&&d==null&&s==null&&o==null&&e.title==null)return CP_({typeReference:l,itemType:c});let b={type:l};return(e.description!=null||d!=null)&&(b.docs=e.description??d),s!=null&&(b.default=s),o!=null&&(b.validation=o),e.availability!=null&&(b.availability=ER(e.availability)),CP_({typeReference:b,itemType:c})}function aau({schema:e,fileContainingReference:t,declarationFile:r,context:i,namespace:n,declarationDepth:a}){let u=iO({schema:e.value,fileContainingReference:t,declarationFile:r,context:i,namespace:n,declarationDepth:a}),c=hq(u),d=bKn(u),s=q5a(u),o=T1c(u),l=c.startsWith("optional<")?c:`optional<${c}>`;if(e.availability==null&&e.description==null&&d==null&&s==null&&o==null&&e.title==null)return l;let b={type:l};return(e.description!=null||d!=null)&&(b.docs=e.description??d),s!=null&&(b.default=s),o!=null&&(b.validation=o),e.availability!=null&&(b.availability=ER(e.availability)),b}function R1c(){return"unknown"}function N1c(e){let t;switch(e.value.type){case"boolean":{t=`literal<${e.value.value}>`;break}case"string":{t=`literal<"${e.value.value}">`;break}default:Ao(e.value)}return e.description==null&&e.title==null?t:{type:t,...e.description!=null?{docs:e.description}:{},...e.availability!=null?{availability:ER(e.availability)}:{}}}function TTE({schema:e,fileContainingReference:t,declarationFile:r,context:i,declarationDepth:n}){let a=T5a(e,n),u=e.nameOverride??e.generatedName;i.builder.addType(r,{name:u,schema:a.schema});let c=oau({type:u,fileContainingReference:t,declarationFile:r,context:i});if(e.description==null&&e.default==null&&e.title==null)return c;let d={type:c};return e.description!=null&&(d.docs=e.description),e.default!=null&&(d.default=e.default.value),e.availability!=null&&(d.availability=ER(e.availability)),d}function CTE({schema:e,fileContainingReference:t,declarationFile:r,context:i,namespace:n,declarationDepth:a}){let u=F1c({schema:e,declarationFile:r,context:i,namespace:n,declarationDepth:a}),c=e.nameOverride??e.generatedName;i.builder.addType(r,{name:c,schema:u.schema});let d=oau({type:c,fileContainingReference:t,declarationFile:r,context:i});return e.description==null&&e.title==null?d:{type:d,...e.description!=null?{docs:e.description}:{},...e.availability!=null?{availability:ER(e.availability)}:{}}}function BTE({schema:e,fileContainingReference:t,declarationFile:r,context:i,namespace:n,declarationDepth:a}){let u=L1c({schema:e,declarationFile:r,context:i,namespace:n,declarationDepth:a}),c=e.nameOverride??e.generatedName;i.builder.addType(r,{name:c,schema:u.schema});let d=oau({type:c,fileContainingReference:t,declarationFile:r,context:i});return e.description==null&&e.title==null?d:{...e.title!=null?{"display-name":e.title}:{},type:d,...e.description!=null?{docs:e.description}:{},...e.availability!=null?{availability:ER(e.availability)}:{}}}function oau({type:e,fileContainingReference:t,declarationFile:r,context:i}){if(r===t)return e;let n=i.builder.addImport({file:t,fileToImport:r});return n!=null?`${n}.${e}`:e}function ITE(e){return wv._visit(e,{primitive:t=>t.nameOverride??t.generatedName,object:t=>t.nameOverride??t.generatedName,array:t=>t.nameOverride??t.generatedName,map:t=>t.nameOverride??t.generatedName,enum:t=>t.nameOverride??t.generatedName,reference:t=>t.nameOverride??t.generatedName,literal:t=>t.nameOverride??t.generatedName,oneOf:t=>t.nameOverride??t.generatedName,optional:t=>t.nameOverride??t.generatedName,nullable:t=>t.nameOverride??t.generatedName,unknown:t=>t.nameOverride??t.generatedName,_other:()=>{}})}function zTE(e){return wv._visit(e,{primitive:t=>t.title,object:t=>t.title,array:t=>t.title,map:t=>t.title,enum:t=>t.title,reference:t=>t.title,literal:t=>t.title,oneOf:t=>t.title,optional:t=>t.title,nullable:t=>t.title,unknown:t=>{},_other:()=>{}})}function CP_({typeReference:e,itemType:t}){return t.startsWith("optional<")?e:typeof e=="string"?`optional<${e}>`:{...e,type:`optional<${e.type}>`}}var w5;(function(e){e[e.Channel=0]="Channel",e[e.Endpoint=1]="Endpoint",e[e.Request=2]="Request",e[e.Webhook=3]="Webhook"})(w5||(w5={}));function $mi(e){switch(e.type){case"openapi":return{openapi:e.file};case"protobuf":return{proto:e.file};default:Ao(e)}}function zP_({schema:e,context:t,declarationFile:r,namespace:i,declarationDepth:n}){let a;switch(e.type){case"primitive":a=NTE(e);break;case"array":a=xTE({schema:e,context:t,declarationFile:r,namespace:i,declarationDepth:n});break;case"map":a=RTE({schema:e,context:t,declarationFile:r,namespace:i,declarationDepth:n});break;case"reference":a=FTE({schema:e,context:t,declarationFile:r,namespace:i});break;case"unknown":a=UTE(e.nameOverride,e.generatedName);break;case"optional":a=xP_({schema:e,context:t,declarationFile:r,namespace:i,declarationDepth:n});break;case"nullable":a=LTE({schema:e,context:t,declarationFile:r,namespace:i,declarationDepth:n});break;case"enum":a=T5a(e,n);break;case"literal":a=VTE(e,e.nameOverride,e.generatedName);break;case"object":a=F1c({schema:e,context:t,declarationFile:r,namespace:i,declarationDepth:n});break;case"oneOf":a=L1c({schema:e.value,context:t,declarationFile:r,namespace:i,declarationDepth:n});break;default:Ao(e)}return a}function F1c({schema:e,context:t,declarationFile:r,namespace:i,declarationDepth:n}){let a=t.isInState(w5.Request)&&t.respectReadonlySchemas&&(t.getEndpointMethod()==="POST"||t.getEndpointMethod()==="PUT"||t.getEndpointMethod()==="PATCH"),u=!1,c={},d=new Set;for(let g of e.properties){if(g.readonly&&(u=!0),a&&g.readonly)continue;if(Object.keys(g.conflict).length>0){if(Object.entries(g.conflict).every(([E,T])=>!T.differentSchema))continue;Object.entries(g.conflict).forEach(([E])=>{U1c({property:g.key,schemaId:E,context:t,namespace:i}).forEach(z=>{d.add(z)})})}let O=iO({schema:g.schema,context:t,fileContainingReference:r,namespace:i,declarationDepth:n+1}),m=g.audiences,P=g.nameOverride,D=ER(g.availability),A=GTE(g);c[g.key]=$TE({typeReference:O,audiences:m,name:P,availability:D,propertyAccess:A})}let s=new Set;for(let g of e.allOfPropertyConflicts)g.allOfSchemaIds.forEach(O=>d.add(O)),g.conflictingTypeSignatures&&s.add(g.propertyKey);let o=[];for(let g of e.allOf){let O=RP_({schema:g.schema,context:t,namespace:i});if(O==null||d.has(g.schema)||d.has(O))continue;let m=iO({schema:wv.reference(g),context:t,fileContainingReference:r,namespace:i,declarationDepth:n+1});o.push(hq(m))}for(let g of d){let O=V1c(t,g,i);for(let m of O.properties)c[m.key]==null&&(s.has(m.key)&&(c[m.key]="unknown"),c[m.key]=iO({schema:m.schema,context:t,fileContainingReference:r,namespace:i,declarationDepth:n+1}));for(let m of O.allOf){if(d.has(m.schema))continue;let P=iO({schema:wv.reference(m),context:t,fileContainingReference:r,namespace:i,declarationDepth:n+1});o.push(hq(P))}}let l={docs:e.description??void 0,properties:Object.fromEntries(Object.entries(c).map(([g,O])=>HTE(g)?[g,typeof O=="string"?{type:O,name:`_${g}`}:{...O,name:`_${g}`}]:[g,O]))};o.length>0&&(l.extends=o),e.additionalProperties&&(l["extra-properties"]=!0),e.availability!=null&&(l.availability=ER(e.availability)),e.source!=null&&(l.source=$mi(e.source)),l.inline=W1c(e,n);let b=e.nameOverride??e.generatedName;return{name:u&&t.respectReadonlySchemas&&!a?`${b}Read`:b,schema:l}}function U1c({property:e,schemaId:t,context:r,namespace:i}){let n=r.getSchema(t,i);if(n==null)return[];if(n.type==="reference")return U1c({property:e,schemaId:n.schema,context:r,namespace:i});if(n.type==="object"){let{properties:a,allOf:u}=V1c(r,t,i),c=a.some(s=>s.key===e),d=[...u.flatMap(s=>U1c({property:e,context:r,schemaId:s.schema,namespace:i}))];if(c||d.length>0)return[t,...d]}return[]}function V1c(e,t,r){let i=e.getSchema(t,r);if(i==null)return{properties:[],allOf:[]};if(i.type==="object")return{properties:i.properties,allOf:i.allOf};if(i.type==="reference")return V1c(e,i.schema,r);throw new Error(`Cannot getAllProperties for a non-object schema. schemaId=${t}, type=${i.type}`)}function xTE({schema:e,context:t,declarationFile:r,namespace:i,declarationDepth:n}){return{name:e.nameOverride??e.generatedName,schema:I1c({schema:e,fileContainingReference:r,declarationFile:r,context:t,namespace:i,declarationDepth:n})}}function RTE({schema:e,context:t,declarationFile:r,namespace:i,declarationDepth:n}){return{name:e.nameOverride??e.generatedName,schema:z1c({schema:e,fileContainingReference:r,declarationFile:r,context:t,namespace:i,declarationDepth:n})}}function NTE(e){let t=nau(e);if(typeof t=="string")return{name:e.nameOverride??e.generatedName,schema:t};let{default:r,...i}=t;return{name:e.nameOverride??e.generatedName,schema:{...i}}}function IP_(e){return e.camel==null&&e.pascal==null&&e.screamingSnake==null&&e.snake==null}function T5a(e,t){let r={enum:e.values.map(a=>{let u=a.nameOverride??a.generatedName,c=a.value;if(u===c&&a.description==null&&(a.casing==null||IP_(a.casing)))return u;let d={value:a.value};if(u!==c&&(d.name=u),a.description!=null&&(d.docs=a.description),a.casing!=null&&!IP_(a.casing)){let s={},o=!1;a.casing.camel!=null&&(s.camel=a.casing.camel,o=!0),a.casing.screamingSnake!=null&&(s["screaming-snake"]=a.casing.screamingSnake,o=!0),a.casing.snake!=null&&(s.snake=a.casing.snake,o=!0),a.casing.pascal!=null&&(s.pascal=a.casing.pascal,o=!0),o&&(d.casing=s)}return d})};e.description!=null&&(r.docs=e.description),e.default!=null&&(r.default=e.default.value),r.inline=W1c(e,t);let i=new Set,n={...r,enum:[],source:e.source!=null?$mi(e.source):void 0};for(let a of r.enum){let u=typeof a=="string"?a:a.name??a.value;i.has(u.toLowerCase())||(n.enum.push(a),i.add(u.toLowerCase()))}return{name:e.nameOverride??e.generatedName,schema:n}}function FTE({schema:e,context:t,declarationFile:r,namespace:i}){return{name:e.nameOverride??e.generatedName,schema:B1c({schema:e,context:t,fileContainingReference:r,namespace:i})}}function LTE({schema:e,context:t,declarationFile:r,namespace:i,declarationDepth:n}){return t.respectNullableSchemas?{name:e.nameOverride??e.generatedName,schema:x1c({schema:e,context:t,fileContainingReference:r,declarationFile:r,namespace:i,declarationDepth:n})}:xP_({schema:e,context:t,declarationFile:r,namespace:i,declarationDepth:n})}function xP_({schema:e,context:t,declarationFile:r,namespace:i,declarationDepth:n}){return{name:e.nameOverride??e.generatedName,schema:aau({schema:e,context:t,fileContainingReference:r,declarationFile:r,namespace:i,declarationDepth:n})}}function UTE(e,t){return{name:e??t,schema:R1c()}}function VTE(e,t,r){return{name:t??r,schema:N1c(e)}}function L1c({schema:e,context:t,declarationFile:r,namespace:i,declarationDepth:n}){let a=e.encoding!=null?iau(e.encoding):void 0;if(e.type==="discriminated"){let c={};for(let s of e.commonProperties)c[s.key]=iO({schema:s.schema,fileContainingReference:r,context:t,namespace:i,declarationDepth:n+1});let d={};for(let[s,o]of Object.entries(e.schemas))d[s]=iO({schema:o,context:t,fileContainingReference:r,namespace:i,declarationDepth:n+1});return{name:e.nameOverride??e.generatedName,schema:{discriminant:e.discriminantProperty,"base-properties":c,docs:e.description??void 0,availability:e.availability!=null?ER(e.availability):void 0,union:d,encoding:a,source:e.source!=null?$mi(e.source):void 0}}}let u=[];for(let c of e.schemas)u.push(iO({schema:c,fileContainingReference:r,context:t,namespace:i,declarationDepth:n+1}));return{name:e.nameOverride??e.generatedName,schema:{discriminated:!1,docs:e.description??void 0,union:u,encoding:a,source:e.source!=null?$mi(e.source):void 0,inline:W1c(e,n)}}}var WTE=/^[0-9]/;function HTE(e){return WTE.test(e)}function RP_({schema:e,context:t,namespace:r}){let i=t.getSchema(e,r);if(i!=null)return i.type==="reference"?RP_({context:t,schema:i.schema,namespace:r}):e}function $TE({typeReference:e,audiences:t,name:r,availability:i,propertyAccess:n}){return t.length===0&&r==null&&i==null&&n==null?e:{...typeof e=="string"?{type:e}:{...e},...t.length>0?{audiences:t}:{},...r!=null?{name:r}:{},...i!=null?{availability:i}:{},...n!=null?{access:n}:{}}}function W1c(e,t){return e.inline===!0||t>0?!0:void 0}function GTE(e){if(!(e.readonly&&e.writeonly)){if(e.readonly)return i7.ObjectPropertyAccess.ReadOnly;if(e.writeonly)return i7.ObjectPropertyAccess.WriteOnly}}function NP_(e){let t=e.replace(/^x-|^X-/,"");return F_(t)}var FP_="BasicAuthScheme",uau="BearerAuthScheme";function LP_(e){if(e.authOverrides!=null){for(let[r,i]of Object.entries(e.authOverrides["auth-schemes"]??{}))e.builder.addAuthScheme({name:r,schema:i});e.authOverrides.auth!=null&&e.builder.setAuth(e.authOverrides.auth);return}let t=!1;for(let[r,i]of Object.entries(e.ir.securitySchemes))if(i.type==="basic"){let n={scheme:"basic"};i.usernameVariableName!=null&&(n.username===void 0?n.username={name:i.usernameVariableName}:n.username.name=i.usernameVariableName),i.usernameEnvVar!=null&&(n.username===void 0?n.username={env:i.usernameEnvVar}:n.username.env=i.usernameEnvVar),i.passwordVariableName!=null&&(n.password===void 0?n.password={name:i.passwordVariableName}:n.password.name=i.passwordVariableName),i.passwordEnvVar!=null&&(n.password===void 0?n.password={env:i.passwordEnvVar}:n.password.env=i.passwordEnvVar),e.builder.addAuthScheme({name:FP_,schema:n}),t||(e.builder.setAuth(FP_),t=!0)}else if(i.type==="bearer"){let n={scheme:"bearer"};i.tokenVariableName!=null&&(n.token===void 0?n.token={name:i.tokenVariableName}:n.token.name=i.tokenVariableName),i.tokenEnvVar!=null&&(n.token===void 0?n.token={env:i.tokenEnvVar}:n.token.env=i.tokenEnvVar),e.builder.addAuthScheme({name:uau,schema:n}),t||(e.builder.setAuth(uau),t=!0)}else if(i.type==="header")if(t)e.builder.addGlobalHeader({name:i.headerName,schema:{type:"string",name:i.headerVariableName??NP_(i.headerName),env:i.headerEnvVar}});else{let n={header:i.headerName,name:i.headerVariableName??"apiKey",type:"string"};i.headerEnvVar!=null&&(n.env=i.headerEnvVar),i.prefix!=null&&(n.prefix=i.prefix),e.builder.addAuthScheme({name:r,schema:n}),e.builder.setAuth(r),t=!0}else if(i.type==="oauth"){let n={scheme:"bearer"};e.builder.addAuthScheme({name:uau,schema:n}),t||(e.builder.setAuth(uau),t=!0),i.scopesEnum!=null&&i.scopesEnum.values.length>0&&e.builder.addType(Ey.of("__package__.yml"),{name:"OauthScope",schema:T5a(i.scopesEnum,0).schema})}}function yor({header:e,context:t,fileContainingReference:r,namespace:i}){let n=iO({schema:e.schema,context:t,fileContainingReference:r,namespace:i,declarationDepth:0}),a=hq(n),u=e.name.replace(/^x-|^X-/,""),c=e.parameterNameOverride!=null?e.parameterNameOverride:F_(u);if(e.description==null&&e.name===c&&e.env==null&&e.availability==null)return a;let d={type:a};return c!==e.name&&(d.name=c),e.description!=null&&(d.docs=e.description),e.env!=null&&(d.env=e.env),e.availability!=null&&(d.availability=ER(e.availability)),d}function sau({pathParameter:e,context:t,fileContainingReference:r,namespace:i}){let n=iO({schema:e.schema,context:t,fileContainingReference:r,namespace:i,declarationDepth:0});if(e.variableReference==null&&e.description==null&&e.availability==null)return hq(n);let a=e.variableReference!=null?{variable:`$${e.variableReference}`}:{type:hq(n)};return e.description!=null&&(a.docs=e.description),e.availability!=null&&(a.availability=ER(e.availability)),a}function lau({queryParameter:e,context:t,fileContainingReference:r,namespace:i}){let n=H1c({schema:e.schema,context:t,fileContainingReference:r,namespace:i});if(n==null)return;let a=hq(n.value),u=q5a(n.value);a==="unknown"?a="string":a==="optional<unknown>"&&(a="optional<string>");let c={type:a};return u!=null&&(c.default=u),n.allowMultiple&&(c["allow-multiple"]=!0),e.description!=null&&(c.docs=e.description),e.parameterNameOverride!=null&&(c.name=e.parameterNameOverride),e.availability!=null&&(c.availability=ER(e.availability)),QTE(n.value)&&n.value.validation!==void 0&&(c.validation=n.value.validation),c.default==null&&c["allow-multiple"]==null&&c.docs==null&&c.name==null&&c.availability==null&&c.validation==null?a:c}function H1c({schema:e,context:t,fileContainingReference:r,namespace:i}){if(e.type==="reference"){let n=t.getSchema(e.schema,i);if(n==null)return;if(n.type==="array")return{value:iO({schema:wv.optional({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:n.value,description:e.description??n.description,availability:e.availability,namespace:void 0,groupName:void 0,inline:void 0}),context:t,declarationFile:Ey.of(CS),fileContainingReference:r,namespace:i,declarationDepth:0}),allowMultiple:!0};if(n.type==="oneOf"&&n.value.type==="undiscriminated"){let a=[],u=!1;for(let[c,d]of Object.entries(n.value.schemas))d.type==="primitive"&&d.schema.type==="string"&&(u=!0),d.type==="literal"&&d.value.type==="string"&&(hKn.test(d.value.value)?a.push(d.value.value):a.push({value:d.value.value,name:yKn(d.value.value)}));if(a.length>0)return t.builder.addType(r,{name:e.generatedName,schema:{enum:a}}),u&&t.respectForwardCompatibleEnums?(t.builder.addType(r,{name:`${e.generatedName}OrString`,schema:{discriminated:!1,union:[{type:"string"},{type:e.generatedName}]}}),{value:`${e.generatedName}OrString`,allowMultiple:!1}):{value:e.generatedName,allowMultiple:!1};if(n.value.schemas.length===2){let[c,d]=n.value.schemas;if(c!=null&&d!=null&&cau({array:c,primitive:d}))return{value:iO({schema:wv.optional({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:d,description:e.description,availability:e.availability,namespace:void 0,groupName:void 0,inline:void 0}),context:t,fileContainingReference:r,namespace:i,declarationDepth:0}),allowMultiple:!0};if(c!=null&&d!=null&&cau({array:c,primitive:d}))return{value:iO({schema:wv.optional({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:c,description:e.description,availability:e.availability,namespace:void 0,groupName:void 0,inline:void 0}),context:t,fileContainingReference:r,namespace:i,declarationDepth:0}),allowMultiple:!0}}for(let[c,d]of Object.entries(n.value.schemas))return H1c({schema:d,context:t,fileContainingReference:r,namespace:i})}else if(t.objectQueryParameters)return{value:iO({schema:e,context:t,fileContainingReference:r,declarationFile:Ey.of(CS),namespace:i,declarationDepth:0}),allowMultiple:!1}}if(e.type==="optional"||e.type==="nullable"){if(e.value.type==="reference"){let n=t.getSchema(e.value.schema,i);if(n==null)return;if(n.type==="array")return{value:iO({schema:wv.optional({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:n.value,description:e.description??n.description,availability:e.availability,namespace:void 0,groupName:void 0,inline:e.inline}),context:t,fileContainingReference:r,declarationFile:Ey.of(CS),namespace:i,declarationDepth:0}),allowMultiple:!0};if(t.objectQueryParameters)return{value:iO({schema:e,context:t,fileContainingReference:r,declarationFile:Ey.of(CS),namespace:i,declarationDepth:0}),allowMultiple:!1}}if(e.value.type==="array")return{value:iO({schema:wv.optional({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:e.value.value,description:e.description,availability:e.availability,namespace:void 0,groupName:void 0,inline:e.inline}),context:t,fileContainingReference:r,namespace:i,declarationDepth:0}),allowMultiple:!0};if(e.value.type==="oneOf"&&e.value.value.type==="undiscriminated"){let n=[],a=!1;for(let[u,c]of Object.entries(e.value.value.schemas))c.type==="primitive"&&c.schema.type==="string"&&(a=!0),c.type==="literal"&&c.value.type==="string"&&(hKn.test(c.value.value)?n.push(c.value.value):n.push({value:c.value.value,name:yKn(c.value.value)}));if(n.length>0)return t.builder.addType(r,{name:e.generatedName,schema:{enum:n}}),a&&t.respectForwardCompatibleEnums?(t.builder.addType(r,{name:`${e.generatedName}OrString`,schema:{discriminated:!1,union:[{type:"string"},{type:`optional<${e.value.value.generatedName}>`}]}}),{value:`optional<${e.value.value.generatedName}OrString>`,allowMultiple:!1}):{value:`optional<${e.value.value.generatedName}>`,allowMultiple:!1};if(e.value.value.schemas.length===2){let[u,c]=e.value.value.schemas;if(u!=null&&c!=null&&cau({array:u,primitive:c}))return{value:iO({schema:wv.optional({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:c,description:e.description,availability:e.availability,namespace:void 0,groupName:void 0,inline:e.inline}),context:t,fileContainingReference:r,namespace:i,declarationDepth:0}),allowMultiple:!0};if(u!=null&&c!=null&&cau({array:c,primitive:u}))return{value:iO({schema:wv.optional({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:u,description:e.description,availability:e.availability,namespace:void 0,groupName:void 0,inline:e.inline}),context:t,fileContainingReference:r,namespace:i,declarationDepth:0}),allowMultiple:!0}}if(t.objectQueryParameters)return{value:iO({schema:e,context:t,fileContainingReference:r,declarationFile:Ey.of(CS),namespace:i,declarationDepth:0}),allowMultiple:!1};for(let[u,c]of Object.entries(e.value.value.schemas))return H1c({schema:wv.optional({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:c,description:void 0,availability:e.availability,namespace:void 0,groupName:void 0,inline:e.inline}),context:t,fileContainingReference:r,namespace:i})}else if(e.value.type==="object")return t.objectQueryParameters?{value:iO({schema:e,context:t,fileContainingReference:r,declarationFile:Ey.of(CS),namespace:i,declarationDepth:0}),allowMultiple:!1}:void 0;return{value:iO({schema:e,context:t,fileContainingReference:r,namespace:i,declarationDepth:0}),allowMultiple:!1}}return e.type==="array"?{value:iO({schema:wv.optional({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:e.value,description:e.description,availability:e.availability,namespace:void 0,groupName:void 0,inline:e.inline}),context:t,fileContainingReference:r,namespace:i,declarationDepth:0}),allowMultiple:!0}:{value:iO({schema:e,context:t,fileContainingReference:r,namespace:i,declarationDepth:0}),allowMultiple:!1}}function cau({array:e,primitive:t}){return e?.type==="array"&&e.value.type==="primitive"&&t?.type==="primitive"&&e.value.schema.type===t.schema.type}function QTE(e){return e.type!=null}function UP_({websocketExample:e,context:t}){let r={messages:[]};e.name!=null&&(r.name=e.name),e.description!=null&&(r.docs=e.description),e.queryParameters!=null&&e.queryParameters.length>0&&(r["query-parameters"]=JTE(e.queryParameters)),e.headers!=null&&e.headers.length>0&&(r.headers=KTE({context:t,namedFullExamples:e.headers}));for(let i of e.messages){let n=BNi(i.payload);n!=null&&r.messages.push({type:i.messageType,body:n})}return r}function JTE(e){let t={};return e.forEach(r=>{let i=BNi(r.value);Array.isArray(i)?t[r.name]=i[0]:i!=null&&(t[r.name]=i)}),t}function KTE({context:e,namedFullExamples:t}){let r=e.builder.getGlobalHeaderNames(),i={};return t.forEach(n=>{let a=BNi(n.value);r.has(n.name)||a!=null&&(i[n.name]=a)}),i}function BNi(e){switch(e.type){case"primitive":return VP_(e.value);case"object":return WP_(e.properties);case"array":return YTE(e.value);case"map":return XTE(e.value);case"oneOf":return ZTE(e.value);case"enum":return e.value;case"literal":return kTE(e.value);case"unknown":return BNi(e.value);default:Ao(e)}}function VP_(e){switch(e.type){case"int":return e.value;case"int64":return e.value;case"uint":return e.value;case"uint64":return e.value;case"float":return e.value;case"double":return e.value;case"string":return e.value.startsWith("$")?`${e.value.slice(1)}`:e.value;case"datetime":try{return new Date(e.value).toISOString().replace(/\.\d{3}Z$/,"Z")}catch{return"2024-01-15T09:30:00Z"}case"date":return e.value;case"base64":case"boolean":return e.value;default:Ao(e)}}function WP_(e){return Object.fromEntries(Object.entries(e).map(([t,r])=>[t,BNi(r)]))}function YTE(e){return e.map(t=>BNi(t))}function XTE(e){return Object.fromEntries(e.map(t=>[VP_(t.key),BNi(t.value)]))}function ZTE(e){return e.type==="discriminated"?WP_(e.value):BNi(e.value)}function kTE(e){switch(e.type){case"string":return e.value;case"boolean":return e.value;default:Ao(e)}}function Gmi(e){return e.find(t=>typeof t!="string"&&t.type==="namespace")?.name}function fau(e,t){return t??(e?.groupName!=null?Gmi(e.groupName):void 0)}function HP_({channel:e,context:t,declarationFile:r}){let i={path:e.path,url:e.servers[0]?.name,auth:!1};e.audiences!=null&&e.audiences.length>0&&(i.audiences=e.audiences),e.summary!=null&&(i["display-name"]=e.summary),e.description!=null&&(i.docs=e.description);let n=Gmi(e.groupName),a={};if(e.handshake.pathParameters.length>0)for(let d of e.handshake.pathParameters)a[d.name]=sau({pathParameter:d,context:t,fileContainingReference:r,namespace:n});Object.keys(a).length>0&&(i["path-parameters"]=a);let u={};if(e.handshake.queryParameters.length>0)for(let d of e.handshake.queryParameters){let s=lau({queryParameter:d,context:t,fileContainingReference:r,namespace:n});s!=null&&(u[d.name]=s)}Object.keys(u).length>0&&(i["query-parameters"]=u);let c={};if(e.handshake.headers.length>0)for(let d of e.handshake.headers){let s=yor({header:d,context:t,fileContainingReference:r,namespace:n});c[d.name]=s}Object.keys(c).length>0&&(i.headers=c),t.builder.addChannel(r,{channel:i});for(let d of e.messages)t.builder.addChannelMessage(r,{messageId:d.name,message:{origin:d.origin,body:iO({schema:d.body,context:t,fileContainingReference:r,namespace:n,declarationDepth:0})}});for(let d of e.examples){let s=UP_({context:t,websocketExample:d});t.builder.addChannelExample(r,{example:s})}}var Qmi="Base",eCE="Default";function INi(e){return Object.entries(e).reduce((t,[r,i])=>(dUn(i)?Object.entries(i.urls).forEach(([n,a])=>{t[n]=a}):t[r]=typeof i=="string"?i:i.url,t),{})}function $P_(e){if(e.environmentOverrides!=null){for(let[g,O]of Object.entries(e.environmentOverrides.environments??{}))e.builder.addEnvironment({name:g,schema:O});e.environmentOverrides["default-environment"]!=null&&e.builder.setDefaultEnvironment(e.environmentOverrides["default-environment"]),e.environmentOverrides["default-url"]!=null&&e.builder.setDefaultUrl(e.environmentOverrides["default-url"]);return}let t={},r=[];for(let g of e.ir.servers){let O=g.audiences?{url:g.url,audiences:g.audiences}:g.url;if(g.name==null){r.push(O);continue}t[g.name]=O}let i={},n=[];for(let g of e.ir.endpoints)for(let O of g.servers){if(O.url==null)continue;let m=O.audiences?{url:O.url,audiences:O.audiences}:O.url;if(O.name==null){n.push(m);continue}i[O.name]=m}let a={},u=[];for(let g of e.ir.websocketServers){let O=g.audiences?{url:g.url,audiences:g.audiences}:g.url;if(g.name==null){u.push(O);continue}a[g.name]=O}let c=Object.keys(t).length,d=c>0,s=Object.keys(i).length>0,o=Object.keys(a).length>0;if(!d&&!s&&o&&e.ir.servers.length===0){for(let[g,O]of Object.entries(a))e.builder.addEnvironment({name:g,schema:O});e.builder.setDefaultEnvironment(Object.keys(a)[0]),e.builder.setDefaultUrl(Qmi);return}if(n.length>0&&e.logger.error(`Skipping endpoint level servers ${n.map(g=>typeof g=="string"?g:g.url).join(", ")} because x-fern-server-name was not provided.`),!d){let g=e.ir.servers[0]?.url,O=e.ir.servers[0]?.audiences;if(g!=null){let m=O?{url:g,audiences:O}:g;t[eCE]=m}}let l=Object.values(t).map(g=>typeof g=="string"?g:g.url),b=r.filter(g=>{let O=typeof g=="string"?g:g.url;return!l.includes(O)});if(b.length>0&&e.logger.error(`Skipping top level servers ${b.map(g=>typeof g=="string"?g:g.url).join(", ")} because x-fern-server-name was not provided.`),s)if(c===1){let g=Object.keys(t)[0],O=Object.values(t)[0],m=typeof O=="string"?O:O.url;e.builder.addEnvironment({name:g,schema:{urls:{[Qmi]:m,...INi(i),...INi(a)}}}),e.builder.setDefaultEnvironment(g),e.builder.setDefaultUrl(Qmi)}else{let g=!0;for(let[O,m]of Object.entries(t))g?(e.builder.addEnvironment({name:O,schema:{urls:{[Qmi]:typeof m=="string"?m:m.url,...INi(i),...INi(a)}}}),e.builder.setDefaultEnvironment(O),g=!1):e.builder.addEnvironment({name:O,schema:{urls:{[Qmi]:typeof m=="string"?m:m.url,...INi(i),...INi(a)}}});e.builder.setDefaultUrl(Qmi)}else{let g=!0;for(let[O,m]of Object.entries(t))g?(o?e.builder.addEnvironment({name:O,schema:{urls:{[Qmi]:typeof m=="string"?m:m.url,...INi(a)}}}):e.builder.addEnvironment({name:O,schema:m}),e.builder.setDefaultEnvironment(O),g=!1):o?e.builder.addEnvironment({name:O,schema:{urls:{[Qmi]:typeof m=="string"?m:m.url,...INi(a)}}}):e.builder.addEnvironment({name:O,schema:m});o&&e.builder.setDefaultUrl(Qmi)}}function dau(e){return hq(e).startsWith("optional")?e:typeof e=="string"?`optional<${e}>`:{...e,type:`optional<${e.type}>`}}var $1c=class{schema;count=0;constructor(t){this.schema=t}increment(){this.count+=1}},tCE=.75,rCE=new Set("authorization");function GP_(e){if(e.globalHeaderOverrides!=null){for(let[r,i]of Object.entries(e.globalHeaderOverrides.headers??{}))e.builder.addGlobalHeader({name:r,schema:i});return}let t=Object.fromEntries((e.ir.globalHeaders??[]).map(r=>[r.header,r]));for(let[r,i]of Object.entries(t)){let n="optional<string>";if(i.name==null&&i.env==null&&typeof i.schema=="string")n=i.schema;else if(i!=null){let a=i.schema?vKn(i.schema):void 0,u=a!=null?Gmi(a):void 0,c=Ey.of("api.yml");n={name:i.name,env:i.env,type:i.schema!=null?hq(iO({schema:i.schema,context:e,fileContainingReference:u?X3(Ey.of(F_(u)),c):c,namespace:u,declarationDepth:0}))??"optional<string>":"optional<string>"}}e.builder.addGlobalHeader({name:r,schema:n})}if(e.detectGlobalHeaders){let r={};for(let n of e.ir.endpoints)for(let a of n.headers){if(rCE.has(a.name.toLowerCase()))continue;let u=r[a.name];if(u==null){let c=t[a.name],d=yor({header:{...a,schema:c?.schema??a.schema,name:c?.name??a.name},fileContainingReference:Ey.of(lF),context:e,namespace:void 0});u=new $1c(d),r[a.name]=u}u.increment()}let i=e.ir.endpoints.length*tCE;for(let[n,a]of Object.entries(r)){let u=t[n],c=a.count===e.ir.endpoints.length,d=a.count>=i;u==null&&(c?e.builder.addGlobalHeader({name:n,schema:a.schema}):d&&e.builder.addGlobalHeader({name:n,schema:dau(a.schema)}))}}}function QP_(e){for(let t of e.ir.idempotencyHeaders??[]){let r=t.schema?vKn(t.schema):void 0,i=r!=null?Gmi(r):void 0,n=yor({header:{...t,schema:t.schema??wv.primitive({description:void 0,availability:void 0,generatedName:"",title:void 0,namespace:void 0,groupName:void 0,nameOverride:void 0,schema:Ww.string({default:void 0,pattern:void 0,format:void 0,minLength:void 0,maxLength:void 0})}),name:t.name??t.header,parameterNameOverride:void 0,description:void 0,availability:void 0,source:void 0},fileContainingReference:Ey.of(lF),context:e,namespace:i});e.builder.addIdempotencyHeader({name:t.header,schema:dau(n)})}}function LK(e){switch(e.type){case"primitive":return KP_(e.value);case"object":return YP_(e.properties);case"array":return XP_(e.value);case"map":return nCE(e.value);case"oneOf":return aCE(e.value);case"enum":return typeof e.value=="string"&&e.value.startsWith("$")?`\\${e.value}`:e.value;case"literal":return oCE(e.value);case"unknown":return LK(e.value);default:Ao(e)}}function JP_(e){switch(e.type){case"withStreaming":return e.sse?{stream:iCE(e.events)}:{stream:XP_(e.events)};case"withoutStreaming":return{body:LK(e.value)};default:Ao(e)}}function KP_(e){switch(e.type){case"int":return e.value;case"int64":return e.value;case"uint":return e.value;case"uint64":return e.value;case"float":return e.value;case"double":return e.value;case"string":return e.value.startsWith("$")?`\\${e.value}`:e.value;case"datetime":try{return!e.value.endsWith("Z")&&!e.value.includes("+")&&(e.value+="Z"),new Date(e.value).toISOString().replace(/\.\d{3}Z$/,"Z")}catch{return"2024-01-15T09:30:00Z"}case"date":return e.value;case"base64":case"boolean":return e.value;default:Ao(e)}}function YP_(e){return Object.fromEntries(Object.entries(e).map(([t,r])=>[t,LK(r)]))}function iCE(e){return e.map(t=>({event:"",data:LK(t)}))}function XP_(e){return e.map(t=>LK(t))}function nCE(e){return Object.fromEntries(e.map(t=>[KP_(t.key),LK(t.value)]))}function aCE(e){return e.type==="discriminated"?YP_(e.value):LK(e.value)}function oCE(e){switch(e.type){case"string":return e.value;case"boolean":return e.value;default:Ao(e)}}function ZP_({endpointExample:e,context:t}){let r={};if(e.type!=="full")return e.value;e.name!=null&&(r.name=e.name),e.description!=null&&(r.docs=e.description),e.pathParameters!=null&&e.pathParameters.length>0&&(r["path-parameters"]=uCE(e.pathParameters)),e.queryParameters!=null&&e.queryParameters.length>0&&(r["query-parameters"]=sCE(e.queryParameters));let i=e.headers!=null&&e.headers.length>0,n=t.builder.getGlobalHeaders(),a=Object.keys(n).length>0,u=new Set(e.headers?.map(c=>c.name)??[]);if(i||a){let c=[];if(e.headers!=null)for(let d of e.headers)d.name!==t.builder.getAuthHeaderName()&&c.push(d);for(let[d,s]of Object.entries(n))if(!u.has(d))if(s!=null&&typeof s=="object"&&s.type!=null){let o=SF({type:s.type,_default:void 0,validation:void 0,visitor:{primitive:l=>l.toString(),map:l=>l.toString(),list:l=>l,optional:l=>l,nullable:l=>l,set:l=>l,named:l=>l,literal:l=>{if(l.type==="string")return l.string;if(l.type==="boolean")return l.boolean.toString()},unknown:Ko}});o!=null&&c.push({name:d,value:rO.literal(mNi.string(o))})}else c.push({name:d,value:rO.primitive(M_.string(d))});r.headers=cCE({context:t,namedFullExamples:c})}return e.request!=null&&(r.request=LK(e.request)),e.response!=null&&(r.response=JP_(e.response)),e.codeSamples!=null&&e.codeSamples.length>0&&(r["code-samples"]=e.codeSamples.map(c=>c.type==="language"?{name:c.name??void 0,docs:c.description??void 0,language:c.language,code:c.code,install:c.install??void 0}:{name:c.name??void 0,docs:c.description??void 0,sdk:c.sdk,code:c.code}).filter(gy)),r}function uCE(e){let t={};return e.forEach(r=>{let i=LK(r.value);i!=null&&(t[r.parameterNameOverride??r.name]=i)}),t}function sCE(e){let t={};return e.forEach(r=>{let i=LK(r.value);Array.isArray(i)?t[r.name]=i[0]:i!=null&&(t[r.name]=i)}),t}function cCE({context:e,namedFullExamples:t}){let r={};return t.forEach(i=>{let n=LK(i.value);n!=null&&(r[i.name]=n)}),r}function kP_(e){return E$._visit(e,{get:()=>i7.HttpMethodSchema.Get,post:()=>i7.HttpMethodSchema.Post,put:()=>i7.HttpMethodSchema.Put,patch:()=>i7.HttpMethodSchema.Patch,delete:()=>i7.HttpMethodSchema.Delete,head:()=>i7.HttpMethodSchema.Head,options:()=>{throw new Error("OPTIONS is unsupported")},trace:()=>{throw new Error("TRACE is unsupported")},_other:()=>{throw new Error("Unknown http method is unsupported")}})}function ej_(e){return e==="POST"||e==="PUT"||e==="PATCH"}function tj_({endpoint:e,declarationFile:t,context:r}){let{nonRequestReferencedSchemas:i}=r.ir,n=[],a=new Set,u=e.path,c=fau(e.sdkName,e.namespace),d={};for(let P of e.pathParameters)P.parameterNameOverride&&(u=u.replace(P.name,P.parameterNameOverride)),d[P.parameterNameOverride??P.name]=sau({pathParameter:P,context:r,fileContainingReference:t,namespace:c}),a.add(P.name);let s={};for(let P of e.queryParameters){let D=lau({queryParameter:P,context:r,fileContainingReference:t,namespace:c});D!=null&&(s[P.name]=D,a.add(P.name))}let o;if(e.pagination!=null)switch(e.pagination.type){case"cursor":o={cursor:e.pagination.cursor,next_cursor:e.pagination.nextCursor,results:e.pagination.results};break;case"offset":o={offset:e.pagination.offset,step:e.pagination.step,results:e.pagination.results,"has-next-page":e.pagination.hasNextPage};break;case"custom":o={type:"custom",results:e.pagination.results};break;default:Ao(e.pagination)}let l={path:u,method:kP_(e.method),auth:e.authed,docs:e.description??void 0,pagination:o,source:e.source!=null?$mi(e.source):void 0};!dCE({context:r,request:e.request})&&Object.keys(d).length>0&&(l["path-parameters"]=d),e.summary!=null&&(l["display-name"]=e.summary);let b={},g=r.builder.getGlobalHeaderNames(),O=r.builder.getAuthHeaderName();O!=null&&g.add(O);let m=e.headers.filter(P=>!g.has(P.name));for(let P of m){let D=yor({header:P,context:r,fileContainingReference:t,namespace:c});b[P.name]=D,a.add(typeof D=="string"?P.name:D.name??P.name)}if(e.request!=null){r.setInState(w5.Request);let P=fCE({endpoint:e,context:r,declarationFile:t,request:e.request,generatedRequestName:e.generatedRequestName,requestNameOverride:e.requestNameOverride??void 0,pathParameters:r.inlinePathParameters&&Object.keys(d).length>0?d:void 0,queryParameters:Object.keys(s).length>0?s:void 0,nonRequestReferencedSchemas:Array.from(i),headers:Object.keys(b).length>0?b:void 0,usedNames:a,namespace:c});l.request=P.value,n=[...n,...P.schemaIdsToExclude??[]],r.unsetInState(w5.Request)}else{let P=r.inlinePathParameters&&Object.keys(d).length>0,D=Object.keys(s).length>0,A=Object.keys(b).length>0,M={};(P||D||A)&&(M.name=e.requestNameOverride??e.generatedRequestName),P&&(M["path-parameters"]=d),D&&(M["query-parameters"]=s),A&&(M.headers=b),Object.keys(M).length>0&&(l.request=M)}if(e.response!=null&&e.response._visit({json:P=>{let D=iO({schema:P.schema,context:r,fileContainingReference:t,namespace:c,declarationDepth:0});l.response={docs:P.description??void 0,type:hq(D)},P.statusCode!=null&&(l.response["status-code"]=P.statusCode),P.responseProperty!=null&&(l.response.property=P.responseProperty)},streamingJson:P=>{let D=iO({schema:P.schema,context:r,fileContainingReference:t,namespace:c,declarationDepth:0});l["response-stream"]={docs:P.description??void 0,type:hq(D),format:"json"}},streamingSse:P=>{let D=iO({schema:P.schema,context:r,fileContainingReference:t,namespace:c,declarationDepth:0});l["response-stream"]={docs:P.description??void 0,type:hq(D),format:"sse"}},file:P=>{l.response={docs:P.description??void 0,type:"file","status-code":P.statusCode}},bytes:P=>{l.response={docs:P.description??void 0,type:"bytes","status-code":P.statusCode}},streamingText:P=>{l["response-stream"]={docs:P.description??void 0,type:"text"}},text:P=>{l.response={docs:P.description??void 0,type:"text","status-code":P.statusCode}},_other:()=>{throw new Error("Unrecognized Response type: "+e.response?.type)}}),r.builder.getEnvironmentType()==="multi"){let P=r.getDefaultServerName(),D=e.servers[0];D==null?P!=null&&(l.url=P):l.url=D.name??void 0}return e.idempotent&&(l.idempotent=!0),e.availability!=null&&(l.availability=ER(e.availability)),Object.entries(e.errors).forEach(([P,D])=>{let A=D.generatedName,M=Ey.of(CS);r.builder.enableUniqueErrorsPerEndpoint&&(A=`${e.generatedRequestName}${D.generatedName}`,D.schema!=null&&(D.schema.type!=="reference"&&D.schema.type!=="oneOf"?D.schema.generatedName=`${e.generatedRequestName}${D.schema.generatedName}`:D.schema.type==="oneOf"&&(D.schema.value.generatedName=`${e.generatedRequestName}${D.schema.value.generatedName}`)));let E={"status-code":parseInt(P)},T=TP_({location:rj_,namespaceOverride:c});if(D.schema!=null){let I=iO({schema:D.schema,context:r,fileContainingReference:T,declarationFile:T,namespace:c,declarationDepth:0});E.type=hq(I),E.docs=D.description}r.builder.addError(T,{name:A,schema:r.isErrorUnknownSchema(parseInt(P))?{...E,type:"unknown"}:E}),l.errors==null&&(l.errors=[]);let z=r.builder.addImport({file:t,fileToImport:T});l.errors.push(z!=null?`${z}.${A}`:A),E.type!=null&&D.examples?.forEach(I=>{let N={value:LK(I.example),name:I.name,docs:I.description};r.builder.addErrorExample(T,{name:A,example:N})})}),e.examples.length>0&&(l.examples=lCE({endpointExamples:e.examples,context:r})),r.ir.hasEndpointsMarkedInternal&&(e.internal==null||!e.internal)?l.audiences=[G1c,...e.audiences]:e.audiences.length>0&&(l.audiences=e.audiences),{value:l,schemaIdsToExclude:n}}function lCE({endpointExamples:e,context:t}){return e.map(r=>{try{return ZP_({endpointExample:r,context:t})}catch(i){throw console.error(`Error building endpoint example: ${i}`),i}})}function fCE({endpoint:e,declarationFile:t,context:r,request:i,requestNameOverride:n,generatedRequestName:a,pathParameters:u,queryParameters:c,nonRequestReferencedSchemas:d,headers:s,usedNames:o,namespace:l}){if(i.type==="json"||i.type==="formUrlEncoded"){let b=i.schema.type==="reference"?i.schema.schema:void 0,g=i.schema.type==="reference"?r.getSchema(i.schema.schema,l):i.schema;if(g?.type!=="object"||b!=null&&d.includes(b)){let A=iO({schema:i.schema,fileContainingReference:t,context:r,namespace:l,declarationDepth:0}),M={schemaIdsToExclude:[],value:{body:A}},E=Object.keys(u??{}).length>0,T=Object.keys(c??{}).length>0,z=Object.keys(s??{}).length>0;return E&&(M.value["path-parameters"]=u),T&&(M.value["query-parameters"]=c),z&&(M.value.headers=s),(E||T||z)&&(M.value.name=n??a),i.contentType!=null&&(M.value["content-type"]=i.contentType),i.description!=null&&(M.value.docs=i.description),M}let O=Object.fromEntries(g.properties.filter(A=>A.readonly==null?!0:!(ej_(e.method)&&A.readonly)).map(A=>{let M=iO({schema:A.schema,fileContainingReference:t,context:r,namespace:l,declarationDepth:1}),E=A.nameOverride??A.key,T=ER(A.availability);if(!o.has(E)&&A.audiences.length<=0)return o.add(E),A.nameOverride!=null?[A.key,{type:hq(M),docs:bKn(M),name:A.nameOverride,availability:T}]:[A.key,T?{...typeof M=="string"?{type:M}:M,availability:T}:M];let z={type:hq(M),docs:bKn(M)};return o.has(E)&&(z.name=A.generatedName),A.audiences.length>0&&(z.audiences=A.audiences),T!=null&&(z.availability=T),o.add(E),[A.key,z]})),m=g.allOf.map(A=>{let M=iO({schema:wv.reference(A),fileContainingReference:t,context:r,namespace:l,declarationDepth:0});return hq(M)}).filter(A=>A!=="unknown"),P={properties:O};m.length>0&&(P.extends=m),i.additionalProperties&&(P["extra-properties"]=!0);let D={name:n??g.nameOverride??g.generatedName,"path-parameters":u,"query-parameters":c,headers:s,body:P};return i.contentType!=null&&(D["content-type"]=i.contentType),i.description!=null&&(D.docs=i.description),{schemaIdsToExclude:b!=null?[b]:[],value:D}}else{if(i.type==="octetStream")return{schemaIdsToExclude:[],value:{body:"bytes","content-type":i.contentType??Uq.APPLICATION_OCTET_STREAM,"query-parameters":c,...i.description?{docs:i.description}:{}}};if(i.type==="multipart"){let b=Object.fromEntries(i.properties.map(g=>{if(g.schema.type==="file"){let O=g.schema.isArray?"list<file>":"file";if(O=g.schema.isOptional?`optional<${O}>`:O,g.description!=null||g.contentType!=null){let m={type:O};if(g.description!=null&&(m.docs=g.description),g.contentType!=null){let P=g.contentType.split(",")[0];m["content-type"]=P}return[g.key,m]}return[g.key,O]}else{let O=iO({schema:g.schema.value,fileContainingReference:t,context:r,namespace:l,declarationDepth:1});if(g.contentType||g.exploded||g.encoding){let m=typeof O=="string"?{type:O}:O;g.contentType!=null&&(m["content-type"]=g.contentType),g.encoding==="form"?m.style="form":g.encoding==="json"?m.style="json":g.exploded&&(m.style="exploded"),O=m}return[g.key,O]}}));return{schemaIdsToExclude:i.name==null?[]:[i.name],value:{name:n??i.name??a,"path-parameters":u,"query-parameters":c,headers:s,body:{properties:b},"content-type":Uq.MULTIPART_FORM_DATA,...i.description?{docs:i.description}:{}}}}else Ao(i)}}function dCE({context:e,request:t}){if(!e.inlinePathParameters)return!1;if(t==null)return!0;switch(t.type){case"octetStream":return!1;case"multipart":return!0;case"json":return!0;case"formUrlEncoded":return!0;default:Ao(t)}}function pCE({location:e,namespaceOverride:t}){return t!=null?{...e,file:X3(Ey.of(t),e.file)}:e}function _CE(e){let t=e.namespace,r=e.tags.filter(d=>d!==t)[0],i=e.operationId;if(i==null)return r!=null?{file:Ey.of(`${F_(r)}.yml`),endpointId:e.summary!=null?F_(e.summary):F_(`${e.method}_${e.path.split("/").join("_")}`)}:e.summary!=null?{file:Ey.of(CS),endpointId:F_(e.summary)}:{file:Ey.of(CS),endpointId:F_(`${e.method}_${e.path.split("/").join("_")}`)};if(r==null)return{file:Ey.of(CS),endpointId:i};let n=C5a(r),a=C5a(i);if(Y8(n,a))return{file:Ey.of("__package__.yml"),endpointId:r};let u=vCE({operationId:i,tag:r,path:e.path,method:e.method});if(u!=null)return u;let c=[];for(let d=0;d<n.length;++d){let s=n[d];if(s!=null&&s===a[d])c.push(s);else{let o=F_(r);return{file:Ey.of(`${o}.yml`),endpointId:i,tag:r}}}if(c.length>=a.length)throw new Error(`Cannot get file for endpoint ${JSON.stringify(e)}`);return{file:Ey.of(F_(c.join("_"))+".yml"),endpointId:F_(a.slice(c.length).join("_")),tag:r}}function B5a(e){let t=e.tags[0];if(e.sdkName!=null){let r=q1c({sdkName:e.sdkName,namespaceOverride:e.namespace}),i=`${r}.yml`,n=r.toLowerCase()===t?.toLowerCase().replaceAll(" ","");return{file:Ey.of(i),endpointId:e.sdkName.methodName,tag:n?t:void 0}}return pCE({namespaceOverride:e.namespace,location:_CE(e)})}function C5a(e){let t;return/^[a-z]+(?:[A-Z][a-z]+)*$/.test(e)?t=e.split(/(?=[A-Z])/):t=e.split(/[^a-zA-Z0-9]+/),t=t.map(r=>r.toLowerCase()),t=MNe(t),t}var hCE=new RegExp("[^a-zA-Z0-9{}]+"),yCE=new RegExp("[{}]","g");function vCE({operationId:e,tag:t,path:r,method:i}){let a=`${r.split(hCE).join("_").replaceAll(yCE,"_")}_${i.toLowerCase()}`;if(e.endsWith(a))return{file:Ey.of(F_(t)+".yml"),endpointId:F_(e.slice(0,-1*a.length)),tag:t}}function ij_(e){let t=new Set,{endpoints:r,tags:i}=e.ir,n=[];for(let a of r){let{endpointId:u,file:c,tag:d}=B5a(a),s=c.split(".")[0];s!=null&&t.add(s);let o;if(a.sdkName!=null){let g=e.ir.groups;for(let O of a.sdkName.groupName){let m=typeof O=="string"?O:O.name,P=g[m];if(P==null)break;if(P.summary!=null||P.description!=null){o=g[m];break}}}let l=d==null?void 0:i.tagsById[d];e.setInState(w5.Endpoint),e.setEndpointMethod(a.method);let b=tj_({context:e,endpoint:a,declarationFile:c});e.unsetEndpointMethod(),e.unsetInState(w5.Endpoint),n=[...n,...b.schemaIdsToExclude],e.builder.addEndpoint(c,{name:u,schema:b.value,source:a.source!=null?$mi(a.source):void 0}),(l?.id!=null||l?.description!=null)&&e.builder.setServiceInfo(c,{"display-name":o?.summary??l?.id,docs:o?.description??l?.description??void 0})}return{schemaIdsToExclude:n,sdkGroups:t}}function nj_(e){for(let[t,r]of Object.entries(e.ir.variables)){let i=r.groupName!=null?Gmi(r.groupName):void 0,n=iO({schema:wv.primitive(r),context:e,fileContainingReference:Ey.of(CS),namespace:i,declarationDepth:0});e.builder.addVariable({name:t,schema:{type:hq(n),docs:r.description??void 0}})}}function aj_(e){for(let t of e.ir.webhooks){let r=OCE({webhook:t,context:e});if(r==null)continue;let i=fau(t.sdkName,t.namespace),n={};for(let u of t.headers)n[u.name]=yor({header:u,context:e,fileContainingReference:r.file,namespace:i});let a={audiences:t.audiences,method:t.method,"display-name":t.summary??void 0,headers:n,payload:iO({schema:t.payload,context:e,fileContainingReference:r.file,namespace:i,declarationDepth:0}),examples:t.examples!=null?t.examples.map(u=>({docs:u.description,name:u.name,payload:LK(u.payload)})):void 0};e.builder.addWebhook(r.file,{name:r.endpointId,schema:a}),t.description!=null&&(a.docs=t.description)}}function bCE({location:e,namespaceOverride:t}){if(e!=null)return t!=null?{...e,file:X3(Ey.of(t),e.file)}:e}function gCE({webhook:e,context:t}){let r=e.tags[0],i=e.operationId;if(r==null)return{file:Ey.of(CS),endpointId:i};let n=C5a(r),a=C5a(i);if(Y8(n,a))return{file:Ey.of("__package__.yml"),endpointId:r};let u=[];for(let c=0;c<n.length;++c){let d=n[c];if(d!=null&&d===a[c])u.push(d);else{let s=F_(r);return{file:Ey.of(`${s}.yml`),endpointId:i,tag:r}}}if(u.length>=a.length){t.logger.warn(`Skipping webhook ${e.operationId} because couldn't compute file location`);return}return{file:Ey.of(F_(u.join("_"))+".yml"),endpointId:F_(a.slice(u.length).join("_")),tag:r}}function OCE({webhook:e,context:t}){return e.sdkName!=null?{file:qP_({sdkName:e.sdkName,namespaceOverride:e.namespace}),endpointId:e.sdkName.methodName}:bCE({namespaceOverride:e.namespace,location:gCE({webhook:e,context:t})})}var mCE=Ey.of(CS);function uj_(e){switch(e.type){case"object":case"primitive":case"enum":case"array":case"map":case"reference":case"literal":case"optional":case"nullable":return oj_({namespace:e.namespace,groupName:e.groupName});case"oneOf":return oj_({namespace:e.value.namespace,groupName:e.value.groupName});case"unknown":return mCE;default:Ao(e)}}function oj_({namespace:e,groupName:t}){return e!=null&&t!=null?CNi([{type:"namespace",name:e},...t]):e!=null?CNi([{type:"namespace",name:e}]):CNi(t)}var G1c="external",rj_=Ey.of(CS);function sj_({schemas:e,schemaIdsToExclude:t,namespace:r,context:i}){for(let[n,a]of Object.entries(e)){if(t.includes(n))continue;let u=uj_(a),c=zP_({schema:a,context:i,declarationFile:u,namespace:r,declarationDepth:0});if(hzi(c.schema)){let d=hq(c.schema);if(d===(c.name??n)||d===`optional<${c.name??n}>`||d===`optional<nullable<${c.name??n}>>`)continue}i.builder.addType(u,{name:c.name??n,schema:c.schema})}}function cj_(e){e.ir.apiVersion!=null&&e.builder.setApiVersion(e.ir.apiVersion),$P_(e),GP_(e),QP_(e),LP_(e),nj_(e),e.ir.basePath!=null&&e.builder.setBasePath(e.ir.basePath),e.ir.hasEndpointsMarkedInternal&&e.builder.addAudience(G1c);let t=ij_(e),r=t.sdkGroups;e.setInState(w5.Webhook),aj_(e),e.unsetInState(w5.Webhook),e.setInState(w5.Channel);for(let n of Object.values(e.ir.channels)){let a=CNi(n.groupName);HP_({channel:n,context:e,declarationFile:a})}e.unsetInState(w5.Channel);let i=PCE({context:e,schemaIdsToExcludeFromServices:t.schemaIdsToExclude});sj_({schemas:e.ir.groupedSchemas.rootSchemas,schemaIdsToExclude:i,namespace:void 0,context:e});for(let[n,a]of Object.entries(e.ir.groupedSchemas.namespacedSchemas))sj_({schemas:a,schemaIdsToExclude:i,namespace:n,context:e});return e.ir.tags.orderedTagIds!=null&&e.ir.tags.orderedTagIds.length>0&&e.ir.tags.orderedTagIds.every(a=>r.has(a))&&e.builder.addNavigation({navigation:e.ir.tags.orderedTagIds}),e.builder.build()}function PCE({context:e,schemaIdsToExcludeFromServices:t}){let r=e.getReferencedSchemaIds();if(r==null)return t;let i=new Set([...Object.keys(e.ir.groupedSchemas.rootSchemas),...Object.values(e.ir.groupedSchemas.namespacedSchemas).flatMap(a=>Object.keys(a))]),n=new Set(t);for(let a of i)r.includes(a)||n.add(a);return Array.from(n)}var I5a=class{context;constructor(t){this.context=t}};var pau=class e{files={};directories={};getAllFiles(){let t={},r=(i,n)=>{for(let[u,c]of Object.entries(i.files)){let d=n!=null?Ey.of(`${n}${Q$t}${u}`):Ey.of(u);t[d]=c}let a=Object.keys(i.directories).sort();for(let u of a){let c=n!=null?`${n}${Q$t}${u}`:u,d=i.directories[u];r(d,c)}};return r(this),t}getOrCreateFile(t){return this.getOrCreateFileRecursive(t.split(Q$t))}getOrCreateFileRecursive(t){if(t.length===1)return this.files[Ey.of(t[0])]??={};let[r,...i]=t;if(r==null)throw new Error(`Internal error; cannot add file with path: ${t}`);return this.directories[r]||(this.directories[r]=new e),this.directories[r].getOrCreateFileRecursive(i)}};var Hnn=class{enableUniqueErrorsPerEndpoint;root;rootApiFile;packageMarkerFile={};basePath=void 0;constructor(t){this.enableUniqueErrorsPerEndpoint=t,this.root=new pau,this.rootApiFile={name:"api","error-discrimination":{strategy:"status-code"}}}setDisplayName({displayName:t}){this.rootApiFile["display-name"]=t}addNavigation({navigation:t}){this.packageMarkerFile.navigation=t}setServiceInfo(t,{auth:r,"base-path":i,"display-name":n,docs:a}){let u=this.getOrCreateFile(t);u.service==null&&(u.service={auth:!1,"base-path":"",endpoints:{}}),r!=null&&(u.service.auth=r),i!=null&&(u.service["base-path"]=i),n!=null&&(u.service["display-name"]=n),a!=null&&(u.docs=a)}addAudience(t){this.rootApiFile.audiences==null&&(this.rootApiFile.audiences=[]),this.rootApiFile.audiences.push(t)}setAuth(t){this.rootApiFile.auth=t}addAuthScheme({name:t,schema:r}){this.rootApiFile["auth-schemes"]==null&&(this.rootApiFile["auth-schemes"]={}),this.rootApiFile["auth-schemes"][t]==null&&(this.rootApiFile["auth-schemes"][t]=r)}setDefaultEnvironment(t){this.rootApiFile["default-environment"]=t}setDefaultUrl(t){this.rootApiFile["default-url"]=t}setBasePath(t){this.basePath=t}setApiVersion(t){this.rootApiFile.version=t}getEnvironmentType(){let t=Object.entries(this.rootApiFile.environments??{})[0];if(t!=null)return jir(t[1],{singleBaseUrl:()=>"single",multipleBaseUrls:()=>"multi"})}addEnvironment({name:t,schema:r}){this.rootApiFile.environments==null&&(this.rootApiFile.environments={}),this.rootApiFile.environments[t]=r}getGlobalHeaderNames(){let t=Object.keys(this.rootApiFile.headers??{});if(this.rootApiFile["auth-schemes"]!=null)for(let i of Object.values(this.rootApiFile["auth-schemes"]))lj_(i)&&t.push(i.header);let r=this.getVersionHeader();return r!=null&&t.push(r),new Set(t)}getAuthHeaderName(){if(this.rootApiFile["auth-schemes"]!=null){for(let t of Object.values(this.rootApiFile["auth-schemes"]))if(lj_(t))return t.header;return"Authorization"}}addGlobalHeader({name:t,schema:r}){let i=this.getVersionHeader();i!=null&&i===t||(this.rootApiFile.headers==null&&(this.rootApiFile.headers={}),this.rootApiFile.headers[t]=r)}getGlobalHeaders(){return this.rootApiFile.headers??{}}addIdempotencyHeader({name:t,schema:r}){this.rootApiFile["idempotency-headers"]==null&&(this.rootApiFile["idempotency-headers"]={}),this.rootApiFile["idempotency-headers"][t]=r}addVariable({name:t,schema:r}){this.rootApiFile.variables==null&&(this.rootApiFile.variables={}),this.rootApiFile.variables[t]=r}addImport({file:t,fileToImport:r,alias:i}){if(t===r)return;let n=i??F_((UNe(r)+"/"+aki(r,{stripExtension:!0})).replaceAll("__package__","root"));if(t===Ey.of(lF))return this.rootApiFile.imports==null&&(this.rootApiFile.imports={}),this.rootApiFile.imports[n]=TBo(UNe(j5n.of(`/${t}`)),j5n.of(`/${r}`)),n;let a=this.getOrCreateFile(t);return a.imports==null&&(a.imports={}),a.imports[n]=TBo(UNe(j5n.of(`/${t}`)),j5n.of(`/${r}`)),n}addType(t,{name:r,schema:i}){if(t===Ey.of(lF))return;let n=this.getOrCreateFile(t);n.types==null&&(n.types={}),n.types[r]=i}addTypeExample(t,r,i){let n=this.getOrCreateFile(t);n.types==null&&(n.types={});let a=n.types[r];a!=null&&(typeof a=="string"?n.types[r]={type:a,examples:[i]}:(a.examples==null&&(a.examples=[]),a.examples.push(i)))}addError(t,{name:r,schema:i}){let n=this.getOrCreateFile(t);n.errors==null&&(n.errors={}),n.errors[r]==null?n.errors[r]=i:n.errors[r]?.type!==i.type&&(n.errors[r]={"status-code":i["status-code"],type:"unknown"})}addErrorExample(t,{name:r,example:i}){let n=this.getOrCreateFile(t);if(n.errors==null)return;let a=n.errors[r];if(a==null)return;a.examples==null&&(a.examples=[]),(a.examples.some(c=>Y8(c,i))??!1)||a.examples?.push(i)}addEndpoint(t,{name:r,schema:i,source:n}){let a=this.getOrCreateFile(t);a.service==null&&(a.service={auth:!1,"base-path":"",endpoints:{}}),n!=null&&(a.service.source=n),a.service.endpoints[r]=i}addWebhook(t,{name:r,schema:i}){let n=this.getOrCreateFile(t);n.webhooks==null&&(n.webhooks={}),n.webhooks[r]=i}addChannel(t,{channel:r}){let i=this.getOrCreateFile(t);i.channel=r;let n=this.basePath;n!=null&&(i.channel.path=X3(n,r.path))}addChannelExample(t,{example:r}){let i=this.getOrCreateFile(t);i.channel==null&&(i.channel={path:"",auth:!1}),i.channel.messages==null&&(i.channel.messages={}),i.channel.examples==null&&(i.channel.examples=[]),i.channel.examples.push(r)}addChannelMessage(t,{messageId:r,message:i}){let n=this.getOrCreateFile(t);n.channel==null&&(n.channel={path:"",auth:!1}),n.channel.messages==null&&(n.channel.messages={}),n.channel.messages[r]=i}build(){let t=this.root.getAllFiles(),r=this.basePath;if(r!=null){this.packageMarkerFile.service!=null&&(this.packageMarkerFile.service={...this.packageMarkerFile.service,endpoints:Object.fromEntries(Object.entries(this.packageMarkerFile.service.endpoints).map(([n,a])=>[n,{...a,path:X3(r,a.path)}]))});for(let n of Object.values(t))n.service!=null&&(n.service={...n.service,endpoints:Object.fromEntries(Object.entries(n.service.endpoints).map(([a,u])=>[a,{...u,path:X3(r,u.path)}]))})}return{rootApiFile:this.rootApiFile,packageMarkerFile:this.packageMarkerFile,definitionFiles:t}}getOrCreateFile(t){return t===CS?this.packageMarkerFile:this.root.getOrCreateFile(t)}getVersionHeader(){if(this.rootApiFile.version!=null)return typeof this.rootApiFile.version.header=="string"?this.rootApiFile.version.header:this.rootApiFile.version.header.value}};function lj_(e){return e?.header!=null}var _au=class{logger;taskContext;ir;builder;environmentOverrides;authOverrides;globalHeaderOverrides;detectGlobalHeaders;objectQueryParameters;respectReadonlySchemas;respectNullableSchemas;onlyIncludeReferencedSchemas;inlinePathParameters;useBytesForBinaryResponse;respectForwardCompatibleEnums;enableUniqueErrorsPerEndpoint;defaultServerName=void 0;unknownSchema=new Set;referencedSchemaIds;endpointMethod;state=new Set;constructor({taskContext:t,ir:r,options:i,environmentOverrides:n,globalHeaderOverrides:a,authOverrides:u}){this.logger=t.logger,this.taskContext=t,this.ir=r,this.environmentOverrides=n,this.authOverrides=u,this.globalHeaderOverrides=a,this.detectGlobalHeaders=i?.detectGlobalHeaders??!0,this.objectQueryParameters=i?.objectQueryParameters??!1,this.respectReadonlySchemas=i?.respectReadonlySchemas??!1,this.respectNullableSchemas=i?.respectNullableSchemas??!1,this.onlyIncludeReferencedSchemas=i?.onlyIncludeReferencedSchemas??!1,this.inlinePathParameters=i?.inlinePathParameters??!1,this.useBytesForBinaryResponse=i?.useBytesForBinaryResponse??!1,this.respectForwardCompatibleEnums=i?.respectForwardCompatibleEnums??!1,this.referencedSchemaIds=i?.onlyIncludeReferencedSchemas?new Set:void 0,this.enableUniqueErrorsPerEndpoint=i?.enableUniqueErrorsPerEndpoint??!1,this.builder=new Hnn(this.enableUniqueErrorsPerEndpoint),r.title!=null&&this.builder.setDisplayName({displayName:r.title});let c={};if(!this.enableUniqueErrorsPerEndpoint)for(let d of r.endpoints)for(let[s,o]of Object.entries(d.errors)){let l=parseInt(s),b=c[l];b==null&&o.schema!=null?c[l]=o.schema:b!=null&&o.schema!=null&&Fue(b,o.schema)||this.unknownSchema.add(l)}}getReferencedSchemaIds(){if(this.referencedSchemaIds!=null)return Array.from(this.referencedSchemaIds)}getSchema(t,r){return r==null?this.ir.groupedSchemas.rootSchemas[t]:this.ir.groupedSchemas.namespacedSchemas[r]?.[t]}getDefaultServerName(){return this.defaultServerName}setDefaultServerName(t){this.defaultServerName=t}isErrorUnknownSchema(t){return this.unknownSchema.has(t)}getEndpointMethod(){return this.endpointMethod}setEndpointMethod(t){this.endpointMethod=t}unsetEndpointMethod(){this.endpointMethod=void 0}isInState(t){return this.state.has(t)}setInState(t){this.state.add(t)}unsetInState(t){this.state.delete(t)}shouldMarkSchemaAsReferenced(){return this.onlyIncludeReferencedSchemas&&this.isInAnyState(w5.Channel,w5.Endpoint,w5.Webhook)}markSchemaAsReferenced(t,r){switch(t.type){case"primitive":return;case"object":this.markObjectSchemaAsReferenced(t,r);return;case"array":this.markSchemaAsReferenced(t.value,r);return;case"map":this.markSchemaAsReferenced(t.value,r);return;case"optional":this.markSchemaAsReferenced(t.value,r);return;case"reference":this.markSchemaIdAsReferenced(t.schema,r);return;case"oneOf":this.markOneofSchemaAsReferenced(t.value,r);return;case"nullable":this.markSchemaAsReferenced(t.value,r);return;case"enum":return;case"literal":return;case"unknown":return;default:Ao(t)}}markObjectSchemaAsReferenced(t,r){for(let i of t.allOf)this.markSchemaIdAsReferenced(i.schema,r);for(let i of t.properties)this.markSchemaAsReferenced(i.schema,r)}markOneofSchemaAsReferenced(t,r){switch(t.type){case"discriminated":for(let i of Object.values(t.schemas))this.markSchemaAsReferenced(i,r);return;case"undiscriminated":for(let i of t.schemas)this.markSchemaAsReferenced(i,r);return;default:Ao(t)}}markSchemaIdAsReferenced(t,r){if(this.referencedSchemaIds!=null&&!this.referencedSchemaIds.has(t)){this.referencedSchemaIds.add(t);let i=this.getSchema(t,r);i!=null&&this.markSchemaAsReferenced(i,r)}}isInAnyState(...t){return t.some(r=>this.isInState(r))}};function Q1c(e){let t=new _au(e);return cj_(t)}var hau=class{args;constructor(t){this.args=t}convert({context:t,ir:r,settings:i,absoluteFilePath:n}){let a=Q1c({taskContext:t,ir:r,options:w5a({overrides:{...i,respectReadonlySchemas:i?.respectReadonlySchemas??this.args.respectReadonlySchemas,respectNullableSchemas:i?.respectNullableSchemas??this.args.respectNullableSchemas,onlyIncludeReferencedSchemas:i?.onlyIncludeReferencedSchemas??this.args.onlyIncludeReferencedSchemas,inlinePathParameters:i?.inlinePathParameters??this.args.inlinePathParameters,objectQueryParameters:i?.objectQueryParameters??this.args.objectQueryParameters,useBytesForBinaryResponse:i?.useBytesForBinaryResponse??this.args.useBytesForBinaryResponse,respectForwardCompatibleEnums:i?.respectForwardCompatibleEnums??this.args.respectForwardCompatibleEnums}}),authOverrides:i?.auth!=null?{auth:i.auth}:this.args.generatorsConfiguration?.api?.auth!=null?{...this.args.generatorsConfiguration.api}:void 0,environmentOverrides:this.args.generatorsConfiguration?.api?.environments!=null?{...this.args.generatorsConfiguration?.api}:void 0,globalHeaderOverrides:this.args.generatorsConfiguration?.api?.headers!=null?{...this.args.generatorsConfiguration?.api}:void 0});return{absoluteFilePath:n??this.args.absoluteFilePath,rootApiFile:{defaultUrl:a.rootApiFile["default-url"],contents:a.rootApiFile,rawContents:Rd.dump(a.rootApiFile)},namedDefinitionFiles:{...Dd(a.definitionFiles,u=>({absoluteFilepath:n??this.args.absoluteFilePath,rawContents:Rd.dump(u),contents:u})),[Ey.of(CS)]:{absoluteFilepath:n??this.args.absoluteFilePath,rawContents:Rd.dump(a.packageMarkerFile),contents:a.packageMarkerFile}},packageMarkers:{},importedDefinitions:{}}}};var z5a=class extends LQt{inlinePathParameters;objectQueryParameters;onlyIncludeReferencedSchemas;respectReadonlySchemas;respectNullableSchemas;exampleGeneration;useBytesForBinaryResponse;respectForwardCompatibleEnums;inlineAllOfSchemas;converter;constructor(t){super(t),this.inlinePathParameters=t.inlinePathParameters,this.objectQueryParameters=t.objectQueryParameters,this.onlyIncludeReferencedSchemas=t.onlyIncludeReferencedSchemas,this.respectReadonlySchemas=t.respectReadonlySchemas,this.respectNullableSchemas=t.respectNullableSchemas,this.exampleGeneration=t.exampleGeneration,this.useBytesForBinaryResponse=t.useBytesForBinaryResponse,this.respectForwardCompatibleEnums=t.respectForwardCompatibleEnums,this.inlineAllOfSchemas=t.inlineAllOfSchemas,this.converter=new hau(t)}async getDefinition({context:t,absoluteFilePath:r,relativePathToDependency:i},n){let a=await this.getOpenAPIIr({context:t,relativePathToDependency:i},n);return this.converter.convert({context:t,ir:a,settings:n,absoluteFilePath:r})}async toFernWorkspace({context:t},r){let i=await this.getDefinition({context:t},r);return new Tqe({absoluteFilePath:this.absoluteFilePath,workspaceName:this.workspaceName,generatorsConfiguration:this.generatorsConfiguration,dependenciesConfiguration:{dependencies:{}},definition:i,cliVersion:this.cliVersion})}};var M$={BEARER_FORMAT:"x-bearer-format",ENUM_VAR_NAMES:"x-enum-varnames",INTERNAL:"x-internal",EXAMPLES:"x-examples",TAGS:"x-tags",REDOCLY_CODE_SAMPLES_KEBAB:"x-code-samples",REDOCLY_CODE_SAMPLES_CAMEL:"x-codeSamples"};var gKn={of(e){return e}};var fj_={properties:{"stream-condition":{type:"string"},response:"Schema","response-stream":"Schema"},required:["stream-condition","response","response-stream"],extensionsPrefix:"x-"},J1c={id:"",typeExtension:{oas3:e=>({...e,XFernStreaming:fj_,Operation:{...e.Operation,properties:{...e.Operation?.properties,"x-fern-streaming":"XFernStreaming"}}})}},ad={SOURCE:gKn.of("source"),SDK_NAMESPACE:gKn.of("x-fern-sdk-namespace"),SDK_METHOD_NAME:gKn.of("x-fern-sdk-method-name"),SDK_GROUP_NAME:gKn.of("x-fern-sdk-group-name"),REQUEST_NAME_V1:"x-request-name",REQUEST_NAME_V2:"x-fern-request-name",TYPE_NAME:"x-fern-type-name",BOOLEAN_LITERAL:"x-fern-boolean-literal",SERVER_NAME_V1:"x-name",SERVER_NAME_V2:"x-fern-server-name",BASE_PATH:"x-fern-base-path",GROUPS:gKn.of("x-fern-groups"),OPENAPI_OVERIDES_FILEPATH:"x-fern-overrides-filepath",TYPE_DEFINITION:"x-fern-type",STREAMING:"x-fern-streaming",PAGINATION:"x-fern-pagination",WEBHOOK:"x-fern-webhook",ASYNC_CONFIG:"x-fern-async-config",SDK_VARIABLES:"x-fern-sdk-variables",SDK_VARIABLE:"x-fern-sdk-variable",PARAMETER_NAME:"x-fern-parameter-name",BASIC_AUTH_USERNAME_VARIABLE_NAME:"x-fern-username-variable-name",BASIC_AUTH_PASSWORD_VARIABLE_NAME:"x-fern-password-variable-name",BEARER_TOKEN_VARIABLE_NAME:"x-fern-token-variable-name",HEADER_VARIABLE_NAME:"x-fern-header-variable-name",FERN_ENUM:"x-fern-enum",AUDIENCES:"x-fern-audiences",IGNORE:"x-fern-ignore",AVAILABILITY:"x-fern-availability",RESPONSE_PROPERTY:"x-fern-sdk-return-value",RESOLUTIONS:"x-fern-resolutions",EXAMPLES:"x-fern-examples",FERN_BEARER_TOKEN:"x-fern-bearer",FERN_HEADER_AUTH:"x-fern-header",FERN_BASIC_AUTH:"x-fern-basic",FERN_GLOBAL_HEADERS:"x-fern-global-headers",FERN_IDEMPOTENCY_HEADERS:"x-fern-idempotency-headers",IDEMPOTENT:"x-fern-idempotent",FERN_PROPERTY_NAME:"x-fern-property-name",IS_UNDISCRIMINATED:"x-fern-undiscriminated",FERN_VERSION:"x-fern-version",ENCODING:"x-fern-encoding",TRANSPORT:"x-fern-transport",IS_DISCRIMINATED:"x-fern-discriminated"};var O7={disableExamples:!1,discriminatedUnionV2:!1,useTitlesAsName:!0,audiences:void 0,optionalAdditionalProperties:!0,coerceEnumsToLiterals:!0,respectReadonlySchemas:!1,respectNullableSchemas:!1,onlyIncludeReferencedSchemas:!1,inlinePathParameters:!1,preserveSchemaIds:!1,objectQueryParameters:!1,shouldUseUndiscriminatedUnionsWithLiterals:!1,shouldUseIdiomaticRequestNames:!1,filter:void 0,asyncApiNaming:"v1",exampleGeneration:void 0,defaultFormParameterEncoding:"json",useBytesForBinaryResponse:!1,respectForwardCompatibleEnums:!1,additionalPropertiesDefaultsTo:!1,typeDatesAsStrings:!0,preserveSingleSchemaOneOf:!1,inlineAllOfSchemas:!1};function HQt({options:e,overrides:t}){return{disableExamples:t?.disableExamples??O7.disableExamples,discriminatedUnionV2:t?.discriminatedUnionV2??e?.discriminatedUnionV2??O7.discriminatedUnionV2,useTitlesAsName:t?.useTitlesAsName??e?.useTitlesAsName??O7.useTitlesAsName,audiences:t?.audiences??e?.audiences??O7.audiences,optionalAdditionalProperties:t?.optionalAdditionalProperties??e?.optionalAdditionalProperties??O7.optionalAdditionalProperties,coerceEnumsToLiterals:t?.coerceEnumsToLiterals??e?.coerceEnumsToLiterals??O7.coerceEnumsToLiterals,respectReadonlySchemas:t?.respectReadonlySchemas??e?.respectReadonlySchemas??O7.respectReadonlySchemas,respectNullableSchemas:t?.respectNullableSchemas??e?.respectNullableSchemas??O7.respectNullableSchemas,onlyIncludeReferencedSchemas:t?.onlyIncludeReferencedSchemas??e?.onlyIncludeReferencedSchemas??O7.onlyIncludeReferencedSchemas,inlinePathParameters:t?.inlinePathParameters??e?.inlinePathParameters??O7.inlinePathParameters,preserveSchemaIds:t?.preserveSchemaIds??O7.preserveSchemaIds,shouldUseUndiscriminatedUnionsWithLiterals:t?.shouldUseUndiscriminatedUnionsWithLiterals??e?.shouldUseUndiscriminatedUnionsWithLiterals??O7.shouldUseUndiscriminatedUnionsWithLiterals,shouldUseIdiomaticRequestNames:t?.shouldUseIdiomaticRequestNames??e?.shouldUseIdiomaticRequestNames??O7.shouldUseIdiomaticRequestNames,objectQueryParameters:t?.objectQueryParameters??e?.objectQueryParameters??O7.objectQueryParameters,filter:t?.filter??e?.filter??O7.filter,asyncApiNaming:t?.asyncApiNaming??e?.asyncApiNaming??O7.asyncApiNaming,useBytesForBinaryResponse:t?.useBytesForBinaryResponse??e?.useBytesForBinaryResponse??O7.useBytesForBinaryResponse,exampleGeneration:t?.exampleGeneration??e?.exampleGeneration??void 0,defaultFormParameterEncoding:t?.defaultFormParameterEncoding??e?.defaultFormParameterEncoding??void 0,respectForwardCompatibleEnums:t?.respectForwardCompatibleEnums??e?.respectForwardCompatibleEnums??O7.respectForwardCompatibleEnums,additionalPropertiesDefaultsTo:t?.additionalPropertiesDefaultsTo??e?.additionalPropertiesDefaultsTo??O7.additionalPropertiesDefaultsTo,typeDatesAsStrings:t?.typeDatesAsStrings??e?.typeDatesAsStrings??O7.typeDatesAsStrings,preserveSingleSchemaOneOf:t?.preserveSingleSchemaOneOf??e?.preserveSingleSchemaOneOf??O7.preserveSingleSchemaOneOf,inlineAllOfSchemas:t?.inlineAllOfSchemas??e?.inlineAllOfSchemas??O7.inlineAllOfSchemas}}var dj_={naming:"v1"};function hf(e,t){let r=Array.isArray(t)?t:[t];for(let i of r){let n=e[i];if(n!=null)return n}}function x5a(e,t,r,i,n=[]){try{let a=hf(e,t);if(a!=null)return r.parse(a)}catch{let u=MNe(n).join(" -> ");i.error(`${u.length>0?`${u}: `:""}Failed to parse ${t}`)}}function $nn(e){let t=hf(e,"examples");if(t!=null){if(Array.isArray(t))return t;if(typeof t=="object"&&t!==null)return Object.values(t).map(r=>typeof r=="object"&&r!==null&&"value"in r?r.value:r)}return[]}function pj_({schema:e,logger:t}){return hf(e,ad.ENCODING)??void 0}function _j_(e){return hf(e,ad.FERN_ENUM)}function hj_({nameOverride:e,generatedName:t,title:r,schema:i,description:n,availability:a}){let u=hf(i,ad.SDK_NAMESPACE),c=hf(i,ad.SDK_GROUP_NAME),d=hf(i,ad.TYPE_DEFINITION);if(d!=null)return R5a({fernType:d,nameOverride:e,generatedName:t,title:r,description:n,availability:a,namespace:u,groupName:typeof c=="string"?[c]:c})}function R5a({fernType:e,nameOverride:t,generatedName:r,title:i,description:n,availability:a,namespace:u,groupName:c}){return SF({type:e,_default:void 0,validation:void 0,visitor:{primitive:d=>{switch(d.v1){case"BASE_64":return Nl.primitive({nameOverride:t,generatedName:r,title:i,description:n,availability:a,namespace:u,groupName:c,schema:bp.base64({example:void 0})});case"BOOLEAN":return Nl.primitive({nameOverride:t,generatedName:r,title:i,description:n,availability:a,namespace:u,groupName:c,schema:bp.boolean({default:void 0,example:void 0})});case"DATE":return Nl.primitive({nameOverride:t,generatedName:r,title:i,description:n,availability:a,namespace:u,groupName:c,schema:bp.date({example:void 0})});case"DATE_TIME":return Nl.primitive({nameOverride:t,generatedName:r,title:i,description:n,availability:a,namespace:u,groupName:c,schema:bp.datetime({example:void 0})});case"FLOAT":return Nl.primitive({nameOverride:t,generatedName:r,title:i,description:n,availability:a,namespace:u,groupName:c,schema:bp.float({example:void 0})});case"DOUBLE":return Nl.primitive({nameOverride:t,generatedName:r,title:i,description:n,availability:a,namespace:u,groupName:c,schema:bp.double({default:void 0,minimum:void 0,maximum:void 0,exclusiveMinimum:void 0,exclusiveMaximum:void 0,multipleOf:void 0,example:void 0})});case"UINT":return Nl.primitive({nameOverride:t,generatedName:r,title:i,description:n,availability:a,namespace:u,groupName:c,schema:bp.uint({default:void 0,example:void 0})});case"INTEGER":return Nl.primitive({nameOverride:t,generatedName:r,title:i,description:n,availability:a,namespace:u,groupName:c,schema:bp.int({default:void 0,minimum:void 0,maximum:void 0,exclusiveMinimum:void 0,exclusiveMaximum:void 0,multipleOf:void 0,example:void 0})});case"UINT_64":return Nl.primitive({nameOverride:t,generatedName:r,title:i,description:n,availability:a,namespace:u,groupName:c,schema:bp.uint64({default:void 0,example:void 0})});case"LONG":return Nl.primitive({nameOverride:t,generatedName:r,title:i,description:n,availability:a,namespace:u,groupName:c,schema:bp.int64({default:void 0,example:void 0})});case"STRING":case"UUID":case"BIG_INTEGER":return Nl.primitive({nameOverride:t,generatedName:r,title:i,description:n,availability:a,namespace:u,groupName:c,schema:bp.string({default:void 0,pattern:void 0,maxLength:void 0,minLength:void 0,example:void 0,format:void 0})});default:Ao(d.v1)}},unknown:()=>Nl.unknown({nameOverride:t,generatedName:r,title:i,example:void 0,description:n,availability:a,namespace:u,groupName:c}),map:({keyType:d,valueType:s})=>d?.type==="primitive"&&s!=null?Nl.map({nameOverride:t,generatedName:r,title:i,key:d,value:s,description:n,availability:a,namespace:u,groupName:c,encoding:void 0,example:void 0,inline:void 0}):void 0,list:d=>d!=null?Nl.array({nameOverride:t,generatedName:r,title:i,value:d,description:n,availability:a,namespace:u,groupName:c,example:void 0,inline:void 0}):void 0,optional:d=>d!=null?Nl.optional({nameOverride:t,generatedName:r,title:i,value:d,description:n,availability:a,namespace:u,groupName:c,inline:void 0}):void 0,nullable:d=>d!=null?Nl.nullable({nameOverride:t,generatedName:r,title:i,value:d,description:n,availability:a,namespace:u,groupName:c,inline:void 0}):void 0,set:d=>d!=null?Nl.array({nameOverride:t,generatedName:r,title:i,value:d,description:n,availability:a,namespace:u,groupName:c,example:void 0,inline:void 0}):void 0,literal:d=>Nl.literal({nameOverride:t,generatedName:r,title:i,value:d._visit({string:s=>mx.string(s),boolean:s=>mx.boolean(s),_other:()=>{throw new Error("Unexpected literal type")}}),description:n,availability:a,namespace:u,groupName:c}),named:d=>Nl.reference({schema:d,nameOverride:t,generatedName:r,title:i,description:n,availability:a,namespace:u,groupName:c,source:RK.openapi({file:"<memory>"})})}})}function yj_(e){let t=hf(e,ad.SOURCE);if(t!=null)return t.endsWith(".proto")?RK.protobuf({file:t}):RK.openapi({file:t})}function Gnn(e){if(e!=null&&typeof e=="boolean")return e}function tp(e){return e.$ref!=null}function vj_({nameOverride:e,generatedName:t,title:r,breadcrumbs:i,additionalProperties:n,description:a,availability:u,wrapAsNullable:c,context:d,namespace:s,groupName:o,example:l,encoding:b,source:g}){return n===void 0&&(n=d.options.additionalPropertiesDefaultsTo),typeof n=="boolean"||OKn(n,d.options)?yau({nameOverride:e,generatedName:t,title:r,wrapAsNullable:c,description:a,availability:u,keySchema:{nameOverride:void 0,generatedName:`${t}Key`,title:void 0,description:void 0,availability:void 0,schema:bp.string({default:void 0,pattern:void 0,format:void 0,minLength:void 0,maxLength:void 0,example:void 0}),namespace:void 0,groupName:void 0},valueSchema:Nl.unknown({nameOverride:void 0,generatedName:`${t}Value`,title:void 0,description:void 0,availability:void 0,example:void 0,namespace:void 0,groupName:void 0}),namespace:s,groupName:o,example:l,encoding:b}):yau({nameOverride:e,generatedName:t,title:r,wrapAsNullable:c,description:a,availability:u,keySchema:{nameOverride:void 0,generatedName:`${t}Key`,title:void 0,description:void 0,availability:void 0,schema:bp.string({default:void 0,pattern:void 0,format:void 0,minLength:void 0,maxLength:void 0,example:void 0}),namespace:void 0,groupName:void 0},valueSchema:bj_(s0(n,d.options.optionalAdditionalProperties?c:!1,d,[...i,"Value"],g,s,void 0,void 0,void 0)),namespace:s,groupName:o,example:l,encoding:b})}function bj_(e){switch(e.type){case"array":case"enum":case"map":case"object":e.inline=!0;break;case"literal":case"primitive":case"reference":case"unknown":break;case"nullable":case"optional":e.inline=!0,e.value=bj_(e.value);break;case"oneOf":e.value.inline=!0;break;default:Ao(e)}return e}function yau({nameOverride:e,generatedName:t,title:r,keySchema:i,valueSchema:n,wrapAsNullable:a,description:u,availability:c,namespace:d,groupName:s,example:o,encoding:l}){return a?Nl.nullable({nameOverride:e,generatedName:t,title:r,value:Nl.map({nameOverride:e,generatedName:t,title:r,description:u,availability:i.availability,key:i,value:n,namespace:d,groupName:s,encoding:l,example:o,inline:void 0}),description:u,availability:c,namespace:d,groupName:s,inline:void 0}):Nl.map({nameOverride:e,generatedName:t,title:r,description:u,availability:c,key:i,value:n,namespace:d,groupName:s,encoding:l,example:o,inline:void 0})}function OKn(e,t){return e==null?t.additionalPropertiesDefaultsTo:typeof e=="boolean"?e:!tp(e)&&Object.keys(e).length===0}function gj_({nameOverride:e,generatedName:t,title:r,breadcrumbs:i,item:n,description:a,availability:u,wrapAsNullable:c,context:d,namespace:s,groupName:o,example:l,source:b}){let g=n==null?Nl.unknown({nameOverride:e,generatedName:t,title:r,description:void 0,availability:void 0,example:void 0,namespace:s,groupName:o}):s0(n,!1,d,[...i,"Item"],b,s);return jCE({nameOverride:e,generatedName:t,title:r,namespace:s,groupName:o,itemSchema:g,wrapAsNullable:c,description:a,availability:u,example:l})}function jCE({nameOverride:e,generatedName:t,title:r,itemSchema:i,wrapAsNullable:n,description:a,availability:u,namespace:c,groupName:d,example:s}){return n?Nl.nullable({nameOverride:e,generatedName:t,title:r,value:Nl.array({nameOverride:e,generatedName:t,title:r,value:i,description:a,availability:u,namespace:c,groupName:d,example:s,inline:void 0}),description:a,availability:u,namespace:c,groupName:d,inline:void 0}):Nl.array({nameOverride:e,generatedName:t,title:r,value:i,description:a,availability:u,namespace:c,groupName:d,example:s,inline:void 0})}function UK(e){switch(hf(e,ad.AVAILABILITY)){case"deprecated":return S$.Deprecated;case"beta":return S$.Beta;case"generally-available":return S$.GenerallyAvailable;default:break}if(!tp(e)&&e.deprecated)return S$.Deprecated}function K1c({nameOverride:e,generatedName:t,title:r,breadcrumbs:i,properties:n,description:a,availability:u,required:c,wrapAsNullable:d,discriminator:s,context:o,namespace:l,groupName:b,encoding:g,source:O}){let m=s.propertyName,P=Object.fromEntries(Object.entries(s.mapping??{}).map(([A,M])=>{let E=Jmi({$ref:M},!1,o,[M],g,O,l);return o.markReferencedByDiscriminatedUnion({$ref:M},m,1),[A,E]})),D=Object.entries(n).filter(([A])=>A!==m).map(([A,M])=>{let E=c!=null&&c.includes(A),T=s0(M,!E,o,[...i,A],O,l);return{key:A,schema:T}});return Oj_({nameOverride:e,generatedName:t,title:r,wrapAsNullable:d,properties:D,description:a,availability:u,discriminant:m,subtypes:P,namespace:l,groupName:b,source:O})}function Y1c({nameOverride:e,generatedName:t,title:r,breadcrumbs:i,properties:n,description:a,availability:u,required:c,wrapAsNullable:d,discriminant:s,variants:o,context:l,namespace:b,groupName:g,encoding:O,source:m}){let P=Object.fromEntries(Object.entries(o).map(([A,M])=>{if(tp(M)){let E=Jmi(M,!1,l,[M.$ref],O,m,b);return l.markReferencedByDiscriminatedUnion(M,s,1),[A,E]}else{let E=mKn(M,!1,l,[...i,A],O,m,b,new Set([s]));return[A,E]}})),D=Object.entries(n).filter(([A])=>A!==s).map(([A,M])=>{let E=c!=null&&c.includes(A),T=s0(M,!E,l,[...i,A],m,b);return{key:A,schema:T}});return Oj_({nameOverride:e,generatedName:t,title:r,wrapAsNullable:d,properties:D,description:a,availability:u,discriminant:s,subtypes:P,namespace:b,groupName:g,source:m})}function Oj_({nameOverride:e,generatedName:t,title:r,wrapAsNullable:i,properties:n,description:a,availability:u,discriminant:c,subtypes:d,namespace:s,groupName:o,source:l}){return i?Nl.nullable({nameOverride:e,generatedName:t,title:r,value:Nl.oneOf(xee.discriminated({description:a,availability:u,discriminantProperty:c,nameOverride:e,generatedName:t,title:r,schemas:d,commonProperties:n,namespace:s,groupName:o,encoding:void 0,source:l,inline:void 0})),namespace:s,groupName:o,description:a,availability:u,inline:void 0}):Nl.oneOf(xee.discriminated({description:a,availability:u,discriminantProperty:c,nameOverride:e,generatedName:t,title:r,schemas:d,commonProperties:n,namespace:s,groupName:o,encoding:void 0,source:l,inline:void 0}))}function mj_(e){if(e.proto!=null)return UJn.protobuf({typeName:e.proto.type})}function zNi({nameOverride:e,generatedName:t,title:r,fernEnum:i,enumVarNames:n,enumValues:a,_default:u,description:c,availability:d,wrapAsNullable:s,namespace:o,groupName:l,context:b,source:g,inline:O}){let m=SCE(n??[]),P=new Set(a),D=Array.from(P).map((M,E)=>{let T=i?.[M],z=m[E],$=hKn.test(M),I=T?.name??z,N=$?M:yKn(M);return I!=null&&!hKn.test(I)&&(b?.logger.warn(`Enum name override ${I} is not a valid name. Falling back on ${N}.`),I=void 0),{nameOverride:I,generatedName:N,value:M,description:T?.description,availability:d,casing:{snake:T?.casing?.snake??void 0,pascal:T?.casing?.pascal??void 0,screamingSnake:T?.casing?.screamingSnake??void 0,camel:T?.casing?.camel??void 0}}}),A=u!=null?D.find(M=>M.value===u):void 0;return wCE({wrapAsNullable:s,nameOverride:e,generatedName:t,title:r,values:D,_default:A,description:c,availability:d,namespace:o,groupName:l,source:g,inline:O})}function wCE({wrapAsNullable:e,nameOverride:t,generatedName:r,title:i,values:n,_default:a,description:u,availability:c,namespace:d,groupName:s,source:o,inline:l}){return e?Nl.nullable({nameOverride:t,generatedName:r,title:i,value:Nl.enum({nameOverride:t,generatedName:r,title:i,values:n,description:u,default:a,availability:c,example:void 0,namespace:d,groupName:s,source:o,inline:l}),description:u,availability:c,namespace:d,groupName:s,inline:l}):Nl.enum({nameOverride:t,generatedName:r,title:i,values:n,description:u,availability:c,default:a,example:void 0,namespace:d,groupName:s,source:o,inline:l})}function SCE(e){if(e.length<=1||e[0]==null)return e;let t=e[0],r=0;for(;t[r]!=null&&e.every(i=>i[r]===t[r]);)r++;return e.map(i=>i.substring(r))}function Pj_({nameOverride:e,generatedName:t,title:r,format:i,_default:n,minimum:a,maximum:u,exclusiveMinimum:c,exclusiveMaximum:d,multipleOf:s,description:o,availability:l,wrapAsNullable:b,example:g,namespace:O,groupName:m}){return i==="int64"?S5({nameOverride:e,generatedName:t,title:r,primitive:bp.int64({default:n,example:g}),wrapAsNullable:b,description:o,availability:l,namespace:O,groupName:m}):i==="uint32"?S5({nameOverride:e,generatedName:t,title:r,primitive:bp.uint({default:n,example:g}),wrapAsNullable:b,description:o,availability:l,namespace:O,groupName:m}):i==="uint64"?S5({nameOverride:e,generatedName:t,title:r,primitive:bp.uint64({default:n,example:g}),wrapAsNullable:b,description:o,availability:l,namespace:O,groupName:m}):S5({nameOverride:e,generatedName:t,title:r,primitive:bp.int({default:n,minimum:a,maximum:u,exclusiveMinimum:c,exclusiveMaximum:d,multipleOf:s,example:g}),wrapAsNullable:b,description:o,availability:l,namespace:O,groupName:m})}function jj_(e){return typeof e=="string"?mx.string(e):typeof e=="boolean"?mx.boolean(e):mx.string(`${e}`)}function wj_({nameOverride:e,generatedName:t,title:r,wrapAsNullable:i,value:n,description:a,availability:u,namespace:c,groupName:d}){return i?Nl.nullable({nameOverride:e,generatedName:t,title:r,value:Nl.literal({nameOverride:e,generatedName:t,title:r,value:jj_(n),description:a,availability:u,namespace:c,groupName:d}),description:a,availability:u,namespace:c,groupName:d,inline:void 0}):Nl.literal({nameOverride:e,generatedName:t,title:r,value:jj_(n),description:a,availability:u,namespace:c,groupName:d})}function X1c({nameOverride:e,generatedName:t,title:r,format:i,_default:n,minimum:a,maximum:u,exclusiveMinimum:c,exclusiveMaximum:d,multipleOf:s,description:o,availability:l,wrapAsNullable:b,example:g,namespace:O,groupName:m}){return i==null||i==="double"?S5({nameOverride:e,generatedName:t,title:r,primitive:bp.double({default:n,minimum:a,maximum:u,exclusiveMinimum:c,exclusiveMaximum:d,multipleOf:s,example:g}),wrapAsNullable:b,description:o,availability:l,namespace:O,groupName:m}):i==="float"?S5({nameOverride:e,generatedName:t,title:r,primitive:bp.float({example:g}),wrapAsNullable:b,description:o,availability:l,namespace:O,groupName:m}):i==="int32"?S5({nameOverride:e,generatedName:t,title:r,primitive:bp.int({default:n,minimum:a,maximum:u,exclusiveMinimum:c,exclusiveMaximum:d,multipleOf:s,example:g}),wrapAsNullable:b,description:o,availability:l,namespace:O,groupName:m}):i==="int64"?S5({nameOverride:e,generatedName:t,title:r,primitive:bp.int64({default:n,example:g}),wrapAsNullable:b,description:o,availability:l,namespace:O,groupName:m}):i==="uint32"?S5({nameOverride:e,generatedName:t,title:r,primitive:bp.uint({default:n,example:g}),wrapAsNullable:b,description:o,availability:l,namespace:O,groupName:m}):i==="uint64"?S5({nameOverride:e,generatedName:t,title:r,primitive:bp.uint64({default:n,example:g}),wrapAsNullable:b,description:o,availability:l,namespace:O,groupName:m}):i==="time-delta"?S5({nameOverride:e,generatedName:t,title:r,primitive:bp.float({example:g}),wrapAsNullable:b,description:o,availability:l,namespace:O,groupName:m}):S5({nameOverride:e,generatedName:t,title:r,primitive:bp.float({example:g}),wrapAsNullable:b,description:o,availability:l,namespace:O,groupName:m})}var DCE={isApplicable:e=>e[0]==="#"&&e[1]==="components"&&e[2]==="schemas",applyStrategy:e=>{let t=[e[3]??""];return{refUnderProcessing:e.slice(4),newBreadcrumbs:t}}},ECE={isApplicable:e=>e[0]==="#"&&e[1]==="components"&&e[2]==="responses",applyStrategy:e=>{let t=[e[3]??""];return e=e.slice(4),{refUnderProcessing:e.slice(4),newBreadcrumbs:t}}},MCE={isApplicable:e=>e[0]==="#"&&e[1]==="components"&&e[2]==="parameters",applyStrategy:e=>{let t=[e[3]??""];return e=e.slice(4),e[0]==="schema"&&(e=e.slice(1)),{refUnderProcessing:e,newBreadcrumbs:t}}},ACE={isApplicable:e=>e[0]==="properties",applyStrategy:e=>{let t=[e[1]??""];return{refUnderProcessing:e.slice(2),newBreadcrumbs:t}}},qCE={isApplicable:e=>e[0]==="items",applyStrategy:e=>({refUnderProcessing:e.slice(1),newBreadcrumbs:[]})},TCE={isApplicable:e=>e[0]==="allOf",applyStrategy:e=>({refUnderProcessing:e.slice(1),newBreadcrumbs:[]})},CCE={isApplicable:e=>e[0]==="anyOf",applyStrategy:e=>({refUnderProcessing:e.slice(1),newBreadcrumbs:[]})},BCE={isApplicable:e=>e[0]==="oneOf",applyStrategy:e=>({refUnderProcessing:e.slice(1),newBreadcrumbs:[]})};function vau(e){let t=e.split("/").map(a=>a.replace(/~1/g,"/")),r=[],i=[DCE,ECE,MCE,ACE,qCE,TCE,CCE,BCE],n;do{n=t;for(let a of i)if(a.isApplicable(t)){let{refUnderProcessing:u,newBreadcrumbs:c}=a.applyStrategy(t);t=u,r=[...r,...c]}}while(t.join("")!==n.join(""));return r}function D5(e,t){let i=e.map(n=>/^[^a-zA-Z0-9]+$/.test(n)?n:eI(F_(n))).join("");return/^\d/.test(i)?A5a(i)??i:i}function Z1c(e){let t=e.join("_");return F_(t)}function DA(e){switch(e.type){case"object":return wv.object({allOf:e.allOf,properties:e.properties.map(t=>zCE(t)),allOfPropertyConflicts:e.allOfPropertyConflicts,description:e.description,generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,namespace:e.namespace,groupName:e.groupName,additionalProperties:e.additionalProperties,availability:e.availability,source:e.source,inline:e.inline});case"array":return wv.array({description:e.description,availability:e.availability,value:DA(e.value),generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,namespace:e.namespace,groupName:e.groupName,inline:e.inline});case"enum":return wv.enum({description:e.description,availability:e.availability,generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,values:e.values,default:e.default,namespace:e.namespace,groupName:e.groupName,source:e.source,inline:e.inline});case"literal":return wv.literal({description:e.description,availability:e.availability,value:e.value,generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,namespace:e.namespace,groupName:e.groupName});case"nullable":return wv.nullable({generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,description:e.description,availability:e.availability,value:DA(e.value),namespace:e.namespace,groupName:e.groupName,inline:e.inline});case"optional":return wv.optional({generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,description:e.description,availability:e.availability,value:DA(e.value),namespace:e.namespace,groupName:e.groupName,inline:e.inline});case"primitive":return wv.primitive({description:e.description,availability:e.availability,schema:Sj_(e.schema),generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,namespace:e.namespace,groupName:e.groupName});case"map":return wv.map({description:e.description,availability:e.availability,key:wv.primitive({description:e.key.description,availability:e.key.availability,schema:Sj_(e.key.schema),generatedName:e.key.generatedName,title:e.key.title,nameOverride:e.key.nameOverride,namespace:e.namespace,groupName:e.groupName}),value:DA(e.value),generatedName:e.generatedName,title:e.title,nameOverride:e.nameOverride,namespace:e.namespace,groupName:e.groupName,encoding:e.encoding,inline:e.inline});case"reference":return wv.reference({description:e.description,availability:e.availability,generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,schema:e.schema,namespace:e.namespace,groupName:e.groupName,source:e.source});case"oneOf":return wv.oneOf(ICE(e.value));case"unknown":return wv.unknown({nameOverride:e.nameOverride,generatedName:e.generatedName});default:Ao(e)}}function ICE(e){switch(e.type){case"discriminated":return Hmi.discriminated({commonProperties:e.commonProperties.map(t=>({key:t.key,schema:DA(t.schema)})),description:e.description,availability:e.availability,discriminantProperty:e.discriminantProperty,generatedName:e.generatedName,title:e.title,nameOverride:e.nameOverride,schemas:Object.fromEntries(Object.entries(e.schemas).map(([t,r])=>[t,DA(r)])),namespace:e.namespace,groupName:e.groupName,encoding:e.encoding,source:e.source,inline:e.inline});case"undiscriminated":return Hmi.undiscriminated({description:e.description,availability:e.availability,generatedName:e.generatedName,title:e.title,nameOverride:e.nameOverride,schemas:e.schemas.map(t=>DA(t)),namespace:e.namespace,groupName:e.groupName,encoding:e.encoding,source:e.source,inline:e.inline});default:Ao(e)}}function Sj_(e){switch(e.type){case"string":return Ww.string(e);case"base64":return Ww.base64();case"boolean":return Ww.boolean(e);case"date":return Ww.date();case"datetime":return Ww.datetime();case"double":return Ww.double(e);case"float":return Ww.float();case"int":return Ww.int(e);case"int64":return Ww.int64(e);case"uint":return Ww.uint();case"uint64":return Ww.uint64();default:Ao(e)}}function zCE(e){return{conflict:e.conflict,generatedName:e.generatedName,key:e.key,schema:DA(e.schema),audiences:e.audiences,nameOverride:e.nameOverride,availability:e.availability,readonly:e.readonly,writeonly:e.writeonly}}function bau(e,t){return Fue(DA(e),DA(t))}function Dj_({nameOverride:e,generatedName:t,title:r,breadcrumbs:i,properties:n,description:a,required:u,wrapAsNullable:c,allOf:d,context:s,propertiesToExclude:o,namespace:l,groupName:b,fullExamples:g,additionalProperties:O,availability:m,source:P}){let D=[...u??[]],A={...n},M=[],E=[];for(let N of d)if(!s.options.inlineAllOfSchemas&&tp(N)){let U=s.resolveSchemaReference(N);if(U.discriminator!=null&&U.discriminator.mapping!=null)continue;if(U.oneOf!=null||U.anyOf!=null){let J=U.oneOf??U.anyOf;if(J!=null){for(let X of J){let oe=tp(X)?s.resolveSchemaReference(X):X,pe=s0(oe,!1,s.DUMMY,i,P,l);pe.type==="object"&&M.push(...pe.properties.map(de=>de.schema.type!=="optional"&&de.schema.type!=="nullable"?{...de,schema:Nl.optional({nameOverride:void 0,generatedName:"",title:void 0,value:de.schema,description:void 0,availability:de.availability,namespace:void 0,groupName:void 0,inline:void 0})}:de))}continue}}let Y=xNi(N);if(Y==null)continue;E.push({schemaId:Y,convertedSchema:k1c(N,[Y],P,s.options.preserveSchemaIds),properties:Ej_({schema:N,context:s,breadcrumbs:i,source:P,namespace:l})}),s.markSchemaAsReferencedByNonRequest(Y)}else if(tp(N)){let U=s.resolveSchemaReference(N),Y=s0(U,!1,s,i,P,l);Y.type==="object"&&M.push(...Y.properties)}else{let U=N.required??[];M=M.map(J=>(J.schema.type==="optional"||J.schema.type==="nullable")&&U.includes(J.key)?{...J,schema:J.schema.value}:J);let Y=s0(N,!1,s,i,P,l);Y.type==="object"&&M.push(...Y.properties)}let T={};for(let N of E)for(let[U,Y]of Object.entries(N.properties)){let J=T[U];J!=null?(J.schemaIds.push(N.schemaId),J.schemas.some(oe=>bau(oe,Y))||J.schemas.push(Y)):T[U]={schemaIds:[N.schemaId],schemas:[Y]}}let z=[];for(let[N,U]of Object.entries(T))U.schemaIds.length>1&&z.push({propertyKey:N,allOfSchemaIds:U.schemaIds,conflictingTypeSignatures:U.schemas.length>1});let $=Object.fromEntries(Object.entries(A).filter(([N,U])=>!(!tp(U)&&U.type==="null"))),I=Object.entries($).map(([N,U])=>{let Y=hf(U,ad.AUDIENCES)??[],J=UK(U),X=tp(U)?!1:U.readOnly,oe=tp(U)?!1:U.writeOnly,pe=D.includes(N)&&!X,de=hf(U,ad.FERN_PROPERTY_NAME),me=[...i,N],Le=Z1c(me),vt=pe?s0(U,!1,s,me,P,l):Nl.optional({nameOverride:e,generatedName:Le,title:r,description:void 0,availability:J,value:s0(U,!1,s,me,P,l),namespace:l,groupName:b,inline:void 0}),De={};for(let Ae of E){let Ct=Ae.properties[N];Ct!=null&&!bau(vt,Ct)?De[Ae.schemaId]={differentSchema:!0}:Ct!=null&&(De[Ae.schemaId]={differentSchema:!1})}return{key:N,schema:vt,nameOverride:de,audiences:Y,conflict:De,generatedName:Z1c([...i,N]),availability:J,readonly:X,writeonly:oe}});return I.push(...M.map(N=>{let U=N.conflict;for(let Y of E){let J=Y.properties[N.key];J!=null&&!bau(N.schema,J)?U[Y.schemaId]={differentSchema:!0}:J!=null&&(U[Y.schemaId]={differentSchema:!1})}return{...N,conflict:U}})),xCE({nameOverride:e,generatedName:t,title:r,wrapAsNullable:c,properties:I.filter(N=>!o.has(N.key)),description:a,allOf:E.map(N=>N.convertedSchema),allOfPropertyConflicts:z,namespace:l,groupName:b,fullExamples:g,additionalProperties:O,availability:m,source:P,context:s})}function xCE({nameOverride:e,generatedName:t,title:r,wrapAsNullable:i,properties:n,description:a,allOf:u,allOfPropertyConflicts:c,namespace:d,groupName:s,fullExamples:o,additionalProperties:l,availability:b,source:g,context:O}){return i?Nl.nullable({nameOverride:e,generatedName:t,title:r,value:Nl.object({description:a,properties:n,nameOverride:e,generatedName:t,title:r,allOf:u,allOfPropertyConflicts:c,namespace:d,groupName:s,fullExamples:o,additionalProperties:OKn(l,O.options),availability:void 0,source:g,inline:void 0}),description:a,availability:b,namespace:d,groupName:s,inline:void 0}):Nl.object({description:a,properties:n,nameOverride:e,generatedName:t,title:r,allOf:u,allOfPropertyConflicts:c,namespace:d,groupName:s,fullExamples:o,additionalProperties:OKn(l,O.options),availability:b,source:g,inline:void 0})}function Ej_({schema:e,context:t,breadcrumbs:r,source:i,namespace:n}){let a={},[u,c]=tp(e)?[t.resolveSchemaReference(e),vau(e.$ref)]:[e,r];for(let d of u.allOf??[])a={...a,...Ej_({schema:d,context:t,breadcrumbs:c,source:i,namespace:n})};for(let[d,s]of Object.entries(u.properties??{})){let o=s0(s,!1,t,[...c,d],i,n);a[d]=o}return a}function RNi({nameOverride:e,generatedName:t,title:r,breadcrumbs:i,description:n,availability:a,wrapAsNullable:u,context:c,subtypes:d,namespace:s,groupName:o,encoding:l,source:b,subtypePrefixOverrides:g}){let O=FCE({schemas:d}),m=d.flatMap((D,A)=>{if(!tp(D)&&D.enum!=null&&c.options.coerceEnumsToLiterals&&D.type==="string")return D.enum.map(E=>Nl.literal({nameOverride:void 0,generatedName:D5([t,E],c.options.preserveSchemaIds),title:void 0,value:mx.string(String(E)),namespace:s,groupName:void 0,description:void 0,availability:E.availability}));let M=O[A];if(g!=null){let E=g[A];E!=null&&"name"in E&&(M=E.name)}return[s0(D,!1,c,[...i,M??`${A}`],b,s)]}),P=RCE(m);return NCE({uniqueSubtypes:P,nameOverride:e,generatedName:t,title:r,wrapAsNullable:u,description:n,availability:a,namespace:s,groupName:o,context:c,encoding:l,source:b})}function RCE(e){let t=[];for(let r=0;r<e.length;++r){let i=e[r],n=!1;for(let a=r+1;a<e.length;++a){let u=e[a];if(i!=null&&u!=null&&Fue(i,u)){n=!0;break}}i!=null&&!n&&t.push(i)}return t}function NCE({uniqueSubtypes:e,nameOverride:t,generatedName:r,title:i,wrapAsNullable:n,description:a,availability:u,namespace:c,groupName:d,context:s,encoding:o,source:l}){if(Object.entries(e).every(([g,O])=>O.type==="literal")){let g={},O=[];return Object.entries(e).forEach(([m,P])=>{P.type==="literal"&&P.value.type==="string"&&(O.push(P.value.value),P.description!=null&&(g[P.value.value]={description:P.description}))}),zNi({nameOverride:t,generatedName:r,title:i,wrapAsNullable:n,description:a,availability:u,fernEnum:g,enumVarNames:void 0,enumValues:O,_default:void 0,namespace:c,groupName:d,context:s,source:l,inline:void 0})}return e.length===1&&e[0]!=null&&!s.options.preserveSingleSchemaOneOf?e[0]:Mj_({nameOverride:t,generatedName:r,title:i,wrapAsNullable:n,description:a,availability:u,subtypes:e,namespace:c,groupName:d,encoding:o,source:l})}function eSc({nameOverride:e,generatedName:t,title:r,description:i,availability:n,wrapAsNullable:a,context:u,namespace:c,groupName:d,discriminator:s,encoding:o,source:l}){let b=Object.entries(s.mapping??{}).map(([m,P],D)=>{let A={$ref:P},M=Jmi(A,!1,u,[P],o,l,c);return u.markSchemaWithDiscriminantValue(A,s.propertyName,m),M.type==="object"&&(M.properties={[s.propertyName]:Nl.literal({nameOverride:void 0,generatedName:D5([t,m],u.options.preserveSchemaIds),title:void 0,value:mx.string(m),namespace:void 0,groupName:void 0,description:void 0,availability:void 0}),...M.properties.filter(E=>E.key!==s.propertyName)}),M}),g=[];for(let m=0;m<b.length;++m){let P=b[m],D=!1;for(let A=m+1;A<b.length;++A){let M=b[A];if(P!=null&&M!=null&&Fue(P,M)){D=!0;break}}P!=null&&!D&&g.push(P)}if(Object.entries(g).every(([m,P])=>P.type==="literal")){let m={},P=[];return Object.entries(g).forEach(([D,A])=>{A.type==="literal"&&A.value.type==="string"&&(P.push(A.value.value),A.description!=null&&(m[A.value.value]={description:A.description}))}),zNi({nameOverride:e,generatedName:t,title:r,wrapAsNullable:a,description:i,availability:n,fernEnum:m,enumVarNames:void 0,enumValues:P,_default:void 0,namespace:c,groupName:d,context:u,source:l,inline:void 0})}return g.length===1&&g[0]!=null&&!u.options.preserveSingleSchemaOneOf?g[0]:Mj_({nameOverride:e,generatedName:t,title:r,wrapAsNullable:a,description:i,availability:n,subtypes:g,namespace:c,groupName:d,encoding:o,source:l})}function FCE({schemas:e}){let t={},r=0;for(let a of e){if(!tp(a)){if(a.properties!=null&&Object.entries(a.properties).length>0){let u=Object.keys(a.properties),c={},d=u;for(let[s,o]of Object.entries(t)){let l=zAo(o,u);d=zAo(d,o),c[s]=l}c[r]=d,t=c}}r++}let i=[],n=0;for(let a of e){let u=t[n];if(u!=null&&u.length>0){let c=u.sort();if(c[0]!=null){i.push(c[0]),++n;continue}}tp(a)?i.push(TNi(n)??`${n}`):a.type==="array"||a.type==="boolean"||a.type==="integer"||a.type==="number"||a.type==="string"?i.push(""):i.push(TNi(n)??`${n}`),++n}return i}function Mj_({nameOverride:e,generatedName:t,title:r,wrapAsNullable:i,description:n,availability:a,subtypes:u,namespace:c,groupName:d,encoding:s,source:o}){return i?Nl.nullable({nameOverride:e,generatedName:t,title:r,value:Nl.oneOf(xee.undiscriminated({description:n,availability:a,nameOverride:e,generatedName:t,title:r,schemas:u,namespace:c,groupName:d,encoding:s,source:o,inline:void 0})),description:n,availability:a,namespace:c,groupName:d,inline:void 0}):Nl.oneOf(xee.undiscriminated({description:n,availability:a,nameOverride:e,generatedName:t,title:r,schemas:u,namespace:c,groupName:d,encoding:s,source:o,inline:void 0}))}function PKn(e){if(e.default!=null&&typeof e.default=="string")return e.default}function gau({schema:e,logger:t,fallback:r}){if(e.example!=null&&typeof e.example=="number")return e.example;let i=$nn(e);for(let n of i??[])if(typeof n=="number")return n;if(r&&typeof r=="number")return r}function Aj_({schema:e,logger:t,fallback:r}){if(e.example!=null&&typeof e.example=="boolean")return e.example;let i=$nn(e);for(let n of i??[])if(typeof n=="boolean")return n;if(r&&typeof r=="boolean")return r}function vor({schema:e,logger:t,fallback:r}){if(e.example!=null&&typeof e.example=="string")return e.example;let i=$nn(e);for(let n of i??[])if(typeof n=="string")return n;if(r&&typeof r=="string")return r}function qj_({schema:e,logger:t,fallback:r}){if(e.example!=null&&Array.isArray(e.example))return e.example;let i=$nn(e);for(let n of i??[])if(Array.isArray(n))return n;if(r&&Array.isArray(r))return r}var Qnn="#/components/schemas/";function s0(e,t,r,i,n,a,u=!1,c=new Set,d){let s=yj_(e)??n,o=QCE({schema:e,logger:r.logger});if(tp(e)){let l=xNi(e);return l!=null?(u?r.markSchemaAsReferencedByRequest(l):r.markSchemaAsReferencedByNonRequest(l),Jmi(e,t,r,i,o,s,a)):mKn(r.resolveSchemaReference(e),t,r,vau(e.$ref),o,s,a,c,u,d)}return mKn(e,t,r,i,o,s,a,c,u,d)}function Jmi(e,t,r,i,n,a,u){let c=e.$ref.includes("properties")?mKn(r.resolveSchemaReference(e),t,r,i,n,a,u,new Set):Nl.reference(k1c(e,i,a,r.options.preserveSchemaIds));return t?Nl.nullable({title:void 0,nameOverride:void 0,generatedName:D5(i,r.options.preserveSchemaIds),value:c,description:void 0,availability:void 0,namespace:void 0,groupName:void 0,inline:void 0}):c}function LCE(e){if(e!=null&&!e.includes(" ")&&/^[a-zA-Z]+$/.test(e))return e}function mKn(e,t,r,i,n,a,u,c=new Set,d=!1,s){typeof e=="string"&&(e={type:e});let o=hf(e,ad.TYPE_NAME)??(r.options.useTitlesAsName?LCE(e.title):void 0),l=hf(e,ad.SDK_GROUP_NAME)??hf(e,M$.TAGS)?.[0],b=(typeof l=="string"?[l]:l)??[];b=r.resolveGroupName(b);let g=D5(i,r.options.preserveSchemaIds),O=e.title,m=e.description,P=UK(e),D=[];e.example!=null&&D.push({name:void 0,value:e.example,description:void 0});let A=hf(e,M$.EXAMPLES);A!=null&&Object.keys(A).length>0&&D.push(...Object.entries(A).map(([T,z])=>({name:z?.summary??T,value:z.value,description:z.description})));let M=$nn(e);M!=null&&Object.keys(M).length>0&&D.push(...M.map(T=>({name:void 0,value:T,description:void 0})));let E=hj_({schema:e,description:m,title:O,nameOverride:o,generatedName:g,availability:P});if(E!=null)return E;if(Array.isArray(e.type)){let T=e.type.indexOf("null"),z=T!==-1;if(e.type.length===1)e.type=e.type[0];else if(e.type.length===2&&z)e.type.splice(T,1),e.type=e.type[0],e.nullable=!0;else if(z&&(e.type.splice(T,1),e.nullable=!0),e.oneOf==null)e.oneOf=[...new Set(e.type)];else{let $=new Set([...e.oneOf,...e.type]);e.oneOf=[...$]}}if(!t&&e.nullable===!0)return mKn(e,!0,r,i,n,a,u,c,d,s);if("const"in e&&(e.enum=[e.const]),e.enum!=null&&(e.type==="string"||e.type==null||e.type==="enum")){if(!Pau(e.enum))return S5({nameOverride:o,generatedName:g,title:O,primitive:bp.string({default:PKn(e),minLength:e.minLength,maxLength:e.maxLength,pattern:e.pattern,format:e.format,example:vor({schema:e,logger:r.logger,fallback:s})}),namespace:u,groupName:b,wrapAsNullable:t,description:m,availability:P});let T=_j_(e);return e.enum.length===1&&e.enum[0]!=null&&T==null?wj_({nameOverride:o,generatedName:g,title:O,wrapAsNullable:t,value:e.enum[0],description:m,availability:P,namespace:u,groupName:b}):zNi({nameOverride:o,generatedName:g,title:O,fernEnum:T,enumVarNames:hf(e,[M$.ENUM_VAR_NAMES]),enumValues:e.enum,_default:e.default,description:m,availability:P,wrapAsNullable:t,namespace:u,groupName:b,context:r,source:a,inline:void 0})}if(Pau(e.type)&&e.type.length>1){let T=e.type.includes("null"),z=e.type.filter($=>$!=="null").map($=>({type:$,nullable:T}));return RNi({nameOverride:o,generatedName:g,title:O,breadcrumbs:i,description:m,availability:P,wrapAsNullable:t,context:r,subtypes:z,namespace:u,groupName:b,encoding:n,source:a})}if(e.type==="boolean"){let T=hf(e,ad.BOOLEAN_LITERAL);return T!=null?Tj_({nameOverride:o,generatedName:g,title:O,literal:mx.boolean(T),wrapAsNullable:t,description:m,availability:P,namespace:u,groupName:b}):S5({nameOverride:o,generatedName:g,title:O,primitive:bp.boolean({default:UCE(e.default),example:Aj_({schema:e,logger:r.logger,fallback:s})}),wrapAsNullable:t,description:m,availability:P,namespace:u,groupName:b})}if(e.type==="number")return X1c({nameOverride:o,generatedName:g,title:O,format:e.format,_default:e.default,minimum:e.minimum,maximum:e.maximum,exclusiveMinimum:Gnn(e.exclusiveMinimum),exclusiveMaximum:Gnn(e.exclusiveMaximum),multipleOf:e.multipleOf,description:m,availability:P,wrapAsNullable:t,example:gau({schema:e,logger:r.logger,fallback:s}),namespace:u,groupName:b});if(e.type==="integer")return Pj_({nameOverride:o,generatedName:g,title:O,format:e.format,_default:e.default,minimum:e.minimum,maximum:e.maximum,exclusiveMinimum:Gnn(e.exclusiveMinimum),exclusiveMaximum:Gnn(e.exclusiveMaximum),multipleOf:e.multipleOf,description:m,availability:P,wrapAsNullable:t,example:gau({schema:e,logger:r.logger,fallback:s}),namespace:u,groupName:b});if(e.type==="float")return X1c({nameOverride:o,generatedName:g,title:O,format:"float",_default:e.default,minimum:e.minimum,maximum:e.maximum,exclusiveMinimum:Gnn(e.exclusiveMinimum),exclusiveMaximum:Gnn(e.exclusiveMaximum),multipleOf:e.multipleOf,description:m,availability:P,wrapAsNullable:t,example:gau({schema:e,logger:r.logger,fallback:s}),namespace:u,groupName:b});if(e.type==="string"){if(e.format==="date-time")return S5({nameOverride:o,generatedName:g,title:O,primitive:bp.datetime({example:vor({schema:e,logger:r.logger,fallback:s})}),wrapAsNullable:t,description:m,availability:P,namespace:u,groupName:b});if(e.format==="date"&&r.options.typeDatesAsStrings===!1)return S5({nameOverride:o,generatedName:g,title:O,primitive:bp.date({example:vor({schema:e,logger:r.logger,fallback:s})}),wrapAsNullable:t,description:m,availability:P,namespace:u,groupName:b});if(e.format==="json-string")return Nl.unknown({nameOverride:o,generatedName:g,title:O,description:m,availability:P,namespace:u,groupName:b,example:void 0});let T=Ij_(e,"const");return T!=null?Tj_({nameOverride:o,generatedName:g,title:O,literal:mx.string(T),wrapAsNullable:t,description:m,availability:P,namespace:u,groupName:b}):S5({nameOverride:o,generatedName:g,title:O,primitive:bp.string({default:PKn(e),pattern:e.pattern,format:e.format,minLength:e.minLength,maxLength:e.maxLength,example:vor({schema:e,logger:r.logger,fallback:s})}),namespace:u,groupName:b,wrapAsNullable:t,description:m,availability:P})}if(e.type==="array")return gj_({nameOverride:o,generatedName:g,title:O,breadcrumbs:i,item:e.items,description:m,availability:P,wrapAsNullable:t,context:r,namespace:u,groupName:b,example:qj_({schema:e,logger:r.logger,fallback:s}),source:a});if(e.additionalProperties!=null&&e.additionalProperties!==!1&&Oau(e))return vj_({nameOverride:o,generatedName:g,title:O,breadcrumbs:i,additionalProperties:e.additionalProperties,description:m,availability:P,wrapAsNullable:t,context:r,namespace:u,groupName:b,encoding:n,example:e.example,source:a});if(e.oneOf!=null&&e.oneOf.length>0&&hf(e,ad.IS_DISCRIMINATED)===!1)return RNi({nameOverride:o,generatedName:g,title:O,breadcrumbs:i,description:m,availability:P,wrapAsNullable:t,context:r,subtypes:e.oneOf,namespace:u,groupName:b,encoding:n,source:a});if(e.type==="object"&&e.discriminator!=null&&e.discriminator.mapping!=null)return r.options.discriminatedUnionV2?eSc({nameOverride:o,generatedName:g,title:O,description:m,availability:P,wrapAsNullable:t,context:r,namespace:u,groupName:b,discriminator:e.discriminator,encoding:n,source:a}):K1c({nameOverride:o,generatedName:g,title:O,breadcrumbs:i,description:m,availability:P,discriminator:e.discriminator,properties:e.properties??{},required:e.required,wrapAsNullable:t,context:r,namespace:u,groupName:b,encoding:n,source:a});if(e.oneOf!=null&&e.oneOf.length>0){let T=hf(e,ad.IS_UNDISCRIMINATED);if(e.discriminator!=null&&e.discriminator.mapping!=null&&Object.keys(e.discriminator.mapping).length>0)return r.options.discriminatedUnionV2||T?eSc({nameOverride:o,generatedName:g,title:O,description:m,availability:P,wrapAsNullable:t,context:r,namespace:u,groupName:b,discriminator:e.discriminator,encoding:n,source:a}):K1c({nameOverride:o,generatedName:g,title:O,breadcrumbs:i,description:m,availability:P,discriminator:e.discriminator,properties:e.properties??{},required:e.required,wrapAsNullable:t,context:r,namespace:u,groupName:b,encoding:n,source:a});if(e.oneOf.length===1&&e.oneOf[0]!=null){if(r.options.preserveSingleSchemaOneOf)return RNi({nameOverride:o,generatedName:g,title:O,breadcrumbs:i,description:m,availability:P,wrapAsNullable:t,context:r,subtypes:e.oneOf.filter($=>tp($)||$.type!=="null"),encoding:n,namespace:u,groupName:b,source:a});let z=s0(e.oneOf[0],t,r,i,a,u,d);return jKn(z,m,u,b)}else if(e.oneOf.length>1){if(e.oneOf.length===2&&e.oneOf[0]!=null&&e.oneOf[1]!=null){let N=e.oneOf[0],U=e.oneOf[1];if(!tp(N)&&N.type==="null")return s0(U,!0,r,i,a,u);if(!tp(U)&&U.type==="null")return s0(N,!0,r,i,a,u)}let z=HCE({schemas:e.oneOf});if(z!=null)return zNi({nameOverride:o,generatedName:g,title:O,fernEnum:void 0,enumVarNames:void 0,enumValues:z,_default:e.default,description:m,availability:P,wrapAsNullable:t,namespace:u,groupName:b,context:r,source:a,inline:void 0});let $=Cj_({schemas:e.oneOf,context:r});if($!=null&&!r.options.discriminatedUnionV2&&!T)return Y1c({nameOverride:o,generatedName:g,title:O,breadcrumbs:i,properties:e.properties??{},required:e.required,description:m,availability:P,wrapAsNullable:t,discriminant:$.discriminant,variants:$.schemas,context:r,namespace:u,groupName:b,encoding:n,source:a});let I=e.oneOf.filter(N=>!tp(N)&&N.type==="null").length>0;return RNi({nameOverride:o,generatedName:g,title:O,breadcrumbs:i,description:m,availability:P,wrapAsNullable:t||I,context:r,subtypes:e.oneOf.filter(N=>tp(N)||N.type!=="null"),encoding:n,namespace:u,groupName:b,source:a})}}if(e.anyOf!=null&&e.anyOf.length>0){if(e.anyOf.length===1&&e.anyOf[0]!=null){let $=s0(e.anyOf[0],t,r,i,a,u,d);return jKn($,m,u,b)}if(e.anyOf.length===2){let[$,I]=e.anyOf;if($!=null&&I!=null){if(!tp($)&&$.type==="null"){let N=s0(I,!0,r,i,a,u);return jKn(N,m,u,b)}else if(!tp(I)&&I.type==="null"){let N=s0($,!0,r,i,a,u);return jKn(N,m,u,b)}}}let T=Cj_({schemas:e.anyOf,context:r});if(T!=null&&!r.options.discriminatedUnionV2)return Y1c({nameOverride:o,generatedName:g,title:O,breadcrumbs:i,properties:e.properties??{},required:e.required,description:m,availability:P,wrapAsNullable:t,discriminant:T.discriminant,variants:T.schemas,context:r,namespace:u,groupName:b,encoding:n,source:a});let z=e.anyOf.filter($=>!tp($)&&$.type==="null").length>0;return RNi({nameOverride:o,generatedName:g,title:O,breadcrumbs:i,description:m,availability:P,wrapAsNullable:t||z,context:r,subtypes:e.anyOf.filter($=>tp($)||$.type!=="null"),encoding:n,namespace:u,groupName:b,source:a})}if(e.allOf!=null||e.properties!=null){let T=[];for(let $ of e.allOf??[])(tp($)||Object.keys($).length>0)&&T.push($);if((e.properties==null||Oau(e))&&T.length===1&&T[0]!=null){let $=s0(T[0],t,r,i,a,u,d);return jKn($,m,u,b)}let z=T.filter($=>{let I=mau($);return I||r.logger.warn(`Skipping non-object allOf element: ${JSON.stringify($)}`),I});if((e.properties==null||Oau(e))&&z.length===1&&z[0]!=null){let $=s0(z[0],t,r,i,a,u,d);return jKn($,m,u,b)}return Dj_({nameOverride:o,generatedName:g,title:O,breadcrumbs:i,properties:e.properties??{},description:m,required:e.required,wrapAsNullable:t,allOf:z,context:r,propertiesToExclude:c,namespace:u,groupName:b,fullExamples:D,additionalProperties:e.additionalProperties,availability:P,encoding:n,source:a})}if(e.type==="object"&&VCE(e)&&WCE(e)&&Oau(e))return yau({nameOverride:o,generatedName:g,title:O,description:m,availability:P,wrapAsNullable:t,keySchema:{nameOverride:void 0,generatedName:`${g}Key`,title:void 0,description:void 0,availability:void 0,schema:bp.string({default:PKn(e),pattern:e.pattern,format:e.format,minLength:e.minLength,maxLength:e.maxLength,example:vor({schema:e,logger:r.logger,fallback:s})}),namespace:u,groupName:b},valueSchema:Nl.unknown({nameOverride:void 0,generatedName:`${g}Value`,title:void 0,description:void 0,availability:void 0,example:void 0,namespace:u,groupName:b}),namespace:u,groupName:b,encoding:n,example:e.example});if(e.type==null){let T=e.example??e.default;return Nl.unknown({nameOverride:o,generatedName:g,title:O,description:m,availability:P,namespace:u,groupName:b,example:T})}throw new Error(`Failed to convert schema breadcrumbs=${JSON.stringify(i)} value=${JSON.stringify(e)}`)}function UCE(e){if(e!=null){if(typeof e=="boolean")return e;if(typeof e=="string"){let t=e.toLowerCase();if(t==="true")return!0;if(t==="false")return!1}}}function xNi(e){if(e.$ref.startsWith(Qnn))return e.$ref.replace(Qnn,"")}function k1c(e,t,r,i){let n=hf(e,ad.TYPE_NAME),a=D5(t,i),u=e.description,c=UK(e),d=xNi(e);if(d==null)throw new Error(`Invalid schema reference ${JSON.stringify(e)}`);return wv.reference({generatedName:a,nameOverride:n,title:void 0,schema:d,description:u??void 0,availability:c,namespace:void 0,groupName:void 0,source:r})}function VCE(e){return e.oneOf==null||e.oneOf.length===0}function WCE(e){return e.allOf==null||e.allOf.length===0}function Oau(e){return e.properties==null||Vq(e.properties)===0}function Pau(e){return Array.isArray(e)&&e.every(t=>typeof t=="string")}function jKn(e,t,r,i){return e.type==="reference"?Nl.reference({...e,description:t,availability:e.availability,namespace:r,groupName:i}):e.type==="optional"?Nl.optional({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:e.value,description:t,availability:e.availability,namespace:r,groupName:i,inline:void 0}):e.type==="nullable"?Nl.nullable({nameOverride:e.nameOverride,generatedName:e.generatedName,title:e.title,value:e.value,description:t,availability:e.availability,namespace:r,groupName:i,inline:void 0}):e}function mau(e){return tp(e)||e.type==="object"||e.properties!=null?!0:e.allOf!=null?e.allOf.every(t=>mau(t)):e.oneOf!=null?e.oneOf.every(t=>mau(t)):e.anyOf!=null?e.anyOf.every(t=>mau(t)):!1}function Tj_({literal:e,wrapAsNullable:t,namespace:r,groupName:i,description:n,availability:a,nameOverride:u,generatedName:c,title:d}){return t?Nl.nullable({nameOverride:u,generatedName:c,title:d,value:Nl.literal({nameOverride:u,generatedName:c,title:d,value:e,description:n,availability:a,namespace:r,groupName:i}),namespace:r,groupName:i,description:n,availability:a,inline:void 0}):Nl.literal({nameOverride:u,generatedName:c,title:d,value:e,namespace:r,groupName:i,description:n,availability:a})}function S5({primitive:e,wrapAsNullable:t,namespace:r,groupName:i,description:n,availability:a,generatedName:u,nameOverride:c,title:d}){return i=typeof i=="string"?[i]:i,t?Nl.nullable({nameOverride:c,generatedName:u,title:d,value:Nl.primitive({nameOverride:c,generatedName:u,title:d,schema:e,description:n,availability:a,namespace:r,groupName:i}),namespace:r,groupName:i,description:n,availability:a,inline:void 0}):Nl.primitive({nameOverride:c,generatedName:u,title:d,schema:e,description:n,availability:a,namespace:r,groupName:i})}function HCE({schemas:e}){let t=new Set;for(let r of e){if(tp(r))return;if(r.enum!=null&&Pau(r.enum))r.enum.forEach(i=>t.add(i));else return}return Array.from(t)}function Cj_({schemas:e,context:t}){let r={};for(let i of e){let n=Bj_({schema:i,context:t});for(let[a,u]of Object.entries(n)){let c=r[a];c!=null?c[u]=i:r[a]={[u]:i}}}for(let[i,n]of Object.entries(r))if(Object.keys(n).length===e.length)return{discriminant:i,schemas:n}}function Bj_({schema:e,context:t}){let r=tp(e)?t.resolveSchemaReference(e):e;return $CE({schema:r,context:t})}function $CE({schema:e,context:t}){let r={};if(e.anyOf!=null){for(let i of e.anyOf){let n=Bj_({schema:i,context:t});for(let[a,u]of Object.entries(n??{}))r[a]=u}return r}for(let[i,n]of Object.entries(e.properties??{})){let a=tp(n)?t.resolveSchemaReference(n):n;a.type==="string"&&a.enum!=null&&Pau(a.enum)&&GCE(a.enum).length===1&&a.enum[0]!=null&&(r[i]=a.enum[0]);let u=Ij_(a,"const");a.type==="string"&&u!=null&&(r[i]=u),i==="type"&&a.example!=null&&(r[i]=a.example)}return r}function GCE(e){if(!e)return[];let t=new Set;return e.forEach(r=>{typeof r=="string"?t.add(r.toLowerCase()):t.add(r)}),Array.from(t)}function Ij_(e,t){let r=e[t];if(r!=null)return r}function QCE({schema:e,logger:t}){let r=pj_({schema:e,logger:t});if(r!=null)return mj_(r)}var wKn=class{document;taskContext;logger;DUMMY;options;namespace;static MESSAGE_REFERENCE_PREFIX="#/components/messages/";constructor({document:t,taskContext:r,options:i,namespace:n}){this.document=t,this.taskContext=r,this.logger=r.logger,this.DUMMY=this,this.options=i,this.namespace=n}resolveGroupName(t){return this.namespace!=null?[{type:"namespace",name:this.namespace},...t]:t}resolveTags(t,r){if(this.namespace==null&&t==null&&r!=null)return[r];let i=[];if(this.namespace!=null){let n={type:"namespace",name:this.namespace};i.push(n)}return i.concat(t??[])}resolveSchemaReference(t){if(!t.$ref.startsWith(Qnn))throw new Error(`Failed to resolve schema reference: ${t.$ref}`);let i=t.$ref.substring(Qnn.length).split("/"),n=this.document.components;if(n==null||n.schemas==null)throw new Error("Document does not have components.schemas.");let[a,u,c]=i;if(a==null||a==="")throw new Error(`${t.$ref} cannot be resolved. No schema key provided.`);let d=n.schemas[a];if(d==null)throw new Error(`Schema "${a}" is undefined in document.components.schemas.`);if(tp(d)&&(d=this.resolveSchemaReference(d)),u==="properties"&&c!=null){let s=d.properties?.[c];if(s==null)throw new Error(`Property "${c}" not found on "${a}". Full ref: ${t.$ref}`);tp(s)?d=this.resolveSchemaReference(s):d=s}return d}referenceExists(t){let r=t.substring(2).split("/").map(n=>n.replace(/~1/g,"/")),i=this.document;for(let n of r){if(typeof i!="object"||i==null)return!1;i=i[n]}return!0}markSchemaAsReferencedByNonRequest(t){}markSchemaAsReferencedByRequest(t){}markReferencedByDiscriminatedUnion(t,r,i){}markSchemaWithDiscriminantValue(t,r,i){}};var jau=class extends wKn{getExampleMessageReference(t){return`#/components/messages/${t.messageId}`}resolveMessageReference(t){let r="#/components/messages/",i=this.document.components;if(i==null||i.messages==null||!t.$ref.startsWith(r))throw new Error(`Failed to resolve message reference: ${t.$ref} in v2 components`);let n=t.$ref.substring(r.length),a=i.messages[n];if(a==null)throw new Error(`${t.$ref} is undefined`);return a}};function SKn(e,t){let r={};if(e!=null)return{rootSchemas:r,namespacedSchemas:{[e]:t}};let i={};for(let[n,a]of Object.entries(t))switch(a.type){case"object":case"array":case"map":case"optional":case"enum":case"literal":case"reference":case"nullable":case"primitive":{if(a.namespace==null){r[n]=a;continue}let u=a.namespace;i[u]??={},i[u][n]=a;continue}case"oneOf":case"unknown":r[n]=a;continue;default:Ao(a)}return{rootSchemas:r,namespacedSchemas:i}}function NNi(e){if(typeof e=="string")return rO.primitive(M_.string(e));if(typeof e=="number")return Number.isInteger(e)?rO.primitive(M_.int(e)):rO.primitive(M_.double(e));if(typeof e=="boolean")return rO.primitive(M_.boolean(e));if(Array.isArray(e)){let t=e.map(r=>NNi(r));return t.length===0?void 0:rO.array(t.filter(r=>r!=null))}else if(e!=null&&typeof e=="object"&&Object.keys(e).every(t=>typeof t=="string")){let t=[];for(let[r,i]of Object.entries(e)){let n=NNi(i);n!=null&&t.push({key:M_.string(r),value:n})}return rO.map(t)}}function N5a(e){if(e!=null&&typeof e=="object"&&Object.keys(e).every(t=>typeof t=="string"))return e}function zj_(e){if(e!=null&&Array.isArray(e))return e}var FNi=class{schemas;nonRequestReferencedSchemas;context;constructor(t,r,i){this.schemas=t,this.nonRequestReferencedSchemas=r,this.context=i}buildExample({schema:t,exampleId:r,example:i,options:n,skipReadonly:a}){return this.buildExampleHelper({schema:t,visitedSchemaIds:new Set,exampleId:r,example:i,options:{...n,maxCheckerDepth:n.maxCheckerDepth??5},depth:0,skipReadonly:a??!1})}buildExampleHelper({exampleId:t,example:r,schema:i,depth:n,visitedSchemaIds:a,options:u,skipReadonly:c}){switch(i.type){case"enum":return typeof r=="string"&&xj_({schema:i,value:r})?rO.enum(r):i.values[0]!=null?rO.enum(i.values[0]?.value):void 0;case"literal":return rO.literal(i.value);case"nullable":{if(r==null&&!this.hasExample(i.value,0,a,u)&&(u.ignoreOptionals||this.exceedsMaxDepth(n,u)))return;let d=this.buildExampleHelper({schema:i.value,visitedSchemaIds:a,exampleId:t,example:r,depth:n,options:u,skipReadonly:c});return d!=null&&d.type==="array"&&d.value.length===0||d!=null&&d.type==="map"&&d.value.length===0||d!=null&&d.type==="object"&&Object.keys(d.properties).length===0?void 0:d}case"optional":{if(r==null&&!this.hasExample(i.value,0,a,u)&&(u.ignoreOptionals||this.exceedsMaxDepth(n,u))||Object.is(r,null))return;let d=this.buildExampleHelper({schema:i.value,visitedSchemaIds:a,exampleId:t,example:r,depth:n,options:u,skipReadonly:c});return d!=null&&d.type==="array"&&d.value.length===0||d!=null&&d.type==="map"&&d.value.length===0||d!=null&&d.type==="object"&&Object.keys(d.properties).length===0?void 0:d}case"primitive":{let d=this.buildExampleFromPrimitive({schema:i.schema,example:r,options:u});return rO.primitive(d)}case"reference":{let d=this.schemas[i.schema];if(d!=null&&!a.has(i.schema)){a.add(i.schema);let s=d?.type==="object"&&!this.nonRequestReferencedSchemas.has(i.schema),o=this.buildExampleHelper({example:r,schema:d,exampleId:t,visitedSchemaIds:a,depth:n,options:u,skipReadonly:s||this.context.options.respectReadonlySchemas?c:!1});return a.delete(i.schema),o}return}case"oneOf":switch(i.value.type){case"discriminated":{let d={},s={},o={},l=N5a(r),b=l?.[i.value.discriminantProperty],g=i.value.schemas[b],O=[],m=this.getDiscriminatedUnionVariantSchema(i.value,l);m!=null&&O.push(m),O.push(...Object.entries(i.value.schemas));for(let P of O)if(b!=null&&g!=null&&g.type==="object"){s=this.getAllProperties(g),o=this.getAllRequiredProperties(g),d[i.value.discriminantProperty]=rO.primitive(M_.string(b));break}else{let D=this.buildExampleHelper({exampleId:t,schema:P[1],example:void 0,visitedSchemaIds:a,depth:n,options:u,skipReadonly:c});if(D!=null){this.mergeExampleWith(D,d),d[i.value.discriminantProperty]=rO.primitive(M_.string(P[0]));break}}for(let P of i.value.commonProperties){s[P.key]={schema:P.schema,readonly:!1};let D=this.getResolvedSchema(P.schema);D.type!=="optional"&&D.type!=="nullable"&&(o[P.key]=P.schema)}for(let[P,D]of Object.entries(s)){let A=P in o;if(A&&l?.[P]!=null){let M=this.buildExampleHelper({schema:D.schema,exampleId:t,example:l[P],visitedSchemaIds:a,depth:n+1,options:u,skipReadonly:c});if(M!=null)d[P]=M;else return}else{let M=this.buildExampleHelper({exampleId:t,schema:D.schema,example:l?.[P],visitedSchemaIds:a,depth:n+1,options:u,skipReadonly:c});if(M!=null)d[P]=M;else if(A)return}}return rO.oneOf(PNi.discriminated(d))}case"undiscriminated":{let d=this.getUnDiscriminatedUnionVariantSchema(i.value,r);if(d!=null)return this.buildExampleHelper({exampleId:t,example:r,schema:d,visitedSchemaIds:a,depth:n,options:u,skipReadonly:c});break}}return;case"unknown":if(r!=null){let d=NNi(r);if(d!=null)return rO.unknown(d)}return u.ignoreOptionals||this.exceedsMaxDepth(n,u)?void 0:u.isParameter?rO.primitive(M_.string(u.name??"string")):rO.map([{key:M_.string("key"),value:rO.primitive(M_.string("value"))}]);case"array":{let d=zj_(r),s=[];if(d!=null&&d.length>0)for(let o of d){let l=this.buildExampleHelper({exampleId:t,example:o,schema:i.value,depth:n+1,visitedSchemaIds:a,options:u,skipReadonly:c});l!=null&&s.push(l)}else if(i.example!=null&&i.example.length>0)for(let o of i.example){let l=this.buildExampleHelper({exampleId:t,example:o,schema:i.value,depth:n+1,visitedSchemaIds:a,options:u,skipReadonly:c});l!=null&&s.push(l)}else{let o=this.buildExampleHelper({exampleId:t,example:void 0,schema:i.value,depth:n+1,visitedSchemaIds:a,options:u,skipReadonly:c});o!=null&&s.push(o)}return rO.array(s)}case"map":{let d=N5a(r??i.example);if(d!=null&&Object.entries(d).length>0){let l=[];for(let[b,g]of Object.entries(d)){let O=this.buildExampleFromPrimitive({schema:i.key.schema,example:b,options:u}),m=this.buildExampleHelper({exampleId:t,example:g,schema:i.value,visitedSchemaIds:a,depth:n+1,options:u,skipReadonly:c});m!=null&&l.push({key:O,value:m})}return rO.map(l)}if(i.key.schema.type==="string"&&i.value.type==="unknown")return rO.map([{key:M_.string("key"),value:rO.unknown(rO.primitive(M_.string("value")))}]);let s=this.buildExampleFromPrimitive({schema:i.key.schema,example:void 0,options:{...u,name:"key"}}),o=this.buildExampleHelper({exampleId:t,example:void 0,schema:i.value,visitedSchemaIds:a,depth:n+1,options:{...u,name:"value"},skipReadonly:c});return o!=null?rO.map([{key:s,value:o}]):rO.map([])}case"object":{let d={},s=i.fullExamples?.find(g=>g.name===t)??i.fullExamples?.find(g=>g.name==null)??i.fullExamples?.[0],o=N5a(r)??(s!=null?N5a(s.value):{})??{},l=this.getAllProperties(i),b=this.getAllRequiredProperties(i);for(let[g,O]of Object.entries(l)){if(c&&O.readonly||O.schema._visit({optional:A=>typeof A.availability=="string"&&A.availability==="Deprecated",primitive:()=>!1,object:()=>!1,array:()=>!1,map:()=>!1,enum:()=>!1,reference:()=>!1,literal:()=>!1,oneOf:()=>!1,nullable:()=>!1,unknown:()=>!1,_other:()=>!1}))continue;let m=g in b,P=Object.keys(o).includes(g),D=this.buildExampleHelper({schema:O.schema,exampleId:t,example:o[g],visitedSchemaIds:a,depth:n+1,options:{...u,name:g},skipReadonly:c});if(m&&D!=null)d[g]=D;else{if(m)return;(P&&D!=null||!u.ignoreOptionals&&D!=null)&&(d[g]=D)}}if(i.additionalProperties){for(let[g,O]of Object.entries(o))if(!(g in d)){let m=this.buildExampleHelper({schema:Nl.unknown({example:O,title:void 0,availability:void 0,description:void 0,generatedName:"",nameOverride:void 0,namespace:void 0,groupName:void 0}),exampleId:t,example:O,visitedSchemaIds:a,depth:n+1,options:{...u,name:g},skipReadonly:c});m!=null&&(d[g]=m)}}return rO.object({properties:d})}default:Ao(i)}}mergeExampleWith(t,r){t._visit({array:Ko,enum:Ko,literal:Ko,map:i=>{for(let n of i){let a=n.key;a.type==="string"&&(r[a.value]=n.value)}},object:i=>{for(let[n,a]of Object.entries(i.properties))r[n]=a},oneOf:i=>{if(i.type==="discriminated")for(let[n,a]of Object.entries(i.value))r[n]=a;else this.mergeExampleWith(i.value,r)},primitive:Ko,unknown:Ko,_other:Ko})}getObjectSchema(t){if(t.type==="object")return t;if(t.type==="reference"){let r=this.schemas[t.schema];if(r!=null)return this.getObjectSchema(r)}}getDiscriminatedUnionVariantSchema(t,r){let i=r?.[t.discriminantProperty];if(i==null||typeof i!="string")return Object.entries(t.schemas)[0];let n=t.schemas[i];return n==null?Object.entries(t.schemas)[0]:[i,n]}getUnDiscriminatedUnionVariantSchema(t,r){return r==null?t.schemas[0]:t.schemas.map(a=>({schema:a,heuristic:this.calcExampleHeuristic(a,r)})).sort((a,u)=>u.heuristic-a.heuristic)[0]?.schema}calcExampleHeuristic(t,r){switch(t.type){case"literal":return t.value.value===r?5:0;case"enum":return xj_({schema:t,value:r})?5:0;case"object":{if(!Rw(r))return 0;let i=this.getAllProperties(t),n=0;for(let[a,u]of Object.entries(i))r[a]!=null?(n++,n+=this.calcExampleHeuristic(u.schema,r[a])):n--;return n}case"array":{if(!Array.isArray(r))return 0;let i=0;for(let n of r)i+=this.calcExampleHeuristic(t.value,n);return i}case"map":{if(!Rw(r))return 0;let i=0;for(let[,n]of Object.entries(r))i+=this.calcExampleHeuristic(t.value,n);return i}case"nullable":case"optional":return this.calcExampleHeuristic(t.value,r);case"reference":{let i=this.getResolvedSchema(t);return i==null?0:this.calcExampleHeuristic(i,r)}case"oneOf":return Object.values(t.value.schemas).map(n=>this.calcExampleHeuristic(n,r)).sort((n,a)=>a-n)[0]??0;case"primitive":return r==null?0:t.schema._visit({int:()=>typeof r=="number",int64:()=>typeof r=="number",uint:()=>typeof r=="number",uint64:()=>typeof r=="number",float:()=>typeof r=="number",double:()=>typeof r=="number",string:()=>typeof r=="string",datetime:()=>typeof r=="string",date:()=>typeof r=="string",base64:()=>typeof r=="string",boolean:()=>typeof r=="boolean",_other:()=>!0})?1:-1;default:return 0}}hasExample(t,r,i=new Set,n){if(this.exceedsMaxCheckerDepth(r,n))return!1;switch(t.type){case"array":return this.hasExample(t.value,r+1,i,n);case"enum":return t.example!=null;case"literal":return!1;case"map":return t.example!=null||t.key.schema.example!=null&&this.hasExample(t.value,r+1,i,n);case"object":{if(t.fullExamples!=null&&t.fullExamples.length>0)return!0;for(let u of t.properties)if(this.hasExample(u.schema,r+1,i,n))return!0;return!1}case"primitive":return t.schema.example!=null;case"reference":{let a=this.schemas[t.schema];if(a!=null&&!i.has(t.schema)){i.add(t.schema);let u=this.hasExample(a,r,i,n);return i.delete(t.schema),u}return!1}case"unknown":return t.example!=null;case"oneOf":return Object.values(t.value.schemas).some(a=>this.hasExample(a,r,i,n));default:return!1}}exceedsMaxCheckerDepth(t,r){return t>(r.maxCheckerDepth??0)}exceedsMaxDepth(t,r){return t>(r.maxDepth??0)}getAllProperties(t){let r={};for(let i of t.properties)r[i.key]={schema:i.schema,readonly:i.readonly??!1};for(let i of t.allOf){let n=this.schemas[i.schema];if(n==null)continue;let a=this.getResolvedSchema(n);a.type==="object"&&(r={...this.getAllProperties(a),...r})}return r}getAllRequiredProperties(t){let r={};for(let i of t.properties){let n=this.getResolvedSchema(i.schema);n.type!=="optional"&&n.type!=="nullable"&&(r[i.key]=i.schema)}for(let i of t.allOf){let n=this.schemas[i.schema];if(n==null)continue;let a=this.getResolvedSchema(n);a.type==="object"&&(r={...this.getAllRequiredProperties(a),...r})}return r}getResolvedSchema(t){for(;t.type==="reference";){let r=this.schemas[t.schema];if(r==null)throw new Error(`Unexpected error: Failed to resolve schema reference: ${t.schema}`);t=r}return t}buildExampleFromPrimitive({example:t,schema:r,options:i}){switch(r.type){case"string":return t!=null&&typeof t=="string"?M_.string(t):r.example!=null?M_.string(r.example):M_.string(i.name??Qh.STRING);case"base64":return t!=null&&typeof t=="string"?M_.base64(t):r.example!=null?M_.base64(r.example):M_.base64(Qh.BASE64);case"boolean":return t!=null&&typeof t=="boolean"?M_.boolean(t):r.example!=null?M_.boolean(r.example):M_.boolean(Qh.BOOLEAN);case"date":return t!=null&&typeof t=="string"?M_.date(t):r.example!=null?M_.date(r.example):M_.date(Qh.DATE);case"datetime":return t!=null&&typeof t=="string"?M_.datetime(t):r.example!=null?M_.datetime(r.example):M_.datetime(Qh.DATE_TIME);case"double":return t!=null&&typeof t=="number"?M_.double(t):r.example!=null?M_.double(r.example):M_.double(Qh.DOUBLE);case"float":return t!=null&&typeof t=="number"?M_.float(t):r.example!=null?M_.float(r.example):M_.float(Qh.FLOAT);case"int":return t!=null&&typeof t=="number"?M_.int(t):r.example!=null?M_.int(r.example):M_.int(Qh.INT);case"int64":return t!=null&&typeof t=="number"?M_.int64(t):r.example!=null?M_.int64(r.example):M_.int64(Qh.INT64);case"uint":return t!=null&&typeof t=="number"?M_.uint(t):r.example!=null?M_.uint(r.example):M_.uint(Qh.UINT);case"uint64":return t!=null&&typeof t=="number"?M_.uint64(t):r.example!=null?M_.uint64(r.example):M_.uint64(Qh.UINT64);default:Ao(r)}}};function xj_({schema:e,value:t}){return e.values.map(r=>r.value).includes(t)}function $Qt(e){switch(e.type){case"object":return Nl.object({allOf:e.allOf,properties:e.properties.map(t=>KCE(t)),allOfPropertyConflicts:e.allOfPropertyConflicts,description:e.description,generatedName:e.generatedName,title:e.title,nameOverride:e.nameOverride,namespace:e.namespace,groupName:e.groupName,fullExamples:void 0,additionalProperties:e.additionalProperties,availability:e.availability,source:e.source,inline:void 0});case"array":return Nl.array({description:e.description,availability:e.availability,value:$Qt(e.value),generatedName:e.generatedName,title:e.title,namespace:e.namespace,nameOverride:e.nameOverride,groupName:e.groupName,example:void 0,inline:void 0});case"enum":return Nl.enum({description:e.description,availability:e.availability,generatedName:e.generatedName,title:e.title,nameOverride:e.nameOverride,values:e.values,default:e.default,namespace:e.namespace,groupName:e.groupName,example:void 0,source:e.source,inline:void 0});case"literal":return Nl.literal({description:e.description,availability:e.availability,value:e.value,generatedName:e.generatedName,title:e.title,nameOverride:e.nameOverride,namespace:e.namespace,groupName:e.groupName});case"nullable":return Nl.nullable({generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,description:e.description,availability:e.availability,value:$Qt(e.value),namespace:e.namespace,groupName:e.groupName,inline:void 0});case"optional":return Nl.optional({generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,description:e.description,availability:e.availability,value:$Qt(e.value),namespace:e.namespace,groupName:e.groupName,inline:void 0});case"primitive":return Nl.primitive({description:e.description,availability:e.availability,schema:Rj_(e.schema),generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,namespace:e.namespace,groupName:e.groupName});case"map":return Nl.map({description:e.description,availability:e.availability,key:Nl.primitive({description:e.key.description,availability:e.key.availability,schema:Rj_(e.key.schema),generatedName:e.key.generatedName,nameOverride:e.key.nameOverride,title:e.key.title,namespace:e.namespace,groupName:e.groupName}),value:$Qt(e.value),generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,namespace:e.namespace,groupName:e.groupName,encoding:e.encoding,example:void 0,inline:void 0});case"reference":return Nl.reference({description:e.description,availability:e.availability,generatedName:e.generatedName,title:e.title,nameOverride:e.nameOverride,schema:e.schema,namespace:e.namespace,groupName:e.groupName,source:e.source});case"oneOf":return Nl.oneOf(JCE(e.value));case"unknown":return Nl.unknown({nameOverride:e.nameOverride,generatedName:e.generatedName,title:void 0,example:void 0,namespace:void 0,groupName:void 0,description:void 0,availability:void 0});default:Ao(e)}}function JCE(e){switch(e.type){case"discriminated":return xee.discriminated({commonProperties:e.commonProperties.map(t=>({key:t.key,schema:$Qt(t.schema)})),description:e.description,availability:e.availability,discriminantProperty:e.discriminantProperty,generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,schemas:Object.fromEntries(Object.entries(e.schemas).map(([t,r])=>[t,$Qt(r)])),namespace:e.namespace,groupName:e.groupName,encoding:e.encoding,source:e.source,inline:void 0});case"undiscriminated":return xee.undiscriminated({description:e.description,availability:e.availability,generatedName:e.generatedName,nameOverride:e.nameOverride,title:e.title,schemas:e.schemas.map(t=>$Qt(t)),namespace:e.namespace,groupName:e.groupName,encoding:e.encoding,source:e.source,inline:void 0});default:Ao(e)}}function Rj_(e){switch(e.type){case"string":return bp.string({default:e.default,pattern:e.pattern,format:e.format,minLength:e.minLength,maxLength:e.maxLength,example:void 0});case"base64":return bp.base64({example:void 0});case"boolean":return bp.boolean({default:e.default,example:void 0});case"date":return bp.date({example:void 0});case"datetime":return bp.datetime({example:void 0});case"double":return bp.double({default:e.default,minimum:e.minimum,maximum:e.maximum,exclusiveMinimum:e.exclusiveMinimum,exclusiveMaximum:e.exclusiveMaximum,multipleOf:e.multipleOf,example:void 0});case"float":return bp.float({example:void 0});case"int":return bp.int({default:e.default,minimum:e.minimum,maximum:e.maximum,exclusiveMinimum:e.exclusiveMinimum,exclusiveMaximum:e.exclusiveMaximum,multipleOf:e.multipleOf,example:void 0});case"int64":return bp.int64({default:e.default,example:void 0});case"uint":return bp.uint({default:void 0,example:void 0});case"uint64":return bp.uint64({default:void 0,example:void 0});default:Ao(e)}}function KCE(e){return{conflict:e.conflict,generatedName:e.generatedName,key:e.key,schema:$Qt(e.schema),audiences:e.audiences,nameOverride:e.nameOverride,availability:e.availability,readonly:e.readonly,writeonly:e.writeonly}}function wau(e){return e.type!=="optional"&&e.type!=="nullable"}function tSc(e){return e==="POST"||e==="PUT"||e==="PATCH"}function F5a(e){if(e.type==="full")return e.request==null&&e.response==null&&e.queryParameters==null&&e.pathParameters==null&&e.headers==null;{let t=e.value;return t.request==null&&t.response==null&&t["query-parameters"]==null&&t["path-parameters"]==null&&t.headers==null}}var Sau=class{schemas;context;globalHeaders;exampleTypeFactory;logger;constructor(t,r,i){this.schemas=t,this.context=r,this.globalHeaders=i,this.schemas=t,this.exampleTypeFactory=new FNi(t,r.nonRequestReferencedSchemas,r),this.logger=r.logger}buildEndpointExample(t){this.logger.debug(`Building endpoint example for ${t.method.toUpperCase()} ${t.path}`);let r=XCE(t.request),i=ZCE(t.response);if(r?.type==="unsupported"||i?.type==="unsupported")return[];let n=[];if(r!=null&&r.type==="present"){let l=this.isSchemaRequired(r.schema);if(r.examples.length===0){let b=this.exampleTypeFactory.buildExample({skipReadonly:tSc(t.method),schema:r.schema,exampleId:void 0,example:void 0,options:{isParameter:!1,ignoreOptionals:!0}});b!=null&&n.push([void 0,b])}else for(let{name:b,value:g}of r.examples){let O=this.exampleTypeFactory.buildExample({skipReadonly:tSc(t.method),schema:r.schema,exampleId:b,example:g,options:{isParameter:!1,ignoreOptionals:!0}});O!=null&&n.push([b,O])}if(l&&n.length===0)return this.logger.trace(`Failed to generate required request example for ${t.method.toUpperCase()} ${t.path}`),[]}let a=[];if(i!=null&&i.type==="present"){let l=this.isSchemaRequired(i.schema);if(i.examples.length===0){let b=this.exampleTypeFactory.buildExample({skipReadonly:!1,schema:i.schema,exampleId:void 0,example:void 0,options:{maxDepth:this.context.options.exampleGeneration?.response?.["max-depth"]??3,isParameter:!1,ignoreOptionals:!1}});b!=null&&(t.response?.type==="json"?a.push([void 0,VQt.withoutStreaming(b)]):(t.response?.type==="streamingJson"||t.response?.type==="streamingSse")&&a.push([void 0,VQt.withStreaming({sse:t.response?.type==="streamingSse",events:[b]})]))}else for(let{name:b,value:g}of i.examples){let O=this.exampleTypeFactory.buildExample({skipReadonly:!1,schema:i.schema,exampleId:b,example:g,options:{maxDepth:this.context.options.exampleGeneration?.response?.["max-depth"]??3,isParameter:!1,ignoreOptionals:!1}});O!=null&&(t.response?.type==="json"?a.push([b,VQt.withoutStreaming(O)]):(t.response?.type==="streamingJson"||t.response?.type==="streamingSse")&&a.push([void 0,VQt.withStreaming({sse:t.response?.type==="streamingSse",events:[O]})]))}if(l&&a.length===0)return this.logger.trace(`Failed to generate required response example for ${t.method.toUpperCase()} ${t.path}`),[]}let u=[];for(let l of t.pathParameters){let b=this.isSchemaRequired(l.schema),g=this.exampleTypeFactory.buildExample({schema:l.schema,exampleId:void 0,example:void 0,options:{name:l.name,isParameter:!0,ignoreOptionals:!0}});if(g!=null&&!GQt(g)&&(this.logger.warn(`Expected a primitive example but got ${g.type} for path parameter ${l.name} for ${t.method.toUpperCase()} ${t.path}`),g=void 0),b&&g==null)return[];g!=null&&u.push({name:l.name,parameterNameOverride:l.parameterNameOverride,value:g})}let c=[];for(let l of t.queryParameters){let b=this.isSchemaRequired(l.schema),g=this.exampleTypeFactory.buildExample({schema:l.schema,exampleId:void 0,example:void 0,options:{name:l.name,isParameter:!0,ignoreOptionals:!0}});if(g!=null&&!GQt(g)&&(this.logger.warn(`Expected a primitive example but got ${g.type} for query parameter ${l.name} for ${t.method.toUpperCase()} ${t.path}`),g=void 0),b&&g==null)return[];g!=null&&c.push({name:l.name,value:g})}let d=[];for(let l of t.headers){let b=this.isSchemaRequired(l.schema),g=this.exampleTypeFactory.buildExample({schema:l.schema,exampleId:void 0,example:void 0,options:{name:l.name,isParameter:!0,ignoreOptionals:!0}});if(g!=null&&!GQt(g)&&(this.logger.warn(`Expected a primitive example but got ${g.type} for header ${l.name} for ${t.method.toUpperCase()} ${t.path}`),g=void 0),b&&g==null)return[];g!=null&&d.push({name:l.name,value:g})}for(let l of this.globalHeaders){let b=l.schema!=null?$Qt(l.schema):Nl.primitive({nameOverride:void 0,generatedName:"",title:void 0,description:void 0,availability:void 0,namespace:void 0,groupName:void 0,schema:bp.string({default:void 0,pattern:void 0,maxLength:void 0,minLength:void 0,example:void 0,format:void 0})}),g=this.exampleTypeFactory.buildExample({schema:b,exampleId:void 0,example:void 0,options:{name:l.header,isParameter:!0,ignoreOptionals:!0}});if(g!=null&&!GQt(g)&&(this.logger.warn(`Expected a primitive example but got ${g.type} for global header ${l.header} for ${t.method.toUpperCase()} ${t.path}`),g=void 0),g==null)return[];g!=null&&d.push({name:l.header,value:g})}let s=[];t.request!=null&&t.response!=null?s=YCE(n,a):t.request!=null?s=n.map(([l,b])=>({id:l,request:b,response:void 0})):t.response!=null&&(s=a.map(([l,b])=>({id:l,request:void 0,response:b})));let o=t.examples.filter(l=>F5a(l)).flatMap(l=>{if(l.type==="unknown"){if(l.value!=null){let b=l.value["code-samples"];if(b!=null)return this.convertCodeSamples(b)}return}else return l.codeSamples}).filter(l=>gy(l));return s.length===0?[UQt.full({name:void 0,description:void 0,pathParameters:u,queryParameters:c,headers:d,request:void 0,response:void 0,codeSamples:o})]:s.map(({id:l,request:b,response:g})=>UQt.full({name:l,description:void 0,pathParameters:u,queryParameters:c,headers:d,request:b,response:g,codeSamples:o}))}convertCodeSamples(t){return t.map(r=>"language"in r?Vmi.language({name:r.name??void 0,description:r.docs??void 0,language:r.language,code:r.code,install:r.install??void 0}):Vmi.sdk({name:r.name??void 0,description:r.docs??void 0,sdk:r.sdk==="c#"?D$.Csharp:r.sdk,code:r.code})).filter(gy)}isSchemaRequired(t){return wau(this.getResolvedSchema(t))}getResolvedSchema(t){return t}};function YCE(e,t){let r=[];if(e.length<=1){let[n,a]=e[0]??[];if(t.length===0)return r.push({id:n,request:a,response:void 0}),r;for(let[u,c]of t)r.push({id:u??n,request:a,response:c});return r}if(t.length<=1){let[n,a]=t[0]??[];if(t.length===0)return r.push({id:n,request:void 0,response:a}),r;for(let[u,c]of e)r.push({id:u??n,request:c,response:a});return r}let i=new Set;for(let[n,a]of e){let u=t.find(([d])=>d==null)?.[1]??t[0]?.[1];if(n==null){if(u==null)continue;r.push({id:void 0,request:a,response:u});continue}let c=!1;for(let d=0;d<t.length;d++){let[s,o]=t[d];s==null||i.has(d)||n===s&&(r.push({id:n,request:a,response:o}),s!=null&&i.add(d),c=!0)}!c&&u!=null&&r.push({id:n,request:a,response:u})}for(let n=0;n<t.length;n++){if(i.has(n))continue;let[a,u]=t[n],c=e.find(([d])=>d==null)?.[1]??e[0]?.[1];c!=null&&r.push({id:a,request:c,response:u})}return r}function XCE(e){if(e!=null)return e.type==="multipart"?{type:"present",schema:kCE(e),examples:[]}:e.type==="json"||e.type==="formUrlEncoded"?{type:"present",schema:e.schema,examples:e.fullExamples??[]}:{type:"unsupported"}}function ZCE(e){if(e!=null)return e.type!=="json"&&e.type!=="streamingJson"&&e.type!=="streamingSse"?{type:"unsupported"}:{type:"present",schema:e.schema,examples:e.fullExamples??[]}}function GQt(e){switch(e.type){case"primitive":case"enum":case"literal":return!0;case"unknown":return GQt(e);case"array":case"object":case"map":return!1;case"oneOf":switch(e.value.type){case"discriminated":return!1;case"undiscriminated":return GQt(e.value.value);default:return!1}default:Ao(e)}}function kCE(e){return Nl.object({properties:e.properties.map(t=>t.schema.type==="file"?null:{key:t.key,schema:$Qt(t.schema.value),audiences:[],conflict:{},generatedName:t.key,nameOverride:void 0,availability:void 0,readonly:void 0,writeonly:void 0,inline:void 0}).filter(gy),allOf:[],allOfPropertyConflicts:[],fullExamples:void 0,description:e.description,nameOverride:void 0,generatedName:"",title:void 0,namespace:void 0,groupName:void 0,additionalProperties:!1,availability:void 0,source:e.source,inline:void 0})}var DKn=class{exampleTypeFactory;schemas;constructor(t,r){this.exampleTypeFactory=new FNi(t,new Set,r),this.schemas=t}buildWebsocketSessionExamplesForExtension({context:t,extensionExamples:r,handshake:i,source:n,namespace:a}){let u=[];for(let c of r){let d=[];for(let l of i.queryParameters){let b=this.isSchemaRequired(l.schema),g=this.exampleTypeFactory.buildExample({schema:l.schema,exampleId:void 0,example:c.queryParameters?.[l.name],options:{name:l.name,isParameter:!0,ignoreOptionals:!0}});g!=null&&!GQt(g)&&(g=void 0),!(b&&g==null)&&g!=null&&d.push({name:l.name,value:g})}let s=[];for(let l of i.headers){let b=this.isSchemaRequired(l.schema),g=this.exampleTypeFactory.buildExample({schema:l.schema,exampleId:void 0,example:c.headers?.[l.name],options:{name:l.name,isParameter:!0,ignoreOptionals:!0}});g!=null&&!GQt(g)&&(g=void 0),!(b&&g==null)&&g!=null&&s.push({name:l.name,value:g})}let o=[];for(let l of c.messages){let b=t.getExampleMessageReference(l),g=t.resolveMessageReference({$ref:b}),O=tp(g.payload)?t.resolveSchemaReference(g.payload):g.payload,m=this.exampleTypeFactory.buildExample({schema:s0(O,!1,t,[l.messageId],n,a),exampleId:void 0,example:l.value,options:{isParameter:!1,ignoreOptionals:!0}});m!=null&&o.push({messageType:l.type,payload:m,description:void 0})}u.push({name:c.summary,queryParameters:d,headers:s,description:c.description,messages:o})}return u}buildWebsocketSessionExample({handshake:t,messages:r}){let i={name:void 0,queryParameters:[],headers:[],description:void 0,messages:[]},n=[];for(let u of t.queryParameters){let c=this.isSchemaRequired(u.schema),d=this.exampleTypeFactory.buildExample({schema:u.schema,exampleId:void 0,example:void 0,options:{name:u.name,isParameter:!0,ignoreOptionals:!0}});if(d!=null&&!GQt(d)&&(d=void 0),c&&d==null)return;d!=null&&n.push({name:u.name,value:d})}let a=[];for(let u of t.headers){let c=this.isSchemaRequired(u.schema),d=this.exampleTypeFactory.buildExample({schema:u.schema,exampleId:void 0,example:void 0,options:{name:u.name,isParameter:!0,ignoreOptionals:!0}});if(d!=null&&!GQt(d)&&(d=void 0),c&&d==null)return;d!=null&&a.push({name:u.name,value:d})}for(let u of r){let c=this.exampleTypeFactory.buildExample({schema:u.payload,exampleId:void 0,example:void 0,options:{isParameter:!1,ignoreOptionals:!0}});c!=null&&i.messages.push({messageType:u.type,payload:c,description:void 0})}return i}isSchemaRequired(t){return wau(this.getResolvedSchema(t))}getResolvedSchema(t){for(;t.type==="reference";){let r=this.schemas[t.schema];if(r==null)throw new Error(`Unexpected error: Failed to resolve schema reference: ${t.schema}`);t=r}return t}};var Fee={FERN_PARAMETER_OPTIONAL:"x-fern-optional",FERN_CHANNEL_ADDRESS:"x-fern-address",FERN_DISPLAY_NAME:"x-fern-display-name",FERN_SDK_GROUP_NAME:"x-fern-sdk-group-name",FERN_EXAMPLES:"x-fern-examples",BASE_PATH:"x-fern-base-path",FERN_ENUM:"x-fern-enum",IGNORE:"x-fern-ignore"};function Dau(e){return hf(e,Fee.FERN_EXAMPLES)??[]}function Eau(e,t){return t.includes("://")?t:`${e}://${t}`}function Mau(e){return e.startsWith("/")?e:"/"+e}function Lj_({context:e,breadcrumbs:t,source:r,asyncApiOptions:i,document:n}){let a={},u={};for(let[s,o]of Object.entries(n.components?.schemas??{})){let l=s0(o,!1,e,[s],r,e.namespace);a[s]=l}let c=new DKn(a,e),d={};for(let[s,o]of Object.entries(n.servers??{}))d[s]={name:s,url:Eau(o.protocol,o.url)};for(let[s,o]of Object.entries(n.channels??{})){let l=hf(o,Fee.IGNORE);if(l!=null&&l){e.logger.debug(`Channel ${s} is marked with x-fern-ignore. Skipping.`);continue}let b=[];if(o.parameters!=null)for(let[D,A]of Object.entries(o.parameters??{}))b.push({name:D,description:A.description,parameterNameOverride:void 0,schema:A.schema!=null?s0(A.schema,!1,e,t,r,e.namespace):Nl.primitive({schema:bp.string({default:void 0,pattern:void 0,format:void 0,maxLength:void 0,minLength:void 0,example:void 0}),description:void 0,availability:void 0,generatedName:"",title:void 0,namespace:void 0,groupName:void 0,nameOverride:void 0}),variableReference:void 0,availability:UK(A),source:r});let g=[],O=[];if(o.bindings?.ws!=null){if(o.bindings.ws.headers!=null){let D=o.bindings.ws.headers.required??[];for(let[A,M]of Object.entries(o.bindings.ws.headers.properties??{})){if(tp(M)){let E=e.resolveSchemaReference(M);g.push({name:A,schema:Jmi(M,!1,e,t,void 0,r,e.namespace),description:E.description,parameterNameOverride:void 0,env:void 0,availability:UK(E),source:r});continue}g.push({name:A,schema:s0(M,!D.includes(A),e,[...t,A],r,e.namespace),description:M.description,parameterNameOverride:void 0,env:void 0,availability:UK(M),source:r})}}if(o.bindings.ws.query!=null){let D=o.bindings.ws.query.required??[];for(let[A,M]of Object.entries(o.bindings.ws.query.properties??{})){if(tp(M)){let E=e.resolveSchemaReference(M);O.push({name:A,schema:Jmi(M,!1,e,t,void 0,r,e.namespace),description:E.description,parameterNameOverride:void 0,availability:UK(E),source:r});continue}O.push({name:A,schema:s0(M,!D.includes(A),e,[...t,A],r,e.namespace),description:M.description,parameterNameOverride:void 0,availability:UK(M),source:r})}}}let m;o.publish!=null&&("oneOf"in o.publish.message?m=Nj_({generatedName:o.publish.operationId??"PublishEvent",event:o.publish,breadcrumbs:t,context:e,source:r,options:e.options,asyncApiOptions:i}):m=Fj_({action:"Publish",channelPath:s,message:o.publish.message,context:e,source:r}));let P;if(o.subscribe!=null&&("oneOf"in o.subscribe.message?P=Nj_({generatedName:o.subscribe.operationId??"SubscribeEvent",event:o.subscribe,breadcrumbs:t,context:e,source:r,options:e.options,asyncApiOptions:i}):P=Fj_({action:"Subscribe",channelPath:s,message:o.subscribe.message,context:e,source:r})),g.length>0||O.length>0||m!=null||P!=null){let D=Dau(o),A=[];if(D.length>0)A=c.buildWebsocketSessionExamplesForExtension({context:e,extensionExamples:D,handshake:{headers:g,queryParameters:O},source:r,namespace:e.namespace});else{let z=[];m!=null&&z.push({type:"publish",payload:m}),P!=null&&z.push({type:"subscribe",payload:P});let $=c.buildWebsocketSessionExample({handshake:{headers:g,queryParameters:O},messages:z});$!=null&&A.push($)}let M=hf(o,Fee.FERN_CHANNEL_ADDRESS),E=M??Mau(s),T=[];m!=null&&T.push({origin:"client",name:"publish",body:DA(m)}),P!=null&&T.push({origin:"server",name:"subscribe",body:DA(P)}),u[s]={audiences:hf(o,ad.AUDIENCES)??[],handshake:{headers:g.map(z=>({...z,schema:DA(z.schema),env:z.env})),queryParameters:O.map(z=>({...z,schema:DA(z.schema)})),pathParameters:b.map(z=>({...z,parameterNameOverride:void 0,schema:DA(z.schema)}))},groupName:e.resolveGroupName([hf(o,Fee.FERN_SDK_GROUP_NAME)??s]),messages:T,servers:(o.servers?.map(z=>d[z])??Object.values(d)).filter(z=>z!=null),summary:hf(o,Fee.FERN_DISPLAY_NAME),path:E,description:o.description,examples:A,source:r}}}return{groupedSchemas:SKn(e.namespace,a),channels:u??void 0,servers:Object.values(d),basePath:hf(n,Fee.BASE_PATH)}}function Nj_({generatedName:e,event:t,context:r,breadcrumbs:i,source:n,options:a,asyncApiOptions:u}){if("oneOf"in t.message&&t.message.oneOf!=null){let c=[],d=[];for(let s of t.message.oneOf){let o,l={type:"notFound"};if(tp(s)){let b=r.resolveMessageReference(s);!tp(b.payload)&&u.naming==="v2"?(l=b.name?{type:"name",name:b.name}:l,o={...b.payload,title:b.name??b.payload.title,description:b.name??b.payload.description}):o=b.payload}else o=s;d.push(l),c.push(o)}return RNi({description:t.description??t.message.description,availability:UK(t.message),subtypes:c,nameOverride:t.operationId,generatedName:e,title:t.message.title,groupName:void 0,wrapAsNullable:!1,breadcrumbs:i,context:r,encoding:void 0,source:n,namespace:r.namespace,subtypePrefixOverrides:u.naming==="v2"?d:[]})}}function Fj_({action:e,channelPath:t,message:r,context:i,source:n}){if(r.payload!=null){let a=r.payload;return tp(r.payload)&&(a=i.resolveSchemaReference(r.payload)),s0(a,!1,i,[t,e],n,i.namespace)}}var Aau=class extends wKn{getExampleMessageReference(t){return`#/channels/${t.channelId}/messages/${t.messageId}`}resolveParameterReference(t){let r="#/components/parameters/";if(this.document.components==null||this.document.components.parameters==null||!t.$ref.startsWith(r))throw new Error(`Failed to resolve ${t.$ref}`);let i=t.$ref.substring(r.length),n=this.document.components.parameters[i];if(n==null)throw new Error(`${t.$ref} is undefined`);return"$ref"in n?this.resolveParameterReference(n):n}resolveMessageReference(t){let r="#/channels/",i="#/components/messages/";if(t.$ref.startsWith(r)){let c=t.$ref.split("/"),d=c[2],s=c[4];if(d==null||s==null||!this.document.channels?.[d])throw new Error(`Failed to resolve message reference ${t.$ref} in channel ${d}`);let l=this.document.channels[d].messages?.[s];if(l==null)throw new Error(`${t.$ref} is undefined`);return"$ref"in l?this.resolveMessageReference(l):{name:s,...l}}let n=this.document.components;if(!t.$ref.startsWith(i)||!n?.messages)throw new Error(`Failed to resolve message reference: ${t.$ref} in v3 components`);let a=t.$ref.substring(i.length),u=n.messages[a];if(u==null)throw new Error(`${t.$ref} is undefined`);return{name:a,...u}}isMessageWithPayload(t){return t!=null&&typeof t=="object"&&"payload"in t}isReferenceObject(t){return t!=null&&typeof t=="object"&&"$ref"in t}};var Uj_="#/channels/",Vj_="#/servers/",rSc="$message.";function Hj_({context:e,breadcrumbs:t,source:r,asyncApiOptions:i,document:n}){let a={},u={},c={},d=[],s={};for(let[O,m]of Object.entries(n.components?.schemas??{}))a[O]=s0(m,!1,e,[O],r,e.namespace);for(let[O,m]of Object.entries(n.channels??{}))if(u[O]||(u[O]={}),m.messages){for(let[P,D]of Object.entries(m.messages))if(e.isReferenceObject(D)||e.isMessageWithPayload(D))if(c[P]||(c[P]=[]),e.isReferenceObject(D)){let A=e.resolveMessageReference(D);c[P].push({channelId:O,payload:A.payload})}else c[P].push({channelId:O,payload:D.payload})}for(let[O,m]of Object.entries(c))if(m.length===1){let P=m[0],D=P.channelId;u[D]=u[D]||{},u[D][O]=s0(P.payload,!1,e,[O],r,e.namespace)}else{d.push(O);for(let{channelId:P,payload:D}of m){let A=`${P}_${O}`;u[P]||(u[P]={}),u[P][A]=s0(D,!1,e,[A],r,e.namespace)}}let o=Object.values(u).reduce((O,m)=>({...O,...m}),{}),l=new DKn(o,e),b={};for(let[O,m]of Object.entries(n.servers??{}))b[O]={name:O,url:Eau(m.protocol,m.host)};let g={};for(let[O,m]of Object.entries(n.operations??{})){if(hf(m,Fee.IGNORE))continue;let P=eBE(m);if(g[P]||(g[P]={subscribe:[],publish:[],__parsedMessages:[]}),m.action==="receive")g[P].subscribe.push(...m.messages);else if(m.action==="send")g[P].publish.push(...m.messages);else throw new Error(`Operation ${O} has an invalid action: ${m.action}`)}for(let[O,m]of Object.entries(g)){let P=[];P.push(...Wj_({messages:m.subscribe,channelPath:O,origin:"server",messageSchemas:u[O]??{},duplicatedMessageIds:d,context:e})),P.push(...Wj_({messages:m.publish,channelPath:O,origin:"client",messageSchemas:u[O]??{},duplicatedMessageIds:d,context:e})),g[O]!=null&&(g[O].__parsedMessages=P)}for(let[O,m]of Object.entries(n.channels??{})){if(hf(m,Fee.IGNORE))continue;let P=[],D=[],A=[];if(m.parameters!=null)for(let[M,E]of Object.entries(m.parameters)){let T=e.isReferenceObject(E)?e.resolveParameterReference(E):E,{type:z,parameterKey:$}=T.location!=null?tBE(T.location):{type:m.address?.includes(`={${M}}`)?"query":"path",parameterKey:M},I=hf(T,Fee.FERN_PARAMETER_OPTIONAL),N=eI(F_(O))+eI(F_(M)),U={...T,type:"string",title:N,example:T.examples?.[0],default:T.default,enum:T.enum,required:void 0},Y=s0(U,!1,e,[$],r,e.namespace);I&&(Y=Nl.optional({value:Y,description:void 0,availability:void 0,generatedName:"",title:N,namespace:void 0,groupName:void 0,nameOverride:void 0,inline:void 0}));let J={name:$,description:T.description,parameterNameOverride:void 0,schema:Y,variableReference:void 0,availability:UK(E),source:r};z==="header"?P.push({...J,env:void 0}):z==="path"?D.push(J):(z==="payload"||z==="query")&&A.push(J)}if(P.length>0||A.length>0||g[O]!=null&&(g[O].publish!=null||g[O].subscribe!=null)){let M=Dau(m),E=g[O]?.__parsedMessages??[],T=[];if(M.length>0)T=l.buildWebsocketSessionExamplesForExtension({context:e,extensionExamples:M,handshake:{headers:P,queryParameters:A},source:r,namespace:e.namespace});else{let z=[],{examplePublishMessage:$,exampleSubscribeMessage:I}=iBE({messages:E,messageSchemas:u[O]??{}});$!=null&&z.push($),I!=null&&z.push(I);let N=l.buildWebsocketSessionExample({handshake:{headers:P,queryParameters:A},messages:z});N!=null&&T.push(N)}s[O]={audiences:hf(m,ad.AUDIENCES)??[],handshake:{headers:P.map(z=>({...z,schema:DA(z.schema),env:z.env})),queryParameters:A.map(z=>({...z,schema:DA(z.schema)})),pathParameters:D.map(z=>({...z,parameterNameOverride:void 0,schema:DA(z.schema)}))},groupName:e.resolveGroupName([hf(m,Fee.FERN_SDK_GROUP_NAME)??O]),messages:E,summary:hf(m,Fee.FERN_DISPLAY_NAME),servers:m.servers?.map(z=>rBE(b,z))??Object.values(b),path:m.address?.split("?")[0]??Mau(O),description:m.description,examples:T,source:r}}}return{groupedSchemas:SKn(e.namespace,a),channels:s,servers:Object.values(b),basePath:hf(n,Fee.BASE_PATH)}}function eBE(e){if(!e.channel.$ref.startsWith(Uj_))throw new Error(`Failed to resolve channel path from operation ${e.channel.$ref}`);return e.channel.$ref.substring(Uj_.length)}function tBE(e){try{let[t,r]=e.split("#/");if(t==null||r==null)throw new Error(`Invalid location format: ${e}; unable to parse message type and parameter key`);if(!t.startsWith(rSc))throw new Error(`Invalid location format: ${e}; expected ${rSc} prefix`);let i=t.substring(rSc.length);if(i!=="header"&&i!=="path"&&i!=="payload")throw new Error(`Invalid message type: ${i}. Must be one of: header, path, payload`);return{type:i,parameterKey:r}}catch{throw new Error(`Invalid location format: ${e}; see here for more details: https://www.asyncapi.com/docs/reference/specification/v3.0.0#runtimeExpression`)}}function rBE(e,t){if(!t.$ref.startsWith(Vj_))throw new Error(`Failed to resolve server name from server ref ${t.$ref}`);let r=t.$ref.substring(Vj_.length),i=e[r];if(i==null)throw new Error(`Failed to find server with name ${r}`);return i}function Wj_({messages:e,channelPath:t,origin:r,messageSchemas:i,duplicatedMessageIds:n,context:a}){let u=[];return e.forEach((c,d)=>{let o=a.resolveMessageReference(c).name;n.includes(o)&&(o=`${t}_${o}`);let l=i[o];l!=null&&u.push({origin:r,name:o??`${r}Message${d+1}`,body:DA(l)})}),u}function iBE({messages:e,messageSchemas:t}){let r=e.find(u=>u.origin==="client")?.name,i=e.find(u=>u.origin==="server")?.name,n=r!=null?t[r]:void 0,a=i!=null?t[i]:void 0;return{examplePublishMessage:n!=null&&r!=null?{type:r,payload:n}:void 0,exampleSubscribeMessage:a!=null&&i!=null?{type:i,payload:a}:void 0}}function $j_({document:e,taskContext:t,options:r,source:i,asyncApiOptions:n,namespace:a}){let u=[];if(a!=null&&u.push(a),parseFloat(e.asyncapi)<3){let c=e;c.tags?.[0]!=null?u.push(c.tags[0].name):n.naming!=="v2"&&u.push("websocket");let d=new jau({document:c,taskContext:t,options:r,namespace:a});return Lj_({context:d,breadcrumbs:u,source:i,asyncApiOptions:n,document:c})}else{let c=e,d=new Aau({document:c,taskContext:t,options:r,namespace:a});return Hj_({context:d,breadcrumbs:u,source:i,asyncApiOptions:n,document:c})}}function Gj_(e){return hf(e,ad.ASYNC_CONFIG)}var Qj_="$request.";function Jj_(e){let t=hf(e,ad.STREAMING);if(t!=null)return typeof t=="boolean"?t?{type:"stream",format:"json"}:void 0:t["stream-condition"]==null&&t.format!=null?{type:"stream",format:t.format}:{type:"streamCondition",format:t.format??"json",streamDescription:t["stream-description"],streamConditionProperty:nBE(t["stream-condition"]),responseStream:t["response-stream"],response:t.response}}function nBE(e){return e.startsWith(Qj_)?e.slice(Qj_.length):e}function Kj_(e){let t=e;if(t.cursor!=null)return DFe.cursor({cursor:t.cursor,nextCursor:t.next_cursor,results:t.results});if("offset"in e){let r=e;return DFe.offset({offset:r.offset,results:r.results,step:r.step,hasNextPage:r["has-next-page"]})}if("type"in e&&e.type==="custom"){let r=e;return DFe.custom({results:r.results})}throw new Error("Invalid pagination extension")}function Yj_(e,t){let r=hf(t,ad.PAGINATION);if(r!=null){if(typeof r=="boolean"){let i=hf(e,ad.PAGINATION);if(typeof i=="boolean")throw new Error("Global pagination extension is a boolean, expected an object. Only endpoints may declare a boolean for x-fern-pagination.");return i==null?void 0:Kj_(i)}return Kj_(r)}}function Xj_(e){let t=aBE(e),r={};return iSc({obj:t,occurrences:r,breadcrumbs:[]}),r}function iSc({obj:e,occurrences:t,breadcrumbs:r}){if(e!=null){if(Array.isArray(e)){for(let i of e)iSc({obj:i,occurrences:t,breadcrumbs:r});return}if(typeof e=="object"){if(e.$ref!=null&&typeof e.$ref=="string"){let i=e.$ref;t[i]==null?t[i]=1:t[i]+=1;return}for(let i in e)iSc({obj:e[i],occurrences:t,breadcrumbs:[...r,i]})}}}function aBE(e){return{...e,paths:Object.fromEntries(Object.entries(e.paths??{}).map(([t,r])=>[t,{...r,get:r?.get!=null?L5a(r.get):void 0,put:r?.put!=null?L5a(r.put):void 0,post:r?.post!=null?L5a(r.post):void 0,patch:r?.patch!=null?L5a(r.patch):void 0,delete:r?.delete!=null?L5a(r.delete):void 0}]))}}function L5a(e){return{...e,requestBody:e.requestBody!=null?tp(e.requestBody)?e.requestBody:oBE(e.requestBody):void 0}}function oBE(e){let t,r;for(let i in e.content){let n=Uq.parse(i);n!=null&&(n.isJSON()?t=e.content[i]:n.isMultipart()&&(r=e.content[i]))}return r!=null&&t!=null?{...e,content:{[Uq.MULTIPART_FORM_DATA]:r}}:e}var qau=class{endpoints;parser=new jen;constructor({context:t,options:r}){this.endpoints=r.filter?.endpoints?new Set(this.validateAndFilterEndpoints({context:t,endpoints:r.filter.endpoints})):void 0}skipEndpoint({method:t,path:r}){return this.endpoints!=null&&!this.endpoints.has(`${t} ${r}`)}hasEndpoints(){return this.endpoints!=null}validateAndFilterEndpoints({context:t,endpoints:r}){let i=[];for(let n of r){let a=this.parser.tryParse(n);if(a==null){t.logger.debug(`Ignoring configured filter endpoint "${n}"; expected format "POST /users/get"`);continue}i.push(`${a.method} ${a.path}`)}return i}};var Zj_="#/components/parameters/",kj_="#/components/responses/",ew_="#/components/examples/",tw_="#/components/requestBodies/",EKn=class{logger;document;taskContext;authHeaders;refOccurrences;DUMMY;options;source;filter;namespace;constructor({document:t,taskContext:r,authHeaders:i,options:n,source:a,namespace:u}){this.document=t,this.logger=r.logger,this.taskContext=r,this.authHeaders=i,this.refOccurrences=Xj_(t),this.options=n,this.source=a,this.filter=new qau({context:r,options:n}),this.DUMMY=this.getDummy(),this.namespace=u}getNumberOfOccurrencesForRef(t){return this.refOccurrences[t.$ref]??0}resolveTagsToTagIds(t){let r=[];return this.namespace!=null&&r.push(this.namespace),r.concat(t??[])}resolveTags(t){let r=[];if(this.namespace!=null){let i={type:"namespace",name:this.namespace};r.push(i)}return r.concat(t??[])}resolveGroupName(t){return this.namespace!=null?[{type:"namespace",name:this.namespace},...t]:t}resolveSchemaReference(t){let r=t.$ref.substring(2).split("/").map(n=>n.replace(/~1/g,"/")),i=this.document;for(let n of r){if(typeof i!="object"||i==null)return{"x-fern-type":"unknown"};if(Array.isArray(i)){let a=parseInt(n,10);if(isNaN(a)||a<0||a>=i.length)return{"x-fern-type":"unknown"};i=i[a]}else i=i[n]}return i==null?(this.logger.warn(`Encountered undefined reference: ${t.$ref}`),{"x-fern-type":"unknown"}):(tp(i)&&(i=this.resolveSchemaReference(i)),i)}resolveParameterReference(t){if(this.document.components==null||this.document.components.parameters==null||!t.$ref.startsWith(Zj_))throw new Error(`Failed to resolve ${t.$ref}`);let r=t.$ref.substring(Zj_.length),i=this.document.components.parameters[r];if(i==null)throw new Error(`${t.$ref} is undefined`);return tp(i)?this.resolveParameterReference(i):i}resolveRequestBodyReference(t){if(this.document.components==null||this.document.components.requestBodies==null||!t.$ref.startsWith(tw_))throw new Error(`Failed to resolve ${t.$ref}`);let r=t.$ref.substring(tw_.length),i=this.document.components.requestBodies[r];if(i==null)throw new Error(`${t.$ref} is undefined`);return tp(i)?this.resolveRequestBodyReference(i):i}resolveResponseReference(t){if(this.document.components==null||this.document.components.responses==null||!t.$ref.startsWith(kj_))throw new Error(`Failed to resolve ${t.$ref}`);let r=t.$ref.substring(kj_.length),i=this.document.components.responses[r];if(i==null)throw new Error(`${t.$ref} is undefined`);return tp(i)?this.resolveResponseReference(i):i}resolveExampleReference(t){if(this.document.components==null||this.document.components.examples==null||!t.$ref.startsWith(ew_))throw new Error(`Failed to resolve ${t.$ref}`);let r=t.$ref.substring(ew_.length),i=this.document.components.examples[r];if(i==null)throw new Error(`${t.$ref} is undefined`);return tp(i)?this.resolveExampleReference(i):i}referenceExists(t){let r=t.substring(2).split("/").map(n=>n.replace(/~1/g,"/")),i=this.document;for(let n of r){if(typeof i!="object"||i==null)return!1;i=i[n]}return!0}};var Jnn=class extends EKn{constructor({document:t,taskContext:r,options:i,source:n,namespace:a}){super({document:t,taskContext:r,authHeaders:new Set,options:i,source:n,namespace:a})}getDummy(){return this}markSchemaAsReferencedByNonRequest(t){}markSchemaAsReferencedByRequest(t){}getReferencedSchemas(){return new Set}markReferencedByDiscriminatedUnion(t,r,i){}getReferencesFromDiscriminatedUnion(t){}excludeSchema(t){}isSchemaExcluded(t){return!1}markSchemaWithDiscriminantValue(t,r,i){}getDiscriminatedUnionMetadata(t){}};var uBE=ou.object({lang:ou.string(),label:ou.optional(ou.string()),source:ou.string()}),nSc=ou.array(uBE);var rw_={README_EXT:"x-readme"};function sBE(e){if(!Array.isArray(e))return!1;for(let t of e)if(!Rw(t)||typeof t.language!="string"||typeof t.code!="string")return!1;return!0}function iw_(e){let t=hf(e,rw_.README_EXT);if(!Rw(t))return[];let r=t["code-samples"];if(!sBE(r))return[];let i=[];for(let n of r)i.push({name:n.name,language:n.language,code:n.code,install:n.install,docs:void 0});return i}function nw_(e,t,r){let n=(hf(t,ad.EXAMPLES)??[]).filter(s=>{let o=i7.serialization.ExampleEndpointCallSchema.parse(s);return o.ok||r.logger.error(`Failed to parse x-fern-example in ${e.path}/${e.method}`),o.ok}),a=x5a(t,M$.REDOCLY_CODE_SAMPLES_KEBAB,nSc,r.logger,[...e.baseBreadcrumbs,`${e.method} ${e.path}`])??[],c=[...x5a(t,M$.REDOCLY_CODE_SAMPLES_CAMEL,nSc,r.logger,[...e.baseBreadcrumbs,`${e.method} ${e.path}`])??[],...a];c.length>0&&n.push({"code-samples":c.map(s=>({name:s.label??s.lang,language:s.lang,code:s.source,install:void 0,docs:void 0}))});let d=iw_(t);return d.length>0&&n.push({"code-samples":d}),n.map(UQt.unknown)}function aw_(e){let t=hf(e,ad.AVAILABILITY);if(t==="ga"||t==="generally-available")return S$.GenerallyAvailable;if(t==="beta"||t==="pre-release")return S$.Beta;if(t==="deprecated")return S$.Deprecated;if(e.deprecated)return S$.Deprecated}function Tau(e){return{url:cBE({url:e.url,variables:e.variables??{}}),description:e.description,name:lBE(e),audiences:hf(e,ad.AUDIENCES)}}function cBE({url:e,variables:t}){let r=Object.fromEntries(Object.entries(t).map(([i,n])=>[i,n.default]));for(let[i,n]of Object.entries(r))e=e.replace(`{${i}}`,encodeURIComponent(n));return e}function lBE(e){let t=hf(e,[ad.SERVER_NAME_V1,ad.SERVER_NAME_V2]);if(t!=null)return t;if(e.description?.toLowerCase()==="production")return"Production";if(e.description?.toLowerCase()==="sandbox")return"Sandbox"}function ow_(e){return hf(e,ad.PARAMETER_NAME)}function uw_(e){return hf(e,ad.SDK_VARIABLE)}function Cau({path:e,httpMethod:t,parameters:r,context:i,requestBreadcrumbs:n,source:a}){let u={pathParameters:[],queryParameters:[],headers:[]};for(let c of r){let d=hf(c,ad.IGNORE);if(d!=null&&d){i.logger.debug(`${t.toUpperCase()} ${e} has a parameter marked with x-fern-ignore. Skipping.`);continue}let s=tp(c)?i.resolveParameterReference(c):c,o=s.required??!1,l=UK(s),b=[...n,s.name],g=D5(b,i.options.preserveSchemaIds),O=s.schema!=null?s0(s.schema,!o,i,b,a,i.namespace,!1,new Set,vor({schema:s,logger:i.logger})):o?Nl.primitive({nameOverride:void 0,generatedName:g,title:void 0,schema:bp.string({default:void 0,pattern:void 0,format:void 0,minLength:void 0,maxLength:void 0,example:vor({schema:s,logger:i.logger})}),description:void 0,availability:l,namespace:void 0,groupName:void 0}):Nl.optional({nameOverride:void 0,generatedName:g,title:void 0,value:Nl.primitive({nameOverride:void 0,generatedName:g,title:void 0,schema:bp.string({default:void 0,pattern:void 0,format:void 0,minLength:void 0,maxLength:void 0,example:vor({schema:s,logger:i.logger})}),description:void 0,availability:void 0,namespace:void 0,groupName:void 0}),description:void 0,availability:l,namespace:void 0,groupName:void 0,inline:void 0});if(s.in==="header"&&s.schema!=null&&!tp(s.schema)&&s.schema.default!=null){let P=s.schema.default;typeof P=="string"&&P.length>0&&(O=Nl.literal({nameOverride:void 0,generatedName:g,title:void 0,value:mx.string(P),description:void 0,availability:l,namespace:void 0,groupName:void 0}))}let m={name:s.name,schema:O,description:s.description,parameterNameOverride:ow_(s),availability:l,source:a};s.in==="query"?u.queryParameters.push(m):s.in==="path"?u.pathParameters.push({...m,variableReference:uw_(s)}):s.in==="header"?!fBE.has(s.name.toLowerCase())&&!i.authHeaders.has(s.name)?u.headers.push({...m,env:void 0}):i.logger.debug(`Ignoring ${s.name} header, in ${t.toUpperCase()} ${e}`):i.logger.warn(`Skipping ${s.in} parameter, ${s.name}, in ${t.toUpperCase()} ${e}`)}return u}var fBE=new Set(["user-agent","content-length","content-type","x-forwarded-for","cookie","origin","content-disposition","x-ping-custom-domain"]);function sw_(e,t){for(let r of Object.keys(e))if(r.includes("text/event-stream")){let i=e[r];if(i==null)continue;let n=i.schema;return{contentType:r,schema:n??{},examples:U5a(i,t)}}}function dBE(e){return e.includes("json")||e==="*/*"}function aSc({content:e,context:t}){for(let[r,i]of Object.entries(e))if(Bau({mediaType:r,mediaTypeObject:i,context:t})!=null)return[r,i]}function Bau({mediaType:e,mediaTypeObject:t,context:r}){if(!dBE(e))return;let i=t.schema;return{contentType:e.includes("*")?void 0:e,schema:i??{},examples:U5a(t,r)}}function Iau({content:e,context:t}){let r=aSc({content:e,context:t});if(!r)return;let[i,n]=r;return Bau({mediaType:i,mediaTypeObject:n,context:t})}function cw_(e,t){for(let r of Object.keys(e)){let i=e[r];if(i==null)continue;return{schema:i.schema??{},examples:U5a(i,t)}}}function U5a(e,t){let r=[];e.example!=null&&r.push({name:void 0,value:e.example,description:void 0});let i=hf(e,M$.EXAMPLES);return i!=null&&Object.keys(i).length>0&&r.push(...Object.entries(i).map(([n,a])=>({name:a.summary??n,value:a.value,description:a.description}))),e.examples!=null&&Object.keys(e.examples).length>0&&r.push(...Object.entries(e.examples).map(([n,a])=>{let u=tp(a)?t.resolveExampleReference(a):a;return{name:u.summary??n,value:u.value,description:u.description}})),r}function pBE({content:e,context:t}){for(let[r,i]of Object.entries(e))if(fw_({mediaType:r,mediaTypeObject:i,context:t}))return[r,i]}function fw_({mediaType:e,mediaTypeObject:t,context:r}){if(Uq.parse(e)?.isURLEncoded())return{schema:t.schema,contentType:e,examples:U5a(t,r)}}function _BE({content:e}){for(let[t,r]of Object.entries(e))if(dw_({mediaType:t,mediaTypeObject:r}))return[t,r]}function dw_({mediaType:e,mediaTypeObject:t}){if(Uq.parse(e)?.isMultipart())return{schema:t.schema,encoding:t.encoding}}function pw_({mediaType:e}){return Uq.parse(e)?.isBinary()??!1}function hBE({content:e}){for(let[t,r]of Object.entries(e))if(pw_({mediaType:t}))return[t,r]}function yBE(e,t){let r=tp(e)?oSc(e,t):{id:void 0,schema:e};return Object.entries(r.schema.properties??{}).find(([i,n])=>!tp(n)&&n.type==="string"&&n.format==="binary")!=null}function xau({content:e,description:t,document:r,context:i,requestBreadcrumbs:n,source:a,namespace:u}){let c=hBE({content:e});if(c){let[b,g]=c;return bor({mediaType:b,mediaTypeObject:g,description:t,document:r,context:i,requestBreadcrumbs:n,source:a,namespace:u})}let d=_BE({content:e}),s=aSc({content:e,context:i}),o=vBE({json:s,multipart:d,document:r,visitor:{json:([b,g])=>bor({mediaType:b,mediaTypeObject:g,description:t,document:r,context:i,requestBreadcrumbs:n,source:a,namespace:u}),multipart:([b,g])=>bor({mediaType:b,mediaTypeObject:g,description:t,document:r,context:i,requestBreadcrumbs:n,source:a,namespace:u}),neither:()=>{}}});if(o)return o;let l=pBE({content:e,context:i});if(l){let[b,g]=l;return bor({mediaType:b,mediaTypeObject:g,description:t,document:r,context:i,requestBreadcrumbs:n,source:a,namespace:u})}}function vBE({json:e,multipart:t,document:r,visitor:i}){if(!e&&!t)return i.neither();let[,n]=e??[void 0,void 0],[,a]=t??[void 0,void 0];return!n?.schema&&!a?.schema?i.neither():n?.schema&&a?.schema?n.schema&&yBE(n.schema,r)?i.multipart(t):i.json(e):n?.schema?i.json(e):a?.schema?i.multipart(t):i.neither()}function bor({mediaType:e,mediaTypeObject:t,description:r,document:i,context:n,requestBreadcrumbs:a,source:u,namespace:c}){let d=bBE({mediaTypeObject:t});if(pw_({mediaType:e}))return zee.octetStream({description:r,source:u,sdkMethodName:d,contentType:e});let s=dw_({mediaType:e,mediaTypeObject:t}),o=s?.schema,l=s?.encoding;if(o){let O=tp(o)?oSc(o,i):{id:void 0,schema:o},m=s0(O.schema,!1,n,a,u,c,!1),P=[];if(m.type==="object")for(let D of m.properties){let{isFile:A,isOptional:M,isArray:E,description:T}=zau({schema:D.schema});if(A){let z=lw_(D.key,l);P.push({key:D.key,schema:Wmi.file({isOptional:M,isArray:E,description:T}),description:T,contentType:z,exploded:!1,encoding:z==null?n.options.defaultFormParameterEncoding:void 0})}else{let z=lw_(D.key,l);P.push({key:D.key,schema:Wmi.json(D.schema),description:void 0,contentType:z,exploded:l?.[D.key]?.explode,encoding:z==null?n.options.defaultFormParameterEncoding:OBE(z)})}}return zee.multipart({name:tp(o)&&n.getNumberOfOccurrencesForRef(o)===1?O.id:void 0,description:O.schema.description,properties:P,source:u,sdkMethodName:d})}let b=Bau({mediaType:e,mediaTypeObject:t,context:n});if(b){let O=s0(b.schema,!1,n,a,u,c,!0);return zee.json({description:void 0,schema:O,contentType:b.contentType,fullExamples:b.examples,additionalProperties:!tp(b.schema)&&OKn(b.schema.additionalProperties,n.options),source:u,sdkMethodName:d})}let g=fw_({mediaType:e,mediaTypeObject:t,context:n});if(g!=null&&g.schema!=null){let O=s0(g.schema,!1,n,a,u,c,!1);return zee.formUrlEncoded({schema:O,description:r,contentType:g.contentType,source:u,fullExamples:g.examples,additionalProperties:!1,sdkMethodName:d})}}function bBE({mediaTypeObject:e}){return hf(e,ad.SDK_METHOD_NAME)}var gBE={"application/json":"json"};function OBE(e){return e?gBE[e]:void 0}function oSc(e,t){if(!e.$ref.startsWith(Qnn))throw new Error(`Failed to resolve schema reference because of unsupported prefix: ${e.$ref}`);let r=xNi(e);if(r==null)throw new Error(`Failed to resolve schema reference because missing schema id: ${e.$ref}`);let i=t.components?.schemas?.[r];if(i==null)throw new Error(`Failed to resolve schema reference because missing: ${e.$ref}`);return tp(i)?oSc(i,t):{id:r,schema:i}}function zau({schema:e,isOptional:t,isArray:r,description:i}){return PBE(e)?zau({schema:e.value,isOptional:!0,isArray:r,description:e.description}):jBE(e)?zau({schema:e.value,isOptional:t,isArray:r,description:e.description}):wBE(e)?zau({schema:e.value,isOptional:t,isArray:!0,description:e.description}):mBE(e)?{isFile:!0,isOptional:t??!1,isArray:r??!1,description:i??e.description}:{isFile:!1,isOptional:t??!1,isArray:r??!1,description:void 0}}function mBE(e){return e.type==="primitive"&&e.schema.type==="string"&&e.schema.format==="binary"}function PBE(e){return e.type==="optional"}function jBE(e){return e.type==="nullable"}function wBE(e){return e.type==="array"}function lw_(e,t){return t?.[e]?.contentType}var uSc={400:"BadRequestError",401:"UnauthorizedError",402:"PaymentRequiredError",403:"ForbiddenError",404:"NotFoundError",405:"MethodNotAllowedError",406:"NotAcceptableError",407:"ProxyAuthenticationRequiredError",408:"RequestTimeoutError",409:"ConflictError",410:"GoneError",411:"LengthRequiredError",412:"PreconditionFailedError",413:"ContentTooLargeError",414:"URITooLongError",415:"UnsupportedMediaTypeError",416:"RangeNotSatisfiableError",417:"ExpectationFailedError",418:"ImATeapotError",419:"AuthenticationTimeoutError",420:"MethodFailureError",421:"MisdirectedRequestError",422:"UnprocessableEntityError",423:"LockedError",424:"FailedDependencyError",425:"TooEarlyError",426:"UpgradeRequiredError",428:"PreconditionError",429:"TooManyRequestsError",430:"RequestHeaderFieldsTooLargeError",431:"RequestHeaderFieldsTooLargeError",444:"NoResponseError",449:"RetryWithError",450:"BlockedByWindowsParentalControlsError",451:"UnavailableForLegalReasonsError",498:"InvalidTokenError",499:"ClientClosedRequestError",500:"InternalServerError",501:"NotImplementedError",502:"BadGatewayError",503:"ServiceUnavailableError",504:"GatewayTimeoutError",505:"HTTPVersionNotSupportedError",506:"VariantAlsoNegotiatesError",507:"InsufficientStorageError",508:"LoopDetectedError",509:"BandwidthLimitExceededError",510:"NotExtendedError",511:"NetworkAuthenticationRequiredError"},_w_=new Set(Object.values(uSc));var SBE=["200","201","202","204"];function yw_({operationContext:e,responses:t,context:r,responseBreadcrumbs:i,responseStatusCode:n,streamFormat:a,source:u}){if(t==null)return{value:void 0,errors:{}};let c=DBE({responses:t,context:r,source:u,namespace:r.namespace}),d=!1,s;for(let o of n!=null?[n]:SBE){let l=t[o];l!=null&&(d=!0,s==null&&(s=hw_({operationContext:e,response:l,context:r,responseBreadcrumbs:i,streamFormat:a,source:u,namespace:r.namespace,statusCode:typeof o=="string"?parseInt(o):o})))}if(s==null&&!d&&t.default!=null&&(s=hw_({operationContext:e,response:t.default,context:r,responseBreadcrumbs:i,streamFormat:a,source:u,namespace:r.namespace})),s!=null)switch(s.type){case"json":return{value:s,errors:c};case"streamingJson":case"streamingSse":return{value:s,errors:c};case"bytes":case"file":case"text":case"streamingText":return{value:s,errors:c};default:Ao(s)}return{value:void 0,errors:c}}function hw_({operationContext:e,streamFormat:t,response:r,context:i,responseBreadcrumbs:n,source:a,namespace:u,statusCode:c}){let d=tp(r)?i.resolveResponseReference(r):r;if(d.content!=null&&Object.entries(d.content).find(([b,g])=>{if(g.schema==null)return!1;let O=tp(g.schema)?i.resolveSchemaReference(g.schema):g.schema;return O.type==="string"&&O.format==="binary"}))return i.options.useBytesForBinaryResponse&&t==null?EB.bytes({description:d.description,source:a,statusCode:c}):EB.file({description:d.description,source:a,statusCode:c});let s=sw_(d.content??{},i);if(s!=null&&t!=null)switch(t){case"json":return EB.streamingJson({statusCode:c,description:d.description,responseProperty:hf(e.operation,ad.RESPONSE_PROPERTY),fullExamples:s.examples,schema:s0(s.schema,!1,i,n,a,u),source:a});case"sse":return EB.streamingSse({description:d.description,responseProperty:void 0,fullExamples:s.examples,schema:s0(s.schema,!1,i,n,a,u),source:a,statusCode:c})}let o=Iau({context:i,content:d.content??{}});if(o){if(t!=null)switch(t){case"json":return EB.streamingJson({description:d.description,responseProperty:void 0,fullExamples:o.examples,schema:s0(o.schema,!1,i,n,a,u),source:a,statusCode:c});case"sse":return EB.streamingSse({description:d.description,responseProperty:void 0,fullExamples:o.examples,schema:s0(o.schema,!1,i,n,a,u),source:a,statusCode:c})}return EB.json({description:d.description,schema:s0(o.schema,!1,i,n,a,u),responseProperty:hf(e.operation,ad.RESPONSE_PROPERTY),fullExamples:o.examples,source:a,statusCode:c})}for(let[l,b]of Object.entries(d.content??{})){let g=Uq.parse(l);if(g!=null){if(g.isOctetStream()||g.isPDF()||g.isAudio()||g.isImage()||g.isVideo()||g.isMultiPartMixed())return EB.file({description:d.description,source:a,statusCode:c});if(g.isPlainText()){let O=b.schema;if(O==null)return EB.text({description:d.description,source:a,statusCode:c});let m=tp(O)?i.resolveSchemaReference(O):O;return m.type==="string"&&m.format==="byte"?EB.file({description:d.description,source:a,statusCode:c}):EB.text({description:d.description,source:a,statusCode:c})}}}}function DBE({responses:e,context:t,source:r,namespace:i}){let n={};for(let[a,u]of Object.entries(e)){if(a==="default")continue;let c=parseInt(a);if(c<400||c>600)continue;let d=tp(u)?t.resolveResponseReference(u):u,s=cw_(d.content??{},t),o=uSc[c];if(o==null){t.logger.warn(`No error name found for status code ${a}`);continue}n[c]={statusCode:c,nameOverride:void 0,generatedName:o,description:d.description,schema:s0(s?.schema??{},!1,t,[o,"Body"],r,i),fullExamples:s?.examples,source:r}}return n}function Kmi({operationContext:e,context:t,responseStatusCode:r,suffix:i,streamFormat:n,source:a}){let{document:u,operation:c,path:d,method:s,baseBreadcrumbs:o}=e,l=hf(c,ad.IDEMPOTENT),b=hf(c,[ad.REQUEST_NAME_V1,ad.REQUEST_NAME_V2]),g=[...o,"Request"],O=Cau({parameters:[...e.pathItemParameters,...e.operationParameters],context:t,requestBreadcrumbs:g,path:d,httpMethod:s,source:a}),m=/{([^}]+)}/g,D=[...d.matchAll(m)].map(I=>I[1]).filter(I=>!O.pathParameters.some(N=>N.name===I));if(D.length>0)for(let I of D)O.pathParameters.push({name:I??"",variableReference:void 0,parameterNameOverride:void 0,availability:void 0,source:a,schema:Nl.primitive({schema:bp.string({default:void 0,example:void 0,format:void 0,maxLength:void 0,minLength:void 0,pattern:void 0}),description:void 0,generatedName:"",nameOverride:void 0,namespace:void 0,groupName:void 0,availability:void 0,title:void 0}),description:void 0});let A=(()=>{if(e.method==="GET")return[void 0];if(!c.requestBody)return[void 0];let I=tp(c.requestBody)?t.resolveRequestBodyReference(c.requestBody):c.requestBody,N=Object.values(I.content).every(Y=>EBE({mediaTypeObject:Y})!=null),U=[];if(N)return U.push(...Object.entries(I.content).map(([Y,J])=>{let X=bor({mediaType:Y,mediaTypeObject:J,description:I.description,document:u,context:new Jnn({document:t.document,taskContext:t.taskContext,options:t.options,source:t.source,namespace:t.namespace}),requestBreadcrumbs:g,source:a,namespace:t.namespace});return vw_({context:t,convertedParameters:O})&&X!=null&&(X.type==="json"||X.type==="formUrlEncoded")&&X.schema.type!=="object"&&c.requestBody!=null?X=bor({mediaType:Y,mediaTypeObject:J,description:I.description,document:u,context:t,requestBreadcrumbs:[...g,"Body"],source:a,namespace:t.namespace}):c.requestBody!=null&&(X=bor({mediaType:Y,mediaTypeObject:J,description:I.description,document:u,context:t,requestBreadcrumbs:[...g],source:a,namespace:t.namespace})),X}).filter(Y=>Y!=null)),U.length===0?[void 0]:U;{let Y=xau({content:I.content,description:I.description,document:u,context:new Jnn({document:t.document,taskContext:t.taskContext,options:t.options,source:t.source,namespace:t.namespace}),requestBreadcrumbs:g,source:a,namespace:t.namespace});return vw_({context:t,convertedParameters:O})&&Y!=null&&(Y.type==="json"||Y.type==="formUrlEncoded")&&Y.schema.type!=="object"&&c.requestBody!=null?Y=xau({content:I.content,description:I.description,document:u,context:t,requestBreadcrumbs:[...g,"Body"],source:a,namespace:t.namespace}):c.requestBody!=null&&(Y=xau({content:I.content,description:I.description,document:u,context:t,requestBreadcrumbs:[...g],source:a,namespace:t.namespace})),[Y]}})(),M=[...o,"Response"],E=yw_({operationContext:e,streamFormat:n,responses:c.responses,context:t,responseBreadcrumbs:M,responseStatusCode:r,source:a}),T=aw_(c),z=nw_(e,c,t),$=hf(c,ad.SERVER_NAME_V2);return A.map(I=>({summary:c.summary,internal:hf(c,M$.INTERNAL),idempotent:l,audiences:hf(c,ad.AUDIENCES)??[],operationId:c.operationId!=null&&i!=null?c.operationId+"_"+i:c.operationId,tags:t.resolveTagsToTagIds(c.tags),namespace:t.namespace,sdkName:MBE({operationContext:e,request:I}),pathParameters:O.pathParameters,queryParameters:O.queryParameters,headers:O.headers,requestNameOverride:b??void 0,generatedRequestName:D5(g,t.options.preserveSchemaIds),request:I,response:E.value,errors:E.errors,servers:$!=null?[{name:$,url:void 0,audiences:void 0}]:(c.servers??[]).map(N=>Tau(N)),description:c.description,authed:ABE(c,u),availability:T,method:s,path:d,examples:z,pagination:e.pagination,source:a}))}function EBE({mediaTypeObject:e}){return hf(e,ad.SDK_METHOD_NAME)}function MBE({operationContext:e,request:t}){return!t||!t.sdkMethodName?e.sdkMethodName:e.sdkMethodName?{groupName:[...e.sdkMethodName.groupName],methodName:t.sdkMethodName??e.sdkMethodName.methodName}:{groupName:[],methodName:t.sdkMethodName}}function ABE(e,t){return e.security!=null?Object.keys(e.security).length>0:t.security!=null?Object.keys(t.security).length>0:!1}function vw_({context:e,convertedParameters:t}){return e.options.inlinePathParameters&&t.pathParameters.length>0||t.queryParameters.length>0||t.headers.length>0}function gw_({operationContext:e,context:t,asyncExtension:r,source:i}){let{operation:n,pathItemParameters:a,operationParameters:u}=e,c=r.discriminant.name,d=r.discriminant.value,s=r["response-status-code"],o=bw_({context:t,headerToIgnore:c,parameters:a}),l=bw_({context:t,headerToIgnore:c,parameters:u}),b=Kmi({operationContext:{...e,pathItemParameters:o,operationParameters:l,operation:{...n,responses:Object.fromEntries(Object.entries(n.responses).filter(([O])=>parseInt(O)!==s))}},context:t,streamFormat:void 0,source:i}),g=Kmi({operationContext:{...e,pathItemParameters:o,operationParameters:l,baseBreadcrumbs:[...e.baseBreadcrumbs,"async"]},context:t,suffix:"async",responseStatusCode:s,streamFormat:void 0,source:i});return g.forEach(O=>{O.headers.push({name:c,schema:Nl.literal({nameOverride:void 0,generatedName:D5([c],t.options.preserveSchemaIds),title:void 0,description:void 0,availability:void 0,value:mx.string(d),namespace:void 0,groupName:void 0}),description:void 0,parameterNameOverride:void 0,env:void 0,availability:void 0,source:i})}),{sync:b,async:g}}function bw_({context:e,headerToIgnore:t,parameters:r}){return r.filter(i=>{let n=tp(i)?e.resolveParameterReference(i):i;return!(n.in==="header"&&n.name===t)})}var sSc="stream";function jw_({operationContext:e,context:t,streamingExtension:r}){switch(r.type){case"stream":return{streaming:Kmi({operationContext:e,context:t,streamFormat:r.format,source:t.source}),nonStreaming:[]};case"streamCondition":{let i=Ow_({context:t,operation:e.operation,streamingExtension:r,isStreaming:!0});if(i?.schemaReference!=null){let s=xNi(i.schemaReference);s!=null&&t.excludeSchema(s)}let n=mw_({operation:e.operation,response:r.responseStream}),a=Kmi({operationContext:{...e,sdkMethodName:e.sdkMethodName!=null?{groupName:e.sdkMethodName.groupName,methodName:e.sdkMethodName.methodName+"_"+sSc}:void 0,operation:{...e.operation,description:r.streamDescription??e.operation.description,requestBody:i?.requestBody,responses:n},baseBreadcrumbs:[...e.baseBreadcrumbs,sSc]},context:t,streamFormat:r.format,suffix:sSc,source:t.source});a.forEach(s=>{s.examples=s.examples.filter(o=>Pw_(o,t)!==!1)});let u=Ow_({context:t,operation:e.operation,streamingExtension:r,isStreaming:!1}),c=mw_({operation:e.operation,response:r.response}),d=Kmi({streamFormat:void 0,operationContext:{...e,operation:{...e.operation,requestBody:u?.requestBody,responses:c}},context:t,source:t.source});return d.forEach(s=>{s.examples=s.examples.filter(o=>Pw_(o,t)!==!0)}),{streaming:a,nonStreaming:d}}default:Ao(r)}}function Ow_({context:e,operation:t,streamingExtension:r,isStreaming:i}){if(t.requestBody==null)return;let n=tp(t.requestBody)?e.resolveRequestBodyReference(t.requestBody):t.requestBody,a=Iau({content:n.content,context:e});if(a==null)return;let u=tp(a.schema)?e.resolveSchemaReference(a.schema):a.schema;if(u.allOf==null&&u.properties==null)return;let c=u.properties?.[r.streamConditionProperty];c!=null&&tp(c)&&(c=void 0);let d={...u,properties:{...u.properties,[r.streamConditionProperty]:{type:"boolean","x-fern-boolean-literal":i,...c??{}}},title:void 0,required:[...u.required??[],r.streamConditionProperty]};return{requestBody:{content:{[Uq.APPLICATION_JSON]:{schema:d}}},schemaReference:tp(a.schema)?a.schema:void 0}}function mw_({operation:e,response:t}){return{...e.responses,200:{description:"",content:{[Uq.APPLICATION_JSON]:{schema:t}}}}}function Pw_(e,t){return e._visit({unknown:r=>{let i=i7.serialization.ExampleEndpointCallSchema.parse(r);if(i.ok&&i.value.response!=null)return i.value.response.stream!=null},full:()=>{},_other:()=>{}})}function ww_({context:e,operationContext:t,source:r}){let{document:i,operation:n,path:a,method:u,baseBreadcrumbs:c,sdkMethodName:d}=t,s=[...c,"Payload"],o=Cau({parameters:[...t.pathItemParameters,...t.operationParameters],context:e,requestBreadcrumbs:s,path:a,httpMethod:u,source:r});if(n.requestBody==null)return e.logger.error(`Skipping webhook ${u.toUpperCase()} ${a}: Missing a request body`),[];let l=n.operationId;if(l==null)return e.logger.error(`Skipping webhook ${a} because no operation id present`),[];if(u!=="POST"&&u!=="GET")return e.logger.error(`Skipping webhook ${u.toUpperCase()} ${a}: Not POST or GET`),[];let b=tp(n.requestBody)?e.resolveRequestBodyReference(n.requestBody):n.requestBody;return Object.entries(b.content).map(([g,O])=>bor({mediaType:g,mediaTypeObject:O,description:b.description,document:i,context:e,requestBreadcrumbs:[...c,"Payload"],source:r,namespace:e.namespace})).filter(g=>g!=null).map(g=>{if(g==null||g.type!=="json"&&g.type!=="formUrlEncoded"){e.logger.error(`Skipping webhook ${a} because non-json and non-formUrlEncoded request body`);return}return{summary:n.summary,audiences:hf(n,ad.AUDIENCES)??[],sdkName:d,namespace:e.namespace,method:u,operationId:l,tags:e.resolveTagsToTagIds(n.tags),headers:o.headers,generatedPayloadName:D5(s,e.options.preserveSchemaIds),payload:g.schema,description:n.description,examples:qBE(g.fullExamples),source:r}}).filter(g=>g!=null)}function qBE(e){if(e==null)return[];let t=[];for(let r of e){let i=NNi(r.value);i!=null&&t.push({description:r.description,name:r.name,payload:i})}return t}function cSc({context:e,pathItemContext:t,operation:r,convertToWebhook:i}){let n=hf(r,ad.IGNORE);if(n!=null&&n){e.logger.debug(`${t.method.toUpperCase()} ${t.path} is marked with x-fern-ignore. Skipping.`);return}let a=TBE(r,e),u=Yj_(e.document,r),c={...t,sdkMethodName:a,baseBreadcrumbs:CBE({operation:r,sdkMethodName:a,httpMethod:t.method,path:t.path,shouldUseIdiomaticRequestNames:e.options.shouldUseIdiomaticRequestNames}),operation:r,operationParameters:r.parameters??[],pagination:u};if(i)return{type:"webhook",value:ww_({context:e,operationContext:c,source:e.source})};let d=Jj_(r);if(d!=null){let l=jw_({context:e,operationContext:c,streamingExtension:d});return l!=null?{type:"streaming",streaming:l.streaming,nonStreaming:l.nonStreaming}:void 0}let s=Gj_(r);if(s!=null){let l=gw_({context:e,operationContext:c,asyncExtension:s,source:e.source});return{type:"async",async:l.async,sync:l.sync}}return{type:"http",value:Kmi({context:e,operationContext:c,streamFormat:void 0,source:e.source})}}function TBE(e,t){let r=hf(e,ad.SDK_METHOD_NAME),i=hf(e,ad.SDK_GROUP_NAME)??[];if(r!=null){let n=typeof i=="string"?[i]:i;return n=t.resolveGroupName(n),{groupName:n,methodName:r}}}function CBE({sdkMethodName:e,operation:t,httpMethod:r,path:i,shouldUseIdiomaticRequestNames:n}){let a=[];if(e!=null){if(n&&a.push(e.methodName),e.groupName.length>0){let u=e.groupName[e.groupName.length-1];u!=null&&a.push(typeof u=="string"?u:u.name)}n||a.push(e.methodName)}else t.operationId!=null?a.push(t.operationId):a.push(F_(`${r}_${i.split("/").join("_")}`));return a}function Sw_(e,t,r,i){let n=[],a=Ew_(t),u={document:r,pathItem:t,path:e,pathItemParameters:t.parameters??[]};for(let c of a){if(i.filter.skipEndpoint({method:c.method,path:e})){i.logger.debug(`Skipping endpoint "${c.method} ${e}"`);continue}let d=BBE({operation:c.operation}),s=cSc({context:i,pathItemContext:{...u,method:c.method},operation:c.operation,convertToWebhook:d});s&&n.push(s)}return n}function Dw_(e,t,r,i){let n=[],a=Ew_(t),u={document:r,pathItem:t,path:e,pathItemParameters:t.parameters??[]};for(let c of a){if(i.filter.skipEndpoint({method:c.method,path:e})){i.logger.debug(`Skipping endpoint "${c.method} ${e}"`);continue}let d=cSc({context:i,pathItemContext:{...u,method:c.method},operation:c.operation,convertToWebhook:!0});d&&n.push(d)}return n}function Ew_(e){let t=[];return e.get!=null&&t.push({method:E$.Get,operation:e.get}),e.post!=null&&t.push({method:E$.Post,operation:e.post}),e.put!=null&&t.push({method:E$.Put,operation:e.put}),e.delete!=null&&t.push({method:E$.Delete,operation:e.delete}),e.patch!=null&&t.push({method:E$.Patch,operation:e.patch}),e.head!=null&&t.push({method:E$.Head,operation:e.head}),t}function BBE({operation:e}){return hf(e,[ad.WEBHOOK])??!1}function Mw_(e){let t=hf(e,ad.BASIC_AUTH_USERNAME_VARIABLE_NAME),r=hf(e,ad.BASIC_AUTH_PASSWORD_VARIABLE_NAME);return{usernameVariable:t,passwordVariable:r}}function Aw_(e){return hf(e,ad.FERN_BASIC_AUTH)}function lSc(e,t){if(tp(e))throw new Error(`Converting referenced security schemes is unsupported: ${JSON.stringify(e)}`);return IBE(e,t)}function IBE(e,t){if(e.type==="apiKey"&&e.in==="header"){let r=hf(e,M$.BEARER_FORMAT),i=hf(e,ad.FERN_HEADER_AUTH);return AU.header({headerName:e.name,prefix:r!=null?"Bearer":i?.prefix,headerVariableName:i?.name??hf(e,ad.HEADER_VARIABLE_NAME),headerEnvVar:i?.env})}else if(e.type==="http"&&e.scheme?.toLowerCase()==="bearer"){let r=hf(e,ad.FERN_BEARER_TOKEN);return AU.bearer({tokenVariableName:r?.name??hf(e,ad.BEARER_TOKEN_VARIABLE_NAME),tokenEnvVar:r?.env})}else if(e.type==="http"&&e.scheme?.toLowerCase()==="basic"){let r=Aw_(e),i=Mw_(e);return AU.basic({usernameVariableName:r?.username?.name??i.usernameVariable,usernameEnvVar:r?.username?.env,passwordVariableName:r?.password?.name??i.passwordVariable,passwordEnvVar:r?.password?.env})}else{if(e.type==="openIdConnect")return AU.bearer({tokenVariableName:void 0,tokenEnvVar:void 0});if(e.type==="oauth2")return AU.oauth({scopesEnum:zBE(e,t)})}}function zBE(e,t){let r=e.flows.authorizationCode?.scopes??e.flows.clientCredentials?.scopes??e.flows.implicit?.scopes??e.flows.password?.scopes;if(r!=null){let i=zNi({nameOverride:void 0,generatedName:"OauthScope",title:void 0,enumValues:Object.keys(r),fernEnum:Object.fromEntries(Object.entries(r).map(([a,u])=>[a,{description:u}])),_default:void 0,description:void 0,availability:void 0,enumVarNames:void 0,wrapAsNullable:!1,namespace:void 0,groupName:void 0,context:void 0,source:t,inline:void 0}),n=DA(i);if(n.type==="enum")return n}}function qw_(e){return hf(e,ad.BASE_PATH)}var xBE=ou.record(ou.string(),ou.object({summary:ou.string().optional(),description:ou.string().optional()}));function Tw_({document:e,context:t}){return x5a(e,ad.GROUPS,xBE,t.logger)}function Cw_({context:e,document:t}){return hf(t,ad.FERN_VERSION)??void 0}function Bw_(e){let t=hf(e,ad.FERN_GLOBAL_HEADERS),r=[];for(let i of t??[])r.push({...i,schema:i.type!=null?R5a({fernType:i.type,description:void 0,availability:void 0,generatedName:i.name??i.header,title:void 0,namespace:void 0,groupName:void 0,nameOverride:void 0}):void 0});return r}function Iw_(e){let t=hf(e,ad.FERN_IDEMPOTENCY_HEADERS),r=[];for(let i of t??[])r.push({...i,schema:i.type!=null?R5a({fernType:i.type,description:void 0,availability:void 0,generatedName:i.name??i.header,title:void 0,namespace:void 0,groupName:void 0,nameOverride:void 0}):void 0});return r}function zw_(e,t){let r=hf(e,ad.SDK_VARIABLES);return r==null?{}:Object.fromEntries(Object.entries(r).map(([i,n])=>{if(n.type==="string")return[i,{nameOverride:void 0,generatedName:D5([i],t),title:n.title,schema:Ww.string({default:PKn(n),pattern:n.pattern,format:n.format,minLength:n.minLength,maxLength:n.maxLength}),description:n.description,availability:void 0,namespace:void 0,groupName:void 0}];throw new Error(`Variable ${i} has unsupported schema ${JSON.stringify(n)}`)}))}var RBE="webhooks";function xw_(e){return hf(e,RBE)??{}}var Rau=class extends EKn{nonRequestReferencedSchemas=new Set;twoOrMoreRequestsReferencedSchemas=new Set;singleRequestReferencedSchemas=new Set;discriminatedUnionReferences={};discriminatedUnionMetadata={};schemasToExclude=new Set;constructor({document:t,taskContext:r,authHeaders:i,options:n,source:a,namespace:u}){super({document:t,taskContext:r,authHeaders:i,options:n,source:a,namespace:u})}getDummy(){return new Jnn({document:this.document,taskContext:this.taskContext,options:this.options,source:this.source,namespace:this.namespace})}markSchemaAsReferencedByNonRequest(t){this.nonRequestReferencedSchemas.add(t)}markSchemaAsReferencedByRequest(t){this.singleRequestReferencedSchemas.has(t)?this.twoOrMoreRequestsReferencedSchemas.add(t):this.singleRequestReferencedSchemas.add(t)}getReferencedSchemas(){return new Set([...this.nonRequestReferencedSchemas,...this.twoOrMoreRequestsReferencedSchemas])}markReferencedByDiscriminatedUnion(t,r,i){let n=this.discriminatedUnionReferences[t.$ref];n!=null?(n.discriminants.add(r),n.numReferences+=i):this.discriminatedUnionReferences[t.$ref]={discriminants:new Set([r]),numReferences:i}}getReferencesFromDiscriminatedUnion(t){return this.discriminatedUnionReferences[t.$ref]}markSchemaWithDiscriminantValue(t,r,i){let n=this.discriminatedUnionMetadata[t.$ref];n!=null?n.discriminants.set(r,i):this.discriminatedUnionMetadata[t.$ref]={discriminants:new Map([[r,i]])}}getDiscriminatedUnionMetadata(t){return this.discriminatedUnionMetadata[t.$ref]}excludeSchema(t){this.schemasToExclude.add(t)}isSchemaExcluded(t){return this.schemasToExclude.has(t)}};function Rw_(e){return hf(e,ad.RESOLUTIONS)}function Nw_({openapi:e}){let t=Rw_(e);if(t==null)return e;let r={};for(let i of t){let n=`#/components/schemas/${i.name}`;for(let a of i.resolutions)e=NBE({openapi:e,schemaReference:a,schemaName:i.name}),e=Fw_({openapi:e,replaceReference:a,schemaReference:n,replacedReferences:r}),r={...r,...Object.fromEntries(i.resolutions.map(u=>[n,u]))}}return e}function NBE({openapi:e,schemaReference:t,schemaName:r}){let i=t.replace("#/","").split("/").map(a=>a.replaceAll("~1","/")),n=e;for(let a of i){let u=n[a];if(u==null)return e;n=u}return e.components==null&&(e.components={}),e.components.schemas==null&&(e.components.schemas={}),e.components.schemas[r]=n,e}function Fw_({openapi:e,replaceReference:t,schemaReference:r,replacedReferences:i}){let n=Object.keys(i).filter(d=>t.startsWith(d)).sort((d,s)=>s.length-d.length)[0];if(n!=null){let d=i[n];if(d!=null){let s=r.replace(n,d);return Fw_({openapi:e,replaceReference:t,schemaReference:s,replacedReferences:{}})}}let a=t.replace("#/","").split("/").map(d=>d.replaceAll("~1","/")),u=e;for(let d of a.slice(0,-1)){let s=u[d];if(s==null)return e;u=s}let c=a[a.length-1];return c==null||(u[c]={$ref:r}),e}function Uw_({openApi:e,taskContext:t,options:r,source:i,namespace:n}){e=Nw_({openapi:e});let a=Object.fromEntries(Object.entries(e.components?.securitySchemes??{}).map(([I,N])=>lSc(N,i)==null?[]:[I,lSc(N,i)])),u=new Set(...Object.entries(a).map(([I,N])=>N.type==="basic"||N.type==="bearer"?"Authorization":N.type==="header"?N.headerName:null)),c=zw_(e,r.preserveSchemaIds),d=Bw_(e),s=Iw_(e),o=r.audiences??[],l=[],b=[],g=new Rau({document:e,taskContext:t,authHeaders:u,options:r,source:i,namespace:n});g.filter.hasEndpoints()&&t.logger.debug("Endpoint filter applied..."),Object.entries(e.paths??{}).forEach(([I,N])=>{if(N==null)return;t.logger.debug(`Converting path ${I}`);let U=Sw_(I,N,e,g);for(let Y of U){let J=Lw_({operation:Y});if(!(o.length>0&&!o.some(X=>J.includes(X))))switch(Y.type){case"async":l.push(...Y.sync),l.push(...Y.async);break;case"http":l.push(...Y.value);break;case"streaming":l.push(...Y.streaming),Y.nonStreaming&&l.push(...Y.nonStreaming);break;case"webhook":b.push(...Y.value);break;default:Ao(Y)}}}),Object.entries(xw_(e)).forEach(([I,N])=>{if(N==null)return;t.logger.debug(`Converting path ${I}`);let U=Dw_(I,N,e,g);for(let Y of U){let J=Lw_({operation:Y});o.length>0&&!o.some(X=>J.includes(X))||b.push(...Y.value)}});let O=Object.fromEntries(Object.entries(e.components?.schemas??{}).map(([I,N])=>{let U=hf(N,ad.SDK_NAMESPACE);if(!tp(N)){let Y=hf(N,ad.IGNORE);if(Y!=null&&Y)return[];if(_w_.has(I))return[I,s0({...N,"x-fern-type-name":`${I}Body`},!1,g,[I],i,U??n)]}return[I,s0(N,!1,g,[I],i,U??n)]}).filter(I=>I.length>0)),m=FBE(O,g,i),P=LBE(m,g),D={};for(let[I,N]of Object.entries(P)){let U=DA(N);g.isSchemaExcluded(I)||(D[I]=U,t.logger.debug(`Converted schema ${I}`))}let A=new FNi(P,g.nonRequestReferencedSchemas,g),M=b.map(I=>{let U=I.examples;if(!r.disableExamples&&U.length===0){let Y=A.buildExample({schema:I.payload,exampleId:void 0,example:void 0,skipReadonly:!1,options:{ignoreOptionals:!1,isParameter:!1}});Y!=null&&(U=[{name:void 0,description:void 0,payload:Y}])}return{...I,payload:DA(I.payload),examples:U}}),E=new Sau(P,g,d),T=l.map(I=>{let N=I.examples,U=N;if(!r.disableExamples&&(N.length===0||N.every(F5a))){let X=E.buildEndpointExample(I);X.length>0&&(U=[...X,...N.filter(oe=>!F5a(oe))])}let Y=I.request,J=I.response;return{...I,request:Y?.type==="json"||Y?.type==="formUrlEncoded"?{...Y,schema:DA(Y.schema)}:Y,response:J?.type==="json"?{...J,schema:DA(J.schema)}:J,queryParameters:I.queryParameters.map(X=>({description:X.description,name:X.name,schema:DA(X.schema),parameterNameOverride:X.parameterNameOverride,availability:X.availability,source:X.source})),pathParameters:I.pathParameters.map(X=>({description:X.description,name:X.name,schema:DA(X.schema),parameterNameOverride:X.parameterNameOverride,variableReference:X.variableReference,availability:X.availability,source:X.source})),headers:I.headers.map(X=>({description:X.description,name:X.name,schema:DA(X.schema),parameterNameOverride:X.parameterNameOverride,env:X.env,availability:X.availability,source:X.source})),examples:U,errors:Dd(I.errors,X=>{let oe=X.fullExamples?.map(pe=>{let de=NNi(pe.value);if(de!=null)return{name:pe.name,description:pe.description,example:de}}).filter(gy);if(oe?.length===0){let pe=A.buildExample({schema:X.schema,example:void 0,exampleId:void 0,skipReadonly:!1,options:{ignoreOptionals:!1,isParameter:!1}});pe!=null&&oe.push({name:void 0,description:void 0,example:pe})}return{generatedName:X.generatedName,nameOverride:X.nameOverride,schema:DA(X.schema),description:X.description,source:X.source,examples:oe}})}}),z=Tw_({document:e,context:g});return{apiVersion:Cw_({context:g,document:e}),basePath:qw_(e),title:e.info.title??"",description:e.info.description,groups:Object.fromEntries(Object.entries(z??{}).map(([I,N])=>[I,{summary:N.summary??void 0,description:N.description??void 0}])),servers:(e.servers??[]).map(I=>Tau(I)),websocketServers:[],tags:{tagsById:Object.fromEntries((e.tags??[]).map(I=>[I.name,{id:I.name,description:I.description}])),orderedTagIds:e.tags?.map(I=>I.name)},endpoints:T,webhooks:M,channels:{},groupedSchemas:SKn(n,D),securitySchemes:a,hasEndpointsMarkedInternal:T.some(I=>I.internal),nonRequestReferencedSchemas:g.getReferencedSchemas(),variables:c,globalHeaders:d,idempotencyHeaders:s}}function FBE(e,t,r){let i={};for(let[n,a]of Object.entries(e)){if(a.type!=="object"){i[n]=a;continue}let u={$ref:`#/components/schemas/${n}`},c=t.getReferencesFromDiscriminatedUnion(u);if(c==null){i[n]=a;continue}let d={...a,type:"object",properties:a.properties.filter(o=>!c.discriminants.has(o.key)),allOfPropertyConflicts:a.allOfPropertyConflicts.filter(o=>!c.discriminants.has(o.propertyKey)),source:r};i[n]=d;let s=Vw_({schema:a,schemas:e});for(let o of[...new Set(s)]){let l=i[o]??e[o];l==null||l.type!=="object"||(i[o]={...l,type:"object",properties:l.properties.filter(b=>!c.discriminants.has(b.key)),allOfPropertyConflicts:l.allOfPropertyConflicts.filter(b=>!c.discriminants.has(b.propertyKey))})}}return i}function LBE(e,t){let r={};for(let[i,n]of Object.entries(e)){if(n.type!=="object"){r[i]=n;continue}let a={$ref:`#/components/schemas/${i}`},u=t.getDiscriminatedUnionMetadata(a);if(u==null){r[i]=n;continue}let c=[];for(let s of n.properties)if(u.discriminants.has(s.key)){let o=u.discriminants.get(s.key);o!=null&&c.push({...s,schema:Nl.literal({nameOverride:void 0,generatedName:D5([n.generatedName,o],t.options.preserveSchemaIds),title:void 0,value:mx.string(o),namespace:void 0,groupName:void 0,description:void 0,availability:n.availability})})}else c.push(s);let d={...n,type:"object",properties:c};r[i]=d}return r}function Vw_({schema:e,schemas:t}){let r=[];for(let i of e.allOf){r.push(i.schema);let n=t[i.schema];n!=null&&n.type==="object"&&r.push(...Vw_({schema:n,schemas:t}))}return r}function Nau(e){return[...new Set(e)]}function Lw_({operation:e}){let t=[];switch(e.type){case"async":t=Nau(e.async.flatMap(r=>r.audiences));break;case"http":t=Nau(e.value.flatMap(r=>r.audiences));break;case"streaming":t=Nau(e.streaming.flatMap(r=>r.audiences));break;case"webhook":t=Nau(e.value.flatMap(r=>r.audiences));break;default:Ao(e)}return t}function Knn({context:e,documents:t,options:r}){let i={apiVersion:void 0,title:void 0,description:void 0,basePath:void 0,servers:[],websocketServers:[],tags:{tagsById:{},orderedTagIds:void 0},hasEndpointsMarkedInternal:!1,endpoints:[],webhooks:[],channels:{},groupedSchemas:{rootSchemas:{},namespacedSchemas:{}},variables:{},nonRequestReferencedSchemas:new Set,securitySchemes:{},globalHeaders:[],idempotencyHeaders:[],groups:{}};for(let n of t){let a=n.source!=null?n.source:RK.openapi({file:"<memory>"});switch(n.type){case"openapi":{let u=Uw_({taskContext:e,openApi:n.value,options:HQt({options:n.settings,overrides:r}),source:a,namespace:n.namespace});i=VBE(i,u);break}case"asyncapi":{let u=$j_({document:n.value,taskContext:e,options:HQt({options:n.settings,overrides:r}),source:a,asyncApiOptions:UBE({options:n.settings}),namespace:n.namespace});u.servers!=null&&(i.websocketServers=[...i.websocketServers,...u.servers.map(c=>({...c,audiences:void 0,description:void 0}))]),u.channels!=null&&(i.channels={...i.channels,...u.channels}),u.groupedSchemas!=null&&(i.groupedSchemas=Ww_(i.groupedSchemas,u.groupedSchemas)),u.basePath!=null&&(i.basePath=u.basePath);break}default:Ao(n)}}return i}function UBE({options:e,overrides:t}){return{naming:t?.naming??e?.asyncApiNaming??dj_.naming}}function VBE(e,t){return{apiVersion:e.apiVersion??t.apiVersion,title:e.title??t.title,description:e.description??t.description,basePath:e.basePath??t.basePath,servers:[...e.servers,...t.servers],websocketServers:[...e.websocketServers,...t.websocketServers],tags:{tagsById:{...e.tags.tagsById,...t.tags.tagsById},orderedTagIds:e.tags.orderedTagIds==null&&t.tags.orderedTagIds==null?void 0:[...e.tags.orderedTagIds??[],...t.tags.orderedTagIds??[]]},hasEndpointsMarkedInternal:e.hasEndpointsMarkedInternal||t.hasEndpointsMarkedInternal,endpoints:[...e.endpoints,...t.endpoints],webhooks:[...e.webhooks,...t.webhooks],channels:{...e.channels,...t.channels},groupedSchemas:Ww_(e.groupedSchemas,t.groupedSchemas),variables:{...e.variables,...t.variables},nonRequestReferencedSchemas:new Set([...e.nonRequestReferencedSchemas,...t.nonRequestReferencedSchemas]),securitySchemes:{...e.securitySchemes,...t.securitySchemes},globalHeaders:e.globalHeaders!=null?[...e.globalHeaders,...t.globalHeaders??[]]:void 0,idempotencyHeaders:e.idempotencyHeaders!=null?[...e.idempotencyHeaders,...t.idempotencyHeaders??[]]:void 0,groups:{...e.groups,...t.groups}}}function Ww_(e,t){e.rootSchemas={...e.rootSchemas,...t.rootSchemas};for(let[r,i]of Object.entries(t.namespacedSchemas))e.namespacedSchemas[r]!=null?e.namespacedSchemas[r]={...e.namespacedSchemas[r],...i}:e.namespacedSchemas[r]=i;return e}var _B_=ci(Icu(),1),zcu={config:new _B_.Config({apis:{},styleguide:{plugins:[J1c],rules:{struct:"warn"}}},void 0),dereference:!1,removeUnusedComponents:!1,keepUrlRefs:!0};function wYn(e){if(e.settings==null&&e.raw?.api?.auth==null)return;let t={detectGlobalHeaders:!0};return e.settings?.unions==="v1"&&(t.discriminatedUnionV2=!0),e.raw?.api?.auth!=null&&(t.auth=e.raw?.api?.auth),t}function G9a(e){return e.swagger!=null}function jqc(e){return e.openapi!=null}function Q9a({options:e,overrides:t}={}){return{...HQt({options:e,overrides:t}),...w5a({options:e,overrides:t})}}function p3i(e,t={}){return{...Object.fromEntries(sF(e.namedDefinitionFiles).map(([r,i])=>[r,{...i,defaultUrl:t.defaultURL}])),...sF(e.importedDefinitions).reduce((r,[i,n])=>({...r,...Dza(p3i(n.definition,{defaultURL:n.url}),(a,u)=>X3(i,Ey.of(u)))}),{})}}function J9a(e,t={}){return{...Object.fromEntries(sF(e.packageMarkers).map(([r,i])=>[r,{...i,defaultUrl:t.defaultURL}])),...sF(e.importedDefinitions).reduce((r,[i,n])=>({...r,...Dza(J9a(n.definition,{defaultURL:n.url}),(a,u)=>X3(i,Ey.of(u)))}),{})}}function pPi(e){return{...J9a(e),...p3i(e)}}function Que(e,t){return pPi(e.definition)[t]?.contents}function KF(e,t){for(let[r,i]of sF(pPi(e.definition)))t(r,i.contents,{isPackageMarker:aki(r)===CS,defaultUrl:i.defaultUrl})}function man(e,t){for(let[r,i]of sF(J9a(e.definition)))t(r,i.contents)}function NFe({breadcrumbs:e=[],title:t,subtitle:r}){let i=[];return e.length>0&&i.push(Bs.blue(e.join(" -> "))),i.push(t),r!=null&&i.push(Bs.dim(r)),i.join(`
|
|
@@ -2310,7 +2310,7 @@ ${a}]`:`[${e.join(u)}]`},L_u=(e,t,r)=>`let ${e} = ${MRc(t,r)}`,MRc=(e,t,r)=>{swi
|
|
|
2310
2310
|
`)}];if(t["base-properties"]!=null){let M=Object.fromEntries(Object.entries(l).filter(([T])=>t["base-properties"]?.[T]!=null)),E=Gon({typeName:e,typeNameForBreadcrumb:e,rawObject:{properties:t["base-properties"]},file:a,example:M,typeResolver:i,exampleResolver:n,workspace:u,breadcrumbs:c,depth:d+1});if(E.length>0)return E}let g=typeof b=="string"?b:b.type;if(typeof g!="string")return XQ_(l);let O=i.resolveType({type:g,file:a});if(O==null)return[];if(O._type==="named"&&TD(O.declaration)){let M=Object.fromEntries(Object.entries(l).filter(([E])=>t["base-properties"]?.[E]==null));return Gon({typeName:e,typeNameForBreadcrumb:e,rawObject:O.declaration,file:O.file,example:M,typeResolver:i,exampleResolver:n,workspace:u,breadcrumbs:c,depth:d+1})}let m=typeof b!="string"&&typeof b.key=="string"?b.key:void 0;if(m==null)return[];let{[m]:P,...D}=l,A=[];return P==null?A.push({message:`Missing property "${m}"`}):A.push(...WU({rawTypeReference:g,example:P,typeResolver:i,exampleResolver:n,file:a,workspace:u,breadcrumbs:c,depth:d+1})),A.push(...XQ_(D)),A}function XQ_(e){return Object.keys(e).map(t=>({severity:"fatal",message:`Unexpected property "${t}"`}))}function Ihu({typeName:e,typeDeclaration:t,file:r,typeResolver:i,exampleResolver:n,example:a,workspace:u,breadcrumbs:c,depth:d}){return DF(t,{alias:s=>HQ_({rawAlias:s,file:r,typeResolver:i,exampleResolver:n,example:a,workspace:u,breadcrumbs:c,depth:d}),enum:s=>$Q_({rawEnum:s,example:a,breadcrumbs:c}),object:s=>Gon({typeName:e,typeNameForBreadcrumb:e,rawObject:s,example:a,file:r,typeResolver:i,exampleResolver:n,workspace:u,breadcrumbs:c,depth:d}),discriminatedUnion:s=>ZQ_({typeName:e,rawUnion:s,example:a,file:r,typeResolver:i,exampleResolver:n,workspace:u,breadcrumbs:c,depth:d}),undiscriminatedUnion:s=>GQ_({rawUnion:s,example:a,file:r,typeResolver:i,exampleResolver:n,workspace:u,breadcrumbs:c,depth:d})})}var uJ_=/^([+-]?\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)?)?)?)?$/,EvM=/^[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}$/,MvM=/^\d{4}-\d{2}-\d{2}$/,AvM=128;function WU({rawTypeReference:e,example:t,typeResolver:r,exampleResolver:i,file:n,workspace:a,breadcrumbs:u,depth:c}){if(c>AvM)return[{message:"Example is too deeply nested. This may indicate a circular reference."}];if(typeof t=="string"&&t.startsWith(sir)){let d=r.resolveType({type:e,file:n});if(d==null)return[];let s=i.parseExampleReference(t);if(s==null)return[];let o=r.resolveNamedType({referenceToNamedType:s.rawTypeReference,file:n});return o==null?[]:fZn({expected:d,actual:o})?[]:[{message:`Expected example to be: ${e}. Example is ${t}.`}]}return Een({type:e,_default:void 0,validation:void 0,visitor:{primitive:d=>qvM({primitiveType:d,example:t}),named:d=>{let s=r.getDeclarationOfNamedType({referenceToNamedType:d,file:n});return s==null?[]:Ihu({typeName:s.typeName,typeDeclaration:s.declaration,file:s.file,example:t,typeResolver:r,exampleResolver:i,workspace:a,breadcrumbs:u,depth:c+1})},map:({keyType:d,valueType:s})=>Rw(t)?Object.entries(t).flatMap(([o,l])=>[...WU({rawTypeReference:d,example:o,typeResolver:r,exampleResolver:i,file:n,workspace:a,breadcrumbs:[...u,o],depth:c+1}),...WU({rawTypeReference:s,example:l,typeResolver:r,exampleResolver:i,file:n,workspace:a,breadcrumbs:[...u,o],depth:c+1})]):kFe(t,"a map"),list:d=>Array.isArray(t)?t.flatMap((s,o)=>WU({rawTypeReference:d,example:s,typeResolver:r,exampleResolver:i,file:n,workspace:a,breadcrumbs:[...u,`${o}`],depth:c+1})):kFe(t,"a list"),set:d=>{if(!Array.isArray(t))return kFe(t,"a list");let s=sHs(t);return s.length>0?[{severity:"fatal",message:`Set has duplicate elements:
|
|
2311
2311
|
`+s.map(o=>` - ${JSON.stringify(o)}`).join(`
|
|
2312
2312
|
`)}]:t.flatMap((o,l)=>WU({rawTypeReference:d,example:o,typeResolver:r,exampleResolver:i,file:n,workspace:a,breadcrumbs:[...u,`${l}`],depth:c+1}))},optional:d=>t==null?[]:WU({rawTypeReference:d,example:t,typeResolver:r,exampleResolver:i,file:n,workspace:a,breadcrumbs:u,depth:c+1}),nullable:d=>t==null?[]:WU({rawTypeReference:d,example:t,typeResolver:r,exampleResolver:i,file:n,workspace:a,breadcrumbs:u,depth:c+1}),unknown:()=>[],literal:d=>{switch(d.type){case"boolean":return Yqe(s=>s===d.boolean,d.boolean.toString())(t);case"string":return Yqe(s=>s===d.string,`"${d.string}"`)(t);default:Ao(d)}}}})}function qvM({primitiveType:e,example:t}){return e.v2!=null?Hd._visit(e.v2,{integer:r=>TvM({example:t,rules:r.validation}),long:()=>rJ_(t),uint:()=>kQ_(t),uint64:()=>eJ_(t),double:r=>CvM({example:t,rules:r.validation}),float:()=>tJ_(t),boolean:()=>iJ_(t),string:r=>BvM({example:t,rules:r.validation}),uuid:()=>nJ_(t),date:()=>oJ_(t),dateTime:()=>aJ_(t),base64:()=>lZn(t),bigInteger:()=>lZn(t),_other:()=>{throw new Error("Unknown primitive type v2: "+e.v2)}}):Oy._visit(e.v1,{integer:()=>sJ_(t),long:()=>rJ_(t),uint:()=>kQ_(t),uint64:()=>eJ_(t),double:()=>cJ_(t),float:()=>tJ_(t),boolean:()=>iJ_(t),string:()=>lZn(t),uuid:()=>nJ_(t),dateTime:()=>aJ_(t),date:()=>oJ_(t),base64:()=>lZn(t),bigInteger:()=>lZn(t),_other:()=>{throw new Error("Unknown primitive type: "+e.v1)}})}function TvM({example:e,rules:t}){let r=sJ_(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 CvM({example:e,rules:t}){let r=cJ_(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 BvM({example:e,rules:t}){let r=lZn(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 lZn=Yqe(e=>typeof e=="string","a string"),sJ_=Yqe(e=>Number.isInteger(e),"an integer"),kQ_=Yqe(e=>Number.isInteger(e)&&typeof e=="number"&&e>=0,"a uint"),eJ_=Yqe(e=>Number.isInteger(e)&&typeof e=="number"&&e>=0,"a uint64"),tJ_=Yqe(e=>typeof e=="number","a float"),cJ_=Yqe(e=>typeof e=="number","a double"),rJ_=Yqe(e=>Number.isInteger(e),"an integer"),iJ_=Yqe(e=>typeof e=="boolean","a boolean"),nJ_=Yqe(e=>typeof e=="string"&&EvM.test(e),"a UUID"),aJ_=Yqe(e=>typeof e=="string"&&uJ_.test(e),"an ISO 8601 timestamp"),oJ_=Yqe(e=>typeof e=="string"&&MvM.test(e)&&uJ_.test(e),"a date");function Yqe(e,t){return r=>e(r)?[]:kFe(r,t)}function fZn({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&&fZn({expected:e.container.itemType,actual:t.container.itemType});case"optional":return fZn({expected:e.container.itemType,actual:t._type==="container"&&t.container._type==="optional"?t.container.itemType:t});case"nullable":return fZn({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&&fZn({expected:e.container.keyType,actual:t.container.keyType})&&fZn({expected:e.container.valueType,actual:t.container.valueType});case"literal":return t._type!=="container"||t.container._type!==e.container._type?!1:IvM({expected:e.container.literal,actual:t.container.literal});default:Ao(e.container)}if(e._type==="named")return t._type==="named"&&t.filepath===e.filepath&&t.rawName===e.rawName;Ao(e)}function IvM({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:Ao(e)}}function zhu({_enum:e,file:t}){let r=e.enum.map(n=>({...nY(n),name:t.casingsGenerator.generateNameAndWireValue({wireValue:typeof n=="string"?n:n.value,name:dZn(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 lJ_(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 dZn(e){return typeof e=="string"?{name:e,wasExplicitlySet:!1}:e.name==null?{name:e.value,wasExplicitlySet:!1}:{name:e.name,wasExplicitlySet:!0}}function E7c({typeName:e,typeDeclaration:t,example:r,typeResolver:i,exampleResolver:n,fileContainingType:a,fileContainingExample:u,workspace:c}){return DF(t,{alias:d=>T1.alias({value:$M({example:r,rawTypeBeingExemplified:typeof d=="string"?d:d.type,fileContainingRawTypeReference:a,fileContainingExample:u,typeResolver:i,exampleResolver:n,workspace:c})}),object:d=>fJ_({typeName:e,rawObject:d,example:r,fileContainingType:a,fileContainingExample:u,typeResolver:i,exampleResolver:n,workspace:c}),discriminatedUnion:d=>{let s=Qon(d);if(!Rw(r))throw new Error("Example is not an object");let o=r[s];if(o==null)throw new Error("Example is missing discriminant: "+s);if(typeof o!="string")throw new Error("Discriminant value is not a string");let l=d.union[o];if(l==null)throw new Error(`${o} is not one of the specified discriminant values.`);let b=typeof l=="string"?l:typeof l.type=="string"?l.type:void 0;return T1.union({discriminant:u.casingsGenerator.generateNameAndWireValue({name:O7i(d).name,wireValue:s}),singleUnionType:xvM({rawValueType:b,rawSingleUnionType:l,fileContainingType:a,fileContainingExample:u,typeResolver:i,exampleResolver:n,example:r,discriminant:s,discriminantValueForExample:o,workspace:c})})},enum:d=>{if(typeof r!="string"){let s=d.enum.map(o=>typeof o=="string"?o:o.value).join(", ");throw new Error(`Expected one of ${s}. Received ${r}`)}return T1.enum({value:u.casingsGenerator.generateNameAndWireValue({name:lJ_(r,d).name,wireValue:r})})},undiscriminatedUnion:d=>{for(let[l,b]of d.union.entries())if(WU({rawTypeReference:typeof b=="string"?b:b.type,example:r,typeResolver:i,exampleResolver:n,file:a,workspace:c,breadcrumbs:[],depth:0}).length===0)return T1.undiscriminatedUnion({index:l,singleUnionType:$M({example:r,rawTypeBeingExemplified:typeof b=="string"?b:b.type,fileContainingRawTypeReference:a,fileContainingExample:u,typeResolver:i,exampleResolver:n,workspace:c})});let o=d.union.map(l=>typeof l=="string"?l:l.type).join(", ");throw new Error(`Expected one of ${o}. Received ${r}`)}})}function $M({example:e,fileContainingExample:t,rawTypeBeingExemplified:r,fileContainingRawTypeReference:i,typeResolver:n,exampleResolver:a,workspace:u}){let{resolvedExample:c,file:d}=a.resolveExampleOrThrow({example:e,file:t}),s=a.resolveAllReferencesInExampleOrThrow({example:e,file:t}).resolvedExample;return{shape:Een({type:r,_default:void 0,validation:void 0,visitor:{primitive:l=>zvM({example:c,typeBeingExemplified:l.v1}),map:({keyType:l,valueType:b})=>{if(!Rw(c))throw new Error("Example is not an object");return my.container(cP.map({map:Object.entries(c).map(([g,O])=>({key:$M({example:g,fileContainingExample:d,rawTypeBeingExemplified:l,fileContainingRawTypeReference:i,typeResolver:n,exampleResolver:a,workspace:u}),value:$M({example:O,fileContainingExample:d,rawTypeBeingExemplified:b,fileContainingRawTypeReference:i,typeResolver:n,exampleResolver:a,workspace:u})})),keyType:i.parseTypeReference(l),valueType:i.parseTypeReference(b)}))},list:l=>{if(!Array.isArray(c))throw new Error("Example is not a list");return my.container(cP.list({list:c.map(b=>$M({example:b,fileContainingExample:d,rawTypeBeingExemplified:l,fileContainingRawTypeReference:i,typeResolver:n,exampleResolver:a,workspace:u})),itemType:i.parseTypeReference(l)}))},set:l=>{if(!Array.isArray(c))throw new Error("Example is not a list");return my.container(cP.set({set:c.map(b=>$M({example:b,fileContainingExample:d,rawTypeBeingExemplified:l,fileContainingRawTypeReference:i,typeResolver:n,exampleResolver:a,workspace:u})),itemType:i.parseTypeReference(l)}))},optional:l=>my.container(cP.optional({optional:c!=null?$M({example:c,fileContainingExample:d,rawTypeBeingExemplified:l,fileContainingRawTypeReference:i,typeResolver:n,exampleResolver:a,workspace:u}):void 0,valueType:i.parseTypeReference(l)})),nullable:l=>my.container(cP.nullable({nullable:c!=null?$M({example:c,fileContainingExample:d,rawTypeBeingExemplified:l,fileContainingRawTypeReference:i,typeResolver:n,exampleResolver:a,workspace:u}):void 0,valueType:i.parseTypeReference(l)})),literal:l=>{switch(l.type){case"boolean":return my.container(cP.literal({literal:ep.boolean(l.boolean)}));case"string":return my.container(cP.literal({literal:ep.string({original:l.string})}));default:Ao(l)}},named:l=>{let b=n.getDeclarationOfNamedTypeOrThrow({referenceToNamedType:r,file:i}),g=i.parseTypeReference(l);if(g.type!=="named")throw new Error("Type reference is not to a named type.");let O={typeId:g.typeId,fernFilepath:g.fernFilepath,name:g.name,displayName:g.displayName};return my.named({typeName:O,shape:E7c({typeName:O,typeDeclaration:b.declaration,fileContainingType:b.file,fileContainingExample:d,example:c,typeResolver:n,exampleResolver:a,workspace:u})})},unknown:()=>my.unknown(s)}}),jsonExample:s}}function zvM({example:e,typeBeingExemplified:t}){return Oy._visit(t,{string:()=>typeof e!="string"?my.primitive(ep.string({original:Qh.STRING})):my.primitive(ep.string({original:e})),dateTime:()=>typeof e!="string"?my.primitive(ep.string({original:Qh.DATE_TIME})):my.primitive(ep.datetime({datetime:new Date(e),raw:e})),date:()=>typeof e!="string"?my.primitive(ep.string({original:Qh.DATE})):my.primitive(ep.date(e)),base64:()=>typeof e!="string"?my.primitive(ep.string({original:Qh.BASE64})):my.primitive(ep.string({original:e})),uint:()=>typeof e!="number"?my.primitive(ep.uint(Qh.UINT)):my.primitive(ep.uint(e)),uint64:()=>typeof e!="number"?my.primitive(ep.uint64(Qh.UINT64)):my.primitive(ep.uint64(e)),integer:()=>typeof e!="number"?my.primitive(ep.integer(Qh.INT)):my.primitive(ep.integer(e)),float:()=>typeof e!="number"?my.primitive(ep.float(Qh.FLOAT)):my.primitive(ep.float(e)),double:()=>typeof e!="number"?my.primitive(ep.double(Qh.DOUBLE)):my.primitive(ep.double(e)),long:()=>typeof e!="number"?my.primitive(ep.long(Qh.UINT)):my.primitive(ep.long(e)),boolean:()=>typeof e!="boolean"?my.primitive(ep.boolean(Qh.BOOLEAN)):my.primitive(ep.boolean(e)),uuid:()=>typeof e!="string"?my.primitive(ep.string({original:Qh.UUID})):my.primitive(ep.uuid(e)),bigInteger:()=>typeof e!="string"?my.primitive(ep.string({original:Qh.BIG_INTEGER})):my.primitive(ep.string({original:e})),_other:()=>{throw new Error("Unknown primitive type: "+t)}})}function fJ_({typeName:e,rawObject:t,example:r,fileContainingType:i,fileContainingExample:n,typeResolver:a,exampleResolver:u,workspace:c}){if(!Rw(r))throw new Error(`Example is not an object. Got: ${JSON.stringify(r)}`);return T1.object({properties:t.properties!=null||t.extends!=null?Object.entries(r).reduce((d,[s,o])=>{let l=dJ_({typeName:e,wirePropertyKey:s,rawObject:t,typeResolver:a,file:i});if(l==null)return d;let b=$M({example:o,fileContainingExample:n,rawTypeBeingExemplified:typeof l.rawPropertyType=="string"?l.rawPropertyType:l.rawPropertyType.type,fileContainingRawTypeReference:l.file,typeResolver:a,exampleResolver:u,workspace:c});return d.push({name:n.casingsGenerator.generateNameAndWireValue({name:VU({propertyKey:s,property:l.rawPropertyType}).name,wireValue:s}),value:b,originalTypeDeclaration:l.typeName}),d},[]):[]})}function dJ_({typeName:e,wirePropertyKey:t,rawObject:r,typeResolver:i,file:n}){let a=r.properties?.[t];return a!=null?{typeName:e,rawPropertyType:a,file:n}:CVa({wirePropertyKey:t,extends_:r.extends,typeResolver:i,file:n})}function CVa({wirePropertyKey:e,extends_:t,typeResolver:r,file:i}){if(t!=null){let n=typeof t=="string"?[t]:t;for(let a of n){let u=r.resolveNamedTypeOrThrow({referenceToNamedType:a,file:i});if(u._type!=="named"||!TD(u.declaration))throw new Error("Extension is not of a named object");let c=dJ_({wirePropertyKey:e,rawObject:u.declaration,typeResolver:r,typeName:u.name,file:u.file});if(c!=null)return c}}}function xvM({rawValueType:e,rawSingleUnionType:t,fileContainingType:r,fileContainingExample:i,typeResolver:n,exampleResolver:a,example:u,discriminant:c,discriminantValueForExample:d,workspace:s}){let o=i.casingsGenerator.generateNameAndWireValue({name:cZn({unionKey:d,rawSingleUnionType:t}).name,wireValue:d});if(e==null)return{wireDiscriminantValue:o,shape:jF.noProperties()};let l=D7c({rawSingleUnionType:t,rawValueType:e,parsedValueType:r.parseTypeReference(e),file:r,typeResolver:n});switch(l.propertiesType){case"singleProperty":{if(!Rw(u))throw new Error("Example is not an object");return{wireDiscriminantValue:o,shape:jF.singleProperty($M({example:u[l.name.wireValue],rawTypeBeingExemplified:e,typeResolver:n,exampleResolver:a,fileContainingRawTypeReference:r,fileContainingExample:i,workspace:s}))}}case"samePropertiesAsObject":{if(!Rw(u))throw new Error("Example is not an object");let{[c]:b,...g}=u,O=n.getDeclarationOfNamedTypeOrThrow({referenceToNamedType:e,file:r});for(;hzi(O.declaration);)O=n.getDeclarationOfNamedTypeOrThrow({referenceToNamedType:typeof O.declaration=="string"?O.declaration:O.declaration.type,file:r});if(!TD(O.declaration))throw new Error(`${e} is not an object`);let m={typeId:l.typeId,fernFilepath:l.fernFilepath,name:l.name,displayName:l.displayName};return{wireDiscriminantValue:o,shape:jF.samePropertiesAsObject({typeId:fP.generateTypeId(m),object:fJ_({rawObject:O.declaration,example:g,fileContainingType:O.file,fileContainingExample:i,typeResolver:n,exampleResolver:a,typeName:m,workspace:s})})}}default:Ao(l)}}function xhu({file:e,queryParameterKey:t,queryParameter:r}){let{name:i}=rji({queryParameterKey:t,queryParameter:r}),n=e.parseTypeReference(r);return{...nY(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:{}}}}function rji({queryParameterKey:e,queryParameter:t}){return typeof t!="string"&&t.name!=null?{name:t.name,wasExplicitlySet:!0}:{name:e,wasExplicitlySet:!1}}function pJ_({service:e,endpoint:t,example:r,typeResolver:i,errorResolver:n,exampleResolver:a,variableResolver:u,file:c,workspace:d}){let s=NvM({service:e,endpoint:t,example:r,typeResolver:i,exampleResolver:a,variableResolver:u,file:c,workspace:d});return{id:r.name??F8a(r),name:r.name!=null?c.casingsGenerator.generateName(r.name):void 0,docs:r.docs,url:WvM({file:c,service:e,endpoint:t,example:r,pathParams:s}),...s,...FvM({service:e,endpoint:t,example:r,typeResolver:i,exampleResolver:a,file:c,workspace:d}),queryParameters:r["query-parameters"]!=null?Object.entries(r["query-parameters"]).map(([o,l])=>{let b=typeof t.request!="string"?t.request?.["query-parameters"]?.[o]:void 0;if(b==null)throw new Error(`Query parameter ${o} does not exist`);return{name:c.casingsGenerator.generateNameAndWireValue({name:rji({queryParameterKey:o,queryParameter:b}).name,wireValue:o}),value:$M({example:l,rawTypeBeingExemplified:typeof b=="string"?b:b.type,typeResolver:i,exampleResolver:a,fileContainingRawTypeReference:c,fileContainingExample:c,workspace:d}),shape:RvM({queryParameter:b})}}):[],request:LvM({endpoint:t,example:r,typeResolver:i,exampleResolver:a,file:c,workspace:d}),response:UvM({endpoint:t,example:r,typeResolver:i,errorResolver:n,exampleResolver:a,file:c,workspace:d})}}function RvM({queryParameter:e}){return(typeof e!="string"&&e["allow-multiple"]!=null?e["allow-multiple"]:!1)?s5.exploded():s5.single()}function NvM({service:e,endpoint:t,example:r,typeResolver:i,exampleResolver:n,variableResolver:a,file:u,workspace:c}){let d=[],s=[],o=[],l=({name:b,pathParameterDeclaration:g,examplePathParameter:O})=>{let m=BVa({parameter:g,variableResolver:a,file:u});return{name:b,value:$M({example:O,rawTypeBeingExemplified:m.rawType,typeResolver:i,exampleResolver:n,fileContainingRawTypeReference:m.file,fileContainingExample:u,workspace:c})}};if(r["path-parameters"]!=null){let b=hJt(t);for(let[g,O]of Object.entries(r["path-parameters"])){let m=u.rootApiFile["path-parameters"]?.[g],P=e["path-parameters"]?.[g],D=b[g];if(m!=null)d.push(l({name:u.casingsGenerator.generateName(g),pathParameterDeclaration:m,examplePathParameter:O}));else if(D!=null)o.push(l({name:u.casingsGenerator.generateName(g),pathParameterDeclaration:D,examplePathParameter:O}));else if(P!=null)s.push(l({name:u.casingsGenerator.generateName(g),pathParameterDeclaration:P,examplePathParameter:O}));else throw new Error(`Path parameter ${g} does not exist`)}}return{rootPathParameters:d,endpointPathParameters:o,servicePathParameters:s}}function FvM({service:e,endpoint:t,example:r,typeResolver:i,exampleResolver:n,file:a,workspace:u}){let c=[],d=[];if(r.headers!=null)for(let[s,o]of Object.entries(r.headers)){let l=typeof t.request!="string"?t.request?.headers?.[s]:void 0,b=e.headers?.[s];l!=null?d.push({name:a.casingsGenerator.generateNameAndWireValue({name:cur({headerKey:s,header:l}).name,wireValue:s}),value:$M({example:o,rawTypeBeingExemplified:typeof l=="string"?l:l.type,typeResolver:i,exampleResolver:n,fileContainingRawTypeReference:a,fileContainingExample:a,workspace:u})}):b!=null&&c.push({name:a.casingsGenerator.generateNameAndWireValue({name:cur({headerKey:s,header:b}).name,wireValue:s}),value:$M({example:o,rawTypeBeingExemplified:typeof b=="string"?b:b.type,typeResolver:i,exampleResolver:n,fileContainingRawTypeReference:a,fileContainingExample:a,workspace:u})})}return{endpointHeaders:d,serviceHeaders:c}}function LvM({endpoint:e,example:t,typeResolver:r,exampleResolver:i,file:n,workspace:a}){let u=typeof e.request!="string"?e.request?.body:e.request;if(u==null||typeof u=="string"&&ONa(u)!=null)return;if(!oI(u))return sK.reference($M({example:t.request,rawTypeBeingExemplified:typeof u!="string"?u.type:u,typeResolver:r,exampleResolver:i,fileContainingRawTypeReference:n,fileContainingExample:n,workspace:a}));if(!t.request)return;if(!Rw(t.request))throw new Error(`Example is not an object. Got: ${JSON.stringify(t.request)}`);let c=[];for(let[d,s]of Object.entries(t.request)){let o=u.properties?.[d],l=typeof o=="string"?o:o?.type;if(!(l!=null&&C3e(l)!=null))if(o!=null)c.push({name:n.casingsGenerator.generateNameAndWireValue({name:VU({propertyKey:d,property:o}).name,wireValue:d}),value:$M({example:s,rawTypeBeingExemplified:typeof o!="string"?o.type:o,typeResolver:r,exampleResolver:i,fileContainingRawTypeReference:n,fileContainingExample:n,workspace:a}),originalTypeDeclaration:void 0});else{let b=CVa({extends_:u.extends,wirePropertyKey:d,typeResolver:r,file:n});if(b==null)throw new Error("Could not find original type declaration for property: "+d);c.push({name:n.casingsGenerator.generateNameAndWireValue({name:VU({propertyKey:d,property:b.rawPropertyType}).name,wireValue:d}),value:$M({example:s,rawTypeBeingExemplified:typeof b.rawPropertyType=="string"?b.rawPropertyType:b.rawPropertyType.type,typeResolver:r,exampleResolver:i,fileContainingRawTypeReference:b.file,fileContainingExample:n,workspace:a}),originalTypeDeclaration:b.typeName})}}return sK.inlinedRequestBody({jsonExample:i.resolveAllReferencesInExampleOrThrow({example:t.request,file:n}).resolvedExample,properties:c})}function UvM({endpoint:e,example:t,typeResolver:r,errorResolver:i,exampleResolver:n,file:a,workspace:u}){return t.response==null?HC.ok(sI.body(void 0)):Aen(e,t.response,{body:c=>{if(c.error!=null){let d=i.getDeclarationOrThrow(c.error,a);return HC.error({error:b7i({errorName:c.error,file:a}),body:d.declaration.type!=null?$M({example:c.body,rawTypeBeingExemplified:d.declaration.type,typeResolver:r,exampleResolver:n,fileContainingRawTypeReference:d.file,fileContainingExample:a,workspace:u}):void 0})}return HC.ok(sI.body(VvM({endpoint:e,example:c,typeResolver:r,exampleResolver:n,file:a,workspace:u})))},stream:c=>{let d=typeof e["response-stream"]=="string"?e["response-stream"]:e["response-stream"]?.type;return HC.ok(sI.stream(c.stream.map(s=>{if(d!=null)return $M({example:s,rawTypeBeingExemplified:d,typeResolver:r,exampleResolver:n,fileContainingRawTypeReference:a,fileContainingExample:a,workspace:u})}).filter(gy)))},events:c=>{let d=typeof e["response-stream"]=="string"?e["response-stream"]:e["response-stream"]?.type;return HC.ok(sI.sse(c.stream.map(({event:s,data:o})=>{if(d==null)return;let l=$M({example:o,rawTypeBeingExemplified:d,typeResolver:r,exampleResolver:n,fileContainingRawTypeReference:a,fileContainingExample:a,workspace:u});return{event:s,data:l}}).filter(gy)))}})}function VvM({endpoint:e,example:t,typeResolver:r,exampleResolver:i,file:n,workspace:a}){let u=typeof e.response!="string"?e.response?.type:e.response;if(u!=null&&t.body!=null)return $M({example:t.body,rawTypeBeingExemplified:u,typeResolver:r,exampleResolver:i,fileContainingRawTypeReference:n,fileContainingExample:n,workspace:a})}function WvM({file:e,service:t,endpoint:r,example:i,pathParams:n}){let a=Wb(e.rootApiFile["base-path"]??"",t["base-path"],r.path);if(i["path-parameters"]!=null)for(let u of[...n.endpointPathParameters,...n.servicePathParameters,...n.rootPathParameters])a=a.replaceAll(`{${u.name.originalName}}`,encodeURIComponent(`${u.value.jsonExample}`));return a=a.replaceAll("//","/"),a.startsWith("/")||(a=`/${a}`),a}function _J_({endpoint:e,file:t,typeResolver:r}){return{body:HvM({endpoint:e,file:t,typeResolver:r}),statusCode:typeof e.response!="string"?e.response?.["status-code"]:void 0}}function HvM({endpoint:e,file:t,typeResolver:r}){let i=$vM({endpoint:e,file:t,typeResolver:r}),n=GvM({endpoint:e,file:t,typeResolver:r});if(i!=null&&n!=null){let a;switch(i.type){case"fileDownload":{a=KH.fileDownload({...i});break}case"json":{a=KH.json({...i.value});break}case"text":{a=KH.text({...i});break}case"bytes":{a=KH.bytes({...i});break}default:Ao(i)}return q1.streamParameter({nonStreamResponse:a,streamResponse:n})}else{if(i!=null)return i;if(n!=null)return q1.streaming(n)}}function $vM({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 C3e(a)!=null?q1.fileDownload({docs:n,v2Examples:void 0}):mNa(a)!=null?q1.text({docs:n,v2Examples:void 0}):Pir(a)!=null?q1.bytes({docs:n,v2Examples:void 0}):QvM(i,n,t,r)}}function GvM({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,u=typeof i=="string"?"json":i.format??"json";return hLn(a)?eU.text({docs:n,v2Examples:void 0}):typeof i!="string"&&u==="sse"?eU.sse({docs:n,payload:t.parseTypeReference(a),terminator:typeof i!="string"?i.terminator:void 0,v2Examples:void 0}):eU.json({docs:n,payload:t.parseTypeReference(a),terminator:typeof i!="string"?i.terminator:void 0,v2Examples:void 0})}}function QvM(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}),u=i.resolveTypeOrThrow({type:n,file:r}),c=typeof e!="string"?e.property:void 0;return c!=null?q1.json(kL.nestedPropertyAsResponse({docs:t,responseBodyType:a,responseProperty:MVa({typeResolver:i,file:r,resolvedType:u,property:c}),v2Examples:void 0})):q1.json(kL.response({docs:t,responseBodyType:a,v2Examples:void 0}))}function hJ_({propertyResolver:e,file:t,endpointName:r,endpointSchema:i,paginationPropertyComponents:n}){return uK.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 yJ_({propertyResolver:e,file:t,endpointName:r,paginationPropertyComponents:i}){return uK.custom({results:e.resolveResponsePropertyOrThrow({file:t,endpoint:r,propertyComponents:i.results})})}function vJ_({propertyResolver:e,file:t,endpointName:r,endpointSchema:i,paginationPropertyComponents:n}){return uK.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 bJ_(e){if(KvM(e))return{type:"offset",offset:_Jt(e.offset),results:Kqe(e.results),step:e.step!=null?_Jt(e.step):void 0,hasNextPage:e["has-next-page"]!=null?Kqe(e["has-next-page"]):void 0};if(JvM(e))return{type:"cursor",cursor:_Jt(e.cursor),next_cursor:Kqe(e.next_cursor),results:Kqe(e.results)};if(YvM(e))return{type:"custom",results:Kqe(e.results)};throw new Error("Invalid pagination schema")}function JvM(e){return e.cursor!=null}function KvM(e){return e.offset!=null&&e.results!=null}function YvM(e){return"type"in e&&e.type==="custom"}function gJ_({propertyResolver:e,file:t,endpointName:r,endpointSchema:i}){let n=typeof i.pagination=="boolean"?t.rootApiFile.pagination:i.pagination;if(!n)return;let a=bJ_(n);switch(a.type){case"cursor":return hJ_({propertyResolver:e,file:t,endpointName:r,endpointSchema:i,paginationPropertyComponents:a});case"offset":return vJ_({propertyResolver:e,file:t,endpointName:r,endpointSchema:i,paginationPropertyComponents:a});case"custom":return yJ_({propertyResolver:e,file:t,endpointName:r,paginationPropertyComponents:a});default:Ao(a)}}function OJ_({errors:e,file:t}){return e==null?[]:Object.values(e).map(r=>{let i=typeof r=="string"?r:r.error,n=b7i({errorName:i,file:t});return{docs:typeof r!="string"?r.docs:void 0,error:n}})}function Rhu({source:e}){return{filepath:e.relativeFilePath,packageName:e.packageName,options:e.csharpNamespace!=null?{csharp:{namespace:e.csharpNamespace}}:void 0}}function mJ_({source:e,serviceNameOverride:t}){let r=t??e.serviceName;if(r!=null)return{file:Rhu({source:e}),name:g7i.generateName(r)}}function PJ_({file:e,serviceDeclaration:t,sourceResolver:r}){return fir(t.source)?wJ_(e,t.source,r,t.transport?.grpc?.["service-name"]):S3e.http()}function jJ_({file:e,serviceTransport:t,endpointDeclaration:r,sourceResolver:i}){let n=t.type==="grpc",a=t.type==="http",u=fir(r.source),c=!u;if(n){if(a&&u)throw new Error("Cannot have a grpc endpoint on an http service");if(n&&c)return S3e.http();if(n&&u){let d=r.source,s=r.transport?.grpc?.["service-name"];return s?wJ_(e,d,i,s):void 0}throw new Error(`Internal error; failed to determine endpoint transport for
|
|
2313
|
-
${JSON.stringify(r)}"`)}}function wJ_(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=mJ_({source:n,serviceNameOverride:i});if(a==null)throw new Error(`Failed to resolve service name from ${n.relativeFilePath}.`);return S3e.grpc({service:a})}function SJ_({rootDefaultUrl:e,rootPathParameters:t,serviceDefinition:r,file:i,errorResolver:n,typeResolver:a,propertyResolver:u,exampleResolver:c,variableResolver:d,sourceResolver:s,globalErrors:o,workspace:l}){let b=pZn({pathParameters:r["path-parameters"],location:D3e.Service,file:i,variableResolver:d}),g=PJ_({file:i,serviceDeclaration:r,sourceResolver:s}),O={fernFilepath:i.fernFilepath};return{availability:ase(r.availability),name:O,displayName:r["display-name"]??void 0,basePath:b7(r["base-path"]),headers:r.headers!=null?Object.entries(r.headers).map(([P,D])=>e6e({headerKey:P,header:D,file:i})):[],pathParameters:b,encoding:ebM(g,r),transport:g,endpoints:Object.entries(r.endpoints).map(([P,D])=>{let A=pZn({pathParameters:hJt(D),location:D3e.Endpoint,file:i,variableResolver:d}),M={...nY(D),id:"",name:i.casingsGenerator.generateName(P),displayName:D["display-name"],auth:D.auth??r.auth,idempotent:D.idempotent??r.idempotent??!1,baseUrl:D.url??r.url??e,v2BaseUrls:void 0,method:D.method!=null?kvM(D.method):uI.Post,basePath:D["base-path"]!=null?b7(D["base-path"]):void 0,path:b7(D.path),fullPath:b7(D["base-path"]!=null?Wb(D["base-path"],D.path):i.rootApiFile["base-path"]!=null?Wb(i.rootApiFile["base-path"],r["base-path"],D.path):Wb(r["base-path"],D.path)),pathParameters:A,allPathParameters:D["base-path"]!=null?A:[...t,...b,...A],queryParameters:typeof D.request!="string"&&D.request?.["query-parameters"]!=null?Object.entries(D.request["query-parameters"]).map(([E,T])=>xhu({file:i,queryParameterKey:E,queryParameter:T})):[],headers:typeof D.request!="string"&&D.request?.headers!=null?Object.entries(D.request.headers).map(([E,T])=>e6e({headerKey:E,header:T,file:i})):[],requestBody:RQ_({request:D.request,file:i}),v2RequestBodies:void 0,sdkRequest:VQ_({service:r,request:D.request,endpoint:D,endpointKey:P,file:i,typeResolver:a,propertyResolver:u}),response:_J_({endpoint:D,file:i,typeResolver:a}),v2Responses:void 0,errors:[...OJ_({errors:D.errors,file:i}),...o],userSpecifiedExamples:D.examples!=null?D.examples.map(E=>{try{let T=pJ_({service:r,endpoint:D,example:E,typeResolver:a,errorResolver:n,exampleResolver:c,variableResolver:d,file:i,workspace:l});return T===void 0?void 0:{example:T,codeSamples:E["code-samples"]?.map(z=>WQ_({codeSample:z,file:i}))}}catch{return}}).filter(E=>E!==void 0):[],autogeneratedExamples:[],pagination:gJ_({propertyResolver:u,file:i,endpointName:P,endpointSchema:D}),transport:jJ_({file:i,serviceTransport:g,endpointDeclaration:D,sourceResolver:s}),v2Examples:void 0,source:void 0,audiences:D.audiences};return M.id=fP.generateEndpointId(O,M),M}),audiences:r.audiences}}function pZn({pathParameters:e,location:t,file:r,variableResolver:i}){return e==null?[]:Object.entries(e).map(([n,a])=>XvM({parameterName:n,parameter:a,location:t,file:r,variableResolver:i}))}function XvM({parameterName:e,parameter:t,location:r,file:i,variableResolver:n}){return{...nY(t),name:i.casingsGenerator.generateName(e),valueType:ZvM({parameter:t,variableResolver:n,file:i}),location:r,variable:pUn(t)?n.getVariableIdOrThrow(typeof t=="string"?t:t.variable):void 0,v2Examples:{userSpecifiedExamples:{},autogeneratedExamples:{}}}}function ZvM({parameter:e,variableResolver:t,file:r}){let i=BVa({parameter:e,variableResolver:t,file:r});return i.file.parseTypeReference(i.rawType)}function BVa({parameter:e,variableResolver:t,file:r}){let i=Nhu({parameter:e,variableResolver:t,file:r});if(i==null)throw new Error("Cannot resolve path parameter");return i}function Nhu({parameter:e,variableResolver:t,file:r}){if(pUn(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 kvM(e){switch(e){case"GET":return uI.Get;case"POST":return uI.Post;case"PUT":return uI.Put;case"PATCH":return uI.Patch;case"DELETE":return uI.Delete;case"HEAD":return uI.Head;default:Ao(e)}}function e6e({headerKey:e,header:t,file:r}){let{name:i}=cur({headerKey:e,header:t});return{...nY(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 cur({headerKey:e,header:t}){return typeof t!="string"&&t.name!=null?{name:t.name,wasExplicitlySet:!0}:{name:e,wasExplicitlySet:!1}}function ebM(e,t){switch(e.type){case"http":return{json:{},proto:void 0};case"grpc":return{json:void 0,proto:{}};default:Ao(e)}}var DJ_="1.0.0";var Fhu=class{ir;casingsGenerator;auth;authValues;generatorConfig;constructor(t){this.ir=t.ir,this.generatorConfig=t.generatorConfig,this.casingsGenerator=Iee({generationLanguage:t.generationLanguage,smartCasing:t.smartCasing??!1,keywords:void 0}),this.auth=this.convertAuth(this.ir.auth),this.authValues=this.getAuthValues(this.ir.auth)}convert({disableExamples:t}){return{version:DJ_,types:this.convertNamedTypes(),headers:this.convertHeaders(),endpoints:this.convertEndpoints({disableExamples:t}),pathParameters:this.convertPathParameters({pathParameters:this.ir.pathParameters}),environments:this.ir.environments,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})}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:_s.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 _s.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 _s.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:Ao(t.sdkRequest.shape)}}convertReferencedRequestBodyType({body:t}){switch(t.type){case"bytes":return _s.ReferencedRequestBodyType.bytes();case"typeReference":return _s.ReferencedRequestBodyType.typeReference(this.convertTypeReference(t.requestBodyType));default:Ao(t)}}convertInlinedRequest({fernFilepath:t,wrapper:r,pathParameters:i,queryParameters:n,headers:a,body:u}){return _s.Request.inlined({declaration:this.convertDeclaration({name:r.wrapperName,fernFilepath:t}),pathParameters:i,queryParameters:n,headers:a,body:u!=null?this.convertInlinedRequestBody({wrapper:r,body:u}):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 _s.InlinedRequestBody.properties(this.convertWireValueParameters({wireValueParameters:i}))}case"reference":return _s.InlinedRequestBody.referenced({bodyKey:t.bodyKey,bodyType:_s.ReferencedRequestBodyType.typeReference(this.convertTypeReference(r.requestBodyType))});case"bytes":return _s.InlinedRequestBody.referenced({bodyKey:t.bodyKey,bodyType:_s.ReferencedRequestBodyType.bytes()});case"fileUpload":return this.convertFileUploadRequestBody({properties:r.properties});default:Ao(r)}}convertFileUploadRequestBody({properties:t}){return _s.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 _s.FileUploadRequestBodyProperty.bodyProperty({name:r.name,typeReference:this.convertTypeReference(r.valueType)});default:Ao(r)}})}convertFileUploadRequestBodyFileProperty({fileProperty:t}){switch(t.type){case"file":return _s.FileUploadRequestBodyProperty.file(t.key);case"fileArray":return _s.FileUploadRequestBodyProperty.fileArray(t.key);default:Ao(t)}}convertPathParameters({pathParameters:t}){return t.map(r=>({name:{name:r.name,wireValue:r.name.originalName},typeReference:this.convertTypeReference(r.valueType)}))}convertWireValueParameters({wireValueParameters:t}){return t.map(r=>({name:{name:r.name.name,wireValue:r.name.wireValue},typeReference:this.convertTypeReference(r.valueType)}))}convertQueryParameters({queryParameters:t}){let r=[];for(let i of t){let n=this.convertTypeReference(i.valueType);i.allowMultiple&&(n=_s.TypeReference.list(n)),r.push({name:{name:i.name.name,wireValue:i.name.wireValue},typeReference:n})}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:Ao(t)}}convertContainerType(t){switch(t.type){case"list":return _s.TypeReference.list(this.convertTypeReference(t.list));case"map":return _s.TypeReference.map({key:this.convertTypeReference(t.keyType),value:this.convertTypeReference(t.valueType)});case"optional":return _s.TypeReference.optional(this.convertTypeReference(t.optional));case"nullable":return _s.TypeReference.nullable(this.convertTypeReference(t.nullable));case"set":return _s.TypeReference.set(this.convertTypeReference(t.set));case"literal":return _s.TypeReference.literal(this.convertLiteral(t.literal));default:Ao(t)}}convertNamedType(t){return _s.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});case"union":return this.convertDiscriminatedUnion({declaration:r,union:t.shape});case"undiscriminatedUnion":return this.convertUndiscriminatedUnion({declaration:r,union:t.shape});default:Ao(t.shape)}}convertAlias({declaration:t,alias:r}){return _s.NamedType.alias({declaration:t,typeReference:this.convertTypeReference(r.aliasOf)})}convertEnum({declaration:t,enum_:r}){return _s.NamedType.enum({declaration:t,values:r.values.map(i=>i.name)})}convertObject({declaration:t,object:r}){let i=[...r.extendedProperties??[],...r.properties];return this.convertObjectProperties({declaration:t,properties:i,additionalProperties:r.extraProperties})}convertObjectProperties({declaration:t,properties:r,additionalProperties:i}){return _s.NamedType.object({declaration:t,properties:this.convertWireValueParameters({wireValueParameters:r}),additionalProperties:i})}convertDiscriminatedUnion({declaration:t,union:r}){let i=[...this.resolveProperties(r.extends),...r.baseProperties];return _s.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:Ao(i)}}convertDiscriminatedUnionTypeObject({inheritedProperties:t,discriminantValue:r,declaredTypeName:i}){return _s.SingleDiscriminatedUnionType.samePropertiesAsObject({typeId:i.typeId,discriminantValue:r,properties:this.convertWireValueParameters({wireValueParameters:t})})}convertDiscriminatedUnionTypeSingleProperty({inheritedProperties:t,discriminantValue:r,singleUnionTypeProperty:i}){return _s.SingleDiscriminatedUnionType.singleProperty({typeReference:this.convertTypeReference(i.type),discriminantValue:r,properties:t.length>0?this.convertWireValueParameters({wireValueParameters:t}):void 0})}convertDiscriminatedUnionTypeNoProperties({inheritedProperties:t,discriminantValue:r}){return _s.SingleDiscriminatedUnionType.noProperties({discriminantValue:r,properties:t.length>0?this.convertWireValueParameters({wireValueParameters:t}):void 0})}convertUndiscriminatedUnion({declaration:t,union:r}){return _s.NamedType.undiscriminatedUnion({declaration:t,types:r.members.map(i=>this.convertTypeReference(i.type))})}convertLiteral(t){switch(t.type){case"boolean":return _s.LiteralType.boolean(t.boolean);case"string":return _s.LiteralType.string(t.string);default:Ao(t)}}convertPrimitiveType(t){return _s.TypeReference.primitive(t.v1)}convertUnknownType(){return _s.TypeReference.unknown()}convertAuth(t){if(t.schemes[0]==null)return;let r=t.schemes[0];switch(r.type){case"basic":return _s.Auth.basic(r);case"bearer":return _s.Auth.bearer(r);case"header":return _s.Auth.header({header:{name:r.name,typeReference:this.convertTypeReference(r.valueType)}});case"oauth":return _s.Auth.oauth({clientId:this.casingsGenerator.generateName("clientId"),clientSecret:this.casingsGenerator.generateName("clientSecret")});case"inferred":return _s.Auth.inferred({});default:Ao(r)}}getAuthValues(t){let r=t.schemes[0];if(r!=null)switch(r.type){case"bearer":return _s.AuthValues.bearer({token:"<token>"});case"basic":return _s.AuthValues.basic({username:"<username>",password:"<password>"});case"header":return _s.AuthValues.header({value:"<value>"});case"oauth":return _s.AuthValues.oauth({clientId:"<clientId>",clientSecret:"<clientSecret>"});case"inferred":return _s.AuthValues.inferred({});default:Ao(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=Wb(r,t.fullPath.head));for(let i of t.fullPath.parts)r=Wb(r,"{"+i.pathParameter+"}"),i.tail.length>0&&(r=Wb(r,i.tail));return r.startsWith("/")?r:`/${r}`}getEndpointSnippetRequests({endpoint:t,location:r}){let i=[];for(let n of[...t.userSpecifiedExamples,...t.autogeneratedExamples])i.push({id:n?.example?.id??Oue(),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(a=>[a.name.wireValue,a.value.jsonExample])),pathParameters:Object.fromEntries([...n.example?.rootPathParameters??[],...n.example?.servicePathParameters??[],...n.example?.endpointPathParameters??[]].map(a=>[a.name.originalName,a.value.jsonExample])),queryParameters:Object.fromEntries([...n.example?.queryParameters??[]].map(a=>[a.name.wireValue,a.value.jsonExample])),requestBody:n.example?.request?.jsonExample});return i}};function IVa({ir:e,generationLanguage:t,smartCasing:r,disableExamples:i,generatorConfig:n}){return new Fhu({ir:e,generationLanguage:t,smartCasing:r,generatorConfig:n}).convert({disableExamples:i})}var aY={};xa(aY,{validateObjectExample:()=>Gon,validateTypeExample:()=>Ihu,validateTypeReferenceExample:()=>WU});function EJ_(e){return{errorInstanceIdKey:e.generateNameAndWireValue({wireValue:"errorInstanceId",name:"errorInstanceId"})}}var Lhu=e=>{let t=Sqe(e.file.fernFilepath),r=e.endpointId;return`endpoint_${t}.${r}`};function Uhu({fernFilePath:e}){return e.packagePath.length===0&&e.file==null}function Vhu({resolvedEndpoint:e}){return{endpointId:Lhu(e),serviceId:fP.generateServiceIdFromFernFilepath(e.file.fernFilepath),subpackageId:Uhu({fernFilePath:e.file.fernFilepath})?void 0:fP.generateSubpackageId(e.file.fernFilepath)}}function MJ_({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:Lhu(n),serviceId:fP.generateServiceIdFromFernFilepath(n.file.fernFilepath),subpackageId:Uhu({fernFilePath:n.file.fernFilepath})?void 0:fP.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 AJ_({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??{}:{},u;try{u=i.responseProperties.expires_in!=null?t.resolveResponsePropertyOrThrow({file:r,endpoint:i.endpoint,propertyComponents:i.responseProperties.expires_in}):void 0}catch{}return{endpointReference:Vhu({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:tbM({requestBodyProperties:a,tokenEndpoint:i,file:r,propertyResolver:t})},responseProperties:{accessToken:t.resolveResponsePropertyOrThrow({file:r,endpoint:i.endpoint,propertyComponents:i.responseProperties.access_token}),expiresIn:u,refreshToken:i.responseProperties.refresh_token!=null?t.resolveResponsePropertyOrThrow({file:r,endpoint:i.endpoint,propertyComponents:i.responseProperties.refresh_token}):void 0}}}var tbM=({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 qJ_({propertyResolver:e,endpointResolver:t,file:r,oauthScheme:i,tokenEndpoint:n,refreshTokenEndpoint:a}){let u=AJ_({propertyResolver:e,endpointResolver:t,file:r,tokenEndpoint:n});if(u==null)throw new Error("Failed to convert OAuth token endpoint.");let c=a!=null?MJ_({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:u,refreshEndpoint:c}}var zVa={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}},M7c={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 TJ_(e){return{endpoint:e["get-token"].endpoint,requestProperties:rbM({requestProperties:e["get-token"]?.["request-properties"]}),responseProperties:ibM({responseProperties:e["get-token"]?.["response-properties"]})}}function CJ_(e){if(e["refresh-token"]!=null)return{endpoint:e["refresh-token"].endpoint,requestProperties:nbM({requestProperties:e["refresh-token"]?.["request-properties"]}),responseProperties:abM({responseProperties:e["refresh-token"]?.["response-properties"]})}}function rbM({requestProperties:e}){if(e==null)return zVa.requestProperties;let t=e["client-id"],r=e["client-secret"],i=e.scopes;return{type:"access_token",client_id:t!=null?_Jt(t):zVa.requestProperties.client_id,client_secret:r!=null?_Jt(r):zVa.requestProperties.client_secret,scopes:i!=null?_Jt(i):zVa.requestProperties.scopes}}function ibM({responseProperties:e}){return BJ_({responseProperties:e,defaultValue:zVa.responseProperties})}function nbM({requestProperties:e}){if(e==null)return M7c.requestProperties;let t=e["refresh-token"];return{type:"refresh_token",refresh_token:t!=null?_Jt(t):M7c.requestProperties.refresh_token}}function abM({responseProperties:e}){return BJ_({responseProperties:e,defaultValue:M7c.responseProperties})}function BJ_({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?Kqe(r):t.access_token,expires_in:i!=null?Kqe(i):t.expires_in,refresh_token:n!=null?Kqe(n):t.refresh_token}}function NJ_({rawApiFileSchema:e,file:t,propertyResolver:r,endpointResolver:i}){if(e.auth==null)return{docs:void 0,requirement:zoe.All,schemes:[]};let n=typeof e.auth!="string"?e.auth.docs:void 0;return qen(e.auth,{single:a=>{let u=IJ_({reference:a,authSchemeDeclarations:e["auth-schemes"],file:t,propertyResolver:r,endpointResolver:i});return{docs:n,requirement:zoe.All,schemes:[u]}},any:({any:a})=>({docs:n,requirement:zoe.Any,schemes:a.map(u=>IJ_({reference:u,authSchemeDeclarations:e["auth-schemes"],file:t,propertyResolver:r,endpointResolver:i}))})})}function IJ_({reference:e,authSchemeDeclarations:t,file:r,propertyResolver:i,endpointResolver:n}){let a=(c,d)=>{let s=t?.[c];if(s==null)throw new Error("Unknown auth scheme: "+c);return PNa(s,{header:o=>iq.header({docs:d,name:r.casingsGenerator.generateNameAndWireValue({name:o.name??c,wireValue:o.header}),valueType:r.parseTypeReference(o.type??"string"),prefix:o.prefix,headerEnvVar:o.env}),basic:o=>xJ_({file:r,docs:d,rawScheme:o}),tokenBearer:o=>zJ_({file:r,docs:d,rawScheme:o}),inferredBearer:o=>obM({file:r,docs:d,rawScheme:o,propertyResolver:i,endpointResolver:n}),oauth:o=>RJ_({file:r,docs:d,rawScheme:o,propertyResolver:i,endpointResolver:n})})},u=typeof e=="string"?e:e.scheme;switch(u){case"bearer":return zJ_({file:r,docs:void 0,rawScheme:void 0});case"basic":return xJ_({file:r,docs:void 0,rawScheme:void 0});case"oauth":return RJ_({file:r,docs:void 0,rawScheme:void 0,propertyResolver:i,endpointResolver:n});default:return a(u,typeof e!="string"?e.docs:void 0)}}function zJ_({file:e,docs:t,rawScheme:r}){return iq.bearer({docs:t,token:e.casingsGenerator.generateName(r?.token?.name??"token"),tokenEnvVar:r?.token?.env})}function xJ_({file:e,docs:t,rawScheme:r}){return iq.basic({docs:t,username:e.casingsGenerator.generateName(r?.username?.name??"username"),usernameEnvVar:r?.username?.env,password:e.casingsGenerator.generateName(r?.password?.name??"password"),passwordEnvVar:r?.password?.env})}function RJ_({file:e,docs:t,rawScheme:r,propertyResolver:i,endpointResolver:n}){switch(r?.type){case"client-credentials":return iq.oauth({docs:t,configuration:rzi.clientCredentials(qJ_({propertyResolver:i,endpointResolver:n,file:e,oauthScheme:r,tokenEndpoint:TJ_(r),refreshTokenEndpoint:CJ_(r)}))});default:throw new Error(`Unknown OAuth type: '${r?.type}'`)}}function obM({file:e,docs:t,rawScheme:r,propertyResolver:i,endpointResolver:n}){return iq.inferred({docs:t,tokenEndpoint:ubM({file:e,rawScheme:r,propertyResolver:i,endpointResolver:n})})}function ubM({file:e,rawScheme:t,propertyResolver:r,endpointResolver:i}){let n=t["get-token"],a=typeof n=="string"?{endpoint:n}:n,u=i.resolveEndpointOrThrow({endpoint:a.endpoint,file:e});return{endpoint:Vhu({resolvedEndpoint:u}),expiryProperty:dbM({tokenEndpoint:u,getTokenEndpointConfig:a,propertyResolver:r}),authenticatedRequestHeaders:cbM({tokenEndpoint:u,getTokenEndpointConfig:a,propertyResolver:r})}}var sbM=["access_token","accessToken","AccessToken","token","Token","auth_token","authToken","AuthToken","bearer_token","bearerToken","BearerToken","jwt","Jwt","authentication_token","authenticationToken","AuthenticationToken"];function cbM({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:Kqe(a["response-property"])}),valuePrefix:a["value-prefix"]})}),!i.has("authorization")){let a=lbM({tokenEndpoint:e,propertyResolver:r});a&&i.set("authorization",{headerName:"Authorization",responseProperty:a,valuePrefix:"Bearer "})}return Array.from(i.values())}function lbM({tokenEndpoint:e,propertyResolver:t}){for(let r of sbM)try{let i=t.resolveResponseProperty({file:e.file,endpoint:e.endpointId,propertyComponents:[r]});if(i)return i}catch{}}var fbM=["expires_in","expiresIn","ExpiresIn","exp","Exp","expiry","Expiry","expires","Expires","expires_at","expiresAt","ExpiresAt","expiration","Expiration","valid_until","validUntil","ValidUntil"];function dbM({tokenEndpoint:e,getTokenEndpointConfig:t,propertyResolver:r}){if(t["expiry-response-property"])return r.resolveResponsePropertyOrThrow({file:e.file,endpoint:e.endpointId,propertyComponents:Kqe(t["expiry-response-property"])});for(let i of fbM)try{let n=r.resolveResponseProperty({file:e.file,endpoint:e.endpointId,propertyComponents:[i]});if(n)return n}catch{}}function FJ_({file:e,rawApiFileSchema:t}){if(t.version!=null)return nzi.header({header:pbM({file:e,header:t.version.header}),value:_bM({file:e,versionDeclaration:t.version})})}function pbM({file:e,header:t}){return typeof t=="string"?e6e({file:e,headerKey:t,header:{type:"string"}}):e6e({file:e,headerKey:t.value,header:{type:"string",name:t.name,env:t.env}})}function _bM({file:e,versionDeclaration:t}){return zhu({_enum:{default:t.default,enum:t.values},file:e})}function LJ_({channel:e,typeResolver:t,exampleResolver:r,variableResolver:i,file:n,workspace:a}){let u=[];for(let[c,d]of Object.entries(e.messages??{}))u.push({type:c,availability:ase(d.availability),docs:d.docs,origin:d.origin,body:vbM({body:d.body,file:n}),displayName:d["display-name"]});return{availability:ase(e.availability),path:b7(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,d])=>e6e({headerKey:c,header:d,file:n})):[],docs:e.docs,pathParameters:e["path-parameters"]!=null?pZn({pathParameters:e["path-parameters"],location:D3e.Endpoint,file:n,variableResolver:i}):[],queryParameters:e["query-parameters"]!=null?Object.entries(e["query-parameters"]).map(([c,d])=>{let{name:s}=rji({queryParameterKey:c,queryParameter:d}),o=n.parseTypeReference(d);return{...nY(d),name:n.casingsGenerator.generateNameAndWireValue({wireValue:c,name:s}),valueType:o,allowMultiple:typeof d!="string"&&d["allow-multiple"]!=null?d["allow-multiple"]:!1,v2Examples:{userSpecifiedExamples:{},autogeneratedExamples:{}}}}):[],messages:Object.values(u),examples:(e.examples??[]).map(c=>{let d=gbM({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:mbM({channel:e,example:c,pathParams:d}),...d,...ObM({channel:e,example:c,typeResolver:t,exampleResolver:r,file:n,workspace:a}),queryParameters:c["query-parameters"]!=null?Object.entries(c["query-parameters"]).map(([s,o])=>{let l=e["query-parameters"]?.[s];if(l==null)throw new Error(`Query parameter ${s} does not exist`);return{name:n.casingsGenerator.generateNameAndWireValue({name:rji({queryParameterKey:s,queryParameter:l}).name,wireValue:s}),value:$M({example:o,rawTypeBeingExemplified:typeof l=="string"?l:l.type,typeResolver:t,exampleResolver:r,fileContainingRawTypeReference:n,fileContainingExample:n,workspace:a}),shape:hbM({queryParameter:l})}}):[],messages:c.messages.map(s=>{let o=e.messages?.[s.type];if(o==null)throw new Error(`Message ${s.type} does not exist`);return{type:s.type,body:ybM({message:o,example:s.body,typeResolver:t,exampleResolver:r,file:n,workspace:a})}})}}),v2Examples:{userSpecifiedExamples:{},autogeneratedExamples:{}}}}function hbM({queryParameter:e}){return(typeof e!="string"&&e["allow-multiple"]!=null?e["allow-multiple"]:!1)?s5.exploded():s5.single()}function ybM({message:e,example:t,typeResolver:r,exampleResolver:i,file:n,workspace:a}){if(!PbM(e.body))return JAe.reference($M({example:t,rawTypeBeingExemplified:typeof e.body!="string"?e.body.type:e.body,typeResolver:r,exampleResolver:i,fileContainingRawTypeReference:n,fileContainingExample:n,workspace:a}));if(!Rw(t))throw new Error("Example must be an object");let u=[];for(let[c,d]of Object.entries(t)){let s=e.body.properties?.[c];if(s!=null)u.push({name:n.casingsGenerator.generateNameAndWireValue({name:VU({propertyKey:c,property:s}).name,wireValue:c}),value:$M({example:d,rawTypeBeingExemplified:typeof s!="string"?s.type:s,typeResolver:r,exampleResolver:i,fileContainingRawTypeReference:n,fileContainingExample:n,workspace:a}),originalTypeDeclaration:void 0});else{let o=CVa({extends_:e.body.extends,wirePropertyKey:c,typeResolver:r,file:n});if(o==null)throw new Error("Could not find original type declaration for property: "+c);u.push({name:n.casingsGenerator.generateNameAndWireValue({name:VU({propertyKey:c,property:o.rawPropertyType}).name,wireValue:c}),value:$M({example:d,rawTypeBeingExemplified:typeof o.rawPropertyType=="string"?o.rawPropertyType:o.rawPropertyType.type,typeResolver:r,exampleResolver:i,fileContainingRawTypeReference:o.file,fileContainingExample:n,workspace:a}),originalTypeDeclaration:o.typeName})}}return JAe.inlinedBody({jsonExample:i.resolveAllReferencesInExampleOrThrow({example:t,file:n}).resolvedExample,properties:u})}function vbM({body:e,file:t}){return typeof e=="string"?iU.reference({docs:void 0,bodyType:t.parseTypeReference(e)}):bbM(e)?iU.reference({docs:void 0,bodyType:t.parseTypeReference(e.type)}):iU.inlinedBody({name:t.casingsGenerator.generateName(e.name),extends:pJt(e.extends??[]).map(r=>UU({typeName:r,file:t})),properties:Object.entries(e.properties??{}).map(([r,i])=>({name:t.casingsGenerator.generateNameAndWireValue({name:VU({propertyKey:r,property:i}).name,wireValue:r}),value:t.parseTypeReference(i),valueType:t.parseTypeReference(i),availability:void 0,docs:void 0}))})}function bbM(e){return e.type!=null}function gbM({channel:e,example:t,typeResolver:r,exampleResolver:i,variableResolver:n,file:a,workspace:u}){let c=[],d=({name:s,pathParameterDeclaration:o,examplePathParameter:l})=>{let b=BVa({parameter:o,variableResolver:n,file:a});return{name:s,value:$M({example:l,rawTypeBeingExemplified:b.rawType,typeResolver:r,exampleResolver:i,fileContainingRawTypeReference:b.file,fileContainingExample:a,workspace:u})}};if(t["path-parameters"]!=null){let s=hJt(e);for(let[o,l]of Object.entries(t["path-parameters"])){let b=s[o];if(b!=null)c.push(d({name:a.casingsGenerator.generateName(o),pathParameterDeclaration:b,examplePathParameter:l}));else throw new Error(`Path parameter ${o} does not exist`)}}return{pathParameters:c}}function ObM({channel:e,example:t,typeResolver:r,exampleResolver:i,file:n,workspace:a}){let u=[];if(t.headers!=null)for(let[c,d]of Object.entries(t.headers)){let s=e.headers?.[c];if(s!=null)u.push({name:n.casingsGenerator.generateNameAndWireValue({name:cur({headerKey:c,header:s}).name,wireValue:c}),value:$M({example:d,rawTypeBeingExemplified:typeof s=="string"?s:s.type,typeResolver:r,exampleResolver:i,fileContainingRawTypeReference:n,fileContainingExample:n,workspace:a})});else throw new Error(`Heder ${c} does not exist`)}return{headers:u}}function mbM({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 PbM(e){return typeof e=="string"?!1:e.extends!=null||e.properties!=null}function UJ_({errorName:e,errorDeclaration:t,file:r,typeResolver:i,exampleResolver:n,workspace:a}){let u=[];if(t.type!=null&&t.examples!=null)for(let c of t.examples)u.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:$M({example:c.value,rawTypeBeingExemplified:t.type,fileContainingRawTypeReference:r,fileContainingExample:r,typeResolver:i,exampleResolver:n,workspace:a})});return{name:b7i({errorName:e,file:r}),discriminantValue:r.casingsGenerator.generateNameAndWireValue({wireValue:e,name:e}),docs:typeof t!="string"?t.docs:void 0,statusCode:t["status-code"],type:t.type!=null?r.parseTypeReference(t.type):void 0,examples:u,v2Examples:void 0,displayName:void 0}}var VJ_="content";function WJ_(e,t){if(e==null||e.strategy==="status-code")return QAe.statusCode();switch(e.strategy){case"property":return QAe.property({discriminant:t.casingsGenerator.generateNameAndWireValue({name:e["property-name"],wireValue:e["property-name"]}),contentProperty:t.casingsGenerator.generateNameAndWireValue({name:VJ_,wireValue:VJ_})});default:Ao(e)}}function HJ_({readme:e,services:t}){let r=new A7c(t);return{apiName:e.apiName,disabledFeatures:e.disabledSections?.map(i=>i.toUpperCase()),apiReferenceLink:e.apiReferenceLink,bannerLink:e.bannerLink,introduction:e.introduction,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 A7c=class{endpoints={};constructor(t){this.endpoints=this.buildEndpoints(t)}getEndpointForReadme(t){let r=wbM({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:jbM(t),stream:t.response?.body?.type==="streaming"})}getEndpointKey({method:t,path:r,stream:i}){return`${t}|${r}|${i}`}};function jbM(e){let t="";e.fullPath.head.length>0&&(t=Wb(t,e.fullPath.head));for(let r of e.fullPath.parts)t=Wb(t,"{"+r.pathParameter+"}"),r.tail.length>0&&(t=Wb(t,r.tail));return t.startsWith("/")?t:`/${t}`}function wbM({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 $J_({webhooks:e,file:t,typeResolver:r,exampleResolver:i,workspace:n}){let a=[];for(let[u,c]of Object.entries(e))a.push({id:fP.generateWebhookId(t.fernFilepath,u),availability:ase(c.availability),displayName:c["display-name"],docs:c.docs,method:c.method,name:t.casingsGenerator.generateName(u),headers:c.headers!=null?Object.entries(c.headers).map(([d,s])=>e6e({headerKey:d,header:s,file:t})):[],payload:SbM({payload:c.payload,file:t}),examples:c.examples!=null?EbM({webhook:c,examples:c.examples,file:t,typeResolver:r,exampleResolver:i,workspace:n}):void 0,v2Examples:void 0});return a}function SbM({payload:e,file:t}){return typeof e=="string"?XH.reference({docs:void 0,payloadType:t.parseTypeReference(e)}):rJn(e)?XH.reference({docs:void 0,payloadType:t.parseTypeReference(e.type)}):XH.inlinedPayload({name:t.casingsGenerator.generateName(e.name),extends:pJt(e.extends).map(r=>UU({typeName:r,file:t})),properties:e.properties!=null?Object.entries(e.properties).map(([r,i])=>DbM({propertyKey:r,propertyDefinition:i,docs:typeof i!="string"?i.docs:void 0,availability:typeof i!="string"?ase(i.availability):void 0,file:t})):[]})}function DbM({propertyKey:e,propertyDefinition:t,docs:r,availability:i,file:n}){return{docs:r,availability:i,name:n.casingsGenerator.generateNameAndWireValue({wireValue:e,name:VU({propertyKey:e,property:t}).name}),valueType:n.parseTypeReference(t)}}function EbM({webhook:e,examples:t,file:r,typeResolver:i,exampleResolver:n,workspace:a}){let u=typeof e.payload=="string"?e.payload:rJn(e.payload)?e.payload.type:void 0;if(u!=null)return t.map(c=>({docs:e.docs,name:c.name!=null?r.casingsGenerator.generateName(c.name):void 0,payload:$M({example:c.payload,rawTypeBeingExemplified:u,fileContainingRawTypeReference:r,fileContainingExample:r,typeResolver:i,exampleResolver:n,workspace:a})}));if(!Rw(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:$M({example:c.payload,rawTypeBeingExemplified:"map<string, unknown>",fileContainingRawTypeReference:r,fileContainingExample:r,typeResolver:i,exampleResolver:n,workspace:a})}))}function GJ_({name:e,source:t}){return Uw.userDefined({file:Rhu({source:t}),name:g7i.generateName(e)})}function QJ_({encoding:e}){if(e.proto!=null&&e.proto.type!=null){let t=MbM({type:e.proto.type});if(t!=null)return t}}function MbM({type:e}){switch(e){case"google.protobuf.Any":return Uw.wellKnown(vd.any());case"google.protobuf.Api":return Uw.wellKnown(vd.api());case"google.protobuf.BoolValue":return Uw.wellKnown(vd.boolValue());case"google.protobuf.BytesValue":return Uw.wellKnown(vd.bytesValue());case"google.protobuf.DoubleValue":return Uw.wellKnown(vd.doubleValue());case"google.protobuf.Duration":return Uw.wellKnown(vd.duration());case"google.protobuf.Empty":return Uw.wellKnown(vd.empty());case"google.protobuf.Enum":return Uw.wellKnown(vd.enum());case"google.protobuf.EnumValue":return Uw.wellKnown(vd.enumValue());case"google.protobuf.Field":return Uw.wellKnown(vd.field());case"google.protobuf.FieldCardinality":return Uw.wellKnown(vd.fieldCardinality());case"google.protobuf.FieldKind":return Uw.wellKnown(vd.fieldKind());case"google.protobuf.FieldMask":return Uw.wellKnown(vd.fieldMask());case"google.protobuf.FloatVlaue":return Uw.wellKnown(vd.floatValue());case"google.protobuf.Int32Value":return Uw.wellKnown(vd.int32Value());case"google.protobuf.Int64Value":return Uw.wellKnown(vd.int64Value());case"google.protobuf.ListValue":return Uw.wellKnown(vd.listValue());case"google.protobuf.Method":return Uw.wellKnown(vd.method());case"google.protobuf.Mixin":return Uw.wellKnown(vd.mixin());case"google.protobuf.NullValue":return Uw.wellKnown(vd.nullValue());case"google.protobuf.Option":return Uw.wellKnown(vd.option());case"google.protobuf.SourceContext":return Uw.wellKnown(vd.sourceContext());case"google.protobuf.StringValue":return Uw.wellKnown(vd.stringValue());case"google.protobuf.Struct":return Uw.wellKnown(vd.struct());case"google.protobuf.Syntax":return Uw.wellKnown(vd.syntax());case"google.protobuf.Timestamp":return Uw.wellKnown(vd.timestamp());case"google.protobuf.Type":return Uw.wellKnown(vd.type());case"google.protobuf.Uint32Value":return Uw.wellKnown(vd.uint32Value());case"google.protobuf.Uint64Value":return Uw.wellKnown(vd.uint64Value());case"google.protobuf.Value":return Uw.wellKnown(vd.value())}}function JJ_({generic:e,file:t,typeResolver:r}){let i=typeof e=="string"?e:e.type,n=vN(i);if(n==null)throw new Error(`Invalid generic type definition: ${i}`);let a=r.getDeclarationOfNamedTypeOrThrow({referenceToNamedType:i,file:t});if(n.arguments&&TD(a.declaration)){let u=vN(a.typeName)?.arguments??[],c=Object.entries(a.declaration.properties??{}).map(([d,s])=>{let o=s;return typeof s=="string"&&u?.includes(s)&&(o=n.arguments?.[u.indexOf(s)]??s),[d,o]});return a0.object({extends:pJt(a.declaration.extends).map(d=>UU({typeName:d,file:t})),properties:EVa({properties:Object.fromEntries(c)},t),extraProperties:a.declaration["extra-properties"]??!1,extendedProperties:void 0})}throw new Error(`Generic type definition not supported: ${i}`)}function KJ_({alias:e,file:t,typeResolver:r}){let i=typeof e=="string"?e:e.type;return j3e(i)?JJ_({generic:i,file:t,typeResolver:r}):a0.alias({aliasOf:t.parseTypeReference(e),resolvedType:AbM({aliasOf:i,file:t,typeResolver:r})})}function AbM({aliasOf:e,file:t,typeResolver:r}){let i=r.resolveTypeOrThrow({type:e,file:t});switch(i._type){case"primitive":return YH.primitive(i.originalTypeReference.primitive);case"container":return YH.container(i.originalTypeReference.container);case"unknown":return YH.unknown();case"named":{let n=TD(i.declaration)?PGt.Object:yzi(i.declaration)?PGt.Union:DGt(i.declaration)?PGt.Enum:_Un(i.declaration)?PGt.UndiscriminatedUnion:Ao(i.declaration);return YH.named({name:i.name,shape:n})}}}function YJ_({union:e,file:t}){let r=e.union.filter((i,n)=>{let a=typeof i=="string"?i:i.type;return e.union.findIndex(u=>(typeof u=="string"?u:u.type)===a)===n});return a0.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"?YAo(n.name.originalName):i["display-name"]??YAo(n.name.originalName)}:n,docs:typeof i=="string"?void 0:i.docs}})})}function XJ_(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 T7c({typeDeclaration:e,file:t,typeResolver:r,seenTypeNames:i=new q7c}){let n=DF(e,{alias:u=>{let c=typeof u=="string"?u:u.type,d=vN(c);if(d!=null){let s=new Set(d.arguments??[]),o=r.getDeclarationOfNamedTypeOrThrow({referenceToNamedType:c,file:t}),l=vN(o.typeName)?.arguments;if(TD(o.declaration)){let b=XJ_(o.declaration);l&&b.filter(g=>!l.includes(g)).forEach(g=>s.add(g))}return Array.from(s)}return[c]},object:u=>XJ_(u),discriminatedUnion:u=>{let c=[];return u["base-properties"]!=null&&c.push(...Object.values(u["base-properties"]).map(d=>typeof d=="string"?d:d.type)),c.push(...Object.values(u.union).reduce((d,s)=>{let o=typeof s=="string"?s:s.type;return typeof o=="string"&&d.push(o),d},[])),c},undiscriminatedUnion:u=>Object.values(u.union).reduce((c,d)=>{let s=typeof d=="string"?d:d.type;return typeof s=="string"&&c.push(s),c},[]),enum:()=>[]}),a=[];for(let u of n){let c=SF({type:u,_default:void 0,validation:void 0,visitor:{primitive:()=>[],map:({keyType:d,valueType:s})=>[...d,...s],list:d=>d,optional:d=>d,nullable:d=>d,set:d=>d,named:d=>[d],literal:()=>[],unknown:()=>[]}});for(let d of c){let s=UU({typeName:d,file:t});if(!i.hasTypeNameBeenSeen(s)){i.addTypeName(s),a.push(s);let o=r.getDeclarationOfNamedTypeOrThrow({referenceToNamedType:d,file:t});if(j3e(o.typeName))continue;a.push(...T7c({typeDeclaration:o.declaration,file:o.file,typeResolver:r,seenTypeNames:i}))}}}return a}var q7c=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 ZJ_({typeName:e,typeDeclaration:t,file:r,typeResolver:i,exampleResolver:n,sourceResolver:a,workspace:u}){let c=nY(t),d=UU({typeName:e,file:r}),s=T7c({typeDeclaration:t,file:r,typeResolver:i}),o={};TD(t)&&(o=Zin(t.properties??{}));let l=TbM({file:r,typeDeclaration:t,typeName:e,sourceResolver:a});return{propertiesByAudience:o,typeDeclaration:{...c,inline:zbM(t),name:d,shape:qbM({typeDeclaration:t,file:r,typeResolver:i}),referencedTypes:new Set(s.map(b=>b.typeId)),encoding:CbM({typeDeclaration:t,source:l}),source:l,userProvidedExamples:typeof t!="string"&&t.examples!=null?t.examples.map(b=>({name:b.name!=null?r.casingsGenerator.generateName(b.name):void 0,docs:b.docs,jsonExample:n.resolveAllReferencesInExampleOrThrow({example:b.value,file:r}).resolvedExample,shape:E7c({typeName:d,example:b.value,typeResolver:i,exampleResolver:n,typeDeclaration:t,fileContainingType:r,fileContainingExample:r,workspace:u})})):[],autogeneratedExamples:[],v2Examples:void 0},descendantFilepaths:new Set(s.map(b=>b.fernFilepath))}}function qbM({typeDeclaration:e,file:t,typeResolver:r}){return DF(e,{alias:i=>KJ_({alias:i,file:t,typeResolver:r}),object:i=>zQ_({object:i,file:t}),discriminatedUnion:i=>YQ_({union:i,file:t,typeResolver:r}),undiscriminatedUnion:i=>YJ_({union:i,file:t}),enum:i=>a0.enum(zhu({_enum:i,file:t}))})}function TbM({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=QJ_({encoding:t.encoding});if(a!=null)return nOi.proto(a)}if(t.source==null)return;let n=i.resolveSourceOrThrow({source:t.source,relativeFilepath:e.relativeFilepath});if(!(n==null||n.type!=="protobuf"))return nOi.proto(GJ_({source:n,name:r}))}function CbM({typeDeclaration:e,source:t}){return typeof e!="string"&&e.encoding!=null?BbM(e.encoding):IbM(t)}function BbM(e){return e.proto!=null?{json:void 0,proto:{}}:{json:{},proto:void 0}}function IbM(e){return e!=null&&e.type==="proto"?{json:void 0,proto:{}}:{json:{},proto:void 0}}function zbM(e){if(typeof e!="string"&&"inline"in e)return e.inline}function kJ_(e,t){let r=t[e];if(r==null)throw new Cgi(`Illegal Error: Failed to load type declaration for type ${e}`);return r}function eK_(e){e.types=Object.fromEntries(Object.entries(e.types).map(([t,r])=>[t,RbM({typeDeclaration:r,ir:e})])),e.services=Object.fromEntries(Object.entries(e.services).map(([t,r])=>[t,{...r,endpoints:r.endpoints.map(i=>xbM({endpoint:i,ir:e}))}]))}function xbM({endpoint:e,ir:t}){return e.requestBody?.type!=="inlinedRequestBody"?e:{...e,requestBody:{...e.requestBody,extendedProperties:e.requestBody.extends.flatMap(r=>tK_(r,t))}}}function RbM({typeDeclaration:e,ir:t}){switch(e.shape.type){case"object":return{...e,shape:{...e.shape,extendedProperties:e.shape.extends.flatMap(r=>tK_(r,t))}}}return e}function tK_(e,t){let r=C7c(e.typeId,t);return rK_({objectTypeDeclaration:r,ir:t})}function C7c(e,t){let r=kJ_(e,t.types);switch(r.shape.type){case"object":return r.shape;case"alias":if(r.shape.resolvedType.type==="named")return C7c(r.shape.resolvedType.name.typeId,t)}throw new Cgi(`Unexpected error: ${e} is extended but has shape ${r.shape.type}`)}function rK_({objectTypeDeclaration:e,ir:t}){let r=e.extends.flatMap(i=>{let n=C7c(i.typeId,t);return rK_({objectTypeDeclaration:n,ir:t})});return[...e.properties,...r]}var Whu=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:fP.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:Dd(this.subpackages,(i,n)=>({...i,hasEndpointsInTree:r.has(n)})),rootPackage:{...this.rootPackage,hasEndpointsInTree:r.size>0||this.rootPackage.service!=null}}}sortRootPackage(t){if(!iK_(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(!iK_(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 o=this.subpackages[s];if(o==null)throw new Error("Subpackage ID is invalid: "+s);return o}),u=r+1,c={allParts:t.allParts.slice(0,u),packagePath:t.packagePath.slice(0,u),file:u===t.allParts.length?t.file:void 0},d=a.find(s=>s.name.originalName===n.originalName);if(d==null){let s=fP.generateSubpackageId(c),o={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]=o,i.subpackages.push(s),d=o}return this.getPackageForFernFilepath(t,u,d)}};function iK_(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 nK_({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:v7i({referencedIn:t,importPath:c})}}var Jon=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 KF(this.workspace,(n,a,u)=>{let c=fg({relativeFilepath:n,definitionFile:a,casingsGenerator:g7i,rootApiFile:this.workspace.definition.rootApiFile.contents,defaultUrl:u.defaultUrl});for(let[d,s]of Object.entries(a.service?.endpoints??{}))s.method===t&&s.path===r&&(i={endpointId:d,endpoint:s,file:c})}),man(this.workspace,(n,a)=>{let u=fg({relativeFilepath:n,definitionFile:a,casingsGenerator:g7i,rootApiFile:this.workspace.definition.rootApiFile.contents});for(let[c,d]of Object.entries(a.service?.endpoints??{}))d.method===t&&d.path===r&&(i={endpointId:c,endpoint:d,file:u})}),i}resolveEndpoint({endpoint:t,file:r}){let n=new jen().tryParse(t);if(n!=null)return this.resolveEndpointByMethodAndPath(n);let a=this.getDeclarationOfEndpoint({referenceToEndpoint:t,file:r});if(a==null)return;let u=a.file.definitionFile.service?.endpoints?.[a.endpointName];if(u!=null)return{endpointId:a.endpointName,endpoint:u,file:a.file}}getDeclarationOfEndpoint({referenceToEndpoint:t,file:r}){let i=nK_({reference:t,referencedIn:r.relativeFilepath,imports:r.imports});if(i==null)return;let n=Que(this.workspace,i.relativeFilepath);if(!(n==null||n.service?.endpoints?.[i.endpointName]==null))return{endpointName:i.endpointName,file:fg({relativeFilepath:i.relativeFilepath,definitionFile:n,casingsGenerator:r.casingsGenerator,rootApiFile:this.workspace.definition.rootApiFile.contents})}}};var Kon=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=Jqe({reference:t,referencedIn:r.relativeFilepath,imports:r.imports});if(i==null)return;let n=Que(this.workspace,i.relativeFilepath);if(n==null)return;let a=n.errors?.[i.typeName];if(a!=null)return{declaration:a,file:fg({definitionFile:n,relativeFilepath:i.relativeFilepath,casingsGenerator:r.casingsGenerator,rootApiFile:this.workspace.definition.rootApiFile.contents})}}};var Xqe=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||typeof i.resolvedExample=="string"?i:this.resolveAllReferencesInExample({example:i.resolvedExample,file:i.file})}else if(Rw(t)){let i={};for(let[n,a]of Object.entries(t)){let u=this.resolveAllReferencesInExample({example:a,file:r});if(u==null)return;i[n]=u.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}){if(typeof t!="string")return{resolvedExample:t,file:r};if(t.startsWith(`\\${sir}`))return{resolvedExample:t.slice(1),file:r};if(!t.startsWith(sir))return{resolvedExample:t,file: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(u=>u.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(sir.length),exampleName:i}:{rawTypeReference:`${r}.${i}`.slice(sir.length),exampleName:n}}};var Hhu=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.resolveObjectProperty({file:n.file,typeName:n.endpoint.request,propertyComponents:i});if(a!=null)return{propertyPath:this.propertyPathFromPropertyComponents({propertyComponents:i,file:t}),property:Roe.body(a)}}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.resolveObjectProperty({file:n.file,typeName:(typeof n.endpoint.response!="string"?n.endpoint.response?.type:n.endpoint.response)??"",propertyComponents:i});if(a!=null)return{propertyPath:this.propertyPathFromPropertyComponents({propertyComponents:i,file:t}),property:a}}resolveRequestPropertyFromInlinedRequest({typeResolver:t,file:r,requestType:i,propertyComponents:n}){if(n.length===1){let a=n[0]??"",u=i["query-parameters"]?.[a]??void 0;if(u!=null)return{property:Roe.query(xhu({file:r,queryParameterKey:a,queryParameter:u})),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 u=this.resolveObjectProperty({file:r,typeName:i.body,propertyComponents:n});return u==null?void 0:{propertyPath:this.propertyPathFromPropertyComponents({propertyComponents:n,file:r}),property:Roe.body(u)}}if(oI(i.body)){let u=j7c({typeResolver:t,file:r,objectSchema:i.body,propertyComponents:n});return u==null?void 0:{propertyPath:this.propertyPathFromPropertyComponents({propertyComponents:n,file:r}),property:Roe.body(u)}}let a=this.resolveObjectProperty({file:r,typeName:i.body.type,propertyComponents:n});if(a!=null)return{propertyPath:this.propertyPathFromPropertyComponents({propertyComponents:n,file:r}),property:Roe.body(a)}}resolveObjectProperty({file:t,typeName:r,propertyComponents:i}){let n=this.typeResolver.resolveTypeOrThrow({type:r,file:t});return P7c({typeResolver:this.typeResolver,file:AVa(n)??t,resolvedType:n,propertyComponents:i})}propertyPathFromPropertyComponents({propertyComponents:t,file:r}){return t.length<=1?[]:t.slice(0,-1).map(i=>r.casingsGenerator.generateName(i))}};var LS=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=Jqe({reference:t,referencedIn:r.relativeFilepath,imports:r.imports});if(i==null)return;let n=Que(this.workspace,i.relativeFilepath);if(n==null)return;let a=n.types?.[i.typeName];if(a==null){let u=vN(i.typeName);if(u!=null){for(let c of Object.keys(n.types??{})??[])if(u.name&&c.startsWith(u.name)&&c.endsWith(">")){let d=n.types?.[c];return d!=null?{typeName:c,declaration:d,file:fg({relativeFilepath:i.relativeFilepath,definitionFile:n,casingsGenerator:r.casingsGenerator,rootApiFile:this.workspace.definition.rootApiFile.contents})}:void 0}}return}return{typeName:i.typeName,declaration:a,file:fg({relativeFilepath:i.relativeFilepath,definitionFile:n,casingsGenerator:r.casingsGenerator,rootApiFile:this.workspace.definition.rootApiFile.contents})}}resolveType({type:t,file:r,objectPath:i=[]}){return SF({type:t,_default:void 0,validation:void 0,visitor:{primitive:n=>({_type:"primitive",primitive:n,originalTypeReference:ol.primitive(n)}),unknown:()=>({_type:"unknown",originalTypeReference:ol.unknown()}),map:({keyType:n,valueType:a})=>n!=null&&a!=null?{_type:"container",container:{_type:"map",keyType:n,valueType:a},originalTypeReference:ol.container(Zy.map({keyType:n.originalTypeReference,valueType:a.originalTypeReference}))}:void 0,list:n=>n!=null?{_type:"container",container:{_type:"list",itemType:n},originalTypeReference:ol.container(Zy.list(n.originalTypeReference))}:void 0,optional:n=>n!=null?{_type:"container",container:{_type:"optional",itemType:n},originalTypeReference:ol.container(Zy.optional(n.originalTypeReference))}:void 0,nullable:n=>n!=null?{_type:"container",container:{_type:"nullable",itemType:n},originalTypeReference:ol.container(Zy.nullable(n.originalTypeReference))}:void 0,set:n=>n!=null?{_type:"container",container:{_type:"set",itemType:n},originalTypeReference:ol.container(Zy.set(n.originalTypeReference))}:void 0,literal:n=>({_type:"container",container:{_type:"literal",literal:n},originalTypeReference:ol.container(Zy.literal(n))}),named:n=>{let a=this.getDeclarationOfNamedType({referenceToNamedType:n,file:r});if(a==null)return;let u={typeName:a.typeName,file:a.file.relativeFilepath,reference:n};if(!i.some(c=>c.file===u.file&&c.typeName===u.typeName))return this.resolveNamedTypeFromDeclaration({referenceToNamedType:n,referencedIn:r,rawDeclaration:a,objectPath:[...i,u]})}}})}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:u}=i;if(hzi(a))return this.resolveType({type:typeof a=="string"?a:a.type,file:u,objectPath:n});let c=TVa({type:t,_default:void 0,validation:void 0,file:r});if(!(c.type!=="named"||Que(this.workspace,u.relativeFilepath)==null))return{_type:"named",rawName:i.typeName,name:c,declaration:a,filepath:u.relativeFilepath,objectPath:n,originalTypeReference:c,file:u}}};var vJt=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:tji({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 $hu(e,t){if(t){for(let[r,i]of Object.entries(t))if(typeof i!="string"&&r===e)return i.audiences}}function Dx({workspace:e,generationLanguage:t,keywords:r,smartCasing:i,exampleGeneration:n,audiences:a,readme:u,packageName:c,version:d,fdrApiDefinitionId:s,sourceResolver:o,disableDynamicExamples:l,dynamicGeneratorConfig:b}){let g=Iee({generationLanguage:t,keywords:r,smartCasing:i}),O=new kin(a),m=tji({casingsGenerator:g,rootApiFile:e.definition.rootApiFile.contents}),P=(e.definition.rootApiFile.contents.errors??[]).map(at=>({error:b7i({errorName:at,file:m}),docs:void 0})),D=new LS(e),A=new Jon(e),M=new Hhu(D,A),E=new Kon(e),T=new Xqe(D),z=new vJt,I=N8a({casingsGenerator:g,rawApiFileSchema:e.definition.rootApiFile.contents})?.environmentsConfig,N={selfHosted:!1,fdrApiDefinitionId:s,apiVersion:FJ_({file:m,rawApiFileSchema:e.definition.rootApiFile.contents}),apiName:g.generateName(e.definition.rootApiFile.contents.name),apiDisplayName:e.definition.rootApiFile.contents["display-name"],apiDocs:DVa(e.definition.rootApiFile.contents.docs),auth:NJ_({rawApiFileSchema:e.definition.rootApiFile.contents,file:m,propertyResolver:M,endpointResolver:A}),headers:e.definition.rootApiFile.contents.headers!=null?Object.entries(e.definition.rootApiFile.contents.headers).map(([at,Oe])=>e6e({headerKey:at,header:Oe,file:m})):[],idempotencyHeaders:e.definition.rootApiFile.contents["idempotency-headers"]!=null?Object.entries(e.definition.rootApiFile.contents["idempotency-headers"]).map(([at,Oe])=>e6e({headerKey:at,header:Oe,file:m})):[],types:{},errors:{},services:{},constants:EJ_(g),environments:I,errorDiscriminationStrategy:WJ_(e.definition.rootApiFile.contents["error-discrimination"],m),basePath:e.definition.rootApiFile.contents["base-path"]!=null?b7(e.definition.rootApiFile.contents["base-path"]):void 0,pathParameters:pZn({pathParameters:e.definition.rootApiFile.contents["path-parameters"],file:m,location:D3e.Root,variableResolver:z}),variables:e.definition.rootApiFile.contents.variables!=null?Object.entries(e.definition.rootApiFile.contents.variables).map(([at,Oe])=>({docs:typeof Oe!="string"?Oe.docs:void 0,id:at,name:m.casingsGenerator.generateName(at),type:m.parseTypeReference(Oe)})):[],serviceTypeReferenceInfo:{typesReferencedOnlyByService:{},sharedTypes:[]},webhookGroups:{},websocketChannels:{},readmeConfig:void 0,sourceConfig:void 0,publishConfig:void 0,dynamic:void 0,audiences:e.definition.rootApiFile.contents.audiences},U=new Whu,Y=at=>{U.addSubpackage(at.fernFilepath),S1(at.definitionFile,{imports:Ko,docs:Oe=>{Oe!=null&&U.addDocs(at.fernFilepath,Oe)},types:Oe=>{if(Oe!=null)for(let[je,bt]of Object.entries(Oe)){if(j3e(je))continue;let Dt=ZJ_({typeName:je,typeDeclaration:bt,file:at,typeResolver:D,exampleResolver:T,sourceResolver:o,workspace:e}),mr=Dt.typeDeclaration;n.disabled&&(mr.userProvidedExamples=[],mr.autogeneratedExamples=[]);let lr=Dt.descendantFilepaths,si=fP.generateTypeId(mr.name);N.types[si]=mr,U.addType(si,mr),O.addType({declaredTypeName:mr.name,descendantTypeIds:mr.referencedTypes,descendantTypeIdsByAudience:{},propertiesByAudience:Dt.propertiesByAudience,descendantFilepaths:lr}),O.markTypeForAudiences(mr.name,IQ_(bt))}},errors:Oe=>{if(Oe==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[bt,Dt]of Object.entries(Oe)){let mr=UJ_({errorName:bt,errorDeclaration:Dt,file:at,typeResolver:D,exampleResolver:T,workspace:e}),lr=fP.generateErrorId(mr.name);N.errors[lr]=mr,U.addError(lr,mr),O.addError(mr)}},service:Oe=>{if(Oe==null)return;let je=SJ_({rootDefaultUrl:at.defaultUrl??e.definition.rootApiFile.contents["default-url"],rootPathParameters:N.pathParameters,serviceDefinition:Oe,file:at,errorResolver:E,typeResolver:D,propertyResolver:M,exampleResolver:T,sourceResolver:o,globalErrors:P,variableResolver:z,workspace:e}),bt=fP.generateServiceId(je.name);N.services[bt]=je,U.addService(bt,je);let Dt={};je.endpoints.forEach(mr=>{n.disabled&&(mr.autogeneratedExamples=[],mr.userSpecifiedExamples=[]);let lr=Oe.endpoints[mr.name.originalName];O.addEndpoint(je,mr,lr),Dt[mr.name.originalName]=mr}),Oe.audiences!=null&&O.markEndpointForAudience(je.name,je.endpoints,Oe.audiences),Object.entries(Oe.endpoints).map(([mr,lr])=>{let si=Dt[mr];si!=null&&lr.audiences!=null&&O.markEndpointForAudience(je.name,[si],lr.audiences)})},webhooks:Oe=>{if(Oe==null)return;let je=fP.generateWebhookGroupId(at.fernFilepath),bt=$J_({webhooks:Oe,file:at,typeResolver:D,exampleResolver:T,workspace:e}),Dt={};for(let mr of bt)Dt[mr.name.originalName]=mr;Object.entries(Oe).forEach(([mr,lr])=>{let si=Dt[mr];si!=null&&(O.addWebhook(at.fernFilepath,si,lr),lr.audiences!=null&&O.markWebhookForAudiences(at.fernFilepath,si,lr.audiences))}),N.webhookGroups[je]=bt,U.addWebhookGroup(je,at.fernFilepath)},channel:Oe=>{if(Oe==null)return;let je=fP.generateWebSocketChannelId(at.fernFilepath),bt=LJ_({channel:Oe,file:at,variableResolver:z,typeResolver:D,exampleResolver:T,workspace:e});O.addChannel(at.fernFilepath,je,bt,Oe),Oe.audiences!=null&&O.markChannelForAudiences(at.fernFilepath,je,Oe.audiences),N.websocketChannels!=null&&(N.websocketChannels[je]=bt,U.addWebSocketChannel(je,at.fernFilepath))}})};KF(e,(at,Oe,je)=>{Y(fg({relativeFilepath:at,definitionFile:Oe,casingsGenerator:g,rootApiFile:e.definition.rootApiFile.contents,defaultUrl:je.defaultUrl}))}),man(e,(at,Oe)=>{if(Oe.navigation!=null)if(typeof Oe.navigation=="string")U.addPackageRedirection({from:nse({relativeFilepath:at,casingsGenerator:g}),to:nse({relativeFilepath:X3(UNe(at),Ey.of(Oe.navigation)),casingsGenerator:g})});else{let je=Oe.navigation.map(bt=>fP.generateSubpackageId(nse({relativeFilepath:X3(UNe(at),Ey.of(bt)),casingsGenerator:g})));at===CS?U.sortRootPackage(je):U.sortSubpackage(fP.generateSubpackageId(nse({relativeFilepath:at,casingsGenerator:g})),je)}}),N.serviceTypeReferenceInfo=FbM(O),eK_(N);let J=n.disabled?N:V8a({ir:N,exampleGeneration:n}),X=e.definition.rootApiFile.contents,oe=I?.environments._visit({singleBaseUrl:at=>at.environments.filter(Oe=>$hu(Oe.id,X.environments)!=null).length===0,multipleBaseUrls:at=>at.environments.filter(Oe=>$hu(Oe.id,X.environments)!=null).length===0,_other:()=>!1});I?.environments.environments.forEach(at=>{O.markEnvironmentForAudiences(at,$hu(at.id,X.environments)??[],oe)});let pe=O.hasNoAudiences()?void 0:O.build(),de=Ujc(J,pe),me=e.definition.rootApiFile.contents.auth!=null&&Object.values(de.services).every(at=>at.endpoints.every(Oe=>Oe.auth)),Le=Object.values(de.services).some(at=>at.endpoints.some(Oe=>Oe.response?.body?.type==="streaming")),vt=Object.values(de.services).some(at=>at.endpoints.some(Oe=>Oe.pagination!=null)),De=Object.values(de.services).some(at=>at.endpoints.some(Oe=>Oe.response?.body?.type==="fileDownload")),Ae={isAuthMandatory:me,hasStreamingEndpoints:Le,hasPaginatedEndpoints:vt,hasFileDownloadEndpoints:De,platformHeaders:{language:"X-Fern-Language",sdkName:"X-Fern-SDK-Name",sdkVersion:"X-Fern-SDK-Version",userAgent:d!=null&&c!=null?{header:"User-Agent",value:`${c}/${d}`}:void 0}},Ct=u??e.generatorsConfiguration?.rawConfiguration.readme,Pe=Ct!=null?HJ_({readme:Ct,services:N.services}):void 0,St=NbM({...de,...U.build(pe),sdkConfig:Ae,readmeConfig:Pe});return{...St,dynamic:IVa({ir:St,generatorConfig:b,disableExamples:l,generationLanguage:t,smartCasing:i})}}function NbM(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]=DVa(n):n&&typeof n=="object"&&t(n)}return r};return t(e)}function FbM(e){let t={},r=[],i=e.getTypesReferencedByService();for(let[n,a]of Object.entries(i)){if(a.size===1){let u=a.values().next().value;if(u==null)break;t[u]===void 0&&(t[u]=[]),t[u]?.push(n);continue}r.push(n)}return{typesReferencedOnlyByService:t,sharedTypes:r}}var nZ_=ci(lhu(),1),aZ_=ci(fhu(),1),Zyu=require("fs/promises"),AFc=ci(tQt(),1);function aK_(e){throw new Error("Unexpected value: "+JSON.stringify(e))}var uK_=ci(M8n(),1);var oK_=["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 bJt(e){return e=e.replace(/([a-z])([A-Z])/g,"$1 $2"),e=e.replace(/_/g," "),e=e.replace(/-/g," "),(0,uK_.default)(e,{special:oK_}).replace(/V\s(\d)/g,"V$1")}function xVa(e,t="type"){return{_visit:r=>{let i=r[e[t]];return i!=null?i(e):(r._other==null&&aK_(e),r._other(e))}}}function lur(e){return typeof e.subpackageId=="string"}function Yon(e,t){return`${e} ${AB(t)}`}function AB(e){return e.map(t=>t.type==="literal"?t.value:`{${t.value}}`).join("")}function t6e(e){return e.map(t=>t.type==="literal"?t.value:`:${t.value}`).join("")}var B7c="__package__",m7i=class e{api;context;static create(t,r){return new e(t,r)}#e=new Map;#t=new Map;#r=new Map;#n=new Map;#i=new Map;#a=new Map;#o=new Map;#s=new Map;#f=new Map;#u=new Map;#c=new Map;#l=new Map;#p=new Map;#_=new Map;static getSubpackageId(t){return lur(t)?t.subpackageId:B7c}getSubpackageByIdOrLocator(t){if(t==null)return;let r=j2.SubpackageId(t),i=j2.SubpackageId(`subpackage_${F_(t)}`);return r===B7c?this.api.rootPackage:this.api.subpackages[r]??this.#_.get(r)??this.api.subpackages[i]??this.#_.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=j2.SubpackageId(e.getSubpackageId(i)),a={endpoints:new Map,webSockets:new Map,webhooks:new Map,grpcs:new Map};this.#f.set(n,a),i.endpoints.forEach(u=>{if(u.protocol?.type==="grpc"){a.grpcs.set(u.id,u);let c=e.createGrpcId(u,n);this.#n.set(c,u)}else{a.endpoints.set(u.id,u);let c=e.createEndpointId(u,n);this.#e.set(c,u);let d=[],s=[u.method];u.response?.type.type==="stream"&&s.push("STREAM"),s.forEach(o=>{d.push(`${o} ${AB(u.path.parts)}`),d.push(`${o} ${t6e(u.path.parts)}`),u.environments.forEach(l=>{d.push(`${o} ${Wb(l.baseUrl,AB(u.path.parts))}`),d.push(`${o} ${Wb(l.baseUrl,t6e(u.path.parts))}`);let b=Ghu(l);b!=null&&(d.push(`${o} ${Wb(b,AB(u.path.parts))}`),d.push(`${o} ${Wb(b,t6e(u.path.parts))}`))})}),d.forEach(o=>{this.context?.logger.trace(`Registering endpoint locator: ${o}`),this.#u.set(o,u)})}}),i.websockets.forEach(u=>{a.webSockets.set(u.id,u);let c=e.createWebSocketId(u,n);this.#t.set(c,u);let d=[];["GET","WSS"].forEach(o=>{d.push(`${o} ${AB(u.path.parts)}`),d.push(`${o} ${t6e(u.path.parts)}`),u.environments.forEach(l=>{d.push(`${o} ${Wb(l.baseUrl,AB(u.path.parts))}`),d.push(`${o} ${Wb(l.baseUrl,t6e(u.path.parts))}`);let b=Ghu(l);b!=null&&(d.push(`${o} ${Wb(b,AB(u.path.parts))}`),d.push(`${o} ${Wb(b,t6e(u.path.parts))}`))})}),d.forEach(o=>{this.context?.logger.trace(`Registering websocket locator: ${o}`),this.#c.set(o,u)})}),i.webhooks.forEach(u=>{a.webhooks.set(u.id,u),this.#r.set(e.createWebhookId(u,n),u)})}),this.#e.forEach((i,n)=>{this.#i.set(i,n)}),this.#t.forEach((i,n)=>{this.#a.set(i,n)}),this.#r.forEach((i,n)=>{this.#o.set(i,n)}),this.#n.forEach((i,n)=>{this.#s.set(i,n)}),this.#h(t.rootPackage,[])}#h(t,r){if(t==null)return;let i=lur(t)?[...r,t.name]:r,n=i.length===0?[B7c]:i;if([n.join("."),n.join("/"),`${n.join(".")}.yml`].forEach(u=>{this.context?.logger.trace(`Registering subpackage locator: ${u}`),this.#_.set(u,t)}),t.pointsTo!=null)return this.#h(this.api.subpackages[t.pointsTo],i);t.endpoints.forEach(u=>{if(u.protocol?.type==="grpc")return;let c=[...i,u.id];[c.join("."),c.join("/")].forEach(s=>{this.context?.logger.trace(`Registering endpoint locator: ${s}`),this.#u.set(s,u)})}),t.websockets.forEach(u=>{let c=[...i,u.id];[c.join("."),c.join("/")].forEach(s=>{this.context?.logger.trace(`Registering websocket locator: ${s}`),this.#c.set(s,u)})}),t.webhooks.forEach(u=>{let c=[...i,u.id];[c.join("."),c.join("/")].forEach(s=>{this.context?.logger.trace(`Registering webhook locator: ${s}`),this.#l.set(s,u)})}),t.subpackages.forEach(u=>{this.#h(this.api.subpackages[u],i)})}get endpoints(){return this.#e}get webSockets(){return this.#t}get webhooks(){return this.#r}get grpcs(){return this.#n}get endpointsByLocator(){return this.#u}get webSocketsByLocator(){return this.#c}get webhooksByLocator(){return this.#l}get grpcsByLocator(){return this.#p}get subpackages(){return this.#f}get subpackagesByLocator(){return this.#_}get subpackageLocators(){return new Set(this.#_.keys())}getEndpointId(t){return this.#i.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 Do.EndpointId(t.originalEndpointId??`${r}.${t.id}`)}static createWebSocketId(t,r){return Do.WebSocketId(`${r}.${t.id}`)}static createWebhookId(t,r){return Do.WebhookId(`${r}.${t.id}`)}static createGrpcId(t,r){return Do.GrpcId(`${r}.${t.id}`)}};function Ghu(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 _Zn=ci(lhu(),1),cK_=ci(fhu(),1);function sK_(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{}}_Zn.default.extend(cK_.default);var LbM="Changelog",UbM=["summary","index","overview"],iji=class{markdownToFullSlug;markdownToNoIndex;changelogFiles;docsWorkspace;idgen;constructor(t,r,i,n,a){this.markdownToFullSlug=t,this.markdownToNoIndex=r,this.changelogFiles=i,this.docsWorkspace=n,this.idgen=a}toChangelogNode(t){let r=t.title??LbM,i=[],n;for(let b of this.changelogFiles??[]){let g=mHs(b.split("/"));if(g==null)continue;let O=sK_(g);if(O==null){let P=g.split(".")[0]?.toLowerCase();P!=null&&UbM.includes(P)&&(n=b);continue}let m=this.toRelativeFilepath(b);i.push({date:O,pageId:Do.PageId(m),absoluteFilepath:b})}let a=t.parentSlug.apply({fullSlug:n!=null?this.markdownToFullSlug.get(n)?.split("/"):void 0,skipUrlSlug:!1,urlSlug:t.slug??FT(r)}),u=n!=null?this.markdownToNoIndex.get(n):void 0,c=i.map(b=>{let g=_Zn.default.utc(b.date);return{id:this.idgen.get(b.pageId),type:"changelogEntry",title:g.format("MMMM D, YYYY"),slug:a.apply({fullSlug:this.markdownToFullSlug.get(b.absoluteFilepath)?.split("/"),urlSlug:g.format("YYYY/M/D")}).get(),icon:void 0,hidden:void 0,date:b.date.toISOString(),pageId:b.pageId,noindex:this.markdownToNoIndex.get(b.absoluteFilepath),authed:void 0,viewers:void 0,orphaned:void 0,featureFlags:void 0}}),d=I7c(c,b=>b.date,"desc"),s=n!=null?Do.PageId(this.toRelativeFilepath(n)):void 0,o=this.idgen.get(s??"changelog"),l=this.groupByYear(o,d,a);return{id:o,type:"changelog",title:r,slug:a.get(),icon:t.icon,hidden:t.hidden,children:l,overviewPageId:s,noindex:u,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 u=_Zn.default.utc(a.date).year(),c=n.get(u)??[];c.push(a),n.set(u,c)}return I7c(Array.from(n.entries()).map(([a,u])=>{let c=i.append(a.toString()).get(),d=this.idgen.get(`${t}/year/${a}`);return{id:d,type:"changelogYear",title:a.toString(),year:a,slug:c,icon:void 0,hidden:void 0,children:this.groupByMonth(d,u,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 u=_Zn.default.utc(a.date).month()+1,c=n.get(u)??[];c.push(a),n.set(u,c)}return I7c(Array.from(n.entries()).map(([a,u])=>{let c=(0,_Zn.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:u,authed:void 0,viewers:void 0,orphaned:void 0,featureFlags:void 0}}),"month","desc")}toRelativeFilepath(t){if(t!=null)return UT(this.docsWorkspace.absoluteFilePath,t)}};function I7c(e,t,r="asc"){return e.concat().sort((i,n)=>{let a=typeof t=="function"?t(i):i[t],u=typeof t=="function"?t(n):n[t];return a<u?r==="asc"?-1:1:a>u?r==="asc"?1:-1:0})}function Qhu(e){if(e)return{environments:e.environments!=null&&e.environments.length>0?e.environments.map(t=>Do.V1.EnvironmentId(t)):void 0,button:e.button!=null&&e.button.href?{href:Do.V1.Url(e.button.href)}:void 0,"limit-websocket-messages-per-connection":e.limitWebsocketMessagesPerConnection!=null?e.limitWebsocketMessagesPerConnection:void 0}}function RVa({child:e,nodeIdToSubpackageId:t,convertApiDefinitionPackageId:r,mergeAndFilterChildren:i}){if(e.type==="apiPackage"){let n=Do.V1.SlugGenerator.init(e.slug),u=(t.get(e.id)??[]).flatMap(s=>r(s,n)),c=e.children.map(s=>RVa({child:s,nodeIdToSubpackageId:t,convertApiDefinitionPackageId:r,mergeAndFilterChildren:i})),d=i(c,u);return{...e,children:d,pointsTo:void 0}}return e}var yK_=ci(pK_(),1);var YC=function(e,t,r,i){function n(a){return a instanceof r?a:new r(function(u){u(a)})}return new(r||(r=Promise))(function(a,u){function c(o){try{s(i.next(o))}catch(l){u(l)}}function d(o){try{s(i.throw(o))}catch(l){u(l)}}function s(o){o.done?a(o.value):n(o.value).then(c,d)}s((i=i.apply(e,t||[])).next())})},XT=function(e,t){var r={label:0,sent:function(){if(a[0]&1)throw a[1];return a[1]},trys:[],ops:[]},i,n,a,u=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return u.next=c(0),u.throw=c(1),u.return=c(2),typeof Symbol=="function"&&(u[Symbol.iterator]=function(){return this}),u;function c(s){return function(o){return d([s,o])}}function d(s){if(i)throw new TypeError("Generator is already executing.");for(;u&&(u=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(o){s=[6,o],n=0}finally{i=a=0}if(s[0]&5)throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}},ose=function(e,t){var r=typeof Symbol=="function"&&e[Symbol.iterator];if(!r)return e;var i=r.call(e),n,a=[],u;try{for(;(t===void 0||t-- >0)&&!(n=i.next()).done;)a.push(n.value)}catch(c){u={error:c}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(u)throw u.error}}return a},r6e=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))},_K_=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.")},gsL=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 YC(this,void 0,void 0,function(){return XT(this,function(i){return t>r?[2,1]:t<r?[2,-1]:[2,0]})})},e.maxComparator=function(t,r){return YC(this,void 0,void 0,function(){return XT(this,function(i){return r>t?[2,1]:r<t?[2,-1]:[2,0]})})},e.minComparatorNumber=function(t,r){return YC(this,void 0,void 0,function(){return XT(this,function(i){return[2,t-r]})})},e.maxComparatorNumber=function(t,r){return YC(this,void 0,void 0,function(){return XT(this,function(i){return[2,r-t]})})},e.defaultIsEqual=function(t,r){return YC(this,void 0,void 0,function(){return XT(this,function(i){return[2,t===r]})})},e.print=function(t){function r(o){var l=e.getParentIndexOf(o);return Math.floor(Math.log2(l+1))}function i(o,l){for(var b="";l>0;--l)b+=o;return b}for(var n=0,a=[],u=r(t.length-1)+2,c=0;n<t.length;){var d=r(n)+1;n===0&&(d=0);var s=String(t.get(n));s.length>c&&(c=s.length),a[d]=a[d]||[],a[d].push(s),n+=1}return a.map(function(o,l){var b=Math.pow(2,u-l)-1;return i(" ",Math.floor(b/2)*c)+o.map(function(g){var O=(c-g.length)/2;return i(" ",Math.ceil(O))+g+i(" ",Math.floor(O))}).join(i(" ",b*c))}).join(`
|
|
2313
|
+
${JSON.stringify(r)}"`)}}function wJ_(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=mJ_({source:n,serviceNameOverride:i});if(a==null)throw new Error(`Failed to resolve service name from ${n.relativeFilePath}.`);return S3e.grpc({service:a})}function SJ_({rootDefaultUrl:e,rootPathParameters:t,serviceDefinition:r,file:i,errorResolver:n,typeResolver:a,propertyResolver:u,exampleResolver:c,variableResolver:d,sourceResolver:s,globalErrors:o,workspace:l}){let b=pZn({pathParameters:r["path-parameters"],location:D3e.Service,file:i,variableResolver:d}),g=PJ_({file:i,serviceDeclaration:r,sourceResolver:s}),O={fernFilepath:i.fernFilepath};return{availability:ase(r.availability),name:O,displayName:r["display-name"]??void 0,basePath:b7(r["base-path"]),headers:r.headers!=null?Object.entries(r.headers).map(([P,D])=>e6e({headerKey:P,header:D,file:i})):[],pathParameters:b,encoding:ebM(g,r),transport:g,endpoints:Object.entries(r.endpoints).map(([P,D])=>{let A=pZn({pathParameters:hJt(D),location:D3e.Endpoint,file:i,variableResolver:d}),M={...nY(D),id:"",name:i.casingsGenerator.generateName(P),displayName:D["display-name"],auth:D.auth??r.auth,idempotent:D.idempotent??r.idempotent??!1,baseUrl:D.url??r.url??e,v2BaseUrls:void 0,method:D.method!=null?kvM(D.method):uI.Post,basePath:D["base-path"]!=null?b7(D["base-path"]):void 0,path:b7(D.path),fullPath:b7(D["base-path"]!=null?Wb(D["base-path"],D.path):i.rootApiFile["base-path"]!=null?Wb(i.rootApiFile["base-path"],r["base-path"],D.path):Wb(r["base-path"],D.path)),pathParameters:A,allPathParameters:D["base-path"]!=null?A:[...t,...b,...A],queryParameters:typeof D.request!="string"&&D.request?.["query-parameters"]!=null?Object.entries(D.request["query-parameters"]).map(([E,T])=>xhu({file:i,queryParameterKey:E,queryParameter:T})):[],headers:typeof D.request!="string"&&D.request?.headers!=null?Object.entries(D.request.headers).map(([E,T])=>e6e({headerKey:E,header:T,file:i})):[],requestBody:RQ_({request:D.request,file:i}),v2RequestBodies:void 0,sdkRequest:VQ_({service:r,request:D.request,endpoint:D,endpointKey:P,file:i,typeResolver:a,propertyResolver:u}),response:_J_({endpoint:D,file:i,typeResolver:a}),v2Responses:void 0,errors:[...OJ_({errors:D.errors,file:i}),...o],userSpecifiedExamples:D.examples!=null?D.examples.map(E=>{try{let T=pJ_({service:r,endpoint:D,example:E,typeResolver:a,errorResolver:n,exampleResolver:c,variableResolver:d,file:i,workspace:l});return T===void 0?void 0:{example:T,codeSamples:E["code-samples"]?.map(z=>WQ_({codeSample:z,file:i}))}}catch{return}}).filter(E=>E!==void 0):[],autogeneratedExamples:[],pagination:gJ_({propertyResolver:u,file:i,endpointName:P,endpointSchema:D}),transport:jJ_({file:i,serviceTransport:g,endpointDeclaration:D,sourceResolver:s}),v2Examples:void 0,source:void 0,audiences:D.audiences};return M.id=fP.generateEndpointId(O,M),M}),audiences:r.audiences}}function pZn({pathParameters:e,location:t,file:r,variableResolver:i}){return e==null?[]:Object.entries(e).map(([n,a])=>XvM({parameterName:n,parameter:a,location:t,file:r,variableResolver:i}))}function XvM({parameterName:e,parameter:t,location:r,file:i,variableResolver:n}){return{...nY(t),name:i.casingsGenerator.generateName(e),valueType:ZvM({parameter:t,variableResolver:n,file:i}),location:r,variable:pUn(t)?n.getVariableIdOrThrow(typeof t=="string"?t:t.variable):void 0,v2Examples:{userSpecifiedExamples:{},autogeneratedExamples:{}}}}function ZvM({parameter:e,variableResolver:t,file:r}){let i=BVa({parameter:e,variableResolver:t,file:r});return i.file.parseTypeReference(i.rawType)}function BVa({parameter:e,variableResolver:t,file:r}){let i=Nhu({parameter:e,variableResolver:t,file:r});if(i==null)throw new Error("Cannot resolve path parameter");return i}function Nhu({parameter:e,variableResolver:t,file:r}){if(pUn(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 kvM(e){switch(e){case"GET":return uI.Get;case"POST":return uI.Post;case"PUT":return uI.Put;case"PATCH":return uI.Patch;case"DELETE":return uI.Delete;case"HEAD":return uI.Head;default:Ao(e)}}function e6e({headerKey:e,header:t,file:r}){let{name:i}=cur({headerKey:e,header:t});return{...nY(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 cur({headerKey:e,header:t}){return typeof t!="string"&&t.name!=null?{name:t.name,wasExplicitlySet:!0}:{name:e,wasExplicitlySet:!1}}function ebM(e,t){switch(e.type){case"http":return{json:{},proto:void 0};case"grpc":return{json:void 0,proto:{}};default:Ao(e)}}var DJ_="1.0.0";var Fhu=class{ir;casingsGenerator;auth;authValues;generatorConfig;constructor(t){this.ir=t.ir,this.generatorConfig=t.generatorConfig,this.casingsGenerator=Iee({generationLanguage:t.generationLanguage,smartCasing:t.smartCasing??!1,keywords:void 0}),this.auth=this.convertAuth(this.ir.auth),this.authValues=this.getAuthValues(this.ir.auth)}convert({disableExamples:t}){return{version:DJ_,types:this.convertNamedTypes(),headers:this.convertHeaders(),endpoints:this.convertEndpoints({disableExamples:t}),pathParameters:this.convertPathParameters({pathParameters:this.ir.pathParameters}),environments:this.ir.environments,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})}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:_s.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 _s.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 _s.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:Ao(t.sdkRequest.shape)}}convertReferencedRequestBodyType({body:t}){switch(t.type){case"bytes":return _s.ReferencedRequestBodyType.bytes();case"typeReference":return _s.ReferencedRequestBodyType.typeReference(this.convertTypeReference(t.requestBodyType));default:Ao(t)}}convertInlinedRequest({fernFilepath:t,wrapper:r,pathParameters:i,queryParameters:n,headers:a,body:u}){return _s.Request.inlined({declaration:this.convertDeclaration({name:r.wrapperName,fernFilepath:t}),pathParameters:i,queryParameters:n,headers:a,body:u!=null?this.convertInlinedRequestBody({wrapper:r,body:u}):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 _s.InlinedRequestBody.properties(this.convertWireValueParameters({wireValueParameters:i}))}case"reference":return _s.InlinedRequestBody.referenced({bodyKey:t.bodyKey,bodyType:_s.ReferencedRequestBodyType.typeReference(this.convertTypeReference(r.requestBodyType))});case"bytes":return _s.InlinedRequestBody.referenced({bodyKey:t.bodyKey,bodyType:_s.ReferencedRequestBodyType.bytes()});case"fileUpload":return this.convertFileUploadRequestBody({properties:r.properties});default:Ao(r)}}convertFileUploadRequestBody({properties:t}){return _s.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 _s.FileUploadRequestBodyProperty.bodyProperty({name:r.name,typeReference:this.convertTypeReference(r.valueType)});default:Ao(r)}})}convertFileUploadRequestBodyFileProperty({fileProperty:t}){switch(t.type){case"file":return _s.FileUploadRequestBodyProperty.file(t.key);case"fileArray":return _s.FileUploadRequestBodyProperty.fileArray(t.key);default:Ao(t)}}convertPathParameters({pathParameters:t}){return t.map(r=>({name:{name:r.name,wireValue:r.name.originalName},typeReference:this.convertTypeReference(r.valueType)}))}convertWireValueParameters({wireValueParameters:t}){return t.map(r=>({name:{name:r.name.name,wireValue:r.name.wireValue},typeReference:this.convertTypeReference(r.valueType)}))}convertQueryParameters({queryParameters:t}){let r=[];for(let i of t){let n=this.convertTypeReference(i.valueType);i.allowMultiple&&(n=_s.TypeReference.list(n)),r.push({name:{name:i.name.name,wireValue:i.name.wireValue},typeReference:n})}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:Ao(t)}}convertContainerType(t){switch(t.type){case"list":return _s.TypeReference.list(this.convertTypeReference(t.list));case"map":return _s.TypeReference.map({key:this.convertTypeReference(t.keyType),value:this.convertTypeReference(t.valueType)});case"optional":return _s.TypeReference.optional(this.convertTypeReference(t.optional));case"nullable":return _s.TypeReference.nullable(this.convertTypeReference(t.nullable));case"set":return _s.TypeReference.set(this.convertTypeReference(t.set));case"literal":return _s.TypeReference.literal(this.convertLiteral(t.literal));default:Ao(t)}}convertNamedType(t){return _s.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});case"union":return this.convertDiscriminatedUnion({declaration:r,union:t.shape});case"undiscriminatedUnion":return this.convertUndiscriminatedUnion({declaration:r,union:t.shape});default:Ao(t.shape)}}convertAlias({declaration:t,alias:r}){return _s.NamedType.alias({declaration:t,typeReference:this.convertTypeReference(r.aliasOf)})}convertEnum({declaration:t,enum_:r}){return _s.NamedType.enum({declaration:t,values:r.values.map(i=>i.name)})}convertObject({declaration:t,object:r}){let i=[...r.extendedProperties??[],...r.properties];return this.convertObjectProperties({declaration:t,properties:i,additionalProperties:r.extraProperties})}convertObjectProperties({declaration:t,properties:r,additionalProperties:i}){return _s.NamedType.object({declaration:t,properties:this.convertWireValueParameters({wireValueParameters:r}),additionalProperties:i})}convertDiscriminatedUnion({declaration:t,union:r}){let i=[...this.resolveProperties(r.extends),...r.baseProperties];return _s.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:Ao(i)}}convertDiscriminatedUnionTypeObject({inheritedProperties:t,discriminantValue:r,declaredTypeName:i}){return _s.SingleDiscriminatedUnionType.samePropertiesAsObject({typeId:i.typeId,discriminantValue:r,properties:this.convertWireValueParameters({wireValueParameters:t})})}convertDiscriminatedUnionTypeSingleProperty({inheritedProperties:t,discriminantValue:r,singleUnionTypeProperty:i}){return _s.SingleDiscriminatedUnionType.singleProperty({typeReference:this.convertTypeReference(i.type),discriminantValue:r,properties:t.length>0?this.convertWireValueParameters({wireValueParameters:t}):void 0})}convertDiscriminatedUnionTypeNoProperties({inheritedProperties:t,discriminantValue:r}){return _s.SingleDiscriminatedUnionType.noProperties({discriminantValue:r,properties:t.length>0?this.convertWireValueParameters({wireValueParameters:t}):void 0})}convertUndiscriminatedUnion({declaration:t,union:r}){return _s.NamedType.undiscriminatedUnion({declaration:t,types:r.members.map(i=>this.convertTypeReference(i.type))})}convertLiteral(t){switch(t.type){case"boolean":return _s.LiteralType.boolean(t.boolean);case"string":return _s.LiteralType.string(t.string);default:Ao(t)}}convertPrimitiveType(t){return _s.TypeReference.primitive(t.v1)}convertUnknownType(){return _s.TypeReference.unknown()}convertAuth(t){if(t.schemes[0]==null)return;let r=t.schemes[0];switch(r.type){case"basic":return _s.Auth.basic(r);case"bearer":return _s.Auth.bearer(r);case"header":return _s.Auth.header({header:{name:r.name,typeReference:this.convertTypeReference(r.valueType)}});case"oauth":return _s.Auth.oauth({clientId:this.casingsGenerator.generateName("clientId"),clientSecret:this.casingsGenerator.generateName("clientSecret")});case"inferred":return _s.Auth.inferred({});default:Ao(r)}}getAuthValues(t){let r=t.schemes[0];if(r!=null)switch(r.type){case"bearer":return _s.AuthValues.bearer({token:"<token>"});case"basic":return _s.AuthValues.basic({username:"<username>",password:"<password>"});case"header":return _s.AuthValues.header({value:"<value>"});case"oauth":return _s.AuthValues.oauth({clientId:"<clientId>",clientSecret:"<clientSecret>"});case"inferred":return _s.AuthValues.inferred({});default:Ao(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=Wb(r,t.fullPath.head));for(let i of t.fullPath.parts)r=Wb(r,"{"+i.pathParameter+"}"),i.tail.length>0&&(r=Wb(r,i.tail));return r.startsWith("/")?r:`/${r}`}getEndpointSnippetRequests({endpoint:t,location:r}){let i=[];for(let n of[...t.userSpecifiedExamples,...t.autogeneratedExamples])i.push({id:n?.example?.id??Oue(),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(a=>[a.name.wireValue,a.value.jsonExample])),pathParameters:Object.fromEntries([...n.example?.rootPathParameters??[],...n.example?.servicePathParameters??[],...n.example?.endpointPathParameters??[]].map(a=>[a.name.originalName,a.value.jsonExample])),queryParameters:Object.fromEntries([...n.example?.queryParameters??[]].map(a=>[a.name.wireValue,a.value.jsonExample])),requestBody:n.example?.request?.jsonExample});return i}};function IVa({ir:e,generationLanguage:t,smartCasing:r,disableExamples:i,generatorConfig:n}){return new Fhu({ir:e,generationLanguage:t,smartCasing:r,generatorConfig:n}).convert({disableExamples:i})}var aY={};xa(aY,{validateObjectExample:()=>Gon,validateTypeExample:()=>Ihu,validateTypeReferenceExample:()=>WU});function EJ_(e){return{errorInstanceIdKey:e.generateNameAndWireValue({wireValue:"errorInstanceId",name:"errorInstanceId"})}}var Lhu=e=>{let t=Sqe(e.file.fernFilepath),r=e.endpointId;return`endpoint_${t}.${r}`};function Uhu({fernFilePath:e}){return e.packagePath.length===0&&e.file==null}function Vhu({resolvedEndpoint:e}){return{endpointId:Lhu(e),serviceId:fP.generateServiceIdFromFernFilepath(e.file.fernFilepath),subpackageId:Uhu({fernFilePath:e.file.fernFilepath})?void 0:fP.generateSubpackageId(e.file.fernFilepath)}}function MJ_({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:Lhu(n),serviceId:fP.generateServiceIdFromFernFilepath(n.file.fernFilepath),subpackageId:Uhu({fernFilePath:n.file.fernFilepath})?void 0:fP.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 AJ_({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??{}:{},u;try{u=i.responseProperties.expires_in!=null?t.resolveResponsePropertyOrThrow({file:r,endpoint:i.endpoint,propertyComponents:i.responseProperties.expires_in}):void 0}catch{}return{endpointReference:Vhu({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:tbM({requestBodyProperties:a,tokenEndpoint:i,file:r,propertyResolver:t})},responseProperties:{accessToken:t.resolveResponsePropertyOrThrow({file:r,endpoint:i.endpoint,propertyComponents:i.responseProperties.access_token}),expiresIn:u,refreshToken:i.responseProperties.refresh_token!=null?t.resolveResponsePropertyOrThrow({file:r,endpoint:i.endpoint,propertyComponents:i.responseProperties.refresh_token}):void 0}}}var tbM=({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 qJ_({propertyResolver:e,endpointResolver:t,file:r,oauthScheme:i,tokenEndpoint:n,refreshTokenEndpoint:a}){let u=AJ_({propertyResolver:e,endpointResolver:t,file:r,tokenEndpoint:n});if(u==null)throw new Error("Failed to convert OAuth token endpoint.");let c=a!=null?MJ_({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:u,refreshEndpoint:c}}var zVa={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}},M7c={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 TJ_(e){return{endpoint:e["get-token"].endpoint,requestProperties:rbM({requestProperties:e["get-token"]?.["request-properties"]}),responseProperties:ibM({responseProperties:e["get-token"]?.["response-properties"]})}}function CJ_(e){if(e["refresh-token"]!=null)return{endpoint:e["refresh-token"].endpoint,requestProperties:nbM({requestProperties:e["refresh-token"]?.["request-properties"]}),responseProperties:abM({responseProperties:e["refresh-token"]?.["response-properties"]})}}function rbM({requestProperties:e}){if(e==null)return zVa.requestProperties;let t=e["client-id"],r=e["client-secret"],i=e.scopes;return{type:"access_token",client_id:t!=null?_Jt(t):zVa.requestProperties.client_id,client_secret:r!=null?_Jt(r):zVa.requestProperties.client_secret,scopes:i!=null?_Jt(i):zVa.requestProperties.scopes}}function ibM({responseProperties:e}){return BJ_({responseProperties:e,defaultValue:zVa.responseProperties})}function nbM({requestProperties:e}){if(e==null)return M7c.requestProperties;let t=e["refresh-token"];return{type:"refresh_token",refresh_token:t!=null?_Jt(t):M7c.requestProperties.refresh_token}}function abM({responseProperties:e}){return BJ_({responseProperties:e,defaultValue:M7c.responseProperties})}function BJ_({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?Kqe(r):t.access_token,expires_in:i!=null?Kqe(i):t.expires_in,refresh_token:n!=null?Kqe(n):t.refresh_token}}function NJ_({rawApiFileSchema:e,file:t,propertyResolver:r,endpointResolver:i}){if(e.auth==null)return{docs:void 0,requirement:zoe.All,schemes:[]};let n=typeof e.auth!="string"?e.auth.docs:void 0;return qen(e.auth,{single:a=>{let u=IJ_({reference:a,authSchemeDeclarations:e["auth-schemes"],file:t,propertyResolver:r,endpointResolver:i});return{docs:n,requirement:zoe.All,schemes:[u]}},any:({any:a})=>({docs:n,requirement:zoe.Any,schemes:a.map(u=>IJ_({reference:u,authSchemeDeclarations:e["auth-schemes"],file:t,propertyResolver:r,endpointResolver:i}))})})}function IJ_({reference:e,authSchemeDeclarations:t,file:r,propertyResolver:i,endpointResolver:n}){let a=(c,d)=>{let s=t?.[c];if(s==null)throw new Error("Unknown auth scheme: "+c);return PNa(s,{header:o=>iq.header({docs:d,name:r.casingsGenerator.generateNameAndWireValue({name:o.name??c,wireValue:o.header}),valueType:r.parseTypeReference(o.type??"string"),prefix:o.prefix,headerEnvVar:o.env}),basic:o=>xJ_({file:r,docs:d,rawScheme:o}),tokenBearer:o=>zJ_({file:r,docs:d,rawScheme:o}),inferredBearer:o=>obM({file:r,docs:d,rawScheme:o,propertyResolver:i,endpointResolver:n}),oauth:o=>RJ_({file:r,docs:d,rawScheme:o,propertyResolver:i,endpointResolver:n})})},u=typeof e=="string"?e:e.scheme;switch(u){case"bearer":return zJ_({file:r,docs:void 0,rawScheme:void 0});case"basic":return xJ_({file:r,docs:void 0,rawScheme:void 0});case"oauth":return RJ_({file:r,docs:void 0,rawScheme:void 0,propertyResolver:i,endpointResolver:n});default:return a(u,typeof e!="string"?e.docs:void 0)}}function zJ_({file:e,docs:t,rawScheme:r}){return iq.bearer({docs:t,token:e.casingsGenerator.generateName(r?.token?.name??"token"),tokenEnvVar:r?.token?.env})}function xJ_({file:e,docs:t,rawScheme:r}){return iq.basic({docs:t,username:e.casingsGenerator.generateName(r?.username?.name??"username"),usernameEnvVar:r?.username?.env,password:e.casingsGenerator.generateName(r?.password?.name??"password"),passwordEnvVar:r?.password?.env})}function RJ_({file:e,docs:t,rawScheme:r,propertyResolver:i,endpointResolver:n}){switch(r?.type){case"client-credentials":return iq.oauth({docs:t,configuration:rzi.clientCredentials(qJ_({propertyResolver:i,endpointResolver:n,file:e,oauthScheme:r,tokenEndpoint:TJ_(r),refreshTokenEndpoint:CJ_(r)}))});default:throw new Error(`Unknown OAuth type: '${r?.type}'`)}}function obM({file:e,docs:t,rawScheme:r,propertyResolver:i,endpointResolver:n}){return iq.inferred({docs:t,tokenEndpoint:ubM({file:e,rawScheme:r,propertyResolver:i,endpointResolver:n})})}function ubM({file:e,rawScheme:t,propertyResolver:r,endpointResolver:i}){let n=t["get-token"],a=typeof n=="string"?{endpoint:n}:n,u=i.resolveEndpointOrThrow({endpoint:a.endpoint,file:e});return{endpoint:Vhu({resolvedEndpoint:u}),expiryProperty:dbM({tokenEndpoint:u,getTokenEndpointConfig:a,propertyResolver:r}),authenticatedRequestHeaders:cbM({tokenEndpoint:u,getTokenEndpointConfig:a,propertyResolver:r})}}var sbM=["access_token","accessToken","AccessToken","token","Token","auth_token","authToken","AuthToken","bearer_token","bearerToken","BearerToken","jwt","Jwt","authentication_token","authenticationToken","AuthenticationToken"];function cbM({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:Kqe(a["response-property"])}),valuePrefix:a["value-prefix"]})}),!i.has("authorization")){let a=lbM({tokenEndpoint:e,propertyResolver:r});a&&i.set("authorization",{headerName:"Authorization",responseProperty:a,valuePrefix:"Bearer "})}return Array.from(i.values())}function lbM({tokenEndpoint:e,propertyResolver:t}){for(let r of sbM)try{let i=t.resolveResponseProperty({file:e.file,endpoint:e.endpointId,propertyComponents:[r]});if(i)return i}catch{}}var fbM=["expires_in","expiresIn","ExpiresIn","exp","Exp","expiry","Expiry","expires","Expires","expires_at","expiresAt","ExpiresAt","expiration","Expiration","valid_until","validUntil","ValidUntil"];function dbM({tokenEndpoint:e,getTokenEndpointConfig:t,propertyResolver:r}){if(t["expiry-response-property"])return r.resolveResponsePropertyOrThrow({file:e.file,endpoint:e.endpointId,propertyComponents:Kqe(t["expiry-response-property"])});for(let i of fbM)try{let n=r.resolveResponseProperty({file:e.file,endpoint:e.endpointId,propertyComponents:[i]});if(n)return n}catch{}}function FJ_({file:e,rawApiFileSchema:t}){if(t.version!=null)return nzi.header({header:pbM({file:e,header:t.version.header}),value:_bM({file:e,versionDeclaration:t.version})})}function pbM({file:e,header:t}){return typeof t=="string"?e6e({file:e,headerKey:t,header:{type:"string"}}):e6e({file:e,headerKey:t.value,header:{type:"string",name:t.name,env:t.env}})}function _bM({file:e,versionDeclaration:t}){return zhu({_enum:{default:t.default,enum:t.values},file:e})}function LJ_({channel:e,typeResolver:t,exampleResolver:r,variableResolver:i,file:n,workspace:a}){let u=[];for(let[c,d]of Object.entries(e.messages??{}))u.push({type:c,availability:ase(d.availability),docs:d.docs,origin:d.origin,body:vbM({body:d.body,file:n}),displayName:d["display-name"]});return{availability:ase(e.availability),path:b7(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,d])=>e6e({headerKey:c,header:d,file:n})):[],docs:e.docs,pathParameters:e["path-parameters"]!=null?pZn({pathParameters:e["path-parameters"],location:D3e.Endpoint,file:n,variableResolver:i}):[],queryParameters:e["query-parameters"]!=null?Object.entries(e["query-parameters"]).map(([c,d])=>{let{name:s}=rji({queryParameterKey:c,queryParameter:d}),o=n.parseTypeReference(d);return{...nY(d),name:n.casingsGenerator.generateNameAndWireValue({wireValue:c,name:s}),valueType:o,allowMultiple:typeof d!="string"&&d["allow-multiple"]!=null?d["allow-multiple"]:!1,v2Examples:{userSpecifiedExamples:{},autogeneratedExamples:{}}}}):[],messages:Object.values(u),examples:(e.examples??[]).map(c=>{let d=gbM({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:mbM({channel:e,example:c,pathParams:d}),...d,...ObM({channel:e,example:c,typeResolver:t,exampleResolver:r,file:n,workspace:a}),queryParameters:c["query-parameters"]!=null?Object.entries(c["query-parameters"]).map(([s,o])=>{let l=e["query-parameters"]?.[s];if(l==null)throw new Error(`Query parameter ${s} does not exist`);return{name:n.casingsGenerator.generateNameAndWireValue({name:rji({queryParameterKey:s,queryParameter:l}).name,wireValue:s}),value:$M({example:o,rawTypeBeingExemplified:typeof l=="string"?l:l.type,typeResolver:t,exampleResolver:r,fileContainingRawTypeReference:n,fileContainingExample:n,workspace:a}),shape:hbM({queryParameter:l})}}):[],messages:c.messages.map(s=>{let o=e.messages?.[s.type];if(o==null)throw new Error(`Message ${s.type} does not exist`);return{type:s.type,body:ybM({message:o,example:s.body,typeResolver:t,exampleResolver:r,file:n,workspace:a})}})}}),v2Examples:{userSpecifiedExamples:{},autogeneratedExamples:{}}}}function hbM({queryParameter:e}){return(typeof e!="string"&&e["allow-multiple"]!=null?e["allow-multiple"]:!1)?s5.exploded():s5.single()}function ybM({message:e,example:t,typeResolver:r,exampleResolver:i,file:n,workspace:a}){if(!PbM(e.body))return JAe.reference($M({example:t,rawTypeBeingExemplified:typeof e.body!="string"?e.body.type:e.body,typeResolver:r,exampleResolver:i,fileContainingRawTypeReference:n,fileContainingExample:n,workspace:a}));if(!Rw(t))throw new Error("Example must be an object");let u=[];for(let[c,d]of Object.entries(t)){let s=e.body.properties?.[c];if(s!=null)u.push({name:n.casingsGenerator.generateNameAndWireValue({name:VU({propertyKey:c,property:s}).name,wireValue:c}),value:$M({example:d,rawTypeBeingExemplified:typeof s!="string"?s.type:s,typeResolver:r,exampleResolver:i,fileContainingRawTypeReference:n,fileContainingExample:n,workspace:a}),originalTypeDeclaration:void 0});else{let o=CVa({extends_:e.body.extends,wirePropertyKey:c,typeResolver:r,file:n});if(o==null)throw new Error("Could not find original type declaration for property: "+c);u.push({name:n.casingsGenerator.generateNameAndWireValue({name:VU({propertyKey:c,property:o.rawPropertyType}).name,wireValue:c}),value:$M({example:d,rawTypeBeingExemplified:typeof o.rawPropertyType=="string"?o.rawPropertyType:o.rawPropertyType.type,typeResolver:r,exampleResolver:i,fileContainingRawTypeReference:o.file,fileContainingExample:n,workspace:a}),originalTypeDeclaration:o.typeName})}}return JAe.inlinedBody({jsonExample:i.resolveAllReferencesInExampleOrThrow({example:t,file:n}).resolvedExample,properties:u})}function vbM({body:e,file:t}){return typeof e=="string"?iU.reference({docs:void 0,bodyType:t.parseTypeReference(e)}):bbM(e)?iU.reference({docs:void 0,bodyType:t.parseTypeReference(e.type)}):iU.inlinedBody({name:t.casingsGenerator.generateName(e.name),extends:pJt(e.extends??[]).map(r=>UU({typeName:r,file:t})),properties:Object.entries(e.properties??{}).map(([r,i])=>({name:t.casingsGenerator.generateNameAndWireValue({name:VU({propertyKey:r,property:i}).name,wireValue:r}),value:t.parseTypeReference(i),valueType:t.parseTypeReference(i),availability:void 0,docs:void 0}))})}function bbM(e){return e.type!=null}function gbM({channel:e,example:t,typeResolver:r,exampleResolver:i,variableResolver:n,file:a,workspace:u}){let c=[],d=({name:s,pathParameterDeclaration:o,examplePathParameter:l})=>{let b=BVa({parameter:o,variableResolver:n,file:a});return{name:s,value:$M({example:l,rawTypeBeingExemplified:b.rawType,typeResolver:r,exampleResolver:i,fileContainingRawTypeReference:b.file,fileContainingExample:a,workspace:u})}};if(t["path-parameters"]!=null){let s=hJt(e);for(let[o,l]of Object.entries(t["path-parameters"])){let b=s[o];if(b!=null)c.push(d({name:a.casingsGenerator.generateName(o),pathParameterDeclaration:b,examplePathParameter:l}));else throw new Error(`Path parameter ${o} does not exist`)}}return{pathParameters:c}}function ObM({channel:e,example:t,typeResolver:r,exampleResolver:i,file:n,workspace:a}){let u=[];if(t.headers!=null)for(let[c,d]of Object.entries(t.headers)){let s=e.headers?.[c];s!=null&&u.push({name:n.casingsGenerator.generateNameAndWireValue({name:cur({headerKey:c,header:s}).name,wireValue:c}),value:$M({example:d,rawTypeBeingExemplified:typeof s=="string"?s:s.type,typeResolver:r,exampleResolver:i,fileContainingRawTypeReference:n,fileContainingExample:n,workspace:a})})}return{headers:u}}function mbM({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 PbM(e){return typeof e=="string"?!1:e.extends!=null||e.properties!=null}function UJ_({errorName:e,errorDeclaration:t,file:r,typeResolver:i,exampleResolver:n,workspace:a}){let u=[];if(t.type!=null&&t.examples!=null)for(let c of t.examples)u.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:$M({example:c.value,rawTypeBeingExemplified:t.type,fileContainingRawTypeReference:r,fileContainingExample:r,typeResolver:i,exampleResolver:n,workspace:a})});return{name:b7i({errorName:e,file:r}),discriminantValue:r.casingsGenerator.generateNameAndWireValue({wireValue:e,name:e}),docs:typeof t!="string"?t.docs:void 0,statusCode:t["status-code"],type:t.type!=null?r.parseTypeReference(t.type):void 0,examples:u,v2Examples:void 0,displayName:void 0}}var VJ_="content";function WJ_(e,t){if(e==null||e.strategy==="status-code")return QAe.statusCode();switch(e.strategy){case"property":return QAe.property({discriminant:t.casingsGenerator.generateNameAndWireValue({name:e["property-name"],wireValue:e["property-name"]}),contentProperty:t.casingsGenerator.generateNameAndWireValue({name:VJ_,wireValue:VJ_})});default:Ao(e)}}function HJ_({readme:e,services:t}){let r=new A7c(t);return{apiName:e.apiName,disabledFeatures:e.disabledSections?.map(i=>i.toUpperCase()),apiReferenceLink:e.apiReferenceLink,bannerLink:e.bannerLink,introduction:e.introduction,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 A7c=class{endpoints={};constructor(t){this.endpoints=this.buildEndpoints(t)}getEndpointForReadme(t){let r=wbM({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:jbM(t),stream:t.response?.body?.type==="streaming"})}getEndpointKey({method:t,path:r,stream:i}){return`${t}|${r}|${i}`}};function jbM(e){let t="";e.fullPath.head.length>0&&(t=Wb(t,e.fullPath.head));for(let r of e.fullPath.parts)t=Wb(t,"{"+r.pathParameter+"}"),r.tail.length>0&&(t=Wb(t,r.tail));return t.startsWith("/")?t:`/${t}`}function wbM({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 $J_({webhooks:e,file:t,typeResolver:r,exampleResolver:i,workspace:n}){let a=[];for(let[u,c]of Object.entries(e))a.push({id:fP.generateWebhookId(t.fernFilepath,u),availability:ase(c.availability),displayName:c["display-name"],docs:c.docs,method:c.method,name:t.casingsGenerator.generateName(u),headers:c.headers!=null?Object.entries(c.headers).map(([d,s])=>e6e({headerKey:d,header:s,file:t})):[],payload:SbM({payload:c.payload,file:t}),examples:c.examples!=null?EbM({webhook:c,examples:c.examples,file:t,typeResolver:r,exampleResolver:i,workspace:n}):void 0,v2Examples:void 0});return a}function SbM({payload:e,file:t}){return typeof e=="string"?XH.reference({docs:void 0,payloadType:t.parseTypeReference(e)}):rJn(e)?XH.reference({docs:void 0,payloadType:t.parseTypeReference(e.type)}):XH.inlinedPayload({name:t.casingsGenerator.generateName(e.name),extends:pJt(e.extends).map(r=>UU({typeName:r,file:t})),properties:e.properties!=null?Object.entries(e.properties).map(([r,i])=>DbM({propertyKey:r,propertyDefinition:i,docs:typeof i!="string"?i.docs:void 0,availability:typeof i!="string"?ase(i.availability):void 0,file:t})):[]})}function DbM({propertyKey:e,propertyDefinition:t,docs:r,availability:i,file:n}){return{docs:r,availability:i,name:n.casingsGenerator.generateNameAndWireValue({wireValue:e,name:VU({propertyKey:e,property:t}).name}),valueType:n.parseTypeReference(t)}}function EbM({webhook:e,examples:t,file:r,typeResolver:i,exampleResolver:n,workspace:a}){let u=typeof e.payload=="string"?e.payload:rJn(e.payload)?e.payload.type:void 0;if(u!=null)return t.map(c=>({docs:e.docs,name:c.name!=null?r.casingsGenerator.generateName(c.name):void 0,payload:$M({example:c.payload,rawTypeBeingExemplified:u,fileContainingRawTypeReference:r,fileContainingExample:r,typeResolver:i,exampleResolver:n,workspace:a})}));if(!Rw(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:$M({example:c.payload,rawTypeBeingExemplified:"map<string, unknown>",fileContainingRawTypeReference:r,fileContainingExample:r,typeResolver:i,exampleResolver:n,workspace:a})}))}function GJ_({name:e,source:t}){return Uw.userDefined({file:Rhu({source:t}),name:g7i.generateName(e)})}function QJ_({encoding:e}){if(e.proto!=null&&e.proto.type!=null){let t=MbM({type:e.proto.type});if(t!=null)return t}}function MbM({type:e}){switch(e){case"google.protobuf.Any":return Uw.wellKnown(vd.any());case"google.protobuf.Api":return Uw.wellKnown(vd.api());case"google.protobuf.BoolValue":return Uw.wellKnown(vd.boolValue());case"google.protobuf.BytesValue":return Uw.wellKnown(vd.bytesValue());case"google.protobuf.DoubleValue":return Uw.wellKnown(vd.doubleValue());case"google.protobuf.Duration":return Uw.wellKnown(vd.duration());case"google.protobuf.Empty":return Uw.wellKnown(vd.empty());case"google.protobuf.Enum":return Uw.wellKnown(vd.enum());case"google.protobuf.EnumValue":return Uw.wellKnown(vd.enumValue());case"google.protobuf.Field":return Uw.wellKnown(vd.field());case"google.protobuf.FieldCardinality":return Uw.wellKnown(vd.fieldCardinality());case"google.protobuf.FieldKind":return Uw.wellKnown(vd.fieldKind());case"google.protobuf.FieldMask":return Uw.wellKnown(vd.fieldMask());case"google.protobuf.FloatVlaue":return Uw.wellKnown(vd.floatValue());case"google.protobuf.Int32Value":return Uw.wellKnown(vd.int32Value());case"google.protobuf.Int64Value":return Uw.wellKnown(vd.int64Value());case"google.protobuf.ListValue":return Uw.wellKnown(vd.listValue());case"google.protobuf.Method":return Uw.wellKnown(vd.method());case"google.protobuf.Mixin":return Uw.wellKnown(vd.mixin());case"google.protobuf.NullValue":return Uw.wellKnown(vd.nullValue());case"google.protobuf.Option":return Uw.wellKnown(vd.option());case"google.protobuf.SourceContext":return Uw.wellKnown(vd.sourceContext());case"google.protobuf.StringValue":return Uw.wellKnown(vd.stringValue());case"google.protobuf.Struct":return Uw.wellKnown(vd.struct());case"google.protobuf.Syntax":return Uw.wellKnown(vd.syntax());case"google.protobuf.Timestamp":return Uw.wellKnown(vd.timestamp());case"google.protobuf.Type":return Uw.wellKnown(vd.type());case"google.protobuf.Uint32Value":return Uw.wellKnown(vd.uint32Value());case"google.protobuf.Uint64Value":return Uw.wellKnown(vd.uint64Value());case"google.protobuf.Value":return Uw.wellKnown(vd.value())}}function JJ_({generic:e,file:t,typeResolver:r}){let i=typeof e=="string"?e:e.type,n=vN(i);if(n==null)throw new Error(`Invalid generic type definition: ${i}`);let a=r.getDeclarationOfNamedTypeOrThrow({referenceToNamedType:i,file:t});if(n.arguments&&TD(a.declaration)){let u=vN(a.typeName)?.arguments??[],c=Object.entries(a.declaration.properties??{}).map(([d,s])=>{let o=s;return typeof s=="string"&&u?.includes(s)&&(o=n.arguments?.[u.indexOf(s)]??s),[d,o]});return a0.object({extends:pJt(a.declaration.extends).map(d=>UU({typeName:d,file:t})),properties:EVa({properties:Object.fromEntries(c)},t),extraProperties:a.declaration["extra-properties"]??!1,extendedProperties:void 0})}throw new Error(`Generic type definition not supported: ${i}`)}function KJ_({alias:e,file:t,typeResolver:r}){let i=typeof e=="string"?e:e.type;return j3e(i)?JJ_({generic:i,file:t,typeResolver:r}):a0.alias({aliasOf:t.parseTypeReference(e),resolvedType:AbM({aliasOf:i,file:t,typeResolver:r})})}function AbM({aliasOf:e,file:t,typeResolver:r}){let i=r.resolveTypeOrThrow({type:e,file:t});switch(i._type){case"primitive":return YH.primitive(i.originalTypeReference.primitive);case"container":return YH.container(i.originalTypeReference.container);case"unknown":return YH.unknown();case"named":{let n=TD(i.declaration)?PGt.Object:yzi(i.declaration)?PGt.Union:DGt(i.declaration)?PGt.Enum:_Un(i.declaration)?PGt.UndiscriminatedUnion:Ao(i.declaration);return YH.named({name:i.name,shape:n})}}}function YJ_({union:e,file:t}){let r=e.union.filter((i,n)=>{let a=typeof i=="string"?i:i.type;return e.union.findIndex(u=>(typeof u=="string"?u:u.type)===a)===n});return a0.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"?YAo(n.name.originalName):i["display-name"]??YAo(n.name.originalName)}:n,docs:typeof i=="string"?void 0:i.docs}})})}function XJ_(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 T7c({typeDeclaration:e,file:t,typeResolver:r,seenTypeNames:i=new q7c}){let n=DF(e,{alias:u=>{let c=typeof u=="string"?u:u.type,d=vN(c);if(d!=null){let s=new Set(d.arguments??[]),o=r.getDeclarationOfNamedTypeOrThrow({referenceToNamedType:c,file:t}),l=vN(o.typeName)?.arguments;if(TD(o.declaration)){let b=XJ_(o.declaration);l&&b.filter(g=>!l.includes(g)).forEach(g=>s.add(g))}return Array.from(s)}return[c]},object:u=>XJ_(u),discriminatedUnion:u=>{let c=[];return u["base-properties"]!=null&&c.push(...Object.values(u["base-properties"]).map(d=>typeof d=="string"?d:d.type)),c.push(...Object.values(u.union).reduce((d,s)=>{let o=typeof s=="string"?s:s.type;return typeof o=="string"&&d.push(o),d},[])),c},undiscriminatedUnion:u=>Object.values(u.union).reduce((c,d)=>{let s=typeof d=="string"?d:d.type;return typeof s=="string"&&c.push(s),c},[]),enum:()=>[]}),a=[];for(let u of n){let c=SF({type:u,_default:void 0,validation:void 0,visitor:{primitive:()=>[],map:({keyType:d,valueType:s})=>[...d,...s],list:d=>d,optional:d=>d,nullable:d=>d,set:d=>d,named:d=>[d],literal:()=>[],unknown:()=>[]}});for(let d of c){let s=UU({typeName:d,file:t});if(!i.hasTypeNameBeenSeen(s)){i.addTypeName(s),a.push(s);let o=r.getDeclarationOfNamedTypeOrThrow({referenceToNamedType:d,file:t});if(j3e(o.typeName))continue;a.push(...T7c({typeDeclaration:o.declaration,file:o.file,typeResolver:r,seenTypeNames:i}))}}}return a}var q7c=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 ZJ_({typeName:e,typeDeclaration:t,file:r,typeResolver:i,exampleResolver:n,sourceResolver:a,workspace:u}){let c=nY(t),d=UU({typeName:e,file:r}),s=T7c({typeDeclaration:t,file:r,typeResolver:i}),o={};TD(t)&&(o=Zin(t.properties??{}));let l=TbM({file:r,typeDeclaration:t,typeName:e,sourceResolver:a});return{propertiesByAudience:o,typeDeclaration:{...c,inline:zbM(t),name:d,shape:qbM({typeDeclaration:t,file:r,typeResolver:i}),referencedTypes:new Set(s.map(b=>b.typeId)),encoding:CbM({typeDeclaration:t,source:l}),source:l,userProvidedExamples:typeof t!="string"&&t.examples!=null?t.examples.map(b=>({name:b.name!=null?r.casingsGenerator.generateName(b.name):void 0,docs:b.docs,jsonExample:n.resolveAllReferencesInExampleOrThrow({example:b.value,file:r}).resolvedExample,shape:E7c({typeName:d,example:b.value,typeResolver:i,exampleResolver:n,typeDeclaration:t,fileContainingType:r,fileContainingExample:r,workspace:u})})):[],autogeneratedExamples:[],v2Examples:void 0},descendantFilepaths:new Set(s.map(b=>b.fernFilepath))}}function qbM({typeDeclaration:e,file:t,typeResolver:r}){return DF(e,{alias:i=>KJ_({alias:i,file:t,typeResolver:r}),object:i=>zQ_({object:i,file:t}),discriminatedUnion:i=>YQ_({union:i,file:t,typeResolver:r}),undiscriminatedUnion:i=>YJ_({union:i,file:t}),enum:i=>a0.enum(zhu({_enum:i,file:t}))})}function TbM({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=QJ_({encoding:t.encoding});if(a!=null)return nOi.proto(a)}if(t.source==null)return;let n=i.resolveSourceOrThrow({source:t.source,relativeFilepath:e.relativeFilepath});if(!(n==null||n.type!=="protobuf"))return nOi.proto(GJ_({source:n,name:r}))}function CbM({typeDeclaration:e,source:t}){return typeof e!="string"&&e.encoding!=null?BbM(e.encoding):IbM(t)}function BbM(e){return e.proto!=null?{json:void 0,proto:{}}:{json:{},proto:void 0}}function IbM(e){return e!=null&&e.type==="proto"?{json:void 0,proto:{}}:{json:{},proto:void 0}}function zbM(e){if(typeof e!="string"&&"inline"in e)return e.inline}function kJ_(e,t){let r=t[e];if(r==null)throw new Cgi(`Illegal Error: Failed to load type declaration for type ${e}`);return r}function eK_(e){e.types=Object.fromEntries(Object.entries(e.types).map(([t,r])=>[t,RbM({typeDeclaration:r,ir:e})])),e.services=Object.fromEntries(Object.entries(e.services).map(([t,r])=>[t,{...r,endpoints:r.endpoints.map(i=>xbM({endpoint:i,ir:e}))}]))}function xbM({endpoint:e,ir:t}){return e.requestBody?.type!=="inlinedRequestBody"?e:{...e,requestBody:{...e.requestBody,extendedProperties:e.requestBody.extends.flatMap(r=>tK_(r,t))}}}function RbM({typeDeclaration:e,ir:t}){switch(e.shape.type){case"object":return{...e,shape:{...e.shape,extendedProperties:e.shape.extends.flatMap(r=>tK_(r,t))}}}return e}function tK_(e,t){let r=C7c(e.typeId,t);return rK_({objectTypeDeclaration:r,ir:t})}function C7c(e,t){let r=kJ_(e,t.types);switch(r.shape.type){case"object":return r.shape;case"alias":if(r.shape.resolvedType.type==="named")return C7c(r.shape.resolvedType.name.typeId,t)}throw new Cgi(`Unexpected error: ${e} is extended but has shape ${r.shape.type}`)}function rK_({objectTypeDeclaration:e,ir:t}){let r=e.extends.flatMap(i=>{let n=C7c(i.typeId,t);return rK_({objectTypeDeclaration:n,ir:t})});return[...e.properties,...r]}var Whu=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:fP.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:Dd(this.subpackages,(i,n)=>({...i,hasEndpointsInTree:r.has(n)})),rootPackage:{...this.rootPackage,hasEndpointsInTree:r.size>0||this.rootPackage.service!=null}}}sortRootPackage(t){if(!iK_(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(!iK_(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 o=this.subpackages[s];if(o==null)throw new Error("Subpackage ID is invalid: "+s);return o}),u=r+1,c={allParts:t.allParts.slice(0,u),packagePath:t.packagePath.slice(0,u),file:u===t.allParts.length?t.file:void 0},d=a.find(s=>s.name.originalName===n.originalName);if(d==null){let s=fP.generateSubpackageId(c),o={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]=o,i.subpackages.push(s),d=o}return this.getPackageForFernFilepath(t,u,d)}};function iK_(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 nK_({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:v7i({referencedIn:t,importPath:c})}}var Jon=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 KF(this.workspace,(n,a,u)=>{let c=fg({relativeFilepath:n,definitionFile:a,casingsGenerator:g7i,rootApiFile:this.workspace.definition.rootApiFile.contents,defaultUrl:u.defaultUrl});for(let[d,s]of Object.entries(a.service?.endpoints??{}))s.method===t&&s.path===r&&(i={endpointId:d,endpoint:s,file:c})}),man(this.workspace,(n,a)=>{let u=fg({relativeFilepath:n,definitionFile:a,casingsGenerator:g7i,rootApiFile:this.workspace.definition.rootApiFile.contents});for(let[c,d]of Object.entries(a.service?.endpoints??{}))d.method===t&&d.path===r&&(i={endpointId:c,endpoint:d,file:u})}),i}resolveEndpoint({endpoint:t,file:r}){let n=new jen().tryParse(t);if(n!=null)return this.resolveEndpointByMethodAndPath(n);let a=this.getDeclarationOfEndpoint({referenceToEndpoint:t,file:r});if(a==null)return;let u=a.file.definitionFile.service?.endpoints?.[a.endpointName];if(u!=null)return{endpointId:a.endpointName,endpoint:u,file:a.file}}getDeclarationOfEndpoint({referenceToEndpoint:t,file:r}){let i=nK_({reference:t,referencedIn:r.relativeFilepath,imports:r.imports});if(i==null)return;let n=Que(this.workspace,i.relativeFilepath);if(!(n==null||n.service?.endpoints?.[i.endpointName]==null))return{endpointName:i.endpointName,file:fg({relativeFilepath:i.relativeFilepath,definitionFile:n,casingsGenerator:r.casingsGenerator,rootApiFile:this.workspace.definition.rootApiFile.contents})}}};var Kon=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=Jqe({reference:t,referencedIn:r.relativeFilepath,imports:r.imports});if(i==null)return;let n=Que(this.workspace,i.relativeFilepath);if(n==null)return;let a=n.errors?.[i.typeName];if(a!=null)return{declaration:a,file:fg({definitionFile:n,relativeFilepath:i.relativeFilepath,casingsGenerator:r.casingsGenerator,rootApiFile:this.workspace.definition.rootApiFile.contents})}}};var Xqe=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||typeof i.resolvedExample=="string"?i:this.resolveAllReferencesInExample({example:i.resolvedExample,file:i.file})}else if(Rw(t)){let i={};for(let[n,a]of Object.entries(t)){let u=this.resolveAllReferencesInExample({example:a,file:r});if(u==null)return;i[n]=u.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}){if(typeof t!="string")return{resolvedExample:t,file:r};if(t.startsWith(`\\${sir}`))return{resolvedExample:t.slice(1),file:r};if(!t.startsWith(sir))return{resolvedExample:t,file: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(u=>u.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(sir.length),exampleName:i}:{rawTypeReference:`${r}.${i}`.slice(sir.length),exampleName:n}}};var Hhu=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.resolveObjectProperty({file:n.file,typeName:n.endpoint.request,propertyComponents:i});if(a!=null)return{propertyPath:this.propertyPathFromPropertyComponents({propertyComponents:i,file:t}),property:Roe.body(a)}}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.resolveObjectProperty({file:n.file,typeName:(typeof n.endpoint.response!="string"?n.endpoint.response?.type:n.endpoint.response)??"",propertyComponents:i});if(a!=null)return{propertyPath:this.propertyPathFromPropertyComponents({propertyComponents:i,file:t}),property:a}}resolveRequestPropertyFromInlinedRequest({typeResolver:t,file:r,requestType:i,propertyComponents:n}){if(n.length===1){let a=n[0]??"",u=i["query-parameters"]?.[a]??void 0;if(u!=null)return{property:Roe.query(xhu({file:r,queryParameterKey:a,queryParameter:u})),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 u=this.resolveObjectProperty({file:r,typeName:i.body,propertyComponents:n});return u==null?void 0:{propertyPath:this.propertyPathFromPropertyComponents({propertyComponents:n,file:r}),property:Roe.body(u)}}if(oI(i.body)){let u=j7c({typeResolver:t,file:r,objectSchema:i.body,propertyComponents:n});return u==null?void 0:{propertyPath:this.propertyPathFromPropertyComponents({propertyComponents:n,file:r}),property:Roe.body(u)}}let a=this.resolveObjectProperty({file:r,typeName:i.body.type,propertyComponents:n});if(a!=null)return{propertyPath:this.propertyPathFromPropertyComponents({propertyComponents:n,file:r}),property:Roe.body(a)}}resolveObjectProperty({file:t,typeName:r,propertyComponents:i}){let n=this.typeResolver.resolveTypeOrThrow({type:r,file:t});return P7c({typeResolver:this.typeResolver,file:AVa(n)??t,resolvedType:n,propertyComponents:i})}propertyPathFromPropertyComponents({propertyComponents:t,file:r}){return t.length<=1?[]:t.slice(0,-1).map(i=>r.casingsGenerator.generateName(i))}};var LS=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=Jqe({reference:t,referencedIn:r.relativeFilepath,imports:r.imports});if(i==null)return;let n=Que(this.workspace,i.relativeFilepath);if(n==null)return;let a=n.types?.[i.typeName];if(a==null){let u=vN(i.typeName);if(u!=null){for(let c of Object.keys(n.types??{})??[])if(u.name&&c.startsWith(u.name)&&c.endsWith(">")){let d=n.types?.[c];return d!=null?{typeName:c,declaration:d,file:fg({relativeFilepath:i.relativeFilepath,definitionFile:n,casingsGenerator:r.casingsGenerator,rootApiFile:this.workspace.definition.rootApiFile.contents})}:void 0}}return}return{typeName:i.typeName,declaration:a,file:fg({relativeFilepath:i.relativeFilepath,definitionFile:n,casingsGenerator:r.casingsGenerator,rootApiFile:this.workspace.definition.rootApiFile.contents})}}resolveType({type:t,file:r,objectPath:i=[]}){return SF({type:t,_default:void 0,validation:void 0,visitor:{primitive:n=>({_type:"primitive",primitive:n,originalTypeReference:ol.primitive(n)}),unknown:()=>({_type:"unknown",originalTypeReference:ol.unknown()}),map:({keyType:n,valueType:a})=>n!=null&&a!=null?{_type:"container",container:{_type:"map",keyType:n,valueType:a},originalTypeReference:ol.container(Zy.map({keyType:n.originalTypeReference,valueType:a.originalTypeReference}))}:void 0,list:n=>n!=null?{_type:"container",container:{_type:"list",itemType:n},originalTypeReference:ol.container(Zy.list(n.originalTypeReference))}:void 0,optional:n=>n!=null?{_type:"container",container:{_type:"optional",itemType:n},originalTypeReference:ol.container(Zy.optional(n.originalTypeReference))}:void 0,nullable:n=>n!=null?{_type:"container",container:{_type:"nullable",itemType:n},originalTypeReference:ol.container(Zy.nullable(n.originalTypeReference))}:void 0,set:n=>n!=null?{_type:"container",container:{_type:"set",itemType:n},originalTypeReference:ol.container(Zy.set(n.originalTypeReference))}:void 0,literal:n=>({_type:"container",container:{_type:"literal",literal:n},originalTypeReference:ol.container(Zy.literal(n))}),named:n=>{let a=this.getDeclarationOfNamedType({referenceToNamedType:n,file:r});if(a==null)return;let u={typeName:a.typeName,file:a.file.relativeFilepath,reference:n};if(!i.some(c=>c.file===u.file&&c.typeName===u.typeName))return this.resolveNamedTypeFromDeclaration({referenceToNamedType:n,referencedIn:r,rawDeclaration:a,objectPath:[...i,u]})}}})}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:u}=i;if(hzi(a))return this.resolveType({type:typeof a=="string"?a:a.type,file:u,objectPath:n});let c=TVa({type:t,_default:void 0,validation:void 0,file:r});if(!(c.type!=="named"||Que(this.workspace,u.relativeFilepath)==null))return{_type:"named",rawName:i.typeName,name:c,declaration:a,filepath:u.relativeFilepath,objectPath:n,originalTypeReference:c,file:u}}};var vJt=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:tji({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 $hu(e,t){if(t){for(let[r,i]of Object.entries(t))if(typeof i!="string"&&r===e)return i.audiences}}function Dx({workspace:e,generationLanguage:t,keywords:r,smartCasing:i,exampleGeneration:n,audiences:a,readme:u,packageName:c,version:d,fdrApiDefinitionId:s,sourceResolver:o,disableDynamicExamples:l,dynamicGeneratorConfig:b}){let g=Iee({generationLanguage:t,keywords:r,smartCasing:i}),O=new kin(a),m=tji({casingsGenerator:g,rootApiFile:e.definition.rootApiFile.contents}),P=(e.definition.rootApiFile.contents.errors??[]).map(at=>({error:b7i({errorName:at,file:m}),docs:void 0})),D=new LS(e),A=new Jon(e),M=new Hhu(D,A),E=new Kon(e),T=new Xqe(D),z=new vJt,I=N8a({casingsGenerator:g,rawApiFileSchema:e.definition.rootApiFile.contents})?.environmentsConfig,N={selfHosted:!1,fdrApiDefinitionId:s,apiVersion:FJ_({file:m,rawApiFileSchema:e.definition.rootApiFile.contents}),apiName:g.generateName(e.definition.rootApiFile.contents.name),apiDisplayName:e.definition.rootApiFile.contents["display-name"],apiDocs:DVa(e.definition.rootApiFile.contents.docs),auth:NJ_({rawApiFileSchema:e.definition.rootApiFile.contents,file:m,propertyResolver:M,endpointResolver:A}),headers:e.definition.rootApiFile.contents.headers!=null?Object.entries(e.definition.rootApiFile.contents.headers).map(([at,Oe])=>e6e({headerKey:at,header:Oe,file:m})):[],idempotencyHeaders:e.definition.rootApiFile.contents["idempotency-headers"]!=null?Object.entries(e.definition.rootApiFile.contents["idempotency-headers"]).map(([at,Oe])=>e6e({headerKey:at,header:Oe,file:m})):[],types:{},errors:{},services:{},constants:EJ_(g),environments:I,errorDiscriminationStrategy:WJ_(e.definition.rootApiFile.contents["error-discrimination"],m),basePath:e.definition.rootApiFile.contents["base-path"]!=null?b7(e.definition.rootApiFile.contents["base-path"]):void 0,pathParameters:pZn({pathParameters:e.definition.rootApiFile.contents["path-parameters"],file:m,location:D3e.Root,variableResolver:z}),variables:e.definition.rootApiFile.contents.variables!=null?Object.entries(e.definition.rootApiFile.contents.variables).map(([at,Oe])=>({docs:typeof Oe!="string"?Oe.docs:void 0,id:at,name:m.casingsGenerator.generateName(at),type:m.parseTypeReference(Oe)})):[],serviceTypeReferenceInfo:{typesReferencedOnlyByService:{},sharedTypes:[]},webhookGroups:{},websocketChannels:{},readmeConfig:void 0,sourceConfig:void 0,publishConfig:void 0,dynamic:void 0,audiences:e.definition.rootApiFile.contents.audiences},U=new Whu,Y=at=>{U.addSubpackage(at.fernFilepath),S1(at.definitionFile,{imports:Ko,docs:Oe=>{Oe!=null&&U.addDocs(at.fernFilepath,Oe)},types:Oe=>{if(Oe!=null)for(let[je,bt]of Object.entries(Oe)){if(j3e(je))continue;let Dt=ZJ_({typeName:je,typeDeclaration:bt,file:at,typeResolver:D,exampleResolver:T,sourceResolver:o,workspace:e}),mr=Dt.typeDeclaration;n.disabled&&(mr.userProvidedExamples=[],mr.autogeneratedExamples=[]);let lr=Dt.descendantFilepaths,si=fP.generateTypeId(mr.name);N.types[si]=mr,U.addType(si,mr),O.addType({declaredTypeName:mr.name,descendantTypeIds:mr.referencedTypes,descendantTypeIdsByAudience:{},propertiesByAudience:Dt.propertiesByAudience,descendantFilepaths:lr}),O.markTypeForAudiences(mr.name,IQ_(bt))}},errors:Oe=>{if(Oe==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[bt,Dt]of Object.entries(Oe)){let mr=UJ_({errorName:bt,errorDeclaration:Dt,file:at,typeResolver:D,exampleResolver:T,workspace:e}),lr=fP.generateErrorId(mr.name);N.errors[lr]=mr,U.addError(lr,mr),O.addError(mr)}},service:Oe=>{if(Oe==null)return;let je=SJ_({rootDefaultUrl:at.defaultUrl??e.definition.rootApiFile.contents["default-url"],rootPathParameters:N.pathParameters,serviceDefinition:Oe,file:at,errorResolver:E,typeResolver:D,propertyResolver:M,exampleResolver:T,sourceResolver:o,globalErrors:P,variableResolver:z,workspace:e}),bt=fP.generateServiceId(je.name);N.services[bt]=je,U.addService(bt,je);let Dt={};je.endpoints.forEach(mr=>{n.disabled&&(mr.autogeneratedExamples=[],mr.userSpecifiedExamples=[]);let lr=Oe.endpoints[mr.name.originalName];O.addEndpoint(je,mr,lr),Dt[mr.name.originalName]=mr}),Oe.audiences!=null&&O.markEndpointForAudience(je.name,je.endpoints,Oe.audiences),Object.entries(Oe.endpoints).map(([mr,lr])=>{let si=Dt[mr];si!=null&&lr.audiences!=null&&O.markEndpointForAudience(je.name,[si],lr.audiences)})},webhooks:Oe=>{if(Oe==null)return;let je=fP.generateWebhookGroupId(at.fernFilepath),bt=$J_({webhooks:Oe,file:at,typeResolver:D,exampleResolver:T,workspace:e}),Dt={};for(let mr of bt)Dt[mr.name.originalName]=mr;Object.entries(Oe).forEach(([mr,lr])=>{let si=Dt[mr];si!=null&&(O.addWebhook(at.fernFilepath,si,lr),lr.audiences!=null&&O.markWebhookForAudiences(at.fernFilepath,si,lr.audiences))}),N.webhookGroups[je]=bt,U.addWebhookGroup(je,at.fernFilepath)},channel:Oe=>{if(Oe==null)return;let je=fP.generateWebSocketChannelId(at.fernFilepath),bt=LJ_({channel:Oe,file:at,variableResolver:z,typeResolver:D,exampleResolver:T,workspace:e});O.addChannel(at.fernFilepath,je,bt,Oe),Oe.audiences!=null&&O.markChannelForAudiences(at.fernFilepath,je,Oe.audiences),N.websocketChannels!=null&&(N.websocketChannels[je]=bt,U.addWebSocketChannel(je,at.fernFilepath))}})};KF(e,(at,Oe,je)=>{Y(fg({relativeFilepath:at,definitionFile:Oe,casingsGenerator:g,rootApiFile:e.definition.rootApiFile.contents,defaultUrl:je.defaultUrl}))}),man(e,(at,Oe)=>{if(Oe.navigation!=null)if(typeof Oe.navigation=="string")U.addPackageRedirection({from:nse({relativeFilepath:at,casingsGenerator:g}),to:nse({relativeFilepath:X3(UNe(at),Ey.of(Oe.navigation)),casingsGenerator:g})});else{let je=Oe.navigation.map(bt=>fP.generateSubpackageId(nse({relativeFilepath:X3(UNe(at),Ey.of(bt)),casingsGenerator:g})));at===CS?U.sortRootPackage(je):U.sortSubpackage(fP.generateSubpackageId(nse({relativeFilepath:at,casingsGenerator:g})),je)}}),N.serviceTypeReferenceInfo=FbM(O),eK_(N);let J=n.disabled?N:V8a({ir:N,exampleGeneration:n}),X=e.definition.rootApiFile.contents,oe=I?.environments._visit({singleBaseUrl:at=>at.environments.filter(Oe=>$hu(Oe.id,X.environments)!=null).length===0,multipleBaseUrls:at=>at.environments.filter(Oe=>$hu(Oe.id,X.environments)!=null).length===0,_other:()=>!1});I?.environments.environments.forEach(at=>{O.markEnvironmentForAudiences(at,$hu(at.id,X.environments)??[],oe)});let pe=O.hasNoAudiences()?void 0:O.build(),de=Ujc(J,pe),me=e.definition.rootApiFile.contents.auth!=null&&Object.values(de.services).every(at=>at.endpoints.every(Oe=>Oe.auth)),Le=Object.values(de.services).some(at=>at.endpoints.some(Oe=>Oe.response?.body?.type==="streaming")),vt=Object.values(de.services).some(at=>at.endpoints.some(Oe=>Oe.pagination!=null)),De=Object.values(de.services).some(at=>at.endpoints.some(Oe=>Oe.response?.body?.type==="fileDownload")),Ae={isAuthMandatory:me,hasStreamingEndpoints:Le,hasPaginatedEndpoints:vt,hasFileDownloadEndpoints:De,platformHeaders:{language:"X-Fern-Language",sdkName:"X-Fern-SDK-Name",sdkVersion:"X-Fern-SDK-Version",userAgent:d!=null&&c!=null?{header:"User-Agent",value:`${c}/${d}`}:void 0}},Ct=u??e.generatorsConfiguration?.rawConfiguration.readme,Pe=Ct!=null?HJ_({readme:Ct,services:N.services}):void 0,St=NbM({...de,...U.build(pe),sdkConfig:Ae,readmeConfig:Pe});return{...St,dynamic:IVa({ir:St,generatorConfig:b,disableExamples:l,generationLanguage:t,smartCasing:i})}}function NbM(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]=DVa(n):n&&typeof n=="object"&&t(n)}return r};return t(e)}function FbM(e){let t={},r=[],i=e.getTypesReferencedByService();for(let[n,a]of Object.entries(i)){if(a.size===1){let u=a.values().next().value;if(u==null)break;t[u]===void 0&&(t[u]=[]),t[u]?.push(n);continue}r.push(n)}return{typesReferencedOnlyByService:t,sharedTypes:r}}var nZ_=ci(lhu(),1),aZ_=ci(fhu(),1),Zyu=require("fs/promises"),AFc=ci(tQt(),1);function aK_(e){throw new Error("Unexpected value: "+JSON.stringify(e))}var uK_=ci(M8n(),1);var oK_=["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 bJt(e){return e=e.replace(/([a-z])([A-Z])/g,"$1 $2"),e=e.replace(/_/g," "),e=e.replace(/-/g," "),(0,uK_.default)(e,{special:oK_}).replace(/V\s(\d)/g,"V$1")}function xVa(e,t="type"){return{_visit:r=>{let i=r[e[t]];return i!=null?i(e):(r._other==null&&aK_(e),r._other(e))}}}function lur(e){return typeof e.subpackageId=="string"}function Yon(e,t){return`${e} ${AB(t)}`}function AB(e){return e.map(t=>t.type==="literal"?t.value:`{${t.value}}`).join("")}function t6e(e){return e.map(t=>t.type==="literal"?t.value:`:${t.value}`).join("")}var B7c="__package__",m7i=class e{api;context;static create(t,r){return new e(t,r)}#e=new Map;#t=new Map;#r=new Map;#n=new Map;#i=new Map;#a=new Map;#o=new Map;#s=new Map;#f=new Map;#u=new Map;#c=new Map;#l=new Map;#p=new Map;#_=new Map;static getSubpackageId(t){return lur(t)?t.subpackageId:B7c}getSubpackageByIdOrLocator(t){if(t==null)return;let r=j2.SubpackageId(t),i=j2.SubpackageId(`subpackage_${F_(t)}`);return r===B7c?this.api.rootPackage:this.api.subpackages[r]??this.#_.get(r)??this.api.subpackages[i]??this.#_.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=j2.SubpackageId(e.getSubpackageId(i)),a={endpoints:new Map,webSockets:new Map,webhooks:new Map,grpcs:new Map};this.#f.set(n,a),i.endpoints.forEach(u=>{if(u.protocol?.type==="grpc"){a.grpcs.set(u.id,u);let c=e.createGrpcId(u,n);this.#n.set(c,u)}else{a.endpoints.set(u.id,u);let c=e.createEndpointId(u,n);this.#e.set(c,u);let d=[],s=[u.method];u.response?.type.type==="stream"&&s.push("STREAM"),s.forEach(o=>{d.push(`${o} ${AB(u.path.parts)}`),d.push(`${o} ${t6e(u.path.parts)}`),u.environments.forEach(l=>{d.push(`${o} ${Wb(l.baseUrl,AB(u.path.parts))}`),d.push(`${o} ${Wb(l.baseUrl,t6e(u.path.parts))}`);let b=Ghu(l);b!=null&&(d.push(`${o} ${Wb(b,AB(u.path.parts))}`),d.push(`${o} ${Wb(b,t6e(u.path.parts))}`))})}),d.forEach(o=>{this.context?.logger.trace(`Registering endpoint locator: ${o}`),this.#u.set(o,u)})}}),i.websockets.forEach(u=>{a.webSockets.set(u.id,u);let c=e.createWebSocketId(u,n);this.#t.set(c,u);let d=[];["GET","WSS"].forEach(o=>{d.push(`${o} ${AB(u.path.parts)}`),d.push(`${o} ${t6e(u.path.parts)}`),u.environments.forEach(l=>{d.push(`${o} ${Wb(l.baseUrl,AB(u.path.parts))}`),d.push(`${o} ${Wb(l.baseUrl,t6e(u.path.parts))}`);let b=Ghu(l);b!=null&&(d.push(`${o} ${Wb(b,AB(u.path.parts))}`),d.push(`${o} ${Wb(b,t6e(u.path.parts))}`))})}),d.forEach(o=>{this.context?.logger.trace(`Registering websocket locator: ${o}`),this.#c.set(o,u)})}),i.webhooks.forEach(u=>{a.webhooks.set(u.id,u),this.#r.set(e.createWebhookId(u,n),u)})}),this.#e.forEach((i,n)=>{this.#i.set(i,n)}),this.#t.forEach((i,n)=>{this.#a.set(i,n)}),this.#r.forEach((i,n)=>{this.#o.set(i,n)}),this.#n.forEach((i,n)=>{this.#s.set(i,n)}),this.#h(t.rootPackage,[])}#h(t,r){if(t==null)return;let i=lur(t)?[...r,t.name]:r,n=i.length===0?[B7c]:i;if([n.join("."),n.join("/"),`${n.join(".")}.yml`].forEach(u=>{this.context?.logger.trace(`Registering subpackage locator: ${u}`),this.#_.set(u,t)}),t.pointsTo!=null)return this.#h(this.api.subpackages[t.pointsTo],i);t.endpoints.forEach(u=>{if(u.protocol?.type==="grpc")return;let c=[...i,u.id];[c.join("."),c.join("/")].forEach(s=>{this.context?.logger.trace(`Registering endpoint locator: ${s}`),this.#u.set(s,u)})}),t.websockets.forEach(u=>{let c=[...i,u.id];[c.join("."),c.join("/")].forEach(s=>{this.context?.logger.trace(`Registering websocket locator: ${s}`),this.#c.set(s,u)})}),t.webhooks.forEach(u=>{let c=[...i,u.id];[c.join("."),c.join("/")].forEach(s=>{this.context?.logger.trace(`Registering webhook locator: ${s}`),this.#l.set(s,u)})}),t.subpackages.forEach(u=>{this.#h(this.api.subpackages[u],i)})}get endpoints(){return this.#e}get webSockets(){return this.#t}get webhooks(){return this.#r}get grpcs(){return this.#n}get endpointsByLocator(){return this.#u}get webSocketsByLocator(){return this.#c}get webhooksByLocator(){return this.#l}get grpcsByLocator(){return this.#p}get subpackages(){return this.#f}get subpackagesByLocator(){return this.#_}get subpackageLocators(){return new Set(this.#_.keys())}getEndpointId(t){return this.#i.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 Do.EndpointId(t.originalEndpointId??`${r}.${t.id}`)}static createWebSocketId(t,r){return Do.WebSocketId(`${r}.${t.id}`)}static createWebhookId(t,r){return Do.WebhookId(`${r}.${t.id}`)}static createGrpcId(t,r){return Do.GrpcId(`${r}.${t.id}`)}};function Ghu(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 _Zn=ci(lhu(),1),cK_=ci(fhu(),1);function sK_(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{}}_Zn.default.extend(cK_.default);var LbM="Changelog",UbM=["summary","index","overview"],iji=class{markdownToFullSlug;markdownToNoIndex;changelogFiles;docsWorkspace;idgen;constructor(t,r,i,n,a){this.markdownToFullSlug=t,this.markdownToNoIndex=r,this.changelogFiles=i,this.docsWorkspace=n,this.idgen=a}toChangelogNode(t){let r=t.title??LbM,i=[],n;for(let b of this.changelogFiles??[]){let g=mHs(b.split("/"));if(g==null)continue;let O=sK_(g);if(O==null){let P=g.split(".")[0]?.toLowerCase();P!=null&&UbM.includes(P)&&(n=b);continue}let m=this.toRelativeFilepath(b);i.push({date:O,pageId:Do.PageId(m),absoluteFilepath:b})}let a=t.parentSlug.apply({fullSlug:n!=null?this.markdownToFullSlug.get(n)?.split("/"):void 0,skipUrlSlug:!1,urlSlug:t.slug??FT(r)}),u=n!=null?this.markdownToNoIndex.get(n):void 0,c=i.map(b=>{let g=_Zn.default.utc(b.date);return{id:this.idgen.get(b.pageId),type:"changelogEntry",title:g.format("MMMM D, YYYY"),slug:a.apply({fullSlug:this.markdownToFullSlug.get(b.absoluteFilepath)?.split("/"),urlSlug:g.format("YYYY/M/D")}).get(),icon:void 0,hidden:void 0,date:b.date.toISOString(),pageId:b.pageId,noindex:this.markdownToNoIndex.get(b.absoluteFilepath),authed:void 0,viewers:void 0,orphaned:void 0,featureFlags:void 0}}),d=I7c(c,b=>b.date,"desc"),s=n!=null?Do.PageId(this.toRelativeFilepath(n)):void 0,o=this.idgen.get(s??"changelog"),l=this.groupByYear(o,d,a);return{id:o,type:"changelog",title:r,slug:a.get(),icon:t.icon,hidden:t.hidden,children:l,overviewPageId:s,noindex:u,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 u=_Zn.default.utc(a.date).year(),c=n.get(u)??[];c.push(a),n.set(u,c)}return I7c(Array.from(n.entries()).map(([a,u])=>{let c=i.append(a.toString()).get(),d=this.idgen.get(`${t}/year/${a}`);return{id:d,type:"changelogYear",title:a.toString(),year:a,slug:c,icon:void 0,hidden:void 0,children:this.groupByMonth(d,u,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 u=_Zn.default.utc(a.date).month()+1,c=n.get(u)??[];c.push(a),n.set(u,c)}return I7c(Array.from(n.entries()).map(([a,u])=>{let c=(0,_Zn.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:u,authed:void 0,viewers:void 0,orphaned:void 0,featureFlags:void 0}}),"month","desc")}toRelativeFilepath(t){if(t!=null)return UT(this.docsWorkspace.absoluteFilePath,t)}};function I7c(e,t,r="asc"){return e.concat().sort((i,n)=>{let a=typeof t=="function"?t(i):i[t],u=typeof t=="function"?t(n):n[t];return a<u?r==="asc"?-1:1:a>u?r==="asc"?1:-1:0})}function Qhu(e){if(e)return{environments:e.environments!=null&&e.environments.length>0?e.environments.map(t=>Do.V1.EnvironmentId(t)):void 0,button:e.button!=null&&e.button.href?{href:Do.V1.Url(e.button.href)}:void 0,"limit-websocket-messages-per-connection":e.limitWebsocketMessagesPerConnection!=null?e.limitWebsocketMessagesPerConnection:void 0}}function RVa({child:e,nodeIdToSubpackageId:t,convertApiDefinitionPackageId:r,mergeAndFilterChildren:i}){if(e.type==="apiPackage"){let n=Do.V1.SlugGenerator.init(e.slug),u=(t.get(e.id)??[]).flatMap(s=>r(s,n)),c=e.children.map(s=>RVa({child:s,nodeIdToSubpackageId:t,convertApiDefinitionPackageId:r,mergeAndFilterChildren:i})),d=i(c,u);return{...e,children:d,pointsTo:void 0}}return e}var yK_=ci(pK_(),1);var YC=function(e,t,r,i){function n(a){return a instanceof r?a:new r(function(u){u(a)})}return new(r||(r=Promise))(function(a,u){function c(o){try{s(i.next(o))}catch(l){u(l)}}function d(o){try{s(i.throw(o))}catch(l){u(l)}}function s(o){o.done?a(o.value):n(o.value).then(c,d)}s((i=i.apply(e,t||[])).next())})},XT=function(e,t){var r={label:0,sent:function(){if(a[0]&1)throw a[1];return a[1]},trys:[],ops:[]},i,n,a,u=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return u.next=c(0),u.throw=c(1),u.return=c(2),typeof Symbol=="function"&&(u[Symbol.iterator]=function(){return this}),u;function c(s){return function(o){return d([s,o])}}function d(s){if(i)throw new TypeError("Generator is already executing.");for(;u&&(u=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(o){s=[6,o],n=0}finally{i=a=0}if(s[0]&5)throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}},ose=function(e,t){var r=typeof Symbol=="function"&&e[Symbol.iterator];if(!r)return e;var i=r.call(e),n,a=[],u;try{for(;(t===void 0||t-- >0)&&!(n=i.next()).done;)a.push(n.value)}catch(c){u={error:c}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(u)throw u.error}}return a},r6e=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))},_K_=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.")},gsL=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 YC(this,void 0,void 0,function(){return XT(this,function(i){return t>r?[2,1]:t<r?[2,-1]:[2,0]})})},e.maxComparator=function(t,r){return YC(this,void 0,void 0,function(){return XT(this,function(i){return r>t?[2,1]:r<t?[2,-1]:[2,0]})})},e.minComparatorNumber=function(t,r){return YC(this,void 0,void 0,function(){return XT(this,function(i){return[2,t-r]})})},e.maxComparatorNumber=function(t,r){return YC(this,void 0,void 0,function(){return XT(this,function(i){return[2,r-t]})})},e.defaultIsEqual=function(t,r){return YC(this,void 0,void 0,function(){return XT(this,function(i){return[2,t===r]})})},e.print=function(t){function r(o){var l=e.getParentIndexOf(o);return Math.floor(Math.log2(l+1))}function i(o,l){for(var b="";l>0;--l)b+=o;return b}for(var n=0,a=[],u=r(t.length-1)+2,c=0;n<t.length;){var d=r(n)+1;n===0&&(d=0);var s=String(t.get(n));s.length>c&&(c=s.length),a[d]=a[d]||[],a[d].push(s),n+=1}return a.map(function(o,l){var b=Math.pow(2,u-l)-1;return i(" ",Math.floor(b/2)*c)+o.map(function(g){var O=(c-g.length)/2;return i(" ",Math.ceil(O))+g+i(" ",Math.floor(O))}).join(i(" ",b*c))}).join(`
|
|
2314
2314
|
`)},e.heapify=function(t,r){return YC(this,void 0,void 0,function(){var i;return XT(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 YC(this,void 0,void 0,function(){var n;return XT(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 YC(this,void 0,void 0,function(){var n;return XT(this,function(a){switch(a.label){case 0:return n=new e(i),n.heapArray=r6e([],ose(r),!1),[4,n.init()];case 1:return a.sent(),[2,n.top(t)]}})})},e.nsmallest=function(t,r,i){return YC(this,void 0,void 0,function(){var n;return XT(this,function(a){switch(a.label){case 0:return n=new e(i),n.heapArray=r6e([],ose(r),!1),[4,n.init()];case 1:return a.sent(),[2,n.bottom(t)]}})})},e.prototype.add=function(t){return YC(this,void 0,void 0,function(){return XT(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 YC(this,void 0,void 0,function(){var r,i,n;return XT(this,function(a){switch(a.label){case 0:r=this.length,(n=this.heapArray).push.apply(n,r6e([],ose(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 YC(this,arguments,void 0,function(t){return t===void 0&&(t=1),XT(this,function(r){return this.heapArray.length===0||t<=0?[2,[]]:this.heapArray.length===1?[2,[this.heapArray[0]]]:t>=this.heapArray.length?[2,r6e([],ose(this.heapArray),!1)]:[2,this._bottomN_push(~~t)]})})},e.prototype.check=function(){return YC(this,void 0,void 0,function(){var t,r,i,n,a,u,c,d,s;return XT(this,function(o){switch(o.label){case 0:t=0,o.label=1;case 1:if(!(t<this.heapArray.length))return[3,10];r=this.heapArray[t],i=this.getChildrenOf(t),o.label=2;case 2:o.trys.push([2,7,8,9]),n=(d=void 0,_K_(i)),a=n.next(),o.label=3;case 3:return a.done?[3,6]:(u=a.value,[4,this.compare(r,u)]);case 4:if(o.sent()>0)return[2,r];o.label=5;case 5:return a=n.next(),[3,3];case 6:return[3,9];case 7:return c=o.sent(),d={error:c},[3,9];case 8:try{a&&!a.done&&(s=n.return)&&s.call(n)}finally{if(d)throw d.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 YC(this,arguments,void 0,function(r,i){var n,a,u,c,d,s;return i===void 0&&(i=e.defaultIsEqual),XT(this,function(o){switch(o.label){case 0:o.trys.push([0,5,6,7]),n=_K_(this.heapArray),a=n.next(),o.label=1;case 1:return a.done?[3,4]:(u=a.value,[4,i(u,r)]);case 2:if(o.sent())return[2,!0];o.label=3;case 3:return a=n.next(),[3,1];case 4:return[3,7];case 5:return c=o.sent(),d={error:c},[3,7];case 6:try{a&&!a.done&&(s=n.return)&&s.call(n)}finally{if(d)throw d.error}return[7];case 7:return[2,!1]}})})},e.prototype.init=function(t){return YC(this,void 0,void 0,function(){var r;return XT(this,function(i){switch(i.label){case 0:t&&(this.heapArray=r6e([],ose(t),!1)),r=Math.floor(this.heapArray.length),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 YC(this,void 0,void 0,function(){var t;return XT(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 YC(this,void 0,void 0,function(){return XT(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 YC(this,void 0,void 0,function(){var r;return XT(this,function(i){switch(i.label){case 0:return[4,this.compare(this.heapArray[0],t)];case 1:return i.sent()<0?(r=ose([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 YC(this,arguments,void 0,function(r,i){var n,a,u,c=this;return i===void 0&&(i=e.defaultIsEqual),XT(this,function(d){switch(d.label){case 0:return this.heapArray.length?r!==void 0?[3,2]:[4,this.pop()]:[2,!1];case 1:return d.sent(),[2,!0];case 2:n=[0],d.label=3;case 3:return n.length?(a=n.shift(),[4,i(this.heapArray[a],r)]):[3,13];case 4:return d.sent()?a!==0?[3,6]:[4,this.pop()]:[3,11];case 5:return d.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 d.sent(),[4,this._sortNodeDown(a)];case 9:d.sent(),d.label=10;case 10:return[2,!0];case 11:u=e.getChildrenIndexOf(a).filter(function(s){return s<c.heapArray.length}),n.push.apply(n,r6e([],ose(u),!1)),d.label=12;case 12:return[3,3];case 13:return[2,!1]}})})},e.prototype.replace=function(t){return YC(this,void 0,void 0,function(){var r;return XT(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 YC(this,arguments,void 0,function(t){return t===void 0&&(t=1),XT(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,r6e([],ose(this.heapArray),!1)]:[2,this._topN_push(~~t)]})})},e.prototype.toArray=function(){return r6e([],ose(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 XT(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 YC(this,void 0,void 0,function(){var r,i,n,a,c,u,c;return XT(this,function(d){switch(d.label){case 0:return r=new e(this.compare),r.limit=t,r.heapArray=this.heapArray.slice(-t),[4,r.init()];case 1:for(d.sent(),i=this.heapArray.length-1-t,n=e.getParentIndexOf(i),a=[],c=i;c>n;--c)a.push(c);u=this.heapArray,d.label=2;case 2:return a.length?(c=a.shift(),[4,this.compare(u[c],r.peek())]):[3,6];case 3:return d.sent()>0?[4,r.replace(u[c])]:[3,5];case 4:d.sent(),c%2&&a.push(e.getParentIndexOf(c)),d.label=5;case 5:return[3,2];case 6:return[2,r.toArray()]}})})},e.prototype._moveNode=function(t,r){var i;i=ose([this.heapArray[r],this.heapArray[t]],2),this.heapArray[t]=i[0],this.heapArray[r]=i[1]},e.prototype._sortNodeDown=function(t){return YC(this,void 0,void 0,function(){var r,i,n,a,u,c;return XT(this,function(d){switch(d.label){case 0:r=this.heapArray.length,d.label=1;case 1:return i=2*t+1,n=i+1,a=t,u=i<r,u?[4,this.compare(this.heapArray[i],this.heapArray[a])]:[3,3];case 2:u=d.sent()<0,d.label=3;case 3:return u&&(a=i),c=n<r,c?[4,this.compare(this.heapArray[n],this.heapArray[a])]:[3,5];case 4:c=d.sent()<0,d.label=5;case 5:if(c&&(a=n),a===t)return[3,7];this._moveNode(t,a),t=a,d.label=6;case 6:return[3,1];case 7:return[2]}})})},e.prototype._sortNodeUp=function(t){return YC(this,void 0,void 0,function(){var r;return XT(this,function(i){switch(i.label){case 0:return t>0?(r=e.getParentIndexOf(t),[4,this.compare(this.heapArray[t],this.heapArray[r])]):[3,2];case 1:if(i.sent()<0)this._moveNode(t,r),t=r;else return[3,2];return[3,0];case 2:return[2]}})})},e.prototype._topN_push=function(t){return YC(this,void 0,void 0,function(){var r,i,n,a;return XT(this,function(u){switch(u.label){case 0:r=new e(this._invertedCompare),r.limit=t,i=[0],n=this.heapArray,u.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 u.sent(),i.push.apply(i,r6e([],ose(e.getChildrenIndexOf(a)),!1)),[3,6];case 3:return[4,this.compare(n[a],r.peek())];case 4:return u.sent()<0?[4,r.replace(n[a])]:[3,6];case 5:u.sent(),i.push.apply(i,r6e([],ose(e.getChildrenIndexOf(a)),!1)),u.label=6;case 6:return[3,1];case 7:return[2,r.toArray()]}})})},e.prototype._topN_fill=function(t){return YC(this,void 0,void 0,function(){var r,i,n,a,u,u;return XT(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=[],u=n;u<t;++u)a.push.apply(a,r6e([],ose(e.getChildrenIndexOf(u).filter(function(d){return d<r.length})),!1));(t-1)%2&&a.push(t),c.label=2;case 2:return a.length?(u=a.shift(),u<r.length?[4,this.compare(r[u],i.peek())]:[3,5]):[3,6];case 3:return c.sent()<0?[4,i.replace(r[u])]:[3,5];case 4:c.sent(),a.push.apply(a,r6e([],ose(e.getChildrenIndexOf(u)),!1)),c.label=5;case 5:return[3,2];case 6:return[2,i.toArray()]}})})},e.prototype._topN_heap=function(t){return YC(this,void 0,void 0,function(){var r,i,n,a,u;return XT(this,function(c){switch(c.label){case 0:r=this.clone(),i=[],n=0,c.label=1;case 1:return n<t?(u=(a=i).push,[4,r.pop()]):[3,4];case 2:u.apply(a,[c.sent()]),c.label=3;case 3:return++n,[3,1];case 4:return[2,i]}})})},e.prototype._topIdxOf=function(t){return YC(this,void 0,void 0,function(){var r,i,n,a;return XT(this,function(u){switch(u.label){case 0:if(!t.length)return[2,-1];r=0,i=t[r],n=1,u.label=1;case 1:return n<t.length?[4,this.compare(t[n],i)]:[3,4];case 2:a=u.sent(),a<0&&(r=n,i=t[n]),u.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 YC(this,void 0,void 0,function(){var i;return XT(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}(),$bM=function(e,t){var r={label:0,sent:function(){if(a[0]&1)throw a[1];return a[1]},trys:[],ops:[]},i,n,a,u=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return u.next=c(0),u.throw=c(1),u.return=c(2),typeof Symbol=="function"&&(u[Symbol.iterator]=function(){return this}),u;function c(s){return function(o){return d([s,o])}}function d(s){if(i)throw new TypeError("Generator is already executing.");for(;u&&(u=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(o){s=[6,o],n=0}finally{i=a=0}if(s[0]&5)throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}},V$=function(e,t){var r=typeof Symbol=="function"&&e[Symbol.iterator];if(!r)return e;var i=r.call(e),n,a=[],u;try{for(;(t===void 0||t-- >0)&&!(n=i.next()).done;)a.push(n.value)}catch(c){u={error:c}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(u)throw u.error}}return a},Zee=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 hK_=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){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 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(o){var l=e.getParentIndexOf(o);return Math.floor(Math.log2(l+1))}function i(o,l){for(var b="";l>0;--l)b+=o;return b}for(var n=0,a=[],u=r(t.length-1)+2,c=0;n<t.length;){var d=r(n)+1;n===0&&(d=0);var s=String(t.get(n));s.length>c&&(c=s.length),a[d]=a[d]||[],a[d].push(s),n+=1}return a.map(function(o,l){var b=Math.pow(2,u-l)-1;return i(" ",Math.floor(b/2)*c)+o.map(function(g){var O=(c-g.length)/2;return i(" ",Math.ceil(O))+g+i(" ",Math.floor(O))}).join(i(" ",b*c))}).join(`
|
|
2315
2315
|
`)},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=Zee([],V$(r),!1),n.init(),n.top(t)},e.nsmallest=function(t,r,i){var n=new e(i);return n.heapArray=Zee([],V$(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,Zee([],V$(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?Zee([],V$(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=Zee([],V$(t),!1));for(var r=Math.floor(this.heapArray.length);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,Zee([],V$(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 u=this.heapArray[a];r(u,t)?(n.push(a),i.push.apply(i,Zee([],V$(e.getChildrenIndexOf(a)),!1))):this.compare(u,t)<=0&&i.push.apply(i,Zee([],V$(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=V$([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 u=e.getChildrenIndexOf(a).filter(function(c){return c<i.heapArray.length});n.push.apply(n,Zee([],V$(u),!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?Zee([],V$(this.heapArray),!1):this._topN_push(~~t)},e.prototype.toArray=function(){return Zee([],V$(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 $bM(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=[],u=i;u>n;--u)a.push(u);for(var c=this.heapArray;a.length;){var u=a.shift();this.compare(c[u],r.peek())>0&&(r.replace(c[u]),u%2&&a.push(e.getParentIndexOf(u)))}return r.toArray()},e.prototype._moveNode=function(t,r){var i;i=V$([this.heapArray[r],this.heapArray[t]],2),this.heapArray[t]=i[0],this.heapArray[r]=i[1]},e.prototype._sortNodeDown=function(t){for(var r=this.heapArray.length;;){var i=2*t+1,n=i+1,a=t;if(i<r&&this.compare(this.heapArray[i],this.heapArray[a])<0&&(a=i),n<r&&this.compare(this.heapArray[n],this.heapArray[a])<0&&(a=n),a===t)break;this._moveNode(t,a),t=a}},e.prototype._sortNodeUp=function(t){for(;t>0;){var r=e.getParentIndexOf(t);if(this.compare(this.heapArray[t],this.heapArray[r])<0)this._moveNode(t,r),t=r;else break}},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,Zee([],V$(e.getChildrenIndexOf(a)),!1))):this.compare(n[a],r.peek())<0&&(r.replace(n[a]),i.push.apply(i,Zee([],V$(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=[],u=n;u<t;++u)a.push.apply(a,Zee([],V$(e.getChildrenIndexOf(u).filter(function(c){return c<r.length})),!1));for((t-1)%2&&a.push(t);a.length;){var u=a.shift();u<r.length&&this.compare(r[u],i.peek())<0&&(i.replace(r[u]),a.push.apply(a,Zee([],V$(e.getChildrenIndexOf(u)),!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 vK_(e,t,r,i,n){if(r<=0)return[];let a=i??(c=>c),u=new hK_(GbM);for(let c of t){let d=yK_.default.get(a(e),a(c));n!=null&&d>n||(u.push({neighbor:c,distance:d}),u.size()>r&&u.pop())}return QbM(u).reverse().map(c=>c.neighbor)}function GbM(e,t){return e.distance!==t.distance?t.distance-e.distance:t.neighbor.localeCompare(e.neighbor)}function QbM(e){let t=[];for(;e.size()>0;){let r=e.pop();r&&t.push(r)}return t}var JbM=3,KbM=5;function P7i(e,t){let r=vK_(e,t,JbM,YbM,KbM),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} [
|
|
2316
2316
|
${i.map(a=>` ${a}`).join(`,
|