@teacss/config 0.7.2 → 0.8.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/README.md CHANGED
@@ -53,8 +53,38 @@ Lower-level APIs:
53
53
  | `scanTopLevelAtRules` | Finds top-level TeaCSS directives safely. |
54
54
  | `scanCustomBlocks` / `diagnoseCustom` | Parses and diagnoses `@custom` blocks. |
55
55
 
56
- This package does not scan application modules, generate CSS, or manage a build
57
- tool's lifecycle.
56
+ The internal `@teacss/config/internal/source-scan` export provides
57
+ `scanSourceFiles(patterns, { cwd, ignore, expandDirectories })` for TeaCSS
58
+ integrations. It returns unique absolute lexical filenames through one tinyglobby
59
+ traversal. The filesystem adapter avoids listing ordinary ancestors when bounded
60
+ metadata queries establish one directory's native spelling. It compares native
61
+ canonical results for the original and alternate ASCII case. Uncertain identity,
62
+ metadata errors, symlinks, exact file leaves and multiple planned siblings require
63
+ a cached, one-level parent-name query. These queries retain native names and
64
+ sibling order, but filter out unplanned children before the crawler processes
65
+ them. A proven strict-ancestor directory alias can be presented as a directory
66
+ when a later alias on the same route would otherwise create a false crawler cycle;
67
+ positive recursive source boundaries retain their native types. A necessary query
68
+ may read the filesystem root; it does not enter unrelated
69
+ directory trees. Input-preserving canonical APIs and non-ASCII names can require
70
+ more parent queries. Exact files do not depend on a planning `stat` succeeding.
71
+ A followed source symlink admits its target only along that traversal's callbacks.
72
+ Excluded links cannot authorize reads on other branches. Exclusions retain their
73
+ original matching coordinates. Parent files precede descendant files; independent
74
+ subtree completion remains asynchronous. Callers own default patterns, file reads,
75
+ extraction and dependency registration.
76
+ The direct picomatch dependency parses static prefixes, including escapes, braces
77
+ and extglobs; tinyglobby owns all matching and crawler behavior.
78
+
79
+ Internal watch planning returns verified plans and original permission errors
80
+ separately. Native `stat`, `lstat`, or `readlink` `EACCES` preserves accessible
81
+ shallow ancestry and healthy source plans without inventing directory identities
82
+ or recursive permission. The registry reports those errors after committing
83
+ the usable watches; existing native events observe source-only permission repair.
84
+ Other unexpected planning errors still propagate immediately.
85
+
86
+ This package does not extract application utilities, generate CSS, or manage a
87
+ build tool's lifecycle.
58
88
 
59
89
  When an entry changes, resolve it again and replace the generator configuration
60
90
  with the complete new result:
@@ -74,14 +104,42 @@ Pre-1.0. Keep behavior aligned across build, CLI, and editor integrations.
74
104
 
75
105
  ## Palette configuration
76
106
 
77
- `@presets "standard,official";` preserves ordered, quoted CSV module names.
107
+ `@presets "standard,icons,official";` preserves ordered, quoted CSV module names.
78
108
  Repeated declarations append; imported relative paths rebase per item.
79
109
  Old `@preset`, malformed lists and nested configuration directives fail.
80
110
 
81
111
  With Standard enabled, `@primary "red,blue";` enables DOM selections through
82
- `data-css-primary`. The same syntax applies to neutral, focused, success, warning,
83
- failure and general. Focused follows neutral unless a configured palette is
84
- selected. Repeated/imported lists union; sources are complete physical palettes
112
+ `data-css-primary`. The same syntax applies to neutral, success, warning,
113
+ failure and general. Focused follows neutral by default; the site binds it once
114
+ with `@custom focused "primary";` or a palette target. `@focused` lists are removed. Repeated/imported lists union; sources are complete physical palettes
85
115
  with no role dependencies. `@custom` defines base values, `@custom dark` color
86
- overrides. Whole-theme variants are removed. Configuration failures retain
116
+ overrides. Whole-theme variants are removed. Configuration failures retain original alias source ranges and
87
117
  import/preset dependency paths for editor and development-server recovery.
118
+
119
+ ### Color alias statements
120
+
121
+ `@custom office "indigo";` expands all 12 scale steps plus `000` into
122
+ `var(--color-indigo-<step>)` references (`000` has a white fallback). It registers
123
+ in the entry and followed imports, never through `@source`. Color utilities,
124
+ alpha and conditions consume the alias normally. Mode blocks override base
125
+ values regardless of their position; within a base or mode block, later values win.
126
+
127
+ Names use lowercase kebab-case and cannot end in a numeric segment. Non-role
128
+ aliases cannot reuse built-in palettes, prior aliases or a complete custom base
129
+ palette formed before the statement. Sparse earlier declarations and later
130
+ per-step overrides are allowed. Targets must have all 12 effective steps in
131
+ base and modes and cannot be aliases or roles; only `focused` may follow
132
+ `primary` or `neutral`, including rebound roles. Targets may be declared later.
133
+ Seven role names can be rebound repeatedly, with the last binding winning.
134
+ Alias names never become selectable role-list candidates.
135
+
136
+ `customToTheme(blocks, themeKeys)` retains its low-level patch interface.
137
+ The shared semantic compiler `resolveCustomTheme(blocks, baseline)` validates
138
+ against resolved preset values and palette identities and reports
139
+ `EntryConfigError.diagnostics` with original file/range locations.
140
+
141
+ Source declaration loading requires a complete enumeration. Native enumeration
142
+ errors retain the original cause after the traversal finishes, so recovery keeps
143
+ the accepted shortcuts and safelists. Missing paths, non-directory components, and
144
+ link cycles remain topology absence. Generic `scanSourceFiles` callers retain
145
+ tinyglobby's existing error suppression.
package/dist/index.d.ts CHANGED
@@ -1,18 +1,82 @@
1
+ import { i as loadConfig, n as entryDiscoveryFiles, r as findEntry, t as LoadConfigResult } from "./load-config-CAzqJCHM.js";
1
2
  import { Preset, UserConfig, UserConfigDefaults } from "@teacss/core";
3
+ //#region src/scanCustom.d.ts
4
+ export interface ScannedCustomDeclaration {
5
+ property: string;
6
+ value: string;
7
+ /** Property-name offsets in the original source (`end` is exclusive). */
8
+ start: number;
9
+ end: number;
10
+ /** Offset of the declaration's `:` separator. */
11
+ colon: number;
12
+ /** Trimmed value offsets in the original source (`valueEnd` is exclusive). */
13
+ valueStart: number;
14
+ valueEnd: number;
15
+ }
16
+ export interface ScannedCustomBlock {
17
+ mode?: string;
18
+ declarations: ScannedCustomDeclaration[];
19
+ /** Offset of the at-rule's `@` (for block-level diagnostics). */
20
+ start: number;
21
+ /** Offsets of the block's opening and closing braces. */
22
+ open: number;
23
+ close: number;
24
+ }
25
+ export interface ScannedTopLevelAtRule {
26
+ /** Included only by the nested diagnostic scan. */
27
+ depth?: number;
28
+ /** At-rule name without the leading `@`. */
29
+ name: string;
30
+ /** Trimmed text between the name and its terminator/opening brace. */
31
+ prelude: string;
32
+ /** Full at-rule offsets in the original source (`end` is exclusive). */
33
+ start: number;
34
+ end: number;
35
+ terminator: ";" | "block" | "eof";
36
+ }
37
+ /** Return string values from exact, top-level at-rules such as `@presets "…"`. */
38
+ export declare function scanQuotedDirectives(css: string, directive: string): string[];
39
+ /** Whether an exact at-rule name occurs at the top level outside strings/comments. */
40
+ export declare function hasTopLevelDirective(css: string, directive: string): boolean;
41
+ /** Scan complete top-level at-rules without matching text in comments, strings, or nested CSS. */
42
+ export declare function scanTopLevelAtRules(css: string, includeNested?: boolean): ScannedTopLevelAtRule[];
43
+ /** Scan top-level `@custom` blocks without treating strings, comments, or nested CSS as directives. */
44
+ export declare function scanCustomBlocks(css: string): ScannedCustomBlock[];
45
+ //#endregion
46
+ //#region src/customAlias.d.ts
47
+ interface EntrySourceRange {
48
+ file?: string;
49
+ start: number;
50
+ end: number;
51
+ }
52
+ interface EntryColorAlias {
53
+ name: string;
54
+ family: string;
55
+ statement: EntrySourceRange;
56
+ nameRange: EntrySourceRange;
57
+ familyRange: EntrySourceRange;
58
+ }
59
+ //#endregion
2
60
  //#region src/entry-lists.d.ts
3
- export declare const ROLE_DIRECTIVES: readonly ["primary", "neutral", "focused", "success", "warning", "failure", "general"];
4
- export type ColorRole = (typeof ROLE_DIRECTIVES)[number];
61
+ export declare const ROLE_DIRECTIVES: readonly ["primary", "neutral", "success", "warning", "failure", "general"];
62
+ export type ColorRole = (typeof ROLE_DIRECTIVES)[number] | "focused";
5
63
  export type RolePalettes = Partial<Record<ColorRole, readonly string[]>>;
6
64
  export interface EntryDiagnostic {
65
+ file?: string;
7
66
  start: number;
8
67
  end: number;
9
68
  message: string;
10
69
  }
70
+ /** @internal Shared build/editor rejection with original source locations. */
71
+ export declare class EntryConfigError extends SyntaxError {
72
+ readonly diagnostics: EntryDiagnostic[];
73
+ constructor(diagnostics: EntryDiagnostic[]);
74
+ }
11
75
  /** Literal module names: commas separate items; CSS escapes are not decoded. */
12
76
  export declare function parseEntryList(prelude: string): string[];
13
77
  /** Recoverable diagnostics for editors; build callers reject these before loading. */
14
78
  export declare function diagnoseEntry(css: string): EntryDiagnostic[];
15
- export declare function assertEntryDirectives(css: string): void;
79
+ export declare function assertEntryDirectives(css: string, file?: string): void;
16
80
  //#endregion
17
81
  //#region src/parseEntry.d.ts
18
82
  export interface EntrySource {
@@ -28,6 +92,8 @@ export interface EntryCustomDecl {
28
92
  value: string;
29
93
  }
30
94
  export interface EntryCustomBlock {
95
+ /** A statement's identity and original source, alongside its expansion. */
96
+ alias?: EntryColorAlias;
31
97
  /** Mode name, or undefined for the base block. */
32
98
  mode?: string;
33
99
  declarations: EntryCustomDecl[];
@@ -55,7 +121,7 @@ export interface EntryConfig {
55
121
  rolePalettes?: RolePalettes;
56
122
  /** `@source "<glob>"` entries (`!`-prefixed → exclude). */
57
123
  sources: EntrySource[];
58
- /** `@custom {}` / `@custom <mode> {}` blocks, in source order. */
124
+ /** Custom blocks and expanded alias statements, in source order. */
59
125
  custom: EntryCustomBlock[];
60
126
  /** `@shortcut <name> "<expansion>"` entries, in source order. */
61
127
  shortcuts: EntryShortcut[];
@@ -71,7 +137,7 @@ export interface EntryConfig {
71
137
  * are ignored. Resolving the returned data (loading presets, scanning sources,
72
138
  * registering `@custom`) lives in the config/integration layer.
73
139
  */
74
- export declare function parseEntry(css: string): EntryConfig;
140
+ export declare function parseEntry(css: string, /** @internal Original source identity for diagnostics. */ file?: string): EntryConfig;
75
141
  //#endregion
76
142
  //#region src/customToTheme.d.ts
77
143
  export interface CustomToThemeResult {
@@ -137,8 +203,20 @@ export interface CustomDiagnostic {
137
203
  /** Position-aware custom-property diagnostics shared by builds and editors. */
138
204
  export declare function diagnoseCustom(css: string, themeKeys: string[]): CustomDiagnostic[];
139
205
  //#endregion
140
- //#region src/resolveEntryConfig.d.ts
141
- export interface ResolveEntryResult {
206
+ //#region src/resolveCustomTheme.d.ts
207
+ /** @internal Preset identity stays separate from mutable application values. */
208
+ export interface CustomThemeBaseline {
209
+ theme: Record<string, any>;
210
+ physicalPalettes?: readonly string[];
211
+ aliases?: readonly string[];
212
+ }
213
+ /** Pure semantic compiler shared by entry resolution and temporary editor configs. */
214
+ export declare function resolveCustomTheme(blocks: EntryCustomBlock[], baseline: CustomThemeBaseline): CustomToThemeResult & {
215
+ aliases: readonly string[];
216
+ };
217
+ //#endregion
218
+ //#region src/entry-operation.d.ts
219
+ interface ResolveEntryResult {
142
220
  /** UserConfig assembled from the entry — feed straight to `createGenerator`. */
143
221
  config: UserConfig;
144
222
  /** `@custom` var names that didn't register (decision 11 — for diagnostics/warnings). */
@@ -148,25 +226,9 @@ export interface ResolveEntryResult {
148
226
  /** Absolute config dependencies: followed imports, sourced CSS, package preset entries, and local preset modules. */
149
227
  sources: string[];
150
228
  }
151
- /**
152
- * Resolve a CSS entry into a `UserConfig` — the single source every integration
153
- * uses. `@presets` → presets (no implicit default — an entry with no `@presets`
154
- * gets no presets, and the caller warns); `@source` → `content.filesystem`
155
- * (`!`-prefixed = exclude); `@custom` → a theme patch; `@shortcut` → custom
156
- * shortcuts (later declarations of the same name win); `@safelist` → safelist
157
- * tokens (group syntax expands, duplicates collapse).
158
- * Unconditional local `@import` statements are followed first, so entry
159
- * directives in imported CSS files take effect at the import's position and
160
- * the imported files join `sources` for watch invalidation.
161
- * `.css` files matched by `@source` also register their `@shortcut` and
162
- * `@safelist` declarations (only those two — other entry directives stay
163
- * entry/import scoped): they resolve before the entry's own text, so the
164
- * entry and its `@import`s win shortcut name conflicts while safelist
165
- * tokens accumulate, and the matched files join `sources`.
166
- * `base` is the entry file's directory (for `@presets` relative specifiers and
167
- * `@import` resolution). Pass `entryFile` when the CSS has a filesystem identity
168
- * so an imported file that points back to the root entry closes the cycle.
169
- */
229
+ //#endregion
230
+ //#region src/resolveEntryConfig.d.ts
231
+ /** Resolve a CSS entry while preserving the original rejection value. */
170
232
  export declare function resolveEntryConfig(entryCss: string, base: string, entryFile?: string, /** @internal Unsaved CSS text keyed by absolute filename; never committed or written. */ sourceOverrides?: ReadonlyMap<string, string>): Promise<ResolveEntryResult>;
171
233
  //#endregion
172
234
  //#region src/resolvePresets.d.ts
@@ -182,72 +244,8 @@ declare function getPresetSourcesFromError(error: unknown): string[];
182
244
  */
183
245
  export declare function resolvePresets<Theme extends object = object>(specifiers: string[], base: string): Promise<Preset<Theme>[]>;
184
246
  //#endregion
185
- //#region src/scanCustom.d.ts
186
- export interface ScannedCustomDeclaration {
187
- property: string;
188
- value: string;
189
- /** Property-name offsets in the original source (`end` is exclusive). */
190
- start: number;
191
- end: number;
192
- /** Offset of the declaration's `:` separator. */
193
- colon: number;
194
- /** Trimmed value offsets in the original source (`valueEnd` is exclusive). */
195
- valueStart: number;
196
- valueEnd: number;
197
- }
198
- export interface ScannedCustomBlock {
199
- mode?: string;
200
- declarations: ScannedCustomDeclaration[];
201
- /** Offset of the at-rule's `@` (for block-level diagnostics). */
202
- start: number;
203
- /** Offsets of the block's opening and closing braces. */
204
- open: number;
205
- close: number;
206
- }
207
- export interface ScannedTopLevelAtRule {
208
- /** Included only by the nested diagnostic scan. */
209
- depth?: number;
210
- /** At-rule name without the leading `@`. */
211
- name: string;
212
- /** Trimmed text between the name and its terminator/opening brace. */
213
- prelude: string;
214
- /** Full at-rule offsets in the original source (`end` is exclusive). */
215
- start: number;
216
- end: number;
217
- terminator: ";" | "block" | "eof";
218
- }
219
- /** Return string values from exact, top-level at-rules such as `@presets "…"`. */
220
- export declare function scanQuotedDirectives(css: string, directive: string): string[];
221
- /** Whether an exact at-rule name occurs at the top level outside strings/comments. */
222
- export declare function hasTopLevelDirective(css: string, directive: string): boolean;
223
- /** Scan complete top-level at-rules without matching text in comments, strings, or nested CSS. */
224
- export declare function scanTopLevelAtRules(css: string, includeNested?: boolean): ScannedTopLevelAtRule[];
225
- /** Scan top-level `@custom` blocks without treating strings, comments, or nested CSS as directives. */
226
- export declare function scanCustomBlocks(css: string): ScannedCustomBlock[];
227
- //#endregion
228
247
  //#region src/index.d.ts
229
- export interface LoadConfigResult<U> {
230
- config: U;
231
- /** CSS entry graph, package preset entries, and bounded local preset graphs. */
232
- sources: string[];
233
- }
234
- /** Relative files that can change CSS-entry discovery, in resolution order. */
235
- export declare const entryDiscoveryFiles: readonly ["package.json", "index.css", "src/index.css"];
236
- /** Find the CSS entry: package.json override → index.css → src/index.css. */
237
- export declare function findEntry(root: string): string | undefined;
238
- /**
239
- * Resolve the TeaCSS config from the CSS entry. `configOrPath` is either an
240
- * inline `UserConfig` (used as-is — programmatic / preset authors) or a root
241
- * directory (or entry file) to discover the entry from. There is no
242
- * `teacss.config.ts` — the CSS entry is the only config source. No entry found →
243
- * empty config (just the caller's `defaults`). An entry that declares no
244
- * `@presets` warns: config never reaches for a specific preset itself.
245
- */
246
- export declare function loadConfig<U extends UserConfig>(cwd?: string, configOrPath?: string | U, defaults?: UserConfigDefaults): Promise<LoadConfigResult<U>>;
247
- /**
248
- * A config loader that recovers from errors by returning the last good result —
249
- * useful in dev where the entry CSS may be momentarily broken between edits.
250
- */
248
+ /** Recover from errors with the last successfully resolved configuration. */
251
249
  export declare function createRecoveryConfigLoader<U extends UserConfig>(): (cwd?: string, configOrPath?: string | U, defaults?: UserConfigDefaults) => Promise<LoadConfigResult<U>>;
252
250
  //#endregion
253
- export { getPresetSourcesFromError as getConfigSourcesFromError };
251
+ export { type EntryColorAlias, type EntrySourceRange, type LoadConfigResult, type ResolveEntryResult, entryDiscoveryFiles, findEntry, getPresetSourcesFromError as getConfigSourcesFromError, loadConfig };
package/dist/index.js CHANGED
@@ -1,2 +1 @@
1
- import{createRequire as e}from"node:module";import*as t from"node:fs";import n,{existsSync as r,readFileSync as i,realpathSync as a}from"node:fs";import{dirname as o,extname as s,isAbsolute as c,join as l,relative as u,resolve as d,sep as f}from"node:path";import p from"node:process";import{consola as m}from"consola";import{expandClassGroups as h,mergeDeep as g,resolveConfig as _,splitClassTokens as v}from"@teacss/core";import{glob as ee}from"tinyglobby";import{Buffer as y}from"node:buffer";import{readFile as b,stat as te}from"node:fs/promises";import{fileURLToPath as x,pathToFileURL as ne}from"node:url";const re=[`000`,`100`,`150`,`200`,`300`,`400`,`500`,`600`,`700`,`800`,`850`,`900`,`950`],ie=new Set(re);function ae(e){return e.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`)}function oe(e){return Object.keys(e).filter(t=>{if(t===`modes`||t===`defaultMode`||t===`rolePalettes`)return!1;let n=e[t];return typeof n!=`object`||!n?!1:t===`colors`||Object.values(n).every(e=>e==null||typeof e==`string`||typeof e==`number`||Array.isArray(e))})}function S(e){return e.map(e=>({key:e,prefix:e===`colors`||e===`semanticColors`?`color`:ae(e),twoLevel:e===`colors`,semanticColor:e===`semanticColors`})).sort((e,t)=>t.prefix.length-e.prefix.length)}function C(e,t,n){Object.defineProperty(e,t,{value:n,configurable:!0,enumerable:!0,writable:!0})}function w(e,t){let n=Object.hasOwn(e,t)?e[t]:void 0;if(typeof n==`object`&&n&&!Array.isArray(n))return n;let r={};return C(e,t,r),r}function T(e,t){let n=t.filter(t=>e===t.prefix||e.startsWith(`${t.prefix}-`)),r=n.find(e=>e.key===`colors`),i=n.find(e=>e.semanticColor);if(r&&i){let t=e===`color`?``:e.slice(6),n=t.lastIndexOf(`-`),a=n>0?t.slice(0,n):``,o=n>0?t.slice(n+1):``;return a&&ie.has(o)?{ok:!0,nsKey:r.key,twoLevel:!0,rest:t,colorName:a,step:o}:a&&/^\d+$/.test(o)?{ok:!1,reason:`illegal-color-step`}:t?{ok:!0,nsKey:i.key,twoLevel:!1,rest:t}:{ok:!1,reason:`unknown-prefix`}}let a=n[0];if(!a)return{ok:!1,reason:`unknown-prefix`};let o=e===a.prefix?``:e.slice(a.prefix.length+1);if(a.twoLevel){let e=o.lastIndexOf(`-`),t=e>0?o.slice(0,e):``,n=e>0?o.slice(e+1):``;return!t||!ie.has(n)?{ok:!1,reason:`illegal-color-step`}:{ok:!0,nsKey:a.key,twoLevel:!0,rest:o,colorName:t,step:n}}return{ok:!0,nsKey:a.key,twoLevel:!1,rest:o}}function E(e,t){let n=S(t),r={},i=[],a=e=>{let t=T(e.startsWith(`--`)?e.slice(2):e,n);return t.ok||i.push(e),t},o=(e,t,n)=>{let r=w(e,t.nsKey);t.twoLevel?C(w(r,t.colorName),t.step,n):C(r,t.rest||`DEFAULT`,n)};for(let t of e){let e=t.mode?w(w(r,`modes`),t.mode):r;for(let{property:n,value:r}of t.declarations){let t=a(n);t.ok&&o(e,t,r)}}return{theme:r,unknown:i}}const se=/[A-Za-z0-9-]/,ce=/[\w-]/;function D(e,t,n){let r=e.indexOf(`*/`,t+2);return r<0||r>=n?n:r+2}function O(e,t,n){let r=e[t];for(let i=t+1;i<n;i++)if(e[i]===`\\`)i++;else if(e[i]===r)return i+1;return n}function k(e,t,n){let r=``;for(let i=t;i<n;i++)if(e[i]===`/`&&e[i+1]===`*`)i=D(e,i,n)-1,r+=` `;else if(e[i]===`"`||e[i]===`'`){let t=O(e,i,n);r+=e.slice(i,t),i=t-1}else r+=e[i];return r.trim()}function le(e,t){let n=[],r=t.startsWith(`@`)?t.slice(1):t;for(let t of A(e)){if(t.name!==r||t.terminator!==`;`)continue;let e=t.prelude[0];if(e!==`"`&&e!==`'`)continue;let i=O(t.prelude,0,t.prelude.length);i!==t.prelude.length||i<=1||t.prelude[i-1]!==e||n.push(t.prelude.slice(1,i-1))}return n}function ue(e,t){let n=t.startsWith(`@`)?t.slice(1):t;return A(e).some(e=>e.name===n)}function de(e,t){for(let n=t;n<e.length;n++)if(e[n]===`/`&&e[n+1]===`*`)n=D(e,n,e.length)-1;else if(e[n]===`"`||e[n]===`'`)n=O(e,n,e.length)-1;else if(e[n]===`{`)return n;else if(e[n]===`;`||e[n]===`}`)return-1;return-1}function fe(e,t){let n=1;for(let r=t+1;r<e.length;r++)if(e[r]===`/`&&e[r+1]===`*`)r=D(e,r,e.length)-1;else if(e[r]===`"`||e[r]===`'`)r=O(e,r,e.length)-1;else if(e[r]===`{`)n++;else if(e[r]===`}`&&--n===0)return r;return-1}function A(e,t=!1){let n=[],r=0;for(let i=0;i<e.length;i++){if(e[i]===`/`&&e[i+1]===`*`){i=D(e,i,e.length)-1;continue}if(e[i]===`"`||e[i]===`'`){i=O(e,i,e.length)-1;continue}if(e[i]===`{`){r++;continue}if(e[i]===`}`){r=Math.max(0,r-1);continue}if(!t&&r!==0||e[i]!==`@`)continue;let a=i,o=a+1;for(;ce.test(e[o]??``);)o++;if(o===a+1)continue;let s=e.slice(a+1,o),c=[],l=!1;for(let u=o;u<e.length;u++){let d=e[u];if(d===`/`&&e[u+1]===`*`)u=D(e,u,e.length)-1;else if(d===`"`||d===`'`)u=O(e,u,e.length)-1;else if(d===`(`)c.push(`)`);else if(d===`[`)c.push(`]`);else if(d===c.at(-1))c.pop();else if(c.length===0&&d===`;`){n.push({name:s,prelude:k(e,o,u),start:a,end:u+1,terminator:`;`,...t?{depth:r}:{}}),i=u,l=!0;break}else if(c.length===0&&d===`{`){let c=fe(e,u);(c>=0||t)&&(n.push({name:s,prelude:k(e,o,u),start:a,end:c<0?e.length:c+1,terminator:`block`,...t?{depth:r}:{}}),i=t?u:c,t&&r++,l=!0);break}}if(!l){n.push({name:s,prelude:k(e,o,e.length),start:a,end:e.length,terminator:`eof`,...t?{depth:r}:{}});break}}return n}function pe(e,t,n){let r=[];for(let i=t;i<n;i++){let t=e[i];if(t===`/`&&e[i+1]===`*`)i=D(e,i,n)-1;else if(t===`"`||t===`'`)i=O(e,i,n)-1;else if(t===`(`)r.push(`)`);else if(t===`[`)r.push(`]`);else if(t===`{`)r.push(`}`);else if(t===r.at(-1))r.pop();else if(t===`;`&&r.length===0)return i}return n}function me(e,t,n){let r=[];for(let i=t;i<n;){for(;i<n;)if(/\s/.test(e[i]))i++;else if(e[i]===`/`&&e[i+1]===`*`)i=D(e,i,n);else break;let t=pe(e,i,n);if(e[i]!==`-`||e[i+1]!==`-`){i=t+1;continue}let a=i+2;for(;a<n&&se.test(e[a]);)a++;if(a===i+2){i=t+1;continue}let o=a;for(;o<n;)if(/\s/.test(e[o]))o++;else if(e[o]===`/`&&e[o+1]===`*`)o=D(e,o,n);else break;if(e[o]!==`:`){i=t+1;continue}let s=o+1,c=e.slice(s,t),l=c.trim(),u=s+c.length-c.trimStart().length,d=u+l.length;r.push({property:e.slice(i,a),value:l,start:i,end:a,colon:o,valueStart:u,valueEnd:d}),i=t+1}return r}function j(e){let t=[];for(let n of A(e)){if(n.name!==`custom`||n.terminator!==`block`)continue;let r=de(e,n.start+7);if(r<0)continue;let i=n.end-1;t.push({mode:n.prelude||void 0,declarations:me(e,r+1,i),start:n.start,open:r,close:i})}return t}const M=[`primary`,`neutral`,`focused`,`success`,`warning`,`failure`,`general`];function N(e){let t=e[0];if(t!==`"`&&t!==`'`)throw Error(`expected one quoted comma-separated list`);let n=1;for(;n<e.length;n++)if(e[n]===`\\`)n++;else if(e[n]===t)break;if(n!==e.length-1||e[n]!==t)throw Error(`expected one complete quoted list without extra arguments`);let r=e.slice(1,-1);if(r.includes(`\\,`))throw Error(`commas cannot be escaped; re-export the preset from a path without commas`);let i=r.split(`,`).map(e=>e.trim());if(i.some(e=>!e))throw Error(`empty lists, empty items and trailing commas are not allowed`);return i}function P(e){let t=[];for(let n of A(e,!0)){let e,r=M.includes(n.name);if(n.name===`preset`)e=`@preset was removed; use @presets "standard,official";`;else if(n.name===`custom`&&n.prelude.split(/\s+/)[0]===`theme`)e=`named themes were removed; use global / mode @custom values and data-css-<role> palette selectors`;else if(n.name===`presets`||r){if(n.depth)e=`configuration directives must be top-level`;else if(n.terminator!==`;`)e=`expected a quoted list ending with a semicolon, without a block`;else try{let t=N(n.prelude);r&&t.some(e=>!/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/.test(e))&&(e=`palette names must use lowercase kebab-case`)}catch(t){e=t.message}}e&&t.push({start:n.start,end:n.end,message:`@${n.name}: ${e}`})}return t}function F(e){let t=P(e);if(t.length)throw SyntaxError(t.map(e=>e.message).join(`
2
- `))}let he;function ge(){return he??=import(`jiti`).then(({createJiti:e})=>({createJiti:e,transformer:e(import.meta.url,{fsCache:!1,interopDefault:!0,moduleCache:!1})}))}const I=new Map,L=new WeakMap,R=16777216,z=new Map;let B=0;const V={icons:`@teacss/preset-icons`,official:`@teacss/preset-official`,standard:`@teacss/preset-standard`};function _e(t,n){try{return n.resolve(t)}catch(r){let i;try{i=n.resolve(`teacss/package.json`)}catch{throw r}return e(i).resolve(t)}}function ve(t,n){if(t.startsWith(`.`)||c(t))return d(n,t);let r=e(d(n,`_`)),i=Object.hasOwn(V,t)?V[t]:void 0;return i?_e(i,r):r.resolve(t)}function H(e){return e.startsWith(`.`)||c(e)}function U(e){try{return a(e)}catch{return d(e)}}function W(e,t){let n=o(e),i=[];for(;;){if(t.has(n)){let e=t.get(n);for(let n of i)t.set(n,e);return e}if(i.push(n),r(d(n,`package.json`))){for(let e of i)t.set(e,n);return n}let e=o(n);if(e===n){for(let e of i)t.set(e,void 0);return}n=e}}function ye(e,t){let n=u(t,e);return n===``||!c(n)&&n!==`..`&&!n.startsWith(`..${f}`)}function G(e,t,n){let r=W(e,n);return t.packageRoot===void 0?r===void 0&&ye(e,t.fallbackRoot):r===t.packageRoot}function K(e,t,n,r,i){if(!e||n.has(e)||(n.add(e),!c(e.filename)))return;let a=U(e.filename);if(G(a,r,i)){t.add(a);for(let a of e.children)K(a,t,n,r,i)}}function be(e){if(!e||typeof e!=`object`)return;let t,n,r;try{t=Reflect.get(e,`path`),n=Reflect.get(e,`url`),r=Reflect.get(e,`message`)}catch{return}if(typeof t==`string`&&c(t))return U(t);if(typeof n==`string`&&n.startsWith(`file:`))return U(x(n));if(typeof r!=`string`)return;let i=/Cannot find module ['"]([^'"]+)['"] from ['"]([^'"]+)['"]/.exec(r),a=/Cannot find module ['"]([^'"]+)['"][\s\S]*?Require stack:\s*\n- ([^\n]+)/.exec(r),s=i??a;if(!s)return;let l=s[1],u=s[2];if(l&&u&&(l.startsWith(`.`)||c(l)))return U(c(l)?l:d(o(u),l))}async function xe(e,t){let n=I.get(e)??Promise.resolve(),r,i=new Promise(e=>{r=e}),a=n.then(()=>i);I.set(e,a),await n;try{return{evaluation:t()}}finally{r(),I.get(e)===a&&I.delete(e)}}function Se(e){return()=>({visitor:{AwaitExpression(t){t.getFunctionParent()||(e.hasTopLevelAwait=!0)},CallExpression(t){t.node.callee?.type===`Identifier`&&t.node.callee.name===`jitiImport`&&(e.hasDynamicImport=!0);let n=t.node.arguments?.[0];if(t.node.callee?.type!==`Identifier`||t.node.callee.name!==`require`)return;let r=n?.type===`StringLiteral`&&typeof n.value==`string`;r&&e.dependencies.add(n.value),typeof t.node.start==`number`&&(r?t.getFunctionParent()?e.hasNestedRequire=!0:e.hasTopLevelRequire=!0:e.hasNonLiteralRequire=!0)},ForOfStatement(t){t.node.await&&!t.getFunctionParent()&&(e.hasTopLevelAwait=!0)}}})}function q(e,t,n){if(e.hasDynamicImport)throw Error(`Dynamic imports are not supported in local preset modules: "${t}". Use static imports so TeaCSS can track and reload the complete graph.`);if(e.hasNonLiteralRequire)throw Error(`CommonJS require() specifiers must be string literals in local preset modules: "${t}".`);if(e.hasNestedRequire)throw Error(`CommonJS require() is only supported at module top level in local preset modules: "${t}".`);if(e.hasTopLevelRequire&&e.hasTopLevelAwait)throw Error(`CommonJS require() cannot be combined with top-level await in a local preset module: "${t}". Use a static import instead.`);if(t!==n&&e.hasTopLevelAwait)throw Error(`Top-level await is only supported in the local preset entry module: "${t}".`)}const J=Symbol(`uncacheable transform option`);function Y(e,t=new Set){if(e===null)return`n`;if(typeof e==`string`)return`s${JSON.stringify(e)}`;if(typeof e==`boolean`)return e?`b1`:`b0`;if(typeof e==`number`)return Number.isNaN(e)?`dNaN`:e===1/0?`dInfinity`:e===-1/0?`d-Infinity`:Object.is(e,-0)?`d-0`:`d${JSON.stringify(e)}`;if(e===void 0)return`u`;if(typeof e!=`object`||t.has(e))throw J;t.add(e);try{if(Array.isArray(e)){for(let t of Reflect.ownKeys(e)){if(t===`length`)continue;if(typeof t!=`string`)throw J;let n=Number(t),r=Object.getOwnPropertyDescriptor(e,t);if(!Number.isSafeInteger(n)||n<0||String(n)!==t||n>=e.length||!r?.enumerable||!(`value`in r))throw J}let n=Array.from({length:e.length},(n,r)=>{let i=Object.getOwnPropertyDescriptor(e,String(r));return i&&`value`in i?Y(i.value,t):`h`});return`a${e.length}[${n.join(`,`)}]`}if(Object.getPrototypeOf(e)!==Object.prototype&&Object.getPrototypeOf(e)!==null)throw J;return`o{${Reflect.ownKeys(e).map(t=>{if(typeof t!=`string`)throw J;let n=Object.getOwnPropertyDescriptor(e,t);if(!n?.enumerable||!(`value`in n))throw J;return[t,n.value]}).sort(([e],[t])=>e.localeCompare(t)).map(([e,n])=>`${JSON.stringify(e)}:${Y(n,t)}`).join(`,`)}}`}finally{t.delete(e)}}function Ce(e,t){return{...t,async:!1,interopDefault:t.interopDefault??!0,jsx:t.jsx??e.options.jsx,retainLines:t.retainLines??e.options.transformOptions?.retainLines}}function we(e){if(!(e&&Object.getPrototypeOf(e)===Object.prototype&&Reflect.ownKeys(e).length===0))return e}function Te(e){try{return Y({babel:we(e.babel),interopDefault:e.interopDefault,jsx:e.jsx,retainLines:e.retainLines,ts:e.ts})}catch{return}}function Ee(e,t,n,r){let i=y.byteLength(e)+y.byteLength(t)+y.byteLength(n);for(let e of r.dependencies)i+=y.byteLength(e);return i}function De(e,t){let n=z.get(e);n&&(B-=n.bytes,z.delete(e));let r=Ee(e,t.source,t.code,t.facts);if(!(r>R))for(z.set(e,{...t,bytes:r}),B+=r;z.size>256||B>R;){let e=z.keys().next();if(e.done)break;let t=z.get(e.value);z.delete(e.value),t&&(B-=t.bytes)}}function Oe(e){return{...e,dependencies:Array.from(e.dependencies)}}function ke(e,t,n,r,i,a){let o=t.filename?U(t.filename):n,s=Ce(e,t),c=Te(s),l=c===void 0?void 0:`${o}\0${c}`,u=l===void 0?void 0:z.get(l);if(l!==void 0&&u?.source===s.source)return z.delete(l),z.set(l,u),G(o,r,i)&&q(u.facts,o,n),{code:u.code,dependencies:u.facts.dependencies};let d=c===void 0?void 0:{filename:o,mode:c,source:s.source},f=d===void 0?void 0:a?.read(d);if(l!==void 0&&f){let e={...f.facts,dependencies:new Set(f.facts.dependencies)};return De(l,{code:f.code,facts:e,source:s.source}),G(o,r,i)&&q(e,o,n),{code:f.code,dependencies:e.dependencies}}let p={dependencies:new Set,hasDynamicImport:!1,hasNestedRequire:!1,hasNonLiteralRequire:!1,hasTopLevelAwait:!1,hasTopLevelRequire:!1},m=Se(p),h=Error.prepareStackTrace,g=Error.stackTraceLimit;try{let t=e.transform({...s,babel:{...s.babel,plugins:[...Array.isArray(s.babel?.plugins)?s.babel.plugins:[],m]}});return l!==void 0&&De(l,{code:t,facts:p,source:s.source}),G(o,r,i)&&q(p,o,n),d!==void 0&&a?.write(d,{code:t,facts:Oe(p)}),{code:t,dependencies:p.dependencies}}finally{Error.prepareStackTrace=h,Error.stackTraceLimit=g}}const Ae=/\.[cm]?[jt]sx?$/;function je(e,t,n){let r=U(c(n)?n:d(o(t),n));if(s(r))return[r];let i=Array.from(new Set([``,...e.options.extensions??[],`.json`])),a=[r,d(r,`index`)].flatMap(e=>i.map(t=>`${e}${t}`));return a.push(d(r,`package.json`)),a}function Me(t,n,r){if(r.startsWith(`node:`))return[];try{let i=H(r)?t.esmResolve(r,{parentURL:ne(n).href,try:!0}):e(n).resolve(r);if(!i)return H(r)?je(t,n,r):[];let a=i.startsWith(`file:`)?x(i):i;return c(a)?[U(a)]:[]}catch{return H(r)?je(t,n,r):[]}}async function Ne(e,t,n,r,i,a,o){let c=[e],l;for(let u=0;u<c.length;u++){let d=c[u];if(!d||!Ae.test(s(d)))continue;let f;try{f=await b(d,`utf8`)}catch(e){if(e.code===`ENOENT`)continue;throw e}d===e&&(l=f);let{dependencies:p}=ke(n,{source:f,filename:d,async:d===e,ts:/\.[cm]?tsx?$/.test(d)},e,r,i,o);for(let e of p)for(let n of Me(t,d,e))!a.has(n)&&G(n,r,i)&&(a.add(n),c.push(n))}return l}async function Pe(e,t){try{let{createPresetTransformDiskCache:n}=await import(`./presetTransformDiskCache-BNUNLsPo.js`);return n(e,import.meta.url,t)}catch{return}}function X(e,t){if(!e||typeof e!=`object`)return;let n=L.get(e)??[];L.set(e,Array.from(new Set([...n,...t])))}function Z(e){return e&&typeof e==`object`?[...L.get(e)??[]]:[]}async function Fe(t,n,r){let i=U(t),a=e(i),s=Object.create(null),c=new Set([i]),l=new Map,u={packageRoot:W(i,l),fallbackRoot:o(i)},[{createJiti:d,transformer:f},p]=await Promise.all([ge(),Pe(i,r)]),m=d(i,{fsCache:!1,interopDefault:!0,moduleCache:!1,tryNative:!1,transform:e=>{let{code:t}=ke(f,e,i,u,l,p);return{code:t}}}),h=()=>{let e=new Set;for(let t of Object.values(s))K(t,c,e,u,l);for(let t of c)K(a.cache[t],c,e,u,l)};try{let e=await Ne(i,m,f,u,l,c,p)??await b(i,`utf8`),{evaluation:t}=await xe(u.packageRoot??u.fallbackRoot,()=>{for(let e of c)delete a.cache[e];return m.evalModule(e,{async:!0,cache:s,filename:i,forceTranspile:!0})}),r=await t,o=r?.__esModule?r.default:r;if(o==null)throw Error(`@presets "${n}" has no default export (expected a Preset or preset factory)`);let d=typeof o==`function`?await o():o;return h(),{preset:d,sources:Array.from(c)}}catch(e){h();let t=be(e);throw X(e,t&&G(t,u,l)?[...c,t]:Array.from(c)),e}}async function Ie(e){let t=await te(e),n=ne(e);return n.searchParams.set(`version`,`${t.mtimeMs}:${t.ctimeMs}:${t.size}:${t.ino}`),(await import(n.href)).default}async function Le(e,t){let n=[],r=new Set,i={protectedSlotsByDirectory:new Map};for(let a of e){let e;try{e=ve(a,t);let o;if(H(a)){let t=await Fe(e,a,i);for(let e of t.sources)r.add(e);n.push(t.preset);continue}if(r.add(U(e)),o=await Ie(e),o==null)throw Error(`@presets "${a}" has no default export (expected a Preset or preset factory)`);n.push(typeof o==`function`?await o():o)}catch(t){throw X(t,e!==void 0&&H(a)?[...r,U(e)]:r),t}}return{presets:n,sources:Array.from(r)}}async function Re(e,t){return(await Le(e,t)).presets}function ze(e){let t=e,n=/^url\(\s*([^)]*?)\s*\)$/i.exec(t);if(n)t=n[1];else if(/^url\(/i.test(t))return;let r=t[0];if(r===`"`||r===`'`){if(t.length<2||t[t.length-1]!==r)return;let e=t.slice(1,-1);return e.includes(r)?void 0:e}return n?t:void 0}function Be(e){return!(!e||e.startsWith(`//`)||/^[a-z][\w+.-]*:/i.test(e))}function Ve(e){return e.split(`\\`).join(`/`)}function He(e,t,n,r){if(!Be(e)||c(e)||!r&&!e.startsWith(`./`)&&!e.startsWith(`../`))return e;let i=Ve(u(n,d(t,e)));return i.startsWith(`.`)?i:`./${i}`}function Ue(e,t){if(t.length===0)return e;t.sort((e,t)=>e.start-t.start);let n=``,r=0;for(let i of t)n+=e.slice(r,i.start)+i.replacement,r=i.end;return n+e.slice(r)}function We(e,t,n){if(t===n)return e;let r=[];for(let i of A(e)){if(i.terminator!==`;`||i.name!==`presets`&&i.name!==`source`)continue;let a=i.prelude[0];if(a!==`"`&&a!==`'`||i.prelude[i.prelude.length-1]!==a)continue;if(i.name===`presets`){let e=N(i.prelude).map(e=>{let r=He(e,t,n,!1);if(r.includes(`,`))throw SyntaxError(`@presets: rebased module paths cannot contain commas; re-export from a path without commas`);return r});r.push({start:i.start,end:i.end,replacement:`@presets ${a}${e.join(`,`)}${a};`});continue}let o=i.prelude.slice(1,-1).trim(),s=i.name===`source`&&o.startsWith(`!`),c=s?o.slice(1):o,l=He(c,t,n,i.name===`source`);if(l===c)continue;let u=e.slice(i.start,i.end).replace(i.prelude,`${a}${s?`!`:``}${l}${a}`);r.push({start:i.start,end:i.end,replacement:u})}return Ue(e,r)}function Ge(e,n,r,i,a,s){if(F(e),a>32)return e;let c=[];for(let l of A(e)){if(l.name!==`import`||l.terminator!==`;`)continue;let e=ze(l.prelude);if(e===void 0||!Be(e))continue;let u=d(n,e);if(!s?.has(u))try{if(!t.statSync(u).isFile())continue}catch{continue}if(r.has(u)){c.push({start:l.start,end:l.end,replacement:``});continue}r.add(u),i.push(u);let f=o(u),p=Ge(s?.get(u)??t.readFileSync(u,`utf8`),f,r,i,a+1,s);p=We(p,f,n),c.push({start:l.start,end:l.end,replacement:p})}return Ue(e,c)}function Ke(e,t,n,r){let i=[],a=new Set(n?[d(t,n)]:[]);try{return{css:Ge(e,t,a,i,0,r),files:i}}catch(e){throw X(e,i),e}}function Q(e){return e?e.split(/\s+/)[0]===`theme`?{kind:`invalid`}:{kind:`mode`,mode:e}:{kind:`base`}}function qe(e){let t,n=0,r=null;for(let i=0;i<e.length;i++){let a=e[i];if(r)a===`\\`?i++:a===r&&(r=null);else if(a===`"`||a===`'`)r=a;else if(a===`/`&&e[i+1]===`*`){let r=e.indexOf(`*/`,i+2),a=r<0?e.length:r+2;(t??=[]).push(e.slice(n,i),` `),n=a,i=a-1}}return t?`${t.join(``)}${e.slice(n)}`:e}function Je(e){let t=e[0];if(t===`"`||t===`'`)for(let n=1;n<e.length;n++){let r=e[n];if(r===`\\`)n++;else if(r===t)return n===e.length-1?e.slice(1,n):void 0}}function $(e){let t=A(e),n=[],r={},i=[],a=[],o=[],s=!1,c=!1;for(let e of t){if(e.name===`custom`&&e.terminator===`block`?s=!0:e.name===`teacss`&&e.prelude===``&&e.terminator!==`block`&&(c=!0),e.terminator!==`;`)continue;if(M.includes(e.name)){try{let t=e.name,n=N(e.prelude);r[t]=[...new Set([...r[t]??[],...n])].sort()}catch{}continue}if(e.name===`shortcut`){let t=e.prelude.search(/\s/);if(t<=0)continue;let n=e.prelude.slice(0,t);if(!/^[A-Za-z_][\w-]*$/.test(n))continue;let r=Je(e.prelude.slice(t).trimStart())?.trim();r&&a.push({name:n,expansion:r});continue}if(e.name!==`presets`&&e.name!==`source`&&e.name!==`safelist`)continue;let t=Je(e.prelude)?.trim();if(!t)continue;if(e.name===`presets`){try{n.push(...N(e.prelude))}catch{}continue}if(e.name===`safelist`){o.push(t);continue}let l=t.startsWith(`!`),u=l?t.slice(1):t;u&&i.push({glob:u,exclude:l})}let l=s?j(e).flatMap(({mode:e,declarations:t})=>{let n=Q(e);return n.kind===`invalid`?[]:[{mode:n.kind===`base`?void 0:n.mode,declarations:t.map(({property:e,value:t})=>({property:e,value:qe(t).trim()}))}]}):[];return{presets:n,...Object.keys(r).length?{rolePalettes:r}:{},sources:i,custom:l,shortcuts:a,safelist:o,hasTeacss:c}}async function Ye(e,t,n,r){let a=e.filter(e=>!e.exclude).map(e=>e.glob);if(a.length===0)return{shortcuts:[],safelist:[],files:[]};let o=e.filter(e=>e.exclude).map(e=>e.glob),s=await ee(a,{cwd:t,absolute:!0,ignore:o,expandDirectories:!1}),c=new Set(n),l=s.filter(e=>e.endsWith(`.css`)&&!c.has(e)).sort(),u=[],d=[];for(let e of l){let t;try{t=r?.get(e)??i(e,`utf8`)}catch(e){if(e.code===`ENOENT`)continue;throw e}if(!t.includes(`@shortcut`)&&!t.includes(`@safelist`))continue;let n=$(t);u.push(...n.shortcuts),d.push(...n.safelist)}return{shortcuts:u,safelist:d,files:l}}async function Xe(e,t,n,r){let i=Ke(e,t,n,r),a=$(i.css),[o,s]=await Promise.all([a.presets.length?Le(a.presets,t):{presets:[],sources:[]},Ye(a.sources,t,i.files,r)]).catch(e=>{throw X(e,i.files),e}),c=o.presets,l={},u=[],d=Object.freeze(Object.fromEntries(Object.entries(a.rolePalettes??{}).map(([e,t])=>[e,Object.freeze([...t])]))),f={name:`@teacss/config/role-palettes`,configResolved(e){Object.defineProperty(e,Symbol.for(`@teacss/config/role-palettes`),{value:d,configurable:!0})}};await _({presets:c,configResolved(e){if({theme:l,unknown:u}=E(a.custom,oe(e.theme)),a.rolePalettes&&!e.presets.some(e=>e.name===`@teacss/preset-standard`))throw TypeError(`Role palette directives require an explicitly enabled Standard preset`);e.theme=g(e.theme,l),a.rolePalettes&&f.configResolved?.(e)}}).catch(e=>{throw X(e,[...i.files,...s.files,...o.sources]),e});let p=[...a.sources.filter(e=>!e.exclude).map(e=>e.glob),...a.sources.filter(e=>e.exclude).map(e=>`!${e.glob}`)],m=[...s.shortcuts,...a.shortcuts],ee=Object.fromEntries(m.map(({name:e,expansion:t})=>[e,t])),y=[...new Set([...s.safelist,...a.safelist].flatMap(e=>v(h(e))))];return{config:{presets:a.rolePalettes?[...c,f]:c,theme:l,...a.sources.length?{content:{filesystem:p}}:{},...m.length?{shortcuts:ee}:{},...y.length?{safelist:y}:{}},unknown:u,hasTeacss:i.files.length===0?a.hasTeacss:$(e).hasTeacss,sources:[...i.files,...s.files,...o.sources]}}const Ze=re.join(` `);function Qe(e,t){switch(t){case`unknown-prefix`:return`@custom var "${e}" matches no theme namespace — not registered (emitted as a plain :root var).`;case`illegal-color-step`:return`@custom var "${e}" has an illegal color step — palette steps are ${Ze}.`;case`removed-theme`:return`@custom ${e}: named themes were removed; use global / mode values and data-css-<role> palette selectors.`}}function $e(e,t){let n=S(t),r=[],i=j(e);for(let e of i){if(Q(e.mode).kind===`invalid`){r.push({property:e.mode,start:e.start,end:e.open,reason:`removed-theme`,message:Qe(e.mode,`removed-theme`)});continue}for(let t of e.declarations){let{property:e,start:i,end:a}=t,o=T(e.slice(2),n);o.ok||r.push({property:e,start:i,end:a,reason:o.reason,message:Qe(e,o.reason)})}}return r}const et=Object.freeze([`package.json`,`index.css`,`src/index.css`]),[tt,...nt]=et;function rt(e){let t=e instanceof Error?`${e.name}:${e.message}`:`${typeof e}:${String(e)}`,r=Array.from(new Set(Z(e))).sort().map(e=>{try{let t=n.statSync(e);return`${e}:${t.mtimeMs}:${t.ctimeMs}:${t.size}:${t.ino}`}catch(t){let n=t.code;return`${e}:${n===`ENOENT`?`missing`:`unreadable:${n??String(t)}`}`}});return JSON.stringify([t,r])}function it(e,t){let n={...e};for(let e of Reflect.ownKeys(t)){if(!Object.getOwnPropertyDescriptor(t,e)?.enumerable)continue;let r=Reflect.get(t,e);r!==void 0&&Object.defineProperty(n,e,{value:r,configurable:!0,enumerable:!0,writable:!0})}return n}function at(e){try{let t=n.readFileSync(e,`utf8`);return t.includes(`@teacss`)?A(t).some(e=>e.name===`teacss`&&e.prelude===``&&e.terminator!==`block`):!1}catch(e){if(e.code===`ENOENT`)return!1;throw e}}function ot(e){try{let t=JSON.parse(n.readFileSync(l(e,tt),`utf8`))?.teacss?.entry;return typeof t==`string`?t:void 0}catch(e){if(e.code===`ENOENT`)return;throw e}}function st(e){let t=ot(e);if(t){let r=d(e,t);if(n.existsSync(r)&&n.statSync(r).isFile())return r}for(let t of nt){let r=l(e,t);if(n.existsSync(r)&&n.statSync(r).isFile()&&at(r))return r}}async function ct(e=p.cwd(),t=e,r={}){if(typeof t!=`string`)return{config:it(r,t),sources:[]};let i=d(e,t),a=n.existsSync(i)&&n.statSync(i).isFile()?i:st(i);if(!a)return{config:{...r},sources:[]};let s;try{s=await Xe(n.readFileSync(a,`utf8`),o(a),a)}catch(e){throw X(e,[a]),e}let{config:c}=s,l=it(r,c);return c.presets?.length||(r.presets?.length?l.presets=r.presets:m.warn(`[@teacss/config] "${a}" declares no @presets — no utilities will be generated. Add one, e.g. \`@presets "standard";\``)),{config:l,sources:Array.from(new Set([a,...s.sources]))}}function lt(){let e=new Map,t=new Map,n=new Map,r=new Map,i=new WeakMap,a=new WeakMap,o=new WeakMap,s=new WeakMap,c=(e,n)=>e?t.get(e):n?a.get(n):void 0,l=(e,t)=>e?n.get(e):t?o.get(t):void 0,u=async(e,t)=>{for(;;){let n=c(e,t),r=l(e,t);if(!r)return;let i=await r;if(c(e,t)===n)return i}};return(c=p.cwd(),l=c,f={})=>{let h=typeof l==`string`?d(c,l):void 0,g=typeof l==`object`&&l?l:void 0,_=h?(t.get(h)??0)+1:g?(a.get(g)??0)+1:0;h?t.set(h,_):g&&a.set(g,_);let v=ct(c,l,f).then(n=>(h&&t.get(h)===_?(e.set(h,n),r.delete(h)):g&&a.get(g)===_&&(i.set(g,n),s.delete(g)),n),async n=>{let o=h?t.get(h)===_:!g||a.get(g)===_;if(!o){let e=await u(h,g);if(e)return e}let c=h?e.get(h):g?i.get(g):void 0;if(!c)throw n;if(o){let e=rt(n);e!==(h?r.get(h):g?s.get(g):void 0)&&(m.error(`[@teacss/config] Error resolving config from the CSS entry:`,n),h?r.set(h,e):g&&s.set(g,e));let t=Array.from(new Set([...c.sources,...Z(n)]));return t.length===c.sources.length?c:{...c,sources:t}}return c});return h?n.set(h,v):g&&o.set(g,v),v}}export{M as ROLE_DIRECTIVES,F as assertEntryDirectives,S as buildNamespaces,T as classifyCustomVar,lt as createRecoveryConfigLoader,E as customToTheme,$e as diagnoseCustom,P as diagnoseEntry,et as entryDiscoveryFiles,st as findEntry,Z as getConfigSourcesFromError,ue as hasTopLevelDirective,ct as loadConfig,Q as parseCustomPrelude,$ as parseEntry,N as parseEntryList,Xe as resolveEntryConfig,Re as resolvePresets,oe as scaleThemeKeys,j as scanCustomBlocks,le as scanQuotedDirectives,A as scanTopLevelAtRules};
1
+ import{A as e,B as t,D as n,E as r,F as i,H as a,I as o,L as s,M as c,N as l,O as u,P as d,R as f,T as p,V as m,a as h,i as g,j as _,k as v,n as y,r as b,t as x,w as S,z as C}from"./recovery-BWqktIa3.js";import w from"node:process";const T=a.join(` `);function E(e,t){switch(t){case`unknown-prefix`:return`@custom var "${e}" matches no theme namespace — not registered (emitted as a plain :root var).`;case`illegal-color-step`:return`@custom var "${e}" has an illegal color step — palette steps are ${T}.`;case`removed-theme`:return`@custom ${e}: named themes were removed; use global / mode values and data-css-<role> palette selectors.`}}function D(e,t){let r=f(t),a=[],o=i(e);for(let e of o){if(n(e.mode).kind===`invalid`){a.push({property:e.mode,start:e.start,end:e.open,reason:`removed-theme`,message:E(e.mode,`removed-theme`)});continue}for(let t of e.declarations){let{property:e,start:n,end:i}=t,o=C(e.slice(2),r);o.ok||a.push({property:e,start:n,end:i,reason:o.reason,message:E(e,o.reason)})}}return a}async function O(e,t,n,r){let i=await h(e,t,n,r);if(i.status===`failed`)throw i.cause;return i.result}function k(){let e=x(!0);return(t=w.cwd(),n=t,r={})=>e(t,n,r)}export{v as EntryConfigError,e as ROLE_DIRECTIVES,_ as assertEntryDirectives,f as buildNamespaces,C as classifyCustomVar,k as createRecoveryConfigLoader,t as customToTheme,D as diagnoseCustom,c as diagnoseEntry,y as entryDiscoveryFiles,b as findEntry,p as getConfigSourcesFromError,d as hasTopLevelDirective,g as loadConfig,n as parseCustomPrelude,u as parseEntry,l as parseEntryList,S as resolveCustomTheme,O as resolveEntryConfig,r as resolvePresets,m as scaleThemeKeys,i as scanCustomBlocks,o as scanQuotedDirectives,s as scanTopLevelAtRules};
@@ -0,0 +1,9 @@
1
+ import { A as sourceWatchTargets, C as sourceDeclarationIntentsOf, D as sourceDeclarationWatchTargets, E as sourceDeclarationStateOf, M as SourceWatchRegistry, N as SourceScanOptions, O as sourceDeclarationsOf, P as SourceSymlinkRoute, S as sourceDeclarationIntent, T as sourceDeclarationSnapshot, _ as observeSourceDeclarations, a as SourceDeclarationAttempt, b as recoverSourceDeclarations, c as SourceDeclarationProbe, d as SourceWatchPlan, f as SourceWatchPlanning, g as createSourceDeclarationCheck, h as copySourceDeclarations, j as stageSourceDeclarations, k as sourceWatchEventRelevant, l as SourceDeclarationSnapshot, m as attachSourceDeclarations, o as SourceDeclarationFailure, p as SourceWatchTarget, s as SourceDeclarationIntent, t as LoadConfigResult, u as SourceDeclarationState, v as planSourceWatches, w as sourceDeclarationMemberPaths, x as scanSourceFiles, y as probeSourceDeclarations } from "../load-config-CAzqJCHM.js";
2
+ import { UserConfig, UserConfigDefaults } from "@teacss/core";
3
+ //#region src/recovery.d.ts
4
+ export declare function createAcceptedConfigLoader<U extends UserConfig>(immediate?: boolean): {
5
+ (cwd?: string, configOrPath?: string | U, defaults?: UserConfigDefaults): Promise<LoadConfigResult<U>>;
6
+ accept(loaded: LoadConfigResult<U>, accepted?: LoadConfigResult<U>): void;
7
+ };
8
+ //#endregion
9
+ export { SourceDeclarationAttempt, SourceDeclarationFailure, SourceDeclarationIntent, SourceDeclarationProbe, SourceDeclarationSnapshot, SourceDeclarationState, type SourceScanOptions, type SourceSymlinkRoute, SourceWatchPlan, SourceWatchPlanning, SourceWatchRegistry, SourceWatchTarget, attachSourceDeclarations, copySourceDeclarations, createSourceDeclarationCheck, observeSourceDeclarations, planSourceWatches, probeSourceDeclarations, recoverSourceDeclarations, scanSourceFiles, sourceDeclarationIntent, sourceDeclarationIntentsOf, sourceDeclarationMemberPaths, sourceDeclarationSnapshot, sourceDeclarationStateOf, sourceDeclarationWatchTargets, sourceDeclarationsOf, sourceWatchEventRelevant, sourceWatchTargets, stageSourceDeclarations };
@@ -0,0 +1 @@
1
+ import{C as e,S as t,_ as n,b as r,c as i,d as a,f as o,g as s,h as c,l,m as u,o as d,p as f,s as p,t as m,u as h,v as g,x as _,y as v}from"../recovery-BWqktIa3.js";import{isAbsolute as y,relative as b,resolve as x,sep as S}from"node:path";function C(e,t){let n=b(e,t);return n===``||n!==`..`&&!n.startsWith(`..${S}`)&&!y(n)}var w=class{createWatcher;onChange;onError;#e=!1;#t=new Map;#n=new Map;constructor(e,t,n){this.createWatcher=e,this.onChange=t,this.onError=n}get roots(){return[...this.#n.values()].map(({plan:e})=>e.directory)}reconcile(e){if(this.#e)return;let t=[...e.plans].sort((e,t)=>e.directory.length-t.directory.length||e.directory.localeCompare(t.directory)),n=t.filter((e,n)=>!e.recursive||!t.slice(0,n).some(t=>t.recursive&&C(t.directory,e.directory))),r=!1,i=[],a=new Map;try{for(let e of n){let t=JSON.stringify(e);if(this.#n.has(t))continue;let n;try{n=this.createWatcher(e.directory,(r,i)=>{if(this.#e||this.#n.get(t)?.handle!==n||!_(e,i))return;let a=i==null?e.recursive?[e.directory]:e.children.map(t=>x(e.directory,t)):[x(e.directory,i.toString())];for(let[e,t]of this.#t){let n=t.recursive?[t.directory]:t.children.map(e=>x(t.directory,e));a.some(e=>n.some(t=>{let n=e.normalize(`NFC`).toLowerCase(),r=t.normalize(`NFC`).toLowerCase();return C(n,r)||C(r,n)}))&&this.#t.delete(e)}this.onChange(i==null?void 0:x(e.directory,i.toString()))},e.recursive);let r=n;n.on(`error`,n=>{if(this.#e||this.#n.get(t)?.handle!==r)return;this.#n.delete(t);let i=!this.#t.has(t);this.#t.set(t,e),this.closeWatcher(r),this.onError(n),i&&!this.#e&&this.#t.has(t)&&this.onChange(void 0)}),a.set(t,{plan:e,handle:n})}catch(a){n&&this.closeWatcher(n);let o=a?.code;if(o===`ENOENT`||o===`ENOTDIR`||o===`ELOOP`){r=!0;continue}if(!n&&o===`EACCES`){i.push({key:t,plan:e,error:a});continue}throw a}}}catch(e){for(let{handle:e}of a.values())this.closeWatcher(e);throw e}if(this.#e){for(let{handle:e}of a.values())this.closeWatcher(e);return}let o=new Map;for(let e of n){let t=JSON.stringify(e),n=this.#n.get(t)??a.get(t);n&&o.set(t,n)}let s=new Set(n.map(e=>JSON.stringify(e)));for(let e of this.#t.keys())s.has(e)||this.#t.delete(e);let c=this.#n;this.#n=o;for(let[e,{handle:t}]of c)o.has(e)||this.closeWatcher(t);if(this.#e||this.#n!==o)return;let l=i.filter(({key:e})=>!this.#t.has(e)).map(({key:e})=>e);for(let{key:e,plan:t}of i)this.#t.set(e,t);for(let t of[...e.permissionErrors,...i.map(({error:e})=>e)]){if(this.#e||this.#n!==o)return;this.onError(t)}!this.#e&&this.#n===o&&(r||l.some(e=>this.#t.has(e)))&&this.onChange(void 0)}retire(){if(this.#e)return;this.#e=!0,this.#t.clear();let e=this.#n;this.#n=new Map;for(let{handle:t}of e.values())this.closeWatcher(t)}closeWatcher(e){try{e.close()}catch(e){this.onError(e)}}};export{w as SourceWatchRegistry,d as attachSourceDeclarations,p as copySourceDeclarations,m as createAcceptedConfigLoader,i as createSourceDeclarationCheck,l as observeSourceDeclarations,h as planSourceWatches,a as probeSourceDeclarations,o as recoverSourceDeclarations,f as scanSourceFiles,u as sourceDeclarationIntent,c as sourceDeclarationIntentsOf,s as sourceDeclarationMemberPaths,n as sourceDeclarationSnapshot,g as sourceDeclarationStateOf,v as sourceDeclarationWatchTargets,r as sourceDeclarationsOf,_ as sourceWatchEventRelevant,t as sourceWatchTargets,e as stageSourceDeclarations};
@@ -0,0 +1,118 @@
1
+ import { UserConfig, UserConfigDefaults } from "@teacss/core";
2
+ import "tinyglobby";
3
+ //#region src/source-scan-impl.d.ts
4
+ /** @internal Filename enumeration shared by TeaCSS integrations. */
5
+ interface SourceSymlinkRoute {
6
+ readonly lexical: string;
7
+ readonly physical: string;
8
+ readonly status: "entered" | "unresolved";
9
+ }
10
+ interface SourceScanOptions {
11
+ cwd: string;
12
+ ignore?: readonly string[];
13
+ expandDirectories: boolean;
14
+ }
15
+ //#endregion
16
+ //#region src/source-watch-registry.d.ts
17
+ type WatchHandle = {
18
+ close(): void;
19
+ on(event: "error", listener: (error: unknown) => void): unknown;
20
+ };
21
+ type WatchFactory = (directory: string, onChange: (eventType: string, filename: string | Buffer | null) => void, recursive: boolean) => WatchHandle;
22
+ declare class SourceWatchRegistry {
23
+ #private;
24
+ private readonly createWatcher;
25
+ private readonly onChange;
26
+ private readonly onError;
27
+ constructor(createWatcher: WatchFactory, onChange: (target: string | undefined) => void, onError: (error: unknown) => void);
28
+ get roots(): string[];
29
+ reconcile(planning: SourceWatchPlanning): void;
30
+ retire(): void;
31
+ private closeWatcher;
32
+ }
33
+ //#endregion
34
+ //#region src/source-scan.d.ts
35
+ /** @internal Shared filename enumeration for TeaCSS integrations. */
36
+ declare function scanSourceFiles(patterns: readonly string[], options: SourceScanOptions): Promise<string[]>;
37
+ interface SourceDeclarationIntent {
38
+ readonly base: string;
39
+ readonly patterns: readonly string[];
40
+ readonly ignore: readonly string[];
41
+ readonly inlined: readonly string[];
42
+ }
43
+ interface SourceDeclarationSnapshot extends SourceDeclarationIntent {
44
+ readonly status: "read";
45
+ readonly members: readonly {
46
+ path: string;
47
+ contents: string;
48
+ }[];
49
+ readonly routes: readonly SourceSymlinkRoute[];
50
+ readonly signature: string;
51
+ }
52
+ interface SourceDeclarationFailure extends SourceDeclarationIntent {
53
+ readonly status: "failed";
54
+ readonly operation: "enumerate" | "read";
55
+ readonly path?: string;
56
+ readonly cause: unknown;
57
+ readonly routes: readonly SourceSymlinkRoute[];
58
+ readonly signature: string;
59
+ }
60
+ type SourceDeclarationAttempt = SourceDeclarationSnapshot | SourceDeclarationFailure;
61
+ interface SourceDeclarationState {
62
+ consumed: SourceDeclarationSnapshot | undefined;
63
+ readonly attempted: SourceDeclarationAttempt | undefined;
64
+ readonly recovered: boolean;
65
+ }
66
+ declare function sourceDeclarationStateOf(result: object): SourceDeclarationState | undefined;
67
+ declare function sourceDeclarationsOf(result: object): SourceDeclarationSnapshot | undefined;
68
+ declare function attachSourceDeclarations<T extends object>(result: T, snapshot: SourceDeclarationSnapshot | undefined): T;
69
+ declare function copySourceDeclarations<T extends object>(result: T, source: object): T;
70
+ declare function recoverSourceDeclarations<T extends object>(result: T, source: object | undefined, attempted: SourceDeclarationAttempt | undefined): T;
71
+ declare function stageSourceDeclarations(result: object, consumed: SourceDeclarationSnapshot | undefined): SourceDeclarationState;
72
+ declare function sourceDeclarationIntentsOf(state: SourceDeclarationState | undefined): readonly SourceDeclarationAttempt[];
73
+ declare function sourceDeclarationMemberPaths(state: SourceDeclarationState | undefined): string[];
74
+ declare function sourceDeclarationWatchTargets(state: SourceDeclarationState | undefined): SourceWatchTarget[];
75
+ declare function sourceDeclarationIntent(base: string, patterns: readonly string[], inlined: readonly string[], ignore?: readonly string[]): SourceDeclarationIntent;
76
+ declare function sourceDeclarationSnapshot(base: string, patterns: readonly string[], inlined: readonly string[], members: SourceDeclarationSnapshot["members"], ignore?: readonly string[], routes?: readonly SourceSymlinkRoute[]): SourceDeclarationSnapshot;
77
+ declare function observeSourceDeclarations(intent: SourceDeclarationIntent, overrides?: ReadonlyMap<string, string>): Promise<SourceDeclarationAttempt>;
78
+ interface SourceDeclarationProbe {
79
+ readonly attempts: readonly SourceDeclarationAttempt[];
80
+ readonly signature: string;
81
+ }
82
+ declare function probeSourceDeclarations(state: SourceDeclarationState | undefined, baseline?: boolean, previous?: SourceDeclarationProbe): Promise<SourceDeclarationProbe>;
83
+ /** Native watchers can omit changes; probe only the already bounded declaration intents. */
84
+ declare function createSourceDeclarationCheck(readState: () => SourceDeclarationState | undefined, onChange: (current: SourceDeclarationProbe) => Promise<void>, onError: (error: unknown) => void | Promise<void>): {
85
+ retire: () => void;
86
+ close(): Promise<void>;
87
+ };
88
+ interface SourceWatchTarget {
89
+ readonly kind: "exact" | "tree";
90
+ readonly path: string;
91
+ }
92
+ interface SourceWatchPlan {
93
+ readonly directory: string;
94
+ readonly recursive: boolean;
95
+ readonly identity: string;
96
+ readonly children: readonly string[];
97
+ }
98
+ declare function sourceWatchTargets(patterns: readonly string[], base: string, expandDirectories?: boolean): SourceWatchTarget[];
99
+ interface SourceWatchPlanning {
100
+ readonly plans: readonly SourceWatchPlan[];
101
+ readonly permissionErrors: readonly unknown[];
102
+ }
103
+ declare function planSourceWatches(targets: readonly SourceWatchTarget[]): SourceWatchPlanning;
104
+ declare function sourceWatchEventRelevant(plan: SourceWatchPlan, filename: string | Buffer | null): boolean;
105
+ //#endregion
106
+ //#region src/load-config.d.ts
107
+ interface LoadConfigResult<U> {
108
+ config: U;
109
+ /** CSS entry graph, package preset entries, and bounded local preset graphs. */
110
+ sources: string[];
111
+ }
112
+ /** Relative files that can change CSS-entry discovery, in resolution order. */
113
+ declare const entryDiscoveryFiles: readonly ["package.json", "index.css", "src/index.css"];
114
+ /** Find the CSS entry: package.json override → index.css → src/index.css. */
115
+ declare function findEntry(root: string): string | undefined;
116
+ declare function loadConfig<U extends UserConfig>(cwd?: string, configOrPath?: string | U, defaults?: UserConfigDefaults): Promise<LoadConfigResult<U>>;
117
+ //#endregion
118
+ export { sourceWatchTargets as A, sourceDeclarationIntentsOf as C, sourceDeclarationWatchTargets as D, sourceDeclarationStateOf as E, SourceWatchRegistry as M, SourceScanOptions as N, sourceDeclarationsOf as O, SourceSymlinkRoute as P, sourceDeclarationIntent as S, sourceDeclarationSnapshot as T, observeSourceDeclarations as _, SourceDeclarationAttempt as a, recoverSourceDeclarations as b, SourceDeclarationProbe as c, SourceWatchPlan as d, SourceWatchPlanning as f, createSourceDeclarationCheck as g, copySourceDeclarations as h, loadConfig as i, stageSourceDeclarations as j, sourceWatchEventRelevant as k, SourceDeclarationSnapshot as l, attachSourceDeclarations as m, entryDiscoveryFiles as n, SourceDeclarationFailure as o, SourceWatchTarget as p, findEntry as r, SourceDeclarationIntent as s, LoadConfigResult as t, SourceDeclarationState as u, planSourceWatches as v, sourceDeclarationMemberPaths as w, scanSourceFiles as x, probeSourceDeclarations as y };
@@ -0,0 +1,2 @@
1
+ import{createRequire as e}from"node:module";import*as t from"node:fs";import n,{existsSync as r,lstatSync as i,readFileSync as a,readlinkSync as o,realpathSync as s,statSync as c}from"node:fs";import*as l from"node:path";import{dirname as u,extname as d,isAbsolute as f,join as p,relative as m,resolve as h,sep as g}from"node:path";import _ from"node:process";import{consola as v}from"consola";import{expandClassGroups as ee,mergeDeep as y,resolveConfig as te,splitClassTokens as ne}from"@teacss/core";import{Buffer as b}from"node:buffer";import{readFile as x,stat as re}from"node:fs/promises";import{fileURLToPath as ie,pathToFileURL as ae}from"node:url";import{AsyncLocalStorage as oe}from"node:async_hooks";import se from"picomatch";import{glob as ce,isDynamicPattern as le}from"tinyglobby";const S=[`000`,`100`,`150`,`200`,`300`,`400`,`500`,`600`,`700`,`800`,`850`,`900`,`950`],ue=new Set(S);function de(e){return e.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`)}function fe(e){return Object.keys(e).filter(t=>{if(t===`modes`||t===`defaultMode`||t===`rolePalettes`)return!1;let n=e[t];return typeof n!=`object`||!n?!1:t===`colors`||Object.values(n).every(e=>e==null||typeof e==`string`||typeof e==`number`||Array.isArray(e))})}function pe(e){return e.map(e=>({key:e,prefix:e===`colors`||e===`semanticColors`?`color`:de(e),twoLevel:e===`colors`,semanticColor:e===`semanticColors`})).sort((e,t)=>t.prefix.length-e.prefix.length)}function C(e,t,n){Object.defineProperty(e,t,{value:n,configurable:!0,enumerable:!0,writable:!0})}function w(e,t){let n=Object.hasOwn(e,t)?e[t]:void 0;if(typeof n==`object`&&n&&!Array.isArray(n))return n;let r={};return C(e,t,r),r}function me(e,t){let n=t.filter(t=>e===t.prefix||e.startsWith(`${t.prefix}-`)),r=n.find(e=>e.key===`colors`),i=n.find(e=>e.semanticColor);if(r&&i){let t=e===`color`?``:e.slice(6),n=t.lastIndexOf(`-`),a=n>0?t.slice(0,n):``,o=n>0?t.slice(n+1):``;return a&&ue.has(o)?{ok:!0,nsKey:r.key,twoLevel:!0,rest:t,colorName:a,step:o}:a&&/^\d+$/.test(o)?{ok:!1,reason:`illegal-color-step`}:t?{ok:!0,nsKey:i.key,twoLevel:!1,rest:t}:{ok:!1,reason:`unknown-prefix`}}let a=n[0];if(!a)return{ok:!1,reason:`unknown-prefix`};let o=e===a.prefix?``:e.slice(a.prefix.length+1);if(a.twoLevel){let e=o.lastIndexOf(`-`),t=e>0?o.slice(0,e):``,n=e>0?o.slice(e+1):``;return!t||!ue.has(n)?{ok:!1,reason:`illegal-color-step`}:{ok:!0,nsKey:a.key,twoLevel:!0,rest:o,colorName:t,step:n}}return{ok:!0,nsKey:a.key,twoLevel:!1,rest:o}}function T(e,t){let n=pe(t),r={},i=[],a=e=>{let t=me(e.startsWith(`--`)?e.slice(2):e,n);return t.ok||i.push(e),t},o=(e,t,n)=>{let r=w(e,t.nsKey);t.twoLevel?C(w(r,t.colorName),t.step,n):C(r,t.rest||`DEFAULT`,n)};for(let t of e){let e=t.mode?w(w(r,`modes`),t.mode):r;for(let{property:n,value:r}of t.declarations){let t=a(n);t.ok&&o(e,t,r)}}return{theme:r,unknown:i}}function he(e){if(e.terminator!==`;`)return`expected @custom <name> "<family>"; without a mode or block`;let t=/^(\S+)\s+(["'])([^"']*)\2$/.exec(e.prelude);if(!t)return`expected one name and one complete quoted target without extra arguments`;if(!/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/.test(t[1])||/^\d+$/.test(t[1].split(`-`).at(-1)))return`alias names must use lowercase kebab-case with a nonnumeric final segment`;if(!/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/.test(t[3]))return`target must be one lowercase kebab-case palette name, without a list`}function E(e,t,n){if(he(t))return;let r=e.slice(t.start,t.end).replace(/(["'])(?:\\.|(?!\1)[\s\S])*?\1|\/\*[\s\S]*?\*\//g,e=>e.startsWith(`/*`)?e.replace(/[^\r\n]/g,` `):e),i=/^@custom\s+(\S+)\s+(["'])([^"']*)\2\s*;$/.exec(r);if(!i)return;let a=t.start+r.indexOf(i[1],7),o=t.start+r.indexOf(i[2],a-t.start+i[1].length)+1;return{name:i[1],family:i[3],statement:{file:n,start:t.start,end:t.end},nameRange:{file:n,start:a,end:a+i[1].length},familyRange:{file:n,start:o,end:o+i[3].length}}}function ge(e){return S.map(t=>({property:`--color-${e.name}-${t}`,value:`var(--color-${e.family}-${t}${t===`000`?`, white`:``})`}))}const _e=/[A-Za-z0-9-]/,ve=/[\w-]/;function D(e,t,n){let r=e.indexOf(`*/`,t+2);return r<0||r>=n?n:r+2}function O(e,t,n){let r=e[t];for(let i=t+1;i<n;i++)if(e[i]===`\\`)i++;else if(e[i]===r)return i+1;return n}function k(e,t,n){let r=``;for(let i=t;i<n;i++)if(e[i]===`/`&&e[i+1]===`*`)i=D(e,i,n)-1,r+=` `;else if(e[i]===`"`||e[i]===`'`){let t=O(e,i,n);r+=e.slice(i,t),i=t-1}else r+=e[i];return r.trim()}function ye(e,t){let n=[],r=t.startsWith(`@`)?t.slice(1):t;for(let t of A(e)){if(t.name!==r||t.terminator!==`;`)continue;let e=t.prelude[0];if(e!==`"`&&e!==`'`)continue;let i=O(t.prelude,0,t.prelude.length);i!==t.prelude.length||i<=1||t.prelude[i-1]!==e||n.push(t.prelude.slice(1,i-1))}return n}function be(e,t){let n=t.startsWith(`@`)?t.slice(1):t;return A(e).some(e=>e.name===n)}function xe(e,t){for(let n=t;n<e.length;n++)if(e[n]===`/`&&e[n+1]===`*`)n=D(e,n,e.length)-1;else if(e[n]===`"`||e[n]===`'`)n=O(e,n,e.length)-1;else if(e[n]===`{`)return n;else if(e[n]===`;`||e[n]===`}`)return-1;return-1}function Se(e,t){let n=1;for(let r=t+1;r<e.length;r++)if(e[r]===`/`&&e[r+1]===`*`)r=D(e,r,e.length)-1;else if(e[r]===`"`||e[r]===`'`)r=O(e,r,e.length)-1;else if(e[r]===`{`)n++;else if(e[r]===`}`&&--n===0)return r;return-1}function A(e,t=!1){let n=[],r=0;for(let i=0;i<e.length;i++){if(e[i]===`/`&&e[i+1]===`*`){i=D(e,i,e.length)-1;continue}if(e[i]===`"`||e[i]===`'`){i=O(e,i,e.length)-1;continue}if(e[i]===`{`){r++;continue}if(e[i]===`}`){r=Math.max(0,r-1);continue}if(!t&&r!==0||e[i]!==`@`)continue;let a=i,o=a+1;for(;ve.test(e[o]??``);)o++;if(o===a+1)continue;let s=e.slice(a+1,o),c=[],l=!1;for(let u=o;u<e.length;u++){let d=e[u];if(d===`/`&&e[u+1]===`*`)u=D(e,u,e.length)-1;else if(d===`"`||d===`'`)u=O(e,u,e.length)-1;else if(d===`(`)c.push(`)`);else if(d===`[`)c.push(`]`);else if(d===c.at(-1))c.pop();else if(c.length===0&&d===`;`){n.push({name:s,prelude:k(e,o,u),start:a,end:u+1,terminator:`;`,...t?{depth:r}:{}}),i=u,l=!0;break}else if(c.length===0&&d===`{`){let c=Se(e,u);(c>=0||t)&&(n.push({name:s,prelude:k(e,o,u),start:a,end:c<0?e.length:c+1,terminator:`block`,...t?{depth:r}:{}}),i=t?u:c,t&&r++,l=!0);break}}if(!l){n.push({name:s,prelude:k(e,o,e.length),start:a,end:e.length,terminator:`eof`,...t?{depth:r}:{}});break}}return n}function Ce(e,t,n){let r=[];for(let i=t;i<n;i++){let t=e[i];if(t===`/`&&e[i+1]===`*`)i=D(e,i,n)-1;else if(t===`"`||t===`'`)i=O(e,i,n)-1;else if(t===`(`)r.push(`)`);else if(t===`[`)r.push(`]`);else if(t===`{`)r.push(`}`);else if(t===r.at(-1))r.pop();else if(t===`;`&&r.length===0)return i}return n}function we(e,t,n){let r=[];for(let i=t;i<n;){for(;i<n;)if(/\s/.test(e[i]))i++;else if(e[i]===`/`&&e[i+1]===`*`)i=D(e,i,n);else break;let t=Ce(e,i,n);if(e[i]!==`-`||e[i+1]!==`-`){i=t+1;continue}let a=i+2;for(;a<n&&_e.test(e[a]);)a++;if(a===i+2){i=t+1;continue}let o=a;for(;o<n;)if(/\s/.test(e[o]))o++;else if(e[o]===`/`&&e[o+1]===`*`)o=D(e,o,n);else break;if(e[o]!==`:`){i=t+1;continue}let s=o+1,c=e.slice(s,t),l=c.trim(),u=s+c.length-c.trimStart().length,d=u+l.length;r.push({property:e.slice(i,a),value:l,start:i,end:a,colon:o,valueStart:u,valueEnd:d}),i=t+1}return r}function Te(e){let t=[];for(let n of A(e)){if(n.name!==`custom`||n.terminator!==`block`)continue;let r=xe(e,n.start+7);if(r<0)continue;let i=n.end-1;t.push({mode:n.prelude||void 0,declarations:we(e,r+1,i),start:n.start,open:r,close:i})}return t}const j=[`primary`,`neutral`,`success`,`warning`,`failure`,`general`];var Ee=class extends SyntaxError{diagnostics;constructor(e){super(e.map(e=>e.message).join(`
2
+ `)),this.diagnostics=e,this.name=`EntryConfigError`}};function M(e){let t=e[0];if(t!==`"`&&t!==`'`)throw Error(`expected one quoted comma-separated list`);let n=1;for(;n<e.length;n++)if(e[n]===`\\`)n++;else if(e[n]===t)break;if(n!==e.length-1||e[n]!==t)throw Error(`expected one complete quoted list without extra arguments`);let r=e.slice(1,-1);if(r.includes(`\\,`))throw Error(`commas cannot be escaped; re-export the preset from a path without commas`);let i=r.split(`,`).map(e=>e.trim());if(i.some(e=>!e))throw Error(`empty lists, empty items and trailing commas are not allowed`);return i}function De(e){let t=[];for(let n of A(e,!0)){let e,r=j.includes(n.name);if(n.name===`preset`)e=`@preset was removed; use @presets "standard,icons,official";`;else if(n.name===`focused`)e=`removed; the site binds focus once with @custom focused "<family>";`;else if(n.name===`custom`&&n.terminator===`block`&&n.prelude.split(/\s+/)[0]===`theme`)e=`named themes were removed; use global / mode @custom values and data-css-<role> palette selectors`;else if(n.name===`custom`&&n.terminator!==`block`)e=n.depth?`configuration directives must be top-level`:he(n);else if(n.name===`presets`||r){if(n.depth)e=`configuration directives must be top-level`;else if(n.terminator!==`;`)e=`expected a quoted list ending with a semicolon, without a block`;else try{let t=M(n.prelude);r&&t.some(e=>!/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/.test(e))&&(e=`palette names must use lowercase kebab-case`)}catch(t){e=t.message}}e&&t.push({start:n.start,end:n.end,message:`@${n.name}: ${e}`})}return t}function Oe(e,t){let n=De(e);if(n.length)throw new Ee(n.map(e=>({...e,file:t})))}function ke(e){return e?e.split(/\s+/)[0]===`theme`?{kind:`invalid`}:{kind:`mode`,mode:e}:{kind:`base`}}function Ae(e){let t,n=0,r=null;for(let i=0;i<e.length;i++){let a=e[i];if(r)a===`\\`?i++:a===r&&(r=null);else if(a===`"`||a===`'`)r=a;else if(a===`/`&&e[i+1]===`*`){let r=e.indexOf(`*/`,i+2),a=r<0?e.length:r+2;(t??=[]).push(e.slice(n,i),` `),n=a,i=a-1}}return t?`${t.join(``)}${e.slice(n)}`:e}function je(e){let t=e[0];if(t===`"`||t===`'`)for(let n=1;n<e.length;n++){let r=e[n];if(r===`\\`)n++;else if(r===t)return n===e.length-1?e.slice(1,n):void 0}}function N(e,t){let n=A(e),r=[],i={},a=[],o=[],s=[],c=[],l=!1;for(let u of n){if(u.name===`teacss`&&u.prelude===``&&u.terminator!==`block`&&(l=!0),u.terminator!==`;`)continue;if(u.name===`custom`){let n=E(e,u,t);n&&c.push({start:u.start,block:{alias:n,declarations:ge(n)}});continue}if(j.includes(u.name)){try{let e=u.name,t=M(u.prelude);i[e]=[...new Set([...i[e]??[],...t])].sort()}catch{}continue}if(u.name===`shortcut`){let e=u.prelude.search(/\s/);if(e<=0)continue;let t=u.prelude.slice(0,e);if(!/^[A-Za-z_][\w-]*$/.test(t))continue;let n=je(u.prelude.slice(e).trimStart())?.trim();n&&o.push({name:t,expansion:n});continue}if(u.name!==`presets`&&u.name!==`source`&&u.name!==`safelist`)continue;let n=je(u.prelude)?.trim();if(!n)continue;if(u.name===`presets`){try{r.push(...M(u.prelude))}catch{}continue}if(u.name===`safelist`){s.push(n);continue}let d=n.startsWith(`!`),f=d?n.slice(1):n;f&&a.push({glob:f,exclude:d})}c.push(...Te(e).flatMap(({start:e,mode:t,declarations:n})=>{let r=ke(t);return r.kind===`invalid`?[]:[{start:e,block:{mode:r.kind===`base`?void 0:r.mode,declarations:n.map(({property:e,value:t})=>({property:e,value:Ae(t).trim()}))}}]}));let u=c.sort((e,t)=>e.start-t.start).map(({block:e})=>e);return{presets:r,...Object.keys(i).length?{rolePalettes:i}:{},sources:a,custom:u,shortcuts:o,safelist:s,hasTeacss:l}}let Me;function Ne(){return Me??=import(`jiti`).then(({createJiti:e})=>({createJiti:e,transformer:e(import.meta.url,{fsCache:!1,interopDefault:!0,moduleCache:!1})}))}const P=new Map,F=new WeakMap,Pe=16777216,I=new Map;let L=0;const Fe={icons:`@teacss/preset-icons`,official:`@teacss/preset-official`,standard:`@teacss/preset-standard`};function Ie(t,n){try{return n.resolve(t)}catch(r){let i;try{i=n.resolve(`teacss/package.json`)}catch{throw r}return e(i).resolve(t)}}function Le(t,n){if(t.startsWith(`.`)||f(t))return h(n,t);let r=e(h(n,`_`)),i=Object.hasOwn(Fe,t)?Fe[t]:void 0;return i?Ie(i,r):r.resolve(t)}function R(e){return e.startsWith(`.`)||f(e)}function z(e){try{return s(e)}catch{return h(e)}}function Re(e,t){let n=u(e),i=[];for(;;){if(t.has(n)){let e=t.get(n);for(let n of i)t.set(n,e);return e}if(i.push(n),r(h(n,`package.json`))){for(let e of i)t.set(e,n);return n}let e=u(n);if(e===n){for(let e of i)t.set(e,void 0);return}n=e}}function ze(e,t){let n=m(t,e);return n===``||!f(n)&&n!==`..`&&!n.startsWith(`..${g}`)}function B(e,t,n){let r=Re(e,n);return t.packageRoot===void 0?r===void 0&&ze(e,t.fallbackRoot):r===t.packageRoot}function V(e,t,n,r,i){if(!e||n.has(e)||(n.add(e),!f(e.filename)))return;let a=z(e.filename);if(B(a,r,i)){t.add(a);for(let a of e.children)V(a,t,n,r,i)}}function Be(e){if(!e||typeof e!=`object`)return;let t,n,r;try{t=Reflect.get(e,`path`),n=Reflect.get(e,`url`),r=Reflect.get(e,`message`)}catch{return}if(typeof t==`string`&&f(t))return z(t);if(typeof n==`string`&&n.startsWith(`file:`))return z(ie(n));if(typeof r!=`string`)return;let i=/Cannot find module ['"]([^'"]+)['"] from ['"]([^'"]+)['"]/.exec(r),a=/Cannot find module ['"]([^'"]+)['"][\s\S]*?Require stack:\s*\n- ([^\n]+)/.exec(r),o=i??a;if(!o)return;let s=o[1],c=o[2];if(s&&c&&(s.startsWith(`.`)||f(s)))return z(f(s)?s:h(u(c),s))}async function Ve(e,t){let n=P.get(e)??Promise.resolve(),r,i=new Promise(e=>{r=e}),a=n.then(()=>i);P.set(e,a),await n;try{return{evaluation:t()}}finally{r(),P.get(e)===a&&P.delete(e)}}function He(e){return()=>({visitor:{AwaitExpression(t){t.getFunctionParent()||(e.hasTopLevelAwait=!0)},CallExpression(t){t.node.callee?.type===`Identifier`&&t.node.callee.name===`jitiImport`&&(e.hasDynamicImport=!0);let n=t.node.arguments?.[0];if(t.node.callee?.type!==`Identifier`||t.node.callee.name!==`require`)return;let r=n?.type===`StringLiteral`&&typeof n.value==`string`;r&&e.dependencies.add(n.value),typeof t.node.start==`number`&&(r?t.getFunctionParent()?e.hasNestedRequire=!0:e.hasTopLevelRequire=!0:e.hasNonLiteralRequire=!0)},ForOfStatement(t){t.node.await&&!t.getFunctionParent()&&(e.hasTopLevelAwait=!0)}}})}function Ue(e,t,n){if(e.hasDynamicImport)throw Error(`Dynamic imports are not supported in local preset modules: "${t}". Use static imports so TeaCSS can track and reload the complete graph.`);if(e.hasNonLiteralRequire)throw Error(`CommonJS require() specifiers must be string literals in local preset modules: "${t}".`);if(e.hasNestedRequire)throw Error(`CommonJS require() is only supported at module top level in local preset modules: "${t}".`);if(e.hasTopLevelRequire&&e.hasTopLevelAwait)throw Error(`CommonJS require() cannot be combined with top-level await in a local preset module: "${t}". Use a static import instead.`);if(t!==n&&e.hasTopLevelAwait)throw Error(`Top-level await is only supported in the local preset entry module: "${t}".`)}const H=Symbol(`uncacheable transform option`);function We(e,t=new Set){if(e===null)return`n`;if(typeof e==`string`)return`s${JSON.stringify(e)}`;if(typeof e==`boolean`)return e?`b1`:`b0`;if(typeof e==`number`)return Number.isNaN(e)?`dNaN`:e===1/0?`dInfinity`:e===-1/0?`d-Infinity`:Object.is(e,-0)?`d-0`:`d${JSON.stringify(e)}`;if(e===void 0)return`u`;if(typeof e!=`object`||t.has(e))throw H;t.add(e);try{if(Array.isArray(e)){for(let t of Reflect.ownKeys(e)){if(t===`length`)continue;if(typeof t!=`string`)throw H;let n=Number(t),r=Object.getOwnPropertyDescriptor(e,t);if(!Number.isSafeInteger(n)||n<0||String(n)!==t||n>=e.length||!r?.enumerable||!(`value`in r))throw H}let n=Array.from({length:e.length},(n,r)=>{let i=Object.getOwnPropertyDescriptor(e,String(r));return i&&`value`in i?We(i.value,t):`h`});return`a${e.length}[${n.join(`,`)}]`}if(Object.getPrototypeOf(e)!==Object.prototype&&Object.getPrototypeOf(e)!==null)throw H;return`o{${Reflect.ownKeys(e).map(t=>{if(typeof t!=`string`)throw H;let n=Object.getOwnPropertyDescriptor(e,t);if(!n?.enumerable||!(`value`in n))throw H;return[t,n.value]}).sort(([e],[t])=>e.localeCompare(t)).map(([e,n])=>`${JSON.stringify(e)}:${We(n,t)}`).join(`,`)}}`}finally{t.delete(e)}}function Ge(e,t){return{...t,async:!1,interopDefault:t.interopDefault??!0,jsx:t.jsx??e.options.jsx,retainLines:t.retainLines??e.options.transformOptions?.retainLines}}function Ke(e){if(!(e&&Object.getPrototypeOf(e)===Object.prototype&&Reflect.ownKeys(e).length===0))return e}function qe(e){try{return We({babel:Ke(e.babel),interopDefault:e.interopDefault,jsx:e.jsx,retainLines:e.retainLines,ts:e.ts})}catch{return}}function Je(e,t,n,r){let i=b.byteLength(e)+b.byteLength(t)+b.byteLength(n);for(let e of r.dependencies)i+=b.byteLength(e);return i}function Ye(e,t){let n=I.get(e);n&&(L-=n.bytes,I.delete(e));let r=Je(e,t.source,t.code,t.facts);if(!(r>Pe))for(I.set(e,{...t,bytes:r}),L+=r;I.size>256||L>Pe;){let e=I.keys().next();if(e.done)break;let t=I.get(e.value);I.delete(e.value),t&&(L-=t.bytes)}}function Xe(e){return{...e,dependencies:Array.from(e.dependencies)}}function Ze(e,t,n,r,i,a){let o=t.filename?z(t.filename):n,s=Ge(e,t),c=qe(s),l=c===void 0?void 0:`${o}\0${c}`,u=l===void 0?void 0:I.get(l);if(l!==void 0&&u?.source===s.source)return I.delete(l),I.set(l,u),B(o,r,i)&&Ue(u.facts,o,n),{code:u.code,dependencies:u.facts.dependencies};let d=c===void 0?void 0:{filename:o,mode:c,source:s.source},f=d===void 0?void 0:a?.read(d);if(l!==void 0&&f){let e={...f.facts,dependencies:new Set(f.facts.dependencies)};return Ye(l,{code:f.code,facts:e,source:s.source}),B(o,r,i)&&Ue(e,o,n),{code:f.code,dependencies:e.dependencies}}let p={dependencies:new Set,hasDynamicImport:!1,hasNestedRequire:!1,hasNonLiteralRequire:!1,hasTopLevelAwait:!1,hasTopLevelRequire:!1},m=He(p),h=Error.prepareStackTrace,g=Error.stackTraceLimit;try{let t=e.transform({...s,babel:{...s.babel,plugins:[...Array.isArray(s.babel?.plugins)?s.babel.plugins:[],m]}});return l!==void 0&&Ye(l,{code:t,facts:p,source:s.source}),B(o,r,i)&&Ue(p,o,n),d!==void 0&&a?.write(d,{code:t,facts:Xe(p)}),{code:t,dependencies:p.dependencies}}finally{Error.prepareStackTrace=h,Error.stackTraceLimit=g}}const Qe=/\.[cm]?[jt]sx?$/;function $e(e,t,n){let r=z(f(n)?n:h(u(t),n));if(d(r))return[r];let i=Array.from(new Set([``,...e.options.extensions??[],`.json`])),a=[r,h(r,`index`)].flatMap(e=>i.map(t=>`${e}${t}`));return a.push(h(r,`package.json`)),a}function et(t,n,r){if(r.startsWith(`node:`))return[];try{let i=R(r)?t.esmResolve(r,{parentURL:ae(n).href,try:!0}):e(n).resolve(r);if(!i)return R(r)?$e(t,n,r):[];let a=i.startsWith(`file:`)?ie(i):i;return f(a)?[z(a)]:[]}catch{return R(r)?$e(t,n,r):[]}}async function tt(e,t,n,r,i,a,o){let s=[e],c;for(let l=0;l<s.length;l++){let u=s[l];if(!u||!Qe.test(d(u)))continue;let f;try{f=await x(u,`utf8`)}catch(e){if(e.code===`ENOENT`)continue;throw e}u===e&&(c=f);let{dependencies:p}=Ze(n,{source:f,filename:u,async:u===e,ts:/\.[cm]?tsx?$/.test(u)},e,r,i,o);for(let e of p)for(let n of et(t,u,e))!a.has(n)&&B(n,r,i)&&(a.add(n),s.push(n))}return c}async function nt(e,t){try{let{createPresetTransformDiskCache:n}=await import(`./presetTransformDiskCache-BNUNLsPo.js`);return n(e,import.meta.url,t)}catch{return}}function U(e,t){if(!e||typeof e!=`object`)return;let n=F.get(e)??[];F.set(e,Array.from(new Set([...n,...t])))}function W(e){return e&&typeof e==`object`?[...F.get(e)??[]]:[]}async function rt(t,n,r){let i=z(t),a=e(i),o=Object.create(null),s=new Set([i]),c=new Map,l={packageRoot:Re(i,c),fallbackRoot:u(i)},[{createJiti:d,transformer:f},p]=await Promise.all([Ne(),nt(i,r)]),m=d(i,{fsCache:!1,interopDefault:!0,moduleCache:!1,tryNative:!1,transform:e=>{let{code:t}=Ze(f,e,i,l,c,p);return{code:t}}}),h=()=>{let e=new Set;for(let t of Object.values(o))V(t,s,e,l,c);for(let t of s)V(a.cache[t],s,e,l,c)};try{let e=await tt(i,m,f,l,c,s,p)??await x(i,`utf8`),{evaluation:t}=await Ve(l.packageRoot??l.fallbackRoot,()=>{for(let e of s)delete a.cache[e];return m.evalModule(e,{async:!0,cache:o,filename:i,forceTranspile:!0})}),r=await t,u=r?.__esModule?r.default:r;if(u==null)throw Error(`@presets "${n}" has no default export (expected a Preset or preset factory)`);let d=typeof u==`function`?await u():u;return h(),{preset:d,sources:Array.from(s)}}catch(e){h();let t=Be(e);throw U(e,t&&B(t,l,c)?[...s,t]:Array.from(s)),e}}async function it(e){let t=await re(e),n=ae(e);return n.searchParams.set(`version`,`${t.mtimeMs}:${t.ctimeMs}:${t.size}:${t.ino}`),(await import(n.href)).default}async function at(e,t){let n=[],r=new Set,i={protectedSlotsByDirectory:new Map};for(let a of e){let e;try{e=Le(a,t);let o;if(R(a)){let t=await rt(e,a,i);for(let e of t.sources)r.add(e);n.push(t.preset);continue}if(r.add(z(e)),o=await it(e),o==null)throw Error(`@presets "${a}" has no default export (expected a Preset or preset factory)`);n.push(typeof o==`function`?await o():o)}catch(t){throw U(t,e!==void 0&&R(a)?[...r,z(e)]:r),t}}return{presets:n,sources:Array.from(r)}}async function ot(e,t){return(await at(e,t)).presets}function st(e){let t=e,n=/^url\(\s*([^)]*?)\s*\)$/i.exec(t);if(n)t=n[1];else if(/^url\(/i.test(t))return;let r=t[0];if(r===`"`||r===`'`){if(t.length<2||t[t.length-1]!==r)return;let e=t.slice(1,-1);return e.includes(r)?void 0:e}return n?t:void 0}function ct(e){return!(!e||e.startsWith(`//`)||/^[a-z][\w+.-]*:/i.test(e))}function lt(e){return e.split(`\\`).join(`/`)}function ut(e,t,n,r){if(!ct(e)||f(e)||!r&&!e.startsWith(`./`)&&!e.startsWith(`../`))return e;let i=lt(m(n,h(t,e)));return i.startsWith(`.`)?i:`./${i}`}function dt(e,t){if(t.length===0)return e;t.sort((e,t)=>e.start-t.start);let n=``,r=0;for(let i of t)n+=e.slice(r,i.start)+i.replacement,r=i.end;return n+e.slice(r)}function ft(e,t,n){if(t===n)return e;let r=[];for(let i of A(e)){if(i.terminator!==`;`||i.name!==`presets`&&i.name!==`source`)continue;let a=i.prelude[0];if(a!==`"`&&a!==`'`||i.prelude[i.prelude.length-1]!==a)continue;if(i.name===`presets`){let e=M(i.prelude).map(e=>{let r=ut(e,t,n,!1);if(r.includes(`,`))throw SyntaxError(`@presets: rebased module paths cannot contain commas; re-export from a path without commas`);return r});r.push({start:i.start,end:i.end,replacement:`@presets ${a}${e.join(`,`)}${a};`});continue}let o=i.prelude.slice(1,-1).trim(),s=i.name===`source`&&o.startsWith(`!`),c=s?o.slice(1):o,l=ut(c,t,n,i.name===`source`);if(l===c)continue;let u=e.slice(i.start,i.end).replace(i.prelude,`${a}${s?`!`:``}${l}${a}`);r.push({start:i.start,end:i.end,replacement:u})}return dt(e,r)}function pt(e,n,r,i,a,o,s,c){if(Oe(e,c),o>32){for(let t of A(e)){if(t.name!==`custom`||t.terminator!==`;`)continue;let n=E(e,t,c);n&&a.push(n)}return e}let l=[];for(let d of A(e)){if(d.name===`custom`&&d.terminator===`;`){let t=E(e,d,c);t&&a.push(t)}if(d.name!==`import`||d.terminator!==`;`)continue;let f=st(d.prelude);if(f===void 0||!ct(f))continue;let p=h(n,f);if(!s?.has(p))try{if(!t.statSync(p).isFile())continue}catch{continue}if(r.has(p)){l.push({start:d.start,end:d.end,replacement:``});continue}r.add(p),i.push(p);let m=u(p),g=pt(s?.get(p)??t.readFileSync(p,`utf8`),m,r,i,a,o+1,s,p);g=ft(g,m,n),l.push({start:d.start,end:d.end,replacement:g})}return dt(e,l)}function mt(e,t,n,r){let i=[],a=[],o=new Set(n?[h(t,n)]:[]);try{return{css:pt(e,t,o,i,a,0,r,n?h(t,n):void 0),files:i,aliases:a}}catch(e){throw U(e,i),e}}function G(e,t){return e!=null&&Object.hasOwn(e,t)?e[t]:void 0}function K(e,t){let n=G(e,t);return S.filter(e=>e!==`000`).every(e=>{let t=G(n,e);return typeof t==`string`&&!!t.trim()&&t!==`initial`})}function ht(e,t){let n=fe(t.theme),r=e.filter(e=>!e.alias),i=y(y({},t.theme),T(r,n).theme),a=new Set([...t.aliases??[],...e.flatMap(e=>e.alias?[e.alias.name]:[])]),o=new Set(t.aliases),s=new Set(t.physicalPalettes),c=new Set([...j,`focused`]),l=[],u=[],d=(e,t)=>u.push({...e,message:`@custom: ${t}`});for(let r of e){let e=r.alias;if(!e){l.push(r);continue}let{name:u,family:f}=e,p=y(y({},t.theme),T(l,n).theme);!c.has(u)&&(s.has(u)||o.has(u)||K(p.colors,u))&&d(e.nameRange,`${u} is already a palette or alias`),o.add(u),(u!==`focused`||f!==`primary`&&f!==`neutral`)&&(c.has(f)?d(e.familyRange,`role ${f} cannot be a target (only focused may follow primary or neutral)`):a.has(f)?d(e.familyRange,`${f} is an alias and cannot be a target`):(!K(i.colors,f)||Object.values(i.modes??{}).some(e=>!K(y(y({},i.colors??{}),G(e,`colors`)??{}),f)))&&d(e.familyRange,`${f} must provide all 12 steps in every mode`))}if(u.length)throw new Ee(u);return{...T(e,n),aliases:Object.freeze([...a])}}const q=e=>e.replace(/\\(.)/gs,`$1`);function gt(e,t,n,r=l){if(!e||e[0]===`!`&&e[1]!==`(`)return;let i=e.endsWith(`/`)?e.slice(0,-1):e;n&&!i.endsWith(`*`)&&(i+=`/**`);let a=r.parse(i).root||r.parse(q(i)).root,o=l.posix.normalize(i);(a.startsWith(`\\\\`)||a.startsWith(`//`))&&!o.startsWith(`//`)&&(o=`/${o}`);let s=se.scan(o,{parts:!0}).parts,c=s?.length?s:[o],u=[];for(let e of c.slice(0,-1)){if(le(e))break;u.push(q(e))}return{root:r.resolve(t,a||`.`,u.join(`/`)||`.`),literal:le(o)?void 0:r.resolve(t,q(o))}}function J(e,t=l){let n=[];for(let r=e;;){let e=t.dirname(r);if(e===r)return n;n.push({parent:e,name:t.basename(r)}),r=e}}function _t(e,t,n){return yt(e,t,n)}async function vt(e,t,n){let r={routes:[],failure:void 0};try{let i=await yt(e,t,n,r),a=[...r.routes];return r.failure?{status:`failed`,cause:r.failure.cause,routes:a}:{status:`complete`,files:i,routes:a}}catch(e){return{status:`failed`,cause:r.failure?.cause??e,routes:[...r.routes]}}}function Y(e,t){e&&!e.failure&&t&&t.code!==`ENOENT`&&t.code!==`ENOTDIR`&&t.code!==`ELOOP`&&(e.failure={cause:t})}async function yt(e,n,r,i){let a={...t,...r},o=l.resolve(n.cwd),s=new Set,c=new Set,u=new Map,d=new Map,f=new Map,p=e=>{let t=d.get(e);return t||(t=new Promise(t=>a.realpath(e,(n,r)=>{i&&!n&&e!==r&&f.set(e,{lexical:e,physical:r,admitted:new Set}),t(n?void 0:r)})),d.set(e,t)),t};for(let t of e){let e=gt(t,o,n.expandDirectories);e&&(e.literal?c.add(e.literal):s.add(e.root))}if(!s.size&&!c.size)return[];for(let e of[...s,...c])for(let{parent:t,name:n}of J(e))for(let e of new Set([t,await p(t)])){if(!e)continue;let t=u.get(e);t||u.set(e,t=new Set),t.add(n)}let m=new Set([...s,...[...s,...c].flatMap(e=>J(e).map(({parent:e})=>e))]),h=new Map,g=e=>{let t=h.get(e);return t||(t=new Promise(t=>a.lstat(e,(n,r)=>{if(n||!r.isSymbolicLink())return t(!1);a.stat(e,(e,n)=>t(!e&&n.isDirectory()))})),h.set(e,t)),t},_=new oe,v=e=>[...s,..._.getStore()?.targets??[]].some(t=>e===t||e.startsWith(t.endsWith(l.sep)?t:`${t}${l.sep}`)),ee=r?.realpathNative??t.realpath.native,y=new Map,te=e=>{let t=y.get(e);return t||(t=new Promise((t,n)=>a.readdir(e,{withFileTypes:!0},(e,r)=>e?n(e):t(r))),y.set(e,t)),t},ne=async(e,t)=>{let n=async()=>(await te(e)).filter(e=>t.has(e.name));if(t.size!==1)return n();let r=[...t][0],i=l.join(e,r);try{let t=await new Promise((e,t)=>a.lstat(i,(n,r)=>n?t(n):e(r)));if(!t.isDirectory()||t.isSymbolicLink()||!/^[\x20-\x7e]+$/.test(r)||!/[A-Za-z]/.test(r))return n();let o=r.replace(/[A-Za-z]/g,e=>e===e.toLowerCase()?e.toUpperCase():e.toLowerCase()),s=e=>new Promise((t,n)=>ee(e,(e,r)=>e?n(e):t(r))),c=await s(i),u=l.basename(c);if(!/^[\x20-\x7e]+$/.test(u)||u.toLowerCase()!==r.toLowerCase())return n();try{if(await s(l.join(e,o))!==c)return n()}catch(e){if(e.code!==`ENOENT`||u!==r)return n();u=r}return[{name:u,parentPath:e,isFile:()=>t.isFile(),isDirectory:()=>t.isDirectory(),isSymbolicLink:()=>t.isSymbolicLink(),isBlockDevice:()=>t.isBlockDevice(),isCharacterDevice:()=>t.isCharacterDevice(),isFIFO:()=>t.isFIFO(),isSocket:()=>t.isSocket()}]}catch{return n()}},b=(e,t,n)=>{let r=l.resolve(e);if(v(r)){let o=_.getStore()?.link;if(!o&&i){let e=[...f.keys()].filter(e=>r.startsWith(`${e}${l.sep}`)).sort((e,t)=>t.length-e.length)[0];e&&(o=f.get(e))}if(o&&i){let e=r===o.physical?r:l.resolve(o.physical,l.relative(o.lexical,r));[...o.admitted].some(t=>e===t||e.startsWith(`${t}${l.sep}`))||(o.admitted.add(e),i.routes.push({lexical:r===o.physical?o.lexical:r,physical:e,status:`entered`}))}return a.readdir(e,t,(e,t)=>{Y(i,e),n(e,t)})}let o=_.getStore()?.ancestor,c=o?.directory===r?o.children:u.get(r);if(!c?.size)return n(null,[]);ne(r,c).then(async e=>Promise.all(e.map(async e=>{let t=l.join(r,e.name);if(!e.isSymbolicLink()||s.has(t)||!u.has(t))return e;try{if(!await g(t))return e;let n=[...m].filter(e=>e.startsWith(`${t}${l.sep}`)),r=await p(t);return!r||!(await Promise.all(n.map(async e=>await g(e)?p(e):void 0))).some(e=>e?.startsWith(`${r}${l.sep}`))?e:{...e,isDirectory:()=>!0,isSymbolicLink:()=>!1,isFile:()=>!1,isBlockDevice:()=>e.isBlockDevice(),isCharacterDevice:()=>e.isCharacterDevice(),isFIFO:()=>e.isFIFO(),isSocket:()=>e.isSocket()}}catch{return e}}))).then(e=>n(null,e),e=>{Y(i,e),n(e,[])})},x=(e,t)=>{let n=_.getStore(),r=n?.targets??[],o=v(l.resolve(e)),s=u.get(l.resolve(e));a.realpath(e,(c,u)=>{if(Y(i,c),i&&c&&(c.code===`ENOENT`||c.code===`ENOTDIR`||c.code===`ELOOP`))return a.readlink(e,(n,r)=>{n||i.routes.push({lexical:l.resolve(e),physical:l.resolve(l.dirname(e),r),status:`unresolved`}),t(c,u)});_.run({targets:!c&&o?[...r,l.resolve(u)]:r,link:c?n?.link:{lexical:l.resolve(e),physical:l.resolve(u),admitted:new Set},ancestor:!c&&s?{directory:l.resolve(u),children:s}:n?.ancestor},t,c,u)})},re=((e,t)=>a.stat(e,(e,n)=>{Y(i,e),t(e,n)}));try{return await ce(e,{...n,absolute:!0,fs:{...a,stat:re,readdir:b,realpath:x}})}finally{_.disable()}}function bt(e,t){return _t(e,t)}const X=Symbol.for(`@teacss/config/source-declarations`);function Z(e){return e[X]}function xt(e){return Z(e)?.consumed}function St(e,t){return Object.defineProperty(e,X,{value:{consumed:t,attempted:t,recovered:!1},configurable:!0}),e}function Q(e,t){let n=Z(t);return n&&Object.defineProperty(e,X,{value:n,configurable:!0}),e}function Ct(e,t,n){return Object.defineProperty(e,X,{value:{consumed:t&&xt(t),attempted:n,recovered:t!==void 0},configurable:!0}),e}function wt(e,t){let n=Z(e),r={consumed:t,attempted:n?.attempted,recovered:n?.recovered??!1};return Object.defineProperty(e,X,{value:r,configurable:!0}),r}function $(e){return JSON.stringify([e.base,e.patterns,e.ignore,e.inlined])}function Tt(e){let t=new Map;for(let n of[e?.consumed,e?.attempted])n&&t.set($(n),n);return[...t.values()]}function Et(e){return[...new Set([e?.consumed,e?.attempted].flatMap(e=>e?.status===`read`?e.members.map(e=>e.path):[]))]}function Dt(e){return[...Tt(e).flatMap(({patterns:e,base:t})=>Nt(e,t)),...Et(e).map(e=>({kind:`exact`,path:e})),...[e?.consumed,e?.attempted].flatMap(e=>[...e?.status===`failed`&&e.operation===`read`&&e.path?[{kind:`exact`,path:e.path}]:[],...(e?.routes??[]).map(e=>({kind:e.status===`entered`?`tree`:`exact`,path:e.physical}))])]}function Ot(e,t,n,r=[]){return Object.freeze({base:e,patterns:Object.freeze([...t]),ignore:Object.freeze([...r]),inlined:Object.freeze([...n])})}function kt(e,t,n,r,i=[],a=[]){return{...Ot(e,t,n,i),status:`read`,members:r,routes:a,signature:JSON.stringify([e,t,i,n,`read`,r,a])}}async function At(e,t){let n=[],r=()=>n.sort((e,t)=>e.lexical.localeCompare(t.lexical)||e.physical.localeCompare(t.physical)||e.status.localeCompare(t.status)),i=`enumerate`,o;try{let s=await vt(e.patterns,{cwd:e.base,ignore:e.ignore,expandDirectories:!1});if(n.push(...s.routes),s.status===`failed`)throw s.cause;let c=s.files.filter(t=>t.endsWith(`.css`)&&!e.inlined.includes(t)).sort();i=`read`;let l=c.map(e=>(o=e,{path:e,contents:t?.get(e)??a(e,`utf8`)}));return kt(e.base,e.patterns,e.inlined,l,e.ignore,r())}catch(t){let a=t,s=[typeof t,a?.name,a?.message??String(t),a?.code];return{...e,status:`failed`,operation:i,path:o,cause:t,routes:r(),signature:JSON.stringify([$(e),`failed`,i,o,s,n])}}}async function jt(e,t=!1,n){let r=Tt(e),i=await Promise.all(r.map(r=>{if(t){if(r===e?.attempted)return r;let t=n?.attempts.find(e=>$(e)===$(r));if(t)return t}return At(r)}));return{attempts:i,signature:JSON.stringify(i.map(e=>e.signature))}}function Mt(e,t,n){let r=!1,i,a=Promise.resolve(),o;function s(){o=setTimeout(()=>{a=(async()=>{let n=e(),a=i??await jt(n,!0),o=await jt(n);r||n!==e()||(i=o,o.signature!==a.signature&&await t(o))})().catch(async e=>{r||await n(e)}).finally(()=>{r||s()})},500)}function c(){r=!0,clearTimeout(o)}return s(),{retire:c,async close(){c(),await a}}}function Nt(e,t,n=!1){return e.flatMap(e=>{let r=gt(e,t,n);return r?[{kind:r.literal?`exact`:`tree`,path:r.literal??r.root}]:[]})}function Pt(e){let t=new Map,n=[],r=new Map,a=e=>{if(r.has(e))return r.get(e);let t;try{let n=c(e);n.isDirectory()&&(t=n)}catch(e){let t=e.code;if(t===`EACCES`)n.push(e);else if(t!==`ENOENT`&&t!==`ENOTDIR`&&t!==`ELOOP`)throw e}return r.set(e,t),t},s=(e,n,r)=>{let i=a(e);if(!i)return;let o=`${i.dev}:${i.ino}`,s=`${n}:${o}`,c=t.get(s);t.set(s,{directory:c?.directory??e,recursive:n,identity:o,children:r?[...new Set([...c?.children??[],r])].sort():[]})},l=e.map(e=>({path:e.path,links:new Set})),u=new Set;for(let t of e)t.kind===`tree`&&s(t.path,!0);for(let e of l){if(u.has(e.path))continue;u.add(e.path);let t=J(e.path);for(let{parent:e,name:n}of t)s(e,!1,n);for(let{parent:r,name:a}of t.reverse()){let t=p(r,a);try{let n=i(t);if(!n.isSymbolicLink())continue;let a=`${n.dev}:${n.ino}`;if(e.links.has(a))break;l.push({path:h(r,o(t),m(t,e.path)),links:new Set([...e.links,a])});break}catch(e){let t=e.code;if(t===`EACCES`){n.push(e);break}if(t!==`ENOENT`&&t!==`ENOTDIR`&&t!==`ELOOP`)throw e}}}return{plans:[...t.values()],permissionErrors:n}}function Ft(e,t){if(e.recursive||t===null)return!0;let n=t.toString().split(g)[0].normalize(`NFC`).toLowerCase();return e.children.some(e=>e.normalize(`NFC`).toLowerCase()===n)}function It(e){let t=e.members.map(e=>e.path),n=[],r=[];for(let{contents:t}of e.members){if(!t.includes(`@shortcut`)&&!t.includes(`@safelist`))continue;let e=N(t);n.push(...e.shortcuts),r.push(...e.safelist)}return{shortcuts:n,safelist:r,files:t,snapshot:e}}async function Lt(e,t,n,r,i){let a=mt(e,t,n,r),o=N(a.css),s=0;for(let e of o.custom)e.alias&&=a.aliases[s++];let c=At(Ot(t,o.sources.filter(e=>!e.exclude).map(e=>e.glob),a.files,o.sources.filter(e=>e.exclude).map(e=>e.glob)),r).then(e=>{if(i.attempt=e,e.status===`failed`)throw e.cause;return It(e)}),[l,u]=await Promise.all([o.presets.length?at(o.presets,t):{presets:[],sources:[]},c]).catch(async e=>{throw await c.catch(()=>void 0),U(e,a.files),e}),d=l.presets,f={},p=[],m=[],h=Object.freeze(Object.fromEntries(Object.entries(o.rolePalettes??{}).map(([e,t])=>[e,Object.freeze([...t])]))),g={name:`@teacss/config/role-palettes`,configResolved(e){Object.defineProperty(e,Symbol.for(`@teacss/config/role-palettes`),{value:h,configurable:!0}),Object.defineProperty(e,Symbol.for(`@teacss/config/color-aliases`),{value:m,configurable:!0})}};await te({presets:d,configResolved(e){let t=e;if({theme:f,unknown:p,aliases:m}=ht(o.custom,{theme:e.theme,physicalPalettes:t[Symbol.for(`@teacss/preset-standard/physical-palettes`)],aliases:t[Symbol.for(`@teacss/config/color-aliases`)]}),o.rolePalettes&&!e.presets.some(e=>e.name===`@teacss/preset-standard`))throw TypeError(`Role palette directives require an explicitly enabled Standard preset`);e.theme=y(e.theme,f),(o.rolePalettes||m.length)&&g.configResolved?.(e)}}).catch(e=>{throw U(e,[...a.files,...u.files,...l.sources]),e});let _=[...o.sources.filter(e=>!e.exclude).map(e=>e.glob),...o.sources.filter(e=>e.exclude).map(e=>`!${e.glob}`)],v=[...u.shortcuts,...o.shortcuts],b=Object.fromEntries(v.map(({name:e,expansion:t})=>[e,t])),x=[...new Set([...u.safelist,...o.safelist].flatMap(e=>ne(ee(e))))];return St({config:{presets:o.rolePalettes||m.length?[...d,g]:d,theme:f,...o.sources.length?{content:{filesystem:_}}:{},...v.length?{shortcuts:b}:{},...x.length?{safelist:x}:{}},unknown:p,hasTeacss:a.files.length===0?o.hasTeacss:N(e).hasTeacss,sources:[...a.files,...u.files,...l.sources]},u.snapshot)}async function Rt(e,t,n,r){let i={};try{return{status:`resolved`,result:await Lt(e,t,n,r,i)}}catch(e){return{status:`failed`,cause:e,attempt:i.attempt}}}const zt=Object.freeze([`package.json`,`index.css`,`src/index.css`]),[Bt,...Vt]=zt;function Ht(e,t){let n={...e};for(let e of Reflect.ownKeys(t)){if(!Object.getOwnPropertyDescriptor(t,e)?.enumerable)continue;let r=Reflect.get(t,e);r!==void 0&&Object.defineProperty(n,e,{value:r,configurable:!0,enumerable:!0,writable:!0})}return n}function Ut(e){try{let t=n.readFileSync(e,`utf8`);return t.includes(`@teacss`)?A(t).some(e=>e.name===`teacss`&&e.prelude===``&&e.terminator!==`block`):!1}catch(e){if(e.code===`ENOENT`)return!1;throw e}}function Wt(e){try{let t=JSON.parse(n.readFileSync(p(e,Bt),`utf8`))?.teacss?.entry;return typeof t==`string`?t:void 0}catch(e){if(e.code===`ENOENT`)return;throw e}}function Gt(e){let t=Wt(e);if(t){let r=h(e,t);if(n.existsSync(r)&&n.statSync(r).isFile())return r}for(let t of Vt){let r=p(e,t);if(n.existsSync(r)&&n.statSync(r).isFile()&&Ut(r))return r}}async function Kt(e,t,r,i){if(typeof t!=`string`)return{config:Ht(r,t),sources:[]};let a=h(e,t),o=n.existsSync(a)&&n.statSync(a).isFile()?a:Gt(a);if(!o)return{config:{...r},sources:[]};let s;try{s=n.readFileSync(o,`utf8`)}catch(e){throw U(e,[o]),e}let c=await Rt(s,u(o),o);if(c.status===`failed`)throw i.attempt=c.attempt,U(c.cause,[o]),c.cause;let l=c.result,{config:d}=l,f=Ht(r,d);return d.presets?.length||(r.presets?.length?f.presets=r.presets:v.warn(`[@teacss/config] "${o}" declares no @presets — no utilities will be generated. Add one, e.g. \`@presets "standard";\``)),Q({config:f,sources:Array.from(new Set([o,...l.sources]))},l)}async function qt(e,t,n){let r={};try{return{status:`resolved`,result:await Kt(e,t,n,r)}}catch(e){return{status:`failed`,cause:e,attempt:r.attempt}}}async function Jt(e=_.cwd(),t=e,n={}){let r=await qt(e,t,n);if(r.status===`failed`)throw r.cause;return r.result}function Yt(e){let t=e instanceof Error?`${e.name}:${e.message}`:`${typeof e}:${String(e)}`,r=Array.from(new Set(W(e))).sort().map(e=>{try{let t=n.statSync(e);return`${e}:${t.mtimeMs}:${t.ctimeMs}:${t.size}:${t.ino}`}catch(t){let n=t.code;return`${e}:${n===`ENOENT`?`missing`:`unreadable:${n??String(t)}`}`}});return JSON.stringify([t,r])}function Xt(e=!1){let t=new Map,n=new WeakMap,r=new WeakMap,i=(i=_.cwd(),a=i,o={})=>{let s;if(typeof a==`string`){let e=h(i,a);s=t.get(e),s||t.set(e,s={version:0})}else typeof a==`object`&&a&&(s=n.get(a),s||n.set(a,s={version:0}));let c=s??{version:0},l=++c.version,u=qt(i,a,o).then(async t=>{if(t.status===`resolved`)return e||r.set(t.result,{slot:c,version:l}),c.version===l&&(c.reportedFailure=void 0,e&&(c.accepted=t.result)),Q(u,t.result),t.result;if(c.version!==l)for(;;){let e=c.version,t=c.latest;try{let n=await t;if(c.version!==e)continue;return Q(u,t),n}catch(n){if(c.version!==e)continue;throw Q(u,t),n}}let n=c.accepted;if(!n)throw Ct(u,void 0,t.attempt),t.cause;let i=Yt(t.cause);c.reportedFailure!==i&&(v.error(`[@teacss/config] Error resolving config from the CSS entry:`,t.cause),c.reportedFailure=i);let a=Array.from(new Set([...n.sources,...W(t.cause)])),o=Ct({...n,sources:a},n,t.attempt);return Q(u,o),o});return c.latest=u,u};return i.accept=(e,t=e)=>{let n=r.get(e);n&&n.version===n.slot.version&&(r.delete(e),n.slot.accepted=Q({...t,sources:[...t.sources]},t))},i}export{j as A,T as B,wt as C,ke as D,ot as E,Te as F,S as H,ye as I,A as L,De as M,M as N,N as O,be as P,pe as R,Nt as S,W as T,fe as V,kt as _,Rt as a,xt as b,Mt as c,jt as d,Ct as f,Et as g,Tt as h,Jt as i,Oe as j,Ee as k,At as l,Ot as m,zt as n,St as o,bt as p,Gt as r,Q as s,Xt as t,Pt as u,Z as v,ht as w,Ft as x,Dt as y,me as z};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@teacss/config",
3
- "version": "0.7.2",
3
+ "version": "0.8.1",
4
4
  "description": "TeaCSS config loader — discovers the CSS entry and resolves its directives into a config (no teacss.config file).",
5
5
  "homepage": "https://css.teasim.com",
6
6
  "funding": "https://github.com/sponsors/billgo",
@@ -10,6 +10,7 @@
10
10
  "type": "module",
11
11
  "exports": {
12
12
  ".": "./dist/index.js",
13
+ "./internal/source-scan": "./dist/internal/source-scan.js",
13
14
  "./package.json": "./package.json"
14
15
  },
15
16
  "types": "./dist/index.d.ts",
@@ -22,11 +23,15 @@
22
23
  "dev": "tsdown --watch"
23
24
  },
24
25
  "dependencies": {
25
- "@teacss/core": "0.7.2",
26
+ "@teacss/core": "0.8.1",
26
27
  "consola": "^3.4.2",
27
28
  "jiti": "^2.7.0",
29
+ "picomatch": "4.0.7",
28
30
  "tinyglobby": "^0.2.17"
29
31
  },
32
+ "devDependencies": {
33
+ "@types/picomatch": "^4.0.2"
34
+ },
30
35
  "engines": {
31
36
  "node": ">=22.12.0"
32
37
  },