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