import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
import { cn } from "../utils/css";
import React, { Fragment, useMemo } from "react";
import { convertValueToPercentage, getThumbInBoundsOffset } from "../slider/utils";
export const SliderMarks = (props)=>{
    const { marks, value, markLabelVisible, isInnerMask } = props;
    // const spanRef = useRef<HTMLSpanElement | null>(null);
    const _value = useMemo(()=>value?.[0] ?? 0, [
        value
    ]);
    const _max = useMemo(()=>props.max === 0 ? 1 : props.max, [
        props.max
    ]);
    return /*#__PURE__*/ _jsx(_Fragment, {
        children: marks?.map((mark, index)=>{
            // const percent = convertValueToPercentage(mark.value, props.min, _max);
            const percent = convertValueToPercentage(index, 0, marks.length - 1);
            const thumbInBoundsOffset = getThumbInBoundsOffset(6, percent, 1);
            const __value = isInnerMask ? mark.value : index;
            return /*#__PURE__*/ _jsxs(Fragment, {
                children: [
                    /*#__PURE__*/ _jsx("span", {
                        className: cn("orderly-absolute orderly-top-[7px] orderly-w-[6px] orderly-h-[6px] orderly-rounded orderly-border orderly-border-base-200 orderly-bg-base-800 orderly-pointer-events-none orderly-translate-x-[-50%]", {
                            "orderly-border-primary orderly-bg-primary": props.color === "primary" && _value >= __value && _value > 0 && !props.disabled,
                            "orderly-border-primary-light orderly-bg-primary-light": props.color === "primary-light" && _value >= __value && _value > 0 && !props.disabled,
                            "orderly-border-trade-profit orderly-bg-trade-profit": props.color === "buy" && _value >= __value && _value > 0 && !props.disabled,
                            "orderly-border-trade-loss orderly-bg-trade-loss": props.color === "sell" && _value >= __value && _value > 0 && !props.disabled
                        }),
                        style: {
                            left: `calc(${percent}% + ${thumbInBoundsOffset}px)`
                        }
                    }),
                    !props.disabled && markLabelVisible && /*#__PURE__*/ _jsx("span", {
                        className: cn("orderly-absolute orderly-top-[20px] orderly-text-2xs orderly-text-base-contrast/50 orderly-pointer-events-none orderly-translate-x-[-50%] desktop:orderly-text-xs"),
                        style: {
                            left: `calc(${percent}% + ${thumbInBoundsOffset}px)`
                        },
                        children: mark.label
                    }, index)
                ]
            }, index);
        })
    });
};

//# sourceMappingURL=marks.js.map