"use strict";

exports.__esModule = true;
exports.ZoomLinearView = ZoomLinearView;
var _react = _interopRequireDefault(require("react"));
var _constants = require("../constants/constants");
var _UncontrolledSliderWithPlusMinusBtns = _interopRequireDefault(require("../helperComponents/UncontrolledSliderWithPlusMinusBtns"));
var _index = require("./index");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
function ZoomLinearView(_ref) {
  var setCharWidth = _ref.setCharWidth,
    minCharWidth = _ref.minCharWidth,
    bindOutsideChangeHelper = _ref.bindOutsideChangeHelper,
    afterOnChange = _ref.afterOnChange,
    smallSlider = _ref.smallSlider;
  return /*#__PURE__*/_react["default"].createElement("div", {
    className: "tg-zoom-bar",
    style: {
      zIndex: 900,
      position: "absolute"
    }
  }, /*#__PURE__*/_react["default"].createElement(_UncontrolledSliderWithPlusMinusBtns["default"], {
    noWraparound: true,
    bindOutsideChangeHelper: bindOutsideChangeHelper,
    onClick: function onClick() {
      setTimeout(_index.scrollToCaret, 0);
    },
    onChange: function onChange(zoomLvl) {
      //zoomLvl is in the range of 0 to 10
      var scaleFactor = Math.pow(12 / minCharWidth, 1 / 10);
      var newCharWidth = minCharWidth * Math.pow(scaleFactor, zoomLvl);
      setCharWidth(newCharWidth);
      (0, _index.scrollToCaret)();
      afterOnChange && afterOnChange();
    },
    leftIcon: "minus",
    rightIcon: "plus",
    title: "Zoom",
    smallSlider: true,
    style: {
      paddingTop: "4px",
      width: smallSlider ? _constants.SLIDER_SMALL_WIDTH : _constants.SLIDER_NORM_WIDTH
    },
    className: "veZoomLinearSlider ove-slider",
    labelRenderer: false,
    stepSize: 0.05,
    clickStepSize: 0.5,
    initialValue: 0,
    max: 10,
    min: 0
  }));
}