"use strict";

exports.__esModule = true;
exports.default = exports.RemoteConfigScreen = void 0;

var _react = _interopRequireWildcard(require("react"));

var _Dialog = _interopRequireDefault(require("@material-ui/core/Dialog"));

var _DialogActions = _interopRequireDefault(require("@material-ui/core/DialogActions"));

var _DialogContent = _interopRequireDefault(require("@material-ui/core/DialogContent"));

var _DialogContentText = _interopRequireDefault(require("@material-ui/core/DialogContentText"));

var _DialogTitle = _interopRequireDefault(require("@material-ui/core/DialogTitle"));

var _Button = _interopRequireDefault(require("@material-ui/core/Button"));

var _TextField = _interopRequireDefault(require("@material-ui/core/TextField"));

var _RemoteReceiverToggleButton = _interopRequireDefault(require("./RemoteReceiverToggleButton"));

var _hooks = require("subfirelib/hooks");

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }

function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }

const RemoteConfigScreen = props => {
  const {
    remoteName,
    setRemoteName
  } = (0, _hooks.useRemoteReceiver)();
  const [editingRemoteName, setEditingRemoteName] = (0, _react.useState)(remoteName);
  const {
    handleClose
  } = props; // eslint-disable-line

  const lockRemoteName = () => {
    setRemoteName(editingRemoteName);
  };

  const remoteNameChange = e => {
    setEditingRemoteName(n => e.target.value);
  }; // console.log(remotes, remoteEnabled);


  const value = editingRemoteName || '';
  return /*#__PURE__*/_react.default.createElement(_Dialog.default, {
    disableBackdropClick: true,
    open: true
  }, /*#__PURE__*/_react.default.createElement(_DialogTitle.default, null, "Remote Receiver Configuration"), /*#__PURE__*/_react.default.createElement(_DialogContent.default, null, /*#__PURE__*/_react.default.createElement(_DialogContentText.default, null, "Name This Client"), /*#__PURE__*/_react.default.createElement(_TextField.default, {
    label: "zz-sbr-",
    value: editingRemoteName,
    onChange: remoteNameChange,
    margin: "normal"
  })), /*#__PURE__*/_react.default.createElement(_DialogActions.default, null, /*#__PURE__*/_react.default.createElement(_RemoteReceiverToggleButton.default, props), /*#__PURE__*/_react.default.createElement(_Button.default, {
    size: "small",
    onClick: () => handleClose()
  }, "Close"), /*#__PURE__*/_react.default.createElement(_Button.default, {
    size: "small",
    color: "primary",
    onClick: lockRemoteName,
    disabled: value === ''
  }, "Save")));
};

exports.RemoteConfigScreen = RemoteConfigScreen;
var _default = RemoteConfigScreen;
exports.default = _default;