"use strict";

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

require("./czi-custom-button.css");

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

var _UICommand = _interopRequireDefault(require("./UICommand"));

var _prosemirrorState = require("prosemirror-state");

var _prosemirrorTransform = require("prosemirror-transform");

var _prosemirrorView = require("prosemirror-view");

require("./custom-dropdown.css");

var _customStyle = require("../customStyle");

var _findActiveHeading = require("./findActiveHeading");

var _PointerSurface = _interopRequireWildcard(require("./PointerSurface"));

var _Icon = _interopRequireDefault(require("./Icon"));

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

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

function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }

function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (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 _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }

function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }

function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }

function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }

class CustomStyleItem extends React.PureComponent {
  constructor() {
    super(...arguments);

    _defineProperty(this, "props", void 0);
  }

  render() {
    const _this$props = this.props,
          {
      icon,
      label,
      hasText
    } = _this$props,
          pointerProps = _objectWithoutProperties(_this$props, ["icon", "label", "hasText"]);

    let text = '';
    let customStyle;
    text = this.sampleText();
    const style = (0, _customStyle.getCustomStyleByName)(label);
    const className = 'czi-custom-menu-item';

    if (style) {
      customStyle = (0, _findActiveHeading.getCustomStyle)(style);
    }

    const klass = (0, _classnames.default)(className, '', {
      'use-icon': !!icon
    });
    return /*#__PURE__*/React.createElement("div", {
      id: "container1",
      tag: label
    }, /*#__PURE__*/React.createElement("div", {
      style: {
        width: '140px',
        height: 'auto'
      }
    }, /*#__PURE__*/React.createElement(_PointerSurface.default, _extends({}, pointerProps, {
      className: klass,
      style: {
        display: 'inline-block',
        width: '140px'
      }
    }), icon, label)), /*#__PURE__*/React.createElement("div", {
      style: {
        width: '100px'
      },
      style: customStyle
    }, /*#__PURE__*/React.createElement(_PointerSurface.default, _extends({}, pointerProps, {
      className: klass,
      style: customStyle
    }), icon, text)), /*#__PURE__*/React.createElement("div", {
      className: "arrow-right",
      style: {
        width: '50px'
      },
      style: hasText ? {
        display: 'block'
      } : {
        display: 'none'
      }
    }, /*#__PURE__*/React.createElement(_PointerSurface.default, _extends({}, pointerProps, {
      className: klass + ' edit-icon'
    }), _Icon.default.get('edit'), '')));
  } // temp method to clear sample text for new and clear command menu item


  sampleText() {
    let text = 'AaBbCcDd';

    if (!this.props.hasText) {
      text = '';
    }

    return text;
  }

}

var _default = CustomStyleItem;
exports.default = _default;