shadcn 4.6.0 → 4.8.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.
@@ -1 +1 @@
1
- export{z as configJsonSchema,d as configSchema,r as iconsSchema,y as presetSchema,c as rawConfigSchema,w as registriesIndexSchema,x as registriesSchema,s as registryBaseColorSchema,a as registryConfigItemSchema,b as registryConfigSchema,p as registryIndexSchema,m as registryItemCommonSchema,j as registryItemCssSchema,i as registryItemCssVarsSchema,k as registryItemEnvVarsSchema,g as registryItemFileSchema,l as registryItemFontSchema,n as registryItemSchema,h as registryItemTailwindSchema,f as registryItemTypeSchema,t as registryResolvedItemsTreeSchema,o as registrySchema,u as searchResultItemSchema,v as searchResultsSchema,q as stylesSchema,e as workspaceConfigSchema}from'../chunk-HW2MEAJZ.js';
1
+ export{A as configJsonSchema,d as configSchema,s as iconsSchema,z as presetSchema,c as rawConfigSchema,x as registriesIndexSchema,y as registriesSchema,t as registryBaseColorSchema,o as registryChunkSchema,a as registryConfigItemSchema,b as registryConfigSchema,q as registryIndexSchema,m as registryItemCommonSchema,j as registryItemCssSchema,i as registryItemCssVarsSchema,k as registryItemEnvVarsSchema,g as registryItemFileSchema,l as registryItemFontSchema,n as registryItemSchema,h as registryItemTailwindSchema,f as registryItemTypeSchema,u as registryResolvedItemsTreeSchema,p as registrySchema,v as searchResultItemSchema,w as searchResultsSchema,r as stylesSchema,e as workspaceConfigSchema}from'../chunk-3ORLOMOE.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "shadcn",
3
- "version": "4.6.0",
3
+ "version": "4.8.0",
4
4
  "description": "Add components to your apps.",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -1,33 +0,0 @@
1
- import {m,l,f,d as d$1,c as c$1,e,n,t,o,b as b$1,p,q as q$1,r,s,x,z as z$1,v as v$1,g as g$1}from'./chunk-HW2MEAJZ.js';import {a,d,c,b,g,f as f$1}from'./chunk-WLJDV6SE.js';import y,{basename}from'path';import {z}from'zod';import {promises,existsSync,statSync}from'fs';import {green,cyan,yellow,red}from'kleur/colors';import {loadConfig,createMatchPath}from'tsconfig-paths';import {cosmiconfig}from'cosmiconfig';import Ke from'fast-glob';import ne from'fs-extra';import {tmpdir,homedir}from'os';import Kr from'ora';import {Project,SyntaxKind,ScriptKind,QuoteKind}from'ts-morph';import {transformFromAstSync}from'@babel/core';import {parse}from'@babel/parser';import Ur from'@babel/plugin-transform-typescript';import*as We from'recast';import is from'prompts';import pe from'deepmerge';import {HttpsProxyAgent}from'https-proxy-agent';import js,{Headers}from'node-fetch';import {createHash}from'crypto';import Ns from'stringify-object';import tn from'fuzzysort';var H=process.env.REGISTRY_URL??"https://ui.shadcn.com/r",k=H.replace(/\/r\/?$/,""),Ae="new-york-v4",kt=[{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"}],N={"@shadcn":`${H}/styles/{style}/{name}.json`};var ln=[{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."}];function ge(e){return e.replace(/\${(\w+)}/g,(t,r)=>process.env[r]||"")}function de(e){let t=[],r=/\${(\w+)}/g,s;for(;(s=r.exec(e))!==null;)t.push(s[1]);return t}var A={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"},I=class extends Error{code;statusCode;context;suggestion;timestamp;cause;constructor(t,r={}){super(t),this.name="RegistryError",this.code=r.code||A.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}}},J=class extends I{constructor(r,s){let n=`The item at ${r} was not found. It may not exist at the registry.`;super(n,{code:A.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";}},Oe=class extends I{constructor(r,s){let n=`The item at ${r} is no longer available. It may have been removed or expired.`;super(n,{code:A.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";}},ue=class extends I{constructor(r,s){let n=`You are not authorized to access the item at ${r}. If this is a remote registry, you may need to authenticate.`;super(n,{code:A.UNAUTHORIZED,statusCode:401,cause:s,context:{url:r},suggestion:"Check your authentication credentials and environment variables."});this.url=r;this.name="RegistryUnauthorizedError";}},he=class extends I{constructor(r,s){let n=`You are not authorized to access the item at ${r}. If this is a remote registry, you may need to authenticate.`;super(n,{code:A.FORBIDDEN,statusCode:403,cause:s,context:{url:r},suggestion:"Check your authentication credentials and environment variables."});this.url=r;this.name="RegistryForbiddenError";}},ye=class extends I{constructor(r,s,n,i){let o=s?`Failed to fetch from registry (${s}): ${r}`:`Failed to fetch from registry: ${r}`,a=typeof i=="string"&&i?`${o} - ${i}`:o,l="Check your network connection and try again.";s===404?l="The requested resource was not found. Check the URL or item name.":s===500?l="The registry server encountered an error. Try again later.":s&&s>=400&&s<500&&(l="There was a client error. Check your request parameters.");super(a,{code:A.FETCH_ERROR,statusCode:s,cause:i,context:{url:r,responseBody:n},suggestion:l});this.url=r;this.responseBody=n;this.name="RegistryFetchError";}},W=class extends I{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:A.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";}},te=class extends I{constructor(r,s){super(`Failed to read local registry file: ${r}`,{code:A.LOCAL_FILE_ERROR,cause:s,context:{filePath:r},suggestion:"Check if the file exists and you have read permissions."});this.filePath=r;this.name="RegistryLocalFileError";}},$=class extends I{constructor(r,s){let n=`Failed to parse registry item: ${r}`;s instanceof z.ZodError&&(n=`Failed to parse registry item: ${r}
7
- ${s.errors.map(i=>` - ${i.path.join(".")}: ${i.message}`).join(`
8
- `)}`);super(n,{code:A.PARSE_ERROR,cause:s,context:{item:r},suggestion:`The registry item may be corrupted or have an invalid format. Please make sure it returns a valid JSON object. See ${k}/schema/registry-item.json.`});this.item=r;this.parseError=s,this.name="RegistryParseError";}parseError},xe=class extends I{constructor(r,s){let n=`Registry "${r}" requires the following environment variables:
9
-
10
- `+s.map(i=>` \u2022 ${i}`).join(`
11
- `);super(n,{code:A.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";}},we=class extends I{constructor(r){let s=`Invalid registry namespace: "${r}". Registry names must start with @ (e.g., @shadcn, @v0).`;super(s,{code:A.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 Ne=class extends I{constructor(r,s){let n=`Invalid components.json configuration in ${r}.`;s instanceof z.ZodError&&(n=`Invalid components.json configuration in ${r}:
12
- ${s.errors.map(i=>` - ${i.path.join(".")}: ${i.message}`).join(`
13
- `)}`);super(n,{code:A.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";}},Ee=class extends I{parseError;constructor(t){let r="Failed to parse registries index";if(t instanceof z.ZodError){let s=t.errors.filter(n=>n.path.length>0).map(n=>`"${n.path[0]}"`).filter((n,i,o)=>o.indexOf(n)===i);s.length>0?r=`Failed to parse registries index. Invalid registry namespace(s): ${s.join(", ")}
14
- ${t.errors.map(n=>` - ${n.path.join(".")}: ${n.message}`).join(`
15
- `)}`:r=`Failed to parse registries index:
16
- ${t.errors.map(n=>` - ${n.path.join(".")}: ${n.message}`).join(`
17
- `)}`;}super(r,{code:A.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 ur=/^(@[a-zA-Z0-9](?:[a-zA-Z0-9-_]*[a-zA-Z0-9])?)\/(.+)$/;function re(e){if(!e.startsWith("@"))return {registry:null,item:e};let t=e.match(ur);return t?{registry:t[1],item:t[2]}:{registry:null,item:e}}var O={"next-app":{name:"next-app",label:"Next.js",links:{installation:`${k}/docs/installation/next`,tailwind:"https://tailwindcss.com/docs/guides/nextjs"}},"next-pages":{name:"next-pages",label:"Next.js",links:{installation:`${k}/docs/installation/next`,tailwind:"https://tailwindcss.com/docs/guides/nextjs"}},remix:{name:"remix",label:"Remix",links:{installation:`${k}/docs/installation/remix`,tailwind:"https://tailwindcss.com/docs/guides/remix"}},"react-router":{name:"react-router",label:"React Router",links:{installation:`${k}/docs/installation/react-router`,tailwind:"https://tailwindcss.com/docs/installation/framework-guides/react-router"}},vite:{name:"vite",label:"Vite",links:{installation:`${k}/docs/installation/vite`,tailwind:"https://tailwindcss.com/docs/guides/vite"}},astro:{name:"astro",label:"Astro",links:{installation:`${k}/docs/installation/astro`,tailwind:"https://tailwindcss.com/docs/guides/astro"}},laravel:{name:"laravel",label:"Laravel",links:{installation:`${k}/docs/installation/laravel`,tailwind:"https://tailwindcss.com/docs/guides/laravel"}},"tanstack-start":{name:"tanstack-start",label:"TanStack Start",links:{installation:`${k}/docs/installation/tanstack`,tailwind:"https://tailwindcss.com/docs/installation/using-postcss"}},gatsby:{name:"gatsby",label:"Gatsby",links:{installation:`${k}/docs/installation/gatsby`,tailwind:"https://tailwindcss.com/docs/guides/gatsby"}},expo:{name:"expo",label:"Expo",links:{installation:`${k}/docs/installation/expo`,tailwind:"https://www.nativewind.dev/docs/getting-started/installation"}},manual:{name:"manual",label:"Manual",links:{installation:`${k}/docs/installation/manual`,tailwind:"https://tailwindcss.com/docs/installation"}}};var T={error:red,warn:yellow,info:cyan,success:green};async function F(e,t){return createMatchPath(t.absoluteBaseUrl,t.paths)(e,void 0,()=>true,[".ts",".tsx",".jsx",".js",".css"])}var kn="@/components",$n="@/lib/utils",An="app/globals.css",On="tailwind.config.js";var Fe=cosmiconfig("components",{searchPlaces:["components.json"]});async function ve(e){let t=await Sr(e);return t?(t.iconLibrary||(t.iconLibrary=t.style==="new-york"?"radix":"lucide"),await Le(e,t)):null}async function Le(e,t){t.registries={...N,...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());return d$1.parse({...t,resolvedPaths:{cwd:e,tailwindConfig:t.tailwind.config?y.resolve(e,t.tailwind.config):"",tailwindCss:y.resolve(e,t.tailwind.css),utils:await F(t.aliases.utils,r),components:await F(t.aliases.components,r),ui:t.aliases.ui?await F(t.aliases.ui,r):y.resolve(await F(t.aliases.components,r)??e,"ui"),lib:t.aliases.lib?await F(t.aliases.lib,r):y.resolve(await F(t.aliases.utils,r)??e,".."),hooks:t.aliases.hooks?await F(t.aliases.hooks,r):y.resolve(await F(t.aliases.components,r)??e,"..","hooks")}})}async function Sr(e){try{let t=await Fe.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 N)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 ${T.info(r)}.`)}}async function Nn(e$1){let t={};for(let s of Object.keys(e$1.aliases)){if(!Ir(s,e$1))continue;let n=e$1.resolvedPaths[s],i=await br(e$1.resolvedPaths.cwd,n);if(!i){t[s]=e$1;continue}t[s]=await ve(i);}let r=e.safeParse(t);return r.success?r.data:null}async function br(e,t){let r=Tr(e,t),s=y.relative(r,t),i=(await Ke.glob("**/package.json",{cwd:r,deep:3,ignore:["**/node_modules/**","**/dist/**","**/build/**","**/public/**"]})).map(o=>y.dirname(o)).find(o=>s.startsWith(o));return i?y.join(r,i):null}function Ir(e,t){return Object.keys(t.resolvedPaths).filter(r=>r!=="utils").includes(e)}function Tr(e,t){let r=e.split(y.sep),s=t.split(y.sep),n=[];for(let i=0;i<Math.min(r.length,s.length)&&r[i]===s[i];i++)n.push(r[i]);return n.join(y.sep)}async function $t(e,t){return (await _(e))?.tailwindVersion==="v4"?"new-york-v4":t}function Fn(e){return e?.startsWith("base-")?"base":"radix"}function At(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:{...N}};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}function tt(e="",t=true){let r=y.join(e,"package.json");return ne.readJSONSync(r,{throws:t})}var _e=["**/node_modules/**",".next","public","dist","build"];z.object({compilerOptions:z.object({paths:z.record(z.string().or(z.array(z.string())))})});async function _(e,t){let[r,s,n,i,o,a,l,c]=await Promise.all([Ke.glob("**/{next,vite,astro,app}.config.*|gatsby-config.*|composer.json|react-router.config.*",{cwd:e,deep:3,ignore:_e}),ne.pathExists(y.resolve(e,"src")),Lr(e),Nr(e),Or(e,t?.configCssFile),Ot(e),Fr(e),tt(e,false)]),f=await ne.pathExists(y.resolve(e,`${s?"src/":""}app`)),p={framework:O.manual,isSrcDir:s,isRSC:false,isTsx:n,tailwindConfigFile:i,tailwindCssFile:o,tailwindVersion:a,frameworkVersion:null,aliasPrefix:l};if(r.find(d=>d.startsWith("next.config."))?.length)return p.framework=f?O["next-app"]:O["next-pages"],p.isRSC=f,p.frameworkVersion=await Ar(p.framework,c),p;if(r.find(d=>d.startsWith("astro.config."))?.length)return p.framework=O.astro,p;if(r.find(d=>d.startsWith("gatsby-config."))?.length)return p.framework=O.gatsby,p;if(r.find(d=>d.startsWith("composer.json"))?.length)return p.framework=O.laravel,p;if(Object.keys(c?.dependencies??{}).find(d=>d.startsWith("@remix-run/")))return p.framework=O.remix,p;if([...Object.keys(c?.dependencies??{}),...Object.keys(c?.devDependencies??{})].find(d=>d.startsWith("@tanstack/react-start")))return p.framework=O["tanstack-start"],p;if(r.find(d=>d.startsWith("react-router.config."))?.length)return p.framework=O["react-router"],p;if(r.find(d=>d.startsWith("vite.config."))?.length)return p.framework=O.vite,p;let x=r.find(d=>d.startsWith("app.config"));return x?.length&&(await ne.readFile(y.resolve(e,x),"utf8")).includes("defineConfig")?(p.framework=O.vite,p):(c?.dependencies?.expo&&(p.framework=O.expo),p)}async function Ar(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 n=r.match(/(\d+\.\d+\.\d+)/);return n?n[1]:r}async function Ot(e){let[t,r]=await Promise.all([tt(e,false),ve(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 Or(e,t){if(t){let i=y.resolve(e,t);if(await ne.pathExists(i))return t}let[r,s]=await Promise.all([Ke.glob(["**/*.css","**/*.scss"],{cwd:e,deep:5,ignore:_e}),Ot(e)]);if(!r.length)return null;for(let i of r){let o=await ne.readFile(y.resolve(e,i),"utf8");if(o.includes('@import "tailwindcss"')||o.includes("@import 'tailwindcss'")||o.includes("@tailwind base"))return i}return null}async function Nr(e){let t=await Ke.glob("tailwind.config.*",{cwd:e,deep:3,ignore:_e});return t.length?t[0]:null}async function Fr(e){let t=await loadConfig(e);if(t?.resultType==="failed"||!Object.entries(t?.paths).length)return null;for(let[r,s]of Object.entries(t.paths))if(s.includes("./*")||s.includes("./src/*")||s.includes("./app/*")||s.includes("./resources/js/*"))return r.replace(/\/\*$/,"")??null;return Object.keys(t?.paths)?.[0].replace(/\/\*$/,"")??null}async function Lr(e){return (await Ke.glob("tsconfig.*",{cwd:e,deep:1,ignore:_e})).length>0}async function Xn(e,t=null){let[r,s]=await Promise.all([ve(e),t?Promise.resolve(t):_(e)]);if(r)return r;if(!s||!s.tailwindCssFile||s.tailwindVersion==="v3"&&!s.tailwindConfigFile)return null;let n={$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:{components:`${s.aliasPrefix}/components`,ui:`${s.aliasPrefix}/components/ui`,hooks:`${s.aliasPrefix}/hooks`,lib:`${s.aliasPrefix}/lib`,utils:`${s.aliasPrefix}/lib/utils`}};return await Le(e,n)}async function ze(e){if(!e.resolvedPaths?.cwd)return "v3";let t=await _(e.resolvedPaths.cwd);return t?.tailwindVersion?t.tailwindVersion:null}async function ei(e){let t=await ve(e);if(!t)return [];let s=(await Le(e,t)).resolvedPaths.ui;if(!ne.existsSync(s))return [];let n=await De(),i=new Set(n?.map(a=>a.name)??[]);return (await promises.readdir(s)).filter(a=>/\.(tsx|jsx)$/.test(a)).map(a=>y.basename(a,y.extname(a))).filter(a=>i.has(a))}function Nt(e,t,r={}){let{ignoreImports:s=false}=r,n=e.replace(/\r\n/g,`
18
- `).trim(),i=t.replace(/\r\n/g,`
19
- `).trim();if(n===i)return true;if(!s)return false;let o=/^(import\s+(?:type\s+)?(?:\*\s+as\s+\w+|\{[^}]*\}|\w+)?(?:\s*,\s*(?:\{[^}]*\}|\w+))?\s+from\s+["'])([^"']+)(["'])/gm,a=f=>f.replace(o,(p,x,d,h)=>{if(d.startsWith("."))return `${x}${d}${h}`;let w=d.split("/"),g=w[w.length-1];return `${x}@normalized/${g}${h}`}),l=a(n),c=a(i);return l===c}function q(e){let t=y.basename(e);return /^\.env(\.|$)/.test(t)}function Lt(e){let t=[".env.local",".env",".env.development.local",".env.development"];for(let r of t){let s=y.join(e,r);if(existsSync(s))return s}return null}function ie(e){let t=e.split(`
20
- `),r={};for(let s of t){let n=s.trim();if(!n||n.startsWith("#"))continue;let i=n.indexOf("=");if(i===-1)continue;let o=n.substring(0,i).trim(),a=n.substring(i+1).trim();o&&(r[o]=a.replace(/^["']|["']$/g,""));}return r}function Dt(e,t){let r=ie(e),s=ie(t),n=[];for(let i of Object.keys(s))i in r||n.push(i);return n}function Kt(e,t){let r=ie(e),s=ie(t),n=e.trimEnd();n&&!n.endsWith(`
21
- `)&&(n+=`
22
- `);let i=[];for(let[o,a]of Object.entries(s))o in r||i.push(`${o}=${a}`);return i.length>0?(n&&(n+=`
23
- `),n+=i.join(`
24
- `),n+`
25
- `):n&&!n.endsWith(`
26
- `)?n+`
27
- `:n}var v={error(...e){console.log(T.error(e.join(" ")));},warn(...e){console.log(T.warn(e.join(" ")));},info(...e){console.log(T.info(e.join(" ")));},success(...e){console.log(T.success(e.join(" ")));},log(...e){console.log(e.join(" "));},break(){console.log("");}};function Y(e,t){return Kr({text:e,isSilent:t?.silent})}var Ve=async({sourceFile:e,config:t,isRemote:r})=>{let s=t.aliases?.utils,i=`${typeof s=="string"&&s.includes("/")?s.split("/")[0]:"@"}/lib/utils`;if(![".tsx",".ts",".jsx",".js"].includes(e.getExtension()))return e;for(let o of e.getImportStringLiterals()){let a=zr(o.getLiteralValue(),t,r);if(o.setLiteralValue(a),i===a||a==="@/lib/utils"){if(!o.getFirstAncestorByKind(SyntaxKind.ImportDeclaration)?.getNamedImports().some(f=>f.getName()==="cn")||!t.aliases.utils)continue;o.setLiteralValue(i===a?a.replace(i,t.aliases.utils):t.aliases.utils);}}return e};function zr(e,t,r=false){if(!e.startsWith("@/")&&!r)return e;if(r&&e.startsWith("@/")&&(e=e.replace(/^@\//,"@/registry/new-york/")),!e.startsWith("@/registry/")){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.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)}var Mr={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"]},_t=async({sourceFile:e,config:t})=>{let r=e.getFullText();if(t.tsx)return r;let s=We.parse(r,{parser:{parse:i=>parse(i,Mr)}}),n=transformFromAstSync(s,r,{cloneInputAst:false,code:false,ast:true,plugins:[Ur],configFile:false});if(!n||!n.ast)throw new Error("Failed to transform JSX");return We.print(n.ast).code};var Hr=/^["']use client["']$/g,Ue=async({sourceFile:e,config:t})=>{if(t.rsc)return e;let r=e.getFirstChildByKind(SyntaxKind.ExpressionStatement);return r&&Hr.test(r.getText())&&r.remove(),e};var Jr=new Set(["cn-font-heading"]),Gr=/\bcn-[a-z-]+\b/;function zt(e){return Gr.test(e)&&!Jr.has(e)}function Vt(e){return e.split(/\s+/).filter(t=>t.length>0&&!zt(t)).join(" ")}function Wt(e){return e.split(/\s+/).some(zt)}function Me(e){let t=e.getLiteralValue();if(!Wt(t))return;let r=Vt(t);r!==t&&e.setLiteralValue(r);}function rt(e){for(let t of e.getDescendantsOfKind(SyntaxKind.StringLiteral))Me(t);for(let t of e.getDescendantsOfKind(SyntaxKind.NoSubstitutionTemplateLiteral))Me(t);}function qr(e){let t=[];for(let r of e.getDescendantsOfKind(SyntaxKind.JsxAttribute)){let s=r.getNameNode().getText();if(s!=="className"&&s!=="classNames")continue;let n=r.getInitializer();if(n?.isKind(SyntaxKind.StringLiteral)){let i=n.getLiteralValue();if(Wt(i)){let o=Vt(i);o===""?t.push(r):o!==i&&n.setLiteralValue(o);}}n?.isKind(SyntaxKind.JsxExpression)&&rt(n);}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)){Me(s);continue}if(s.isKind(SyntaxKind.NoSubstitutionTemplateLiteral)){Me(s);continue}rt(s);}for(let r of e.getDescendantsOfKind(SyntaxKind.CallExpression))r.getExpression().getText()==="mergeProps"&&rt(r);}var Be=async({sourceFile:e})=>(qr(e),e);var He=async({sourceFile:e,config:t})=>{if(!t.tailwind?.prefix)return e;let r=await ze(t);return e.getDescendantsOfKind(SyntaxKind.CallExpression).filter(s=>s.getExpression().getText()==="cva").forEach(s=>{if(s.getArguments()[0]?.isKind(SyntaxKind.StringLiteral)){let n=s.getArguments()[0];n&&n.replaceWithText(`"${U(n.getText()?.replace(/"|'/g,""),t.tailwind.prefix,r)}"`);}s.getArguments()[1]?.isKind(SyntaxKind.ObjectLiteralExpression)&&s.getArguments()[1]?.getDescendantsOfKind(SyntaxKind.PropertyAssignment).find(n=>n.getName()==="variants")?.getDescendantsOfKind(SyntaxKind.PropertyAssignment).forEach(n=>{n.getDescendantsOfKind(SyntaxKind.PropertyAssignment).forEach(i=>{let o=i.getInitializerIfKind(SyntaxKind.StringLiteral);o&&o?.replaceWithText(`"${U(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 n=s.getInitializer();n&&n.replaceWithText(`"${U(n.getText()?.replace(/"|'/g,""),t.tailwind.prefix,r)}"`);}if(s.getInitializer()?.isKind(SyntaxKind.JsxExpression)){let n=s.getInitializer()?.getDescendantsOfKind(SyntaxKind.CallExpression).find(i=>i.getExpression().getText()==="cn");n&&n.getArguments().forEach(i=>{(i.isKind(SyntaxKind.ConditionalExpression)||i.isKind(SyntaxKind.BinaryExpression))&&i.getChildrenOfKind(SyntaxKind.StringLiteral).forEach(o=>{o.replaceWithText(`"${U(o.getText()?.replace(/"|'/g,""),t.tailwind.prefix,r)}"`);}),i.isKind(SyntaxKind.StringLiteral)&&i.replaceWithText(`"${U(i.getText()?.replace(/"|'/g,""),t.tailwind.prefix,r)}"`);});}}s.getNameNode().getText()==="classNames"&&s.getInitializer()?.isKind(SyntaxKind.JsxExpression)&&s.getDescendantsOfKind(SyntaxKind.PropertyAssignment).forEach(n=>{if(n.getInitializer()?.isKind(SyntaxKind.CallExpression)){let i=n.getInitializerIfKind(SyntaxKind.CallExpression);i&&i.getArguments().forEach(o=>{o.isKind(SyntaxKind.ConditionalExpression)&&o.getChildrenOfKind(SyntaxKind.StringLiteral).forEach(a=>{a.replaceWithText(`"${U(a.getText()?.replace(/"|'/g,""),t.tailwind.prefix,r)}"`);}),o.isKind(SyntaxKind.StringLiteral)&&o.replaceWithText(`"${U(o.getText()?.replace(/"|'/g,""),t.tailwind.prefix,r)}"`);});}if(n.getInitializer()?.isKind(SyntaxKind.StringLiteral)&&n.getNameNode().getText()!=="variant"){let i=n.getInitializer();i&&i.replaceWithText(`"${U(i.getText()?.replace(/"|'/g,""),t.tailwind.prefix,r)}"`);}});}),e};function U(e,t="",r){return r==="v3"?e.split(" ").map(s=>{let[n,i,o]=b(s);return n?o?`${n}:${t}${i}/${o}`:`${n}:${t}${i}`:o?`${t}${i}/${o}`:`${t}${i}`}).join(" "):e.split(" ").map(s=>s.indexOf(`${t}:`)===0?s:`${t}:${s.trim()}`).join(" ")}var es=new Project({compilerOptions:{}});async function ts(e){let t=await promises.mkdtemp(y.join(tmpdir(),"shadcn-"));return y.join(t,e)}async function Mt(e,t=[Ve,Ue,a,He,d,c,Be]){let r=await ts(e.filename),s=es.createSourceFile(r,e.raw,{scriptKind:ScriptKind.TSX});for(let n of t)await n({sourceFile:s,...e});return e.transformJsx?await _t({sourceFile:s,...e}):s.getText()}var rs=["a","span","div","Link","label","Label"],Bt=async({sourceFile:e,config:t})=>{if(!t.style?.startsWith("base-"))return e;let r=10;for(let s=0;s<r;s++){let i=e.getDescendantsOfKind(SyntaxKind.JsxElement).filter(l=>l.getOpeningElement().getAttribute("asChild"));if(i.length===0)break;let o=i.filter(l=>!l.getDescendantsOfKind(SyntaxKind.JsxElement).some(f=>f.getOpeningElement().getAttribute("asChild"))),a=[];for(let l of o){let c=l.getOpeningElement(),f=c.getAttribute("asChild");if(!f)continue;let p=c.getTagNameNode().getText(),d=l.getJsxChildren().find(m=>m.getKind()===SyntaxKind.JsxElement||m.getKind()===SyntaxKind.JsxSelfClosingElement);if(!d){f.remove();continue}let h,w,g;if(d.getKind()===SyntaxKind.JsxSelfClosingElement){let m=d.asKindOrThrow(SyntaxKind.JsxSelfClosingElement);h=m.getTagNameNode().getText(),w=m.getAttributes().map(E=>E.getText()).join(" "),g="";}else {let m=d.asKindOrThrow(SyntaxKind.JsxElement),E=m.getOpeningElement();h=E.getTagNameNode().getText(),w=E.getAttributes().map(b=>b.getText()).join(" "),g=m.getJsxChildren().map(b=>b.getText()).join("");}let j=p==="Button"&&rs.includes(h);a.push({parentElement:l,parentTagName:p,childTagName:h,childProps:w,childChildren:g,needsNativeButton:j});}for(let l of a.reverse()){let f=l.parentElement.getOpeningElement().getAttributes().filter(w=>w.getKind()===SyntaxKind.JsxAttribute?w.asKindOrThrow(SyntaxKind.JsxAttribute).getNameNode().getText()!=="asChild":true).map(w=>w.getText()).join(" "),p=l.childProps?`{<${l.childTagName} ${l.childProps} />}`:`{<${l.childTagName} />}`,x=f?`${f} `:"";x+=`render=${p}`,l.needsNativeButton&&(x+=" nativeButton={false}");let d=l.childChildren.trim()?`${l.childChildren}`:"",h=`<${l.parentTagName} ${x}>${d}</${l.parentTagName}>`;l.parentElement.replaceWithText(h);}}return e};var Ht=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);async function Co(e,t,r){if(!e?.length)return {filesCreated:[],filesUpdated:[],filesSkipped:[]};r={overwrite:false,force:false,silent:false,isRemote:false,isWorkspace:false,...r};let s=Y("Updating files.",{silent:r.silent})?.start(),[n,i]=await Promise.all([_(t.resolvedPaths.cwd),t.tailwind.baseColor?Je(t.tailwind.baseColor):Promise.resolve(void 0)]),o=[],a$1=[],l=[],c$1=[],f=null;for(let h=0;h<e.length;h++){let w=e[h];if(!w.content)continue;let g$1=nt(w,t,{isSrcDir:n?.isSrcDir,framework:n?.framework.name,commonRoot:it(e.map(R=>R.path),w.path),path:r.path,fileIndex:h});if(!g$1)continue;let j=basename(w.path),m=y.dirname(g$1);if(t.tsx||(g$1=g$1.replace(/\.tsx?$/,R=>R===".tsx"?".jsx":".js")),q(g$1)&&!existsSync(g$1)){let R=Lt(m);R&&(g$1=R);}let E=existsSync(g$1);if(w.type==="registry:lib"&&basename(w.path)==="utils.ts"&&n?.framework.name==="laravel"&&E){l.push(y.relative(t.resolvedPaths.cwd,g$1));continue}if(E&&statSync(g$1).isDirectory())throw new Error(`Cannot write to ${g$1}: path exists and is a directory. Please provide a file path instead.`);let b=w.type==="registry:file"||w.type==="registry:item",S=q(g$1)||b?w.content:await Mt({filename:w.path,raw:w.content,config:t,baseColor:i,transformJsx:!t.tsx,isRemote:r.isRemote,supportedFontMarkers:r.supportedFontMarkers},[Ve,Ue,a,He,c,g,Bt,d,...Jt(g$1,n,t)?[Ht]:[],f$1,Be]);if(E&&!q(g$1)){let R=await promises.readFile(g$1,"utf-8");if(Nt(R,S,{ignoreImports:r.isWorkspace})){l.push(y.relative(t.resolvedPaths.cwd,g$1));continue}}if(E&&!r.overwrite&&!q(g$1)){s.stop(),r.rootSpinner&&r.rootSpinner.stop();let{overwrite:R}=await is({type:"confirm",name:"overwrite",message:`The file ${T.info(j)} already exists. Would you like to overwrite?`,initial:false});if(!R){l.push(y.relative(t.resolvedPaths.cwd,g$1)),r.rootSpinner&&r.rootSpinner.start();continue}s?.start(),r.rootSpinner&&r.rootSpinner.start();}if(Jt(g$1,n,t)&&(g$1=g$1.replace(/middleware\.(ts|js)$/,"proxy.$1")),existsSync(m)||await promises.mkdir(m,{recursive:true}),q(g$1)&&E){let R=await promises.readFile(g$1,"utf-8"),X=Kt(R,S);if(c$1=Dt(R,S),f=y.relative(t.resolvedPaths.cwd,g$1),!c$1.length){l.push(y.relative(t.resolvedPaths.cwd,g$1));continue}await promises.writeFile(g$1,X,"utf-8"),a$1.push(y.relative(t.resolvedPaths.cwd,g$1));continue}await promises.writeFile(g$1,S,"utf-8"),E?a$1.push(y.relative(t.resolvedPaths.cwd,g$1)):(o.push(y.relative(t.resolvedPaths.cwd,g$1)),q(g$1)&&(c$1=Object.keys(ie(S)),f=y.relative(t.resolvedPaths.cwd,g$1)));}let p=[...o,...a$1,...l],x=await ms(p,t);if(a$1.push(...x),o=Array.from(new Set(o)),a$1=Array.from(new Set(a$1.filter(h=>!o.includes(h)))),l=Array.from(new Set(l)),!(o.length||a$1.length)&&!l.length&&s?.info("No files updated."),o.length){if(s?.succeed(`Created ${o.length} ${o.length===1?"file":"files"}:`),!r.silent)for(let h of o)v.log(` - ${h}`);}else s?.stop();if(a$1.length&&(Y(`Updated ${a$1.length} ${a$1.length===1?"file":"files"}:`,{silent:r.silent})?.info(),!r.silent))for(let h of a$1)v.log(` - ${h}`);if(l.length&&(Y(`Skipped ${l.length} ${l.length===1?"file":"files"}: (files might be identical, use --overwrite to overwrite)`,{silent:r.silent})?.info(),!r.silent))for(let h of l)v.log(` - ${h}`);if(c$1.length&&f&&(Y(`Added the following variables to ${T.info(f)}:`)?.info(),!r.silent))for(let h of c$1)v.log(` ${T.success("+")} ${h}`);return {filesCreated:o,filesUpdated:a$1,filesSkipped:l}}function nt(e,t,r){if(r.path){let i=y.isAbsolute(r.path)?r.path:y.join(t.resolvedPaths.cwd,r.path);if(/\.[^/\\]+$/.test(i)){if(r.fileIndex===0)return i}else {let a=y.basename(e.path);return y.join(i,a)}}if(e.target){if(e.target.startsWith("~/"))return y.join(t.resolvedPaths.cwd,e.target.replace("~/",""));let i=e.target;return e.type==="registry:page"&&(i=fs(i,r.framework),!i)?"":r.isSrcDir?y.join(t.resolvedPaths.cwd,"src",i.replace("src/","")):y.join(t.resolvedPaths.cwd,i.replace("src/",""))}let s=cs(e,t),n=ps(e.path,s);return y.join(s,n)}function cs(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 it(e,t){let r=e.map(o=>o.replace(/^\//,"")),s=t.replace(/^\//,""),n=s.split("/").slice(0,-1).join("/");if(!n)return "";let i=n.split("/");for(let o=i.length;o>0;o--){let a=i.slice(0,o).join("/");if(r.some(c=>c!==s&&c.startsWith(a+"/")))return "/"+a}return "/"+n}function ps(e,t){let r=e.replace(/^\/|\/$/g,""),s=t.replace(/^\/|\/$/g,""),n=r.split("/"),i=s.split("/"),o=i[i.length-1],a=n.findIndex(l=>l===o);return a===-1?n[n.length-1]:n.slice(a+1).join("/")}function fs(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 ms(e,t){let r=new Project({compilerOptions:{}}),s=await _(t.resolvedPaths.cwd),n=loadConfig(t.resolvedPaths.cwd),i=[];if(!s||n.resultType==="failed")return [];for(let o of e){let a=y.resolve(t.resolvedPaths.cwd,o);if(!existsSync(a))continue;let l=await promises.readFile(a,"utf-8"),c=await promises.mkdtemp(y.join(tmpdir(),"shadcn-")),f=r.createSourceFile(y.join(c,basename(a)),l,{scriptKind:ScriptKind.TSX});if(![".tsx",".ts",".jsx",".js"].includes(f.getExtension()))continue;let p=f.getImportDeclarations();for(let x of p){let d=x.getModuleSpecifierValue();if(s?.aliasPrefix&&!d.startsWith(`${s.aliasPrefix}/`))continue;let h=await F(d,n);if(!h)continue;let w=gs(h,e,t);if(!w)continue;let g=ds(w,t,s);!g||g===d||(x.setModuleSpecifier(g),await promises.writeFile(a,f.getFullText(),"utf-8"),i.push(o));}}return i}function gs(e,t,r,s=[".tsx",".ts",".js",".jsx",".css"]){let n=y.normalize(r.resolvedPaths.cwd),i=t.map(g=>g.split(y.sep).join(y.posix.sep)),o=new Set(i),a=y.extname(e),l=a!=="",c=l?e.slice(0,-a.length):e,p=y.relative(n,c).split(y.sep).join(y.posix.sep),x=l?[a]:s,d=new Set;for(let g of x){let j=c+g,m=y.posix.normalize(y.relative(n,j));(o.has(m)||existsSync(j))&&d.add(m);let E=y.join(c,`index${g}`),b=y.posix.normalize(y.relative(n,E));(o.has(b)||existsSync(E))&&d.add(b);}let h=y.basename(c);for(let g of i)x.some(j=>g.endsWith(`/${h}${j}`))&&d.add(g);return d.size===0?null:Array.from(d).sort((g,j)=>{let m=y.posix.extname(g),E=y.posix.extname(j),b=x.indexOf(m)-x.indexOf(E);if(b!==0)return b;let S=p&&g.startsWith(p)?-1:1,R=p&&j.startsWith(p)?-1:1;return S-R})[0]}function ds(e,t,r){let s=y.normalize(y.join(t.resolvedPaths.cwd,e)),n=Object.entries(t.resolvedPaths).filter(([,h])=>h&&s.startsWith(y.normalize(h+y.sep))).sort((h,w)=>w[1].length-h[1].length);if(n.length===0)return null;let[i,o]=n[0],a=y.relative(o,s);a=a.split(y.sep).join("/");let l=y.posix.extname(a),f=[".ts",".tsx",".js",".jsx"].includes(l)?"":l,p=a.slice(0,a.length-l.length);p.endsWith("/index")&&(p=p.slice(0,-6));let x=i==="cwd"?r.aliasPrefix:t.aliases[i];if(!x)return null;let d=p===""?"":`/${p}`;return d=d.replace("/src",""),`${x}${d}${f}`}function Jt(e,t,r){let s=e===y.join(r.resolvedPaths.cwd,"middleware.ts")||e===y.join(r.resolvedPaths.cwd,"middleware.js"),n=t?.framework.name==="next-app"||t?.framework.name==="next-pages";if(!s||!n||!t?.frameworkVersion)return false;let i=parseInt(t.frameworkVersion.split(".")[0]);return !isNaN(i)&&i>=16}new Project({compilerOptions:{}});function L(e){try{return new URL(e),!0}catch{return false}}function ae(e){return e.endsWith(".json")&&!L(e)}function Ko(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 qt(e,t){if(!hs(t))return z.array(g$1).parse(e.flat().filter(Boolean));let r=await _(t.resolvedPaths.cwd),s=new Map,n=z.array(g$1).parse(e.flat().filter(Boolean));return n.forEach(i=>{let o=nt(i,t,{isSrcDir:r?.isSrcDir,framework:r?.framework.name,commonRoot:it(n.map(a=>a.path),i.path)});o&&s.set(o,i);}),Array.from(s.values())}function hs(e){return !!(e?.resolvedPaths?.cwd&&(e?.resolvedPaths?.ui||e?.resolvedPaths?.lib||e?.resolvedPaths?.components||e?.resolvedPaths?.hooks))}function xs(e){return e.style?e.style==="new-york"&&e.tailwind?.config===""?Ae:e.style:Ae}function le(e){let t=At({style:Ae,registries:N});return e?d$1.parse(pe(t,{...e,style:xs(e),registries:{...N,...e.registries}})):t}var Ge={headers:{}};function Re(e){Ge.headers={...Ge.headers,...e};}function Yt(e){return Ge.headers[e]||{}}function Ce(){Ge.headers={};}function ws(e){let t=new Set;return typeof e=="string"?de(e).forEach(r=>t.add(r)):(de(e.url).forEach(r=>t.add(r)),e.params&&Object.values(e.params).forEach(r=>{de(r).forEach(s=>t.add(s));}),e.headers&&Object.values(e.headers).forEach(r=>{de(r).forEach(s=>t.add(s));})),Array.from(t)}function Zt(e,t){let s=ws(t).filter(n=>!process.env[n]);if(s.length>0)throw new xe(e,s)}function Xo(e,t){for(let r of e)ce(r,le(t));Ce();}var Qt="{name}",qe="{style}",Xt=/\${(\w+)}/g,er="?",Es="&";function vs(e){return e.startsWith("./")||e.startsWith("/")}function ce(e,t){let{registry:r,item:s}=re(e);if(!r){if(L(e)||ae(e)||vs(e))return null;r="@shadcn";}let i={...N,...t?.registries}[r];if(!i)throw new W(r);return Zt(r,i),{url:Rs(s,i,t),headers:Cs(i)}}function Rs(e,t,r){if(typeof t=="string"){let n=t.replace(Qt,e);return r?.style&&n.includes(qe)&&(n=n.replace(qe,r.style)),ge(n)}let s=t.url.replace(Qt,e);return r?.style&&s.includes(qe)&&(s=s.replace(qe,r.style)),s=ge(s),t.params?Ss(s,t.params):s}function Cs(e){if(typeof e=="string"||!e.headers)return {};let t={};for(let[r,s]of Object.entries(e.headers)){let n=ge(s);bs(s,n)&&(t[r]=n);}return t}function Ss(e,t){let r=new URLSearchParams;for(let[i,o]of Object.entries(t)){let a=ge(o);a&&r.append(i,a);}let s=r.toString();if(!s)return e;let n=e.includes(er)?Es:er;return `${e}${n}${s}`}function bs(e,t){let r=t.trim();if(!r)return false;if(e.includes("${")&&e.match(Xt)){let n=e.replace(Xt,"").trim();return r!==n}return true}function Ye(e){if(L(e)){let t=new URL(e);return t.pathname.match(/\/chat\/b\//)&&!t.pathname.endsWith("/json")&&(t.pathname=`${t.pathname}/json`),t.toString()}return `${H}/${e}`}var $s=process.env.https_proxy?new HttpsProxyAgent(process.env.https_proxy):void 0,ot=new Map;async function P(e,t={}){t={useCache:true,...t};try{return await Promise.all(e.map(async s=>{let n=Ye(s);if(t.useCache&&ot.has(n))return ot.get(n);let i=(async()=>{let o=Yt(n),a=new Headers({Accept:"application/vnd.shadcn.v1+json, application/json;q=0.9","User-Agent":"shadcn"});for(let[c,f]of Object.entries(o))a.set(c,f);let l=await js(n,{agent:$s,headers:a});if(!l.ok){let c;if(l.headers.get("content-type")?.includes("application/json")){let f=await l.json(),p=z.object({detail:z.string().optional(),title:z.string().optional(),message:z.string().optional(),error:z.string().optional()}).safeParse(f);p.success&&(c=p.data.detail||p.data.message,p.data.error&&(c=`[${p.data.error}] ${c}`));}throw l.status===401?new ue(n,c):l.status===404?new J(n,c):l.status===410?new Oe(n,c):l.status===403?new he(n,c):new ye(n,l.status,c)}return l.json()})();return t.useCache&&ot.set(n,i),i}))}catch(r){throw r}}async function rr(e){try{let t=e;e.startsWith("~/")&&(t=y.join(homedir(),e.slice(2)));let r=y.resolve(t),s=await promises.readFile(r,"utf8"),n$1=JSON.parse(s);try{return n.parse(n$1)}catch(i){throw new $(e,i)}}catch(t){throw t instanceof Error&&(t.message.includes("ENOENT")||t.message.includes("no such file"))?new te(e,t):t instanceof $?t:new te(e,t)}}async function $a(e,t,r){if(!e||(r={silent:false,tailwindVersion:"v3",...r},r.tailwindVersion==="v4"))return;let s=y.relative(t.resolvedPaths.cwd,t.resolvedPaths.tailwindConfig),n=Y(`Updating ${T.info(s)}`,{silent:r.silent}).start(),i=await promises.readFile(t.resolvedPaths.tailwindConfig,"utf8"),o=await Ds(i,e,t);await promises.writeFile(t.resolvedPaths.tailwindConfig,o,"utf8"),n?.succeed();}async function Ds(e,t,r){let s=await nr(e,r),n=s.getDescendantsOfKind(SyntaxKind.ObjectLiteralExpression).find(o=>o.getProperties().some(a=>a.isKind(SyntaxKind.PropertyAssignment)&&a.getName()==="content"));if(!n)return e;let i=Vs(n);return Ks(n,{name:"darkMode",value:"class"},{quoteChar:i}),t.plugins?.forEach(o=>{zs(n,o);}),t.theme&&await _s(n,t.theme),s.getFullText()}function Ks(e,t,{quoteChar:r}){let s=e.getProperty("darkMode");if(!s){let n={name:t.name,initializer:`[${r}${t.value}${r}]`};return t.name==="darkMode"?(e.insertPropertyAssignment(0,n),e):(e.addPropertyAssignment(n),e)}if(s.isKind(SyntaxKind.PropertyAssignment)){let n=s.getInitializer(),i=`${r}${t.value}${r}`;if(n?.isKind(SyntaxKind.StringLiteral)){let o=n.getText();return n.replaceWithText(`[${o}, ${i}]`),e}if(n?.isKind(SyntaxKind.ArrayLiteralExpression)){if(n.getElements().map(o=>o.getText()).includes(i))return e;n.addElement(i);}return e}return e}async function _s(e,t){e.getProperty("theme")||e.addPropertyAssignment({name:"theme",initializer:"{}"}),lt(e);let s=(e.getPropertyOrThrow("theme")?.asKindOrThrow(SyntaxKind.PropertyAssignment)).getInitializer();if(s?.isKind(SyntaxKind.ObjectLiteralExpression)){let n=s.getText(),i=await Ws(n),o=pe(i,t,{arrayMerge:(l,c)=>c}),a=Ns(o).replace(/\'\.\.\.(.*)\'/g,"...$1").replace(/\'\"/g,"'").replace(/\"\'/g,"'").replace(/\'\[/g,"[").replace(/\]\'/g,"]").replace(/\'\\\'/g,"'").replace(/\\\'/g,"'").replace(/\\\'\'/g,"'").replace(/\'\'/g,"'");s.replaceWithText(a);}ct(e);}function zs(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(n=>n.getText().replace(/["']/g,"")).includes(t.replace(/["']/g,"")))return e;s.addElement(t);}return e}return e}async function nr(e,t){let r=await promises.mkdtemp(y.join(tmpdir(),"shadcn-")),s=t?.resolvedPaths?.tailwindConfig||"tailwind.config.ts",n=y.join(r,`shadcn-${y.basename(s)}`);return new Project({compilerOptions:{}}).createSourceFile(n,e,{scriptKind:y.extname(s)===".ts"?ScriptKind.TS:ScriptKind.JS})}function Vs(e){return e.getFirstDescendantByKind(SyntaxKind.StringLiteral)?.getQuoteKind()===QuoteKind.Single?"'":'"'}function lt(e){let t=e.getProperties();for(let r=0;r<t.length;r++){let s=t[r];if(s.isKind(SyntaxKind.SpreadAssignment)){let n=s.asKindOrThrow(SyntaxKind.SpreadAssignment),i=n.getExpression().getText();e.insertPropertyAssignment(r,{name:`"___${i.replace(/^\.\.\./,"")}"`,initializer:`"...${i.replace(/^\.\.\./,"")}"`}),n.remove();}else if(s.isKind(SyntaxKind.PropertyAssignment)){let i=s.asKindOrThrow(SyntaxKind.PropertyAssignment).getInitializer();i&&i.isKind(SyntaxKind.ObjectLiteralExpression)?lt(i.asKindOrThrow(SyntaxKind.ObjectLiteralExpression)):i&&i.isKind(SyntaxKind.ArrayLiteralExpression)&&ir(i.asKindOrThrow(SyntaxKind.ArrayLiteralExpression));}}}function ir(e){let t=e.getElements();for(let r=0;r<t.length;r++){let s=t[r];if(s.isKind(SyntaxKind.ObjectLiteralExpression))lt(s.asKindOrThrow(SyntaxKind.ObjectLiteralExpression));else if(s.isKind(SyntaxKind.ArrayLiteralExpression))ir(s.asKindOrThrow(SyntaxKind.ArrayLiteralExpression));else if(s.isKind(SyntaxKind.SpreadElement)){let n=s.getText();e.removeElement(r),e.insertElement(r,`"${n}"`);}}}function ct(e){let t=e.getProperties();for(let r=0;r<t.length;r++){let s=t[r];if(s.isKind(SyntaxKind.PropertyAssignment)){let n=s,i=n.getInitializer();if(i&&i.isKind(SyntaxKind.StringLiteral)){let o=i.asKindOrThrow(SyntaxKind.StringLiteral).getLiteralValue();o.startsWith("...")&&(e.insertSpreadAssignment(r,{expression:o.slice(3)}),n.remove());}else i?.isKind(SyntaxKind.ObjectLiteralExpression)?ct(i):i&&i.isKind(SyntaxKind.ArrayLiteralExpression)&&or(i.asKindOrThrow(SyntaxKind.ArrayLiteralExpression));}}}function or(e){let t=e.getElements();for(let r=0;r<t.length;r++){let s=t[r];if(s.isKind(SyntaxKind.ObjectLiteralExpression))ct(s.asKindOrThrow(SyntaxKind.ObjectLiteralExpression));else if(s.isKind(SyntaxKind.ArrayLiteralExpression))or(s.asKindOrThrow(SyntaxKind.ArrayLiteralExpression));else if(s.isKind(SyntaxKind.StringLiteral)){let n=s.getText(),i=/(?:^['"])(\.\.\..*)(?:['"]$)/g;i.test(n)&&(e.removeElement(r),e.insertElement(r,n.replace(i,"$1")));}}}async function Ws(e){let r=(await nr(`const theme = ${e}`,null)).getStatements()[0];if(r?.getKind()===SyntaxKind.VariableStatement){let n=(r.getDeclarationList()?.getDeclarations()[0]).getInitializer();if(n?.isKind(SyntaxKind.ObjectLiteralExpression))return await Ze(n)}throw new Error("Invalid input: not an object literal")}function Ze(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]=Ze(r.getInitializer()):r.getInitializer()?.isKind(SyntaxKind.ArrayLiteralExpression)?t[s]=ar(r.getInitializer()):t[s]=pt(r.getInitializer());}return t}function ar(e){let t=[];for(let r of e.getElements())r.isKind(SyntaxKind.ObjectLiteralExpression)?t.push(Ze(r.asKindOrThrow(SyntaxKind.ObjectLiteralExpression))):r.isKind(SyntaxKind.ArrayLiteralExpression)?t.push(ar(r.asKindOrThrow(SyntaxKind.ArrayLiteralExpression))):t.push(pt(r));return t}function pt(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(pt);case SyntaxKind.ObjectLiteralExpression:return Ze(e);default:return e.getText()}}function lr(e){let t={};for(let r of Object.keys(e)){let s=r.split("-"),n=s[0],i=s.slice(1).join("-");i===""?typeof t[n]=="object"?t[n].DEFAULT=`hsl(var(--${r}))`:t[n]=`hsl(var(--${r}))`:(typeof t[n]!="object"&&(t[n]={DEFAULT:`hsl(var(--${n}))`}),t[n][i]=`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 Ie(e,t){let r={},s=[...e];if(!t?.registries)return Re({}),s;for(let n=0;n<s.length;n++){let i=ce(s[n],t);i&&(s[n]=i.url,Object.keys(i.headers).length>0&&(r[i.url]=i.headers));}return Re(r),s}async function Z(e,t,r={}){return await Promise.all(e.map(async n$1=>{if(ae(n$1))return rr(n$1);if(L(n$1)){let[a]=await P([n$1],r);try{return n.parse(a)}catch(l){throw new $(n$1,l)}}if(n$1.startsWith("@")&&t?.registries){let a=Ie([n$1],t),[l]=await P(a,r);try{return n.parse(l)}catch(c){throw new $(n$1,c)}}let i=`styles/${t?.style??"new-york-v4"}/${n$1}.json`,[o]=await P([i],r);try{return n.parse(o)}catch(a){throw new $(n$1,a)}}))}m.extend({type:f,_source:z.string().optional(),font:l.optional(),config:z.any().optional()}).passthrough();async function pr(e,t$1,r={}){r={useCache:true,...r};let s=[],n$1=[],i=[],o=Array.from(new Set(e)),a=await Z(o,t$1,r),l=new Map;for(let m=0;m<a.length;m++)a[m]&&l.set(o[m],a[m]);for(let[m,E]of Array.from(l.entries())){let b={...E,_source:m};if(s.push(b),E.registryDependencies){let S=E.registryDependencies;if(t$1?.registries)S=Ie(E.registryDependencies,t$1);else {let ee=E.registryDependencies.filter(me=>me.startsWith("@"));if(ee.length>0){let{registry:me}=re(ee[0]);throw new W(me)}}let{items:R,registryNames:X}=await Te(S,t$1,r,new Set(o));n$1.push(...R),i.push(...X);}}if(s.push(...n$1),i.length>0){let m=Array.from(new Set(i)),E=m.filter(S=>!S.startsWith("@")),b=m.filter(S=>S.startsWith("@"));if(b.length>0){let S=await Z(b,t$1,r);for(let R=0;R<S.length;R++){let ee={...S[R],_source:b[R]};s.push(ee);}}if(E.length>0){let S=await De();if(!S&&s.length===0)return null;if(S){E.includes("index")&&E.unshift("index");let R=[];for(let gr of E){let dr=await Ms(gr,t$1,r);R.push(...dr);}let X=Array.from(new Set(R)),ee=await P(X,r),me=z.array(n).parse(ee);s.push(...me);}}}if(!s.length)return null;if((o.includes("index")||i.includes("index"))&&t$1.tailwind.baseColor){let m=await Bs(t$1.tailwind.baseColor,t$1);m&&s.unshift(m);}let c=new Map;s.forEach(m=>{let E=m._source||m.name;c.set(m,E);}),s=Js(s,c),s.sort((m,E)=>m.type==="registry:theme"&&E.type!=="registry:theme"?-1:m.type!=="registry:theme"&&E.type==="registry:theme"?1:0);let f={};s.forEach(m=>{f=pe(f,m.tailwind??{});});let p={};s.forEach(m=>{p=pe(p,m.cssVars??{});});let x={};s.forEach(m=>{x=pe(x,m.css??{});});let d="";s.forEach(m=>{m.docs&&(d+=`${m.docs}
28
- `);});let h={};s.forEach(m=>{h=pe(h,m.envVars??{});});let w=await qt(s.map(m=>m.files??[]),t$1),g=s.filter(m=>m.type==="registry:font"&&m.font).map(m=>({...m,type:"registry:font",font:m.font})),j=t.parse({dependencies:pe.all(s.map(m=>m.dependencies??[])),devDependencies:pe.all(s.map(m=>m.devDependencies??[])),files:w,tailwind:f,cssVars:p,css:x,docs:d,fonts:g.length>0?g:void 0});return Object.keys(h).length>0&&(j.envVars=h),j}async function Te(e,t,r={},s=new Set){let n=[],i=[];for(let o of e)if(!s.has(o)){if(s.add(o),L(o)||ae(o)){let[a]=await Z([o],t,r);if(a&&(n.push(a),a.registryDependencies)){let l=t?.registries?Ie(a.registryDependencies,t):a.registryDependencies,c=await Te(l,t,r,s);n.push(...c.items),i.push(...c.registryNames);}}else if(o.startsWith("@")&&t?.registries){let{registry:a}=re(o);if(a&&!(a in t.registries))throw new W(a);let[l]=await Z([o],t,r);if(l&&(n.push(l),l.registryDependencies)){let c=t?.registries?Ie(l.registryDependencies,t):l.registryDependencies,f=await Te(c,t,r,s);n.push(...f.items),i.push(...f.registryNames);}}else if(i.push(o),t)try{let[a]=await Z([o],t,r);if(a&&a.registryDependencies){let l=t?.registries?Ie(a.registryDependencies,t):a.registryDependencies,c=await Te(l,t,r,s);n.push(...c.items),i.push(...c.registryNames);}}catch{}}return {items:n,registryNames:i}}async function Ms(e,t,r={}){if(L(e))return [e];let{registryNames:s}=await Te([e],t,r,new Set),n=t.resolvedPaths?.cwd?await $t(t.resolvedPaths.cwd,t.style):t.style,i=s.map(o=>Ye(L(o)?o:`styles/${n}/${o}.json`));return Array.from(new Set(i))}async function Bs(e,t){let[r,s]=await Promise.all([Je(e),ze(t)]);if(!r)return null;let n={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&&(n.tailwind.config.theme.extend.colors={...n.tailwind.config.theme.extend.colors,...lr(r.cssVars.dark??{})},n.cssVars={theme:{...r.cssVars.theme,...n.cssVars.theme},light:{...r.cssVars.light,...n.cssVars.light},dark:{...r.cssVars.dark,...n.cssVars.dark}},s==="v4"&&r.cssVarsV4&&(n.cssVars={theme:{...r.cssVarsV4.theme,...n.cssVars.theme},light:{radius:"0.625rem",...r.cssVarsV4.light},dark:{...r.cssVarsV4.dark}})),n}function B(e,t){let r=t||e.name,s=createHash("sha256").update(r).digest("hex").substring(0,8);return `${e.name}::${s}`}function Hs(e){if(L(e)){let s=new URL(e).pathname,n=s.match(/\/([^/]+)\.json$/),i=n?n[1]:y.basename(s,".json");return {name:i,hash:B({name:i},e)}}if(ae(e)){let r=e.match(/\/([^/]+)\.json$/),s=r?r[1]:y.basename(e,".json");return {name:s,hash:B({name:s},e)}}let{item:t}=re(e);return {name:t,hash:B({name:t},e)}}function Js(e,t){let r=new Map,s=new Map,n=new Map,i=new Map;e.forEach(c=>{let f=t.get(c)||c.name,p=B(c,f);r.set(p,c),s.set(p,c),n.set(p,0),i.set(p,[]);});let o=new Map;e.forEach(c=>{let f=t.get(c)||c.name,p=B(c,f);o.has(c.name)||o.set(c.name,[]),o.get(c.name).push(p),f!==c.name&&(o.has(f)||o.set(f,[]),o.get(f).push(p));}),e.forEach(c=>{let f=t.get(c)||c.name,p=B(c,f);c.registryDependencies&&c.registryDependencies.forEach(x=>{let d,h=o.get(x)||[];if(h.length===1)d=h[0];else if(h.length>1)d=h[0];else {let{name:w}=Hs(x),g=o.get(w)||[];g.length>0&&(d=g[0]);}d&&r.has(d)&&(i.get(d).push(p),n.set(p,n.get(p)+1));});});let a=[],l=[];for(n.forEach((c,f)=>{c===0&&a.push(f);});a.length>0;){let c=a.shift(),f=r.get(c);l.push(f),i.get(c).forEach(p=>{let x=n.get(p)-1;n.set(p,x),x===0&&a.push(p);});}if(l.length!==e.length){let c=new Set(l.map(f=>{let p=t.get(f)||f.name;return B(f,p)}));e.forEach(f=>{let p=t.get(f)||f.name,x=B(f,p);c.has(x)||l.push(f);});}return l}function fe(e){if(v.break(),v.error("Something went wrong. Please check the error below for more details."),v.error("If the problem persists, please open an issue on GitHub."),v.error(""),typeof e=="string"&&(v.error(e),v.break(),process.exit(1)),e instanceof I&&(e.message&&(v.error(e.cause?"Error:":"Message:"),v.error(e.message)),e.cause&&(v.error(`
29
- Message:`),v.error(e.cause)),e.suggestion&&(v.error(`
30
- Suggestion:`),v.error(e.suggestion)),v.break(),process.exit(1)),e instanceof z.ZodError){v.error("Validation failed:");for(let[t,r]of Object.entries(e.flatten().fieldErrors))v.error(`- ${T.info(t)}: ${r}`);v.break(),process.exit(1);}e instanceof Error&&(v.error(e.message),v.break(),process.exit(1)),v.break(),process.exit(1);}async function mt(e,t){let{config:r,useCache:s}=t||{};if(L(e)){let[a]=await P([e],{useCache:s});try{return o.parse(a)}catch(l){throw new $(e,l)}}if(!e.startsWith("@"))throw new we(e);let n=e;n.endsWith("/registry")||(n=`${n}/registry`);let i=ce(n,le(r));if(!i?.url)throw new J(n);i.headers&&Object.keys(i.headers).length>0&&Re({[i.url]:i.headers});let[o$1]=await P([i.url],{useCache:s});try{return o.parse(o$1)}catch(a){throw new $(n,a)}}async function Ys(e,t){let{config:r,useCache:s=false}=t||{};return Ce(),Z(e,le(r),{useCache:s})}async function Zs(e,t){let{config:r,useCache:s=false}=t||{};return Ce(),pr(e,le(r),{useCache:s})}async function wl(e,t){let{useCache:r=true}=t||{};r||Fe.clearCaches();let s=await Fe.search(e);if(!s)return {registries:N};let n=z.object({registries:b$1.optional()}).safeParse(s.config);if(!n.success)throw new Ne(e,n.error);return {registries:{...N,...n.data.registries||{}}}}async function De(){try{let[e]=await P(["index.json"]);return p.parse(e)}catch(e){v.error(`
31
- `),fe(e);}}async function El(){try{let[e]=await P(["styles/index.json"]);return q$1.parse(e)}catch(e){return v.error(`
32
- `),fe(e),[]}}async function vl(){try{let[e]=await P(["icons/index.json"]);return r.parse(e)}catch(e){return fe(e),{}}}async function Rl(){return kt}async function Je(e){try{let[t]=await P([`colors/${e}.json`]);return s.parse(t)}catch(t){fe(t);}}async function Qs(e,t){let r=[];for(let s of t){let n=e.find(i=>i.name===s);if(n&&(r.push(n),n.registryDependencies)){let i=await Qs(e,n.registryDependencies);r.push(...i);}}return r.filter((s,n,i)=>i.findIndex(o=>o.name===s.name)===n)}async function Cl(e,t){try{let r=t.map(n=>`styles/${e}/${n.name}.json`);return (await P(r)).map(n$1=>n.parse(n$1))}catch(r){return fe(r),[]}}async function Sl(e,t,r){if(r)return r;if(t.type==="registry:ui")return e.resolvedPaths.ui??e.resolvedPaths.components;let[s,n]=t.type?.split(":")??[];return s in e.resolvedPaths?y.join(e.resolvedPaths[s],n):null}async function mr(e){e={useCache:true,...e};let t=`${H}/registries.json`,[r]=await P([t],{useCache:e.useCache});try{return x.parse(r)}catch(s){throw s instanceof z.ZodError?new Ee(s):s}}async function Xs(e){let t=await mr(e);return t?Object.fromEntries(t.map(r=>[r.name,r.url])):null}async function en(e){e={useCache:true,...e};let t=`${H}/config.json`,[r]=await P([t],{useCache:e.useCache});return z$1.parse(r).presets}async function bl(e,t){return (await en(t)).find(s=>s.name.toLowerCase()===e.toLowerCase())??null}async function rn(e,t){let{query:r,limit:s,offset:n,config:i,useCache:o}=t||{},a=[];for(let x of e){let h=((await mt(x,{config:i,useCache:o})).items||[]).map(w=>({name:w.name,type:w.type,description:w.description,registry:x,addCommandArgument:an(w.name,x)}));a=a.concat(h);}r&&(a=nn(a,{query:r,limit:a.length,keys:["name","description"]}));let l=n||0,c=s||a.length,f=a.length,p={pagination:{total:f,offset:l,limit:c,hasMore:l+c<f},items:a.slice(l,l+c)};return v$1.parse(p)}var sn=z.object({name:z.string(),type:z.string().optional(),description:z.string().optional(),registry:z.string().optional(),addCommandArgument:z.string().optional()}).passthrough();function nn(e,t){t={limit:100,threshold:-1e4,...t};let s=tn.go(t.query,e,{keys:t.keys,threshold:t.threshold,limit:t.limit}).map(n=>n.obj);return z.array(sn).parse(s)}function on(e){try{return new URL(e),!0}catch{return false}}function an(e,t){if(!on(t))return `${t}/${e}`;let r=t.indexOf("://")+3,s=t.indexOf("/",r);if(s===-1){let x=t.indexOf("?",r);if(x!==-1){let d=t.substring(0,x),w=t.substring(x).replace(/\bregistry\b/g,e);return d+w}return t}let n=t.substring(0,s),i=t.substring(s),o=i.indexOf("?")!==-1?i.indexOf("?"):i.length,a=i.substring(0,o),l=i.substring(o),c=a.lastIndexOf("registry"),f=a;c!==-1&&(f=a.substring(0,c)+e+a.substring(c+8));let p=l.replace(/\bregistry\b/g,e);return n+f+p}
33
- export{fe as $,He as A,Mt as B,Bt as C,Co as D,nt as E,it as F,L as G,Ko as H,kn as I,$n as J,An as K,On as L,Fe as M,ve as N,Le as O,Nn as P,br as Q,Tr as R,Fn as S,At as T,le as U,Ce as V,Xo as W,ce as X,$a as Y,Z,pr as _,T as a,mt as aa,v as b,Ys as ba,k as c,Zs as ca,N as d,wl as da,ln as e,De as ea,I as f,El as fa,J as g,vl as ga,ue as h,Rl as ha,he as i,Je as ia,ye as j,Qs as ja,W as k,Cl as ka,te as l,Sl as la,$ as m,mr as ma,xe as n,Xs as na,we as o,en as oa,Ee as p,bl as pa,re as q,tt as qa,Nt as r,_ as ra,q as s,Xn as sa,Lt as t,ze as ta,Dt as u,ei as ua,Kt as v,rn as va,Y as w,Ve as x,Ue as y,Be as z};
@@ -1,119 +0,0 @@
1
- import {va,ba,f,da}from'./chunk-42UQOK2K.js';import {Server}from'@modelcontextprotocol/sdk/server/index.js';import {ListToolsRequestSchema,CallToolRequestSchema}from'@modelcontextprotocol/sdk/types.js';import P from'dedent';import {z}from'zod';import {zodToJsonSchema}from'zod-to-json-schema';import I,{join,normalize,delimiter,resolve,dirname}from'path';import R,{cwd}from'process';import Wr from'readline';import es from'events';import Qe from'fs/promises';import {createRequire}from'module';import {spawn}from'child_process';import {PassThrough}from'stream';import Kt from'fs';import ts from'os';import rs from'tty';var K=["npm","yarn","yarn@berry","pnpm","pnpm@6","bun","deno"],X={"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"},Z={"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"},Xe={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 Q(e,t){try{let o=await Qe.stat(e);return t==="file"?o.isFile():o.isDirectory()}catch{return false}}function*ar(e=R.cwd()){let t=I.resolve(e),{root:o}=I.parse(t);for(;t&&t!==o;)yield t,t=I.dirname(t);}async function Ze(e,t){return !e||!Q(e,"file")?null:await ur(e,t)}async function ee(e={}){let{cwd:t,strategies:o=["lockfile","packageManager-field","devEngines-field"],onUnknown:r}=e,u;if(typeof e.stopDir=="string"){let c=I.resolve(e.stopDir);u=l=>l===c;}else u=e.stopDir;for(let c of ar(t)){for(let l of o)switch(l){case "lockfile":{for(let a of Object.keys(X))if(await Q(I.join(c,a),"file")){let s=X[a],h=await Ze(I.join(c,"package.json"),r);return h||{name:s,agent:s}}break}case "packageManager-field":case "devEngines-field":{let a=await Ze(I.join(c,"package.json"),r);if(a)return a;break}case "install-metadata":{for(let a of Object.keys(Z)){let s=a.endsWith("/")?"dir":"file";if(await Q(I.join(c,a),s)){let h=Z[a],i=h==="yarn"?cr(a)?"yarn":"yarn@berry":h;return {name:h,agent:i}}}break}}if(u?.(c))break}return null}function lr(e){let t=o=>o?.match(/\d+(\.\d+){0,2}/)?.[0]??o;if(typeof e.packageManager=="string"){let[o,r]=e.packageManager.replace(/^\^/,"").split("@");return {name:o,ver:t(r)}}if(typeof e.devEngines?.packageManager?.name=="string")return {name:e.devEngines.packageManager.name,ver:t(e.devEngines.packageManager.version)}}async function ur(e,t){try{let o=JSON.parse(await Qe.readFile(e,"utf8")),r,u=lr(o);if(u){let c=u.name,l=u.ver,a=l;return c==="yarn"&&l&&Number.parseInt(l)>1?(r="yarn@berry",a="berry",{name:c,agent:r,version:a}):c==="pnpm"&&l&&Number.parseInt(l)<7?(r="pnpm@6",{name:c,agent:r,version:a}):K.includes(c)?(r=c,{name:c,agent:r,version:a}):t?.(o.packageManager)??null}}catch{}return null}function cr(e){return e.endsWith(".yarn_integrity")}var H=createRequire(import.meta.url),dr=Object.create,st=Object.defineProperty,fr=Object.getOwnPropertyDescriptor,pr=Object.getOwnPropertyNames,mr=Object.getPrototypeOf,gr=Object.prototype.hasOwnProperty,q=(e=>typeof H<"u"?H:typeof Proxy<"u"?new Proxy(e,{get:(t,o)=>(typeof H<"u"?H:t)[o]}):e)(function(e){if(typeof H<"u")return H.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')}),O=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),yr=(e,t,o,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let u of pr(t))!gr.call(e,u)&&u!==o&&st(e,u,{get:()=>t[u],enumerable:!(r=fr(t,u))||r.enumerable});return e},vr=(e,t,o)=>(o=e!=null?dr(mr(e)):{},yr(st(o,"default",{value:e,enumerable:true}),e)),br=O((e,t)=>{t.exports=c,c.sync=l;var o=q("fs");function r(a,s){var h=s.pathExt!==void 0?s.pathExt:process.env.PATHEXT;if(!h||(h=h.split(";"),h.indexOf("")!==-1))return true;for(var i=0;i<h.length;i++){var n=h[i].toLowerCase();if(n&&a.substr(-n.length).toLowerCase()===n)return true}return false}function u(a,s,h){return !a.isSymbolicLink()&&!a.isFile()?false:r(s,h)}function c(a,s,h){o.stat(a,function(i,n){h(i,i?false:u(n,a,s));});}function l(a,s){return u(o.statSync(a),a,s)}}),wr=O((e,t)=>{t.exports=r,r.sync=u;var o=q("fs");function r(a,s,h){o.stat(a,function(i,n){h(i,i?false:c(n,s));});}function u(a,s){return c(o.statSync(a),s)}function c(a,s){return a.isFile()&&l(a,s)}function l(a,s){var h=a.mode,i=a.uid,n=a.gid,f=s.uid!==void 0?s.uid:process.getuid&&process.getuid(),d=s.gid!==void 0?s.gid:process.getgid&&process.getgid(),p=parseInt("100",8),g=parseInt("010",8),m=parseInt("001",8),b=p|g,x=h&m||h&g&&n===d||h&p&&i===f||h&b&&f===0;return x}}),xr=O((e,t)=>{q("fs");var r;process.platform==="win32"||global.TESTING_WINDOWS?r=br():r=wr(),t.exports=u,u.sync=c;function u(l,a,s){if(typeof a=="function"&&(s=a,a={}),!s){if(typeof Promise!="function")throw new TypeError("callback not provided");return new Promise(function(h,i){u(l,a||{},function(n,f){n?i(n):h(f);});})}r(l,a||{},function(h,i){h&&(h.code==="EACCES"||a&&a.ignoreErrors)&&(h=null,i=false),s(h,i);});}function c(l,a){try{return r.sync(l,a||{})}catch(s){if(a&&a.ignoreErrors||s.code==="EACCES")return false;throw s}}}),_r=O((e,t)=>{var o=process.platform==="win32"||process.env.OSTYPE==="cygwin"||process.env.OSTYPE==="msys",r=q("path"),u=o?";":":",c=xr(),l=i=>Object.assign(new Error(`not found: ${i}`),{code:"ENOENT"}),a=(i,n)=>{let f=n.colon||u,d=i.match(/\//)||o&&i.match(/\\/)?[""]:[...o?[process.cwd()]:[],...(n.path||process.env.PATH||"").split(f)],p=o?n.pathExt||process.env.PATHEXT||".EXE;.CMD;.BAT;.COM":"",g=o?p.split(f):[""];return o&&i.indexOf(".")!==-1&&g[0]!==""&&g.unshift(""),{pathEnv:d,pathExt:g,pathExtExe:p}},s=(i,n,f)=>{typeof n=="function"&&(f=n,n={}),n||(n={});let{pathEnv:d,pathExt:p,pathExtExe:g}=a(i,n),m=[],b=w=>new Promise((y,v)=>{if(w===d.length)return n.all&&m.length?y(m):v(l(i));let E=d[w],$=/^".*"$/.test(E)?E.slice(1,-1):E,S=r.join($,i),T=!$&&/^\.[\\\/]/.test(i)?i.slice(0,2)+S:S;y(x(T,w,0));}),x=(w,y,v)=>new Promise((E,$)=>{if(v===p.length)return E(b(y+1));let S=p[v];c(w+S,{pathExt:g},(T,z)=>{if(!T&&z)if(n.all)m.push(w+S);else return E(w+S);return E(x(w,y,v+1))});});return f?b(0).then(w=>f(null,w),f):b(0)},h=(i,n)=>{n=n||{};let{pathEnv:f,pathExt:d,pathExtExe:p}=a(i,n),g=[];for(let m=0;m<f.length;m++){let b=f[m],x=/^".*"$/.test(b)?b.slice(1,-1):b,w=r.join(x,i),y=!x&&/^\.[\\\/]/.test(i)?i.slice(0,2)+w:w;for(let v=0;v<d.length;v++){let E=y+d[v];try{if(c.sync(E,{pathExt:p}))if(n.all)g.push(E);else return E}catch{}}}if(n.all&&g.length)return g;if(n.nothrow)return null;throw l(i)};t.exports=s,s.sync=h;}),Er=O((e,t)=>{var o=(r={})=>{let u=r.env||process.env;return (r.platform||process.platform)!=="win32"?"PATH":Object.keys(u).reverse().find(c=>c.toUpperCase()==="PATH")||"Path"};t.exports=o,t.exports.default=o;}),Sr=O((e,t)=>{var o=q("path"),r=_r(),u=Er();function c(a,s){let h=a.options.env||process.env,i=process.cwd(),n=a.options.cwd!=null,f=n&&process.chdir!==void 0&&!process.chdir.disabled;if(f)try{process.chdir(a.options.cwd);}catch{}let d;try{d=r.sync(a.command,{path:h[u({env:h})],pathExt:s?o.delimiter:void 0});}catch{}finally{f&&process.chdir(i);}return d&&(d=o.resolve(n?a.options.cwd:"",d)),d}function l(a){return c(a)||c(a,true)}t.exports=l;}),$r=O((e,t)=>{var o=/([()\][%!^"`<>&|;, *?])/g;function r(c){return c=c.replace(o,"^$1"),c}function u(c,l){return c=`${c}`,c=c.replace(/(\\*)"/g,'$1$1\\"'),c=c.replace(/(\\*)$/,"$1$1"),c=`"${c}"`,c=c.replace(o,"^$1"),l&&(c=c.replace(o,"^$1")),c}t.exports.command=r,t.exports.argument=u;}),Or=O((e,t)=>{t.exports=/^#!(.*)/;}),Tr=O((e,t)=>{var o=Or();t.exports=(r="")=>{let u=r.match(o);if(!u)return null;let[c,l]=u[0].replace(/#! ?/,"").split(" "),a=c.split("/").pop();return a==="env"?l:l?`${a} ${l}`:a};}),Cr=O((e,t)=>{var o=q("fs"),r=Tr();function u(c){let l=Buffer.alloc(150),a;try{a=o.openSync(c,"r"),o.readSync(a,l,0,150,0),o.closeSync(a);}catch{}return r(l.toString())}t.exports=u;}),Ar=O((e,t)=>{var o=q("path"),r=Sr(),u=$r(),c=Cr(),l=process.platform==="win32",a=/\.(?:com|exe)$/i,s=/node_modules[\\/].bin[\\/][^\\/]+\.cmd$/i;function h(f){f.file=r(f);let d=f.file&&c(f.file);return d?(f.args.unshift(f.file),f.command=d,r(f)):f.file}function i(f){if(!l)return f;let d=h(f),p=!a.test(d);if(f.options.forceShell||p){let g=s.test(d);f.command=o.normalize(f.command),f.command=u.command(f.command),f.args=f.args.map(b=>u.argument(b,g));let m=[f.command].concat(f.args).join(" ");f.args=["/d","/s","/c",`"${m}"`],f.command=process.env.comspec||"cmd.exe",f.options.windowsVerbatimArguments=true;}return f}function n(f,d,p){d&&!Array.isArray(d)&&(p=d,d=null),d=d?d.slice(0):[],p=Object.assign({},p);let g={command:f,args:d,options:p,file:void 0,original:{command:f,args:d}};return p.shell?g:i(g)}t.exports=n;}),Mr=O((e,t)=>{var o=process.platform==="win32";function r(a,s){return Object.assign(new Error(`${s} ${a.command} ENOENT`),{code:"ENOENT",errno:"ENOENT",syscall:`${s} ${a.command}`,path:a.command,spawnargs:a.args})}function u(a,s){if(!o)return;let h=a.emit;a.emit=function(i,n){if(i==="exit"){let f=c(n,s);if(f)return h.call(a,"error",f)}return h.apply(a,arguments)};}function c(a,s){return o&&a===1&&!s.file?r(s.original,"spawn"):null}function l(a,s){return o&&a===1&&!s.file?r(s.original,"spawnSync"):null}t.exports={hookChildProcess:u,verifyENOENT:c,verifyENOENTSync:l,notFoundError:r};}),Pr=O((e,t)=>{var o=q("child_process"),r=Ar(),u=Mr();function c(a,s,h){let i=r(a,s,h),n=o.spawn(i.command,i.args,i.options);return u.hookChildProcess(n,i),n}function l(a,s,h){let i=r(a,s,h),n=o.spawnSync(i.command,i.args,i.options);return n.error=n.error||u.verifyENOENTSync(n.status,i),n}t.exports=c,t.exports.spawn=c,t.exports.sync=l,t.exports._parse=r,t.exports._enoent=u;}),Nr=/^path$/i,tt={key:"PATH",value:""};function Dr(e){for(let t in e){if(!Object.prototype.hasOwnProperty.call(e,t)||!Nr.test(t))continue;let o=e[t];return o?{key:t,value:o}:tt}return tt}function Lr(e,t){let o=t.value.split(delimiter),r=e,u;do o.push(resolve(r,"node_modules",".bin")),u=r,r=dirname(r);while(r!==u);return {key:t.key,value:o.join(delimiter)}}function Fr(e,t){let o={...process.env,...t},r=Lr(e,Dr(o));return o[r.key]=r.value,o}var Gr=e=>{let t=e.length,o=new PassThrough,r=()=>{--t===0&&o.emit("end");};for(let u of e)u.pipe(o,{end:false}),u.on("end",r);return o},Vr=vr(Pr()),rt=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;}},Yr={timeout:void 0,persist:false},Ur={windowsHide:true};function Br(e,t){return {command:normalize(e),args:t??[]}}function zr(e){let t=new AbortController;for(let o of e){if(o.aborted)return t.abort(),o;let r=()=>{t.abort(o.reason);};o.addEventListener("abort",r,{signal:t.signal});}return t.signal}var Jr=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,o){this._options={...Yr,...o},this._command=e,this._args=t??[],this._processClosed=new Promise(r=>{this._resolveClose=r;});}kill(e){return this._process?.kill(e)===true}get aborted(){return this._aborted}get killed(){return this._process?.killed===true}pipe(e,t,o){return Kr(e,t,{...o,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 o=Gr(t),r=Wr.createInterface({input:o});for await(let u of r)yield u.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 rt(this)}async _waitForOutput(){let e=this._process;if(!e)throw new Error("No process was started");let t="",o="";if(this._streamOut)for await(let u of this._streamOut)o+=u.toString();if(this._streamErr)for await(let u of this._streamErr)t+=u.toString();if(await this._processClosed,this._options?.stdin&&await this._options.stdin,e.removeAllListeners(),this._thrownError)throw this._thrownError;let r={stderr:t,stdout:o,exitCode:this.exitCode};if(this._options.throwOnError&&this.exitCode!==0&&this.exitCode!==void 0)throw new rt(this,r);return r}then(e,t){return this._waitForOutput().then(e,t)}_streamOut;_streamErr;spawn(){let e=cwd(),t=this._options,o={...Ur,...t.nodeOptions},r=[];this._resetState(),t.timeout!==void 0&&r.push(AbortSignal.timeout(t.timeout)),t.signal!==void 0&&r.push(t.signal),t.persist===true&&(o.detached=true),r.length>0&&(o.signal=zr(r)),o.env=Fr(e,o.env);let{command:u,args:c}=Br(this._command,this._args),l=(0, Vr._parse)(u,c,o),a=spawn(l.command,l.args,l.options);if(a.stderr&&(this._streamErr=a.stderr),a.stdout&&(this._streamOut=a.stdout),this._process=a,a.once("error",this._onError),a.once("close",this._onClose),t.stdin!==void 0&&a.stdin&&t.stdin.process){let{stdout:s}=t.stdin.process;s&&s.pipe(a.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();}},te=(e,t,o)=>{let r=new Jr(e,t,o);return r.spawn(),r},Kr=te;function Ve(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var se={},ie,nt;function A(){if(nt)return ie;nt=1;let e,t,o,r,u=true;typeof process<"u"&&({FORCE_COLOR:e,NODE_DISABLE_COLORS:t,NO_COLOR:o,TERM:r}=process.env||{},u=process.stdout&&process.stdout.isTTY);let c={enabled:!t&&o==null&&r!=="dumb"&&(e!=null&&e!=="0"||u),reset:s(0,0),bold:s(1,22),dim:s(2,22),italic:s(3,23),underline:s(4,24),inverse:s(7,27),hidden:s(8,28),strikethrough:s(9,29),black:s(30,39),red:s(31,39),green:s(32,39),yellow:s(33,39),blue:s(34,39),magenta:s(35,39),cyan:s(36,39),white:s(37,39),gray:s(90,39),grey:s(90,39),bgBlack:s(40,49),bgRed:s(41,49),bgGreen:s(42,49),bgYellow:s(43,49),bgBlue:s(44,49),bgMagenta:s(45,49),bgCyan:s(46,49),bgWhite:s(47,49)};function l(h,i){let n=0,f,d="",p="";for(;n<h.length;n++)f=h[n],d+=f.open,p+=f.close,~i.indexOf(f.close)&&(i=i.replace(f.rgx,f.close+f.open));return d+i+p}function a(h,i){let n={has:h,keys:i};return n.reset=c.reset.bind(n),n.bold=c.bold.bind(n),n.dim=c.dim.bind(n),n.italic=c.italic.bind(n),n.underline=c.underline.bind(n),n.inverse=c.inverse.bind(n),n.hidden=c.hidden.bind(n),n.strikethrough=c.strikethrough.bind(n),n.black=c.black.bind(n),n.red=c.red.bind(n),n.green=c.green.bind(n),n.yellow=c.yellow.bind(n),n.blue=c.blue.bind(n),n.magenta=c.magenta.bind(n),n.cyan=c.cyan.bind(n),n.white=c.white.bind(n),n.gray=c.gray.bind(n),n.grey=c.grey.bind(n),n.bgBlack=c.bgBlack.bind(n),n.bgRed=c.bgRed.bind(n),n.bgGreen=c.bgGreen.bind(n),n.bgYellow=c.bgYellow.bind(n),n.bgBlue=c.bgBlue.bind(n),n.bgMagenta=c.bgMagenta.bind(n),n.bgCyan=c.bgCyan.bind(n),n.bgWhite=c.bgWhite.bind(n),n}function s(h,i){let n={open:`\x1B[${h}m`,close:`\x1B[${i}m`,rgx:new RegExp(`\\x1b\\[${i}m`,"g")};return function(f){return this!==void 0&&this.has!==void 0?(~this.has.indexOf(h)||(this.has.push(h),this.keys.push(n)),f===void 0?this:c.enabled?l(this.keys,f+""):f+""):f===void 0?a([h],[n]):c.enabled?l([n],f+""):f+""}}return ie=c,ie}var ne,ot;function os(){return ot||(ot=1,ne=(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}}),ne}var oe,at;function We(){return at||(at=1,oe=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("|"),o=new RegExp(t,"g");return typeof e=="string"?e.replace(o,""):e}),oe}var ae,lt;function M(){if(lt)return ae;lt=1;let e="\x1B",t=`${e}[`,o="\x07",r={to(l,a){return a?`${t}${a+1};${l+1}H`:`${t}${l+1}G`},move(l,a){let s="";return l<0?s+=`${t}${-l}D`:l>0&&(s+=`${t}${l}C`),a<0?s+=`${t}${-a}A`:a>0&&(s+=`${t}${a}B`),s},up:(l=1)=>`${t}${l}A`,down:(l=1)=>`${t}${l}B`,forward:(l=1)=>`${t}${l}C`,backward:(l=1)=>`${t}${l}D`,nextLine:(l=1)=>`${t}E`.repeat(l),prevLine:(l=1)=>`${t}F`.repeat(l),left:`${t}G`,hide:`${t}?25l`,show:`${t}?25h`,save:`${e}7`,restore:`${e}8`},u={up:(l=1)=>`${t}S`.repeat(l),down:(l=1)=>`${t}T`.repeat(l)},c={screen:`${t}2J`,up:(l=1)=>`${t}1J`.repeat(l),down:(l=1)=>`${t}J`.repeat(l),line:`${t}2K`,lineEnd:`${t}K`,lineStart:`${t}1K`,lines(l){let a="";for(let s=0;s<l;s++)a+=this.line+(s<l-1?r.up():"");return l&&(a+=r.left),a}};return ae={cursor:r,scroll:u,erase:c,beep:o},ae}var le,ut;function as(){if(ut)return le;ut=1;let e=We(),{erase:t,cursor:o}=M(),r=u=>[...e(u)].length;return le=function(u,c){if(!c)return t.line+o.to(0);let l=0,a=u.split(/\r?\n/);for(let s of a)l+=1+Math.floor(Math.max(r(s)-1,0)/c);return t.lines(l)},le}var ue,ct;function Zt(){if(ct)return ue;ct=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 ue=process.platform==="win32"?t:e,ue}var ce,ht;function ls(){if(ht)return ce;ht=1;let e=A(),t=Zt(),o=Object.freeze({password:{scale:1,render:s=>"*".repeat(s.length)},emoji:{scale:2,render:s=>"\u{1F603}".repeat(s.length)},invisible:{scale:0,render:s=>""},default:{scale:1,render:s=>`${s}`}}),r=s=>o[s]||o.default,u=Object.freeze({aborted:e.red(t.cross),done:e.green(t.tick),exited:e.yellow(t.cross),default:e.cyan("?")});return ce={styles:o,render:r,symbols:u,symbol:(s,h,i)=>h?u.aborted:i?u.exited:s?u.done:u.default,delimiter:s=>e.gray(s?t.ellipsis:t.pointerSmall),item:(s,h)=>e.gray(s?h?t.pointerSmall:"+":t.line)},ce}var he,dt;function us(){if(dt)return he;dt=1;let e=We();return he=function(t,o){let r=String(e(t)||"").split(/\r?\n/);return o?r.map(u=>Math.ceil(u.length/o)).reduce((u,c)=>u+c):r.length},he}var de,ft;function cs(){return ft||(ft=1,de=(e,t={})=>{let o=Number.isSafeInteger(parseInt(t.margin))?new Array(parseInt(t.margin)).fill(" ").join(""):t.margin||"",r=t.width;return (e||"").split(/\r?\n/g).map(u=>u.split(/\s+/g).reduce((c,l)=>(l.length+o.length>=r||c[c.length-1].length+l.length+1<r?c[c.length-1]+=` ${l}`:c.push(`${o}${l}`),c),[o]).join(`
2
- `)).join(`
3
- `)}),de}var fe,pt;function hs(){return pt||(pt=1,fe=(e,t,o)=>{o=o||t;let r=Math.min(t-o,e-Math.floor(o/2));r<0&&(r=0);let u=Math.min(r+o,t);return {startIndex:r,endIndex:u}}),fe}var pe,mt;function k(){return mt||(mt=1,pe={action:os(),clear:as(),style:ls(),strip:We(),figures:Zt(),lines:us(),wrap:cs(),entriesToDisplay:hs()}),pe}var me,gt;function N(){if(gt)return me;gt=1;let e=Wr,{action:t}=k(),o=es,{beep:r,cursor:u}=M(),c=A();class l extends o{constructor(s={}){super(),this.firstRender=true,this.in=s.stdin||process.stdin,this.out=s.stdout||process.stdout,this.onRender=(s.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 i=["SelectPrompt","MultiselectPrompt"].indexOf(this.constructor.name)>-1,n=(f,d)=>{let p=t(d,i);p===false?this._&&this._(f,d):typeof this[p]=="function"?this[p](d):this.bell();};this.close=()=>{this.out.write(u.show),this.in.removeListener("keypress",n),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",n);}fire(){this.emit("state",{value:this.value,aborted:!!this.aborted,exited:!!this.exited});}bell(){this.out.write(r);}render(){this.onRender(c),this.firstRender&&(this.firstRender=false);}}return me=l,me}var ge,yt;function ds(){if(yt)return ge;yt=1;let e=A(),t=N(),{erase:o,cursor:r}=M(),{style:u,clear:c,lines:l,figures:a}=k();class s extends t{constructor(i={}){super(i),this.transform=u.render(i.style),this.scale=this.transform.scale,this.msg=i.message,this.initial=i.initial||"",this.validator=i.validate||(()=>true),this.value="",this.errorMsg=i.error||"Please Enter A Valid Value",this.cursor=+!!this.initial,this.cursorOffset=0,this.clear=c("",this.out.columns),this.render();}set value(i){!i&&this.initial?(this.placeholder=true,this.rendered=e.gray(this.transform.render(this.initial))):(this.placeholder=false,this.rendered=this.transform.render(i)),this._value=i,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(`
4
- `),this.close();}async validate(){let i=await this.validator(this.value);typeof i=="string"&&(this.errorMsg=i,i=false),this.error=!i;}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(`
5
- `),this.close();}next(){if(!this.placeholder)return this.bell();this.value=this.initial,this.cursor=this.rendered.length,this.fire(),this.render();}moveCursor(i){this.placeholder||(this.cursor=this.cursor+i,this.cursorOffset+=i);}_(i,n){let f=this.value.slice(0,this.cursor),d=this.value.slice(this.cursor);this.value=`${f}${i}${d}`,this.red=false,this.cursor=this.placeholder?0:f.length+1,this.render();}delete(){if(this.isCursorAtStart())return this.bell();let i=this.value.slice(0,this.cursor-1),n=this.value.slice(this.cursor);this.value=`${i}${n}`,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 i=this.value.slice(0,this.cursor),n=this.value.slice(this.cursor+1);this.value=`${i}${n}`,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(r.down(l(this.outputError,this.out.columns)-1)+c(this.outputError,this.out.columns)),this.out.write(c(this.outputText,this.out.columns))),super.render(),this.outputError="",this.outputText=[u.symbol(this.done,this.aborted),e.bold(this.msg),u.delimiter(this.done),this.red?e.red(this.rendered):this.rendered].join(" "),this.error&&(this.outputError+=this.errorMsg.split(`
6
- `).reduce((i,n,f)=>i+`
7
- ${f?" ":a.pointerSmall} ${e.red().italic(n)}`,"")),this.out.write(o.line+r.to(0)+this.outputText+r.save+this.outputError+r.restore+r.move(this.cursorOffset,0)));}}return ge=s,ge}var ye,vt;function fs(){if(vt)return ye;vt=1;let e=A(),t=N(),{style:o,clear:r,figures:u,wrap:c,entriesToDisplay:l}=k(),{cursor:a}=M();class s extends t{constructor(i={}){super(i),this.msg=i.message,this.hint=i.hint||"- Use arrow-keys. Return to submit.",this.warn=i.warn||"- This option is disabled",this.cursor=i.initial||0,this.choices=i.choices.map((n,f)=>(typeof n=="string"&&(n={title:n,value:f}),{title:n&&(n.title||n.value||n),value:n&&(n.value===void 0?f:n.value),description:n&&n.description,selected:n&&n.selected,disabled:n&&n.disabled})),this.optionsPerPage=i.optionsPerPage||10,this.value=(this.choices[this.cursor]||{}).value,this.clear=r("",this.out.columns),this.render();}moveCursor(i){this.cursor=i,this.value=this.choices[i].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(`
8
- `),this.close();}submit(){this.selection.disabled?this.bell():(this.done=true,this.aborted=false,this.fire(),this.render(),this.out.write(`
9
- `),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();}_(i,n){if(i===" ")return this.submit()}get selection(){return this.choices[this.cursor]}render(){if(this.closed)return;this.firstRender?this.out.write(a.hide):this.out.write(r(this.outputText,this.out.columns)),super.render();let{startIndex:i,endIndex:n}=l(this.cursor,this.choices.length,this.optionsPerPage);if(this.outputText=[o.symbol(this.done,this.aborted),e.bold(this.msg),o.delimiter(false),this.done?this.selection.title:this.selection.disabled?e.yellow(this.warn):e.gray(this.hint)].join(" "),!this.done){this.outputText+=`
10
- `;for(let f=i;f<n;f++){let d,p,g="",m=this.choices[f];f===i&&i>0?p=u.arrowUp:f===n-1&&n<this.choices.length?p=u.arrowDown:p=" ",m.disabled?(d=this.cursor===f?e.gray().underline(m.title):e.strikethrough().gray(m.title),p=(this.cursor===f?e.bold().gray(u.pointer)+" ":" ")+p):(d=this.cursor===f?e.cyan().underline(m.title):m.title,p=(this.cursor===f?e.cyan(u.pointer)+" ":" ")+p,m.description&&this.cursor===f&&(g=` - ${m.description}`,(p.length+d.length+g.length>=this.out.columns||m.description.split(/\r?\n/).length>1)&&(g=`
11
- `+c(m.description,{margin:3,width:this.out.columns})))),this.outputText+=`${p} ${d}${e.gray(g)}
12
- `;}}this.out.write(this.outputText);}}return ye=s,ye}var ve,bt;function ps(){if(bt)return ve;bt=1;let e=A(),t=N(),{style:o,clear:r}=k(),{cursor:u,erase:c}=M();class l extends t{constructor(s={}){super(s),this.msg=s.message,this.value=!!s.initial,this.active=s.active||"on",this.inactive=s.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(`
13
- `),this.close();}submit(){this.done=true,this.aborted=false,this.fire(),this.render(),this.out.write(`
14
- `),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();}_(s,h){if(s===" ")this.value=!this.value;else if(s==="1")this.value=true;else if(s==="0")this.value=false;else return this.bell();this.render();}render(){this.closed||(this.firstRender?this.out.write(u.hide):this.out.write(r(this.outputText,this.out.columns)),super.render(),this.outputText=[o.symbol(this.done,this.aborted),e.bold(this.msg),o.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(c.line+u.to(0)+this.outputText));}}return ve=l,ve}var be,wt;function j(){if(wt)return be;wt=1;class e{constructor({token:o,date:r,parts:u,locales:c}){this.token=o,this.date=r||new Date,this.parts=u||[this],this.locales=c||{};}up(){}down(){}next(){let o=this.parts.indexOf(this);return this.parts.find((r,u)=>u>o&&r instanceof e)}setTo(o){}prev(){let o=[].concat(this.parts).reverse(),r=o.indexOf(this);return o.find((u,c)=>c>r&&u instanceof e)}toString(){return String(this.date)}}return be=e,be}var we,xt;function ms(){if(xt)return we;xt=1;let e=j();class t extends e{constructor(r={}){super(r);}up(){this.date.setHours((this.date.getHours()+12)%24);}down(){this.up();}toString(){let r=this.date.getHours()>12?"pm":"am";return /\A/.test(this.token)?r.toUpperCase():r}}return we=t,we}var xe,_t;function gs(){if(_t)return xe;_t=1;let e=j(),t=r=>(r=r%10,r===1?"st":r===2?"nd":r===3?"rd":"th");class o extends e{constructor(u={}){super(u);}up(){this.date.setDate(this.date.getDate()+1);}down(){this.date.setDate(this.date.getDate()-1);}setTo(u){this.date.setDate(parseInt(u.substr(-2)));}toString(){let u=this.date.getDate(),c=this.date.getDay();return this.token==="DD"?String(u).padStart(2,"0"):this.token==="Do"?u+t(u):this.token==="d"?c+1:this.token==="ddd"?this.locales.weekdaysShort[c]:this.token==="dddd"?this.locales.weekdays[c]:u}}return xe=o,xe}var _e,Et;function ys(){if(Et)return _e;Et=1;let e=j();class t extends e{constructor(r={}){super(r);}up(){this.date.setHours(this.date.getHours()+1);}down(){this.date.setHours(this.date.getHours()-1);}setTo(r){this.date.setHours(parseInt(r.substr(-2)));}toString(){let r=this.date.getHours();return /h/.test(this.token)&&(r=r%12||12),this.token.length>1?String(r).padStart(2,"0"):r}}return _e=t,_e}var Ee,St;function vs(){if(St)return Ee;St=1;let e=j();class t extends e{constructor(r={}){super(r);}up(){this.date.setMilliseconds(this.date.getMilliseconds()+1);}down(){this.date.setMilliseconds(this.date.getMilliseconds()-1);}setTo(r){this.date.setMilliseconds(parseInt(r.substr(-this.token.length)));}toString(){return String(this.date.getMilliseconds()).padStart(4,"0").substr(0,this.token.length)}}return Ee=t,Ee}var Se,$t;function bs(){if($t)return Se;$t=1;let e=j();class t extends e{constructor(r={}){super(r);}up(){this.date.setMinutes(this.date.getMinutes()+1);}down(){this.date.setMinutes(this.date.getMinutes()-1);}setTo(r){this.date.setMinutes(parseInt(r.substr(-2)));}toString(){let r=this.date.getMinutes();return this.token.length>1?String(r).padStart(2,"0"):r}}return Se=t,Se}var $e,Ot;function ws(){if(Ot)return $e;Ot=1;let e=j();class t extends e{constructor(r={}){super(r);}up(){this.date.setMonth(this.date.getMonth()+1);}down(){this.date.setMonth(this.date.getMonth()-1);}setTo(r){r=parseInt(r.substr(-2))-1,this.date.setMonth(r<0?0:r);}toString(){let r=this.date.getMonth(),u=this.token.length;return u===2?String(r+1).padStart(2,"0"):u===3?this.locales.monthsShort[r]:u===4?this.locales.months[r]:String(r+1)}}return $e=t,$e}var Oe,Tt;function xs(){if(Tt)return Oe;Tt=1;let e=j();class t extends e{constructor(r={}){super(r);}up(){this.date.setSeconds(this.date.getSeconds()+1);}down(){this.date.setSeconds(this.date.getSeconds()-1);}setTo(r){this.date.setSeconds(parseInt(r.substr(-2)));}toString(){let r=this.date.getSeconds();return this.token.length>1?String(r).padStart(2,"0"):r}}return Oe=t,Oe}var Te,Ct;function _s(){if(Ct)return Te;Ct=1;let e=j();class t extends e{constructor(r={}){super(r);}up(){this.date.setFullYear(this.date.getFullYear()+1);}down(){this.date.setFullYear(this.date.getFullYear()-1);}setTo(r){this.date.setFullYear(r.substr(-4));}toString(){let r=String(this.date.getFullYear()).padStart(4,"0");return this.token.length===2?r.substr(-2):r}}return Te=t,Te}var Ce,At;function Es(){return At||(At=1,Ce={DatePart:j(),Meridiem:ms(),Day:gs(),Hours:ys(),Milliseconds:vs(),Minutes:bs(),Month:ws(),Seconds:xs(),Year:_s()}),Ce}var Ae,Mt;function Ss(){if(Mt)return Ae;Mt=1;let e=A(),t=N(),{style:o,clear:r,figures:u}=k(),{erase:c,cursor:l}=M(),{DatePart:a,Meridiem:s,Day:h,Hours:i,Milliseconds:n,Minutes:f,Month:d,Seconds:p,Year:g}=Es(),m=/\\(.)|"((?:\\["\\]|[^"])+)"|(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,b={1:({token:y})=>y.replace(/\\(.)/g,"$1"),2:y=>new h(y),3:y=>new d(y),4:y=>new g(y),5:y=>new s(y),6:y=>new i(y),7:y=>new f(y),8:y=>new p(y),9:y=>new n(y)},x={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(v={}){super(v),this.msg=v.message,this.cursor=0,this.typed="",this.locales=Object.assign(x,v.locales),this._date=v.initial||new Date,this.errorMsg=v.error||"Please Enter A Valid Value",this.validator=v.validate||(()=>true),this.mask=v.mask||"YYYY-MM-DD HH:mm:ss",this.clear=r("",this.out.columns),this.render();}get value(){return this.date}get date(){return this._date}set date(v){v&&this._date.setTime(v.getTime());}set mask(v){let E;for(this.parts=[];E=m.exec(v);){let S=E.shift(),T=E.findIndex(z=>z!=null);this.parts.push(T in b?b[T]({token:E[T]||S,date:this.date,parts:this.parts,locales:this.locales}):E[T]||S);}let $=this.parts.reduce((S,T)=>(typeof T=="string"&&typeof S[S.length-1]=="string"?S[S.length-1]+=T:S.push(T),S),[]);this.parts.splice(0),this.parts.push(...$),this.reset();}moveCursor(v){this.typed="",this.cursor=v,this.fire();}reset(){this.moveCursor(this.parts.findIndex(v=>v instanceof a)),this.fire(),this.render();}exit(){this.abort();}abort(){this.done=this.aborted=true,this.error=false,this.fire(),this.render(),this.out.write(`
15
- `),this.close();}async validate(){let v=await this.validator(this.value);typeof v=="string"&&(this.errorMsg=v,v=false),this.error=!v;}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(`
16
- `),this.close();}up(){this.typed="",this.parts[this.cursor].up(),this.render();}down(){this.typed="",this.parts[this.cursor].down(),this.render();}left(){let v=this.parts[this.cursor].prev();if(v==null)return this.bell();this.moveCursor(this.parts.indexOf(v)),this.render();}right(){let v=this.parts[this.cursor].next();if(v==null)return this.bell();this.moveCursor(this.parts.indexOf(v)),this.render();}next(){let v=this.parts[this.cursor].next();this.moveCursor(v?this.parts.indexOf(v):this.parts.findIndex(E=>E instanceof a)),this.render();}_(v){/\d/.test(v)&&(this.typed+=v,this.parts[this.cursor].setTo(this.typed),this.render());}render(){this.closed||(this.firstRender?this.out.write(l.hide):this.out.write(r(this.outputText,this.out.columns)),super.render(),this.outputText=[o.symbol(this.done,this.aborted),e.bold(this.msg),o.delimiter(false),this.parts.reduce((v,E,$)=>v.concat($===this.cursor&&!this.done?e.cyan().underline(E.toString()):E),[]).join("")].join(" "),this.error&&(this.outputText+=this.errorMsg.split(`
17
- `).reduce((v,E,$)=>v+`
18
- ${$?" ":u.pointerSmall} ${e.red().italic(E)}`,"")),this.out.write(c.line+l.to(0)+this.outputText));}}return Ae=w,Ae}var Me,Pt;function $s(){if(Pt)return Me;Pt=1;let e=A(),t=N(),{cursor:o,erase:r}=M(),{style:u,figures:c,clear:l,lines:a}=k(),s=/[0-9]/,h=f=>f!==void 0,i=(f,d)=>{let p=Math.pow(10,d);return Math.round(f*p)/p};class n extends t{constructor(d={}){super(d),this.transform=u.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(`${i(d,this.round)}`),this._value=i(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||s.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(`
19
- `),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(`
20
- `),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 g=Date.now();if(g-this.lastHit>1e3&&(this.typed=""),this.typed+=d,this.lastHit=g,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(o.down(a(this.outputError,this.out.columns)-1)+l(this.outputError,this.out.columns)),this.out.write(l(this.outputText,this.out.columns))),super.render(),this.outputError="",this.outputText=[u.symbol(this.done,this.aborted),e.bold(this.msg),u.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(`
21
- `).reduce((d,p,g)=>d+`
22
- ${g?" ":c.pointerSmall} ${e.red().italic(p)}`,"")),this.out.write(r.line+o.to(0)+this.outputText+o.save+this.outputError+o.restore));}}return Me=n,Me}var Pe,Rt;function Qt(){if(Rt)return Pe;Rt=1;let e=A(),{cursor:t}=M(),o=N(),{clear:r,figures:u,style:c,wrap:l,entriesToDisplay:a}=k();class s extends o{constructor(i={}){super(i),this.msg=i.message,this.cursor=i.cursor||0,this.scrollIndex=i.cursor||0,this.hint=i.hint||"",this.warn=i.warn||"- This option is disabled -",this.minSelected=i.min,this.showMinError=false,this.maxChoices=i.max,this.instructions=i.instructions,this.optionsPerPage=i.optionsPerPage||10,this.value=i.choices.map((n,f)=>(typeof n=="string"&&(n={title:n,value:f}),{title:n&&(n.title||n.value||n),description:n&&n.description,value:n&&(n.value===void 0?f:n.value),selected:n&&n.selected,disabled:n&&n.disabled})),this.clear=r("",this.out.columns),i.overrideRender||this.render();}reset(){this.value.map(i=>!i.selected),this.cursor=0,this.fire(),this.render();}selected(){return this.value.filter(i=>i.selected)}exit(){this.abort();}abort(){this.done=this.aborted=true,this.fire(),this.render(),this.out.write(`
23
- `),this.close();}submit(){let i=this.value.filter(n=>n.selected);this.minSelected&&i.length<this.minSelected?(this.showMinError=true,this.render()):(this.done=true,this.aborted=false,this.fire(),this.render(),this.out.write(`
24
- `),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(i=>i.selected).length>=this.maxChoices)return this.bell();this.value[this.cursor].selected=true,this.render();}handleSpaceToggle(){let i=this.value[this.cursor];if(i.selected)i.selected=false,this.render();else {if(i.disabled||this.value.filter(n=>n.selected).length>=this.maxChoices)return this.bell();i.selected=true,this.render();}}toggleAll(){if(this.maxChoices!==void 0||this.value[this.cursor].disabled)return this.bell();let i=!this.value[this.cursor].selected;this.value.filter(n=>!n.disabled).forEach(n=>n.selected=i),this.render();}_(i,n){if(i===" ")this.handleSpaceToggle();else if(i==="a")this.toggleAll();else return this.bell()}renderInstructions(){return this.instructions===void 0||this.instructions?typeof this.instructions=="string"?this.instructions:`
25
- Instructions:
26
- ${u.arrowUp}/${u.arrowDown}: Highlight option
27
- ${u.arrowLeft}/${u.arrowRight}/[space]: Toggle selection
28
- `+(this.maxChoices===void 0?` a: Toggle all
29
- `:"")+" enter/return: Complete answer":""}renderOption(i,n,f,d){let p=(n.selected?e.green(u.radioOn):u.radioOff)+" "+d+" ",g,m;return n.disabled?g=i===f?e.gray().underline(n.title):e.strikethrough().gray(n.title):(g=i===f?e.cyan().underline(n.title):n.title,i===f&&n.description&&(m=` - ${n.description}`,(p.length+g.length+m.length>=this.out.columns||n.description.split(/\r?\n/).length>1)&&(m=`
30
- `+l(n.description,{margin:p.length,width:this.out.columns})))),p+g+e.gray(m||"")}paginateOptions(i){if(i.length===0)return e.red("No matches for this query.");let{startIndex:n,endIndex:f}=a(this.cursor,i.length,this.optionsPerPage),d,p=[];for(let g=n;g<f;g++)g===n&&n>0?d=u.arrowUp:g===f-1&&f<i.length?d=u.arrowDown:d=" ",p.push(this.renderOption(this.cursor,i[g],g,d));return `
31
- `+p.join(`
32
- `)}renderOptions(i){return this.done?"":this.paginateOptions(i)}renderDoneOrInstructions(){if(this.done)return this.value.filter(n=>n.selected).map(n=>n.title).join(", ");let i=[e.gray(this.hint),this.renderInstructions()];return this.value[this.cursor].disabled&&i.push(e.yellow(this.warn)),i.join(" ")}render(){if(this.closed)return;this.firstRender&&this.out.write(t.hide),super.render();let i=[c.symbol(this.done,this.aborted),e.bold(this.msg),c.delimiter(false),this.renderDoneOrInstructions()].join(" ");this.showMinError&&(i+=e.red(`You must select a minimum of ${this.minSelected} choices.`),this.showMinError=false),i+=this.renderOptions(this.value),this.out.write(this.clear+i),this.clear=r(i,this.out.columns);}}return Pe=s,Pe}var Re,kt;function Os(){if(kt)return Re;kt=1;let e=A(),t=N(),{erase:o,cursor:r}=M(),{style:u,clear:c,figures:l,wrap:a,entriesToDisplay:s}=k(),h=(d,p)=>d[p]&&(d[p].value||d[p].title||d[p]),i=(d,p)=>d[p]&&(d[p].title||d[p].value||d[p]),n=(d,p)=>{let g=d.findIndex(m=>m.value===p||m.title===p);return g>-1?g: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:n(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=u.render(p.style),this.scale=this.transform.scale,this.render=this.render.bind(this),this.complete=this.complete.bind(this),this.clear=c("",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 g=this.completing=this.suggest(this.input,this.choices),m=await g;if(this.completing!==g)return;this.suggestions=m.map((x,w,y)=>({title:i(y,w),value:h(y,w),description:x.description})),this.completing=false;let b=Math.max(m.length-1,0);this.moveSelect(Math.min(b,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(`
33
- `),this.close());}abort(){this.done=this.aborted=true,this.exited=false,this.fire(),this.render(),this.out.write(`
34
- `),this.close();}submit(){this.done=true,this.aborted=this.exited=false,this.fire(),this.render(),this.out.write(`
35
- `),this.close();}_(p,g){let m=this.input.slice(0,this.cursor),b=this.input.slice(this.cursor);this.input=`${m}${p}${b}`,this.cursor=m.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),g=this.input.slice(this.cursor);this.input=`${p}${g}`,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),g=this.input.slice(this.cursor+1);this.input=`${p}${g}`,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,g,m,b){let x,w=m?l.arrowUp:b?l.arrowDown:" ",y=g?e.cyan().underline(p.title):p.title;return w=(g?e.cyan(l.pointer)+" ":" ")+w,p.description&&(x=` - ${p.description}`,(w.length+y.length+x.length>=this.out.columns||p.description.split(/\r?\n/).length>1)&&(x=`
36
- `+a(p.description,{margin:3,width:this.out.columns}))),w+" "+y+e.gray(x||"")}render(){if(this.closed)return;this.firstRender?this.out.write(r.hide):this.out.write(c(this.outputText,this.out.columns)),super.render();let{startIndex:p,endIndex:g}=s(this.select,this.choices.length,this.limit);if(this.outputText=[u.symbol(this.done,this.aborted,this.exited),e.bold(this.msg),u.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 m=this.suggestions.slice(p,g).map((b,x)=>this.renderOption(b,this.select===x+p,x===0&&p>0,x+p===g-1&&g<this.choices.length)).join(`
37
- `);this.outputText+=`
38
- `+(m||e.gray(this.fallback.title));}this.out.write(o.line+r.to(0)+this.outputText);}}return Re=f,Re}var ke,jt;function Ts(){if(jt)return ke;jt=1;let e=A(),{cursor:t}=M(),o=Qt(),{clear:r,style:u,figures:c}=k();class l extends o{constructor(s={}){s.overrideRender=true,super(s),this.inputValue="",this.clear=r("",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(s=>s.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 s=this.filteredOptions[this.cursor];this.filteredOptions=this.value.filter(i=>this.inputValue?!!(typeof i.title=="string"&&i.title.toLowerCase().includes(this.inputValue.toLowerCase())||typeof i.value=="string"&&i.value.toLowerCase().includes(this.inputValue.toLowerCase())):true);let h=this.filteredOptions.findIndex(i=>i===s);this.cursor=h<0?0:h,this.render();}handleSpaceToggle(){let s=this.filteredOptions[this.cursor];if(s.selected)s.selected=false,this.render();else {if(s.disabled||this.value.filter(h=>h.selected).length>=this.maxChoices)return this.bell();s.selected=true,this.render();}}handleInputChange(s){this.inputValue=this.inputValue+s,this.updateFilteredOptions();}_(s,h){s===" "?this.handleSpaceToggle():this.handleInputChange(s);}renderInstructions(){return this.instructions===void 0||this.instructions?typeof this.instructions=="string"?this.instructions:`
39
- Instructions:
40
- ${c.arrowUp}/${c.arrowDown}: Highlight option
41
- ${c.arrowLeft}/${c.arrowRight}/[space]: Toggle selection
42
- [a,b,c]/delete: Filter choices
43
- enter/return: Complete answer
44
- `:""}renderCurrentInput(){return `
45
- Filtered results for: ${this.inputValue?this.inputValue:e.gray("Enter something to filter")}
46
- `}renderOption(s,h,i,n){let f=(h.selected?e.green(c.radioOn):c.radioOff)+" "+n+" ",d;return h.disabled?d=s===i?e.gray().underline(h.title):e.strikethrough().gray(h.title):d=s===i?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 s=[e.gray(this.hint),this.renderInstructions(),this.renderCurrentInput()];return this.filteredOptions.length&&this.filteredOptions[this.cursor].disabled&&s.push(e.yellow(this.warn)),s.join(" ")}render(){if(this.closed)return;this.firstRender&&this.out.write(t.hide),super.render();let s=[u.symbol(this.done,this.aborted),e.bold(this.msg),u.delimiter(false),this.renderDoneOrInstructions()].join(" ");this.showMinError&&(s+=e.red(`You must select a minimum of ${this.minSelected} choices.`),this.showMinError=false),s+=this.renderOptions(this.filteredOptions),this.out.write(this.clear+s),this.clear=r(s,this.out.columns);}}return ke=l,ke}var je,It;function Cs(){if(It)return je;It=1;let e=A(),t=N(),{style:o,clear:r}=k(),{erase:u,cursor:c}=M();class l extends t{constructor(s={}){super(s),this.msg=s.message,this.value=s.initial,this.initialValue=!!s.initial,this.yesMsg=s.yes||"yes",this.yesOption=s.yesOption||"(Y/n)",this.noMsg=s.no||"no",this.noOption=s.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(`
47
- `),this.close();}submit(){this.value=this.value||false,this.done=true,this.aborted=false,this.fire(),this.render(),this.out.write(`
48
- `),this.close();}_(s,h){return s.toLowerCase()==="y"?(this.value=true,this.submit()):s.toLowerCase()==="n"?(this.value=false,this.submit()):this.bell()}render(){this.closed||(this.firstRender?this.out.write(c.hide):this.out.write(r(this.outputText,this.out.columns)),super.render(),this.outputText=[o.symbol(this.done,this.aborted),e.bold(this.msg),o.delimiter(this.done),this.done?this.value?this.yesMsg:this.noMsg:e.gray(this.initialValue?this.yesOption:this.noOption)].join(" "),this.out.write(u.line+c.to(0)+this.outputText));}}return je=l,je}var Ie,qt;function As(){return qt||(qt=1,Ie={TextPrompt:ds(),SelectPrompt:fs(),TogglePrompt:ps(),DatePrompt:Ss(),NumberPrompt:$s(),MultiselectPrompt:Qt(),AutocompletePrompt:Os(),AutocompleteMultiselectPrompt:Ts(),ConfirmPrompt:Cs()}),Ie}var Nt;function Ms(){return Nt||(Nt=1,function(e){let t=e,o=As(),r=l=>l;function u(l,a,s={}){return new Promise((h,i)=>{let n=new o[l](a),f=s.onAbort||r,d=s.onSubmit||r,p=s.onExit||r;n.on("state",a.onState||r),n.on("submit",g=>h(d(g))),n.on("exit",g=>h(p(g))),n.on("abort",g=>i(f(g)));})}t.text=l=>u("TextPrompt",l),t.password=l=>(l.style="password",t.text(l)),t.invisible=l=>(l.style="invisible",t.text(l)),t.number=l=>u("NumberPrompt",l),t.date=l=>u("DatePrompt",l),t.confirm=l=>u("ConfirmPrompt",l),t.list=l=>{let a=l.separator||",";return u("TextPrompt",l,{onSubmit:s=>s.split(a).map(h=>h.trim())})},t.toggle=l=>u("TogglePrompt",l),t.select=l=>u("SelectPrompt",l),t.multiselect=l=>{l.choices=[].concat(l.choices||[]);let a=s=>s.filter(h=>h.selected).map(h=>h.value);return u("MultiselectPrompt",l,{onAbort:a,onSubmit:a})},t.autocompleteMultiselect=l=>{l.choices=[].concat(l.choices||[]);let a=s=>s.filter(h=>h.selected).map(h=>h.value);return u("AutocompleteMultiselectPrompt",l,{onAbort:a,onSubmit:a})};let c=(l,a)=>Promise.resolve(a.filter(s=>s.title.slice(0,l.length).toLowerCase()===l.toLowerCase()));t.autocomplete=l=>(l.suggest=l.suggest||c,l.choices=[].concat(l.choices||[]),u("AutocompletePrompt",l));}(se)),se}var qe,Dt;function Ps(){if(Dt)return qe;Dt=1;let e=Ms(),t=["suggest","format","onState","validate","onRender","type"],o=()=>{};async function r(a=[],{onSubmit:s=o,onCancel:h=o}={}){let i={},n=r._override||{};a=[].concat(a);let f,d,p,g,m,b,x=async(w,y,v=false)=>{if(!(!v&&w.validate&&w.validate(y)!==true))return w.format?await w.format(y,i):y};for(d of a)if({name:g,type:m}=d,typeof m=="function"&&(m=await m(f,{...i},d),d.type=m),!!m){for(let w in d){if(t.includes(w))continue;let y=d[w];d[w]=typeof y=="function"?await y(f,{...i},b):y;}if(b=d,typeof d.message!="string")throw new Error("prompt message is required");if({name:g,type:m}=d,e[m]===void 0)throw new Error(`prompt type (${m}) is not defined`);if(n[d.name]!==void 0&&(f=await x(d,n[d.name]),f!==void 0)){i[g]=f;continue}try{f=r._injected?u(r._injected,d.initial):await e[m](d),i[g]=f=await x(d,f,!0),p=await s(d,f,i);}catch{p=!await h(d,i);}if(p)return i}return i}function u(a,s){let h=a.shift();if(h instanceof Error)throw h;return h===void 0?s:h}function c(a){r._injected=(r._injected||[]).concat(a);}function l(a){r._override=Object.assign({},a);}return qe=Object.assign(r,{prompt:r,prompts:e,inject:c,override:l}),qe}var Ne,Lt;function Rs(){return Lt||(Lt=1,Ne=Ps()),Ne}var ks=Rs(),js=Ve(ks),Ye=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 B=globalThis.navigator?.userAgentData?.platform;B==="macOS"||globalThis.navigator?.platform==="MacIntel"||globalThis.navigator?.userAgent?.includes(" Mac ")===true||globalThis.process?.platform;B==="Windows"||globalThis.navigator?.platform==="Win32"||globalThis.process?.platform;B==="Linux"||globalThis.navigator?.platform?.startsWith("Linux")===true||globalThis.navigator?.userAgent?.includes(" Linux ")===true||globalThis.process?.platform;B==="Android"||globalThis.navigator?.platform==="Android"||globalThis.navigator?.userAgent?.includes(" Android ")===true||globalThis.process?.platform;var Ft="\x1B]",Ht="\x07",U=";";!Ye&&R.env.TERM_PROGRAM;!Ye&&R.platform;Ye||R.cwd;var Is=(e,t)=>[Ft,"8",U,U,t,Ht,e,Ft,"8",U,U,Ht].join(""),De,Gt;function er(){return Gt||(Gt=1,De=(e,t=process.argv)=>{let o=e.startsWith("-")?"":e.length===1?"-":"--",r=t.indexOf(o+e),u=t.indexOf("--");return r!==-1&&(u===-1||r<u)}),De}var Le,Vt;function qs(){if(Vt)return Le;Vt=1;let e=ts,t=rs,o=er(),{env:r}=process,u;o("no-color")||o("no-colors")||o("color=false")||o("color=never")?u=0:(o("color")||o("colors")||o("color=true")||o("color=always"))&&(u=1),"FORCE_COLOR"in r&&(r.FORCE_COLOR==="true"?u=1:r.FORCE_COLOR==="false"?u=0:u=r.FORCE_COLOR.length===0?1:Math.min(parseInt(r.FORCE_COLOR,10),3));function c(s){return s===0?false:{level:s,hasBasic:true,has256:s>=2,has16m:s>=3}}function l(s,h){if(u===0)return 0;if(o("color=16m")||o("color=full")||o("color=truecolor"))return 3;if(o("color=256"))return 2;if(s&&!h&&u===void 0)return 0;let i=u||0;if(r.TERM==="dumb")return i;if(process.platform==="win32"){let n=e.release().split(".");return Number(n[0])>=10&&Number(n[2])>=10586?Number(n[2])>=14931?3:2:1}if("CI"in r)return ["TRAVIS","CIRCLECI","APPVEYOR","GITLAB_CI","GITHUB_ACTIONS","BUILDKITE"].some(n=>n in r)||r.CI_NAME==="codeship"?1:i;if("TEAMCITY_VERSION"in r)return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(r.TEAMCITY_VERSION)?1:0;if(r.COLORTERM==="truecolor")return 3;if("TERM_PROGRAM"in r){let n=parseInt((r.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(r.TERM_PROGRAM){case "iTerm.app":return n>=3?3:2;case "Apple_Terminal":return 2}}return /-256(color)?$/i.test(r.TERM)?2:/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(r.TERM)||"COLORTERM"in r?1:i}function a(s){let h=l(s,s&&s.isTTY);return c(h)}return Le={supportsColor:a,stdout:c(l(true,t.isatty(1))),stderr:c(l(true,t.isatty(2)))},Le}var Fe,Wt;function Ns(){if(Wt)return Fe;Wt=1;let e=qs(),t=er();function o(u){if(/^\d{3,4}$/.test(u)){let l=/(\d{1,2})(\d{2})/.exec(u)||[];return {major:0,minor:parseInt(l[1],10),patch:parseInt(l[2],10)}}let c=(u||"").split(".").map(l=>parseInt(l,10));return {major:c[0],minor:c[1],patch:c[2]}}function r(u){let{CI:c,FORCE_HYPERLINK:l,NETLIFY:a,TEAMCITY_VERSION:s,TERM_PROGRAM:h,TERM_PROGRAM_VERSION:i,VTE_VERSION:n,TERM:f}=process.env;if(l)return !(l.length>0&&parseInt(l,10)===0);if(t("no-hyperlink")||t("no-hyperlinks")||t("hyperlink=false")||t("hyperlink=never"))return false;if(t("hyperlink=true")||t("hyperlink=always")||a)return true;if(!e.supportsColor(u)||u&&!u.isTTY)return false;if("WT_SESSION"in process.env)return true;if(process.platform==="win32"||c||s)return false;if(h){let d=o(i||"");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(n){if(n==="0.50.0")return false;let d=o(n);return d.major>0||d.minor>=50}switch(f){case "alacritty":return true}return false}return Fe={supportsHyperlink:r,stdout:r(process.stdout),stderr:r(process.stderr)},Fe}var Ds=Ns(),Ue=Ve(Ds);function W(e,t,{target:o="stdout",...r}={}){return Ue[o]?Is(e,t):r.fallback===false?e:typeof r.fallback=="function"?r.fallback(e,t):`${e} (\u200B${t}\u200B)`}W.isSupported=Ue.stdout;W.stderr=(e,t,o={})=>W(e,t,{target:"stderr",...o});W.stderr.isSupported=Ue.stderr;var C={},D={},Yt;function Ls(){if(Yt)return D;Yt=1,Object.defineProperty(D,"__esModule",{value:true}),D.sync=D.isexe=void 0;let e=Kt,t=Qe,o=async(l,a={})=>{let{ignoreErrors:s=false}=a;try{return u(await(0,t.stat)(l),a)}catch(h){let i=h;if(s||i.code==="EACCES")return false;throw i}};D.isexe=o;let r=(l,a={})=>{let{ignoreErrors:s=false}=a;try{return u((0,e.statSync)(l),a)}catch(h){let i=h;if(s||i.code==="EACCES")return false;throw i}};D.sync=r;let u=(l,a)=>l.isFile()&&c(l,a),c=(l,a)=>{let s=a.uid??process.getuid?.(),h=a.groups??process.getgroups?.()??[],i=a.gid??process.getgid?.()??h[0];if(s===void 0||i===void 0)throw new Error("cannot get uid or gid");let n=new Set([i,...h]),f=l.mode,d=l.uid,p=l.gid,g=parseInt("100",8),m=parseInt("010",8),b=parseInt("001",8),x=g|m;return !!(f&b||f&m&&n.has(p)||f&g&&d===s||f&x&&s===0)};return D}var L={},Ut;function Fs(){if(Ut)return L;Ut=1,Object.defineProperty(L,"__esModule",{value:true}),L.sync=L.isexe=void 0;let e=Kt,t=Qe,o=async(l,a={})=>{let{ignoreErrors:s=false}=a;try{return c(await(0,t.stat)(l),l,a)}catch(h){let i=h;if(s||i.code==="EACCES")return false;throw i}};L.isexe=o;let r=(l,a={})=>{let{ignoreErrors:s=false}=a;try{return c((0,e.statSync)(l),l,a)}catch(h){let i=h;if(s||i.code==="EACCES")return false;throw i}};L.sync=r;let u=(l,a)=>{let{pathExt:s=process.env.PATHEXT||""}=a,h=s.split(";");if(h.indexOf("")!==-1)return true;for(let i=0;i<h.length;i++){let n=h[i].toLowerCase(),f=l.substring(l.length-n.length).toLowerCase();if(n&&f===n)return true}return false},c=(l,a,s)=>l.isFile()&&u(a,s);return L}var He={},Bt;function Hs(){return Bt||(Bt=1,Object.defineProperty(He,"__esModule",{value:true})),He}var zt;function Gs(){return zt||(zt=1,function(e){var t=C&&C.__createBinding||(Object.create?function(h,i,n,f){f===void 0&&(f=n);var d=Object.getOwnPropertyDescriptor(i,n);(!d||("get"in d?!i.__esModule:d.writable||d.configurable))&&(d={enumerable:true,get:function(){return i[n]}}),Object.defineProperty(h,f,d);}:function(h,i,n,f){f===void 0&&(f=n),h[f]=i[n];}),o=C&&C.__setModuleDefault||(Object.create?function(h,i){Object.defineProperty(h,"default",{enumerable:true,value:i});}:function(h,i){h.default=i;}),r=C&&C.__importStar||function(h){if(h&&h.__esModule)return h;var i={};if(h!=null)for(var n in h)n!=="default"&&Object.prototype.hasOwnProperty.call(h,n)&&t(i,h,n);return o(i,h),i},u=C&&C.__exportStar||function(h,i){for(var n in h)n!=="default"&&!Object.prototype.hasOwnProperty.call(i,n)&&t(i,h,n);};Object.defineProperty(e,"__esModule",{value:true}),e.sync=e.isexe=e.posix=e.win32=void 0;let c=r(Ls());e.posix=c;let l=r(Fs());e.win32=l,u(Hs(),e);let s=(process.env._ISEXE_TEST_PLATFORM_||process.platform)==="win32"?l:c;e.isexe=s.isexe,e.sync=s.sync;}(C)),C}var Ge,Jt;function Vs(){if(Jt)return Ge;Jt=1;let{isexe:e,sync:t}=Gs(),{join:o,delimiter:r,sep:u,posix:c}=I,l=process.platform==="win32",a=new RegExp(`[${c.sep}${u===c.sep?"":u}]`.replace(/(\\)/g,"\\$1")),s=new RegExp(`^\\.${a.source}`),h=p=>Object.assign(new Error(`not found: ${p}`),{code:"ENOENT"}),i=(p,{path:g=process.env.PATH,pathExt:m=process.env.PATHEXT,delimiter:b=r})=>{let x=p.match(a)?[""]:[...l?[process.cwd()]:[],...(g||"").split(b)];if(l){let w=m||[".EXE",".CMD",".BAT",".COM"].join(b),y=w.split(b).flatMap(v=>[v,v.toLowerCase()]);return p.includes(".")&&y[0]!==""&&y.unshift(""),{pathEnv:x,pathExt:y,pathExtExe:w}}return {pathEnv:x,pathExt:[""]}},n=(p,g)=>{let m=/^".*"$/.test(p)?p.slice(1,-1):p;return (!m&&s.test(g)?g.slice(0,2):"")+o(m,g)},f=async(p,g={})=>{let{pathEnv:m,pathExt:b,pathExtExe:x}=i(p,g),w=[];for(let y of m){let v=n(y,p);for(let E of b){let $=v+E;if(await e($,{pathExt:x,ignoreErrors:true})){if(!g.all)return $;w.push($);}}}if(g.all&&w.length)return w;if(g.nothrow)return null;throw h(p)},d=(p,g={})=>{let{pathEnv:m,pathExt:b,pathExtExe:x}=i(p,g),w=[];for(let y of m){let v=n(y,p);for(let E of b){let $=v+E;if(t($,{pathExt:x,ignoreErrors:true})){if(!g.all)return $;w.push($);}}}if(g.all&&w.length)return w;if(g.nothrow)return null;throw h(p)};return Ge=f,f.sync=d,Ge}var Ws=Vs(),Ys=Ve(Ws);join(ts.tmpdir(),"antfu-ni");function tr(e){return Ys.sync(e,{nothrow:true})!==null}async function Be({autoInstall:e,programmatic:t,cwd:o}={}){let{name:r,agent:u,version:c}=await ee({cwd:o,onUnknown:l=>{t||console.warn("[ni] Unknown packageManager:",l);}})||{};if(r&&!tr(r)&&!t){if(!e){console.warn(`[ni] Detected ${r} but it doesn't seem to be installed.
49
- `),R.env.CI&&R.exit(1);let l=W(r,Xe[r]),{tryInstall:a}=await js({name:"tryInstall",type:"confirm",message:`Would you like to globally install ${l}?`});a||R.exit(1);}await te("npm",["i","-g",`${r}${c?`@${c}`:""}`],{nodeOptions:{stdio:"inherit",cwd:o},throwOnError:true});}return u}R.env.NI_CONFIG_FILE;var Bs=R.platform==="win32"?R.env.USERPROFILE:R.env.HOME;I.join(Bs||"~/",".nirc");async function zs(e,{withFallback:t}={withFallback:false}){let o=await Be({programmatic:true,cwd:e});if(o==="yarn@berry")return "yarn";if(o==="pnpm@6")return "pnpm";if(o==="bun")return "bun";if(o==="deno")return "deno";if(!t)return o??"npm";let r=process.env.npm_config_user_agent||"";return r.startsWith("yarn")?"yarn":r.startsWith("pnpm")?"pnpm":r.startsWith("bun")?"bun":"npm"}async function rr(e){let t=await zs(e);return t==="pnpm"?"pnpm dlx":t==="bun"?"bunx":"npx"}var Js="shadcn@latest";async function G(e){return `${await rr(process.cwd())} ${Js} ${e}`}async function V(e=process.cwd()){return {registries:(await da(e,{useCache:false})).registries}}function ze(e,t){let{query:o,registries:r}=t||{},u=e.items.map(s=>{let h=[`- ${s.name}`];return s.type&&h.push(`(${s.type})`),s.description&&h.push(`- ${s.description}`),s.registry&&h.push(`[${s.registry}]`),h.push(`
50
- Add command: \`${G(`add ${s.addCommandArgument}`)}\``),h.join(" ")}),c=`Found ${e.pagination.total} items`;o&&(c+=` matching "${o}"`),r&&r.length>0&&(c+=` in registries ${r.join(", ")}`),c+=":";let l=`Showing items ${e.pagination.offset+1}-${Math.min(e.pagination.offset+e.pagination.limit,e.pagination.total)} of ${e.pagination.total}:`,a=`${c}
51
-
52
- ${l}
53
-
54
- ${u.join(`
55
-
56
- `)}`;return e.pagination.hasMore&&(a+=`
57
-
58
- More items available. Use offset: ${e.pagination.offset+e.pagination.limit} to see the next page.`),a}function sr(e){return e.map(t=>[`## ${t.name}`,t.description?`
59
- ${t.description}
60
- `:"",t.type?`**Type:** ${t.type}`:"",t.files&&t.files.length>0?`**Files:** ${t.files.length} file(s)`:"",t.dependencies&&t.dependencies.length>0?`**Dependencies:** ${t.dependencies.join(", ")}`:"",t.devDependencies&&t.devDependencies.length>0?`**Dev Dependencies:** ${t.devDependencies.join(", ")}`:""].filter(Boolean).join(`
61
- `))}function ir(e,t){let o=e.map(u=>{let c=[`## Example: ${u.name}`,u.description?`
62
- ${u.description}
63
- `:""];return u.files?.length&&u.files.forEach(l=>{l.content&&(c.push(`### Code (${l.path}):
64
- `),c.push("```tsx"),c.push(l.content),c.push("```"));}),c.filter(Boolean).join(`
65
- `)});return `# Usage Examples
66
-
67
- Found ${e.length} example${e.length>1?"s":""} matching "${t}":
68
- `+o.join(`
69
-
70
- ---
71
-
72
- `)}var nr=new Server({name:"shadcn",version:"1.0.0"},{capabilities:{resources:{},tools:{}}});nr.setRequestHandler(ListToolsRequestSchema,async()=>({tools:[{name:"get_project_registries",description:"Get configured registry names from components.json - Returns error if no components.json exists (use init_project to create one)",inputSchema:zodToJsonSchema(z.object({}))},{name:"list_items_in_registries",description:"List items from registries (requires components.json - use init_project if missing)",inputSchema:zodToJsonSchema(z.object({registries:z.array(z.string()).describe("Array of registry names to search (e.g., ['@shadcn', '@acme'])"),limit:z.number().optional().describe("Maximum number of items to return"),offset:z.number().optional().describe("Number of items to skip for pagination")}))},{name:"search_items_in_registries",description:"Search for components in registries using fuzzy matching (requires components.json). After finding an item, use get_item_examples_from_registries to see usage examples.",inputSchema:zodToJsonSchema(z.object({registries:z.array(z.string()).describe("Array of registry names to search (e.g., ['@shadcn', '@acme'])"),query:z.string().describe("Search query string for fuzzy matching against item names and descriptions"),limit:z.number().optional().describe("Maximum number of items to return"),offset:z.number().optional().describe("Number of items to skip for pagination")}))},{name:"view_items_in_registries",description:"View detailed information about specific registry items including the name, description, type and files content. For usage examples, use get_item_examples_from_registries instead.",inputSchema:zodToJsonSchema(z.object({items:z.array(z.string()).describe("Array of item names with registry prefix (e.g., ['@shadcn/button', '@shadcn/card'])")}))},{name:"get_item_examples_from_registries",description:"Find usage examples and demos with their complete code. Search for patterns like 'accordion-demo', 'button example', 'card-demo', etc. Returns full implementation code with dependencies.",inputSchema:zodToJsonSchema(z.object({registries:z.array(z.string()).describe("Array of registry names to search (e.g., ['@shadcn', '@acme'])"),query:z.string().describe("Search query for examples (e.g., 'accordion-demo', 'button demo', 'card example', 'tooltip-demo', 'example-booking-form', 'example-hero'). Common patterns: '{item-name}-demo', '{item-name} example', 'example {item-name}'")}))},{name:"get_add_command_for_items",description:"Get the shadcn CLI add command for specific items in a registry. This is useful for adding one or more components to your project.",inputSchema:zodToJsonSchema(z.object({items:z.array(z.string()).describe("Array of items to get the add command for prefixed with the registry name (e.g., ['@shadcn/button', '@shadcn/card'])")}))},{name:"get_audit_checklist",description:"After creating new components or generating new code files, use this tool for a quick checklist to verify that everything is working as expected. Make sure to run the tool after all required steps have been completed.",inputSchema:zodToJsonSchema(z.object({}))}]}));nr.setRequestHandler(CallToolRequestSchema,async e=>{try{if(!e.params.arguments)throw new Error("No tool arguments provided.");switch(e.params.name){case "get_project_registries":{let t=await V(process.cwd());return t?.registries?{content:[{type:"text",text:P`The following registries are configured in the current project:
73
-
74
- ${Object.keys(t.registries).map(o=>`- ${o}`).join(`
75
- `)}
76
-
77
- You can view the items in a registry by running:
78
- \`${await G("view @name-of-registry")}\`
79
-
80
- For example: \`${await G("view @shadcn")}\` or \`${await G("view @shadcn @acme")}\` to view multiple registries.
81
- `}]}:{content:[{type:"text",text:P`No components.json found or no registries configured.
82
-
83
- To fix this:
84
- 1. Use the \`init\` command to create a components.json file
85
- 2. Or manually create components.json with a registries section`}]}}case "search_items_in_registries":{let o=z.object({registries:z.array(z.string()),query:z.string(),limit:z.number().optional(),offset:z.number().optional()}).parse(e.params.arguments),r=await va(o.registries,{query:o.query,limit:o.limit,offset:o.offset,config:await V(process.cwd()),useCache:!1});return r.items.length===0?{content:[{type:"text",text:P`No items found matching "${o.query}" in registries ${o.registries.join(", ")}, Try searching with a different query or registry.`}]}:{content:[{type:"text",text:ze(r,{query:o.query,registries:o.registries})}]}}case "list_items_in_registries":{let o=z.object({registries:z.array(z.string()),limit:z.number().optional(),offset:z.number().optional(),cwd:z.string().optional()}).parse(e.params.arguments),r=await va(o.registries,{limit:o.limit,offset:o.offset,config:await V(process.cwd()),useCache:!1});return r.items.length===0?{content:[{type:"text",text:P`No items found in registries ${o.registries.join(", ")}.`}]}:{content:[{type:"text",text:ze(r,{registries:o.registries})}]}}case "view_items_in_registries":{let o=z.object({items:z.array(z.string())}).parse(e.params.arguments),r=await ba(o.items,{config:await V(process.cwd()),useCache:!1});if(r?.length===0)return {content:[{type:"text",text:P`No items found for: ${o.items.join(", ")}
86
-
87
- Make sure the item names are correct and include the registry prefix (e.g., @shadcn/button).`}]};let u=sr(r);return {content:[{type:"text",text:P`Item Details:
88
-
89
- ${u.join(`
90
-
91
- ---
92
-
93
- `)}`}]}}case "get_item_examples_from_registries":{let o=z.object({query:z.string(),registries:z.array(z.string())}).parse(e.params.arguments),r=await V(),u=await va(o.registries,{query:o.query,config:r,useCache:!1});if(u.items.length===0)return {content:[{type:"text",text:P`No examples found for query "${o.query}".
94
-
95
- Try searching with patterns like:
96
- - "accordion-demo" for accordion examples
97
- - "button demo" or "button example"
98
- - Component name followed by "-demo" or "example"
99
-
100
- You can also:
101
- 1. Use search_items_in_registries to find all items matching your query
102
- 2. View the main component with view_items_in_registries for inline usage documentation`}]};let c=u.items.map(a=>a.addCommandArgument),l=await ba(c,{config:r,useCache:!1});return {content:[{type:"text",text:ir(l,o.query)}]}}case "get_add_command_for_items":{let t=z.object({items:z.array(z.string())}).parse(e.params.arguments);return {content:[{type:"text",text:await G(`add ${t.items.join(" ")}`)}]}}case "get_audit_checklist":return {content:[{type:"text",text:P`## Component Audit Checklist
103
-
104
- After adding or generating components, check the following common issues:
105
-
106
- - [ ] Ensure imports are correct i.e named vs default imports
107
- - [ ] If using next/image, ensure images.remotePatterns next.config.js is configured correctly.
108
- - [ ] Ensure all dependencies are installed.
109
- - [ ] Check for linting errors or warnings
110
- - [ ] Check for TypeScript errors
111
- - [ ] Use the Playwright MCP if available.
112
- `}]};default:throw new Error(`Tool ${e.params.name} not found`)}}catch(t){if(t instanceof z.ZodError)return {content:[{type:"text",text:P`Invalid input parameters:
113
- ${t.errors.map(r=>`- ${r.path.join(".")}: ${r.message}`).join(`
114
- `)}
115
- `}],isError:true};if(t instanceof f){let r=t.message;return t.suggestion&&(r+=`
116
-
117
- \u{1F4A1} ${t.suggestion}`),t.context&&(r+=`
118
-
119
- Context: ${JSON.stringify(t.context,null,2)}`),{content:[{type:"text",text:P`Error (${t.code}): ${r}`}],isError:true}}let o=t instanceof Error?t.message:String(t);return {content:[{type:"text",text:P`Error: ${o}`}],isError:true}}});export{zs as a,nr as b};