"use strict";
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
const index_esm = require("../../../min-dash/dist/index.esm.js");
const ModelUtil = require("../util/ModelUtil.js");
const RenderUtil = require("../../../diagram-js/lib/util/RenderUtil.js");
var black = "hsl(225, 10%, 15%)";
function isTypedEvent(event, eventDefinitionType, filter) {
  function matches(definition, filter2) {
    return index_esm.every(filter2, function(val, key) {
      return definition[key] == val;
    });
  }
  return index_esm.some(event.eventDefinitions, function(definition) {
    return definition.$type === eventDefinitionType && matches(event, filter);
  });
}
function isThrowEvent(event) {
  return event.$type === "bpmn:IntermediateThrowEvent" || event.$type === "bpmn:EndEvent";
}
function isCollection(element) {
  var dataObject = element.dataObjectRef;
  return element.isCollection || dataObject && dataObject.isCollection;
}
function getSemantic(element) {
  return element.businessObject;
}
function getFillColor(element, defaultColor) {
  var di = ModelUtil.getDi(element);
  return di.get("color:background-color") || di.get("bioc:fill") || defaultColor || "white";
}
function getStrokeColor(element, defaultColor) {
  var di = ModelUtil.getDi(element);
  return di.get("color:border-color") || di.get("bioc:stroke") || defaultColor || black;
}
function getLabelColor(element, defaultColor, defaultStrokeColor) {
  var di = ModelUtil.getDi(element), label = di.get("label");
  return label && label.get("color:color") || defaultColor || getStrokeColor(element, defaultStrokeColor);
}
function getCirclePath(shape) {
  var cx = shape.x + shape.width / 2, cy = shape.y + shape.height / 2, radius = shape.width / 2;
  var circlePath = [
    ["M", cx, cy],
    ["m", 0, -radius],
    ["a", radius, radius, 0, 1, 1, 0, 2 * radius],
    ["a", radius, radius, 0, 1, 1, 0, -2 * radius],
    ["z"]
  ];
  return RenderUtil.componentsToPath(circlePath);
}
function getRoundRectPath(shape, borderRadius) {
  var x = shape.x, y = shape.y, width = shape.width, height = shape.height;
  var roundRectPath = [
    ["M", x + borderRadius, y],
    ["l", width - borderRadius * 2, 0],
    ["a", borderRadius, borderRadius, 0, 0, 1, borderRadius, borderRadius],
    ["l", 0, height - borderRadius * 2],
    ["a", borderRadius, borderRadius, 0, 0, 1, -borderRadius, borderRadius],
    ["l", borderRadius * 2 - width, 0],
    ["a", borderRadius, borderRadius, 0, 0, 1, -borderRadius, -borderRadius],
    ["l", 0, borderRadius * 2 - height],
    ["a", borderRadius, borderRadius, 0, 0, 1, borderRadius, -borderRadius],
    ["z"]
  ];
  return RenderUtil.componentsToPath(roundRectPath);
}
function getDiamondPath(shape) {
  var width = shape.width, height = shape.height, x = shape.x, y = shape.y, halfWidth = width / 2, halfHeight = height / 2;
  var diamondPath = [
    ["M", x + halfWidth, y],
    ["l", halfWidth, halfHeight],
    ["l", -halfWidth, halfHeight],
    ["l", -halfWidth, -halfHeight],
    ["z"]
  ];
  return RenderUtil.componentsToPath(diamondPath);
}
function getRectPath(shape) {
  var x = shape.x, y = shape.y, width = shape.width, height = shape.height;
  var rectPath = [
    ["M", x, y],
    ["l", width, 0],
    ["l", 0, height],
    ["l", -width, 0],
    ["z"]
  ];
  return RenderUtil.componentsToPath(rectPath);
}
exports.getDi = ModelUtil.getDi;
exports.black = black;
exports.getCirclePath = getCirclePath;
exports.getDiamondPath = getDiamondPath;
exports.getFillColor = getFillColor;
exports.getLabelColor = getLabelColor;
exports.getRectPath = getRectPath;
exports.getRoundRectPath = getRoundRectPath;
exports.getSemantic = getSemantic;
exports.getStrokeColor = getStrokeColor;
exports.isCollection = isCollection;
exports.isThrowEvent = isThrowEvent;
exports.isTypedEvent = isTypedEvent;
