'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

var Slider_tokens = require('../Slider.tokens.js');

var getSingleSliderLayout = function getSingleSliderLayout(_ref) {
  var value = _ref.value,
    min = _ref.min,
    max = _ref.max,
    isVertical = _ref.isVertical,
    isHovered = _ref.isHovered,
    reversed = _ref.reversed,
    scaleTicks = _ref.scaleTicks,
    showRangeValues = _ref.showRangeValues,
    showScale = _ref.showScale,
    showCurrentValue = _ref.showCurrentValue,
    currentValueVisibility = _ref.currentValueVisibility,
    label = _ref.label,
    labelContentLeft = _ref.labelContentLeft,
    labelContent = _ref.labelContent,
    labelPlacement = _ref.labelPlacement,
    sliderAlign = _ref.sliderAlign,
    rangeValuesPlacementOld = _ref.rangeValuesPlacementOld,
    scaleAlign = _ref.scaleAlign,
    pointerSize = _ref.pointerSize,
    pointerVisibility = _ref.pointerVisibility;
  var innerShowScale = Boolean((showRangeValues || showScale) && !scaleTicks);
  var innerShowCurrentValue = !scaleTicks && (currentValueVisibility === 'hover' ? showCurrentValue && isHovered : showCurrentValue);
  var hasLabelContent = Boolean(label || labelContentLeft || labelContent) && (!isVertical || sliderAlign !== 'none');
  var labelPlacementClass = !isVertical && (labelPlacement === 'outer' || labelPlacement === 'top') ? Slider_tokens.classes.labelPlacementOuter : Slider_tokens.classes.labelPlacementInner;
  var rangeValuesPlacement = rangeValuesPlacementOld === 'outer' || scaleAlign === 'bottom' || scaleAlign === 'top' || Boolean(scaleTicks) ? 'outer' : 'inner';
  var scaleAlignClass = rangeValuesPlacement === 'outer' ? Slider_tokens.classes.rangeValuesPlacementOuter : Slider_tokens.classes.rangeValuesPlacementInner;
  var labelVerticalPlacement = reversed ? 'bottom' : 'top';
  var showPointer = pointerSize !== 'none' && (pointerVisibility === 'always' || isHovered);
  var thumbPercent = (value - min) / (max - min);
  var thumbSize = "var(".concat(Slider_tokens.privateTokens.thumbSize, ")");
  var thumbPosition = "calc(".concat(thumbPercent, " * (100% - ").concat(thumbSize, ") + ").concat(thumbSize, " / 2)");
  var currentValueStyle = isVertical ? {
    top: "calc(".concat(1 - thumbPercent, " * (100% - ").concat(thumbSize, ") + ").concat(thumbSize, " / 2)")
  } : {
    left: thumbPosition
  };
  var progressSizeStyle = isVertical ? {
    height: "calc(".concat(thumbPercent, " * (100% - ").concat(thumbSize, "))")
  } : {
    width: "calc(".concat(thumbPercent, " * (100% - ").concat(thumbSize, "))")
  };
  return {
    innerShowScale: innerShowScale,
    innerShowCurrentValue: innerShowCurrentValue,
    hasLabelContent: hasLabelContent,
    labelPlacementClass: labelPlacementClass,
    rangeValuesPlacement: rangeValuesPlacement,
    scaleAlignClass: scaleAlignClass,
    labelVerticalPlacement: labelVerticalPlacement,
    showPointer: showPointer,
    currentValueStyle: currentValueStyle,
    progressSizeStyle: progressSizeStyle
  };
};

exports.getSingleSliderLayout = getSingleSliderLayout;
