/*! © 2026 Yahoo, Inc. UDS v0.0.0-development */
"use client";
import { cx, getStyles } from "../../../styles/styler.js";
import { mergeSlotProps } from "../../../utils/mergeSlotProps.js";
import { ChipBase, VARIANT_DEFAULT } from "./ChipBase.js";
import { forwardRef, useCallback, useMemo } from "react";
import { jsx } from "react/jsx-runtime";
//#region src/components/client/Chip/ChipToggle.tsx
const ChipToggle = forwardRef(function ChipToggle({ isToggled = false, onToggle, onClick, variant = VARIANT_DEFAULT, slotProps, className, role = "checkbox", ...rest }, ref) {
	const classNames = useMemo(() => ({
		root: getStyles({
			chipToggleVariantRoot: variant,
			chipToggleVariantActiveRoot: isToggled ? "on" : "off",
			className: cx("uds-ring", className)
		}),
		icon: getStyles({ chipToggleVariantIcon: variant })
	}), [
		className,
		isToggled,
		variant
	]);
	const handleClick = useCallback((e) => {
		onToggle?.(!isToggled);
		onClick?.(e);
	}, [
		isToggled,
		onClick,
		onToggle
	]);
	const mergedSlotProps = mergeSlotProps(slotProps, {
		startIcon: { className: classNames.icon },
		endIcon: { className: classNames.icon }
	});
	return /* @__PURE__ */ jsx(ChipBase, {
		ref,
		as: "button",
		role,
		"aria-checked": role === "checkbox" || role === "switch" ? isToggled : void 0,
		onClick: handleClick,
		className: classNames.root,
		slotProps: mergedSlotProps,
		tabIndex: 0,
		...rest
	});
});
ChipToggle.displayName = "ChipToggle";
//#endregion
export { ChipToggle };
