stoop 0.4.1 → 0.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -61,10 +61,15 @@ const Button = styled("button", {
61
61
 
62
62
  ## Documentation
63
63
 
64
- - **[GUIDE.md](./docs/GUIDE.md)** - Step-by-step setup and usage guide
65
- - **[API.md](./docs/API.md)** - Complete API reference
66
- - **[ARCHITECTURE.md](./docs/ARCHITECTURE.md)** - Internal implementation details
67
- - **[TESTING.md](./docs/TESTING.md)** - Testing guide and test suite documentation
64
+ 📚 **[Full Documentation →](https://stoop.dolmios.com)**
65
+
66
+ - [Installation](https://stoop.dolmios.com/installation)
67
+ - [Theme Setup](https://stoop.dolmios.com/theme-setup)
68
+ - [Creating Components](https://stoop.dolmios.com/creating-components)
69
+ - [SSR Guide](https://stoop.dolmios.com/ssr)
70
+ - [API Reference](https://stoop.dolmios.com/api)
71
+
72
+ For internal architecture details, see [ARCHITECTURE.md](./ARCHITECTURE.md) (developer-only).
68
73
 
69
74
  ## API Overview
70
75
 
@@ -89,10 +94,8 @@ Use `$` prefix for theme tokens. Shorthand `$token` uses property-aware resoluti
89
94
  Variants create component variations via props:
90
95
 
91
96
  ```tsx
92
- const Button = styled(
93
- "button",
94
- {},
95
- {
97
+ const Button = styled("button", {
98
+ variants: {
96
99
  variant: {
97
100
  primary: { backgroundColor: "$primary" },
98
101
  secondary: { backgroundColor: "$secondary" },
@@ -102,7 +105,7 @@ const Button = styled(
102
105
  large: { padding: "$large" },
103
106
  },
104
107
  },
105
- );
108
+ });
106
109
 
107
110
  <Button variant="primary" size="small" />;
108
111
  ```
@@ -32,3 +32,4 @@ export declare function createCSSFunction(defaultTheme: Theme, prefix?: string,
32
32
  * @returns Function that accepts keyframes objects and returns animation names
33
33
  */
34
34
  export declare function createKeyframesFunction(prefix?: string, theme?: Theme, themeMap?: Record<string, ThemeScale>): (keyframes: Record<string, CSS>) => string;
35
+ export declare function createGlobalCSSFunction(defaultTheme: Theme, prefix?: string, media?: Record<string, string>, utils?: Record<string, UtilityFunction>, themeMap?: Record<string, ThemeScale>): (styles: CSS) => () => void;
@@ -4,7 +4,7 @@
4
4
  * and CSS prop merging. Supports component targeting via selector references.
5
5
  */
6
6
  import { forwardRef, type Context } from "react";
7
- import type { CSS, StyledComponentProps, StyledComponentRef, StylableElement, Theme, ThemeContextValue, ThemeScale, UtilityFunction, Variants } from "../types";
7
+ import type { CSS, CSSWithVariants, StyledComponentProps, StyledComponentRef, StylableElement, Theme, ThemeContextValue, ThemeScale, UtilityFunction } from "../types";
8
8
  /**
9
9
  * Creates a styled component reference for selector targeting.
10
10
  *
@@ -12,11 +12,6 @@ import type { CSS, StyledComponentProps, StyledComponentRef, StylableElement, Th
12
12
  * @returns StyledComponentRef for use in CSS selectors
13
13
  */
14
14
  export declare function createStyledComponentRef(className: string): StyledComponentRef;
15
- type CSSWithVariants = {
16
- [K in keyof CSS]: CSS[K];
17
- } & {
18
- variants: Variants;
19
- };
20
15
  /**
21
16
  * Creates a styled component factory function.
22
17
  * Supports polymorphic components, variants, theme awareness, and CSS prop merging.
@@ -33,8 +28,7 @@ export declare function createStyledFunction(defaultTheme: Theme, prefix?: strin
33
28
  <DefaultElement extends StylableElement, BaseStyles extends CSSWithVariants>(defaultElement: DefaultElement, baseStyles: BaseStyles): ReturnType<typeof forwardRef<unknown, StyledComponentProps<DefaultElement, BaseStyles["variants"]>>> & {
34
29
  selector: StyledComponentRef;
35
30
  };
36
- <DefaultElement extends StylableElement, VariantsConfig extends Variants = {}>(defaultElement: DefaultElement, baseStyles?: CSS, variants?: VariantsConfig): ReturnType<typeof forwardRef<unknown, StyledComponentProps<DefaultElement, VariantsConfig>>> & {
31
+ <DefaultElement extends StylableElement>(defaultElement: DefaultElement, baseStyles?: CSS): ReturnType<typeof forwardRef<unknown, StyledComponentProps<DefaultElement, {}>>> & {
37
32
  selector: StyledComponentRef;
38
33
  };
39
34
  };
40
- export {};
@@ -17,13 +17,13 @@ import type { ProviderProps, Theme, ThemeContextValue, ThemeManagementContextVal
17
17
  *
18
18
  * @remarks
19
19
  * To prevent FOUC (Flash of Unstyled Content) when a user has a non-default theme stored,
20
- * call `preloadTheme()` from your stoop instance in a script tag before React hydrates:
20
+ * call `preloadTheme()` from your stoop instance in a script tag before React hydrates.
21
+ * Note: `preloadTheme()` takes no parameters and always preloads all configured themes.
21
22
  *
22
23
  * ```html
23
24
  * <script>
24
- * // Read theme from storage and preload before React renders
25
- * const storedTheme = localStorage.getItem('stoop-theme') || 'light';
26
- * stoopInstance.preloadTheme(storedTheme);
25
+ * // Preload all themes before React renders
26
+ * stoopInstance.preloadTheme();
27
27
  * </script>
28
28
  * ```
29
29
  */
@@ -17,7 +17,6 @@ export declare const classNameCache: LRUCache<string, string>;
17
17
  export declare const cssStringCache: LRUCache<string, string>;
18
18
  /**
19
19
  * Checks if a CSS string has been injected.
20
- * Uses a Set for O(1) lookup.
21
20
  *
22
21
  * @param css - CSS string to check
23
22
  * @returns True if CSS has been injected
@@ -0,0 +1,19 @@
1
+ /**
2
+ * CSS property name stringification utilities.
3
+ * Handles conversion of camelCase CSS property names to kebab-case,
4
+ * including proper vendor prefix detection and normalization.
5
+ */
6
+ /**
7
+ * Sanitizes CSS property names to prevent injection attacks.
8
+ * Handles vendor prefixes, camelCase conversion, and edge cases.
9
+ *
10
+ * Vendor prefix patterns handled:
11
+ * - Moz* → -moz-*
12
+ * - Webkit* → -webkit-*
13
+ * - ms* → -ms-*
14
+ * - O* → -o-*
15
+ *
16
+ * @param propertyName - Property name to sanitize
17
+ * @returns Sanitized property name
18
+ */
19
+ export declare function sanitizeCSSPropertyName(propertyName: string): string;
@@ -1,8 +1,6 @@
1
1
  /**
2
2
  * Theme variable management.
3
- * Updates CSS custom properties when theme changes.
4
- * Ensures CSS variables are injected and kept in sync with theme updates.
5
- * Automatically merges themes with the default theme when applied.
3
+ * Updates CSS custom properties when theme changes and merges themes with the default theme.
6
4
  */
7
5
  import type { Theme } from "../types";
8
6
  /**
@@ -21,9 +19,7 @@ export declare function registerDefaultTheme(theme: Theme, prefix?: string): voi
21
19
  */
22
20
  export declare function getDefaultTheme(prefix?: string): Theme | null;
23
21
  /**
24
- * Core theme merging logic.
25
22
  * Merges source theme into target theme, handling nested objects.
26
- * Shared implementation used by both mergeWithDefaultTheme and createTheme.
27
23
  *
28
24
  * @param target - Target theme to merge into
29
25
  * @param source - Source theme to merge from
@@ -31,9 +27,7 @@ export declare function getDefaultTheme(prefix?: string): Theme | null;
31
27
  */
32
28
  export declare function mergeThemes(target: Theme, source: Theme | Partial<Theme>): Theme;
33
29
  /**
34
- * Merges a theme with the default theme if it's not already the default theme.
35
- * This ensures all themes extend the default theme, keeping all original properties.
36
- * Uses caching to avoid repeated merging of the same theme objects.
30
+ * Merges a theme with the default theme, ensuring all themes extend the default theme.
37
31
  *
38
32
  * @param theme - Theme to merge
39
33
  * @param prefix - Optional prefix for theme scoping
@@ -42,9 +36,7 @@ export declare function mergeThemes(target: Theme, source: Theme | Partial<Theme
42
36
  export declare function mergeWithDefaultTheme(theme: Theme, prefix?: string): Theme;
43
37
  /**
44
38
  * Injects CSS variables for all themes using attribute selectors.
45
- * This allows all themes to be available simultaneously, with theme switching
46
- * handled by changing the data-theme attribute. This prevents layout shifts
47
- * and eliminates the need to replace CSS variables on theme change.
39
+ * All themes are available simultaneously, with theme switching handled by changing the data-theme attribute.
48
40
  *
49
41
  * @param themes - Map of theme names to theme objects
50
42
  * @param prefix - Optional prefix for CSS variable names
@@ -4,24 +4,22 @@
4
4
  * React types are only imported conditionally when creating client instances.
5
5
  */
6
6
  import type { CSS, StoopConfig, Theme, ThemeScale } from "./types";
7
- import { createCSSFunction, createKeyframesFunction } from "./api/core-api";
8
- import { createGlobalCSSFunction } from "./api/global-css";
7
+ import { createCSSFunction, createKeyframesFunction, createGlobalCSSFunction } from "./api/core-api";
9
8
  /**
10
9
  * Shared implementation for creating Stoop instances.
11
10
  * Handles common setup logic for both client and server instances.
12
- * Exported for use in SSR entry point.
13
11
  */
14
12
  export declare function createStoopBase(config: StoopConfig): {
15
13
  config: StoopConfig;
16
14
  createTheme: (overrides?: Partial<Theme>) => Theme;
17
15
  css: ReturnType<typeof createCSSFunction>;
18
- getCssText: (theme?: string | Theme) => string;
16
+ getCssText: () => string;
19
17
  globalCss: ReturnType<typeof createGlobalCSSFunction>;
20
18
  globalCssConfig: StoopConfig["globalCss"];
21
19
  keyframes: ReturnType<typeof createKeyframesFunction>;
22
20
  media: StoopConfig["media"];
23
21
  mergedThemeMap: Record<string, ThemeScale>;
24
- preloadTheme: (theme: string | Theme) => void;
22
+ preloadTheme: () => void;
25
23
  sanitizedPrefix: string;
26
24
  theme: Theme;
27
25
  utils: StoopConfig["utils"];
@@ -2,8 +2,6 @@
2
2
  * SSR-safe entry point for Stoop.
3
3
  * Exports only server-safe APIs that don't require React.
4
4
  * Use this import in Server Components: import { createStoop } from "stoop/ssr"
5
- *
6
- * This file does NOT import React types or create React components.
7
5
  */
8
6
  import type { StoopConfig, StoopServerInstance } from "./types";
9
7
  export type { CSS, Theme, StoopConfig, StoopServerInstance, UtilityFunction, ThemeScale, DefaultTheme, } from "./types";
@@ -1,16 +1,16 @@
1
- var J0=Object.freeze({}),j=1e4,GJ=5000,QJ=10,FJ=500,P=1000;var c=["colors","opacities","space","radii","sizes","fonts","fontWeights","fontSizes","lineHeights","letterSpacings","shadows","zIndices","transitions"],N={accentColor:"colors",animation:"transitions",animationDelay:"transitions",animationDuration:"transitions",animationTimingFunction:"transitions",backdropFilter:"shadows",background:"colors",backgroundColor:"colors",blockSize:"sizes",border:"colors",borderBlockColor:"colors",borderBlockEndColor:"colors",borderBlockStartColor:"colors",borderBottomColor:"colors",borderBottomLeftRadius:"radii",borderBottomRightRadius:"radii",borderColor:"colors",borderEndEndRadius:"radii",borderEndStartRadius:"radii",borderInlineColor:"colors",borderInlineEndColor:"colors",borderInlineStartColor:"colors",borderLeftColor:"colors",borderRadius:"radii",borderRightColor:"colors",borderStartEndRadius:"radii",borderStartStartRadius:"radii",borderTopColor:"colors",borderTopLeftRadius:"radii",borderTopRightRadius:"radii",bottom:"space",boxShadow:"shadows",caretColor:"colors",color:"colors",columnGap:"space",columnRuleColor:"colors",fill:"colors",filter:"shadows",flexBasis:"sizes",floodColor:"colors",font:"fontSizes",fontFamily:"fonts",fontSize:"fontSizes",fontWeight:"fontWeights",gap:"space",gridColumnGap:"space",gridGap:"space",gridRowGap:"space",height:"sizes",inlineSize:"sizes",inset:"space",insetBlock:"space",insetBlockEnd:"space",insetBlockStart:"space",insetInline:"space",insetInlineEnd:"space",insetInlineStart:"space",left:"space",letterSpacing:"letterSpacings",lightingColor:"colors",lineHeight:"lineHeights",margin:"space",marginBlock:"space",marginBlockEnd:"space",marginBlockStart:"space",marginBottom:"space",marginInline:"space",marginInlineEnd:"space",marginInlineStart:"space",marginLeft:"space",marginRight:"space",marginTop:"space",maxBlockSize:"sizes",maxHeight:"sizes",maxInlineSize:"sizes",maxWidth:"sizes",minBlockSize:"sizes",minHeight:"sizes",minInlineSize:"sizes",minWidth:"sizes",opacity:"opacities",outline:"colors",outlineColor:"colors",padding:"space",paddingBlock:"space",paddingBlockEnd:"space",paddingBlockStart:"space",paddingBottom:"space",paddingInline:"space",paddingInlineEnd:"space",paddingInlineStart:"space",paddingLeft:"space",paddingRight:"space",paddingTop:"space",right:"space",rowGap:"space",size:"sizes",stopColor:"colors",stroke:"colors",textDecorationColor:"colors",textEmphasisColor:"colors",textShadow:"shadows",top:"space",transition:"transitions",transitionDelay:"transitions",transitionDuration:"transitions",transitionProperty:"transitions",transitionTimingFunction:"transitions",width:"sizes",zIndex:"zIndices"},ZJ=Symbol.for("stoop.component");class L extends Map{maxSize;constructor(J){super();this.maxSize=J}get(J){let $=super.get(J);if($!==void 0)super.delete(J),super.set(J,$);return $}set(J,$){if(super.has(J))super.delete(J);else if(this.size>=this.maxSize){let Y=this.keys().next().value;if(Y!==void 0)super.delete(Y)}return super.set(J,$),this}}var WJ=new L(GJ),n=new L(j);function K(){return typeof window!=="undefined"&&typeof document!=="undefined"&&typeof window.document==="object"&&typeof document.createElement==="function"}function g(){return typeof process!=="undefined"&&process.env?.NODE_ENV==="production"}function v(J){return typeof J==="object"&&J!==null}function p(J){return typeof J==="object"&&J!==null&&"__isStoopStyled"in J&&"__stoopClassName"in J&&J.__isStoopStyled===!0}function m(J){return v(J)&&!p(J)}function o(J){return typeof J==="object"&&J!==null&&!Array.isArray(J)}function x(J){if(!J||typeof J!=="object"||Array.isArray(J))throw new Error("[Stoop] Theme must be a non-null object");if(g())return J;let $=J,Y=[];for(let q in $){if(q==="media")continue;if(!c.includes(q))Y.push(q)}if(Y.length>0){let q=`[Stoop] Theme contains invalid scales: ${Y.join(", ")}. Only these scales are allowed: ${c.join(", ")}`;throw new Error(q)}return J}function z(J,$){if(!$||!J||typeof J!=="object")return J;let Y={},q=Object.keys($);for(let X in J){let F=J[X];if(q.includes(X)&&$[X])try{let Q=$[X](F);if(Q&&typeof Q==="object")for(let Z in Q)Y[Z]=Q[Z]}catch{Y[X]=F}else if(v(F))Y[X]=z(F,$);else Y[X]=F}return Y}var l=null,DJ=new L(P),wJ=new L(P),Z0=new L(P),HJ=new L(P);function b(J){let q=2166136261;for(let X=0;X<J.length;X++)q^=J.charCodeAt(X),q=Math.imul(q,16777619);return q^=J.length,(q>>>0).toString(36)}function T(J){try{return b(JSON.stringify(J))}catch{return b(String(J))}}function cJ(J){return J.replace(/([A-Z])/g,"-$1").toLowerCase()}function UJ(J,$=!1){let q=String(J).replace(/\\/g,"\\\\").replace(/"/g,"\\\"").replace(/'/g,"\\'").replace(/;/g,"\\;").replace(/\n/g,"\\A ").replace(/\r/g,"").replace(/\f/g,"\\C ");if($)q=q.replace(/\{/g,"\\7B ").replace(/\}/g,"\\7D ");return q}function BJ(J){return UJ(J,!1)}function I(J){let $=DJ.get(J);if($!==void 0)return $;let Y=J.replace(/[^a-zA-Z0-9\s\-_>+~:.#[\]&@()]/g,""),q=!Y.trim()||/^[>+~:.#[\]&@()\s]+$/.test(Y)?"":Y;return DJ.set(J,q),q}function R(J){let $=HJ.get(J);if($!==void 0)return $;let X=J.replace(/[^a-zA-Z0-9-_]/g,"-").replace(/^[\d-]+/,"").replace(/^-+/,"")||"invalid";return HJ.set(J,X),X}function LJ(J){return UJ(J,!0)}function B(J){if(!J)return"stoop";return J.replace(/[^a-zA-Z0-9-_]/g,"").replace(/^[\d-]+/,"").replace(/^-+/,"")||"stoop"}function _J(J){if(!J||typeof J!=="string")return"";let $=J.replace(/[^a-zA-Z0-9\s():,<>=\-@]/g,"");if(!$.trim()||!/[a-zA-Z]/.test($))return"";return $}function C(J){if(!J||typeof J!=="string")return"";let $=wJ.get(J);if($!==void 0)return $;let X=cJ(J).replace(/[^a-zA-Z0-9-]/g,"").replace(/^-+|-+$/g,"").replace(/^\d+/,"")||"";return wJ.set(J,X),X}function AJ(J){if(!J||typeof J!=="string")return!1;if(J==="from"||J==="to")return!0;if(/^\d+(\.\d+)?%$/.test(J)){let Y=parseFloat(J);return Y>=0&&Y<=100}return!1}function KJ(J=""){if(!l){let Y=":root".replace(/[.*+?^${}()|[\]\\]/g,"\\$&");l=new RegExp(`${Y}\\s*\\{[\\s\\S]*\\}`)}return l}function nJ(J){if(J.includes("Color")||J==="fill"||J==="stroke"||J==="accentColor"||J==="caretColor"||J==="border"||J==="outline"||J.includes("background")&&!J.includes("Size")&&!J.includes("Image"))return"colors";if(/^(margin|padding|gap|inset|top|right|bottom|left|rowGap|columnGap|gridGap|gridRowGap|gridColumnGap)/.test(J)||J.includes("Block")||J.includes("Inline"))return"space";if(/(width|height|size|basis)$/i.test(J)||J.includes("BlockSize")||J.includes("InlineSize"))return"sizes";if(J==="fontSize"||J==="font"&&!J.includes("Family"))return"fontSizes";if(J==="fontFamily"||J.includes("FontFamily"))return"fonts";if(J==="fontWeight"||J.includes("FontWeight"))return"fontWeights";if(J==="letterSpacing"||J.includes("LetterSpacing"))return"letterSpacings";if(J.includes("Radius")||J.includes("radius"))return"radii";if(J.includes("Shadow")||J.includes("shadow")||J==="filter"||J==="backdropFilter")return"shadows";if(J==="zIndex"||J.includes("ZIndex")||J.includes("z-index"))return"zIndices";if(J==="opacity"||J.includes("Opacity"))return"opacities";if(J.startsWith("transition")||J.startsWith("animation")||J.includes("Transition")||J.includes("Animation"))return"transitions";return}function OJ(J,$){if($&&J in $)return $[J];if(J in N)return N[J];return nJ(J)}var r=new Map;function S(J){return r.has(J)}function f(J,$){r.set(J,$)}var i=new L(j);function MJ(J){if(!i.has(J))i.set(J,!0)}function IJ(){return Array.from(i.keys()).join(`
2
- `)}var k=new Map;var RJ=new Map;function EJ(J="stoop"){if(!K())throw new Error("Cannot access document in SSR context");let $=B(J),Y=k.get($);if(!Y||!Y.parentNode){let q=document.getElementById("stoop-ssr");if(q){let X=q.getAttribute("data-stoop");if(!X||X===$)return Y=q,Y.setAttribute("data-stoop",$),k.set($,Y),Y}Y=document.createElement("style"),Y.setAttribute("data-stoop",$),Y.setAttribute("id",`stoop-${$}`),document.head.appendChild(Y),k.set($,Y)}return Y}function a(J){let $=J,Y=KJ("");$=$.replace(Y,"").trim();let q=$.indexOf("[data-theme=");while(q!==-1){let X=$.indexOf("{",q);if(X===-1)break;let F=1,Q=X+1;while(Q<$.length&&F>0){if($[Q]==="{")F++;else if($[Q]==="}")F--;Q++}if(F===0){let Z=$.substring(0,q).trim(),G=$.substring(Q).trim();$=(Z+`
3
- `+G).trim()}else break;q=$.indexOf("[data-theme=")}return $.trim()}function VJ(J,$="stoop"){if(!J)return;let Y=B($),q=`__all_theme_vars_${Y}`;if((RJ.get(q)??null)===J)return;if(RJ.set(q,J),!K()){MJ(J);return}let F=EJ(Y),Q=F.textContent||"",Z=Q.includes(":root")||Q.includes("[data-theme=");if(S(q)||Z){let G=a(Q);F.textContent=J+(G?`
1
+ var YJ=Object.freeze({}),C=1e4,Fq=5000,Uq=10,Hq=500,z=1000;var i=["colors","opacities","space","radii","sizes","fonts","fontWeights","fontSizes","lineHeights","letterSpacings","shadows","zIndices","transitions"],v={accentColor:"colors",animation:"transitions",animationDelay:"transitions",animationDuration:"transitions",animationTimingFunction:"transitions",backdropFilter:"shadows",background:"colors",backgroundColor:"colors",blockSize:"sizes",border:"colors",borderBlockColor:"colors",borderBlockEndColor:"colors",borderBlockStartColor:"colors",borderBottomColor:"colors",borderBottomLeftRadius:"radii",borderBottomRightRadius:"radii",borderColor:"colors",borderEndEndRadius:"radii",borderEndStartRadius:"radii",borderInlineColor:"colors",borderInlineEndColor:"colors",borderInlineStartColor:"colors",borderLeftColor:"colors",borderRadius:"radii",borderRightColor:"colors",borderStartEndRadius:"radii",borderStartStartRadius:"radii",borderTopColor:"colors",borderTopLeftRadius:"radii",borderTopRightRadius:"radii",bottom:"space",boxShadow:"shadows",caretColor:"colors",color:"colors",columnGap:"space",columnRuleColor:"colors",fill:"colors",filter:"shadows",flexBasis:"sizes",floodColor:"colors",font:"fontSizes",fontFamily:"fonts",fontSize:"fontSizes",fontWeight:"fontWeights",gap:"space",gridColumnGap:"space",gridGap:"space",gridRowGap:"space",height:"sizes",inlineSize:"sizes",inset:"space",insetBlock:"space",insetBlockEnd:"space",insetBlockStart:"space",insetInline:"space",insetInlineEnd:"space",insetInlineStart:"space",left:"space",letterSpacing:"letterSpacings",lightingColor:"colors",lineHeight:"lineHeights",margin:"space",marginBlock:"space",marginBlockEnd:"space",marginBlockStart:"space",marginBottom:"space",marginInline:"space",marginInlineEnd:"space",marginInlineStart:"space",marginLeft:"space",marginRight:"space",marginTop:"space",maxBlockSize:"sizes",maxHeight:"sizes",maxInlineSize:"sizes",maxWidth:"sizes",minBlockSize:"sizes",minHeight:"sizes",minInlineSize:"sizes",minWidth:"sizes",opacity:"opacities",outline:"colors",outlineColor:"colors",padding:"space",paddingBlock:"space",paddingBlockEnd:"space",paddingBlockStart:"space",paddingBottom:"space",paddingInline:"space",paddingInlineEnd:"space",paddingInlineStart:"space",paddingLeft:"space",paddingRight:"space",paddingTop:"space",right:"space",rowGap:"space",size:"sizes",stopColor:"colors",stroke:"colors",textDecorationColor:"colors",textEmphasisColor:"colors",textShadow:"shadows",top:"space",transition:"transitions",transitionDelay:"transitions",transitionDuration:"transitions",transitionProperty:"transitions",transitionTimingFunction:"transitions",width:"sizes",zIndex:"zIndices"},Bq=Symbol.for("stoop.component");class R extends Map{maxSize;constructor(q){super();this.maxSize=q}get(q){let J=super.get(q);if(J!==void 0)super.delete(q),super.set(q,J);return J}set(q,J){if(super.has(q))super.delete(q);else if(this.size>=this.maxSize){let $=this.keys().next().value;if($!==void 0)super.delete($)}return super.set(q,J),this}}var Lq=new R(Fq),r=new R(C);function P(){return typeof window!=="undefined"&&typeof document!=="undefined"&&typeof window.document==="object"&&typeof document.createElement==="function"}function k(){return typeof process!=="undefined"&&process.env?.NODE_ENV==="production"}function S(q){return typeof q==="object"&&q!==null}function s(q){return typeof q==="object"&&q!==null&&"__isStoopStyled"in q&&"__stoopClassName"in q&&q.__isStoopStyled===!0}function d(q){return S(q)&&!s(q)}function a(q){return typeof q==="object"&&q!==null&&!Array.isArray(q)}function u(q){if(!q||typeof q!=="object"||Array.isArray(q))throw new Error("[Stoop] Theme must be a non-null object");if(k())return q;let J=q,$=[];for(let Y in J){if(Y==="media")continue;if(!i.includes(Y))$.push(Y)}if($.length>0){let Y=`[Stoop] Theme contains invalid scales: ${$.join(", ")}. Only these scales are allowed: ${i.join(", ")}`;throw new Error(Y)}return q}function T(q,J){if(!J||!q||typeof q!=="object")return q;let $=Object.keys(J),Y=!1;for(let w in q)if($.includes(w)){Y=!0;break}if(!Y)return q;let G={};for(let w in q){let Q=q[w];if($.includes(w)&&J[w])try{let W=J[w](Q);if(W&&typeof W==="object")for(let X in W)G[X]=W[X]}catch{G[w]=Q}else if(S(Q))G[w]=T(Q,J);else G[w]=Q}return G}var t=null,_q=new R(z),FJ=new R(z),Aq=new R(z);function f(q){if(q.length===0)return"0";let J=2166136261,$=16777619,Y=J;for(let G=0;G<q.length;G++)Y^=q.charCodeAt(G),Y=Math.imul(Y,$);return Y^=q.length,(Y>>>0).toString(36)}function e(q){try{return f(JSON.stringify(q))}catch{return f(String(q))}}function Oq(q,J=!1){let Y=String(q).replace(/\\/g,"\\\\").replace(/"/g,"\\\"").replace(/'/g,"\\'").replace(/;/g,"\\;").replace(/\n/g,"\\A ").replace(/\r/g,"").replace(/\f/g,"\\C ");if(J)Y=Y.replace(/\{/g,"\\7B ").replace(/\}/g,"\\7D ");return Y}function qq(q){return Oq(q,!1)}function g(q){let J=_q.get(q);if(J!==void 0)return J;let $=q.replace(/[^a-zA-Z0-9\s\-_>+~:.#[\]&@()]/g,""),Y=!$.trim()||/^[>+~:.#[\]&@()\s]+$/.test($)?"":$;return _q.set(q,Y),Y}function M(q){let J=Aq.get(q);if(J!==void 0)return J;let G=q.replace(/[^a-zA-Z0-9-_]/g,"-").replace(/^[\d-]+/,"").replace(/^-+/,"")||"invalid";return Aq.set(q,G),G}function Rq(q){return Oq(q,!0)}function A(q){if(!q)return"stoop";return q.replace(/[^a-zA-Z0-9-_]/g,"").replace(/^[\d-]+/,"").replace(/^-+/,"")||"stoop"}function Iq(q){if(!q||typeof q!=="string")return"";let J=q.replace(/[^a-zA-Z0-9\s():,<>=\-@]/g,"");if(!J.trim()||!/[a-zA-Z]/.test(J))return"";return J}function Kq(q){if(!q||typeof q!=="string")return!1;if(q==="from"||q==="to")return!0;if(/^\d+(\.\d+)?%$/.test(q)){let $=parseFloat(q);return $>=0&&$<=100}return!1}function Eq(q=""){if(!t){let $=":root".replace(/[.*+?^${}()|[\]\\]/g,"\\$&");t=new RegExp(`${$}\\s*\\{[\\s\\S]*\\}`)}return t}function cq(q){if(q.includes("Color")||q==="fill"||q==="stroke"||q==="accentColor"||q==="caretColor"||q==="border"||q==="outline"||q.includes("background")&&!q.includes("Size")&&!q.includes("Image"))return"colors";if(/^(margin|padding|gap|inset|top|right|bottom|left|rowGap|columnGap|gridGap|gridRowGap|gridColumnGap)/.test(q)||q.includes("Block")||q.includes("Inline"))return"space";if(/(width|height|size|basis)$/i.test(q)||q.includes("BlockSize")||q.includes("InlineSize"))return"sizes";if(q==="fontSize"||q==="font"&&!q.includes("Family"))return"fontSizes";if(q==="fontFamily"||q.includes("FontFamily"))return"fonts";if(q==="fontWeight"||q.includes("FontWeight"))return"fontWeights";if(q==="letterSpacing"||q.includes("LetterSpacing"))return"letterSpacings";if(q.includes("Radius")||q.includes("radius"))return"radii";if(q.includes("Shadow")||q.includes("shadow")||q==="filter"||q==="backdropFilter")return"shadows";if(q==="zIndex"||q.includes("ZIndex")||q.includes("z-index"))return"zIndices";if(q==="opacity"||q.includes("Opacity"))return"opacities";if(q.startsWith("transition")||q.startsWith("animation")||q.includes("Transition")||q.includes("Animation"))return"transitions";return}function Mq(q,J){if(J&&q in J)return J[q];if(q in v)return v[q];return cq(q)}var $q=new Map;function h(q){return $q.has(q)}function n(q,J){$q.set(q,J)}var Jq=new R(C);function gq(q){if(!Jq.has(q))Jq.set(q,!0)}function Pq(){return Array.from(Jq.keys()).join(`
2
+ `)}var y=new Map;var Vq=new Map;function zq(q="stoop"){if(!P())throw new Error("Cannot access document in SSR context");let J=A(q),$=y.get(J);if(!$||!$.parentNode){let Y=document.getElementById("stoop-ssr");if(Y){let G=Y.getAttribute("data-stoop");if(!G||G===J)return $=Y,$.setAttribute("data-stoop",J),y.set(J,$),$}$=document.createElement("style"),$.setAttribute("data-stoop",J),$.setAttribute("id",`stoop-${J}`),document.head.appendChild($),y.set(J,$)}return $}function Yq(q){let J=q,$=Eq("");J=J.replace($,"").trim();let Y=J.indexOf("[data-theme=");while(Y!==-1){let G=J.indexOf("{",Y);if(G===-1)break;let w=1,Q=G+1;while(Q<J.length&&w>0){if(J[Q]==="{")w++;else if(J[Q]==="}")w--;Q++}if(w===0){let W=J.substring(0,Y).trim(),X=J.substring(Q).trim();J=(W+`
3
+ `+X).trim()}else break;Y=J.indexOf("[data-theme=")}return J.trim()}function xq(q,J="stoop"){if(!q)return;let $=A(J),Y=`__all_theme_vars_${$}`;if((Vq.get(Y)??null)===q)return;if(Vq.set(Y,q),!P()){gq(q);return}let w=zq($),Q=w.textContent||"",W=Q.includes(":root")||Q.includes("[data-theme=");if(h(Y)||W){let X=Yq(Q);w.textContent=q+(X?`
4
4
 
5
- `+G:""),f(q,J)}else F.textContent=J+(Q?`
5
+ `+X:""),n(Y,q)}else w.textContent=q+(Q?`
6
6
 
7
- `+Q:""),f(q,J)}function pJ(J,$,Y="stoop"){if(!K())return;let q=B(Y);if(S($))return;let X=EJ(q),F=X.textContent||"";X.textContent=F+(F?`
8
- `:"")+J,f($,J)}function mJ(J,$,Y="stoop"){if(S($))return;let q=B(Y);pJ(J,$,q)}function oJ(J="stoop"){let $=B(J);return k.get($)||null}function lJ(){return new Map(r)}function M(J,$="stoop",Y){let q=Y||J;if(!K()){if(!S(q))f(q,J);MJ(J);return}mJ(J,q,$)}function PJ(J="stoop"){if(K()){let $=B(J),Y=oJ($);if(Y&&Y.parentNode){let q=Y.textContent||"";if(!q&&lJ().size>0)return IJ();return q}}return IJ()}var iJ=/(-?\$[a-zA-Z][a-zA-Z0-9]*(?:\$[a-zA-Z][a-zA-Z0-9]*)?(?:\.[a-zA-Z][a-zA-Z0-9]*)?)/g;function t(J){let $=new Map;function Y(q,X=[]){let F=Object.keys(q);for(let Q of F){let Z=q[Q],G=[...X,Q];if(o(Z))Y(Z,G);else{let D=$.get(Q);if(D)D.push(G);else $.set(Q,[G])}}}Y(J);for(let[,q]of $.entries())if(q.length>1)q.sort((X,F)=>{let Q=X.length-F.length;if(Q!==0)return Q;let Z=X.join("."),G=F.join(".");return Z.localeCompare(G)});return $}function rJ(J,$){let Y=Object.keys(J).filter((X)=>X!=="media"),q=Object.keys($).filter((X)=>X!=="media");if(Y.length!==q.length)return!1;for(let X of Y)if(!(X in $))return!1;return!0}function zJ(J,$){if(J===$)return!0;if(!J||!$)return!1;if(!rJ(J,$))return!1;let Y={...J},q={...$};return delete Y.media,delete q.media,JSON.stringify(Y)===JSON.stringify(q)}function s(J,$,Y){if(Y&&Y in J){let F=J[Y];if(F&&typeof F==="object"&&!Array.isArray(F)&&$ in F)return[Y,$]}let X=t(J).get($);if(!X||X.length===0)return null;return X[0]}function NJ(J,$,Y,q){if(!J.startsWith("$"))return J;let X=J.slice(1);if(X.includes("$")||X.includes("."))return`var(${`--${(X.includes("$")?X.split("$"):X.split(".")).map((W)=>R(W)).join("-")}`})`;if($&&Y){let Z=OJ(Y,q);if(Z){let w=s($,X,Z);if(w)return`var(${`--${w.map((A)=>R(A)).join("-")}`})`}let D=t($).get(X);if(D&&D.length>1){if(!g()){let w=Z?`Property "${Y}" maps to "${Z}" scale, but token not found there. `:`No scale mapping found for property "${Y}". `;console.warn(`[Stoop] Ambiguous token "$${X}" found in multiple categories: ${D.map((H)=>H.join(".")).join(", ")}. ${w}Using "${D[0].join(".")}" (deterministic: shorter paths first, then alphabetical). Use full path "$${D[0].join(".")}" to be explicit.`)}}let W=s($,X);if(W)return`var(${`--${W.map((U)=>R(U)).join("-")}`})`}else if($){let G=t($).get(X);if(G&&G.length>1){if(!g())console.warn(`[Stoop] Ambiguous token "$${X}" found in multiple categories: ${G.map((W)=>W.join(".")).join(", ")}. Using "${G[0].join(".")}" (deterministic: shorter paths first, then alphabetical). Use full path "$${G[0].join(".")}" to be explicit, or use with a CSS property for automatic resolution.`)}let D=s($,X);if(D)return`var(${`--${D.map((H)=>R(H)).join("-")}`})`}return`var(${`--${R(X)}`})`}function e(J,$="stoop",Y){let q=Y||":root",X=[];function F(Q,Z=[]){let G=Object.keys(Q).sort();for(let D of G){if(D==="media")continue;let W=Q[D],w=[...Z,D];if(o(W))F(W,w);else{let U=`--${w.map((y)=>R(y)).join("-")}`,A=typeof W==="string"||typeof W==="number"?LJ(W):String(W);X.push(` ${U}: ${A};`)}}}if(F(J),X.length===0)return"";return`${q} {
9
- ${X.join(`
7
+ `+Q:""),n(Y,q)}function mq(q,J,$="stoop"){if(!P())return;let Y=A($);if(h(J))return;let G=zq(Y),w=G.textContent||"";G.textContent=w+(w?`
8
+ `:"")+q,n(J,q)}function oq(q,J,$="stoop"){if(h(J))return;let Y=A($);mq(q,J,Y)}function pq(q="stoop"){let J=A(q);return y.get(J)||null}function lq(){return new Map($q)}function x(q,J="stoop",$){let Y=$||q;if(!P()){if(!h(Y))n(Y,q);gq(q);return}oq(q,Y,J)}function jq(q="stoop"){if(P()){let J=A(q),$=pq(J);if($&&$.parentNode){let Y=$.textContent||"";if(!Y&&lq().size>0)return Pq();return Y}}return Pq()}var iq=/(-?\$[a-zA-Z][a-zA-Z0-9]*(?:\$[a-zA-Z][a-zA-Z0-9]*)?(?:\.[a-zA-Z][a-zA-Z0-9]*)?)/g,Nq=new WeakMap;function Gq(q){let J=Nq.get(q);if(J)return J;let $=new Map;function Y(G,w=[]){let Q=Object.keys(G);for(let W of Q){let X=G[W],Z=[...w,W];if(a(X))Y(X,Z);else{let D=$.get(W);if(D)D.push(Z);else $.set(W,[Z])}}}Y(q);for(let[,G]of $.entries())if(G.length>1)G.sort((w,Q)=>{let W=w.length-Q.length;if(W!==0)return W;let X=w.join("."),Z=Q.join(".");return X.localeCompare(Z)});return Nq.set(q,$),$}function rq(q,J){let $=Object.keys(q).filter((G)=>G!=="media"),Y=Object.keys(J).filter((G)=>G!=="media");if($.length!==Y.length)return!1;for(let G of $)if(!(G in J))return!1;return!0}function vq(q,J){if(q===J)return!0;if(!q||!J)return!1;if(!rq(q,J))return!1;let $={...q},Y={...J};return delete $.media,delete Y.media,JSON.stringify($)===JSON.stringify(Y)}function sq(q,J,$){if($&&$ in q){let w=q[$];if(w&&typeof w==="object"&&!Array.isArray(w)&&J in w)return[$,J]}let G=Gq(q).get(J);if(!G||G.length===0)return null;return G[0]}function c(q,J,$,Y){if(!q.startsWith("$"))return q;let G=q.slice(1);if(G.includes("$")||G.includes("."))return`var(${`--${(G.includes("$")?G.split("$"):G.split(".")).map((D)=>M(D)).join("-")}`})`;if(J&&$){let W=Mq($,Y);if(W){let D=sq(J,G,W);if(D)return`var(${`--${D.map((H)=>M(H)).join("-")}`})`}let Z=Gq(J).get(G);if(Z&&Z.length>1){if(!k()){let D=W?`Property "${$}" maps to "${W}" scale, but token not found there. `:`No scale mapping found for property "${$}". `;console.warn(`[Stoop] Ambiguous token "$${G}" found in multiple categories: ${Z.map((U)=>U.join(".")).join(", ")}. ${D}Using "${Z[0].join(".")}" (deterministic: shorter paths first, then alphabetical). Use full path "$${Z[0].join(".")}" to be explicit.`)}}if(Z&&Z.length>0)return`var(${`--${Z[0].map((H)=>M(H)).join("-")}`})`}else if(J){let X=Gq(J).get(G);if(X&&X.length>1){if(!k())console.warn(`[Stoop] Ambiguous token "$${G}" found in multiple categories: ${X.map((Z)=>Z.join(".")).join(", ")}. Using "${X[0].join(".")}" (deterministic: shorter paths first, then alphabetical). Use full path "$${X[0].join(".")}" to be explicit, or use with a CSS property for automatic resolution.`)}if(X&&X.length>0)return`var(${`--${X[0].map((F)=>M(F)).join("-")}`})`}return`var(${`--${M(G)}`})`}function Xq(q,J="stoop",$){let Y=$||":root",G=[];function w(Q,W=[]){let X=Object.keys(Q).sort();for(let Z of X){if(Z==="media")continue;let D=Q[Z],U=[...W,Z];if(a(D))w(D,U);else{let H=`--${U.map((B)=>M(B)).join("-")}`,_=typeof D==="string"||typeof D==="number"?Rq(D):String(D);G.push(` ${H}: ${_};`)}}}if(w(q),G.length===0)return"";return`${Y} {
9
+ ${G.join(`
10
10
  `)}
11
- }`}function d(J,$="stoop",Y="data-theme"){let q=[];for(let[X,F]of Object.entries(J)){let Q=`[${Y}="${X}"]`,Z=e(F,$,Q);if(Z)q.push(Z)}return q.join(`
11
+ }`}function m(q,J="stoop",$="data-theme"){let Y=[];for(let[G,w]of Object.entries(q)){let Q=`[${$}="${G}"]`,W=Xq(w,J,Q);if(W)Y.push(W)}return Y.join(`
12
12
 
13
- `)}function E(J,$,Y,q){if(!J||typeof J!=="object")return J;let X={},F=!1,Q=Object.keys(J).sort();for(let Z of Q){let G=J[Z];if(v(G)){let D=E(G,$,Y,void 0);if(X[Z]=D,D!==G)F=!0}else if(typeof G==="string"&&G.includes("$")){F=!0;let D=q||Z;X[Z]=G.replace(iJ,(W)=>{if(W.startsWith("-$")){let w=W.slice(1);return`calc(-1 * ${NJ(w,$,D,Y)})`}return NJ(W,$,D,Y)})}else X[Z]=G}if(!F)return J;return X}function aJ(J,$){if(typeof J==="symbol"&&J===ZJ)return!0;if(p($))return!0;if(typeof J==="string"&&J.startsWith("__STOOP_COMPONENT_"))return!0;return!1}function sJ(J,$){if(typeof $==="object"&&$!==null&&"__stoopClassName"in $&&typeof $.__stoopClassName==="string")return $.__stoopClassName;if(typeof J==="string"&&J.startsWith("__STOOP_COMPONENT_"))return J.replace("__STOOP_COMPONENT_","");return""}function _(J,$="",Y=0,q){if(!J||typeof J!=="object")return"";if(Y>QJ)return"";let X=[],F=[],Q=Object.keys(J).sort();for(let G of Q){let D=J[G];if(aJ(G,D)){let W=sJ(G,D);if(!W)continue;let w=I(W);if(!w)continue;let H=$?`${$} .${w}`:`.${w}`,U=m(D)?_(D,H,Y+1,q):"";if(U)F.push(U);continue}if(m(D))if(q&&G in q){let W=_J(q[G]);if(W){let w=_(D,$,Y+1,q);if(w)F.push(`${W} { ${w} }`)}}else if(G.startsWith("@")){let W=I(G);if(W){let w=_(D,$,Y+1,q);if(w)F.push(`${W} { ${w} }`)}}else if(G.includes("&")){let W=I(G);if(W){let H=W.split("&").join($),U=_(D,H,Y+1,q);if(U)F.push(U)}}else if(G.startsWith(":")){let W=I(G);if(W){let w=`${$}${W}`,H=_(D,w,Y+1,q);if(H)F.push(H)}}else if(G.includes(" ")||G.includes(">")||G.includes("+")||G.includes("~")){let W=I(G);if(W){let H=/^[\s>+~]/.test(W.trim())?`${$}${W}`:`${$} ${W}`,U=_(D,H,Y+1,q);if(U)F.push(U)}}else{let W=I(G);if(W){let w=$?`${$} ${W}`:W,H=_(D,w,Y+1,q);if(H)F.push(H)}}else if(D!==void 0){let W=C(G);if(W&&(typeof D==="string"||typeof D==="number")){let w=BJ(D);X.push(`${W}: ${w};`)}}}let Z=[];if(X.length>0)Z.push(`${$} { ${X.join(" ")} }`);return Z.push(...F),Z.join("")}function u(J,$,Y="stoop",q,X,F){let Q=B(Y),Z=z(J,X),G=E(Z,$,F),D=_(G,"",0,q),W=b(D),w=Q?`${Q}-${W}`:`css-${W}`,H=`${Q}:${w}`,U=n.get(H);if(U)return M(U,Q,H),w;let A=_(G,`.${w}`,0,q);return n.set(H,A),WJ.set(H,w),M(A,Q,H),w}var jJ=new Map;function gJ(J,$="stoop"){let Y=$||"";jJ.set(Y,J)}function tJ(J="stoop"){let $=J||"";return jJ.get($)||null}function JJ(J,$){let Y={...J},q=Object.keys($);for(let X of q){if(X==="media")continue;let F=$[X],Q=J[X];if(F&&typeof F==="object"&&!Array.isArray(F)&&Q&&typeof Q==="object"&&!Array.isArray(Q))Y[X]={...Q,...F};else if(F!==void 0)Y[X]=F}return Y}function $J(J,$="stoop"){let Y=tJ($);if(!Y)return J;if(zJ(J,Y))return J;return JJ(Y,J)}function vJ(J,$="stoop",Y="data-theme"){if(!K())return;let q={};for(let[F,Q]of Object.entries(J))q[F]=$J(Q,$);let X=d(q,$,Y);VJ(X,$)}function xJ(J){return function $(Y={}){let q=x(Y);return JJ(J,q)}}function bJ(J,$="stoop",Y,q,X){return function F(Q){return u(Q,J,$,Y,q,X)}}function eJ(J,$,Y,q){let X=`@keyframes ${$} {`,F=Object.keys(J).sort((Q,Z)=>{let G=parseFloat(Q.replace("%","")),D=parseFloat(Z.replace("%",""));if(Q==="from")return-1;if(Z==="from")return 1;if(Q==="to")return 1;if(Z==="to")return-1;return G-D});for(let Q of F){if(!AJ(Q))continue;let Z=J[Q];if(!Z||typeof Z!=="object")continue;X+=` ${Q} {`;let G=E(Z,Y,q),D=Object.keys(G).sort();for(let W of D){let w=G[W];if(w!==void 0&&(typeof w==="string"||typeof w==="number")){let H=C(W);if(H){let U=String(w);X+=` ${H}: ${U};`}}}X+=" }"}return X+=" }",X}function TJ(J="stoop",$,Y){let q=B(J),X=new L(FJ);return function F(Q){let Z=T(Q),G=X.get(Z);if(G)return G;let D=Z.slice(0,8),W=q?`${q}-${D}`:`stoop-${D}`,w=eJ(Q,W,$,Y),H=`__keyframes_${W}`;return M(w,q,H),X.set(Z,W),W}}var YJ=new Set;function CJ(J,$="stoop",Y,q,X){return function F(Q){let Z=T(Q);if(YJ.has(Z))return()=>{};YJ.add(Z);let G=B($),D=z(Q,q),W=E(D,J,X),w=_(W,"",0,Y);return M(w,G,`__global_${Z}`),()=>{YJ.delete(Z)}}}function kJ(J){let{globalCss:$,media:Y,prefix:q="stoop",theme:X,themeMap:F,utils:Q}=J,Z=B(q),G=x(X),D=G.media||Y,W={...N,...F};gJ(G,Z);let w=bJ(G,Z,D,Q,W),H=xJ(G),U=CJ(G,Z,D,Q,W),A=TJ(Z,G,W),y=Object.freeze({...G});function fJ(h){for(let O of h)try{u(O,G,Z,D,Q,W)}catch{}}function SJ(h){if(!J.themes||Object.keys(J.themes).length===0)return;vJ(J.themes,Z)}function dJ(h){let O="";if(J.themes&&Object.keys(J.themes).length>0){let V={};for(let[yJ,hJ]of Object.entries(J.themes))V[yJ]=$J(hJ,Z);let XJ=d(V,Z,"data-theme");if(XJ)O+=XJ+`
14
- `}else{let V=e(G,Z);if(V)O+=V+`
15
- `}let uJ=PJ(),qJ=a(uJ).trim();if(qJ)O+=(O?`
16
- `:"")+qJ;return O}return{config:{...J,prefix:Z},createTheme:H,css:w,getCssText:dJ,globalCss:U,globalCssConfig:$,keyframes:A,media:D,mergedThemeMap:W,preloadTheme:SJ,sanitizedPrefix:Z,theme:y,utils:Q,validatedTheme:G,warmCache:fJ}}function Y1(J){let $=kJ(J);return{config:{...$.config,prefix:$.sanitizedPrefix},createTheme:$.createTheme,css:$.css,getCssText:$.getCssText,globalCss:$.globalCss,keyframes:$.keyframes,preloadTheme:$.preloadTheme,theme:$.theme,warmCache:$.warmCache}}export{Y1 as createStoop};
13
+ `)}function j(q,J,$,Y){if(!q||typeof q!=="object")return q;let G=Object.keys(q),w=!1;for(let X of G){let Z=q[X];if(typeof Z==="string"&&Z.includes("$")){w=!0;break}}if(!w&&!J)return q;let Q={},W=!1;for(let X of G){let Z=q[X];if(S(Z)){let D=j(Z,J,$,void 0);if(Q[X]=D,D!==Z)W=!0}else if(typeof Z==="string"&&Z.includes("$")){W=!0;let D=Y||X;if(Z.startsWith("$")&&!Z.includes(" ")&&!Z.includes("calc(")&&Z===Z.trim())if(Z.startsWith("-$")){let F=Z.slice(1);if(F.includes(".")||F.includes("$")){let H=F.includes("$")?F.split("$"):F.split("."),_=!1;for(let B=0;B<H.length;B++){let I=H[B];for(let O=0;O<I.length;O++){let L=I.charCodeAt(O);if(!(L>=48&&L<=57||L>=65&&L<=90||L>=97&&L<=122||L===45||L===95)){_=!0;break}}if(_)break}if(_){let I=`--${H.map((O)=>M(O)).join("-")}`;Q[X]=`calc(-1 * var(${I}))`}else{let B=`--${H.join("-")}`;Q[X]=`calc(-1 * var(${B}))`}}else{let H=c(F,J,D,$);Q[X]=`calc(-1 * ${H})`}}else{let F=Z.slice(1);if(F.includes(".")||F.includes("$")){let H=F.includes("$")?F.split("$"):F.split("."),_=!1;for(let B=0;B<H.length;B++){let I=H[B];for(let O=0;O<I.length;O++){let L=I.charCodeAt(O);if(!(L>=48&&L<=57||L>=65&&L<=90||L>=97&&L<=122||L===45||L===95)){_=!0;break}}if(_)break}if(_){let I=`--${H.map((O)=>M(O)).join("-")}`;Q[X]=`var(${I})`}else{let B=`--${H.join("-")}`;Q[X]=`var(${B})`}}else Q[X]=c(Z,J,D,$)}else Q[X]=Z.replace(iq,(F)=>{if(F.startsWith("-$")){let H=F.slice(1);return`calc(-1 * ${c(H,J,D,$)})`}return c(F,J,D,$)})}else Q[X]=Z}if(!W)return q;return Q}var K=new R(z);function aq(q){return q.replace(/([A-Z])/g,"-$1").toLowerCase()}function tq(q){if(q===q.toUpperCase()&&q.length>1)return q.charAt(0)+q.slice(1).toLowerCase();return q}function o(q){if(!q)return"";return q.charAt(0).toLowerCase()+q.slice(1).replace(/([A-Z])/g,"-$1").toLowerCase()}function b(q){if(!q||typeof q!=="string")return"";let J=K.get(q);if(J!==void 0)return J;if(/^-[a-z]+-/.test(q))return K.set(q,q),q;let $=tq(q);if(/^[Mm]oz/i.test($)){if($.length===3||$.toLowerCase()==="moz")return K.set(q,"-moz"),"-moz";let Q=$.match(/^[Mm]oz(.+)$/i);if(Q&&Q[1]){let[,W]=Q,X=o(W);if(X){let Z=`-moz-${X}`;return K.set(q,Z),Z}}}if(/^[Ww]ebkit/i.test($)){if($.length===6||$.toLowerCase()==="webkit")return K.set(q,"-webkit"),"-webkit";let Q=$.match(/^[Ww]ebkit(.+)$/i);if(Q&&Q[1]){let[,W]=Q,X=o(W);if(X){let Z=`-webkit-${X}`;return K.set(q,Z),Z}}}if(/^[Mm]s/i.test($)){if($.length===2||$.toLowerCase()==="ms")return K.set(q,"-ms"),"-ms";let Q=$.match(/^[Mm]s(.+)$/i);if(Q&&Q[1]){let[,W]=Q,X=o(W);if(X){let Z=`-ms-${X}`;return K.set(q,Z),Z}}}if(/^O/i.test($)){if($.length===1||$.toLowerCase()==="o")return K.set(q,"-o"),"-o";if(/^O[A-Z]/.test($)){let Q=$.substring(1),W=o(Q);if(W){let X=`-o-${W}`;return K.set(q,X),X}}}let w=aq($).replace(/[^a-zA-Z0-9-]/g,"").replace(/^-+|-+$/g,"").replace(/^\d+/,"")||"";return K.set(q,w),w}function Tq(q,J){if(typeof q==="symbol"&&q===Bq)return!0;if(s(J))return!0;if(typeof q==="string"&&q.startsWith("__STOOP_COMPONENT_"))return!0;return!1}function eq(q,J){if(typeof J==="object"&&J!==null&&"__stoopClassName"in J&&typeof J.__stoopClassName==="string")return J.__stoopClassName;if(typeof q==="string"&&q.startsWith("__STOOP_COMPONENT_"))return q.replace("__STOOP_COMPONENT_","");return""}function E(q,J="",$=0,Y){if(!q||typeof q!=="object")return"";if($>Uq)return"";let G=[],w=[],Q=J===""?Object.keys(q).sort():Object.keys(q);for(let X of Q){let Z=q[X];if(Tq(X,Z)){let D=eq(X,Z);if(!D)continue;let U=g(D);if(!U)continue;let F=J?`${J} .${U}`:`.${U}`,H=d(Z)?E(Z,F,$+1,Y):"";if(H)w.push(H);continue}if(d(Z))if(Y&&X in Y){let D=Iq(Y[X]);if(D){let U=E(Z,J,$+1,Y);if(U)w.push(`${D} { ${U} }`)}}else if(X.startsWith("@")){let D=g(X);if(D){let U=E(Z,J,$+1,Y);if(U)w.push(`${D} { ${U} }`)}}else if(X.includes("&")){let D=g(X);if(D){let F=D.split("&").join(J),H=E(Z,F,$+1,Y);if(H)w.push(H)}}else if(X.startsWith(":")){let D=g(X);if(D){let U=`${J}${D}`,F=E(Z,U,$+1,Y);if(F)w.push(F)}}else if(X.includes(" ")||X.includes(">")||X.includes("+")||X.includes("~")){let D=g(X);if(D){let F=/^[\s>+~]/.test(D.trim())?`${J}${D}`:`${J} ${D}`,H=E(Z,F,$+1,Y);if(H)w.push(H)}}else{let D=g(X);if(D){let U=J?`${J} ${D}`:D,F=E(Z,U,$+1,Y);if(F)w.push(F)}}else if(Z!==void 0){let D=b(X);if(D&&(typeof Z==="string"||typeof Z==="number")){let U=qq(Z);G.push(`${D}: ${U};`)}}}let W=[];if(G.length>0)W.push(`${J} { ${G.join(" ")} }`);return W.push(...w),W.join("")}function qJ(q,J){if(!q||typeof q!=="object")return"";let $=[],Y=Object.keys(q).sort();for(let G of Y){let w=q[G];if(d(w))return"";if(J&&G in J)return"";if(G.startsWith("@")||G.includes("&")||G.startsWith(":")||G.includes(" ")||G.includes(">")||G.includes("+")||G.includes("~"))return"";if(w!==void 0&&!Tq(G,w)){let Q=b(G);if(Q&&(typeof w==="string"||typeof w==="number")){let W=qq(w);$.push(`${Q}: ${W};`)}}}return $.join(" ")}function p(q,J,$="stoop",Y,G,w){let Q=A($),W=T(q,G),X=j(W,J,w),Z=qJ(X,Y),D,U;if(Z)D=Z,U=f(D);else D=E(X,"",0,Y),U=f(D);let F=Q?`${Q}-${U}`:`css-${U}`,H=`${Q}:${F}`,_=r.get(H);if(_)return x(_,Q,H),F;let B;if(Z)B=`.${F} { ${Z} }`;else B=E(X,`.${F}`,0,Y);return r.set(H,B),Lq.set(H,F),x(B,Q,H),F}var fq=new Map;function bq(q,J="stoop"){let $=J||"";fq.set($,q)}function JJ(q="stoop"){let J=q||"";return fq.get(J)||null}function Qq(q,J){let $={...q},Y=Object.keys(J);for(let G of Y){if(G==="media")continue;let w=J[G],Q=q[G];if(w&&typeof w==="object"&&!Array.isArray(w)&&Q&&typeof Q==="object"&&!Array.isArray(Q))$[G]={...Q,...w};else if(w!==void 0)$[G]=w}return $}function Zq(q,J="stoop"){let $=JJ(J);if(!$)return q;if(vq(q,$))return q;return Qq($,q)}function Cq(q,J="stoop",$="data-theme"){if(!P())return;let Y={};for(let[w,Q]of Object.entries(q))Y[w]=Zq(Q,J);let G=m(Y,J,$);xq(G,J)}function kq(q){return function J($={}){let Y=u($);return Qq(q,Y)}}function Sq(q,J="stoop",$,Y,G){return function w(Q){return p(Q,q,J,$,Y,G)}}function $J(q,J,$,Y){let G=`@keyframes ${J} {`,w=Object.keys(q).sort((Q,W)=>{let X=parseFloat(Q.replace("%","")),Z=parseFloat(W.replace("%",""));if(Q==="from")return-1;if(W==="from")return 1;if(Q==="to")return 1;if(W==="to")return-1;return X-Z});for(let Q of w){if(!Kq(Q))continue;let W=q[Q];if(!W||typeof W!=="object")continue;G+=` ${Q} {`;let X=j(W,$,Y),Z=Object.keys(X).sort();for(let D of Z){let U=X[D];if(U!==void 0&&(typeof U==="string"||typeof U==="number")){let F=b(D);if(F){let H=String(U);G+=` ${F}: ${H};`}}}G+=" }"}return G+=" }",G}function dq(q="stoop",J,$){let Y=A(q),G=new R(Hq);return function w(Q){let W=e(Q),X=G.get(W);if(X)return X;let Z=W.slice(0,8),D=Y?`${Y}-${Z}`:`stoop-${Z}`,U=$J(Q,D,J,$),F=`__keyframes_${D}`;return x(U,Y,F),G.set(W,D),D}}var Wq=new Set;function uq(q,J="stoop",$,Y,G){return function w(Q){let W=e(Q);if(Wq.has(W))return()=>{};Wq.add(W);let X=A(J),Z=T(Q,Y),D=j(Z,q,G),U=E(D,"",0,$);return x(U,X,`__global_${W}`),()=>{Wq.delete(W)}}}function yq(q){let{globalCss:J,media:$,prefix:Y="stoop",theme:G,themeMap:w,utils:Q}=q,W=A(Y),X=u(G),Z=X.media||$,D={...v,...w};bq(X,W);let U=Sq(X,W,Z,Q,D),F=kq(X),H=uq(X,W,Z,Q,D),_=dq(W,X,D),B=Object.freeze({...X});function I(V){for(let l of V)try{p(l,X,W,Z,Q,D)}catch{}}function O(){if(!q.themes||Object.keys(q.themes).length===0)return;Cq(q.themes,W)}function L(){let V="";if(q.themes&&Object.keys(q.themes).length>0){let N={};for(let[nq,hq]of Object.entries(q.themes))N[nq]=Zq(hq,W);let Dq=m(N,W,"data-theme");if(Dq)V+=Dq+`
14
+ `}else{let N=Xq(X,W);if(N)V+=N+`
15
+ `}let l=jq(),wq=Yq(l).trim();if(wq)V+=(V?`
16
+ `:"")+wq;return V}return{config:{...q,prefix:W},createTheme:F,css:U,getCssText:L,globalCss:H,globalCssConfig:J,keyframes:_,media:Z,mergedThemeMap:D,preloadTheme:O,sanitizedPrefix:W,theme:B,utils:Q,validatedTheme:X,warmCache:I}}function Y0(q){let J=yq(q);return{config:{...J.config,prefix:J.sanitizedPrefix},createTheme:J.createTheme,css:J.css,getCssText:J.getCssText,globalCss:J.globalCss,keyframes:J.keyframes,preloadTheme:J.preloadTheme,theme:J.theme,warmCache:J.warmCache}}export{Y0 as createStoop};
@@ -1,27 +1,24 @@
1
1
  /**
2
2
  * Factory function that creates a Stoop instance.
3
3
  * Supports both client-side (with React APIs) and server-side (without React) usage.
4
- * Automatically detects environment and includes appropriate APIs.
5
4
  */
6
5
  import type { CSS, StoopConfig, StoopInstance, Theme, ThemeScale } from "./types";
7
- import { createCSSFunction, createKeyframesFunction } from "./api/core-api";
8
- import { createGlobalCSSFunction } from "./api/global-css";
6
+ import { createCSSFunction, createKeyframesFunction, createGlobalCSSFunction } from "./api/core-api";
9
7
  /**
10
8
  * Shared implementation for creating Stoop instances.
11
9
  * Handles common setup logic for both client and server instances.
12
- * Exported for use in SSR entry point.
13
10
  */
14
11
  export declare function createStoopBase(config: StoopConfig): {
15
12
  config: StoopConfig;
16
13
  createTheme: (overrides?: Partial<Theme>) => Theme;
17
14
  css: ReturnType<typeof createCSSFunction>;
18
- getCssText: (theme?: string | Theme) => string;
15
+ getCssText: () => string;
19
16
  globalCss: ReturnType<typeof createGlobalCSSFunction>;
20
17
  globalCssConfig: StoopConfig["globalCss"];
21
18
  keyframes: ReturnType<typeof createKeyframesFunction>;
22
19
  media: StoopConfig["media"];
23
20
  mergedThemeMap: Record<string, ThemeScale>;
24
- preloadTheme: (theme: string | Theme) => void;
21
+ preloadTheme: () => void;
25
22
  sanitizedPrefix: string;
26
23
  theme: Theme;
27
24
  utils: StoopConfig["utils"];
@@ -31,7 +28,6 @@ export declare function createStoopBase(config: StoopConfig): {
31
28
  /**
32
29
  * Creates a Stoop instance with the provided configuration.
33
30
  * Includes all APIs: styled, Provider, useTheme, etc.
34
- * In server contexts without React, React APIs will be undefined.
35
31
  *
36
32
  * @param config - Configuration object containing theme, media queries, utilities, and optional prefix/themeMap
37
33
  * @returns StoopInstance with all API functions
@@ -1,16 +1,16 @@
1
- var r=Object.freeze({}),s=1e4,T0=5000,C0=10,f0=500,c=1000,k0=31536000,S0="/",W0=["colors","opacities","space","radii","sizes","fonts","fontWeights","fontSizes","lineHeights","letterSpacings","shadows","zIndices","transitions"],n={accentColor:"colors",animation:"transitions",animationDelay:"transitions",animationDuration:"transitions",animationTimingFunction:"transitions",backdropFilter:"shadows",background:"colors",backgroundColor:"colors",blockSize:"sizes",border:"colors",borderBlockColor:"colors",borderBlockEndColor:"colors",borderBlockStartColor:"colors",borderBottomColor:"colors",borderBottomLeftRadius:"radii",borderBottomRightRadius:"radii",borderColor:"colors",borderEndEndRadius:"radii",borderEndStartRadius:"radii",borderInlineColor:"colors",borderInlineEndColor:"colors",borderInlineStartColor:"colors",borderLeftColor:"colors",borderRadius:"radii",borderRightColor:"colors",borderStartEndRadius:"radii",borderStartStartRadius:"radii",borderTopColor:"colors",borderTopLeftRadius:"radii",borderTopRightRadius:"radii",bottom:"space",boxShadow:"shadows",caretColor:"colors",color:"colors",columnGap:"space",columnRuleColor:"colors",fill:"colors",filter:"shadows",flexBasis:"sizes",floodColor:"colors",font:"fontSizes",fontFamily:"fonts",fontSize:"fontSizes",fontWeight:"fontWeights",gap:"space",gridColumnGap:"space",gridGap:"space",gridRowGap:"space",height:"sizes",inlineSize:"sizes",inset:"space",insetBlock:"space",insetBlockEnd:"space",insetBlockStart:"space",insetInline:"space",insetInlineEnd:"space",insetInlineStart:"space",left:"space",letterSpacing:"letterSpacings",lightingColor:"colors",lineHeight:"lineHeights",margin:"space",marginBlock:"space",marginBlockEnd:"space",marginBlockStart:"space",marginBottom:"space",marginInline:"space",marginInlineEnd:"space",marginInlineStart:"space",marginLeft:"space",marginRight:"space",marginTop:"space",maxBlockSize:"sizes",maxHeight:"sizes",maxInlineSize:"sizes",maxWidth:"sizes",minBlockSize:"sizes",minHeight:"sizes",minInlineSize:"sizes",minWidth:"sizes",opacity:"opacities",outline:"colors",outlineColor:"colors",padding:"space",paddingBlock:"space",paddingBlockEnd:"space",paddingBlockStart:"space",paddingBottom:"space",paddingInline:"space",paddingInlineEnd:"space",paddingInlineStart:"space",paddingLeft:"space",paddingRight:"space",paddingTop:"space",right:"space",rowGap:"space",size:"sizes",stopColor:"colors",stroke:"colors",textDecorationColor:"colors",textEmphasisColor:"colors",textShadow:"shadows",top:"space",transition:"transitions",transitionDelay:"transitions",transitionDuration:"transitions",transitionProperty:"transitions",transitionTimingFunction:"transitions",width:"sizes",zIndex:"zIndices"},a=Symbol.for("stoop.component");class E extends Map{maxSize;constructor($){super();this.maxSize=$}get($){let J=super.get($);if(J!==void 0)super.delete($),super.set($,J);return J}set($,J){if(super.has($))super.delete($);else if(this.size>=this.maxSize){let q=this.keys().next().value;if(q!==void 0)super.delete(q)}return super.set($,J),this}}var d0=new E(T0),D0=new E(s);function w(){return typeof window!=="undefined"&&typeof document!=="undefined"&&typeof window.document==="object"&&typeof document.createElement==="function"}function u(){return typeof process!=="undefined"&&process.env?.NODE_ENV==="production"}function t($){return typeof $==="object"&&$!==null}function m($){return typeof $==="object"&&$!==null&&"__isStoopStyled"in $&&"__stoopClassName"in $&&$.__isStoopStyled===!0}function U0($){return t($)&&!m($)}function H0($){return typeof $==="object"&&$!==null&&!Array.isArray($)}function e($){if(!$||typeof $!=="object"||Array.isArray($))throw new Error("[Stoop] Theme must be a non-null object");if(u())return $;let J=$,q=[];for(let X in J){if(X==="media")continue;if(!W0.includes(X))q.push(X)}if(q.length>0){let X=`[Stoop] Theme contains invalid scales: ${q.join(", ")}. Only these scales are allowed: ${W0.join(", ")}`;throw new Error(X)}return $}function i($,J){if(!J||!$||typeof $!=="object")return $;let q={},X=Object.keys(J);for(let Y in $){let Q=$[Y];if(X.includes(Y)&&J[Y])try{let G=J[Y](Q);if(G&&typeof G==="object")for(let Z in G)q[Z]=G[Z]}catch{q[Y]=Q}else if(t(Q))q[Y]=i(Q,J);else q[Y]=Q}return q}var F0=null,u0=new E(c),y0=new E(c),p0=new E(c),h0=new E(c);function y($){let X=2166136261;for(let Y=0;Y<$.length;Y++)X^=$.charCodeAt(Y),X=Math.imul(X,16777619);return X^=$.length,(X>>>0).toString(36)}function $0($){try{return y(JSON.stringify($))}catch{return y(String($))}}function O1($){return $.replace(/([A-Z])/g,"-$1").toLowerCase()}function c0($,J=!1){let X=String($).replace(/\\/g,"\\\\").replace(/"/g,"\\\"").replace(/'/g,"\\'").replace(/;/g,"\\;").replace(/\n/g,"\\A ").replace(/\r/g,"").replace(/\f/g,"\\C ");if(J)X=X.replace(/\{/g,"\\7B ").replace(/\}/g,"\\7D ");return X}function n0($){return c0($,!1)}function T($){let J=u0.get($);if(J!==void 0)return J;let q=$.replace(/[^a-zA-Z0-9\s\-_>+~:.#[\]&@()]/g,""),X=!q.trim()||/^[>+~:.#[\]&@()\s]+$/.test(q)?"":q;return u0.set($,X),X}function C($){let J=h0.get($);if(J!==void 0)return J;let Y=$.replace(/[^a-zA-Z0-9-_]/g,"-").replace(/^[\d-]+/,"").replace(/^-+/,"")||"invalid";return h0.set($,Y),Y}function m0($){return c0($,!0)}function R($){if(!$)return"stoop";return $.replace(/[^a-zA-Z0-9-_]/g,"").replace(/^[\d-]+/,"").replace(/^-+/,"")||"stoop"}function i0($){if(!$||typeof $!=="string")return"";let J=$.replace(/[^a-zA-Z0-9\s():,<>=\-@]/g,"");if(!J.trim()||!/[a-zA-Z]/.test(J))return"";return J}function o0($){if(!$||typeof $!=="string")return"";let J=p0.get($);if(J!==void 0)return J;let q=$.trim().split(/\s+/),X=[];for(let Q of q){if(!Q)continue;let Z=Q.replace(/[^a-zA-Z0-9-_]/g,"").replace(/^\d+/,"");if(Z&&/^[a-zA-Z-_]/.test(Z))X.push(Z)}let Y=X.join(" ");return p0.set($,Y),Y}function J0($){if(!$||typeof $!=="string")return"";let J=y0.get($);if(J!==void 0)return J;let Y=O1($).replace(/[^a-zA-Z0-9-]/g,"").replace(/^-+|-+$/g,"").replace(/^\d+/,"")||"";return y0.set($,Y),Y}function l0($){if(!$||typeof $!=="string")return!1;if($==="from"||$==="to")return!0;if(/^\d+(\.\d+)?%$/.test($)){let q=parseFloat($);return q>=0&&q<=100}return!1}function r0($=""){if(!F0){let q=":root".replace(/[.*+?^${}()|[\]\\]/g,"\\$&");F0=new RegExp(`${q}\\s*\\{[\\s\\S]*\\}`)}return F0}function M1($){if($.includes("Color")||$==="fill"||$==="stroke"||$==="accentColor"||$==="caretColor"||$==="border"||$==="outline"||$.includes("background")&&!$.includes("Size")&&!$.includes("Image"))return"colors";if(/^(margin|padding|gap|inset|top|right|bottom|left|rowGap|columnGap|gridGap|gridRowGap|gridColumnGap)/.test($)||$.includes("Block")||$.includes("Inline"))return"space";if(/(width|height|size|basis)$/i.test($)||$.includes("BlockSize")||$.includes("InlineSize"))return"sizes";if($==="fontSize"||$==="font"&&!$.includes("Family"))return"fontSizes";if($==="fontFamily"||$.includes("FontFamily"))return"fonts";if($==="fontWeight"||$.includes("FontWeight"))return"fontWeights";if($==="letterSpacing"||$.includes("LetterSpacing"))return"letterSpacings";if($.includes("Radius")||$.includes("radius"))return"radii";if($.includes("Shadow")||$.includes("shadow")||$==="filter"||$==="backdropFilter")return"shadows";if($==="zIndex"||$.includes("ZIndex")||$.includes("z-index"))return"zIndices";if($==="opacity"||$.includes("Opacity"))return"opacities";if($.startsWith("transition")||$.startsWith("animation")||$.includes("Transition")||$.includes("Animation"))return"transitions";return}function s0($,J){if(J&&$ in J)return J[$];if($ in n)return n[$];return M1($)}var w0=new Map;function Y0($){return w0.has($)}function X0($,J){w0.set($,J)}var L0=new E(s);function e0($){if(!L0.has($))L0.set($,!0)}function a0(){return Array.from(L0.keys()).join(`
2
- `)}var q0=new Map;var t0=new Map;function $1($="stoop"){if(!w())throw new Error("Cannot access document in SSR context");let J=R($),q=q0.get(J);if(!q||!q.parentNode){let X=document.getElementById("stoop-ssr");if(X){let Y=X.getAttribute("data-stoop");if(!Y||Y===J)return q=X,q.setAttribute("data-stoop",J),q0.set(J,q),q}q=document.createElement("style"),q.setAttribute("data-stoop",J),q.setAttribute("id",`stoop-${J}`),document.head.appendChild(q),q0.set(J,q)}return q}function B0($){let J=$,q=r0("");J=J.replace(q,"").trim();let X=J.indexOf("[data-theme=");while(X!==-1){let Y=J.indexOf("{",X);if(Y===-1)break;let Q=1,G=Y+1;while(G<J.length&&Q>0){if(J[G]==="{")Q++;else if(J[G]==="}")Q--;G++}if(Q===0){let Z=J.substring(0,X).trim(),W=J.substring(G).trim();J=(Z+`
3
- `+W).trim()}else break;X=J.indexOf("[data-theme=")}return J.trim()}function J1($,J="stoop"){if(!$)return;let q=R(J),X=`__all_theme_vars_${q}`;if((t0.get(X)??null)===$)return;if(t0.set(X,$),!w()){e0($);return}let Q=$1(q),G=Q.textContent||"",Z=G.includes(":root")||G.includes("[data-theme=");if(Y0(X)||Z){let W=B0(G);Q.textContent=$+(W?`
1
+ var s=Object.freeze({}),a=1e4,kJ=5000,SJ=10,dJ=500,d=1000,uJ=31536000,yJ="/",UJ=["colors","opacities","space","radii","sizes","fonts","fontWeights","fontSizes","lineHeights","letterSpacings","shadows","zIndices","transitions"],n={accentColor:"colors",animation:"transitions",animationDelay:"transitions",animationDuration:"transitions",animationTimingFunction:"transitions",backdropFilter:"shadows",background:"colors",backgroundColor:"colors",blockSize:"sizes",border:"colors",borderBlockColor:"colors",borderBlockEndColor:"colors",borderBlockStartColor:"colors",borderBottomColor:"colors",borderBottomLeftRadius:"radii",borderBottomRightRadius:"radii",borderColor:"colors",borderEndEndRadius:"radii",borderEndStartRadius:"radii",borderInlineColor:"colors",borderInlineEndColor:"colors",borderInlineStartColor:"colors",borderLeftColor:"colors",borderRadius:"radii",borderRightColor:"colors",borderStartEndRadius:"radii",borderStartStartRadius:"radii",borderTopColor:"colors",borderTopLeftRadius:"radii",borderTopRightRadius:"radii",bottom:"space",boxShadow:"shadows",caretColor:"colors",color:"colors",columnGap:"space",columnRuleColor:"colors",fill:"colors",filter:"shadows",flexBasis:"sizes",floodColor:"colors",font:"fontSizes",fontFamily:"fonts",fontSize:"fontSizes",fontWeight:"fontWeights",gap:"space",gridColumnGap:"space",gridGap:"space",gridRowGap:"space",height:"sizes",inlineSize:"sizes",inset:"space",insetBlock:"space",insetBlockEnd:"space",insetBlockStart:"space",insetInline:"space",insetInlineEnd:"space",insetInlineStart:"space",left:"space",letterSpacing:"letterSpacings",lightingColor:"colors",lineHeight:"lineHeights",margin:"space",marginBlock:"space",marginBlockEnd:"space",marginBlockStart:"space",marginBottom:"space",marginInline:"space",marginInlineEnd:"space",marginInlineStart:"space",marginLeft:"space",marginRight:"space",marginTop:"space",maxBlockSize:"sizes",maxHeight:"sizes",maxInlineSize:"sizes",maxWidth:"sizes",minBlockSize:"sizes",minHeight:"sizes",minInlineSize:"sizes",minWidth:"sizes",opacity:"opacities",outline:"colors",outlineColor:"colors",padding:"space",paddingBlock:"space",paddingBlockEnd:"space",paddingBlockStart:"space",paddingBottom:"space",paddingInline:"space",paddingInlineEnd:"space",paddingInlineStart:"space",paddingLeft:"space",paddingRight:"space",paddingTop:"space",right:"space",rowGap:"space",size:"sizes",stopColor:"colors",stroke:"colors",textDecorationColor:"colors",textEmphasisColor:"colors",textShadow:"shadows",top:"space",transition:"transitions",transitionDelay:"transitions",transitionDuration:"transitions",transitionProperty:"transitions",transitionTimingFunction:"transitions",width:"sizes",zIndex:"zIndices"},t=Symbol.for("stoop.component");class V extends Map{maxSize;constructor(J){super();this.maxSize=J}get(J){let $=super.get(J);if($!==void 0)super.delete(J),super.set(J,$);return $}set(J,$){if(super.has(J))super.delete(J);else if(this.size>=this.maxSize){let q=this.keys().next().value;if(q!==void 0)super.delete(q)}return super.set(J,$),this}}var hJ=new V(kJ),HJ=new V(a);function O(){return typeof window!=="undefined"&&typeof document!=="undefined"&&typeof window.document==="object"&&typeof document.createElement==="function"}function u(){return typeof process!=="undefined"&&process.env?.NODE_ENV==="production"}function e(J){return typeof J==="object"&&J!==null}function m(J){return typeof J==="object"&&J!==null&&"__isStoopStyled"in J&&"__stoopClassName"in J&&J.__isStoopStyled===!0}function JJ(J){return e(J)&&!m(J)}function FJ(J){return typeof J==="object"&&J!==null&&!Array.isArray(J)}function $J(J){if(!J||typeof J!=="object"||Array.isArray(J))throw new Error("[Stoop] Theme must be a non-null object");if(u())return J;let $=J,q=[];for(let X in $){if(X==="media")continue;if(!UJ.includes(X))q.push(X)}if(q.length>0){let X=`[Stoop] Theme contains invalid scales: ${q.join(", ")}. Only these scales are allowed: ${UJ.join(", ")}`;throw new Error(X)}return J}function o(J,$){if(!$||!J||typeof J!=="object")return J;let q=Object.keys($),X=!1;for(let Z in J)if(q.includes(Z)){X=!0;break}if(!X)return J;let Y={};for(let Z in J){let G=J[Z];if(q.includes(Z)&&$[Z])try{let W=$[Z](G);if(W&&typeof W==="object")for(let Q in W)Y[Q]=W[Q]}catch{Y[Z]=G}else if(e(G))Y[Z]=o(G,$);else Y[Z]=G}return Y}var LJ=null,cJ=new V(d),pJ=new V(d),nJ=new V(d);function C(J){if(J.length===0)return"0";let $=2166136261,q=16777619,X=$;for(let Y=0;Y<J.length;Y++)X^=J.charCodeAt(Y),X=Math.imul(X,q);return X^=J.length,(X>>>0).toString(36)}function wJ(J){try{return C(JSON.stringify(J))}catch{return C(String(J))}}function mJ(J,$=!1){let X=String(J).replace(/\\/g,"\\\\").replace(/"/g,"\\\"").replace(/'/g,"\\'").replace(/;/g,"\\;").replace(/\n/g,"\\A ").replace(/\r/g,"").replace(/\f/g,"\\C ");if($)X=X.replace(/\{/g,"\\7B ").replace(/\}/g,"\\7D ");return X}function BJ(J){return mJ(J,!1)}function b(J){let $=cJ.get(J);if($!==void 0)return $;let q=J.replace(/[^a-zA-Z0-9\s\-_>+~:.#[\]&@()]/g,""),X=!q.trim()||/^[>+~:.#[\]&@()\s]+$/.test(q)?"":q;return cJ.set(J,X),X}function v(J){let $=nJ.get(J);if($!==void 0)return $;let Y=J.replace(/[^a-zA-Z0-9-_]/g,"-").replace(/^[\d-]+/,"").replace(/^-+/,"")||"invalid";return nJ.set(J,Y),Y}function oJ(J){return mJ(J,!0)}function K(J){if(!J)return"stoop";return J.replace(/[^a-zA-Z0-9-_]/g,"").replace(/^[\d-]+/,"").replace(/^-+/,"")||"stoop"}function iJ(J){if(!J||typeof J!=="string")return"";let $=J.replace(/[^a-zA-Z0-9\s():,<>=\-@]/g,"");if(!$.trim()||!/[a-zA-Z]/.test($))return"";return $}function lJ(J){if(!J||typeof J!=="string")return"";let $=pJ.get(J);if($!==void 0)return $;let q=J.trim().split(/\s+/),X=[];for(let Z of q){if(!Z)continue;let W=Z.replace(/[^a-zA-Z0-9-_]/g,"").replace(/^\d+/,"");if(W&&/^[a-zA-Z-_]/.test(W))X.push(W)}let Y=X.join(" ");return pJ.set(J,Y),Y}function rJ(J){if(!J||typeof J!=="string")return!1;if(J==="from"||J==="to")return!0;if(/^\d+(\.\d+)?%$/.test(J)){let q=parseFloat(J);return q>=0&&q<=100}return!1}function sJ(J=""){if(!LJ){let q=":root".replace(/[.*+?^${}()|[\]\\]/g,"\\$&");LJ=new RegExp(`${q}\\s*\\{[\\s\\S]*\\}`)}return LJ}function M0(J){if(J.includes("Color")||J==="fill"||J==="stroke"||J==="accentColor"||J==="caretColor"||J==="border"||J==="outline"||J.includes("background")&&!J.includes("Size")&&!J.includes("Image"))return"colors";if(/^(margin|padding|gap|inset|top|right|bottom|left|rowGap|columnGap|gridGap|gridRowGap|gridColumnGap)/.test(J)||J.includes("Block")||J.includes("Inline"))return"space";if(/(width|height|size|basis)$/i.test(J)||J.includes("BlockSize")||J.includes("InlineSize"))return"sizes";if(J==="fontSize"||J==="font"&&!J.includes("Family"))return"fontSizes";if(J==="fontFamily"||J.includes("FontFamily"))return"fonts";if(J==="fontWeight"||J.includes("FontWeight"))return"fontWeights";if(J==="letterSpacing"||J.includes("LetterSpacing"))return"letterSpacings";if(J.includes("Radius")||J.includes("radius"))return"radii";if(J.includes("Shadow")||J.includes("shadow")||J==="filter"||J==="backdropFilter")return"shadows";if(J==="zIndex"||J.includes("ZIndex")||J.includes("z-index"))return"zIndices";if(J==="opacity"||J.includes("Opacity"))return"opacities";if(J.startsWith("transition")||J.startsWith("animation")||J.includes("Transition")||J.includes("Animation"))return"transitions";return}function aJ(J,$){if($&&J in $)return $[J];if(J in n)return n[J];return M0(J)}var _J=new Map;function YJ(J){return _J.has(J)}function XJ(J,$){_J.set(J,$)}var AJ=new V(a);function J0(J){if(!AJ.has(J))AJ.set(J,!0)}function tJ(){return Array.from(AJ.keys()).join(`
2
+ `)}var qJ=new Map;var eJ=new Map;function $0(J="stoop"){if(!O())throw new Error("Cannot access document in SSR context");let $=K(J),q=qJ.get($);if(!q||!q.parentNode){let X=document.getElementById("stoop-ssr");if(X){let Y=X.getAttribute("data-stoop");if(!Y||Y===$)return q=X,q.setAttribute("data-stoop",$),qJ.set($,q),q}q=document.createElement("style"),q.setAttribute("data-stoop",$),q.setAttribute("id",`stoop-${$}`),document.head.appendChild(q),qJ.set($,q)}return q}function OJ(J){let $=J,q=sJ("");$=$.replace(q,"").trim();let X=$.indexOf("[data-theme=");while(X!==-1){let Y=$.indexOf("{",X);if(Y===-1)break;let Z=1,G=Y+1;while(G<$.length&&Z>0){if($[G]==="{")Z++;else if($[G]==="}")Z--;G++}if(Z===0){let W=$.substring(0,X).trim(),Q=$.substring(G).trim();$=(W+`
3
+ `+Q).trim()}else break;X=$.indexOf("[data-theme=")}return $.trim()}function q0(J,$="stoop"){if(!J)return;let q=K($),X=`__all_theme_vars_${q}`;if((eJ.get(X)??null)===J)return;if(eJ.set(X,J),!O()){J0(J);return}let Z=$0(q),G=Z.textContent||"",W=G.includes(":root")||G.includes("[data-theme=");if(YJ(X)||W){let Q=OJ(G);Z.textContent=J+(Q?`
4
4
 
5
- `+W:""),X0(X,$)}else Q.textContent=$+(G?`
5
+ `+Q:""),XJ(X,J)}else Z.textContent=J+(G?`
6
6
 
7
- `+G:""),X0(X,$)}function z1($,J,q="stoop"){if(!w())return;let X=R(q);if(Y0(J))return;let Y=$1(X),Q=Y.textContent||"";Y.textContent=Q+(Q?`
8
- `:"")+$,X0(J,$)}function E1($,J,q="stoop"){if(Y0(J))return;let X=R(q);z1($,J,X)}function K1($="stoop"){let J=R($);return q0.get(J)||null}function j1(){return new Map(w0)}function f($,J="stoop",q){let X=q||$;if(!w()){if(!Y0(X))X0(X,$);e0($);return}E1($,X,J)}function q1($="stoop"){if(w()){let J=R($),q=K1(J);if(q&&q.parentNode){let X=q.textContent||"";if(!X&&j1().size>0)return a0();return X}}return a0()}var P1=/(-?\$[a-zA-Z][a-zA-Z0-9]*(?:\$[a-zA-Z][a-zA-Z0-9]*)?(?:\.[a-zA-Z][a-zA-Z0-9]*)?)/g;function _0($){let J=new Map;function q(X,Y=[]){let Q=Object.keys(X);for(let G of Q){let Z=X[G],W=[...Y,G];if(H0(Z))q(Z,W);else{let U=J.get(G);if(U)U.push(W);else J.set(G,[W])}}}q($);for(let[,X]of J.entries())if(X.length>1)X.sort((Y,Q)=>{let G=Y.length-Q.length;if(G!==0)return G;let Z=Y.join("."),W=Q.join(".");return Z.localeCompare(W)});return J}function V1($,J){let q=Object.keys($).filter((Y)=>Y!=="media"),X=Object.keys(J).filter((Y)=>Y!=="media");if(q.length!==X.length)return!1;for(let Y of q)if(!(Y in J))return!1;return!0}function Y1($,J){if($===J)return!0;if(!$||!J)return!1;if(!V1($,J))return!1;let q={...$},X={...J};return delete q.media,delete X.media,JSON.stringify(q)===JSON.stringify(X)}function A0($,J,q){if(q&&q in $){let Q=$[q];if(Q&&typeof Q==="object"&&!Array.isArray(Q)&&J in Q)return[q,J]}let Y=_0($).get(J);if(!Y||Y.length===0)return null;return Y[0]}function X1($,J,q,X){if(!$.startsWith("$"))return $;let Y=$.slice(1);if(Y.includes("$")||Y.includes("."))return`var(${`--${(Y.includes("$")?Y.split("$"):Y.split(".")).map((D)=>C(D)).join("-")}`})`;if(J&&q){let Z=s0(q,X);if(Z){let H=A0(J,Y,Z);if(H)return`var(${`--${H.map((O)=>C(O)).join("-")}`})`}let U=_0(J).get(Y);if(U&&U.length>1){if(!u()){let H=Z?`Property "${q}" maps to "${Z}" scale, but token not found there. `:`No scale mapping found for property "${q}". `;console.warn(`[Stoop] Ambiguous token "$${Y}" found in multiple categories: ${U.map((F)=>F.join(".")).join(", ")}. ${H}Using "${U[0].join(".")}" (deterministic: shorter paths first, then alphabetical). Use full path "$${U[0].join(".")}" to be explicit.`)}}let D=A0(J,Y);if(D)return`var(${`--${D.map((L)=>C(L)).join("-")}`})`}else if(J){let W=_0(J).get(Y);if(W&&W.length>1){if(!u())console.warn(`[Stoop] Ambiguous token "$${Y}" found in multiple categories: ${W.map((D)=>D.join(".")).join(", ")}. Using "${W[0].join(".")}" (deterministic: shorter paths first, then alphabetical). Use full path "$${W[0].join(".")}" to be explicit, or use with a CSS property for automatic resolution.`)}let U=A0(J,Y);if(U)return`var(${`--${U.map((F)=>C(F)).join("-")}`})`}return`var(${`--${C(Y)}`})`}function I0($,J="stoop",q){let X=q||":root",Y=[];function Q(G,Z=[]){let W=Object.keys(G).sort();for(let U of W){if(U==="media")continue;let D=G[U],H=[...Z,U];if(H0(D))Q(D,H);else{let L=`--${H.map((_)=>C(_)).join("-")}`,O=typeof D==="string"||typeof D==="number"?m0(D):String(D);Y.push(` ${L}: ${O};`)}}}if(Q($),Y.length===0)return"";return`${X} {
7
+ `+G:""),XJ(X,J)}function E0(J,$,q="stoop"){if(!O())return;let X=K(q);if(YJ($))return;let Y=$0(X),Z=Y.textContent||"";Y.textContent=Z+(Z?`
8
+ `:"")+J,XJ($,J)}function K0(J,$,q="stoop"){if(YJ($))return;let X=K(q);E0(J,$,X)}function z0(J="stoop"){let $=K(J);return qJ.get($)||null}function V0(){return new Map(_J)}function y(J,$="stoop",q){let X=q||J;if(!O()){if(!YJ(X))XJ(X,J);J0(J);return}K0(J,X,$)}function X0(J="stoop"){if(O()){let $=K(J),q=z0($);if(q&&q.parentNode){let X=q.textContent||"";if(!X&&V0().size>0)return tJ();return X}}return tJ()}var P0=/(-?\$[a-zA-Z][a-zA-Z0-9]*(?:\$[a-zA-Z][a-zA-Z0-9]*)?(?:\.[a-zA-Z][a-zA-Z0-9]*)?)/g,Y0=new WeakMap;function IJ(J){let $=Y0.get(J);if($)return $;let q=new Map;function X(Y,Z=[]){let G=Object.keys(Y);for(let W of G){let Q=Y[W],D=[...Z,W];if(FJ(Q))X(Q,D);else{let U=q.get(W);if(U)U.push(D);else q.set(W,[D])}}}X(J);for(let[,Y]of q.entries())if(Y.length>1)Y.sort((Z,G)=>{let W=Z.length-G.length;if(W!==0)return W;let Q=Z.join("."),D=G.join(".");return Q.localeCompare(D)});return Y0.set(J,q),q}function j0(J,$){let q=Object.keys(J).filter((Y)=>Y!=="media"),X=Object.keys($).filter((Y)=>Y!=="media");if(q.length!==X.length)return!1;for(let Y of q)if(!(Y in $))return!1;return!0}function G0(J,$){if(J===$)return!0;if(!J||!$)return!1;if(!j0(J,$))return!1;let q={...J},X={...$};return delete q.media,delete X.media,JSON.stringify(q)===JSON.stringify(X)}function x0(J,$,q){if(q&&q in J){let Z=J[q];if(Z&&typeof Z==="object"&&!Array.isArray(Z)&&$ in Z)return[q,$]}let Y=IJ(J).get($);if(!Y||Y.length===0)return null;return Y[0]}function GJ(J,$,q,X){if(!J.startsWith("$"))return J;let Y=J.slice(1);if(Y.includes("$")||Y.includes("."))return`var(${`--${(Y.includes("$")?Y.split("$"):Y.split(".")).map((U)=>v(U)).join("-")}`})`;if($&&q){let W=aJ(q,X);if(W){let U=x0($,Y,W);if(U)return`var(${`--${U.map((L)=>v(L)).join("-")}`})`}let D=IJ($).get(Y);if(D&&D.length>1){if(!u()){let U=W?`Property "${q}" maps to "${W}" scale, but token not found there. `:`No scale mapping found for property "${q}". `;console.warn(`[Stoop] Ambiguous token "$${Y}" found in multiple categories: ${D.map((H)=>H.join(".")).join(", ")}. ${U}Using "${D[0].join(".")}" (deterministic: shorter paths first, then alphabetical). Use full path "$${D[0].join(".")}" to be explicit.`)}}if(D&&D.length>0)return`var(${`--${D[0].map((L)=>v(L)).join("-")}`})`}else if($){let Q=IJ($).get(Y);if(Q&&Q.length>1){if(!u())console.warn(`[Stoop] Ambiguous token "$${Y}" found in multiple categories: ${Q.map((D)=>D.join(".")).join(", ")}. Using "${Q[0].join(".")}" (deterministic: shorter paths first, then alphabetical). Use full path "$${Q[0].join(".")}" to be explicit, or use with a CSS property for automatic resolution.`)}if(Q&&Q.length>0)return`var(${`--${Q[0].map((F)=>v(F)).join("-")}`})`}return`var(${`--${v(Y)}`})`}function RJ(J,$="stoop",q){let X=q||":root",Y=[];function Z(G,W=[]){let Q=Object.keys(G).sort();for(let D of Q){if(D==="media")continue;let U=G[D],H=[...W,D];if(FJ(U))Z(U,H);else{let L=`--${H.map((w)=>v(w)).join("-")}`,_=typeof U==="string"||typeof U==="number"?oJ(U):String(U);Y.push(` ${L}: ${_};`)}}}if(Z(J),Y.length===0)return"";return`${X} {
9
9
  ${Y.join(`
10
10
  `)}
11
- }`}function G0($,J="stoop",q="data-theme"){let X=[];for(let[Y,Q]of Object.entries($)){let G=`[${q}="${Y}"]`,Z=I0(Q,J,G);if(Z)X.push(Z)}return X.join(`
11
+ }`}function QJ(J,$="stoop",q="data-theme"){let X=[];for(let[Y,Z]of Object.entries(J)){let G=`[${q}="${Y}"]`,W=RJ(Z,$,G);if(W)X.push(W)}return X.join(`
12
12
 
13
- `)}function k($,J,q,X){if(!$||typeof $!=="object")return $;let Y={},Q=!1,G=Object.keys($).sort();for(let Z of G){let W=$[Z];if(t(W)){let U=k(W,J,q,void 0);if(Y[Z]=U,U!==W)Q=!0}else if(typeof W==="string"&&W.includes("$")){Q=!0;let U=X||Z;Y[Z]=W.replace(P1,(D)=>{if(D.startsWith("-$")){let H=D.slice(1);return`calc(-1 * ${X1(H,J,U,q)})`}return X1(D,J,U,q)})}else Y[Z]=W}if(!Q)return $;return Y}function N1($,J){if(typeof $==="symbol"&&$===a)return!0;if(m(J))return!0;if(typeof $==="string"&&$.startsWith("__STOOP_COMPONENT_"))return!0;return!1}function x1($,J){if(typeof J==="object"&&J!==null&&"__stoopClassName"in J&&typeof J.__stoopClassName==="string")return J.__stoopClassName;if(typeof $==="string"&&$.startsWith("__STOOP_COMPONENT_"))return $.replace("__STOOP_COMPONENT_","");return""}function K($,J="",q=0,X){if(!$||typeof $!=="object")return"";if(q>C0)return"";let Y=[],Q=[],G=Object.keys($).sort();for(let W of G){let U=$[W];if(N1(W,U)){let D=x1(W,U);if(!D)continue;let H=T(D);if(!H)continue;let F=J?`${J} .${H}`:`.${H}`,L=U0(U)?K(U,F,q+1,X):"";if(L)Q.push(L);continue}if(U0(U))if(X&&W in X){let D=i0(X[W]);if(D){let H=K(U,J,q+1,X);if(H)Q.push(`${D} { ${H} }`)}}else if(W.startsWith("@")){let D=T(W);if(D){let H=K(U,J,q+1,X);if(H)Q.push(`${D} { ${H} }`)}}else if(W.includes("&")){let D=T(W);if(D){let F=D.split("&").join(J),L=K(U,F,q+1,X);if(L)Q.push(L)}}else if(W.startsWith(":")){let D=T(W);if(D){let H=`${J}${D}`,F=K(U,H,q+1,X);if(F)Q.push(F)}}else if(W.includes(" ")||W.includes(">")||W.includes("+")||W.includes("~")){let D=T(W);if(D){let F=/^[\s>+~]/.test(D.trim())?`${J}${D}`:`${J} ${D}`,L=K(U,F,q+1,X);if(L)Q.push(L)}}else{let D=T(W);if(D){let H=J?`${J} ${D}`:D,F=K(U,H,q+1,X);if(F)Q.push(F)}}else if(U!==void 0){let D=J0(W);if(D&&(typeof U==="string"||typeof U==="number")){let H=n0(U);Y.push(`${D}: ${H};`)}}}let Z=[];if(Y.length>0)Z.push(`${J} { ${Y.join(" ")} }`);return Z.push(...Q),Z.join("")}function p($,J,q="stoop",X,Y,Q){let G=R(q),Z=i($,Y),W=k(Z,J,Q),U=K(W,"",0,X),D=y(U),H=G?`${G}-${D}`:`css-${D}`,F=`${G}:${H}`,L=D0.get(F);if(L)return f(L,G,F),H;let O=K(W,`.${H}`,0,X);return D0.set(F,O),d0.set(F,H),f(O,G,F),H}var G1=new Map;function Q1($,J="stoop"){let q=J||"";G1.set(q,$)}function v1($="stoop"){let J=$||"";return G1.get(J)||null}function R0($,J){let q={...$},X=Object.keys(J);for(let Y of X){if(Y==="media")continue;let Q=J[Y],G=$[Y];if(Q&&typeof Q==="object"&&!Array.isArray(Q)&&G&&typeof G==="object"&&!Array.isArray(G))q[Y]={...G,...Q};else if(Q!==void 0)q[Y]=Q}return q}function O0($,J="stoop"){let q=v1(J);if(!q)return $;if(Y1($,q))return $;return R0(q,$)}function Q0($,J="stoop",q="data-theme"){if(!w())return;let X={};for(let[Q,G]of Object.entries($))X[Q]=O0(G,J);let Y=G0(X,J,q);J1(Y,J)}function Z1($){return function J(q={}){let X=e(q);return R0($,X)}}function W1($,J="stoop",q,X,Y){return function Q(G){return p(G,$,J,q,X,Y)}}function b1($,J,q,X){let Y=`@keyframes ${J} {`,Q=Object.keys($).sort((G,Z)=>{let W=parseFloat(G.replace("%","")),U=parseFloat(Z.replace("%",""));if(G==="from")return-1;if(Z==="from")return 1;if(G==="to")return 1;if(Z==="to")return-1;return W-U});for(let G of Q){if(!l0(G))continue;let Z=$[G];if(!Z||typeof Z!=="object")continue;Y+=` ${G} {`;let W=k(Z,q,X),U=Object.keys(W).sort();for(let D of U){let H=W[D];if(H!==void 0&&(typeof H==="string"||typeof H==="number")){let F=J0(D);if(F){let L=String(H);Y+=` ${F}: ${L};`}}}Y+=" }"}return Y+=" }",Y}function D1($="stoop",J,q){let X=R($),Y=new E(f0);return function Q(G){let Z=$0(G),W=Y.get(Z);if(W)return W;let U=Z.slice(0,8),D=X?`${X}-${U}`:`stoop-${U}`,H=b1(G,D,J,q),F=`__keyframes_${D}`;return f(H,X,F),Y.set(Z,D),D}}var M0=new Set;function U1($,J="stoop",q,X,Y){return function Q(G){let Z=$0(G);if(M0.has(Z))return()=>{};M0.add(Z);let W=R(J),U=i(G,X),D=k(U,$,Y),H=K(D,"",0,q);return f(H,W,`__global_${Z}`),()=>{M0.delete(Z)}}}import{useMemo as Z0,forwardRef as g1,createElement as T1,useContext as C1,createContext as f1}from"react";function H1($,J,q){let X=!1,Y=[];for(let G in $){let Z=J[G];if(Z===void 0)continue;let W=$[G],U=Z===!0?"true":Z===!1?"false":String(Z);if(W[U])Y.push(W[U]),X=!0}if(!X)return q;let Q={...Y[0]};for(let G=1;G<Y.length;G++)Object.assign(Q,Y[G]);return{...q,...Q}}var z0=null;function k1(){if(!z0)z0=f1(null);return z0}function S1($){return{__isStoopStyled:!0,__stoopClassName:$,[a]:$,toString:()=>`__STOOP_COMPONENT_${$}`}}function d1($){return m($)}var u1=new Set(["alignContent","alignItems","alignSelf","animation","animationDelay","animationDirection","animationDuration","animationFillMode","animationIterationCount","animationName","animationPlayState","animationTimingFunction","aspectRatio","backdropFilter","backfaceVisibility","background","backgroundAttachment","backgroundBlendMode","backgroundClip","backgroundColor","backgroundImage","backgroundOrigin","backgroundPosition","backgroundRepeat","backgroundSize","border","borderBottom","borderBottomColor","borderBottomLeftRadius","borderBottomRightRadius","borderBottomStyle","borderBottomWidth","borderCollapse","borderColor","borderImage","borderImageOutset","borderImageRepeat","borderImageSlice","borderImageSource","borderImageWidth","borderLeft","borderLeftColor","borderLeftStyle","borderLeftWidth","borderRadius","borderRight","borderRightColor","borderRightStyle","borderRightWidth","borderSpacing","borderStyle","borderTop","borderTopColor","borderTopLeftRadius","borderTopRightRadius","borderTopStyle","borderTopWidth","borderWidth","bottom","boxShadow","boxSizing","captionSide","caretColor","clear","clip","clipPath","color","columnCount","columnFill","columnGap","columnRule","columnRuleColor","columnRuleStyle","columnRuleWidth","columnSpan","columnWidth","columns","content","counterIncrement","counterReset","cursor","direction","display","emptyCells","filter","flex","flexBasis","flexDirection","flexFlow","flexGrow","flexShrink","flexWrap","float","font","fontFamily","fontFeatureSettings","fontKerning","fontLanguageOverride","fontSize","fontSizeAdjust","fontStretch","fontStyle","fontSynthesis","fontVariant","fontVariantAlternates","fontVariantCaps","fontVariantEastAsian","fontVariantLigatures","fontVariantNumeric","fontVariantPosition","fontWeight","gap","grid","gridArea","gridAutoColumns","gridAutoFlow","gridAutoRows","gridColumn","gridColumnEnd","gridColumnGap","gridColumnStart","gridGap","gridRow","gridRowEnd","gridRowGap","gridRowStart","gridTemplate","gridTemplateAreas","gridTemplateColumns","gridTemplateRows","height","hyphens","imageOrientation","imageRendering","imageResolution","imeMode","inlineSize","isolation","justifyContent","justifyItems","justifySelf","left","letterSpacing","lineHeight","listStyle","listStyleImage","listStylePosition","listStyleType","margin","marginBottom","marginLeft","marginRight","marginTop","maxHeight","maxWidth","minHeight","minWidth","objectFit","objectPosition","opacity","order","orphans","outline","outlineColor","outlineOffset","outlineStyle","outlineWidth","overflow","overflowWrap","overflowX","overflowY","padding","paddingBottom","paddingLeft","paddingRight","paddingTop","pageBreakAfter","pageBreakBefore","pageBreakInside","perspective","perspectiveOrigin","placeContent","placeItems","placeSelf","pointerEvents","position","quotes","resize","right","rowGap","scrollBehavior","tabSize","tableLayout","textAlign","textAlignLast","textDecoration","textDecorationColor","textDecorationLine","textDecorationStyle","textIndent","textJustify","textOverflow","textShadow","textTransform","textUnderlinePosition","top","transform","transformOrigin","transformStyle","transition","transitionDelay","transitionDuration","transitionProperty","transitionTimingFunction","unicodeBidi","userSelect","verticalAlign","visibility","whiteSpace","width","wordBreak","wordSpacing","wordWrap","writingMode","zIndex"]);function y1($){return u1.has($)}function p1($,J){let q=J?new Set(Object.keys(J)):new Set,X={},Y={},Q={};for(let G in $)if(q.has(G))X[G]=$[G];else if(y1(G))Y[G]=$[G];else Q[G]=$[G];return{cssProps:Y,elementProps:Q,variantProps:X}}function F1($,J="stoop",q,X,Y,Q){return function G(Z,W,U){let D=W||r,H=U;if(W&&"variants"in W&&typeof W.variants==="object"){H=W.variants;let{variants:v,...x}=W;D=x}let F;if(typeof Z!=="string"&&d1(Z))F=Z.__stoopClassName;let L=g1(function v(x,j){let{as:z,className:P,css:M,...N}=x,b=z||Z,g=Z0(()=>M&&typeof M==="object"&&M!==null?M:r,[M]),{cssProps:B,elementProps:V,variantProps:S}=p1(N,H),l=C1(Q||k1())?.theme||$,x0=l.media?{...q,...l.media}:q,v0=Z0(()=>{if(!H)return"";let I=Object.entries(S);if(I.length===0)return"";return I.sort(([d],[h])=>d.localeCompare(h)).map(([d,h])=>`${d}:${String(h)}`).join("|")},[S]),b0=Z0(()=>{let I=D;if(H&&v0)I=H1(H,S,D);if(Object.keys(B).length>0)I=Object.assign({},I,B);if(g!==r)I=Object.assign({},I,g);return I},[v0,g,B,D,H,S]),R1=Z0(()=>{let I=[];if(F)I.push(F);let d=p(b0,l,J,x0,X,Y);if(d)I.push(d);if(P){let h=typeof P==="string"?P:String(P),g0=o0(h);if(g0)I.push(g0)}return I.length>0?I.join(" "):void 0},[b0,P,F,l,J,x0,X,Y]);return T1(b,{...V,className:R1,ref:j})}),O=y(JSON.stringify(D)),_=`${J}-${O}`,A=L;return A.selector=S1(_),A}}import{createContext as w1,useCallback as B1,useContext as h1,useLayoutEffect as o,useMemo as P0,useRef as V0,useState as c1}from"react";function E0($){if(!w())return{error:"Not in browser environment",success:!1,value:null};try{return{source:"localStorage",success:!0,value:localStorage.getItem($)}}catch(J){return{error:J instanceof Error?J.message:"localStorage access failed",success:!1,value:null}}}function K0($,J){if(!w())return{error:"Not in browser environment",success:!1,value:void 0};try{return localStorage.setItem($,J),{success:!0,value:void 0}}catch(q){return{error:q instanceof Error?q.message:"localStorage write failed",success:!1,value:void 0}}}function j0($){if(!w())return null;let q=`; ${document.cookie}`.split(`; ${$}=`);if(q.length===2)return q.pop()?.split(";").shift()||null;return null}function L1($,J,q={}){if(!w())return!1;let{maxAge:X=k0,path:Y=S0,secure:Q=!1}=q;try{return document.cookie=`${$}=${J}; path=${Y}; max-age=${X}${Q?"; secure":""}`,!0}catch{return!1}}import{jsx as A1}from"react/jsx-runtime";function N0($,J,q){if(!w())return;let X=J?j0(J):null,Y=E0(q),Q=Y.success?Y.value:null;if(X===$&&Q!==$)K0(q,$);if(Q===$&&J&&X!==$)L1(J,$)}function n1($,J,q){if(!w())return null;if($!==void 0){let Q=j0($);if(Q&&q[Q])return Q}let X=E0(J),Y=X.success?X.value:null;if(Y&&q[Y])return Y;return null}function _1($,J,q="stoop",X,Y){let Q=w1(null),G=w1(null),Z=Object.keys($),W=Z[0]||"default",U=X&&Y?Y(X):void 0;function D({attribute:H="data-theme",children:F,cookieKey:L,defaultTheme:O,storageKey:_="stoop-theme"}){let[A,v]=c1(O||W),x=V0(!1);o(()=>{if(!w()||x.current)return;let B=n1(L,_,$);if(B){if(N0(B,L,_),B!==A)v(B)}x.current=!0},[L,_,$]),o(()=>{if(!w())return;let B=(V)=>{if(V.key===_&&V.newValue&&$[V.newValue]&&V.newValue!==A)v(V.newValue),N0(V.newValue,L,_)};return window.addEventListener("storage",B),()=>{window.removeEventListener("storage",B)}},[_,L,A,$]);let j=P0(()=>{return $[A]||$[O||W]||J},[A,O,W,$,J]),z=V0(!1),P=V0(!1);o(()=>{if(!w()||z.current)return;Q0($,q,H),z.current=!0},[$,q,H]),o(()=>{if(!w()||P.current)return;if(U)U(),P.current=!0},[U]),o(()=>{if(!w())return;if(H)document.documentElement.setAttribute(H,A)},[A,H]);let M=B1((B)=>{if($[B])v(B),K0(_,B),N0(B,L,_);else if(!u())console.warn(`[Stoop] Theme "${B}" not found. Available themes: ${Z.join(", ")}`)},[_,L,$,Z,A]),N=P0(()=>({theme:j,themeName:A}),[j,A]),b=B1(()=>{let V=(Z.indexOf(A)+1)%Z.length,S=Z[V];M(S)},[A,M,Z]),g=P0(()=>({availableThemes:Z,setTheme:M,theme:j,themeName:A,toggleTheme:b}),[j,A,M,b]);return A1(Q.Provider,{value:N,children:A1(G.Provider,{value:g,children:F})})}return{Provider:D,ThemeContext:Q,ThemeManagementContext:G}}function I1($){return function J(){let q=h1($);if(!q)throw new Error("useTheme must be used within a Provider");return q}}function m1($){let{globalCss:J,media:q,prefix:X="stoop",theme:Y,themeMap:Q,utils:G}=$,Z=R(X),W=e(Y),U=W.media||q,D={...n,...Q};Q1(W,Z);let H=W1(W,Z,U,G,D),F=Z1(W),L=U1(W,Z,U,G,D),O=D1(Z,W,D),_=Object.freeze({...W});function A(j){for(let z of j)try{p(z,W,Z,U,G,D)}catch{}}function v(j){if(!$.themes||Object.keys($.themes).length===0)return;Q0($.themes,Z)}function x(j){let z="";if($.themes&&Object.keys($.themes).length>0){let N={};for(let[g,B]of Object.entries($.themes))N[g]=O0(B,Z);let b=G0(N,Z,"data-theme");if(b)z+=b+`
14
- `}else{let N=I0(W,Z);if(N)z+=N+`
15
- `}let P=q1(),M=B0(P).trim();if(M)z+=(z?`
16
- `:"")+M;return z}return{config:{...$,prefix:Z},createTheme:F,css:H,getCssText:x,globalCss:L,globalCssConfig:J,keyframes:O,media:U,mergedThemeMap:D,preloadTheme:v,sanitizedPrefix:Z,theme:_,utils:G,validatedTheme:W,warmCache:A}}function U5($){let J=m1($),q,X,Y;if($.themes){let G={};for(let[D,H]of Object.entries($.themes))G[D]=J.createTheme(H);let{Provider:Z,ThemeContext:W,ThemeManagementContext:U}=_1(G,J.validatedTheme,J.sanitizedPrefix,J.globalCssConfig,J.globalCss);Y=W,q=Z,X=I1(U)}let Q=F1(J.validatedTheme,J.sanitizedPrefix,J.media,J.utils,J.mergedThemeMap,Y);return{config:J.config,createTheme:J.createTheme,css:J.css,getCssText:J.getCssText,globalCss:J.globalCss,keyframes:J.keyframes,preloadTheme:J.preloadTheme,Provider:q,styled:Q,theme:J.theme,useTheme:X,warmCache:J.warmCache}}export{m1 as createStoopBase,U5 as createStoop};
13
+ `)}function h(J,$,q,X){if(!J||typeof J!=="object")return J;let Y=Object.keys(J),Z=!1;for(let Q of Y){let D=J[Q];if(typeof D==="string"&&D.includes("$")){Z=!0;break}}if(!Z&&!$)return J;let G={},W=!1;for(let Q of Y){let D=J[Q];if(e(D)){let U=h(D,$,q,void 0);if(G[Q]=U,U!==D)W=!0}else if(typeof D==="string"&&D.includes("$")){W=!0;let U=X||Q;if(D.startsWith("$")&&!D.includes(" ")&&!D.includes("calc(")&&D===D.trim())if(D.startsWith("-$")){let F=D.slice(1);if(F.includes(".")||F.includes("$")){let L=F.includes("$")?F.split("$"):F.split("."),_=!1;for(let w=0;w<L.length;w++){let B=L[w];for(let I=0;I<B.length;I++){let A=B.charCodeAt(I);if(!(A>=48&&A<=57||A>=65&&A<=90||A>=97&&A<=122||A===45||A===95)){_=!0;break}}if(_)break}if(_){let B=`--${L.map((I)=>v(I)).join("-")}`;G[Q]=`calc(-1 * var(${B}))`}else{let w=`--${L.join("-")}`;G[Q]=`calc(-1 * var(${w}))`}}else{let L=GJ(F,$,U,q);G[Q]=`calc(-1 * ${L})`}}else{let F=D.slice(1);if(F.includes(".")||F.includes("$")){let L=F.includes("$")?F.split("$"):F.split("."),_=!1;for(let w=0;w<L.length;w++){let B=L[w];for(let I=0;I<B.length;I++){let A=B.charCodeAt(I);if(!(A>=48&&A<=57||A>=65&&A<=90||A>=97&&A<=122||A===45||A===95)){_=!0;break}}if(_)break}if(_){let B=`--${L.map((I)=>v(I)).join("-")}`;G[Q]=`var(${B})`}else{let w=`--${L.join("-")}`;G[Q]=`var(${w})`}}else G[Q]=GJ(D,$,U,q)}else G[Q]=D.replace(P0,(F)=>{if(F.startsWith("-$")){let L=F.slice(1);return`calc(-1 * ${GJ(L,$,U,q)})`}return GJ(F,$,U,q)})}else G[Q]=D}if(!W)return J;return G}var N=new V(d);function N0(J){return J.replace(/([A-Z])/g,"-$1").toLowerCase()}function g0(J){if(J===J.toUpperCase()&&J.length>1)return J.charAt(0)+J.slice(1).toLowerCase();return J}function ZJ(J){if(!J)return"";return J.charAt(0).toLowerCase()+J.slice(1).replace(/([A-Z])/g,"-$1").toLowerCase()}function i(J){if(!J||typeof J!=="string")return"";let $=N.get(J);if($!==void 0)return $;if(/^-[a-z]+-/.test(J))return N.set(J,J),J;let q=g0(J);if(/^[Mm]oz/i.test(q)){if(q.length===3||q.toLowerCase()==="moz")return N.set(J,"-moz"),"-moz";let G=q.match(/^[Mm]oz(.+)$/i);if(G&&G[1]){let[,W]=G,Q=ZJ(W);if(Q){let D=`-moz-${Q}`;return N.set(J,D),D}}}if(/^[Ww]ebkit/i.test(q)){if(q.length===6||q.toLowerCase()==="webkit")return N.set(J,"-webkit"),"-webkit";let G=q.match(/^[Ww]ebkit(.+)$/i);if(G&&G[1]){let[,W]=G,Q=ZJ(W);if(Q){let D=`-webkit-${Q}`;return N.set(J,D),D}}}if(/^[Mm]s/i.test(q)){if(q.length===2||q.toLowerCase()==="ms")return N.set(J,"-ms"),"-ms";let G=q.match(/^[Mm]s(.+)$/i);if(G&&G[1]){let[,W]=G,Q=ZJ(W);if(Q){let D=`-ms-${Q}`;return N.set(J,D),D}}}if(/^O/i.test(q)){if(q.length===1||q.toLowerCase()==="o")return N.set(J,"-o"),"-o";if(/^O[A-Z]/.test(q)){let G=q.substring(1),W=ZJ(G);if(W){let Q=`-o-${W}`;return N.set(J,Q),Q}}}let Z=N0(q).replace(/[^a-zA-Z0-9-]/g,"").replace(/^-+|-+$/g,"").replace(/^\d+/,"")||"";return N.set(J,Z),Z}function Q0(J,$){if(typeof J==="symbol"&&J===t)return!0;if(m($))return!0;if(typeof J==="string"&&J.startsWith("__STOOP_COMPONENT_"))return!0;return!1}function v0(J,$){if(typeof $==="object"&&$!==null&&"__stoopClassName"in $&&typeof $.__stoopClassName==="string")return $.__stoopClassName;if(typeof J==="string"&&J.startsWith("__STOOP_COMPONENT_"))return J.replace("__STOOP_COMPONENT_","");return""}function g(J,$="",q=0,X){if(!J||typeof J!=="object")return"";if(q>SJ)return"";let Y=[],Z=[],G=$===""?Object.keys(J).sort():Object.keys(J);for(let Q of G){let D=J[Q];if(Q0(Q,D)){let U=v0(Q,D);if(!U)continue;let H=b(U);if(!H)continue;let F=$?`${$} .${H}`:`.${H}`,L=JJ(D)?g(D,F,q+1,X):"";if(L)Z.push(L);continue}if(JJ(D))if(X&&Q in X){let U=iJ(X[Q]);if(U){let H=g(D,$,q+1,X);if(H)Z.push(`${U} { ${H} }`)}}else if(Q.startsWith("@")){let U=b(Q);if(U){let H=g(D,$,q+1,X);if(H)Z.push(`${U} { ${H} }`)}}else if(Q.includes("&")){let U=b(Q);if(U){let F=U.split("&").join($),L=g(D,F,q+1,X);if(L)Z.push(L)}}else if(Q.startsWith(":")){let U=b(Q);if(U){let H=`${$}${U}`,F=g(D,H,q+1,X);if(F)Z.push(F)}}else if(Q.includes(" ")||Q.includes(">")||Q.includes("+")||Q.includes("~")){let U=b(Q);if(U){let F=/^[\s>+~]/.test(U.trim())?`${$}${U}`:`${$} ${U}`,L=g(D,F,q+1,X);if(L)Z.push(L)}}else{let U=b(Q);if(U){let H=$?`${$} ${U}`:U,F=g(D,H,q+1,X);if(F)Z.push(F)}}else if(D!==void 0){let U=i(Q);if(U&&(typeof D==="string"||typeof D==="number")){let H=BJ(D);Y.push(`${U}: ${H};`)}}}let W=[];if(Y.length>0)W.push(`${$} { ${Y.join(" ")} }`);return W.push(...Z),W.join("")}function T0(J,$){if(!J||typeof J!=="object")return"";let q=[],X=Object.keys(J).sort();for(let Y of X){let Z=J[Y];if(JJ(Z))return"";if($&&Y in $)return"";if(Y.startsWith("@")||Y.includes("&")||Y.startsWith(":")||Y.includes(" ")||Y.includes(">")||Y.includes("+")||Y.includes("~"))return"";if(Z!==void 0&&!Q0(Y,Z)){let G=i(Y);if(G&&(typeof Z==="string"||typeof Z==="number")){let W=BJ(Z);q.push(`${G}: ${W};`)}}}return q.join(" ")}function c(J,$,q="stoop",X,Y,Z){let G=K(q),W=o(J,Y),Q=h(W,$,Z),D=T0(Q,X),U,H;if(D)U=D,H=C(U);else U=g(Q,"",0,X),H=C(U);let F=G?`${G}-${H}`:`css-${H}`,L=`${G}:${F}`,_=HJ.get(L);if(_)return y(_,G,L),F;let w;if(D)w=`.${F} { ${D} }`;else w=g(Q,`.${F}`,0,X);return HJ.set(L,w),hJ.set(L,F),y(w,G,L),F}var Z0=new Map;function W0(J,$="stoop"){let q=$||"";Z0.set(q,J)}function f0(J="stoop"){let $=J||"";return Z0.get($)||null}function MJ(J,$){let q={...J},X=Object.keys($);for(let Y of X){if(Y==="media")continue;let Z=$[Y],G=J[Y];if(Z&&typeof Z==="object"&&!Array.isArray(Z)&&G&&typeof G==="object"&&!Array.isArray(G))q[Y]={...G,...Z};else if(Z!==void 0)q[Y]=Z}return q}function EJ(J,$="stoop"){let q=f0($);if(!q)return J;if(G0(J,q))return J;return MJ(q,J)}function WJ(J,$="stoop",q="data-theme"){if(!O())return;let X={};for(let[Z,G]of Object.entries(J))X[Z]=EJ(G,$);let Y=QJ(X,$,q);q0(Y,$)}function D0(J){return function $(q={}){let X=$J(q);return MJ(J,X)}}function U0(J,$="stoop",q,X,Y){return function Z(G){return c(G,J,$,q,X,Y)}}function C0(J,$,q,X){let Y=`@keyframes ${$} {`,Z=Object.keys(J).sort((G,W)=>{let Q=parseFloat(G.replace("%","")),D=parseFloat(W.replace("%",""));if(G==="from")return-1;if(W==="from")return 1;if(G==="to")return 1;if(W==="to")return-1;return Q-D});for(let G of Z){if(!rJ(G))continue;let W=J[G];if(!W||typeof W!=="object")continue;Y+=` ${G} {`;let Q=h(W,q,X),D=Object.keys(Q).sort();for(let U of D){let H=Q[U];if(H!==void 0&&(typeof H==="string"||typeof H==="number")){let F=i(U);if(F){let L=String(H);Y+=` ${F}: ${L};`}}}Y+=" }"}return Y+=" }",Y}function H0(J="stoop",$,q){let X=K(J),Y=new V(dJ);return function Z(G){let W=wJ(G),Q=Y.get(W);if(Q)return Q;let D=W.slice(0,8),U=X?`${X}-${D}`:`stoop-${D}`,H=C0(G,U,$,q),F=`__keyframes_${U}`;return y(H,X,F),Y.set(W,U),U}}var KJ=new Set;function F0(J,$="stoop",q,X,Y){return function Z(G){let W=wJ(G);if(KJ.has(W))return()=>{};KJ.add(W);let Q=K($),D=o(G,X),U=h(D,J,Y),H=g(U,"",0,q);return y(H,Q,`__global_${W}`),()=>{KJ.delete(W)}}}import{useMemo as DJ,forwardRef as b0,createElement as k0,useContext as S0,createContext as d0}from"react";function u0(J,$,q){let X=[];for(let Z in J){let G=$[Z];if(G===void 0)continue;let W=J[Z],Q=G===!0?"true":G===!1?"false":String(G);if(W[Q])X.push(W[Q])}if(X.length===0)return q;if(X.length===1)return{...q,...X[0]};let Y={...X[0]};for(let Z=1;Z<X.length;Z++)Object.assign(Y,X[Z]);return{...q,...Y}}var zJ=null;function y0(){if(!zJ)zJ=d0(null);return zJ}function h0(J){return{__isStoopStyled:!0,__stoopClassName:J,[t]:J,toString:()=>`__STOOP_COMPONENT_${J}`}}function c0(J){return m(J)}var p0=new Set(["alignContent","alignItems","alignSelf","animation","animationDelay","animationDirection","animationDuration","animationFillMode","animationIterationCount","animationName","animationPlayState","animationTimingFunction","aspectRatio","backdropFilter","backfaceVisibility","background","backgroundAttachment","backgroundBlendMode","backgroundClip","backgroundColor","backgroundImage","backgroundOrigin","backgroundPosition","backgroundRepeat","backgroundSize","border","borderBottom","borderBottomColor","borderBottomLeftRadius","borderBottomRightRadius","borderBottomStyle","borderBottomWidth","borderCollapse","borderColor","borderImage","borderImageOutset","borderImageRepeat","borderImageSlice","borderImageSource","borderImageWidth","borderLeft","borderLeftColor","borderLeftStyle","borderLeftWidth","borderRadius","borderRight","borderRightColor","borderRightStyle","borderRightWidth","borderSpacing","borderStyle","borderTop","borderTopColor","borderTopLeftRadius","borderTopRightRadius","borderTopStyle","borderTopWidth","borderWidth","bottom","boxShadow","boxSizing","captionSide","caretColor","clear","clip","clipPath","color","columnCount","columnFill","columnGap","columnRule","columnRuleColor","columnRuleStyle","columnRuleWidth","columnSpan","columnWidth","columns","content","counterIncrement","counterReset","cursor","direction","display","emptyCells","filter","flex","flexBasis","flexDirection","flexFlow","flexGrow","flexShrink","flexWrap","float","font","fontFamily","fontFeatureSettings","fontKerning","fontLanguageOverride","fontSize","fontSizeAdjust","fontStretch","fontStyle","fontSynthesis","fontVariant","fontVariantAlternates","fontVariantCaps","fontVariantEastAsian","fontVariantLigatures","fontVariantNumeric","fontVariantPosition","fontWeight","gap","grid","gridArea","gridAutoColumns","gridAutoFlow","gridAutoRows","gridColumn","gridColumnEnd","gridColumnGap","gridColumnStart","gridGap","gridRow","gridRowEnd","gridRowGap","gridRowStart","gridTemplate","gridTemplateAreas","gridTemplateColumns","gridTemplateRows","height","hyphens","imageOrientation","imageRendering","imageResolution","imeMode","inlineSize","isolation","justifyContent","justifyItems","justifySelf","left","letterSpacing","lineHeight","listStyle","listStyleImage","listStylePosition","listStyleType","margin","marginBottom","marginLeft","marginRight","marginTop","maxHeight","maxWidth","minHeight","minWidth","objectFit","objectPosition","opacity","order","orphans","outline","outlineColor","outlineOffset","outlineStyle","outlineWidth","overflow","overflowWrap","overflowX","overflowY","padding","paddingBottom","paddingLeft","paddingRight","paddingTop","pageBreakAfter","pageBreakBefore","pageBreakInside","perspective","perspectiveOrigin","placeContent","placeItems","placeSelf","pointerEvents","position","quotes","resize","right","rowGap","scrollBehavior","tabSize","tableLayout","textAlign","textAlignLast","textDecoration","textDecorationColor","textDecorationLine","textDecorationStyle","textIndent","textJustify","textOverflow","textShadow","textTransform","textUnderlinePosition","top","transform","transformOrigin","transformStyle","transition","transitionDelay","transitionDuration","transitionProperty","transitionTimingFunction","unicodeBidi","userSelect","verticalAlign","visibility","whiteSpace","width","wordBreak","wordSpacing","wordWrap","writingMode","zIndex"]);function n0(J){return p0.has(J)}function m0(J,$){let q=$?new Set(Object.keys($)):new Set,X={},Y={},Z={};for(let G in J)if(q.has(G))X[G]=J[G];else if(n0(G))Y[G]=J[G];else Z[G]=J[G];return{cssProps:Y,elementProps:Z,variantProps:X}}function L0(J,$="stoop",q,X,Y,Z){return function G(W,Q){let D=Q||s,U;if(Q&&"variants"in Q&&typeof Q.variants==="object"&&Q.variants!==null&&!Array.isArray(Q.variants)){let B=Q.variants;if(Object.keys(B).length>0&&Object.values(B).every((A)=>typeof A==="object"&&A!==null&&!Array.isArray(A))){U=Q.variants;let{variants:A,...R}=Q;D=R}}let H;if(typeof W!=="string"&&c0(W))H=W.__stoopClassName;let F=b0(function B(I,A){let{as:R,className:P,css:x,...j}=I,k=R||W,T=DJ(()=>x&&typeof x==="object"&&x!==null?x:s,[x]),{cssProps:f,elementProps:M,variantProps:z}=m0(j,U),r=S0(Z||y0())?.theme||J,TJ=r.media?{...q,...r.media}:q,fJ=DJ(()=>{if(!U)return"";let E=Object.entries(z);if(E.length===0)return"";return E.sort(([S],[p])=>S.localeCompare(p)).map(([S,p])=>`${S}:${String(p)}`).join("|")},[z]),CJ=DJ(()=>{let E=D;if(U&&fJ)E=u0(U,z,D);if(Object.keys(f).length>0)E=Object.assign({},E,f);if(T!==s)E=Object.assign({},E,T);return E},[fJ,T,f,D,U,z]),R0=DJ(()=>{let E=[];if(H)E.push(H);let S=c(CJ,r,$,TJ,X,Y);if(S)E.push(S);if(P){let p=typeof P==="string"?P:String(P),bJ=lJ(p);if(bJ)E.push(bJ)}return E.length>0?E.join(" "):void 0},[CJ,P,H,r,$,TJ,X,Y]);return k0(k,{...M,className:R0,ref:A})}),L=C(JSON.stringify(D)),_=`${$}-${L}`,w=F;return w.selector=h0(_),w}}import{createContext as B0,useCallback as A0,useContext as o0,useLayoutEffect as l,useMemo as xJ,useRef as NJ,useState as i0}from"react";function VJ(J){if(!O())return{error:"Not in browser environment",success:!1,value:null};try{return{source:"localStorage",success:!0,value:localStorage.getItem(J)}}catch($){return{error:$ instanceof Error?$.message:"localStorage access failed",success:!1,value:null}}}function PJ(J,$){if(!O())return{error:"Not in browser environment",success:!1,value:void 0};try{return localStorage.setItem(J,$),{success:!0,value:void 0}}catch(q){return{error:q instanceof Error?q.message:"localStorage write failed",success:!1,value:void 0}}}function jJ(J){if(!O())return null;let q=`; ${document.cookie}`.split(`; ${J}=`);if(q.length===2)return q.pop()?.split(";").shift()||null;return null}function w0(J,$,q={}){if(!O())return!1;let{maxAge:X=uJ,path:Y=yJ,secure:Z=!1}=q;try{return document.cookie=`${J}=${$}; path=${Y}; max-age=${X}${Z?"; secure":""}`,!0}catch{return!1}}import{jsx as _0}from"react/jsx-runtime";function gJ(J,$,q){if(!O())return;let X=$?jJ($):null,Y=VJ(q),Z=Y.success?Y.value:null;if(X===J&&Z!==J)PJ(q,J);if(Z===J&&$&&X!==J)w0($,J)}function l0(J,$,q){if(!O())return null;if(J!==void 0){let Z=jJ(J);if(Z&&q[Z])return Z}let X=VJ($),Y=X.success?X.value:null;if(Y&&q[Y])return Y;return null}function O0(J,$,q="stoop",X,Y){let Z=B0(null),G=B0(null),W=Object.keys(J),Q=W[0]||"default",D=X&&Y?Y(X):void 0;function U({attribute:H="data-theme",children:F,cookieKey:L,defaultTheme:_,storageKey:w="stoop-theme"}){let[B,I]=i0(_||Q),A=NJ(!1);l(()=>{if(!O()||A.current)return;let M=l0(L,w,J);if(M){if(gJ(M,L,w),M!==B)I(M)}A.current=!0},[L,w,J]),l(()=>{if(!O())return;let M=(z)=>{if(z.key===w&&z.newValue&&J[z.newValue]&&z.newValue!==B)I(z.newValue),gJ(z.newValue,L,w)};return window.addEventListener("storage",M),()=>{window.removeEventListener("storage",M)}},[w,L,B,J]);let R=xJ(()=>{return J[B]||J[_||Q]||$},[B,_,Q,J,$]),P=NJ(!1),x=NJ(!1);l(()=>{if(!O()||P.current)return;WJ(J,q,H),P.current=!0},[J,q,H]),l(()=>{if(!O()||x.current)return;if(D)D(),x.current=!0},[D]),l(()=>{if(!O())return;if(H)document.documentElement.setAttribute(H,B)},[B,H]);let j=A0((M)=>{if(J[M])I(M),PJ(w,M),gJ(M,L,w);else if(!u())console.warn(`[Stoop] Theme "${M}" not found. Available themes: ${W.join(", ")}`)},[w,L,J,W,B]),k=xJ(()=>({theme:R,themeName:B}),[R,B]),T=A0(()=>{let z=(W.indexOf(B)+1)%W.length,vJ=W[z];j(vJ)},[B,j,W]),f=xJ(()=>({availableThemes:W,setTheme:j,theme:R,themeName:B,toggleTheme:T}),[R,B,j,T]);return _0(Z.Provider,{value:k,children:_0(G.Provider,{value:f,children:F})})}return{Provider:U,ThemeContext:Z,ThemeManagementContext:G}}function I0(J){return function $(){let q=o0(J);if(!q)throw new Error("useTheme must be used within a Provider");return q}}function r0(J){let{globalCss:$,media:q,prefix:X="stoop",theme:Y,themeMap:Z,utils:G}=J,W=K(X),Q=$J(Y),D=Q.media||q,U={...n,...Z};W0(Q,W);let H=U0(Q,W,D,G,U),F=D0(Q),L=F0(Q,W,D,G,U),_=H0(W,Q,U),w=Object.freeze({...Q});function B(R){for(let P of R)try{c(P,Q,W,D,G,U)}catch{}}function I(){if(!J.themes||Object.keys(J.themes).length===0)return;WJ(J.themes,W)}function A(){let R="";if(J.themes&&Object.keys(J.themes).length>0){let j={};for(let[T,f]of Object.entries(J.themes))j[T]=EJ(f,W);let k=QJ(j,W,"data-theme");if(k)R+=k+`
14
+ `}else{let j=RJ(Q,W);if(j)R+=j+`
15
+ `}let P=X0(),x=OJ(P).trim();if(x)R+=(R?`
16
+ `:"")+x;return R}return{config:{...J,prefix:W},createTheme:F,css:H,getCssText:A,globalCss:L,globalCssConfig:$,keyframes:_,media:D,mergedThemeMap:U,preloadTheme:I,sanitizedPrefix:W,theme:w,utils:G,validatedTheme:Q,warmCache:B}}function D4(J){let $=r0(J),q,X,Y;if(J.themes){let G={};for(let[U,H]of Object.entries(J.themes))G[U]=$.createTheme(H);let{Provider:W,ThemeContext:Q,ThemeManagementContext:D}=O0(G,$.validatedTheme,$.sanitizedPrefix,$.globalCssConfig,$.globalCss);Y=Q,q=W,X=I0(D)}let Z=L0($.validatedTheme,$.sanitizedPrefix,$.media,$.utils,$.mergedThemeMap,Y);return{config:$.config,createTheme:$.createTheme,css:$.css,getCssText:$.getCssText,globalCss:$.globalCss,keyframes:$.keyframes,preloadTheme:$.preloadTheme,Provider:q,styled:Z,theme:$.theme,useTheme:X,warmCache:$.warmCache}}export{r0 as createStoopBase,D4 as createStoop};
package/dist/inject.d.ts CHANGED
@@ -43,7 +43,6 @@ export declare function isInSSRCache(css: string): boolean;
43
43
  /**
44
44
  * Gets or creates the stylesheet element for CSS injection.
45
45
  * Reuses the SSR stylesheet if it exists to prevent FOUC.
46
- * Supports multiple Stoop instances with different prefixes.
47
46
  *
48
47
  * @param prefix - Optional prefix for stylesheet identification
49
48
  * @returns HTMLStyleElement
@@ -59,8 +58,7 @@ export declare function getStylesheet(prefix?: string): HTMLStyleElement;
59
58
  export declare function removeThemeVariableBlocks(css: string): string;
60
59
  /**
61
60
  * Injects CSS variables for all themes using attribute selectors.
62
- * This allows all themes to be available simultaneously, with theme switching
63
- * handled by changing the data-theme attribute.
61
+ * All themes are available simultaneously, with theme switching handled by changing the data-theme attribute.
64
62
  *
65
63
  * @param allThemeVars - CSS string containing all theme CSS variables
66
64
  * @param prefix - Optional prefix for CSS variables
@@ -90,7 +88,7 @@ export declare function injectBrowserCSS(css: string, ruleKey: string, prefix?:
90
88
  */
91
89
  export declare function getStylesheetElement(prefix?: string): HTMLStyleElement | null;
92
90
  /**
93
- * Gets all injected rules (for internal use).
91
+ * Gets all injected rules.
94
92
  */
95
93
  export declare function getAllInjectedRules(): Map<string, string>;
96
94
  /**
@@ -26,6 +26,17 @@ export type StylableElement = HTMLElements | ElementType;
26
26
  export interface StyledBaseProps {
27
27
  css?: CSS;
28
28
  }
29
+ /**
30
+ * CSS object that includes variants configuration.
31
+ * Used for styled component definitions that combine base styles with variants.
32
+ * This type explicitly requires the `variants` property to be present and of type Variants.
33
+ * We exclude variants from the CSS index signature to make it distinct.
34
+ */
35
+ export type CSSWithVariants = {
36
+ [K in keyof CSS as K extends "variants" ? never : K]: CSS[K];
37
+ } & {
38
+ variants: Variants;
39
+ };
29
40
  export type UtilityFunction = (value: CSSPropertyValue | CSS | undefined) => CSS;
30
41
  /**
31
42
  * Theme scale type - represents valid keys from DefaultTheme.
@@ -95,10 +106,10 @@ export interface StoopServerInstance {
95
106
  };
96
107
  createTheme: (themeOverride: Partial<Theme>) => Theme;
97
108
  css: (styles: CSS) => string;
98
- getCssText: (theme?: string | Theme) => string;
109
+ getCssText: () => string;
99
110
  globalCss: (...args: CSS[]) => () => void;
100
111
  keyframes: (definition: Record<string, CSS>) => string;
101
- preloadTheme: (theme: string | Theme) => void;
112
+ preloadTheme: () => void;
102
113
  theme: Theme;
103
114
  warmCache: (styles: CSS[]) => void;
104
115
  }
@@ -194,9 +205,11 @@ export type StyledComponent<DefaultElement extends ElementType, VariantsConfig e
194
205
  };
195
206
  /**
196
207
  * Styled function type - the main styled() function signature
208
+ * Variants must be embedded in the baseStyles object, matching Stitches API.
197
209
  */
198
210
  export interface StyledFunction {
199
- <DefaultElement extends StylableElement, VariantsConfig extends Variants = {}>(defaultElement: DefaultElement, baseStyles?: CSS, variants?: VariantsConfig): StyledComponent<DefaultElement, VariantsConfig>;
211
+ <DefaultElement extends StylableElement, BaseStyles extends CSSWithVariants>(defaultElement: DefaultElement, baseStyles: BaseStyles): StyledComponent<DefaultElement, BaseStyles["variants"]>;
212
+ <DefaultElement extends StylableElement>(defaultElement: DefaultElement, baseStyles?: CSS): StyledComponent<DefaultElement, {}>;
200
213
  }
201
214
  export interface GetCssTextOptions {
202
215
  theme?: Theme;
@@ -248,10 +261,9 @@ export interface StoopInstance {
248
261
  * Gets all generated CSS text for server-side rendering.
249
262
  * Always includes theme CSS variables.
250
263
  *
251
- * @param theme - Deprecated parameter, kept for backward compatibility but ignored
252
264
  * @returns CSS text string with theme variables and component styles
253
265
  */
254
- getCssText: (theme?: string | Theme) => string;
266
+ getCssText: () => string;
255
267
  config: StoopConfig;
256
268
  /**
257
269
  * Pre-compiles CSS objects to warm the cache.
@@ -261,12 +273,11 @@ export interface StoopInstance {
261
273
  */
262
274
  warmCache: (styles: CSS[]) => void;
263
275
  /**
264
- * Preloads a theme by injecting its CSS variables before React renders.
276
+ * Preloads themes by injecting CSS variables before React renders.
265
277
  * Useful for preventing FOUC when loading a non-default theme from localStorage.
266
- *
267
- * @param theme - Theme to preload (theme name string or Theme object)
278
+ * Always injects all configured themes.
268
279
  */
269
- preloadTheme: (theme: string | Theme) => void;
280
+ preloadTheme: () => void;
270
281
  /**
271
282
  * Provider component for managing theme state and updates.
272
283
  * Available when themes are provided in createStoop config.
@@ -11,7 +11,6 @@ import type { CSS, DefaultTheme, StyledComponentRef, Theme, UtilityFunction } fr
11
11
  export declare function isBrowser(): boolean;
12
12
  /**
13
13
  * Checks if running in production mode.
14
- * Extracted to helper function for consistency.
15
14
  *
16
15
  * @returns True if running in production mode
17
16
  */
@@ -25,7 +24,6 @@ export declare function isProduction(): boolean;
25
24
  export declare function isCSSObject(value: unknown): value is CSS;
26
25
  /**
27
26
  * Checks if a value is a styled component reference.
28
- * Consolidated function used across the codebase.
29
27
  *
30
28
  * @param value - Value to check
31
29
  * @returns True if value is a styled component reference
@@ -47,7 +45,6 @@ export declare function isValidCSSObject(value: unknown): value is CSS;
47
45
  export declare function isThemeObject(value: unknown): value is Theme;
48
46
  /**
49
47
  * Validates that a theme object only contains approved scales.
50
- * In production, skips all validation for performance.
51
48
  *
52
49
  * @param theme - Theme object to validate
53
50
  * @returns Validated theme as DefaultTheme
@@ -1,9 +1,8 @@
1
1
  /**
2
2
  * Storage and theme detection utilities.
3
- * Provides simplified localStorage and cookie management, plus automatic theme selection.
4
- * Supports SSR compatibility and error handling.
3
+ * Provides simplified localStorage and cookie management with SSR compatibility and error handling.
5
4
  */
6
- import type { ThemeDetectionOptions, ThemeDetectionResult, StorageOptions, StorageResult } from "../types";
5
+ import type { StorageOptions, StorageResult } from "../types";
7
6
  /**
8
7
  * Safely gets a value from localStorage.
9
8
  *
@@ -54,95 +53,3 @@ export declare function setCookie(name: string, value: string, options?: Omit<St
54
53
  * @returns Success status
55
54
  */
56
55
  export declare function removeCookie(name: string, path?: string): boolean;
57
- /**
58
- * Unified storage API that works with both localStorage and cookies.
59
- *
60
- * @param key - Storage key
61
- * @param options - Storage options
62
- * @returns Storage result
63
- */
64
- export declare function getStorage(key: string, options?: StorageOptions): StorageResult<string | null>;
65
- /**
66
- * Unified storage API that works with both localStorage and cookies.
67
- *
68
- * @param key - Storage key
69
- * @param value - Value to store
70
- * @param options - Storage options
71
- * @returns Storage result
72
- */
73
- export declare function setStorage(key: string, value: string, options?: StorageOptions): StorageResult<void>;
74
- /**
75
- * Unified storage API that works with both localStorage and cookies.
76
- *
77
- * @param key - Storage key
78
- * @param options - Storage options
79
- * @returns Storage result
80
- */
81
- export declare function removeStorage(key: string, options?: StorageOptions): StorageResult<void>;
82
- /**
83
- * Gets a JSON value from storage with automatic parsing.
84
- *
85
- * @param key - Storage key
86
- * @param fallback - Fallback value if parsing fails or key not found
87
- * @param options - Storage options
88
- * @returns Parsed JSON value or fallback
89
- */
90
- export declare function getJsonFromStorage<T>(key: string, fallback: T, options?: StorageOptions): StorageResult<T>;
91
- /**
92
- * Sets a JSON value in storage with automatic serialization.
93
- *
94
- * @param key - Storage key
95
- * @param value - Value to serialize and store
96
- * @param options - Storage options
97
- * @returns Storage result
98
- */
99
- export declare function setJsonInStorage<T>(key: string, value: T, options?: StorageOptions): StorageResult<void>;
100
- /**
101
- * Creates a typed storage interface for a specific key.
102
- *
103
- * @param key - Storage key
104
- * @param options - Storage options
105
- * @returns Typed storage interface
106
- */
107
- export declare function createStorage<T = string>(key: string, options?: StorageOptions): {
108
- get: () => StorageResult<string | null>;
109
- getJson: (fallback: T) => StorageResult<T>;
110
- remove: () => StorageResult<void>;
111
- set: (value: string) => StorageResult<void>;
112
- setJson: (value: T) => StorageResult<void>;
113
- };
114
- /**
115
- * Detects the best theme to use based on multiple sources with priority.
116
- *
117
- * Priority order (highest to lowest):
118
- * 1. Explicit localStorage preference
119
- * 2. Cookie preference (for SSR compatibility)
120
- * 3. System color scheme preference
121
- * 4. Default theme
122
- *
123
- * @param options - Theme detection options
124
- * @returns Theme detection result
125
- */
126
- export declare function detectTheme(options?: ThemeDetectionOptions): ThemeDetectionResult;
127
- /**
128
- * Creates a theme detector function with pre-configured options.
129
- *
130
- * @param options - Theme detection options
131
- * @returns Theme detection function
132
- */
133
- export declare function createThemeDetector(options: ThemeDetectionOptions): () => ThemeDetectionResult;
134
- /**
135
- * Auto-detects theme for SSR contexts (server-side or during hydration).
136
- * Uses only cookie and default sources since localStorage isn't available.
137
- *
138
- * @param options - Theme detection options
139
- * @returns Theme name
140
- */
141
- export declare function detectThemeForSSR(options?: ThemeDetectionOptions): string;
142
- /**
143
- * Listens for system theme changes and calls callback when changed.
144
- *
145
- * @param callback - Function to call when system theme changes
146
- * @returns Cleanup function
147
- */
148
- export declare function onSystemThemeChange(callback: (theme: "dark" | "light") => void): () => void;
@@ -36,7 +36,6 @@ export declare function escapeCSSValue(value: string | number): string;
36
36
  /**
37
37
  * Validates and sanitizes CSS selectors to prevent injection attacks.
38
38
  * Only allows safe selector characters. Returns empty string for invalid selectors.
39
- * Uses memoization for performance.
40
39
  *
41
40
  * @param selector - Selector to sanitize
42
41
  * @returns Sanitized selector string or empty string if invalid
@@ -45,7 +44,6 @@ export declare function sanitizeCSSSelector(selector: string): string;
45
44
  /**
46
45
  * Validates and sanitizes CSS variable names to prevent injection attacks.
47
46
  * CSS custom properties must start with -- and contain only valid characters.
48
- * Uses memoization for performance.
49
47
  *
50
48
  * @param name - Variable name to sanitize
51
49
  * @returns Sanitized variable name
@@ -78,20 +76,11 @@ export declare function sanitizeMediaQuery(mediaQuery: string): string;
78
76
  /**
79
77
  * Sanitizes CSS class names to prevent injection attacks.
80
78
  * Only allows valid CSS class name characters.
81
- * Uses memoization for performance.
82
79
  *
83
80
  * @param className - Class name(s) to sanitize
84
81
  * @returns Sanitized class name string
85
82
  */
86
83
  export declare function sanitizeClassName(className: string): string;
87
- /**
88
- * Sanitizes CSS property names to prevent injection attacks.
89
- * Uses memoization for performance.
90
- *
91
- * @param propertyName - Property name to sanitize
92
- * @returns Sanitized property name
93
- */
94
- export declare function sanitizeCSSPropertyName(propertyName: string): string;
95
84
  /**
96
85
  * Validates keyframe percentage keys (e.g., "0%", "50%", "from", "to").
97
86
  *
@@ -101,7 +90,6 @@ export declare function sanitizeCSSPropertyName(propertyName: string): string;
101
90
  export declare function validateKeyframeKey(key: string): boolean;
102
91
  /**
103
92
  * Gets a pre-compiled regex for matching :root CSS selector blocks.
104
- * Uses caching for performance.
105
93
  *
106
94
  * @param prefix - Optional prefix (unused, kept for API compatibility)
107
95
  * @returns RegExp for matching :root selector blocks
@@ -109,7 +97,6 @@ export declare function validateKeyframeKey(key: string): boolean;
109
97
  export declare function getRootRegex(prefix?: string): RegExp;
110
98
  /**
111
99
  * Auto-detects theme scale from CSS property name using pattern matching.
112
- * Used as fallback when property is not in DEFAULT_THEME_MAP.
113
100
  *
114
101
  * @param property - CSS property name
115
102
  * @returns Theme scale name or undefined if no pattern matches
@@ -1,7 +1,6 @@
1
1
  /**
2
2
  * Theme token resolution utilities.
3
3
  * Converts theme tokens to CSS variables for runtime theme switching.
4
- * Uses cached token index for efficient lookups and theme comparison.
5
4
  */
6
5
  import type { CSS, Theme, ThemeScale } from "../types";
7
6
  /**
@@ -34,8 +33,7 @@ export declare function tokenToCSSVar(token: string, theme?: Theme, property?: s
34
33
  export declare function generateCSSVariables(theme: Theme, prefix?: string, attributeSelector?: string): string;
35
34
  /**
36
35
  * Generates CSS custom properties for all themes using attribute selectors.
37
- * This allows all themes to be available simultaneously, with theme switching
38
- * handled by changing the data-theme attribute.
36
+ * All themes are available simultaneously, with theme switching handled by changing the data-theme attribute.
39
37
  *
40
38
  * @param themes - Map of theme names to theme objects
41
39
  * @param prefix - Optional prefix for CSS variable names
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "stoop",
3
3
  "description": "CSS-in-JS library with type inference, theme creation, and variants support.",
4
- "version": "0.4.1",
4
+ "version": "0.5.1",
5
5
  "author": "Jackson Dolman <mail@dolmios.com>",
6
6
  "main": "./dist/create-stoop.js",
7
7
  "types": "./dist/create-stoop.d.ts",
@@ -17,10 +17,13 @@
17
17
  "react-polymorphic-types": "^2.0.0"
18
18
  },
19
19
  "devDependencies": {
20
+ "@stitches/stringify": "^1.2.8",
20
21
  "@types/node": "^25.0.3",
21
22
  "@types/react": "^19.2.7",
22
23
  "@types/react-dom": "^19.2.3",
23
24
  "bun-types": "^1.3.5",
25
+ "style-object-to-css-string": "^1.1.3",
26
+ "to-css": "^1.2.1",
24
27
  "typescript": "^5.9.3"
25
28
  },
26
29
  "exports": {
@@ -36,12 +39,6 @@
36
39
  "require": "./dist/utils/storage.js",
37
40
  "default": "./dist/utils/storage.js"
38
41
  },
39
- "./utils/auto-preload": {
40
- "types": "./dist/utils/auto-preload.d.ts",
41
- "import": "./dist/utils/auto-preload.js",
42
- "require": "./dist/utils/auto-preload.js",
43
- "default": "./dist/utils/auto-preload.js"
44
- },
45
42
  "./types": {
46
43
  "types": "./dist/types/index.d.ts",
47
44
  "import": "./dist/types/index.js",
@@ -97,12 +94,7 @@
97
94
  "react-dom": ">=16.8.0"
98
95
  },
99
96
  "scripts": {
100
- "build": "bun run build:clean && bun run build:js && bun run build:js:ssr && bun run build:types",
101
- "build:clean": "rm -rf dist",
102
- "build:copy-declarations": "mkdir -p dist/types && cp src/types/react-polymorphic-types.d.ts dist/types/react-polymorphic-types.d.ts 2>/dev/null || :",
103
- "build:js": "NODE_ENV=production bun build ./src/create-stoop.ts --outfile ./dist/create-stoop.js --target browser --format esm --minify --jsx=automatic --external react --external react-dom --external react/jsx-runtime --define process.env.NODE_ENV='\"production\"'",
104
- "build:js:ssr": "NODE_ENV=production bun build ./src/create-stoop-ssr.ts --outfile ./dist/create-stoop-ssr.js --target browser --format esm --minify --jsx=automatic --external react --external react-dom --external react/jsx-runtime --define process.env.NODE_ENV='\"production\"'",
105
- "build:types": "bunx tsc --project tsconfig.build.json && bun run build:copy-declarations",
97
+ "build": "bun run build.ts",
106
98
  "lint": "eslint src --fix",
107
99
  "prepare": "bun run build",
108
100
  "test": "bun test",
@@ -112,4 +104,3 @@
112
104
  "sideEffects": false,
113
105
  "type": "module"
114
106
  }
115
-
@@ -1,7 +0,0 @@
1
- /**
2
- * Global CSS injection API.
3
- * Creates a function that injects global styles into the document.
4
- * Supports media queries, nested selectors, and theme tokens.
5
- */
6
- import type { CSS, Theme, ThemeScale, UtilityFunction } from "../types";
7
- export declare function createGlobalCSSFunction(defaultTheme: Theme, prefix?: string, media?: Record<string, string>, utils?: Record<string, UtilityFunction>, themeMap?: Record<string, ThemeScale>): (styles: CSS) => () => void;
@@ -1,15 +0,0 @@
1
- /**
2
- * Variant application logic.
3
- * Merges variant styles with base styles based on component props.
4
- * Optimized to avoid unnecessary object spreads when no variants are applied.
5
- */
6
- import type { CSS, Variants, VariantProps } from "../types";
7
- /**
8
- * Applies variant styles to base styles based on component props.
9
- *
10
- * @param variants - Variant configuration object
11
- * @param props - Component props containing variant values
12
- * @param baseStyles - Base styles to merge with variant styles
13
- * @returns Merged CSS object
14
- */
15
- export declare function applyVariants(variants: Variants, props: VariantProps, baseStyles: CSS): CSS;
@@ -1,45 +0,0 @@
1
- /**
2
- * Auto-preloading utilities for cache warming and theme preloading.
3
- * Helps eliminate FOUC (Flash of Unstyled Content) by pre-compiling styles and preloading themes.
4
- */
5
- import type { CSS, Theme, ThemeDetectionOptions, ThemeDetectionResult, AutoPreloadOptions, AutoPreloadResult } from "../types";
6
- /**
7
- * Common UI component styles that are frequently used.
8
- * These represent typical design system patterns.
9
- */
10
- export declare const COMMON_UI_STYLES: CSS[];
11
- /**
12
- * Automatically warms the cache with common styles.
13
- *
14
- * @param warmCacheFn - The warmCache function from Stoop instance
15
- * @param styles - Styles to warm (defaults to COMMON_UI_STYLES)
16
- * @returns Promise that resolves when warming is complete
17
- */
18
- export declare function autoWarmCache(warmCacheFn: (styles: CSS[]) => void, styles?: CSS[]): Promise<void>;
19
- /**
20
- * Automatically preloads a detected theme.
21
- *
22
- * @param preloadThemeFn - The preloadTheme function from Stoop instance
23
- * @param options - Theme detection options
24
- * @param ssr - Whether running in SSR context
25
- * @returns Promise that resolves when preloading is complete
26
- */
27
- export declare function autoPreloadTheme(preloadThemeFn: (theme: string | Theme) => void, options?: ThemeDetectionOptions, ssr?: boolean): Promise<ThemeDetectionResult>;
28
- /**
29
- * Performs automatic preloading operations based on configuration.
30
- *
31
- * @param warmCacheFn - The warmCache function from Stoop instance
32
- * @param preloadThemeFn - The preloadTheme function from Stoop instance
33
- * @param options - Auto-preload options
34
- * @returns Promise that resolves with preload results
35
- */
36
- export declare function autoPreload(warmCacheFn: (styles: CSS[]) => void, preloadThemeFn: (theme: string | Theme) => void, options?: AutoPreloadOptions): Promise<AutoPreloadResult>;
37
- /**
38
- * Creates an auto-preloader with pre-configured options.
39
- *
40
- * @param warmCacheFn - The warmCache function from Stoop instance
41
- * @param preloadThemeFn - The preloadTheme function from Stoop instance
42
- * @param defaultOptions - Default auto-preload options
43
- * @returns Auto-preloader function
44
- */
45
- export declare function createAutoPreloader(warmCacheFn: (styles: CSS[]) => void, preloadThemeFn: (theme: string | Theme) => void, defaultOptions?: AutoPreloadOptions): (options?: Partial<AutoPreloadOptions>) => Promise<AutoPreloadResult>;