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