"use strict";
Object.defineProperty(exports, "__esModule", {
    value: true
});
Object.defineProperty(exports, "SliderMarks", {
    enumerable: true,
    get: function() {
        return SliderMarks;
    }
});
const _jsxruntime = require("react/jsx-runtime");
const _css = require("../utils/css");
const _react = /*#__PURE__*/ _interop_require_wildcard(require("react"));
const _utils = require("../slider/utils");
function _getRequireWildcardCache(nodeInterop) {
    if (typeof WeakMap !== "function") return null;
    var cacheBabelInterop = new WeakMap();
    var cacheNodeInterop = new WeakMap();
    return (_getRequireWildcardCache = function(nodeInterop) {
        return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
    })(nodeInterop);
}
function _interop_require_wildcard(obj, nodeInterop) {
    if (!nodeInterop && obj && obj.__esModule) {
        return obj;
    }
    if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
        return {
            default: obj
        };
    }
    var cache = _getRequireWildcardCache(nodeInterop);
    if (cache && cache.has(obj)) {
        return cache.get(obj);
    }
    var newObj = {
        __proto__: null
    };
    var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
    for(var key in obj){
        if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
            var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
            if (desc && (desc.get || desc.set)) {
                Object.defineProperty(newObj, key, desc);
            } else {
                newObj[key] = obj[key];
            }
        }
    }
    newObj.default = obj;
    if (cache) {
        cache.set(obj, newObj);
    }
    return newObj;
}
const SliderMarks = (props)=>{
    const { marks, value, markLabelVisible, isInnerMask } = props;
    // const spanRef = useRef<HTMLSpanElement | null>(null);
    const _value = (0, _react.useMemo)(()=>value?.[0] ?? 0, [
        value
    ]);
    const _max = (0, _react.useMemo)(()=>props.max === 0 ? 1 : props.max, [
        props.max
    ]);
    return /*#__PURE__*/ (0, _jsxruntime.jsx)(_jsxruntime.Fragment, {
        children: marks?.map((mark, index)=>{
            // const percent = convertValueToPercentage(mark.value, props.min, _max);
            const percent = (0, _utils.convertValueToPercentage)(index, 0, marks.length - 1);
            const thumbInBoundsOffset = (0, _utils.getThumbInBoundsOffset)(6, percent, 1);
            const __value = isInnerMask ? mark.value : index;
            return /*#__PURE__*/ (0, _jsxruntime.jsxs)(_react.Fragment, {
                children: [
                    /*#__PURE__*/ (0, _jsxruntime.jsx)("span", {
                        className: (0, _css.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__*/ (0, _jsxruntime.jsx)("span", {
                        className: (0, _css.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