stoop 0.4.0 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/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
 
@@ -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,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,26 +1,16 @@
1
- /**
2
- * SSR-safe entry point for Stoop.
3
- * Exports only server-safe APIs that don't require React.
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
- */
8
- // Import createStoopBase from create-stoop-internal to avoid React type imports
9
- // create-stoop-internal.ts is a copy of create-stoop.ts without React imports at module level
10
- import { createStoopBase } from "./create-stoop-internal";
11
- export function createStoop(config) {
12
- const base = createStoopBase(config);
13
- // Return only server-safe APIs (no React components)
14
- // Ensure config.prefix is always a string (not undefined) for type compatibility
15
- return {
16
- config: { ...base.config, prefix: base.sanitizedPrefix },
17
- createTheme: base.createTheme,
18
- css: base.css,
19
- getCssText: base.getCssText,
20
- globalCss: base.globalCss,
21
- keyframes: base.keyframes,
22
- preloadTheme: base.preloadTheme,
23
- theme: base.theme,
24
- warmCache: base.warmCache,
25
- };
26
- }
1
+ var $0=Object.freeze({}),x=1e4,QJ=5000,ZJ=10,WJ=500,E=1000;var c=["colors","opacities","space","radii","sizes","fonts","fontWeights","fontSizes","lineHeights","letterSpacings","shadows","zIndices","transitions"],z={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"},DJ=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(QJ),o=new L(x);function R(){return typeof window!=="undefined"&&typeof document!=="undefined"&&typeof window.document==="object"&&typeof document.createElement==="function"}function v(){return typeof process!=="undefined"&&process.env?.NODE_ENV==="production"}function N(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 p(J){return N(J)&&!m(J)}function i(J){return typeof J==="object"&&J!==null&&!Array.isArray(J)}function T(J){if(!J||typeof J!=="object"||Array.isArray(J))throw new Error("[Stoop] Theme must be a non-null object");if(v())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 j(J,$){if(!$||!J||typeof J!=="object")return J;let Y={},q=Object.keys($);for(let X in J){let Z=J[X];if(q.includes(X)&&$[X])try{let G=$[X](Z);if(G&&typeof G==="object")for(let Q in G)Y[Q]=G[Q]}catch{Y[X]=Z}else if(N(Z))Y[X]=j(Z,$);else Y[X]=Z}return Y}var l=null,UJ=new L(E),W0=new L(E),HJ=new L(E);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 r(J){try{return b(JSON.stringify(J))}catch{return b(String(J))}}function BJ(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 LJ(J){return BJ(J,!1)}function O(J){let $=UJ.get(J);if($!==void 0)return $;let Y=J.replace(/[^a-zA-Z0-9\s\-_>+~:.#[\]&@()]/g,""),q=!Y.trim()||/^[>+~:.#[\]&@()\s]+$/.test(Y)?"":Y;return UJ.set(J,q),q}function M(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 _J(J){return BJ(J,!0)}function B(J){if(!J)return"stoop";return J.replace(/[^a-zA-Z0-9-_]/g,"").replace(/^[\d-]+/,"").replace(/^-+/,"")||"stoop"}function AJ(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 IJ(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 RJ(J=""){if(!l){let Y=":root".replace(/[.*+?^${}()|[\]\\]/g,"\\$&");l=new RegExp(`${Y}\\s*\\{[\\s\\S]*\\}`)}return l}function hJ(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 KJ(J,$){if($&&J in $)return $[J];if(J in z)return z[J];return hJ(J)}var a=new Map;function k(J){return a.has(J)}function C(J,$){a.set(J,$)}var s=new L(x);function EJ(J){if(!s.has(J))s.set(J,!0)}function OJ(){return Array.from(s.keys()).join(`
2
+ `)}var f=new Map;var MJ=new Map;function VJ(J="stoop"){if(!R())throw new Error("Cannot access document in SSR context");let $=B(J),Y=f.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",$),f.set($,Y),Y}Y=document.createElement("style"),Y.setAttribute("data-stoop",$),Y.setAttribute("id",`stoop-${$}`),document.head.appendChild(Y),f.set($,Y)}return Y}function t(J){let $=J,Y=RJ("");$=$.replace(Y,"").trim();let q=$.indexOf("[data-theme=");while(q!==-1){let X=$.indexOf("{",q);if(X===-1)break;let Z=1,G=X+1;while(G<$.length&&Z>0){if($[G]==="{")Z++;else if($[G]==="}")Z--;G++}if(Z===0){let Q=$.substring(0,q).trim(),F=$.substring(G).trim();$=(Q+`
3
+ `+F).trim()}else break;q=$.indexOf("[data-theme=")}return $.trim()}function PJ(J,$="stoop"){if(!J)return;let Y=B($),q=`__all_theme_vars_${Y}`;if((MJ.get(q)??null)===J)return;if(MJ.set(q,J),!R()){EJ(J);return}let Z=VJ(Y),G=Z.textContent||"",Q=G.includes(":root")||G.includes("[data-theme=");if(k(q)||Q){let F=t(G);Z.textContent=J+(F?`
4
+
5
+ `+F:""),C(q,J)}else Z.textContent=J+(G?`
6
+
7
+ `+G:""),C(q,J)}function cJ(J,$,Y="stoop"){if(!R())return;let q=B(Y);if(k($))return;let X=VJ(q),Z=X.textContent||"";X.textContent=Z+(Z?`
8
+ `:"")+J,C($,J)}function oJ(J,$,Y="stoop"){if(k($))return;let q=B(Y);cJ(J,$,q)}function mJ(J="stoop"){let $=B(J);return f.get($)||null}function pJ(){return new Map(a)}function V(J,$="stoop",Y){let q=Y||J;if(!R()){if(!k(q))C(q,J);EJ(J);return}oJ(J,q,$)}function gJ(J="stoop"){if(R()){let $=B(J),Y=mJ($);if(Y&&Y.parentNode){let q=Y.textContent||"";if(!q&&pJ().size>0)return OJ();return q}}return OJ()}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 JJ(J){let $=new Map;function Y(q,X=[]){let Z=Object.keys(q);for(let G of Z){let Q=q[G],F=[...X,G];if(i(Q))Y(Q,F);else{let D=$.get(G);if(D)D.push(F);else $.set(G,[F])}}}Y(J);for(let[,q]of $.entries())if(q.length>1)q.sort((X,Z)=>{let G=X.length-Z.length;if(G!==0)return G;let Q=X.join("."),F=Z.join(".");return Q.localeCompare(F)});return $}function lJ(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 jJ(J,$){if(J===$)return!0;if(!J||!$)return!1;if(!lJ(J,$))return!1;let Y={...J},q={...$};return delete Y.media,delete q.media,JSON.stringify(Y)===JSON.stringify(q)}function e(J,$,Y){if(Y&&Y in J){let Z=J[Y];if(Z&&typeof Z==="object"&&!Array.isArray(Z)&&$ in Z)return[Y,$]}let X=JJ(J).get($);if(!X||X.length===0)return null;return X[0]}function zJ(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)=>M(W)).join("-")}`})`;if($&&Y){let Q=KJ(Y,q);if(Q){let w=e($,X,Q);if(w)return`var(${`--${w.map((I)=>M(I)).join("-")}`})`}let D=JJ($).get(X);if(D&&D.length>1){if(!v()){let w=Q?`Property "${Y}" maps to "${Q}" 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((U)=>U.join(".")).join(", ")}. ${w}Using "${D[0].join(".")}" (deterministic: shorter paths first, then alphabetical). Use full path "$${D[0].join(".")}" to be explicit.`)}}let W=e($,X);if(W)return`var(${`--${W.map((H)=>M(H)).join("-")}`})`}else if($){let F=JJ($).get(X);if(F&&F.length>1){if(!v())console.warn(`[Stoop] Ambiguous token "$${X}" found in multiple categories: ${F.map((W)=>W.join(".")).join(", ")}. Using "${F[0].join(".")}" (deterministic: shorter paths first, then alphabetical). Use full path "$${F[0].join(".")}" to be explicit, or use with a CSS property for automatic resolution.`)}let D=e($,X);if(D)return`var(${`--${D.map((U)=>M(U)).join("-")}`})`}return`var(${`--${M(X)}`})`}function $J(J,$="stoop",Y){let q=Y||":root",X=[];function Z(G,Q=[]){let F=Object.keys(G).sort();for(let D of F){if(D==="media")continue;let W=G[D],w=[...Q,D];if(i(W))Z(W,w);else{let H=`--${w.map((n)=>M(n)).join("-")}`,I=typeof W==="string"||typeof W==="number"?_J(W):String(W);X.push(` ${H}: ${I};`)}}}if(Z(J),X.length===0)return"";return`${q} {
9
+ ${X.join(`
10
+ `)}
11
+ }`}function S(J,$="stoop",Y="data-theme"){let q=[];for(let[X,Z]of Object.entries(J)){let G=`[${Y}="${X}"]`,Q=$J(Z,$,G);if(Q)q.push(Q)}return q.join(`
12
+
13
+ `)}function P(J,$,Y,q){if(!J||typeof J!=="object")return J;let X={},Z=!1,G=Object.keys(J).sort();for(let Q of G){let F=J[Q];if(N(F)){let D=P(F,$,Y,void 0);if(X[Q]=D,D!==F)Z=!0}else if(typeof F==="string"&&F.includes("$")){Z=!0;let D=q||Q;X[Q]=F.replace(iJ,(W)=>{if(W.startsWith("-$")){let w=W.slice(1);return`calc(-1 * ${zJ(w,$,D,Y)})`}return zJ(W,$,D,Y)})}else X[Q]=F}if(!Z)return J;return X}var _=new L(E);function rJ(J){return J.replace(/([A-Z])/g,"-$1").toLowerCase()}function sJ(J){if(J===J.toUpperCase()&&J.length>1)return J.charAt(0)+J.slice(1).toLowerCase();return J}function d(J){if(!J)return"";return J.charAt(0).toLowerCase()+J.slice(1).replace(/([A-Z])/g,"-$1").toLowerCase()}function u(J){if(!J||typeof J!=="string")return"";let $=_.get(J);if($!==void 0)return $;if(/^-[a-z]+-/.test(J))return _.set(J,J),J;let Y=sJ(J);if(/^[Mm]oz/i.test(Y)){if(Y.length===3||Y.toLowerCase()==="moz")return _.set(J,"-moz"),"-moz";let G=Y.match(/^[Mm]oz(.+)$/i);if(G&&G[1]){let[,Q]=G,F=d(Q);if(F){let D=`-moz-${F}`;return _.set(J,D),D}}}if(/^[Ww]ebkit/i.test(Y)){if(Y.length===6||Y.toLowerCase()==="webkit")return _.set(J,"-webkit"),"-webkit";let G=Y.match(/^[Ww]ebkit(.+)$/i);if(G&&G[1]){let[,Q]=G,F=d(Q);if(F){let D=`-webkit-${F}`;return _.set(J,D),D}}}if(/^[Mm]s/i.test(Y)){if(Y.length===2||Y.toLowerCase()==="ms")return _.set(J,"-ms"),"-ms";let G=Y.match(/^[Mm]s(.+)$/i);if(G&&G[1]){let[,Q]=G,F=d(Q);if(F){let D=`-ms-${F}`;return _.set(J,D),D}}}if(/^O/i.test(Y)){if(Y.length===1||Y.toLowerCase()==="o")return _.set(J,"-o"),"-o";if(/^O[A-Z]/.test(Y)){let G=Y.substring(1),Q=d(G);if(Q){let F=`-o-${Q}`;return _.set(J,F),F}}}let Z=rJ(Y).replace(/[^a-zA-Z0-9-]/g,"").replace(/^-+|-+$/g,"").replace(/^\d+/,"")||"";return _.set(J,Z),Z}function aJ(J,$){if(typeof J==="symbol"&&J===DJ)return!0;if(m($))return!0;if(typeof J==="string"&&J.startsWith("__STOOP_COMPONENT_"))return!0;return!1}function tJ(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 A(J,$="",Y=0,q){if(!J||typeof J!=="object")return"";if(Y>ZJ)return"";let X=[],Z=[],G=Object.keys(J).sort();for(let F of G){let D=J[F];if(aJ(F,D)){let W=tJ(F,D);if(!W)continue;let w=O(W);if(!w)continue;let U=$?`${$} .${w}`:`.${w}`,H=p(D)?A(D,U,Y+1,q):"";if(H)Z.push(H);continue}if(p(D))if(q&&F in q){let W=AJ(q[F]);if(W){let w=A(D,$,Y+1,q);if(w)Z.push(`${W} { ${w} }`)}}else if(F.startsWith("@")){let W=O(F);if(W){let w=A(D,$,Y+1,q);if(w)Z.push(`${W} { ${w} }`)}}else if(F.includes("&")){let W=O(F);if(W){let U=W.split("&").join($),H=A(D,U,Y+1,q);if(H)Z.push(H)}}else if(F.startsWith(":")){let W=O(F);if(W){let w=`${$}${W}`,U=A(D,w,Y+1,q);if(U)Z.push(U)}}else if(F.includes(" ")||F.includes(">")||F.includes("+")||F.includes("~")){let W=O(F);if(W){let U=/^[\s>+~]/.test(W.trim())?`${$}${W}`:`${$} ${W}`,H=A(D,U,Y+1,q);if(H)Z.push(H)}}else{let W=O(F);if(W){let w=$?`${$} ${W}`:W,U=A(D,w,Y+1,q);if(U)Z.push(U)}}else if(D!==void 0){let W=u(F);if(W&&(typeof D==="string"||typeof D==="number")){let w=LJ(D);X.push(`${W}: ${w};`)}}}let Q=[];if(X.length>0)Q.push(`${$} { ${X.join(" ")} }`);return Q.push(...Z),Q.join("")}function y(J,$,Y="stoop",q,X,Z){let G=B(Y),Q=j(J,X),F=P(Q,$,Z),D=A(F,"",0,q),W=b(D),w=G?`${G}-${W}`:`css-${W}`,U=`${G}:${w}`,H=o.get(U);if(H)return V(H,G,U),w;let I=A(F,`.${w}`,0,q);return o.set(U,I),wJ.set(U,w),V(I,G,U),w}var xJ=new Map;function vJ(J,$="stoop"){let Y=$||"";xJ.set(Y,J)}function eJ(J="stoop"){let $=J||"";return xJ.get($)||null}function YJ(J,$){let Y={...J},q=Object.keys($);for(let X of q){if(X==="media")continue;let Z=$[X],G=J[X];if(Z&&typeof Z==="object"&&!Array.isArray(Z)&&G&&typeof G==="object"&&!Array.isArray(G))Y[X]={...G,...Z};else if(Z!==void 0)Y[X]=Z}return Y}function qJ(J,$="stoop"){let Y=eJ($);if(!Y)return J;if(jJ(J,Y))return J;return YJ(Y,J)}function NJ(J,$="stoop",Y="data-theme"){if(!R())return;let q={};for(let[Z,G]of Object.entries(J))q[Z]=qJ(G,$);let X=S(q,$,Y);PJ(X,$)}function TJ(J){return function $(Y={}){let q=T(Y);return YJ(J,q)}}function bJ(J,$="stoop",Y,q,X){return function Z(G){return y(G,J,$,Y,q,X)}}function J0(J,$,Y,q){let X=`@keyframes ${$} {`,Z=Object.keys(J).sort((G,Q)=>{let F=parseFloat(G.replace("%","")),D=parseFloat(Q.replace("%",""));if(G==="from")return-1;if(Q==="from")return 1;if(G==="to")return 1;if(Q==="to")return-1;return F-D});for(let G of Z){if(!IJ(G))continue;let Q=J[G];if(!Q||typeof Q!=="object")continue;X+=` ${G} {`;let F=P(Q,Y,q),D=Object.keys(F).sort();for(let W of D){let w=F[W];if(w!==void 0&&(typeof w==="string"||typeof w==="number")){let U=u(W);if(U){let H=String(w);X+=` ${U}: ${H};`}}}X+=" }"}return X+=" }",X}function fJ(J="stoop",$,Y){let q=B(J),X=new L(WJ);return function Z(G){let Q=r(G),F=X.get(Q);if(F)return F;let D=Q.slice(0,8),W=q?`${q}-${D}`:`stoop-${D}`,w=J0(G,W,$,Y),U=`__keyframes_${W}`;return V(w,q,U),X.set(Q,W),W}}var XJ=new Set;function CJ(J,$="stoop",Y,q,X){return function Z(G){let Q=r(G);if(XJ.has(Q))return()=>{};XJ.add(Q);let F=B($),D=j(G,q),W=P(D,J,X),w=A(W,"",0,Y);return V(w,F,`__global_${Q}`),()=>{XJ.delete(Q)}}}function kJ(J){let{globalCss:$,media:Y,prefix:q="stoop",theme:X,themeMap:Z,utils:G}=J,Q=B(q),F=T(X),D=F.media||Y,W={...z,...Z};vJ(F,Q);let w=bJ(F,Q,D,G,W),U=TJ(F),H=CJ(F,Q,D,G,W),I=fJ(Q,F,W),n=Object.freeze({...F});function SJ(K){for(let h of K)try{y(h,F,Q,D,G,W)}catch{}}function dJ(){if(!J.themes||Object.keys(J.themes).length===0)return;NJ(J.themes,Q)}function uJ(){let K="";if(J.themes&&Object.keys(J.themes).length>0){let g={};for(let[yJ,nJ]of Object.entries(J.themes))g[yJ]=qJ(nJ,Q);let FJ=S(g,Q,"data-theme");if(FJ)K+=FJ+`
14
+ `}else{let g=$J(F,Q);if(g)K+=g+`
15
+ `}let h=gJ(),GJ=t(h).trim();if(GJ)K+=(K?`
16
+ `:"")+GJ;return K}return{config:{...J,prefix:Q},createTheme:U,css:w,getCssText:uJ,globalCss:H,globalCssConfig:$,keyframes:I,media:D,mergedThemeMap:W,preloadTheme:dJ,sanitizedPrefix:Q,theme:n,utils:G,validatedTheme:F,warmCache:SJ}}function $1(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{$1 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,156 +1,16 @@
1
- /**
2
- * Factory function that creates a Stoop instance.
3
- * Supports both client-side (with React APIs) and server-side (without React) usage.
4
- * Automatically detects environment and includes appropriate APIs.
5
- */
6
- import { createTheme as createThemeFactory, createCSSFunction, createKeyframesFunction, } from "./api/core-api";
7
- import { createGlobalCSSFunction } from "./api/global-css";
8
- import { createStyledFunction } from "./api/styled";
9
- import { createProvider, createUseThemeHook } from "./api/theme-provider";
10
- import { DEFAULT_THEME_MAP } from "./constants";
11
- import { compileCSS } from "./core/compiler";
12
- import { mergeWithDefaultTheme, registerDefaultTheme, injectAllThemes } from "./core/theme-manager";
13
- import { getCssText as getCssTextBase, removeThemeVariableBlocks } from "./inject";
14
- import { validateTheme } from "./utils/helpers";
15
- import { generateAllThemeVariables, generateCSSVariables } from "./utils/theme";
16
- import { sanitizePrefix } from "./utils/theme-utils";
17
- /**
18
- * Shared implementation for creating Stoop instances.
19
- * Handles common setup logic for both client and server instances.
20
- * Exported for use in SSR entry point.
21
- */
22
- export function createStoopBase(config) {
23
- const { globalCss: globalCssConfig, media: configMedia, prefix = "stoop", theme, themeMap: userThemeMap, utils, } = config;
24
- const sanitizedPrefix = sanitizePrefix(prefix);
25
- const validatedTheme = validateTheme(theme);
26
- const media = validatedTheme.media || configMedia;
27
- const mergedThemeMap = {
28
- ...DEFAULT_THEME_MAP,
29
- ...userThemeMap,
30
- };
31
- registerDefaultTheme(validatedTheme, sanitizedPrefix);
32
- const css = createCSSFunction(validatedTheme, sanitizedPrefix, media, utils, mergedThemeMap);
33
- const createTheme = createThemeFactory(validatedTheme);
34
- const globalCss = createGlobalCSSFunction(validatedTheme, sanitizedPrefix, media, utils, mergedThemeMap);
35
- const keyframes = createKeyframesFunction(sanitizedPrefix, validatedTheme, mergedThemeMap);
36
- const themeObject = Object.freeze({ ...validatedTheme });
37
- /**
38
- * Pre-compiles CSS objects to warm the cache.
39
- * Useful for eliminating FOUC by pre-compiling common styles.
40
- *
41
- * @param styles - Array of CSS objects to pre-compile
42
- */
43
- function warmCache(styles) {
44
- for (const style of styles) {
45
- try {
46
- compileCSS(style, validatedTheme, sanitizedPrefix, media, utils, mergedThemeMap);
47
- }
48
- catch {
49
- // Skip invalid styles
50
- }
51
- }
52
- }
53
- /**
54
- * Preloads a theme by injecting its CSS variables before React renders.
55
- * Useful for preventing FOUC when loading a non-default theme from localStorage.
56
- * Uses injectAllThemes to ensure all themes are available.
57
- *
58
- * @param theme - Theme to preload (can be theme name string or Theme object)
59
- */
60
- function preloadTheme(theme) {
61
- if (!config.themes || Object.keys(config.themes).length === 0) {
62
- return;
63
- }
64
- // Always inject all themes for consistency and to prevent FOUC
65
- injectAllThemes(config.themes, sanitizedPrefix);
66
- }
67
- /**
68
- * Gets all injected CSS text for server-side rendering.
69
- * Always includes all theme CSS variables using attribute selectors.
70
- *
71
- * @param theme - Deprecated parameter, kept for backward compatibility but ignored
72
- * @returns CSS text string with theme variables and component styles
73
- */
74
- function getCssText(theme) {
75
- let result = "";
76
- // Always include all themes using attribute selectors for consistency
77
- if (config.themes && Object.keys(config.themes).length > 0) {
78
- // Merge all themes with default theme for consistency with client-side behavior
79
- const mergedThemes = {};
80
- for (const [themeName, theme] of Object.entries(config.themes)) {
81
- mergedThemes[themeName] = mergeWithDefaultTheme(theme, sanitizedPrefix);
82
- }
83
- const allThemeVars = generateAllThemeVariables(mergedThemes, sanitizedPrefix, "data-theme");
84
- if (allThemeVars) {
85
- result += allThemeVars + "\n";
86
- }
87
- }
88
- else {
89
- // No themes configured, just use default theme
90
- const themeVars = generateCSSVariables(validatedTheme, sanitizedPrefix);
91
- if (themeVars) {
92
- result += themeVars + "\n";
93
- }
94
- }
95
- const baseCss = getCssTextBase();
96
- // Remove any existing theme variable blocks (they're already included above)
97
- const cleanedCss = removeThemeVariableBlocks(baseCss).trim();
98
- if (cleanedCss) {
99
- result += (result ? "\n" : "") + cleanedCss;
100
- }
101
- return result;
102
- }
103
- return {
104
- config: { ...config, prefix: sanitizedPrefix },
105
- createTheme,
106
- css,
107
- getCssText,
108
- globalCss,
109
- globalCssConfig,
110
- keyframes,
111
- media,
112
- mergedThemeMap,
113
- preloadTheme,
114
- sanitizedPrefix,
115
- theme: themeObject,
116
- utils,
117
- // Internal values for React API creation
118
- validatedTheme,
119
- warmCache,
120
- };
121
- }
122
- export function createStoop(config) {
123
- const base = createStoopBase(config);
124
- // Create full client instance (React APIs may be undefined in SSR contexts)
125
- // Create Provider and useTheme if themes are configured
126
- let Provider;
127
- let useTheme;
128
- let themeContext;
129
- if (config.themes) {
130
- const mergedThemesForProvider = {};
131
- for (const [themeName, themeOverride] of Object.entries(config.themes)) {
132
- mergedThemesForProvider[themeName] = base.createTheme(themeOverride);
133
- }
134
- const { Provider: ProviderComponent, ThemeContext, ThemeManagementContext, } = createProvider(mergedThemesForProvider, base.validatedTheme, base.sanitizedPrefix, base.globalCssConfig, base.globalCss);
135
- themeContext = ThemeContext;
136
- Provider = ProviderComponent;
137
- useTheme = createUseThemeHook(ThemeManagementContext);
138
- }
139
- // Create styled function
140
- const styled = createStyledFunction(base.validatedTheme, base.sanitizedPrefix, base.media, base.utils, base.mergedThemeMap, themeContext);
141
- // Return instance with all APIs
142
- return {
143
- config: base.config,
144
- createTheme: base.createTheme,
145
- css: base.css,
146
- getCssText: base.getCssText,
147
- globalCss: base.globalCss,
148
- keyframes: base.keyframes,
149
- preloadTheme: base.preloadTheme,
150
- Provider,
151
- styled,
152
- theme: base.theme,
153
- useTheme,
154
- warmCache: base.warmCache,
155
- };
156
- }
1
+ var r=Object.freeze({}),s=1e4,CJ=5000,fJ=10,SJ=500,S=1000,dJ=31536000,uJ="/",WJ=["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 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 yJ=new V(CJ),DJ=new V(s);function w(){return typeof window!=="undefined"&&typeof document!=="undefined"&&typeof window.document==="object"&&typeof document.createElement==="function"}function d(){return typeof process!=="undefined"&&process.env?.NODE_ENV==="production"}function t(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 UJ(J){return t(J)&&!m(J)}function FJ(J){return typeof J==="object"&&J!==null&&!Array.isArray(J)}function e(J){if(!J||typeof J!=="object"||Array.isArray(J))throw new Error("[Stoop] Theme must be a non-null object");if(d())return J;let $=J,q=[];for(let X in $){if(X==="media")continue;if(!WJ.includes(X))q.push(X)}if(q.length>0){let X=`[Stoop] Theme contains invalid scales: ${q.join(", ")}. Only these scales are allowed: ${WJ.join(", ")}`;throw new Error(X)}return J}function i(J,$){if(!$||!J||typeof J!=="object")return J;let q={},X=Object.keys($);for(let Y in J){let W=J[Y];if(X.includes(Y)&&$[Y])try{let G=$[Y](W);if(G&&typeof G==="object")for(let Z in G)q[Z]=G[Z]}catch{q[Y]=W}else if(t(W))q[Y]=i(W,$);else q[Y]=W}return q}var HJ=null,hJ=new V(S),cJ=new V(S),pJ=new V(S);function u(J){let X=2166136261;for(let Y=0;Y<J.length;Y++)X^=J.charCodeAt(Y),X=Math.imul(X,16777619);return X^=J.length,(X>>>0).toString(36)}function LJ(J){try{return u(JSON.stringify(J))}catch{return u(String(J))}}function nJ(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 mJ(J){return nJ(J,!1)}function k(J){let $=hJ.get(J);if($!==void 0)return $;let q=J.replace(/[^a-zA-Z0-9\s\-_>+~:.#[\]&@()]/g,""),X=!q.trim()||/^[>+~:.#[\]&@()\s]+$/.test(q)?"":q;return hJ.set(J,X),X}function b(J){let $=pJ.get(J);if($!==void 0)return $;let Y=J.replace(/[^a-zA-Z0-9-_]/g,"-").replace(/^[\d-]+/,"").replace(/^-+/,"")||"invalid";return pJ.set(J,Y),Y}function iJ(J){return nJ(J,!0)}function M(J){if(!J)return"stoop";return J.replace(/[^a-zA-Z0-9-_]/g,"").replace(/^[\d-]+/,"").replace(/^-+/,"")||"stoop"}function oJ(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 $=cJ.get(J);if($!==void 0)return $;let q=J.trim().split(/\s+/),X=[];for(let W of q){if(!W)continue;let Z=W.replace(/[^a-zA-Z0-9-_]/g,"").replace(/^\d+/,"");if(Z&&/^[a-zA-Z-_]/.test(Z))X.push(Z)}let Y=X.join(" ");return cJ.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(!HJ){let q=":root".replace(/[.*+?^${}()|[\]\\]/g,"\\$&");HJ=new RegExp(`${q}\\s*\\{[\\s\\S]*\\}`)}return HJ}function O0(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 O0(J)}var BJ=new Map;function qJ(J){return BJ.has(J)}function $J(J,$){BJ.set(J,$)}var wJ=new V(s);function J0(J){if(!wJ.has(J))wJ.set(J,!0)}function tJ(){return Array.from(wJ.keys()).join(`
2
+ `)}var JJ=new Map;var eJ=new Map;function $0(J="stoop"){if(!w())throw new Error("Cannot access document in SSR context");let $=M(J),q=JJ.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",$),JJ.set($,q),q}q=document.createElement("style"),q.setAttribute("data-stoop",$),q.setAttribute("id",`stoop-${$}`),document.head.appendChild(q),JJ.set($,q)}return q}function _J(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 W=1,G=Y+1;while(G<$.length&&W>0){if($[G]==="{")W++;else if($[G]==="}")W--;G++}if(W===0){let Z=$.substring(0,X).trim(),Q=$.substring(G).trim();$=(Z+`
3
+ `+Q).trim()}else break;X=$.indexOf("[data-theme=")}return $.trim()}function q0(J,$="stoop"){if(!J)return;let q=M($),X=`__all_theme_vars_${q}`;if((eJ.get(X)??null)===J)return;if(eJ.set(X,J),!w()){J0(J);return}let W=$0(q),G=W.textContent||"",Z=G.includes(":root")||G.includes("[data-theme=");if(qJ(X)||Z){let Q=_J(G);W.textContent=J+(Q?`
4
+
5
+ `+Q:""),$J(X,J)}else W.textContent=J+(G?`
6
+
7
+ `+G:""),$J(X,J)}function M0(J,$,q="stoop"){if(!w())return;let X=M(q);if(qJ($))return;let Y=$0(X),W=Y.textContent||"";Y.textContent=W+(W?`
8
+ `:"")+J,$J($,J)}function E0(J,$,q="stoop"){if(qJ($))return;let X=M(q);M0(J,$,X)}function V0(J="stoop"){let $=M(J);return JJ.get($)||null}function K0(){return new Map(BJ)}function y(J,$="stoop",q){let X=q||J;if(!w()){if(!qJ(X))$J(X,J);J0(J);return}E0(J,X,$)}function X0(J="stoop"){if(w()){let $=M(J),q=V0($);if(q&&q.parentNode){let X=q.textContent||"";if(!X&&K0().size>0)return tJ();return X}}return tJ()}var z0=/(-?\$[a-zA-Z][a-zA-Z0-9]*(?:\$[a-zA-Z][a-zA-Z0-9]*)?(?:\.[a-zA-Z][a-zA-Z0-9]*)?)/g;function IJ(J){let $=new Map;function q(X,Y=[]){let W=Object.keys(X);for(let G of W){let Z=X[G],Q=[...Y,G];if(FJ(Z))q(Z,Q);else{let D=$.get(G);if(D)D.push(Q);else $.set(G,[Q])}}}q(J);for(let[,X]of $.entries())if(X.length>1)X.sort((Y,W)=>{let G=Y.length-W.length;if(G!==0)return G;let Z=Y.join("."),Q=W.join(".");return Z.localeCompare(Q)});return $}function P0(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(!P0(J,$))return!1;let q={...J},X={...$};return delete q.media,delete X.media,JSON.stringify(q)===JSON.stringify(X)}function AJ(J,$,q){if(q&&q in J){let W=J[q];if(W&&typeof W==="object"&&!Array.isArray(W)&&$ in W)return[q,$]}let Y=IJ(J).get($);if(!Y||Y.length===0)return null;return Y[0]}function Y0(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)=>b(U)).join("-")}`})`;if($&&q){let Z=aJ(q,X);if(Z){let F=AJ($,Y,Z);if(F)return`var(${`--${F.map((O)=>b(O)).join("-")}`})`}let D=IJ($).get(Y);if(D&&D.length>1){if(!d()){let F=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: ${D.map((H)=>H.join(".")).join(", ")}. ${F}Using "${D[0].join(".")}" (deterministic: shorter paths first, then alphabetical). Use full path "$${D[0].join(".")}" to be explicit.`)}}let U=AJ($,Y);if(U)return`var(${`--${U.map((L)=>b(L)).join("-")}`})`}else if($){let Q=IJ($).get(Y);if(Q&&Q.length>1){if(!d())console.warn(`[Stoop] Ambiguous token "$${Y}" found in multiple categories: ${Q.map((U)=>U.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.`)}let D=AJ($,Y);if(D)return`var(${`--${D.map((H)=>b(H)).join("-")}`})`}return`var(${`--${b(Y)}`})`}function RJ(J,$="stoop",q){let X=q||":root",Y=[];function W(G,Z=[]){let Q=Object.keys(G).sort();for(let D of Q){if(D==="media")continue;let U=G[D],F=[...Z,D];if(FJ(U))W(U,F);else{let L=`--${F.map((_)=>b(_)).join("-")}`,O=typeof U==="string"||typeof U==="number"?iJ(U):String(U);Y.push(` ${L}: ${O};`)}}}if(W(J),Y.length===0)return"";return`${X} {
9
+ ${Y.join(`
10
+ `)}
11
+ }`}function XJ(J,$="stoop",q="data-theme"){let X=[];for(let[Y,W]of Object.entries(J)){let G=`[${q}="${Y}"]`,Z=RJ(W,$,G);if(Z)X.push(Z)}return X.join(`
12
+
13
+ `)}function h(J,$,q,X){if(!J||typeof J!=="object")return J;let Y={},W=!1,G=Object.keys(J).sort();for(let Z of G){let Q=J[Z];if(t(Q)){let D=h(Q,$,q,void 0);if(Y[Z]=D,D!==Q)W=!0}else if(typeof Q==="string"&&Q.includes("$")){W=!0;let D=X||Z;Y[Z]=Q.replace(z0,(U)=>{if(U.startsWith("-$")){let F=U.slice(1);return`calc(-1 * ${Y0(F,$,D,q)})`}return Y0(U,$,D,q)})}else Y[Z]=Q}if(!W)return J;return Y}var x=new V(S);function j0(J){return J.replace(/([A-Z])/g,"-$1").toLowerCase()}function x0(J){if(J===J.toUpperCase()&&J.length>1)return J.charAt(0)+J.slice(1).toLowerCase();return J}function YJ(J){if(!J)return"";return J.charAt(0).toLowerCase()+J.slice(1).replace(/([A-Z])/g,"-$1").toLowerCase()}function GJ(J){if(!J||typeof J!=="string")return"";let $=x.get(J);if($!==void 0)return $;if(/^-[a-z]+-/.test(J))return x.set(J,J),J;let q=x0(J);if(/^[Mm]oz/i.test(q)){if(q.length===3||q.toLowerCase()==="moz")return x.set(J,"-moz"),"-moz";let G=q.match(/^[Mm]oz(.+)$/i);if(G&&G[1]){let[,Z]=G,Q=YJ(Z);if(Q){let D=`-moz-${Q}`;return x.set(J,D),D}}}if(/^[Ww]ebkit/i.test(q)){if(q.length===6||q.toLowerCase()==="webkit")return x.set(J,"-webkit"),"-webkit";let G=q.match(/^[Ww]ebkit(.+)$/i);if(G&&G[1]){let[,Z]=G,Q=YJ(Z);if(Q){let D=`-webkit-${Q}`;return x.set(J,D),D}}}if(/^[Mm]s/i.test(q)){if(q.length===2||q.toLowerCase()==="ms")return x.set(J,"-ms"),"-ms";let G=q.match(/^[Mm]s(.+)$/i);if(G&&G[1]){let[,Z]=G,Q=YJ(Z);if(Q){let D=`-ms-${Q}`;return x.set(J,D),D}}}if(/^O/i.test(q)){if(q.length===1||q.toLowerCase()==="o")return x.set(J,"-o"),"-o";if(/^O[A-Z]/.test(q)){let G=q.substring(1),Z=YJ(G);if(Z){let Q=`-o-${Z}`;return x.set(J,Q),Q}}}let W=j0(q).replace(/[^a-zA-Z0-9-]/g,"").replace(/^-+|-+$/g,"").replace(/^\d+/,"")||"";return x.set(J,W),W}function N0(J,$){if(typeof J==="symbol"&&J===a)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 N(J,$="",q=0,X){if(!J||typeof J!=="object")return"";if(q>fJ)return"";let Y=[],W=[],G=Object.keys(J).sort();for(let Q of G){let D=J[Q];if(N0(Q,D)){let U=v0(Q,D);if(!U)continue;let F=k(U);if(!F)continue;let H=$?`${$} .${F}`:`.${F}`,L=UJ(D)?N(D,H,q+1,X):"";if(L)W.push(L);continue}if(UJ(D))if(X&&Q in X){let U=oJ(X[Q]);if(U){let F=N(D,$,q+1,X);if(F)W.push(`${U} { ${F} }`)}}else if(Q.startsWith("@")){let U=k(Q);if(U){let F=N(D,$,q+1,X);if(F)W.push(`${U} { ${F} }`)}}else if(Q.includes("&")){let U=k(Q);if(U){let H=U.split("&").join($),L=N(D,H,q+1,X);if(L)W.push(L)}}else if(Q.startsWith(":")){let U=k(Q);if(U){let F=`${$}${U}`,H=N(D,F,q+1,X);if(H)W.push(H)}}else if(Q.includes(" ")||Q.includes(">")||Q.includes("+")||Q.includes("~")){let U=k(Q);if(U){let H=/^[\s>+~]/.test(U.trim())?`${$}${U}`:`${$} ${U}`,L=N(D,H,q+1,X);if(L)W.push(L)}}else{let U=k(Q);if(U){let F=$?`${$} ${U}`:U,H=N(D,F,q+1,X);if(H)W.push(H)}}else if(D!==void 0){let U=GJ(Q);if(U&&(typeof D==="string"||typeof D==="number")){let F=mJ(D);Y.push(`${U}: ${F};`)}}}let Z=[];if(Y.length>0)Z.push(`${$} { ${Y.join(" ")} }`);return Z.push(...W),Z.join("")}function c(J,$,q="stoop",X,Y,W){let G=M(q),Z=i(J,Y),Q=h(Z,$,W),D=N(Q,"",0,X),U=u(D),F=G?`${G}-${U}`:`css-${U}`,H=`${G}:${F}`,L=DJ.get(H);if(L)return y(L,G,H),F;let O=N(Q,`.${F}`,0,X);return DJ.set(H,O),yJ.set(H,F),y(O,G,H),F}var Q0=new Map;function Z0(J,$="stoop"){let q=$||"";Q0.set(q,J)}function g0(J="stoop"){let $=J||"";return Q0.get($)||null}function OJ(J,$){let q={...J},X=Object.keys($);for(let Y of X){if(Y==="media")continue;let W=$[Y],G=J[Y];if(W&&typeof W==="object"&&!Array.isArray(W)&&G&&typeof G==="object"&&!Array.isArray(G))q[Y]={...G,...W};else if(W!==void 0)q[Y]=W}return q}function MJ(J,$="stoop"){let q=g0($);if(!q)return J;if(G0(J,q))return J;return OJ(q,J)}function QJ(J,$="stoop",q="data-theme"){if(!w())return;let X={};for(let[W,G]of Object.entries(J))X[W]=MJ(G,$);let Y=XJ(X,$,q);q0(Y,$)}function W0(J){return function $(q={}){let X=e(q);return OJ(J,X)}}function D0(J,$="stoop",q,X,Y){return function W(G){return c(G,J,$,q,X,Y)}}function T0(J,$,q,X){let Y=`@keyframes ${$} {`,W=Object.keys(J).sort((G,Z)=>{let Q=parseFloat(G.replace("%","")),D=parseFloat(Z.replace("%",""));if(G==="from")return-1;if(Z==="from")return 1;if(G==="to")return 1;if(Z==="to")return-1;return Q-D});for(let G of W){if(!rJ(G))continue;let Z=J[G];if(!Z||typeof Z!=="object")continue;Y+=` ${G} {`;let Q=h(Z,q,X),D=Object.keys(Q).sort();for(let U of D){let F=Q[U];if(F!==void 0&&(typeof F==="string"||typeof F==="number")){let H=GJ(U);if(H){let L=String(F);Y+=` ${H}: ${L};`}}}Y+=" }"}return Y+=" }",Y}function U0(J="stoop",$,q){let X=M(J),Y=new V(SJ);return function W(G){let Z=LJ(G),Q=Y.get(Z);if(Q)return Q;let D=Z.slice(0,8),U=X?`${X}-${D}`:`stoop-${D}`,F=T0(G,U,$,q),H=`__keyframes_${U}`;return y(F,X,H),Y.set(Z,U),U}}var EJ=new Set;function F0(J,$="stoop",q,X,Y){return function W(G){let Z=LJ(G);if(EJ.has(Z))return()=>{};EJ.add(Z);let Q=M($),D=i(G,X),U=h(D,J,Y),F=N(U,"",0,q);return y(F,Q,`__global_${Z}`),()=>{EJ.delete(Z)}}}import{useMemo as ZJ,forwardRef as k0,createElement as b0,useContext as C0,createContext as f0}from"react";function S0(J,$,q){let X=[];for(let W in J){let G=$[W];if(G===void 0)continue;let Z=J[W],Q=G===!0?"true":G===!1?"false":String(G);if(Z[Q])X.push(Z[Q])}if(X.length===0)return q;if(X.length===1)return{...q,...X[0]};let Y={...X[0]};for(let W=1;W<X.length;W++)Object.assign(Y,X[W]);return{...q,...Y}}var VJ=null;function d0(){if(!VJ)VJ=f0(null);return VJ}function u0(J){return{__isStoopStyled:!0,__stoopClassName:J,[a]:J,toString:()=>`__STOOP_COMPONENT_${J}`}}function y0(J){return m(J)}var h0=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 c0(J){return h0.has(J)}function p0(J,$){let q=$?new Set(Object.keys($)):new Set,X={},Y={},W={};for(let G in J)if(q.has(G))X[G]=J[G];else if(c0(G))Y[G]=J[G];else W[G]=J[G];return{cssProps:Y,elementProps:W,variantProps:X}}function H0(J,$="stoop",q,X,Y,W){return function G(Z,Q){let D=Q||r,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((P)=>typeof P==="object"&&P!==null&&!Array.isArray(P))){U=Q.variants;let{variants:P,...A}=Q;D=A}}let F;if(typeof Z!=="string"&&y0(Z))F=Z.__stoopClassName;let H=k0(function B(v,P){let{as:A,className:K,css:j,...z}=v,C=A||Z,g=ZJ(()=>j&&typeof j==="object"&&j!==null?j:r,[j]),{cssProps:T,elementProps:I,variantProps:E}=p0(z,U),l=C0(W||d0())?.theme||J,gJ=l.media?{...q,...l.media}:q,TJ=ZJ(()=>{if(!U)return"";let R=Object.entries(E);if(R.length===0)return"";return R.sort(([f],[p])=>f.localeCompare(p)).map(([f,p])=>`${f}:${String(p)}`).join("|")},[E]),kJ=ZJ(()=>{let R=D;if(U&&TJ)R=S0(U,E,D);if(Object.keys(T).length>0)R=Object.assign({},R,T);if(g!==r)R=Object.assign({},R,g);return R},[TJ,g,T,D,U,E]),R0=ZJ(()=>{let R=[];if(F)R.push(F);let f=c(kJ,l,$,gJ,X,Y);if(f)R.push(f);if(K){let p=typeof K==="string"?K:String(K),bJ=lJ(p);if(bJ)R.push(bJ)}return R.length>0?R.join(" "):void 0},[kJ,K,F,l,$,gJ,X,Y]);return b0(C,{...I,className:R0,ref:P})}),L=u(JSON.stringify(D)),O=`${$}-${L}`,_=H;return _.selector=u0(O),_}}import{createContext as w0,useCallback as B0,useContext as n0,useLayoutEffect as o,useMemo as jJ,useRef as xJ,useState as m0}from"react";function KJ(J){if(!w())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 zJ(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 PJ(J){if(!w())return null;let q=`; ${document.cookie}`.split(`; ${J}=`);if(q.length===2)return q.pop()?.split(";").shift()||null;return null}function L0(J,$,q={}){if(!w())return!1;let{maxAge:X=dJ,path:Y=uJ,secure:W=!1}=q;try{return document.cookie=`${J}=${$}; path=${Y}; max-age=${X}${W?"; secure":""}`,!0}catch{return!1}}import{jsx as _0}from"react/jsx-runtime";function NJ(J,$,q){if(!w())return;let X=$?PJ($):null,Y=KJ(q),W=Y.success?Y.value:null;if(X===J&&W!==J)zJ(q,J);if(W===J&&$&&X!==J)L0($,J)}function i0(J,$,q){if(!w())return null;if(J!==void 0){let W=PJ(J);if(W&&q[W])return W}let X=KJ($),Y=X.success?X.value:null;if(Y&&q[Y])return Y;return null}function A0(J,$,q="stoop",X,Y){let W=w0(null),G=w0(null),Z=Object.keys(J),Q=Z[0]||"default",D=X&&Y?Y(X):void 0;function U({attribute:F="data-theme",children:H,cookieKey:L,defaultTheme:O,storageKey:_="stoop-theme"}){let[B,v]=m0(O||Q),P=xJ(!1);o(()=>{if(!w()||P.current)return;let I=i0(L,_,J);if(I){if(NJ(I,L,_),I!==B)v(I)}P.current=!0},[L,_,J]),o(()=>{if(!w())return;let I=(E)=>{if(E.key===_&&E.newValue&&J[E.newValue]&&E.newValue!==B)v(E.newValue),NJ(E.newValue,L,_)};return window.addEventListener("storage",I),()=>{window.removeEventListener("storage",I)}},[_,L,B,J]);let A=jJ(()=>{return J[B]||J[O||Q]||$},[B,O,Q,J,$]),K=xJ(!1),j=xJ(!1);o(()=>{if(!w()||K.current)return;QJ(J,q,F),K.current=!0},[J,q,F]),o(()=>{if(!w()||j.current)return;if(D)D(),j.current=!0},[D]),o(()=>{if(!w())return;if(F)document.documentElement.setAttribute(F,B)},[B,F]);let z=B0((I)=>{if(J[I])v(I),zJ(_,I),NJ(I,L,_);else if(!d())console.warn(`[Stoop] Theme "${I}" not found. Available themes: ${Z.join(", ")}`)},[_,L,J,Z,B]),C=jJ(()=>({theme:A,themeName:B}),[A,B]),g=B0(()=>{let E=(Z.indexOf(B)+1)%Z.length,vJ=Z[E];z(vJ)},[B,z,Z]),T=jJ(()=>({availableThemes:Z,setTheme:z,theme:A,themeName:B,toggleTheme:g}),[A,B,z,g]);return _0(W.Provider,{value:C,children:_0(G.Provider,{value:T,children:H})})}return{Provider:U,ThemeContext:W,ThemeManagementContext:G}}function I0(J){return function $(){let q=n0(J);if(!q)throw new Error("useTheme must be used within a Provider");return q}}function o0(J){let{globalCss:$,media:q,prefix:X="stoop",theme:Y,themeMap:W,utils:G}=J,Z=M(X),Q=e(Y),D=Q.media||q,U={...n,...W};Z0(Q,Z);let F=D0(Q,Z,D,G,U),H=W0(Q),L=F0(Q,Z,D,G,U),O=U0(Z,Q,U),_=Object.freeze({...Q});function B(A){for(let K of A)try{c(K,Q,Z,D,G,U)}catch{}}function v(){if(!J.themes||Object.keys(J.themes).length===0)return;QJ(J.themes,Z)}function P(){let A="";if(J.themes&&Object.keys(J.themes).length>0){let z={};for(let[g,T]of Object.entries(J.themes))z[g]=MJ(T,Z);let C=XJ(z,Z,"data-theme");if(C)A+=C+`
14
+ `}else{let z=RJ(Q,Z);if(z)A+=z+`
15
+ `}let K=X0(),j=_J(K).trim();if(j)A+=(A?`
16
+ `:"")+j;return A}return{config:{...J,prefix:Z},createTheme:H,css:F,getCssText:P,globalCss:L,globalCssConfig:$,keyframes:O,media:D,mergedThemeMap:U,preloadTheme:v,sanitizedPrefix:Z,theme:_,utils:G,validatedTheme:Q,warmCache:B}}function Z4(J){let $=o0(J),q,X,Y;if(J.themes){let G={};for(let[U,F]of Object.entries(J.themes))G[U]=$.createTheme(F);let{Provider:Z,ThemeContext:Q,ThemeManagementContext:D}=A0(G,$.validatedTheme,$.sanitizedPrefix,$.globalCssConfig,$.globalCss);Y=Q,q=Z,X=I0(D)}let W=H0($.validatedTheme,$.sanitizedPrefix,$.media,$.utils,$.mergedThemeMap,Y);return{config:$.config,createTheme:$.createTheme,css:$.css,getCssText:$.getCssText,globalCss:$.globalCss,keyframes:$.keyframes,preloadTheme:$.preloadTheme,Provider:q,styled:W,theme:$.theme,useTheme:X,warmCache:$.warmCache}}export{o0 as createStoopBase,Z4 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
  /**