import { jsxs, jsx } from 'react/jsx-runtime';
import { forwardRef, useId } from 'react';
import { Switch as Switch$1 } from './primitives/Switch.js';
import { Label } from './primitives/Label.js';
import { c as cn } from './utils-DdHUxIdC.js';

const Switch = forwardRef(({ label, error, helpText, required = false, className, size = "default", disabled, id: idProp, ...otherProps }, ref) => {
    const generatedId = useId();
    const id = idProp ?? generatedId;
    const errorId = `error_${id}`;
    const helpTextId = `helpText_${id}`;
    const ariaDescribedBy = [error ? errorId : null, helpText ? helpTextId : null]
        .filter(Boolean)
        .join(" ") || undefined;
    return (jsxs("div", { className: cn("inline-flex flex-col gap-1.5", className), "data-disabled": disabled || undefined, "data-invalid": !!error || undefined, children: [jsxs("div", { className: cn("inline-flex gap-2", helpText ? "items-start" : "items-center"), children: [jsx(Switch$1, { ref: ref, id: id, size: size, disabled: disabled, "aria-invalid": !!error || undefined, "aria-describedby": ariaDescribedBy, "aria-required": required || undefined, className: helpText ? "mt-0.5" : undefined, ...otherProps }), (label || helpText) && (jsxs("div", { className: "flex flex-col gap-0.5", children: [label && (jsxs(Label, { htmlFor: id, className: cn("cursor-pointer", disabled && "cursor-not-allowed opacity-50"), children: [label, required && (jsx("span", { "aria-hidden": "true", className: "text-destructive", children: "*" }))] })), helpText && (jsx("p", { id: helpTextId, className: "text-sm text-muted-foreground", children: helpText }))] }))] }), error && (jsx("p", { id: errorId, role: "alert", className: "text-xs text-destructive", children: error }))] }));
});
Switch.displayName = "Switch";

export { Switch as S };
//# sourceMappingURL=Switch-B83TGxJ_.js.map
