"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports["default"] = exports.RawMathPreview = void 0;

var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));

var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));

var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));

var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));

var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));

var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));

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

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

var _debug = _interopRequireDefault(require("debug"));

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

var _propTypes = _interopRequireDefault(require("prop-types"));

var _mathInput = require("../math-input");

function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; }

function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }

var log = (0, _debug["default"])('@pie-lib:math-toolbar:math-preview');

var RawMathPreview = /*#__PURE__*/function (_React$Component) {
  (0, _inherits2["default"])(RawMathPreview, _React$Component);

  var _super = _createSuper(RawMathPreview);

  function RawMathPreview() {
    (0, _classCallCheck2["default"])(this, RawMathPreview);
    return _super.apply(this, arguments);
  }

  (0, _createClass2["default"])(RawMathPreview, [{
    key: "render",
    value: function render() {
      log('[render] data: ', this.props.node.data);
      var latex = this.props.node.data.get('latex');
      var _this$props = this.props,
          classes = _this$props.classes,
          isSelected = _this$props.isSelected,
          onFocus = _this$props.onFocus,
          onBlur = _this$props.onBlur;
      return /*#__PURE__*/_react["default"].createElement("div", {
        className: (0, _classnames["default"])(classes.root, isSelected && classes.selected)
      }, ' ', /*#__PURE__*/_react["default"].createElement("span", {
        className: classes.insideOverlay
      }), /*#__PURE__*/_react["default"].createElement(_mathInput.mq.Static, {
        latex: latex,
        onFocus: onFocus,
        onBlur: onBlur
      }));
    }
  }]);
  return RawMathPreview;
}(_react["default"].Component);

exports.RawMathPreview = RawMathPreview;
(0, _defineProperty2["default"])(RawMathPreview, "propTypes", {
  latex: _propTypes["default"].string,
  node: _propTypes["default"].object,
  classes: _propTypes["default"].object,
  isSelected: _propTypes["default"].bool,
  onFocus: _propTypes["default"].func,
  onBlur: _propTypes["default"].func
});

var mp = function mp(theme) {
  return {
    root: {
      display: 'inline-flex',
      alignItems: 'center',
      position: 'relative',
      '& *': {
        fontFamily: 'MJXZERO, MJXTEX !important',
        '-webkit-font-smoothing': 'antialiased !important'
      },
      '& > .mq-math-mode > span > var': {
        fontFamily: 'MJXZERO, MJXTEX-I !important'
      },
      '& > .mq-math-mode span var': {
        fontFamily: 'MJXZERO, MJXTEX-I !important'
      },
      '& > .mq-math-mode .mq-nonSymbola': {
        fontFamily: 'MJXZERO, MJXTEX-I !important'
      },
      '& > .mq-math-mode > span > var.mq-operator-name': {
        fontFamily: 'MJXZERO, MJXTEX !important'
      },
      '& > .mq-math-mode': {
        border: 'solid 1px lightgrey'
      },
      '& > .mq-focused': {
        outline: 'none',
        boxShadow: 'none',
        border: 'solid 1px black',
        borderRadius: '0px'
      },
      '& > .mq-math-mode .mq-root-block': {
        paddingTop: '7px !important'
      },
      '& > .mq-math-mode .mq-overarc ': {
        paddingTop: '0.45em !important'
      },
      '& > .mq-math-mode .mq-sqrt-prefix': {
        verticalAlign: 'baseline !important',
        top: '1px !important',
        left: '-0.1em !important'
      },
      '& > .mq-math-mode .mq-denominator': {
        marginTop: '-5px !important',
        padding: '0.5em 0.1em 0.1em !important'
      },
      '& > .mq-math-mode .mq-numerator, .mq-math-mode .mq-over': {
        padding: '0 0.1em !important',
        paddingBottom: '0 !important',
        marginBottom: '-2px'
      },
      '& > .mq-math-mode sup.mq-nthroot': {
        fontSize: '70.7% !important',
        verticalAlign: '0.5em !important',
        paddingRight: '0.15em'
      },
      '& > .mq-longdiv-inner': {
        marginTop: '-1px',
        marginLeft: '5px !important;',
        '& > .mq-empty': {
          padding: '0 !important',
          marginLeft: '0px !important',
          marginTop: '2px'
        }
      },
      '& > .mq-math-mode .mq-longdiv': {
        display: 'inline-flex !important'
      },
      '& > .mq-math-mode .mq-longdiv .mq-longdiv-inner .mq-empty': {
        paddingTop: '6px !important',
        paddingLeft: '4px !important'
      },
      '& > .mq-math-mode .mq-longdiv .mq-longdiv-inner': {
        marginLeft: '0 !important'
      },
      '& > .mq-math-mode .mq-supsub': {
        fontSize: '70.7% !important'
      },
      '& > .mq-math-mode .mq-overarrow': {
        fontFamily: 'Roboto, Helvetica, Arial, sans-serif !important'
      },
      '& > .mq-math-mode .mq-paren': {
        verticalAlign: 'top !important',
        padding: '1px 0.1em !important'
      },
      '& > .mq-math-mode .mq-sqrt-stem': {
        borderTop: '0.07em solid',
        marginLeft: '-1.5px',
        marginTop: '-2px !important',
        paddingTop: '5px !important'
      },
      '& > .mq-supsub ': {
        fontSize: '70.7%'
      },
      '& > .mq-math-mode .mq-supsub.mq-sup-only': {
        verticalAlign: '-0.1em !important',
        '& .mq-sup': {
          marginBottom: '0px !important'
        }
      },
      '& .mq-overarrow-inner': {
        paddingTop: '0 !important',
        border: 'none !important'
      },
      '& .mq-editable-field .mq-cursor': {
        marginTop: '-15px !important'
      },
      '& .mq-overarrow.mq-arrow-both': {
        top: '7.5px',
        marginTop: '0px',
        minWidth: '1.23em',
        '& *': {
          lineHeight: '1 !important'
        },
        '&:before': {
          top: '-0.4em',
          left: '-1px'
        },
        '&:after': {
          top: '0px !important',
          position: 'absolute',
          right: '-2px'
        },
        '&.mq-empty:after': {
          top: '-0.45em'
        }
      },
      '& .mq-overarrow.mq-arrow-right': {
        '&:before': {
          top: '-0.4em',
          right: '-1px'
        }
      },
      '& .mq-overarrow-inner-right': {
        display: 'none !important'
      },
      '& .mq-overarrow-inner-left': {
        display: 'none !important'
      },
      '& .mq-longdiv-inner': {
        borderTop: '1px solid !important',
        paddingTop: '1.5px !important'
      },
      '& .mq-parallelogram': {
        lineHeight: 0.85
      }
    },
    selected: {
      border: "solid 1px ".concat(theme.palette.primary.main),
      '& > .mq-math-mode': {
        border: 'solid 0px lightgrey'
      }
    },
    insideOverlay: {
      position: 'absolute',
      bottom: 0,
      left: 0,
      right: 0,
      top: 0
    }
  };
};

var _default = (0, _styles.withStyles)(mp)(RawMathPreview);

exports["default"] = _default;
//# sourceMappingURL=math-preview.js.map