fern-api 3.23.1 → 3.23.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cli.cjs +3 -3
- package/package.json +1 -1
package/cli.cjs
CHANGED
|
@@ -1147,7 +1147,7 @@ ${yUp.default.cursorShow}`)}releaseCursor(){this.extraLinesUnderPrompt>0&&o9s(th
|
|
|
1147
1147
|
`+N7i.default.red(">> ")+t),this.screen.render(r,i)}getMaskedValue(t){return this.status==="answered"?this.opt.mask?N7i.default.cyan(wUp(t,this.opt.mask)):N7i.default.italic(N7i.default.dim("[hidden]")):this.opt.mask?wUp(t,this.opt.mask):N7i.default.italic(N7i.default.dim("[input is hidden] "))}getSpinningValue(t){return this.getMaskedValue(t)}filterInput(t){return t||(this.opt.default==null?"":this.opt.default)}onEnd(t){this.status="answered",this.answer=t.value,this.render(),this.screen.done(),this.done(t.value)}onError(t){this.render(t.isValid)}onKeypress(){this.opt.default&&=void 0,this.render()}};var t0o=ue(y1(),1);var w4p=ue(L9s(),1),kmo=require("child_process"),aTn=require("fs"),Zmo=ue(require("path"),1),E4p=ue(require("os"),1),S4p=require("crypto"),wGs=ue(P4p(),1);var $mo=class extends Error{originalError;constructor(t){super(`Failed to create temporary file. ${t.message}`),this.originalError=t}};var Jga=class extends Error{originalError;constructor(t){super(`Failed to launch editor. ${t.message}`),this.originalError=t}};var Ymo=class extends Error{originalError;constructor(t){super(`Failed to read temporary file. ${t.message}`),this.originalError=t}};var Xmo=class extends Error{originalError;constructor(t){super(`Failed to remove temporary file. ${t.message}`),this.originalError=t}};function e0o(e="",t,r){let i=new EGs(e,r);i.runAsync((n,a)=>{if(n)setImmediate(t,n,void 0);else try{i.cleanup(),setImmediate(t,void 0,a)}catch(o){setImmediate(t,o,void 0)}})}function j4p(e){return e?e.replace(/[^a-zA-Z0-9_.-]/g,"_"):""}function XvS(e){let t=[],r="";for(let i=0;i<e.length;i++){let n=e.charAt(i);i>0&&n===" "&&e[i-1]!=="\\"&&r.length>0?(t.push(r),r=""):r=`${r}${n}`}return r.length>0&&t.push(r),t}var EGs=class{text="";tempFile;editor;lastExitStatus=0;fileOptions={};get temp_file(){return console.log("DEPRECATED: temp_file. Use tempFile moving forward."),this.tempFile}get last_exit_status(){return console.log("DEPRECATED: last_exit_status. Use lastExitStatus moving forward."),this.lastExitStatus}constructor(t="",r){this.text=t,r&&(this.fileOptions=r),this.determineEditor(),this.createTemporaryFile()}run(){return this.launchEditor(),this.readTemporaryFile(),this.text}runAsync(t){try{this.launchEditorAsync(()=>{try{this.readTemporaryFile(),setImmediate(t,void 0,this.text)}catch(r){setImmediate(t,r,void 0)}})}catch(r){setImmediate(t,r,void 0)}}cleanup(){this.removeTemporaryFile()}determineEditor(){let t=process.env.VISUAL?process.env.VISUAL:process.env.EDITOR?process.env.EDITOR:process.platform.startsWith("win")?"notepad":"vim",r=XvS(t).map(n=>n.replace("\\ "," ")),i=r.shift();this.editor={args:r,bin:i}}createTemporaryFile(){try{let t=this.fileOptions.dir??E4p.default.tmpdir(),r=(0,S4p.randomUUID)(),i=j4p(this.fileOptions.prefix),n=j4p(this.fileOptions.postfix),a=`${i}${r}${n}`,o=Zmo.default.resolve(t,a),c=Zmo.default.resolve(t)+Zmo.default.sep;if(!o.startsWith(c))throw new Error("Resolved temporary file escaped the base directory");this.tempFile=o;let f={encoding:"utf8",flag:"wx"};Object.prototype.hasOwnProperty.call(this.fileOptions,"mode")&&(f.mode=this.fileOptions.mode),(0,aTn.writeFileSync)(this.tempFile,this.text,f)}catch(t){throw new $mo(t)}}readTemporaryFile(){try{let t=(0,aTn.readFileSync)(this.tempFile);if(t.length===0)this.text="";else{let r=(0,w4p.detect)(t)??"utf8";wGs.default.encodingExists(r)||(r="utf8"),this.text=wGs.default.decode(t,r)}}catch(t){throw new Ymo(t)}}removeTemporaryFile(){try{(0,aTn.unlinkSync)(this.tempFile)}catch(t){throw new Xmo(t)}}launchEditor(){try{let t=(0,kmo.spawnSync)(this.editor.bin,this.editor.args.concat([this.tempFile]),{stdio:"inherit"});this.lastExitStatus=t.status??0}catch(t){throw new Jga(t)}}launchEditorAsync(t){try{(0,kmo.spawn)(this.editor.bin,this.editor.args.concat([this.tempFile]),{stdio:"inherit"}).on("exit",i=>{this.lastExitStatus=i,setImmediate(t)})}catch(r){throw new Jga(r)}}};var M4p=ue(Z_e(),1);var $ga=class extends b1{_run(t){this.done=t,this.editorResult=new M4p.Subject;let r=CQ(this.rl);this.lineSubscription=r.line.subscribe(this.startExternalEditor.bind(this));let i=this.opt.waitUserInput===void 0?!0:this.opt.waitUserInput,n=this.handleSubmitEvents(this.editorResult);return n.success.forEach(this.onEnd.bind(this)),n.error.forEach(this.onError.bind(this)),this.currentText=this.opt.default,this.opt.default=null,i?this.render():this.startExternalEditor(),this}render(t){let r="",i=this.getQuestion();i+=this.status==="answered"?t0o.default.dim("Received"):t0o.default.dim("Press <enter> to launch your preferred editor."),t&&(r=t0o.default.red(">> ")+t),this.screen.render(i,r)}startExternalEditor(){this.rl.pause(),e0o(this.currentText,this.endExternalEditor.bind(this),{postfix:this.opt.postfix??".txt"})}endExternalEditor(t,r){this.rl.resume(),t?this.editorResult.error(t):this.editorResult.next(r)}onEnd(t){this.editorResult.unsubscribe(),this.lineSubscription.unsubscribe(),this.answer=t.value,this.status="answered",this.render(),this.screen.done(),this.done(this.answer)}onError(t){this.render(t.isValid)}};var q4p=require("stream");var I4p=ue(require("readline"),1),C4p=ue(B4p(),1),L7i=class{constructor(t){this.rl||=I4p.default.createInterface(kvS(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 kvS(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 C4p.default;return r.pipe(e.output||process.stdout),{terminal:!0,...e,input:t,output:r}}var Yga=class extends L7i{constructor(t={}){super(t),this.log=new q4p.Writable({write:(r,i,n)=>{this.writeLog(r),n()}}),this.bottomBar=t.bottomBar||"",this.render()}render(){return this.write(this.bottomBar),this}clean(){return qga(this.rl,this.bottomBar.split(`
|
|
1148
1148
|
`).length),this}updateBottomBar(t){return qga(this.rl,1),this.rl.output.unmute(),this.clean(),this.bottomBar=t,this.render(),this.rl.output.mute(),this}writeLog(t){return this.rl.output.unmute(),this.clean(),this.rl.output.write(this.enforceLF(t.toString())),this.render(),this.rl.output.mute(),this}enforceLF(t){return/[\n\r]$/.test(t)?t:t+`
|
|
1149
1149
|
`}write(t){let r=t.split(/\n/);this.height=r.length,this.rl.setPrompt(r.at(-1)),this.rl.output.rows===0&&this.rl.output.columns===0&&Pmo(this.rl,t.length+this.rl.line.length),this.rl.output.write(t)}};var pO=ue(Z_e(),1),z4p=ue(ega(),1);var r0o=ue(Z_e(),1),T4p=ue(ega(),1),i0o=function(e,t,r){return typeof e[t]!="function"?(0,r0o.of)(e):(0,r0o.from)((0,T4p.default)(e[t])(r).then(i=>(e[t]=i,e)))};var R4p={set:(e,t="",r)=>{let i=e;t.split(".").forEach((n,a,o)=>{n==="__proto__"||n==="constructor"||(a===o.length-1?i[n]=r:(!(n in i)||typeof i[n]!="object")&&(i[n]={}),i=i[n])})},get:(e,t="",r)=>{let i=a=>String.prototype.split.call(t,a).filter(Boolean).reduce((o,c)=>o!=null?o[c]:o,e),n=i(/[,[\]]+?/)||i(/[,.[\]]+?/);return n===void 0||n===e?r:n}},oTn=class extends L7i{constructor(t,r){super(r),this.prompts=t}run(t,r){this.answers=typeof r=="object"?{...r}:{};let i;return Array.isArray(t)?i=(0,pO.from)(t):(0,pO.isObservable)(t)?i=t:Object.values(t).every(n=>typeof n=="object"&&!Array.isArray(n)&&n!=null)?i=(0,pO.from)(Object.entries(t).map(([n,a])=>({name:n,...a}))):i=(0,pO.from)([t]),this.process=i.pipe((0,pO.concatMap)(this.processQuestion.bind(this)),(0,pO.publish)()),this.process.connect(),this.process.pipe((0,pO.reduce)((n,a)=>(R4p.set(n,a.name,a.answer),n),this.answers)).toPromise(Promise).then(this.onCompletion.bind(this),this.onError.bind(this))}onCompletion(){return this.close(),this.answers}onError(t){return this.close(),Promise.reject(t)}processQuestion(t){return t={...t},(0,pO.defer)(()=>(0,pO.of)(t).pipe((0,pO.concatMap)(this.setDefaultType.bind(this)),(0,pO.concatMap)(this.filterIfRunnable.bind(this)),(0,pO.concatMap)(()=>i0o(t,"message",this.answers)),(0,pO.concatMap)(()=>i0o(t,"default",this.answers)),(0,pO.concatMap)(()=>i0o(t,"choices",this.answers)),(0,pO.concatMap)(this.fetchAnswer.bind(this))))}fetchAnswer(t){let r=this.prompts[t.type];return this.activePrompt=new r(t,this.rl,this.answers),(0,pO.defer)(()=>(0,pO.from)(this.activePrompt.run().then(i=>({name:t.name,answer:i}))))}setDefaultType(t){return this.prompts[t.type]||(t.type="input"),(0,pO.defer)(()=>(0,pO.of)(t))}filterIfRunnable(t){if(t.askAnswered!==!0&&R4p.get(this.answers,t.name)!==void 0)return pO.EMPTY;if(t.when===!1)return pO.EMPTY;if(typeof t.when!="function")return(0,pO.of)(t);let{answers:r}=this;return(0,pO.defer)(()=>(0,pO.from)((0,z4p.default)(t.when)(r).then(i=>{if(i)return t})).pipe((0,pO.filter)(i=>i!=null)))}};function N4p(e){let t=function(r,i){let n;try{n=new oTn(t.prompts,e)}catch(o){return Promise.reject(o)}let a=n.run(r,i);return a.ui=n,a};return t.prompts={},t.registerPrompt=function(r,i){return t.prompts[r]=i,this},t.restoreDefaultPrompts=function(){this.registerPrompt("list",Rga),this.registerPrompt("input",z7i),this.registerPrompt("number",zga),this.registerPrompt("confirm",Nga),this.registerPrompt("rawlist",Fga),this.registerPrompt("expand",Qga),this.registerPrompt("checkbox",Uga),this.registerPrompt("password",Lga),this.registerPrompt("editor",$ga)},t.restoreDefaultPrompts(),t}var MGs=N4p();function tgS(e,t){MGs.registerPrompt(e,t)}function rgS(){MGs.restoreDefaultPrompts()}var igS={prompt:MGs,ui:{BottomBar:Yga,Prompt:oTn},createPromptModule:N4p,registerPrompt:tgS,restoreDefaultPrompts:rgS,Separator:jH},n0o=igS;var gTn=require("path"),y3p=require("fs"),b3p=require("readline"),LLp="posthog-node";function BAS(e,{organization:t,projectId:r,prefix:i,severityAllowList:n=["error"]}={}){return a=>{if(!(n==="*"||n.includes(a.level)))return a;a.tags||(a.tags={});let c=a.tags[j0o.POSTHOG_ID_TAG];if(c===void 0)return a;let f=e.options.host??"https://us.i.posthog.com",s=new URL(`/project/${e.apiKey}/person/${c}`,f).toString();a.tags["PostHog Person URL"]=s;let u=a.exception?.values||[],l=u.map(_=>({..._,stacktrace:_.stacktrace?{..._.stacktrace,type:"raw",frames:(_.stacktrace.frames||[]).map(h=>({...h,platform:"node:javascript"}))}:void 0})),p={$exception_message:u[0]?.value||a.message,$exception_type:u[0]?.type,$exception_personURL:s,$exception_level:a.level,$exception_list:l,$sentry_event_id:a.event_id,$sentry_exception:a.exception,$sentry_exception_message:u[0]?.value||a.message,$sentry_exception_type:u[0]?.type,$sentry_tags:a.tags};return t&&r&&(p.$sentry_url=(i||"https://sentry.io/organizations/")+t+"/issues/?project="+r+"&query="+a.event_id),e.capture({event:"$exception",distinctId:c,properties:p}),a}}var j0o=class{constructor(t,r,i,n){this.name=LLp,this.name=LLp,this.setupOnce=function(a,o){let c=o()?.getClient()?.getDsn()?.projectId;a(BAS(t,{organization:r,projectId:c,prefix:i,severityAllowList:n}))}}};j0o.POSTHOG_ID_TAG="posthog_distinct_id";var g0o="0123456789abcdef",w0o=class e{constructor(t){this.bytes=t}static ofInner(t){if(t.length!==16)throw new TypeError("not 128-bit length");return new e(t)}static fromFieldsV7(t,r,i,n){if(!Number.isInteger(t)||!Number.isInteger(r)||!Number.isInteger(i)||!Number.isInteger(n)||t<0||r<0||i<0||n<0||t>0xffffffffffff||r>4095||i>1073741823||n>4294967295)throw new RangeError("invalid field value");let a=new Uint8Array(16);return a[0]=t/2**40,a[1]=t/2**32,a[2]=t/2**24,a[3]=t/2**16,a[4]=t/2**8,a[5]=t,a[6]=112|r>>>8,a[7]=r,a[8]=128|i>>>24,a[9]=i>>>16,a[10]=i>>>8,a[11]=i,a[12]=n>>>24,a[13]=n>>>16,a[14]=n>>>8,a[15]=n,new e(a)}static parse(t){let r;switch(t.length){case 32:r=/^[0-9a-f]{32}$/i.exec(t)?.[0];break;case 36:r=/^([0-9a-f]{8})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{12})$/i.exec(t)?.slice(1,6).join("");break;case 38:r=/^\{([0-9a-f]{8})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{12})\}$/i.exec(t)?.slice(1,6).join("");break;case 45:r=/^urn:uuid:([0-9a-f]{8})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{12})$/i.exec(t)?.slice(1,6).join("");break}if(r){let i=new Uint8Array(16);for(let n=0;n<16;n+=4){let a=parseInt(r.substring(2*n,2*n+8),16);i[n+0]=a>>>24,i[n+1]=a>>>16,i[n+2]=a>>>8,i[n+3]=a}return new e(i)}else throw new SyntaxError("could not parse UUID string")}toString(){let t="";for(let r=0;r<this.bytes.length;r++)t+=g0o.charAt(this.bytes[r]>>>4),t+=g0o.charAt(this.bytes[r]&15),(r===3||r===5||r===7||r===9)&&(t+="-");return t}toHex(){let t="";for(let r=0;r<this.bytes.length;r++)t+=g0o.charAt(this.bytes[r]>>>4),t+=g0o.charAt(this.bytes[r]&15);return t}toJSON(){return this.toString()}getVariant(){let t=this.bytes[8]>>>4;if(t<0)throw new Error("unreachable");if(t<=7)return this.bytes.every(r=>r===0)?"NIL":"VAR_0";if(t<=11)return"VAR_10";if(t<=13)return"VAR_110";if(t<=15)return this.bytes.every(r=>r===255)?"MAX":"VAR_RESERVED";throw new Error("unreachable")}getVersion(){return this.getVariant()==="VAR_10"?this.bytes[6]>>>4:void 0}clone(){return new e(this.bytes.slice(0))}equals(t){return this.compareTo(t)===0}compareTo(t){for(let r=0;r<16;r++){let i=this.bytes[r]-t.bytes[r];if(i!==0)return Math.sign(i)}return 0}},d7s=class{constructor(t){this.timestamp=0,this.counter=0,this.random=t??IAS()}generate(){return this.generateOrResetCore(Date.now(),1e4)}generateOrAbort(){return this.generateOrAbortCore(Date.now(),1e4)}generateOrResetCore(t,r){let i=this.generateOrAbortCore(t,r);return i===void 0&&(this.timestamp=0,i=this.generateOrAbortCore(t,r)),i}generateOrAbortCore(t,r){if(!Number.isInteger(t)||t<1||t>0xffffffffffff)throw new RangeError("`unixTsMs` must be a 48-bit positive integer");if(r<0||r>0xffffffffffff)throw new RangeError("`rollbackAllowance` out of reasonable range");if(t>this.timestamp)this.timestamp=t,this.resetCounter();else if(t+r>=this.timestamp)this.counter++,this.counter>4398046511103&&(this.timestamp++,this.resetCounter());else return;return w0o.fromFieldsV7(this.timestamp,Math.trunc(this.counter/2**30),this.counter&2**30-1,this.random.nextUint32())}resetCounter(){this.counter=this.random.nextUint32()*1024+(this.random.nextUint32()&1023)}generateV4(){let t=new Uint8Array(Uint32Array.of(this.random.nextUint32(),this.random.nextUint32(),this.random.nextUint32(),this.random.nextUint32()).buffer);return t[6]=64|t[6]>>>4,t[8]=128|t[8]>>>2,w0o.ofInner(t)}},IAS=()=>({nextUint32:()=>Math.trunc(Math.random()*65536)*65536+Math.trunc(Math.random()*65536)}),VLp,p7s=()=>CAS().toString(),CAS=()=>(VLp||(VLp=new d7s)).generate();function qAS(e,t){let r=!1;return Object.assign(i=>{let a=global.process.listeners("uncaughtException").filter(o=>o.name!=="domainUncaughtExceptionClear"&&o._posthogErrorHandler!==!0).length===0;e(i,{mechanism:{type:"onuncaughtexception",handled:!1}}),!r&&a&&(r=!0,t())},{_posthogErrorHandler:!0})}function TAS(e,t){global.process.on("uncaughtException",qAS(e,t))}function RAS(e){global.process.on("unhandledRejection",t=>{e(t,{mechanism:{type:"onunhandledrejection",handled:!1}})})}var O0o,WLp,A0o;function zAS(e){let t=globalThis._posthogChunkIds;if(!t)return console.error("No chunk id map found"),{};let r=Object.keys(t);return A0o&&r.length===WLp||(WLp=r.length,A0o=r.reduce((i,n)=>{O0o||(O0o={});let a=O0o[n];if(a)i[a[0]]=a[1];else{let o=e(n);for(let c=o.length-1;c>=0;c--){let s=o[c]?.filename,u=t[n];if(s&&u){i[s]=u,O0o[n]=[s,u];break}}}return i},{})),A0o}function NAS(e){return typeof Event<"u"&&v3p(e,Event)}function FAS(e){return g3p(e,"Object")}function A7s(e){switch(Object.prototype.toString.call(e)){case"[object Error]":case"[object Exception]":case"[object DOMException]":case"[object WebAssembly.Exception]":return!0;default:return v3p(e,Error)}}function v3p(e,t){try{return e instanceof t}catch{return!1}}function QAS(e){return g3p(e,"ErrorEvent")}function g3p(e,t){return Object.prototype.toString.call(e)===`[object ${t}]`}async function UAS(e,t,r,i){let a=i&&i.mechanism||{handled:!0,type:"generic"},o=O3p(a,r,i);return{$exception_list:await Promise.all(o.map(async s=>{let u=await KAS(e,t,s);return u.value=u.value||"",u.type=u.type||"Error",u.mechanism=a,u}))}}function O3p(e,t,r){let i=LAS(e,t,r);return i.cause?[i,...O3p(e,i.cause,r)]:[i]}function LAS(e,t,r){if(A7s(t))return t;if(e.synthetic=!0,FAS(t)){let n=VAS(t);if(n)return n;let a=WAS(t),o=r?.syntheticException||new Error(a);return o.message=a,o}let i=r?.syntheticException||new Error(t);return i.message=`${t}`,i}function VAS(e){for(let t in e)if(Object.prototype.hasOwnProperty.call(e,t)){let r=e[t];if(A7s(r))return r}}function WAS(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=GAS(e);if(QAS(e))return`Event \`ErrorEvent\` captured as exception with message \`${e.message}\``;let r=xAS(e);return`${r&&r!=="Object"?`'${r}'`:"Object"} captured as exception with keys: ${t}`}function xAS(e){try{let t=Object.getPrototypeOf(e);return t?t.constructor.name:void 0}catch{}}function GAS(e,t=40){let r=Object.keys(HAS(e));r.sort();let i=r[0];if(!i)return"[object has no keys]";if(i.length>=t)return xLp(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:xLp(a,t)}return""}function xLp(e,t=0){return typeof e!="string"||t===0||e.length<=t?e:`${e.slice(0,t)}...`}function HAS(e){return A7s(e)?{message:e.message,name:e.name,stack:e.stack,...GLp(e)}:NAS(e)?{type:e.type,target:HLp(e.target),currentTarget:HLp(e.currentTarget),...GLp(e)}:e}function GLp(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 HLp(e){try{return Object.prototype.toString.call(e)}catch{return"<unknown>"}}async function KAS(e,t,r){let i={type:r.name||r.constructor.name,value:r.message},n=JAS(e,r);for(let a of t)n=await a(n);return n.length&&(i.stacktrace={frames:n,type:"raw"}),i}function JAS(e,t){return $AS(e(t.stack||"",1),e)}function $AS(e,t){let r=zAS(t);return e.forEach(i=>{i.filename&&(i.chunk_id=r[i.filename])}),e}var YAS=2e3,yTn=class e{static async captureException(t,r,i,n,a){let o={...a};n||(o.$process_person_profile=!1);let c=await UAS(this.stackParser,this.frameModifiers,r,i);t.capture({event:"$exception",distinctId:n||p7s(),properties:{...c,...o}})}constructor(t,r){this.client=t,this._exceptionAutocaptureEnabled=r.enableExceptionAutocapture||!1,this.startAutocaptureIfEnabled()}startAutocaptureIfEnabled(){this.isEnabled()&&(TAS(this.onException.bind(this),this.onFatalError.bind(this)),RAS(this.onException.bind(this)))}onException(t,r){e.captureException(this.client,t,r)}async onFatalError(){await this.client.shutdown(YAS)}isEnabled(){return!this.client.isDisabled&&this._exceptionAutocaptureEnabled}};function XAS(e=process.argv[1]?(0,gTn.dirname)(process.argv[1]):process.cwd(),t=gTn.sep==="\\"){let r=t?KLp(e):e;return i=>{if(!i)return;let n=t?KLp(i):i,{dir:a,base:o,ext:c}=gTn.posix.parse(n);(c===".js"||c===".mjs"||c===".cjs")&&(o=o.slice(0,c.length*-1));let f=decodeURIComponent(o);a||(a=".");let s=a.lastIndexOf("/node_modules");if(s>-1)return`${a.slice(s+14).replace(/\//g,".")}:${f}`;if(a.startsWith(r)){let u=a.slice(r.length+1).replace(/\//g,".");return u?`${u}:${f}`:f}return f}}function KLp(e){return e.replace(/^[A-Z]:/,"").replace(/\\/g,"/")}var E0o=class{constructor(t){this._maxSize=t,this._cache=new Map}get(t){let r=this._cache.get(t);if(r!==void 0)return this._cache.delete(t),this._cache.set(t,r),r}set(t,r){this._cache.set(t,r)}reduce(){for(;this._cache.size>=this._maxSize;){let t=this._cache.keys().next().value;t&&this._cache.delete(t)}}},P0o=new E0o(25),A3p=new E0o(20),m7s=7,ZAS=1e3,kAS=1e4;async function emS(e){let t={};for(let n=e.length-1;n>=0;n--){let a=e[n],o=a?.filename;if(!a||typeof o!="string"||typeof a.lineno!="number"||nmS(o)||amS(a))continue;t[o]||(t[o]=[]),t[o].push(a.lineno)}let r=Object.keys(t);if(r.length==0)return e;let i=[];for(let n of r){if(A3p.get(n))continue;let a=t[n];if(!a)continue;a.sort((f,s)=>f-s);let o=umS(a);if(o.every(f=>omS(n,f)))continue;let c=smS(P0o,n,{});i.push(tmS(n,o,c))}return await Promise.all(i).catch(()=>{}),e&&e.length>0&&rmS(e,P0o),P0o.reduce(),e}function tmS(e,t,r){return new Promise(i=>{let n=(0,y3p.createReadStream)(e),a=(0,b3p.createInterface)({input:n});function o(){n.destroy(),i()}let c=0,f=0,s=t[f];if(s===void 0){o();return}let u=s[0],l=s[1];function p(){A3p.set(e,1),a.close(),a.removeAllListeners(),o()}n.on("error",p),a.on("error",p),a.on("close",o),a.on("line",_=>{if(c++,!(c<u)&&(r[c]=cmS(_,0),c>=l)){if(f===t.length-1){a.close(),a.removeAllListeners();return}f++;let h=t[f];if(h===void 0){a.close(),a.removeAllListeners();return}u=h[0],l=h[1]}})})}function rmS(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;imS(r.lineno,r,i)}}function imS(e,t,r){if(t.lineno===void 0||r===void 0)return;t.pre_context=[];for(let n=m3p(e);n<e;n++){let a=r[n];if(a===void 0){JLp(t);return}t.pre_context.push(a)}if(r[e]===void 0){JLp(t);return}t.context_line=r[e];let i=P3p(e);t.post_context=[];for(let n=e+1;n<=i;n++){let a=r[n];if(a===void 0)break;t.post_context.push(a)}}function JLp(e){delete e.pre_context,delete e.context_line,delete e.post_context}function nmS(e){return e.startsWith("node:")||e.endsWith(".min.js")||e.endsWith(".min.cjs")||e.endsWith(".min.mjs")||e.startsWith("data:")}function amS(e){return e.lineno!==void 0&&e.lineno>kAS||e.colno!==void 0&&e.colno>ZAS}function omS(e,t){let r=P0o.get(e);if(r===void 0)return!1;for(let i=t[0];i<=t[1];i++)if(r[i]===void 0)return!1;return!0}function umS(e){if(!e.length)return[];let t=0,r=e[0];if(typeof r!="number")return[];let i=$Lp(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+m7s:(n.push(i),i=$Lp(a)),t++}return n}function $Lp(e){return[m3p(e),P3p(e)]}function m3p(e){return Math.max(1,e-m7s)}function P3p(e){return e+m7s}function smS(e,t,r){let i=e.get(t);return i===void 0?(e.set(t,r),r):i}function cmS(e,t){let r=e,i=r.length;if(i<=150)return r;t>i&&(t=i);let n=Math.max(t-60,0);n<5&&(n=0);let a=Math.min(n+140,i);return a>i-5&&(a=i),a===i&&(n=Math.max(a-140,0)),r=r.slice(n,a),n>0&&(r=`...${r}`),a<i&&(r+="..."),r}var lmS="4.18.0",DH;(function(e){e.AnonymousId="anonymous_id",e.DistinctId="distinct_id",e.Props="props",e.FeatureFlagDetails="feature_flag_details",e.FeatureFlags="feature_flags",e.FeatureFlagPayloads="feature_flag_payloads",e.BootstrapFeatureFlagDetails="bootstrap_feature_flag_details",e.BootstrapFeatureFlags="bootstrap_feature_flags",e.BootstrapFeatureFlagPayloads="bootstrap_feature_flag_payloads",e.OverrideFeatureFlags="override_feature_flags",e.Queue="queue",e.OptedOut="opted_out",e.SessionId="session_id",e.SessionStartTimestamp="session_start_timestamp",e.SessionLastTimestamp="session_timestamp",e.PersonProperties="person_properties",e.GroupProperties="group_properties",e.InstalledAppBuild="installed_app_build",e.InstalledAppVersion="installed_app_version",e.SessionReplay="session_replay",e.DecideEndpointWasHit="decide_endpoint_was_hit",e.SurveyLastSeenDate="survey_last_seen_date",e.SurveysSeen="surveys_seen",e.Surveys="surveys",e.RemoteConfig="remote_config"})(DH||(DH={}));var YLp;(function(e){e.Left="left",e.Right="right",e.Center="center"})(YLp||(YLp={}));var XLp;(function(e){e.Button="button",e.Tab="tab",e.Selector="selector"})(XLp||(XLp={}));var ZLp;(function(e){e.Popover="popover",e.API="api",e.Widget="widget"})(ZLp||(ZLp={}));var kLp;(function(e){e.Html="html",e.Text="text"})(kLp||(kLp={}));var e3p;(function(e){e.Number="number",e.Emoji="emoji"})(e3p||(e3p={}));var t3p;(function(e){e.Open="open",e.MultipleChoice="multiple_choice",e.SingleChoice="single_choice",e.Rating="rating",e.Link="link"})(t3p||(t3p={}));var r3p;(function(e){e.NextQuestion="next_question",e.End="end",e.ResponseBased="response_based",e.SpecificQuestion="specific_question"})(r3p||(r3p={}));var i3p;(function(e){e.Regex="regex",e.NotRegex="not_regex",e.Exact="exact",e.IsNot="is_not",e.Icontains="icontains",e.NotIcontains="not_icontains"})(i3p||(i3p={}));var n3p;(function(e){e.Contains="contains",e.Exact="exact",e.Regex="regex"})(n3p||(n3p={}));var fmS=e=>{if("flags"in e){let t=pmS(e.flags),r=_mS(e.flags);return{...e,featureFlags:t,featureFlagPayloads:r}}else{let t=e.featureFlags??{},r=Object.fromEntries(Object.entries(e.featureFlagPayloads||{}).map(([n,a])=>[n,j3p(a)])),i=Object.fromEntries(Object.entries(t).map(([n,a])=>[n,dmS(n,a,r[n])]));return{...e,featureFlags:t,featureFlagPayloads:r,flags:i}}};function dmS(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 pmS=e=>Object.fromEntries(Object.entries(e??{}).map(([t,r])=>[t,P7s(r)]).filter(([,t])=>t!==void 0)),_mS=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?j3p(i):void 0]}))},P7s=e=>e===void 0?void 0:e.variant??e.enabled,j3p=e=>{if(typeof e!="string")return e;try{return JSON.parse(e)}catch{return e}},hmS=1,ymS=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"]),bmS="utf8";function vmS(e,t){if(!e||typeof e!="string"||gmS(e))throw new Error(t)}function gmS(e){return e.trim().length===0}function OmS(e){return e?.replace(/\/+$/,"")}async function AmS(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 a3p(){return new Date().getTime()}function l7s(){return new Date().toISOString()}function S0o(e,t){let r=setTimeout(e,t);return r?.unref&&r?.unref(),r}function mmS(){return typeof fetch<"u"?fetch:typeof globalThis.fetch<"u"?globalThis.fetch:void 0}function PmS(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 jmS(e,t=0,r){let i=PmS(e);return r?.has(i)?!1:parseInt(i,16)/4294967295<t}function o3p(e){return Promise.all(e.map(t=>(t??Promise.resolve()).then(r=>({status:"fulfilled",value:r}),r=>({status:"rejected",reason:r}))))}var oOa=String.fromCharCode,u3p="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",m0o={};function wmS(e,t){if(!m0o[e]){m0o[e]={};for(let r=0;r<e.length;r++)m0o[e][e.charAt(r)]=r}return m0o[e][t]}var _Tn={compressToBase64:function(e){if(e==null)return"";let t=_Tn._compress(e,6,function(r){return u3p.charAt(r)});switch(t.length%4){default:case 0:return t;case 1:return t+"===";case 2:return t+"==";case 3:return t+"="}},decompressFromBase64:function(e){return e==null?"":e==""?null:_Tn._decompress(e.length,32,function(t){return wmS(u3p,e.charAt(t))})},compress:function(e){return _Tn._compress(e,16,function(t){return oOa(t)})},_compress:function(e,t,r){if(e==null)return"";let i={},n={},a=[],o,c,f="",s="",u="",l=2,p=3,_=2,h=0,y=0,b;for(b=0;b<e.length;b+=1)if(f=e.charAt(b),Object.prototype.hasOwnProperty.call(i,f)||(i[f]=p++,n[f]=!0),s=u+f,Object.prototype.hasOwnProperty.call(i,s))u=s;else{if(Object.prototype.hasOwnProperty.call(n,u)){if(u.charCodeAt(0)<256){for(o=0;o<_;o++)h=h<<1,y==t-1?(y=0,a.push(r(h)),h=0):y++;for(c=u.charCodeAt(0),o=0;o<8;o++)h=h<<1|c&1,y==t-1?(y=0,a.push(r(h)),h=0):y++,c=c>>1}else{for(c=1,o=0;o<_;o++)h=h<<1|c,y==t-1?(y=0,a.push(r(h)),h=0):y++,c=0;for(c=u.charCodeAt(0),o=0;o<16;o++)h=h<<1|c&1,y==t-1?(y=0,a.push(r(h)),h=0):y++,c=c>>1}l--,l==0&&(l=Math.pow(2,_),_++),delete n[u]}else for(c=i[u],o=0;o<_;o++)h=h<<1|c&1,y==t-1?(y=0,a.push(r(h)),h=0):y++,c=c>>1;l--,l==0&&(l=Math.pow(2,_),_++),i[s]=p++,u=String(f)}if(u!==""){if(Object.prototype.hasOwnProperty.call(n,u)){if(u.charCodeAt(0)<256){for(o=0;o<_;o++)h=h<<1,y==t-1?(y=0,a.push(r(h)),h=0):y++;for(c=u.charCodeAt(0),o=0;o<8;o++)h=h<<1|c&1,y==t-1?(y=0,a.push(r(h)),h=0):y++,c=c>>1}else{for(c=1,o=0;o<_;o++)h=h<<1|c,y==t-1?(y=0,a.push(r(h)),h=0):y++,c=0;for(c=u.charCodeAt(0),o=0;o<16;o++)h=h<<1|c&1,y==t-1?(y=0,a.push(r(h)),h=0):y++,c=c>>1}l--,l==0&&(l=Math.pow(2,_),_++),delete n[u]}else for(c=i[u],o=0;o<_;o++)h=h<<1|c&1,y==t-1?(y=0,a.push(r(h)),h=0):y++,c=c>>1;l--,l==0&&(l=Math.pow(2,_),_++)}for(c=2,o=0;o<_;o++)h=h<<1|c&1,y==t-1?(y=0,a.push(r(h)),h=0):y++,c=c>>1;for(;;)if(h=h<<1,y==t-1){a.push(r(h));break}else y++;return a.join("")},decompress:function(e){return e==null?"":e==""?null:_Tn._decompress(e.length,32768,function(t){return e.charCodeAt(t)})},_decompress:function(e,t,r){let i=[],n=[],a={val:r(0),position:t,index:1},o=4,c=4,f=3,s="",u,l,p,_,h,y,b;for(u=0;u<3;u+=1)i[u]=u;for(p=0,h=Math.pow(2,2),y=1;y!=h;)_=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),p|=(_>0?1:0)*y,y<<=1;switch(p){case 0:for(p=0,h=Math.pow(2,8),y=1;y!=h;)_=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),p|=(_>0?1:0)*y,y<<=1;b=oOa(p);break;case 1:for(p=0,h=Math.pow(2,16),y=1;y!=h;)_=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),p|=(_>0?1:0)*y,y<<=1;b=oOa(p);break;case 2:return""}for(i[3]=b,l=b,n.push(b);;){if(a.index>e)return"";for(p=0,h=Math.pow(2,f),y=1;y!=h;)_=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),p|=(_>0?1:0)*y,y<<=1;switch(b=p){case 0:for(p=0,h=Math.pow(2,8),y=1;y!=h;)_=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),p|=(_>0?1:0)*y,y<<=1;i[c++]=oOa(p),b=c-1,o--;break;case 1:for(p=0,h=Math.pow(2,16),y=1;y!=h;)_=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),p|=(_>0?1:0)*y,y<<=1;i[c++]=oOa(p),b=c-1,o--;break;case 2:return n.join("")}if(o==0&&(o=Math.pow(2,f),f++),i[b])s=i[b];else if(b===c)s=l+l.charAt(0);else return null;n.push(s),i[c++]=l+s.charAt(0),o--,l=s,o==0&&(o=Math.pow(2,f),f++)}}},_7s=class{constructor(){this.events={},this.events={}}on(t,r){return this.events[t]||(this.events[t]=[]),this.events[t].push(r),()=>{this.events[t]=this.events[t].filter(i=>i!==r)}}emit(t,r){for(let i of this.events[t]||[])i(r);for(let i of this.events["*"]||[])i(t,r)}},bTn=class extends Error{constructor(t,r){super("HTTP error while fetching PostHog: status="+t.status+", reqByteLength="+r),this.response=t,this.reqByteLength=r,this.name="PostHogFetchHttpError"}get status(){return this.response.status}get text(){return this.response.text()}get json(){return this.response.json()}},uOa=class extends Error{constructor(t){super("Network error while fetching PostHog",t instanceof Error?{cause:t}:{}),this.error=t,this.name="PostHogFetchNetworkError"}};async function s3p(e){if(e instanceof bTn){let t="";try{t=await e.text}catch{}console.error(`Error while flushing PostHog: message=${e.message}, response body=${t}`,e)}else console.error("Error while flushing PostHog",e);return Promise.resolve()}function f7s(e){return typeof e=="object"&&(e instanceof bTn||e instanceof uOa)}function c3p(e){return typeof e=="object"&&e instanceof bTn&&e.status===413}var h7s;(function(e){e.FeatureFlags="feature_flags",e.Recordings="recordings"})(h7s||(h7s={}));var y7s=class{constructor(t,r){this.flushPromise=null,this.shutdownPromise=null,this.pendingPromises={},this._events=new _7s,this._isInitialized=!1,vmS(t,"You must pass your PostHog project's api key."),this.apiKey=t,this.host=OmS(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:f7s},this.requestTimeout=r?.requestTimeout??1e4,this.featureFlagsRequestTimeoutMs=r?.featureFlagsRequestTimeoutMs??3e3,this.remoteConfigRequestTimeoutMs=r?.remoteConfigRequestTimeoutMs??3e3,this.disableGeoip=r?.disableGeoip??!0,this.disabled=r?.disabled??!1,this.historicalMigration=r?.historicalMigration??!1,this._initPromise=Promise.resolve(),this._isInitialized=!0}logMsgIfDebug(t){this.isDebug&&t()}wrap(t){if(this.disabled){this.logMsgIfDebug(()=>console.warn("[PostHog] The client is disabled"));return}if(this._isInitialized)return t();this._initPromise.then(()=>t())}getCommonEventProperties(){return{$lib:this.getLibraryId(),$lib_version:this.getLibraryVersion()}}get optedOut(){return this.getPersistedProperty(DH.OptedOut)??!this.defaultOptIn}async optIn(){this.wrap(()=>{this.setPersistedProperty(DH.OptedOut,!1)})}async optOut(){this.wrap(()=>{this.setPersistedProperty(DH.OptedOut,!0)})}on(t,r){return this._events.on(t,r)}debug(t=!0){if(this.removeDebugCallback?.(),t){let r=this.on("*",(i,n)=>console.log("PostHog Debug",i,n));this.removeDebugCallback=()=>{r(),this.removeDebugCallback=void 0}}}get isDebug(){return!!this.removeDebugCallback}get isDisabled(){return this.disabled}buildPayload(t){return{distinct_id:t.distinct_id,event:t.event,properties:{...t.properties||{},...this.getCommonEventProperties()}}}addPendingPromise(t){let r=p7s();return this.pendingPromises[r]=t,t.catch(()=>{}).finally(()=>{delete this.pendingPromises[r]}),t}identifyStateless(t,r,i){this.wrap(()=>{let n={...this.buildPayload({distinct_id:t,event:"$identify",properties:r})};this.enqueue("identify",n,i)})}async identifyStatelessImmediate(t,r,i){let n={...this.buildPayload({distinct_id:t,event:"$identify",properties:r})};await this.sendImmediate("identify",n,i)}captureStateless(t,r,i,n){this.wrap(()=>{let a=this.buildPayload({distinct_id:t,event:r,properties:i});this.enqueue("capture",a,n)})}async captureStatelessImmediate(t,r,i,n){let a=this.buildPayload({distinct_id:t,event:r,properties:i});await this.sendImmediate("capture",a,n)}aliasStateless(t,r,i,n){this.wrap(()=>{let a=this.buildPayload({event:"$create_alias",distinct_id:r,properties:{...i||{},distinct_id:r,alias:t}});this.enqueue("alias",a,n)})}async aliasStatelessImmediate(t,r,i,n){let a=this.buildPayload({event:"$create_alias",distinct_id:r,properties:{...i||{},distinct_id:r,alias:t}});await this.sendImmediate("alias",a,n)}groupIdentifyStateless(t,r,i,n,a,o){this.wrap(()=>{let c=this.buildPayload({distinct_id:a||`$${t}_${r}`,event:"$groupidentify",properties:{$group_type:t,$group_key:r,$group_set:i||{},...o||{}}});this.enqueue("capture",c,n)})}async getRemoteConfig(){await this._initPromise;let t=this.host;t==="https://us.i.posthog.com"?t="https://us-assets.i.posthog.com":t==="https://eu.i.posthog.com"&&(t="https://eu-assets.i.posthog.com");let r=`${t}/array/${this.apiKey}/config`,i={method:"GET",headers:{...this.getCustomHeaders(),"Content-Type":"application/json"}};return this.fetchWithRetry(r,i,{retryCount:0},this.remoteConfigRequestTimeoutMs).then(n=>n.json()).catch(n=>{this.logMsgIfDebug(()=>console.error("Remote config could not be loaded",n)),this._events.emit("error",n)})}async getDecide(t,r={},i={},n={},a={}){await this._initPromise;let c=jmS(this.apiKey,hmS,ymS)?`${this.host}/flags/?v=2`:`${this.host}/decide/?v=4`,f={method:"POST",headers:{...this.getCustomHeaders(),"Content-Type":"application/json"},body:JSON.stringify({token:this.apiKey,distinct_id:t,groups:r,person_properties:i,group_properties:n,...a})};return this.logMsgIfDebug(()=>console.log("PostHog Debug","Decide URL",c)),this.fetchWithRetry(c,f,{retryCount:0},this.featureFlagsRequestTimeoutMs).then(s=>s.json()).then(s=>fmS(s)).catch(s=>{this._events.emit("error",s)})}async getFeatureFlagStateless(t,r,i={},n={},a={},o){await this._initPromise;let c=await this.getFeatureFlagDetailStateless(t,r,i,n,a,o);if(c===void 0)return{response:void 0,requestId:void 0};let f=P7s(c.response);return f===void 0&&(f=!1),{response:f,requestId:c.requestId}}async getFeatureFlagDetailStateless(t,r,i={},n={},a={},o){await this._initPromise;let c=await this.getFeatureFlagDetailsStateless(r,i,n,a,o,[t]);return c===void 0?void 0:{response:c.flags[t],requestId:c.requestId}}async getFeatureFlagPayloadStateless(t,r,i={},n={},a={},o){await this._initPromise;let c=await this.getFeatureFlagPayloadsStateless(r,i,n,a,o,[t]);if(!c)return;let f=c[t];return f===void 0?null:f}async getFeatureFlagPayloadsStateless(t,r={},i={},n={},a,o){return await this._initPromise,(await this.getFeatureFlagsAndPayloadsStateless(t,r,i,n,a,o)).payloads}async getFeatureFlagsStateless(t,r={},i={},n={},a,o){return await this._initPromise,await this.getFeatureFlagsAndPayloadsStateless(t,r,i,n,a,o)}async getFeatureFlagsAndPayloadsStateless(t,r={},i={},n={},a,o){await this._initPromise;let c=await this.getFeatureFlagDetailsStateless(t,r,i,n,a,o);return c?{flags:c.featureFlags,payloads:c.featureFlagPayloads,requestId:c.requestId}:{flags:void 0,payloads:void 0,requestId:void 0}}async getFeatureFlagDetailsStateless(t,r={},i={},n={},a,o){await this._initPromise;let c={};(a??this.disableGeoip)&&(c.geoip_disable=!0),o&&(c.flag_keys_to_evaluate=o);let f=await this.getDecide(t,r,i,n,c);if(f!==void 0)return f.errorsWhileComputingFlags&&console.error("[FEATURE FLAGS] Error while computing feature flags, some flags may be missing or incorrect. Learn more at https://posthog.com/docs/feature-flags/best-practices"),f.quotaLimited?.includes(h7s.FeatureFlags)?(console.warn("[FEATURE FLAGS] Feature flags quota limit exceeded - feature flags unavailable. Learn more about billing limits at https://posthog.com/docs/billing/limits-alerts"),{flags:{},featureFlags:{},featureFlagPayloads:{},requestId:f?.requestId}):f}async getSurveysStateless(){if(await this._initPromise,this.disableSurveys===!0)return this.logMsgIfDebug(()=>console.log("PostHog Debug","Loading surveys is disabled.")),[];let t=`${this.host}/api/surveys/?token=${this.apiKey}`,r={method:"GET",headers:{...this.getCustomHeaders(),"Content-Type":"application/json"}},n=(await this.fetchWithRetry(t,r).then(a=>{if(a.status!==200||!a.json){let o=`Surveys API could not be loaded: ${a.status}`,c=new Error(o);this.logMsgIfDebug(()=>console.error(c)),this._events.emit("error",new Error(o));return}return a.json()}).catch(a=>{this.logMsgIfDebug(()=>console.error("Surveys API could not be loaded",a)),this._events.emit("error",a)}))?.surveys;return n&&this.logMsgIfDebug(()=>console.log("PostHog Debug","Surveys fetched from API: ",JSON.stringify(n))),n??[]}get props(){return this._props||(this._props=this.getPersistedProperty(DH.Props)),this._props||{}}set props(t){this._props=t}async register(t){this.wrap(()=>{this.props={...this.props,...t},this.setPersistedProperty(DH.Props,this.props)})}async unregister(t){this.wrap(()=>{delete this.props[t],this.setPersistedProperty(DH.Props,this.props)})}enqueue(t,r,i){this.wrap(()=>{if(this.optedOut){this._events.emit(t,"Library is disabled. Not sending event. To re-enable, call posthog.optIn()");return}let n=this.prepareMessage(t,r,i),a=this.getPersistedProperty(DH.Queue)||[];a.length>=this.maxQueueSize&&(a.shift(),this.logMsgIfDebug(()=>console.info("Queue is full, the oldest event is dropped."))),a.push({message:n}),this.setPersistedProperty(DH.Queue,a),this._events.emit(t,n),a.length>=this.flushAt&&this.flushBackground(),this.flushInterval&&!this._flushTimer&&(this._flushTimer=S0o(()=>this.flushBackground(),this.flushInterval))})}async sendImmediate(t,r,i){if(this.disabled){this.logMsgIfDebug(()=>console.warn("[PostHog] The client is disabled"));return}if(this._isInitialized||await this._initPromise,this.optedOut){this._events.emit(t,"Library is disabled. Not sending event. To re-enable, call posthog.optIn()");return}let n={api_key:this.apiKey,batch:[this.prepareMessage(t,r,i)],sent_at:l7s()};this.historicalMigration&&(n.historical_migration=!0);let a=JSON.stringify(n),o=this.captureMode==="form"?`${this.host}/e/?ip=1&_=${a3p()}&v=${this.getLibraryVersion()}`:`${this.host}/batch/`,c=this.captureMode==="form"?{method:"POST",mode:"no-cors",credentials:"omit",headers:{...this.getCustomHeaders(),"Content-Type":"application/x-www-form-urlencoded"},body:`data=${encodeURIComponent(_Tn.compressToBase64(a))}&compression=lz64`}:{method:"POST",headers:{...this.getCustomHeaders(),"Content-Type":"application/json"},body:a};try{await this.fetchWithRetry(o,c)}catch(f){this._events.emit("error",f)}}prepareMessage(t,r,i){let n={...r,type:t,library:this.getLibraryId(),library_version:this.getLibraryVersion(),timestamp:i?.timestamp?i?.timestamp:l7s(),uuid:i?.uuid?i.uuid:p7s()};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 s3p(t)})}async flush(){let t=o3p([this.flushPromise]).then(()=>this._flush());return this.flushPromise=t,this.addPendingPromise(t),o3p([t]).then(()=>{this.flushPromise===t&&(this.flushPromise=null)}),t}getCustomHeaders(){let t=this.getCustomUserAgent(),r={};return t&&t!==""&&(r["User-Agent"]=t),r}async _flush(){this.clearFlushTimer(),await this._initPromise;let t=this.getPersistedProperty(DH.Queue)||[];if(!t.length)return;let r=[],i=t.length;for(;t.length>0&&r.length<i;){let n=t.slice(0,this.maxBatchSize),a=n.map(p=>p.message),o=()=>{let _=(this.getPersistedProperty(DH.Queue)||[]).slice(n.length);this.setPersistedProperty(DH.Queue,_),t=_},c={api_key:this.apiKey,batch:a,sent_at:l7s()};this.historicalMigration&&(c.historical_migration=!0);let f=JSON.stringify(c),s=this.captureMode==="form"?`${this.host}/e/?ip=1&_=${a3p()}&v=${this.getLibraryVersion()}`:`${this.host}/batch/`,u=this.captureMode==="form"?{method:"POST",mode:"no-cors",credentials:"omit",headers:{...this.getCustomHeaders(),"Content-Type":"application/x-www-form-urlencoded"},body:`data=${encodeURIComponent(_Tn.compressToBase64(f))}&compression=lz64`}:{method:"POST",headers:{...this.getCustomHeaders(),"Content-Type":"application/json"},body:f},l={retryCheck:p=>c3p(p)?!1:f7s(p)};try{await this.fetchWithRetry(s,u,l)}catch(p){if(c3p(p)&&a.length>1){this.maxBatchSize=Math.max(1,Math.floor(a.length/2)),this.logMsgIfDebug(()=>console.warn(`Received 413 when sending batch of size ${a.length}, reducing batch size to ${this.maxBatchSize}`));continue}throw p instanceof uOa||o(),this._events.emit("error",p),p}o(),r.push(...a)}this._events.emit("flush",r)}async fetchWithRetry(t,r,i,n){var a;(a=AbortSignal).timeout??(a.timeout=function(s){let u=new AbortController;return setTimeout(()=>u.abort(),s),u.signal});let o=r.body?r.body:"",c=-1;try{c=Buffer.byteLength(o,bmS)}catch{c=new TextEncoder().encode(o).length}return await AmS(async()=>{let f=null;try{f=await this.fetch(t,{signal:AbortSignal.timeout(n??this.requestTimeout),...r})}catch(u){throw new uOa(u)}if(!(r.mode==="no-cors")&&(f.status<200||f.status>=400))throw new bTn(f,c);return f},{...this._retryOptions,...i})}async _shutdown(t=3e4){await this._initPromise;let r=!1;this.clearFlushTimer();let i=async()=>{try{for(await Promise.all(Object.values(this.pendingPromises));!((this.getPersistedProperty(DH.Queue)||[]).length===0||(await this.flush(),r)););}catch(n){if(!f7s(n))throw n;await s3p(n)}};return Promise.race([new Promise((n,a)=>{S0o(()=>{this.logMsgIfDebug(()=>console.error("Timed out while shutting down PostHog")),r=!0,a("Timeout while shutting down PostHog. Some events may not have been sent.")},t)}),i()])}async shutdown(t=3e4){return this.shutdownPromise?this.logMsgIfDebug(()=>console.warn("shutdown() called while already shutting down. shutdown() is meant to be called once before process exit - use flush() for per-request cleanup")):this.shutdownPromise=this._shutdown(t).finally(()=>{this.shutdownPromise=null}),this.shutdownPromise}},b7s=mmS();if(!b7s){let e=ULp();b7s=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 w3p=b7s,M0o=class{constructor(t){this.factory=t}async getValue(){return this.value!==void 0?this.value:(this.initializationPromise===void 0&&(this.initializationPromise=(async()=>{try{let t=await this.factory();return this.value=t,t}finally{this.initializationPromise=void 0}})()),this.initializationPromise)}isInitialized(){return this.value!==void 0}async waitForInitialization(){this.isInitialized()||await this.getValue()}},E3p=new M0o(async()=>{try{return await import("crypto")}catch{return}});async function EmS(){return await E3p.getValue()}var SmS=new M0o(async()=>{if(typeof globalThis.crypto?.subtle<"u")return globalThis.crypto.subtle;try{let e=await E3p.getValue();if(e?.webcrypto?.subtle)return e.webcrypto.subtle}catch{}});async function MmS(){return await SmS.getValue()}async function DmS(e){let t=await EmS();if(t)return t.createHash("sha1").update(e).digest("hex");let r=await MmS();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 BmS=60*1e3,ImS=1152921504606847e3,CmS=["is_not"],hTn=class e extends Error{constructor(t){super(),Error.captureStackTrace(this,this.constructor),this.name="ClientError",this.message=t,Object.setPrototypeOf(this,e.prototype)}},v1=class e extends Error{constructor(t){super(t),this.name=this.constructor.name,Error.captureStackTrace(this,this.constructor),Object.setPrototypeOf(this,e.prototype)}},v7s=class{constructor({pollingInterval:t,personalApiKey:r,projectApiKey:i,timeout:n,host:a,customHeaders:o,...c}){this.debugMode=!1,this.shouldBeginExponentialBackoff=!1,this.backOffCount=0,this.pollingInterval=t,this.personalApiKey=r,this.featureFlags=[],this.featureFlagsByKey={},this.groupTypeMapping={},this.cohorts={},this.loadedSuccessfullyOnce=!1,this.timeout=n,this.projectApiKey=i,this.host=a,this.poller=void 0,this.fetch=c.fetch||w3p,this.onError=c.onError,this.customHeaders=o,this.onLoad=c.onLoad,this.loadFeatureFlags()}debug(t=!0){this.debugMode=t}logMsgIfDebug(t){this.debugMode&&t()}async getFeatureFlag(t,r,i={},n={},a={}){await this.loadFeatureFlags();let o,c;if(!this.loadedSuccessfullyOnce)return o;for(let f of this.featureFlags)if(t===f.key){c=f;break}if(c!==void 0)try{o=await this.computeFlagLocally(c,r,i,n,a),this.logMsgIfDebug(()=>console.debug(`Successfully computed flag locally: ${t} -> ${o}`))}catch(f){f instanceof v1?this.logMsgIfDebug(()=>console.debug(`InconclusiveMatchError when computing flag locally: ${t}: ${f}`)):f instanceof Error&&this.onError?.(new Error(`Error computing flag locally: ${t}: ${f}`))}return o}async computeFeatureFlagPayloadLocally(t,r){await this.loadFeatureFlags();let i;if(this.loadedSuccessfullyOnce){if(typeof r=="boolean"?i=this.featureFlagsByKey?.[t]?.filters?.payloads?.[r.toString()]:typeof r=="string"&&(i=this.featureFlagsByKey?.[t]?.filters?.payloads?.[r]),i==null)return null;try{return JSON.parse(i)}catch{return i}}}async getAllFlagsAndPayloads(t,r={},i={},n={}){await this.loadFeatureFlags();let a={},o={},c=this.featureFlags.length==0;return await Promise.all(this.featureFlags.map(async f=>{try{let s=await this.computeFlagLocally(f,t,r,i,n);a[f.key]=s;let u=await this.computeFeatureFlagPayloadLocally(f.key,s);u&&(o[f.key]=u)}catch(s){s instanceof v1||s instanceof Error&&this.onError?.(new Error(`Error computing flag locally: ${f.key}: ${s}`)),c=!0}})),{response:a,payloads:o,fallbackToDecide:c}}async computeFlagLocally(t,r,i={},n={},a={}){if(t.ensure_experience_continuity)throw new v1("Flag has experience continuity enabled");if(!t.active)return!1;let c=(t.filters||{}).aggregation_group_type_index;if(c!=null){let f=this.groupTypeMapping[String(c)];if(!f)throw this.logMsgIfDebug(()=>console.warn(`[FEATURE FLAGS] Unknown group type index ${c} for feature flag ${t.key}`)),new v1("Flag has unknown group type index");if(!(f in i))return this.logMsgIfDebug(()=>console.warn(`[FEATURE FLAGS] Can't compute group feature flag: ${t.key} without group names passed in`)),!1;let s=a[f];return await this.matchFeatureFlagProperties(t,i[f],s)}else return await this.matchFeatureFlagProperties(t,r,n)}async matchFeatureFlagProperties(t,r,i){let n=t.filters||{},a=n.groups||[],o=!1,c,f=[...a].sort((s,u)=>{let l=!!s.variant,p=!!u.variant;return l&&p?0:l?-1:p?1:0});for(let s of f)try{if(await this.isConditionMatch(t,r,s,i)){let u=s.variant,l=n.multivariate?.variants||[];u&&l.some(p=>p.key===u)?c=u:c=await this.getMatchingVariant(t,r)||!0;break}}catch(u){if(u instanceof v1)o=!0;else throw u}if(c!==void 0)return c;if(o)throw new v1("Can't determine if feature flag is enabled or not with given properties");return!1}async isConditionMatch(t,r,i,n){let a=i.rollout_percentage,o=c=>{this.logMsgIfDebug(()=>console.warn(c))};if((i.properties||[]).length>0){for(let c of i.properties){let f=c.type,s=!1;if(f==="cohort"?s=M3p(c,n,this.cohorts,this.debugMode):s=S3p(c,n,o),!s)return!1}if(a==null)return!0}return!(a!=null&&await l3p(t.key,r)>a/100)}async getMatchingVariant(t,r){let i=await l3p(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(BmS,this.pollingInterval*2**this.backOffCount):this.pollingInterval}async _loadFeatureFlags(){this.poller&&(clearTimeout(this.poller),this.poller=void 0),this.poller=setTimeout(()=>this._loadFeatureFlags(),this.getPollingInterval());try{let t=await this._requestFeatureFlagDefinitions();if(!t)return;switch(t.status){case 401:throw this.shouldBeginExponentialBackoff=!0,this.backOffCount+=1,new hTn(`Your project key or personal API key is invalid. Setting next polling interval to ${this.getPollingInterval()}ms. More information: https://posthog.com/docs/api#rate-limiting`);case 402:console.warn("[FEATURE FLAGS] Feature flags quota limit exceeded - unsetting all local flags. Learn more about billing limits at https://posthog.com/docs/billing/limits-alerts"),this.featureFlags=[],this.featureFlagsByKey={},this.groupTypeMapping={},this.cohorts={};return;case 403:throw this.shouldBeginExponentialBackoff=!0,this.backOffCount+=1,new hTn(`Your personal API key does not have permission to fetch feature flag definitions for local evaluation. Setting next polling interval to ${this.getPollingInterval()}ms. Are you sure you're using the correct personal and Project API key pair? More information: https://posthog.com/docs/api/overview`);case 429:throw this.shouldBeginExponentialBackoff=!0,this.backOffCount+=1,new hTn(`You are being rate limited. Setting next polling interval to ${this.getPollingInterval()}ms. More information: https://posthog.com/docs/api#rate-limiting`);case 200:{let r=await t.json()??{};if(!("flags"in r)){this.onError?.(new Error(`Invalid response when getting feature flags: ${JSON.stringify(r)}`));return}this.featureFlags=r.flags??[],this.featureFlagsByKey=this.featureFlags.reduce((i,n)=>(i[n.key]=n,i),{}),this.groupTypeMapping=r.group_type_mapping||{},this.cohorts=r.cohorts||{},this.loadedSuccessfullyOnce=!0,this.shouldBeginExponentialBackoff=!1,this.backOffCount=0,this.onLoad?.(this.featureFlags.length);break}default:return}}catch(t){t instanceof hTn&&this.onError?.(t)}}getPersonalApiKeyRequestOptions(t="GET"){return{method:t,headers:{...this.customHeaders,"Content-Type":"application/json",Authorization:`Bearer ${this.personalApiKey}`}}}async _requestFeatureFlagDefinitions(){let t=`${this.host}/api/feature_flag/local_evaluation?token=${this.projectApiKey}&send_cohorts`,r=this.getPersonalApiKeyRequestOptions(),i=null;if(this.timeout&&typeof this.timeout=="number"){let n=new AbortController;i=S0o(()=>{n.abort()},this.timeout),r.signal=n.signal}try{return await this.fetch(t,r)}finally{clearTimeout(i)}}stopPoller(){clearTimeout(this.poller)}_requestRemoteConfigPayload(t){let r=`${this.host}/api/projects/@current/feature_flags/${t}/remote_config/`,i=this.getPersonalApiKeyRequestOptions(),n=null;if(this.timeout&&typeof this.timeout=="number"){let a=new AbortController;n=S0o(()=>{a.abort()},this.timeout),i.signal=a.signal}try{return this.fetch(r,i)}finally{clearTimeout(n)}}};async function l3p(e,t,r=""){let i=await DmS(`${e}.${t}${r}`);return parseInt(i.slice(0,15),16)/ImS}function S3p(e,t,r){let i=e.key,n=e.value,a=e.operator||"exact";if(i in t){if(a==="is_not_set")throw new v1("Operator is_not_set is not supported")}else throw new v1(`Property ${i} not found in propertyValues`);let o=t[i];if(o==null&&!CmS.includes(a))return r&&r(`Property ${i} cannot have a value of null/undefined with the ${a} operator`),!1;function c(s,u){return Array.isArray(s)?s.map(l=>String(l).toLowerCase()).includes(String(u).toLowerCase()):String(s).toLowerCase()===String(u).toLowerCase()}function f(s,u,l){if(l==="gt")return s>u;if(l==="gte")return s>=u;if(l==="lt")return s<u;if(l==="lte")return s<=u;throw new Error(`Invalid operator: ${l}`)}switch(a){case"exact":return c(n,o);case"is_not":return!c(n,o);case"is_set":return i in t;case"icontains":return String(o).toLowerCase().includes(String(n).toLowerCase());case"not_icontains":return!String(o).toLowerCase().includes(String(n).toLowerCase());case"regex":return f3p(String(n))&&String(o).match(String(n))!==null;case"not_regex":return f3p(String(n))&&String(o).match(String(n))===null;case"gt":case"gte":case"lt":case"lte":{let s=typeof n=="number"?n:null;if(typeof n=="string")try{s=parseFloat(n)}catch{}return s!=null&&o!=null?typeof o=="string"?f(o,String(n),a):f(o,s,a):f(String(o),String(n),a)}case"is_date_after":case"is_date_before":{let s=qmS(String(n));if(s==null&&(s=d3p(n)),s==null)throw new v1(`Invalid date: ${n}`);let u=d3p(o);return["is_date_before"].includes(a)?u<s:u>s}default:throw new v1(`Unknown operator: ${a}`)}}function M3p(e,t,r,i=!1){let n=String(e.value);if(!(n in r))throw new v1("can't match cohort without a given cohort property value");let a=r[n];return D3p(a,t,r,i)}function D3p(e,t,r,i=!1){if(!e)return!0;let n=e.type,a=e.values;if(!a||a.length===0)return!0;let o=!1;if("values"in a[0]){for(let c of a)try{let f=D3p(c,t,r,i);if(n==="AND"){if(!f)return!1}else if(f)return!0}catch(f){if(f instanceof v1)i&&console.debug(`Failed to compute property ${c} locally: ${f}`),o=!0;else throw f}if(o)throw new v1("Can't match cohort without a given cohort property value");return n==="AND"}else{for(let c of a)try{let f;c.type==="cohort"?f=M3p(c,t,r,i):f=S3p(c,t);let s=c.negation||!1;if(n==="AND"){if(!f&&!s||f&&s)return!1}else if(f&&!s||!f&&s)return!0}catch(f){if(f instanceof v1)i&&console.debug(`Failed to compute property ${c} locally: ${f}`),o=!0;else throw f}if(o)throw new v1("can't match cohort without a given cohort property value");return n==="AND"}}function f3p(e){try{return new RegExp(e),!0}catch{return!1}}function d3p(e){if(e instanceof Date)return e;if(typeof e=="string"||typeof e=="number"){let t=new Date(e);if(!isNaN(t.valueOf()))return t;throw new v1(`${e} is in an invalid date format`)}else throw new v1(`The date provided ${e} must be a string, number, or date object`)}function qmS(e){let t=/^-?(?<number>[0-9]+)(?<interval>[a-z])$/,r=e.match(t),i=new Date(new Date().toISOString());if(r){if(!r.groups)return null;let n=parseInt(r.groups.number);if(n>=1e4)return null;let a=r.groups.interval;if(a=="h")i.setUTCHours(i.getUTCHours()-n);else if(a=="d")i.setUTCDate(i.getUTCDate()-n);else if(a=="w")i.setUTCDate(i.getUTCDate()-n*7);else if(a=="m")i.setUTCMonth(i.getUTCMonth()-n);else if(a=="y")i.setUTCFullYear(i.getUTCFullYear()-n);else return null;return i}else return null}var g7s=class{constructor(){this._memoryStorage={}}getProperty(t){return this._memoryStorage[t]}setProperty(t,r){this._memoryStorage[t]=r!==null?r:void 0}},TmS=100,p3p=30*1e3,RmS=50*1e3,O7s=class extends y7s{constructor(t,r={}){if(super(t,r),this._memoryStorage=new g7s,this.options=r,this.options.featureFlagsPollingInterval=typeof r.featureFlagsPollingInterval=="number"?Math.max(r.featureFlagsPollingInterval,TmS):p3p,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 v7s({pollingInterval:this.options.featureFlagsPollingInterval,personalApiKey:r.personalApiKey,projectApiKey:t,timeout:r.requestTimeout??1e4,host:this.host,fetch:r.fetch,onError:i=>{this._events.emit("error",i)},onLoad:i=>{this._events.emit("localEvaluationFlagsLoaded",i)},customHeaders:this.getCustomHeaders()})}this.errorTracking=new yTn(this,r),this.distinctIdHasSentFlagCalls={},this.maxCacheSize=r.maxCacheSize||RmS}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):w3p(t,r)}getLibraryVersion(){return lmS}getCustomUserAgent(){return`${this.getLibraryId()}/${this.getLibraryVersion()}`}enable(){return super.optIn()}disable(){return super.optOut()}debug(t=!0){super.debug(t),this.featureFlagsPoller?.debug(t)}capture(t){typeof t=="string"&&this.logMsgIfDebug(()=>console.warn("Called capture() with a string as the first argument when an object was expected."));let{distinctId:r,event:i,properties:n,groups:a,sendFeatureFlags:o,timestamp:c,disableGeoip:f,uuid:s}=t,u=_=>{super.captureStateless(r,i,_,{timestamp:c,disableGeoip:f,uuid:s})},l=async(_,h,y)=>(await super.getFeatureFlagsStateless(_,h,void 0,void 0,y)).flags,p=Promise.resolve().then(async()=>{if(o)return await l(r,a,f);if(i==="$feature_flag_called")return{};if((this.featureFlagsPoller?.featureFlags?.length||0)>0){let _={};for(let[h,y]of Object.entries(a||{}))_[h]=String(y);return await this.getAllFlags(r,{groups:_,disableGeoip:f,onlyEvaluateLocally:!0})}return{}}).then(_=>{let h={};if(_)for(let[b,v]of Object.entries(_))h[`$feature/${b}`]=v;let y=Object.keys(_||{}).filter(b=>_?.[b]!==!1).sort();return y.length>0&&(h.$active_feature_flags=y),h}).catch(()=>({})).then(_=>{u({..._,...n,$groups:a})});this.addPendingPromise(p)}async captureImmediate(t){typeof t=="string"&&this.logMsgIfDebug(()=>console.warn("Called capture() with a string as the first argument when an object was expected."));let{distinctId:r,event:i,properties:n,groups:a,sendFeatureFlags:o,timestamp:c,disableGeoip:f,uuid:s}=t,u=_=>super.captureStatelessImmediate(r,i,_,{timestamp:c,disableGeoip:f,uuid:s}),l=async(_,h,y)=>(await super.getFeatureFlagsStateless(_,h,void 0,void 0,y)).flags;await Promise.resolve().then(async()=>{if(o)return await l(r,a,f);if(i==="$feature_flag_called")return{};if((this.featureFlagsPoller?.featureFlags?.length||0)>0){let _={};for(let[h,y]of Object.entries(a||{}))_[h]=String(y);return await this.getAllFlags(r,{groups:_,disableGeoip:f,onlyEvaluateLocally:!0})}return{}}).then(_=>{let h={};if(_)for(let[b,v]of Object.entries(_))h[`$feature/${b}`]=v;let y=Object.keys(_||{}).filter(b=>_?.[b]!==!1).sort();return y.length>0&&(h.$active_feature_flags=y),h}).catch(()=>({})).then(_=>{u({..._,...n,$groups:a})})}identify({distinctId:t,properties:r,disableGeoip:i}){let n=r?.$set_once;delete r?.$set_once;let a=r?.$set||r;super.identifyStateless(t,{$set:a,$set_once:n},{disableGeoip:i})}async identifyImmediate({distinctId:t,properties:r,disableGeoip:i}){let n=r?.$set_once;delete r?.$set_once;let a=r?.$set||r;await super.identifyStatelessImmediate(t,{$set:a,$set_once:n},{disableGeoip:i})}alias(t){super.aliasStateless(t.alias,t.distinctId,void 0,{disableGeoip:t.disableGeoip})}async aliasImmediate(t){await super.aliasStatelessImmediate(t.alias,t.distinctId,void 0,{disableGeoip:t.disableGeoip})}isLocalEvaluationReady(){return this.featureFlagsPoller?.isLocalEvaluationReady()??!1}async waitForLocalEvaluationReady(t=p3p){return this.isLocalEvaluationReady()?!0:this.featureFlagsPoller===void 0?!1:new Promise(r=>{let i=setTimeout(()=>{n(),r(!1)},t),n=this._events.on("localEvaluationFlagsLoaded",a=>{clearTimeout(i),n(),r(a>0)})})}async getFeatureFlag(t,r,i){let{groups:n,disableGeoip:a}=i||{},{onlyEvaluateLocally:o,sendFeatureFlagEvents:c,personProperties:f,groupProperties:s}=i||{},u=this.addLocalPersonAndGroupProperties(r,n,f,s);f=u.allPersonProperties,s=u.allGroupProperties,o==null&&(o=!1),c==null&&(c=!0);let l=await this.featureFlagsPoller?.getFeatureFlag(t,r,n,f,s),p=l!==void 0,_,h;if(!p&&!o){let b=await super.getFeatureFlagDetailStateless(t,r,n,f,s,a);if(b===void 0)return;h=b.response,l=P7s(h),_=b?.requestId}let y=`${t}_${l}`;return c&&(!(r in this.distinctIdHasSentFlagCalls)||!this.distinctIdHasSentFlagCalls[r].includes(y))&&(Object.keys(this.distinctIdHasSentFlagCalls).length>=this.maxCacheSize&&(this.distinctIdHasSentFlagCalls={}),Array.isArray(this.distinctIdHasSentFlagCalls[r])?this.distinctIdHasSentFlagCalls[r].push(y):this.distinctIdHasSentFlagCalls[r]=[y],this.capture({distinctId:r,event:"$feature_flag_called",properties:{$feature_flag:t,$feature_flag_response:l,$feature_flag_id:h?.metadata?.id,$feature_flag_version:h?.metadata?.version,$feature_flag_reason:h?.reason?.description??h?.reason?.code,locally_evaluated:p,[`$feature/${t}`]:l,$feature_flag_request_id:_},groups:n,disableGeoip:a})),l}async getFeatureFlagPayload(t,r,i,n){let{groups:a,disableGeoip:o}=n||{},{onlyEvaluateLocally:c,sendFeatureFlagEvents:f,personProperties:s,groupProperties:u}=n||{},l=this.addLocalPersonAndGroupProperties(r,a,s,u);s=l.allPersonProperties,u=l.allGroupProperties;let p;return this.featureFlagsPoller!==void 0&&(i||(i=await this.getFeatureFlag(t,r,{...n,onlyEvaluateLocally:!0,sendFeatureFlagEvents:!1})),i&&(p=await this.featureFlagsPoller?.computeFeatureFlagPayloadLocally(t,i))),c==null&&(c=!1),f==null&&(f=!0),c==null&&(c=!1),!(p!==void 0)&&!c&&(p=await super.getFeatureFlagPayloadStateless(t,r,a,s,u,o)),p}async getRemoteConfigPayload(t){return(await this.featureFlagsPoller?._requestRemoteConfigPayload(t))?.json()}async isFeatureEnabled(t,r,i){let n=await this.getFeatureFlag(t,r,i);if(n!==void 0)return!!n||!1}async getAllFlags(t,r){return(await this.getAllFlagsAndPayloads(t,r)).featureFlags||{}}async getAllFlagsAndPayloads(t,r){let{groups:i,disableGeoip:n}=r||{},{onlyEvaluateLocally:a,personProperties:o,groupProperties:c}=r||{},f=this.addLocalPersonAndGroupProperties(t,i,o,c);o=f.allPersonProperties,c=f.allGroupProperties,a==null&&(a=!1);let s=await this.featureFlagsPoller?.getAllFlagsAndPayloads(t,i,o,c),u={},l={},p=!0;if(s&&(u=s.response,l=s.payloads,p=s.fallbackToDecide),p&&!a){let _=await super.getFeatureFlagsAndPayloadsStateless(t,i,o,c,n);u={...u,..._.flags||{}},l={...l,..._.payloads||{}}}return{featureFlags:u,featureFlagPayloads:l}}groupIdentify({groupType:t,groupKey:r,properties:i,distinctId:n,disableGeoip:a}){super.groupIdentifyStateless(t,r,i,{disableGeoip:a},n)}async reloadFeatureFlags(){await this.featureFlagsPoller?.loadFeatureFlags(!0)}async _shutdown(t){return this.featureFlagsPoller?.stopPoller(),super._shutdown(t)}addLocalPersonAndGroupProperties(t,r,i,n){let a={distinct_id:t,...i||{}},o={};if(r)for(let c of Object.keys(r))o[c]={$group_key:r[c],...n?.[c]||{}};return{allPersonProperties:a,allGroupProperties:o}}captureException(t,r,i){let n=new Error("PostHog syntheticException");yTn.captureException(this,t,{syntheticException:n},r,i)}},_3p=/\(error: (.*)\)/,B3p=50,I3p="?";function zmS(e){let t=/^\s*[-]{4,}$/,r=/at (?:async )?(?:(.+?)\s+\()?(?:(.+):(\d+):(\d+)?|([^)]+))\)?/;return i=>{let n=i.match(r);if(n){let a,o,c,f,s;if(n[1]){c=n[1];let p=c.lastIndexOf(".");if(c[p-1]==="."&&p--,p>0){a=c.slice(0,p),o=c.slice(p+1);let _=a.indexOf(".Module");_>0&&(c=c.slice(_+1),a=a.slice(0,_))}f=void 0}o&&(f=a,s=o),o==="<anonymous>"&&(s=void 0,c=void 0),c===void 0&&(s=s||I3p,c=f?`${f}.${s}`:s);let u=n[2]?.startsWith("file://")?n[2].slice(7):n[2],l=n[5]==="native";return u?.match(/\/[A-Z]:/)&&(u=u.slice(1)),!u&&n[5]&&!l&&(u=n[5]),{filename:u?decodeURI(u):void 0,module:e?e(u):void 0,function:c,lineno:h3p(n[3]),colno:h3p(n[4]),in_app:NmS(u||"",l),platform:"node:javascript"}}if(i.match(t))return{filename:i,platform:"node:javascript"}}}function NmS(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 h3p(e){return parseInt(e||"",10)||void 0}function FmS(e){return[90,zmS(e)]}function QmS(e){let r=[FmS(e)].sort((i,n)=>i[0]-n[0]).map(i=>i[1]);return(i,n=0)=>{let a=[],o=i.split(`
|
|
1150
|
-
`);for(let c=n;c<o.length;c++){let f=o[c];if(f.length>1024)continue;let s=_3p.test(f)?f.replace(_3p,"$1"):f;if(!s.match(/\S*Error: /)){for(let u of r){let l=u(s);if(l){a.push(l);break}}if(a.length>=B3p)break}}return UmS(a)}}function UmS(e){if(!e.length)return[];let t=Array.from(e);return t.reverse(),t.slice(0,B3p).map(r=>({...r,filename:r.filename||LmS(t).filename,function:r.function||I3p}))}function LmS(e){return e[e.length-1]||{}}yTn.stackParser=QmS(XAS());yTn.frameModifiers=[emS];var vTn=class extends O7s{getLibraryId(){return"posthog-node"}};var D0o=class{posthog;constructor({posthogApiKey:t}){this.posthog=new vTn(t)}async identify(){}async sendEvent(t){t.orgId!=null&&this.posthog.capture({distinctId:t.orgId,event:"CLI",properties:{...t,...t.properties,version:"3.23.1",usingAccessToken:!0}})}async flush(){await this.posthog.flush()}};var sOa=class{async sendEvent(){}async identify(){}async flush(){}};var OTn=require("fs/promises"),R3p=require("os"),z3p=require("path");var C3p=ue(require("crypto")),I0o=new Uint8Array(256),B0o=I0o.length;function j7s(){return B0o>I0o.length-16&&(C3p.default.randomFillSync(I0o),B0o=0),I0o.slice(B0o,B0o+=16)}var TQ=[];for(let e=0;e<256;++e)TQ.push((e+256).toString(16).slice(1));function q3p(e,t=0){return TQ[e[t+0]]+TQ[e[t+1]]+TQ[e[t+2]]+TQ[e[t+3]]+"-"+TQ[e[t+4]]+TQ[e[t+5]]+"-"+TQ[e[t+6]]+TQ[e[t+7]]+"-"+TQ[e[t+8]]+TQ[e[t+9]]+"-"+TQ[e[t+10]]+TQ[e[t+11]]+TQ[e[t+12]]+TQ[e[t+13]]+TQ[e[t+14]]+TQ[e[t+15]]}var T3p=ue(require("crypto")),w7s={randomUUID:T3p.default.randomUUID};function VmS(e,t,r){if(w7s.randomUUID&&!t&&!e)return w7s.randomUUID();e=e||{};let i=e.random||(e.rng||j7s)();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 q3p(i)}var ehe=VmS;var WmS="id",xmS=".fern",cOa=class{posthog;userId;constructor({token:t,posthogApiKey:r}){this.posthog=new vTn(r),this.userId=t==null?void 0:H8s(t)}async identify(){this.userId!=null&&this.posthog.alias({distinctId:this.userId,alias:await this.getPersistedDistinctId()})}async sendEvent(t){this.posthog.capture({distinctId:this.userId??await this.getPersistedDistinctId(),event:"CLI",properties:{version:"3.23.1",...t,...t.properties}})}async flush(){await this.posthog.flush()}persistedDistinctId;async getPersistedDistinctId(){if(this.persistedDistinctId==null){let t=It(Rr.of((0,R3p.homedir)()),Ze.of(xmS),Ze.of(WmS));await qi(t)||(await(0,OTn.mkdir)((0,z3p.dirname)(t),{recursive:!0}),await(0,OTn.writeFile)(t,ehe())),this.persistedDistinctId=(await(0,OTn.readFile)(t)).toString()}return this.persistedDistinctId}};var E7s;async function ATn(){return E7s==null&&(E7s=await GmS()),E7s}async function GmS(){try{let e="phc_yQgAEdJJkVpI24NdSRID2mor1x1leRpDoC9yZ9mfXal",t=process.env.FERN_DISABLE_TELEMETRY==="true";if(e==null||t)return new sOa;let r=await Jyo();return r!=null?new cOa({token:r,posthogApiKey:e}):await jqn()!=null?new D0o({posthogApiKey:e}):new cOa({token:void 0,posthogApiKey:e})}catch{return new sOa}}function lOa(e,t){return function(){return e.apply(t,arguments)}}var{toString:HmS}=Object.prototype,{getPrototypeOf:M7s}=Object,{iterator:q0o,toStringTag:F3p}=Symbol,T0o=(e=>t=>{let r=HmS.call(t);return e[r]||(e[r]=r.slice(8,-1).toLowerCase())})(Object.create(null)),NNt=e=>(e=e.toLowerCase(),t=>T0o(t)===e),R0o=e=>t=>typeof t===e,{isArray:PTn}=Array,mTn=R0o("undefined");function fOa(e){return e!==null&&!mTn(e)&&e.constructor!==null&&!mTn(e.constructor)&&BH(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}var Q3p=NNt("ArrayBuffer");function KmS(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&Q3p(e.buffer),t}var JmS=R0o("string"),BH=R0o("function"),U3p=R0o("number"),dOa=e=>e!==null&&typeof e=="object",$mS=e=>e===!0||e===!1,C0o=e=>{if(T0o(e)!=="object")return!1;let t=M7s(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(F3p in e)&&!(q0o in e)},YmS=e=>{if(!dOa(e)||fOa(e))return!1;try{return Object.keys(e).length===0&&Object.getPrototypeOf(e)===Object.prototype}catch{return!1}},XmS=NNt("Date"),ZmS=NNt("File"),kmS=NNt("Blob"),e0S=NNt("FileList"),t0S=e=>dOa(e)&&BH(e.pipe),r0S=e=>{let t;return e&&(typeof FormData=="function"&&e instanceof FormData||BH(e.append)&&((t=T0o(e))==="formdata"||t==="object"&&BH(e.toString)&&e.toString()==="[object FormData]"))},i0S=NNt("URLSearchParams"),[n0S,a0S,o0S,u0S]=["ReadableStream","Request","Response","Headers"].map(NNt),s0S=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function pOa(e,t,{allOwnKeys:r=!1}={}){if(e===null||typeof e>"u")return;let i,n;if(typeof e!="object"&&(e=[e]),PTn(e))for(i=0,n=e.length;i<n;i++)t.call(null,e[i],i,e);else{if(fOa(e))return;let a=r?Object.getOwnPropertyNames(e):Object.keys(e),o=a.length,c;for(i=0;i<o;i++)c=a[i],t.call(null,e[c],c,e)}}function L3p(e,t){if(fOa(e))return null;t=t.toLowerCase();let r=Object.keys(e),i=r.length,n;for(;i-- >0;)if(n=r[i],t===n.toLowerCase())return n;return null}var K7i=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,V3p=e=>!mTn(e)&&e!==K7i;function S7s(){let{caseless:e,skipUndefined:t}=V3p(this)&&this||{},r={},i=(n,a)=>{let o=e&&L3p(r,a)||a;C0o(r[o])&&C0o(n)?r[o]=S7s(r[o],n):C0o(n)?r[o]=S7s({},n):PTn(n)?r[o]=n.slice():(!t||!mTn(n))&&(r[o]=n)};for(let n=0,a=arguments.length;n<a;n++)arguments[n]&&pOa(arguments[n],i);return r}var c0S=(e,t,r,{allOwnKeys:i}={})=>(pOa(t,(n,a)=>{r&&BH(n)?e[a]=lOa(n,r):e[a]=n},{allOwnKeys:i}),e),l0S=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),f0S=(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)},d0S=(e,t,r,i)=>{let n,a,o,c={};if(t=t||{},e==null)return t;do{for(n=Object.getOwnPropertyNames(e),a=n.length;a-- >0;)o=n[a],(!i||i(o,e,t))&&!c[o]&&(t[o]=e[o],c[o]=!0);e=r!==!1&&M7s(e)}while(e&&(!r||r(e,t))&&e!==Object.prototype);return t},p0S=(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},_0S=e=>{if(!e)return null;if(PTn(e))return e;let t=e.length;if(!U3p(t))return null;let r=new Array(t);for(;t-- >0;)r[t]=e[t];return r},h0S=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&M7s(Uint8Array)),y0S=(e,t)=>{let i=(e&&e[q0o]).call(e),n;for(;(n=i.next())&&!n.done;){let a=n.value;t.call(e,a[0],a[1])}},b0S=(e,t)=>{let r,i=[];for(;(r=e.exec(t))!==null;)i.push(r);return i},v0S=NNt("HTMLFormElement"),g0S=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(r,i,n){return i.toUpperCase()+n}),N3p=(({hasOwnProperty:e})=>(t,r)=>e.call(t,r))(Object.prototype),O0S=NNt("RegExp"),W3p=(e,t)=>{let r=Object.getOwnPropertyDescriptors(e),i={};pOa(r,(n,a)=>{let o;(o=t(n,a,e))!==!1&&(i[a]=o||n)}),Object.defineProperties(e,i)},A0S=e=>{W3p(e,(t,r)=>{if(BH(e)&&["arguments","caller","callee"].indexOf(r)!==-1)return!1;let i=e[r];if(BH(i)){if(t.enumerable=!1,"writable"in t){t.writable=!1;return}t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+r+"'")})}})},m0S=(e,t)=>{let r={},i=n=>{n.forEach(a=>{r[a]=!0})};return PTn(e)?i(e):i(String(e).split(t)),r},P0S=()=>{},j0S=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t;function w0S(e){return!!(e&&BH(e.append)&&e[F3p]==="FormData"&&e[q0o])}var E0S=e=>{let t=new Array(10),r=(i,n)=>{if(dOa(i)){if(t.indexOf(i)>=0)return;if(fOa(i))return i;if(!("toJSON"in i)){t[n]=i;let a=PTn(i)?[]:{};return pOa(i,(o,c)=>{let f=r(o,n+1);!mTn(f)&&(a[c]=f)}),t[n]=void 0,a}}return i};return r(e,0)},S0S=NNt("AsyncFunction"),M0S=e=>e&&(dOa(e)||BH(e))&&BH(e.then)&&BH(e.catch),x3p=((e,t)=>e?setImmediate:t?((r,i)=>(K7i.addEventListener("message",({source:n,data:a})=>{n===K7i&&a===r&&i.length&&i.shift()()},!1),n=>{i.push(n),K7i.postMessage(r,"*")}))(`axios@${Math.random()}`,[]):r=>setTimeout(r))(typeof setImmediate=="function",BH(K7i.postMessage)),D0S=typeof queueMicrotask<"u"?queueMicrotask.bind(K7i):typeof process<"u"&&process.nextTick||x3p,B0S=e=>e!=null&&BH(e[q0o]),er={isArray:PTn,isArrayBuffer:Q3p,isBuffer:fOa,isFormData:r0S,isArrayBufferView:KmS,isString:JmS,isNumber:U3p,isBoolean:$mS,isObject:dOa,isPlainObject:C0o,isEmptyObject:YmS,isReadableStream:n0S,isRequest:a0S,isResponse:o0S,isHeaders:u0S,isUndefined:mTn,isDate:XmS,isFile:ZmS,isBlob:kmS,isRegExp:O0S,isFunction:BH,isStream:t0S,isURLSearchParams:i0S,isTypedArray:h0S,isFileList:e0S,forEach:pOa,merge:S7s,extend:c0S,trim:s0S,stripBOM:l0S,inherits:f0S,toFlatObject:d0S,kindOf:T0o,kindOfTest:NNt,endsWith:p0S,toArray:_0S,forEachEntry:y0S,matchAll:b0S,isHTMLForm:v0S,hasOwnProperty:N3p,hasOwnProp:N3p,reduceDescriptors:W3p,freezeMethods:A0S,toObjectSet:m0S,toCamelCase:g0S,noop:P0S,toFiniteNumber:j0S,findKey:L3p,global:K7i,isContextDefined:V3p,isSpecCompliantForm:w0S,toJSONObject:E0S,isAsyncFn:S0S,isThenable:M0S,setImmediate:x3p,asap:D0S,isIterable:B0S};function jTn(e,t,r,i,n){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=e,this.name="AxiosError",t&&(this.code=t),r&&(this.config=r),i&&(this.request=i),n&&(this.response=n,this.status=n.status?n.status:null)}er.inherits(jTn,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:er.toJSONObject(this.config),code:this.code,status:this.status}}});var G3p=jTn.prototype,H3p={};["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=>{H3p[e]={value:e}});Object.defineProperties(jTn,H3p);Object.defineProperty(G3p,"isAxiosError",{value:!0});jTn.from=(e,t,r,i,n,a)=>{let o=Object.create(G3p);er.toFlatObject(e,o,function(u){return u!==Error.prototype},s=>s!=="isAxiosError");let c=e&&e.message?e.message:"Error",f=t==null&&e?e.code:t;return jTn.call(o,c,f,r,i,n),e&&o.cause==null&&Object.defineProperty(o,"cause",{value:e,configurable:!0}),o.name=e&&e.name||"Error",a&&Object.assign(o,a),o};var ha=jTn;var K3p=ue(IGi(),1),z0o=K3p.default;function D7s(e){return er.isPlainObject(e)||er.isArray(e)}function $3p(e){return er.endsWith(e,"[]")?e.slice(0,-2):e}function J3p(e,t,r){return e?e.concat(t).map(function(n,a){return n=$3p(n),!r&&a?"["+n+"]":n}).join(r?".":""):t}function I0S(e){return er.isArray(e)&&!e.some(D7s)}var C0S=er.toFlatObject(er,{},null,function(t){return/^is[A-Z]/.test(t)});function q0S(e,t,r){if(!er.isObject(e))throw new TypeError("target must be an object");t=t||new(z0o||FormData),r=er.toFlatObject(r,{metaTokens:!0,dots:!1,indexes:!1},!1,function(y,b){return!er.isUndefined(b[y])});let i=r.metaTokens,n=r.visitor||u,a=r.dots,o=r.indexes,f=(r.Blob||typeof Blob<"u"&&Blob)&&er.isSpecCompliantForm(t);if(!er.isFunction(n))throw new TypeError("visitor must be a function");function s(h){if(h===null)return"";if(er.isDate(h))return h.toISOString();if(er.isBoolean(h))return h.toString();if(!f&&er.isBlob(h))throw new ha("Blob is not supported. Use a Buffer instead.");return er.isArrayBuffer(h)||er.isTypedArray(h)?f&&typeof Blob=="function"?new Blob([h]):Buffer.from(h):h}function u(h,y,b){let v=h;if(h&&!b&&typeof h=="object"){if(er.endsWith(y,"{}"))y=i?y:y.slice(0,-2),h=JSON.stringify(h);else if(er.isArray(h)&&I0S(h)||(er.isFileList(h)||er.endsWith(y,"[]"))&&(v=er.toArray(h)))return y=$3p(y),v.forEach(function(A,g){!(er.isUndefined(A)||A===null)&&t.append(o===!0?J3p([y],g,a):o===null?y:y+"[]",s(A))}),!1}return D7s(h)?!0:(t.append(J3p(b,y,a),s(h)),!1)}let l=[],p=Object.assign(C0S,{defaultVisitor:u,convertValue:s,isVisitable:D7s});function _(h,y){if(!er.isUndefined(h)){if(l.indexOf(h)!==-1)throw Error("Circular reference detected in "+y.join("."));l.push(h),er.forEach(h,function(v,O){(!(er.isUndefined(v)||v===null)&&n.call(t,v,er.isString(O)?O.trim():O,y,p))===!0&&_(v,y?y.concat(O):[O])}),l.pop()}}if(!er.isObject(e))throw new TypeError("data must be an object");return _(e),t}var zBi=q0S;function Y3p(e){let t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(i){return t[i]})}function X3p(e,t){this._pairs=[],e&&zBi(e,this,t)}var Z3p=X3p.prototype;Z3p.append=function(t,r){this._pairs.push([t,r])};Z3p.toString=function(t){let r=t?function(i){return t.call(this,i,Y3p)}:Y3p;return this._pairs.map(function(n){return r(n[0])+"="+r(n[1])},"").join("&")};var k3p=X3p;function T0S(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function J7i(e,t,r){if(!t)return e;let i=r&&r.encode||T0S;er.isFunction(r)&&(r={serialize:r});let n=r&&r.serialize,a;if(n?a=n(t,r):a=er.isURLSearchParams(t)?t.toString():new k3p(t,r).toString(i),a){let o=e.indexOf("#");o!==-1&&(e=e.slice(0,o)),e+=(e.indexOf("?")===-1?"?":"&")+a}return e}var B7s=class{constructor(){this.handlers=[]}use(t,r,i){return this.handlers.push({fulfilled:t,rejected:r,synchronous:i?i.synchronous:!1,runWhen:i?i.runWhen:null}),this.handlers.length-1}eject(t){this.handlers[t]&&(this.handlers[t]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(t){er.forEach(this.handlers,function(i){i!==null&&t(i)})}},I7s=B7s;var wTn={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1};var i8p=ue(require("crypto"),1);var e8p=ue(require("url"),1),t8p=e8p.default.URLSearchParams;var C7s="abcdefghijklmnopqrstuvwxyz",r8p="0123456789",n8p={DIGIT:r8p,ALPHA:C7s,ALPHA_DIGIT:C7s+C7s.toUpperCase()+r8p},R0S=(e=16,t=n8p.ALPHA_DIGIT)=>{let r="",{length:i}=t,n=new Uint32Array(e);i8p.default.randomFillSync(n);for(let a=0;a<e;a++)r+=t[n[a]%i];return r},a8p={isNode:!0,classes:{URLSearchParams:t8p,FormData:z0o,Blob:typeof Blob<"u"&&Blob||null},ALPHABET:n8p,generateString:R0S,protocols:["http","https","file","data"]};var R7s={};Yt(R7s,{hasBrowserEnv:()=>T7s,hasStandardBrowserEnv:()=>z0S,hasStandardBrowserWebWorkerEnv:()=>N0S,navigator:()=>q7s,origin:()=>F0S});var T7s=typeof window<"u"&&typeof document<"u",q7s=typeof navigator=="object"&&navigator||void 0,z0S=T7s&&(!q7s||["ReactNative","NativeScript","NS"].indexOf(q7s.product)<0),N0S=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",F0S=T7s&&window.location.href||"http://localhost";var OA={...R7s,...a8p};function z7s(e,t){return zBi(e,new OA.classes.URLSearchParams,{visitor:function(r,i,n,a){return OA.isNode&&er.isBuffer(r)?(this.append(i,r.toString("base64")),!1):a.defaultVisitor.apply(this,arguments)},...t})}function Q0S(e){return er.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function U0S(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 L0S(e){function t(r,i,n,a){let o=r[a++];if(o==="__proto__")return!0;let c=Number.isFinite(+o),f=a>=r.length;return o=!o&&er.isArray(n)?n.length:o,f?(er.hasOwnProp(n,o)?n[o]=[n[o],i]:n[o]=i,!c):((!n[o]||!er.isObject(n[o]))&&(n[o]=[]),t(r,i,n[o],a)&&er.isArray(n[o])&&(n[o]=U0S(n[o])),!c)}if(er.isFormData(e)&&er.isFunction(e.entries)){let r={};return er.forEachEntry(e,(i,n)=>{t(Q0S(i),n,r,0)}),r}return null}var N0o=L0S;function V0S(e,t,r){if(er.isString(e))try{return(t||JSON.parse)(e),er.trim(e)}catch(i){if(i.name!=="SyntaxError")throw i}return(r||JSON.stringify)(e)}var N7s={transitional:wTn,adapter:["xhr","http","fetch"],transformRequest:[function(t,r){let i=r.getContentType()||"",n=i.indexOf("application/json")>-1,a=er.isObject(t);if(a&&er.isHTMLForm(t)&&(t=new FormData(t)),er.isFormData(t))return n?JSON.stringify(N0o(t)):t;if(er.isArrayBuffer(t)||er.isBuffer(t)||er.isStream(t)||er.isFile(t)||er.isBlob(t)||er.isReadableStream(t))return t;if(er.isArrayBufferView(t))return t.buffer;if(er.isURLSearchParams(t))return r.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),t.toString();let c;if(a){if(i.indexOf("application/x-www-form-urlencoded")>-1)return z7s(t,this.formSerializer).toString();if((c=er.isFileList(t))||i.indexOf("multipart/form-data")>-1){let f=this.env&&this.env.FormData;return zBi(c?{"files[]":t}:t,f&&new f,this.formSerializer)}}return a||n?(r.setContentType("application/json",!1),V0S(t)):t}],transformResponse:[function(t){let r=this.transitional||N7s.transitional,i=r&&r.forcedJSONParsing,n=this.responseType==="json";if(er.isResponse(t)||er.isReadableStream(t))return t;if(t&&er.isString(t)&&(i&&!this.responseType||n)){let o=!(r&&r.silentJSONParsing)&&n;try{return JSON.parse(t,this.parseReviver)}catch(c){if(o)throw c.name==="SyntaxError"?ha.from(c,ha.ERR_BAD_RESPONSE,this,null,this.response):c}}return t}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:OA.classes.FormData,Blob:OA.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};er.forEach(["delete","get","head","post","put","patch"],e=>{N7s.headers[e]={}});var ETn=N7s;var W0S=er.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),o8p=e=>{let t={},r,i,n;return e&&e.split(`
|
|
1150
|
+
`);for(let c=n;c<o.length;c++){let f=o[c];if(f.length>1024)continue;let s=_3p.test(f)?f.replace(_3p,"$1"):f;if(!s.match(/\S*Error: /)){for(let u of r){let l=u(s);if(l){a.push(l);break}}if(a.length>=B3p)break}}return UmS(a)}}function UmS(e){if(!e.length)return[];let t=Array.from(e);return t.reverse(),t.slice(0,B3p).map(r=>({...r,filename:r.filename||LmS(t).filename,function:r.function||I3p}))}function LmS(e){return e[e.length-1]||{}}yTn.stackParser=QmS(XAS());yTn.frameModifiers=[emS];var vTn=class extends O7s{getLibraryId(){return"posthog-node"}};var D0o=class{posthog;constructor({posthogApiKey:t}){this.posthog=new vTn(t)}async identify(){}async sendEvent(t){t.orgId!=null&&this.posthog.capture({distinctId:t.orgId,event:"CLI",properties:{...t,...t.properties,version:"3.23.2",usingAccessToken:!0}})}async flush(){await this.posthog.flush()}};var sOa=class{async sendEvent(){}async identify(){}async flush(){}};var OTn=require("fs/promises"),R3p=require("os"),z3p=require("path");var C3p=ue(require("crypto")),I0o=new Uint8Array(256),B0o=I0o.length;function j7s(){return B0o>I0o.length-16&&(C3p.default.randomFillSync(I0o),B0o=0),I0o.slice(B0o,B0o+=16)}var TQ=[];for(let e=0;e<256;++e)TQ.push((e+256).toString(16).slice(1));function q3p(e,t=0){return TQ[e[t+0]]+TQ[e[t+1]]+TQ[e[t+2]]+TQ[e[t+3]]+"-"+TQ[e[t+4]]+TQ[e[t+5]]+"-"+TQ[e[t+6]]+TQ[e[t+7]]+"-"+TQ[e[t+8]]+TQ[e[t+9]]+"-"+TQ[e[t+10]]+TQ[e[t+11]]+TQ[e[t+12]]+TQ[e[t+13]]+TQ[e[t+14]]+TQ[e[t+15]]}var T3p=ue(require("crypto")),w7s={randomUUID:T3p.default.randomUUID};function VmS(e,t,r){if(w7s.randomUUID&&!t&&!e)return w7s.randomUUID();e=e||{};let i=e.random||(e.rng||j7s)();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 q3p(i)}var ehe=VmS;var WmS="id",xmS=".fern",cOa=class{posthog;userId;constructor({token:t,posthogApiKey:r}){this.posthog=new vTn(r),this.userId=t==null?void 0:H8s(t)}async identify(){this.userId!=null&&this.posthog.alias({distinctId:this.userId,alias:await this.getPersistedDistinctId()})}async sendEvent(t){this.posthog.capture({distinctId:this.userId??await this.getPersistedDistinctId(),event:"CLI",properties:{version:"3.23.2",...t,...t.properties}})}async flush(){await this.posthog.flush()}persistedDistinctId;async getPersistedDistinctId(){if(this.persistedDistinctId==null){let t=It(Rr.of((0,R3p.homedir)()),Ze.of(xmS),Ze.of(WmS));await qi(t)||(await(0,OTn.mkdir)((0,z3p.dirname)(t),{recursive:!0}),await(0,OTn.writeFile)(t,ehe())),this.persistedDistinctId=(await(0,OTn.readFile)(t)).toString()}return this.persistedDistinctId}};var E7s;async function ATn(){return E7s==null&&(E7s=await GmS()),E7s}async function GmS(){try{let e="phc_yQgAEdJJkVpI24NdSRID2mor1x1leRpDoC9yZ9mfXal",t=process.env.FERN_DISABLE_TELEMETRY==="true";if(e==null||t)return new sOa;let r=await Jyo();return r!=null?new cOa({token:r,posthogApiKey:e}):await jqn()!=null?new D0o({posthogApiKey:e}):new cOa({token:void 0,posthogApiKey:e})}catch{return new sOa}}function lOa(e,t){return function(){return e.apply(t,arguments)}}var{toString:HmS}=Object.prototype,{getPrototypeOf:M7s}=Object,{iterator:q0o,toStringTag:F3p}=Symbol,T0o=(e=>t=>{let r=HmS.call(t);return e[r]||(e[r]=r.slice(8,-1).toLowerCase())})(Object.create(null)),NNt=e=>(e=e.toLowerCase(),t=>T0o(t)===e),R0o=e=>t=>typeof t===e,{isArray:PTn}=Array,mTn=R0o("undefined");function fOa(e){return e!==null&&!mTn(e)&&e.constructor!==null&&!mTn(e.constructor)&&BH(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}var Q3p=NNt("ArrayBuffer");function KmS(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&Q3p(e.buffer),t}var JmS=R0o("string"),BH=R0o("function"),U3p=R0o("number"),dOa=e=>e!==null&&typeof e=="object",$mS=e=>e===!0||e===!1,C0o=e=>{if(T0o(e)!=="object")return!1;let t=M7s(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(F3p in e)&&!(q0o in e)},YmS=e=>{if(!dOa(e)||fOa(e))return!1;try{return Object.keys(e).length===0&&Object.getPrototypeOf(e)===Object.prototype}catch{return!1}},XmS=NNt("Date"),ZmS=NNt("File"),kmS=NNt("Blob"),e0S=NNt("FileList"),t0S=e=>dOa(e)&&BH(e.pipe),r0S=e=>{let t;return e&&(typeof FormData=="function"&&e instanceof FormData||BH(e.append)&&((t=T0o(e))==="formdata"||t==="object"&&BH(e.toString)&&e.toString()==="[object FormData]"))},i0S=NNt("URLSearchParams"),[n0S,a0S,o0S,u0S]=["ReadableStream","Request","Response","Headers"].map(NNt),s0S=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function pOa(e,t,{allOwnKeys:r=!1}={}){if(e===null||typeof e>"u")return;let i,n;if(typeof e!="object"&&(e=[e]),PTn(e))for(i=0,n=e.length;i<n;i++)t.call(null,e[i],i,e);else{if(fOa(e))return;let a=r?Object.getOwnPropertyNames(e):Object.keys(e),o=a.length,c;for(i=0;i<o;i++)c=a[i],t.call(null,e[c],c,e)}}function L3p(e,t){if(fOa(e))return null;t=t.toLowerCase();let r=Object.keys(e),i=r.length,n;for(;i-- >0;)if(n=r[i],t===n.toLowerCase())return n;return null}var K7i=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,V3p=e=>!mTn(e)&&e!==K7i;function S7s(){let{caseless:e,skipUndefined:t}=V3p(this)&&this||{},r={},i=(n,a)=>{let o=e&&L3p(r,a)||a;C0o(r[o])&&C0o(n)?r[o]=S7s(r[o],n):C0o(n)?r[o]=S7s({},n):PTn(n)?r[o]=n.slice():(!t||!mTn(n))&&(r[o]=n)};for(let n=0,a=arguments.length;n<a;n++)arguments[n]&&pOa(arguments[n],i);return r}var c0S=(e,t,r,{allOwnKeys:i}={})=>(pOa(t,(n,a)=>{r&&BH(n)?e[a]=lOa(n,r):e[a]=n},{allOwnKeys:i}),e),l0S=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),f0S=(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)},d0S=(e,t,r,i)=>{let n,a,o,c={};if(t=t||{},e==null)return t;do{for(n=Object.getOwnPropertyNames(e),a=n.length;a-- >0;)o=n[a],(!i||i(o,e,t))&&!c[o]&&(t[o]=e[o],c[o]=!0);e=r!==!1&&M7s(e)}while(e&&(!r||r(e,t))&&e!==Object.prototype);return t},p0S=(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},_0S=e=>{if(!e)return null;if(PTn(e))return e;let t=e.length;if(!U3p(t))return null;let r=new Array(t);for(;t-- >0;)r[t]=e[t];return r},h0S=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&M7s(Uint8Array)),y0S=(e,t)=>{let i=(e&&e[q0o]).call(e),n;for(;(n=i.next())&&!n.done;){let a=n.value;t.call(e,a[0],a[1])}},b0S=(e,t)=>{let r,i=[];for(;(r=e.exec(t))!==null;)i.push(r);return i},v0S=NNt("HTMLFormElement"),g0S=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(r,i,n){return i.toUpperCase()+n}),N3p=(({hasOwnProperty:e})=>(t,r)=>e.call(t,r))(Object.prototype),O0S=NNt("RegExp"),W3p=(e,t)=>{let r=Object.getOwnPropertyDescriptors(e),i={};pOa(r,(n,a)=>{let o;(o=t(n,a,e))!==!1&&(i[a]=o||n)}),Object.defineProperties(e,i)},A0S=e=>{W3p(e,(t,r)=>{if(BH(e)&&["arguments","caller","callee"].indexOf(r)!==-1)return!1;let i=e[r];if(BH(i)){if(t.enumerable=!1,"writable"in t){t.writable=!1;return}t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+r+"'")})}})},m0S=(e,t)=>{let r={},i=n=>{n.forEach(a=>{r[a]=!0})};return PTn(e)?i(e):i(String(e).split(t)),r},P0S=()=>{},j0S=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t;function w0S(e){return!!(e&&BH(e.append)&&e[F3p]==="FormData"&&e[q0o])}var E0S=e=>{let t=new Array(10),r=(i,n)=>{if(dOa(i)){if(t.indexOf(i)>=0)return;if(fOa(i))return i;if(!("toJSON"in i)){t[n]=i;let a=PTn(i)?[]:{};return pOa(i,(o,c)=>{let f=r(o,n+1);!mTn(f)&&(a[c]=f)}),t[n]=void 0,a}}return i};return r(e,0)},S0S=NNt("AsyncFunction"),M0S=e=>e&&(dOa(e)||BH(e))&&BH(e.then)&&BH(e.catch),x3p=((e,t)=>e?setImmediate:t?((r,i)=>(K7i.addEventListener("message",({source:n,data:a})=>{n===K7i&&a===r&&i.length&&i.shift()()},!1),n=>{i.push(n),K7i.postMessage(r,"*")}))(`axios@${Math.random()}`,[]):r=>setTimeout(r))(typeof setImmediate=="function",BH(K7i.postMessage)),D0S=typeof queueMicrotask<"u"?queueMicrotask.bind(K7i):typeof process<"u"&&process.nextTick||x3p,B0S=e=>e!=null&&BH(e[q0o]),er={isArray:PTn,isArrayBuffer:Q3p,isBuffer:fOa,isFormData:r0S,isArrayBufferView:KmS,isString:JmS,isNumber:U3p,isBoolean:$mS,isObject:dOa,isPlainObject:C0o,isEmptyObject:YmS,isReadableStream:n0S,isRequest:a0S,isResponse:o0S,isHeaders:u0S,isUndefined:mTn,isDate:XmS,isFile:ZmS,isBlob:kmS,isRegExp:O0S,isFunction:BH,isStream:t0S,isURLSearchParams:i0S,isTypedArray:h0S,isFileList:e0S,forEach:pOa,merge:S7s,extend:c0S,trim:s0S,stripBOM:l0S,inherits:f0S,toFlatObject:d0S,kindOf:T0o,kindOfTest:NNt,endsWith:p0S,toArray:_0S,forEachEntry:y0S,matchAll:b0S,isHTMLForm:v0S,hasOwnProperty:N3p,hasOwnProp:N3p,reduceDescriptors:W3p,freezeMethods:A0S,toObjectSet:m0S,toCamelCase:g0S,noop:P0S,toFiniteNumber:j0S,findKey:L3p,global:K7i,isContextDefined:V3p,isSpecCompliantForm:w0S,toJSONObject:E0S,isAsyncFn:S0S,isThenable:M0S,setImmediate:x3p,asap:D0S,isIterable:B0S};function jTn(e,t,r,i,n){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=e,this.name="AxiosError",t&&(this.code=t),r&&(this.config=r),i&&(this.request=i),n&&(this.response=n,this.status=n.status?n.status:null)}er.inherits(jTn,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:er.toJSONObject(this.config),code:this.code,status:this.status}}});var G3p=jTn.prototype,H3p={};["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=>{H3p[e]={value:e}});Object.defineProperties(jTn,H3p);Object.defineProperty(G3p,"isAxiosError",{value:!0});jTn.from=(e,t,r,i,n,a)=>{let o=Object.create(G3p);er.toFlatObject(e,o,function(u){return u!==Error.prototype},s=>s!=="isAxiosError");let c=e&&e.message?e.message:"Error",f=t==null&&e?e.code:t;return jTn.call(o,c,f,r,i,n),e&&o.cause==null&&Object.defineProperty(o,"cause",{value:e,configurable:!0}),o.name=e&&e.name||"Error",a&&Object.assign(o,a),o};var ha=jTn;var K3p=ue(IGi(),1),z0o=K3p.default;function D7s(e){return er.isPlainObject(e)||er.isArray(e)}function $3p(e){return er.endsWith(e,"[]")?e.slice(0,-2):e}function J3p(e,t,r){return e?e.concat(t).map(function(n,a){return n=$3p(n),!r&&a?"["+n+"]":n}).join(r?".":""):t}function I0S(e){return er.isArray(e)&&!e.some(D7s)}var C0S=er.toFlatObject(er,{},null,function(t){return/^is[A-Z]/.test(t)});function q0S(e,t,r){if(!er.isObject(e))throw new TypeError("target must be an object");t=t||new(z0o||FormData),r=er.toFlatObject(r,{metaTokens:!0,dots:!1,indexes:!1},!1,function(y,b){return!er.isUndefined(b[y])});let i=r.metaTokens,n=r.visitor||u,a=r.dots,o=r.indexes,f=(r.Blob||typeof Blob<"u"&&Blob)&&er.isSpecCompliantForm(t);if(!er.isFunction(n))throw new TypeError("visitor must be a function");function s(h){if(h===null)return"";if(er.isDate(h))return h.toISOString();if(er.isBoolean(h))return h.toString();if(!f&&er.isBlob(h))throw new ha("Blob is not supported. Use a Buffer instead.");return er.isArrayBuffer(h)||er.isTypedArray(h)?f&&typeof Blob=="function"?new Blob([h]):Buffer.from(h):h}function u(h,y,b){let v=h;if(h&&!b&&typeof h=="object"){if(er.endsWith(y,"{}"))y=i?y:y.slice(0,-2),h=JSON.stringify(h);else if(er.isArray(h)&&I0S(h)||(er.isFileList(h)||er.endsWith(y,"[]"))&&(v=er.toArray(h)))return y=$3p(y),v.forEach(function(A,g){!(er.isUndefined(A)||A===null)&&t.append(o===!0?J3p([y],g,a):o===null?y:y+"[]",s(A))}),!1}return D7s(h)?!0:(t.append(J3p(b,y,a),s(h)),!1)}let l=[],p=Object.assign(C0S,{defaultVisitor:u,convertValue:s,isVisitable:D7s});function _(h,y){if(!er.isUndefined(h)){if(l.indexOf(h)!==-1)throw Error("Circular reference detected in "+y.join("."));l.push(h),er.forEach(h,function(v,O){(!(er.isUndefined(v)||v===null)&&n.call(t,v,er.isString(O)?O.trim():O,y,p))===!0&&_(v,y?y.concat(O):[O])}),l.pop()}}if(!er.isObject(e))throw new TypeError("data must be an object");return _(e),t}var zBi=q0S;function Y3p(e){let t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(i){return t[i]})}function X3p(e,t){this._pairs=[],e&&zBi(e,this,t)}var Z3p=X3p.prototype;Z3p.append=function(t,r){this._pairs.push([t,r])};Z3p.toString=function(t){let r=t?function(i){return t.call(this,i,Y3p)}:Y3p;return this._pairs.map(function(n){return r(n[0])+"="+r(n[1])},"").join("&")};var k3p=X3p;function T0S(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function J7i(e,t,r){if(!t)return e;let i=r&&r.encode||T0S;er.isFunction(r)&&(r={serialize:r});let n=r&&r.serialize,a;if(n?a=n(t,r):a=er.isURLSearchParams(t)?t.toString():new k3p(t,r).toString(i),a){let o=e.indexOf("#");o!==-1&&(e=e.slice(0,o)),e+=(e.indexOf("?")===-1?"?":"&")+a}return e}var B7s=class{constructor(){this.handlers=[]}use(t,r,i){return this.handlers.push({fulfilled:t,rejected:r,synchronous:i?i.synchronous:!1,runWhen:i?i.runWhen:null}),this.handlers.length-1}eject(t){this.handlers[t]&&(this.handlers[t]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(t){er.forEach(this.handlers,function(i){i!==null&&t(i)})}},I7s=B7s;var wTn={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1};var i8p=ue(require("crypto"),1);var e8p=ue(require("url"),1),t8p=e8p.default.URLSearchParams;var C7s="abcdefghijklmnopqrstuvwxyz",r8p="0123456789",n8p={DIGIT:r8p,ALPHA:C7s,ALPHA_DIGIT:C7s+C7s.toUpperCase()+r8p},R0S=(e=16,t=n8p.ALPHA_DIGIT)=>{let r="",{length:i}=t,n=new Uint32Array(e);i8p.default.randomFillSync(n);for(let a=0;a<e;a++)r+=t[n[a]%i];return r},a8p={isNode:!0,classes:{URLSearchParams:t8p,FormData:z0o,Blob:typeof Blob<"u"&&Blob||null},ALPHABET:n8p,generateString:R0S,protocols:["http","https","file","data"]};var R7s={};Yt(R7s,{hasBrowserEnv:()=>T7s,hasStandardBrowserEnv:()=>z0S,hasStandardBrowserWebWorkerEnv:()=>N0S,navigator:()=>q7s,origin:()=>F0S});var T7s=typeof window<"u"&&typeof document<"u",q7s=typeof navigator=="object"&&navigator||void 0,z0S=T7s&&(!q7s||["ReactNative","NativeScript","NS"].indexOf(q7s.product)<0),N0S=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",F0S=T7s&&window.location.href||"http://localhost";var OA={...R7s,...a8p};function z7s(e,t){return zBi(e,new OA.classes.URLSearchParams,{visitor:function(r,i,n,a){return OA.isNode&&er.isBuffer(r)?(this.append(i,r.toString("base64")),!1):a.defaultVisitor.apply(this,arguments)},...t})}function Q0S(e){return er.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function U0S(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 L0S(e){function t(r,i,n,a){let o=r[a++];if(o==="__proto__")return!0;let c=Number.isFinite(+o),f=a>=r.length;return o=!o&&er.isArray(n)?n.length:o,f?(er.hasOwnProp(n,o)?n[o]=[n[o],i]:n[o]=i,!c):((!n[o]||!er.isObject(n[o]))&&(n[o]=[]),t(r,i,n[o],a)&&er.isArray(n[o])&&(n[o]=U0S(n[o])),!c)}if(er.isFormData(e)&&er.isFunction(e.entries)){let r={};return er.forEachEntry(e,(i,n)=>{t(Q0S(i),n,r,0)}),r}return null}var N0o=L0S;function V0S(e,t,r){if(er.isString(e))try{return(t||JSON.parse)(e),er.trim(e)}catch(i){if(i.name!=="SyntaxError")throw i}return(r||JSON.stringify)(e)}var N7s={transitional:wTn,adapter:["xhr","http","fetch"],transformRequest:[function(t,r){let i=r.getContentType()||"",n=i.indexOf("application/json")>-1,a=er.isObject(t);if(a&&er.isHTMLForm(t)&&(t=new FormData(t)),er.isFormData(t))return n?JSON.stringify(N0o(t)):t;if(er.isArrayBuffer(t)||er.isBuffer(t)||er.isStream(t)||er.isFile(t)||er.isBlob(t)||er.isReadableStream(t))return t;if(er.isArrayBufferView(t))return t.buffer;if(er.isURLSearchParams(t))return r.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),t.toString();let c;if(a){if(i.indexOf("application/x-www-form-urlencoded")>-1)return z7s(t,this.formSerializer).toString();if((c=er.isFileList(t))||i.indexOf("multipart/form-data")>-1){let f=this.env&&this.env.FormData;return zBi(c?{"files[]":t}:t,f&&new f,this.formSerializer)}}return a||n?(r.setContentType("application/json",!1),V0S(t)):t}],transformResponse:[function(t){let r=this.transitional||N7s.transitional,i=r&&r.forcedJSONParsing,n=this.responseType==="json";if(er.isResponse(t)||er.isReadableStream(t))return t;if(t&&er.isString(t)&&(i&&!this.responseType||n)){let o=!(r&&r.silentJSONParsing)&&n;try{return JSON.parse(t,this.parseReviver)}catch(c){if(o)throw c.name==="SyntaxError"?ha.from(c,ha.ERR_BAD_RESPONSE,this,null,this.response):c}}return t}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:OA.classes.FormData,Blob:OA.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};er.forEach(["delete","get","head","post","put","patch"],e=>{N7s.headers[e]={}});var ETn=N7s;var W0S=er.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),o8p=e=>{let t={},r,i,n;return e&&e.split(`
|
|
1151
1151
|
`).forEach(function(o){n=o.indexOf(":"),r=o.substring(0,n).trim().toLowerCase(),i=o.substring(n+1).trim(),!(!r||t[r]&&W0S[r])&&(r==="set-cookie"?t[r]?t[r].push(i):t[r]=[i]:t[r]=t[r]?t[r]+", "+i:i)}),t};var u8p=Symbol("internals");function _Oa(e){return e&&String(e).trim().toLowerCase()}function F0o(e){return e===!1||e==null?e:er.isArray(e)?e.map(F0o):String(e)}function x0S(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 G0S=e=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim());function F7s(e,t,r,i,n){if(er.isFunction(i))return i.call(this,t,r);if(n&&(t=r),!!er.isString(t)){if(er.isString(i))return t.indexOf(i)!==-1;if(er.isRegExp(i))return i.test(t)}}function H0S(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(t,r,i)=>r.toUpperCase()+i)}function K0S(e,t){let r=er.toCamelCase(" "+t);["get","set","has"].forEach(i=>{Object.defineProperty(e,i+r,{value:function(n,a,o){return this[i].call(this,t,n,a,o)},configurable:!0})})}var STn=class{constructor(t){t&&this.set(t)}set(t,r,i){let n=this;function a(c,f,s){let u=_Oa(f);if(!u)throw new Error("header name must be a non-empty string");let l=er.findKey(n,u);(!l||n[l]===void 0||s===!0||s===void 0&&n[l]!==!1)&&(n[l||f]=F0o(c))}let o=(c,f)=>er.forEach(c,(s,u)=>a(s,u,f));if(er.isPlainObject(t)||t instanceof this.constructor)o(t,r);else if(er.isString(t)&&(t=t.trim())&&!G0S(t))o(o8p(t),r);else if(er.isObject(t)&&er.isIterable(t)){let c={},f,s;for(let u of t){if(!er.isArray(u))throw TypeError("Object iterator must return a key-value pair");c[s=u[0]]=(f=c[s])?er.isArray(f)?[...f,u[1]]:[f,u[1]]:u[1]}o(c,r)}else t!=null&&a(r,t,i);return this}get(t,r){if(t=_Oa(t),t){let i=er.findKey(this,t);if(i){let n=this[i];if(!r)return n;if(r===!0)return x0S(n);if(er.isFunction(r))return r.call(this,n,i);if(er.isRegExp(r))return r.exec(n);throw new TypeError("parser must be boolean|regexp|function")}}}has(t,r){if(t=_Oa(t),t){let i=er.findKey(this,t);return!!(i&&this[i]!==void 0&&(!r||F7s(this,this[i],i,r)))}return!1}delete(t,r){let i=this,n=!1;function a(o){if(o=_Oa(o),o){let c=er.findKey(i,o);c&&(!r||F7s(i,i[c],c,r))&&(delete i[c],n=!0)}}return er.isArray(t)?t.forEach(a):a(t),n}clear(t){let r=Object.keys(this),i=r.length,n=!1;for(;i--;){let a=r[i];(!t||F7s(this,this[a],a,t,!0))&&(delete this[a],n=!0)}return n}normalize(t){let r=this,i={};return er.forEach(this,(n,a)=>{let o=er.findKey(i,a);if(o){r[o]=F0o(n),delete r[a];return}let c=t?H0S(a):String(a).trim();c!==a&&delete r[a],r[c]=F0o(n),i[c]=!0}),this}concat(...t){return this.constructor.concat(this,...t)}toJSON(t){let r=Object.create(null);return er.forEach(this,(i,n)=>{i!=null&&i!==!1&&(r[n]=t&&er.isArray(i)?i.join(", "):i)}),r}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([t,r])=>t+": "+r).join(`
|
|
1152
1152
|
`)}getSetCookie(){return this.get("set-cookie")||[]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(t){return t instanceof this?t:new this(t)}static concat(t,...r){let i=new this(t);return r.forEach(n=>i.set(n)),i}static accessor(t){let i=(this[u8p]=this[u8p]={accessors:{}}).accessors,n=this.prototype;function a(o){let c=_Oa(o);i[c]||(K0S(n,o),i[c]=!0)}return er.isArray(t)?t.forEach(a):a(t),this}};STn.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]);er.reduceDescriptors(STn.prototype,({value:e},t)=>{let r=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(i){this[r]=i}}});er.freezeMethods(STn);var QS=STn;function hOa(e,t){let r=this||ETn,i=t||r,n=QS.from(i.headers),a=i.data;return er.forEach(e,function(c){a=c.call(r,a,n.normalize(),t?t.status:void 0)}),n.normalize(),a}function yOa(e){return!!(e&&e.__CANCEL__)}function s8p(e,t,r){ha.call(this,e??"canceled",ha.ERR_CANCELED,t,r),this.name="CanceledError"}er.inherits(s8p,ha,{__CANCEL__:!0});var the=s8p;function o6t(e,t,r){let i=r.config.validateStatus;!r.status||!i||i(r.status)?e(r):t(new ha("Request failed with status code "+r.status,[ha.ERR_BAD_REQUEST,ha.ERR_BAD_RESPONSE][Math.floor(r.status/100)-4],r.config,r.request,r))}function Q7s(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function U7s(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}function $7i(e,t,r){let i=!Q7s(t);return e&&(i||r==!1)?U7s(e,t):t}var j8p=ue(a0o(),1),w8p=ue(require("http"),1),E8p=ue(require("https"),1),S8p=ue(require("util"),1),M8p=ue(LGs(),1),Ubi=ue(require("zlib"),1);var Y7i="1.12.2";function bOa(e){let t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}var J0S=/^(?:([^;]+);)?(?:[^;]+;)?(base64|),([\s\S]*)$/;function L7s(e,t,r){let i=r&&r.Blob||OA.classes.Blob,n=bOa(e);if(t===void 0&&i&&(t=!0),n==="data"){e=n.length?e.slice(n.length+1):e;let a=J0S.exec(e);if(!a)throw new ha("Invalid URL",ha.ERR_INVALID_URL);let o=a[1],c=a[2],f=a[3],s=Buffer.from(decodeURIComponent(f),c?"base64":"utf8");if(t){if(!i)throw new ha("Blob is not supported",ha.ERR_NOT_SUPPORT);return new i([s],{type:o})}return s}throw new ha("Unsupported protocol "+n,ha.ERR_NOT_SUPPORT)}var Z7i=ue(require("stream"),1);var c8p=ue(require("stream"),1);var V7s=Symbol("internals"),W7s=class extends c8p.default.Transform{constructor(t){t=er.toFlatObject(t,{maxRate:0,chunkSize:64*1024,minChunkSize:100,timeWindow:500,ticksRate:2,samplesCount:15},null,(i,n)=>!er.isUndefined(n[i])),super({readableHighWaterMark:t.chunkSize});let r=this[V7s]={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[V7s];return r.onReadCallback&&r.onReadCallback(),super._read(t)}_transform(t,r,i){let n=this[V7s],a=n.maxRate,o=this.readableHighWaterMark,c=n.timeWindow,f=1e3/c,s=a/f,u=n.minChunkSize!==!1?Math.max(n.minChunkSize,s*.01):0,l=(_,h)=>{let y=Buffer.byteLength(_);n.bytesSeen+=y,n.bytes+=y,n.isCaptured&&this.emit("progress",n.bytesSeen),this.push(_)?process.nextTick(h):n.onReadCallback=()=>{n.onReadCallback=null,process.nextTick(h)}},p=(_,h)=>{let y=Buffer.byteLength(_),b=null,v=o,O,A=0;if(a){let g=Date.now();(!n.ts||(A=g-n.ts)>=c)&&(n.ts=g,O=s-n.bytes,n.bytes=O<0?-O:0,A=0),O=s-n.bytes}if(a){if(O<=0)return setTimeout(()=>{h(null,_)},c-A);O<v&&(v=O)}v&&y>v&&y-v>u&&(b=_.subarray(v),_=_.subarray(0,v)),l(_,b?()=>{process.nextTick(h,null,b)}:h)};p(t,function _(h,y){if(h)return i(h);y?p(y,_):i(null)})}},x7s=W7s;var D8p=require("events");var f8p=ue(require("util"),1),d8p=require("stream");var{asyncIterator:l8p}=Symbol,$0S=async function*(e){e.stream?yield*e.stream():e.arrayBuffer?yield await e.arrayBuffer():e[l8p]?yield*e[l8p]():yield e},Q0o=$0S;var Y0S=OA.ALPHABET.ALPHA_DIGIT+"-_",vOa=typeof TextEncoder=="function"?new TextEncoder:new f8p.default.TextEncoder,X7i=`\r
|
|
1153
1153
|
`,X0S=vOa.encode(X7i),Z0S=2,G7s=class{constructor(t,r){let{escapeName:i}=this.constructor,n=er.isString(r),a=`Content-Disposition: form-data; name="${i(t)}"${!n&&r.name?`; filename="${i(r.name)}"`:""}${X7i}`;n?r=vOa.encode(String(r).replace(/\r?\n|\r\n?/g,X7i)):a+=`Content-Type: ${r.type||"application/octet-stream"}${X7i}`,this.headers=vOa.encode(a+X7i),this.contentLength=n?r.byteLength:r.size,this.size=this.headers.byteLength+this.contentLength+Z0S,this.name=t,this.value=r}async*encode(){yield this.headers;let{value:t}=this;er.isTypedArray(t)?yield t:yield*Q0o(t),yield X0S}static escapeName(t){return String(t).replace(/[\r\n"]/g,r=>({"\r":"%0D","\n":"%0A",'"':"%22"})[r])}},k0S=(e,t,r)=>{let{tag:i="form-data-boundary",size:n=25,boundary:a=i+"-"+OA.generateString(n,Y0S)}=r||{};if(!er.isFormData(e))throw TypeError("FormData instance required");if(a.length<1||a.length>70)throw Error("boundary must be 10-70 characters long");let o=vOa.encode("--"+a+X7i),c=vOa.encode("--"+a+"--"+X7i),f=c.byteLength,s=Array.from(e.entries()).map(([l,p])=>{let _=new G7s(l,p);return f+=_.size,_});f+=o.byteLength*s.length,f=er.toFiniteNumber(f);let u={"Content-Type":`multipart/form-data; boundary=${a}`};return Number.isFinite(f)&&(u["Content-Length"]=f),t&&t(u),d8p.Readable.from((async function*(){for(let l of s)yield o,yield*l.encode();yield c})())},p8p=k0S;var _8p=ue(require("stream"),1),H7s=class extends _8p.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)}},h8p=H7s;var ePS=(e,t)=>er.isAsyncFn(e)?function(...r){let i=r.pop();e.apply(this,r).then(n=>{try{t?i(null,...t(n)):i(null,n)}catch(a){i(a)}},i)}:e,y8p=ePS;function tPS(e,t){e=e||10;let r=new Array(e),i=new Array(e),n=0,a=0,o;return t=t!==void 0?t:1e3,function(f){let s=Date.now(),u=i[a];o||(o=s),r[n]=f,i[n]=s;let l=a,p=0;for(;l!==n;)p+=r[l++],l=l%e;if(n=(n+1)%e,n===a&&(a=(a+1)%e),s-o<t)return;let _=u&&s-u;return _?Math.round(p*1e3/_):void 0}}var b8p=tPS;function rPS(e,t){let r=0,i=1e3/t,n,a,o=(s,u=Date.now())=>{r=u,n=null,a&&(clearTimeout(a),a=null),e(...s)};return[(...s)=>{let u=Date.now(),l=u-r;l>=i?o(s,u):(n=s,a||(a=setTimeout(()=>{a=null,o(n)},i-l)))},()=>n&&o(n)]}var v8p=rPS;var Qbi=(e,t,r=3)=>{let i=0,n=b8p(50,250);return v8p(a=>{let o=a.loaded,c=a.lengthComputable?a.total:void 0,f=o-i,s=n(f),u=o<=c;i=o;let l={loaded:o,total:c,progress:c?o/c:void 0,bytes:f,rate:s||void 0,estimated:s&&c&&u?(c-o)/s:void 0,event:a,lengthComputable:c!=null,[t?"download":"upload"]:!0};e(l)},r)},MTn=(e,t)=>{let r=e!=null;return[i=>t[0]({lengthComputable:r,total:e,loaded:i}),t[1]]},DTn=e=>(...t)=>er.asap(()=>e(...t));function K7s(e){if(!e||typeof e!="string"||!e.startsWith("data:"))return 0;let t=e.indexOf(",");if(t<0)return 0;let r=e.slice(5,t),i=e.slice(t+1);if(/;base64/i.test(r)){let a=i.length,o=i.length;for(let p=0;p<o;p++)if(i.charCodeAt(p)===37&&p+2<o){let _=i.charCodeAt(p+1),h=i.charCodeAt(p+2);(_>=48&&_<=57||_>=65&&_<=70||_>=97&&_<=102)&&(h>=48&&h<=57||h>=65&&h<=70||h>=97&&h<=102)&&(a-=2,p+=2)}let c=0,f=o-1,s=p=>p>=2&&i.charCodeAt(p-2)===37&&i.charCodeAt(p-1)===51&&(i.charCodeAt(p)===68||i.charCodeAt(p)===100);f>=0&&(i.charCodeAt(f)===61?(c++,f--):s(f)&&(c++,f-=3)),c===1&&f>=0&&(i.charCodeAt(f)===61||s(f))&&c++;let l=Math.floor(a/4)*3-(c||0);return l>0?l:0}return Buffer.byteLength(i,"utf8")}var g8p={flush:Ubi.default.constants.Z_SYNC_FLUSH,finishFlush:Ubi.default.constants.Z_SYNC_FLUSH},iPS={flush:Ubi.default.constants.BROTLI_OPERATION_FLUSH,finishFlush:Ubi.default.constants.BROTLI_OPERATION_FLUSH},O8p=er.isFunction(Ubi.default.createBrotliDecompress),{http:nPS,https:aPS}=M8p.default,oPS=/https:?/,A8p=OA.protocols.map(e=>e+":"),m8p=(e,[t,r])=>(e.on("end",r).on("error",r),t);function uPS(e,t){e.beforeRedirects.proxy&&e.beforeRedirects.proxy(e),e.beforeRedirects.config&&e.beforeRedirects.config(e,t)}function B8p(e,t,r){let i=t;if(!i&&i!==!1){let n=j8p.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){B8p(a,t,a.href)}}var sPS=typeof process<"u"&&er.kindOf(process)==="process",cPS=e=>new Promise((t,r)=>{let i,n,a=(f,s)=>{n||(n=!0,i&&i(f,s))},o=f=>{a(f),t(f)},c=f=>{a(f,!0),r(f)};e(o,c,f=>i=f).catch(c)}),lPS=({address:e,family:t})=>{if(!er.isString(e))throw TypeError("address must be a string");return{address:e,family:t||(e.indexOf(".")<0?6:4)}},P8p=(e,t)=>lPS(er.isObject(e)?e:{address:e,family:t}),I8p=sPS&&function(t){return cPS(async function(i,n,a){let{data:o,lookup:c,family:f}=t,{responseType:s,responseEncoding:u}=t,l=t.method.toUpperCase(),p,_=!1,h;if(c){let K=y8p(c,fe=>er.isArray(fe)?fe:[fe]);c=(fe,pe,L)=>{K(fe,pe,(G,Re,le)=>{if(G)return L(G);let De=er.isArray(Re)?Re.map(Ke=>P8p(Ke)):[P8p(Re,le)];pe.all?L(G,De):L(G,De[0].address,De[0].family)})}}let y=new D8p.EventEmitter,b=()=>{t.cancelToken&&t.cancelToken.unsubscribe(v),t.signal&&t.signal.removeEventListener("abort",v),y.removeAllListeners()};a((K,fe)=>{p=!0,fe&&(_=!0,b())});function v(K){y.emit("abort",!K||K.type?new the(null,t,h):K)}y.once("abort",n),(t.cancelToken||t.signal)&&(t.cancelToken&&t.cancelToken.subscribe(v),t.signal&&(t.signal.aborted?v():t.signal.addEventListener("abort",v)));let O=$7i(t.baseURL,t.url,t.allowAbsoluteUrls),A=new URL(O,OA.hasBrowserEnv?OA.origin:void 0),g=A.protocol||A8p[0];if(g==="data:"){if(t.maxContentLength>-1){let fe=String(t.url||O||"");if(K7s(fe)>t.maxContentLength)return n(new ha("maxContentLength size of "+t.maxContentLength+" exceeded",ha.ERR_BAD_RESPONSE,t))}let K;if(l!=="GET")return o6t(i,n,{status:405,statusText:"method not allowed",headers:{},config:t});try{K=L7s(t.url,s==="blob",{Blob:t.env&&t.env.Blob})}catch(fe){throw ha.from(fe,ha.ERR_BAD_REQUEST,t)}return s==="text"?(K=K.toString(u),(!u||u==="utf8")&&(K=er.stripBOM(K))):s==="stream"&&(K=Z7i.default.Readable.from(K)),o6t(i,n,{data:K,status:200,statusText:"OK",headers:new QS,config:t})}if(A8p.indexOf(g)===-1)return n(new ha("Unsupported protocol "+g,ha.ERR_BAD_REQUEST,t));let m=QS.from(t.headers).normalize();m.set("User-Agent","axios/"+Y7i,!1);let{onUploadProgress:j,onDownloadProgress:M}=t,E=t.maxRate,D,B;if(er.isSpecCompliantForm(o)){let K=m.getContentType(/boundary=([-_\w\d]{10,70})/i);o=p8p(o,fe=>{m.set(fe)},{tag:`axios-${Y7i}-boundary`,boundary:K&&K[1]||void 0})}else if(er.isFormData(o)&&er.isFunction(o.getHeaders)){if(m.set(o.getHeaders()),!m.hasContentLength())try{let K=await S8p.default.promisify(o.getLength).call(o);Number.isFinite(K)&&K>=0&&m.setContentLength(K)}catch{}}else if(er.isBlob(o)||er.isFile(o))o.size&&m.setContentType(o.type||"application/octet-stream"),m.setContentLength(o.size||0),o=Z7i.default.Readable.from(Q0o(o));else if(o&&!er.isStream(o)){if(!Buffer.isBuffer(o))if(er.isArrayBuffer(o))o=Buffer.from(new Uint8Array(o));else if(er.isString(o))o=Buffer.from(o,"utf-8");else return n(new ha("Data after transformation must be a string, an ArrayBuffer, a Buffer, or a Stream",ha.ERR_BAD_REQUEST,t));if(m.setContentLength(o.length,!1),t.maxBodyLength>-1&&o.length>t.maxBodyLength)return n(new ha("Request body larger than maxBodyLength limit",ha.ERR_BAD_REQUEST,t))}let F=er.toFiniteNumber(m.getContentLength());er.isArray(E)?(D=E[0],B=E[1]):D=B=E,o&&(j||D)&&(er.isStream(o)||(o=Z7i.default.Readable.from(o,{objectMode:!1})),o=Z7i.default.pipeline([o,new x7s({maxRate:er.toFiniteNumber(D)})],er.noop),j&&o.on("progress",m8p(o,MTn(F,Qbi(DTn(j),!1,3)))));let N;if(t.auth){let K=t.auth.username||"",fe=t.auth.password||"";N=K+":"+fe}if(!N&&A.username){let K=A.username,fe=A.password;N=K+":"+fe}N&&m.delete("authorization");let R;try{R=J7i(A.pathname+A.search,t.params,t.paramsSerializer).replace(/^\?/,"")}catch(K){let fe=new Error(K.message);return fe.config=t,fe.url=t.url,fe.exists=!0,n(fe)}m.set("Accept-Encoding","gzip, compress, deflate"+(O8p?", br":""),!1);let z={path:R,method:l,headers:m.toJSON(),agents:{http:t.httpAgent,https:t.httpsAgent},auth:N,protocol:g,family:f,beforeRedirect:uPS,beforeRedirects:{}};!er.isUndefined(c)&&(z.lookup=c),t.socketPath?z.socketPath=t.socketPath:(z.hostname=A.hostname.startsWith("[")?A.hostname.slice(1,-1):A.hostname,z.port=A.port,B8p(z,t.proxy,g+"//"+A.hostname+(A.port?":"+A.port:"")+z.path));let U,W=oPS.test(z.protocol);if(z.agent=W?t.httpsAgent:t.httpAgent,t.transport?U=t.transport:t.maxRedirects===0?U=W?E8p.default:w8p.default:(t.maxRedirects&&(z.maxRedirects=t.maxRedirects),t.beforeRedirect&&(z.beforeRedirects.config=t.beforeRedirect),U=W?aPS:nPS),t.maxBodyLength>-1?z.maxBodyLength=t.maxBodyLength:z.maxBodyLength=1/0,t.insecureHTTPParser&&(z.insecureHTTPParser=t.insecureHTTPParser),h=U.request(z,function(fe){if(h.destroyed)return;let pe=[fe],L=+fe.headers["content-length"];if(M||B){let Ke=new x7s({maxRate:er.toFiniteNumber(B)});M&&Ke.on("progress",m8p(Ke,MTn(L,Qbi(DTn(M),!0,3)))),pe.push(Ke)}let G=fe,Re=fe.req||h;if(t.decompress!==!1&&fe.headers["content-encoding"])switch((l==="HEAD"||fe.statusCode===204)&&delete fe.headers["content-encoding"],(fe.headers["content-encoding"]||"").toLowerCase()){case"gzip":case"x-gzip":case"compress":case"x-compress":pe.push(Ubi.default.createUnzip(g8p)),delete fe.headers["content-encoding"];break;case"deflate":pe.push(new h8p),pe.push(Ubi.default.createUnzip(g8p)),delete fe.headers["content-encoding"];break;case"br":O8p&&(pe.push(Ubi.default.createBrotliDecompress(iPS)),delete fe.headers["content-encoding"])}G=pe.length>1?Z7i.default.pipeline(pe,er.noop):pe[0];let le=Z7i.default.finished(G,()=>{le(),b()}),De={status:fe.statusCode,statusText:fe.statusMessage,headers:new QS(fe.headers),config:t,request:Re};if(s==="stream")De.data=G,o6t(i,n,De);else{let Ke=[],se=0;G.on("data",function(Je){Ke.push(Je),se+=Je.length,t.maxContentLength>-1&&se>t.maxContentLength&&(_=!0,G.destroy(),n(new ha("maxContentLength size of "+t.maxContentLength+" exceeded",ha.ERR_BAD_RESPONSE,t,Re)))}),G.on("aborted",function(){if(_)return;let Je=new ha("stream has been aborted",ha.ERR_BAD_RESPONSE,t,Re);G.destroy(Je),n(Je)}),G.on("error",function(Je){h.destroyed||n(ha.from(Je,null,t,Re))}),G.on("end",function(){try{let Je=Ke.length===1?Ke[0]:Buffer.concat(Ke);s!=="arraybuffer"&&(Je=Je.toString(u),(!u||u==="utf8")&&(Je=er.stripBOM(Je))),De.data=Je}catch(Je){return n(ha.from(Je,null,t,De.request,De))}o6t(i,n,De)})}y.once("abort",Ke=>{G.destroyed||(G.emit("error",Ke),G.destroy())})}),y.once("abort",K=>{n(K),h.destroy(K)}),h.on("error",function(fe){n(ha.from(fe,null,t,h))}),h.on("socket",function(fe){fe.setKeepAlive(!0,1e3*60)}),t.timeout){let K=parseInt(t.timeout,10);if(Number.isNaN(K)){n(new ha("error trying to parse `config.timeout` to int",ha.ERR_BAD_OPTION_VALUE,t,h));return}h.setTimeout(K,function(){if(p)return;let pe=t.timeout?"timeout of "+t.timeout+"ms exceeded":"timeout exceeded",L=t.transitional||wTn;t.timeoutErrorMessage&&(pe=t.timeoutErrorMessage),n(new ha(pe,L.clarifyTimeoutError?ha.ETIMEDOUT:ha.ECONNABORTED,t,h)),v()})}if(er.isStream(o)){let K=!1,fe=!1;o.on("end",()=>{K=!0}),o.once("error",pe=>{fe=!0,h.destroy(pe)}),o.on("close",()=>{!K&&!fe&&v(new the("Request stream has been aborted",t,h))}),o.pipe(h)}else h.end(o)})};var C8p=OA.hasStandardBrowserEnv?((e,t)=>r=>(r=new URL(r,OA.origin),e.protocol===r.protocol&&e.host===r.host&&(t||e.port===r.port)))(new URL(OA.origin),OA.navigator&&/(msie|trident)/i.test(OA.navigator.userAgent)):()=>!0;var q8p=OA.hasStandardBrowserEnv?{write(e,t,r,i,n,a){let o=[e+"="+encodeURIComponent(t)];er.isNumber(r)&&o.push("expires="+new Date(r).toGMTString()),er.isString(i)&&o.push("path="+i),er.isString(n)&&o.push("domain="+n),a===!0&&o.push("secure"),document.cookie=o.join("; ")},read(e){let t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove(e){this.write(e,"",Date.now()-864e5)}}:{write(){},read(){return null},remove(){}};var T8p=e=>e instanceof QS?{...e}:e;function FNt(e,t){t=t||{};let r={};function i(s,u,l,p){return er.isPlainObject(s)&&er.isPlainObject(u)?er.merge.call({caseless:p},s,u):er.isPlainObject(u)?er.merge({},u):er.isArray(u)?u.slice():u}function n(s,u,l,p){if(er.isUndefined(u)){if(!er.isUndefined(s))return i(void 0,s,l,p)}else return i(s,u,l,p)}function a(s,u){if(!er.isUndefined(u))return i(void 0,u)}function o(s,u){if(er.isUndefined(u)){if(!er.isUndefined(s))return i(void 0,s)}else return i(void 0,u)}function c(s,u,l){if(l in t)return i(s,u);if(l in e)return i(void 0,s)}let f={url:a,method:a,data:a,baseURL:o,transformRequest:o,transformResponse:o,paramsSerializer:o,timeout:o,timeoutMessage:o,withCredentials:o,withXSRFToken:o,adapter:o,responseType:o,xsrfCookieName:o,xsrfHeaderName:o,onUploadProgress:o,onDownloadProgress:o,decompress:o,maxContentLength:o,maxBodyLength:o,beforeRedirect:o,transport:o,httpAgent:o,httpsAgent:o,cancelToken:o,socketPath:o,responseEncoding:o,validateStatus:c,headers:(s,u,l)=>n(T8p(s),T8p(u),l,!0)};return er.forEach(Object.keys({...e,...t}),function(u){let l=f[u]||n,p=l(e[u],t[u],u);er.isUndefined(p)&&l!==c||(r[u]=p)}),r}var U0o=e=>{let t=FNt({},e),{data:r,withXSRFToken:i,xsrfHeaderName:n,xsrfCookieName:a,headers:o,auth:c}=t;if(t.headers=o=QS.from(o),t.url=J7i($7i(t.baseURL,t.url,t.allowAbsoluteUrls),e.params,e.paramsSerializer),c&&o.set("Authorization","Basic "+btoa((c.username||"")+":"+(c.password?unescape(encodeURIComponent(c.password)):""))),er.isFormData(r)){if(OA.hasStandardBrowserEnv||OA.hasStandardBrowserWebWorkerEnv)o.setContentType(void 0);else if(er.isFunction(r.getHeaders)){let f=r.getHeaders(),s=["content-type","content-length"];Object.entries(f).forEach(([u,l])=>{s.includes(u.toLowerCase())&&o.set(u,l)})}}if(OA.hasStandardBrowserEnv&&(i&&er.isFunction(i)&&(i=i(t)),i||i!==!1&&C8p(t.url))){let f=n&&a&&q8p.read(a);f&&o.set(n,f)}return t};var fPS=typeof XMLHttpRequest<"u",R8p=fPS&&function(e){return new Promise(function(r,i){let n=U0o(e),a=n.data,o=QS.from(n.headers).normalize(),{responseType:c,onUploadProgress:f,onDownloadProgress:s}=n,u,l,p,_,h;function y(){_&&_(),h&&h(),n.cancelToken&&n.cancelToken.unsubscribe(u),n.signal&&n.signal.removeEventListener("abort",u)}let b=new XMLHttpRequest;b.open(n.method.toUpperCase(),n.url,!0),b.timeout=n.timeout;function v(){if(!b)return;let A=QS.from("getAllResponseHeaders"in b&&b.getAllResponseHeaders()),m={data:!c||c==="text"||c==="json"?b.responseText:b.response,status:b.status,statusText:b.statusText,headers:A,config:e,request:b};o6t(function(M){r(M),y()},function(M){i(M),y()},m),b=null}"onloadend"in b?b.onloadend=v:b.onreadystatechange=function(){!b||b.readyState!==4||b.status===0&&!(b.responseURL&&b.responseURL.indexOf("file:")===0)||setTimeout(v)},b.onabort=function(){b&&(i(new ha("Request aborted",ha.ECONNABORTED,e,b)),b=null)},b.onerror=function(g){let m=g&&g.message?g.message:"Network Error",j=new ha(m,ha.ERR_NETWORK,e,b);j.event=g||null,i(j),b=null},b.ontimeout=function(){let g=n.timeout?"timeout of "+n.timeout+"ms exceeded":"timeout exceeded",m=n.transitional||wTn;n.timeoutErrorMessage&&(g=n.timeoutErrorMessage),i(new ha(g,m.clarifyTimeoutError?ha.ETIMEDOUT:ha.ECONNABORTED,e,b)),b=null},a===void 0&&o.setContentType(null),"setRequestHeader"in b&&er.forEach(o.toJSON(),function(g,m){b.setRequestHeader(m,g)}),er.isUndefined(n.withCredentials)||(b.withCredentials=!!n.withCredentials),c&&c!=="json"&&(b.responseType=n.responseType),s&&([p,h]=Qbi(s,!0),b.addEventListener("progress",p)),f&&b.upload&&([l,_]=Qbi(f),b.upload.addEventListener("progress",l),b.upload.addEventListener("loadend",_)),(n.cancelToken||n.signal)&&(u=A=>{b&&(i(!A||A.type?new the(null,e,b):A),b.abort(),b=null)},n.cancelToken&&n.cancelToken.subscribe(u),n.signal&&(n.signal.aborted?u():n.signal.addEventListener("abort",u)));let O=bOa(n.url);if(O&&OA.protocols.indexOf(O)===-1){i(new ha("Unsupported protocol "+O+":",ha.ERR_BAD_REQUEST,e));return}b.send(a||null)})};var dPS=(e,t)=>{let{length:r}=e=e?e.filter(Boolean):[];if(t||r){let i=new AbortController,n,a=function(s){if(!n){n=!0,c();let u=s instanceof Error?s:this.reason;i.abort(u instanceof ha?u:new the(u instanceof Error?u.message:u))}},o=t&&setTimeout(()=>{o=null,a(new ha(`timeout ${t} of ms exceeded`,ha.ETIMEDOUT))},t),c=()=>{e&&(o&&clearTimeout(o),o=null,e.forEach(s=>{s.unsubscribe?s.unsubscribe(a):s.removeEventListener("abort",a)}),e=null)};e.forEach(s=>s.addEventListener("abort",a));let{signal:f}=i;return f.unsubscribe=()=>er.asap(c),f}},z8p=dPS;var pPS=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},_PS=async function*(e,t){for await(let r of hPS(e))yield*pPS(r,t)},hPS=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()}},J7s=(e,t,r,i)=>{let n=_PS(e,t),a=0,o,c=f=>{o||(o=!0,i&&i(f))};return new ReadableStream({async pull(f){try{let{done:s,value:u}=await n.next();if(s){c(),f.close();return}let l=u.byteLength;if(r){let p=a+=l;r(p)}f.enqueue(new Uint8Array(u))}catch(s){throw c(s),s}},cancel(f){return c(f),n.return()}},{highWaterMark:2})};var N8p=64*1024,{isFunction:L0o}=er,yPS=(({Request:e,Response:t})=>({Request:e,Response:t}))(er.global),{ReadableStream:F8p,TextEncoder:Q8p}=er.global,U8p=(e,...t)=>{try{return!!e(...t)}catch{return!1}},bPS=e=>{e=er.merge.call({skipUndefined:!0},yPS,e);let{fetch:t,Request:r,Response:i}=e,n=t?L0o(t):typeof fetch=="function",a=L0o(r),o=L0o(i);if(!n)return!1;let c=n&&L0o(F8p),f=n&&(typeof Q8p=="function"?(h=>y=>h.encode(y))(new Q8p):async h=>new Uint8Array(await new r(h).arrayBuffer())),s=a&&c&&U8p(()=>{let h=!1,y=new r(OA.origin,{body:new F8p,method:"POST",get duplex(){return h=!0,"half"}}).headers.has("Content-Type");return h&&!y}),u=o&&c&&U8p(()=>er.isReadableStream(new i("").body)),l={stream:u&&(h=>h.body)};n&&["text","arrayBuffer","blob","formData","stream"].forEach(h=>{!l[h]&&(l[h]=(y,b)=>{let v=y&&y[h];if(v)return v.call(y);throw new ha(`Response type '${h}' is not supported`,ha.ERR_NOT_SUPPORT,b)})});let p=async h=>{if(h==null)return 0;if(er.isBlob(h))return h.size;if(er.isSpecCompliantForm(h))return(await new r(OA.origin,{method:"POST",body:h}).arrayBuffer()).byteLength;if(er.isArrayBufferView(h)||er.isArrayBuffer(h))return h.byteLength;if(er.isURLSearchParams(h)&&(h=h+""),er.isString(h))return(await f(h)).byteLength},_=async(h,y)=>{let b=er.toFiniteNumber(h.getContentLength());return b??p(y)};return async h=>{let{url:y,method:b,data:v,signal:O,cancelToken:A,timeout:g,onDownloadProgress:m,onUploadProgress:j,responseType:M,headers:E,withCredentials:D="same-origin",fetchOptions:B}=U0o(h),F=t||fetch;M=M?(M+"").toLowerCase():"text";let N=z8p([O,A&&A.toAbortSignal()],g),R=null,z=N&&N.unsubscribe&&(()=>{N.unsubscribe()}),U;try{if(j&&s&&b!=="get"&&b!=="head"&&(U=await _(E,v))!==0){let G=new r(y,{method:"POST",body:v,duplex:"half"}),Re;if(er.isFormData(v)&&(Re=G.headers.get("content-type"))&&E.setContentType(Re),G.body){let[le,De]=MTn(U,Qbi(DTn(j)));v=J7s(G.body,N8p,le,De)}}er.isString(D)||(D=D?"include":"omit");let W=a&&"credentials"in r.prototype,K={...B,signal:N,method:b.toUpperCase(),headers:E.normalize().toJSON(),body:v,duplex:"half",credentials:W?D:void 0};R=a&&new r(y,K);let fe=await(a?F(R,B):F(y,K)),pe=u&&(M==="stream"||M==="response");if(u&&(m||pe&&z)){let G={};["status","statusText","headers"].forEach(Ke=>{G[Ke]=fe[Ke]});let Re=er.toFiniteNumber(fe.headers.get("content-length")),[le,De]=m&&MTn(Re,Qbi(DTn(m),!0))||[];fe=new i(J7s(fe.body,N8p,le,()=>{De&&De(),z&&z()}),G)}M=M||"text";let L=await l[er.findKey(l,M)||"text"](fe,h);return!pe&&z&&z(),await new Promise((G,Re)=>{o6t(G,Re,{data:L,headers:QS.from(fe.headers),status:fe.status,statusText:fe.statusText,config:h,request:R})})}catch(W){throw z&&z(),W&&W.name==="TypeError"&&/Load failed|fetch/i.test(W.message)?Object.assign(new ha("Network Error",ha.ERR_NETWORK,h,R),{cause:W.cause||W}):ha.from(W,W&&W.code,h,R)}}},vPS=new Map,$7s=e=>{let t=e?e.env:{},{fetch:r,Request:i,Response:n}=t,a=[i,n,r],o=a.length,c=o,f,s,u=vPS;for(;c--;)f=a[c],s=u.get(f),s===void 0&&u.set(f,s=c?new Map:bPS(t)),u=s;return s},pg5=$7s();var Y7s={http:I8p,xhr:R8p,fetch:{get:$7s}};er.forEach(Y7s,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});var L8p=e=>`- ${e}`,OPS=e=>er.isFunction(e)||e===null||e===!1,V0o={getAdapter:(e,t)=>{e=er.isArray(e)?e:[e];let{length:r}=e,i,n,a={};for(let o=0;o<r;o++){i=e[o];let c;if(n=i,!OPS(i)&&(n=Y7s[(c=String(i)).toLowerCase()],n===void 0))throw new ha(`Unknown adapter '${c}'`);if(n&&(er.isFunction(n)||(n=n.get(t))))break;a[c||"#"+o]=n}if(!n){let o=Object.entries(a).map(([f,s])=>`adapter ${f} `+(s===!1?"is not supported by the environment":"is not available in the build")),c=r?o.length>1?`since :
|
|
@@ -1391,7 +1391,7 @@ ${g}${O}${m}${AQn}`});function BQo({message:e,error:t,logger:r,logLevel:i=$s.Err
|
|
|
1391
1391
|
Run ${Ut.cyan("fern generator upgrade")} to upgrade your generators.`),n.length>2&&(r+=`
|
|
1392
1392
|
Run ${Ut.cyan("fern generator upgrade --list")} to see the full list of generator upgrades available.`),QBi(r,{padding:1,float:"center",textAlignment:"center",borderColor:"yellow",borderStyle:"round"})}async function Iuc({generatorUpgradeInfo:e,header:t,limit:r,includeBoxen:i=!0}){if(!qf_(e))return;let n=t??"",a=e.filter(c=>c.isUpgradeAvailable);r!=null&&(a=a.slice(0,r+1));let o=a.sort((c,f)=>c.generatorName.localeCompare(f.generatorName)||c.currentVersion.localeCompare(f.currentVersion));for(let c of o)n+=`
|
|
1393
1393
|
${await oZS(c.generatorName)} (${c.apiName!=null?"API: "+c.apiName+", ":""}Group: ${c.generatorGroup}) `+Ut.dim(c.currentVersion)+Ut.reset(" \u2192 ")+Ut.green(c.latestVersion);return n+=`
|
|
1394
|
-
`,i?QBi(n,{padding:1,float:"center",textAlignment:"center",borderColor:"yellow",borderStyle:"round"}):n}async function oZS(e){let r=await new Cf_.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 uZS({cliContext:e,project:{apiWorkspaces:t},generatorFilter:r,groupFilter:i,channel:n,includeMajor:a}){if(t.length===1){let c={type:"singleApi",versions:{}};return await Rf_({cliContext:e,apiWorkspaces:t,perGeneratorAction:async(f,s,u,l)=>{c.versions[s]==null&&(c.versions[s]={});let p=NMi(u.name,l),_=await dNt({generatorName:p,cliVersion:e.environment.packageVersion,currentGeneratorVersion:u.version,channel:n,includeMajor:a,context:l});_!=null&&(c.versions[s][u.name]={previousVersion:u.version,latestVersion:_})},generatorFilter:r,groupFilter:i}),c}let o={type:"multiApi",versions:{}};return await Rf_({cliContext:e,apiWorkspaces:t,perGeneratorAction:async(c,f,s,u)=>{if(c==null)return;o.versions[c]==null&&(o.versions[c]={}),o.versions[c][f]==null&&(o.versions[c][f]={});let l=NMi(s.name,u),p=await dNt({generatorName:l,cliVersion:e.environment.packageVersion,currentGeneratorVersion:s.version,channel:n,includeMajor:a,context:u});p!=null&&(o.versions[c][f][s.name]={previousVersion:s.version,latestVersion:p})},generatorFilter:r,groupFilter:i}),o}async function Rf_({cliContext:e,apiWorkspaces:t,perGeneratorAction:r,generatorFilter:i,groupFilter:n}){await Promise.all(t.map(async a=>{await e.runTaskForWorkspace(a,async o=>{let c=await $_e({absolutePathToWorkspace:a.absoluteFilePath,context:o});if(!(c==null||c.groups==null)){for(let f of c.groups)if(!(n!=null&&f.groupName!==n))for(let s of f.generators)i!=null&&s.name!==i||await r(a.workspaceName,f.groupName,s,o)}})}))}function zf_(e,t,r){let i=[];for(let[n,a]of Object.entries(e))for(let[o,c]of Object.entries(a)){r.debug(`Checking if ${o} in group ${n} has an upgrade available...`);let f=kH(c.latestVersion,c.previousVersion);r.debug(`Latest version: ${c.latestVersion}. `+(f?"Upgrade available.":"No upgrade available.")),i.push({generatorName:o,generatorGroup:n,apiName:t,isUpgradeAvailable:f,currentVersion:c.previousVersion,latestVersion:c.latestVersion})}return i}async function TQo({project:e,cliContext:t,generatorFilter:r,groupFilter:i,channel:n,includeMajor:a}){let o=[];if(e!=null){let c=await uZS({cliContext:t,project:e,generatorFilter:r,groupFilter:i,channel:n,includeMajor:a});if(c.type==="multiApi")for(let[f,s]of Object.entries(c.versions))o.push(...zf_(s,f,t.logger));else o.push(...zf_(c.versions,void 0,t.logger))}return o}var IPa=class extends Error{response;request;options;constructor(t,r,i){let n=t.status||t.status===0?t.status:"",a=t.statusText??"",o=`${n} ${a}`.trim(),c=o?`status code ${o}`:"an unknown error";super(`Request failed with ${c}: ${r.method} ${r.url}`),this.name="HTTPError",this.response=t,this.request=r,this.options=i}};var wQn=class extends Error{request;constructor(t){super(`Request timed out: ${t.method} ${t.url}`),this.name="TimeoutError",this.request=t}};var Cuc=(()=>{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})(),Nf_=typeof globalThis.AbortController=="function",Ff_=typeof globalThis.AbortSignal=="function"&&typeof globalThis.AbortSignal.any=="function",Qf_=typeof globalThis.ReadableStream=="function",Uf_=typeof globalThis.FormData=="function",RQo=["get","post","put","patch","head","delete"],sZS=()=>{};sZS();var Lf_={json:"application/json",text:"text/*",formData:"multipart/form-data",arrayBuffer:"*/*",blob:"*/*",bytes:"*/*"},zQo=2147483647,Vf_=new TextEncoder().encode("------WebKitFormBoundaryaxpyiPgbbPti10Rw").length,NQo=Symbol("stop"),Wf_={json:!0,parseJson:!0,stringifyJson:!0,searchParams:!0,prefixUrl:!0,retry:!0,timeout:!0,hooks:!0,throwHttpErrors:!0,onDownloadProgress:!0,onUploadProgress:!0,fetch:!0},xf_={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 cZS=e=>{if(!e)return 0;if(e instanceof FormData){let t=0;for(let[r,i]of e)t+=Vf_,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},Gf_=(e,t,r)=>{let i,n=0;return e.pipeThrough(new TransformStream({transform(a,o){if(o.enqueue(a),i){n+=i.byteLength;let c=t===0?0:n/t;c>=1&&(c=1-Number.EPSILON),r?.({percent:c,totalBytes:Math.max(t,n),transferredBytes:n},i)}i=a},flush(){i&&(n+=i.byteLength,r?.({percent:1,totalBytes:Math.max(t,n),transferredBytes:n},i))}}))},Hf_=(e,t)=>{if(!e.body)return e;if(e.status===204)return new Response(null,{status:e.status,statusText:e.statusText,headers:e.headers});let r=Number(e.headers.get("content-length"))||0;return new Response(Gf_(e.body,r,t),{status:e.status,statusText:e.statusText,headers:e.headers})},Kf_=(e,t,r)=>{if(!e.body)return e;let i=cZS(r??e.body);return new Request(e,{duplex:"half",body:Gf_(e.body,i,t)})};var EQn=e=>e!==null&&typeof e=="object";var CPa=(...e)=>{for(let t of e)if((!EQn(t)||Array.isArray(t))&&t!==void 0)throw new TypeError("The `options` argument must be an object");return Ruc({},...e)},quc=(e={},t={})=>{let r=new globalThis.Headers(e),i=t instanceof globalThis.Headers,n=new globalThis.Headers(t);for(let[a,o]of n.entries())i&&o==="undefined"||o===void 0?r.delete(a):r.set(a,o);return r};function FQo(e,t,r){return Object.hasOwn(t,r)&&t[r]===void 0?[]:Ruc(e[r]??[],t[r]??[])}var Tuc=(e={},t={})=>({beforeRequest:FQo(e,t,"beforeRequest"),beforeRetry:FQo(e,t,"beforeRetry"),afterResponse:FQo(e,t,"afterResponse"),beforeError:FQo(e,t,"beforeError")}),Ruc=(...e)=>{let t={},r={},i={};for(let n of e)if(Array.isArray(n))Array.isArray(t)||(t=[]),t=[...t,...n];else if(EQn(n)){for(let[a,o]of Object.entries(n))EQn(o)&&a in t&&(o=Ruc(t[a],o)),t={...t,[a]:o};EQn(n.hooks)&&(i=Tuc(i,n.hooks),t.hooks=i),EQn(n.headers)&&(r=quc(r,n.headers),t.headers=r)}return t};var $f_=e=>RQo.includes(e)?e.toUpperCase():e,lZS=["get","put","head","delete","options","trace"],fZS=[408,413,429,500,502,503,504],dZS=[413,429,503],Jf_={limit:2,methods:lZS,statusCodes:fZS,afterStatusCodes:dZS,maxRetryAfter:Number.POSITIVE_INFINITY,backoffLimit:Number.POSITIVE_INFINITY,delay:e=>.3*2**(e-1)*1e3},Yf_=(e={})=>{if(typeof e=="number")return{...Jf_,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{...Jf_,...e}};async function zuc(e,t,r,i){return new Promise((n,a)=>{let o=setTimeout(()=>{r&&r.abort(),a(new wQn(e))},i.timeout);i.fetch(e,t).then(n).catch(a).then(()=>{clearTimeout(o)})})}async function Nuc(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 Xf_=(e,t)=>{let r={};for(let i in t)!(i in xf_)&&!(i in Wf_)&&!(i in e)&&(r[i]=t[i]);return r},Zf_=e=>e===void 0?!1:Array.isArray(e)?e.length>0:e instanceof URLSearchParams?e.size>0:typeof e=="object"?Object.keys(e).length>0:typeof e=="string"?e.trim().length>0:!!e;var qPa=class e{static create(t,r){let i=new e(t,r),n=async()=>{if(typeof i._options.timeout=="number"&&i._options.timeout>zQo)throw new RangeError(`The \`timeout\` option cannot be greater than ${zQo}`);await Promise.resolve();let c=await i._fetch();for(let f of i._options.hooks.afterResponse){let s=await f(i.request,i._options,i._decorateResponse(c.clone()));s instanceof globalThis.Response&&(c=s)}if(i._decorateResponse(c),!c.ok&&i._options.throwHttpErrors){let f=new IPa(c,i.request,i._options);for(let s of i._options.hooks.beforeError)f=await s(f);throw f}if(i._options.onDownloadProgress){if(typeof i._options.onDownloadProgress!="function")throw new TypeError("The `onDownloadProgress` option must be a function");if(!Qf_)throw new Error("Streams are not supported in your environment. `ReadableStream` is missing.");return Hf_(c.clone(),i._options.onDownloadProgress)}return c},o=(i._options.retry.methods.includes(i.request.method.toLowerCase())?i._retry(n):n()).finally(async()=>{let c=i._originalRequest,f=[];c&&!c.bodyUsed&&f.push(c.body?.cancel()),i.request.bodyUsed||f.push(i.request.body?.cancel()),await Promise.all(f)});for(let[c,f]of Object.entries(Lf_))c==="bytes"&&typeof globalThis.Response?.prototype?.bytes!="function"||(o[c]=async()=>{i.request.headers.set("accept",i.request.headers.get("accept")||f);let s=await o;if(c==="json"){if(s.status===204)return"";let u=await s.text();return u===""?"":r.parseJson?r.parseJson(u):JSON.parse(u)}return s[c]()});return o}static#e(t){return t&&typeof t=="object"&&!Array.isArray(t)&&!(t instanceof URLSearchParams)?Object.fromEntries(Object.entries(t).filter(([,r])=>r!==void 0)):t}request;abortController;_retryCount=0;_input;_options;_originalRequest;constructor(t,r={}){if(this._input=t,this._options={...r,headers:quc(this._input.headers,r.headers),hooks:Tuc({beforeRequest:[],beforeRetry:[],beforeError:[],afterResponse:[]},r.hooks),method:$f_(r.method??this._input.method??"GET"),prefixUrl:String(r.prefixUrl||""),retry:Yf_(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(Nf_&&Ff_){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(Cuc&&(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),Zf_(this._options.searchParams)){let n="?"+(typeof this._options.searchParams=="string"?this._options.searchParams.replace(/^\?/,""):new URLSearchParams(e.#e(this._options.searchParams)).toString()),a=this.request.url.replace(/(?:\?.*?)?(?=#|$)/,n);(Uf_&&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(!Cuc)throw new Error("Request streams are not supported in your environment. The `duplex` option for `Request` is not available.");this.request.body&&(this.request=Kf_(this.request,this._options.onUploadProgress,this._options.body))}}_calculateRetryDelay(t){if(this._retryCount++,this._retryCount>this._options.retry.limit||t instanceof wQn)throw t;if(t instanceof IPa){if(!this._options.retry.statusCodes.includes(t.response.status))throw t;let i=t.response.headers.get("Retry-After")??t.response.headers.get("RateLimit-Reset")??t.response.headers.get("X-RateLimit-Reset")??t.response.headers.get("X-Rate-Limit-Reset");if(i&&this._options.retry.afterStatusCodes.includes(t.response.status)){let n=Number(i)*1e3;Number.isNaN(n)?n=Date.parse(i)-Date.now():n>=Date.parse("2024-01-01")&&(n-=Date.now());let a=this._options.retry.maxRetryAfter??n;return n<a?n:a}if(t.response.status===413)throw t}let r=this._options.retry.delay(this._retryCount);return Math.min(this._options.retry.backoffLimit,r)}_decorateResponse(t){return this._options.parseJson&&(t.json=async()=>this._options.parseJson(await t.text())),t}async _retry(t){try{return await t()}catch(r){let i=Math.min(this._calculateRetryDelay(r),zQo);if(this._retryCount<1)throw r;await Nuc(i,{signal:this._options.signal});for(let n of this._options.hooks.beforeRetry)if(await n({request:this.request,options:this._options,error:r,retryCount:this._retryCount})===NQo)return;return this._retry(t)}}async _fetch(){for(let r of this._options.hooks.beforeRequest){let i=await r(this.request,this._options);if(i instanceof Request){this.request=i;break}if(i instanceof Response)return i}let t=Xf_(this.request,this._options);return this._originalRequest=this.request,this.request=this._originalRequest.clone(),this._options.timeout===!1?this._options.fetch(this._originalRequest,t):zuc(this._originalRequest,t,this.abortController,this._options)}};var Fuc=e=>{let t=(r,i)=>qPa.create(r,CPa(e,i));for(let r of RQo)t[r]=(i,n)=>qPa.create(i,CPa(e,n,{method:r}));return t.create=r=>Fuc(CPa(r)),t.extend=r=>(typeof r=="function"&&(r=r(e??{})),Fuc(CPa(e,r))),t.stop=NQo,t},pZS=Fuc(),kf_=pZS;var md_=ue(Ad_(),1);function Wuc(e){let t=(0,md_.default)("npm",{registry:"https://registry.npmjs.org/"}),r=t[`${e}:registry`]||t.config_registry||t.registry;return r.slice(-1)==="/"?r:`${r}/`}var yp_=ue(hp_(),1),bp_=ue(m_e(),1),rsc=class extends Error{constructor(t){super(`Package \`${t}\` could not be found`),this.name="PackageNotFoundError"}},isc=class extends Error{constructor(t,r){super(`Version \`${r}\` for package \`${t}\` could not be found`),this.name="VersionNotFoundError"}};async function nsc(e,t={}){let{version:r="latest"}=t,{omitDeprecated:i=!0}=t,n=e.split("/")[0],a=t.registryUrl??Wuc(n),o=new URL(encodeURIComponent(e).replace(/^%40/,"@"),a),c=(0,yp_.default)(a.toString(),{recursive:!0}),f={accept:"application/vnd.npm.install-v1+json; q=1.0, application/json; q=0.8, */*"};t.fullMetadata&&delete f.accept,c&&(f.authorization=`${c.type} ${c.token}`);let s;try{s=await kf_(o,{headers:f,keepalive:!0}).json()}catch(l){throw l?.response?.status===404?new rsc(e):l}if(t.allVersions)return s;let u=new isc(e,r);if(s["dist-tags"][r]){let{time:l}=s;s=s.versions[s["dist-tags"][r]],s.time=l}else if(r){let l=!!s.versions[r];if(i&&!l)for(let[_,h]of Object.entries(s.versions))h.deprecated&&delete s.versions[_];if(!l){let _=Object.keys(s.versions);if(r=bp_.default.maxSatisfying(_,r),!r)throw u}let{time:p}=s;if(s=s.versions[r],s.time=p,!s)throw u}return s}async function QPa(e,t){let{version:r}=await nsc(e.toLowerCase(),t);return r}async function qCi({cliEnvironment:e,includePreReleases:t=!1}){return e.packageName!=="fern-api"?e.packageVersion:QPa(e.packageName,{version:t?"prerelease":"latest"})}var vp_=["#2E86AB","#A23B72","#F18F01","#C73E1D","#CCE2A3"],YQo=class{environment;didSucceed=!0;numTasks=0;ttyAwareLogger;logLevel=$s.Info;isLocal;constructor(t,r,{isLocal:i}){this.ttyAwareLogger=new qQo(t,r),this.isLocal=i??!1;let n=this.getPackageName(),a=this.getPackageVersion(),o=this.getCliName();(n==null||a==null||o==null)&&this.exitProgram(),this.environment={packageName:n,packageVersion:a,cliName:o}}getPackageName(){return"fern-api"}getPackageVersion(){return"3.23.1"}getCliName(){return"fern"}setLogLevel(t){this.logLevel=t}logFernVersionDebug(){this.logger.debug(`Running ${Ut.bold(`${this.environment.cliName}`)} (${this.environment.packageName}@${this.environment.packageVersion})`)}failAndThrow(t,r){throw this.failWithoutThrowing(t,r),new TE}failWithoutThrowing(t,r){this.didSucceed=!1,BQo({message:t,error:r,logger:this.logger})}async exit({code:t}={}){!this._suppressUpgradeMessage&&!this.isLocal&&await this.nudgeUpgradeIfAvailable(),this.ttyAwareLogger.finish(),await(await ATn()).flush(),this.exitProgram({code:t})}async nudgeUpgradeIfAvailable(){try{let t=await Promise.race([this.isUpgradeAvailable(),new Promise((i,n)=>setTimeout(()=>n("Request timed out"),300))]),r=await Tf_({cliEnvironment:this.environment,upgradeInfo:t});r!=null&&(r.endsWith(`
|
|
1394
|
+
`,i?QBi(n,{padding:1,float:"center",textAlignment:"center",borderColor:"yellow",borderStyle:"round"}):n}async function oZS(e){let r=await new Cf_.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 uZS({cliContext:e,project:{apiWorkspaces:t},generatorFilter:r,groupFilter:i,channel:n,includeMajor:a}){if(t.length===1){let c={type:"singleApi",versions:{}};return await Rf_({cliContext:e,apiWorkspaces:t,perGeneratorAction:async(f,s,u,l)=>{c.versions[s]==null&&(c.versions[s]={});let p=NMi(u.name,l),_=await dNt({generatorName:p,cliVersion:e.environment.packageVersion,currentGeneratorVersion:u.version,channel:n,includeMajor:a,context:l});_!=null&&(c.versions[s][u.name]={previousVersion:u.version,latestVersion:_})},generatorFilter:r,groupFilter:i}),c}let o={type:"multiApi",versions:{}};return await Rf_({cliContext:e,apiWorkspaces:t,perGeneratorAction:async(c,f,s,u)=>{if(c==null)return;o.versions[c]==null&&(o.versions[c]={}),o.versions[c][f]==null&&(o.versions[c][f]={});let l=NMi(s.name,u),p=await dNt({generatorName:l,cliVersion:e.environment.packageVersion,currentGeneratorVersion:s.version,channel:n,includeMajor:a,context:u});p!=null&&(o.versions[c][f][s.name]={previousVersion:s.version,latestVersion:p})},generatorFilter:r,groupFilter:i}),o}async function Rf_({cliContext:e,apiWorkspaces:t,perGeneratorAction:r,generatorFilter:i,groupFilter:n}){await Promise.all(t.map(async a=>{await e.runTaskForWorkspace(a,async o=>{let c=await $_e({absolutePathToWorkspace:a.absoluteFilePath,context:o});if(!(c==null||c.groups==null)){for(let f of c.groups)if(!(n!=null&&f.groupName!==n))for(let s of f.generators)i!=null&&s.name!==i||await r(a.workspaceName,f.groupName,s,o)}})}))}function zf_(e,t,r){let i=[];for(let[n,a]of Object.entries(e))for(let[o,c]of Object.entries(a)){r.debug(`Checking if ${o} in group ${n} has an upgrade available...`);let f=kH(c.latestVersion,c.previousVersion);r.debug(`Latest version: ${c.latestVersion}. `+(f?"Upgrade available.":"No upgrade available.")),i.push({generatorName:o,generatorGroup:n,apiName:t,isUpgradeAvailable:f,currentVersion:c.previousVersion,latestVersion:c.latestVersion})}return i}async function TQo({project:e,cliContext:t,generatorFilter:r,groupFilter:i,channel:n,includeMajor:a}){let o=[];if(e!=null){let c=await uZS({cliContext:t,project:e,generatorFilter:r,groupFilter:i,channel:n,includeMajor:a});if(c.type==="multiApi")for(let[f,s]of Object.entries(c.versions))o.push(...zf_(s,f,t.logger));else o.push(...zf_(c.versions,void 0,t.logger))}return o}var IPa=class extends Error{response;request;options;constructor(t,r,i){let n=t.status||t.status===0?t.status:"",a=t.statusText??"",o=`${n} ${a}`.trim(),c=o?`status code ${o}`:"an unknown error";super(`Request failed with ${c}: ${r.method} ${r.url}`),this.name="HTTPError",this.response=t,this.request=r,this.options=i}};var wQn=class extends Error{request;constructor(t){super(`Request timed out: ${t.method} ${t.url}`),this.name="TimeoutError",this.request=t}};var Cuc=(()=>{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})(),Nf_=typeof globalThis.AbortController=="function",Ff_=typeof globalThis.AbortSignal=="function"&&typeof globalThis.AbortSignal.any=="function",Qf_=typeof globalThis.ReadableStream=="function",Uf_=typeof globalThis.FormData=="function",RQo=["get","post","put","patch","head","delete"],sZS=()=>{};sZS();var Lf_={json:"application/json",text:"text/*",formData:"multipart/form-data",arrayBuffer:"*/*",blob:"*/*",bytes:"*/*"},zQo=2147483647,Vf_=new TextEncoder().encode("------WebKitFormBoundaryaxpyiPgbbPti10Rw").length,NQo=Symbol("stop"),Wf_={json:!0,parseJson:!0,stringifyJson:!0,searchParams:!0,prefixUrl:!0,retry:!0,timeout:!0,hooks:!0,throwHttpErrors:!0,onDownloadProgress:!0,onUploadProgress:!0,fetch:!0},xf_={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 cZS=e=>{if(!e)return 0;if(e instanceof FormData){let t=0;for(let[r,i]of e)t+=Vf_,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},Gf_=(e,t,r)=>{let i,n=0;return e.pipeThrough(new TransformStream({transform(a,o){if(o.enqueue(a),i){n+=i.byteLength;let c=t===0?0:n/t;c>=1&&(c=1-Number.EPSILON),r?.({percent:c,totalBytes:Math.max(t,n),transferredBytes:n},i)}i=a},flush(){i&&(n+=i.byteLength,r?.({percent:1,totalBytes:Math.max(t,n),transferredBytes:n},i))}}))},Hf_=(e,t)=>{if(!e.body)return e;if(e.status===204)return new Response(null,{status:e.status,statusText:e.statusText,headers:e.headers});let r=Number(e.headers.get("content-length"))||0;return new Response(Gf_(e.body,r,t),{status:e.status,statusText:e.statusText,headers:e.headers})},Kf_=(e,t,r)=>{if(!e.body)return e;let i=cZS(r??e.body);return new Request(e,{duplex:"half",body:Gf_(e.body,i,t)})};var EQn=e=>e!==null&&typeof e=="object";var CPa=(...e)=>{for(let t of e)if((!EQn(t)||Array.isArray(t))&&t!==void 0)throw new TypeError("The `options` argument must be an object");return Ruc({},...e)},quc=(e={},t={})=>{let r=new globalThis.Headers(e),i=t instanceof globalThis.Headers,n=new globalThis.Headers(t);for(let[a,o]of n.entries())i&&o==="undefined"||o===void 0?r.delete(a):r.set(a,o);return r};function FQo(e,t,r){return Object.hasOwn(t,r)&&t[r]===void 0?[]:Ruc(e[r]??[],t[r]??[])}var Tuc=(e={},t={})=>({beforeRequest:FQo(e,t,"beforeRequest"),beforeRetry:FQo(e,t,"beforeRetry"),afterResponse:FQo(e,t,"afterResponse"),beforeError:FQo(e,t,"beforeError")}),Ruc=(...e)=>{let t={},r={},i={};for(let n of e)if(Array.isArray(n))Array.isArray(t)||(t=[]),t=[...t,...n];else if(EQn(n)){for(let[a,o]of Object.entries(n))EQn(o)&&a in t&&(o=Ruc(t[a],o)),t={...t,[a]:o};EQn(n.hooks)&&(i=Tuc(i,n.hooks),t.hooks=i),EQn(n.headers)&&(r=quc(r,n.headers),t.headers=r)}return t};var $f_=e=>RQo.includes(e)?e.toUpperCase():e,lZS=["get","put","head","delete","options","trace"],fZS=[408,413,429,500,502,503,504],dZS=[413,429,503],Jf_={limit:2,methods:lZS,statusCodes:fZS,afterStatusCodes:dZS,maxRetryAfter:Number.POSITIVE_INFINITY,backoffLimit:Number.POSITIVE_INFINITY,delay:e=>.3*2**(e-1)*1e3},Yf_=(e={})=>{if(typeof e=="number")return{...Jf_,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{...Jf_,...e}};async function zuc(e,t,r,i){return new Promise((n,a)=>{let o=setTimeout(()=>{r&&r.abort(),a(new wQn(e))},i.timeout);i.fetch(e,t).then(n).catch(a).then(()=>{clearTimeout(o)})})}async function Nuc(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 Xf_=(e,t)=>{let r={};for(let i in t)!(i in xf_)&&!(i in Wf_)&&!(i in e)&&(r[i]=t[i]);return r},Zf_=e=>e===void 0?!1:Array.isArray(e)?e.length>0:e instanceof URLSearchParams?e.size>0:typeof e=="object"?Object.keys(e).length>0:typeof e=="string"?e.trim().length>0:!!e;var qPa=class e{static create(t,r){let i=new e(t,r),n=async()=>{if(typeof i._options.timeout=="number"&&i._options.timeout>zQo)throw new RangeError(`The \`timeout\` option cannot be greater than ${zQo}`);await Promise.resolve();let c=await i._fetch();for(let f of i._options.hooks.afterResponse){let s=await f(i.request,i._options,i._decorateResponse(c.clone()));s instanceof globalThis.Response&&(c=s)}if(i._decorateResponse(c),!c.ok&&i._options.throwHttpErrors){let f=new IPa(c,i.request,i._options);for(let s of i._options.hooks.beforeError)f=await s(f);throw f}if(i._options.onDownloadProgress){if(typeof i._options.onDownloadProgress!="function")throw new TypeError("The `onDownloadProgress` option must be a function");if(!Qf_)throw new Error("Streams are not supported in your environment. `ReadableStream` is missing.");return Hf_(c.clone(),i._options.onDownloadProgress)}return c},o=(i._options.retry.methods.includes(i.request.method.toLowerCase())?i._retry(n):n()).finally(async()=>{let c=i._originalRequest,f=[];c&&!c.bodyUsed&&f.push(c.body?.cancel()),i.request.bodyUsed||f.push(i.request.body?.cancel()),await Promise.all(f)});for(let[c,f]of Object.entries(Lf_))c==="bytes"&&typeof globalThis.Response?.prototype?.bytes!="function"||(o[c]=async()=>{i.request.headers.set("accept",i.request.headers.get("accept")||f);let s=await o;if(c==="json"){if(s.status===204)return"";let u=await s.text();return u===""?"":r.parseJson?r.parseJson(u):JSON.parse(u)}return s[c]()});return o}static#e(t){return t&&typeof t=="object"&&!Array.isArray(t)&&!(t instanceof URLSearchParams)?Object.fromEntries(Object.entries(t).filter(([,r])=>r!==void 0)):t}request;abortController;_retryCount=0;_input;_options;_originalRequest;constructor(t,r={}){if(this._input=t,this._options={...r,headers:quc(this._input.headers,r.headers),hooks:Tuc({beforeRequest:[],beforeRetry:[],beforeError:[],afterResponse:[]},r.hooks),method:$f_(r.method??this._input.method??"GET"),prefixUrl:String(r.prefixUrl||""),retry:Yf_(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(Nf_&&Ff_){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(Cuc&&(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),Zf_(this._options.searchParams)){let n="?"+(typeof this._options.searchParams=="string"?this._options.searchParams.replace(/^\?/,""):new URLSearchParams(e.#e(this._options.searchParams)).toString()),a=this.request.url.replace(/(?:\?.*?)?(?=#|$)/,n);(Uf_&&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(!Cuc)throw new Error("Request streams are not supported in your environment. The `duplex` option for `Request` is not available.");this.request.body&&(this.request=Kf_(this.request,this._options.onUploadProgress,this._options.body))}}_calculateRetryDelay(t){if(this._retryCount++,this._retryCount>this._options.retry.limit||t instanceof wQn)throw t;if(t instanceof IPa){if(!this._options.retry.statusCodes.includes(t.response.status))throw t;let i=t.response.headers.get("Retry-After")??t.response.headers.get("RateLimit-Reset")??t.response.headers.get("X-RateLimit-Reset")??t.response.headers.get("X-Rate-Limit-Reset");if(i&&this._options.retry.afterStatusCodes.includes(t.response.status)){let n=Number(i)*1e3;Number.isNaN(n)?n=Date.parse(i)-Date.now():n>=Date.parse("2024-01-01")&&(n-=Date.now());let a=this._options.retry.maxRetryAfter??n;return n<a?n:a}if(t.response.status===413)throw t}let r=this._options.retry.delay(this._retryCount);return Math.min(this._options.retry.backoffLimit,r)}_decorateResponse(t){return this._options.parseJson&&(t.json=async()=>this._options.parseJson(await t.text())),t}async _retry(t){try{return await t()}catch(r){let i=Math.min(this._calculateRetryDelay(r),zQo);if(this._retryCount<1)throw r;await Nuc(i,{signal:this._options.signal});for(let n of this._options.hooks.beforeRetry)if(await n({request:this.request,options:this._options,error:r,retryCount:this._retryCount})===NQo)return;return this._retry(t)}}async _fetch(){for(let r of this._options.hooks.beforeRequest){let i=await r(this.request,this._options);if(i instanceof Request){this.request=i;break}if(i instanceof Response)return i}let t=Xf_(this.request,this._options);return this._originalRequest=this.request,this.request=this._originalRequest.clone(),this._options.timeout===!1?this._options.fetch(this._originalRequest,t):zuc(this._originalRequest,t,this.abortController,this._options)}};var Fuc=e=>{let t=(r,i)=>qPa.create(r,CPa(e,i));for(let r of RQo)t[r]=(i,n)=>qPa.create(i,CPa(e,n,{method:r}));return t.create=r=>Fuc(CPa(r)),t.extend=r=>(typeof r=="function"&&(r=r(e??{})),Fuc(CPa(e,r))),t.stop=NQo,t},pZS=Fuc(),kf_=pZS;var md_=ue(Ad_(),1);function Wuc(e){let t=(0,md_.default)("npm",{registry:"https://registry.npmjs.org/"}),r=t[`${e}:registry`]||t.config_registry||t.registry;return r.slice(-1)==="/"?r:`${r}/`}var yp_=ue(hp_(),1),bp_=ue(m_e(),1),rsc=class extends Error{constructor(t){super(`Package \`${t}\` could not be found`),this.name="PackageNotFoundError"}},isc=class extends Error{constructor(t,r){super(`Version \`${r}\` for package \`${t}\` could not be found`),this.name="VersionNotFoundError"}};async function nsc(e,t={}){let{version:r="latest"}=t,{omitDeprecated:i=!0}=t,n=e.split("/")[0],a=t.registryUrl??Wuc(n),o=new URL(encodeURIComponent(e).replace(/^%40/,"@"),a),c=(0,yp_.default)(a.toString(),{recursive:!0}),f={accept:"application/vnd.npm.install-v1+json; q=1.0, application/json; q=0.8, */*"};t.fullMetadata&&delete f.accept,c&&(f.authorization=`${c.type} ${c.token}`);let s;try{s=await kf_(o,{headers:f,keepalive:!0}).json()}catch(l){throw l?.response?.status===404?new rsc(e):l}if(t.allVersions)return s;let u=new isc(e,r);if(s["dist-tags"][r]){let{time:l}=s;s=s.versions[s["dist-tags"][r]],s.time=l}else if(r){let l=!!s.versions[r];if(i&&!l)for(let[_,h]of Object.entries(s.versions))h.deprecated&&delete s.versions[_];if(!l){let _=Object.keys(s.versions);if(r=bp_.default.maxSatisfying(_,r),!r)throw u}let{time:p}=s;if(s=s.versions[r],s.time=p,!s)throw u}return s}async function QPa(e,t){let{version:r}=await nsc(e.toLowerCase(),t);return r}async function qCi({cliEnvironment:e,includePreReleases:t=!1}){return e.packageName!=="fern-api"?e.packageVersion:QPa(e.packageName,{version:t?"prerelease":"latest"})}var vp_=["#2E86AB","#A23B72","#F18F01","#C73E1D","#CCE2A3"],YQo=class{environment;didSucceed=!0;numTasks=0;ttyAwareLogger;logLevel=$s.Info;isLocal;constructor(t,r,{isLocal:i}){this.ttyAwareLogger=new qQo(t,r),this.isLocal=i??!1;let n=this.getPackageName(),a=this.getPackageVersion(),o=this.getCliName();(n==null||a==null||o==null)&&this.exitProgram(),this.environment={packageName:n,packageVersion:a,cliName:o}}getPackageName(){return"fern-api"}getPackageVersion(){return"3.23.2"}getCliName(){return"fern"}setLogLevel(t){this.logLevel=t}logFernVersionDebug(){this.logger.debug(`Running ${Ut.bold(`${this.environment.cliName}`)} (${this.environment.packageName}@${this.environment.packageVersion})`)}failAndThrow(t,r){throw this.failWithoutThrowing(t,r),new TE}failWithoutThrowing(t,r){this.didSucceed=!1,BQo({message:t,error:r,logger:this.logger})}async exit({code:t}={}){!this._suppressUpgradeMessage&&!this.isLocal&&await this.nudgeUpgradeIfAvailable(),this.ttyAwareLogger.finish(),await(await ATn()).flush(),this.exitProgram({code:t})}async nudgeUpgradeIfAvailable(){try{let t=await Promise.race([this.isUpgradeAvailable(),new Promise((i,n)=>setTimeout(()=>n("Request timed out"),300))]),r=await Tf_({cliEnvironment:this.environment,upgradeInfo:t});r!=null&&(r.endsWith(`
|
|
1395
1395
|
`)||(r+=`
|
|
1396
1396
|
`),this.stderr.info(r))}catch{}}async exitIfFailed(){this.didSucceed||await this.exit()}exitProgram({code:t}={}){process.exit(t??(this.didSucceed?0:1))}longestWorkspaceName;registerWorkspaces(t){let r=lws(t.map(i=>i.type==="docs"?"docs":i.workspaceName??"api"),i=>i.length);r!=null&&(this.longestWorkspaceName=r)}project;registerProject(t){this.project=t}runTask(t){return this.runTaskWithInit(this.constructTaskInit(),t)}addTask(){return this.addTaskWithInit(this.constructTaskInit())}async runTaskForWorkspace(t,r){await this.runTaskWithInit(this.constructTaskInitForWorkspace(t),r)}addTaskWithInit(t){let r=new wPa(t);return this.ttyAwareLogger.registerTask(r),r}USE_NODE_18_OR_ABOVE_MESSAGE="The Fern CLI requires Node 18+ or above.";async runTaskWithInit(t,r){let i=this.addTaskWithInit(t).start(),n;try{n=await r(i)}catch(a){throw a.message.includes("globalThis")?(i.logger.error(this.USE_NODE_18_OR_ABOVE_MESSAGE),i.failWithoutThrowing()):i.failWithoutThrowing(void 0,a),new TE}finally{i.finish()}return n}async instrumentPostHogEvent(t){this.isLocal||(await ATn()).sendEvent(t)}logger=$8t((t,...r)=>this.log(t,...r));stderr=$8t((t,...r)=>this.logStderr(t,...r));constructTaskInitForWorkspace(t){let r=gp_(t.type==="docs"?"docs":t.workspaceName??"api"),i=1+(this.longestWorkspaceName!=null?gp_(this.longestWorkspaceName):r).length,n=r.padEnd(i),a=vp_[this.numTasks++%vp_.length],o=Ut.hex(a)(n);return{...this.constructTaskInit(),logPrefix:o}}constructTaskInit(){return{logImmediately:t=>this.logImmediately(t),takeOverTerminal:t=>this.ttyAwareLogger.takeOverTerminal(t),onResult:t=>{t===yj.Failure&&(this.didSucceed=!1)},instrumentPostHogEvent:async t=>{await this.instrumentPostHogEvent(t)},shouldBufferLogs:!1}}log(t,...r){this.logImmediately([{parts:r,level:t,time:new Date}])}logStderr(t,...r){this.logImmediately([{parts:r,level:t,time:new Date}],{stderr:!0})}logImmediately(t,{stderr:r=!1}={}){let i=t.filter(n=>aMi.indexOf(n.level)>=aMi.indexOf(this.logLevel));this.ttyAwareLogger.log(i,{includeDebugInfo:this.logLevel===$s.Debug,stderr:r})}_suppressUpgradeMessage=!1;suppressUpgradeMessage(){this._suppressUpgradeMessage=!0}_isUpgradeAvailable;async isUpgradeAvailable({includePreReleases:t=!1}={}){if(this._isUpgradeAvailable==null){this.logger.debug(`Checking if ${this.environment.packageName} upgrade is available...`);let r=await qCi({cliEnvironment:this.environment,includePreReleases:t}),i=kH(r,this.environment.packageVersion);this.logger.debug(`Latest version: ${r}. `+(i?"Upgrade available.":"No upgrade available."));let n={isUpgradeAvailable:i,latestVersion:r},a=await TQo({project:this.project,cliContext:this});this._isUpgradeAvailable={cliUpgradeInfo:n,generatorUpgradeInfo:a}}return this._isUpgradeAvailable}async confirmPrompt(t,r=!1){try{return await guc({message:t,choices:[{name:"No",value:!1},{name:"Yes",value:!0}],default:r,theme:{prefix:Ut.yellow("?"),style:{answer:n=>Ut.cyan(n),message:n=>Ut.bold(n),highlight:n=>Ut.cyan(n)}}})}catch(i){throw i?.name==="ExitPromptError"?(this.logger.info(`
|
|
1397
1397
|
Cancelled by user.`),new TE):i}}async getInput(t){return await huc({message:t.message,default:t.default})}};function gp_(e){return`[${e}]:`}var hFt=class{generatorsConfiguration;workspaceName;cliVersion;absoluteFilePath;changelog;constructor({generatorsConfiguration:t,workspaceName:r,cliVersion:i,absoluteFilePath:n,changelog:a}){this.generatorsConfiguration=t,this.workspaceName=r,this.cliVersion=i,this.absoluteFilePath=n,this.changelog=a}};function XQo(e,t,r,i){if(typeof r!="function")throw new Error("method for before hook must be a function");return i||(i={}),Array.isArray(t)?t.reverse().reduce((n,a)=>XQo.bind(null,e,a,n,i),r)():Promise.resolve().then(()=>e.registry[t]?e.registry[t].reduce((n,a)=>a.hook.bind(null,n,i),r)():r(i))}function Op_(e,t,r,i){let n=i;e.registry[r]||(e.registry[r]=[]),t==="before"&&(i=(a,o)=>Promise.resolve().then(n.bind(null,o)).then(a.bind(null,o))),t==="after"&&(i=(a,o)=>{let c;return Promise.resolve().then(a.bind(null,o)).then(f=>(c=f,n(c,o))).then(()=>c)}),t==="error"&&(i=(a,o)=>Promise.resolve().then(a.bind(null,o)).catch(c=>n(c,o))),e.registry[r].push({hook:i,orig:n})}function Ap_(e,t,r){if(!e.registry[t])return;let i=e.registry[t].map(n=>n.orig).indexOf(r);i!==-1&&e.registry[t].splice(i,1)}var mp_=Function.bind,Pp_=mp_.bind(mp_);function jp_(e,t,r){let i=Pp_(Ap_,null).apply(null,r?[t,r]:[t]);e.api={remove:i},e.remove=i,["before","error","after","wrap"].forEach(n=>{let a=r?[t,n,r]:[t,n];e[n]=e.api[n]=Pp_(Op_,null).apply(null,a)})}function g2S(){let e=Symbol("Singular"),t={registry:{}},r=XQo.bind(null,t,e);return jp_(r,t,e),r}function O2S(){let e={registry:{}},t=XQo.bind(null,e);return jp_(t,e),t}var wp_={Singular:g2S,Collection:O2S};var A2S="0.0.0-development",m2S=`octokit-endpoint.js/${A2S} ${qR()}`,P2S={method:"GET",baseUrl:"https://api.github.com",headers:{accept:"application/vnd.github.v3+json","user-agent":m2S},mediaType:{format:""}};function j2S(e){return e?Object.keys(e).reduce((t,r)=>(t[r.toLowerCase()]=e[r],t),{}):{}}function w2S(e){if(typeof e!="object"||e===null||Object.prototype.toString.call(e)!=="[object Object]")return!1;let t=Object.getPrototypeOf(e);if(t===null)return!0;let r=Object.prototype.hasOwnProperty.call(t,"constructor")&&t.constructor;return typeof r=="function"&&r instanceof r&&Function.prototype.call(r)===Function.prototype.call(e)}function Mp_(e,t){let r=Object.assign({},e);return Object.keys(t).forEach(i=>{w2S(t[i])?i in e?r[i]=Mp_(e[i],t[i]):Object.assign(r,{[i]:t[i]}):Object.assign(r,{[i]:t[i]})}),r}function Ep_(e){for(let t in e)e[t]===void 0&&delete e[t];return e}function osc(e,t,r){if(typeof t=="string"){let[n,a]=t.split(" ");r=Object.assign(a?{method:n,url:a}:{url:n},r)}else r=Object.assign({},t);r.headers=j2S(r.headers),Ep_(r),Ep_(r.headers);let i=Mp_(e||{},r);return r.url==="/graphql"&&(e&&e.mediaType.previews?.length&&(i.mediaType.previews=e.mediaType.previews.filter(n=>!i.mediaType.previews.includes(n)).concat(i.mediaType.previews)),i.mediaType.previews=(i.mediaType.previews||[]).map(n=>n.replace(/-preview/,""))),i}function E2S(e,t){let r=/\?/.test(e)?"&":"?",i=Object.keys(t);return i.length===0?e:e+r+i.map(n=>n==="q"?"q="+t.q.split("+").map(encodeURIComponent).join("+"):`${n}=${encodeURIComponent(t[n])}`).join("&")}var S2S=/\{[^{}}]+\}/g;function M2S(e){return e.replace(/(?:^\W+)|(?:(?<!\W)\W+$)/g,"").split(/,/)}function D2S(e){let t=e.match(S2S);return t?t.map(M2S).reduce((r,i)=>r.concat(i),[]):[]}function Sp_(e,t){let r={__proto__:null};for(let i of Object.keys(e))t.indexOf(i)===-1&&(r[i]=e[i]);return r}function Dp_(e){return e.split(/(%[0-9A-Fa-f]{2})/g).map(function(t){return/%[0-9A-Fa-f]/.test(t)||(t=encodeURI(t).replace(/%5B/g,"[").replace(/%5D/g,"]")),t}).join("")}function TQn(e){return encodeURIComponent(e).replace(/[!'()*]/g,function(t){return"%"+t.charCodeAt(0).toString(16).toUpperCase()})}function UPa(e,t,r){return t=e==="+"||e==="#"?Dp_(t):TQn(t),r?TQn(r)+"="+t:t}function qQn(e){return e!=null}function asc(e){return e===";"||e==="&"||e==="?"}function B2S(e,t,r,i){var n=e[r],a=[];if(qQn(n)&&n!=="")if(typeof n=="string"||typeof n=="number"||typeof n=="boolean")n=n.toString(),i&&i!=="*"&&(n=n.substring(0,parseInt(i,10))),a.push(UPa(t,n,asc(t)?r:""));else if(i==="*")Array.isArray(n)?n.filter(qQn).forEach(function(o){a.push(UPa(t,o,asc(t)?r:""))}):Object.keys(n).forEach(function(o){qQn(n[o])&&a.push(UPa(t,n[o],o))});else{let o=[];Array.isArray(n)?n.filter(qQn).forEach(function(c){o.push(UPa(t,c))}):Object.keys(n).forEach(function(c){qQn(n[c])&&(o.push(TQn(c)),o.push(UPa(t,n[c].toString())))}),asc(t)?a.push(TQn(r)+"="+o.join(",")):o.length!==0&&a.push(o.join(","))}else t===";"?qQn(n)&&a.push(TQn(r)):n===""&&(t==="&"||t==="?")?a.push(TQn(r)+"="):n===""&&a.push("");return a}function I2S(e){return{expand:C2S.bind(null,e)}}function C2S(e,t){var r=["+","#",".","/",";","?","&"];return e=e.replace(/\{([^\{\}]+)\}|([^\{\}]+)/g,function(i,n,a){if(n){let c="",f=[];if(r.indexOf(n.charAt(0))!==-1&&(c=n.charAt(0),n=n.substr(1)),n.split(/,/g).forEach(function(s){var u=/([^:\*]*)(?::(\d+)|(\*))?/.exec(s);f.push(B2S(t,c,u[1],u[2]||u[3]))}),c&&c!=="+"){var o=",";return c==="?"?o="&":c!=="#"&&(o=c),(f.length!==0?c:"")+f.join(o)}else return f.join(",")}else return Dp_(a)}),e==="/"?e:e.replace(/\/$/,"")}function Bp_(e){let t=e.method.toUpperCase(),r=(e.url||"/").replace(/:([a-z]\w+)/g,"{$1}"),i=Object.assign({},e.headers),n,a=Sp_(e,["method","baseUrl","url","headers","request","mediaType"]),o=D2S(r);r=I2S(r).expand(a),/^http/.test(r)||(r=e.baseUrl+r);let c=Object.keys(e).filter(u=>o.includes(u)).concat("baseUrl"),f=Sp_(a,c);if(!/application\/octet-stream/i.test(i.accept)&&(e.mediaType.format&&(i.accept=i.accept.split(/,/).map(u=>u.replace(/application\/vnd(\.\w+)(\.v3)?(\.\w+)?(\+json)?$/,`application/vnd$1$2.${e.mediaType.format}`)).join(",")),r.endsWith("/graphql")&&e.mediaType.previews?.length)){let u=i.accept.match(/(?<![\w-])[\w-]+(?=-preview)/g)||[];i.accept=u.concat(e.mediaType.previews).map(l=>{let p=e.mediaType.format?`.${e.mediaType.format}`:"+json";return`application/vnd.github.${l}-preview${p}`}).join(",")}return["GET","HEAD"].includes(t)?r=E2S(r,f):"data"in f?n=f.data:Object.keys(f).length&&(n=f),!i["content-type"]&&typeof n<"u"&&(i["content-type"]="application/json; charset=utf-8"),["PATCH","PUT"].includes(t)&&typeof n>"u"&&(n=""),Object.assign({method:t,url:r,headers:i},typeof n<"u"?{body:n}:null,e.request?{request:e.request}:null)}function q2S(e,t,r){return Bp_(osc(e,t,r))}function Ip_(e,t){let r=osc(e,t),i=q2S.bind(null,r);return Object.assign(i,{DEFAULTS:r,defaults:Ip_.bind(null,r),merge:osc.bind(null,r),parse:Bp_})}var Cp_=Ip_(null,P2S);var Fp_=ue(zp_(),1);var yFt=class extends Error{name;status;request;response;constructor(t,r,i){super(t),this.name="HttpError",this.status=Number.parseInt(r),Number.isNaN(this.status)&&(this.status=0),"response"in i&&(this.response=i.response);let n=Object.assign({},i.request);i.request.headers.authorization&&(n.headers=Object.assign({},i.request.headers,{authorization:i.request.headers.authorization.replace(/(?<! ) .*$/," [REDACTED]")})),n.url=n.url.replace(/\bclient_secret=\w+/g,"client_secret=[REDACTED]").replace(/\baccess_token=\w+/g,"access_token=[REDACTED]"),this.request=n}};var T2S="10.0.6",R2S={headers:{"user-agent":`octokit-request.js/${T2S} ${qR()}`}};function z2S(e){if(typeof e!="object"||e===null||Object.prototype.toString.call(e)!=="[object Object]")return!1;let t=Object.getPrototypeOf(e);if(t===null)return!0;let r=Object.prototype.hasOwnProperty.call(t,"constructor")&&t.constructor;return typeof r=="function"&&r instanceof r&&Function.prototype.call(r)===Function.prototype.call(e)}async function Np_(e){let t=e.request?.fetch||globalThis.fetch;if(!t)throw new Error("fetch is not set. Please pass a fetch implementation as new Octokit({ request: { fetch }}). Learn more at https://github.com/octokit/octokit.js/#fetch-missing");let r=e.request?.log||console,i=e.request?.parseSuccessResponseBody!==!1,n=z2S(e.body)||Array.isArray(e.body)?JSON.stringify(e.body):e.body,a=Object.fromEntries(Object.entries(e.headers).map(([l,p])=>[l,String(p)])),o;try{o=await t(e.url,{method:e.method,body:n,redirect:e.request?.redirect,headers:a,signal:e.request?.signal,...e.body&&{duplex:"half"}})}catch(l){let p="Unknown Error";if(l instanceof Error){if(l.name==="AbortError")throw l.status=500,l;p=l.message,l.name==="TypeError"&&"cause"in l&&(l.cause instanceof Error?p=l.cause.message:typeof l.cause=="string"&&(p=l.cause))}let _=new yFt(p,500,{request:e});throw _.cause=l,_}let c=o.status,f=o.url,s={};for(let[l,p]of o.headers)s[l]=p;let u={url:f,status:c,headers:s,data:""};if("deprecation"in s){let l=s.link&&s.link.match(/<([^<>]+)>; rel="deprecation"/),p=l&&l.pop();r.warn(`[@octokit/request] "${e.method} ${e.url}" is deprecated. It is scheduled to be removed on ${s.sunset}${p?`. See ${p}`:""}`)}if(c===204||c===205)return u;if(e.method==="HEAD"){if(c<400)return u;throw new yFt(o.statusText,c,{response:u,request:e})}if(c===304)throw u.data=await usc(o),new yFt("Not modified",c,{response:u,request:e});if(c>=400)throw u.data=await usc(o),new yFt(F2S(u.data),c,{response:u,request:e});return u.data=i?await usc(o):o.body,u}async function usc(e){let t=e.headers.get("content-type");if(!t)return e.text().catch(()=>"");let r=(0,Fp_.safeParse)(t);if(N2S(r)){let i="";try{return i=await e.text(),JSON.parse(i)}catch{return i}}else return r.type.startsWith("text/")||r.parameters.charset?.toLowerCase()==="utf-8"?e.text().catch(()=>""):e.arrayBuffer().catch(()=>new ArrayBuffer(0))}function N2S(e){return e.type==="application/json"||e.type==="application/scim+json"}function F2S(e){if(typeof e=="string")return e;if(e instanceof ArrayBuffer)return"Unknown error";if("message"in e){let t="documentation_url"in e?` - ${e.documentation_url}`:"";return Array.isArray(e.errors)?`${e.message}: ${e.errors.map(r=>JSON.stringify(r)).join(", ")}${t}`:`${e.message}${t}`}return`Unknown error: ${JSON.stringify(e)}`}function ssc(e,t){let r=e.defaults(t);return Object.assign(function(n,a){let o=r.merge(n,a);if(!o.request||!o.request.hook)return Np_(r.parse(o));let c=(f,s)=>Np_(r.parse(r.merge(f,s)));return Object.assign(c,{endpoint:r,defaults:ssc.bind(null,r)}),o.request.hook(c,o)},{endpoint:r,defaults:ssc.bind(null,r)})}var VO=ssc(Cp_,R2S);var Q2S="0.0.0-development";function U2S(e){return`Request failed due to following response errors:
|
|
@@ -2073,7 +2073,7 @@ ${Ut.dim(a.summary)}`}));r.push("Do you wish to continue?");let{[t]:i}=await n0o
|
|
|
2073
2073
|
`)[0];if(!o)return{version:null,failureReason:"config-not-tracked"};let{stdout:c,failed:f}=await ov(t,"git",["show",`HEAD:${o}`],{cwd:n,doNotPipeOutput:!0,reject:!1});if(f||!c.trim())return{version:null,failureReason:"no-git-history"};let u=JSON.parse(c).version??null;return u==null?{version:null,failureReason:"no-version-field"}:{version:u}}catch(r){return t.debug(`Failed to retrieve version from git: ${r}`),{version:null,failureReason:"parse-error"}}}async function g9j({fromVersion:e,fromGit:t,cliContext:r,fernDirectory:i,projectConfig:n,isLocalDev:a}){let o=e?.trim(),c=process.env[c0s]?.trim(),f=A9j({cliVersion:r.environment.packageVersion,fromVersion:e,isLocalDev:a});if(!o&&c&&c!=="0.0.0"&&!f&&!t&&(o=c),!o||f||t){let s=await MB8(i,r.logger);if(s.version!=null)f&&r.logger.debug(`Detected faulty upgrade (FERN_PRE_UPGRADE_VERSION=${process.env[c0s]}). Using version from git history: ${s.version}`),o=s.version;else if(f){let u=v9j(s.failureReason);r.logger.warn(`Detected potential faulty upgrade but could not retrieve version from git history${u}. Using current config version: ${n.version}`),o=n.version}else if(t){let u=v9j(s.failureReason);r.logger.debug(`Could not retrieve version from git${u}. Falling back to config.`),o=o||n.version}else o=o||n.version}return o}function DB8({cliContext:e,targetVersion:t,currentVersion:r}){kH(t,r)||e.failAndThrow(`Cannot upgrade because target version (${t}) is not ahead of existing version ${r}`)}function BB8(e){let t=new Set(["--version","--to","--from","--from-git"]),r=[],i=0;for(;i<e.length;){let n=e[i];if(i===0&&n==="upgrade"){i++;continue}let a=t.has(n??""),o=Array.from(t).some(c=>n?.startsWith(`${c}=`));a?(i++,i<e.length&&!e[i]?.startsWith("-")&&i++):(o||n!=null&&r.push(n),i++)}return r}async function m9j({cliContext:e,includePreReleases:t,targetVersion:r,fromVersion:i,fromGit:n,yes:a}){let o=e.environment.packageVersion==="0.0.0",c=r?.trim();if(!c){let h=(await e.isUpgradeAvailable({includePreReleases:t})).cliUpgradeInfo;if(h!=null&&h.isUpgradeAvailable)c=h.latestVersion;else{if(o){e.logger.info("No upgrade available.");return}let b=await Gw();if(b==null)return e.failAndThrow(`Directory "${r1}" not found.`);let v=await e.runTask(A=>U_e({directory:b,context:A})),O=A9j({cliVersion:e.environment.packageVersion,fromVersion:i,isLocalDev:o});if(v.version!==e.environment.packageVersion||O)c=e.environment.packageVersion,O?e.logger.info(`Detected faulty upgrade. Config version is ${v.version}, CLI version is ${e.environment.packageVersion}`):e.logger.info(`No newer version available, but config version (${v.version}) differs from CLI version (${e.environment.packageVersion})`);else{e.logger.info("No upgrade available.");return}}}if(e.environment.packageVersion===c||o){let _=await Gw();if(_==null)return e.failAndThrow(`Directory "${r1}" not found.`);let h=await e.runTask(v=>U_e({directory:_,context:v})),y=await g9j({fromVersion:i,fromGit:n,cliContext:e,fernDirectory:_,projectConfig:h,isLocalDev:o});e.logger.info(`Running migrations from ${Ut.dim(y)} \u2192 ${Ut.green(c)}`),await e.runTask(async v=>{await jgd({fromVersion:y,toVersion:c,context:v,yes:a??!1})}),await e.exitIfFailed();let b=HKo(h.rawConfig,v=>{v.version=c});await(0,O9j.writeFile)(h._absolutePath,SB8(JSON.stringify(b,void 0,2))),e.logger.info(`Updated fern.config.json to version ${Ut.green(c)}`);return}DB8({cliContext:e,targetVersion:c,currentVersion:e.environment.packageVersion});let f=await Gw();if(f==null)return e.failAndThrow(`Directory "${r1}" not found.`);let s=await e.runTask(_=>U_e({directory:f,context:_})),u=await g9j({fromVersion:i,fromGit:n,cliContext:e,fernDirectory:f,projectConfig:s,isLocalDev:o});e.logger.info(`Upgrading from ${Ut.dim(e.environment.packageVersion)} \u2192 ${Ut.green(c)}`);let l=BB8(process.argv.slice(2)),p=["upgrade","--from",u,"--to",c,...l];a&&!l.some(_=>_==="--yes"||_==="-y")&&p.push("--yes");try{await Aeo({version:c,cliContext:e,env:{[c0s]:u},args:p,throwOnError:!0})}catch(_){if(_ instanceof Oeo){e.logger.debug(`Rerun CLI failed with stdout: ${_.stdout}`),e.logger.debug(`Rerun CLI failed with stderr: ${_.stderr}`);let h=(_.stderr??"")+(_.stdout??"");if(h.includes("ETARGET")||h.includes("E404")||h.includes("404 Not Found")||h.includes("No matching version found")||h.includes("version not found"))return e.failAndThrow(`Failed to upgrade to ${c} because it does not exist. See https://www.npmjs.com/package/${e.environment.packageName}?activeTab=versions.`)}throw _}}async function P9j({project:e,cliContext:t,errorOnBrokenLinks:r}){let i=e.docsWorkspaces;if(i==null){t.failAndThrow("No docs workspace found");return}await t.runTaskForWorkspace(i,async n=>{let a=performance.now(),o=await Promise.all(e.apiWorkspaces.map(async u=>u.toFernWorkspace({context:n}))),c=await oU(e),f=await _Ma(i,n,o,c,!0),s=performance.now()-a;R3n({violations:f,context:n,logWarnings:!0,logSummary:!0,logBreadcrumbs:!1,elapsedMillis:s}),f.length>0&&r&&n.failAndThrow()})}async function j9j({project:e,cliContext:t,logWarnings:r,brokenLinks:i,errorOnBrokenLinks:n,isLocal:a,directFromOpenapi:o}){let c=e.docsWorkspaces;c!=null&&await t.runTaskForWorkspace(c,async f=>{let s=i||n?[]:["valid-markdown-links"];await FKo({workspace:c,context:f,logWarnings:r,apiWorkspaces:e.apiWorkspaces,ossWorkspaces:await oU(e),errorOnBrokenLinks:n,excludeRules:s})}),await Promise.all(e.apiWorkspaces.map(async f=>{f.generatorsConfiguration?.groups.length===0&&f.type!="fern"||await t.runTaskForWorkspace(f,async s=>{if(f instanceof Xw&&o){await f.getIntermediateRepresentation({context:s,audiences:{type:"all"},enableUniqueErrorsPerEndpoint:!1,generateV1Examples:!1,logWarnings:r});return}let u=await f.toFernWorkspace({context:s});await z_i({workspace:u,context:s,logWarnings:r,ossWorkspace:f instanceof Xw?f:void 0})})}))}var k_i=require("fs/promises");var wgd=ue(require("path"),1);async function w9j({project:e,cliContext:t,sdkLanguage:r,preserveSchemaIds:i}){await Promise.all(e.apiWorkspaces.map(async n=>{await t.runTaskForWorkspace(n,async a=>{n instanceof rK?await IB8({workspace:n,context:a}):await CB8({workspace:await n.toFernWorkspace({context:a},{preserveSchemaIds:i}),context:a})})}))}async function IB8({workspace:e,context:t}){for(let[r,i]of Object.entries(e.definition.importedDefinitions)){let n=It(e.absoluteFilePath,Ze.of(pR),Ze.of(r),Ze.of(`.${pR}`));await E9j({definition:i.definition,absolutePathToOutputDirectory:n}),t.logger.info(Ut.green(`Wrote imported definition at ${wgd.default.relative(process.cwd(),n)}`))}}async function CB8({workspace:e,context:t}){let r=It(e.absoluteFilePath,Ze.of(`.${pR}`));await E9j({definition:e.definition,absolutePathToOutputDirectory:r}),t.logger.info(Ut.green(`Wrote definition to ${wgd.default.relative(process.cwd(),r)}`))}async function E9j({definition:e,absolutePathToOutputDirectory:t}){let r=(i,n)=>{let a={imports:0,types:1,services:2},o=i in a?a[i]:Object.keys(a).length,c=n in a?a[n]:Object.keys(a).length;return o==null?-1:c==null?1:o!==c?o-c:i.localeCompare(n)};await qi(t)&&await(0,k_i.rm)(t,{recursive:!0}),await(0,k_i.mkdir)(t,{recursive:!0}),await(0,k_i.writeFile)(It(t,Ze.of(i1)),wi.dump(e.rootApiFile.contents,{sortKeys:r}));for(let[i,n]of Object.entries(e.packageMarkers)){let a=It(t,Ze.of(i));await(0,k_i.mkdir)(Zi(a),{recursive:!0}),await(0,k_i.writeFile)(a,wi.dump(n.contents,{sortKeys:r}))}for(let[i,n]of Object.entries(e.namedDefinitionFiles)){let a=It(t,Ze.of(i));await(0,k_i.mkdir)(Zi(a),{recursive:!0}),await(0,k_i.writeFile)(a,wi.dump(n.contents,{sortKeys:r}))}}var S9j=require("fs/promises");async function M9j({project:e,outputPath:t,cliContext:r}){let i=e.docsWorkspaces;i!=null&&await r.runTaskForWorkspace(i,async n=>{let a=await oU(e),o=await Promise.all(e.apiWorkspaces.map(async s=>s.toFernWorkspace({context:n},{enableUniqueErrorsPerEndpoint:!0,detectGlobalHeaders:!1}))),f=await new xFt({domain:i.config.instances[0]?.url??"http://localhost:8080",docsWorkspace:i,ossWorkspaces:a,apiWorkspaces:o,taskContext:n,editThisPage:void 0,uploadFiles:void 0,registerApi:void 0,targetAudiences:i.config.instances[0]?.audiences?Array.isArray(i.config.instances[0].audiences)?i.config.instances[0].audiences:[i.config.instances[0].audiences]:void 0}).resolve();await(0,S9j.writeFile)(Rr.of(t),JSON.stringify(f,null,2)),n.logger.info(Ut.green(`Docs definition written to ${t}`))})}var G9j=ue(NAc(),1),Ula=require("fs"),FRt=require("fs/promises"),H9j=ue(Auc(),1),Igd=ue(require("path"),1);var qB8="https://r88yjrnw5k.execute-api.us-east-1.amazonaws.com/dev2/translate",TB8=3,RB8=1e3,zB8=3e4,NB8=3e4;function D9j(e,t){if(e.name==="AbortError"||e.code==="ECONNRESET"||e.code==="ENOTFOUND"||e.code==="ECONNREFUSED"||e.code==="ETIMEDOUT")return!0;if(e.cause instanceof Error){let r=e.cause;if(r.code==="ECONNRESET"||r.code==="ENOTFOUND"||r.code==="ECONNREFUSED"||r.code==="ETIMEDOUT")return!0}if(t){let r=t.status;if(r>=500&&r<600||r===429||r===408)return!0}return!1}function B9j(e,t,r){let i=t*Math.pow(2,e-1),n=Math.random()*.1*i;return Math.min(i+n,r)}function FB8(e,t,r){let i=new AbortController,n=setTimeout(()=>i.abort(),r);return fetch(e,{...t,signal:i.signal}).finally(()=>{clearTimeout(n)})}async function meo({text:e,language:t,sourceLanguage:r,fileType:i,cliContext:n,retryConfig:a={}}){if(t===r)return e;let o=await n7i();if(o==null)throw n.logger.error("Authentication required. Please run 'fern login' or set the FERN_TOKEN environment variable."),new Error("Authentication required for translation service");let c={maxRetries:a.maxRetries??TB8,baseDelay:a.baseDelay??RB8,maxDelay:a.maxDelay??zB8,timeout:a.timeout??NB8},f;for(let u=1;u<=c.maxRetries+1;u++)try{let l=await FB8(qB8,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${o.value}`},body:JSON.stringify({text:e,source_language:r,target_language:t,...i!==void 0&&{file_type:i}})},c.timeout);if(!l.ok){let _="";try{let y=await l.json();_=y.detail||JSON.stringify(y)}catch{_=await l.text()}if(l.status===403)throw new Error(`403: ${_}`);let h=new Error(`HTTP ${l.status}: ${_}`);if(!D9j(h,l))return n.logger.debug(`[TRANSLATE] Non-retriable error ${l.status}: ${_}`),e;if(f=h,u<=c.maxRetries){n.logger.debug(`[TRANSLATE] Attempt ${u} failed with status ${l.status}: ${_}. Retrying...`);let y=B9j(u,c.baseDelay,c.maxDelay);await new Promise(b=>setTimeout(b,y));continue}else return n.logger.debug(`[TRANSLATE] All ${c.maxRetries+1} attempts failed. Final error: ${_}`),e}let p=await l.json();return u>1&&n.logger.debug(`[TRANSLATE] Succeeded on attempt ${u} after ${u-1} retries`),await new Promise(_=>setTimeout(_,500)),p.translated_text??e}catch(l){if(f=l,l instanceof Error&&l.message.includes("403"))throw l;if(l instanceof Error&&!D9j(l)){let h=l instanceof Error?l.message:String(l);return n.logger.debug(`[TRANSLATE] Non-retriable error: ${h}`),e}if(u>c.maxRetries){let h=l instanceof Error?l.message:String(l);return n.logger.debug(`[TRANSLATE] All ${c.maxRetries+1} attempts failed. Final error: ${h}`),e}let p=l instanceof Error?l.message:String(l);n.logger.debug(`[TRANSLATE] Attempt ${u} failed: ${p}. Retrying...`);let _=B9j(u,c.baseDelay,c.maxDelay);await new Promise(h=>setTimeout(h,_))}let s=f instanceof Error?f.message:f?String(f):"Unknown error";return n.logger.debug(`[TRANSLATE] Unexpected end of retry loop. Last error: ${s}`),e}var QB8=new Set(["title","display-name","page","section","text","link","message","subtitle","search-text","system-prompt","summary","description","docs","tags","api"]);function I9j(e,t){return typeof t!="string"||t==="string"||t.startsWith("./")?!1:!!QB8.has(e)}function BSn({name:e}){let t=e.replace(/\.(md|mdx)$/i,"");return Rw(t)}function UB8(e){if(typeof e!="object"||e===null)return!1;let t=e;return typeof t.page=="string"&&typeof t.path=="string"}function LB8(e){if(typeof e!="object"||e===null)return!1;let t=e;return typeof t.section=="string"&&Array.isArray(t.contents)}function VB8(e){return typeof e!="object"||e===null?!1:typeof e.api=="string"}function WB8(e){return typeof e!="object"||e===null?!1:typeof e.changelog=="string"}function xB8(e){if(typeof e!="object"||e===null)return!1;let t=e;return typeof t["display-name"]=="string"||typeof t.displayName=="string"}function GB8(e){if(typeof e!="object"||e===null)return!1;let t=e;return(typeof t["display-name"]=="string"||typeof t.displayName=="string")&&typeof t.path=="string"}function HB8(e){if(typeof e!="object"||e===null)return;let t=e;if(typeof t.slug=="string")return t.slug;if(t["skip-slug"]!==!0){if(UB8(e))return BSn({name:e.page});if(LB8(e))return BSn({name:e.section});if(VB8(e)){let r=e["api-name"],i=e.api;return BSn({name:typeof r=="string"?r:i})}if(WB8(e)){let r=e.title;if(typeof r=="string")return BSn({name:r});let i=e.changelog;if(typeof i=="string"){let n=i.split("/").pop()||i;return BSn({name:n})}}if(xB8(e)){let r=e["display-name"]||e.displayName;if(typeof r=="string")return BSn({name:r})}if(GB8(e)){let r=e["display-name"]||e.displayName;if(typeof r=="string")return BSn({name:r})}}}async function Egd({obj:e,language:t,sourceLanguage:r,filePath:i,cliContext:n,stub:a,sourceObj:o}){if(e==null||typeof e=="string")return e;if(Array.isArray(e)){let c=Array.isArray(o)?o:void 0;return await Promise.all(e.map((f,s)=>Egd({obj:f,language:t,sourceLanguage:r,filePath:i,cliContext:n,stub:a,sourceObj:c?.[s]})))}if(typeof e=="object"){let c={},f=typeof o=="object"&&o!==null?o:void 0,s;s=HB8(e);for(let[u,l]of Object.entries(e))if(u!=="slug")if(I9j(u,l)){if(a){c[u]=l;continue}c[u]=await meo({text:l,language:t,sourceLanguage:r,cliContext:n})}else c[u]=await Egd({obj:l,language:t,sourceLanguage:r,filePath:i,cliContext:n,stub:a,sourceObj:f?.[u]});return s!==void 0&&(c.slug=s),c}return e}async function C9j({yamlContent:e,language:t,sourceLanguage:r,filePath:i,cliContext:n,stub:a=!1}){if(t===r)return e;try{let o=uBn(e);if(!o)return e;let c=await Egd({obj:o,language:t,sourceLanguage:r,filePath:i,cliContext:n,stub:a,sourceObj:o});return j6i(c,{indent:2,lineWidth:-1,quotingType:'"',forceQuotes:!1})}catch(o){if(o instanceof Error&&o.message.includes("403"))throw o;return n.logger.error(` [ERROR] Failed to process YAML file ${i}: ${o}`),e}}async function l0s({transformation:e,cliContext:t,stub:r=!1}){let{filePath:i,language:n,sourceLanguage:a,originalContent:o}=e;if(r&&!i.endsWith(".yml")&&!i.endsWith(".yaml"))return t.logger.debug(`[STUB] Returning content as-is for ${i} (stub mode enabled)`),o;t.logger.debug(`[PROCESSING] ${i} for language: ${n} (source: ${a})`);try{return(i.endsWith(".yml")||i.endsWith(".yaml"))&&!i.includes("generators.yml")?await C9j({yamlContent:o,language:n,sourceLanguage:a,filePath:i,cliContext:t,stub:r}):i.endsWith(".md")||i.endsWith(".mdx")?meo({text:o,language:n,sourceLanguage:a,fileType:"MDX",cliContext:t}):i.endsWith(".json")&&!i.includes("fern.config.json")?meo({text:o,language:n,sourceLanguage:a,cliContext:t}):(t.logger.debug(`[SKIP] Skipping file "${i}" - unsupported file type for translation.`),o)}catch(c){if(c instanceof Error&&c.message.includes("403"))throw c;return o}}function q9j(e){let t=[".png",".jpg",".jpeg",".gif",".svg",".webp",".ico",".bmp",".tiff",".tif",".woff",".woff2",".ttf",".otf",".eot",".pdf",".doc",".docx",".mp4",".webm",".ogg",".mp3",".wav",".zip",".tar",".gz",".bin"],r=e.toLowerCase();return t.some(i=>r.endsWith(i))}function T9j(e,t){return e.endsWith(".yaml")||e.endsWith(".yml")?!0:e.endsWith(".md")||e.endsWith(".mdx")||e.endsWith(".json")&&!e.includes("fern.config.json")?!t:!1}var d0s=require("fs/promises");function f0s(e,t){try{let r=new URL(e),i=r.hostname,n=e.endsWith("/");if(i.includes(".docs.buildwithfern.com")){let o=i.split(".")[0];r.hostname=`${o}-${t}.docs.buildwithfern.com`,r.pathname=`/${t}${r.pathname}`}else r.hostname=`${t}.${i}`,r.pathname=`/${t}${r.pathname}`;let a=r.toString();return!n&&a.endsWith("/")&&r.pathname===`/${t}/`&&(a=a.slice(0,-1)),a}catch{let r=e.endsWith("/");if(e.includes("://")){let[i,n]=e.split("://"),[a,...o]=n?.split("#")??[],[c,...f]=a?.split("?")??[],[s,...u]=c?.split("/")??[];if(!s)return e;let l;s.includes(".docs.buildwithfern.com")?l=`${s.split(".")[0]}-${t}.docs.buildwithfern.com/${t}`:l=`${t}.${s}/${t}`;let p=`${i}://${l}`;return u.length>0?p+="/"+u.join("/"):r&&(p+="/"),f.length>0&&(p+="?"+f.join("?")),o.length>0&&(p+="#"+o.join("#")),p}else if(e.includes("/")){let i=e.split("/"),n=i[0],a=i.slice(1),o;return n?.includes(".docs.buildwithfern.com")?o=`${n.split(".")[0]}-${t}.docs.buildwithfern.com/${t}`:o=`${t}.${n}/${t}`,a.length>0||a.some(c=>c!=="")?`${o}/${a.join("/")}`:r?`${o}/`:o}else return e.includes(".docs.buildwithfern.com")?`${e.split(".")[0]}-${t}.docs.buildwithfern.com/${t}`:`${t}.${e}/${t}`}}function KB8(e,t){let r=JB8({docsConfig:e,language:t});return $B8({docsConfig:r,language:t})}function JB8({docsConfig:e,language:t}){let r=structuredClone(e);return r.settings?(r.settings.language=t,r.settings["search-text"]=R9j[t]):r.settings={language:t,"search-text":R9j[t]},r}var R9j={en:"Search",es:"Buscar",fr:"Rechercher",de:"Suchen",it:"Cerca",pt:"Pesquisar",ja:"\u691C\u7D22",zh:"\u641C\u7D22",ko:"\uAC80\uC0C9",el:"\u0391\u03BD\u03B1\u03B6\u03AE\u03C4\u03B7\u03C3\u03B7",no:"S\xF8k",pl:"Szukaj",ru:"\u041F\u043E\u0438\u0441\u043A",sv:"S\xF6k",tr:"Ara"};function $B8({docsConfig:e,language:t}){let r=structuredClone(e);return r.instances&&Array.isArray(r.instances)&&(r.instances=r.instances.map(i=>{let n={...i};if(n.url&&(n.url=f0s(n.url,t)),n["custom-domain"]){let a=n["custom-domain"];typeof a=="string"?n["custom-domain"]=f0s(a,t):Array.isArray(a)&&(n["custom-domain"]=a.map(o=>f0s(o,t)))}return n})),r}async function z9j({originalDocsConfigPath:e,targetDirectory:t,language:r,sourceLanguage:i,context:n,stub:a=!1}){try{let o=await(0,d0s.readFile)(e,"utf-8"),f=await l0s({transformation:{filePath:uP,language:r,sourceLanguage:i,originalContent:o},cliContext:n,stub:a}),s=wi.load(f),u=KB8(s,r),l=It(t,Ze.of(uP)),p=wi.dump(u,{sortKeys:!1});await(0,d0s.writeFile)(l,p,"utf-8"),n.logger.debug(`Created language-specific docs config: ${l}`)}catch(o){if(o instanceof Error&&o.message.includes("403"))throw o;n.logger.warn(`Failed to create language-specific docs config for ${r}: ${o}`)}}var N9j=require("fs"),F9j=require("fs/promises"),Q9j=ue(require("path"),1);async function Sgd(e,t){let r={},i=await(0,F9j.readdir)(e);for(let n of i){if(n==="translations")continue;let a=Q9j.default.join(e,n),o=t?It(t,Ze.of(n)):Ze.of(n),c=(0,N9j.statSync)(a);if(c.isDirectory()){let f=await Sgd(a,o);for(let[s,u]of Object.entries(f))r[s]=u}else c.isFile()&&(r[a]=o)}return r}var U9j=require("crypto"),L9j=require("fs"),Peo=require("fs/promises"),Mgd=ue(require("path"),1);function V9j(e){return(0,U9j.createHash)("sha256").update(e,"utf-8").digest("hex")}async function W9j(e){let t=Mgd.default.join(e,"hashes");if(!(0,L9j.existsSync)(t))return{};try{let r=await(0,Peo.readFile)(t,"utf-8"),i=JSON.parse(r),{_comment:n,...a}=i;return a}catch{return{}}}async function Dgd(e,t){let r=Mgd.default.join(e,"hashes"),i={};Object.keys(t).sort().forEach(a=>{let o=t[a];o!==void 0&&(i[a]=o)});let n={_comment:"This file is auto-generated by Fern to track source file changes for translation purposes. Do not edit manually - it will be overwritten on the next translation update.",...i};await(0,Peo.writeFile)(r,JSON.stringify(n,null,2),"utf-8")}async function p0s(e,t,r){try{let i=await(0,Peo.readFile)(e,"utf-8"),n=V9j(i),a=r[t];return n!==a}catch{return!0}}function YB8(e,t,r){let i=V9j(r);e[t]=i}async function Bgd(e,t,r,i){YB8(t,r,i),await Dgd(e,t)}function x9j(e,t){let r={};for(let[i,n]of Object.entries(e))t.has(i)&&(r[i]=n);return r}async function K9j({project:e,cliContext:t,stub:r=!1}){let i=e.docsWorkspaces;if(i==null){t.logger.error("No docs workspace found. Please ensure you have a docs.yml file configured.");return}let n=i.config.languages;if(n==null||n.length===0){t.logger.error("No languages found in docs.yml configuration. Please add a 'languages' field with the desired languages.");return}await t.runTaskForWorkspace(i,async a=>{let o=i.absoluteFilePath,c=It(o,Ze.of("translations")),f=n[0];if(!f)throw new Error("Unexpected error - first element of languages array is invalid");(0,Ula.existsSync)(c)||(a.logger.debug(`Creating translations directory at: ${c}`),await(0,FRt.mkdir)(c,{recursive:!0}));let s={},u=n.filter(y=>y!==f),l=It(o,Ze.of(uP)),p=(0,Ula.existsSync)(l);for(let y of u){let b=It(c,Ze.of(y),Ze.of("fern"));(0,Ula.existsSync)(b)||await(0,FRt.mkdir)(b,{recursive:!0}),s[y]={filesProcessed:0,filesSkipped:0}}s[f]={filesProcessed:0,filesSkipped:0};let _={filesProcessed:0,filesSkipped:0};try{let y=await W9j(c),b=await Sgd(o,""),v=Object.entries(b),O=new Set(Object.values(b)),A=x9j(y,O);Object.keys(A).length!==Object.keys(y).length&&await Dgd(c,A),y=A;let g=[];for(let[R,z]of v)p&&z===uP||T9j(R,r)&&await p0s(R,z,y)&&g.push([R,z]);let m=!1;p&&(m=await p0s(l,Ze.of(uP),y));let j=g.length+(m?1:0),M=j*u.length,E=process.stdout.isTTY&&!H9j.default&&M>0,D;E&&(D=new G9j.default.SingleBar({format:"Processing files [{bar}] {percentage}% | {value}/{total} files",barCompleteChar:"\u2588",barIncompleteChar:"\u2591",hideCursor:!0,clearOnComplete:!1,stopOnComplete:!0}),D.start(M,0));let B=0,F=0;try{if(p)if(m){for(let U of u){B++,F++,E||a.logger.info(Ut.gray(`[${F}/${j+1}] Processing: ${uP} (docs config) for language: ${U}`)),t.logger.debug(`[PROCESSING] ${uP} (docs config) for language: ${U}`);let W=It(c,Ze.of(U),Ze.of("fern"));await z9j({originalDocsConfigPath:l,targetDirectory:W,language:U,sourceLanguage:f,context:t,stub:r});let K=s[U];D&&D.update(B),K&&K.filesProcessed++,t.logger.debug(`[COMPLETED] ${uP} -> ${U}/${uP}`)}let R=await(0,FRt.readFile)(l,"utf-8");await Bgd(c,y,Ze.of(uP),R);let z=s[f];z&&z.filesProcessed++,t.logger.debug(`[HASH UPDATED] ${uP} -> ${f} (source language - hash updated)`)}else{for(let R of n){let z=s[R];z&&z.filesSkipped++}t.logger.debug(`[SKIPPED] ${uP} (no changes since last translation)`)}for(let[R,z]of v){if(p&&z===uP){t.logger.debug(`[SKIPPED] ${z} (already handled by docs config processing)`);continue}if(!await p0s(R,z,y)){for(let fe of n){let pe=s[fe];pe&&pe.filesSkipped++}t.logger.debug(`[SKIPPED] ${z} (no changes since last translation)`);continue}t.logger.debug(`[PROCESSING] ${z} (detected changes)`);let W=await(0,FRt.readFile)(R,"utf-8");await Bgd(c,y,z,W);let K=s[f];K&&K.filesProcessed++,t.logger.debug(`[HASH UPDATED] ${z} -> ${f} (source language - hash only)`);for(let fe of u){F++,B++,E||a.logger.info(Ut.gray(`[${F}/${j}] Processing: ${z}`));let pe=It(c,Ze.of(fe),Ze.of("fern")),L=It(pe,z),G=Igd.default.dirname(L);(0,Ula.existsSync)(G)||await(0,FRt.mkdir)(G,{recursive:!0});let le=await l0s({transformation:{filePath:z,language:fe,sourceLanguage:f,originalContent:W},cliContext:t,stub:r});await(0,FRt.writeFile)(L,le,"utf-8");let De=s[fe];De&&De.filesProcessed++,t.logger.debug(`[COMPLETED] ${z} -> ${fe}/${z}`),D&&D.update(B)}}}finally{D&&(D.update(M),D.stop(),t.logger.info())}a.logger.info(Ut.cyan("Copying asset files..."));let N=0;for(let[R,z]of v)if(q9j(R))for(let U of u){let W=It(c,Ze.of(U),Ze.of("fern")),K=It(W,z),fe=Igd.default.dirname(K);(0,Ula.existsSync)(fe)||await(0,FRt.mkdir)(fe,{recursive:!0}),await(0,FRt.copyFile)(R,K),N++,t.logger.debug(`[ASSET COPIED] ${z} -> ${U}/${z}`)}N>0&&a.logger.info(Ut.green(`\u2713 Copied ${N} asset files to translation directories`));for(let R of n){let z=s[R];if(!z)continue;_.filesProcessed+=z.filesProcessed,_.filesSkipped+=z.filesSkipped;let U=z.filesProcessed+z.filesSkipped;R===f?(a.logger.info(Ut.blue(`${R} (source) hash tracking summary: ${z.filesProcessed} processed, ${z.filesSkipped} skipped (${U} total)`)),a.logger.info(Ut.green(`\u2713 Successfully tracked ${R} source language hashes (no directory created)`))):(a.logger.info(Ut.blue(`${R} translation summary: ${z.filesProcessed} processed, ${z.filesSkipped} skipped (${U} total)`)),a.logger.info(Ut.green(`\u2713 Successfully created ${R} translation with content processing`)))}}catch(y){throw y instanceof Error&&y.message.includes("403")||a.logger.error(`Failed to create translations: ${y}`),y}let h=_.filesProcessed+_.filesSkipped;if(a.logger.info(Ut.cyan(`Overall summary: ${_.filesProcessed} files processed, ${_.filesSkipped} files skipped across ${n.length} languages (${h} total operations)`)),a.logger.info(Ut.green(`Translations created successfully in: ${c}`)),u.length>0){a.logger.info("You can now modify the content in each language directory:");for(let y of u)a.logger.info(Ut.blue(` - ${y}: ${It(c,Ze.of(y))}`))}if(a.logger.info(`Source language (${f}) values are tracked as hashes in translations/hashes`),p&&u.length>0){a.logger.info("Language-specific docs configurations created with modified instance URLs:");for(let y of u)a.logger.info(` - ${y}/docs.yml: URLs modified to include ${y} prefix`)}})}var _0s=XB8();function XB8(){return typeof window<"u"&&typeof window.document<"u"?{type:"browser",version:window.navigator.userAgent}:typeof globalThis<"u"&&globalThis?.navigator?.userAgent==="Cloudflare-Workers"?{type:"workerd"}:typeof EdgeRuntime=="string"?{type:"edge-runtime"}:typeof self=="object"&&typeof self?.importScripts=="function"&&(self.constructor?.name==="DedicatedWorkerGlobalScope"||self.constructor?.name==="ServiceWorkerGlobalScope"||self.constructor?.name==="SharedWorkerGlobalScope")?{type:"web-worker"}:typeof Deno<"u"&&typeof Deno.version<"u"&&typeof Deno.version.deno<"u"?{type:"deno",version:Deno.version.deno}:typeof Bun<"u"&&typeof Bun.version<"u"?{type:"bun",version:Bun.version}:typeof process<"u"&&"version"in process&&!!process.version&&"versions"in process&&!!process.versions?.node?{type:"node",version:process.versions.node,parsedVersion:Number(process.versions.node.split(".")[0])}:typeof navigator<"u"&&navigator?.product==="ReactNative"?{type:"react-native"}:{type:"unknown"}}p38();var d38="The Fern CLI requires Node 18+ or above.";async function p38(){let e=process.argv.includes("--local"),t=new YQo(process.stdout,process.stderr,{isLocal:e}),r=async()=>{await t.exit()};if(_0s.type==="node"&&_0s.parsedVersion!=null&&_0s.parsedVersion>=18){let{setGlobalDispatcher:i,Agent:n}=await Promise.resolve().then(()=>ue(Ymd(),1));i(new n({connect:{timeout:2147483647},bodyTimeout:0,headersTimeout:2147483647}))}if(process.env.HTTP_PROXY!=null){let{setGlobalDispatcher:i,ProxyAgent:n}=await Promise.resolve().then(()=>ue(Ymd(),1)),a=new n(process.env.HTTP_PROXY);i(a)}process.on("SIGINT",async()=>{t.suppressUpgradeMessage(),await r()});try{let i=process.env[geo];i!=null&&process.chdir(i);let n=await h38(t);t.environment.packageVersion===n?await _38(t):await Aeo({version:n,cliContext:t})}catch(i){await t.instrumentPostHogEvent({command:process.argv.join(" "),properties:{failed:!0,error:i}}),i?.message.includes("globalThis")?(t.logger.error(d38),t.failWithoutThrowing()):i instanceof TE?t.failWithoutThrowing():i instanceof Chi?t.logger.error(`Failed. ${i.log}`):t.failWithoutThrowing("Failed.",i)}await r()}async function _38(e){let t=Rl_(noc(process.argv)).scriptName(e.environment.cliName).version(!1).fail((r,i,n)=>{i==null&&(n.showHelp(),e.logger.error(r))}).strict().exitProcess(!1).command("$0",!1,r=>r.option("version",{describe:"Print current version",alias:"v"}).version(!1),r=>{r.version!=null?e.logger.info(e.environment.packageVersion):(t.showHelp(),e.failAndThrow())}).option("log-level",{default:$s.Info,choices:aMi}).demandCommand().recommendCommands();v38(t,e),g38(t,e),b38(t,e),O38(t,e),A38(t,e),m38(t,e),P38(t,e),E38(t,e),j38(t,e),w38(t,e),D38(t,e),S38(t,e),M38(t,e),T38(t,e),R38(t,e),z38(t,e),W38(t,e),x38(t,e),F38(t,e),Q38(t,e),V38(t,e),N38(t,e),C38(t,e),q38(t,e),B38({cli:t,cliContext:e,onRun:()=>{e.suppressUpgradeMessage()}}),I38(t,e),K38(t,e),J38(t,e),$38(t,e),Y38(t,e),Kq_(t,e),Jq_(t,e),X38(t,e),t.middleware(async r=>{e.setLogLevel(r["log-level"]),e.logFernVersionDebug()}),await t.parse()}async function h38(e){if(process.env.FERN_NO_VERSION_REDIRECTION==="true")return e.environment.packageVersion;let t=await Gw();if(t!=null){let r=await e.runTask(i=>U_e({directory:t,context:i}));return r.version==="*"?e.environment.packageVersion:r.version}return qCi({cliEnvironment:e.environment})}async function y38(e){let t=await Gw();if(t!=null)return(await e.runTask(i=>U_e({directory:t,context:i}))).organization}function b38(e,t){e.command("init","Initialize a Fern API",r=>r.option("api",{boolean:!0,description:"Initialize an api."}).option("docs",{boolean:!0,description:"Initialize a docs website."}).option("organization",{alias:"org",type:"string",description:"Organization name"}).option("openapi",{type:"string",description:"Filepath or url to an existing OpenAPI spec"}).option("mintlify",{type:"string",description:"Migrate docs from Mintlify provided a path to a mint.json file"}).option("readme",{type:"string",description:"Migrate docs from Readme provided a URL to a Readme generated docs site"}),async r=>{if(r.organization==null){let i=await y38(t);i!=null?r.organization=i:r.organization=await t.getInput({message:"Please enter your organization"})}if(r.api!=null&&r.docs!=null)return t.failWithoutThrowing("Cannot specify both --api and --docs. Please choose one.");if(r.readme!=null&&r.mintlify!=null)return t.failWithoutThrowing("Cannot specify both --readme and --mintlify. Please choose one.");if(r.readme!=null)await t.runTask(async i=>{await snc({readmeUrl:r.readme,organization:r.organization??"fern",taskContext:i,versionOfCli:await qCi({cliEnvironment:t.environment})})});else if(r.docs!=null)await t.runTask(async i=>{await lJs({organization:r.organization,versionOfCli:await qCi({cliEnvironment:t.environment}),taskContext:i})});else if(r.mintlify!=null)await t.runTask(async i=>{await hJs({pathToMintJson:r.mintlify,organization:r.organization??"fern",taskContext:i,versionOfCli:await qCi({cliEnvironment:t.environment})})});else{let i;if(r.openapi!=null){if(g6i(r.openapi)){let a=await Ql_({url:r.openapi,logger:t.logger});a.status==="failure"&&t.failAndThrow(a.errorMessage);let o=a.filePath;i=Rr.of(o)}else i=Rr.of(wu(fA(),r.openapi));await qi(i)||t.failAndThrow(`${i} does not exist`)}await t.runTask(async n=>{await sJs({organization:r.organization,versionOfCli:await qCi({cliEnvironment:t.environment}),context:n,openApiPath:i})})}})}function v38(e,t){e.command("diff","Diff two versions of an API",r=>r.option("from",{string:!0,demandOption:!0,description:"The previous version of the API"}).option("to",{string:!0,demandOption:!0,description:"The next version of the API"}).option("from-version",{string:!0,description:"The previous version of the API (e.g. 1.1.0)"}).option("from-generator-version",{string:!0,description:"The previous version of the generator (e.g. 1.1.0)"}).option("to-generator-version",{string:!0,description:"The next version of the generator (e.g. 1.1.0)"}).option("quiet",{boolean:!0,default:!1,alias:"q",description:"Whether to suppress output written to stderr"}).middleware(i=>{if(!gws(i.fromGeneratorVersion,i.toGeneratorVersion))throw new Error("Both --from-generator-version and --to-generator-version must be provided together, or neither should be provided")}),async r=>{let i=bws(r.fromVersion),n=vws({from:r.fromGeneratorVersion,to:r.toGeneratorVersion}),a=await e1_({context:t,from:r.from,to:r.to,fromVersion:i,generatorVersions:n});if(i!=null){let{errors:c,...f}=a;t.logger.info(JSON.stringify(f))}!r.quiet&&a.errors.length>0&&t.stderr.info(a.errors.join(`
|
|
2074
2074
|
`));let o=a.bump==="major"?1:0;await t.exit({code:o})})}function g38(e,t){e.command("sdk-diff <from-dir> <to-dir>",!1,r=>r.positional("from-dir",{type:"string",demandOption:!0,description:"Path to the directory containing the previous version of the SDK"}).positional("to-dir",{type:"string",demandOption:!0,description:"Path to the directory containing the next version of the SDK"}).option("json",{boolean:!0,default:!1,description:"Output result as JSON"}),async r=>{await t.instrumentPostHogEvent({command:"fern sdk-diff"});let i=await Jg(t,{commandLineApiWorkspace:void 0,defaultToAllApiWorkspaces:!0}),n=await j8j({context:t,project:i,fromDir:r.fromDir,toDir:r.toDir});r.json?t.logger.info(JSON.stringify(n,null,2)):(t.logger.info(`
|
|
2075
2075
|
`+n.message),t.logger.info(`
|
|
2076
|
-
Version Bump: ${n.version_bump}`))})}function O38(e,t){e.command("token","Generate a Fern Token",r=>r.option("organization",{alias:"org",type:"string",description:"The organization to create a token for. Defaults to the one in `fern.config.json`"}),async r=>{await t.runTask(async i=>{await M8j({orgId:r.organization??(await Jg(t,{commandLineApiWorkspace:void 0,defaultToAllApiWorkspaces:!0})).config.organization,taskContext:i})})})}function A38(e,t){e.command("add <generator>",`Add a code generator to ${CS}`,r=>r.positional("generator",{type:"string",demandOption:!0}).option("api",{string:!0,description:"Only run the command on the provided API"}).option("group",{string:!0,description:"Add the generator to the specified group"}),async r=>{await Yq_({project:await Jg(t,{commandLineApiWorkspace:r.api,defaultToAllApiWorkspaces:!1}),generatorName:r.generator,groupName:r.group,cliContext:t})})}function m38(e,t){e.command(["generate"],"Generate all generators in the specified group",r=>r.option("api",{string:!0,description:"If multiple APIs, specify the name with --api <name>. Otherwise, just --api."}).option("docs",{string:!0,description:"If multiple docs sites, specify the name with --docs <name>. Otherwise just --docs."}).option("instance",{string:!0,description:"The url for the instance of docs (e.g. --instance acme.docs.buildwithfern.com)"}).option("preview",{boolean:!0,default:!1,description:"Whether to generate a preview link for the docs"}).option("group",{type:"string",description:"The group to generate"}).option("mode",{choices:Object.values(L3j),description:"Defaults to the mode specified in generators.yml"}).option("version",{type:"string",description:"The version for the generated packages"}).option("printZipUrl",{boolean:!0,hidden:!0,default:!1}).option("local",{boolean:!0,default:!1,description:"Run the generator(s) locally, using Docker"}).option("keepDocker",{boolean:!0,default:!1,description:"Prevent auto-deletion of the Docker containers."}).option("force",{boolean:!0,default:!1,description:"Ignore prompts to confirm generation, defaults to false"}).option("broken-links",{boolean:!0,description:"Log a warning if there are broken links in the docs.",default:!1}).option("strict-broken-links",{boolean:!0,description:"Throw an error (rather than logging a warning) if there are broken links in the docs.",default:!1}).option("disable-snippets",{boolean:!0,description:"Disable snippets in docs generation.",default:!1}).option("runner",{choices:["docker","podman"],description:"Choose the container runtime to use for local generation.",default:void 0}).option("lfs-override",{type:"string",hidden:!0,description:"Override output mode to local-file-system with the specified path"}).option("disable-dynamic-snippets",{boolean:!0,description:"Disable dynamic SDK snippets in docs generation",default:!1}).option("prompt",{boolean:!0,description:"Prompt for confirmation before generating (use --no-prompt to skip)",default:!0}).option("skip-upload",{boolean:!0,description:"Skip asset upload step and generate fake links for preview",default:!1}).option("fernignore",{type:"string",description:"Path to a custom .fernignore file to use instead of the one on the main branch (remote generation only)"}),async r=>r.api!=null&&r.docs!=null?t.failWithoutThrowing("Cannot specify both --api and --docs. Please choose one."):r.skipUpload&&!r.preview?t.failWithoutThrowing("The --skip-upload flag can only be used with --preview."):r.skipUpload&&r.docs==null?t.failWithoutThrowing("The --skip-upload flag can only be used with --docs."):r.fernignore!=null&&(r.local||r.runner!=null)?t.failWithoutThrowing("The --fernignore flag is not supported with local generation (--local or --runner). It can only be used with remote generation."):r.api!=null?await yvd({project:await Jg(t,{commandLineApiWorkspace:r.api,defaultToAllApiWorkspaces:!1}),cliContext:t,version:r.version,groupName:r.group,shouldLogS3Url:r.printZipUrl,keepDocker:r.keepDocker,useLocalDocker:r.local||r.runner!=null,preview:r.preview,mode:r.mode,force:r.force,runner:r.runner,inspect:!1,lfsOverride:r.lfsOverride,fernignorePath:r.fernignore}):r.docs!=null?(r.group!=null&&t.logger.warn("--group is ignored when generating docs"),r.version!=null&&t.logger.warn("--version is ignored when generating docs"),await W3j({project:await Jg(t,{commandLineApiWorkspace:void 0,defaultToAllApiWorkspaces:!0},!0),cliContext:t,instance:r.instance,preview:r.preview,brokenLinks:r.brokenLinks,strictBrokenLinks:r.strictBrokenLinks,disableTemplates:r.disableSnippets,noPrompt:!r.prompt,skipUpload:r.skipUpload})):await yvd({project:await Jg(t,{commandLineApiWorkspace:r.api,defaultToAllApiWorkspaces:!1}),cliContext:t,version:r.version,groupName:r.group,shouldLogS3Url:r.printZipUrl,keepDocker:r.keepDocker,useLocalDocker:r.local,preview:r.preview,mode:r.mode,force:r.force,runner:r.runner,inspect:!1,lfsOverride:r.lfsOverride,fernignorePath:r.fernignore}))}function P38(e,t){e.command("ir <path-to-output>","Generate IR (Intermediate Representation)",r=>r.positional("path-to-output",{type:"string",description:"Path to write intermediate representation (IR)",demandOption:!0}).option("api",{string:!0,description:"Only run the command on the provided API"}).option("version",{string:!0,description:"The version of IR to produce"}).option("language",{choices:Object.values(hn.GenerationLanguage),description:"Generate IR for a particular language"}).option("audience",{type:"array",string:!0,default:[],description:"Filter the IR for certain audiences"}).option("smart-casing",{boolean:!0,description:"Whether to use smart casing"}).option("from-openapi",{boolean:!0,description:"Whether to use the new parser and go directly from OpenAPI to IR",default:!1}).option("disable-examples",{boolean:!0,description:"Whether to disable automatic example generation in the IR",default:!1}),async r=>{await $3j({project:await Jg(t,{commandLineApiWorkspace:r.api,defaultToAllApiWorkspaces:!1,sdkLanguage:r.language}),irFilepath:wu(fA(),r.pathToOutput),cliContext:t,generationLanguage:r.language,audiences:r.audience.length>0?{type:"select",audiences:r.audience}:{type:"all"},version:r.version,keywords:void 0,smartCasing:r.smartCasing??!1,readme:void 0,directFromOpenapi:r.fromOpenapi,disableExamples:r.disableExamples})})}function j38(e,t){e.command("openapi-ir <path-to-output>",!1,r=>r.positional("path-to-output",{type:"string",description:"Path to write intermediate representation (IR)",demandOption:!0}).option("language",{choices:Object.values(hn.GenerationLanguage),description:"Generate IR for a particular language"}).option("api",{string:!0,description:"Only run the command on the provided API"}),async r=>{await Z3j({project:await Jg(t,{commandLineApiWorkspace:r.api,defaultToAllApiWorkspaces:!1,sdkLanguage:r.language}),irFilepath:wu(fA(),r.pathToOutput),cliContext:t,sdkLanguage:r.language})})}function w38(e,t){e.command("dynamic-ir <path-to-output>",!1,r=>r.positional("path-to-output",{type:"string",description:"Path to write intermediate representation (IR)",demandOption:!0}).option("api",{string:!0,description:"Only run the command on the provided API"}).option("version",{string:!0,description:"The version of IR to produce"}).option("language",{choices:Object.values(hn.GenerationLanguage),description:"Generate IR for a particular language"}).option("audience",{type:"array",string:!0,default:[],description:"Filter the IR for certain audiences"}).option("smart-casing",{boolean:!0,description:"Whether to use smart casing"}).option("disable-examples",{boolean:!0,description:"Whether to suppress examples from being included in the IR"}),async r=>{await G3j({project:await Jg(t,{commandLineApiWorkspace:r.api,defaultToAllApiWorkspaces:!1,sdkLanguage:r.language}),irFilepath:wu(fA(),r.pathToOutput),cliContext:t,generationLanguage:r.language,audiences:{type:"all"},version:r.version,keywords:void 0,smartCasing:r.smartCasing??!1,disableDynamicExamples:r.disableExamples??!1})})}function E38(e,t){e.command("fdr <path-to-output>",!1,r=>r.positional("path-to-output",{type:"string",description:"Path to write FDR API definition",demandOption:!0}).option("api",{string:!0,description:"Only run the command on the provided API"}).option("audience",{type:"array",string:!0,default:[],description:"Filter the FDR API definition for certain audiences"}).option("v2",{boolean:!0,description:"Use v2 format"}).option("from-openapi",{boolean:!0,description:"Whether to use the new parser and go directly from OpenAPI to IR",default:!1}),async r=>{r.v2?await bvd({project:await Jg(t,{commandLineApiWorkspace:r.api,defaultToAllApiWorkspaces:!1}),outputFilepath:wu(fA(),r.pathToOutput),directFromOpenapi:!1,cliContext:t,audiences:r.audience.length>0?{type:"select",audiences:r.audience}:{type:"all"}}):r.fromOpenapi?await bvd({project:await Jg(t,{commandLineApiWorkspace:r.api,defaultToAllApiWorkspaces:!1}),outputFilepath:wu(fA(),r.pathToOutput),directFromOpenapi:!0,cliContext:t,audiences:r.audience.length>0?{type:"select",audiences:r.audience}:{type:"all"}}):await K3j({project:await Jg(t,{commandLineApiWorkspace:r.api,defaultToAllApiWorkspaces:!1}),outputFilepath:wu(fA(),r.pathToOutput),cliContext:t,audiences:r.audience.length>0?{type:"select",audiences:r.audience}:{type:"all"}})})}function S38(e,t){e.command(["register"],!1,r=>r.option("version",{type:"string",description:"The version for the registered api"}).option("api",{string:!0,description:"Only run the command on the provided API"}),async r=>{let i=await Jg(t,{commandLineApiWorkspace:r.api,defaultToAllApiWorkspaces:!1}),n=await t.runTask(a=>Lme(a));await O8j({project:i,cliContext:t,token:n,version:r.version})})}function M38(e,t){e.command(["register-v2"],!1,r=>r.option("api",{string:!0,description:"Only run the command on the provided API"}),async r=>{let i=await Jg(t,{commandLineApiWorkspace:r.api,defaultToAllApiWorkspaces:!1}),n=await t.runTask(a=>Lme(a));await A8j({project:i,cliContext:t,token:n})})}function D38(e,t){e.command("check","Validates your Fern Definition. Logs errors.",r=>r.option("api",{string:!0,description:"Only run the command on the provided API"}).option("warnings",{boolean:!0,description:"Log warnings in addition to errors.",default:!1}).option("broken-links",{boolean:!0,description:"Log a warning if there are broken links in the docs.",default:!1}).option("strict-broken-links",{boolean:!0,description:"Throw an error (rather than logging a warning) if there are broken links in the docs.",default:!1}).option("local",{boolean:!0,description:"Run validation locally without sending data to Fern API.",default:!1}).option("from-openapi",{boolean:!0,description:"Whether to use the new parser and go directly from OpenAPI to IR",default:!1}),async r=>{await j9j({project:await Jg(t,{commandLineApiWorkspace:r.api,defaultToAllApiWorkspaces:!0}),cliContext:t,logWarnings:r.warnings,brokenLinks:r.brokenLinks,errorOnBrokenLinks:r.strictBrokenLinks,directFromOpenapi:r.fromOpenapi})})}function B38({cli:e,cliContext:t,onRun:r}){e.command("upgrade",`Upgrades Fern CLI version in ${$F}`,i=>i.option("rc",{boolean:!0,hidden:!0,default:!1}).option("version",{string:!0,description:"The version to upgrade to. Defaults to the latest release."}).option("to",{string:!0,hidden:!0}).option("from",{string:!0,description:"The version to migrate from. Use this to manually run migrations when upgrading from an older CLI version."}).option("from-git",{boolean:!0,hidden:!0}).option("yes",{alias:"y",boolean:!0,default:!1,description:"Automatically answer yes to migration prompts."}),async i=>{await m9j({cliContext:t,includePreReleases:i.rc,targetVersion:i.to??i.version,fromVersion:i.from,fromGit:i["from-git"],yes:i.yes}),r()})}function I38(e,t){e.command("downgrade <version>",`Downgrades Fern CLI version in ${$F}`,r=>r.positional("version",{type:"string",description:"The version to downgrade to",demandOption:!0}),async r=>{await oK_({cliContext:t,targetVersion:r.version})})}function C38(e,t){e.command("api update",`Pulls the latest OpenAPI spec from the specified origin in ${CS} and updates the local spec.`,r=>r.option("api",{string:!0,description:"The API to update the spec for. If not specified, all APIs with a declared origin will be updated."}),async r=>{await t.instrumentPostHogEvent({command:"fern api update"}),await C8j({cliContext:t,project:await Jg(t,{commandLineApiWorkspace:r.api,defaultToAllApiWorkspaces:!0})})})}function q38(e,t){e.command("self-update [version]","Updates the globally installed Fern CLI to the latest version or the specified version",r=>r.positional("version",{type:"string",description:"The version to update to (e.g., 0.85.0, 10). Defaults to latest."}).option("dry-run",{type:"boolean",description:"Show what would be executed without actually running the update",default:!1}),async r=>{await t.instrumentPostHogEvent({command:"fern self-update"}),await E8j({cliContext:t,version:r.version,dryRun:r.dryRun})})}function T38(e,t){e.command("login","Log in to Fern via GitHub",r=>r.option("device-code",{boolean:!0,default:!1,description:"Use device code authorization"}),async r=>{await t.runTask(async i=>{await t.instrumentPostHogEvent({command:"fern login"}),await jOa(i,{useDeviceCodeFlow:r.deviceCode})})})}function R38(e,t){e.command("logout","Log out of Fern",r=>r,async()=>{await t.runTask(async r=>{await t.instrumentPostHogEvent({command:"fern logout"}),await mHs(r)})})}function z38(e,t){e.command("format","Formats your Fern Definition",r=>r.option("ci",{boolean:!0,default:!1,description:"Fail with non-zero exit status if files are not formatted correctly."}).option("api",{string:!0,description:"Only run the command on the provided API"}),async r=>{await t.instrumentPostHogEvent({command:"fern format"}),await hK_({project:await Jg(t,{commandLineApiWorkspace:r.api,defaultToAllApiWorkspaces:!0}),cliContext:t,shouldFix:!r.ci})})}function N38(e,t){e.command("test","Runs tests specified in --command, this spins up a mock server in the background that is terminated upon completion of the tests.",r=>r.option("api",{string:!0,description:"The API to mock."}).option("command",{string:!0,description:"The command to run to test your SDK."}).option("language",{choices:Object.values(hn.GenerationLanguage),description:"Run the tests configured to a specific language"}),async r=>{await t.instrumentPostHogEvent({command:"fern test"}),await S8j({cliContext:t,project:await Jg(t,{commandLineApiWorkspace:r.api,defaultToAllApiWorkspaces:!1,nameOverride:".mock",sdkLanguage:r.language}),testCommand:r.command,generationLanguage:r.language})})}function F38(e,t){e.command("mock","Starts a mock server for an API.",r=>r.option("port",{number:!0,description:"The port the server binds to."}).option("api",{string:!0,description:"The API to mock."}),async r=>{await t.instrumentPostHogEvent({command:"fern mock"}),await _8j({cliContext:t,project:await Jg(t,{commandLineApiWorkspace:r.api,defaultToAllApiWorkspaces:!1}),port:r.port})})}function Q38(e,t){e.command("overrides","Commands for managing OpenAPI overrides",r=>(U38(r,t),L38(r,t),r))}function U38(e,t){e.command("compare <original> <modified>","Compare two OpenAPI specs and generate an overrides file from the differences.",r=>r.positional("original",{type:"string",description:"Path to the original OpenAPI spec",demandOption:!0}).positional("modified",{type:"string",description:"Path to the modified OpenAPI spec",demandOption:!0}).option("output",{type:"string",alias:"o",description:"Path to write the overrides file (defaults to <original>-overrides.yml)"}),async r=>{await t.instrumentPostHogEvent({command:"fern overrides compare"});let i=wu(fA(),r.original),n=wu(fA(),r.modified),a=r.output!=null?wu(fA(),r.output):void 0;await e8j({originalPath:Rr.of(i),modifiedPath:Rr.of(n),outputPath:a!=null?Rr.of(a):void 0,cliContext:t})})}function L38(e,t){e.command("write","Generate a basic openapi overrides file.",r=>[r.option("api",{string:!0,description:"Only run the command on the provided API"}),r.option("exclude-models",{boolean:!0,description:"When generating the initial overrides, also stub the models (in addition to the endpoints)",default:!1})],async r=>{await t.instrumentPostHogEvent({command:"fern overrides write"}),await gvd({project:await Jg(t,{commandLineApiWorkspace:r.api,defaultToAllApiWorkspaces:!0}),includeModels:!r.excludeModels,cliContext:t})})}function V38(e,t){e.command("write-overrides",!1,r=>[r.option("api",{string:!0,description:"Only run the command on the provided API"}),r.option("exclude-models",{boolean:!0,description:"When generating the initial overrides, also stub the models (in addition to the endpoints)",default:!1})],async r=>{t.logger.warn("The 'write-overrides' command is deprecated. Use 'fern overrides write' instead."),await t.instrumentPostHogEvent({command:"fern write-overrides"}),await gvd({project:await Jg(t,{commandLineApiWorkspace:r.api,defaultToAllApiWorkspaces:!0}),includeModels:!r.excludeModels,cliContext:t})})}function W38(e,t){e.command("write-definition","Write underlying Fern Definition for OpenAPI specs and API Dependencies.",r=>r.option("api",{string:!0,description:"Only run the command on the provided API"}).option("language",{choices:Object.values(hn.GenerationLanguage),description:"Write the definition for a particular SDK language"}).option("preserve-schemas",{string:!0,description:"Preserve potentially unsafe schema Ids in the generated fern definition"}),async r=>{let i=r.preserveSchemas!=null;await t.instrumentPostHogEvent({command:"fern write-definition"}),await w9j({project:await Jg(t,{commandLineApiWorkspace:r.api,defaultToAllApiWorkspaces:!0,sdkLanguage:r.language,preserveSchemaIds:i}),cliContext:t,sdkLanguage:r.language,preserveSchemaIds:i})})}function x38(e,t){e.command("docs","Commands for managing your docs",r=>(G38(r,t),H38(r,t),r))}function G38(e,t){e.command("dev","Run a local development server to preview your docs",r=>r.option("port",{number:!0,description:"Run the development server on the following port"}).option("bundle-path",{string:!0,hidden:!0,description:"Path of the local docs bundle to use"}).option("broken-links",{boolean:!0,default:!1,description:"Check for broken links in your docs"}).option("beta",{boolean:!0,default:!1,description:"Run the app router development server"}).option("legacy",{boolean:!0,default:!1,description:"Run the legacy development server"}).option("backend-port",{number:!0,description:"Run the development backend server on the following port"}),async r=>{r.beta&&t.logger.warn("--beta flag now accesses the same functionality as default and will be deprecated in a future release");let i;r.port!=null?i=r.port:i=await fQn({port:[3e3,3001,3002,3003,3004,3005,3006,3007,3008,3009,3010]});let n;r.backendPort!=null?n=r.backendPort:n=await fQn({port:[3001,3002,3003,3004,3005,3006,3007,3008,3009,3010,3011]});let a=r.bundlePath;await KH_({loadProject:()=>Jg(t,{defaultToAllApiWorkspaces:!0,commandLineApiWorkspace:void 0}),cliContext:t,port:i,bundlePath:a,brokenLinks:r.brokenLinks,legacyPreview:r.legacy,backendPort:n})})}function H38(e,t){e.command("broken-links","Check for broken links in your docs",r=>r.option("strict",{boolean:!0,default:!1,description:"Fail with non-zero exit status"}),async r=>{let i=await Jg(t,{commandLineApiWorkspace:void 0,defaultToAllApiWorkspaces:!0});await P9j({project:i,cliContext:t,errorOnBrokenLinks:r.strict})})}function K38(e,t){e.command("jsonschema <path-to-output>","Generate JSON Schema for a specific type",r=>r.option("api",{string:!0,description:"Only run the command on the provided API"}).positional("path-to-output",{type:"string",description:"Path to write JSON Schema",demandOption:!0}).option("type",{string:!0,demandOption:!0,description:"The type to generate JSON Schema for (e.g. 'MySchema' or 'mypackage.MySchema')"}),async r=>{await t.instrumentPostHogEvent({command:"fern jsonschema",properties:{output:r.output}}),await s8j({typeLocator:r.type,project:await Jg(t,{commandLineApiWorkspace:r.api,defaultToAllApiWorkspaces:!1}),jsonschemaFilepath:wu(fA(),r.pathToOutput),cliContext:t})})}function J38(e,t){e.command("write-docs-definition <output-path>",!1,r=>r.positional("output-path",{type:"string",description:"Path to write the docs definition",demandOption:!0}),async r=>{await t.instrumentPostHogEvent({command:"fern write-docs-definition",properties:{outputPath:r.outputPath}}),await M9j({project:await Jg(t,{defaultToAllApiWorkspaces:!0,commandLineApiWorkspace:void 0}),outputPath:wu(fA(),r.outputPath),cliContext:t})})}function $38(e,t){e.command("write-translation","Generate translation directories for each language defined in docs.yml",r=>r.option("stub",{alias:"s",type:"boolean",default:!1,description:"Return content as-is without calling the translation service"}),async r=>{await t.instrumentPostHogEvent({command:"fern write-translation"}),await K9j({project:await Jg(t,{defaultToAllApiWorkspaces:!0,commandLineApiWorkspace:void 0}),cliContext:t,stub:r.stub})})}function Y38(e,t){e.command("export <output-path>","Export your API to an OpenAPI spec",r=>r.positional("output-path",{type:"string",description:"Path to write the OpenAPI spec",demandOption:!0}).option("api",{string:!0,description:"Only run the command on the provided API"}),async r=>{await t.instrumentPostHogEvent({command:"fern export",properties:{outputPath:r.outputPath}}),await _K_({project:await Jg(t,{commandLineApiWorkspace:r.api,defaultToAllApiWorkspaces:!1}),cliContext:t,outputPath:wu(fA(),r.outputPath)})})}function X38(e,t){e.command("protoc-gen-fern",!1,r=>{},async()=>{let r=roc,i=await Z38(process.stdin),n=Gfa(wPd,i),a=r.run(n);await k38(process.stdout,Wjs(Yto,a)),process.exit(0)})}function Z38(e){return new Promise((t,r)=>{let i=[];e.on("data",n=>i.push(n)),e.on("end",()=>{t(new Uint8Array(Buffer.concat(i)))}),e.on("error",n=>{r(n)})})}function k38(e,t){return new Promise((r,i)=>{e.write(t,n=>{n?i(n):r()})})}
|
|
2076
|
+
Version Bump: ${n.version_bump}`))})}function O38(e,t){e.command("token","Generate a Fern Token",r=>r.option("organization",{alias:"org",type:"string",description:"The organization to create a token for. Defaults to the one in `fern.config.json`"}),async r=>{await t.runTask(async i=>{await M8j({orgId:r.organization??(await Jg(t,{commandLineApiWorkspace:void 0,defaultToAllApiWorkspaces:!0})).config.organization,taskContext:i})})})}function A38(e,t){e.command("add <generator>",`Add a code generator to ${CS}`,r=>r.positional("generator",{type:"string",demandOption:!0}).option("api",{string:!0,description:"Only run the command on the provided API"}).option("group",{string:!0,description:"Add the generator to the specified group"}),async r=>{await Yq_({project:await Jg(t,{commandLineApiWorkspace:r.api,defaultToAllApiWorkspaces:!1}),generatorName:r.generator,groupName:r.group,cliContext:t})})}function m38(e,t){e.command(["generate"],"Generate all generators in the specified group",r=>r.option("api",{string:!0,description:"If multiple APIs, specify the name with --api <name>. Otherwise, just --api."}).option("docs",{string:!0,description:"If multiple docs sites, specify the name with --docs <name>. Otherwise just --docs."}).option("instance",{string:!0,description:"The url for the instance of docs (e.g. --instance acme.docs.buildwithfern.com)"}).option("preview",{boolean:!0,default:!1,description:"Whether to generate a preview link for the docs"}).option("group",{type:"string",description:"The group to generate"}).option("mode",{choices:Object.values(L3j),description:"Defaults to the mode specified in generators.yml"}).option("version",{type:"string",description:"The version for the generated packages"}).option("printZipUrl",{boolean:!0,hidden:!0,default:!1}).option("local",{boolean:!0,default:!1,description:"Run the generator(s) locally, using Docker"}).option("keepDocker",{boolean:!0,default:!1,description:"Prevent auto-deletion of the Docker containers."}).option("force",{boolean:!0,default:!1,description:"Ignore prompts to confirm generation, defaults to false"}).option("broken-links",{boolean:!0,description:"Log a warning if there are broken links in the docs.",default:!1}).option("strict-broken-links",{boolean:!0,description:"Throw an error (rather than logging a warning) if there are broken links in the docs.",default:!1}).option("disable-snippets",{boolean:!0,description:"Disable snippets in docs generation.",default:!1}).option("runner",{choices:["docker","podman"],description:"Choose the container runtime to use for local generation.",default:void 0}).option("lfs-override",{type:"string",hidden:!0,description:"Override output mode to local-file-system with the specified path"}).option("disable-dynamic-snippets",{boolean:!0,description:"Disable dynamic SDK snippets in docs generation",default:!1}).option("prompt",{boolean:!0,description:"Prompt for confirmation before generating (use --no-prompt to skip)",default:!0}).option("skip-upload",{boolean:!0,description:"Skip asset upload step and generate fake links for preview",default:!1}).option("fernignore",{type:"string",description:"Path to a custom .fernignore file to use instead of the one on the main branch (remote generation only)"}),async r=>r.api!=null&&r.docs!=null?t.failWithoutThrowing("Cannot specify both --api and --docs. Please choose one."):r.skipUpload&&!r.preview?t.failWithoutThrowing("The --skip-upload flag can only be used with --preview."):r.skipUpload&&r.docs==null?t.failWithoutThrowing("The --skip-upload flag can only be used with --docs."):r.fernignore!=null&&(r.local||r.runner!=null)?t.failWithoutThrowing("The --fernignore flag is not supported with local generation (--local or --runner). It can only be used with remote generation."):r.api!=null?await yvd({project:await Jg(t,{commandLineApiWorkspace:r.api,defaultToAllApiWorkspaces:!1}),cliContext:t,version:r.version,groupName:r.group,shouldLogS3Url:r.printZipUrl,keepDocker:r.keepDocker,useLocalDocker:r.local||r.runner!=null,preview:r.preview,mode:r.mode,force:r.force,runner:r.runner,inspect:!1,lfsOverride:r.lfsOverride,fernignorePath:r.fernignore}):r.docs!=null?(r.group!=null&&t.logger.warn("--group is ignored when generating docs"),r.version!=null&&t.logger.warn("--version is ignored when generating docs"),await W3j({project:await Jg(t,{commandLineApiWorkspace:void 0,defaultToAllApiWorkspaces:!0},!0),cliContext:t,instance:r.instance,preview:r.preview,brokenLinks:r.brokenLinks,strictBrokenLinks:r.strictBrokenLinks,disableTemplates:r.disableSnippets,noPrompt:!r.prompt,skipUpload:r.skipUpload})):await yvd({project:await Jg(t,{commandLineApiWorkspace:r.api,defaultToAllApiWorkspaces:!1}),cliContext:t,version:r.version,groupName:r.group,shouldLogS3Url:r.printZipUrl,keepDocker:r.keepDocker,useLocalDocker:r.local,preview:r.preview,mode:r.mode,force:r.force,runner:r.runner,inspect:!1,lfsOverride:r.lfsOverride,fernignorePath:r.fernignore}))}function P38(e,t){e.command("ir <path-to-output>","Generate IR (Intermediate Representation)",r=>r.positional("path-to-output",{type:"string",description:"Path to write intermediate representation (IR)",demandOption:!0}).option("api",{string:!0,description:"Only run the command on the provided API"}).option("version",{string:!0,description:"The version of IR to produce"}).option("language",{choices:Object.values(hn.GenerationLanguage),description:"Generate IR for a particular language"}).option("audience",{type:"array",string:!0,default:[],description:"Filter the IR for certain audiences"}).option("smart-casing",{boolean:!0,description:"Whether to use smart casing"}).option("from-openapi",{boolean:!0,description:"Whether to use the new parser and go directly from OpenAPI to IR",default:!1}).option("disable-examples",{boolean:!0,description:"Whether to disable automatic example generation in the IR",default:!1}),async r=>{await $3j({project:await Jg(t,{commandLineApiWorkspace:r.api,defaultToAllApiWorkspaces:!1,sdkLanguage:r.language}),irFilepath:wu(fA(),r.pathToOutput),cliContext:t,generationLanguage:r.language,audiences:r.audience.length>0?{type:"select",audiences:r.audience}:{type:"all"},version:r.version,keywords:void 0,smartCasing:r.smartCasing??!1,readme:void 0,directFromOpenapi:r.fromOpenapi,disableExamples:r.disableExamples})})}function j38(e,t){e.command("openapi-ir <path-to-output>",!1,r=>r.positional("path-to-output",{type:"string",description:"Path to write intermediate representation (IR)",demandOption:!0}).option("language",{choices:Object.values(hn.GenerationLanguage),description:"Generate IR for a particular language"}).option("api",{string:!0,description:"Only run the command on the provided API"}),async r=>{await Z3j({project:await Jg(t,{commandLineApiWorkspace:r.api,defaultToAllApiWorkspaces:!1,sdkLanguage:r.language}),irFilepath:wu(fA(),r.pathToOutput),cliContext:t,sdkLanguage:r.language})})}function w38(e,t){e.command("dynamic-ir <path-to-output>",!1,r=>r.positional("path-to-output",{type:"string",description:"Path to write intermediate representation (IR)",demandOption:!0}).option("api",{string:!0,description:"Only run the command on the provided API"}).option("version",{string:!0,description:"The version of IR to produce"}).option("language",{choices:Object.values(hn.GenerationLanguage),description:"Generate IR for a particular language"}).option("audience",{type:"array",string:!0,default:[],description:"Filter the IR for certain audiences"}).option("smart-casing",{boolean:!0,description:"Whether to use smart casing"}).option("disable-examples",{boolean:!0,description:"Whether to suppress examples from being included in the IR"}),async r=>{await G3j({project:await Jg(t,{commandLineApiWorkspace:r.api,defaultToAllApiWorkspaces:!1,sdkLanguage:r.language}),irFilepath:wu(fA(),r.pathToOutput),cliContext:t,generationLanguage:r.language,audiences:{type:"all"},version:r.version,keywords:void 0,smartCasing:r.smartCasing??!1,disableDynamicExamples:r.disableExamples??!1})})}function E38(e,t){e.command("fdr <path-to-output>",!1,r=>r.positional("path-to-output",{type:"string",description:"Path to write FDR API definition",demandOption:!0}).option("api",{string:!0,description:"Only run the command on the provided API"}).option("audience",{type:"array",string:!0,default:[],description:"Filter the FDR API definition for certain audiences"}).option("v2",{boolean:!0,description:"Use v2 format"}).option("from-openapi",{boolean:!0,description:"Whether to use the new parser and go directly from OpenAPI to IR",default:!1}),async r=>{r.v2?await bvd({project:await Jg(t,{commandLineApiWorkspace:r.api,defaultToAllApiWorkspaces:!1}),outputFilepath:wu(fA(),r.pathToOutput),directFromOpenapi:!1,cliContext:t,audiences:r.audience.length>0?{type:"select",audiences:r.audience}:{type:"all"}}):r.fromOpenapi?await bvd({project:await Jg(t,{commandLineApiWorkspace:r.api,defaultToAllApiWorkspaces:!1}),outputFilepath:wu(fA(),r.pathToOutput),directFromOpenapi:!0,cliContext:t,audiences:r.audience.length>0?{type:"select",audiences:r.audience}:{type:"all"}}):await K3j({project:await Jg(t,{commandLineApiWorkspace:r.api,defaultToAllApiWorkspaces:!1}),outputFilepath:wu(fA(),r.pathToOutput),cliContext:t,audiences:r.audience.length>0?{type:"select",audiences:r.audience}:{type:"all"}})})}function S38(e,t){e.command(["register"],!1,r=>r.option("version",{type:"string",description:"The version for the registered api"}).option("api",{string:!0,description:"Only run the command on the provided API"}),async r=>{let i=await Jg(t,{commandLineApiWorkspace:r.api,defaultToAllApiWorkspaces:!1}),n=await t.runTask(a=>Lme(a));await O8j({project:i,cliContext:t,token:n,version:r.version})})}function M38(e,t){e.command(["register-v2"],!1,r=>r.option("api",{string:!0,description:"Only run the command on the provided API"}),async r=>{let i=await Jg(t,{commandLineApiWorkspace:r.api,defaultToAllApiWorkspaces:!1}),n=await t.runTask(a=>Lme(a));await A8j({project:i,cliContext:t,token:n})})}function D38(e,t){e.command("check","Validates your Fern Definition. Logs errors.",r=>r.option("api",{string:!0,description:"Only run the command on the provided API"}).option("warnings",{boolean:!0,description:"Log warnings in addition to errors.",default:!1}).option("broken-links",{boolean:!0,description:"Log a warning if there are broken links in the docs.",default:!1}).option("strict-broken-links",{boolean:!0,description:"Throw an error (rather than logging a warning) if there are broken links in the docs.",default:!1}).option("local",{boolean:!0,description:"Run validation locally without sending data to Fern API.",default:!1}).option("from-openapi",{boolean:!0,description:"Whether to use the new parser and go directly from OpenAPI to IR",default:!1}),async r=>{await j9j({project:await Jg(t,{commandLineApiWorkspace:r.api,defaultToAllApiWorkspaces:!0}),cliContext:t,logWarnings:r.warnings,brokenLinks:r.brokenLinks,errorOnBrokenLinks:r.strictBrokenLinks,directFromOpenapi:r.fromOpenapi})})}function B38({cli:e,cliContext:t,onRun:r}){e.command("upgrade",`Upgrades Fern CLI version in ${$F}`,i=>i.option("rc",{boolean:!0,hidden:!0,default:!1}).option("version",{string:!0,description:"The version to upgrade to. Defaults to the latest release."}).option("to",{string:!0,hidden:!0}).option("from",{string:!0,description:"The version to migrate from. Use this to manually run migrations when upgrading from an older CLI version."}).option("from-git",{boolean:!0,hidden:!0}).option("yes",{alias:"y",boolean:!0,default:!1,description:"Automatically answer yes to migration prompts."}),async i=>{await m9j({cliContext:t,includePreReleases:i.rc,targetVersion:i.to??i.version,fromVersion:i.from,fromGit:i["from-git"],yes:i.yes}),r()})}function I38(e,t){e.command("downgrade <version>",`Downgrades Fern CLI version in ${$F}`,r=>r.positional("version",{type:"string",description:"The version to downgrade to",demandOption:!0}),async r=>{await oK_({cliContext:t,targetVersion:r.version})})}function C38(e,t){e.command("api update",`Pulls the latest OpenAPI spec from the specified origin in ${CS} and updates the local spec.`,r=>r.option("api",{string:!0,description:"The API to update the spec for. If not specified, all APIs with a declared origin will be updated."}),async r=>{await t.instrumentPostHogEvent({command:"fern api update"}),await C8j({cliContext:t,project:await Jg(t,{commandLineApiWorkspace:r.api,defaultToAllApiWorkspaces:!0})})})}function q38(e,t){e.command("self-update [version]","Updates the globally installed Fern CLI to the latest version or the specified version",r=>r.positional("version",{type:"string",description:"The version to update to (e.g., 0.85.0, 10). Defaults to latest."}).option("dry-run",{type:"boolean",description:"Show what would be executed without actually running the update",default:!1}),async r=>{await t.instrumentPostHogEvent({command:"fern self-update"}),await E8j({cliContext:t,version:r.version,dryRun:r.dryRun})})}function T38(e,t){e.command("login","Log in to Fern via GitHub",r=>r.option("device-code",{boolean:!0,default:!1,description:"Use device code authorization"}),async r=>{await t.runTask(async i=>{await t.instrumentPostHogEvent({command:"fern login"}),await jOa(i,{useDeviceCodeFlow:r.deviceCode})})})}function R38(e,t){e.command("logout","Log out of Fern",r=>r,async()=>{await t.runTask(async r=>{await t.instrumentPostHogEvent({command:"fern logout"}),await mHs(r)})})}function z38(e,t){e.command("format","Formats your Fern Definition",r=>r.option("ci",{boolean:!0,default:!1,description:"Fail with non-zero exit status if files are not formatted correctly."}).option("api",{string:!0,description:"Only run the command on the provided API"}),async r=>{await t.instrumentPostHogEvent({command:"fern format"}),await hK_({project:await Jg(t,{commandLineApiWorkspace:r.api,defaultToAllApiWorkspaces:!0}),cliContext:t,shouldFix:!r.ci})})}function N38(e,t){e.command("test",!1,r=>r.option("api",{string:!0,description:"The API to mock."}).option("command",{string:!0,description:"The command to run to test your SDK."}).option("language",{choices:Object.values(hn.GenerationLanguage),description:"Run the tests configured to a specific language"}),async r=>{await t.instrumentPostHogEvent({command:"fern test"}),await S8j({cliContext:t,project:await Jg(t,{commandLineApiWorkspace:r.api,defaultToAllApiWorkspaces:!1,nameOverride:".mock",sdkLanguage:r.language}),testCommand:r.command,generationLanguage:r.language})})}function F38(e,t){e.command("mock",!1,r=>r.option("port",{number:!0,description:"The port the server binds to."}).option("api",{string:!0,description:"The API to mock."}),async r=>{await t.instrumentPostHogEvent({command:"fern mock"}),await _8j({cliContext:t,project:await Jg(t,{commandLineApiWorkspace:r.api,defaultToAllApiWorkspaces:!1}),port:r.port})})}function Q38(e,t){e.command("overrides","Commands for managing OpenAPI overrides",r=>(U38(r,t),L38(r,t),r))}function U38(e,t){e.command("compare <original> <modified>","Compare two OpenAPI specs and generate an overrides file from the differences.",r=>r.positional("original",{type:"string",description:"Path to the original OpenAPI spec",demandOption:!0}).positional("modified",{type:"string",description:"Path to the modified OpenAPI spec",demandOption:!0}).option("output",{type:"string",alias:"o",description:"Path to write the overrides file (defaults to <original>-overrides.yml)"}),async r=>{await t.instrumentPostHogEvent({command:"fern overrides compare"});let i=wu(fA(),r.original),n=wu(fA(),r.modified),a=r.output!=null?wu(fA(),r.output):void 0;await e8j({originalPath:Rr.of(i),modifiedPath:Rr.of(n),outputPath:a!=null?Rr.of(a):void 0,cliContext:t})})}function L38(e,t){e.command("write","Generate a basic openapi overrides file.",r=>[r.option("api",{string:!0,description:"Only run the command on the provided API"}),r.option("exclude-models",{boolean:!0,description:"When generating the initial overrides, also stub the models (in addition to the endpoints)",default:!1})],async r=>{await t.instrumentPostHogEvent({command:"fern overrides write"}),await gvd({project:await Jg(t,{commandLineApiWorkspace:r.api,defaultToAllApiWorkspaces:!0}),includeModels:!r.excludeModels,cliContext:t})})}function V38(e,t){e.command("write-overrides",!1,r=>[r.option("api",{string:!0,description:"Only run the command on the provided API"}),r.option("exclude-models",{boolean:!0,description:"When generating the initial overrides, also stub the models (in addition to the endpoints)",default:!1})],async r=>{t.logger.warn("The 'write-overrides' command is deprecated. Use 'fern overrides write' instead."),await t.instrumentPostHogEvent({command:"fern write-overrides"}),await gvd({project:await Jg(t,{commandLineApiWorkspace:r.api,defaultToAllApiWorkspaces:!0}),includeModels:!r.excludeModels,cliContext:t})})}function W38(e,t){e.command("write-definition","Write underlying Fern Definition for OpenAPI specs and API Dependencies.",r=>r.option("api",{string:!0,description:"Only run the command on the provided API"}).option("language",{choices:Object.values(hn.GenerationLanguage),description:"Write the definition for a particular SDK language"}).option("preserve-schemas",{string:!0,description:"Preserve potentially unsafe schema Ids in the generated fern definition"}),async r=>{let i=r.preserveSchemas!=null;await t.instrumentPostHogEvent({command:"fern write-definition"}),await w9j({project:await Jg(t,{commandLineApiWorkspace:r.api,defaultToAllApiWorkspaces:!0,sdkLanguage:r.language,preserveSchemaIds:i}),cliContext:t,sdkLanguage:r.language,preserveSchemaIds:i})})}function x38(e,t){e.command("docs","Commands for managing your docs",r=>(G38(r,t),H38(r,t),r))}function G38(e,t){e.command("dev","Run a local development server to preview your docs",r=>r.option("port",{number:!0,description:"Run the development server on the following port"}).option("bundle-path",{string:!0,hidden:!0,description:"Path of the local docs bundle to use"}).option("broken-links",{boolean:!0,default:!1,description:"Check for broken links in your docs"}).option("beta",{boolean:!0,default:!1,description:"Run the app router development server"}).option("legacy",{boolean:!0,default:!1,description:"Run the legacy development server"}).option("backend-port",{number:!0,description:"Run the development backend server on the following port"}),async r=>{r.beta&&t.logger.warn("--beta flag now accesses the same functionality as default and will be deprecated in a future release");let i;r.port!=null?i=r.port:i=await fQn({port:[3e3,3001,3002,3003,3004,3005,3006,3007,3008,3009,3010]});let n;r.backendPort!=null?n=r.backendPort:n=await fQn({port:[3001,3002,3003,3004,3005,3006,3007,3008,3009,3010,3011]});let a=r.bundlePath;await KH_({loadProject:()=>Jg(t,{defaultToAllApiWorkspaces:!0,commandLineApiWorkspace:void 0}),cliContext:t,port:i,bundlePath:a,brokenLinks:r.brokenLinks,legacyPreview:r.legacy,backendPort:n})})}function H38(e,t){e.command("broken-links","Check for broken links in your docs",r=>r.option("strict",{boolean:!0,default:!1,description:"Fail with non-zero exit status"}),async r=>{let i=await Jg(t,{commandLineApiWorkspace:void 0,defaultToAllApiWorkspaces:!0});await P9j({project:i,cliContext:t,errorOnBrokenLinks:r.strict})})}function K38(e,t){e.command("jsonschema <path-to-output>","Generate JSON Schema for a specific type",r=>r.option("api",{string:!0,description:"Only run the command on the provided API"}).positional("path-to-output",{type:"string",description:"Path to write JSON Schema",demandOption:!0}).option("type",{string:!0,demandOption:!0,description:"The type to generate JSON Schema for (e.g. 'MySchema' or 'mypackage.MySchema')"}),async r=>{await t.instrumentPostHogEvent({command:"fern jsonschema",properties:{output:r.output}}),await s8j({typeLocator:r.type,project:await Jg(t,{commandLineApiWorkspace:r.api,defaultToAllApiWorkspaces:!1}),jsonschemaFilepath:wu(fA(),r.pathToOutput),cliContext:t})})}function J38(e,t){e.command("write-docs-definition <output-path>",!1,r=>r.positional("output-path",{type:"string",description:"Path to write the docs definition",demandOption:!0}),async r=>{await t.instrumentPostHogEvent({command:"fern write-docs-definition",properties:{outputPath:r.outputPath}}),await M9j({project:await Jg(t,{defaultToAllApiWorkspaces:!0,commandLineApiWorkspace:void 0}),outputPath:wu(fA(),r.outputPath),cliContext:t})})}function $38(e,t){e.command("write-translation","Generate translation directories for each language defined in docs.yml",r=>r.option("stub",{alias:"s",type:"boolean",default:!1,description:"Return content as-is without calling the translation service"}),async r=>{await t.instrumentPostHogEvent({command:"fern write-translation"}),await K9j({project:await Jg(t,{defaultToAllApiWorkspaces:!0,commandLineApiWorkspace:void 0}),cliContext:t,stub:r.stub})})}function Y38(e,t){e.command("export <output-path>","Export your API to an OpenAPI spec",r=>r.positional("output-path",{type:"string",description:"Path to write the OpenAPI spec",demandOption:!0}).option("api",{string:!0,description:"Only run the command on the provided API"}),async r=>{await t.instrumentPostHogEvent({command:"fern export",properties:{outputPath:r.outputPath}}),await _K_({project:await Jg(t,{commandLineApiWorkspace:r.api,defaultToAllApiWorkspaces:!1}),cliContext:t,outputPath:wu(fA(),r.outputPath)})})}function X38(e,t){e.command("protoc-gen-fern",!1,r=>{},async()=>{let r=roc,i=await Z38(process.stdin),n=Gfa(wPd,i),a=r.run(n);await k38(process.stdout,Wjs(Yto,a)),process.exit(0)})}function Z38(e){return new Promise((t,r)=>{let i=[];e.on("data",n=>i.push(n)),e.on("end",()=>{t(new Uint8Array(Buffer.concat(i)))}),e.on("error",n=>{r(n)})})}function k38(e,t){return new Promise((r,i)=>{e.write(t,n=>{n?i(n):r()})})}
|
|
2077
2077
|
/*! Bundled license information:
|
|
2078
2078
|
|
|
2079
2079
|
tmp/lib/tmp.js:
|
package/package.json
CHANGED