import _parseFloat from "@babel/runtime-corejs2/core-js/parse-float";
import _Object$assign from "@babel/runtime-corejs2/core-js/object/assign";
import _inheritsLoose from "../../../inheritsLoose";
import _defineProperty from "@babel/runtime-corejs2/helpers/defineProperty";
import { DShape } from './shape';
import mx from '../mxgraph';
import { hasWindow } from '../../utils';
var mxActor = mx.mxActor,
    mxUtils = mx.mxUtils,
    mxRectangle = mx.mxRectangle,
    mxCellRenderer = mx.mxCellRenderer,
    mxConnectionConstraint = mx.mxConnectionConstraint,
    mxPoint = mx.mxPoint;
export var DDocument =
/*#__PURE__*/
function (_DShape) {
  _inheritsLoose(DDocument, _DShape);

  function DDocument() {
    return _DShape.apply(this, arguments) || this;
  }

  var _proto = DDocument.prototype;

  _proto.defaults = function defaults() {
    return _Object$assign({}, _DShape.prototype.defaults.call(this), {
      width: 120,
      height: 80
    });
  };

  _proto._getStylesheet = function _getStylesheet() {
    return 'shape=document;whiteSpace=wrap;html=1;boundedLbl=1;';
  };

  return DDocument;
}(DShape);

_defineProperty(DDocument, "displayName", 'DDocument');

if (hasWindow) {
  // Document shape
  var DocumentShape = function DocumentShape() {
    mxActor.call(this);
  };

  ;
  mxUtils.extend(DocumentShape, mxActor);
  DocumentShape.prototype.size = 0.3;
  /* istanbul ignore next */

  DocumentShape.prototype.getLabelMargins = function (rect) {
    if (mxUtils.getValue(this.style, 'boundedLbl', false)) {
      return new mxRectangle(0, 0, 0, _parseFloat(mxUtils.getValue(this.style, 'size', this.size)) * rect.height);
    }

    return null;
  };

  DocumentShape.prototype.redrawPath = function (c, x, y, w, h) {
    var dy = h * Math.max(0, Math.min(1, _parseFloat(mxUtils.getValue(this.style, 'size', this.size))));
    var fy = 1.4;
    c.moveTo(0, 0);
    c.lineTo(w, 0);
    c.lineTo(w, h - dy / 2);
    c.quadTo(w * 3 / 4, h - dy * fy, w / 2, h - dy / 2);
    c.quadTo(w / 4, h - dy * (1 - fy), 0, h - dy / 2);
    c.lineTo(0, dy / 2);
    c.close();
    c.end();
  };

  mxCellRenderer.registerShape('document', DocumentShape);
  DocumentShape.prototype.constraints = [new mxConnectionConstraint(new mxPoint(0.25, 0), true), new mxConnectionConstraint(new mxPoint(0.5, 0), true), new mxConnectionConstraint(new mxPoint(0.75, 0), true), new mxConnectionConstraint(new mxPoint(0, 0.25), true), new mxConnectionConstraint(new mxPoint(0, 0.5), true), new mxConnectionConstraint(new mxPoint(0, 0.75), true), new mxConnectionConstraint(new mxPoint(1, 0.25), true), new mxConnectionConstraint(new mxPoint(1, 0.5), true), new mxConnectionConstraint(new mxPoint(1, 0.75), true)];
}