"use strict";

require("core-js/modules/es.object.define-property.js");
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.FcrMobileSwitch = void 0;
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
var _react = require("react");
var _classnames = _interopRequireDefault(require("classnames"));
require("./mobile.css");
var _jsxRuntime = require("react/jsx-runtime");
var FcrMobileSwitch = exports.FcrMobileSwitch = function FcrMobileSwitch(_ref) {
  var labels = _ref.labels,
    value = _ref.value,
    _ref$onChange = _ref.onChange,
    onChange = _ref$onChange === void 0 ? function () {} : _ref$onChange;
  var _useState = (0, _react.useState)(value),
    _useState2 = (0, _slicedToArray2["default"])(_useState, 2),
    toggle = _useState2[0],
    setToggle = _useState2[1];
  var cls = (0, _classnames["default"])('fcr-switch', {
    'fcr-switch--on': toggle,
    'fcr-switch--off': !toggle
  });
  var handleClick = function handleClick() {
    setToggle(!toggle);
    onChange(!toggle);
  };
  (0, _react.useEffect)(function () {
    setToggle(value);
  }, [value]);
  return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
    className: cls,
    onClick: handleClick,
    children: /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
      className: "fcr-switch__slider"
    })
  });
};