"use strict";
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
const index_esm = require("../../../min-dash/dist/index.esm.js");
const ModelUtil = require("./ModelUtil.js");
var e = {
  width: 90,
  height: 20
}, b = 15;
function v(t) {
  return ModelUtil.is(t, "bpmn:Event") || ModelUtil.is(t, "bpmn:Gateway") || ModelUtil.is(t, "bpmn:DataStoreReference") || ModelUtil.is(t, "bpmn:DataObjectReference") || ModelUtil.is(t, "bpmn:DataInput") || ModelUtil.is(t, "bpmn:DataOutput") || ModelUtil.is(t, "bpmn:SequenceFlow") || ModelUtil.is(t, "bpmn:MessageFlow") || ModelUtil.is(t, "bpmn:Group");
}
function f(t) {
  var n = t.length / 2 - 1, r = t[Math.floor(n)], a = t[Math.ceil(n + 0.01)], h = g(t), o = Math.atan((a.y - r.y) / (a.x - r.x)), u = h.x, x = h.y;
  return Math.abs(o) < Math.PI / 2 ? x -= b : u += b, { x: u, y: x };
}
function g(t) {
  var n = t.length / 2 - 1, r = t[Math.floor(n)], a = t[Math.ceil(n + 0.01)];
  return {
    x: r.x + (a.x - r.x) / 2,
    y: r.y + (a.y - r.y) / 2
  };
}
function l(t) {
  return t.waypoints ? f(t.waypoints) : ModelUtil.is(t, "bpmn:Group") ? {
    x: t.x + t.width / 2,
    y: t.y + e.height / 2
  } : {
    x: t.x + t.width / 2,
    y: t.y + t.height + e.height / 2
  };
}
function s(t, n) {
  var r, a, h, o = t.label;
  return o && o.bounds ? (h = o.bounds, a = {
    width: Math.max(e.width, h.width),
    height: h.height
  }, r = {
    x: h.x + h.width / 2,
    y: h.y + h.height / 2
  }) : (r = l(n), a = e), index_esm.assign({
    x: r.x - a.width / 2,
    y: r.y - a.height / 2
  }, a);
}
exports.DEFAULT_LABEL_SIZE = e;
exports.FLOW_LABEL_INDENT = b;
exports.getExternalLabelBounds = s;
exports.getExternalLabelMid = l;
exports.getFlowLabelPosition = f;
exports.getWaypointsMid = g;
exports.isLabelExternal = v;
