@mintlify/cli 4.1.1 → 4.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/start.js +8 -8
- package/package.json +2 -2
package/dist/start.js
CHANGED
|
@@ -1922,7 +1922,7 @@ Calls to async() callback can have unexpected results.`),d=!0,function(e,t){e?u(
|
|
|
1922
1922
|
* @packageDocumentation
|
|
1923
1923
|
*/
|
|
1924
1924
|
;var wkt=class e{constructor(e){this.bytes=e}static ofInner(t){if(t.length===16)return new e(t);throw TypeError(`not 128-bit length`)}static fromFieldsV7(t,n,r,i){if(!Number.isInteger(t)||!Number.isInteger(n)||!Number.isInteger(r)||!Number.isInteger(i)||t<0||n<0||r<0||i<0||t>0xffffffffffff||n>4095||r>1073741823||i>4294967295)throw RangeError(`invalid field value`);let a=/* @__PURE__ */ 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/256,a[5]=t,a[6]=112|n>>>8,a[7]=n,a[8]=128|r>>>24,a[9]=r>>>16,a[10]=r>>>8,a[11]=r,a[12]=i>>>24,a[13]=i>>>16,a[14]=i>>>8,a[15]=i,new e(a)}static parse(t){let n;switch(t.length){case 32:n=/^[0-9a-f]{32}$/i.exec(t)?.[0];break;case 36:n=/^([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:n=/^\{([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:n=/^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(``)}if(n){let t=/* @__PURE__ */ new Uint8Array(16);for(let e=0;e<16;e+=4){let r=parseInt(n.substring(2*e,2*e+8),16);t[e+0]=r>>>24,t[e+1]=r>>>16,t[e+2]=r>>>8,t[e+3]=r}return new e(t)}throw SyntaxError(`could not parse UUID string`)}toString(){let e=``;for(let t=0;t<this.bytes.length;t++)e+=R$.charAt(this.bytes[t]>>>4),e+=R$.charAt(15&this.bytes[t]),(t===3||t===5||t===7||t===9)&&(e+=`-`);return e}toHex(){let e=``;for(let t=0;t<this.bytes.length;t++)e+=R$.charAt(this.bytes[t]>>>4),e+=R$.charAt(15&this.bytes[t]);return e}toJSON(){return this.toString()}getVariant(){let e=this.bytes[8]>>>4;if(e<0)throw Error(`unreachable`);if(e<=7)return this.bytes.every(e=>e===0)?`NIL`:`VAR_0`;if(e<=11)return`VAR_10`;if(e<=13)return`VAR_110`;if(e<=15)return this.bytes.every(e=>e===255)?`MAX`:`VAR_RESERVED`;throw Error(`unreachable`)}getVersion(){return this.getVariant()===`VAR_10`?this.bytes[6]>>>4:void 0}clone(){return new e(this.bytes.slice(0))}equals(e){return this.compareTo(e)===0}compareTo(e){for(let t=0;t<16;t++){let n=this.bytes[t]-e.bytes[t];if(n!==0)return Math.sign(n)}return 0}},Tkt=class{constructor(e){this.timestamp=0,this.counter=0,this.random=e??Ekt()}generate(){return this.generateOrResetCore(Date.now(),1e4)}generateOrAbort(){return this.generateOrAbortCore(Date.now(),1e4)}generateOrResetCore(e,t){let n=this.generateOrAbortCore(e,t);return n===void 0&&(this.timestamp=0,n=this.generateOrAbortCore(e,t)),n}generateOrAbortCore(e,t){if(!Number.isInteger(e)||e<1||e>0xffffffffffff)throw RangeError("`unixTsMs` must be a 48-bit positive integer");if(t<0||t>0xffffffffffff)throw RangeError("`rollbackAllowance` out of reasonable range");if(e>this.timestamp)this.timestamp=e,this.resetCounter();else{if(!(e+t>=this.timestamp))return;this.counter++,this.counter>4398046511103&&(this.timestamp++,this.resetCounter())}return wkt.fromFieldsV7(this.timestamp,Math.trunc(this.counter/2**30),this.counter&2**30-1,this.random.nextUint32())}resetCounter(){this.counter=1024*this.random.nextUint32()+(1023&this.random.nextUint32())}generateV4(){let e=new Uint8Array(Uint32Array.of(this.random.nextUint32(),this.random.nextUint32(),this.random.nextUint32(),this.random.nextUint32()).buffer);return e[6]=64|e[6]>>>4,e[8]=128|e[8]>>>2,wkt.ofInner(e)}};const Ekt=()=>({nextUint32:()=>65536*Math.trunc(65536*Math.random())+Math.trunc(65536*Math.random())});let Dkt;const z$=()=>Okt().toString(),Okt=()=>(Dkt||=new Tkt).generate(),kkt=/* @__PURE__ */ `amazonbot,amazonproductbot,app.hypefactors.com,applebot,archive.org_bot,awariobot,backlinksextendedbot,baiduspider,bingbot,bingpreview,chrome-lighthouse,dataforseobot,deepscan,duckduckbot,facebookexternal,facebookcatalog,http://yandex.com/bots,hubspot,ia_archiver,leikibot,linkedinbot,meta-externalagent,mj12bot,msnbot,nessus,petalbot,pinterest,prerender,rogerbot,screaming frog,sebot-wa,sitebulb,slackbot,slurp,trendictionbot,turnitin,twitterbot,vercel-screenshot,vercelbot,yahoo! slurp,yandexbot,zoombot,bot.htm,bot.php,(bot;,bot/,crawler,ahrefsbot,ahrefssiteaudit,semrushbot,siteauditbot,splitsignalbot,gptbot,oai-searchbot,chatgpt-user,perplexitybot,better uptime bot,sentryuptimebot,uptimerobot,headlesschrome,cypress,google-hoteladsverifier,adsbot-google,apis-google,duplexweb-google,feedfetcher-google,google favicon,google web preview,google-read-aloud,googlebot,googleother,google-cloudvertexbot,googleweblight,mediapartners-google,storebot-google,google-inspectiontool,bytespider`.split(`,`),Akt=function(e,t=[]){if(!e)return!1;let n=e.toLowerCase();return kkt.concat(t).some(e=>{let t=e.toLowerCase();return n.indexOf(t)!==-1})};var B$=/*#__PURE__*/ function(e){return e.AnonymousId=`anonymous_id`,e.DistinctId=`distinct_id`,e.Props=`props`,e.FeatureFlagDetails=`feature_flag_details`,e.FeatureFlags=`feature_flags`,e.FeatureFlagPayloads=`feature_flag_payloads`,e.BootstrapFeatureFlagDetails=`bootstrap_feature_flag_details`,e.BootstrapFeatureFlags=`bootstrap_feature_flags`,e.BootstrapFeatureFlagPayloads=`bootstrap_feature_flag_payloads`,e.OverrideFeatureFlags=`override_feature_flags`,e.Queue=`queue`,e.OptedOut=`opted_out`,e.SessionId=`session_id`,e.SessionStartTimestamp=`session_start_timestamp`,e.SessionLastTimestamp=`session_timestamp`,e.PersonProperties=`person_properties`,e.GroupProperties=`group_properties`,e.InstalledAppBuild=`installed_app_build`,e.InstalledAppVersion=`installed_app_version`,e.SessionReplay=`session_replay`,e.SurveyLastSeenDate=`survey_last_seen_date`,e.SurveysSeen=`surveys_seen`,e.Surveys=`surveys`,e.RemoteConfig=`remote_config`,e.FlagsEndpointWasHit=`flags_endpoint_was_hit`,e}({});const jkt=Array.isArray,Mkt=Object.prototype;Mkt.hasOwnProperty;const V$=Mkt.toString,Nkt=jkt||function(e){return V$.call(e)===`[object Array]`},Pkt=e=>e===void 0,Fkt=e=>V$.call(e)==`[object String]`,Ikt=e=>Fkt(e)&&e.trim().length===0,Lkt=e=>V$.call(e)==`[object Number]`,Rkt=e=>e instanceof Error;function zkt(e,t){try{return e instanceof t}catch{return!1}}function Bkt(e){return typeof e!=`object`||!e}function Vkt(e,t){return Object.prototype.toString.call(e)===`[object ${t}]`}function Hkt(e){return!Pkt(Event)&&zkt(e,Event)}function Ukt(e){return Vkt(e,`Object`)}function H$(e,t,n,r,i){return t>n&&(r.warn(`min cannot be greater than max.`),t=n),Lkt(e)?e>n?(r.warn(` cannot be greater than max: `+n+`. Using max value instead.`),n):e<t?(r.warn(` cannot be less than min: `+t+`. Using min value instead.`),t):e:(r.warn(` must be a number. using max or fallback. max: `+n+`, fallback: `+i),H$(i||n,t,n,r))}var Wkt=class{constructor(e){this._buckets={},this._onBucketRateLimited=e._onBucketRateLimited,this._bucketSize=H$(e.bucketSize,0,100,e._logger),this._refillRate=H$(e.refillRate,0,this._bucketSize,e._logger),this._refillInterval=H$(e.refillInterval,0,864e5,e._logger)}_applyRefill(e,t){let n=t-e.lastAccess,r=Math.floor(n/this._refillInterval);if(r>0){let t=r*this._refillRate;e.tokens=Math.min(e.tokens+t,this._bucketSize),e.lastAccess+=r*this._refillInterval}}consumeRateLimit(e){let t=Date.now(),n=String(e),r=this._buckets[n];return r?this._applyRefill(r,t):(r={tokens:this._bucketSize,lastAccess:t},this._buckets[n]=r),r.tokens===0||(r.tokens--,r.tokens===0&&this._onBucketRateLimited?.(e),r.tokens===0)}stop(){this._buckets={}}},Gkt=class{add(e){let t=z$();return this.promiseByIds[t]=e,e.catch(()=>{}).finally(()=>{delete this.promiseByIds[t]}),e}async join(){let e=Object.values(this.promiseByIds),t=e.length;for(;t>0;)await Promise.all(e),e=Object.values(this.promiseByIds),t=e.length}get length(){return Object.keys(this.promiseByIds).length}constructor(){this.promiseByIds={}}};function Kkt(e=console){return{log:e.log.bind(e),warn:e.warn.bind(e),error:e.error.bind(e),debug:e.debug.bind(e)}}const qkt=(e,t,n)=>{function r(r,...i){t(()=>{let t=n[r];t(e,...i)})}return{info:(...e)=>{r(`log`,...e)},warn:(...e)=>{r(`warn`,...e)},error:(...e)=>{r(`error`,...e)},critical:(...t)=>{n.error(e,...t)},createLogger:r=>qkt(`${e} ${r}`,t,n)}},Jkt=e=>e();function Ykt(e,t=Jkt){return qkt(e,t,Kkt())}function Xkt(e,t){if(!e||typeof e!=`string`||Zkt(e))throw Error(t)}function Zkt(e){return e.trim().length===0}function Qkt(e){return e?.replace(/\/+$/,``)}async function $kt(e,t){let n=null;for(let r=0;r<t.retryCount+1;r++){r>0&&await new Promise(e=>setTimeout(e,t.retryDelay));try{return await e()}catch(e){if(n=e,!t.retryCheck(e))throw e}}throw n}function U$(){return(/* @__PURE__ */ new Date()).toISOString()}function W$(e,t){let n=setTimeout(e,t);return n?.unref&&n?.unref(),n}const eAt=e=>e instanceof Error;function tAt(e){return Promise.all(e.map(e=>(e??Promise.resolve()).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}var nAt=class{constructor(){this.events={},this.events={}}on(e,t){return this.events[e]||(this.events[e]=[]),this.events[e].push(t),()=>{this.events[e]=this.events[e].filter(e=>e!==t)}}emit(e,t){for(let n of this.events[e]||[])n(t);for(let n of this.events[`*`]||[])n(e,t)}};function rAt(){return`CompressionStream`in globalThis}async function iAt(e,t=!0){try{let t=new Blob([e],{type:`text/plain`}).stream().pipeThrough(new CompressionStream(`gzip`));return await new Response(t).blob()}catch(e){return t&&console.error(`Failed to gzip compress data`,e),null}}var G$=class extends Error{constructor(e,t){super(`HTTP error while fetching PostHog: status=`+e.status+`, reqByteLength=`+t),this.response=e,this.reqByteLength=t,this.name=`PostHogFetchHttpError`}get status(){return this.response.status}get text(){return this.response.text()}get json(){return this.response.json()}},K$=class extends Error{constructor(e){super(`Network error while fetching PostHog`,e instanceof Error?{cause:e}:{}),this.error=e,this.name=`PostHogFetchNetworkError`}};async function aAt(e){if(e instanceof G$){let t=``;try{t=await e.text}catch{}console.error(`Error while flushing PostHog: message=${e.message}, response body=${t}`,e)}else console.error(`Error while flushing PostHog`,e);return Promise.resolve()}function q$(e){return typeof e==`object`&&(e instanceof G$||e instanceof K$)}function oAt(e){return typeof e==`object`&&e instanceof G$&&e.status===413}var sAt=class{constructor(e,t={}){this.flushPromise=null,this.shutdownPromise=null,this.promiseQueue=new Gkt,this._events=new nAt,this._isInitialized=!1,Xkt(e,`You must pass your PostHog project's api key.`),this.apiKey=e,this.host=Qkt(t.host||`https://us.i.posthog.com`),this.flushAt=t.flushAt?Math.max(t.flushAt,1):20,this.maxBatchSize=Math.max(this.flushAt,t.maxBatchSize??100),this.maxQueueSize=Math.max(this.flushAt,t.maxQueueSize??1e3),this.flushInterval=t.flushInterval??1e4,this.preloadFeatureFlags=t.preloadFeatureFlags??!0,this.defaultOptIn=t.defaultOptIn??!0,this.disableSurveys=t.disableSurveys??!1,this._retryOptions={retryCount:t.fetchRetryCount??3,retryDelay:t.fetchRetryDelay??3e3,retryCheck:q$},this.requestTimeout=t.requestTimeout??1e4,this.featureFlagsRequestTimeoutMs=t.featureFlagsRequestTimeoutMs??3e3,this.remoteConfigRequestTimeoutMs=t.remoteConfigRequestTimeoutMs??3e3,this.disableGeoip=t.disableGeoip??!0,this.disabled=t.disabled??!1,this.historicalMigration=t?.historicalMigration??!1,this.evaluationEnvironments=t?.evaluationEnvironments,this._initPromise=Promise.resolve(),this._isInitialized=!0,this._logger=Ykt(`[PostHog]`,this.logMsgIfDebug.bind(this)),this.disableCompression=!rAt()||(t?.disableCompression??!1)}logMsgIfDebug(e){this.isDebug&&e()}wrap(e){if(this.disabled)return void this._logger.warn(`The client is disabled`);if(this._isInitialized)return e();this._initPromise.then(()=>e())}getCommonEventProperties(){return{$lib:this.getLibraryId(),$lib_version:this.getLibraryVersion()}}get optedOut(){return this.getPersistedProperty(B$.OptedOut)??!this.defaultOptIn}async optIn(){this.wrap(()=>{this.setPersistedProperty(B$.OptedOut,!1)})}async optOut(){this.wrap(()=>{this.setPersistedProperty(B$.OptedOut,!0)})}on(e,t){return this._events.on(e,t)}debug(e=!0){if(this.removeDebugCallback?.(),e){let e=this.on(`*`,(e,t)=>this._logger.info(e,t));this.removeDebugCallback=()=>{e(),this.removeDebugCallback=void 0}}}get isDebug(){return!!this.removeDebugCallback}get isDisabled(){return this.disabled}buildPayload(e){return{distinct_id:e.distinct_id,event:e.event,properties:{...e.properties||{},...this.getCommonEventProperties()}}}addPendingPromise(e){return this.promiseQueue.add(e)}identifyStateless(e,t,n){this.wrap(()=>{let r={...this.buildPayload({distinct_id:e,event:`$identify`,properties:t})};this.enqueue(`identify`,r,n)})}async identifyStatelessImmediate(e,t,n){let r={...this.buildPayload({distinct_id:e,event:`$identify`,properties:t})};await this.sendImmediate(`identify`,r,n)}captureStateless(e,t,n,r){this.wrap(()=>{let i=this.buildPayload({distinct_id:e,event:t,properties:n});this.enqueue(`capture`,i,r)})}async captureStatelessImmediate(e,t,n,r){let i=this.buildPayload({distinct_id:e,event:t,properties:n});await this.sendImmediate(`capture`,i,r)}aliasStateless(e,t,n,r){this.wrap(()=>{let i=this.buildPayload({event:`$create_alias`,distinct_id:t,properties:{...n||{},distinct_id:t,alias:e}});this.enqueue(`alias`,i,r)})}async aliasStatelessImmediate(e,t,n,r){let i=this.buildPayload({event:`$create_alias`,distinct_id:t,properties:{...n||{},distinct_id:t,alias:e}});await this.sendImmediate(`alias`,i,r)}groupIdentifyStateless(e,t,n,r,i,a){this.wrap(()=>{let o=this.buildPayload({distinct_id:i||`$${e}_${t}`,event:`$groupidentify`,properties:{$group_type:e,$group_key:t,$group_set:n||{},...a||{}}});this.enqueue(`capture`,o,r)})}async getRemoteConfig(){await this._initPromise;let e=this.host;e===`https://us.i.posthog.com`?e=`https://us-assets.i.posthog.com`:e===`https://eu.i.posthog.com`&&(e=`https://eu-assets.i.posthog.com`);let t=`${e}/array/${this.apiKey}/config`,n={method:`GET`,headers:{...this.getCustomHeaders(),"Content-Type":`application/json`}};return this.fetchWithRetry(t,n,{retryCount:0},this.remoteConfigRequestTimeoutMs).then(e=>e.json()).catch(e=>{this._logger.error(`Remote config could not be loaded`,e),this._events.emit(`error`,e)})}async getFlags(e,t={},n={},r={},i={},a=!0){await this._initPromise;let o=a?`&config=true`:``,s=`${this.host}/flags/?v=2${o}`,c={token:this.apiKey,distinct_id:e,groups:t,person_properties:n,group_properties:r,...i};this.evaluationEnvironments&&this.evaluationEnvironments.length>0&&(c.evaluation_environments=this.evaluationEnvironments);let l={method:`POST`,headers:{...this.getCustomHeaders(),"Content-Type":`application/json`},body:JSON.stringify(c)};return this._logger.info(`Flags URL`,s),this.fetchWithRetry(s,l,{retryCount:0},this.featureFlagsRequestTimeoutMs).then(e=>e.json()).then(e=>ykt(e)).catch(e=>{this._events.emit(`error`,e)})}async getFeatureFlagStateless(e,t,n={},r={},i={},a){await this._initPromise;let o=await this.getFeatureFlagDetailStateless(e,t,n,r,i,a);if(o===void 0)return{response:void 0,requestId:void 0};let s=L$(o.response);return s===void 0&&(s=!1),{response:s,requestId:o.requestId}}async getFeatureFlagDetailStateless(e,t,n={},r={},i={},a){await this._initPromise;let o=await this.getFeatureFlagDetailsStateless(t,n,r,i,a,[e]);if(o!==void 0)return{response:o.flags[e],requestId:o.requestId,evaluatedAt:o.evaluatedAt}}async getFeatureFlagPayloadStateless(e,t,n={},r={},i={},a){await this._initPromise;let o=await this.getFeatureFlagPayloadsStateless(t,n,r,i,a,[e]);if(!o)return;let s=o[e];return s===void 0?null:s}async getFeatureFlagPayloadsStateless(e,t={},n={},r={},i,a){return await this._initPromise,(await this.getFeatureFlagsAndPayloadsStateless(e,t,n,r,i,a)).payloads}async getFeatureFlagsStateless(e,t={},n={},r={},i,a){return await this._initPromise,await this.getFeatureFlagsAndPayloadsStateless(e,t,n,r,i,a)}async getFeatureFlagsAndPayloadsStateless(e,t={},n={},r={},i,a){await this._initPromise;let o=await this.getFeatureFlagDetailsStateless(e,t,n,r,i,a);return o?{flags:o.featureFlags,payloads:o.featureFlagPayloads,requestId:o.requestId}:{flags:void 0,payloads:void 0,requestId:void 0}}async getFeatureFlagDetailsStateless(e,t={},n={},r={},i,a){await this._initPromise;let o={};(i??this.disableGeoip)&&(o.geoip_disable=!0),a&&(o.flag_keys_to_evaluate=a);let s=await this.getFlags(e,t,n,r,o);if(s!==void 0)return s.errorsWhileComputingFlags&&console.error(`[FEATURE FLAGS] Error while computing feature flags, some flags may be missing or incorrect. Learn more at https://posthog.com/docs/feature-flags/best-practices`),s.quotaLimited?.includes(`feature_flags`)?(console.warn(`[FEATURE FLAGS] Feature flags quota limit exceeded - feature flags unavailable. Learn more about billing limits at https://posthog.com/docs/billing/limits-alerts`),{flags:{},featureFlags:{},featureFlagPayloads:{},requestId:s?.requestId}):s}async getSurveysStateless(){if(await this._initPromise,!0===this.disableSurveys)return this._logger.info(`Loading surveys is disabled.`),[];let e=`${this.host}/api/surveys/?token=${this.apiKey}`,t={method:`GET`,headers:{...this.getCustomHeaders(),"Content-Type":`application/json`}},n=(await this.fetchWithRetry(e,t).then(e=>{if(e.status!==200||!e.json){let t=`Surveys API could not be loaded: ${e.status}`,n=Error(t);this._logger.error(n),this._events.emit(`error`,Error(t))}else return e.json()}).catch(e=>{this._logger.error(`Surveys API could not be loaded`,e),this._events.emit(`error`,e)}))?.surveys;return n&&this._logger.info(`Surveys fetched from API: `,JSON.stringify(n)),n??[]}get props(){return this._props||=this.getPersistedProperty(B$.Props),this._props||{}}set props(e){this._props=e}async register(e){this.wrap(()=>{this.props={...this.props,...e},this.setPersistedProperty(B$.Props,this.props)})}async unregister(e){this.wrap(()=>{delete this.props[e],this.setPersistedProperty(B$.Props,this.props)})}enqueue(e,t,n){this.wrap(()=>{if(this.optedOut)return void this._events.emit(e,`Library is disabled. Not sending event. To re-enable, call posthog.optIn()`);let r=this.prepareMessage(e,t,n),i=this.getPersistedProperty(B$.Queue)||[];i.length>=this.maxQueueSize&&(i.shift(),this._logger.info(`Queue is full, the oldest event is dropped.`)),i.push({message:r}),this.setPersistedProperty(B$.Queue,i),this._events.emit(e,r),i.length>=this.flushAt&&this.flushBackground(),this.flushInterval&&!this._flushTimer&&(this._flushTimer=W$(()=>this.flushBackground(),this.flushInterval))})}async sendImmediate(e,t,n){if(this.disabled)return void this._logger.warn(`The client is disabled`);if(this._isInitialized||await this._initPromise,this.optedOut)return void this._events.emit(e,`Library is disabled. Not sending event. To re-enable, call posthog.optIn()`);let r={api_key:this.apiKey,batch:[this.prepareMessage(e,t,n)],sent_at:U$()};this.historicalMigration&&(r.historical_migration=!0);let i=JSON.stringify(r),a=`${this.host}/batch/`,o=this.disableCompression?null:await iAt(i,this.isDebug),s={method:`POST`,headers:{...this.getCustomHeaders(),"Content-Type":`application/json`,...o!==null&&{"Content-Encoding":`gzip`}},body:o||i};try{await this.fetchWithRetry(a,s)}catch(e){this._events.emit(`error`,e)}}prepareMessage(e,t,n){let r={...t,type:e,library:this.getLibraryId(),library_version:this.getLibraryVersion(),timestamp:n?.timestamp?n?.timestamp:U$(),uuid:n?.uuid?n.uuid:z$()};return(n?.disableGeoip??this.disableGeoip)&&(r.properties||={},r.properties.$geoip_disable=!0),r.distinctId&&(r.distinct_id=r.distinctId,delete r.distinctId),r}clearFlushTimer(){this._flushTimer&&=(clearTimeout(this._flushTimer),void 0)}flushBackground(){this.flush().catch(async e=>{await aAt(e)})}async flush(){let e=tAt([this.flushPromise]).then(()=>this._flush());return this.flushPromise=e,this.addPendingPromise(e),tAt([e]).then(()=>{this.flushPromise===e&&(this.flushPromise=null)}),e}getCustomHeaders(){let e=this.getCustomUserAgent(),t={};return e&&e!==``&&(t[`User-Agent`]=e),t}async _flush(){this.clearFlushTimer(),await this._initPromise;let e=this.getPersistedProperty(B$.Queue)||[];if(!e.length)return;let t=[],n=e.length;for(;e.length>0&&t.length<n;){let n=e.slice(0,this.maxBatchSize),r=n.map(e=>e.message),i=()=>{let t=(this.getPersistedProperty(B$.Queue)||[]).slice(n.length);this.setPersistedProperty(B$.Queue,t),e=t},a={api_key:this.apiKey,batch:r,sent_at:U$()};this.historicalMigration&&(a.historical_migration=!0);let o=JSON.stringify(a),s=`${this.host}/batch/`,c=this.disableCompression?null:await iAt(o,this.isDebug),l={method:`POST`,headers:{...this.getCustomHeaders(),"Content-Type":`application/json`,...c!==null&&{"Content-Encoding":`gzip`}},body:c||o},u={retryCheck:e=>!oAt(e)&&q$(e)};try{await this.fetchWithRetry(s,l,u)}catch(e){if(oAt(e)&&r.length>1){this.maxBatchSize=Math.max(1,Math.floor(r.length/2)),this._logger.warn(`Received 413 when sending batch of size ${r.length}, reducing batch size to ${this.maxBatchSize}`);continue}throw e instanceof K$||i(),this._events.emit(`error`,e),e}i(),t.push(...r)}this._events.emit(`flush`,t)}async fetchWithRetry(e,t,n,r){AbortSignal.timeout??=function(e){let t=new AbortController;return setTimeout(()=>t.abort(),e),t.signal};let i=t.body?t.body:``,a=-1;try{a=i instanceof Blob?i.size:Buffer.byteLength(i,`utf8`)}catch{a=i instanceof Blob?i.size:new TextEncoder().encode(i).length}return await $kt(async()=>{let n=null;try{n=await this.fetch(e,{signal:AbortSignal.timeout(r??this.requestTimeout),...t})}catch(e){throw new K$(e)}if(t.mode!==`no-cors`&&(n.status<200||n.status>=400))throw new G$(n,a);return n},{...this._retryOptions,...n})}async _shutdown(e=3e4){await this._initPromise;let t=!1;return this.clearFlushTimer(),Promise.race([new Promise((n,r)=>{W$(()=>{this._logger.error(`Timed out while shutting down PostHog`),t=!0,r(`Timeout while shutting down PostHog. Some events may not have been sent.`)},e)}),(async()=>{try{for(await this.promiseQueue.join();!((this.getPersistedProperty(B$.Queue)||[]).length===0||(await this.flush(),t)););}catch(e){if(!q$(e))throw e;await aAt(e)}})()])}async shutdown(e=3e4){return this.shutdownPromise?this._logger.warn(`shutdown() called while already shutting down. shutdown() is meant to be called once before process exit - use flush() for per-request cleanup`):this.shutdownPromise=this._shutdown(e).finally(()=>{this.shutdownPromise=null}),this.shutdownPromise}};let J$,cAt,Y$;function lAt(e){let t=globalThis._posthogChunkIds;if(!t)return;let n=Object.keys(t);return Y$&&n.length===cAt||(cAt=n.length,Y$=n.reduce((n,r)=>{J$||={};let i=J$[r];if(i)n[i[0]]=i[1];else{let i=e(r);for(let e=i.length-1;e>=0;e--){let a=i[e]?.filename,o=t[r];if(a&&o){n[a]=o,J$[r]=[a,o];break}}}return n},{})),Y$}var uAt=class{constructor(e,t,n=[]){this.coercers=e,this.stackParser=t,this.modifiers=n}buildFromUnknown(e,t={}){let n=t&&t.mechanism||{handled:!0,type:`generic`},r=this.buildCoercingContext(n,t,0).apply(e),i=this.buildParsingContext(),a=this.parseStacktrace(r,i);return{$exception_list:this.convertToExceptionList(a,n),$exception_level:`error`}}async modifyFrames(e){for(let t of e)t.stacktrace&&t.stacktrace.frames&&Nkt(t.stacktrace.frames)&&(t.stacktrace.frames=await this.applyModifiers(t.stacktrace.frames));return e}coerceFallback(e){return{type:`Error`,value:`Unknown error`,stack:e.syntheticException?.stack,synthetic:!0}}parseStacktrace(e,t){let n;e.cause!=null&&(n=this.parseStacktrace(e.cause,t));let r;return e.stack!=``&&e.stack!=null&&(r=this.applyChunkIds(this.stackParser(e.stack,+!!e.synthetic),t.chunkIdMap)),{...e,cause:n,stack:r}}applyChunkIds(e,t){return e.map(e=>(e.filename&&t&&(e.chunk_id=t[e.filename]),e))}applyCoercers(e,t){for(let n of this.coercers)if(n.match(e))return n.coerce(e,t);return this.coerceFallback(t)}async applyModifiers(e){let t=e;for(let e of this.modifiers)t=await e(t);return t}convertToExceptionList(e,t){let n={type:e.type,value:e.value,mechanism:{type:t.type??`generic`,handled:t.handled??!0,synthetic:e.synthetic??!1}};e.stack&&(n.stacktrace={type:`raw`,frames:e.stack});let r=[n];return e.cause!=null&&r.push(...this.convertToExceptionList(e.cause,{...t,handled:!0})),r}buildParsingContext(){return{chunkIdMap:lAt(this.stackParser)}}buildCoercingContext(e,t,n=0){let r=(n,r)=>{if(r<=4){let i=this.buildCoercingContext(e,t,r);return this.applyCoercers(n,i)}};return{...t,syntheticException:n==0?t.syntheticException:void 0,mechanism:e,apply:e=>r(e,n),next:e=>r(e,n+1)}}};const dAt=/^\s*[-]{4,}$/,fAt=/at (?:async )?(?:(.+?)\s+\()?(?:(.+):(\d+):(\d+)?|([^)]+))\)?/,pAt=(e,t)=>{let n=e.match(fAt);if(n){let e,r,i,a,o;if(n[1]){i=n[1];let t=i.lastIndexOf(`.`);if(i[t-1]===`.`&&t--,t>0){e=i.slice(0,t),r=i.slice(t+1);let n=e.indexOf(`.Module`);n>0&&(i=i.slice(n+1),e=e.slice(0,n))}a=void 0}r&&(a=e,o=r),r===`<anonymous>`&&(o=void 0,i=void 0),i===void 0&&(o||=`?`,i=a?`${a}.${o}`:o);let s=n[2]?.startsWith(`file://`)?n[2].slice(7):n[2],c=n[5]===`native`;return s?.match(/\/[A-Z]:/)&&(s=s.slice(1)),!s&&n[5]&&!c&&(s=n[5]),{filename:s?decodeURI(s):void 0,module:void 0,function:i,lineno:hAt(n[3]),colno:hAt(n[4]),in_app:mAt(s||``,c),platform:t}}if(e.match(dAt))return{filename:e,platform:t}};function mAt(e,t=!1){return!(t||e&&!e.startsWith(`/`)&&!e.match(/^[A-Z]:/)&&!e.startsWith(`.`)&&!e.match(/^[a-zA-Z]([a-zA-Z0-9.\-+])*:\/\//))&&e!==void 0&&!e.includes(`node_modules/`)}function hAt(e){return parseInt(e||``,10)||void 0}const gAt=/\(error: (.*)\)/;function _At(e){if(!e.length)return[];let t=Array.from(e);return t.reverse(),t.slice(0,50).map(e=>({...e,filename:e.filename||vAt(t).filename,function:e.function||`?`}))}function vAt(e){return e[e.length-1]||{}}function yAt(e,...t){return(n,r=0)=>{let i=[],a=n.split(`
|
|
1925
|
-
`);for(let n=r;n<a.length;n++){let r=a[n];if(r.length>1024)continue;let o=gAt.test(r)?r.replace(gAt,`$1`):r;if(!o.match(/\S*Error: /)){for(let n of t){let t=n(o,e);if(t){i.push(t);break}}if(i.length>=50)break}}return _At(i)}}var bAt=class{match(e){return Rkt(e)}coerce(e,t){return{type:this.getType(e),value:this.getMessage(e,t),stack:this.getStack(e),cause:e.cause?t.next(e.cause):void 0,synthetic:!1}}getType(e){return e.name||e.constructor.name}getMessage(e,t){let n=e.message;return n.error&&typeof n.error.message==`string`?String(n.error.message):String(n)}getStack(e){return e.stacktrace||e.stack||void 0}};const xAt=/^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/i;var SAt=class{match(e){return typeof e==`string`}coerce(e,t){let[n,r]=this.getInfos(e);return{type:n??`Error`,value:r??e,stack:t.syntheticException?.stack,synthetic:!0}}getInfos(e){let t=`Error`,n=e,r=e.match(xAt);return r&&(t=r[1],n=r[2]),[t,n]}};const CAt=[`fatal`,`error`,`warning`,`log`,`info`,`debug`];function wAt(e,t=40){let n=Object.keys(e);if(n.sort(),!n.length)return`[object has no keys]`;for(let e=n.length;e>0;e--){let r=n.slice(0,e).join(`, `);if(!(r.length>t))return e===n.length||r.length<=t?r:`${r.slice(0,t)}...`}return``}var TAt=class{match(e){return typeof e==`object`&&!!e}coerce(e,t){let n=this.getErrorPropertyFromObject(e);return n?t.apply(n):{type:this.getType(e),value:this.getValue(e),stack:t.syntheticException?.stack,level:this.isSeverityLevel(e.level)?e.level:`error`,synthetic:!0}}getType(e){return Hkt(e)?e.constructor.name:`Error`}getValue(e){if(`name`in e&&typeof e.name==`string`){let t=`'${e.name}' captured as exception`;return`message`in e&&typeof e.message==`string`&&(t+=` with message: '${e.message}'`),t}if(`message`in e&&typeof e.message==`string`)return e.message;let t=this.getObjectClassName(e),n=wAt(e);return`${t&&t!==`Object`?`'${t}'`:`Object`} captured as exception with keys: ${n}`}isSeverityLevel(e){return Fkt(e)&&!Ikt(e)&&CAt.indexOf(e)>=0}getErrorPropertyFromObject(e){for(let t in e)if(Object.prototype.hasOwnProperty.call(e,t)){let n=e[t];if(eAt(n))return n}}getObjectClassName(e){try{let t=Object.getPrototypeOf(e);return t?t.constructor.name:void 0}catch{return}}},EAt=class{match(e){return Hkt(e)}coerce(e,t){let n=e.constructor.name;return{type:n,value:`${n} captured as exception with keys: ${wAt(e)}`,stack:t.syntheticException?.stack,synthetic:!0}}},DAt=class{match(e){return Bkt(e)}coerce(e,t){return{type:`Error`,value:`Primitive value captured as exception: ${String(e)}`,stack:t.syntheticException?.stack,synthetic:!0}}},OAt=class{constructor(e){this._maxSize=e,this._cache=/* @__PURE__ */ new Map}get(e){let t=this._cache.get(e);if(t!==void 0)return this._cache.delete(e),this._cache.set(e,t),t}set(e,t){this._cache.set(e,t)}reduce(){for(;this._cache.size>=this._maxSize;){let e=this._cache.keys().next().value;e&&this._cache.delete(e)}}};const X$=new OAt(25),kAt=new OAt(20);async function AAt(e){let t={};for(let n=e.length-1;n>=0;n--){let r=e[n],i=r?.filename;!r||typeof i!=`string`||typeof r.lineno!=`number`||FAt(i)||IAt(r)||(t[i]||(t[i]=[]),t[i].push(r.lineno))}let n=Object.keys(t);if(n.length==0)return e;let r=[];for(let e of n){if(kAt.get(e))continue;let n=t[e];if(!n)continue;n.sort((e,t)=>e-t);let i=RAt(n);if(i.every(t=>LAt(e,t)))continue;let a=HAt(X$,e,{});r.push(jAt(e,i,a))}return await Promise.all(r).catch(()=>{}),e&&e.length>0&&MAt(e,X$),X$.reduce(),e}function jAt(e,t,n){return new Promise(r=>{let i=Dn(e),a=Ar({input:i});function o(){i.destroy(),r()}let s=0,c=0,l=t[c];if(l===void 0)return void o();let u=l[0],d=l[1];function f(){kAt.set(e,1),a.close(),a.removeAllListeners(),o()}i.on(`error`,f),a.on(`error`,f),a.on(`close`,o),a.on(`line`,e=>{if(s++,!(s<u)&&(n[s]=UAt(e,0),s>=d)){if(c===t.length-1){a.close(),a.removeAllListeners();return}c++;let e=t[c];if(e===void 0){a.close(),a.removeAllListeners();return}u=e[0],d=e[1]}})})}function MAt(e,t){for(let n of e)if(n.filename&&n.context_line===void 0&&typeof n.lineno==`number`){let e=t.get(n.filename);if(e===void 0)continue;NAt(n.lineno,n,e)}}function NAt(e,t,n){if(t.lineno===void 0||n===void 0)return;t.pre_context=[];for(let r=BAt(e);r<e;r++){let e=n[r];if(e===void 0)return void PAt(t);t.pre_context.push(e)}if(n[e]===void 0)return void PAt(t);t.context_line=n[e];let r=VAt(e);t.post_context=[];for(let i=e+1;i<=r;i++){let e=n[i];if(e===void 0)break;t.post_context.push(e)}}function PAt(e){delete e.pre_context,delete e.context_line,delete e.post_context}function FAt(e){return e.startsWith(`node:`)||e.endsWith(`.min.js`)||e.endsWith(`.min.cjs`)||e.endsWith(`.min.mjs`)||e.startsWith(`data:`)}function IAt(e){return e.lineno!==void 0&&e.lineno>1e4||e.colno!==void 0&&e.colno>1e3}function LAt(e,t){let n=X$.get(e);if(n===void 0)return!1;for(let e=t[0];e<=t[1];e++)if(n[e]===void 0)return!1;return!0}function RAt(e){if(!e.length)return[];let t=0,n=e[0];if(typeof n!=`number`)return[];let r=zAt(n),i=[];for(;;){if(t===e.length-1){i.push(r);break}let n=e[t+1];if(typeof n!=`number`)break;n<=r[1]?r[1]=n+7:(i.push(r),r=zAt(n)),t++}return i}function zAt(e){return[BAt(e),VAt(e)]}function BAt(e){return Math.max(1,e-7)}function VAt(e){return e+7}function HAt(e,t,n){let r=e.get(t);return r===void 0?(e.set(t,n),n):r}function UAt(e,t){let n=e,r=n.length;if(r<=150)return n;t>r&&(t=r);let i=Math.max(t-60,0);i<5&&(i=0);let a=Math.min(i+140,r);return a>r-5&&(a=r),a===r&&(i=Math.max(a-140,0)),n=n.slice(i,a),i>0&&(n=`...${n}`),a<r&&(n+=`...`),n}function WAt(e,t){let n=!1;return Object.assign(r=>{let i=global.process.listeners(`uncaughtException`).filter(e=>e.name!==`domainUncaughtExceptionClear`&&!0!==e._posthogErrorHandler).length===0;e(r,{mechanism:{type:`onuncaughtexception`,handled:!1}}),!n&&i&&(n=!0,t(r))},{_posthogErrorHandler:!0})}function GAt(e,t){globalThis.process?.on(`uncaughtException`,WAt(e,t))}function KAt(e){globalThis.process?.on(`unhandledRejection`,t=>e(t,{mechanism:{type:`onunhandledrejection`,handled:!1}}))}var Z$=class e{constructor(e,t,n){this.client=e,this._exceptionAutocaptureEnabled=t.enableExceptionAutocapture||!1,this._logger=n,this._rateLimiter=new Wkt({refillRate:1,bucketSize:10,refillInterval:1e4,_logger:this._logger}),this.startAutocaptureIfEnabled()}static async buildEventMessage(e,t,n,r){let i={...r};n||(i.$process_person_profile=!1);let a=this.errorPropertiesBuilder.buildFromUnknown(e,t);return a.$exception_list=await this.errorPropertiesBuilder.modifyFrames(a.$exception_list),{event:`$exception`,distinctId:n||z$(),properties:{...a,...i}}}startAutocaptureIfEnabled(){this.isEnabled()&&(GAt(this.onException.bind(this),this.onFatalError.bind(this)),KAt(this.onException.bind(this)))}onException(t,n){this.client.addPendingPromise((async()=>{let r=await e.buildEventMessage(t,n),i=r.properties?.$exception_list[0]?.type??`Exception`;return this._rateLimiter.consumeRateLimit(i)?void this._logger.info(`Skipping exception capture because of client rate limiting.`,{exception:i}):this.client.capture(r)})())}async onFatalError(e){console.error(e),await this.client.shutdown(2e3),process.exit(1)}isEnabled(){return!this.client.isDisabled&&this._exceptionAutocaptureEnabled}shutdown(){this._rateLimiter.stop()}};async function qAt(e){let t=globalThis.crypto?.subtle;if(!t)throw Error(`SubtleCrypto API not available`);let n=await t.digest(`SHA-1`,new TextEncoder().encode(e));return Array.from(new Uint8Array(n)).map(e=>e.toString(16).padStart(2,`0`)).join(``)}const JAt=[`is_not`];var Q$=class e extends Error{constructor(t){super(),Error.captureStackTrace(this,this.constructor),this.name=`ClientError`,this.message=t,Object.setPrototypeOf(this,e.prototype)}},$$=class e extends Error{constructor(t){super(t),this.name=this.constructor.name,Error.captureStackTrace(this,this.constructor),Object.setPrototypeOf(this,e.prototype)}},e1=class e extends Error{constructor(t){super(t),this.name=this.constructor.name,Error.captureStackTrace(this,this.constructor),Object.setPrototypeOf(this,e.prototype)}},YAt=class{constructor({pollingInterval:e,personalApiKey:t,projectApiKey:n,timeout:r,host:i,customHeaders:a,...o}){this.debugMode=!1,this.shouldBeginExponentialBackoff=!1,this.backOffCount=0,this.pollingInterval=e,this.personalApiKey=t,this.featureFlags=[],this.featureFlagsByKey={},this.groupTypeMapping={},this.cohorts={},this.loadedSuccessfullyOnce=!1,this.timeout=r,this.projectApiKey=n,this.host=i,this.poller=void 0,this.fetch=o.fetch||fetch,this.onError=o.onError,this.customHeaders=a,this.onLoad=o.onLoad,this.cacheProvider=o.cacheProvider,this.loadFeatureFlags()}debug(e=!0){this.debugMode=e}logMsgIfDebug(e){this.debugMode&&e()}async getFeatureFlag(e,t,n={},r={},i={}){await this.loadFeatureFlags();let a,o;if(!this.loadedSuccessfullyOnce)return a;if(o=this.featureFlagsByKey[e],o!==void 0)try{a=(await this.computeFlagAndPayloadLocally(o,t,n,r,i)).value,this.logMsgIfDebug(()=>console.debug(`Successfully computed flag locally: ${e} -> ${a}`))}catch(t){t instanceof e1||t instanceof $$?this.logMsgIfDebug(()=>console.debug(`${t.name} when computing flag locally: ${e}: ${t.message}`)):t instanceof Error&&this.onError?.(/* @__PURE__ */ Error(`Error computing flag locally: ${e}: ${t}`))}return a}async getAllFlagsAndPayloads(e,t={},n={},r={},i){await this.loadFeatureFlags();let a={},o={},s=this.featureFlags.length==0,c=i?i.map(e=>this.featureFlagsByKey[e]).filter(Boolean):this.featureFlags,l={};return await Promise.all(c.map(async i=>{try{let{value:s,payload:c}=await this.computeFlagAndPayloadLocally(i,e,t,n,r,void 0,l);a[i.key]=s,c&&(o[i.key]=c)}catch(e){e instanceof e1||e instanceof $$?this.logMsgIfDebug(()=>console.debug(`${e.name} when computing flag locally: ${i.key}: ${e.message}`)):e instanceof Error&&this.onError?.(/* @__PURE__ */ Error(`Error computing flag locally: ${i.key}: ${e}`)),s=!0}})),{response:a,payloads:o,fallbackToFlags:s}}async computeFlagAndPayloadLocally(e,t,n={},r={},i={},a,o,s=!1){if(s||await this.loadFeatureFlags(),!this.loadedSuccessfullyOnce)return{value:!1,payload:null};let c;c=a===void 0?await this.computeFlagValueLocally(e,t,n,r,i,o):a;let l=this.getFeatureFlagPayload(e.key,c);return{value:c,payload:l}}async computeFlagValueLocally(e,t,n={},r={},i={},a={}){if(e.ensure_experience_continuity)throw new $$(`Flag has experience continuity enabled`);if(!e.active)return!1;let o=(e.filters||{}).aggregation_group_type_index;if(o==null)return await this.matchFeatureFlagProperties(e,t,r,a);{let t=this.groupTypeMapping[String(o)];if(!t)throw this.logMsgIfDebug(()=>console.warn(`[FEATURE FLAGS] Unknown group type index ${o} for feature flag ${e.key}`)),new $$(`Flag has unknown group type index`);if(!(t in n))return this.logMsgIfDebug(()=>console.warn(`[FEATURE FLAGS] Can't compute group feature flag: ${e.key} without group names passed in`)),!1;let r=i[t];return await this.matchFeatureFlagProperties(e,n[t],r,a)}}getFeatureFlagPayload(e,t){let n=null;if(!1!==t&&t!=null&&(typeof t==`boolean`?n=this.featureFlagsByKey?.[e]?.filters?.payloads?.[t.toString()]||null:typeof t==`string`&&(n=this.featureFlagsByKey?.[e]?.filters?.payloads?.[t]||null),n!=null)){if(typeof n==`object`)return n;if(typeof n==`string`)try{return JSON.parse(n)}catch{}return n}return null}async evaluateFlagDependency(e,t,n,r){let i=e.key;if(!this.featureFlagsByKey)throw new $$(`Feature flags not available for dependency evaluation`);if(!(`dependency_chain`in e))throw new $$(`Flag dependency property for '${i}' is missing required 'dependency_chain' field`);let a=e.dependency_chain;if(!Array.isArray(a))throw new $$(`Flag dependency property for '${i}' has an invalid 'dependency_chain' (expected array, got ${typeof a})`);if(a.length===0)throw new $$(`Circular dependency detected for flag '${i}' (empty dependency chain)`);for(let e of a){if(!(e in r)){let a=this.featureFlagsByKey[e];if(a){if(a.active)try{r[e]=await this.matchFeatureFlagProperties(a,t,n,r)}catch(t){throw new $$(`Error evaluating flag dependency '${e}' for flag '${i}': ${t}`)}else r[e]=!1}else throw new $$(`Missing flag dependency '${e}' for flag '${i}'`)}if(r[e]==null)throw new $$(`Dependency '${e}' could not be evaluated`)}let o=r[i];return this.flagEvaluatesToExpectedValue(e.value,o)}flagEvaluatesToExpectedValue(e,t){return typeof e==`boolean`?e===t||typeof t==`string`&&t!==``&&!0===e:typeof e==`string`&&t===e}async matchFeatureFlagProperties(e,t,n,r={}){let i=e.filters||{},a=i.groups||[],o=!1,s;for(let c of a)try{if(await this.isConditionMatch(e,t,c,n,r)){let n=c.variant,r=i.multivariate?.variants||[];s=n&&r.some(e=>e.key===n)?n:await this.getMatchingVariant(e,t)||!0;break}}catch(e){if(e instanceof e1)throw e;if(e instanceof $$)o=!0;else throw e}if(s!==void 0)return s;if(o)throw new $$(`Can't determine if feature flag is enabled or not with given properties`);return!1}async isConditionMatch(e,t,n,r,i={}){let a=n.rollout_percentage,o=e=>{this.logMsgIfDebug(()=>console.warn(e))};if((n.properties||[]).length>0){for(let e of n.properties){let n=e.type,a=!1;if(a=n===`cohort`?$At(e,r,this.cohorts,this.debugMode):n===`flag`?await this.evaluateFlagDependency(e,t,r,i):ZAt(e,r,o),!a)return!1}if(a==null)return!0}return!(a!=null&&await XAt(e.key,t)>a/100)}async getMatchingVariant(e,t){let n=await XAt(e.key,t,`variant`),r=this.variantLookupTable(e).find(e=>n>=e.valueMin&&n<e.valueMax);if(r)return r.key}variantLookupTable(e){let t=[],n=0,r=0;return((e.filters||{}).multivariate?.variants||[]).forEach(e=>{r=n+e.rollout_percentage/100,t.push({valueMin:n,valueMax:r,key:e.key}),n=r}),t}updateFlagState(e){this.featureFlags=e.flags,this.featureFlagsByKey=e.flags.reduce((e,t)=>(e[t.key]=t,e),{}),this.groupTypeMapping=e.groupTypeMapping,this.cohorts=e.cohorts,this.loadedSuccessfullyOnce=!0}async loadFromCache(e){if(!this.cacheProvider)return!1;try{let t=await this.cacheProvider.getFlagDefinitions();return t?(this.updateFlagState(t),this.logMsgIfDebug(()=>console.debug(`[FEATURE FLAGS] ${e} (${t.flags.length} flags)`)),this.onLoad?.(this.featureFlags.length),!0):!1}catch(e){return this.onError?.(/* @__PURE__ */ Error(`Failed to load from cache: ${e}`)),!1}}async loadFeatureFlags(e=!1){if(!this.loadedSuccessfullyOnce||e)return this.loadingPromise||=this._loadFeatureFlags().catch(e=>this.logMsgIfDebug(()=>console.debug(`[FEATURE FLAGS] Failed to load feature flags: ${e}`))).finally(()=>{this.loadingPromise=void 0}),this.loadingPromise}isLocalEvaluationReady(){return(this.loadedSuccessfullyOnce??!1)&&(this.featureFlags?.length??0)>0}getPollingInterval(){return this.shouldBeginExponentialBackoff?Math.min(6e4,this.pollingInterval*2**this.backOffCount):this.pollingInterval}async _loadFeatureFlags(){this.poller&&=(clearTimeout(this.poller),void 0),this.poller=setTimeout(()=>this.loadFeatureFlags(!0),this.getPollingInterval());try{let e=!0;if(this.cacheProvider)try{e=await this.cacheProvider.shouldFetchFlagDefinitions()}catch(e){this.onError?.(/* @__PURE__ */ Error(`Error in shouldFetchFlagDefinitions: ${e}`))}if(!e&&(await this.loadFromCache(`Loaded flags from cache (skipped fetch)`)||this.loadedSuccessfullyOnce))return;let t=await this._requestFeatureFlagDefinitions();if(!t)return;switch(t.status){case 304:this.logMsgIfDebug(()=>console.debug(`[FEATURE FLAGS] Flags not modified (304), using cached data`)),this.flagsEtag=t.headers?.get(`ETag`)??this.flagsEtag,this.loadedSuccessfullyOnce=!0,this.shouldBeginExponentialBackoff=!1,this.backOffCount=0;return;case 401:throw this.shouldBeginExponentialBackoff=!0,this.backOffCount+=1,new Q$(`Your project key or personal API key is invalid. Setting next polling interval to ${this.getPollingInterval()}ms. More information: https://posthog.com/docs/api#rate-limiting`);case 402:console.warn(`[FEATURE FLAGS] Feature flags quota limit exceeded - unsetting all local flags. Learn more about billing limits at https://posthog.com/docs/billing/limits-alerts`),this.featureFlags=[],this.featureFlagsByKey={},this.groupTypeMapping={},this.cohorts={};return;case 403:throw this.shouldBeginExponentialBackoff=!0,this.backOffCount+=1,new Q$(`Your personal API key does not have permission to fetch feature flag definitions for local evaluation. Setting next polling interval to ${this.getPollingInterval()}ms. Are you sure you're using the correct personal and Project API key pair? More information: https://posthog.com/docs/api/overview`);case 429:throw this.shouldBeginExponentialBackoff=!0,this.backOffCount+=1,new Q$(`You are being rate limited. Setting next polling interval to ${this.getPollingInterval()}ms. More information: https://posthog.com/docs/api#rate-limiting`);case 200:{let n=await t.json()??{};if(!(`flags`in n))return void this.onError?.(/* @__PURE__ */ Error(`Invalid response when getting feature flags: ${JSON.stringify(n)}`));this.flagsEtag=t.headers?.get(`ETag`)??void 0;let r={flags:n.flags??[],groupTypeMapping:n.group_type_mapping||{},cohorts:n.cohorts||{}};if(this.updateFlagState(r),this.shouldBeginExponentialBackoff=!1,this.backOffCount=0,this.cacheProvider&&e)try{await this.cacheProvider.onFlagDefinitionsReceived(r)}catch(e){this.onError?.(/* @__PURE__ */ Error(`Failed to store in cache: ${e}`))}this.onLoad?.(this.featureFlags.length);break}default:return}}catch(e){e instanceof Q$&&this.onError?.(e)}}getPersonalApiKeyRequestOptions(e=`GET`,t){let n={...this.customHeaders,"Content-Type":`application/json`,Authorization:`Bearer ${this.personalApiKey}`};return t&&(n[`If-None-Match`]=t),{method:e,headers:n}}_requestFeatureFlagDefinitions(){let e=`${this.host}/api/feature_flag/local_evaluation?token=${this.projectApiKey}&send_cohorts`,t=this.getPersonalApiKeyRequestOptions(`GET`,this.flagsEtag),n=null;if(this.timeout&&typeof this.timeout==`number`){let e=new AbortController;n=W$(()=>{e.abort()},this.timeout),t.signal=e.signal}try{let n=this.fetch;return n(e,t)}finally{clearTimeout(n)}}async stopPoller(e=3e4){if(clearTimeout(this.poller),this.cacheProvider)try{let t=this.cacheProvider.shutdown();t instanceof Promise&&await Promise.race([t,new Promise((t,n)=>setTimeout(()=>n(/* @__PURE__ */ Error(`Cache shutdown timeout after ${e}ms`)),e))])}catch(e){this.onError?.(/* @__PURE__ */ Error(`Error during cache shutdown: ${e}`))}}};async function XAt(e,t,n=``){let r=await qAt(`${e}.${t}${n}`);return parseInt(r.slice(0,15),16)/0x1000000000000000}function ZAt(e,t,n){let r=e.key,i=e.value,a=e.operator||`exact`;if(r in t){if(a===`is_not_set`)throw new $$(`Operator is_not_set is not supported`)}else throw new $$(`Property ${r} not found in propertyValues`);let o=t[r];if(o==null&&!JAt.includes(a))return n&&n(`Property ${r} cannot have a value of null/undefined with the ${a} operator`),!1;function s(e,t){return Array.isArray(e)?e.map(e=>String(e).toLowerCase()).includes(String(t).toLowerCase()):String(e).toLowerCase()===String(t).toLowerCase()}function c(e,t,n){if(n===`gt`)return e>t;if(n===`gte`)return e>=t;if(n===`lt`)return e<t;if(n===`lte`)return e<=t;throw Error(`Invalid operator: ${n}`)}switch(a){case`exact`:return s(i,o);case`is_not`:return!s(i,o);case`is_set`:return r in t;case`icontains`:return String(o).toLowerCase().includes(String(i).toLowerCase());case`not_icontains`:return!String(o).toLowerCase().includes(String(i).toLowerCase());case`regex`:return tjt(String(i))&&String(o).match(String(i))!==null;case`not_regex`:return tjt(String(i))&&String(o).match(String(i))===null;case`gt`:case`gte`:case`lt`:case`lte`:{let e=typeof i==`number`?i:null;if(typeof i==`string`)try{e=parseFloat(i)}catch{}return e==null||o==null?c(String(o),String(i),a):typeof o==`string`?c(o,String(i),a):c(o,e,a)}case`is_date_after`:case`is_date_before`:{if(typeof i==`boolean`)throw new $$(`Date operations cannot be performed on boolean values`);let e=rjt(String(i));if(e??=njt(i),e==null)throw new $$(`Invalid date: ${i}`);let t=njt(o);return[`is_date_before`].includes(a)?t<e:t>e}default:throw new $$(`Unknown operator: ${a}`)}}function QAt(e,t){if(!(e in t))throw new e1(`cohort ${e} not found in local cohorts - likely a static cohort that requires server evaluation`)}function $At(e,t,n,r=!1){let i=String(e.value);QAt(i,n);let a=n[i];return ejt(a,t,n,r)}function ejt(e,t,n,r=!1){if(!e)return!0;let i=e.type,a=e.values;if(!a||a.length===0)return!0;let o=!1;if(`values`in a[0]){for(let e of a)try{let a=ejt(e,t,n,r);if(i===`AND`){if(!a)return!1}else if(a)return!0}catch(t){if(t instanceof e1)throw t;if(t instanceof $$)r&&console.debug(`Failed to compute property ${e} locally: ${t}`),o=!0;else throw t}if(o)throw new $$(`Can't match cohort without a given cohort property value`);return i===`AND`}for(let e of a)try{let a;if(e.type===`cohort`)a=$At(e,t,n,r);else if(e.type===`flag`){r&&console.warn(`[FEATURE FLAGS] Flag dependency filters are not supported in local evaluation. Skipping condition with dependency on flag '${e.key||`unknown`}'`);continue}else a=ZAt(e,t);let o=e.negation||!1;if(i===`AND`){if(!a&&!o||a&&o)return!1}else if(a&&!o||!a&&o)return!0}catch(t){if(t instanceof e1)throw t;if(t instanceof $$)r&&console.debug(`Failed to compute property ${e} locally: ${t}`),o=!0;else throw t}if(o)throw new $$(`can't match cohort without a given cohort property value`);return i===`AND`}function tjt(e){try{return new RegExp(e),!0}catch{return!1}}function njt(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 $$(`${e} is in an invalid date format`)}throw new $$(`The date provided ${e} must be a string, number, or date object`)}function rjt(e){let t=e.match(/^-?(?<number>[0-9]+)(?<interval>[a-z])$/),n=new Date((/* @__PURE__ */ new Date()).toISOString());if(!t)return null;{if(!t.groups)return null;let e=parseInt(t.groups.number);if(e>=1e4)return null;let r=t.groups.interval;if(r==`h`)n.setUTCHours(n.getUTCHours()-e);else if(r==`d`)n.setUTCDate(n.getUTCDate()-e);else if(r==`w`)n.setUTCDate(n.getUTCDate()-7*e);else if(r==`m`)n.setUTCMonth(n.getUTCMonth()-e);else{if(r!=`y`)return null;n.setUTCFullYear(n.getUTCFullYear()-e)}return n}}var ijt=class{getProperty(e){return this._memoryStorage[e]}setProperty(e,t){this._memoryStorage[e]=t===null?void 0:t}constructor(){this._memoryStorage={}}};const ajt=3e4;var ojt=class extends sAt{constructor(e,t={}){if(super(e,t),this._memoryStorage=new ijt,this.options=t,this.context=this.initializeContext(),this.options.featureFlagsPollingInterval=typeof t.featureFlagsPollingInterval==`number`?Math.max(t.featureFlagsPollingInterval,100):ajt,t.personalApiKey){if(t.personalApiKey.includes(`phc_`))throw Error(`Your Personal API key is invalid. These keys are prefixed with "phx_" and can be created in PostHog project settings.`);!1!==t.enableLocalEvaluation&&(this.featureFlagsPoller=new YAt({pollingInterval:this.options.featureFlagsPollingInterval,personalApiKey:t.personalApiKey,projectApiKey:e,timeout:t.requestTimeout??1e4,host:this.host,fetch:t.fetch,onError:e=>{this._events.emit(`error`,e)},onLoad:e=>{this._events.emit(`localEvaluationFlagsLoaded`,e)},customHeaders:this.getCustomHeaders(),cacheProvider:t.flagDefinitionCacheProvider}))}this.errorTracking=new Z$(this,t,this._logger),this.distinctIdHasSentFlagCalls={},this.maxCacheSize=t.maxCacheSize||5e4}getPersistedProperty(e){return this._memoryStorage.getProperty(e)}setPersistedProperty(e,t){return this._memoryStorage.setProperty(e,t)}fetch(e,t){return this.options.fetch?this.options.fetch(e,t):fetch(e,t)}getLibraryVersion(){return`5.17.2`}getCustomUserAgent(){return`${this.getLibraryId()}/${this.getLibraryVersion()}`}enable(){return super.optIn()}disable(){return super.optOut()}debug(e=!0){super.debug(e),this.featureFlagsPoller?.debug(e)}capture(e){typeof e==`string`&&this._logger.warn(`Called capture() with a string as the first argument when an object was expected.`),this.addPendingPromise(this.prepareEventMessage(e).then(({distinctId:e,event:t,properties:n,options:r})=>super.captureStateless(e,t,n,{timestamp:r.timestamp,disableGeoip:r.disableGeoip,uuid:r.uuid})).catch(e=>{e&&console.error(e)}))}async captureImmediate(e){return typeof e==`string`&&this._logger.warn(`Called captureImmediate() with a string as the first argument when an object was expected.`),this.addPendingPromise(this.prepareEventMessage(e).then(({distinctId:e,event:t,properties:n,options:r})=>super.captureStatelessImmediate(e,t,n,{timestamp:r.timestamp,disableGeoip:r.disableGeoip,uuid:r.uuid})).catch(e=>{e&&console.error(e)}))}identify({distinctId:e,properties:t,disableGeoip:n}){let r=t?.$set_once;delete t?.$set_once;let i=t?.$set||t;super.identifyStateless(e,{$set:i,$set_once:r},{disableGeoip:n})}async identifyImmediate({distinctId:e,properties:t,disableGeoip:n}){let r=t?.$set_once;delete t?.$set_once;let i=t?.$set||t;await super.identifyStatelessImmediate(e,{$set:i,$set_once:r},{disableGeoip:n})}alias(e){super.aliasStateless(e.alias,e.distinctId,void 0,{disableGeoip:e.disableGeoip})}async aliasImmediate(e){await super.aliasStatelessImmediate(e.alias,e.distinctId,void 0,{disableGeoip:e.disableGeoip})}isLocalEvaluationReady(){return this.featureFlagsPoller?.isLocalEvaluationReady()??!1}async waitForLocalEvaluationReady(e=ajt){return this.isLocalEvaluationReady()?!0:this.featureFlagsPoller!==void 0&&new Promise(t=>{let n=setTimeout(()=>{r(),t(!1)},e),r=this._events.on(`localEvaluationFlagsLoaded`,e=>{clearTimeout(n),r(),t(e>0)})})}async getFeatureFlag(e,t,n){let{groups:r,disableGeoip:i}=n||{},{onlyEvaluateLocally:a,sendFeatureFlagEvents:o,personProperties:s,groupProperties:c}=n||{},l=this.addLocalPersonAndGroupProperties(t,r,s,c);s=l.allPersonProperties,c=l.allGroupProperties,a??=!1,o??=this.options.sendFeatureFlagEvent??!0;let u=await this.featureFlagsPoller?.getFeatureFlag(e,t,r,s,c),d=u!==void 0,f,p,m;if(!d&&!a){let n=await super.getFeatureFlagDetailStateless(e,t,r,s,c,i);if(n===void 0)return;m=n.response,u=L$(m),f=n?.requestId,p=n?.evaluatedAt}let h=`${e}_${u}`;return o&&(!(t in this.distinctIdHasSentFlagCalls)||!this.distinctIdHasSentFlagCalls[t].includes(h))&&(Object.keys(this.distinctIdHasSentFlagCalls).length>=this.maxCacheSize&&(this.distinctIdHasSentFlagCalls={}),Array.isArray(this.distinctIdHasSentFlagCalls[t])?this.distinctIdHasSentFlagCalls[t].push(h):this.distinctIdHasSentFlagCalls[t]=[h],this.capture({distinctId:t,event:`$feature_flag_called`,properties:{$feature_flag:e,$feature_flag_response:u,$feature_flag_id:m?.metadata?.id,$feature_flag_version:m?.metadata?.version,$feature_flag_reason:m?.reason?.description??m?.reason?.code,locally_evaluated:d,[`$feature/${e}`]:u,$feature_flag_request_id:f,$feature_flag_evaluated_at:p},groups:r,disableGeoip:i})),u}async getFeatureFlagPayload(e,t,n,r){let{groups:i,disableGeoip:a}=r||{},{onlyEvaluateLocally:o,personProperties:s,groupProperties:c}=r||{},l=this.addLocalPersonAndGroupProperties(t,i,s,c);s=l.allPersonProperties,c=l.allGroupProperties;let u;if(this.featureFlagsPoller!==void 0){await this.featureFlagsPoller?.loadFeatureFlags();let r=this.featureFlagsPoller?.featureFlagsByKey[e];if(r)try{let e=await this.featureFlagsPoller?.computeFlagAndPayloadLocally(r,t,i,s,c,n);e&&(n=e.value,u=e.payload)}catch(e){if(e instanceof e1||e instanceof $$)this._logger?.info(`${e.name} when computing flag locally: ${r.key}: ${e.message}`);else throw e}}return o??=!1,u===void 0&&!o&&(u=await super.getFeatureFlagPayloadStateless(e,t,i,s,c,a)),u}async getRemoteConfigPayload(e){if(!this.options.personalApiKey)throw Error(`Personal API key is required for remote config payload decryption`);let t=await this._requestRemoteConfigPayload(e);if(!t)return;let n=await t.json();if(typeof n==`string`)try{return JSON.parse(n)}catch{}return n}async isFeatureEnabled(e,t,n){let r=await this.getFeatureFlag(e,t,n);if(r!==void 0)return!!r||!1}async getAllFlags(e,t){return(await this.getAllFlagsAndPayloads(e,t)).featureFlags||{}}async getAllFlagsAndPayloads(e,t){let{groups:n,disableGeoip:r,flagKeys:i}=t||{},{onlyEvaluateLocally:a,personProperties:o,groupProperties:s}=t||{},c=this.addLocalPersonAndGroupProperties(e,n,o,s);o=c.allPersonProperties,s=c.allGroupProperties,a??=!1;let l=await this.featureFlagsPoller?.getAllFlagsAndPayloads(e,n,o,s,i),u={},d={},f=!0;if(l&&(u=l.response,d=l.payloads,f=l.fallbackToFlags),f&&!a){let t=await super.getFeatureFlagsAndPayloadsStateless(e,n,o,s,r,i);u={...u,...t.flags||{}},d={...d,...t.payloads||{}}}return{featureFlags:u,featureFlagPayloads:d}}groupIdentify({groupType:e,groupKey:t,properties:n,distinctId:r,disableGeoip:i}){super.groupIdentifyStateless(e,t,n,{disableGeoip:i},r)}async reloadFeatureFlags(){await this.featureFlagsPoller?.loadFeatureFlags(!0)}withContext(e,t,n){return this.context?this.context.run(e,t,n):t()}getContext(){return this.context?.get()}async _shutdown(e){return this.featureFlagsPoller?.stopPoller(e),this.errorTracking.shutdown(),super._shutdown(e)}async _requestRemoteConfigPayload(e){if(!this.options.personalApiKey)return;let t=`${this.host}/api/projects/@current/feature_flags/${e}/remote_config?token=${encodeURIComponent(this.apiKey)}`,n={method:`GET`,headers:{...this.getCustomHeaders(),"Content-Type":`application/json`,Authorization:`Bearer ${this.options.personalApiKey}`}},r=null;if(this.options.requestTimeout&&typeof this.options.requestTimeout==`number`){let e=new AbortController;r=W$(()=>{e.abort()},this.options.requestTimeout),n.signal=e.signal}try{return await this.fetch(t,n)}catch(e){this._events.emit(`error`,e);return}finally{r&&clearTimeout(r)}}extractPropertiesFromEvent(e,t){if(!e)return{personProperties:{},groupProperties:{}};let n={},r={};for(let[i,a]of Object.entries(e))if(Ukt(a)&&t&&i in t){let e={};for(let[t,n]of Object.entries(a))e[String(t)]=String(n);r[String(i)]=e}else n[String(i)]=String(a);return{personProperties:n,groupProperties:r}}async getFeatureFlagsForEvent(e,t,n,r){let i=r?.personProperties||{},a=r?.groupProperties||{},o=r?.flagKeys;if(r?.onlyEvaluateLocally??!1){if((this.featureFlagsPoller?.featureFlags?.length||0)>0){let r={};for(let[e,n]of Object.entries(t||{}))r[e]=String(n);return await this.getAllFlags(e,{groups:r,personProperties:i,groupProperties:a,disableGeoip:n,onlyEvaluateLocally:!0,flagKeys:o})}return{}}if((this.featureFlagsPoller?.featureFlags?.length||0)>0){let r={};for(let[e,n]of Object.entries(t||{}))r[e]=String(n);return await this.getAllFlags(e,{groups:r,personProperties:i,groupProperties:a,disableGeoip:n,onlyEvaluateLocally:!0,flagKeys:o})}return(await super.getFeatureFlagsStateless(e,t,i,a,n)).flags}addLocalPersonAndGroupProperties(e,t,n,r){let i={distinct_id:e,...n||{}},a={};if(t)for(let e of Object.keys(t))a[e]={$group_key:t[e],...r?.[e]||{}};return{allPersonProperties:i,allGroupProperties:a}}captureException(e,t,n){let r=/* @__PURE__ */ Error(`PostHog syntheticException`);this.addPendingPromise(Z$.buildEventMessage(e,{syntheticException:r},t,n).then(e=>this.capture(e)))}async captureExceptionImmediate(e,t,n){let r=/* @__PURE__ */ Error(`PostHog syntheticException`);this.addPendingPromise(Z$.buildEventMessage(e,{syntheticException:r},t,n).then(e=>this.captureImmediate(e)))}async prepareEventMessage(e){let{distinctId:t,event:n,properties:r,groups:i,sendFeatureFlags:a,timestamp:o,disableGeoip:s,uuid:c}=e,l=this.context?.get(),u=t||l?.distinctId,d={...l?.properties||{},...r||{}};u||(u=z$(),d.$process_person_profile=!1),l?.sessionId&&!d.$session_id&&(d.$session_id=l.sessionId);let f=this._runBeforeSend({distinctId:u,event:n,properties:d,groups:i,sendFeatureFlags:a,timestamp:o,disableGeoip:s,uuid:c});if(!f)return Promise.reject(null);let p=await Promise.resolve().then(async()=>{if(a){let e=typeof a==`object`?a:void 0;return await this.getFeatureFlagsForEvent(f.distinctId,i,s,e)}return f.event,{}}).then(e=>{let t={};if(e)for(let[n,r]of Object.entries(e))t[`$feature/${n}`]=r;let n=Object.keys(e||{}).filter(t=>e?.[t]!==!1).sort();return n.length>0&&(t.$active_feature_flags=n),t}).catch(()=>({})).then(e=>({...e,...f.properties||{},$groups:f.groups||i}));return f.event===`$pageview`&&this.options.__preview_capture_bot_pageviews&&typeof p.$raw_user_agent==`string`&&Akt(p.$raw_user_agent,this.options.custom_blocked_useragents||[])&&(f.event=`$bot_pageview`,p.$browser_type=`bot`),{distinctId:f.distinctId,event:f.event,properties:p,options:{timestamp:f.timestamp,disableGeoip:f.disableGeoip,uuid:f.uuid}}}_runBeforeSend(e){let t=this.options.before_send;if(!t)return e;let n=Array.isArray(t)?t:[t],r=e;for(let t of n){if(r=t(r),!r)return this._logger.info(`Event '${e.event}' was rejected in beforeSend function`),null;if(!r.properties||Object.keys(r.properties).length===0){let e=`Event '${r.event}' has no properties after beforeSend function, this is likely an error.`;this._logger.warn(e)}}return r}},sjt=class{constructor(){this.storage=new Er}get(){return this.storage.getStore()}run(e,t,n){if(n?.fresh===!0)return this.storage.run(e,t);{let n=this.get()||{},r={distinctId:e.distinctId??n.distinctId,sessionId:e.sessionId??n.sessionId,properties:{...n.properties||{},...e.properties||{}}};return this.storage.run(r,t)}}};const cjt=`posthog-node`;function ljt(e,{organization:t,projectId:n,prefix:r,severityAllowList:i=[`error`],sendExceptionsToPostHog:a=!0}={}){return o=>{if(!(i===`*`||i.includes(o.level)))return o;o.tags||={};let s=o.tags[ujt.POSTHOG_ID_TAG];if(s===void 0)return o;let c=e.options.host??`https://us.i.posthog.com`,l=new URL(`/project/${e.apiKey}/person/${s}`,c).toString();o.tags[`PostHog Person URL`]=l;let u=o.exception?.values||[],d=u.map(e=>({...e,stacktrace:e.stacktrace?{...e.stacktrace,type:`raw`,frames:(e.stacktrace.frames||[]).map(e=>({...e,platform:`node:javascript`}))}:void 0})),f={$exception_message:u[0]?.value||o.message,$exception_type:u[0]?.type,$exception_level:o.level,$exception_list:d,$sentry_event_id:o.event_id,$sentry_exception:o.exception,$sentry_exception_message:u[0]?.value||o.message,$sentry_exception_type:u[0]?.type,$sentry_tags:o.tags};return t&&n&&(f.$sentry_url=(r||`https://sentry.io/organizations/`)+t+`/issues/?project=`+n+`&query=`+o.event_id),a&&e.capture({event:`$exception`,distinctId:s,properties:f}),o}}var ujt=class{static#e=this.POSTHOG_ID_TAG=`posthog_distinct_id`;constructor(e,t,n,r,i){this.name=cjt,this.name=cjt,this.setupOnce=function(a,o){let s=o()?.getClient()?.getDsn()?.projectId;a(ljt(e,{organization:t,projectId:s,prefix:n,severityAllowList:r,sendExceptionsToPostHog:i??!0}))}}};Z$.errorPropertiesBuilder=new uAt([new EAt,new bAt,new TAt,new SAt,new DAt],yAt(`node:javascript`,pAt),[gkt(),AAt]);var djt=class extends ojt{getLibraryId(){return`posthog-node`}initializeContext(){return new sjt}},fjt=function(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})};const pjt=1e4;let t1=null,n1=Promise.resolve();function mjt(){return t1||=new djt(`phc_eNuN6Ojnk9O7uWfC17z12AK85fNR0BY6IiGVy0Gfwzw`,{host:`https://ph.mintlify.com`}),t1}function r1(e){n1=Promise.allSettled([n1,e]).then(()=>void 0)}function i1(){return fjt(this,void 0,void 0,function*(){try{yield Promise.race([n1,new Promise(e=>{setTimeout(e,pjt).unref()})])}catch{}if(t1){try{yield Promise.race([t1.shutdown(),new Promise(e=>{setTimeout(e,pjt).unref()})])}catch{}t1=null}})}var a1=function(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})};const o1=process.cwd(),hjt=e=>a1(void 0,void 0,void 0,function*(){let t=typeof e.port==`number`?e.port:3e3;if(t===(yield(0,ekt.default)(t)))return t;for(let e=t+1;e<t+10;e++)if(jH((0,z.jsx)(yH,{message:`port ${e-1} is already in use. trying ${e} instead`})),e===(yield(0,ekt.default)(e)))return e}),gjt=()=>a1(void 0,void 0,void 0,function*(){let e=process.version;e.charAt(0)===`v`&&(e=e.slice(1));let t=e.split(`.`),n=parseInt(t[0],10),r=parseInt(t[1],10);n===25&&(jH((0,z.jsx)(CH,{message:`mintlify is not supported on node 25 (current version ${e}). Please switch to an LTS node version.`})),yield f1(1)),(n<20||n===20&&r<17)&&(jH((0,z.jsx)(CH,{message:`mintlify requires node 20.17 or higher. Please upgrade to an LTS node version.`})),yield f1(1))}),_jt=()=>a1(void 0,void 0,void 0,function*(){return!!(yield vF(o1,`mint`))}),vjt=e=>a1(void 0,void 0,void 0,function*(){let t=gt.resolve(e),{root:n}=gt.parse(t),r=t;for(;r!==n;){if((yield vF(r,`docs`))||(yield vF(r,`mint`)))return r;r=gt.dirname(r)}return t}),yjt=()=>a1(void 0,void 0,void 0,function*(){let e=gt.join(o1,`docs.json`);if(!(yield k$.default.pathExists(e))){jH((0,z.jsx)(yH,{message:`new docs.json file is available`}));let{action:e}=yield pkt.prompt([{type:`list`,name:`action`,message:`would you like to upgrade your mint.json to docs.json?`,choices:[{name:`upgrade (migrate from mint.json to docs.json)`,value:`upgrade`},{name:`continue (use existing mint.json)`,value:`continue`}]}]);e===`continue`&&jH((0,z.jsx)(yH,{message:`proceeding with the existing mint.json...`})),e===`upgrade`&&(jH((0,z.jsx)(xH,{message:`upgrading docs.json...`})),yield xjt())}}),bjt=()=>a1(void 0,void 0,void 0,function*(){if(!(yield _jt()))return;let e=gt.join(o1,`docs.json`);(yield k$.default.pathExists(e))||(jH((0,z.jsx)(SH,{message:`Legacy mint.json detected, auto-upgrading to docs.json`})),jH((0,z.jsx)(xH,{message:`upgrading mint.json to docs.json...`})),yield xjt())}),xjt=()=>a1(void 0,void 0,void 0,function*(){try{let e=gt.join(o1,`mint.json`),t=gt.join(o1,`docs.json`),n=yield Hn.readFile(e,`utf8`),r=(yield EF.validateConfigJsonString(n)).data,i=ff(r,{shouldUpgradeTheme:!0});yield Hn.writeFile(t,JSON.stringify(i,null,2)),IH(),jH((0,z.jsx)(bH,{message:`mint.json file has been upgraded to docs.json.`}))}catch(e){IH(),jH((0,z.jsx)(CH,{message:e instanceof Error?e.message:`an unknown error occurred`}))}}),Sjt=pt(import.meta.url),Cjt=()=>{try{return!Gt(import.meta.url).split(gt.sep).includes(`node_modules`)}catch{return!1}},wjt=e=>{try{let t=Sjt.resolve(`${e}/package.json`),n=JSON.parse(kn(t,`utf8`));return typeof n.version==`string`?n.version:void 0}catch{return}},s1=e=>(e===void 0&&(e=process.env.MINTLIFY_PACKAGE_NAME??`mint`),process.env.CLI_TEST_MODE===`true`?`test-cli`:Cjt()?ai:wjt(e)),c1=e=>(e===void 0&&(e=process.env.MINTLIFY_PACKAGE_NAME??`mint`),{cli:s1(e),client:Hut().trim()}),l1={shell:process.platform===`win32`},Tjt=/^(@[a-z0-9~-][a-z0-9._~-]*\/)?[a-z0-9~-][a-z0-9._~-]*$/,u1=e=>{if(!Tjt.test(e))throw Error(`Invalid package name: ${e}`)},Ejt=e=>(u1(e),Mr(`npm`,[`view`,e,`version`,`--silent`],Object.assign({encoding:`utf-8`,stdio:[`pipe`,`pipe`,`pipe`]},l1)).trim()),Djt=()=>{let e=[`No utility classes were detected`,`https://tailwindcss.com/docs/content-configuration`,`DeprecationWarning`],t=console.error;console.error=(...n)=>{let r=n.join(` `);e.some(e=>r.includes(e))||t.apply(console,n)};let n=console.warn;console.warn=(...t)=>{let r=t.join(` `);e.some(e=>r.includes(e))||n.apply(console,t)}},Ojt=e=>a1(void 0,void 0,void 0,function*(){let{resolvedPath:t}=_f(e,o1),n=yield Hn.readFile(t,`utf-8`);return Re.load(n)}),d1=e=>e instanceof Error?e.message:String(e),f1=e=>a1(void 0,void 0,void 0,function*(){yield new Promise(e=>setTimeout(e,50)),yield i1(),process.exit(e)}),p1=pr(jr);function m1(){return!process.stdin.isTTY||I$()!==void 0}const kjt=e=>a1(void 0,[e],void 0,function*({packageName:e}){u1(e);try{let{stdout:t}=yield p1(`which`,[e]);return t.includes(`pnpm`)?`pnpm`:`npm`}catch{return`npm`}});var Ajt=function(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})};const jjt=()=>Ajt(void 0,void 0,void 0,function*(){try{yield yjt();let e=yield vF(o1,`docs`),t=yield vF(o1,`mint`);if(!e&&!t)return jH((0,z.jsx)(CH,{message:`No configuration file found. Please run this command from a directory with a mint.json or docs.json file.`})),1;let n=yield bF(o1,e?`docs`:`mint`);if(!n?.colors)return jH((0,z.jsx)(SH,{message:`No colors section found in configuration file`})),0;let{colors:r,navigation:i}=n,{lightHex:a,darkHex:o}=Nce(n),s=sSt(r,{lightHex:a,darkHex:o},i),c=(e,t,n=``)=>{if(!e)return;let{recommendation:r,message:i}=e,a=r===`pass`?`PASS`:r===`warning`?`WARN`:`FAIL`,o=r===`pass`?`green`:r===`warning`?`yellow`:`red`;jH((0,z.jsxs)(gH,{children:[(0,z.jsxs)(gH,{bold:n===``,children:[n,t,`:`,` `]}),(0,z.jsxs)(gH,{color:o,children:[a,` `,i]})]}))};jH((0,z.jsx)(gH,{bold:!0,color:`cyan`,children:`Checking color accessibility...`})),jH((0,z.jsx)(gH,{})),c(s.primaryContrast,`Primary Color (${r.primary}) vs Light Background`),c(s.lightContrast,`Light Color (${r.light}) vs Dark Background`),c(s.darkContrast,`Dark Color (${r.dark}) vs Dark Background`),c(s.darkOnLightContrast,`Dark Color (${r.dark}) vs Light Background`);let l=s.anchorResults.filter(e=>e.lightContrast||e.darkContrast);if(l.length>0){jH((0,z.jsx)(gH,{})),jH((0,z.jsx)(gH,{bold:!0,color:`cyan`,children:`Navigation Anchors:`}));for(let e of l)jH((0,z.jsxs)(gH,{bold:!0,children:[` `,e.name,`:`]})),c(e.lightContrast,`Light variant vs Light Background`,` `),c(e.darkContrast,`Dark variant vs Dark Background`,` `)}jH((0,z.jsx)(gH,{}));let u=s.overallScore===`pass`?`PASS`:s.overallScore===`warning`?`WARN`:`FAIL`,d=s.overallScore===`pass`?`green`:s.overallScore===`warning`?`yellow`:`red`,f=s.overallScore===`pass`?`All colors meet accessibility standards!`:s.overallScore===`warning`?`Some colors could be improved for better accessibility`:`Some colors fail accessibility standards and should be updated`;return jH((0,z.jsx)(gH,{children:(0,z.jsxs)(gH,{bold:!0,color:d,children:[`Overall Assessment: `,u,` `,f]})})),+(s.overallScore===`fail`)}catch(e){return jH((0,z.jsx)(CH,{message:`Accessibility check failed: ${e instanceof Error?e.message:`Unknown error`}`})),1}});var h1=function(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})};const g1=`mintlify`,_1=`access_token`,v1=`refresh_token`,y1=`user_email`;function b1(){return h1(this,void 0,void 0,function*(){try{let e=yield import(`keytar`);return e.default??e}catch{throw Error(`keytar is required for credential storage but is not installed. Install it with: npm install keytar`)}})}function x1(e,t,n){return h1(this,void 0,void 0,function*(){let r=yield b1();yield Promise.all([r.setPassword(g1,_1,e),r.setPassword(g1,v1,t)]);try{n===null?yield r.deletePassword(g1,y1):n!==void 0&&(yield r.setPassword(g1,y1,n))}catch{}})}function S1(){return h1(this,void 0,void 0,function*(){return(yield b1()).getPassword(g1,_1)})}function Mjt(){return h1(this,void 0,void 0,function*(){return(yield b1()).getPassword(g1,v1)})}function Njt(){return h1(this,void 0,void 0,function*(){return(yield b1()).getPassword(g1,y1)})}function Pjt(e){return h1(this,void 0,void 0,function*(){yield(yield b1()).setPassword(g1,y1,e)})}function Fjt(){return h1(this,void 0,void 0,function*(){let e=yield b1();yield Promise.all([e.deletePassword(g1,_1),e.deletePassword(g1,v1),e.deletePassword(g1,y1).catch(()=>!1)])})}const Ijt=mt.homedir(),C1=gt.join(Ijt,`.config`,`mintlify`),Ljt=gt.join(C1,`config.json`),Rjt=process.env.CLI_TEST_MODE===`true`||s1()==ai,w1=process.env.MINTLIFY_API_URL??(Rjt?`http://localhost:5000`:`https://leaves.mintlify.com`),T1=process.env.MINTLIFY_DASHBOARD_URL??(Rjt?`http://localhost:3000`:`https://app.mintlify.com`),E1=`${w1}/api/oauth-token/cli`;function D1(e){if(e)try{let t=e.split(`.`)[1];if(!t)return;let n=JSON.parse(Buffer.from(t,`base64url`).toString(`utf8`));return typeof n.email==`string`&&n.email.length>0?n.email:void 0}catch{return}}var zjt=function(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})};let O1=null;function Bjt(){return zjt(this,void 0,void 0,function*(){return O1||(O1=Vjt().finally(()=>{O1=null}),O1)})}function Vjt(){return zjt(this,void 0,void 0,function*(){try{let e=yield Mjt();if(!e)return null;let t=yield fetch(E1,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({grant_type:`refresh_token`,refresh_token:e})});if(!t.ok)return null;let n=yield t.json().catch(()=>null);return!n?.access_token||!n.refresh_token?null:(yield x1(n.access_token,n.refresh_token,D1(n.id_token)),n.access_token)}catch{return null}})}var Hjt=function(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})};function Ujt(){return Hjt(this,void 0,void 0,function*(){try{return yield S1()}catch{return null}})}function k1(e,t){return Hjt(this,void 0,void 0,function*(){let n=yield Ujt(),r=process.env.MINTLIFY_SESSION_TOKEN,i=n??r;if(!i)throw Error("Not authenticated. Run `mint login` to authenticate.");let a=n=>fetch(e,Object.assign(Object.assign({},t),{headers:Object.assign(Object.assign({},t?.headers),{Authorization:`Bearer ${n}`})})),o=yield a(i);if(o.status!==401)return o;if(n){let e=yield Bjt();if(e)return a(e)}return r&&i!==r?a(r):o})}var A1=function(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})};const Wjt=Ne({registrationId:He(),subdomain:He()});function Gjt(e){let t=Wjt.safeParse(j1().agentSites?.[e]);return t.success?t.data:void 0}function Kjt(e,t){return A1(this,void 0,void 0,function*(){yield M1({agentSites:Object.assign(Object.assign({},j1().agentSites),{[e]:t})})})}function j1(){try{let e=qt.readFileSync(Ljt,`utf-8`);return JSON.parse(e)}catch{return{}}}function M1(e){return A1(this,void 0,void 0,function*(){yield(0,k$.ensureDir)(C1);let t=j1();qt.writeFileSync(Ljt,JSON.stringify(Object.assign(Object.assign({},t),e),null,2))})}function N1(){return process.env.CLI_TEST_MODE===`true`||process.env.MINTLIFY_TELEMETRY_DISABLED===`1`||process.env.DO_NOT_TRACK===`1`?!1:j1().telemetryEnabled!==!1}function qjt(e){return A1(this,void 0,void 0,function*(){yield M1({telemetryEnabled:e})})}function P1(e){return j1()[e]}function F1(e,t){return A1(this,void 0,void 0,function*(){yield M1({[e]:t})})}function Jjt(e){return A1(this,void 0,void 0,function*(){yield M1({[e]:void 0})})}function Yjt(e){return j1().publishPromptShown?.includes(e)??!1}function Xjt(e){return A1(this,void 0,void 0,function*(){yield M1({publishPromptShown:[...j1().publishPromptShown??[],e]})})}var I1=function(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})};const L1=Ne({user:Ne({email:He()}),org:Ne({name:He()}),subdomains:Ke(He()).default([])});function Zjt(e){return I1(this,void 0,void 0,function*(){try{let t=yield fetch(`${w1}/api/cli/status`,{headers:{Authorization:`Bearer ${e}`}});if(!t.ok)return null;let n=yield t.json().catch(()=>null),r=L1.safeParse(n);return r.success?r.data:null}catch{return null}})}function Qjt(e){return I1(this,void 0,void 0,function*(){let t;try{t=yield k1(`${w1}/api/cli/status`,{signal:e})}catch(e){let t=e instanceof Error?e.message:String(e);return/not authenticated/i.test(t)?{ok:!1,reason:`unauthenticated`}:{ok:!1,reason:`unreachable`,detail:t}}if(t.status===401||t.status===403)return{ok:!1,reason:`unauthenticated`};if(!t.ok)return{ok:!1,reason:`unreachable`,detail:`HTTP ${t.status}`};let n=L1.safeParse(yield t.json().catch(()=>null));return n.success?{ok:!0,status:n.data}:{ok:!1,reason:`invalid`}})}function R1(e){return I1(this,void 0,void 0,function*(){return(yield Zjt(e))?.subdomains??[]})}function $jt(){return I1(this,void 0,void 0,function*(){if(!((yield S1().catch(()=>null))??process.env.MINTLIFY_SESSION_TOKEN))jH((0,z.jsx)(CH,{message:"not logged in. Run `mint login` to authenticate."}));else try{let e=yield k1(`${w1}/api/cli/status`);if(!e.ok){jH((0,z.jsx)(CH,{message:"not logged in. Run `mint login` to authenticate."}));return}let t=yield e.json().catch(()=>null),n=L1.safeParse(t);if(!n.success){jH((0,z.jsx)(CH,{message:`unexpected response from server. please try again.`}));return}let{user:r,org:i,subdomains:a}=n.data,o=s1(),s=P1(`subdomain`),c=(s&&a.includes(s)?s:a[0])??null;c&&c!==s&&(yield F1(`subdomain`,c).catch(()=>void 0)),jH((0,z.jsxs)(hH,{flexDirection:`column`,paddingY:1,children:[o&&(0,z.jsxs)(hH,{children:[(0,z.jsx)(hH,{minWidth:16,children:(0,z.jsx)(gH,{dimColor:!0,children:`Version`})}),(0,z.jsx)(gH,{children:o})]}),(0,z.jsxs)(hH,{children:[(0,z.jsx)(hH,{minWidth:16,children:(0,z.jsx)(gH,{dimColor:!0,children:`Email`})}),(0,z.jsx)(gH,{children:r.email})]}),(0,z.jsxs)(hH,{children:[(0,z.jsx)(hH,{minWidth:16,children:(0,z.jsx)(gH,{dimColor:!0,children:`Organization`})}),(0,z.jsx)(gH,{children:i.name})]}),c&&(0,z.jsxs)(hH,{children:[(0,z.jsx)(hH,{minWidth:16,children:(0,z.jsx)(gH,{dimColor:!0,children:`Subdomain`})}),(0,z.jsx)(gH,{children:c})]})]}))}catch{jH((0,z.jsx)(CH,{message:`unexpected response from server. please try again.`}))}})}var eMt=function(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})};const tMt=5e3,nMt=/^[a-z0-9]([a-z0-9-]*[a-z0-9])?(\.[a-z0-9]([a-z0-9-]*[a-z0-9])?)+$/i;function rMt(e,t){return eMt(this,void 0,void 0,function*(){if(!nMt.test(e)){jH((0,z.jsx)(CH,{message:`invalid domain "${e}". Expected a bare hostname, e.g. docs.example.com`}));return}let n=xJe(t?.trim());if(n){let e=TJe(n);if(e){jH((0,z.jsx)(CH,{message:`invalid base path "${t}": ${e}`}));return}}let r=yield S1();if(!r){jH((0,z.jsx)(CH,{message:"not logged in. Run `mint login` to authenticate."}));return}let i=yield R1(r),a=P1(`subdomain`),o=a&&i.includes(a)?a:i[0];if(!o){jH((0,z.jsx)(CH,{message:"no subdomain found. Run `mint status` to check your account."}));return}try{let t=yield k1(`${w1}/api/cli/deployment/custom-domain/${o}/${e}`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({basePath:n?`/docs`:``})});if(!t.ok){let e=yield t.json().catch(()=>({}));jH((0,z.jsx)(CH,{message:`could not add domain: ${e.error??`unknown error`}`}));return}}catch{jH((0,z.jsx)(CH,{message:`could not reach the server`}));return}let s=!1,c=!1;if(n){jH((0,z.jsx)(xH,{message:`setting base path to ${n}...`}));try{let e=yield k1(`${w1}/api/cli/deployment/base-path/${o}`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({basePath:n})});if(IH(),e.ok){let t=yield e.json().catch(()=>({}));s=!0,c=!!t.pendingBasePathUpdate}else{let t=yield e.json().catch(()=>({})),n=t.issues?.[0]?.message??t.error??`unknown error`;jH((0,z.jsx)(CH,{message:`domain added, but base path was not saved: ${n}`}))}}catch{IH(),jH((0,z.jsx)(CH,{message:`domain added, but base path was not saved: could not reach the server`}))}}jH((0,z.jsx)(xH,{message:`waiting for DNS records to generate (up to ${2*tMt/1e3}s)...`}));let l=[],u=!1;try{for(let t=0;t<3;t++){let n=yield k1(`${w1}/api/cli/deployment/custom-domain/${o}/${e}`);if(n.ok){l=(yield n.json()).cloudflare?.dnsRecords??[];let e=l.some(e=>e.value===`loading`);if(l.length>0&&!e){u=!0;break}}t<2&&(yield new Promise(e=>setTimeout(e,tMt)))}}catch{IH(),jH((0,z.jsx)(CH,{message:`domain added, but could not fetch DNS records`}));return}IH();let d=l.filter(e=>e.type===`TXT`&&e.value!==`loading`),f=c?`domain ${e} added; base path ${n} queued for the next deploy`:s?`domain ${e} added (serving at ${n})`:`domain ${e} added`;jH((0,z.jsx)(bH,{message:f})),jH((0,z.jsxs)(hH,{flexDirection:`column`,gap:1,paddingY:1,children:[(0,z.jsx)(gH,{bold:!0,children:`Add these DNS records with your domain provider:`}),(0,z.jsxs)(hH,{flexDirection:`column`,paddingLeft:3,children:[d.map(t=>(0,z.jsxs)(gH,{children:[`TXT `,bJe(t.domain,e),` → `,t.value]},t.domain)),(0,z.jsxs)(gH,{children:[`CNAME `,bJe(e,e),` → `,`cname.mintlify.builders`]})]}),(0,z.jsx)(gH,{dimColor:!0,children:`Add the TXT records first; add the CNAME once they're validated.`}),c&&(0,z.jsx)(gH,{dimColor:!0,children:`The base path takes effect when that deploy finishes; the current path stays up until then.`}),s&&(0,z.jsxs)(gH,{dimColor:!0,children:[`The CNAME sends all paths on `,e,` to Mintlify. Only add it if this domain hosts nothing else. Otherwise, set up a reverse proxy for `,n,`: https://www.mintlify.com/docs/deploy/docs-subpath`]}),!u&&(0,z.jsx)(gH,{dimColor:!0,children:`Some TXT records are still being generated. Check the dashboard in a moment for the rest.`})]}))})}var iMt=function(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})};const aMt=Ne({code:He().optional(),error:He().optional()});var z1=class extends Error{constructor(e,t){super(`Agent request failed (HTTP ${e}).${t?` Code: ${t}.`:``}`),this.status=e,this.code=t}};function B1(e,t){return iMt(this,void 0,void 0,function*(){try{let n=AbortSignal.timeout(3e4),r=t?.signal?AbortSignal.any([t.signal,n]):n;return yield fetch(e,Object.assign(Object.assign({},t),{redirect:`error`,signal:r}))}catch{throw Error(`Could not reach the agent service. Retry the same command.`)}})}function V1(e,t){return iMt(this,void 0,void 0,function*(){let n=yield e.json().catch(()=>null);if(!e.ok){let t=aMt.safeParse(n),r=t.success?t.data.code??t.data.error:void 0;throw new z1(e.status,r?.match(/^[a-z_]{1,80}$/)?.[0])}let r=t.safeParse(n);if(!r.success)throw Error(`The agent service returned an unexpected response.`);return r.data})}var H1=function(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})};const oMt=Ne({authorization_servers:Ke(I()).min(1)}),sMt=Ne({issuer:I(),token_endpoint:I(),agent_auth:Ne({identity_endpoint:I(),claim_endpoint:I(),identity_types_supported:Ke(He())})}),cMt=Ne({assertion:He().min(1)}),lMt=Ne({id:He().min(1),identity:cMt,claim:Ne({token:He().min(1)})}),uMt=Ne({access_token:He().min(1),expires_in:Ae().positive(),token_type:He().regex(/^bearer$/i)}),dMt=ke(`identityType`,[Ne({registrationId:He(),identityType:nt(`anonymous`)}),Ne({registrationId:He(),identityType:nt(`user_bound`),userId:He(),orgId:He()})]);function U1(e){return H1(this,void 0,void 0,function*(){let t=(yield V1(yield B1(`${e}/api/agent/.well-known/oauth-protected-resource`),oMt)).authorization_servers[0];if(!t||new URL(t).protocol!==`https:`)throw Error(`Agent authentication requires an HTTPS issuer.`);let n=yield V1(yield B1(`${t.replace(/\/$/,``)}/.well-known/oauth-authorization-server`),sMt),r=new URL(t).origin;if([n.issuer,n.token_endpoint,n.agent_auth.identity_endpoint,n.agent_auth.claim_endpoint].some(e=>new URL(e).origin!==r))throw Error(`Agent authentication endpoints do not match the configured issuer.`);return n})}function fMt(e){return H1(this,void 0,void 0,function*(){if(!e.agent_auth.identity_types_supported.includes(`anonymous`))throw Error(`Anonymous registration is not enabled for this environment.`);let t=yield V1(yield B1(e.agent_auth.identity_endpoint,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({type:`anonymous`})}),lMt);return{registrationId:t.id,issuer:e.issuer,assertion:t.identity.assertion,claimToken:t.claim.token}})}function pMt(e,t){return H1(this,void 0,void 0,function*(){if(new URL(t.issuer).origin!==new URL(e.issuer).origin)throw Error(`Saved agent credentials belong to another issuer.`);if(t.accessToken&&(t.accessTokenExpiresAt??0)>Date.now()+3e4)return Object.assign(Object.assign({},t),{accessToken:t.accessToken});let n=yield V1(yield B1(e.token_endpoint,{method:`POST`,body:new URLSearchParams({grant_type:`urn:ietf:params:oauth:grant-type:jwt-bearer`,assertion:t.assertion})}),uMt);return Object.assign(Object.assign({},t),{accessToken:n.access_token,accessTokenExpiresAt:Date.now()+n.expires_in*1e3})})}function mMt(e,t){return H1(this,void 0,void 0,function*(){return V1(yield B1(`${e}/api/agent/identity`,{headers:{Authorization:`Bearer ${t}`}}),dMt)})}var W1=function(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})},hMt=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols==`function`)for(var i=0,r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]]);return n};const G1=`mintlify-agent`,K1=()=>It.join(C1,`agent-credentials.json`),gMt=Ne({registrationId:He().min(1),issuer:I(),assertion:He().min(1),claimToken:He().min(1),claimVerified:Qe().optional(),accessToken:He().min(1).optional(),accessTokenExpiresAt:Ae().optional()});function _Mt(e,t){return`project:${Mn(`sha256`).update(JSON.stringify([new URL(e).origin,It.resolve(t)])).digest(`hex`)}`}function vMt(e,t){return`${new URL(e).origin}:${t}`}function q1(){return W1(this,void 0,void 0,function*(){try{return Je(He(),He()).parse(JSON.parse(yield Hn.readFile(K1(),`utf-8`)))}catch{return{}}})}function yMt(e){return W1(this,void 0,void 0,function*(){yield Hn.mkdir(C1,{recursive:!0});let t=`${K1()}.${process.pid}.tmp`;yield Hn.writeFile(t,JSON.stringify(e,null,2),{mode:384}),yield Hn.chmod(t,384),yield Hn.rename(t,K1())})}function bMt(e){return W1(this,void 0,void 0,function*(){let t;try{let t=yield(yield b1()).getPassword(G1,e);if(t)return t}catch(e){t=e}let n=(yield q1())[e];if(n)return n;if(t)throw t;return null})}function xMt(e,t){return W1(this,void 0,void 0,function*(){try{yield(yield b1()).setPassword(G1,e,t)}catch{yield yMt(Object.assign(Object.assign({},yield q1()),{[e]:t})),yield b1().then(t=>t.deletePassword(G1,e)).catch(()=>{});return}let n=yield q1(),r=e,i=n[r],a=hMt(n,[typeof r==`symbol`?r:r+``]);i&&(yield yMt(a).catch(()=>{}))})}function SMt(e,t){return W1(this,void 0,void 0,function*(){let n=yield bMt(_Mt(e,t));if(!n)return null;let r=yield bMt(vMt(e,n));if(!r)throw Error(`Saved agent credentials are missing. Use --new to create another site.`);let i=gMt.parse(JSON.parse(r));if(i.registrationId!==n)throw Error(`Saved agent credentials do not match this project.`);return i})}function CMt(e,t,n){return W1(this,void 0,void 0,function*(){let r=gMt.parse(n);yield xMt(vMt(e,r.registrationId),JSON.stringify(r)),yield xMt(_Mt(e,t),r.registrationId)})}const J1=gt.join(C1,`anonymous-id`),wMt=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;function Y1(){try{let e=qt.readFileSync(J1,`utf-8`).trim();if(wMt.test(e))return e}catch{}return null}function TMt(){let e=jt.createHash(`sha256`);e.update(mt.hostname()),e.update(`\0`),e.update(mt.homedir()),e.update(`\0`),e.update(process.env.USER??process.env.USERNAME??``);let t=e.digest(`hex`).slice(0,32);return`${t.slice(0,8)}-${t.slice(8,12)}-${t.slice(12,16)}-${t.slice(16,20)}-${t.slice(20,32)}`}function EMt(e){qt.mkdirSync(gt.dirname(J1),{recursive:!0}),qt.writeFileSync(J1,e,{flag:`wx`})}let DMt=!1;function OMt(){return kMt(),DMt}function kMt(){let e=Y1();if(e)return e;let t=jt.randomUUID();try{return EMt(t),DMt=!0,Y1()??t}catch(e){if(e.code===`EEXIST`){let e=Y1();if(e)return e;try{qt.writeFileSync(J1,t)}catch{}return Y1()??t}}let n=TMt();try{qt.mkdirSync(gt.dirname(J1),{recursive:!0}),qt.writeFileSync(J1,n)}catch{}return Y1()??n}const AMt=gt.join(C1,`telemetry-session.json`);let X1;function jMt(e){let t=jt.randomBytes(16);t.writeUIntBE(e,0,6),t[6]=t[6]&15|112,t[8]=t[8]&63|128;let n=t.toString(`hex`);return`${n.slice(0,8)}-${n.slice(8,12)}-${n.slice(12,16)}-${n.slice(16,20)}-${n.slice(20)}`}function MMt(){try{let{id:e,lastSeenAt:t}=JSON.parse(qt.readFileSync(AMt,`utf-8`));return typeof e==`string`&&typeof t==`number`?{id:e,lastSeenAt:t}:null}catch{return null}}function NMt(e=Date.now()){if(!X1){let t=MMt();X1=t&&e-t.lastSeenAt<18e5?t.id:jMt(e)}try{qt.mkdirSync(C1,{recursive:!0}),qt.writeFileSync(AMt,JSON.stringify({id:X1,lastSeenAt:e}))}catch{}return X1}var Z1=function(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})};function Q1(){let e=I$();return{os:mt.platform(),arch:mt.arch(),node_version:process.version,is_ai_agent:e!==void 0,ai_agent:e,is_ci:hkt(),is_tty:!!process.stdin.isTTY,is_first_run:OMt(),$session_id:NMt()}}function $1(e,t){return Z1(this,void 0,void 0,function*(){yield Promise.race([mjt().captureImmediate({distinctId:kMt(),event:e,properties:t}).catch(()=>{}),new Promise(e=>{setTimeout(e,1e4).unref()})])})}function PMt(){return Z1(this,void 0,void 0,function*(){try{let[e,t]=yield Promise.all([S1(),Njt().catch(()=>null)]);if(!e)return{loggedIn:!1,email:null};if(t)return{loggedIn:!0,email:t};let n=yield Qjt(AbortSignal.timeout(3e3));if(!n.ok)return{loggedIn:!0,email:null};let r=n.status.user.email;return yield Pjt(r).catch(()=>{}),{loggedIn:!0,email:r}}catch{return{loggedIn:!1,email:null}}})}function e0(){return Z1(this,void 0,void 0,function*(){let{loggedIn:e,email:t}=yield PMt();return Object.assign({is_logged_in:e},t?{email:t,$set:{email:t}}:{})})}function FMt(e){return Z1(this,arguments,void 0,function*({command:e,cliVersion:t,subdomain:n}){if(!N1())return;let r=Z1(this,void 0,void 0,function*(){try{yield $1(`cli.command.executed`,Object.assign(Object.assign(Object.assign({command:e,cli_version:t},Q1()),yield e0()),{subdomain:n}))}catch{}});r1(r),yield r})}function t0(e,t){return Z1(this,void 0,void 0,function*(){if(!N1())return;let n=Z1(this,void 0,void 0,function*(){try{let{cli:n}=c1();yield $1(e,Object.assign(Object.assign(Object.assign(Object.assign({},t),{cli_version:n}),Q1()),yield e0()))}catch{}});r1(n),yield n})}function IMt(){return Z1(this,void 0,void 0,function*(){return t0(`cli.login.attempted`)})}function LMt(){return Z1(this,void 0,void 0,function*(){return t0(`cli.login.succeeded`)})}function RMt(e){return Z1(this,void 0,void 0,function*(){return t0(`cli.login.failed`,{reason:e})})}function n0(e,t){return Z1(this,void 0,void 0,function*(){if(!N1())return;let n=Z1(this,void 0,void 0,function*(){try{let{cli:n}=c1();yield $1(e,Object.assign(Object.assign(Object.assign(Object.assign({},t),{cli_version:n}),Q1()),yield e0()))}catch{}});r1(n),yield n})}function zMt(e){return Z1(this,void 0,void 0,function*(){if(process.env.CLI_TEST_MODE!==`true`)try{let{cli:t}=c1();yield $1(`cli.telemetry.preference_changed`,Object.assign({enabled:e.enabled,cli_version:t},Q1()))}catch{}})}var BMt=function(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})};const VMt=Ne({attempt:Ne({verification_uri:I()})});function HMt(e,t,n){return BMt(this,void 0,void 0,function*(){let r=Ve().parse(n),i=yield U1(e);if(new URL(i.issuer).origin!==new URL(t.issuer).origin)throw Error(`Saved agent credentials belong to another issuer.`);let a=yield V1(yield B1(i.agent_auth.claim_endpoint,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({type:`service_auth`,claim_token:t.claimToken,login_hint:r})}),VMt).catch(e=>{throw e instanceof z1&&e.code===`too_many_attempts`?Error(`Too many claim links are still pending. Send the user the last claim link, or wait 5 minutes and retry.`):e}),o=He().min(1).parse(new URL(a.attempt.verification_uri).searchParams.get(`token`)),s=new URL(`/agent-claim`,T1);return s.searchParams.set(`token`,o),s.searchParams.set(`registration`,t.registrationId),n0(`agent_signup.claim_started`,{registration_id:t.registrationId}),s.toString()})}const UMt=Ne({identity:cMt}),WMt=Ne({orgId:He().min(1),claimed:nt(!0)});function GMt(e){return BMt(this,arguments,void 0,function*(e,t=()=>{}){let{apiUrl:n,directory:r}=e,i=e.code?.trim(),a=e.email?.trim();if(!i&&!a||i&&a)throw Error(`Provide either --email <email> for a claim link or --code <code> to finish the claim.`);let o=yield SMt(n,r);if(!o)throw Error(`No saved agent registration. Run from the directory used for mint deploy, or pass --directory.`);if(a&&!o.claimVerified)return t(`Creating the claim link...`),`Claim link for the user: ${yield HMt(n,o,a)}\nAsk the user to open it, sign in, and return the displayed code. Then run mint claim --code <code> from the same directory (or repeat --directory).`;let s=yield U1(n);if(new URL(s.issuer).origin!==new URL(o.issuer).origin)throw Error(`Saved agent credentials belong to another issuer.`);let c=e=>CMt(n,r,e);if(!o.claimVerified){t(`Completing the WorkOS claim...`);let e=yield V1(yield B1(`${s.agent_auth.claim_endpoint.replace(/\/$/,``)}/complete`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({claim_token:o.claimToken,user_code:i})}),UMt);n0(`agent_signup.claim_completed`,{registration_id:o.registrationId}),o=Object.assign(Object.assign({},o),{assertion:e.identity.assertion,claimVerified:!0,accessToken:void 0,accessTokenExpiresAt:void 0}),yield c(o)}t(`Finishing the site claim...`);let l=yield pMt(s,o);return yield V1(yield B1(`${n}/api/agent/signup`,{method:`POST`,headers:{Authorization:`Bearer ${l.accessToken}`}}),WMt),yield c(l),`Site claimed successfully. The user can now manage it in the Mintlify dashboard.`})}const r0=(e,t=[])=>e.name===`up`||t.includes(`vim`)&&e.name===`k`||t.includes(`emacs`)&&e.ctrl&&e.name===`p`,i0=(e,t=[])=>e.name===`down`||t.includes(`vim`)&&e.name===`j`||t.includes(`emacs`)&&e.ctrl&&e.name===`n`,KMt=e=>e.name===`space`,qMt=e=>e.name===`backspace`,JMt=e=>e.name===`tab`,YMt=e=>`1234567890`.includes(e.name),a0=e=>e.name===`enter`||e.name===`return`;var XMt=class extends Error{name=`AbortPromptError`;message=`Prompt was aborted`;constructor(e){super(),this.cause=e?.cause}},ZMt=class extends Error{name=`CancelPromptError`;message=`Prompt was canceled`},QMt=class extends Error{name=`ExitPromptError`},$Mt=class extends Error{name=`HookError`},o0=class extends Error{name=`ValidationError`};const eNt=new Er;function tNt(e){return{rl:e,hooks:[],hooksCleanup:[],hooksEffect:[],index:0,handleChange(){}}}function nNt(e,t){let n=tNt(e);return eNt.run(n,()=>{function e(e){n.handleChange=()=>{n.index=0,e()},n.handleChange()}return t(e)})}function s0(){let e=eNt.getStore();if(!e)throw new $Mt(`[Inquirer] Hook functions can only be called from within a prompt`);return e}function rNt(){return s0().rl}function iNt(e){return Dr.bind((...t)=>{let n=s0(),r=!1,i=n.handleChange;n.handleChange=()=>{r=!0};let a=e(...t);return r&&i(),n.handleChange=i,a})}function c0(e){let t=s0(),{index:n}=t,r=e({get(){return t.hooks[n]},set(e){t.hooks[n]=e},initialized:n in t.hooks});return t.index++,r}function aNt(){s0().handleChange()}const l0={queue(e){let t=s0(),{index:n}=t;t.hooksEffect.push(()=>{t.hooksCleanup[n]?.();let r=e(rNt());if(r!=null&&typeof r!=`function`)throw new o0(`useEffect return value must be a cleanup function or nothing.`);t.hooksCleanup[n]=r})},run(){let e=s0();iNt(()=>{e.hooksEffect.forEach(e=>{e()}),e.hooksEffect.length=0})()},clearAll(){let e=s0();e.hooksCleanup.forEach(e=>{e?.()}),e.hooksEffect.length=0,e.hooksCleanup.length=0}};function u0(e){return c0(t=>{let n=Dr.bind(function(e){t.get()!==e&&(t.set(e),aNt())});if(t.initialized)return[t.get(),n];let r=typeof e==`function`?e():e;return t.set(r),[r,n]})}function d0(e,t){c0(n=>{let r=n.get();(!Array.isArray(r)||t.some((e,t)=>!Object.is(e,r[t])))&&l0.queue(e),n.set(t)})}function oNt(){return Vt.platform===`win32`?!!Vt.env.WT_SESSION||!!Vt.env.TERMINUS_SUBLIME||Vt.env.ConEmuTask===`{cmd::Cmder}`||Vt.env.TERM_PROGRAM===`Terminus-Sublime`||Vt.env.TERM_PROGRAM===`vscode`||Vt.env.TERM===`xterm-256color`||Vt.env.TERM===`alacritty`||Vt.env.TERMINAL_EMULATOR===`JetBrains-JediTerm`:Vt.env.TERM!==`linux`}const sNt={circleQuestionMark:`(?)`,questionMarkPrefix:`(?)`,square:`█`,squareDarkShade:`▓`,squareMediumShade:`▒`,squareLightShade:`░`,squareTop:`▀`,squareBottom:`▄`,squareLeft:`▌`,squareRight:`▐`,squareCenter:`■`,bullet:`●`,dot:`․`,ellipsis:`…`,pointerSmall:`›`,triangleUp:`▲`,triangleUpSmall:`▴`,triangleDown:`▼`,triangleDownSmall:`▾`,triangleLeftSmall:`◂`,triangleRightSmall:`▸`,home:`⌂`,heart:`♥`,musicNote:`♪`,musicNoteBeamed:`♫`,arrowUp:`↑`,arrowDown:`↓`,arrowLeft:`←`,arrowRight:`→`,arrowLeftRight:`↔`,arrowUpDown:`↕`,almostEqual:`≈`,notEqual:`≠`,lessOrEqual:`≤`,greaterOrEqual:`≥`,identical:`≡`,infinity:`∞`,subscriptZero:`₀`,subscriptOne:`₁`,subscriptTwo:`₂`,subscriptThree:`₃`,subscriptFour:`₄`,subscriptFive:`₅`,subscriptSix:`₆`,subscriptSeven:`₇`,subscriptEight:`₈`,subscriptNine:`₉`,oneHalf:`½`,oneThird:`⅓`,oneQuarter:`¼`,oneFifth:`⅕`,oneSixth:`⅙`,oneEighth:`⅛`,twoThirds:`⅔`,twoFifths:`⅖`,threeQuarters:`¾`,threeFifths:`⅗`,threeEighths:`⅜`,fourFifths:`⅘`,fiveSixths:`⅚`,fiveEighths:`⅝`,sevenEighths:`⅞`,line:`─`,lineBold:`━`,lineDouble:`═`,lineDashed0:`┄`,lineDashed1:`┅`,lineDashed2:`┈`,lineDashed3:`┉`,lineDashed4:`╌`,lineDashed5:`╍`,lineDashed6:`╴`,lineDashed7:`╶`,lineDashed8:`╸`,lineDashed9:`╺`,lineDashed10:`╼`,lineDashed11:`╾`,lineDashed12:`−`,lineDashed13:`–`,lineDashed14:`‐`,lineDashed15:`⁃`,lineVertical:`│`,lineVerticalBold:`┃`,lineVerticalDouble:`║`,lineVerticalDashed0:`┆`,lineVerticalDashed1:`┇`,lineVerticalDashed2:`┊`,lineVerticalDashed3:`┋`,lineVerticalDashed4:`╎`,lineVerticalDashed5:`╏`,lineVerticalDashed6:`╵`,lineVerticalDashed7:`╷`,lineVerticalDashed8:`╹`,lineVerticalDashed9:`╻`,lineVerticalDashed10:`╽`,lineVerticalDashed11:`╿`,lineDownLeft:`┐`,lineDownLeftArc:`╮`,lineDownBoldLeftBold:`┓`,lineDownBoldLeft:`┒`,lineDownLeftBold:`┑`,lineDownDoubleLeftDouble:`╗`,lineDownDoubleLeft:`╖`,lineDownLeftDouble:`╕`,lineDownRight:`┌`,lineDownRightArc:`╭`,lineDownBoldRightBold:`┏`,lineDownBoldRight:`┎`,lineDownRightBold:`┍`,lineDownDoubleRightDouble:`╔`,lineDownDoubleRight:`╓`,lineDownRightDouble:`╒`,lineUpLeft:`┘`,lineUpLeftArc:`╯`,lineUpBoldLeftBold:`┛`,lineUpBoldLeft:`┚`,lineUpLeftBold:`┙`,lineUpDoubleLeftDouble:`╝`,lineUpDoubleLeft:`╜`,lineUpLeftDouble:`╛`,lineUpRight:`└`,lineUpRightArc:`╰`,lineUpBoldRightBold:`┗`,lineUpBoldRight:`┖`,lineUpRightBold:`┕`,lineUpDoubleRightDouble:`╚`,lineUpDoubleRight:`╙`,lineUpRightDouble:`╘`,lineUpDownLeft:`┤`,lineUpBoldDownBoldLeftBold:`┫`,lineUpBoldDownBoldLeft:`┨`,lineUpDownLeftBold:`┥`,lineUpBoldDownLeftBold:`┩`,lineUpDownBoldLeftBold:`┪`,lineUpDownBoldLeft:`┧`,lineUpBoldDownLeft:`┦`,lineUpDoubleDownDoubleLeftDouble:`╣`,lineUpDoubleDownDoubleLeft:`╢`,lineUpDownLeftDouble:`╡`,lineUpDownRight:`├`,lineUpBoldDownBoldRightBold:`┣`,lineUpBoldDownBoldRight:`┠`,lineUpDownRightBold:`┝`,lineUpBoldDownRightBold:`┡`,lineUpDownBoldRightBold:`┢`,lineUpDownBoldRight:`┟`,lineUpBoldDownRight:`┞`,lineUpDoubleDownDoubleRightDouble:`╠`,lineUpDoubleDownDoubleRight:`╟`,lineUpDownRightDouble:`╞`,lineDownLeftRight:`┬`,lineDownBoldLeftBoldRightBold:`┳`,lineDownLeftBoldRightBold:`┯`,lineDownBoldLeftRight:`┰`,lineDownBoldLeftBoldRight:`┱`,lineDownBoldLeftRightBold:`┲`,lineDownLeftRightBold:`┮`,lineDownLeftBoldRight:`┭`,lineDownDoubleLeftDoubleRightDouble:`╦`,lineDownDoubleLeftRight:`╥`,lineDownLeftDoubleRightDouble:`╤`,lineUpLeftRight:`┴`,lineUpBoldLeftBoldRightBold:`┻`,lineUpLeftBoldRightBold:`┷`,lineUpBoldLeftRight:`┸`,lineUpBoldLeftBoldRight:`┹`,lineUpBoldLeftRightBold:`┺`,lineUpLeftRightBold:`┶`,lineUpLeftBoldRight:`┵`,lineUpDoubleLeftDoubleRightDouble:`╩`,lineUpDoubleLeftRight:`╨`,lineUpLeftDoubleRightDouble:`╧`,lineUpDownLeftRight:`┼`,lineUpBoldDownBoldLeftBoldRightBold:`╋`,lineUpDownBoldLeftBoldRightBold:`╈`,lineUpBoldDownLeftBoldRightBold:`╇`,lineUpBoldDownBoldLeftRightBold:`╊`,lineUpBoldDownBoldLeftBoldRight:`╉`,lineUpBoldDownLeftRight:`╀`,lineUpDownBoldLeftRight:`╁`,lineUpDownLeftBoldRight:`┽`,lineUpDownLeftRightBold:`┾`,lineUpBoldDownBoldLeftRight:`╂`,lineUpDownLeftBoldRightBold:`┿`,lineUpBoldDownLeftBoldRight:`╃`,lineUpBoldDownLeftRightBold:`╄`,lineUpDownBoldLeftBoldRight:`╅`,lineUpDownBoldLeftRightBold:`╆`,lineUpDoubleDownDoubleLeftDoubleRightDouble:`╬`,lineUpDoubleDownDoubleLeftRight:`╫`,lineUpDownLeftDoubleRightDouble:`╪`,lineCross:`╳`,lineBackslash:`╲`,lineSlash:`╱`},cNt={tick:`✔`,info:`ℹ`,warning:`⚠`,cross:`✘`,squareSmall:`◻`,squareSmallFilled:`◼`,circle:`◯`,circleFilled:`◉`,circleDotted:`◌`,circleDouble:`◎`,circleCircle:`ⓞ`,circleCross:`ⓧ`,circlePipe:`Ⓘ`,radioOn:`◉`,radioOff:`◯`,checkboxOn:`☒`,checkboxOff:`☐`,checkboxCircleOn:`ⓧ`,checkboxCircleOff:`Ⓘ`,pointer:`❯`,triangleUpOutline:`△`,triangleLeft:`◀`,triangleRight:`▶`,lozenge:`◆`,lozengeOutline:`◇`,hamburger:`☰`,smiley:`㋡`,mustache:`෴`,star:`★`,play:`▶`,nodejs:`⬢`,oneSeventh:`⅐`,oneNinth:`⅑`,oneTenth:`⅒`},lNt={tick:`√`,info:`i`,warning:`‼`,cross:`×`,squareSmall:`□`,squareSmallFilled:`■`,circle:`( )`,circleFilled:`(*)`,circleDotted:`( )`,circleDouble:`( )`,circleCircle:`(○)`,circleCross:`(×)`,circlePipe:`(│)`,radioOn:`(*)`,radioOff:`( )`,checkboxOn:`[×]`,checkboxOff:`[ ]`,checkboxCircleOn:`(×)`,checkboxCircleOff:`( )`,pointer:`>`,triangleUpOutline:`∆`,triangleLeft:`◄`,triangleRight:`►`,lozenge:`♦`,lozengeOutline:`◊`,hamburger:`≡`,smiley:`☺`,mustache:`┌─┐`,star:`✶`,play:`►`,nodejs:`♦`,oneSeventh:`1/7`,oneNinth:`1/9`,oneTenth:`1/10`},uNt={...sNt,...cNt},dNt={...sNt,...lNt},fNt=oNt()?uNt:dNt;Object.entries(cNt);const pNt={prefix:{idle:GZ.default.blue(`?`),done:GZ.default.green(fNt.tick)},spinner:{interval:80,frames:[`⠋`,`⠙`,`⠹`,`⠸`,`⠼`,`⠴`,`⠦`,`⠧`,`⠇`,`⠏`].map(e=>GZ.default.yellow(e))},style:{answer:GZ.default.cyan,message:GZ.default.bold,error:e=>GZ.default.red(`> ${e}`),defaultAnswer:e=>GZ.default.dim(`(${e})`),help:GZ.default.dim,highlight:GZ.default.cyan,key:e=>GZ.default.cyan(GZ.default.bold(`<${e}>`))}};function mNt(e){if(typeof e!=`object`||!e)return!1;let t=e;for(;Object.getPrototypeOf(t)!==null;)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t}function hNt(...e){let t={};for(let n of e)for(let[e,r]of Object.entries(n)){let n=t[e];t[e]=mNt(n)&&mNt(r)?hNt(n,r):r}return t}function f0(...e){return hNt(pNt,...e.filter(e=>e!=null))}function p0({status:e=`idle`,theme:t}){let[n,r]=u0(!1),[i,a]=u0(0),{prefix:o,spinner:s}=f0(t);return d0(()=>{if(e===`loading`){let e,t=-1,n=setTimeout(()=>{r(!0),e=setInterval(()=>{t+=1,a(t%s.frames.length)},s.interval)},300);return()=>{clearTimeout(n),clearInterval(e)}}r(!1)},[e]),n?s.frames[i]:typeof o==`string`?o:o[e===`loading`?`idle`:e]??o.idle}function m0(e,t){return c0(n=>{let r=n.get();if(!r||r.dependencies.length!==t.length||r.dependencies.some((e,n)=>e!==t[n])){let r=e();return n.set({value:r,dependencies:t}),r}return r.value})}function h0(e){return u0({current:e})[0]}function g0(e){let t=h0(e);t.current=e,d0(e=>{let n=!1,r=iNt((r,i)=>{n||t.current(i,e)});return e.input.on(`keypress`,r),()=>{n=!0,e.input.removeListener(`keypress`,r)}},[])}function _0(e,t){return e.split(`
|
|
1925
|
+
`);for(let n=r;n<a.length;n++){let r=a[n];if(r.length>1024)continue;let o=gAt.test(r)?r.replace(gAt,`$1`):r;if(!o.match(/\S*Error: /)){for(let n of t){let t=n(o,e);if(t){i.push(t);break}}if(i.length>=50)break}}return _At(i)}}var bAt=class{match(e){return Rkt(e)}coerce(e,t){return{type:this.getType(e),value:this.getMessage(e,t),stack:this.getStack(e),cause:e.cause?t.next(e.cause):void 0,synthetic:!1}}getType(e){return e.name||e.constructor.name}getMessage(e,t){let n=e.message;return n.error&&typeof n.error.message==`string`?String(n.error.message):String(n)}getStack(e){return e.stacktrace||e.stack||void 0}};const xAt=/^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/i;var SAt=class{match(e){return typeof e==`string`}coerce(e,t){let[n,r]=this.getInfos(e);return{type:n??`Error`,value:r??e,stack:t.syntheticException?.stack,synthetic:!0}}getInfos(e){let t=`Error`,n=e,r=e.match(xAt);return r&&(t=r[1],n=r[2]),[t,n]}};const CAt=[`fatal`,`error`,`warning`,`log`,`info`,`debug`];function wAt(e,t=40){let n=Object.keys(e);if(n.sort(),!n.length)return`[object has no keys]`;for(let e=n.length;e>0;e--){let r=n.slice(0,e).join(`, `);if(!(r.length>t))return e===n.length||r.length<=t?r:`${r.slice(0,t)}...`}return``}var TAt=class{match(e){return typeof e==`object`&&!!e}coerce(e,t){let n=this.getErrorPropertyFromObject(e);return n?t.apply(n):{type:this.getType(e),value:this.getValue(e),stack:t.syntheticException?.stack,level:this.isSeverityLevel(e.level)?e.level:`error`,synthetic:!0}}getType(e){return Hkt(e)?e.constructor.name:`Error`}getValue(e){if(`name`in e&&typeof e.name==`string`){let t=`'${e.name}' captured as exception`;return`message`in e&&typeof e.message==`string`&&(t+=` with message: '${e.message}'`),t}if(`message`in e&&typeof e.message==`string`)return e.message;let t=this.getObjectClassName(e),n=wAt(e);return`${t&&t!==`Object`?`'${t}'`:`Object`} captured as exception with keys: ${n}`}isSeverityLevel(e){return Fkt(e)&&!Ikt(e)&&CAt.indexOf(e)>=0}getErrorPropertyFromObject(e){for(let t in e)if(Object.prototype.hasOwnProperty.call(e,t)){let n=e[t];if(eAt(n))return n}}getObjectClassName(e){try{let t=Object.getPrototypeOf(e);return t?t.constructor.name:void 0}catch{return}}},EAt=class{match(e){return Hkt(e)}coerce(e,t){let n=e.constructor.name;return{type:n,value:`${n} captured as exception with keys: ${wAt(e)}`,stack:t.syntheticException?.stack,synthetic:!0}}},DAt=class{match(e){return Bkt(e)}coerce(e,t){return{type:`Error`,value:`Primitive value captured as exception: ${String(e)}`,stack:t.syntheticException?.stack,synthetic:!0}}},OAt=class{constructor(e){this._maxSize=e,this._cache=/* @__PURE__ */ new Map}get(e){let t=this._cache.get(e);if(t!==void 0)return this._cache.delete(e),this._cache.set(e,t),t}set(e,t){this._cache.set(e,t)}reduce(){for(;this._cache.size>=this._maxSize;){let e=this._cache.keys().next().value;e&&this._cache.delete(e)}}};const X$=new OAt(25),kAt=new OAt(20);async function AAt(e){let t={};for(let n=e.length-1;n>=0;n--){let r=e[n],i=r?.filename;!r||typeof i!=`string`||typeof r.lineno!=`number`||FAt(i)||IAt(r)||(t[i]||(t[i]=[]),t[i].push(r.lineno))}let n=Object.keys(t);if(n.length==0)return e;let r=[];for(let e of n){if(kAt.get(e))continue;let n=t[e];if(!n)continue;n.sort((e,t)=>e-t);let i=RAt(n);if(i.every(t=>LAt(e,t)))continue;let a=HAt(X$,e,{});r.push(jAt(e,i,a))}return await Promise.all(r).catch(()=>{}),e&&e.length>0&&MAt(e,X$),X$.reduce(),e}function jAt(e,t,n){return new Promise(r=>{let i=Dn(e),a=Ar({input:i});function o(){i.destroy(),r()}let s=0,c=0,l=t[c];if(l===void 0)return void o();let u=l[0],d=l[1];function f(){kAt.set(e,1),a.close(),a.removeAllListeners(),o()}i.on(`error`,f),a.on(`error`,f),a.on(`close`,o),a.on(`line`,e=>{if(s++,!(s<u)&&(n[s]=UAt(e,0),s>=d)){if(c===t.length-1){a.close(),a.removeAllListeners();return}c++;let e=t[c];if(e===void 0){a.close(),a.removeAllListeners();return}u=e[0],d=e[1]}})})}function MAt(e,t){for(let n of e)if(n.filename&&n.context_line===void 0&&typeof n.lineno==`number`){let e=t.get(n.filename);if(e===void 0)continue;NAt(n.lineno,n,e)}}function NAt(e,t,n){if(t.lineno===void 0||n===void 0)return;t.pre_context=[];for(let r=BAt(e);r<e;r++){let e=n[r];if(e===void 0)return void PAt(t);t.pre_context.push(e)}if(n[e]===void 0)return void PAt(t);t.context_line=n[e];let r=VAt(e);t.post_context=[];for(let i=e+1;i<=r;i++){let e=n[i];if(e===void 0)break;t.post_context.push(e)}}function PAt(e){delete e.pre_context,delete e.context_line,delete e.post_context}function FAt(e){return e.startsWith(`node:`)||e.endsWith(`.min.js`)||e.endsWith(`.min.cjs`)||e.endsWith(`.min.mjs`)||e.startsWith(`data:`)}function IAt(e){return e.lineno!==void 0&&e.lineno>1e4||e.colno!==void 0&&e.colno>1e3}function LAt(e,t){let n=X$.get(e);if(n===void 0)return!1;for(let e=t[0];e<=t[1];e++)if(n[e]===void 0)return!1;return!0}function RAt(e){if(!e.length)return[];let t=0,n=e[0];if(typeof n!=`number`)return[];let r=zAt(n),i=[];for(;;){if(t===e.length-1){i.push(r);break}let n=e[t+1];if(typeof n!=`number`)break;n<=r[1]?r[1]=n+7:(i.push(r),r=zAt(n)),t++}return i}function zAt(e){return[BAt(e),VAt(e)]}function BAt(e){return Math.max(1,e-7)}function VAt(e){return e+7}function HAt(e,t,n){let r=e.get(t);return r===void 0?(e.set(t,n),n):r}function UAt(e,t){let n=e,r=n.length;if(r<=150)return n;t>r&&(t=r);let i=Math.max(t-60,0);i<5&&(i=0);let a=Math.min(i+140,r);return a>r-5&&(a=r),a===r&&(i=Math.max(a-140,0)),n=n.slice(i,a),i>0&&(n=`...${n}`),a<r&&(n+=`...`),n}function WAt(e,t){let n=!1;return Object.assign(r=>{let i=global.process.listeners(`uncaughtException`).filter(e=>e.name!==`domainUncaughtExceptionClear`&&!0!==e._posthogErrorHandler).length===0;e(r,{mechanism:{type:`onuncaughtexception`,handled:!1}}),!n&&i&&(n=!0,t(r))},{_posthogErrorHandler:!0})}function GAt(e,t){globalThis.process?.on(`uncaughtException`,WAt(e,t))}function KAt(e){globalThis.process?.on(`unhandledRejection`,t=>e(t,{mechanism:{type:`onunhandledrejection`,handled:!1}}))}var Z$=class e{constructor(e,t,n){this.client=e,this._exceptionAutocaptureEnabled=t.enableExceptionAutocapture||!1,this._logger=n,this._rateLimiter=new Wkt({refillRate:1,bucketSize:10,refillInterval:1e4,_logger:this._logger}),this.startAutocaptureIfEnabled()}static async buildEventMessage(e,t,n,r){let i={...r};n||(i.$process_person_profile=!1);let a=this.errorPropertiesBuilder.buildFromUnknown(e,t);return a.$exception_list=await this.errorPropertiesBuilder.modifyFrames(a.$exception_list),{event:`$exception`,distinctId:n||z$(),properties:{...a,...i}}}startAutocaptureIfEnabled(){this.isEnabled()&&(GAt(this.onException.bind(this),this.onFatalError.bind(this)),KAt(this.onException.bind(this)))}onException(t,n){this.client.addPendingPromise((async()=>{let r=await e.buildEventMessage(t,n),i=r.properties?.$exception_list[0]?.type??`Exception`;return this._rateLimiter.consumeRateLimit(i)?void this._logger.info(`Skipping exception capture because of client rate limiting.`,{exception:i}):this.client.capture(r)})())}async onFatalError(e){console.error(e),await this.client.shutdown(2e3),process.exit(1)}isEnabled(){return!this.client.isDisabled&&this._exceptionAutocaptureEnabled}shutdown(){this._rateLimiter.stop()}};async function qAt(e){let t=globalThis.crypto?.subtle;if(!t)throw Error(`SubtleCrypto API not available`);let n=await t.digest(`SHA-1`,new TextEncoder().encode(e));return Array.from(new Uint8Array(n)).map(e=>e.toString(16).padStart(2,`0`)).join(``)}const JAt=[`is_not`];var Q$=class e extends Error{constructor(t){super(),Error.captureStackTrace(this,this.constructor),this.name=`ClientError`,this.message=t,Object.setPrototypeOf(this,e.prototype)}},$$=class e extends Error{constructor(t){super(t),this.name=this.constructor.name,Error.captureStackTrace(this,this.constructor),Object.setPrototypeOf(this,e.prototype)}},e1=class e extends Error{constructor(t){super(t),this.name=this.constructor.name,Error.captureStackTrace(this,this.constructor),Object.setPrototypeOf(this,e.prototype)}},YAt=class{constructor({pollingInterval:e,personalApiKey:t,projectApiKey:n,timeout:r,host:i,customHeaders:a,...o}){this.debugMode=!1,this.shouldBeginExponentialBackoff=!1,this.backOffCount=0,this.pollingInterval=e,this.personalApiKey=t,this.featureFlags=[],this.featureFlagsByKey={},this.groupTypeMapping={},this.cohorts={},this.loadedSuccessfullyOnce=!1,this.timeout=r,this.projectApiKey=n,this.host=i,this.poller=void 0,this.fetch=o.fetch||fetch,this.onError=o.onError,this.customHeaders=a,this.onLoad=o.onLoad,this.cacheProvider=o.cacheProvider,this.loadFeatureFlags()}debug(e=!0){this.debugMode=e}logMsgIfDebug(e){this.debugMode&&e()}async getFeatureFlag(e,t,n={},r={},i={}){await this.loadFeatureFlags();let a,o;if(!this.loadedSuccessfullyOnce)return a;if(o=this.featureFlagsByKey[e],o!==void 0)try{a=(await this.computeFlagAndPayloadLocally(o,t,n,r,i)).value,this.logMsgIfDebug(()=>console.debug(`Successfully computed flag locally: ${e} -> ${a}`))}catch(t){t instanceof e1||t instanceof $$?this.logMsgIfDebug(()=>console.debug(`${t.name} when computing flag locally: ${e}: ${t.message}`)):t instanceof Error&&this.onError?.(/* @__PURE__ */ Error(`Error computing flag locally: ${e}: ${t}`))}return a}async getAllFlagsAndPayloads(e,t={},n={},r={},i){await this.loadFeatureFlags();let a={},o={},s=this.featureFlags.length==0,c=i?i.map(e=>this.featureFlagsByKey[e]).filter(Boolean):this.featureFlags,l={};return await Promise.all(c.map(async i=>{try{let{value:s,payload:c}=await this.computeFlagAndPayloadLocally(i,e,t,n,r,void 0,l);a[i.key]=s,c&&(o[i.key]=c)}catch(e){e instanceof e1||e instanceof $$?this.logMsgIfDebug(()=>console.debug(`${e.name} when computing flag locally: ${i.key}: ${e.message}`)):e instanceof Error&&this.onError?.(/* @__PURE__ */ Error(`Error computing flag locally: ${i.key}: ${e}`)),s=!0}})),{response:a,payloads:o,fallbackToFlags:s}}async computeFlagAndPayloadLocally(e,t,n={},r={},i={},a,o,s=!1){if(s||await this.loadFeatureFlags(),!this.loadedSuccessfullyOnce)return{value:!1,payload:null};let c;c=a===void 0?await this.computeFlagValueLocally(e,t,n,r,i,o):a;let l=this.getFeatureFlagPayload(e.key,c);return{value:c,payload:l}}async computeFlagValueLocally(e,t,n={},r={},i={},a={}){if(e.ensure_experience_continuity)throw new $$(`Flag has experience continuity enabled`);if(!e.active)return!1;let o=(e.filters||{}).aggregation_group_type_index;if(o==null)return await this.matchFeatureFlagProperties(e,t,r,a);{let t=this.groupTypeMapping[String(o)];if(!t)throw this.logMsgIfDebug(()=>console.warn(`[FEATURE FLAGS] Unknown group type index ${o} for feature flag ${e.key}`)),new $$(`Flag has unknown group type index`);if(!(t in n))return this.logMsgIfDebug(()=>console.warn(`[FEATURE FLAGS] Can't compute group feature flag: ${e.key} without group names passed in`)),!1;let r=i[t];return await this.matchFeatureFlagProperties(e,n[t],r,a)}}getFeatureFlagPayload(e,t){let n=null;if(!1!==t&&t!=null&&(typeof t==`boolean`?n=this.featureFlagsByKey?.[e]?.filters?.payloads?.[t.toString()]||null:typeof t==`string`&&(n=this.featureFlagsByKey?.[e]?.filters?.payloads?.[t]||null),n!=null)){if(typeof n==`object`)return n;if(typeof n==`string`)try{return JSON.parse(n)}catch{}return n}return null}async evaluateFlagDependency(e,t,n,r){let i=e.key;if(!this.featureFlagsByKey)throw new $$(`Feature flags not available for dependency evaluation`);if(!(`dependency_chain`in e))throw new $$(`Flag dependency property for '${i}' is missing required 'dependency_chain' field`);let a=e.dependency_chain;if(!Array.isArray(a))throw new $$(`Flag dependency property for '${i}' has an invalid 'dependency_chain' (expected array, got ${typeof a})`);if(a.length===0)throw new $$(`Circular dependency detected for flag '${i}' (empty dependency chain)`);for(let e of a){if(!(e in r)){let a=this.featureFlagsByKey[e];if(a){if(a.active)try{r[e]=await this.matchFeatureFlagProperties(a,t,n,r)}catch(t){throw new $$(`Error evaluating flag dependency '${e}' for flag '${i}': ${t}`)}else r[e]=!1}else throw new $$(`Missing flag dependency '${e}' for flag '${i}'`)}if(r[e]==null)throw new $$(`Dependency '${e}' could not be evaluated`)}let o=r[i];return this.flagEvaluatesToExpectedValue(e.value,o)}flagEvaluatesToExpectedValue(e,t){return typeof e==`boolean`?e===t||typeof t==`string`&&t!==``&&!0===e:typeof e==`string`&&t===e}async matchFeatureFlagProperties(e,t,n,r={}){let i=e.filters||{},a=i.groups||[],o=!1,s;for(let c of a)try{if(await this.isConditionMatch(e,t,c,n,r)){let n=c.variant,r=i.multivariate?.variants||[];s=n&&r.some(e=>e.key===n)?n:await this.getMatchingVariant(e,t)||!0;break}}catch(e){if(e instanceof e1)throw e;if(e instanceof $$)o=!0;else throw e}if(s!==void 0)return s;if(o)throw new $$(`Can't determine if feature flag is enabled or not with given properties`);return!1}async isConditionMatch(e,t,n,r,i={}){let a=n.rollout_percentage,o=e=>{this.logMsgIfDebug(()=>console.warn(e))};if((n.properties||[]).length>0){for(let e of n.properties){let n=e.type,a=!1;if(a=n===`cohort`?$At(e,r,this.cohorts,this.debugMode):n===`flag`?await this.evaluateFlagDependency(e,t,r,i):ZAt(e,r,o),!a)return!1}if(a==null)return!0}return!(a!=null&&await XAt(e.key,t)>a/100)}async getMatchingVariant(e,t){let n=await XAt(e.key,t,`variant`),r=this.variantLookupTable(e).find(e=>n>=e.valueMin&&n<e.valueMax);if(r)return r.key}variantLookupTable(e){let t=[],n=0,r=0;return((e.filters||{}).multivariate?.variants||[]).forEach(e=>{r=n+e.rollout_percentage/100,t.push({valueMin:n,valueMax:r,key:e.key}),n=r}),t}updateFlagState(e){this.featureFlags=e.flags,this.featureFlagsByKey=e.flags.reduce((e,t)=>(e[t.key]=t,e),{}),this.groupTypeMapping=e.groupTypeMapping,this.cohorts=e.cohorts,this.loadedSuccessfullyOnce=!0}async loadFromCache(e){if(!this.cacheProvider)return!1;try{let t=await this.cacheProvider.getFlagDefinitions();return t?(this.updateFlagState(t),this.logMsgIfDebug(()=>console.debug(`[FEATURE FLAGS] ${e} (${t.flags.length} flags)`)),this.onLoad?.(this.featureFlags.length),!0):!1}catch(e){return this.onError?.(/* @__PURE__ */ Error(`Failed to load from cache: ${e}`)),!1}}async loadFeatureFlags(e=!1){if(!this.loadedSuccessfullyOnce||e)return this.loadingPromise||=this._loadFeatureFlags().catch(e=>this.logMsgIfDebug(()=>console.debug(`[FEATURE FLAGS] Failed to load feature flags: ${e}`))).finally(()=>{this.loadingPromise=void 0}),this.loadingPromise}isLocalEvaluationReady(){return(this.loadedSuccessfullyOnce??!1)&&(this.featureFlags?.length??0)>0}getPollingInterval(){return this.shouldBeginExponentialBackoff?Math.min(6e4,this.pollingInterval*2**this.backOffCount):this.pollingInterval}async _loadFeatureFlags(){this.poller&&=(clearTimeout(this.poller),void 0),this.poller=setTimeout(()=>this.loadFeatureFlags(!0),this.getPollingInterval());try{let e=!0;if(this.cacheProvider)try{e=await this.cacheProvider.shouldFetchFlagDefinitions()}catch(e){this.onError?.(/* @__PURE__ */ Error(`Error in shouldFetchFlagDefinitions: ${e}`))}if(!e&&(await this.loadFromCache(`Loaded flags from cache (skipped fetch)`)||this.loadedSuccessfullyOnce))return;let t=await this._requestFeatureFlagDefinitions();if(!t)return;switch(t.status){case 304:this.logMsgIfDebug(()=>console.debug(`[FEATURE FLAGS] Flags not modified (304), using cached data`)),this.flagsEtag=t.headers?.get(`ETag`)??this.flagsEtag,this.loadedSuccessfullyOnce=!0,this.shouldBeginExponentialBackoff=!1,this.backOffCount=0;return;case 401:throw this.shouldBeginExponentialBackoff=!0,this.backOffCount+=1,new Q$(`Your project key or personal API key is invalid. Setting next polling interval to ${this.getPollingInterval()}ms. More information: https://posthog.com/docs/api#rate-limiting`);case 402:console.warn(`[FEATURE FLAGS] Feature flags quota limit exceeded - unsetting all local flags. Learn more about billing limits at https://posthog.com/docs/billing/limits-alerts`),this.featureFlags=[],this.featureFlagsByKey={},this.groupTypeMapping={},this.cohorts={};return;case 403:throw this.shouldBeginExponentialBackoff=!0,this.backOffCount+=1,new Q$(`Your personal API key does not have permission to fetch feature flag definitions for local evaluation. Setting next polling interval to ${this.getPollingInterval()}ms. Are you sure you're using the correct personal and Project API key pair? More information: https://posthog.com/docs/api/overview`);case 429:throw this.shouldBeginExponentialBackoff=!0,this.backOffCount+=1,new Q$(`You are being rate limited. Setting next polling interval to ${this.getPollingInterval()}ms. More information: https://posthog.com/docs/api#rate-limiting`);case 200:{let n=await t.json()??{};if(!(`flags`in n))return void this.onError?.(/* @__PURE__ */ Error(`Invalid response when getting feature flags: ${JSON.stringify(n)}`));this.flagsEtag=t.headers?.get(`ETag`)??void 0;let r={flags:n.flags??[],groupTypeMapping:n.group_type_mapping||{},cohorts:n.cohorts||{}};if(this.updateFlagState(r),this.shouldBeginExponentialBackoff=!1,this.backOffCount=0,this.cacheProvider&&e)try{await this.cacheProvider.onFlagDefinitionsReceived(r)}catch(e){this.onError?.(/* @__PURE__ */ Error(`Failed to store in cache: ${e}`))}this.onLoad?.(this.featureFlags.length);break}default:return}}catch(e){e instanceof Q$&&this.onError?.(e)}}getPersonalApiKeyRequestOptions(e=`GET`,t){let n={...this.customHeaders,"Content-Type":`application/json`,Authorization:`Bearer ${this.personalApiKey}`};return t&&(n[`If-None-Match`]=t),{method:e,headers:n}}_requestFeatureFlagDefinitions(){let e=`${this.host}/api/feature_flag/local_evaluation?token=${this.projectApiKey}&send_cohorts`,t=this.getPersonalApiKeyRequestOptions(`GET`,this.flagsEtag),n=null;if(this.timeout&&typeof this.timeout==`number`){let e=new AbortController;n=W$(()=>{e.abort()},this.timeout),t.signal=e.signal}try{let n=this.fetch;return n(e,t)}finally{clearTimeout(n)}}async stopPoller(e=3e4){if(clearTimeout(this.poller),this.cacheProvider)try{let t=this.cacheProvider.shutdown();t instanceof Promise&&await Promise.race([t,new Promise((t,n)=>setTimeout(()=>n(/* @__PURE__ */ Error(`Cache shutdown timeout after ${e}ms`)),e))])}catch(e){this.onError?.(/* @__PURE__ */ Error(`Error during cache shutdown: ${e}`))}}};async function XAt(e,t,n=``){let r=await qAt(`${e}.${t}${n}`);return parseInt(r.slice(0,15),16)/0x1000000000000000}function ZAt(e,t,n){let r=e.key,i=e.value,a=e.operator||`exact`;if(r in t){if(a===`is_not_set`)throw new $$(`Operator is_not_set is not supported`)}else throw new $$(`Property ${r} not found in propertyValues`);let o=t[r];if(o==null&&!JAt.includes(a))return n&&n(`Property ${r} cannot have a value of null/undefined with the ${a} operator`),!1;function s(e,t){return Array.isArray(e)?e.map(e=>String(e).toLowerCase()).includes(String(t).toLowerCase()):String(e).toLowerCase()===String(t).toLowerCase()}function c(e,t,n){if(n===`gt`)return e>t;if(n===`gte`)return e>=t;if(n===`lt`)return e<t;if(n===`lte`)return e<=t;throw Error(`Invalid operator: ${n}`)}switch(a){case`exact`:return s(i,o);case`is_not`:return!s(i,o);case`is_set`:return r in t;case`icontains`:return String(o).toLowerCase().includes(String(i).toLowerCase());case`not_icontains`:return!String(o).toLowerCase().includes(String(i).toLowerCase());case`regex`:return tjt(String(i))&&String(o).match(String(i))!==null;case`not_regex`:return tjt(String(i))&&String(o).match(String(i))===null;case`gt`:case`gte`:case`lt`:case`lte`:{let e=typeof i==`number`?i:null;if(typeof i==`string`)try{e=parseFloat(i)}catch{}return e==null||o==null?c(String(o),String(i),a):typeof o==`string`?c(o,String(i),a):c(o,e,a)}case`is_date_after`:case`is_date_before`:{if(typeof i==`boolean`)throw new $$(`Date operations cannot be performed on boolean values`);let e=rjt(String(i));if(e??=njt(i),e==null)throw new $$(`Invalid date: ${i}`);let t=njt(o);return[`is_date_before`].includes(a)?t<e:t>e}default:throw new $$(`Unknown operator: ${a}`)}}function QAt(e,t){if(!(e in t))throw new e1(`cohort ${e} not found in local cohorts - likely a static cohort that requires server evaluation`)}function $At(e,t,n,r=!1){let i=String(e.value);QAt(i,n);let a=n[i];return ejt(a,t,n,r)}function ejt(e,t,n,r=!1){if(!e)return!0;let i=e.type,a=e.values;if(!a||a.length===0)return!0;let o=!1;if(`values`in a[0]){for(let e of a)try{let a=ejt(e,t,n,r);if(i===`AND`){if(!a)return!1}else if(a)return!0}catch(t){if(t instanceof e1)throw t;if(t instanceof $$)r&&console.debug(`Failed to compute property ${e} locally: ${t}`),o=!0;else throw t}if(o)throw new $$(`Can't match cohort without a given cohort property value`);return i===`AND`}for(let e of a)try{let a;if(e.type===`cohort`)a=$At(e,t,n,r);else if(e.type===`flag`){r&&console.warn(`[FEATURE FLAGS] Flag dependency filters are not supported in local evaluation. Skipping condition with dependency on flag '${e.key||`unknown`}'`);continue}else a=ZAt(e,t);let o=e.negation||!1;if(i===`AND`){if(!a&&!o||a&&o)return!1}else if(a&&!o||!a&&o)return!0}catch(t){if(t instanceof e1)throw t;if(t instanceof $$)r&&console.debug(`Failed to compute property ${e} locally: ${t}`),o=!0;else throw t}if(o)throw new $$(`can't match cohort without a given cohort property value`);return i===`AND`}function tjt(e){try{return new RegExp(e),!0}catch{return!1}}function njt(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 $$(`${e} is in an invalid date format`)}throw new $$(`The date provided ${e} must be a string, number, or date object`)}function rjt(e){let t=e.match(/^-?(?<number>[0-9]+)(?<interval>[a-z])$/),n=new Date((/* @__PURE__ */ new Date()).toISOString());if(!t)return null;{if(!t.groups)return null;let e=parseInt(t.groups.number);if(e>=1e4)return null;let r=t.groups.interval;if(r==`h`)n.setUTCHours(n.getUTCHours()-e);else if(r==`d`)n.setUTCDate(n.getUTCDate()-e);else if(r==`w`)n.setUTCDate(n.getUTCDate()-7*e);else if(r==`m`)n.setUTCMonth(n.getUTCMonth()-e);else{if(r!=`y`)return null;n.setUTCFullYear(n.getUTCFullYear()-e)}return n}}var ijt=class{getProperty(e){return this._memoryStorage[e]}setProperty(e,t){this._memoryStorage[e]=t===null?void 0:t}constructor(){this._memoryStorage={}}};const ajt=3e4;var ojt=class extends sAt{constructor(e,t={}){if(super(e,t),this._memoryStorage=new ijt,this.options=t,this.context=this.initializeContext(),this.options.featureFlagsPollingInterval=typeof t.featureFlagsPollingInterval==`number`?Math.max(t.featureFlagsPollingInterval,100):ajt,t.personalApiKey){if(t.personalApiKey.includes(`phc_`))throw Error(`Your Personal API key is invalid. These keys are prefixed with "phx_" and can be created in PostHog project settings.`);!1!==t.enableLocalEvaluation&&(this.featureFlagsPoller=new YAt({pollingInterval:this.options.featureFlagsPollingInterval,personalApiKey:t.personalApiKey,projectApiKey:e,timeout:t.requestTimeout??1e4,host:this.host,fetch:t.fetch,onError:e=>{this._events.emit(`error`,e)},onLoad:e=>{this._events.emit(`localEvaluationFlagsLoaded`,e)},customHeaders:this.getCustomHeaders(),cacheProvider:t.flagDefinitionCacheProvider}))}this.errorTracking=new Z$(this,t,this._logger),this.distinctIdHasSentFlagCalls={},this.maxCacheSize=t.maxCacheSize||5e4}getPersistedProperty(e){return this._memoryStorage.getProperty(e)}setPersistedProperty(e,t){return this._memoryStorage.setProperty(e,t)}fetch(e,t){return this.options.fetch?this.options.fetch(e,t):fetch(e,t)}getLibraryVersion(){return`5.17.2`}getCustomUserAgent(){return`${this.getLibraryId()}/${this.getLibraryVersion()}`}enable(){return super.optIn()}disable(){return super.optOut()}debug(e=!0){super.debug(e),this.featureFlagsPoller?.debug(e)}capture(e){typeof e==`string`&&this._logger.warn(`Called capture() with a string as the first argument when an object was expected.`),this.addPendingPromise(this.prepareEventMessage(e).then(({distinctId:e,event:t,properties:n,options:r})=>super.captureStateless(e,t,n,{timestamp:r.timestamp,disableGeoip:r.disableGeoip,uuid:r.uuid})).catch(e=>{e&&console.error(e)}))}async captureImmediate(e){return typeof e==`string`&&this._logger.warn(`Called captureImmediate() with a string as the first argument when an object was expected.`),this.addPendingPromise(this.prepareEventMessage(e).then(({distinctId:e,event:t,properties:n,options:r})=>super.captureStatelessImmediate(e,t,n,{timestamp:r.timestamp,disableGeoip:r.disableGeoip,uuid:r.uuid})).catch(e=>{e&&console.error(e)}))}identify({distinctId:e,properties:t,disableGeoip:n}){let r=t?.$set_once;delete t?.$set_once;let i=t?.$set||t;super.identifyStateless(e,{$set:i,$set_once:r},{disableGeoip:n})}async identifyImmediate({distinctId:e,properties:t,disableGeoip:n}){let r=t?.$set_once;delete t?.$set_once;let i=t?.$set||t;await super.identifyStatelessImmediate(e,{$set:i,$set_once:r},{disableGeoip:n})}alias(e){super.aliasStateless(e.alias,e.distinctId,void 0,{disableGeoip:e.disableGeoip})}async aliasImmediate(e){await super.aliasStatelessImmediate(e.alias,e.distinctId,void 0,{disableGeoip:e.disableGeoip})}isLocalEvaluationReady(){return this.featureFlagsPoller?.isLocalEvaluationReady()??!1}async waitForLocalEvaluationReady(e=ajt){return this.isLocalEvaluationReady()?!0:this.featureFlagsPoller!==void 0&&new Promise(t=>{let n=setTimeout(()=>{r(),t(!1)},e),r=this._events.on(`localEvaluationFlagsLoaded`,e=>{clearTimeout(n),r(),t(e>0)})})}async getFeatureFlag(e,t,n){let{groups:r,disableGeoip:i}=n||{},{onlyEvaluateLocally:a,sendFeatureFlagEvents:o,personProperties:s,groupProperties:c}=n||{},l=this.addLocalPersonAndGroupProperties(t,r,s,c);s=l.allPersonProperties,c=l.allGroupProperties,a??=!1,o??=this.options.sendFeatureFlagEvent??!0;let u=await this.featureFlagsPoller?.getFeatureFlag(e,t,r,s,c),d=u!==void 0,f,p,m;if(!d&&!a){let n=await super.getFeatureFlagDetailStateless(e,t,r,s,c,i);if(n===void 0)return;m=n.response,u=L$(m),f=n?.requestId,p=n?.evaluatedAt}let h=`${e}_${u}`;return o&&(!(t in this.distinctIdHasSentFlagCalls)||!this.distinctIdHasSentFlagCalls[t].includes(h))&&(Object.keys(this.distinctIdHasSentFlagCalls).length>=this.maxCacheSize&&(this.distinctIdHasSentFlagCalls={}),Array.isArray(this.distinctIdHasSentFlagCalls[t])?this.distinctIdHasSentFlagCalls[t].push(h):this.distinctIdHasSentFlagCalls[t]=[h],this.capture({distinctId:t,event:`$feature_flag_called`,properties:{$feature_flag:e,$feature_flag_response:u,$feature_flag_id:m?.metadata?.id,$feature_flag_version:m?.metadata?.version,$feature_flag_reason:m?.reason?.description??m?.reason?.code,locally_evaluated:d,[`$feature/${e}`]:u,$feature_flag_request_id:f,$feature_flag_evaluated_at:p},groups:r,disableGeoip:i})),u}async getFeatureFlagPayload(e,t,n,r){let{groups:i,disableGeoip:a}=r||{},{onlyEvaluateLocally:o,personProperties:s,groupProperties:c}=r||{},l=this.addLocalPersonAndGroupProperties(t,i,s,c);s=l.allPersonProperties,c=l.allGroupProperties;let u;if(this.featureFlagsPoller!==void 0){await this.featureFlagsPoller?.loadFeatureFlags();let r=this.featureFlagsPoller?.featureFlagsByKey[e];if(r)try{let e=await this.featureFlagsPoller?.computeFlagAndPayloadLocally(r,t,i,s,c,n);e&&(n=e.value,u=e.payload)}catch(e){if(e instanceof e1||e instanceof $$)this._logger?.info(`${e.name} when computing flag locally: ${r.key}: ${e.message}`);else throw e}}return o??=!1,u===void 0&&!o&&(u=await super.getFeatureFlagPayloadStateless(e,t,i,s,c,a)),u}async getRemoteConfigPayload(e){if(!this.options.personalApiKey)throw Error(`Personal API key is required for remote config payload decryption`);let t=await this._requestRemoteConfigPayload(e);if(!t)return;let n=await t.json();if(typeof n==`string`)try{return JSON.parse(n)}catch{}return n}async isFeatureEnabled(e,t,n){let r=await this.getFeatureFlag(e,t,n);if(r!==void 0)return!!r||!1}async getAllFlags(e,t){return(await this.getAllFlagsAndPayloads(e,t)).featureFlags||{}}async getAllFlagsAndPayloads(e,t){let{groups:n,disableGeoip:r,flagKeys:i}=t||{},{onlyEvaluateLocally:a,personProperties:o,groupProperties:s}=t||{},c=this.addLocalPersonAndGroupProperties(e,n,o,s);o=c.allPersonProperties,s=c.allGroupProperties,a??=!1;let l=await this.featureFlagsPoller?.getAllFlagsAndPayloads(e,n,o,s,i),u={},d={},f=!0;if(l&&(u=l.response,d=l.payloads,f=l.fallbackToFlags),f&&!a){let t=await super.getFeatureFlagsAndPayloadsStateless(e,n,o,s,r,i);u={...u,...t.flags||{}},d={...d,...t.payloads||{}}}return{featureFlags:u,featureFlagPayloads:d}}groupIdentify({groupType:e,groupKey:t,properties:n,distinctId:r,disableGeoip:i}){super.groupIdentifyStateless(e,t,n,{disableGeoip:i},r)}async reloadFeatureFlags(){await this.featureFlagsPoller?.loadFeatureFlags(!0)}withContext(e,t,n){return this.context?this.context.run(e,t,n):t()}getContext(){return this.context?.get()}async _shutdown(e){return this.featureFlagsPoller?.stopPoller(e),this.errorTracking.shutdown(),super._shutdown(e)}async _requestRemoteConfigPayload(e){if(!this.options.personalApiKey)return;let t=`${this.host}/api/projects/@current/feature_flags/${e}/remote_config?token=${encodeURIComponent(this.apiKey)}`,n={method:`GET`,headers:{...this.getCustomHeaders(),"Content-Type":`application/json`,Authorization:`Bearer ${this.options.personalApiKey}`}},r=null;if(this.options.requestTimeout&&typeof this.options.requestTimeout==`number`){let e=new AbortController;r=W$(()=>{e.abort()},this.options.requestTimeout),n.signal=e.signal}try{return await this.fetch(t,n)}catch(e){this._events.emit(`error`,e);return}finally{r&&clearTimeout(r)}}extractPropertiesFromEvent(e,t){if(!e)return{personProperties:{},groupProperties:{}};let n={},r={};for(let[i,a]of Object.entries(e))if(Ukt(a)&&t&&i in t){let e={};for(let[t,n]of Object.entries(a))e[String(t)]=String(n);r[String(i)]=e}else n[String(i)]=String(a);return{personProperties:n,groupProperties:r}}async getFeatureFlagsForEvent(e,t,n,r){let i=r?.personProperties||{},a=r?.groupProperties||{},o=r?.flagKeys;if(r?.onlyEvaluateLocally??!1){if((this.featureFlagsPoller?.featureFlags?.length||0)>0){let r={};for(let[e,n]of Object.entries(t||{}))r[e]=String(n);return await this.getAllFlags(e,{groups:r,personProperties:i,groupProperties:a,disableGeoip:n,onlyEvaluateLocally:!0,flagKeys:o})}return{}}if((this.featureFlagsPoller?.featureFlags?.length||0)>0){let r={};for(let[e,n]of Object.entries(t||{}))r[e]=String(n);return await this.getAllFlags(e,{groups:r,personProperties:i,groupProperties:a,disableGeoip:n,onlyEvaluateLocally:!0,flagKeys:o})}return(await super.getFeatureFlagsStateless(e,t,i,a,n)).flags}addLocalPersonAndGroupProperties(e,t,n,r){let i={distinct_id:e,...n||{}},a={};if(t)for(let e of Object.keys(t))a[e]={$group_key:t[e],...r?.[e]||{}};return{allPersonProperties:i,allGroupProperties:a}}captureException(e,t,n){let r=/* @__PURE__ */ Error(`PostHog syntheticException`);this.addPendingPromise(Z$.buildEventMessage(e,{syntheticException:r},t,n).then(e=>this.capture(e)))}async captureExceptionImmediate(e,t,n){let r=/* @__PURE__ */ Error(`PostHog syntheticException`);this.addPendingPromise(Z$.buildEventMessage(e,{syntheticException:r},t,n).then(e=>this.captureImmediate(e)))}async prepareEventMessage(e){let{distinctId:t,event:n,properties:r,groups:i,sendFeatureFlags:a,timestamp:o,disableGeoip:s,uuid:c}=e,l=this.context?.get(),u=t||l?.distinctId,d={...l?.properties||{},...r||{}};u||(u=z$(),d.$process_person_profile=!1),l?.sessionId&&!d.$session_id&&(d.$session_id=l.sessionId);let f=this._runBeforeSend({distinctId:u,event:n,properties:d,groups:i,sendFeatureFlags:a,timestamp:o,disableGeoip:s,uuid:c});if(!f)return Promise.reject(null);let p=await Promise.resolve().then(async()=>{if(a){let e=typeof a==`object`?a:void 0;return await this.getFeatureFlagsForEvent(f.distinctId,i,s,e)}return f.event,{}}).then(e=>{let t={};if(e)for(let[n,r]of Object.entries(e))t[`$feature/${n}`]=r;let n=Object.keys(e||{}).filter(t=>e?.[t]!==!1).sort();return n.length>0&&(t.$active_feature_flags=n),t}).catch(()=>({})).then(e=>({...e,...f.properties||{},$groups:f.groups||i}));return f.event===`$pageview`&&this.options.__preview_capture_bot_pageviews&&typeof p.$raw_user_agent==`string`&&Akt(p.$raw_user_agent,this.options.custom_blocked_useragents||[])&&(f.event=`$bot_pageview`,p.$browser_type=`bot`),{distinctId:f.distinctId,event:f.event,properties:p,options:{timestamp:f.timestamp,disableGeoip:f.disableGeoip,uuid:f.uuid}}}_runBeforeSend(e){let t=this.options.before_send;if(!t)return e;let n=Array.isArray(t)?t:[t],r=e;for(let t of n){if(r=t(r),!r)return this._logger.info(`Event '${e.event}' was rejected in beforeSend function`),null;if(!r.properties||Object.keys(r.properties).length===0){let e=`Event '${r.event}' has no properties after beforeSend function, this is likely an error.`;this._logger.warn(e)}}return r}},sjt=class{constructor(){this.storage=new Er}get(){return this.storage.getStore()}run(e,t,n){if(n?.fresh===!0)return this.storage.run(e,t);{let n=this.get()||{},r={distinctId:e.distinctId??n.distinctId,sessionId:e.sessionId??n.sessionId,properties:{...n.properties||{},...e.properties||{}}};return this.storage.run(r,t)}}};const cjt=`posthog-node`;function ljt(e,{organization:t,projectId:n,prefix:r,severityAllowList:i=[`error`],sendExceptionsToPostHog:a=!0}={}){return o=>{if(!(i===`*`||i.includes(o.level)))return o;o.tags||={};let s=o.tags[ujt.POSTHOG_ID_TAG];if(s===void 0)return o;let c=e.options.host??`https://us.i.posthog.com`,l=new URL(`/project/${e.apiKey}/person/${s}`,c).toString();o.tags[`PostHog Person URL`]=l;let u=o.exception?.values||[],d=u.map(e=>({...e,stacktrace:e.stacktrace?{...e.stacktrace,type:`raw`,frames:(e.stacktrace.frames||[]).map(e=>({...e,platform:`node:javascript`}))}:void 0})),f={$exception_message:u[0]?.value||o.message,$exception_type:u[0]?.type,$exception_level:o.level,$exception_list:d,$sentry_event_id:o.event_id,$sentry_exception:o.exception,$sentry_exception_message:u[0]?.value||o.message,$sentry_exception_type:u[0]?.type,$sentry_tags:o.tags};return t&&n&&(f.$sentry_url=(r||`https://sentry.io/organizations/`)+t+`/issues/?project=`+n+`&query=`+o.event_id),a&&e.capture({event:`$exception`,distinctId:s,properties:f}),o}}var ujt=class{static#e=this.POSTHOG_ID_TAG=`posthog_distinct_id`;constructor(e,t,n,r,i){this.name=cjt,this.name=cjt,this.setupOnce=function(a,o){let s=o()?.getClient()?.getDsn()?.projectId;a(ljt(e,{organization:t,projectId:s,prefix:n,severityAllowList:r,sendExceptionsToPostHog:i??!0}))}}};Z$.errorPropertiesBuilder=new uAt([new EAt,new bAt,new TAt,new SAt,new DAt],yAt(`node:javascript`,pAt),[gkt(),AAt]);var djt=class extends ojt{getLibraryId(){return`posthog-node`}initializeContext(){return new sjt}},fjt=function(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})};const pjt=1e4;let t1=null,n1=Promise.resolve();function mjt(){return t1||=new djt(`phc_eNuN6Ojnk9O7uWfC17z12AK85fNR0BY6IiGVy0Gfwzw`,{host:`https://ph.mintlify.com`}),t1}function r1(e){n1=Promise.allSettled([n1,e]).then(()=>void 0)}function i1(){return fjt(this,void 0,void 0,function*(){try{yield Promise.race([n1,new Promise(e=>{setTimeout(e,pjt).unref()})])}catch{}if(t1){try{yield Promise.race([t1.shutdown(),new Promise(e=>{setTimeout(e,pjt).unref()})])}catch{}t1=null}})}var a1=function(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})};const o1=process.cwd(),hjt=e=>a1(void 0,void 0,void 0,function*(){let t=typeof e.port==`number`?e.port:3e3;if(t===(yield(0,ekt.default)(t)))return t;for(let e=t+1;e<t+10;e++)if(jH((0,z.jsx)(yH,{message:`port ${e-1} is already in use. trying ${e} instead`})),e===(yield(0,ekt.default)(e)))return e}),gjt=()=>a1(void 0,void 0,void 0,function*(){let e=process.version;e.charAt(0)===`v`&&(e=e.slice(1));let t=e.split(`.`),n=parseInt(t[0],10),r=parseInt(t[1],10);n===25&&(jH((0,z.jsx)(CH,{message:`mintlify is not supported on node 25 (current version ${e}). Please switch to an LTS node version.`})),yield f1(1)),(n<20||n===20&&r<17)&&(jH((0,z.jsx)(CH,{message:`mintlify requires node 20.17 or higher. Please upgrade to an LTS node version.`})),yield f1(1))}),_jt=()=>a1(void 0,void 0,void 0,function*(){return!!(yield vF(o1,`mint`))}),vjt=e=>a1(void 0,void 0,void 0,function*(){let t=gt.resolve(e),{root:n}=gt.parse(t),r=t;for(;r!==n;){if((yield vF(r,`docs`))||(yield vF(r,`mint`)))return r;r=gt.dirname(r)}return t}),yjt=()=>a1(void 0,void 0,void 0,function*(){let e=gt.join(o1,`docs.json`);if(!(yield k$.default.pathExists(e))){jH((0,z.jsx)(yH,{message:`new docs.json file is available`}));let{action:e}=yield pkt.prompt([{type:`list`,name:`action`,message:`would you like to upgrade your mint.json to docs.json?`,choices:[{name:`upgrade (migrate from mint.json to docs.json)`,value:`upgrade`},{name:`continue (use existing mint.json)`,value:`continue`}]}]);e===`continue`&&jH((0,z.jsx)(yH,{message:`proceeding with the existing mint.json...`})),e===`upgrade`&&(jH((0,z.jsx)(xH,{message:`upgrading docs.json...`})),yield xjt())}}),bjt=()=>a1(void 0,void 0,void 0,function*(){if(!(yield _jt()))return;let e=gt.join(o1,`docs.json`);(yield k$.default.pathExists(e))||(jH((0,z.jsx)(SH,{message:`Legacy mint.json detected, auto-upgrading to docs.json`})),jH((0,z.jsx)(xH,{message:`upgrading mint.json to docs.json...`})),yield xjt())}),xjt=()=>a1(void 0,void 0,void 0,function*(){try{let e=gt.join(o1,`mint.json`),t=gt.join(o1,`docs.json`),n=yield Hn.readFile(e,`utf8`),r=(yield EF.validateConfigJsonString(n)).data,i=ff(r,{shouldUpgradeTheme:!0});yield Hn.writeFile(t,JSON.stringify(i,null,2)),IH(),jH((0,z.jsx)(bH,{message:`mint.json file has been upgraded to docs.json.`}))}catch(e){IH(),jH((0,z.jsx)(CH,{message:e instanceof Error?e.message:`an unknown error occurred`}))}}),Sjt=pt(import.meta.url),Cjt=()=>{try{return!Gt(import.meta.url).split(gt.sep).includes(`node_modules`)}catch{return!1}},wjt=e=>{try{let t=Sjt.resolve(`${e}/package.json`),n=JSON.parse(kn(t,`utf8`));return typeof n.version==`string`?n.version:void 0}catch{return}},s1=e=>(e===void 0&&(e=process.env.MINTLIFY_PACKAGE_NAME??`mint`),process.env.CLI_TEST_MODE===`true`?`test-cli`:Cjt()?ai:wjt(e)),c1=e=>(e===void 0&&(e=process.env.MINTLIFY_PACKAGE_NAME??`mint`),{cli:s1(e),client:Hut().trim()}),l1={shell:process.platform===`win32`},Tjt=/^(@[a-z0-9~-][a-z0-9._~-]*\/)?[a-z0-9~-][a-z0-9._~-]*$/,u1=e=>{if(!Tjt.test(e))throw Error(`Invalid package name: ${e}`)},Ejt=e=>(u1(e),Mr(`npm`,[`view`,e,`version`,`--silent`],Object.assign({encoding:`utf-8`,stdio:[`pipe`,`pipe`,`pipe`]},l1)).trim()),Djt=()=>{let e=[`No utility classes were detected`,`https://tailwindcss.com/docs/content-configuration`,`DeprecationWarning`],t=console.error;console.error=(...n)=>{let r=n.join(` `);e.some(e=>r.includes(e))||t.apply(console,n)};let n=console.warn;console.warn=(...t)=>{let r=t.join(` `);e.some(e=>r.includes(e))||n.apply(console,t)}},Ojt=e=>a1(void 0,void 0,void 0,function*(){let{resolvedPath:t}=_f(e,o1),n=yield Hn.readFile(t,`utf-8`);return Re.load(n)}),d1=e=>e instanceof Error?e.message:String(e),f1=e=>a1(void 0,void 0,void 0,function*(){yield new Promise(e=>setTimeout(e,50)),yield i1(),process.exit(e)}),p1=pr(jr);function m1(){return!process.stdin.isTTY||I$()!==void 0}const kjt=e=>a1(void 0,[e],void 0,function*({packageName:e}){u1(e);try{let{stdout:t}=yield p1(`which`,[e]);return t.includes(`pnpm`)?`pnpm`:`npm`}catch{return`npm`}});var Ajt=function(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})};const jjt=()=>Ajt(void 0,void 0,void 0,function*(){try{yield yjt();let e=yield vF(o1,`docs`),t=yield vF(o1,`mint`);if(!e&&!t)return jH((0,z.jsx)(CH,{message:`No configuration file found. Please run this command from a directory with a mint.json or docs.json file.`})),1;let n=yield bF(o1,e?`docs`:`mint`);if(!n?.colors)return jH((0,z.jsx)(SH,{message:`No colors section found in configuration file`})),0;let{colors:r,navigation:i}=n,{lightHex:a,darkHex:o}=Nce(n),s=sSt(r,{lightHex:a,darkHex:o},i),c=(e,t,n=``)=>{if(!e)return;let{recommendation:r,message:i}=e,a=r===`pass`?`PASS`:r===`warning`?`WARN`:`FAIL`,o=r===`pass`?`green`:r===`warning`?`yellow`:`red`;jH((0,z.jsxs)(gH,{children:[(0,z.jsxs)(gH,{bold:n===``,children:[n,t,`:`,` `]}),(0,z.jsxs)(gH,{color:o,children:[a,` `,i]})]}))};jH((0,z.jsx)(gH,{bold:!0,color:`cyan`,children:`Checking color accessibility...`})),jH((0,z.jsx)(gH,{})),c(s.primaryContrast,`Primary Color (${r.primary}) vs Light Background`),c(s.lightContrast,`Light Color (${r.light}) vs Dark Background`),c(s.darkContrast,`Dark Color (${r.dark}) vs Dark Background`),c(s.darkOnLightContrast,`Dark Color (${r.dark}) vs Light Background`);let l=s.anchorResults.filter(e=>e.lightContrast||e.darkContrast);if(l.length>0){jH((0,z.jsx)(gH,{})),jH((0,z.jsx)(gH,{bold:!0,color:`cyan`,children:`Navigation Anchors:`}));for(let e of l)jH((0,z.jsxs)(gH,{bold:!0,children:[` `,e.name,`:`]})),c(e.lightContrast,`Light variant vs Light Background`,` `),c(e.darkContrast,`Dark variant vs Dark Background`,` `)}jH((0,z.jsx)(gH,{}));let u=s.overallScore===`pass`?`PASS`:s.overallScore===`warning`?`WARN`:`FAIL`,d=s.overallScore===`pass`?`green`:s.overallScore===`warning`?`yellow`:`red`,f=s.overallScore===`pass`?`All colors meet accessibility standards!`:s.overallScore===`warning`?`Some colors could be improved for better accessibility`:`Some colors fail accessibility standards and should be updated`;return jH((0,z.jsx)(gH,{children:(0,z.jsxs)(gH,{bold:!0,color:d,children:[`Overall Assessment: `,u,` `,f]})})),+(s.overallScore===`fail`)}catch(e){return jH((0,z.jsx)(CH,{message:`Accessibility check failed: ${e instanceof Error?e.message:`Unknown error`}`})),1}});var h1=function(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})};const g1=`mintlify`,_1=`access_token`,v1=`refresh_token`,y1=`user_email`;function b1(){return h1(this,void 0,void 0,function*(){try{let e=yield import(`keytar`);return e.default??e}catch{throw Error(`keytar is required for credential storage but is not installed. Install it with: npm install keytar`)}})}function x1(e,t,n){return h1(this,void 0,void 0,function*(){let r=yield b1();yield Promise.all([r.setPassword(g1,_1,e),r.setPassword(g1,v1,t)]);try{n===null?yield r.deletePassword(g1,y1):n!==void 0&&(yield r.setPassword(g1,y1,n))}catch{}})}function S1(){return h1(this,void 0,void 0,function*(){return(yield b1()).getPassword(g1,_1)})}function Mjt(){return h1(this,void 0,void 0,function*(){return(yield b1()).getPassword(g1,v1)})}function Njt(){return h1(this,void 0,void 0,function*(){return(yield b1()).getPassword(g1,y1)})}function Pjt(e){return h1(this,void 0,void 0,function*(){yield(yield b1()).setPassword(g1,y1,e)})}function Fjt(){return h1(this,void 0,void 0,function*(){let e=yield b1();yield Promise.all([e.deletePassword(g1,_1),e.deletePassword(g1,v1),e.deletePassword(g1,y1).catch(()=>!1)])})}const Ijt=mt.homedir(),C1=gt.join(Ijt,`.config`,`mintlify`),Ljt=gt.join(C1,`config.json`),Rjt=process.env.CLI_TEST_MODE===`true`||s1()==ai,w1=process.env.MINTLIFY_API_URL??(Rjt?`http://localhost:5000`:`https://leaves.mintlify.com`),T1=process.env.MINTLIFY_DASHBOARD_URL??(Rjt?`http://localhost:3000`:`https://app.mintlify.com`),E1=`${w1}/api/oauth-token/cli`;function D1(e){if(e)try{let t=e.split(`.`)[1];if(!t)return;let n=JSON.parse(Buffer.from(t,`base64url`).toString(`utf8`));return typeof n.email==`string`&&n.email.length>0?n.email:void 0}catch{return}}var zjt=function(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})};let O1=null;function Bjt(){return zjt(this,void 0,void 0,function*(){return O1||(O1=Vjt().finally(()=>{O1=null}),O1)})}function Vjt(){return zjt(this,void 0,void 0,function*(){try{let e=yield Mjt();if(!e)return null;let t=yield fetch(E1,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({grant_type:`refresh_token`,refresh_token:e})});if(!t.ok)return null;let n=yield t.json().catch(()=>null);return!n?.access_token||!n.refresh_token?null:(yield x1(n.access_token,n.refresh_token,D1(n.id_token)),n.access_token)}catch{return null}})}var Hjt=function(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})};function Ujt(){return Hjt(this,void 0,void 0,function*(){try{return yield S1()}catch{return null}})}function k1(e,t){return Hjt(this,void 0,void 0,function*(){let n=yield Ujt(),r=process.env.MINTLIFY_SESSION_TOKEN,i=n??r;if(!i)throw Error("Not authenticated. Run `mint login` to authenticate.");let a=n=>fetch(e,Object.assign(Object.assign({},t),{headers:Object.assign(Object.assign({},t?.headers),{Authorization:`Bearer ${n}`})})),o=yield a(i);if(o.status!==401)return o;if(n){let e=yield Bjt();if(e)return a(e)}return r&&i!==r?a(r):o})}var A1=function(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})};const Wjt=Ne({registrationId:He(),subdomain:He()});function Gjt(e){let t=Wjt.safeParse(j1().agentSites?.[e]);return t.success?t.data:void 0}function Kjt(e,t){return A1(this,void 0,void 0,function*(){yield M1({agentSites:Object.assign(Object.assign({},j1().agentSites),{[e]:t})})})}function j1(){try{let e=qt.readFileSync(Ljt,`utf-8`);return JSON.parse(e)}catch{return{}}}function M1(e){return A1(this,void 0,void 0,function*(){yield(0,k$.ensureDir)(C1);let t=j1();qt.writeFileSync(Ljt,JSON.stringify(Object.assign(Object.assign({},t),e),null,2))})}function N1(){return process.env.CLI_TEST_MODE===`true`||process.env.MINTLIFY_TELEMETRY_DISABLED===`1`||process.env.DO_NOT_TRACK===`1`?!1:j1().telemetryEnabled!==!1}function qjt(e){return A1(this,void 0,void 0,function*(){yield M1({telemetryEnabled:e})})}function P1(e){return j1()[e]}function F1(e,t){return A1(this,void 0,void 0,function*(){yield M1({[e]:t})})}function Jjt(e){return A1(this,void 0,void 0,function*(){yield M1({[e]:void 0})})}function Yjt(e){return j1().publishPromptShown?.includes(e)??!1}function Xjt(e){return A1(this,void 0,void 0,function*(){yield M1({publishPromptShown:[...j1().publishPromptShown??[],e]})})}var I1=function(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})};const L1=Ne({user:Ne({email:He()}),org:Ne({name:He()}),subdomains:Ke(He()).default([])});function Zjt(e){return I1(this,void 0,void 0,function*(){try{let t=yield fetch(`${w1}/api/cli/status`,{headers:{Authorization:`Bearer ${e}`}});if(!t.ok)return null;let n=yield t.json().catch(()=>null),r=L1.safeParse(n);return r.success?r.data:null}catch{return null}})}function Qjt(e){return I1(this,void 0,void 0,function*(){let t;try{t=yield k1(`${w1}/api/cli/status`,{signal:e})}catch(e){let t=e instanceof Error?e.message:String(e);return/not authenticated/i.test(t)?{ok:!1,reason:`unauthenticated`}:{ok:!1,reason:`unreachable`,detail:t}}if(t.status===401||t.status===403)return{ok:!1,reason:`unauthenticated`};if(!t.ok)return{ok:!1,reason:`unreachable`,detail:`HTTP ${t.status}`};let n=L1.safeParse(yield t.json().catch(()=>null));return n.success?{ok:!0,status:n.data}:{ok:!1,reason:`invalid`}})}function R1(e){return I1(this,void 0,void 0,function*(){return(yield Zjt(e))?.subdomains??[]})}function $jt(){return I1(this,void 0,void 0,function*(){if(!((yield S1().catch(()=>null))??process.env.MINTLIFY_SESSION_TOKEN))jH((0,z.jsx)(CH,{message:"not logged in. Run `mint login` to authenticate."}));else try{let e=yield k1(`${w1}/api/cli/status`);if(!e.ok){jH((0,z.jsx)(CH,{message:"not logged in. Run `mint login` to authenticate."}));return}let t=yield e.json().catch(()=>null),n=L1.safeParse(t);if(!n.success){jH((0,z.jsx)(CH,{message:`unexpected response from server. please try again.`}));return}let{user:r,org:i,subdomains:a}=n.data,o=s1(),s=P1(`subdomain`),c=(s&&a.includes(s)?s:a[0])??null;c&&c!==s&&(yield F1(`subdomain`,c).catch(()=>void 0)),jH((0,z.jsxs)(hH,{flexDirection:`column`,paddingY:1,children:[o&&(0,z.jsxs)(hH,{children:[(0,z.jsx)(hH,{minWidth:16,children:(0,z.jsx)(gH,{dimColor:!0,children:`Version`})}),(0,z.jsx)(gH,{children:o})]}),(0,z.jsxs)(hH,{children:[(0,z.jsx)(hH,{minWidth:16,children:(0,z.jsx)(gH,{dimColor:!0,children:`Email`})}),(0,z.jsx)(gH,{children:r.email})]}),(0,z.jsxs)(hH,{children:[(0,z.jsx)(hH,{minWidth:16,children:(0,z.jsx)(gH,{dimColor:!0,children:`Organization`})}),(0,z.jsx)(gH,{children:i.name})]}),c&&(0,z.jsxs)(hH,{children:[(0,z.jsx)(hH,{minWidth:16,children:(0,z.jsx)(gH,{dimColor:!0,children:`Subdomain`})}),(0,z.jsx)(gH,{children:c})]})]}))}catch{jH((0,z.jsx)(CH,{message:`unexpected response from server. please try again.`}))}})}var eMt=function(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})};const tMt=5e3,nMt=/^[a-z0-9]([a-z0-9-]*[a-z0-9])?(\.[a-z0-9]([a-z0-9-]*[a-z0-9])?)+$/i;function rMt(e,t){return eMt(this,void 0,void 0,function*(){if(!nMt.test(e)){jH((0,z.jsx)(CH,{message:`invalid domain "${e}". Expected a bare hostname, e.g. docs.example.com`}));return}let n=xJe(t?.trim());if(n){let e=TJe(n);if(e){jH((0,z.jsx)(CH,{message:`invalid base path "${t}": ${e}`}));return}}let r=yield S1();if(!r){jH((0,z.jsx)(CH,{message:"not logged in. Run `mint login` to authenticate."}));return}let i=yield R1(r),a=P1(`subdomain`),o=a&&i.includes(a)?a:i[0];if(!o){jH((0,z.jsx)(CH,{message:"no subdomain found. Run `mint status` to check your account."}));return}try{let t=yield k1(`${w1}/api/cli/deployment/custom-domain/${o}/${e}`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({basePath:n?`/docs`:``})});if(!t.ok){let e=yield t.json().catch(()=>({}));jH((0,z.jsx)(CH,{message:`could not add domain: ${e.error??`unknown error`}`}));return}}catch{jH((0,z.jsx)(CH,{message:`could not reach the server`}));return}let s=!1,c=!1;if(n){jH((0,z.jsx)(xH,{message:`setting base path to ${n}...`}));try{let e=yield k1(`${w1}/api/cli/deployment/base-path/${o}`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({basePath:n})});if(IH(),e.ok){let t=yield e.json().catch(()=>({}));s=!0,c=!!t.pendingBasePathUpdate}else{let t=yield e.json().catch(()=>({})),n=t.issues?.[0]?.message??t.error??`unknown error`;jH((0,z.jsx)(CH,{message:`domain added, but base path was not saved: ${n}`}))}}catch{IH(),jH((0,z.jsx)(CH,{message:`domain added, but base path was not saved: could not reach the server`}))}}jH((0,z.jsx)(xH,{message:`waiting for DNS records to generate (up to ${2*tMt/1e3}s)...`}));let l=[],u=!1;try{for(let t=0;t<3;t++){let n=yield k1(`${w1}/api/cli/deployment/custom-domain/${o}/${e}`);if(n.ok){l=(yield n.json()).cloudflare?.dnsRecords??[];let e=l.some(e=>e.value===`loading`);if(l.length>0&&!e){u=!0;break}}t<2&&(yield new Promise(e=>setTimeout(e,tMt)))}}catch{IH(),jH((0,z.jsx)(CH,{message:`domain added, but could not fetch DNS records`}));return}IH();let d=l.filter(e=>e.type===`TXT`&&e.value!==`loading`),f=c?`domain ${e} added; base path ${n} queued for the next deploy`:s?`domain ${e} added (serving at ${n})`:`domain ${e} added`;jH((0,z.jsx)(bH,{message:f})),jH((0,z.jsxs)(hH,{flexDirection:`column`,gap:1,paddingY:1,children:[(0,z.jsx)(gH,{bold:!0,children:`Add these DNS records with your domain provider:`}),(0,z.jsxs)(hH,{flexDirection:`column`,paddingLeft:3,children:[d.map(t=>(0,z.jsxs)(gH,{children:[`TXT `,bJe(t.domain,e),` → `,t.value]},t.domain)),(0,z.jsxs)(gH,{children:[`CNAME `,bJe(e,e),` → `,`cname.mintlify.builders`]})]}),(0,z.jsx)(gH,{dimColor:!0,children:`Add the TXT records first; add the CNAME once they're validated.`}),c&&(0,z.jsx)(gH,{dimColor:!0,children:`The base path takes effect when that deploy finishes; the current path stays up until then.`}),s&&(0,z.jsxs)(gH,{dimColor:!0,children:[`The CNAME sends all paths on `,e,` to Mintlify. Only add it if this domain hosts nothing else. Otherwise, set up a reverse proxy for `,n,`: https://www.mintlify.com/docs/deploy/docs-subpath`]}),!u&&(0,z.jsx)(gH,{dimColor:!0,children:`Some TXT records are still being generated. Check the dashboard in a moment for the rest.`})]}))})}var iMt=function(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})};const aMt=Ne({code:He().optional(),error:He().optional()});var oMt=class extends Error{constructor(e,t){super(`Agent request failed (HTTP ${e}).${t?` Code: ${t}.`:``}`),this.status=e,this.code=t}};function z1(e,t){return iMt(this,void 0,void 0,function*(){try{let n=AbortSignal.timeout(3e4),r=t?.signal?AbortSignal.any([t.signal,n]):n;return yield fetch(e,Object.assign(Object.assign({},t),{redirect:`error`,signal:r}))}catch{throw Error(`Could not reach the agent service. Retry the same command.`)}})}function B1(e,t){return iMt(this,void 0,void 0,function*(){let n=yield e.json().catch(()=>null);if(!e.ok){let t=aMt.safeParse(n),r=t.success?t.data.code??t.data.error:void 0;throw new oMt(e.status,r?.match(/^[a-z_]{1,80}$/)?.[0])}let r=t.safeParse(n);if(!r.success)throw Error(`The agent service returned an unexpected response.`);return r.data})}var V1=function(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})};const sMt=Ne({authorization_servers:Ke(I()).min(1)}),cMt=Ne({issuer:I(),token_endpoint:I(),agent_auth:Ne({identity_endpoint:I(),claim_endpoint:I(),identity_types_supported:Ke(He())})}),lMt=Ne({assertion:He().min(1)}),uMt=Ne({id:He().min(1),identity:lMt,claim:Ne({token:He().min(1)})}),dMt=Ne({access_token:He().min(1),expires_in:Ae().positive(),token_type:He().regex(/^bearer$/i)}),fMt=ke(`identityType`,[Ne({registrationId:He(),identityType:nt(`anonymous`)}),Ne({registrationId:He(),identityType:nt(`user_bound`),userId:He(),orgId:He()})]);function H1(e){return V1(this,void 0,void 0,function*(){let t=(yield B1(yield z1(`${e}/api/agent/.well-known/oauth-protected-resource`),sMt)).authorization_servers[0];if(!t||new URL(t).protocol!==`https:`)throw Error(`Agent authentication requires an HTTPS issuer.`);let n=yield B1(yield z1(`${t.replace(/\/$/,``)}/.well-known/oauth-authorization-server`),cMt),r=new URL(t).origin;if([n.issuer,n.token_endpoint,n.agent_auth.identity_endpoint,n.agent_auth.claim_endpoint].some(e=>new URL(e).origin!==r))throw Error(`Agent authentication endpoints do not match the configured issuer.`);return n})}function pMt(e){return V1(this,void 0,void 0,function*(){if(!e.agent_auth.identity_types_supported.includes(`anonymous`))throw Error(`Anonymous registration is not enabled for this environment.`);let t=yield B1(yield z1(e.agent_auth.identity_endpoint,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({type:`anonymous`})}),uMt);return{registrationId:t.id,issuer:e.issuer,assertion:t.identity.assertion,claimToken:t.claim.token}})}function U1(e,t){return V1(this,void 0,void 0,function*(){if(new URL(t.issuer).origin!==new URL(e.issuer).origin)throw Error(`Saved agent credentials belong to another issuer.`);if(t.accessToken&&(t.accessTokenExpiresAt??0)>Date.now()+3e4)return Object.assign(Object.assign({},t),{accessToken:t.accessToken});let n=yield B1(yield z1(e.token_endpoint,{method:`POST`,body:new URLSearchParams({grant_type:`urn:ietf:params:oauth:grant-type:jwt-bearer`,assertion:t.assertion})}),dMt);return Object.assign(Object.assign({},t),{accessToken:n.access_token,accessTokenExpiresAt:Date.now()+n.expires_in*1e3})})}function mMt(e,t){return V1(this,void 0,void 0,function*(){return B1(yield z1(`${e}/api/agent/identity`,{headers:{Authorization:`Bearer ${t}`}}),fMt)})}var W1=function(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})},hMt=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols==`function`)for(var i=0,r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]]);return n};const G1=`mintlify-agent`,K1=()=>It.join(C1,`agent-credentials.json`),gMt=Ne({registrationId:He().min(1),issuer:I(),assertion:He().min(1),claimToken:He().min(1),claimVerified:Qe().optional(),accessToken:He().min(1).optional(),accessTokenExpiresAt:Ae().optional()});function _Mt(e,t){return`project:${Mn(`sha256`).update(JSON.stringify([new URL(e).origin,It.resolve(t)])).digest(`hex`)}`}function vMt(e,t){return`${new URL(e).origin}:${t}`}function q1(){return W1(this,void 0,void 0,function*(){try{return Je(He(),He()).parse(JSON.parse(yield Hn.readFile(K1(),`utf-8`)))}catch{return{}}})}function yMt(e){return W1(this,void 0,void 0,function*(){yield Hn.mkdir(C1,{recursive:!0});let t=`${K1()}.${process.pid}.tmp`;yield Hn.writeFile(t,JSON.stringify(e,null,2),{mode:384}),yield Hn.chmod(t,384),yield Hn.rename(t,K1())})}function bMt(e){return W1(this,void 0,void 0,function*(){let t;try{let t=yield(yield b1()).getPassword(G1,e);if(t)return t}catch(e){t=e}let n=(yield q1())[e];if(n)return n;if(t)throw t;return null})}function xMt(e,t){return W1(this,void 0,void 0,function*(){try{yield(yield b1()).setPassword(G1,e,t)}catch{yield yMt(Object.assign(Object.assign({},yield q1()),{[e]:t})),yield b1().then(t=>t.deletePassword(G1,e)).catch(()=>{});return}let n=yield q1(),r=e,i=n[r],a=hMt(n,[typeof r==`symbol`?r:r+``]);i&&(yield yMt(a).catch(()=>{}))})}function SMt(e,t){return W1(this,void 0,void 0,function*(){let n=yield bMt(_Mt(e,t));if(!n)return null;let r=yield bMt(vMt(e,n));if(!r)throw Error(`Saved agent credentials are missing. Use --new to create another site.`);let i=gMt.parse(JSON.parse(r));if(i.registrationId!==n)throw Error(`Saved agent credentials do not match this project.`);return i})}function CMt(e,t,n){return W1(this,void 0,void 0,function*(){let r=gMt.parse(n);yield xMt(vMt(e,r.registrationId),JSON.stringify(r)),yield xMt(_Mt(e,t),r.registrationId)})}const J1=gt.join(C1,`anonymous-id`),wMt=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;function Y1(){try{let e=qt.readFileSync(J1,`utf-8`).trim();if(wMt.test(e))return e}catch{}return null}function TMt(){let e=jt.createHash(`sha256`);e.update(mt.hostname()),e.update(`\0`),e.update(mt.homedir()),e.update(`\0`),e.update(process.env.USER??process.env.USERNAME??``);let t=e.digest(`hex`).slice(0,32);return`${t.slice(0,8)}-${t.slice(8,12)}-${t.slice(12,16)}-${t.slice(16,20)}-${t.slice(20,32)}`}function EMt(e){qt.mkdirSync(gt.dirname(J1),{recursive:!0}),qt.writeFileSync(J1,e,{flag:`wx`})}let DMt=!1;function OMt(){return kMt(),DMt}function kMt(){let e=Y1();if(e)return e;let t=jt.randomUUID();try{return EMt(t),DMt=!0,Y1()??t}catch(e){if(e.code===`EEXIST`){let e=Y1();if(e)return e;try{qt.writeFileSync(J1,t)}catch{}return Y1()??t}}let n=TMt();try{qt.mkdirSync(gt.dirname(J1),{recursive:!0}),qt.writeFileSync(J1,n)}catch{}return Y1()??n}const AMt=gt.join(C1,`telemetry-session.json`);let X1;function jMt(e){let t=jt.randomBytes(16);t.writeUIntBE(e,0,6),t[6]=t[6]&15|112,t[8]=t[8]&63|128;let n=t.toString(`hex`);return`${n.slice(0,8)}-${n.slice(8,12)}-${n.slice(12,16)}-${n.slice(16,20)}-${n.slice(20)}`}function MMt(){try{let{id:e,lastSeenAt:t}=JSON.parse(qt.readFileSync(AMt,`utf-8`));return typeof e==`string`&&typeof t==`number`?{id:e,lastSeenAt:t}:null}catch{return null}}function NMt(e=Date.now()){if(!X1){let t=MMt();X1=t&&e-t.lastSeenAt<18e5?t.id:jMt(e)}try{qt.mkdirSync(C1,{recursive:!0}),qt.writeFileSync(AMt,JSON.stringify({id:X1,lastSeenAt:e}))}catch{}return X1}var Z1=function(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})};function Q1(){let e=I$();return{os:mt.platform(),arch:mt.arch(),node_version:process.version,is_ai_agent:e!==void 0,ai_agent:e,is_ci:hkt(),is_tty:!!process.stdin.isTTY,is_first_run:OMt(),$session_id:NMt()}}function $1(e,t){return Z1(this,void 0,void 0,function*(){yield Promise.race([mjt().captureImmediate({distinctId:kMt(),event:e,properties:t}).catch(()=>{}),new Promise(e=>{setTimeout(e,1e4).unref()})])})}function PMt(){return Z1(this,void 0,void 0,function*(){try{let[e,t]=yield Promise.all([S1(),Njt().catch(()=>null)]);if(!e)return{loggedIn:!1,email:null};if(t)return{loggedIn:!0,email:t};let n=yield Qjt(AbortSignal.timeout(3e3));if(!n.ok)return{loggedIn:!0,email:null};let r=n.status.user.email;return yield Pjt(r).catch(()=>{}),{loggedIn:!0,email:r}}catch{return{loggedIn:!1,email:null}}})}function e0(){return Z1(this,void 0,void 0,function*(){let{loggedIn:e,email:t}=yield PMt();return Object.assign({is_logged_in:e},t?{email:t,$set:{email:t}}:{})})}function FMt(e){return Z1(this,arguments,void 0,function*({command:e,cliVersion:t,subdomain:n}){if(!N1())return;let r=Z1(this,void 0,void 0,function*(){try{yield $1(`cli.command.executed`,Object.assign(Object.assign(Object.assign({command:e,cli_version:t},Q1()),yield e0()),{subdomain:n}))}catch{}});r1(r),yield r})}function t0(e,t){return Z1(this,void 0,void 0,function*(){if(!N1())return;let n=Z1(this,void 0,void 0,function*(){try{let{cli:n}=c1();yield $1(e,Object.assign(Object.assign(Object.assign(Object.assign({},t),{cli_version:n}),Q1()),yield e0()))}catch{}});r1(n),yield n})}function IMt(){return Z1(this,void 0,void 0,function*(){return t0(`cli.login.attempted`)})}function LMt(){return Z1(this,void 0,void 0,function*(){return t0(`cli.login.succeeded`)})}function RMt(e){return Z1(this,void 0,void 0,function*(){return t0(`cli.login.failed`,{reason:e})})}function n0(e,t){return Z1(this,void 0,void 0,function*(){if(!N1())return;let n=Z1(this,void 0,void 0,function*(){try{let{cli:n}=c1();yield $1(e,Object.assign(Object.assign(Object.assign(Object.assign({},t),{cli_version:n}),Q1()),yield e0()))}catch{}});r1(n),yield n})}function zMt(e){return Z1(this,void 0,void 0,function*(){if(process.env.CLI_TEST_MODE!==`true`)try{let{cli:t}=c1();yield $1(`cli.telemetry.preference_changed`,Object.assign({enabled:e.enabled,cli_version:t},Q1()))}catch{}})}var BMt=function(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})};const VMt=Ne({url:I()});function HMt(e,t,n){return BMt(this,void 0,void 0,function*(){let r=n===void 0?void 0:Ve().parse(n),{accessToken:i}=yield U1(yield H1(e),t),{url:a}=yield B1(yield z1(`${e}/api/agent/claim-link`,{method:`POST`,headers:{Authorization:`Bearer ${i}`,"Content-Type":`application/json`},body:JSON.stringify({claimToken:t.claimToken})}),VMt),o=new URL(a);return r&&o.searchParams.set(`email`,r),n0(`agent_signup.claim_started`,{registration_id:t.registrationId}),o.toString()})}const UMt=Ne({identity:lMt}),WMt=Ne({orgId:He().min(1),claimed:nt(!0)});function GMt(e){return BMt(this,arguments,void 0,function*(e,t=()=>{}){let{apiUrl:n,directory:r}=e,i=e.code?.trim(),a=e.email?.trim();if(i&&a)throw Error(`Pass --code to finish the claim, or leave it out to get a claim link.`);let o=yield SMt(n,r);if(!o)throw Error(`No saved agent registration. Run from the directory used for mint deploy, or pass --directory.`);if(!i&&!o.claimVerified)return t(`Creating the claim link...`),`Claim link for the user: ${yield HMt(n,o,a||void 0)}\nAsk the user to open it, sign in with any account, and click Confirm. The site then moves into their account; there is no code to relay and nothing more to run.`;let s=yield H1(n);if(new URL(s.issuer).origin!==new URL(o.issuer).origin)throw Error(`Saved agent credentials belong to another issuer.`);let c=e=>CMt(n,r,e);if(!o.claimVerified){t(`Completing the WorkOS claim...`);let e=yield B1(yield z1(`${s.agent_auth.claim_endpoint.replace(/\/$/,``)}/complete`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({claim_token:o.claimToken,user_code:i})}),UMt);n0(`agent_signup.claim_completed`,{registration_id:o.registrationId}),o=Object.assign(Object.assign({},o),{assertion:e.identity.assertion,claimVerified:!0,accessToken:void 0,accessTokenExpiresAt:void 0}),yield c(o)}t(`Finishing the site claim...`);let l=yield U1(s,o);return yield B1(yield z1(`${n}/api/agent/signup`,{method:`POST`,headers:{Authorization:`Bearer ${l.accessToken}`}}),WMt),yield c(l),`Site claimed successfully. The user can now manage it in the Mintlify dashboard.`})}const r0=(e,t=[])=>e.name===`up`||t.includes(`vim`)&&e.name===`k`||t.includes(`emacs`)&&e.ctrl&&e.name===`p`,i0=(e,t=[])=>e.name===`down`||t.includes(`vim`)&&e.name===`j`||t.includes(`emacs`)&&e.ctrl&&e.name===`n`,KMt=e=>e.name===`space`,qMt=e=>e.name===`backspace`,JMt=e=>e.name===`tab`,YMt=e=>`1234567890`.includes(e.name),a0=e=>e.name===`enter`||e.name===`return`;var XMt=class extends Error{name=`AbortPromptError`;message=`Prompt was aborted`;constructor(e){super(),this.cause=e?.cause}},ZMt=class extends Error{name=`CancelPromptError`;message=`Prompt was canceled`},QMt=class extends Error{name=`ExitPromptError`},$Mt=class extends Error{name=`HookError`},o0=class extends Error{name=`ValidationError`};const eNt=new Er;function tNt(e){return{rl:e,hooks:[],hooksCleanup:[],hooksEffect:[],index:0,handleChange(){}}}function nNt(e,t){let n=tNt(e);return eNt.run(n,()=>{function e(e){n.handleChange=()=>{n.index=0,e()},n.handleChange()}return t(e)})}function s0(){let e=eNt.getStore();if(!e)throw new $Mt(`[Inquirer] Hook functions can only be called from within a prompt`);return e}function rNt(){return s0().rl}function iNt(e){return Dr.bind((...t)=>{let n=s0(),r=!1,i=n.handleChange;n.handleChange=()=>{r=!0};let a=e(...t);return r&&i(),n.handleChange=i,a})}function c0(e){let t=s0(),{index:n}=t,r=e({get(){return t.hooks[n]},set(e){t.hooks[n]=e},initialized:n in t.hooks});return t.index++,r}function aNt(){s0().handleChange()}const l0={queue(e){let t=s0(),{index:n}=t;t.hooksEffect.push(()=>{t.hooksCleanup[n]?.();let r=e(rNt());if(r!=null&&typeof r!=`function`)throw new o0(`useEffect return value must be a cleanup function or nothing.`);t.hooksCleanup[n]=r})},run(){let e=s0();iNt(()=>{e.hooksEffect.forEach(e=>{e()}),e.hooksEffect.length=0})()},clearAll(){let e=s0();e.hooksCleanup.forEach(e=>{e?.()}),e.hooksEffect.length=0,e.hooksCleanup.length=0}};function u0(e){return c0(t=>{let n=Dr.bind(function(e){t.get()!==e&&(t.set(e),aNt())});if(t.initialized)return[t.get(),n];let r=typeof e==`function`?e():e;return t.set(r),[r,n]})}function d0(e,t){c0(n=>{let r=n.get();(!Array.isArray(r)||t.some((e,t)=>!Object.is(e,r[t])))&&l0.queue(e),n.set(t)})}function oNt(){return Vt.platform===`win32`?!!Vt.env.WT_SESSION||!!Vt.env.TERMINUS_SUBLIME||Vt.env.ConEmuTask===`{cmd::Cmder}`||Vt.env.TERM_PROGRAM===`Terminus-Sublime`||Vt.env.TERM_PROGRAM===`vscode`||Vt.env.TERM===`xterm-256color`||Vt.env.TERM===`alacritty`||Vt.env.TERMINAL_EMULATOR===`JetBrains-JediTerm`:Vt.env.TERM!==`linux`}const sNt={circleQuestionMark:`(?)`,questionMarkPrefix:`(?)`,square:`█`,squareDarkShade:`▓`,squareMediumShade:`▒`,squareLightShade:`░`,squareTop:`▀`,squareBottom:`▄`,squareLeft:`▌`,squareRight:`▐`,squareCenter:`■`,bullet:`●`,dot:`․`,ellipsis:`…`,pointerSmall:`›`,triangleUp:`▲`,triangleUpSmall:`▴`,triangleDown:`▼`,triangleDownSmall:`▾`,triangleLeftSmall:`◂`,triangleRightSmall:`▸`,home:`⌂`,heart:`♥`,musicNote:`♪`,musicNoteBeamed:`♫`,arrowUp:`↑`,arrowDown:`↓`,arrowLeft:`←`,arrowRight:`→`,arrowLeftRight:`↔`,arrowUpDown:`↕`,almostEqual:`≈`,notEqual:`≠`,lessOrEqual:`≤`,greaterOrEqual:`≥`,identical:`≡`,infinity:`∞`,subscriptZero:`₀`,subscriptOne:`₁`,subscriptTwo:`₂`,subscriptThree:`₃`,subscriptFour:`₄`,subscriptFive:`₅`,subscriptSix:`₆`,subscriptSeven:`₇`,subscriptEight:`₈`,subscriptNine:`₉`,oneHalf:`½`,oneThird:`⅓`,oneQuarter:`¼`,oneFifth:`⅕`,oneSixth:`⅙`,oneEighth:`⅛`,twoThirds:`⅔`,twoFifths:`⅖`,threeQuarters:`¾`,threeFifths:`⅗`,threeEighths:`⅜`,fourFifths:`⅘`,fiveSixths:`⅚`,fiveEighths:`⅝`,sevenEighths:`⅞`,line:`─`,lineBold:`━`,lineDouble:`═`,lineDashed0:`┄`,lineDashed1:`┅`,lineDashed2:`┈`,lineDashed3:`┉`,lineDashed4:`╌`,lineDashed5:`╍`,lineDashed6:`╴`,lineDashed7:`╶`,lineDashed8:`╸`,lineDashed9:`╺`,lineDashed10:`╼`,lineDashed11:`╾`,lineDashed12:`−`,lineDashed13:`–`,lineDashed14:`‐`,lineDashed15:`⁃`,lineVertical:`│`,lineVerticalBold:`┃`,lineVerticalDouble:`║`,lineVerticalDashed0:`┆`,lineVerticalDashed1:`┇`,lineVerticalDashed2:`┊`,lineVerticalDashed3:`┋`,lineVerticalDashed4:`╎`,lineVerticalDashed5:`╏`,lineVerticalDashed6:`╵`,lineVerticalDashed7:`╷`,lineVerticalDashed8:`╹`,lineVerticalDashed9:`╻`,lineVerticalDashed10:`╽`,lineVerticalDashed11:`╿`,lineDownLeft:`┐`,lineDownLeftArc:`╮`,lineDownBoldLeftBold:`┓`,lineDownBoldLeft:`┒`,lineDownLeftBold:`┑`,lineDownDoubleLeftDouble:`╗`,lineDownDoubleLeft:`╖`,lineDownLeftDouble:`╕`,lineDownRight:`┌`,lineDownRightArc:`╭`,lineDownBoldRightBold:`┏`,lineDownBoldRight:`┎`,lineDownRightBold:`┍`,lineDownDoubleRightDouble:`╔`,lineDownDoubleRight:`╓`,lineDownRightDouble:`╒`,lineUpLeft:`┘`,lineUpLeftArc:`╯`,lineUpBoldLeftBold:`┛`,lineUpBoldLeft:`┚`,lineUpLeftBold:`┙`,lineUpDoubleLeftDouble:`╝`,lineUpDoubleLeft:`╜`,lineUpLeftDouble:`╛`,lineUpRight:`└`,lineUpRightArc:`╰`,lineUpBoldRightBold:`┗`,lineUpBoldRight:`┖`,lineUpRightBold:`┕`,lineUpDoubleRightDouble:`╚`,lineUpDoubleRight:`╙`,lineUpRightDouble:`╘`,lineUpDownLeft:`┤`,lineUpBoldDownBoldLeftBold:`┫`,lineUpBoldDownBoldLeft:`┨`,lineUpDownLeftBold:`┥`,lineUpBoldDownLeftBold:`┩`,lineUpDownBoldLeftBold:`┪`,lineUpDownBoldLeft:`┧`,lineUpBoldDownLeft:`┦`,lineUpDoubleDownDoubleLeftDouble:`╣`,lineUpDoubleDownDoubleLeft:`╢`,lineUpDownLeftDouble:`╡`,lineUpDownRight:`├`,lineUpBoldDownBoldRightBold:`┣`,lineUpBoldDownBoldRight:`┠`,lineUpDownRightBold:`┝`,lineUpBoldDownRightBold:`┡`,lineUpDownBoldRightBold:`┢`,lineUpDownBoldRight:`┟`,lineUpBoldDownRight:`┞`,lineUpDoubleDownDoubleRightDouble:`╠`,lineUpDoubleDownDoubleRight:`╟`,lineUpDownRightDouble:`╞`,lineDownLeftRight:`┬`,lineDownBoldLeftBoldRightBold:`┳`,lineDownLeftBoldRightBold:`┯`,lineDownBoldLeftRight:`┰`,lineDownBoldLeftBoldRight:`┱`,lineDownBoldLeftRightBold:`┲`,lineDownLeftRightBold:`┮`,lineDownLeftBoldRight:`┭`,lineDownDoubleLeftDoubleRightDouble:`╦`,lineDownDoubleLeftRight:`╥`,lineDownLeftDoubleRightDouble:`╤`,lineUpLeftRight:`┴`,lineUpBoldLeftBoldRightBold:`┻`,lineUpLeftBoldRightBold:`┷`,lineUpBoldLeftRight:`┸`,lineUpBoldLeftBoldRight:`┹`,lineUpBoldLeftRightBold:`┺`,lineUpLeftRightBold:`┶`,lineUpLeftBoldRight:`┵`,lineUpDoubleLeftDoubleRightDouble:`╩`,lineUpDoubleLeftRight:`╨`,lineUpLeftDoubleRightDouble:`╧`,lineUpDownLeftRight:`┼`,lineUpBoldDownBoldLeftBoldRightBold:`╋`,lineUpDownBoldLeftBoldRightBold:`╈`,lineUpBoldDownLeftBoldRightBold:`╇`,lineUpBoldDownBoldLeftRightBold:`╊`,lineUpBoldDownBoldLeftBoldRight:`╉`,lineUpBoldDownLeftRight:`╀`,lineUpDownBoldLeftRight:`╁`,lineUpDownLeftBoldRight:`┽`,lineUpDownLeftRightBold:`┾`,lineUpBoldDownBoldLeftRight:`╂`,lineUpDownLeftBoldRightBold:`┿`,lineUpBoldDownLeftBoldRight:`╃`,lineUpBoldDownLeftRightBold:`╄`,lineUpDownBoldLeftBoldRight:`╅`,lineUpDownBoldLeftRightBold:`╆`,lineUpDoubleDownDoubleLeftDoubleRightDouble:`╬`,lineUpDoubleDownDoubleLeftRight:`╫`,lineUpDownLeftDoubleRightDouble:`╪`,lineCross:`╳`,lineBackslash:`╲`,lineSlash:`╱`},cNt={tick:`✔`,info:`ℹ`,warning:`⚠`,cross:`✘`,squareSmall:`◻`,squareSmallFilled:`◼`,circle:`◯`,circleFilled:`◉`,circleDotted:`◌`,circleDouble:`◎`,circleCircle:`ⓞ`,circleCross:`ⓧ`,circlePipe:`Ⓘ`,radioOn:`◉`,radioOff:`◯`,checkboxOn:`☒`,checkboxOff:`☐`,checkboxCircleOn:`ⓧ`,checkboxCircleOff:`Ⓘ`,pointer:`❯`,triangleUpOutline:`△`,triangleLeft:`◀`,triangleRight:`▶`,lozenge:`◆`,lozengeOutline:`◇`,hamburger:`☰`,smiley:`㋡`,mustache:`෴`,star:`★`,play:`▶`,nodejs:`⬢`,oneSeventh:`⅐`,oneNinth:`⅑`,oneTenth:`⅒`},lNt={tick:`√`,info:`i`,warning:`‼`,cross:`×`,squareSmall:`□`,squareSmallFilled:`■`,circle:`( )`,circleFilled:`(*)`,circleDotted:`( )`,circleDouble:`( )`,circleCircle:`(○)`,circleCross:`(×)`,circlePipe:`(│)`,radioOn:`(*)`,radioOff:`( )`,checkboxOn:`[×]`,checkboxOff:`[ ]`,checkboxCircleOn:`(×)`,checkboxCircleOff:`( )`,pointer:`>`,triangleUpOutline:`∆`,triangleLeft:`◄`,triangleRight:`►`,lozenge:`♦`,lozengeOutline:`◊`,hamburger:`≡`,smiley:`☺`,mustache:`┌─┐`,star:`✶`,play:`►`,nodejs:`♦`,oneSeventh:`1/7`,oneNinth:`1/9`,oneTenth:`1/10`},uNt={...sNt,...cNt},dNt={...sNt,...lNt},fNt=oNt()?uNt:dNt;Object.entries(cNt);const pNt={prefix:{idle:GZ.default.blue(`?`),done:GZ.default.green(fNt.tick)},spinner:{interval:80,frames:[`⠋`,`⠙`,`⠹`,`⠸`,`⠼`,`⠴`,`⠦`,`⠧`,`⠇`,`⠏`].map(e=>GZ.default.yellow(e))},style:{answer:GZ.default.cyan,message:GZ.default.bold,error:e=>GZ.default.red(`> ${e}`),defaultAnswer:e=>GZ.default.dim(`(${e})`),help:GZ.default.dim,highlight:GZ.default.cyan,key:e=>GZ.default.cyan(GZ.default.bold(`<${e}>`))}};function mNt(e){if(typeof e!=`object`||!e)return!1;let t=e;for(;Object.getPrototypeOf(t)!==null;)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t}function hNt(...e){let t={};for(let n of e)for(let[e,r]of Object.entries(n)){let n=t[e];t[e]=mNt(n)&&mNt(r)?hNt(n,r):r}return t}function f0(...e){return hNt(pNt,...e.filter(e=>e!=null))}function p0({status:e=`idle`,theme:t}){let[n,r]=u0(!1),[i,a]=u0(0),{prefix:o,spinner:s}=f0(t);return d0(()=>{if(e===`loading`){let e,t=-1,n=setTimeout(()=>{r(!0),e=setInterval(()=>{t+=1,a(t%s.frames.length)},s.interval)},300);return()=>{clearTimeout(n),clearInterval(e)}}r(!1)},[e]),n?s.frames[i]:typeof o==`string`?o:o[e===`loading`?`idle`:e]??o.idle}function m0(e,t){return c0(n=>{let r=n.get();if(!r||r.dependencies.length!==t.length||r.dependencies.some((e,n)=>e!==t[n])){let r=e();return n.set({value:r,dependencies:t}),r}return r.value})}function h0(e){return u0({current:e})[0]}function g0(e){let t=h0(e);t.current=e,d0(e=>{let n=!1,r=iNt((r,i)=>{n||t.current(i,e)});return e.input.on(`keypress`,r),()=>{n=!0,e.input.removeListener(`keypress`,r)}},[])}function _0(e,t){return e.split(`
|
|
1926
1926
|
`).flatMap(e=>(0,$Z.default)(e,t,{trim:!1,hard:!0}).split(`
|
|
1927
1927
|
`).map(e=>e.trimEnd())).join(`
|
|
1928
1928
|
`)}function gNt(){return(0,QZ.default)({defaultWidth:80,output:rNt().output})}function _Nt({active:e,renderedItems:t,pageSize:n,loop:r}){let i=h0({lastPointer:e,lastActive:void 0}),{lastPointer:a,lastActive:o}=i.current,s=Math.floor(n/2),c=t.reduce((e,t)=>e+t.length,0),l=t.slice(0,e).reduce((e,t)=>e+t.length,0),u=l;if(c>n){if(r)u=a,o!=null&&o<e&&e-o<n&&(u=Math.min(s,Math.abs(e-o)===1?Math.min(a+(t[o]?.length??0),Math.max(l,a)):a+e-o));else{let r=t.slice(e).reduce((e,t)=>e+t.length,0);u=r<n-s?n-r:Math.min(l,s)}}return i.current.lastPointer=u,i.current.lastActive=e,u}function v0({items:e,active:t,renderItem:n,pageSize:r,loop:i=!0}){let a=gNt(),o=t=>(t%e.length+e.length)%e.length,s=e.map((e,r)=>e==null?[]:_0(n({item:e,index:r,isActive:r===t}),a).split(`
|
|
@@ -2198,15 +2198,15 @@ Admin MCP is configured. Complete OAuth sign-in to grant account and project acc
|
|
|
2198
2198
|
`))}yield f1(0)}catch(e){t===`table`&&IH(),jH((0,z.jsx)(CH,{message:e instanceof Error?e.message:`unknown error`})),yield f1(1)}})).command(`view <id>`,`view conversations in a bucket`,e=>n2(e).option(`limit`,{type:`number`,description:`Maximum threads to return (1-100)`}).option(`cursor`,{type:`string`,description:`Pagination cursor from a previous response`}).positional(`id`,{type:`string`,demandOption:!0,description:`Bucket ID`}),e=>t2(void 0,void 0,void 0,function*(){let t=Q0(e);try{t===`table`&&jH((0,z.jsx)(xH,{message:`Fetching bucket conversations...`}));let n=yield cFt(e.id,{dateFrom:e.from,dateTo:e.to,limit:e.limit,cursor:e.cursor},e.subdomain);if(t===`table`&&IH(),t===`json`)r2(t,JSON.stringify(n,null,2));else{let r=[`Thread ID`,`Query`,`Length`,`Feedback`,`Created`],i=n.data.map(e=>[e.id.slice(0,12),Z0(e.firstUserMessage||`—`,40),X0(e.length),`+${e.feedback.up} -${e.feedback.down}`,e.createdAt.slice(0,10)]),a=[];t===`table`&&a.push(nY.bold(`\nBucket ${e.id}\n`)),a.push(e2(t,r,i,n)),t===`table`&&n.pagination.hasMore&&n.pagination.nextCursor&&a.push(nY.dim(`\n More results available. Run again with --cursor ${n.pagination.nextCursor}`)),r2(t,a.join(`
|
|
2199
2199
|
`))}yield f1(0)}catch(e){t===`table`&&IH(),jH((0,z.jsx)(CH,{message:e instanceof Error?e.message:`unknown error`})),yield f1(1)}})).demandCommand(1,`specify a subcommand: list or view`)).demandCommand(1,`specify a subcommand: list, view, or buckets`)).demandCommand(1,`specify a subcommand: stats, search, feedback, or conversation`),wFt=[];function i2(e){let t=-1;if(!e||!Array.isArray(e)&&!e.type)throw Error("Expected node, not `"+e+"`");if(`value`in e)return e.value;let n=(Array.isArray(e)?e:e.children)||wFt,r=[];for(;++t<n.length;)r[t]=i2(n[t]);return r.join(``)}const TFt={}.hasOwnProperty;function EFt(e,t,n){let r=-1;if(!e)throw Error(`Iterate requires that |this| not be `+e);if(!TFt.call(e,`length`))throw Error("Iterate requires that |this| has a `length`");if(typeof t!=`function`)throw TypeError("`callback` must be a function");for(;++r<e.length;){if(!(r in e))continue;let i=t.call(n,e[r],r,e);typeof i==`number`&&(i<0&&(r=0),r=i-1)}}function a2(e){return t;function t(e){if(!e||!e.children)throw Error("Missing children in `parent` for `modifier`");EFt(e.children,n,e)}function n(t,n){return e(t,n,this)}}const DFt=a2(function(e,t,n){let r=n.children[t-1];if(r&&`children`in r&&`children`in e&&e.children.length>0){let i=-1;for(;e.children[++i];){let a=e.children[i];if(a.type===`WordNode`)return;if(a.type===`SymbolNode`||a.type===`PunctuationNode`){let i=i2(a);return i!==`,`&&i!==`;`?void 0:(r.children.push(...e.children),r.position&&e.position&&(r.position.end=e.position.end),n.children.splice(t,1),t)}}}}),OFt=/^([!"').?\u0F3B\u0F3D\u169C\u2019\u201D\u2026\u203A\u203D\u2046\u207E\u208E\u2309\u230B\u232A\u2769\u276B\u276D\u276F\u2771\u2773\u2775\u27C6\u27E7\u27E9\u27EB\u27ED\u27EF\u2984\u2986\u2988\u298A\u298C\u298E\u2990\u2992\u2994\u2996\u2998\u29D9\u29DB\u29FD\u2E03\u2E05\u2E0A\u2E0D\u2E1D\u2E21\u2E23\u2E25\u2E27\u2E29\u2E56\u2E58\u2E5A\u2E5C\u3009\u300B\u300D\u300F\u3011\u3015\u3017\u3019\u301B\u301E\u301F\uFD3E\uFE18\uFE36\uFE38\uFE3A\uFE3C\uFE3E\uFE40\uFE42\uFE44\uFE48\uFE5A\uFE5C\uFE5E\uFF09\uFF3D\uFF5D\uFF60\uFF63\u00BB\]}])\1*$/,kFt=/^[ \t]*((\r?\n|\r)[\t ]*)+$/,AFt=/^([!.?\u2026\u203D]+)$/,jFt=/^([&'\-.:=?@\u00AD\u00B7\u2010\u2011\u2019\u2027]|_+)$/,MFt=/^(?:[\d\u00B2\u00B3\u00B9\u00BC-\u00BE\u0660-\u0669\u06F0-\u06F9\u07C0-\u07C9\u0966-\u096F\u09E6-\u09EF\u09F4-\u09F9\u0A66-\u0A6F\u0AE6-\u0AEF\u0B66-\u0B6F\u0B72-\u0B77\u0BE6-\u0BF2\u0C66-\u0C6F\u0C78-\u0C7E\u0CE6-\u0CEF\u0D58-\u0D5E\u0D66-\u0D78\u0DE6-\u0DEF\u0E50-\u0E59\u0ED0-\u0ED9\u0F20-\u0F33\u1040-\u1049\u1090-\u1099\u1369-\u137C\u16EE-\u16F0\u17E0-\u17E9\u17F0-\u17F9\u1810-\u1819\u1946-\u194F\u19D0-\u19DA\u1A80-\u1A89\u1A90-\u1A99\u1B50-\u1B59\u1BB0-\u1BB9\u1C40-\u1C49\u1C50-\u1C59\u2070\u2074-\u2079\u2080-\u2089\u2150-\u2182\u2185-\u2189\u2460-\u249B\u24EA-\u24FF\u2776-\u2793\u2CFD\u3007\u3021-\u3029\u3038-\u303A\u3192-\u3195\u3220-\u3229\u3248-\u324F\u3251-\u325F\u3280-\u3289\u32B1-\u32BF\uA620-\uA629\uA6E6-\uA6EF\uA830-\uA835\uA8D0-\uA8D9\uA900-\uA909\uA9D0-\uA9D9\uA9F0-\uA9F9\uAA50-\uAA59\uABF0-\uABF9\uFF10-\uFF19]|\uD800[\uDD07-\uDD33\uDD40-\uDD78\uDD8A\uDD8B\uDEE1-\uDEFB\uDF20-\uDF23\uDF41\uDF4A\uDFD1-\uDFD5]|\uD801[\uDCA0-\uDCA9]|\uD802[\uDC58-\uDC5F\uDC79-\uDC7F\uDCA7-\uDCAF\uDCFB-\uDCFF\uDD16-\uDD1B\uDDBC\uDDBD\uDDC0-\uDDCF\uDDD2-\uDDFF\uDE40-\uDE48\uDE7D\uDE7E\uDE9D-\uDE9F\uDEEB-\uDEEF\uDF58-\uDF5F\uDF78-\uDF7F\uDFA9-\uDFAF]|\uD803[\uDCFA-\uDCFF\uDD30-\uDD39\uDE60-\uDE7E\uDF1D-\uDF26\uDF51-\uDF54\uDFC5-\uDFCB]|\uD804[\uDC52-\uDC6F\uDCF0-\uDCF9\uDD36-\uDD3F\uDDD0-\uDDD9\uDDE1-\uDDF4\uDEF0-\uDEF9]|\uD805[\uDC50-\uDC59\uDCD0-\uDCD9\uDE50-\uDE59\uDEC0-\uDEC9\uDF30-\uDF3B]|\uD806[\uDCE0-\uDCF2\uDD50-\uDD59]|\uD807[\uDC50-\uDC6C\uDD50-\uDD59\uDDA0-\uDDA9\uDF50-\uDF59\uDFC0-\uDFD4]|\uD809[\uDC00-\uDC6E]|\uD81A[\uDE60-\uDE69\uDEC0-\uDEC9\uDF50-\uDF59\uDF5B-\uDF61]|\uD81B[\uDE80-\uDE96]|\uD834[\uDEC0-\uDED3\uDEE0-\uDEF3\uDF60-\uDF78]|\uD835[\uDFCE-\uDFFF]|\uD838[\uDD40-\uDD49\uDEF0-\uDEF9]|\uD839[\uDCF0-\uDCF9]|\uD83A[\uDCC7-\uDCCF\uDD50-\uDD59]|\uD83B[\uDC71-\uDCAB\uDCAD-\uDCAF\uDCB1-\uDCB4\uDD01-\uDD2D\uDD2F-\uDD3D]|\uD83C[\uDD00-\uDD0C]|\uD83E[\uDFF0-\uDFF9])+$/,NFt=/^\d/,PFt=/^(?:[a-z\u00B5\u00DF-\u00F6\u00F8-\u00FF\u0101\u0103\u0105\u0107\u0109\u010B\u010D\u010F\u0111\u0113\u0115\u0117\u0119\u011B\u011D\u011F\u0121\u0123\u0125\u0127\u0129\u012B\u012D\u012F\u0131\u0133\u0135\u0137\u0138\u013A\u013C\u013E\u0140\u0142\u0144\u0146\u0148\u0149\u014B\u014D\u014F\u0151\u0153\u0155\u0157\u0159\u015B\u015D\u015F\u0161\u0163\u0165\u0167\u0169\u016B\u016D\u016F\u0171\u0173\u0175\u0177\u017A\u017C\u017E-\u0180\u0183\u0185\u0188\u018C\u018D\u0192\u0195\u0199-\u019B\u019E\u01A1\u01A3\u01A5\u01A8\u01AA\u01AB\u01AD\u01B0\u01B4\u01B6\u01B9\u01BA\u01BD-\u01BF\u01C6\u01C9\u01CC\u01CE\u01D0\u01D2\u01D4\u01D6\u01D8\u01DA\u01DC\u01DD\u01DF\u01E1\u01E3\u01E5\u01E7\u01E9\u01EB\u01ED\u01EF\u01F0\u01F3\u01F5\u01F9\u01FB\u01FD\u01FF\u0201\u0203\u0205\u0207\u0209\u020B\u020D\u020F\u0211\u0213\u0215\u0217\u0219\u021B\u021D\u021F\u0221\u0223\u0225\u0227\u0229\u022B\u022D\u022F\u0231\u0233-\u0239\u023C\u023F\u0240\u0242\u0247\u0249\u024B\u024D\u024F-\u0293\u0295-\u02AF\u0371\u0373\u0377\u037B-\u037D\u0390\u03AC-\u03CE\u03D0\u03D1\u03D5-\u03D7\u03D9\u03DB\u03DD\u03DF\u03E1\u03E3\u03E5\u03E7\u03E9\u03EB\u03ED\u03EF-\u03F3\u03F5\u03F8\u03FB\u03FC\u0430-\u045F\u0461\u0463\u0465\u0467\u0469\u046B\u046D\u046F\u0471\u0473\u0475\u0477\u0479\u047B\u047D\u047F\u0481\u048B\u048D\u048F\u0491\u0493\u0495\u0497\u0499\u049B\u049D\u049F\u04A1\u04A3\u04A5\u04A7\u04A9\u04AB\u04AD\u04AF\u04B1\u04B3\u04B5\u04B7\u04B9\u04BB\u04BD\u04BF\u04C2\u04C4\u04C6\u04C8\u04CA\u04CC\u04CE\u04CF\u04D1\u04D3\u04D5\u04D7\u04D9\u04DB\u04DD\u04DF\u04E1\u04E3\u04E5\u04E7\u04E9\u04EB\u04ED\u04EF\u04F1\u04F3\u04F5\u04F7\u04F9\u04FB\u04FD\u04FF\u0501\u0503\u0505\u0507\u0509\u050B\u050D\u050F\u0511\u0513\u0515\u0517\u0519\u051B\u051D\u051F\u0521\u0523\u0525\u0527\u0529\u052B\u052D\u052F\u0560-\u0588\u10D0-\u10FA\u10FD-\u10FF\u13F8-\u13FD\u1C80-\u1C88\u1D00-\u1D2B\u1D6B-\u1D77\u1D79-\u1D9A\u1E01\u1E03\u1E05\u1E07\u1E09\u1E0B\u1E0D\u1E0F\u1E11\u1E13\u1E15\u1E17\u1E19\u1E1B\u1E1D\u1E1F\u1E21\u1E23\u1E25\u1E27\u1E29\u1E2B\u1E2D\u1E2F\u1E31\u1E33\u1E35\u1E37\u1E39\u1E3B\u1E3D\u1E3F\u1E41\u1E43\u1E45\u1E47\u1E49\u1E4B\u1E4D\u1E4F\u1E51\u1E53\u1E55\u1E57\u1E59\u1E5B\u1E5D\u1E5F\u1E61\u1E63\u1E65\u1E67\u1E69\u1E6B\u1E6D\u1E6F\u1E71\u1E73\u1E75\u1E77\u1E79\u1E7B\u1E7D\u1E7F\u1E81\u1E83\u1E85\u1E87\u1E89\u1E8B\u1E8D\u1E8F\u1E91\u1E93\u1E95-\u1E9D\u1E9F\u1EA1\u1EA3\u1EA5\u1EA7\u1EA9\u1EAB\u1EAD\u1EAF\u1EB1\u1EB3\u1EB5\u1EB7\u1EB9\u1EBB\u1EBD\u1EBF\u1EC1\u1EC3\u1EC5\u1EC7\u1EC9\u1ECB\u1ECD\u1ECF\u1ED1\u1ED3\u1ED5\u1ED7\u1ED9\u1EDB\u1EDD\u1EDF\u1EE1\u1EE3\u1EE5\u1EE7\u1EE9\u1EEB\u1EED\u1EEF\u1EF1\u1EF3\u1EF5\u1EF7\u1EF9\u1EFB\u1EFD\u1EFF-\u1F07\u1F10-\u1F15\u1F20-\u1F27\u1F30-\u1F37\u1F40-\u1F45\u1F50-\u1F57\u1F60-\u1F67\u1F70-\u1F7D\u1F80-\u1F87\u1F90-\u1F97\u1FA0-\u1FA7\u1FB0-\u1FB4\u1FB6\u1FB7\u1FBE\u1FC2-\u1FC4\u1FC6\u1FC7\u1FD0-\u1FD3\u1FD6\u1FD7\u1FE0-\u1FE7\u1FF2-\u1FF4\u1FF6\u1FF7\u210A\u210E\u210F\u2113\u212F\u2134\u2139\u213C\u213D\u2146-\u2149\u214E\u2184\u2C30-\u2C5F\u2C61\u2C65\u2C66\u2C68\u2C6A\u2C6C\u2C71\u2C73\u2C74\u2C76-\u2C7B\u2C81\u2C83\u2C85\u2C87\u2C89\u2C8B\u2C8D\u2C8F\u2C91\u2C93\u2C95\u2C97\u2C99\u2C9B\u2C9D\u2C9F\u2CA1\u2CA3\u2CA5\u2CA7\u2CA9\u2CAB\u2CAD\u2CAF\u2CB1\u2CB3\u2CB5\u2CB7\u2CB9\u2CBB\u2CBD\u2CBF\u2CC1\u2CC3\u2CC5\u2CC7\u2CC9\u2CCB\u2CCD\u2CCF\u2CD1\u2CD3\u2CD5\u2CD7\u2CD9\u2CDB\u2CDD\u2CDF\u2CE1\u2CE3\u2CE4\u2CEC\u2CEE\u2CF3\u2D00-\u2D25\u2D27\u2D2D\uA641\uA643\uA645\uA647\uA649\uA64B\uA64D\uA64F\uA651\uA653\uA655\uA657\uA659\uA65B\uA65D\uA65F\uA661\uA663\uA665\uA667\uA669\uA66B\uA66D\uA681\uA683\uA685\uA687\uA689\uA68B\uA68D\uA68F\uA691\uA693\uA695\uA697\uA699\uA69B\uA723\uA725\uA727\uA729\uA72B\uA72D\uA72F-\uA731\uA733\uA735\uA737\uA739\uA73B\uA73D\uA73F\uA741\uA743\uA745\uA747\uA749\uA74B\uA74D\uA74F\uA751\uA753\uA755\uA757\uA759\uA75B\uA75D\uA75F\uA761\uA763\uA765\uA767\uA769\uA76B\uA76D\uA76F\uA771-\uA778\uA77A\uA77C\uA77F\uA781\uA783\uA785\uA787\uA78C\uA78E\uA791\uA793-\uA795\uA797\uA799\uA79B\uA79D\uA79F\uA7A1\uA7A3\uA7A5\uA7A7\uA7A9\uA7AF\uA7B5\uA7B7\uA7B9\uA7BB\uA7BD\uA7BF\uA7C1\uA7C3\uA7C8\uA7CA\uA7D1\uA7D3\uA7D5\uA7D7\uA7D9\uA7F6\uA7FA\uAB30-\uAB5A\uAB60-\uAB68\uAB70-\uABBF\uFB00-\uFB06\uFB13-\uFB17\uFF41-\uFF5A]|\uD801[\uDC28-\uDC4F\uDCD8-\uDCFB\uDD97-\uDDA1\uDDA3-\uDDB1\uDDB3-\uDDB9\uDDBB\uDDBC]|\uD803[\uDCC0-\uDCF2]|\uD806[\uDCC0-\uDCDF]|\uD81B[\uDE60-\uDE7F]|\uD835[\uDC1A-\uDC33\uDC4E-\uDC54\uDC56-\uDC67\uDC82-\uDC9B\uDCB6-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDCCF\uDCEA-\uDD03\uDD1E-\uDD37\uDD52-\uDD6B\uDD86-\uDD9F\uDDBA-\uDDD3\uDDEE-\uDE07\uDE22-\uDE3B\uDE56-\uDE6F\uDE8A-\uDEA5\uDEC2-\uDEDA\uDEDC-\uDEE1\uDEFC-\uDF14\uDF16-\uDF1B\uDF36-\uDF4E\uDF50-\uDF55\uDF70-\uDF88\uDF8A-\uDF8F\uDFAA-\uDFC2\uDFC4-\uDFC9\uDFCB]|\uD837[\uDF00-\uDF09\uDF0B-\uDF1E\uDF25-\uDF2A]|\uD83A[\uDD22-\uDD43])/,FFt=/[\uD800-\uDFFF]/,IFt=/[!"'-),-/:;?[-\]_{}\u00A1\u00A7\u00AB\u00B6\u00B7\u00BB\u00BF\u037E\u0387\u055A-\u055F\u0589\u058A\u05BE\u05C0\u05C3\u05C6\u05F3\u05F4\u0609\u060A\u060C\u060D\u061B\u061D-\u061F\u066A-\u066D\u06D4\u0700-\u070D\u07F7-\u07F9\u0830-\u083E\u085E\u0964\u0965\u0970\u09FD\u0A76\u0AF0\u0C77\u0C84\u0DF4\u0E4F\u0E5A\u0E5B\u0F04-\u0F12\u0F14\u0F3A-\u0F3D\u0F85\u0FD0-\u0FD4\u0FD9\u0FDA\u104A-\u104F\u10FB\u1360-\u1368\u1400\u166E\u169B\u169C\u16EB-\u16ED\u1735\u1736\u17D4-\u17D6\u17D8-\u17DA\u1800-\u180A\u1944\u1945\u1A1E\u1A1F\u1AA0-\u1AA6\u1AA8-\u1AAD\u1B5A-\u1B60\u1B7D\u1B7E\u1BFC-\u1BFF\u1C3B-\u1C3F\u1C7E\u1C7F\u1CC0-\u1CC7\u1CD3\u2010-\u201F\u2022-\u2027\u2032-\u203A\u203C-\u2043\u2045-\u2051\u2053-\u205E\u207D\u207E\u208D\u208E\u2308-\u230B\u2329\u232A\u2768-\u2775\u27C5\u27C6\u27E6-\u27EF\u2983-\u2998\u29D8-\u29DB\u29FC\u29FD\u2CF9-\u2CFC\u2CFE\u2CFF\u2D70\u2E00-\u2E2E\u2E30-\u2E4F\u2E52-\u2E5D\u3001-\u3003\u3008-\u3011\u3014-\u301F\u3030\u303D\u30A0\u30FB\uA4FE\uA4FF\uA60D-\uA60F\uA673\uA67E\uA6F2-\uA6F7\uA874-\uA877\uA8CE\uA8CF\uA8F8-\uA8FA\uA8FC\uA92E\uA92F\uA95F\uA9C1-\uA9CD\uA9DE\uA9DF\uAA5C-\uAA5F\uAADE\uAADF\uAAF0\uAAF1\uABEB\uFD3E\uFD3F\uFE10-\uFE19\uFE30-\uFE52\uFE54-\uFE61\uFE63\uFE68\uFE6A\uFE6B\uFF01-\uFF03\uFF05-\uFF0A\uFF0C-\uFF0F\uFF1A\uFF1B\uFF1F\uFF20\uFF3B-\uFF3D\uFF3F\uFF5B\uFF5D\uFF5F-\uFF65]|\uD800[\uDD00-\uDD02\uDF9F\uDFD0]|\uD801\uDD6F|\uD802[\uDC57\uDD1F\uDD3F\uDE50-\uDE58\uDE7F\uDEF0-\uDEF6\uDF39-\uDF3F\uDF99-\uDF9C]|\uD803[\uDEAD\uDF55-\uDF59\uDF86-\uDF89]|\uD804[\uDC47-\uDC4D\uDCBB\uDCBC\uDCBE-\uDCC1\uDD40-\uDD43\uDD74\uDD75\uDDC5-\uDDC8\uDDCD\uDDDB\uDDDD-\uDDDF\uDE38-\uDE3D\uDEA9]|\uD805[\uDC4B-\uDC4F\uDC5A\uDC5B\uDC5D\uDCC6\uDDC1-\uDDD7\uDE41-\uDE43\uDE60-\uDE6C\uDEB9\uDF3C-\uDF3E]|\uD806[\uDC3B\uDD44-\uDD46\uDDE2\uDE3F-\uDE46\uDE9A-\uDE9C\uDE9E-\uDEA2\uDF00-\uDF09]|\uD807[\uDC41-\uDC45\uDC70\uDC71\uDEF7\uDEF8\uDF43-\uDF4F\uDFFF]|\uD809[\uDC70-\uDC74]|\uD80B[\uDFF1\uDFF2]|\uD81A[\uDE6E\uDE6F\uDEF5\uDF37-\uDF3B\uDF44]|\uD81B[\uDE97-\uDE9A\uDFE2]|\uD82F\uDC9F|\uD836[\uDE87-\uDE8B]|\uD83A[\uDD5E\uDD5F]/,LFt=/[\dA-Za-z\u00AA\u00B2\u00B3\u00B5\u00B9\u00BA\u00BC-\u00BE\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0300-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u0483-\u052F\u0531-\u0556\u0559\u0560-\u0588\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u05D0-\u05EA\u05EF-\u05F2\u0610-\u061A\u0620-\u0669\u066E-\u06D3\u06D5-\u06DC\u06DF-\u06E8\u06EA-\u06FC\u06FF\u0710-\u074A\u074D-\u07B1\u07C0-\u07F5\u07FA\u07FD\u0800-\u082D\u0840-\u085B\u0860-\u086A\u0870-\u0887\u0889-\u088E\u0898-\u08E1\u08E3-\u0963\u0966-\u096F\u0971-\u0983\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BC-\u09C4\u09C7\u09C8\u09CB-\u09CE\u09D7\u09DC\u09DD\u09DF-\u09E3\u09E6-\u09F1\u09F4-\u09F9\u09FC\u09FE\u0A01-\u0A03\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A59-\u0A5C\u0A5E\u0A66-\u0A75\u0A81-\u0A83\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABC-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AD0\u0AE0-\u0AE3\u0AE6-\u0AEF\u0AF9-\u0AFF\u0B01-\u0B03\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3C-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B55-\u0B57\u0B5C\u0B5D\u0B5F-\u0B63\u0B66-\u0B6F\u0B71-\u0B77\u0B82\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD0\u0BD7\u0BE6-\u0BF2\u0C00-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3C-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C58-\u0C5A\u0C5D\u0C60-\u0C63\u0C66-\u0C6F\u0C78-\u0C7E\u0C80-\u0C83\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBC-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CDD\u0CDE\u0CE0-\u0CE3\u0CE6-\u0CEF\u0CF1-\u0CF3\u0D00-\u0D0C\u0D0E-\u0D10\u0D12-\u0D44\u0D46-\u0D48\u0D4A-\u0D4E\u0D54-\u0D63\u0D66-\u0D78\u0D7A-\u0D7F\u0D81-\u0D83\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DE6-\u0DEF\u0DF2\u0DF3\u0E01-\u0E3A\u0E40-\u0E4E\u0E50-\u0E59\u0E81\u0E82\u0E84\u0E86-\u0E8A\u0E8C-\u0EA3\u0EA5\u0EA7-\u0EBD\u0EC0-\u0EC4\u0EC6\u0EC8-\u0ECE\u0ED0-\u0ED9\u0EDC-\u0EDF\u0F00\u0F18\u0F19\u0F20-\u0F33\u0F35\u0F37\u0F39\u0F3E-\u0F47\u0F49-\u0F6C\u0F71-\u0F84\u0F86-\u0F97\u0F99-\u0FBC\u0FC6\u1000-\u1049\u1050-\u109D\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u135D-\u135F\u1369-\u137C\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u1715\u171F-\u1734\u1740-\u1753\u1760-\u176C\u176E-\u1770\u1772\u1773\u1780-\u17D3\u17D7\u17DC\u17DD\u17E0-\u17E9\u17F0-\u17F9\u180B-\u180D\u180F-\u1819\u1820-\u1878\u1880-\u18AA\u18B0-\u18F5\u1900-\u191E\u1920-\u192B\u1930-\u193B\u1946-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u19D0-\u19DA\u1A00-\u1A1B\u1A20-\u1A5E\u1A60-\u1A7C\u1A7F-\u1A89\u1A90-\u1A99\u1AA7\u1AB0-\u1ACE\u1B00-\u1B4C\u1B50-\u1B59\u1B6B-\u1B73\u1B80-\u1BF3\u1C00-\u1C37\u1C40-\u1C49\u1C4D-\u1C7D\u1C80-\u1C88\u1C90-\u1CBA\u1CBD-\u1CBF\u1CD0-\u1CD2\u1CD4-\u1CFA\u1D00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2070\u2071\u2074-\u2079\u207F-\u2089\u2090-\u209C\u20D0-\u20F0\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2150-\u2189\u2460-\u249B\u24EA-\u24FF\u2776-\u2793\u2C00-\u2CE4\u2CEB-\u2CF3\u2CFD\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D7F-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2DE0-\u2DFF\u2E2F\u3005-\u3007\u3021-\u302F\u3031-\u3035\u3038-\u303C\u3041-\u3096\u3099\u309A\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312F\u3131-\u318E\u3192-\u3195\u31A0-\u31BF\u31F0-\u31FF\u3220-\u3229\u3248-\u324F\u3251-\u325F\u3280-\u3289\u32B1-\u32BF\u3400-\u4DBF\u4E00-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA62B\uA640-\uA672\uA674-\uA67D\uA67F-\uA6F1\uA717-\uA71F\uA722-\uA788\uA78B-\uA7CA\uA7D0\uA7D1\uA7D3\uA7D5-\uA7D9\uA7F2-\uA827\uA82C\uA830-\uA835\uA840-\uA873\uA880-\uA8C5\uA8D0-\uA8D9\uA8E0-\uA8F7\uA8FB\uA8FD-\uA92D\uA930-\uA953\uA960-\uA97C\uA980-\uA9C0\uA9CF-\uA9D9\uA9E0-\uA9FE\uAA00-\uAA36\uAA40-\uAA4D\uAA50-\uAA59\uAA60-\uAA76\uAA7A-\uAAC2\uAADB-\uAADD\uAAE0-\uAAEF\uAAF2-\uAAF6\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB69\uAB70-\uABEA\uABEC\uABED\uABF0-\uABF9\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE00-\uFE0F\uFE20-\uFE2F\uFE70-\uFE74\uFE76-\uFEFC\uFF10-\uFF19\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDD07-\uDD33\uDD40-\uDD78\uDD8A\uDD8B\uDDFD\uDE80-\uDE9C\uDEA0-\uDED0\uDEE0-\uDEFB\uDF00-\uDF23\uDF2D-\uDF4A\uDF50-\uDF7A\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF\uDFD1-\uDFD5]|\uD801[\uDC00-\uDC9D\uDCA0-\uDCA9\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDD70-\uDD7A\uDD7C-\uDD8A\uDD8C-\uDD92\uDD94\uDD95\uDD97-\uDDA1\uDDA3-\uDDB1\uDDB3-\uDDB9\uDDBB\uDDBC\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67\uDF80-\uDF85\uDF87-\uDFB0\uDFB2-\uDFBA]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC58-\uDC76\uDC79-\uDC9E\uDCA7-\uDCAF\uDCE0-\uDCF2\uDCF4\uDCF5\uDCFB-\uDD1B\uDD20-\uDD39\uDD80-\uDDB7\uDDBC-\uDDCF\uDDD2-\uDE03\uDE05\uDE06\uDE0C-\uDE13\uDE15-\uDE17\uDE19-\uDE35\uDE38-\uDE3A\uDE3F-\uDE48\uDE60-\uDE7E\uDE80-\uDE9F\uDEC0-\uDEC7\uDEC9-\uDEE6\uDEEB-\uDEEF\uDF00-\uDF35\uDF40-\uDF55\uDF58-\uDF72\uDF78-\uDF91\uDFA9-\uDFAF]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2\uDCFA-\uDD27\uDD30-\uDD39\uDE60-\uDE7E\uDE80-\uDEA9\uDEAB\uDEAC\uDEB0\uDEB1\uDEFD-\uDF27\uDF30-\uDF54\uDF70-\uDF85\uDFB0-\uDFCB\uDFE0-\uDFF6]|\uD804[\uDC00-\uDC46\uDC52-\uDC75\uDC7F-\uDCBA\uDCC2\uDCD0-\uDCE8\uDCF0-\uDCF9\uDD00-\uDD34\uDD36-\uDD3F\uDD44-\uDD47\uDD50-\uDD73\uDD76\uDD80-\uDDC4\uDDC9-\uDDCC\uDDCE-\uDDDA\uDDDC\uDDE1-\uDDF4\uDE00-\uDE11\uDE13-\uDE37\uDE3E-\uDE41\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEEA\uDEF0-\uDEF9\uDF00-\uDF03\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3B-\uDF44\uDF47\uDF48\uDF4B-\uDF4D\uDF50\uDF57\uDF5D-\uDF63\uDF66-\uDF6C\uDF70-\uDF74]|\uD805[\uDC00-\uDC4A\uDC50-\uDC59\uDC5E-\uDC61\uDC80-\uDCC5\uDCC7\uDCD0-\uDCD9\uDD80-\uDDB5\uDDB8-\uDDC0\uDDD8-\uDDDD\uDE00-\uDE40\uDE44\uDE50-\uDE59\uDE80-\uDEB8\uDEC0-\uDEC9\uDF00-\uDF1A\uDF1D-\uDF2B\uDF30-\uDF3B\uDF40-\uDF46]|\uD806[\uDC00-\uDC3A\uDCA0-\uDCF2\uDCFF-\uDD06\uDD09\uDD0C-\uDD13\uDD15\uDD16\uDD18-\uDD35\uDD37\uDD38\uDD3B-\uDD43\uDD50-\uDD59\uDDA0-\uDDA7\uDDAA-\uDDD7\uDDDA-\uDDE1\uDDE3\uDDE4\uDE00-\uDE3E\uDE47\uDE50-\uDE99\uDE9D\uDEB0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC36\uDC38-\uDC40\uDC50-\uDC6C\uDC72-\uDC8F\uDC92-\uDCA7\uDCA9-\uDCB6\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD36\uDD3A\uDD3C\uDD3D\uDD3F-\uDD47\uDD50-\uDD59\uDD60-\uDD65\uDD67\uDD68\uDD6A-\uDD8E\uDD90\uDD91\uDD93-\uDD98\uDDA0-\uDDA9\uDEE0-\uDEF6\uDF00-\uDF10\uDF12-\uDF3A\uDF3E-\uDF42\uDF50-\uDF59\uDFB0\uDFC0-\uDFD4]|\uD808[\uDC00-\uDF99]|\uD809[\uDC00-\uDC6E\uDC80-\uDD43]|\uD80B[\uDF90-\uDFF0]|[\uD80C\uD81C-\uD820\uD822\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879\uD880-\uD883\uD885-\uD887][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2F\uDC40-\uDC55]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDE60-\uDE69\uDE70-\uDEBE\uDEC0-\uDEC9\uDED0-\uDEED\uDEF0-\uDEF4\uDF00-\uDF36\uDF40-\uDF43\uDF50-\uDF59\uDF5B-\uDF61\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDE40-\uDE96\uDF00-\uDF4A\uDF4F-\uDF87\uDF8F-\uDF9F\uDFE0\uDFE1\uDFE3\uDFE4\uDFF0\uDFF1]|\uD821[\uDC00-\uDFF7]|\uD823[\uDC00-\uDCD5\uDD00-\uDD08]|\uD82B[\uDFF0-\uDFF3\uDFF5-\uDFFB\uDFFD\uDFFE]|\uD82C[\uDC00-\uDD22\uDD32\uDD50-\uDD52\uDD55\uDD64-\uDD67\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99\uDC9D\uDC9E]|\uD833[\uDF00-\uDF2D\uDF30-\uDF46]|\uD834[\uDD65-\uDD69\uDD6D-\uDD72\uDD7B-\uDD82\uDD85-\uDD8B\uDDAA-\uDDAD\uDE42-\uDE44\uDEC0-\uDED3\uDEE0-\uDEF3\uDF60-\uDF78]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB\uDFCE-\uDFFF]|\uD836[\uDE00-\uDE36\uDE3B-\uDE6C\uDE75\uDE84\uDE9B-\uDE9F\uDEA1-\uDEAF]|\uD837[\uDF00-\uDF1E\uDF25-\uDF2A]|\uD838[\uDC00-\uDC06\uDC08-\uDC18\uDC1B-\uDC21\uDC23\uDC24\uDC26-\uDC2A\uDC30-\uDC6D\uDC8F\uDD00-\uDD2C\uDD30-\uDD3D\uDD40-\uDD49\uDD4E\uDE90-\uDEAE\uDEC0-\uDEF9]|\uD839[\uDCD0-\uDCF9\uDFE0-\uDFE6\uDFE8-\uDFEB\uDFED\uDFEE\uDFF0-\uDFFE]|\uD83A[\uDC00-\uDCC4\uDCC7-\uDCD6\uDD00-\uDD4B\uDD50-\uDD59]|\uD83B[\uDC71-\uDCAB\uDCAD-\uDCAF\uDCB1-\uDCB4\uDD01-\uDD2D\uDD2F-\uDD3D\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD83C[\uDD00-\uDD0C]|\uD83E[\uDFF0-\uDFF9]|\uD869[\uDC00-\uDEDF\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF39\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D]|\uD884[\uDC00-\uDF4A\uDF50-\uDFFF]|\uD888[\uDC00-\uDFAF]|\uDB40[\uDD00-\uDDEF]/,RFt=/[\t-\r \u0085\u00A0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000]/,zFt=a2(function(e,t,n){if(`children`in e&&e.children.length>0&&t>0){let r=n.children[t-1],i=e.children[0],a=e.children[1];if(r&&r.type===`SentenceNode`&&(i.type===`SymbolNode`||i.type===`PunctuationNode`)&&OFt.test(i2(i)))return e.children.shift(),r.children.push(i),i.position&&r.position&&(r.position.end=i.position.end),a&&a.position&&e.position&&(e.position.start=a.position.start),t-1}}),BFt=a2(function(e,t,n){if(e.type!==`SentenceNode`)return;let r=e.children,i=0;for(;++i<r.length-1;){let a=r[i];if(a.type!==`WhiteSpaceNode`||i2(a).split(/\r\n|\r|\n/).length<3)continue;e.children=r.slice(0,i);let o={type:`SentenceNode`,children:r.slice(i+1)},s=r[i-1],c=r[i+1];if(n.children.splice(t+1,0,a,o),e.position&&s.position&&c.position){let t=e.position.end;e.position.end=s.position.end,o.position={start:c.position.start,end:t}}return t+1}}),VFt=a2(function(e,t,n){if(`children`in e){let r=e.children[e.children.length-1];if(r&&r.type===`WhiteSpaceNode`){e.children.pop(),n.children.splice(t+1,0,r);let i=e.children[e.children.length-1];return i&&i.position&&e.position&&(e.position.end=i.position.end),t}}});function o2(e){return t;function t(t){let n=t&&t.children,r=-1;if(!n)throw Error("Missing children in `parent` for `visit`");for(;++r in n;)e(n[r],r,t)}}const HFt=o2(function(e,t,n){if(`children`in e&&e.children){let r=e.children[0];if(r&&r.type===`WhiteSpaceNode`){e.children.shift(),n.children.splice(t,0,r);let i=e.children[0];i&&i.position&&e.position&&(e.position.start=i.position.start)}}}),UFt=a2(function(e,t,n){if(t>0&&(e.type===`SymbolNode`||e.type===`PunctuationNode`)&&i2(e)===`-`){let r=n.children,i=r[t-1],a=r[t+1];if((!a||a.type!==`WordNode`)&&i&&i.type===`WordNode`)return r.splice(t,1),i.children.push(e),i.position&&e.position&&(i.position.end=e.position.end),t}}),WFt=a2(function(e,t,n){let r=n.children[t-1];if(r&&r.type===`SentenceNode`&&e.type===`SentenceNode`){let i=e.children[0];if(i&&i.type===`WordNode`&&NFt.test(i2(i)))return r.children.push(...e.children),n.children.splice(t,1),r.position&&e.position&&(r.position.end=e.position.end),t}}),GFt=a2(function(e,t,n){if(e.type===`SentenceNode`&&t>0){let r=n.children[t-1],i=e.children;if(i.length>0&&r.type===`SentenceNode`){let a=-1;for(;i[++a];){let o=i[a];if(o.type===`WordNode`)return PFt.test(i2(o))?(r.children.push(...i),n.children.splice(t,1),r.position&&e.position&&(r.position.end=e.position.end),t):void 0;if(o.type===`SymbolNode`||o.type===`PunctuationNode`)return}}}}),KFt=a2(function(e,t,n){if(e.type!==`SymbolNode`&&e.type!==`PunctuationNode`||i2(e)!==`&`)return;let r=n.children,i=r[t+1];if(!(t>0&&r[t-1].type===`WordNode`||!(i&&i.type===`WordNode`)))return r.splice(t,1),i.children.unshift(e),i.position&&e.position&&(i.position.start=e.position.start),t-1}),qFt=a2(function(e,t,n){if(t>0&&e.type===`PunctuationNode`&&i2(e)===`.`){let r=n.children[t-1];if(r.type===`WordNode`&&r.children&&r.children.length!==1&&r.children.length%2!=0){let i=r.children.length,a=!0;for(;r.children[--i];){let e=r.children[i],t=i2(e);if(i%2==0){if(t.length>1)return;MFt.test(t)||(a=!1)}else if(t!==`.`){if(i<r.children.length-2)break;return}}if(!a)return n.children.splice(t,1),r.children.push(e),r.position&&e.position&&(r.position.end=e.position.end),t}}}),JFt=a2(function(e,t,n){if(t>0&&(e.type===`SymbolNode`||e.type===`PunctuationNode`)){let e=n.children,r=e[t-1];if(r&&r.type===`WordNode`){let n=t-1,i=[],a=[];for(;e[++n];){let t=e[n];if(t.type===`WordNode`)i.push(...a,...t.children),a=[];else if((t.type===`SymbolNode`||t.type===`PunctuationNode`)&&jFt.test(i2(t)))a.push(t);else break}if(i.length>0){a.length>0&&(n-=a.length),e.splice(t,n-t),r.children.push(...i);let o=i[i.length-1];return r.position&&o.position&&(r.position.end=o.position.end),t}}}}),YFt=a2(function(e,t,n){let r=n.children,i=r[t-1];if(i&&i.type===`WordNode`&&(e.type===`SymbolNode`||e.type===`PunctuationNode`)&&i2(e)===`/`){let n=i2(i),a=e,o=[e],s=1,c=``,l=r[t+1];if(l&&l.type===`WordNode`&&(c=i2(l),a=l,o.push(...l.children),s++),n.length<3&&(!c||c.length<3))return i.children.push(...o),r.splice(t,s),i.position&&a.position&&(i.position.end=a.position.end),t}}),XFt=a2(function(e,t,n){if(`children`in e){let r=-1;for(;e.children[++r];)if(e.children[r].type===`WordNode`)return;let i=n.children[t-1];if(i&&`children`in i)return i.children.push(...e.children),n.children.splice(t,1),i.position&&e.position&&(i.position.end=e.position.end),t;let a=n.children[t+1];a&&`children`in a&&(a.children.unshift(...e.children),a.position&&e.position&&(a.position.start=e.position.start),n.children.splice(t,1))}}),ZFt=/* @__PURE__ */ RegExp(`^([0-9]{1,3}|[a-z]|al|ca|cap|cca|cent|cf|cit|con|cp|cwt|ead|etc|ff|fl|ibid|id|nem|op|pro|seq|sic|stat|tem|viz)$`),QFt=a2(function(e,t,n){if(`children`in e&&e.children.length>1){let r=e.children[e.children.length-1];if(r&&(r.type===`PunctuationNode`||r.type===`SymbolNode`)&&i2(r)===`.`){let i=e.children[e.children.length-2];if(i&&i.type===`WordNode`&&ZFt.test(i2(i).toLowerCase())){i.children.push(r),e.children.pop(),r.position&&i.position&&(i.position.end=r.position.end);let a=n.children[t+1];if(a&&a.type===`SentenceNode`)return e.children.push(...a.children),n.children.splice(t+1,1),a.position&&e.position&&(e.position.end=a.position.end),t-1}}}}),$Ft=o2(function(e,t,n){if(`children`in e){let t=e.children.length,n=!1;for(;e.children[--t];){let r=e.children[t];if(r.type!==`SymbolNode`&&r.type!==`PunctuationNode`){r.type===`WordNode`&&(n=!0);continue}if(!AFt.test(i2(r)))continue;if(!n){n=!0;continue}if(i2(r)!==`.`)continue;let i=e.children[t-1],a=e.children[t+1];if(i&&i.type===`WordNode`){let n=e.children[t+2];if(a&&n&&a.type===`WhiteSpaceNode`&&i2(n)===`.`)continue;e.children.splice(t,1),i.children.push(r),r.position&&i.position&&(i.position.end=r.position.end),t--}else a&&a.type===`WordNode`&&(e.children.splice(t,1),a.children.unshift(r),r.position&&a.position&&(a.position.start=r.position.start))}}}),eIt=a2(function(e,t,n){if(`children`in e&&e.children.length===0)return n.children.splice(t,1),t}),s2=o2(function(e,t,n){let r=n.children;e.position&&t<1&&(!n.position||!n.position.start)&&(tIt(n),n.position.start=e.position.start),e.position&&t===r.length-1&&(!n.position||!n.position.end)&&(tIt(n),n.position.end=e.position.end)});function tIt(e){e.position||={}}var c2=class{constructor(e,t){let n=t||e;this.doc=n?String(n):void 0,this.tokenizeRootPlugins=[...this.tokenizeRootPlugins],this.tokenizeParagraphPlugins=[...this.tokenizeParagraphPlugins],this.tokenizeSentencePlugins=[...this.tokenizeSentencePlugins]}parse(e){return this.tokenizeRoot(e||this.doc)}tokenizeRoot(e){let t={type:`RootNode`,children:nIt(this.tokenizeParagraph(e),`WhiteSpaceNode`,kFt)},n=-1;for(;this.tokenizeRootPlugins[++n];)this.tokenizeRootPlugins[n](t);return t}tokenizeParagraph(e){let t={type:`ParagraphNode`,children:nIt(this.tokenizeSentence(e),`PunctuationNode`,AFt)},n=-1;for(;this.tokenizeParagraphPlugins[++n];)this.tokenizeParagraphPlugins[n](t);return t}tokenizeSentence(e){let t={type:`SentenceNode`,children:this.tokenize(e)},n=-1;for(;this.tokenizeSentencePlugins[++n];)this.tokenizeSentencePlugins[n](t);return t}tokenize(e){let t=[];if(!e)return t;let n={line:1,column:1,offset:0},r=0,i=0,a={...n},o,s;for(;i<e.length;){let l=e.charAt(i),u=RFt.test(l)?`WhiteSpaceNode`:IFt.test(l)?`PunctuationNode`:LFt.test(l)?`WordNode`:`SymbolNode`;r<i&&o&&u&&(o!==u||o!==`WordNode`&&o!==`WhiteSpaceNode`&&l!==s&&!FFt.test(l))&&(t.push(c(o,e.slice(r,i))),r=i,a={...n}),l===`\r`||l===`
|
|
2200
2200
|
`&&s!==`\r`?(n.line++,n.column=1):l!==`
|
|
2201
|
-
`&&n.column++,n.offset++,o=u,s=l,i++}return o&&r<i&&t.push(c(o,e.slice(r,i))),t;function c(e,t){return e===`WordNode`?{type:`WordNode`,children:[{type:`TextNode`,value:t,position:{start:a,end:{...n}}}],position:{start:a,end:{...n}}}:{type:e,value:t,position:{start:a,end:{...n}}}}}};c2.prototype.tokenizeSentencePlugins=[KFt,UFt,JFt,YFt,qFt,s2],c2.prototype.tokenizeParagraphPlugins=[XFt,zFt,GFt,WFt,QFt,DFt,$Ft,HFt,VFt,BFt,eIt,s2],c2.prototype.tokenizeRootPlugins=[HFt,VFt,eIt,s2];function nIt(e,t,n){let r=[],i=-1,a=0;for(;++i<e.children.length;){let o=e.children[i];if(i===e.children.length-1||o.type===t&&n.test(i2(o))){let t={type:e.type,children:e.children.slice(a,i+1)},n=e.children[a],s=o;n.position&&s.position&&(t.position={start:n.position.start,end:s.position.end}),r.push(t),a=i+1}}return r}function rIt(){let e=this;e.parser=t;function t(t){let n=new c2;return l2(n.tokenizeParagraphPlugins,e.data(`nlcstParagraphExtensions`)),l2(n.tokenizeRootPlugins,e.data(`nlcstRootExtensions`)),l2(n.tokenizeSentencePlugins,e.data(`nlcstSentenceExtensions`)),n.parse(t)}}function l2(e,t){t&&e.unshift(...t)}function iIt(){let e=this;e.compiler=aIt}function aIt(e){return i2(e)}const oIt=tt().use(rIt).use(iIt).freeze(),sIt=[`”`,`’`],cIt=[`“`,`‘`],lIt={};function uIt(e){let t=e||lIt,n=[];if(t.quotes!==!1&&n.push(yIt),t.ellipses===`spaced`?n.push(_It):t.ellipses===`unspaced`?n.push(vIt):t.ellipses!==!1&&n.push(gIt),t.backticks===`all`){if(t.quotes!==!1)throw Error("Cannot accept `backticks: 'all'` with `quotes: true`");n.push(dIt)}else t.backticks!==!1&&n.push(fIt);t.dashes===`inverted`?n.push(mIt):t.dashes===`oldschool`?n.push(hIt):t.dashes!==!1&&n.push(pIt);let r={close:t.closingQuotes?[t.closingQuotes.double,t.closingQuotes.single]:sIt,open:t.openingQuotes?[t.openingQuotes.double,t.openingQuotes.single]:cIt};return function(e){ue(e,function(e,t,i){let a=-1;if(i&&t!==void 0&&(e.type===`PunctuationNode`||e.type===`SymbolNode`)){for(;++a<n.length;)if(n[a](r,e,t,i)===!0)return console.log(`drop`,e),i.children.splice(t,1),t}})}}function dIt(e,t,n,r){fIt(e,t,n,r),t.value==="`"?t.value=`‘`:t.value===`'`&&(t.value=`’`)}function fIt(e,t){t.value==="``"?t.value=`“`:t.value===`''`&&(t.value=`”`)}function pIt(e,t){t.value===`--`&&(t.value=`—`)}function mIt(e,t,n,r){let i=r.children[n+1];if(t.value===`—`&&i&&i.type===`PunctuationNode`&&i.value===`-`)return i.value=`–`,!0;t.value===`---`?t.value=`–`:t.value===`--`&&(t.value=`—`)}function hIt(e,t,n,r){let i=r.children[n+1];if(t.value===`–`&&i&&i.type===`PunctuationNode`&&i.value===`-`)return i.value=`—`,!0;t.value===`---`?t.value=`—`:t.value===`--`&&(t.value=`–`)}function gIt(e,t,n,r){_It(e,t,n,r),vIt(e,t,n,r)}function _It(e,t,n,r){let i=t.value,a=r.children;if(!/^\.+$/.test(i))return;let o=[],s=n,c=1;for(;--s>0;){let e=a[s];if(e.type!==`WhiteSpaceNode`)break;let t=e;if(e=a[--s],e&&(e.type===`PunctuationNode`||e.type===`SymbolNode`)&&/^\.+$/.test(e.value))o.push(t,e),c++;else break}c<3||(a.splice(n-o.length,o.length),t.value=`…`)}function vIt(e,t){/^\.{3,}$/.test(t.value)&&(t.value=`…`)}function yIt(e,t,n,r){let i=r.children,a=t.value;if(a!==`"`&&a!==`'`)return;let o=a===`"`?0:1,s=i[n-1],c=i[n+1],l=i[n+2],u=c?i2(c):``;c&&(c.type===`PunctuationNode`||c.type===`SymbolNode`)&&(!l||l.type!==`WordNode`)?t.value=e.close[o]:c&&(c.type===`PunctuationNode`||c.type===`SymbolNode`)&&(u===`"`||u===`'`)&&l&&l.type===`WordNode`?(t.value=e.open[o],c.value=e.open[u===`"`?0:1]):t.value=c&&/^\d\ds$/.test(u)?e.close[o]:s&&(s.type===`WhiteSpaceNode`||s.type===`PunctuationNode`||s.type===`SymbolNode`)&&c&&c.type===`WordNode`?e.open[o]:s&&s.type!==`WhiteSpaceNode`&&s.type!==`SymbolNode`&&s.type!==`PunctuationNode`||!c||c.type===`WhiteSpaceNode`||a===`'`&&u===`s`?e.close[o]:e.open[o]}const bIt=/* @__PURE__ */ new Set([`text`,`inlineCode`,`paragraph`]),xIt=/* @__PURE__ */ new Set([`style`,`script`]),SIt=(e,t,n)=>n&&(n.type!==`mdxJsxTextElement`||`name`in n&&typeof n.name==`string`&&!xIt.has(n.name))&&bIt.has(e.type)&&(u2(e)||d2(e)),CIt=e=>{let t=oIt().use(uIt,{...e,ellipses:!1,dashes:!1,backticks:!1}),n=oIt().use(uIt,{...e,quotes:!1});return e=>{let r=``,i=0,a=[];ue(e,SIt,e=>{u2(e)?r+=e.type===`text`?e.value:`A`.repeat(e.value.length):d2(e)&&(r+=` `),a.push(e)}),/["']/.test(r)&&(r=t.processSync(r).toString());for(let e of a)if(u2(e)){let t=i+e.value.length;if(e.type===`text`){let a=r.slice(i,t);e.value=/\.[\s\u0085]*\.|--|``|''/.test(a)?n.processSync(a).toString():a}i=t}else d2(e)&&(i+=1)}};function u2(e){return`value`in e&&typeof e.value==`string`}function d2(e){return e.type===`paragraph`}const wIt=(function(e){if(e==null)return OIt;if(typeof e==`string`)return DIt(e);if(typeof e==`object`)return Array.isArray(e)?TIt(e):EIt(e);if(typeof e==`function`)return f2(e);throw Error(`Expected function, string, or object as test`)});function TIt(e){let t=[],n=-1;for(;++n<e.length;)t[n]=wIt(e[n]);return f2(r);function r(...e){let n=-1;for(;++n<t.length;)if(t[n].call(this,...e))return!0;return!1}}function EIt(e){return f2(t);function t(t){let n;for(n in e)if(t[n]!==e[n])return!1;return!0}}function DIt(e){return f2(t);function t(t){return t&&t.type===e}}function f2(e){return t;function t(t,...n){return!!(t&&typeof t==`object`&&`type`in t&&e.call(this,t,...n))}}function OIt(){return!0}function kIt(e){return`\x1B[33m`+e+`\x1B[39m`}const AIt=(function(e,t,n,r){typeof t==`function`&&typeof n!=`function`&&(r=n,n=t,t=null);let i=wIt(t),a=r?-1:1;o(e,void 0,[])();function o(e,s,c){let l=e&&typeof e==`object`?e:{};if(typeof l.type==`string`){let t=typeof l.tagName==`string`?l.tagName:typeof l.name==`string`?l.name:void 0;Object.defineProperty(u,"name",{value:`node (`+kIt(e.type+(t?`<`+t+`>`:``))+`)`})}return u;function u(){let l=[],u,d,f;if((!t||i(e,s,c[c.length-1]||null))&&(l=jIt(n(e,c)),l[0]===!1))return l;if(e.children&&l[0]!==`skip`)for(d=(r?e.children.length:-1)+a,f=c.concat(e);d>-1&&d<e.children.length;){if(u=o(e.children[d],d,f)(),u[0]===!1)return u;d=typeof u[1]==`number`?u[1]:d+a}return l}}});function jIt(e){return Array.isArray(e)?e:typeof e==`number`?[!0,e]:[e]}const p2=(function(e,t,n,r){typeof t==`function`&&typeof n!=`function`&&(r=n,n=t,t=null),AIt(e,t,i,r);function i(e,t){let r=t[t.length-1];return n(e,r?r.children.indexOf(e):null,r)}}),MIt=[`.mdx`,`.md`],NIt=[`.jpeg`,`.jpg`,`.jfif`,`.pjpeg`,`.pjp`,`.png`,`.svg`,`.svgz`,`.ico`,`.webp`,`.gif`,`.apng`,`.avif`,`.bmp`,`.mp4`,`.css`,`.xml`],PIt=e=>!(e.dir===`node_modules`||e.dir.startsWith(`node_modules/`)),FIt=e=>!(e.dir===`.github`||e.dir.startsWith(`.github/`)),IIt=e=>MIt.includes(e.ext),LIt=e=>NIt.includes(e.ext),RIt=e=>IIt(e)||LIt(e),zIt=e=>e.map(h2).map(Ct).filter(PIt),BIt=e=>zIt(e).filter(IIt).filter(FIt),VIt=e=>zIt(e).filter(RIt).filter(FIt),HIt=e=>xt(e.dir,e.base),UIt=e=>e.split(`#`)[0].split(`?`)[0],WIt=(e,t=[])=>BIt(RP(e,e,t)).map(HIt),m2=(e,t=[])=>VIt(RP(e,e,t)).map(HIt),h2=e=>St(g2(e)),g2=e=>e.startsWith(`/`)?e.slice(1):e;var _2;(function(e){e.INTERNAL=`internal`,e.EXTERNAL=`external`,e.DATA=`data`})(_2||={});const GIt=e=>{try{return decodeURIComponent(e)}catch{return e}},v2=e=>/[:*]/.test(e);var y2;(function(e){e.MD=`md`,e.SRC=`src`,e.HREF=`href`,e.CARD=`card`,e.IMPORT=`import`})(y2||={});var KIt;(function(e){e.CONTENT=`content`,e.NAVIGATION=`navigation`})(KIt||={});var b2=class e{static getPathType(e){let t;return t=URL.canParse(e)?_2.EXTERNAL:e.startsWith(`data:`)?_2.DATA:_2.INTERNAL,t}constructParsedPath(){let t=e.getPathType(this.originalPath),n,r;if(t===_2.INTERNAL){let e=new URL(`mintlify:/`);e.pathname=`/${this.relativeDir}/${this.filename}`.replaceAll(Pr,`/`),n=new URL(this.originalPath.replaceAll(Pr,`/`),e);let t=GIt(n.pathname).slice(1);t.endsWith(`/`)&&(t=t.slice(0,-1)),t===``&&(t=`.`),r=Ct(t)}else try{n=new URL(this.originalPath),r=n}catch{throw Error(`Failed to parse path as URL: ${this.originalPath}. If this is a purposefully malformed path, please wrap it in backticks, i.e \`${this.originalPath}\` `)}let i=n.hash?t===_2.INTERNAL?GIt(n.hash):n.hash:void 0,a=n.searchParams;return{path:r,pathType:t,anchorLink:i,queryParams:a}}constructor(e,t=``,n=``,r){this.originalPath=e,this.relativeDir=t,this.filename=n,this.wrapper=r,this.pagePaths=[],this.relativeDir=h2(t);let{path:i,pathType:a,anchorLink:o,queryParams:s}=this.constructParsedPath();this.path=i,this.pathType=a,this.anchorLink=o,this.queryParams=s}toString(){if(this.pathType===_2.INTERNAL){let e=this.path;return xt(e.dir,e.base)}return this.path.toString()}getResolvedFiles(e,t){if(this.pathType!==_2.INTERNAL||this.path instanceof URL)return[];let{dir:n,name:r,base:i}=Ct(this.toString()),a=[];return Jt(Et(t,this.toString()))&&a.push(xt(n,i)),a.push(...e.lookup(n,r,i)),a}resolvesTo(e,t,n){return this.pathType===_2.INTERNAL&&!!(this.toString()===e.toString()||this.getResolvedFiles(t,n).includes(e.toString()))}static filterMapInternalPaths(t){return t.map(t=>new e(t)).filter(({pathType:e})=>e===_2.INTERNAL).map(e=>e.toString())}},qIt=class e{constructor(t){this.byDirAndName=/* @__PURE__ */ new Map,t.forEach((t,n)=>{let r=t.startsWith(`/`)?t.slice(1):t,{dir:i,name:a}=Ct(r),o=e.key(i,a),s=[n,r],c=this.byDirAndName.get(o);c?c.push(s):this.byDirAndName.set(o,[s])})}static key(e,t){return`${e}\0${t}`}lookup(t,n,r){let i=this.byDirAndName.get(e.key(t,n))??[],a=r===n?[]:this.byDirAndName.get(e.key(t,r))??[];return[...i,...a].sort(([e],[t])=>e-t).map(([,e])=>e)}},x2=class{constructor(e,t=[]){this.label=e,this.paths=t,this.edges=[],this.headingSlugs=null,this.relativeDir=h2(vt(e)),this.filename=_t(e),this.label=xt(this.relativeDir,this.filename)}toString(){return this.label}equals(e){return this.label===e.label}addPath(e,t){let n=new b2(e,this.relativeDir,this.filename,t);this.paths.push(n)}addOutgoingEdge(e){let t=this.edges.find(t=>t.equals(e));t?t.incrementCount():this.edges.push(e)}getChildNodes(e=1){let t=[];for(let n of this.edges){let r=n.target;t.push(r),e>1&&t.push(...r.getChildNodes(e-1))}return t}},JIt=class{constructor(e,t,n){this.source=e,this.target=t,this.edgeType=n,this.count=0,this.count++}incrementCount(){this.count++}getCount(){return this.count}equals(e){return this.source.equals(e.source)&&this.target.equals(e.target)&&this.edgeType===e.edgeType}},YIt=class{constructor(e,t=[]){this.baseDir=e,this.nodes=Object.create(null),this.edges=[],this.fileResolutionMap=/* @__PURE__ */ new Map,this.redirectMap=/* @__PURE__ */ new Map,this.wildcardRedirects=[],this.configRedirects=[],this.mintIgnoreGlobs=[],this.virtualNodes=/* @__PURE__ */ new Set,this.snippetReferencesByFile=/* @__PURE__ */ new Map,this.baseDir=Et(e),this.mintIgnoreGlobs=t}addNode(e){return this.nodes[e]||(this.nodes[e]=new x2(e)),this.nodes[e]}addNodes(e){for(let t of e)this.addNode(t)}addVirtualNodes(e){for(let t of e)this.addNode(t),this.virtualNodes.add(new x2(t).toString())}setRedirects(e){this.configRedirects=e,this.redirectMap.clear();for(let t of e){let e=h2(t.source);this.redirectMap.has(e)||this.redirectMap.set(e,h2(t.destination))}this.wildcardRedirects=[...this.redirectMap].filter(([e])=>v2(e))}matchesWildcardPattern(e,t){let n=`^${t.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`).replace(/:(\w+)/g,`(?<$1>[^/]+)`).replace(/\\\*/g,`(.*)`)}$`;return new RegExp(n).test(e)}applyWildcardRedirect(e,t,n){let r=t.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`),i=[],a=r.replace(/:(\w+)/g,(e,t)=>(i.push({type:`param`,name:t}),`(?<${t}>[^/]+)`)).replace(/\\\*/g,()=>(i.push({type:`wildcard`}),`(.*)`)),o=RegExp(`^${a}$`),s=e.match(o);if(!s)return n;let c=n,l=s.groups||{};for(let[e,t]of Object.entries(l))c=c.replace(RegExp(`:${e}`,`g`),t);let u=s.slice(1),d=0,f=u.filter((e,t)=>i[t]&&i[t].type===`wildcard`);return c=c.replace(/\*/g,()=>f[d++]||``),c}addAliasNodes(){let e=b2.filterMapInternalPaths(WJe(this.baseDir,this.baseDir,this.mintIgnoreGlobs)).filter(e=>!MP(e,this.mintIgnoreGlobs));this.addNodes(e)}getNode(e){return this.nodes[e]}getAnchorTargetFiles(e){this.fileResolutionMap.size===0&&this.precomputeFileResolutions();let t=new Set(Object.keys(this.nodes)),n=/* @__PURE__ */ new Set;for(let r of Object.values(this.nodes))for(let i of r.paths.flatMap(e=>[e,...e.pagePaths]))if(i.pathType===_2.INTERNAL&&i.anchorLink&&e.has(xt(i.relativeDir,i.filename)))for(let e of this.getHeadingSlugCandidates(i.toString(),t)){let t=this.nodes[e];if(t&&(n.add(e),t.headingSlugs!==null))break}return n}addEdge(e,t,n=KIt.CONTENT){let r=new JIt(e,t,n);return this.edges.find(e=>e.equals(r)?(e.incrementCount(),!0):!1)||(this.edges.push(r),r)}addEdgesBetweenNodes(){let e=new qIt(m2(this.baseDir,this.mintIgnoreGlobs));for(let t of Object.values(this.nodes))for(let n of t.paths)if(n.pathType===_2.INTERNAL){let r=Object.values(this.nodes).find(t=>n.resolvesTo(t,e,this.baseDir));if(r){let e=this.addEdge(t,r);t.addOutgoingEdge(e)}}}precomputeFileResolutions(){let e=new qIt(m2(this.baseDir,this.mintIgnoreGlobs)),t=/* @__PURE__ */ new Set;Object.values(this.nodes).forEach(n=>{n.paths.flatMap(e=>[e,...e.pagePaths]).filter(e=>e.pathType===_2.INTERNAL).forEach(n=>{let r=n.toString();if(t.has(r))return;t.add(r);let i=n.getResolvedFiles(e,this.baseDir);this.fileResolutionMap.set(r,new Set(i))})})}getHeadingSlugCandidates(e,t){let n=[...this.fileResolutionMap.get(e)??[]].filter(e=>t.has(e)),r=xt(e,`index.mdx`),i=this.nodes[r]?r:xt(e,`index.md`);return[...n,e,i]}getHeadingSlugsForPath(e,t){for(let n of this.getHeadingSlugCandidates(e,t)){let e=this.nodes[n];if(e&&e.headingSlugs!==null)return e.headingSlugs}}getBrokenInternalLinks(e){this.fileResolutionMap.size===0&&this.precomputeFileResolutions();let t=/* @__PURE__ */ new Set,n=new Set(Object.values(this.nodes).map(e=>e.toString()));for(let r of Object.values(this.nodes))for(let i of r.paths.flatMap(e=>[e,...e.pagePaths]))if(i.pathType===_2.INTERNAL){let r=i.toString(),a=this.fileResolutionMap.get(r);if(!(r===`.`||a&&[...a].some(e=>n.has(e))||this.virtualNodes.has(r))&&!this.reachesPage(r))t.add(i);else if(e?.checkAnchors&&i.anchorLink){let e=$E(i.anchorLink.slice(1)),a=this.getHeadingSlugsForPath(r,n);a&&!a.has(e)&&t.add(i)}}return Object.values(this.nodes).flatMap(e=>e.paths).filter(e=>t.has(e)&&(e.pagePaths.length===0||e.pagePaths.some(e=>t.has(e))))}getPageCandidates(e){return e===`.`?[`index.mdx`,`index.md`]:[`${e}.mdx`,`${e}.md`,xt(e,`index.mdx`),xt(e,`index.md`)]}isPageRoute(e){return this.getPageCandidates(e).some(e=>this.nodes[e])||this.virtualNodes.has(e)}resolvesToValidPath(e,t=/* @__PURE__ */ new Set){if(URL.canParse(e))return!0;let n=UIt(e);return!n||v2(n)?!0:this.reachesPage(h2(n),t)}reachesPage(e,t=/* @__PURE__ */ new Set){if(t.has(e))return!1;t.add(e);let n=this.getExactRedirectTarget(e);if(n!==void 0)return this.resolvesToValidPath(n,t);if(e!==`.`&&this.nodes[e]||this.isPageRoute(e))return!0;let r=this.getRedirectTarget(e);return r!==void 0&&this.resolvesToValidPath(r,t)}getExactRedirectTarget(e){return this.redirectMap.get(e)}getRedirectTarget(e){let t=this.getExactRedirectTarget(e);if(t!==void 0)return t;for(let[t,n]of this.wildcardRedirects)if(this.matchesWildcardPattern(e,t))return this.applyWildcardRedirect(e,t,n)}getBrokenRedirects(){let e=[],t=/* @__PURE__ */ new Set;for(let{source:n,destination:r}of this.configRedirects){let i=h2(n);t.has(i)||(t.add(i),!URL.canParse(r)&&(v2(UIt(r))||this.resolvesToValidPath(r)||e.push({source:n,destination:r})))}return e}getExternalPathsByNode(){let e=/* @__PURE__ */ new Map;for(let[t,n]of Object.entries(this.nodes)){let r=n.paths.filter(e=>e.pathType===_2.EXTERNAL);r.length>0&&e.set(t,r)}return e}getAllInternalPaths(){return Object.values(this.nodes).flatMap(e=>e.paths).filter(e=>e.pathType===_2.INTERNAL).map(e=>e.originalPath+` => `+e.toString())}},S2=function(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})};const C2=e=>S2(void 0,void 0,void 0,function*(){for(let t of[`docs.json`,`mint.json`]){let n=gt.join(e,t);if(gF.default.existsSync(n))try{let{resolved:r}=yield hF(yield gF.default.readJSON(n),e);if(r&&typeof r==`object`&&!Array.isArray(r))return{configFile:t,json:r}}catch(e){console.warn(`Warning: Failed to read or resolve ${t}: ${e}`)}}return null}),XIt=e=>S2(void 0,void 0,void 0,function*(){let t=yield C2(e);return t?t.configFile===`docs.json`?Nd(jd(t.json)):Md(t.json):null}),ZIt=e=>S2(void 0,void 0,void 0,function*(){let t=yield C2(e);if(!t||t.configFile!==`docs.json`)return null;let n=Nd(jd(t.json));return n.success?n.data:null});var QIt=function(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})};const $It=e=>QIt(void 0,void 0,void 0,function*(){let t=yield ZIt(e);if(!t)return[];let{generatedRoutes:n}=yield cB(t,t=>lB(t,e),{onSourceError:(e,t)=>console.warn(`Warning: Failed to load GraphQL schema ${e}: ${t}`)});return n});var eLt=function(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})};const tLt=e=>typeof e==`string`&&e!==``&&Rf(e)===void 0&&uJe(e)===void 0,w2=e=>{if(typeof e!=`object`||!e)return[];if(Array.isArray(e))return e.flatMap(w2);let t=e,n=[];if(typeof t.href==`string`&&n.push(t.href),tLt(t.root)&&n.push(t.root.startsWith(`/`)?t.root:`/${t.root}`),Array.isArray(t.pages))for(let e of t.pages)tLt(e)&&n.push(e.startsWith(`/`)?e:`/${e}`);for(let e of Object.values(t))n.push(...w2(e));return n},nLt=e=>eLt(void 0,void 0,void 0,function*(){let t=yield C2(e);if(t&&t.json.navigation)return{hrefs:w2(t.json.navigation),configFile:t.configFile}});var rLt=function(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})};const iLt=(e,t)=>rLt(void 0,void 0,void 0,function*(){let n=[];try{let r=yield ZIt(e),i=r?mf(r):void 0,a=yield Ett(e,{explicitOverlays:i,fetchRemoteDocument:t?.fetchRemoteDocument});if(r){let o=yield Ttt(e,{explicitOverlays:i,fetchRemoteDocument:t?.fetchRemoteDocument}),s=yield aLt(r,o,t?.fetchRemoteDocument),c=[...a,...s],l={};try{yield v9e(r.navigation,c,l,{writeFiles:!1,overlayRegistry:o,fetchRemoteDocument:t?.fetchRemoteDocument})}catch(e){console.warn(`Warning: Failed to extract OpenAPI pages from navigation: ${e}`)}n.push(...Object.keys(l))}for(let e of a)try{let{pagesAcc:t}=yield UXe(e.spec,{openApiFilePath:e.originalFileLocation,writeFiles:!1,outDir:`api-reference`});n.push(...Object.keys(t))}catch(t){console.warn(`Warning: Failed to extract pages from OpenAPI spec ${e.originalFileLocation}: ${t}`)}}catch(e){console.warn(`Warning: Failed to categorize files for OpenAPI extraction: ${e}`)}return[...new Set(n)]}),aLt=(e,t,n)=>rLt(void 0,void 0,void 0,function*(){try{return yield uB(`docs`,e,void 0,t,n)}catch(e){return console.warn(`Warning: Failed to fetch URL-based OpenAPI specs: ${e}`),[]}});var oLt=function(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})};const sLt=e=>oLt(void 0,void 0,void 0,function*(){let t=[],n=yield XIt(e);return n&&n.success&&`redirects`in n.data&&n.data.redirects&&t.push(...n.data.redirects),t}),cLt=[`ImportDefaultSpecifier`,`ImportNamespaceSpecifier`],lLt=e=>{let t=[],n=[],r=[],i=/* @__PURE__ */ new Set;p2(e,e=>{if(at(e)&&st(e)){for(let n of e.data.estree.body){if(!f(n)||typeof n.source.value!=`string`)continue;let e=n.source.value;t.push(e);for(let t of n.specifiers)cLt.includes(t.type)&&r.push({source:e,name:t.local.name})}return}if(!g(e)||!e.name||(i.add(e.name),e.name!==`Snippet`))return;let a=e.attributes.find(e=>e.type===`mdxJsxAttribute`&&e.name===`file`)?.value;typeof a==`string`&&n.push(`/_snippets/`+g2(a))});for(let{source:e,name:t}of r)i.has(t)&&n.push(e);return{imported:t,rendered:n}},uLt=[`snippets/`,`_snippets/`],T2=e=>e.replaceAll(Pr,`/`),dLt=({originalPath:e,pathType:t,wrapper:n})=>n!==y2.IMPORT&&t===_2.INTERNAL&&!e.startsWith(`/`),fLt=(e,t)=>{var n;let r=new Map([...t.keys()].map(e=>[T2(e),e])),i=(e,t)=>e.flatMap(e=>{let n=XT(e,T2(t)),i=n&&r.get(g2(n));return i?[i]:[]}),a=/* @__PURE__ */ new Set;for(let[e,{imported:n}]of t){let t=T2(e).toLowerCase();uLt.some(e=>t.startsWith(e))&&a.add(e);for(let t of i(n,e))a.add(t)}let o=(e,n)=>{let r=t.get(e)?.rendered??[];for(let t of i(r,e))!n.has(t)&&a.has(t)&&(n.add(t),o(t,n));return n},s=/* @__PURE__ */ new Map;for(let e of t.keys())a.has(e)||s.set(e,o(e,/* @__PURE__ */ new Set));for(let[t,r]of s){let i=e.getNode(t);if(i)for(let t of r){let r=e.getNode(t);for(let e of r?.paths.filter(dLt)??[])e.pagePaths.push(new b2(e.originalPath,i.relativeDir,i.filename,e.wrapper));for(let e of r?.headingSlugs??[])(n=i.headingSlugs)==null||n.add(e)}}},pLt=(e,t,n)=>{let r=/* @__PURE__ */ new Set;if(!n.checkAnchors&&!n.checkSnippets)return r;let i=n.checkAnchors?[...e.getAnchorTargetFiles(t)]:[];for(let e of i)r.add(T2(e));let a=new Map([...e.snippetReferencesByFile.keys()].map(e=>[T2(e),e])),o=/* @__PURE__ */ new Set,s=t=>{if(o.has(t))return;o.add(t);let n=a.get(t),i=n?e.snippetReferencesByFile.get(n)?.rendered??[]:[];for(let e of i){let n=XT(e,t);if(!n)continue;let i=g2(n);r.add(i),s(i)}};for(let e of[...t,...i])s(T2(e));return r};var E2=function(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})};const mLt=e=>{let t=/* @__PURE__ */ new Set;for(let n of e){t.add(QE(n.slug));for(let e of mLt(n.children))t.add(e)}return t},hLt=/* @__PURE__ */ new Set([`ParamField`,`Param`,`ResponseField`]),gLt=/* @__PURE__ */ new Set([`query`,`path`,`body`,`header`,`name`]),_Lt=e=>{let t=/* @__PURE__ */ new Set,n=/* @__PURE__ */ new Map;return p2(e,`mdxJsxFlowElement`,e=>{if(hLt.has(e.name??``)){let r=e.attributes.find(e=>`name`in e&&gLt.has(e.name));if(r&&typeof r.value==`string`&&r.value){let e=n.get(r.value)??0;n.set(r.value,e+1),t.add(mDe(r.value,e))}return}if($Me.has(e.name??``))return;let r=e.attributes.find(e=>`name`in e&&e.name===`id`);if(r&&typeof r.value==`string`&&r.value){let n=eNe.has(e.name??``)?QE(r.value):r.value;t.add(n)}}),t},vLt=e=>{if(typeof e==`string`)return e;let t=(e?.data?.estree)?.body[0],n=t?.type===`ExpressionStatement`?t.expression:void 0;if(n?.type===`Literal`&&typeof n.value==`string`)return n.value;if(n?.type===`TemplateLiteral`&&n.expressions.length===0)return n.quasis[0]?.value.cooked??void 0},yLt=(e,t,n)=>E2(void 0,void 0,void 0,function*(){let r={},i=()=>t=>{let n=/* @__PURE__ */ new Set;return p2(t,[`linkReference`,`imageReference`],e=>{`identifier`in e&&n.add(e.identifier)}),p2(t,t=>{if(t.type===`link`||t.type===`image`){e.addPath(t.url,y2.MD);return}if(t.type===`definition`){n.delete(t.identifier)&&e.addPath(t.url,y2.MD);return}let r=t;if(r.name===`img`||r.name===`source`){let t=r.attributes.findIndex(e=>e.type===`mdxJsxAttribute`&&e.name===`src`),n=vLt(r.attributes[t]?.value);if(typeof n==`string`){e.addPath(n,y2.SRC);return}}else if(r.name===`a`||r.name===`Card`){let t=r.attributes.findIndex(e=>e.type===`mdxJsxAttribute`&&e.name===`href`),n=vLt(r.attributes[t]?.value);if(typeof n==`string`){e.addPath(n,y2.HREF);return}}}),t},a=b(Ly(t)),o=zT().use(CIt).use(i).use(Tje).use(Nje,r),s=o.parse(a),c=lLt(s);if(n?.checkSnippets)for(let t of c.imported)e.addPath(t,y2.IMPORT);yield o.run(s);let l=r.tableOfContents?mLt(r.tableOfContents):/* @__PURE__ */ new Set,u=_Lt(s);return e.headingSlugs=/* @__PURE__ */ new Set([...l,...u]),c}),bLt=(e,t)=>E2(void 0,void 0,void 0,function*(){let n=e||process.cwd(),r=yield yF(n),i=new YIt(n,r),a=m2(n,r).filter(e=>!MP(e,r));i.addNodes(a);let o=yield sLt(n);i.setRedirects(o),i.addAliasNodes();try{let e=yield iLt(n,{fetchRemoteDocument:t?.fetchRemoteDocument});i.addVirtualNodes(e)}catch(e){console.warn(`Warning: Failed to extract OpenAPI page paths: ${e}`)}try{let e=yield $It(n);i.addVirtualNodes(e)}catch(e){console.warn(`Warning: Failed to extract GraphQL page paths: ${e}`)}let s=yield nLt(n);if(s){let e=i.addNode(s.configFile);for(let t of s.hrefs){let n=t===`/`||t===``?`/index`:t.replace(/^\/#/,`/index#`);e.addPath(n)}}let c=WIt(n,r).filter(e=>!MP(e,r)),l=/* @__PURE__ */ new Map,u=0;return yield Promise.all(Array.from({length:Math.min(8,c.length)},()=>E2(void 0,void 0,void 0,function*(){for(;u<c.length;){let e=c[u++];if(e===void 0)continue;let r=i.getNode(e);if(!r)continue;let a=gF.default.readFileSync(gt.join(n,e)).toString();try{let n=yield yLt(r,a,{checkSnippets:t?.checkSnippets});l.set(e,n)}catch(n){let r=/* @__PURE__ */ Error(`Syntax error - Unable to parse ${e} - ${n}`);if(!t?.onParseError)throw r;t.onParseError(e,r)}}}))),fLt(i,l),i.snippetReferencesByFile=l,i});var D2=function(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})};const xLt=e=>{try{let t=new URL(e);return t.protocol===`http:`||t.protocol===`https:`}catch{return!1}},SLt=(e,t)=>D2(void 0,void 0,void 0,function*(){let n=new AbortController,r=setTimeout(()=>n.abort(),1e4);try{let r=yield fetch(e,{method:t,signal:n.signal,headers:{"User-Agent":`Mintlify-LinkChecker/1.0`},redirect:`follow`});return yield r.body?.cancel().catch(()=>void 0),r.status}finally{clearTimeout(r)}}),CLt=/* @__PURE__ */ new Set([404,405]),wLt=e=>D2(void 0,void 0,void 0,function*(){try{let t=yield SLt(e,`HEAD`),n=CLt.has(t)?yield SLt(e,`GET`).catch(()=>t):t;return{ok:n!==404,status:n}}catch(e){return{ok:!1,status:null,error:e instanceof Error?e.message:`unknown error`}}}),TLt=(e,t,n)=>D2(void 0,void 0,void 0,function*(){let r=[],i=0,a=()=>D2(void 0,void 0,void 0,function*(){for(;i<e.length;){let n=i++;r[n]=yield t(e[n])}}),o=Array.from({length:Math.min(n,e.length)},()=>a());return yield Promise.all(o),r}),ELt=(e,t)=>D2(void 0,void 0,void 0,function*(){let n=/* @__PURE__ */ new Map;for(let[r,i]of e.getExternalPathsByNode())if(!t?.sourceFiles||t.sourceFiles.has(r)){for(let e of i)if(xLt(e.originalPath)){let t=e.originalPath,i=n.get(t),a={file:r,originalPath:e.originalPath};i?i.push(a):n.set(t,[a])}}let r=[...n.keys()];return(yield TLt(r,e=>D2(void 0,void 0,void 0,function*(){let t=yield wLt(e);if(t.ok)return null;let r={url:e,status:t.status,sources:n.get(e)};return t.error&&(r.error=t.error),r}),5)).filter(e=>e!==null)});var O2=function(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})};const DLt=/[*?]/,OLt=/\.mdx?$/i,kLt=/[.+^${}()|\\[\]]/,ALt=/* @__PURE__ */ new Set([`.git`,`node_modules`]);function jLt(e){return e.split(It.sep).join(`/`)}function MLt(e){return jLt(e).replace(/^\.\//,``)}function NLt(e){let t=``,n=0;for(;n<e.length;){let r=e[n];r===`*`?e[n+1]===`*`?e[n+2]===`/`?(t+=`(?:[^/]+/)*`,n+=3):(t+=`.*`,n+=2):(t+=`[^/]*`,n+=1):r===`?`?(t+=`[^/]`,n+=1):(t+=kLt.test(r)?`\\${r}`:r,n+=1)}return RegExp(`^${t}$`)}function PLt(e){return O2(this,void 0,void 0,function*(){try{return(yield Hn.stat(e)).isFile()}catch{return!1}})}function FLt(e){return O2(this,arguments,void 0,function*(e,t=``){let n=yield Hn.readdir(It.join(e,t),{withFileTypes:!0}),r=[];for(let i of n){if(ALt.has(i.name))continue;let n=t?`${t}/${i.name}`:i.name;i.isDirectory()?r.push(...yield FLt(e,n)):r.push(n)}return r})}var ILt=class extends Error{};function LLt(e,t){return O2(this,void 0,void 0,function*(){let n=null,r=[],i=[];for(let a of t){let t=MLt(a);if(DLt.test(t)){n??=yield FLt(e);let o=NLt(t),s=n.filter(e=>OLt.test(e)&&o.test(e)).sort();s.length===0?i.push(a):r.push(...s)}else(yield PLt(It.join(e,t)))?r.push(t):i.push(a)}if(i.length>0)throw new ILt(`No matching files for: ${i.join(`, `)} (globs match .md and .mdx files)`);return[...new Set(r)]})}var RLt=function(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})};const zLt=e=>RLt(void 0,void 0,void 0,function*(){yield bjt(),jH((0,z.jsx)(xH,{message:`checking for broken links...`}));try{let t=yield vjt(o1),n=(e.files??[]).map(String).filter(Boolean),r=n.length>0?new Set((yield LLt(o1,n)).map(e=>gt.relative(t,gt.resolve(o1,e)))):void 0,i=/* @__PURE__ */ new Map,a=yield bLt(t,{checkSnippets:e[`check-snippets`],onParseError:(e,t)=>i.set(e,t.message)});a.precomputeFileResolutions();let o=r?pLt(a,r,{checkAnchors:e[`check-anchors`],checkSnippets:e[`check-snippets`]}):void 0,s=[...i].filter(([e])=>!r||r.has(e)||o?.has(e.split(gt.sep).join(`/`))).map(([,e])=>e),c=a.getBrokenInternalLinks({checkAnchors:e[`check-anchors`]}).filter(({relativeDir:e,filename:t})=>!r||r.has(gt.join(e,t))),l={};if(c.forEach(e=>{let t=gt.join(e.relativeDir,e.filename),n=l[t];n?n.push(e.originalPath):l[t]=[e.originalPath]}),e[`check-external`]){let e=yield ELt(a,r?{sourceFiles:r}:void 0);for(let t of e)for(let e of t.sources){let n=t.status?`${t.url} (${t.status})`:`${t.url} (${t.error})`,r=l[e.file];r?r.push(n):l[e.file]=[n]}}if(e[`check-redirects`]){let e=a.getBrokenRedirects();if(e.length>0){let n=yield Hn.access(gt.join(t,`docs.json`)).then(()=>`docs.json`).catch(()=>`mint.json`),r=e.map(({source:e,destination:t})=>`${e} → ${t}`),i=l[n];i?i.push(...r):l[n]=r}}let u=Object.keys(l).length>0;!u&&s.length===0&&(FH(),jH((0,z.jsx)(bH,{message:`no broken links found`})),yield f1(0)),FH(),jH(u?(0,z.jsx)(cat,{brokenLinksByFile:l}):(0,z.jsx)(bH,{message:`no broken links found in the files that parsed`}));for(let e of s)jH((0,z.jsx)(CH,{message:e}));s.length>0&&jH((0,z.jsx)(SH,{message:`skipped ${s.length} file(s) that could not be parsed; links in them were not checked`}))}catch(e){jH((0,z.jsx)(CH,{message:e instanceof Error?e.message:`unknown error`})),yield f1(1)}yield f1(1)});var BLt=function(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})};function VLt(e,t){return()=>BLt(this,void 0,void 0,function*(){N1()?jH((0,z.jsx)(bH,{message:`Thanks for your interest in "${t} ${e}"! Your vote has been counted.`})):jH((0,z.jsx)(SH,{message:`Telemetry is disabled, so your vote won't be counted. Enable it with: ${t} --telemetry=true`})),jH((0,z.jsx)(gH,{dimColor:!0,children:`This feature is currently in development. Learn more at https://mintlify.com/docs`})),yield f1(0)})}var k2=function(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})};const HLt=Ne({status:nt(`ready`),deploymentId:He().min(1),subdomain:He().min(1),remote:I(),branch:nt(`main`),expiresAt:Pe(),orgSlug:He().min(1).optional()}),ULt=ke(`status`,[HLt.extend({code:nt(`deployment_already_exists`)}),Ne({status:nt(`provisioning`),code:nt(`deployment_already_exists`),deploymentId:He().optional(),subdomain:He().optional()}),Ne({status:nt(`expired`),code:Te([`deployment_already_exists`,`deployment_claim_expired`]),deploymentId:He(),subdomain:He(),expiresAt:Pe().optional()})]),WLt=Ne({remote:I(),branch:nt(`main`),token:He().min(1),tokenExpiresAt:Pe()}),GLt=Ne({subdomain:He().min(1),trustedRepos:Ke(Ne({repositoryId:He(),repository:He(),branch:He()}))});function KLt(e,t,n){return k2(this,void 0,void 0,function*(){for(let r=0;r<4;r++){let i=yield B1(`${e}/api/agent/deployments/provision`,{method:`POST`,headers:{Authorization:`Bearer ${t}`,"Content-Type":`application/json`},body:JSON.stringify(Object.assign(Object.assign({},n),{docsPath:``}))});if(i.status!==409)return Object.assign(Object.assign({},yield V1(i,HLt)),{created:!0});let a=yield i.json().catch(()=>null),o=ULt.safeParse(a);if(!o.success)throw Error(`The deployment service returned an unexpected response.`);if(o.data.status!==`provisioning`)return Object.assign(Object.assign({},o.data),{created:!1});r<3&&(yield Fr(1e3*(r+1)))}throw Error(`Your site is still provisioning. Run the same command again.`)})}function qLt(e,t){return k2(this,void 0,void 0,function*(){return V1(yield B1(`${e}/api/agent/deployments/token`,{method:`POST`,headers:{Authorization:`Bearer ${t}`}}),WLt)})}function JLt(e,t,n){return k2(this,void 0,void 0,function*(){return V1(yield B1(`${e}/api/agent/deployments/github-actions/token`,{method:`POST`,headers:{Authorization:`Bearer ${t}`,"Content-Type":`application/json`},body:JSON.stringify({subdomain:n})}),WLt)})}function YLt(e,t,n){return k2(this,void 0,void 0,function*(){return V1(yield B1(`${e}/api/agent/deployments/trusted-repos`,{method:`POST`,headers:{Authorization:`Bearer ${t}`,"Content-Type":`application/json`},body:JSON.stringify(n)}),GLt)})}var XLt=function(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})};function ZLt(e,t){return XLt(this,arguments,void 0,function*(e,t,n=()=>{}){let{apiUrl:r}=e,i=It.resolve(e.directory),a=JSON.stringify([new URL(r).origin,i]),o=Gjt(a);n(`Authenticating agent...`);let s=e.newSite?null:yield SMt(r,i).catch(()=>{if(o)throw Error(`Could not read this site’s saved credentials. Unlock your keyring or use --new for another site.`);return t(`Could not read the keyring. Continuing with a new registration for this run.`),null}),c=e.subdomain??(e.newSite?void 0:o?.subdomain);if(!c)throw Error(`Choose a site name with --subdomain <name>.`);let l=yield U1(r),u=e.base?`workspace`:`site`,d=e=>CMt(r,i,e);for(let i=0;i<2;i++){let i=s??(yield fMt(l));n0(`agent_signup.discovered`,{registration_id:i.registrationId}),s||n0(`agent_signup.registered`,{registration_id:i.registrationId}),yield d(i);let o=yield pMt(l,i);yield d(o);let f=yield mMt(r,o.accessToken);if(f.registrationId!==i.registrationId)throw Error(`Agent identity does not match the saved registration.`);if(f.identityType===`user_bound`)return{status:`claimed`};n(`Provisioning the ${e.base?`base`:`site`} and repository...`);let p=yield KLt(r,o.accessToken,Object.assign({subdomain:c,orgName:e.orgName},e.base&&{projectType:u}));if(p.status===`expired`){t(`The previous anonymous site expired. Creating a new registration and site.`),s=null;continue}n0(`cli.deploy.provisioned`,{registration_id:i.registrationId,deployment_id:p.deploymentId,subdomain:p.subdomain,created:p.created}),yield Kjt(a,{registrationId:i.registrationId,subdomain:p.subdomain}).catch(()=>t(`Could not save the site name locally. Provide --subdomain on your next invocation.`)),n(`Getting repository write access...`);let m=yield qLt(r,o.accessToken);if(m.remote!==p.remote)throw Error(`Repository credentials do not match the provisioned site.`);return{status:`ready`,projectType:u,site:p,write:m,created:p.created,credentials:o}}throw Error(`The new anonymous site is already expired. Please retry later.`)})}function A2(e,t){let n=new URL(e).hostname===`leaves-dev.mintlify.com`?`mint-dev.mintlify.me`:`mintlify.site`;return new URL(`https://${t}.${n}`).toString()}function QLt(e){return e.orgSlug?new URL(`/${e.orgSlug}/${e.subdomain}/editor`,T1).toString():new URL(T1).toString()}function $Lt(e,t){if(e.status===`claimed`)return`This site has been claimed. Manage it in the Mintlify dashboard. Use mint deploy --new --subdomain <name> to create another site.`;let{site:n,write:r}=e,i=[`Repository: ${n.remote}`,`Branch: ${n.branch}`,`Write token: ${r.token}`,`Write token expires: ${r.tokenExpiresAt}`];if(e.projectType===`workspace`)return[e.created?`Base provisioned.`:`Using the existing anonymous base.`,`Editor: ${QLt(n)}`,`Expires: ${n.expiresAt}. Claim it before then or it is deleted.`].join(`
|
|
2201
|
+
`&&n.column++,n.offset++,o=u,s=l,i++}return o&&r<i&&t.push(c(o,e.slice(r,i))),t;function c(e,t){return e===`WordNode`?{type:`WordNode`,children:[{type:`TextNode`,value:t,position:{start:a,end:{...n}}}],position:{start:a,end:{...n}}}:{type:e,value:t,position:{start:a,end:{...n}}}}}};c2.prototype.tokenizeSentencePlugins=[KFt,UFt,JFt,YFt,qFt,s2],c2.prototype.tokenizeParagraphPlugins=[XFt,zFt,GFt,WFt,QFt,DFt,$Ft,HFt,VFt,BFt,eIt,s2],c2.prototype.tokenizeRootPlugins=[HFt,VFt,eIt,s2];function nIt(e,t,n){let r=[],i=-1,a=0;for(;++i<e.children.length;){let o=e.children[i];if(i===e.children.length-1||o.type===t&&n.test(i2(o))){let t={type:e.type,children:e.children.slice(a,i+1)},n=e.children[a],s=o;n.position&&s.position&&(t.position={start:n.position.start,end:s.position.end}),r.push(t),a=i+1}}return r}function rIt(){let e=this;e.parser=t;function t(t){let n=new c2;return l2(n.tokenizeParagraphPlugins,e.data(`nlcstParagraphExtensions`)),l2(n.tokenizeRootPlugins,e.data(`nlcstRootExtensions`)),l2(n.tokenizeSentencePlugins,e.data(`nlcstSentenceExtensions`)),n.parse(t)}}function l2(e,t){t&&e.unshift(...t)}function iIt(){let e=this;e.compiler=aIt}function aIt(e){return i2(e)}const oIt=tt().use(rIt).use(iIt).freeze(),sIt=[`”`,`’`],cIt=[`“`,`‘`],lIt={};function uIt(e){let t=e||lIt,n=[];if(t.quotes!==!1&&n.push(yIt),t.ellipses===`spaced`?n.push(_It):t.ellipses===`unspaced`?n.push(vIt):t.ellipses!==!1&&n.push(gIt),t.backticks===`all`){if(t.quotes!==!1)throw Error("Cannot accept `backticks: 'all'` with `quotes: true`");n.push(dIt)}else t.backticks!==!1&&n.push(fIt);t.dashes===`inverted`?n.push(mIt):t.dashes===`oldschool`?n.push(hIt):t.dashes!==!1&&n.push(pIt);let r={close:t.closingQuotes?[t.closingQuotes.double,t.closingQuotes.single]:sIt,open:t.openingQuotes?[t.openingQuotes.double,t.openingQuotes.single]:cIt};return function(e){ue(e,function(e,t,i){let a=-1;if(i&&t!==void 0&&(e.type===`PunctuationNode`||e.type===`SymbolNode`)){for(;++a<n.length;)if(n[a](r,e,t,i)===!0)return console.log(`drop`,e),i.children.splice(t,1),t}})}}function dIt(e,t,n,r){fIt(e,t,n,r),t.value==="`"?t.value=`‘`:t.value===`'`&&(t.value=`’`)}function fIt(e,t){t.value==="``"?t.value=`“`:t.value===`''`&&(t.value=`”`)}function pIt(e,t){t.value===`--`&&(t.value=`—`)}function mIt(e,t,n,r){let i=r.children[n+1];if(t.value===`—`&&i&&i.type===`PunctuationNode`&&i.value===`-`)return i.value=`–`,!0;t.value===`---`?t.value=`–`:t.value===`--`&&(t.value=`—`)}function hIt(e,t,n,r){let i=r.children[n+1];if(t.value===`–`&&i&&i.type===`PunctuationNode`&&i.value===`-`)return i.value=`—`,!0;t.value===`---`?t.value=`—`:t.value===`--`&&(t.value=`–`)}function gIt(e,t,n,r){_It(e,t,n,r),vIt(e,t,n,r)}function _It(e,t,n,r){let i=t.value,a=r.children;if(!/^\.+$/.test(i))return;let o=[],s=n,c=1;for(;--s>0;){let e=a[s];if(e.type!==`WhiteSpaceNode`)break;let t=e;if(e=a[--s],e&&(e.type===`PunctuationNode`||e.type===`SymbolNode`)&&/^\.+$/.test(e.value))o.push(t,e),c++;else break}c<3||(a.splice(n-o.length,o.length),t.value=`…`)}function vIt(e,t){/^\.{3,}$/.test(t.value)&&(t.value=`…`)}function yIt(e,t,n,r){let i=r.children,a=t.value;if(a!==`"`&&a!==`'`)return;let o=a===`"`?0:1,s=i[n-1],c=i[n+1],l=i[n+2],u=c?i2(c):``;c&&(c.type===`PunctuationNode`||c.type===`SymbolNode`)&&(!l||l.type!==`WordNode`)?t.value=e.close[o]:c&&(c.type===`PunctuationNode`||c.type===`SymbolNode`)&&(u===`"`||u===`'`)&&l&&l.type===`WordNode`?(t.value=e.open[o],c.value=e.open[u===`"`?0:1]):t.value=c&&/^\d\ds$/.test(u)?e.close[o]:s&&(s.type===`WhiteSpaceNode`||s.type===`PunctuationNode`||s.type===`SymbolNode`)&&c&&c.type===`WordNode`?e.open[o]:s&&s.type!==`WhiteSpaceNode`&&s.type!==`SymbolNode`&&s.type!==`PunctuationNode`||!c||c.type===`WhiteSpaceNode`||a===`'`&&u===`s`?e.close[o]:e.open[o]}const bIt=/* @__PURE__ */ new Set([`text`,`inlineCode`,`paragraph`]),xIt=/* @__PURE__ */ new Set([`style`,`script`]),SIt=(e,t,n)=>n&&(n.type!==`mdxJsxTextElement`||`name`in n&&typeof n.name==`string`&&!xIt.has(n.name))&&bIt.has(e.type)&&(u2(e)||d2(e)),CIt=e=>{let t=oIt().use(uIt,{...e,ellipses:!1,dashes:!1,backticks:!1}),n=oIt().use(uIt,{...e,quotes:!1});return e=>{let r=``,i=0,a=[];ue(e,SIt,e=>{u2(e)?r+=e.type===`text`?e.value:`A`.repeat(e.value.length):d2(e)&&(r+=` `),a.push(e)}),/["']/.test(r)&&(r=t.processSync(r).toString());for(let e of a)if(u2(e)){let t=i+e.value.length;if(e.type===`text`){let a=r.slice(i,t);e.value=/\.[\s\u0085]*\.|--|``|''/.test(a)?n.processSync(a).toString():a}i=t}else d2(e)&&(i+=1)}};function u2(e){return`value`in e&&typeof e.value==`string`}function d2(e){return e.type===`paragraph`}const wIt=(function(e){if(e==null)return OIt;if(typeof e==`string`)return DIt(e);if(typeof e==`object`)return Array.isArray(e)?TIt(e):EIt(e);if(typeof e==`function`)return f2(e);throw Error(`Expected function, string, or object as test`)});function TIt(e){let t=[],n=-1;for(;++n<e.length;)t[n]=wIt(e[n]);return f2(r);function r(...e){let n=-1;for(;++n<t.length;)if(t[n].call(this,...e))return!0;return!1}}function EIt(e){return f2(t);function t(t){let n;for(n in e)if(t[n]!==e[n])return!1;return!0}}function DIt(e){return f2(t);function t(t){return t&&t.type===e}}function f2(e){return t;function t(t,...n){return!!(t&&typeof t==`object`&&`type`in t&&e.call(this,t,...n))}}function OIt(){return!0}function kIt(e){return`\x1B[33m`+e+`\x1B[39m`}const AIt=(function(e,t,n,r){typeof t==`function`&&typeof n!=`function`&&(r=n,n=t,t=null);let i=wIt(t),a=r?-1:1;o(e,void 0,[])();function o(e,s,c){let l=e&&typeof e==`object`?e:{};if(typeof l.type==`string`){let t=typeof l.tagName==`string`?l.tagName:typeof l.name==`string`?l.name:void 0;Object.defineProperty(u,"name",{value:`node (`+kIt(e.type+(t?`<`+t+`>`:``))+`)`})}return u;function u(){let l=[],u,d,f;if((!t||i(e,s,c[c.length-1]||null))&&(l=jIt(n(e,c)),l[0]===!1))return l;if(e.children&&l[0]!==`skip`)for(d=(r?e.children.length:-1)+a,f=c.concat(e);d>-1&&d<e.children.length;){if(u=o(e.children[d],d,f)(),u[0]===!1)return u;d=typeof u[1]==`number`?u[1]:d+a}return l}}});function jIt(e){return Array.isArray(e)?e:typeof e==`number`?[!0,e]:[e]}const p2=(function(e,t,n,r){typeof t==`function`&&typeof n!=`function`&&(r=n,n=t,t=null),AIt(e,t,i,r);function i(e,t){let r=t[t.length-1];return n(e,r?r.children.indexOf(e):null,r)}}),MIt=[`.mdx`,`.md`],NIt=[`.jpeg`,`.jpg`,`.jfif`,`.pjpeg`,`.pjp`,`.png`,`.svg`,`.svgz`,`.ico`,`.webp`,`.gif`,`.apng`,`.avif`,`.bmp`,`.mp4`,`.css`,`.xml`],PIt=e=>!(e.dir===`node_modules`||e.dir.startsWith(`node_modules/`)),FIt=e=>!(e.dir===`.github`||e.dir.startsWith(`.github/`)),IIt=e=>MIt.includes(e.ext),LIt=e=>NIt.includes(e.ext),RIt=e=>IIt(e)||LIt(e),zIt=e=>e.map(h2).map(Ct).filter(PIt),BIt=e=>zIt(e).filter(IIt).filter(FIt),VIt=e=>zIt(e).filter(RIt).filter(FIt),HIt=e=>xt(e.dir,e.base),UIt=e=>e.split(`#`)[0].split(`?`)[0],WIt=(e,t=[])=>BIt(RP(e,e,t)).map(HIt),m2=(e,t=[])=>VIt(RP(e,e,t)).map(HIt),h2=e=>St(g2(e)),g2=e=>e.startsWith(`/`)?e.slice(1):e;var _2;(function(e){e.INTERNAL=`internal`,e.EXTERNAL=`external`,e.DATA=`data`})(_2||={});const GIt=e=>{try{return decodeURIComponent(e)}catch{return e}},v2=e=>/[:*]/.test(e);var y2;(function(e){e.MD=`md`,e.SRC=`src`,e.HREF=`href`,e.CARD=`card`,e.IMPORT=`import`})(y2||={});var KIt;(function(e){e.CONTENT=`content`,e.NAVIGATION=`navigation`})(KIt||={});var b2=class e{static getPathType(e){let t;return t=URL.canParse(e)?_2.EXTERNAL:e.startsWith(`data:`)?_2.DATA:_2.INTERNAL,t}constructParsedPath(){let t=e.getPathType(this.originalPath),n,r;if(t===_2.INTERNAL){let e=new URL(`mintlify:/`);e.pathname=`/${this.relativeDir}/${this.filename}`.replaceAll(Pr,`/`),n=new URL(this.originalPath.replaceAll(Pr,`/`),e);let t=GIt(n.pathname).slice(1);t.endsWith(`/`)&&(t=t.slice(0,-1)),t===``&&(t=`.`),r=Ct(t)}else try{n=new URL(this.originalPath),r=n}catch{throw Error(`Failed to parse path as URL: ${this.originalPath}. If this is a purposefully malformed path, please wrap it in backticks, i.e \`${this.originalPath}\` `)}let i=n.hash?t===_2.INTERNAL?GIt(n.hash):n.hash:void 0,a=n.searchParams;return{path:r,pathType:t,anchorLink:i,queryParams:a}}constructor(e,t=``,n=``,r){this.originalPath=e,this.relativeDir=t,this.filename=n,this.wrapper=r,this.pagePaths=[],this.relativeDir=h2(t);let{path:i,pathType:a,anchorLink:o,queryParams:s}=this.constructParsedPath();this.path=i,this.pathType=a,this.anchorLink=o,this.queryParams=s}toString(){if(this.pathType===_2.INTERNAL){let e=this.path;return xt(e.dir,e.base)}return this.path.toString()}getResolvedFiles(e,t){if(this.pathType!==_2.INTERNAL||this.path instanceof URL)return[];let{dir:n,name:r,base:i}=Ct(this.toString()),a=[];return Jt(Et(t,this.toString()))&&a.push(xt(n,i)),a.push(...e.lookup(n,r,i)),a}resolvesTo(e,t,n){return this.pathType===_2.INTERNAL&&!!(this.toString()===e.toString()||this.getResolvedFiles(t,n).includes(e.toString()))}static filterMapInternalPaths(t){return t.map(t=>new e(t)).filter(({pathType:e})=>e===_2.INTERNAL).map(e=>e.toString())}},qIt=class e{constructor(t){this.byDirAndName=/* @__PURE__ */ new Map,t.forEach((t,n)=>{let r=t.startsWith(`/`)?t.slice(1):t,{dir:i,name:a}=Ct(r),o=e.key(i,a),s=[n,r],c=this.byDirAndName.get(o);c?c.push(s):this.byDirAndName.set(o,[s])})}static key(e,t){return`${e}\0${t}`}lookup(t,n,r){let i=this.byDirAndName.get(e.key(t,n))??[],a=r===n?[]:this.byDirAndName.get(e.key(t,r))??[];return[...i,...a].sort(([e],[t])=>e-t).map(([,e])=>e)}},x2=class{constructor(e,t=[]){this.label=e,this.paths=t,this.edges=[],this.headingSlugs=null,this.relativeDir=h2(vt(e)),this.filename=_t(e),this.label=xt(this.relativeDir,this.filename)}toString(){return this.label}equals(e){return this.label===e.label}addPath(e,t){let n=new b2(e,this.relativeDir,this.filename,t);this.paths.push(n)}addOutgoingEdge(e){let t=this.edges.find(t=>t.equals(e));t?t.incrementCount():this.edges.push(e)}getChildNodes(e=1){let t=[];for(let n of this.edges){let r=n.target;t.push(r),e>1&&t.push(...r.getChildNodes(e-1))}return t}},JIt=class{constructor(e,t,n){this.source=e,this.target=t,this.edgeType=n,this.count=0,this.count++}incrementCount(){this.count++}getCount(){return this.count}equals(e){return this.source.equals(e.source)&&this.target.equals(e.target)&&this.edgeType===e.edgeType}},YIt=class{constructor(e,t=[]){this.baseDir=e,this.nodes=Object.create(null),this.edges=[],this.fileResolutionMap=/* @__PURE__ */ new Map,this.redirectMap=/* @__PURE__ */ new Map,this.wildcardRedirects=[],this.configRedirects=[],this.mintIgnoreGlobs=[],this.virtualNodes=/* @__PURE__ */ new Set,this.snippetReferencesByFile=/* @__PURE__ */ new Map,this.baseDir=Et(e),this.mintIgnoreGlobs=t}addNode(e){return this.nodes[e]||(this.nodes[e]=new x2(e)),this.nodes[e]}addNodes(e){for(let t of e)this.addNode(t)}addVirtualNodes(e){for(let t of e)this.addNode(t),this.virtualNodes.add(new x2(t).toString())}setRedirects(e){this.configRedirects=e,this.redirectMap.clear();for(let t of e){let e=h2(t.source);this.redirectMap.has(e)||this.redirectMap.set(e,h2(t.destination))}this.wildcardRedirects=[...this.redirectMap].filter(([e])=>v2(e))}matchesWildcardPattern(e,t){let n=`^${t.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`).replace(/:(\w+)/g,`(?<$1>[^/]+)`).replace(/\\\*/g,`(.*)`)}$`;return new RegExp(n).test(e)}applyWildcardRedirect(e,t,n){let r=t.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`),i=[],a=r.replace(/:(\w+)/g,(e,t)=>(i.push({type:`param`,name:t}),`(?<${t}>[^/]+)`)).replace(/\\\*/g,()=>(i.push({type:`wildcard`}),`(.*)`)),o=RegExp(`^${a}$`),s=e.match(o);if(!s)return n;let c=n,l=s.groups||{};for(let[e,t]of Object.entries(l))c=c.replace(RegExp(`:${e}`,`g`),t);let u=s.slice(1),d=0,f=u.filter((e,t)=>i[t]&&i[t].type===`wildcard`);return c=c.replace(/\*/g,()=>f[d++]||``),c}addAliasNodes(){let e=b2.filterMapInternalPaths(WJe(this.baseDir,this.baseDir,this.mintIgnoreGlobs)).filter(e=>!MP(e,this.mintIgnoreGlobs));this.addNodes(e)}getNode(e){return this.nodes[e]}getAnchorTargetFiles(e){this.fileResolutionMap.size===0&&this.precomputeFileResolutions();let t=new Set(Object.keys(this.nodes)),n=/* @__PURE__ */ new Set;for(let r of Object.values(this.nodes))for(let i of r.paths.flatMap(e=>[e,...e.pagePaths]))if(i.pathType===_2.INTERNAL&&i.anchorLink&&e.has(xt(i.relativeDir,i.filename)))for(let e of this.getHeadingSlugCandidates(i.toString(),t)){let t=this.nodes[e];if(t&&(n.add(e),t.headingSlugs!==null))break}return n}addEdge(e,t,n=KIt.CONTENT){let r=new JIt(e,t,n);return this.edges.find(e=>e.equals(r)?(e.incrementCount(),!0):!1)||(this.edges.push(r),r)}addEdgesBetweenNodes(){let e=new qIt(m2(this.baseDir,this.mintIgnoreGlobs));for(let t of Object.values(this.nodes))for(let n of t.paths)if(n.pathType===_2.INTERNAL){let r=Object.values(this.nodes).find(t=>n.resolvesTo(t,e,this.baseDir));if(r){let e=this.addEdge(t,r);t.addOutgoingEdge(e)}}}precomputeFileResolutions(){let e=new qIt(m2(this.baseDir,this.mintIgnoreGlobs)),t=/* @__PURE__ */ new Set;Object.values(this.nodes).forEach(n=>{n.paths.flatMap(e=>[e,...e.pagePaths]).filter(e=>e.pathType===_2.INTERNAL).forEach(n=>{let r=n.toString();if(t.has(r))return;t.add(r);let i=n.getResolvedFiles(e,this.baseDir);this.fileResolutionMap.set(r,new Set(i))})})}getHeadingSlugCandidates(e,t){let n=[...this.fileResolutionMap.get(e)??[]].filter(e=>t.has(e)),r=xt(e,`index.mdx`),i=this.nodes[r]?r:xt(e,`index.md`);return[...n,e,i]}getHeadingSlugsForPath(e,t){for(let n of this.getHeadingSlugCandidates(e,t)){let e=this.nodes[n];if(e&&e.headingSlugs!==null)return e.headingSlugs}}getBrokenInternalLinks(e){this.fileResolutionMap.size===0&&this.precomputeFileResolutions();let t=/* @__PURE__ */ new Set,n=new Set(Object.values(this.nodes).map(e=>e.toString()));for(let r of Object.values(this.nodes))for(let i of r.paths.flatMap(e=>[e,...e.pagePaths]))if(i.pathType===_2.INTERNAL){let r=i.toString(),a=this.fileResolutionMap.get(r);if(!(r===`.`||a&&[...a].some(e=>n.has(e))||this.virtualNodes.has(r))&&!this.reachesPage(r))t.add(i);else if(e?.checkAnchors&&i.anchorLink){let e=$E(i.anchorLink.slice(1)),a=this.getHeadingSlugsForPath(r,n);a&&!a.has(e)&&t.add(i)}}return Object.values(this.nodes).flatMap(e=>e.paths).filter(e=>t.has(e)&&(e.pagePaths.length===0||e.pagePaths.some(e=>t.has(e))))}getPageCandidates(e){return e===`.`?[`index.mdx`,`index.md`]:[`${e}.mdx`,`${e}.md`,xt(e,`index.mdx`),xt(e,`index.md`)]}isPageRoute(e){return this.getPageCandidates(e).some(e=>this.nodes[e])||this.virtualNodes.has(e)}resolvesToValidPath(e,t=/* @__PURE__ */ new Set){if(URL.canParse(e))return!0;let n=UIt(e);return!n||v2(n)?!0:this.reachesPage(h2(n),t)}reachesPage(e,t=/* @__PURE__ */ new Set){if(t.has(e))return!1;t.add(e);let n=this.getExactRedirectTarget(e);if(n!==void 0)return this.resolvesToValidPath(n,t);if(e!==`.`&&this.nodes[e]||this.isPageRoute(e))return!0;let r=this.getRedirectTarget(e);return r!==void 0&&this.resolvesToValidPath(r,t)}getExactRedirectTarget(e){return this.redirectMap.get(e)}getRedirectTarget(e){let t=this.getExactRedirectTarget(e);if(t!==void 0)return t;for(let[t,n]of this.wildcardRedirects)if(this.matchesWildcardPattern(e,t))return this.applyWildcardRedirect(e,t,n)}getBrokenRedirects(){let e=[],t=/* @__PURE__ */ new Set;for(let{source:n,destination:r}of this.configRedirects){let i=h2(n);t.has(i)||(t.add(i),!URL.canParse(r)&&(v2(UIt(r))||this.resolvesToValidPath(r)||e.push({source:n,destination:r})))}return e}getExternalPathsByNode(){let e=/* @__PURE__ */ new Map;for(let[t,n]of Object.entries(this.nodes)){let r=n.paths.filter(e=>e.pathType===_2.EXTERNAL);r.length>0&&e.set(t,r)}return e}getAllInternalPaths(){return Object.values(this.nodes).flatMap(e=>e.paths).filter(e=>e.pathType===_2.INTERNAL).map(e=>e.originalPath+` => `+e.toString())}},S2=function(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})};const C2=e=>S2(void 0,void 0,void 0,function*(){for(let t of[`docs.json`,`mint.json`]){let n=gt.join(e,t);if(gF.default.existsSync(n))try{let{resolved:r}=yield hF(yield gF.default.readJSON(n),e);if(r&&typeof r==`object`&&!Array.isArray(r))return{configFile:t,json:r}}catch(e){console.warn(`Warning: Failed to read or resolve ${t}: ${e}`)}}return null}),XIt=e=>S2(void 0,void 0,void 0,function*(){let t=yield C2(e);return t?t.configFile===`docs.json`?Nd(jd(t.json)):Md(t.json):null}),ZIt=e=>S2(void 0,void 0,void 0,function*(){let t=yield C2(e);if(!t||t.configFile!==`docs.json`)return null;let n=Nd(jd(t.json));return n.success?n.data:null});var QIt=function(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})};const $It=e=>QIt(void 0,void 0,void 0,function*(){let t=yield ZIt(e);if(!t)return[];let{generatedRoutes:n}=yield cB(t,t=>lB(t,e),{onSourceError:(e,t)=>console.warn(`Warning: Failed to load GraphQL schema ${e}: ${t}`)});return n});var eLt=function(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})};const tLt=e=>typeof e==`string`&&e!==``&&Rf(e)===void 0&&uJe(e)===void 0,w2=e=>{if(typeof e!=`object`||!e)return[];if(Array.isArray(e))return e.flatMap(w2);let t=e,n=[];if(typeof t.href==`string`&&n.push(t.href),tLt(t.root)&&n.push(t.root.startsWith(`/`)?t.root:`/${t.root}`),Array.isArray(t.pages))for(let e of t.pages)tLt(e)&&n.push(e.startsWith(`/`)?e:`/${e}`);for(let e of Object.values(t))n.push(...w2(e));return n},nLt=e=>eLt(void 0,void 0,void 0,function*(){let t=yield C2(e);if(t&&t.json.navigation)return{hrefs:w2(t.json.navigation),configFile:t.configFile}});var rLt=function(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})};const iLt=(e,t)=>rLt(void 0,void 0,void 0,function*(){let n=[];try{let r=yield ZIt(e),i=r?mf(r):void 0,a=yield Ett(e,{explicitOverlays:i,fetchRemoteDocument:t?.fetchRemoteDocument});if(r){let o=yield Ttt(e,{explicitOverlays:i,fetchRemoteDocument:t?.fetchRemoteDocument}),s=yield aLt(r,o,t?.fetchRemoteDocument),c=[...a,...s],l={};try{yield v9e(r.navigation,c,l,{writeFiles:!1,overlayRegistry:o,fetchRemoteDocument:t?.fetchRemoteDocument})}catch(e){console.warn(`Warning: Failed to extract OpenAPI pages from navigation: ${e}`)}n.push(...Object.keys(l))}for(let e of a)try{let{pagesAcc:t}=yield UXe(e.spec,{openApiFilePath:e.originalFileLocation,writeFiles:!1,outDir:`api-reference`});n.push(...Object.keys(t))}catch(t){console.warn(`Warning: Failed to extract pages from OpenAPI spec ${e.originalFileLocation}: ${t}`)}}catch(e){console.warn(`Warning: Failed to categorize files for OpenAPI extraction: ${e}`)}return[...new Set(n)]}),aLt=(e,t,n)=>rLt(void 0,void 0,void 0,function*(){try{return yield uB(`docs`,e,void 0,t,n)}catch(e){return console.warn(`Warning: Failed to fetch URL-based OpenAPI specs: ${e}`),[]}});var oLt=function(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})};const sLt=e=>oLt(void 0,void 0,void 0,function*(){let t=[],n=yield XIt(e);return n&&n.success&&`redirects`in n.data&&n.data.redirects&&t.push(...n.data.redirects),t}),cLt=[`ImportDefaultSpecifier`,`ImportNamespaceSpecifier`],lLt=e=>{let t=[],n=[],r=[],i=/* @__PURE__ */ new Set;p2(e,e=>{if(at(e)&&st(e)){for(let n of e.data.estree.body){if(!f(n)||typeof n.source.value!=`string`)continue;let e=n.source.value;t.push(e);for(let t of n.specifiers)cLt.includes(t.type)&&r.push({source:e,name:t.local.name})}return}if(!g(e)||!e.name||(i.add(e.name),e.name!==`Snippet`))return;let a=e.attributes.find(e=>e.type===`mdxJsxAttribute`&&e.name===`file`)?.value;typeof a==`string`&&n.push(`/_snippets/`+g2(a))});for(let{source:e,name:t}of r)i.has(t)&&n.push(e);return{imported:t,rendered:n}},uLt=[`snippets/`,`_snippets/`],T2=e=>e.replaceAll(Pr,`/`),dLt=({originalPath:e,pathType:t,wrapper:n})=>n!==y2.IMPORT&&t===_2.INTERNAL&&!e.startsWith(`/`),fLt=(e,t)=>{var n;let r=new Map([...t.keys()].map(e=>[T2(e),e])),i=(e,t)=>e.flatMap(e=>{let n=XT(e,T2(t)),i=n&&r.get(g2(n));return i?[i]:[]}),a=/* @__PURE__ */ new Set;for(let[e,{imported:n}]of t){let t=T2(e).toLowerCase();uLt.some(e=>t.startsWith(e))&&a.add(e);for(let t of i(n,e))a.add(t)}let o=(e,n)=>{let r=t.get(e)?.rendered??[];for(let t of i(r,e))!n.has(t)&&a.has(t)&&(n.add(t),o(t,n));return n},s=/* @__PURE__ */ new Map;for(let e of t.keys())a.has(e)||s.set(e,o(e,/* @__PURE__ */ new Set));for(let[t,r]of s){let i=e.getNode(t);if(i)for(let t of r){let r=e.getNode(t);for(let e of r?.paths.filter(dLt)??[])e.pagePaths.push(new b2(e.originalPath,i.relativeDir,i.filename,e.wrapper));for(let e of r?.headingSlugs??[])(n=i.headingSlugs)==null||n.add(e)}}},pLt=(e,t,n)=>{let r=/* @__PURE__ */ new Set;if(!n.checkAnchors&&!n.checkSnippets)return r;let i=n.checkAnchors?[...e.getAnchorTargetFiles(t)]:[];for(let e of i)r.add(T2(e));let a=new Map([...e.snippetReferencesByFile.keys()].map(e=>[T2(e),e])),o=/* @__PURE__ */ new Set,s=t=>{if(o.has(t))return;o.add(t);let n=a.get(t),i=n?e.snippetReferencesByFile.get(n)?.rendered??[]:[];for(let e of i){let n=XT(e,t);if(!n)continue;let i=g2(n);r.add(i),s(i)}};for(let e of[...t,...i])s(T2(e));return r};var E2=function(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})};const mLt=e=>{let t=/* @__PURE__ */ new Set;for(let n of e){t.add(QE(n.slug));for(let e of mLt(n.children))t.add(e)}return t},hLt=/* @__PURE__ */ new Set([`ParamField`,`Param`,`ResponseField`]),gLt=/* @__PURE__ */ new Set([`query`,`path`,`body`,`header`,`name`]),_Lt=e=>{let t=/* @__PURE__ */ new Set,n=/* @__PURE__ */ new Map;return p2(e,`mdxJsxFlowElement`,e=>{if(hLt.has(e.name??``)){let r=e.attributes.find(e=>`name`in e&&gLt.has(e.name));if(r&&typeof r.value==`string`&&r.value){let e=n.get(r.value)??0;n.set(r.value,e+1),t.add(mDe(r.value,e))}return}if($Me.has(e.name??``))return;let r=e.attributes.find(e=>`name`in e&&e.name===`id`);if(r&&typeof r.value==`string`&&r.value){let n=eNe.has(e.name??``)?QE(r.value):r.value;t.add(n)}}),t},vLt=e=>{if(typeof e==`string`)return e;let t=(e?.data?.estree)?.body[0],n=t?.type===`ExpressionStatement`?t.expression:void 0;if(n?.type===`Literal`&&typeof n.value==`string`)return n.value;if(n?.type===`TemplateLiteral`&&n.expressions.length===0)return n.quasis[0]?.value.cooked??void 0},yLt=(e,t,n)=>E2(void 0,void 0,void 0,function*(){let r={},i=()=>t=>{let n=/* @__PURE__ */ new Set;return p2(t,[`linkReference`,`imageReference`],e=>{`identifier`in e&&n.add(e.identifier)}),p2(t,t=>{if(t.type===`link`||t.type===`image`){e.addPath(t.url,y2.MD);return}if(t.type===`definition`){n.delete(t.identifier)&&e.addPath(t.url,y2.MD);return}let r=t;if(r.name===`img`||r.name===`source`){let t=r.attributes.findIndex(e=>e.type===`mdxJsxAttribute`&&e.name===`src`),n=vLt(r.attributes[t]?.value);if(typeof n==`string`){e.addPath(n,y2.SRC);return}}else if(r.name===`a`||r.name===`Card`){let t=r.attributes.findIndex(e=>e.type===`mdxJsxAttribute`&&e.name===`href`),n=vLt(r.attributes[t]?.value);if(typeof n==`string`){e.addPath(n,y2.HREF);return}}}),t},a=b(Ly(t)),o=zT().use(CIt).use(i).use(Tje).use(Nje,r),s=o.parse(a),c=lLt(s);if(n?.checkSnippets)for(let t of c.imported)e.addPath(t,y2.IMPORT);yield o.run(s);let l=r.tableOfContents?mLt(r.tableOfContents):/* @__PURE__ */ new Set,u=_Lt(s);return e.headingSlugs=/* @__PURE__ */ new Set([...l,...u]),c}),bLt=(e,t)=>E2(void 0,void 0,void 0,function*(){let n=e||process.cwd(),r=yield yF(n),i=new YIt(n,r),a=m2(n,r).filter(e=>!MP(e,r));i.addNodes(a);let o=yield sLt(n);i.setRedirects(o),i.addAliasNodes();try{let e=yield iLt(n,{fetchRemoteDocument:t?.fetchRemoteDocument});i.addVirtualNodes(e)}catch(e){console.warn(`Warning: Failed to extract OpenAPI page paths: ${e}`)}try{let e=yield $It(n);i.addVirtualNodes(e)}catch(e){console.warn(`Warning: Failed to extract GraphQL page paths: ${e}`)}let s=yield nLt(n);if(s){let e=i.addNode(s.configFile);for(let t of s.hrefs){let n=t===`/`||t===``?`/index`:t.replace(/^\/#/,`/index#`);e.addPath(n)}}let c=WIt(n,r).filter(e=>!MP(e,r)),l=/* @__PURE__ */ new Map,u=0;return yield Promise.all(Array.from({length:Math.min(8,c.length)},()=>E2(void 0,void 0,void 0,function*(){for(;u<c.length;){let e=c[u++];if(e===void 0)continue;let r=i.getNode(e);if(!r)continue;let a=gF.default.readFileSync(gt.join(n,e)).toString();try{let n=yield yLt(r,a,{checkSnippets:t?.checkSnippets});l.set(e,n)}catch(n){let r=/* @__PURE__ */ Error(`Syntax error - Unable to parse ${e} - ${n}`);if(!t?.onParseError)throw r;t.onParseError(e,r)}}}))),fLt(i,l),i.snippetReferencesByFile=l,i});var D2=function(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})};const xLt=e=>{try{let t=new URL(e);return t.protocol===`http:`||t.protocol===`https:`}catch{return!1}},SLt=(e,t)=>D2(void 0,void 0,void 0,function*(){let n=new AbortController,r=setTimeout(()=>n.abort(),1e4);try{let r=yield fetch(e,{method:t,signal:n.signal,headers:{"User-Agent":`Mintlify-LinkChecker/1.0`},redirect:`follow`});return yield r.body?.cancel().catch(()=>void 0),r.status}finally{clearTimeout(r)}}),CLt=/* @__PURE__ */ new Set([404,405]),wLt=e=>D2(void 0,void 0,void 0,function*(){try{let t=yield SLt(e,`HEAD`),n=CLt.has(t)?yield SLt(e,`GET`).catch(()=>t):t;return{ok:n!==404,status:n}}catch(e){return{ok:!1,status:null,error:e instanceof Error?e.message:`unknown error`}}}),TLt=(e,t,n)=>D2(void 0,void 0,void 0,function*(){let r=[],i=0,a=()=>D2(void 0,void 0,void 0,function*(){for(;i<e.length;){let n=i++;r[n]=yield t(e[n])}}),o=Array.from({length:Math.min(n,e.length)},()=>a());return yield Promise.all(o),r}),ELt=(e,t)=>D2(void 0,void 0,void 0,function*(){let n=/* @__PURE__ */ new Map;for(let[r,i]of e.getExternalPathsByNode())if(!t?.sourceFiles||t.sourceFiles.has(r)){for(let e of i)if(xLt(e.originalPath)){let t=e.originalPath,i=n.get(t),a={file:r,originalPath:e.originalPath};i?i.push(a):n.set(t,[a])}}let r=[...n.keys()];return(yield TLt(r,e=>D2(void 0,void 0,void 0,function*(){let t=yield wLt(e);if(t.ok)return null;let r={url:e,status:t.status,sources:n.get(e)};return t.error&&(r.error=t.error),r}),5)).filter(e=>e!==null)});var O2=function(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})};const DLt=/[*?]/,OLt=/\.mdx?$/i,kLt=/[.+^${}()|\\[\]]/,ALt=/* @__PURE__ */ new Set([`.git`,`node_modules`]);function jLt(e){return e.split(It.sep).join(`/`)}function MLt(e){return jLt(e).replace(/^\.\//,``)}function NLt(e){let t=``,n=0;for(;n<e.length;){let r=e[n];r===`*`?e[n+1]===`*`?e[n+2]===`/`?(t+=`(?:[^/]+/)*`,n+=3):(t+=`.*`,n+=2):(t+=`[^/]*`,n+=1):r===`?`?(t+=`[^/]`,n+=1):(t+=kLt.test(r)?`\\${r}`:r,n+=1)}return RegExp(`^${t}$`)}function PLt(e){return O2(this,void 0,void 0,function*(){try{return(yield Hn.stat(e)).isFile()}catch{return!1}})}function FLt(e){return O2(this,arguments,void 0,function*(e,t=``){let n=yield Hn.readdir(It.join(e,t),{withFileTypes:!0}),r=[];for(let i of n){if(ALt.has(i.name))continue;let n=t?`${t}/${i.name}`:i.name;i.isDirectory()?r.push(...yield FLt(e,n)):r.push(n)}return r})}var ILt=class extends Error{};function LLt(e,t){return O2(this,void 0,void 0,function*(){let n=null,r=[],i=[];for(let a of t){let t=MLt(a);if(DLt.test(t)){n??=yield FLt(e);let o=NLt(t),s=n.filter(e=>OLt.test(e)&&o.test(e)).sort();s.length===0?i.push(a):r.push(...s)}else(yield PLt(It.join(e,t)))?r.push(t):i.push(a)}if(i.length>0)throw new ILt(`No matching files for: ${i.join(`, `)} (globs match .md and .mdx files)`);return[...new Set(r)]})}var RLt=function(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})};const zLt=e=>RLt(void 0,void 0,void 0,function*(){yield bjt(),jH((0,z.jsx)(xH,{message:`checking for broken links...`}));try{let t=yield vjt(o1),n=(e.files??[]).map(String).filter(Boolean),r=n.length>0?new Set((yield LLt(o1,n)).map(e=>gt.relative(t,gt.resolve(o1,e)))):void 0,i=/* @__PURE__ */ new Map,a=yield bLt(t,{checkSnippets:e[`check-snippets`],onParseError:(e,t)=>i.set(e,t.message)});a.precomputeFileResolutions();let o=r?pLt(a,r,{checkAnchors:e[`check-anchors`],checkSnippets:e[`check-snippets`]}):void 0,s=[...i].filter(([e])=>!r||r.has(e)||o?.has(e.split(gt.sep).join(`/`))).map(([,e])=>e),c=a.getBrokenInternalLinks({checkAnchors:e[`check-anchors`]}).filter(({relativeDir:e,filename:t})=>!r||r.has(gt.join(e,t))),l={};if(c.forEach(e=>{let t=gt.join(e.relativeDir,e.filename),n=l[t];n?n.push(e.originalPath):l[t]=[e.originalPath]}),e[`check-external`]){let e=yield ELt(a,r?{sourceFiles:r}:void 0);for(let t of e)for(let e of t.sources){let n=t.status?`${t.url} (${t.status})`:`${t.url} (${t.error})`,r=l[e.file];r?r.push(n):l[e.file]=[n]}}if(e[`check-redirects`]){let e=a.getBrokenRedirects();if(e.length>0){let n=yield Hn.access(gt.join(t,`docs.json`)).then(()=>`docs.json`).catch(()=>`mint.json`),r=e.map(({source:e,destination:t})=>`${e} → ${t}`),i=l[n];i?i.push(...r):l[n]=r}}let u=Object.keys(l).length>0;!u&&s.length===0&&(FH(),jH((0,z.jsx)(bH,{message:`no broken links found`})),yield f1(0)),FH(),jH(u?(0,z.jsx)(cat,{brokenLinksByFile:l}):(0,z.jsx)(bH,{message:`no broken links found in the files that parsed`}));for(let e of s)jH((0,z.jsx)(CH,{message:e}));s.length>0&&jH((0,z.jsx)(SH,{message:`skipped ${s.length} file(s) that could not be parsed; links in them were not checked`}))}catch(e){jH((0,z.jsx)(CH,{message:e instanceof Error?e.message:`unknown error`})),yield f1(1)}yield f1(1)});var BLt=function(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})};function VLt(e,t){return()=>BLt(this,void 0,void 0,function*(){N1()?jH((0,z.jsx)(bH,{message:`Thanks for your interest in "${t} ${e}"! Your vote has been counted.`})):jH((0,z.jsx)(SH,{message:`Telemetry is disabled, so your vote won't be counted. Enable it with: ${t} --telemetry=true`})),jH((0,z.jsx)(gH,{dimColor:!0,children:`This feature is currently in development. Learn more at https://mintlify.com/docs`})),yield f1(0)})}var k2=function(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})};const HLt=Ne({status:nt(`ready`),deploymentId:He().min(1),subdomain:He().min(1),remote:I(),branch:nt(`main`),expiresAt:Pe(),orgSlug:He().min(1).optional()}),ULt=ke(`status`,[HLt.extend({code:nt(`deployment_already_exists`)}),Ne({status:nt(`provisioning`),code:nt(`deployment_already_exists`),deploymentId:He().optional(),subdomain:He().optional()}),Ne({status:nt(`expired`),code:Te([`deployment_already_exists`,`deployment_claim_expired`]),deploymentId:He(),subdomain:He(),expiresAt:Pe().optional()})]),WLt=Ne({remote:I(),branch:nt(`main`),token:He().min(1),tokenExpiresAt:Pe()}),GLt=Ne({subdomain:He().min(1),trustedRepos:Ke(Ne({repositoryId:He(),repository:He(),branch:He()}))});function KLt(e,t,n){return k2(this,void 0,void 0,function*(){for(let r=0;r<4;r++){let i=yield z1(`${e}/api/agent/deployments/provision`,{method:`POST`,headers:{Authorization:`Bearer ${t}`,"Content-Type":`application/json`},body:JSON.stringify(Object.assign(Object.assign({},n),{docsPath:``}))});if(i.status!==409)return Object.assign(Object.assign({},yield B1(i,HLt)),{created:!0});let a=yield i.json().catch(()=>null),o=ULt.safeParse(a);if(!o.success)throw Error(`The deployment service returned an unexpected response.`);if(o.data.status!==`provisioning`)return Object.assign(Object.assign({},o.data),{created:!1});r<3&&(yield Fr(1e3*(r+1)))}throw Error(`Your site is still provisioning. Run the same command again.`)})}function qLt(e,t){return k2(this,void 0,void 0,function*(){return B1(yield z1(`${e}/api/agent/deployments/token`,{method:`POST`,headers:{Authorization:`Bearer ${t}`}}),WLt)})}function JLt(e,t,n){return k2(this,void 0,void 0,function*(){return B1(yield z1(`${e}/api/agent/deployments/github-actions/token`,{method:`POST`,headers:{Authorization:`Bearer ${t}`,"Content-Type":`application/json`},body:JSON.stringify({subdomain:n})}),WLt)})}function YLt(e,t,n){return k2(this,void 0,void 0,function*(){return B1(yield z1(`${e}/api/agent/deployments/trusted-repos`,{method:`POST`,headers:{Authorization:`Bearer ${t}`,"Content-Type":`application/json`},body:JSON.stringify(n)}),GLt)})}var XLt=function(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})};function ZLt(e,t){return XLt(this,arguments,void 0,function*(e,t,n=()=>{}){let{apiUrl:r}=e,i=It.resolve(e.directory),a=JSON.stringify([new URL(r).origin,i]),o=Gjt(a);n(`Authenticating agent...`);let s=e.newSite?null:yield SMt(r,i).catch(()=>{if(o)throw Error(`Could not read this site’s saved credentials. Unlock your keyring or use --new for another site.`);return t(`Could not read the keyring. Continuing with a new registration for this run.`),null}),c=e.subdomain??(e.newSite?void 0:o?.subdomain);if(!c)throw Error(`Choose a site name with --subdomain <name>.`);let l=yield H1(r),u=e.base?`workspace`:`site`,d=e=>CMt(r,i,e);for(let i=0;i<2;i++){let i=s??(yield pMt(l));n0(`agent_signup.discovered`,{registration_id:i.registrationId}),s||n0(`agent_signup.registered`,{registration_id:i.registrationId}),yield d(i);let o=yield U1(l,i);yield d(o);let f=yield mMt(r,o.accessToken);if(f.registrationId!==i.registrationId)throw Error(`Agent identity does not match the saved registration.`);if(f.identityType===`user_bound`)return{status:`claimed`};n(`Provisioning the ${e.base?`base`:`site`} and repository...`);let p=yield KLt(r,o.accessToken,Object.assign({subdomain:c,orgName:e.orgName},e.base&&{projectType:u}));if(p.status===`expired`){t(`The previous anonymous site expired. Creating a new registration and site.`),s=null;continue}n0(`cli.deploy.provisioned`,{registration_id:i.registrationId,deployment_id:p.deploymentId,subdomain:p.subdomain,created:p.created}),yield Kjt(a,{registrationId:i.registrationId,subdomain:p.subdomain}).catch(()=>t(`Could not save the site name locally. Provide --subdomain on your next invocation.`)),n(`Getting repository write access...`);let m=yield qLt(r,o.accessToken);if(m.remote!==p.remote)throw Error(`Repository credentials do not match the provisioned site.`);return{status:`ready`,projectType:u,site:p,write:m,created:p.created,credentials:o}}throw Error(`The new anonymous site is already expired. Please retry later.`)})}function A2(e,t){let n=new URL(e).hostname===`leaves-dev.mintlify.com`?`mint-dev.mintlify.me`:`mintlify.site`;return new URL(`https://${t}.${n}`).toString()}function QLt(e){return e.orgSlug?new URL(`/${e.orgSlug}/${e.subdomain}/editor`,T1).toString():new URL(T1).toString()}function $Lt(e,t){if(e.status===`claimed`)return`This site has been claimed. Manage it in the Mintlify dashboard. Use mint deploy --new --subdomain <name> to create another site.`;let{site:n,write:r}=e,i=[`Repository: ${n.remote}`,`Branch: ${n.branch}`,`Write token: ${r.token}`,`Write token expires: ${r.tokenExpiresAt}`];if(e.projectType===`workspace`)return[e.created?`Base provisioned.`:`Using the existing anonymous base.`,`Editor: ${QLt(n)}`,`Expires: ${n.expiresAt}. Claim it before then or it is deleted.`].join(`
|
|
2202
2202
|
`);let a=A2(t,n.subdomain);return[e.created?`Repository provisioned; push required to build the site.`:`Using the existing anonymous repository; push any changes to build the site.`,`Site: ${a}`,`Expires: ${n.expiresAt}`,...i,`Commit and push your documentation to this repository to start the build.`,`The site link becomes available after the push and build complete.`].join(`
|
|
2203
2203
|
`)}var j2=function(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})};const eRt=Ne({value:He().min(1)});function tRt(e=process.env){return e.GITHUB_ACTIONS===`true`}function nRt(e,t){return j2(this,void 0,void 0,function*(){let n=e.ACTIONS_ID_TOKEN_REQUEST_URL,r=e.ACTIONS_ID_TOKEN_REQUEST_TOKEN;if(!n||!r)throw Error("GitHub Actions did not provide an OIDC token. Add `permissions: id-token: write` to the workflow or job.");let i;try{i=yield fetch(`${n}&audience=${encodeURIComponent(t)}`,{headers:{Authorization:`Bearer ${r}`},signal:AbortSignal.timeout(3e4)})}catch{throw Error(`Could not request a GitHub Actions OIDC token. Retry the workflow.`)}let a=eRt.safeParse(yield i.json().catch(()=>null));if(!i.ok||!a.success)throw Error(`Could not get a GitHub Actions OIDC token (HTTP ${i.status}). Check that the workflow has \`permissions: id-token: write\`.`);return a.data.value})}function M2(e,t,n){return new Promise((r,i)=>{let a=Nr(`git`,e,{cwd:t,env:n,stdio:[`ignore`,`pipe`,`inherit`]}),o=``;a.stdout.on(`data`,e=>o+=e.toString()),a.on(`error`,i),a.on(`close`,t=>t===0?r(o.trim()):i(/* @__PURE__ */ Error(`git ${e[0]} failed`)))})}function rRt(e,t){return j2(this,void 0,void 0,function*(){let n=yield M2([`rev-parse`,`HEAD:${yield M2([`rev-parse`,`--show-prefix`],e,t)}`],e,t),[r=``,i=``,a=``,o=``,s=``]=(yield M2([`log`,`-1`,`--format=%an%n%ae%n%aI%n%H%n%s`],e,t)).split(`
|
|
2204
|
-
`);return M2([`commit-tree`,n,`-m`,s,`-m`,`Deployed from ${t.GITHUB_REPOSITORY?`${t.GITHUB_REPOSITORY}@`:``}${o}`],e,Object.assign(Object.assign({},t),{GIT_AUTHOR_NAME:r,GIT_AUTHOR_EMAIL:i,GIT_AUTHOR_DATE:a,GIT_COMMITTER_NAME:r,GIT_COMMITTER_EMAIL:i}))})}function iRt(e,t,n,r){let i=Number(r.GIT_CONFIG_COUNT)||0,a=Buffer.from(`x-access-token:${n.token}`).toString(`base64`);return new Promise((o,s)=>{let c=Nr(`git`,[`push`,`--force`,n.remote,`${t}:refs/heads/${n.branch}`],{cwd:e,stdio:[`ignore`,`inherit`,`inherit`],env:Object.assign(Object.assign({},r),{GIT_CONFIG_COUNT:String(i+1),[`GIT_CONFIG_KEY_${i}`]:`http.${n.remote}.extraHeader`,[`GIT_CONFIG_VALUE_${i}`]:`Authorization: Basic ${a}`})}),l=()=>s(/* @__PURE__ */ Error(`git push to the site repository failed.`));c.on(`error`,l),c.on(`close`,e=>e===0?o():l())})}function aRt(e){return j2(this,arguments,void 0,function*(e,t=()=>{},n=process.env){let{apiUrl:r,subdomain:i}=e;if(!i)throw Error(`Pass the site name with --subdomain <name>.`);let a=It.resolve(e.directory),o=yield rRt(a,n).catch(()=>{throw Error(`Could not read ${e.directory} from the checked-out commit. Run mint deploy after actions/checkout, with --directory inside the repository.`)});t(`Requesting a GitHub Actions identity token...`);let s=yield nRt(n,r);t(`Getting repository write access...`);let c;try{c=yield JLt(r,s,i)}catch(e){throw e instanceof
|
|
2204
|
+
`);return M2([`commit-tree`,n,`-m`,s,`-m`,`Deployed from ${t.GITHUB_REPOSITORY?`${t.GITHUB_REPOSITORY}@`:``}${o}`],e,Object.assign(Object.assign({},t),{GIT_AUTHOR_NAME:r,GIT_AUTHOR_EMAIL:i,GIT_AUTHOR_DATE:a,GIT_COMMITTER_NAME:r,GIT_COMMITTER_EMAIL:i}))})}function iRt(e,t,n,r){let i=Number(r.GIT_CONFIG_COUNT)||0,a=Buffer.from(`x-access-token:${n.token}`).toString(`base64`);return new Promise((o,s)=>{let c=Nr(`git`,[`push`,`--force`,n.remote,`${t}:refs/heads/${n.branch}`],{cwd:e,stdio:[`ignore`,`inherit`,`inherit`],env:Object.assign(Object.assign({},r),{GIT_CONFIG_COUNT:String(i+1),[`GIT_CONFIG_KEY_${i}`]:`http.${n.remote}.extraHeader`,[`GIT_CONFIG_VALUE_${i}`]:`Authorization: Basic ${a}`})}),l=()=>s(/* @__PURE__ */ Error(`git push to the site repository failed.`));c.on(`error`,l),c.on(`close`,e=>e===0?o():l())})}function aRt(e){return j2(this,arguments,void 0,function*(e,t=()=>{},n=process.env){let{apiUrl:r,subdomain:i}=e;if(!i)throw Error(`Pass the site name with --subdomain <name>.`);let a=It.resolve(e.directory),o=yield rRt(a,n).catch(()=>{throw Error(`Could not read ${e.directory} from the checked-out commit. Run mint deploy after actions/checkout, with --directory inside the repository.`)});t(`Requesting a GitHub Actions identity token...`);let s=yield nRt(n,r);t(`Getting repository write access...`);let c;try{c=yield JLt(r,s,i)}catch(e){throw e instanceof oMt&&e.status===403?Error(`This repository/branch isn't trusted to deploy ${i}. Run \`mint deploy --github\` locally from this repository to trust it.`):e}return t(`Pushing to the site repository...`),yield iRt(a,o,c,n),A2(r,i)})}var oRt=function(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})};function sRt(e,t){return oRt(this,void 0,void 0,function*(){let n=Object.assign(Object.assign({},process.env),{GIT_CONFIG_COUNT:`1`,GIT_CONFIG_KEY_0:`http.${t.remote}.extraHeader`,GIT_CONFIG_VALUE_0:`Authorization: Bearer ${t.token}`});yield M2([`fetch`,t.remote,t.branch],e,n),yield M2([`rebase`,`FETCH_HEAD`],e,n).catch(()=>{throw Error(`Could not rebase ${e} onto the latest ${t.branch}. Resolve the conflicts, run git rebase --continue, then rerun mint deploy --base --push ${e}.`)}),yield M2([`push`,t.remote,`HEAD:refs/heads/${t.branch}`],e,n)})}const cRt=[`No login is required. This command provisions a temporary site and returns repository access. Commit and push the documentation yourself; the CLI does not upload files.`,`Run from your documentation directory, or pass --directory. Put docs.json, pages, and assets at the hosted repository root.`,`Run again from the same documentation directory for the current anonymous site and a fresh write token. Use --new --subdomain <name> to create another site.`,`Claimed sites are managed in the dashboard. Confirmed expired sites start a new anonymous registration.`,`To hand the site to the user, run mint claim. Do not ask for their email: they sign in on the claim page with any account. If you already know the email of their Mintlify account, pass --email to prefill the sign-in. Show the link to the user; they sign in and click Confirm, and the site moves into their account. There is no code to relay. Run it from the original documentation directory, or pass --directory.`,`The output contains a short-lived write token. Do not paste it into public logs or save it in a Git remote.`,`Pass --github from the root of a GitHub repository to deploy on every push: it trusts the repository (via the gh CLI and the origin remote) to deploy the site and writes .github/workflows/mintlify.yml. Commit and push that workflow. Pass --directory to deploy a docs subdirectory of the repository as the site root. Use --force to overwrite a different existing workflow.`,`Pass --base to provision a base instead of a docs site. The output has the claim steps, a clone command, and the editor link; there is no site URL. Commit in the clone, then run mint deploy --base --push <clone-directory> to publish. --base cannot be combined with --github.`,"In GitHub Actions (GITHUB_ACTIONS=true), no agent credentials are used: the workflow needs `permissions: id-token: write`, --subdomain is required, and the current commit is force-pushed to the site from a trusted repository and branch."].join(`
|
|
2205
2205
|
|
|
2206
|
-
`),lRt=[`
|
|
2206
|
+
`),lRt=[`To hand the site to the user, run mint claim from the same documentation directory (or repeat --directory). Do not ask for their email first; they sign in on the claim page with any account.`,`Show them the claim link it prints. They sign in and click Confirm; there is no code to relay and nothing more to run.`],uRt=e=>e?[`3. Claim the base last. Send the user this link: ${e}`,` They sign in with any account and click Confirm. There is no code to relay.`]:[`3. Claim the base last. Run mint claim, without asking the user for an email.`,` Send the user the claim link it prints. They sign in with any account and click Confirm. There is no code to relay.`];function dRt(e,t){let{site:n,write:r}=e,i=n.subdomain;return[`
|
|
2207
2207
|
Next steps:`,`1. Clone the base into ./${i}:`,` git -c http.${r.remote}.extraHeader="Authorization: Bearer ${r.token}" clone ${r.remote} ${i}`,` The clone command works until ${r.tokenExpiresAt}. Run mint deploy --base again for a fresh one.`,`2. Commit your changes in ./${i}, then publish them:`,` mint deploy --base --push ${i}`,` This rebases onto the latest main and pushes. Do not run git push yourself.`,...uRt(t),` After the claim, the user opens the base at the editor link above and edits it there. The CLI can no longer push to it.`,`Run every mint command from this directory (or repeat --directory).`].join(`
|
|
2208
2208
|
`)}function fRt(e,t){return e.status===`ready`?e.projectType===`workspace`?dRt(e,t):[`
|
|
2209
|
-
Next steps:`,`1. Clone the hosted repository into a separate directory. Do not replace the user’s existing Git remote.`,`2. Copy the selected documentation into its root, including docs.json, .md/.mdx pages, images, and other required assets. Exclude credentials, .env files, node_modules, and .git.`,`3. Commit the documentation. For subsequent updates, fetch the hosted main branch and commit on top of it. Do not force-push.`,`4. Push to main. Supply the write token as an HTTP Authorization: Bearer header for this Git operation only; never embed it in the remote URL or persist it in Git config.`,`5. If the write token expires, run mint deploy again from the same documentation directory to obtain a fresh token.`,`A successful push starts the normal build. Provisioning and Git success do not confirm build success.`,``,`Git examples (POSIX shell): set REPOSITORY_URL and WRITE_TOKEN from the output above. Set CHECKOUT_DIR to a new directory outside the source documentation directory. Keep the token private and do not enable shell tracing.`,'GIT_CONFIG_COUNT=1 GIT_CONFIG_KEY_0="http.${REPOSITORY_URL}.extraHeader" GIT_CONFIG_VALUE_0="Authorization: Bearer ${WRITE_TOKEN}" git clone "$REPOSITORY_URL" "$CHECKOUT_DIR"',`After copying and committing the documentation:`,'GIT_CONFIG_COUNT=1 GIT_CONFIG_KEY_0="http.${REPOSITORY_URL}.extraHeader" GIT_CONFIG_VALUE_0="Authorization: Bearer ${WRITE_TOKEN}" git -C "$CHECKOUT_DIR" push origin HEAD:main',`These settings apply only to that Git process. Use the same authentication settings for later fetches.`,``,...t?[`Claim link for the user: ${t}`,`Show this link to the user.
|
|
2209
|
+
Next steps:`,`1. Clone the hosted repository into a separate directory. Do not replace the user’s existing Git remote.`,`2. Copy the selected documentation into its root, including docs.json, .md/.mdx pages, images, and other required assets. Exclude credentials, .env files, node_modules, and .git.`,`3. Commit the documentation. For subsequent updates, fetch the hosted main branch and commit on top of it. Do not force-push.`,`4. Push to main. Supply the write token as an HTTP Authorization: Bearer header for this Git operation only; never embed it in the remote URL or persist it in Git config.`,`5. If the write token expires, run mint deploy again from the same documentation directory to obtain a fresh token.`,`A successful push starts the normal build. Provisioning and Git success do not confirm build success.`,``,`Git examples (POSIX shell): set REPOSITORY_URL and WRITE_TOKEN from the output above. Set CHECKOUT_DIR to a new directory outside the source documentation directory. Keep the token private and do not enable shell tracing.`,'GIT_CONFIG_COUNT=1 GIT_CONFIG_KEY_0="http.${REPOSITORY_URL}.extraHeader" GIT_CONFIG_VALUE_0="Authorization: Bearer ${WRITE_TOKEN}" git clone "$REPOSITORY_URL" "$CHECKOUT_DIR"',`After copying and committing the documentation:`,'GIT_CONFIG_COUNT=1 GIT_CONFIG_KEY_0="http.${REPOSITORY_URL}.extraHeader" GIT_CONFIG_VALUE_0="Authorization: Bearer ${WRITE_TOKEN}" git -C "$CHECKOUT_DIR" push origin HEAD:main',`These settings apply only to that Git process. Use the same authentication settings for later fetches.`,``,...t?[`Claim link for the user: ${t}`,`Show this link to the user. They open it, sign in, and click Confirm; the site moves into their account. Do not sign in on their behalf. There is no code to relay.`]:lRt].join(`
|
|
2210
2210
|
`):``}var N2=function(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})};const pRt=Ne({id:Ae().int().positive(),full_name:He().regex(/^[\w.-]+\/[\w.-]+$/),default_branch:He().min(1)}),P2=It.join(`.github`,`workflows`,`mintlify.yml`);function F2(e,t,n){return new Promise((r,i)=>{jr(e,t,{cwd:n},(e,t)=>e?i(e):r(String(t).trim()))})}function mRt(e){let t=e.trim().match(/^(?:https:\/\/(?:[^@/]+@)?github\.com\/|ssh:\/\/git@github\.com(?::\d+)?\/|git@github\.com:)([\w.-]+)\/([\w.-]+?)(?:\.git)?\/?$/);return t?.[1]&&t[2]?{owner:t[1],repo:t[2]}:null}function hRt(e,t,n=``){let r=/^[\w./-]+$/.test(n)?n:JSON.stringify(n);return[`name: Deploy to Mintlify`,`on:`,` push:`,` branches: [${JSON.stringify(e)}]`,...n?[` paths: [${JSON.stringify(`${n}/**`)}, ".github/workflows/mintlify.yml"]`]:[],`permissions:`,` id-token: write`,` contents: read`,`concurrency:`,` group: mintlify-deploy`,` cancel-in-progress: true`,`jobs:`,` deploy:`,` runs-on: ubuntu-latest`,` steps:`,` - uses: actions/checkout@v4`,` - run: npx mint@latest deploy --subdomain ${t}${n?` --directory ${r}`:``}`,``].join(`
|
|
2211
2211
|
`)}function gRt(e){return N2(this,void 0,void 0,function*(){return Hn.readFile(e,`utf8`).catch(e=>{if(e.code!==`ENOENT`)throw e})})}function _Rt(e,t){return N2(this,arguments,void 0,function*(e,t,n=!1){let r=It.join(e,P2),i=yield gRt(r);if(i===t)return`unchanged`;if(i!==void 0&&!n)throw Error(`${P2} already exists with different contents. Pass --force to overwrite it.`);return yield Hn.mkdir(It.dirname(r),{recursive:!0}),yield Hn.writeFile(r,t),i===void 0?`created`:`updated`})}function vRt(e){return N2(this,void 0,void 0,function*(){try{return yield F2(`git`,[`rev-parse`,`--show-toplevel`],e)}catch{throw Error(`--github requires a Git repository. Run it inside your docs repository.`)}})}function yRt(e){return N2(this,void 0,void 0,function*(){let t=yield F2(`git`,[`remote`,`get-url`,`origin`],e).catch(()=>{throw Error(`This repository has no origin remote. Add a github.com origin and retry.`)}),n=mRt(t);if(!n)throw Error(`The origin remote (${t}) is not a github.com repository.`);let r=yield F2(`gh`,[`api`,`repos/${n.owner}/${n.repo}`,`--jq`,`{id: .id, full_name: .full_name, default_branch: .default_branch}`],e).catch(e=>{throw e.code===`ENOENT`?Error("The GitHub CLI (gh) is required. Install it and run `gh auth login`."):Error(`Could not read ${n.owner}/${n.repo} with gh. Run \`gh auth login\` with access to the repository and retry.`)});try{return pRt.parse(JSON.parse(r))}catch{throw Error(`gh returned an unexpected repository response.`)}})}function bRt(e,t){return N2(this,arguments,void 0,function*(e,t,n=()=>{}){let r=It.resolve(e.directory),i=yield vRt(r),[a,o]=yield Promise.all([Hn.realpath(i),Hn.realpath(r)]),s=It.relative(a,o).split(It.sep).join(`/`);if(!(yield gRt(It.join(r,`docs.json`))))throw Error(`No docs.json in ${r}. Pass the docs folder with --directory.`);n(`Resolving the GitHub repository...`);let c=yield yRt(i),l=yield ZLt(e,t,n);if(l.status===`claimed`)throw Error(`This site has been claimed. Setting up GitHub deploys for claimed sites is not supported yet; connect the repository from the Mintlify dashboard.`);let u=l.credentials.accessToken;if(!u)throw Error(`Agent authentication did not return an access token.`);n(`Trusting ${c.full_name}@${c.default_branch} to deploy...`),yield YLt(e.apiUrl,u,{repositoryId:String(c.id),repository:c.full_name,branch:c.default_branch});let d=yield _Rt(i,hRt(c.default_branch,l.site.subdomain,s),e.force);return{siteUrl:A2(e.apiUrl,l.site.subdomain),subdomain:l.site.subdomain,repository:c.full_name,branch:c.default_branch,workflowPath:P2,workflow:d}})}function xRt(e){return[`Site: ${e.siteUrl}`,`Trusted repository: ${e.repository} (branch ${e.branch})`,`Workflow: ${e.workflowPath} (${e.workflow})`,``,`Next steps:`,`1. Commit and push ${e.workflowPath} to ${e.branch}.`,`2. Every push to ${e.branch} then deploys ${e.subdomain} through GitHub Actions. No secrets are stored in the repository.`,``,...lRt].join(`
|
|
2212
2212
|
`)}var SRt=function(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})};const CRt=[`bug`,`docs`,`idea`];function wRt(e){return SRt(this,void 0,void 0,function*(){let t;try{t=yield fetch(`${w1}/api/cli/feedback`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(Object.assign(Object.assign({},e),{source:`cli`}))})}catch{return`could not reach the server`}return t.ok?void 0:`could not send feedback (HTTP ${t.status})`})}function TRt(e){return SRt(this,void 0,void 0,function*(){let t=yield wRt(e);return jH(t?(0,z.jsx)(CH,{message:t}):(0,z.jsx)(bH,{message:`feedback sent`})),!t})}var ERt=function(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})},I2=function(e){return this instanceof I2?(this.v=e,this):new I2(e)},DRt=function(e){if(!Symbol.asyncIterator)throw TypeError(`Symbol.asyncIterator is not defined.`);var t=e[Symbol.asyncIterator],n;return t?t.call(e):(e=typeof __values==`function`?__values(e):e[Symbol.iterator](),n={},r(`next`),r(`throw`),r(`return`),n[Symbol.asyncIterator]=function(){return this},n);function r(t){n[t]=e[t]&&function(n){return new Promise(function(r,a){n=e[t](n),i(r,a,n.done,n.value)})}}function i(e,t,n,r){Promise.resolve(r).then(function(t){e({value:t,done:n})},t)}},ORt=function(e){var t={},n;return r(`next`),r(`throw`,function(e){throw e}),r(`return`),t[Symbol.iterator]=function(){return this},t;function r(r,i){t[r]=e[r]?function(t){return(n=!n)?{value:I2(e[r](t)),done:!1}:i?i(t):t}:i}},kRt=function(e,t,n){if(!Symbol.asyncIterator)throw TypeError(`Symbol.asyncIterator is not defined.`);var r=n.apply(e,t||[]),i,a=[];return i=Object.create((typeof AsyncIterator==`function`?AsyncIterator:Object).prototype),s(`next`),s(`throw`),s(`return`,o),i[Symbol.asyncIterator]=function(){return this},i;function o(e){return function(t){return Promise.resolve(t).then(e,d)}}function s(e,t){r[e]&&(i[e]=function(t){return new Promise(function(n,r){a.push([e,t,n,r])>1||c(e,t)})},t&&(i[e]=t(i[e])))}function c(e,t){try{l(r[e](t))}catch(e){f(a[0][3],e)}}function l(e){e.value instanceof I2?Promise.resolve(e.value.v).then(u,d):f(a[0][2],e)}function u(e){c(`next`,e)}function d(e){c(`throw`,e)}function f(e,t){e(t),a.shift(),a.length&&c(a[0][0],a[0][1])}};function ARt(){return ERt(this,void 0,void 0,function*(){try{return jP(yield Hn.readFile(It.join(o1,`.gitignore`),`utf-8`))}catch{return[]}})}function jRt(e,t){return kRt(this,arguments,function*(){let n=yield I2(Hn.readdir(e,{withFileTypes:!0}));for(let r of n){let n=It.join(e,r.name);NP(It.relative(o1,n).split(It.sep).join(`/`),t,r.isDirectory())||(r.isDirectory()?yield I2(yield*ORt(DRt(jRt(n,t)))):r.name.endsWith(`.mdx`)&&(yield yield I2(n)))}})}const MRt=()=>ERt(void 0,void 0,void 0,function*(){var e,t,n,r;let{mdxToPm:i,pmToMdx:a,canonicalPmToMdxOptions:o}=yield import(`./converter-d8O3xkdU.js`),s=PP([...yield ARt(),...yield yF(o1)]),c=0,l=0,u=0;try{for(var d=!0,f=DRt(jRt(o1,s)),p;p=yield f.next(),e=p.done,!e;d=!0){r=p.value,d=!1;let e=r;c++;let t=It.relative(o1,e);try{let t=yield Hn.readFile(e,`utf-8`),n=t,r=0;for(let e=0;e<3;e++){let{doc:t,frontmatter:s}=i(n);e===0&&(r=Object.keys(s).length);let c=`${a(t,Object.assign({frontmatter:s},o))}\n`;if(c===n)break;n=c}if(r>0&&!n.startsWith(`---`))throw Error(`formatting would remove frontmatter; file left untouched`);n!==t&&(yield Hn.writeFile(e,n),l++)}catch(e){u++,jH((0,z.jsx)(CH,{message:`${t}: ${e instanceof Error?e.message:`unknown error`}`}))}}}catch(e){t={error:e}}finally{try{!d&&!e&&(n=f.return)&&(yield n.call(f))}finally{if(t)throw t.error}}jH((0,z.jsx)(bH,{message:`formatted ${l} of ${c} mdx file${c===1?``:`s`}${u>0?` (${u} failed)`:``}`})),yield f1(+(u>0))});var L2=function(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})};const R2=`mintlify`,z2=`templates`,B2=`main`;function V2(){return L2(this,void 0,void 0,function*(){let e=yield fetch(`https://api.github.com/repos/${R2}/${z2}/contents/?ref=${B2}`,{headers:{Accept:`application/vnd.github.v3+json`}});if(!e.ok)throw Error(`Failed to fetch templates: ${e.status} ${e.statusText}`);return(yield e.json()).filter(e=>e.type===`dir`).map(e=>e.name)})}function NRt(e){return L2(this,void 0,void 0,function*(){if(!e||e===`.`||e===`..`||e.includes(`/`))throw Error(`Invalid template name: "${e}".`);let t=`https://api.github.com/repos/${R2}/${z2}/contents/${encodeURIComponent(e)}?ref=${B2}`,n=yield fetch(t,{headers:{Accept:`application/vnd.github.v3+json`}});if(!n.ok){let t=yield V2().catch(()=>[]),n=t.length>0?` Available templates: ${t.join(`, `)}`:``;throw Error(`Template "${e}" not found in ${R2}/${z2}.${n}`)}if(!(yield n.json()).some(e=>e.name===`docs.json`))throw Error(`Template "${e}" is not a valid Mintlify template (missing docs.json).`);return e})}function PRt(){return L2(this,void 0,void 0,function*(){jH((0,z.jsx)(xH,{message:`fetching available templates...`}));let e;try{e=yield V2()}catch{throw IH(),Error(`Failed to fetch templates. Please check your network connection and try again.`)}if(IH(),e.length===0)throw Error(`No templates are currently available.`);return O0({message:`Choose a template`,choices:e.map(e=>({name:e,value:e}))})})}function FRt(e,t,n,r){return L2(this,void 0,void 0,function*(){let i=gt.join(e,`__template__.zip`),a=gt.join(e,`__template_extract__`);try{jH((0,z.jsx)(xH,{message:`downloading template "${t}"...`}));try{let e=yield fetch(`https://github.com/${R2}/${z2}/archive/refs/heads/${B2}.zip`);if(!e.ok)throw Error(`Failed to download templates archive: ${e.status}`);let t=yield e.arrayBuffer();yield k$.default.writeFile(i,Buffer.from(t))}finally{IH()}jH((0,z.jsx)(xH,{message:`extracting template...`}));try{new ZK.default(i).extractAllTo(a,!0)}finally{IH()}let n=gt.join(a,`${z2}-${B2}`),r=gt.join(n,t);if(!(yield k$.default.pathExists(r)))throw Error(`Template directory "${t}" not found in the downloaded archive.`);yield k$.default.copy(r,e,{overwrite:!0})}finally{yield k$.default.remove(i).catch(()=>{}),yield k$.default.remove(a).catch(()=>{})}let o=gt.join(e,`docs.json`);if(yield k$.default.pathExists(o)){let e=yield k$.default.readJson(o);n&&(e.name=n),r&&(e.theme=r),yield k$.default.writeJson(o,e,{spaces:2})}})}var H2=function(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})};const IRt=e=>{MH((0,z.jsx)(gH,{bold:!0,children:`Documentation Setup!`}),(0,z.jsx)(gH,{children:`To see your docs run`}),(0,z.jsxs)(hH,{children:[(0,z.jsx)(gH,{color:`blue`,children:`cd`}),(0,z.jsxs)(gH,{children:[` `,e]})]}),(0,z.jsx)(gH,{color:`blue`,children:`mint dev`})),m1()&&jH((0,z.jsxs)(gH,{children:["When the docs are ready, run `mint validate` in ",e,` to check the build and get publish steps.`]}))},LRt=(e,t,n,r)=>{let i=r===void 0?`Unable to fetch templates — use --template flag if you know the name`:r.length>0?`Templates: ${JSON.stringify(r)}`:`No templates are currently available`;MH((0,z.jsx)(gH,{children:`Agent Detected - sending AI friendly prompt`}),(0,z.jsx)(gH,{children:`<system-message>`}),(0,z.jsx)(gH,{children:"Help the user set up a Mintlify docs site with `mint new`. Ask each step one at a time unless the user asks you to skip questions or use your best judgment."}),(0,z.jsx)(gH,{children:[`- [ ] Pick a theme or clone a template? (${i})`,`- [ ] If template: which one? If theme: which one? (Themes: ${JSON.stringify(n)})`,`- [ ] Project name?`,`- [ ] Directory? (default: "${e}", auto-created if needed)${t?` ⚠️ "${e}" is occupied — subdirectory, overwrite (--force), or different path?`:``}`].join(`
|
|
@@ -2300,11 +2300,11 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
2300
2300
|
|
|
2301
2301
|
`,o=/^\n*/.exec(e.content.slice(i))?.[0].length??0,s=`
|
|
2302
2302
|
`.repeat(Math.max(0,2-o)),c=(o,c)=>{let l=o?.split(`.`)[0];if(!o||!l||!/^[A-Z]/.test(l)||t.has(l)||n.has(o)||nNe(o))return;n.add(o);let u=pTe.map(e=>`snippets/${l}${e}`).find(t=>e.readFile?.call(e,t)!==void 0),d=u&&e.readFile?.call(e,u),f=u&&d!==void 0&&o===l?y8t(d,u,l):void 0;r.push({line:c?.line,column:c?.column,message:`<${o}> is not built in, imported or exported on this page`,edit:f?{start:i,end:i,text:`${a}import ${f} from "/${u}";${s}`}:void 0})},l=(e,t)=>me(e,/* @__PURE__ */ new Set,{reference:e=>{if(e.type!==`JSXIdentifier`)return;let n=e.loc;c(String(e.name),n?.start??t)}});return ue(e.tree,e=>{if(e.type===`mdxJsxFlowElement`||e.type===`mdxJsxTextElement`){c(e.name,e.position?.start);for(let t of e.attributes){let n=t.type===`mdxJsxAttribute`?t.value:t;n&&typeof n==`object`&&l(n.data?.estree,e.position?.start)}}else(e.type===`mdxFlowExpression`||e.type===`mdxTextExpression`)&&l(e.data?.estree,e.position?.start)}),r}},x8t=FEe.filter(e=>e!==`image`),S8t=String.raw`"[^"]*"|'[^']*'|\{[^{}]*\}|[^<>"'{}]`,C8t=new RegExp(String.raw`<(${x8t.join(`|`)})(?=[\s/>])(?:${S8t})*?(\/?)>`,`g`),w8t={id:`void-tags`,group:`content`,severity:`error`,scope:`file`,description:`self-close void HTML tags (<br>, <img>, <source>, …); MDX can't parse them unclosed`,raw:!0,check:({content:e})=>{let t=C6t(e),n=[];for(let r of t.matchAll(C8t)){if(r[2])continue;let i=r.index,a=i+r[0].length;if(RegExp(`^\\s*</${r[1]}\\s*>`).test(t.slice(a)))continue;let o=e.slice(0,i).split(`
|
|
2303
|
-
`);n.push({line:o.length,column:(o.pop()?.length??0)+1,message:`<${r[1]}> must be self-closed`,edit:{start:i,end:a,text:`${e.slice(i,a-1).trimEnd()} />`}})}return n}};var T8t=function(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})};const F9=[w8t,s8t,b8t,g8t,m8t,f8t,d8t,{id:`openapi-spec`,group:`openapi`,severity:`error`,scope:`site`,description:`OpenAPI specs in docs.json or mint.json that don't parse or validate, with overlays applied`,check:e=>T8t(void 0,void 0,void 0,function*(){let t=[];try{let n=JSON.parse(yield Hn.readFile(It.join(e.baseDir,e.configFile),`utf-8`));t=F3t(e.configFile===`mint.json`?{api:{openapi:n.openapi}}:n)}catch{}if(t.length===0)return[];let n;try{n=yield I3t(e.localSchema)}catch(t){return[{file:e.configFile,message:`OpenAPI overlays: ${d1(t)}`}]}return(yield Promise.all(t.map(t=>T8t(void 0,void 0,void 0,function*(){let r=[];return yield R3t(t,e.localSchema,n,e=>r.push(e)),r.flatMap(({level:e,message:n})=>e===`error`?[{file:t,message:n}]:e===`warning`?[{file:t,message:n,severity:`warning`}]:[])})))).flat()})},...t8t];var E8t=function(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})};const D8t=e=>{try{let{variables:t}=JSON.parse(e);return t&&typeof t==`object`?t:void 0}catch{return}},O8t=(e,t)=>E8t(void 0,[e,t],void 0,function*(e,{selected:t,localSchema:n}){let r=yield N6t(e),i=/* @__PURE__ */ new Map,a=En.existsSync(It.join(e,`docs.json`))?`docs.json`:`mint.json`,o=t=>{if(!i.has(t))try{i.set(t,En.readFileSync(It.join(e,t),`utf-8`))}catch{i.set(t,void 0)}return i.get(t)};return{baseDir:e,files:r,selected:t,configFile:a,variables:D8t(o(a)??``),localSchema:n,read:o,locate:(e,t)=>{let n=o(e)??``,r=t?n.indexOf(t):-1;return r===-1?{}:D9(n,r)}}}),I9=[`content`,`nav`,`config`,`openapi`];var L9=function(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})},R9=class extends Error{};const k8t=()=>F9.map(({id:e})=>e).join(`, `),A8t=e=>{if(e===`all`)return F9;let t=F9.find(({id:t})=>t===e);if(t)return[t];if(I9.includes(e))return F9.filter(({group:t})=>t===e);throw new R9(`unknown rule or group "${e}". Groups: all, ${I9.join(`, `)}. Rules: ${k8t()}`)},j8t=({enable:e=[],disable:t=[]})=>{if([...t,...e].includes(k9.id))throw new R9(`${k9.id} always runs and can't be disabled`);let n=new Set(F9);for(let e of t)for(let t of A8t(e))n.delete(t);for(let t of e)for(let e of A8t(t))n.add(e);return F9.filter(e=>n.has(e))},M8t=(e,t)=>Object.assign(Object.assign({},t),{rule:e.id,group:e.group,severity:t.severity??e.severity}),N8t=new Map(F9.map(({id:e},t)=>[e,t])),z9=e=>e.sort((e,t)=>(e.file<t.file?-1:+(e.file>t.file))||(e.line??0)-(t.line??0)||(e.column??0)-(t.column??0)||(N8t.get(e.rule)??0)-(N8t.get(t.rule)??0)),P8t=(e,t,n,r)=>{let i=new Set(e.filter(e=>e.rule===t.id).map(r));for(let a of n)i.has(r(a))||(i.add(r(a)),e.push(M8t(t,a)))},F8t=(e,t,n)=>P8t(t,k9,n.filter(({file:t})=>!e.selected||e.selected.has(t)),({file:e})=>e),B9=e=>e.filter(e=>e.scope===`file`),I8t=(e,t,n,r)=>L9(void 0,void 0,void 0,function*(){for(let i of t)if(i.scope===`site`&&!!i.needsBuild===n)for(let t of yield i.check(e))r.push(M8t(i,t))}),L8t=(e,t)=>L9(void 0,void 0,void 0,function*(){let n=yield J6t(e,B9(t));return yield I8t(e,t,!1,n),z9(n)}),R8t=(e,t,n)=>L9(void 0,void 0,void 0,function*(){return yield I8t(e,t,!0,n),F8t(e,n,n8t(e,`parse-error`)),z9(n)}),z8t=(e,t,n)=>{let r=V6t(e,t,n);return`error`in r?0:r.approximate?1:2},B8t=(e,t)=>L9(void 0,void 0,void 0,function*(){let n=t=>e.read(t)??``,r=/* @__PURE__ */ new Map,i=({file:e,start:t,end:n})=>(r.get(e)??[]).some(({fix:e})=>t<e.end&&e.start<n);for(let{rule:e,fix:a}of t){if(!a||i(a))continue;let t=n(a.file),o=Object.assign(Object.assign({rule:e,file:a.file},D9(t,a.start)),{before:t.slice(a.start,a.end),after:a.text});r.set(a.file,[...r.get(a.file)??[],{fix:a,change:o}])}let a=new Set(e.files.filter(({kind:e})=>e===`snippet`).map(({file:e})=>e)),o=(t,n)=>z8t(t,a.has(t)?MO(n,e.variables):n,e.baseDir),s=[];for(let[t,i]of r){let r=n(t),a=E9(r,T9(i.map(({fix:e})=>e)));/\.mdx?$/.test(t)&&o(t,a)<o(t,r)||(yield Hn.writeFile(It.join(e.baseDir,t),a),s.push(...i.map(({change:e})=>e)))}return s}),V8t=(e,t,n)=>L9(void 0,void 0,void 0,function*(){let r=[],i=yield O8t(e,n),{selected:a}=n;if(a&&!i.files.some(({file:e})=>a.has(e)))throw new R9(`none of the given files are pages or snippets of this site: ${[...a].join(`, `)}`);let o=yield L8t(i,t);if(!n.fix)return{site:i,diagnostics:o,fixed:r};let s=o;for(let a=0;a<5;a++){let a=yield B8t(i,s);if(a.length===0)break;r.push(...a),i=yield O8t(e,n);let o=new Set(a.map(({file:e})=>e));s=z9(yield J6t(Object.assign(Object.assign({},i),{selected:o}),B9(t)))}return r.length===0?{site:i,diagnostics:o,fixed:r}:{site:i,diagnostics:yield L8t(i,t),fixed:r}}),H8t=e=>{let t=JSON.stringify(e);return t.length>60?`${t.slice(0,57)}..."`:t},U8t=({line:e,column:t})=>e?`${e}${t?`:${t}`:``}`:``,W8t=({diagnostic:e})=>{let t=U8t(e);return(0,z.jsxs)(gH,{children:[` `,e.severity===`error`?(0,z.jsx)(gH,{color:`red`,children:`✗`}):(0,z.jsx)(gH,{color:`yellow`,children:`!`}),` `,t&&(0,z.jsxs)(gH,{dimColor:!0,children:[t,` `]}),(0,z.jsx)(gH,{dimColor:!0,children:e.rule}),` `,e.message,e.fix&&(0,z.jsx)(gH,{dimColor:!0,children:` (fixable)`})]})},V9=(e,t)=>`${e} ${t}${e===1?``:`s`}`,G8t=e=>{for(let t of e.fixed??[])jH((0,z.jsx)(bH,{message:`fixed ${t.file}${t.line?`:${t.line}`:``} ${t.rule}: ${H8t(t.before)} → ${H8t(t.after)}`}));let t=/* @__PURE__ */ new Map;for(let n of e.diagnostics)t.get(n.file)?.push(n)??t.set(n.file,[n]);for(let[e,n]of t)jH((0,z.jsxs)(hH,{flexDirection:`column`,children:[(0,z.jsx)(gH,{bold:!0,children:e}),n.map((e,t)=>(0,z.jsx)(W8t,{diagnostic:e},t))]}));let n=e.diagnostics.filter(({fix:e})=>e).length;n>0&&!e.fixed&&jH((0,z.jsx)(yH,{message:`\`--fix\` would fix ${V9(n,`issue`)}.`}));let{build:r}=e;r.ran&&r.passed?jH((0,z.jsx)(bH,{message:`build passed`})):r.ran&&e.passed?jH((0,z.jsx)(yH,{message:`build failed only on disabled rules`})):r.ran?jH((0,z.jsx)(CH,{message:`build failed`})):r.reason===`errors found`&&jH((0,z.jsx)(yH,{message:`build skipped until the errors above are fixed`}));let{errors:i,warnings:a}=e.summary,o=V9(a,`warning`),s=a>0?`passed with ${o}`:`validation passed`,c=`${V9(i,`error`)}${a>0?`, ${o}`:``}`;jH(e.passed?(0,z.jsx)(bH,{message:s}):(0,z.jsx)(CH,{message:c}))},K8t=(e,t,n)=>{let r={};for(let{rule:t}of e)r[t]=(r[t]??0)+1;let i=e.filter(({severity:e})=>e===`error`).length;return Object.assign({passed:i===0,summary:{errors:i,warnings:e.length-i,byRule:r},diagnostics:e.map(({rule:e,group:t,severity:n,file:r,line:i,column:a,message:o,fix:s})=>Object.assign(Object.assign(Object.assign(Object.assign({rule:e,group:t,severity:n,file:r},i!==void 0&&{line:i}),a!==void 0&&{column:a}),{message:o}),s&&{fix:s})),build:t},n&&{fixed:n})};var q8t=function(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})},J8t=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols==`function`)for(var i=0,r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]]);return n};const H9={passed:0,failed:1,crashed:2},Y8t=e=>e.flatMap(e=>e.split(`,`).map(e=>e.trim()).filter(Boolean)),X8t=e=>new Promise(t=>{process.stdout.write(e,()=>t())}),Z8t=()=>{let e={log:console.log,info:console.info,warn:console.warn,error:console.error};return console.log=console.info=console.warn=console.error=(...e)=>{process.stderr.write(`${dr(...e)}\n`)},()=>Object.assign(console,e)},Q8t=(e,t)=>q8t(void 0,void 0,void 0,function*(){let n=(t??[]).map(String).filter(Boolean);if(n.length===0)return;let r=yield LLt(o1,n);return new Set(r.map(t=>It.relative(e,It.resolve(o1,t)).split(It.sep).join(`/`)))}),$8t=(e,t,...n)=>q8t(void 0,[e,t,...n],void 0,function*(e,t,n=o1){let r=e.format===`json`,i=r?Z8t():void 0;try{let a=j8t({enable:e.enable,disable:e.disable??[]}),o=yield Q8t(n,e.files);r||jH((0,z.jsx)(xH,{message:`validating...`}));let s=yield V8t(n,a,{selected:o,localSchema:e[`local-schema`],fix:e.fix}),{site:c,fixed:l}=s,{diagnostics:u}=J8t(s,[`site`,`fixed`]),d=a.some(({needsBuild:e})=>e),f;if(!e.build)f={ran:!1,reason:`disabled`};else if(!d)f={ran:!1,reason:`no build rules`};else if(u.some(({severity:e})=>e===`error`))f={ran:!1,reason:`errors found`};else{r||jH((0,z.jsx)(xH,{message:`building...`}));let{cli:n}=c1(t);c.build=yield $ut(Object.assign(Object.assign({},e),{_:[],$0:t,packageName:t,cliVersion:n,disableOpenapi:!a.some(({group:e})=>e===`openapi`)})),u=yield R8t(c,a,u),f={ran:!0,passed:c.build.passed}}let p=K8t(u,f,e.fix?l:void 0);r?(i?.(),yield X8t(`${JSON.stringify(p)}\n`)):(FH(),G8t(p),p.passed&&f.ran&&f.passed&&(yield t6t())),yield f1(p.passed?H9.passed:H9.failed)}catch(e){r?(i?.(),process.stderr.write(`Error: ${d1(e)}\n`)):(FH(),jH((0,z.jsx)(CH,{message:d1(e)}))),yield f1(H9.crashed)}}),U9=nY.hex(`#18E299`),e5t=[{title:`Preview`,commands:[{name:`dev`,description:`Start a local preview of your site`},{name:`new`,description:`Scaffold a new documentation site`},{name:`deploy`,description:`Provision a docs site without login; get Git push instructions`}]},{title:`Quality`,commands:[{name:`validate`,description:`Validate the site build (strict)`},{name:`broken-links`,description:`Find broken links before you ship`},{name:`a11y`,description:`Check site for accessibility issues`},{name:`score`,description:`Run agent-readiness checks`}]},{title:`Insights`,commands:[{name:`analytics`,description:`View analytics for your site`},{name:`automations`,description:`Create and manage automations`}]},{title:`Account`,commands:[{name:`login`,description:`Authenticate with Mintlify`},{name:`claim`,description:`Claim a site created with mint deploy`},{name:`logout`,description:`Sign out on this device`},{name:`status`,description:`View authentication status`}]},{title:`CLI`,commands:[{name:`agent setup`,description:`Install Mintlify skills and configure Admin MCP`},{name:`config`,description:`Manage CLI configuration`},{name:`instructions`,description:`Print Mintlify workflow instructions`},{name:`update`,description:`Update to the latest version`}]}],t5t=[{name:`dev`,description:`Start a local preview of your site`},{name:`new docs`,description:`Scaffold a new site in ./docs`},{name:`claim --email you@example.com`,description:`Get a claim link; use the deployment directory`},{name:`claim --code <code>`,description:`Finish the claim in the same directory`},{name:`validate`,description:`Validate your site before shipping`},{name:`broken-links`,description:`Find broken links across your site`}],n5t=e5t.flatMap(e=>e.commands).reduce((e,t)=>Math.max(e,t.name.length),0)+2,r5t=(e,t,n,r)=>` `.repeat(r)+U9(e.padEnd(n))+nY.dim(t);function i5t({packageName:e,version:t,signedIn:n,subdomain:r}){let i=`${e.charAt(0).toUpperCase()}${e.slice(1)} CLI`,a=t?/^\d/.test(t)?`v${t}`:t:void 0,o=[nY.bold(i)+(a?nY.dim(` ${a}`):``),``,n?nY.dim(`Signed in to Mintlify`):nY.dim(`Run `)+U9(`${e} login`)+nY.dim(` to sign in`),...r?[nY.dim(`Project ${r}`)]:[]],s=[``];s.push(...o);let c=t5t.reduce((t,n)=>Math.max(t,`${e} ${n.name}`.length),0)+2;s.push(``,` `+nY.bold(`EXAMPLES`));for(let t of t5t)s.push(r5t(`${e} ${t.name}`,t.description,c,3));s.push(``,` `+nY.bold(`COMMANDS`));for(let e of e5t){s.push(``,` `+nY.bold(e.title));for(let t of e.commands)s.push(r5t(t.name,t.description,n5t,5))}return s.push(``,` `+nY.dim(`Run `)+U9(`${e} <command> --help`)+nY.dim(` for details on any command.`),``),s.join(`
|
|
2303
|
+
`);n.push({line:o.length,column:(o.pop()?.length??0)+1,message:`<${r[1]}> must be self-closed`,edit:{start:i,end:a,text:`${e.slice(i,a-1).trimEnd()} />`}})}return n}};var T8t=function(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})};const F9=[w8t,s8t,b8t,g8t,m8t,f8t,d8t,{id:`openapi-spec`,group:`openapi`,severity:`error`,scope:`site`,description:`OpenAPI specs in docs.json or mint.json that don't parse or validate, with overlays applied`,check:e=>T8t(void 0,void 0,void 0,function*(){let t=[];try{let n=JSON.parse(yield Hn.readFile(It.join(e.baseDir,e.configFile),`utf-8`));t=F3t(e.configFile===`mint.json`?{api:{openapi:n.openapi}}:n)}catch{}if(t.length===0)return[];let n;try{n=yield I3t(e.localSchema)}catch(t){return[{file:e.configFile,message:`OpenAPI overlays: ${d1(t)}`}]}return(yield Promise.all(t.map(t=>T8t(void 0,void 0,void 0,function*(){let r=[];return yield R3t(t,e.localSchema,n,e=>r.push(e)),r.flatMap(({level:e,message:n})=>e===`error`?[{file:t,message:n}]:e===`warning`?[{file:t,message:n,severity:`warning`}]:[])})))).flat()})},...t8t];var E8t=function(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})};const D8t=e=>{try{let{variables:t}=JSON.parse(e);return t&&typeof t==`object`?t:void 0}catch{return}},O8t=(e,t)=>E8t(void 0,[e,t],void 0,function*(e,{selected:t,localSchema:n}){let r=yield N6t(e),i=/* @__PURE__ */ new Map,a=En.existsSync(It.join(e,`docs.json`))?`docs.json`:`mint.json`,o=t=>{if(!i.has(t))try{i.set(t,En.readFileSync(It.join(e,t),`utf-8`))}catch{i.set(t,void 0)}return i.get(t)};return{baseDir:e,files:r,selected:t,configFile:a,variables:D8t(o(a)??``),localSchema:n,read:o,locate:(e,t)=>{let n=o(e)??``,r=t?n.indexOf(t):-1;return r===-1?{}:D9(n,r)}}}),I9=[`content`,`nav`,`config`,`openapi`];var L9=function(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})},R9=class extends Error{};const k8t=()=>F9.map(({id:e})=>e).join(`, `),A8t=e=>{if(e===`all`)return F9;let t=F9.find(({id:t})=>t===e);if(t)return[t];if(I9.includes(e))return F9.filter(({group:t})=>t===e);throw new R9(`unknown rule or group "${e}". Groups: all, ${I9.join(`, `)}. Rules: ${k8t()}`)},j8t=({enable:e=[],disable:t=[]})=>{if([...t,...e].includes(k9.id))throw new R9(`${k9.id} always runs and can't be disabled`);let n=new Set(F9);for(let e of t)for(let t of A8t(e))n.delete(t);for(let t of e)for(let e of A8t(t))n.add(e);return F9.filter(e=>n.has(e))},M8t=(e,t)=>Object.assign(Object.assign({},t),{rule:e.id,group:e.group,severity:t.severity??e.severity}),N8t=new Map(F9.map(({id:e},t)=>[e,t])),z9=e=>e.sort((e,t)=>(e.file<t.file?-1:+(e.file>t.file))||(e.line??0)-(t.line??0)||(e.column??0)-(t.column??0)||(N8t.get(e.rule)??0)-(N8t.get(t.rule)??0)),P8t=(e,t,n,r)=>{let i=new Set(e.filter(e=>e.rule===t.id).map(r));for(let a of n)i.has(r(a))||(i.add(r(a)),e.push(M8t(t,a)))},F8t=(e,t,n)=>P8t(t,k9,n.filter(({file:t})=>!e.selected||e.selected.has(t)),({file:e})=>e),B9=e=>e.filter(e=>e.scope===`file`),I8t=(e,t,n,r)=>L9(void 0,void 0,void 0,function*(){for(let i of t)if(i.scope===`site`&&!!i.needsBuild===n)for(let t of yield i.check(e))r.push(M8t(i,t))}),L8t=(e,t)=>L9(void 0,void 0,void 0,function*(){let n=yield J6t(e,B9(t));return yield I8t(e,t,!1,n),z9(n)}),R8t=(e,t,n)=>L9(void 0,void 0,void 0,function*(){return yield I8t(e,t,!0,n),F8t(e,n,n8t(e,`parse-error`)),z9(n)}),z8t=(e,t,n)=>{let r=V6t(e,t,n);return`error`in r?0:r.approximate?1:2},B8t=(e,t)=>L9(void 0,void 0,void 0,function*(){let n=t=>e.read(t)??``,r=/* @__PURE__ */ new Map,i=({file:e,start:t,end:n})=>(r.get(e)??[]).some(({fix:e})=>t<e.end&&e.start<n);for(let{rule:e,fix:a}of t){if(!a||i(a))continue;let t=n(a.file),o=Object.assign(Object.assign({rule:e,file:a.file},D9(t,a.start)),{before:t.slice(a.start,a.end),after:a.text});r.set(a.file,[...r.get(a.file)??[],{fix:a,change:o}])}let a=new Set(e.files.filter(({kind:e})=>e===`snippet`).map(({file:e})=>e)),o=(t,n)=>z8t(t,a.has(t)?MO(n,e.variables):n,e.baseDir),s=[];for(let[t,i]of r){let r=n(t),a=E9(r,T9(i.map(({fix:e})=>e)));/\.mdx?$/.test(t)&&o(t,a)<o(t,r)||(yield Hn.writeFile(It.join(e.baseDir,t),a),s.push(...i.map(({change:e})=>e)))}return s}),V8t=(e,t,n)=>L9(void 0,void 0,void 0,function*(){let r=[],i=yield O8t(e,n),{selected:a}=n;if(a&&!i.files.some(({file:e})=>a.has(e)))throw new R9(`none of the given files are pages or snippets of this site: ${[...a].join(`, `)}`);let o=yield L8t(i,t);if(!n.fix)return{site:i,diagnostics:o,fixed:r};let s=o;for(let a=0;a<5;a++){let a=yield B8t(i,s);if(a.length===0)break;r.push(...a),i=yield O8t(e,n);let o=new Set(a.map(({file:e})=>e));s=z9(yield J6t(Object.assign(Object.assign({},i),{selected:o}),B9(t)))}return r.length===0?{site:i,diagnostics:o,fixed:r}:{site:i,diagnostics:yield L8t(i,t),fixed:r}}),H8t=e=>{let t=JSON.stringify(e);return t.length>60?`${t.slice(0,57)}..."`:t},U8t=({line:e,column:t})=>e?`${e}${t?`:${t}`:``}`:``,W8t=({diagnostic:e})=>{let t=U8t(e);return(0,z.jsxs)(gH,{children:[` `,e.severity===`error`?(0,z.jsx)(gH,{color:`red`,children:`✗`}):(0,z.jsx)(gH,{color:`yellow`,children:`!`}),` `,t&&(0,z.jsxs)(gH,{dimColor:!0,children:[t,` `]}),(0,z.jsx)(gH,{dimColor:!0,children:e.rule}),` `,e.message,e.fix&&(0,z.jsx)(gH,{dimColor:!0,children:` (fixable)`})]})},V9=(e,t)=>`${e} ${t}${e===1?``:`s`}`,G8t=e=>{for(let t of e.fixed??[])jH((0,z.jsx)(bH,{message:`fixed ${t.file}${t.line?`:${t.line}`:``} ${t.rule}: ${H8t(t.before)} → ${H8t(t.after)}`}));let t=/* @__PURE__ */ new Map;for(let n of e.diagnostics)t.get(n.file)?.push(n)??t.set(n.file,[n]);for(let[e,n]of t)jH((0,z.jsxs)(hH,{flexDirection:`column`,children:[(0,z.jsx)(gH,{bold:!0,children:e}),n.map((e,t)=>(0,z.jsx)(W8t,{diagnostic:e},t))]}));let n=e.diagnostics.filter(({fix:e})=>e).length;n>0&&!e.fixed&&jH((0,z.jsx)(yH,{message:`\`--fix\` would fix ${V9(n,`issue`)}.`}));let{build:r}=e;r.ran&&r.passed?jH((0,z.jsx)(bH,{message:`build passed`})):r.ran&&e.passed?jH((0,z.jsx)(yH,{message:`build failed only on disabled rules`})):r.ran?jH((0,z.jsx)(CH,{message:`build failed`})):r.reason===`errors found`&&jH((0,z.jsx)(yH,{message:`build skipped until the errors above are fixed`}));let{errors:i,warnings:a}=e.summary,o=V9(a,`warning`),s=a>0?`passed with ${o}`:`validation passed`,c=`${V9(i,`error`)}${a>0?`, ${o}`:``}`;jH(e.passed?(0,z.jsx)(bH,{message:s}):(0,z.jsx)(CH,{message:c}))},K8t=(e,t,n)=>{let r={};for(let{rule:t}of e)r[t]=(r[t]??0)+1;let i=e.filter(({severity:e})=>e===`error`).length;return Object.assign({passed:i===0,summary:{errors:i,warnings:e.length-i,byRule:r},diagnostics:e.map(({rule:e,group:t,severity:n,file:r,line:i,column:a,message:o,fix:s})=>Object.assign(Object.assign(Object.assign(Object.assign({rule:e,group:t,severity:n,file:r},i!==void 0&&{line:i}),a!==void 0&&{column:a}),{message:o}),s&&{fix:s})),build:t},n&&{fixed:n})};var q8t=function(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})},J8t=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols==`function`)for(var i=0,r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]]);return n};const H9={passed:0,failed:1,crashed:2},Y8t=e=>e.flatMap(e=>e.split(`,`).map(e=>e.trim()).filter(Boolean)),X8t=e=>new Promise(t=>{process.stdout.write(e,()=>t())}),Z8t=()=>{let e={log:console.log,info:console.info,warn:console.warn,error:console.error};return console.log=console.info=console.warn=console.error=(...e)=>{process.stderr.write(`${dr(...e)}\n`)},()=>Object.assign(console,e)},Q8t=(e,t)=>q8t(void 0,void 0,void 0,function*(){let n=(t??[]).map(String).filter(Boolean);if(n.length===0)return;let r=yield LLt(o1,n);return new Set(r.map(t=>It.relative(e,It.resolve(o1,t)).split(It.sep).join(`/`)))}),$8t=(e,t,...n)=>q8t(void 0,[e,t,...n],void 0,function*(e,t,n=o1){let r=e.format===`json`,i=r?Z8t():void 0;try{let a=j8t({enable:e.enable,disable:e.disable??[]}),o=yield Q8t(n,e.files);r||jH((0,z.jsx)(xH,{message:`validating...`}));let s=yield V8t(n,a,{selected:o,localSchema:e[`local-schema`],fix:e.fix}),{site:c,fixed:l}=s,{diagnostics:u}=J8t(s,[`site`,`fixed`]),d=a.some(({needsBuild:e})=>e),f;if(!e.build)f={ran:!1,reason:`disabled`};else if(!d)f={ran:!1,reason:`no build rules`};else if(u.some(({severity:e})=>e===`error`))f={ran:!1,reason:`errors found`};else{r||jH((0,z.jsx)(xH,{message:`building...`}));let{cli:n}=c1(t);c.build=yield $ut(Object.assign(Object.assign({},e),{_:[],$0:t,packageName:t,cliVersion:n,disableOpenapi:!a.some(({group:e})=>e===`openapi`)})),u=yield R8t(c,a,u),f={ran:!0,passed:c.build.passed}}let p=K8t(u,f,e.fix?l:void 0);r?(i?.(),yield X8t(`${JSON.stringify(p)}\n`)):(FH(),G8t(p),p.passed&&f.ran&&f.passed&&(yield t6t())),yield f1(p.passed?H9.passed:H9.failed)}catch(e){r?(i?.(),process.stderr.write(`Error: ${d1(e)}\n`)):(FH(),jH((0,z.jsx)(CH,{message:d1(e)}))),yield f1(H9.crashed)}}),U9=nY.hex(`#18E299`),e5t=[{title:`Preview`,commands:[{name:`dev`,description:`Start a local preview of your site`},{name:`new`,description:`Scaffold a new documentation site`},{name:`deploy`,description:`Provision a docs site without login; get Git push instructions`}]},{title:`Quality`,commands:[{name:`validate`,description:`Validate the site build (strict)`},{name:`broken-links`,description:`Find broken links before you ship`},{name:`a11y`,description:`Check site for accessibility issues`},{name:`score`,description:`Run agent-readiness checks`}]},{title:`Insights`,commands:[{name:`analytics`,description:`View analytics for your site`},{name:`automations`,description:`Create and manage automations`}]},{title:`Account`,commands:[{name:`login`,description:`Authenticate with Mintlify`},{name:`claim`,description:`Claim a site created with mint deploy`},{name:`logout`,description:`Sign out on this device`},{name:`status`,description:`View authentication status`}]},{title:`CLI`,commands:[{name:`agent setup`,description:`Install Mintlify skills and configure Admin MCP`},{name:`config`,description:`Manage CLI configuration`},{name:`instructions`,description:`Print Mintlify workflow instructions`},{name:`update`,description:`Update to the latest version`}]}],t5t=[{name:`dev`,description:`Start a local preview of your site`},{name:`new docs`,description:`Scaffold a new site in ./docs`},{name:`claim`,description:`Get a claim link; use the deployment directory`},{name:`validate`,description:`Validate your site before shipping`},{name:`broken-links`,description:`Find broken links across your site`}],n5t=e5t.flatMap(e=>e.commands).reduce((e,t)=>Math.max(e,t.name.length),0)+2,r5t=(e,t,n,r)=>` `.repeat(r)+U9(e.padEnd(n))+nY.dim(t);function i5t({packageName:e,version:t,signedIn:n,subdomain:r}){let i=`${e.charAt(0).toUpperCase()}${e.slice(1)} CLI`,a=t?/^\d/.test(t)?`v${t}`:t:void 0,o=[nY.bold(i)+(a?nY.dim(` ${a}`):``),``,n?nY.dim(`Signed in to Mintlify`):nY.dim(`Run `)+U9(`${e} login`)+nY.dim(` to sign in`),...r?[nY.dim(`Project ${r}`)]:[]],s=[``];s.push(...o);let c=t5t.reduce((t,n)=>Math.max(t,`${e} ${n.name}`.length),0)+2;s.push(``,` `+nY.bold(`EXAMPLES`));for(let t of t5t)s.push(r5t(`${e} ${t.name}`,t.description,c,3));s.push(``,` `+nY.bold(`COMMANDS`));for(let e of e5t){s.push(``,` `+nY.bold(e.title));for(let t of e.commands)s.push(r5t(t.name,t.description,n5t,5))}return s.push(``,` `+nY.dim(`Run `)+U9(`${e} <command> --help`)+nY.dim(` for details on any command.`),``),s.join(`
|
|
2304
2304
|
`)+`
|
|
2305
2305
|
`}var a5t=function(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})};function W9(e,t){return a5t(this,void 0,void 0,function*(){let n=yield k1(`${w1}/api/cli/workflows${e}`,Object.assign(Object.assign({},t),{headers:Object.assign({Accept:`application/json`},t?.headers)}));if(!n.ok){let e=yield n.text().catch(()=>``);throw Error(`API error (${n.status}): ${e||n.statusText}`)}return n.json()})}function o5t(e,t){return W9(`/${encodeURIComponent(e)}`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)})}function s5t(e){return W9(`/${encodeURIComponent(e)}`)}function c5t(e,t){return W9(`/${encodeURIComponent(e)}/${encodeURIComponent(t)}`,{method:`DELETE`})}const G9=[`changelog`,`source-code-agent`,`translations`,`writing-style`,`typo-check`,`broken-link-detection`,`seo-metadata-audit`,`assistant-docs-updates`,`contextual-feedback-docs-updates`];var K9=function(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})};function q9(e){return e.format===`json`?`json`:`table`}function J9(e,t){e===`table`?jH((0,z.jsx)(gH,{children:t})):process.stdout.write(t+`
|
|
2306
2306
|
`)}function Y9(e){if(!e)throw Error("No subdomain set. Pass --subdomain, or run `mint config set subdomain <name>`.");return e}function l5t(e){return K9(this,void 0,void 0,function*(){let t=It.isAbsolute(e)?e:It.join(o1,e),n=yield Hn.readFile(t,`utf-8`);return/\.ya?ml$/i.test(t)?Re.load(n):JSON.parse(n)})}function u5t(e){let t=(e.pushRepo??[]).map(String).filter(Boolean);if(e.cron&&t.length>0)throw Error(`Specify either --cron or --push-repo, not both.`);if(e.cron)return{cron:e.cron};if(t.length>0)return{push:t.map(e=>({repo:e}))};throw Error(`A trigger is required. Pass --cron <expr> or --push-repo <owner/repo>.`)}function d5t(e){if(!e.name)throw Error(`--name is required when --file is not provided.`);let t=e.type;if(t!==void 0&&!G9.includes(t))throw Error(`Invalid --type "${t}". Valid types: ${G9.join(`, `)}`);let n={name:e.name,on:u5t(e)};e.prompt&&(n.prompt=e.prompt),t&&(n.type=t),e.automerge!==void 0&&(n.automerge=e.automerge);let r=(e.contextRepo??[]).map(String).filter(Boolean);return r.length>0&&(n.context=r.map(e=>({repo:e}))),n}function X9(e){return`webhook`in e?`webhook`:`cron`in e?`cron(${e.cron})`:`push`in e?`push(${e.push.map(e=>e.repo).join(`, `)})`:`composio(${e.composio.toolkit}:${e.composio.triggerSlug})`}function f5t(e){let t=[];return t.push(nY.bold(`\nAutomation ${e.name}`)),t.push(` ${nY.dim(`ID`)} ${e._id}`),t.push(` ${nY.dim(`Status`)} ${e.status}`),e.type&&t.push(` ${nY.dim(`Type`)} ${e.type}`),t.push(` ${nY.dim(`Trigger`)} ${X9(e.trigger)}`),e.automerge!==void 0&&t.push(` ${nY.dim(`Automerge`)} ${e.automerge}`),t.join(`
|
|
2307
2307
|
`)}function p5t(e){if(e.length===0)return`No automations found.`;let t=e.map(e=>[e._id,e.name,e.type??`—`,X9(e.trigger),e.status]),n=[`ID`,`Name`,`Type`,`Trigger`,`Status`],r=n.map((e,n)=>Math.max(e.length,...t.map(e=>String(e[n]).length))),i=e=>e.map((e,t)=>e.padEnd(r[t])).join(` `);return[nY.bold(i(n)),...t.map(i)].join(`
|
|
2308
|
-
`)}const Z9=e=>e.option(`subdomain`,{type:`string`,description:`Documentation subdomain (default: mint config set subdomain)`}),Q9=e=>e.option(`format`,{type:`string`,choices:[`table`,`json`],description:`Output format (table=pretty, json=raw)`}),m5t=e=>e.middleware($Pt).command(`create`,`Create a new automation`,e=>Q9(Z9(e).option(`name`,{type:`string`,description:`Automation name`}).option(`prompt`,{type:`string`,description:`Automation prompt`}).option(`type`,{type:`string`,choices:G9,description:`Automation type`}).option(`cron`,{type:`string`,description:`Cron expression for a scheduled trigger`}).option(`push-repo`,{type:`string`,array:!0,description:`Repository (owner/repo) for a push trigger (repeatable)`}).option(`context-repo`,{type:`string`,array:!0,description:`Additional context repository (repeatable)`}).option(`automerge`,{type:`boolean`,description:`Automatically merge PRs opened by this automation`}).option(`file`,{type:`string`,description:`Path to a JSON or YAML file with the full automation body`})).example(`mint automations create --name Translations --cron "0 6 * * *" --type translations`,``).example(`mint automations create --file automation.yaml`,``),e=>K9(void 0,void 0,void 0,function*(){let t=q9(e);try{let n=Y9(e.subdomain),r=e.file?yield l5t(e.file):d5t(e);t===`table`&&jH((0,z.jsx)(xH,{message:`Creating automation...`}));let i=yield o5t(n,r);t===`table`&&IH(),n0(`cli.automation.created`,{subdomain:n,type:i.type,triggerKind:X9(i.trigger).split(`(`)[0]}),t===`json`?J9(t,JSON.stringify(i,null,2)):(jH((0,z.jsx)(bH,{message:`Created automation ${i._id}`})),J9(t,f5t(i))),yield f1(0)}catch(e){t===`table`&&IH();let n=e instanceof Error?e.message:`unknown error`;t===`json`?process.stderr.write(`Error: ${n}\n`):jH((0,z.jsx)(CH,{message:n})),yield f1(1)}})).command(`list`,`List automations for the current deployment`,e=>Q9(Z9(e)),e=>K9(void 0,void 0,void 0,function*(){let t=q9(e);try{let n=Y9(e.subdomain);t===`table`&&jH((0,z.jsx)(xH,{message:`Fetching automations...`}));let r=yield s5t(n);t===`table`&&IH(),t===`json`?J9(t,JSON.stringify(r,null,2)):J9(t,p5t(r)),yield f1(0)}catch(e){t===`table`&&IH();let n=e instanceof Error?e.message:`unknown error`;t===`json`?process.stderr.write(`Error: ${n}\n`):jH((0,z.jsx)(CH,{message:n})),yield f1(1)}})).command(`delete <id>`,`Delete an automation by ID`,e=>Q9(Z9(e)).positional(`id`,{type:`string`,demandOption:!0,description:`Automation schema ID`}),e=>K9(void 0,void 0,void 0,function*(){let t=q9(e);try{let n=Y9(e.subdomain);t===`table`&&jH((0,z.jsx)(xH,{message:`Deleting automation...`})),yield c5t(n,e.id),t===`table`&&IH(),t===`json`?J9(t,JSON.stringify({success:!0,id:e.id},null,2)):jH((0,z.jsx)(bH,{message:`Deleted automation ${e.id}`})),yield f1(0)}catch(e){t===`table`&&IH();let n=e instanceof Error?e.message:`unknown error`;t===`json`?process.stderr.write(`Error: ${n}\n`):jH((0,z.jsx)(CH,{message:n})),yield f1(1)}})).demandCommand(1,`specify a subcommand: create, list, or delete`);var $9=function(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})};const h5t=e=>{if(!process.stdout.isTTY||m1()||process.env.CLI_TEST_MODE===`true`)return!1;if(e.length===0)return!0;let t=e.filter(e=>!e.startsWith(`-`)),n=t[0],r=n===void 0||n===`help`&&t.length===1,i=n===`help`||e.includes(`--help`)||e.includes(`-h`);return r&&i},g5t=e=>$9(void 0,void 0,void 0,function*(){let{cli:t}=c1(e),n=P1(`subdomain`),r=!1;try{r=!!(yield S1())}catch{}process.stdout.write(i5t({packageName:e,version:t,signedIn:r,subdomain:n})),yield f1(0)}),_5t=({packageName:e=`mint`})=>{let t=Jbt(process.argv);if(h5t(t))return g5t(e);let n=qzt();return Zit((0,z.jsx)(lat,{})),$xt(t).scriptName(e).option(`telemetry`,{type:`boolean`,alias:`t`,description:`Enable or disable usage telemetry`}).middleware(e=>$9(void 0,void 0,void 0,function*(){e.telemetry!==void 0&&e._.length===0&&(yield qjt(e.telemetry),yield zMt({enabled:e.telemetry}),jH((0,z.jsx)(bH,{message:`telemetry ${e.telemetry?`enabled`:`disabled`}`})),yield f1(0))}),!0).middleware(gjt).middleware(Djt).middleware(n).command(`agent`,`Set up AI coding agents for Mintlify`,e=>e.command(`setup`,`Install Mintlify skills and configure Admin MCP`,e=>e.exitProcess(!1).option(`agent`,{alias:`a`,type:`string`,array:!0,choices:J0,description:`Agents to configure (defaults to interactive selection)`}).option(`global`,{alias:`g`,type:`boolean`,default:!1,description:`Set up agents for your user account instead of this project`}).example(`$0 agent setup`,`Choose agents and set up the current project`).example(`$0 agent setup --agent codex --global`,`Set up Codex for your user account`).epilog(`Requires Node.js 22.20 or later and npm. Admin MCP requires a separate OAuth sign-in in each agent.`),e=>$9(void 0,void 0,void 0,function*(){try{yield ZPt({agents:e.agent,global:e.global}),yield f1(0)}catch(e){process.stderr.write(`${e instanceof Error?e.message:`Agent setup failed.`}\n`),yield f1(1)}})).demandCommand(1,`Run mint agent setup to configure your coding agents.`)).command(`claim`,`Claim a site created with mint deploy`,e=>e.option(`email`,{type:`string`,description:`
|
|
2309
|
-
`),n=yield HMt(w1,t.credentials,e.email)}catch(e){let t=e instanceof Error?` ${e.message}`:``;process.stderr.write(`Warning: Could not create the claim link.${t} Your site is provisioned;
|
|
2308
|
+
`)}const Z9=e=>e.option(`subdomain`,{type:`string`,description:`Documentation subdomain (default: mint config set subdomain)`}),Q9=e=>e.option(`format`,{type:`string`,choices:[`table`,`json`],description:`Output format (table=pretty, json=raw)`}),m5t=e=>e.middleware($Pt).command(`create`,`Create a new automation`,e=>Q9(Z9(e).option(`name`,{type:`string`,description:`Automation name`}).option(`prompt`,{type:`string`,description:`Automation prompt`}).option(`type`,{type:`string`,choices:G9,description:`Automation type`}).option(`cron`,{type:`string`,description:`Cron expression for a scheduled trigger`}).option(`push-repo`,{type:`string`,array:!0,description:`Repository (owner/repo) for a push trigger (repeatable)`}).option(`context-repo`,{type:`string`,array:!0,description:`Additional context repository (repeatable)`}).option(`automerge`,{type:`boolean`,description:`Automatically merge PRs opened by this automation`}).option(`file`,{type:`string`,description:`Path to a JSON or YAML file with the full automation body`})).example(`mint automations create --name Translations --cron "0 6 * * *" --type translations`,``).example(`mint automations create --file automation.yaml`,``),e=>K9(void 0,void 0,void 0,function*(){let t=q9(e);try{let n=Y9(e.subdomain),r=e.file?yield l5t(e.file):d5t(e);t===`table`&&jH((0,z.jsx)(xH,{message:`Creating automation...`}));let i=yield o5t(n,r);t===`table`&&IH(),n0(`cli.automation.created`,{subdomain:n,type:i.type,triggerKind:X9(i.trigger).split(`(`)[0]}),t===`json`?J9(t,JSON.stringify(i,null,2)):(jH((0,z.jsx)(bH,{message:`Created automation ${i._id}`})),J9(t,f5t(i))),yield f1(0)}catch(e){t===`table`&&IH();let n=e instanceof Error?e.message:`unknown error`;t===`json`?process.stderr.write(`Error: ${n}\n`):jH((0,z.jsx)(CH,{message:n})),yield f1(1)}})).command(`list`,`List automations for the current deployment`,e=>Q9(Z9(e)),e=>K9(void 0,void 0,void 0,function*(){let t=q9(e);try{let n=Y9(e.subdomain);t===`table`&&jH((0,z.jsx)(xH,{message:`Fetching automations...`}));let r=yield s5t(n);t===`table`&&IH(),t===`json`?J9(t,JSON.stringify(r,null,2)):J9(t,p5t(r)),yield f1(0)}catch(e){t===`table`&&IH();let n=e instanceof Error?e.message:`unknown error`;t===`json`?process.stderr.write(`Error: ${n}\n`):jH((0,z.jsx)(CH,{message:n})),yield f1(1)}})).command(`delete <id>`,`Delete an automation by ID`,e=>Q9(Z9(e)).positional(`id`,{type:`string`,demandOption:!0,description:`Automation schema ID`}),e=>K9(void 0,void 0,void 0,function*(){let t=q9(e);try{let n=Y9(e.subdomain);t===`table`&&jH((0,z.jsx)(xH,{message:`Deleting automation...`})),yield c5t(n,e.id),t===`table`&&IH(),t===`json`?J9(t,JSON.stringify({success:!0,id:e.id},null,2)):jH((0,z.jsx)(bH,{message:`Deleted automation ${e.id}`})),yield f1(0)}catch(e){t===`table`&&IH();let n=e instanceof Error?e.message:`unknown error`;t===`json`?process.stderr.write(`Error: ${n}\n`):jH((0,z.jsx)(CH,{message:n})),yield f1(1)}})).demandCommand(1,`specify a subcommand: create, list, or delete`);var $9=function(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})};const h5t=e=>{if(!process.stdout.isTTY||m1()||process.env.CLI_TEST_MODE===`true`)return!1;if(e.length===0)return!0;let t=e.filter(e=>!e.startsWith(`-`)),n=t[0],r=n===void 0||n===`help`&&t.length===1,i=n===`help`||e.includes(`--help`)||e.includes(`-h`);return r&&i},g5t=e=>$9(void 0,void 0,void 0,function*(){let{cli:t}=c1(e),n=P1(`subdomain`),r=!1;try{r=!!(yield S1())}catch{}process.stdout.write(i5t({packageName:e,version:t,signedIn:r,subdomain:n})),yield f1(0)}),_5t=({packageName:e=`mint`})=>{let t=Jbt(process.argv);if(h5t(t))return g5t(e);let n=qzt();return Zit((0,z.jsx)(lat,{})),$xt(t).scriptName(e).option(`telemetry`,{type:`boolean`,alias:`t`,description:`Enable or disable usage telemetry`}).middleware(e=>$9(void 0,void 0,void 0,function*(){e.telemetry!==void 0&&e._.length===0&&(yield qjt(e.telemetry),yield zMt({enabled:e.telemetry}),jH((0,z.jsx)(bH,{message:`telemetry ${e.telemetry?`enabled`:`disabled`}`})),yield f1(0))}),!0).middleware(gjt).middleware(Djt).middleware(n).command(`agent`,`Set up AI coding agents for Mintlify`,e=>e.command(`setup`,`Install Mintlify skills and configure Admin MCP`,e=>e.exitProcess(!1).option(`agent`,{alias:`a`,type:`string`,array:!0,choices:J0,description:`Agents to configure (defaults to interactive selection)`}).option(`global`,{alias:`g`,type:`boolean`,default:!1,description:`Set up agents for your user account instead of this project`}).example(`$0 agent setup`,`Choose agents and set up the current project`).example(`$0 agent setup --agent codex --global`,`Set up Codex for your user account`).epilog(`Requires Node.js 22.20 or later and npm. Admin MCP requires a separate OAuth sign-in in each agent.`),e=>$9(void 0,void 0,void 0,function*(){try{yield ZPt({agents:e.agent,global:e.global}),yield f1(0)}catch(e){process.stderr.write(`${e instanceof Error?e.message:`Agent setup failed.`}\n`),yield f1(1)}})).demandCommand(1,`Run mint agent setup to configure your coding agents.`)).command(`claim`,`Claim a site created with mint deploy`,e=>e.option(`email`,{type:`string`,description:`Email of the user's Mintlify account, if known, to prefill sign-in`}).option(`code`,{type:`string`,description:`Code returned by the user from the claim page`}).option(`directory`,{type:`string`,default:`.`,description:`Original documentation directory used for mint deploy`}).conflicts(`code`,`email`).example(`$0 claim`,`Get a claim link for the current site`).example(`$0 claim --code ABCDEFGH`,`Finish a claim from an older claim link that showed a code`).epilog(`Run from the same directory as mint deploy, or pass --directory. Do not ask the user for an email; they sign in on the claim page with any account. Ask the user to open the claim link and click Confirm; there is no code to relay. --code only finishes claims from older claim links. The CLI reads saved credentials internally; do not read or print keychain secrets. Retry the same command if Mintlify signup fails.`),e=>$9(void 0,void 0,void 0,function*(){try{let t=yield GMt({apiUrl:w1,directory:e.directory,code:e.code,email:e.email},e=>process.stderr.write(`${e}\n`));process.stdout.write(`${t}\n`),yield f1(0)}catch(e){process.stderr.write(`${e instanceof Error?e.message:`Claim failed.`}\n`),yield f1(1)}})).command(`deploy`,`Provision an anonymous docs site and get Git push instructions`,e=>e.option(`subdomain`,{type:`string`,description:`Requested site name; required for the first deployment or --new`}).option(`org-name`,{type:`string`,description:`Organization display name`}).option(`directory`,{type:`string`,default:`.`,description:`Documentation directory associated with this site`}).option(`new`,{type:`boolean`,default:!1,description:`Create a new registration and site`}).option(`email`,{type:`string`,description:`Also print a claim link, prefilled with this Mintlify account email`}).option(`github`,{type:`boolean`,description:`Trust this GitHub repository to deploy the site and write a GitHub Actions workflow`}).option(`force`,{type:`boolean`,default:!1,description:`With --github, overwrite an existing .github/workflows/mintlify.yml`}).option(`base`,{type:`boolean`,description:`Provision a base, edited in the Mintlify editor, instead of a docs site`}).option(`push`,{type:`string`,description:`With --base, rebase this clone onto main and push it to the base`}).implies(`push`,`base`).conflicts(`push`,`email`).conflicts(`github`,`email`).conflicts(`base`,`github`).example(`$0 deploy --subdomain my-docs`,`Provision a site without signing in`).example(`$0 deploy --email you@example.com`,`Get repository access and a claim link for the current site`).example(`$0 deploy --new --subdomain another-site`,`Create another anonymous site`).example(`$0 deploy --base --subdomain my-base`,`Provision a base and get its editor link`).example(`$0 deploy --github --subdomain my-docs`,`Deploy the site from GitHub Actions on every push to the default branch`).example(`$0 deploy --subdomain my-docs`,`In GitHub Actions with id-token: write, push the current commit to a trusted site`).epilog(cRt),e=>$9(void 0,void 0,void 0,function*(){try{if(tRt()){let t=yield aRt({apiUrl:w1,directory:e.directory,subdomain:e.subdomain},e=>process.stderr.write(`${e}\n`));process.stdout.write(`Pushed to ${e.subdomain}; the build starts now.\nSite: ${t}\n`),yield f1(0);return}if(e.github){let t=yield bRt({apiUrl:w1,directory:e.directory,subdomain:e.subdomain,orgName:e.orgName,newSite:e.new,force:e.force},e=>process.stderr.write(`Warning: ${e}\n`),e=>process.stderr.write(`${e}\n`));process.stdout.write(`${xRt(t)}\n`),yield f1(0);return}let t=yield ZLt({apiUrl:w1,directory:e.directory,subdomain:e.subdomain,orgName:e.orgName,newSite:e.new,base:e.base},e=>{process.stderr.write(`Warning: ${e}\n`)},e=>process.stderr.write(`${e}\n`));if(e.push&&t.status===`ready`){yield sRt(e.push,t.write),process.stdout.write(`Pushed ${e.push} to the base.\nEditor: ${QLt(t.site)}\n`),yield f1(0);return}process.stdout.write(`${$Lt(t,w1)}\n`);let n;if(e.email&&t.status===`ready`)try{process.stderr.write(`Creating the claim link...
|
|
2309
|
+
`),n=yield HMt(w1,t.credentials,e.email)}catch(e){let t=e instanceof Error?` ${e.message}`:``;process.stderr.write(`Warning: Could not create the claim link.${t} Your site is provisioned; run mint claim for a claim link.\n`)}process.stdout.write(`${fRt(t,n)}\n`),yield f1(0)}catch(e){process.stderr.write(`${e instanceof Error?e.message:`Deployment failed.`}\n`),yield f1(1)}})).command(`dev`,`Initialize a local preview environment`,e=>e.option(`open`,{type:`boolean`,default:!0,description:`open a local preview in the browser`}).option(`local-schema`,{type:`boolean`,default:!1,hidden:!0,description:`use a locally hosted schema file (note: only https protocol is supported in production)`}).option(`client-version`,{type:`string`,hidden:!0,description:`the version of the client to use for cli testing`}).option(`local-client-version`,{type:`string`,hidden:!0,description:`path to local client repo to symlink for development`}).option(`groups`,{type:`array`,description:`Mock user groups for local development and testing`,example:`--groups admin user`}).option(`signed-in`,{type:`boolean`,default:!1,description:`Mock a signed-in user with no groups for local development and testing`}).option(`disable-openapi`,{type:`boolean`,default:!1,description:`Disable OpenAPI file generation`}).option(`disable-prefetch`,{type:`boolean`,default:!1,description:`Disable navigation prefetching in the local preview`}).option(`host`,{type:`boolean`,default:!1,description:`Expose the local preview on your network`}).option(`classic`,{type:`boolean`,default:!1,description:`Preview with the classic client`}).usage(`usage: mintlify dev [options]`).example(`mintlify dev`,`run with default settings (opens in browser)`).example(`mintlify dev --no-open`,`run without opening in browser`),t=>$9(void 0,void 0,void 0,function*(){yield bjt();let n=yield hjt(t),{cli:r}=c1(e),i,a;try{i=(yield S1())??void 0,a=P1(`subdomain`)??(i?(yield R1(i))[0]:void 0)}catch{}n==null?(jH((0,z.jsx)(CH,{message:`no available port found`})),yield f1(1)):yield bbt(Object.assign(Object.assign({},t),{groups:t.groups??(t.signedIn?[]:void 0),port:n,packageName:e,cliVersion:r,accessToken:i,subdomain:a,apiUrl:w1}))})).command(`validate`,`Check the docs: content, OpenAPI specs, then a strict build. Exits 0 with no errors, 1 with errors, 2 when validate itself could not run`,e=>e.option(`local-schema`,{type:`boolean`,default:!1,hidden:!0,description:`use a locally hosted schema file`}).option(`client-version`,{type:`string`,hidden:!0,description:`the version of the client to use for cli testing`}).option(`groups`,{type:`array`,description:`Mock user groups for validation`}).option(`files`,{type:`string`,array:!0,description:`Limit page checks to these files or globs; site-wide checks and the build still cover the whole site`}).option(`build`,{type:`boolean`,default:!0,description:`Run the strict build after the other checks pass; --no-build skips it, so no client download is needed. Remote OpenAPI specs are still fetched unless openapi rules are disabled`}).option(`enable`,{type:`string`,array:!0,coerce:Y8t,description:`Turn on rules or groups (comma-separated), for example after --disable all`}).option(`disable`,{type:`string`,array:!0,coerce:Y8t,description:`Turn off rules or groups (comma-separated), or all; parse errors are still reported`}).option(`fix`,{type:`boolean`,default:!1,description:`Apply the fixes and check again`}).option(`format`,{type:`string`,choices:[`text`,`json`],default:`text`,description:`Output format; json prints one report ({ passed, summary, diagnostics, build }) and nothing else on stdout, and errors to stderr`}).usage(`usage: mint validate [options]`).epilogue([`Groups: ${I9.join(`, `)}. Rules:`,...F9.map(({id:e,description:t})=>` ${e} — ${t}`),` parse-error — ${k9.description} (always runs)`].join(`
|
|
2310
2310
|
`)).example(`mint validate`,`run every check and the build`).example(`mint validate --no-build --format json`,`fast offline check for scripts and agents`).example(`mint validate --files "guides/**/*.mdx" --fix`,`check some pages and apply fixes`).example(`mint validate --disable all --enable content`,`run the content rules only; missing-file and import-error still run the build`).strict(),t=>$8t(t,e)).command(`export`,`Export a static site for air-gapped deployment`,e=>e.option(`output`,{type:`string`,default:`export.zip`,description:`output zip file path`}).option(`client-version`,{type:`string`,hidden:!0}).option(`local-client-version`,{type:`string`,hidden:!0,description:`path to local client repo to symlink for development`}).option(`groups`,{type:`array`,description:`Mock user groups for export`}).option(`base-path`,{type:`string`,description:`path prefix the export will be served under, e.g. /docs`}).option(`disable-openapi`,{type:`boolean`,default:!1,description:`Disable OpenAPI file generation`}).option(`classic`,{type:`boolean`,default:!1,description:`Export with the classic client`}).usage(`usage: mintlify export [options]`).example(`mintlify export`,`export as export.zip`).example(`mintlify export --output docs.zip`,`export to custom filename`).example(`mintlify export --base-path /docs`,`export for hosting under /docs`),t=>$9(void 0,void 0,void 0,function*(){let{cli:n}=c1(e);yield pht(Object.assign(Object.assign({},t),{packageName:e,cliVersion:n})),yield f1(0)})).command(`openapi-check <filename>`,!1,e=>e.positional(`filename`,{describe:`the filename of the OpenAPI spec (e.g. ./openapi.yaml) or the URL to the OpenAPI spec (e.g. https://petstore3.swagger.io/api/v3/openapi.json)`,type:`string`,demandOption:!0}).option(`local-schema`,{type:`boolean`,default:!1,description:`use a locally hosted schema file (note: only https protocol is supported in production)`}),e=>$9(void 0,[e],void 0,function*({filename:e,"local-schema":t}){jH((0,z.jsx)(SH,{message:"openapi-check is deprecated, use `mintlify validate` instead"}));let n;try{n=yield I3t(t)}catch(e){jH((0,z.jsx)(CH,{message:e instanceof Error?e.message:String(e)})),yield f1(1);return}let r=yield R3t(e,t,n);yield f1(+!r)})).command(`broken-links`,`Check for broken links`,e=>e.option(`files`,{type:`string`,array:!0,description:`Files or globs to check (defaults to the whole site)`}).option(`check-anchors`,{type:`boolean`,default:!1,description:`also validate anchor links (e.g. #section) against heading slugs`}).option(`check-external`,{type:`boolean`,default:!1,description:`also check external links for broken URLs`}).option(`check-snippets`,{type:`boolean`,default:!1,description:`also check links inside <Snippet> components`}).option(`check-redirects`,{type:`boolean`,default:!1,description:`also check that docs.json redirect destinations resolve to valid paths`}).example(`mint broken-links --files introduction.mdx`,`Check a specific page`).example(`mint broken-links --files "guides/**/*.mdx"`,`Check pages matching a glob`),e=>zLt(e)).command(`instructions [topics..]`,`Print Mintlify workflow instructions for agents`,e=>e.positional(`topics`,{type:`string`,array:!0,default:[],description:`Topic and optional subtopic`}).example(`mint instructions`,`List topics`).example(`mint instructions publish domain`,`Custom domain instructions`),e=>$9(void 0,[e],void 0,function*({topics:e}){if(e.length===0){process.stdout.write(GRt()),yield f1(0);return}let t;try{t=yield JRt(e)}catch(e){jH((0,z.jsx)(CH,{message:e instanceof Error?e.message:String(e)})),yield f1(1);return}yield new Promise(e=>process.stdout.write(t,()=>e())),yield f1(0)})).command(`status`,`View current authentication status`,()=>void 0,()=>$9(void 0,void 0,void 0,function*(){yield $jt(),yield f1(0)})).command(`logout`,`Logout of your Mintlify account`,()=>void 0,()=>$9(void 0,void 0,void 0,function*(){yield Pzt(),yield f1(0)})).command(`login`,`Authenticate your account to Mintlify`,()=>void 0,()=>$9(void 0,void 0,void 0,function*(){yield Azt(),yield f1(0)})).command(`signup`,`Create a new Mintlify account`,e=>e.option(`firstName`,{type:`string`,description:`First name`}).option(`lastName`,{type:`string`,description:`Last name`}).option(`company`,{type:`string`,description:`Company name`}).option(`email`,{type:`string`,description:`Email address`}).epilogue(`Note: this command does not return until the user clicks the verification link sent to their email, which can take several minutes. Non-interactive or scripted callers should run it as a background process rather than waiting on it synchronously.`),e=>$9(void 0,void 0,void 0,function*(){yield r6t({firstName:e.firstName,lastName:e.lastName,company:e.company,email:e.email}),yield f1(0)})).command(`add-domain <domain>`,`Add a custom domain to your deployment`,e=>e.positional(`domain`,{type:`string`,demandOption:!0,description:`The custom domain to add (e.g. docs.example.com)`}).option(`basePath`,{type:`string`,description:`Serve the docs under a base path (e.g. /docs)`}),e=>$9(void 0,void 0,void 0,function*(){yield rMt(e.domain,e.basePath),yield f1(0)})).command(`feedback <message>`,`Send feedback to the Mintlify team`,e=>e.positional(`message`,{type:`string`,demandOption:!0,description:`Feedback to send. Leave out API keys, tokens, and other secrets`}).option(`client-id`,{type:`string`,demandOption:!0,description:`ID for this report, so the team can tell retries apart`}).option(`category`,{choices:CRt,demandOption:!0,description:`Feedback category`}).example(`$0 feedback "mint dev crashes on a missing image" --client-id 7f3a --category bug`,`Report a bug`).epilog(`Never include API keys, tokens, passwords, or other secrets in the message.`),e=>$9(void 0,void 0,void 0,function*(){let t=yield TRt({message:e.message,clientId:e.clientId,category:e.category});yield f1(+!t)})).command(`config`,`Manage CLI configuration`,e=>e.command(`set <key> <value>`,`Set a configuration value`,e=>e.positional(`key`,{type:`string`,demandOption:!0,description:`Config key (e.g. subdomain)`}).positional(`value`,{type:`string`,demandOption:!0,description:`Config value`}),e=>$9(void 0,void 0,void 0,function*(){let t=[`subdomain`,`dateFrom`,`dateTo`];t.includes(e.key)?(yield F1(e.key,e.value),jH((0,z.jsx)(bH,{message:`${e.key} = "${e.value}"`})),yield f1(0)):(jH((0,z.jsx)(CH,{message:`Unknown config key: "${e.key}". Valid keys: ${t.join(`, `)}`})),yield f1(1))})).command(`get <key>`,`Get a configuration value`,e=>e.positional(`key`,{type:`string`,demandOption:!0,description:`Config key (e.g. subdomain, dateFrom, dateTo)`}),e=>$9(void 0,void 0,void 0,function*(){let t=[`subdomain`,`dateFrom`,`dateTo`];if(!t.includes(e.key)){jH((0,z.jsx)(CH,{message:`Unknown config key: "${e.key}". Valid keys: ${t.join(`, `)}`})),yield f1(1);return}let n=P1(e.key);jH((0,z.jsx)(gH,{children:n??`not set`})),yield f1(0)})).command(`clear <key>`,`Remove a configuration value`,e=>e.positional(`key`,{type:`string`,demandOption:!0,description:`Config key (e.g. subdomain, dateFrom, dateTo)`}),e=>$9(void 0,void 0,void 0,function*(){let t=[`subdomain`,`dateFrom`,`dateTo`];t.includes(e.key)?(yield Jjt(e.key),jH((0,z.jsx)(bH,{message:`${e.key} cleared`})),yield f1(0)):(jH((0,z.jsx)(CH,{message:`Unknown config key: "${e.key}". Valid keys: ${t.join(`, `)}`})),yield f1(1))})).demandCommand(1,`specify a subcommand: set, get, or clear`)).command(`update`,`Update the CLI to the latest version`,()=>void 0,()=>$9(void 0,void 0,void 0,function*(){yield a6t({packageName:e}),yield f1(0)})).command([`a11y`,`accessibility-check`,`a11y-check`,`accessibility`],`Check for accessibility issues in documentation`,e=>e.option(`skip-contrast`,{type:`boolean`,default:!1,description:`Skip color contrast checks`}).option(`skip-alt-text`,{type:`boolean`,default:!1,description:`Skip alt text checks on images and videos`}).check(e=>{if(e.skipContrast&&e.skipAltText)throw Error(`Cannot skip both contrast and alt-text checks`);return!0}).example(`mint a11y`,`Run all accessibility checks`).example(`mint a11y --skip-contrast`,`Only check for missing alt text`).example(`mint a11y --skip-alt-text`,`Only check color contrast`),e=>$9(void 0,void 0,void 0,function*(){let t=0,n=0;e.skipContrast||(t=yield jjt()),e.skipAltText||(n=yield zzt()),yield f1(t||n)})).command(`og [page]`,`Render the social preview (OG) image for a page`,e=>e.positional(`page`,{type:`string`,description:`Page path, such as guides/webhooks. Defaults to index`}).option(`preset`,{choices:Ds.shape.preset.unwrap().options,description:`Try a preset without editing docs.json`}).option(`surface`,{choices:Ds.shape.surface.unwrap().options,description:`Try a surface without editing docs.json`}).option(`appearance`,{choices:Ds.shape.appearance.unwrap().options,description:`Try an appearance without editing docs.json`}).option(`output`,{type:`string`,description:`Where to write the PNG. Defaults to a temporary file`}).option(`open`,{type:`boolean`,default:!0,description:`Open the image after rendering. Use --no-open in CI`}).example(`mint og guides/webhooks`,`Render one page and open it`).example(`mint og --preset headline --surface brand`,`Try settings on the home page`).example(`mint og --output og.png --no-open`,`Render to a file in CI`),e=>$9(void 0,void 0,void 0,function*(){yield f1(yield N3t(e))})).command([`version`,`v`],`Display the current version of the CLI and client`,()=>void 0,()=>$9(void 0,void 0,void 0,function*(){let{cli:t,client:n}=c1(e);jH((0,z.jsxs)(gH,{children:[(0,z.jsx)(gH,{bold:!0,color:`green`,children:`cli version`}),` `,t]})),jH((0,z.jsxs)(gH,{children:[(0,z.jsx)(gH,{bold:!0,color:`green`,children:`client version`}),` `,n]}))})).command(`new [directory]`,`Create a new Mintlify documentation site`,e=>e.positional(`directory`,{describe:`The directory to initialize your documentation`,type:`string`,default:`.`}).option(`theme`,{type:`string`,description:`Theme for the documentation site`}).option(`name`,{type:`string`,description:`Name of the documentation project`}).option(`template`,{type:`string`,description:`Use a template as a starting point`}).option(`force`,{type:`boolean`,default:!1,description:`Create the documentation in a subdirectory`}),e=>$9(void 0,[e],void 0,function*({directory:e,theme:t,name:n,force:r,template:i}){try{yield VRt(e,r,t,n,i),yield f1(0)}catch(e){jH((0,z.jsx)(CH,{message:e instanceof Error?e.message:`error occurred`})),yield f1(1)}})).command(`analytics`,`View analytics for your documentation`,CFt).command([`automations`,`workflow`,`workflows`],`Create and manage automations`,m5t).command(`score [url]`,`Run agent readiness checks on a docs site`,e=>e.positional(`url`,{type:`string`,description:`URL of the docs site to check (defaults to your configured subdomain)`}).option(`format`,{type:`string`,choices:[`table`,`plain`,`json`],description:`Output format`}).example(`mint score`,`Run agent readiness checks on your default subdomain`).example(`mint score docs.example.com`,`Run agent readiness checks on a URL`),Q3t).command(`format`,`Format MDX files in the current directory`,e=>e.usage(`usage: mint format`).example(`mint format`,`format all MDX files in the current directory`),MRt).command(`migrate`,`Print instructions for migrating a docs site to Mintlify`,e=>e.option(`from`,{type:`string`,choices:$2(`sources`),description:`Include instructions for a source platform`}).option(`topic`,{type:`string`,choices:$2(`topics`),description:`Print a single topic`}).option(`agent`,{type:`string`,choices:Object.keys(e4),description:`Run the migration with a coding agent`}).option(`claude`,{type:`boolean`,description:`Alias for --agent claude`}),e=>$9(void 0,void 0,void 0,function*(){let t=e.agent??(e.claude?`claude`:void 0);if(n0(`cli.migrate.executed`,{from:e.from,topic:e.topic,agent:t}),t)try{return yield f1(yield $zt(t,e.from))}catch(e){return jH((0,z.jsx)(CH,{message:e instanceof Error?e.message:String(e)})),yield f1(1)}yield new Promise(t=>process.stdout.write(Xzt(e),()=>t())),yield f1(0)})).command(`ai`,`[Coming soon] AI-powered documentation (run mint ai to vote)`,()=>void 0,VLt(`ai`,e)).command(`mcp`,`[Coming soon] MCP server for documentation (run mint mcp to vote)`,()=>void 0,VLt(`mcp`,e)).strictCommands().demandCommand(1,`unknown command. see above for the list of supported commands.`).alias(`h`,`help`).alias(`v`,`version`).parseAsync()};var v5t=function(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})};_5t({packageName:process.env.MINTLIFY_PACKAGE_NAME??`mint`}).catch(e=>{console.error(e instanceof Error?e.message:e),process.exit(1)});function y5t(e){return v5t(this,void 0,void 0,function*(){yield i1(),process.exit(e)})}process.once(`beforeExit`,()=>v5t(void 0,void 0,void 0,function*(){try{yield i1()}catch{}})),process.on(`SIGINT`,()=>{y5t(130)}),process.on(`SIGTERM`,()=>{y5t(143)});export{};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mintlify/cli",
|
|
3
|
-
"version": "4.1.
|
|
3
|
+
"version": "4.1.2",
|
|
4
4
|
"description": "The Mintlify CLI",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": ">=18.0.0"
|
|
@@ -113,5 +113,5 @@
|
|
|
113
113
|
"yargs": "17.7.1",
|
|
114
114
|
"zod": "4.3.6"
|
|
115
115
|
},
|
|
116
|
-
"gitHead": "
|
|
116
|
+
"gitHead": "a4608233dd751191e146dd173c8e4d61656b1fbd"
|
|
117
117
|
}
|