shadcn 4.9.0 → 4.10.0
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/chunk-MKTVVRV2.js +108 -0
- package/dist/{chunk-NAQBA4XN.js → chunk-OY2PM3KO.js} +4 -4
- package/dist/index.d.ts +156 -0
- package/dist/index.js +69 -69
- package/dist/mcp/index.js +1 -1
- package/dist/registry/index.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-2X25ZGWB.js +0 -97
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import {m,l,f,d as d$1,c as c$1,e,n,u,p,b as b$1,q as q$1,r,s,t,y,A,w,o,g as g$1}from'./chunk-3ORLOMOE.js';import {a,d,c,b,g,f as f$1}from'./chunk-7SBJAAAY.js';import*as R from'path';import R__default,{join,basename,normalize,delimiter,resolve,dirname}from'path';import {z}from'zod';import qn,{promises,existsSync,statSync}from'fs';import {green,cyan,yellow,red}from'kleur/colors';import K from'fs-extra';import Et from'fast-glob';import {loadConfig,createMatchPath}from'tsconfig-paths';import {cosmiconfig}from'cosmiconfig';import cu,{tmpdir,homedir}from'os';import da from'ora';import {Project,SyntaxKind,ScriptKind,QuoteKind}from'ts-morph';import {transformFromAstSync}from'@babel/core';import {parse}from'@babel/parser';import va from'@babel/plugin-transform-typescript';import*as $t from'recast';import Na from'prompts';import je from'deepmerge';import {HttpsProxyAgent}from'https-proxy-agent';import xc,{Headers}from'node-fetch';import {execa}from'execa';import {createHash}from'crypto';import Qc from'stringify-object';import Z,{cwd}from'process';import Zl from'readline';import au from'events';import*as Yi from'fs/promises';import Yi__default from'fs/promises';import {createRequire}from'module';import {spawn}from'child_process';import {PassThrough}from'stream';import lu from'tty';import fh from'fuzzysort';var xe=process.env.REGISTRY_URL??"https://ui.shadcn.com/r",F=xe.replace(/\/r\/?$/,""),dt="new-york-v4",Ps=[{name:"neutral",label:"Neutral"},{name:"zinc",label:"Zinc"},{name:"stone",label:"Stone"},{name:"mauve",label:"Mauve"},{name:"olive",label:"Olive"},{name:"mist",label:"Mist"},{name:"taupe",label:"Taupe"}],G={"@shadcn":`${xe}/styles/{style}/{name}.json`};var Ah=[{name:"toast",deprecatedBy:"sonner",message:"The toast component is deprecated. Use the sonner component instead."},{name:"toaster",deprecatedBy:"sonner",message:"The toaster component is deprecated. Use the sonner component instead."}];var N={NETWORK_ERROR:"NETWORK_ERROR",NOT_FOUND:"NOT_FOUND",GONE:"GONE",UNAUTHORIZED:"UNAUTHORIZED",FORBIDDEN:"FORBIDDEN",FETCH_ERROR:"FETCH_ERROR",NOT_CONFIGURED:"NOT_CONFIGURED",INVALID_CONFIG:"INVALID_CONFIG",MISSING_ENV_VARS:"MISSING_ENV_VARS",LOCAL_FILE_ERROR:"LOCAL_FILE_ERROR",PARSE_ERROR:"PARSE_ERROR",VALIDATION_ERROR:"VALIDATION_ERROR",UNKNOWN_ERROR:"UNKNOWN_ERROR"},j=class extends Error{code;statusCode;context;suggestion;timestamp;cause;constructor(t,r={}){super(t),this.name="RegistryError",this.code=r.code||N.UNKNOWN_ERROR,this.statusCode=r.statusCode,this.cause=r.cause,this.context=r.context,this.suggestion=r.suggestion,this.timestamp=new Date,Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor);}toJSON(){return {name:this.name,message:this.message,code:this.code,statusCode:this.statusCode,context:this.context,suggestion:this.suggestion,timestamp:this.timestamp,stack:this.stack}}},ve=class extends j{constructor(r,s){let i=`The item at ${r} was not found. It may not exist at the registry.`;super(i,{code:N.NOT_FOUND,statusCode:404,cause:s,context:{url:r},suggestion:"Check if the item name is correct and the registry URL is accessible."});this.url=r;this.name="RegistryNotFoundError";}},ft=class extends j{constructor(r,s){let i=`The item at ${r} is no longer available. It may have been removed or expired.`;super(i,{code:N.GONE,statusCode:410,cause:s,context:{url:r},suggestion:"This resource was previously available but has been permanently removed. Check if a newer version exists or contact the registry maintainer."});this.url=r;this.name="RegistryGoneError";}},Fe=class extends j{constructor(r,s){let i=`You are not authorized to access the item at ${r}. If this is a remote registry, you may need to authenticate.`;super(i,{code:N.UNAUTHORIZED,statusCode:401,cause:s,context:{url:r},suggestion:"Check your authentication credentials and environment variables."});this.url=r;this.name="RegistryUnauthorizedError";}},De=class extends j{constructor(r,s){let i=`You are not authorized to access the item at ${r}. If this is a remote registry, you may need to authenticate.`;super(i,{code:N.FORBIDDEN,statusCode:403,cause:s,context:{url:r},suggestion:"Check your authentication credentials and environment variables."});this.url=r;this.name="RegistryForbiddenError";}},We=class extends j{constructor(r,s,i,n){let o=s?`Failed to fetch from registry (${s}): ${r}`:`Failed to fetch from registry: ${r}`,c=typeof n=="string"&&n?`${o} - ${n}`:o,a="Check your network connection and try again.";s===404?a="The requested resource was not found. Check the URL or item name.":s===500?a="The registry server encountered an error. Try again later.":s&&s>=400&&s<500&&(a="There was a client error. Check your request parameters.");super(c,{code:N.FETCH_ERROR,statusCode:s,cause:n,context:{url:r,responseBody:i},suggestion:a});this.url=r;this.responseBody=i;this.name="RegistryFetchError";}},ae=class extends j{constructor(r){let s=r?`Unknown registry "${r}". Make sure it is defined in components.json as follows:
|
|
2
|
+
{
|
|
3
|
+
"registries": {
|
|
4
|
+
"${r}": "[URL_TO_REGISTRY]"
|
|
5
|
+
}
|
|
6
|
+
}`:'Unknown registry. Make sure it is defined in components.json under "registries".';super(s,{code:N.NOT_CONFIGURED,context:{registryName:r},suggestion:"Add the registry configuration to your components.json file. Consult the registry documentation for the correct format."});this.registryName=r;this.name="RegistryNotConfiguredError";}},ee=class extends j{constructor(r,s,i={}){super(i.message??`Failed to read local registry file: ${r}`,{code:N.LOCAL_FILE_ERROR,cause:s,context:{filePath:r,...i.context},suggestion:i.suggestion??"Check if the file exists and you have read permissions."});this.filePath=r;this.name="RegistryLocalFileError";}},W=class extends j{constructor(r,s,i={}){super(i.message??`Failed to read registry source file: ${r}`,{code:N.FETCH_ERROR,cause:s,context:{filePath:r,...i.context},suggestion:i.suggestion??"Check if the source file exists and is accessible."});this.filePath=r;this.name="RegistrySourceFileError";}},M=class extends j{constructor(r,s,i={}){let n=i.subject??"registry item",o=`Failed to parse ${n}: ${r}`;s instanceof z.ZodError&&(o=`Failed to parse ${n}: ${r}
|
|
7
|
+
${s.errors.map(c=>` - ${c.path.join(".")}: ${c.message}`).join(`
|
|
8
|
+
`)}`);super(o,{code:N.PARSE_ERROR,cause:s,context:{item:r,...i.context},suggestion:i.suggestion??`The registry item may be corrupted or have an invalid format. Please make sure it returns a valid JSON object. See ${F}/schema/registry-item.json.`});this.item=r;this.parseError=s,this.name="RegistryParseError";}parseError},S=class extends j{constructor(t,r={}){super(t,{code:N.VALIDATION_ERROR,cause:r.cause,context:{...r.registryFile?{registryFile:r.registryFile}:{},...r.context},suggestion:r.suggestion??"Update the registry.json file and try running the command again."}),this.name="RegistryValidationError";}},be=class extends j{constructor(r){super(`Registry item "${r}" was not found.`,{code:N.NOT_FOUND,statusCode:404,context:{itemName:r},suggestion:"Check that the item name exists in the resolved registry catalog."});this.itemName=r;this.name="RegistryItemNotFoundError";}},He=class extends j{constructor(r,s){let i=`Registry "${r}" requires the following environment variables:
|
|
9
|
+
|
|
10
|
+
`+s.map(n=>` \u2022 ${n}`).join(`
|
|
11
|
+
`);super(i,{code:N.MISSING_ENV_VARS,context:{registryName:r,missingVars:s},suggestion:"Set the required environment variables to your .env or .env.local file."});this.registryName=r;this.missingVars=s;this.name="RegistryMissingEnvironmentVariablesError";}},ze=class extends j{constructor(r){let s=`Invalid registry namespace: "${r}". Registry names must start with @ (e.g., @shadcn, @v0).`;super(s,{code:N.VALIDATION_ERROR,context:{name:r},suggestion:"Use a valid registry name starting with @ or provide a direct URL to the registry."});this.name=r;this.name="RegistryInvalidNamespaceError";}};var pt=class extends j{constructor(r,s){let i=`Invalid components.json configuration in ${r}.`;s instanceof z.ZodError&&(i=`Invalid components.json configuration in ${r}:
|
|
12
|
+
${s.errors.map(n=>` - ${n.path.join(".")}: ${n.message}`).join(`
|
|
13
|
+
`)}`);super(i,{code:N.INVALID_CONFIG,cause:s,context:{cwd:r},suggestion:"Check your components.json file for syntax errors or invalid configuration. Run 'npx shadcn@latest init' to regenerate a valid configuration."});this.cwd=r;this.name="ConfigParseError";}},Ve=class extends j{parseError;constructor(t){let r="Failed to parse registries index";if(t instanceof z.ZodError){let s=t.errors.filter(i=>i.path.length>0).map(i=>`"${i.path[0]}"`).filter((i,n,o)=>o.indexOf(i)===n);s.length>0?r=`Failed to parse registries index. Invalid registry namespace(s): ${s.join(", ")}
|
|
14
|
+
${t.errors.map(i=>` - ${i.path.join(".")}: ${i.message}`).join(`
|
|
15
|
+
`)}`:r=`Failed to parse registries index:
|
|
16
|
+
${t.errors.map(i=>` - ${i.path.join(".")}: ${i.message}`).join(`
|
|
17
|
+
`)}`;}super(r,{code:N.PARSE_ERROR,cause:t,context:{parseError:t},suggestion:"The registries index may be corrupted or have invalid registry namespace format. Registry names must start with @ (e.g., @shadcn, @example)."}),this.parseError=t,this.name="RegistriesIndexParseError";}};var wo=/^(@[a-zA-Z0-9](?:[a-zA-Z0-9-_]*[a-zA-Z0-9])?)\/(.+)$/;function ce(e){if(!e.startsWith("@"))return {registry:null,item:e};let t=e.match(wo);return t?{registry:t[1],item:t[2]}:{registry:null,item:e}}var H={"next-app":{name:"next-app",label:"Next.js",links:{installation:`${F}/docs/installation/next`,tailwind:"https://tailwindcss.com/docs/guides/nextjs"}},"next-pages":{name:"next-pages",label:"Next.js",links:{installation:`${F}/docs/installation/next`,tailwind:"https://tailwindcss.com/docs/guides/nextjs"}},remix:{name:"remix",label:"Remix",links:{installation:`${F}/docs/installation/remix`,tailwind:"https://tailwindcss.com/docs/guides/remix"}},"react-router":{name:"react-router",label:"React Router",links:{installation:`${F}/docs/installation/react-router`,tailwind:"https://tailwindcss.com/docs/installation/framework-guides/react-router"}},vite:{name:"vite",label:"Vite",links:{installation:`${F}/docs/installation/vite`,tailwind:"https://tailwindcss.com/docs/guides/vite"}},astro:{name:"astro",label:"Astro",links:{installation:`${F}/docs/installation/astro`,tailwind:"https://tailwindcss.com/docs/guides/astro"}},laravel:{name:"laravel",label:"Laravel",links:{installation:`${F}/docs/installation/laravel`,tailwind:"https://tailwindcss.com/docs/guides/laravel"}},"tanstack-start":{name:"tanstack-start",label:"TanStack Start",links:{installation:`${F}/docs/installation/tanstack`,tailwind:"https://tailwindcss.com/docs/installation/using-postcss"}},gatsby:{name:"gatsby",label:"Gatsby",links:{installation:`${F}/docs/installation/gatsby`,tailwind:"https://tailwindcss.com/docs/guides/gatsby"}},expo:{name:"expo",label:"Expo",links:{installation:`${F}/docs/installation/expo`,tailwind:"https://www.nativewind.dev/docs/getting-started/installation"}},manual:{name:"manual",label:"Manual",links:{installation:`${F}/docs/installation/manual`,tailwind:"https://tailwindcss.com/docs/installation"}}};var P={error:red,warn:yellow,info:cyan,success:green};function mt(e){let t=[e];for(;t.length;){let r=t.shift();if(typeof r=="string"){if(r.startsWith("./"))return r;continue}if(Array.isArray(r)){t.unshift(...r);continue}r&&typeof r=="object"&&t.unshift(...Object.values(r));}return null}function gt(e){if(!e.includes("*"))return "strip_extension";let t=e.slice(e.indexOf("*")+1);return t&&/^\.[^/]+$/.test(t)?"strip_extension":"preserve_extension"}function yt(e,t){let r=t.find(i=>!i.hasWildcard&&i.key===e);if(r)return {path:R__default.resolve(r.rootDir,r.target),matchedAlias:r.key,matchedTarget:r.target,emitMode:r.emitMode};let s=t.filter(i=>i.hasWildcard).sort((i,n)=>n.key.length-i.key.length);for(let i of s){let n=Ut(e,i.key,{allowBareAliasBase:true});if(n!==null)return {path:R__default.resolve(i.rootDir,Io(i.target,n)),matchedAlias:i.key,matchedTarget:i.target,emitMode:i.emitMode}}return null}function Ut(e,t,r={}){if(!t.includes("*"))return e===t?"":null;let[s,i=""]=t.split("*");return e.startsWith(s)&&e.endsWith(i)?i?e.slice(s.length,-i.length):e.slice(s.length):r.allowBareAliasBase&&i===""&&s.endsWith("/")&&e===s.slice(0,-1)?"":null}function Io(e,t){if(!e.includes("*"))return e;let[r,s=""]=e.split("*");return t?`${r}${t}${s}`:r.replace(/\/$/,"")}function le(e="",t=true){let r=R__default.join(e,"package.json");return K.readJSONSync(r,{throws:t})}var Kt=new Map;function Bt(e){let t=R__default.resolve(e),r=Kt.get(t);if(r)return r;let i=le(e,false)?.imports;if(!i||typeof i!="object"||Array.isArray(i))return Kt.set(t,[]),[];let n=[];for(let[o,c]of Object.entries(i)){if(!o.startsWith("#"))continue;let a=mt(c);a&&n.push({key:o,aliasBase:o==="#*"?"#":o.endsWith("/*")?o.slice(0,-2):o,target:a,emitMode:gt(a),hasWildcard:o.includes("*"),rootDir:t});}return Kt.set(t,n),n}function Os(e){let t=Bt(e).map(r=>r.aliasBase);return t.length?To(t):null}function Ue(e,t){return yt(e,Bt(t))}function js(e){let t=Bt(e),r=t.some(s=>s.key==="#*")?{components:"#components",ui:"#components/ui",lib:"#lib",hooks:"#hooks",utils:"#lib/utils"}:null;return {components:Ge(t,"components")??r?.components,ui:Ge(t,"ui")??r?.ui,lib:Ge(t,"lib")??r?.lib,hooks:Ge(t,"hooks")??r?.hooks,utils:Ge(t,"utils")??r?.utils}}function Ge(e,t){return e.map(s=>({entry:s,score:ko(s,t)})).filter(s=>s.score>0).sort((s,i)=>i.score-s.score||i.entry.aliasBase.length-s.entry.aliasBase.length)[0]?.entry.aliasBase}function ko(e,t){let r=e.aliasBase.toLowerCase(),s=$o(e.target).toLowerCase();switch(t){case "components":return r.endsWith("/ui")||s.includes("/components/ui")?0:wt(r,"components")?4:wt(s,"components")?3:0;case "ui":return r.endsWith("/ui")||r==="#ui"?5:s.includes("/components/ui")?4:s.endsWith("/ui")?3:0;case "lib":return r==="#lib"||r.endsWith("/lib")?5:s.endsWith("/lib")?4:wt(s,"lib")?3:0;case "hooks":return r==="#hooks"||r.endsWith("/hooks")?5:s.endsWith("/hooks")?4:wt(s,"hooks")?3:0;case "utils":return r==="#utils"||r.endsWith("/utils")?5:s.endsWith("/lib/utils")?4:s.endsWith("/utils")?3:0}}function $o(e){return e.replace(/\/\*$/,"").replace(/\*$/,"").replace(/\/index\.[^/]+$/,"")}function wt(e,t){return e===t||e.includes(`/${t}`)||e.includes(`${t}/`)}function To(e){let t=e.map(r=>r.slice(1).split("/").filter(Boolean)).reduce((r,s,i)=>i?r.filter((n,o)=>s[o]===n):s,[]);return t.length?`#${t.join("/")}`:"#"}var C={error(...e){console.log(P.error(e.join(" ")));},warn(...e){console.log(P.warn(e.join(" ")));},info(...e){console.log(P.info(e.join(" ")));},success(...e){console.log(P.success(e.join(" ")));},log(...e){console.log(e.join(" "));},break(){console.log("");}};var Po=["next.config.*","vite.config.*","astro.config.*","remix.config.*","nuxt.config.*","svelte.config.*","gatsby-config.*","angular.json"];async function sd(e){if(K.existsSync(R__default.resolve(e,"pnpm-workspace.yaml")))return true;let t=R__default.resolve(e,"package.json");if(K.existsSync(t))try{if((await K.readJson(t)).workspaces)return !0}catch{}return !!(K.existsSync(R__default.resolve(e,"lerna.json"))||K.existsSync(R__default.resolve(e,"nx.json")))}async function id(e){let t=await xt(e);if(!t.length)return [];let r=await Et(t,{cwd:e,onlyDirectories:true,ignore:["**/node_modules/**"]}),s=[];for(let i of r){let n=R__default.resolve(e,i);if(!K.existsSync(R__default.resolve(n,"package.json")))continue;let o=K.existsSync(R__default.resolve(n,"components.json")),c=Po.some(a=>Et.sync(a,{cwd:n,dot:true}).length>0);(o||c)&&s.push({name:i,hasConfig:o});}return s}function nd(e,t,r){let s=r?.cwdFlag??"-c";C.break(),C.log(`It looks like you are running ${P.info(e)} from a monorepo root.`),C.log(`To use shadcn in a specific workspace, use the ${P.info(s)} flag:`),C.break();for(let i of t)C.log(` shadcn ${e} ${s} ${i.name}`);C.break();}async function xt(e){let t=[],r=R__default.resolve(e,"pnpm-workspace.yaml");if(K.existsSync(r)){let i=await K.readFile(r,"utf8");t.push(...Ao(i));}let s=R__default.resolve(e,"package.json");if(K.existsSync(s))try{let i=await K.readJson(s),n=Array.isArray(i.workspaces)?i.workspaces:i.workspaces?.packages;Array.isArray(n)&&t.push(...n.filter(o=>!o.startsWith("!")));}catch{}return Array.from(new Set(t))}function Ao(e){let t=[],r=false,s=0;for(let i of e.split(`
|
|
18
|
+
`)){let n=i.trim();if(!n||n.startsWith("#"))continue;let o=i.match(/^(\s*)([A-Za-z0-9_-]+)\s*:/);if(o){s=o[1].length,r=o[2]==="packages";continue}if(!r)continue;let c=i.match(/^(\s*)-\s*(.+?)\s*(?:#.*)?$/);!c||c[1].length<=s||t.push(c[2].trim().replace(/^["']|["']$/g,""));}return t}var Ns=new Map,qt=new Map,vt=new Map;async function Ms(e,t){let r=Do(e);if(!r)return null;let s=await No(t,r.packageName);return s?yt(e,_o(s)):null}function _o(e){let t=`${e.packageRoot}:${e.packageName}`,r=qt.get(t);if(r)return r;let i=le(e.packageRoot,false)?.exports;if(!i||typeof i!="object"||Array.isArray(i))return qt.set(t,[]),[];let n=[];for(let[o,c]of Object.entries(i)){if(o!=="."&&!o.startsWith("./"))continue;let a=mt(c);if(!a)continue;let h=Wo(e.packageName,o);n.push({key:o.includes("*")?`${h}/*`:h,aliasBase:h,target:a,emitMode:gt(a),hasWildcard:o.includes("*"),rootDir:e.packageRoot});}return qt.set(t,n),n}async function No(e,t){let r=await Lo(e);if(!r)return null;let s=Ns.get(r);if(s?.has(t))return s.get(t)??null;let i=await Mo(r);return Ns.set(r,i),i.get(t)??null}async function Mo(e){let t=await xt(e),r=new Map;if(!t.length)return r;let s=await Et(t.map(i=>R__default.posix.join(i.split(R__default.sep).join("/"),"package.json")),{cwd:e,ignore:["**/node_modules/**"]});for(let i of s){let n=R__default.resolve(e,R__default.dirname(i)),c=le(n,false)?.name;c&&r.set(c,{packageName:c,packageRoot:n});}return r}async function Lo(e){let t=R__default.resolve(e),r=vt.get(t);if(r!==void 0)return r;let s=t,i=await Fo(t);for(;;){if((await xt(s)).length)return vt.set(t,s),s;if(i&&s===i)return vt.set(t,null),null;let o=R__default.dirname(s);if(o===s)return vt.set(t,null),null;s=o;}}async function Fo(e){let t=R__default.resolve(e);for(;;){if(K.existsSync(R__default.resolve(t,".git")))return t;let r=R__default.dirname(t);if(r===t)return null;t=r;}}function Do(e){if(e.startsWith("#")||e.startsWith(".")||R__default.isAbsolute(e))return null;let t=e.split("/");return e.startsWith("@")?t.length<2?null:{packageName:`${t[0]}/${t[1]}`}:{packageName:t[0]}}function Wo(e,t){if(t===".")return e;let r=t.slice(2).replace(/\/\*$/,"");return r?`${e}/${r}`:e}async function Ke(e,t){let r=t.cwd??t.absoluteBaseUrl;if(e.startsWith("#")){let i=Ue(e,r);if(i)return {path:i.path,source:"package_imports",matchedAlias:i.matchedAlias,matchedTarget:i.matchedTarget,emitMode:i.emitMode}}let s=await Ms(e,r);return s?{path:s.path,source:"workspace_package_exports",matchedAlias:s.matchedAlias,matchedTarget:s.matchedTarget,emitMode:s.emitMode}:Vo(e,t)}function Jt(e,t){return e.startsWith("#")?true:t?e.startsWith(`${t}/`):false}function zo(e){return /^@[^/]+\/[^/]+(?:\/.*)?$/.test(e)}function Vo(e,t){let r=createMatchPath(t.absoluteBaseUrl,t.paths)(e,void 0,()=>true,[".ts",".tsx",".jsx",".js",".css"]);if(!r)return null;let s=Go(e,t.paths);return !s&&zo(e)?null:{path:r,source:"tsconfig_paths",matchedAlias:s?.key??e,matchedTarget:s?.target??r,emitMode:"strip_extension"}}function Go(e,t){for(let[r,s]of Object.entries(t)){let i=Array.isArray(s)?s:[s],n=Ut(e,r);if(n!==null)return {key:r,target:i[0]?.includes("*")&&n!==null?i[0].replace(/\*/g,n):i[0]}}return null}var $d="@/components",Td="@/lib/utils",Pd="app/globals.css",Ad="tailwind.config.js";var bt=cosmiconfig("components",{searchPlaces:["components.json"]});async function qe(e){let t=await Jo(e);return t?(t.iconLibrary||(t.iconLibrary=t.style==="new-york"?"radix":"lucide"),await Rt(e,t)):null}async function Rt(e,t){t.registries={...G,...t.registries||{}};let r=await loadConfig(e);if(r.resultType==="failed")throw new Error(`Failed to load ${t.tsx?"tsconfig":"jsconfig"}.json. ${r.message??""}`.trim());let s=await Be("utils",t.aliases.utils,e,r),i=await Be("components",t.aliases.components,e,r),n=t.aliases.ui?await Be("ui",t.aliases.ui,e,r):R__default.resolve(i??e,"ui"),o=t.aliases.lib?await Be("lib",t.aliases.lib,e,r):R__default.resolve(s??e,".."),c=t.aliases.hooks?await Be("hooks",t.aliases.hooks,e,r):R__default.resolve(i??e,"..","hooks");return qo(e,{components:i,utils:s,ui:n,lib:o,hooks:c}),d$1.parse({...t,resolvedPaths:{cwd:e,tailwindConfig:t.tailwind.config?R__default.resolve(e,t.tailwind.config):"",tailwindCss:R__default.resolve(e,t.tailwind.css),utils:s,components:i,ui:n,lib:o,hooks:c}})}async function Be(e,t,r,s){let i=await Ke(t,{...s,cwd:r});if(!i?.path||t.startsWith("#")&&i.path===R__default.resolve(r,t))return null;if(e!=="utils"&&(i.source==="package_imports"||i.source==="workspace_package_exports")){if(!i.matchedAlias.includes("*")&&/\/index\.[^/]+$/.test(i.path))return R__default.dirname(i.path);if(i.matchedAlias.includes("*")&&/\.[^/]+$/.test(i.path))return i.path.replace(/\.[^/]+$/,"")}return i.path}function qo(e,t){let r=["components","ui","lib","hooks","utils"].filter(s=>!t[s]);if(r.length)throw new Error([`Could not resolve the following aliases in ${P.info(e)}: ${P.info(r.join(", "))}.`,`Configure path aliases in ${P.info("tsconfig.json")} or imports in ${P.info("package.json")} for this workspace and try again.`].join(`
|
|
19
|
+
`))}async function Jo(e){try{let t=await bt.search(e);if(!t)return null;let r=c$1.parse(t.config);if(r.registries){for(let s of Object.keys(r.registries))if(s in G)throw new Error(`"${s}" is a built-in registry and cannot be overridden.`)}return r}catch(t){let r=`${e}/components.json`;throw t instanceof Error&&t.message.includes("reserved registry")?t:new Error(`Invalid configuration found in ${P.info(r)}.`)}}async function Od(e$1){let t={};for(let s of Object.keys(e$1.aliases)){if(!Zo(s,e$1))continue;let i=e$1.resolvedPaths[s],n=await Yo(e$1.resolvedPaths.cwd,i);if(!n){t[s]=e$1;continue}let o=await qe(n);if(!o)throw new Error([`Could not load the workspace config in ${P.info(n)}.`,`Add ${P.info("components.json")} to this workspace and configure its path aliases or package imports, then try again.`].join(`
|
|
20
|
+
`));t[s]=o;}let r=e.safeParse(t);return r.success?r.data:null}async function Yo(e,t){let r=Xo(e,t),s=R__default.relative(r,t),n=(await Et.glob("**/package.json",{cwd:r,deep:3,ignore:["**/node_modules/**","**/dist/**","**/build/**","**/public/**"]})).map(o=>R__default.dirname(o)).find(o=>s.startsWith(o));return n?R__default.join(r,n):null}function Zo(e,t){return Object.keys(t.resolvedPaths).filter(r=>r!=="utils").includes(e)}function Xo(e,t){let r=e.split(R__default.sep),s=t.split(R__default.sep),i=[];for(let n=0;n<Math.min(r.length,s.length)&&r[n]===s[n];n++)i.push(r[n]);return i.join(R__default.sep)}async function Ls(e,t){return (await re(e))?.tailwindVersion==="v4"?"new-york-v4":t}function jd(e){return e?.startsWith("base-")?"base":"radix"}function Fs(e){let t={resolvedPaths:{cwd:process.cwd(),tailwindConfig:"",tailwindCss:"",utils:"",components:"",ui:"",lib:"",hooks:""},style:"",tailwind:{config:"",css:"",baseColor:"",cssVariables:false},rsc:false,tsx:true,aliases:{components:"",utils:""},registries:{...G}};return e?{...t,...e,resolvedPaths:{...t.resolvedPaths,...e.resolvedPaths||{}},tailwind:{...t.tailwind,...e.tailwind||{}},aliases:{...t.aliases,...e.aliases||{}},registries:{...t.registries,...e.registries||{}}}:t}var St=["**/node_modules/**",".next","public","dist","build"],ta=z.object({compilerOptions:z.object({paths:z.record(z.string().or(z.array(z.string())))})});async function re(e,t){let[r,s,i,n,o,c,a,h]=await Promise.all([Et.glob("**/{next,vite,astro,app}.config.*|gatsby-config.*|composer.json|react-router.config.*",{cwd:e,deep:3,ignore:St}),K.pathExists(R__default.resolve(e,"src")),oa(e),ia(e),sa(e,t?.configCssFile),Ds(e),Ws(e),le(e,false)]),l=await K.pathExists(R__default.resolve(e,`${s?"src/":""}app`)),u={framework:H.manual,isSrcDir:s,isRSC:false,isTsx:i,tailwindConfigFile:n,tailwindCssFile:o,tailwindVersion:c,frameworkVersion:null,aliasPrefix:a.prefix};if(r.find(d=>d.startsWith("next.config."))?.length)return u.framework=l?H["next-app"]:H["next-pages"],u.isRSC=l,u.frameworkVersion=await ra(u.framework,h),u;if(r.find(d=>d.startsWith("astro.config."))?.length)return u.framework=H.astro,u;if(r.find(d=>d.startsWith("gatsby-config."))?.length)return u.framework=H.gatsby,u;if(r.find(d=>d.startsWith("composer.json"))?.length)return u.framework=H.laravel,u;if(Object.keys(h?.dependencies??{}).find(d=>d.startsWith("@remix-run/")))return u.framework=H.remix,u;if([...Object.keys(h?.dependencies??{}),...Object.keys(h?.devDependencies??{})].find(d=>d.startsWith("@tanstack/react-start")))return u.framework=H["tanstack-start"],u;if(r.find(d=>d.startsWith("react-router.config."))?.length)return u.framework=H["react-router"],u;if(r.find(d=>d.startsWith("vite.config."))?.length)return u.framework=H.vite,u;let f=r.find(d=>d.startsWith("app.config"));return f?.length&&(await K.readFile(R__default.resolve(e,f),"utf8")).includes("defineConfig")?(u.framework=H.vite,u):(h?.dependencies?.expo&&(u.framework=H.expo),u)}async function ra(e,t){if(!t||!["next-app","next-pages"].includes(e.name))return null;let r=t.dependencies?.next||t.devDependencies?.next;if(!r)return null;let s=r.match(/^[\^~]?(\d+\.\d+\.\d+)/);if(s)return s[1];let i=r.match(/(\d+\.\d+\.\d+)/);return i?i[1]:r}async function Ds(e){let[t,r]=await Promise.all([le(e,false),qe(e)]);return r?.tailwind?.config===""?"v4":!t?.dependencies?.tailwindcss&&!t?.devDependencies?.tailwindcss?null:/^(?:\^|~)?3(?:\.\d+)*(?:-.*)?$/.test(t?.dependencies?.tailwindcss||t?.devDependencies?.tailwindcss||"")?"v3":"v4"}async function sa(e,t){if(t){let n=R__default.resolve(e,t);if(await K.pathExists(n))return t}let[r,s]=await Promise.all([Et.glob(["**/*.css","**/*.scss"],{cwd:e,deep:5,ignore:St}),Ds(e)]);if(!r.length)return null;for(let n of r){let o=await K.readFile(R__default.resolve(e,n),"utf8");if(o.includes('@import "tailwindcss"')||o.includes("@import 'tailwindcss'")||o.includes("@tailwind base"))return n}return null}async function ia(e){let t=await Et.glob("tailwind.config.*",{cwd:e,deep:3,ignore:St});return t.length?t[0]:null}async function na(e){let t=await loadConfig(e),r=t?.resultType==="success"&&Object.entries(t.paths).length?t.paths:(await aa(e))?.compilerOptions.paths;if(!r||!Object.entries(r).length)return null;for(let[s,i]of Object.entries(r)){let n=Array.isArray(i)?i:[i];if(n.includes("./*")||n.includes("./src/*")||n.includes("./app/*")||n.includes("./resources/js/*"))return s.replace(/\/\*$/,"")??null}return Object.keys(r)?.[0].replace(/\/\*$/,"")??null}async function Ws(e){let t=await na(e),r=Os(e);return r&&t?.startsWith("#")?{prefix:r,source:"package_imports"}:t?{prefix:t,source:"tsconfig_paths"}:r?{prefix:r,source:"package_imports"}:{prefix:null,source:null}}async function oa(e){return (await Et.glob("tsconfig.*",{cwd:e,deep:1,ignore:St})).length>0}async function aa(e){for(let t of ["tsconfig.json","tsconfig.web.json","tsconfig.app.json"]){let r=R__default.resolve(e,t);if(!await K.pathExists(r))continue;let s=await K.readFile(r,"utf8"),i;try{i=JSON.parse(ca(s));}catch{continue}let n=ta.safeParse(i);if(!n.error)return n.data}return null}function ca(e){let t="",r=false,s=false;for(let i=0;i<e.length;i++){let n=e[i],o=e[i+1];if(r){if(t+=n,s){s=false;continue}if(n==="\\"){s=true;continue}n==='"'&&(r=false);continue}if(n==='"'){r=true,t+=n;continue}if(n==="/"&&o==="/"){for(;i<e.length&&e[i]!==`
|
|
21
|
+
`;)i++;i<e.length&&(t+=e[i]);continue}if(n==="/"&&o==="*"){for(i+=2;i<e.length;){if(e[i]==="*"&&e[i+1]==="/"){i++;break}e[i]===`
|
|
22
|
+
`&&(t+=`
|
|
23
|
+
`),i++;}continue}if(n===","){let c=i+1;for(;c<e.length;){for(;/\s/.test(e[c]??"");)c++;if(e[c]==="/"&&e[c+1]==="/"){for(c+=2;c<e.length&&e[c]!==`
|
|
24
|
+
`&&e[c]!=="\r";)c++;continue}if(e[c]==="/"&&e[c+1]==="*"){for(c+=2;c<e.length&&!(e[c]==="*"&&e[c+1]==="/");)c++;c+=2;continue}break}if(e[c]==="}"||e[c]==="]")continue}t+=n;}return t}async function qd(e,t=null){let[r,s,i]=await Promise.all([qe(e),t?Promise.resolve(t):re(e),Ws(e)]);if(r)return r;if(!s||!s.tailwindCssFile||s.tailwindVersion==="v3"&&!s.tailwindConfigFile)return null;let n=i.source==="package_imports"?js(e):null;if(!s.aliasPrefix)return null;let o=la(s.aliasPrefix,i.source==="package_imports"),c=i.source==="package_imports"&&n?ua({...o,components:n.components??o.components,ui:n.ui??o.ui,hooks:n.hooks??o.hooks,lib:n.lib??o.lib,utils:n.utils??o.utils}):o;if(!c.components||!c.utils)return null;let a={$schema:"https://ui.shadcn.com/schema.json",rsc:s.isRSC,tsx:s.isTsx,style:"new-york",tailwind:{config:s.tailwindConfigFile??"",baseColor:"zinc",css:s.tailwindCssFile,cssVariables:true,prefix:""},iconLibrary:"lucide",aliases:c};return await Rt(e,a)}function la(e,t=false){return t&&e==="#"?{components:"",ui:void 0,hooks:void 0,lib:void 0,utils:""}:{components:`${e}/components`,ui:`${e}/components/ui`,hooks:`${e}/hooks`,lib:`${e}/lib`,utils:`${e}/lib/utils`}}function ua(e){let t={...e};return !t.ui&&t.components&&(t.ui=`${t.components}/ui`),!t.lib&&t.utils.endsWith("/utils")&&(t.lib=t.utils.slice(0,-6)),!t.utils&&t.lib&&(t.utils=`${t.lib}/utils`),t}async function Ct(e){if(!e.resolvedPaths?.cwd)return "v3";let t=await re(e.resolvedPaths.cwd);return t?.tailwindVersion?t.tailwindVersion:null}async function Jd(e){let t=await qe(e);if(!t)return [];let s=(await Rt(e,t)).resolvedPaths.ui;if(!K.existsSync(s))return [];let i=await It(),n=new Set(i?.map(c=>c.name)??[]);return (await promises.readdir(s)).filter(c=>/\.(tsx|jsx)$/.test(c)).map(c=>R__default.basename(c,R__default.extname(c))).filter(c=>n.has(c))}function Hs(e,t,r={}){let{ignoreImports:s=false}=r,i=e.replace(/\r\n/g,`
|
|
25
|
+
`).trim(),n=t.replace(/\r\n/g,`
|
|
26
|
+
`).trim();if(i===n)return true;if(!s)return false;let o=/^(import\s+(?:type\s+)?(?:\*\s+as\s+\w+|\{[^}]*\}|\w+)?(?:\s*,\s*(?:\{[^}]*\}|\w+))?\s+from\s+["'])([^"']+)(["'])/gm,c=l=>l.replace(o,(u,f,d,p)=>{if(d.startsWith("."))return `${f}${d}${p}`;let m=d.split("/"),g=m[m.length-1];return `${f}@normalized/${g}${p}`}),a=c(i),h=c(n);return a===h}function Re(e){let t=R__default.basename(e);return /^\.env(\.|$)/.test(t)}function Vs(e){let t=[".env.local",".env",".env.development.local",".env.development"];for(let r of t){let s=R__default.join(e,r);if(existsSync(s))return s}return null}function Te(e){let t=e.split(`
|
|
27
|
+
`),r={};for(let s of t){let i=s.trim();if(!i||i.startsWith("#"))continue;let n=i.indexOf("=");if(n===-1)continue;let o=i.substring(0,n).trim(),c=i.substring(n+1).trim();o&&(r[o]=c.replace(/^["']|["']$/g,""));}return r}function Gs(e,t){let r=Te(e),s=Te(t),i=[];for(let n of Object.keys(s))n in r||i.push(n);return i}function Us(e,t){let r=Te(e),s=Te(t),i=e.trimEnd();i&&!i.endsWith(`
|
|
28
|
+
`)&&(i+=`
|
|
29
|
+
`);let n=[];for(let[o,c]of Object.entries(s))o in r||n.push(`${o}=${c}`);return n.length>0?(i&&(i+=`
|
|
30
|
+
`),i+=n.join(`
|
|
31
|
+
`),i+`
|
|
32
|
+
`):i&&!i.endsWith(`
|
|
33
|
+
`)?i+`
|
|
34
|
+
`:i}function Ie(e,t){return da({text:e,isSilent:t?.silent})}var kt=async({sourceFile:e,config:t,isRemote:r})=>{let s=t.aliases?.utils,i=typeof s=="string"?ma(s):"@",n=i?`${i}/lib/utils`:"@/lib/utils";if(![".tsx",".ts",".jsx",".js"].includes(e.getExtension()))return e;for(let o of e.getImportStringLiterals()){let c=pa(o.getLiteralValue(),t,r);if(o.setLiteralValue(c),n===c||c==="@/lib/utils"){if(!o.getFirstAncestorByKind(SyntaxKind.ImportDeclaration)?.getNamedImports().some(l=>l.getName()==="cn")||!t.aliases.utils)continue;o.setLiteralValue(n===c?c.replace(n,t.aliases.utils):t.aliases.utils);}}return e};function pa(e,t,r=false){if(e=ga(e,t),!e.startsWith("@/")&&!r)return e;if(r&&e.startsWith("@/")&&(e=e.replace(/^@\//,"@/registry/new-york/")),e==="@/registry")return t.aliases.components;if(!e.startsWith("@/registry/")){if(e==="@/lib/utils"&&t.aliases.utils)return t.aliases.utils;if(t.aliases.ui&&e.match(/^@\/components\/ui(?=\/|$)/))return e.replace(/^@\/components\/ui/,t.aliases.ui);if(t.aliases.components&&e.match(/^@\/components(?=\/|$)/))return e.replace(/^@\/components/,t.aliases.components);if(t.aliases.hooks&&e.match(/^@\/hooks(?=\/|$)/))return e.replace(/^@\/hooks/,t.aliases.hooks);if(t.aliases.lib&&e.match(/^@\/lib(?=\/|$)/))return e.replace(/^@\/lib/,t.aliases.lib);let s=t.aliases.components.split("/")[0];return e.replace(/^@\//,`${s}/`)}return e.match(/^@\/registry\/(.+)\/ui/)?e.replace(/^@\/registry\/(.+)\/ui/,t.aliases.ui??`${t.aliases.components}/ui`):t.aliases.utils&&e.match(/^@\/registry\/(.+)\/lib\/utils$/)?t.aliases.utils:t.aliases.components&&e.match(/^@\/registry\/(.+)\/components/)?e.replace(/^@\/registry\/(.+)\/components/,t.aliases.components):t.aliases.lib&&e.match(/^@\/registry\/(.+)\/lib/)?e.replace(/^@\/registry\/(.+)\/lib/,t.aliases.lib):t.aliases.hooks&&e.match(/^@\/registry\/(.+)\/hooks/)?e.replace(/^@\/registry\/(.+)\/hooks/,t.aliases.hooks):e.replace(/^@\/registry\/[^/]+/,t.aliases.components)}function ma(e){if(e.startsWith("#"))return "";if(e.endsWith("/lib/utils"))return e.slice(0,-10);if(e.startsWith("@")){let[r,s]=e.split("/");return r&&s?`${r}/${s}`:e}let t=e.indexOf("/");return t===-1?e:e.slice(0,t)}function ga(e,t){if(e==="#registry")return "@/registry";if(e.startsWith("#/"))return e.replace(/^#\//,"@/");if(e.startsWith("#registry/"))return e.replace(/^#registry\//,"@/registry/");for(let{alias:r,normalized:s}of ya(t)){if(e===r)return s;if(e.startsWith(`${r}/`))return `${s}${e.slice(r.length)}`}return e}function ya(e){return e.aliases?[{alias:e.aliases.ui,normalized:"@/components/ui"},{alias:e.aliases.components,normalized:"@/components"},{alias:e.aliases.hooks,normalized:"@/hooks"},{alias:e.aliases.lib,normalized:"@/lib"},{alias:e.aliases.utils,normalized:"@/lib/utils"}].filter(t=>typeof t.alias=="string"&&t.alias.startsWith("#")).sort((t,r)=>r.alias.length-t.alias.length):[]}var ba={sourceType:"module",allowImportExportEverywhere:true,allowReturnOutsideFunction:true,startLine:1,tokens:true,plugins:["asyncGenerators","bigInt","classPrivateMethods","classPrivateProperties","classProperties","classStaticBlock","decimal","decorators-legacy","doExpressions","dynamicImport","exportDefaultFrom","exportNamespaceFrom","functionBind","functionSent","importAssertions","importMeta","nullishCoalescingOperator","numericSeparator","objectRestSpread","optionalCatchBinding","optionalChaining",["pipelineOperator",{proposal:"minimal"}],["recordAndTuple",{syntaxType:"hash"}],"throwExpressions","topLevelAwait","v8intrinsic","typescript","jsx"]},Ks=async({sourceFile:e,config:t})=>{let r=e.getFullText();if(t.tsx)return r;let s=$t.parse(r,{parser:{parse:n=>parse(n,ba)}}),i=transformFromAstSync(s,r,{cloneInputAst:false,code:false,ast:true,plugins:[va],configFile:false});if(!i||!i.ast)throw new Error("Failed to transform JSX");return $t.print(i.ast).code};var Ia=/^["']use client["']$/g,Tt=async({sourceFile:e,config:t})=>{if(t.rsc)return e;let r=e.getFirstChildByKind(SyntaxKind.ExpressionStatement);return r&&Ia.test(r.getText())&&r.remove(),e};var Ea=new Set(["cn-font-heading"]),Sa=/\bcn-[a-z-]+\b/;function Bs(e){return Sa.test(e)&&!Ea.has(e)}function qs(e){return e.split(/\s+/).filter(t=>t.length>0&&!Bs(t)).join(" ")}function Js(e){return e.split(/\s+/).some(Bs)}function Pt(e){let t=e.getLiteralValue();if(!Js(t))return;let r=qs(t);r!==t&&e.setLiteralValue(r);}function Yt(e){for(let t of e.getDescendantsOfKind(SyntaxKind.StringLiteral))Pt(t);for(let t of e.getDescendantsOfKind(SyntaxKind.NoSubstitutionTemplateLiteral))Pt(t);}function Ca(e){let t=[];for(let r of e.getDescendantsOfKind(SyntaxKind.JsxAttribute)){let s=r.getNameNode().getText();if(s!=="className"&&s!=="classNames")continue;let i=r.getInitializer();if(i?.isKind(SyntaxKind.StringLiteral)){let n=i.getLiteralValue();if(Js(n)){let o=qs(n);o===""?t.push(r):o!==n&&i.setLiteralValue(o);}}i?.isKind(SyntaxKind.JsxExpression)&&Yt(i);}for(let r of t)r.remove();for(let r of e.getDescendantsOfKind(SyntaxKind.CallExpression))if(r.getExpression().getText()==="cva")for(let s of r.getArguments()){if(s.isKind(SyntaxKind.StringLiteral)){Pt(s);continue}if(s.isKind(SyntaxKind.NoSubstitutionTemplateLiteral)){Pt(s);continue}Yt(s);}for(let r of e.getDescendantsOfKind(SyntaxKind.CallExpression))r.getExpression().getText()==="mergeProps"&&Yt(r);}var At=async({sourceFile:e})=>(Ca(e),e);var Ot=async({sourceFile:e,config:t})=>{if(!t.tailwind?.prefix)return e;let r=await Ct(t);return e.getDescendantsOfKind(SyntaxKind.CallExpression).filter(s=>s.getExpression().getText()==="cva").forEach(s=>{if(s.getArguments()[0]?.isKind(SyntaxKind.StringLiteral)){let i=s.getArguments()[0];i&&i.replaceWithText(`"${de(i.getText()?.replace(/"|'/g,""),t.tailwind.prefix,r)}"`);}s.getArguments()[1]?.isKind(SyntaxKind.ObjectLiteralExpression)&&s.getArguments()[1]?.getDescendantsOfKind(SyntaxKind.PropertyAssignment).find(i=>i.getName()==="variants")?.getDescendantsOfKind(SyntaxKind.PropertyAssignment).forEach(i=>{i.getDescendantsOfKind(SyntaxKind.PropertyAssignment).forEach(n=>{let o=n.getInitializerIfKind(SyntaxKind.StringLiteral);o&&o?.replaceWithText(`"${de(o.getText()?.replace(/"|'/g,""),t.tailwind.prefix,r)}"`);});});}),e.getDescendantsOfKind(SyntaxKind.JsxAttribute).forEach(s=>{if(s.getNameNode().getText()==="className"){if(s.getInitializer()?.isKind(SyntaxKind.StringLiteral)){let i=s.getInitializer();i&&i.replaceWithText(`"${de(i.getText()?.replace(/"|'/g,""),t.tailwind.prefix,r)}"`);}if(s.getInitializer()?.isKind(SyntaxKind.JsxExpression)){let i=s.getInitializer()?.getDescendantsOfKind(SyntaxKind.CallExpression).find(n=>n.getExpression().getText()==="cn");i&&i.getArguments().forEach(n=>{(n.isKind(SyntaxKind.ConditionalExpression)||n.isKind(SyntaxKind.BinaryExpression))&&n.getChildrenOfKind(SyntaxKind.StringLiteral).forEach(o=>{o.replaceWithText(`"${de(o.getText()?.replace(/"|'/g,""),t.tailwind.prefix,r)}"`);}),n.isKind(SyntaxKind.StringLiteral)&&n.replaceWithText(`"${de(n.getText()?.replace(/"|'/g,""),t.tailwind.prefix,r)}"`);});}}s.getNameNode().getText()==="classNames"&&s.getInitializer()?.isKind(SyntaxKind.JsxExpression)&&s.getDescendantsOfKind(SyntaxKind.PropertyAssignment).forEach(i=>{if(i.getInitializer()?.isKind(SyntaxKind.CallExpression)){let n=i.getInitializerIfKind(SyntaxKind.CallExpression);n&&n.getArguments().forEach(o=>{o.isKind(SyntaxKind.ConditionalExpression)&&o.getChildrenOfKind(SyntaxKind.StringLiteral).forEach(c=>{c.replaceWithText(`"${de(c.getText()?.replace(/"|'/g,""),t.tailwind.prefix,r)}"`);}),o.isKind(SyntaxKind.StringLiteral)&&o.replaceWithText(`"${de(o.getText()?.replace(/"|'/g,""),t.tailwind.prefix,r)}"`);});}if(i.getInitializer()?.isKind(SyntaxKind.StringLiteral)&&i.getNameNode().getText()!=="variant"){let n=i.getInitializer();n&&n.replaceWithText(`"${de(n.getText()?.replace(/"|'/g,""),t.tailwind.prefix,r)}"`);}});}),e};function de(e,t="",r){return r==="v3"?e.split(" ").map(s=>{let[i,n,o]=b(s);return i?o?`${i}:${t}${n}/${o}`:`${i}:${t}${n}`:o?`${t}${n}/${o}`:`${t}${n}`}).join(" "):e.split(" ").map(s=>s.indexOf(`${t}:`)===0?s:`${t}:${s.trim()}`).join(" ")}var Aa=new Project({compilerOptions:{}});async function Oa(e){let t=await promises.mkdtemp(R__default.join(tmpdir(),"shadcn-"));return R__default.join(t,e)}async function Zs(e,t=[kt,Tt,a,Ot,d,c,At]){let r=await Oa(e.filename),s=Aa.createSourceFile(r,e.raw,{scriptKind:ScriptKind.TSX});for(let i of t)await i({sourceFile:s,...e});return e.transformJsx?await Ks({sourceFile:s,...e}):s.getText()}var ja=["a","span","div","Link","label","Label"],Xs=async({sourceFile:e,config:t})=>{if(!t.style?.startsWith("base-"))return e;let r=10;for(let s=0;s<r;s++){let n=e.getDescendantsOfKind(SyntaxKind.JsxElement).filter(a=>a.getOpeningElement().getAttribute("asChild"));if(n.length===0)break;let o=n.filter(a=>!a.getDescendantsOfKind(SyntaxKind.JsxElement).some(l=>l.getOpeningElement().getAttribute("asChild"))),c=[];for(let a of o){let h=a.getOpeningElement(),l=h.getAttribute("asChild");if(!l)continue;let u=h.getTagNameNode().getText(),d=a.getJsxChildren().find(y=>y.getKind()===SyntaxKind.JsxElement||y.getKind()===SyntaxKind.JsxSelfClosingElement);if(!d){l.remove();continue}let p,m,g;if(d.getKind()===SyntaxKind.JsxSelfClosingElement){let y=d.asKindOrThrow(SyntaxKind.JsxSelfClosingElement);p=y.getTagNameNode().getText(),m=y.getAttributes().map(w=>w.getText()).join(" "),g="";}else {let y=d.asKindOrThrow(SyntaxKind.JsxElement),w=y.getOpeningElement();p=w.getTagNameNode().getText(),m=w.getAttributes().map(v=>v.getText()).join(" "),g=y.getJsxChildren().map(v=>v.getText()).join("");}let x=u==="Button"&&ja.includes(p);c.push({parentElement:a,parentTagName:u,childTagName:p,childProps:m,childChildren:g,needsNativeButton:x});}for(let a of c.reverse()){let l=a.parentElement.getOpeningElement().getAttributes().filter(m=>m.getKind()===SyntaxKind.JsxAttribute?m.asKindOrThrow(SyntaxKind.JsxAttribute).getNameNode().getText()!=="asChild":true).map(m=>m.getText()).join(" "),u=a.childProps?`{<${a.childTagName} ${a.childProps} />}`:`{<${a.childTagName} />}`,f=l?`${l} `:"";f+=`render=${u}`,a.needsNativeButton&&(f+=" nativeButton={false}");let d=a.childChildren.trim()?`${a.childChildren}`:"",p=`<${a.parentTagName} ${f}>${d}</${a.parentTagName}>`;a.parentElement.replaceWithText(p);}}return e};var Qs=async({sourceFile:e})=>(e.getFunctions().forEach(t=>{t.getName()==="middleware"&&t.rename("proxy");}),e.getVariableDeclarations().forEach(t=>{t.getName()==="middleware"&&t.rename("proxy");}),e.getExportDeclarations().forEach(t=>{t.getNamedExports().forEach(s=>{s.getName()==="middleware"&&s.setName("proxy"),s.getAliasNode()?.getText()==="middleware"&&s.setAlias("proxy");});}),e);var Xt=[".ts",".tsx",".js",".jsx"],Ma=new Set(["tailwindConfig","tailwindCss"]),La=["components","ui","lib","hooks"];async function yp(e,t,r){if(!e?.length)return {filesCreated:[],filesUpdated:[],filesSkipped:[]};r={overwrite:false,force:false,silent:false,isRemote:false,isWorkspace:false,...r};let s=Ie("Updating files.",{silent:r.silent})?.start(),[i,n]=await Promise.all([re(t.resolvedPaths.cwd),t.tailwind.baseColor?Nt(t.tailwind.baseColor):Promise.resolve(void 0)]),o=loadConfig(t.resolvedPaths.cwd),c$1=Ga(r.plannedFiles??e,t,{isSrcDir:i?.isSrcDir,framework:i?.framework.name,path:r.path}),a$1=new Project({compilerOptions:{}}),h=[],l=[],u=[],f=[],d$1=null;for(let x=0;x<e.length;x++){let y=e[x];if(!y.content)continue;let w=jt(y,t,{isSrcDir:i?.isSrcDir,framework:i?.framework.name,commonRoot:_t(e.map(k=>k.path),y.path),path:r.path,fileIndex:x});if(!w)continue;let v=basename(y.path),b=R__default.dirname(w);if(t.tsx||(w=w.replace(/\.tsx?$/,k=>k===".tsx"?".jsx":".js")),Re(w)&&!existsSync(w)){let k=Vs(b);k&&(w=k);}let I=existsSync(w);if(y.type==="registry:lib"&&basename(y.path)==="utils.ts"&&i?.framework.name==="laravel"&&I){u.push(R__default.relative(t.resolvedPaths.cwd,w));continue}if(I&&statSync(w).isDirectory())throw new Error(`Cannot write to ${w}: path exists and is a directory. Please provide a file path instead.`);let T=y.type==="registry:file"||y.type==="registry:item",$=Re(w)||T?y.content:await Zs({filename:y.path,raw:y.content,config:t,baseColor:n,transformJsx:!t.tsx,isRemote:r.isRemote,supportedFontMarkers:r.supportedFontMarkers},[kt,Tt,a,Ot,c,g,Xs,d,...ei(w,i,t)?[Qs]:[],f$1,At]);if(I&&!Re(w)){let k=await ni({config:t,content:$,filePaths:c$1,project:a$1,projectInfo:i,resolvedPath:w,tsConfig:o}),Q=await promises.readFile(w,"utf-8");if(Hs(Q,k,{ignoreImports:r.isWorkspace})){u.push(R__default.relative(t.resolvedPaths.cwd,w));continue}}if(I&&!r.overwrite&&!Re(w)){s.stop(),r.rootSpinner&&r.rootSpinner.stop();let{overwrite:k}=await Na({type:"confirm",name:"overwrite",message:`The file ${P.info(v)} already exists. Would you like to overwrite?`,initial:false});if(!k){u.push(R__default.relative(t.resolvedPaths.cwd,w)),r.rootSpinner&&r.rootSpinner.start();continue}s?.start(),r.rootSpinner&&r.rootSpinner.start();}if(ei(w,i,t)&&(w=w.replace(/middleware\.(ts|js)$/,"proxy.$1")),existsSync(b)||await promises.mkdir(b,{recursive:true}),Re(w)&&I){let k=await promises.readFile(w,"utf-8"),Q=Us(k,$);if(f=Gs(k,$),d$1=R__default.relative(t.resolvedPaths.cwd,w),!f.length){u.push(R__default.relative(t.resolvedPaths.cwd,w));continue}await promises.writeFile(w,Q,"utf-8"),l.push(R__default.relative(t.resolvedPaths.cwd,w));continue}await promises.writeFile(w,$,"utf-8"),I?l.push(R__default.relative(t.resolvedPaths.cwd,w)):(h.push(R__default.relative(t.resolvedPaths.cwd,w)),Re(w)&&(f=Object.keys(Te($)),d$1=R__default.relative(t.resolvedPaths.cwd,w)));}let p=[...h,...l,...u],m=await Va(p,t,c$1);if(l.push(...m),h=Array.from(new Set(h)),l=Array.from(new Set(l.filter(x=>!h.includes(x)))),u=Array.from(new Set(u)),!(h.length||l.length)&&!u.length&&s?.info("No files updated."),h.length){if(s?.succeed(`Created ${h.length} ${h.length===1?"file":"files"}:`),!r.silent)for(let x of h)C.log(` - ${x}`);}else s?.stop();if(l.length&&(Ie(`Updated ${l.length} ${l.length===1?"file":"files"}:`,{silent:r.silent})?.info(),!r.silent))for(let x of l)C.log(` - ${x}`);if(u.length&&(Ie(`Skipped ${u.length} ${u.length===1?"file":"files"}: (files might be identical, use --overwrite to overwrite)`,{silent:r.silent})?.info(),!r.silent))for(let x of u)C.log(` - ${x}`);if(f.length&&d$1&&(Ie(`Added the following variables to ${P.info(d$1)}:`)?.info(),!r.silent))for(let x of f)C.log(` ${P.success("+")} ${x}`);return {filesCreated:h,filesUpdated:l,filesSkipped:u}}function jt(e,t,r){if(r.path){let n=R__default.isAbsolute(r.path)?r.path:R__default.join(t.resolvedPaths.cwd,r.path);if(/\.[^/\\]+$/.test(n)){if(r.fileIndex===0)return n}else {let c=R__default.basename(e.path);return R__default.join(n,c)}}if(e.target){if(e.target.startsWith("~/"))return R__default.join(t.resolvedPaths.cwd,e.target.replace("~/",""));let n=e.target,o=Fa(n,t);return o?.resolvedPath?o.resolvedPath:(o?.target&&(n=o.target),e.type==="registry:page"&&(n=za(n,r.framework),!n)?"":r.isSrcDir?R__default.join(t.resolvedPaths.cwd,"src",n.replace("src/","")):R__default.join(t.resolvedPaths.cwd,n.replace("src/","")))}let s=Wa(e,t),i=Ha(e.path,s);return R__default.join(s,i)}function Fa(e,t){let r=e.match(/^@([^/]+)\/(.+)$/);if(!r)return null;let[,s,i]=r;if(!Da(s))return {target:`${s}/${i}`};let n=R__default.resolve(t.resolvedPaths[s]),o=R__default.resolve(n,i);if(o!==n&&!o.startsWith(`${n}${R__default.sep}`))throw new Error(`Invalid target path "${e}". Target paths using @${s}/ must stay within the ${s} alias root.`);return {resolvedPath:o}}function Da(e){return La.includes(e)}function Wa(e,t){return e.type==="registry:ui"?t.resolvedPaths.ui:e.type==="registry:lib"?t.resolvedPaths.lib:e.type==="registry:block"||e.type==="registry:component"?t.resolvedPaths.components:e.type==="registry:hook"?t.resolvedPaths.hooks:t.resolvedPaths.components}function _t(e,t){let r=e.map(o=>o.replace(/^\//,"")),s=t.replace(/^\//,""),i=s.split("/").slice(0,-1).join("/");if(!i)return "";let n=i.split("/");for(let o=n.length;o>0;o--){let c=n.slice(0,o).join("/");if(r.some(h=>h!==s&&h.startsWith(c+"/")))return "/"+c}return "/"+i}function Ha(e,t){let r=e.replace(/^\/|\/$/g,""),s=t.replace(/^\/|\/$/g,""),i=r.split("/"),n=s.split("/"),o=n[n.length-1],c=i.findIndex(a=>a===o);return c===-1?i[i.length-1]:i.slice(c+1).join("/")}function za(e,t){if(!t)return "";if(t==="next-app")return e;if(t==="next-pages"){let r=e.replace(/^app\//,"pages/");return r=r.replace(/\/page(\.[jt]sx?)$/,"$1"),r}if(t==="react-router"){let r=e.replace(/^app\//,"app/routes/");return r=r.replace(/\/page(\.[jt]sx?)$/,"$1"),r}if(t==="laravel"){let r=e.replace(/^app\//,"resources/js/pages/");return r=r.replace(/\/page(\.[jt]sx?)$/,"$1"),r}return ""}async function Va(e,t,r=e){let s=new Project({compilerOptions:{}}),i=await re(t.resolvedPaths.cwd),n=loadConfig(t.resolvedPaths.cwd),o=[];if(!i||n.resultType==="failed")return [];for(let c of e){let a=R__default.resolve(t.resolvedPaths.cwd,c);if(!existsSync(a))continue;let h=await promises.readFile(a,"utf-8"),l=await promises.mkdtemp(R__default.join(tmpdir(),"shadcn-")),u=s.createSourceFile(R__default.join(l,basename(a)),h,{scriptKind:ScriptKind.TSX});if(![".tsx",".ts",".jsx",".js"].includes(u.getExtension()))continue;let f=await ni({config:t,content:h,filePaths:r,project:s,projectInfo:i,resolvedPath:a,sourceFile:u,tsConfig:n});f!==h&&(await promises.writeFile(a,f,"utf-8"),o.push(c));}return o}function Ga(e,t,r){return (e??[])?.filter(s=>!!s?.content).map((s,i)=>{let n=jt(s,t,{isSrcDir:r.isSrcDir,framework:r.framework,commonRoot:_t((e??[]).map(o=>o.path),s.path),path:r.path,fileIndex:i});return n?(t.tsx||(n=n.replace(/\.tsx?$/,o=>o===".tsx"?".jsx":".js")),R__default.relative(t.resolvedPaths.cwd,n)):null}).filter(s=>!!s)}async function ni({content:e,resolvedPath:t,filePaths:r,config:s,projectInfo:i,tsConfig:n,project:o,sourceFile:c}){if(!i||n.resultType==="failed")return e;let a=R__default.extname(t);if(![".tsx",".ts",".jsx",".js"].includes(a))return e;let h=c===void 0?o.createSourceFile(R__default.join(tmpdir(),`shadcn-${Math.random().toString(36).slice(2)}${a||".tsx"}`),e,{scriptKind:ScriptKind.TSX,overwrite:true}):null,l=c??h;try{let u=!1;for(let f of l.getImportDeclarations()){let d=f.getModuleSpecifierValue();if(!Jt(d,i.aliasPrefix??null))continue;let p=await Ua(d,r,s,n);if(!p)continue;let m=Ba(p,s,i,t);!m||m===d||(f.setModuleSpecifier(m),u=!0);}return u?l.getFullText():e}finally{h&&o.removeSourceFile(h);}}async function Ua(e,t,r,s){let i=(await Ke(e,{...s,cwd:r.resolvedPaths.cwd}))?.path,n=!i&&!e.startsWith(".")?Ja(e,r):null;return !i&&!n?null:Ka(i??n,t,r)}function Ka(e,t,r,s=[".tsx",".ts",".js",".jsx",".css"]){let i=R__default.normalize(r.resolvedPaths.cwd),n=t.map(g=>g.split(R__default.sep).join(R__default.posix.sep)),o=new Set(n),c=R__default.extname(e),a=c!=="",h=a?e.slice(0,-c.length):e,u=R__default.relative(i,h).split(R__default.sep).join(R__default.posix.sep),f=a?[c]:s,d=new Set;for(let g of f){let x=h+g,y=R__default.posix.normalize(R__default.relative(i,x));(o.has(y)||existsSync(x))&&d.add(y);let w=R__default.join(h,`index${g}`),v=R__default.posix.normalize(R__default.relative(i,w));(o.has(v)||existsSync(w))&&d.add(v);}let p=R__default.basename(h);for(let g of n)f.some(x=>g.endsWith(`/${p}${x}`))&&d.add(g);return d.size===0?null:Array.from(d).sort((g,x)=>{let y=R__default.posix.extname(g),w=R__default.posix.extname(x),v=f.indexOf(y)-f.indexOf(w);if(v!==0)return v;let b=u&&g.startsWith(u)?-1:1,I=u&&x.startsWith(u)?-1:1;return b-I})[0]}function Ba(e,t,r,s){let i=R__default.normalize(R__default.join(t.resolvedPaths.cwd,e)),n=Object.entries(t.resolvedPaths).filter(([p,m])=>{if(!m||Ma.has(p))return false;let g=R__default.normalize(m);if(i===g){let x=t.aliases[p];if(typeof x!="string"||!x.startsWith("#"))return true;let y=Ue(x,t.resolvedPaths.cwd);return y!==null&&!y.matchedAlias.includes("*")}return i.startsWith(R__default.normalize(m+R__default.sep))}).sort((p,m)=>m[1].length-p[1].length);if(n.length===0)return null;let[o,c]=n[0],a=R__default.relative(c,i);a=a.split(R__default.sep).join("/");let h=o==="cwd"?r.aliasPrefix:t.aliases[o];if(!h)return null;if(h.startsWith("#")){let p=Ue(h,t.resolvedPaths.cwd);if(p)return qa(h,a,p)??(s?Za(s,i):null)}let l=R__default.posix.extname(a),u=Xt.includes(l)?"":l,f=a.slice(0,a.length-l.length);f.endsWith("/index")&&(f=f.slice(0,-6));let d=f===""?"":`/${f}`;return d=d.replace("/src",""),`${h}${d}${u}`}function qa(e,t,r){let s=R__default.posix.extname(t),i=Xt.includes(s)&&r.emitMode==="strip_extension"?"":s,n=t?t.slice(0,t.length-s.length)+i:"";return r.matchedAlias.includes("*")?n?`${e}/${n}`:e:n===""||n==="index"?e:null}function Ja(e,t){let r=Ya(t);for(let s of r){if(e===s.alias||e===s.canonical)return s.rootPath;if(e.startsWith(`${s.alias}/`))return R__default.join(s.rootPath,e.slice(s.alias.length+1));if(e.startsWith(`${s.canonical}/`))return R__default.join(s.rootPath,e.slice(s.canonical.length+1))}return null}function Ya(e){return [{alias:e.aliases.ui,canonical:"@/components/ui",rootPath:e.resolvedPaths.ui},{alias:e.aliases.components,canonical:"@/components",rootPath:e.resolvedPaths.components},{alias:e.aliases.hooks,canonical:"@/hooks",rootPath:e.resolvedPaths.hooks},{alias:e.aliases.lib,canonical:"@/lib",rootPath:e.resolvedPaths.lib},{alias:e.aliases.utils,canonical:"@/lib/utils",rootPath:e.resolvedPaths.utils}].filter(t=>typeof t.alias=="string"&&typeof t.rootPath=="string").sort((t,r)=>r.alias.length-t.alias.length||r.canonical.length-t.canonical.length)}function Za(e,t){let r=R__default.relative(R__default.dirname(e),t);r=r.split(R__default.sep).join("/");let s=R__default.posix.extname(r),i=Xt.includes(s)?"":s,n=r.slice(0,r.length-s.length);return n.endsWith("/index")&&(n=n.slice(0,-6)),n.startsWith(".")||(n=`./${n}`),`${n}${i}`}function ei(e,t,r){let s=e===R__default.join(r.resolvedPaths.cwd,"middleware.ts")||e===R__default.join(r.resolvedPaths.cwd,"middleware.js"),i=t?.framework.name==="next-app"||t?.framework.name==="next-pages";if(!s||!i||!t?.frameworkVersion)return false;let n=parseInt(t.frameworkVersion.split(".")[0]);return !isNaN(n)&&n>=16}new Project({compilerOptions:{}});function _(e){try{return new URL(e),!0}catch{return false}}function pe(e){return e.endsWith(".json")&&!_(e)}function Op(e){return !e||e.type!=="registry:item"&&e.type!=="registry:file"?false:(e.files??[]).every(r=>!!r.target&&(r.type==="registry:file"||r.type==="registry:item"))}async function ai(e,t){if(!Qa(t))return z.array(g$1).parse(e.flat().filter(Boolean));let r=await re(t.resolvedPaths.cwd),s=new Map,i=z.array(g$1).parse(e.flat().filter(Boolean));return i.forEach(n=>{let o=jt(n,t,{isSrcDir:r?.isSrcDir,framework:r?.framework.name,commonRoot:_t(i.map(c=>c.path),n.path)});o&&s.set(o,n);}),Array.from(s.values())}function Qa(e){return !!(e?.resolvedPaths?.cwd&&(e?.resolvedPaths?.ui||e?.resolvedPaths?.lib||e?.resolvedPaths?.components||e?.resolvedPaths?.hooks))}var ec=/^(?!.*--)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,37}[a-zA-Z0-9])?$/,tc=/^[a-zA-Z0-9._-]+$/,rc=new Set([".",".."]),sc=/[\x00-\x1F\x7F]/,ic=/\s/,nc=/^-/;function Je(e){if(_(e))return {scheme:"url",url:e};if(pe(e))return {scheme:"file",path:e};let{registry:t,item:r}=ce(e);if(t)return {scheme:"namespace",namespace:t,item:r};let s=oc(e);return s||{scheme:"shadcn",item:e}}function Mt(e){return Je(e).scheme==="github"}function Ye(e){let t=e.indexOf("#"),r=t===-1?e:e.slice(0,t),s=t===-1?void 0:e.slice(t+1),i=r.split("/");if(i.length!==2)return null;let[n,o]=i;if(!li(n)||!ui(o))return null;if(s!==void 0&&!hi(s))throw new S(`Invalid GitHub ref in registry source "${e}".`,{context:{source:e,ref:s},suggestion:"Use a non-empty branch, tag, or commit SHA without whitespace, control characters or leading dashes."});return {owner:n,repo:o,ref:s}}function ci(e){return Ye(e)!==null}function oc(e){let t=e.indexOf("#"),r=t===-1?e:e.slice(0,t),s=t===-1?void 0:e.slice(t+1),i=r.split("/");if(i.length<3)return null;let[n,o,...c]=i;if(!li(n)||!ui(o))return null;let a=c.join("/");if(!a)return null;if(s!==void 0&&!hi(s))throw new S(`Invalid GitHub ref in item address "${e}".`,{context:{address:e,ref:s},suggestion:"Use a non-empty branch, tag, or commit SHA without whitespace, control characters or leading dashes."});return {scheme:"github",owner:n,repo:o,item:a,ref:s}}function li(e){return ec.test(e)}function ui(e){return tc.test(e)&&!rc.has(e)}function hi(e){return !!e&&!sc.test(e)&&!ic.test(e)&&!nc.test(e)}function Ze(e){return e.replace(/\${(\w+)}/g,(t,r)=>process.env[r]||"")}function Xe(e){let t=[],r=/\${(\w+)}/g,s;for(;(s=r.exec(e))!==null;)t.push(s[1]);return t}function cc(e){return e.style?e.style==="new-york"&&e.tailwind?.config===""?dt:e.style:dt}function Ae(e){let t=Fs({style:dt,registries:G});return e?d$1.parse(je(t,{...e,style:cc(e),registries:{...G,...e.registries}})):t}var Lt={headers:{}};function Qe(e){Lt.headers={...Lt.headers,...e};}function di(e){return Lt.headers[e]||{}}function et(){Lt.headers={};}function lc(e){let t=new Set;return typeof e=="string"?Xe(e).forEach(r=>t.add(r)):(Xe(e.url).forEach(r=>t.add(r)),e.params&&Object.values(e.params).forEach(r=>{Xe(r).forEach(s=>t.add(s));}),e.headers&&Object.values(e.headers).forEach(r=>{Xe(r).forEach(s=>t.add(s));})),Array.from(t)}function fi(e,t){let s=lc(t).filter(i=>!process.env[i]);if(s.length>0)throw new He(e,s)}function Qp(e,t){for(let r of e)ci(r)||Oe(r,Ae(t));et();}var pi="{name}",Ft="{style}",mi=/\${(\w+)}/g,gi="?",uc="&";function hc(e){return e.startsWith("./")||e.startsWith("/")}function Oe(e,t){let{registry:r,item:s}=ce(e);if(!r){if(_(e)||pe(e)||hc(e)||Mt(e))return null;r="@shadcn";}let n={...G,...t?.registries}[r];if(!n)throw new ae(r);return fi(r,n),{url:dc(s,n,t),headers:fc(n)}}function dc(e,t,r){if(typeof t=="string"){let i=t.replace(pi,e);return r?.style&&i.includes(Ft)&&(i=i.replace(Ft,r.style)),Ze(i)}let s=t.url.replace(pi,e);return r?.style&&s.includes(Ft)&&(s=s.replace(Ft,r.style)),s=Ze(s),t.params?pc(s,t.params):s}function fc(e){if(typeof e=="string"||!e.headers)return {};let t={};for(let[r,s]of Object.entries(e.headers)){let i=Ze(s);mc(s,i)&&(t[r]=i);}return t}function pc(e,t){let r=new URLSearchParams;for(let[n,o]of Object.entries(t)){let c=Ze(o);c&&r.append(n,c);}let s=r.toString();if(!s)return e;let i=e.includes(gi)?uc:gi;return `${e}${i}${s}`}function mc(e,t){let r=t.trim();if(!r)return false;if(e.includes("${")&&e.match(mi)){let i=e.replace(mi,"").trim();return r!==i}return true}function Dt(e){if(_(e)){let t=new URL(e);return t.pathname.match(/\/chat\/b\//)&&!t.pathname.endsWith("/json")&&(t.pathname=`${t.pathname}/json`),t.toString()}return `${xe}/${e}`}var bc=process.env.https_proxy?new HttpsProxyAgent(process.env.https_proxy):void 0,Qt=new Map;async function L(e,t={}){t={useCache:true,...t};try{return await Promise.all(e.map(async s=>{let i=Dt(s);if(t.useCache&&Qt.has(i))return Qt.get(i);let n=(async()=>{let o=di(i),c=new Headers({Accept:"application/vnd.shadcn.v1+json, application/json;q=0.9","User-Agent":"shadcn"});for(let[h,l]of Object.entries(o))c.set(h,l);let a=await xc(i,{agent:bc,headers:c});if(!a.ok){let h;if(a.headers.get("content-type")?.includes("application/json")){let l=await a.json(),u=z.object({detail:z.string().optional(),title:z.string().optional(),message:z.string().optional(),error:z.string().optional()}).safeParse(l);u.success&&(h=u.data.detail||u.data.message,u.data.error&&(h=`[${u.data.error}] ${h}`));}throw a.status===401?new Fe(i,h):a.status===404?new ve(i,h):a.status===410?new ft(i,h):a.status===403?new De(i,h):new We(i,a.status,h)}return a.json()})();return t.useCache&&Qt.set(i,n),n}))}catch(r){throw r}}async function wi(e){try{let t=e;e.startsWith("~/")&&(t=R__default.join(homedir(),e.slice(2)));let r=R__default.resolve(t),s=await promises.readFile(r,"utf8"),i=JSON.parse(s);try{return n.parse(i)}catch(n){throw new M(e,n)}}catch(t){throw t instanceof Error&&(t.message.includes("ENOENT")||t.message.includes("no such file"))?new ee(e,t):t instanceof M?t:new ee(e,t)}}var Ic="https://github.com",xi=/^[a-fA-F0-9]{40}$/,Ec=15e3;async function vi(e,t={}){let r=e.ref??"HEAD";if(xi.test(r))return r.toLowerCase();let s=`${e.owner}/${e.repo}#${r}`;if(t.cache?.has(s))return t.cache.get(s);let i=Sc(e,r).catch(n=>{throw t.cache?.delete(s),n});return t.cache?.set(s,i),i}async function Sc(e,t){let r=`${Ic}/${e.owner}/${e.repo}.git`,s=Cc(t),i;try{i=(await execa("git",["ls-remote","--symref","--",r,...s],{env:{GIT_TERMINAL_PROMPT:"0"},timeout:Ec})).stdout;}catch(o){throw $c(e,t,r,o)}let n=kc(i);for(let o of bi(t)){let c=n.get(o);if(c)return c}throw new W("registry.json",void 0,{message:`Could not resolve GitHub ref "${t}" for ${e.owner}/${e.repo}.`,context:{reason:"github-ref-resolution",source:Ri(e),ref:t,repoUrl:r},suggestion:'Use an existing branch, tag, or full commit SHA. For example: "owner/repo/item#main" or "owner/repo/item#v1.0.0".'})}function Cc(e){return Array.from(new Set(bi(e)))}function bi(e){return e==="HEAD"?["HEAD"]:e.startsWith("refs/tags/")?[`${e}^{}`,e]:e.startsWith("refs/")?[e]:[`refs/heads/${e}`,`refs/tags/${e}^{}`,`refs/tags/${e}`,e]}function kc(e){let t=new Map;for(let r of e.split(`
|
|
35
|
+
`)){let s=r.trim();if(!s||s.startsWith("ref:"))continue;let[i,n]=s.split(/\s+/);i&&n&&xi.test(i)&&t.set(n,i.toLowerCase());}return t}function $c(e,t,r,s){return new W("registry.json",s,{message:`Failed to resolve GitHub ref "${t}" for ${e.owner}/${e.repo}.`,context:{reason:"github-ref-resolution",source:Ri(e),ref:t,repoUrl:r},suggestion:Tc(s)})}function Tc(e){return Pc(e)?"Install Git and try again. Git is required to resolve GitHub registry refs.":Ac(e)?"GitHub ref resolution timed out. Check your network connection and try again.":"Check that the public GitHub repository exists and the ref is accessible."}function Pc(e){return typeof e=="object"&&e!==null&&"code"in e&&e.code==="ENOENT"}function Ac(e){return typeof e=="object"&&e!==null&&"timedOut"in e&&e.timedOut===true}function Ri(e){return `${e.owner}/${e.repo}#${e.ref??"HEAD"}`}async function er(e,t,r={}){let s=_i(r.registryFile??"registry.json"),i=await Si(s,t,{source:r.source}),n=i.registry.items.find(o=>o.name===e);if(!n)throw new be(e);return Oc(n,i,t)}async function tr(e,t={}){let r=_i(t.registryFile??"registry.json"),s=await Si(r,e,{source:t.source});return jc(s)}async function Si(e,t,r={}){let s=await Ti(e,t,r),i=Pi(s,e);Ii(i,e);let n={itemSources:new Map,itemSourcesByItem:new Map,firstIncludedFrom:new Map},o=!!i.include?.length;if(!o){let l=ji(e);return i.items.forEach((u,f)=>{Oi(u,e,l);let d={registryFile:e,registryDir:l,itemIndex:f};n.itemSources.set(u.name,d),n.itemSourcesByItem.set(u,d);}),Ei(i.items,n.itemSourcesByItem),{registry:i,itemSources:n.itemSources,itemSourcesByItem:n.itemSourcesByItem,usesInclude:o}}if(R__default.posix.basename(e)!=="registry.json")throw new S(`Invalid source registry file at ${e}: registries that use include must be named registry.json.`,{registryFile:e});let c=await $i(e,i,t,n,[]);Ei(c.items,n.itemSourcesByItem);let{include:a,...h}=c;return Ii(h,e),{registry:h,itemSources:n.itemSources,itemSourcesByItem:n.itemSourcesByItem,usesInclude:o}}async function Oc(e,t,r){let s={...Ci(e,t.itemSourcesByItem),$schema:"https://ui.shadcn.com/schema/registry-item.json"};return await Promise.all((e.files??[]).map(async(i,n)=>{let o=s.files?.[n];if(!o)return;let c=t.itemSourcesByItem.get(e),a=ki(e,i.path,t.itemSourcesByItem);o.content=await _c(e.name,i.path,a,c,r);})),n.parse(s)}function jc(e){return {...e.registry,items:e.registry.items.map(t=>Nc(Ci(t,e.itemSourcesByItem)))}}async function _c(e,t,r,s,i){try{return await i.readText(r)}catch(n){let o=n instanceof W&&n.context?.reason==="github-source-file";throw new W(r,n,{message:`Failed to read file "${t}" for registry item "${e}" (${rt(s)}). Expected file at ${r}.`,context:{registryFile:s?.registryFile,itemIndex:s?.itemIndex,itemName:e,itemFilePath:t,sourcePath:r},suggestion:o&&n.suggestion?n.suggestion:"Make sure the file path is relative to the registry.json file that declares the item."})}}function Ci(e,t){return {...e,files:e.files?.map(r=>({...r,path:Mc(e,r.path,t)}))}}function Nc(e){return {...e,files:e.files?.map(({content:t,...r})=>r)}}function ki(e,t,r){let s=r.get(e);return rr(s?.registryDir??".",t)}function Mc(e,t,r){let s=ki(e,t,r);return Fc(".",s)}async function $i(e,t,r,s,i){if(Ai(e),i.length>=32)throw new S(`Registry include tree is too deep at ${e}. The maximum include depth is 32.`,{registryFile:e,context:{maxDepth:32},suggestion:"Flatten part of the registry include tree or reduce nested include depth."});if(i.includes(e))throw new S(Dc([...i,e]),{registryFile:e});let n=i.at(-1)??e,o=s.firstIncludedFrom.get(e);if(o)throw new S(`Registry file included more than once: ${e}.
|
|
36
|
+
- first included from ${o}
|
|
37
|
+
- included again from ${n}
|
|
38
|
+
Each registry.json file can only appear once in the resolved include tree. Remove one include or move shared items into a single included registry.json.`,{registryFile:e,context:{firstSource:o,secondSource:n}});s.firstIncludedFrom.set(e,n);let c=[...i,e],a=ji(e),h=[];for(let l of t.include??[]){let u=Lc(l,a,e),f=await Ti(u,r),d=Pi(f,u),p=await $i(u,d,r,s,c);h.push(...p.items);}return t.items?.forEach((l,u)=>{Oi(l,e,a),s.itemSources.set(l.name,{registryFile:e,registryDir:a,itemIndex:u}),s.itemSourcesByItem.set(l,{registryFile:e,registryDir:a,itemIndex:u});}),{...t,items:[...h,...t.items??[]]}}async function Ti(e,t,r={}){try{return await t.readText(e)}catch(s){throw s instanceof W&&(s.context?.reason==="github-ref-resolution"||s.context?.reason==="github-source-file")?s:new W(e,s,{message:`Failed to read source registry file at ${Wc(e,r.source)}.`,context:{registryFile:e,source:r.source},suggestion:e==="registry.json"?"Check that the repository has a registry.json file at its root.":"Check that the included registry.json file exists and that the include path is correct."})}}function Pi(e,t){let r;try{r=JSON.parse(e);}catch(i){throw new M(t,i,{subject:"registry file",context:{registryFile:t},suggestion:"Fix the JSON syntax in the registry.json file and try again."})}let s=o.safeParse(r);if(!s.success)throw new S(`Invalid registry file at ${t}:
|
|
39
|
+
${Hc(s.error)}`,{registryFile:t,cause:s.error,suggestion:"Update the registry.json file so it matches the registry schema."});return s.data}function Ii(e,t){let r=[];if(e.name||r.push("name"),e.homepage||r.push("homepage"),r.length)throw new S(`Invalid root registry file at ${t}: root registry.json must define ${r.map(s=>`"${s}"`).join(" and ")}. Included registry.json files may omit these fields.`,{registryFile:t})}function Lc(e,t,r){if(_(e))throw new S(`Invalid include "${e}" in ${r}: remote includes are not supported by shadcn build. Use a relative path to a registry.json file in the same repository.`,{registryFile:r,context:{includePath:e}});if(R__default.posix.isAbsolute(e))throw new S(`Invalid include "${e}" in ${r}: include paths must be relative. Use a path like "./registry/ui/registry.json".`,{registryFile:r,context:{includePath:e}});if(Mi(e))throw new S(`Invalid include "${e}" in ${r}: include paths cannot use parent-directory traversal. Keep included registry.json files inside the registry root.`,{registryFile:r,context:{includePath:e}});if(R__default.posix.basename(e)!=="registry.json")throw new S(`Invalid include "${e}" in ${r}: include paths must explicitly reference a registry.json file. Use a path like "./registry/ui/registry.json".`,{registryFile:r,context:{includePath:e}});let s=rr(t,e);return Ai(s),s}function Ai(e){if(!Ni(e))throw new S(`Invalid registry file at ${e}: registry includes must stay inside the source registry root.`,{registryFile:e})}function Oi(e,t,r){for(let s of e.files??[]){if(_(s.path))throw new S(`Invalid file path "${s.path}" for item "${e.name}" in ${t}: remote file paths are not supported by shadcn build.`,{registryFile:t,context:{itemName:e.name,filePath:s.path}});if(R__default.posix.isAbsolute(s.path))throw new S(`Invalid file path "${s.path}" for item "${e.name}" in ${t}: file paths must be relative.`,{registryFile:t,context:{itemName:e.name,filePath:s.path}});if(Mi(s.path))throw new S(`Invalid file path "${s.path}" for item "${e.name}" in ${t}: file paths cannot use parent-directory traversal.`,{registryFile:t,context:{itemName:e.name,filePath:s.path}});let i=rr(r,s.path);if(!Ni(i,r))throw new S(`Invalid file path "${s.path}" for item "${e.name}" in ${t}: file paths must stay inside the registry chunk directory.`,{registryFile:t,context:{itemName:e.name,filePath:s.path}})}}function Ei(e,t){let r=new Map;for(let s of e){let i=r.get(s.name);if(!i){r.set(s.name,s);continue}let n=t.get(i),o=t.get(s);throw new S(`Duplicate registry item name "${s.name}". Registry item names must be unique.
|
|
40
|
+
- ${rt(n)}
|
|
41
|
+
- ${rt(o)}
|
|
42
|
+
Rename one of these items so each name is unique across the resolved registry.`,{context:{itemName:s.name,firstSource:rt(n),secondSource:rt(o)}})}}function ji(e){let t=R__default.posix.dirname(e);return t==="."?".":t}function rr(...e){let t=R__default.posix.normalize(R__default.posix.join(...e));return t==="."?"":t}function _i(e){let t=R__default.posix.normalize(e);return t.startsWith("./")?t.slice(2):t}function Fc(e,t){return R__default.posix.relative(e,t)||R__default.posix.basename(t)}function Ni(e,t="."){let r=R__default.posix.relative(t,e);return !!r&&!r.startsWith("..")&&!R__default.posix.isAbsolute(r)}function Mi(e){return e.split(/[\\/]+/).includes("..")}function Dc(e){return `Registry include cycle detected:
|
|
43
|
+
${e.map(t=>` - ${t}`).join(`
|
|
44
|
+
`)}`}function rt(e){return e?`${e.registryFile} items[${e.itemIndex}]`:"unknown source"}function Wc(e,t){return t?`${t}/${e}`:e}function Hc(e){return e.errors.map(t=>` - ${t.path.length?t.path.join("."):"(root)"}: ${t.message}`).join(`
|
|
45
|
+
`)}var Uc="https://raw.githubusercontent.com",Kc=8,Bc=process.env.https_proxy?new HttpsProxyAgent(process.env.https_proxy):void 0;async function Fi(e,t={}){t={...t,sourceCache:t.sourceCache??new Map};let r=sr(e,t);return er(e.item,r,{source:Ee(e)})}async function Di(e,t={}){t={...t,sourceCache:t.sourceCache??new Map};let r=sr(e,t);return tr(r,{source:Ee(e)})}async function jm(e,t={}){let r=Ee(e),s=`${r}/registry.json`,i=new Set,n=t.sourceCache??new Map,o={...t,sourceCache:n},c=sr(e,o),a={async readText(h){return h.endsWith("registry.json")&&i.add(`${r}/${h}`),c.readText(h)}};try{let h=await tr(a,{source:r}),u=(await Yc(h.items,Kc,async(f,d)=>{try{return await er(f.name,a,{source:r}),null}catch(p){return Li(p,{defaultRegistryFile:s,itemName:f.name,itemIndex:d,sourceLabel:r})}})).filter(f=>f!==null);return {valid:u.length===0,cwd:r,registryFiles:i.size,registryFilePaths:Array.from(i),items:h.items.length,diagnostics:u}}catch(h){return {valid:false,cwd:r,registryFiles:i.size||1,registryFilePaths:i.size?Array.from(i):[s],items:0,diagnostics:[Li(h,{defaultRegistryFile:s,sourceLabel:r})]}}}function sr(e,t){let r=vi(e,{cache:t.sourceCache});return {async readText(s){let i=await r,n=Jc(e,i,s);if(t.useCache!==false&&t.sourceCache?.has(n))return t.sourceCache.get(n);let o=qc(n,s,e);return t.useCache!==false&&t.sourceCache?.set(n,o),o}}}async function qc(e,t,r){let s;try{s=await xc(e,{agent:Bc,headers:new Headers({"Accept-Encoding":"identity","User-Agent":"shadcn"})});}catch(i){throw new W(t,i,{message:`Failed to read GitHub source file "${t}" from ${Ee(r)}.`,context:{reason:"github-source-file",url:e,source:Ee(r),filePath:t},suggestion:"GitHub ref resolution succeeded, but the CLI could not fetch from raw.githubusercontent.com. Check that raw.githubusercontent.com is accessible from this network."})}if(!s.ok)throw new W(t,void 0,{message:`Failed to read GitHub source file "${t}" from ${Ee(r)}.`,context:{reason:"github-source-file",url:e,statusCode:s.status,source:Ee(r),filePath:t},suggestion:t==="registry.json"?"The GitHub repository and ref were resolved, but raw.githubusercontent.com did not return a root registry.json file. Check that the public repository has registry.json at its root and that raw.githubusercontent.com is accessible from this network.":"Check that the file path exists in the public GitHub repository."});return s.text()}function Jc(e,t,r){let s=r.split("/").map(i=>encodeURIComponent(i)).join("/");return `${Uc}/${e.owner}/${e.repo}/${t}/${s}`}async function Yc(e,t,r){let s=new Array(e.length),i=0,n=Math.min(t,e.length),o=Array.from({length:n},async()=>{for(;i<e.length;){let c=i++;s[c]=await r(e[c],c);}});return await Promise.all(o),s}function Ee(e){return `${e.owner}/${e.repo}#${e.ref??"HEAD"}`}function Li(e,t){return e instanceof j?{registryFile:typeof e.context?.registryFile=="string"?`${t.sourceLabel}/${e.context.registryFile}`:t.defaultRegistryFile,itemName:t.itemName,itemIndex:typeof e.context?.itemIndex=="number"?e.context.itemIndex:t.itemIndex,filePath:typeof e.context?.itemFilePath=="string"?e.context.itemFilePath:typeof e.context?.filePath=="string"?e.context.filePath:void 0,includePath:typeof e.context?.includePath=="string"?e.context.includePath:void 0,message:e.message,suggestion:e.suggestion}:{registryFile:t.defaultRegistryFile,itemName:t.itemName,itemIndex:t.itemIndex,message:e instanceof Error?e.message:"Unknown error."}}async function Bm(e,t,r){if(!e||(r={silent:false,tailwindVersion:"v3",...r},r.tailwindVersion==="v4"))return;let s=R__default.relative(t.resolvedPaths.cwd,t.resolvedPaths.tailwindConfig),i=Ie(`Updating ${P.info(s)}`,{silent:r.silent}).start(),n=await promises.readFile(t.resolvedPaths.tailwindConfig,"utf8"),o=await rl(n,e,t);await promises.writeFile(t.resolvedPaths.tailwindConfig,o,"utf8"),i?.succeed();}async function rl(e,t,r){let s=await Hi(e,r),i=s.getDescendantsOfKind(SyntaxKind.ObjectLiteralExpression).find(o=>o.getProperties().some(c=>c.isKind(SyntaxKind.PropertyAssignment)&&c.getName()==="content"));if(!i)return e;let n=ol(i);return sl(i,{name:"darkMode",value:"class"},{quoteChar:n}),t.plugins?.forEach(o=>{nl(i,o);}),t.theme&&await il(i,t.theme),s.getFullText()}function sl(e,t,{quoteChar:r}){let s=e.getProperty("darkMode");if(!s){let i={name:t.name,initializer:`[${r}${t.value}${r}]`};return t.name==="darkMode"?(e.insertPropertyAssignment(0,i),e):(e.addPropertyAssignment(i),e)}if(s.isKind(SyntaxKind.PropertyAssignment)){let i=s.getInitializer(),n=`${r}${t.value}${r}`;if(i?.isKind(SyntaxKind.StringLiteral)){let o=i.getText();return i.replaceWithText(`[${o}, ${n}]`),e}if(i?.isKind(SyntaxKind.ArrayLiteralExpression)){if(i.getElements().map(o=>o.getText()).includes(n))return e;i.addElement(n);}return e}return e}async function il(e,t){e.getProperty("theme")||e.addPropertyAssignment({name:"theme",initializer:"{}"}),nr(e);let s=(e.getPropertyOrThrow("theme")?.asKindOrThrow(SyntaxKind.PropertyAssignment)).getInitializer();if(s?.isKind(SyntaxKind.ObjectLiteralExpression)){let i=s.getText(),n=await al(i),o=je(n,t,{arrayMerge:(a,h)=>h}),c=Qc(o).replace(/\'\.\.\.(.*)\'/g,"...$1").replace(/\'\"/g,"'").replace(/\"\'/g,"'").replace(/\'\[/g,"[").replace(/\]\'/g,"]").replace(/\'\\\'/g,"'").replace(/\\\'/g,"'").replace(/\\\'\'/g,"'").replace(/\'\'/g,"'");s.replaceWithText(c);}or(e);}function nl(e,t){let r=e.getProperty("plugins");if(!r)return e.addPropertyAssignment({name:"plugins",initializer:`[${t}]`}),e;if(r.isKind(SyntaxKind.PropertyAssignment)){let s=r.getInitializer();if(s?.isKind(SyntaxKind.ArrayLiteralExpression)){if(s.getElements().map(i=>i.getText().replace(/["']/g,"")).includes(t.replace(/["']/g,"")))return e;s.addElement(t);}return e}return e}async function Hi(e,t){let r=await promises.mkdtemp(R__default.join(tmpdir(),"shadcn-")),s=t?.resolvedPaths?.tailwindConfig||"tailwind.config.ts",i=R__default.join(r,`shadcn-${R__default.basename(s)}`);return new Project({compilerOptions:{}}).createSourceFile(i,e,{scriptKind:R__default.extname(s)===".ts"?ScriptKind.TS:ScriptKind.JS})}function ol(e){return e.getFirstDescendantByKind(SyntaxKind.StringLiteral)?.getQuoteKind()===QuoteKind.Single?"'":'"'}function nr(e){let t=e.getProperties();for(let r=0;r<t.length;r++){let s=t[r];if(s.isKind(SyntaxKind.SpreadAssignment)){let i=s.asKindOrThrow(SyntaxKind.SpreadAssignment),n=i.getExpression().getText();e.insertPropertyAssignment(r,{name:`"___${n.replace(/^\.\.\./,"")}"`,initializer:`"...${n.replace(/^\.\.\./,"")}"`}),i.remove();}else if(s.isKind(SyntaxKind.PropertyAssignment)){let n=s.asKindOrThrow(SyntaxKind.PropertyAssignment).getInitializer();n&&n.isKind(SyntaxKind.ObjectLiteralExpression)?nr(n.asKindOrThrow(SyntaxKind.ObjectLiteralExpression)):n&&n.isKind(SyntaxKind.ArrayLiteralExpression)&&zi(n.asKindOrThrow(SyntaxKind.ArrayLiteralExpression));}}}function zi(e){let t=e.getElements();for(let r=0;r<t.length;r++){let s=t[r];if(s.isKind(SyntaxKind.ObjectLiteralExpression))nr(s.asKindOrThrow(SyntaxKind.ObjectLiteralExpression));else if(s.isKind(SyntaxKind.ArrayLiteralExpression))zi(s.asKindOrThrow(SyntaxKind.ArrayLiteralExpression));else if(s.isKind(SyntaxKind.SpreadElement)){let i=s.getText();e.removeElement(r),e.insertElement(r,`"${i}"`);}}}function or(e){let t=e.getProperties();for(let r=0;r<t.length;r++){let s=t[r];if(s.isKind(SyntaxKind.PropertyAssignment)){let i=s,n=i.getInitializer();if(n&&n.isKind(SyntaxKind.StringLiteral)){let o=n.asKindOrThrow(SyntaxKind.StringLiteral).getLiteralValue();o.startsWith("...")&&(e.insertSpreadAssignment(r,{expression:o.slice(3)}),i.remove());}else n?.isKind(SyntaxKind.ObjectLiteralExpression)?or(n):n&&n.isKind(SyntaxKind.ArrayLiteralExpression)&&Vi(n.asKindOrThrow(SyntaxKind.ArrayLiteralExpression));}}}function Vi(e){let t=e.getElements();for(let r=0;r<t.length;r++){let s=t[r];if(s.isKind(SyntaxKind.ObjectLiteralExpression))or(s.asKindOrThrow(SyntaxKind.ObjectLiteralExpression));else if(s.isKind(SyntaxKind.ArrayLiteralExpression))Vi(s.asKindOrThrow(SyntaxKind.ArrayLiteralExpression));else if(s.isKind(SyntaxKind.StringLiteral)){let i=s.getText(),n=/(?:^['"])(\.\.\..*)(?:['"]$)/g;n.test(i)&&(e.removeElement(r),e.insertElement(r,i.replace(n,"$1")));}}}async function al(e){let r=(await Hi(`const theme = ${e}`,null)).getStatements()[0];if(r?.getKind()===SyntaxKind.VariableStatement){let i=(r.getDeclarationList()?.getDeclarations()[0]).getInitializer();if(i?.isKind(SyntaxKind.ObjectLiteralExpression))return await Wt(i)}throw new Error("Invalid input: not an object literal")}function Wt(e){let t={};for(let r of e.getProperties())if(r.isKind(SyntaxKind.PropertyAssignment)){let s=r.getName().replace(/\'/g,"");r.getInitializer()?.isKind(SyntaxKind.ObjectLiteralExpression)?t[s]=Wt(r.getInitializer()):r.getInitializer()?.isKind(SyntaxKind.ArrayLiteralExpression)?t[s]=Gi(r.getInitializer()):t[s]=ar(r.getInitializer());}return t}function Gi(e){let t=[];for(let r of e.getElements())r.isKind(SyntaxKind.ObjectLiteralExpression)?t.push(Wt(r.asKindOrThrow(SyntaxKind.ObjectLiteralExpression))):r.isKind(SyntaxKind.ArrayLiteralExpression)?t.push(Gi(r.asKindOrThrow(SyntaxKind.ArrayLiteralExpression))):t.push(ar(r));return t}function ar(e){switch(e.getKind()){case SyntaxKind.StringLiteral:return e.getText();case SyntaxKind.NumericLiteral:return Number(e.getText());case SyntaxKind.TrueKeyword:return true;case SyntaxKind.FalseKeyword:return false;case SyntaxKind.NullKeyword:return null;case SyntaxKind.ArrayLiteralExpression:return e.getElements().map(ar);case SyntaxKind.ObjectLiteralExpression:return Wt(e);default:return e.getText()}}function Ui(e){let t={};for(let r of Object.keys(e)){let s=r.split("-"),i=s[0],n=s.slice(1).join("-");n===""?typeof t[i]=="object"?t[i].DEFAULT=`hsl(var(--${r}))`:t[i]=`hsl(var(--${r}))`:(typeof t[i]!="object"&&(t[i]={DEFAULT:`hsl(var(--${i}))`}),t[i][n]=`hsl(var(--${r}))`);}for(let[r,s]of Object.entries(t))typeof s=="object"&&s.DEFAULT===`hsl(var(--${r}))`&&!(r in e)&&delete s.DEFAULT;return t}function _e(e,t){let r={},s=[...e];if(!t?.registries)return Qe({}),s;for(let i=0;i<s.length;i++){if(Mt(s[i]))continue;let n=Oe(s[i],t);n&&(s[i]=n.url,Object.keys(n.headers).length>0&&(r[n.url]=n.headers));}return Qe(r),s}async function me(e,t,r={}){return r={...r,sourceCache:r.sourceCache??new Map},await Promise.all(e.map(async i=>{let n$1=Je(i);if(n$1.scheme==="github")return Fi(n$1,r);if(pe(i))return wi(i);if(_(i)){let[a]=await L([i],r);try{return n.parse(a)}catch(h){throw new M(i,h)}}if(i.startsWith("@")&&t?.registries){let a=_e([i],t),[h]=await L(a,r);try{return n.parse(h)}catch(l){throw new M(i,l)}}let o=`styles/${t?.style??"new-york-v4"}/${i}.json`,[c]=await L([o],r);try{return n.parse(c)}catch(a){throw new M(i,a)}}))}m.extend({type:f,_source:z.string().optional(),font:l.optional(),config:z.any().optional()}).passthrough();async function Bi(e,t,r={}){r={useCache:true,...r,sourceCache:r.sourceCache??new Map};let s=[],i=[],n$1=[],o=Array.from(new Set(e)),c=await me(o,t,r),a=new Map;for(let y=0;y<c.length;y++)c[y]&&a.set(o[y],c[y]);for(let[y,w]of Array.from(a.entries())){let v={...w,_source:y};if(s.push(v),w.registryDependencies){let b=w.registryDependencies;if(t?.registries)b=_e(w.registryDependencies,t);else {let $=w.registryDependencies.filter(k=>k.startsWith("@"));if($.length>0){let{registry:k}=ce($[0]);throw new ae(k)}}let{items:I,registryNames:T}=await Ne(b,t,r,new Set(o));i.push(...I),n$1.push(...T);}}if(s.push(...i),n$1.length>0){let y=Array.from(new Set(n$1)),w=y.filter(b=>!b.startsWith("@")),v=y.filter(b=>b.startsWith("@"));if(v.length>0){let b=await me(v,t,r);for(let I=0;I<b.length;I++){let $={...b[I],_source:v[I]};s.push($);}}if(w.length>0){let b=await It();if(!b&&s.length===0)return null;if(b){w.includes("index")&&w.unshift("index");let I=[];for(let Q of w){let yo=await ll(Q,t,r);I.push(...yo);}let T=Array.from(new Set(I)),$=await L(T,r),k=z.array(n).parse($);s.push(...k);}}}if(!s.length)return null;if((o.includes("index")||n$1.includes("index"))&&t.tailwind.baseColor){let y=await ul(t.tailwind.baseColor,t);y&&s.unshift(y);}let h=new Map;s.forEach(y=>{let w=y._source||y.name;h.set(y,w);}),s=dl(s,h),s.sort((y,w)=>y.type==="registry:theme"&&w.type!=="registry:theme"?-1:y.type!=="registry:theme"&&w.type==="registry:theme"?1:0);let l={};s.forEach(y=>{l=je(l,y.tailwind??{});});let u$1={};s.forEach(y=>{u$1=je(u$1,y.cssVars??{});});let f={};s.forEach(y=>{f=je(f,y.css??{});});let d="";s.forEach(y=>{y.docs&&(d+=`${y.docs}
|
|
46
|
+
`);});let p={};s.forEach(y=>{p=je(p,y.envVars??{});});let m=await ai(s.map(y=>y.files??[]),t),g=s.filter(y=>y.type==="registry:font"&&y.font).map(y=>({...y,type:"registry:font",font:y.font})),x=u.parse({dependencies:je.all(s.map(y=>y.dependencies??[])),devDependencies:je.all(s.map(y=>y.devDependencies??[])),files:m,tailwind:l,cssVars:u$1,css:f,docs:d,fonts:g.length>0?g:void 0});return Object.keys(p).length>0&&(x.envVars=p),x}async function Ne(e,t,r={},s=new Set){let i=[],n=[];for(let o of e){if(s.has(o))continue;if(s.add(o),Je(o).scheme==="github"){let[a]=await me([o],t,r);if(a&&(i.push({...a,_source:o}),a.registryDependencies)){let h=t?.registries?_e(a.registryDependencies,t):a.registryDependencies,l=await Ne(h,t,r,s);i.push(...l.items),n.push(...l.registryNames);}}else if(_(o)||pe(o)){let[a]=await me([o],t,r);if(a&&(i.push({...a,_source:o}),a.registryDependencies)){let h=t?.registries?_e(a.registryDependencies,t):a.registryDependencies,l=await Ne(h,t,r,s);i.push(...l.items),n.push(...l.registryNames);}}else if(o.startsWith("@")&&t?.registries){let{registry:a}=ce(o);if(a&&!(a in t.registries))throw new ae(a);let[h]=await me([o],t,r);if(h&&(i.push(h),h.registryDependencies)){let l=t?.registries?_e(h.registryDependencies,t):h.registryDependencies,u=await Ne(l,t,r,s);i.push(...u.items),n.push(...u.registryNames);}}else if(n.push(o),t)try{let[a]=await me([o],t,r);if(a&&a.registryDependencies){let h=t?.registries?_e(a.registryDependencies,t):a.registryDependencies,l=await Ne(h,t,r,s);i.push(...l.items),n.push(...l.registryNames);}}catch{}}return {items:i,registryNames:n}}async function ll(e,t,r={}){if(_(e))return [e];let{registryNames:s}=await Ne([e],t,r,new Set),i=t.resolvedPaths?.cwd?await Ls(t.resolvedPaths.cwd,t.style):t.style,n=s.map(o=>Dt(_(o)?o:`styles/${i}/${o}.json`));return Array.from(new Set(n))}async function ul(e,t){let[r,s]=await Promise.all([Nt(e),Ct(t)]);if(!r)return null;let i={name:e,type:"registry:theme",tailwind:{config:{theme:{extend:{borderRadius:{lg:"var(--radius)",md:"calc(var(--radius) - 2px)",sm:"calc(var(--radius) - 4px)"},colors:{}}}}},cssVars:{theme:{},light:{radius:"0.5rem"},dark:{}}};return t.tailwind.cssVariables&&(i.tailwind.config.theme.extend.colors={...i.tailwind.config.theme.extend.colors,...Ui(r.cssVars.dark??{})},i.cssVars={theme:{...r.cssVars.theme,...i.cssVars.theme},light:{...r.cssVars.light,...i.cssVars.light},dark:{...r.cssVars.dark,...i.cssVars.dark}},s==="v4"&&r.cssVarsV4&&(i.cssVars={theme:{...r.cssVarsV4.theme,...i.cssVars.theme},light:{radius:"0.625rem",...r.cssVarsV4.light},dark:{...r.cssVarsV4.dark}})),i}function ne(e,t){let r=t||e.name,s=createHash("sha256").update(r).digest("hex").substring(0,8);return `${e.name}::${s}`}function hl(e){let t=Je(e);if(t.scheme==="github")return {name:t.item,hash:ne({name:t.item},e)};if(_(e)){let i=new URL(e).pathname,n=i.match(/\/([^/]+)\.json$/),o=n?n[1]:R__default.basename(i,".json");return {name:o,hash:ne({name:o},e)}}if(pe(e)){let s=e.match(/\/([^/]+)\.json$/),i=s?s[1]:R__default.basename(e,".json");return {name:i,hash:ne({name:i},e)}}let{item:r}=ce(e);return {name:r,hash:ne({name:r},e)}}function dl(e,t){let r=new Map,s=new Map,i=new Map,n=new Map;e.forEach(h=>{let l=t.get(h)||h.name,u=ne(h,l);r.set(u,h),s.set(u,h),i.set(u,0),n.set(u,[]);});let o=new Map;e.forEach(h=>{let l=t.get(h)||h.name,u=ne(h,l);o.has(h.name)||o.set(h.name,[]),o.get(h.name).push(u),l!==h.name&&(o.has(l)||o.set(l,[]),o.get(l).push(u));}),e.forEach(h=>{let l=t.get(h)||h.name,u=ne(h,l);h.registryDependencies&&h.registryDependencies.forEach(f=>{let d,p=o.get(f)||[];if(p.length===1)d=p[0];else if(p.length>1)d=p[0];else {let{name:m}=hl(f),g=o.get(m)||[];g.length>0&&(d=g[0]);}d&&r.has(d)&&(n.get(d).push(u),i.set(u,i.get(u)+1));});});let c=[],a=[];for(i.forEach((h,l)=>{h===0&&c.push(l);});c.length>0;){let h=c.shift(),l=r.get(h);a.push(l),n.get(h).forEach(u=>{let f=i.get(u)-1;i.set(u,f),f===0&&c.push(u);});}if(a.length!==e.length){let h=new Set(a.map(l=>{let u=t.get(l)||l.name;return ne(l,u)}));e.forEach(l=>{let u=t.get(l)||l.name,f=ne(l,u);h.has(f)||a.push(l);});}return a}var lr=["npm","yarn","yarn@berry","pnpm","pnpm@6","bun","deno"],ur={"bun.lock":"bun","bun.lockb":"bun","deno.lock":"deno","pnpm-lock.yaml":"pnpm","pnpm-workspace.yaml":"pnpm","yarn.lock":"yarn","package-lock.json":"npm","npm-shrinkwrap.json":"npm"},hr={"node_modules/.deno/":"deno","node_modules/.pnpm/":"pnpm","node_modules/.yarn-state.yml":"yarn","node_modules/.yarn_integrity":"yarn","node_modules/.package-lock.json":"npm",".pnp.cjs":"yarn",".pnp.js":"yarn","bun.lock":"bun","bun.lockb":"bun"},qi={bun:"https://bun.sh",deno:"https://deno.com",pnpm:"https://pnpm.io/installation","pnpm@6":"https://pnpm.io/6.x/installation",yarn:"https://classic.yarnpkg.com/en/docs/install","yarn@berry":"https://yarnpkg.com/getting-started/install",npm:"https://docs.npmjs.com/cli/configuring-npm/install"};async function dr(e,t){try{let r=await Yi__default.stat(e);return t==="file"?r.isFile():r.isDirectory()}catch{return false}}function*pl(e=Z.cwd()){let t=R__default.resolve(e),{root:r}=R__default.parse(t);for(;t&&t!==r;)yield t,t=R__default.dirname(t);}async function Ji(e,t){return !e||!dr(e,"file")?null:await gl(e,t)}async function fr(e={}){let{cwd:t,strategies:r=["lockfile","packageManager-field","devEngines-field"],onUnknown:s}=e,i;if(typeof e.stopDir=="string"){let n=R__default.resolve(e.stopDir);i=o=>o===n;}else i=e.stopDir;for(let n of pl(t)){for(let o of r)switch(o){case "lockfile":{for(let c of Object.keys(ur))if(await dr(R__default.join(n,c),"file")){let a=ur[c],h=await Ji(R__default.join(n,"package.json"),s);return h||{name:a,agent:a}}break}case "packageManager-field":case "devEngines-field":{let c=await Ji(R__default.join(n,"package.json"),s);if(c)return c;break}case "install-metadata":{for(let c of Object.keys(hr)){let a=c.endsWith("/")?"dir":"file";if(await dr(R__default.join(n,c),a)){let h=hr[c],l=h==="yarn"?yl(c)?"yarn":"yarn@berry":h;return {name:h,agent:l}}}break}}if(i?.(n))break}return null}function ml(e){let t=r=>r?.match(/\d+(\.\d+){0,2}/)?.[0]??r;if(typeof e.packageManager=="string"){let[r,s]=e.packageManager.replace(/^\^/,"").split("@");return {name:r,ver:t(s)}}if(typeof e.devEngines?.packageManager?.name=="string")return {name:e.devEngines.packageManager.name,ver:t(e.devEngines.packageManager.version)}}async function gl(e,t){try{let r=JSON.parse(await Yi__default.readFile(e,"utf8")),s,i=ml(r);if(i){let n=i.name,o=i.ver,c=o;return n==="yarn"&&o&&Number.parseInt(o)>1?(s="yarn@berry",c="berry",{name:n,agent:s,version:c}):n==="pnpm"&&o&&Number.parseInt(o)<7?(s="pnpm@6",{name:n,agent:s,version:c}):lr.includes(n)?(s=n,{name:n,agent:s,version:c}):t?.(r.packageManager)??null}}catch{}return null}function yl(e){return e.endsWith(".yarn_integrity")}var Me=createRequire(import.meta.url),xl=Object.create,en=Object.defineProperty,vl=Object.getOwnPropertyDescriptor,bl=Object.getOwnPropertyNames,Rl=Object.getPrototypeOf,Il=Object.prototype.hasOwnProperty,ye=(e=>typeof Me<"u"?Me:typeof Proxy<"u"?new Proxy(e,{get:(t,r)=>(typeof Me<"u"?Me:t)[r]}):e)(function(e){if(typeof Me<"u")return Me.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')}),V=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),El=(e,t,r,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of bl(t))!Il.call(e,i)&&i!==r&&en(e,i,{get:()=>t[i],enumerable:!(s=vl(t,i))||s.enumerable});return e},Sl=(e,t,r)=>(r=e!=null?xl(Rl(e)):{},El(en(r,"default",{value:e,enumerable:true}),e)),Cl=V((e,t)=>{t.exports=n,n.sync=o;var r=ye("fs");function s(c,a){var h=a.pathExt!==void 0?a.pathExt:process.env.PATHEXT;if(!h||(h=h.split(";"),h.indexOf("")!==-1))return true;for(var l=0;l<h.length;l++){var u=h[l].toLowerCase();if(u&&c.substr(-u.length).toLowerCase()===u)return true}return false}function i(c,a,h){return !c.isSymbolicLink()&&!c.isFile()?false:s(a,h)}function n(c,a,h){r.stat(c,function(l,u){h(l,l?false:i(u,c,a));});}function o(c,a){return i(r.statSync(c),c,a)}}),kl=V((e,t)=>{t.exports=s,s.sync=i;var r=ye("fs");function s(c,a,h){r.stat(c,function(l,u){h(l,l?false:n(u,a));});}function i(c,a){return n(r.statSync(c),a)}function n(c,a){return c.isFile()&&o(c,a)}function o(c,a){var h=c.mode,l=c.uid,u=c.gid,f=a.uid!==void 0?a.uid:process.getuid&&process.getuid(),d=a.gid!==void 0?a.gid:process.getgid&&process.getgid(),p=parseInt("100",8),m=parseInt("010",8),g=parseInt("001",8),x=p|m,y=h&g||h&m&&u===d||h&p&&l===f||h&x&&f===0;return y}}),$l=V((e,t)=>{ye("fs");var s;process.platform==="win32"||global.TESTING_WINDOWS?s=Cl():s=kl(),t.exports=i,i.sync=n;function i(o,c,a){if(typeof c=="function"&&(a=c,c={}),!a){if(typeof Promise!="function")throw new TypeError("callback not provided");return new Promise(function(h,l){i(o,c||{},function(u,f){u?l(u):h(f);});})}s(o,c||{},function(h,l){h&&(h.code==="EACCES"||c&&c.ignoreErrors)&&(h=null,l=false),a(h,l);});}function n(o,c){try{return s.sync(o,c||{})}catch(a){if(c&&c.ignoreErrors||a.code==="EACCES")return false;throw a}}}),Tl=V((e,t)=>{var r=process.platform==="win32"||process.env.OSTYPE==="cygwin"||process.env.OSTYPE==="msys",s=ye("path"),i=r?";":":",n=$l(),o=l=>Object.assign(new Error(`not found: ${l}`),{code:"ENOENT"}),c=(l,u)=>{let f=u.colon||i,d=l.match(/\//)||r&&l.match(/\\/)?[""]:[...r?[process.cwd()]:[],...(u.path||process.env.PATH||"").split(f)],p=r?u.pathExt||process.env.PATHEXT||".EXE;.CMD;.BAT;.COM":"",m=r?p.split(f):[""];return r&&l.indexOf(".")!==-1&&m[0]!==""&&m.unshift(""),{pathEnv:d,pathExt:m,pathExtExe:p}},a=(l,u,f)=>{typeof u=="function"&&(f=u,u={}),u||(u={});let{pathEnv:d,pathExt:p,pathExtExe:m}=c(l,u),g=[],x=w=>new Promise((v,b)=>{if(w===d.length)return u.all&&g.length?v(g):b(o(l));let I=d[w],T=/^".*"$/.test(I)?I.slice(1,-1):I,$=s.join(T,l),k=!T&&/^\.[\\\/]/.test(l)?l.slice(0,2)+$:$;v(y(k,w,0));}),y=(w,v,b)=>new Promise((I,T)=>{if(b===p.length)return I(x(v+1));let $=p[b];n(w+$,{pathExt:m},(k,Q)=>{if(!k&&Q)if(u.all)g.push(w+$);else return I(w+$);return I(y(w,v,b+1))});});return f?x(0).then(w=>f(null,w),f):x(0)},h=(l,u)=>{u=u||{};let{pathEnv:f,pathExt:d,pathExtExe:p}=c(l,u),m=[];for(let g=0;g<f.length;g++){let x=f[g],y=/^".*"$/.test(x)?x.slice(1,-1):x,w=s.join(y,l),v=!y&&/^\.[\\\/]/.test(l)?l.slice(0,2)+w:w;for(let b=0;b<d.length;b++){let I=v+d[b];try{if(n.sync(I,{pathExt:p}))if(u.all)m.push(I);else return I}catch{}}}if(u.all&&m.length)return m;if(u.nothrow)return null;throw o(l)};t.exports=a,a.sync=h;}),Pl=V((e,t)=>{var r=(s={})=>{let i=s.env||process.env;return (s.platform||process.platform)!=="win32"?"PATH":Object.keys(i).reverse().find(n=>n.toUpperCase()==="PATH")||"Path"};t.exports=r,t.exports.default=r;}),Al=V((e,t)=>{var r=ye("path"),s=Tl(),i=Pl();function n(c,a){let h=c.options.env||process.env,l=process.cwd(),u=c.options.cwd!=null,f=u&&process.chdir!==void 0&&!process.chdir.disabled;if(f)try{process.chdir(c.options.cwd);}catch{}let d;try{d=s.sync(c.command,{path:h[i({env:h})],pathExt:a?r.delimiter:void 0});}catch{}finally{f&&process.chdir(l);}return d&&(d=r.resolve(u?c.options.cwd:"",d)),d}function o(c){return n(c)||n(c,true)}t.exports=o;}),Ol=V((e,t)=>{var r=/([()\][%!^"`<>&|;, *?])/g;function s(n){return n=n.replace(r,"^$1"),n}function i(n,o){return n=`${n}`,n=n.replace(/(\\*)"/g,'$1$1\\"'),n=n.replace(/(\\*)$/,"$1$1"),n=`"${n}"`,n=n.replace(r,"^$1"),o&&(n=n.replace(r,"^$1")),n}t.exports.command=s,t.exports.argument=i;}),jl=V((e,t)=>{t.exports=/^#!(.*)/;}),_l=V((e,t)=>{var r=jl();t.exports=(s="")=>{let i=s.match(r);if(!i)return null;let[n,o]=i[0].replace(/#! ?/,"").split(" "),c=n.split("/").pop();return c==="env"?o:o?`${c} ${o}`:c};}),Nl=V((e,t)=>{var r=ye("fs"),s=_l();function i(n){let o=Buffer.alloc(150),c;try{c=r.openSync(n,"r"),r.readSync(c,o,0,150,0),r.closeSync(c);}catch{}return s(o.toString())}t.exports=i;}),Ml=V((e,t)=>{var r=ye("path"),s=Al(),i=Ol(),n=Nl(),o=process.platform==="win32",c=/\.(?:com|exe)$/i,a=/node_modules[\\/].bin[\\/][^\\/]+\.cmd$/i;function h(f){f.file=s(f);let d=f.file&&n(f.file);return d?(f.args.unshift(f.file),f.command=d,s(f)):f.file}function l(f){if(!o)return f;let d=h(f),p=!c.test(d);if(f.options.forceShell||p){let m=a.test(d);f.command=r.normalize(f.command),f.command=i.command(f.command),f.args=f.args.map(x=>i.argument(x,m));let g=[f.command].concat(f.args).join(" ");f.args=["/d","/s","/c",`"${g}"`],f.command=process.env.comspec||"cmd.exe",f.options.windowsVerbatimArguments=true;}return f}function u(f,d,p){d&&!Array.isArray(d)&&(p=d,d=null),d=d?d.slice(0):[],p=Object.assign({},p);let m={command:f,args:d,options:p,file:void 0,original:{command:f,args:d}};return p.shell?m:l(m)}t.exports=u;}),Ll=V((e,t)=>{var r=process.platform==="win32";function s(c,a){return Object.assign(new Error(`${a} ${c.command} ENOENT`),{code:"ENOENT",errno:"ENOENT",syscall:`${a} ${c.command}`,path:c.command,spawnargs:c.args})}function i(c,a){if(!r)return;let h=c.emit;c.emit=function(l,u){if(l==="exit"){let f=n(u,a);if(f)return h.call(c,"error",f)}return h.apply(c,arguments)};}function n(c,a){return r&&c===1&&!a.file?s(a.original,"spawn"):null}function o(c,a){return r&&c===1&&!a.file?s(a.original,"spawnSync"):null}t.exports={hookChildProcess:i,verifyENOENT:n,verifyENOENTSync:o,notFoundError:s};}),Fl=V((e,t)=>{var r=ye("child_process"),s=Ml(),i=Ll();function n(c,a,h){let l=s(c,a,h),u=r.spawn(l.command,l.args,l.options);return i.hookChildProcess(u,l),u}function o(c,a,h){let l=s(c,a,h),u=r.spawnSync(l.command,l.args,l.options);return u.error=u.error||i.verifyENOENTSync(u.status,l),u}t.exports=n,t.exports.spawn=n,t.exports.sync=o,t.exports._parse=s,t.exports._enoent=i;}),Gl=/^path$/i,Xi={key:"PATH",value:""};function Ul(e){for(let t in e){if(!Object.prototype.hasOwnProperty.call(e,t)||!Gl.test(t))continue;let r=e[t];return r?{key:t,value:r}:Xi}return Xi}function Kl(e,t){let r=t.value.split(delimiter),s=e,i;do r.push(resolve(s,"node_modules",".bin")),i=s,s=dirname(s);while(s!==i);return {key:t.key,value:r.join(delimiter)}}function Bl(e,t){let r={...process.env,...t},s=Kl(e,Ul(r));return r[s.key]=s.value,r}var Jl=e=>{let t=e.length,r=new PassThrough,s=()=>{--t===0&&r.emit("end");};for(let i of e)i.pipe(r,{end:false}),i.on("end",s);return r},Yl=Sl(Fl()),Qi=class extends Error{result;output;get exitCode(){if(this.result.exitCode!==null)return this.result.exitCode}constructor(e,t){super(`Process exited with non-zero status (${e.exitCode})`),this.result=e,this.output=t;}},Xl={timeout:void 0,persist:false},Ql={windowsHide:true};function eu(e,t){return {command:normalize(e),args:t??[]}}function tu(e){let t=new AbortController;for(let r of e){if(r.aborted)return t.abort(),r;let s=()=>{t.abort(r.reason);};r.addEventListener("abort",s,{signal:t.signal});}return t.signal}var ru=class{_process;_aborted=false;_options;_command;_args;_resolveClose;_processClosed;_thrownError;get process(){return this._process}get pid(){return this._process?.pid}get exitCode(){if(this._process&&this._process.exitCode!==null)return this._process.exitCode}constructor(e,t,r){this._options={...Xl,...r},this._command=e,this._args=t??[],this._processClosed=new Promise(s=>{this._resolveClose=s;});}kill(e){return this._process?.kill(e)===true}get aborted(){return this._aborted}get killed(){return this._process?.killed===true}pipe(e,t,r){return su(e,t,{...r,stdin:this})}async*[Symbol.asyncIterator](){let e=this._process;if(!e)return;let t=[];this._streamErr&&t.push(this._streamErr),this._streamOut&&t.push(this._streamOut);let r=Jl(t),s=Zl.createInterface({input:r});for await(let i of s)yield i.toString();if(await this._processClosed,e.removeAllListeners(),this._thrownError)throw this._thrownError;if(this._options?.throwOnError&&this.exitCode!==0&&this.exitCode!==void 0)throw new Qi(this)}async _waitForOutput(){let e=this._process;if(!e)throw new Error("No process was started");let t="",r="";if(this._streamOut)for await(let i of this._streamOut)r+=i.toString();if(this._streamErr)for await(let i of this._streamErr)t+=i.toString();if(await this._processClosed,this._options?.stdin&&await this._options.stdin,e.removeAllListeners(),this._thrownError)throw this._thrownError;let s={stderr:t,stdout:r,exitCode:this.exitCode};if(this._options.throwOnError&&this.exitCode!==0&&this.exitCode!==void 0)throw new Qi(this,s);return s}then(e,t){return this._waitForOutput().then(e,t)}_streamOut;_streamErr;spawn(){let e=cwd(),t=this._options,r={...Ql,...t.nodeOptions},s=[];this._resetState(),t.timeout!==void 0&&s.push(AbortSignal.timeout(t.timeout)),t.signal!==void 0&&s.push(t.signal),t.persist===true&&(r.detached=true),s.length>0&&(r.signal=tu(s)),r.env=Bl(e,r.env);let{command:i,args:n}=eu(this._command,this._args),o=(0, Yl._parse)(i,n,r),c=spawn(o.command,o.args,o.options);if(c.stderr&&(this._streamErr=c.stderr),c.stdout&&(this._streamOut=c.stdout),this._process=c,c.once("error",this._onError),c.once("close",this._onClose),t.stdin!==void 0&&c.stdin&&t.stdin.process){let{stdout:a}=t.stdin.process;a&&a.pipe(c.stdin);}}_resetState(){this._aborted=false,this._processClosed=new Promise(e=>{this._resolveClose=e;}),this._thrownError=void 0;}_onError=e=>{if(e.name==="AbortError"&&(!(e.cause instanceof Error)||e.cause.name!=="TimeoutError")){this._aborted=true;return}this._thrownError=e;};_onClose=()=>{this._resolveClose&&this._resolveClose();}},pr=(e,t,r)=>{let s=new ru(e,t,r);return s.spawn(),s},su=pr;function rs(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var gr={},yr,rn;function q(){if(rn)return yr;rn=1;let e,t,r,s,i=true;typeof process<"u"&&({FORCE_COLOR:e,NODE_DISABLE_COLORS:t,NO_COLOR:r,TERM:s}=process.env||{},i=process.stdout&&process.stdout.isTTY);let n={enabled:!t&&r==null&&s!=="dumb"&&(e!=null&&e!=="0"||i),reset:a(0,0),bold:a(1,22),dim:a(2,22),italic:a(3,23),underline:a(4,24),inverse:a(7,27),hidden:a(8,28),strikethrough:a(9,29),black:a(30,39),red:a(31,39),green:a(32,39),yellow:a(33,39),blue:a(34,39),magenta:a(35,39),cyan:a(36,39),white:a(37,39),gray:a(90,39),grey:a(90,39),bgBlack:a(40,49),bgRed:a(41,49),bgGreen:a(42,49),bgYellow:a(43,49),bgBlue:a(44,49),bgMagenta:a(45,49),bgCyan:a(46,49),bgWhite:a(47,49)};function o(h,l){let u=0,f,d="",p="";for(;u<h.length;u++)f=h[u],d+=f.open,p+=f.close,~l.indexOf(f.close)&&(l=l.replace(f.rgx,f.close+f.open));return d+l+p}function c(h,l){let u={has:h,keys:l};return u.reset=n.reset.bind(u),u.bold=n.bold.bind(u),u.dim=n.dim.bind(u),u.italic=n.italic.bind(u),u.underline=n.underline.bind(u),u.inverse=n.inverse.bind(u),u.hidden=n.hidden.bind(u),u.strikethrough=n.strikethrough.bind(u),u.black=n.black.bind(u),u.red=n.red.bind(u),u.green=n.green.bind(u),u.yellow=n.yellow.bind(u),u.blue=n.blue.bind(u),u.magenta=n.magenta.bind(u),u.cyan=n.cyan.bind(u),u.white=n.white.bind(u),u.gray=n.gray.bind(u),u.grey=n.grey.bind(u),u.bgBlack=n.bgBlack.bind(u),u.bgRed=n.bgRed.bind(u),u.bgGreen=n.bgGreen.bind(u),u.bgYellow=n.bgYellow.bind(u),u.bgBlue=n.bgBlue.bind(u),u.bgMagenta=n.bgMagenta.bind(u),u.bgCyan=n.bgCyan.bind(u),u.bgWhite=n.bgWhite.bind(u),u}function a(h,l){let u={open:`\x1B[${h}m`,close:`\x1B[${l}m`,rgx:new RegExp(`\\x1b\\[${l}m`,"g")};return function(f){return this!==void 0&&this.has!==void 0?(~this.has.indexOf(h)||(this.has.push(h),this.keys.push(u)),f===void 0?this:n.enabled?o(this.keys,f+""):f+""):f===void 0?c([h],[u]):n.enabled?o([u],f+""):f+""}}return yr=n,yr}var wr,sn;function fu(){return sn||(sn=1,wr=(e,t)=>{if(!(e.meta&&e.name!=="escape")){if(e.ctrl)return e.name==="a"?"first":e.name==="c"||e.name==="d"?"abort":e.name==="e"?"last":e.name==="g"?"reset":e.name==="n"?"down":e.name==="p"?"up":void 0;if(t){if(e.name==="j")return "down";if(e.name==="k")return "up"}return e.name==="return"||e.name==="enter"?"submit":e.name==="backspace"?"delete":e.name==="delete"?"deleteForward":e.name==="abort"?"abort":e.name==="escape"?"exit":e.name==="tab"?"next":e.name==="pagedown"?"nextPage":e.name==="pageup"?"prevPage":e.name==="home"?"home":e.name==="end"?"end":e.name==="up"?"up":e.name==="down"?"down":e.name==="right"?"right":e.name==="left"?"left":false}}),wr}var xr,nn;function ss(){return nn||(nn=1,xr=e=>{let t=["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)","(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PRZcf-ntqry=><~]))"].join("|"),r=new RegExp(t,"g");return typeof e=="string"?e.replace(r,""):e}),xr}var vr,on;function J(){if(on)return vr;on=1;let e="\x1B",t=`${e}[`,r="\x07",s={to(o,c){return c?`${t}${c+1};${o+1}H`:`${t}${o+1}G`},move(o,c){let a="";return o<0?a+=`${t}${-o}D`:o>0&&(a+=`${t}${o}C`),c<0?a+=`${t}${-c}A`:c>0&&(a+=`${t}${c}B`),a},up:(o=1)=>`${t}${o}A`,down:(o=1)=>`${t}${o}B`,forward:(o=1)=>`${t}${o}C`,backward:(o=1)=>`${t}${o}D`,nextLine:(o=1)=>`${t}E`.repeat(o),prevLine:(o=1)=>`${t}F`.repeat(o),left:`${t}G`,hide:`${t}?25l`,show:`${t}?25h`,save:`${e}7`,restore:`${e}8`},i={up:(o=1)=>`${t}S`.repeat(o),down:(o=1)=>`${t}T`.repeat(o)},n={screen:`${t}2J`,up:(o=1)=>`${t}1J`.repeat(o),down:(o=1)=>`${t}J`.repeat(o),line:`${t}2K`,lineEnd:`${t}K`,lineStart:`${t}1K`,lines(o){let c="";for(let a=0;a<o;a++)c+=this.line+(a<o-1?s.up():"");return o&&(c+=s.left),c}};return vr={cursor:s,scroll:i,erase:n,beep:r},vr}var br,an;function pu(){if(an)return br;an=1;let e=ss(),{erase:t,cursor:r}=J(),s=i=>[...e(i)].length;return br=function(i,n){if(!n)return t.line+r.to(0);let o=0,c=i.split(/\r?\n/);for(let a of c)o+=1+Math.floor(Math.max(s(a)-1,0)/n);return t.lines(o)},br}var Rr,cn;function Yn(){if(cn)return Rr;cn=1;let e={arrowUp:"\u2191",arrowDown:"\u2193",arrowLeft:"\u2190",arrowRight:"\u2192",radioOn:"\u25C9",radioOff:"\u25EF",tick:"\u2714",cross:"\u2716",ellipsis:"\u2026",pointerSmall:"\u203A",line:"\u2500",pointer:"\u276F"},t={arrowUp:e.arrowUp,arrowDown:e.arrowDown,arrowLeft:e.arrowLeft,arrowRight:e.arrowRight,radioOn:"(*)",radioOff:"( )",tick:"\u221A",cross:"\xD7",ellipsis:"...",pointerSmall:"\xBB",line:"\u2500",pointer:">"};return Rr=process.platform==="win32"?t:e,Rr}var Ir,ln;function mu(){if(ln)return Ir;ln=1;let e=q(),t=Yn(),r=Object.freeze({password:{scale:1,render:a=>"*".repeat(a.length)},emoji:{scale:2,render:a=>"\u{1F603}".repeat(a.length)},invisible:{scale:0,render:a=>""},default:{scale:1,render:a=>`${a}`}}),s=a=>r[a]||r.default,i=Object.freeze({aborted:e.red(t.cross),done:e.green(t.tick),exited:e.yellow(t.cross),default:e.cyan("?")});return Ir={styles:r,render:s,symbols:i,symbol:(a,h,l)=>h?i.aborted:l?i.exited:a?i.done:i.default,delimiter:a=>e.gray(a?t.ellipsis:t.pointerSmall),item:(a,h)=>e.gray(a?h?t.pointerSmall:"+":t.line)},Ir}var Er,un;function gu(){if(un)return Er;un=1;let e=ss();return Er=function(t,r){let s=String(e(t)||"").split(/\r?\n/);return r?s.map(i=>Math.ceil(i.length/r)).reduce((i,n)=>i+n):s.length},Er}var Sr,hn;function yu(){return hn||(hn=1,Sr=(e,t={})=>{let r=Number.isSafeInteger(parseInt(t.margin))?new Array(parseInt(t.margin)).fill(" ").join(""):t.margin||"",s=t.width;return (e||"").split(/\r?\n/g).map(i=>i.split(/\s+/g).reduce((n,o)=>(o.length+r.length>=s||n[n.length-1].length+o.length+1<s?n[n.length-1]+=` ${o}`:n.push(`${r}${o}`),n),[r]).join(`
|
|
47
|
+
`)).join(`
|
|
48
|
+
`)}),Sr}var Cr,dn;function wu(){return dn||(dn=1,Cr=(e,t,r)=>{r=r||t;let s=Math.min(t-r,e-Math.floor(r/2));s<0&&(s=0);let i=Math.min(s+r,t);return {startIndex:s,endIndex:i}}),Cr}var kr,fn;function X(){return fn||(fn=1,kr={action:fu(),clear:pu(),style:mu(),strip:ss(),figures:Yn(),lines:gu(),wrap:yu(),entriesToDisplay:wu()}),kr}var $r,pn;function we(){if(pn)return $r;pn=1;let e=Zl,{action:t}=X(),r=au,{beep:s,cursor:i}=J(),n=q();class o extends r{constructor(a={}){super(),this.firstRender=true,this.in=a.stdin||process.stdin,this.out=a.stdout||process.stdout,this.onRender=(a.onRender||(()=>{})).bind(this);let h=e.createInterface({input:this.in,escapeCodeTimeout:50});e.emitKeypressEvents(this.in,h),this.in.isTTY&&this.in.setRawMode(true);let l=["SelectPrompt","MultiselectPrompt"].indexOf(this.constructor.name)>-1,u=(f,d)=>{let p=t(d,l);p===false?this._&&this._(f,d):typeof this[p]=="function"?this[p](d):this.bell();};this.close=()=>{this.out.write(i.show),this.in.removeListener("keypress",u),this.in.isTTY&&this.in.setRawMode(false),h.close(),this.emit(this.aborted?"abort":this.exited?"exit":"submit",this.value),this.closed=true;},this.in.on("keypress",u);}fire(){this.emit("state",{value:this.value,aborted:!!this.aborted,exited:!!this.exited});}bell(){this.out.write(s);}render(){this.onRender(n),this.firstRender&&(this.firstRender=false);}}return $r=o,$r}var Tr,mn;function xu(){if(mn)return Tr;mn=1;let e=q(),t=we(),{erase:r,cursor:s}=J(),{style:i,clear:n,lines:o,figures:c}=X();class a extends t{constructor(l={}){super(l),this.transform=i.render(l.style),this.scale=this.transform.scale,this.msg=l.message,this.initial=l.initial||"",this.validator=l.validate||(()=>true),this.value="",this.errorMsg=l.error||"Please Enter A Valid Value",this.cursor=+!!this.initial,this.cursorOffset=0,this.clear=n("",this.out.columns),this.render();}set value(l){!l&&this.initial?(this.placeholder=true,this.rendered=e.gray(this.transform.render(this.initial))):(this.placeholder=false,this.rendered=this.transform.render(l)),this._value=l,this.fire();}get value(){return this._value}reset(){this.value="",this.cursor=+!!this.initial,this.cursorOffset=0,this.fire(),this.render();}exit(){this.abort();}abort(){this.value=this.value||this.initial,this.done=this.aborted=true,this.error=false,this.red=false,this.fire(),this.render(),this.out.write(`
|
|
49
|
+
`),this.close();}async validate(){let l=await this.validator(this.value);typeof l=="string"&&(this.errorMsg=l,l=false),this.error=!l;}async submit(){if(this.value=this.value||this.initial,this.cursorOffset=0,this.cursor=this.rendered.length,await this.validate(),this.error){this.red=true,this.fire(),this.render();return}this.done=true,this.aborted=false,this.fire(),this.render(),this.out.write(`
|
|
50
|
+
`),this.close();}next(){if(!this.placeholder)return this.bell();this.value=this.initial,this.cursor=this.rendered.length,this.fire(),this.render();}moveCursor(l){this.placeholder||(this.cursor=this.cursor+l,this.cursorOffset+=l);}_(l,u){let f=this.value.slice(0,this.cursor),d=this.value.slice(this.cursor);this.value=`${f}${l}${d}`,this.red=false,this.cursor=this.placeholder?0:f.length+1,this.render();}delete(){if(this.isCursorAtStart())return this.bell();let l=this.value.slice(0,this.cursor-1),u=this.value.slice(this.cursor);this.value=`${l}${u}`,this.red=false,this.isCursorAtStart()?this.cursorOffset=0:(this.cursorOffset++,this.moveCursor(-1)),this.render();}deleteForward(){if(this.cursor*this.scale>=this.rendered.length||this.placeholder)return this.bell();let l=this.value.slice(0,this.cursor),u=this.value.slice(this.cursor+1);this.value=`${l}${u}`,this.red=false,this.isCursorAtEnd()?this.cursorOffset=0:this.cursorOffset++,this.render();}first(){this.cursor=0,this.render();}last(){this.cursor=this.value.length,this.render();}left(){if(this.cursor<=0||this.placeholder)return this.bell();this.moveCursor(-1),this.render();}right(){if(this.cursor*this.scale>=this.rendered.length||this.placeholder)return this.bell();this.moveCursor(1),this.render();}isCursorAtStart(){return this.cursor===0||this.placeholder&&this.cursor===1}isCursorAtEnd(){return this.cursor===this.rendered.length||this.placeholder&&this.cursor===this.rendered.length+1}render(){this.closed||(this.firstRender||(this.outputError&&this.out.write(s.down(o(this.outputError,this.out.columns)-1)+n(this.outputError,this.out.columns)),this.out.write(n(this.outputText,this.out.columns))),super.render(),this.outputError="",this.outputText=[i.symbol(this.done,this.aborted),e.bold(this.msg),i.delimiter(this.done),this.red?e.red(this.rendered):this.rendered].join(" "),this.error&&(this.outputError+=this.errorMsg.split(`
|
|
51
|
+
`).reduce((l,u,f)=>l+`
|
|
52
|
+
${f?" ":c.pointerSmall} ${e.red().italic(u)}`,"")),this.out.write(r.line+s.to(0)+this.outputText+s.save+this.outputError+s.restore+s.move(this.cursorOffset,0)));}}return Tr=a,Tr}var Pr,gn;function vu(){if(gn)return Pr;gn=1;let e=q(),t=we(),{style:r,clear:s,figures:i,wrap:n,entriesToDisplay:o}=X(),{cursor:c}=J();class a extends t{constructor(l={}){super(l),this.msg=l.message,this.hint=l.hint||"- Use arrow-keys. Return to submit.",this.warn=l.warn||"- This option is disabled",this.cursor=l.initial||0,this.choices=l.choices.map((u,f)=>(typeof u=="string"&&(u={title:u,value:f}),{title:u&&(u.title||u.value||u),value:u&&(u.value===void 0?f:u.value),description:u&&u.description,selected:u&&u.selected,disabled:u&&u.disabled})),this.optionsPerPage=l.optionsPerPage||10,this.value=(this.choices[this.cursor]||{}).value,this.clear=s("",this.out.columns),this.render();}moveCursor(l){this.cursor=l,this.value=this.choices[l].value,this.fire();}reset(){this.moveCursor(0),this.fire(),this.render();}exit(){this.abort();}abort(){this.done=this.aborted=true,this.fire(),this.render(),this.out.write(`
|
|
53
|
+
`),this.close();}submit(){this.selection.disabled?this.bell():(this.done=true,this.aborted=false,this.fire(),this.render(),this.out.write(`
|
|
54
|
+
`),this.close());}first(){this.moveCursor(0),this.render();}last(){this.moveCursor(this.choices.length-1),this.render();}up(){this.cursor===0?this.moveCursor(this.choices.length-1):this.moveCursor(this.cursor-1),this.render();}down(){this.cursor===this.choices.length-1?this.moveCursor(0):this.moveCursor(this.cursor+1),this.render();}next(){this.moveCursor((this.cursor+1)%this.choices.length),this.render();}_(l,u){if(l===" ")return this.submit()}get selection(){return this.choices[this.cursor]}render(){if(this.closed)return;this.firstRender?this.out.write(c.hide):this.out.write(s(this.outputText,this.out.columns)),super.render();let{startIndex:l,endIndex:u}=o(this.cursor,this.choices.length,this.optionsPerPage);if(this.outputText=[r.symbol(this.done,this.aborted),e.bold(this.msg),r.delimiter(false),this.done?this.selection.title:this.selection.disabled?e.yellow(this.warn):e.gray(this.hint)].join(" "),!this.done){this.outputText+=`
|
|
55
|
+
`;for(let f=l;f<u;f++){let d,p,m="",g=this.choices[f];f===l&&l>0?p=i.arrowUp:f===u-1&&u<this.choices.length?p=i.arrowDown:p=" ",g.disabled?(d=this.cursor===f?e.gray().underline(g.title):e.strikethrough().gray(g.title),p=(this.cursor===f?e.bold().gray(i.pointer)+" ":" ")+p):(d=this.cursor===f?e.cyan().underline(g.title):g.title,p=(this.cursor===f?e.cyan(i.pointer)+" ":" ")+p,g.description&&this.cursor===f&&(m=` - ${g.description}`,(p.length+d.length+m.length>=this.out.columns||g.description.split(/\r?\n/).length>1)&&(m=`
|
|
56
|
+
`+n(g.description,{margin:3,width:this.out.columns})))),this.outputText+=`${p} ${d}${e.gray(m)}
|
|
57
|
+
`;}}this.out.write(this.outputText);}}return Pr=a,Pr}var Ar,yn;function bu(){if(yn)return Ar;yn=1;let e=q(),t=we(),{style:r,clear:s}=X(),{cursor:i,erase:n}=J();class o extends t{constructor(a={}){super(a),this.msg=a.message,this.value=!!a.initial,this.active=a.active||"on",this.inactive=a.inactive||"off",this.initialValue=this.value,this.render();}reset(){this.value=this.initialValue,this.fire(),this.render();}exit(){this.abort();}abort(){this.done=this.aborted=true,this.fire(),this.render(),this.out.write(`
|
|
58
|
+
`),this.close();}submit(){this.done=true,this.aborted=false,this.fire(),this.render(),this.out.write(`
|
|
59
|
+
`),this.close();}deactivate(){if(this.value===false)return this.bell();this.value=false,this.render();}activate(){if(this.value===true)return this.bell();this.value=true,this.render();}delete(){this.deactivate();}left(){this.deactivate();}right(){this.activate();}down(){this.deactivate();}up(){this.activate();}next(){this.value=!this.value,this.fire(),this.render();}_(a,h){if(a===" ")this.value=!this.value;else if(a==="1")this.value=true;else if(a==="0")this.value=false;else return this.bell();this.render();}render(){this.closed||(this.firstRender?this.out.write(i.hide):this.out.write(s(this.outputText,this.out.columns)),super.render(),this.outputText=[r.symbol(this.done,this.aborted),e.bold(this.msg),r.delimiter(this.done),this.value?this.inactive:e.cyan().underline(this.inactive),e.gray("/"),this.value?e.cyan().underline(this.active):this.active].join(" "),this.out.write(n.line+i.to(0)+this.outputText));}}return Ar=o,Ar}var Or,wn;function oe(){if(wn)return Or;wn=1;class e{constructor({token:r,date:s,parts:i,locales:n}){this.token=r,this.date=s||new Date,this.parts=i||[this],this.locales=n||{};}up(){}down(){}next(){let r=this.parts.indexOf(this);return this.parts.find((s,i)=>i>r&&s instanceof e)}setTo(r){}prev(){let r=[].concat(this.parts).reverse(),s=r.indexOf(this);return r.find((i,n)=>n>s&&i instanceof e)}toString(){return String(this.date)}}return Or=e,Or}var jr,xn;function Ru(){if(xn)return jr;xn=1;let e=oe();class t extends e{constructor(s={}){super(s);}up(){this.date.setHours((this.date.getHours()+12)%24);}down(){this.up();}toString(){let s=this.date.getHours()>12?"pm":"am";return /\A/.test(this.token)?s.toUpperCase():s}}return jr=t,jr}var _r,vn;function Iu(){if(vn)return _r;vn=1;let e=oe(),t=s=>(s=s%10,s===1?"st":s===2?"nd":s===3?"rd":"th");class r extends e{constructor(i={}){super(i);}up(){this.date.setDate(this.date.getDate()+1);}down(){this.date.setDate(this.date.getDate()-1);}setTo(i){this.date.setDate(parseInt(i.substr(-2)));}toString(){let i=this.date.getDate(),n=this.date.getDay();return this.token==="DD"?String(i).padStart(2,"0"):this.token==="Do"?i+t(i):this.token==="d"?n+1:this.token==="ddd"?this.locales.weekdaysShort[n]:this.token==="dddd"?this.locales.weekdays[n]:i}}return _r=r,_r}var Nr,bn;function Eu(){if(bn)return Nr;bn=1;let e=oe();class t extends e{constructor(s={}){super(s);}up(){this.date.setHours(this.date.getHours()+1);}down(){this.date.setHours(this.date.getHours()-1);}setTo(s){this.date.setHours(parseInt(s.substr(-2)));}toString(){let s=this.date.getHours();return /h/.test(this.token)&&(s=s%12||12),this.token.length>1?String(s).padStart(2,"0"):s}}return Nr=t,Nr}var Mr,Rn;function Su(){if(Rn)return Mr;Rn=1;let e=oe();class t extends e{constructor(s={}){super(s);}up(){this.date.setMilliseconds(this.date.getMilliseconds()+1);}down(){this.date.setMilliseconds(this.date.getMilliseconds()-1);}setTo(s){this.date.setMilliseconds(parseInt(s.substr(-this.token.length)));}toString(){return String(this.date.getMilliseconds()).padStart(4,"0").substr(0,this.token.length)}}return Mr=t,Mr}var Lr,In;function Cu(){if(In)return Lr;In=1;let e=oe();class t extends e{constructor(s={}){super(s);}up(){this.date.setMinutes(this.date.getMinutes()+1);}down(){this.date.setMinutes(this.date.getMinutes()-1);}setTo(s){this.date.setMinutes(parseInt(s.substr(-2)));}toString(){let s=this.date.getMinutes();return this.token.length>1?String(s).padStart(2,"0"):s}}return Lr=t,Lr}var Fr,En;function ku(){if(En)return Fr;En=1;let e=oe();class t extends e{constructor(s={}){super(s);}up(){this.date.setMonth(this.date.getMonth()+1);}down(){this.date.setMonth(this.date.getMonth()-1);}setTo(s){s=parseInt(s.substr(-2))-1,this.date.setMonth(s<0?0:s);}toString(){let s=this.date.getMonth(),i=this.token.length;return i===2?String(s+1).padStart(2,"0"):i===3?this.locales.monthsShort[s]:i===4?this.locales.months[s]:String(s+1)}}return Fr=t,Fr}var Dr,Sn;function $u(){if(Sn)return Dr;Sn=1;let e=oe();class t extends e{constructor(s={}){super(s);}up(){this.date.setSeconds(this.date.getSeconds()+1);}down(){this.date.setSeconds(this.date.getSeconds()-1);}setTo(s){this.date.setSeconds(parseInt(s.substr(-2)));}toString(){let s=this.date.getSeconds();return this.token.length>1?String(s).padStart(2,"0"):s}}return Dr=t,Dr}var Wr,Cn;function Tu(){if(Cn)return Wr;Cn=1;let e=oe();class t extends e{constructor(s={}){super(s);}up(){this.date.setFullYear(this.date.getFullYear()+1);}down(){this.date.setFullYear(this.date.getFullYear()-1);}setTo(s){this.date.setFullYear(s.substr(-4));}toString(){let s=String(this.date.getFullYear()).padStart(4,"0");return this.token.length===2?s.substr(-2):s}}return Wr=t,Wr}var Hr,kn;function Pu(){return kn||(kn=1,Hr={DatePart:oe(),Meridiem:Ru(),Day:Iu(),Hours:Eu(),Milliseconds:Su(),Minutes:Cu(),Month:ku(),Seconds:$u(),Year:Tu()}),Hr}var zr,$n;function Au(){if($n)return zr;$n=1;let e=q(),t=we(),{style:r,clear:s,figures:i}=X(),{erase:n,cursor:o}=J(),{DatePart:c,Meridiem:a,Day:h,Hours:l,Milliseconds:u,Minutes:f,Month:d,Seconds:p,Year:m}=Pu(),g=/\\(.)|"((?:\\["\\]|[^"])+)"|(D[Do]?|d{3,4}|d)|(M{1,4})|(YY(?:YY)?)|([aA])|([Hh]{1,2})|(m{1,2})|(s{1,2})|(S{1,4})|./g,x={1:({token:v})=>v.replace(/\\(.)/g,"$1"),2:v=>new h(v),3:v=>new d(v),4:v=>new m(v),5:v=>new a(v),6:v=>new l(v),7:v=>new f(v),8:v=>new p(v),9:v=>new u(v)},y={months:"January,February,March,April,May,June,July,August,September,October,November,December".split(","),monthsShort:"Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec".split(","),weekdays:"Sunday,Monday,Tuesday,Wednesday,Thursday,Friday,Saturday".split(","),weekdaysShort:"Sun,Mon,Tue,Wed,Thu,Fri,Sat".split(",")};class w extends t{constructor(b={}){super(b),this.msg=b.message,this.cursor=0,this.typed="",this.locales=Object.assign(y,b.locales),this._date=b.initial||new Date,this.errorMsg=b.error||"Please Enter A Valid Value",this.validator=b.validate||(()=>true),this.mask=b.mask||"YYYY-MM-DD HH:mm:ss",this.clear=s("",this.out.columns),this.render();}get value(){return this.date}get date(){return this._date}set date(b){b&&this._date.setTime(b.getTime());}set mask(b){let I;for(this.parts=[];I=g.exec(b);){let $=I.shift(),k=I.findIndex(Q=>Q!=null);this.parts.push(k in x?x[k]({token:I[k]||$,date:this.date,parts:this.parts,locales:this.locales}):I[k]||$);}let T=this.parts.reduce(($,k)=>(typeof k=="string"&&typeof $[$.length-1]=="string"?$[$.length-1]+=k:$.push(k),$),[]);this.parts.splice(0),this.parts.push(...T),this.reset();}moveCursor(b){this.typed="",this.cursor=b,this.fire();}reset(){this.moveCursor(this.parts.findIndex(b=>b instanceof c)),this.fire(),this.render();}exit(){this.abort();}abort(){this.done=this.aborted=true,this.error=false,this.fire(),this.render(),this.out.write(`
|
|
60
|
+
`),this.close();}async validate(){let b=await this.validator(this.value);typeof b=="string"&&(this.errorMsg=b,b=false),this.error=!b;}async submit(){if(await this.validate(),this.error){this.color="red",this.fire(),this.render();return}this.done=true,this.aborted=false,this.fire(),this.render(),this.out.write(`
|
|
61
|
+
`),this.close();}up(){this.typed="",this.parts[this.cursor].up(),this.render();}down(){this.typed="",this.parts[this.cursor].down(),this.render();}left(){let b=this.parts[this.cursor].prev();if(b==null)return this.bell();this.moveCursor(this.parts.indexOf(b)),this.render();}right(){let b=this.parts[this.cursor].next();if(b==null)return this.bell();this.moveCursor(this.parts.indexOf(b)),this.render();}next(){let b=this.parts[this.cursor].next();this.moveCursor(b?this.parts.indexOf(b):this.parts.findIndex(I=>I instanceof c)),this.render();}_(b){/\d/.test(b)&&(this.typed+=b,this.parts[this.cursor].setTo(this.typed),this.render());}render(){this.closed||(this.firstRender?this.out.write(o.hide):this.out.write(s(this.outputText,this.out.columns)),super.render(),this.outputText=[r.symbol(this.done,this.aborted),e.bold(this.msg),r.delimiter(false),this.parts.reduce((b,I,T)=>b.concat(T===this.cursor&&!this.done?e.cyan().underline(I.toString()):I),[]).join("")].join(" "),this.error&&(this.outputText+=this.errorMsg.split(`
|
|
62
|
+
`).reduce((b,I,T)=>b+`
|
|
63
|
+
${T?" ":i.pointerSmall} ${e.red().italic(I)}`,"")),this.out.write(n.line+o.to(0)+this.outputText));}}return zr=w,zr}var Vr,Tn;function Ou(){if(Tn)return Vr;Tn=1;let e=q(),t=we(),{cursor:r,erase:s}=J(),{style:i,figures:n,clear:o,lines:c}=X(),a=/[0-9]/,h=f=>f!==void 0,l=(f,d)=>{let p=Math.pow(10,d);return Math.round(f*p)/p};class u extends t{constructor(d={}){super(d),this.transform=i.render(d.style),this.msg=d.message,this.initial=h(d.initial)?d.initial:"",this.float=!!d.float,this.round=d.round||2,this.inc=d.increment||1,this.min=h(d.min)?d.min:-1/0,this.max=h(d.max)?d.max:1/0,this.errorMsg=d.error||"Please Enter A Valid Value",this.validator=d.validate||(()=>true),this.color="cyan",this.value="",this.typed="",this.lastHit=0,this.render();}set value(d){!d&&d!==0?(this.placeholder=true,this.rendered=e.gray(this.transform.render(`${this.initial}`)),this._value=""):(this.placeholder=false,this.rendered=this.transform.render(`${l(d,this.round)}`),this._value=l(d,this.round)),this.fire();}get value(){return this._value}parse(d){return this.float?parseFloat(d):parseInt(d)}valid(d){return d==="-"||d==="."&&this.float||a.test(d)}reset(){this.typed="",this.value="",this.fire(),this.render();}exit(){this.abort();}abort(){let d=this.value;this.value=d!==""?d:this.initial,this.done=this.aborted=true,this.error=false,this.fire(),this.render(),this.out.write(`
|
|
64
|
+
`),this.close();}async validate(){let d=await this.validator(this.value);typeof d=="string"&&(this.errorMsg=d,d=false),this.error=!d;}async submit(){if(await this.validate(),this.error){this.color="red",this.fire(),this.render();return}let d=this.value;this.value=d!==""?d:this.initial,this.done=true,this.aborted=false,this.error=false,this.fire(),this.render(),this.out.write(`
|
|
65
|
+
`),this.close();}up(){if(this.typed="",this.value===""&&(this.value=this.min-this.inc),this.value>=this.max)return this.bell();this.value+=this.inc,this.color="cyan",this.fire(),this.render();}down(){if(this.typed="",this.value===""&&(this.value=this.min+this.inc),this.value<=this.min)return this.bell();this.value-=this.inc,this.color="cyan",this.fire(),this.render();}delete(){let d=this.value.toString();if(d.length===0)return this.bell();this.value=this.parse(d=d.slice(0,-1))||"",this.value!==""&&this.value<this.min&&(this.value=this.min),this.color="cyan",this.fire(),this.render();}next(){this.value=this.initial,this.fire(),this.render();}_(d,p){if(!this.valid(d))return this.bell();let m=Date.now();if(m-this.lastHit>1e3&&(this.typed=""),this.typed+=d,this.lastHit=m,this.color="cyan",d===".")return this.fire();this.value=Math.min(this.parse(this.typed),this.max),this.value>this.max&&(this.value=this.max),this.value<this.min&&(this.value=this.min),this.fire(),this.render();}render(){this.closed||(this.firstRender||(this.outputError&&this.out.write(r.down(c(this.outputError,this.out.columns)-1)+o(this.outputError,this.out.columns)),this.out.write(o(this.outputText,this.out.columns))),super.render(),this.outputError="",this.outputText=[i.symbol(this.done,this.aborted),e.bold(this.msg),i.delimiter(this.done),!this.done||!this.done&&!this.placeholder?e[this.color]().underline(this.rendered):this.rendered].join(" "),this.error&&(this.outputError+=this.errorMsg.split(`
|
|
66
|
+
`).reduce((d,p,m)=>d+`
|
|
67
|
+
${m?" ":n.pointerSmall} ${e.red().italic(p)}`,"")),this.out.write(s.line+r.to(0)+this.outputText+r.save+this.outputError+r.restore));}}return Vr=u,Vr}var Gr,Pn;function Zn(){if(Pn)return Gr;Pn=1;let e=q(),{cursor:t}=J(),r=we(),{clear:s,figures:i,style:n,wrap:o,entriesToDisplay:c}=X();class a extends r{constructor(l={}){super(l),this.msg=l.message,this.cursor=l.cursor||0,this.scrollIndex=l.cursor||0,this.hint=l.hint||"",this.warn=l.warn||"- This option is disabled -",this.minSelected=l.min,this.showMinError=false,this.maxChoices=l.max,this.instructions=l.instructions,this.optionsPerPage=l.optionsPerPage||10,this.value=l.choices.map((u,f)=>(typeof u=="string"&&(u={title:u,value:f}),{title:u&&(u.title||u.value||u),description:u&&u.description,value:u&&(u.value===void 0?f:u.value),selected:u&&u.selected,disabled:u&&u.disabled})),this.clear=s("",this.out.columns),l.overrideRender||this.render();}reset(){this.value.map(l=>!l.selected),this.cursor=0,this.fire(),this.render();}selected(){return this.value.filter(l=>l.selected)}exit(){this.abort();}abort(){this.done=this.aborted=true,this.fire(),this.render(),this.out.write(`
|
|
68
|
+
`),this.close();}submit(){let l=this.value.filter(u=>u.selected);this.minSelected&&l.length<this.minSelected?(this.showMinError=true,this.render()):(this.done=true,this.aborted=false,this.fire(),this.render(),this.out.write(`
|
|
69
|
+
`),this.close());}first(){this.cursor=0,this.render();}last(){this.cursor=this.value.length-1,this.render();}next(){this.cursor=(this.cursor+1)%this.value.length,this.render();}up(){this.cursor===0?this.cursor=this.value.length-1:this.cursor--,this.render();}down(){this.cursor===this.value.length-1?this.cursor=0:this.cursor++,this.render();}left(){this.value[this.cursor].selected=false,this.render();}right(){if(this.value.filter(l=>l.selected).length>=this.maxChoices)return this.bell();this.value[this.cursor].selected=true,this.render();}handleSpaceToggle(){let l=this.value[this.cursor];if(l.selected)l.selected=false,this.render();else {if(l.disabled||this.value.filter(u=>u.selected).length>=this.maxChoices)return this.bell();l.selected=true,this.render();}}toggleAll(){if(this.maxChoices!==void 0||this.value[this.cursor].disabled)return this.bell();let l=!this.value[this.cursor].selected;this.value.filter(u=>!u.disabled).forEach(u=>u.selected=l),this.render();}_(l,u){if(l===" ")this.handleSpaceToggle();else if(l==="a")this.toggleAll();else return this.bell()}renderInstructions(){return this.instructions===void 0||this.instructions?typeof this.instructions=="string"?this.instructions:`
|
|
70
|
+
Instructions:
|
|
71
|
+
${i.arrowUp}/${i.arrowDown}: Highlight option
|
|
72
|
+
${i.arrowLeft}/${i.arrowRight}/[space]: Toggle selection
|
|
73
|
+
`+(this.maxChoices===void 0?` a: Toggle all
|
|
74
|
+
`:"")+" enter/return: Complete answer":""}renderOption(l,u,f,d){let p=(u.selected?e.green(i.radioOn):i.radioOff)+" "+d+" ",m,g;return u.disabled?m=l===f?e.gray().underline(u.title):e.strikethrough().gray(u.title):(m=l===f?e.cyan().underline(u.title):u.title,l===f&&u.description&&(g=` - ${u.description}`,(p.length+m.length+g.length>=this.out.columns||u.description.split(/\r?\n/).length>1)&&(g=`
|
|
75
|
+
`+o(u.description,{margin:p.length,width:this.out.columns})))),p+m+e.gray(g||"")}paginateOptions(l){if(l.length===0)return e.red("No matches for this query.");let{startIndex:u,endIndex:f}=c(this.cursor,l.length,this.optionsPerPage),d,p=[];for(let m=u;m<f;m++)m===u&&u>0?d=i.arrowUp:m===f-1&&f<l.length?d=i.arrowDown:d=" ",p.push(this.renderOption(this.cursor,l[m],m,d));return `
|
|
76
|
+
`+p.join(`
|
|
77
|
+
`)}renderOptions(l){return this.done?"":this.paginateOptions(l)}renderDoneOrInstructions(){if(this.done)return this.value.filter(u=>u.selected).map(u=>u.title).join(", ");let l=[e.gray(this.hint),this.renderInstructions()];return this.value[this.cursor].disabled&&l.push(e.yellow(this.warn)),l.join(" ")}render(){if(this.closed)return;this.firstRender&&this.out.write(t.hide),super.render();let l=[n.symbol(this.done,this.aborted),e.bold(this.msg),n.delimiter(false),this.renderDoneOrInstructions()].join(" ");this.showMinError&&(l+=e.red(`You must select a minimum of ${this.minSelected} choices.`),this.showMinError=false),l+=this.renderOptions(this.value),this.out.write(this.clear+l),this.clear=s(l,this.out.columns);}}return Gr=a,Gr}var Ur,An;function ju(){if(An)return Ur;An=1;let e=q(),t=we(),{erase:r,cursor:s}=J(),{style:i,clear:n,figures:o,wrap:c,entriesToDisplay:a}=X(),h=(d,p)=>d[p]&&(d[p].value||d[p].title||d[p]),l=(d,p)=>d[p]&&(d[p].title||d[p].value||d[p]),u=(d,p)=>{let m=d.findIndex(g=>g.value===p||g.title===p);return m>-1?m:void 0};class f extends t{constructor(p={}){super(p),this.msg=p.message,this.suggest=p.suggest,this.choices=p.choices,this.initial=typeof p.initial=="number"?p.initial:u(p.choices,p.initial),this.select=this.initial||p.cursor||0,this.i18n={noMatches:p.noMatches||"no matches found"},this.fallback=p.fallback||this.initial,this.clearFirst=p.clearFirst||false,this.suggestions=[],this.input="",this.limit=p.limit||10,this.cursor=0,this.transform=i.render(p.style),this.scale=this.transform.scale,this.render=this.render.bind(this),this.complete=this.complete.bind(this),this.clear=n("",this.out.columns),this.complete(this.render),this.render();}set fallback(p){this._fb=Number.isSafeInteger(parseInt(p))?parseInt(p):p;}get fallback(){let p;return typeof this._fb=="number"?p=this.choices[this._fb]:typeof this._fb=="string"&&(p={title:this._fb}),p||this._fb||{title:this.i18n.noMatches}}moveSelect(p){this.select=p,this.suggestions.length>0?this.value=h(this.suggestions,p):this.value=this.fallback.value,this.fire();}async complete(p){let m=this.completing=this.suggest(this.input,this.choices),g=await m;if(this.completing!==m)return;this.suggestions=g.map((y,w,v)=>({title:l(v,w),value:h(v,w),description:y.description})),this.completing=false;let x=Math.max(g.length-1,0);this.moveSelect(Math.min(x,this.select)),p&&p();}reset(){this.input="",this.complete(()=>{this.moveSelect(this.initial!==void 0?this.initial:0),this.render();}),this.render();}exit(){this.clearFirst&&this.input.length>0?this.reset():(this.done=this.exited=true,this.aborted=false,this.fire(),this.render(),this.out.write(`
|
|
78
|
+
`),this.close());}abort(){this.done=this.aborted=true,this.exited=false,this.fire(),this.render(),this.out.write(`
|
|
79
|
+
`),this.close();}submit(){this.done=true,this.aborted=this.exited=false,this.fire(),this.render(),this.out.write(`
|
|
80
|
+
`),this.close();}_(p,m){let g=this.input.slice(0,this.cursor),x=this.input.slice(this.cursor);this.input=`${g}${p}${x}`,this.cursor=g.length+1,this.complete(this.render),this.render();}delete(){if(this.cursor===0)return this.bell();let p=this.input.slice(0,this.cursor-1),m=this.input.slice(this.cursor);this.input=`${p}${m}`,this.complete(this.render),this.cursor=this.cursor-1,this.render();}deleteForward(){if(this.cursor*this.scale>=this.rendered.length)return this.bell();let p=this.input.slice(0,this.cursor),m=this.input.slice(this.cursor+1);this.input=`${p}${m}`,this.complete(this.render),this.render();}first(){this.moveSelect(0),this.render();}last(){this.moveSelect(this.suggestions.length-1),this.render();}up(){this.select===0?this.moveSelect(this.suggestions.length-1):this.moveSelect(this.select-1),this.render();}down(){this.select===this.suggestions.length-1?this.moveSelect(0):this.moveSelect(this.select+1),this.render();}next(){this.select===this.suggestions.length-1?this.moveSelect(0):this.moveSelect(this.select+1),this.render();}nextPage(){this.moveSelect(Math.min(this.select+this.limit,this.suggestions.length-1)),this.render();}prevPage(){this.moveSelect(Math.max(this.select-this.limit,0)),this.render();}left(){if(this.cursor<=0)return this.bell();this.cursor=this.cursor-1,this.render();}right(){if(this.cursor*this.scale>=this.rendered.length)return this.bell();this.cursor=this.cursor+1,this.render();}renderOption(p,m,g,x){let y,w=g?o.arrowUp:x?o.arrowDown:" ",v=m?e.cyan().underline(p.title):p.title;return w=(m?e.cyan(o.pointer)+" ":" ")+w,p.description&&(y=` - ${p.description}`,(w.length+v.length+y.length>=this.out.columns||p.description.split(/\r?\n/).length>1)&&(y=`
|
|
81
|
+
`+c(p.description,{margin:3,width:this.out.columns}))),w+" "+v+e.gray(y||"")}render(){if(this.closed)return;this.firstRender?this.out.write(s.hide):this.out.write(n(this.outputText,this.out.columns)),super.render();let{startIndex:p,endIndex:m}=a(this.select,this.choices.length,this.limit);if(this.outputText=[i.symbol(this.done,this.aborted,this.exited),e.bold(this.msg),i.delimiter(this.completing),this.done&&this.suggestions[this.select]?this.suggestions[this.select].title:this.rendered=this.transform.render(this.input)].join(" "),!this.done){let g=this.suggestions.slice(p,m).map((x,y)=>this.renderOption(x,this.select===y+p,y===0&&p>0,y+p===m-1&&m<this.choices.length)).join(`
|
|
82
|
+
`);this.outputText+=`
|
|
83
|
+
`+(g||e.gray(this.fallback.title));}this.out.write(r.line+s.to(0)+this.outputText);}}return Ur=f,Ur}var Kr,On;function _u(){if(On)return Kr;On=1;let e=q(),{cursor:t}=J(),r=Zn(),{clear:s,style:i,figures:n}=X();class o extends r{constructor(a={}){a.overrideRender=true,super(a),this.inputValue="",this.clear=s("",this.out.columns),this.filteredOptions=this.value,this.render();}last(){this.cursor=this.filteredOptions.length-1,this.render();}next(){this.cursor=(this.cursor+1)%this.filteredOptions.length,this.render();}up(){this.cursor===0?this.cursor=this.filteredOptions.length-1:this.cursor--,this.render();}down(){this.cursor===this.filteredOptions.length-1?this.cursor=0:this.cursor++,this.render();}left(){this.filteredOptions[this.cursor].selected=false,this.render();}right(){if(this.value.filter(a=>a.selected).length>=this.maxChoices)return this.bell();this.filteredOptions[this.cursor].selected=true,this.render();}delete(){this.inputValue.length&&(this.inputValue=this.inputValue.substr(0,this.inputValue.length-1),this.updateFilteredOptions());}updateFilteredOptions(){let a=this.filteredOptions[this.cursor];this.filteredOptions=this.value.filter(l=>this.inputValue?!!(typeof l.title=="string"&&l.title.toLowerCase().includes(this.inputValue.toLowerCase())||typeof l.value=="string"&&l.value.toLowerCase().includes(this.inputValue.toLowerCase())):true);let h=this.filteredOptions.findIndex(l=>l===a);this.cursor=h<0?0:h,this.render();}handleSpaceToggle(){let a=this.filteredOptions[this.cursor];if(a.selected)a.selected=false,this.render();else {if(a.disabled||this.value.filter(h=>h.selected).length>=this.maxChoices)return this.bell();a.selected=true,this.render();}}handleInputChange(a){this.inputValue=this.inputValue+a,this.updateFilteredOptions();}_(a,h){a===" "?this.handleSpaceToggle():this.handleInputChange(a);}renderInstructions(){return this.instructions===void 0||this.instructions?typeof this.instructions=="string"?this.instructions:`
|
|
84
|
+
Instructions:
|
|
85
|
+
${n.arrowUp}/${n.arrowDown}: Highlight option
|
|
86
|
+
${n.arrowLeft}/${n.arrowRight}/[space]: Toggle selection
|
|
87
|
+
[a,b,c]/delete: Filter choices
|
|
88
|
+
enter/return: Complete answer
|
|
89
|
+
`:""}renderCurrentInput(){return `
|
|
90
|
+
Filtered results for: ${this.inputValue?this.inputValue:e.gray("Enter something to filter")}
|
|
91
|
+
`}renderOption(a,h,l,u){let f=(h.selected?e.green(n.radioOn):n.radioOff)+" "+u+" ",d;return h.disabled?d=a===l?e.gray().underline(h.title):e.strikethrough().gray(h.title):d=a===l?e.cyan().underline(h.title):h.title,f+d}renderDoneOrInstructions(){if(this.done)return this.value.filter(h=>h.selected).map(h=>h.title).join(", ");let a=[e.gray(this.hint),this.renderInstructions(),this.renderCurrentInput()];return this.filteredOptions.length&&this.filteredOptions[this.cursor].disabled&&a.push(e.yellow(this.warn)),a.join(" ")}render(){if(this.closed)return;this.firstRender&&this.out.write(t.hide),super.render();let a=[i.symbol(this.done,this.aborted),e.bold(this.msg),i.delimiter(false),this.renderDoneOrInstructions()].join(" ");this.showMinError&&(a+=e.red(`You must select a minimum of ${this.minSelected} choices.`),this.showMinError=false),a+=this.renderOptions(this.filteredOptions),this.out.write(this.clear+a),this.clear=s(a,this.out.columns);}}return Kr=o,Kr}var Br,jn;function Nu(){if(jn)return Br;jn=1;let e=q(),t=we(),{style:r,clear:s}=X(),{erase:i,cursor:n}=J();class o extends t{constructor(a={}){super(a),this.msg=a.message,this.value=a.initial,this.initialValue=!!a.initial,this.yesMsg=a.yes||"yes",this.yesOption=a.yesOption||"(Y/n)",this.noMsg=a.no||"no",this.noOption=a.noOption||"(y/N)",this.render();}reset(){this.value=this.initialValue,this.fire(),this.render();}exit(){this.abort();}abort(){this.done=this.aborted=true,this.fire(),this.render(),this.out.write(`
|
|
92
|
+
`),this.close();}submit(){this.value=this.value||false,this.done=true,this.aborted=false,this.fire(),this.render(),this.out.write(`
|
|
93
|
+
`),this.close();}_(a,h){return a.toLowerCase()==="y"?(this.value=true,this.submit()):a.toLowerCase()==="n"?(this.value=false,this.submit()):this.bell()}render(){this.closed||(this.firstRender?this.out.write(n.hide):this.out.write(s(this.outputText,this.out.columns)),super.render(),this.outputText=[r.symbol(this.done,this.aborted),e.bold(this.msg),r.delimiter(this.done),this.done?this.value?this.yesMsg:this.noMsg:e.gray(this.initialValue?this.yesOption:this.noOption)].join(" "),this.out.write(i.line+n.to(0)+this.outputText));}}return Br=o,Br}var qr,_n;function Mu(){return _n||(_n=1,qr={TextPrompt:xu(),SelectPrompt:vu(),TogglePrompt:bu(),DatePrompt:Au(),NumberPrompt:Ou(),MultiselectPrompt:Zn(),AutocompletePrompt:ju(),AutocompleteMultiselectPrompt:_u(),ConfirmPrompt:Nu()}),qr}var Nn;function Lu(){return Nn||(Nn=1,function(e){let t=e,r=Mu(),s=o=>o;function i(o,c,a={}){return new Promise((h,l)=>{let u=new r[o](c),f=a.onAbort||s,d=a.onSubmit||s,p=a.onExit||s;u.on("state",c.onState||s),u.on("submit",m=>h(d(m))),u.on("exit",m=>h(p(m))),u.on("abort",m=>l(f(m)));})}t.text=o=>i("TextPrompt",o),t.password=o=>(o.style="password",t.text(o)),t.invisible=o=>(o.style="invisible",t.text(o)),t.number=o=>i("NumberPrompt",o),t.date=o=>i("DatePrompt",o),t.confirm=o=>i("ConfirmPrompt",o),t.list=o=>{let c=o.separator||",";return i("TextPrompt",o,{onSubmit:a=>a.split(c).map(h=>h.trim())})},t.toggle=o=>i("TogglePrompt",o),t.select=o=>i("SelectPrompt",o),t.multiselect=o=>{o.choices=[].concat(o.choices||[]);let c=a=>a.filter(h=>h.selected).map(h=>h.value);return i("MultiselectPrompt",o,{onAbort:c,onSubmit:c})},t.autocompleteMultiselect=o=>{o.choices=[].concat(o.choices||[]);let c=a=>a.filter(h=>h.selected).map(h=>h.value);return i("AutocompleteMultiselectPrompt",o,{onAbort:c,onSubmit:c})};let n=(o,c)=>Promise.resolve(c.filter(a=>a.title.slice(0,o.length).toLowerCase()===o.toLowerCase()));t.autocomplete=o=>(o.suggest=o.suggest||n,o.choices=[].concat(o.choices||[]),i("AutocompletePrompt",o));}(gr)),gr}var Jr,Mn;function Fu(){if(Mn)return Jr;Mn=1;let e=Lu(),t=["suggest","format","onState","validate","onRender","type"],r=()=>{};async function s(c=[],{onSubmit:a=r,onCancel:h=r}={}){let l={},u=s._override||{};c=[].concat(c);let f,d,p,m,g,x,y=async(w,v,b=false)=>{if(!(!b&&w.validate&&w.validate(v)!==true))return w.format?await w.format(v,l):v};for(d of c)if({name:m,type:g}=d,typeof g=="function"&&(g=await g(f,{...l},d),d.type=g),!!g){for(let w in d){if(t.includes(w))continue;let v=d[w];d[w]=typeof v=="function"?await v(f,{...l},x):v;}if(x=d,typeof d.message!="string")throw new Error("prompt message is required");if({name:m,type:g}=d,e[g]===void 0)throw new Error(`prompt type (${g}) is not defined`);if(u[d.name]!==void 0&&(f=await y(d,u[d.name]),f!==void 0)){l[m]=f;continue}try{f=s._injected?i(s._injected,d.initial):await e[g](d),l[m]=f=await y(d,f,!0),p=await a(d,f,l);}catch{p=!await h(d,l);}if(p)return l}return l}function i(c,a){let h=c.shift();if(h instanceof Error)throw h;return h===void 0?a:h}function n(c){s._injected=(s._injected||[]).concat(c);}function o(c){s._override=Object.assign({},c);}return Jr=Object.assign(s,{prompt:s,prompts:e,inject:n,override:o}),Jr}var Yr,Ln;function Du(){return Ln||(Ln=1,Yr=Fu()),Yr}var Wu=Du(),Hu=rs(Wu),is=globalThis.window?.document!==void 0;globalThis.process?.versions?.node;globalThis.process?.versions?.bun;globalThis.Deno?.version?.deno;globalThis.process?.versions?.electron;globalThis.navigator?.userAgent?.includes("jsdom");typeof WorkerGlobalScope<"u"&&globalThis instanceof WorkerGlobalScope;typeof DedicatedWorkerGlobalScope<"u"&&globalThis instanceof DedicatedWorkerGlobalScope;typeof SharedWorkerGlobalScope<"u"&&globalThis instanceof SharedWorkerGlobalScope;typeof ServiceWorkerGlobalScope<"u"&&globalThis instanceof ServiceWorkerGlobalScope;var zt=globalThis.navigator?.userAgentData?.platform;zt==="macOS"||globalThis.navigator?.platform==="MacIntel"||globalThis.navigator?.userAgent?.includes(" Mac ")===true||globalThis.process?.platform;zt==="Windows"||globalThis.navigator?.platform==="Win32"||globalThis.process?.platform;zt==="Linux"||globalThis.navigator?.platform?.startsWith("Linux")===true||globalThis.navigator?.userAgent?.includes(" Linux ")===true||globalThis.process?.platform;zt==="Android"||globalThis.navigator?.platform==="Android"||globalThis.navigator?.userAgent?.includes(" Android ")===true||globalThis.process?.platform;var Fn="\x1B]",Dn="\x07",Ht=";";!is&&Z.env.TERM_PROGRAM;!is&&Z.platform;is||Z.cwd;var zu=(e,t)=>[Fn,"8",Ht,Ht,t,Dn,e,Fn,"8",Ht,Ht,Dn].join(""),Zr,Wn;function Xn(){return Wn||(Wn=1,Zr=(e,t=process.argv)=>{let r=e.startsWith("-")?"":e.length===1?"-":"--",s=t.indexOf(r+e),i=t.indexOf("--");return s!==-1&&(i===-1||s<i)}),Zr}var Xr,Hn;function Vu(){if(Hn)return Xr;Hn=1;let e=cu,t=lu,r=Xn(),{env:s}=process,i;r("no-color")||r("no-colors")||r("color=false")||r("color=never")?i=0:(r("color")||r("colors")||r("color=true")||r("color=always"))&&(i=1),"FORCE_COLOR"in s&&(s.FORCE_COLOR==="true"?i=1:s.FORCE_COLOR==="false"?i=0:i=s.FORCE_COLOR.length===0?1:Math.min(parseInt(s.FORCE_COLOR,10),3));function n(a){return a===0?false:{level:a,hasBasic:true,has256:a>=2,has16m:a>=3}}function o(a,h){if(i===0)return 0;if(r("color=16m")||r("color=full")||r("color=truecolor"))return 3;if(r("color=256"))return 2;if(a&&!h&&i===void 0)return 0;let l=i||0;if(s.TERM==="dumb")return l;if(process.platform==="win32"){let u=e.release().split(".");return Number(u[0])>=10&&Number(u[2])>=10586?Number(u[2])>=14931?3:2:1}if("CI"in s)return ["TRAVIS","CIRCLECI","APPVEYOR","GITLAB_CI","GITHUB_ACTIONS","BUILDKITE"].some(u=>u in s)||s.CI_NAME==="codeship"?1:l;if("TEAMCITY_VERSION"in s)return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(s.TEAMCITY_VERSION)?1:0;if(s.COLORTERM==="truecolor")return 3;if("TERM_PROGRAM"in s){let u=parseInt((s.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(s.TERM_PROGRAM){case "iTerm.app":return u>=3?3:2;case "Apple_Terminal":return 2}}return /-256(color)?$/i.test(s.TERM)?2:/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(s.TERM)||"COLORTERM"in s?1:l}function c(a){let h=o(a,a&&a.isTTY);return n(h)}return Xr={supportsColor:c,stdout:n(o(true,t.isatty(1))),stderr:n(o(true,t.isatty(2)))},Xr}var Qr,zn;function Gu(){if(zn)return Qr;zn=1;let e=Vu(),t=Xn();function r(i){if(/^\d{3,4}$/.test(i)){let o=/(\d{1,2})(\d{2})/.exec(i)||[];return {major:0,minor:parseInt(o[1],10),patch:parseInt(o[2],10)}}let n=(i||"").split(".").map(o=>parseInt(o,10));return {major:n[0],minor:n[1],patch:n[2]}}function s(i){let{CI:n,FORCE_HYPERLINK:o,NETLIFY:c,TEAMCITY_VERSION:a,TERM_PROGRAM:h,TERM_PROGRAM_VERSION:l,VTE_VERSION:u,TERM:f}=process.env;if(o)return !(o.length>0&&parseInt(o,10)===0);if(t("no-hyperlink")||t("no-hyperlinks")||t("hyperlink=false")||t("hyperlink=never"))return false;if(t("hyperlink=true")||t("hyperlink=always")||c)return true;if(!e.supportsColor(i)||i&&!i.isTTY)return false;if("WT_SESSION"in process.env)return true;if(process.platform==="win32"||n||a)return false;if(h){let d=r(l||"");switch(h){case "iTerm.app":return d.major===3?d.minor>=1:d.major>3;case "WezTerm":return d.major>=20200620;case "vscode":return d.major>1||d.major===1&&d.minor>=72;case "ghostty":return true}}if(u){if(u==="0.50.0")return false;let d=r(u);return d.major>0||d.minor>=50}switch(f){case "alacritty":return true}return false}return Qr={supportsHyperlink:s,stdout:s(process.stdout),stderr:s(process.stderr)},Qr}var Uu=Gu(),ns=rs(Uu);function it(e,t,{target:r="stdout",...s}={}){return ns[r]?zu(e,t):s.fallback===false?e:typeof s.fallback=="function"?s.fallback(e,t):`${e} (\u200B${t}\u200B)`}it.isSupported=ns.stdout;it.stderr=(e,t,r={})=>it(e,t,{target:"stderr",...r});it.stderr.isSupported=ns.stderr;var B={},Se={},Vn;function Ku(){if(Vn)return Se;Vn=1,Object.defineProperty(Se,"__esModule",{value:true}),Se.sync=Se.isexe=void 0;let e=qn,t=Yi__default,r=async(o,c={})=>{let{ignoreErrors:a=false}=c;try{return i(await(0,t.stat)(o),c)}catch(h){let l=h;if(a||l.code==="EACCES")return false;throw l}};Se.isexe=r;let s=(o,c={})=>{let{ignoreErrors:a=false}=c;try{return i((0,e.statSync)(o),c)}catch(h){let l=h;if(a||l.code==="EACCES")return false;throw l}};Se.sync=s;let i=(o,c)=>o.isFile()&&n(o,c),n=(o,c)=>{let a=c.uid??process.getuid?.(),h=c.groups??process.getgroups?.()??[],l=c.gid??process.getgid?.()??h[0];if(a===void 0||l===void 0)throw new Error("cannot get uid or gid");let u=new Set([l,...h]),f=o.mode,d=o.uid,p=o.gid,m=parseInt("100",8),g=parseInt("010",8),x=parseInt("001",8),y=m|g;return !!(f&x||f&g&&u.has(p)||f&m&&d===a||f&y&&a===0)};return Se}var Ce={},Gn;function Bu(){if(Gn)return Ce;Gn=1,Object.defineProperty(Ce,"__esModule",{value:true}),Ce.sync=Ce.isexe=void 0;let e=qn,t=Yi__default,r=async(o,c={})=>{let{ignoreErrors:a=false}=c;try{return n(await(0,t.stat)(o),o,c)}catch(h){let l=h;if(a||l.code==="EACCES")return false;throw l}};Ce.isexe=r;let s=(o,c={})=>{let{ignoreErrors:a=false}=c;try{return n((0,e.statSync)(o),o,c)}catch(h){let l=h;if(a||l.code==="EACCES")return false;throw l}};Ce.sync=s;let i=(o,c)=>{let{pathExt:a=process.env.PATHEXT||""}=c,h=a.split(";");if(h.indexOf("")!==-1)return true;for(let l=0;l<h.length;l++){let u=h[l].toLowerCase(),f=o.substring(o.length-u.length).toLowerCase();if(u&&f===u)return true}return false},n=(o,c,a)=>o.isFile()&&i(c,a);return Ce}var es={},Un;function qu(){return Un||(Un=1,Object.defineProperty(es,"__esModule",{value:true})),es}var Kn;function Ju(){return Kn||(Kn=1,function(e){var t=B&&B.__createBinding||(Object.create?function(h,l,u,f){f===void 0&&(f=u);var d=Object.getOwnPropertyDescriptor(l,u);(!d||("get"in d?!l.__esModule:d.writable||d.configurable))&&(d={enumerable:true,get:function(){return l[u]}}),Object.defineProperty(h,f,d);}:function(h,l,u,f){f===void 0&&(f=u),h[f]=l[u];}),r=B&&B.__setModuleDefault||(Object.create?function(h,l){Object.defineProperty(h,"default",{enumerable:true,value:l});}:function(h,l){h.default=l;}),s=B&&B.__importStar||function(h){if(h&&h.__esModule)return h;var l={};if(h!=null)for(var u in h)u!=="default"&&Object.prototype.hasOwnProperty.call(h,u)&&t(l,h,u);return r(l,h),l},i=B&&B.__exportStar||function(h,l){for(var u in h)u!=="default"&&!Object.prototype.hasOwnProperty.call(l,u)&&t(l,h,u);};Object.defineProperty(e,"__esModule",{value:true}),e.sync=e.isexe=e.posix=e.win32=void 0;let n=s(Ku());e.posix=n;let o=s(Bu());e.win32=o,i(qu(),e);let a=(process.env._ISEXE_TEST_PLATFORM_||process.platform)==="win32"?o:n;e.isexe=a.isexe,e.sync=a.sync;}(B)),B}var ts,Bn;function Yu(){if(Bn)return ts;Bn=1;let{isexe:e,sync:t}=Ju(),{join:r,delimiter:s,sep:i,posix:n}=R__default,o=process.platform==="win32",c=new RegExp(`[${n.sep}${i===n.sep?"":i}]`.replace(/(\\)/g,"\\$1")),a=new RegExp(`^\\.${c.source}`),h=p=>Object.assign(new Error(`not found: ${p}`),{code:"ENOENT"}),l=(p,{path:m=process.env.PATH,pathExt:g=process.env.PATHEXT,delimiter:x=s})=>{let y=p.match(c)?[""]:[...o?[process.cwd()]:[],...(m||"").split(x)];if(o){let w=g||[".EXE",".CMD",".BAT",".COM"].join(x),v=w.split(x).flatMap(b=>[b,b.toLowerCase()]);return p.includes(".")&&v[0]!==""&&v.unshift(""),{pathEnv:y,pathExt:v,pathExtExe:w}}return {pathEnv:y,pathExt:[""]}},u=(p,m)=>{let g=/^".*"$/.test(p)?p.slice(1,-1):p;return (!g&&a.test(m)?m.slice(0,2):"")+r(g,m)},f=async(p,m={})=>{let{pathEnv:g,pathExt:x,pathExtExe:y}=l(p,m),w=[];for(let v of g){let b=u(v,p);for(let I of x){let T=b+I;if(await e(T,{pathExt:y,ignoreErrors:true})){if(!m.all)return T;w.push(T);}}}if(m.all&&w.length)return w;if(m.nothrow)return null;throw h(p)},d=(p,m={})=>{let{pathEnv:g,pathExt:x,pathExtExe:y}=l(p,m),w=[];for(let v of g){let b=u(v,p);for(let I of x){let T=b+I;if(t(T,{pathExt:y,ignoreErrors:true})){if(!m.all)return T;w.push(T);}}}if(m.all&&w.length)return w;if(m.nothrow)return null;throw h(p)};return ts=f,f.sync=d,ts}var Zu=Yu(),Xu=rs(Zu);join(cu.tmpdir(),"antfu-ni");function Qn(e){return Xu.sync(e,{nothrow:true})!==null}async function os({autoInstall:e,programmatic:t,cwd:r}={}){let{name:s,agent:i,version:n}=await fr({cwd:r,onUnknown:o=>{t||console.warn("[ni] Unknown packageManager:",o);}})||{};if(s&&!Qn(s)&&!t){if(!e){console.warn(`[ni] Detected ${s} but it doesn't seem to be installed.
|
|
94
|
+
`),Z.env.CI&&Z.exit(1);let o=it(s,qi[s]),{tryInstall:c}=await Hu({name:"tryInstall",type:"confirm",message:`Would you like to globally install ${o}?`});c||Z.exit(1);}await pr("npm",["i","-g",`${s}${n?`@${n}`:""}`],{nodeOptions:{stdio:"inherit",cwd:r},throwOnError:true});}return i}Z.env.NI_CONFIG_FILE;var eh=Z.platform==="win32"?Z.env.USERPROFILE:Z.env.HOME;R__default.join(eh||"~/",".nirc");async function th(e,{withFallback:t}={withFallback:false}){let r=await os({programmatic:true,cwd:e});return r==="yarn@berry"?"yarn":r==="pnpm@6"?"pnpm":r==="bun"?"bun":r==="deno"?"deno":t?as()??"npm":r??"npm"}function as(e=process.env.npm_config_user_agent||""){return e.startsWith("yarn")?"yarn":e.startsWith("pnpm")?"pnpm":e.startsWith("bun")?"bun":e.startsWith("deno")?"deno":e.startsWith("npm")?"npm":null}function cs(e){return e==="pnpm"?"pnpm dlx":e==="bun"?"bunx":"npx"}async function Ly(e){let t=await th(e);return cs(t)}var eo={name:"shadcn",version:"4.10.0",description:"Add components to your apps.",publishConfig:{access:"public"},license:"MIT",author:{name:"shadcn",url:"https://twitter.com/shadcn"},repository:{type:"git",url:"https://github.com/shadcn-ui/ui.git",directory:"packages/shadcn"},files:["dist"],keywords:["components","ui","tailwind","radix-ui","base-ui","shadcn"],type:"module",exports:{".":{types:"./dist/index.d.ts",default:"./dist/index.js"},"./registry":{types:"./dist/registry/index.d.ts",default:"./dist/registry/index.js"},"./schema":{types:"./dist/schema/index.d.ts",default:"./dist/schema/index.js"},"./mcp":{types:"./dist/mcp/index.d.ts",default:"./dist/mcp/index.js"},"./utils":{types:"./dist/utils/index.d.ts",default:"./dist/utils/index.js"},"./icons":{types:"./dist/icons/index.d.ts",default:"./dist/icons/index.js"},"./preset":{types:"./dist/preset/index.d.ts",default:"./dist/preset/index.js"},"./tailwind.css":{style:"./dist/tailwind.css"}},bin:"./dist/index.js",scripts:{dev:"tsup --watch",build:"tsup",typecheck:"tsc --noEmit",clean:"rimraf dist && rimraf components","start:dev":"cross-env REGISTRY_URL=http://localhost:4000/r SHADCN_TEMPLATE_DIR=../../templates node dist/index.js","start:prod":"cross-env REGISTRY_URL=https://ui.shadcn.com/r node dist/index.js",start:"node dist/index.js","format:write":'prettier --write "**/*.{ts,tsx,mdx}" --cache',"format:check":'prettier --check "**/*.{ts,tsx,mdx}" --cache',release:"changeset version","pub:beta":"pnpm build && pnpm publish --no-git-checks --access public --tag beta","pub:rc":"pnpm build && pnpm publish --no-git-checks --access public --tag rc","pub:next":"pnpm build && pnpm publish --no-git-checks --access public --tag next","pub:release":"pnpm build && pnpm publish --access public",test:"vitest run","test:dev":"REGISTRY_URL=http://localhost:4000/r SHADCN_TEMPLATE_DIR=../../templates vitest run","mcp:inspect":"pnpm dlx @modelcontextprotocol/inspector node dist/index.js mcp"},dependencies:{"@babel/core":"^7.28.0","@babel/parser":"^7.28.0","@babel/plugin-transform-typescript":"^7.28.0","@babel/preset-typescript":"^7.27.1","@dotenvx/dotenvx":"^1.48.4","@modelcontextprotocol/sdk":"^1.26.0","@types/validate-npm-package-name":"^4.0.2",browserslist:"^4.26.2",commander:"^14.0.0",cosmiconfig:"^9.0.0",dedent:"^1.6.0",deepmerge:"^4.3.1",diff:"^8.0.2",execa:"^9.6.0","fast-glob":"^3.3.3","fs-extra":"^11.3.1",fuzzysort:"^3.1.0","https-proxy-agent":"^7.0.6",kleur:"^4.1.5",msw:"^2.10.4","node-fetch":"^3.3.2",open:"^11.0.0",ora:"^8.2.0",postcss:"^8.5.6","postcss-selector-parser":"^7.1.0",prompts:"^2.4.2",recast:"^0.23.11","stringify-object":"^5.0.0","tailwind-merge":"^3.0.1","ts-morph":"^26.0.0","tsconfig-paths":"^4.2.0","validate-npm-package-name":"^7.0.1",zod:"^3.24.1","zod-to-json-schema":"^3.24.6"},devDependencies:{"@antfu/ni":"^25.0.0","@types/babel__core":"^7.20.5","@types/fs-extra":"^11.0.4","@types/prompts":"^2.4.9","@types/stringify-object":"^4.0.5",rimraf:"^6.0.1",tsup:"^8.5.0","type-fest":"^4.41.0",typescript:"^5.9.2"}};function Le(e){if(C.break(),C.error("Something went wrong. Please check the error below for more details."),C.error("If the problem persists, please open an issue on GitHub."),C.error(""),typeof e=="string"&&(C.error(e),nt()),e instanceof j&&(e.message&&(C.error(e.cause?"Error:":"Message:"),C.error(e.message)),e.cause&&(C.error(`
|
|
95
|
+
Message:`),C.error(e.cause)),e.suggestion&&(C.error(`
|
|
96
|
+
Suggestion:`),C.error(e.suggestion)),nt()),e instanceof z.ZodError){C.error("Validation failed:");for(let[t,r]of Object.entries(e.flatten().fieldErrors))C.error(`- ${P.info(t)}: ${r}`);nt();}e instanceof Error&&(C.error(e.message),nt()),nt();}function ih(e){let t=e.match(/^(\d+)\.(\d+)\.\d+/);if(!t)return null;let r=Number.parseInt(t[1],10),s=Number.parseInt(t[2],10);return s===0?null:`${r}.${s-1}.0`}function nh(e=eo.version,t=process.argv.slice(2)){let r=ih(e);return r?[...cs(as()).split(" "),`shadcn@${r}`,...t].map(oh).join(" "):null}function nt(){let e=nh();e&&(C.error(""),C.error("You can also try a previous version to see if that works:"),C.error(e)),C.break(),process.exit(1);}function oh(e){return /^[a-zA-Z0-9_./:@%+=,-]+$/.test(e)?e:`'${e.replace(/'/g,"'\\''")}'`}async function ls(e,t){let{config:r,useCache:s}=t||{};if(_(e)){let[a]=await L([e],{useCache:s});return to(e,a)}let i=Ye(e);if(i)return Di(i,{useCache:s});if(!e.startsWith("@"))throw new ze(e);let n=e;n.endsWith("/registry")||(n=`${n}/registry`);let o=Oe(n,Ae(r));if(!o?.url)throw new ve(n);o.headers&&Object.keys(o.headers).length>0&&Qe({[o.url]:o.headers});let[c]=await L([o.url],{useCache:s});return to(n,c)}function to(e,t){try{let r=p.parse(t);if(r.include?.length)throw new S(`Registry catalog "${e}" uses "include", but consumer registry endpoints must serve a resolved registry catalog. Run "npx shadcn build" and serve the built registry.json, or use loadRegistry() in a dynamic route.`,{context:{registry:e,include:r.include},suggestion:"Serve a flattened registry.json for CLI consumers. Source registry.json files with include are supported by shadcn build and loadRegistry()."});return r}catch(r){throw r instanceof S?r:new M(e,r,{subject:"registry catalog",suggestion:"The registry catalog may be corrupted or have an invalid format. Please make sure it returns a valid registry.json object. See https://ui.shadcn.com/schema/registry.json."})}}async function ch(e,t){let{config:r,useCache:s=false}=t||{};return et(),me(e,Ae(r),{useCache:s})}async function lh(e,t){let{config:r,useCache:s=false}=t||{};return et(),Bi(e,Ae(r),{useCache:s})}async function hw(e,t){let{useCache:r=true}=t||{};r||bt.clearCaches();let s=await bt.search(e);if(!s)return {registries:G};let i=z.object({registries:b$1.optional()}).safeParse(s.config);if(!i.success)throw new pt(e,i.error);return {registries:{...G,...i.data.registries||{}}}}async function It(){try{let[e]=await L(["index.json"]);return q$1.parse(e)}catch(e){C.error(`
|
|
97
|
+
`),Le(e);}}async function dw(){try{let[e]=await L(["styles/index.json"]);return r.parse(e)}catch(e){return C.error(`
|
|
98
|
+
`),Le(e),[]}}async function fw(){try{let[e]=await L(["icons/index.json"]);return s.parse(e)}catch(e){return Le(e),{}}}async function pw(){return Ps}async function Nt(e){try{let[t$1]=await L([`colors/${e}.json`]);return t.parse(t$1)}catch(t){Le(t);}}async function uh(e,t){let r=[];for(let s of t){let i=e.find(n=>n.name===s);if(i&&(r.push(i),i.registryDependencies)){let n=await uh(e,i.registryDependencies);r.push(...n);}}return r.filter((s,i,n)=>n.findIndex(o=>o.name===s.name)===i)}async function mw(e,t){try{let r=t.map(i=>`styles/${e}/${i.name}.json`);return (await L(r)).map(i=>n.parse(i))}catch(r){return Le(r),[]}}async function gw(e,t,r){if(r)return r;if(t.type==="registry:ui")return e.resolvedPaths.ui??e.resolvedPaths.components;let[s,i]=t.type?.split(":")??[];return s in e.resolvedPaths?R__default.join(e.resolvedPaths[s],i):null}async function so(e){e={useCache:true,...e};let t=`${xe}/registries.json`,[r]=await L([t],{useCache:e.useCache});try{return y.parse(r)}catch(s){throw s instanceof z.ZodError?new Ve(s):s}}async function hh(e){let t=await so(e);return t?Object.fromEntries(t.map(r=>[r.name,r.url])):null}async function dh(e){e={useCache:true,...e};let t=`${xe}/config.json`,[r]=await L([t],{useCache:e.useCache});return A.parse(r).presets}async function yw(e,t){return (await dh(t)).find(s=>s.name.toLowerCase()===e.toLowerCase())??null}async function ph(e,t){let{query:r,limit:s,offset:i,config:n,useCache:o}=t||{},c=[];for(let f of e){let p=((await ls(f,{config:n,useCache:o})).items||[]).map(m=>({name:m.name,type:m.type,description:m.description,registry:f,addCommandArgument:wh(m.name,f)}));c=c.concat(p);}r&&(c=gh(c,{query:r,limit:c.length,keys:["name","description"]}));let a=i||0,h=s||c.length,l=c.length,u={pagination:{total:l,offset:a,limit:h,hasMore:a+h<l},items:c.slice(a,a+h)};return w.parse(u)}var mh=z.object({name:z.string(),type:z.string().optional(),description:z.string().optional(),registry:z.string().optional(),addCommandArgument:z.string().optional()}).passthrough();function gh(e,t){t={limit:100,threshold:-1e4,...t};let s=fh.go(t.query,e,{keys:t.keys,threshold:t.threshold,limit:t.limit}).map(i=>i.obj);return z.array(mh).parse(s)}function yh(e){try{return new URL(e),!0}catch{return false}}function wh(e,t){let r=Ye(t);if(r){let d=`${r.owner}/${r.repo}/${e}`;return r.ref?`${d}#${r.ref}`:d}if(!yh(t))return `${t}/${e}`;let s=t.indexOf("://")+3,i=t.indexOf("/",s);if(i===-1){let d=t.indexOf("?",s);if(d!==-1){let p=t.substring(0,d),g=t.substring(d).replace(/\bregistry\b/g,e);return p+g}return t}let n=t.substring(0,i),o=t.substring(i),c=o.indexOf("?")!==-1?o.indexOf("?"):o.length,a=o.substring(0,c),h=o.substring(c),l=a.lastIndexOf("registry"),u=a;l!==-1&&(u=a.substring(0,l)+e+a.substring(l+8));let f=h.replace(/\bregistry\b/g,e);return n+u+f}var us=32;async function xh(e){let{cwd:t,registryFile:r}=fo(e),s=await no(r,{cwd:t}),i=po(s,t,r);return bh(s,i,t)}async function vh(e,t){let{cwd:r,registryFile:s}=fo(t),i=await no(s,{cwd:r}),n=i.registry.items.find(c=>c.name===e);if(!n)throw new be(e);let o=po(i,r,s);return Rh(n,i,o,r)}async function no(e,t){let r=R.resolve(t.cwd,e),s=await lo(r),i=uo(s,r);io(i,r);let n={cwd:R.resolve(t.cwd),itemSources:new Map,itemSourcesByItem:new Map,firstIncludedFrom:new Map},o=!!i.include?.length;if(!o)return i.items.forEach((l,u)=>{let f={registryFile:r,registryDir:n.cwd,itemIndex:u};n.itemSources.set(l.name,f),n.itemSourcesByItem.set(l,f);}),{registry:i,itemSources:n.itemSources,itemSourcesByItem:n.itemSourcesByItem,usesInclude:o};if(R.basename(r)!=="registry.json")throw new S(`Invalid registry file at ${r}: registries that use include must be named registry.json.`,{registryFile:r});let c=await co(r,i,n,[]);$h(c.items,n.itemSourcesByItem);let{include:a,...h}=c;return io(h,r),{registry:h,itemSources:n.itemSources,itemSourcesByItem:n.itemSourcesByItem,usesInclude:o}}function bh(e,t,r){return {...e.registry,items:e.registry.items.map(s=>Eh(oo(s,e.itemSourcesByItem,t,r)))}}async function Rh(e,t,r,s){let i={...oo(e,t.itemSourcesByItem,r,s),$schema:"https://ui.shadcn.com/schema/registry-item.json"};return await Promise.all((e.files??[]).map(async(n,o)=>{let c=i.files?.[o];if(!c)return;let a=t.itemSourcesByItem.get(e),h=ao(e,n.path,t.itemSourcesByItem,s);c.content=await Ih(e.name,n.path,h,a);})),n.parse(i)}async function Ih(e,t,r,s){try{return await Yi.readFile(r,"utf-8")}catch(i){throw new ee(r,i,{message:`Failed to read file "${t}" for registry item "${e}" (${ot(s)}). Expected file at ${r}.`,context:{itemName:e,itemFilePath:t,sourcePath:r},suggestion:"Make sure the file path is relative to the registry.json file that declares the item."})}}function oo(e,t,r,s){return {...e,files:e.files?.map(i=>({...i,path:Sh(e,i.path,t,r,s)}))}}function Eh(e){return {...e,files:e.files?.map(({content:t,...r})=>r)}}function ao(e,t,r,s){let i=r.get(e);return R.resolve(i?.registryDir??s,t)}function Sh(e,t,r,s,i){let n=ao(e,t,r,i);return R.relative(s,n).split(R.sep).join("/")}async function co(e,t,r,s){if(ho(e,r.cwd),s.length>=us)throw new S(`Registry include tree is too deep at ${e}. The maximum include depth is ${us}.`,{registryFile:e,context:{maxDepth:us},suggestion:"Flatten part of the registry include tree or reduce nested include depth."});if(s.includes(e))throw new S(Th([...s,e]),{registryFile:e});let i=s.at(-1)??e,n=r.firstIncludedFrom.get(e);if(n)throw new S(`Registry file included more than once: ${e}.
|
|
99
|
+
- first included from ${n}
|
|
100
|
+
- included again from ${i}
|
|
101
|
+
Each registry.json file can only appear once in the resolved include tree. Remove one include or move shared items into a single included registry.json.`,{registryFile:e,context:{firstSource:n,secondSource:i}});r.firstIncludedFrom.set(e,i);let o=[...s,e],c=R.dirname(e),a=[];for(let h of t.include??[]){let l=Ch(h,c,r.cwd,e),u=await lo(l),f=uo(u,l),d=await co(l,f,r,o);a.push(...d.items);}return t.items.forEach((h,l)=>{kh(h,e,c),r.itemSources.set(h.name,{registryFile:e,registryDir:c,itemIndex:l}),r.itemSourcesByItem.set(h,{registryFile:e,registryDir:c,itemIndex:l});}),{...t,items:[...a,...t.items]}}async function lo(e){try{return await Yi.readFile(e,"utf-8")}catch(t){throw new ee(e,t,{message:`Failed to read registry file at ${e}.`,context:{registryFile:e},suggestion:"Check that the registry.json file exists and that the path is correct."})}}function uo(e,t){let r;try{r=JSON.parse(e);}catch(i){throw new M(t,i,{subject:"registry file",context:{registryFile:t},suggestion:"Fix the JSON syntax in the registry.json file and try again."})}let s=o.safeParse(r);if(!s.success)throw new S(`Invalid registry file at ${t}:
|
|
102
|
+
${Ph(s.error)}`,{registryFile:t,cause:s.error,suggestion:"Update the registry.json file so it matches the registry schema."});return s.data}function io(e,t){let r=[];if(e.name||r.push("name"),e.homepage||r.push("homepage"),r.length)throw new S(`Invalid root registry file at ${t}: root registry.json must define ${r.map(s=>`"${s}"`).join(" and ")}. Included registry.json files may omit these fields.`,{registryFile:t})}function Ch(e,t,r,s){if(_(e))throw new S(`Invalid include "${e}" in ${s}: remote includes are not supported by shadcn build. Use a relative path to a registry.json file in the same repository.`,{registryFile:s,context:{includePath:e}});if(R.isAbsolute(e))throw new S(`Invalid include "${e}" in ${s}: include paths must be relative. Use a path like "./registry/ui/registry.json".`,{registryFile:s,context:{includePath:e}});if(mo(e))throw new S(`Invalid include "${e}" in ${s}: include paths cannot use parent-directory traversal. Keep included registry.json files inside the registry root.`,{registryFile:s,context:{includePath:e}});if(R.basename(e)!=="registry.json")throw new S(`Invalid include "${e}" in ${s}: include paths must explicitly reference a registry.json file. Use a path like "./registry/ui/registry.json".`,{registryFile:s,context:{includePath:e}});let i=R.resolve(t,e);return ho(i,r),i}function ho(e,t){if(!go(e,t))throw new S(`Invalid registry file at ${e}: registry includes must stay inside ${t}.`,{registryFile:e,context:{cwd:t}})}function fo(e){return {cwd:R.resolve(e?.cwd??process.cwd()),registryFile:e?.registryFile??"registry.json"}}function po(e,t,r){return e.usesInclude?R.dirname(R.resolve(t,r)):t}function kh(e,t,r){for(let s of e.files??[]){if(_(s.path))throw new S(`Invalid file path "${s.path}" for item "${e.name}" in ${t}: remote file paths are not supported by shadcn build.`,{registryFile:t,context:{itemName:e.name,filePath:s.path}});if(R.isAbsolute(s.path))throw new S(`Invalid file path "${s.path}" for item "${e.name}" in ${t}: file paths must be relative.`,{registryFile:t,context:{itemName:e.name,filePath:s.path}});if(mo(s.path))throw new S(`Invalid file path "${s.path}" for item "${e.name}" in ${t}: file paths cannot use parent-directory traversal.`,{registryFile:t,context:{itemName:e.name,filePath:s.path}});let i=R.resolve(r,s.path);if(!go(i,r))throw new S(`Invalid file path "${s.path}" for item "${e.name}" in ${t}: file paths must stay inside the registry chunk directory.`,{registryFile:t,context:{itemName:e.name,filePath:s.path}})}}function $h(e,t){let r=new Map;for(let s of e){let i=r.get(s.name);if(!i){r.set(s.name,s);continue}let n=t.get(i),o=t.get(s);throw new S(`Duplicate registry item name "${s.name}". Registry item names must be unique.
|
|
103
|
+
- ${ot(n)}
|
|
104
|
+
- ${ot(o)}
|
|
105
|
+
Rename one of these items so each name is unique across the resolved registry.`,{context:{itemName:s.name,firstSource:ot(n),secondSource:ot(o)}})}}function mo(e){return e.split(/[\\/]+/).includes("..")}function go(e,t){let r=R.relative(t,e);return !!r&&!r.startsWith("..")&&!R.isAbsolute(r)}function Th(e){return `Registry include cycle detected:
|
|
106
|
+
${e.map(t=>` - ${t}`).join(`
|
|
107
|
+
`)}`}function ot(e){return e?`${e.registryFile} items[${e.itemIndex}]`:"unknown source"}function Ph(e){return e.errors.map(t=>` - ${t.path.length?t.path.join("."):"(root)"}: ${t.message}`).join(`
|
|
108
|
+
`)}export{Yo as $,Re as A,gw as Aa,Vs as B,so as Ba,Gs as C,hh as Ca,Us as D,dh as Da,Ie as E,yw as Ea,kt as F,re as Fa,Tt as G,qd as Ga,At as H,Ct as Ha,Ot as I,Jd as Ia,Zs as J,xh as Ja,Xs as K,vh as Ka,yp as L,no as La,jt as M,bh as Ma,_t as N,Rh as Na,Ga as O,ph as Oa,ni as P,_ as Q,Op as R,Ye as S,$d as T,Td as U,Pd as V,Ad as W,bt as X,qe as Y,Rt as Z,Od as _,F as a,Xo as aa,G as b,jd as ba,Ah as c,Fs as ca,P as d,Ae as da,C as e,et as ea,sd as f,Qp as fa,id as g,Oe as ga,nd as h,jm as ha,Ao as i,Bm as ia,N as j,me as ja,j as k,Bi as ka,ve as l,th as la,Fe as m,Ly as ma,De as n,eo as na,We as o,Le as oa,ae as p,ls as pa,ee as q,ch as qa,M as r,lh as ra,S as s,hw as sa,be as t,It as ta,He as u,dw as ua,ze as v,fw as va,Ve as w,pw as wa,ce as x,Nt as xa,le as y,uh as ya,Hs as z,mw as za};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {Oa,qa,k,ma,sa}from'./chunk-MKTVVRV2.js';import {Server}from'@modelcontextprotocol/sdk/server/index.js';import {ListToolsRequestSchema,CallToolRequestSchema}from'@modelcontextprotocol/sdk/types.js';import a from'dedent';import {z}from'zod';import {zodToJsonSchema}from'zod-to-json-schema';var S="shadcn@latest";async function p(n){return `${await ma(process.cwd())} ${S} ${n}`}async function f(n=process.cwd()){return {registries:(await sa(n,{useCache:false})).registries}}function y(n,t){let{query:r,registries:i}=t||{},s=n.items.map(c=>{let u=[`- ${c.name}`];return c.type&&u.push(`(${c.type})`),c.description&&u.push(`- ${c.description}`),c.registry&&u.push(`[${c.registry}]`),u.push(`
|
|
2
2
|
Add command: \`${p(`add ${c.addCommandArgument}`)}\``),u.join(" ")}),o=`Found ${n.pagination.total} items`;r&&(o+=` matching "${r}"`),i&&i.length>0&&(o+=` in registries ${i.join(", ")}`),o+=":";let m=`Showing items ${n.pagination.offset+1}-${Math.min(n.pagination.offset+n.pagination.limit,n.pagination.total)} of ${n.pagination.total}:`,d=`${o}
|
|
3
3
|
|
|
4
4
|
${m}
|
|
@@ -34,7 +34,7 @@ Found ${n.length} example${n.length>1?"s":""} matching "${t}":
|
|
|
34
34
|
|
|
35
35
|
To fix this:
|
|
36
36
|
1. Use the \`init\` command to create a components.json file
|
|
37
|
-
2. Or manually create components.json with a registries section`}]}}case "search_items_in_registries":{let r=z.object({registries:z.array(z.string()),query:z.string(),limit:z.number().optional(),offset:z.number().optional()}).parse(n.params.arguments),i=await
|
|
37
|
+
2. Or manually create components.json with a registries section`}]}}case "search_items_in_registries":{let r=z.object({registries:z.array(z.string()),query:z.string(),limit:z.number().optional(),offset:z.number().optional()}).parse(n.params.arguments),i=await Oa(r.registries,{query:r.query,limit:r.limit,offset:r.offset,config:await f(process.cwd()),useCache:!1});return i.items.length===0?{content:[{type:"text",text:a`No items found matching "${r.query}" in registries ${r.registries.join(", ")}, Try searching with a different query or registry.`}]}:{content:[{type:"text",text:y(i,{query:r.query,registries:r.registries})}]}}case "list_items_in_registries":{let r=z.object({registries:z.array(z.string()),limit:z.number().optional(),offset:z.number().optional(),cwd:z.string().optional()}).parse(n.params.arguments),i=await Oa(r.registries,{limit:r.limit,offset:r.offset,config:await f(process.cwd()),useCache:!1});return i.items.length===0?{content:[{type:"text",text:a`No items found in registries ${r.registries.join(", ")}.`}]}:{content:[{type:"text",text:y(i,{registries:r.registries})}]}}case "view_items_in_registries":{let r=z.object({items:z.array(z.string())}).parse(n.params.arguments),i=await qa(r.items,{config:await f(process.cwd()),useCache:!1});if(i?.length===0)return {content:[{type:"text",text:a`No items found for: ${r.items.join(", ")}
|
|
38
38
|
|
|
39
39
|
Make sure the item names are correct and include the registry prefix (e.g., @shadcn/button).`}]};let s=$(i);return {content:[{type:"text",text:a`Item Details:
|
|
40
40
|
|
|
@@ -42,7 +42,7 @@ Found ${n.length} example${n.length>1?"s":""} matching "${t}":
|
|
|
42
42
|
|
|
43
43
|
---
|
|
44
44
|
|
|
45
|
-
`)}`}]}}case "get_item_examples_from_registries":{let r=z.object({query:z.string(),registries:z.array(z.string())}).parse(n.params.arguments),i=await f(),s=await
|
|
45
|
+
`)}`}]}}case "get_item_examples_from_registries":{let r=z.object({query:z.string(),registries:z.array(z.string())}).parse(n.params.arguments),i=await f(),s=await Oa(r.registries,{query:r.query,config:i,useCache:!1});if(s.items.length===0)return {content:[{type:"text",text:a`No examples found for query "${r.query}".
|
|
46
46
|
|
|
47
47
|
Try searching with patterns like:
|
|
48
48
|
- "accordion-demo" for accordion examples
|
|
@@ -51,7 +51,7 @@ Found ${n.length} example${n.length>1?"s":""} matching "${t}":
|
|
|
51
51
|
|
|
52
52
|
You can also:
|
|
53
53
|
1. Use search_items_in_registries to find all items matching your query
|
|
54
|
-
2. View the main component with view_items_in_registries for inline usage documentation`}]};let o=s.items.map(d=>d.addCommandArgument),m=await
|
|
54
|
+
2. View the main component with view_items_in_registries for inline usage documentation`}]};let o=s.items.map(d=>d.addCommandArgument),m=await qa(o,{config:i,useCache:!1});return {content:[{type:"text",text:b(m,r.query)}]}}case "get_add_command_for_items":{let t=z.object({items:z.array(z.string())}).parse(n.params.arguments);return {content:[{type:"text",text:await p(`add ${t.items.join(" ")}`)}]}}case "get_audit_checklist":return {content:[{type:"text",text:a`## Component Audit Checklist
|
|
55
55
|
|
|
56
56
|
After adding or generating components, check the following common issues:
|
|
57
57
|
|