123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200 |
- import {
- attr,
- create
- } from "./chunk-IQOBXLIK.js";
- import {
- getDi
- } from "./chunk-L5SG54UC.js";
- import {
- has,
- isNumber,
- some
- } from "./chunk-4AK4GF4H.js";
- // node_modules/.pnpm/diagram-js@13.4.0/node_modules/diagram-js/lib/util/RenderUtil.js
- function componentsToPath(elements) {
- return elements.flat().join(",").replace(/,?([A-z]),?/g, "$1");
- }
- function move(point) {
- return ["M", point.x, point.y];
- }
- function lineTo(point) {
- return ["L", point.x, point.y];
- }
- function curveTo(p1, p2, p3) {
- return ["C", p1.x, p1.y, p2.x, p2.y, p3.x, p3.y];
- }
- function drawPath(waypoints, cornerRadius) {
- const pointCount = waypoints.length;
- const path = [move(waypoints[0])];
- for (let i = 1; i < pointCount; i++) {
- const pointBefore = waypoints[i - 1];
- const point = waypoints[i];
- const pointAfter = waypoints[i + 1];
- if (!pointAfter || !cornerRadius) {
- path.push(lineTo(point));
- continue;
- }
- const effectiveRadius = Math.min(
- cornerRadius,
- vectorLength(point.x - pointBefore.x, point.y - pointBefore.y),
- vectorLength(pointAfter.x - point.x, pointAfter.y - point.y)
- );
- if (!effectiveRadius) {
- path.push(lineTo(point));
- continue;
- }
- const beforePoint = getPointAtLength(point, pointBefore, effectiveRadius);
- const beforePoint2 = getPointAtLength(point, pointBefore, effectiveRadius * 0.5);
- const afterPoint = getPointAtLength(point, pointAfter, effectiveRadius);
- const afterPoint2 = getPointAtLength(point, pointAfter, effectiveRadius * 0.5);
- path.push(lineTo(beforePoint));
- path.push(curveTo(beforePoint2, afterPoint2, afterPoint));
- }
- return path;
- }
- function getPointAtLength(start, end, length) {
- const deltaX = end.x - start.x;
- const deltaY = end.y - start.y;
- const totalLength = vectorLength(deltaX, deltaY);
- const percent = length / totalLength;
- return {
- x: start.x + deltaX * percent,
- y: start.y + deltaY * percent
- };
- }
- function vectorLength(x, y) {
- return Math.sqrt(Math.pow(x, 2) + Math.pow(y, 2));
- }
- function createLine(points, attrs, radius) {
- if (isNumber(attrs)) {
- radius = attrs;
- attrs = null;
- }
- if (!attrs) {
- attrs = {};
- }
- const line = create("path", attrs);
- if (isNumber(radius)) {
- line.dataset.cornerRadius = String(radius);
- }
- return updateLine(line, points);
- }
- function updateLine(gfx, points) {
- const cornerRadius = parseInt(gfx.dataset.cornerRadius, 10) || 0;
- attr(gfx, {
- d: componentsToPath(drawPath(points, cornerRadius))
- });
- return gfx;
- }
- // node_modules/.pnpm/bpmn-js@16.3.2/node_modules/bpmn-js/lib/draw/BpmnRenderUtil.js
- var black = "hsl(225, 10%, 15%)";
- var white = "white";
- function isTypedEvent(event, eventDefinitionType) {
- return some(event.eventDefinitions, function(definition) {
- return definition.$type === eventDefinitionType;
- });
- }
- 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 getFillColor(element, defaultColor, overrideColor) {
- var di = getDi(element);
- return overrideColor || di.get("color:background-color") || di.get("bioc:fill") || defaultColor || white;
- }
- function getStrokeColor(element, defaultColor, overrideColor) {
- var di = getDi(element);
- return overrideColor || di.get("color:border-color") || di.get("bioc:stroke") || defaultColor || black;
- }
- function getLabelColor(element, defaultColor, defaultStrokeColor, overrideColor) {
- var di = getDi(element), label = di.get("label");
- return overrideColor || 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 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 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 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 componentsToPath(rectPath);
- }
- function getBounds(bounds, overrides = {}) {
- return {
- width: getWidth(bounds, overrides),
- height: getHeight(bounds, overrides)
- };
- }
- function getWidth(bounds, overrides = {}) {
- return has(overrides, "width") ? overrides.width : bounds.width;
- }
- function getHeight(bounds, overrides = {}) {
- return has(overrides, "height") ? overrides.height : bounds.height;
- }
- export {
- componentsToPath,
- createLine,
- updateLine,
- black,
- white,
- isTypedEvent,
- isThrowEvent,
- isCollection,
- getFillColor,
- getStrokeColor,
- getLabelColor,
- getCirclePath,
- getRoundRectPath,
- getDiamondPath,
- getRectPath,
- getBounds,
- getWidth,
- getHeight
- };
- //# sourceMappingURL=chunk-LSRYXWJD.js.map
|