"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports["default"] = void 0;
var _react = _interopRequireDefault(require("react"));
var _propTypes = _interopRequireDefault(require("prop-types"));
var _clsx = _interopRequireDefault(require("clsx"));
var _styles = require("@material-ui/core/styles");
var _withWidth = _interopRequireDefault(require("@material-ui/core/withWidth"));
var _Card = _interopRequireDefault(require("@material-ui/core/Card"));
var _CardContent = _interopRequireDefault(require("@material-ui/core/CardContent"));
var _Grid = _interopRequireDefault(require("@material-ui/core/Grid"));
var _Typography = _interopRequireDefault(require("@material-ui/core/Typography"));
var _CheckCircle = _interopRequireDefault(require("@material-ui/icons/CheckCircle"));
var _Info = _interopRequireDefault(require("@material-ui/icons/Info"));
var _Button = _interopRequireDefault(require("@material-ui/core/Button"));
var _Icon = _interopRequireDefault(require("@material-ui/core/Icon"));
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 _Tooltip = _interopRequireDefault(require("@material-ui/core/Tooltip"));
var _upperFirst = _interopRequireDefault(require("lodash/upperFirst"));
var _i18n = require("../../../../../Framework/i18n");
var _ObjectTools = _interopRequireDefault(require("../ObjectTools"));
var _AnalyticsWrapper = _interopRequireDefault(require("../../../../Shared/Components/Analytics/AnalyticsWrapper"));
var _CustomDialog = _interopRequireDefault(require("../../../../../Shared/Components/CustomDialog"));
var _customClassName = _interopRequireDefault(require("../../../../Utils/customClassName"));
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
function _inherits(t, e) { if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function"); t.prototype = Object.create(e && e.prototype, { constructor: { value: t, writable: !0, configurable: !0 } }), Object.defineProperty(t, "prototype", { writable: !1 }), e && _setPrototypeOf(t, e); }
function _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); }
function _createSuper(t) { var r = _isNativeReflectConstruct(); return function () { var e, o = _getPrototypeOf(t); if (r) { var s = _getPrototypeOf(this).constructor; e = Reflect.construct(o, arguments, s); } else e = o.apply(this, arguments); return _possibleConstructorReturn(this, e); }; }
function _possibleConstructorReturn(t, e) { if (e && ("object" == _typeof(e) || "function" == typeof e)) return e; if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined"); return _assertThisInitialized(t); }
function _assertThisInitialized(e) { if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); return e; }
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
function _getPrototypeOf(t) { return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) { return t.__proto__ || Object.getPrototypeOf(t); }, _getPrototypeOf(t); }
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
var styles = function styles(theme) {
  var _CardContentWrapper;
  return {
    card: {
      borderTop: '7px solid ' + theme.palette.primary.main,
      position: 'relative',
      overflow: 'visible'
    },
    cardUnboxed: {
      borderTop: 'none',
      boxShadow: 'none',
      borderRadius: 0
    },
    CardContentWrapper: (_CardContentWrapper = {
      padding: 8
    }, _defineProperty(_CardContentWrapper, theme.breakpoints.down('xs'), {
      padding: '8px 0',
      '&:last-child': {
        paddingBottom: 12
      }
    }), _defineProperty(_CardContentWrapper, '& .object-btn', _defineProperty({}, theme.breakpoints.down('xs'), {
      height: 50,
      width: 50,
      margin: '15px 5px 0 0'
    })), _CardContentWrapper),
    printQuality: _defineProperty({
      display: 'inline-flex',
      alignItems: 'center',
      backgroundColor: '#000000',
      marginBottom: 15,
      borderRadius: '4px',
      color: '#fff',
      padding: '10px',
      width: '100%',
      minHeight: 40
    }, theme.breakpoints.down('xs'), {
      margin: 0,
      minHeight: 56
    }),
    printQualityText: {
      color: '#fff',
      padding: '0 10px',
      fontSize: 15,
      lineHeight: '18px'
    },
    printQualityGreat: {
      backgroundColor: '#4FC36D'
    },
    printQualityOk: {
      backgroundColor: '#FF9800'
    },
    printQualityPoor: {
      backgroundColor: '#ED1C29'
    },
    printQualityIcon: {
      verticalAlign: 'middle'
    },
    printQualityInfoIcon: {
      verticalAlign: 'middle',
      cursor: 'pointer'
    },
    editButtonLine: {
      margin: '15px 0'
    },
    editButton: _defineProperty({
      minWidth: 30,
      width: 35,
      margin: '0px 8px 0 0'
    }, theme.breakpoints.down('xs'), {
      margin: '15px 5px 0 0',
      height: 50,
      width: 50
    })
  };
};
var ImageControlbox = /*#__PURE__*/function (_React$Component) {
  _inherits(ImageControlbox, _React$Component);
  var _super = _createSuper(ImageControlbox);
  function ImageControlbox(props) {
    var _this;
    _classCallCheck(this, ImageControlbox);
    _this = _super.call(this, props);
    _defineProperty(_assertThisInitialized(_this), "onEditClick", function () {
      var _this$props = _this.props,
        imageData = _this$props.imageData,
        openImageEditDialog = _this$props.openImageEditDialog,
        canvas = _this$props.canvas;
      if (imageData.isPlaceHolderImage) {
        openImageEditDialog(null, canvas, true);
      } else {
        openImageEditDialog(imageData.identifier, canvas);
      }
    });
    _defineProperty(_assertThisInitialized(_this), "onPrintQualityInfoClick", function () {
      _this.setState({
        printQualityInfoDialogOpen: true
      });
    });
    _defineProperty(_assertThisInitialized(_this), "handlePrintQualityInfoDialogClose", function () {
      _this.setState({
        printQualityInfoDialogOpen: false
      });
    });
    _this.state = {
      printQualityInfoDialogOpen: false
    };
    return _this;
  }
  _createClass(ImageControlbox, [{
    key: "render",
    value: function render() {
      var _this$props2 = this.props,
        classes = _this$props2.classes,
        boxed = _this$props2.boxed,
        printQuality = _this$props2.printQuality,
        handleObjectButtonClick = _this$props2.handleObjectButtonClick,
        flipToFrontDisabled = _this$props2.flipToFrontDisabled,
        flipToBackDisabled = _this$props2.flipToBackDisabled,
        alignVerticalCenterIcon = _this$props2.alignVerticalCenterIcon,
        alignHorizontalCenterIcon = _this$props2.alignHorizontalCenterIcon,
        moveDownIcon = _this$props2.moveDownIcon,
        moveUpIcon = _this$props2.moveUpIcon;
      var printQualityInfoDialogOpen = this.state.printQualityInfoDialogOpen;
      var printQualityInfoExists = (0, _i18n.translationExists)('imageControlbox.printQuality.' + this.props.printQuality);
      return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement(_Card["default"], {
        className: (0, _clsx["default"])(boxed ? classes.card : classes.cardUnboxed, (0, _customClassName["default"])('image-tools-box'))
      }, /*#__PURE__*/_react["default"].createElement(_CardContent["default"], {
        className: boxed ? '' : classes.CardContentWrapper
      }, /*#__PURE__*/_react["default"].createElement(_Grid["default"], {
        container: true
      }, /*#__PURE__*/_react["default"].createElement(_Grid["default"], {
        item: true,
        xs: 12,
        lg: 12
      }, /*#__PURE__*/_react["default"].createElement(_Grid["default"], {
        container: true,
        alignItems: "center"
      }, /*#__PURE__*/_react["default"].createElement(_Grid["default"], {
        item: true,
        lg: printQualityInfoExists ? 10 : 12,
        className: classes.printQuality + ' ' + classes['printQuality' + (0, _upperFirst["default"])(printQuality)]
      }, /*#__PURE__*/_react["default"].createElement(_CheckCircle["default"], {
        className: classes.printQualityIcon
      }), /*#__PURE__*/_react["default"].createElement(_Typography["default"], {
        variant: "body1",
        component: "span",
        className: classes.printQualityText
      }, (0, _i18n.t)('imageControlbox.printQualityLabel'), ":", ' ', (0, _i18n.t)('imageControlbox.printQuality.' + printQuality))), printQualityInfoExists && /*#__PURE__*/_react["default"].createElement(_Grid["default"], {
        item: true,
        lg: 2,
        align: "center"
      }, /*#__PURE__*/_react["default"].createElement(_Info["default"], {
        className: classes.printQualityInfoIcon,
        onClick: this.onPrintQualityInfoClick
      })))), /*#__PURE__*/_react["default"].createElement(_Grid["default"], {
        item: true,
        xs: 10,
        md: 8,
        lg: 8
      }, /*#__PURE__*/_react["default"].createElement(_ObjectTools["default"], {
        handleObjectButtonClick: handleObjectButtonClick,
        flipToFrontDisabled: flipToFrontDisabled,
        flipToBackDisabled: flipToBackDisabled,
        alignVerticalCenterIcon: alignVerticalCenterIcon,
        alignHorizontalCenterIcon: alignHorizontalCenterIcon,
        moveDownIcon: moveDownIcon,
        moveUpIcon: moveUpIcon
      })), /*#__PURE__*/_react["default"].createElement(_Grid["default"], {
        item: true,
        xs: 2,
        md: 4,
        lg: 4
      }, /*#__PURE__*/_react["default"].createElement(_AnalyticsWrapper["default"], {
        targetId: "edit_image"
      }, /*#__PURE__*/_react["default"].createElement(_Button["default"], {
        style: {
          "float": 'right'
        },
        className: classes.editButton,
        variant: "outlined",
        onClick: this.onEditClick
      }, /*#__PURE__*/_react["default"].createElement(_Tooltip["default"], {
        title: (0, _i18n.t)('imageControlbox.editButtonTooltip')
      }, /*#__PURE__*/_react["default"].createElement(_Icon["default"], null, "edit")))))))), /*#__PURE__*/_react["default"].createElement(_CustomDialog["default"], {
        open: printQualityInfoDialogOpen,
        onClose: this.handlePrintQualityInfoDialogClose
      }, /*#__PURE__*/_react["default"].createElement(_DialogContent["default"], null, /*#__PURE__*/_react["default"].createElement(_DialogContentText["default"], {
        id: "alert-dialog-description"
      }, (0, _i18n.t)('imageControlbox.printQuality.' + printQuality))), /*#__PURE__*/_react["default"].createElement(_DialogActions["default"], null, /*#__PURE__*/_react["default"].createElement(_Button["default"], {
        onClick: this.handlePrintQualityInfoDialogClose,
        color: "primary"
      }, "OK"))));
    }
  }]);
  return ImageControlbox;
}(_react["default"].Component);
var _default = exports["default"] = (0, _withWidth["default"])({
  initialWidth: 'lg'
})((0, _styles.withStyles)(styles, {
  name: 'ImageControlbox'
})(ImageControlbox));