"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;
exports.conditionNode = void 0;
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
var _icons = require("../icons");
var _type = require("../type");
/**
 * 条件节点，主要配置条件事件
 */

var conditionNode = exports.conditionNode = {
  options: {
    style: {
      fill: "#FFF2E8",
      stroke: "#FFC069",
      radius: 20,
      lineWidth: 1,
      lineDash: [4, 4]
    },
    stateStyles: {
      hover: {},
      selected: {}
    },
    labelCfg: {
      style: {
        fill: "#000000",
        fontSize: 14,
        fontWeight: 400,
        fillOpacity: "0.7"
      }
    },
    size: [120, 40]
  },
  drawShape: function drawShape(cfg, group) {
    var _cfg$menus;
    var styles = this.getShapeStyle(cfg);
    var h = styles.height;
    var w = styles.width;
    var keyShape = group.addShape("rect", {
      attrs: (0, _extends2["default"])({
        x: 0,
        y: 0
      }, styles)
    });
    group.addShape("marker", {
      attrs: {
        x: w / 2 - 20,
        y: 0,
        r: 6,
        stroke: "#ff4d4f",
        cursor: "pointer",
        symbol: _icons.COLLAPSE_ICON
      },
      name: _type.FlowEvent.removeItem
    });
    if ((_cfg$menus = cfg.menus) !== null && _cfg$menus !== void 0 && _cfg$menus.length) {
      group.addShape("marker", {
        attrs: {
          x: 0,
          y: h / 2 + 7,
          r: 6,
          stroke: "#73d13d",
          cursor: "pointer",
          symbol: _icons.EXPAND_ICON
        },
        // must be assigned in G6 3.3 and later versions. it can be any string you want, but should be unique in a custom item type
        name: _type.FlowEvent.addItem
      });
    }
    return keyShape;
  },
  update: function update(cfg, node) {
    var _cfg$menus2;
    var styles = this.getShapeStyle(cfg);
    var h = styles.height;
    var group = node.getContainer();
    var child = group.find(function (item) {
      return item.get("name") === _type.FlowEvent.addItem;
    });
    if (!child && (_cfg$menus2 = cfg.menus) !== null && _cfg$menus2 !== void 0 && _cfg$menus2.length) {
      group.addShape("marker", {
        attrs: {
          x: 0,
          y: h / 2 + 7,
          r: 6,
          stroke: "#73d13d",
          cursor: "pointer",
          symbol: _icons.EXPAND_ICON
        },
        // must be assigned in G6 3.3 and later versions. it can be any string you want, but should be unique in a custom item type
        name: _type.FlowEvent.addItem
      });
    }
  }
};