text: "use strict";
  Object.defineProperty(exports, "__esModule", { value: true });
  var util_1 = require("@antv/util");
  var clear_overlapping_1 = require("./clear-overlapping");
  /** 图形向上抖开并拉线 */
  // todo 允许设置offset和拉线样式
  function nodeJitterUpward(shape, option, index, cfg) {
      var nodes = cfg.nodes.nodes;
      if (index === 0) {
          return;
      }
      var current = nodes[index];
      var previous = nodes[index - 1];
      if (clear_overlapping_1.isNodeOverlap(current, previous)) {
          var element = cfg.plot.plot.get('elements')[0];
          var y = previous.top - current.height / 2;
          var offset = 10;
          if (y - offset > cfg.region.top) {
              // 取到label对应的element-shape
              var origin_1 = current.shape.get('origin');
              var shapeId = element.getShapeId(origin_1);
              var shapes = element.getShapes();
              var shapeBbox = getShapeById(shapeId, shapes).get('box');
              var originX = shapeBbox.left + shapeBbox.width / 2;
              var originY = shapeBbox.top;
              // 拉线
              var container = element.get('labelController').labelsContainer;
              var labelLine = container.addShape('path', {
                  attrs: {
                      path: [
                          ['M', originX, originY],
                          ['L', current.shape.attr('x'), y],
                      ],
                      stroke: '#ccc',
                      lineWidth: 1,
                  },
              });
              /** 保存labelLine和label初始位置信息 */
              var origin_position = { x: shape.attr('x'), y: shape.attr('y') };
              // 更新标签位置，同步更新node
              current.shape.attr('y', y - offset);
              nodes[index] = cfg.nodes.measure(current.shape);
              nodes[index].line = labelLine;
              nodes[index].origin_position = origin_position;
          }
      }
  }
  exports.default = nodeJitterUpward;
  function getShapeById(shapeId, shapes) {
      var target;
      util_1.each(shapes, function (shape) {
          var s = shape;
          var id = s.get('id');
          if (id === shapeId) {
              target = s;
          }
      });
      return target;
  }
  //# sourceMappingURL=node-jitter-upward.js.map