fern-api 0.58.0-rc0 → 0.58.0-rc1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cli.cjs +4 -4
- package/package.json +1 -1
package/cli.cjs
CHANGED
|
@@ -1701,7 +1701,7 @@ ${c.indent}`:""}${tGf(o)}:${l.indent?" ":""}`;return u=!1,s=!0,l.objectItem=void
|
|
|
1701
1701
|
`}),r.replaceAll(/\n$/g,"")}function SNS(e){return e?eh.green(S7.radioOn):S7.radioOff}var bmo=li(KSe(),1);function pop(e,t){return e=String(e),t=typeof t=="string"?t:"*",e.length===0?"":Array.from({length:e.length+1}).join(t)}var Oca=class extends x2{_run(t){this.done=t;let r=hV(this.rl),i=r.line.pipe((0,bmo.map)(this.filterInput.bind(this))),n=this.handleSubmitEvents(i);return n.success.forEach(this.onEnd.bind(this)),n.error.forEach(this.onError.bind(this)),r.keypress.pipe((0,bmo.takeUntil)(n.success)).forEach(this.onKeypress.bind(this)),this.render(),this}render(t){let r=this.getQuestion(),i="";r+=this.status==="answered"?this.getMaskedValue(this.answer):this.getMaskedValue(this.rl.line||""),t&&(i=`
|
|
1702
1702
|
`+eh.red(">> ")+t),this.screen.render(r,i)}getMaskedValue(t){return this.status==="answered"?this.opt.mask?eh.cyan(pop(t,this.opt.mask)):eh.italic.dim("[hidden]"):this.opt.mask?pop(t,this.opt.mask):eh.italic.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 Rup=li(_xs(),1),Nup=li(KSe(),1);var qca=class extends x2{_run(t){this.done=t,this.editorResult=new Nup.Subject;let r=hV(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"?eh.dim("Received"):eh.dim("Press <enter> to launch your preferred editor."),t&&(r=eh.red(">> ")+t),this.screen.render(i,r)}startExternalEditor(){this.rl.pause(),(0,Rup.editAsync)(this.currentText,this.endExternalEditor.bind(this),{postfix:this.opt.postfix??".txt"})}endExternalEditor(t,r){this.rl.resume(),t?this.editorResult.error(t):this.editorResult.next(r)}onEnd(t){this.editorResult.unsubscribe(),this.lineSubscription.unsubscribe(),this.answer=t.value,this.status="answered",this.render(),this.screen.done(),this.done(this.answer)}onError(t){this.render(t.isValid)}};var Osp=li(hsp(),1);var bsp=li(require("readline"),1),gsp=li(vsp(),1),kIi=class{constructor(t){this.rl||=bsp.default.createInterface(UFS(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 UFS(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 gsp.default;return r.pipe(e.output||process.stdout),{terminal:!0,...e,input:t,output:r}}var Bca=class extends kIi{constructor(t={}){super(t),this.log=(0,Osp.default)(this.writeLog.bind(this)),this.bottomBar=t.bottomBar||"",this.render()}render(){return this.write(this.bottomBar),this}clean(){return dca(this.rl,this.bottomBar.split(`
|
|
1703
1703
|
`).length),this}updateBottomBar(t){return dca(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+`
|
|
1704
|
-
`}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&&_mo(this.rl,t.length+this.rl.line.length),this.rl.output.write(t)}};var qsp=li(jsp(),1),Tsp=li(PCs(),1),Csp=li(Msp(),1),ZA=li(KSe(),1),Bsp=li(msa(),1);var Vmo=li(KSe(),1),Asp=li(msa(),1),Wmo=function(e,t,r){return typeof e[t]!="function"?(0,Vmo.of)(e):(0,Vmo.from)((0,Asp.default)(e[t])(r).then(i=>(e[t]=i,e)))};var xca={isPlainObject:qsp.default,set:Csp.default,get:Tsp.default},Jmn=class extends kIi{constructor(t,r){super(r),this.prompts=t}run(t,r){this.answers=xca.isPlainObject(r)?{...r}:{},xca.isPlainObject(t)&&(t=Object.values(t).every(n=>xca.isPlainObject(n)&&n.name===void 0)?Object.entries(t).map(([n,a])=>({name:n,...a})):[t]);let i=Array.isArray(t)?(0,ZA.from)(t):t;return this.process=i.pipe((0,ZA.concatMap)(this.processQuestion.bind(this)),(0,ZA.publish)()),this.process.connect(),this.process.pipe((0,ZA.reduce)((n,a)=>(xca.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,ZA.defer)(()=>(0,ZA.of)(t).pipe((0,ZA.concatMap)(this.setDefaultType.bind(this)),(0,ZA.concatMap)(this.filterIfRunnable.bind(this)),(0,ZA.concatMap)(()=>Wmo(t,"message",this.answers)),(0,ZA.concatMap)(()=>Wmo(t,"default",this.answers)),(0,ZA.concatMap)(()=>Wmo(t,"choices",this.answers)),(0,ZA.concatMap)(this.fetchAnswer.bind(this))))}fetchAnswer(t){let r=this.prompts[t.type];return this.activePrompt=new r(t,this.rl,this.answers),(0,ZA.defer)(()=>(0,ZA.from)(this.activePrompt.run().then(i=>({name:t.name,answer:i}))))}setDefaultType(t){return this.prompts[t.type]||(t.type="input"),(0,ZA.defer)(()=>(0,ZA.of)(t))}filterIfRunnable(t){if(t.askAnswered!==!0&&xca.get(this.answers,t.name)!==void 0)return(0,ZA.empty)();if(t.when===!1)return(0,ZA.empty)();if(typeof t.when!="function")return(0,ZA.of)(t);let{answers:r}=this;return(0,ZA.defer)(()=>(0,ZA.from)((0,Bsp.default)(t.when)(r).then(i=>{if(i)return t})).pipe((0,ZA.filter)(i=>i!=null)))}};function xsp(e){let t=function(r,i){let n;try{n=new Jmn(t.prompts,e)}catch(u){return Promise.reject(u)}let a=n.run(r,i);return a.ui=n,a};return t.prompts={},t.registerPrompt=function(r,i){return t.prompts[r]=i,this},t.restoreDefaultPrompts=function(){this.registerPrompt("list",_ca),this.registerPrompt("input",HIi),this.registerPrompt("number",hca),this.registerPrompt("confirm",yca),this.registerPrompt("rawlist",vca),this.registerPrompt("expand",bca),this.registerPrompt("checkbox",gca),this.registerPrompt("password",Oca),this.registerPrompt("editor",qca)},t.restoreDefaultPrompts(),t}var Sxs=xsp();function a3S(e,t){Sxs.registerPrompt(e,t)}function o3S(){Sxs.restoreDefaultPrompts()}var u3S={prompt:Sxs,ui:{BottomBar:Bca,Prompt:Jmn},createPromptModule:xsp,registerPrompt:a3S,restoreDefaultPrompts:o3S,Separator:Bie},Hmo=u3S;var Hcp=li(Isp()),x6S="4.2.1",b5t;(function(e){e.AnonymousId="anonymous_id",e.DistinctId="distinct_id",e.Props="props",e.FeatureFlags="feature_flags",e.FeatureFlagPayloads="feature_flag_payloads",e.OverrideFeatureFlags="override_feature_flags",e.Queue="queue",e.OptedOut="opted_out",e.SessionId="session_id",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"})(b5t||(b5t={}));function I6S(e,t){if(!e)throw new Error(t)}function z6S(e){return e?.replace(/\/+$/,"")}async function R6S(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 N6S(){return new Date().getTime()}function zcp(){return new Date().toISOString()}function $cp(e,t){let r=setTimeout(e,t);return r?.unref&&r?.unref(),r}var $ca=String.fromCharCode,Rcp="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",aPo={};function F6S(e,t){if(!aPo[e]){aPo[e]={};for(let r=0;r<e.length;r++)aPo[e][e.charAt(r)]=r}return aPo[e][t]}var Gca={compressToBase64:function(e){if(e==null)return"";let t=Gca._compress(e,6,function(r){return Rcp.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:Gca._decompress(e.length,32,function(t){return F6S(Rcp,e.charAt(t))})},compress:function(e){return Gca._compress(e,16,function(t){return $ca(t)})},_compress:function(e,t,r){if(e==null)return"";let i={},n={},a=[],u,l,d="",s="",o="",c=2,b=3,g=2,O=0,m=0,w;for(w=0;w<e.length;w+=1)if(d=e.charAt(w),Object.prototype.hasOwnProperty.call(i,d)||(i[d]=b++,n[d]=!0),s=o+d,Object.prototype.hasOwnProperty.call(i,s))o=s;else{if(Object.prototype.hasOwnProperty.call(n,o)){if(o.charCodeAt(0)<256){for(u=0;u<g;u++)O=O<<1,m==t-1?(m=0,a.push(r(O)),O=0):m++;for(l=o.charCodeAt(0),u=0;u<8;u++)O=O<<1|l&1,m==t-1?(m=0,a.push(r(O)),O=0):m++,l=l>>1}else{for(l=1,u=0;u<g;u++)O=O<<1|l,m==t-1?(m=0,a.push(r(O)),O=0):m++,l=0;for(l=o.charCodeAt(0),u=0;u<16;u++)O=O<<1|l&1,m==t-1?(m=0,a.push(r(O)),O=0):m++,l=l>>1}c--,c==0&&(c=Math.pow(2,g),g++),delete n[o]}else for(l=i[o],u=0;u<g;u++)O=O<<1|l&1,m==t-1?(m=0,a.push(r(O)),O=0):m++,l=l>>1;c--,c==0&&(c=Math.pow(2,g),g++),i[s]=b++,o=String(d)}if(o!==""){if(Object.prototype.hasOwnProperty.call(n,o)){if(o.charCodeAt(0)<256){for(u=0;u<g;u++)O=O<<1,m==t-1?(m=0,a.push(r(O)),O=0):m++;for(l=o.charCodeAt(0),u=0;u<8;u++)O=O<<1|l&1,m==t-1?(m=0,a.push(r(O)),O=0):m++,l=l>>1}else{for(l=1,u=0;u<g;u++)O=O<<1|l,m==t-1?(m=0,a.push(r(O)),O=0):m++,l=0;for(l=o.charCodeAt(0),u=0;u<16;u++)O=O<<1|l&1,m==t-1?(m=0,a.push(r(O)),O=0):m++,l=l>>1}c--,c==0&&(c=Math.pow(2,g),g++),delete n[o]}else for(l=i[o],u=0;u<g;u++)O=O<<1|l&1,m==t-1?(m=0,a.push(r(O)),O=0):m++,l=l>>1;c--,c==0&&(c=Math.pow(2,g),g++)}for(l=2,u=0;u<g;u++)O=O<<1|l&1,m==t-1?(m=0,a.push(r(O)),O=0):m++,l=l>>1;for(;;)if(O=O<<1,m==t-1){a.push(r(O));break}else m++;return a.join("")},decompress:function(e){return e==null?"":e==""?null:Gca._decompress(e.length,32768,function(t){return e.charCodeAt(t)})},_decompress:function(e,t,r){let i=[],n=[],a={val:r(0),position:t,index:1},u=4,l=4,d=3,s="",o,c,b,g,O,m,w;for(o=0;o<3;o+=1)i[o]=o;for(b=0,O=Math.pow(2,2),m=1;m!=O;)g=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),b|=(g>0?1:0)*m,m<<=1;switch(b){case 0:for(b=0,O=Math.pow(2,8),m=1;m!=O;)g=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),b|=(g>0?1:0)*m,m<<=1;w=$ca(b);break;case 1:for(b=0,O=Math.pow(2,16),m=1;m!=O;)g=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),b|=(g>0?1:0)*m,m<<=1;w=$ca(b);break;case 2:return""}for(i[3]=w,c=w,n.push(w);;){if(a.index>e)return"";for(b=0,O=Math.pow(2,d),m=1;m!=O;)g=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),b|=(g>0?1:0)*m,m<<=1;switch(w=b){case 0:for(b=0,O=Math.pow(2,8),m=1;m!=O;)g=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),b|=(g>0?1:0)*m,m<<=1;i[l++]=$ca(b),w=l-1,u--;break;case 1:for(b=0,O=Math.pow(2,16),m=1;m!=O;)g=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),b|=(g>0?1:0)*m,m<<=1;i[l++]=$ca(b),w=l-1,u--;break;case 2:return n.join("")}if(u==0&&(u=Math.pow(2,d),d++),i[w])s=i[w];else if(w===l)s=c+c.charAt(0);else return null;n.push(s),i[l++]=c+s.charAt(0),u--,c=s,u==0&&(u=Math.pow(2,d),d++)}}},cIs=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)}};var oPo="0123456789abcdef",uPo=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+=oPo.charAt(this.bytes[r]>>>4),t+=oPo.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+=oPo.charAt(this.bytes[r]>>>4),t+=oPo.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}},lIs=class{constructor(t){this.timestamp=0,this.counter=0,this.random=t??L6S()}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 uPo.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,uPo.ofInner(t)}},L6S=()=>({nextUint32:()=>Math.trunc(Math.random()*65536)*65536+Math.trunc(Math.random()*65536)}),Ncp,Fcp=()=>U6S().toString(),U6S=()=>(Ncp||(Ncp=new lIs)).generate(),sPo=class extends Error{constructor(t){super("HTTP error while fetching PostHog: "+t.status),this.response=t,this.name="PostHogFetchHttpError"}},Qca=class extends Error{constructor(t){super("Network error while fetching PostHog",t instanceof Error?{cause:t}:{}),this.error=t,this.name="PostHogFetchNetworkError"}};function Lcp(e){return typeof e=="object"&&(e instanceof sPo||e instanceof Qca)}var fIs=class{constructor(t,r){this.flushPromise=null,this.disableGeoip=!0,this.historicalMigration=!1,this.disabled=!1,this.defaultOptIn=!0,this.pendingPromises={},this._events=new cIs,this._isInitialized=!1,I6S(t,"You must pass your PostHog project's api key."),this.apiKey=t,this.host=z6S(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.defaultOptIn=r?.defaultOptIn??!0,this._retryOptions={retryCount:r?.fetchRetryCount??3,retryDelay:r?.fetchRetryDelay??3e3,retryCheck:Lcp},this.requestTimeout=r?.requestTimeout??1e4,this.featureFlagsRequestTimeoutMs=r?.featureFlagsRequestTimeoutMs??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(b5t.OptedOut)??!this.defaultOptIn}async optIn(){this.wrap(()=>{this.setPersistedProperty(b5t.OptedOut,!1)})}async optOut(){this.wrap(()=>{this.setPersistedProperty(b5t.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}buildPayload(t){return{distinct_id:t.distinct_id,event:t.event,properties:{...t.properties||{},...this.getCommonEventProperties()}}}addPendingPromise(t){let r=Fcp();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)})}captureStateless(t,r,i,n){this.wrap(()=>{let a=this.buildPayload({distinct_id:t,event:r,properties:i});this.enqueue("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)})}groupIdentifyStateless(t,r,i,n,a,u){this.wrap(()=>{let l=this.buildPayload({distinct_id:a||`$${t}_${r}`,event:"$groupidentify",properties:{$group_type:t,$group_key:r,$group_set:i||{},...u||{}}});this.enqueue("capture",l,n)})}async getDecide(t,r={},i={},n={},a={}){await this._initPromise;let u=`${this.host}/decide/?v=3`,l={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.fetchWithRetry(u,l,{retryCount:0},this.featureFlagsRequestTimeoutMs).then(d=>d.json()).catch(d=>{this._events.emit("error",d)})}async getFeatureFlagStateless(t,r,i={},n={},a={},u){await this._initPromise;let l=await this.getFeatureFlagsStateless(r,i,n,a,u);if(!l)return;let d=l[t];return d===void 0&&(d=!1),d}async getFeatureFlagPayloadStateless(t,r,i={},n={},a={},u){await this._initPromise;let l=await this.getFeatureFlagPayloadsStateless(r,i,n,a,u);if(!l)return;let d=l[t];return d===void 0?null:d}async getFeatureFlagPayloadsStateless(t,r={},i={},n={},a){return await this._initPromise,(await this.getFeatureFlagsAndPayloadsStateless(t,r,i,n,a)).payloads}_parsePayload(t){try{return JSON.parse(t)}catch{return t}}async getFeatureFlagsStateless(t,r={},i={},n={},a){return await this._initPromise,(await this.getFeatureFlagsAndPayloadsStateless(t,r,i,n,a)).flags}async getFeatureFlagsAndPayloadsStateless(t,r={},i={},n={},a){await this._initPromise;let u={};(a??this.disableGeoip)&&(u.geoip_disable=!0);let l=await this.getDecide(t,r,i,n,u),d=l?.featureFlags,s=l?.featureFlagPayloads,o=s;return s&&(o=Object.fromEntries(Object.entries(s).map(([c,b])=>[c,this._parsePayload(b)]))),{flags:d,payloads:o}}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={...r,type:t,library:this.getLibraryId(),library_version:this.getLibraryVersion(),timestamp:i?.timestamp?i?.timestamp:zcp(),uuid:i?.uuid?i.uuid:Fcp()};(i?.disableGeoip??this.disableGeoip)&&(n.properties||(n.properties={}),n.properties.$geoip_disable=!0),n.distinctId&&(n.distinct_id=n.distinctId,delete n.distinctId);let u=this.getPersistedProperty(b5t.Queue)||[];u.length>=this.maxQueueSize&&(u.shift(),this.logMsgIfDebug(()=>console.info("Queue is full, the oldest event is dropped."))),u.push({message:n}),this.setPersistedProperty(b5t.Queue,u),this._events.emit(t,n),u.length>=this.flushAt&&this.flushBackground(),this.flushInterval&&!this._flushTimer&&(this._flushTimer=$cp(()=>this.flushBackground(),this.flushInterval))})}clearFlushTimer(){this._flushTimer&&(clearTimeout(this._flushTimer),this._flushTimer=void 0)}flushBackground(){this.flush().catch(()=>{})}async flush(){return this.flushPromise||(this.flushPromise=this._flush().finally(()=>{this.flushPromise=null}),this.addPendingPromise(this.flushPromise)),this.flushPromise}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(b5t.Queue)||[];if(!t.length)return[];let r=t.slice(0,this.maxBatchSize),i=r.map(s=>s.message),n=()=>{let s=this.getPersistedProperty(b5t.Queue)||[];this.setPersistedProperty(b5t.Queue,s.slice(r.length))},a={api_key:this.apiKey,batch:i,sent_at:zcp()};this.historicalMigration&&(a.historical_migration=!0);let u=JSON.stringify(a),l=this.captureMode==="form"?`${this.host}/e/?ip=1&_=${N6S()}&v=${this.getLibraryVersion()}`:`${this.host}/batch/`,d=this.captureMode==="form"?{method:"POST",mode:"no-cors",credentials:"omit",headers:{...this.getCustomHeaders(),"Content-Type":"application/x-www-form-urlencoded"},body:`data=${encodeURIComponent(Gca.compressToBase64(u))}&compression=lz64`}:{method:"POST",headers:{...this.getCustomHeaders(),"Content-Type":"application/json"},body:u};try{await this.fetchWithRetry(l,d)}catch(s){throw s instanceof Qca||n(),this._events.emit("error",s),s}return n(),this._events.emit("flush",i),i}async fetchWithRetry(t,r,i,n){var a;return(a=AbortSignal).timeout??(a.timeout=function(l){let d=new AbortController;return setTimeout(()=>d.abort(),l),d.signal}),await R6S(async()=>{let u=null;try{u=await this.fetch(t,{signal:AbortSignal.timeout(n??this.requestTimeout),...r})}catch(d){throw new Qca(d)}if(!(r.mode==="no-cors")&&(u.status<200||u.status>=400))throw new sPo(u);return u},{...this._retryOptions,...i})}async shutdown(t=3e4){await this._initPromise,this.clearFlushTimer();try{await Promise.all(Object.values(this.pendingPromises));let r=Date.now()+t;for(;(this.getPersistedProperty(b5t.Queue)||[]).length!==0;){await this.flush();let n=Date.now();if(r<n)break}}catch(r){if(!Lcp(r))throw r;this.logMsgIfDebug(()=>console.error("Error while shutting down PostHog",r))}}},dIs=class{constructor(){this._memoryStorage={}}getProperty(t){return this._memoryStorage[t]}setProperty(t,r){this._memoryStorage[t]=r!==null?r:void 0}},pIs=typeof fetch<"u"?fetch:typeof global.fetch<"u"?global.fetch:void 0;if(!pIs){let e=Icp();pIs=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 Gcp=pIs,V6S=1152921504606847e3,W6S=["is_not"],cPo=class e extends Error{constructor(t){super(),Error.captureStackTrace(this,this.constructor),this.name="ClientError",this.message=t,Object.setPrototypeOf(this,e.prototype)}},I2=class e extends Error{constructor(t){super(t),this.name=this.constructor.name,Error.captureStackTrace(this,this.constructor),Object.setPrototypeOf(this,e.prototype)}},_Is=class{constructor({pollingInterval:t,personalApiKey:r,projectApiKey:i,timeout:n,host:a,customHeaders:u,...l}){this.debugMode=!1,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=l.fetch||Gcp,this.onError=l.onError,this.customHeaders=u,this.loadFeatureFlags()}debug(t=!0){this.debugMode=t}logMsgIfDebug(t){this.debugMode&&t()}async getFeatureFlag(t,r,i={},n={},a={}){await this.loadFeatureFlags();let u,l;if(!this.loadedSuccessfullyOnce)return u;for(let d of this.featureFlags)if(t===d.key){l=d;break}if(l!==void 0)try{u=this.computeFlagLocally(l,r,i,n,a),this.logMsgIfDebug(()=>console.debug(`Successfully computed flag locally: ${t} -> ${u}`))}catch(d){d instanceof I2?this.logMsgIfDebug(()=>console.debug(`InconclusiveMatchError when computing flag locally: ${t}: ${d}`)):d instanceof Error&&this.onError?.(new Error(`Error computing flag locally: ${t}: ${d}`))}return u}async computeFeatureFlagPayloadLocally(t,r){await this.loadFeatureFlags();let i;if(this.loadedSuccessfullyOnce){if(typeof r=="boolean"?i=this.featureFlagsByKey?.[t]?.filters?.payloads?.[r.toString()]:typeof r=="string"&&(i=this.featureFlagsByKey?.[t]?.filters?.payloads?.[r]),i==null)return null;try{return JSON.parse(i)}catch{return i}}}async getAllFlagsAndPayloads(t,r={},i={},n={}){await this.loadFeatureFlags();let a={},u={},l=this.featureFlags.length==0;return this.featureFlags.map(async d=>{try{let s=this.computeFlagLocally(d,t,r,i,n);a[d.key]=s;let o=await this.computeFeatureFlagPayloadLocally(d.key,s);o&&(u[d.key]=o)}catch(s){s instanceof I2||s instanceof Error&&this.onError?.(new Error(`Error computing flag locally: ${d.key}: ${s}`)),l=!0}}),{response:a,payloads:u,fallbackToDecide:l}}computeFlagLocally(t,r,i={},n={},a={}){if(t.ensure_experience_continuity)throw new I2("Flag has experience continuity enabled");if(!t.active)return!1;let l=(t.filters||{}).aggregation_group_type_index;if(l!=null){let d=this.groupTypeMapping[String(l)];if(!d)throw this.logMsgIfDebug(()=>console.warn(`[FEATURE FLAGS] Unknown group type index ${l} for feature flag ${t.key}`)),new I2("Flag has unknown group type index");if(!(d in i))return this.logMsgIfDebug(()=>console.warn(`[FEATURE FLAGS] Can't compute group feature flag: ${t.key} without group names passed in`)),!1;let s=a[d];return this.matchFeatureFlagProperties(t,i[d],s)}else return this.matchFeatureFlagProperties(t,r,n)}matchFeatureFlagProperties(t,r,i){let n=t.filters||{},a=n.groups||[],u=!1,l,d=[...a].sort((s,o)=>{let c=!!s.variant,b=!!o.variant;return c&&b?0:c?-1:b?1:0});for(let s of d)try{if(this.isConditionMatch(t,r,s,i)){let o=s.variant,c=n.multivariate?.variants||[];o&&c.some(b=>b.key===o)?l=o:l=this.getMatchingVariant(t,r)||!0;break}}catch(o){if(o instanceof I2)u=!0;else throw o}if(l!==void 0)return l;if(u)throw new I2("Can't determine if feature flag is enabled or not with given properties");return!1}isConditionMatch(t,r,i,n){let a=i.rollout_percentage,u=l=>{this.logMsgIfDebug(()=>console.warn(l))};if((i.properties||[]).length>0){for(let l of i.properties){let d=l.type,s=!1;if(d==="cohort"?s=Jcp(l,n,this.cohorts,this.debugMode):s=Qcp(l,n,u),!s)return!1}if(a==null)return!0}return!(a!=null&&Ucp(t.key,r)>a/100)}getMatchingVariant(t,r){let i=Ucp(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(l=>{n=i+l.rollout_percentage/100,r.push({valueMin:i,valueMax:n,key:l.key}),i=n}),r}async loadFeatureFlags(t=!1){(!this.loadedSuccessfullyOnce||t)&&await this._loadFeatureFlags()}async _loadFeatureFlags(){this.poller&&(clearTimeout(this.poller),this.poller=void 0),this.poller=setTimeout(()=>this._loadFeatureFlags(),this.pollingInterval);try{let t=await this._requestFeatureFlagDefinitions();if(t&&t.status===401)throw new cPo("Your personalApiKey is invalid. Are you sure you're not using your Project API key? More information: https://posthog.com/docs/api/overview");if(t&&t.status!==200)return;let r=await t.json();"flags"in r||this.onError?.(new Error(`Invalid response when getting feature flags: ${JSON.stringify(r)}`)),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}catch(t){t instanceof cPo&&this.onError?.(t)}}async _requestFeatureFlagDefinitions(){let t=`${this.host}/api/feature_flag/local_evaluation?token=${this.projectApiKey}&send_cohorts`,r={method:"GET",headers:{...this.customHeaders,"Content-Type":"application/json",Authorization:`Bearer ${this.personalApiKey}`}},i=null;if(this.timeout&&typeof this.timeout=="number"){let n=new AbortController;i=$cp(()=>{n.abort()},this.timeout),r.signal=n.signal}try{return await this.fetch(t,r)}finally{clearTimeout(i)}}stopPoller(){clearTimeout(this.poller)}};function Ucp(e,t,r=""){let i=(0,Hcp.createHash)();return i.update(`${e}.${t}${r}`),parseInt(i.digest("hex").slice(0,15),16)/V6S}function Qcp(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 I2("Operator is_not_set is not supported")}else throw new I2(`Property ${i} not found in propertyValues`);let u=t[i];if(u==null&&!W6S.includes(a))return r&&r(`Property ${i} cannot have a value of null/undefined with the ${a} operator`),!1;function l(s,o){return Array.isArray(s)?s.map(c=>String(c).toLowerCase()).includes(String(o).toLowerCase()):String(s).toLowerCase()===String(o).toLowerCase()}function d(s,o,c){if(c==="gt")return s>o;if(c==="gte")return s>=o;if(c==="lt")return s<o;if(c==="lte")return s<=o;throw new Error(`Invalid operator: ${c}`)}switch(a){case"exact":return l(n,u);case"is_not":return!l(n,u);case"is_set":return i in t;case"icontains":return String(u).toLowerCase().includes(String(n).toLowerCase());case"not_icontains":return!String(u).toLowerCase().includes(String(n).toLowerCase());case"regex":return Vcp(String(n))&&String(u).match(String(n))!==null;case"not_regex":return Vcp(String(n))&&String(u).match(String(n))===null;case"gt":case"gte":case"lt":case"lte":{let s=typeof n=="number"?n:null;if(typeof n=="string")try{s=parseFloat(n)}catch{}return s!=null&&u!=null?typeof u=="string"?d(u,String(n),a):d(u,s,a):d(String(u),String(n),a)}case"is_date_after":case"is_date_before":{let s=H6S(String(n));if(s==null&&(s=Wcp(n)),s==null)throw new I2(`Invalid date: ${n}`);let o=Wcp(u);return["is_date_before"].includes(a)?o<s:o>s}default:throw new I2(`Unknown operator: ${a}`)}}function Jcp(e,t,r,i=!1){let n=String(e.value);if(!(n in r))throw new I2("can't match cohort without a given cohort property value");let a=r[n];return Kcp(a,t,r,i)}function Kcp(e,t,r,i=!1){if(!e)return!0;let n=e.type,a=e.values;if(!a||a.length===0)return!0;let u=!1;if("values"in a[0]){for(let l of a)try{let d=Kcp(l,t,r,i);if(n==="AND"){if(!d)return!1}else if(d)return!0}catch(d){if(d instanceof I2)i&&console.debug(`Failed to compute property ${l} locally: ${d}`),u=!0;else throw d}if(u)throw new I2("Can't match cohort without a given cohort property value");return n==="AND"}else{for(let l of a)try{let d;l.type==="cohort"?d=Jcp(l,t,r,i):d=Qcp(l,t);let s=l.negation||!1;if(n==="AND"){if(!d&&!s||d&&s)return!1}else if(d&&!s||!d&&s)return!0}catch(d){if(d instanceof I2)i&&console.debug(`Failed to compute property ${l} locally: ${d}`),u=!0;else throw d}if(u)throw new I2("can't match cohort without a given cohort property value");return n==="AND"}}function Vcp(e){try{return new RegExp(e),!0}catch{return!1}}function Wcp(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 I2(`${e} is in an invalid date format`)}else throw new I2(`The date provided ${e} must be a string, number, or date object`)}function H6S(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 $6S=30*1e3,G6S=50*1e3,tPn=class extends fIs{constructor(t,r={}){super(t,r),this._memoryStorage=new dIs,this.options=r,r.personalApiKey&&(this.featureFlagsPoller=new _Is({pollingInterval:typeof r.featureFlagsPollingInterval=="number"?r.featureFlagsPollingInterval:$6S,personalApiKey:r.personalApiKey,projectApiKey:t,timeout:r.requestTimeout??1e4,host:this.host,fetch:r.fetch,onError:i=>{this._events.emit("error",i)},customHeaders:this.getCustomHeaders()})),this.distinctIdHasSentFlagCalls={},this.maxCacheSize=r.maxCacheSize||G6S}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):Gcp(t,r)}getLibraryId(){return"posthog-node"}getLibraryVersion(){return x6S}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({distinctId:t,event:r,properties:i,groups:n,sendFeatureFlags:a,timestamp:u,disableGeoip:l,uuid:d}){let s=b=>{super.captureStateless(t,r,b,{timestamp:u,disableGeoip:l,uuid:d})},o=(b,g,O)=>super.getFeatureFlagsStateless(b,g,void 0,void 0,O),c=Promise.resolve().then(async()=>{if(a)return await o(t,n,l);if((this.featureFlagsPoller?.featureFlags?.length||0)>0){let b={};for(let[g,O]of Object.entries(n||{}))b[g]=String(O);return await this.getAllFlags(t,{groups:b,disableGeoip:l,onlyEvaluateLocally:!0})}return{}}).then(b=>{let g={};if(b)for(let[m,w]of Object.entries(b))g[`$feature/${m}`]=w;let O=Object.keys(b||{}).filter(m=>b?.[m]!==!1);return O.length>0&&(g.$active_feature_flags=O),g}).catch(()=>({})).then(b=>{s({...b,...i,$groups:n})});this.addPendingPromise(c)}identify({distinctId:t,properties:r,disableGeoip:i}){let n=r?.$set||r;super.identifyStateless(t,{$set:n},{disableGeoip:i})}alias(t){super.aliasStateless(t.alias,t.distinctId,void 0,{disableGeoip:t.disableGeoip})}async getFeatureFlag(t,r,i){let{groups:n,disableGeoip:a}=i||{},{onlyEvaluateLocally:u,sendFeatureFlagEvents:l,personProperties:d,groupProperties:s}=i||{},o=this.addLocalPersonAndGroupProperties(r,n,d,s);d=o.allPersonProperties,s=o.allGroupProperties,u==null&&(u=!1),l==null&&(l=!0);let c=await this.featureFlagsPoller?.getFeatureFlag(t,r,n,d,s),b=c!==void 0;!b&&!u&&(c=await super.getFeatureFlagStateless(t,r,n,d,s,a));let g=`${t}_${c}`;return l&&(!(r in this.distinctIdHasSentFlagCalls)||!this.distinctIdHasSentFlagCalls[r].includes(g))&&(Object.keys(this.distinctIdHasSentFlagCalls).length>=this.maxCacheSize&&(this.distinctIdHasSentFlagCalls={}),Array.isArray(this.distinctIdHasSentFlagCalls[r])?this.distinctIdHasSentFlagCalls[r].push(g):this.distinctIdHasSentFlagCalls[r]=[g],this.capture({distinctId:r,event:"$feature_flag_called",properties:{$feature_flag:t,$feature_flag_response:c,locally_evaluated:b,[`$feature/${t}`]:c},groups:n,disableGeoip:a})),c}async getFeatureFlagPayload(t,r,i,n){let{groups:a,disableGeoip:u}=n||{},{onlyEvaluateLocally:l,sendFeatureFlagEvents:d,personProperties:s,groupProperties:o}=n||{},c=this.addLocalPersonAndGroupProperties(r,a,s,o);s=c.allPersonProperties,o=c.allGroupProperties;let b;return i||(i=await this.getFeatureFlag(t,r,{...n,onlyEvaluateLocally:!0})),i&&(b=await this.featureFlagsPoller?.computeFeatureFlagPayloadLocally(t,i)),l==null&&(l=!1),d==null&&(d=!0),l==null&&(l=!1),!(b!==void 0)&&!l&&(b=await super.getFeatureFlagPayloadStateless(t,r,a,s,o,u)),b}async isFeatureEnabled(t,r,i){let n=await this.getFeatureFlag(t,r,i);if(n!==void 0)return!!n||!1}async getAllFlags(t,r){return(await this.getAllFlagsAndPayloads(t,r)).featureFlags}async getAllFlagsAndPayloads(t,r){let{groups:i,disableGeoip:n}=r||{},{onlyEvaluateLocally:a,personProperties:u,groupProperties:l}=r||{},d=this.addLocalPersonAndGroupProperties(t,i,u,l);u=d.allPersonProperties,l=d.allGroupProperties,a==null&&(a=!1);let s=await this.featureFlagsPoller?.getAllFlagsAndPayloads(t,i,u,l),o={},c={},b=!0;if(s&&(o=s.response,c=s.payloads,b=s.fallbackToDecide),b&&!a){let g=await super.getFeatureFlagsAndPayloadsStateless(t,i,u,l,n);o={...o,...g.flags||{}},c={...c,...g.payloads||{}}}return{featureFlags:o,featureFlagPayloads:c}}groupIdentify({groupType:t,groupKey:r,properties:i,distinctId:n,disableGeoip:a}){super.groupIdentifyStateless(t,r,i,{disableGeoip:a},n)}async reloadFeatureFlags(){await this.featureFlagsPoller?.loadFeatureFlags(!0)}async shutdown(t){return this.featureFlagsPoller?.stopPoller(),super.shutdown(t)}addLocalPersonAndGroupProperties(t,r,i,n){let a={distinct_id:t,...i||{}},u={};if(r)for(let l of Object.keys(r))u[l]={$group_key:r[l],...n?.[l]||{}};return{allPersonProperties:a,allGroupProperties:u}}},hIs=class e{constructor(t,r,i,n){this.posthog=t,this.posthogHost=r,this.organization=i,this.prefix=n,this.name="posthog-node",this.posthogHost=t.options.host??"https://us.i.posthog.com"}setupOnce(t,r){t(i=>{if(i.exception?.values===void 0||i.exception.values.length===0)return i;i.tags||(i.tags={});let n=r(),a=i.tags[e.POSTHOG_ID_TAG];if(a===void 0)return i;i.tags["PostHog Person URL"]=new URL(`/person/${a}`,this.posthogHost).toString();let u={$exception_message:i.exception.values[0]?.value,$exception_type:i.exception.values[0]?.type,$exception_personURL:i.tags["PostHog Person URL"],$sentry_event_id:i.event_id,$sentry_exception:i.exception,$sentry_exception_message:i.exception.values[0]?.value,$sentry_exception_type:i.exception.values[0]?.type,$sentry_tags:i.tags},l=n.getClient()?.getDsn()?.projectId;return this.organization!==void 0&&l!==void 0&&i.event_id!==void 0&&(u.$sentry_url=`${this.prefix??"https://sentry.io/organizations"}/${this.organization}/issues/?project=${l}&query=${i.event_id}`),this.posthog.capture({event:"$exception",distinctId:a,properties:u}),i})}};hIs.POSTHOG_ID_TAG="posthog_distinct_id";var lPo=class{posthog;constructor({posthogApiKey:t}){this.posthog=new tPn(t)}async identify(){}async sendEvent(t){t.orgId!=null&&this.posthog.capture({distinctId:t.orgId,event:"CLI",properties:{...t,...t.properties,version:"0.58.0-rc0",usingAccessToken:!0}})}async flush(){await this.posthog.flush()}};var Jca=class{async sendEvent(){}async identify(){}async flush(){}};var rPn=require("fs/promises"),kcp=require("os"),elp=require("path");var Ycp=li(require("crypto")),dPo=new Uint8Array(256),fPo=dPo.length;function yIs(){return fPo>dPo.length-16&&(Ycp.default.randomFillSync(dPo),fPo=0),dPo.slice(fPo,fPo+=16)}var bV=[];for(let e=0;e<256;++e)bV.push((e+256).toString(16).slice(1));function Xcp(e,t=0){return bV[e[t+0]]+bV[e[t+1]]+bV[e[t+2]]+bV[e[t+3]]+"-"+bV[e[t+4]]+bV[e[t+5]]+"-"+bV[e[t+6]]+bV[e[t+7]]+"-"+bV[e[t+8]]+bV[e[t+9]]+"-"+bV[e[t+10]]+bV[e[t+11]]+bV[e[t+12]]+bV[e[t+13]]+bV[e[t+14]]+bV[e[t+15]]}var Zcp=li(require("crypto")),vIs={randomUUID:Zcp.default.randomUUID};function Q6S(e,t,r){if(vIs.randomUUID&&!t&&!e)return vIs.randomUUID();e=e||{};let i=e.random||(e.rng||yIs)();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 Xcp(i)}var Nie=Q6S;var J6S="id",K6S=".fern",Kca=class{posthog;userId;constructor({token:t,posthogApiKey:r}){this.posthog=new tPn(r),this.userId=t==null?void 0:SEs(t)}async identify(){this.userId!=null&&this.posthog.alias({distinctId:this.userId,alias:await this.getPersistedDistinctId()})}async sendEvent(t){this.posthog.capture({distinctId:this.userId??await this.getPersistedDistinctId(),event:"CLI",properties:{version:"0.58.0-rc0",...t,...t.properties}})}async flush(){await this.posthog.flush()}persistedDistinctId;async getPersistedDistinctId(){if(this.persistedDistinctId==null){let t=Wu(Ul.of((0,kcp.homedir)()),eo.of(K6S),eo.of(J6S));await Cf(t)||(await(0,rPn.mkdir)((0,elp.dirname)(t),{recursive:!0}),await(0,rPn.writeFile)(t,Nie())),this.persistedDistinctId=(await(0,rPn.readFile)(t)).toString()}return this.persistedDistinctId}};var bIs;async function iPn(){return bIs==null&&(bIs=await Y6S()),bIs}async function Y6S(){try{let e="phc_yQgAEdJJkVpI24NdSRID2mor1x1leRpDoC9yZ9mfXal",t=process.env.FERN_DISABLE_TELEMETRY==="true";if(e==null||t)return new Jca;let r=await _yo();return r!=null?new Kca({token:r,posthogApiKey:e}):await pyo()!=null?new lPo({posthogApiKey:e}):new Kca({token:void 0,posthogApiKey:e})}catch{return new Jca}}function Yca(e,t){return function(){return e.apply(t,arguments)}}var{toString:X6S}=Object.prototype,{getPrototypeOf:OIs}=Object,_Po=(e=>t=>{let r=X6S.call(t);return e[r]||(e[r]=r.slice(8,-1).toLowerCase())})(Object.create(null)),g5t=e=>(e=e.toLowerCase(),t=>_Po(t)===e),hPo=e=>t=>typeof t===e,{isArray:nPn}=Array,Xca=hPo("undefined");function Z6S(e){return e!==null&&!Xca(e)&&e.constructor!==null&&!Xca(e.constructor)&&XSe(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}var rlp=g5t("ArrayBuffer");function k6S(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&rlp(e.buffer),t}var e2S=hPo("string"),XSe=hPo("function"),ilp=hPo("number"),yPo=e=>e!==null&&typeof e=="object",t2S=e=>e===!0||e===!1,pPo=e=>{if(_Po(e)!=="object")return!1;let t=OIs(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)},r2S=g5t("Date"),i2S=g5t("File"),n2S=g5t("Blob"),a2S=g5t("FileList"),o2S=e=>yPo(e)&&XSe(e.pipe),u2S=e=>{let t;return e&&(typeof FormData=="function"&&e instanceof FormData||XSe(e.append)&&((t=_Po(e))==="formdata"||t==="object"&&XSe(e.toString)&&e.toString()==="[object FormData]"))},s2S=g5t("URLSearchParams"),[c2S,l2S,f2S,d2S]=["ReadableStream","Request","Response","Headers"].map(g5t),p2S=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function Zca(e,t,{allOwnKeys:r=!1}={}){if(e===null||typeof e>"u")return;let i,n;if(typeof e!="object"&&(e=[e]),nPn(e))for(i=0,n=e.length;i<n;i++)t.call(null,e[i],i,e);else{let a=r?Object.getOwnPropertyNames(e):Object.keys(e),u=a.length,l;for(i=0;i<u;i++)l=a[i],t.call(null,e[l],l,e)}}function nlp(e,t){t=t.toLowerCase();let r=Object.keys(e),i=r.length,n;for(;i-- >0;)if(n=r[i],t===n.toLowerCase())return n;return null}var nzi=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,alp=e=>!Xca(e)&&e!==nzi;function gIs(){let{caseless:e}=alp(this)&&this||{},t={},r=(i,n)=>{let a=e&&nlp(t,n)||n;pPo(t[a])&&pPo(i)?t[a]=gIs(t[a],i):pPo(i)?t[a]=gIs({},i):nPn(i)?t[a]=i.slice():t[a]=i};for(let i=0,n=arguments.length;i<n;i++)arguments[i]&&Zca(arguments[i],r);return t}var _2S=(e,t,r,{allOwnKeys:i}={})=>(Zca(t,(n,a)=>{r&&XSe(n)?e[a]=Yca(n,r):e[a]=n},{allOwnKeys:i}),e),h2S=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),y2S=(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)},v2S=(e,t,r,i)=>{let n,a,u,l={};if(t=t||{},e==null)return t;do{for(n=Object.getOwnPropertyNames(e),a=n.length;a-- >0;)u=n[a],(!i||i(u,e,t))&&!l[u]&&(t[u]=e[u],l[u]=!0);e=r!==!1&&OIs(e)}while(e&&(!r||r(e,t))&&e!==Object.prototype);return t},b2S=(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},g2S=e=>{if(!e)return null;if(nPn(e))return e;let t=e.length;if(!ilp(t))return null;let r=new Array(t);for(;t-- >0;)r[t]=e[t];return r},O2S=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&OIs(Uint8Array)),m2S=(e,t)=>{let i=(e&&e[Symbol.iterator]).call(e),n;for(;(n=i.next())&&!n.done;){let a=n.value;t.call(e,a[0],a[1])}},P2S=(e,t)=>{let r,i=[];for(;(r=e.exec(t))!==null;)i.push(r);return i},j2S=g5t("HTMLFormElement"),w2S=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(r,i,n){return i.toUpperCase()+n}),tlp=(({hasOwnProperty:e})=>(t,r)=>e.call(t,r))(Object.prototype),S2S=g5t("RegExp"),olp=(e,t)=>{let r=Object.getOwnPropertyDescriptors(e),i={};Zca(r,(n,a)=>{let u;(u=t(n,a,e))!==!1&&(i[a]=u||n)}),Object.defineProperties(e,i)},D2S=e=>{olp(e,(t,r)=>{if(XSe(e)&&["arguments","caller","callee"].indexOf(r)!==-1)return!1;let i=e[r];if(XSe(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+"'")})}})},E2S=(e,t)=>{let r={},i=n=>{n.forEach(a=>{r[a]=!0})};return nPn(e)?i(e):i(String(e).split(t)),r},M2S=()=>{},A2S=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t;function q2S(e){return!!(e&&XSe(e.append)&&e[Symbol.toStringTag]==="FormData"&&e[Symbol.iterator])}var T2S=e=>{let t=new Array(10),r=(i,n)=>{if(yPo(i)){if(t.indexOf(i)>=0)return;if(!("toJSON"in i)){t[n]=i;let a=nPn(i)?[]:{};return Zca(i,(u,l)=>{let d=r(u,n+1);!Xca(d)&&(a[l]=d)}),t[n]=void 0,a}}return i};return r(e,0)},C2S=g5t("AsyncFunction"),B2S=e=>e&&(yPo(e)||XSe(e))&&XSe(e.then)&&XSe(e.catch),ulp=((e,t)=>e?setImmediate:t?((r,i)=>(nzi.addEventListener("message",({source:n,data:a})=>{n===nzi&&a===r&&i.length&&i.shift()()},!1),n=>{i.push(n),nzi.postMessage(r,"*")}))(`axios@${Math.random()}`,[]):r=>setTimeout(r))(typeof setImmediate=="function",XSe(nzi.postMessage)),x2S=typeof queueMicrotask<"u"?queueMicrotask.bind(nzi):typeof process<"u"&&process.nextTick||ulp,ds={isArray:nPn,isArrayBuffer:rlp,isBuffer:Z6S,isFormData:u2S,isArrayBufferView:k6S,isString:e2S,isNumber:ilp,isBoolean:t2S,isObject:yPo,isPlainObject:pPo,isReadableStream:c2S,isRequest:l2S,isResponse:f2S,isHeaders:d2S,isUndefined:Xca,isDate:r2S,isFile:i2S,isBlob:n2S,isRegExp:S2S,isFunction:XSe,isStream:o2S,isURLSearchParams:s2S,isTypedArray:O2S,isFileList:a2S,forEach:Zca,merge:gIs,extend:_2S,trim:p2S,stripBOM:h2S,inherits:y2S,toFlatObject:v2S,kindOf:_Po,kindOfTest:g5t,endsWith:b2S,toArray:g2S,forEachEntry:m2S,matchAll:P2S,isHTMLForm:j2S,hasOwnProperty:tlp,hasOwnProp:tlp,reduceDescriptors:olp,freezeMethods:D2S,toObjectSet:E2S,toCamelCase:w2S,noop:M2S,toFiniteNumber:A2S,findKey:nlp,global:nzi,isContextDefined:alp,isSpecCompliantForm:q2S,toJSONObject:T2S,isAsyncFn:C2S,isThenable:B2S,setImmediate:ulp,asap:x2S};function aPn(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)}ds.inherits(aPn,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:ds.toJSONObject(this.config),code:this.code,status:this.status}}});var slp=aPn.prototype,clp={};["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=>{clp[e]={value:e}});Object.defineProperties(aPn,clp);Object.defineProperty(slp,"isAxiosError",{value:!0});aPn.from=(e,t,r,i,n,a)=>{let u=Object.create(slp);return ds.toFlatObject(e,u,function(d){return d!==Error.prototype},l=>l!=="isAxiosError"),aPn.call(u,e.message,t,r,i,n),u.cause=e,u.name=e.name,a&&Object.assign(u,a),u};var Dp=aPn;var llp=li(Mia(),1),vPo=llp.default;function mIs(e){return ds.isPlainObject(e)||ds.isArray(e)}function dlp(e){return ds.endsWith(e,"[]")?e.slice(0,-2):e}function flp(e,t,r){return e?e.concat(t).map(function(n,a){return n=dlp(n),!r&&a?"["+n+"]":n}).join(r?".":""):t}function I2S(e){return ds.isArray(e)&&!e.some(mIs)}var z2S=ds.toFlatObject(ds,{},null,function(t){return/^is[A-Z]/.test(t)});function R2S(e,t,r){if(!ds.isObject(e))throw new TypeError("target must be an object");t=t||new(vPo||FormData),r=ds.toFlatObject(r,{metaTokens:!0,dots:!1,indexes:!1},!1,function(m,w){return!ds.isUndefined(w[m])});let i=r.metaTokens,n=r.visitor||o,a=r.dots,u=r.indexes,d=(r.Blob||typeof Blob<"u"&&Blob)&&ds.isSpecCompliantForm(t);if(!ds.isFunction(n))throw new TypeError("visitor must be a function");function s(O){if(O===null)return"";if(ds.isDate(O))return O.toISOString();if(!d&&ds.isBlob(O))throw new Dp("Blob is not supported. Use a Buffer instead.");return ds.isArrayBuffer(O)||ds.isTypedArray(O)?d&&typeof Blob=="function"?new Blob([O]):Buffer.from(O):O}function o(O,m,w){let E=O;if(O&&!w&&typeof O=="object"){if(ds.endsWith(m,"{}"))m=i?m:m.slice(0,-2),O=JSON.stringify(O);else if(ds.isArray(O)&&I2S(O)||(ds.isFileList(O)||ds.endsWith(m,"[]"))&&(E=ds.toArray(O)))return m=dlp(m),E.forEach(function(q,D){!(ds.isUndefined(q)||q===null)&&t.append(u===!0?flp([m],D,a):u===null?m:m+"[]",s(q))}),!1}return mIs(O)?!0:(t.append(flp(w,m,a),s(O)),!1)}let c=[],b=Object.assign(z2S,{defaultVisitor:o,convertValue:s,isVisitable:mIs});function g(O,m){if(!ds.isUndefined(O)){if(c.indexOf(O)!==-1)throw Error("Circular reference detected in "+m.join("."));c.push(O),ds.forEach(O,function(E,A){(!(ds.isUndefined(E)||E===null)&&n.call(t,E,ds.isString(A)?A.trim():A,m,b))===!0&&g(E,m?m.concat(A):[A])}),c.pop()}}if(!ds.isObject(e))throw new TypeError("data must be an object");return g(e),t}var mfi=R2S;function plp(e){let t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(i){return t[i]})}function _lp(e,t){this._pairs=[],e&&mfi(e,this,t)}var hlp=_lp.prototype;hlp.append=function(t,r){this._pairs.push([t,r])};hlp.toString=function(t){let r=t?function(i){return t.call(this,i,plp)}:plp;return this._pairs.map(function(n){return r(n[0])+"="+r(n[1])},"").join("&")};var ylp=_lp;function N2S(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function azi(e,t,r){if(!t)return e;let i=r&&r.encode||N2S;ds.isFunction(r)&&(r={serialize:r});let n=r&&r.serialize,a;if(n?a=n(t,r):a=ds.isURLSearchParams(t)?t.toString():new ylp(t,r).toString(i),a){let u=e.indexOf("#");u!==-1&&(e=e.slice(0,u)),e+=(e.indexOf("?")===-1?"?":"&")+a}return e}var PIs=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){ds.forEach(this.handlers,function(i){i!==null&&t(i)})}},jIs=PIs;var oPn={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1};var Olp=li(require("crypto"),1);var vlp=li(require("url"),1),blp=vlp.default.URLSearchParams;var wIs="abcdefghijklmnopqrstuvwxyz",glp="0123456789",mlp={DIGIT:glp,ALPHA:wIs,ALPHA_DIGIT:wIs+wIs.toUpperCase()+glp},F2S=(e=16,t=mlp.ALPHA_DIGIT)=>{let r="",{length:i}=t,n=new Uint32Array(e);Olp.default.randomFillSync(n);for(let a=0;a<e;a++)r+=t[n[a]%i];return r},Plp={isNode:!0,classes:{URLSearchParams:blp,FormData:vPo,Blob:typeof Blob<"u"&&Blob||null},ALPHABET:mlp,generateString:F2S,protocols:["http","https","file","data"]};var EIs={};jo(EIs,{hasBrowserEnv:()=>DIs,hasStandardBrowserEnv:()=>L2S,hasStandardBrowserWebWorkerEnv:()=>U2S,navigator:()=>SIs,origin:()=>V2S});var DIs=typeof window<"u"&&typeof document<"u",SIs=typeof navigator=="object"&&navigator||void 0,L2S=DIs&&(!SIs||["ReactNative","NativeScript","NS"].indexOf(SIs.product)<0),U2S=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",V2S=DIs&&window.location.href||"http://localhost";var EM={...EIs,...Plp};function MIs(e,t){return mfi(e,new EM.classes.URLSearchParams,Object.assign({visitor:function(r,i,n,a){return EM.isNode&&ds.isBuffer(r)?(this.append(i,r.toString("base64")),!1):a.defaultVisitor.apply(this,arguments)}},t))}function W2S(e){return ds.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function H2S(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 $2S(e){function t(r,i,n,a){let u=r[a++];if(u==="__proto__")return!0;let l=Number.isFinite(+u),d=a>=r.length;return u=!u&&ds.isArray(n)?n.length:u,d?(ds.hasOwnProp(n,u)?n[u]=[n[u],i]:n[u]=i,!l):((!n[u]||!ds.isObject(n[u]))&&(n[u]=[]),t(r,i,n[u],a)&&ds.isArray(n[u])&&(n[u]=H2S(n[u])),!l)}if(ds.isFormData(e)&&ds.isFunction(e.entries)){let r={};return ds.forEachEntry(e,(i,n)=>{t(W2S(i),n,r,0)}),r}return null}var bPo=$2S;function G2S(e,t,r){if(ds.isString(e))try{return(t||JSON.parse)(e),ds.trim(e)}catch(i){if(i.name!=="SyntaxError")throw i}return(r||JSON.stringify)(e)}var AIs={transitional:oPn,adapter:["xhr","http","fetch"],transformRequest:[function(t,r){let i=r.getContentType()||"",n=i.indexOf("application/json")>-1,a=ds.isObject(t);if(a&&ds.isHTMLForm(t)&&(t=new FormData(t)),ds.isFormData(t))return n?JSON.stringify(bPo(t)):t;if(ds.isArrayBuffer(t)||ds.isBuffer(t)||ds.isStream(t)||ds.isFile(t)||ds.isBlob(t)||ds.isReadableStream(t))return t;if(ds.isArrayBufferView(t))return t.buffer;if(ds.isURLSearchParams(t))return r.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),t.toString();let l;if(a){if(i.indexOf("application/x-www-form-urlencoded")>-1)return MIs(t,this.formSerializer).toString();if((l=ds.isFileList(t))||i.indexOf("multipart/form-data")>-1){let d=this.env&&this.env.FormData;return mfi(l?{"files[]":t}:t,d&&new d,this.formSerializer)}}return a||n?(r.setContentType("application/json",!1),G2S(t)):t}],transformResponse:[function(t){let r=this.transitional||AIs.transitional,i=r&&r.forcedJSONParsing,n=this.responseType==="json";if(ds.isResponse(t)||ds.isReadableStream(t))return t;if(t&&ds.isString(t)&&(i&&!this.responseType||n)){let u=!(r&&r.silentJSONParsing)&&n;try{return JSON.parse(t)}catch(l){if(u)throw l.name==="SyntaxError"?Dp.from(l,Dp.ERR_BAD_RESPONSE,this,null,this.response):l}}return t}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:EM.classes.FormData,Blob:EM.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};ds.forEach(["delete","get","head","post","put","patch"],e=>{AIs.headers[e]={}});var uPn=AIs;var Q2S=ds.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"]),jlp=e=>{let t={},r,i,n;return e&&e.split(`
|
|
1704
|
+
`}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&&_mo(this.rl,t.length+this.rl.line.length),this.rl.output.write(t)}};var qsp=li(jsp(),1),Tsp=li(PCs(),1),Csp=li(Msp(),1),ZA=li(KSe(),1),Bsp=li(msa(),1);var Vmo=li(KSe(),1),Asp=li(msa(),1),Wmo=function(e,t,r){return typeof e[t]!="function"?(0,Vmo.of)(e):(0,Vmo.from)((0,Asp.default)(e[t])(r).then(i=>(e[t]=i,e)))};var xca={isPlainObject:qsp.default,set:Csp.default,get:Tsp.default},Jmn=class extends kIi{constructor(t,r){super(r),this.prompts=t}run(t,r){this.answers=xca.isPlainObject(r)?{...r}:{},xca.isPlainObject(t)&&(t=Object.values(t).every(n=>xca.isPlainObject(n)&&n.name===void 0)?Object.entries(t).map(([n,a])=>({name:n,...a})):[t]);let i=Array.isArray(t)?(0,ZA.from)(t):t;return this.process=i.pipe((0,ZA.concatMap)(this.processQuestion.bind(this)),(0,ZA.publish)()),this.process.connect(),this.process.pipe((0,ZA.reduce)((n,a)=>(xca.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,ZA.defer)(()=>(0,ZA.of)(t).pipe((0,ZA.concatMap)(this.setDefaultType.bind(this)),(0,ZA.concatMap)(this.filterIfRunnable.bind(this)),(0,ZA.concatMap)(()=>Wmo(t,"message",this.answers)),(0,ZA.concatMap)(()=>Wmo(t,"default",this.answers)),(0,ZA.concatMap)(()=>Wmo(t,"choices",this.answers)),(0,ZA.concatMap)(this.fetchAnswer.bind(this))))}fetchAnswer(t){let r=this.prompts[t.type];return this.activePrompt=new r(t,this.rl,this.answers),(0,ZA.defer)(()=>(0,ZA.from)(this.activePrompt.run().then(i=>({name:t.name,answer:i}))))}setDefaultType(t){return this.prompts[t.type]||(t.type="input"),(0,ZA.defer)(()=>(0,ZA.of)(t))}filterIfRunnable(t){if(t.askAnswered!==!0&&xca.get(this.answers,t.name)!==void 0)return(0,ZA.empty)();if(t.when===!1)return(0,ZA.empty)();if(typeof t.when!="function")return(0,ZA.of)(t);let{answers:r}=this;return(0,ZA.defer)(()=>(0,ZA.from)((0,Bsp.default)(t.when)(r).then(i=>{if(i)return t})).pipe((0,ZA.filter)(i=>i!=null)))}};function xsp(e){let t=function(r,i){let n;try{n=new Jmn(t.prompts,e)}catch(u){return Promise.reject(u)}let a=n.run(r,i);return a.ui=n,a};return t.prompts={},t.registerPrompt=function(r,i){return t.prompts[r]=i,this},t.restoreDefaultPrompts=function(){this.registerPrompt("list",_ca),this.registerPrompt("input",HIi),this.registerPrompt("number",hca),this.registerPrompt("confirm",yca),this.registerPrompt("rawlist",vca),this.registerPrompt("expand",bca),this.registerPrompt("checkbox",gca),this.registerPrompt("password",Oca),this.registerPrompt("editor",qca)},t.restoreDefaultPrompts(),t}var Sxs=xsp();function a3S(e,t){Sxs.registerPrompt(e,t)}function o3S(){Sxs.restoreDefaultPrompts()}var u3S={prompt:Sxs,ui:{BottomBar:Bca,Prompt:Jmn},createPromptModule:xsp,registerPrompt:a3S,restoreDefaultPrompts:o3S,Separator:Bie},Hmo=u3S;var Hcp=li(Isp()),x6S="4.2.1",b5t;(function(e){e.AnonymousId="anonymous_id",e.DistinctId="distinct_id",e.Props="props",e.FeatureFlags="feature_flags",e.FeatureFlagPayloads="feature_flag_payloads",e.OverrideFeatureFlags="override_feature_flags",e.Queue="queue",e.OptedOut="opted_out",e.SessionId="session_id",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"})(b5t||(b5t={}));function I6S(e,t){if(!e)throw new Error(t)}function z6S(e){return e?.replace(/\/+$/,"")}async function R6S(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 N6S(){return new Date().getTime()}function zcp(){return new Date().toISOString()}function $cp(e,t){let r=setTimeout(e,t);return r?.unref&&r?.unref(),r}var $ca=String.fromCharCode,Rcp="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",aPo={};function F6S(e,t){if(!aPo[e]){aPo[e]={};for(let r=0;r<e.length;r++)aPo[e][e.charAt(r)]=r}return aPo[e][t]}var Gca={compressToBase64:function(e){if(e==null)return"";let t=Gca._compress(e,6,function(r){return Rcp.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:Gca._decompress(e.length,32,function(t){return F6S(Rcp,e.charAt(t))})},compress:function(e){return Gca._compress(e,16,function(t){return $ca(t)})},_compress:function(e,t,r){if(e==null)return"";let i={},n={},a=[],u,l,d="",s="",o="",c=2,b=3,g=2,O=0,m=0,w;for(w=0;w<e.length;w+=1)if(d=e.charAt(w),Object.prototype.hasOwnProperty.call(i,d)||(i[d]=b++,n[d]=!0),s=o+d,Object.prototype.hasOwnProperty.call(i,s))o=s;else{if(Object.prototype.hasOwnProperty.call(n,o)){if(o.charCodeAt(0)<256){for(u=0;u<g;u++)O=O<<1,m==t-1?(m=0,a.push(r(O)),O=0):m++;for(l=o.charCodeAt(0),u=0;u<8;u++)O=O<<1|l&1,m==t-1?(m=0,a.push(r(O)),O=0):m++,l=l>>1}else{for(l=1,u=0;u<g;u++)O=O<<1|l,m==t-1?(m=0,a.push(r(O)),O=0):m++,l=0;for(l=o.charCodeAt(0),u=0;u<16;u++)O=O<<1|l&1,m==t-1?(m=0,a.push(r(O)),O=0):m++,l=l>>1}c--,c==0&&(c=Math.pow(2,g),g++),delete n[o]}else for(l=i[o],u=0;u<g;u++)O=O<<1|l&1,m==t-1?(m=0,a.push(r(O)),O=0):m++,l=l>>1;c--,c==0&&(c=Math.pow(2,g),g++),i[s]=b++,o=String(d)}if(o!==""){if(Object.prototype.hasOwnProperty.call(n,o)){if(o.charCodeAt(0)<256){for(u=0;u<g;u++)O=O<<1,m==t-1?(m=0,a.push(r(O)),O=0):m++;for(l=o.charCodeAt(0),u=0;u<8;u++)O=O<<1|l&1,m==t-1?(m=0,a.push(r(O)),O=0):m++,l=l>>1}else{for(l=1,u=0;u<g;u++)O=O<<1|l,m==t-1?(m=0,a.push(r(O)),O=0):m++,l=0;for(l=o.charCodeAt(0),u=0;u<16;u++)O=O<<1|l&1,m==t-1?(m=0,a.push(r(O)),O=0):m++,l=l>>1}c--,c==0&&(c=Math.pow(2,g),g++),delete n[o]}else for(l=i[o],u=0;u<g;u++)O=O<<1|l&1,m==t-1?(m=0,a.push(r(O)),O=0):m++,l=l>>1;c--,c==0&&(c=Math.pow(2,g),g++)}for(l=2,u=0;u<g;u++)O=O<<1|l&1,m==t-1?(m=0,a.push(r(O)),O=0):m++,l=l>>1;for(;;)if(O=O<<1,m==t-1){a.push(r(O));break}else m++;return a.join("")},decompress:function(e){return e==null?"":e==""?null:Gca._decompress(e.length,32768,function(t){return e.charCodeAt(t)})},_decompress:function(e,t,r){let i=[],n=[],a={val:r(0),position:t,index:1},u=4,l=4,d=3,s="",o,c,b,g,O,m,w;for(o=0;o<3;o+=1)i[o]=o;for(b=0,O=Math.pow(2,2),m=1;m!=O;)g=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),b|=(g>0?1:0)*m,m<<=1;switch(b){case 0:for(b=0,O=Math.pow(2,8),m=1;m!=O;)g=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),b|=(g>0?1:0)*m,m<<=1;w=$ca(b);break;case 1:for(b=0,O=Math.pow(2,16),m=1;m!=O;)g=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),b|=(g>0?1:0)*m,m<<=1;w=$ca(b);break;case 2:return""}for(i[3]=w,c=w,n.push(w);;){if(a.index>e)return"";for(b=0,O=Math.pow(2,d),m=1;m!=O;)g=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),b|=(g>0?1:0)*m,m<<=1;switch(w=b){case 0:for(b=0,O=Math.pow(2,8),m=1;m!=O;)g=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),b|=(g>0?1:0)*m,m<<=1;i[l++]=$ca(b),w=l-1,u--;break;case 1:for(b=0,O=Math.pow(2,16),m=1;m!=O;)g=a.val&a.position,a.position>>=1,a.position==0&&(a.position=t,a.val=r(a.index++)),b|=(g>0?1:0)*m,m<<=1;i[l++]=$ca(b),w=l-1,u--;break;case 2:return n.join("")}if(u==0&&(u=Math.pow(2,d),d++),i[w])s=i[w];else if(w===l)s=c+c.charAt(0);else return null;n.push(s),i[l++]=c+s.charAt(0),u--,c=s,u==0&&(u=Math.pow(2,d),d++)}}},cIs=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)}};var oPo="0123456789abcdef",uPo=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+=oPo.charAt(this.bytes[r]>>>4),t+=oPo.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+=oPo.charAt(this.bytes[r]>>>4),t+=oPo.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}},lIs=class{constructor(t){this.timestamp=0,this.counter=0,this.random=t??L6S()}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 uPo.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,uPo.ofInner(t)}},L6S=()=>({nextUint32:()=>Math.trunc(Math.random()*65536)*65536+Math.trunc(Math.random()*65536)}),Ncp,Fcp=()=>U6S().toString(),U6S=()=>(Ncp||(Ncp=new lIs)).generate(),sPo=class extends Error{constructor(t){super("HTTP error while fetching PostHog: "+t.status),this.response=t,this.name="PostHogFetchHttpError"}},Qca=class extends Error{constructor(t){super("Network error while fetching PostHog",t instanceof Error?{cause:t}:{}),this.error=t,this.name="PostHogFetchNetworkError"}};function Lcp(e){return typeof e=="object"&&(e instanceof sPo||e instanceof Qca)}var fIs=class{constructor(t,r){this.flushPromise=null,this.disableGeoip=!0,this.historicalMigration=!1,this.disabled=!1,this.defaultOptIn=!0,this.pendingPromises={},this._events=new cIs,this._isInitialized=!1,I6S(t,"You must pass your PostHog project's api key."),this.apiKey=t,this.host=z6S(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.defaultOptIn=r?.defaultOptIn??!0,this._retryOptions={retryCount:r?.fetchRetryCount??3,retryDelay:r?.fetchRetryDelay??3e3,retryCheck:Lcp},this.requestTimeout=r?.requestTimeout??1e4,this.featureFlagsRequestTimeoutMs=r?.featureFlagsRequestTimeoutMs??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(b5t.OptedOut)??!this.defaultOptIn}async optIn(){this.wrap(()=>{this.setPersistedProperty(b5t.OptedOut,!1)})}async optOut(){this.wrap(()=>{this.setPersistedProperty(b5t.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}buildPayload(t){return{distinct_id:t.distinct_id,event:t.event,properties:{...t.properties||{},...this.getCommonEventProperties()}}}addPendingPromise(t){let r=Fcp();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)})}captureStateless(t,r,i,n){this.wrap(()=>{let a=this.buildPayload({distinct_id:t,event:r,properties:i});this.enqueue("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)})}groupIdentifyStateless(t,r,i,n,a,u){this.wrap(()=>{let l=this.buildPayload({distinct_id:a||`$${t}_${r}`,event:"$groupidentify",properties:{$group_type:t,$group_key:r,$group_set:i||{},...u||{}}});this.enqueue("capture",l,n)})}async getDecide(t,r={},i={},n={},a={}){await this._initPromise;let u=`${this.host}/decide/?v=3`,l={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.fetchWithRetry(u,l,{retryCount:0},this.featureFlagsRequestTimeoutMs).then(d=>d.json()).catch(d=>{this._events.emit("error",d)})}async getFeatureFlagStateless(t,r,i={},n={},a={},u){await this._initPromise;let l=await this.getFeatureFlagsStateless(r,i,n,a,u);if(!l)return;let d=l[t];return d===void 0&&(d=!1),d}async getFeatureFlagPayloadStateless(t,r,i={},n={},a={},u){await this._initPromise;let l=await this.getFeatureFlagPayloadsStateless(r,i,n,a,u);if(!l)return;let d=l[t];return d===void 0?null:d}async getFeatureFlagPayloadsStateless(t,r={},i={},n={},a){return await this._initPromise,(await this.getFeatureFlagsAndPayloadsStateless(t,r,i,n,a)).payloads}_parsePayload(t){try{return JSON.parse(t)}catch{return t}}async getFeatureFlagsStateless(t,r={},i={},n={},a){return await this._initPromise,(await this.getFeatureFlagsAndPayloadsStateless(t,r,i,n,a)).flags}async getFeatureFlagsAndPayloadsStateless(t,r={},i={},n={},a){await this._initPromise;let u={};(a??this.disableGeoip)&&(u.geoip_disable=!0);let l=await this.getDecide(t,r,i,n,u),d=l?.featureFlags,s=l?.featureFlagPayloads,o=s;return s&&(o=Object.fromEntries(Object.entries(s).map(([c,b])=>[c,this._parsePayload(b)]))),{flags:d,payloads:o}}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={...r,type:t,library:this.getLibraryId(),library_version:this.getLibraryVersion(),timestamp:i?.timestamp?i?.timestamp:zcp(),uuid:i?.uuid?i.uuid:Fcp()};(i?.disableGeoip??this.disableGeoip)&&(n.properties||(n.properties={}),n.properties.$geoip_disable=!0),n.distinctId&&(n.distinct_id=n.distinctId,delete n.distinctId);let u=this.getPersistedProperty(b5t.Queue)||[];u.length>=this.maxQueueSize&&(u.shift(),this.logMsgIfDebug(()=>console.info("Queue is full, the oldest event is dropped."))),u.push({message:n}),this.setPersistedProperty(b5t.Queue,u),this._events.emit(t,n),u.length>=this.flushAt&&this.flushBackground(),this.flushInterval&&!this._flushTimer&&(this._flushTimer=$cp(()=>this.flushBackground(),this.flushInterval))})}clearFlushTimer(){this._flushTimer&&(clearTimeout(this._flushTimer),this._flushTimer=void 0)}flushBackground(){this.flush().catch(()=>{})}async flush(){return this.flushPromise||(this.flushPromise=this._flush().finally(()=>{this.flushPromise=null}),this.addPendingPromise(this.flushPromise)),this.flushPromise}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(b5t.Queue)||[];if(!t.length)return[];let r=t.slice(0,this.maxBatchSize),i=r.map(s=>s.message),n=()=>{let s=this.getPersistedProperty(b5t.Queue)||[];this.setPersistedProperty(b5t.Queue,s.slice(r.length))},a={api_key:this.apiKey,batch:i,sent_at:zcp()};this.historicalMigration&&(a.historical_migration=!0);let u=JSON.stringify(a),l=this.captureMode==="form"?`${this.host}/e/?ip=1&_=${N6S()}&v=${this.getLibraryVersion()}`:`${this.host}/batch/`,d=this.captureMode==="form"?{method:"POST",mode:"no-cors",credentials:"omit",headers:{...this.getCustomHeaders(),"Content-Type":"application/x-www-form-urlencoded"},body:`data=${encodeURIComponent(Gca.compressToBase64(u))}&compression=lz64`}:{method:"POST",headers:{...this.getCustomHeaders(),"Content-Type":"application/json"},body:u};try{await this.fetchWithRetry(l,d)}catch(s){throw s instanceof Qca||n(),this._events.emit("error",s),s}return n(),this._events.emit("flush",i),i}async fetchWithRetry(t,r,i,n){var a;return(a=AbortSignal).timeout??(a.timeout=function(l){let d=new AbortController;return setTimeout(()=>d.abort(),l),d.signal}),await R6S(async()=>{let u=null;try{u=await this.fetch(t,{signal:AbortSignal.timeout(n??this.requestTimeout),...r})}catch(d){throw new Qca(d)}if(!(r.mode==="no-cors")&&(u.status<200||u.status>=400))throw new sPo(u);return u},{...this._retryOptions,...i})}async shutdown(t=3e4){await this._initPromise,this.clearFlushTimer();try{await Promise.all(Object.values(this.pendingPromises));let r=Date.now()+t;for(;(this.getPersistedProperty(b5t.Queue)||[]).length!==0;){await this.flush();let n=Date.now();if(r<n)break}}catch(r){if(!Lcp(r))throw r;this.logMsgIfDebug(()=>console.error("Error while shutting down PostHog",r))}}},dIs=class{constructor(){this._memoryStorage={}}getProperty(t){return this._memoryStorage[t]}setProperty(t,r){this._memoryStorage[t]=r!==null?r:void 0}},pIs=typeof fetch<"u"?fetch:typeof global.fetch<"u"?global.fetch:void 0;if(!pIs){let e=Icp();pIs=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 Gcp=pIs,V6S=1152921504606847e3,W6S=["is_not"],cPo=class e extends Error{constructor(t){super(),Error.captureStackTrace(this,this.constructor),this.name="ClientError",this.message=t,Object.setPrototypeOf(this,e.prototype)}},I2=class e extends Error{constructor(t){super(t),this.name=this.constructor.name,Error.captureStackTrace(this,this.constructor),Object.setPrototypeOf(this,e.prototype)}},_Is=class{constructor({pollingInterval:t,personalApiKey:r,projectApiKey:i,timeout:n,host:a,customHeaders:u,...l}){this.debugMode=!1,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=l.fetch||Gcp,this.onError=l.onError,this.customHeaders=u,this.loadFeatureFlags()}debug(t=!0){this.debugMode=t}logMsgIfDebug(t){this.debugMode&&t()}async getFeatureFlag(t,r,i={},n={},a={}){await this.loadFeatureFlags();let u,l;if(!this.loadedSuccessfullyOnce)return u;for(let d of this.featureFlags)if(t===d.key){l=d;break}if(l!==void 0)try{u=this.computeFlagLocally(l,r,i,n,a),this.logMsgIfDebug(()=>console.debug(`Successfully computed flag locally: ${t} -> ${u}`))}catch(d){d instanceof I2?this.logMsgIfDebug(()=>console.debug(`InconclusiveMatchError when computing flag locally: ${t}: ${d}`)):d instanceof Error&&this.onError?.(new Error(`Error computing flag locally: ${t}: ${d}`))}return u}async computeFeatureFlagPayloadLocally(t,r){await this.loadFeatureFlags();let i;if(this.loadedSuccessfullyOnce){if(typeof r=="boolean"?i=this.featureFlagsByKey?.[t]?.filters?.payloads?.[r.toString()]:typeof r=="string"&&(i=this.featureFlagsByKey?.[t]?.filters?.payloads?.[r]),i==null)return null;try{return JSON.parse(i)}catch{return i}}}async getAllFlagsAndPayloads(t,r={},i={},n={}){await this.loadFeatureFlags();let a={},u={},l=this.featureFlags.length==0;return this.featureFlags.map(async d=>{try{let s=this.computeFlagLocally(d,t,r,i,n);a[d.key]=s;let o=await this.computeFeatureFlagPayloadLocally(d.key,s);o&&(u[d.key]=o)}catch(s){s instanceof I2||s instanceof Error&&this.onError?.(new Error(`Error computing flag locally: ${d.key}: ${s}`)),l=!0}}),{response:a,payloads:u,fallbackToDecide:l}}computeFlagLocally(t,r,i={},n={},a={}){if(t.ensure_experience_continuity)throw new I2("Flag has experience continuity enabled");if(!t.active)return!1;let l=(t.filters||{}).aggregation_group_type_index;if(l!=null){let d=this.groupTypeMapping[String(l)];if(!d)throw this.logMsgIfDebug(()=>console.warn(`[FEATURE FLAGS] Unknown group type index ${l} for feature flag ${t.key}`)),new I2("Flag has unknown group type index");if(!(d in i))return this.logMsgIfDebug(()=>console.warn(`[FEATURE FLAGS] Can't compute group feature flag: ${t.key} without group names passed in`)),!1;let s=a[d];return this.matchFeatureFlagProperties(t,i[d],s)}else return this.matchFeatureFlagProperties(t,r,n)}matchFeatureFlagProperties(t,r,i){let n=t.filters||{},a=n.groups||[],u=!1,l,d=[...a].sort((s,o)=>{let c=!!s.variant,b=!!o.variant;return c&&b?0:c?-1:b?1:0});for(let s of d)try{if(this.isConditionMatch(t,r,s,i)){let o=s.variant,c=n.multivariate?.variants||[];o&&c.some(b=>b.key===o)?l=o:l=this.getMatchingVariant(t,r)||!0;break}}catch(o){if(o instanceof I2)u=!0;else throw o}if(l!==void 0)return l;if(u)throw new I2("Can't determine if feature flag is enabled or not with given properties");return!1}isConditionMatch(t,r,i,n){let a=i.rollout_percentage,u=l=>{this.logMsgIfDebug(()=>console.warn(l))};if((i.properties||[]).length>0){for(let l of i.properties){let d=l.type,s=!1;if(d==="cohort"?s=Jcp(l,n,this.cohorts,this.debugMode):s=Qcp(l,n,u),!s)return!1}if(a==null)return!0}return!(a!=null&&Ucp(t.key,r)>a/100)}getMatchingVariant(t,r){let i=Ucp(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(l=>{n=i+l.rollout_percentage/100,r.push({valueMin:i,valueMax:n,key:l.key}),i=n}),r}async loadFeatureFlags(t=!1){(!this.loadedSuccessfullyOnce||t)&&await this._loadFeatureFlags()}async _loadFeatureFlags(){this.poller&&(clearTimeout(this.poller),this.poller=void 0),this.poller=setTimeout(()=>this._loadFeatureFlags(),this.pollingInterval);try{let t=await this._requestFeatureFlagDefinitions();if(t&&t.status===401)throw new cPo("Your personalApiKey is invalid. Are you sure you're not using your Project API key? More information: https://posthog.com/docs/api/overview");if(t&&t.status!==200)return;let r=await t.json();"flags"in r||this.onError?.(new Error(`Invalid response when getting feature flags: ${JSON.stringify(r)}`)),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}catch(t){t instanceof cPo&&this.onError?.(t)}}async _requestFeatureFlagDefinitions(){let t=`${this.host}/api/feature_flag/local_evaluation?token=${this.projectApiKey}&send_cohorts`,r={method:"GET",headers:{...this.customHeaders,"Content-Type":"application/json",Authorization:`Bearer ${this.personalApiKey}`}},i=null;if(this.timeout&&typeof this.timeout=="number"){let n=new AbortController;i=$cp(()=>{n.abort()},this.timeout),r.signal=n.signal}try{return await this.fetch(t,r)}finally{clearTimeout(i)}}stopPoller(){clearTimeout(this.poller)}};function Ucp(e,t,r=""){let i=(0,Hcp.createHash)();return i.update(`${e}.${t}${r}`),parseInt(i.digest("hex").slice(0,15),16)/V6S}function Qcp(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 I2("Operator is_not_set is not supported")}else throw new I2(`Property ${i} not found in propertyValues`);let u=t[i];if(u==null&&!W6S.includes(a))return r&&r(`Property ${i} cannot have a value of null/undefined with the ${a} operator`),!1;function l(s,o){return Array.isArray(s)?s.map(c=>String(c).toLowerCase()).includes(String(o).toLowerCase()):String(s).toLowerCase()===String(o).toLowerCase()}function d(s,o,c){if(c==="gt")return s>o;if(c==="gte")return s>=o;if(c==="lt")return s<o;if(c==="lte")return s<=o;throw new Error(`Invalid operator: ${c}`)}switch(a){case"exact":return l(n,u);case"is_not":return!l(n,u);case"is_set":return i in t;case"icontains":return String(u).toLowerCase().includes(String(n).toLowerCase());case"not_icontains":return!String(u).toLowerCase().includes(String(n).toLowerCase());case"regex":return Vcp(String(n))&&String(u).match(String(n))!==null;case"not_regex":return Vcp(String(n))&&String(u).match(String(n))===null;case"gt":case"gte":case"lt":case"lte":{let s=typeof n=="number"?n:null;if(typeof n=="string")try{s=parseFloat(n)}catch{}return s!=null&&u!=null?typeof u=="string"?d(u,String(n),a):d(u,s,a):d(String(u),String(n),a)}case"is_date_after":case"is_date_before":{let s=H6S(String(n));if(s==null&&(s=Wcp(n)),s==null)throw new I2(`Invalid date: ${n}`);let o=Wcp(u);return["is_date_before"].includes(a)?o<s:o>s}default:throw new I2(`Unknown operator: ${a}`)}}function Jcp(e,t,r,i=!1){let n=String(e.value);if(!(n in r))throw new I2("can't match cohort without a given cohort property value");let a=r[n];return Kcp(a,t,r,i)}function Kcp(e,t,r,i=!1){if(!e)return!0;let n=e.type,a=e.values;if(!a||a.length===0)return!0;let u=!1;if("values"in a[0]){for(let l of a)try{let d=Kcp(l,t,r,i);if(n==="AND"){if(!d)return!1}else if(d)return!0}catch(d){if(d instanceof I2)i&&console.debug(`Failed to compute property ${l} locally: ${d}`),u=!0;else throw d}if(u)throw new I2("Can't match cohort without a given cohort property value");return n==="AND"}else{for(let l of a)try{let d;l.type==="cohort"?d=Jcp(l,t,r,i):d=Qcp(l,t);let s=l.negation||!1;if(n==="AND"){if(!d&&!s||d&&s)return!1}else if(d&&!s||!d&&s)return!0}catch(d){if(d instanceof I2)i&&console.debug(`Failed to compute property ${l} locally: ${d}`),u=!0;else throw d}if(u)throw new I2("can't match cohort without a given cohort property value");return n==="AND"}}function Vcp(e){try{return new RegExp(e),!0}catch{return!1}}function Wcp(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 I2(`${e} is in an invalid date format`)}else throw new I2(`The date provided ${e} must be a string, number, or date object`)}function H6S(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 $6S=30*1e3,G6S=50*1e3,tPn=class extends fIs{constructor(t,r={}){super(t,r),this._memoryStorage=new dIs,this.options=r,r.personalApiKey&&(this.featureFlagsPoller=new _Is({pollingInterval:typeof r.featureFlagsPollingInterval=="number"?r.featureFlagsPollingInterval:$6S,personalApiKey:r.personalApiKey,projectApiKey:t,timeout:r.requestTimeout??1e4,host:this.host,fetch:r.fetch,onError:i=>{this._events.emit("error",i)},customHeaders:this.getCustomHeaders()})),this.distinctIdHasSentFlagCalls={},this.maxCacheSize=r.maxCacheSize||G6S}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):Gcp(t,r)}getLibraryId(){return"posthog-node"}getLibraryVersion(){return x6S}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({distinctId:t,event:r,properties:i,groups:n,sendFeatureFlags:a,timestamp:u,disableGeoip:l,uuid:d}){let s=b=>{super.captureStateless(t,r,b,{timestamp:u,disableGeoip:l,uuid:d})},o=(b,g,O)=>super.getFeatureFlagsStateless(b,g,void 0,void 0,O),c=Promise.resolve().then(async()=>{if(a)return await o(t,n,l);if((this.featureFlagsPoller?.featureFlags?.length||0)>0){let b={};for(let[g,O]of Object.entries(n||{}))b[g]=String(O);return await this.getAllFlags(t,{groups:b,disableGeoip:l,onlyEvaluateLocally:!0})}return{}}).then(b=>{let g={};if(b)for(let[m,w]of Object.entries(b))g[`$feature/${m}`]=w;let O=Object.keys(b||{}).filter(m=>b?.[m]!==!1);return O.length>0&&(g.$active_feature_flags=O),g}).catch(()=>({})).then(b=>{s({...b,...i,$groups:n})});this.addPendingPromise(c)}identify({distinctId:t,properties:r,disableGeoip:i}){let n=r?.$set||r;super.identifyStateless(t,{$set:n},{disableGeoip:i})}alias(t){super.aliasStateless(t.alias,t.distinctId,void 0,{disableGeoip:t.disableGeoip})}async getFeatureFlag(t,r,i){let{groups:n,disableGeoip:a}=i||{},{onlyEvaluateLocally:u,sendFeatureFlagEvents:l,personProperties:d,groupProperties:s}=i||{},o=this.addLocalPersonAndGroupProperties(r,n,d,s);d=o.allPersonProperties,s=o.allGroupProperties,u==null&&(u=!1),l==null&&(l=!0);let c=await this.featureFlagsPoller?.getFeatureFlag(t,r,n,d,s),b=c!==void 0;!b&&!u&&(c=await super.getFeatureFlagStateless(t,r,n,d,s,a));let g=`${t}_${c}`;return l&&(!(r in this.distinctIdHasSentFlagCalls)||!this.distinctIdHasSentFlagCalls[r].includes(g))&&(Object.keys(this.distinctIdHasSentFlagCalls).length>=this.maxCacheSize&&(this.distinctIdHasSentFlagCalls={}),Array.isArray(this.distinctIdHasSentFlagCalls[r])?this.distinctIdHasSentFlagCalls[r].push(g):this.distinctIdHasSentFlagCalls[r]=[g],this.capture({distinctId:r,event:"$feature_flag_called",properties:{$feature_flag:t,$feature_flag_response:c,locally_evaluated:b,[`$feature/${t}`]:c},groups:n,disableGeoip:a})),c}async getFeatureFlagPayload(t,r,i,n){let{groups:a,disableGeoip:u}=n||{},{onlyEvaluateLocally:l,sendFeatureFlagEvents:d,personProperties:s,groupProperties:o}=n||{},c=this.addLocalPersonAndGroupProperties(r,a,s,o);s=c.allPersonProperties,o=c.allGroupProperties;let b;return i||(i=await this.getFeatureFlag(t,r,{...n,onlyEvaluateLocally:!0})),i&&(b=await this.featureFlagsPoller?.computeFeatureFlagPayloadLocally(t,i)),l==null&&(l=!1),d==null&&(d=!0),l==null&&(l=!1),!(b!==void 0)&&!l&&(b=await super.getFeatureFlagPayloadStateless(t,r,a,s,o,u)),b}async isFeatureEnabled(t,r,i){let n=await this.getFeatureFlag(t,r,i);if(n!==void 0)return!!n||!1}async getAllFlags(t,r){return(await this.getAllFlagsAndPayloads(t,r)).featureFlags}async getAllFlagsAndPayloads(t,r){let{groups:i,disableGeoip:n}=r||{},{onlyEvaluateLocally:a,personProperties:u,groupProperties:l}=r||{},d=this.addLocalPersonAndGroupProperties(t,i,u,l);u=d.allPersonProperties,l=d.allGroupProperties,a==null&&(a=!1);let s=await this.featureFlagsPoller?.getAllFlagsAndPayloads(t,i,u,l),o={},c={},b=!0;if(s&&(o=s.response,c=s.payloads,b=s.fallbackToDecide),b&&!a){let g=await super.getFeatureFlagsAndPayloadsStateless(t,i,u,l,n);o={...o,...g.flags||{}},c={...c,...g.payloads||{}}}return{featureFlags:o,featureFlagPayloads:c}}groupIdentify({groupType:t,groupKey:r,properties:i,distinctId:n,disableGeoip:a}){super.groupIdentifyStateless(t,r,i,{disableGeoip:a},n)}async reloadFeatureFlags(){await this.featureFlagsPoller?.loadFeatureFlags(!0)}async shutdown(t){return this.featureFlagsPoller?.stopPoller(),super.shutdown(t)}addLocalPersonAndGroupProperties(t,r,i,n){let a={distinct_id:t,...i||{}},u={};if(r)for(let l of Object.keys(r))u[l]={$group_key:r[l],...n?.[l]||{}};return{allPersonProperties:a,allGroupProperties:u}}},hIs=class e{constructor(t,r,i,n){this.posthog=t,this.posthogHost=r,this.organization=i,this.prefix=n,this.name="posthog-node",this.posthogHost=t.options.host??"https://us.i.posthog.com"}setupOnce(t,r){t(i=>{if(i.exception?.values===void 0||i.exception.values.length===0)return i;i.tags||(i.tags={});let n=r(),a=i.tags[e.POSTHOG_ID_TAG];if(a===void 0)return i;i.tags["PostHog Person URL"]=new URL(`/person/${a}`,this.posthogHost).toString();let u={$exception_message:i.exception.values[0]?.value,$exception_type:i.exception.values[0]?.type,$exception_personURL:i.tags["PostHog Person URL"],$sentry_event_id:i.event_id,$sentry_exception:i.exception,$sentry_exception_message:i.exception.values[0]?.value,$sentry_exception_type:i.exception.values[0]?.type,$sentry_tags:i.tags},l=n.getClient()?.getDsn()?.projectId;return this.organization!==void 0&&l!==void 0&&i.event_id!==void 0&&(u.$sentry_url=`${this.prefix??"https://sentry.io/organizations"}/${this.organization}/issues/?project=${l}&query=${i.event_id}`),this.posthog.capture({event:"$exception",distinctId:a,properties:u}),i})}};hIs.POSTHOG_ID_TAG="posthog_distinct_id";var lPo=class{posthog;constructor({posthogApiKey:t}){this.posthog=new tPn(t)}async identify(){}async sendEvent(t){t.orgId!=null&&this.posthog.capture({distinctId:t.orgId,event:"CLI",properties:{...t,...t.properties,version:"0.58.0-rc1",usingAccessToken:!0}})}async flush(){await this.posthog.flush()}};var Jca=class{async sendEvent(){}async identify(){}async flush(){}};var rPn=require("fs/promises"),kcp=require("os"),elp=require("path");var Ycp=li(require("crypto")),dPo=new Uint8Array(256),fPo=dPo.length;function yIs(){return fPo>dPo.length-16&&(Ycp.default.randomFillSync(dPo),fPo=0),dPo.slice(fPo,fPo+=16)}var bV=[];for(let e=0;e<256;++e)bV.push((e+256).toString(16).slice(1));function Xcp(e,t=0){return bV[e[t+0]]+bV[e[t+1]]+bV[e[t+2]]+bV[e[t+3]]+"-"+bV[e[t+4]]+bV[e[t+5]]+"-"+bV[e[t+6]]+bV[e[t+7]]+"-"+bV[e[t+8]]+bV[e[t+9]]+"-"+bV[e[t+10]]+bV[e[t+11]]+bV[e[t+12]]+bV[e[t+13]]+bV[e[t+14]]+bV[e[t+15]]}var Zcp=li(require("crypto")),vIs={randomUUID:Zcp.default.randomUUID};function Q6S(e,t,r){if(vIs.randomUUID&&!t&&!e)return vIs.randomUUID();e=e||{};let i=e.random||(e.rng||yIs)();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 Xcp(i)}var Nie=Q6S;var J6S="id",K6S=".fern",Kca=class{posthog;userId;constructor({token:t,posthogApiKey:r}){this.posthog=new tPn(r),this.userId=t==null?void 0:SEs(t)}async identify(){this.userId!=null&&this.posthog.alias({distinctId:this.userId,alias:await this.getPersistedDistinctId()})}async sendEvent(t){this.posthog.capture({distinctId:this.userId??await this.getPersistedDistinctId(),event:"CLI",properties:{version:"0.58.0-rc1",...t,...t.properties}})}async flush(){await this.posthog.flush()}persistedDistinctId;async getPersistedDistinctId(){if(this.persistedDistinctId==null){let t=Wu(Ul.of((0,kcp.homedir)()),eo.of(K6S),eo.of(J6S));await Cf(t)||(await(0,rPn.mkdir)((0,elp.dirname)(t),{recursive:!0}),await(0,rPn.writeFile)(t,Nie())),this.persistedDistinctId=(await(0,rPn.readFile)(t)).toString()}return this.persistedDistinctId}};var bIs;async function iPn(){return bIs==null&&(bIs=await Y6S()),bIs}async function Y6S(){try{let e="phc_yQgAEdJJkVpI24NdSRID2mor1x1leRpDoC9yZ9mfXal",t=process.env.FERN_DISABLE_TELEMETRY==="true";if(e==null||t)return new Jca;let r=await _yo();return r!=null?new Kca({token:r,posthogApiKey:e}):await pyo()!=null?new lPo({posthogApiKey:e}):new Kca({token:void 0,posthogApiKey:e})}catch{return new Jca}}function Yca(e,t){return function(){return e.apply(t,arguments)}}var{toString:X6S}=Object.prototype,{getPrototypeOf:OIs}=Object,_Po=(e=>t=>{let r=X6S.call(t);return e[r]||(e[r]=r.slice(8,-1).toLowerCase())})(Object.create(null)),g5t=e=>(e=e.toLowerCase(),t=>_Po(t)===e),hPo=e=>t=>typeof t===e,{isArray:nPn}=Array,Xca=hPo("undefined");function Z6S(e){return e!==null&&!Xca(e)&&e.constructor!==null&&!Xca(e.constructor)&&XSe(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}var rlp=g5t("ArrayBuffer");function k6S(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&rlp(e.buffer),t}var e2S=hPo("string"),XSe=hPo("function"),ilp=hPo("number"),yPo=e=>e!==null&&typeof e=="object",t2S=e=>e===!0||e===!1,pPo=e=>{if(_Po(e)!=="object")return!1;let t=OIs(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)},r2S=g5t("Date"),i2S=g5t("File"),n2S=g5t("Blob"),a2S=g5t("FileList"),o2S=e=>yPo(e)&&XSe(e.pipe),u2S=e=>{let t;return e&&(typeof FormData=="function"&&e instanceof FormData||XSe(e.append)&&((t=_Po(e))==="formdata"||t==="object"&&XSe(e.toString)&&e.toString()==="[object FormData]"))},s2S=g5t("URLSearchParams"),[c2S,l2S,f2S,d2S]=["ReadableStream","Request","Response","Headers"].map(g5t),p2S=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function Zca(e,t,{allOwnKeys:r=!1}={}){if(e===null||typeof e>"u")return;let i,n;if(typeof e!="object"&&(e=[e]),nPn(e))for(i=0,n=e.length;i<n;i++)t.call(null,e[i],i,e);else{let a=r?Object.getOwnPropertyNames(e):Object.keys(e),u=a.length,l;for(i=0;i<u;i++)l=a[i],t.call(null,e[l],l,e)}}function nlp(e,t){t=t.toLowerCase();let r=Object.keys(e),i=r.length,n;for(;i-- >0;)if(n=r[i],t===n.toLowerCase())return n;return null}var nzi=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,alp=e=>!Xca(e)&&e!==nzi;function gIs(){let{caseless:e}=alp(this)&&this||{},t={},r=(i,n)=>{let a=e&&nlp(t,n)||n;pPo(t[a])&&pPo(i)?t[a]=gIs(t[a],i):pPo(i)?t[a]=gIs({},i):nPn(i)?t[a]=i.slice():t[a]=i};for(let i=0,n=arguments.length;i<n;i++)arguments[i]&&Zca(arguments[i],r);return t}var _2S=(e,t,r,{allOwnKeys:i}={})=>(Zca(t,(n,a)=>{r&&XSe(n)?e[a]=Yca(n,r):e[a]=n},{allOwnKeys:i}),e),h2S=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),y2S=(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)},v2S=(e,t,r,i)=>{let n,a,u,l={};if(t=t||{},e==null)return t;do{for(n=Object.getOwnPropertyNames(e),a=n.length;a-- >0;)u=n[a],(!i||i(u,e,t))&&!l[u]&&(t[u]=e[u],l[u]=!0);e=r!==!1&&OIs(e)}while(e&&(!r||r(e,t))&&e!==Object.prototype);return t},b2S=(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},g2S=e=>{if(!e)return null;if(nPn(e))return e;let t=e.length;if(!ilp(t))return null;let r=new Array(t);for(;t-- >0;)r[t]=e[t];return r},O2S=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&OIs(Uint8Array)),m2S=(e,t)=>{let i=(e&&e[Symbol.iterator]).call(e),n;for(;(n=i.next())&&!n.done;){let a=n.value;t.call(e,a[0],a[1])}},P2S=(e,t)=>{let r,i=[];for(;(r=e.exec(t))!==null;)i.push(r);return i},j2S=g5t("HTMLFormElement"),w2S=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(r,i,n){return i.toUpperCase()+n}),tlp=(({hasOwnProperty:e})=>(t,r)=>e.call(t,r))(Object.prototype),S2S=g5t("RegExp"),olp=(e,t)=>{let r=Object.getOwnPropertyDescriptors(e),i={};Zca(r,(n,a)=>{let u;(u=t(n,a,e))!==!1&&(i[a]=u||n)}),Object.defineProperties(e,i)},D2S=e=>{olp(e,(t,r)=>{if(XSe(e)&&["arguments","caller","callee"].indexOf(r)!==-1)return!1;let i=e[r];if(XSe(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+"'")})}})},E2S=(e,t)=>{let r={},i=n=>{n.forEach(a=>{r[a]=!0})};return nPn(e)?i(e):i(String(e).split(t)),r},M2S=()=>{},A2S=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t;function q2S(e){return!!(e&&XSe(e.append)&&e[Symbol.toStringTag]==="FormData"&&e[Symbol.iterator])}var T2S=e=>{let t=new Array(10),r=(i,n)=>{if(yPo(i)){if(t.indexOf(i)>=0)return;if(!("toJSON"in i)){t[n]=i;let a=nPn(i)?[]:{};return Zca(i,(u,l)=>{let d=r(u,n+1);!Xca(d)&&(a[l]=d)}),t[n]=void 0,a}}return i};return r(e,0)},C2S=g5t("AsyncFunction"),B2S=e=>e&&(yPo(e)||XSe(e))&&XSe(e.then)&&XSe(e.catch),ulp=((e,t)=>e?setImmediate:t?((r,i)=>(nzi.addEventListener("message",({source:n,data:a})=>{n===nzi&&a===r&&i.length&&i.shift()()},!1),n=>{i.push(n),nzi.postMessage(r,"*")}))(`axios@${Math.random()}`,[]):r=>setTimeout(r))(typeof setImmediate=="function",XSe(nzi.postMessage)),x2S=typeof queueMicrotask<"u"?queueMicrotask.bind(nzi):typeof process<"u"&&process.nextTick||ulp,ds={isArray:nPn,isArrayBuffer:rlp,isBuffer:Z6S,isFormData:u2S,isArrayBufferView:k6S,isString:e2S,isNumber:ilp,isBoolean:t2S,isObject:yPo,isPlainObject:pPo,isReadableStream:c2S,isRequest:l2S,isResponse:f2S,isHeaders:d2S,isUndefined:Xca,isDate:r2S,isFile:i2S,isBlob:n2S,isRegExp:S2S,isFunction:XSe,isStream:o2S,isURLSearchParams:s2S,isTypedArray:O2S,isFileList:a2S,forEach:Zca,merge:gIs,extend:_2S,trim:p2S,stripBOM:h2S,inherits:y2S,toFlatObject:v2S,kindOf:_Po,kindOfTest:g5t,endsWith:b2S,toArray:g2S,forEachEntry:m2S,matchAll:P2S,isHTMLForm:j2S,hasOwnProperty:tlp,hasOwnProp:tlp,reduceDescriptors:olp,freezeMethods:D2S,toObjectSet:E2S,toCamelCase:w2S,noop:M2S,toFiniteNumber:A2S,findKey:nlp,global:nzi,isContextDefined:alp,isSpecCompliantForm:q2S,toJSONObject:T2S,isAsyncFn:C2S,isThenable:B2S,setImmediate:ulp,asap:x2S};function aPn(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)}ds.inherits(aPn,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:ds.toJSONObject(this.config),code:this.code,status:this.status}}});var slp=aPn.prototype,clp={};["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=>{clp[e]={value:e}});Object.defineProperties(aPn,clp);Object.defineProperty(slp,"isAxiosError",{value:!0});aPn.from=(e,t,r,i,n,a)=>{let u=Object.create(slp);return ds.toFlatObject(e,u,function(d){return d!==Error.prototype},l=>l!=="isAxiosError"),aPn.call(u,e.message,t,r,i,n),u.cause=e,u.name=e.name,a&&Object.assign(u,a),u};var Dp=aPn;var llp=li(Mia(),1),vPo=llp.default;function mIs(e){return ds.isPlainObject(e)||ds.isArray(e)}function dlp(e){return ds.endsWith(e,"[]")?e.slice(0,-2):e}function flp(e,t,r){return e?e.concat(t).map(function(n,a){return n=dlp(n),!r&&a?"["+n+"]":n}).join(r?".":""):t}function I2S(e){return ds.isArray(e)&&!e.some(mIs)}var z2S=ds.toFlatObject(ds,{},null,function(t){return/^is[A-Z]/.test(t)});function R2S(e,t,r){if(!ds.isObject(e))throw new TypeError("target must be an object");t=t||new(vPo||FormData),r=ds.toFlatObject(r,{metaTokens:!0,dots:!1,indexes:!1},!1,function(m,w){return!ds.isUndefined(w[m])});let i=r.metaTokens,n=r.visitor||o,a=r.dots,u=r.indexes,d=(r.Blob||typeof Blob<"u"&&Blob)&&ds.isSpecCompliantForm(t);if(!ds.isFunction(n))throw new TypeError("visitor must be a function");function s(O){if(O===null)return"";if(ds.isDate(O))return O.toISOString();if(!d&&ds.isBlob(O))throw new Dp("Blob is not supported. Use a Buffer instead.");return ds.isArrayBuffer(O)||ds.isTypedArray(O)?d&&typeof Blob=="function"?new Blob([O]):Buffer.from(O):O}function o(O,m,w){let E=O;if(O&&!w&&typeof O=="object"){if(ds.endsWith(m,"{}"))m=i?m:m.slice(0,-2),O=JSON.stringify(O);else if(ds.isArray(O)&&I2S(O)||(ds.isFileList(O)||ds.endsWith(m,"[]"))&&(E=ds.toArray(O)))return m=dlp(m),E.forEach(function(q,D){!(ds.isUndefined(q)||q===null)&&t.append(u===!0?flp([m],D,a):u===null?m:m+"[]",s(q))}),!1}return mIs(O)?!0:(t.append(flp(w,m,a),s(O)),!1)}let c=[],b=Object.assign(z2S,{defaultVisitor:o,convertValue:s,isVisitable:mIs});function g(O,m){if(!ds.isUndefined(O)){if(c.indexOf(O)!==-1)throw Error("Circular reference detected in "+m.join("."));c.push(O),ds.forEach(O,function(E,A){(!(ds.isUndefined(E)||E===null)&&n.call(t,E,ds.isString(A)?A.trim():A,m,b))===!0&&g(E,m?m.concat(A):[A])}),c.pop()}}if(!ds.isObject(e))throw new TypeError("data must be an object");return g(e),t}var mfi=R2S;function plp(e){let t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(i){return t[i]})}function _lp(e,t){this._pairs=[],e&&mfi(e,this,t)}var hlp=_lp.prototype;hlp.append=function(t,r){this._pairs.push([t,r])};hlp.toString=function(t){let r=t?function(i){return t.call(this,i,plp)}:plp;return this._pairs.map(function(n){return r(n[0])+"="+r(n[1])},"").join("&")};var ylp=_lp;function N2S(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function azi(e,t,r){if(!t)return e;let i=r&&r.encode||N2S;ds.isFunction(r)&&(r={serialize:r});let n=r&&r.serialize,a;if(n?a=n(t,r):a=ds.isURLSearchParams(t)?t.toString():new ylp(t,r).toString(i),a){let u=e.indexOf("#");u!==-1&&(e=e.slice(0,u)),e+=(e.indexOf("?")===-1?"?":"&")+a}return e}var PIs=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){ds.forEach(this.handlers,function(i){i!==null&&t(i)})}},jIs=PIs;var oPn={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1};var Olp=li(require("crypto"),1);var vlp=li(require("url"),1),blp=vlp.default.URLSearchParams;var wIs="abcdefghijklmnopqrstuvwxyz",glp="0123456789",mlp={DIGIT:glp,ALPHA:wIs,ALPHA_DIGIT:wIs+wIs.toUpperCase()+glp},F2S=(e=16,t=mlp.ALPHA_DIGIT)=>{let r="",{length:i}=t,n=new Uint32Array(e);Olp.default.randomFillSync(n);for(let a=0;a<e;a++)r+=t[n[a]%i];return r},Plp={isNode:!0,classes:{URLSearchParams:blp,FormData:vPo,Blob:typeof Blob<"u"&&Blob||null},ALPHABET:mlp,generateString:F2S,protocols:["http","https","file","data"]};var EIs={};jo(EIs,{hasBrowserEnv:()=>DIs,hasStandardBrowserEnv:()=>L2S,hasStandardBrowserWebWorkerEnv:()=>U2S,navigator:()=>SIs,origin:()=>V2S});var DIs=typeof window<"u"&&typeof document<"u",SIs=typeof navigator=="object"&&navigator||void 0,L2S=DIs&&(!SIs||["ReactNative","NativeScript","NS"].indexOf(SIs.product)<0),U2S=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",V2S=DIs&&window.location.href||"http://localhost";var EM={...EIs,...Plp};function MIs(e,t){return mfi(e,new EM.classes.URLSearchParams,Object.assign({visitor:function(r,i,n,a){return EM.isNode&&ds.isBuffer(r)?(this.append(i,r.toString("base64")),!1):a.defaultVisitor.apply(this,arguments)}},t))}function W2S(e){return ds.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function H2S(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 $2S(e){function t(r,i,n,a){let u=r[a++];if(u==="__proto__")return!0;let l=Number.isFinite(+u),d=a>=r.length;return u=!u&&ds.isArray(n)?n.length:u,d?(ds.hasOwnProp(n,u)?n[u]=[n[u],i]:n[u]=i,!l):((!n[u]||!ds.isObject(n[u]))&&(n[u]=[]),t(r,i,n[u],a)&&ds.isArray(n[u])&&(n[u]=H2S(n[u])),!l)}if(ds.isFormData(e)&&ds.isFunction(e.entries)){let r={};return ds.forEachEntry(e,(i,n)=>{t(W2S(i),n,r,0)}),r}return null}var bPo=$2S;function G2S(e,t,r){if(ds.isString(e))try{return(t||JSON.parse)(e),ds.trim(e)}catch(i){if(i.name!=="SyntaxError")throw i}return(r||JSON.stringify)(e)}var AIs={transitional:oPn,adapter:["xhr","http","fetch"],transformRequest:[function(t,r){let i=r.getContentType()||"",n=i.indexOf("application/json")>-1,a=ds.isObject(t);if(a&&ds.isHTMLForm(t)&&(t=new FormData(t)),ds.isFormData(t))return n?JSON.stringify(bPo(t)):t;if(ds.isArrayBuffer(t)||ds.isBuffer(t)||ds.isStream(t)||ds.isFile(t)||ds.isBlob(t)||ds.isReadableStream(t))return t;if(ds.isArrayBufferView(t))return t.buffer;if(ds.isURLSearchParams(t))return r.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),t.toString();let l;if(a){if(i.indexOf("application/x-www-form-urlencoded")>-1)return MIs(t,this.formSerializer).toString();if((l=ds.isFileList(t))||i.indexOf("multipart/form-data")>-1){let d=this.env&&this.env.FormData;return mfi(l?{"files[]":t}:t,d&&new d,this.formSerializer)}}return a||n?(r.setContentType("application/json",!1),G2S(t)):t}],transformResponse:[function(t){let r=this.transitional||AIs.transitional,i=r&&r.forcedJSONParsing,n=this.responseType==="json";if(ds.isResponse(t)||ds.isReadableStream(t))return t;if(t&&ds.isString(t)&&(i&&!this.responseType||n)){let u=!(r&&r.silentJSONParsing)&&n;try{return JSON.parse(t)}catch(l){if(u)throw l.name==="SyntaxError"?Dp.from(l,Dp.ERR_BAD_RESPONSE,this,null,this.response):l}}return t}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:EM.classes.FormData,Blob:EM.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};ds.forEach(["delete","get","head","post","put","patch"],e=>{AIs.headers[e]={}});var uPn=AIs;var Q2S=ds.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"]),jlp=e=>{let t={},r,i,n;return e&&e.split(`
|
|
1705
1705
|
`).forEach(function(u){n=u.indexOf(":"),r=u.substring(0,n).trim().toLowerCase(),i=u.substring(n+1).trim(),!(!r||t[r]&&Q2S[r])&&(r==="set-cookie"?t[r]?t[r].push(i):t[r]=[i]:t[r]=t[r]?t[r]+", "+i:i)}),t};var wlp=Symbol("internals");function kca(e){return e&&String(e).trim().toLowerCase()}function gPo(e){return e===!1||e==null?e:ds.isArray(e)?e.map(gPo):String(e)}function J2S(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 K2S=e=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim());function qIs(e,t,r,i,n){if(ds.isFunction(i))return i.call(this,t,r);if(n&&(t=r),!!ds.isString(t)){if(ds.isString(i))return t.indexOf(i)!==-1;if(ds.isRegExp(i))return i.test(t)}}function Y2S(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(t,r,i)=>r.toUpperCase()+i)}function X2S(e,t){let r=ds.toCamelCase(" "+t);["get","set","has"].forEach(i=>{Object.defineProperty(e,i+r,{value:function(n,a,u){return this[i].call(this,t,n,a,u)},configurable:!0})})}var sPn=class{constructor(t){t&&this.set(t)}set(t,r,i){let n=this;function a(l,d,s){let o=kca(d);if(!o)throw new Error("header name must be a non-empty string");let c=ds.findKey(n,o);(!c||n[c]===void 0||s===!0||s===void 0&&n[c]!==!1)&&(n[c||d]=gPo(l))}let u=(l,d)=>ds.forEach(l,(s,o)=>a(s,o,d));if(ds.isPlainObject(t)||t instanceof this.constructor)u(t,r);else if(ds.isString(t)&&(t=t.trim())&&!K2S(t))u(jlp(t),r);else if(ds.isHeaders(t))for(let[l,d]of t.entries())a(d,l,i);else t!=null&&a(r,t,i);return this}get(t,r){if(t=kca(t),t){let i=ds.findKey(this,t);if(i){let n=this[i];if(!r)return n;if(r===!0)return J2S(n);if(ds.isFunction(r))return r.call(this,n,i);if(ds.isRegExp(r))return r.exec(n);throw new TypeError("parser must be boolean|regexp|function")}}}has(t,r){if(t=kca(t),t){let i=ds.findKey(this,t);return!!(i&&this[i]!==void 0&&(!r||qIs(this,this[i],i,r)))}return!1}delete(t,r){let i=this,n=!1;function a(u){if(u=kca(u),u){let l=ds.findKey(i,u);l&&(!r||qIs(i,i[l],l,r))&&(delete i[l],n=!0)}}return ds.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||qIs(this,this[a],a,t,!0))&&(delete this[a],n=!0)}return n}normalize(t){let r=this,i={};return ds.forEach(this,(n,a)=>{let u=ds.findKey(i,a);if(u){r[u]=gPo(n),delete r[a];return}let l=t?Y2S(a):String(a).trim();l!==a&&delete r[a],r[l]=gPo(n),i[l]=!0}),this}concat(...t){return this.constructor.concat(this,...t)}toJSON(t){let r=Object.create(null);return ds.forEach(this,(i,n)=>{i!=null&&i!==!1&&(r[n]=t&&ds.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(`
|
|
1706
1706
|
`)}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[wlp]=this[wlp]={accessors:{}}).accessors,n=this.prototype;function a(u){let l=kca(u);i[l]||(X2S(n,u),i[l]=!0)}return ds.isArray(t)?t.forEach(a):a(t),this}};sPn.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]);ds.reduceDescriptors(sPn.prototype,({value:e},t)=>{let r=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(i){this[r]=i}}});ds.freezeMethods(sPn);var yz=sPn;function ela(e,t){let r=this||uPn,i=t||r,n=yz.from(i.headers),a=i.data;return ds.forEach(e,function(l){a=l.call(r,a,n.normalize(),t?t.status:void 0)}),n.normalize(),a}function tla(e){return!!(e&&e.__CANCEL__)}function Slp(e,t,r){Dp.call(this,e??"canceled",Dp.ERR_CANCELED,t,r),this.name="CanceledError"}ds.inherits(Slp,Dp,{__CANCEL__:!0});var ZSe=Slp;function QYt(e,t,r){let i=r.config.validateStatus;!r.status||!i||i(r.status)?e(r):t(new Dp("Request failed with status code "+r.status,[Dp.ERR_BAD_REQUEST,Dp.ERR_BAD_RESPONSE][Math.floor(r.status/100)-4],r.config,r.request,r))}function TIs(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function CIs(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}function ozi(e,t,r){let i=!TIs(t);return e&&i||r==!1?CIs(e,t):t}var Ulp=li(zca(),1),Vlp=li(require("http"),1),Wlp=li(require("https"),1),Hlp=li(require("util"),1),$lp=li(Fxs(),1),FJr=li(require("zlib"),1);var uzi="1.8.2";function rla(e){let t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}var Z2S=/^(?:([^;]+);)?(?:[^;]+;)?(base64|),([\s\S]*)$/;function BIs(e,t,r){let i=r&&r.Blob||EM.classes.Blob,n=rla(e);if(t===void 0&&i&&(t=!0),n==="data"){e=n.length?e.slice(n.length+1):e;let a=Z2S.exec(e);if(!a)throw new Dp("Invalid URL",Dp.ERR_INVALID_URL);let u=a[1],l=a[2],d=a[3],s=Buffer.from(decodeURIComponent(d),l?"base64":"utf8");if(t){if(!i)throw new Dp("Blob is not supported",Dp.ERR_NOT_SUPPORT);return new i([s],{type:u})}return s}throw new Dp("Unsupported protocol "+n,Dp.ERR_NOT_SUPPORT)}var szi=li(require("stream"),1);var Dlp=li(require("stream"),1);var xIs=Symbol("internals"),IIs=class extends Dlp.default.Transform{constructor(t){t=ds.toFlatObject(t,{maxRate:0,chunkSize:64*1024,minChunkSize:100,timeWindow:500,ticksRate:2,samplesCount:15},null,(i,n)=>!ds.isUndefined(n[i])),super({readableHighWaterMark:t.chunkSize});let r=this[xIs]={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[xIs];return r.onReadCallback&&r.onReadCallback(),super._read(t)}_transform(t,r,i){let n=this[xIs],a=n.maxRate,u=this.readableHighWaterMark,l=n.timeWindow,d=1e3/l,s=a/d,o=n.minChunkSize!==!1?Math.max(n.minChunkSize,s*.01):0,c=(g,O)=>{let m=Buffer.byteLength(g);n.bytesSeen+=m,n.bytes+=m,n.isCaptured&&this.emit("progress",n.bytesSeen),this.push(g)?process.nextTick(O):n.onReadCallback=()=>{n.onReadCallback=null,process.nextTick(O)}},b=(g,O)=>{let m=Buffer.byteLength(g),w=null,E=u,A,q=0;if(a){let D=Date.now();(!n.ts||(q=D-n.ts)>=l)&&(n.ts=D,A=s-n.bytes,n.bytes=A<0?-A:0,q=0),A=s-n.bytes}if(a){if(A<=0)return setTimeout(()=>{O(null,g)},l-q);A<E&&(E=A)}E&&m>E&&m-E>o&&(w=g.subarray(E),g=g.subarray(0,E)),c(g,w?()=>{process.nextTick(O,null,w)}:O)};b(t,function g(O,m){if(O)return i(O);m?b(m,g):i(null)})}},zIs=IIs;var Glp=require("events");var Mlp=li(require("util"),1),Alp=require("stream");var{asyncIterator:Elp}=Symbol,k2S=async function*(e){e.stream?yield*e.stream():e.arrayBuffer?yield await e.arrayBuffer():e[Elp]?yield*e[Elp]():yield e},OPo=k2S;var e4S=EM.ALPHABET.ALPHA_DIGIT+"-_",ila=typeof TextEncoder=="function"?new TextEncoder:new Mlp.default.TextEncoder,Pfi=`\r
|
|
1707
1707
|
`,t4S=ila.encode(Pfi),r4S=2,RIs=class{constructor(t,r){let{escapeName:i}=this.constructor,n=ds.isString(r),a=`Content-Disposition: form-data; name="${i(t)}"${!n&&r.name?`; filename="${i(r.name)}"`:""}${Pfi}`;n?r=ila.encode(String(r).replace(/\r?\n|\r\n?/g,Pfi)):a+=`Content-Type: ${r.type||"application/octet-stream"}${Pfi}`,this.headers=ila.encode(a+Pfi),this.contentLength=n?r.byteLength:r.size,this.size=this.headers.byteLength+this.contentLength+r4S,this.name=t,this.value=r}async*encode(){yield this.headers;let{value:t}=this;ds.isTypedArray(t)?yield t:yield*OPo(t),yield t4S}static escapeName(t){return String(t).replace(/[\r\n"]/g,r=>({"\r":"%0D","\n":"%0A",'"':"%22"})[r])}},i4S=(e,t,r)=>{let{tag:i="form-data-boundary",size:n=25,boundary:a=i+"-"+EM.generateString(n,e4S)}=r||{};if(!ds.isFormData(e))throw TypeError("FormData instance required");if(a.length<1||a.length>70)throw Error("boundary must be 10-70 characters long");let u=ila.encode("--"+a+Pfi),l=ila.encode("--"+a+"--"+Pfi+Pfi),d=l.byteLength,s=Array.from(e.entries()).map(([c,b])=>{let g=new RIs(c,b);return d+=g.size,g});d+=u.byteLength*s.length,d=ds.toFiniteNumber(d);let o={"Content-Type":`multipart/form-data; boundary=${a}`};return Number.isFinite(d)&&(o["Content-Length"]=d),t&&t(o),Alp.Readable.from(async function*(){for(let c of s)yield u,yield*c.encode();yield l}())},qlp=i4S;var Tlp=li(require("stream"),1),NIs=class extends Tlp.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)}},Clp=NIs;var n4S=(e,t)=>ds.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,Blp=n4S;function a4S(e,t){e=e||10;let r=new Array(e),i=new Array(e),n=0,a=0,u;return t=t!==void 0?t:1e3,function(d){let s=Date.now(),o=i[a];u||(u=s),r[n]=d,i[n]=s;let c=a,b=0;for(;c!==n;)b+=r[c++],c=c%e;if(n=(n+1)%e,n===a&&(a=(a+1)%e),s-u<t)return;let g=o&&s-o;return g?Math.round(b*1e3/g):void 0}}var xlp=a4S;function o4S(e,t){let r=0,i=1e3/t,n,a,u=(s,o=Date.now())=>{r=o,n=null,a&&(clearTimeout(a),a=null),e.apply(null,s)};return[(...s)=>{let o=Date.now(),c=o-r;c>=i?u(s,o):(n=s,a||(a=setTimeout(()=>{a=null,u(n)},i-c)))},()=>n&&u(n)]}var Ilp=o4S;var NJr=(e,t,r=3)=>{let i=0,n=xlp(50,250);return Ilp(a=>{let u=a.loaded,l=a.lengthComputable?a.total:void 0,d=u-i,s=n(d),o=u<=l;i=u;let c={loaded:u,total:l,progress:l?u/l:void 0,bytes:d,rate:s||void 0,estimated:s&&l&&o?(l-u)/s:void 0,event:a,lengthComputable:l!=null,[t?"download":"upload"]:!0};e(c)},r)},cPn=(e,t)=>{let r=e!=null;return[i=>t[0]({lengthComputable:r,total:e,loaded:i}),t[1]]},lPn=e=>(...t)=>ds.asap(()=>e(...t));var zlp={flush:FJr.default.constants.Z_SYNC_FLUSH,finishFlush:FJr.default.constants.Z_SYNC_FLUSH},u4S={flush:FJr.default.constants.BROTLI_OPERATION_FLUSH,finishFlush:FJr.default.constants.BROTLI_OPERATION_FLUSH},Rlp=ds.isFunction(FJr.default.createBrotliDecompress),{http:s4S,https:c4S}=$lp.default,l4S=/https:?/,Nlp=EM.protocols.map(e=>e+":"),Flp=(e,[t,r])=>(e.on("end",r).on("error",r),t);function f4S(e,t){e.beforeRedirects.proxy&&e.beforeRedirects.proxy(e),e.beforeRedirects.config&&e.beforeRedirects.config(e,t)}function Qlp(e,t,r){let i=t;if(!i&&i!==!1){let n=Ulp.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){Qlp(a,t,a.href)}}var d4S=typeof process<"u"&&ds.kindOf(process)==="process",p4S=e=>new Promise((t,r)=>{let i,n,a=(d,s)=>{n||(n=!0,i&&i(d,s))},u=d=>{a(d),t(d)},l=d=>{a(d,!0),r(d)};e(u,l,d=>i=d).catch(l)}),_4S=({address:e,family:t})=>{if(!ds.isString(e))throw TypeError("address must be a string");return{address:e,family:t||(e.indexOf(".")<0?6:4)}},Llp=(e,t)=>_4S(ds.isObject(e)?e:{address:e,family:t}),Jlp=d4S&&function(t){return p4S(async function(i,n,a){let{data:u,lookup:l,family:d}=t,{responseType:s,responseEncoding:o}=t,c=t.method.toUpperCase(),b,g=!1,O;if(l){let Se=Blp(l,Qe=>ds.isArray(Qe)?Qe:[Qe]);l=(Qe,St,Ee)=>{Se(Qe,St,(Te,xt,Pe)=>{if(Te)return Ee(Te);let Ot=ds.isArray(xt)?xt.map(at=>Llp(at)):[Llp(xt,Pe)];St.all?Ee(Te,Ot):Ee(Te,Ot[0].address,Ot[0].family)})}}let m=new Glp.EventEmitter,w=()=>{t.cancelToken&&t.cancelToken.unsubscribe(E),t.signal&&t.signal.removeEventListener("abort",E),m.removeAllListeners()};a((Se,Qe)=>{b=!0,Qe&&(g=!0,w())});function E(Se){m.emit("abort",!Se||Se.type?new ZSe(null,t,O):Se)}m.once("abort",n),(t.cancelToken||t.signal)&&(t.cancelToken&&t.cancelToken.subscribe(E),t.signal&&(t.signal.aborted?E():t.signal.addEventListener("abort",E)));let A=ozi(t.baseURL,t.url,t.allowAbsoluteUrls),q=new URL(A,EM.hasBrowserEnv?EM.origin:void 0),D=q.protocol||Nlp[0];if(D==="data:"){let Se;if(c!=="GET")return QYt(i,n,{status:405,statusText:"method not allowed",headers:{},config:t});try{Se=BIs(t.url,s==="blob",{Blob:t.env&&t.env.Blob})}catch(Qe){throw Dp.from(Qe,Dp.ERR_BAD_REQUEST,t)}return s==="text"?(Se=Se.toString(o),(!o||o==="utf8")&&(Se=ds.stripBOM(Se))):s==="stream"&&(Se=szi.default.Readable.from(Se)),QYt(i,n,{data:Se,status:200,statusText:"OK",headers:new yz,config:t})}if(Nlp.indexOf(D)===-1)return n(new Dp("Unsupported protocol "+D,Dp.ERR_BAD_REQUEST,t));let C=yz.from(t.headers).normalize();C.set("User-Agent","axios/"+uzi,!1);let{onUploadProgress:z,onDownloadProgress:$}=t,x=t.maxRate,L,V;if(ds.isSpecCompliantForm(u)){let Se=C.getContentType(/boundary=([-_\w\d]{10,70})/i);u=qlp(u,Qe=>{C.set(Qe)},{tag:`axios-${uzi}-boundary`,boundary:Se&&Se[1]||void 0})}else if(ds.isFormData(u)&&ds.isFunction(u.getHeaders)){if(C.set(u.getHeaders()),!C.hasContentLength())try{let Se=await Hlp.default.promisify(u.getLength).call(u);Number.isFinite(Se)&&Se>=0&&C.setContentLength(Se)}catch{}}else if(ds.isBlob(u)||ds.isFile(u))u.size&&C.setContentType(u.type||"application/octet-stream"),C.setContentLength(u.size||0),u=szi.default.Readable.from(OPo(u));else if(u&&!ds.isStream(u)){if(!Buffer.isBuffer(u))if(ds.isArrayBuffer(u))u=Buffer.from(new Uint8Array(u));else if(ds.isString(u))u=Buffer.from(u,"utf-8");else return n(new Dp("Data after transformation must be a string, an ArrayBuffer, a Buffer, or a Stream",Dp.ERR_BAD_REQUEST,t));if(C.setContentLength(u.length,!1),t.maxBodyLength>-1&&u.length>t.maxBodyLength)return n(new Dp("Request body larger than maxBodyLength limit",Dp.ERR_BAD_REQUEST,t))}let X=ds.toFiniteNumber(C.getContentLength());ds.isArray(x)?(L=x[0],V=x[1]):L=V=x,u&&(z||L)&&(ds.isStream(u)||(u=szi.default.Readable.from(u,{objectMode:!1})),u=szi.default.pipeline([u,new zIs({maxRate:ds.toFiniteNumber(L)})],ds.noop),z&&u.on("progress",Flp(u,cPn(X,NJr(lPn(z),!1,3)))));let Q;if(t.auth){let Se=t.auth.username||"",Qe=t.auth.password||"";Q=Se+":"+Qe}if(!Q&&q.username){let Se=q.username,Qe=q.password;Q=Se+":"+Qe}Q&&C.delete("authorization");let Z;try{Z=azi(q.pathname+q.search,t.params,t.paramsSerializer).replace(/^\?/,"")}catch(Se){let Qe=new Error(Se.message);return Qe.config=t,Qe.url=t.url,Qe.exists=!0,n(Qe)}C.set("Accept-Encoding","gzip, compress, deflate"+(Rlp?", br":""),!1);let fe={path:Z,method:c,headers:C.toJSON(),agents:{http:t.httpAgent,https:t.httpsAgent},auth:Q,protocol:D,family:d,beforeRedirect:f4S,beforeRedirects:{}};!ds.isUndefined(l)&&(fe.lookup=l),t.socketPath?fe.socketPath=t.socketPath:(fe.hostname=q.hostname.startsWith("[")?q.hostname.slice(1,-1):q.hostname,fe.port=q.port,Qlp(fe,t.proxy,D+"//"+q.hostname+(q.port?":"+q.port:"")+fe.path));let me,ye=l4S.test(fe.protocol);if(fe.agent=ye?t.httpsAgent:t.httpAgent,t.transport?me=t.transport:t.maxRedirects===0?me=ye?Wlp.default:Vlp.default:(t.maxRedirects&&(fe.maxRedirects=t.maxRedirects),t.beforeRedirect&&(fe.beforeRedirects.config=t.beforeRedirect),me=ye?c4S:s4S),t.maxBodyLength>-1?fe.maxBodyLength=t.maxBodyLength:fe.maxBodyLength=1/0,t.insecureHTTPParser&&(fe.insecureHTTPParser=t.insecureHTTPParser),O=me.request(fe,function(Qe){if(O.destroyed)return;let St=[Qe],Ee=+Qe.headers["content-length"];if($||V){let at=new zIs({maxRate:ds.toFiniteNumber(V)});$&&at.on("progress",Flp(at,cPn(Ee,NJr(lPn($),!0,3)))),St.push(at)}let Te=Qe,xt=Qe.req||O;if(t.decompress!==!1&&Qe.headers["content-encoding"])switch((c==="HEAD"||Qe.statusCode===204)&&delete Qe.headers["content-encoding"],(Qe.headers["content-encoding"]||"").toLowerCase()){case"gzip":case"x-gzip":case"compress":case"x-compress":St.push(FJr.default.createUnzip(zlp)),delete Qe.headers["content-encoding"];break;case"deflate":St.push(new Clp),St.push(FJr.default.createUnzip(zlp)),delete Qe.headers["content-encoding"];break;case"br":Rlp&&(St.push(FJr.default.createBrotliDecompress(u4S)),delete Qe.headers["content-encoding"])}Te=St.length>1?szi.default.pipeline(St,ds.noop):St[0];let Pe=szi.default.finished(Te,()=>{Pe(),w()}),Ot={status:Qe.statusCode,statusText:Qe.statusMessage,headers:new yz(Qe.headers),config:t,request:xt};if(s==="stream")Ot.data=Te,QYt(i,n,Ot);else{let at=[],_e=0;Te.on("data",function(bt){at.push(bt),_e+=bt.length,t.maxContentLength>-1&&_e>t.maxContentLength&&(g=!0,Te.destroy(),n(new Dp("maxContentLength size of "+t.maxContentLength+" exceeded",Dp.ERR_BAD_RESPONSE,t,xt)))}),Te.on("aborted",function(){if(g)return;let bt=new Dp("stream has been aborted",Dp.ERR_BAD_RESPONSE,t,xt);Te.destroy(bt),n(bt)}),Te.on("error",function(bt){O.destroyed||n(Dp.from(bt,null,t,xt))}),Te.on("end",function(){try{let bt=at.length===1?at[0]:Buffer.concat(at);s!=="arraybuffer"&&(bt=bt.toString(o),(!o||o==="utf8")&&(bt=ds.stripBOM(bt))),Ot.data=bt}catch(bt){return n(Dp.from(bt,null,t,Ot.request,Ot))}QYt(i,n,Ot)})}m.once("abort",at=>{Te.destroyed||(Te.emit("error",at),Te.destroy())})}),m.once("abort",Se=>{n(Se),O.destroy(Se)}),O.on("error",function(Qe){n(Dp.from(Qe,null,t,O))}),O.on("socket",function(Qe){Qe.setKeepAlive(!0,1e3*60)}),t.timeout){let Se=parseInt(t.timeout,10);if(Number.isNaN(Se)){n(new Dp("error trying to parse `config.timeout` to int",Dp.ERR_BAD_OPTION_VALUE,t,O));return}O.setTimeout(Se,function(){if(b)return;let St=t.timeout?"timeout of "+t.timeout+"ms exceeded":"timeout exceeded",Ee=t.transitional||oPn;t.timeoutErrorMessage&&(St=t.timeoutErrorMessage),n(new Dp(St,Ee.clarifyTimeoutError?Dp.ETIMEDOUT:Dp.ECONNABORTED,t,O)),E()})}if(ds.isStream(u)){let Se=!1,Qe=!1;u.on("end",()=>{Se=!0}),u.once("error",St=>{Qe=!0,O.destroy(St)}),u.on("close",()=>{!Se&&!Qe&&E(new ZSe("Request stream has been aborted",t,O))}),u.pipe(O)}else O.end(u)})};var Klp=EM.hasStandardBrowserEnv?((e,t)=>r=>(r=new URL(r,EM.origin),e.protocol===r.protocol&&e.host===r.host&&(t||e.port===r.port)))(new URL(EM.origin),EM.navigator&&/(msie|trident)/i.test(EM.navigator.userAgent)):()=>!0;var Ylp=EM.hasStandardBrowserEnv?{write(e,t,r,i,n,a){let u=[e+"="+encodeURIComponent(t)];ds.isNumber(r)&&u.push("expires="+new Date(r).toGMTString()),ds.isString(i)&&u.push("path="+i),ds.isString(n)&&u.push("domain="+n),a===!0&&u.push("secure"),document.cookie=u.join("; ")},read(e){let t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove(e){this.write(e,"",Date.now()-864e5)}}:{write(){},read(){return null},remove(){}};var Xlp=e=>e instanceof yz?{...e}:e;function O5t(e,t){t=t||{};let r={};function i(s,o,c,b){return ds.isPlainObject(s)&&ds.isPlainObject(o)?ds.merge.call({caseless:b},s,o):ds.isPlainObject(o)?ds.merge({},o):ds.isArray(o)?o.slice():o}function n(s,o,c,b){if(ds.isUndefined(o)){if(!ds.isUndefined(s))return i(void 0,s,c,b)}else return i(s,o,c,b)}function a(s,o){if(!ds.isUndefined(o))return i(void 0,o)}function u(s,o){if(ds.isUndefined(o)){if(!ds.isUndefined(s))return i(void 0,s)}else return i(void 0,o)}function l(s,o,c){if(c in t)return i(s,o);if(c in e)return i(void 0,s)}let d={url:a,method:a,data:a,baseURL:u,transformRequest:u,transformResponse:u,paramsSerializer:u,timeout:u,timeoutMessage:u,withCredentials:u,withXSRFToken:u,adapter:u,responseType:u,xsrfCookieName:u,xsrfHeaderName:u,onUploadProgress:u,onDownloadProgress:u,decompress:u,maxContentLength:u,maxBodyLength:u,beforeRedirect:u,transport:u,httpAgent:u,httpsAgent:u,cancelToken:u,socketPath:u,responseEncoding:u,validateStatus:l,headers:(s,o,c)=>n(Xlp(s),Xlp(o),c,!0)};return ds.forEach(Object.keys(Object.assign({},e,t)),function(o){let c=d[o]||n,b=c(e[o],t[o],o);ds.isUndefined(b)&&c!==l||(r[o]=b)}),r}var mPo=e=>{let t=O5t({},e),{data:r,withXSRFToken:i,xsrfHeaderName:n,xsrfCookieName:a,headers:u,auth:l}=t;t.headers=u=yz.from(u),t.url=azi(ozi(t.baseURL,t.url),e.params,e.paramsSerializer),l&&u.set("Authorization","Basic "+btoa((l.username||"")+":"+(l.password?unescape(encodeURIComponent(l.password)):"")));let d;if(ds.isFormData(r)){if(EM.hasStandardBrowserEnv||EM.hasStandardBrowserWebWorkerEnv)u.setContentType(void 0);else if((d=u.getContentType())!==!1){let[s,...o]=d?d.split(";").map(c=>c.trim()).filter(Boolean):[];u.setContentType([s||"multipart/form-data",...o].join("; "))}}if(EM.hasStandardBrowserEnv&&(i&&ds.isFunction(i)&&(i=i(t)),i||i!==!1&&Klp(t.url))){let s=n&&a&&Ylp.read(a);s&&u.set(n,s)}return t};var h4S=typeof XMLHttpRequest<"u",Zlp=h4S&&function(e){return new Promise(function(r,i){let n=mPo(e),a=n.data,u=yz.from(n.headers).normalize(),{responseType:l,onUploadProgress:d,onDownloadProgress:s}=n,o,c,b,g,O;function m(){g&&g(),O&&O(),n.cancelToken&&n.cancelToken.unsubscribe(o),n.signal&&n.signal.removeEventListener("abort",o)}let w=new XMLHttpRequest;w.open(n.method.toUpperCase(),n.url,!0),w.timeout=n.timeout;function E(){if(!w)return;let q=yz.from("getAllResponseHeaders"in w&&w.getAllResponseHeaders()),C={data:!l||l==="text"||l==="json"?w.responseText:w.response,status:w.status,statusText:w.statusText,headers:q,config:e,request:w};QYt(function($){r($),m()},function($){i($),m()},C),w=null}"onloadend"in w?w.onloadend=E:w.onreadystatechange=function(){!w||w.readyState!==4||w.status===0&&!(w.responseURL&&w.responseURL.indexOf("file:")===0)||setTimeout(E)},w.onabort=function(){w&&(i(new Dp("Request aborted",Dp.ECONNABORTED,e,w)),w=null)},w.onerror=function(){i(new Dp("Network Error",Dp.ERR_NETWORK,e,w)),w=null},w.ontimeout=function(){let D=n.timeout?"timeout of "+n.timeout+"ms exceeded":"timeout exceeded",C=n.transitional||oPn;n.timeoutErrorMessage&&(D=n.timeoutErrorMessage),i(new Dp(D,C.clarifyTimeoutError?Dp.ETIMEDOUT:Dp.ECONNABORTED,e,w)),w=null},a===void 0&&u.setContentType(null),"setRequestHeader"in w&&ds.forEach(u.toJSON(),function(D,C){w.setRequestHeader(C,D)}),ds.isUndefined(n.withCredentials)||(w.withCredentials=!!n.withCredentials),l&&l!=="json"&&(w.responseType=n.responseType),s&&([b,O]=NJr(s,!0),w.addEventListener("progress",b)),d&&w.upload&&([c,g]=NJr(d),w.upload.addEventListener("progress",c),w.upload.addEventListener("loadend",g)),(n.cancelToken||n.signal)&&(o=q=>{w&&(i(!q||q.type?new ZSe(null,e,w):q),w.abort(),w=null)},n.cancelToken&&n.cancelToken.subscribe(o),n.signal&&(n.signal.aborted?o():n.signal.addEventListener("abort",o)));let A=rla(n.url);if(A&&EM.protocols.indexOf(A)===-1){i(new Dp("Unsupported protocol "+A+":",Dp.ERR_BAD_REQUEST,e));return}w.send(a||null)})};var y4S=(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,l();let o=s instanceof Error?s:this.reason;i.abort(o instanceof Dp?o:new ZSe(o instanceof Error?o.message:o))}},u=t&&setTimeout(()=>{u=null,a(new Dp(`timeout ${t} of ms exceeded`,Dp.ETIMEDOUT))},t),l=()=>{e&&(u&&clearTimeout(u),u=null,e.forEach(s=>{s.unsubscribe?s.unsubscribe(a):s.removeEventListener("abort",a)}),e=null)};e.forEach(s=>s.addEventListener("abort",a));let{signal:d}=i;return d.unsubscribe=()=>ds.asap(l),d}},klp=y4S;var v4S=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},b4S=async function*(e,t){for await(let r of g4S(e))yield*v4S(r,t)},g4S=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()}},FIs=(e,t,r,i)=>{let n=b4S(e,t),a=0,u,l=d=>{u||(u=!0,i&&i(d))};return new ReadableStream({async pull(d){try{let{done:s,value:o}=await n.next();if(s){l(),d.close();return}let c=o.byteLength;if(r){let b=a+=c;r(b)}d.enqueue(new Uint8Array(o))}catch(s){throw l(s),s}},cancel(d){return l(d),n.return()}},{highWaterMark:2})};var jPo=typeof fetch=="function"&&typeof Request=="function"&&typeof Response=="function",tfp=jPo&&typeof ReadableStream=="function",O4S=jPo&&(typeof TextEncoder=="function"?(e=>t=>e.encode(t))(new TextEncoder):async e=>new Uint8Array(await new Response(e).arrayBuffer())),rfp=(e,...t)=>{try{return!!e(...t)}catch{return!1}},m4S=tfp&&rfp(()=>{let e=!1,t=new Request(EM.origin,{body:new ReadableStream,method:"POST",get duplex(){return e=!0,"half"}}).headers.has("Content-Type");return e&&!t}),efp=64*1024,LIs=tfp&&rfp(()=>ds.isReadableStream(new Response("").body)),PPo={stream:LIs&&(e=>e.body)};jPo&&(e=>{["text","arrayBuffer","blob","formData","stream"].forEach(t=>{!PPo[t]&&(PPo[t]=ds.isFunction(e[t])?r=>r[t]():(r,i)=>{throw new Dp(`Response type '${t}' is not supported`,Dp.ERR_NOT_SUPPORT,i)})})})(new Response);var P4S=async e=>{if(e==null)return 0;if(ds.isBlob(e))return e.size;if(ds.isSpecCompliantForm(e))return(await new Request(EM.origin,{method:"POST",body:e}).arrayBuffer()).byteLength;if(ds.isArrayBufferView(e)||ds.isArrayBuffer(e))return e.byteLength;if(ds.isURLSearchParams(e)&&(e=e+""),ds.isString(e))return(await O4S(e)).byteLength},j4S=async(e,t)=>{let r=ds.toFiniteNumber(e.getContentLength());return r??P4S(t)},ifp=jPo&&(async e=>{let{url:t,method:r,data:i,signal:n,cancelToken:a,timeout:u,onDownloadProgress:l,onUploadProgress:d,responseType:s,headers:o,withCredentials:c="same-origin",fetchOptions:b}=mPo(e);s=s?(s+"").toLowerCase():"text";let g=klp([n,a&&a.toAbortSignal()],u),O,m=g&&g.unsubscribe&&(()=>{g.unsubscribe()}),w;try{if(d&&m4S&&r!=="get"&&r!=="head"&&(w=await j4S(o,i))!==0){let C=new Request(t,{method:"POST",body:i,duplex:"half"}),z;if(ds.isFormData(i)&&(z=C.headers.get("content-type"))&&o.setContentType(z),C.body){let[$,x]=cPn(w,NJr(lPn(d)));i=FIs(C.body,efp,$,x)}}ds.isString(c)||(c=c?"include":"omit");let E="credentials"in Request.prototype;O=new Request(t,{...b,signal:g,method:r.toUpperCase(),headers:o.normalize().toJSON(),body:i,duplex:"half",credentials:E?c:void 0});let A=await fetch(O),q=LIs&&(s==="stream"||s==="response");if(LIs&&(l||q&&m)){let C={};["status","statusText","headers"].forEach(L=>{C[L]=A[L]});let z=ds.toFiniteNumber(A.headers.get("content-length")),[$,x]=l&&cPn(z,NJr(lPn(l),!0))||[];A=new Response(FIs(A.body,efp,$,()=>{x&&x(),m&&m()}),C)}s=s||"text";let D=await PPo[ds.findKey(PPo,s)||"text"](A,e);return!q&&m&&m(),await new Promise((C,z)=>{QYt(C,z,{data:D,headers:yz.from(A.headers),status:A.status,statusText:A.statusText,config:e,request:O})})}catch(E){throw m&&m(),E&&E.name==="TypeError"&&/fetch/i.test(E.message)?Object.assign(new Dp("Network Error",Dp.ERR_NETWORK,e,O),{cause:E.cause||E}):Dp.from(E,E&&E.code,e,O)}});var UIs={http:Jlp,xhr:Zlp,fetch:ifp};ds.forEach(UIs,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});var nfp=e=>`- ${e}`,w4S=e=>ds.isFunction(e)||e===null||e===!1,wPo={getAdapter:e=>{e=ds.isArray(e)?e:[e];let{length:t}=e,r,i,n={};for(let a=0;a<t;a++){r=e[a];let u;if(i=r,!w4S(r)&&(i=UIs[(u=String(r)).toLowerCase()],i===void 0))throw new Dp(`Unknown adapter '${u}'`);if(i)break;n[u||"#"+a]=i}if(!i){let a=Object.entries(n).map(([l,d])=>`adapter ${l} `+(d===!1?"is not supported by the environment":"is not available in the build")),u=t?a.length>1?`since :
|
|
@@ -1940,7 +1940,7 @@ ${q}${A}${D}${kqp.default.cursorHide}`});var x_a=li(dxi(),1);function q5s(e,t){i
|
|
|
1940
1940
|
Run ${Ws.cyan("fern generator upgrade")} to upgrade your generators.`),n.length>2&&(r+=`
|
|
1941
1941
|
Run ${Ws.cyan("fern generator upgrade --list")} to see the full list of generator upgrades available.`),dPn(r,{padding:1,float:"center",textAlignment:"center",borderColor:"yellow",borderStyle:"round"})}async function U5s({generatorUpgradeInfo:e,header:t,limit:r,includeBoxen:i=!0}){if(!jTp(e))return;let n=t??"",a=e.filter(l=>l.isUpgradeAvailable);r!=null&&(a=a.slice(0,r+1));let u=a.sort((l,d)=>l.generatorName.localeCompare(d.generatorName)||l.currentVersion.localeCompare(d.currentVersion));for(let l of u)n+=`
|
|
1942
1942
|
${await ppD(l.generatorName)} (${l.apiName!=null?"API: "+l.apiName+", ":""}Group: ${l.generatorGroup}) `+Ws.dim(l.currentVersion)+Ws.reset(" \u2192 ")+Ws.green(l.latestVersion);return n+=`
|
|
1943
|
-
`,i?dPn(n,{padding:1,float:"center",textAlignment:"center",borderColor:"yellow",borderStyle:"round"}):n}async function ppD(e){let r=await new PTp.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 _pD({cliContext:e,project:{apiWorkspaces:t},generatorFilter:r,groupFilter:i,channel:n,includeMajor:a}){if(t.length===1){let l={type:"singleApi",versions:{}};return await STp({cliContext:e,apiWorkspaces:t,perGeneratorAction:async(d,s,o,c)=>{l.versions[s]==null&&(l.versions[s]={});let b=Ksi(o.name,c),g=await aJt({generatorName:b,cliVersion:e.environment.packageVersion,currentGeneratorVersion:o.version,channel:n,includeMajor:a,context:c});g!=null&&(l.versions[s][o.name]={previousVersion:o.version,latestVersion:g})},generatorFilter:r,groupFilter:i}),l}let u={type:"multiApi",versions:{}};return await STp({cliContext:e,apiWorkspaces:t,perGeneratorAction:async(l,d,s,o)=>{if(l==null)return;u.versions[l]==null&&(u.versions[l]={}),u.versions[l][d]==null&&(u.versions[l][d]={});let c=Ksi(s.name,o),b=await aJt({generatorName:c,cliVersion:e.environment.packageVersion,currentGeneratorVersion:s.version,channel:n,includeMajor:a,context:o});b!=null&&(u.versions[l][d][s.name]={previousVersion:s.version,latestVersion:b})},generatorFilter:r,groupFilter:i}),u}async function STp({cliContext:e,apiWorkspaces:t,perGeneratorAction:r,generatorFilter:i,groupFilter:n}){await Promise.all(t.map(async a=>{await e.runTaskForWorkspace(a,async u=>{let l=await H8t({absolutePathToWorkspace:a.absoluteFilePath,context:u});if(!(l==null||l.groups==null)){for(let d of l.groups)if(!(n!=null&&d.groupName!==n))for(let s of d.generators)i!=null&&s.name!==i||await r(a.workspaceName,d.groupName,s,u)}})}))}function DTp(e,t,r){let i=[];for(let[n,a]of Object.entries(e))for(let[u,l]of Object.entries(a)){r.debug(`Checking if ${u} in group ${n} has an upgrade available...`);let d=Kie(l.latestVersion,l.previousVersion);r.debug(`Latest version: ${l.latestVersion}. `+(d?"Upgrade available.":"No upgrade available.")),i.push({generatorName:u,generatorGroup:n,apiName:t,isUpgradeAvailable:d,currentVersion:l.previousVersion,latestVersion:l.latestVersion})}return i}async function SAo({project:e,cliContext:t,generatorFilter:r,groupFilter:i,channel:n,includeMajor:a}){let u=[];if(e!=null){let l=await _pD({cliContext:t,project:e,generatorFilter:r,groupFilter:i,channel:n,includeMajor:a});if(l.type==="multiApi")for(let[d,s]of Object.entries(l.versions))u.push(...DTp(s,d,t.logger));else u.push(...DTp(l.versions,void 0,t.logger))}return u}var V_a=class extends Error{response;request;options;constructor(t,r,i){let n=t.status||t.status===0?t.status:"",a=t.statusText||"",u=`${n} ${a}`.trim(),l=u?`status code ${u}`:"an unknown error";super(`Request failed with ${l}: ${r.method} ${r.url}`),this.name="HTTPError",this.response=t,this.request=r,this.options=i}};var $1n=class extends Error{request;constructor(t){super(`Request timed out: ${t.method} ${t.url}`),this.name="TimeoutError",this.request=t}};var G1n=e=>e!==null&&typeof e=="object";var W_a=(...e)=>{for(let t of e)if((!G1n(t)||Array.isArray(t))&&t!==void 0)throw new TypeError("The `options` argument must be an object");return H5s({},...e)},V5s=(e={},t={})=>{let r=new globalThis.Headers(e),i=t instanceof globalThis.Headers,n=new globalThis.Headers(t);for(let[a,u]of n.entries())i&&u==="undefined"||u===void 0?r.delete(a):r.set(a,u);return r};function DAo(e,t,r){return Object.hasOwn(t,r)&&t[r]===void 0?[]:H5s(e[r]??[],t[r]??[])}var W5s=(e={},t={})=>({beforeRequest:DAo(e,t,"beforeRequest"),beforeRetry:DAo(e,t,"beforeRetry"),afterResponse:DAo(e,t,"afterResponse"),beforeError:DAo(e,t,"beforeError")}),H5s=(...e)=>{let t={},r={},i={};for(let n of e)if(Array.isArray(n))Array.isArray(t)||(t=[]),t=[...t,...n];else if(G1n(n)){for(let[a,u]of Object.entries(n))G1n(u)&&a in t&&(u=H5s(t[a],u)),t={...t,[a]:u};G1n(n.hooks)&&(i=W5s(i,n.hooks),t.hooks=i),G1n(n.headers)&&(r=V5s(r,n.headers),t.headers=r)}return t};var ETp=(()=>{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})(),MTp=typeof globalThis.AbortController=="function",ATp=typeof globalThis.ReadableStream=="function",qTp=typeof globalThis.FormData=="function",EAo=["get","post","put","patch","head","delete"],hpD=()=>{};hpD();var TTp={json:"application/json",text:"text/*",formData:"multipart/form-data",arrayBuffer:"*/*",blob:"*/*"},MAo=2147483647,AAo=Symbol("stop"),CTp={json:!0,parseJson:!0,stringifyJson:!0,searchParams:!0,prefixUrl:!0,retry:!0,timeout:!0,hooks:!0,throwHttpErrors:!0,onDownloadProgress:!0,fetch:!0},BTp={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 ITp=e=>EAo.includes(e)?e.toUpperCase():e,ypD=["get","put","head","delete","options","trace"],vpD=[408,413,429,500,502,503,504],bpD=[413,429,503],xTp={limit:2,methods:ypD,statusCodes:vpD,afterStatusCodes:bpD,maxRetryAfter:Number.POSITIVE_INFINITY,backoffLimit:Number.POSITIVE_INFINITY,delay:e=>.3*2**(e-1)*1e3},zTp=(e={})=>{if(typeof e=="number")return{...xTp,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{...xTp,...e}};async function $5s(e,t,r,i){return new Promise((n,a)=>{let u=setTimeout(()=>{r&&r.abort(),a(new $1n(e))},i.timeout);i.fetch(e,t).then(n).catch(a).then(()=>{clearTimeout(u)})})}async function G5s(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 RTp=(e,t)=>{let r={};for(let i in t)!(i in BTp)&&!(i in CTp)&&!(i in e)&&(r[i]=t[i]);return r};var H_a=class e{static create(t,r){let i=new e(t,r),n=async()=>{if(typeof i._options.timeout=="number"&&i._options.timeout>MAo)throw new RangeError(`The \`timeout\` option cannot be greater than ${MAo}`);await Promise.resolve();let l=await i._fetch();for(let d of i._options.hooks.afterResponse){let s=await d(i.request,i._options,i._decorateResponse(l.clone()));s instanceof globalThis.Response&&(l=s)}if(i._decorateResponse(l),!l.ok&&i._options.throwHttpErrors){let d=new V_a(l,i.request,i._options);for(let s of i._options.hooks.beforeError)d=await s(d);throw d}if(i._options.onDownloadProgress){if(typeof i._options.onDownloadProgress!="function")throw new TypeError("The `onDownloadProgress` option must be a function");if(!ATp)throw new Error("Streams are not supported in your environment. `ReadableStream` is missing.");return i._stream(l.clone(),i._options.onDownloadProgress)}return l},u=i._options.retry.methods.includes(i.request.method.toLowerCase())?i._retry(n):n();for(let[l,d]of Object.entries(TTp))u[l]=async()=>{i.request.headers.set("accept",i.request.headers.get("accept")||d);let o=(await u).clone();if(l==="json"){if(o.status===204||(await o.clone().arrayBuffer()).byteLength===0)return"";if(r.parseJson)return r.parseJson(await o.text())}return o[l]()};return u}request;abortController;_retryCount=0;_input;_options;constructor(t,r={}){if(this._input=t,this._options={...r,headers:V5s(this._input.headers,r.headers),hooks:W5s({beforeRequest:[],beforeRetry:[],beforeError:[],afterResponse:[]},r.hooks),method:ITp(r.method??this._input.method),prefixUrl:String(r.prefixUrl||""),retry:zTp(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(MTp){this.abortController=new globalThis.AbortController;let i=this._options.signal??this._input.signal;i?.addEventListener("abort",()=>{this.abortController.abort(i.reason)}),this._options.signal=this.abortController.signal}if(ETp&&(this._options.duplex="half"),this._options.json!==void 0&&(this._options.body=this._options.stringifyJson?.(this._options.json)??JSON.stringify(this._options.json),this._options.headers.set("content-type",this._options.headers.get("content-type")??"application/json")),this.request=new globalThis.Request(this._input,this._options),this._options.searchParams){let n="?"+(typeof this._options.searchParams=="string"?this._options.searchParams.replace(/^\?/,""):new URLSearchParams(this._options.searchParams).toString()),a=this.request.url.replace(/(?:\?.*?)?(?=#|$)/,n);(qTp&&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)}}_calculateRetryDelay(t){if(this._retryCount++,this._retryCount>this._options.retry.limit||t instanceof $1n)throw t;if(t instanceof V_a){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),MAo);if(this._retryCount<1)throw r;await G5s(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})===AAo)return;return this._retry(t)}}async _fetch(){for(let i of this._options.hooks.beforeRequest){let n=await i(this.request,this._options);if(n instanceof Request){this.request=n;break}if(n instanceof Response)return n}let t=RTp(this.request,this._options),r=this.request;return this.request=r.clone(),this._options.timeout===!1?this._options.fetch(r,t):$5s(r,t,this.abortController,this._options)}_stream(t,r){let i=Number(t.headers.get("content-length"))||0,n=0;return t.status===204?(r&&r({percent:1,totalBytes:i,transferredBytes:n},new Uint8Array),new globalThis.Response(null,{status:t.status,statusText:t.statusText,headers:t.headers})):new globalThis.Response(new globalThis.ReadableStream({async start(a){let u=t.body.getReader();r&&r({percent:0,transferredBytes:0,totalBytes:i},new Uint8Array);async function l(){let{done:d,value:s}=await u.read();if(d){a.close();return}if(r){n+=s.byteLength;let o=i===0?0:n/i;r({percent:o,transferredBytes:n,totalBytes:i},s)}a.enqueue(s),await l()}await l()}}),{status:t.status,statusText:t.statusText,headers:t.headers})}};var Q5s=e=>{let t=(r,i)=>H_a.create(r,W_a(e,i));for(let r of EAo)t[r]=(i,n)=>H_a.create(i,W_a(e,n,{method:r}));return t.create=r=>Q5s(W_a(r)),t.extend=r=>(typeof r=="function"&&(r=r(e??{})),Q5s(W_a(e,r))),t.stop=AAo,t},gpD=Q5s(),NTp=gpD;var uCp=li(oCp(),1);function Z5s(e){let t=(0,uCp.default)("npm",{registry:"https://registry.npmjs.org/"}),r=t[`${e}:registry`]||t.config_registry||t.registry;return r.slice(-1)==="/"?r:`${r}/`}var tBp=li(eBp(),1),rBp=li(dxi(),1),d9s=class extends Error{constructor(t){super(`Package \`${t}\` could not be found`),this.name="PackageNotFoundError"}},p9s=class extends Error{constructor(t,r){super(`Version \`${r}\` for package \`${t}\` could not be found`),this.name="VersionNotFoundError"}};async function _9s(e,t={}){let{version:r="latest"}=t,{omitDeprecated:i=!0}=t,n=e.split("/")[0],a=t.registryUrl??Z5s(n),u=new URL(encodeURIComponent(e).replace(/^%40/,"@"),a),l=(0,tBp.default)(a.toString(),{recursive:!0}),d={accept:"application/vnd.npm.install-v1+json; q=1.0, application/json; q=0.8, */*"};t.fullMetadata&&delete d.accept,l&&(d.authorization=`${l.type} ${l.token}`);let s;try{s=await NTp(u,{headers:d,keepalive:!0}).json()}catch(c){throw c?.response?.status===404?new d9s(e):c}if(t.allVersions)return s;let o=new p9s(e,r);if(s["dist-tags"][r]){let{time:c}=s;s=s.versions[s["dist-tags"][r]],s.time=c}else if(r){let c=!!s.versions[r];if(i&&!c)for(let[g,O]of Object.entries(s.versions))O.deprecated&&delete s.versions[g];if(!c){let g=Object.keys(s.versions);if(r=rBp.default.maxSatisfying(g,r),!r)throw o}let{time:b}=s;if(s=s.versions[r],s.time=b,!s)throw o}return s}async function Y_a(e,t){let{version:r}=await _9s(e.toLowerCase(),t);return r}async function Gdi({cliEnvironment:e,includePreReleases:t=!1}){return e.packageName!=="fern-api"?e.packageVersion:Y_a(e.packageName,{version:t?"prerelease":"latest"})}var iBp=["#2E86AB","#A23B72","#F18F01","#C73E1D","#CCE2A3"],UAo=class{environment;didSucceed=!0;numTasks=0;ttyAwareLogger;logLevel=H0.Info;constructor(t){this.ttyAwareLogger=new wAo(t);let r=this.getPackageName(),i=this.getPackageVersion(),n=this.getCliName();(r==null||i==null||n==null)&&this.exitProgram(),this.environment={packageName:r,packageVersion:i,cliName:n}}getPackageName(){return"fern-api"}getPackageVersion(){return"0.58.0-rc0"}getCliName(){return"fern"}setLogLevel(t){this.logLevel=t}logDebugInfo(){this.logger.debug(`Running ${Ws.bold(`${this.environment.cliName}`)} (${this.environment.packageName}@${this.environment.packageVersion})`)}failAndThrow(t,r){throw this.failWithoutThrowing(t,r),new pre}failWithoutThrowing(t,r){this.didSucceed=!1,OAo({message:t,error:r,logger:this.logger})}async exit(){this._suppressUpgradeMessage||await this.nudgeUpgradeIfAvailable(),this.ttyAwareLogger.finish(),await(await iPn()).flush(),this.exitProgram()}async nudgeUpgradeIfAvailable(){try{let t=await Promise.race([this.isUpgradeAvailable(),new Promise((i,n)=>setTimeout(()=>n("Request timed out"),300))]),r=await wTp({cliEnvironment:this.environment,upgradeInfo:t});r!=null&&(r.endsWith(`
|
|
1943
|
+
`,i?dPn(n,{padding:1,float:"center",textAlignment:"center",borderColor:"yellow",borderStyle:"round"}):n}async function ppD(e){let r=await new PTp.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 _pD({cliContext:e,project:{apiWorkspaces:t},generatorFilter:r,groupFilter:i,channel:n,includeMajor:a}){if(t.length===1){let l={type:"singleApi",versions:{}};return await STp({cliContext:e,apiWorkspaces:t,perGeneratorAction:async(d,s,o,c)=>{l.versions[s]==null&&(l.versions[s]={});let b=Ksi(o.name,c),g=await aJt({generatorName:b,cliVersion:e.environment.packageVersion,currentGeneratorVersion:o.version,channel:n,includeMajor:a,context:c});g!=null&&(l.versions[s][o.name]={previousVersion:o.version,latestVersion:g})},generatorFilter:r,groupFilter:i}),l}let u={type:"multiApi",versions:{}};return await STp({cliContext:e,apiWorkspaces:t,perGeneratorAction:async(l,d,s,o)=>{if(l==null)return;u.versions[l]==null&&(u.versions[l]={}),u.versions[l][d]==null&&(u.versions[l][d]={});let c=Ksi(s.name,o),b=await aJt({generatorName:c,cliVersion:e.environment.packageVersion,currentGeneratorVersion:s.version,channel:n,includeMajor:a,context:o});b!=null&&(u.versions[l][d][s.name]={previousVersion:s.version,latestVersion:b})},generatorFilter:r,groupFilter:i}),u}async function STp({cliContext:e,apiWorkspaces:t,perGeneratorAction:r,generatorFilter:i,groupFilter:n}){await Promise.all(t.map(async a=>{await e.runTaskForWorkspace(a,async u=>{let l=await H8t({absolutePathToWorkspace:a.absoluteFilePath,context:u});if(!(l==null||l.groups==null)){for(let d of l.groups)if(!(n!=null&&d.groupName!==n))for(let s of d.generators)i!=null&&s.name!==i||await r(a.workspaceName,d.groupName,s,u)}})}))}function DTp(e,t,r){let i=[];for(let[n,a]of Object.entries(e))for(let[u,l]of Object.entries(a)){r.debug(`Checking if ${u} in group ${n} has an upgrade available...`);let d=Kie(l.latestVersion,l.previousVersion);r.debug(`Latest version: ${l.latestVersion}. `+(d?"Upgrade available.":"No upgrade available.")),i.push({generatorName:u,generatorGroup:n,apiName:t,isUpgradeAvailable:d,currentVersion:l.previousVersion,latestVersion:l.latestVersion})}return i}async function SAo({project:e,cliContext:t,generatorFilter:r,groupFilter:i,channel:n,includeMajor:a}){let u=[];if(e!=null){let l=await _pD({cliContext:t,project:e,generatorFilter:r,groupFilter:i,channel:n,includeMajor:a});if(l.type==="multiApi")for(let[d,s]of Object.entries(l.versions))u.push(...DTp(s,d,t.logger));else u.push(...DTp(l.versions,void 0,t.logger))}return u}var V_a=class extends Error{response;request;options;constructor(t,r,i){let n=t.status||t.status===0?t.status:"",a=t.statusText||"",u=`${n} ${a}`.trim(),l=u?`status code ${u}`:"an unknown error";super(`Request failed with ${l}: ${r.method} ${r.url}`),this.name="HTTPError",this.response=t,this.request=r,this.options=i}};var $1n=class extends Error{request;constructor(t){super(`Request timed out: ${t.method} ${t.url}`),this.name="TimeoutError",this.request=t}};var G1n=e=>e!==null&&typeof e=="object";var W_a=(...e)=>{for(let t of e)if((!G1n(t)||Array.isArray(t))&&t!==void 0)throw new TypeError("The `options` argument must be an object");return H5s({},...e)},V5s=(e={},t={})=>{let r=new globalThis.Headers(e),i=t instanceof globalThis.Headers,n=new globalThis.Headers(t);for(let[a,u]of n.entries())i&&u==="undefined"||u===void 0?r.delete(a):r.set(a,u);return r};function DAo(e,t,r){return Object.hasOwn(t,r)&&t[r]===void 0?[]:H5s(e[r]??[],t[r]??[])}var W5s=(e={},t={})=>({beforeRequest:DAo(e,t,"beforeRequest"),beforeRetry:DAo(e,t,"beforeRetry"),afterResponse:DAo(e,t,"afterResponse"),beforeError:DAo(e,t,"beforeError")}),H5s=(...e)=>{let t={},r={},i={};for(let n of e)if(Array.isArray(n))Array.isArray(t)||(t=[]),t=[...t,...n];else if(G1n(n)){for(let[a,u]of Object.entries(n))G1n(u)&&a in t&&(u=H5s(t[a],u)),t={...t,[a]:u};G1n(n.hooks)&&(i=W5s(i,n.hooks),t.hooks=i),G1n(n.headers)&&(r=V5s(r,n.headers),t.headers=r)}return t};var ETp=(()=>{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})(),MTp=typeof globalThis.AbortController=="function",ATp=typeof globalThis.ReadableStream=="function",qTp=typeof globalThis.FormData=="function",EAo=["get","post","put","patch","head","delete"],hpD=()=>{};hpD();var TTp={json:"application/json",text:"text/*",formData:"multipart/form-data",arrayBuffer:"*/*",blob:"*/*"},MAo=2147483647,AAo=Symbol("stop"),CTp={json:!0,parseJson:!0,stringifyJson:!0,searchParams:!0,prefixUrl:!0,retry:!0,timeout:!0,hooks:!0,throwHttpErrors:!0,onDownloadProgress:!0,fetch:!0},BTp={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 ITp=e=>EAo.includes(e)?e.toUpperCase():e,ypD=["get","put","head","delete","options","trace"],vpD=[408,413,429,500,502,503,504],bpD=[413,429,503],xTp={limit:2,methods:ypD,statusCodes:vpD,afterStatusCodes:bpD,maxRetryAfter:Number.POSITIVE_INFINITY,backoffLimit:Number.POSITIVE_INFINITY,delay:e=>.3*2**(e-1)*1e3},zTp=(e={})=>{if(typeof e=="number")return{...xTp,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{...xTp,...e}};async function $5s(e,t,r,i){return new Promise((n,a)=>{let u=setTimeout(()=>{r&&r.abort(),a(new $1n(e))},i.timeout);i.fetch(e,t).then(n).catch(a).then(()=>{clearTimeout(u)})})}async function G5s(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 RTp=(e,t)=>{let r={};for(let i in t)!(i in BTp)&&!(i in CTp)&&!(i in e)&&(r[i]=t[i]);return r};var H_a=class e{static create(t,r){let i=new e(t,r),n=async()=>{if(typeof i._options.timeout=="number"&&i._options.timeout>MAo)throw new RangeError(`The \`timeout\` option cannot be greater than ${MAo}`);await Promise.resolve();let l=await i._fetch();for(let d of i._options.hooks.afterResponse){let s=await d(i.request,i._options,i._decorateResponse(l.clone()));s instanceof globalThis.Response&&(l=s)}if(i._decorateResponse(l),!l.ok&&i._options.throwHttpErrors){let d=new V_a(l,i.request,i._options);for(let s of i._options.hooks.beforeError)d=await s(d);throw d}if(i._options.onDownloadProgress){if(typeof i._options.onDownloadProgress!="function")throw new TypeError("The `onDownloadProgress` option must be a function");if(!ATp)throw new Error("Streams are not supported in your environment. `ReadableStream` is missing.");return i._stream(l.clone(),i._options.onDownloadProgress)}return l},u=i._options.retry.methods.includes(i.request.method.toLowerCase())?i._retry(n):n();for(let[l,d]of Object.entries(TTp))u[l]=async()=>{i.request.headers.set("accept",i.request.headers.get("accept")||d);let o=(await u).clone();if(l==="json"){if(o.status===204||(await o.clone().arrayBuffer()).byteLength===0)return"";if(r.parseJson)return r.parseJson(await o.text())}return o[l]()};return u}request;abortController;_retryCount=0;_input;_options;constructor(t,r={}){if(this._input=t,this._options={...r,headers:V5s(this._input.headers,r.headers),hooks:W5s({beforeRequest:[],beforeRetry:[],beforeError:[],afterResponse:[]},r.hooks),method:ITp(r.method??this._input.method),prefixUrl:String(r.prefixUrl||""),retry:zTp(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(MTp){this.abortController=new globalThis.AbortController;let i=this._options.signal??this._input.signal;i?.addEventListener("abort",()=>{this.abortController.abort(i.reason)}),this._options.signal=this.abortController.signal}if(ETp&&(this._options.duplex="half"),this._options.json!==void 0&&(this._options.body=this._options.stringifyJson?.(this._options.json)??JSON.stringify(this._options.json),this._options.headers.set("content-type",this._options.headers.get("content-type")??"application/json")),this.request=new globalThis.Request(this._input,this._options),this._options.searchParams){let n="?"+(typeof this._options.searchParams=="string"?this._options.searchParams.replace(/^\?/,""):new URLSearchParams(this._options.searchParams).toString()),a=this.request.url.replace(/(?:\?.*?)?(?=#|$)/,n);(qTp&&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)}}_calculateRetryDelay(t){if(this._retryCount++,this._retryCount>this._options.retry.limit||t instanceof $1n)throw t;if(t instanceof V_a){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),MAo);if(this._retryCount<1)throw r;await G5s(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})===AAo)return;return this._retry(t)}}async _fetch(){for(let i of this._options.hooks.beforeRequest){let n=await i(this.request,this._options);if(n instanceof Request){this.request=n;break}if(n instanceof Response)return n}let t=RTp(this.request,this._options),r=this.request;return this.request=r.clone(),this._options.timeout===!1?this._options.fetch(r,t):$5s(r,t,this.abortController,this._options)}_stream(t,r){let i=Number(t.headers.get("content-length"))||0,n=0;return t.status===204?(r&&r({percent:1,totalBytes:i,transferredBytes:n},new Uint8Array),new globalThis.Response(null,{status:t.status,statusText:t.statusText,headers:t.headers})):new globalThis.Response(new globalThis.ReadableStream({async start(a){let u=t.body.getReader();r&&r({percent:0,transferredBytes:0,totalBytes:i},new Uint8Array);async function l(){let{done:d,value:s}=await u.read();if(d){a.close();return}if(r){n+=s.byteLength;let o=i===0?0:n/i;r({percent:o,transferredBytes:n,totalBytes:i},s)}a.enqueue(s),await l()}await l()}}),{status:t.status,statusText:t.statusText,headers:t.headers})}};var Q5s=e=>{let t=(r,i)=>H_a.create(r,W_a(e,i));for(let r of EAo)t[r]=(i,n)=>H_a.create(i,W_a(e,n,{method:r}));return t.create=r=>Q5s(W_a(r)),t.extend=r=>(typeof r=="function"&&(r=r(e??{})),Q5s(W_a(e,r))),t.stop=AAo,t},gpD=Q5s(),NTp=gpD;var uCp=li(oCp(),1);function Z5s(e){let t=(0,uCp.default)("npm",{registry:"https://registry.npmjs.org/"}),r=t[`${e}:registry`]||t.config_registry||t.registry;return r.slice(-1)==="/"?r:`${r}/`}var tBp=li(eBp(),1),rBp=li(dxi(),1),d9s=class extends Error{constructor(t){super(`Package \`${t}\` could not be found`),this.name="PackageNotFoundError"}},p9s=class extends Error{constructor(t,r){super(`Version \`${r}\` for package \`${t}\` could not be found`),this.name="VersionNotFoundError"}};async function _9s(e,t={}){let{version:r="latest"}=t,{omitDeprecated:i=!0}=t,n=e.split("/")[0],a=t.registryUrl??Z5s(n),u=new URL(encodeURIComponent(e).replace(/^%40/,"@"),a),l=(0,tBp.default)(a.toString(),{recursive:!0}),d={accept:"application/vnd.npm.install-v1+json; q=1.0, application/json; q=0.8, */*"};t.fullMetadata&&delete d.accept,l&&(d.authorization=`${l.type} ${l.token}`);let s;try{s=await NTp(u,{headers:d,keepalive:!0}).json()}catch(c){throw c?.response?.status===404?new d9s(e):c}if(t.allVersions)return s;let o=new p9s(e,r);if(s["dist-tags"][r]){let{time:c}=s;s=s.versions[s["dist-tags"][r]],s.time=c}else if(r){let c=!!s.versions[r];if(i&&!c)for(let[g,O]of Object.entries(s.versions))O.deprecated&&delete s.versions[g];if(!c){let g=Object.keys(s.versions);if(r=rBp.default.maxSatisfying(g,r),!r)throw o}let{time:b}=s;if(s=s.versions[r],s.time=b,!s)throw o}return s}async function Y_a(e,t){let{version:r}=await _9s(e.toLowerCase(),t);return r}async function Gdi({cliEnvironment:e,includePreReleases:t=!1}){return e.packageName!=="fern-api"?e.packageVersion:Y_a(e.packageName,{version:t?"prerelease":"latest"})}var iBp=["#2E86AB","#A23B72","#F18F01","#C73E1D","#CCE2A3"],UAo=class{environment;didSucceed=!0;numTasks=0;ttyAwareLogger;logLevel=H0.Info;constructor(t){this.ttyAwareLogger=new wAo(t);let r=this.getPackageName(),i=this.getPackageVersion(),n=this.getCliName();(r==null||i==null||n==null)&&this.exitProgram(),this.environment={packageName:r,packageVersion:i,cliName:n}}getPackageName(){return"fern-api"}getPackageVersion(){return"0.58.0-rc1"}getCliName(){return"fern"}setLogLevel(t){this.logLevel=t}logDebugInfo(){this.logger.debug(`Running ${Ws.bold(`${this.environment.cliName}`)} (${this.environment.packageName}@${this.environment.packageVersion})`)}failAndThrow(t,r){throw this.failWithoutThrowing(t,r),new pre}failWithoutThrowing(t,r){this.didSucceed=!1,OAo({message:t,error:r,logger:this.logger})}async exit(){this._suppressUpgradeMessage||await this.nudgeUpgradeIfAvailable(),this.ttyAwareLogger.finish(),await(await iPn()).flush(),this.exitProgram()}async nudgeUpgradeIfAvailable(){try{let t=await Promise.race([this.isUpgradeAvailable(),new Promise((i,n)=>setTimeout(()=>n("Request timed out"),300))]),r=await wTp({cliEnvironment:this.environment,upgradeInfo:t});r!=null&&(r.endsWith(`
|
|
1944
1944
|
`)||(r+=`
|
|
1945
1945
|
`),this.logger.info(r))}catch{}}async exitIfFailed(){this.didSucceed||await this.exit()}exitProgram(){process.exit(this.didSucceed?0:1)}longestWorkspaceName;registerWorkspaces(t){let r=p_s(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 I_a(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 pre}finally{i.finish()}return n}async instrumentPostHogEvent(t){(await iPn()).sendEvent(t)}logger=PQr(this.log.bind(this));constructTaskInitForWorkspace(t){let r=nBp(t.type==="docs"?"docs":t.workspaceName??"api"),i=1+(this.longestWorkspaceName!=null?nBp(this.longestWorkspaceName):r).length,n=r.padEnd(i),a=iBp[this.numTasks++%iBp.length],u=Ws.hex(a)(n);return{...this.constructTaskInit(),logPrefix:u}}constructTaskInit(){return{logImmediately:t=>this.logImmediately(t),takeOverTerminal:t=>this.ttyAwareLogger.takeOverTerminal(t),onResult:t=>{t===xC.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}])}logImmediately(t){let r=t.filter(i=>dsi.indexOf(i.level)>=dsi.indexOf(this.logLevel));this.ttyAwareLogger.log(r,{includeDebugInfo:this.logLevel===H0.Debug})}_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 Gdi({cliEnvironment:this.environment,includePreReleases:t}),i=Kie(r,this.environment.packageVersion);this.logger.debug(`Latest version: ${r}. `+(i?"Upgrade available.":"No upgrade available."));let n={isUpgradeAvailable:i,latestVersion:r},a=await SAo({project:this.project,cliContext:this});this._isUpgradeAvailable={cliUpgradeInfo:n,generatorUpgradeInfo:a}}return this._isUpgradeAvailable}async confirmPrompt(t,r=!1){return await w5s({message:t,default:r})}async getInput(t){return await S5s({message:t.message,default:t.default})}};function nBp(e){return`[${e}]:`}var CGp=require("fs/promises");function Yie({breadcrumbs:e=[],title:t,subtitle:r}){let i=[];return e.length>0&&i.push(Ws.blue(e.join(" -> "))),i.push(t),r!=null&&i.push(Ws.dim(r)),i.join(`
|
|
1946
1946
|
`)}var CLp=require("fs/promises");var X5t=class{generatorsConfiguration;workspaceName;cliVersion;absoluteFilePath;changelog;constructor({generatorsConfiguration:t,workspaceName:r,cliVersion:i,absoluteFilePath:n,changelog:a}){this.generatorsConfiguration=t,this.workspaceName=r,this.cliVersion=i,this.absoluteFilePath=n,this.changelog=a}};var vDe=class extends X5t{definition;sources;type="fern";constructor({definition:t,sources:r,...i}){super(i),this.definition=t,this.sources=r??[]}async getDefinition(){return this.definition}async toFernWorkspace(){return this}getSources(){return this.sources}getAbsoluteFilePaths(){return[this.absoluteFilePath]}};var X_a=class{context;constructor(t){this.context=t}};var VAo=class e{files={};directories={};getAllFiles(){let t={},r=(i,n)=>{for(let[u,l]of Object.entries(i.files)){let d=n!=null?Yh.of(`${n}${c8t}${u}`):Yh.of(u);t[d]=l}let a=Object.keys(i.directories).sort();for(let u of a){let l=n!=null?`${n}${c8t}${u}`:u,d=i.directories[u];r(d,l)}};return r(this),t}getOrCreateFile(t){return this.getOrCreateFileRecursive(t.split(c8t))}getOrCreateFileRecursive(t){if(t.length===1)return this.files[Yh.of(t[0])]??={};let[r,...i]=t;if(r==null)throw new Error(`Internal error; cannot add file with path: ${t}`);return this.directories[r]||(this.directories[r]=new e),this.directories[r].getOrCreateFileRecursive(i)}};var fNi=class{enableUniqueErrorsPerEndpoint;root;rootApiFile;packageMarkerFile={};basePath=void 0;constructor(t){this.enableUniqueErrorsPerEndpoint=t,this.root=new VAo,this.rootApiFile={name:"api","error-discrimination":{strategy:"status-code"}}}setDisplayName({displayName:t}){this.rootApiFile["display-name"]=t}addNavigation({navigation:t}){this.packageMarkerFile.navigation=t}setServiceInfo(t,{auth:r,"base-path":i,"display-name":n,docs:a}){let u=this.getOrCreateFile(t);u.service==null&&(u.service={auth:!1,"base-path":"",endpoints:{}}),r!=null&&(u.service.auth=r),i!=null&&(u.service["base-path"]=i),n!=null&&(u.service["display-name"]=n),a!=null&&(u.docs=a)}addAudience(t){this.rootApiFile.audiences==null&&(this.rootApiFile.audiences=[]),this.rootApiFile.audiences.push(t)}setAuth(t){this.rootApiFile.auth=t}addAuthScheme({name:t,schema:r}){this.rootApiFile["auth-schemes"]==null&&(this.rootApiFile["auth-schemes"]={}),this.rootApiFile["auth-schemes"][t]==null&&(this.rootApiFile["auth-schemes"][t]=r)}setDefaultEnvironment(t){this.rootApiFile["default-environment"]=t}setDefaultUrl(t){this.rootApiFile["default-url"]=t}setBasePath(t){this.basePath=t}setApiVersion(t){this.rootApiFile.version=t}getEnvironmentType(){let t=Object.entries(this.rootApiFile.environments??{})[0];if(t!=null)return GQr(t[1],{singleBaseUrl:()=>"single",multipleBaseUrls:()=>"multi"})}addEnvironment({name:t,schema:r}){this.rootApiFile.environments==null&&(this.rootApiFile.environments={}),this.rootApiFile.environments[t]=r}getGlobalHeaderNames(){let t=Object.keys(this.rootApiFile.headers??{});if(this.rootApiFile["auth-schemes"]!=null)for(let i of Object.values(this.rootApiFile["auth-schemes"]))w_D(i)&&t.push(i.header);let r=this.getVersionHeader();return r!=null&&t.push(r),new Set(t)}addGlobalHeader({name:t,schema:r}){let i=this.getVersionHeader();i!=null&&i===t||(this.rootApiFile.headers==null&&(this.rootApiFile.headers={}),this.rootApiFile.headers[t]=r)}addIdempotencyHeader({name:t,schema:r}){this.rootApiFile["idempotency-headers"]==null&&(this.rootApiFile["idempotency-headers"]={}),this.rootApiFile["idempotency-headers"][t]=r}addVariable({name:t,schema:r}){this.rootApiFile.variables==null&&(this.rootApiFile.variables={}),this.rootApiFile.variables[t]=r}addImport({file:t,fileToImport:r,alias:i}){if(t===r)return;let n=i??V0((nxe(r)+"/"+aBi(r,{stripExtension:!0})).replaceAll("__package__","root"));if(t===Yh.of(YN))return this.rootApiFile.imports==null&&(this.rootApiFile.imports={}),this.rootApiFile.imports[n]=yto(nxe(uvn.of(`/${t}`)),uvn.of(`/${r}`)),n;let a=this.getOrCreateFile(t);return a.imports==null&&(a.imports={}),a.imports[n]=yto(nxe(uvn.of(`/${t}`)),uvn.of(`/${r}`)),n}addType(t,{name:r,schema:i}){if(t===Yh.of(YN))return;let n=this.getOrCreateFile(t);n.types==null&&(n.types={}),n.types[r]=i}addTypeExample(t,r,i){let n=this.getOrCreateFile(t);n.types==null&&(n.types={});let a=n.types[r];a!=null&&(typeof a=="string"?n.types[r]={type:a,examples:[i]}:(a.examples==null&&(a.examples=[]),a.examples.push(i)))}addError(t,{name:r,schema:i}){let n=this.getOrCreateFile(t);n.errors==null&&(n.errors={}),n.errors[r]==null?n.errors[r]=i:n.errors[r]?.type!==i.type&&(n.errors[r]={"status-code":i["status-code"],type:"unknown"})}addErrorExample(t,{name:r,example:i}){let n=this.getOrCreateFile(t);if(n.errors==null)return;let a=n.errors[r];if(a==null)return;a.examples==null&&(a.examples=[]),(a.examples.some(l=>dSe(l,i))??!1)||a.examples?.push(i)}addEndpoint(t,{name:r,schema:i,source:n}){let a=this.getOrCreateFile(t);a.service==null&&(a.service={auth:!1,"base-path":"",endpoints:{}}),n!=null&&(a.service.source=n),a.service.endpoints[r]=i}addWebhook(t,{name:r,schema:i}){let n=this.getOrCreateFile(t);n.webhooks==null&&(n.webhooks={}),n.webhooks[r]=i}addChannel(t,{channel:r}){let i=this.getOrCreateFile(t);i.channel=r;let n=this.basePath;n!=null&&(i.channel.path=zR(n,r.path))}addChannelExample(t,{example:r}){let i=this.getOrCreateFile(t);i.channel==null&&(i.channel={path:"",auth:!1}),i.channel.messages==null&&(i.channel.messages={}),i.channel.examples==null&&(i.channel.examples=[]),i.channel.examples.push(r)}addChannelMessage(t,{messageId:r,message:i}){let n=this.getOrCreateFile(t);n.channel==null&&(n.channel={path:"",auth:!1}),n.channel.messages==null&&(n.channel.messages={}),n.channel.messages[r]=i}build(){let t=this.root.getAllFiles(),r=this.basePath;if(r!=null){this.packageMarkerFile.service!=null&&(this.packageMarkerFile.service={...this.packageMarkerFile.service,endpoints:Object.fromEntries(Object.entries(this.packageMarkerFile.service.endpoints).map(([n,a])=>[n,{...a,path:zR(r,a.path)}]))});for(let n of Object.values(t))n.service!=null&&(n.service={...n.service,endpoints:Object.fromEntries(Object.entries(n.service.endpoints).map(([a,u])=>[a,{...u,path:zR(r,u.path)}]))})}return{rootApiFile:this.rootApiFile,packageMarkerFile:this.packageMarkerFile,definitionFiles:t}}getOrCreateFile(t){return t===rS?this.packageMarkerFile:this.root.getOrCreateFile(t)}getVersionHeader(){if(this.rootApiFile.version!=null)return typeof this.rootApiFile.version.header=="string"?this.rootApiFile.version.header:this.rootApiFile.version.header.value}};function w_D(e){return e?.header!=null}var Xie={openapi:e=>({...e,type:"openapi",_visit:function(t){return Xie._visit(this,t)}}),protobuf:e=>({...e,type:"protobuf",_visit:function(t){return Xie._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"openapi":return t.openapi(e);case"protobuf":return t.protobuf(e);default:return t._other(e)}}};var k1n={protobuf:e=>({...e,type:"protobuf",_visit:function(t){return k1n._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"protobuf":return t.protobuf(e);default:return t._other(e)}}};var F5={basic:e=>({...e,type:"basic",_visit:function(t){return F5._visit(this,t)}}),bearer:e=>({...e,type:"bearer",_visit:function(t){return F5._visit(this,t)}}),header:e=>({...e,type:"header",_visit:function(t){return F5._visit(this,t)}}),query:e=>({...e,type:"query",_visit:function(t){return F5._visit(this,t)}}),oauth:e=>({...e,type:"oauth",_visit:function(t){return F5._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"basic":return t.basic(e);case"bearer":return t.bearer(e);case"header":return t.header(e);case"query":return t.query(e);case"oauth":return t.oauth(e);default:return t._other(e)}}};var Qg={primitive:e=>({value:e,type:"primitive",_visit:function(t){return Qg._visit(this,t)}}),object:e=>({...e,type:"object",_visit:function(t){return Qg._visit(this,t)}}),array:e=>({value:e,type:"array",_visit:function(t){return Qg._visit(this,t)}}),map:e=>({value:e,type:"map",_visit:function(t){return Qg._visit(this,t)}}),enum:e=>({value:e,type:"enum",_visit:function(t){return Qg._visit(this,t)}}),literal:e=>({value:e,type:"literal",_visit:function(t){return Qg._visit(this,t)}}),oneOf:e=>({value:e,type:"oneOf",_visit:function(t){return Qg._visit(this,t)}}),unknown:e=>({value:e,type:"unknown",_visit:function(t){return Qg._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"primitive":return t.primitive(e.value);case"object":return t.object(e);case"array":return t.array(e.value);case"map":return t.map(e.value);case"enum":return t.enum(e.value);case"literal":return t.literal(e.value);case"oneOf":return t.oneOf(e.value);case"unknown":return t.unknown(e.value);default:return t._other(e)}}};var c_={int:e=>({value:e,type:"int",_visit:function(t){return c_._visit(this,t)}}),int64:e=>({value:e,type:"int64",_visit:function(t){return c_._visit(this,t)}}),uint:e=>({value:e,type:"uint",_visit:function(t){return c_._visit(this,t)}}),uint64:e=>({value:e,type:"uint64",_visit:function(t){return c_._visit(this,t)}}),float:e=>({value:e,type:"float",_visit:function(t){return c_._visit(this,t)}}),double:e=>({value:e,type:"double",_visit:function(t){return c_._visit(this,t)}}),string:e=>({value:e,type:"string",_visit:function(t){return c_._visit(this,t)}}),datetime:e=>({value:e,type:"datetime",_visit:function(t){return c_._visit(this,t)}}),date:e=>({value:e,type:"date",_visit:function(t){return c_._visit(this,t)}}),base64:e=>({value:e,type:"base64",_visit:function(t){return c_._visit(this,t)}}),boolean:e=>({value:e,type:"boolean",_visit:function(t){return c_._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"int":return t.int(e.value);case"int64":return t.int64(e.value);case"uint":return t.uint(e.value);case"uint64":return t.uint64(e.value);case"float":return t.float(e.value);case"double":return t.double(e.value);case"string":return t.string(e.value);case"datetime":return t.datetime(e.value);case"date":return t.date(e.value);case"base64":return t.base64(e.value);case"boolean":return t.boolean(e.value);default:return t._other(e)}}};var eSn={boolean:e=>({value:e,type:"boolean",_visit:function(t){return eSn._visit(this,t)}}),string:e=>({value:e,type:"string",_visit:function(t){return eSn._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"boolean":return t.boolean(e.value);case"string":return t.string(e.value);default:return t._other(e)}}};var Qdi={discriminated:e=>({value:e,type:"discriminated",_visit:function(t){return Qdi._visit(this,t)}}),undiscriminated:e=>({value:e,type:"undiscriminated",_visit:function(t){return Qdi._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"discriminated":return t.discriminated(e.value);case"undiscriminated":return t.undiscriminated(e.value);default:return t._other(e)}}};var AV={GenerallyAvailable:"GenerallyAvailable",Beta:"Beta",Deprecated:"Deprecated",_visit:(e,t)=>{switch(e){case AV.GenerallyAvailable:return t.generallyAvailable();case AV.Beta:return t.beta();case AV.Deprecated:return t.deprecated();default:return t._other()}}};var Hze={cursor:e=>({...e,type:"cursor",_visit:function(t){return Hze._visit(this,t)}}),offset:e=>({...e,type:"offset",_visit:function(t){return Hze._visit(this,t)}}),custom:e=>({...e,type:"custom",_visit:function(t){return Hze._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"cursor":return t.cursor(e);case"offset":return t.offset(e);case"custom":return t.custom(e);default:return t._other(e)}}};var MKr={language:e=>({...e,type:"language",_visit:function(t){return MKr._visit(this,t)}}),sdk:e=>({...e,type:"sdk",_visit:function(t){return MKr._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"language":return t.language(e);case"sdk":return t.sdk(e);default:return t._other(e)}}};var qV={Curl:"curl",Python:"python",Javascript:"javascript",Typescript:"typescript",Go:"go",Ruby:"ruby",Csharp:"csharp",Java:"java",Js:"js",Node:"node",Ts:"ts",Nodets:"nodets",Golang:"golang",Dotnet:"dotnet",Jvm:"jvm",_visit:(e,t)=>{switch(e){case qV.Curl:return t.curl();case qV.Python:return t.python();case qV.Javascript:return t.javascript();case qV.Typescript:return t.typescript();case qV.Go:return t.go();case qV.Ruby:return t.ruby();case qV.Csharp:return t.csharp();case qV.Java:return t.java();case qV.Js:return t.js();case qV.Node:return t.node();case qV.Ts:return t.ts();case qV.Nodets:return t.nodets();case qV.Golang:return t.golang();case qV.Dotnet:return t.dotnet();case qV.Jvm:return t.jvm();default:return t._other()}}};var Z5t={unknown:e=>({value:e,type:"unknown",_visit:function(t){return Z5t._visit(this,t)}}),full:e=>({...e,type:"full",_visit:function(t){return Z5t._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"unknown":return t.unknown(e.value);case"full":return t.full(e);default:return t._other(e)}}};var k5t={withStreaming:e=>({...e,type:"withStreaming",_visit:function(t){return k5t._visit(this,t)}}),withoutStreaming:e=>({value:e,type:"withoutStreaming",_visit:function(t){return k5t._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"withStreaming":return t.withStreaming(e);case"withoutStreaming":return t.withoutStreaming(e.value);default:return t._other(e)}}};var CG={Get:"GET",Post:"POST",Put:"PUT",Patch:"PATCH",Delete:"DELETE",Head:"HEAD",Options:"OPTIONS",Trace:"TRACE",_visit:(e,t)=>{switch(e){case CG.Get:return t.get();case CG.Post:return t.post();case CG.Put:return t.put();case CG.Patch:return t.patch();case CG.Delete:return t.delete();case CG.Head:return t.head();case CG.Options:return t.options();case CG.Trace:return t.trace();default:return t._other()}}};var Jdi={octetStream:e=>({...e,type:"octetStream",_visit:function(t){return Jdi._visit(this,t)}}),multipart:e=>({...e,type:"multipart",_visit:function(t){return Jdi._visit(this,t)}}),json:e=>({...e,type:"json",_visit:function(t){return Jdi._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"octetStream":return t.octetStream(e);case"multipart":return t.multipart(e);case"json":return t.json(e);default:return t._other(e)}}};var AKr={file:e=>({...e,type:"file",_visit:function(t){return AKr._visit(this,t)}}),json:e=>({value:e,type:"json",_visit:function(t){return AKr._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"file":return t.file(e);case"json":return t.json(e.value);default:return t._other(e)}}};var BG={file:e=>({...e,type:"file",_visit:function(t){return BG._visit(this,t)}}),json:e=>({...e,type:"json",_visit:function(t){return BG._visit(this,t)}}),text:e=>({...e,type:"text",_visit:function(t){return BG._visit(this,t)}}),bytes:e=>({...e,type:"bytes",_visit:function(t){return BG._visit(this,t)}}),streamingSse:e=>({...e,type:"streamingSse",_visit:function(t){return BG._visit(this,t)}}),streamingText:e=>({...e,type:"streamingText",_visit:function(t){return BG._visit(this,t)}}),streamingJson:e=>({...e,type:"streamingJson",_visit:function(t){return BG._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"file":return t.file(e);case"json":return t.json(e);case"text":return t.text(e);case"bytes":return t.bytes(e);case"streamingSse":return t.streamingSse(e);case"streamingText":return t.streamingText(e);case"streamingJson":return t.streamingJson(e);default:return t._other(e)}}};var my={primitive:e=>({...e,type:"primitive",_visit:function(t){return my._visit(this,t)}}),object:e=>({...e,type:"object",_visit:function(t){return my._visit(this,t)}}),array:e=>({...e,type:"array",_visit:function(t){return my._visit(this,t)}}),map:e=>({...e,type:"map",_visit:function(t){return my._visit(this,t)}}),optional:e=>({...e,type:"optional",_visit:function(t){return my._visit(this,t)}}),enum:e=>({...e,type:"enum",_visit:function(t){return my._visit(this,t)}}),reference:e=>({...e,type:"reference",_visit:function(t){return my._visit(this,t)}}),literal:e=>({...e,type:"literal",_visit:function(t){return my._visit(this,t)}}),oneOf:e=>({value:e,type:"oneOf",_visit:function(t){return my._visit(this,t)}}),nullable:e=>({...e,type:"nullable",_visit:function(t){return my._visit(this,t)}}),unknown:e=>({...e,type:"unknown",_visit:function(t){return my._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"primitive":return t.primitive(e);case"object":return t.object(e);case"array":return t.array(e);case"map":return t.map(e);case"optional":return t.optional(e);case"enum":return t.enum(e);case"reference":return t.reference(e);case"literal":return t.literal(e);case"oneOf":return t.oneOf(e.value);case"nullable":return t.nullable(e);case"unknown":return t.unknown(e);default:return t._other(e)}}};var Pj={int:e=>({...e,type:"int",_visit:function(t){return Pj._visit(this,t)}}),int64:e=>({...e,type:"int64",_visit:function(t){return Pj._visit(this,t)}}),uint:()=>({type:"uint",_visit:function(e){return Pj._visit(this,e)}}),uint64:()=>({type:"uint64",_visit:function(e){return Pj._visit(this,e)}}),float:()=>({type:"float",_visit:function(e){return Pj._visit(this,e)}}),double:e=>({...e,type:"double",_visit:function(t){return Pj._visit(this,t)}}),string:e=>({...e,type:"string",_visit:function(t){return Pj._visit(this,t)}}),datetime:()=>({type:"datetime",_visit:function(e){return Pj._visit(this,e)}}),date:()=>({type:"date",_visit:function(e){return Pj._visit(this,e)}}),base64:()=>({type:"base64",_visit:function(e){return Pj._visit(this,e)}}),boolean:e=>({...e,type:"boolean",_visit:function(t){return Pj._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"int":return t.int(e);case"int64":return t.int64(e);case"uint":return t.uint();case"uint64":return t.uint64();case"float":return t.float();case"double":return t.double(e);case"string":return t.string(e);case"datetime":return t.datetime();case"date":return t.date();case"base64":return t.base64();case"boolean":return t.boolean(e);default:return t._other(e)}}};var jx={boolean:e=>({value:e,type:"boolean",_visit:function(t){return jx._visit(this,t)}}),string:e=>({value:e,type:"string",_visit:function(t){return jx._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"boolean":return t.boolean(e.value);case"string":return t.string(e.value);default:return t._other(e)}}};var qKr={discriminated:e=>({...e,type:"discriminated",_visit:function(t){return qKr._visit(this,t)}}),undiscriminated:e=>({...e,type:"undiscriminated",_visit:function(t){return qKr._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"discriminated":return t.discriminated(e);case"undiscriminated":return t.undiscriminated(e);default:return t._other(e)}}};var bDe={octetStream:e=>({...e,type:"octetStream",_visit:function(t){return bDe._visit(this,t)}}),multipart:e=>({...e,type:"multipart",_visit:function(t){return bDe._visit(this,t)}}),json:e=>({...e,type:"json",_visit:function(t){return bDe._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"octetStream":return t.octetStream(e);case"multipart":return t.multipart(e);case"json":return t.json(e);default:return t._other(e)}}};var wT={file:e=>({...e,type:"file",_visit:function(t){return wT._visit(this,t)}}),json:e=>({...e,type:"json",_visit:function(t){return wT._visit(this,t)}}),text:e=>({...e,type:"text",_visit:function(t){return wT._visit(this,t)}}),bytes:e=>({...e,type:"bytes",_visit:function(t){return wT._visit(this,t)}}),streamingSse:e=>({...e,type:"streamingSse",_visit:function(t){return wT._visit(this,t)}}),streamingText:e=>({...e,type:"streamingText",_visit:function(t){return wT._visit(this,t)}}),streamingJson:e=>({...e,type:"streamingJson",_visit:function(t){return wT._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"file":return t.file(e);case"json":return t.json(e);case"text":return t.text(e);case"bytes":return t.bytes(e);case"streamingSse":return t.streamingSse(e);case"streamingText":return t.streamingText(e);case"streamingJson":return t.streamingJson(e);default:return t._other(e)}}};var Cl={primitive:e=>({...e,type:"primitive",_visit:function(t){return Cl._visit(this,t)}}),object:e=>({...e,type:"object",_visit:function(t){return Cl._visit(this,t)}}),array:e=>({...e,type:"array",_visit:function(t){return Cl._visit(this,t)}}),map:e=>({...e,type:"map",_visit:function(t){return Cl._visit(this,t)}}),optional:e=>({...e,type:"optional",_visit:function(t){return Cl._visit(this,t)}}),enum:e=>({...e,type:"enum",_visit:function(t){return Cl._visit(this,t)}}),reference:e=>({...e,type:"reference",_visit:function(t){return Cl._visit(this,t)}}),literal:e=>({...e,type:"literal",_visit:function(t){return Cl._visit(this,t)}}),oneOf:e=>({value:e,type:"oneOf",_visit:function(t){return Cl._visit(this,t)}}),nullable:e=>({...e,type:"nullable",_visit:function(t){return Cl._visit(this,t)}}),unknown:e=>({...e,type:"unknown",_visit:function(t){return Cl._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"primitive":return t.primitive(e);case"object":return t.object(e);case"array":return t.array(e);case"map":return t.map(e);case"optional":return t.optional(e);case"enum":return t.enum(e);case"reference":return t.reference(e);case"literal":return t.literal(e);case"oneOf":return t.oneOf(e.value);case"nullable":return t.nullable(e);case"unknown":return t.unknown(e);default:return t._other(e)}}};var yX={discriminated:e=>({...e,type:"discriminated",_visit:function(t){return yX._visit(this,t)}}),undiscriminated:e=>({...e,type:"undiscriminated",_visit:function(t){return yX._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"discriminated":return t.discriminated(e);case"undiscriminated":return t.undiscriminated(e);default:return t._other(e)}}};var up={int:e=>({...e,type:"int",_visit:function(t){return up._visit(this,t)}}),int64:e=>({...e,type:"int64",_visit:function(t){return up._visit(this,t)}}),uint:e=>({...e,type:"uint",_visit:function(t){return up._visit(this,t)}}),uint64:e=>({...e,type:"uint64",_visit:function(t){return up._visit(this,t)}}),float:e=>({...e,type:"float",_visit:function(t){return up._visit(this,t)}}),double:e=>({...e,type:"double",_visit:function(t){return up._visit(this,t)}}),string:e=>({...e,type:"string",_visit:function(t){return up._visit(this,t)}}),datetime:e=>({...e,type:"datetime",_visit:function(t){return up._visit(this,t)}}),date:e=>({...e,type:"date",_visit:function(t){return up._visit(this,t)}}),base64:e=>({...e,type:"base64",_visit:function(t){return up._visit(this,t)}}),boolean:e=>({...e,type:"boolean",_visit:function(t){return up._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"int":return t.int(e);case"int64":return t.int64(e);case"uint":return t.uint(e);case"uint64":return t.uint64(e);case"float":return t.float(e);case"double":return t.double(e);case"string":return t.string(e);case"datetime":return t.datetime(e);case"date":return t.date(e);case"base64":return t.base64(e);case"boolean":return t.boolean(e);default:return t._other(e)}}};var cv={};jo(cv,{AllOfPropertyConflict:()=>jSn,ArraySchema:()=>nTo,ArraySchemaWithExample:()=>CTo,Availability:()=>ZAo,Base64WithExample:()=>ETo,BasicSecurityScheme:()=>tqo,BearerSecurityScheme:()=>rqo,BooleanSchema:()=>Zqo,BooleanWithExample:()=>MTo,BytesResponse:()=>_Sn,CasingOverrides:()=>aqo,CommonProperty:()=>dTo,CommonPropertyWithExample:()=>UTo,CursorPagination:()=>Iqo,CustomCodeSample:()=>Bqo,CustomCodeSampleLanguage:()=>qqo,CustomCodeSampleSdk:()=>Cqo,CustomPagination:()=>Rqo,DateWithExample:()=>DTo,DatetimeWithExample:()=>STo,DiscriminatedOneOfSchema:()=>lTo,DiscriminatedOneOfSchemaWithExample:()=>FTo,DoubleSchema:()=>Yqo,DoubleWithExample:()=>jTo,Encoding:()=>XAo,Endpoint:()=>Nqo,EndpointExample:()=>bSn,EndpointResponseExample:()=>Aqo,EndpointSdkName:()=>xXt,EndpointWithExample:()=>xBp,EnumSchema:()=>nSn,EnumSchemaWithExample:()=>qTo,EnumValue:()=>Xdi,ErrorExample:()=>wqo,FernExample:()=>Dqo,FileResponse:()=>dSn,FileSchema:()=>vqo,FloatWithExample:()=>PTo,FullEndpointExample:()=>xqo,FullExample:()=>tq,FullObjectExample:()=>dqo,FullOneOfExample:()=>_qo,GlobalHeader:()=>eTo,Header:()=>kdi,HeaderExample:()=>vSn,HeaderSecurityScheme:()=>iqo,HeaderWithExample:()=>rpi,HttpEndpointServer:()=>hSn,HttpError:()=>Sqo,HttpErrorWithExample:()=>vTo,HttpMethod:()=>uSn,IdempotencyHeader:()=>tTo,Int64WithExample:()=>gTo,IntSchema:()=>Jqo,IntWithExample:()=>bTo,JsonRequest:()=>mqo,JsonRequestWithExample:()=>_To,JsonResponse:()=>pSn,JsonResponseWithExample:()=>DSn,KeyValuePair:()=>pqo,LiteralExample:()=>fqo,LiteralSchema:()=>PSn,LiteralSchemaValue:()=>rTo,LongSchema:()=>Kqo,MapSchema:()=>aTo,MapSchemaWithExample:()=>BTo,MultipartRequest:()=>fSn,MultipartRequestProperty:()=>Oqo,MultipartRequestPropertyEncoding:()=>gqo,MultipartSchema:()=>bqo,NamedFullExample:()=>zXt,Namespace:()=>oqo,NamespaceId:()=>lqo,NullableSchema:()=>uTo,NullableSchemaWithExample:()=>ITo,OauthSecurityScheme:()=>sqo,ObjectProperty:()=>cTo,ObjectPropertyConflictInfo:()=>wSn,ObjectPropertyWithExample:()=>NTo,ObjectSchema:()=>iTo,ObjectSchemaWithExample:()=>zTo,OctetStreamRequest:()=>lSn,OffsetPagination:()=>zqo,OneOfSchema:()=>sTo,OneOfSchemaWithExample:()=>RTo,OpenApiIntermediateRepresentation:()=>CBp,OpenApiSource:()=>QAo,OptionalSchema:()=>oTo,OptionalSchemaWithExample:()=>xTo,Pagination:()=>gSn,PathParameter:()=>sSn,PathParameterExample:()=>Eqo,PathParameterWithExample:()=>pTo,PrimitiveExample:()=>oSn,PrimitiveSchema:()=>tpi,PrimitiveSchemaValue:()=>kqo,PrimitiveSchemaValueWithExample:()=>ATo,PrimitiveSchemaWithExample:()=>ESn,PropertyKey:()=>aSn,ProtobufEncoding:()=>YAo,ProtobufSource:()=>JAo,QueryParameter:()=>cSn,QueryParameterExample:()=>ySn,QueryParameterWithExample:()=>SSn,QuerySecurityScheme:()=>nqo,ReferencedSchema:()=>IXt,Request:()=>Pqo,RequestWithExample:()=>hTo,Response:()=>jqo,ResponseWithExample:()=>yTo,Schema:()=>XO,SchemaId:()=>vX,SchemaWithExample:()=>CM,Schemas:()=>Qqo,SdkGroup:()=>uqo,SdkGroupInfo:()=>hqo,SdkGroupName:()=>Zdi,SecurityScheme:()=>cqo,SecuritySchemeId:()=>eqo,Server:()=>tha,Source:()=>KAo,StatusCode:()=>CXt,StreamingResponseExample:()=>Mqo,StringSchema:()=>Xqo,StringSchemaWithExample:()=>wTo,SupportedSdkLanguage:()=>Tqo,Tag:()=>kAo,TagId:()=>bX,Tags:()=>yqo,TextResponse:()=>epi,Uint64WithExample:()=>mTo,UintWithExample:()=>OTo,UnDiscriminatedOneOfSchema:()=>fTo,UnDiscriminatedOneOfSchemaWithExample:()=>LTo,UnknownSchemaWithExample:()=>TTo,Webhook:()=>Fqo,WebhookExampleCall:()=>mSn,WebhookHttpMethod:()=>OSn,WebhookWithExample:()=>IBp,WebsocketChannel:()=>Gqo,WebsocketHandshake:()=>Lqo,WebsocketHandshakeWithExample:()=>BBp,WebsocketMessageExample:()=>Hqo,WebsocketMessageOrigin:()=>Uqo,WebsocketMessageSchema:()=>Vqo,WebsocketServer:()=>Wqo,WebsocketSessionExample:()=>$qo,WithAvailability:()=>ph,WithDescription:()=>pf,WithEncoding:()=>Zie,WithInline:()=>pE,WithName:()=>o0,WithNamespace:()=>BXt,WithSdkGroupName:()=>zO,WithSource:()=>qh,WithStatusCode:()=>$ze,WithTitle:()=>IO,commons:()=>g9s,example:()=>O9s,finalIr:()=>m9s,parseIr:()=>P9s});var g9s={};jo(g9s,{BasicSecurityScheme:()=>tqo,BearerSecurityScheme:()=>rqo,Encoding:()=>XAo,HeaderSecurityScheme:()=>iqo,Namespace:()=>oqo,NamespaceId:()=>lqo,OauthSecurityScheme:()=>sqo,OpenApiSource:()=>QAo,ProtobufEncoding:()=>YAo,ProtobufSource:()=>JAo,QuerySecurityScheme:()=>nqo,SchemaId:()=>vX,SdkGroup:()=>uqo,SdkGroupName:()=>Zdi,SecurityScheme:()=>cqo,SecuritySchemeId:()=>eqo,Server:()=>tha,Source:()=>KAo,StatusCode:()=>CXt,Tag:()=>kAo,TagId:()=>bX,WithAvailability:()=>ph,WithDescription:()=>pf,WithEncoding:()=>Zie,WithInline:()=>pE,WithName:()=>o0,WithNamespace:()=>BXt,WithSdkGroupName:()=>zO,WithSource:()=>qh,WithStatusCode:()=>$ze,WithTitle:()=>IO});var At={};jo(At,{JsonError:()=>tSn,ParseError:()=>rSn,any:()=>gBp,bigint:()=>oBp,boolean:()=>OBp,booleanLiteral:()=>bBp,date:()=>uBp,discriminant:()=>ABp,enum_:()=>HAo,getObjectLikeUtils:()=>e9t,getObjectUtils:()=>dNi,getSchemaUtils:()=>eq,isProperty:()=>Ydi,lazy:()=>sBp,lazyObject:()=>hBp,list:()=>GAo,number:()=>mBp,object:()=>$Ao,objectWithoutOptionalProperties:()=>_Bp,optional:()=>h9s,property:()=>lBp,record:()=>SBp,set:()=>DBp,string:()=>PBp,stringLiteral:()=>vBp,transform:()=>y9s,undiscriminatedUnion:()=>MBp,union:()=>TBp,unknown:()=>jBp,withParsedProperties:()=>b9s});var kP={BIGINT:"bigint",DATE:"date",ENUM:"enum",LIST:"list",STRING_LITERAL:"stringLiteral",BOOLEAN_LITERAL:"booleanLiteral",OBJECT:"object",ANY:"any",BOOLEAN:"boolean",NUMBER:"number",STRING:"string",UNKNOWN:"unknown",RECORD:"record",SET:"set",UNION:"union",UNDISCRIMINATED_UNION:"undiscriminatedUnion",OPTIONAL:"optional"};function TM(e,t){return`Expected ${t}. Received ${S_D(e)}.`}function S_D(e){if(Array.isArray(e))return"list";if(e===null)return"null";if(e instanceof BigInt)return"BigInt";switch(typeof e){case"string":return`"${e}"`;case"bigint":case"number":case"boolean":case"undefined":return`${e}`}return typeof e}function L5(e){return{...e,json:aBp(e.json),parse:aBp(e.parse)}}function aBp(e){return(t,r)=>{let i=e(t,r),{skipValidation:n=!1}=r??{};return!i.ok&&n?(console.warn(["Failed to validate.",...i.errors.map(a=>" - "+(a.path.length>0?`${a.path.join(".")}: ${a.message}`:a.message))].join(`
|
|
@@ -2014,8 +2014,8 @@ Please wait while the installation completes. This may take a few minutes depend
|
|
|
2014
2014
|
`),i=t.start.column-1;for(let a=0;a<t.start.line-1;a++){let u=r[a];if(u==null)break;i+=u.length+1}let n=0-t.start.column+t.end.column;for(let a=t.start.line-1;a<t.end.line-1;a++){let u=r[a];if(u==null)break;n+=u.length+1}return{start:i,length:n}}function rhi(e){if(typeof e=="string")return e.replace(/#.*$/,"")}function uuE(e,t,r){for(let i of t){let n=e[i];if(n!=null){if(typeof n=="object")n.type==="fileId"&&(e[i]={type:"fileId",value:dAn.FernRegistry.FileId(r(n.value)??n.value)});else if(typeof n=="string"){let a=r(n);e[i]=a?{type:"fileId",value:dAn.FernRegistry.FileId(a)}:{type:"url",value:dAn.FernRegistry.Url(n)}}}}}var suE=Tu.union([Tu.string(),Tu.object({light:Tu.string().optional(),dark:Tu.string().optional()})]);function Mic(e,t){let r=t(e);return r?{type:"fileId",value:dAn.FernRegistry.FileId(r)}:{type:"url",value:dAn.FernRegistry.Url(e)}}function cuE(e,t){let r=suE.safeParse(e.logo);if(!r.success)return;let i=r.data;typeof i=="string"?e.logo=Mic(i,t):(i.light!=null&&(e.logo.light=Mic(i.light,t)),i.dark!=null&&(e.logo.dark=Mic(i.dark,t)))}var Rh_=require("fs/promises"),Nh_=li(kYt(),1);async function luE(e){let{content:t}=(0,Nh_.default)(await(0,Rh_.readFile)(e));return t}async function Tic({markdown:e,absolutePathToFernFolder:t,absolutePathToMarkdownFile:r,context:i,markdownLoader:n=luE}){if(!e.includes("<Markdown"))return e;let a=/([ \t]*)<Markdown\s+src={?['"]([^'"]+.mdx?)['"](?! \+)}?\s*\/>/g,u=e,l;for(;(l=a.exec(e))!=null;){let d=l[0],s=l[1],o=l[2];if(d==null||o==null)throw new Error(`Failed to parse regex "${l}" in ${r}`);let c=Fg(o.startsWith("/")?t:Zd(r),eo.of(o.replace(/^\//,"")));try{let b=await n(c);b=b.split(`
|
|
2015
2015
|
`).map(g=>s+g).join(`
|
|
2016
2016
|
`),u=u.replace(d,b)}catch{i.logger.warn(`Failed to read markdown file "${o}" referenced in ${r}`);break}}return u}async function x2o({domain:e,project:t,context:r,previousDocsDefinition:i,editedAbsoluteFilepaths:n}){let a=t.docsWorkspaces,u=t.apiWorkspaces;if(a==null)throw new Error("No docs workspace found in project");if(n!=null&&i!=null){let w=n.every(E=>E.endsWith(".mdx")||E.endsWith(".md"));for(let E of n){let A=QA(a.absoluteFilePath,E),q=(await(0,Fh_.readFile)(E)).toString(),D=await Tic({markdown:q,absolutePathToFernFolder:a.absoluteFilePath,absolutePathToMarkdownFile:E,context:r}),C=i.pages[yA.PageId(A)];if(C==null)continue;let z=new Map(Object.entries(i.filesV2??{}).map(([x,L])=>{let V="/"+L.url.replace("/_local/","");return[Ul.of(V),x]})),$=qic(D,z,{},{absolutePathToFernFolder:a.absoluteFilePath,absolutePathToMarkdownFile:E},r);i.pages[yA.PageId(A)]={markdown:$,editThisPageUrl:C.editThisPageUrl}}if(w)return i}let l=[];t.docsWorkspaces?.config.experimental?.openapiParserV3||(l=await Promise.all(u.map(async w=>await w.toFernWorkspace({context:r},{enableUniqueErrorsPerEndpoint:!0,detectGlobalHeaders:!1,preserveSchemaIds:!0}))));let d=await $V(t),s=new Cic(r),o=new Bic(r),c={},g=await new x9t(e,a,d,l,r,void 0,async w=>w.map(E=>{let A=Nie();return c[A]={type:"url",url:xo.Url(`/_local${tvs(E.absoluteFilePath)}`)},{absoluteFilePath:E.absoluteFilePath,relativeFilePath:E.relativeFilePath,fileId:A}}),async w=>s.addReferencedAPI(w),async w=>o.addReferencedAPI(w)).resolve(),O=_ec({writeShape:g,files:{}}),m=yec({dbShape:O.config});return{apis:s.getAPIsForDefinition(),apisV2:o.getAPIsForDefinition(),config:m,files:{},filesV2:c,pages:O.pages,search:{type:"legacyMultiAlgoliaIndex",algoliaIndex:void 0},algoliaSearchIndex:void 0,jsFiles:void 0,id:void 0}}var Cic=class{context;apis={};constructor(t){this.context=t}addReferencedAPI({ir:t,snippetsConfig:r,playgroundConfig:i}){try{let n=Nie(),a=r0a(LX({ir:t,snippetsConfig:r,playgroundConfig:i}),yA.ApiDefinitionId(n),new f3i({snippetsConfigWithSdkId:{},snippetsBySdkId:{},snippetTemplatesByEndpoint:{},snippetTemplatesByEndpointId:{},snippetsBySdkIdAndEndpointId:{}})),u=a0a(a);return this.apis[n]=u,n}catch(n){let a=n;throw this.context.logger.debug(`Failed to read referenced API: ${a?.message} ${a?.stack}`),this.context.logger.error("An error occurred while trying to read an API definition. Please reach out to support."),a.stack!=null&&this.context.logger.error(a?.stack),n}}getAPIsForDefinition(){return this.apis}},Bic=class{context;apis={};constructor(t){this.context=t}addReferencedAPI({api:t,snippetsConfig:r}){try{return t.snippetsConfiguration=r,this.apis[t.id]=t,t.id}catch(i){let n=i;throw this.context.logger.debug(`Failed to read referenced API: ${n?.message} ${n?.stack}`),this.context.logger.error("An error occurred while trying to read an API definition. Please reach out to support."),n.stack!=null&&this.context.logger.error(n?.stack),i}}getAPIsForDefinition(){return this.apis}};var fuE={pages:{},apis:{},apisV2:{},files:{},filesV2:{},config:{aiChatConfig:void 0,hideNavLinks:void 0,navigation:void 0,root:void 0,title:void 0,defaultLanguage:void 0,announcement:void 0,navbarLinks:void 0,footerLinks:void 0,logoHeight:void 0,logoHref:void 0,favicon:void 0,metadata:void 0,redirects:void 0,colorsV3:void 0,layout:void 0,typographyV2:void 0,analyticsConfig:void 0,integrations:void 0,css:void 0,js:void 0},search:{type:"legacyMultiAlgoliaIndex",algoliaIndex:void 0},algoliaSearchIndex:void 0,jsFiles:void 0,id:void 0};async function Iic({initialProject:e,reloadProject:t,validateProject:r,context:i,port:n,bundlePath:a}){if(a!=null)i.logger.info(`Using bundle from path: ${a}`);else try{let $="https://prod-local-preview-bundle2.s3.amazonaws.com/";if($==null)throw new Error("Failed to connect to the docs preview server. Please contact support@buildwithfern.com");await C2o({bucketUrl:$,logger:i.logger,preferCached:!0})}catch($){let x=A3i({});if($ instanceof Error&&i.logger.debug(`Failed to download latest docs bundle: ${$.message}`),await Cf(x))i.logger.warn("Falling back to cached bundle...");else{i.logger.warn("Please reach out to support@buildwithfern.com.");return}}let u=Zd(e.config._absolutePath),l=(0,xic.default)(),d=Uh_.default.createServer(l),s=new Aba.default({server:d}),o=new Set;function c($){for(let x of o)x.send(JSON.stringify($))}s.on("connection",function(x){o.add(x),x.on("close",function(){o.delete(x)})}),l.use((0,Lh_.default)());let b=new URL(UX(e.docsWorkspaces?.config.instances[0]?.url??`http://localhost:${n}`)),g=e,O,m=null,w=!1,E=1e3,A=async $=>{i.logger.info("Reloading docs...");let x=Date.now();try{g=await t(),i.logger.info("Validating docs..."),await r(g);let L=await x2o({domain:`${b.host}${b.pathname}`,project:g,context:i,previousDocsDefinition:O,editedAbsoluteFilepaths:$});return i.logger.info(`Reload completed in ${Date.now()-x}ms`),L}catch(L){return O==null?i.logger.error("Failed to read docs configuration. Rendering blank page."):i.logger.error("Failed to read docs configuration. Rendering last successful configuration."),L instanceof Error&&(i.logger.error(L.message),L instanceof Error&&L.stack&&i.logger.debug(`Stack Trace:
|
|
2017
|
-
${L.stack}`)),O}};O=await A();let q=g.apiWorkspaces.flatMap($=>$.getAbsoluteFilePaths()),D=a?Ul.of(I2o.default.resolve(a)):A3i({}),C=new TFo([u,...q],{recursive:!0,ignoreInitial:!0,debounce:100,renameDetection:!0}),z=[];C.on("all",async($,x,L)=>{i.logger.info(Ws.dim(`[${$}] ${x}`)),!w&&(z.push(Ul.of(x)),m!=null&&clearTimeout(m),m=setTimeout(()=>{(async()=>{w=!0,c({version:1,type:"startReload"});let V=await A(z);V!=null&&(O=V),z.length=0,c({version:1,type:"finishReload"}),w=!1})()},E))}),l.post("/v2/registry/docs/load-with-url",async($,x)=>{try{let L=O??fuE,V={baseUrl:{domain:b.host,basePath:b.pathname},definition:L,lightModeEnabled:L.config.colorsV3?.type!=="dark",orgId:xo.OrgId(e.config.organization)};x.send(V)}catch(L){i.logger.error("Stack trace:",L.stack??""),i.logger.error("Error loading docs",L.message),x.status(500).send()}}),l.get(/^\/_local\/(.*)/,($,x)=>x.sendFile(`/${$.params[0]}`)),l.get("/",($,x,L)=>$.headers.upgrade==="websocket"?s.handleUpgrade($,$.socket,Buffer.alloc(0),V=>{s.emit("connection",V,$)}):L()),l.use("/_next",xic.default.static(I2o.default.join(D,"/_next"))),l.use("*",async($,x)=>x.sendFile(I2o.default.join(D,"/[[...slug]].html"))),l.listen(n),i.logger.info(`Running server on http://localhost:${n}`),await new Promise(()=>{})}var Vh_=require("child_process"),Wh_=li(NKs(),1),Hh_=li(SFo(),1),$h_=li(require("http"),1),Gh_=li(require("path"),1);var duE={pages:{},apis:{},apisV2:{},files:{},filesV2:{},config:{aiChatConfig:void 0,hideNavLinks:void 0,navigation:void 0,root:void 0,title:void 0,defaultLanguage:void 0,announcement:void 0,navbarLinks:void 0,footerLinks:void 0,logoHeight:void 0,logoHref:void 0,favicon:void 0,metadata:void 0,redirects:void 0,colorsV3:void 0,layout:void 0,typographyV2:void 0,analyticsConfig:void 0,integrations:void 0,css:void 0,js:void 0},search:{type:"legacyMultiAlgoliaIndex",algoliaIndex:void 0},algoliaSearchIndex:void 0,jsFiles:void 0,id:void 0};async function zic({initialProject:e,reloadProject:t,validateProject:r,context:i,port:n,bundlePath:a}){if(a!=null)i.logger.info(`Using bundle from path: ${a}`);else try{let Q=
|
|
2018
|
-
${fe.stack}`)),D}};D=await x();let L=q.apiWorkspaces.flatMap(Q=>Q.getAbsoluteFilePaths()),V=new TFo([b,...L],{recursive:!0,ignoreInitial:!0,debounce:100,renameDetection:!0}),X=[];V.on("all",async(Q,Z,fe)=>{i.logger.info(Ws.dim(`[${Q}] ${Z}`)),!z&&(X.push(Ul.of(Z)),C!=null&&clearTimeout(C),C=setTimeout(()=>{(async()=>{z=!0,E({version:1,type:"startReload"});let me=await x(X);me!=null&&(D=me),X.length=0,E({version:1,type:"finishReload"}),z=!1})()},$))}),g.post("/v2/registry/docs/load-with-url",async(Q,Z)=>{try{let fe=D??duE,me={baseUrl:{domain:A.host,basePath:A.pathname},definition:fe,lightModeEnabled:fe.config.colorsV3?.type!=="dark",orgId:xo.OrgId(e.config.organization)};Z.send(me)}catch(fe){i.logger.error("Stack trace:",fe.stack??""),i.logger.error("Error loading docs",fe.message),Z.status(500).send()}}),g.get(/^\/_local\/(.*)/,(Q,Z)=>Z.sendFile(`/${Q.params[0]}`)),g.get("/",(Q,Z,fe)=>Q.headers.upgrade==="websocket"?m.handleUpgrade(Q,Q.socket,Buffer.alloc(0),me=>{m.emit("connection",me,Q)}):fe()),g.listen(d),i.logger.info(`Running server on http://localhost:${d}`),await new Promise(()=>{})}var Ric={};jo(Ric,{additionalProperties:()=>yuE,default:()=>buE,definitions:()=>vuE,properties:()=>_uE,required:()=>huE,type:()=>puE});var puE="object",_uE={tabs:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/docs.TabConfig"}},{type:"null"}]},"landing-page":{oneOf:[{$ref:"#/definitions/docs.PageConfiguration"},{type:"null"}]},navigation:{$ref:"#/definitions/docs.NavigationConfig"}},huE=["navigation"],yuE=!1,vuE={"docs.RoleId":{type:"string"},"docs.Role":{anyOf:[{$ref:"#/definitions/docs.RoleId"},{type:"array",items:{$ref:"#/definitions/docs.RoleId"}}]},"docs.FeatureFlag":{type:"object",properties:{flag:{type:"string"},"fallback-value":{oneOf:[{type:["string","number","boolean","object","array","null"]},{type:"null"}]},match:{oneOf:[{type:["string","number","boolean","object","array","null"]},{type:"null"}]}},required:["flag"],additionalProperties:!1},"docs.FeatureFlagConfiguration":{anyOf:[{type:"string",description:"The name of the feature flag, We assume that it is a boolean feature flag that needs to be evaluated to true."},{$ref:"#/definitions/docs.FeatureFlag",description:"A single feature flag with a configurable name, fallback value, and match value. Especially useful for non boolean feature flags."},{type:"array",items:{$ref:"#/definitions/docs.FeatureFlag"},description:"A list of feature flags. If any of the feature flags are satisfied, we will show all content."}]},"docs.ChangelogFolderRelativePath":{type:"string"},"docs.TabConfig":{type:"object",properties:{viewers:{oneOf:[{$ref:"#/definitions/docs.Role"},{type:"null"}]},orphaned:{oneOf:[{type:"boolean"},{type:"null"}]},"feature-flag":{oneOf:[{$ref:"#/definitions/docs.FeatureFlagConfiguration"},{type:"null"}]},"display-name":{type:"string"},icon:{oneOf:[{type:"string"},{type:"null"}]},slug:{oneOf:[{type:"string"},{type:"null"}]},"skip-slug":{oneOf:[{type:"boolean"},{type:"null"}]},hidden:{oneOf:[{type:"boolean"},{type:"null"}]},href:{oneOf:[{type:"string"},{type:"null"}]},changelog:{oneOf:[{$ref:"#/definitions/docs.ChangelogFolderRelativePath"},{type:"null"}]}},required:["display-name"],additionalProperties:!1},"docs.PageConfiguration":{type:"object",properties:{viewers:{oneOf:[{$ref:"#/definitions/docs.Role"},{type:"null"}]},orphaned:{oneOf:[{type:"boolean"},{type:"null"}]},"feature-flag":{oneOf:[{$ref:"#/definitions/docs.FeatureFlagConfiguration"},{type:"null"}]},page:{type:"string"},path:{type:"string"},slug:{oneOf:[{type:"string"},{type:"null"}]},icon:{oneOf:[{type:"string"},{type:"null"}]},hidden:{oneOf:[{type:"boolean"},{type:"null"}]},noindex:{oneOf:[{type:"boolean"},{type:"null"}]}},required:["page","path"],additionalProperties:!1},"docs.SectionConfiguration":{type:"object",properties:{viewers:{oneOf:[{$ref:"#/definitions/docs.Role"},{type:"null"}]},orphaned:{oneOf:[{type:"boolean"},{type:"null"}]},"feature-flag":{oneOf:[{$ref:"#/definitions/docs.FeatureFlagConfiguration"},{type:"null"}]},section:{type:"string"},path:{oneOf:[{type:"string"},{type:"null"}]},contents:{type:"array",items:{$ref:"#/definitions/docs.NavigationItem"}},collapsed:{oneOf:[{type:"boolean"},{type:"null"}]},slug:{oneOf:[{type:"string"},{type:"null"}]},icon:{oneOf:[{type:"string"},{type:"null"}]},hidden:{oneOf:[{type:"boolean"},{type:"null"}]},"skip-slug":{oneOf:[{type:"boolean"},{type:"null"}]}},required:["section","contents"],additionalProperties:!1},"docs.AudienceId":{type:"string"},"docs.VersionedSnippetLanguageConfiguration":{type:"object",properties:{version:{type:"string"},package:{type:"string"}},required:["version","package"],additionalProperties:!1},"docs.SnippetLanguageConfiguration":{anyOf:[{type:"string"},{$ref:"#/definitions/docs.VersionedSnippetLanguageConfiguration"}]},"docs.SnippetsConfiguration":{type:"object",properties:{python:{oneOf:[{$ref:"#/definitions/docs.SnippetLanguageConfiguration"},{type:"null"}]},typescript:{oneOf:[{$ref:"#/definitions/docs.SnippetLanguageConfiguration"},{type:"null"}]},go:{oneOf:[{$ref:"#/definitions/docs.SnippetLanguageConfiguration"},{type:"null"}]},java:{oneOf:[{$ref:"#/definitions/docs.SnippetLanguageConfiguration"},{type:"null"}]},ruby:{oneOf:[{$ref:"#/definitions/docs.SnippetLanguageConfiguration"},{type:"null"}]},csharp:{oneOf:[{$ref:"#/definitions/docs.SnippetLanguageConfiguration"},{type:"null"}]}},additionalProperties:!1},"docs.PlaygroundButtonSettings":{type:"object",properties:{href:{oneOf:[{type:"string"},{type:"null"}]}},additionalProperties:!1},"docs.PlaygroundSettings":{type:"object",properties:{environments:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},button:{oneOf:[{$ref:"#/definitions/docs.PlaygroundButtonSettings"},{type:"null"}]},oauth:{oneOf:[{type:"boolean"},{type:"null"}]},"limit-websocket-messages-per-connection":{oneOf:[{type:"integer"},{type:"null"}]}},additionalProperties:!1},"docs.ApiReferencePackageConfigurationWithOptions":{type:"object",properties:{viewers:{oneOf:[{$ref:"#/definitions/docs.Role"},{type:"null"}]},orphaned:{oneOf:[{type:"boolean"},{type:"null"}]},"feature-flag":{oneOf:[{$ref:"#/definitions/docs.FeatureFlagConfiguration"},{type:"null"}]},title:{oneOf:[{type:"string"},{type:"null"}]},summary:{oneOf:[{type:"string"},{type:"null"}]},contents:{oneOf:[{type:"array",items:{$ref:"#/definitions/docs.ApiReferenceLayoutItem"}},{type:"null"}]},slug:{oneOf:[{type:"string"},{type:"null"}]},icon:{oneOf:[{type:"string"},{type:"null"}]},hidden:{oneOf:[{type:"boolean"},{type:"null"}]},"skip-slug":{oneOf:[{type:"boolean"},{type:"null"}]},playground:{oneOf:[{$ref:"#/definitions/docs.PlaygroundSettings"},{type:"null"}]}},additionalProperties:!1},"docs.ApiReferencePackageConfiguration":{anyOf:[{type:"array",items:{$ref:"#/definitions/docs.ApiReferenceLayoutItem"}},{$ref:"#/definitions/docs.ApiReferencePackageConfigurationWithOptions"}]},"docs.ApiReferenceSectionConfiguration":{type:"object",properties:{viewers:{oneOf:[{$ref:"#/definitions/docs.Role"},{type:"null"}]},orphaned:{oneOf:[{type:"boolean"},{type:"null"}]},"feature-flag":{oneOf:[{$ref:"#/definitions/docs.FeatureFlagConfiguration"},{type:"null"}]},section:{type:"string"},"referenced-packages":{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},summary:{oneOf:[{type:"string"},{type:"null"}]},contents:{oneOf:[{type:"array",items:{$ref:"#/definitions/docs.ApiReferenceLayoutItem"}},{type:"null"}]},slug:{oneOf:[{type:"string"},{type:"null"}]},icon:{oneOf:[{type:"string"},{type:"null"}]},hidden:{oneOf:[{type:"boolean"},{type:"null"}]},"skip-slug":{oneOf:[{type:"boolean"},{type:"null"}]},playground:{oneOf:[{$ref:"#/definitions/docs.PlaygroundSettings"},{type:"null"}]}},required:["section"],additionalProperties:!1},"docs.ApiReferenceEndpointConfiguration":{type:"object",properties:{viewers:{oneOf:[{$ref:"#/definitions/docs.Role"},{type:"null"}]},orphaned:{oneOf:[{type:"boolean"},{type:"null"}]},"feature-flag":{oneOf:[{$ref:"#/definitions/docs.FeatureFlagConfiguration"},{type:"null"}]},endpoint:{type:"string"},title:{oneOf:[{type:"string"},{type:"null"}]},slug:{oneOf:[{type:"string"},{type:"null"}]},icon:{oneOf:[{type:"string"},{type:"null"}]},hidden:{oneOf:[{type:"boolean"},{type:"null"}]},playground:{oneOf:[{$ref:"#/definitions/docs.PlaygroundSettings"},{type:"null"}]}},required:["endpoint"],additionalProperties:!1},"docs.LinkConfiguration":{type:"object",properties:{link:{type:"string"},href:{type:"string"},icon:{oneOf:[{type:"string"},{type:"null"}]}},required:["link","href"],additionalProperties:!1},"docs.ApiReferenceLayoutItem":{anyOf:[{type:"string",description:"This should be either an endpoint, websocket, webhook, or subpackage ID"},{type:"object",additionalProperties:{$ref:"#/definitions/docs.ApiReferencePackageConfiguration"},description:"Keyed by subpackage name, this object allows you to group endpoints and pages together."},{$ref:"#/definitions/docs.ApiReferenceSectionConfiguration"},{$ref:"#/definitions/docs.ApiReferenceEndpointConfiguration"},{$ref:"#/definitions/docs.PageConfiguration"},{$ref:"#/definitions/docs.LinkConfiguration"}]},"docs.ApiReferenceConfiguration":{type:"object",properties:{viewers:{oneOf:[{$ref:"#/definitions/docs.Role"},{type:"null"}]},orphaned:{oneOf:[{type:"boolean"},{type:"null"}]},"feature-flag":{oneOf:[{$ref:"#/definitions/docs.FeatureFlagConfiguration"},{type:"null"}]},api:{type:"string"},"api-name":{oneOf:[{type:"string"},{type:"null"}]},openrpc:{oneOf:[{type:"string"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{$ref:"#/definitions/docs.AudienceId"}},{type:"null"}]},"display-errors":{oneOf:[{type:"boolean"},{type:"null"}]},snippets:{oneOf:[{$ref:"#/definitions/docs.SnippetsConfiguration"},{type:"null"}]},summary:{oneOf:[{type:"string"},{type:"null"}]},layout:{oneOf:[{type:"array",items:{$ref:"#/definitions/docs.ApiReferenceLayoutItem"}},{type:"null"}]},icon:{oneOf:[{type:"string"},{type:"null"}]},slug:{oneOf:[{type:"string"},{type:"null"}]},hidden:{oneOf:[{type:"boolean"},{type:"null"}]},"skip-slug":{oneOf:[{type:"boolean"},{type:"null"}]},alphabetized:{oneOf:[{type:"boolean"},{type:"null"}]},flattened:{oneOf:[{type:"boolean"},{type:"null"}]},paginated:{oneOf:[{type:"boolean"},{type:"null"}]},playground:{oneOf:[{$ref:"#/definitions/docs.PlaygroundSettings"},{type:"null"}]}},required:["api"],additionalProperties:!1},"docs.ChangelogConfiguration":{type:"object",properties:{viewers:{oneOf:[{$ref:"#/definitions/docs.Role"},{type:"null"}]},orphaned:{oneOf:[{type:"boolean"},{type:"null"}]},"feature-flag":{oneOf:[{$ref:"#/definitions/docs.FeatureFlagConfiguration"},{type:"null"}]},changelog:{$ref:"#/definitions/docs.ChangelogFolderRelativePath"},title:{oneOf:[{type:"string"},{type:"null"}]},slug:{oneOf:[{type:"string"},{type:"null"}]},icon:{oneOf:[{type:"string"},{type:"null"}]},hidden:{oneOf:[{type:"boolean"},{type:"null"}]}},required:["changelog"],additionalProperties:!1},"docs.NavigationItem":{anyOf:[{$ref:"#/definitions/docs.PageConfiguration"},{$ref:"#/definitions/docs.SectionConfiguration"},{$ref:"#/definitions/docs.ApiReferenceConfiguration"},{$ref:"#/definitions/docs.LinkConfiguration"},{$ref:"#/definitions/docs.ChangelogConfiguration"}]},"docs.UntabbedNavigationConfig":{type:"array",items:{$ref:"#/definitions/docs.NavigationItem"}},"docs.TabId":{type:"string"},"docs.TabbedNavigationItem":{type:"object",properties:{tab:{$ref:"#/definitions/docs.TabId"},layout:{oneOf:[{type:"array",items:{$ref:"#/definitions/docs.NavigationItem"}},{type:"null"}]}},required:["tab"],additionalProperties:!1},"docs.TabbedNavigationConfig":{type:"array",items:{$ref:"#/definitions/docs.TabbedNavigationItem"}},"docs.NavigationConfig":{anyOf:[{$ref:"#/definitions/docs.UntabbedNavigationConfig"},{$ref:"#/definitions/docs.TabbedNavigationConfig"}]}},buE={type:puE,properties:_uE,required:huE,additionalProperties:yuE,definitions:vuE};async function z2o({value:e}){let t=cQr(e,Ric);if(t.success)return{type:"success",contents:u8t.RawSchemas.Serializer.VersionFileConfig.parseOrThrow(e)};let r=t.error?.instancePath?` at ${t?.error.instancePath}`:"";return{type:"failure",message:`${t.error?.message??"Failed to parse because JSON schema validation failed"}${r}`}}function Qh_(e,t){let r={type:"element",tagName:"blockquote",properties:{},children:e.wrap(e.all(t),!0)};return e.patch(t,r),e.applyData(t,r)}function Jh_(e,t){let r={type:"element",tagName:"br",properties:{},children:[]};return e.patch(t,r),[e.applyData(t,r),{type:"text",value:`
|
|
2017
|
+
${L.stack}`)),O}};O=await A();let q=g.apiWorkspaces.flatMap($=>$.getAbsoluteFilePaths()),D=a?Ul.of(I2o.default.resolve(a)):A3i({}),C=new TFo([u,...q],{recursive:!0,ignoreInitial:!0,debounce:100,renameDetection:!0}),z=[];C.on("all",async($,x,L)=>{i.logger.info(Ws.dim(`[${$}] ${x}`)),!w&&(z.push(Ul.of(x)),m!=null&&clearTimeout(m),m=setTimeout(()=>{(async()=>{w=!0,c({version:1,type:"startReload"});let V=await A(z);V!=null&&(O=V),z.length=0,c({version:1,type:"finishReload"}),w=!1})()},E))}),l.post("/v2/registry/docs/load-with-url",async($,x)=>{try{let L=O??fuE,V={baseUrl:{domain:b.host,basePath:b.pathname},definition:L,lightModeEnabled:L.config.colorsV3?.type!=="dark",orgId:xo.OrgId(e.config.organization)};x.send(V)}catch(L){i.logger.error("Stack trace:",L.stack??""),i.logger.error("Error loading docs",L.message),x.status(500).send()}}),l.get(/^\/_local\/(.*)/,($,x)=>x.sendFile(`/${$.params[0]}`)),l.get("/",($,x,L)=>$.headers.upgrade==="websocket"?s.handleUpgrade($,$.socket,Buffer.alloc(0),V=>{s.emit("connection",V,$)}):L()),l.use("/_next",xic.default.static(I2o.default.join(D,"/_next"))),l.use("*",async($,x)=>x.sendFile(I2o.default.join(D,"/[[...slug]].html"))),l.listen(n),i.logger.info(`Running server on http://localhost:${n}`),await new Promise(()=>{})}var Vh_=require("child_process"),Wh_=li(NKs(),1),Hh_=li(SFo(),1),$h_=li(require("http"),1),Gh_=li(require("path"),1);var duE={pages:{},apis:{},apisV2:{},files:{},filesV2:{},config:{aiChatConfig:void 0,hideNavLinks:void 0,navigation:void 0,root:void 0,title:void 0,defaultLanguage:void 0,announcement:void 0,navbarLinks:void 0,footerLinks:void 0,logoHeight:void 0,logoHref:void 0,favicon:void 0,metadata:void 0,redirects:void 0,colorsV3:void 0,layout:void 0,typographyV2:void 0,analyticsConfig:void 0,integrations:void 0,css:void 0,js:void 0},search:{type:"legacyMultiAlgoliaIndex",algoliaIndex:void 0},algoliaSearchIndex:void 0,jsFiles:void 0,id:void 0};async function zic({initialProject:e,reloadProject:t,validateProject:r,context:i,port:n,bundlePath:a}){if(a!=null)i.logger.info(`Using bundle from path: ${a}`);else try{let Q="https://dev2-local-preview-bundle3.s3.amazonaws.com/";if(Q==null)throw new Error("Failed to connect to the docs preview server. Please contact support@buildwithfern.com");await C2o({bucketUrl:Q,logger:i.logger,preferCached:!0,app:!0})}catch(Q){if(Q instanceof Error&&i.logger.debug(`Failed to download latest docs bundle: ${Q.message}`),await Cf(A3i({app:!0})))i.logger.warn("Falling back to cached bundle...");else{i.logger.warn("Please reach out to support@buildwithfern.com.");return}}let u=a||A3i({app:!0}),l=Gh_.default.join(u,"standalone/packages/fern-docs/bundle/server.js"),d=n+1,s={...process.env,PORT:n.toString(),HOSTNAME:"0.0.0.0",NEXT_PUBLIC_FDR_ORIGIN:`http://localhost:${d}`,NEXT_PUBLIC_DOCS_DOMAIN:e.docsWorkspaces?.config.instances[0]?.url,NEXT_PUBLIC_IS_LOCAL:"1",NEXT_DISABLE_CACHE:"1",NODE_ENV:"development",NODE_PATH:u},o=(0,Vh_.spawn)("node",[l],{env:s,detached:!0,stdio:["ignore","pipe","pipe"]});o.stdout?.on("data",Q=>{i.logger.debug(`[Next.js] ${Q.toString()}`)}),o.stderr?.on("data",Q=>{i.logger.debug(`[Next.js] ${Q.toString()}`)}),i.logger.debug(`Next.js standalone server started with PID: ${o.pid}`),o.on("error",Q=>{i.logger.error(`Server process error: ${Q.message}`)}),o.on("exit",(Q,Z)=>{Q?i.logger.error(`Server process exited with code: ${Q}`):Z?i.logger.debug(`Server process killed with signal: ${Z}`):i.logger.debug("Server process exited")});let c=()=>{if(o.pid){i.logger.debug(`Killing server process with PID: ${o.pid}`);try{process.kill(-o.pid,"SIGTERM")}catch(Q){i.logger.error(`Failed to kill server process: ${Q}`)}}};process.on("SIGINT",c),process.on("SIGTERM",c),process.on("exit",c),await new Promise(Q=>setTimeout(Q,3e3)),i.logger.debug(`Next.js server should now be running on http://localhost:${n}`);let b=Zd(e.config._absolutePath),g=(0,Hh_.default)(),O=$h_.default.createServer(g),m=new Aba.default({server:O}),w=new Set;function E(Q){for(let Z of w)Z.send(JSON.stringify(Q))}m.on("connection",function(Z){w.add(Z),Z.on("close",function(){w.delete(Z)})}),g.use((0,Wh_.default)());let A=new URL(UX(e.docsWorkspaces?.config.instances[0]?.url??`http://localhost:${n}`)),q=e,D,C=null,z=!1,$=1e3,x=async Q=>{i.logger.info("Reloading docs...");let Z=Date.now();try{q=await t(),i.logger.info("Validating docs..."),await r(q);let fe=await x2o({domain:`${A.host}${A.pathname}`,project:q,context:i,previousDocsDefinition:D,editedAbsoluteFilepaths:Q});return i.logger.info(`Reload completed in ${Date.now()-Z}ms`),fe}catch(fe){return D==null?i.logger.error("Failed to read docs configuration. Rendering blank page."):i.logger.error("Failed to read docs configuration. Rendering last successful configuration."),fe instanceof Error&&(i.logger.error(fe.message),fe instanceof Error&&fe.stack&&i.logger.debug(`Stack Trace:
|
|
2018
|
+
${fe.stack}`)),D}};D=await x();let L=q.apiWorkspaces.flatMap(Q=>Q.getAbsoluteFilePaths()),V=new TFo([b,...L],{recursive:!0,ignoreInitial:!0,debounce:100,renameDetection:!0}),X=[];V.on("all",async(Q,Z,fe)=>{i.logger.info(Ws.dim(`[${Q}] ${Z}`)),!z&&(X.push(Ul.of(Z)),C!=null&&clearTimeout(C),C=setTimeout(()=>{(async()=>{z=!0,E({version:1,type:"startReload"});let me=await x(X);me!=null&&(D=me),X.length=0,E({version:1,type:"finishReload"}),z=!1})()},$))}),g.post("/v2/registry/docs/load-with-url",async(Q,Z)=>{try{let fe=D??duE,me={baseUrl:{domain:A.host,basePath:A.pathname},definition:fe,lightModeEnabled:fe.config.colorsV3?.type!=="dark",orgId:xo.OrgId(e.config.organization)};Z.send(me)}catch(fe){i.logger.error("Stack trace:",fe.stack??""),i.logger.error("Error loading docs",fe.message),Z.status(500).send()}}),g.get(/^\/_local\/(.*)/,(Q,Z)=>Z.sendFile(`/${Q.params[0]}`)),g.get("/",(Q,Z,fe)=>Q.headers.upgrade==="websocket"?m.handleUpgrade(Q,Q.socket,Buffer.alloc(0),me=>{m.emit("connection",me,Q)}):fe()),g.listen(d),i.logger.debug(`Running server on http://localhost:${d}`),await new Promise(()=>{})}var Ric={};jo(Ric,{additionalProperties:()=>yuE,default:()=>buE,definitions:()=>vuE,properties:()=>_uE,required:()=>huE,type:()=>puE});var puE="object",_uE={tabs:{oneOf:[{type:"object",additionalProperties:{$ref:"#/definitions/docs.TabConfig"}},{type:"null"}]},"landing-page":{oneOf:[{$ref:"#/definitions/docs.PageConfiguration"},{type:"null"}]},navigation:{$ref:"#/definitions/docs.NavigationConfig"}},huE=["navigation"],yuE=!1,vuE={"docs.RoleId":{type:"string"},"docs.Role":{anyOf:[{$ref:"#/definitions/docs.RoleId"},{type:"array",items:{$ref:"#/definitions/docs.RoleId"}}]},"docs.FeatureFlag":{type:"object",properties:{flag:{type:"string"},"fallback-value":{oneOf:[{type:["string","number","boolean","object","array","null"]},{type:"null"}]},match:{oneOf:[{type:["string","number","boolean","object","array","null"]},{type:"null"}]}},required:["flag"],additionalProperties:!1},"docs.FeatureFlagConfiguration":{anyOf:[{type:"string",description:"The name of the feature flag, We assume that it is a boolean feature flag that needs to be evaluated to true."},{$ref:"#/definitions/docs.FeatureFlag",description:"A single feature flag with a configurable name, fallback value, and match value. Especially useful for non boolean feature flags."},{type:"array",items:{$ref:"#/definitions/docs.FeatureFlag"},description:"A list of feature flags. If any of the feature flags are satisfied, we will show all content."}]},"docs.ChangelogFolderRelativePath":{type:"string"},"docs.TabConfig":{type:"object",properties:{viewers:{oneOf:[{$ref:"#/definitions/docs.Role"},{type:"null"}]},orphaned:{oneOf:[{type:"boolean"},{type:"null"}]},"feature-flag":{oneOf:[{$ref:"#/definitions/docs.FeatureFlagConfiguration"},{type:"null"}]},"display-name":{type:"string"},icon:{oneOf:[{type:"string"},{type:"null"}]},slug:{oneOf:[{type:"string"},{type:"null"}]},"skip-slug":{oneOf:[{type:"boolean"},{type:"null"}]},hidden:{oneOf:[{type:"boolean"},{type:"null"}]},href:{oneOf:[{type:"string"},{type:"null"}]},changelog:{oneOf:[{$ref:"#/definitions/docs.ChangelogFolderRelativePath"},{type:"null"}]}},required:["display-name"],additionalProperties:!1},"docs.PageConfiguration":{type:"object",properties:{viewers:{oneOf:[{$ref:"#/definitions/docs.Role"},{type:"null"}]},orphaned:{oneOf:[{type:"boolean"},{type:"null"}]},"feature-flag":{oneOf:[{$ref:"#/definitions/docs.FeatureFlagConfiguration"},{type:"null"}]},page:{type:"string"},path:{type:"string"},slug:{oneOf:[{type:"string"},{type:"null"}]},icon:{oneOf:[{type:"string"},{type:"null"}]},hidden:{oneOf:[{type:"boolean"},{type:"null"}]},noindex:{oneOf:[{type:"boolean"},{type:"null"}]}},required:["page","path"],additionalProperties:!1},"docs.SectionConfiguration":{type:"object",properties:{viewers:{oneOf:[{$ref:"#/definitions/docs.Role"},{type:"null"}]},orphaned:{oneOf:[{type:"boolean"},{type:"null"}]},"feature-flag":{oneOf:[{$ref:"#/definitions/docs.FeatureFlagConfiguration"},{type:"null"}]},section:{type:"string"},path:{oneOf:[{type:"string"},{type:"null"}]},contents:{type:"array",items:{$ref:"#/definitions/docs.NavigationItem"}},collapsed:{oneOf:[{type:"boolean"},{type:"null"}]},slug:{oneOf:[{type:"string"},{type:"null"}]},icon:{oneOf:[{type:"string"},{type:"null"}]},hidden:{oneOf:[{type:"boolean"},{type:"null"}]},"skip-slug":{oneOf:[{type:"boolean"},{type:"null"}]}},required:["section","contents"],additionalProperties:!1},"docs.AudienceId":{type:"string"},"docs.VersionedSnippetLanguageConfiguration":{type:"object",properties:{version:{type:"string"},package:{type:"string"}},required:["version","package"],additionalProperties:!1},"docs.SnippetLanguageConfiguration":{anyOf:[{type:"string"},{$ref:"#/definitions/docs.VersionedSnippetLanguageConfiguration"}]},"docs.SnippetsConfiguration":{type:"object",properties:{python:{oneOf:[{$ref:"#/definitions/docs.SnippetLanguageConfiguration"},{type:"null"}]},typescript:{oneOf:[{$ref:"#/definitions/docs.SnippetLanguageConfiguration"},{type:"null"}]},go:{oneOf:[{$ref:"#/definitions/docs.SnippetLanguageConfiguration"},{type:"null"}]},java:{oneOf:[{$ref:"#/definitions/docs.SnippetLanguageConfiguration"},{type:"null"}]},ruby:{oneOf:[{$ref:"#/definitions/docs.SnippetLanguageConfiguration"},{type:"null"}]},csharp:{oneOf:[{$ref:"#/definitions/docs.SnippetLanguageConfiguration"},{type:"null"}]}},additionalProperties:!1},"docs.PlaygroundButtonSettings":{type:"object",properties:{href:{oneOf:[{type:"string"},{type:"null"}]}},additionalProperties:!1},"docs.PlaygroundSettings":{type:"object",properties:{environments:{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},button:{oneOf:[{$ref:"#/definitions/docs.PlaygroundButtonSettings"},{type:"null"}]},oauth:{oneOf:[{type:"boolean"},{type:"null"}]},"limit-websocket-messages-per-connection":{oneOf:[{type:"integer"},{type:"null"}]}},additionalProperties:!1},"docs.ApiReferencePackageConfigurationWithOptions":{type:"object",properties:{viewers:{oneOf:[{$ref:"#/definitions/docs.Role"},{type:"null"}]},orphaned:{oneOf:[{type:"boolean"},{type:"null"}]},"feature-flag":{oneOf:[{$ref:"#/definitions/docs.FeatureFlagConfiguration"},{type:"null"}]},title:{oneOf:[{type:"string"},{type:"null"}]},summary:{oneOf:[{type:"string"},{type:"null"}]},contents:{oneOf:[{type:"array",items:{$ref:"#/definitions/docs.ApiReferenceLayoutItem"}},{type:"null"}]},slug:{oneOf:[{type:"string"},{type:"null"}]},icon:{oneOf:[{type:"string"},{type:"null"}]},hidden:{oneOf:[{type:"boolean"},{type:"null"}]},"skip-slug":{oneOf:[{type:"boolean"},{type:"null"}]},playground:{oneOf:[{$ref:"#/definitions/docs.PlaygroundSettings"},{type:"null"}]}},additionalProperties:!1},"docs.ApiReferencePackageConfiguration":{anyOf:[{type:"array",items:{$ref:"#/definitions/docs.ApiReferenceLayoutItem"}},{$ref:"#/definitions/docs.ApiReferencePackageConfigurationWithOptions"}]},"docs.ApiReferenceSectionConfiguration":{type:"object",properties:{viewers:{oneOf:[{$ref:"#/definitions/docs.Role"},{type:"null"}]},orphaned:{oneOf:[{type:"boolean"},{type:"null"}]},"feature-flag":{oneOf:[{$ref:"#/definitions/docs.FeatureFlagConfiguration"},{type:"null"}]},section:{type:"string"},"referenced-packages":{oneOf:[{type:"array",items:{type:"string"}},{type:"null"}]},summary:{oneOf:[{type:"string"},{type:"null"}]},contents:{oneOf:[{type:"array",items:{$ref:"#/definitions/docs.ApiReferenceLayoutItem"}},{type:"null"}]},slug:{oneOf:[{type:"string"},{type:"null"}]},icon:{oneOf:[{type:"string"},{type:"null"}]},hidden:{oneOf:[{type:"boolean"},{type:"null"}]},"skip-slug":{oneOf:[{type:"boolean"},{type:"null"}]},playground:{oneOf:[{$ref:"#/definitions/docs.PlaygroundSettings"},{type:"null"}]}},required:["section"],additionalProperties:!1},"docs.ApiReferenceEndpointConfiguration":{type:"object",properties:{viewers:{oneOf:[{$ref:"#/definitions/docs.Role"},{type:"null"}]},orphaned:{oneOf:[{type:"boolean"},{type:"null"}]},"feature-flag":{oneOf:[{$ref:"#/definitions/docs.FeatureFlagConfiguration"},{type:"null"}]},endpoint:{type:"string"},title:{oneOf:[{type:"string"},{type:"null"}]},slug:{oneOf:[{type:"string"},{type:"null"}]},icon:{oneOf:[{type:"string"},{type:"null"}]},hidden:{oneOf:[{type:"boolean"},{type:"null"}]},playground:{oneOf:[{$ref:"#/definitions/docs.PlaygroundSettings"},{type:"null"}]}},required:["endpoint"],additionalProperties:!1},"docs.LinkConfiguration":{type:"object",properties:{link:{type:"string"},href:{type:"string"},icon:{oneOf:[{type:"string"},{type:"null"}]}},required:["link","href"],additionalProperties:!1},"docs.ApiReferenceLayoutItem":{anyOf:[{type:"string",description:"This should be either an endpoint, websocket, webhook, or subpackage ID"},{type:"object",additionalProperties:{$ref:"#/definitions/docs.ApiReferencePackageConfiguration"},description:"Keyed by subpackage name, this object allows you to group endpoints and pages together."},{$ref:"#/definitions/docs.ApiReferenceSectionConfiguration"},{$ref:"#/definitions/docs.ApiReferenceEndpointConfiguration"},{$ref:"#/definitions/docs.PageConfiguration"},{$ref:"#/definitions/docs.LinkConfiguration"}]},"docs.ApiReferenceConfiguration":{type:"object",properties:{viewers:{oneOf:[{$ref:"#/definitions/docs.Role"},{type:"null"}]},orphaned:{oneOf:[{type:"boolean"},{type:"null"}]},"feature-flag":{oneOf:[{$ref:"#/definitions/docs.FeatureFlagConfiguration"},{type:"null"}]},api:{type:"string"},"api-name":{oneOf:[{type:"string"},{type:"null"}]},openrpc:{oneOf:[{type:"string"},{type:"null"}]},audiences:{oneOf:[{type:"array",items:{$ref:"#/definitions/docs.AudienceId"}},{type:"null"}]},"display-errors":{oneOf:[{type:"boolean"},{type:"null"}]},snippets:{oneOf:[{$ref:"#/definitions/docs.SnippetsConfiguration"},{type:"null"}]},summary:{oneOf:[{type:"string"},{type:"null"}]},layout:{oneOf:[{type:"array",items:{$ref:"#/definitions/docs.ApiReferenceLayoutItem"}},{type:"null"}]},icon:{oneOf:[{type:"string"},{type:"null"}]},slug:{oneOf:[{type:"string"},{type:"null"}]},hidden:{oneOf:[{type:"boolean"},{type:"null"}]},"skip-slug":{oneOf:[{type:"boolean"},{type:"null"}]},alphabetized:{oneOf:[{type:"boolean"},{type:"null"}]},flattened:{oneOf:[{type:"boolean"},{type:"null"}]},paginated:{oneOf:[{type:"boolean"},{type:"null"}]},playground:{oneOf:[{$ref:"#/definitions/docs.PlaygroundSettings"},{type:"null"}]}},required:["api"],additionalProperties:!1},"docs.ChangelogConfiguration":{type:"object",properties:{viewers:{oneOf:[{$ref:"#/definitions/docs.Role"},{type:"null"}]},orphaned:{oneOf:[{type:"boolean"},{type:"null"}]},"feature-flag":{oneOf:[{$ref:"#/definitions/docs.FeatureFlagConfiguration"},{type:"null"}]},changelog:{$ref:"#/definitions/docs.ChangelogFolderRelativePath"},title:{oneOf:[{type:"string"},{type:"null"}]},slug:{oneOf:[{type:"string"},{type:"null"}]},icon:{oneOf:[{type:"string"},{type:"null"}]},hidden:{oneOf:[{type:"boolean"},{type:"null"}]}},required:["changelog"],additionalProperties:!1},"docs.NavigationItem":{anyOf:[{$ref:"#/definitions/docs.PageConfiguration"},{$ref:"#/definitions/docs.SectionConfiguration"},{$ref:"#/definitions/docs.ApiReferenceConfiguration"},{$ref:"#/definitions/docs.LinkConfiguration"},{$ref:"#/definitions/docs.ChangelogConfiguration"}]},"docs.UntabbedNavigationConfig":{type:"array",items:{$ref:"#/definitions/docs.NavigationItem"}},"docs.TabId":{type:"string"},"docs.TabbedNavigationItem":{type:"object",properties:{tab:{$ref:"#/definitions/docs.TabId"},layout:{oneOf:[{type:"array",items:{$ref:"#/definitions/docs.NavigationItem"}},{type:"null"}]}},required:["tab"],additionalProperties:!1},"docs.TabbedNavigationConfig":{type:"array",items:{$ref:"#/definitions/docs.TabbedNavigationItem"}},"docs.NavigationConfig":{anyOf:[{$ref:"#/definitions/docs.UntabbedNavigationConfig"},{$ref:"#/definitions/docs.TabbedNavigationConfig"}]}},buE={type:puE,properties:_uE,required:huE,additionalProperties:yuE,definitions:vuE};async function z2o({value:e}){let t=cQr(e,Ric);if(t.success)return{type:"success",contents:u8t.RawSchemas.Serializer.VersionFileConfig.parseOrThrow(e)};let r=t.error?.instancePath?` at ${t?.error.instancePath}`:"";return{type:"failure",message:`${t.error?.message??"Failed to parse because JSON schema validation failed"}${r}`}}function Qh_(e,t){let r={type:"element",tagName:"blockquote",properties:{},children:e.wrap(e.all(t),!0)};return e.patch(t,r),e.applyData(t,r)}function Jh_(e,t){let r={type:"element",tagName:"br",properties:{},children:[]};return e.patch(t,r),[e.applyData(t,r),{type:"text",value:`
|
|
2019
2019
|
`}]}function Kh_(e,t){let r=t.value?t.value+`
|
|
2020
2020
|
`:"",i={};t.lang&&(i.className=["language-"+t.lang]);let n={type:"element",tagName:"code",properties:i,children:[{type:"text",value:r}]};return t.meta&&(n.data={meta:t.meta}),e.patch(t,n),n=e.applyData(t,n),n={type:"element",tagName:"pre",properties:{},children:[n]},e.patch(t,n),n}function Yh_(e,t){let r={type:"element",tagName:"del",properties:{},children:e.all(t)};return e.patch(t,r),e.applyData(t,r)}function Xh_(e,t){let r={type:"element",tagName:"em",properties:{},children:e.all(t)};return e.patch(t,r),e.applyData(t,r)}function Zh_(e,t){let r=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",i=String(t.identifier).toUpperCase(),n=lze(i.toLowerCase()),a=e.footnoteOrder.indexOf(i),u,l=e.footnoteCounts.get(i);l===void 0?(l=0,e.footnoteOrder.push(i),u=e.footnoteOrder.length):u=a+1,l+=1,e.footnoteCounts.set(i,l);let d={type:"element",tagName:"a",properties:{href:"#"+r+"fn-"+n,id:r+"fnref-"+n+(l>1?"-"+l:""),dataFootnoteRef:!0,ariaDescribedBy:["footnote-label"]},children:[{type:"text",value:String(u)}]};e.patch(t,d);let s={type:"element",tagName:"sup",properties:{},children:[d]};return e.patch(t,s),e.applyData(t,s)}function kh_(e,t){let r={type:"element",tagName:"h"+t.depth,properties:{},children:e.all(t)};return e.patch(t,r),e.applyData(t,r)}function ey_(e,t){if(e.options.allowDangerousHtml){let r={type:"raw",value:t.value};return e.patch(t,r),e.applyData(t,r)}}function R2o(e,t){let r=t.referenceType,i="]";if(r==="collapsed"?i+="[]":r==="full"&&(i+="["+(t.label||t.identifier)+"]"),t.type==="imageReference")return[{type:"text",value:"!["+t.alt+i}];let n=e.all(t),a=n[0];a&&a.type==="text"?a.value="["+a.value:n.unshift({type:"text",value:"["});let u=n[n.length-1];return u&&u.type==="text"?u.value+=i:n.push({type:"text",value:i}),n}function ty_(e,t){let r=String(t.identifier).toUpperCase(),i=e.definitionById.get(r);if(!i)return R2o(e,t);let n={src:lze(i.url||""),alt:t.alt};i.title!==null&&i.title!==void 0&&(n.title=i.title);let a={type:"element",tagName:"img",properties:n,children:[]};return e.patch(t,a),e.applyData(t,a)}function ry_(e,t){let r={src:lze(t.url)};t.alt!==null&&t.alt!==void 0&&(r.alt=t.alt),t.title!==null&&t.title!==void 0&&(r.title=t.title);let i={type:"element",tagName:"img",properties:r,children:[]};return e.patch(t,i),e.applyData(t,i)}function iy_(e,t){let r={type:"text",value:t.value.replace(/\r?\n|\r/g," ")};e.patch(t,r);let i={type:"element",tagName:"code",properties:{},children:[r]};return e.patch(t,i),e.applyData(t,i)}function ny_(e,t){let r=String(t.identifier).toUpperCase(),i=e.definitionById.get(r);if(!i)return R2o(e,t);let n={href:lze(i.url||"")};i.title!==null&&i.title!==void 0&&(n.title=i.title);let a={type:"element",tagName:"a",properties:n,children:e.all(t)};return e.patch(t,a),e.applyData(t,a)}function ay_(e,t){let r={href:lze(t.url)};t.title!==null&&t.title!==void 0&&(r.title=t.title);let i={type:"element",tagName:"a",properties:r,children:e.all(t)};return e.patch(t,i),e.applyData(t,i)}function oy_(e,t,r){let i=e.all(t),n=r?guE(r):uy_(t),a={},u=[];if(typeof t.checked=="boolean"){let o=i[0],c;o&&o.type==="element"&&o.tagName==="p"?c=o:(c={type:"element",tagName:"p",properties:{},children:[]},i.unshift(c)),c.children.length>0&&c.children.unshift({type:"text",value:" "}),c.children.unshift({type:"element",tagName:"input",properties:{type:"checkbox",checked:t.checked,disabled:!0},children:[]}),a.className=["task-list-item"]}let l=-1;for(;++l<i.length;){let o=i[l];(n||l!==0||o.type!=="element"||o.tagName!=="p")&&u.push({type:"text",value:`
|
|
2021
2021
|
`}),o.type==="element"&&o.tagName==="p"&&!n?u.push(...o.children):u.push(o)}let d=i[i.length-1];d&&(n||d.type!=="element"||d.tagName!=="p")&&u.push({type:"text",value:`
|