'use client';
import {
  clsx
} from "../chunk-XUDKYAVC.js";
import "../chunk-O23TLLXW.js";

// src/integrations/css-modules-helper.tsx
import { jsx } from "react/jsx-runtime";
function createSemiontClassName(styles, baseClass) {
  return function buildClassName(_dataAttributes, additionalClasses) {
    const classes = [baseClass];
    if (styles[baseClass]) {
      classes.push(styles[baseClass]);
    }
    if (additionalClasses) {
      classes.push(additionalClasses);
    }
    return clsx(...classes);
  };
}
function generateDataAttributes(props) {
  return {
    "data-variant": props.variant,
    "data-size": props.size,
    "data-loading": props.loading ? "true" : void 0,
    "data-full-width": props.fullWidth ? "true" : void 0,
    "data-icon-only": props.iconOnly ? "true" : void 0,
    "data-active": props.active ? "true" : void 0,
    "data-disabled": props.disabled ? "true" : void 0,
    "data-orientation": props.orientation,
    "data-attached": props.attached ? "true" : void 0,
    "data-spacing": props.attached ? void 0 : props.spacing
  };
}
function mergeDataAttributes(props, dataAttributes) {
  const merged = { ...props };
  Object.entries(dataAttributes).forEach(([key, value]) => {
    if (value !== void 0) {
      merged[key] = value;
    }
  });
  return merged;
}
function withCSSModules(Component, styles, baseClassName) {
  return function WrappedComponent(props) {
    const className = clsx(
      baseClassName,
      styles[baseClassName],
      props.className
    );
    return /* @__PURE__ */ jsx(Component, { ...props, className });
  };
}
var cssModulesConfig = {
  // PostCSS config for CSS Modules
  postcss: {
    plugins: [
      // Preserve data-attribute selectors
      {
        postcssPlugin: "preserve-data-attributes",
        Once(root) {
          root.walkRules((rule) => {
            if (rule.selector.includes("[data-")) {
              rule.selector = rule.selector.replace(
                /\.([a-zA-Z][a-zA-Z0-9-_]*)/g,
                (_match, className) => {
                  return `:global(.${className})`;
                }
              );
            }
          });
        }
      }
    ]
  },
  // Webpack config for CSS Modules
  webpack: {
    cssLoader: {
      modules: {
        // Custom naming for CSS Modules
        localIdentName: "[name]__[local]___[hash:base64:5]",
        // Preserve data-attribute selectors
        getLocalIdent: (_context, _localIdentName, localName) => {
          if (localName.startsWith("semiont-")) {
            return localName;
          }
          return null;
        }
      }
    }
  },
  // Vite config for CSS Modules
  vite: {
    css: {
      modules: {
        // Custom naming for CSS Modules
        generateScopedName: "[name]__[local]___[hash:base64:5]",
        // Preserve specific selectors
        scopeBehaviour: "local",
        // Global patterns
        globalModulePaths: [/semiont-.*\.css$/]
      }
    }
  }
};
function defineCSSModules(styles) {
  return styles;
}
export {
  createSemiontClassName,
  cssModulesConfig,
  defineCSSModules,
  generateDataAttributes,
  mergeDataAttributes,
  withCSSModules
};
//# sourceMappingURL=css-modules-helper.js.map