import { mergeProps } from 'zag-ripple';
import { trackSplit, track } from 'ripple';
import { useAngleSliderContext } from './use-angle-slider-context';
import { ark } from '../factory';
import type { HTMLProps, MaybeTracked, PolymorphicProps } from '../../types';

export interface AngleSliderLabelBaseProps extends PolymorphicProps<'label'> {}
export interface AngleSliderLabelProps extends HTMLProps<'label'>, AngleSliderLabelBaseProps {}

export component AngleSliderLabel(props: MaybeTracked<AngleSliderLabelProps>) {
  const [children, rest] = trackSplit(props, ['children']);
  const angleSlider = useAngleSliderContext();

  let mergedProps = track(() => mergeProps(@angleSlider.getLabelProps(), @rest));

  <ark.label {...@mergedProps}>
    <@children />
  </ark.label>
}
