var _excluded = ["checked", "disabled", "className", "children", "labelLeft", "labelRight", "Label", "colored", "margin", "alignSelf", "toggleProps"];
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
import React from "react";
import { Text } from "../typography";
import { ToggleContainer, HiddenToggleInput, StyledToggle, StyledLabel, LabelText } from "./styled";
export var Toggle = function Toggle(_ref) {
  var checked = _ref.checked,
    disabled = _ref.disabled,
    className = _ref.className,
    children = _ref.children,
    _ref$labelLeft = _ref.labelLeft,
    labelLeft = _ref$labelLeft === void 0 ? children : _ref$labelLeft,
    labelRight = _ref.labelRight,
    _ref$Label = _ref.Label,
    Label = _ref$Label === void 0 ? Text : _ref$Label,
    _ref$colored = _ref.colored,
    colored = _ref$colored === void 0 ? false : _ref$colored,
    margin = _ref.margin,
    alignSelf = _ref.alignSelf,
    _ref$toggleProps = _ref.toggleProps,
    toggleProps = _ref$toggleProps === void 0 ? {} : _ref$toggleProps,
    props = _objectWithoutPropertiesLoose(_ref, _excluded);
  return /*#__PURE__*/React.createElement(StyledLabel, {
    className: className,
    margin: margin,
    alignSelf: alignSelf
  }, labelLeft && /*#__PURE__*/React.createElement(LabelText, {
    as: Label,
    left: true
  }, labelLeft), /*#__PURE__*/React.createElement(ToggleContainer, null, /*#__PURE__*/React.createElement(HiddenToggleInput, _extends({
    disabled: disabled,
    checked: checked
  }, props)), /*#__PURE__*/React.createElement(StyledToggle, _extends({
    checked: checked,
    disabled: disabled,
    colored: colored,
    role: "switch"
  }, toggleProps))), labelRight && /*#__PURE__*/React.createElement(LabelText, {
    as: Label,
    right: true
  }, labelRight));
};