import React from "react";
import { SLIDER_NORM_WIDTH, SLIDER_SMALL_WIDTH } from "../constants/constants";
import UncontrolledSliderWithPlusMinusBtns from "../helperComponents/UncontrolledSliderWithPlusMinusBtns";
export function ZoomCircularViewSlider(_ref) {
  var zoomHelper = _ref.zoomHelper,
    zoomLevel = _ref.zoomLevel,
    setZoomLevel = _ref.setZoomLevel,
    maxZoomLevel = _ref.maxZoomLevel,
    onZoom = _ref.onZoom,
    smallSlider = _ref.smallSlider;
  var clickStepSize = (maxZoomLevel - 1) / 440;
  clickStepSize = clickStepSize * Math.max(1, Math.log(zoomLevel + 2));
  clickStepSize = Math.round(clickStepSize * 1000) / 1000;
  var stepSize = clickStepSize;
  var min = 1;
  function setZoom(val) {
    var newZoomLev = val;
    setZoomLevel(newZoomLev);
    onZoom(newZoomLev);
  }
  if (zoomLevel > maxZoomLevel) {
    setTimeout(function () {
      if (zoomHelper.current && zoomHelper.current.triggerChange) {
        zoomHelper.current.triggerChange(function (_ref2) {
          var changeValue = _ref2.changeValue;
          changeValue(maxZoomLevel);
        });
      }
    }, 0);
  }
  return /*#__PURE__*/React.createElement("div", {
    style: {
      position: "absolute",
      left: smallSlider ? 100 : 150,
      top: 0,
      zIndex: 900
    }
  }, /*#__PURE__*/React.createElement(UncontrolledSliderWithPlusMinusBtns, {
    bindOutsideChangeHelper: zoomHelper.current,
    onChange: setZoom,
    onRelease: setZoom,
    title: "Adjust Zoom Level",
    style: {
      paddingTop: "4px",
      width: smallSlider ? SLIDER_SMALL_WIDTH : SLIDER_NORM_WIDTH
    },
    smallSlider: true,
    noWraparound: true,
    className: "veZoomCircularSlider ove-slider",
    labelRenderer: false,
    stepSize: stepSize,
    clickStepSize: clickStepSize,
    initialValue: zoomLevel || 1,
    justUpdateInitialValOnce: true,
    max: maxZoomLevel || 14,
    min: min
  }));
}