import { classes } from "../Slider.tokens";
export const getSingleSliderLayout = ({ value, min, max, isVertical, isHovered, reversed, scaleTicks, showRangeValues, showScale, showCurrentValue, currentValueVisibility, label, labelContentLeft, labelContent, labelPlacement, sliderAlign, rangeValuesPlacementOld, scaleAlign, pointerSize, pointerVisibility, valuePlacement })=>{
    const innerShowScale = Boolean((showRangeValues || showScale) && !scaleTicks);
    const innerShowCurrentValue = !scaleTicks && (currentValueVisibility === 'hover' ? showCurrentValue && isHovered : showCurrentValue);
    const hasLabelContent = Boolean(label || labelContentLeft || labelContent) && (!isVertical || sliderAlign !== 'none');
    const labelPlacementClass = !isVertical && (labelPlacement === 'outer' || labelPlacement === 'top') ? classes.labelPlacementOuter : classes.labelPlacementInner;
    const rangeValuesPlacement = rangeValuesPlacementOld === 'outer' || scaleAlign === 'bottom' || scaleAlign === 'top' || Boolean(scaleTicks) ? 'outer' : 'inner';
    const scaleAlignClass = rangeValuesPlacement === 'outer' ? classes.rangeValuesPlacementOuter : classes.rangeValuesPlacementInner;
    const labelVerticalPlacement = reversed ? 'bottom' : 'top';
    const showPointer = pointerSize !== 'none' && (pointerVisibility === 'always' || isHovered);
    const FADE_RANGE = 0.3;
    const fadeOpacity = (proximity)=>Math.min(1, Math.max(0, proximity / FADE_RANGE));
    const thumbPercent = (value - min) / (max - min);
    const progressSize = `calc(${thumbPercent} * 100%)`;
    const progressSizeStyle = isVertical ? {
        height: progressSize
    } : {
        width: progressSize
    };
    const shouldFadeRangeValues = innerShowCurrentValue && valuePlacement !== 'none';
    const rangeMaxValueOpacity = shouldFadeRangeValues ? fadeOpacity(reversed ? thumbPercent : 1 - thumbPercent) : 1;
    const rangeMinValueOpacity = shouldFadeRangeValues ? fadeOpacity(reversed ? 1 - thumbPercent : thumbPercent) : 1;
    const nearHighFactor = Math.min(1, Math.max(0, (thumbPercent - (1 - FADE_RANGE)) / FADE_RANGE));
    const nearLowFactor = Math.min(1, Math.max(0, (FADE_RANGE - thumbPercent) / FADE_RANGE));
    const verticalScaleCompensation = reversed ? '' : ' scaleY(-1)';
    const getHorizontalCurrentValueStyle = ()=>{
        const left = `calc(${thumbPercent} * 100%)`;
        if (nearHighFactor > 0) {
            return {
                left,
                transform: `translateX(-${50 + nearHighFactor * 50}%)`
            };
        }
        if (nearLowFactor > 0) {
            return {
                left,
                transform: `translateX(-${50 - nearLowFactor * 50}%)`
            };
        }
        return {
            left
        };
    };
    const getVerticalCurrentValueStyle = ()=>{
        const top = `calc(${1 - thumbPercent} * 100%)`;
        if (nearHighFactor > 0) {
            return {
                top,
                transform: `translateY(-${50 - nearHighFactor * 50}%)${verticalScaleCompensation}`
            };
        }
        if (nearLowFactor > 0) {
            return {
                top,
                transform: `translateY(-${50 + nearLowFactor * 50}%)${verticalScaleCompensation}`
            };
        }
        return {
            top
        };
    };
    const currentValueStyle = isVertical ? getVerticalCurrentValueStyle() : getHorizontalCurrentValueStyle();
    return {
        innerShowScale,
        innerShowCurrentValue,
        hasLabelContent,
        labelPlacementClass,
        rangeValuesPlacement,
        scaleAlignClass,
        labelVerticalPlacement,
        showPointer,
        currentValueStyle,
        progressSizeStyle,
        rangeMinValueOpacity,
        rangeMaxValueOpacity
    };
};
