import _Object$assign from "@babel/runtime-corejs2/core-js/object/assign";
import Spinner from '../spinner';
import { getRestProps } from '../utils';
export default function (obj, _Vdt, blocks, $callee) {
  var _classNameObj;

  _Vdt || (_Vdt = Vdt);
  obj || (obj = {});
  blocks || (blocks = {});
  var h = _Vdt.miss.h,
      hc = _Vdt.miss.hc,
      hu = _Vdt.miss.hu,
      widgets = this && this.widgets || {},
      _blocks = {},
      __blocks = {},
      __u = _Vdt.utils,
      extend = __u.extend,
      _e = __u.error,
      _className = __u.className,
      __slice = __u.slice,
      __noop = __u.noop,
      __m = __u.map,
      __o = __u.Options,
      _getModel = __o.getModel,
      _setModel = __o.setModel,
      _setCheckboxModel = __u.setCheckboxModel,
      _detectCheckboxChecked = __u.detectCheckboxChecked,
      _setSelectModel = __u.setSelectModel,
      self = this.data,
      $this = this,
      scope = obj,
      Animate = self && self.Animate,
      parent = ($callee || {})._super;

  var _self$get = self.get(),
      value = _self$get.value,
      min = _self$get.min,
      max = _self$get.max,
      className = _self$get.className,
      disabled = _self$get.disabled,
      isRange = _self$get.isRange,
      isInnerText = _self$get.isInnerText,
      isShowInput = _self$get.isShowInput,
      isShowEnd = _self$get.isShowEnd,
      unit = _self$get.unit,
      step = _self$get.step,
      _isDragging = _self$get._isDragging,
      _isFirst = _self$get._isFirst,
      _inputValue = _self$get._inputValue,
      _isSecond = _self$get._isSecond,
      _sliderValue = _self$get._sliderValue,
      isShowStop = _self$get.isShowStop,
      marks = _self$get.marks;

  var classNameObj = (_classNameObj = {
    'k-slider': true,
    'k-disabled': disabled
  }, _classNameObj[className] = className, _classNameObj['k-dragging'] = _isDragging, _classNameObj['k-show-input'] = isShowInput && !isRange, _classNameObj['k-show-end'] = isShowEnd, _classNameObj);
  var sliderWidth = max - min;
  return h('div', _Object$assign({}, function () {
    try {
      return getRestProps(self);
    } catch (e) {
      _e(e);
    }
  }.call($this)), [h('div', null, [h('div', {
    'ev-click': function () {
      try {
        return self._clickWrapper;
      } catch (e) {
        _e(e);
      }
    }.call($this)
  }, h('div', null, [h('div', {
    'style': function () {
      try {
        return isRange ? {
          width: Math.abs(_sliderValue[1] - _sliderValue[0]) / sliderWidth * 100 + '%',
          left: (Math.min(_sliderValue[0], _sliderValue[1]) - min) / sliderWidth * 100 + '%'
        } : {
          width: (_sliderValue - min) / sliderWidth * 100 + '%'
        };
      } catch (e) {
        _e(e);
      }
    }.call($this)
  }, null, 'k-bar'), h('div', {
    'style': function () {
      try {
        return {
          left: isRange ? (_sliderValue[0] - min) / sliderWidth * 100 + '%' : (_sliderValue - min) / sliderWidth * 100 + '%'
        };
      } catch (e) {
        _e(e);
      }
    }.call($this),
    'tabindex': function () {
      try {
        return disabled ? "-1" : "0";
      } catch (e) {
        _e(e);
      }
    }.call($this),
    'ev-mousedown': function () {
      try {
        return isRange ? self._onDrag.bind(self, '_isFirst') : self._onDrag.bind(self, undefined);
      } catch (e) {
        _e(e);
      }
    }.call($this),
    'ev-click': function () {
      try {
        return self._stopPropagation;
      } catch (e) {
        _e(e);
      }
    }.call($this),
    'ev-keydown': function () {
      try {
        return isRange ? self._onKeydown.bind(self, '_isFirst') : self._onKeydown.bind(self, undefined);
      } catch (e) {
        _e(e);
      }
    }.call($this),
    'ev-focusin': function () {
      try {
        return self._onFocusin.bind(self, '_isFirst');
      } catch (e) {
        _e(e);
      }
    }.call($this),
    'ev-focusout': function () {
      try {
        return self._onFocusout.bind(self, '_isFirst');
      } catch (e) {
        _e(e);
      }
    }.call($this)
  }, function () {
    try {
      return isInnerText;
    } catch (e) {
      _e(e);
    }
  }.call($this) ? h('div', null, function () {
    try {
      return isRange ? value : value[0];
    } catch (e) {
      _e(e);
    }
  }.call($this)) : undefined, _className(function () {
    try {
      return {
        "k-handle": true,
        "k-active": _isFirst && _sliderValue[1] === self._max || _isSecond && value[0] !== self._min
      };
    } catch (e) {
      _e(e);
    }
  }.call($this)), null, function () {
    try {
      return function (dom) {
        return self.$sliderFirstBtn = dom;
      };
    } catch (e) {
      _e(e);
    }
  }.call($this)), function () {
    try {
      return isRange;
    } catch (e) {
      _e(e);
    }
  }.call($this) ? h('div', {
    'style': function () {
      try {
        return {
          left: (_sliderValue[1] - min) / sliderWidth * 100 + '%'
        };
      } catch (e) {
        _e(e);
      }
    }.call($this),
    'tabindex': function () {
      try {
        return disabled ? "-1" : "0";
      } catch (e) {
        _e(e);
      }
    }.call($this),
    'ev-mousedown': function () {
      try {
        return self._onDrag.bind(self, "_isSecond");
      } catch (e) {
        _e(e);
      }
    }.call($this),
    'ev-keydown': function () {
      try {
        return self._onKeydown.bind(self, '_isSecond');
      } catch (e) {
        _e(e);
      }
    }.call($this),
    'ev-focusin': function () {
      try {
        return self._onFocusin.bind(self, '_isSecond');
      } catch (e) {
        _e(e);
      }
    }.call($this),
    'ev-focusout': function () {
      try {
        return self._onFocusout.bind(self, '_isSecond');
      } catch (e) {
        _e(e);
      }
    }.call($this),
    'ev-click': function () {
      try {
        return self._stopPropagation;
      } catch (e) {
        _e(e);
      }
    }.call($this)
  }, function () {
    try {
      return isInnerText;
    } catch (e) {
      _e(e);
    }
  }.call($this) ? h('div', null, function () {
    try {
      return value[1];
    } catch (e) {
      _e(e);
    }
  }.call($this)) : undefined, _className(function () {
    try {
      return {
        "k-handle": true,
        "k-active": _isSecond && _sliderValue[0] === self._min || _isFirst && _sliderValue[1] !== self._max
      };
    } catch (e) {
      _e(e);
    }
  }.call($this)), null, function () {
    try {
      return function (dom) {
        return self.$sliderSecondBtn = dom;
      };
    } catch (e) {
      _e(e);
    }
  }.call($this)) : undefined, function () {
    try {
      return function () {
        if (isShowStop) {
          var _ret = function () {
            var counts = Math.floor((max - min) / step);
            var ret = [];

            var _loop = function _loop(i) {
              ret.push(h('i', {
                'style': function () {
                  try {
                    return {
                      left: i / counts * 100 + '%'
                    };
                  } catch (e) {
                    _e(e);
                  }
                }.call($this)
              }, null, 'k-point'));
            };

            for (var i = 1; i < counts; i++) {
              _loop(i);
            }

            return {
              v: ret
            };
          }();

          if (typeof _ret === "object") return _ret.v;
        }
      }();
    } catch (e) {
      _e(e);
    }
  }.call($this)], 'k-wrapper', null, function () {
    try {
      return function (dom) {
        return self.$slider = dom;
      };
    } catch (e) {
      _e(e);
    }
  }.call($this)), 'k-bar-wrapper'), function () {
    try {
      return isShowEnd && !marks;
    } catch (e) {
      _e(e);
    }
  }.call($this) ? h('div', null, [h('span', {
    'ev-click': function () {
      try {
        return self._setOneValue.bind(self, min);
      } catch (e) {
        _e(e);
      }
    }.call($this)
  }, function () {
    try {
      return min + unit;
    } catch (e) {
      _e(e);
    }
  }.call($this)), h('span', {
    'ev-click': function () {
      try {
        return self._setOneValue.bind(self, max);
      } catch (e) {
        _e(e);
      }
    }.call($this)
  }, function () {
    try {
      return max + unit;
    } catch (e) {
      _e(e);
    }
  }.call($this))], 'k-box') : undefined, function () {
    try {
      return marks;
    } catch (e) {
      _e(e);
    }
  }.call($this) ? h('div', null, function () {
    try {
      var counts;
      return counts = Math.floor((max - min) / step), __m(function () {
        try {
          return marks;
        } catch (e) {
          _e(e);
        }
      }.call($this), function (value, key) {
        return h('span', {
          'style': function () {
            try {
              return {
                left: (key - min) / counts * 100 + '%'
              };
            } catch (e) {
              _e(e);
            }
          }.call($this),
          'ev-click': function () {
            try {
              return self._setOneValue.bind(self, key);
            } catch (e) {
              _e(e);
            }
          }.call($this)
        }, function () {
          try {
            return value;
          } catch (e) {
            _e(e);
          }
        }.call($this));
      }, $this);
    } catch (e) {
      _e(e);
    }
  }.call($this), 'k-marks') : undefined], 'k-slider-wrapper'), function () {
    try {
      return isShowInput && !isRange;
    } catch (e) {
      _e(e);
    }
  }.call($this) ? h('div', null, h(Spinner, {
    'disabled': function () {
      try {
        return disabled;
      } catch (e) {
        _e(e);
      }
    }.call($this),
    'max': function () {
      try {
        return max;
      } catch (e) {
        _e(e);
      }
    }.call($this),
    'min': function () {
      try {
        return min;
      } catch (e) {
        _e(e);
      }
    }.call($this),
    'step': function () {
      try {
        return step;
      } catch (e) {
        _e(e);
      }
    }.call($this),
    'ref': function ref(i) {
      widgets['spinner'] = i;
    },
    'vertical': function () {
      try {
        return true;
      } catch (e) {
        _e(e);
      }
    }.call($this),
    '_context': $this,
    'value': _getModel(self, '_inputValue'),
    'ev-change': function () {
      try {
        return self._onChange;
      } catch (e) {
        _e(e);
      }
    }.call($this),
    'ev-$change:value': function ev$changeValue(__c, __n) {
      _setModel(self, '_inputValue', __n, $this);
    }
  }), 'k-spinner-wrapper') : undefined], _className(function () {
    try {
      return classNameObj;
    } catch (e) {
      _e(e);
    }
  }.call($this)));
}