import { assign as q } from "../../../min-dash/dist/index.esm.mjs";
import { is as u } from "./ModelUtil.mjs";
var e = {
  width: 90,
  height: 20
}, b = 15;
function v(t) {
  return u(t, "bpmn:Event") || u(t, "bpmn:Gateway") || u(t, "bpmn:DataStoreReference") || u(t, "bpmn:DataObjectReference") || u(t, "bpmn:DataInput") || u(t, "bpmn:DataOutput") || u(t, "bpmn:SequenceFlow") || u(t, "bpmn:MessageFlow") || u(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)), u2 = h.x, x = h.y;
  return Math.abs(o) < Math.PI / 2 ? x -= b : u2 += b, { x: u2, 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) : u(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), q({
    x: r.x - a.width / 2,
    y: r.y - a.height / 2
  }, a);
}
export {
  e as DEFAULT_LABEL_SIZE,
  b as FLOW_LABEL_INDENT,
  s as getExternalLabelBounds,
  l as getExternalLabelMid,
  f as getFlowLabelPosition,
  g as getWaypointsMid,
  v as isLabelExternal
};
