"use strict";

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

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

var _styles = require("@material-ui/core/styles");

var _InputBase = _interopRequireDefault(require("@material-ui/core/InputBase"));

var _InputBaseProps = _interopRequireWildcard(require("./InputBaseProps"));

var _classnames = _interopRequireDefault(require("classnames"));

function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(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; }

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

(function () {
  var enterModule = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.enterModule : undefined;
  enterModule && enterModule(module);
})();

(function () {
  var enterModule = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.enterModule : undefined;
  enterModule && enterModule(module);
})();

var __signature__ = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.default.signature : function (a) {
  return a;
};

var __signature__ = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.default.signature : function (a) {
  return a;
};

var useStyles = (0, _styles.makeStyles)(function (theme) {
  return {
    container: {
      display: "flex",
      flexDirection: "column"
    },
    inputContainer: {
      display: "flex"
    },
    prepend: {
      fontSize: theme.spacing(1.3),
      lineHeight: theme.spacing(1.3),
      padding: theme.spacing(0.85),
      minWidth: theme.spacing(6),
      marginRight: theme.spacing(-0.1),
      height: theme.spacing(3),
      display: "inline-flex",
      borderRadius: theme.spacing(0.5, 0, 0, 0.5),
      border: "".concat(theme.spacing(0.1), " solid ").concat(theme.palette.grey.borders),
      boxSizing: "border-box",
      backgroundColor: theme.palette.grey.light,
      whiteSpace: "nowrap"
    },
    disabledPrepend: {
      border: 0,
      padding: theme.spacing(0.8),
      height: theme.spacing(2.8),
      backgroundColor: theme.palette.grey.borders
    },
    controlInput: {
      minHeight: theme.spacing(1.6),
      maxWidth: "unset",
      minWidth: 0,
      border: "".concat(theme.spacing(0.1), " solid ").concat(theme.palette.grey.borders),
      borderRadius: function borderRadius(props) {
        return props.label ? theme.spacing(0, 0.5, 0.5, 0) : theme.spacing(0.5);
      },
      paddingLeft: theme.spacing(0.85),
      "&:focus, &:active": {
        border: "".concat(theme.spacing(0.1), " solid ").concat(theme.palette.focus),
        borderRadius: function borderRadius(props) {
          return props.label ? theme.spacing(0, 0.5, 0.5, 0) : theme.spacing(0.5);
        }
      }
    },
    errorInput: {
      "& input, & textarea": {
        border: "".concat(theme.spacing(0.1), " solid ").concat(theme.palette.error.main),
        "&:focus, &:active": {
          border: "".concat(theme.spacing(0.1), " solid ").concat(theme.palette.error.main),
          boxShadow: "".concat(theme.spacing(0, 0, 0.4), " ").concat(theme.palette.error.main)
        }
      }
    },
    errorText: {
      marginTop: theme.spacing(0.5),
      color: theme.palette.error.main,
      fontSize: theme.typography.fieldLabelSize,
      float: function float(props) {
        return props.errorPosition === "right" ? "right" : "left";
      }
    },
    disabled: {
      "& input, & textarea": {
        color: theme.palette.text.primary,
        backgroundColor: theme.palette.grey.light,
        border: 0,
        "&:focus, &:active": {
          border: 0,
          boxShadow: 0
        }
      }
    },
    multiline: {
      padding: 0
    },
    inputMultiline: {
      padding: theme.spacing(0.6, 0.6, 0.6, 0.85)
    }
  };
});
exports.useStyles = useStyles;

var InputBase = function InputBase(_ref) {
  var _inputProps$get;

  var inputProps = _ref.inputProps;

  if ((0, _InputBaseProps.isInputProps)(inputProps) === false) {
    throw new TypeError("inputProps property is not of type InputBaseProps");
  }

  var multiline = (inputProps == null ? void 0 : inputProps.get(_InputBaseProps.default.propNames.multiline)) || false;
  var update = inputProps == null ? void 0 : inputProps.get(_InputBaseProps.default.propNames.update);
  var value = (_inputProps$get = inputProps == null ? void 0 : inputProps.get(_InputBaseProps.default.propNames.value)) != null ? _inputProps$get : "";
  var label = !multiline && (inputProps == null ? void 0 : inputProps.get(_InputBaseProps.default.propNames.label));
  var type = (inputProps == null ? void 0 : inputProps.get(_InputBaseProps.default.propNames.type)) || "text";
  var inputAttributes = (inputProps == null ? void 0 : inputProps.get(_InputBaseProps.default.propNames.inputAttributes)) || {};
  var placeholder = inputProps == null ? void 0 : inputProps.get(_InputBaseProps.default.propNames.placeholder);
  var error = inputProps == null ? void 0 : inputProps.get(_InputBaseProps.default.propNames.error);
  var errorPosition = inputProps == null ? void 0 : inputProps.get(_InputBaseProps.default.propNames.errorPosition);
  var disabled = (inputProps == null ? void 0 : inputProps.get(_InputBaseProps.default.propNames.disabled)) || false;
  var onBlur = (inputProps == null ? void 0 : inputProps.get(_InputBaseProps.default.propNames.onBlur)) || null;
  var startAdornment = inputProps == null ? void 0 : inputProps.get(_InputBaseProps.default.propNames.startAdornment);
  var endAdornment = inputProps == null ? void 0 : inputProps.get(_InputBaseProps.default.propNames.endAdornment);
  var metadata = inputProps == null ? void 0 : inputProps.get(_InputBaseProps.default.propNames.metadata);
  var autoComplete = inputProps == null ? void 0 : inputProps.get(_InputBaseProps.default.propNames.autoComplete);

  var onClick = function onClick(item) {
    // Fixes FireFox issue, where the input number buttons do not focus on input control,
    // causing onBlur to never fire
    item.target.focus();
  };

  var classes = useStyles({
    label: label,
    errorPosition: errorPosition
  });

  var onChangeHandler = function onChangeHandler(event) {
    event.persist();
    update(event.target.value, metadata);
  };

  var inputBaseInputStyle = inputProps == null ? void 0 : inputProps.getStyle(_InputBaseProps.default.ruleNames.input);
  var errorTextStyle = inputProps == null ? void 0 : inputProps.getStyle(_InputBaseProps.default.ruleNames.errorText);
  return /*#__PURE__*/_react.default.createElement("div", {
    className: classes.container
  }, /*#__PURE__*/_react.default.createElement("div", {
    className: classes.inputContainer
  }, label && /*#__PURE__*/_react.default.createElement("label", {
    className: "".concat(classes.prepend, " ").concat(disabled && classes.disabledPrepend)
  }, label), /*#__PURE__*/_react.default.createElement(_InputBase.default, {
    classes: {
      input: (0, _classnames.default)(classes.controlInput, inputBaseInputStyle),
      error: classes.errorInput,
      disabled: classes.disabled,
      multiline: classes.multiline,
      inputMultiline: classes.inputMultiline
    },
    onBlur: onBlur,
    onClick: onClick,
    type: type,
    placeholder: placeholder,
    value: value,
    fullWidth: true,
    onChange: function onChange(event) {
      return onChangeHandler(event);
    },
    error: !!error,
    inputProps: inputAttributes,
    disabled: disabled,
    multiline: multiline,
    startAdornment: startAdornment,
    endAdornment: endAdornment,
    rows: 4,
    title: value,
    autoComplete: autoComplete
  })), error && /*#__PURE__*/_react.default.createElement("div", {
    className: (0, _classnames.default)(classes.errorText, errorTextStyle)
  }, error));
};

__signature__(InputBase, "useStyles{classes}", function () {
  return [useStyles];
});

__signature__(InputBase, "useStyles{classes}", function () {
  return [useStyles];
});

var compareInputBase = function compareInputBase(prev, next) {
  return prev.inputProps.get(_InputBaseProps.default.propNames.value) === next.inputProps.get(_InputBaseProps.default.propNames.value) && prev.inputProps.get(_InputBaseProps.default.propNames.error) === next.inputProps.get(_InputBaseProps.default.propNames.error) && prev.inputProps.get(_InputBaseProps.default.propNames.update) === next.inputProps.get(_InputBaseProps.default.propNames.update) && prev.inputProps.get(_InputBaseProps.default.propNames.disabled) === next.inputProps.get(_InputBaseProps.default.propNames.disabled);
};

var _default = _react.default.memo(InputBase, compareInputBase);

var _default2 = _default;
var _default3 = _default2;
exports.default = _default3;
;

(function () {
  var reactHotLoader = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.default : undefined;

  if (!reactHotLoader) {
    return;
  }

  reactHotLoader.register(useStyles, "useStyles", "/home/vsts/work/1/s/src/components/MaterialUI/Inputs/InputBase.js");
  reactHotLoader.register(InputBase, "InputBase", "/home/vsts/work/1/s/src/components/MaterialUI/Inputs/InputBase.js");
  reactHotLoader.register(compareInputBase, "compareInputBase", "/home/vsts/work/1/s/src/components/MaterialUI/Inputs/InputBase.js");
  reactHotLoader.register(_default, "default", "/home/vsts/work/1/s/src/components/MaterialUI/Inputs/InputBase.js");
})();

;

(function () {
  var leaveModule = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.leaveModule : undefined;
  leaveModule && leaveModule(module);
})();

;

(function () {
  var reactHotLoader = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.default : undefined;

  if (!reactHotLoader) {
    return;
  }

  reactHotLoader.register(useStyles, "useStyles", "/home/vsts/work/1/s/src/components/MaterialUI/Inputs/InputBase.js");
  reactHotLoader.register(InputBase, "InputBase", "/home/vsts/work/1/s/src/components/MaterialUI/Inputs/InputBase.js");
  reactHotLoader.register(compareInputBase, "compareInputBase", "/home/vsts/work/1/s/src/components/MaterialUI/Inputs/InputBase.js");
  reactHotLoader.register(_default2, "default", "/home/vsts/work/1/s/src/components/MaterialUI/Inputs/InputBase.js");
})();

;

(function () {
  var leaveModule = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.leaveModule : undefined;
  leaveModule && leaveModule(module);
})();