'use strict';

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

var React = require('react');
var reactTransitionGroup = require('react-transition-group');
var classNames = require('clsx');
var Spinner = require('@prom-ui/core/Spinner');

function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }

function _interopNamespaceCompat(e) {
  if (e && typeof e === 'object' && 'default' in e) return e;
  var n = Object.create(null);
  if (e) {
    Object.keys(e).forEach(function (k) {
      if (k !== 'default') {
        var d = Object.getOwnPropertyDescriptor(e, k);
        Object.defineProperty(n, k, d.get ? d : {
          enumerable: true,
          get: function () { return e[k]; }
        });
      }
    });
  }
  n.default = e;
  return Object.freeze(n);
}

var React__namespace = /*#__PURE__*/_interopNamespaceCompat(React);
var classNames__default = /*#__PURE__*/_interopDefaultCompat(classNames);

function _defineProperty(obj, key, value) {
  key = _toPropertyKey(key);
  if (key in obj) {
    Object.defineProperty(obj, key, {
      value: value,
      enumerable: true,
      configurable: true,
      writable: true
    });
  } else {
    obj[key] = value;
  }
  return obj;
}
function _extends() {
  _extends = Object.assign ? Object.assign.bind() : function (target) {
    for (var i = 1; i < arguments.length; i++) {
      var source = arguments[i];
      for (var key in source) {
        if (Object.prototype.hasOwnProperty.call(source, key)) {
          target[key] = source[key];
        }
      }
    }
    return target;
  };
  return _extends.apply(this, arguments);
}
function _objectWithoutPropertiesLoose(source, excluded) {
  if (source == null) return {};
  var target = {};
  var sourceKeys = Object.keys(source);
  var key, i;
  for (i = 0; i < sourceKeys.length; i++) {
    key = sourceKeys[i];
    if (excluded.indexOf(key) >= 0) continue;
    target[key] = source[key];
  }
  return target;
}
function _objectWithoutProperties(source, excluded) {
  if (source == null) return {};
  var target = _objectWithoutPropertiesLoose(source, excluded);
  var key, i;
  if (Object.getOwnPropertySymbols) {
    var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
    for (i = 0; i < sourceSymbolKeys.length; i++) {
      key = sourceSymbolKeys[i];
      if (excluded.indexOf(key) >= 0) continue;
      if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
      target[key] = source[key];
    }
  }
  return target;
}
function _toPrimitive(input, hint) {
  if (typeof input !== "object" || input === null) return input;
  var prim = input[Symbol.toPrimitive];
  if (prim !== undefined) {
    var res = prim.call(input, hint || "default");
    if (typeof res !== "object") return res;
    throw new TypeError("@@toPrimitive must return a primitive value.");
  }
  return (hint === "string" ? String : Number)(input);
}
function _toPropertyKey(arg) {
  var key = _toPrimitive(arg, "string");
  return typeof key === "symbol" ? key : String(key);
}

var css = {"root":"Tumbler__root___17yYC","view":"Tumbler__view___w66K2","viewCircle":"Tumbler__viewCircle___xvJqd","input":"Tumbler__input___Kg91O","inputLoading":"Tumbler__inputLoading___y1iJD","spinner":"Tumbler__spinner___CNMl7","spinnerEnterActive":"Tumbler__spinnerEnterActive___C2P5b","spinnerEnterDone":"Tumbler__spinnerEnterDone___cgEXP","spinnerExitActive":"Tumbler__spinnerExitActive___k-mzv","spinnerExitDone":"Tumbler__spinnerExitDone___XD0-8"};

var _excluded = ["className", "loading", "type"];
var Tumbler = /*#__PURE__*/React__namespace.forwardRef(function (_ref, ref) {
  var className = _ref.className,
    _ref$loading = _ref.loading,
    loading = _ref$loading === void 0 ? false : _ref$loading,
    _ref$type = _ref.type,
    type = _ref$type === void 0 ? 'checkbox' : _ref$type,
    props = _objectWithoutProperties(_ref, _excluded);
  return /*#__PURE__*/React__namespace.createElement("div", {
    className: classNames__default.default(css.root, className)
  }, /*#__PURE__*/React__namespace.createElement("input", _extends({
    ref: ref,
    className: classNames__default.default(css.input, _defineProperty({}, css.inputLoading, loading)),
    type: type
  }, props)), /*#__PURE__*/React__namespace.createElement("div", {
    className: css.view
  }, /*#__PURE__*/React__namespace.createElement("div", {
    className: css.viewCircle
  }, /*#__PURE__*/React__namespace.createElement(reactTransitionGroup.CSSTransition, {
    "in": loading,
    timeout: 100,
    classNames: {
      enterActive: css.spinnerEnterActive,
      enterDone: css.spinnerEnterDone,
      exitActive: css.spinnerExitActive,
      exitDone: css.spinnerExitDone
    },
    unmountOnExit: true
  }, /*#__PURE__*/React__namespace.createElement(Spinner.Spinner, {
    className: css.spinner
  })))));
});
Tumbler.displayName = 'Tumbler';

exports.Tumbler = Tumbler;

require('./style.development.css');
