@create-ui/cli 0.1.0-beta.1 → 0.5.1

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/LICENSE.md CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2023 createui
3
+ Copyright (c) 2026 createui
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -1,62 +1,232 @@
1
- # @create-ui/cli
1
+ <div align="center">
2
2
 
3
- A CLI for adding components to your project.
3
+ # Create UI
4
+
5
+ **Design faster. Build cleaner. Scale with one design system.**
6
+
7
+ A modern design code system evolved from shadcn/ui, built on React 19, Tailwind CSS v4, and Radix UI. Components are copied into your project, so you own every line. One unified system, many themes.
8
+
9
+ [![npm version](https://img.shields.io/npm/v/@create-ui/cli?color=000&label=%40create-ui%2Fcli)](https://www.npmjs.com/package/@create-ui/cli)
10
+ [![npm downloads](https://img.shields.io/npm/dm/@create-ui/cli?color=000)](https://www.npmjs.com/package/@create-ui/cli)
11
+ [![license](https://img.shields.io/npm/l/@create-ui/cli?color=000)](./LICENSE.md)
12
+ [![Tailwind v4](https://img.shields.io/badge/Tailwind-v4-000)](https://tailwindcss.com)
13
+
14
+ [Documentation](https://createui.co/docs) · [Components](https://createui.co/docs/components) · [CLI reference](https://createui.co/docs/cli) · [MCP](#ai-integration)
15
+
16
+ </div>
17
+
18
+ ---
19
+
20
+ ## Quick start
21
+
22
+ Scaffold a brand-new project, fully wired up:
23
+
24
+ ```bash
25
+ npx @create-ui/cli create
26
+ ```
27
+
28
+ Or add Create UI to an existing app:
29
+
30
+ ```bash
31
+ # set up Tailwind, CSS variables, the cn() util, and your theme
32
+ npx @create-ui/cli init
33
+
34
+ # then add components whenever you need them
35
+ npx @create-ui/cli add button badge
36
+ ```
37
+
38
+ That's it. The components land in your codebase as real, editable source files.
39
+
40
+ ## Why Create UI
41
+
42
+ - **You own the code.** Components are copied into your project, not hidden behind a package. Read them, edit them, ship them.
43
+ - **One system, many themes.** No legacy style/base split. A single styling foundation with themes (light/dark, semantic tokens) layered on top.
44
+ - **Semantic design tokens.** Spacing, radius, typography, and color are tokenized for consistency and effortless theming.
45
+ - **Accessible by default.** Built on Radix UI primitives with sensible keyboard and screen-reader behavior baked in.
46
+ - **AI-native.** A built-in MCP server and agent skill let assistants like Claude Code and Cursor add and compose components for you.
47
+ - **Bring your own registry.** Add from the official registry, a custom one, a URL, or a local path. Build and publish your own.
4
48
 
5
49
  ## Installation
6
50
 
51
+ Run on demand with `npx` (recommended, always the latest version):
52
+
7
53
  ```bash
8
- # one-off via npx (recommended)
9
- npx @create-ui/cli@beta <command>
54
+ npx @create-ui/cli <command>
55
+ ```
10
56
 
11
- # or install globally and run as `createui`
12
- pnpm add -g @create-ui/cli@beta
57
+ Or install globally and call the `createui` binary directly:
58
+
59
+ ```bash
60
+ pnpm add -g @create-ui/cli
13
61
  createui <command>
14
62
  ```
15
63
 
16
- ## create
64
+ ## Commands
65
+
66
+ ### `create`
67
+
68
+ Scaffold a new project with Create UI preconfigured. Run it bare to open the design-system builder in your browser and pick a preset, or pass a name to skip straight to the terminal flow.
69
+
70
+ ```bash
71
+ npx @create-ui/cli create [name]
72
+ ```
73
+
74
+ | Flag | Description |
75
+ | ---------------------------- | ----------------------------------------------------------------------------------- |
76
+ | `-t, --template <template>` | Framework template: `next`, `vite`, `start` |
77
+ | `-p, --preset [name]` | Apply a design-system preset (interactive list if used alone, or pass a preset URL) |
78
+ | `--src-dir` / `--no-src-dir` | Use (or skip) a `src/` directory |
79
+ | `-y, --yes` | Skip confirmation prompts |
80
+ | `-c, --cwd <cwd>` | Working directory (defaults to the current directory) |
81
+
82
+ ### `init`
83
+
84
+ Initialize an existing project: create `components.json`, install dependencies, configure Tailwind CSS and CSS variables, add the `cn()` utility, and install the base style.
85
+
86
+ ```bash
87
+ npx @create-ui/cli init [components...]
88
+ ```
89
+
90
+ | Flag | Description |
91
+ | ---------------------------------------- | ------------------------------------------------------------------------------ |
92
+ | `-t, --template <template>` | Template: `next`, `start`, `vite`, `next-monorepo` |
93
+ | `--theme <theme>` | Primary color theme (e.g. `indigo`, `blue`, `lime`, `rose`). Default: `indigo` |
94
+ | `--neutral <neutral>` | Neutral color (e.g. `slate`, `gray`, `zinc`, `stone`). Default: `slate` |
95
+ | `--font-variant <variant>` | Font variant. Default: `inter` |
96
+ | `--css-variables` / `--no-css-variables` | Use CSS variables for theming (default: on) |
97
+ | `--no-base-style` | Skip installing the base Create UI style |
98
+ | `--src-dir` / `--no-src-dir` | Use (or skip) a `src/` directory |
99
+ | `-d, --defaults` | Use the default configuration |
100
+ | `-f, --force` | Overwrite an existing configuration |
101
+ | `-y, --yes` | Skip confirmation prompts |
102
+ | `-c, --cwd <cwd>` | Working directory |
17
103
 
18
- 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.
104
+ ### `add`
105
+
106
+ Add components and their dependencies to your project. Run it without arguments for an interactive multi-select. If `components.json` is missing, the CLI initializes the project first.
19
107
 
20
108
  ```bash
21
- npx @create-ui/cli@beta create
109
+ npx @create-ui/cli add [components...]
22
110
  ```
23
111
 
24
- ## init
112
+ ```bash
113
+ # a single component
114
+ npx @create-ui/cli add inline-alert
115
+
116
+ # several at once
117
+ npx @create-ui/cli add button input field
118
+
119
+ # everything
120
+ npx @create-ui/cli add --all
121
+ ```
25
122
 
26
- Use the `init` command to initialize dependencies for a new project.
123
+ | Flag | Description |
124
+ | ---------------------------------------- | ------------------------------------- |
125
+ | `-a, --all` | Add every available component |
126
+ | `-o, --overwrite` | Overwrite existing files |
127
+ | `-p, --path <path>` | Target path for the components |
128
+ | `--css-variables` / `--no-css-variables` | Theme via CSS variables (default: on) |
129
+ | `--src-dir` / `--no-src-dir` | Use (or skip) a `src/` directory |
130
+ | `-y, --yes` | Skip confirmation prompts |
131
+ | `-s, --silent` | Mute output |
132
+ | `-c, --cwd <cwd>` | Working directory |
27
133
 
28
- The `init` command installs dependencies, adds the `cn` util, configures Tailwind CSS, and CSS variables for the project.
134
+ ### `diff`
135
+
136
+ Check installed components against the registry and preview available updates. Run it bare to list every component with pending changes, or pass a name to see its diff.
29
137
 
30
138
  ```bash
31
- npx @create-ui/cli@beta init
139
+ npx @create-ui/cli diff [component]
32
140
  ```
33
141
 
34
- ## add
142
+ ### `view`
143
+
144
+ Print the full details of one or more registry items as JSON, including file contents. Accepts item names or registry URLs.
145
+
146
+ ```bash
147
+ npx @create-ui/cli view button dialog
148
+ ```
35
149
 
36
- Use the `add` command to add components to your project.
150
+ ### `migrate`
37
151
 
38
- The `add` command adds a component to your project and installs all required dependencies.
152
+ Run a migration to update components and dependencies in place.
39
153
 
40
154
  ```bash
41
- npx @create-ui/cli@beta add [component]
155
+ # list available migrations
156
+ npx @create-ui/cli migrate --list
157
+
158
+ # run one
159
+ npx @create-ui/cli migrate icons
42
160
  ```
43
161
 
44
- ### Example
162
+ Available migrations: `icons` (switch icon library) and `radix` (migrate to `radix-ui`).
163
+
164
+ ### `info`
165
+
166
+ Print project and configuration details, including the resolved framework and your `components.json`.
45
167
 
46
168
  ```bash
47
- npx @create-ui/cli@beta add alert-dialog
169
+ npx @create-ui/cli info
48
170
  ```
49
171
 
50
- You can also run the command without any arguments to view a list of all available components:
172
+ ### `build`
173
+
174
+ Build a registry into distributable JSON. Reads a `registry.json`, resolves file imports, validates each item, embeds file contents, and writes the output (default: `./public/r`).
51
175
 
52
176
  ```bash
53
- npx @create-ui/cli@beta add
177
+ npx @create-ui/cli build [registry] --output ./public/r
54
178
  ```
55
179
 
180
+ > An experimental `registry:build` exists for recursive import resolution, and `registry:mcp` is deprecated in favor of [`mcp`](#mcp-server).
181
+
182
+ ## AI integration
183
+
184
+ Create UI is built to work hand in hand with AI coding agents.
185
+
186
+ ### MCP server
187
+
188
+ The CLI ships a [Model Context Protocol](https://modelcontextprotocol.io) server that lets an agent browse, search, and add components on your behalf. The server can list and search registries, view full component source, fetch usage examples, return the exact `add` command for a component, and run a post-generation audit checklist.
189
+
190
+ Configure it for your client in one step:
191
+
192
+ ```bash
193
+ npx @create-ui/cli mcp init --client claude
194
+ ```
195
+
196
+ Supported clients and where the config is written:
197
+
198
+ | Client | Config file |
199
+ | ----------- | ---------------------- |
200
+ | Claude Code | `.mcp.json` |
201
+ | Cursor | `.cursor/mcp.json` |
202
+ | VS Code | `.vscode/mcp.json` |
203
+ | Codex | `~/.codex/config.toml` |
204
+ | OpenCode | `opencode.json` |
205
+
206
+ To start the server directly (for custom integrations), run `npx @create-ui/cli mcp`.
207
+
208
+ ### Agent skill
209
+
210
+ Install the Create UI skill so your agent understands the design system and can compose components from natural language.
211
+
212
+ ```bash
213
+ npx @create-ui/cli skill --client claude
214
+ ```
215
+
216
+ Supported agents: `claude` (Claude Code), `gemini` (Gemini CLI), `codex`, and `agents`. Use `--project` to install into the current project instead of your home directory. Once installed, just ask:
217
+
218
+ > Add a Create UI login form.
219
+
220
+ ## Frameworks & requirements
221
+
222
+ - **Frameworks:** Next.js, Vite, React Router / Remix, and TanStack Start.
223
+ - **React 19** and **Tailwind CSS v4** are required.
224
+ - Components are built on **Radix UI** with **class-variance-authority** for variants.
225
+
56
226
  ## Documentation
57
227
 
58
- Visit https://dev.createui.co/docs/cli to view the documentation.
228
+ Full guides, the component catalog, and theming docs live at **[createui.co/docs](https://createui.co/docs)**. CLI reference: **[createui.co/docs/cli](https://createui.co/docs/cli)**.
59
229
 
60
- ## License
230
+ ## Community
61
231
 
62
- MIT
232
+ Follow [@createui](https://x.com/createui) for updates, or reach the team at [team@createui.co](mailto:team@createui.co).
@@ -1,18 +1,18 @@
1
- import {m,l,d,b,a,c,n,s,o,q as q$1,r,w as w$1,e}from'./chunk-Y7WZRQWW.js';import {Project,SyntaxKind,ScriptKind}from'ts-morph';import {z as z$1}from'zod';import*as h from'path';import h__default,{basename}from'path';import*as z from'fs/promises';import {tmpdir,homedir}from'os';import {green,cyan,yellow,red}from'kleur/colors';import {loadConfig,createMatchPath}from'tsconfig-paths';import {cosmiconfig}from'cosmiconfig';import pe from'fast-glob';import fe from'fs-extra';import {existsSync,statSync,promises}from'fs';import Wt from'ora';import {transformFromAstSync}from'@babel/core';import {parse}from'@babel/parser';import Bt from'@babel/plugin-transform-typescript';import*as de from'recast';import sr from'prompts';import q from'deepmerge';import {HttpsProxyAgent}from'https-proxy-agent';import Pr from'node-fetch';import {createHash}from'crypto';var Ue=async({sourceFile:e,config:t})=>{let s=t.menuColor==="inverted"?"dark":"";for(let n of e.getDescendantsOfKind(SyntaxKind.JsxAttribute)){if(n.getNameNode().getText()!=="className")continue;let o=n.getInitializer();if(!o)continue;let a=o.getText();if(!a.includes("cn-menu-target"))continue;let l=a.replace(/cn-menu-target/g,s);s||(l=l.replace(/\s{2,}/g," "),l=l.replace(/"\s+/g,'"'),l=l.replace(/\s+"/g,'"'),l=l.replace(/,\s*""\s*,/g,","),l=l.replace(/\(\s*""\s*,/g,"("),l=l.replace(/,\s*""\s*\)/g,")")),n.setInitializer(l);}return e};var U={NOT_FOUND:"NOT_FOUND",UNAUTHORIZED:"UNAUTHORIZED",FORBIDDEN:"FORBIDDEN",FETCH_ERROR:"FETCH_ERROR",LOCAL_FILE_ERROR:"LOCAL_FILE_ERROR",PARSE_ERROR:"PARSE_ERROR",UNKNOWN_ERROR:"UNKNOWN_ERROR"},O=class extends Error{code;statusCode;context;suggestion;timestamp;cause;constructor(t,r={}){super(t),this.name="RegistryError",this.code=r.code||U.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}}},se=class extends O{constructor(r,s){let n=`The item at ${r} was not found. It may not exist at the registry.`;super(n,{code:U.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";}},ne=class extends O{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:U.UNAUTHORIZED,statusCode:401,cause:s,context:{url:r},suggestion:"Check your authentication credentials and environment variables."});this.url=r;this.name="RegistryUnauthorizedError";}},ie=class extends O{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:U.FORBIDDEN,statusCode:403,cause:s,context:{url:r},suggestion:"Check your authentication credentials and environment variables."});this.url=r;this.name="RegistryForbiddenError";}},oe=class extends O{constructor(r,s,n,i){let o=s?`Failed to fetch from registry (${s}): ${r}`:`Failed to fetch from registry: ${r}`,a=typeof i=="string"&&i?`${o} - ${i}`:o,l="Check your network connection and try again.";s===404?l="The requested resource was not found. Check the URL or item name.":s===500?l="The registry server encountered an error. Try again later.":s&&s>=400&&s<500&&(l="There was a client error. Check your request parameters.");super(a,{code:U.FETCH_ERROR,statusCode:s,cause:i,context:{url:r,responseBody:n},suggestion:l});this.url=r;this.responseBody=n;this.name="RegistryFetchError";}},Z=class extends O{constructor(r,s){super(`Failed to read local registry file: ${r}`,{code:U.LOCAL_FILE_ERROR,cause:s,context:{filePath:r},suggestion:"Check if the file exists and you have read permissions."});this.filePath=r;this.name="RegistryLocalFileError";}},$=class extends O{constructor(r,s){let n=`Failed to parse registry item: ${r}`;s instanceof z$1.ZodError&&(n=`Failed to parse registry item: ${r}
1
+ import {m,l,d,b,a,c,n,s,o,q as q$1,r,w as w$1,e}from'./chunk-Y7WZRQWW.js';import {Project,SyntaxKind,ScriptKind}from'ts-morph';import {z as z$1}from'zod';import*as h from'path';import h__default,{basename}from'path';import*as z from'fs/promises';import {tmpdir,homedir}from'os';import {green,cyan,yellow,red}from'kleur/colors';import {loadConfig,createMatchPath}from'tsconfig-paths';import {cosmiconfig}from'cosmiconfig';import me from'fast-glob';import pe from'fs-extra';import {existsSync,statSync,promises}from'fs';import Wt from'ora';import {transformFromAstSync}from'@babel/core';import {parse}from'@babel/parser';import Bt from'@babel/plugin-transform-typescript';import*as he from'recast';import sr from'prompts';import q from'deepmerge';import {HttpsProxyAgent}from'https-proxy-agent';import Pr from'node-fetch';import {createHash}from'crypto';var Ke=async({sourceFile:e,config:t})=>{let s=t.menuColor==="inverted"?"dark":"";for(let n of e.getDescendantsOfKind(SyntaxKind.JsxAttribute)){if(n.getNameNode().getText()!=="className")continue;let o=n.getInitializer();if(!o)continue;let a=o.getText();if(!a.includes("cn-menu-target"))continue;let l=a.replace(/cn-menu-target/g,s);s||(l=l.replace(/\s{2,}/g," "),l=l.replace(/"\s+/g,'"'),l=l.replace(/\s+"/g,'"'),l=l.replace(/,\s*""\s*,/g,","),l=l.replace(/\(\s*""\s*,/g,"("),l=l.replace(/,\s*""\s*\)/g,")")),n.setInitializer(l);}return e};var U={NOT_FOUND:"NOT_FOUND",UNAUTHORIZED:"UNAUTHORIZED",FORBIDDEN:"FORBIDDEN",FETCH_ERROR:"FETCH_ERROR",LOCAL_FILE_ERROR:"LOCAL_FILE_ERROR",PARSE_ERROR:"PARSE_ERROR",UNKNOWN_ERROR:"UNKNOWN_ERROR"},O=class extends Error{code;statusCode;context;suggestion;timestamp;cause;constructor(t,r={}){super(t),this.name="RegistryError",this.code=r.code||U.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}}},se=class extends O{constructor(r,s){let n=`The item at ${r} was not found. It may not exist at the registry.`;super(n,{code:U.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";}},ne=class extends O{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:U.UNAUTHORIZED,statusCode:401,cause:s,context:{url:r},suggestion:"Check your authentication credentials and environment variables."});this.url=r;this.name="RegistryUnauthorizedError";}},ie=class extends O{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:U.FORBIDDEN,statusCode:403,cause:s,context:{url:r},suggestion:"Check your authentication credentials and environment variables."});this.url=r;this.name="RegistryForbiddenError";}},oe=class extends O{constructor(r,s,n,i){let o=s?`Failed to fetch from registry (${s}): ${r}`:`Failed to fetch from registry: ${r}`,a=typeof i=="string"&&i?`${o} - ${i}`:o,l="Check your network connection and try again.";s===404?l="The requested resource was not found. Check the URL or item name.":s===500?l="The registry server encountered an error. Try again later.":s&&s>=400&&s<500&&(l="There was a client error. Check your request parameters.");super(a,{code:U.FETCH_ERROR,statusCode:s,cause:i,context:{url:r,responseBody:n},suggestion:l});this.url=r;this.responseBody=n;this.name="RegistryFetchError";}},Z=class extends O{constructor(r,s){super(`Failed to read local registry file: ${r}`,{code:U.LOCAL_FILE_ERROR,cause:s,context:{filePath:r},suggestion:"Check if the file exists and you have read permissions."});this.filePath=r;this.name="RegistryLocalFileError";}},$=class extends O{constructor(r,s){let n=`Failed to parse registry item: ${r}`;s instanceof z$1.ZodError&&(n=`Failed to parse registry item: ${r}
2
2
  ${s.errors.map(i=>` - ${i.path.join(".")}: ${i.message}`).join(`
3
- `)}`);super(n,{code:U.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 https://dev.createui.co/schema/registry-item.json."});this.item=r;this.parseError=s,this.name="RegistryParseError";}parseError};var ae=process.env.REGISTRY_URL??"https://dev.createui.co/r",ut=[{name:"indigo",label:"Indigo"},{name:"lime",label:"Lime"},{name:"green",label:"Green"},{name:"red",label:"Red"},{name:"orange",label:"Orange"},{name:"yellow",label:"Yellow"},{name:"cyan",label:"Cyan"},{name:"blue",label:"Blue"}],gt=ut,dt=[{name:"gray",label:"Gray"},{name:"slate",label:"Slate"},{name:"zinc",label:"Zinc"},{name:"base",label:"Base"},{name:"stone",label:"Stone"}];gt.map(e=>e.name);var Kr=dt.map(e=>e.name),Mr="gray",ht=[{name:"v1",label:"Default (Geist + JetBrains Mono)"}],Br=ht.map(e=>e.name),Gr="v1";var Hr=[{name:"toast",deprecatedBy:"sonner",message:"The toast component is deprecated. Use the sonner component instead."},{name:"toaster",deprecatedBy:"sonner",message:"The toaster component is deprecated. Use the sonner component instead."}];var P={"next-app":{name:"next-app",label:"Next.js",links:{installation:"https://dev.createui.co/docs/installation/next",tailwind:"https://tailwindcss.com/docs/guides/nextjs"}},"next-pages":{name:"next-pages",label:"Next.js",links:{installation:"https://dev.createui.co/docs/installation/next",tailwind:"https://tailwindcss.com/docs/guides/nextjs"}},remix:{name:"remix",label:"Remix",links:{installation:"https://dev.createui.co/docs/installation/remix",tailwind:"https://tailwindcss.com/docs/guides/remix"}},"react-router":{name:"react-router",label:"React Router",links:{installation:"https://dev.createui.co/docs/installation/react-router",tailwind:"https://tailwindcss.com/docs/installation/framework-guides/react-router"}},vite:{name:"vite",label:"Vite",links:{installation:"https://dev.createui.co/docs/installation/vite",tailwind:"https://tailwindcss.com/docs/guides/vite"}},astro:{name:"astro",label:"Astro",links:{installation:"https://dev.createui.co/docs/installation/astro",tailwind:"https://tailwindcss.com/docs/guides/astro"}},laravel:{name:"laravel",label:"Laravel",links:{installation:"https://dev.createui.co/docs/installation/laravel",tailwind:"https://tailwindcss.com/docs/guides/laravel"}},"tanstack-start":{name:"tanstack-start",label:"TanStack Start",links:{installation:"https://dev.createui.co/docs/installation/tanstack",tailwind:"https://tailwindcss.com/docs/installation/using-postcss"}},gatsby:{name:"gatsby",label:"Gatsby",links:{installation:"https://dev.createui.co/docs/installation/gatsby",tailwind:"https://tailwindcss.com/docs/guides/gatsby"}},expo:{name:"expo",label:"Expo",links:{installation:"https://dev.createui.co/docs/installation/expo",tailwind:"https://www.nativewind.dev/docs/getting-started/installation"}},manual:{name:"manual",label:"Manual",links:{installation:"https://dev.createui.co/docs/installation/manual",tailwind:"https://tailwindcss.com/docs/installation"}}};var k={error:red,warn:yellow,info:cyan,success:green};async function T(e,t){return createMatchPath(t.absoluteBaseUrl,t.paths)(e,void 0,()=>true,[".ts",".tsx",".jsx",".js",".css"])}var as="@/components",cs="@/lib/utils",ls="app/globals.css",fs="tailwind.config.js";var It=cosmiconfig("components",{searchPlaces:["components.json"]});async function ce(e){let t=await St(e);return t?(t.iconLibrary||(t.iconLibrary="lucide"),await be(e,t)):null}async function be(e,t){let r=await loadConfig(e);if(r.resultType==="failed")throw new Error(`Failed to load ${t.tsx?"tsconfig":"jsconfig"}.json. ${r.message??""}`.trim());return b.parse({...t,resolvedPaths:{cwd:e,tailwindConfig:t.tailwind.config?h__default.resolve(e,t.tailwind.config):"",tailwindCss:h__default.resolve(e,t.tailwind.css),utils:await T(t.aliases.utils,r),components:await T(t.aliases.components,r),ui:t.aliases.ui?await T(t.aliases.ui,r):h__default.resolve(await T(t.aliases.components,r)??e,"ui"),lib:t.aliases.lib?await T(t.aliases.lib,r):h__default.resolve(await T(t.aliases.utils,r)??e,".."),hooks:t.aliases.hooks?await T(t.aliases.hooks,r):h__default.resolve(await T(t.aliases.components,r)??e,"..","hooks")}})}async function St(e){try{let t=await It.search(e);return t?a.parse(t.config):null}catch{let r=`${e}/components.json`;throw new Error(`Invalid configuration found in ${k.info(r)}.`)}}async function ps(e){let t={};for(let s of Object.keys(e.aliases)){if(!kt(s,e))continue;let n=e.resolvedPaths[s],i=await Pt(e.resolvedPaths.cwd,n);if(!i){t[s]=e;continue}t[s]=await ce(i);}let r=c.safeParse(t);return r.success?r.data:null}async function Pt(e,t){let r=Tt(e,t),s=h__default.relative(r,t),i=(await pe.glob("**/package.json",{cwd:r,deep:3,ignore:["**/node_modules/**","**/dist/**","**/build/**","**/public/**"]})).map(o=>h__default.dirname(o)).find(o=>s.startsWith(o));return i?h__default.join(r,i):null}function kt(e,t){return Object.keys(t.resolvedPaths).filter(r=>r!=="utils").includes(e)}function Tt(e,t){let r=e.split(h__default.sep),s=t.split(h__default.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(h__default.sep)}function Ve(e){let t={resolvedPaths:{cwd:process.cwd(),tailwindConfig:"",tailwindCss:"",utils:"",components:"",ui:"",lib:"",hooks:""},tailwind:{config:"",css:"",baseColor:"",cssVariables:false},rsc:false,tsx:true,aliases:{components:"",utils:""}};return e?{...t,...e,resolvedPaths:{...t.resolvedPaths,...e.resolvedPaths||{}},tailwind:{...t.tailwind,...e.tailwind||{}},aliases:{...t.aliases,...e.aliases||{}}}:t}function Ee(e="",t=true){let r=h__default.join(e,"package.json");return fe.readJSONSync(r,{throws:t})}var me=["**/node_modules/**",".next","public","dist","build"];z$1.object({compilerOptions:z$1.object({paths:z$1.record(z$1.string().or(z$1.array(z$1.string())))})});async function B(e){let[t,r,s,n,i,o,a,l]=await Promise.all([pe.glob("**/{next,vite,astro,app}.config.*|gatsby-config.*|composer.json|react-router.config.*",{cwd:e,deep:3,ignore:me}),fe.pathExists(h__default.resolve(e,"src")),Lt(e),At(e),Dt(e),$t(e),_t(e),Ee(e,false)]),f=await fe.pathExists(h__default.resolve(e,`${r?"src/":""}app`)),c={framework:P.manual,isSrcDir:r,isRSC:false,isTsx:s,tailwindConfigFile:n,tailwindCssFile:i,tailwindVersion:o,frameworkVersion:null,aliasPrefix:a};if(t.find(m=>m.startsWith("next.config."))?.length)return c.framework=f?P["next-app"]:P["next-pages"],c.isRSC=f,c.frameworkVersion=await Ot(c.framework,l),c;if(t.find(m=>m.startsWith("astro.config."))?.length)return c.framework=P.astro,c;if(t.find(m=>m.startsWith("gatsby-config."))?.length)return c.framework=P.gatsby,c;if(t.find(m=>m.startsWith("composer.json"))?.length)return c.framework=P.laravel,c;if(Object.keys(l?.dependencies??{}).find(m=>m.startsWith("@remix-run/")))return c.framework=P.remix,c;if([...Object.keys(l?.dependencies??{}),...Object.keys(l?.devDependencies??{})].find(m=>m.startsWith("@tanstack/react-start")))return c.framework=P["tanstack-start"],c;if(t.find(m=>m.startsWith("react-router.config."))?.length)return c.framework=P["react-router"],c;if(t.find(m=>m.startsWith("vite.config."))?.length)return c.framework=P.vite,c;let d=t.find(m=>m.startsWith("app.config"));return d?.length&&(await fe.readFile(h__default.resolve(e,d),"utf8")).includes("defineConfig")?(c.framework=P.vite,c):(l?.dependencies?.expo&&(c.framework=P.expo),c)}async function Ot(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 $t(e){let[t,r]=await Promise.all([Ee(e,false),ce(e)]);return r?.tailwind?.config===""?"v4":!t?.dependencies?.tailwindcss&&!t?.devDependencies?.tailwindcss?null:"v4"}async function Dt(e){let t=await pe.glob(["**/*.css","**/*.scss"],{cwd:e,deep:5,ignore:me});if(!t.length)return null;for(let r of t){let s=await fe.readFile(h__default.resolve(e,r),"utf8");if(s.includes('@import "tailwindcss"')||s.includes("@import 'tailwindcss'"))return r}return null}async function At(e){let t=await pe.glob("tailwind.config.*",{cwd:e,deep:3,ignore:me});return t.length?t[0]:null}async function _t(e){let t=await loadConfig(e);if(t?.resultType==="failed"||!Object.entries(t?.paths).length)return null;for(let[r,s]of Object.entries(t.paths))if(s.includes("./*")||s.includes("./src/*")||s.includes("./app/*")||s.includes("./resources/js/*"))return r.replace(/\/\*$/,"")??null;return Object.keys(t?.paths)?.[0].replace(/\/\*$/,"")??null}async function Lt(e){return (await pe.glob("tsconfig.*",{cwd:e,deep:1,ignore:me})).length>0}async function Ps(e,t=null){let[r,s]=await Promise.all([ce(e),t?Promise.resolve(t):B(e)]);if(r)return r;if(!s||!s.tailwindCssFile)return null;let n={$schema:"https://dev.createui.co/schema.json",rsc:s.isRSC,tsx:s.isTsx,tailwind:{config:s.tailwindConfigFile??"",baseColor:"zinc",css:s.tailwindCssFile,cssVariables:true,prefix:""},iconLibrary:"lucide",aliases:{components:`${s.aliasPrefix}/components`,ui:`${s.aliasPrefix}/components/ui`,hooks:`${s.aliasPrefix}/hooks`,lib:`${s.aliasPrefix}/lib`,utils:`${s.aliasPrefix}/lib/utils`}};return await be(e,n)}function Ke(e,t,r={}){let{ignoreImports:s=false}=r,n=e.replace(/\r\n/g,`
3
+ `)}`);super(n,{code:U.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 https://createui.co/schema/registry-item.json."});this.item=r;this.parseError=s,this.name="RegistryParseError";}parseError};var ae=process.env.REGISTRY_URL??"https://createui.co/r",gt=[{name:"indigo",label:"Indigo"},{name:"lime",label:"Lime"},{name:"green",label:"Green"},{name:"red",label:"Red"},{name:"orange",label:"Orange"},{name:"yellow",label:"Yellow"},{name:"cyan",label:"Cyan"},{name:"blue",label:"Blue"}],dt=gt,ht=[{name:"gray",label:"Gray"},{name:"slate",label:"Slate"},{name:"zinc",label:"Zinc"},{name:"base",label:"Base"},{name:"stone",label:"Stone"}];dt.map(e=>e.name);var Mr=ht.map(e=>e.name),Br="gray",ce=[{name:"v1",label:"Default (Geist + JetBrains Mono)"}],Gr=ce.map(e=>e.name),Hr="v1";var Jr=[{name:"toast",deprecatedBy:"sonner",message:"The toast component is deprecated. Use the sonner component instead."},{name:"toaster",deprecatedBy:"sonner",message:"The toaster component is deprecated. Use the sonner component instead."}];var P={"next-app":{name:"next-app",label:"Next.js",links:{installation:"https://createui.co/docs/installation",tailwind:"https://tailwindcss.com/docs/guides/nextjs"}},"next-pages":{name:"next-pages",label:"Next.js",links:{installation:"https://createui.co/docs/installation",tailwind:"https://tailwindcss.com/docs/guides/nextjs"}},remix:{name:"remix",label:"Remix",links:{installation:"https://createui.co/docs/installation",tailwind:"https://tailwindcss.com/docs/guides/remix"}},"react-router":{name:"react-router",label:"React Router",links:{installation:"https://createui.co/docs/installation",tailwind:"https://tailwindcss.com/docs/installation/framework-guides/react-router"}},vite:{name:"vite",label:"Vite",links:{installation:"https://createui.co/docs/installation",tailwind:"https://tailwindcss.com/docs/guides/vite"}},astro:{name:"astro",label:"Astro",links:{installation:"https://createui.co/docs/installation",tailwind:"https://tailwindcss.com/docs/guides/astro"}},laravel:{name:"laravel",label:"Laravel",links:{installation:"https://createui.co/docs/installation",tailwind:"https://tailwindcss.com/docs/guides/laravel"}},"tanstack-start":{name:"tanstack-start",label:"TanStack Start",links:{installation:"https://createui.co/docs/installation",tailwind:"https://tailwindcss.com/docs/installation/using-postcss"}},gatsby:{name:"gatsby",label:"Gatsby",links:{installation:"https://createui.co/docs/installation",tailwind:"https://tailwindcss.com/docs/guides/gatsby"}},expo:{name:"expo",label:"Expo",links:{installation:"https://createui.co/docs/installation",tailwind:"https://www.nativewind.dev/docs/getting-started/installation"}},manual:{name:"manual",label:"Manual",links:{installation:"https://createui.co/docs/installation",tailwind:"https://tailwindcss.com/docs/installation"}}};var T={error:red,warn:yellow,info:cyan,success:green};async function k(e,t){return createMatchPath(t.absoluteBaseUrl,t.paths)(e,void 0,()=>true,[".ts",".tsx",".jsx",".js",".css"])}var cs="@/components",ls="@/lib/utils",fs="app/globals.css",ps="tailwind.config.js";var It=cosmiconfig("components",{searchPlaces:["components.json"]});async function le(e){let t=await St(e);return t?(t.iconLibrary||(t.iconLibrary="lucide"),await Ee(e,t)):null}async function Ee(e,t){let r=await loadConfig(e);if(r.resultType==="failed")throw new Error(`Failed to load ${t.tsx?"tsconfig":"jsconfig"}.json. ${r.message??""}`.trim());return b.parse({...t,resolvedPaths:{cwd:e,tailwindConfig:t.tailwind.config?h__default.resolve(e,t.tailwind.config):"",tailwindCss:h__default.resolve(e,t.tailwind.css),utils:await k(t.aliases.utils,r),components:await k(t.aliases.components,r),ui:t.aliases.ui?await k(t.aliases.ui,r):h__default.resolve(await k(t.aliases.components,r)??e,"ui"),lib:t.aliases.lib?await k(t.aliases.lib,r):h__default.resolve(await k(t.aliases.utils,r)??e,".."),hooks:t.aliases.hooks?await k(t.aliases.hooks,r):h__default.resolve(await k(t.aliases.components,r)??e,"..","hooks")}})}async function St(e){try{let t=await It.search(e);return t?a.parse(t.config):null}catch{let r=`${e}/components.json`;throw new Error(`Invalid configuration found in ${T.info(r)}.`)}}async function ms(e){let t={};for(let s of Object.keys(e.aliases)){if(!Tt(s,e))continue;let n=e.resolvedPaths[s],i=await Pt(e.resolvedPaths.cwd,n);if(!i){t[s]=e;continue}t[s]=await le(i);}let r=c.safeParse(t);return r.success?r.data:null}async function Pt(e,t){let r=kt(e,t),s=h__default.relative(r,t),i=(await me.glob("**/package.json",{cwd:r,deep:3,ignore:["**/node_modules/**","**/dist/**","**/build/**","**/public/**"]})).map(o=>h__default.dirname(o)).find(o=>s.startsWith(o));return i?h__default.join(r,i):null}function Tt(e,t){return Object.keys(t.resolvedPaths).filter(r=>r!=="utils").includes(e)}function kt(e,t){let r=e.split(h__default.sep),s=t.split(h__default.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(h__default.sep)}function Me(e){let t={resolvedPaths:{cwd:process.cwd(),tailwindConfig:"",tailwindCss:"",utils:"",components:"",ui:"",lib:"",hooks:""},tailwind:{config:"",css:"",baseColor:"",cssVariables:false},rsc:false,tsx:true,aliases:{components:"",utils:""}};return e?{...t,...e,resolvedPaths:{...t.resolvedPaths,...e.resolvedPaths||{}},tailwind:{...t.tailwind,...e.tailwind||{}},aliases:{...t.aliases,...e.aliases||{}}}:t}function Ce(e="",t=true){let r=h__default.join(e,"package.json");return pe.readJSONSync(r,{throws:t})}var ue=["**/node_modules/**",".next","public","dist","build"];z$1.object({compilerOptions:z$1.object({paths:z$1.record(z$1.string().or(z$1.array(z$1.string())))})});async function B(e){let[t,r,s,n,i,o,a,l]=await Promise.all([me.glob("**/{next,vite,astro,app}.config.*|gatsby-config.*|composer.json|react-router.config.*",{cwd:e,deep:3,ignore:ue}),pe.pathExists(h__default.resolve(e,"src")),Lt(e),At(e),Dt(e),$t(e),_t(e),Ce(e,false)]),f=await pe.pathExists(h__default.resolve(e,`${r?"src/":""}app`)),c={framework:P.manual,isSrcDir:r,isRSC:false,isTsx:s,tailwindConfigFile:n,tailwindCssFile:i,tailwindVersion:o,frameworkVersion:null,aliasPrefix:a};if(t.find(m=>m.startsWith("next.config."))?.length)return c.framework=f?P["next-app"]:P["next-pages"],c.isRSC=f,c.frameworkVersion=await Ot(c.framework,l),c;if(t.find(m=>m.startsWith("astro.config."))?.length)return c.framework=P.astro,c;if(t.find(m=>m.startsWith("gatsby-config."))?.length)return c.framework=P.gatsby,c;if(t.find(m=>m.startsWith("composer.json"))?.length)return c.framework=P.laravel,c;if(Object.keys(l?.dependencies??{}).find(m=>m.startsWith("@remix-run/")))return c.framework=P.remix,c;if([...Object.keys(l?.dependencies??{}),...Object.keys(l?.devDependencies??{})].find(m=>m.startsWith("@tanstack/react-start")))return c.framework=P["tanstack-start"],c;if(t.find(m=>m.startsWith("react-router.config."))?.length)return c.framework=P["react-router"],c;if(t.find(m=>m.startsWith("vite.config."))?.length)return c.framework=P.vite,c;let d=t.find(m=>m.startsWith("app.config"));return d?.length&&(await pe.readFile(h__default.resolve(e,d),"utf8")).includes("defineConfig")?(c.framework=P.vite,c):(l?.dependencies?.expo&&(c.framework=P.expo),c)}async function Ot(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 $t(e){let[t,r]=await Promise.all([Ce(e,false),le(e)]);return r?.tailwind?.config===""?"v4":!t?.dependencies?.tailwindcss&&!t?.devDependencies?.tailwindcss?null:"v4"}async function Dt(e){let t=await me.glob(["**/*.css","**/*.scss"],{cwd:e,deep:5,ignore:ue});if(!t.length)return null;for(let r of t){let s=await pe.readFile(h__default.resolve(e,r),"utf8");if(s.includes('@import "tailwindcss"')||s.includes("@import 'tailwindcss'"))return r}return null}async function At(e){let t=await me.glob("tailwind.config.*",{cwd:e,deep:3,ignore:ue});return t.length?t[0]:null}async function _t(e){let t=await loadConfig(e);if(t?.resultType==="failed"||!Object.entries(t?.paths).length)return null;for(let[r,s]of Object.entries(t.paths))if(s.includes("./*")||s.includes("./src/*")||s.includes("./app/*")||s.includes("./resources/js/*"))return r.replace(/\/\*$/,"")??null;return Object.keys(t?.paths)?.[0].replace(/\/\*$/,"")??null}async function Lt(e){return (await me.glob("tsconfig.*",{cwd:e,deep:1,ignore:ue})).length>0}async function Ts(e,t=null){let[r,s]=await Promise.all([le(e),t?Promise.resolve(t):B(e)]);if(r)return r;if(!s||!s.tailwindCssFile)return null;let n={$schema:"https://createui.co/schema.json",rsc:s.isRSC,tsx:s.isTsx,tailwind:{config:s.tailwindConfigFile??"",baseColor:"zinc",css:s.tailwindCssFile,cssVariables:true,prefix:""},iconLibrary:"lucide",aliases:{components:`${s.aliasPrefix}/components`,ui:`${s.aliasPrefix}/components/ui`,hooks:`${s.aliasPrefix}/hooks`,lib:`${s.aliasPrefix}/lib`,utils:`${s.aliasPrefix}/lib/utils`}};return await Ee(e,n)}function Be(e,t,r={}){let{ignoreImports:s=false}=r,n=e.replace(/\r\n/g,`
4
4
  `).trim(),i=t.replace(/\r\n/g,`
5
- `).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=c=>c.replace(o,(d,m,u,y)=>{if(u.startsWith("."))return `${m}${u}${y}`;let g=u.split("/"),v=g[g.length-1];return `${m}@normalized/${v}${y}`}),l=a(n),f=a(i);return l===f}function V(e){let t=h__default.basename(e);return /^\.env(\.|$)/.test(t)}function Be(e){let t=[".env.local",".env",".env.development.local",".env.development"];for(let r of t){let s=h__default.join(e,r);if(existsSync(s))return s}return null}function G(e){let t=e.split(`
6
- `),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 Ge(e,t){let r=G(e),s=G(t),n=[];for(let i of Object.keys(s))i in r||n.push(i);return n}function He(e,t){let r=G(e),s=G(t),n=e.trimEnd();n&&!n.endsWith(`
5
+ `).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=c=>c.replace(o,(d,m,u,y)=>{if(u.startsWith("."))return `${m}${u}${y}`;let g=u.split("/"),v=g[g.length-1];return `${m}@normalized/${v}${y}`}),l=a(n),f=a(i);return l===f}function V(e){let t=h__default.basename(e);return /^\.env(\.|$)/.test(t)}function He(e){let t=[".env.local",".env",".env.development.local",".env.development"];for(let r of t){let s=h__default.join(e,r);if(existsSync(s))return s}return null}function G(e){let t=e.split(`
6
+ `),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 Je(e,t){let r=G(e),s=G(t),n=[];for(let i of Object.keys(s))i in r||n.push(i);return n}function qe(e,t){let r=G(e),s=G(t),n=e.trimEnd();n&&!n.endsWith(`
7
7
  `)&&(n+=`
8
8
  `);let i=[];for(let[o,a]of Object.entries(s))o in r||i.push(`${o}=${a}`);return i.length>0?(n&&(n+=`
9
9
  `),n+=i.join(`
10
10
  `),n+`
11
11
  `):n&&!n.endsWith(`
12
12
  `)?n+`
13
- `:n}var w={error(...e){console.log(k.error(e.join(" ")));},warn(...e){console.log(k.warn(e.join(" ")));},info(...e){console.log(k.info(e.join(" ")));},success(...e){console.log(k.success(e.join(" ")));},log(...e){console.log(e.join(" "));},break(){console.log("");}};function X(e,t){return Wt({text:e,isSilent:t?.silent})}var ue=async({sourceFile:e})=>e;var ge=async({sourceFile:e,config:t,isRemote:r})=>{let s=t.aliases?.utils,i=`${typeof s=="string"&&s.includes("/")?s.split("/")[0]:"@"}/lib/utils`;if(![".tsx",".ts",".jsx",".js"].includes(e.getExtension()))return e;for(let o of e.getImportStringLiterals()){let a=Vt(o.getLiteralValue(),t,r);if(o.setLiteralValue(a),i===a||a==="@/lib/utils"){if(!o.getFirstAncestorByKind(SyntaxKind.ImportDeclaration)?.getNamedImports().some(c=>c.getName()==="cn")||!t.aliases.utils)continue;o.setLiteralValue(i===a?a.replace(i,t.aliases.utils):t.aliases.utils);}}return e};function Vt(e,t,r=false){if(!e.startsWith("@/")&&!r)return e;if(r&&e.startsWith("@/")&&(e=e.replace(/^@\//,"@/registry/_/")),!e.startsWith("@/registry/")){let s=t.aliases.components.split("/")[0];return e.replace(/^@\//,`${s}/`)}return e.match(/^@\/registry\/((.+)\/)?ui/)?e.replace(/^@\/registry\/((.+)\/)?ui/,t.aliases.ui??`${t.aliases.components}/ui`):t.aliases.components&&e.match(/^@\/registry\/((.+)\/)?components/)?e.replace(/^@\/registry\/((.+)\/)?components/,t.aliases.components):t.aliases.lib&&e.match(/^@\/registry\/((.+)\/)?lib/)?e.replace(/^@\/registry\/((.+)\/)?lib/,t.aliases.lib):t.aliases.hooks&&e.match(/^@\/registry\/((.+)\/)?hooks/)?e.replace(/^@\/registry\/((.+)\/)?hooks/,t.aliases.hooks):e.replace(/^@\/registry\/[^/]+/,t.aliases.components)}var Gt={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"]},Je=async({sourceFile:e,config:t})=>{let r=e.getFullText();if(t.tsx)return r;let s=de.parse(r,{parser:{parse:i=>parse(i,Gt)}}),n=transformFromAstSync(s,r,{cloneInputAst:false,code:false,ast:true,plugins:[Bt],configFile:false});if(!n||!n.ast)throw new Error("Failed to transform JSX");return de.print(n.ast).code};var Jt=/^["']use client["']$/g,he=async({sourceFile:e,config:t})=>{if(t.rsc)return e;let r=e.getFirstChildByKind(SyntaxKind.ExpressionStatement);return r&&Jt.test(r.getText())&&r.remove(),e};var ye=async({sourceFile:e,config:t})=>(t.tailwind?.prefix&&(e.getDescendantsOfKind(SyntaxKind.CallExpression).filter(r=>r.getExpression().getText()==="cva").forEach(r=>{if(r.getArguments()[0]?.isKind(SyntaxKind.StringLiteral)){let s=r.getArguments()[0];s&&s.replaceWithText(`"${_(s.getText()?.replace(/"|'/g,""),t.tailwind.prefix)}"`);}r.getArguments()[1]?.isKind(SyntaxKind.ObjectLiteralExpression)&&r.getArguments()[1]?.getDescendantsOfKind(SyntaxKind.PropertyAssignment).find(s=>s.getName()==="variants")?.getDescendantsOfKind(SyntaxKind.PropertyAssignment).forEach(s=>{s.getDescendantsOfKind(SyntaxKind.PropertyAssignment).forEach(n=>{let i=n.getInitializerIfKind(SyntaxKind.StringLiteral);i&&i?.replaceWithText(`"${_(i.getText()?.replace(/"|'/g,""),t.tailwind.prefix)}"`);});});}),e.getDescendantsOfKind(SyntaxKind.JsxAttribute).forEach(r=>{if(r.getNameNode().getText()==="className"){if(r.getInitializer()?.isKind(SyntaxKind.StringLiteral)){let s=r.getInitializer();s&&s.replaceWithText(`"${_(s.getText()?.replace(/"|'/g,""),t.tailwind.prefix)}"`);}if(r.getInitializer()?.isKind(SyntaxKind.JsxExpression)){let s=r.getInitializer()?.getDescendantsOfKind(SyntaxKind.CallExpression).find(n=>n.getExpression().getText()==="cn");s&&s.getArguments().forEach(n=>{(n.isKind(SyntaxKind.ConditionalExpression)||n.isKind(SyntaxKind.BinaryExpression))&&n.getChildrenOfKind(SyntaxKind.StringLiteral).forEach(i=>{i.replaceWithText(`"${_(i.getText()?.replace(/"|'/g,""),t.tailwind.prefix)}"`);}),n.isKind(SyntaxKind.StringLiteral)&&n.replaceWithText(`"${_(n.getText()?.replace(/"|'/g,""),t.tailwind.prefix)}"`);});}}r.getNameNode().getText()==="classNames"&&r.getInitializer()?.isKind(SyntaxKind.JsxExpression)&&r.getDescendantsOfKind(SyntaxKind.PropertyAssignment).forEach(s=>{if(s.getInitializer()?.isKind(SyntaxKind.CallExpression)){let n=s.getInitializerIfKind(SyntaxKind.CallExpression);n&&n.getArguments().forEach(i=>{i.isKind(SyntaxKind.ConditionalExpression)&&i.getChildrenOfKind(SyntaxKind.StringLiteral).forEach(o=>{o.replaceWithText(`"${_(o.getText()?.replace(/"|'/g,""),t.tailwind.prefix)}"`);}),i.isKind(SyntaxKind.StringLiteral)&&i.replaceWithText(`"${_(i.getText()?.replace(/"|'/g,""),t.tailwind.prefix)}"`);});}if(s.getInitializer()?.isKind(SyntaxKind.StringLiteral)&&s.getNameNode().getText()!=="variant"){let n=s.getInitializer();n&&n.replaceWithText(`"${_(n.getText()?.replace(/"|'/g,""),t.tailwind.prefix)}"`);}});})),e);function _(e,t=""){return e.split(" ").map(r=>r.indexOf(`${t}:`)===0?r:`${t}:${r.trim()}`).join(" ")}var Qt=new Project({compilerOptions:{}});async function er(e){let t=await promises.mkdtemp(h__default.join(tmpdir(),"createui-"));return h__default.join(t,e)}async function Ye(e,t=[ge,he,ue,ye]){let r=await er(e.filename),s=Qt.createSourceFile(r,e.raw,{scriptKind:ScriptKind.TSX});for(let n of t)await n({sourceFile:s,...e});return e.transformJsx?await Je({sourceFile:s,...e}):s.getText()}var Ze=async({sourceFile:e})=>(e.getFunctions().forEach(t=>{t.getName()==="middleware"&&t.rename("proxy");}),e.getVariableDeclarations().forEach(t=>{t.getName()==="middleware"&&t.rename("proxy");}),e.getExportDeclarations().forEach(t=>{t.getNamedExports().forEach(s=>{s.getName()==="middleware"&&s.setName("proxy"),s.getAliasNode()?.getText()==="middleware"&&s.setAlias("proxy");});}),e);async function kn(e,t,r){if(!e?.length)return {filesCreated:[],filesUpdated:[],filesSkipped:[]};r={overwrite:false,force:false,silent:false,isRemote:false,isWorkspace:false,...r};let s=X("Updating files.",{silent:r.silent})?.start(),n=await B(t.resolvedPaths.cwd),i=[],o=[],a=[],l=[],f=null;for(let u=0;u<e.length;u++){let y=e[u];if(!y.content)continue;let g=Ce(y,t,{isSrcDir:n?.isSrcDir,framework:n?.framework.name,commonRoot:Ie(e.map(E=>E.path),y.path),path:r.path,fileIndex:u});if(!g)continue;let v=basename(y.path),C=h__default.dirname(g);if(t.tsx||(g=g.replace(/\.tsx?$/,E=>E===".tsx"?".jsx":".js")),V(g)&&!existsSync(g)){let E=Be(C);E&&(g=E);}let p=existsSync(g);if(p&&statSync(g).isDirectory())throw new Error(`Cannot write to ${g}: path exists and is a directory. Please provide a file path instead.`);let x=y.type==="registry:file"||y.type==="registry:item",b=V(g)||x?y.content:await Ye({filename:y.path,raw:y.content,config:t,transformJsx:!t.tsx,isRemote:r.isRemote},[ge,he,ue,ye,Ue,...Xe(g,n,t)?[Ze]:[]]);if(p&&!V(g)){let E=await promises.readFile(g,"utf-8");if(Ke(E,b,{ignoreImports:r.isWorkspace})){a.push(h__default.relative(t.resolvedPaths.cwd,g));continue}}if(p&&!r.overwrite&&!V(g)){s.stop(),r.rootSpinner&&r.rootSpinner.stop();let{overwrite:E}=await sr({type:"confirm",name:"overwrite",message:`The file ${k.info(v)} already exists. Would you like to overwrite?`,initial:false});if(!E){a.push(h__default.relative(t.resolvedPaths.cwd,g)),r.rootSpinner&&r.rootSpinner.start();continue}s?.start(),r.rootSpinner&&r.rootSpinner.start();}if(Xe(g,n,t)&&(g=g.replace(/middleware\.(ts|js)$/,"proxy.$1")),existsSync(C)||await promises.mkdir(C,{recursive:true}),V(g)&&p){let E=await promises.readFile(g,"utf-8"),S=He(E,b);if(l=Ge(E,b),f=h__default.relative(t.resolvedPaths.cwd,g),!l.length){a.push(h__default.relative(t.resolvedPaths.cwd,g));continue}await promises.writeFile(g,S,"utf-8"),o.push(h__default.relative(t.resolvedPaths.cwd,g));continue}await promises.writeFile(g,b,"utf-8"),p?o.push(h__default.relative(t.resolvedPaths.cwd,g)):(i.push(h__default.relative(t.resolvedPaths.cwd,g)),V(g)&&(l=Object.keys(G(b)),f=h__default.relative(t.resolvedPaths.cwd,g)));}let c=[...i,...o,...a],d=await fr(c,t);if(o.push(...d),o=o.filter(u=>!i.includes(u)),!(i.length||o.length)&&!a.length&&s?.info("No files updated."),i=Array.from(new Set(i)),o=Array.from(new Set(o)),a=Array.from(new Set(a)),i.length){if(s?.succeed(`Created ${i.length} ${i.length===1?"file":"files"}:`),!r.silent)for(let u of i)w.log(` - ${u}`);}else s?.stop();if(o.length&&(X(`Updated ${o.length} ${o.length===1?"file":"files"}:`,{silent:r.silent})?.info(),!r.silent))for(let u of o)w.log(` - ${u}`);if(a.length&&(X(`Skipped ${a.length} ${o.length===1?"file":"files"}: (files might be identical, use --overwrite to overwrite)`,{silent:r.silent})?.info(),!r.silent))for(let u of a)w.log(` - ${u}`);if(l.length&&f&&(X(`Added the following variables to ${k.info(f)}:`)?.info(),!r.silent))for(let u of l)w.log(` ${k.success("+")} ${u}`);return r.silent||w.break(),{filesCreated:i,filesUpdated:o,filesSkipped:a}}function Ce(e,t,r){if(r.path){let i=h__default.isAbsolute(r.path)?r.path:h__default.join(t.resolvedPaths.cwd,r.path);if(/\.[^/\\]+$/.test(i)){if(r.fileIndex===0)return i}else {let a=h__default.basename(e.path);return h__default.join(i,a)}}if(e.target){if(e.target.startsWith("~/"))return h__default.join(t.resolvedPaths.cwd,e.target.replace("~/",""));let i=e.target;return e.type==="registry:page"&&(i=lr(i,r.framework),!i)?"":r.isSrcDir?h__default.join(t.resolvedPaths.cwd,"src",i.replace("src/","")):h__default.join(t.resolvedPaths.cwd,i.replace("src/",""))}let s=ar(e,t),n=cr(e.path,s);return h__default.join(s,n)}function ar(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 Ie(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(f=>f!==s&&f.startsWith(a+"/")))return "/"+a}return "/"+n}function cr(e,t){let r=e.replace(/^\/|\/$/g,""),s=t.replace(/^\/|\/$/g,""),n=r.split("/"),i=s.split("/"),o=i[i.length-1],a=n.findIndex(l=>l===o);return a===-1?n[n.length-1]:n.slice(a+1).join("/")}function lr(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 fr(e,t){let r=new Project({compilerOptions:{}}),s=await B(t.resolvedPaths.cwd),n=loadConfig(t.resolvedPaths.cwd),i=[];if(!s||n.resultType==="failed")return [];for(let o of e){let a=h__default.resolve(t.resolvedPaths.cwd,o);if(!existsSync(a))continue;let l=await promises.readFile(a,"utf-8"),f=await promises.mkdtemp(h__default.join(tmpdir(),"createui-")),c=r.createSourceFile(h__default.join(f,basename(a)),l,{scriptKind:ScriptKind.TSX});if(![".tsx",".ts",".jsx",".js"].includes(c.getExtension()))continue;let d=c.getImportDeclarations();for(let m of d){let u=m.getModuleSpecifierValue();if(s?.aliasPrefix&&!u.startsWith(`${s.aliasPrefix}/`))continue;let y=await T(u,n);if(!y)continue;let g=pr(y,e,t);if(!g)continue;let v=mr(g,t,s);!v||v===u||(m.setModuleSpecifier(v),await promises.writeFile(a,c.getFullText(),"utf-8"),i.push(o));}}return i}function pr(e,t,r,s=[".tsx",".ts",".js",".jsx",".css"]){let n=h__default.normalize(r.resolvedPaths.cwd),i=t.map(v=>v.split(h__default.sep).join(h__default.posix.sep)),o=new Set(i),a=h__default.extname(e),l=a!=="",f=l?e.slice(0,-a.length):e,d=h__default.relative(n,f).split(h__default.sep).join(h__default.posix.sep),m=l?[a]:s,u=new Set;for(let v of m){let C=f+v,p=h__default.posix.normalize(h__default.relative(n,C));(o.has(p)||existsSync(C))&&u.add(p);let x=h__default.join(f,`index${v}`),b=h__default.posix.normalize(h__default.relative(n,x));(o.has(b)||existsSync(x))&&u.add(b);}let y=h__default.basename(f);for(let v of i)m.some(C=>v.endsWith(`/${y}${C}`))&&u.add(v);return u.size===0?null:Array.from(u).sort((v,C)=>{let p=h__default.posix.extname(v),x=h__default.posix.extname(C),b=m.indexOf(p)-m.indexOf(x);if(b!==0)return b;let E=d&&v.startsWith(d)?-1:1,S=d&&C.startsWith(d)?-1:1;return E-S})[0]}function mr(e,t,r){let s=h__default.normalize(h__default.join(t.resolvedPaths.cwd,e)),n=Object.entries(t.resolvedPaths).filter(([,y])=>y&&s.startsWith(h__default.normalize(y+h__default.sep))).sort((y,g)=>g[1].length-y[1].length);if(n.length===0)return null;let[i,o]=n[0],a=h__default.relative(o,s);a=a.split(h__default.sep).join("/");let l=h__default.posix.extname(a),c=[".ts",".tsx",".js",".jsx"].includes(l)?"":l,d=a.slice(0,a.length-l.length);d.endsWith("/index")&&(d=d.slice(0,-6));let m=i==="cwd"?r.aliasPrefix:t.aliases[i];if(!m)return null;let u=d===""?"":`/${d}`;return u=u.replace("/src",""),`${m}${u}${c}`}function Xe(e,t,r){let s=e===h__default.join(r.resolvedPaths.cwd,"middleware.ts")||e===h__default.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}var tt=[".tsx",".ts",".jsx",".js",".css"],rt=["lib/utils.ts"],yr=[/^(react|react-dom|next)(\/.*)?$/,/^(node|jsr|npm):.*$/],xr=new Project({compilerOptions:{}});function wr(e){if(yr.some(t=>t.test(e)))return null;if(!e.startsWith("@")&&e.includes("/")&&(e=e.split("/")[0]),e.startsWith("@")){let t=e.split("/");t.length>2&&(e=t.slice(0,2).join("/"));}return e}async function vr(e,t,r,s=new Set){let n=h.resolve(t.resolvedPaths.cwd,e),i=h.relative(t.resolvedPaths.cwd,n);if(rt.includes(i))return {dependencies:[],files:[]};let o=h.extname(e);if(!tt.includes(o))return {dependencies:[],files:[]};if(s.has(i))return {dependencies:[],files:[]};if(s.add(i),!(await z.stat(n)).isFile())return {dependencies:[],files:[]};let l=await z.readFile(n,"utf-8"),f=await Rr(h.basename(n)),c=xr.createSourceFile(f,l,{scriptKind:ScriptKind.TSX}),d=await loadConfig(t.resolvedPaths.cwd);if(d.resultType==="failed")return {dependencies:[],files:[]};let m=[],u=new Set,y=st(e),g={path:i,type:y,target:""};m.push(g);let v=c.getImportDeclarations();for(let p of v){let x=p.getModuleSpecifierValue(),b=x.startsWith(".");if(!x.startsWith(`${r.aliasPrefix}/`)&&!b){let N=wr(x);N&&u.add(N);continue}let S=await T(x,d);if(b&&(S=h.resolve(h.dirname(n),x)),!S)continue;if(!h.extname(S))for(let N of tt){let je=`${S}${N}`;try{await z.access(je),S=je;break}catch{continue}}let K=h.relative(t.resolvedPaths.cwd,S);if(s.has(K)||rt.includes(K))continue;let Y=st(x),Te={path:K,type:Y,target:""};(Y==="registry:page"||Y==="registry:file")&&(Te.target=x),m.push(Te);let te=await vr(K,t,r,s);if(te.files)for(let N of te.files)s.has(N.path)||(s.add(N.path),m.push(N));te.dependencies&&te.dependencies.forEach(N=>u.add(N));}let C=Array.from(new Map(m.map(p=>[p.path,p])).values());return {dependencies:Array.from(u),files:C}}async function Rr(e){let t=await z.mkdtemp(h.join(tmpdir(),"createui-"));return h.join(t,e)}function st(e){return e.includes("/ui/")?"registry:ui":e.includes("/lib/")?"registry:lib":e.includes("/hooks/")?"registry:hook":(e.includes("/components/"),"registry:component")}function F(e){try{return new URL(e),!0}catch{return false}}function xe(e){return e.endsWith(".json")&&!F(e)}function Un(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 nt(e$1,t){if(!br(t))return z$1.array(e).parse(e$1.flat().filter(Boolean));let r=await B(t.resolvedPaths.cwd),s=new Map,n=z$1.array(e).parse(e$1.flat().filter(Boolean));return n.forEach(i=>{let o=Ce(i,t,{isSrcDir:r?.isSrcDir,framework:r?.framework.name,commonRoot:Ie(n.map(a=>a.path),i.path)});o&&s.set(o,i);}),Array.from(s.values())}function br(e){return !!(e?.resolvedPaths?.cwd&&(e?.resolvedPaths?.ui||e?.resolvedPaths?.lib||e?.resolvedPaths?.components||e?.resolvedPaths?.hooks))}function J(e){return F(e)?e:`${ae}/${e}`}function it(e){let t=Ve();return e?b.parse(q(t,e)):t}var kr=process.env.https_proxy?new HttpsProxyAgent(process.env.https_proxy):void 0,Se=new Map;async function D(e,t={}){t={useCache:true,...t};try{return await Promise.all(e.map(async s=>{let n=J(s);if(t.useCache&&Se.has(n))return Se.get(n);let i=(async()=>{let o=await Pr(n,{agent:kr});if(!o.ok){let a;if(o.headers.get("content-type")?.includes("application/json")){let l=await o.json(),f=z$1.object({detail:z$1.string().optional(),title:z$1.string().optional(),message:z$1.string().optional(),error:z$1.string().optional()}).safeParse(l);f.success&&(a=f.data.detail||f.data.message,f.data.error&&(a=`[${f.data.error}] ${a}`));}throw o.status===401?new ne(n,a):o.status===404?new se(n,a):o.status===403?new ie(n,a):new oe(n,o.status,a)}return o.json()})();return t.useCache&&Se.set(n,i),i}))}catch(r){throw r}}async function at(e){try{let t=e;e.startsWith("~/")&&(t=h__default.join(homedir(),e.slice(2)));let r=h__default.resolve(t),s=await promises.readFile(r,"utf8"),n$1=JSON.parse(s);try{return n.parse(n$1)}catch(i){throw new $(e,i)}}catch(t){throw t instanceof Error&&(t.message.includes("ENOENT")||t.message.includes("no such file"))?new Z(e,t):t instanceof $?t:new Z(e,t)}}async function ee(e,t={}){return await Promise.all(e.map(async s=>{if(xe(s))return at(s);if(F(s)){let[o]=await D([s],t);try{return n.parse(o)}catch(a){throw new $(s,a)}}let n$1=`${s}.json`,[i]=await D([n$1],t);try{return n.parse(i)}catch(o){throw new $(s,o)}}))}m.extend({type:d,_source:z$1.string().optional(),fontVariant:l.optional(),config:z$1.any().optional()}).passthrough();async function lt(e,t,r={}){r={useCache:true,...r};let s$1=[],n$1=[],i=[],o=Array.from(new Set(e)),a=await ee(o,r),l=new Map;for(let p=0;p<a.length;p++)a[p]&&l.set(o[p],a[p]);for(let[p,x]of Array.from(l.entries())){let b={...x,_source:p};if(s$1.push(b),x.registryDependencies){let{items:E,registryNames:S}=await we(x.registryDependencies,t,r,new Set(o));n$1.push(...E),i.push(...S);}}if(s$1.push(...n$1),i.length>0){let p=Array.from(new Set(i)),x=await ft();if(!x&&s$1.length===0)return null;if(x){p.includes("index")&&p.unshift("index");let b=[];for(let K of p){let Y=await jr(K,t,r);b.push(...Y);}let E=Array.from(new Set(b)),S=await D(E,r),ke=z$1.array(n).parse(S);s$1.push(...ke);}}if(!s$1.length)return null;let f=new Map;s$1.forEach(p=>{let x=p._source||p.name;f.set(p,x);}),s$1=Nr(s$1,f),s$1.sort((p,x)=>p.type==="registry:theme"&&x.type!=="registry:theme"?-1:p.type!=="registry:theme"&&x.type==="registry:theme"?1:0);let c={};s$1.forEach(p=>{c=q(c,p.tailwind??{});});let d={};s$1.forEach(p=>{d=q(d,p.cssVars??{});});let m={};s$1.forEach(p=>{m=q(m,p.css??{});});let u="";s$1.forEach(p=>{p.docs&&(u+=`${p.docs}
14
- `);});let y={};s$1.forEach(p=>{y=q(y,p.envVars??{});});let g=await nt(s$1.map(p=>p.files??[]),t),v=[];for(let p of s$1)if(p.type==="registry:font-variant"&&p.fontVariant)for(let x of ["display","body","numeric"]){let b=p.fontVariant[x];b&&v.push({name:`${p.name}-${x}`,type:"registry:font",role:x,font:b});}let C=s.parse({dependencies:q.all(s$1.map(p=>p.dependencies??[])),devDependencies:q.all(s$1.map(p=>p.devDependencies??[])),files:g,tailwind:c,cssVars:d,css:m,docs:u,fonts:v.length>0?v:void 0});return Object.keys(y).length>0&&(C.envVars=y),C}async function we(e,t,r={},s=new Set){let n=[],i=[];for(let o of e)if(!s.has(o))if(s.add(o),F(o)||xe(o)){let[a]=await ee([o],r);if(a&&(n.push(a),a.registryDependencies)){let l=await we(a.registryDependencies,t,r,s);n.push(...l.items),i.push(...l.registryNames);}}else {i.push(o);try{let[a]=await ee([o],r);if(a&&a.registryDependencies){let l=await we(a.registryDependencies,t,r,s);n.push(...l.items),i.push(...l.registryNames);}}catch{}}return {items:n,registryNames:i}}async function jr(e,t,r={}){if(F(e))return [e];let{registryNames:s}=await we([e],t,r,new Set),n=s.map(i=>J(F(i)?i:`${i}.json`));return Array.from(new Set(n))}function W(e,t){let r=t||e.name,s=createHash("sha256").update(r).digest("hex").substring(0,8);return `${e.name}::${s}`}function Fr(e){if(F(e)){let r=new URL(e).pathname,s=r.match(/\/([^/]+)\.json$/),n=s?s[1]:h__default.basename(r,".json");return {name:n,hash:W({name:n},e)}}if(xe(e)){let t=e.match(/\/([^/]+)\.json$/),r=t?t[1]:h__default.basename(e,".json");return {name:r,hash:W({name:r},e)}}return {name:e,hash:W({name:e},e)}}function Nr(e,t){let r=new Map,s=new Map,n=new Map,i=new Map;e.forEach(f=>{let c=t.get(f)||f.name,d=W(f,c);r.set(d,f),s.set(d,f),n.set(d,0),i.set(d,[]);});let o=new Map;e.forEach(f=>{let c=t.get(f)||f.name,d=W(f,c);o.has(f.name)||o.set(f.name,[]),o.get(f.name).push(d),c!==f.name&&(o.has(c)||o.set(c,[]),o.get(c).push(d));}),e.forEach(f=>{let c=t.get(f)||f.name,d=W(f,c);f.registryDependencies&&f.registryDependencies.forEach(m=>{let u,y=o.get(m)||[];if(y.length===1)u=y[0];else if(y.length>1)u=y[0];else {let{name:g}=Fr(m),v=o.get(g)||[];v.length>0&&(u=v[0]);}u&&r.has(u)&&(i.get(u).push(d),n.set(d,n.get(d)+1));});});let a=[],l=[];for(n.forEach((f,c)=>{f===0&&a.push(c);});a.length>0;){let f=a.shift(),c=r.get(f);l.push(c),i.get(f).forEach(d=>{let m=n.get(d)-1;n.set(d,m),m===0&&a.push(d);});}if(l.length!==e.length){console.warn("Circular dependency detected in registry items");let f=new Set(l.map(c=>{let d=t.get(c)||c.name;return W(c,d)}));e.forEach(c=>{let d=t.get(c)||c.name,m=W(c,d);f.has(m)||l.push(c);});}return l}function ve(e){if(w.break(),w.error("Something went wrong. Please check the error below for more details."),w.error("If the problem persists, please open an issue on GitHub."),w.error(""),typeof e=="string"&&(w.error(e),w.break(),process.exit(1)),e instanceof O&&(e.message&&(w.error(e.cause?"Error:":"Message:"),w.error(e.message)),e.cause&&(w.error(`
13
+ `:n}var w={error(...e){console.log(T.error(e.join(" ")));},warn(...e){console.log(T.warn(e.join(" ")));},info(...e){console.log(T.info(e.join(" ")));},success(...e){console.log(T.success(e.join(" ")));},log(...e){console.log(e.join(" "));},break(){console.log("");}};function X(e,t){return Wt({text:e,isSilent:t?.silent})}var ge=async({sourceFile:e})=>e;var de=async({sourceFile:e,config:t,isRemote:r})=>{let s=t.aliases?.utils,i=`${typeof s=="string"&&s.includes("/")?s.split("/")[0]:"@"}/lib/utils`;if(![".tsx",".ts",".jsx",".js"].includes(e.getExtension()))return e;for(let o of e.getImportStringLiterals()){let a=Vt(o.getLiteralValue(),t,r);if(o.setLiteralValue(a),i===a||a==="@/lib/utils"){if(!o.getFirstAncestorByKind(SyntaxKind.ImportDeclaration)?.getNamedImports().some(c=>c.getName()==="cn")||!t.aliases.utils)continue;o.setLiteralValue(i===a?a.replace(i,t.aliases.utils):t.aliases.utils);}}return e};function Vt(e,t,r=false){if(!e.startsWith("@/")&&!r)return e;if(r&&e.startsWith("@/")&&(e=e.replace(/^@\//,"@/registry/_/")),!e.startsWith("@/registry/")){let s=t.aliases.components.split("/")[0];return e.replace(/^@\//,`${s}/`)}return e.match(/^@\/registry\/((.+)\/)?ui/)?e.replace(/^@\/registry\/((.+)\/)?ui/,t.aliases.ui??`${t.aliases.components}/ui`):t.aliases.components&&e.match(/^@\/registry\/((.+)\/)?components/)?e.replace(/^@\/registry\/((.+)\/)?components/,t.aliases.components):t.aliases.lib&&e.match(/^@\/registry\/((.+)\/)?lib/)?e.replace(/^@\/registry\/((.+)\/)?lib/,t.aliases.lib):t.aliases.hooks&&e.match(/^@\/registry\/((.+)\/)?hooks/)?e.replace(/^@\/registry\/((.+)\/)?hooks/,t.aliases.hooks):e.replace(/^@\/registry\/[^/]+/,t.aliases.components)}var Gt={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"]},Ye=async({sourceFile:e,config:t})=>{let r=e.getFullText();if(t.tsx)return r;let s=he.parse(r,{parser:{parse:i=>parse(i,Gt)}}),n=transformFromAstSync(s,r,{cloneInputAst:false,code:false,ast:true,plugins:[Bt],configFile:false});if(!n||!n.ast)throw new Error("Failed to transform JSX");return he.print(n.ast).code};var Jt=/^["']use client["']$/g,ye=async({sourceFile:e,config:t})=>{if(t.rsc)return e;let r=e.getFirstChildByKind(SyntaxKind.ExpressionStatement);return r&&Jt.test(r.getText())&&r.remove(),e};var xe=async({sourceFile:e,config:t})=>(t.tailwind?.prefix&&(e.getDescendantsOfKind(SyntaxKind.CallExpression).filter(r=>r.getExpression().getText()==="cva").forEach(r=>{if(r.getArguments()[0]?.isKind(SyntaxKind.StringLiteral)){let s=r.getArguments()[0];s&&s.replaceWithText(`"${_(s.getText()?.replace(/"|'/g,""),t.tailwind.prefix)}"`);}r.getArguments()[1]?.isKind(SyntaxKind.ObjectLiteralExpression)&&r.getArguments()[1]?.getDescendantsOfKind(SyntaxKind.PropertyAssignment).find(s=>s.getName()==="variants")?.getDescendantsOfKind(SyntaxKind.PropertyAssignment).forEach(s=>{s.getDescendantsOfKind(SyntaxKind.PropertyAssignment).forEach(n=>{let i=n.getInitializerIfKind(SyntaxKind.StringLiteral);i&&i?.replaceWithText(`"${_(i.getText()?.replace(/"|'/g,""),t.tailwind.prefix)}"`);});});}),e.getDescendantsOfKind(SyntaxKind.JsxAttribute).forEach(r=>{if(r.getNameNode().getText()==="className"){if(r.getInitializer()?.isKind(SyntaxKind.StringLiteral)){let s=r.getInitializer();s&&s.replaceWithText(`"${_(s.getText()?.replace(/"|'/g,""),t.tailwind.prefix)}"`);}if(r.getInitializer()?.isKind(SyntaxKind.JsxExpression)){let s=r.getInitializer()?.getDescendantsOfKind(SyntaxKind.CallExpression).find(n=>n.getExpression().getText()==="cn");s&&s.getArguments().forEach(n=>{(n.isKind(SyntaxKind.ConditionalExpression)||n.isKind(SyntaxKind.BinaryExpression))&&n.getChildrenOfKind(SyntaxKind.StringLiteral).forEach(i=>{i.replaceWithText(`"${_(i.getText()?.replace(/"|'/g,""),t.tailwind.prefix)}"`);}),n.isKind(SyntaxKind.StringLiteral)&&n.replaceWithText(`"${_(n.getText()?.replace(/"|'/g,""),t.tailwind.prefix)}"`);});}}r.getNameNode().getText()==="classNames"&&r.getInitializer()?.isKind(SyntaxKind.JsxExpression)&&r.getDescendantsOfKind(SyntaxKind.PropertyAssignment).forEach(s=>{if(s.getInitializer()?.isKind(SyntaxKind.CallExpression)){let n=s.getInitializerIfKind(SyntaxKind.CallExpression);n&&n.getArguments().forEach(i=>{i.isKind(SyntaxKind.ConditionalExpression)&&i.getChildrenOfKind(SyntaxKind.StringLiteral).forEach(o=>{o.replaceWithText(`"${_(o.getText()?.replace(/"|'/g,""),t.tailwind.prefix)}"`);}),i.isKind(SyntaxKind.StringLiteral)&&i.replaceWithText(`"${_(i.getText()?.replace(/"|'/g,""),t.tailwind.prefix)}"`);});}if(s.getInitializer()?.isKind(SyntaxKind.StringLiteral)&&s.getNameNode().getText()!=="variant"){let n=s.getInitializer();n&&n.replaceWithText(`"${_(n.getText()?.replace(/"|'/g,""),t.tailwind.prefix)}"`);}});})),e);function _(e,t=""){return e.split(" ").map(r=>r.indexOf(`${t}:`)===0?r:`${t}:${r.trim()}`).join(" ")}var Qt=new Project({compilerOptions:{}});async function er(e){let t=await promises.mkdtemp(h__default.join(tmpdir(),"createui-"));return h__default.join(t,e)}async function Xe(e,t=[de,ye,ge,xe]){let r=await er(e.filename),s=Qt.createSourceFile(r,e.raw,{scriptKind:ScriptKind.TSX});for(let n of t)await n({sourceFile:s,...e});return e.transformJsx?await Ye({sourceFile:s,...e}):s.getText()}var Qe=async({sourceFile:e})=>(e.getFunctions().forEach(t=>{t.getName()==="middleware"&&t.rename("proxy");}),e.getVariableDeclarations().forEach(t=>{t.getName()==="middleware"&&t.rename("proxy");}),e.getExportDeclarations().forEach(t=>{t.getNamedExports().forEach(s=>{s.getName()==="middleware"&&s.setName("proxy"),s.getAliasNode()?.getText()==="middleware"&&s.setAlias("proxy");});}),e);async function kn(e,t,r){if(!e?.length)return {filesCreated:[],filesUpdated:[],filesSkipped:[]};r={overwrite:false,force:false,silent:false,isRemote:false,isWorkspace:false,...r};let s=X("Updating files.",{silent:r.silent})?.start(),n=await B(t.resolvedPaths.cwd),i=[],o=[],a=[],l=[],f=null;for(let u=0;u<e.length;u++){let y=e[u];if(!y.content)continue;let g=Ie(y,t,{isSrcDir:n?.isSrcDir,framework:n?.framework.name,commonRoot:Se(e.map(E=>E.path),y.path),path:r.path,fileIndex:u});if(!g)continue;let v=basename(y.path),C=h__default.dirname(g);if(t.tsx||(g=g.replace(/\.tsx?$/,E=>E===".tsx"?".jsx":".js")),V(g)&&!existsSync(g)){let E=He(C);E&&(g=E);}let p=existsSync(g);if(p&&statSync(g).isDirectory())throw new Error(`Cannot write to ${g}: path exists and is a directory. Please provide a file path instead.`);let x=y.type==="registry:file"||y.type==="registry:item",b=V(g)||x?y.content:await Xe({filename:y.path,raw:y.content,config:t,transformJsx:!t.tsx,isRemote:r.isRemote},[de,ye,ge,xe,Ke,...et(g,n,t)?[Qe]:[]]);if(p&&!V(g)){let E=await promises.readFile(g,"utf-8");if(Be(E,b,{ignoreImports:r.isWorkspace})){a.push(h__default.relative(t.resolvedPaths.cwd,g));continue}}if(p&&!r.overwrite&&!V(g)){s.stop(),r.rootSpinner&&r.rootSpinner.stop();let{overwrite:E}=await sr({type:"confirm",name:"overwrite",message:`The file ${T.info(v)} already exists. Would you like to overwrite?`,initial:false});if(!E){a.push(h__default.relative(t.resolvedPaths.cwd,g)),r.rootSpinner&&r.rootSpinner.start();continue}s?.start(),r.rootSpinner&&r.rootSpinner.start();}if(et(g,n,t)&&(g=g.replace(/middleware\.(ts|js)$/,"proxy.$1")),existsSync(C)||await promises.mkdir(C,{recursive:true}),V(g)&&p){let E=await promises.readFile(g,"utf-8"),S=qe(E,b);if(l=Je(E,b),f=h__default.relative(t.resolvedPaths.cwd,g),!l.length){a.push(h__default.relative(t.resolvedPaths.cwd,g));continue}await promises.writeFile(g,S,"utf-8"),o.push(h__default.relative(t.resolvedPaths.cwd,g));continue}await promises.writeFile(g,b,"utf-8"),p?o.push(h__default.relative(t.resolvedPaths.cwd,g)):(i.push(h__default.relative(t.resolvedPaths.cwd,g)),V(g)&&(l=Object.keys(G(b)),f=h__default.relative(t.resolvedPaths.cwd,g)));}let c=[...i,...o,...a],d=await fr(c,t);if(o.push(...d),o=o.filter(u=>!i.includes(u)),!(i.length||o.length)&&!a.length&&s?.info("No files updated."),i=Array.from(new Set(i)),o=Array.from(new Set(o)),a=Array.from(new Set(a)),i.length){if(s?.succeed(`Created ${i.length} ${i.length===1?"file":"files"}:`),!r.silent)for(let u of i)w.log(` - ${u}`);}else s?.stop();if(o.length&&(X(`Updated ${o.length} ${o.length===1?"file":"files"}:`,{silent:r.silent})?.info(),!r.silent))for(let u of o)w.log(` - ${u}`);if(a.length&&(X(`Skipped ${a.length} ${o.length===1?"file":"files"}: (files might be identical, use --overwrite to overwrite)`,{silent:r.silent})?.info(),!r.silent))for(let u of a)w.log(` - ${u}`);if(l.length&&f&&(X(`Added the following variables to ${T.info(f)}:`)?.info(),!r.silent))for(let u of l)w.log(` ${T.success("+")} ${u}`);return r.silent||w.break(),{filesCreated:i,filesUpdated:o,filesSkipped:a}}function Ie(e,t,r){if(r.path){let i=h__default.isAbsolute(r.path)?r.path:h__default.join(t.resolvedPaths.cwd,r.path);if(/\.[^/\\]+$/.test(i)){if(r.fileIndex===0)return i}else {let a=h__default.basename(e.path);return h__default.join(i,a)}}if(e.target){if(e.target.startsWith("~/"))return h__default.join(t.resolvedPaths.cwd,e.target.replace("~/",""));let i=e.target;return e.type==="registry:page"&&(i=lr(i,r.framework),!i)?"":r.isSrcDir?h__default.join(t.resolvedPaths.cwd,"src",i.replace("src/","")):h__default.join(t.resolvedPaths.cwd,i.replace("src/",""))}let s=ar(e,t),n=cr(e.path,s);return h__default.join(s,n)}function ar(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 Se(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(f=>f!==s&&f.startsWith(a+"/")))return "/"+a}return "/"+n}function cr(e,t){let r=e.replace(/^\/|\/$/g,""),s=t.replace(/^\/|\/$/g,""),n=r.split("/"),i=s.split("/"),o=i[i.length-1],a=n.findIndex(l=>l===o);return a===-1?n[n.length-1]:n.slice(a+1).join("/")}function lr(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 fr(e,t){let r=new Project({compilerOptions:{}}),s=await B(t.resolvedPaths.cwd),n=loadConfig(t.resolvedPaths.cwd),i=[];if(!s||n.resultType==="failed")return [];for(let o of e){let a=h__default.resolve(t.resolvedPaths.cwd,o);if(!existsSync(a))continue;let l=await promises.readFile(a,"utf-8"),f=await promises.mkdtemp(h__default.join(tmpdir(),"createui-")),c=r.createSourceFile(h__default.join(f,basename(a)),l,{scriptKind:ScriptKind.TSX});if(![".tsx",".ts",".jsx",".js"].includes(c.getExtension()))continue;let d=c.getImportDeclarations();for(let m of d){let u=m.getModuleSpecifierValue();if(s?.aliasPrefix&&!u.startsWith(`${s.aliasPrefix}/`))continue;let y=await k(u,n);if(!y)continue;let g=pr(y,e,t);if(!g)continue;let v=mr(g,t,s);!v||v===u||(m.setModuleSpecifier(v),await promises.writeFile(a,c.getFullText(),"utf-8"),i.push(o));}}return i}function pr(e,t,r,s=[".tsx",".ts",".js",".jsx",".css"]){let n=h__default.normalize(r.resolvedPaths.cwd),i=t.map(v=>v.split(h__default.sep).join(h__default.posix.sep)),o=new Set(i),a=h__default.extname(e),l=a!=="",f=l?e.slice(0,-a.length):e,d=h__default.relative(n,f).split(h__default.sep).join(h__default.posix.sep),m=l?[a]:s,u=new Set;for(let v of m){let C=f+v,p=h__default.posix.normalize(h__default.relative(n,C));(o.has(p)||existsSync(C))&&u.add(p);let x=h__default.join(f,`index${v}`),b=h__default.posix.normalize(h__default.relative(n,x));(o.has(b)||existsSync(x))&&u.add(b);}let y=h__default.basename(f);for(let v of i)m.some(C=>v.endsWith(`/${y}${C}`))&&u.add(v);return u.size===0?null:Array.from(u).sort((v,C)=>{let p=h__default.posix.extname(v),x=h__default.posix.extname(C),b=m.indexOf(p)-m.indexOf(x);if(b!==0)return b;let E=d&&v.startsWith(d)?-1:1,S=d&&C.startsWith(d)?-1:1;return E-S})[0]}function mr(e,t,r){let s=h__default.normalize(h__default.join(t.resolvedPaths.cwd,e)),n=Object.entries(t.resolvedPaths).filter(([,y])=>y&&s.startsWith(h__default.normalize(y+h__default.sep))).sort((y,g)=>g[1].length-y[1].length);if(n.length===0)return null;let[i,o]=n[0],a=h__default.relative(o,s);a=a.split(h__default.sep).join("/");let l=h__default.posix.extname(a),c=[".ts",".tsx",".js",".jsx"].includes(l)?"":l,d=a.slice(0,a.length-l.length);d.endsWith("/index")&&(d=d.slice(0,-6));let m=i==="cwd"?r.aliasPrefix:t.aliases[i];if(!m)return null;let u=d===""?"":`/${d}`;return u=u.replace("/src",""),`${m}${u}${c}`}function et(e,t,r){let s=e===h__default.join(r.resolvedPaths.cwd,"middleware.ts")||e===h__default.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}var st=[".tsx",".ts",".jsx",".js",".css"],nt=["lib/utils.ts"],yr=[/^(react|react-dom|next)(\/.*)?$/,/^(node|jsr|npm):.*$/],xr=new Project({compilerOptions:{}});function wr(e){if(yr.some(t=>t.test(e)))return null;if(!e.startsWith("@")&&e.includes("/")&&(e=e.split("/")[0]),e.startsWith("@")){let t=e.split("/");t.length>2&&(e=t.slice(0,2).join("/"));}return e}async function vr(e,t,r,s=new Set){let n=h.resolve(t.resolvedPaths.cwd,e),i=h.relative(t.resolvedPaths.cwd,n);if(nt.includes(i))return {dependencies:[],files:[]};let o=h.extname(e);if(!st.includes(o))return {dependencies:[],files:[]};if(s.has(i))return {dependencies:[],files:[]};if(s.add(i),!(await z.stat(n)).isFile())return {dependencies:[],files:[]};let l=await z.readFile(n,"utf-8"),f=await Rr(h.basename(n)),c=xr.createSourceFile(f,l,{scriptKind:ScriptKind.TSX}),d=await loadConfig(t.resolvedPaths.cwd);if(d.resultType==="failed")return {dependencies:[],files:[]};let m=[],u=new Set,y=it(e),g={path:i,type:y,target:""};m.push(g);let v=c.getImportDeclarations();for(let p of v){let x=p.getModuleSpecifierValue(),b=x.startsWith(".");if(!x.startsWith(`${r.aliasPrefix}/`)&&!b){let N=wr(x);N&&u.add(N);continue}let S=await k(x,d);if(b&&(S=h.resolve(h.dirname(n),x)),!S)continue;if(!h.extname(S))for(let N of st){let Ne=`${S}${N}`;try{await z.access(Ne),S=Ne;break}catch{continue}}let K=h.relative(t.resolvedPaths.cwd,S);if(s.has(K)||nt.includes(K))continue;let Y=it(x),Fe={path:K,type:Y,target:""};(Y==="registry:page"||Y==="registry:file")&&(Fe.target=x),m.push(Fe);let te=await vr(K,t,r,s);if(te.files)for(let N of te.files)s.has(N.path)||(s.add(N.path),m.push(N));te.dependencies&&te.dependencies.forEach(N=>u.add(N));}let C=Array.from(new Map(m.map(p=>[p.path,p])).values());return {dependencies:Array.from(u),files:C}}async function Rr(e){let t=await z.mkdtemp(h.join(tmpdir(),"createui-"));return h.join(t,e)}function it(e){return e.includes("/ui/")?"registry:ui":e.includes("/lib/")?"registry:lib":e.includes("/hooks/")?"registry:hook":(e.includes("/components/"),"registry:component")}function F(e){try{return new URL(e),!0}catch{return false}}function we(e){return e.endsWith(".json")&&!F(e)}function Vn(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 ot(e$1,t){if(!br(t))return z$1.array(e).parse(e$1.flat().filter(Boolean));let r=await B(t.resolvedPaths.cwd),s=new Map,n=z$1.array(e).parse(e$1.flat().filter(Boolean));return n.forEach(i=>{let o=Ie(i,t,{isSrcDir:r?.isSrcDir,framework:r?.framework.name,commonRoot:Se(n.map(a=>a.path),i.path)});o&&s.set(o,i);}),Array.from(s.values())}function br(e){return !!(e?.resolvedPaths?.cwd&&(e?.resolvedPaths?.ui||e?.resolvedPaths?.lib||e?.resolvedPaths?.components||e?.resolvedPaths?.hooks))}function J(e){return F(e)?e:`${ae}/${e}`}function at(e){let t=Me();return e?b.parse(q(t,e)):t}var Tr=process.env.https_proxy?new HttpsProxyAgent(process.env.https_proxy):void 0,Pe=new Map;async function D(e,t={}){t={useCache:true,...t};try{return await Promise.all(e.map(async s=>{let n=J(s);if(t.useCache&&Pe.has(n))return Pe.get(n);let i=(async()=>{let o=await Pr(n,{agent:Tr});if(!o.ok){let a;if(o.headers.get("content-type")?.includes("application/json")){let l=await o.json(),f=z$1.object({detail:z$1.string().optional(),title:z$1.string().optional(),message:z$1.string().optional(),error:z$1.string().optional()}).safeParse(l);f.success&&(a=f.data.detail||f.data.message,f.data.error&&(a=`[${f.data.error}] ${a}`));}throw o.status===401?new ne(n,a):o.status===404?new se(n,a):o.status===403?new ie(n,a):new oe(n,o.status,a)}return o.json()})();return t.useCache&&Pe.set(n,i),i}))}catch(r){throw r}}async function lt(e){try{let t=e;e.startsWith("~/")&&(t=h__default.join(homedir(),e.slice(2)));let r=h__default.resolve(t),s=await promises.readFile(r,"utf8"),n$1=JSON.parse(s);try{return n.parse(n$1)}catch(i){throw new $(e,i)}}catch(t){throw t instanceof Error&&(t.message.includes("ENOENT")||t.message.includes("no such file"))?new Z(e,t):t instanceof $?t:new Z(e,t)}}async function ee(e,t={}){return await Promise.all(e.map(async s=>{if(we(s))return lt(s);if(F(s)){let[o]=await D([s],t);try{return n.parse(o)}catch(a){throw new $(s,a)}}let n$1=`${s}.json`,[i]=await D([n$1],t);try{return n.parse(i)}catch(o){throw new $(s,o)}}))}m.extend({type:d,_source:z$1.string().optional(),fontVariant:l.optional(),config:z$1.any().optional()}).passthrough();async function pt(e,t,r={}){r={useCache:true,...r};let s$1=[],n$1=[],i=[],o=Array.from(new Set(e)),a=await ee(o,r),l=new Map;for(let p=0;p<a.length;p++)a[p]&&l.set(o[p],a[p]);for(let[p,x]of Array.from(l.entries())){let b={...x,_source:p};if(s$1.push(b),x.registryDependencies){let{items:E,registryNames:S}=await ve(x.registryDependencies,t,r,new Set(o));n$1.push(...E),i.push(...S);}}if(s$1.push(...n$1),i.length>0){let p=Array.from(new Set(i)),x=await ke();if(!x&&s$1.length===0)return null;if(x){p.includes("index")&&p.unshift("index");let b=[];for(let K of p){let Y=await jr(K,t,r);b.push(...Y);}let E=Array.from(new Set(b)),S=await D(E,r),je=z$1.array(n).parse(S);s$1.push(...je);}}if(!s$1.length)return null;let f=new Map;s$1.forEach(p=>{let x=p._source||p.name;f.set(p,x);}),s$1=Nr(s$1,f),s$1.sort((p,x)=>p.type==="registry:theme"&&x.type!=="registry:theme"?-1:p.type!=="registry:theme"&&x.type==="registry:theme"?1:0);let c={};s$1.forEach(p=>{c=q(c,p.tailwind??{});});let d={};s$1.forEach(p=>{d=q(d,p.cssVars??{});});let m={};s$1.forEach(p=>{m=q(m,p.css??{});});let u="";s$1.forEach(p=>{p.docs&&(u+=`${p.docs}
14
+ `);});let y={};s$1.forEach(p=>{y=q(y,p.envVars??{});});let g=await ot(s$1.map(p=>p.files??[]),t),v=[];for(let p of s$1)if(p.type==="registry:font-variant"&&p.fontVariant)for(let x of ["display","body","numeric"]){let b=p.fontVariant[x];b&&v.push({name:`${p.name}-${x}`,type:"registry:font",role:x,font:b});}let C=s.parse({dependencies:q.all(s$1.map(p=>p.dependencies??[])),devDependencies:q.all(s$1.map(p=>p.devDependencies??[])),files:g,tailwind:c,cssVars:d,css:m,docs:u,fonts:v.length>0?v:void 0});return Object.keys(y).length>0&&(C.envVars=y),C}async function ve(e,t,r={},s=new Set){let n=[],i=[];for(let o of e)if(!s.has(o))if(s.add(o),F(o)||we(o)){let[a]=await ee([o],r);if(a&&(n.push(a),a.registryDependencies)){let l=await ve(a.registryDependencies,t,r,s);n.push(...l.items),i.push(...l.registryNames);}}else {i.push(o);try{let[a]=await ee([o],r);if(a&&a.registryDependencies){let l=await ve(a.registryDependencies,t,r,s);n.push(...l.items),i.push(...l.registryNames);}}catch{}}return {items:n,registryNames:i}}async function jr(e,t,r={}){if(F(e))return [e];let{registryNames:s}=await ve([e],t,r,new Set),n=s.map(i=>J(F(i)?i:`${i}.json`));return Array.from(new Set(n))}function W(e,t){let r=t||e.name,s=createHash("sha256").update(r).digest("hex").substring(0,8);return `${e.name}::${s}`}function Fr(e){if(F(e)){let r=new URL(e).pathname,s=r.match(/\/([^/]+)\.json$/),n=s?s[1]:h__default.basename(r,".json");return {name:n,hash:W({name:n},e)}}if(we(e)){let t=e.match(/\/([^/]+)\.json$/),r=t?t[1]:h__default.basename(e,".json");return {name:r,hash:W({name:r},e)}}return {name:e,hash:W({name:e},e)}}function Nr(e,t){let r=new Map,s=new Map,n=new Map,i=new Map;e.forEach(f=>{let c=t.get(f)||f.name,d=W(f,c);r.set(d,f),s.set(d,f),n.set(d,0),i.set(d,[]);});let o=new Map;e.forEach(f=>{let c=t.get(f)||f.name,d=W(f,c);o.has(f.name)||o.set(f.name,[]),o.get(f.name).push(d),c!==f.name&&(o.has(c)||o.set(c,[]),o.get(c).push(d));}),e.forEach(f=>{let c=t.get(f)||f.name,d=W(f,c);f.registryDependencies&&f.registryDependencies.forEach(m=>{let u,y=o.get(m)||[];if(y.length===1)u=y[0];else if(y.length>1)u=y[0];else {let{name:g}=Fr(m),v=o.get(g)||[];v.length>0&&(u=v[0]);}u&&r.has(u)&&(i.get(u).push(d),n.set(d,n.get(d)+1));});});let a=[],l=[];for(n.forEach((f,c)=>{f===0&&a.push(c);});a.length>0;){let f=a.shift(),c=r.get(f);l.push(c),i.get(f).forEach(d=>{let m=n.get(d)-1;n.set(d,m),m===0&&a.push(d);});}if(l.length!==e.length){console.warn("Circular dependency detected in registry items");let f=new Set(l.map(c=>{let d=t.get(c)||c.name;return W(c,d)}));e.forEach(c=>{let d=t.get(c)||c.name,m=W(c,d);f.has(m)||l.push(c);});}return l}function Re(e){if(w.break(),w.error("Something went wrong. Please check the error below for more details."),w.error("If the problem persists, please open an issue on GitHub."),w.error(""),typeof e=="string"&&(w.error(e),w.break(),process.exit(1)),e instanceof O&&(e.message&&(w.error(e.cause?"Error:":"Message:"),w.error(e.message)),e.cause&&(w.error(`
15
15
  Message:`),w.error(e.cause)),e.suggestion&&(w.error(`
16
- Suggestion:`),w.error(e.suggestion)),w.break(),process.exit(1)),e instanceof z$1.ZodError){w.error("Validation failed:");for(let[t,r]of Object.entries(e.flatten().fieldErrors))w.error(`- ${k.info(t)}: ${r}`);w.break(),process.exit(1);}e instanceof Error&&(w.error(e.message),w.break(),process.exit(1)),w.break(),process.exit(1);}async function Dr(e,t){let{useCache:r}=t||{},s=F(e)?e:J("registry.json"),[n]=await D([s],{useCache:r});try{return o.parse(n)}catch(i){throw new $(e,i)}}async function Li(e,t){let{useCache:r=false}=t||{};return ee(e,{useCache:r})}async function zi(e,t){let{config:r,useCache:s=false}=t||{};return lt(e,it(r),{useCache:s})}async function ft(){try{return (await Dr("registry.json")).items}catch(e){w.error(`
17
- `),ve(e);}}async function Wi(){try{let[e]=await D(["styles/index.json"]);return q$1.parse(e)}catch{return []}}async function Ui(){try{let[e]=await D(["icons/index.json"]);return r.parse(e)}catch(e){return ve(e),{}}}async function Ar(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 Ar(e,n.registryDependencies);r.push(...i);}}return r.filter((s,n,i)=>i.findIndex(o=>o.name===s.name)===n)}async function Vi(e,t){try{let r=t.map(n=>`${n.name}.json`);return (await D(r)).map(n$1=>n.parse(n$1))}catch(r){return ve(r),[]}}async function Ki(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?h__default.join(e.resolvedPaths[s],n):null}async function _r(e){e={useCache:true,...e};let t=`${ae}/config.json`,[r]=await D([t],{useCache:e.useCache});return w$1.parse(r).presets}async function Mi(e,t){return (await _r(t)).find(s=>s.name.toLowerCase()===e.toLowerCase())??null}export{_r as $,He as A,Ye as B,Ue as C,kn as D,vr as E,F,Un as G,it as H,O as I,se as J,ne as K,ie as L,oe as M,Z as N,$ as O,D as P,lt as Q,ve as R,Dr as S,Li as T,zi as U,ft as V,Wi as W,Ui as X,Ar as Y,Vi as Z,Ki as _,k as a,Mi as aa,as as b,cs as c,ls as d,fs as e,ce as f,be as g,ps as h,Pt as i,Tt as j,Ve as k,Ee as l,B as m,Ps as n,w as o,X as p,ut as q,dt as r,Kr as s,Mr as t,ht as u,Br as v,Gr as w,Hr as x,Be as y,Ge as z};//# sourceMappingURL=chunk-UPXNWTZZ.js.map
18
- //# sourceMappingURL=chunk-UPXNWTZZ.js.map
16
+ Suggestion:`),w.error(e.suggestion)),w.break(),process.exit(1)),e instanceof z$1.ZodError){w.error("Validation failed:");for(let[t,r]of Object.entries(e.flatten().fieldErrors))w.error(`- ${T.info(t)}: ${r}`);w.break(),process.exit(1);}e instanceof Error&&(w.error(e.message),w.break(),process.exit(1)),w.break(),process.exit(1);}async function Dr(e,t){let{useCache:r}=t||{},s=F(e)?e:J("registry.json"),[n]=await D([s],{useCache:r});try{return o.parse(n)}catch(i){throw new $(e,i)}}async function zi(e,t){let{useCache:r=false}=t||{};return ee(e,{useCache:r})}async function Wi(e,t){let{config:r,useCache:s=false}=t||{};return pt(e,at(r),{useCache:s})}async function ke(){try{return (await Dr("registry.json")).items}catch(e){w.error(`
17
+ `),Re(e);}}async function Ui(){try{let[e]=await D(["styles/index.json"]);return q$1.parse(e)}catch{return []}}async function Vi(){try{let[e]=await D(["icons/index.json"]);return r.parse(e)}catch(e){return Re(e),{}}}async function Ar(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 Ar(e,n.registryDependencies);r.push(...i);}}return r.filter((s,n,i)=>i.findIndex(o=>o.name===s.name)===n)}async function Ki(e,t){try{let r=t.map(n=>`${n.name}.json`);return (await D(r)).map(n$1=>n.parse(n$1))}catch(r){return Re(r),[]}}async function Mi(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?h__default.join(e.resolvedPaths[s],n):null}async function _r(e){e={useCache:true,...e};let t=`${ae}/config.json`,[r]=await D([t],{useCache:e.useCache});return w$1.parse(r).presets}async function Bi(e,t){return (await _r(t)).find(s=>s.name.toLowerCase()===e.toLowerCase())??null}function Lr(e){return (e.split(",")[0]?.trim().replace(/^['"]|['"]$/g,"")??e).replace(/\s*variable$/i,"").trim()}async function Gi(){try{let e=await ke()??[],t=[];for(let r of e){if(r.type!=="registry:font-variant"||!r.fontVariant)continue;let s=Array.from(new Set([r.fontVariant.display?.family,r.fontVariant.numeric?.family].filter(i=>!!i).map(Lr))),n=r.title??r.name;t.push({name:r.name.replace(/^font-variant-/,""),label:s.length?`${n} (${s.join(" + ")})`:n});}return t.length?t:[...ce]}catch{return [...ce]}}export{Bi as $,Xe as A,Ke as B,kn as C,vr as D,F as E,Vn as F,at as G,O as H,se as I,ne as J,ie as K,oe as L,Z as M,$ as N,D as O,pt as P,Re as Q,Dr as R,zi as S,Wi as T,ke as U,Ui as V,Vi as W,Ar as X,Ki as Y,Mi as Z,_r as _,T as a,Gi as aa,cs as b,ls as c,fs as d,ps as e,le as f,Ee as g,ms as h,Pt as i,kt as j,Me as k,Ce as l,B as m,Ts as n,w as o,X as p,gt as q,ht as r,Mr as s,Br as t,Gr as u,Hr as v,Jr as w,He as x,Je as y,qe as z};//# sourceMappingURL=chunk-EWAP55CF.js.map
18
+ //# sourceMappingURL=chunk-EWAP55CF.js.map