/*!
 * DevExpress Diagram (dx-diagram)
 * Version: 2.1.57
 * Build date: Mon May 30 2022
 * 
 * Copyright (c) 2012 - 2022 Developer Express Inc. ALL RIGHTS RESERVED
 * Read about DevExpress licensing here: https://www.devexpress.com/Support/EULAs
 */
(function webpackUniversalModuleDefinition(root, factory) {
	if(typeof exports === 'object' && typeof module === 'object')
		module.exports = factory();
	else if(typeof define === 'function' && define.amd)
		define([], factory);
	else if(typeof exports === 'object')
		exports["diagram"] = factory();
	else
		root["DevExpress"] = root["DevExpress"] || {}, root["DevExpress"]["diagram"] = factory();
})(this, function() {
return /******/ (function(modules) { // webpackBootstrap
/******/ 	// The module cache
/******/ 	var installedModules = {};
/******/
/******/ 	// The require function
/******/ 	function __webpack_require__(moduleId) {
/******/
/******/ 		// Check if module is in cache
/******/ 		if(installedModules[moduleId]) {
/******/ 			return installedModules[moduleId].exports;
/******/ 		}
/******/ 		// Create a new module (and put it into the cache)
/******/ 		var module = installedModules[moduleId] = {
/******/ 			i: moduleId,
/******/ 			l: false,
/******/ 			exports: {}
/******/ 		};
/******/
/******/ 		// Execute the module function
/******/ 		modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/
/******/ 		// Flag the module as loaded
/******/ 		module.l = true;
/******/
/******/ 		// Return the exports of the module
/******/ 		return module.exports;
/******/ 	}
/******/
/******/
/******/ 	// expose the modules object (__webpack_modules__)
/******/ 	__webpack_require__.m = modules;
/******/
/******/ 	// expose the module cache
/******/ 	__webpack_require__.c = installedModules;
/******/
/******/ 	// define getter function for harmony exports
/******/ 	__webpack_require__.d = function(exports, name, getter) {
/******/ 		if(!__webpack_require__.o(exports, name)) {
/******/ 			Object.defineProperty(exports, name, { enumerable: true, get: getter });
/******/ 		}
/******/ 	};
/******/
/******/ 	// define __esModule on exports
/******/ 	__webpack_require__.r = function(exports) {
/******/ 		if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
/******/ 			Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
/******/ 		}
/******/ 		Object.defineProperty(exports, '__esModule', { value: true });
/******/ 	};
/******/
/******/ 	// create a fake namespace object
/******/ 	// mode & 1: value is a module id, require it
/******/ 	// mode & 2: merge all properties of value into the ns
/******/ 	// mode & 4: return value when already ns object
/******/ 	// mode & 8|1: behave like require
/******/ 	__webpack_require__.t = function(value, mode) {
/******/ 		if(mode & 1) value = __webpack_require__(value);
/******/ 		if(mode & 8) return value;
/******/ 		if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
/******/ 		var ns = Object.create(null);
/******/ 		__webpack_require__.r(ns);
/******/ 		Object.defineProperty(ns, 'default', { enumerable: true, value: value });
/******/ 		if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
/******/ 		return ns;
/******/ 	};
/******/
/******/ 	// getDefaultExport function for compatibility with non-harmony modules
/******/ 	__webpack_require__.n = function(module) {
/******/ 		var getter = module && module.__esModule ?
/******/ 			function getDefault() { return module['default']; } :
/******/ 			function getModuleExports() { return module; };
/******/ 		__webpack_require__.d(getter, 'a', getter);
/******/ 		return getter;
/******/ 	};
/******/
/******/ 	// Object.prototype.hasOwnProperty.call
/******/ 	__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
/******/
/******/ 	// __webpack_public_path__
/******/ 	__webpack_require__.p = "";
/******/
/******/
/******/ 	// Load entry module and return exports
/******/ 	return __webpack_require__(__webpack_require__.s = 58);
/******/ })
/************************************************************************/
/******/ ([
/* 0 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

Object.defineProperty(exports, "__esModule", { value: true });
var Point = (function () {
    function Point(x, y) {
        this.x = x;
        this.y = y;
    }
    Point.zero = function () {
        return new Point(0, 0);
    };
    Point.fromNumber = function (num) {
        return new Point(num, num);
    };
    Point.prototype.isZero = function () {
        return this.x === 0 && this.y === 0;
    };
    Point.prototype.toString = function () {
        return JSON.stringify(this);
    };
    Point.prototype.copyFrom = function (obj) {
        this.x = obj.x;
        this.y = obj.y;
    };
    Point.prototype.clone = function () {
        return new Point(this.x, this.y);
    };
    Point.prototype.equals = function (obj) {
        return this.x === obj.x && this.y === obj.y;
    };
    Point.prototype.offset = function (offsetX, offsetY) {
        this.x += offsetX;
        this.y += offsetY;
        return this;
    };
    Point.prototype.offsetByPoint = function (offset) {
        this.x += offset.x;
        this.y += offset.y;
        return this;
    };
    Point.prototype.multiply = function (multiplierX, multiplierY) {
        this.x *= multiplierX;
        this.y *= multiplierY;
        return this;
    };
    Point.prototype.negative = function () {
        this.x *= -1;
        this.y *= -1;
        return this;
    };
    Point.prototype.applyConverter = function (converter) {
        this.x = converter(this.x);
        this.y = converter(this.y);
        return this;
    };
    Point.plus = function (a, b) {
        return new Point(a.x + b.x, a.y + b.y);
    };
    Point.minus = function (a, b) {
        return new Point(a.x - b.x, a.y - b.y);
    };
    Point.xComparer = function (a, b) {
        return a.x - b.x;
    };
    Point.yComparer = function (a, b) {
        return a.y - b.y;
    };
    Point.equals = function (a, b) {
        return a.x === b.x && a.y === b.y;
    };
    return Point;
}());
exports.Point = Point;


/***/ }),
/* 1 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.ShapeType = exports.ShapeTypes = exports.ShapeCategories = void 0;
var ShapeCategories = (function () {
    function ShapeCategories() {
    }
    ShapeCategories.General = "general";
    ShapeCategories.Flowchart = "flowchart";
    ShapeCategories.OrgChart = "orgChart";
    ShapeCategories.Containers = "containers";
    ShapeCategories.Custom = "custom";
    return ShapeCategories;
}());
exports.ShapeCategories = ShapeCategories;
var ShapeTypes = (function () {
    function ShapeTypes() {
    }
    ShapeTypes.Text = "text";
    ShapeTypes.Rectangle = "rectangle";
    ShapeTypes.Ellipse = "ellipse";
    ShapeTypes.Cross = "cross";
    ShapeTypes.Triangle = "triangle";
    ShapeTypes.Diamond = "diamond";
    ShapeTypes.Heart = "heart";
    ShapeTypes.Pentagon = "pentagon";
    ShapeTypes.Hexagon = "hexagon";
    ShapeTypes.Octagon = "octagon";
    ShapeTypes.Star = "star";
    ShapeTypes.ArrowLeft = "arrowLeft";
    ShapeTypes.ArrowUp = "arrowTop";
    ShapeTypes.ArrowRight = "arrowRight";
    ShapeTypes.ArrowDown = "arrowBottom";
    ShapeTypes.ArrowUpDown = "arrowNorthSouth";
    ShapeTypes.ArrowLeftRight = "arrowEastWest";
    ShapeTypes.Process = "process";
    ShapeTypes.Decision = "decision";
    ShapeTypes.Terminator = "terminator";
    ShapeTypes.PredefinedProcess = "predefinedProcess";
    ShapeTypes.Document = "document";
    ShapeTypes.MultipleDocuments = "multipleDocuments";
    ShapeTypes.ManualInput = "manualInput";
    ShapeTypes.Preparation = "preparation";
    ShapeTypes.Data = "data";
    ShapeTypes.Database = "database";
    ShapeTypes.HardDisk = "hardDisk";
    ShapeTypes.InternalStorage = "internalStorage";
    ShapeTypes.PaperTape = "paperTape";
    ShapeTypes.ManualOperation = "manualOperation";
    ShapeTypes.Delay = "delay";
    ShapeTypes.StoredData = "storedData";
    ShapeTypes.Display = "display";
    ShapeTypes.Merge = "merge";
    ShapeTypes.Connector = "connector";
    ShapeTypes.Or = "or";
    ShapeTypes.SummingJunction = "summingJunction";
    ShapeTypes.Container = "container";
    ShapeTypes.VerticalContainer = "verticalContainer";
    ShapeTypes.HorizontalContainer = "horizontalContainer";
    ShapeTypes.Card = "card";
    ShapeTypes.CardWithImageOnLeft = "cardWithImageOnLeft";
    ShapeTypes.CardWithImageOnTop = "cardWithImageOnTop";
    ShapeTypes.CardWithImageOnRight = "cardWithImageOnRight";
    return ShapeTypes;
}());
exports.ShapeTypes = ShapeTypes;
var ShapeType;
(function (ShapeType) {
    ShapeType[ShapeType["text"] = 0] = "text";
    ShapeType[ShapeType["rectangle"] = 1] = "rectangle";
    ShapeType[ShapeType["ellipse"] = 2] = "ellipse";
    ShapeType[ShapeType["cross"] = 3] = "cross";
    ShapeType[ShapeType["triangle"] = 4] = "triangle";
    ShapeType[ShapeType["diamond"] = 5] = "diamond";
    ShapeType[ShapeType["heart"] = 6] = "heart";
    ShapeType[ShapeType["pentagon"] = 7] = "pentagon";
    ShapeType[ShapeType["hexagon"] = 8] = "hexagon";
    ShapeType[ShapeType["octagon"] = 9] = "octagon";
    ShapeType[ShapeType["star"] = 10] = "star";
    ShapeType[ShapeType["arrowLeft"] = 11] = "arrowLeft";
    ShapeType[ShapeType["arrowTop"] = 12] = "arrowTop";
    ShapeType[ShapeType["arrowRight"] = 13] = "arrowRight";
    ShapeType[ShapeType["arrowBottom"] = 14] = "arrowBottom";
    ShapeType[ShapeType["arrowNorthSouth"] = 15] = "arrowNorthSouth";
    ShapeType[ShapeType["arrowEastWest"] = 16] = "arrowEastWest";
    ShapeType[ShapeType["process"] = 17] = "process";
    ShapeType[ShapeType["decision"] = 18] = "decision";
    ShapeType[ShapeType["terminator"] = 19] = "terminator";
    ShapeType[ShapeType["predefinedProcess"] = 20] = "predefinedProcess";
    ShapeType[ShapeType["document"] = 21] = "document";
    ShapeType[ShapeType["multipleDocuments"] = 22] = "multipleDocuments";
    ShapeType[ShapeType["manualInput"] = 23] = "manualInput";
    ShapeType[ShapeType["preparation"] = 24] = "preparation";
    ShapeType[ShapeType["data"] = 25] = "data";
    ShapeType[ShapeType["database"] = 26] = "database";
    ShapeType[ShapeType["hardDisk"] = 27] = "hardDisk";
    ShapeType[ShapeType["internalStorage"] = 28] = "internalStorage";
    ShapeType[ShapeType["paperTape"] = 29] = "paperTape";
    ShapeType[ShapeType["manualOperation"] = 30] = "manualOperation";
    ShapeType[ShapeType["delay"] = 31] = "delay";
    ShapeType[ShapeType["storedData"] = 32] = "storedData";
    ShapeType[ShapeType["display"] = 33] = "display";
    ShapeType[ShapeType["merge"] = 34] = "merge";
    ShapeType[ShapeType["connector"] = 35] = "connector";
    ShapeType[ShapeType["or"] = 36] = "or";
    ShapeType[ShapeType["summingJunction"] = 37] = "summingJunction";
    ShapeType[ShapeType["verticalContainer"] = 38] = "verticalContainer";
    ShapeType[ShapeType["horizontalContainer"] = 39] = "horizontalContainer";
    ShapeType[ShapeType["cardWithImageOnLeft"] = 40] = "cardWithImageOnLeft";
    ShapeType[ShapeType["cardWithImageOnTop"] = 41] = "cardWithImageOnTop";
    ShapeType[ShapeType["cardWithImageOnRight"] = 42] = "cardWithImageOnRight";
})(ShapeType = exports.ShapeType || (exports.ShapeType = {}));


/***/ }),
/* 2 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

Object.defineProperty(exports, "__esModule", { value: true });
var Size = (function () {
    function Size(width, height) {
        this.width = width;
        this.height = height;
    }
    Size.empty = function () {
        return new Size(0, 0);
    };
    Size.fromNumber = function (num) {
        return new Size(num, num);
    };
    Size.initByCommonAction = function (action) {
        var widthAdp = function (s) { return s.width; };
        var heightAdp = function (s) { return s.height; };
        return new Size(action(widthAdp, heightAdp), action(heightAdp, widthAdp));
    };
    Size.prototype.isEmpty = function () {
        return this.width === 0 && this.height === 0;
    };
    Size.prototype.toString = function () {
        return JSON.stringify(this);
    };
    Size.prototype.nonNegativeSize = function () {
        if (this.width < 0)
            this.width = 0;
        if (this.height < 0)
            this.height = 0;
        return this;
    };
    Size.prototype.offset = function (offsetWidth, offsetHeight) {
        this.width = this.width + offsetWidth;
        this.height = this.height + offsetHeight;
        return this;
    };
    Size.prototype.multiply = function (multiplierW, multiplierH) {
        this.width *= multiplierW;
        this.height *= multiplierH;
        return this;
    };
    Size.prototype.equals = function (obj) {
        return this.width === obj.width && this.height === obj.height;
    };
    Size.prototype.clone = function () {
        return new Size(this.width, this.height);
    };
    Size.prototype.copyFrom = function (obj) {
        this.width = obj.width;
        this.height = obj.height;
    };
    Size.prototype.applyConverter = function (conv) {
        this.width = conv(this.width);
        this.height = conv(this.height);
        return this;
    };
    Size.equals = function (a, b) {
        return a.width === b.width && a.height === b.height;
    };
    return Size;
}());
exports.Size = Size;


/***/ }),
/* 3 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.EventUtils = exports.HtmlFocusUtils = exports.ObjectUtils = exports.GeometryUtils = exports.Utils = exports.EventDispatcher = exports.Range = exports.LineEquation = void 0;
__webpack_require__(174);
var size_1 = __webpack_require__(2);
var point_1 = __webpack_require__(0);
var rectangle_1 = __webpack_require__(13);
var search_1 = __webpack_require__(41);
var metrics_1 = __webpack_require__(35);
var math_1 = __webpack_require__(31);
var vector_1 = __webpack_require__(60);
var segment_1 = __webpack_require__(33);
var Style_1 = __webpack_require__(26);
var browser_1 = __webpack_require__(18);
var evt_1 = __webpack_require__(65);
var LineEquation = (function () {
    function LineEquation(aParam, bParam, cParam) {
        this.aParam = aParam;
        this.bParam = bParam;
        this.cParam = cParam;
    }
    LineEquation.fromPoints = function (pointA, pointB, accuracy) {
        if (accuracy === void 0) { accuracy = 0.00001; }
        return !GeometryUtils.areDuplicatedPoints(pointA, pointB, accuracy) ?
            new LineEquation(pointB.y - pointA.y, pointA.x - pointB.x, pointB.x * pointA.y - pointA.x * pointB.y) : undefined;
    };
    LineEquation.prototype.getPointIntersection = function (other, accuracy) {
        if (accuracy === void 0) { accuracy = 0.00001; }
        var A1 = this.aParam;
        var B1 = this.bParam;
        var C1 = this.cParam;
        var A2 = other.aParam;
        var B2 = other.bParam;
        var C2 = other.cParam;
        var v = A2 * B1 - A1 * B2;
        if (math_1.MathUtils.numberCloseTo(v, 0, accuracy))
            return null;
        if (A1 === 0) {
            var x = (B2 * C1 - C2 * B1) / (B1 * A2);
            return this.createPoint(x, -C1 / B1);
        }
        var y = (C2 * A1 - C1 * A2) / v;
        return this.createPoint((-B1 * y - C1) / A1, y);
    };
    LineEquation.prototype.containsPoint = function (point, accuracy) {
        if (accuracy === void 0) { accuracy = 0.00001; }
        return math_1.MathUtils.numberCloseTo(this.aParam * point.x + this.bParam * point.y + this.cParam, 0, accuracy);
    };
    LineEquation.prototype.createPoint = function (x, y, accuracy) {
        if (accuracy === void 0) { accuracy = 0.00001; }
        return new point_1.Point(math_1.MathUtils.numberCloseTo(x, 0, accuracy) ? 0 : x, math_1.MathUtils.numberCloseTo(y, 0, accuracy) ? 0 : y);
    };
    return LineEquation;
}());
exports.LineEquation = LineEquation;
var Range = (function () {
    function Range(from, to) {
        this.from = from;
        this.to = to !== undefined ? to : from;
    }
    Object.defineProperty(Range.prototype, "length", {
        get: function () {
            return Math.abs(this.to - this.from);
        },
        enumerable: false,
        configurable: true
    });
    Range.prototype.extend = function (range) {
        this.from = Math.min(range.from, this.from);
        this.to = Math.max(range.to, this.to);
    };
    Range.prototype.includes = function (value) {
        return value >= this.from && value <= this.to;
    };
    Range.fromLength = function (from, length) {
        return new Range(from, from + length);
    };
    return Range;
}());
exports.Range = Range;
var EventDispatcher = (function () {
    function EventDispatcher() {
        this.listeners = [];
    }
    EventDispatcher.prototype.add = function (listener) {
        if (!listener)
            throw new Error("Not Implemented");
        if (!this.hasEventListener(listener))
            this.listeners.push(listener);
    };
    EventDispatcher.prototype.remove = function (listener) {
        for (var i = 0, currentListener = void 0; currentListener = this.listeners[i]; i++)
            if (currentListener === listener) {
                this.listeners.splice(i, 1);
                break;
            }
    };
    EventDispatcher.prototype.raise = function (funcName) {
        var args = [];
        for (var _i = 1; _i < arguments.length; _i++) {
            args[_i - 1] = arguments[_i];
        }
        for (var i = 0, listener = void 0; listener = this.listeners[i]; i++) {
            var func = listener[funcName];
            func && func.apply(listener, args);
        }
    };
    EventDispatcher.prototype.raise1 = function (action) {
        for (var i = 0, listener = void 0; listener = this.listeners[i]; i++)
            action(listener);
    };
    EventDispatcher.prototype.hasEventListener = function (listener) {
        for (var i = 0, l = this.listeners.length; i < l; i++)
            if (this.listeners[i] === listener)
                return true;
        return false;
    };
    return EventDispatcher;
}());
exports.EventDispatcher = EventDispatcher;
var Utils = (function () {
    function Utils() {
    }
    Utils.flatten = function (arr) {
        return [].concat.apply([], arr);
    };
    return Utils;
}());
exports.Utils = Utils;
var GeometryUtils = (function () {
    function GeometryUtils() {
    }
    GeometryUtils.getCommonRectangle = function (rects) {
        if (!rects.length)
            return new rectangle_1.Rectangle(0, 0, 0, 0);
        var minX = Number.MAX_VALUE;
        var maxX = -Number.MAX_VALUE;
        var minY = Number.MAX_VALUE;
        var maxY = -Number.MAX_VALUE;
        rects.forEach(function (rect) {
            minX = Math.min(minX, rect.x);
            maxX = Math.max(maxX, rect.right);
            minY = Math.min(minY, rect.y);
            maxY = Math.max(maxY, rect.bottom);
        });
        return new rectangle_1.Rectangle(minX, minY, maxX - minX, maxY - minY);
    };
    GeometryUtils.findFreeSpace = function (rects, size, exact, targetRect) {
        var xs = [targetRect ? targetRect.x : 0];
        var ys = [targetRect ? targetRect.y : 0];
        rects.forEach(function (r) {
            xs.push(r.x);
            xs.push(r.right);
            ys.push(r.y);
            ys.push(r.bottom);
        });
        xs = xs.sort(function (a, b) { return a - b; }).reduce(function (acc, v, index) { return (xs[index - 1] !== v && acc.push(v) && acc) || acc; }, []);
        ys = ys.sort(function (a, b) { return a - b; }).reduce(function (acc, v, index) { return (ys[index - 1] !== v && acc.push(v) && acc) || acc; }, []);
        var matrix = ys.map(function (y) { return xs.map(function (x, i) { return xs[i + 1] - x; }); });
        var _loop_1 = function (i, rect) {
            var xi0 = search_1.SearchUtils.binaryIndexOf(xs, function (a) { return a - rect.x; });
            var xi1 = search_1.SearchUtils.binaryIndexOf(xs, function (a) { return a - rect.right; });
            var yi0 = search_1.SearchUtils.binaryIndexOf(ys, function (a) { return a - rect.y; });
            var yi1 = search_1.SearchUtils.binaryIndexOf(ys, function (a) { return a - rect.bottom; });
            for (var y = yi0; y < yi1; y++)
                for (var x = xi0; x < xi1; x++)
                    matrix[y][x] *= -1;
        };
        for (var i = 0, rect = void 0; rect = rects[i]; i++) {
            _loop_1(i, rect);
        }
        for (var yi = 0; yi < ys.length; yi++)
            for (var xi = 0; xi < xs.length - 1; xi++) {
                var checkResult = this.checkRect(matrix, ys, xs, yi, xi, size, exact);
                if (checkResult > 0)
                    xi = checkResult;
                else if (checkResult === 0)
                    return new point_1.Point(xs[xi], ys[yi]);
            }
        return null;
    };
    GeometryUtils.checkRect = function (matrix, ys, xs, yimin, ximin, size, exact) {
        var height = 0;
        var width = 0;
        var ximax = xs.length - 2;
        for (var yi = yimin; yi < ys.length; yi++) {
            height = ys[yi + 1] - ys[yimin];
            for (var xi = ximin; xi <= ximax; xi++) {
                if (matrix[yi][xi] < 0)
                    return xi === 0 ? -1 : xi;
                width = xs[xi + 1] - xs[ximin];
                if (size.width <= width || (!exact && xi === xs.length - 2 && size.width / 2 <= width)) {
                    if (size.height <= height || (!exact && yi === ys.length - 2 && size.height / 2 <= height))
                        return 0;
                    ximax = xi;
                }
            }
        }
    };
    GeometryUtils.getArrowPoints = function (point, directionPoint, arrowHeight, arrowWidth) {
        if (point.x === directionPoint.x && point.y === directionPoint.y)
            return { point1: point.clone(), point2: point.clone(), point3: point.clone() };
        var catX = directionPoint.x - point.x;
        var catY = directionPoint.y - point.y;
        var hypotenuse = Math.sqrt(Math.pow(catX, 2) + Math.pow(catY, 2));
        var cos = catX / hypotenuse;
        var sin = catY / hypotenuse;
        var x1 = point.x + arrowHeight * cos + arrowWidth * sin;
        var y1 = point.y + arrowHeight * sin - arrowWidth * cos;
        var x2 = point.x + arrowHeight * cos - arrowWidth * sin;
        var y2 = point.y + arrowHeight * sin + arrowWidth * cos;
        var x3 = point.x + arrowHeight * cos;
        var y3 = point.y + arrowHeight * sin;
        return { point1: new point_1.Point(x1, y1), point2: new point_1.Point(x2, y2), point3: new point_1.Point(x3, y3) };
    };
    GeometryUtils.createSegments = function (points) {
        var result = [];
        for (var i = 1; i < points.length; i++)
            result.push(new segment_1.Segment(points[i - 1], points[i]));
        return result;
    };
    GeometryUtils.createRectagle = function (points) {
        var xarr = points.map(function (p) { return p.x; });
        var yarr = points.map(function (p) { return p.y; });
        var minX = xarr.reduce(function (prev, cur) { return Math.min(prev, cur); }, Number.MAX_VALUE);
        var maxX = xarr.reduce(function (prev, cur) { return Math.max(prev, cur); }, -Number.MAX_VALUE);
        var minY = yarr.reduce(function (prev, cur) { return Math.min(prev, cur); }, Number.MAX_VALUE);
        var maxY = yarr.reduce(function (prev, cur) { return Math.max(prev, cur); }, -Number.MAX_VALUE);
        return new rectangle_1.Rectangle(minX, minY, maxX - minX, maxY - minY);
    };
    GeometryUtils.createSegmentsFromRectangle = function (rect) {
        var result = [];
        var topLeft = new point_1.Point(rect.x, rect.y);
        var topRight = new point_1.Point(rect.right, rect.y);
        var bottomRight = new point_1.Point(rect.right, rect.bottom);
        var bottomLeft = new point_1.Point(rect.x, rect.bottom);
        result.push(new segment_1.Segment(topLeft, topRight));
        result.push(new segment_1.Segment(topRight, bottomRight));
        result.push(new segment_1.Segment(bottomRight, bottomLeft));
        result.push(new segment_1.Segment(bottomLeft, topLeft));
        return result;
    };
    GeometryUtils.areSegmentsCutRectangle = function (segments, rect) {
        if (!rect)
            return false;
        var rectanlePolygonalChain = GeometryUtils.createSegmentsFromRectangle(rect);
        var hasSegmentIn = false;
        var hasSegmentOut = false;
        var _loop_2 = function (i) {
            if (hasSegmentIn && hasSegmentOut)
                return { value: true };
            var segment = segments[i];
            if (segment.isIntersectedByRect(rect)) {
                var startPoint_1 = segment.startPoint;
                var endPoint_1 = segment.endPoint;
                var currentContainsStart = rect.containsPoint(startPoint_1);
                var currentContainsEnd = rect.containsPoint(endPoint_1);
                if (!currentContainsStart && !currentContainsEnd)
                    return { value: true };
                if (currentContainsStart && !currentContainsEnd) {
                    var rectLinesContainsStart_1 = rectanlePolygonalChain.filter(function (s) { return s.containsPoint(startPoint_1); });
                    if (rectLinesContainsStart_1.length > 0) {
                        var otherRectSegments = rectanlePolygonalChain.filter(function (s) {
                            if (rectLinesContainsStart_1.length === 1)
                                return !s.containsPoint(rectLinesContainsStart_1[0].startPoint) && !s.containsPoint(rectLinesContainsStart_1[0].endPoint);
                            return s !== rectLinesContainsStart_1[0] && s !== rectLinesContainsStart_1[1];
                        });
                        if (otherRectSegments.some(function (s) { return segment.isIntersected(s); }) && !hasSegmentIn)
                            hasSegmentIn = true;
                    }
                    if (!hasSegmentOut)
                        hasSegmentOut = true;
                    return "continue";
                }
                if (!currentContainsStart && currentContainsEnd) {
                    if (!hasSegmentIn) {
                        hasSegmentIn = true;
                        if (hasSegmentOut)
                            hasSegmentOut = false;
                    }
                    var rectLinesContainsEnd_1 = rectanlePolygonalChain.filter(function (s) { return s.containsPoint(endPoint_1); });
                    if (rectLinesContainsEnd_1.length > 0) {
                        var otherRectSegments = rectanlePolygonalChain.filter(function (s) {
                            if (rectLinesContainsEnd_1.length === 1)
                                return !s.containsPoint(rectLinesContainsEnd_1[0].startPoint) && !s.containsPoint(rectLinesContainsEnd_1[0].endPoint);
                            return s !== rectLinesContainsEnd_1[0] && s !== rectLinesContainsEnd_1[1];
                        });
                        if (otherRectSegments.some(function (s) { return segment.isIntersected(s); }) && !hasSegmentOut)
                            hasSegmentOut = true;
                    }
                    return "continue";
                }
                var rectLinesContainsStart = rectanlePolygonalChain.filter(function (s) { return s.containsPoint(startPoint_1); });
                var rectLinesContainsEnd = rectanlePolygonalChain.filter(function (s) { return s.containsPoint(endPoint_1); });
                if (rectLinesContainsStart.length === 2 && rectLinesContainsEnd.length === 2)
                    return { value: true };
                if (rectLinesContainsStart.length === 1 && rectLinesContainsEnd.length === 1 &&
                    rectLinesContainsStart[0] !== rectLinesContainsEnd[0])
                    return { value: true };
                if (!hasSegmentOut && rectLinesContainsEnd.length === 1 && !rectLinesContainsStart.length)
                    hasSegmentOut = true;
                if (!hasSegmentIn && rectLinesContainsStart.length === 1 && !rectLinesContainsEnd.length) {
                    hasSegmentIn = true;
                    if (hasSegmentOut)
                        hasSegmentOut = false;
                }
            }
        };
        for (var i = 0; i < segments.length; i++) {
            var state_1 = _loop_2(i);
            if (typeof state_1 === "object")
                return state_1.value;
        }
        return hasSegmentIn && hasSegmentOut;
    };
    GeometryUtils.areIntersectedSegments = function (segments, otherSegments) {
        if (!otherSegments)
            return false;
        var segmentIndex = 0;
        var segment;
        while (segment = segments[segmentIndex]) {
            var otherSegmentIndex = 0;
            var otherSegment = void 0;
            while (otherSegment = otherSegments[otherSegmentIndex]) {
                if (otherSegment.isIntersected(segment))
                    return true;
                otherSegmentIndex++;
            }
            segmentIndex++;
        }
        return false;
    };
    GeometryUtils.isLineIntersected = function (beginLinePoint, endLinePoint, segment, excludeBeginPoint, excludeEndPoint) {
        var line = LineEquation.fromPoints(beginLinePoint, endLinePoint);
        var segmentStartPoint = segment.startPoint;
        var segmentEndPoint = segment.endPoint;
        if (line.containsPoint(segmentStartPoint) && line.containsPoint(segmentEndPoint))
            return !excludeBeginPoint && !excludeEndPoint;
        var segmentLine = LineEquation.fromPoints(segmentStartPoint, segmentEndPoint);
        var intersection = segmentLine.getPointIntersection(line);
        if (!intersection || !segment.containsPoint(intersection))
            return false;
        if (excludeBeginPoint)
            return !GeometryUtils.areDuplicatedPoints(segmentStartPoint, intersection);
        if (excludeEndPoint)
            return !GeometryUtils.areDuplicatedPoints(segmentEndPoint, intersection);
        return true;
    };
    GeometryUtils.removeUnnecessaryPoints = function (points, removeCallback, checkCallback, accuracy) {
        if (checkCallback === void 0) { checkCallback = function (p) { return p !== undefined; }; }
        if (accuracy === void 0) { accuracy = 0.00001; }
        this.removeUnnecessaryPointsCore(points, removeCallback, checkCallback, accuracy);
        this.removeBackwardPoints(points, removeCallback, checkCallback, accuracy);
        this.removeUnnecessaryPointsCore(points, removeCallback, checkCallback, accuracy);
    };
    GeometryUtils.removeUnnecessaryRightAnglePoints = function (points, removeCallback, checkCallback, accuracy) {
        if (checkCallback === void 0) { checkCallback = function (p) { return p !== undefined; }; }
        if (accuracy === void 0) { accuracy = 0.00001; }
        this.removeUnnecessaryPointsCore(points, removeCallback, checkCallback, accuracy);
        this.removeBackwardPoints(points, removeCallback, checkCallback, accuracy);
        this.removeNotRightAnglePoints(points, removeCallback, checkCallback, accuracy);
        this.removeUnnecessaryPointsCore(points, removeCallback, checkCallback, accuracy);
    };
    GeometryUtils.removeUnnecessaryPointsCore = function (points, removeCallback, checkCallback, accuracy) {
        if (checkCallback === void 0) { checkCallback = function (p) { return p !== undefined; }; }
        if (accuracy === void 0) { accuracy = 0.00001; }
        this.removeDuplicatedPoints(points, removeCallback, checkCallback, accuracy);
        this.removeNotCornersPoints(points, removeCallback, checkCallback, accuracy);
    };
    GeometryUtils.removeNotRightAnglePoints = function (points, removeCallback, checkCallback, accuracy) {
        if (checkCallback === void 0) { checkCallback = function (p) { return p !== undefined; }; }
        if (accuracy === void 0) { accuracy = 0.00001; }
        var index = 0;
        var point;
        while ((point = points[index]) && points.length > 2) {
            var nextPoint = this.getNextPoint(points, index, 1, checkCallback);
            var prevPoint = this.getNextPoint(points, index, -1, checkCallback);
            if (!prevPoint || !nextPoint ||
                GeometryUtils.isRightAngleCorner(prevPoint, point, nextPoint, accuracy) ||
                !removeCallback(point, index))
                index++;
        }
    };
    GeometryUtils.removeDuplicatedPoints = function (points, removeCallback, checkCallback, accuracy) {
        if (checkCallback === void 0) { checkCallback = function (p) { return p !== undefined; }; }
        if (accuracy === void 0) { accuracy = 0.00001; }
        var index = 0;
        var point;
        while ((point = points[index]) && points.length > 2) {
            var nextPoint = this.getNextPoint(points, index, 1, checkCallback);
            if (nextPoint && GeometryUtils.areDuplicatedPoints(point, nextPoint, accuracy)) {
                var actualIndex = index === points.length - 2 ? index : index + 1;
                if (removeCallback(points[actualIndex], actualIndex))
                    continue;
            }
            index++;
        }
    };
    GeometryUtils.removeNotCornersPoints = function (points, removeCallback, checkCallback, accuracy) {
        if (checkCallback === void 0) { checkCallback = function (p) { return p !== undefined; }; }
        if (accuracy === void 0) { accuracy = 0.00001; }
        var index = 0;
        var point;
        while ((point = points[index]) && points.length > 2) {
            var nextPoint = this.getNextPoint(points, index, 1, checkCallback);
            var prevPoint = this.getNextPoint(points, index, -1, checkCallback);
            if (!prevPoint || !nextPoint ||
                GeometryUtils.isCorner(prevPoint, point, nextPoint, accuracy) ||
                !removeCallback(point, index))
                index++;
        }
    };
    GeometryUtils.removeBackwardPoints = function (points, removeCallback, checkCallback, accuracy) {
        if (checkCallback === void 0) { checkCallback = function (p) { return p !== undefined; }; }
        if (accuracy === void 0) { accuracy = 0.00001; }
        var index = 0;
        var point;
        while ((point = points[index]) && points.length > 2) {
            var nextPoint = this.getNextPoint(points, index, 1, checkCallback);
            var prevPoint = this.getNextPoint(points, index, -1, checkCallback);
            if (!prevPoint || !nextPoint ||
                !GeometryUtils.isBackwardPoint(prevPoint, point, nextPoint, accuracy) ||
                !removeCallback(point, index))
                index++;
        }
    };
    GeometryUtils.isRightAngleCorner = function (prev, current, next, accuracy) {
        if (accuracy === void 0) { accuracy = 0.00001; }
        return math_1.MathUtils.numberCloseTo(GeometryUtils.createAngle(prev, current, next), Math.PI / 2.0, accuracy) ||
            math_1.MathUtils.numberCloseTo(GeometryUtils.createAngle(prev, current, next), Math.PI, accuracy) ||
            math_1.MathUtils.numberCloseTo(GeometryUtils.createAngle(prev, current, next), 3.0 * Math.PI / 2.0, accuracy);
    };
    GeometryUtils.isCorner = function (prev, current, next, accuracy) {
        if (accuracy === void 0) { accuracy = 0.00001; }
        return !math_1.MathUtils.numberCloseTo(GeometryUtils.createAngle(prev, current, next), 0, accuracy);
    };
    GeometryUtils.areDuplicatedPoints = function (current, next, accuracy) {
        if (accuracy === void 0) { accuracy = 0.00001; }
        return (math_1.MathUtils.numberCloseTo(current.x, next.x, accuracy) && math_1.MathUtils.numberCloseTo(current.y, next.y, accuracy));
    };
    GeometryUtils.isBackwardPoint = function (prev, current, next, accuracy) {
        if (accuracy === void 0) { accuracy = 0.00001; }
        return math_1.MathUtils.numberCloseTo(GeometryUtils.createAngle(prev, current, next), Math.PI, accuracy);
    };
    GeometryUtils.createAngle = function (prev, current, next) {
        var vector1 = vector_1.Vector.fromPoints(current, next);
        var vector2 = vector_1.Vector.fromPoints(prev, current);
        var vector1X = vector1.x;
        var vector1Y = vector1.y;
        var vector2X = vector2.x;
        var vector2Y = vector2.y;
        var atan = Math.atan2(vector1X * vector2Y - vector2X * vector1Y, vector1X * vector2X + vector1Y * vector2Y);
        return atan < 0 ? 2 * Math.PI + atan : atan;
    };
    GeometryUtils.getNextPoint = function (points, index, step, checkCallback) {
        var result;
        var newIndex = index + step;
        while (result = points[newIndex]) {
            if (checkCallback(result))
                return result;
            newIndex = newIndex + step;
        }
    };
    GeometryUtils.addSelectedLinesTo = function (prevPt, pt, nextPt, offsetX, offsetY, offsetXNegative, offsetYNegative, nextOffsetX, nextOffsetY, nextOffsetXNegative, nextOffsetYNegative, addSelectedLine, addSelectedLineWB, accuracy) {
        if (accuracy === void 0) { accuracy = 0.00001; }
        var a1 = pt.y - prevPt.y;
        var a2 = nextPt.y - pt.y;
        var b1 = prevPt.x - pt.x;
        var b2 = pt.x - nextPt.x;
        var det = a1 * b2 - a2 * b1;
        if (!math_1.MathUtils.numberCloseTo(det, 0, accuracy)) {
            var c1 = a1 * (prevPt.x + offsetX) + b1 * (prevPt.y + offsetY);
            var c2 = a2 * (pt.x + nextOffsetX) + b2 * (pt.y + nextOffsetY);
            addSelectedLine((b2 * c1 - b1 * c2) / det, (a1 * c2 - a2 * c1) / det);
            var c1WB = a1 * (prevPt.x + offsetXNegative) + b1 * (prevPt.y + offsetYNegative);
            var c2WB = a2 * (pt.x + nextOffsetXNegative) + b2 * (pt.y + nextOffsetYNegative);
            addSelectedLineWB((b2 * c1WB - b1 * c2WB) / det, (a1 * c2WB - a2 * c1WB) / det);
        }
    };
    GeometryUtils.getSelectionOffsetPoint = function (prev, current, distance) {
        return new point_1.Point((prev.y - current.y) / distance, (current.x - prev.x) / distance);
    };
    GeometryUtils.getSelectionTextStartEndPoints = function (prev, current, distance, center, size, align) {
        var cos = (current.x - prev.x) / distance;
        var sin = (current.y - prev.y) / distance;
        var width = size.width * cos + size.height * sin;
        switch (align) {
            case Style_1.TextAlignment.Left:
                return [center, new point_1.Point(center.x + cos * width, center.y + sin * width)];
            case Style_1.TextAlignment.Right:
                return [new point_1.Point(center.x - cos * width, center.y - sin * width), center];
            default:
                return [
                    new point_1.Point(center.x - 0.5 * cos * width, center.y - 0.5 * sin * width),
                    new point_1.Point(center.x + 0.5 * cos * width, center.y + 0.5 * sin * width)
                ];
        }
    };
    GeometryUtils.getPathLength = function (points) {
        var length = 0;
        var prevPt;
        points.forEach(function (pt) {
            if (prevPt !== undefined)
                length += metrics_1.Metrics.euclideanDistance(pt, prevPt);
            prevPt = pt;
        });
        return length;
    };
    GeometryUtils.getPathPointByPosition = function (points, relativePosition) {
        if (!points.length)
            throw new Error("Invalid points");
        if (0 > relativePosition || relativePosition > 1)
            throw new Error("Invalid relative position");
        var length = this.getPathLength(points);
        if (points.length <= 2 && length === 0 || relativePosition === 0)
            return [points[0], 0];
        var targetLength = length * relativePosition;
        var currentLength = 0;
        for (var i = 1; i < points.length; i++) {
            var lineLength = metrics_1.Metrics.euclideanDistance(points[i], points[i - 1]);
            if (currentLength + lineLength >= targetLength) {
                var delta = targetLength - currentLength;
                var cos = (points[i].x - points[i - 1].x) / lineLength;
                var sin = (points[i].y - points[i - 1].y) / lineLength;
                return [new point_1.Point(points[i - 1].x + cos * delta, points[i - 1].y + sin * delta), i];
            }
            currentLength += lineLength;
        }
        return [points[points.length - 1], points.length - 1];
    };
    GeometryUtils.getLineAngle = function (beginPoint, endPoint) {
        return Math.atan2(endPoint.y - beginPoint.y, endPoint.x - beginPoint.x);
    };
    GeometryUtils.getTriangleBeginAngle = function (beginPoint, endPoint, point) {
        var lineAngle = this.getLineAngle(beginPoint, endPoint);
        var beginPointAngle = this.getLineAngle(beginPoint, point);
        return Math.abs(beginPointAngle - lineAngle);
    };
    GeometryUtils.getTriangleEndAngle = function (beginPoint, endPoint, point) {
        var lineAngle = this.getLineAngle(beginPoint, endPoint);
        var endPointAngle = this.getLineAngle(point, endPoint);
        return Math.abs(lineAngle - endPointAngle);
    };
    GeometryUtils.getPathPointByPoint = function (points, point) {
        if (!points.length)
            throw new Error("Invalid points");
        if (points.length === 1)
            return points[0];
        var distance = Number.MAX_VALUE;
        var result;
        for (var i = 1; i < points.length; i++) {
            var beginPoint = points[i - 1];
            var endPoint = points[i];
            if (point.equals(beginPoint)) {
                result = beginPoint.clone();
                break;
            }
            if (point.equals(endPoint)) {
                result = endPoint.clone();
                break;
            }
            var beginAngle = this.getTriangleBeginAngle(beginPoint, endPoint, point);
            var endAngle = this.getTriangleEndAngle(beginPoint, endPoint, point);
            var beginDistance = metrics_1.Metrics.euclideanDistance(point, beginPoint);
            var endDistance = metrics_1.Metrics.euclideanDistance(point, endPoint);
            var orthOffset = beginDistance * Math.sin(beginAngle);
            var currentDistance = void 0;
            if (Math.PI / 2 <= beginAngle && beginAngle <= Math.PI * 3 / 2)
                currentDistance = beginDistance;
            else if (Math.PI / 2 <= endAngle && endAngle <= Math.PI * 3 / 2)
                currentDistance = endDistance;
            else
                currentDistance = Math.abs(orthOffset);
            if (currentDistance < distance) {
                distance = currentDistance;
                if (Math.PI / 2 <= beginAngle && beginAngle <= Math.PI * 3 / 2)
                    result = beginPoint.clone();
                else if (Math.PI / 2 <= endAngle && endAngle <= Math.PI * 3 / 2)
                    result = endPoint.clone();
                else {
                    var round = Math.fround || Math.round;
                    var lineAngle = this.getLineAngle(beginPoint, endPoint);
                    var offsetX = round(Math.abs(orthOffset * Math.sin(lineAngle)));
                    var offsetY = round(Math.abs(orthOffset * Math.cos(lineAngle)));
                    var isAbove = point.y - beginPoint.y < round((point.x - beginPoint.x) * Math.tan(lineAngle));
                    if (0 <= lineAngle && lineAngle <= Math.PI / 2) {
                        offsetX *= isAbove ? -1 : 1;
                        offsetY *= isAbove ? 1 : -1;
                    }
                    else if (Math.PI / 2 <= lineAngle && lineAngle <= Math.PI) {
                        offsetX *= isAbove ? 1 : -1;
                        offsetY *= isAbove ? 1 : -1;
                    }
                    else if (0 >= lineAngle && lineAngle >= -Math.PI / 2) {
                        offsetX *= isAbove ? 1 : -1;
                        offsetY *= isAbove ? 1 : -1;
                    }
                    else if (-Math.PI / 2 >= lineAngle && lineAngle >= -Math.PI) {
                        offsetX *= isAbove ? -1 : 1;
                        offsetY *= isAbove ? 1 : -1;
                    }
                    result = point.clone().offset(offsetX, offsetY);
                }
            }
        }
        return result;
    };
    GeometryUtils.getPathPositionByPoint = function (points, point, maxPositionCount) {
        if (maxPositionCount === void 0) { maxPositionCount = 100; }
        point = this.getPathPointByPoint(points, point);
        var length = this.getPathLength(points);
        var currentLength = 0;
        for (var i = 1; i < points.length; i++) {
            var beginPoint = points[i - 1];
            var endPoint = points[i];
            var lineLength = metrics_1.Metrics.euclideanDistance(endPoint, beginPoint);
            var angle = Math.atan((endPoint.y - beginPoint.y) / (endPoint.x - beginPoint.x));
            var round = Math.fround || Math.round;
            if ((point.x === endPoint.x && point.x === beginPoint.x) || (point.y === endPoint.y && point.y === beginPoint.y) ||
                round(point.y - beginPoint.y) === round((point.x - beginPoint.x) * Math.tan(angle))) {
                if (Math.sin(angle) !== 0)
                    currentLength += Math.abs((point.y - beginPoint.y) / Math.sin(angle));
                else
                    currentLength += Math.abs(point.x - beginPoint.x);
                return Math.round(currentLength * maxPositionCount / length) / maxPositionCount;
            }
            currentLength += lineLength;
        }
        return 1;
    };
    GeometryUtils.arePointsEqual = function (points1, points2) {
        var count1 = points1.length;
        var count2 = points2.length;
        if (count1 !== count2)
            return false;
        for (var i = 0; i < count1; i++)
            if (!points1[i].equals(points2[i]))
                return false;
        return true;
    };
    GeometryUtils.getMaxRectangleEnscribedInEllipse = function (ellipseSize) {
        var dx = ellipseSize.width * Math.sqrt(2) / 2;
        var dy = ellipseSize.height * Math.sqrt(2) / 2;
        return new size_1.Size(dx, dy);
    };
    GeometryUtils.getEllipseByEnscribedRectangle = function (rectSize) {
        return new size_1.Size(2 * rectSize.width / Math.sqrt(2), 2 * rectSize.height / Math.sqrt(2));
    };
    return GeometryUtils;
}());
exports.GeometryUtils = GeometryUtils;
var ObjectUtils = (function () {
    function ObjectUtils() {
    }
    ObjectUtils.cloneObject = function (source) {
        return source && Object.assign({}, source);
    };
    ObjectUtils.compareObjects = function (obj1, obj2) {
        if (obj1 === obj2)
            return true;
        if (typeof obj1 === "object" && typeof obj2 === "object")
            return this.isDeepEqual(obj1, obj2);
        return false;
    };
    ObjectUtils.isDeepEqual = function (obj1, obj2) {
        var props1 = obj1 ? Object.getOwnPropertyNames(obj1) : [];
        var props2 = obj2 ? Object.getOwnPropertyNames(obj2) : [];
        if (props1.length !== props2.length)
            return false;
        for (var i = 0; i < props1.length; i++) {
            var property = props1[i];
            switch (typeof obj1[property]) {
                case "object": {
                    if (!this.isDeepEqual(obj1[property], obj2[property]))
                        return false;
                    break;
                }
                case "number": {
                    if (!isNaN(obj1[property]) || !isNaN(obj2[property]))
                        if (obj1[property] !== obj2[property])
                            return false;
                    break;
                }
                default: {
                    if (obj1[property] !== obj2[property])
                        return false;
                }
            }
        }
        return true;
    };
    return ObjectUtils;
}());
exports.ObjectUtils = ObjectUtils;
var HtmlFocusUtils = (function () {
    function HtmlFocusUtils() {
    }
    HtmlFocusUtils.focusWithPreventScroll = function (element) {
        try {
            var isPreventScrollNotSupported = browser_1.Browser.Safari;
            var savedDocumentScrollPosition = isPreventScrollNotSupported && this.getHtmlScrollPosition();
            if (isPreventScrollNotSupported) {
                var parentPos = element.parentElement && element.parentElement.getBoundingClientRect();
                if (parentPos) {
                    var left = parentPos.left < 0 ? -parentPos.left + 1 : 0;
                    var top_1 = parentPos.top < 0 ? -parentPos.top + 1 : 0;
                    var iframePos = window.frameElement && window.frameElement.getBoundingClientRect();
                    if (iframePos) {
                        if (iframePos.top < 0 && (-iframePos.top > parentPos.top))
                            top_1 = -iframePos.top - parentPos.top + 1;
                        if (iframePos.left < 0 && (-iframePos.left > parentPos.left))
                            left = -iframePos.left - parentPos.left + 1;
                    }
                    element.style.setProperty("left", left + "px", "important");
                    element.style.setProperty("top", top_1 + "px", "important");
                }
            }
            element.focus({ preventScroll: true });
            if (isPreventScrollNotSupported) {
                var newDocumentScrollPosition = this.getHtmlScrollPosition();
                if (!ObjectUtils.compareObjects(savedDocumentScrollPosition, newDocumentScrollPosition))
                    this.setHtmlScrollPosition(savedDocumentScrollPosition);
                element.style.setProperty("left", "-1000px", "important");
                element.style.setProperty("top", "-1000px", "important");
            }
        }
        catch (e) {
        }
    };
    HtmlFocusUtils.getHtmlScrollPosition = function () {
        return {
            pos: this.getDocumentScrollPosition(window, document),
            iframePos: window.top !== window && this.getDocumentScrollPosition(window.top, window.top.document)
        };
    };
    HtmlFocusUtils.getDocumentScrollPosition = function (win, doc) {
        return {
            left: win.pageXOffset || doc.documentElement.scrollLeft || doc.body.scrollLeft,
            top: win.pageYOffset || doc.documentElement.scrollTop || doc.body.scrollTop
        };
    };
    HtmlFocusUtils.setHtmlScrollPosition = function (position) {
        this.setDocumentScrollPosition(document, position.pos);
        if (window.top !== window && position.iframePos)
            this.setDocumentScrollPosition(window.top.document, position.iframePos);
    };
    HtmlFocusUtils.setDocumentScrollPosition = function (doc, pos) {
        doc.documentElement.scrollTop = pos.top;
        doc.documentElement.scrollLeft = pos.left;
        doc.body.scrollTop = pos.top;
        doc.body.scrollLeft = pos.left;
    };
    return HtmlFocusUtils;
}());
exports.HtmlFocusUtils = HtmlFocusUtils;
var EventUtils = (function () {
    function EventUtils() {
    }
    EventUtils.isLeftButtonPressed = function (evt) {
        return evt_1.EvtUtils.isLeftButtonPressed(evt);
    };
    EventUtils.isPointerEvents = function () {
        return window.PointerEvent;
    };
    EventUtils.isMousePointer = function (evt) {
        return this.isPointerEvents() && evt.pointerType && evt.pointerType === "mouse";
    };
    EventUtils.isTouchMode = function () {
        return browser_1.Browser.TouchUI || (window.navigator && window.navigator.maxTouchPoints > 0);
    };
    EventUtils.isTouchEvent = function (evt) {
        return browser_1.Browser.TouchUI || !EventUtils.isMousePointer(evt);
    };
    return EventUtils;
}());
exports.EventUtils = EventUtils;


/***/ }),
/* 4 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.ModelUtils = void 0;
var unit_converter_1 = __webpack_require__(12);
var metrics_1 = __webpack_require__(35);
var point_1 = __webpack_require__(0);
var rectangle_1 = __webpack_require__(13);
var size_1 = __webpack_require__(2);
var vector_1 = __webpack_require__(60);
var math_1 = __webpack_require__(31);
var Enums_1 = __webpack_require__(47);
var AddConnectionHistoryItem_1 = __webpack_require__(48);
var AddConnectorHistoryItem_1 = __webpack_require__(66);
var AddConnectorPointHistoryItem_1 = __webpack_require__(188);
var AddShapeHistoryItem_1 = __webpack_require__(53);
var ChangeConnectorPointsHistoryItem_1 = __webpack_require__(86);
var ChangeShapeParametersHistoryItem_1 = __webpack_require__(112);
var DeleteConnectionHistoryItem_1 = __webpack_require__(67);
var DeleteConnectorHistoryItem_1 = __webpack_require__(113);
var DeleteShapeHistoryItem_1 = __webpack_require__(114);
var InsertToContainerHistoryItem_1 = __webpack_require__(189);
var MoveConnectorPointHistoryItem_1 = __webpack_require__(190);
var MoveShapeHistoryItem_1 = __webpack_require__(191);
var RemoveFromContainerHistoryItem_1 = __webpack_require__(192);
var ResizeShapeHistoryItem_1 = __webpack_require__(115);
var SetSelectionHistoryItem_1 = __webpack_require__(68);
var ModelResizeHistoryItem_1 = __webpack_require__(193);
var UpdatePositionsOnPageResizeHistoryItem_1 = __webpack_require__(194);
var ChangeConnectorPropertyHistoryItem_1 = __webpack_require__(88);
var ChangeConnectorTextHistoryItem_1 = __webpack_require__(69);
var ChangeCustomDataHistoryItem_1 = __webpack_require__(116);
var ChangeLockedHistoryItem_1 = __webpack_require__(117);
var ChangeStyleHistoryItem_1 = __webpack_require__(89);
var ChangeStyleTextHistoryItem_1 = __webpack_require__(70);
var Graph_1 = __webpack_require__(54);
var GraphInfo_1 = __webpack_require__(195);
var Structures_1 = __webpack_require__(38);
var Utils_1 = __webpack_require__(3);
var Connector_1 = __webpack_require__(6);
var ConnectorProperties_1 = __webpack_require__(32);
var ConnectorRenderPoint_1 = __webpack_require__(29);
var ConnectorRenderPointsContext_1 = __webpack_require__(85);
var Shape_1 = __webpack_require__(14);
var ModelUtils = (function () {
    function ModelUtils() {
    }
    ModelUtils.setShapePosition = function (history, model, shape, newPosition, includeChildren) {
        if (includeChildren === void 0) { includeChildren = true; }
        if (!shape.position.equals(newPosition)) {
            var delta_1 = newPosition.clone().offset(-shape.position.x, -shape.position.y);
            history.addAndRedo(new MoveShapeHistoryItem_1.MoveShapeHistoryItem(shape.key, newPosition));
            if (includeChildren)
                shape.children.forEach(function (child) {
                    if (child instanceof Shape_1.Shape) {
                        var childPosition = child.position.clone().offset(delta_1.x, delta_1.y);
                        ModelUtils.setShapePosition(history, model, child, childPosition);
                    }
                });
        }
    };
    ModelUtils.setShapeSize = function (history, model, shape, newPosition, newSize) {
        if (!shape.size.equals(newSize) || !shape.position.equals(newPosition))
            history.addAndRedo(new ResizeShapeHistoryItem_1.ResizeShapeHistoryItem(shape.key, newPosition, newSize));
    };
    ModelUtils.addConnectorPoint = function (history, connectorKey, pointIndex, position) {
        history.addAndRedo(new AddConnectorPointHistoryItem_1.AddConnectorPointHistoryItem(connectorKey, pointIndex, position));
    };
    ModelUtils.deleteConnectorCustomPoints = function (history, connector) {
        if (connector.points.length > 2) {
            var oldContext = connector.createRenderPointsContext();
            if (connector.properties.lineOption === ConnectorProperties_1.ConnectorLineOption.Straight || !oldContext)
                history.addAndRedo(new ChangeConnectorPointsHistoryItem_1.ReplaceConnectorPointsHistoryItem(connector.key, [
                    connector.points[0].clone(),
                    connector.points[connector.points.length - 1].clone()
                ]));
            else {
                var beginPoint = connector.points[0].clone();
                var lastPoint = connector.points[connector.points.length - 1].clone();
                history.addAndRedo(new ChangeConnectorPointsHistoryItem_1.ChangeConnectorPointsHistoryItem(connector.key, [beginPoint, lastPoint], new ConnectorRenderPointsContext_1.ConnectorRenderPointsContext([
                    new ConnectorRenderPoint_1.ConnectorRenderPoint(beginPoint.x, beginPoint.y, 0),
                    new ConnectorRenderPoint_1.ConnectorRenderPoint(lastPoint.x, lastPoint.y, 1)
                ], false, oldContext.actualRoutingMode)));
            }
        }
    };
    ModelUtils.deleteConnectorUnnecessaryPoints = function (history, connector) {
        var oldRenderPoints = connector.getRenderPoints(true).map(function (p) { return p.clone(); });
        if (connector.properties.lineOption === ConnectorProperties_1.ConnectorLineOption.Straight) {
            var unnecessaryPoints = ModelUtils.createUnnecessaryRenderPoints(oldRenderPoints.filter(function (p) { return !p.skipped; }).map(function (p) { return p.clone(); }), connector.skippedRenderPoints, function (removedPoint) { return ModelUtils.findFirstPointIndex(oldRenderPoints, function (p) { return p.equals(removedPoint); }); });
            if (Object.keys(unnecessaryPoints).length)
                history.addAndRedo(new ChangeConnectorPointsHistoryItem_1.ReplaceConnectorPointsHistoryItem(connector.key, ModelUtils.createNecessaryPoints(connector.points.map(function (p) { return p.clone(); }), unnecessaryPoints)));
        }
        else {
            var oldContext = connector.createRenderPointsContext();
            var newRenderPoints = oldRenderPoints.filter(function (p) { return !p.skipped; }).map(function (p) { return p.clone(); });
            var unnecessaryPoints = ModelUtils.createUnnecessaryRightAngleRenderPoints(newRenderPoints, connector.skippedRenderPoints, function (removedPoint) { return ModelUtils.findFirstPointIndex(oldRenderPoints, function (p) { return p.equals(removedPoint); }); });
            if (Object.keys(unnecessaryPoints).length) {
                var newPoints = ModelUtils.createNecessaryPoints(connector.points.map(function (p) { return p.clone(); }), unnecessaryPoints);
                var newRenderContext = new ConnectorRenderPointsContext_1.ConnectorRenderPointsContext(ModelUtils.validateRenderPointIndexes(newPoints, newRenderPoints, 0), oldContext.lockCreateRenderPoints, oldContext.actualRoutingMode);
                history.addAndRedo(new ChangeConnectorPointsHistoryItem_1.ChangeConnectorPointsHistoryItem(connector.key, newPoints, newRenderContext));
            }
        }
    };
    ModelUtils.skipUnnecessaryRenderPoints = function (points) {
        var clonedPoints = points.map(function (p) { return p.clone(); });
        ModelUtils.removeUnnecessaryRenderPoints(clonedPoints);
        points.forEach(function (p) { return p.skipped = clonedPoints.some(function (cp) { return cp.skipped && cp.equals(p); }); });
        points[0].skipped = false;
        points[points.length - 1].skipped = false;
    };
    ModelUtils.skipUnnecessaryRightAngleRenderPoints = function (points) {
        var clonedPoints = points.map(function (p) { return p.clone(); });
        ModelUtils.removeUnnecessaryRightAngleRenderPoints(clonedPoints);
        points.forEach(function (p) { return p.skipped = clonedPoints.some(function (cp) { return cp.skipped && cp.equals(p); }); });
        points[0].skipped = false;
        points[points.length - 1].skipped = false;
    };
    ModelUtils.removeUnnecessaryRenderPoints = function (points) {
        Utils_1.GeometryUtils.removeUnnecessaryPoints(points, function (pt, index) { return ModelUtils.removeUnnecessaryPoint(points, pt, index); }, function (pt) { return pt !== undefined && !pt.skipped; });
        points[0].skipped = false;
        points[points.length - 1].skipped = false;
    };
    ModelUtils.removeUnnecessaryRightAngleRenderPoints = function (points) {
        Utils_1.GeometryUtils.removeUnnecessaryRightAnglePoints(points, function (p, index) { return ModelUtils.removeUnnecessaryPoint(points, p, index); }, function (p) { return p !== undefined && !p.skipped; });
        points[0].skipped = false;
        points[points.length - 1].skipped = false;
    };
    ModelUtils.createUnnecessaryRenderPoints = function (renderPointsWithoutSkipped, skippedRenderPoints, getPosition, predicate) {
        if (predicate === void 0) { predicate = function (_) { return true; }; }
        var result = {};
        Utils_1.GeometryUtils.removeUnnecessaryPoints(renderPointsWithoutSkipped, function (removedPoint, removedIndex) {
            return ModelUtils.collectNotSkippedRenderPoints(result, renderPointsWithoutSkipped, removedPoint, removedIndex, getPosition, predicate);
        });
        ModelUtils.collectSkippedRenderPoints(result, skippedRenderPoints, getPosition, predicate);
        return result;
    };
    ModelUtils.createUnnecessaryRightAngleRenderPoints = function (renderPointsWithoutSkipped, skippedRenderPoints, getPosition, predicate) {
        if (predicate === void 0) { predicate = function (_) { return true; }; }
        var result = {};
        Utils_1.GeometryUtils.removeUnnecessaryRightAnglePoints(renderPointsWithoutSkipped, function (removedPoint, removedIndex) {
            return ModelUtils.collectNotSkippedRenderPoints(result, renderPointsWithoutSkipped, removedPoint, removedIndex, getPosition, predicate);
        });
        ModelUtils.collectSkippedRenderPoints(result, skippedRenderPoints, getPosition, predicate);
        return result;
    };
    ModelUtils.createNecessaryPoints = function (points, unnecessaryPoints) {
        var _this = this;
        var result = [];
        var lastPointIndex = points.length - 1;
        points.forEach(function (p, index) {
            if (index === 0 || index === lastPointIndex || _this.isNecessaryPoint(p, index, unnecessaryPoints))
                result.push(p.clone());
        });
        return result;
    };
    ModelUtils.isNecessaryPoint = function (point, pointIndex, unnecessaryPoints) {
        return !Object.keys(unnecessaryPoints).some(function (key) {
            var unnecessaryPoint = unnecessaryPoints[key];
            return unnecessaryPoint.pointIndex === pointIndex && Utils_1.GeometryUtils.areDuplicatedPoints(point, unnecessaryPoint);
        });
    };
    ModelUtils.collectSkippedRenderPoints = function (targetRenderPoints, skippedRenderPoints, getPosition, predicate) {
        if (predicate === void 0) { predicate = function (_) { return true; }; }
        skippedRenderPoints && skippedRenderPoints.forEach(function (skippedPoint) {
            if (predicate(skippedPoint)) {
                var positionIndex = getPosition(skippedPoint);
                if (targetRenderPoints[positionIndex] === undefined)
                    targetRenderPoints[positionIndex] = skippedPoint;
            }
        });
    };
    ModelUtils.collectNotSkippedRenderPoints = function (targetRenderPoints, sourceRenderPoints, removedPoint, removedIndex, getPosition, predicate) {
        if (predicate === void 0) { predicate = function (_) { return true; }; }
        if (!predicate(removedPoint))
            return false;
        var positionIndex = getPosition(removedPoint);
        if (targetRenderPoints[positionIndex] === undefined) {
            targetRenderPoints[positionIndex] = removedPoint;
            removedPoint.skipped = true;
            sourceRenderPoints.splice(removedIndex, 1);
        }
        return true;
    };
    ModelUtils.removeUnnecessaryPoint = function (points, point, removedIndex) {
        if (point.pointIndex === -1) {
            points.splice(removedIndex, 1);
            return true;
        }
        point.skipped = true;
        return false;
    };
    ModelUtils.validateRenderPointIndexes = function (points, renderPoints, startIndex) {
        var _this = this;
        var result = renderPoints.map(function (rp, i) { return new ConnectorRenderPoint_1.ConnectorRenderPoint(rp.x, rp.y, i >= startIndex && rp.pointIndex >= 0 ? _this.findFirstPointIndex(points, function (p) { return p.equals(rp); }) : rp.pointIndex, rp.skipped); });
        result[0].skipped = false;
        result[result.length - 1].skipped = false;
        return result;
    };
    ModelUtils.findFirstPointIndex = function (points, predicate) {
        if (!points || !predicate)
            return -1;
        for (var i = 0; i < points.length; i++)
            if (predicate(points[i]))
                return i;
        return -1;
    };
    ModelUtils.moveConnectorRightAnglePoints = function (history, connector, firstPoint, firstPointIndex, lastPoint, lastPointIndex) {
        if (!Utils_1.GeometryUtils.areDuplicatedPoints(connector.points[firstPointIndex], firstPoint) ||
            !Utils_1.GeometryUtils.areDuplicatedPoints(connector.points[lastPointIndex], lastPoint))
            history.addAndRedo(new MoveConnectorPointHistoryItem_1.MoveConnectorRightAnglePointsHistoryItem(connector.key, firstPointIndex, firstPoint, lastPointIndex, lastPoint));
    };
    ModelUtils.moveConnectorPoint = function (history, connector, pointIndex, newPosition) {
        if (!connector.points[pointIndex].equals(newPosition))
            history.addAndRedo(new MoveConnectorPointHistoryItem_1.MoveConnectorPointHistoryItem(connector.key, pointIndex, newPosition));
    };
    ModelUtils.updateConnectorAttachedPoints = function (history, model, connector) {
        history.beginTransaction();
        var beginContainer = connector.beginItem && model.findItemCollapsedContainer(connector.beginItem);
        var beginAttachedToContainer = beginContainer && (!connector.endItem || !model.isContainerItem(beginContainer, connector.endItem));
        var endContainer = connector.endItem && model.findItemCollapsedContainer(connector.endItem);
        var endAttachedToContainer = endContainer && (!connector.beginItem || !model.isContainerItem(endContainer, connector.beginItem));
        if (beginAttachedToContainer)
            this.updateConnectorBeginPoint(history, connector, beginContainer, (endAttachedToContainer && endContainer) || connector.endItem, function (index) { return beginContainer.getConnectionPointIndexForItem(connector.beginItem, index); });
        else
            this.updateConnectorBeginPoint(history, connector, connector.beginItem, (endAttachedToContainer && endContainer) || connector.endItem);
        if (endAttachedToContainer)
            this.updateConnectorEndPoint(history, connector, endContainer, function (index) { return endContainer.getConnectionPointIndexForItem(connector.beginItem, index); });
        else
            this.updateConnectorEndPoint(history, connector, connector.endItem);
        history.endTransaction();
    };
    ModelUtils.updateConnectorBeginPoint = function (history, connector, beginItem, endItem, getConnectionPointIndex) {
        if (beginItem) {
            var connectionPointIndex = getConnectionPointIndex !== undefined ?
                getConnectionPointIndex(connector.beginConnectionPointIndex) : connector.beginConnectionPointIndex;
            var targetPoint = connector.points[1];
            if (endItem && connector.points.length === 2)
                if (connector.endConnectionPointIndex !== -1)
                    targetPoint = endItem.getConnectionPointPosition(connector.endConnectionPointIndex, point_1.Point.zero());
                else
                    targetPoint = endItem.rectangle.center;
            var newPoint = beginItem.getConnectionPointPosition(connectionPointIndex, targetPoint);
            this.moveConnectorPoint(history, connector, 0, newPoint.clone());
        }
    };
    ModelUtils.updateConnectorEndPoint = function (history, connector, endItem, getConnectionPointIndex) {
        if (endItem) {
            var connectionPointIndex = getConnectionPointIndex !== undefined ?
                getConnectionPointIndex(connector.endConnectionPointIndex) : connector.endConnectionPointIndex;
            var newPoint = endItem.getConnectionPointPosition(connectionPointIndex, connector.points[connector.points.length - 2]);
            this.moveConnectorPoint(history, connector, connector.points.length - 1, newPoint);
        }
    };
    ModelUtils.updateContainerConnectorsAttachedPoints = function (history, model, rootContainer, container) {
        var _this = this;
        if (container === void 0) { container = rootContainer; }
        history.beginTransaction();
        var children = model.getChildren(container);
        children.forEach(function (child) {
            if (child instanceof Shape_1.Shape) {
                child.attachedConnectors.forEach(function (connector) {
                    var beginItemInContainer = connector.beginItem && model.isContainerItem(container, connector.beginItem);
                    var endItemInContainer = connector.endItem && model.isContainerItem(container, connector.endItem);
                    if (beginItemInContainer && !endItemInContainer) {
                        var collapsedContainer = model.findItemTopCollapsedContainer(connector.beginItem);
                        var endCollapsedContainer = connector.endItem && model.findItemTopCollapsedContainer(connector.endItem);
                        if (!collapsedContainer)
                            _this.updateConnectorBeginPoint(history, connector, connector.beginItem, endCollapsedContainer || connector.endItem);
                        else
                            _this.updateConnectorBeginPoint(history, connector, collapsedContainer, endCollapsedContainer || connector.endItem, function (index) { return rootContainer.getConnectionPointIndexForItem(connector.beginItem, index); });
                    }
                    if (endItemInContainer && !beginItemInContainer) {
                        var collapsedContainer = model.findItemTopCollapsedContainer(connector.endItem);
                        if (!collapsedContainer)
                            _this.updateConnectorEndPoint(history, connector, connector.endItem);
                        else
                            _this.updateConnectorEndPoint(history, connector, collapsedContainer, function (index) { return rootContainer.getConnectionPointIndexForItem(connector.endItem, index); });
                    }
                });
                _this.updateContainerConnectorsAttachedPoints(history, model, rootContainer, child);
            }
        });
        history.endTransaction();
    };
    ModelUtils.getConnectorsWithoutBeginItemInfo = function (model) {
        var connectors = model.findConnectorsWithoutBeginItem();
        return connectors.map(function (c) {
            return {
                connector: c,
                point: c.points[0].clone()
            };
        });
    };
    ModelUtils.getConnectorsWithoutEndItemInfo = function (model) {
        var connectors = model.findConnectorsWithoutEndItem();
        return connectors.map(function (c) {
            return {
                connector: c,
                point: c.points[c.points.length - 1].clone()
            };
        });
    };
    ModelUtils.updateShapeAttachedConnectors = function (history, model, shape) {
        var _this = this;
        shape.attachedConnectors.forEach(function (connector) {
            _this.removeConnectorIntermediatePoints(history, connector);
            _this.updateConnectorAttachedPoints(history, model, connector);
        });
    };
    ModelUtils.updateMovingShapeConnections = function (history, shape, beginPointsInfo, endPointsInfo, resetTargetCallback, updateTargetCallback, beforeAttachConnectorCallback) {
        var _this = this;
        resetTargetCallback();
        beginPointsInfo.forEach(function (pi) {
            var connectionPointIndex = _this.getMovingShapeConnectionPointIndex(shape, pi.point);
            if (shape.rectangle.containsPoint(pi.point) || connectionPointIndex > -1) {
                updateTargetCallback(shape, connectionPointIndex);
                if (connectionPointIndex !== pi.connector.beginConnectionPointIndex && pi.connector.beginItem)
                    history.addAndRedo(new DeleteConnectionHistoryItem_1.DeleteConnectionHistoryItem(pi.connector, Connector_1.ConnectorPosition.Begin));
                beforeAttachConnectorCallback(pi.connector);
                history.addAndRedo(new AddConnectionHistoryItem_1.AddConnectionHistoryItem(pi.connector, shape, connectionPointIndex, Connector_1.ConnectorPosition.Begin));
            }
            else if (pi.connector.beginItem) {
                history.addAndRedo(new DeleteConnectionHistoryItem_1.DeleteConnectionHistoryItem(pi.connector, Connector_1.ConnectorPosition.Begin));
                history.addAndRedo(new MoveConnectorPointHistoryItem_1.MoveConnectorPointHistoryItem(pi.connector.key, 0, pi.point));
            }
        });
        endPointsInfo.forEach(function (pi) {
            var connectionPointIndex = _this.getMovingShapeConnectionPointIndex(shape, pi.point);
            if (shape.rectangle.containsPoint(pi.point) || connectionPointIndex > -1) {
                updateTargetCallback(shape, connectionPointIndex);
                if (connectionPointIndex !== pi.connector.endConnectionPointIndex && pi.connector.endItem)
                    history.addAndRedo(new DeleteConnectionHistoryItem_1.DeleteConnectionHistoryItem(pi.connector, Connector_1.ConnectorPosition.End));
                beforeAttachConnectorCallback(pi.connector);
                history.addAndRedo(new AddConnectionHistoryItem_1.AddConnectionHistoryItem(pi.connector, shape, connectionPointIndex, Connector_1.ConnectorPosition.End));
            }
            else if (pi.connector.endItem) {
                history.addAndRedo(new DeleteConnectionHistoryItem_1.DeleteConnectionHistoryItem(pi.connector, Connector_1.ConnectorPosition.End));
                history.addAndRedo(new MoveConnectorPointHistoryItem_1.MoveConnectorPointHistoryItem(pi.connector.key, pi.connector.points.length - 1, pi.point));
            }
        });
    };
    ModelUtils.getMovingShapeConnectionPointIndex = function (shape, point) {
        var _this = this;
        var connectionPointIndex = -1;
        shape.getConnectionPoints().forEach(function (pt, index) {
            if (metrics_1.Metrics.euclideanDistance(point, pt) < _this.connectionPointActionSize)
                connectionPointIndex = index;
        });
        return connectionPointIndex;
    };
    ModelUtils.shouldRemoveConnectorIntermediatePoints = function (connector, shapes) {
        if (connector.properties.lineOption !== ConnectorProperties_1.ConnectorLineOption.Orthogonal || connector.points.length === 2 || !shapes || !shapes.length)
            return false;
        var index = 0;
        var shape;
        while (shape = shapes[index]) {
            if (this.isShapeIntersectConnectorCustomPoints(shape, connector))
                return true;
            index++;
        }
        return false;
    };
    ModelUtils.removeConnectorIntermediatePoints = function (history, connector) {
        if (this.shouldRemoveConnectorIntermediatePoints(connector, [connector.beginItem, connector.endItem]))
            this.deleteConnectorCustomPoints(history, connector);
    };
    ModelUtils.isShapeIntersectConnectorCustomPoints = function (shape, connector) {
        if (!shape)
            return false;
        var customRenderPoints = connector.getCustomRenderPoints(true);
        if (!customRenderPoints.length)
            return false;
        var offset = Connector_1.Connector.minOffset - unit_converter_1.UnitConverter.pixelsToTwips(1);
        return Utils_1.GeometryUtils.areIntersectedSegments(Utils_1.GeometryUtils.createSegments(customRenderPoints), Utils_1.GeometryUtils.createSegmentsFromRectangle(shape.rectangle.clone().inflate(offset, offset)));
    };
    ModelUtils.getSnappedPos = function (model, gridSize, pos, isHorizontal) {
        var snapOffset = isHorizontal ? model.snapStartPoint.x : model.snapStartPoint.y;
        return Math.round((pos - snapOffset) / gridSize) * gridSize + snapOffset;
    };
    ModelUtils.tryUpdateModelRectangle = function (history, processPoints) {
        var offset = history.modelManipulator.getModelSizeUpdateOffset();
        if (!offset.isEmpty()) {
            history.addAndRedo(new ModelResizeHistoryItem_1.ModelResizeHistoryItem(offset));
            if (offset.left || offset.top) {
                history.addAndRedo(new UpdatePositionsOnPageResizeHistoryItem_1.UpdatePositionsOnPageResizeHistoryItem(new vector_1.Vector(offset.left, offset.top)));
                if (processPoints !== undefined)
                    processPoints(offset.left, offset.top);
            }
            history.modelManipulator.raiseModelRectangleChanged(history.modelManipulator.model.getRectangle(true));
        }
    };
    ModelUtils.deleteItems = function (history, model, selection, items, deleteLocked) {
        history.beginTransaction();
        var itemsHash = {};
        items.forEach(function (item) { return itemsHash[item.key] = item; });
        var selectionKeys = selection.getKeys().filter(function (key) { return !itemsHash[key]; });
        history.addAndRedo(new SetSelectionHistoryItem_1.SetSelectionHistoryItem(selection, selectionKeys));
        this.deleteItemsCore(history, model, items, deleteLocked);
        this.tryUpdateModelRectangle(history);
        history.endTransaction();
    };
    ModelUtils.deleteItemsCore = function (history, model, items, deleteLocked) {
        var _this = this;
        items.sort(function (a, b) {
            var v1 = (a instanceof Connector_1.Connector) ? 0 : 1;
            var v2 = (b instanceof Connector_1.Connector) ? 0 : 1;
            return v1 - v2;
        });
        items.forEach(function (item) {
            if (item.container)
                _this.removeFromContainer(history, model, item);
            if (item instanceof Shape_1.Shape) {
                var children = model.getChildren(item);
                if (children.length) {
                    children.forEach(function (child) {
                        history.addAndRedo(new RemoveFromContainerHistoryItem_1.RemoveFromContainerHistoryItem(child));
                        _this.updateAttachedConnectorsContainer(history, model, child);
                    });
                    _this.deleteItemsCore(history, model, children.filter(function (child) { return !child.locked || deleteLocked; }), deleteLocked);
                }
                if (model.findItem(item.key))
                    _this.deleteShape(history, item);
            }
            if (item instanceof Connector_1.Connector)
                if (model.findItem(item.key))
                    _this.deleteConnector(history, item);
        });
    };
    ModelUtils.detachConnectors = function (history, shape) {
        history.beginTransaction();
        while (shape.attachedConnectors.length > 0) {
            var connector = shape.attachedConnectors[0];
            history.addAndRedo(new DeleteConnectionHistoryItem_1.DeleteConnectionHistoryItem(connector, connector.beginItem === shape ? Connector_1.ConnectorPosition.Begin : Connector_1.ConnectorPosition.End));
        }
        history.endTransaction();
    };
    ModelUtils.deleteShape = function (history, shape) {
        var allowed = history.modelManipulator.permissionsProvider.canDeleteItems([shape]);
        history.beginTransaction();
        this.detachConnectors(history, shape);
        history.addAndRedo(new DeleteShapeHistoryItem_1.DeleteShapeHistoryItem(shape.key, allowed));
        history.endTransaction();
    };
    ModelUtils.deleteConnector = function (history, connector) {
        history.beginTransaction();
        if (connector.beginItem)
            history.addAndRedo(new DeleteConnectionHistoryItem_1.DeleteConnectionHistoryItem(connector, Connector_1.ConnectorPosition.Begin));
        if (connector.endItem)
            history.addAndRedo(new DeleteConnectionHistoryItem_1.DeleteConnectionHistoryItem(connector, Connector_1.ConnectorPosition.End));
        history.addAndRedo(new DeleteConnectorHistoryItem_1.DeleteConnectorHistoryItem(connector.key));
        history.endTransaction();
    };
    ModelUtils.deleteAllItems = function (history, model, selection) {
        this.deleteItems(history, model, selection, model.items.slice(), true);
    };
    ModelUtils.deleteSelection = function (history, model, selection) {
        this.deleteItems(history, model, selection, selection.getSelectedItems());
    };
    ModelUtils.changeSelectionLocked = function (history, model, selection, locked) {
        history.beginTransaction();
        var items = selection.getSelectedItems(true);
        items.forEach(function (item) {
            history.addAndRedo(new ChangeLockedHistoryItem_1.ChangeLockedHistoryItem(item, locked));
        });
        ModelUtils.updateSelection(history, selection);
        history.endTransaction();
    };
    ModelUtils.copyStylesToItem = function (history, model, fromItem, newItemKey) {
        var toItem = model.findItem(newItemKey);
        fromItem.styleText.forEach(function (propertyName) {
            if (fromItem.styleText[propertyName] !== toItem.styleText[propertyName])
                history.addAndRedo(new ChangeStyleTextHistoryItem_1.ChangeStyleTextHistoryItem(newItemKey, propertyName, fromItem.styleText[propertyName]));
        });
        fromItem.style.forEach(function (propertyName) {
            if (fromItem.style[propertyName] !== toItem.style[propertyName])
                history.addAndRedo(new ChangeStyleHistoryItem_1.ChangeStyleHistoryItem(newItemKey, propertyName, fromItem.style[propertyName]));
        });
    };
    ModelUtils.updateSelection = function (history, selection) {
        history.addAndRedo(new SetSelectionHistoryItem_1.SetSelectionHistoryItem(selection, selection.getKeys(), true));
    };
    ModelUtils.cloneShapeToOffset = function (history, model, shape, dx, dy) {
        history.beginTransaction();
        var newPosition = shape.position.clone().offset(dx, dy);
        var addHistoryItem = new AddShapeHistoryItem_1.AddShapeHistoryItem(shape.description, newPosition, shape.text);
        history.addAndRedo(addHistoryItem);
        var newKey = addHistoryItem.shapeKey;
        history.addAndRedo(new ResizeShapeHistoryItem_1.ResizeShapeHistoryItem(newKey, newPosition, shape.size.clone()));
        history.addAndRedo(new ChangeCustomDataHistoryItem_1.ChangeCustomDataHistoryItem(newKey, Utils_1.ObjectUtils.cloneObject(shape.customData)));
        history.addAndRedo(new ChangeShapeParametersHistoryItem_1.ChangeShapeParametersHistoryItem(newKey, shape.parameters.clone()));
        this.copyStylesToItem(history, model, shape, newKey);
        history.endTransaction();
        return newKey;
    };
    ModelUtils.applyOffsetToConnectorRenderPointsContext = function (context, dx, dy) {
        return context && context.renderPoints ? new ConnectorRenderPointsContext_1.ConnectorRenderPointsContext(context.renderPoints.map(function (p) { return p.clone().offset(dx, dy); }), true, context.actualRoutingMode) : undefined;
    };
    ModelUtils.cloneConnectorToOffset = function (history, model, connector, beginItemKey, endItemKey, dx, dy) {
        history.beginTransaction();
        var newPoints = connector.points.map(function (p) { return p.clone().offset(dx, dy); });
        var addHistoryItem = new AddConnectorHistoryItem_1.AddConnectorHistoryItem(newPoints, undefined, this.applyOffsetToConnectorRenderPointsContext(connector.createRenderPointsContext(), dx, dy));
        history.addAndRedo(addHistoryItem);
        var newKey = addHistoryItem.connectorKey;
        var newConnector = model.findConnector(newKey);
        connector.properties.forEach(function (propertyName) {
            if (connector.properties[propertyName] !== newConnector.properties[propertyName])
                history.addAndRedo(new ChangeConnectorPropertyHistoryItem_1.ChangeConnectorPropertyHistoryItem(newKey, propertyName, connector.properties[propertyName]));
        });
        if (beginItemKey) {
            var from = model.findShape(beginItemKey);
            history.addAndRedo(new AddConnectionHistoryItem_1.AddConnectionHistoryItem(newConnector, from, connector.beginConnectionPointIndex, Connector_1.ConnectorPosition.Begin));
        }
        if (endItemKey) {
            var to = model.findShape(endItemKey);
            history.addAndRedo(new AddConnectionHistoryItem_1.AddConnectionHistoryItem(newConnector, to, connector.endConnectionPointIndex, Connector_1.ConnectorPosition.End));
        }
        var newTexts = connector.texts.clone();
        newTexts.forEach(function (connectorText) {
            history.addAndRedo(new ChangeConnectorTextHistoryItem_1.ChangeConnectorTextHistoryItem(newConnector, connectorText.position, connectorText.value));
        });
        this.copyStylesToItem(history, model, connector, newKey);
        history.endTransaction();
        return newKey;
    };
    ModelUtils.cloneSelectionToOffset = function (history, model, onItemAdded, selection, dx, dy) {
        var _this = this;
        history.beginTransaction();
        var newShapes = {};
        var ids = [];
        selection.getSelectedShapes().forEach(function (shape) {
            var newKey = _this.cloneShapeToOffset(history, model, shape, dx, dy);
            newShapes[shape.key] = newKey;
            ids.push(newKey);
            if (onItemAdded)
                onItemAdded(newKey);
        });
        selection.getSelectedConnectors().forEach(function (connector) {
            var beginItemKey = connector.beginItem ? newShapes[connector.beginItem.key] : null;
            var endItemKey = connector.endItem ? newShapes[connector.endItem.key] : null;
            var newKey = _this.cloneConnectorToOffset(history, model, connector, beginItemKey, endItemKey, dx, dy);
            ids.push(newKey);
            if (onItemAdded)
                onItemAdded(newKey);
        });
        history.addAndRedo(new SetSelectionHistoryItem_1.SetSelectionHistoryItem(selection, ids));
        ModelUtils.tryUpdateModelRectangle(history);
        history.endTransaction();
    };
    ModelUtils.findContainerByEventKey = function (model, selection, key) {
        var container = model.findContainer(key);
        if (container && !container.isLocked)
            return container;
        else {
            var shape = model.findShape(key);
            if (shape && shape.container && !selection.hasKey(shape.key))
                return ModelUtils.findContainerByEventKey(model, selection, shape.container.key);
        }
    };
    ModelUtils.canInsertToContainer = function (model, item, container) {
        if (item === container)
            return false;
        if (item instanceof Shape_1.Shape)
            if (model.findChild(item, container.key))
                return false;
        return true;
    };
    ModelUtils.canInsertSelectionToContainer = function (model, selection, container) {
        var result = true;
        selection.getSelectedItems().forEach(function (item) {
            if (item === container) {
                result = false;
                return;
            }
            if (item instanceof Shape_1.Shape)
                if (model.findChild(item, container.key)) {
                    result = false;
                    return;
                }
        });
        return result;
    };
    ModelUtils.insertToContainer = function (history, model, item, container) {
        if (!container.enableChildren)
            throw Error("Inpossible to add children to non-container shape.");
        if (!this.canInsertToContainer(model, item, container))
            return;
        var oldContainer = item.container;
        if (oldContainer !== container) {
            history.beginTransaction();
            if (oldContainer) {
                history.addAndRedo(new RemoveFromContainerHistoryItem_1.RemoveFromContainerHistoryItem(item));
                item.attachedConnectors.forEach(function (connector) {
                    if (connector.container)
                        history.addAndRedo(new RemoveFromContainerHistoryItem_1.RemoveFromContainerHistoryItem(connector));
                });
            }
            history.addAndRedo(new InsertToContainerHistoryItem_1.InsertToContainerHistoryItem(item, container));
            this.updateAttachedConnectorsContainer(history, model, item);
            history.endTransaction();
        }
    };
    ModelUtils.removeFromContainer = function (history, model, item) {
        if (item.container) {
            history.beginTransaction();
            history.addAndRedo(new RemoveFromContainerHistoryItem_1.RemoveFromContainerHistoryItem(item));
            this.updateAttachedConnectorsContainer(history, model, item);
            history.endTransaction();
        }
    };
    ModelUtils.insertSelectionToContainer = function (history, model, selection, container) {
        var _this = this;
        history.beginTransaction();
        var selectedItems = selection.getSelectedItems();
        var items = selectedItems.filter(function (item) { return !item.container || selectedItems.indexOf(item.container) === -1; });
        items.forEach(function (item) {
            _this.insertToContainer(history, model, item, container);
        });
        history.endTransaction();
    };
    ModelUtils.removeSelectionFromContainer = function (history, model, selection) {
        var _this = this;
        history.beginTransaction();
        selection.getSelectedItems().forEach(function (item) {
            if (item.container && !selection.hasKey(item.container.key)) {
                history.addAndRedo(new RemoveFromContainerHistoryItem_1.RemoveFromContainerHistoryItem(item));
                _this.updateAttachedConnectorsContainer(history, model, item);
            }
        });
        history.endTransaction();
    };
    ModelUtils.getConnectorContainer = function (connector) {
        if (connector.beginItem && connector.endItem) {
            var beginItemContainers = {};
            var containerForBeginItem = connector.beginItem.container;
            while (containerForBeginItem) {
                beginItemContainers[containerForBeginItem.key] = true;
                containerForBeginItem = containerForBeginItem.container;
            }
            var containerForEndItem = connector.endItem.container;
            while (containerForEndItem) {
                if (beginItemContainers[containerForEndItem.key] !== undefined)
                    return containerForEndItem;
                containerForEndItem = containerForEndItem.container;
            }
        }
    };
    ModelUtils.updateAttachedConnectorsContainer = function (history, model, item) {
        var _this = this;
        history.beginTransaction();
        item.attachedConnectors.forEach(function (connector) {
            _this.updateConnectorContainer(history, model, connector);
        });
        history.endTransaction();
    };
    ModelUtils.updateConnectorContainer = function (history, model, connector) {
        var container = this.getConnectorContainer(connector);
        if (container)
            history.addAndRedo(new InsertToContainerHistoryItem_1.InsertToContainerHistoryItem(connector, container));
        else if (connector.container)
            history.addAndRedo(new RemoveFromContainerHistoryItem_1.RemoveFromContainerHistoryItem(connector));
    };
    ModelUtils.updateNewShapeProperties = function (history, selection, itemKey) {
        var style = selection.inputPosition.getDefaultStyle();
        style.forEach(function (propertyName) {
            history.addAndRedo(new ChangeStyleHistoryItem_1.ChangeStyleHistoryItem(itemKey, propertyName, selection.inputPosition.getDefaultStylePropertyValue(propertyName)));
        });
        var textStyle = selection.inputPosition.getDefaultTextStyle();
        textStyle.forEach(function (propertyName) {
            history.addAndRedo(new ChangeStyleTextHistoryItem_1.ChangeStyleTextHistoryItem(itemKey, propertyName, selection.inputPosition.getDefaultTextStylePropertyValue(propertyName)));
        });
    };
    ModelUtils.updateNewConnectorProperties = function (history, selection, itemKey) {
        var connectorProperties = selection.inputPosition.getDefaultConnectorProperties();
        connectorProperties.forEach(function (propertyName) {
            history.addAndRedo(new ChangeConnectorPropertyHistoryItem_1.ChangeConnectorPropertyHistoryItem(itemKey, propertyName, selection.inputPosition.getDefaultConnectorPropertyValue(propertyName)));
        });
        var style = selection.inputPosition.getDefaultStyle();
        style.forEach(function (propertyName) {
            history.addAndRedo(new ChangeStyleHistoryItem_1.ChangeStyleHistoryItem(itemKey, propertyName, selection.inputPosition.getDefaultStylePropertyValue(propertyName)));
        });
        var textStyle = selection.inputPosition.getDefaultTextStyle();
        textStyle.forEach(function (propertyName) {
            history.addAndRedo(new ChangeStyleTextHistoryItem_1.ChangeStyleTextHistoryItem(itemKey, propertyName, selection.inputPosition.getDefaultTextStylePropertyValue(propertyName)));
        });
    };
    ModelUtils.applyLayout = function (history, model, container, graph, layout, nonGraphItems, settings, snapToGrid, gridSize, skipPointIndices) {
        history.beginTransaction();
        var occupiedRectangles = this.getOccupiedRectangles(nonGraphItems, container);
        layout = this.offsetLayoutToFreeSpace(layout, container && container.clientRectangle, occupiedRectangles, settings.containerPadding);
        if (snapToGrid)
            this.adjustLayoutToSnapGrid(model, layout, gridSize);
        if (container)
            this.resizeContainerOnLayout(history, model, layout, container, settings.containerPadding);
        this.applyLayoutToNodes(history, model, layout, graph.edges.map(function (e) { return model.findConnector(e.key); }));
        this.applyLayoutToConnectors(history, model, layout, graph.edges.map(function (e) { return model.findConnector(e.key); }), skipPointIndices);
        history.endTransaction();
        return layout.getRectangle(true);
    };
    ModelUtils.getNonGraphItems = function (model, container, nodeKeyMap, shapes, connectors) {
        var allItems = container ? model.getChildren(container) : model.items.filter(function (item) { return !item.container; });
        return allItems.filter(function (item) {
            if (item instanceof Connector_1.Connector)
                return (!item.beginItem || !nodeKeyMap[item.beginItem.key]) && (!item.endItem || !nodeKeyMap[item.endItem.key]) &&
                    connectors.indexOf(item) === -1;
            if (item instanceof Shape_1.Shape)
                return !nodeKeyMap[item.key] &&
                    shapes.indexOf(item) === -1;
        });
    };
    ModelUtils.getOccupiedRectangles = function (nonGraphItems, container) {
        var occupiedRectangles = nonGraphItems.map(function (i) { return i.rectangle; });
        if (container && occupiedRectangles.length) {
            var rect = container.clientRectangle;
            occupiedRectangles.push(new rectangle_1.Rectangle(rect.right, rect.y, 1, 1));
            occupiedRectangles.push(new rectangle_1.Rectangle(rect.right, rect.bottom, 1, 1));
        }
        return occupiedRectangles;
    };
    ModelUtils.offsetLayoutToFreeSpace = function (layout, containerRect, occupiedRectangles, spacing) {
        var graphItemRect = layout.getRectangle(true);
        var freePoint = Utils_1.GeometryUtils.findFreeSpace(occupiedRectangles, graphItemRect.createSize().offset(spacing, spacing).nonNegativeSize(), false, containerRect);
        if (freePoint) {
            var x = freePoint.x + spacing;
            var y = freePoint.y + spacing;
            return layout.offsetNodes(x, y);
        }
        var maxX = occupiedRectangles && occupiedRectangles.length ?
            occupiedRectangles.reduce(function (max, rect) { return rect.right > max ? rect.right : max; }, 0) :
            (containerRect ? containerRect.x : 0);
        var minY = containerRect ? containerRect.y : Math.max(0, graphItemRect.y);
        return layout.offsetNodes(maxX + spacing, minY + spacing);
    };
    ModelUtils.resizeContainerOnLayout = function (history, model, layout, container, spacing) {
        var layoutRect = layout.getRectangle(true);
        var nonLayoutRectangles = container.children
            .filter(function (item) {
            if (item instanceof Shape_1.Shape)
                return layout.nodeKeys.indexOf(item.key) === -1;
            if (item instanceof Connector_1.Connector && item.beginItem && item.endItem)
                return layout.nodeKeys.indexOf(item.beginItem.key) === -1 && layout.nodeKeys.indexOf(item.endItem.key) === -1;
            return false;
        })
            .map(function (item) { return item.rectangle; });
        var right = nonLayoutRectangles.map(function (rect) { return rect.right; }).reduce(function (prev, cur) { return Math.max(prev, cur); }, layoutRect.right);
        var bottom = nonLayoutRectangles.map(function (rect) { return rect.bottom; }).reduce(function (prev, cur) { return Math.max(prev, cur); }, layoutRect.bottom);
        var width = container.rectangle.width + right + spacing - container.rectangle.right;
        var height = container.rectangle.height + bottom + spacing - container.rectangle.bottom;
        ModelUtils.setShapeSize(history, model, container, container.position, new size_1.Size(width, height));
        ModelUtils.updateShapeAttachedConnectors(history, model, container);
    };
    ModelUtils.applyLayoutToNodes = function (history, model, layout, connectors) {
        var _this = this;
        var connectorsSet = connectors.reduce(function (acc, c) { return acc[c.key] =  true && acc; }, {});
        layout.forEachNode(function (nl, nk) {
            var shape = model.findShape(nk);
            _this.applyLayoutToNode(history, model, shape, nl.position, connectorsSet);
        });
    };
    ModelUtils.applyLayoutToNode = function (history, model, shape, position, connectorsSet) {
        var _this = this;
        var delta = position.clone().offset(-shape.position.x, -shape.position.y);
        ModelUtils.setShapePosition(history, model, shape, position, false);
        if (delta.x !== 0 || delta.y !== 0) {
            shape.attachedConnectors
                .filter(function (c) { return !connectorsSet[c.key]; })
                .forEach(function (connector) {
                _this.updateConnectorAttachedPoints(history, model, connector);
                var beginPointIndex = connector.beginItem ? 1 : 0;
                var endPointIndex = connector.endItem ? (connector.points.length - 2) : (connector.points.length - 1);
                for (var i = beginPointIndex; i <= endPointIndex; i++)
                    _this.moveConnectorPoint(history, connector, i, connector.points[i].offset(delta.x, delta.y));
            });
            model.getChildren(shape).forEach(function (child) {
                if (child instanceof Shape_1.Shape) {
                    var childPosition = child.position.clone().offset(delta.x, delta.y);
                    _this.applyLayoutToNode(history, model, child, childPosition, connectorsSet);
                }
            });
        }
    };
    ModelUtils.applyLayoutToConnectors = function (history, model, layout, connectors, skipPointIndices) {
        var _this = this;
        connectors.filter(function (c) { return c.beginItem || c.endItem; }).forEach(function (connector) {
            var edgeLayout = layout.edgeToPosition[connector.key];
            if (connector.beginItem && connector.endItem && !skipPointIndices && edgeLayout) {
                var beginIndex = connector.beginItem.getConnectionPointIndexForSide(edgeLayout.beginIndex);
                if (beginIndex !== connector.beginConnectionPointIndex)
                    history.addAndRedo(new AddConnectionHistoryItem_1.SetConnectionPointIndexHistoryItem(connector, beginIndex, Connector_1.ConnectorPosition.Begin));
                var endIndex = connector.endItem.getConnectionPointIndexForSide(edgeLayout.endIndex);
                if (endIndex !== connector.endConnectionPointIndex)
                    history.addAndRedo(new AddConnectionHistoryItem_1.SetConnectionPointIndexHistoryItem(connector, endIndex, Connector_1.ConnectorPosition.End));
            }
            _this.updateConnectorAttachedPoints(history, model, connector);
            if (edgeLayout)
                _this.deleteConnectorCustomPoints(history, connector);
        });
    };
    ModelUtils.adjustLayoutToSnapGrid = function (model, layout, gridSize) {
        var _this = this;
        layout.nodeKeys.forEach(function (key) {
            layout.nodeToLayout[key].position.x = _this.getSnappedPos(model, gridSize, layout.nodeToLayout[key].position.x, true);
            layout.nodeToLayout[key].position.y = _this.getSnappedPos(model, gridSize, layout.nodeToLayout[key].position.y, false);
        });
    };
    ModelUtils.getGraphInfoByItems = function (model, shapes, connectors, isDatabinding) {
        if (isDatabinding === void 0) { isDatabinding = true; }
        var itemsByContainerKey = {};
        var items = [].concat(shapes).concat(connectors);
        items.forEach(function (item) {
            var containerKey = item.container && item.container.key;
            if (!itemsByContainerKey[containerKey])
                itemsByContainerKey[containerKey] = [];
            itemsByContainerKey[containerKey].push(item);
        });
        var result = [];
        for (var key in itemsByContainerKey) {
            if (!Object.prototype.hasOwnProperty.call(itemsByContainerKey, key))
                continue;
            var container = key && model.findContainer(key);
            if (!container || (container.expanded && !model.findItemCollapsedContainer(container))) {
                var containerKey = container && container.key;
                var graph = this.getGraphByItems(model, itemsByContainerKey[key], containerKey, !isDatabinding);
                var allowCreateInfo = false;
                if (graph.nodes.length > 1)
                    allowCreateInfo = true;
                else if (graph.nodes.length)
                    if (isDatabinding)
                        allowCreateInfo = true;
                    else if (container && itemsByContainerKey[container.container && container.container.key])
                        allowCreateInfo = true;
                if (allowCreateInfo)
                    result.push(new GraphInfo_1.GraphInfo(container, graph));
            }
        }
        return result.sort(function (a, b) { return b.level - a.level; });
    };
    ModelUtils.getGraphByItems = function (model, items, containerKey, skipLocked) {
        var _this = this;
        var graph = new Graph_1.Graph([], []);
        var knownIds = {};
        items.forEach(function (item) {
            _this.extendByConnectedComponents(item, graph, containerKey, knownIds, skipLocked);
        });
        graph.nodes.sort(function (a, b) { return model.getItemIndex(model.findItem(a)) - model.getItemIndex(model.findItem(b)); });
        graph.edges.sort(function (a, b) { return model.getItemIndex(model.findItem(a.key)) - model.getItemIndex(model.findItem(b.key)); });
        graph.edges = graph.edges.filter(function (e) { return graph.getNode(e.from) && graph.getNode(e.to); });
        return graph;
    };
    ModelUtils.extendByConnectedComponents = function (item, graph, containerKey, knownIds, skipLocked) {
        var _this = this;
        if (!item || (skipLocked && item.locked) || knownIds[item.key])
            return;
        knownIds[item.key] = true;
        if (item instanceof Connector_1.Connector && (item.container && item.container.key) === containerKey &&
            item.beginItem && (!item.beginItem.locked || !skipLocked) && item.endItem && (!item.endItem.locked || !skipLocked) &&
            item.beginItem !== item.endItem) {
            graph.addEdge(new Structures_1.Edge(item.key, item.beginItem && item.beginItem.key, item.endItem && item.endItem.key));
            this.extendByConnectedComponents(item.beginItem, graph, containerKey, knownIds, skipLocked);
            this.extendByConnectedComponents(item.endItem, graph, containerKey, knownIds, skipLocked);
        }
        else if (item instanceof Shape_1.Shape && (item.container && item.container.key) === containerKey) {
            graph.addNode(item);
            item.attachedConnectors.forEach(function (c) { return _this.extendByConnectedComponents(c, graph, containerKey, knownIds, skipLocked); });
        }
    };
    ModelUtils.getlUnitValue = function (units, twipsValue) {
        switch (units) {
            case Enums_1.DiagramUnit.Cm:
                return unit_converter_1.UnitConverter.twipsToCentimeters(twipsValue);
            case Enums_1.DiagramUnit.In:
                return unit_converter_1.UnitConverter.twipsToInches(twipsValue);
            case Enums_1.DiagramUnit.Px:
                return unit_converter_1.UnitConverter.twipsToPixels(twipsValue);
        }
    };
    ModelUtils.getUnitText = function (units, unitItems, formatUnit, twipsValue, fractionDigits) {
        if (fractionDigits === void 0) { fractionDigits = 2; }
        var unitItemText = unitItems[units] ? " " + unitItems[units] : "";
        var unitValue = this.getlUnitValue(units, twipsValue);
        switch (units) {
            case Enums_1.DiagramUnit.Cm:
                return formatUnit(+unitValue.toFixed(fractionDigits)) + unitItemText;
            case Enums_1.DiagramUnit.In:
                return formatUnit(+unitValue.toFixed(fractionDigits)) + unitItemText;
            case Enums_1.DiagramUnit.Px:
                return formatUnit(+unitValue.toFixed(0)) + unitItemText;
        }
    };
    ModelUtils.getTwipsValue = function (units, value) {
        switch (units) {
            case Enums_1.DiagramUnit.Cm:
                return unit_converter_1.UnitConverter.centimetersToTwips(value);
            case Enums_1.DiagramUnit.In:
                return unit_converter_1.UnitConverter.inchesToTwips(value);
            case Enums_1.DiagramUnit.Px:
                return unit_converter_1.UnitConverter.pixelsToTwips(value);
        }
    };
    ModelUtils.getGuidItemKey = function () {
        return math_1.MathUtils.generateGuid();
    };
    ModelUtils.createSelectedItems = function (selection) {
        var result = {};
        selection.getSelectedItems(true).forEach(function (i) { return result[i.key] = i; });
        return result;
    };
    ModelUtils.canMoveConnector = function (selectedItems, connector) {
        var beginItem = connector.beginItem;
        var endItem = connector.endItem;
        if (!beginItem && !endItem)
            return !connector.isLocked;
        if (!selectedItems[connector.key])
            return false;
        if (beginItem === endItem)
            return !!selectedItems[beginItem.key];
        if (!beginItem)
            return !!selectedItems[endItem.key];
        if (!endItem)
            return !!selectedItems[beginItem.key];
        return !!selectedItems[beginItem.key] && !!selectedItems[endItem.key];
    };
    ModelUtils.createRectangle = function (items) {
        return Utils_1.GeometryUtils.getCommonRectangle(items.map(function (i) { return i.rectangle; }));
    };
    ModelUtils.connectionPointActionSize = unit_converter_1.UnitConverter.pixelsToTwips(8);
    return ModelUtils;
}());
exports.ModelUtils = ModelUtils;


/***/ }),
/* 5 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.PathPrimitiveClosePathCommand = exports.PathPrimitiveArcToCommand = exports.PathPrimitiveQuadraticCurveToCommand = exports.PathPrimitiveCubicCurveToCommand = exports.PathPrimitiveLineToCommand = exports.PathPrimitiveMoveToCommand = exports.PathPrimitiveCommand = exports.PathPrimitive = void 0;
var RenderHelper_1 = __webpack_require__(15);
var Primitive_1 = __webpack_require__(24);
var PrimitiveObject_1 = __webpack_require__(109);
var PathPrimitive = (function (_super) {
    __extends(PathPrimitive, _super);
    function PathPrimitive(commands, style, className, clipPathId, onApplyProperties) {
        var _this = _super.call(this, style, className, clipPathId, onApplyProperties) || this;
        _this.commands = commands.map(function (command) {
            command.style = style;
            return command;
        });
        return _this;
    }
    PathPrimitive.prototype.createMainElement = function () {
        return document.createElementNS(RenderHelper_1.svgNS, "path");
    };
    PathPrimitive.prototype.applyElementProperties = function (element, measurer) {
        element.setAttribute("d", this.commands.map(function (c) { return c.toString(); }).join(" "));
        this.setPositionCorrectionAttribute(element);
        _super.prototype.applyElementProperties.call(this, element, measurer);
    };
    return PathPrimitive;
}(Primitive_1.SvgPrimitive));
exports.PathPrimitive = PathPrimitive;
var PathPrimitiveCommand = (function (_super) {
    __extends(PathPrimitiveCommand, _super);
    function PathPrimitiveCommand() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    return PathPrimitiveCommand;
}(PrimitiveObject_1.PrimitiveObject));
exports.PathPrimitiveCommand = PathPrimitiveCommand;
var PathPrimitiveMoveToCommand = (function (_super) {
    __extends(PathPrimitiveMoveToCommand, _super);
    function PathPrimitiveMoveToCommand(x, y) {
        var _this = _super.call(this) || this;
        _this.x = x;
        _this.y = y;
        return _this;
    }
    PathPrimitiveMoveToCommand.prototype.toString = function () {
        return "M " + this.getUnitVaue(this.x) + " " + this.getUnitVaue(this.y);
    };
    PathPrimitiveMoveToCommand.fromPoint = function (point) {
        return new PathPrimitiveMoveToCommand(point.x, point.y);
    };
    return PathPrimitiveMoveToCommand;
}(PathPrimitiveCommand));
exports.PathPrimitiveMoveToCommand = PathPrimitiveMoveToCommand;
var PathPrimitiveLineToCommand = (function (_super) {
    __extends(PathPrimitiveLineToCommand, _super);
    function PathPrimitiveLineToCommand(x, y) {
        var _this = _super.call(this) || this;
        _this.x = x;
        _this.y = y;
        return _this;
    }
    PathPrimitiveLineToCommand.prototype.toString = function () {
        return "L " + this.getUnitVaue(this.x) + " " + this.getUnitVaue(this.y);
    };
    PathPrimitiveLineToCommand.fromPoint = function (point) {
        return new PathPrimitiveLineToCommand(point.x, point.y);
    };
    return PathPrimitiveLineToCommand;
}(PathPrimitiveCommand));
exports.PathPrimitiveLineToCommand = PathPrimitiveLineToCommand;
var PathPrimitiveCubicCurveToCommand = (function (_super) {
    __extends(PathPrimitiveCubicCurveToCommand, _super);
    function PathPrimitiveCubicCurveToCommand(x1, y1, x2, y2, x3, y3) {
        var _this = _super.call(this) || this;
        _this.x1 = x1;
        _this.y1 = y1;
        _this.x2 = x2;
        _this.y2 = y2;
        _this.x3 = x3;
        _this.y3 = y3;
        return _this;
    }
    PathPrimitiveCubicCurveToCommand.prototype.toString = function () {
        return "C " + this.getUnitVaue(this.x1) + " " + this.getUnitVaue(this.y1) + "," +
            this.getUnitVaue(this.x2) + " " + this.getUnitVaue(this.y2) + "," +
            this.getUnitVaue(this.x3) + " " + this.getUnitVaue(this.y3);
    };
    return PathPrimitiveCubicCurveToCommand;
}(PathPrimitiveCommand));
exports.PathPrimitiveCubicCurveToCommand = PathPrimitiveCubicCurveToCommand;
var PathPrimitiveQuadraticCurveToCommand = (function (_super) {
    __extends(PathPrimitiveQuadraticCurveToCommand, _super);
    function PathPrimitiveQuadraticCurveToCommand(x1, y1, x2, y2) {
        var _this = _super.call(this) || this;
        _this.x1 = x1;
        _this.y1 = y1;
        _this.x2 = x2;
        _this.y2 = y2;
        return _this;
    }
    PathPrimitiveQuadraticCurveToCommand.prototype.toString = function () {
        return "Q " + this.getUnitVaue(this.x1) + " " + this.getUnitVaue(this.y1) + "," +
            this.getUnitVaue(this.x2) + " " + this.getUnitVaue(this.y2);
    };
    return PathPrimitiveQuadraticCurveToCommand;
}(PathPrimitiveCommand));
exports.PathPrimitiveQuadraticCurveToCommand = PathPrimitiveQuadraticCurveToCommand;
var PathPrimitiveArcToCommand = (function (_super) {
    __extends(PathPrimitiveArcToCommand, _super);
    function PathPrimitiveArcToCommand(rx, ry, xAxisRotation, largeArcFlag, sweepFag, x, y) {
        var _this = _super.call(this) || this;
        _this.rx = rx;
        _this.ry = ry;
        _this.xAxisRotation = xAxisRotation;
        _this.largeArcFlag = largeArcFlag;
        _this.sweepFag = sweepFag;
        _this.x = x;
        _this.y = y;
        return _this;
    }
    PathPrimitiveArcToCommand.prototype.toString = function () {
        return "A " + this.getUnitVaue(this.rx) + " " + this.getUnitVaue(this.ry) + " " +
            this.getUnitVaue(this.xAxisRotation) + " " +
            (this.largeArcFlag ? "1" : "0") + " " + (this.sweepFag ? "1" : "0") +
            this.getUnitVaue(this.x) + "," + this.getUnitVaue(this.y);
    };
    return PathPrimitiveArcToCommand;
}(PathPrimitiveCommand));
exports.PathPrimitiveArcToCommand = PathPrimitiveArcToCommand;
var PathPrimitiveClosePathCommand = (function (_super) {
    __extends(PathPrimitiveClosePathCommand, _super);
    function PathPrimitiveClosePathCommand() {
        return _super.call(this) || this;
    }
    PathPrimitiveClosePathCommand.prototype.toString = function () {
        return "z";
    };
    return PathPrimitiveClosePathCommand;
}(PathPrimitiveCommand));
exports.PathPrimitiveClosePathCommand = PathPrimitiveClosePathCommand;


/***/ }),
/* 6 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.Connector = exports.CONNECTOR_DEFAULT_TEXT_POSITION = exports.ConnectorPosition = void 0;
var unit_converter_1 = __webpack_require__(12);
var rectangle_1 = __webpack_require__(13);
var segment_1 = __webpack_require__(33);
var size_1 = __webpack_require__(2);
var CanvasManagerBase_1 = __webpack_require__(42);
var NativeItem_1 = __webpack_require__(84);
var Event_1 = __webpack_require__(11);
var ITextMeasurer_1 = __webpack_require__(43);
var PathPrimitive_1 = __webpack_require__(5);
var TextPrimitive_1 = __webpack_require__(63);
var Utils_1 = __webpack_require__(17);
var Settings_1 = __webpack_require__(28);
var Utils_2 = __webpack_require__(3);
var DiagramItem_1 = __webpack_require__(9);
var ModelUtils_1 = __webpack_require__(4);
var ConnectorPointsCalculator_1 = __webpack_require__(179);
var ConnectorPointsOrthogonalCalculator_1 = __webpack_require__(180);
var ConnectorLineEndingStrategies_1 = __webpack_require__(186);
var ConnectorProperties_1 = __webpack_require__(32);
var ConnectorTexts_1 = __webpack_require__(187);
var ConnectorRenderPointsContext_1 = __webpack_require__(85);
var ConnectorPosition;
(function (ConnectorPosition) {
    ConnectorPosition[ConnectorPosition["Begin"] = 0] = "Begin";
    ConnectorPosition[ConnectorPosition["End"] = 1] = "End";
})(ConnectorPosition = exports.ConnectorPosition || (exports.ConnectorPosition = {}));
exports.CONNECTOR_DEFAULT_TEXT_POSITION = 0.5;
var Connector = (function (_super) {
    __extends(Connector, _super);
    function Connector(points) {
        var _this = _super.call(this) || this;
        _this.beginConnectionPointIndex = -1;
        _this.endConnectionPointIndex = -1;
        _this.properties = new ConnectorProperties_1.ConnectorProperties();
        _this.points = points.map(function (pt) { return pt.clone(); });
        if (points.length < 2)
            throw Error("Points count should be greater than 1");
        _this.texts = new ConnectorTexts_1.ConnectorTexts();
        return _this;
    }
    Object.defineProperty(Connector.prototype, "rectangle", {
        get: function () {
            return Utils_2.GeometryUtils.createRectagle(this.getRenderPoints(true));
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(Connector.prototype, "skippedRenderPoints", {
        get: function () {
            return this.renderPoints ? this.renderPoints.filter(function (p) { return p.skipped; }) : undefined;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(Connector.prototype, "shouldChangeRenderPoints", {
        get: function () {
            return this.renderPoints !== undefined && this.routingStrategy !== undefined;
        },
        enumerable: false,
        configurable: true
    });
    Connector.prototype.assign = function (item) {
        _super.prototype.assign.call(this, item);
        item.beginItem = this.beginItem;
        item.beginConnectionPointIndex = this.beginConnectionPointIndex;
        item.endItem = this.endItem;
        item.endConnectionPointIndex = this.endConnectionPointIndex;
        item.properties = this.properties.clone();
        item.texts = this.texts.clone();
        if (this.routingStrategy !== undefined)
            item.routingStrategy = this.routingStrategy.clone();
        if (this.renderPoints !== undefined)
            item.renderPoints = this.renderPoints.map(function (p) { return p.clone(); });
        if (this.renderPointsWithoutSkipped !== undefined)
            item.renderPointsWithoutSkipped = this.renderPointsWithoutSkipped.map(function (p) { return p.clone(); });
        if (this.actualRoutingMode !== undefined)
            item.actualRoutingMode = this.actualRoutingMode;
        if (this.lockCreateRenderPoints !== undefined)
            item.lockCreateRenderPoints = this.lockCreateRenderPoints;
        if (this.shouldInvalidateRenderPoints !== undefined)
            item.shouldInvalidateRenderPoints = this.shouldInvalidateRenderPoints;
    };
    Connector.prototype.clone = function () {
        var clone = new Connector(this.points);
        this.assign(clone);
        return clone;
    };
    Connector.prototype.getTextCount = function () {
        return this.texts.count();
    };
    Connector.prototype.getText = function (position) {
        if (position === void 0) { position = exports.CONNECTOR_DEFAULT_TEXT_POSITION; }
        var textObj = this.texts.get(position);
        return textObj ? textObj.value : "";
    };
    Connector.prototype.setText = function (text, position) {
        if (position === void 0) { position = exports.CONNECTOR_DEFAULT_TEXT_POSITION; }
        if (!text || text === "")
            this.texts.remove(position);
        else
            this.texts.set(position, new ConnectorTexts_1.ConnectorText(position, text));
    };
    Connector.prototype.getTextPoint = function (position) {
        var points = this.getRenderPoints();
        return Utils_2.GeometryUtils.getPathPointByPosition(points, position)[0];
    };
    Connector.prototype.getTextPositionByPoint = function (point) {
        var points = this.getRenderPoints();
        var length = Utils_2.GeometryUtils.getPathLength(points);
        var pos = Utils_2.GeometryUtils.getPathPositionByPoint(points, point);
        var minTextHeight = unit_converter_1.UnitConverter.pointsToTwips(parseInt(this.styleText["font-size"]));
        if (minTextHeight > pos * length)
            return minTextHeight / length;
        if (minTextHeight > length - pos * length)
            return (length - minTextHeight) / length;
        return pos;
    };
    Connector.prototype.getTextRectangle = function (position) {
        return rectangle_1.Rectangle.fromGeometry(this.getTextPoint(position), new size_1.Size(0, 0));
    };
    Connector.prototype.changeRoutingStrategy = function (strategy) {
        this.routingStrategy = strategy;
        this.invalidateRenderPoints();
    };
    Connector.prototype.clearRoutingStrategy = function () {
        delete this.routingStrategy;
        delete this.renderPoints;
        delete this.renderPointsWithoutSkipped;
        delete this.lockCreateRenderPoints;
        delete this.actualRoutingMode;
        delete this.shouldInvalidateRenderPoints;
        this.invalidateRenderPoints();
    };
    Connector.prototype.getCustomRenderPoints = function (keepSkipped) {
        if (keepSkipped === void 0) { keepSkipped = false; }
        var renderPoints = this.getRenderPoints(keepSkipped);
        var result = [];
        renderPoints.forEach(function (p, index) {
            if (index > 0 && index < renderPoints.length - 1)
                result.push(p);
        });
        return result;
    };
    Connector.prototype.getRenderPoints = function (keepSkipped) {
        if (keepSkipped === void 0) { keepSkipped = false; }
        if (this.shouldInvalidateRenderPoints === undefined || this.shouldInvalidateRenderPoints) {
            this.shouldInvalidateRenderPoints = false;
            if (!this.routingStrategy)
                this.changeRenderPoints(this.getCalculator().getPoints());
            else if (!this.lockCreateRenderPoints) {
                this.changeRenderPoints(new ConnectorPointsOrthogonalCalculator_1.ConnectorPointsOrthogonalCalculator(this).getPoints());
                if (this.actualRoutingMode !== Settings_1.ConnectorRoutingMode.None && this.points && this.renderPoints) {
                    var beginPoint = this.points[0];
                    var endPoint = this.points[this.points.length - 1];
                    if (!beginPoint.equals(endPoint)) {
                        var newRenderPoints = this.routingStrategy.createRenderPoints(this.points, this.renderPoints, this.beginItem, this.endItem, this.beginConnectionPointIndex, this.endConnectionPointIndex, ModelUtils_1.ModelUtils.getConnectorContainer(this));
                        if (newRenderPoints) {
                            this.changeRenderPoints(newRenderPoints);
                            this.actualRoutingMode = Settings_1.ConnectorRoutingMode.AllShapesOnly;
                        }
                        else
                            this.actualRoutingMode = Settings_1.ConnectorRoutingMode.None;
                    }
                }
            }
        }
        return keepSkipped ? this.renderPoints : this.renderPointsWithoutSkipped;
    };
    Connector.prototype.createRenderPointsContext = function () {
        return this.shouldChangeRenderPoints ? new ConnectorRenderPointsContext_1.ConnectorRenderPointsContext(this.renderPoints.map(function (p) { return p.clone(); }), this.lockCreateRenderPoints, this.actualRoutingMode) : undefined;
    };
    Connector.prototype.updatePointsOnPageResize = function (offsetX, offsetY) {
        this.points = this.points.map(function (p) { return p.clone().offset(offsetX, offsetY); });
        if (this.renderPoints)
            this.changeRenderPoints(this.renderPoints.map(function (p) {
                var result = p.clone().offset(offsetX, offsetY);
                result.pointIndex = p.pointIndex;
                result.skipped = p.skipped;
                return result;
            }));
    };
    Connector.prototype.addPoint = function (pointIndex, point) {
        this.points.splice(pointIndex, 0, point);
    };
    Connector.prototype.deletePoint = function (pointIndex) {
        this.points.splice(pointIndex, 1);
    };
    Connector.prototype.movePoint = function (pointIndex, point) {
        this.points[pointIndex] = point;
    };
    Connector.prototype.onAddPoint = function (pointIndex, point) {
        if (this.shouldChangeRenderPoints)
            this.replaceRenderPointsCore(this.routingStrategy.onAddPoint(this.points, pointIndex, point, this.renderPoints), true, Settings_1.ConnectorRoutingMode.AllShapesOnly);
        else
            this.invalidateRenderPoints();
    };
    Connector.prototype.onDeletePoint = function (pointIndex) {
        if (this.shouldChangeRenderPoints)
            this.replaceRenderPointsCore(this.routingStrategy.onDeletePoint(this.points, pointIndex, this.renderPoints), this.points.length > 2, Settings_1.ConnectorRoutingMode.AllShapesOnly);
        else
            this.invalidateRenderPoints();
    };
    Connector.prototype.onMovePoint = function (pointIndex, point) {
        if (this.shouldChangeRenderPoints) {
            if (pointIndex === 0 || pointIndex === this.points.length - 1)
                this.lockCreateRenderPoints = false;
            this.replaceRenderPointsCore(this.routingStrategy.onMovePoint(this.points, pointIndex, point, this.renderPoints), this.lockCreateRenderPoints, Settings_1.ConnectorRoutingMode.AllShapesOnly);
        }
        else
            this.invalidateRenderPoints();
    };
    Connector.prototype.onMovePoints = function (beginPointIndex, beginPoint, lastPointIndex, lastPoint) {
        if (this.shouldChangeRenderPoints) {
            if (beginPointIndex === 0 || lastPointIndex === this.points.length - 1)
                this.lockCreateRenderPoints = false;
            this.replaceRenderPointsCore(this.routingStrategy.onMovePoints(this.points, beginPointIndex, beginPoint, lastPointIndex, lastPoint, this.renderPoints), this.lockCreateRenderPoints, Settings_1.ConnectorRoutingMode.AllShapesOnly);
        }
        else
            this.invalidateRenderPoints();
    };
    Connector.prototype.replaceRenderPoints = function (context) {
        if (context !== undefined)
            this.replaceRenderPointsCore(context.renderPoints, context.lockCreateRenderPoints, context.actualRoutingMode);
        else
            this.invalidateRenderPoints();
    };
    Connector.prototype.clearRenderPoints = function () {
        this.changeRenderPoints(undefined);
        this.lockCreateRenderPoints = false;
        this.actualRoutingMode = undefined;
        this.invalidateRenderPoints();
    };
    Connector.prototype.replaceRenderPointsCore = function (renderPoints, lockCreateRenderPoints, mode) {
        this.changeRenderPoints(renderPoints);
        this.lockCreateRenderPoints = lockCreateRenderPoints;
        this.actualRoutingMode = mode;
        this.invalidateRenderPoints();
    };
    Connector.prototype.changeRenderPoints = function (renderPoints) {
        this.renderPoints = renderPoints;
        this.renderPointsWithoutSkipped = renderPoints ? this.renderPoints.filter(function (pt) { return !pt.skipped; }) : undefined;
    };
    Connector.prototype.getCalculator = function () {
        return (this.properties.lineOption === ConnectorProperties_1.ConnectorLineOption.Straight) ?
            new ConnectorPointsCalculator_1.ConnectorPointsCalculator(this) :
            new ConnectorPointsOrthogonalCalculator_1.ConnectorPointsOrthogonalCalculator(this);
    };
    Connector.prototype.invalidateRenderPoints = function () {
        this.shouldInvalidateRenderPoints = true;
    };
    Connector.prototype.createPrimitives = function () {
        var result = [];
        var points = this.getRenderPoints();
        var path = new PathPrimitive_1.PathPrimitive(points.map(function (pt, index) {
            return index === 0 ? new PathPrimitive_1.PathPrimitiveMoveToCommand(pt.x, pt.y) : new PathPrimitive_1.PathPrimitiveLineToCommand(pt.x, pt.y);
        }), this.style);
        result.push(path);
        result = result.concat(this.createLineEndingPrimitives(points, path));
        result = result.concat(this.createTextPrimitives());
        return result;
    };
    Connector.prototype.createLineEndingPrimitives = function (points, connectorPath) {
        var result = [];
        if (points.length > 1) {
            var lineEndingInfo = [
                { strategy: this.createLineEndingStrategy(this.properties.startLineEnding), point1: points[0], point2: points[1] },
                { strategy: this.createLineEndingStrategy(this.properties.endLineEnding), point1: points[points.length - 1], point2: points[points.length - 2] }
            ];
            lineEndingInfo.forEach(function (info) {
                var strategy = info.strategy;
                if (strategy.hasCommands()) {
                    var lineEndingPath = connectorPath;
                    if (strategy.needCreateSeparatePrimitive())
                        result.push(lineEndingPath = strategy.createPrimitive());
                    lineEndingPath.commands = lineEndingPath.commands.concat(strategy.createCommands(info.point1, info.point2));
                }
            });
        }
        return result;
    };
    Connector.prototype.createLineEndingStrategy = function (lineEnding) {
        switch (lineEnding) {
            case ConnectorProperties_1.ConnectorLineEnding.None:
                return new ConnectorLineEndingStrategies_1.ConnectorLineEndingNoneStrategy(this.style);
            case ConnectorProperties_1.ConnectorLineEnding.Arrow:
                return new ConnectorLineEndingStrategies_1.ConnectorLineEndingArrowStrategy(this.style);
            case ConnectorProperties_1.ConnectorLineEnding.OutlinedTriangle:
                return new ConnectorLineEndingStrategies_1.ConnectorLineEndingOutlinedTriangleStrategy(this.style);
            case ConnectorProperties_1.ConnectorLineEnding.FilledTriangle:
                return new ConnectorLineEndingStrategies_1.ConnectorLineEndingFilledTriangleStrategy(this.style);
            default:
                return new ConnectorLineEndingStrategies_1.ConnectorLineEndingStrategy(this.style);
        }
    };
    Connector.prototype.createSelectorPrimitives = function () {
        var result = [];
        var points = this.getRenderPoints();
        result.push(new PathPrimitive_1.PathPrimitive(points.map(function (pt, index) {
            if (index === 0)
                return new PathPrimitive_1.PathPrimitiveMoveToCommand(pt.x, pt.y);
            else
                return new PathPrimitive_1.PathPrimitiveLineToCommand(pt.x, pt.y);
        }), null, "selector"));
        return result;
    };
    Connector.prototype.createTextPrimitives = function () {
        var _this = this;
        if (!this.enableText)
            return [];
        var result = [];
        this.texts.forEach(function (textObj) {
            var text = _this.getText(textObj.position);
            if (text && text !== "") {
                var pt = _this.getTextPoint(textObj.position);
                result = result.concat([
                    new TextPrimitive_1.TextPrimitive(pt.x, pt.y, text, ITextMeasurer_1.TextOwner.Connector, undefined, undefined, undefined, _this.styleText, true, null, CanvasManagerBase_1.PAGE_BG_TEXTFLOOR_FILTER_ID, undefined, function (el) {
                        Utils_1.RenderUtils.setElementEventData(el, Event_1.MouseEventElementType.ConnectorText, _this.key, textObj.position);
                    })
                ]);
            }
        });
        return result;
    };
    Connector.prototype.getExtremeItem = function (position) {
        if (position === ConnectorPosition.Begin)
            return this.beginItem;
        if (position === ConnectorPosition.End)
            return this.endItem;
        return null;
    };
    Connector.prototype.getExtremeConnectionPointIndex = function (position) {
        if (position === ConnectorPosition.Begin)
            return this.beginConnectionPointIndex;
        if (position === ConnectorPosition.End)
            return this.endConnectionPointIndex;
        return -1;
    };
    Connector.prototype.getMinX = function () {
        var points = this.getRenderPoints();
        var xarr = points.map(function (p) { return p.x; });
        return xarr.reduce(function (prev, cur) { return Math.min(prev, cur); }, Number.MAX_VALUE);
    };
    Connector.prototype.getMinY = function () {
        var points = this.getRenderPoints();
        var yarr = points.map(function (p) { return p.y; });
        return yarr.reduce(function (prev, cur) { return Math.min(prev, cur); }, Number.MAX_VALUE);
    };
    Connector.prototype.getConnectionPoints = function () {
        return [];
    };
    Connector.prototype.getConnectionPointSide = function (point, targetPoint) {
        return DiagramItem_1.ConnectionPointSide.Undefined;
    };
    Connector.prototype.getSegments = function () {
        var result = [];
        var renderPoints = this.getRenderPoints();
        renderPoints.forEach(function (pt, index) {
            if (index > 0)
                result.push(new segment_1.Segment(renderPoints[index - 1], pt));
        });
        return result;
    };
    Connector.prototype.intersectedByRect = function (rect) {
        return this.getSegments().some(function (s) { return s.isIntersectedByRect(rect); });
    };
    Connector.prototype.toNative = function (units) {
        var item = new NativeItem_1.NativeConnector(this.key, this.dataKey);
        item.fromKey = this.beginItem && this.beginItem.dataKey;
        item.toKey = this.endItem && this.endItem.dataKey;
        item.texts = this.texts.map(function (t) { return t; }).sort(function (a, b) { return a.position - b.position; }).map(function (a) { return a.value; });
        item.fromId = this.beginItem && this.beginItem.key;
        item.fromPointIndex = this.beginConnectionPointIndex;
        item.toId = this.endItem && this.endItem.key;
        item.toPointIndex = this.endConnectionPointIndex;
        item.points = this.points.map(function (pt) { return pt.clone(); });
        item.applyUnits(units);
        return item;
    };
    Connector.minOffset = unit_converter_1.UnitConverter.pixelsToTwips(24);
    Connector.minTextHeight = unit_converter_1.UnitConverter.pixelsToTwips(12);
    return Connector;
}(DiagramItem_1.DiagramItem));
exports.Connector = Connector;


/***/ }),
/* 7 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.ShapeDescription = exports.ShapeTextPadding = exports.ShapeDefaultSize = exports.ShapeMinDimension = exports.ShapeDefaultDimension = void 0;
var unit_converter_1 = __webpack_require__(12);
var size_1 = __webpack_require__(2);
var LocalizationService_1 = __webpack_require__(36);
var ITextMeasurer_1 = __webpack_require__(43);
var RectaglePrimitive_1 = __webpack_require__(21);
var TextPrimitive_1 = __webpack_require__(63);
var Utils_1 = __webpack_require__(3);
var ConnectionPoint_1 = __webpack_require__(45);
var DiagramItem_1 = __webpack_require__(9);
exports.ShapeDefaultDimension = 1440;
exports.ShapeMinDimension = 360;
exports.ShapeDefaultSize = new size_1.Size(exports.ShapeDefaultDimension, exports.ShapeDefaultDimension);
exports.ShapeTextPadding = unit_converter_1.UnitConverter.pixelsToTwips(10);
var ShapeDescription = (function () {
    function ShapeDescription(defaultSize, hasDefaultText) {
        if (defaultSize === void 0) { defaultSize = exports.ShapeDefaultSize.clone(); }
        this.defaultSize = defaultSize;
        this.hasDefaultText = hasDefaultText;
        this.onChanged = new Utils_1.EventDispatcher();
        this.connectionPoints = this.createConnectionPoints();
    }
    Object.defineProperty(ShapeDescription.prototype, "enableText", {
        get: function () { return true; },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(ShapeDescription.prototype, "allowEditText", {
        get: function () { return true; },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(ShapeDescription.prototype, "enableImage", {
        get: function () { return false; },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(ShapeDescription.prototype, "allowEditImage", {
        get: function () { return true; },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(ShapeDescription.prototype, "hasTemplate", {
        get: function () { return false; },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(ShapeDescription.prototype, "enableChildren", {
        get: function () { return false; },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(ShapeDescription.prototype, "minWidth", {
        get: function () { return undefined; },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(ShapeDescription.prototype, "minHeight", {
        get: function () { return undefined; },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(ShapeDescription.prototype, "maxWidth", {
        get: function () { return undefined; },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(ShapeDescription.prototype, "maxHeight", {
        get: function () { return undefined; },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(ShapeDescription.prototype, "toolboxSize", {
        get: function () { return this.defaultSize; },
        enumerable: false,
        configurable: true
    });
    ShapeDescription.prototype.getTitle = function () {
        return LocalizationService_1.DiagramLocalizationService.shapeTexts[this.key];
    };
    ShapeDescription.prototype.getDefaultText = function () {
        return this.hasDefaultText ? LocalizationService_1.DiagramLocalizationService.shapeTexts[this.key] : "";
    };
    ShapeDescription.prototype.getDefaultImageUrl = function () {
        return "";
    };
    ShapeDescription.prototype.getConnectionPoints = function () {
        return this.connectionPoints;
    };
    ShapeDescription.prototype.createConnectionPoints = function () {
        return [
            new ConnectionPoint_1.ConnectionPoint(0.5, 0, DiagramItem_1.ConnectionPointSide.North),
            new ConnectionPoint_1.ConnectionPoint(1, 0.5, DiagramItem_1.ConnectionPointSide.East),
            new ConnectionPoint_1.ConnectionPoint(0.5, 1, DiagramItem_1.ConnectionPointSide.South),
            new ConnectionPoint_1.ConnectionPoint(0, 0.5, DiagramItem_1.ConnectionPointSide.West)
        ];
    };
    ShapeDescription.prototype.processConnectionPoint = function (shape, point) {
    };
    ShapeDescription.prototype.getConnectionPointIndexForItem = function (item, connectionPointIndex) {
        return connectionPointIndex;
    };
    ShapeDescription.prototype.getConnectionPointIndexForSide = function (side) {
        return side;
    };
    ShapeDescription.getConnectionPointSideByGeometry = function (point) {
        if (point.x >= point.y && (point.x > 0 || point.y > 0)) {
            if (point.x < 0.5 || (1 - point.x) >= point.y)
                return DiagramItem_1.ConnectionPointSide.North;
            return DiagramItem_1.ConnectionPointSide.East;
        }
        else {
            if (point.x > 0.5 || (1 - point.x) <= point.y)
                return DiagramItem_1.ConnectionPointSide.South;
            return DiagramItem_1.ConnectionPointSide.West;
        }
    };
    ShapeDescription.prototype.createParameters = function (parameters) {
    };
    ShapeDescription.prototype.normalizeParameters = function (shape, parameters) {
    };
    ShapeDescription.prototype.modifyParameters = function (shape, parameters, deltaX, deltaY) {
        throw Error("Not implemented");
    };
    ShapeDescription.prototype.changeParameterValue = function (parameters, key, change) {
        var p = parameters.get(key);
        p.value = change(p);
    };
    ShapeDescription.prototype.getParameterPoints = function (shape) {
        return [];
    };
    ShapeDescription.prototype.getExpandedSize = function (shape) {
        return shape.size;
    };
    ShapeDescription.prototype.getCollapsedSize = function (shape) {
        return shape.size;
    };
    ShapeDescription.prototype.getToolboxHeightToWidthRatio = function (width, height) {
        return height / width;
    };
    ShapeDescription.prototype.allowResizeHorizontally = function (_shape) {
        return true;
    };
    ShapeDescription.prototype.allowResizeVertically = function (_shape) {
        return true;
    };
    ShapeDescription.prototype.createPrimitives = function (shape, forToolbox) {
        var primitives = [];
        primitives = primitives.concat(this.createShapePrimitives(shape, forToolbox));
        if (this.enableImage)
            primitives = primitives.concat(this.createImagePrimitives(shape, forToolbox));
        if (this.enableText)
            primitives = primitives.concat(this.createTextPrimitives(shape, forToolbox));
        return primitives;
    };
    ShapeDescription.prototype.createImagePrimitives = function (_shape, _forToolbox) {
        return [];
    };
    ShapeDescription.prototype.createTextPrimitives = function (shape, forToolbox) {
        if (shape.text === undefined || shape.text === "")
            return [];
        var rect = this.getTextRectangle(shape);
        return [
            new TextPrimitive_1.TextPrimitive(rect.x, rect.y, shape.text, ITextMeasurer_1.TextOwner.Shape, rect.width, rect.height, ShapeDescription.textSpacing, shape.styleText, false, this.getTextClipPathId(forToolbox), undefined, this.getTextAngle())
        ];
    };
    ShapeDescription.prototype.getTextClipPathId = function (_forToolbox) {
        return undefined;
    };
    ShapeDescription.prototype.getTextAngle = function () {
        return TextPrimitive_1.TextAngle.Angle0deg;
    };
    ShapeDescription.prototype.getClientRectangle = function (shape) {
        return shape.rectangle;
    };
    ShapeDescription.prototype.getTextEditRectangle = function (shape) {
        return this.getTextRectangle(shape);
    };
    ShapeDescription.prototype.createSelectorPrimitives = function (shape) {
        return [
            new RectaglePrimitive_1.RectanglePrimitive(shape.position.x, shape.position.y, shape.size.width, shape.size.height, null, "selector")
        ];
    };
    ShapeDescription.prototype.raiseShapeDescriptionChanged = function (description) {
        this.onChanged.raise1(function (l) { return l.notifyShapeDescriptionChanged(description); });
    };
    ShapeDescription.textSpacing = unit_converter_1.UnitConverter.pixelsToTwips(2);
    return ShapeDescription;
}());
exports.ShapeDescription = ShapeDescription;


/***/ }),
/* 8 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.CompositionHistoryItem = exports.HistoryItem = void 0;
var HistoryItem = (function () {
    function HistoryItem() {
        this.uniqueId = -1;
    }
    HistoryItem.prototype.changeModified = function () {
        return true;
    };
    HistoryItem.prototype.getName = function () {
        return this.constructor.name;
    };
    return HistoryItem;
}());
exports.HistoryItem = HistoryItem;
var CompositionHistoryItem = (function (_super) {
    __extends(CompositionHistoryItem, _super);
    function CompositionHistoryItem() {
        var _this = _super !== null && _super.apply(this, arguments) || this;
        _this.historyItems = [];
        _this.dataSyncItems = [];
        return _this;
    }
    CompositionHistoryItem.prototype.changeModified = function () {
        var item;
        for (var i = 0; item = this.historyItems[i]; i++)
            if (item.changeModified())
                return true;
        return false;
    };
    CompositionHistoryItem.prototype.redo = function (manipulator) {
        var item;
        for (var i = 0; item = this.historyItems[i]; i++)
            item.redo(manipulator);
    };
    CompositionHistoryItem.prototype.undo = function (manipulator) {
        var item;
        for (var i = this.dataSyncItems.length - 1; item = this.dataSyncItems[i]; i--)
            item.undo(manipulator);
        this.dataSyncItems = [];
        for (var i = this.historyItems.length - 1; item = this.historyItems[i]; i--)
            item.undo(manipulator);
    };
    CompositionHistoryItem.prototype.add = function (historyItem) {
        if (historyItem == null)
            throw new Error("cannot be null");
        this.historyItems.push(historyItem);
    };
    return CompositionHistoryItem;
}(HistoryItem));
exports.CompositionHistoryItem = CompositionHistoryItem;


/***/ }),
/* 9 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.DiagramItem = exports.DEFAULT_ZINDEX = exports.ConnectionPointSide = void 0;
var rectangle_1 = __webpack_require__(13);
var metrics_1 = __webpack_require__(35);
var Utils_1 = __webpack_require__(3);
var Style_1 = __webpack_require__(26);
var ConnectionPointSide;
(function (ConnectionPointSide) {
    ConnectionPointSide[ConnectionPointSide["Undefined"] = -1] = "Undefined";
    ConnectionPointSide[ConnectionPointSide["North"] = 0] = "North";
    ConnectionPointSide[ConnectionPointSide["East"] = 1] = "East";
    ConnectionPointSide[ConnectionPointSide["South"] = 2] = "South";
    ConnectionPointSide[ConnectionPointSide["West"] = 3] = "West";
})(ConnectionPointSide = exports.ConnectionPointSide || (exports.ConnectionPointSide = {}));
exports.DEFAULT_ZINDEX = 0;
var DiagramItem = (function () {
    function DiagramItem() {
        this.key = undefined;
        this.dataKey = undefined;
        this.customData = undefined;
        this.attachedConnectors = [];
        this.zIndex = exports.DEFAULT_ZINDEX;
        this.locked = false;
        this.container = undefined;
        this.style = new Style_1.Style();
        this.styleText = new Style_1.TextStyle();
    }
    DiagramItem.prototype.assign = function (item) {
        item.key = this.key;
        item.dataKey = this.dataKey;
        item.customData = Utils_1.ObjectUtils.cloneObject(this.customData);
        item.locked = this.locked;
        item.attachedConnectors = this.attachedConnectors.slice();
        item.style = this.style.clone();
        item.styleText = this.styleText.clone();
        item.zIndex = this.zIndex;
        item.container = this.container;
    };
    DiagramItem.prototype.getConnectionPointPosition = function (index, targetPoint) {
        return this.getConnectionPoint(index, targetPoint).toPoint();
    };
    DiagramItem.prototype.getConnectionPoint = function (index, targetPoint) {
        if (index < 0 && targetPoint)
            index = this.getNearestConnectionPoint(targetPoint);
        var connectionPoints = this.getConnectionPoints();
        return connectionPoints[index] || connectionPoints[0];
    };
    DiagramItem.prototype.getNearestConnectionPoint = function (targetPoint) {
        var distance = Number.MAX_VALUE;
        var result;
        this.getConnectionPoints().forEach(function (pt, index) {
            var ptDistance = metrics_1.Metrics.euclideanDistance(pt, targetPoint);
            if (ptDistance < distance) {
                distance = ptDistance;
                result = index;
            }
        });
        return result;
    };
    DiagramItem.prototype.getConnectionPointIndex = function (side) {
        var points = this.getConnectionPoints();
        return points.reduce(function (prevIndex, pt, index) {
            if (side === ConnectionPointSide.North && pt.y < points[prevIndex].y)
                return index;
            if (side === ConnectionPointSide.South && pt.y > points[prevIndex].y)
                return index;
            if (side === ConnectionPointSide.West && pt.x < points[prevIndex].x)
                return index;
            if (side === ConnectionPointSide.East && pt.x > points[prevIndex].x)
                return index;
            return prevIndex;
        }, 0);
    };
    DiagramItem.prototype.getConnectionPointSideByIndex = function (index, targetPoint) {
        var point = this.getConnectionPoint(index, targetPoint);
        return this.getConnectionPointSide(point, targetPoint);
    };
    DiagramItem.prototype.getConnectionPointIndexForSide = function (side) {
        return side;
    };
    Object.defineProperty(DiagramItem.prototype, "enableText", {
        get: function () { return true; },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(DiagramItem.prototype, "allowEditText", {
        get: function () { return true; },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(DiagramItem.prototype, "hasTemplate", {
        get: function () { return false; },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(DiagramItem.prototype, "enableChildren", {
        get: function () { return false; },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(DiagramItem.prototype, "isLocked", {
        get: function () { return this.locked || (this.container && this.container.isLocked); },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(DiagramItem.prototype, "allowResizeHorizontally", {
        get: function () { return false; },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(DiagramItem.prototype, "allowResizeVertically", {
        get: function () { return false; },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(DiagramItem.prototype, "strokeWidth", {
        get: function () { return this.style.strokeWidth; },
        enumerable: false,
        configurable: true
    });
    DiagramItem.prototype.intersectedByRect = function (rect) {
        return rectangle_1.Rectangle.areIntersected(this.rectangle, rect);
    };
    return DiagramItem;
}());
exports.DiagramItem = DiagramItem;


/***/ }),
/* 10 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.SimpleCommandBase = void 0;
var CommandBase_1 = __webpack_require__(197);
var CommandStates_1 = __webpack_require__(198);
var ModelUtils_1 = __webpack_require__(4);
var LocalizationService_1 = __webpack_require__(36);
var SimpleCommandBase = (function (_super) {
    __extends(SimpleCommandBase, _super);
    function SimpleCommandBase() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    SimpleCommandBase.prototype.getState = function () {
        return new CommandStates_1.SimpleCommandState(this.isEnabled(), this.getValue(), this.getDefaultValue(), this.getItems(), this.isVisible());
    };
    SimpleCommandBase.prototype.isVisible = function () {
        return true;
    };
    SimpleCommandBase.prototype.isEnabled = function () {
        return !this.control.settings.readOnly || this.isEnabledInReadOnlyMode();
    };
    SimpleCommandBase.prototype.isEnabledInReadOnlyMode = function () {
        return false;
    };
    SimpleCommandBase.prototype.getValue = function () {
        return undefined;
    };
    SimpleCommandBase.prototype.getDefaultValue = function () {
        return undefined;
    };
    SimpleCommandBase.prototype.getItems = function () {
        return undefined;
    };
    SimpleCommandBase.prototype.getModelUnit = function (value) {
        return ModelUtils_1.ModelUtils.getlUnitValue(this.control.model.units, value);
    };
    SimpleCommandBase.prototype.getModelUnitText = function (value) {
        return ModelUtils_1.ModelUtils.getUnitText(this.control.model.units, LocalizationService_1.DiagramLocalizationService.unitItems, LocalizationService_1.DiagramLocalizationService.formatUnit, value);
    };
    SimpleCommandBase.prototype.getModelUnitTwipsValue = function (value) {
        return ModelUtils_1.ModelUtils.getTwipsValue(this.control.model.units, value);
    };
    SimpleCommandBase.prototype.getViewUnit = function (value) {
        return ModelUtils_1.ModelUtils.getlUnitValue(this.control.settings.viewUnits, value);
    };
    SimpleCommandBase.prototype.getViewUnitText = function (value) {
        return ModelUtils_1.ModelUtils.getUnitText(this.control.settings.viewUnits, LocalizationService_1.DiagramLocalizationService.unitItems, LocalizationService_1.DiagramLocalizationService.formatUnit, value);
    };
    SimpleCommandBase.prototype.getViewUnitTwipsValue = function (value) {
        return ModelUtils_1.ModelUtils.getTwipsValue(this.control.settings.viewUnits, value);
    };
    return SimpleCommandBase;
}(CommandBase_1.CommandBase));
exports.SimpleCommandBase = SimpleCommandBase;


/***/ }),
/* 11 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.DiagramClipboardEvent = exports.DiagramKeyboardEvent = exports.DiagramContextMenuEvent = exports.DiagramWheelEvent = exports.DiagramMouseEvent = exports.DiagramMouseEventBase = exports.DiagramMouseEventTouch = exports.DiagramFocusEvent = exports.DiagramEvent = exports.ResizeEventSource = exports.MouseEventSource = exports.MouseEventElementType = exports.MouseButton = void 0;
var key_1 = __webpack_require__(25);
var MouseButton;
(function (MouseButton) {
    MouseButton[MouseButton["None"] = 0] = "None";
    MouseButton[MouseButton["Left"] = 1] = "Left";
    MouseButton[MouseButton["Right"] = 2] = "Right";
    MouseButton[MouseButton["Middle"] = 4] = "Middle";
})(MouseButton = exports.MouseButton || (exports.MouseButton = {}));
var MouseEventElementType;
(function (MouseEventElementType) {
    MouseEventElementType[MouseEventElementType["Undefined"] = 0] = "Undefined";
    MouseEventElementType[MouseEventElementType["Background"] = 1] = "Background";
    MouseEventElementType[MouseEventElementType["Document"] = 2] = "Document";
    MouseEventElementType[MouseEventElementType["Connector"] = 3] = "Connector";
    MouseEventElementType[MouseEventElementType["ConnectorPoint"] = 4] = "ConnectorPoint";
    MouseEventElementType[MouseEventElementType["ConnectorSide"] = 5] = "ConnectorSide";
    MouseEventElementType[MouseEventElementType["ConnectorOrthogonalSide"] = 6] = "ConnectorOrthogonalSide";
    MouseEventElementType[MouseEventElementType["ConnectorText"] = 7] = "ConnectorText";
    MouseEventElementType[MouseEventElementType["Shape"] = 8] = "Shape";
    MouseEventElementType[MouseEventElementType["ShapeResizeBox"] = 9] = "ShapeResizeBox";
    MouseEventElementType[MouseEventElementType["ShapeParameterBox"] = 10] = "ShapeParameterBox";
    MouseEventElementType[MouseEventElementType["SelectionRect"] = 11] = "SelectionRect";
    MouseEventElementType[MouseEventElementType["ShapeConnectionPoint"] = 12] = "ShapeConnectionPoint";
    MouseEventElementType[MouseEventElementType["ShapeExpandButton"] = 13] = "ShapeExpandButton";
})(MouseEventElementType = exports.MouseEventElementType || (exports.MouseEventElementType = {}));
var MouseEventSource = (function () {
    function MouseEventSource(type, key, value) {
        this.type = type;
        this.key = key;
        this.value = value;
    }
    return MouseEventSource;
}());
exports.MouseEventSource = MouseEventSource;
var ResizeEventSource;
(function (ResizeEventSource) {
    ResizeEventSource[ResizeEventSource["Undefined"] = 0] = "Undefined";
    ResizeEventSource[ResizeEventSource["ResizeBox_NW"] = 1] = "ResizeBox_NW";
    ResizeEventSource[ResizeEventSource["ResizeBox_NE"] = 2] = "ResizeBox_NE";
    ResizeEventSource[ResizeEventSource["ResizeBox_SE"] = 3] = "ResizeBox_SE";
    ResizeEventSource[ResizeEventSource["ResizeBox_SW"] = 4] = "ResizeBox_SW";
    ResizeEventSource[ResizeEventSource["ResizeBox_N"] = 5] = "ResizeBox_N";
    ResizeEventSource[ResizeEventSource["ResizeBox_E"] = 6] = "ResizeBox_E";
    ResizeEventSource[ResizeEventSource["ResizeBox_S"] = 7] = "ResizeBox_S";
    ResizeEventSource[ResizeEventSource["ResizeBox_W"] = 8] = "ResizeBox_W";
})(ResizeEventSource = exports.ResizeEventSource || (exports.ResizeEventSource = {}));
var DiagramEvent = (function () {
    function DiagramEvent(modifiers) {
        this.modifiers = modifiers;
    }
    return DiagramEvent;
}());
exports.DiagramEvent = DiagramEvent;
var DiagramFocusEvent = (function (_super) {
    __extends(DiagramFocusEvent, _super);
    function DiagramFocusEvent(inputText) {
        var _this = _super.call(this, key_1.ModifierKey.None) || this;
        _this.inputText = inputText;
        return _this;
    }
    return DiagramFocusEvent;
}(DiagramEvent));
exports.DiagramFocusEvent = DiagramFocusEvent;
var DiagramMouseEventTouch = (function () {
    function DiagramMouseEventTouch(offsetPoint, modelPoint) {
        this.offsetPoint = offsetPoint;
        this.modelPoint = modelPoint;
    }
    return DiagramMouseEventTouch;
}());
exports.DiagramMouseEventTouch = DiagramMouseEventTouch;
var DiagramMouseEventBase = (function (_super) {
    __extends(DiagramMouseEventBase, _super);
    function DiagramMouseEventBase(modifiers, offsetPoint, modelPoint, source) {
        var _this = _super.call(this, modifiers) || this;
        _this.offsetPoint = offsetPoint;
        _this.modelPoint = modelPoint;
        _this.source = source;
        return _this;
    }
    return DiagramMouseEventBase;
}(DiagramEvent));
exports.DiagramMouseEventBase = DiagramMouseEventBase;
var DiagramMouseEvent = (function (_super) {
    __extends(DiagramMouseEvent, _super);
    function DiagramMouseEvent(modifiers, button, offsetPoint, modelPoint, source, touches, isTouchMode) {
        if (touches === void 0) { touches = []; }
        var _this = _super.call(this, modifiers, offsetPoint, modelPoint, source) || this;
        _this.button = button;
        _this.touches = touches;
        _this.isTouchMode = isTouchMode;
        _this.scrollX = 0;
        _this.scrollY = 0;
        return _this;
    }
    return DiagramMouseEvent;
}(DiagramMouseEventBase));
exports.DiagramMouseEvent = DiagramMouseEvent;
var DiagramWheelEvent = (function (_super) {
    __extends(DiagramWheelEvent, _super);
    function DiagramWheelEvent(modifiers, deltaX, deltaY, offsetPoint, modelPoint, source) {
        var _this = _super.call(this, modifiers, offsetPoint, modelPoint, source) || this;
        _this.deltaX = deltaX;
        _this.deltaY = deltaY;
        return _this;
    }
    return DiagramWheelEvent;
}(DiagramMouseEventBase));
exports.DiagramWheelEvent = DiagramWheelEvent;
var DiagramContextMenuEvent = (function (_super) {
    __extends(DiagramContextMenuEvent, _super);
    function DiagramContextMenuEvent(modifiers, eventPoint, modelPoint) {
        var _this = _super.call(this, modifiers) || this;
        _this.eventPoint = eventPoint;
        _this.modelPoint = modelPoint;
        return _this;
    }
    return DiagramContextMenuEvent;
}(DiagramEvent));
exports.DiagramContextMenuEvent = DiagramContextMenuEvent;
var DiagramKeyboardEvent = (function (_super) {
    __extends(DiagramKeyboardEvent, _super);
    function DiagramKeyboardEvent(modifiers, keyCode, inputText) {
        var _this = _super.call(this, modifiers) || this;
        _this.keyCode = keyCode;
        _this.inputText = inputText;
        return _this;
    }
    DiagramKeyboardEvent.prototype.getShortcutCode = function () {
        return this.modifiers | this.keyCode;
    };
    return DiagramKeyboardEvent;
}(DiagramEvent));
exports.DiagramKeyboardEvent = DiagramKeyboardEvent;
var DiagramClipboardEvent = (function (_super) {
    __extends(DiagramClipboardEvent, _super);
    function DiagramClipboardEvent(clipboardData) {
        var _this = _super.call(this, key_1.ModifierKey.None) || this;
        _this.clipboardData = clipboardData;
        return _this;
    }
    return DiagramClipboardEvent;
}(DiagramEvent));
exports.DiagramClipboardEvent = DiagramClipboardEvent;


/***/ }),
/* 12 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

Object.defineProperty(exports, "__esModule", { value: true });
var UnitConverter = (function () {
    function UnitConverter() {
    }
    UnitConverter.hundredthsOfMillimeterToTwipsRound = function (value) {
        return Math.round(1440 * value / 2540.0);
    };
    UnitConverter.documentsToTwips = function (value) {
        return 24 * value / 5;
    };
    UnitConverter.pixelsToTwips = function (value) {
        return Math.round(UnitConverter.pixelsToTwipsF(value));
    };
    UnitConverter.pixelsToTwipsCustomDpi = function (value, dpi) {
        return Math.round(UnitConverter.pixelsToTwipsFCustomDpi(value, dpi));
    };
    UnitConverter.inchesToTwips = function (value) {
        return Math.round(UnitConverter.inchesToTwipsF(value));
    };
    UnitConverter.pointsToTwips = function (value) {
        return Math.round(UnitConverter.pointsToTwipsF(value));
    };
    UnitConverter.picasToTwips = function (value) {
        return Math.round(value * 1440 / UnitConverter.PICAS_PER_INCH);
    };
    UnitConverter.centimetersToTwips = function (value) {
        return Math.round(UnitConverter.centimetersToTwipsF(value));
    };
    UnitConverter.pixelsToTwipsF = function (value) {
        return value * 1440 / UnitConverter.DPI;
    };
    UnitConverter.pixelsToTwipsFCustomDpi = function (value, dpi) {
        return value * 1440 / dpi;
    };
    UnitConverter.inchesToTwipsF = function (value) {
        return value * 1440;
    };
    UnitConverter.pointsToTwipsF = function (value) {
        return value * 20;
    };
    UnitConverter.centimetersToTwipsF = function (value) {
        return value * 1440 / UnitConverter.CENTIMETERS_PER_INCH;
    };
    UnitConverter.twipsToDegrees = function (value) {
        return value / 60000;
    };
    UnitConverter.twipsToRadians = function (value) {
        return value / 60000 * Math.PI / 180;
    };
    UnitConverter.degreesToTwips = function (value) {
        return value * 60000;
    };
    UnitConverter.radiansToTwips = function (value) {
        return value * 60000 / Math.PI * 180;
    };
    UnitConverter.radiansToDegrees = function (value) {
        return value / Math.PI * 180;
    };
    UnitConverter.twipsToFD = function (value) {
        return Math.round(value * 2048 / 1875);
    };
    UnitConverter.fdToTwips = function (value) {
        return Math.round(value * 1875 / 2048);
    };
    UnitConverter.emuToTwips = function (val) {
        return val / 635;
    };
    UnitConverter.twipsToPixels = function (value) {
        return Math.round(UnitConverter.twipsToPixelsF(value));
    };
    UnitConverter.inchesToPixels = function (value) {
        return Math.round(UnitConverter.DPI * value);
    };
    UnitConverter.centimeterToPixel = function (value) {
        return Math.round(this.centimeterToPixelF(value));
    };
    UnitConverter.centimeterToPixelF = function (value) {
        return value * UnitConverter.DPI / UnitConverter.CENTIMETERS_PER_INCH;
    };
    UnitConverter.millimetersToPixel = function (value) {
        return Math.round(value / (UnitConverter.CENTIMETERS_PER_INCH / UnitConverter.DPI) / 10);
    };
    UnitConverter.pointsToPixels = function (value) {
        return Math.round(value * UnitConverter.DPI / 72);
    };
    UnitConverter.pointsToPixelsF = function (value) {
        return value * UnitConverter.DPI / 72;
    };
    UnitConverter.twipsToPixelsF = function (value) {
        return value * UnitConverter.DPI / 1440;
    };
    UnitConverter.pixelsToPoints = function (value) {
        return Math.round(value * 72 / UnitConverter.DPI);
    };
    UnitConverter.pixelsToPointsF = function (value) {
        return value * 72 / UnitConverter.DPI;
    };
    UnitConverter.twipsToPoints = function (value) {
        return Math.round(this.twipsToPointsF(value));
    };
    UnitConverter.twipsToPointsF = function (value) {
        return value / 20;
    };
    UnitConverter.twipsToInches = function (value) {
        return value / 1440;
    };
    UnitConverter.pixelsToInches = function (value) {
        return value / UnitConverter.DPI;
    };
    UnitConverter.twipsToCentimeters = function (value) {
        return value * UnitConverter.CENTIMETERS_PER_INCH / 1440;
    };
    UnitConverter.pixelToCentimeters = function (value) {
        return value * UnitConverter.CENTIMETERS_PER_INCH / UnitConverter.DPI;
    };
    UnitConverter.twipsToHundredthsOfMillimeter = function (value) {
        return Math.round(127 * value / 72);
    };
    UnitConverter.pixelsToHundredthsOfMillimeter = function (value) {
        return Math.round(2540 * value / UnitConverter.DPI);
    };
    UnitConverter.hundredthsOfMillimeterToTwips = function (value) {
        return 15 * value / 127;
    };
    UnitConverter.twipsToEmu = function (val) {
        return val * 635;
    };
    UnitConverter.twipsToDegree = function (value) {
        return value / 60000;
    };
    UnitConverter.DPI = 96;
    UnitConverter.CENTIMETERS_PER_INCH = 2.54;
    UnitConverter.PICAS_PER_INCH = 6;
    return UnitConverter;
}());
exports.UnitConverter = UnitConverter;


/***/ }),
/* 13 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

Object.defineProperty(exports, "__esModule", { value: true });
var flag_1 = __webpack_require__(163);
var algorithms_1 = __webpack_require__(164);
var fixed_1 = __webpack_require__(106);
var point_1 = __webpack_require__(0);
var size_1 = __webpack_require__(2);
var Rectangle = (function () {
    function Rectangle(x, y, width, height) {
        this.x = x;
        this.y = y;
        this.width = width;
        this.height = height;
    }
    Object.defineProperty(Rectangle.prototype, "right", {
        get: function () {
            return this.x + this.width;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(Rectangle.prototype, "bottom", {
        get: function () {
            return this.y + this.height;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(Rectangle.prototype, "center", {
        get: function () {
            return Rectangle.center(this);
        },
        enumerable: true,
        configurable: true
    });
    Rectangle.prototype.createRectangle = function () {
        return new Rectangle(this.x, this.y, this.width, this.height);
    };
    Rectangle.prototype.createSize = function () {
        return new size_1.Size(this.width, this.height);
    };
    Rectangle.prototype.createPosition = function () {
        return new point_1.Point(this.x, this.y);
    };
    Rectangle.prototype.createVerticalInterval = function () {
        return new fixed_1.FixedInterval(this.y, this.height);
    };
    Rectangle.prototype.createHorizontalInterval = function () {
        return new fixed_1.FixedInterval(this.x, this.width);
    };
    Rectangle.fromGeometry = function (point, size) {
        return new Rectangle(point.x, point.y, size.width, size.height);
    };
    Rectangle.fromPoints = function (pointA, pointB) {
        var x = Math.min(pointA.x, pointB.x);
        var y = Math.min(pointA.y, pointB.y);
        var width = Math.abs(pointA.x - pointB.x);
        var height = Math.abs(pointA.y - pointB.y);
        return new Rectangle(x, y, width, height);
    };
    Rectangle.fromPositions = function (x1, y1, x2, y2) {
        var x = Math.min(x1, x2);
        var y = Math.min(y1, y2);
        var width = Math.abs(x2 - x1);
        var height = Math.abs(y2 - y1);
        return new Rectangle(x, y, width, height);
    };
    Rectangle.fromCenter = function (center, minRadius) {
        return new Rectangle(center.x - minRadius, center.y - minRadius, minRadius * 2, minRadius * 2);
    };
    Rectangle.prototype.isCollapsed = function () {
        return this.width === 0 || this.height === 0;
    };
    Rectangle.prototype.isEmpty = function () {
        return this.x === 0 && this.y === 0 &&
            this.width === 0 && this.height === 0;
    };
    Rectangle.prototype.toString = function () {
        return JSON.stringify(this);
    };
    Rectangle.prototype.setPosition = function (pos) {
        this.x = pos.x;
        this.y = pos.y;
        return this;
    };
    Rectangle.prototype.setSize = function (size) {
        this.width = size.width;
        this.height = size.height;
        return this;
    };
    Rectangle.prototype.setGeomerty = function (rect) {
        this.x = rect.x;
        this.y = rect.y;
        this.width = rect.width;
        this.height = rect.height;
        return this;
    };
    Rectangle.prototype.moveRectangle = function (offsetX, offsetY) {
        this.x += offsetX;
        this.y += offsetY;
        return this;
    };
    Rectangle.prototype.moveRectangleByPoint = function (offset) {
        this.x += offset.x;
        this.y += offset.y;
        return this;
    };
    Rectangle.prototype.resize = function (deltaX, deltaY) {
        this.width += deltaX;
        this.height += deltaY;
        return this;
    };
    Rectangle.prototype.nonNegativeSize = function () {
        if (this.width < 0)
            this.width = 0;
        if (this.height < 0)
            this.height = 0;
        return this;
    };
    Rectangle.prototype.multiply = function (multiplierX, multiplierY) {
        this.x *= multiplierX;
        this.y *= multiplierY;
        this.width *= multiplierX;
        this.height *= multiplierY;
        return this;
    };
    Rectangle.prototype.equals = function (obj) {
        return Rectangle.equals(this, obj);
    };
    Rectangle.prototype.clone = function () {
        var rect = new Rectangle(0, 0, 0, 0);
        rect.copyFrom(this);
        return rect;
    };
    Rectangle.prototype.copyFrom = function (obj) {
        this.x = obj.x;
        this.y = obj.y;
        this.width = obj.width;
        this.height = obj.height;
    };
    Rectangle.prototype.containsPoint = function (point) {
        return Rectangle.containsPoint(this, point);
    };
    Rectangle.prototype.containsRectangle = function (rectangle) {
        return this.x <= rectangle.x &&
            this.right >= rectangle.right &&
            this.y <= rectangle.y &&
            this.bottom >= rectangle.bottom;
    };
    Rectangle.prototype.inflate = function (deltaX, deltaY) {
        if (deltaY === void 0) { deltaY = deltaX; }
        this.x -= deltaX;
        this.y -= deltaY;
        this.width += deltaX * 2;
        this.height += deltaY * 2;
        return this;
    };
    Rectangle.prototype.applyOffsetsInside = function (offsets) {
        this.x += offsets.left;
        this.y += offsets.top;
        this.width -= offsets.left + offsets.right;
        this.height -= offsets.top + offsets.bottom;
        return this;
    };
    Rectangle.prototype.applyNormalizedOffsetsInside = function (offsets) {
        var left = Math.max(0, offsets.left);
        var right = Math.max(0, offsets.right);
        var horSum = left + right;
        if (horSum !== 0) {
            if (horSum <= this.width) {
                this.x += left;
                this.width -= horSum;
            }
            else {
                this.x += this.width * (left / horSum);
                this.width = 0;
            }
        }
        var top = Math.max(0, offsets.top);
        var bottom = Math.max(0, offsets.bottom);
        var vertSum = top + bottom;
        if (vertSum !== 0) {
            if (vertSum <= this.height) {
                this.y += top;
                this.height -= vertSum;
            }
            else {
                this.y += this.height * (top / vertSum);
                this.height = 0;
            }
        }
        return this;
    };
    Rectangle.prototype.applyOffsetsOutside = function (offsets) {
        this.x -= offsets.left;
        this.y -= offsets.top;
        this.width += offsets.left + offsets.right;
        this.height += offsets.top + offsets.bottom;
        return this;
    };
    Rectangle.prototype.applyConverter = function (converter) {
        this.x = converter(this.x);
        this.y = converter(this.y);
        this.width = converter(this.width);
        this.height = converter(this.height);
        return this;
    };
    Rectangle.getHorizIntersection = function (objA, objB) {
        return algorithms_1.IntervalAlgorithms.getIntersection(new fixed_1.FixedInterval(objA.x, objA.width), new fixed_1.FixedInterval(objB.x, objB.width));
    };
    Rectangle.getVertIntersection = function (objA, objB) {
        return algorithms_1.IntervalAlgorithms.getIntersection(new fixed_1.FixedInterval(objA.y, objA.height), new fixed_1.FixedInterval(objB.y, objB.height));
    };
    Rectangle.getIntersection = function (objA, objB) {
        var horInters = algorithms_1.IntervalAlgorithms.getIntersection(new fixed_1.FixedInterval(objA.x, objA.width), new fixed_1.FixedInterval(objB.x, objB.width));
        if (!horInters)
            return null;
        var vertInters = algorithms_1.IntervalAlgorithms.getIntersection(new fixed_1.FixedInterval(objA.y, objA.height), new fixed_1.FixedInterval(objB.y, objB.height));
        if (!vertInters)
            return null;
        return new Rectangle(horInters.start, vertInters.start, horInters.length, vertInters.length);
    };
    Rectangle.getHorNonCollapsedIntersection = function (objA, objB) {
        var inters = Rectangle.getHorizIntersection(objA, objB);
        return inters && !inters.isCollapsed() ? inters : null;
    };
    Rectangle.getVertNonCollapsedIntersection = function (objA, objB) {
        var inters = Rectangle.getVertIntersection(objA, objB);
        return inters && !inters.isCollapsed() ? inters : null;
    };
    Rectangle.getNonCollapsedIntersection = function (objA, objB) {
        var inters = Rectangle.getIntersection(objA, objB);
        return inters && !inters.isCollapsed() ? inters : null;
    };
    Rectangle.areIntersected = function (rectA, rectB) {
        return !(rectA.x > rectB.x + rectB.width || rectB.x > rectA.x + rectA.width) &&
            !(rectA.y > rectB.y + rectB.height || rectB.y > rectA.y + rectA.height);
    };
    Rectangle.union = function (rectA, rectB) {
        var right = Math.max(rectA.x + rectA.width, rectB.x + rectB.width);
        var bottom = Math.max(rectA.y + rectA.height, rectB.y + rectB.height);
        var x = Math.min(rectA.x, rectB.x);
        var y = Math.min(rectA.y, rectB.y);
        return new Rectangle(x, y, right - x, bottom - y);
    };
    Rectangle.equals = function (a, b) {
        return a.x === b.x &&
            a.y === b.y &&
            a.width === b.width &&
            a.height === b.height;
    };
    Rectangle.center = function (rect) {
        return new point_1.Point(rect.x + rect.width / 2, rect.y + rect.height / 2);
    };
    Rectangle.containsPoint = function (rect, point) {
        var right = rect.x + rect.width;
        var bottom = rect.y + rect.height;
        return point.y >= rect.y && bottom >= point.y &&
            point.x >= rect.x && right >= point.x;
    };
    return Rectangle;
}());
exports.Rectangle = Rectangle;
var HitTestDeviation;
(function (HitTestDeviation) {
    HitTestDeviation[HitTestDeviation["None"] = 0] = "None";
    HitTestDeviation[HitTestDeviation["Top"] = 1] = "Top";
    HitTestDeviation[HitTestDeviation["Bottom"] = 2] = "Bottom";
    HitTestDeviation[HitTestDeviation["Left"] = 4] = "Left";
    HitTestDeviation[HitTestDeviation["Right"] = 8] = "Right";
})(HitTestDeviation = exports.HitTestDeviation || (exports.HitTestDeviation = {}));
var RectangleDeviation = (function () {
    function RectangleDeviation(initRectangle, initPoint) {
        this.initRectangle = initRectangle;
        this.initPoint = initPoint;
        this.deviation = new flag_1.Flag(HitTestDeviation.None);
    }
    RectangleDeviation.prototype.calcDeviation = function () {
        if (this.initPoint.x < this.initRectangle.x)
            this.deviation.set(HitTestDeviation.Left, true);
        else if (this.initPoint.x > this.initRectangle.right)
            this.deviation.set(HitTestDeviation.Right, true);
        if (this.initPoint.y < this.initRectangle.y)
            this.deviation.set(HitTestDeviation.Top, true);
        else if (this.initPoint.y > this.initRectangle.bottom)
            this.deviation.set(HitTestDeviation.Bottom, true);
        return this;
    };
    RectangleDeviation.prototype.calcAdditionalParams = function () {
        this.insidePoint = this.initPoint.clone();
        this.offsetToInside = new point_1.Point(0, 0);
        if (this.deviation.get(HitTestDeviation.Left)) {
            this.insidePoint.x = this.initRectangle.x;
            this.offsetToInside.x = this.insidePoint.x - this.initPoint.x;
        }
        else if (this.deviation.get(HitTestDeviation.Right)) {
            this.insidePoint.x = this.initRectangle.right;
            this.offsetToInside.x = this.initPoint.x - this.insidePoint.x;
        }
        if (this.deviation.get(HitTestDeviation.Top)) {
            this.insidePoint.y = this.initRectangle.y;
            this.offsetToInside.y = this.insidePoint.y - this.initPoint.y;
        }
        else if (this.deviation.get(HitTestDeviation.Bottom)) {
            this.insidePoint.y = this.initRectangle.bottom;
            this.offsetToInside.y = this.initPoint.y - this.insidePoint.y;
        }
        return this;
    };
    return RectangleDeviation;
}());
exports.RectangleDeviation = RectangleDeviation;


/***/ }),
/* 14 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.Shape = void 0;
var rectangle_1 = __webpack_require__(13);
var ShapeDescription_1 = __webpack_require__(7);
var ShapeParameters_1 = __webpack_require__(37);
var DiagramItem_1 = __webpack_require__(9);
var ConnectionPoint_1 = __webpack_require__(45);
var ImageInfo_1 = __webpack_require__(51);
var NativeItem_1 = __webpack_require__(84);
var Shape = (function (_super) {
    __extends(Shape, _super);
    function Shape(description, position, forToolbox) {
        var _this = _super.call(this) || this;
        _this.description = description;
        _this.children = [];
        _this.expanded = true;
        _this.expandedSize = undefined;
        if (!description)
            throw Error("Shape type is incorrect");
        _this.position = position.clone();
        var defaultSize = forToolbox ? description.toolboxSize : description.defaultSize;
        _this.size = defaultSize.clone();
        _this.text = description.getDefaultText();
        _this.image = new ImageInfo_1.ImageInfo(description.getDefaultImageUrl());
        _this.parameters = new ShapeParameters_1.ShapeParameters();
        description.createParameters(_this.parameters);
        return _this;
    }
    Shape.prototype.assign = function (item) {
        _super.prototype.assign.call(this, item);
        item.size = this.size.clone();
        item.text = this.text;
        item.image = this.image.clone();
        item.parameters = this.parameters.clone();
        item.children = this.children.slice();
        item.expanded = this.expanded;
        if (this.expandedSize)
            item.expandedSize = this.expandedSize.clone();
    };
    Shape.prototype.clone = function () {
        var clone = new Shape(this.description, this.position.clone());
        this.assign(clone);
        return clone;
    };
    Object.defineProperty(Shape.prototype, "enableText", {
        get: function () { return this.description.enableText; },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(Shape.prototype, "allowEditText", {
        get: function () { return this.description.allowEditText; },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(Shape.prototype, "hasTemplate", {
        get: function () { return this.description.hasTemplate; },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(Shape.prototype, "enableChildren", {
        get: function () { return this.description.enableChildren; },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(Shape.prototype, "enableImage", {
        get: function () { return this.description.enableImage; },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(Shape.prototype, "allowEditImage", {
        get: function () { return this.description.allowEditImage; },
        enumerable: false,
        configurable: true
    });
    Shape.prototype.getMinWidth = function (settingsMinWidth) {
        return typeof (this.description.minWidth) === "number" ? this.description.minWidth :
            typeof (settingsMinWidth) === "number" ? settingsMinWidth : ShapeDescription_1.ShapeMinDimension;
    };
    Shape.prototype.getMinHeight = function (settingsMinHeight) {
        return typeof (this.description.minHeight) === "number" ? this.description.minHeight :
            typeof (settingsMinHeight) === "number" ? settingsMinHeight : ShapeDescription_1.ShapeMinDimension;
    };
    Shape.prototype.getMaxWidth = function (settingsMaxWidth) {
        return typeof (this.description.maxWidth) === "number" ? this.description.maxWidth :
            typeof (settingsMaxWidth) === "number" ? settingsMaxWidth : undefined;
    };
    Shape.prototype.getMaxHeight = function (settingsMaxHeight) {
        return typeof (this.description.maxHeight) === "number" ? this.description.maxHeight :
            typeof (settingsMaxHeight) === "number" ? settingsMaxHeight : undefined;
    };
    Shape.prototype.createPrimitives = function () {
        return this.description.createPrimitives(this);
    };
    Shape.prototype.createSelectorPrimitives = function () {
        return this.description.createSelectorPrimitives(this);
    };
    Shape.prototype.normalizeX = function (x) {
        return Math.max(this.position.x, Math.min(x, this.position.x + this.size.width));
    };
    Shape.prototype.normalizeY = function (y) {
        return Math.max(this.position.y, Math.min(y, this.position.y + this.size.height));
    };
    Shape.prototype.getConnectionPoints = function () {
        var _this = this;
        var result = this.description.getConnectionPoints().map(function (pt) {
            var point = new ConnectionPoint_1.ConnectionPoint(_this.position.x + pt.x * _this.size.width, _this.position.y + pt.y * _this.size.height, pt.side);
            _this.description.processConnectionPoint(_this, point);
            return point;
        });
        return result;
    };
    Shape.prototype.getConnectionPointSide = function (point, targetPoint) {
        if (point.side !== DiagramItem_1.ConnectionPointSide.Undefined)
            return point.side;
        return this.getConnectionPointSideByGeometry(point);
    };
    Shape.prototype.getConnectionPointSideByGeometry = function (point) {
        var pt = point.clone().offset(-this.position.x, -this.position.y).multiply(1 / this.size.width, 1 / this.size.height);
        return ShapeDescription_1.ShapeDescription.getConnectionPointSideByGeometry(pt);
    };
    Shape.prototype.getConnectionPointIndexForItem = function (item, connectionPointIndex) {
        return this.description.getConnectionPointIndexForItem(item, connectionPointIndex);
    };
    Shape.prototype.getConnectionPointIndexForSide = function (side) {
        return this.description.getConnectionPointIndexForSide(side);
    };
    Shape.prototype.toggleExpandedSize = function () {
        if (!this.expanded) {
            this.expandedSize = this.size.clone();
            this.size = this.getCollapsedSize();
        }
        else {
            this.size = this.getExpandedSize();
            this.expandedSize = undefined;
        }
    };
    Shape.prototype.getExpandedSize = function () {
        return this.description.getExpandedSize(this);
    };
    Shape.prototype.getCollapsedSize = function () {
        return this.description.getCollapsedSize(this);
    };
    Shape.prototype.getToolboxHeightToWidthRatio = function () {
        return this.description.getToolboxHeightToWidthRatio(this.size.width, this.size.height);
    };
    Object.defineProperty(Shape.prototype, "allowResizeHorizontally", {
        get: function () {
            return this.description.allowResizeHorizontally(this);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(Shape.prototype, "allowResizeVertically", {
        get: function () {
            return this.description.allowResizeVertically(this);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(Shape.prototype, "rectangle", {
        get: function () {
            return rectangle_1.Rectangle.fromGeometry(this.position, this.size);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(Shape.prototype, "clientRectangle", {
        get: function () {
            return this.description.getClientRectangle(this);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(Shape.prototype, "textRectangle", {
        get: function () {
            return this.description.getTextRectangle(this);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(Shape.prototype, "textEditRectangle", {
        get: function () {
            return this.description.getTextEditRectangle(this);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(Shape.prototype, "textAngle", {
        get: function () {
            return this.description.getTextAngle();
        },
        enumerable: false,
        configurable: true
    });
    Shape.prototype.toNative = function (units) {
        var item = new NativeItem_1.NativeShape(this.key, this.dataKey);
        item.type = this.description.key;
        item.text = this.text;
        item.position = this.position.clone();
        item.size = this.size.clone();
        item.attachedConnectorIds = this.attachedConnectors.map(function (c) { return c.key; });
        item.applyUnits(units);
        item.containerId = this.container ? this.container.key : null;
        item.containerChildItemIds = this.children.map(function (item) { return item.key; });
        item.containerExpanded = this.expanded;
        return item;
    };
    return Shape;
}(DiagramItem_1.DiagramItem));
exports.Shape = Shape;


/***/ }),
/* 15 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.RenderHelper = exports.svgNS = void 0;
var Diagnostics_1 = __webpack_require__(61);
exports.svgNS = "http://www.w3.org/2000/svg";
var RenderHelper = (function () {
    function RenderHelper() {
    }
    RenderHelper.createSvgElement = function (parent, forExport) {
        if (forExport === void 0) { forExport = false; }
        var svgElement = document.createElementNS(exports.svgNS, "svg");
        svgElement.className.baseVal = "dxdi-canvas" + (forExport ? " export" : "");
        parent && parent.appendChild(svgElement);
        return svgElement;
    };
    RenderHelper.createMainElement = function (parent, forMeasurer) {
        if (forMeasurer === void 0) { forMeasurer = false; }
        var element = document.createElement("div");
        element.setAttribute("class", "dxdi-control" + (forMeasurer ? " measurer" : ""));
        if (Diagnostics_1.Diagnostics.optimizeLayers)
            element.style.transform = "translateZ(0)";
        parent && parent.appendChild(element);
        return element;
    };
    RenderHelper.addEventListener = function (element, eventName, handler) {
        element.addEventListener(eventName, handler);
    };
    RenderHelper.removeEventListener = function (element, eventName, handler) {
        element.removeEventListener(eventName, handler);
    };
    return RenderHelper;
}());
exports.RenderHelper = RenderHelper;


/***/ }),
/* 16 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.DiagramModelOperation = exports.ModelOperationSettings = void 0;
var ModelOperationSettings = (function () {
    function ModelOperationSettings() {
        this._addShape = true;
        this._addShapeFromToolbox = true;
        this._deleteShape = true;
        this._deleteConnector = true;
        this._changeConnection = true;
        this._changeConnectorPoints = true;
        this._changeShapeText = true;
        this._changeConnectorText = true;
        this._resizeShape = true;
        this._moveShape = true;
    }
    Object.defineProperty(ModelOperationSettings.prototype, "addShape", {
        get: function () { return this._addShape; },
        set: function (value) {
            if (value !== this._addShape)
                this._addShape = value;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(ModelOperationSettings.prototype, "addShapeFromToolbox", {
        get: function () { return this._addShapeFromToolbox; },
        set: function (value) {
            if (value !== this._addShapeFromToolbox)
                this._addShapeFromToolbox = value;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(ModelOperationSettings.prototype, "deleteShape", {
        get: function () { return this._deleteShape; },
        set: function (value) {
            if (value !== this._deleteShape)
                this._deleteShape = value;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(ModelOperationSettings.prototype, "deleteConnector", {
        get: function () { return this._deleteConnector; },
        set: function (value) {
            if (value !== this._deleteConnector)
                this._deleteConnector = value;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(ModelOperationSettings.prototype, "changeConnection", {
        get: function () { return this._changeConnection; },
        set: function (value) {
            if (value !== this._changeConnection)
                this._changeConnection = value;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(ModelOperationSettings.prototype, "changeConnectorPoints", {
        get: function () { return this._changeConnectorPoints; },
        set: function (value) {
            if (value !== this._changeConnectorPoints)
                this._changeConnectorPoints = value;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(ModelOperationSettings.prototype, "changeShapeText", {
        get: function () { return this._changeShapeText; },
        set: function (value) {
            if (value !== this._changeShapeText)
                this._changeShapeText = value;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(ModelOperationSettings.prototype, "changeConnectorText", {
        get: function () { return this._changeConnectorText; },
        set: function (value) {
            if (value !== this._changeConnectorText)
                this._changeConnectorText = value;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(ModelOperationSettings.prototype, "resizeShape", {
        get: function () { return this._resizeShape; },
        set: function (value) {
            if (value !== this._resizeShape)
                this._resizeShape = value;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(ModelOperationSettings.prototype, "moveShape", {
        get: function () { return this._moveShape; },
        set: function (value) {
            if (value !== this._moveShape)
                this._moveShape = value;
        },
        enumerable: false,
        configurable: true
    });
    ModelOperationSettings.prototype.applySettings = function (settings) {
        if (!settings)
            return;
        if (typeof settings.addShape === "boolean")
            this.addShape = settings.addShape;
        if (typeof settings.addShapeFromToolbox === "boolean")
            this.addShapeFromToolbox = settings.addShapeFromToolbox;
        if (typeof settings.deleteShape === "boolean")
            this.deleteShape = settings.deleteShape;
        if (typeof settings.deleteConnector === "boolean")
            this.deleteConnector = settings.deleteConnector;
        if (typeof settings.changeConnection === "boolean")
            this.changeConnection = settings.changeConnection;
        if (typeof settings.changeConnectorPoints === "boolean")
            this.changeConnectorPoints = settings.changeConnectorPoints;
        if (typeof settings.changeShapeText === "boolean")
            this.changeShapeText = settings.changeShapeText;
        if (typeof settings.changeConnectorText === "boolean")
            this.changeConnectorText = settings.changeConnectorText;
        if (typeof settings.resizeShape === "boolean")
            this.resizeShape = settings.resizeShape;
        if (typeof settings.moveShape === "boolean")
            this.moveShape = settings.moveShape;
    };
    return ModelOperationSettings;
}());
exports.ModelOperationSettings = ModelOperationSettings;
var DiagramModelOperation;
(function (DiagramModelOperation) {
    DiagramModelOperation[DiagramModelOperation["AddShape"] = 0] = "AddShape";
    DiagramModelOperation[DiagramModelOperation["AddShapeFromToolbox"] = 1] = "AddShapeFromToolbox";
    DiagramModelOperation[DiagramModelOperation["DeleteShape"] = 2] = "DeleteShape";
    DiagramModelOperation[DiagramModelOperation["DeleteConnector"] = 3] = "DeleteConnector";
    DiagramModelOperation[DiagramModelOperation["ChangeConnection"] = 4] = "ChangeConnection";
    DiagramModelOperation[DiagramModelOperation["ChangeConnectorPoints"] = 5] = "ChangeConnectorPoints";
    DiagramModelOperation[DiagramModelOperation["BeforeChangeShapeText"] = 6] = "BeforeChangeShapeText";
    DiagramModelOperation[DiagramModelOperation["ChangeShapeText"] = 7] = "ChangeShapeText";
    DiagramModelOperation[DiagramModelOperation["BeforeChangeConnectorText"] = 8] = "BeforeChangeConnectorText";
    DiagramModelOperation[DiagramModelOperation["ChangeConnectorText"] = 9] = "ChangeConnectorText";
    DiagramModelOperation[DiagramModelOperation["ResizeShape"] = 10] = "ResizeShape";
    DiagramModelOperation[DiagramModelOperation["MoveShape"] = 11] = "MoveShape";
})(DiagramModelOperation = exports.DiagramModelOperation || (exports.DiagramModelOperation = {}));


/***/ }),
/* 17 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.raiseEvent = exports.RenderUtils = void 0;
var Event_1 = __webpack_require__(11);
var math_1 = __webpack_require__(31);
var RenderUtils = (function () {
    function RenderUtils() {
    }
    RenderUtils.updateSvgElementSize = function (svgElement, width, height, forExport) {
        svgElement.style.width = width + "px";
        svgElement.style.height = height + "px";
        svgElement.setAttribute("viewBox", "0 0 " + width + " " + height);
        if (forExport) {
            svgElement.setAttribute("width", width.toString());
            svgElement.setAttribute("height", height.toString());
        }
    };
    RenderUtils.removeElement = function (element) {
        element && element.parentNode && element.parentNode.removeChild(element);
    };
    RenderUtils.removeContent = function (element) {
        while (element && element.firstChild)
            element.removeChild(element.firstChild);
    };
    RenderUtils.setElementEventData = function (element, type, key, value) {
        if (type === Event_1.MouseEventElementType.Undefined)
            return;
        element.setAttribute("data-type", type.toString());
        if (key !== undefined)
            element.setAttribute("data-key", key.toString());
        if (value !== undefined)
            element.setAttribute("data-value", value.toString());
    };
    RenderUtils.getElementEventData = function (element) {
        if (element.getAttribute && element.getAttribute("data-type"))
            return new Event_1.MouseEventSource(parseInt(element.getAttribute("data-type")), element.getAttribute("data-key"), element.getAttribute("data-value"));
        var className = element.getAttribute && element.getAttribute("class");
        if (className === "dxdi-page" || className === "dxdi-main")
            return new Event_1.MouseEventSource(Event_1.MouseEventElementType.Document);
    };
    RenderUtils.getHtmlElementStylePropertyName = function (propertyName) {
        switch (propertyName) {
            case "fill":
                return "color";
            case "text-anchor":
                return "text-align";
        }
        return propertyName;
    };
    RenderUtils.getTextAnchorValue = function (propertyValue, reverseTextAnchor) {
        if (reverseTextAnchor === void 0) { reverseTextAnchor = false; }
        if (reverseTextAnchor) {
            if (propertyValue === "start")
                return "end";
            if (propertyValue === "end")
                return "start";
        }
        return propertyValue;
    };
    RenderUtils.getStrokeDasharrayValue = function (propertyValue, strokeWidth) {
        if (strokeWidth) {
            var dashArray = propertyValue && propertyValue.toString();
            var dashArrayParts = dashArray ? dashArray.split(/[\s,]+/) : [];
            return dashArrayParts.map(function (v) { return parseInt(v) / 2 * strokeWidth; }).join(",");
        }
        return propertyValue;
    };
    RenderUtils.applyStyleToElement = function (style, element, reverseTextAnchor) {
        var _this = this;
        if (reverseTextAnchor === void 0) { reverseTextAnchor = false; }
        var defaultStyle = style.getDefaultInstance();
        style.forEach(function (propertyName) {
            var propertyValue = style[propertyName];
            var elPropertyName = (element instanceof HTMLElement) ? _this.getHtmlElementStylePropertyName(propertyName) : propertyName;
            if (propertyValue !== undefined && propertyValue !== "" && propertyValue !== defaultStyle[propertyName]) {
                switch (propertyName) {
                    case "text-anchor":
                        propertyValue = _this.getTextAnchorValue(propertyValue, reverseTextAnchor);
                        break;
                    case "stroke-dasharray":
                        propertyValue = _this.getStrokeDasharrayValue(propertyValue, parseInt(style["stroke-width"]));
                        break;
                }
                element.style.setProperty(elPropertyName, propertyValue);
            }
            else
                element.style.setProperty(elPropertyName, "");
        });
    };
    RenderUtils.generateSvgElementId = function (prefix) {
        return prefix + "_" + math_1.MathUtils.generateGuid();
    };
    RenderUtils.getUrlPathById = function (id) {
        return "url(#" + id + ")";
    };
    return RenderUtils;
}());
exports.RenderUtils = RenderUtils;
function raiseEvent(evt, _evt, raiseFunc) {
    raiseFunc(_evt);
    if (_evt.preventDefault)
        evt.preventDefault();
}
exports.raiseEvent = raiseEvent;


/***/ }),
/* 18 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

Object.defineProperty(exports, "__esModule", { value: true });
var Browser = (function () {
    function Browser() {
    }
    Browser.IdentUserAgent = function (userAgent, ignoreDocumentMode) {
        if (ignoreDocumentMode === void 0) { ignoreDocumentMode = false; }
        var browserTypesOrderedList = ['Mozilla', 'IE', 'Firefox', 'Netscape', 'Safari', 'Chrome', 'Opera', 'Opera10', 'Edge'];
        var defaultBrowserType = 'IE';
        var defaultPlatform = 'Win';
        var defaultVersions = { Safari: 2, Chrome: 0.1, Mozilla: 1.9, Netscape: 8, Firefox: 2, Opera: 9, IE: 6, Edge: 12 };
        if (!userAgent || userAgent.length === 0) {
            Browser.fillUserAgentInfo(browserTypesOrderedList, defaultBrowserType, defaultVersions[defaultBrowserType], defaultPlatform);
            return;
        }
        userAgent = userAgent.toLowerCase();
        Browser.indentPlatformMajorVersion(userAgent);
        try {
            var platformIdentStrings = {
                'Windows': 'Win',
                'Macintosh': 'Mac',
                'Mac OS': 'Mac',
                'Mac_PowerPC': 'Mac',
                'cpu os': 'MacMobile',
                'cpu iphone os': 'MacMobile',
                'Android': 'Android',
                '!Windows Phone': 'WinPhone',
                '!WPDesktop': 'WinPhone',
                '!ZuneWP': 'WinPhone'
            };
            var optSlashOrSpace = '(?:/|\\s*)?';
            var versionString = '(\\d+)(?:\\.((?:\\d+?[1-9])|\\d)0*?)?';
            var optVersion = '(?:' + versionString + ')?';
            var patterns = {
                Safari: 'applewebkit(?:.*?(?:version/' + versionString + '[\\.\\w\\d]*?(?:\\s+mobile/\\S*)?\\s+safari))?',
                Chrome: '(?:chrome|crios)(?!frame)' + optSlashOrSpace + optVersion,
                Mozilla: 'mozilla(?:.*rv:' + optVersion + '.*Gecko)?',
                Netscape: '(?:netscape|navigator)\\d*/?\\s*' + optVersion,
                Firefox: 'firefox' + optSlashOrSpace + optVersion,
                Opera: '(?:opera|\\sopr)' + optSlashOrSpace + optVersion,
                Opera10: 'opera.*\\s*version' + optSlashOrSpace + optVersion,
                IE: 'msie\\s*' + optVersion,
                Edge: 'edge' + optSlashOrSpace + optVersion
            };
            var browserType = null;
            var version = -1;
            for (var i = 0; i < browserTypesOrderedList.length; i++) {
                var browserTypeCandidate = browserTypesOrderedList[i];
                var regExp = new RegExp(patterns[browserTypeCandidate], 'i');
                var matches = regExp.exec(userAgent);
                if (matches && matches.index >= 0) {
                    if (browserType === 'IE' && version >= 11 && browserTypeCandidate === 'Safari')
                        continue;
                    browserType = browserTypeCandidate;
                    if (browserType === 'Opera10')
                        browserType = 'Opera';
                    var tridentPattern = 'trident' + optSlashOrSpace + optVersion;
                    version = Browser.GetBrowserVersion(userAgent, matches, tridentPattern, Browser.getIECompatibleVersionString());
                    if (browserType === 'Mozilla' && version >= 11)
                        browserType = 'IE';
                }
            }
            if (!browserType)
                browserType = defaultBrowserType;
            var browserVersionDetected = version !== -1;
            if (!browserVersionDetected)
                version = defaultVersions[browserType];
            var platform = null;
            var minOccurenceIndex = Number.MAX_VALUE;
            for (var identStr in platformIdentStrings) {
                if (!Object.prototype.hasOwnProperty.call(platformIdentStrings, identStr))
                    continue;
                var importantIdent = identStr.substr(0, 1) === '!';
                var occurenceIndex = userAgent.indexOf((importantIdent ? identStr.substr(1) : identStr).toLowerCase());
                if (occurenceIndex >= 0 && (occurenceIndex < minOccurenceIndex || importantIdent)) {
                    minOccurenceIndex = importantIdent ? 0 : occurenceIndex;
                    platform = platformIdentStrings[identStr];
                }
            }
            var samsungPattern = 'SM-[A-Z]';
            var m = userAgent.toUpperCase().match(samsungPattern);
            var isSamsungAndroidDevice = m && m.length > 0;
            if (platform === 'WinPhone' && version < 9)
                version = Math.floor(Browser.getVersionFromTrident(userAgent, 'trident' + optSlashOrSpace + optVersion));
            if (!ignoreDocumentMode && browserType === 'IE' && version > 7 && document.documentMode < version)
                version = document.documentMode;
            if (platform === 'WinPhone')
                version = Math.max(9, version);
            if (!platform)
                platform = defaultPlatform;
            if (platform === platformIdentStrings['cpu os'] && !browserVersionDetected)
                version = 4;
            Browser.fillUserAgentInfo(browserTypesOrderedList, browserType, version, platform, isSamsungAndroidDevice);
        }
        catch (e) {
            Browser.fillUserAgentInfo(browserTypesOrderedList, defaultBrowserType, defaultVersions[defaultBrowserType], defaultPlatform);
        }
    };
    Browser.GetBrowserVersion = function (userAgent, matches, tridentPattern, ieCompatibleVersionString) {
        var version = Browser.getVersionFromMatches(matches);
        if (ieCompatibleVersionString) {
            var versionFromTrident = Browser.getVersionFromTrident(userAgent, tridentPattern);
            if (ieCompatibleVersionString === 'edge' || parseInt(ieCompatibleVersionString) === versionFromTrident)
                return versionFromTrident;
        }
        return version;
    };
    Browser.getIECompatibleVersionString = function () {
        if (document.compatible) {
            for (var i = 0; i < document.compatible.length; i++) {
                if (document.compatible[i].userAgent === 'IE' && document.compatible[i].version)
                    return document.compatible[i].version.toLowerCase();
            }
        }
        return '';
    };
    Browser.isTouchEnabled = function () {
        return Browser.hasTouchStart() || Browser.hasMaxTouchPoints() || Browser.hasMsMaxTouchPoints();
    };
    Browser.hasTouchStart = function () {
        return ('ontouchstart' in window);
    };
    Browser.hasMaxTouchPoints = function () {
        return navigator['maxTouchPoints'] > 0;
    };
    Browser.hasMsMaxTouchPoints = function () {
        return navigator['msMaxTouchPoints'] > 0;
    };
    Browser.hasNavigator = function () {
        return typeof navigator !== 'undefined';
    };
    Browser.fillUserAgentInfo = function (browserTypesOrderedList, browserType, version, platform, isSamsungAndroidDevice) {
        if (isSamsungAndroidDevice === void 0) { isSamsungAndroidDevice = false; }
        for (var i = 0; i < browserTypesOrderedList.length; i++) {
            var type = browserTypesOrderedList[i];
            Browser[type] = type === browserType;
        }
        Browser.Version = Math.floor(10.0 * version) / 10.0;
        Browser.MajorVersion = Math.floor(Browser.Version);
        Browser.WindowsPlatform = platform === 'Win' || platform === 'WinPhone';
        Browser.MacOSMobilePlatform = platform === 'MacMobile' || (platform === 'Mac' && Browser.isTouchEnabled());
        Browser.MacOSPlatform = platform === 'Mac' && !Browser.MacOSMobilePlatform;
        Browser.AndroidMobilePlatform = platform === 'Android';
        Browser.WindowsPhonePlatform = platform === 'WinPhone';
        Browser.WebKitFamily = Browser.Safari || Browser.Chrome || Browser.Opera && Browser.MajorVersion >= 15;
        Browser.NetscapeFamily = Browser.Netscape || Browser.Mozilla || Browser.Firefox;
        Browser.WebKitTouchUI = Browser.MacOSMobilePlatform || Browser.AndroidMobilePlatform;
        var isIETouchUI = Browser.IE && Browser.MajorVersion > 9 && Browser.WindowsPlatform && Browser.UserAgent.toLowerCase().indexOf('touch') >= 0;
        Browser.MSTouchUI = isIETouchUI || (Browser.Edge && !!window.navigator.maxTouchPoints);
        Browser.TouchUI = Browser.WebKitTouchUI || Browser.MSTouchUI;
        Browser.MobileUI = Browser.WebKitTouchUI || Browser.WindowsPhonePlatform;
        Browser.AndroidDefaultBrowser = Browser.AndroidMobilePlatform && !Browser.Chrome;
        Browser.AndroidChromeBrowser = Browser.AndroidMobilePlatform && Browser.Chrome;
        if (isSamsungAndroidDevice)
            Browser.SamsungAndroidDevice = isSamsungAndroidDevice;
        if (Browser.MSTouchUI) {
            var isARMArchitecture = Browser.UserAgent.toLowerCase().indexOf('arm;') > -1;
            Browser.VirtualKeyboardSupported = isARMArchitecture || Browser.WindowsPhonePlatform;
        }
        else
            Browser.VirtualKeyboardSupported = Browser.WebKitTouchUI;
        Browser.fillDocumentElementBrowserTypeClassNames(browserTypesOrderedList);
    };
    Browser.indentPlatformMajorVersion = function (userAgent) {
        var regex = /(?:(?:windows nt|macintosh|mac os|cpu os|cpu iphone os|android|windows phone|linux) )(\d+)(?:[-0-9_.])*/;
        var matches = regex.exec(userAgent);
        if (matches)
            Browser.PlaformMajorVersion = matches[1];
    };
    Browser.getVersionFromMatches = function (matches) {
        var result = -1;
        var versionStr = '';
        if (matches) {
            if (matches[1]) {
                versionStr += matches[1];
                if (matches[2])
                    versionStr += '.' + matches[2];
            }
            if (versionStr !== '') {
                result = parseFloat(versionStr);
                if (isNaN(result))
                    result = -1;
            }
        }
        return result;
    };
    Browser.getVersionFromTrident = function (userAgent, tridentPattern) {
        var tridentDiffFromVersion = 4;
        var matches = new RegExp(tridentPattern, 'i').exec(userAgent);
        return Browser.getVersionFromMatches(matches) + tridentDiffFromVersion;
    };
    Browser.fillDocumentElementBrowserTypeClassNames = function (browserTypesOrderedList) {
        var documentElementClassName = '';
        var browserTypeslist = browserTypesOrderedList.concat(['WindowsPlatform', 'MacOSPlatform', 'MacOSMobilePlatform', 'AndroidMobilePlatform',
            'WindowsPhonePlatform', 'WebKitFamily', 'WebKitTouchUI', 'MSTouchUI', 'TouchUI', 'AndroidDefaultBrowser']);
        for (var i = 0; i < browserTypeslist.length; i++) {
            var type = browserTypeslist[i];
            if (Browser[type])
                documentElementClassName += 'dx' + type + ' ';
        }
        documentElementClassName += 'dxBrowserVersion-' + Browser.MajorVersion;
        if (typeof document !== 'undefined' && document && document.documentElement) {
            if (document.documentElement.className !== '')
                documentElementClassName = ' ' + documentElementClassName;
            document.documentElement.className += documentElementClassName;
            Browser.Info = documentElementClassName;
        }
    };
    Browser.getUserAgent = function () {
        return Browser.hasNavigator() && navigator.userAgent ? navigator.userAgent.toLowerCase() : '';
    };
    Browser.UserAgent = Browser.getUserAgent();
    Browser._foo = Browser.IdentUserAgent(Browser.UserAgent);
    return Browser;
}());
exports.Browser = Browser;


/***/ }),
/* 19 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.RectangleShapeDescription = void 0;
var ShapeDescription_1 = __webpack_require__(7);
var size_1 = __webpack_require__(2);
var RectaglePrimitive_1 = __webpack_require__(21);
var ShapeTypes_1 = __webpack_require__(1);
var RectangleShapeDescription = (function (_super) {
    __extends(RectangleShapeDescription, _super);
    function RectangleShapeDescription(defaultSize, hasDefaultText) {
        if (defaultSize === void 0) { defaultSize = new size_1.Size(ShapeDescription_1.ShapeDefaultDimension, ShapeDescription_1.ShapeDefaultDimension * 0.75); }
        return _super.call(this, defaultSize, hasDefaultText) || this;
    }
    Object.defineProperty(RectangleShapeDescription.prototype, "key", {
        get: function () { return ShapeTypes_1.ShapeTypes.Rectangle; },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(RectangleShapeDescription.prototype, "keepRatioOnAutoSize", {
        get: function () { return false; },
        enumerable: false,
        configurable: true
    });
    RectangleShapeDescription.prototype.createShapePrimitives = function (shape) {
        var _a = shape.rectangle, left = _a.x, top = _a.y, width = _a.width, height = _a.height;
        return [
            new RectaglePrimitive_1.RectanglePrimitive(left, top, width, height, shape.style),
        ];
    };
    RectangleShapeDescription.prototype.getTextRectangle = function (shape) {
        return shape.rectangle.clone().inflate(-ShapeDescription_1.ShapeTextPadding, -ShapeDescription_1.ShapeTextPadding);
    };
    RectangleShapeDescription.prototype.getSizeByText = function (textSize, _shape) {
        return textSize.clone().offset(ShapeDescription_1.ShapeTextPadding * 2, ShapeDescription_1.ShapeTextPadding * 2);
    };
    return RectangleShapeDescription;
}(ShapeDescription_1.ShapeDescription));
exports.RectangleShapeDescription = RectangleShapeDescription;


/***/ }),
/* 20 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.Alignment = exports.DataLayoutOrientation = exports.LogicalDirectionKind = exports.TreeLayoutSettings = exports.LayoutSettings = void 0;
var Connector_1 = __webpack_require__(6);
var LayoutSettings = (function () {
    function LayoutSettings(gridSize) {
        this.orientation = DataLayoutOrientation.Vertical;
        this.direction = LogicalDirectionKind.Forward;
        var baseSpacing = (gridSize && gridSize * 2 > Connector_1.Connector.minOffset) ? gridSize * 2 : Connector_1.Connector.minOffset;
        this.columnSpacing = baseSpacing;
        this.layerSpacing = baseSpacing * 2;
        this.containerPadding = baseSpacing * 2;
        this.componentSpacing = baseSpacing * 2;
    }
    return LayoutSettings;
}());
exports.LayoutSettings = LayoutSettings;
var TreeLayoutSettings = (function (_super) {
    __extends(TreeLayoutSettings, _super);
    function TreeLayoutSettings(gridSize) {
        var _this = _super.call(this, gridSize) || this;
        _this.alignment = Alignment.Center;
        _this.subTreeColumnSpacing = _this.componentSpacing / 2;
        return _this;
    }
    return TreeLayoutSettings;
}(LayoutSettings));
exports.TreeLayoutSettings = TreeLayoutSettings;
var LogicalDirectionKind;
(function (LogicalDirectionKind) {
    LogicalDirectionKind[LogicalDirectionKind["Backward"] = 0] = "Backward";
    LogicalDirectionKind[LogicalDirectionKind["Forward"] = 1] = "Forward";
})(LogicalDirectionKind = exports.LogicalDirectionKind || (exports.LogicalDirectionKind = {}));
var DataLayoutOrientation;
(function (DataLayoutOrientation) {
    DataLayoutOrientation[DataLayoutOrientation["Horizontal"] = 0] = "Horizontal";
    DataLayoutOrientation[DataLayoutOrientation["Vertical"] = 1] = "Vertical";
})(DataLayoutOrientation = exports.DataLayoutOrientation || (exports.DataLayoutOrientation = {}));
var Alignment;
(function (Alignment) {
    Alignment[Alignment["Left"] = 0] = "Left";
    Alignment[Alignment["Center"] = 1] = "Center";
})(Alignment = exports.Alignment || (exports.Alignment = {}));


/***/ }),
/* 21 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.RectanglePrimitive = void 0;
var RenderHelper_1 = __webpack_require__(15);
var Primitive_1 = __webpack_require__(24);
var RectanglePrimitive = (function (_super) {
    __extends(RectanglePrimitive, _super);
    function RectanglePrimitive(x, y, width, height, style, className, clipPathId, onApplyProperties) {
        var _this = _super.call(this, style, className, clipPathId, onApplyProperties) || this;
        _this.x = x;
        _this.y = y;
        _this.width = width;
        _this.height = height;
        return _this;
    }
    RectanglePrimitive.prototype.createMainElement = function () {
        return document.createElementNS(RenderHelper_1.svgNS, "rect");
    };
    RectanglePrimitive.prototype.applyElementProperties = function (element, measurer) {
        this.setUnitAttribute(element, "x", this.x);
        this.setUnitAttribute(element, "y", this.y);
        this.setUnitAttribute(element, "width", this.width);
        this.setUnitAttribute(element, "height", this.height);
        this.setPositionCorrectionAttribute(element);
        _super.prototype.applyElementProperties.call(this, element, measurer);
    };
    return RectanglePrimitive;
}(Primitive_1.SvgPrimitive));
exports.RectanglePrimitive = RectanglePrimitive;


/***/ }),
/* 22 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

Object.defineProperty(exports, "__esModule", { value: true });
var string_1 = __webpack_require__(49);
var ColorUtils = (function () {
    function ColorUtils() {
    }
    ColorUtils.getAlpha = function (color) {
        return (color >> 24) & 255;
    };
    ColorUtils.getRed = function (color) {
        return (color >> 16) & 255;
    };
    ColorUtils.getGreen = function (color) {
        return (color >> 8) & 255;
    };
    ColorUtils.getBlue = function (color) {
        return color & 255;
    };
    ColorUtils.redPartToString = function (color) {
        var redStr = ColorUtils.getRed(color).toString(16);
        return redStr.length > 1 ? redStr : '0' + redStr;
    };
    ColorUtils.greenPartToString = function (color) {
        var greenStr = ColorUtils.getGreen(color).toString(16);
        return greenStr.length > 1 ? greenStr : '0' + greenStr;
    };
    ColorUtils.bluePartToString = function (color) {
        var blueStr = ColorUtils.getBlue(color).toString(16);
        return blueStr.length > 1 ? blueStr : '0' + blueStr;
    };
    ColorUtils.fromArgbNumber = function (alpha, red, green, blue) {
        return (alpha << 24) | (red << 16) | (green << 8) | blue;
    };
    ColorUtils.fromRgbaString = function (color, alpha) {
        if (alpha === void 0) { alpha = 255; }
        var matchesRGBA = color.replace(/ +/g, '').match(/(rgba?)|(\d+(\.\d+)?%?)|(\.\d+)/g);
        if (matchesRGBA && matchesRGBA.length > 3) {
            var result = [];
            for (var i = 1, matchItem = void 0; matchItem = matchesRGBA[i]; i++) {
                var item = matchItem.indexOf('%') !== -1 ?
                    Math.round(parseFloat(matchItem) * 2.55) :
                    parseInt(matchItem);
                if (item < 0 || item > 255)
                    return null;
                result.push(item);
            }
            if (color.indexOf('rgba') === 0) {
                if (isNaN(result[3]) || result[3] < 0 || result[3] > 1)
                    return null;
                else if (result[3] <= 1)
                    result[3] = Math.round(result[3] * 255);
            }
            else if (result[3])
                return null;
            return ((result[0] & 255) << 16) | ((result[1] & 255) << 8) | (result[2] & 255) |
                (((result.length > 3 ? result[3] : alpha) & 255) << 24);
        }
        return null;
    };
    ColorUtils.fromHashString = function (hash, alpha) {
        if (alpha === void 0) { alpha = 255; }
        if (!ColorUtils.isHashColorString(hash))
            return null;
        if (hash.charAt(0) === '#')
            hash = hash.substr(1);
        if (hash.length === 3)
            hash = string_1.StringUtils.repeat(hash.charAt(0), 2) + string_1.StringUtils.repeat(hash.charAt(1), 2) + string_1.StringUtils.repeat(hash.charAt(2), 2);
        return parseInt(hash, 16) | (alpha << 24);
    };
    ColorUtils.fromColorName = function (color, alpha) {
        if (alpha === void 0) { alpha = 255; }
        var colorNameAsHash = ColorUtils.colorNames[color.toLowerCase()];
        return colorNameAsHash ? ColorUtils.fromHashString(colorNameAsHash, alpha) : null;
    };
    ColorUtils.fromString = function (color, alpha) {
        if (alpha === void 0) { alpha = 255; }
        var rgbaColor = ColorUtils.fromRgbaString(color, alpha);
        if (rgbaColor !== null)
            return rgbaColor;
        var hashColor = ColorUtils.fromHashString(color, alpha);
        if (hashColor !== null)
            return hashColor;
        return ColorUtils.fromColorName(color, alpha);
    };
    ColorUtils.colorToHash = function (color) {
        return '#' + ColorUtils.redPartToString(color) + ColorUtils.greenPartToString(color) + ColorUtils.bluePartToString(color);
    };
    ColorUtils.stringToHash = function (color) {
        var result = this.fromString(color);
        return result !== null ? this.colorToHash(result) : null;
    };
    ColorUtils.isHashColorString = function (color) {
        return /^#?([0-9a-f]{6})$/i.test(color) || /^#?([0-9a-f]{3})$/i.test(color);
    };
    ColorUtils.isKnownColorName = function (color) {
        return !!ColorUtils.colorNames[color.toLowerCase()];
    };
    ColorUtils.isGray = function (color) {
        var red = ColorUtils.getRed(color);
        return red === ColorUtils.getGreen(color) && red === ColorUtils.getBlue(color);
    };
    ColorUtils.DARK_COLOR = -16777216;
    ColorUtils.LIGHT_COLOR = -1;
    ColorUtils.colorNames = {
        aliceblue: '#f0f8ff', antiquewhite: '#faebd7', aqua: '#00ffff',
        aquamarine: '#7fffd4', azure: '#f0ffff', beige: '#f5f5dc',
        bisque: '#ffe4c4', black: '#000000', blanchedalmond: '#ffebcd',
        blue: '#0000ff', blueviolet: '#8a2be2', brown: '#a52a2a',
        burlywood: '#deb887', cadetblue: '#5f9ea0', chartreuse: '#7fff00',
        chocolate: '#d2691e', coral: '#ff7f50', cornflowerblue: '#6495ed',
        cornsilk: '#fff8dc', crimson: '#dc143c', cyan: '#00ffff',
        darkblue: '#00008b', darkcyan: '#008b8b', darkgoldenrod: '#b8860b',
        darkgray: '#a9a9a9', darkgreen: '#006400', darkkhaki: '#bdb76b',
        darkmagenta: '#8b008b', darkolivegreen: '#556b2f', darkorange: '#ff8c00',
        darkorchid: '#9932cc', darkred: '#8b0000', darksalmon: '#e9967a',
        darkseagreen: '#8fbc8f', darkslateblue: '#483d8b', darkslategray: '#2f4f4f',
        darkturquoise: '#00ced1', darkviolet: '#9400d3', deeppink: '#ff1493',
        deepskyblue: '#00bfff', dimgray: '#696969', dodgerblue: '#1e90ff',
        feldspar: '#d19275', firebrick: '#b22222', floralwhite: '#fffaf0',
        forestgreen: '#228b22', fuchsia: '#ff00ff', gainsboro: '#dcdcdc',
        ghostwhite: '#f8f8ff', gold: '#ffd700', goldenrod: '#daa520', gray: '#808080',
        green: '#00ff00', greenyellow: '#adff2f', honeydew: '#f0fff0', hotpink: '#ff69b4',
        indianred: '#cd5c5c', indigo: '#4b0082', ivory: '#fffff0', khaki: '#f0e68c',
        lavender: '#e6e6fa', lavenderblush: '#fff0f5', lawngreen: '#7cfc00',
        lemonchiffon: '#fffacd', lightblue: '#add8e6', lightcoral: '#f08080',
        lightcyan: '#e0ffff', lightgoldenrodyellow: '#fafad2', lightgray: '#d3d3d3',
        lightgreen: '#90ee90', lightpink: '#ffb6c1', lightsalmon: '#ffa07a',
        lightseagreen: '#20b2aa', lightskyblue: '#87cefa', lightslateblue: '#8470ff',
        lightslategray: '#778899', lightsteelblue: '#b0c4de', lightyellow: '#ffffe0',
        lime: '#00ff00', limegreen: '#32cd32', linen: '#faf0e6', magenta: '#ff00ff',
        maroon: '#800000', mediumaquamarine: '#66cdaa', mediumblue: '#0000cd',
        mediumorchid: '#ba55d3', mediumpurple: '#9370d8', mediumseagreen: '#3cb371',
        mediumslateblue: '#7b68ee', mediumspringgreen: '#00fa9a', mediumturquoise: '#48d1cc',
        mediumvioletred: '#c71585', midnightblue: '#191970', mintcream: '#f5fffa',
        mistyrose: '#ffe4e1', moccasin: '#ffe4b5', navajowhite: '#ffdead', navy: '#000080',
        oldlace: '#fdf5e6', olive: '#808000', olivedrab: '#6b8e23', orange: '#ffa500',
        orangered: '#ff4500', orchid: '#da70d6', palegoldenrod: '#eee8aa', palegreen: '#98fb98',
        paleturquoise: '#afeeee', palevioletred: '#d87093', papayawhip: '#ffefd5',
        peachpuff: '#ffdab9', peru: '#cd853f', pink: '#ffc0cb', plum: '#dda0dd',
        powderblue: '#b0e0e6', purple: '#800080', red: '#ff0000', rosybrown: '#bc8f8f',
        royalblue: '#4169e1', saddlebrown: '#8b4513', salmon: '#fa8072', sandybrown: '#f4a460',
        seagreen: '#2e8b57', seashell: '#fff5ee', sienna: '#a0522d', silver: '#c0c0c0',
        skyblue: '#87ceeb', slateblue: '#6a5acd', slategray: '#708090', snow: '#fffafa',
        springgreen: '#00ff7f', steelblue: '#4682b4', tan: '#d2b48c', teal: '#008080',
        thistle: '#d8bfd8', tomato: '#ff6347', turquoise: '#40e0d0', violet: '#ee82ee',
        violetred: '#d02090', wheat: '#f5deb3', white: '#ffffff', whitesmoke: '#f5f5f5',
        yellow: '#ffff00', yellowgreen: '#9acd32', windowtext: '#000000'
    };
    return ColorUtils;
}());
exports.ColorUtils = ColorUtils;


/***/ }),
/* 23 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.PermissionRequestEventArgs = exports.RequestedEntity = void 0;
var RequestedEntity = (function () {
    function RequestedEntity(apiController) {
        this.apiController = apiController;
    }
    Object.defineProperty(RequestedEntity.prototype, "allowed", {
        get: function () {
            return this.eventArgs.allowed;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(RequestedEntity.prototype, "updateUI", {
        get: function () {
            return this.eventArgs.updateUI;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(RequestedEntity.prototype, "eventArgs", {
        get: function () {
            if (!this._eventArgs)
                this._eventArgs = this.createEventArgs();
            return this._eventArgs;
        },
        enumerable: false,
        configurable: true
    });
    return RequestedEntity;
}());
exports.RequestedEntity = RequestedEntity;
var PermissionRequestEventArgs = (function () {
    function PermissionRequestEventArgs() {
        this.allowed = true;
        this.updateUI = false;
    }
    return PermissionRequestEventArgs;
}());
exports.PermissionRequestEventArgs = PermissionRequestEventArgs;


/***/ }),
/* 24 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.SvgPrimitive = void 0;
var Utils_1 = __webpack_require__(17);
var PrimitiveObject_1 = __webpack_require__(109);
var SvgPrimitive = (function (_super) {
    __extends(SvgPrimitive, _super);
    function SvgPrimitive(style, className, clipPathId, onApplyProperties) {
        var _this = _super.call(this, style) || this;
        _this.className = className;
        _this.clipPathId = clipPathId;
        _this.onApplyProperties = onApplyProperties;
        _this.children = [];
        return _this;
    }
    SvgPrimitive.prototype.createElement = function (insertInDOM) {
        var el = this.createMainElement();
        this.createChildElements(el);
        insertInDOM(el);
        this.createCustomContent(el);
        return el;
    };
    SvgPrimitive.prototype.createChildElements = function (parent) {
        for (var i = 0; i < this.children.length; i++)
            this.children[i].createElement(function (el) { return parent.appendChild(el); });
    };
    SvgPrimitive.prototype.applyElementProperties = function (element, measurer) {
        this.applyElementStyleProperties(element);
        if (this.className)
            element.setAttribute("class", this.className);
        if (typeof this.clipPathId === "string")
            if (this.clipPathId)
                element.setAttribute("clip-path", Utils_1.RenderUtils.getUrlPathById(this.clipPathId));
            else
                element.removeAttribute("clip-path");
        if (this.onApplyProperties)
            this.onApplyProperties(element);
        this.applyChildrenProperties(element, measurer);
    };
    SvgPrimitive.prototype.applyChildrenProperties = function (element, measurer) {
        for (var i = 0; i < this.children.length; i++)
            this.children[i].applyElementProperties(element.childNodes[i], measurer);
    };
    SvgPrimitive.prototype.applyElementStyleProperties = function (element) {
        this.applyElementStylePropertiesCore(element);
    };
    SvgPrimitive.prototype.applyElementStylePropertiesCore = function (element, reverseTextAnchor) {
        if (reverseTextAnchor === void 0) { reverseTextAnchor = false; }
        if (this.style)
            Utils_1.RenderUtils.applyStyleToElement(this.style, element, reverseTextAnchor);
    };
    SvgPrimitive.prototype.createCustomContent = function (parent) {
    };
    SvgPrimitive.prototype.destroyCustomContent = function (parent) {
    };
    SvgPrimitive.prototype.dispose = function () {
        if (this.children)
            this.children.forEach(function (primitive) { return primitive.dispose(); });
    };
    return SvgPrimitive;
}(PrimitiveObject_1.PrimitiveObject));
exports.SvgPrimitive = SvgPrimitive;


/***/ }),
/* 25 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

Object.defineProperty(exports, "__esModule", { value: true });
var browser_1 = __webpack_require__(18);
var encode_1 = __webpack_require__(173);
var string_1 = __webpack_require__(49);
var KeyUtils = (function () {
    function KeyUtils() {
    }
    KeyUtils.getKeyModifiers = function (evt) {
        var result = 0;
        if (evt.altKey)
            result |= ModifierKey.Alt;
        if (evt.ctrlKey)
            result |= ModifierKey.Ctrl;
        if (evt.shiftKey)
            result |= ModifierKey.Shift;
        if (evt.metaKey)
            result |= ModifierKey.Meta;
        return result;
    };
    KeyUtils.getShortcutCode = function (keyCode, isCtrlKey, isShiftKey, isAltKey, isMetaKey) {
        var value = keyCode;
        value |= isCtrlKey ? ModifierKey.Ctrl : 0;
        value |= isShiftKey ? ModifierKey.Shift : 0;
        value |= isAltKey ? ModifierKey.Alt : 0;
        value |= isMetaKey ? ModifierKey.Meta : 0;
        return value;
    };
    KeyUtils.getShortcutCodeByEvent = function (evt) {
        return KeyUtils.getShortcutCode(KeyUtils.getEventKeyCode(evt), evt.ctrlKey, evt.shiftKey, evt.altKey, browser_1.Browser.MacOSPlatform ? evt.metaKey : false);
    };
    KeyUtils.getEventKeyCode = function (evt) {
        return browser_1.Browser.NetscapeFamily || browser_1.Browser.Opera ? evt.which : evt.keyCode;
    };
    KeyUtils.parseShortcutString = function (shortcutString) {
        if (!shortcutString)
            return 0;
        var isCtrlKey = false;
        var isShiftKey = false;
        var isAltKey = false;
        var isMetaKey = false;
        var keyCode = null;
        var shcKeys = shortcutString.toString().split('+');
        if (shcKeys.length > 0) {
            for (var i = 0; i < shcKeys.length; i++) {
                var key = string_1.StringUtils.trim(shcKeys[i].toUpperCase());
                switch (key) {
                    case 'CONTROL':
                    case 'CONTROLKEY':
                    case 'CTRL':
                        isCtrlKey = true;
                        break;
                    case 'SHIFT':
                    case 'SHIFTKEY':
                        isShiftKey = true;
                        break;
                    case 'ALT':
                        isAltKey = true;
                        break;
                    case 'CMD':
                        isMetaKey = true;
                        break;
                    case 'F1':
                        keyCode = KeyCode.F1;
                        break;
                    case 'F2':
                        keyCode = KeyCode.F2;
                        break;
                    case 'F3':
                        keyCode = KeyCode.F3;
                        break;
                    case 'F4':
                        keyCode = KeyCode.F4;
                        break;
                    case 'F5':
                        keyCode = KeyCode.F5;
                        break;
                    case 'F6':
                        keyCode = KeyCode.F6;
                        break;
                    case 'F7':
                        keyCode = KeyCode.F7;
                        break;
                    case 'F8':
                        keyCode = KeyCode.F8;
                        break;
                    case 'F9':
                        keyCode = KeyCode.F9;
                        break;
                    case 'F10':
                        keyCode = KeyCode.F10;
                        break;
                    case 'F11':
                        keyCode = KeyCode.F11;
                        break;
                    case 'F12':
                        keyCode = KeyCode.F12;
                        break;
                    case 'RETURN':
                    case 'ENTER':
                        keyCode = KeyCode.Enter;
                        break;
                    case 'HOME':
                        keyCode = KeyCode.Home;
                        break;
                    case 'END':
                        keyCode = KeyCode.End;
                        break;
                    case 'LEFT':
                        keyCode = KeyCode.Left;
                        break;
                    case 'RIGHT':
                        keyCode = KeyCode.Right;
                        break;
                    case 'UP':
                        keyCode = KeyCode.Up;
                        break;
                    case 'DOWN':
                        keyCode = KeyCode.Down;
                        break;
                    case 'PAGEUP':
                        keyCode = KeyCode.PageUp;
                        break;
                    case 'PAGEDOWN':
                        keyCode = KeyCode.PageDown;
                        break;
                    case 'SPACE':
                        keyCode = KeyCode.Space;
                        break;
                    case 'TAB':
                        keyCode = KeyCode.Tab;
                        break;
                    case 'BACKSPACE':
                    case 'BACK':
                        keyCode = KeyCode.Backspace;
                        break;
                    case 'CONTEXT':
                        keyCode = KeyCode.ContextMenu;
                        break;
                    case 'ESCAPE':
                    case 'ESC':
                        keyCode = KeyCode.Esc;
                        break;
                    case 'DELETE':
                    case 'DEL':
                        keyCode = KeyCode.Delete;
                        break;
                    case 'INSERT':
                    case 'INS':
                        keyCode = KeyCode.Insert;
                        break;
                    case 'PLUS':
                        keyCode = '+'.charCodeAt(0);
                        break;
                    default:
                        keyCode = key.charCodeAt(0);
                        break;
                }
            }
        }
        else
            alert(encode_1.EncodeUtils.decodeViaTextArea('Invalid shortcut'));
        return KeyUtils.getShortcutCode(keyCode, isCtrlKey, isShiftKey, isAltKey, isMetaKey);
    };
    return KeyUtils;
}());
exports.KeyUtils = KeyUtils;
var ModifierKey;
(function (ModifierKey) {
    ModifierKey[ModifierKey["None"] = 0] = "None";
    ModifierKey[ModifierKey["Ctrl"] = 65536] = "Ctrl";
    ModifierKey[ModifierKey["Shift"] = 262144] = "Shift";
    ModifierKey[ModifierKey["Alt"] = 1048576] = "Alt";
    ModifierKey[ModifierKey["Meta"] = 16777216] = "Meta";
})(ModifierKey = exports.ModifierKey || (exports.ModifierKey = {}));
var KeyCode;
(function (KeyCode) {
    KeyCode[KeyCode["Backspace"] = 8] = "Backspace";
    KeyCode[KeyCode["Tab"] = 9] = "Tab";
    KeyCode[KeyCode["Enter"] = 13] = "Enter";
    KeyCode[KeyCode["Pause"] = 19] = "Pause";
    KeyCode[KeyCode["CapsLock"] = 20] = "CapsLock";
    KeyCode[KeyCode["Esc"] = 27] = "Esc";
    KeyCode[KeyCode["Space"] = 32] = "Space";
    KeyCode[KeyCode["PageUp"] = 33] = "PageUp";
    KeyCode[KeyCode["PageDown"] = 34] = "PageDown";
    KeyCode[KeyCode["End"] = 35] = "End";
    KeyCode[KeyCode["Home"] = 36] = "Home";
    KeyCode[KeyCode["Left"] = 37] = "Left";
    KeyCode[KeyCode["Up"] = 38] = "Up";
    KeyCode[KeyCode["Right"] = 39] = "Right";
    KeyCode[KeyCode["Down"] = 40] = "Down";
    KeyCode[KeyCode["Insert"] = 45] = "Insert";
    KeyCode[KeyCode["Delete"] = 46] = "Delete";
    KeyCode[KeyCode["Key_0"] = 48] = "Key_0";
    KeyCode[KeyCode["Key_1"] = 49] = "Key_1";
    KeyCode[KeyCode["Key_2"] = 50] = "Key_2";
    KeyCode[KeyCode["Key_3"] = 51] = "Key_3";
    KeyCode[KeyCode["Key_4"] = 52] = "Key_4";
    KeyCode[KeyCode["Key_5"] = 53] = "Key_5";
    KeyCode[KeyCode["Key_6"] = 54] = "Key_6";
    KeyCode[KeyCode["Key_7"] = 55] = "Key_7";
    KeyCode[KeyCode["Key_8"] = 56] = "Key_8";
    KeyCode[KeyCode["Key_9"] = 57] = "Key_9";
    KeyCode[KeyCode["Key_a"] = 65] = "Key_a";
    KeyCode[KeyCode["Key_b"] = 66] = "Key_b";
    KeyCode[KeyCode["Key_c"] = 67] = "Key_c";
    KeyCode[KeyCode["Key_d"] = 68] = "Key_d";
    KeyCode[KeyCode["Key_e"] = 69] = "Key_e";
    KeyCode[KeyCode["Key_f"] = 70] = "Key_f";
    KeyCode[KeyCode["Key_g"] = 71] = "Key_g";
    KeyCode[KeyCode["Key_h"] = 72] = "Key_h";
    KeyCode[KeyCode["Key_i"] = 73] = "Key_i";
    KeyCode[KeyCode["Key_j"] = 74] = "Key_j";
    KeyCode[KeyCode["Key_k"] = 75] = "Key_k";
    KeyCode[KeyCode["Key_l"] = 76] = "Key_l";
    KeyCode[KeyCode["Key_m"] = 77] = "Key_m";
    KeyCode[KeyCode["Key_n"] = 78] = "Key_n";
    KeyCode[KeyCode["Key_o"] = 79] = "Key_o";
    KeyCode[KeyCode["Key_p"] = 80] = "Key_p";
    KeyCode[KeyCode["Key_q"] = 81] = "Key_q";
    KeyCode[KeyCode["Key_r"] = 82] = "Key_r";
    KeyCode[KeyCode["Key_s"] = 83] = "Key_s";
    KeyCode[KeyCode["Key_t"] = 84] = "Key_t";
    KeyCode[KeyCode["Key_u"] = 85] = "Key_u";
    KeyCode[KeyCode["Key_v"] = 86] = "Key_v";
    KeyCode[KeyCode["Key_w"] = 87] = "Key_w";
    KeyCode[KeyCode["Key_x"] = 88] = "Key_x";
    KeyCode[KeyCode["Key_y"] = 89] = "Key_y";
    KeyCode[KeyCode["Key_z"] = 90] = "Key_z";
    KeyCode[KeyCode["Windows"] = 91] = "Windows";
    KeyCode[KeyCode["ContextMenu"] = 93] = "ContextMenu";
    KeyCode[KeyCode["Numpad_0"] = 96] = "Numpad_0";
    KeyCode[KeyCode["Numpad_1"] = 97] = "Numpad_1";
    KeyCode[KeyCode["Numpad_2"] = 98] = "Numpad_2";
    KeyCode[KeyCode["Numpad_3"] = 99] = "Numpad_3";
    KeyCode[KeyCode["Numpad_4"] = 100] = "Numpad_4";
    KeyCode[KeyCode["Numpad_5"] = 101] = "Numpad_5";
    KeyCode[KeyCode["Numpad_6"] = 102] = "Numpad_6";
    KeyCode[KeyCode["Numpad_7"] = 103] = "Numpad_7";
    KeyCode[KeyCode["Numpad_8"] = 104] = "Numpad_8";
    KeyCode[KeyCode["Numpad_9"] = 105] = "Numpad_9";
    KeyCode[KeyCode["Multiply"] = 106] = "Multiply";
    KeyCode[KeyCode["Add"] = 107] = "Add";
    KeyCode[KeyCode["Subtract"] = 109] = "Subtract";
    KeyCode[KeyCode["Decimal"] = 110] = "Decimal";
    KeyCode[KeyCode["Divide"] = 111] = "Divide";
    KeyCode[KeyCode["F1"] = 112] = "F1";
    KeyCode[KeyCode["F2"] = 113] = "F2";
    KeyCode[KeyCode["F3"] = 114] = "F3";
    KeyCode[KeyCode["F4"] = 115] = "F4";
    KeyCode[KeyCode["F5"] = 116] = "F5";
    KeyCode[KeyCode["F6"] = 117] = "F6";
    KeyCode[KeyCode["F7"] = 118] = "F7";
    KeyCode[KeyCode["F8"] = 119] = "F8";
    KeyCode[KeyCode["F9"] = 120] = "F9";
    KeyCode[KeyCode["F10"] = 121] = "F10";
    KeyCode[KeyCode["F11"] = 122] = "F11";
    KeyCode[KeyCode["F12"] = 123] = "F12";
    KeyCode[KeyCode["NumLock"] = 144] = "NumLock";
    KeyCode[KeyCode["ScrollLock"] = 145] = "ScrollLock";
    KeyCode[KeyCode["Semicolon"] = 186] = "Semicolon";
    KeyCode[KeyCode["Equals"] = 187] = "Equals";
    KeyCode[KeyCode["Comma"] = 188] = "Comma";
    KeyCode[KeyCode["Dash"] = 189] = "Dash";
    KeyCode[KeyCode["Period"] = 190] = "Period";
    KeyCode[KeyCode["ForwardSlash"] = 191] = "ForwardSlash";
    KeyCode[KeyCode["GraveAccent"] = 192] = "GraveAccent";
    KeyCode[KeyCode["OpenBracket"] = 219] = "OpenBracket";
    KeyCode[KeyCode["BackSlash"] = 220] = "BackSlash";
    KeyCode[KeyCode["CloseBracket"] = 221] = "CloseBracket";
    KeyCode[KeyCode["SingleQuote"] = 222] = "SingleQuote";
})(KeyCode = exports.KeyCode || (exports.KeyCode = {}));


/***/ }),
/* 26 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.EmptyStyle = exports.StrokeStyle = exports.TextAlignment = exports.TextStyle = exports.Style = exports.DEFAULT_STROKE_DASHARRAY = exports.DEFAULT_STROKE_WIDTH = exports.StyleBase = void 0;
var color_1 = __webpack_require__(22);
var Svg_1 = __webpack_require__(110);
var unit_converter_1 = __webpack_require__(12);
var StyleBase = (function () {
    function StyleBase() {
        this.createDefaultProperties();
    }
    StyleBase.prototype.clone = function () {
        var _this = this;
        var style = this.createInstance();
        this.forEach(function (propertyName) { style[propertyName] = _this[propertyName]; });
        return style;
    };
    StyleBase.prototype.forEach = function (callback) {
        for (var propertyName in this)
            if (Object.prototype.hasOwnProperty.call(this, propertyName))
                callback(propertyName);
    };
    Object.defineProperty(StyleBase.prototype, "strokeWidthPx", {
        get: function () {
            return 0;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(StyleBase.prototype, "strokeWidth", {
        get: function () {
            return unit_converter_1.UnitConverter.pixelsToTwips(this.strokeWidthPx);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(StyleBase.prototype, "strokeOffset", {
        get: function () {
            return 0.5;
        },
        enumerable: false,
        configurable: true
    });
    StyleBase.prototype.toHash = function () {
        var obj = this.toObject();
        return !obj ? "" : Object.keys(obj).map(function (k) { return k + "|" + obj[k]; }).join("");
    };
    StyleBase.prototype.toObject = function () {
        var _this = this;
        var result = {};
        var modified = false;
        var defaultStyle = this.getDefaultInstance();
        this.forEach(function (key) {
            if (_this[key] !== defaultStyle[key]) {
                result[key] = _this[key];
                modified = true;
            }
        });
        return modified ? result : null;
    };
    StyleBase.prototype.fromObject = function (obj) {
        for (var key in obj)
            if (Object.prototype.hasOwnProperty.call(obj, key)) {
                var value = Svg_1.isColorProperty(key) ? color_1.ColorUtils.stringToHash(obj[key]) : obj[key];
                this[key] = value;
            }
    };
    return StyleBase;
}());
exports.StyleBase = StyleBase;
exports.DEFAULT_STROKE_WIDTH = 2;
exports.DEFAULT_STROKE_DASHARRAY = "";
var Style = (function (_super) {
    __extends(Style, _super);
    function Style() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    Style.prototype.createInstance = function () {
        return new Style();
    };
    Style.prototype.createDefaultProperties = function () {
        this["fill"] = "#ffffff";
        this["stroke"] = "#000000";
        this["stroke-width"] = exports.DEFAULT_STROKE_WIDTH.toString();
        this["stroke-dasharray"] = exports.DEFAULT_STROKE_DASHARRAY;
    };
    Style.prototype.getDefaultInstance = function () {
        return Style.defaultInstance;
    };
    Style.prototype.isDefaultStrokeDashArray = function () {
        return this["stroke-dasharray"] === exports.DEFAULT_STROKE_DASHARRAY;
    };
    Style.prototype.resetStrokeDashArray = function () {
        this["stroke-dasharray"] = exports.DEFAULT_STROKE_DASHARRAY;
    };
    Object.defineProperty(Style.prototype, "strokeWidthPx", {
        get: function () {
            return parseInt(this["stroke-width"]);
        },
        enumerable: false,
        configurable: true
    });
    Style.defaultInstance = new Style();
    return Style;
}(StyleBase));
exports.Style = Style;
var TextStyle = (function (_super) {
    __extends(TextStyle, _super);
    function TextStyle() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    TextStyle.prototype.createInstance = function () {
        return new TextStyle();
    };
    TextStyle.prototype.createDefaultProperties = function () {
        this["fill"] = "#000000";
        this["font-family"] = "Arial";
        this["font-size"] = "10pt";
        this["font-weight"] = "";
        this["font-style"] = "";
        this["text-decoration"] = "";
        this["text-anchor"] = "middle";
    };
    TextStyle.prototype.getDefaultInstance = function () {
        return TextStyle.defaultInstance;
    };
    TextStyle.prototype.getAlignment = function () {
        switch (this["text-anchor"]) {
            case "left":
                return TextAlignment.Left;
            case "right":
                return TextAlignment.Right;
            default:
                return TextAlignment.Center;
        }
    };
    TextStyle.defaultInstance = new TextStyle();
    return TextStyle;
}(StyleBase));
exports.TextStyle = TextStyle;
var TextAlignment;
(function (TextAlignment) {
    TextAlignment[TextAlignment["Left"] = 0] = "Left";
    TextAlignment[TextAlignment["Right"] = 1] = "Right";
    TextAlignment[TextAlignment["Center"] = 2] = "Center";
})(TextAlignment = exports.TextAlignment || (exports.TextAlignment = {}));
var StrokeStyle = (function (_super) {
    __extends(StrokeStyle, _super);
    function StrokeStyle(strokeWidthPx, strokeOffset) {
        var _this = _super.call(this) || this;
        _this._strokeWidthPx = strokeWidthPx;
        _this._strokeOffset = strokeOffset;
        return _this;
    }
    StrokeStyle.prototype.createInstance = function () {
        return new StrokeStyle();
    };
    StrokeStyle.prototype.createDefaultProperties = function () {
    };
    StrokeStyle.prototype.getDefaultInstance = function () {
        return TextStyle.defaultInstance;
    };
    Object.defineProperty(StrokeStyle.prototype, "strokeWidthPx", {
        get: function () {
            return this._strokeWidthPx || 0;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(StrokeStyle.prototype, "strokeOffset", {
        get: function () {
            return this._strokeOffset || 0;
        },
        enumerable: false,
        configurable: true
    });
    StrokeStyle.default1pxInstance = new StrokeStyle(1, 0.5);
    StrokeStyle.default1pxNegativeOffsetInstance = new StrokeStyle(1, -0.5);
    StrokeStyle.default2pxInstance = new StrokeStyle(2);
    return StrokeStyle;
}(Style));
exports.StrokeStyle = StrokeStyle;
var EmptyStyle = (function (_super) {
    __extends(EmptyStyle, _super);
    function EmptyStyle(styles) {
        var _this = _super.call(this) || this;
        if (styles)
            Object.keys(styles).forEach(function (k) { return _this[k] = styles[k]; });
        return _this;
    }
    EmptyStyle.prototype.createInstance = function () {
        return new EmptyStyle();
    };
    EmptyStyle.prototype.createDefaultProperties = function () {
    };
    EmptyStyle.prototype.getDefaultInstance = function () {
        return TextStyle.defaultInstance;
    };
    EmptyStyle.defaultInstance = new EmptyStyle();
    return EmptyStyle;
}(Style));
exports.EmptyStyle = EmptyStyle;


/***/ }),
/* 27 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

Object.defineProperty(exports, "__esModule", { value: true });
var browser_1 = __webpack_require__(18);
var common_1 = __webpack_require__(50);
var math_1 = __webpack_require__(31);
var string_1 = __webpack_require__(49);
var DomUtils = (function () {
    function DomUtils() {
    }
    DomUtils.clearInnerHtml = function (element) {
        while (element.firstChild)
            element.removeChild(element.firstChild);
    };
    DomUtils.setStylePosition = function (style, point) {
        style.left = math_1.MathUtils.round(point.x, 3) + 'px';
        style.top = math_1.MathUtils.round(point.y, 3) + 'px';
    };
    DomUtils.setStyleSize = function (style, size) {
        style.width = math_1.MathUtils.round(size.width, 3) + 'px';
        style.height = math_1.MathUtils.round(size.height, 3) + 'px';
    };
    DomUtils.setStyleSizeAndPosition = function (style, rectangle) {
        DomUtils.setStylePosition(style, rectangle);
        DomUtils.setStyleSize(style, rectangle);
    };
    DomUtils.hideNode = function (node) {
        if (node) {
            var parentNode = node.parentNode;
            if (parentNode)
                parentNode.removeChild(node);
        }
    };
    DomUtils.isHTMLElementNode = function (node) {
        return node.nodeType === Node.ELEMENT_NODE;
    };
    DomUtils.isTextNode = function (node) {
        return node.nodeType === Node.TEXT_NODE;
    };
    DomUtils.isElementNode = function (node) {
        return node.nodeType === Node.ELEMENT_NODE;
    };
    DomUtils.isHTMLTableRowElement = function (element) {
        return element.tagName === 'TR';
    };
    DomUtils.isItParent = function (parentElement, element) {
        if (!parentElement || !element)
            return false;
        while (element) {
            if (element === parentElement)
                return true;
            if (element.tagName === 'BODY')
                return false;
            element = element.parentNode;
        }
        return false;
    };
    DomUtils.getParentByTagName = function (element, tagName) {
        tagName = tagName.toUpperCase();
        while (element) {
            if (element.tagName === 'BODY')
                return null;
            if (element.tagName === tagName)
                return element;
            element = element.parentNode;
        }
        return null;
    };
    DomUtils.getDocumentScrollTop = function () {
        var isScrollBodyIE = browser_1.Browser.IE && DomUtils.getCurrentStyle(document.body).overflow === 'hidden' && document.body.scrollTop > 0;
        if (browser_1.Browser.WebKitFamily || browser_1.Browser.Edge || isScrollBodyIE) {
            if (browser_1.Browser.MacOSMobilePlatform)
                return window.pageYOffset;
            if (browser_1.Browser.WebKitFamily)
                return document.documentElement.scrollTop || document.body.scrollTop;
            return document.body.scrollTop;
        }
        else
            return document.documentElement.scrollTop;
    };
    DomUtils.getDocumentScrollLeft = function () {
        var isScrollBodyIE = browser_1.Browser.IE && DomUtils.getCurrentStyle(document.body).overflow === 'hidden' && document.body.scrollLeft > 0;
        if (browser_1.Browser.Edge || isScrollBodyIE)
            return document.body ? document.body.scrollLeft : document.documentElement.scrollLeft;
        if (browser_1.Browser.WebKitFamily)
            return document.documentElement.scrollLeft || document.body.scrollLeft;
        return document.documentElement.scrollLeft;
    };
    DomUtils.getCurrentStyle = function (element) {
        if (element.currentStyle)
            return element.currentStyle;
        else if (document.defaultView && document.defaultView.getComputedStyle) {
            var result = document.defaultView.getComputedStyle(element, null);
            if (!result && browser_1.Browser.Firefox && window.frameElement) {
                var changes = [];
                var curElement = window.frameElement;
                while (!(result = document.defaultView.getComputedStyle(element, null))) {
                    changes.push([curElement, curElement.style.display]);
                    curElement.style.setProperty('display', 'block', 'important');
                    curElement = curElement.tagName === 'BODY' ? curElement.ownerDocument.defaultView.frameElement : curElement.parentNode;
                }
                result = cloneObject(result);
                for (var ch = void 0, i = 0; ch = changes[i]; i++)
                    ch[0].style.display = ch[1];
                document.body.offsetWidth;
            }
            return result;
        }
        return window.getComputedStyle(element, null);
    };
    DomUtils.setFocus = function (element) {
        function focusCore() {
            try {
                element.focus();
                if (browser_1.Browser.IE && document.activeElement !== element)
                    element.focus();
            }
            catch (e) {
            }
        }
        if (browser_1.Browser.MacOSMobilePlatform)
            focusCore();
        else {
            setTimeout(function () {
                focusCore();
            }, 100);
        }
    };
    DomUtils.hasClassName = function (element, className) {
        try {
            var classNames = className.split(' ');
            var classList = element.classList;
            if (classList) {
                for (var i = classNames.length - 1; i >= 0; i--) {
                    if (!classList.contains(classNames[i]))
                        return false;
                }
            }
            else {
                var elementClassName = element.getAttribute && element.getAttribute('class');
                if (!elementClassName)
                    return false;
                var elementClasses = elementClassName.split(' ');
                for (var i = classNames.length - 1; i >= 0; i--) {
                    if (elementClasses.indexOf(classNames[i]) < 0)
                        return false;
                }
            }
            return true;
        }
        catch (e) {
            return false;
        }
    };
    DomUtils.addClassName = function (element, className) {
        if (!DomUtils.hasClassName(element, className)) {
            var elementClassName = element.getAttribute && element.getAttribute('class');
            element.setAttribute('class', elementClassName === '' ? className : elementClassName + " " + className);
        }
    };
    DomUtils.removeClassName = function (element, className) {
        var elementClassName = element.getAttribute && element.getAttribute('class');
        var updClassName = " " + elementClassName + " ";
        var newClassName = updClassName.replace(" " + className + " ", ' ');
        if (updClassName.length !== newClassName.length)
            element.setAttribute('class', string_1.StringUtils.trim(newClassName));
    };
    DomUtils.toggleClassName = function (element, className, toggle) {
        if (toggle === undefined) {
            if (DomUtils.hasClassName(element, className))
                DomUtils.removeClassName(element, className);
            else
                DomUtils.addClassName(element, className);
        }
        else {
            if (toggle)
                DomUtils.addClassName(element, className);
            else
                DomUtils.removeClassName(element, className);
        }
    };
    DomUtils.pxToInt = function (px) {
        return pxToNumber(px, parseInt);
    };
    DomUtils.pxToFloat = function (px) {
        return pxToNumber(px, parseFloat);
    };
    DomUtils.getAbsolutePositionY = function (element) {
        function getAbsolutePositionY_IE(element) {
            return browser_1.Browser.IE && element.parentNode === null ?
                0 :
                element.getBoundingClientRect().top + DomUtils.getDocumentScrollTop();
        }
        function getAbsolutePositionY_FF3(element) {
            return Math.round(element.getBoundingClientRect().top + DomUtils.getDocumentScrollTop());
        }
        function getAbsolutePositionY_Opera(curEl) {
            var isFirstCycle = true;
            if (curEl && DomUtils.isHTMLTableRowElement(curEl) && curEl.cells.length > 0)
                curEl = curEl.cells[0];
            var pos = getAbsoluteScrollOffset_OperaFF(curEl, false);
            while (curEl != null) {
                pos += curEl.offsetTop;
                if (!isFirstCycle)
                    pos -= curEl.scrollTop;
                curEl = curEl.offsetParent;
                isFirstCycle = false;
            }
            pos += document.body.scrollTop;
            return pos;
        }
        function getAbsolutePositionY_NS(curEl) {
            var pos = getAbsoluteScrollOffset_OperaFF(curEl, false);
            var isFirstCycle = true;
            while (curEl != null) {
                pos += curEl.offsetTop;
                if (!isFirstCycle && curEl.offsetParent != null)
                    pos -= curEl.scrollTop;
                if (!isFirstCycle && browser_1.Browser.Firefox) {
                    var style = DomUtils.getCurrentStyle(curEl);
                    if (curEl.tagName === 'DIV' && style.overflow !== 'visible')
                        pos += DomUtils.pxToInt(style.borderTopWidth);
                }
                isFirstCycle = false;
                curEl = curEl.offsetParent;
            }
            return pos;
        }
        function getAbsolutePositionY_Other(curEl) {
            var pos = 0;
            var isFirstCycle = true;
            while (curEl != null) {
                pos += curEl.offsetTop;
                if (!isFirstCycle && curEl.offsetParent != null)
                    pos -= curEl.scrollTop;
                isFirstCycle = false;
                curEl = curEl.offsetParent;
            }
            return pos;
        }
        if (!element)
            return 0;
        if (browser_1.Browser.IE)
            return getAbsolutePositionY_IE(element);
        else if (browser_1.Browser.Firefox && browser_1.Browser.Version >= 3)
            return getAbsolutePositionY_FF3(element);
        else if (browser_1.Browser.Opera)
            return getAbsolutePositionY_Opera(element);
        else if (browser_1.Browser.NetscapeFamily && (!browser_1.Browser.Firefox || browser_1.Browser.Version < 3))
            return getAbsolutePositionY_NS(element);
        else if (browser_1.Browser.WebKitFamily || browser_1.Browser.Edge)
            return getAbsolutePositionY_FF3(element);
        return getAbsolutePositionY_Other(element);
    };
    DomUtils.getAbsolutePositionX = function (element) {
        function getAbsolutePositionX_IE(element) {
            return browser_1.Browser.IE && element.parentNode === null ?
                0 :
                element.getBoundingClientRect().left + DomUtils.getDocumentScrollLeft();
        }
        function getAbsolutePositionX_FF3(element) {
            return Math.round(element.getBoundingClientRect().left + DomUtils.getDocumentScrollLeft());
        }
        function getAbsolutePositionX_Opera(curEl) {
            var isFirstCycle = true;
            var pos = getAbsoluteScrollOffset_OperaFF(curEl, true);
            while (curEl != null) {
                pos += curEl.offsetLeft;
                if (!isFirstCycle)
                    pos -= curEl.scrollLeft;
                curEl = curEl.offsetParent;
                isFirstCycle = false;
            }
            pos += document.body.scrollLeft;
            return pos;
        }
        function getAbsolutePositionX_NS(curEl) {
            var pos = getAbsoluteScrollOffset_OperaFF(curEl, true);
            var isFirstCycle = true;
            while (curEl != null) {
                pos += curEl.offsetLeft;
                if (!isFirstCycle && curEl.offsetParent != null)
                    pos -= curEl.scrollLeft;
                if (!isFirstCycle && browser_1.Browser.Firefox) {
                    var style = DomUtils.getCurrentStyle(curEl);
                    if (curEl.tagName === 'DIV' && style.overflow !== 'visible')
                        pos += DomUtils.pxToInt(style.borderLeftWidth);
                }
                isFirstCycle = false;
                curEl = curEl.offsetParent;
            }
            return pos;
        }
        function getAbsolutePositionX_Other(curEl) {
            var pos = 0;
            var isFirstCycle = true;
            while (curEl != null) {
                pos += curEl.offsetLeft;
                if (!isFirstCycle && curEl.offsetParent != null)
                    pos -= curEl.scrollLeft;
                isFirstCycle = false;
                curEl = curEl.offsetParent;
            }
            return pos;
        }
        if (!element)
            return 0;
        if (browser_1.Browser.IE)
            return getAbsolutePositionX_IE(element);
        else if (browser_1.Browser.Firefox && browser_1.Browser.Version >= 3)
            return getAbsolutePositionX_FF3(element);
        else if (browser_1.Browser.Opera && browser_1.Browser.Version <= 12)
            return getAbsolutePositionX_Opera(element);
        else if (browser_1.Browser.NetscapeFamily && (!browser_1.Browser.Firefox || browser_1.Browser.Version < 3))
            return getAbsolutePositionX_NS(element);
        else if (browser_1.Browser.WebKitFamily || browser_1.Browser.Edge)
            return getAbsolutePositionX_FF3(element);
        else
            return getAbsolutePositionX_Other(element);
    };
    DomUtils.isInteractiveControl = function (element) {
        return ['A', 'INPUT', 'SELECT', 'OPTION', 'TEXTAREA', 'BUTTON', 'IFRAME'].indexOf(element.tagName) > -1;
    };
    DomUtils.getClearClientHeight = function (element) {
        return element.offsetHeight - (DomUtils.getTopBottomPaddings(element) + DomUtils.getVerticalBordersWidth(element));
    };
    DomUtils.getTopBottomPaddings = function (element, style) {
        var currentStyle = style ? style : DomUtils.getCurrentStyle(element);
        return DomUtils.pxToInt(currentStyle.paddingTop) + DomUtils.pxToInt(currentStyle.paddingBottom);
    };
    DomUtils.getVerticalBordersWidth = function (element, style) {
        if (!common_1.isDefined(style))
            style = (browser_1.Browser.IE && browser_1.Browser.MajorVersion !== 9 && window.getComputedStyle) ? window.getComputedStyle(element) : DomUtils.getCurrentStyle(element);
        var res = 0;
        if (style.borderTopStyle !== 'none')
            res += DomUtils.pxToFloat(style.borderTopWidth);
        if (style.borderBottomStyle !== 'none')
            res += DomUtils.pxToFloat(style.borderBottomWidth);
        return res;
    };
    DomUtils.getNodes = function (parent, predicate) {
        var collection = parent.all || parent.getElementsByTagName('*');
        var result = [];
        for (var i = 0; i < collection.length; i++) {
            var element = collection[i];
            if (predicate(element))
                result.push(element);
        }
        return result;
    };
    DomUtils.getChildNodes = function (parent, predicate) {
        var collection = parent.childNodes;
        var result = [];
        for (var i = 0; i < collection.length; i++) {
            var element = collection[i];
            if (predicate(element))
                result.push(element);
        }
        return result;
    };
    DomUtils.getNodesByClassName = function (parent, className) {
        if (parent.querySelectorAll) {
            var children = parent.querySelectorAll("." + className);
            var result_1 = [];
            children.forEach(function (element) { return result_1.push(element); });
            return result_1;
        }
        else
            return DomUtils.getNodes(parent, function (elem) { return DomUtils.hasClassName(elem, className); });
    };
    DomUtils.getChildNodesByClassName = function (parent, className) {
        function nodeListToArray(nodeList, filter) {
            var result = [];
            for (var i = 0; i < nodeList.length; i++) {
                var element = nodeList[i];
                if (filter(element))
                    result.push(element);
            }
            return result;
        }
        if (parent.querySelectorAll) {
            var children = parent.querySelectorAll("." + className);
            return nodeListToArray(children, function (element) { return element.parentNode === parent; });
        }
        else {
            return DomUtils.getChildNodes(parent, function (elem) {
                if (DomUtils.isElementNode(elem))
                    return common_1.isNonNullString(elem.className) && DomUtils.hasClassName(elem, elem.className);
                else
                    return false;
            });
        }
    };
    DomUtils.getVerticalScrollBarWidth = function () {
        if (DomUtils.verticalScrollBarWidth === undefined) {
            var container = document.createElement('DIV');
            container.style.cssText = 'position: absolute; top: 0px; left: 0px; visibility: hidden; width: 200px; height: 150px; overflow: hidden; box-sizing: content-box';
            document.body.appendChild(container);
            var child = document.createElement('P');
            container.appendChild(child);
            child.style.cssText = 'width: 100%; height: 200px;';
            var widthWithoutScrollBar = child.offsetWidth;
            container.style.overflow = 'scroll';
            var widthWithScrollBar = child.offsetWidth;
            if (widthWithoutScrollBar === widthWithScrollBar)
                widthWithScrollBar = container.clientWidth;
            DomUtils.verticalScrollBarWidth = widthWithoutScrollBar - widthWithScrollBar;
            document.body.removeChild(container);
        }
        return DomUtils.verticalScrollBarWidth;
    };
    DomUtils.getHorizontalBordersWidth = function (element, style) {
        if (!common_1.isDefined(style))
            style = (browser_1.Browser.IE && window.getComputedStyle) ? window.getComputedStyle(element) : DomUtils.getCurrentStyle(element);
        var res = 0;
        if (style.borderLeftStyle !== 'none')
            res += DomUtils.pxToFloat(style.borderLeftWidth);
        if (style.borderRightStyle !== 'none')
            res += DomUtils.pxToFloat(style.borderRightWidth);
        return res;
    };
    DomUtils.getFontFamiliesFromCssString = function (cssString) {
        return cssString.split(',').map(function (fam) { return string_1.StringUtils.trim(fam.replace(/'|"/gi, '')); });
    };
    DomUtils.getInnerText = function (container) {
        if (browser_1.Browser.Safari && browser_1.Browser.MajorVersion <= 5) {
            if (DomUtils.html2PlainTextFilter === null) {
                DomUtils.html2PlainTextFilter = document.createElement('DIV');
                DomUtils.html2PlainTextFilter.style.width = '0';
                DomUtils.html2PlainTextFilter.style.height = '0';
                DomUtils.html2PlainTextFilter.style.overflow = 'visible';
                DomUtils.html2PlainTextFilter.style.display = 'none';
                document.body.appendChild(DomUtils.html2PlainTextFilter);
            }
            var filter = DomUtils.html2PlainTextFilter;
            filter.innerHTML = container.innerHTML;
            filter.style.display = '';
            var innerText = filter.innerText;
            filter.style.display = 'none';
            return innerText;
        }
        else if (browser_1.Browser.NetscapeFamily || browser_1.Browser.WebKitFamily || (browser_1.Browser.IE && browser_1.Browser.Version >= 9) || browser_1.Browser.Edge)
            return container.textContent;
        else
            return container.innerText;
    };
    DomUtils.html2PlainTextFilter = null;
    DomUtils.verticalScrollBarWidth = undefined;
    return DomUtils;
}());
exports.DomUtils = DomUtils;
function cloneObject(srcObject) {
    if (typeof (srcObject) !== 'object' || !common_1.isDefined(srcObject))
        return srcObject;
    var newObject = {};
    for (var i in srcObject)
        newObject[i] = srcObject[i];
    return newObject;
}
function pxToNumber(px, parseFunction) {
    var result = 0;
    if (common_1.isDefined(px) && px !== '') {
        try {
            var indexOfPx = px.indexOf('px');
            if (indexOfPx > -1)
                result = parseFunction(px.substr(0, indexOfPx));
        }
        catch (e) { }
    }
    return result;
}
function getAbsoluteScrollOffset_OperaFF(curEl, isX) {
    var pos = 0;
    var isFirstCycle = true;
    while (curEl != null) {
        if (curEl.tagName === 'BODY')
            break;
        var style = DomUtils.getCurrentStyle(curEl);
        if (style.position === 'absolute')
            break;
        if (!isFirstCycle && curEl.tagName === 'DIV' && (style.position === '' || style.position === 'static'))
            pos -= isX ? curEl.scrollLeft : curEl.scrollTop;
        curEl = curEl.parentNode;
        isFirstCycle = false;
    }
    return pos;
}


/***/ }),
/* 28 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.ConnectorRoutingMode = exports.AutoZoomMode = exports.DiagramSettings = void 0;
var Utils_1 = __webpack_require__(3);
var size_1 = __webpack_require__(2);
var Enums_1 = __webpack_require__(47);
var ModelUtils_1 = __webpack_require__(4);
var DiagramSettings = (function () {
    function DiagramSettings() {
        this.onZoomChanged = new Utils_1.EventDispatcher();
        this.onViewChanged = new Utils_1.EventDispatcher();
        this.onReadOnlyChanged = new Utils_1.EventDispatcher();
        this.onConnectorRoutingModeChanged = new Utils_1.EventDispatcher();
        this._zoomLevel = 1;
        this._zoomLevelWasChanged = false;
        this._zoomLevelItems = [0.5, 0.75, 1, 1.25, 1.5, 2, 3];
        this._simpleView = false;
        this._fullscreen = false;
        this._readOnly = false;
        this._autoZoom = AutoZoomMode.Disabled;
        this._snapToGrid = true;
        this._showGrid = true;
        this._contextMenuEnabled = true;
        this._gridSize = 180;
        this._gridSizeItems = [90, 180, 360, 720];
        this._pageSizeItems = [
            { size: new size_1.Size(12240, 15840), text: "US-Letter ({width} x {height})" },
            { size: new size_1.Size(12240, 20160), text: "US-Legal ({width} x {height})" },
            { size: new size_1.Size(15817, 24491), text: "US-Tabloid ({width} x {height})" },
            { size: new size_1.Size(47679, 67408), text: "A0 ({width} x {height})" },
            { size: new size_1.Size(33676, 47679), text: "A1 ({width} x {height})" },
            { size: new size_1.Size(23811, 33676), text: "A2 ({width} x {height})" },
            { size: new size_1.Size(16838, 23811), text: "A3 ({width} x {height})" },
            { size: new size_1.Size(11906, 16838), text: "A4 ({width} x {height})" },
            { size: new size_1.Size(8391, 11906), text: "A5 ({width} x {height})" },
            { size: new size_1.Size(5953, 8391), text: "A6 ({width} x {height})" },
            { size: new size_1.Size(4195, 5953), text: "A7 ({width} x {height})" }
        ];
        this._viewUnits = Enums_1.DiagramUnit.In;
        this._connectorRoutingMode = ConnectorRoutingMode.AllShapesOnly;
        this._reloadInsertedItemRequired = false;
        this._useCanvgForExportToImage = true;
    }
    Object.defineProperty(DiagramSettings.prototype, "zoomLevel", {
        get: function () { return this._zoomLevel; },
        set: function (value) {
            var _this = this;
            value = DiagramSettings.correctZoomLevel(value);
            if (value !== this._zoomLevel) {
                this._zoomLevel = value;
                this._zoomLevelWasChanged = true;
                this.onZoomChanged.raise1(function (listener) { return listener.notifyZoomChanged(value, _this._autoZoom); });
            }
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(DiagramSettings.prototype, "zoomLevelWasChanged", {
        get: function () { return this._zoomLevelWasChanged; },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(DiagramSettings.prototype, "zoomLevelItems", {
        get: function () { return this._zoomLevelItems; },
        set: function (value) {
            value = value.map(function (l) { return DiagramSettings.correctZoomLevel(l); });
            if (value !== this._zoomLevelItems)
                this._zoomLevelItems = value;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(DiagramSettings.prototype, "autoZoom", {
        get: function () { return this._autoZoom; },
        set: function (value) {
            var _this = this;
            if (value !== this._autoZoom) {
                this._autoZoom = value;
                this.onZoomChanged.raise1(function (l) { return l.notifyZoomChanged(_this._zoomLevel, value); });
            }
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(DiagramSettings.prototype, "simpleView", {
        get: function () { return this._simpleView; },
        set: function (value) {
            if (value !== this._simpleView) {
                this._simpleView = value;
                this.notifyViewChanged();
            }
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(DiagramSettings.prototype, "readOnly", {
        get: function () { return this._readOnly; },
        set: function (value) {
            if (value !== this._readOnly) {
                this._readOnly = value;
                this.onReadOnlyChanged.raise1(function (listener) { return listener.notifyReadOnlyChanged(value); });
            }
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(DiagramSettings.prototype, "fullscreen", {
        get: function () { return this._fullscreen; },
        set: function (value) { this._fullscreen = value; },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(DiagramSettings.prototype, "snapToGrid", {
        get: function () { return this._snapToGrid; },
        set: function (value) { this._snapToGrid = value; },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(DiagramSettings.prototype, "showGrid", {
        get: function () { return this._showGrid; },
        set: function (value) {
            var _this = this;
            if (value !== this._showGrid) {
                this._showGrid = value;
                this.onViewChanged.raise1(function (l) { return l.notifyGridChanged(_this.showGrid, _this.gridSize); });
            }
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(DiagramSettings.prototype, "contextMenuEnabled", {
        get: function () { return this._contextMenuEnabled; },
        set: function (value) {
            this._contextMenuEnabled = value;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(DiagramSettings.prototype, "gridSize", {
        get: function () { return this._gridSize; },
        set: function (value) {
            var _this = this;
            if (value !== this._gridSize) {
                this._gridSize = value;
                this.onViewChanged.raise1(function (l) { return l.notifyGridChanged(_this.showGrid, _this.gridSize); });
            }
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(DiagramSettings.prototype, "gridSizeItems", {
        get: function () { return this._gridSizeItems; },
        set: function (value) {
            if (value !== this._gridSizeItems)
                this._gridSizeItems = value;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(DiagramSettings.prototype, "pageSizeItems", {
        get: function () { return this._pageSizeItems; },
        set: function (value) {
            if (value !== this._pageSizeItems)
                this._pageSizeItems = value;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(DiagramSettings.prototype, "viewUnits", {
        get: function () { return this._viewUnits; },
        set: function (value) { this._viewUnits = value; },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(DiagramSettings.prototype, "connectorRoutingMode", {
        get: function () { return this._connectorRoutingMode; },
        set: function (value) {
            if (value !== this._connectorRoutingMode) {
                this._connectorRoutingMode = value;
                this.onConnectorRoutingModeChanged.raise1(function (listener) { return listener.notifyConnectorRoutingModeChanged(value); });
            }
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(DiagramSettings.prototype, "reloadInsertedItemRequired", {
        get: function () { return this._reloadInsertedItemRequired; },
        set: function (value) {
            this._reloadInsertedItemRequired = value;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(DiagramSettings.prototype, "useCanvgForExportToImage", {
        get: function () { return this._useCanvgForExportToImage; },
        set: function (value) {
            this._useCanvgForExportToImage = value;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(DiagramSettings.prototype, "shapeMinWidth", {
        get: function () { return this._shapeMinWidth; },
        set: function (value) { this._shapeMinWidth = value; },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(DiagramSettings.prototype, "shapeMinHeight", {
        get: function () { return this._shapeMinHeight; },
        set: function (value) { this._shapeMinHeight = value; },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(DiagramSettings.prototype, "shapeMaxWidth", {
        get: function () { return this._shapeMaxWidth; },
        set: function (value) { this._shapeMaxWidth = value; },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(DiagramSettings.prototype, "shapeMaxHeight", {
        get: function () { return this._shapeMaxHeight; },
        set: function (value) { this._shapeMaxHeight = value; },
        enumerable: false,
        configurable: true
    });
    DiagramSettings.prototype.applyShapeSizeSettings = function (settings, units) {
        if (!settings)
            return;
        if (typeof (settings.shapeMaxHeight) === "number")
            this.shapeMaxHeight = ModelUtils_1.ModelUtils.getTwipsValue(units, settings.shapeMaxHeight);
        if (typeof (settings.shapeMinHeight) === "number")
            this.shapeMinHeight = ModelUtils_1.ModelUtils.getTwipsValue(units, settings.shapeMinHeight);
        if (typeof (settings.shapeMaxWidth) === "number")
            this.shapeMaxWidth = ModelUtils_1.ModelUtils.getTwipsValue(units, settings.shapeMaxWidth);
        if (typeof (settings.shapeMinWidth) === "number")
            this.shapeMinWidth = ModelUtils_1.ModelUtils.getTwipsValue(units, settings.shapeMinWidth);
    };
    DiagramSettings.prototype.notifyViewChanged = function () {
        var _this = this;
        this.onViewChanged.raise1(function (listener) { return listener.notifyViewChanged(_this._simpleView); });
    };
    DiagramSettings.correctZoomLevel = function (level) {
        return Math.min(10, Math.max(level, 0.01));
    };
    return DiagramSettings;
}());
exports.DiagramSettings = DiagramSettings;
var AutoZoomMode;
(function (AutoZoomMode) {
    AutoZoomMode[AutoZoomMode["Disabled"] = 0] = "Disabled";
    AutoZoomMode[AutoZoomMode["FitContent"] = 1] = "FitContent";
    AutoZoomMode[AutoZoomMode["FitToWidth"] = 2] = "FitToWidth";
})(AutoZoomMode = exports.AutoZoomMode || (exports.AutoZoomMode = {}));
var ConnectorRoutingMode;
(function (ConnectorRoutingMode) {
    ConnectorRoutingMode[ConnectorRoutingMode["None"] = 0] = "None";
    ConnectorRoutingMode[ConnectorRoutingMode["ConnectorShapesOnly"] = 1] = "ConnectorShapesOnly";
    ConnectorRoutingMode[ConnectorRoutingMode["AllShapesOnly"] = 2] = "AllShapesOnly";
})(ConnectorRoutingMode = exports.ConnectorRoutingMode || (exports.ConnectorRoutingMode = {}));


/***/ }),
/* 29 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.ConnectorRenderPoint = void 0;
var point_1 = __webpack_require__(0);
var ConnectorRenderPoint = (function (_super) {
    __extends(ConnectorRenderPoint, _super);
    function ConnectorRenderPoint(x, y, pointIndex, skipped) {
        if (pointIndex === void 0) { pointIndex = -1; }
        if (skipped === void 0) { skipped = false; }
        var _this = _super.call(this, x, y) || this;
        _this.pointIndex = pointIndex;
        _this.skipped = skipped;
        return _this;
    }
    ConnectorRenderPoint.prototype.offset = function (offsetX, offsetY) {
        _super.prototype.offset.call(this, offsetX, offsetY);
        this.pointIndex = -1;
        this.skipped = false;
        return this;
    };
    ConnectorRenderPoint.prototype.multiply = function (multiplierX, multiplierY) {
        _super.prototype.multiply.call(this, multiplierX, multiplierY);
        this.pointIndex = -1;
        this.skipped = false;
        return this;
    };
    ConnectorRenderPoint.prototype.clone = function () { return new ConnectorRenderPoint(this.x, this.y, this.pointIndex, this.skipped); };
    return ConnectorRenderPoint;
}(point_1.Point));
exports.ConnectorRenderPoint = ConnectorRenderPoint;


/***/ }),
/* 30 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.ShapeParameterPoint = void 0;
var ShapeParameterPoint = (function () {
    function ShapeParameterPoint(key, point) {
        this.key = key;
        this.point = point;
    }
    return ShapeParameterPoint;
}());
exports.ShapeParameterPoint = ShapeParameterPoint;


/***/ }),
/* 31 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

Object.defineProperty(exports, "__esModule", { value: true });
var list_1 = __webpack_require__(105);
var MathUtils = (function () {
    function MathUtils() {
    }
    MathUtils.round = function (value, digits) {
        if (digits === void 0) { digits = 0; }
        var factor = MathUtils.powFactor[digits];
        return Math.round(value * factor) / factor;
    };
    MathUtils.numberCloseTo = function (num, to, accuracy) {
        if (accuracy === void 0) { accuracy = 0.00001; }
        return Math.abs(num - to) < accuracy;
    };
    MathUtils.restrictValue = function (val, minVal, maxVal) {
        if (maxVal < minVal)
            maxVal = minVal;
        if (val > maxVal)
            return maxVal;
        else if (val < minVal)
            return minVal;
        return val;
    };
    MathUtils.getRandomInt = function (min, max) {
        return Math.floor(Math.random() * (max - min + 1)) + min;
    };
    MathUtils.generateGuid = function () {
        return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
            var r = Math.random() * 16 | 0;
            var v = c === 'x' ? r : (r & 0x3 | 0x8);
            return v.toString(16);
        });
    };
    MathUtils.powFactor = list_1.ListUtils.initByCallback(20, function (ind) { return Math.pow(10, ind); });
    MathUtils.somePrimes = [1009, 1013,
        1019, 1021, 1031, 1033, 1039, 1049, 1051, 1061, 1063, 1069,
        1087, 1091, 1093, 1097, 1103, 1109, 1117, 1123, 1129, 1151,
        1153, 1163, 1171, 1181, 1187, 1193, 1201, 1213, 1217, 1223,
        1229, 1231, 1237, 1249, 1259, 1277, 1279, 1283, 1289, 1291,
        1297, 1301, 1303, 1307, 1319, 1321, 1327, 1361, 1367, 1373,
        1381, 1399, 1409, 1423, 1427, 1429, 1433, 1439, 1447, 1451,
        1453, 1459, 1471, 1481, 1483, 1487, 1489, 1493, 1499, 1511,
        1523, 1531, 1543, 1549, 1553, 1559, 1567, 1571, 1579, 1583,
        1597, 1601, 1607, 1609, 1613, 1619, 1621, 1627, 1637, 1657,
        1663, 1667, 1669, 1693, 1697, 1699, 1709, 1721, 1723, 1733,
        1741, 1747, 1753, 1759, 1777, 1783, 1787, 1789, 1801, 1811,
        1823, 1831, 1847, 1861, 1867, 1871, 1873, 1877, 1879, 1889,
        1901, 1907, 1913, 1931, 1933, 1949, 1951, 1973, 1979, 1987,
        1993, 1997, 1999, 2003];
    return MathUtils;
}());
exports.MathUtils = MathUtils;


/***/ }),
/* 32 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.ConnectorProperties = exports.DEFAULT_CONNECTOR_ENDLINEENDING = exports.DEFAULT_CONNECTOR_STARTLINEENDING = exports.DEFAULT_CONNECTOR_LINEOPTION = exports.ConnectorLineEnding = exports.ConnectorLineOption = void 0;
var ConnectorLineOption;
(function (ConnectorLineOption) {
    ConnectorLineOption[ConnectorLineOption["Straight"] = 0] = "Straight";
    ConnectorLineOption[ConnectorLineOption["Orthogonal"] = 1] = "Orthogonal";
})(ConnectorLineOption = exports.ConnectorLineOption || (exports.ConnectorLineOption = {}));
var ConnectorLineEnding;
(function (ConnectorLineEnding) {
    ConnectorLineEnding[ConnectorLineEnding["None"] = 0] = "None";
    ConnectorLineEnding[ConnectorLineEnding["Arrow"] = 1] = "Arrow";
    ConnectorLineEnding[ConnectorLineEnding["OutlinedTriangle"] = 2] = "OutlinedTriangle";
    ConnectorLineEnding[ConnectorLineEnding["FilledTriangle"] = 3] = "FilledTriangle";
})(ConnectorLineEnding = exports.ConnectorLineEnding || (exports.ConnectorLineEnding = {}));
exports.DEFAULT_CONNECTOR_LINEOPTION = ConnectorLineOption.Orthogonal;
exports.DEFAULT_CONNECTOR_STARTLINEENDING = ConnectorLineEnding.None;
exports.DEFAULT_CONNECTOR_ENDLINEENDING = ConnectorLineEnding.Arrow;
var ConnectorProperties = (function () {
    function ConnectorProperties() {
        this.lineOption = exports.DEFAULT_CONNECTOR_LINEOPTION;
        this.startLineEnding = exports.DEFAULT_CONNECTOR_STARTLINEENDING;
        this.endLineEnding = exports.DEFAULT_CONNECTOR_ENDLINEENDING;
    }
    ConnectorProperties.prototype.clone = function () {
        var clone = new ConnectorProperties();
        clone.lineOption = this.lineOption;
        clone.startLineEnding = this.startLineEnding;
        clone.endLineEnding = this.endLineEnding;
        return clone;
    };
    ConnectorProperties.prototype.forEach = function (callback) {
        for (var propertyName in this)
            if (Object.prototype.hasOwnProperty.call(this, propertyName))
                callback(propertyName);
    };
    ConnectorProperties.prototype.toObject = function () {
        var result = {};
        var modified = false;
        if (this.lineOption !== exports.DEFAULT_CONNECTOR_LINEOPTION) {
            result["lineOption"] = this.lineOption;
            modified = true;
        }
        if (this.startLineEnding !== exports.DEFAULT_CONNECTOR_STARTLINEENDING) {
            result["startLineEnding"] = this.startLineEnding;
            modified = true;
        }
        if (this.endLineEnding !== exports.DEFAULT_CONNECTOR_ENDLINEENDING) {
            result["endLineEnding"] = this.endLineEnding;
            modified = true;
        }
        return modified ? result : null;
    };
    ConnectorProperties.prototype.fromObject = function (obj) {
        if (typeof obj["lineOption"] === "number")
            this.lineOption = obj["lineOption"];
        if (typeof obj["startLineEnding"] === "number")
            this.startLineEnding = obj["startLineEnding"];
        if (typeof obj["endLineEnding"] === "number")
            this.endLineEnding = obj["endLineEnding"];
    };
    return ConnectorProperties;
}());
exports.ConnectorProperties = ConnectorProperties;


/***/ }),
/* 33 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

Object.defineProperty(exports, "__esModule", { value: true });
var math_1 = __webpack_require__(31);
var metrics_1 = __webpack_require__(35);
var point_1 = __webpack_require__(0);
var rectangle_1 = __webpack_require__(13);
var Segment = (function () {
    function Segment(startPoint, endPoint) {
        this.startPoint = startPoint;
        this.endPoint = endPoint;
    }
    Object.defineProperty(Segment.prototype, "length", {
        get: function () {
            return metrics_1.Metrics.euclideanDistance(this.startPoint, this.endPoint);
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(Segment.prototype, "xLength", {
        get: function () {
            return Math.abs(this.endPoint.x - this.startPoint.x);
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(Segment.prototype, "yLength", {
        get: function () {
            return Math.abs(this.endPoint.y - this.startPoint.y);
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(Segment.prototype, "center", {
        get: function () {
            return new point_1.Point(this.startPoint.x + (this.endPoint.x - this.startPoint.x) / 2, this.startPoint.y + (this.endPoint.y - this.startPoint.y) / 2);
        },
        enumerable: true,
        configurable: true
    });
    Segment.prototype.isIntersected = function (segment) {
        return this.startPoint.equals(segment.startPoint) || this.endPoint.equals(segment.startPoint) ||
            this.startPoint.equals(segment.endPoint) || this.endPoint.equals(segment.endPoint) ||
            (this.intersectCore(segment) && segment.intersectCore(this));
    };
    Segment.prototype.containsPoint = function (point, accuracy) {
        if (accuracy === void 0) { accuracy = 0.0000001; }
        return this.startPoint.equals(point) || this.endPoint.equals(point) ||
            math_1.MathUtils.numberCloseTo(this.length, metrics_1.Metrics.euclideanDistance(this.startPoint, point) + metrics_1.Metrics.euclideanDistance(this.endPoint, point), accuracy);
    };
    Segment.prototype.isIntersectedByRect = function (rect) {
        if (rectangle_1.Rectangle.containsPoint(rect, this.startPoint) || rectangle_1.Rectangle.containsPoint(rect, this.endPoint))
            return true;
        var left = rect.x;
        var right = rect.x + rect.width;
        var top = rect.y;
        var bottom = rect.y + rect.height;
        return this.isIntersected(new Segment(new point_1.Point(left, top), new point_1.Point(left, bottom))) ||
            this.isIntersected(new Segment(new point_1.Point(right, top), new point_1.Point(right, bottom))) ||
            this.isIntersected(new Segment(new point_1.Point(left, top), new point_1.Point(right, top))) ||
            this.isIntersected(new Segment(new point_1.Point(left, bottom), new point_1.Point(right, bottom)));
    };
    Segment.prototype.intersectCore = function (segment) {
        if (this.startPoint.x === this.endPoint.x) {
            if (this.startPoint.x - segment.endPoint.x !== 0)
                return (this.startPoint.x - segment.startPoint.x) / (this.startPoint.x - segment.endPoint.x) <= 0;
            if (segment.endPoint.y - this.endPoint.y !== 0)
                return (segment.endPoint.y - this.startPoint.y) / (segment.endPoint.y - this.endPoint.y) <= 0;
        }
        if (this.startPoint.y === this.endPoint.y) {
            if (this.startPoint.y - segment.endPoint.y !== 0)
                return (this.startPoint.y - segment.startPoint.y) / (this.startPoint.y - segment.endPoint.y) <= 0;
            if (segment.endPoint.x - this.endPoint.x !== 0)
                return (segment.endPoint.x - this.startPoint.x) / (segment.endPoint.x - this.endPoint.x) <= 0;
        }
        var tg = (this.endPoint.y - this.startPoint.y) / (this.endPoint.x - this.startPoint.x);
        var y1 = this.startPoint.y + (segment.startPoint.x - this.startPoint.x) * tg;
        var y2 = this.startPoint.y + (segment.endPoint.x - this.startPoint.x) * tg;
        var dy1 = segment.startPoint.y - y1;
        var dy2 = segment.endPoint.y - y2;
        if (dy1 === 0 && dy2 === 0) {
            return (this.startPoint.y - y1) / (this.endPoint.y - y1) <= 0 ||
                (this.startPoint.y - y2) / (this.endPoint.y - y2) <= 0;
        }
        return dy1 === 0 || dy2 === 0 || dy1 / dy2 < 0;
    };
    return Segment;
}());
exports.Segment = Segment;


/***/ }),
/* 34 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.MouseHandlerDraggingState = void 0;
var MouseHandlerStateBase_1 = __webpack_require__(40);
var Event_1 = __webpack_require__(11);
var unit_converter_1 = __webpack_require__(12);
var MouseHandlerDraggingState = (function (_super) {
    __extends(MouseHandlerDraggingState, _super);
    function MouseHandlerDraggingState(handler, history) {
        var _this = _super.call(this, handler) || this;
        _this.history = history;
        return _this;
    }
    MouseHandlerDraggingState.prototype.canApplyChangesOnMouseMove = function (initPosition, position) {
        return !initPosition || !position ||
            Math.abs(initPosition.x - position.x) > MouseHandlerDraggingState.dragStartLimit ||
            Math.abs(initPosition.y - position.y) > MouseHandlerDraggingState.dragStartLimit;
    };
    MouseHandlerDraggingState.prototype.onAfterApplyChanges = function () {
        if (!this.modified)
            this.handler.raiseDragStart(this.getDraggingElementKeys());
        this.modified = true;
        this.mouseDownPoint = undefined;
    };
    MouseHandlerDraggingState.prototype.onMouseDown = function (evt) {
        this.mouseDownPoint = evt.modelPoint.clone();
    };
    MouseHandlerDraggingState.prototype.onMouseMove = function (evt) {
        this.mouseMoveEvent = evt;
        if (evt.button !== Event_1.MouseButton.Left) {
            this.cancelChanges();
            this.handler.switchToDefaultState();
        }
        else if (evt.button === Event_1.MouseButton.Left && this.canApplyChangesOnMouseMove(this.mouseDownPoint, evt.modelPoint)) {
            this.onApplyChanges(evt);
            this.onAfterApplyChanges();
        }
    };
    MouseHandlerDraggingState.prototype.onKeyDown = function (evt) {
        if (this.mouseMoveEvent && (evt.keyCode === 16 || evt.keyCode === 17 || evt.keyCode === 18))
            this.performMouseMoveEvent(evt.modifiers);
    };
    MouseHandlerDraggingState.prototype.onKeyUp = function (evt) {
        if (this.mouseMoveEvent && (evt.keyCode === 16 || evt.keyCode === 17 || evt.keyCode === 18))
            this.performMouseMoveEvent(evt.modifiers);
    };
    MouseHandlerDraggingState.prototype.onMouseUp = function (evt) {
        this.mouseDownPoint = undefined;
        this.mouseMoveEvent = undefined;
        this.handler.switchToDefaultState();
    };
    MouseHandlerDraggingState.prototype.performMouseMoveEvent = function (modifiers) {
        this.mouseMoveEvent.modifiers = modifiers;
        this.onMouseMove(this.mouseMoveEvent);
    };
    MouseHandlerDraggingState.prototype.start = function () {
        this.handler.beginStorePermissions();
        this.history.beginTransaction();
    };
    MouseHandlerDraggingState.prototype.finish = function () {
        this.checkStoredPermissionsOnFinish();
        if (this.modified) {
            this.onFinishWithChanges();
            this.modified = false;
            this.history.endTransaction();
            this.handler.raiseDragEnd(this.getDraggingElementKeys());
        }
        else
            this.history.endTransaction();
        this.handler.endStorePermissions();
        this.handler.clearInteractingItems();
    };
    MouseHandlerDraggingState.prototype.checkStoredPermissionsOnFinish = function () {
        if (!this.handler.isStoredPermissionsGranted()) {
            this.cancelChanges();
            this.modified = false;
        }
    };
    MouseHandlerDraggingState.prototype.onFinishWithChanges = function () { };
    MouseHandlerDraggingState.prototype.cancelChanges = function () {
        this.handler.lockPermissions();
        this.history.undoTransaction();
        this.handler.unlockPermissions();
        if (this.modified)
            this.handler.raiseDragEnd(this.getDraggingElementKeys());
        this.modified = false;
    };
    MouseHandlerDraggingState.prototype.getSnappedPoint = function (evt, point) {
        return this.handler.getSnappedPointOnDragPoint(evt, point);
    };
    MouseHandlerDraggingState.dragStartLimit = unit_converter_1.UnitConverter.pixelsToTwips(4);
    return MouseHandlerDraggingState;
}(MouseHandlerStateBase_1.MouseHandlerCancellableState));
exports.MouseHandlerDraggingState = MouseHandlerDraggingState;


/***/ }),
/* 35 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

Object.defineProperty(exports, "__esModule", { value: true });
var Metrics = (function () {
    function Metrics() {
    }
    Metrics.euclideanDistance = function (a, b) {
        var xDist = a.x - b.x;
        var yDist = a.y - b.y;
        return Math.sqrt(xDist * xDist + yDist * yDist);
    };
    Metrics.manhattanDistance = function (a, b) {
        return Math.abs(a.x - b.x) + Math.abs(a.y - b.y);
    };
    return Metrics;
}());
exports.Metrics = Metrics;


/***/ }),
/* 36 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.DiagramLocalizationService = void 0;
var ShapeTypes_1 = __webpack_require__(1);
var Enums_1 = __webpack_require__(47);
var DiagramLocalizationService = (function () {
    function DiagramLocalizationService() {
    }
    DiagramLocalizationService.unitItems = {};
    DiagramLocalizationService.formatUnit = function (value) { return value.toString(); };
    DiagramLocalizationService.shapeTexts = {};
    return DiagramLocalizationService;
}());
exports.DiagramLocalizationService = DiagramLocalizationService;
DiagramLocalizationService.unitItems[Enums_1.DiagramUnit.In] = "in";
DiagramLocalizationService.unitItems[Enums_1.DiagramUnit.Cm] = "cm";
DiagramLocalizationService.unitItems[Enums_1.DiagramUnit.Px] = "px";
DiagramLocalizationService.shapeTexts[ShapeTypes_1.ShapeTypes.Text] = "Text";
DiagramLocalizationService.shapeTexts[ShapeTypes_1.ShapeTypes.Rectangle] = "Rectangle";
DiagramLocalizationService.shapeTexts[ShapeTypes_1.ShapeTypes.Ellipse] = "Ellipse";
DiagramLocalizationService.shapeTexts[ShapeTypes_1.ShapeTypes.Cross] = "Cross";
DiagramLocalizationService.shapeTexts[ShapeTypes_1.ShapeTypes.Triangle] = "Triangle";
DiagramLocalizationService.shapeTexts[ShapeTypes_1.ShapeTypes.Diamond] = "Diamond";
DiagramLocalizationService.shapeTexts[ShapeTypes_1.ShapeTypes.Heart] = "Heart";
DiagramLocalizationService.shapeTexts[ShapeTypes_1.ShapeTypes.Pentagon] = "Pentagon";
DiagramLocalizationService.shapeTexts[ShapeTypes_1.ShapeTypes.Hexagon] = "Hexagon";
DiagramLocalizationService.shapeTexts[ShapeTypes_1.ShapeTypes.Octagon] = "Octagon";
DiagramLocalizationService.shapeTexts[ShapeTypes_1.ShapeTypes.Star] = "Star";
DiagramLocalizationService.shapeTexts[ShapeTypes_1.ShapeTypes.ArrowLeft] = "Left Arrow";
DiagramLocalizationService.shapeTexts[ShapeTypes_1.ShapeTypes.ArrowUp] = "Up Arrow";
DiagramLocalizationService.shapeTexts[ShapeTypes_1.ShapeTypes.ArrowRight] = "Right Arrow";
DiagramLocalizationService.shapeTexts[ShapeTypes_1.ShapeTypes.ArrowDown] = "Down Arrow";
DiagramLocalizationService.shapeTexts[ShapeTypes_1.ShapeTypes.ArrowUpDown] = "Up Down Arrow";
DiagramLocalizationService.shapeTexts[ShapeTypes_1.ShapeTypes.ArrowLeftRight] = "Left Right Arrow";
DiagramLocalizationService.shapeTexts[ShapeTypes_1.ShapeTypes.Process] = "Process";
DiagramLocalizationService.shapeTexts[ShapeTypes_1.ShapeTypes.Decision] = "Decision";
DiagramLocalizationService.shapeTexts[ShapeTypes_1.ShapeTypes.Terminator] = "Terminator";
DiagramLocalizationService.shapeTexts[ShapeTypes_1.ShapeTypes.PredefinedProcess] = "Predefined Process";
DiagramLocalizationService.shapeTexts[ShapeTypes_1.ShapeTypes.Document] = "Document";
DiagramLocalizationService.shapeTexts[ShapeTypes_1.ShapeTypes.MultipleDocuments] = "Multiple Documents";
DiagramLocalizationService.shapeTexts[ShapeTypes_1.ShapeTypes.ManualInput] = "Manual Input";
DiagramLocalizationService.shapeTexts[ShapeTypes_1.ShapeTypes.Preparation] = "Preparation";
DiagramLocalizationService.shapeTexts[ShapeTypes_1.ShapeTypes.Data] = "Data";
DiagramLocalizationService.shapeTexts[ShapeTypes_1.ShapeTypes.Database] = "Database";
DiagramLocalizationService.shapeTexts[ShapeTypes_1.ShapeTypes.HardDisk] = "Hard Disk";
DiagramLocalizationService.shapeTexts[ShapeTypes_1.ShapeTypes.InternalStorage] = "Internal Storage";
DiagramLocalizationService.shapeTexts[ShapeTypes_1.ShapeTypes.PaperTape] = "Paper Tape";
DiagramLocalizationService.shapeTexts[ShapeTypes_1.ShapeTypes.ManualOperation] = "Manual Operation";
DiagramLocalizationService.shapeTexts[ShapeTypes_1.ShapeTypes.Delay] = "Delay";
DiagramLocalizationService.shapeTexts[ShapeTypes_1.ShapeTypes.StoredData] = "Stored Data";
DiagramLocalizationService.shapeTexts[ShapeTypes_1.ShapeTypes.Display] = "Display";
DiagramLocalizationService.shapeTexts[ShapeTypes_1.ShapeTypes.Merge] = "Merge";
DiagramLocalizationService.shapeTexts[ShapeTypes_1.ShapeTypes.Connector] = "Connector";
DiagramLocalizationService.shapeTexts[ShapeTypes_1.ShapeTypes.Or] = "Or";
DiagramLocalizationService.shapeTexts[ShapeTypes_1.ShapeTypes.SummingJunction] = "Summing Junction";
DiagramLocalizationService.shapeTexts[ShapeTypes_1.ShapeTypes.Container] = "Container";
DiagramLocalizationService.shapeTexts[ShapeTypes_1.ShapeTypes.VerticalContainer] = "Vertical Container";
DiagramLocalizationService.shapeTexts[ShapeTypes_1.ShapeTypes.HorizontalContainer] = "Horizontal Container";
DiagramLocalizationService.shapeTexts[ShapeTypes_1.ShapeTypes.Card] = "Person's Name";
DiagramLocalizationService.shapeTexts[ShapeTypes_1.ShapeTypes.CardWithImageOnLeft] = "Card with Image on the Left";
DiagramLocalizationService.shapeTexts[ShapeTypes_1.ShapeTypes.CardWithImageOnTop] = "Card with Image on the Top";
DiagramLocalizationService.shapeTexts[ShapeTypes_1.ShapeTypes.CardWithImageOnRight] = "Card with Image on the Right";


/***/ }),
/* 37 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.ShapeParameters = exports.ShapeParameter = void 0;
var ShapeParameter = (function () {
    function ShapeParameter(key, value) {
        this.key = key;
        this.value = value;
    }
    return ShapeParameter;
}());
exports.ShapeParameter = ShapeParameter;
var ShapeParameters = (function () {
    function ShapeParameters() {
        this.items = {};
    }
    ShapeParameters.prototype.add = function (parameter) {
        this.items[parameter.key] = parameter;
    };
    ShapeParameters.prototype.addRange = function (parameters) {
        for (var i = 0; i < parameters.length; i++)
            this.add(parameters[i]);
    };
    ShapeParameters.prototype.get = function (key) {
        return this.items[key];
    };
    ShapeParameters.prototype.forEach = function (callback) {
        for (var key in this.items)
            if (Object.prototype.hasOwnProperty.call(this.items, key))
                callback(this.items[key]);
    };
    ShapeParameters.prototype.clone = function () {
        var result = new ShapeParameters();
        this.forEach(function (p) { result.add(new ShapeParameter(p.key, p.value)); });
        return result;
    };
    ShapeParameters.prototype.toObject = function () {
        var result = {};
        var modified = false;
        this.forEach(function (p) {
            result[p.key] = { "value": p.value };
            modified = true;
        });
        return modified ? result : null;
    };
    ShapeParameters.prototype.fromObject = function (obj) {
        this.forEach(function (p) {
            var paramObj = obj[p.key];
            if (paramObj)
                if (typeof paramObj["value"] === "number")
                    p.value = paramObj["value"];
        });
    };
    return ShapeParameters;
}());
exports.ShapeParameters = ShapeParameters;


/***/ }),
/* 38 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.ConnectionMode = exports.PositionInfo = exports.Edge = void 0;
var Edge = (function () {
    function Edge(key, from, to, weight) {
        if (weight === void 0) { weight = 1; }
        this.weight = weight;
        this.key = key;
        this.from = from;
        this.to = to;
    }
    Edge.prototype.getHashKey = function () {
        return this.from + "_" + this.to;
    };
    Edge.prototype.reverse = function () {
        return new Edge(this.key, this.to, this.from, this.weight);
    };
    return Edge;
}());
exports.Edge = Edge;
var PositionInfo = (function () {
    function PositionInfo(item, position) {
        this.item = item;
        this.position = position;
    }
    return PositionInfo;
}());
exports.PositionInfo = PositionInfo;
var ConnectionMode;
(function (ConnectionMode) {
    ConnectionMode[ConnectionMode["Outgoing"] = 1] = "Outgoing";
    ConnectionMode[ConnectionMode["Incoming"] = 2] = "Incoming";
    ConnectionMode[ConnectionMode["OutgoingAndIncoming"] = 3] = "OutgoingAndIncoming";
})(ConnectionMode = exports.ConnectionMode || (exports.ConnectionMode = {}));


/***/ }),
/* 39 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.GroupPrimitive = void 0;
var RenderHelper_1 = __webpack_require__(15);
var Primitive_1 = __webpack_require__(24);
var GroupPrimitive = (function (_super) {
    __extends(GroupPrimitive, _super);
    function GroupPrimitive(children, className, zIndex, clipPathId, onApplyProperties, onBeforeDispose) {
        var _this = _super.call(this, null, className, clipPathId, onApplyProperties) || this;
        _this.zIndex = zIndex;
        _this.onBeforeDispose = onBeforeDispose;
        _this.children = children;
        return _this;
    }
    GroupPrimitive.prototype.createMainElement = function () {
        return document.createElementNS(RenderHelper_1.svgNS, "g");
    };
    GroupPrimitive.prototype.applyElementProperties = function (element, measurer) {
        if (this.zIndex || this.zIndex === 0)
            element.style.setProperty("z-index", this.zIndex.toString());
        _super.prototype.applyElementProperties.call(this, element, measurer);
    };
    GroupPrimitive.prototype.dispose = function () {
        if (this.onBeforeDispose)
            this.onBeforeDispose();
        _super.prototype.dispose.call(this);
    };
    return GroupPrimitive;
}(Primitive_1.SvgPrimitive));
exports.GroupPrimitive = GroupPrimitive;


/***/ }),
/* 40 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.MouseHandlerCancellableState = exports.MouseHandlerStateBase = void 0;
var key_1 = __webpack_require__(25);
var MouseHandlerStateBase = (function () {
    function MouseHandlerStateBase(handler) {
        this.handler = handler;
    }
    MouseHandlerStateBase.prototype.start = function () { };
    MouseHandlerStateBase.prototype.finish = function () { };
    MouseHandlerStateBase.prototype.onMouseClick = function (_evt) { };
    MouseHandlerStateBase.prototype.onMouseDblClick = function (_evt) {
        this.handler.switchToDefaultState();
    };
    MouseHandlerStateBase.prototype.onMouseDown = function (_evt) { };
    MouseHandlerStateBase.prototype.onMouseUp = function (_evt) { };
    MouseHandlerStateBase.prototype.onMouseMove = function (_evt) { };
    MouseHandlerStateBase.prototype.onMouseWheel = function (_evt) { return false; };
    MouseHandlerStateBase.prototype.onDragStart = function (_evt) { };
    MouseHandlerStateBase.prototype.onDragEnd = function (_evt) { };
    MouseHandlerStateBase.prototype.onShortcut = function (_shortcutCode) { return false; };
    MouseHandlerStateBase.prototype.onKeyDown = function (_evt) { };
    MouseHandlerStateBase.prototype.onKeyUp = function (_evt) { };
    MouseHandlerStateBase.prototype.onConnectionPointsShow = function (key, points) { };
    MouseHandlerStateBase.prototype.onConnectionTargetShow = function (key, info) { };
    return MouseHandlerStateBase;
}());
exports.MouseHandlerStateBase = MouseHandlerStateBase;
var MouseHandlerCancellableState = (function (_super) {
    __extends(MouseHandlerCancellableState, _super);
    function MouseHandlerCancellableState() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    MouseHandlerCancellableState.prototype.onShortcut = function (code) {
        if (code === key_1.KeyCode.Esc) {
            this.cancelChanges();
            this.handler.switchToDefaultState();
            return true;
        }
        return false;
    };
    return MouseHandlerCancellableState;
}(MouseHandlerStateBase));
exports.MouseHandlerCancellableState = MouseHandlerCancellableState;


/***/ }),
/* 41 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

Object.defineProperty(exports, "__esModule", { value: true });
var SearchUtils = (function () {
    function SearchUtils() {
    }
    SearchUtils.binaryIndexOf = function (array, comparer, minIndex, maxIndex) {
        if (minIndex === void 0) { minIndex = 0; }
        if (maxIndex === void 0) { maxIndex = -2; }
        var findFromZeroPosition = minIndex === 0;
        if (maxIndex === -2)
            maxIndex = array.length - 1;
        while (minIndex <= maxIndex) {
            var currentIndex = (minIndex + ((maxIndex - minIndex) >> 1));
            var compare = comparer(array[currentIndex]);
            if (compare < 0)
                minIndex = currentIndex + 1;
            else if (compare > 0)
                maxIndex = currentIndex - 1;
            else
                return currentIndex;
        }
        return findFromZeroPosition ? ~minIndex : -1;
    };
    SearchUtils.normedBinaryIndexOf = function (array, comparer, minIndex, maxIndex) {
        if (minIndex === void 0) { minIndex = 0; }
        if (maxIndex === void 0) { maxIndex = -2; }
        var index = SearchUtils.binaryIndexOf(array, comparer, minIndex, maxIndex);
        return SearchUtils.binaryIndexNormalizator(index);
    };
    SearchUtils.binaryIndexNormalizator = function (index) {
        return index < 0 ? ~index - 1 : index;
    };
    SearchUtils.normedInterpolationIndexOf = function (array, getValue, toFind, lowIndex, highIndex) {
        if (lowIndex === void 0) { lowIndex = 0; }
        if (highIndex === void 0) { highIndex = -2; }
        if (highIndex === -2)
            highIndex = array.length - 1;
        var firstObject = array[Math.min(lowIndex, highIndex)];
        if (firstObject === undefined || toFind < getValue(firstObject))
            return -1;
        var lowValue = getValue(array[lowIndex]);
        var highValue = getValue(array[highIndex]);
        while (true) {
            if (toFind > lowValue && toFind < highValue) {
                var midIndex = lowIndex + Math.floor(((toFind - lowValue) * (highIndex - lowIndex)) / (highValue - lowValue));
                var midValue = getValue(array[midIndex]);
                if (toFind > midValue) {
                    lowIndex = midIndex + 1;
                    lowValue = getValue(array[lowIndex]);
                    if (toFind < lowValue)
                        return midIndex;
                }
                else if (toFind < midValue) {
                    highIndex = midIndex - 1;
                    highValue = getValue(array[highIndex]);
                }
                else
                    return midIndex;
            }
            else
                return toFind === lowValue ? lowIndex : highIndex;
        }
    };
    return SearchUtils;
}());
exports.SearchUtils = SearchUtils;


/***/ }),
/* 42 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.CanvasManagerBase = exports.PAGE_BG_TEXTFLOOR_FILTER_ID = void 0;
var TextFilterPrimitive_1 = __webpack_require__(172);
var unit_converter_1 = __webpack_require__(12);
exports.PAGE_BG_TEXTFLOOR_FILTER_ID = "page-text-flood";
var CanvasManagerBase = (function () {
    function CanvasManagerBase(actualZoom, dom) {
        this.elements = {};
        this.actualZoom = actualZoom;
        this.dom = dom;
    }
    CanvasManagerBase.prototype.createAndChangePrimitivesElements = function (primitives, parent) {
        var _this = this;
        primitives.forEach(function (primitive) {
            _this.createAndChangePrimitiveElement(primitive, parent);
        });
    };
    CanvasManagerBase.prototype.createPrimitiveElement = function (primitive, parent, sibling) {
        return this.dom.createElement(primitive, parent, sibling);
    };
    CanvasManagerBase.prototype.createAndChangePrimitiveElement = function (primitive, parent, sibling) {
        var element = this.createPrimitiveElement(primitive, parent, sibling);
        this.dom.changeByPrimitive(element, primitive);
        return element;
    };
    CanvasManagerBase.prototype.changePrimitiveElement = function (primitive, element) {
        this.dom.changeByPrimitive(element, primitive);
    };
    CanvasManagerBase.prototype.getOrCreateElement = function (key, primitive, parent, sibling) {
        var element = (key && this.elements[key]) || (this.elements[key] = this.createPrimitiveElement(primitive, parent, sibling));
        this.changePrimitiveElement(primitive, element);
        return element;
    };
    CanvasManagerBase.prototype.createTextFloodFilter = function (key, parent, pageColor) {
        this.getOrCreateElement(key, new TextFilterPrimitive_1.TextFloodFilterPrimitive(exports.PAGE_BG_TEXTFLOOR_FILTER_ID, pageColor), parent);
    };
    CanvasManagerBase.prototype.getAbsoluteSize = function (modelSize) {
        return modelSize
            .clone().applyConverter(unit_converter_1.UnitConverter.twipsToPixelsF)
            .clone().multiply(this.actualZoom, this.actualZoom);
    };
    return CanvasManagerBase;
}());
exports.CanvasManagerBase = CanvasManagerBase;


/***/ }),
/* 43 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.TextOwner = void 0;
var TextOwner;
(function (TextOwner) {
    TextOwner[TextOwner["Shape"] = 0] = "Shape";
    TextOwner[TextOwner["Connector"] = 1] = "Connector";
    TextOwner[TextOwner["ExtensionLine"] = 2] = "ExtensionLine";
    TextOwner[TextOwner["Resize"] = 3] = "Resize";
})(TextOwner = exports.TextOwner || (exports.TextOwner = {}));


/***/ }),
/* 44 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.Data = exports.SetAbsoluteY = exports.SetAbsoluteX = void 0;
var dom_1 = __webpack_require__(27);
var common_1 = __webpack_require__(50);
function IsNumber(str) {
    return !isNaN(parseFloat(str)) && isFinite(str);
}
function SetAbsoluteX(element, x) {
    element.style.left = prepareClientPosForElement(x, element, true) + "px";
}
exports.SetAbsoluteX = SetAbsoluteX;
function SetAbsoluteY(element, y) {
    element.style.top = prepareClientPosForElement(y, element, false) + "px";
}
exports.SetAbsoluteY = SetAbsoluteY;
function prepareClientPosForElement(pos, element, isX) {
    pos -= getPositionElementOffset(element, isX);
    return pos;
}
function getPositionElementOffset(element, isX) {
    var div = createElementMock(element);
    if (div.style.position === "static")
        div.style.position = "absolute";
    element.parentNode.appendChild(div);
    var realPos = isX ? dom_1.DomUtils.getAbsolutePositionX(div) : dom_1.DomUtils.getAbsolutePositionY(div);
    element.parentNode.removeChild(div);
    return Math.round(realPos);
}
function createElementMock(element) {
    var div = document.createElement("DIV");
    div.style.top = "0px";
    div.style.left = "0px";
    div.style.visibility = "hidden";
    div.style.position = dom_1.DomUtils.getCurrentStyle(element).position;
    return div;
}
var Data = (function () {
    function Data() {
    }
    Data.ArrayInsert = function (array, element, position) {
        if (0 <= position && position < array.length) {
            for (var i = array.length; i > position; i--)
                array[i] = array[i - 1];
            array[position] = element;
        }
        else
            array.push(element);
    };
    Data.ArrayRemove = function (array, element) {
        var index = Data.ArrayIndexOf(array, element);
        if (index > -1)
            Data.ArrayRemoveAt(array, index);
    };
    Data.ArrayRemoveAt = function (array, index) {
        if (index >= 0 && index < array.length) {
            for (var i = index; i < array.length - 1; i++)
                array[i] = array[i + 1];
            array.pop();
        }
    };
    Data.ArrayClear = function (array) {
        while (array.length > 0)
            array.pop();
    };
    Data.ArrayIndexOf = function (array, element, comparer) {
        if (!comparer)
            for (var i = 0; i < array.length; i++) {
                if (array[i] === element)
                    return i;
            }
        else
            for (var i = 0; i < array.length; i++)
                if (comparer(array[i], element))
                    return i;
        return -1;
    };
    Data.ArrayContains = function (array, element) {
        return Data.ArrayIndexOf(array, element) >= 0;
    };
    Data.ArrayEqual = function (array1, array2) {
        var count1 = array1.length;
        var count2 = array2.length;
        if (count1 !== count2)
            return false;
        for (var i = 0; i < count1; i++)
            if (array1[i] !== array2[i])
                return false;
        return true;
    };
    Data.ArraySame = function (array1, array2) {
        if (array1.length !== array2.length)
            return false;
        return array1.every(function (elem) { return Data.ArrayContains(array2, elem); });
    };
    Data.ArrayGetIntegerEdgeValues = function (array) {
        var arrayToSort = Data.CollectionToArray(array);
        Data.ArrayIntegerAscendingSort(arrayToSort);
        return {
            start: arrayToSort[0],
            end: arrayToSort[arrayToSort.length - 1]
        };
    };
    Data.ArrayIntegerAscendingSort = function (array) {
        Data.ArrayIntegerSort(array, false);
    };
    Data.ArrayIntegerSort = function (array, desc) {
        array.sort(function (i1, i2) {
            var res = 0;
            if (i1 > i2)
                res = 1;
            else if (i1 < i2)
                res = -1;
            if (desc)
                res *= -1;
            return res;
        });
    };
    Data.CollectionsUnionToArray = function (firstCollection, secondCollection) {
        var result = [];
        var firstCollectionLength = firstCollection.length;
        var secondCollectionLength = secondCollection.length;
        for (var i = 0; i < firstCollectionLength + secondCollectionLength; i++)
            if (i < firstCollectionLength)
                result.push(firstCollection[i]);
            else
                result.push(secondCollection[i - firstCollectionLength]);
        return result;
    };
    Data.CollectionToArray = function (collection) {
        var array = [];
        for (var i = 0; i < collection.length; i++)
            array.push(collection[i]);
        return array;
    };
    Data.CreateHashTableFromArray = function (array) {
        var hash = [];
        for (var i = 0; i < array.length; i++)
            hash[array[i]] = 1;
        return hash;
    };
    Data.CreateIndexHashTableFromArray = function (array) {
        var hash = [];
        for (var i = 0; i < array.length; i++)
            hash[array[i]] = i;
        return hash;
    };
    Data.ArrayToHash = function (array, getKeyFunc, getValueFunc) {
        if (!(array instanceof Array))
            return {};
        return array.reduce(function (map, element, index) {
            var key = getKeyFunc(element, index);
            var value = getValueFunc(element, index);
            map[key] = value;
            return map;
        }, {});
    };
    Data.Sum = function (array, getValueFunc) {
        if (!(array instanceof Array))
            return 0;
        return array.reduce(function (prevValue, item) {
            var value = getValueFunc ? getValueFunc(item) : item;
            if (!IsNumber(value))
                value = 0;
            return prevValue + value;
        }, 0);
    };
    Data.Min = function (array, getValueFunc) { return Data.CalculateArrayMinMax(array, getValueFunc, false); };
    Data.Max = function (array, getValueFunc) { return Data.CalculateArrayMinMax(array, getValueFunc, true); };
    Data.NearestLeftBinarySearchComparer = function (array, index, value) {
        var arrayElement = array[index];
        var leftPoint = arrayElement < value;
        var lastLeftPoint = leftPoint && index === array.length - 1;
        var nearestLeftPoint = lastLeftPoint || (leftPoint && array[index + 1] >= value);
        if (nearestLeftPoint)
            return 0;
        else
            return arrayElement < value ? -1 : 1;
    };
    Data.ArrayBinarySearch = function (array, value, binarySearchComparer, startIndex, length) {
        if (!binarySearchComparer)
            binarySearchComparer = Data.defaultBinarySearchComparer;
        if (!common_1.isDefined(startIndex))
            startIndex = 0;
        if (!common_1.isDefined(length))
            length = array.length - startIndex;
        var endIndex = (startIndex + length) - 1;
        while (startIndex <= endIndex) {
            var middle = (startIndex + ((endIndex - startIndex) >> 1));
            var compareResult = binarySearchComparer(array, middle, value);
            if (compareResult === 0)
                return middle;
            if (compareResult < 0)
                startIndex = middle + 1;
            else
                endIndex = middle - 1;
        }
        return -(startIndex + 1);
    };
    Data.ArrayFlatten = function (arrayOfArrays) {
        var result = [];
        arrayOfArrays.forEach(function (arr) {
            result = result.concat(arr);
        });
        return result;
    };
    Data.GetDistinctArray = function (array) {
        var resultArray = [];
        for (var i = 0; i < array.length; i++) {
            var currentEntry = array[i];
            if (Data.ArrayIndexOf(resultArray, currentEntry) === -1)
                resultArray.push(currentEntry);
        }
        return resultArray;
    };
    Data.ForEach = function (arr, callback) {
        if (Array.prototype.forEach)
            Array.prototype.forEach.call(arr, callback);
        else
            for (var i = 0, len = arr.length; i < len; i++)
                callback(arr[i], i, arr);
    };
    Data.MergeHashTables = function (target, object) {
        if (!object || typeof (object) === "string")
            return target;
        if (!target)
            target = {};
        for (var key in object)
            if (key && !(key in target))
                target[key] = object[key];
        return target;
    };
    Data.Range = function (count, start) {
        count = parseInt(count) || 0;
        start = parseInt(start) || 0;
        if (count < 0)
            count = 0;
        if (start < 0)
            start = 0;
        var result = Array(count);
        return result.map(function (_val, i) { return start + i; });
    };
    Data.CalculateArrayMinMax = function (array, getValueFunc, isMax) {
        if (!(array instanceof Array))
            return 0;
        var startValue = isMax ? Number.NEGATIVE_INFINITY : Number.POSITIVE_INFINITY;
        return array.reduce(function (prevValue, item) {
            var value = getValueFunc ? getValueFunc(item) : item;
            if (!IsNumber(value))
                value = startValue;
            var func = isMax ? Math.max : Math.min;
            return func(value, prevValue);
        }, startValue);
    };
    Data.byRange = function (value, min, max) {
        return Math.min(Math.max(value, min), max);
    };
    Data.defaultBinarySearchComparer = function (array, index, value) {
        var arrayElement = array[index];
        if (arrayElement === value)
            return 0;
        else
            return arrayElement < value ? -1 : 1;
    };
    Data.cssTextToObject = function (cssText) {
        if (!cssText)
            return {};
        cssText = cssText.replace(/\/\*(.|\s)*?\*\//g, "").replace(/\s+/g, " ");
        return cssText.split(";").reduce(function (acc, val) {
            if (val) {
                var matches = /\s*([^:]+?)\s*:\s*([^;]*)\s*$/.exec(val);
                if (matches) {
                    var name_1 = matches[1], value = matches[2];
                    name_1 && value && (acc[name_1.trim()] = value.trim());
                }
                return acc;
            }
            return acc;
        }, {});
    };
    Data.objectToCssText = function (obj) {
        if (!obj)
            return "";
        return Object.keys(obj).reduce(function (acc, key) {
            var name = key.trim();
            var value = obj[key];
            if (name && value)
                acc.push(name + ": " + value.toString().trim());
            return acc;
        }, []).join("; ");
    };
    return Data;
}());
exports.Data = Data;


/***/ }),
/* 45 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.ConnectionPoint = void 0;
var point_1 = __webpack_require__(0);
var DiagramItem_1 = __webpack_require__(9);
var ConnectionPoint = (function (_super) {
    __extends(ConnectionPoint, _super);
    function ConnectionPoint(x, y, side) {
        if (side === void 0) { side = DiagramItem_1.ConnectionPointSide.Undefined; }
        var _this = _super.call(this, x, y) || this;
        _this.side = side;
        return _this;
    }
    ConnectionPoint.prototype.offset = function (offsetX, offsetY) {
        _super.prototype.offset.call(this, offsetX, offsetY);
        this.side = DiagramItem_1.ConnectionPointSide.Undefined;
        return this;
    };
    ConnectionPoint.prototype.multiply = function (multiplierX, multiplierY) {
        _super.prototype.multiply.call(this, multiplierX, multiplierY);
        this.side = DiagramItem_1.ConnectionPointSide.Undefined;
        return this;
    };
    ConnectionPoint.prototype.clone = function () { return new ConnectionPoint(this.x, this.y, this.side); };
    ConnectionPoint.prototype.toPoint = function () { return new point_1.Point(this.x, this.y); };
    return ConnectionPoint;
}(point_1.Point));
exports.ConnectionPoint = ConnectionPoint;


/***/ }),
/* 46 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.ImageCache = exports.CacheImageInfo = void 0;
var base64_1 = __webpack_require__(83);
var ImageInfo_1 = __webpack_require__(51);
var Utils_1 = __webpack_require__(3);
var CacheImageInfo = (function () {
    function CacheImageInfo(base64, actualId, imageUrl, referenceInfo, isLoaded) {
        this._base64 = base64 !== undefined ? base64_1.Base64Utils.normalizeToDataUrl(base64, "image/png") : undefined;
        this.actualId = actualId;
        this._referenceInfo = referenceInfo;
        this._isLoaded = isLoaded !== undefined ? isLoaded : false;
        this.imageUrl = imageUrl;
    }
    Object.defineProperty(CacheImageInfo.prototype, "isLoaded", {
        get: function () { return this._referenceInfo ? this._referenceInfo._isLoaded : this._isLoaded; },
        set: function (val) { this._isLoaded = val; },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(CacheImageInfo.prototype, "base64", {
        get: function () { return this._base64; },
        set: function (val) { this._base64 = base64_1.Base64Utils.normalizeToDataUrl(val, "image/png"); },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(CacheImageInfo.prototype, "referenceInfo", {
        get: function () { return this._referenceInfo; },
        set: function (val) {
            this._referenceInfo = val;
            this._base64 = undefined;
            this._isLoaded = undefined;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(CacheImageInfo.prototype, "isLoading", {
        get: function () { return this._referenceInfo ? this.referenceInfo._isLoading : this._isLoading; },
        enumerable: false,
        configurable: true
    });
    CacheImageInfo.prototype.startLoading = function () {
        if (this._referenceInfo)
            this._referenceInfo.startLoading();
        else
            this._isLoading = true;
    };
    CacheImageInfo.prototype.finalizeLoading = function () {
        if (this._referenceInfo)
            this._referenceInfo.finalizeLoading();
        else
            this._isLoading = false;
    };
    return CacheImageInfo;
}());
exports.CacheImageInfo = CacheImageInfo;
var ImageCache = (function () {
    function ImageCache() {
        this.emptyImageId = 0;
        this.lastActualId = 0;
        this.onReadyStateChanged = new Utils_1.EventDispatcher();
        this.cache = [];
        this.nonLoadedImages = [];
        var emptyImage = this.createUnloadedInfoByBase64(ImageInfo_1.ImageInfo.transparentOnePixelImage);
        emptyImage.isLoaded = true;
    }
    ImageCache.prototype.reset = function () {
        this.cache.splice(1);
        this.nonLoadedImages = [];
        this.lastActualId = 1;
    };
    Object.defineProperty(ImageCache.prototype, "emptyImage", {
        get: function () { return this.cache[this.emptyImageId]; },
        enumerable: false,
        configurable: true
    });
    ImageCache.prototype.getImageData = function (id) {
        return this.cache[id];
    };
    ImageCache.prototype.createUnloadedInfoByUrl = function (imageUrl) {
        var info = this.findInfoByUrl(imageUrl);
        if (info)
            return info;
        return this.registerImageData(new CacheImageInfo(undefined, this.getNextActualId(), imageUrl));
    };
    ImageCache.prototype.createUnloadedInfoByBase64 = function (base64) {
        var info = this.findInfoByBase64(base64);
        if (info)
            return info;
        return this.registerImageData(new CacheImageInfo(base64, this.getNextActualId()));
    };
    ImageCache.prototype.createUnloadedInfoByShapeImageInfo = function (imageInfo) {
        var data = imageInfo.exportUrl;
        return base64_1.Base64Utils.checkPrependDataUrl(data) ?
            this.createUnloadedInfoByBase64(data) :
            this.createUnloadedInfoByUrl(data);
    };
    ImageCache.prototype.registerImageData = function (data) {
        var existingData = this.cache[data.actualId];
        if (!existingData)
            existingData = data;
        if (data.actualId !== undefined)
            this.cache[data.actualId] = existingData;
        if (data.actualId !== 0) {
            this.nonLoadedImages.push(data);
            if (this.nonLoadedImages.length === 1)
                this.raiseReadyStateChanged(false);
        }
        return existingData;
    };
    ImageCache.prototype.loadAllImages = function (loader) {
        var _this = this;
        this.cache.forEach(function (cacheInfo) {
            if (_this.emptyImageId !== cacheInfo.actualId && !cacheInfo.isLoaded && !cacheInfo.isLoading)
                loader.load(cacheInfo);
        });
    };
    ImageCache.prototype.finalizeLoading = function (existingInfo, loadedInfo) {
        existingInfo.finalizeLoading();
        existingInfo.isLoaded = true;
        var imageInfoIndex = this.nonLoadedImages.indexOf(existingInfo);
        this.nonLoadedImages.splice(imageInfoIndex, 1);
        if (this.nonLoadedImages.length === 0)
            this.raiseReadyStateChanged(true);
        if (existingInfo.referenceInfo)
            return;
        if (loadedInfo.base64) {
            var base64_2 = base64_1.Base64Utils.normalizeToDataUrl(loadedInfo.base64, "image/png");
            this.cache.forEach(function (cacheElem) {
                var isReference = cacheElem.base64 === base64_2 && cacheElem !== existingInfo && cacheElem.isLoaded;
                if (isReference)
                    existingInfo.referenceInfo = cacheElem.referenceInfo ? cacheElem.referenceInfo : cacheElem;
                return isReference;
            });
            existingInfo.base64 = base64_2;
        }
    };
    ImageCache.prototype.hasNonLoadedImages = function () {
        return this.nonLoadedImages.length !== 0;
    };
    ImageCache.prototype.getNextActualId = function () {
        return this.lastActualId++;
    };
    ImageCache.prototype.findInfoByBase64 = function (base64) {
        base64 = base64_1.Base64Utils.normalizeToDataUrl(base64, "image/png");
        return this.findInfoCore(function (cacheImageInfo) { return cacheImageInfo.base64 === base64; });
    };
    ImageCache.prototype.findInfoByUrl = function (imageUrl) {
        return this.findInfoCore(function (cacheImageInfo) { return cacheImageInfo.imageUrl === imageUrl; });
    };
    ImageCache.prototype.findInfoCore = function (callback) {
        var cacheInfo;
        this.cache.forEach(function (item) {
            if (callback(item))
                cacheInfo = item;
        });
        return cacheInfo;
    };
    ImageCache.prototype.raiseReadyStateChanged = function (ready) {
        this.onReadyStateChanged.raise1(function (l) { return l.notifyImageCacheReadyStateChanged(ready); });
    };
    ImageCache.instance = new ImageCache();
    return ImageCache;
}());
exports.ImageCache = ImageCache;


/***/ }),
/* 47 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.PageOrientation = exports.DiagramUnit = void 0;
var DiagramUnit;
(function (DiagramUnit) {
    DiagramUnit[DiagramUnit["In"] = 0] = "In";
    DiagramUnit[DiagramUnit["Cm"] = 1] = "Cm";
    DiagramUnit[DiagramUnit["Px"] = 2] = "Px";
})(DiagramUnit = exports.DiagramUnit || (exports.DiagramUnit = {}));
var PageOrientation;
(function (PageOrientation) {
    PageOrientation[PageOrientation["Portrait"] = 0] = "Portrait";
    PageOrientation[PageOrientation["Landscape"] = 1] = "Landscape";
})(PageOrientation = exports.PageOrientation || (exports.PageOrientation = {}));


/***/ }),
/* 48 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.SetConnectionPointIndexHistoryItem = exports.AddConnectionHistoryItem = void 0;
var HistoryItem_1 = __webpack_require__(8);
var Connector_1 = __webpack_require__(6);
var AddConnectionHistoryItem = (function (_super) {
    __extends(AddConnectionHistoryItem, _super);
    function AddConnectionHistoryItem(connector, item, connectionPointIndex, position) {
        var _this = _super.call(this) || this;
        _this.connectorKey = connector.key;
        _this.itemKey = item.key;
        _this.connectionPointIndex = connectionPointIndex;
        _this.position = position;
        return _this;
    }
    AddConnectionHistoryItem.prototype.redo = function (manipulator) {
        var connector = manipulator.model.findConnector(this.connectorKey);
        var item = manipulator.model.findItem(this.itemKey);
        manipulator.addConnection(connector, item, this.connectionPointIndex, this.position);
    };
    AddConnectionHistoryItem.prototype.undo = function (manipulator) {
        var connector = manipulator.model.findConnector(this.connectorKey);
        manipulator.deleteConnection(connector, this.position);
    };
    return AddConnectionHistoryItem;
}(HistoryItem_1.HistoryItem));
exports.AddConnectionHistoryItem = AddConnectionHistoryItem;
var SetConnectionPointIndexHistoryItem = (function (_super) {
    __extends(SetConnectionPointIndexHistoryItem, _super);
    function SetConnectionPointIndexHistoryItem(connector, connectionPointIndex, position) {
        var _this = _super.call(this) || this;
        _this.connectorKey = connector.key;
        _this.connectionPointIndex = connectionPointIndex;
        _this.position = position;
        return _this;
    }
    SetConnectionPointIndexHistoryItem.prototype.redo = function (manipulator) {
        var connector = manipulator.model.findConnector(this.connectorKey);
        this.oldConnectionPointIndex = this.position === Connector_1.ConnectorPosition.Begin ? connector.beginConnectionPointIndex : connector.endConnectionPointIndex;
        manipulator.setConnectionPointIndex(connector, this.connectionPointIndex, this.position);
    };
    SetConnectionPointIndexHistoryItem.prototype.undo = function (manipulator) {
        var connector = manipulator.model.findConnector(this.connectorKey);
        manipulator.setConnectionPointIndex(connector, this.oldConnectionPointIndex, this.position);
    };
    return SetConnectionPointIndexHistoryItem;
}(HistoryItem_1.HistoryItem));
exports.SetConnectionPointIndexHistoryItem = SetConnectionPointIndexHistoryItem;


/***/ }),
/* 49 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

Object.defineProperty(exports, "__esModule", { value: true });
var StringUtils = (function () {
    function StringUtils() {
    }
    StringUtils.isAlpha = function (ch) {
        return (ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z');
    };
    StringUtils.isDigit = function (ch) {
        return ch >= '0' && ch <= '9';
    };
    StringUtils.stringHashCode = function (str) {
        var hash = 0;
        if (str.length === 0)
            return hash;
        var strLen = str.length;
        for (var i = 0; i < strLen; i++) {
            hash = ((hash << 5) - hash) + str.charCodeAt(i);
            hash |= 0;
        }
        return hash;
    };
    StringUtils.endsAt = function (str, template) {
        var strInd = str.length - 1;
        var tmplInd = template.length - 1;
        var strStartInd = strInd - tmplInd;
        if (strStartInd < 0)
            return false;
        for (; strInd >= strStartInd; strInd--, tmplInd--) {
            if (str[strInd] !== template[tmplInd])
                return false;
        }
        return true;
    };
    StringUtils.startsAt = function (str, template) {
        return str.substr(0, template.length) === template;
    };
    StringUtils.stringInLowerCase = function (str) {
        return str.toLowerCase() === str;
    };
    StringUtils.stringInUpperCase = function (str) {
        return str.toUpperCase() === str;
    };
    StringUtils.atLeastOneSymbolInUpperCase = function (str) {
        for (var i = 0, char = void 0; char = str[i]; i++) {
            if (StringUtils.stringInUpperCase(char) && !StringUtils.stringInLowerCase(char))
                return true;
        }
        return false;
    };
    StringUtils.getSymbolFromEnd = function (text, posFromEnd) {
        return text[text.length - posFromEnd];
    };
    StringUtils.trim = function (str, trimChars) {
        if (trimChars === undefined)
            return StringUtils.trimInternal(str, true, true);
        else {
            var joinedChars = trimChars.join('');
            return str.replace(new RegExp("(^[" + joinedChars + "]*)|([" + joinedChars + "]*$)", 'g'), '');
        }
    };
    StringUtils.trimStart = function (str, trimChars) {
        if (trimChars === undefined)
            return StringUtils.trimInternal(str, true, false);
        else {
            var joinedChars = trimChars.join('');
            return str.replace(new RegExp("^[" + joinedChars + "]*", 'g'), '');
        }
    };
    StringUtils.trimEnd = function (str, trimChars) {
        if (trimChars === undefined)
            return StringUtils.trimInternal(str, false, true);
        else {
            var joinedChars = trimChars.join('');
            return str.replace(new RegExp("[" + joinedChars + "]*$", 'g'), '');
        }
    };
    StringUtils.getDecimalSeparator = function () {
        return (1.1).toLocaleString().substr(1, 1);
    };
    StringUtils.repeat = function (str, count) {
        return new Array(count <= 0 ? 0 : count + 1).join(str);
    };
    StringUtils.isNullOrEmpty = function (str) {
        return !str || !str.length;
    };
    StringUtils.padLeft = function (str, totalWidth, paddingChar) {
        return StringUtils.repeat(paddingChar, Math.max(0, totalWidth - str.length)) + str;
    };
    StringUtils.trimInternal = function (source, trimStart, trimEnd) {
        var len = source.length;
        if (!len)
            return source;
        if (len < 0xBABA1) {
            var result = source;
            if (trimStart)
                result = result.replace(/^\s+/, '');
            if (trimEnd)
                result = result.replace(/\s+$/, '');
            return result;
        }
        else {
            var start = 0;
            if (trimEnd) {
                while (len > 0 && /\s/.test(source[len - 1]))
                    len--;
            }
            if (trimStart && len > 0) {
                while (start < len && /\s/.test(source[start]))
                    start++;
            }
            return source.substring(start, len);
        }
    };
    return StringUtils;
}());
exports.StringUtils = StringUtils;


/***/ }),
/* 50 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

Object.defineProperty(exports, "__esModule", { value: true });
var string_1 = __webpack_require__(49);
function isDefined(value) {
    return value !== undefined && value !== null;
}
exports.isDefined = isDefined;
function boolToInt(value) {
    return value ? 1 : 0;
}
exports.boolToInt = boolToInt;
function boolToString(value) {
    return value ? '1' : '0';
}
exports.boolToString = boolToString;
function isNumber(obj) {
    return typeof obj === 'number';
}
exports.isNumber = isNumber;
function isString(obj) {
    return typeof obj === 'string';
}
exports.isString = isString;
function isNonNullString(str) {
    return !!str;
}
exports.isNonNullString = isNonNullString;
function isEven(num) {
    return (num % 2) !== 0;
}
exports.isEven = isEven;
function isOdd(num) {
    return (num % 2) === 0;
}
exports.isOdd = isOdd;
function numberToStringBin(num, minLength) {
    if (minLength === void 0) { minLength = 0; }
    return string_1.StringUtils.padLeft(num.toString(2), minLength, '0');
}
exports.numberToStringBin = numberToStringBin;
function numberToStringHex(num, minLength) {
    if (minLength === void 0) { minLength = 0; }
    return string_1.StringUtils.padLeft(num.toString(16), minLength, '0');
}
exports.numberToStringHex = numberToStringHex;


/***/ }),
/* 51 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.ImageInfo = void 0;
var base64_1 = __webpack_require__(83);
var ImageInfo = (function () {
    function ImageInfo(imageUrlOrBase64) {
        this.url = undefined;
        this.base64 = undefined;
        if (imageUrlOrBase64)
            if (base64_1.Base64Utils.checkPrependDataUrl(imageUrlOrBase64))
                this.base64 = imageUrlOrBase64;
            else
                this.url = imageUrlOrBase64;
        this.loadFailed = false;
    }
    ImageInfo.prototype.clone = function () {
        var result = new ImageInfo();
        result.url = this.url;
        result.base64 = this.base64;
        return result;
    };
    Object.defineProperty(ImageInfo.prototype, "isEmpty", {
        get: function () { return this.url === undefined && this.base64 === undefined; },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(ImageInfo.prototype, "unableToLoad", {
        get: function () { return this.loadFailed; },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(ImageInfo.prototype, "renderUrl", {
        get: function () { return this.base64 || ""; },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(ImageInfo.prototype, "exportUrl", {
        get: function () { return this.base64 ? this.base64 : this.url; },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(ImageInfo.prototype, "actualUrl", {
        get: function () { return this.url ? this.url : this.base64; },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(ImageInfo, "transparentOnePixelImage", {
        get: function () { return this.transparentWhiteImage1_1; },
        enumerable: false,
        configurable: true
    });
    ImageInfo.prototype.loadBase64Content = function (base64Content) {
        this.base64 = base64_1.Base64Utils.normalizeToDataUrl(base64Content, "image/png");
    };
    ImageInfo.prototype.setUnableToLoadFlag = function () {
        this.loadFailed = true;
    };
    ImageInfo.transparentWhiteImage1_1 = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAANSURBVBhXY/j///9/AAn7A/0FQ0XKAAAAAElFTkSuQmCC";
    return ImageInfo;
}());
exports.ImageInfo = ImageInfo;


/***/ }),
/* 52 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.ConnectorPointsOrthogonalSideCalculatorBase = void 0;
var rectangle_1 = __webpack_require__(13);
var DiagramItem_1 = __webpack_require__(9);
var Connector_1 = __webpack_require__(6);
var ConnectorPointsOrthogonalSideCalculatorBase = (function () {
    function ConnectorPointsOrthogonalSideCalculatorBase(parent) {
        this.parent = parent;
    }
    Object.defineProperty(ConnectorPointsOrthogonalSideCalculatorBase.prototype, "connector", {
        get: function () { return this.parent.connector; },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(ConnectorPointsOrthogonalSideCalculatorBase.prototype, "beginRect", {
        get: function () { return this.parent.beginRect; },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(ConnectorPointsOrthogonalSideCalculatorBase.prototype, "endRect", {
        get: function () { return this.parent.endRect; },
        enumerable: false,
        configurable: true
    });
    ConnectorPointsOrthogonalSideCalculatorBase.prototype.getBeginOffsetPoints = function (targetSide, originPoint, targetPoint, originRect) {
        originPoint = this.getCorrectOriginPoint(originPoint, originRect);
        if (targetSide !== DiagramItem_1.ConnectionPointSide.Undefined) {
            if (this.isBeginEndSame())
                return this.getSameShapeOffsetPoints(targetSide, originPoint, targetPoint, originRect);
            else if (this.isBeginEndOverlappedPoints(originPoint, targetPoint))
                return this.getOverlappedPointsOffsetPoints(targetSide, originPoint, targetPoint, originRect);
            else if (this.isBeginEndOverlapped())
                return this.getBeginOverlappedShapeOffsetPoints(targetSide, originPoint, targetPoint, originRect);
        }
        else if (this.isOriginRectContainsTargetPoint(originRect, targetPoint))
            return this.getOverlappedPointsOffsetPoints(targetSide, originPoint, targetPoint, originRect);
        if (this.isOnSidePoint(originPoint, targetPoint))
            return this.getBeginOnSideOffsetPoints(targetSide, originPoint, targetPoint, originRect);
        return this.getBeginOffSideOffsetPoints(targetSide, originPoint, targetPoint, originRect);
    };
    ConnectorPointsOrthogonalSideCalculatorBase.prototype.getEndOffsetPoints = function (targetSide, originPoint, targetPoint, originRect) {
        originPoint = this.getCorrectOriginPoint(originPoint, originRect);
        if (targetSide !== DiagramItem_1.ConnectionPointSide.Undefined) {
            if (this.isBeginEndSame())
                return this.getSameShapeOffsetPoints(targetSide, originPoint, targetPoint, originRect);
            else if (this.isBeginEndOverlappedPoints(targetPoint, originPoint))
                return this.getOverlappedPointsOffsetPoints(targetSide, originPoint, targetPoint, originRect);
            else if (this.isBeginEndOverlapped())
                return this.getEndOverlappedShapeOffsetPoints(targetSide, originPoint, targetPoint, originRect);
        }
        else if (this.isOriginRectContainsTargetPoint(originRect, targetPoint))
            return this.getOverlappedPointsOffsetPoints(targetSide, originPoint, targetPoint, originRect);
        if (this.isOnSidePoint(originPoint, targetPoint))
            return this.getEndOnSideOffsetPoints(targetSide, originPoint, targetPoint, originRect);
        return this.getEndOffSideOffsetPoints(targetSide, originPoint, targetPoint, originRect);
    };
    ConnectorPointsOrthogonalSideCalculatorBase.prototype.getSide = function (originPoint, targetPoint) {
        var diffX = Math.abs(targetPoint.x - originPoint.x);
        var diffY = Math.abs(targetPoint.y - originPoint.y);
        if (diffX > diffY)
            if (targetPoint.x > originPoint.x)
                return DiagramItem_1.ConnectionPointSide.East;
            else
                return DiagramItem_1.ConnectionPointSide.West;
        else if (targetPoint.y > originPoint.y)
            return DiagramItem_1.ConnectionPointSide.South;
        else
            return DiagramItem_1.ConnectionPointSide.North;
    };
    ConnectorPointsOrthogonalSideCalculatorBase.prototype.getSideCalculator = function (originPoint, targetPoint) {
        return this.parent.getSideCalculator(this.getSide(originPoint, targetPoint));
    };
    ConnectorPointsOrthogonalSideCalculatorBase.prototype.getMinOffset = function () {
        return Connector_1.Connector.minOffset;
    };
    ConnectorPointsOrthogonalSideCalculatorBase.prototype.isBeginEndSame = function () {
        return this.connector.beginItem === this.connector.endItem;
    };
    ConnectorPointsOrthogonalSideCalculatorBase.prototype.isBeginEndOverlapped = function () {
        return this.beginRect && this.endRect && rectangle_1.Rectangle.areIntersected(this.beginRect, this.endRect);
    };
    ConnectorPointsOrthogonalSideCalculatorBase.prototype.isBeginEndOverlappedX = function () {
        return this.beginRect && this.endRect && !!rectangle_1.Rectangle.getHorizIntersection(this.beginRect, this.endRect);
    };
    ConnectorPointsOrthogonalSideCalculatorBase.prototype.isBeginEndOverlappedY = function () {
        return this.beginRect && this.endRect && !!rectangle_1.Rectangle.getVertIntersection(this.beginRect, this.endRect);
    };
    ConnectorPointsOrthogonalSideCalculatorBase.prototype.isBeginEndOverlappedPoints = function (beginPoint, endPoint) {
        return this.beginRect && this.endRect && (this.beginRect.containsPoint(endPoint) || this.endRect.containsPoint(beginPoint));
    };
    ConnectorPointsOrthogonalSideCalculatorBase.prototype.isOriginRectContainsTargetPoint = function (originRect, targetPoint) {
        return originRect && targetPoint && originRect.containsPoint(targetPoint);
    };
    return ConnectorPointsOrthogonalSideCalculatorBase;
}());
exports.ConnectorPointsOrthogonalSideCalculatorBase = ConnectorPointsOrthogonalSideCalculatorBase;


/***/ }),
/* 53 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.AddShapeHistoryItem = void 0;
var HistoryItem_1 = __webpack_require__(8);
var Shape_1 = __webpack_require__(14);
var AddShapeHistoryItem = (function (_super) {
    __extends(AddShapeHistoryItem, _super);
    function AddShapeHistoryItem(shapeDescription, position, text, dataKey) {
        var _this = _super.call(this) || this;
        _this.shapeDescription = shapeDescription;
        _this.position = position;
        _this.text = text;
        _this.dataKey = dataKey;
        return _this;
    }
    AddShapeHistoryItem.prototype.redo = function (manipulator) {
        var shape = new Shape_1.Shape(this.shapeDescription, this.position);
        if (typeof this.text === "string")
            shape.text = this.text;
        if (this.dataKey !== undefined)
            shape.dataKey = this.dataKey;
        manipulator.addShape(shape, this.shapeKey);
        this.shapeKey = shape.key;
    };
    AddShapeHistoryItem.prototype.undo = function (manipulator) {
        manipulator.deleteShape(manipulator.model.findShape(this.shapeKey), true);
    };
    return AddShapeHistoryItem;
}(HistoryItem_1.HistoryItem));
exports.AddShapeHistoryItem = AddShapeHistoryItem;


/***/ }),
/* 54 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.GraphIterator = exports.FastGraph = exports.Graph = void 0;
var Structures_1 = __webpack_require__(38);
var Shape_1 = __webpack_require__(14);
var search_1 = __webpack_require__(41);
var ListUtils_1 = __webpack_require__(90);
var GraphBase = (function () {
    function GraphBase(nodes, edges) {
        this.nodeMap = {};
        this.edgeMap = {};
        this.nodes = [];
        this.edges = [];
        this.onInit();
        nodes.forEach(this.addNode.bind(this));
        edges.forEach(this.addEdge.bind(this));
    }
    Object.defineProperty(GraphBase.prototype, "items", {
        get: function () {
            return this.nodes.map(this.getNode.bind(this));
        },
        enumerable: false,
        configurable: true
    });
    GraphBase.prototype.onInit = function () { };
    GraphBase.prototype.addEdge = function (edge) {
        this.edgeMap[edge.key] = edge;
        this.edges.push(edge);
    };
    GraphBase.prototype.addNode = function (node) {
        this.nodeMap[node.key] = node;
        this.nodes.push(node.key);
    };
    GraphBase.prototype.getNode = function (key) {
        return this.nodeMap[key];
    };
    GraphBase.prototype.getEdge = function (key) {
        return this.edgeMap[key];
    };
    GraphBase.prototype.isEmpty = function () {
        return !this.nodes.length && !this.edges.length;
    };
    GraphBase.prototype.getAdjacentEdges = function (nodeKey, connectionMode) {
        if (connectionMode === void 0) { connectionMode = Structures_1.ConnectionMode.OutgoingAndIncoming; }
        return this.edges.filter(function (e) {
            return connectionMode & Structures_1.ConnectionMode.Incoming && e.to === nodeKey ||
                connectionMode & Structures_1.ConnectionMode.Outgoing && e.from === nodeKey;
        });
    };
    return GraphBase;
}());
var Graph = (function (_super) {
    __extends(Graph, _super);
    function Graph() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    Graph.prototype.cast = function (castNode, castEdge) {
        var _this = this;
        var newNodes = this.nodes.map(function (nk) { return castNode(_this.getNode(nk)); });
        var newEdges = this.edges.map(function (e) { return castEdge ? castEdge(e) : e; });
        return new Graph(newNodes, newEdges);
    };
    Graph.prototype.getConnectedComponents = function () {
        var iterator = this.createIterator(Structures_1.ConnectionMode.OutgoingAndIncoming);
        iterator.visitEachEdgeOnce = true;
        var components = [];
        var _loop_1 = function (i) {
            var nodes = [];
            var edges = [];
            iterator.onNode = function (n) { return nodes.push(n); };
            iterator.onEdge = function (e) { return edges.push(e); };
            iterator.iterate(this_1.nodes[i]);
            if (nodes.length)
                components.push(new Graph(nodes, edges));
        };
        var this_1 = this;
        for (var i = 0; i < this.nodes.length; i++) {
            _loop_1(i);
        }
        return components;
    };
    Graph.prototype.createIterator = function (connectionMode) {
        var iterator = new GraphIterator(this, connectionMode);
        iterator.comparer = function (a, b) { return a.weight - b.weight; };
        return iterator;
    };
    Graph.prototype.getSpanningGraph = function (rootKey, connectionMode, edgeWeightFunc) {
        var _this = this;
        if (edgeWeightFunc === void 0) { edgeWeightFunc = undefined; }
        if (!this.nodes.length)
            return new Graph([], []);
        if (!edgeWeightFunc)
            edgeWeightFunc = function (e) { return e.weight; };
        var sortedAdjacentEdges = [];
        var spanningTreeNodesSet = new ListUtils_1.HashSet();
        var spanningTreeEdgesSet = new ListUtils_1.HashSet([], function (e) { return e.getHashKey(); });
        this.addNodeToSpanningGraph(rootKey, connectionMode, sortedAdjacentEdges, spanningTreeNodesSet, spanningTreeEdgesSet, edgeWeightFunc);
        while (sortedAdjacentEdges.length && spanningTreeNodesSet.length !== this.nodes.length) {
            var minWeighedEdge = sortedAdjacentEdges.shift();
            spanningTreeEdgesSet.tryPush(minWeighedEdge);
            var node = spanningTreeNodesSet.contains(minWeighedEdge.from) ? minWeighedEdge.to : minWeighedEdge.from;
            this.addNodeToSpanningGraph(node, connectionMode, sortedAdjacentEdges, spanningTreeNodesSet, spanningTreeEdgesSet, edgeWeightFunc);
            sortedAdjacentEdges = sortedAdjacentEdges.filter(function (e) { return !spanningTreeNodesSet.contains(e.from) || !spanningTreeNodesSet.contains(e.to); });
        }
        return new Graph(spanningTreeNodesSet.list().map(function (nk) { return _this.getNode(nk); }), spanningTreeEdgesSet.list());
    };
    Graph.prototype.addNodeToSpanningGraph = function (nodeKey, connectionMode, adjacentEdges, spanningTreeNodesSet, spanningTreeEdgesSet, edgeWeightFunc) {
        spanningTreeNodesSet.tryPush(nodeKey);
        this.getAdjacentEdges(nodeKey, connectionMode)
            .filter(function (e) { return !spanningTreeEdgesSet.contains(e); })
            .forEach(function (e) {
            var weight = edgeWeightFunc(e);
            var pos = search_1.SearchUtils.binaryIndexOf(adjacentEdges, function (a) { return a.weight - weight; });
            pos = pos < 0 ? ~pos : pos;
            while (pos < adjacentEdges.length && edgeWeightFunc(adjacentEdges[pos]) === weight)
                pos++;
            adjacentEdges.splice(pos, 0, new Structures_1.Edge(e.key, e.from, e.to, weight));
        });
    };
    Graph.create = function (shapes, connectors) {
        var nodes = shapes;
        var edges = connectors
            .filter(function (i) { return i.beginItem && i.endItem instanceof Shape_1.Shape && i.endItem && i.endItem instanceof Shape_1.Shape && i.beginItem !== i.endItem; })
            .map(function (i) { return new Structures_1.Edge(i.key, i.beginItem && i.beginItem.key, i.endItem && i.endItem.key); });
        return new Graph(nodes, edges);
    };
    return Graph;
}(GraphBase));
exports.Graph = Graph;
var FastGraph = (function (_super) {
    __extends(FastGraph, _super);
    function FastGraph() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    FastGraph.prototype.onInit = function () {
        this.parentToChildren = {};
        this.childToParents = {};
    };
    FastGraph.prototype.addEdge = function (edge) {
        _super.prototype.addEdge.call(this, edge);
        (this.parentToChildren[edge.from] || (this.parentToChildren[edge.from] = [])).push(edge.to);
        (this.childToParents[edge.to] || (this.childToParents[edge.to] = [])).push(edge.from);
    };
    FastGraph.prototype.getChildren = function (parent) {
        return this.parentToChildren[parent] || [];
    };
    FastGraph.prototype.getParents = function (child) {
        return this.childToParents[child] || [];
    };
    FastGraph.prototype.createIterator = function (connectionMode) {
        return new GraphIterator(this, connectionMode);
    };
    return FastGraph;
}(GraphBase));
exports.FastGraph = FastGraph;
var GraphIterator = (function () {
    function GraphIterator(graph, connectionMode) {
        if (connectionMode === void 0) { connectionMode = Structures_1.ConnectionMode.OutgoingAndIncoming; }
        this.graph = graph;
        this.connectionMode = connectionMode;
        this.visitEachEdgeOnce = true;
        this.visitEachNodeOnce = true;
        this.visitedNodes = {};
        this.visitedEdges = {};
    }
    GraphIterator.prototype.iterate = function (nodeKey) {
        if (!this.visitEachNodeOnce && !this.visitEachEdgeOnce && !this.skipNode)
            throw "skipNode or visitEachNodeOnce or visitEachEdgeOnce must be set to avoid SOF";
        this.iterateCore(nodeKey);
    };
    GraphIterator.prototype.iterateCore = function (nodeKey) {
        var _this = this;
        var node = this.graph.getNode(nodeKey);
        if (!node || (this.skipNode && this.skipNode(node)) || (this.visitEachNodeOnce && this.isNodeVisited(nodeKey)))
            return;
        this.visitedNodes[nodeKey] = true;
        this.onNode && this.onNode(node);
        var edges = this.graph.getAdjacentEdges(nodeKey, this.connectionMode);
        if (this.skipEdge)
            edges = edges.filter(function (e) { return !_this.skipEdge(e); });
        if (this.connectionMode & Structures_1.ConnectionMode.Outgoing) {
            var outgoing = edges.filter(function (e) { return e.from === nodeKey; });
            if (this.comparer)
                outgoing.sort(this.comparer);
            outgoing.forEach(function (e) {
                if (_this.visitEachEdgeOnce && _this.visitedEdges[e.key])
                    return;
                _this.visitedEdges[e.key] = true;
                _this.onEdge && _this.onEdge(e, true);
                _this.iterateCore(e.to);
                _this.onAfterEdge && _this.onAfterEdge(e, true);
            });
        }
        this.onAllEdges && this.onAllEdges(node, true);
        if (this.connectionMode & Structures_1.ConnectionMode.Incoming) {
            var incoming = edges.filter(function (e) { return e.to === nodeKey; });
            if (this.comparer)
                incoming.sort(this.comparer);
            incoming.forEach(function (e) {
                if (_this.visitEachEdgeOnce && _this.visitedEdges[e.key])
                    return;
                _this.visitedEdges[e.key] = true;
                _this.onEdge && _this.onEdge(e, false);
                _this.iterateCore(e.from);
                _this.onAfterEdge && _this.onAfterEdge(e, false);
            });
        }
        this.onAllEdges && this.onAllEdges(node, false);
    };
    GraphIterator.prototype.isNodeVisited = function (nodeKey) {
        return !!this.visitedNodes[nodeKey];
    };
    GraphIterator.prototype.isEdgeVisited = function (edgeKey) {
        return !!this.visitedEdges[edgeKey];
    };
    return GraphIterator;
}());
exports.GraphIterator = GraphIterator;


/***/ }),
/* 55 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.EllipsePrimitive = void 0;
var RenderHelper_1 = __webpack_require__(15);
var Primitive_1 = __webpack_require__(24);
var EllipsePrimitive = (function (_super) {
    __extends(EllipsePrimitive, _super);
    function EllipsePrimitive(cx, cy, rx, ry, style, className, onApplyProperties) {
        var _this = _super.call(this, style, className, undefined, onApplyProperties) || this;
        _this.cx = cx;
        _this.cy = cy;
        _this.rx = rx;
        _this.ry = ry;
        return _this;
    }
    EllipsePrimitive.prototype.createMainElement = function () {
        return document.createElementNS(RenderHelper_1.svgNS, "ellipse");
    };
    EllipsePrimitive.prototype.applyElementProperties = function (element, measurer) {
        this.setUnitAttribute(element, "cx", this.cx);
        this.setUnitAttribute(element, "cy", this.cy);
        this.setUnitAttribute(element, "rx", this.rx);
        this.setUnitAttribute(element, "ry", this.ry);
        this.setPositionCorrectionAttribute(element);
        _super.prototype.applyElementProperties.call(this, element, measurer);
    };
    return EllipsePrimitive;
}(Primitive_1.SvgPrimitive));
exports.EllipsePrimitive = EllipsePrimitive;


/***/ }),
/* 56 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.ClipPathPrimitive = void 0;
var RenderHelper_1 = __webpack_require__(15);
var Primitive_1 = __webpack_require__(24);
var ClipPathPrimitive = (function (_super) {
    __extends(ClipPathPrimitive, _super);
    function ClipPathPrimitive(id, children) {
        var _this = _super.call(this) || this;
        _this.id = id;
        _this.children = children;
        return _this;
    }
    ClipPathPrimitive.prototype.createMainElement = function () {
        var element = document.createElementNS(RenderHelper_1.svgNS, "clipPath");
        element.setAttribute("id", this.id);
        return element;
    };
    ClipPathPrimitive.prototype.applyElementProperties = function (element, measurer) {
        if (this.id)
            element.setAttribute("id", this.id);
        _super.prototype.applyElementProperties.call(this, element, measurer);
    };
    return ClipPathPrimitive;
}(Primitive_1.SvgPrimitive));
exports.ClipPathPrimitive = ClipPathPrimitive;


/***/ }),
/* 57 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.ExportImportCommandBase = void 0;
var SimpleCommandBase_1 = __webpack_require__(10);
var ExportImportCommandBase = (function (_super) {
    __extends(ExportImportCommandBase, _super);
    function ExportImportCommandBase() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    ExportImportCommandBase.prototype.isEnabledInReadOnlyMode = function () {
        return true;
    };
    return ExportImportCommandBase;
}(SimpleCommandBase_1.SimpleCommandBase));
exports.ExportImportCommandBase = ExportImportCommandBase;


/***/ }),
/* 58 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.DiagramModelOperation = exports.Diagnostics = exports.RenderHelper = exports.DiagramLocalizationService = exports.NativeConnector = exports.NativeShape = exports.ShapeType = exports.ColorUtils = exports.PageOrientation = exports.ConnectorPosition = exports.ConnectorLineOption = exports.ConnectorLineEnding = exports.AutoZoomMode = exports.Browser = exports.UnitConverter = exports.EventDispatcher = exports.DataLayoutOrientation = exports.DataLayoutType = exports.ShapeCategories = exports.ShapeTypes = exports.DiagramUnit = exports.default = exports.DiagramControl = exports.DiagramCommand = exports.Point = exports.Size = void 0;
var CommandManager_1 = __webpack_require__(82);
Object.defineProperty(exports, "DiagramCommand", { enumerable: true, get: function () { return CommandManager_1.DiagramCommand; } });
var Diagram_1 = __webpack_require__(301);
Object.defineProperty(exports, "DiagramControl", { enumerable: true, get: function () { return Diagram_1.DiagramControl; } });
Object.defineProperty(exports, "default", { enumerable: true, get: function () { return Diagram_1.DiagramControl; } });
var size_1 = __webpack_require__(2);
Object.defineProperty(exports, "Size", { enumerable: true, get: function () { return size_1.Size; } });
var point_1 = __webpack_require__(0);
Object.defineProperty(exports, "Point", { enumerable: true, get: function () { return point_1.Point; } });
var Utils_1 = __webpack_require__(3);
Object.defineProperty(exports, "EventDispatcher", { enumerable: true, get: function () { return Utils_1.EventDispatcher; } });
var ShapeTypes_1 = __webpack_require__(1);
Object.defineProperty(exports, "ShapeTypes", { enumerable: true, get: function () { return ShapeTypes_1.ShapeTypes; } });
Object.defineProperty(exports, "ShapeCategories", { enumerable: true, get: function () { return ShapeTypes_1.ShapeCategories; } });
Object.defineProperty(exports, "ShapeType", { enumerable: true, get: function () { return ShapeTypes_1.ShapeType; } });
var unit_converter_1 = __webpack_require__(12);
Object.defineProperty(exports, "UnitConverter", { enumerable: true, get: function () { return unit_converter_1.UnitConverter; } });
var browser_1 = __webpack_require__(18);
Object.defineProperty(exports, "Browser", { enumerable: true, get: function () { return browser_1.Browser; } });
var Settings_1 = __webpack_require__(28);
Object.defineProperty(exports, "AutoZoomMode", { enumerable: true, get: function () { return Settings_1.AutoZoomMode; } });
var DataLayoutParameters_1 = __webpack_require__(103);
Object.defineProperty(exports, "DataLayoutType", { enumerable: true, get: function () { return DataLayoutParameters_1.DataLayoutType; } });
var LayoutSettings_1 = __webpack_require__(20);
Object.defineProperty(exports, "DataLayoutOrientation", { enumerable: true, get: function () { return LayoutSettings_1.DataLayoutOrientation; } });
__webpack_require__(380);
var ConnectorProperties_1 = __webpack_require__(32);
Object.defineProperty(exports, "ConnectorLineEnding", { enumerable: true, get: function () { return ConnectorProperties_1.ConnectorLineEnding; } });
Object.defineProperty(exports, "ConnectorLineOption", { enumerable: true, get: function () { return ConnectorProperties_1.ConnectorLineOption; } });
var color_1 = __webpack_require__(22);
Object.defineProperty(exports, "ColorUtils", { enumerable: true, get: function () { return color_1.ColorUtils; } });
var Diagnostics_1 = __webpack_require__(61);
Object.defineProperty(exports, "Diagnostics", { enumerable: true, get: function () { return Diagnostics_1.Diagnostics; } });
var NativeItem_1 = __webpack_require__(84);
Object.defineProperty(exports, "NativeShape", { enumerable: true, get: function () { return NativeItem_1.NativeShape; } });
Object.defineProperty(exports, "NativeConnector", { enumerable: true, get: function () { return NativeItem_1.NativeConnector; } });
var LocalizationService_1 = __webpack_require__(36);
Object.defineProperty(exports, "DiagramLocalizationService", { enumerable: true, get: function () { return LocalizationService_1.DiagramLocalizationService; } });
var RenderHelper_1 = __webpack_require__(15);
Object.defineProperty(exports, "RenderHelper", { enumerable: true, get: function () { return RenderHelper_1.RenderHelper; } });
var Enums_1 = __webpack_require__(47);
Object.defineProperty(exports, "DiagramUnit", { enumerable: true, get: function () { return Enums_1.DiagramUnit; } });
Object.defineProperty(exports, "PageOrientation", { enumerable: true, get: function () { return Enums_1.PageOrientation; } });
var ModelOperationSettings_1 = __webpack_require__(16);
Object.defineProperty(exports, "DiagramModelOperation", { enumerable: true, get: function () { return ModelOperationSettings_1.DiagramModelOperation; } });
var Connector_1 = __webpack_require__(6);
Object.defineProperty(exports, "ConnectorPosition", { enumerable: true, get: function () { return Connector_1.ConnectorPosition; } });


/***/ }),
/* 59 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {

"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__extends", function() { return __extends; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__assign", function() { return __assign; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__rest", function() { return __rest; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__decorate", function() { return __decorate; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__param", function() { return __param; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__metadata", function() { return __metadata; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__awaiter", function() { return __awaiter; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__generator", function() { return __generator; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__createBinding", function() { return __createBinding; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__exportStar", function() { return __exportStar; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__values", function() { return __values; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__read", function() { return __read; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__spread", function() { return __spread; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__spreadArrays", function() { return __spreadArrays; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__await", function() { return __await; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__asyncGenerator", function() { return __asyncGenerator; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__asyncDelegator", function() { return __asyncDelegator; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__asyncValues", function() { return __asyncValues; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__makeTemplateObject", function() { return __makeTemplateObject; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__importStar", function() { return __importStar; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__importDefault", function() { return __importDefault; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__classPrivateFieldGet", function() { return __classPrivateFieldGet; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__classPrivateFieldSet", function() { return __classPrivateFieldSet; });
/*! *****************************************************************************
Copyright (c) Microsoft Corporation.

Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted.

THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */
/* global Reflect, Promise */

var extendStatics = function(d, b) {
    extendStatics = Object.setPrototypeOf ||
        ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
        function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
    return extendStatics(d, b);
};

function __extends(d, b) {
    extendStatics(d, b);
    function __() { this.constructor = d; }
    d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
}

var __assign = function() {
    __assign = Object.assign || function __assign(t) {
        for (var s, i = 1, n = arguments.length; i < n; i++) {
            s = arguments[i];
            for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
        }
        return t;
    }
    return __assign.apply(this, arguments);
}

function __rest(s, e) {
    var t = {};
    for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
        t[p] = s[p];
    if (s != null && typeof Object.getOwnPropertySymbols === "function")
        for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
            if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
                t[p[i]] = s[p[i]];
        }
    return t;
}

function __decorate(decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
}

function __param(paramIndex, decorator) {
    return function (target, key) { decorator(target, key, paramIndex); }
}

function __metadata(metadataKey, metadataValue) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
}

function __awaiter(thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
}

function __generator(thisArg, body) {
    var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
    return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
    function verb(n) { return function (v) { return step([n, v]); }; }
    function step(op) {
        if (f) throw new TypeError("Generator is already executing.");
        while (_) try {
            if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
            if (y = 0, t) op = [op[0] & 2, t.value];
            switch (op[0]) {
                case 0: case 1: t = op; break;
                case 4: _.label++; return { value: op[1], done: false };
                case 5: _.label++; y = op[1]; op = [0]; continue;
                case 7: op = _.ops.pop(); _.trys.pop(); continue;
                default:
                    if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
                    if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
                    if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
                    if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
                    if (t[2]) _.ops.pop();
                    _.trys.pop(); continue;
            }
            op = body.call(thisArg, _);
        } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
        if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
    }
}

var __createBinding = Object.create ? (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    o[k2] = m[k];
});

function __exportStar(m, o) {
    for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(o, p)) __createBinding(o, m, p);
}

function __values(o) {
    var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
    if (m) return m.call(o);
    if (o && typeof o.length === "number") return {
        next: function () {
            if (o && i >= o.length) o = void 0;
            return { value: o && o[i++], done: !o };
        }
    };
    throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
}

function __read(o, n) {
    var m = typeof Symbol === "function" && o[Symbol.iterator];
    if (!m) return o;
    var i = m.call(o), r, ar = [], e;
    try {
        while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
    }
    catch (error) { e = { error: error }; }
    finally {
        try {
            if (r && !r.done && (m = i["return"])) m.call(i);
        }
        finally { if (e) throw e.error; }
    }
    return ar;
}

function __spread() {
    for (var ar = [], i = 0; i < arguments.length; i++)
        ar = ar.concat(__read(arguments[i]));
    return ar;
}

function __spreadArrays() {
    for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
    for (var r = Array(s), k = 0, i = 0; i < il; i++)
        for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
            r[k] = a[j];
    return r;
};

function __await(v) {
    return this instanceof __await ? (this.v = v, this) : new __await(v);
}

function __asyncGenerator(thisArg, _arguments, generator) {
    if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
    var g = generator.apply(thisArg, _arguments || []), i, q = [];
    return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
    function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
    function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
    function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
    function fulfill(value) { resume("next", value); }
    function reject(value) { resume("throw", value); }
    function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
}

function __asyncDelegator(o) {
    var i, p;
    return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
    function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; } : f; }
}

function __asyncValues(o) {
    if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
    var m = o[Symbol.asyncIterator], i;
    return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
    function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
    function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
}

function __makeTemplateObject(cooked, raw) {
    if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
    return cooked;
};

var __setModuleDefault = Object.create ? (function(o, v) {
    Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
    o["default"] = v;
};

function __importStar(mod) {
    if (mod && mod.__esModule) return mod;
    var result = {};
    if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
    __setModuleDefault(result, mod);
    return result;
}

function __importDefault(mod) {
    return (mod && mod.__esModule) ? mod : { default: mod };
}

function __classPrivateFieldGet(receiver, privateMap) {
    if (!privateMap.has(receiver)) {
        throw new TypeError("attempted to get private field on non-instance");
    }
    return privateMap.get(receiver);
}

function __classPrivateFieldSet(receiver, privateMap, value) {
    if (!privateMap.has(receiver)) {
        throw new TypeError("attempted to set private field on non-instance");
    }
    privateMap.set(receiver, value);
    return value;
}


/***/ }),
/* 60 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

Object.defineProperty(exports, "__esModule", { value: true });
var Vector = (function () {
    function Vector(x, y) {
        if (x === void 0) { x = 0; }
        if (y === void 0) { y = 0; }
        this.x = x;
        this.y = y;
    }
    Object.defineProperty(Vector.prototype, "length", {
        get: function () {
            return Math.sqrt(this.x * this.x + this.y * this.y);
        },
        enumerable: true,
        configurable: true
    });
    Vector.fromPoints = function (begin, end) {
        return new Vector(end.x - begin.x, end.y - begin.y);
    };
    Vector.fromSegment = function (segment) {
        return new Vector(segment.endPoint.x - segment.startPoint.x, segment.endPoint.y - segment.startPoint.y);
    };
    Vector.prototype.normalize = function () {
        var length = this.length;
        if (length !== 0) {
            this.x /= length;
            this.y /= length;
        }
        return this;
    };
    Vector.prototype.negative = function () {
        this.x *= -1;
        this.y *= -1;
        return this;
    };
    Object.defineProperty(Vector, "axisX", {
        get: function () {
            return new Vector(1, 0);
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(Vector, "axisY", {
        get: function () {
            return new Vector(0, 1);
        },
        enumerable: true,
        configurable: true
    });
    Vector.angleBetween = function (a, b) {
        var cosFi = Vector.scalarProduct(a, b) / (a.length * b.length);
        return Math.acos(cosFi);
    };
    Vector.scalarProduct = function (a, b) {
        return a.x * b.x + a.y * b.y;
    };
    return Vector;
}());
exports.Vector = Vector;


/***/ }),
/* 61 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.Diagnostics = void 0;
var LoggerDisplayMode;
(function (LoggerDisplayMode) {
    LoggerDisplayMode[LoggerDisplayMode["Disabled"] = 0] = "Disabled";
    LoggerDisplayMode[LoggerDisplayMode["Console"] = 1] = "Console";
    LoggerDisplayMode[LoggerDisplayMode["Document"] = 2] = "Document";
})(LoggerDisplayMode || (LoggerDisplayMode = {}));
var Diagnostics = (function () {
    function Diagnostics() {
    }
    Diagnostics.beginAverage = function (groupName) {
        if (!this.enableLogsAndTimers)
            return;
        this.lastAverageGroupName = groupName;
    };
    Diagnostics.endAverage = function () {
        if (!this.enableLogsAndTimers)
            return;
        this.lastAverageGroupName = null;
    };
    Diagnostics.tryLogAverage = function (groupName) {
        var _this = this;
        if (this.lastAverageGroupName === groupName)
            return;
        var sameGroupTimers = Object.keys(this.timers)
            .map(function (t) { return _this.timers[t]; })
            .filter(function (t) { return t.groupName === groupName; });
        if (!sameGroupTimers.filter(function (t) { return !t.endTime; }).length) {
            var average = sameGroupTimers.reduce(function (acc, t) { return acc + (t.endTime - t.startTime); }, 0) / sameGroupTimers.length;
            this.log("average: " + average);
        }
    };
    Diagnostics.timer = function (message) {
        if (!this.enableLogsAndTimers)
            return;
        this.lastCreatedTimer = {
            message: message,
            startTime: performance.now(),
            groupName: this.lastAverageGroupName
        };
    };
    Diagnostics.endTimer = function () {
        var _this = this;
        if (!this.enableLogsAndTimers)
            return;
        var timer = this.lastCreatedTimer;
        var timeoutID = setTimeout(function () {
            timer.endTime = performance.now();
            _this.showMessage("timer \"" + timer.message + "\": " + (timer.endTime - timer.startTime));
            timer.groupName && _this.tryLogAverage(timer.groupName);
        }, 0);
        this.timers[timeoutID] = timer;
        this.lastCreatedTimer = null;
    };
    Diagnostics.logPerfInfo = function () {
        var nodesCount = document.querySelector(".dxdi-control > svg").querySelectorAll("*").length;
        var memory = performance["memory"];
        this.log("nodes: " + nodesCount.toLocaleString() + (memory ? " memory: " : "") + (memory ? memory["usedJSHeapSize"].toLocaleString() : ""));
    };
    Diagnostics.log = function (message) {
        this.showMessage(message);
    };
    Diagnostics.showMessage = function (message) {
        switch (Diagnostics.mode) {
            case LoggerDisplayMode.Console:
                console.log(message);
                break;
            case LoggerDisplayMode.Document: {
                var existText = this.getElement().value;
                if (this.lastMessage === message) {
                    var lastLineLength = existText.indexOf("\r\n");
                    if (lastLineLength < 0)
                        lastLineLength = existText.indexOf("\n");
                    var lastLine = existText.substr(0, lastLineLength);
                    var regex = /( \()([0-9]+)(\))$/;
                    if (regex.test(lastLine))
                        lastLine = lastLine.replace(/( \()([0-9]+)(\))$/, function (str, before, val, after) { return before + (++val) + after; });
                    else
                        lastLine += " (1)";
                    this.getElement().value = lastLine + existText.substr(lastLineLength);
                }
                else {
                    this.getElement().value = message + "\r\n" + existText;
                    this.lastMessage = message;
                }
            }
        }
    };
    Diagnostics.getElement = function () {
        var _this = this;
        if (!this.el) {
            this.el = document.createElement("textarea");
            this.el.style.top = "0px";
            this.el.style.right = "0px";
            this.el.style.position = "fixed";
            this.el.style.background = "transparent";
            this.el.style.fontSize = "11px";
            this.el.style.fontFamily = "monospace";
            this.el.style.overflow = "auto";
            this.el.style.width = "400px";
            document.body.appendChild(this.el);
            var clr = document.createElement("button");
            clr.innerHTML = "x";
            clr.addEventListener("click", function () { _this.el.value = ""; _this.lastMessage = ""; });
            clr.style.top = "0px";
            clr.style.right = "400px";
            clr.style.position = "fixed";
            clr.style.opacity = "0.1";
            document.body.appendChild(clr);
        }
        return this.el;
    };
    Diagnostics.mode = LoggerDisplayMode.Document;
    Diagnostics.optimizeUsingRAF = true;
    Diagnostics.optimizeLayers = true;
    Diagnostics.timers = {};
    Diagnostics.enableLogsAndTimers = false;
    return Diagnostics;
}());
exports.Diagnostics = Diagnostics;


/***/ }),
/* 62 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.DiagramModel = void 0;
var Shape_1 = __webpack_require__(14);
var Connector_1 = __webpack_require__(6);
var Utils_1 = __webpack_require__(3);
var rectangle_1 = __webpack_require__(13);
var size_1 = __webpack_require__(2);
var point_1 = __webpack_require__(0);
var ImageCache_1 = __webpack_require__(46);
var color_1 = __webpack_require__(22);
var Enums_1 = __webpack_require__(47);
var ModelUtils_1 = __webpack_require__(4);
var DiagramModel = (function () {
    function DiagramModel(pageSize) {
        if (pageSize === void 0) { pageSize = new size_1.Size(8391, 11906); }
        this.items = [];
        this.itemIndexByKey = {};
        this.keyCounter = 0;
        this.pageSize = new size_1.Size(8391, 11906);
        this.pageLandscape = false;
        this.pageColor = DiagramModel.defaultPageColor;
        this.units = Enums_1.DiagramUnit.In;
        this.snapStartPoint = new point_1.Point(0, 0);
        this.pageSize = pageSize;
        this.size = this.pageSize.clone();
        this.rectangle = rectangle_1.Rectangle.fromGeometry(new point_1.Point(0, 0), new size_1.Size(0, 0));
        this.initializeKeyCounter();
    }
    Object.defineProperty(DiagramModel.prototype, "pageWidth", {
        get: function () {
            return this.pageLandscape ? this.pageSize.height : this.pageSize.width;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(DiagramModel.prototype, "pageHeight", {
        get: function () {
            return this.pageLandscape ? this.pageSize.width : this.pageSize.height;
        },
        enumerable: false,
        configurable: true
    });
    DiagramModel.prototype.getRectangle = function (forceUpdate) {
        if (forceUpdate)
            this.rectangle = ModelUtils_1.ModelUtils.createRectangle(this.items);
        return this.rectangle;
    };
    DiagramModel.prototype.pushItem = function (item) {
        var index = this.items.push(item);
        this.itemIndexByKey[item.key] = index - 1;
        if (item instanceof Shape_1.Shape && !item.image.isEmpty)
            this.cacheShapeImage(item);
    };
    DiagramModel.prototype.removeItem = function (item) {
        var index = this.getItemIndex(item);
        delete this.itemIndexByKey[item.key];
        this.items.splice(index, 1);
        this.updateIndicesHash(index);
    };
    DiagramModel.prototype.updateIndicesHash = function (startIndex) {
        for (var i = startIndex; i < this.items.length; i++)
            this.itemIndexByKey[this.items[i].key] = i;
    };
    DiagramModel.prototype.getItemIndex = function (item) {
        return this.itemIndexByKey[item.key];
    };
    DiagramModel.prototype.findShape = function (key) {
        var shape = this.findItem(key);
        return shape instanceof Shape_1.Shape ? shape : undefined;
    };
    DiagramModel.prototype.findShapesCore = function (callback) {
        var shapes = [];
        this.items.forEach(function (item) {
            if (item instanceof Shape_1.Shape)
                if (callback(item)) {
                    shapes.push(item);
                    return;
                }
        });
        return shapes;
    };
    DiagramModel.prototype.findShapeCore = function (callback) {
        for (var i = 0; i < this.items.length; i++) {
            var item = this.items[i];
            if (item instanceof Shape_1.Shape)
                if (callback(item))
                    return item;
        }
    };
    DiagramModel.prototype.findShapeAtPosition = function (position) {
        return this.findShapeCore(function (shape) { return shape.position.equals(position); });
    };
    DiagramModel.prototype.findShapeByDataKey = function (key) {
        return this.findShapeCore(function (shape) { return shape.dataKey === key; });
    };
    DiagramModel.prototype.findShapesByImageUrl = function (imageUrl) {
        return this.findShapesCore(function (shape) { return shape.image.url === imageUrl; });
    };
    DiagramModel.prototype.findShapesByDescription = function (description) {
        return this.findShapesCore(function (shape) { return shape.description.key === description.key; });
    };
    DiagramModel.prototype.cacheShapeImage = function (shape) {
        var cacheImageInfo = ImageCache_1.ImageCache.instance.createUnloadedInfoByShapeImageInfo(shape.image);
        if (cacheImageInfo.isLoaded)
            shape.image.loadBase64Content(cacheImageInfo.base64);
    };
    DiagramModel.prototype.loadAllImages = function (imageLoader) {
        ImageCache_1.ImageCache.instance.loadAllImages(imageLoader);
    };
    DiagramModel.prototype.findContainer = function (key) {
        var shape = this.findShape(key);
        return shape && shape.enableChildren ? shape : undefined;
    };
    DiagramModel.prototype.findNearestContainer = function (key) {
        var shape = this.findShape(key);
        if (shape)
            return shape.enableChildren ? shape : shape.container;
        else
            return undefined;
    };
    DiagramModel.prototype.getChildren = function (container) {
        var _this = this;
        return container.children.map(function (child) { return _this.findItem(child.key); }).filter(function (item) { return item; });
    };
    DiagramModel.prototype.findChild = function (container, key, recursive) {
        var _this = this;
        if (recursive === void 0) { recursive = true; }
        var result;
        container.children.forEach(function (child) {
            if (result)
                return;
            if (child.key === key) {
                result = child;
                return;
            }
            if (recursive && child instanceof Shape_1.Shape) {
                result = _this.findChild(child, key, recursive);
                if (result)
                    return;
            }
        });
        return result;
    };
    DiagramModel.prototype.findItemContainerCore = function (item, callback) {
        var container = item.container;
        while (container) {
            if (!callback || callback(container))
                break;
            container = container.container;
        }
        return container;
    };
    DiagramModel.prototype.findItemContainer = function (item) {
        return this.findItemContainerCore(item);
    };
    DiagramModel.prototype.findItemCollapsedContainer = function (item) {
        return this.findItemContainerCore(item, function (c) { return !c.expanded; });
    };
    DiagramModel.prototype.findItemTopCollapsedContainer = function (item) {
        var container = item.container;
        var collapsedContainer;
        while (container) {
            if (!container.expanded)
                collapsedContainer = container;
            container = container.container;
        }
        return collapsedContainer;
    };
    DiagramModel.prototype.isContainerItem = function (container, item) {
        return this.findItemContainerCore(item, function (c) { return c.key === container.key; }) !== undefined;
    };
    DiagramModel.prototype.findConnector = function (key) {
        var connector = this.findItem(key);
        return connector instanceof Connector_1.Connector ? connector : undefined;
    };
    DiagramModel.prototype.findConnectorCore = function (callback) {
        for (var i = 0; i < this.items.length; i++) {
            var item = this.items[i];
            if (item instanceof Connector_1.Connector)
                if (callback(item))
                    return item;
        }
    };
    DiagramModel.prototype.findConnectorAtPoints = function (points) {
        return this.findConnectorCore(function (connector) { return Utils_1.GeometryUtils.arePointsEqual(connector.points, points); });
    };
    DiagramModel.prototype.findConnectorByDataKey = function (key) {
        return this.findConnectorCore(function (connector) { return connector.dataKey === key; });
    };
    DiagramModel.prototype.findConnectorByBeginEndDataKeys = function (beginDataKey, endDataKey) {
        return this.findConnectorCore(function (connector) { return (connector.beginItem && connector.beginItem.dataKey === beginDataKey) &&
            (connector.endItem && connector.endItem.dataKey === endDataKey); });
    };
    DiagramModel.prototype.findConnectorsCore = function (callback) {
        var result = [];
        this.items.forEach(function (item) {
            if (item instanceof Connector_1.Connector)
                if (callback(item)) {
                    result.push(item);
                    return;
                }
        });
        return result;
    };
    DiagramModel.prototype.findConnectorsWithoutBeginItem = function () {
        return this.findConnectorsCore(function (connector) { return !connector.beginItem; });
    };
    DiagramModel.prototype.findConnectorsWithoutEndItem = function () {
        return this.findConnectorsCore(function (connector) { return !connector.endItem; });
    };
    DiagramModel.prototype.findItem = function (key) {
        return this.items[this.itemIndexByKey[key]];
    };
    DiagramModel.prototype.findItemByDataKey = function (key) {
        return this.findItemCore(function (item) { return item.dataKey === key; });
    };
    DiagramModel.prototype.findItemCore = function (callback) {
        for (var i = 0; i < this.items.length; i++)
            if (callback(this.items[i]))
                return this.items[i];
    };
    DiagramModel.isIntersectedItems = function (item1, item2) {
        var result = false;
        if (item1 instanceof Shape_1.Shape)
            result = item2.intersectedByRect(item1.rectangle);
        else if (item1 instanceof Connector_1.Connector)
            item1.getSegments().forEach(function (s1) {
                if (item2 instanceof Shape_1.Shape)
                    result = result || s1.isIntersectedByRect(item2.rectangle);
                else if (item2 instanceof Connector_1.Connector)
                    item2.getSegments().forEach(function (s2) {
                        result = result || s1.isIntersected(s2);
                    });
            });
        return result;
    };
    DiagramModel.prototype.getIntersectItems = function (item) {
        var result = [];
        this.items.forEach(function (i) {
            if (i.container !== item.container)
                return;
            if (item !== i && (!(i instanceof Connector_1.Connector) || item.attachedConnectors.indexOf(i) === -1) &&
                DiagramModel.isIntersectedItems(i, item))
                result.push(i);
        });
        return result;
    };
    DiagramModel.prototype.getIntersectItemsMinZIndex = function (item) {
        var items = this.getIntersectItems(item);
        return items.map(function (i) { return i.zIndex; }).reduce(function (prev, cur) { return Math.min(prev, cur); }, Number.MAX_VALUE);
    };
    DiagramModel.prototype.getIntersectItemsMaxZIndex = function (item) {
        var items = this.getIntersectItems(item);
        return items.map(function (i) { return i.zIndex; }).reduce(function (prev, cur) { return Math.max(prev, cur); }, -Number.MAX_VALUE);
    };
    DiagramModel.prototype.iterateItems = function (callback) {
        this.items.forEach(callback);
    };
    DiagramModel.prototype.getNextKey = function () {
        return (this.keyCounter++).toString();
    };
    DiagramModel.prototype.initializeKeyCounter = function () {
        this.keyCounter = this.items.reduce(function (prev, cur) {
            var num = parseInt(cur.key);
            return Math.max(prev, isNaN(num) ? 0 : num + 1);
        }, this.items.length);
    };
    DiagramModel.defaultPageColor = color_1.ColorUtils.LIGHT_COLOR;
    return DiagramModel;
}());
exports.DiagramModel = DiagramModel;


/***/ }),
/* 63 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.TextPrimitive270degRenderHelper = exports.TextPrimitive180degRenderHelper = exports.TextPrimitive90degRenderHelper = exports.TextPrimitiveRenderHelper = exports.TextPrimitive = exports.TextAngle = void 0;
var unit_converter_1 = __webpack_require__(12);
var RenderHelper_1 = __webpack_require__(15);
var Primitive_1 = __webpack_require__(24);
var Utils_1 = __webpack_require__(17);
var TextUtils_1 = __webpack_require__(64);
var TextAngle;
(function (TextAngle) {
    TextAngle[TextAngle["Angle0deg"] = 0] = "Angle0deg";
    TextAngle[TextAngle["Angle90deg"] = 90] = "Angle90deg";
    TextAngle[TextAngle["Angle180deg"] = 180] = "Angle180deg";
    TextAngle[TextAngle["Angle270deg"] = 270] = "Angle270deg";
})(TextAngle = exports.TextAngle || (exports.TextAngle = {}));
var TextPrimitive = (function (_super) {
    __extends(TextPrimitive, _super);
    function TextPrimitive(x, y, text, owner, textWidth, textHeight, textSpacing, style, reverseTextAhchor, clipPathId, filterId, angle, onApplyProperties) {
        var _this = _super.call(this, style, "", clipPathId, onApplyProperties) || this;
        _this.x = x;
        _this.y = y;
        _this.text = text;
        _this.owner = owner;
        _this.textWidth = textWidth;
        _this.textHeight = textHeight;
        _this.textSpacing = textSpacing;
        _this.reverseTextAhchor = reverseTextAhchor;
        _this.angle = angle;
        _this.filterId = filterId;
        _this.textSegmens = TextUtils_1.textToParagraphs(_this.text);
        _this.renderHelper = _this.createRenderHelper();
        if (_this.textWidth !== undefined && _this.textWidth !== undefined) {
            _this.x = _this.renderHelper.getTextX(_this.x);
            _this.y = _this.renderHelper.getTextY(_this.y);
        }
        return _this;
    }
    TextPrimitive.prototype.createMainElement = function () {
        return document.createElementNS(RenderHelper_1.svgNS, "text");
    };
    TextPrimitive.prototype.applyElementProperties = function (element, measurer) {
        this.setUnitAttribute(element, "x", this.x);
        this.setUnitAttribute(element, "y", this.y);
        if (this.filterId)
            element.setAttribute("filter", Utils_1.RenderUtils.getUrlPathById(this.filterId));
        _super.prototype.applyElementProperties.call(this, element, measurer);
        if (element.getAttribute("appliedText") !== this.text || element.getAttribute("appliedSize") !== (this.fitToSize && this.fitToSize.toString())) {
            this.createTSpanElements(element, measurer);
            element.setAttribute("appliedText", this.text);
            element.setAttribute("appliedSize", (this.fitToSize && this.fitToSize.toString()));
        }
        else
            this.prepareTSpanElements(element);
        this.renderHelper.prepareMainElement(element, this.x, this.y);
    };
    TextPrimitive.prototype.createTSpanElements = function (element, measurer) {
        var _this = this;
        Utils_1.RenderUtils.removeContent(element);
        this.textSegmens.forEach(function (txt, index) {
            if (!txt && _this.textSegmens.length > 1) {
                var span = _this.createTSpanElement(element);
                span.textContent = " ";
            }
            else if (_this.fitToSize) {
                var words_1 = TextUtils_1.textToWords(txt);
                var lines = TextUtils_1.wordsByLines(unit_converter_1.UnitConverter.twipsToPixels(_this.fitToSize), words_1, function () { return measurer.measureWords(words_1, _this.style, _this.owner); });
                lines.forEach(function (line) {
                    var span = _this.createTSpanElement(element);
                    span.textContent = line;
                });
                if (!lines.length) {
                    var span = _this.createTSpanElement(element);
                    span.textContent = " ";
                }
            }
            else {
                var tSpan = _this.createTSpanElement(element);
                tSpan.textContent = txt;
            }
        });
        var firstTSpan = element.firstChild;
        if (firstTSpan)
            this.prepareFirstTSpanElement(firstTSpan, element.childNodes.length);
    };
    TextPrimitive.prototype.createTSpanElement = function (parent) {
        var tSpan = document.createElementNS(RenderHelper_1.svgNS, "tspan");
        parent.appendChild(tSpan);
        this.prepareTSpanElement(tSpan);
        return tSpan;
    };
    TextPrimitive.prototype.prepareTSpanElements = function (element) {
        for (var i = 0; i < element.childNodes.length; i++) {
            var tSpan = element.childNodes[i];
            this.prepareTSpanElement(tSpan);
        }
        var firstTSpan = element.firstChild;
        if (firstTSpan)
            this.prepareFirstTSpanElement(firstTSpan, element.childNodes.length);
    };
    TextPrimitive.prototype.prepareTSpanElement = function (tSpan) {
        this.renderHelper.prepareTSpanElement(tSpan, this.x, this.y);
    };
    TextPrimitive.prototype.prepareFirstTSpanElement = function (tSpan, lineCount) {
        this.renderHelper.prepareFirstTSpanElement(tSpan, lineCount);
    };
    TextPrimitive.prototype.applyElementStyleProperties = function (element) {
        this.applyElementStylePropertiesCore(element, this.reverseTextAhchor);
    };
    Object.defineProperty(TextPrimitive.prototype, "fitToSize", {
        get: function () { return this.renderHelper.fitToSize; },
        enumerable: false,
        configurable: true
    });
    TextPrimitive.prototype.createRenderHelper = function () {
        switch (this.angle) {
            case TextAngle.Angle90deg:
                return new TextPrimitive90degRenderHelper(this);
            case TextAngle.Angle180deg:
                return new TextPrimitive180degRenderHelper(this);
            case TextAngle.Angle270deg:
                return new TextPrimitive270degRenderHelper(this);
            default:
                return new TextPrimitiveRenderHelper(this);
        }
    };
    TextPrimitive.baselineCorrection = 0.35;
    return TextPrimitive;
}(Primitive_1.SvgPrimitive));
exports.TextPrimitive = TextPrimitive;
var TextPrimitiveRenderHelper = (function () {
    function TextPrimitiveRenderHelper(primitive) {
        this.primitive = primitive;
    }
    Object.defineProperty(TextPrimitiveRenderHelper.prototype, "textWidth", {
        get: function () { return this.primitive.textWidth; },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(TextPrimitiveRenderHelper.prototype, "textHeight", {
        get: function () { return this.primitive.textHeight; },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(TextPrimitiveRenderHelper.prototype, "fitToSize", {
        get: function () { return this.textWidth; },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(TextPrimitiveRenderHelper.prototype, "textAnchor", {
        get: function () { return this.primitive.style["text-anchor"]; },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(TextPrimitiveRenderHelper.prototype, "textSpacing", {
        get: function () { return this.primitive.textSpacing; },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(TextPrimitiveRenderHelper.prototype, "angle", {
        get: function () { return undefined; },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(TextPrimitiveRenderHelper.prototype, "needRotation", {
        get: function () { return false; },
        enumerable: false,
        configurable: true
    });
    TextPrimitiveRenderHelper.prototype.prepareMainElement = function (element, x, y) {
        if (this.needRotation)
            element.setAttribute("transform", "rotate(" + this.angle + ", " +
                unit_converter_1.UnitConverter.twipsToPixels(x) + ", " + unit_converter_1.UnitConverter.twipsToPixels(y) + ")");
    };
    TextPrimitiveRenderHelper.prototype.prepareTSpanElement = function (tSpan, x, y) {
        this.primitive.setUnitAttribute(tSpan, "x", x);
        tSpan.setAttribute("dy", TextUtils_1.LINE_HEIGHT + "em");
    };
    TextPrimitiveRenderHelper.prototype.prepareFirstTSpanElement = function (tSpan, lineCount) {
        var dy = -((lineCount - 1) / 2) + TextPrimitive.baselineCorrection;
        tSpan.setAttribute("dy", dy.toFixed(2) + "em");
    };
    TextPrimitiveRenderHelper.prototype.getTextX = function (x) {
        if (!this.textAnchor || this.textAnchor === "middle")
            return x + this.textWidth / 2;
        else if (this.textAnchor === "end")
            return x + this.textWidth - this.textSpacing;
        else if (this.textAnchor === "start")
            return x + this.textSpacing;
        return x;
    };
    TextPrimitiveRenderHelper.prototype.getTextY = function (y) {
        return y + this.textHeight / 2;
    };
    TextPrimitiveRenderHelper.prototype.setUnitAttribute = function (element, key, value) {
        this.primitive.setUnitAttribute(element, key, value);
    };
    return TextPrimitiveRenderHelper;
}());
exports.TextPrimitiveRenderHelper = TextPrimitiveRenderHelper;
var TextPrimitive90degRenderHelper = (function (_super) {
    __extends(TextPrimitive90degRenderHelper, _super);
    function TextPrimitive90degRenderHelper(primitive) {
        return _super.call(this, primitive) || this;
    }
    Object.defineProperty(TextPrimitive90degRenderHelper.prototype, "fitToSize", {
        get: function () { return this.textHeight; },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(TextPrimitive90degRenderHelper.prototype, "angle", {
        get: function () { return 90; },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(TextPrimitive90degRenderHelper.prototype, "needRotation", {
        get: function () { return true; },
        enumerable: false,
        configurable: true
    });
    TextPrimitive90degRenderHelper.prototype.getTextX = function (x) {
        return x + this.textWidth / 2;
    };
    TextPrimitive90degRenderHelper.prototype.getTextY = function (y) {
        if (!this.textAnchor || this.textAnchor === "middle")
            return y + this.textHeight / 2;
        else if (this.textAnchor === "end")
            return y + this.textHeight - this.textSpacing;
        else if (this.textAnchor === "start")
            return y + this.textSpacing;
        return y;
    };
    return TextPrimitive90degRenderHelper;
}(TextPrimitiveRenderHelper));
exports.TextPrimitive90degRenderHelper = TextPrimitive90degRenderHelper;
var TextPrimitive180degRenderHelper = (function (_super) {
    __extends(TextPrimitive180degRenderHelper, _super);
    function TextPrimitive180degRenderHelper(primitive) {
        return _super.call(this, primitive) || this;
    }
    Object.defineProperty(TextPrimitive180degRenderHelper.prototype, "angle", {
        get: function () { return 180; },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(TextPrimitive180degRenderHelper.prototype, "needRotation", {
        get: function () { return true; },
        enumerable: false,
        configurable: true
    });
    TextPrimitive180degRenderHelper.prototype.getTextX = function (x) {
        if (!this.textAnchor || this.textAnchor === "middle")
            return x + this.textWidth / 2;
        else if (this.textAnchor === "start")
            return x + this.textWidth - this.textSpacing;
        else if (this.textAnchor === "end")
            return x + this.textSpacing;
        return x;
    };
    return TextPrimitive180degRenderHelper;
}(TextPrimitiveRenderHelper));
exports.TextPrimitive180degRenderHelper = TextPrimitive180degRenderHelper;
var TextPrimitive270degRenderHelper = (function (_super) {
    __extends(TextPrimitive270degRenderHelper, _super);
    function TextPrimitive270degRenderHelper(primitive) {
        return _super.call(this, primitive) || this;
    }
    Object.defineProperty(TextPrimitive270degRenderHelper.prototype, "angle", {
        get: function () { return 270; },
        enumerable: false,
        configurable: true
    });
    TextPrimitive270degRenderHelper.prototype.getTextY = function (y) {
        if (!this.textAnchor || this.textAnchor === "middle")
            return y + this.textHeight / 2;
        else if (this.textAnchor === "start")
            return y + this.textHeight - this.textSpacing;
        else if (this.textAnchor === "end")
            return y + this.textSpacing;
        return y;
    };
    return TextPrimitive270degRenderHelper;
}(TextPrimitive90degRenderHelper));
exports.TextPrimitive270degRenderHelper = TextPrimitive270degRenderHelper;


/***/ }),
/* 64 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.getLineHeight = exports.getTextHeight = exports.getTextLineSize = exports.getOptimalTextRectangle = exports.TEXTRECT_RATIO_EPS = exports.textToParagraphs = exports.textToWords = exports.wordsByLines = exports.LINE_HEIGHT = void 0;
var Utils_1 = __webpack_require__(3);
var size_1 = __webpack_require__(2);
var Data_1 = __webpack_require__(44);
var WHITESPACES = /\s/gm;
exports.LINE_HEIGHT = 1.05;
function wordsByLines(absLineWidth, words, measureWords) {
    if (words.length === 1)
        return words;
    var measuredWords = measureWords();
    var spaceWidth = measuredWords.words[" "].width;
    var result = [];
    var lastLineWidth = 0;
    var lastLineIndex = -1;
    for (var i = 0; i < words.length; i++) {
        var word = words[i];
        var wordWidth = measuredWords.words[word].width;
        if (lastLineIndex === -1 || lastLineWidth + spaceWidth + wordWidth > absLineWidth) {
            lastLineIndex = result.push(word) - 1;
            lastLineWidth = wordWidth;
        }
        else {
            lastLineWidth += spaceWidth + wordWidth;
            result[lastLineIndex] += " " + word;
        }
    }
    return result;
}
exports.wordsByLines = wordsByLines;
function textToWords(text) {
    return text.split(WHITESPACES).filter(function (t) { return t.length; });
}
exports.textToWords = textToWords;
function textToParagraphs(text) {
    return text.split("\n");
}
exports.textToParagraphs = textToParagraphs;
exports.TEXTRECT_RATIO_EPS = 1.2;
var TEXTRECT_WIDTH_DIFF_EPS = 1;
function getOptimalTextRectangle(text, style, owner, measurer, initialSize, keepRatio, minWidth, maxWidth, minHeight, maxHeight) {
    if (minWidth === void 0) { minWidth = 0; }
    if (maxWidth === void 0) { maxWidth = Number.MAX_SAFE_INTEGER || Number.MAX_VALUE; }
    if (minHeight === void 0) { minHeight = 0; }
    if (maxHeight === void 0) { maxHeight = Number.MAX_SAFE_INTEGER || Number.MAX_VALUE; }
    if (!text)
        return new size_1.Size(Data_1.Data.byRange(initialSize.width, minWidth, maxWidth), Data_1.Data.byRange(initialSize.height, minHeight, maxHeight));
    if (minWidth > maxWidth || minHeight > maxHeight)
        throw new Error("Min size cannot exceed max size");
    if (minWidth === maxWidth && minHeight === maxHeight)
        return new size_1.Size(minWidth, minHeight);
    var measureResult = measurer.measureWords(text, style, owner);
    var paragraphs = textToParagraphs(text);
    var maxWordWidth = Object.keys(measureResult.words).reduce(function (acc, word) { return Math.max(acc, measureResult.words[word].width); }, 0);
    var xRange = new Utils_1.Range(Data_1.Data.byRange(Math.max(initialSize.width, maxWordWidth), minWidth, maxWidth), maxWidth);
    var yRange = new Utils_1.Range(Data_1.Data.byRange(initialSize.height, minHeight, maxHeight), maxHeight);
    if (maxWordWidth <= initialSize.width && getTextHeight(paragraphs, initialSize.width, measureResult, false) <= initialSize.height && xRange.includes(initialSize.width) && yRange.includes(initialSize.height))
        return initialSize;
    var ratio = initialSize.width / initialSize.height;
    return getOptimalTextRectangleCore(paragraphs, measureResult, ratio, xRange, yRange, keepRatio);
}
exports.getOptimalTextRectangle = getOptimalTextRectangle;
function getOptimalTextRectangleCore(paragraphs, measureResult, initRatio, xRange, yRange, incHeightToRatio) {
    var _a;
    var maxParagraphWidth = paragraphs.reduce(function (acc, val) { return Math.max(acc, getTextLineSize(val, measureResult).width); }, 0);
    var size = new size_1.Size(0, 0);
    var newSize = new size_1.Size(0, 0);
    var newFitToHeight;
    var deltaWidth = 0;
    var error = 0;
    for (var attempt = 0; attempt < 5; attempt++) {
        if (attempt === 0)
            newSize.width = calcByFit(maxParagraphWidth, xRange)[0];
        else if (Math.abs(deltaWidth) > TEXTRECT_WIDTH_DIFF_EPS)
            newSize.width = calcByFit(size.width + deltaWidth, xRange)[0];
        else
            break;
        _a = calcHeight(paragraphs, newSize.width, measureResult, yRange), newSize.height = _a[0], newFitToHeight = _a[1];
        if (attempt === 0) {
            size = newSize.clone();
            error = (size.width / size.height) / initRatio;
        }
        if (attempt === 0 && !newFitToHeight)
            break;
        var newRatio = (newSize.width / newSize.height);
        var newError = newRatio / initRatio;
        if (attempt === 0)
            deltaWidth = (newSize.width / newError - newSize.width) / 2;
        else if (!newFitToHeight)
            deltaWidth /= 2;
        else if (!compareRatio(initRatio, newRatio, exports.TEXTRECT_RATIO_EPS)) {
            size = newSize.clone();
            error = newError;
            break;
        }
        else if (compareRatio(error, newError, 1) < 0) {
            size = newSize.clone();
            error = newError;
            deltaWidth = (newSize.width / newError - newSize.width) / 2;
            if (newError < 1)
                deltaWidth /= 2;
        }
        else
            break;
    }
    if (incHeightToRatio)
        size.height = Data_1.Data.byRange(size.width / initRatio, size.height, yRange.to);
    return size;
}
function compareRatio(a, b, eps) {
    var an = a < 1 ? 1 / a : a;
    var bn = b < 1 ? 1 / b : b;
    var e = an / bn;
    var en = e < 1 ? 1 / e : e;
    return en <= eps ? 0 : bn > an ? 1 : -1;
}
function calcHeight(paragraphs, width, measureResult, yRange) {
    var height = getTextHeight(paragraphs, width, measureResult, false);
    return calcByFit(height, yRange);
}
function calcByFit(value, range) {
    return [
        Data_1.Data.byRange(value, range.from, range.to),
        value <= range.to
    ];
}
function getTextLineSize(text, measureResult) {
    var words = textToWords(text);
    return words.reduce(function (acc, word, index) {
        var wordSize = measureResult.words[word];
        acc.width += wordSize.width;
        acc.height = Math.max(acc.height, wordSize.height);
        if (index > 0)
            acc.width += measureResult.words[" "].width;
        return acc;
    }, new size_1.Size(0, 0));
}
exports.getTextLineSize = getTextLineSize;
function getTextHeight(textOrParagraphs, width, measureResult, emptyTextAsSingleLine) {
    var paragraphs = Array.isArray(textOrParagraphs) ? textOrParagraphs : textToParagraphs(textOrParagraphs);
    if (emptyTextAsSingleLine && (!paragraphs.length || (paragraphs.length === 1 && !paragraphs[0].length)))
        return getLineHeight(measureResult);
    return paragraphs.reduce(function (acc, line) { return acc + wordsByLines(width, textToWords(line), function () { return measureResult; }).length; }, 0) * getLineHeight(measureResult);
}
exports.getTextHeight = getTextHeight;
function getLineHeight(measureResult) {
    return measureResult.fontSize * exports.LINE_HEIGHT;
}
exports.getLineHeight = getLineHeight;


/***/ }),
/* 65 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

Object.defineProperty(exports, "__esModule", { value: true });
var browser_1 = __webpack_require__(18);
var common_1 = __webpack_require__(50);
var dom_1 = __webpack_require__(27);
var touch_1 = __webpack_require__(176);
var EvtUtils = (function () {
    function EvtUtils() {
    }
    EvtUtils.preventEvent = function (evt) {
        if (!evt.cancelable)
            return;
        if (evt.preventDefault)
            evt.preventDefault();
        else
            evt.returnValue = false;
    };
    EvtUtils.getEventSource = function (evt) {
        return common_1.isDefined(evt) ? EvtUtils.getEventSourceCore(evt) : null;
    };
    EvtUtils.getEventSourceByPosition = function (evt) {
        if (!common_1.isDefined(evt))
            return null;
        if (!document.elementFromPoint)
            return EvtUtils.getEventSourceCore(evt);
        var clientX = EvtUtils.getEventX(evt) - (EvtUtils.clientEventRequiresDocScrollCorrection() ? dom_1.DomUtils.getDocumentScrollLeft() : 0);
        var clientY = EvtUtils.getEventY(evt) - (EvtUtils.clientEventRequiresDocScrollCorrection() ? dom_1.DomUtils.getDocumentScrollTop() : 0);
        if (clientX === undefined || clientY === undefined)
            return EvtUtils.getEventSourceCore(evt);
        return document.elementFromPoint(clientX, clientY);
    };
    EvtUtils.getEventSourceCore = function (evt) {
        return evt.srcElement ? evt.srcElement : evt.target;
    };
    EvtUtils.getMouseWheelEventName = function () {
        if (browser_1.Browser.Safari)
            return 'mousewheel';
        if (browser_1.Browser.NetscapeFamily && browser_1.Browser.MajorVersion < 17)
            return 'DOMMouseScroll';
        return 'wheel';
    };
    EvtUtils.isLeftButtonPressed = function (evt) {
        if (touch_1.TouchUtils.isTouchEvent(evt))
            return true;
        evt = (browser_1.Browser.IE && common_1.isDefined(event)) ? event : evt;
        if (!evt)
            return false;
        if (browser_1.Browser.IE && browser_1.Browser.Version < 11)
            return browser_1.Browser.MSTouchUI ? true : evt.button % 2 === 1;
        if (browser_1.Browser.WebKitFamily)
            return (evt.type === 'pointermove' || evt.type === 'pointerenter' || evt.type === 'pointerleave') ? evt.buttons === 1 : evt.which === 1;
        if (browser_1.Browser.NetscapeFamily || browser_1.Browser.Edge || (browser_1.Browser.IE && browser_1.Browser.Version >= 11))
            return EvtUtils.isMoveEventName(evt.type) ? evt.buttons === 1 : evt.which === 1;
        return browser_1.Browser.Opera ? evt.button === 0 : true;
    };
    EvtUtils.isMoveEventName = function (type) {
        return type === touch_1.TouchUtils.touchMouseMoveEventName || type === EvtUtils.getMoveEventName();
    };
    EvtUtils.getMoveEventName = function () {
        return window.PointerEvent ? 'pointermove' : (browser_1.Browser.TouchUI ? 'touchmove' : 'mousemove');
    };
    EvtUtils.preventEventAndBubble = function (evt) {
        EvtUtils.preventEvent(evt);
        if (evt.stopPropagation)
            evt.stopPropagation();
        evt.cancelBubble = true;
    };
    EvtUtils.clientEventRequiresDocScrollCorrection = function () {
        var isSafariVerLess3 = browser_1.Browser.Safari && browser_1.Browser.Version < 3;
        var isMacOSMobileVerLess51 = browser_1.Browser.MacOSMobilePlatform && browser_1.Browser.Version < 5.1;
        return browser_1.Browser.AndroidDefaultBrowser || browser_1.Browser.AndroidChromeBrowser || !(isSafariVerLess3 || isMacOSMobileVerLess51);
    };
    EvtUtils.getEventX = function (evt) {
        if (touch_1.TouchUtils.isTouchEvent(evt))
            return touch_1.TouchUtils.getEventX(evt);
        return evt.clientX + (EvtUtils.clientEventRequiresDocScrollCorrection() ? dom_1.DomUtils.getDocumentScrollLeft() : 0);
    };
    EvtUtils.getEventY = function (evt) {
        if (touch_1.TouchUtils.isTouchEvent(evt))
            return touch_1.TouchUtils.getEventY(evt);
        return evt.clientY + (EvtUtils.clientEventRequiresDocScrollCorrection() ? dom_1.DomUtils.getDocumentScrollTop() : 0);
    };
    EvtUtils.cancelBubble = function (evt) {
        evt.cancelBubble = true;
    };
    EvtUtils.getWheelDelta = function (evt) {
        var ret;
        if (browser_1.Browser.NetscapeFamily && browser_1.Browser.MajorVersion < 17)
            ret = -evt.detail;
        else if (browser_1.Browser.Safari)
            ret = evt.wheelDelta;
        else
            ret = -evt.deltaY;
        if (browser_1.Browser.Opera && browser_1.Browser.Version < 9)
            ret = -ret;
        return ret;
    };
    return EvtUtils;
}());
exports.EvtUtils = EvtUtils;


/***/ }),
/* 66 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.AddConnectorHistoryItem = void 0;
var HistoryItem_1 = __webpack_require__(8);
var Connector_1 = __webpack_require__(6);
var AddConnectorHistoryItem = (function (_super) {
    __extends(AddConnectorHistoryItem, _super);
    function AddConnectorHistoryItem(points, dataKey, renderPointsContext) {
        var _this = _super.call(this) || this;
        _this.points = points;
        _this.dataKey = dataKey;
        _this.renderPointsContext = renderPointsContext;
        return _this;
    }
    AddConnectorHistoryItem.prototype.redo = function (manipulator) {
        var connector = new Connector_1.Connector(this.points);
        if (this.dataKey !== undefined)
            connector.dataKey = this.dataKey;
        if (this.renderPointsContext !== undefined)
            connector.replaceRenderPoints(this.renderPointsContext);
        manipulator.addConnector(connector, this.connectorKey);
        this.connectorKey = connector.key;
    };
    AddConnectorHistoryItem.prototype.undo = function (manipulator) {
        var connector = manipulator.model.findConnector(this.connectorKey);
        manipulator.deleteConnector(connector);
    };
    return AddConnectorHistoryItem;
}(HistoryItem_1.HistoryItem));
exports.AddConnectorHistoryItem = AddConnectorHistoryItem;


/***/ }),
/* 67 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.DeleteConnectionHistoryItem = void 0;
var HistoryItem_1 = __webpack_require__(8);
var Connector_1 = __webpack_require__(6);
var DeleteConnectionHistoryItem = (function (_super) {
    __extends(DeleteConnectionHistoryItem, _super);
    function DeleteConnectionHistoryItem(connector, position) {
        var _this = _super.call(this) || this;
        _this.connectorKey = connector.key;
        _this.position = position;
        _this.itemKey = connector.getExtremeItem(_this.position).key;
        return _this;
    }
    DeleteConnectionHistoryItem.prototype.redo = function (manipulator) {
        var connector = manipulator.model.findConnector(this.connectorKey);
        this.oldConnectionPointIndex = this.position === Connector_1.ConnectorPosition.Begin ? connector.beginConnectionPointIndex : connector.endConnectionPointIndex;
        manipulator.deleteConnection(connector, this.position);
    };
    DeleteConnectionHistoryItem.prototype.undo = function (manipulator) {
        var connector = manipulator.model.findConnector(this.connectorKey);
        var item = manipulator.model.findItem(this.itemKey);
        manipulator.addConnection(connector, item, this.oldConnectionPointIndex, this.position);
    };
    return DeleteConnectionHistoryItem;
}(HistoryItem_1.HistoryItem));
exports.DeleteConnectionHistoryItem = DeleteConnectionHistoryItem;


/***/ }),
/* 68 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.SetSelectionHistoryItem = void 0;
var HistoryItem_1 = __webpack_require__(8);
var SetSelectionHistoryItem = (function (_super) {
    __extends(SetSelectionHistoryItem, _super);
    function SetSelectionHistoryItem(selection, selectedKeys, forceChange) {
        var _this = _super.call(this) || this;
        _this.selectedKeys = selectedKeys;
        _this.selection = selection;
        _this.forceChange = forceChange;
        return _this;
    }
    SetSelectionHistoryItem.prototype.redo = function () {
        this.oldSelection = this.selection.getKeys().slice(0);
        this.selection.set(this.selectedKeys, this.forceChange);
    };
    SetSelectionHistoryItem.prototype.undo = function () {
        this.selection.set(this.oldSelection, this.forceChange);
    };
    return SetSelectionHistoryItem;
}(HistoryItem_1.HistoryItem));
exports.SetSelectionHistoryItem = SetSelectionHistoryItem;


/***/ }),
/* 69 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.ChangeConnectorTextHistoryItem = void 0;
var HistoryItem_1 = __webpack_require__(8);
var ChangeConnectorTextHistoryItem = (function (_super) {
    __extends(ChangeConnectorTextHistoryItem, _super);
    function ChangeConnectorTextHistoryItem(connector, position, text) {
        var _this = _super.call(this) || this;
        _this.connectorKey = connector.key;
        _this.text = text;
        _this.position = position;
        return _this;
    }
    ChangeConnectorTextHistoryItem.prototype.redo = function (manipulator) {
        var connector = manipulator.model.findConnector(this.connectorKey);
        this.oldText = connector.getText(this.position);
        manipulator.changeConnectorText(connector, this.text, this.position);
    };
    ChangeConnectorTextHistoryItem.prototype.undo = function (manipulator) {
        var connector = manipulator.model.findConnector(this.connectorKey);
        manipulator.changeConnectorText(connector, this.oldText, this.position);
    };
    return ChangeConnectorTextHistoryItem;
}(HistoryItem_1.HistoryItem));
exports.ChangeConnectorTextHistoryItem = ChangeConnectorTextHistoryItem;


/***/ }),
/* 70 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.ChangeStyleTextHistoryItem = void 0;
var ChangeStyleHistoryItemBase_1 = __webpack_require__(118);
var ChangeStyleTextHistoryItem = (function (_super) {
    __extends(ChangeStyleTextHistoryItem, _super);
    function ChangeStyleTextHistoryItem(itemKey, styleProperty, styleValue) {
        return _super.call(this, itemKey, styleProperty, styleValue) || this;
    }
    ChangeStyleTextHistoryItem.prototype.redo = function (manipulator) {
        var item = manipulator.model.findItem(this.itemKey);
        this.oldStyleValue = item.styleText[this.styleProperty];
        manipulator.changeStyleText(item, this.styleProperty, this.styleValue);
    };
    ChangeStyleTextHistoryItem.prototype.undo = function (manipulator) {
        var item = manipulator.model.findItem(this.itemKey);
        manipulator.changeStyleText(item, this.styleProperty, this.oldStyleValue);
    };
    return ChangeStyleTextHistoryItem;
}(ChangeStyleHistoryItemBase_1.ChangeStyleHistoryItemBase));
exports.ChangeStyleTextHistoryItem = ChangeStyleTextHistoryItem;


/***/ }),
/* 71 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.Margin = exports.EdgeLayout = exports.NodeLayout = exports.NodeInfo = void 0;
var rectangle_1 = __webpack_require__(13);
var NodeInfo = (function () {
    function NodeInfo(key, margin, size, connectionPoints) {
        if (connectionPoints === void 0) { connectionPoints = []; }
        this.key = key;
        this.margin = margin;
        this.size = size;
        this.connectionPoints = connectionPoints;
    }
    return NodeInfo;
}());
exports.NodeInfo = NodeInfo;
var NodeLayout = (function () {
    function NodeLayout(info, position) {
        this.info = info;
        this.position = position;
    }
    Object.defineProperty(NodeLayout.prototype, "key", {
        get: function () { return this.info.key; },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(NodeLayout.prototype, "rectangle", {
        get: function () {
            return rectangle_1.Rectangle.fromGeometry(this.position, this.info.size);
        },
        enumerable: false,
        configurable: true
    });
    return NodeLayout;
}());
exports.NodeLayout = NodeLayout;
var EdgeLayout = (function () {
    function EdgeLayout(key, beginIndex, endIndex) {
        this.key = key;
        this.beginIndex = beginIndex;
        this.endIndex = endIndex;
    }
    return EdgeLayout;
}());
exports.EdgeLayout = EdgeLayout;
var Margin = (function () {
    function Margin(top, right, bottom, left) {
        if (right === void 0) { right = top; }
        if (bottom === void 0) { bottom = top; }
        if (left === void 0) { left = top; }
        this.top = top;
        this.right = right;
        this.bottom = bottom;
        this.left = left;
    }
    Margin.empty = function () {
        return new Margin(0);
    };
    return Margin;
}());
exports.Margin = Margin;


/***/ }),
/* 72 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.EllipseShapeDescription = void 0;
var ShapeDescription_1 = __webpack_require__(7);
var size_1 = __webpack_require__(2);
var EllipsePrimitive_1 = __webpack_require__(55);
var ShapeTypes_1 = __webpack_require__(1);
var Utils_1 = __webpack_require__(3);
var rectangle_1 = __webpack_require__(13);
var EllipseShapeDescription = (function (_super) {
    __extends(EllipseShapeDescription, _super);
    function EllipseShapeDescription(hasDefaultText) {
        return _super.call(this, new size_1.Size(ShapeDescription_1.ShapeDefaultDimension, ShapeDescription_1.ShapeDefaultDimension * 0.75), hasDefaultText) || this;
    }
    Object.defineProperty(EllipseShapeDescription.prototype, "key", {
        get: function () { return ShapeTypes_1.ShapeTypes.Ellipse; },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(EllipseShapeDescription.prototype, "keepRatioOnAutoSize", {
        get: function () { return false; },
        enumerable: false,
        configurable: true
    });
    EllipseShapeDescription.prototype.getTextRectangle = function (shape) {
        var textSize = Utils_1.GeometryUtils.getMaxRectangleEnscribedInEllipse(shape.size);
        return rectangle_1.Rectangle.fromGeometry(shape.position.clone().offset((shape.size.width - textSize.width) / 2, (shape.size.height - textSize.height) / 2), textSize);
    };
    EllipseShapeDescription.prototype.getSizeByText = function (textSize, _shape) {
        return Utils_1.GeometryUtils.getEllipseByEnscribedRectangle(textSize);
    };
    EllipseShapeDescription.prototype.createShapePrimitives = function (shape) {
        var rect = shape.rectangle;
        var width = rect.width, height = rect.height;
        var _a = rect.center, cx = _a.x, cy = _a.y;
        return [
            new EllipsePrimitive_1.EllipsePrimitive(cx, cy, width / 2, height / 2, shape.style),
        ];
    };
    return EllipseShapeDescription;
}(ShapeDescription_1.ShapeDescription));
exports.EllipseShapeDescription = EllipseShapeDescription;


/***/ }),
/* 73 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.Exporter = void 0;
var Shape_1 = __webpack_require__(14);
var Connector_1 = __webpack_require__(6);
var Utils_1 = __webpack_require__(3);
var Exporter = (function () {
    function Exporter() {
    }
    Exporter.prototype.export = function (model) {
        var obj = {
            page: {},
            connectors: [],
            shapes: []
        };
        obj.page = {
            "width": model.size.width,
            "height": model.size.height,
            "pageColor": model.pageColor,
            "pageWidth": model.pageSize.width,
            "pageHeight": model.pageSize.height,
            "pageLandscape": model.pageLandscape
        };
        this.exportItemsCore(model.items, obj);
        return JSON.stringify(obj);
    };
    Exporter.prototype.exportItems = function (items) {
        var obj = {
            connectors: [],
            shapes: []
        };
        this.exportItemsCore(items, obj);
        return JSON.stringify(obj);
    };
    Exporter.prototype.exportItemsCore = function (items, obj) {
        var _this = this;
        items.forEach(function (item) {
            if (item instanceof Shape_1.Shape)
                obj.shapes.push(_this.exportShape(item));
            else if (item instanceof Connector_1.Connector) {
                var connectorObj = _this.exportConnector(item);
                if (item.beginItem) {
                    connectorObj["beginItemKey"] = item.beginItem.key;
                    connectorObj["beginConnectionPointIndex"] = item.beginConnectionPointIndex;
                }
                if (item.endItem) {
                    connectorObj["endItemKey"] = item.endItem.key;
                    connectorObj["endConnectionPointIndex"] = item.endConnectionPointIndex;
                }
                obj.connectors.push(connectorObj);
            }
        });
    };
    Exporter.prototype.exportItem = function (item) {
        return {
            "key": item.key,
            "dataKey": item.dataKey,
            "customData": Utils_1.ObjectUtils.cloneObject(item.customData),
            "locked": item.locked,
            "zIndex": item.zIndex
        };
    };
    Exporter.prototype.exportShape = function (shape) {
        var result = this.exportItem(shape);
        result["type"] = shape.description.key;
        result["text"] = shape.text;
        if (!shape.image.isEmpty)
            result["imageUrl"] = shape.image.exportUrl;
        result["x"] = shape.position.x;
        result["y"] = shape.position.y;
        result["width"] = shape.size.width;
        result["height"] = shape.size.height;
        var paramsObj = shape.parameters.toObject();
        if (paramsObj)
            result["parameters"] = paramsObj;
        var styleObj = shape.style.toObject();
        if (styleObj)
            result["style"] = styleObj;
        var styleTextObj = shape.styleText.toObject();
        if (styleTextObj)
            result["styleText"] = styleTextObj;
        if (shape.children.length)
            result["childKeys"] = shape.children.map(function (child) { return child.key; });
        if (!shape.expanded)
            result["expanded"] = false;
        if (shape.expandedSize) {
            result["expandedWidth"] = shape.expandedSize.width;
            result["expandedHeight"] = shape.expandedSize.height;
        }
        return result;
    };
    Exporter.prototype.exportConnector = function (connector) {
        var result = this.exportItem(connector);
        result["points"] = connector.points.map(function (p) { return { "x": p.x, "y": p.y }; });
        var textObj = connector.texts.toObject();
        if (textObj)
            result["texts"] = textObj;
        var propsObj = connector.properties.toObject();
        if (propsObj)
            result["properties"] = propsObj;
        var styleObj = connector.style.toObject();
        if (styleObj)
            result["style"] = styleObj;
        var styleTextObj = connector.styleText.toObject();
        if (styleTextObj)
            result["styleText"] = styleTextObj;
        return result;
    };
    Exporter.prototype.exportSvg = function (modelSize, pageColor, exportManager, callback) {
        exportManager.exportSvgImage(modelSize, pageColor, callback);
    };
    Exporter.prototype.exportPng = function (modelSize, pageColor, exportManager, callback, useCanvgForExportToImage) {
        exportManager.exportPngImage(modelSize, pageColor, callback, useCanvgForExportToImage);
    };
    Exporter.prototype.exportJpg = function (modelSize, pageColor, exportManager, callback, useCanvgForExportToImage) {
        exportManager.exportJpgImage(modelSize, pageColor, callback, useCanvgForExportToImage);
    };
    return Exporter;
}());
exports.Exporter = Exporter;


/***/ }),
/* 74 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.ToggleStyleTextPropertyCommand = void 0;
var StylePropertyCommandBase_1 = __webpack_require__(134);
var ChangeStyleTextHistoryItem_1 = __webpack_require__(70);
var Style_1 = __webpack_require__(26);
var ToggleStyleTextPropertyCommand = (function (_super) {
    __extends(ToggleStyleTextPropertyCommand, _super);
    function ToggleStyleTextPropertyCommand() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    ToggleStyleTextPropertyCommand.prototype.getValue = function () {
        var value = this.control.selection.inputPosition.getCurrentTextStylePropertyValue(this.getStyleProperty());
        return value === this.getStylePropertyValue();
    };
    ToggleStyleTextPropertyCommand.prototype.executeCore = function (state) {
        var _this = this;
        this.control.history.beginTransaction();
        var styleProperty = this.getStyleProperty();
        var styleValue = state.value ? Style_1.TextStyle.defaultInstance[styleProperty] : this.getStylePropertyValue();
        var items = this.control.selection.getSelectedItems();
        items.forEach(function (item) {
            _this.control.history.addAndRedo(new ChangeStyleTextHistoryItem_1.ChangeStyleTextHistoryItem(item.key, styleProperty, styleValue));
        });
        this.control.selection.inputPosition.setTextStylePropertyValue(this.getStyleProperty(), styleValue);
        this.control.history.endTransaction();
        return true;
    };
    ToggleStyleTextPropertyCommand.prototype.getStyleObj = function (item) {
        return item.styleText;
    };
    ToggleStyleTextPropertyCommand.prototype.getDefaultStyleObj = function () {
        return new Style_1.TextStyle();
    };
    return ToggleStyleTextPropertyCommand;
}(StylePropertyCommandBase_1.StylePropertyCommandBase));
exports.ToggleStyleTextPropertyCommand = ToggleStyleTextPropertyCommand;


/***/ }),
/* 75 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.ChangeStylePropertyCommand = void 0;
var ChangeStylePropertyCommandBase_1 = __webpack_require__(135);
var ChangeStyleHistoryItem_1 = __webpack_require__(89);
var Style_1 = __webpack_require__(26);
var ChangeStylePropertyCommand = (function (_super) {
    __extends(ChangeStylePropertyCommand, _super);
    function ChangeStylePropertyCommand() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    ChangeStylePropertyCommand.prototype.getValue = function () {
        return this.control.selection.inputPosition.getCurrentStylePropertyValue(this.getStyleProperty());
    };
    ChangeStylePropertyCommand.prototype.getStyleObj = function (item) {
        return item.style;
    };
    ChangeStylePropertyCommand.prototype.getDefaultStyleObj = function () {
        return new Style_1.Style();
    };
    ChangeStylePropertyCommand.prototype.createHistoryItem = function (item, styleProperty, styleValue) {
        return new ChangeStyleHistoryItem_1.ChangeStyleHistoryItem(item.key, styleProperty, styleValue);
    };
    ChangeStylePropertyCommand.prototype.updateInputPosition = function (value) {
        this.control.selection.inputPosition.setStylePropertyValue(this.getStyleProperty(), value);
    };
    return ChangeStylePropertyCommand;
}(ChangeStylePropertyCommandBase_1.ChangeStylePropertyCommandBase));
exports.ChangeStylePropertyCommand = ChangeStylePropertyCommand;


/***/ }),
/* 76 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.AutoLayoutCommandBase = void 0;
var ModelUtils_1 = __webpack_require__(4);
var SimpleCommandBase_1 = __webpack_require__(10);
var Shape_1 = __webpack_require__(14);
var Connector_1 = __webpack_require__(6);
var Utils_1 = __webpack_require__(3);
var rectangle_1 = __webpack_require__(13);
var ScrollIntoViewHistoryItem_1 = __webpack_require__(251);
var AutoLayoutCommandBase = (function (_super) {
    __extends(AutoLayoutCommandBase, _super);
    function AutoLayoutCommandBase() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    AutoLayoutCommandBase.prototype.executeCore = function (state, parameter) {
        var _this = this;
        this.control.history.beginTransaction();
        var shapes = this.getAffectedShapes();
        var connectors = this.getAffectedConnectors();
        var settings = this.createLayoutSettings();
        var graphInfo = ModelUtils_1.ModelUtils.getGraphInfoByItems(this.control.model, shapes, connectors, false);
        if (graphInfo.length) {
            var rectangle_2;
            var model_1 = this.control.model;
            var commonRect = Utils_1.GeometryUtils.getCommonRectangle(Utils_1.Utils.flatten(graphInfo.map(function (g) { return g.graph.items.map(function (i) { return model_1.findItem(i.key); }); }))
                .concat(graphInfo.map(function (g) { return g.container; }))
                .filter(function (i) { return i; })
                .map(function (i) { return i.rectangle; }));
            this.control.history.addAndRedo(new ScrollIntoViewHistoryItem_1.ScrollIntoViewOnUndoHistoryItem(this.control.view, commonRect));
            graphInfo.forEach(function (info) {
                var layout = _this.createLayout(settings, info.graph);
                var nonGraphItems = ModelUtils_1.ModelUtils.getNonGraphItems(_this.control.model, info.container, layout.nodeToLayout, shapes, connectors);
                var layoutRect = ModelUtils_1.ModelUtils.applyLayout(_this.control.history, _this.control.model, info.container, info.graph, layout, nonGraphItems, settings, _this.control.settings.snapToGrid, _this.control.settings.gridSize, false);
                rectangle_2 = rectangle_2 && rectangle_1.Rectangle.union(rectangle_2, layoutRect) || layoutRect;
            });
            ModelUtils_1.ModelUtils.tryUpdateModelRectangle(this.control.history);
            this.control.history.addAndRedo(new ScrollIntoViewHistoryItem_1.ScrollIntoViewOnRedoHistoryItem(this.control.view, rectangle_2));
        }
        this.control.history.endTransaction();
        return true;
    };
    AutoLayoutCommandBase.prototype.getAffectedShapes = function () {
        return this.control.selection.isEmpty() ?
            this.control.model.items.filter((function (i) { return i instanceof Shape_1.Shape && !i.locked; })) :
            this.control.selection.getSelectedShapes(false, true);
    };
    AutoLayoutCommandBase.prototype.getAffectedConnectors = function () {
        return this.control.selection.isEmpty() ?
            this.control.model.items.filter((function (i) { return i instanceof Connector_1.Connector && !i.locked; })) :
            this.control.selection.getSelectedConnectors(false, true);
    };
    return AutoLayoutCommandBase;
}(SimpleCommandBase_1.SimpleCommandBase));
exports.AutoLayoutCommandBase = AutoLayoutCommandBase;


/***/ }),
/* 77 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.ChangePagePropertyCommand = void 0;
var ModelUtils_1 = __webpack_require__(4);
var SimpleCommandBase_1 = __webpack_require__(10);
var ChangePagePropertyCommand = (function (_super) {
    __extends(ChangePagePropertyCommand, _super);
    function ChangePagePropertyCommand() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    ChangePagePropertyCommand.prototype.executeCore = function (state, parameter) {
        var _this = this;
        this.control.history.beginTransaction();
        var items = this.createHistoryItems(parameter);
        items.forEach(function (item) { _this.control.history.addAndRedo(item); });
        ModelUtils_1.ModelUtils.tryUpdateModelRectangle(this.control.history);
        this.control.history.endTransaction();
        return true;
    };
    ChangePagePropertyCommand.prototype.getItems = function () {
        return null;
    };
    return ChangePagePropertyCommand;
}(SimpleCommandBase_1.SimpleCommandBase));
exports.ChangePagePropertyCommand = ChangePagePropertyCommand;


/***/ }),
/* 78 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.CanvasItemsManager = exports.CONNECTOR_CAN_MOVE = exports.NOT_VALID_CSSCLASS = void 0;
var ModelChange_1 = __webpack_require__(99);
var Event_1 = __webpack_require__(11);
var GroupPrimitive_1 = __webpack_require__(39);
var Utils_1 = __webpack_require__(17);
var Shape_1 = __webpack_require__(14);
var Connector_1 = __webpack_require__(6);
var dom_1 = __webpack_require__(27);
var CanvasManager_1 = __webpack_require__(140);
var ModelUtils_1 = __webpack_require__(4);
exports.NOT_VALID_CSSCLASS = "not-valid";
exports.CONNECTOR_CAN_MOVE = "can-move";
var CanvasItemsManager = (function (_super) {
    __extends(CanvasItemsManager, _super);
    function CanvasItemsManager(viewElement, zoomLevel, dom) {
        var _this = _super.call(this, zoomLevel, dom) || this;
        _this.itemSelectorGroupContainers = {};
        _this.itemSelectorElements = {};
        _this.itemGroupContainers = {};
        _this.itemElements = {};
        _this.itemChildElements = {};
        _this.primitives = {};
        _this.selectorPrimitives = {};
        _this.selectedItems = {};
        _this.initializeContainerElements(viewElement);
        return _this;
    }
    CanvasItemsManager.prototype.initializeContainerElements = function (view) {
        this.itemSelectorsContainer = this.createAndChangePrimitiveElement(new GroupPrimitive_1.GroupPrimitive([], null), view);
        this.itemsContainer = this.createAndChangePrimitiveElement(new GroupPrimitive_1.GroupPrimitive([], null), view);
    };
    CanvasItemsManager.prototype.clear = function () {
        this.primitives = {};
        this.selectorPrimitives = {};
        Utils_1.RenderUtils.removeContent(this.itemSelectorsContainer);
        Utils_1.RenderUtils.removeContent(this.itemsContainer);
        this.itemSelectorGroupContainers = {};
        this.itemSelectorElements = {};
        this.itemGroupContainers = {};
        this.itemElements = {};
        this.itemChildElements = {};
        this.selectedItems = {};
    };
    CanvasItemsManager.prototype.applyChange = function (change) {
        var item = change.item;
        var itemParent = this.getItemParent(item.zIndex, item.container && item.container.key);
        if (!itemParent)
            return false;
        if (item instanceof Shape_1.Shape)
            this.applyShapeChange(item, change.type, change.isValid);
        else if (item instanceof Connector_1.Connector)
            this.applyConnectorChange(item, change.type, change.isValid);
        return true;
    };
    CanvasItemsManager.prototype.setPointerEventsNone = function (element, value) {
        var style = element.style;
        if (style !== undefined && style.pointerEvents !== undefined)
            style.pointerEvents = value ? "none" : "";
        var childNodes = element.childNodes;
        for (var i = 0; i < childNodes.length; i++)
            this.setPointerEventsNone(childNodes[i], value);
    };
    CanvasItemsManager.prototype.notifyDragStart = function (itemKeys) {
        var _this = this;
        itemKeys.forEach(function (itemKey) {
            if (_this.itemElements[itemKey])
                _this.setPointerEventsNone(_this.itemElements[itemKey], true);
            if (_this.itemChildElements[itemKey])
                _this.setPointerEventsNone(_this.itemChildElements[itemKey], true);
            if (_this.itemSelectorElements[itemKey])
                _this.setPointerEventsNone(_this.itemSelectorElements[itemKey], true);
        });
    };
    CanvasItemsManager.prototype.notifyDragEnd = function (itemKeys) {
        var _this = this;
        itemKeys.forEach(function (itemKey) {
            if (_this.itemElements[itemKey])
                _this.setPointerEventsNone(_this.itemElements[itemKey], false);
            if (_this.itemChildElements[itemKey])
                _this.setPointerEventsNone(_this.itemChildElements[itemKey], false);
            if (_this.itemSelectorElements[itemKey])
                _this.setPointerEventsNone(_this.itemSelectorElements[itemKey], false);
        });
    };
    CanvasItemsManager.prototype.notifyDragScrollStart = function () { };
    CanvasItemsManager.prototype.notifyDragScrollEnd = function () { };
    CanvasItemsManager.prototype.notifyTextInputStart = function (item, text, position, size) {
        var element = this.itemElements[item.key];
        dom_1.DomUtils.addClassName(element, "text-input");
    };
    CanvasItemsManager.prototype.notifyTextInputEnd = function (item, captureFocus) {
        var element = this.itemElements[item.key];
        dom_1.DomUtils.removeClassName(element, "text-input");
    };
    CanvasItemsManager.prototype.notifyTextInputPermissionsCheck = function (item, allowed) {
        var element = this.itemElements[item.key];
        if (allowed)
            dom_1.DomUtils.removeClassName(element, exports.NOT_VALID_CSSCLASS);
        else
            dom_1.DomUtils.addClassName(element, exports.NOT_VALID_CSSCLASS);
    };
    CanvasItemsManager.prototype.notifyActualZoomChanged = function (actualZoom) {
        var scale = "scale(" + actualZoom + ")";
        this.dom.changeByFunc(this.itemsContainer, function (e) { return e.setAttribute("transform", scale); });
        this.dom.changeByFunc(this.itemSelectorsContainer, function (e) { return e.setAttribute("transform", scale); });
        this.actualZoom = actualZoom;
    };
    CanvasItemsManager.prototype.notifyViewAdjusted = function (canvasOffset) { };
    CanvasItemsManager.prototype.invalidatePrimitives = function (item) {
        if (this.primitives[item.key]) {
            this.primitives[item.key].forEach(function (primitive) {
                primitive.dispose();
            });
            delete this.primitives[item.key];
        }
        if (this.selectorPrimitives[item.key]) {
            this.selectorPrimitives[item.key].forEach(function (primitive) {
                primitive.dispose();
            });
            delete this.selectorPrimitives[item.key];
        }
    };
    CanvasItemsManager.prototype.getPrimitives = function (item) {
        if (!this.primitives[item.key])
            this.primitives[item.key] = item.createPrimitives();
        return this.primitives[item.key];
    };
    CanvasItemsManager.prototype.getSelectorPrimitives = function (item) {
        if (!this.selectorPrimitives[item.key])
            this.selectorPrimitives[item.key] = item.createSelectorPrimitives();
        return this.selectorPrimitives[item.key];
    };
    CanvasItemsManager.prototype.getShapeSelectorClassName = function (shape) {
        var className = "shape";
        if (shape.enableChildren)
            className += " container";
        if (shape.isLocked)
            className += " locked";
        return className;
    };
    CanvasItemsManager.prototype.getShapeClassName = function (shape, isValid) {
        var selectorClassName = this.getShapeSelectorClassName(shape);
        return isValid ? selectorClassName : selectorClassName + " " + exports.NOT_VALID_CSSCLASS;
    };
    CanvasItemsManager.prototype.applyShapeChange = function (shape, type, isValid) {
        var key = shape.key;
        var containerKey = shape.container && shape.container.key;
        var itemSelectorParent = this.getItemSelectorGroupContainer(shape.zIndex, containerKey);
        var itemParent = this.getItemGroupContainer(shape.zIndex, containerKey);
        var itemClassName = this.getShapeClassName(shape, isValid);
        switch (type) {
            case ModelChange_1.ItemChangeType.Create:
                this.itemSelectorElements[key] = this.createItemElements(key, this.getSelectorPrimitives(shape), itemSelectorParent, this.getShapeSelectorClassName(shape), Event_1.MouseEventElementType.Shape);
                this.itemElements[key] = this.createItemElements(key, this.getPrimitives(shape), itemParent, itemClassName, Event_1.MouseEventElementType.Shape);
                if (shape.enableChildren) {
                    this.itemChildElements[key] = this.createItemElements(key, [], itemParent, "container-children", Event_1.MouseEventElementType.Undefined);
                    this.changeItemChildrenVisibility(this.itemChildElements[key], shape.expanded);
                }
                break;
            case ModelChange_1.ItemChangeType.Remove:
                this.removeItemCustomContent(this.itemSelectorElements[key], this.getSelectorPrimitives(shape));
                this.removeItemCustomContent(this.itemElements[key], this.getPrimitives(shape));
                this.invalidatePrimitives(shape);
                this.removeItemElements(this.itemSelectorElements[key]);
                delete this.itemSelectorElements[key];
                this.removeItemElements(this.itemElements[key]);
                delete this.itemElements[key];
                if (this.itemChildElements[key]) {
                    this.removeItemElements(this.itemChildElements[key]);
                    delete this.itemChildElements[key];
                    delete this.itemGroupContainers[key];
                    delete this.itemSelectorGroupContainers[key];
                }
                break;
            case ModelChange_1.ItemChangeType.UpdateStructure:
            case ModelChange_1.ItemChangeType.UpdateProperties:
            case ModelChange_1.ItemChangeType.Update:
                if (type !== ModelChange_1.ItemChangeType.Update) {
                    if (type === ModelChange_1.ItemChangeType.UpdateStructure) {
                        this.removeItemCustomContent(this.itemSelectorElements[key], this.getSelectorPrimitives(shape));
                        this.removeItemCustomContent(this.itemElements[key], this.getPrimitives(shape));
                    }
                    this.invalidatePrimitives(shape);
                }
                this.changeItemElements(this.getSelectorPrimitives(shape), this.itemSelectorElements[key], type === ModelChange_1.ItemChangeType.UpdateStructure);
                this.changeItemElements(this.getPrimitives(shape), this.itemElements[key], type === ModelChange_1.ItemChangeType.UpdateStructure);
                this.changeItemClassName(this.itemElements[key], itemClassName);
                if (this.itemChildElements[key])
                    this.changeItemChildrenVisibility(this.itemChildElements[key], shape.expanded);
                if (itemSelectorParent !== (this.itemSelectorElements[key] && this.itemSelectorElements[key].parentNode))
                    this.moveItemElements(itemSelectorParent, this.itemSelectorElements[key]);
                if (itemParent !== (this.itemElements[key] && this.itemElements[key].parentNode))
                    this.moveItemElements(itemParent, this.itemElements[key]);
                if (this.itemChildElements[key] && (itemParent !== this.itemChildElements[key].parentNode))
                    this.moveItemElements(itemParent, this.itemChildElements[key]);
                break;
            case ModelChange_1.ItemChangeType.UpdateClassName:
                this.changeItemClassName(this.itemElements[key], itemClassName);
        }
    };
    CanvasItemsManager.prototype.getConnectorSelectorClassName = function (connector) {
        var selectorClassName = "connector";
        return ModelUtils_1.ModelUtils.canMoveConnector(this.selectedItems, connector) ? selectorClassName + " " + exports.CONNECTOR_CAN_MOVE : selectorClassName;
    };
    CanvasItemsManager.prototype.getConnectorClassName = function (connector, isValid) {
        var selectorMoveClassName = this.getConnectorSelectorClassName(connector);
        return isValid ? selectorMoveClassName : selectorMoveClassName + " " + exports.NOT_VALID_CSSCLASS;
    };
    CanvasItemsManager.prototype.applyConnectorChange = function (connector, type, isValid) {
        var key = connector.key;
        var containerKey = connector.container && connector.container.key;
        var itemSelectorParent = this.getItemSelectorGroupContainer(connector.zIndex, containerKey);
        var itemParent = this.getItemGroupContainer(connector.zIndex, containerKey);
        var className = this.getConnectorClassName(connector, isValid);
        switch (type) {
            case ModelChange_1.ItemChangeType.Create:
                this.itemSelectorElements[key] = this.createItemElements(key, this.getSelectorPrimitives(connector), itemSelectorParent, this.getConnectorSelectorClassName(connector), Event_1.MouseEventElementType.Connector);
                this.itemElements[key] = this.createItemElements(key, this.getPrimitives(connector), itemParent, className, Event_1.MouseEventElementType.Connector);
                break;
            case ModelChange_1.ItemChangeType.Remove:
                this.removeItemCustomContent(this.itemSelectorElements[key], this.getSelectorPrimitives(connector));
                this.removeItemCustomContent(this.itemElements[key], this.getPrimitives(connector));
                this.invalidatePrimitives(connector);
                this.removeItemElements(this.itemSelectorElements[key]);
                delete this.itemSelectorElements[key];
                this.removeItemElements(this.itemElements[key]);
                delete this.itemElements[key];
                break;
            case ModelChange_1.ItemChangeType.UpdateStructure:
            case ModelChange_1.ItemChangeType.UpdateProperties:
            case ModelChange_1.ItemChangeType.Update:
                if (type !== ModelChange_1.ItemChangeType.Update) {
                    if (type === ModelChange_1.ItemChangeType.UpdateStructure) {
                        this.removeItemCustomContent(this.itemSelectorElements[key], this.getSelectorPrimitives(connector));
                        this.removeItemCustomContent(this.itemElements[key], this.getPrimitives(connector));
                    }
                    this.invalidatePrimitives(connector);
                }
                this.changeItemElements(this.getSelectorPrimitives(connector), this.itemSelectorElements[key], type === ModelChange_1.ItemChangeType.UpdateStructure);
                this.changeItemClassName(this.itemSelectorElements[key], this.getConnectorSelectorClassName(connector));
                this.changeItemElements(this.getPrimitives(connector), this.itemElements[key], type === ModelChange_1.ItemChangeType.UpdateStructure);
                this.changeItemClassName(this.itemElements[key], className);
                if (itemSelectorParent !== (this.itemSelectorElements[key] && this.itemSelectorElements[key].parentNode))
                    this.moveItemElements(itemSelectorParent, this.itemSelectorElements[key]);
                if (itemParent !== (this.itemElements[key] && this.itemElements[key].parentNode))
                    this.moveItemElements(itemParent, this.itemElements[key]);
                break;
            case ModelChange_1.ItemChangeType.UpdateClassName:
                this.changeItemClassName(this.itemSelectorElements[key], this.getConnectorSelectorClassName(connector));
                this.changeItemClassName(this.itemElements[key], className);
        }
    };
    CanvasItemsManager.prototype.createItemElements = function (key, primitives, parent, className, type) {
        var gEl = this.createAndChangePrimitiveElement(new GroupPrimitive_1.GroupPrimitive([], className, undefined, undefined, function (e) { return Utils_1.RenderUtils.setElementEventData(e, type, key); }), parent);
        this.createAndChangePrimitivesElements(primitives, gEl);
        return gEl;
    };
    CanvasItemsManager.prototype.changeItemElements = function (primitives, element, updateStructure) {
        if (updateStructure || primitives.length !== element.childNodes.length) {
            Utils_1.RenderUtils.removeContent(element);
            this.createAndChangePrimitivesElements(primitives, element);
        }
        else
            this.dom.changeChildrenByPrimitives(primitives, element);
    };
    CanvasItemsManager.prototype.changeItemClassName = function (element, className) {
        if (className && element)
            this.changePrimitiveElement(new GroupPrimitive_1.GroupPrimitive([], className), element);
    };
    CanvasItemsManager.prototype.removeItemElements = function (element) {
        if (element && element.parentNode)
            element.parentNode.removeChild(element);
    };
    CanvasItemsManager.prototype.removeItemCustomContent = function (element, primitives) {
        if (element && primitives && primitives.length === element.childNodes.length)
            primitives.forEach(function (primitive, index) {
                primitive.destroyCustomContent(element.childNodes[index]);
            });
    };
    CanvasItemsManager.prototype.moveItemElements = function (parent, element, sibling) {
        if (element && parent)
            if (sibling)
                parent.insertBefore(element, sibling);
            else
                parent.appendChild(element);
    };
    CanvasItemsManager.prototype.changeItemChildrenVisibility = function (element, expanded) {
        element.style.display = expanded ? "" : "none";
    };
    CanvasItemsManager.prototype.getItemGroupContainerKey = function (zIndex, parentContainerKey) {
        return parentContainerKey !== undefined ? zIndex + "_" + parentContainerKey : zIndex.toString();
    };
    CanvasItemsManager.prototype.getItemGroupContainer = function (zIndex, parentContainerKey) {
        var parent = parentContainerKey !== undefined ? this.getItemParent(zIndex, parentContainerKey) : this.itemsContainer;
        var key = parentContainerKey || "Main";
        if (this.itemGroupContainers[key] === undefined || this.itemGroupContainers[key][zIndex] === undefined) {
            if (this.itemGroupContainers[key] === undefined)
                this.itemGroupContainers[key] = [];
            var nextSiblingZIndex = Object.keys(this.itemGroupContainers[key]).map(function (z) { return +z; }).sort().filter(function (z) { return z > zIndex; })[0];
            this.itemGroupContainers[key][zIndex] = this.createAndChangePrimitiveElement(new GroupPrimitive_1.GroupPrimitive([], null, zIndex), parent, this.itemGroupContainers[key][nextSiblingZIndex]);
        }
        return this.itemGroupContainers[key][zIndex];
    };
    CanvasItemsManager.prototype.getItemSelectorGroupContainer = function (zIndex, parentContainerKey) {
        var parent = parentContainerKey !== undefined ? this.getItemSelectorParent(zIndex, parentContainerKey) : this.itemSelectorsContainer;
        var key = parentContainerKey || "Main";
        if (this.itemSelectorGroupContainers[key] === undefined || this.itemSelectorGroupContainers[key][zIndex] === undefined) {
            if (this.itemSelectorGroupContainers[key] === undefined)
                this.itemSelectorGroupContainers[key] = [];
            var nextSiblingZIndex = Object.keys(this.itemSelectorGroupContainers[key]).map(function (z) { return +z; }).sort().filter(function (z) { return z > zIndex; })[0];
            this.itemSelectorGroupContainers[key][zIndex] = this.createAndChangePrimitiveElement(new GroupPrimitive_1.GroupPrimitive([], null, zIndex), parent, this.itemSelectorGroupContainers[key][nextSiblingZIndex]);
        }
        return this.itemSelectorGroupContainers[key][zIndex];
    };
    CanvasItemsManager.prototype.getItemParent = function (zIndex, parentContainerKey) {
        return parentContainerKey !== undefined ?
            this.itemChildElements[parentContainerKey] :
            this.getItemGroupContainer(zIndex);
    };
    CanvasItemsManager.prototype.getItemSelectorParent = function (zIndex, parentContainerKey) {
        return parentContainerKey !== undefined ?
            this.itemChildElements[parentContainerKey] :
            this.getItemSelectorGroupContainer(zIndex);
    };
    CanvasItemsManager.prototype.notifySelectionChanged = function (selection) {
        var _this = this;
        var newSelectedItems = ModelUtils_1.ModelUtils.createSelectedItems(selection);
        var itemsToUpdate = [];
        this.populateItems(itemsToUpdate, newSelectedItems, this.selectedItems);
        this.populateItems(itemsToUpdate, this.selectedItems, newSelectedItems);
        this.selectedItems = newSelectedItems;
        itemsToUpdate.forEach(function (item) {
            if (item instanceof Connector_1.Connector)
                _this.applyOrPostponeChanges([new ModelChange_1.ItemChange(item, ModelChange_1.ItemChangeType.UpdateClassName, true)]);
        });
    };
    CanvasItemsManager.prototype.populateItems = function (target, sourceSet, checkSet) {
        Object.keys(sourceSet).forEach(function (key) {
            if (!checkSet[key])
                target.push(sourceSet[key]);
        });
    };
    return CanvasItemsManager;
}(CanvasManager_1.CanvasManager));
exports.CanvasItemsManager = CanvasItemsManager;


/***/ }),
/* 79 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.TextMeasurer = void 0;
var size_1 = __webpack_require__(2);
var Utils_1 = __webpack_require__(17);
var Shape_1 = __webpack_require__(14);
var Connector_1 = __webpack_require__(6);
var ITextMeasurer_1 = __webpack_require__(43);
var RenderHelper_1 = __webpack_require__(15);
var TextUtils_1 = __webpack_require__(64);
var TextMeasurer = (function () {
    function TextMeasurer(parent) {
        this.cache = {};
        this.fontSizeCache = {};
        this.containers = {};
        this.parent = parent;
        this.createNodes();
    }
    TextMeasurer.prototype.measureWords = function (text, style, owner) {
        var _this = this;
        var result = { words: {}, fontSize: -1 };
        var words = typeof text === "string" ? this.splitToWords(text, false) : text.reduce(function (acc, t) { return acc.concat(_this.splitToWords(t, false)); }, []);
        words.push(" ");
        var styleHashKey = this.getStyleHash(style, owner);
        var measureElements = this.tryLoadWordsToMeasurer(words, style, styleHashKey, owner, undefined, undefined, undefined, undefined, result);
        if (measureElements) {
            var container = this.containers[owner];
            this.putElementsInDOM(container, measureElements);
            this.beforeMeasureInDOM();
            this.measureElementsInDOM(measureElements, result);
            this.afterMeasureInDOM();
        }
        return result;
    };
    TextMeasurer.prototype.measureTextLine = function (textLine, style, owner) {
        var results = this.measureWords(textLine, style, owner);
        return TextUtils_1.getTextLineSize(textLine, results);
    };
    TextMeasurer.prototype.onNewModel = function (items, dom) {
        var _this = this;
        dom.changeByFunc(null, function () { return _this.onNewModelCore(items); });
    };
    TextMeasurer.prototype.onNewModelCore = function (items) {
        var shapes = items.filter(function (i) { return i instanceof Shape_1.Shape; });
        var connectors = items.filter(function (i) { return i instanceof Connector_1.Connector; });
        var shapeElements = this.tryLoadShapeTexts(shapes);
        var connectorElements = this.tryLoadConnectorTexts(connectors);
        if (shapeElements || connectorElements) {
            shapeElements && this.putElementsInDOM(this.containers[ITextMeasurer_1.TextOwner.Shape], shapeElements);
            connectorElements && this.putElementsInDOM(this.containers[ITextMeasurer_1.TextOwner.Connector], connectorElements);
            this.beforeMeasureInDOM();
            shapeElements && this.measureElementsInDOM(shapeElements);
            connectorElements && this.measureElementsInDOM(connectorElements);
            this.afterMeasureInDOM();
        }
    };
    TextMeasurer.prototype.replaceParent = function (parent) {
        if (this.parent !== parent) {
            if (this.mainElement.parentNode)
                parent.appendChild(this.mainElement);
            this.parent = parent;
        }
    };
    TextMeasurer.prototype.clean = function () {
        Utils_1.RenderUtils.removeElement(this.mainElement);
    };
    TextMeasurer.prototype.tryLoadShapeTexts = function (shapes) {
        var _this = this;
        var newSet = {};
        var elements = [];
        var hashes = [];
        var styleHashes = [];
        shapes.forEach(function (s) {
            var styleHashKey = _this.getStyleHash(s.styleText, ITextMeasurer_1.TextOwner.Shape);
            _this.tryLoadWordsToMeasurer(_this.splitToWords(s.text, true), s.styleText, styleHashKey, ITextMeasurer_1.TextOwner.Shape, newSet, elements, hashes, styleHashes);
        });
        return elements.length ? { elements: elements, hashes: hashes, styleHashes: styleHashes } : null;
    };
    TextMeasurer.prototype.tryLoadConnectorTexts = function (connectors) {
        var _this = this;
        var newSet = {};
        var elements = [];
        var hashes = [];
        var styleHashes = [];
        connectors.forEach(function (c) {
            var words = c.texts.map(function (t) { return t.value; }).reduce(function (acc, text) { return acc.concat(_this.splitToWords(text, false)); }, []);
            if (words.length) {
                words.push(" ");
                var styleHashKey = _this.getStyleHash(c.styleText, ITextMeasurer_1.TextOwner.Connector);
                _this.tryLoadWordsToMeasurer(words, c.styleText, styleHashKey, ITextMeasurer_1.TextOwner.Connector, newSet, elements, hashes, styleHashes);
            }
        });
        return elements.length ? { elements: elements, hashes: hashes, styleHashes: styleHashes } : null;
    };
    TextMeasurer.prototype.tryLoadWordsToMeasurer = function (words, style, styleHashKey, textOwner, newSet, elementsToMeasure, hashesToMeasure, styleHashesToMeasure, result) {
        var _this = this;
        var newWords = [];
        elementsToMeasure = elementsToMeasure || [];
        hashesToMeasure = hashesToMeasure || [];
        styleHashesToMeasure = styleHashesToMeasure || [];
        newSet = newSet || {};
        words.forEach(function (t) { return _this.tryLoadWordToMeasurer(t, style, styleHashKey, textOwner, newSet, elementsToMeasure, hashesToMeasure, styleHashesToMeasure, newWords, result); });
        return elementsToMeasure.length ? { elements: elementsToMeasure, hashes: hashesToMeasure, styleHashes: styleHashesToMeasure, newWords: newWords } : null;
    };
    TextMeasurer.prototype.putElementsInDOM = function (container, measureElements) {
        container.parentNode && container.parentNode.removeChild(container);
        while (container.firstChild)
            container.removeChild(container.firstChild);
        measureElements.elements.forEach(function (el) { return container.appendChild(el); });
        this.svgElement.appendChild(container);
    };
    TextMeasurer.prototype.measureElementsInDOM = function (measureElements, result) {
        var hashes = measureElements.hashes;
        var elements = measureElements.elements;
        var words = measureElements.newWords;
        var count = hashes.length;
        for (var i = 0; i < count; i++) {
            var size = this.getDomElementSize(elements[i]);
            if (size) {
                if (!size.isEmpty())
                    this.cache[hashes[i]] = size;
                if (result)
                    result.words[words[i]] = size;
            }
            var styleHashKey = measureElements.styleHashes[i];
            if (this.fontSizeCache[styleHashKey] === undefined)
                this.fontSizeCache[styleHashKey] = this.getDomFontSize(elements[i]);
            if (result && result.fontSize < 0)
                result.fontSize = this.fontSizeCache[styleHashKey];
        }
    };
    TextMeasurer.prototype.beforeMeasureInDOM = function () {
        this.parent.appendChild(this.mainElement);
    };
    TextMeasurer.prototype.afterMeasureInDOM = function () {
        this.mainElement.parentNode && this.mainElement.parentNode.removeChild(this.mainElement);
    };
    TextMeasurer.prototype.tryLoadWordToMeasurer = function (word, style, styleHashKey, owner, newSet, elementsToMeasure, hashesToMeasure, styleHashesToMeasure, newWords, result) {
        var hash = this.getHash(word, style, owner);
        var cachedSize = this.cache[hash];
        if (!cachedSize && !newSet[hash]) {
            newSet[hash] = true;
            hashesToMeasure.push(hash);
            elementsToMeasure.push(this.createElement(word, style));
            styleHashesToMeasure.push(styleHashKey);
            newWords.push(word);
        }
        else if (cachedSize && result) {
            result.words[word] = cachedSize;
            result.fontSize = this.fontSizeCache[styleHashKey];
        }
    };
    TextMeasurer.prototype.getHash = function (text, style, owner) {
        return owner + "|" + (style && style.toHash()) + "|" + text;
    };
    TextMeasurer.prototype.getStyleHash = function (style, owner) {
        return this.getHash(" ", style, owner);
    };
    TextMeasurer.prototype.createElement = function (text, style) {
        var element = document.createElementNS(RenderHelper_1.svgNS, "text");
        if (text === " ")
            element.setAttributeNS("http://www.w3.org/XML/1998/namespace", "xml:space", "preserve");
        element.textContent = text;
        style && Utils_1.RenderUtils.applyStyleToElement(style, element);
        return element;
    };
    TextMeasurer.prototype.splitToWords = function (text, includeWhitespace) {
        var words = TextUtils_1.textToWords(text);
        includeWhitespace && words.push(" ");
        return words;
    };
    TextMeasurer.prototype.getDomFontSize = function (textEl) {
        return parseFloat(window.getComputedStyle(textEl).fontSize);
    };
    TextMeasurer.prototype.getDomElementSize = function (textEl) {
        var bBox;
        try {
            bBox = textEl.getBBox();
        }
        catch (_a) { }
        return bBox ? new size_1.Size(bBox.width, bBox.height) : new size_1.Size(0, 0);
    };
    TextMeasurer.prototype.createNodes = function () {
        this.mainElement = RenderHelper_1.RenderHelper.createMainElement(undefined, true);
        this.svgElement = RenderHelper_1.RenderHelper.createSvgElement(this.mainElement, false);
        this.createContainer(ITextMeasurer_1.TextOwner.Shape, "shape");
        this.createContainer(ITextMeasurer_1.TextOwner.Connector, "connector");
        this.createContainer(ITextMeasurer_1.TextOwner.ExtensionLine, "extension-line");
        this.createContainer(ITextMeasurer_1.TextOwner.Resize, "resize-info");
    };
    TextMeasurer.prototype.createContainer = function (owner, className) {
        var element = document.createElementNS(RenderHelper_1.svgNS, "g");
        element.setAttribute("class", className);
        this.containers[owner] = element;
    };
    return TextMeasurer;
}());
exports.TextMeasurer = TextMeasurer;


/***/ }),
/* 80 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.EdgeOnLayer = exports.NodeOnLayer = exports.SugiyamaNodesOrderer = exports.SugiyamaLayerDistributor = exports.SugiyamaLayoutBuilder = void 0;
var BaseBuilder_1 = __webpack_require__(139);
var Graph_1 = __webpack_require__(54);
var NodeLayout_1 = __webpack_require__(71);
var Structures_1 = __webpack_require__(38);
var ListUtils_1 = __webpack_require__(90);
var search_1 = __webpack_require__(41);
var point_1 = __webpack_require__(0);
var LayoutSettings_1 = __webpack_require__(20);
var GraphLayout_1 = __webpack_require__(138);
var Connector_1 = __webpack_require__(6);
var CycleRemover_1 = __webpack_require__(270);
var SugiyamaLayoutBuilder = (function (_super) {
    __extends(SugiyamaLayoutBuilder, _super);
    function SugiyamaLayoutBuilder() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    SugiyamaLayoutBuilder.prototype.build = function () {
        var _this = this;
        var offset = 0;
        var layout = new GraphLayout_1.GraphLayout();
        var nodeOrderer = new SugiyamaNodesOrderer();
        this.graph.getConnectedComponents()
            .forEach(function (component) {
            var acyclicGraphInfo = CycleRemover_1.CycleRemover.removeCycles(component);
            var layers = SugiyamaLayerDistributor.getLayers(acyclicGraphInfo.graph);
            var orderedGraph = nodeOrderer.orderNodes(acyclicGraphInfo.graph, layers);
            var removedEdges = Object.keys(acyclicGraphInfo.removedEdges).map(function (ek) { return component.getEdge(ek); });
            var coordinatedGraph = nodeOrderer.assignAbsCoordinates(orderedGraph);
            var componentLayout = _this.createInfoGraphLayout(coordinatedGraph, acyclicGraphInfo.reversedEdges, removedEdges);
            layout.extend(_this.setComponentOffset(componentLayout, offset));
            offset += _this.getComponentOffset(componentLayout);
        });
        return layout;
    };
    SugiyamaLayoutBuilder.prototype.createInfoGraphLayout = function (coordinatedGraph, reversedEdges, removedEdges) {
        var _this = this;
        var currentPosition = new point_1.Point(0, 0);
        var items = coordinatedGraph.items;
        var sortedLayers = new ListUtils_1.HashSet(items.map(function (n) { return n.layer; }).sort(function (a, b) { return a - b; }));
        var absOffsetInfo = this.getAbsOffsetInfo(coordinatedGraph.items);
        var positions = {};
        var totalDepth = 0;
        var leftEdge = Number.MAX_SAFE_INTEGER || Number.MAX_VALUE;
        var rightEdge = Number.MIN_SAFE_INTEGER || Number.MAX_VALUE;
        var _loop_1 = function (i) {
            var layer = sortedLayers.item(i);
            var maxDepthLayer = 0;
            items
                .filter(function (n) { return n.layer === layer; })
                .sort(function (a, b) { return a.position - b.position; })
                .forEach(function (n) {
                var depthNodeSize = _this.getDepthNodeSize(n);
                var directionOffset = _this.chooseDirectionValue(0, depthNodeSize);
                var absPosition = _this.getAbsPosition(n.position, _this.getBreadthNodeSize(n), absOffsetInfo);
                currentPosition = _this.setBreadth(currentPosition, absPosition);
                var nodePosition = _this.setDepthOffset(currentPosition, -directionOffset);
                positions[n.key] = nodePosition;
                if (n.isDummy)
                    return;
                var breadth = _this.settings.orientation === LayoutSettings_1.DataLayoutOrientation.Horizontal ? nodePosition.y : nodePosition.x;
                leftEdge = Math.min(leftEdge, breadth);
                rightEdge = Math.max(rightEdge, breadth + _this.getBreadthNodeSize(n));
                maxDepthLayer = Math.max(maxDepthLayer, _this.getDepthNodeSize(n));
            });
            totalDepth += maxDepthLayer;
            currentPosition = this_1.setBreadth(currentPosition, 0);
            currentPosition = this_1.setDepthOffset(currentPosition, this_1.getDirectionValue(maxDepthLayer + this_1.settings.layerSpacing));
        };
        var this_1 = this;
        for (var i = 0; i < sortedLayers.length; i++) {
            _loop_1(i);
        }
        totalDepth += (sortedLayers.length - 1) * this.settings.layerSpacing;
        var layout = new GraphLayout_1.GraphLayout();
        this.createNodesLayout(coordinatedGraph, layout, leftEdge, totalDepth, positions);
        this.createEdgesLayout(coordinatedGraph, layout, reversedEdges, removedEdges);
        return layout;
    };
    SugiyamaLayoutBuilder.prototype.createNodesLayout = function (infoGraph, layout, leftEdge, totalDepth, positions) {
        var _this = this;
        var offset = this.settings.orientation === LayoutSettings_1.DataLayoutOrientation.Vertical ?
            new point_1.Point(-leftEdge, this.chooseDirectionValue(0, totalDepth)) :
            new point_1.Point(this.chooseDirectionValue(0, totalDepth), -leftEdge);
        infoGraph.items.forEach(function (n) {
            if (!n.isDummy) {
                var node = _this.graph.getNode(n.key);
                layout.addNode(new NodeLayout_1.NodeLayout(node, positions[n.key].clone().offset(offset.x, offset.y)));
            }
        });
    };
    SugiyamaLayoutBuilder.prototype.createEdgesLayout = function (infoGraph, layout, reversedEdges, removedEdges) {
        var DIRECT = this.getDirectEdgeLayout();
        var TOP_TO_BOTTOM = this.getDiffLevelEdgeLayout(true);
        var BOTTOM_TO_TOP = this.getDiffLevelEdgeLayout(false);
        var TOP_TO_TOP = this.getSameLevelEdgeLayout(true);
        var BOTTOM_TO_BOTTOM = this.getSameLevelEdgeLayout(false);
        var occupied = {};
        infoGraph.edges
            .filter(function (e) { return !e.isDummy; })
            .concat(removedEdges.map(function (e) { return new EdgeOnLayer(e.key, false, e.from, e.to); }))
            .sort(function (a, b) {
            return (infoGraph.getNode(a.originFrom).layer - infoGraph.getNode(b.originFrom).layer) ||
                (infoGraph.getNode(a.to).layer - infoGraph.getNode(b.to).layer);
        })
            .forEach(function (e) {
            var isReversed = reversedEdges[e.key];
            var from = infoGraph.getNode(isReversed ? e.to : e.originFrom);
            var to = infoGraph.getNode(isReversed ? e.originFrom : e.to);
            if (to.layer - from.layer === 1)
                layout.addEdge(new NodeLayout_1.EdgeLayout(e.key, DIRECT.from, DIRECT.to));
            else {
                var candidates_1 = [];
                if (to.position - from.position >= 1) {
                    candidates_1.push(TOP_TO_BOTTOM);
                    candidates_1.push({ from: DIRECT.from, to: TOP_TO_BOTTOM.to });
                    candidates_1.push({ from: TOP_TO_BOTTOM.from, to: DIRECT.to });
                }
                else if (to.position - from.position <= -1) {
                    candidates_1.push(BOTTOM_TO_TOP);
                    candidates_1.push({ from: DIRECT.from, to: BOTTOM_TO_TOP.to });
                    candidates_1.push({ from: BOTTOM_TO_TOP.from, to: DIRECT.to });
                }
                else {
                    var oneliner = from.position === to.position && to.position === 0 ? [TOP_TO_TOP, BOTTOM_TO_BOTTOM] : [BOTTOM_TO_BOTTOM, TOP_TO_TOP];
                    oneliner.forEach(function (c) { return candidates_1.push(c); });
                    oneliner.forEach(function (c) {
                        candidates_1.push({ from: c.from, to: DIRECT.to });
                        candidates_1.push({ from: DIRECT.from, to: c.to });
                    });
                }
                candidates_1.push(DIRECT);
                for (var i = 0, candidate = void 0; candidate = candidates_1[i]; i++) {
                    var fromKey = from.key + "_" + candidate.from;
                    var toKey = to.key + "_" + candidate.to;
                    if (occupied[fromKey] !== Connector_1.ConnectorPosition.End && occupied[toKey] !== Connector_1.ConnectorPosition.Begin) {
                        layout.addEdge(new NodeLayout_1.EdgeLayout(e.key, candidate.from, candidate.to));
                        occupied[fromKey] = Connector_1.ConnectorPosition.Begin;
                        occupied[toKey] = Connector_1.ConnectorPosition.End;
                        break;
                    }
                }
            }
        });
    };
    SugiyamaLayoutBuilder.prototype.getDirectEdgeLayout = function () {
        if (this.settings.orientation === LayoutSettings_1.DataLayoutOrientation.Horizontal)
            return this.settings.direction === LayoutSettings_1.LogicalDirectionKind.Forward ? { from: 1, to: 3 } : { from: 3, to: 1 };
        return this.settings.direction === LayoutSettings_1.LogicalDirectionKind.Forward ? { from: 2, to: 0 } : { from: 0, to: 2 };
    };
    SugiyamaLayoutBuilder.prototype.getDiffLevelEdgeLayout = function (topToBottom) {
        if (this.settings.orientation === LayoutSettings_1.DataLayoutOrientation.Horizontal)
            return topToBottom ? { from: 2, to: 0 } : { from: 0, to: 2 };
        return topToBottom ? { from: 3, to: 1 } : { from: 1, to: 3 };
    };
    SugiyamaLayoutBuilder.prototype.getSameLevelEdgeLayout = function (topToBottom) {
        if (this.settings.orientation === LayoutSettings_1.DataLayoutOrientation.Horizontal)
            return topToBottom ? { from: 0, to: 0 } : { from: 2, to: 2 };
        return topToBottom ? { from: 3, to: 3 } : { from: 1, to: 1 };
    };
    SugiyamaLayoutBuilder.prototype.getAbsOffsetInfo = function (nodesInfos) {
        var _this = this;
        var absOffsetMatrix = {};
        var addCell = function (n, intAbsCoord) {
            if (absOffsetMatrix[intAbsCoord] === undefined)
                absOffsetMatrix[intAbsCoord] = _this.getBreadthNodeSize(n);
            absOffsetMatrix[intAbsCoord] = Math.max(absOffsetMatrix[intAbsCoord], _this.getBreadthNodeSize(n));
        };
        nodesInfos.forEach(function (n) {
            var intAbsCoord = trunc(n.position);
            addCell(n, intAbsCoord);
            if (absOffsetMatrix[intAbsCoord] % 1 !== 0)
                addCell(n, intAbsCoord + 1);
        });
        var absOffsetInfo = {};
        var leftOffset = 0;
        Object.keys(absOffsetMatrix).sort(function (a, b) { return parseFloat(a) - parseFloat(b); }).forEach(function (coord) {
            absOffsetInfo[coord] = { leftOffset: leftOffset, width: absOffsetMatrix[coord] };
            leftOffset += absOffsetMatrix[coord] + _this.settings.columnSpacing;
        });
        return absOffsetInfo;
    };
    SugiyamaLayoutBuilder.prototype.setBreadth = function (position, breadthPosition) {
        if (this.settings.orientation === LayoutSettings_1.DataLayoutOrientation.Vertical)
            return new point_1.Point(breadthPosition, position.y);
        return new point_1.Point(position.x, breadthPosition);
    };
    SugiyamaLayoutBuilder.prototype.setDepthOffset = function (position, offset) {
        if (this.settings.orientation === LayoutSettings_1.DataLayoutOrientation.Horizontal)
            return new point_1.Point(position.x + offset, position.y);
        return new point_1.Point(position.x, position.y + offset);
    };
    SugiyamaLayoutBuilder.prototype.getAbsPosition = function (absCoordinate, itemSize, absoluteOffsetInfo) {
        var intAbsCoord = trunc(absCoordinate);
        var absLeftOffset = absoluteOffsetInfo[intAbsCoord].leftOffset;
        var cellWidth = absoluteOffsetInfo[intAbsCoord].width;
        if (absCoordinate % 1 === 0)
            return absLeftOffset + (cellWidth - itemSize) / 2;
        return absLeftOffset + cellWidth - (itemSize - this.settings.columnSpacing) / 2;
    };
    SugiyamaLayoutBuilder.prototype.getBreadthNodeSize = function (node) {
        return node.isDummy ? 0 : this.getBreadthNodeSizeCore(this.graph.getNode(node.key));
    };
    SugiyamaLayoutBuilder.prototype.getDepthNodeSize = function (node) {
        return node.isDummy ? 0 : this.getDepthNodeSizeCore(this.graph.getNode(node.key));
    };
    return SugiyamaLayoutBuilder;
}(BaseBuilder_1.LayoutBuilder));
exports.SugiyamaLayoutBuilder = SugiyamaLayoutBuilder;
var SugiyamaLayerDistributor = (function () {
    function SugiyamaLayerDistributor() {
    }
    SugiyamaLayerDistributor.getLayers = function (acyclicGraph) {
        var feasibleTree = this.getFeasibleTree(acyclicGraph);
        return this.calcNodesLayers(feasibleTree);
    };
    SugiyamaLayerDistributor.getFeasibleTree = function (graph) {
        var layers = this.initLayerAssignment(graph);
        return graph.getSpanningGraph(graph.nodes[0], Structures_1.ConnectionMode.OutgoingAndIncoming, function (e) { return layers[e.to] - layers[e.from]; });
    };
    SugiyamaLayerDistributor.initLayerAssignment = function (graph) {
        var layers = {};
        var currentLayer = 0;
        var actualAssignedNodes = {};
        var assigningNodes = graph.nodes.filter(function (n) { return !graph.getAdjacentEdges(n, Structures_1.ConnectionMode.Incoming).length; });
        var _loop_2 = function () {
            assigningNodes.forEach(function (n) {
                layers[n] = currentLayer;
                actualAssignedNodes[n] = true;
            });
            Object.keys(actualAssignedNodes).forEach(function (n) {
                if (graph.getAdjacentEdges(n, Structures_1.ConnectionMode.Outgoing).filter(function (e) { return layers[e.to] === undefined; }).length === 0)
                    delete actualAssignedNodes[n];
            });
            var assigningNodesSet = {};
            Object.keys(actualAssignedNodes).forEach(function (n) {
                graph.getAdjacentEdges(n, Structures_1.ConnectionMode.Outgoing)
                    .map(function (e) { return e.to; })
                    .filter(function (n) { return layers[n] === undefined && graph.getAdjacentEdges(n, Structures_1.ConnectionMode.Incoming).reduce(function (acc, e) { return acc && layers[e.from] !== undefined; }, true); })
                    .forEach(function (n) { return assigningNodesSet[n] = true; });
            });
            assigningNodes = Object.keys(assigningNodesSet);
            currentLayer++;
        };
        while (assigningNodes.length) {
            _loop_2();
        }
        return layers;
    };
    SugiyamaLayerDistributor.calcNodesLayers = function (graph) {
        var layers = {};
        var minLayer = Number.MAX_SAFE_INTEGER || Number.MAX_VALUE;
        var currentLevel = 0;
        var iterator = graph.createIterator(Structures_1.ConnectionMode.OutgoingAndIncoming);
        iterator.visitEachEdgeOnce = false;
        iterator.onNode = function (n) {
            layers[n.key] = currentLevel;
            minLayer = Math.min(minLayer, currentLevel);
        };
        iterator.skipNode = function (n) { return layers[n.key] !== undefined; };
        iterator.skipEdge = function (e) { return layers[e.from] !== undefined && layers[e.to] !== undefined; };
        iterator.onEdge = function (e, out) {
            if (out)
                currentLevel = layers[e.from] + 1;
            else
                currentLevel = layers[e.to] - 1;
        };
        iterator.iterate(graph.nodes[0]);
        for (var key in layers) {
            if (!Object.prototype.hasOwnProperty.call(layers, key))
                continue;
            layers[key] -= minLayer;
        }
        return layers;
    };
    return SugiyamaLayerDistributor;
}());
exports.SugiyamaLayerDistributor = SugiyamaLayerDistributor;
var SugiyamaNodesOrderer = (function () {
    function SugiyamaNodesOrderer() {
        this.idCounter = -10000;
    }
    SugiyamaNodesOrderer.prototype.orderNodes = function (graph, layers) {
        var maxIteration = 14;
        var currentIteration = 1;
        var graphInfo = this.initGraphInfo(graph, layers);
        var nodeInfos = graphInfo.items;
        var orderInfo = this.initOrder(nodeInfos);
        var bestNodesPositions = this.getNodeToPositionMap(nodeInfos);
        var bestCrossCount = this.getCrossCount(orderInfo, graphInfo);
        var isParentToChildren = true;
        while (currentIteration < maxIteration && bestCrossCount !== 0) {
            orderInfo = this.getNodesOrder(orderInfo, graphInfo, isParentToChildren);
            var crossCount = this.getCrossCount(orderInfo, graphInfo);
            if (crossCount < bestCrossCount) {
                bestNodesPositions = this.getNodeToPositionMap(graphInfo.items);
                bestCrossCount = crossCount;
            }
            isParentToChildren = !isParentToChildren;
            currentIteration++;
        }
        graphInfo.items.forEach(function (n) { return n.position = bestNodesPositions[n.key]; });
        return graphInfo;
    };
    SugiyamaNodesOrderer.prototype.getNodesOrder = function (current, graph, isParentToChildren) {
        var _this = this;
        var order = {};
        var _loop_3 = function (layer) {
            if (!Object.prototype.hasOwnProperty.call(current, layer))
                return "continue";
            var nodePositions = {};
            var nodeKeys = [];
            current[layer].forEach(function (ni) {
                var adjacentNodesPositions = (isParentToChildren ? graph.getChildren(ni.key) : graph.getParents(ni.key))
                    .map(function (nk) { return graph.getNode(nk).position; });
                nodeKeys.push(ni.key);
                nodePositions[ni.key] = _this.getNodePosition(adjacentNodesPositions);
            });
            order[layer] = this_2.sortNodes(nodeKeys, nodePositions, graph);
        };
        var this_2 = this;
        for (var layer in current) {
            _loop_3(layer);
        }
        return order;
    };
    SugiyamaNodesOrderer.prototype.sortNodes = function (nodeKeys, nodePositions, graph) {
        return nodeKeys
            .sort(function (a, b) { return nodePositions[a] - nodePositions[b]; })
            .map(function (nk, index) {
            var node = graph.getNode(nk);
            node.position = index;
            return node;
        });
    };
    SugiyamaNodesOrderer.prototype.getNodePosition = function (adjacentNodesPositions) {
        adjacentNodesPositions = adjacentNodesPositions.sort(function (a, b) { return a - b; });
        if (!adjacentNodesPositions.length)
            return 0;
        var medianIndex = Math.floor(adjacentNodesPositions.length / 2);
        if (adjacentNodesPositions.length === 2 || adjacentNodesPositions.length % 2 === 1)
            return adjacentNodesPositions[medianIndex];
        var leftMedianPosition = adjacentNodesPositions[medianIndex - 1] - adjacentNodesPositions[0];
        var rightMedianPosition = adjacentNodesPositions[adjacentNodesPositions.length - 1] - adjacentNodesPositions[medianIndex];
        return Math.floor((adjacentNodesPositions[medianIndex - 1] * rightMedianPosition + adjacentNodesPositions[medianIndex] * leftMedianPosition) /
            (leftMedianPosition + rightMedianPosition));
    };
    SugiyamaNodesOrderer.prototype.initOrder = function (nodeInfos) {
        var result = {};
        nodeInfos.forEach(function (ni) { return (result[ni.layer] || (result[ni.layer] = [])).push(ni); });
        return result;
    };
    SugiyamaNodesOrderer.prototype.getCrossCount = function (orderInfo, graph) {
        var count = 0;
        var _loop_4 = function (layer) {
            if (!Object.prototype.hasOwnProperty.call(orderInfo, layer))
                return "continue";
            var viewedAdjacentNodesPositions = [];
            orderInfo[layer].forEach(function (n) {
                var positions = graph.getChildren(n.key).map(function (c) { return graph.getNode(c).position; });
                positions.forEach(function (p) {
                    count += viewedAdjacentNodesPositions.filter(function (vp) { return p < vp; }).length;
                });
                viewedAdjacentNodesPositions = viewedAdjacentNodesPositions.concat(positions);
            });
        };
        for (var layer in orderInfo) {
            _loop_4(layer);
        }
        return count;
    };
    SugiyamaNodesOrderer.prototype.initGraphInfo = function (graph, layers) {
        var _this = this;
        var countNodesOnLayer = {};
        var nodesInfoMap = {};
        var nodeInfos = [];
        var edgeInfos = [];
        graph.nodes.forEach(function (n) {
            var layer = layers[n];
            if (countNodesOnLayer[layer] === undefined)
                countNodesOnLayer[layer] = 0;
            var info = new NodeOnLayer(n, false, layer, countNodesOnLayer[layer]++);
            nodesInfoMap[n] = info;
            nodeInfos.push(info);
        });
        graph.edges.forEach(function (e) {
            var span = layers[e.to] - layers[e.from];
            if (span > 1) {
                var prevNodeInfo = nodesInfoMap[e.from];
                for (var delta = 1; delta < span; delta++) {
                    var dNodeInfo = new NodeOnLayer(_this.createDummyID(), true, layers[e.from] + delta, countNodesOnLayer[layers[e.from] + delta]++);
                    edgeInfos.push(new EdgeOnLayer(_this.createDummyID(), true, prevNodeInfo.key, dNodeInfo.key));
                    nodeInfos.push(dNodeInfo);
                    prevNodeInfo = dNodeInfo;
                }
                edgeInfos.push(new EdgeOnLayer(e.key, false, prevNodeInfo.key, nodesInfoMap[e.to].key, nodesInfoMap[e.from].key));
            }
            else
                edgeInfos.push(new EdgeOnLayer(e.key, false, nodesInfoMap[e.from].key, nodesInfoMap[e.to].key));
        });
        return new Graph_1.FastGraph(nodeInfos, edgeInfos);
    };
    SugiyamaNodesOrderer.prototype.createDummyID = function () {
        return "dummy_" + --this.idCounter;
    };
    SugiyamaNodesOrderer.prototype.getNodeToPositionMap = function (nodeInfos) {
        return nodeInfos.reduce(function (acc, ni) {
            acc[ni.key] = ni.position;
            return acc;
        }, {});
    };
    SugiyamaNodesOrderer.prototype.assignAbsCoordinates = function (graph) {
        var absCoordinates = this.getAbsCoodinate(graph);
        return new Graph_1.FastGraph(graph.items.map(function (n) { return new NodeOnLayer(n.key, n.isDummy, n.layer, absCoordinates[n.key]); }), graph.edges.slice(0));
    };
    SugiyamaNodesOrderer.prototype.getAbsCoodinate = function (graph) {
        var _this = this;
        var orderInfo = graph.items.reduce(function (acc, n) {
            acc[n.layer] = acc[n.layer] || [];
            var pos = search_1.SearchUtils.binaryIndexOf(acc[n.layer], function (ni) { return ni.position - n.position; });
            acc[n.layer].splice(pos < 0 ? ~pos : pos, 0, n);
            return acc;
        }, {});
        var medianPositions = [MedianAlignmentMode.TopLeft, MedianAlignmentMode.TopRight, MedianAlignmentMode.BottomLeft, MedianAlignmentMode.BottomRight]
            .map(function (alignment) { return _this.getPositionByMedian(graph, alignment, orderInfo); });
        var nodeToPosition = {};
        graph.items.forEach(function (n) {
            var posList = medianPositions.map(function (positions) { return positions[n.key]; }).sort(function (a, b) { return a - b; });
            nodeToPosition[n.key] = (posList[1] + posList[2]) / 2;
        });
        return nodeToPosition;
    };
    SugiyamaNodesOrderer.prototype.getPositionByMedian = function (graph, alignment, orderInfo) {
        var nodeInfos = graph.items;
        var positions = this.getNodeToPositionMap(nodeInfos);
        var medians = this.getMedians(graph, nodeInfos, alignment);
        medians = this.resolveMedianConflicts(graph, orderInfo, medians, alignment);
        this.getSortedBlocks(graph, nodeInfos, medians, alignment)
            .forEach(function (block) {
            var maxPos = block.reduce(function (acc, n) { return positions[n.key] > acc ? positions[n.key] : acc; }, -2);
            block.forEach(function (n) {
                var delta = maxPos - positions[n.key];
                if (delta > 0)
                    orderInfo[n.layer]
                        .filter(function (ln) { return ln.position > n.position; })
                        .forEach(function (ln) { return positions[ln.key] += delta; });
                positions[n.key] = maxPos;
            });
        });
        return positions;
    };
    SugiyamaNodesOrderer.prototype.getSortedBlocks = function (graph, nodeInfos, medians, alignment) {
        var blocks = [];
        var isBottom = alignment === MedianAlignmentMode.BottomLeft || alignment === MedianAlignmentMode.BottomRight;
        var allNodesInfo = new ListUtils_1.HashSet(nodeInfos.slice(0).sort(function (a, b) { return isBottom ? (a.layer - b.layer) : (b.layer - a.layer); }), function (n) { return n.key; });
        while (allNodesInfo.length) {
            var firstNode = allNodesInfo.item(0);
            var block = this.getBlock(graph, firstNode, medians, alignment);
            blocks.push(block);
            block.forEach(function (n) { return allNodesInfo.remove(n); });
        }
        blocks.sort(function (x, y) {
            var xMinNodeInfo = x.reduce(function (min, n) { return n.position < min.position ? n : min; }, x[0]);
            var yOnMinXLayer = y.filter(function (n) { return n.layer === xMinNodeInfo.layer; })[0];
            if (yOnMinXLayer)
                return xMinNodeInfo.position > yOnMinXLayer.position ? 1 : -1;
            var yMinNodeInfo = y.reduce(function (min, n) { return n.position < min.position ? n : min; }, y[0]);
            var xOnMinYLayer = x.filter(function (n) { return n.layer === yMinNodeInfo.layer; })[0];
            if (xOnMinYLayer)
                return xOnMinYLayer.position > yMinNodeInfo.position ? 1 : -1;
            return xMinNodeInfo.layer > yMinNodeInfo.layer ? 1 : -1;
        });
        return blocks;
    };
    SugiyamaNodesOrderer.prototype.getBlock = function (graph, root, medians, alignment) {
        var block = [];
        var median = null;
        do {
            if (median)
                root = alignment === MedianAlignmentMode.TopLeft || alignment === MedianAlignmentMode.TopRight ? graph.getNode(median.from) : graph.getNode(median.to);
            block.push(root);
            median = medians[root.key];
        } while (median);
        return block;
    };
    SugiyamaNodesOrderer.prototype.resolveMedianConflicts = function (graph, layers, medians, alignment) {
        var _this = this;
        var filteredMedians = {};
        var _loop_5 = function (layer) {
            if (!Object.prototype.hasOwnProperty.call(layers, layer))
                return "continue";
            var minPos;
            var maxPos;
            var nodeInfos = layers[layer];
            if (alignment === MedianAlignmentMode.TopRight || alignment === MedianAlignmentMode.BottomRight)
                nodeInfos = nodeInfos.slice(0).sort(function (a, b) { return b.position - a.position; });
            nodeInfos.forEach(function (n) {
                var median = medians[n.key];
                if (!median)
                    filteredMedians[n.key] = null;
                else {
                    var medianItemKey = alignment === MedianAlignmentMode.TopLeft || alignment === MedianAlignmentMode.TopRight ? median.from : median.to;
                    var medianPosition = graph.getNode(medianItemKey).position;
                    if (_this.checkMedianConfict(minPos, maxPos, medianPosition, alignment))
                        filteredMedians[n.key] = null;
                    else {
                        minPos = minPos === undefined ? medianPosition : Math.min(minPos, medianPosition);
                        maxPos = maxPos === undefined ? medianPosition : Math.max(maxPos, medianPosition);
                        filteredMedians[n.key] = median;
                    }
                }
            });
        };
        for (var layer in layers) {
            _loop_5(layer);
        }
        return filteredMedians;
    };
    SugiyamaNodesOrderer.prototype.checkMedianConfict = function (min, max, medianPosition, alignment) {
        if (min === undefined || max === undefined)
            return false;
        if (alignment === MedianAlignmentMode.TopLeft || alignment === MedianAlignmentMode.BottomLeft)
            return max >= medianPosition;
        return min <= medianPosition;
    };
    SugiyamaNodesOrderer.prototype.getMedians = function (graph, nodeInfos, alignment) {
        var _this = this;
        var medians = {};
        nodeInfos.forEach(function (n) {
            var actualAdjacentEdges = _this.getActualAdjacentEdges(graph, n, alignment);
            var medianPosition = _this.getMedianPosition(actualAdjacentEdges.length, alignment);
            medians[n.key] = actualAdjacentEdges[medianPosition];
        });
        return medians;
    };
    SugiyamaNodesOrderer.prototype.getMedianPosition = function (length, alignment) {
        if (length === 0)
            return -1;
        if (length % 2 !== 0)
            return Math.floor(length / 2);
        if (alignment === MedianAlignmentMode.TopLeft || alignment === MedianAlignmentMode.BottomLeft)
            return Math.floor(length / 2) - 1;
        if (alignment === MedianAlignmentMode.TopRight || alignment === MedianAlignmentMode.BottomRight)
            return Math.floor(length / 2);
        throw new Error("Invalid Operation");
    };
    SugiyamaNodesOrderer.prototype.getActualAdjacentEdges = function (graph, node, alignment) {
        if (alignment === MedianAlignmentMode.TopLeft || alignment === MedianAlignmentMode.TopRight)
            return graph.getAdjacentEdges(node.key, Structures_1.ConnectionMode.Incoming).sort(function (a, b) { return graph.getNode(a.from).position - graph.getNode(b.from).position; });
        return graph.getAdjacentEdges(node.key, Structures_1.ConnectionMode.Outgoing).sort(function (a, b) { return graph.getNode(a.to).position - graph.getNode(b.to).position; });
    };
    return SugiyamaNodesOrderer;
}());
exports.SugiyamaNodesOrderer = SugiyamaNodesOrderer;
var NodeOnLayer = (function () {
    function NodeOnLayer(key, isDummy, layer, position) {
        this.key = key;
        this.isDummy = isDummy;
        this.layer = layer;
        this.position = position;
    }
    NodeOnLayer.prototype.getHashCode = function () {
        return this.key.toString();
    };
    return NodeOnLayer;
}());
exports.NodeOnLayer = NodeOnLayer;
var EdgeOnLayer = (function () {
    function EdgeOnLayer(key, isDummy, from, to, originFrom) {
        this.key = key;
        this.isDummy = isDummy;
        this.from = from;
        this.to = to;
        this._originFrom = originFrom;
    }
    EdgeOnLayer.prototype.getHashCode = function () {
        return this.from + "-" + this.to;
    };
    Object.defineProperty(EdgeOnLayer.prototype, "originFrom", {
        get: function () {
            return this._originFrom !== undefined ? this._originFrom : this.from;
        },
        enumerable: false,
        configurable: true
    });
    return EdgeOnLayer;
}());
exports.EdgeOnLayer = EdgeOnLayer;
var MedianAlignmentMode;
(function (MedianAlignmentMode) {
    MedianAlignmentMode[MedianAlignmentMode["TopLeft"] = 0] = "TopLeft";
    MedianAlignmentMode[MedianAlignmentMode["TopRight"] = 1] = "TopRight";
    MedianAlignmentMode[MedianAlignmentMode["BottomLeft"] = 2] = "BottomLeft";
    MedianAlignmentMode[MedianAlignmentMode["BottomRight"] = 3] = "BottomRight";
})(MedianAlignmentMode || (MedianAlignmentMode = {}));
function trunc(val) {
    if (Math.trunc)
        return Math.trunc(val);
    if (!isFinite(val))
        return val;
    return (val - val % 1) || (val < 0 ? -0 : val === 0 ? val : 0);
}


/***/ }),
/* 81 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

Object.defineProperty(exports, "__esModule", { value: true });
var BatchUpdatableObject = (function () {
    function BatchUpdatableObject() {
        this.suspendUpdateCount = 0;
        this.occurredEvents = 0;
    }
    BatchUpdatableObject.prototype.beginUpdate = function () {
        if (this.suspendUpdateCount === 0)
            this.onUpdateLocked();
        if (this.suspendUpdateCount < 0)
            this.suspendUpdateCount--;
        else
            this.suspendUpdateCount++;
    };
    BatchUpdatableObject.prototype.endUpdate = function () {
        if (this.suspendUpdateCount < 0)
            this.suspendUpdateCount++;
        else if (this.suspendUpdateCount > 0)
            this.suspendUpdateCount--;
        if (!this.isUpdateLocked()) {
            var occurredEvents = this.occurredEvents;
            this.occurredEvents = 0;
            this.onUpdateUnlocked(occurredEvents);
        }
    };
    BatchUpdatableObject.prototype.suspendUpdate = function () {
        if (this.suspendUpdateCount > 0) {
            this.suspendUpdateCount *= -1;
            var occurredEvents = this.occurredEvents;
            this.occurredEvents = 0;
            this.onUpdateUnlocked(occurredEvents);
        }
    };
    BatchUpdatableObject.prototype.continueUpdate = function () {
        if (this.suspendUpdateCount < 0)
            this.suspendUpdateCount *= -1;
    };
    BatchUpdatableObject.prototype.isUpdateLocked = function () {
        return this.suspendUpdateCount > 0;
    };
    BatchUpdatableObject.prototype.onUpdateLocked = function () { };
    BatchUpdatableObject.prototype.registerOccurredEvent = function (eventMask) {
        this.occurredEvents |= eventMask;
    };
    BatchUpdatableObject.prototype.resetOccurredEvents = function () {
        this.occurredEvents = 0;
    };
    BatchUpdatableObject.prototype.isLocked = function () {
        return this.suspendUpdateCount !== 0;
    };
    return BatchUpdatableObject;
}());
exports.BatchUpdatableObject = BatchUpdatableObject;
var EmptyBatchUpdatableObject = (function () {
    function EmptyBatchUpdatableObject() {
    }
    EmptyBatchUpdatableObject.prototype.beginUpdate = function () { };
    EmptyBatchUpdatableObject.prototype.endUpdate = function () { };
    return EmptyBatchUpdatableObject;
}());
exports.EmptyBatchUpdatableObject = EmptyBatchUpdatableObject;


/***/ }),
/* 82 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.CommandManager = exports.DiagramCommand = void 0;
var DeleteCommand_1 = __webpack_require__(162);
var UndoCommand_1 = __webpack_require__(199);
var RedoCommand_1 = __webpack_require__(200);
var ImportCommand_1 = __webpack_require__(201);
var ExportCommand_1 = __webpack_require__(238);
var ToggleFontBoldCommand_1 = __webpack_require__(239);
var ToggleFontItalicCommand_1 = __webpack_require__(240);
var ToggleFontUnderlineCommand_1 = __webpack_require__(241);
var ChangeFontNameCommand_1 = __webpack_require__(242);
var ChangeFontSizeCommand_1 = __webpack_require__(243);
var ChangeFontColorCommand_1 = __webpack_require__(244);
var ChangeFillColorCommand_1 = __webpack_require__(245);
var ChangeStrokeColorCommand_1 = __webpack_require__(246);
var ChangeTextAlignCommand_1 = __webpack_require__(247);
var ChangeConnectorLineEndingCommand_1 = __webpack_require__(248);
var ChangeConnectorLineOptionCommand_1 = __webpack_require__(249);
var SelectAllCommand_1 = __webpack_require__(250);
var key_1 = __webpack_require__(25);
var AutoLayoutTreeVerticalCommand_1 = __webpack_require__(137);
var ChangeSnapToGridCommand_1 = __webpack_require__(253);
var ChangeGridSizeCommand_1 = __webpack_require__(254);
var ChangePageLandscapeCommand_1 = __webpack_require__(255);
var ChangePageSizeCommand_1 = __webpack_require__(257);
var ExportPngCommand_1 = __webpack_require__(259);
var ExportSvgCommand_1 = __webpack_require__(261);
var ExportJpgCommand_1 = __webpack_require__(262);
var CopySelectionCommand_1 = __webpack_require__(263);
var CutSelectionCommand_1 = __webpack_require__(264);
var PasteSelectionCommand_1 = __webpack_require__(265);
var ImportBPMNCommand_1 = __webpack_require__(268);
var SendToBackCommand_1 = __webpack_require__(271);
var BringToFrontCommand_1 = __webpack_require__(272);
var AutoLayoutLayeredHorizontalCommand_1 = __webpack_require__(142);
var MoveCommands_1 = __webpack_require__(273);
var ChangeZoomLevelCommand_1 = __webpack_require__(274);
var BindDocumentCommand_1 = __webpack_require__(275);
var UnbindDocumentCommand_1 = __webpack_require__(276);
var AutoLayoutTreeHorizontalCommand_1 = __webpack_require__(143);
var AutoLayoutLayeredVerticalCommand_1 = __webpack_require__(144);
var LockCommand_1 = __webpack_require__(277);
var UnlockCommand_1 = __webpack_require__(278);
var CloneCommand_1 = __webpack_require__(279);
var ChangeUnitsCommand_1 = __webpack_require__(280);
var ChangePageColorCommand_1 = __webpack_require__(282);
var ChangeShowGridCommand_1 = __webpack_require__(284);
var ToggleFullscreenCommand_1 = __webpack_require__(285);
var ToggleSimpleViewCommand_1 = __webpack_require__(286);
var ToggleReadOnlyCommand_1 = __webpack_require__(287);
var EditShapeImageCommand_1 = __webpack_require__(288);
var PasteSelectionInPosition_1 = __webpack_require__(289);
var ImportXMLCommand_1 = __webpack_require__(290);
var InsertShapeImageCommand_1 = __webpack_require__(292);
var DeleteShapeImageCommand_1 = __webpack_require__(293);
var ChangeStrokeStyleCommand_1 = __webpack_require__(294);
var ChangeStrokeWidthCommand_1 = __webpack_require__(295);
var AutoLayoutTreeVerticalBottomToTopCommand_1 = __webpack_require__(296);
var AutoLayoutTreeHorizontalRightToLeftCommand_1 = __webpack_require__(297);
var AutoLayoutLayeredVerticalBottomToTopCommand_1 = __webpack_require__(298);
var AutoLayoutLayeredHorizontalRightToLeftCommand_1 = __webpack_require__(299);
var ChangeConnectorRoutingModeCommand_1 = __webpack_require__(300);
var DiagramCommand;
(function (DiagramCommand) {
    DiagramCommand[DiagramCommand["Undo"] = 0] = "Undo";
    DiagramCommand[DiagramCommand["Redo"] = 1] = "Redo";
    DiagramCommand[DiagramCommand["Cut"] = 2] = "Cut";
    DiagramCommand[DiagramCommand["Copy"] = 3] = "Copy";
    DiagramCommand[DiagramCommand["Paste"] = 4] = "Paste";
    DiagramCommand[DiagramCommand["PasteInPosition"] = 5] = "PasteInPosition";
    DiagramCommand[DiagramCommand["SelectAll"] = 6] = "SelectAll";
    DiagramCommand[DiagramCommand["Delete"] = 7] = "Delete";
    DiagramCommand[DiagramCommand["Import"] = 8] = "Import";
    DiagramCommand[DiagramCommand["ImportBPMN"] = 9] = "ImportBPMN";
    DiagramCommand[DiagramCommand["Export"] = 10] = "Export";
    DiagramCommand[DiagramCommand["ExportSvg"] = 11] = "ExportSvg";
    DiagramCommand[DiagramCommand["ExportPng"] = 12] = "ExportPng";
    DiagramCommand[DiagramCommand["ExportJpg"] = 13] = "ExportJpg";
    DiagramCommand[DiagramCommand["BindDocument"] = 14] = "BindDocument";
    DiagramCommand[DiagramCommand["UnbindDocument"] = 15] = "UnbindDocument";
    DiagramCommand[DiagramCommand["Bold"] = 16] = "Bold";
    DiagramCommand[DiagramCommand["Italic"] = 17] = "Italic";
    DiagramCommand[DiagramCommand["Underline"] = 18] = "Underline";
    DiagramCommand[DiagramCommand["FontName"] = 19] = "FontName";
    DiagramCommand[DiagramCommand["FontSize"] = 20] = "FontSize";
    DiagramCommand[DiagramCommand["FontColor"] = 21] = "FontColor";
    DiagramCommand[DiagramCommand["FillColor"] = 22] = "FillColor";
    DiagramCommand[DiagramCommand["StrokeColor"] = 23] = "StrokeColor";
    DiagramCommand[DiagramCommand["TextLeftAlign"] = 24] = "TextLeftAlign";
    DiagramCommand[DiagramCommand["TextCenterAlign"] = 25] = "TextCenterAlign";
    DiagramCommand[DiagramCommand["TextRightAlign"] = 26] = "TextRightAlign";
    DiagramCommand[DiagramCommand["ConnectorLineOption"] = 27] = "ConnectorLineOption";
    DiagramCommand[DiagramCommand["ConnectorStartLineEnding"] = 28] = "ConnectorStartLineEnding";
    DiagramCommand[DiagramCommand["ConnectorEndLineEnding"] = 29] = "ConnectorEndLineEnding";
    DiagramCommand[DiagramCommand["BringToFront"] = 30] = "BringToFront";
    DiagramCommand[DiagramCommand["SendToBack"] = 31] = "SendToBack";
    DiagramCommand[DiagramCommand["MoveLeft"] = 32] = "MoveLeft";
    DiagramCommand[DiagramCommand["MoveStepLeft"] = 33] = "MoveStepLeft";
    DiagramCommand[DiagramCommand["MoveRight"] = 34] = "MoveRight";
    DiagramCommand[DiagramCommand["MoveStepRight"] = 35] = "MoveStepRight";
    DiagramCommand[DiagramCommand["MoveUp"] = 36] = "MoveUp";
    DiagramCommand[DiagramCommand["MoveStepUp"] = 37] = "MoveStepUp";
    DiagramCommand[DiagramCommand["MoveDown"] = 38] = "MoveDown";
    DiagramCommand[DiagramCommand["MoveStepDown"] = 39] = "MoveStepDown";
    DiagramCommand[DiagramCommand["CloneLeft"] = 40] = "CloneLeft";
    DiagramCommand[DiagramCommand["CloneRight"] = 41] = "CloneRight";
    DiagramCommand[DiagramCommand["CloneUp"] = 42] = "CloneUp";
    DiagramCommand[DiagramCommand["CloneDown"] = 43] = "CloneDown";
    DiagramCommand[DiagramCommand["AutoLayoutTree"] = 44] = "AutoLayoutTree";
    DiagramCommand[DiagramCommand["AutoLayoutFlow"] = 45] = "AutoLayoutFlow";
    DiagramCommand[DiagramCommand["AutoLayoutTreeVertical"] = 46] = "AutoLayoutTreeVertical";
    DiagramCommand[DiagramCommand["AutoLayoutTreeHorizontal"] = 47] = "AutoLayoutTreeHorizontal";
    DiagramCommand[DiagramCommand["AutoLayoutLayeredVertical"] = 48] = "AutoLayoutLayeredVertical";
    DiagramCommand[DiagramCommand["AutoLayoutLayeredHorizontal"] = 49] = "AutoLayoutLayeredHorizontal";
    DiagramCommand[DiagramCommand["Lock"] = 50] = "Lock";
    DiagramCommand[DiagramCommand["Unlock"] = 51] = "Unlock";
    DiagramCommand[DiagramCommand["Units"] = 52] = "Units";
    DiagramCommand[DiagramCommand["ViewUnits"] = 53] = "ViewUnits";
    DiagramCommand[DiagramCommand["PageSize"] = 54] = "PageSize";
    DiagramCommand[DiagramCommand["PageLandscape"] = 55] = "PageLandscape";
    DiagramCommand[DiagramCommand["PageColor"] = 56] = "PageColor";
    DiagramCommand[DiagramCommand["GridSize"] = 57] = "GridSize";
    DiagramCommand[DiagramCommand["ShowGrid"] = 58] = "ShowGrid";
    DiagramCommand[DiagramCommand["SnapToGrid"] = 59] = "SnapToGrid";
    DiagramCommand[DiagramCommand["ZoomLevel"] = 60] = "ZoomLevel";
    DiagramCommand[DiagramCommand["Fullscreen"] = 61] = "Fullscreen";
    DiagramCommand[DiagramCommand["ToggleSimpleView"] = 62] = "ToggleSimpleView";
    DiagramCommand[DiagramCommand["ToggleReadOnly"] = 63] = "ToggleReadOnly";
    DiagramCommand[DiagramCommand["EditShapeImage"] = 64] = "EditShapeImage";
    DiagramCommand[DiagramCommand["FitToScreen"] = 65] = "FitToScreen";
    DiagramCommand[DiagramCommand["SwitchAutoZoom"] = 66] = "SwitchAutoZoom";
    DiagramCommand[DiagramCommand["ToggleAutoZoom"] = 67] = "ToggleAutoZoom";
    DiagramCommand[DiagramCommand["FitToWidth"] = 68] = "FitToWidth";
    DiagramCommand[DiagramCommand["ZoomLevelItems"] = 69] = "ZoomLevelItems";
    DiagramCommand[DiagramCommand["GridSizeItems"] = 70] = "GridSizeItems";
    DiagramCommand[DiagramCommand["PageSizeItems"] = 71] = "PageSizeItems";
    DiagramCommand[DiagramCommand["ImportXML"] = 72] = "ImportXML";
    DiagramCommand[DiagramCommand["InsertShapeImage"] = 73] = "InsertShapeImage";
    DiagramCommand[DiagramCommand["DeleteShapeImage"] = 74] = "DeleteShapeImage";
    DiagramCommand[DiagramCommand["StrokeStyle"] = 75] = "StrokeStyle";
    DiagramCommand[DiagramCommand["StrokeWidth"] = 76] = "StrokeWidth";
    DiagramCommand[DiagramCommand["AutoLayoutTreeVerticalBottomToTop"] = 77] = "AutoLayoutTreeVerticalBottomToTop";
    DiagramCommand[DiagramCommand["AutoLayoutTreeHorizontalRightToLeft"] = 78] = "AutoLayoutTreeHorizontalRightToLeft";
    DiagramCommand[DiagramCommand["AutoLayoutLayeredVerticalBottomToTop"] = 79] = "AutoLayoutLayeredVerticalBottomToTop";
    DiagramCommand[DiagramCommand["AutoLayoutLayeredHorizontalRightToLeft"] = 80] = "AutoLayoutLayeredHorizontalRightToLeft";
    DiagramCommand[DiagramCommand["Zoom25"] = 81] = "Zoom25";
    DiagramCommand[DiagramCommand["Zoom50"] = 82] = "Zoom50";
    DiagramCommand[DiagramCommand["Zoom75"] = 83] = "Zoom75";
    DiagramCommand[DiagramCommand["Zoom100"] = 84] = "Zoom100";
    DiagramCommand[DiagramCommand["Zoom125"] = 85] = "Zoom125";
    DiagramCommand[DiagramCommand["Zoom150"] = 86] = "Zoom150";
    DiagramCommand[DiagramCommand["Zoom200"] = 87] = "Zoom200";
    DiagramCommand[DiagramCommand["AutoZoomToContent"] = 88] = "AutoZoomToContent";
    DiagramCommand[DiagramCommand["AutoZoomToWidth"] = 89] = "AutoZoomToWidth";
    DiagramCommand[DiagramCommand["ZoomLevelInPercentage"] = 90] = "ZoomLevelInPercentage";
    DiagramCommand[DiagramCommand["ConnectorRoutingMode"] = 91] = "ConnectorRoutingMode";
})(DiagramCommand = exports.DiagramCommand || (exports.DiagramCommand = {}));
var CommandManager = (function () {
    function CommandManager(control) {
        this.commands = {};
        this.shortcutsToCommand = {};
        this.lastCommandsChain = [];
        this.executingCommandsChain = [];
        this.executingCommandCounter = 0;
        this.isPublicApiCall = false;
        this.createCommand(control, DiagramCommand.Undo, UndoCommand_1.UndoCommand, key_1.ModifierKey.Ctrl | key_1.KeyCode.Key_z, key_1.ModifierKey.Meta | key_1.KeyCode.Key_z);
        this.createCommand(control, DiagramCommand.Redo, RedoCommand_1.RedoCommand, key_1.ModifierKey.Ctrl | key_1.KeyCode.Key_y, key_1.ModifierKey.Ctrl | key_1.ModifierKey.Shift | key_1.KeyCode.Key_z, key_1.ModifierKey.Meta | key_1.ModifierKey.Shift | key_1.KeyCode.Key_z);
        this.createCommand(control, DiagramCommand.Cut, CutSelectionCommand_1.CutSelectionCommand, key_1.KeyCode.Key_x | key_1.ModifierKey.Ctrl, key_1.KeyCode.Key_x | key_1.ModifierKey.Meta, key_1.KeyCode.Delete | key_1.ModifierKey.Shift);
        this.createCommand(control, DiagramCommand.Copy, CopySelectionCommand_1.CopySelectionCommand, key_1.KeyCode.Key_c | key_1.ModifierKey.Ctrl, key_1.KeyCode.Key_c | key_1.ModifierKey.Meta, key_1.KeyCode.Insert | key_1.ModifierKey.Ctrl);
        this.createCommand(control, DiagramCommand.Paste, PasteSelectionCommand_1.PasteSelectionCommand);
        this.createCommand(control, DiagramCommand.PasteInPosition, PasteSelectionInPosition_1.PasteSelectionInPositionCommand);
        this.createCommand(control, DiagramCommand.SelectAll, SelectAllCommand_1.SelectAllCommand, key_1.KeyCode.Key_a | key_1.ModifierKey.Ctrl, key_1.KeyCode.Key_a | key_1.ModifierKey.Meta);
        this.createCommand(control, DiagramCommand.Delete, DeleteCommand_1.DeleteCommand, key_1.KeyCode.Delete, key_1.KeyCode.Backspace);
        this.createCommand(control, DiagramCommand.Import, ImportCommand_1.ImportCommand);
        this.createCommand(control, DiagramCommand.ImportBPMN, ImportBPMNCommand_1.ImportBPMNCommand);
        this.createCommand(control, DiagramCommand.ImportXML, ImportXMLCommand_1.ImportXMLCommand);
        this.createCommand(control, DiagramCommand.Export, ExportCommand_1.ExportCommand);
        this.createCommand(control, DiagramCommand.ExportSvg, ExportSvgCommand_1.ExportSvgCommand);
        this.createCommand(control, DiagramCommand.ExportPng, ExportPngCommand_1.ExportPngCommand);
        this.createCommand(control, DiagramCommand.ExportJpg, ExportJpgCommand_1.ExportJpgCommand);
        this.createCommand(control, DiagramCommand.BindDocument, BindDocumentCommand_1.BindDocumentCommand);
        this.createCommand(control, DiagramCommand.UnbindDocument, UnbindDocumentCommand_1.UnbindDocumentCommand);
        this.createCommand(control, DiagramCommand.Bold, ToggleFontBoldCommand_1.ToggleFontBoldCommand, key_1.ModifierKey.Ctrl | key_1.KeyCode.Key_b, key_1.ModifierKey.Meta | key_1.KeyCode.Key_b);
        this.createCommand(control, DiagramCommand.Italic, ToggleFontItalicCommand_1.ToggleFontItalicCommand, key_1.ModifierKey.Ctrl | key_1.KeyCode.Key_i, key_1.ModifierKey.Meta | key_1.KeyCode.Key_i);
        this.createCommand(control, DiagramCommand.Underline, ToggleFontUnderlineCommand_1.ToggleFontUnderlineCommand, key_1.ModifierKey.Ctrl | key_1.KeyCode.Key_u, key_1.ModifierKey.Meta | key_1.KeyCode.Key_u);
        this.createCommand(control, DiagramCommand.FontName, ChangeFontNameCommand_1.ChangeFontNameCommand);
        this.createCommand(control, DiagramCommand.FontSize, ChangeFontSizeCommand_1.ChangeFontSizeCommand);
        this.createCommand(control, DiagramCommand.FontColor, ChangeFontColorCommand_1.ChangeFontColorCommand);
        this.createCommand(control, DiagramCommand.FillColor, ChangeFillColorCommand_1.ChangeFillColorCommand);
        this.createCommand(control, DiagramCommand.StrokeColor, ChangeStrokeColorCommand_1.ChangeStrokeColorCommand);
        this.createCommand(control, DiagramCommand.StrokeStyle, ChangeStrokeStyleCommand_1.ChangeStrokeStyleCommand);
        this.createCommand(control, DiagramCommand.StrokeWidth, ChangeStrokeWidthCommand_1.ChangeStrokeWidthCommand);
        this.createCommand(control, DiagramCommand.TextLeftAlign, ChangeTextAlignCommand_1.TextLeftAlignCommand);
        this.createCommand(control, DiagramCommand.TextCenterAlign, ChangeTextAlignCommand_1.TextCenterAlignCommand);
        this.createCommand(control, DiagramCommand.TextRightAlign, ChangeTextAlignCommand_1.TextRightAlignCommand);
        this.createCommand(control, DiagramCommand.ConnectorLineOption, ChangeConnectorLineOptionCommand_1.ChangeConnectorLineOptionCommand);
        this.createCommand(control, DiagramCommand.ConnectorStartLineEnding, ChangeConnectorLineEndingCommand_1.ChangeConnectorStartLineEndingCommand);
        this.createCommand(control, DiagramCommand.ConnectorEndLineEnding, ChangeConnectorLineEndingCommand_1.ChangeConnectorEndLineEndingCommand);
        this.createCommand(control, DiagramCommand.BringToFront, BringToFrontCommand_1.BringToFrontCommand);
        this.createCommand(control, DiagramCommand.SendToBack, SendToBackCommand_1.SendToBackCommand);
        this.createCommand(control, DiagramCommand.MoveLeft, MoveCommands_1.MoveLeftCommand, key_1.ModifierKey.Ctrl | key_1.KeyCode.Left, key_1.ModifierKey.Ctrl | key_1.ModifierKey.Shift | key_1.KeyCode.Left);
        this.createCommand(control, DiagramCommand.MoveRight, MoveCommands_1.MoveRightCommand, key_1.ModifierKey.Ctrl | key_1.KeyCode.Right, key_1.ModifierKey.Ctrl | key_1.ModifierKey.Shift | key_1.KeyCode.Right);
        this.createCommand(control, DiagramCommand.MoveUp, MoveCommands_1.MoveUpCommand, key_1.ModifierKey.Ctrl | key_1.KeyCode.Up, key_1.ModifierKey.Ctrl | key_1.ModifierKey.Shift | key_1.KeyCode.Up);
        this.createCommand(control, DiagramCommand.MoveDown, MoveCommands_1.MoveDownCommand, key_1.ModifierKey.Ctrl | key_1.KeyCode.Down, key_1.ModifierKey.Ctrl | key_1.ModifierKey.Shift | key_1.KeyCode.Down);
        this.createCommand(control, DiagramCommand.MoveStepLeft, MoveCommands_1.MoveStepLeftCommand, key_1.KeyCode.Left, key_1.ModifierKey.Shift | key_1.KeyCode.Left);
        this.createCommand(control, DiagramCommand.MoveStepRight, MoveCommands_1.MoveStepRightCommand, key_1.KeyCode.Right, key_1.ModifierKey.Shift | key_1.KeyCode.Right);
        this.createCommand(control, DiagramCommand.MoveStepUp, MoveCommands_1.MoveStepUpCommand, key_1.KeyCode.Up, key_1.ModifierKey.Shift | key_1.KeyCode.Up);
        this.createCommand(control, DiagramCommand.MoveStepDown, MoveCommands_1.MoveStepDownCommand, key_1.KeyCode.Down, key_1.ModifierKey.Shift | key_1.KeyCode.Down);
        this.createCommand(control, DiagramCommand.CloneLeft, CloneCommand_1.CloneLeftCommand, key_1.ModifierKey.Alt | key_1.KeyCode.Left, key_1.ModifierKey.Alt | key_1.ModifierKey.Shift | key_1.KeyCode.Left);
        this.createCommand(control, DiagramCommand.CloneRight, CloneCommand_1.CloneRightCommand, key_1.ModifierKey.Alt | key_1.KeyCode.Right, key_1.ModifierKey.Alt | key_1.ModifierKey.Shift | key_1.KeyCode.Right);
        this.createCommand(control, DiagramCommand.CloneUp, CloneCommand_1.CloneUpCommand, key_1.ModifierKey.Alt | key_1.KeyCode.Up, key_1.ModifierKey.Alt | key_1.ModifierKey.Shift | key_1.KeyCode.Up);
        this.createCommand(control, DiagramCommand.CloneDown, CloneCommand_1.CloneDownCommand, key_1.ModifierKey.Alt | key_1.KeyCode.Down, key_1.ModifierKey.Alt | key_1.ModifierKey.Shift | key_1.KeyCode.Down);
        this.createCommand(control, DiagramCommand.Lock, LockCommand_1.LockCommand);
        this.createCommand(control, DiagramCommand.Unlock, UnlockCommand_1.UnLockCommand);
        this.createCommand(control, DiagramCommand.AutoLayoutTree, AutoLayoutTreeVerticalCommand_1.AutoLayoutTreeVerticalCommand);
        this.createCommand(control, DiagramCommand.AutoLayoutFlow, AutoLayoutLayeredHorizontalCommand_1.AutoLayoutLayeredHorizontalCommand);
        this.createCommand(control, DiagramCommand.Units, ChangeUnitsCommand_1.ChangeUnitsCommand);
        this.createCommand(control, DiagramCommand.ViewUnits, ChangeUnitsCommand_1.ChangeViewUnitsCommand);
        this.createCommand(control, DiagramCommand.PageSize, ChangePageSizeCommand_1.ChangePageSizeCommand);
        this.createCommand(control, DiagramCommand.PageLandscape, ChangePageLandscapeCommand_1.ChangePageLandscapeCommand);
        this.createCommand(control, DiagramCommand.PageColor, ChangePageColorCommand_1.ChangePageColorCommand);
        this.createCommand(control, DiagramCommand.GridSize, ChangeGridSizeCommand_1.ChangeGridSizeCommand);
        this.createCommand(control, DiagramCommand.ShowGrid, ChangeShowGridCommand_1.ChangeShowGridCommand);
        this.createCommand(control, DiagramCommand.SnapToGrid, ChangeSnapToGridCommand_1.ChangeSnapToGridCommand);
        this.createCommand(control, DiagramCommand.ZoomLevel, ChangeZoomLevelCommand_1.ChangeZoomLevelCommand);
        this.createCommand(control, DiagramCommand.ZoomLevelInPercentage, ChangeZoomLevelCommand_1.ChangeZoomLevelInPercentageCommand);
        this.createCommand(control, DiagramCommand.AutoLayoutTreeVertical, AutoLayoutTreeVerticalCommand_1.AutoLayoutTreeVerticalCommand);
        this.createCommand(control, DiagramCommand.AutoLayoutTreeVerticalBottomToTop, AutoLayoutTreeVerticalBottomToTopCommand_1.AutoLayoutTreeVerticalBottomToTopCommand);
        this.createCommand(control, DiagramCommand.AutoLayoutTreeHorizontal, AutoLayoutTreeHorizontalCommand_1.AutoLayoutTreeHorizontalCommand);
        this.createCommand(control, DiagramCommand.AutoLayoutTreeHorizontalRightToLeft, AutoLayoutTreeHorizontalRightToLeftCommand_1.AutoLayoutTreeHorizontalRightToLeftCommand);
        this.createCommand(control, DiagramCommand.AutoLayoutLayeredVertical, AutoLayoutLayeredVerticalCommand_1.AutoLayoutLayeredVerticalCommand);
        this.createCommand(control, DiagramCommand.AutoLayoutLayeredVerticalBottomToTop, AutoLayoutLayeredVerticalBottomToTopCommand_1.AutoLayoutLayeredVerticalBottomToTopCommand);
        this.createCommand(control, DiagramCommand.AutoLayoutLayeredHorizontal, AutoLayoutLayeredHorizontalCommand_1.AutoLayoutLayeredHorizontalCommand);
        this.createCommand(control, DiagramCommand.AutoLayoutLayeredHorizontalRightToLeft, AutoLayoutLayeredHorizontalRightToLeftCommand_1.AutoLayoutLayeredHorizontalRightToLeftCommand);
        this.createCommand(control, DiagramCommand.Fullscreen, ToggleFullscreenCommand_1.ToggleFullscreenCommand, key_1.KeyCode.F11);
        this.createCommand(control, DiagramCommand.ToggleSimpleView, ToggleSimpleViewCommand_1.ToggleSimpleViewCommand);
        this.createCommand(control, DiagramCommand.ToggleReadOnly, ToggleReadOnlyCommand_1.ToggleReadOnlyCommand);
        this.createCommand(control, DiagramCommand.InsertShapeImage, InsertShapeImageCommand_1.InsertShapeImageCommand);
        this.createCommand(control, DiagramCommand.EditShapeImage, EditShapeImageCommand_1.EditShapeImageCommand);
        this.createCommand(control, DiagramCommand.DeleteShapeImage, DeleteShapeImageCommand_1.DeleteShapeImageCommand);
        this.createCommand(control, DiagramCommand.FitToScreen, ChangeZoomLevelCommand_1.FitToScreenCommand);
        this.createCommand(control, DiagramCommand.FitToWidth, ChangeZoomLevelCommand_1.FitToWidthCommand);
        this.createCommand(control, DiagramCommand.SwitchAutoZoom, ChangeZoomLevelCommand_1.SwitchAutoZoomCommand);
        this.createCommand(control, DiagramCommand.ToggleAutoZoom, ChangeZoomLevelCommand_1.ToggleAutoZoomCommand);
        this.createCommand(control, DiagramCommand.ZoomLevelItems, ChangeZoomLevelCommand_1.ChangeZoomLevelItemsCommand);
        this.createCommand(control, DiagramCommand.GridSizeItems, ChangeGridSizeCommand_1.ChangeGridSizeItemsCommand);
        this.createCommand(control, DiagramCommand.PageSizeItems, ChangePageSizeCommand_1.ChangePageSizeItemsCommand);
        this.createCommand(control, DiagramCommand.Zoom25, ChangeZoomLevelCommand_1.ChangeZoomLevelTo25Command);
        this.createCommand(control, DiagramCommand.Zoom50, ChangeZoomLevelCommand_1.ChangeZoomLevelTo50Command);
        this.createCommand(control, DiagramCommand.Zoom75, ChangeZoomLevelCommand_1.ChangeZoomLevelTo75Command);
        this.createCommand(control, DiagramCommand.Zoom100, ChangeZoomLevelCommand_1.ChangeZoomLevelTo100Command);
        this.createCommand(control, DiagramCommand.Zoom125, ChangeZoomLevelCommand_1.ChangeZoomLevelTo125Command);
        this.createCommand(control, DiagramCommand.Zoom150, ChangeZoomLevelCommand_1.ChangeZoomLevelTo150Command);
        this.createCommand(control, DiagramCommand.Zoom200, ChangeZoomLevelCommand_1.ChangeZoomLevelTo200Command);
        this.createCommand(control, DiagramCommand.AutoZoomToContent, ChangeZoomLevelCommand_1.ToggleAutoZoomToContentCommand);
        this.createCommand(control, DiagramCommand.AutoZoomToWidth, ChangeZoomLevelCommand_1.ToggleAutoZoomToWidthCommand);
        this.createCommand(control, DiagramCommand.ConnectorRoutingMode, ChangeConnectorRoutingModeCommand_1.ChangeConnectorRoutingModeCommand);
    }
    CommandManager.prototype.getCommand = function (key) {
        return this.commands[key];
    };
    CommandManager.prototype.beforeExecuting = function (command) {
        this.executingCommandsChain.push(command);
        this.executingCommandCounter++;
    };
    CommandManager.prototype.afterExecuting = function () {
        this.executingCommandCounter--;
        if (this.executingCommandCounter === 0) {
            this.lastCommandsChain = this.executingCommandsChain;
            this.executingCommandsChain = [];
        }
    };
    CommandManager.prototype.processShortcut = function (code) {
        var command = this.shortcutsToCommand[code];
        if (command)
            return command.execute();
        return false;
    };
    CommandManager.prototype.processPaste = function (clipboardData) {
        var command = this.getCommand(DiagramCommand.Paste);
        if (command && command.isEnabled())
            command.execute(clipboardData);
        return true;
    };
    CommandManager.prototype.notifySelectionChanged = function (_selection) {
        this.lastCommandsChain = [];
    };
    CommandManager.prototype.notifyScrollPositionChanged = function () { };
    CommandManager.prototype.createCommand = function (control, commandId, commandType) {
        var shortcuts = [];
        for (var _i = 3; _i < arguments.length; _i++) {
            shortcuts[_i - 3] = arguments[_i];
        }
        this.commands[commandId] = new commandType(control);
        for (var i = 0; i < shortcuts.length; i++) {
            var shortcut = shortcuts[i];
            if (typeof shortcut === "number")
                this.shortcutsToCommand[shortcut] = this.commands[commandId];
        }
    };
    return CommandManager;
}());
exports.CommandManager = CommandManager;


/***/ }),
/* 83 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

Object.defineProperty(exports, "__esModule", { value: true });
var file_1 = __webpack_require__(177);
var mime_type_1 = __webpack_require__(178);
var Base64Utils = (function () {
    function Base64Utils() {
    }
    Base64Utils.normalizeToDataUrl = function (base64, mimeType) {
        if (!Base64Utils.checkPrependDataUrl(base64))
            base64 = Base64Utils.prependByDataUrl(base64, mimeType);
        return base64;
    };
    Base64Utils.prependByDataUrl = function (base64, mimeType) {
        return "data:" + mimeType + ";base64," + base64;
    };
    Base64Utils.checkPrependDataUrl = function (base64) {
        return Base64Utils.dataUrl.test(base64);
    };
    Base64Utils.deleteDataUrlPrefix = function (base64DataUrl) {
        return base64DataUrl.replace(Base64Utils.dataUrl, '');
    };
    Base64Utils.getUint8Array = function (base64) {
        base64 = atob(base64);
        var n = base64.length;
        var arr = new Uint8Array(n);
        while (n--)
            arr[n] = base64.charCodeAt(n);
        return arr;
    };
    Base64Utils.fromArrayBuffer = function (buffer) {
        var binary = [];
        var bytes = new Uint8Array(buffer);
        var len = bytes.byteLength;
        for (var i = 0; i < len; i++)
            binary.push(String.fromCharCode(bytes[i]));
        return window.btoa(binary.join(''));
    };
    Base64Utils.getFileFromBase64 = function (base64, fileName, options) {
        if (fileName === void 0) { fileName = ''; }
        var data = Base64Utils.getUint8Array(base64);
        return file_1.FileUtils.createFile([data], fileName, options);
    };
    Base64Utils.getMimeTypeAsString = function (base64) {
        var match = base64.match(Base64Utils.dataUrl);
        return match ? match[1] : null;
    };
    Base64Utils.getKnownMimeType = function (base64) {
        var match = base64.match(Base64Utils.dataUrl);
        return match ? mime_type_1.MimeTypeUtils.stringTypeToType(match[1]) : mime_type_1.DxMimeType.Unknown;
    };
    Base64Utils.fromBlobAsArrayBuffer = function (blob, callback) {
        var reader = new FileReader();
        reader.onloadend = function () { return callback(Base64Utils.fromArrayBuffer(reader.result)); };
        reader.readAsArrayBuffer(blob);
    };
    Base64Utils.fromBlobAsDataUrl = function (blob, callback) {
        var reader = new FileReader();
        reader.onloadend = function () { return callback(reader.result); };
        reader.readAsDataURL(blob);
    };
    Base64Utils.dataUrl = /^data:(.*?)(;(.*?))??(;base64)?,/;
    return Base64Utils;
}());
exports.Base64Utils = Base64Utils;


/***/ }),
/* 84 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.NativeConnector = exports.NativeShape = exports.NativeItem = void 0;
var ModelUtils_1 = __webpack_require__(4);
var NativeItem = (function () {
    function NativeItem(id, key) {
        this.id = id;
        this.key = key;
        this.unitsApplied = false;
    }
    NativeItem.prototype.applyUnits = function (units) {
        if (!this.unitsApplied && units !== undefined) {
            this.applyUnitsCore(units);
            this.unitsApplied = true;
        }
    };
    return NativeItem;
}());
exports.NativeItem = NativeItem;
var NativeShape = (function (_super) {
    __extends(NativeShape, _super);
    function NativeShape() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    NativeShape.prototype.applyUnitsCore = function (units) {
        this.position.x = ModelUtils_1.ModelUtils.getlUnitValue(units, this.position.x);
        this.position.y = ModelUtils_1.ModelUtils.getlUnitValue(units, this.position.y);
        this.size.width = ModelUtils_1.ModelUtils.getlUnitValue(units, this.size.width);
        this.size.height = ModelUtils_1.ModelUtils.getlUnitValue(units, this.size.height);
    };
    return NativeShape;
}(NativeItem));
exports.NativeShape = NativeShape;
var NativeConnector = (function (_super) {
    __extends(NativeConnector, _super);
    function NativeConnector() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    NativeConnector.prototype.applyUnitsCore = function (units) {
        this.points.forEach(function (pt) {
            pt.x = ModelUtils_1.ModelUtils.getlUnitValue(units, pt.x);
            pt.y = ModelUtils_1.ModelUtils.getlUnitValue(units, pt.y);
        });
    };
    return NativeConnector;
}(NativeItem));
exports.NativeConnector = NativeConnector;


/***/ }),
/* 85 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.ConnectorRenderPointsContext = void 0;
var ConnectorRenderPointsContext = (function () {
    function ConnectorRenderPointsContext(renderPoints, lockCreateRenderPoints, actualRoutingMode) {
        this.renderPoints = renderPoints;
        this.lockCreateRenderPoints = lockCreateRenderPoints;
        this.actualRoutingMode = actualRoutingMode;
    }
    return ConnectorRenderPointsContext;
}());
exports.ConnectorRenderPointsContext = ConnectorRenderPointsContext;


/***/ }),
/* 86 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.ReplaceConnectorPointsHistoryItem = exports.ChangeConnectorPointsHistoryItem = exports.UpdateConnectorPointsHistoryItem = void 0;
var HistoryItem_1 = __webpack_require__(8);
var UpdateConnectorPointsHistoryItem = (function (_super) {
    __extends(UpdateConnectorPointsHistoryItem, _super);
    function UpdateConnectorPointsHistoryItem(connectorKey, newPoints) {
        var _this = _super.call(this) || this;
        _this.connectorKey = connectorKey;
        _this.newPoints = newPoints;
        return _this;
    }
    UpdateConnectorPointsHistoryItem.prototype.redo = function (manipulator) {
        var _this = this;
        var connector = manipulator.model.findConnector(this.connectorKey);
        this.oldRenderContext = connector.createRenderPointsContext();
        this.oldPoints = connector.points.map(function (p) { return p.clone(); });
        manipulator.changeConnectorPoints(connector, function (connector) {
            connector.points = _this.newPoints;
            _this.updateRenderPoints(connector);
        });
    };
    UpdateConnectorPointsHistoryItem.prototype.undo = function (manipulator) {
        var _this = this;
        var connector = manipulator.model.findConnector(this.connectorKey);
        manipulator.changeConnectorPoints(connector, function (connector) {
            connector.points = _this.oldPoints;
            connector.replaceRenderPoints(_this.oldRenderContext);
        });
    };
    return UpdateConnectorPointsHistoryItem;
}(HistoryItem_1.HistoryItem));
exports.UpdateConnectorPointsHistoryItem = UpdateConnectorPointsHistoryItem;
var ChangeConnectorPointsHistoryItem = (function (_super) {
    __extends(ChangeConnectorPointsHistoryItem, _super);
    function ChangeConnectorPointsHistoryItem(connectorKey, newPoints, newRenderContext) {
        var _this = _super.call(this, connectorKey, newPoints) || this;
        _this.connectorKey = connectorKey;
        _this.newPoints = newPoints;
        _this.newRenderContext = newRenderContext;
        return _this;
    }
    ChangeConnectorPointsHistoryItem.prototype.updateRenderPoints = function (connector) {
        connector.replaceRenderPoints(this.newRenderContext);
    };
    return ChangeConnectorPointsHistoryItem;
}(UpdateConnectorPointsHistoryItem));
exports.ChangeConnectorPointsHistoryItem = ChangeConnectorPointsHistoryItem;
var ReplaceConnectorPointsHistoryItem = (function (_super) {
    __extends(ReplaceConnectorPointsHistoryItem, _super);
    function ReplaceConnectorPointsHistoryItem(connectorKey, newPoints) {
        var _this = _super.call(this, connectorKey, newPoints) || this;
        _this.connectorKey = connectorKey;
        _this.newPoints = newPoints;
        return _this;
    }
    ReplaceConnectorPointsHistoryItem.prototype.updateRenderPoints = function (connector) {
        connector.clearRenderPoints();
    };
    return ReplaceConnectorPointsHistoryItem;
}(UpdateConnectorPointsHistoryItem));
exports.ReplaceConnectorPointsHistoryItem = ReplaceConnectorPointsHistoryItem;


/***/ }),
/* 87 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

Object.defineProperty(exports, "__esModule", { value: true });
var Offsets = (function () {
    function Offsets(left, right, top, bottom) {
        this.left = left;
        this.right = right;
        this.top = top;
        this.bottom = bottom;
    }
    Offsets.empty = function () {
        return new Offsets(0, 0, 0, 0);
    };
    Object.defineProperty(Offsets.prototype, "horizontal", {
        get: function () {
            return this.left + this.right;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(Offsets.prototype, "vertical", {
        get: function () {
            return this.top + this.bottom;
        },
        enumerable: true,
        configurable: true
    });
    Offsets.fromNumber = function (offset) {
        return new Offsets(offset, offset, offset, offset);
    };
    Offsets.fromOffsets = function (offsets) {
        return new Offsets(offsets.left, offsets.right, offsets.top, offsets.bottom);
    };
    Offsets.fromSide = function (horizontal, vertical) {
        return new Offsets(horizontal, horizontal, vertical, vertical);
    };
    Offsets.prototype.normalize = function () {
        this.left = Math.max(0, this.left);
        this.right = Math.max(0, this.right);
        this.top = Math.max(0, this.top);
        this.bottom = Math.max(0, this.bottom);
        return this;
    };
    Offsets.prototype.toString = function () {
        return JSON.stringify(this);
    };
    Offsets.prototype.isEmpty = function () {
        return this.left === 0 && this.right === 0 && this.top === 0 && this.bottom === 0;
    };
    Offsets.prototype.offset = function (offset) {
        this.left += offset.left;
        this.right += offset.right;
        this.top += offset.top;
        this.bottom += offset.bottom;
        return this;
    };
    Offsets.prototype.multiply = function (multLeft, multRight, multTop, multBottom) {
        switch (arguments.length) {
            case 1: {
                this.left *= multLeft;
                this.right *= multLeft;
                this.top *= multLeft;
                this.bottom *= multLeft;
                return this;
            }
            case 2: {
                this.left *= multLeft;
                this.right *= multLeft;
                this.top *= multRight;
                this.bottom *= multRight;
                return this;
            }
            case 4: {
                this.left *= multLeft;
                this.right *= multRight;
                this.top *= multTop;
                this.bottom *= multBottom;
                return this;
            }
        }
        return this;
    };
    Offsets.prototype.clone = function () {
        return new Offsets(this.left, this.right, this.top, this.bottom);
    };
    Offsets.prototype.copyFrom = function (obj) {
        this.left = obj.left;
        this.right = obj.right;
        this.top = obj.top;
        this.bottom = obj.bottom;
    };
    Offsets.prototype.equals = function (obj) {
        return this.top === obj.top &&
            this.bottom === obj.bottom &&
            this.right === obj.right &&
            this.left === obj.left;
    };
    Offsets.prototype.applyConverter = function (converter) {
        this.left = converter(this.left);
        this.right = converter(this.right);
        this.top = converter(this.top);
        this.bottom = converter(this.bottom);
        return this;
    };
    return Offsets;
}());
exports.Offsets = Offsets;


/***/ }),
/* 88 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.ChangeConnectorPropertyHistoryItem = void 0;
var HistoryItem_1 = __webpack_require__(8);
var ChangeConnectorPropertyHistoryItem = (function (_super) {
    __extends(ChangeConnectorPropertyHistoryItem, _super);
    function ChangeConnectorPropertyHistoryItem(connectorKey, propertyName, value) {
        var _this = _super.call(this) || this;
        _this.connectorKey = connectorKey;
        _this.propertyName = propertyName;
        _this.value = value;
        return _this;
    }
    ChangeConnectorPropertyHistoryItem.prototype.redo = function (manipulator) {
        var connector = manipulator.model.findConnector(this.connectorKey);
        this.oldValue = connector.properties[this.propertyName];
        manipulator.changeConnectorProperty(connector, this.propertyName, this.value);
    };
    ChangeConnectorPropertyHistoryItem.prototype.undo = function (manipulator) {
        var connector = manipulator.model.findConnector(this.connectorKey);
        manipulator.changeConnectorProperty(connector, this.propertyName, this.oldValue);
    };
    return ChangeConnectorPropertyHistoryItem;
}(HistoryItem_1.HistoryItem));
exports.ChangeConnectorPropertyHistoryItem = ChangeConnectorPropertyHistoryItem;


/***/ }),
/* 89 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.ChangeStyleHistoryItem = void 0;
var ChangeStyleHistoryItemBase_1 = __webpack_require__(118);
var ChangeStyleHistoryItem = (function (_super) {
    __extends(ChangeStyleHistoryItem, _super);
    function ChangeStyleHistoryItem(itemKey, styleProperty, styleValue) {
        return _super.call(this, itemKey, styleProperty, styleValue) || this;
    }
    ChangeStyleHistoryItem.prototype.redo = function (manipulator) {
        var item = manipulator.model.findItem(this.itemKey);
        this.oldStyleValue = item.style[this.styleProperty];
        manipulator.changeStyle(item, this.styleProperty, this.styleValue);
    };
    ChangeStyleHistoryItem.prototype.undo = function (manipulator) {
        var item = manipulator.model.findItem(this.itemKey);
        manipulator.changeStyle(item, this.styleProperty, this.oldStyleValue);
    };
    return ChangeStyleHistoryItem;
}(ChangeStyleHistoryItemBase_1.ChangeStyleHistoryItemBase));
exports.ChangeStyleHistoryItem = ChangeStyleHistoryItem;


/***/ }),
/* 90 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.HashSet = void 0;
var HashSet = (function () {
    function HashSet(list, getHashCode) {
        var _this = this;
        if (list === void 0) { list = []; }
        if (getHashCode === void 0) { getHashCode = function (item) { return item.toString(); }; }
        this.items = [];
        this.map = {};
        this.getHashCode = getHashCode;
        list.forEach(function (i) { return _this.tryPush(i); });
    }
    HashSet.prototype.tryPush = function (item) {
        var code = this.getHashCode(item);
        if (this.map[code] === undefined) {
            this.map[code] = this.items.push(item) - 1;
            return true;
        }
        return false;
    };
    HashSet.prototype.contains = function (item) {
        return this.map[this.getHashCode(item)] !== undefined;
    };
    HashSet.prototype.forEach = function (callback) {
        this.items.forEach(callback);
    };
    HashSet.prototype.filter = function (predicate) {
        return this.items.filter(predicate);
    };
    HashSet.prototype.list = function () {
        return this.items.slice(0);
    };
    HashSet.prototype.item = function (index) {
        return this.items[index];
    };
    HashSet.prototype.first = function () {
        return this.items[0];
    };
    HashSet.prototype.remove = function (item) {
        var code = this.getHashCode(item);
        var index = this.map[code];
        if (typeof index === "number") {
            delete this.map[code];
            this.items.splice(index, 1);
            for (var i = index; i < this.items.length; i++)
                this.map[this.getHashCode(this.items[i])]--;
        }
        else
            throw "Item not found";
    };
    Object.defineProperty(HashSet.prototype, "length", {
        get: function () { return this.items.length; },
        enumerable: false,
        configurable: true
    });
    return HashSet;
}());
exports.HashSet = HashSet;


/***/ }),
/* 91 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.ShapeDescriptionManager = void 0;
var ProcessShapeDescription_1 = __webpack_require__(202);
var DecisionShapeDescription_1 = __webpack_require__(203);
var ManualInputShapeDescription_1 = __webpack_require__(204);
var DataShapeDescription_1 = __webpack_require__(205);
var TerminatorShapeDescription_1 = __webpack_require__(206);
var PredefinedProcessShapeDescription_1 = __webpack_require__(207);
var ArrowUpDownShapeDescription_1 = __webpack_require__(208);
var ArrowRightShapeDescription_1 = __webpack_require__(209);
var ArrowUpShapeDescription_1 = __webpack_require__(210);
var CrossShapeDescription_1 = __webpack_require__(211);
var DiamondShapeDescription_1 = __webpack_require__(120);
var EllipseShapeDescription_1 = __webpack_require__(72);
var HeartShapeDescription_1 = __webpack_require__(212);
var RectangleShapeDescription_1 = __webpack_require__(19);
var TextShapeDescription_1 = __webpack_require__(121);
var PentagonShapeDescription_1 = __webpack_require__(122);
var HexagonShapeDescription_1 = __webpack_require__(123);
var OctagonShapeDescription_1 = __webpack_require__(213);
var StarShapeDescription_1 = __webpack_require__(214);
var ArrowDownShapeDescription_1 = __webpack_require__(215);
var ArrowLeftRightShapeDescription_1 = __webpack_require__(216);
var ArrowLeftShapeDescription_1 = __webpack_require__(217);
var TriangleShapeDescription_1 = __webpack_require__(124);
var DocumentShapeDescription_1 = __webpack_require__(125);
var MultipleDocumentsShapeDescription_1 = __webpack_require__(218);
var PreparationShapeDescription_1 = __webpack_require__(219);
var HardDiskShapeDescription_1 = __webpack_require__(220);
var DatabaseShapeDescription_1 = __webpack_require__(221);
var InternalStorageShapeDescription_1 = __webpack_require__(222);
var PaperTapeShapeDescription_1 = __webpack_require__(223);
var ManualOperationShapeDescription_1 = __webpack_require__(224);
var DelayShapeDescription_1 = __webpack_require__(225);
var StoredDataShapeDescription_1 = __webpack_require__(226);
var MergeShapeDescription_1 = __webpack_require__(227);
var DisplayShapeDescription_1 = __webpack_require__(228);
var OrShapeDescription_1 = __webpack_require__(229);
var SummingJunctionShapeDescription_1 = __webpack_require__(230);
var CustomShapeDescription_1 = __webpack_require__(126);
var VerticalContainerDescription_1 = __webpack_require__(232);
var HorizontalContainerDescription_1 = __webpack_require__(233);
var CardWithImageOnTopDescription_1 = __webpack_require__(234);
var ShapeTypes_1 = __webpack_require__(1);
var ConnectorShapeDescription_1 = __webpack_require__(236);
var Utils_1 = __webpack_require__(3);
var CardWithHorizontalImageDescription_1 = __webpack_require__(237);
var ShapeDescriptionManager = (function () {
    function ShapeDescriptionManager() {
        this.descriptions = {};
        this.descriptionTypes = {};
        this.descriptionCategories = {};
        this.onShapeDecriptionChanged = new Utils_1.EventDispatcher();
        this.register(new TextShapeDescription_1.TextShapeDescription(), ShapeTypes_1.ShapeCategories.General);
        this.register(new RectangleShapeDescription_1.RectangleShapeDescription(), ShapeTypes_1.ShapeCategories.General);
        this.register(new EllipseShapeDescription_1.EllipseShapeDescription(), ShapeTypes_1.ShapeCategories.General);
        this.register(new CrossShapeDescription_1.CrossShapeDescription(), ShapeTypes_1.ShapeCategories.General);
        this.register(new TriangleShapeDescription_1.TriangleShapeDescription(), ShapeTypes_1.ShapeCategories.General);
        this.register(new DiamondShapeDescription_1.DiamondShapeDescription(), ShapeTypes_1.ShapeCategories.General);
        this.register(new HeartShapeDescription_1.HeartShapeDescription(), ShapeTypes_1.ShapeCategories.General);
        this.register(new PentagonShapeDescription_1.PentagonShapeDescription(), ShapeTypes_1.ShapeCategories.General);
        this.register(new HexagonShapeDescription_1.HexagonShapeDescription(), ShapeTypes_1.ShapeCategories.General);
        this.register(new OctagonShapeDescription_1.OctagonShapeDescription(), ShapeTypes_1.ShapeCategories.General);
        this.register(new StarShapeDescription_1.StarShapeDescription(), ShapeTypes_1.ShapeCategories.General);
        this.register(new ArrowUpShapeDescription_1.ArrowUpShapeDescription(), ShapeTypes_1.ShapeCategories.General);
        this.register(new ArrowDownShapeDescription_1.ArrowDownShapeDescription(), ShapeTypes_1.ShapeCategories.General);
        this.register(new ArrowLeftShapeDescription_1.ArrowLeftShapeDescription(), ShapeTypes_1.ShapeCategories.General);
        this.register(new ArrowRightShapeDescription_1.ArrowRightShapeDescription(), ShapeTypes_1.ShapeCategories.General);
        this.register(new ArrowUpDownShapeDescription_1.ArrowUpDownShapeDescription(), ShapeTypes_1.ShapeCategories.General);
        this.register(new ArrowLeftRightShapeDescription_1.ArrowLeftRightShapeDescription(), ShapeTypes_1.ShapeCategories.General);
        this.register(new ProcessShapeDescription_1.ProcessShapeDescription(), ShapeTypes_1.ShapeCategories.Flowchart);
        this.register(new DecisionShapeDescription_1.DecisionShapeDescription(), ShapeTypes_1.ShapeCategories.Flowchart);
        this.register(new TerminatorShapeDescription_1.TerminatorShapeDescription(), ShapeTypes_1.ShapeCategories.Flowchart);
        this.register(new PredefinedProcessShapeDescription_1.PredefinedProcessShapeDescription(), ShapeTypes_1.ShapeCategories.Flowchart);
        this.register(new DocumentShapeDescription_1.DocumentShapeDescription(), ShapeTypes_1.ShapeCategories.Flowchart);
        this.register(new MultipleDocumentsShapeDescription_1.MultipleDocumentsShapeDescription(), ShapeTypes_1.ShapeCategories.Flowchart);
        this.register(new ManualInputShapeDescription_1.ManualInputShapeDescription(), ShapeTypes_1.ShapeCategories.Flowchart);
        this.register(new PreparationShapeDescription_1.PreparationShapeDescription(), ShapeTypes_1.ShapeCategories.Flowchart);
        this.register(new DataShapeDescription_1.DataShapeDescription(), ShapeTypes_1.ShapeCategories.Flowchart);
        this.register(new DatabaseShapeDescription_1.DatabaseShapeDescription(), ShapeTypes_1.ShapeCategories.Flowchart);
        this.register(new HardDiskShapeDescription_1.HardDiskShapeDescription(), ShapeTypes_1.ShapeCategories.Flowchart);
        this.register(new InternalStorageShapeDescription_1.InternalStorageShapeDescription(), ShapeTypes_1.ShapeCategories.Flowchart);
        this.register(new PaperTapeShapeDescription_1.PaperTapeShapeDescription(), ShapeTypes_1.ShapeCategories.Flowchart);
        this.register(new ManualOperationShapeDescription_1.ManualOperationShapeDescription(), ShapeTypes_1.ShapeCategories.Flowchart);
        this.register(new DelayShapeDescription_1.DelayShapeDescription(), ShapeTypes_1.ShapeCategories.Flowchart);
        this.register(new StoredDataShapeDescription_1.StoredDataShapeDescription(), ShapeTypes_1.ShapeCategories.Flowchart);
        this.register(new DisplayShapeDescription_1.DisplayShapeDescription(), ShapeTypes_1.ShapeCategories.Flowchart);
        this.register(new MergeShapeDescription_1.MergeShapeDescription(), ShapeTypes_1.ShapeCategories.Flowchart);
        this.register(new ConnectorShapeDescription_1.ConnectorShapeDescription(), ShapeTypes_1.ShapeCategories.Flowchart);
        this.register(new OrShapeDescription_1.OrShapeDescription(), ShapeTypes_1.ShapeCategories.Flowchart);
        this.register(new SummingJunctionShapeDescription_1.SummingJunctionShapeDescription(), ShapeTypes_1.ShapeCategories.Flowchart);
        this.register(new CardWithHorizontalImageDescription_1.CardWithImageOnLeftDescription(), ShapeTypes_1.ShapeCategories.OrgChart);
        this.register(new CardWithHorizontalImageDescription_1.CardWithImageOnRightDescription(), ShapeTypes_1.ShapeCategories.OrgChart);
        this.register(new CardWithImageOnTopDescription_1.CardWithImageOnTopDescription(), ShapeTypes_1.ShapeCategories.OrgChart);
        this.register(new VerticalContainerDescription_1.VerticalContainerDescription(), ShapeTypes_1.ShapeCategories.Containers);
        this.register(new HorizontalContainerDescription_1.HorizontalContainerDescription(), ShapeTypes_1.ShapeCategories.Containers);
    }
    Object.defineProperty(ShapeDescriptionManager, "default", {
        get: function () {
            return ShapeDescriptionManager.defaultInstance;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(ShapeDescriptionManager, "defaultContainer", {
        get: function () {
            return ShapeDescriptionManager.defaultContainerInstance;
        },
        enumerable: false,
        configurable: true
    });
    ShapeDescriptionManager.prototype.get = function (type) {
        return this.descriptions[type];
    };
    ShapeDescriptionManager.prototype.getTypesByCategory = function (category) {
        return this.descriptionTypes[category] || [];
    };
    ShapeDescriptionManager.prototype.getCategoryByType = function (type) {
        return this.descriptionCategories[type];
    };
    ShapeDescriptionManager.prototype.getCategoryByDescription = function (description) {
        return this.getCategoryByType(description.key);
    };
    ShapeDescriptionManager.prototype.register = function (description, category, type) {
        if (type === void 0) { type = description.key; }
        if (this.descriptions[type] !== undefined)
            throw Error("Description key is duplicated");
        this.descriptions[type] = description;
        if (!this.descriptionTypes[category])
            this.descriptionTypes[category] = [];
        this.descriptionTypes[category].push(type);
        this.descriptionCategories[type] = category;
        description.onChanged.add(this);
    };
    ShapeDescriptionManager.prototype.registerCustomShape = function (shape) {
        if (shape.type === undefined)
            throw Error("Custom shape type is not defined");
        if (this.descriptions[shape.type] !== undefined)
            throw Error("Custom shape type is duplicated");
        var baseDescription = shape.baseType && this.descriptions[shape.baseType];
        if (shape.minWidth > shape.maxWidth)
            shape.maxWidth = shape.minWidth;
        if (shape.minHeight > shape.maxHeight)
            shape.maxHeight = shape.minHeight;
        this.register(new CustomShapeDescription_1.CustomShapeDescription(shape, baseDescription), shape.category || ShapeTypes_1.ShapeCategories.Custom);
    };
    ShapeDescriptionManager.prototype.unregisterCustomShape = function (shapeType) {
        var description = this.descriptions[shapeType];
        if (description instanceof CustomShapeDescription_1.CustomShapeDescription) {
            description.onChanged.remove(this);
            var category = this.descriptionCategories[shapeType];
            delete this.descriptions[shapeType];
            delete this.descriptionCategories[shapeType];
            var index = this.descriptionTypes[category].indexOf(shapeType);
            this.descriptionTypes[category].splice(index, 1);
            if (this.descriptionTypes[category].length === 0)
                delete this.descriptionTypes[category];
        }
    };
    ShapeDescriptionManager.prototype.unregisterAllCustomShapes = function () {
        var _this = this;
        Object.keys(this.descriptions).forEach(function (shapeType) {
            _this.unregisterCustomShape(shapeType);
        });
    };
    ShapeDescriptionManager.prototype.notifyShapeDescriptionChanged = function (description) {
        this.onShapeDecriptionChanged.raise1(function (l) { return l.notifyShapeDescriptionChanged(description); });
    };
    ShapeDescriptionManager.defaultInstance = new RectangleShapeDescription_1.RectangleShapeDescription();
    ShapeDescriptionManager.defaultContainerInstance = new VerticalContainerDescription_1.VerticalContainerDescription();
    return ShapeDescriptionManager;
}());
exports.ShapeDescriptionManager = ShapeDescriptionManager;


/***/ }),
/* 92 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.ArrowVerticalShapeDescription = exports.ArrowVerticalLineWidthParameterName = exports.ArrowVerticalTriangleHeightParameterName = void 0;
var ShapeDescription_1 = __webpack_require__(7);
var size_1 = __webpack_require__(2);
var ShapeParameters_1 = __webpack_require__(37);
var DiagramItem_1 = __webpack_require__(9);
exports.ArrowVerticalTriangleHeightParameterName = "th";
exports.ArrowVerticalLineWidthParameterName = "lw";
var ArrowVerticalShapeDescription = (function (_super) {
    __extends(ArrowVerticalShapeDescription, _super);
    function ArrowVerticalShapeDescription() {
        return _super.call(this, new size_1.Size(ShapeDescription_1.ShapeDefaultDimension * 0.375, ShapeDescription_1.ShapeDefaultDimension)) || this;
    }
    Object.defineProperty(ArrowVerticalShapeDescription.prototype, "keepRatioOnAutoSize", {
        get: function () { return false; },
        enumerable: false,
        configurable: true
    });
    ArrowVerticalShapeDescription.prototype.createParameters = function (parameters) {
        parameters.addRange([
            new ShapeParameters_1.ShapeParameter(exports.ArrowVerticalTriangleHeightParameterName, Math.sqrt(Math.pow(this.defaultSize.width, 2) - Math.pow(this.defaultSize.width / 2, 2))),
            new ShapeParameters_1.ShapeParameter(exports.ArrowVerticalLineWidthParameterName, this.defaultSize.width / 3)
        ]);
    };
    ArrowVerticalShapeDescription.prototype.normalizeParameters = function (shape, parameters) {
        this.changeParameterValue(parameters, exports.ArrowVerticalTriangleHeightParameterName, function (p) { return Math.max(0, Math.min(shape.size.height, p.value)); });
        this.changeParameterValue(parameters, exports.ArrowVerticalLineWidthParameterName, function (p) { return Math.max(0, Math.min(shape.size.width, p.value)); });
    };
    ArrowVerticalShapeDescription.prototype.processConnectionPoint = function (shape, point) {
        var delta = (shape.size.width - shape.parameters.get(exports.ArrowVerticalLineWidthParameterName).value) / 2;
        var side = shape.getConnectionPointSide(point);
        if (side === DiagramItem_1.ConnectionPointSide.East)
            point.x -= delta;
        else if (side === DiagramItem_1.ConnectionPointSide.West)
            point.x += delta;
    };
    ArrowVerticalShapeDescription.prototype.getTextRectangle = function (shape) {
        return shape.rectangle.clone().inflate(-ShapeDescription_1.ShapeTextPadding, -ShapeDescription_1.ShapeTextPadding);
    };
    ArrowVerticalShapeDescription.prototype.getSizeByText = function (textSize, _shape) {
        return textSize.clone().offset(ShapeDescription_1.ShapeTextPadding * 2, ShapeDescription_1.ShapeTextPadding * 2);
    };
    return ArrowVerticalShapeDescription;
}(ShapeDescription_1.ShapeDescription));
exports.ArrowVerticalShapeDescription = ArrowVerticalShapeDescription;


/***/ }),
/* 93 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.ArrowHorizontalShapeDescription = exports.ArrowVerticalLineHeightParameterName = exports.ArrowVerticalTriangleWidthParameterName = void 0;
var ShapeDescription_1 = __webpack_require__(7);
var size_1 = __webpack_require__(2);
var ShapeParameters_1 = __webpack_require__(37);
var DiagramItem_1 = __webpack_require__(9);
exports.ArrowVerticalTriangleWidthParameterName = "tw";
exports.ArrowVerticalLineHeightParameterName = "lh";
var ArrowHorizontalShapeDescription = (function (_super) {
    __extends(ArrowHorizontalShapeDescription, _super);
    function ArrowHorizontalShapeDescription() {
        return _super.call(this, new size_1.Size(ShapeDescription_1.ShapeDefaultDimension, ShapeDescription_1.ShapeDefaultDimension * 0.375)) || this;
    }
    Object.defineProperty(ArrowHorizontalShapeDescription.prototype, "keepRatioOnAutoSize", {
        get: function () { return false; },
        enumerable: false,
        configurable: true
    });
    ArrowHorizontalShapeDescription.prototype.createParameters = function (parameters) {
        parameters.addRange([
            new ShapeParameters_1.ShapeParameter(exports.ArrowVerticalTriangleWidthParameterName, Math.sqrt(Math.pow(this.defaultSize.height, 2) - Math.pow(this.defaultSize.height / 2, 2))),
            new ShapeParameters_1.ShapeParameter(exports.ArrowVerticalLineHeightParameterName, this.defaultSize.height / 3)
        ]);
    };
    ArrowHorizontalShapeDescription.prototype.normalizeParameters = function (shape, parameters) {
        this.changeParameterValue(parameters, exports.ArrowVerticalTriangleWidthParameterName, function (p) { return Math.max(0, Math.min(shape.size.width, p.value)); });
        this.changeParameterValue(parameters, exports.ArrowVerticalLineHeightParameterName, function (p) { return Math.max(0, Math.min(shape.size.height, p.value)); });
    };
    ArrowHorizontalShapeDescription.prototype.processConnectionPoint = function (shape, point) {
        var delta = (shape.size.height - shape.parameters.get(exports.ArrowVerticalLineHeightParameterName).value) / 2;
        var side = shape.getConnectionPointSide(point);
        if (side === DiagramItem_1.ConnectionPointSide.North)
            point.y += delta;
        else if (side === DiagramItem_1.ConnectionPointSide.South)
            point.y -= delta;
    };
    ArrowHorizontalShapeDescription.prototype.getTextRectangle = function (shape) {
        return shape.rectangle.clone().inflate(-ShapeDescription_1.ShapeTextPadding, -ShapeDescription_1.ShapeTextPadding);
    };
    ArrowHorizontalShapeDescription.prototype.getSizeByText = function (textSize, _shape) {
        return textSize.clone().offset(ShapeDescription_1.ShapeTextPadding * 2, ShapeDescription_1.ShapeTextPadding * 2);
    };
    return ArrowHorizontalShapeDescription;
}(ShapeDescription_1.ShapeDescription));
exports.ArrowHorizontalShapeDescription = ArrowHorizontalShapeDescription;


/***/ }),
/* 94 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.PolygonShapeDescription = void 0;
var ShapeDescription_1 = __webpack_require__(7);
var PolygonShapeDescription = (function (_super) {
    __extends(PolygonShapeDescription, _super);
    function PolygonShapeDescription(hasDefaultText) {
        var _this = _super.call(this, undefined, hasDefaultText) || this;
        _this.defaultSize.height = _this.calculateHeight(ShapeDescription_1.ShapeDefaultDimension);
        return _this;
    }
    Object.defineProperty(PolygonShapeDescription.prototype, "keepRatioOnAutoSize", {
        get: function () { return true; },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(PolygonShapeDescription.prototype, "angle", {
        get: function () {
            return Math.PI * (this.angleCount - 2) / this.angleCount;
        },
        enumerable: false,
        configurable: true
    });
    return PolygonShapeDescription;
}(ShapeDescription_1.ShapeDescription));
exports.PolygonShapeDescription = PolygonShapeDescription;


/***/ }),
/* 95 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.ImportUtils = void 0;
var ImportUtils = (function () {
    function ImportUtils() {
    }
    ImportUtils.parseJSON = function (json) {
        if (!json || json === "")
            return {};
        try {
            return JSON.parse(json);
        }
        catch (_a) {
            return {};
        }
    };
    ImportUtils.createDocument = function (xml) {
        var parser = new DOMParser();
        return parser.parseFromString(xml, "application/xml");
    };
    return ImportUtils;
}());
exports.ImportUtils = ImportUtils;


/***/ }),
/* 96 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.ChangeStyleTextPropertyCommand = void 0;
var ChangeStylePropertyCommandBase_1 = __webpack_require__(135);
var ChangeStyleTextHistoryItem_1 = __webpack_require__(70);
var Style_1 = __webpack_require__(26);
var ChangeStyleTextPropertyCommand = (function (_super) {
    __extends(ChangeStyleTextPropertyCommand, _super);
    function ChangeStyleTextPropertyCommand() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    ChangeStyleTextPropertyCommand.prototype.getValue = function () {
        return this.control.selection.inputPosition.getCurrentTextStylePropertyValue(this.getStyleProperty());
    };
    ChangeStyleTextPropertyCommand.prototype.getStyleObj = function (item) {
        return item.styleText;
    };
    ChangeStyleTextPropertyCommand.prototype.getDefaultStyleObj = function () {
        return new Style_1.TextStyle();
    };
    ChangeStyleTextPropertyCommand.prototype.createHistoryItem = function (item, styleProperty, styleValue) {
        return new ChangeStyleTextHistoryItem_1.ChangeStyleTextHistoryItem(item.key, styleProperty, styleValue);
    };
    ChangeStyleTextPropertyCommand.prototype.updateInputPosition = function (value) {
        this.control.selection.inputPosition.setTextStylePropertyValue(this.getStyleProperty(), value);
    };
    return ChangeStyleTextPropertyCommand;
}(ChangeStylePropertyCommandBase_1.ChangeStylePropertyCommandBase));
exports.ChangeStyleTextPropertyCommand = ChangeStyleTextPropertyCommand;


/***/ }),
/* 97 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.TreeLayoutBuilder = void 0;
var GraphLayout_1 = __webpack_require__(138);
var Tree_1 = __webpack_require__(252);
var NodeLayout_1 = __webpack_require__(71);
var Utils_1 = __webpack_require__(3);
var point_1 = __webpack_require__(0);
var BaseBuilder_1 = __webpack_require__(139);
var Structures_1 = __webpack_require__(38);
var DiagramItem_1 = __webpack_require__(9);
var LayoutSettings_1 = __webpack_require__(20);
var Graph_1 = __webpack_require__(54);
var TreeLayoutBuilder = (function (_super) {
    __extends(TreeLayoutBuilder, _super);
    function TreeLayoutBuilder() {
        var _this = _super !== null && _super.apply(this, arguments) || this;
        _this.nodeToLevel = {};
        _this.levelDepthSize = {};
        return _this;
    }
    TreeLayoutBuilder.prototype.build = function () {
        var _this = this;
        var layout = new GraphLayout_1.GraphLayout();
        var offset = 0;
        this.graph.getConnectedComponents().forEach(function (c) {
            var tree = Tree_1.Tree.createSpanningTree(c);
            var componentLayout = _this.processTree(tree);
            var subOffset = _this.getComponentOffset(componentLayout);
            while (componentLayout.nodeKeys.length < c.nodes.length) {
                var subGraph = new Graph_1.Graph(c.nodes.filter(function (n) { return !componentLayout.nodeToLayout[n]; }).map(function (n) { return c.getNode(n); }), c.edges.filter(function (e) { return !componentLayout.edgeToPosition[e.key]; }));
                var subTree = Tree_1.Tree.createSpanningTree(subGraph);
                var subComponentLayout = _this.processTree(subTree);
                componentLayout.extend(_this.setComponentOffset(subComponentLayout, subOffset));
                subOffset += _this.getComponentOffset(subComponentLayout);
            }
            layout.extend(_this.setComponentOffset(componentLayout, offset));
            offset += _this.getComponentOffset(componentLayout);
        });
        return layout;
    };
    TreeLayoutBuilder.prototype.preProcessTree = function (tree, parents, level) {
        var _this = this;
        parents = parents.filter(function (p) { return (_this.nodeToLevel[p.key] === undefined ? (_this.nodeToLevel[p.key] = level) : -1) >= 0; });
        if (parents.length) {
            var maxDepthSize = this.getMaxDepthSize(parents);
            this.levelDepthSize[level] = maxDepthSize;
            this.preProcessTree(tree, [].concat.apply([], parents.map(function (p) { return tree.getChildren(p); })), level + 1);
        }
    };
    TreeLayoutBuilder.prototype.loadNodes = function (tree, layout, parent) {
        if (!parent)
            return [layout.addNode(new NodeLayout_1.NodeLayout(tree.root, point_1.Point.zero()))];
        return tree.getChildren(parent.info).map(function (child) {
            return !layout.hasNode(child.key) ? layout.addNode(new NodeLayout_1.NodeLayout(child, point_1.Point.zero())) : undefined;
        }).filter(function (nl) { return nl; });
    };
    TreeLayoutBuilder.prototype.processTree = function (tree) {
        var _this = this;
        var layout = new GraphLayout_1.GraphLayout();
        this.preProcessTree(tree, [tree.root], 0);
        this.processLevel(tree, layout, 0, new Utils_1.Range(0), 0);
        if (this.settings.direction === LayoutSettings_1.LogicalDirectionKind.Backward) {
            var levelDepths = Object.keys(this.levelDepthSize).map(function (l) { return _this.levelDepthSize[l]; });
            var mostDepthPos_1 = levelDepths.reduce(function (acc, v) { return acc + v; }, 0) + (levelDepths.length - 1) * this.settings.layerSpacing;
            layout.forEachNode(function (n) { return _this.setDepthPos(n, _this.getDepthPos(n) + mostDepthPos_1); });
        }
        return layout;
    };
    TreeLayoutBuilder.prototype.processLevel = function (tree, layout, depthPos, breadthParentRange, level, parent) {
        var _this = this;
        var nodes = this.addNodes(tree, layout, level, parent);
        var parentEdges = parent ? this.graph.getAdjacentEdges(parent.key, Structures_1.ConnectionMode.Outgoing) : [];
        var maxDepthSize = this.getDirectionValue(this.levelDepthSize[level]);
        var layerSpacing = this.getDirectionValue(this.settings.layerSpacing);
        var prevRange;
        nodes.forEach(function (node) {
            var range = Utils_1.Range.fromLength(prevRange ? (prevRange.to + _this.settings.columnSpacing) : breadthParentRange.from, _this.getBreadthNodeSizeCore(node.info));
            node.position = _this.getNodePosition(range.from, depthPos, maxDepthSize).clone().offset(node.info.margin.left, node.info.margin.top);
            _this.processLevel(tree, layout, depthPos + maxDepthSize + layerSpacing, range, level + 1, node);
            _this.updateEdgeConnections(layout, parentEdges, node);
            breadthParentRange.extend(range);
            prevRange = range;
        });
        if (parent && nodes.length) {
            var lastChild = nodes[nodes.length - 1];
            var childRange = new Utils_1.Range(this.getBreadthPos(nodes[0]), this.getBreadthPos(lastChild) + this.getBreadthNodeSizeCore(lastChild.info, true));
            this.alignParent(parent, childRange, breadthParentRange);
        }
    };
    TreeLayoutBuilder.prototype.addNodes = function (tree, layout, level, parent) {
        var _this = this;
        if (level === 0)
            return [layout.addNode(new NodeLayout_1.NodeLayout(tree.root, point_1.Point.zero()))];
        return tree.getChildren(parent.info)
            .reduce(function (acc, n) {
            if (_this.nodeToLevel[n.key] === level && !layout.hasNode(n.key))
                acc.push(layout.addNode(new NodeLayout_1.NodeLayout(n, point_1.Point.zero())));
            return acc;
        }, []);
    };
    TreeLayoutBuilder.prototype.getMaxDepthSize = function (nodes) {
        var _this = this;
        return nodes.reduce(function (acc, node) { return Math.max(acc, _this.getDepthNodeSizeCore(node)); }, 0);
    };
    TreeLayoutBuilder.prototype.getNodePosition = function (breadthPos, depthPos, maxDepthSide) {
        if (this.settings.direction === LayoutSettings_1.LogicalDirectionKind.Forward)
            return this.settings.orientation === LayoutSettings_1.DataLayoutOrientation.Vertical ? new point_1.Point(breadthPos, depthPos) : new point_1.Point(depthPos, breadthPos);
        return this.settings.orientation === LayoutSettings_1.DataLayoutOrientation.Vertical ? new point_1.Point(breadthPos, depthPos + maxDepthSide) : new point_1.Point(depthPos + maxDepthSide, breadthPos);
    };
    TreeLayoutBuilder.prototype.updateEdgeConnections = function (layout, edges, node) {
        var _this = this;
        edges.filter(function (e) { return e.to === node.key; }).forEach(function (e) {
            var beginIndex = _this.getBeginEdgeIndex();
            var endIndex = _this.getEndEdgeIndex();
            layout.addEdge(new NodeLayout_1.EdgeLayout(e.key, beginIndex, endIndex));
        });
    };
    TreeLayoutBuilder.prototype.getBeginEdgeIndex = function () {
        if (this.settings.direction === LayoutSettings_1.LogicalDirectionKind.Forward)
            return this.isVertical() ? DiagramItem_1.ConnectionPointSide.South : DiagramItem_1.ConnectionPointSide.East;
        return this.isVertical() ? DiagramItem_1.ConnectionPointSide.North : DiagramItem_1.ConnectionPointSide.West;
    };
    TreeLayoutBuilder.prototype.getEndEdgeIndex = function () {
        if (this.settings.direction === LayoutSettings_1.LogicalDirectionKind.Forward)
            return this.isVertical() ? DiagramItem_1.ConnectionPointSide.North : DiagramItem_1.ConnectionPointSide.West;
        return this.isVertical() ? DiagramItem_1.ConnectionPointSide.South : DiagramItem_1.ConnectionPointSide.East;
    };
    TreeLayoutBuilder.prototype.alignParent = function (parent, childRange, availableRange) {
        if (this.settings.alignment === LayoutSettings_1.Alignment.Center) {
            var alignedPosition = childRange.from + childRange.length / 2 - this.getBreadthNodeSizeCore(parent.info, true) / 2;
            if (this.settings.orientation === LayoutSettings_1.DataLayoutOrientation.Vertical) {
                parent.position.x = Math.max(availableRange.from + parent.info.margin.left, alignedPosition);
                parent.position.x = Math.min(availableRange.to - parent.info.size.width - parent.info.margin.right, parent.position.x);
            }
            else {
                parent.position.y = Math.max(availableRange.from + parent.info.margin.top, alignedPosition);
                parent.position.y = Math.min(availableRange.to - parent.info.size.height - parent.info.margin.bottom, parent.position.y);
            }
        }
    };
    TreeLayoutBuilder.prototype.getDepthPos = function (node) {
        return this.settings.orientation === LayoutSettings_1.DataLayoutOrientation.Vertical ? node.position.y : node.position.x;
    };
    TreeLayoutBuilder.prototype.getBreadthPos = function (node) {
        return this.settings.orientation === LayoutSettings_1.DataLayoutOrientation.Vertical ? node.position.x : node.position.y;
    };
    TreeLayoutBuilder.prototype.setDepthPos = function (node, pos) {
        if (this.settings.orientation === LayoutSettings_1.DataLayoutOrientation.Vertical)
            node.position.y = pos;
        else
            node.position.x = pos;
    };
    TreeLayoutBuilder.prototype.isVertical = function () {
        return this.settings.orientation === LayoutSettings_1.DataLayoutOrientation.Vertical;
    };
    return TreeLayoutBuilder;
}(BaseBuilder_1.LayoutBuilder));
exports.TreeLayoutBuilder = TreeLayoutBuilder;


/***/ }),
/* 98 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.ExportImageCommand = void 0;
var CanvasItemsManager_1 = __webpack_require__(78);
var CanvasExportManager_1 = __webpack_require__(260);
var ExportImportCommandBase_1 = __webpack_require__(57);
var Exporter_1 = __webpack_require__(73);
var RenderHelper_1 = __webpack_require__(15);
var TextMeasurer_1 = __webpack_require__(79);
var DOMManipulator_1 = __webpack_require__(100);
var ImageCache_1 = __webpack_require__(46);
var ExportImageCommand = (function (_super) {
    __extends(ExportImageCommand, _super);
    function ExportImageCommand(control) {
        var _this = _super.call(this, control) || this;
        _this.exporter = new Exporter_1.Exporter();
        return _this;
    }
    ExportImageCommand.prototype.isEnabled = function () {
        return !ImageCache_1.ImageCache.instance.hasNonLoadedImages();
    };
    ExportImageCommand.prototype.executeCore = function (state, parameter) {
        var _this = this;
        try {
            var exportManager = this.getExportManager();
            var exportFunc = this.getExportFunc();
            exportFunc(this.control.model.size.clone(), this.control.model.pageColor, exportManager, function (url) {
                parameter(url, _this.getExtension());
                _this.tryDispose();
            }, this.control.settings.useCanvgForExportToImage);
        }
        catch (e) {
            this.tryDispose();
            throw e;
        }
        return true;
    };
    ExportImageCommand.prototype.getExportManager = function () {
        var measurer = this.getOrCreateMeasurer();
        var itemsManager = (this.control.render && this.control.render.items) || this.createItemsManager(measurer);
        return this.exportManager || (this.exportManager = new CanvasExportManager_1.CanvasExportManager(itemsManager.itemsContainer, measurer));
    };
    ExportImageCommand.prototype.createItemsManager = function (measurer) {
        this.svgElement = RenderHelper_1.RenderHelper.createSvgElement(document.body, true);
        var canvasManager = new CanvasItemsManager_1.CanvasItemsManager(this.svgElement, 1, new DOMManipulator_1.ExportDOMManipulator(measurer));
        this.control.modelManipulator.onModelChanged.add(canvasManager);
        this.control.modelManipulator.commitItemsCreateChanges();
        return canvasManager;
    };
    ExportImageCommand.prototype.tryDispose = function () {
        if (this.svgElement) {
            document.body.removeChild(this.svgElement);
            delete this.svgElement;
        }
        if (this.tempMeasurer) {
            this.tempMeasurer.clean();
            this.tempMeasurer = undefined;
        }
        this.exportManager = undefined;
    };
    ExportImageCommand.prototype.getOrCreateMeasurer = function () {
        return this.control.measurer || (this.tempMeasurer = new TextMeasurer_1.TextMeasurer(document.body));
    };
    return ExportImageCommand;
}(ExportImportCommandBase_1.ExportImportCommandBase));
exports.ExportImageCommand = ExportImageCommand;


/***/ }),
/* 99 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.ItemChange = exports.ItemChangeType = void 0;
var ItemChangeType;
(function (ItemChangeType) {
    ItemChangeType[ItemChangeType["Create"] = 0] = "Create";
    ItemChangeType[ItemChangeType["UpdateProperties"] = 1] = "UpdateProperties";
    ItemChangeType[ItemChangeType["UpdateStructure"] = 2] = "UpdateStructure";
    ItemChangeType[ItemChangeType["Update"] = 3] = "Update";
    ItemChangeType[ItemChangeType["Remove"] = 4] = "Remove";
    ItemChangeType[ItemChangeType["UpdateClassName"] = 5] = "UpdateClassName";
})(ItemChangeType = exports.ItemChangeType || (exports.ItemChangeType = {}));
var ItemChange = (function () {
    function ItemChange(item, type, isValid) {
        if (isValid === void 0) { isValid = true; }
        this.item = item;
        this.type = type;
        this.isValid = isValid;
    }
    Object.defineProperty(ItemChange.prototype, "key", {
        get: function () { return this.item.key; },
        enumerable: false,
        configurable: true
    });
    return ItemChange;
}());
exports.ItemChange = ItemChange;


/***/ }),
/* 100 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.ExportDOMManipulator = exports.DOMManipulator = void 0;
var Diagnostics_1 = __webpack_require__(61);
var RAF_CHANGES_LIMIT = 2000;
var DOMManipulator = (function () {
    function DOMManipulator(measurer) {
        this.measurer = measurer;
        this.queue = [];
    }
    DOMManipulator.prototype.createElement = function (primitive, parent, sibling) {
        return primitive.createElement(function (el) {
            if (parent != null)
                if (sibling !== undefined)
                    parent.insertBefore(el, sibling);
                else
                    parent.appendChild(el);
        });
    };
    DOMManipulator.prototype.changeChildrenByPrimitives = function (primitives, parent) {
        var _this = this;
        primitives.forEach(function (primitive, index) {
            var element = parent.childNodes[index];
            _this.changeByPrimitive(element, primitive);
        });
    };
    DOMManipulator.prototype.changeByFunc = function (element, func) {
        this.doChange(element, func);
    };
    DOMManipulator.prototype.changeByPrimitive = function (element, primitive) {
        this.doChange(element, primitive);
    };
    DOMManipulator.prototype.cancelAnimation = function () {
        if (this.rafId !== undefined) {
            cancelAnimationFrame(this.rafId);
            this.queue = [];
        }
    };
    DOMManipulator.prototype.doChange = function (element, action) {
        if (Diagnostics_1.Diagnostics.optimizeUsingRAF) {
            this.queue.push([element, action]);
            this.requestAnimation();
        }
        else
            this.doChangeSync(element, action);
    };
    DOMManipulator.prototype.doChangeSync = function (element, action) {
        if (typeof action === "function")
            action(element);
        else
            action.applyElementProperties(element, this.measurer);
    };
    DOMManipulator.prototype.requestAnimation = function () {
        var _this = this;
        if (!this.rafRequested) {
            this.rafRequested = true;
            var func_1 = function () {
                _this.queue.splice(0, RAF_CHANGES_LIMIT).forEach(function (t) { return _this.doChangeSync(t[0], t[1]); });
                if (_this.queue.length)
                    _this.rafId = requestAnimationFrame(func_1);
                else {
                    _this.rafRequested = false;
                    _this.rafId = undefined;
                }
            };
            this.rafId = requestAnimationFrame(func_1);
        }
    };
    return DOMManipulator;
}());
exports.DOMManipulator = DOMManipulator;
var ExportDOMManipulator = (function (_super) {
    __extends(ExportDOMManipulator, _super);
    function ExportDOMManipulator() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    ExportDOMManipulator.prototype.doChange = function (element, action) {
        this.doChangeSync(element, action);
    };
    return ExportDOMManipulator;
}(DOMManipulator));
exports.ExportDOMManipulator = ExportDOMManipulator;


/***/ }),
/* 101 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.ClipboardCommand = void 0;
var SimpleCommandBase_1 = __webpack_require__(10);
var ClipboardCommand = (function (_super) {
    __extends(ClipboardCommand, _super);
    function ClipboardCommand() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    ClipboardCommand.prototype.setClipboardData = function (data) {
        if (this.control.render)
            this.control.render.input.setClipboardData(data);
        ClipboardCommand.clipboardData = data;
    };
    ClipboardCommand.prototype.getClipboardData = function (callback) {
        if (this.control.render && this.isPasteSupportedByBrowser())
            this.control.render.input.getClipboardData(callback);
        else
            callback(ClipboardCommand.clipboardData);
    };
    ClipboardCommand.prototype.isPasteSupportedByBrowser = function () {
        return this.control.render && this.control.render.input.isPasteSupportedByBrowser();
    };
    return ClipboardCommand;
}(SimpleCommandBase_1.SimpleCommandBase));
exports.ClipboardCommand = ClipboardCommand;


/***/ }),
/* 102 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.ChangeZindexHistoryItem = void 0;
var HistoryItem_1 = __webpack_require__(8);
var ChangeZindexHistoryItem = (function (_super) {
    __extends(ChangeZindexHistoryItem, _super);
    function ChangeZindexHistoryItem(item, zIndex) {
        var _this = _super.call(this) || this;
        _this.itemKey = item.key;
        _this.zIndex = zIndex;
        return _this;
    }
    ChangeZindexHistoryItem.prototype.redo = function (manipulator) {
        var item = manipulator.model.findItem(this.itemKey);
        this.oldZIndex = item.zIndex;
        manipulator.changeZIndex(item, this.zIndex);
    };
    ChangeZindexHistoryItem.prototype.undo = function (manipulator) {
        var item = manipulator.model.findItem(this.itemKey);
        manipulator.changeZIndex(item, this.oldZIndex);
    };
    return ChangeZindexHistoryItem;
}(HistoryItem_1.HistoryItem));
exports.ChangeZindexHistoryItem = ChangeZindexHistoryItem;


/***/ }),
/* 103 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.DataLayoutParameters = exports.DataLayoutType = void 0;
var LayoutSettings_1 = __webpack_require__(20);
var WideTree_1 = __webpack_require__(97);
var Sugiyama_1 = __webpack_require__(80);
var DataLayoutType;
(function (DataLayoutType) {
    DataLayoutType[DataLayoutType["Tree"] = 0] = "Tree";
    DataLayoutType[DataLayoutType["Sugiyama"] = 1] = "Sugiyama";
})(DataLayoutType = exports.DataLayoutType || (exports.DataLayoutType = {}));
var DataLayoutParameters = (function () {
    function DataLayoutParameters(sizeSettings, parameter) {
        this.sizeSettings = sizeSettings;
        if (parameter) {
            if (parameter.type !== undefined) {
                this.layoutType = parameter.type;
                this.layoutSettings = this.layoutType === DataLayoutType.Sugiyama ? new LayoutSettings_1.LayoutSettings() : new LayoutSettings_1.TreeLayoutSettings();
            }
            if (parameter.orientation !== undefined)
                this.layoutSettings.orientation = parameter.orientation;
            this.skipPointIndices = parameter.skipPointIndices;
            this.autoSizeEnabled = parameter.autoSizeEnabled;
        }
    }
    Object.defineProperty(DataLayoutParameters.prototype, "needAutoLayout", {
        get: function () { return this.layoutType !== undefined; },
        enumerable: false,
        configurable: true
    });
    DataLayoutParameters.prototype.getLayoutBuilder = function (graph) {
        return (this.layoutType === DataLayoutType.Tree) ?
            new WideTree_1.TreeLayoutBuilder(this.layoutSettings, graph) :
            new Sugiyama_1.SugiyamaLayoutBuilder(this.layoutSettings, graph);
    };
    return DataLayoutParameters;
}());
exports.DataLayoutParameters = DataLayoutParameters;


/***/ }),
/* 104 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.EditShapeImageCommandBase = void 0;
var ChangeShapeImageHistoryItem_1 = __webpack_require__(146);
var SimpleCommandBase_1 = __webpack_require__(10);
var EditShapeImageCommandBase = (function (_super) {
    __extends(EditShapeImageCommandBase, _super);
    function EditShapeImageCommandBase() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    EditShapeImageCommandBase.prototype.isEnabled = function () {
        var selectedShape = this.getSelectedShape();
        return _super.prototype.isEnabled.call(this) && !!selectedShape && !selectedShape.locked && selectedShape.enableImage && selectedShape.allowEditImage;
    };
    EditShapeImageCommandBase.prototype.getValue = function () {
        var selectedShape = this.getSelectedShape();
        var imageUrl = (selectedShape) ? selectedShape.image.exportUrl : undefined;
        return imageUrl;
    };
    EditShapeImageCommandBase.prototype.getSelectedShape = function () {
        var selectedShapes = this.control.selection.getSelectedShapes(true);
        return (selectedShapes.length === 1) ? selectedShapes[0] : undefined;
    };
    EditShapeImageCommandBase.prototype.executeCore = function (state, parameter) {
        this.control.history.beginTransaction();
        var selectedUnlockedShapes = this.control.selection.getSelectedShapes(false);
        this.control.history.addAndRedo(new ChangeShapeImageHistoryItem_1.ChangeShapeImageHistoryItem(selectedUnlockedShapes[0], parameter));
        this.control.history.endTransaction();
        return true;
    };
    return EditShapeImageCommandBase;
}(SimpleCommandBase_1.SimpleCommandBase));
exports.EditShapeImageCommandBase = EditShapeImageCommandBase;


/***/ }),
/* 105 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

Object.defineProperty(exports, "__esModule", { value: true });
var min_max_1 = __webpack_require__(165);
var comparers_1 = __webpack_require__(166);
var ListUtils = (function () {
    function ListUtils() {
    }
    ListUtils.remove = function (list, element) {
        var index = list.indexOf(element, 0);
        if (index >= 0)
            list.splice(index, 1);
    };
    ListUtils.removeBy = function (list, callback) {
        var len = list.length;
        for (var index = 0; index < len; index++) {
            if (callback(list[index], index))
                return list.splice(index, 1)[0];
        }
        return null;
    };
    ListUtils.shallowCopy = function (list) {
        return list.slice();
    };
    ListUtils.deepCopy = function (list) {
        return ListUtils.map(list, function (val) { return val.clone(); });
    };
    ListUtils.initByValue = function (numElements, initValue) {
        var result = [];
        for (; numElements > 0; numElements--)
            result.push(initValue);
        return result;
    };
    ListUtils.initByCallback = function (numElements, initCallback) {
        var result = [];
        for (var index = 0; index < numElements; index++)
            result.push(initCallback(index));
        return result;
    };
    ListUtils.forEachOnInterval = function (interval, callback) {
        var end = interval.end;
        for (var index = interval.start; index < end; index++)
            callback(index);
    };
    ListUtils.reverseForEachOnInterval = function (interval, callback) {
        var start = interval.start;
        for (var index = interval.end - 1; index >= start; index--)
            callback(index);
    };
    ListUtils.reducedMap = function (list, callback, startIndex, endIndex) {
        if (startIndex === void 0) { startIndex = 0; }
        if (endIndex === void 0) { endIndex = list.length; }
        var result = [];
        for (var index = startIndex; index < endIndex; index++) {
            var newItem = callback(list[index], index);
            if (newItem !== null)
                result.push(newItem);
        }
        return result;
    };
    ListUtils.filter = function (list, callback, startIndex, endIndex) {
        if (startIndex === void 0) { startIndex = 0; }
        if (endIndex === void 0) { endIndex = list.length; }
        var result = [];
        for (var index = startIndex; index < endIndex; index++) {
            var item = list[index];
            if (callback(item, index))
                result.push(item);
        }
        return result;
    };
    ListUtils.map = function (list, callback, startIndex, endIndex) {
        if (startIndex === void 0) { startIndex = 0; }
        if (endIndex === void 0) { endIndex = list.length; }
        var result = [];
        for (var index = startIndex; index < endIndex; index++)
            result.push(callback(list[index], index));
        return result;
    };
    ListUtils.indexBy = function (list, callback, startIndex, endIndex) {
        if (startIndex === void 0) { startIndex = 0; }
        if (endIndex === void 0) { endIndex = list.length; }
        for (var ind = startIndex; ind < endIndex; ind++) {
            if (callback(list[ind], ind))
                return ind;
        }
        return -1;
    };
    ListUtils.reverseIndexBy = function (list, callback, startIndex, endIndex) {
        if (startIndex === void 0) { startIndex = list.length - 1; }
        if (endIndex === void 0) { endIndex = 0; }
        for (var ind = startIndex; ind >= endIndex; ind--) {
            if (callback(list[ind], ind))
                return ind;
        }
        return -1;
    };
    ListUtils.elementBy = function (list, callback, startIndex, endIndex) {
        if (startIndex === void 0) { startIndex = 0; }
        if (endIndex === void 0) { endIndex = list.length; }
        var ind = ListUtils.indexBy(list, callback, startIndex, endIndex);
        return ind < 0 ? null : list[ind];
    };
    ListUtils.reverseElementBy = function (list, callback, startIndex, endIndex) {
        if (startIndex === void 0) { startIndex = list.length - 1; }
        if (endIndex === void 0) { endIndex = 0; }
        var ind = ListUtils.reverseIndexBy(list, callback, startIndex, endIndex);
        return ind < 0 ? null : list[ind];
    };
    ListUtils.last = function (list) {
        return list[list.length - 1];
    };
    ListUtils.setLast = function (list, newVal) {
        return list[list.length - 1] = newVal;
    };
    ListUtils.incLast = function (list) {
        return ++list[list.length - 1];
    };
    ListUtils.decLast = function (list) {
        return --list[list.length - 1];
    };
    ListUtils.equals = function (a, b) {
        return a.length === b.length && ListUtils.allOf2(a, b, function (a, b) { return a.equals(b); });
    };
    ListUtils.equalsByReference = function (a, b) {
        var aLen = a.length;
        var bLen = a.length;
        if (aLen !== bLen)
            return false;
        for (var i = 0; i < aLen; i++) {
            if (a[i] !== b[i])
                return false;
        }
        return true;
    };
    ListUtils.unique = function (list, cmp, equal, finalizeObj) {
        if (equal === void 0) { equal = cmp; }
        if (finalizeObj === void 0) { finalizeObj = function () { }; }
        var len = list.length;
        if (len === 0)
            return [];
        list = list.sort(cmp);
        var prevValue = list[0];
        var result = ListUtils.reducedMap(list, function (v) {
            if (equal(prevValue, v) !== 0) {
                prevValue = v;
                return v;
            }
            finalizeObj(v);
            return null;
        }, 1, len);
        result.unshift(list[0]);
        return result;
    };
    ListUtils.uniqueNumber = function (list) {
        list = list.sort(comparers_1.Comparers.number);
        var prevValue = Number.NaN;
        for (var i = list.length - 1; i >= 0; i--) {
            if (prevValue === list[i])
                list.splice(i, 1);
            else
                prevValue = list[i];
        }
        return list;
    };
    ListUtils.forEach = function (list, callback, startIndex, endIndex) {
        if (startIndex === void 0) { startIndex = 0; }
        if (endIndex === void 0) { endIndex = list.length; }
        for (var index = startIndex; index < endIndex; index++)
            callback(list[index], index);
    };
    ListUtils.forEach2 = function (listA, listB, callback, startIndex, endIndex) {
        if (startIndex === void 0) { startIndex = 0; }
        if (endIndex === void 0) { endIndex = listA.length; }
        for (var index = startIndex; index < endIndex; index++)
            callback(listA[index], listB[index], index);
    };
    ListUtils.reverseForEach = function (list, callback, startIndex, endIndex) {
        if (startIndex === void 0) { startIndex = list.length - 1; }
        if (endIndex === void 0) { endIndex = 0; }
        for (var index = startIndex; index >= endIndex; index--)
            callback(list[index], index);
    };
    ListUtils.reverseIndexOf = function (list, element, startIndex, endIndex) {
        if (startIndex === void 0) { startIndex = list.length - 1; }
        if (endIndex === void 0) { endIndex = 0; }
        for (var index = startIndex; index >= endIndex; index--) {
            if (list[index] === element)
                return index;
        }
        return -1;
    };
    ListUtils.accumulate = function (list, initAccValue, callback, startIndex, endIndex) {
        if (startIndex === void 0) { startIndex = 0; }
        if (endIndex === void 0) { endIndex = list.length; }
        var acc = initAccValue;
        for (var ind = startIndex; ind < endIndex; ind++)
            acc = callback(acc, list[ind], ind);
        return acc;
    };
    ListUtils.accumulateNumber = function (list, callback, initAccValue, startIndex, endIndex) {
        if (initAccValue === void 0) { initAccValue = 0; }
        if (startIndex === void 0) { startIndex = 0; }
        if (endIndex === void 0) { endIndex = list.length; }
        var acc = initAccValue;
        for (var ind = startIndex; ind < endIndex; ind++)
            acc += callback(list[ind], ind, acc);
        return acc;
    };
    ListUtils.anyOf = function (list, callback, startIndex, endIndex) {
        if (startIndex === void 0) { startIndex = 0; }
        if (endIndex === void 0) { endIndex = list.length; }
        for (var index = startIndex; index < endIndex; index++) {
            if (callback(list[index], index))
                return true;
        }
        return false;
    };
    ListUtils.unsafeAnyOf = function (list, callback, startIndex, endIndex) {
        if (startIndex === void 0) { startIndex = 0; }
        if (endIndex === void 0) { endIndex = list.length; }
        for (var index = startIndex; index < endIndex; index++) {
            var currResult = callback(list[index], index);
            if (currResult)
                return currResult;
        }
        return null;
    };
    ListUtils.reverseAnyOf = function (list, callback, startIndex, endIndex) {
        if (startIndex === void 0) { startIndex = list.length - 1; }
        if (endIndex === void 0) { endIndex = 0; }
        for (var index = startIndex; index >= endIndex; index--) {
            if (callback(list[index], index))
                return true;
        }
        return false;
    };
    ListUtils.unsafeReverseAnyOf = function (list, callback, startIndex, endIndex) {
        if (startIndex === void 0) { startIndex = list.length - 1; }
        if (endIndex === void 0) { endIndex = 0; }
        for (var index = startIndex; index >= endIndex; index--) {
            var currResult = callback(list[index], index);
            if (currResult)
                return currResult;
        }
        return null;
    };
    ListUtils.anyOf2 = function (listA, listB, callback, startIndex, endIndex) {
        if (startIndex === void 0) { startIndex = 0; }
        if (endIndex === void 0) { endIndex = listA.length; }
        for (var index = startIndex; index < endIndex; index++) {
            if (callback(listA[index], listB[index], index))
                return true;
        }
        return false;
    };
    ListUtils.allOf = function (list, callback, startIndex, endIndex) {
        if (startIndex === void 0) { startIndex = 0; }
        if (endIndex === void 0) { endIndex = list.length; }
        for (var index = startIndex; index < endIndex; index++) {
            if (!callback(list[index], index))
                return false;
        }
        return true;
    };
    ListUtils.allOf2 = function (listA, listB, callback, startIndex, endIndex) {
        if (startIndex === void 0) { startIndex = 0; }
        if (endIndex === void 0) { endIndex = listA.length; }
        for (var index = startIndex; index < endIndex; index++) {
            if (!callback(listA[index], listB[index], index))
                return false;
        }
        return true;
    };
    ListUtils.allOfOnInterval = function (interval, callback) {
        var endIndex = interval.end;
        for (var index = interval.start; index < endIndex; index++) {
            if (!callback(index))
                return false;
        }
        return true;
    };
    ListUtils.addListOnTail = function (resultList, addedList) {
        for (var i = 0, elem = void 0; elem = addedList[i]; i++)
            resultList.push(elem);
        return resultList;
    };
    ListUtils.joinLists = function (converter) {
        var lists = [];
        for (var _i = 1; _i < arguments.length; _i++) {
            lists[_i - 1] = arguments[_i];
        }
        return ListUtils.accumulate(lists, [], function (accList, list) {
            ListUtils.addListOnTail(accList, converter(list));
            return accList;
        });
    };
    ListUtils.push = function (list, element) {
        list.push(element);
        return list;
    };
    ListUtils.countIf = function (list, callback) {
        return ListUtils.accumulateNumber(list, function (elem, ind) { return callback(elem, ind) ? 1 : 0; });
    };
    ListUtils.clear = function (list) {
        list.splice(0);
    };
    ListUtils.merge = function (list, cmp, shouldMerge, merge, startIndex, endIndex) {
        if (startIndex === void 0) { startIndex = 0; }
        if (endIndex === void 0) { endIndex = list.length; }
        list = list.slice(startIndex, endIndex);
        if (endIndex - startIndex < 2)
            return list;
        list = list.sort(cmp);
        var prevObj = list[startIndex];
        var result = [prevObj];
        for (var ind = startIndex + 1; ind < endIndex; ind++) {
            var obj = list[ind];
            if (shouldMerge(prevObj, obj))
                merge(prevObj, obj);
            else {
                prevObj = obj;
                result.push(prevObj);
            }
        }
        return result;
    };
    ListUtils.min = function (list, getValue, startIndex, endIndex) {
        if (startIndex === void 0) { startIndex = 0; }
        if (endIndex === void 0) { endIndex = list.length; }
        var res = ListUtils.minExtended(list, getValue, startIndex, endIndex);
        return res ? res.minElement : null;
    };
    ListUtils.max = function (list, getValue, startIndex, endIndex) {
        if (startIndex === void 0) { startIndex = 0; }
        if (endIndex === void 0) { endIndex = list.length; }
        var res = ListUtils.maxExtended(list, getValue, startIndex, endIndex);
        return res ? res.maxElement : null;
    };
    ListUtils.minMax = function (list, getValue, startIndex, endIndex) {
        if (startIndex === void 0) { startIndex = 0; }
        if (endIndex === void 0) { endIndex = list.length; }
        var res = ListUtils.minMaxExtended(list, getValue, startIndex, endIndex);
        return res ? new min_max_1.MinMax(res.minElement, res.maxElement) : null;
    };
    ListUtils.minExtended = function (list, getValue, startIndex, endIndex) {
        if (startIndex === void 0) { startIndex = 0; }
        if (endIndex === void 0) { endIndex = list.length; }
        if (list.length === 0)
            return null;
        var minElement = list[startIndex];
        var minValue = getValue(minElement);
        for (var index = startIndex + 1; index < endIndex; index++) {
            var elem = list[index];
            var elemValue = getValue(elem);
            if (elemValue < minValue) {
                minValue = elemValue;
                minElement = elem;
            }
        }
        return new min_max_1.ExtendedMin(minElement, minValue);
    };
    ListUtils.maxExtended = function (list, getValue, startIndex, endIndex) {
        if (startIndex === void 0) { startIndex = 0; }
        if (endIndex === void 0) { endIndex = list.length; }
        if (list.length === 0)
            return null;
        var maxElement = list[startIndex];
        var maxValue = getValue(maxElement);
        for (var index = startIndex + 1; index < endIndex; index++) {
            var elem = list[index];
            var elemValue = getValue(elem);
            if (elemValue > maxValue) {
                maxValue = elemValue;
                maxElement = elem;
            }
        }
        return new min_max_1.ExtendedMax(maxElement, maxValue);
    };
    ListUtils.minMaxExtended = function (list, getValue, startIndex, endIndex) {
        if (startIndex === void 0) { startIndex = 0; }
        if (endIndex === void 0) { endIndex = list.length; }
        if (list.length === 0)
            return null;
        var minElement = list[startIndex];
        var maxElement = minElement;
        var minValue = getValue(minElement);
        var maxValue = minValue;
        for (var index = startIndex + 1; index < endIndex; index++) {
            var elem = list[index];
            var elemValue = getValue(elem);
            if (elemValue < minValue) {
                minValue = elemValue;
                minElement = elem;
            }
            else if (elemValue > maxValue) {
                maxValue = elemValue;
                maxElement = elem;
            }
        }
        return new min_max_1.ExtendedMinMax(minElement, minValue, maxElement, maxValue);
    };
    ListUtils.minByCmp = function (list, cmp, startIndex, endIndex) {
        if (startIndex === void 0) { startIndex = 0; }
        if (endIndex === void 0) { endIndex = list.length; }
        if (list.length === 0)
            return null;
        var found = list[startIndex];
        for (var index = startIndex + 1; index < endIndex; index++) {
            var elem = list[index];
            if (cmp(elem, found) < 0)
                found = elem;
        }
        return found;
    };
    ListUtils.maxByCmp = function (list, cmp, startIndex, endIndex) {
        if (startIndex === void 0) { startIndex = 0; }
        if (endIndex === void 0) { endIndex = list.length; }
        if (list.length === 0)
            return null;
        var found = list[startIndex];
        for (var index = startIndex + 1; index < endIndex; index++) {
            var elem = list[index];
            if (cmp(elem, found) > 0)
                found = elem;
        }
        return found;
    };
    ListUtils.minMaxByCmp = function (list, cmp, startIndex, endIndex) {
        if (startIndex === void 0) { startIndex = 0; }
        if (endIndex === void 0) { endIndex = list.length; }
        if (list.length === 0)
            return null;
        var min = list[startIndex];
        var max = min;
        for (var index = startIndex + 1; index < endIndex; index++) {
            var elem = list[index];
            var res = cmp(elem, min);
            if (res > 0)
                max = elem;
            else if (res < 0)
                min = elem;
        }
        return new min_max_1.MinMax(min, max);
    };
    return ListUtils;
}());
exports.ListUtils = ListUtils;


/***/ }),
/* 106 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = __webpack_require__(59);
var mutable_1 = __webpack_require__(167);
var FixedInterval = (function (_super) {
    tslib_1.__extends(FixedInterval, _super);
    function FixedInterval(start, length) {
        var _this = _super.call(this) || this;
        _this.start = start;
        _this.length = length;
        return _this;
    }
    Object.defineProperty(FixedInterval.prototype, "end", {
        get: function () {
            return this.start + this.length;
        },
        set: function (newEnd) {
            this.length = newEnd - this.start;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(FixedInterval.prototype, "center", {
        get: function () {
            return this.start + this.length / 2;
        },
        enumerable: true,
        configurable: true
    });
    FixedInterval.prototype.copyFrom = function (obj) {
        this.start = obj.start;
        this.length = obj.length;
    };
    FixedInterval.prototype.equals = function (obj) {
        return obj && this.start === obj.start && this.length === obj.length;
    };
    FixedInterval.prototype.clone = function () {
        return new FixedInterval(this.start, this.length);
    };
    FixedInterval.prototype.makeByStartEnd = function (start, end) {
        return new FixedInterval(start, end - start);
    };
    FixedInterval.prototype.makeByStartLength = function (start, length) {
        return new FixedInterval(start, length);
    };
    FixedInterval.prototype.makeByLengthEnd = function (length, end) {
        return new FixedInterval(end - length, length);
    };
    FixedInterval.fromPositions = function (start, end) {
        return new FixedInterval(start, end - start);
    };
    FixedInterval.makeByConstInterval = function (interval) {
        return new FixedInterval(interval.start, interval.length);
    };
    FixedInterval.prototype.expand = function (interval) {
        var end = Math.max(interval.end, this.end);
        this.start = Math.min(interval.start, this.start);
        this.end = end;
        return this;
    };
    return FixedInterval;
}(mutable_1.MutableInterval));
exports.FixedInterval = FixedInterval;


/***/ }),
/* 107 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

Object.defineProperty(exports, "__esModule", { value: true });
var SparseIntervalsIterator = (function () {
    function SparseIntervalsIterator(sparseIntervals) {
        this.sparseIntervals = sparseIntervals;
        this.intervalIndex = -1;
    }
    Object.defineProperty(SparseIntervalsIterator.prototype, "isStarted", {
        get: function () {
            return !!this.curr;
        },
        enumerable: true,
        configurable: true
    });
    SparseIntervalsIterator.prototype.moveNext = function () {
        if (this.curr && this.posInInterval + 1 < this.curr.length) {
            this.posInInterval++;
            this.index++;
            this.initObject();
            return true;
        }
        if (this.intervalIndex + 1 < this.sparseIntervals.numIntervals) {
            this.intervalIndex++;
            this.curr = this.sparseIntervals.getInterval(this.intervalIndex);
            if (!this.curr.length)
                return this.moveNext();
            this.posInInterval = 0;
            this.index = this.curr.start;
            this.initObject();
            return true;
        }
        return false;
    };
    SparseIntervalsIterator.prototype.movePrev = function () {
        if (this.curr && this.posInInterval - 1 >= this.curr.start) {
            this.posInInterval--;
            this.index--;
            this.initObject();
            return true;
        }
        if (!this.isStarted)
            this.intervalIndex = this.sparseIntervals.numIntervals;
        if (this.intervalIndex - 1 >= 0) {
            this.intervalIndex--;
            this.curr = this.sparseIntervals.getInterval(this.intervalIndex);
            this.posInInterval = Math.max(this.curr.length - 1, this.curr.start);
            this.index = this.curr.start;
            this.initObject();
            return true;
        }
        return false;
    };
    SparseIntervalsIterator.prototype.initObject = function () { };
    return SparseIntervalsIterator;
}());
exports.SparseIntervalsIterator = SparseIntervalsIterator;


/***/ }),
/* 108 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.FilterPrimitive = void 0;
var RenderHelper_1 = __webpack_require__(15);
var Primitive_1 = __webpack_require__(24);
var FilterPrimitive = (function (_super) {
    __extends(FilterPrimitive, _super);
    function FilterPrimitive(id, x, y, width, height) {
        var _this = _super.call(this) || this;
        _this.id = id;
        _this.x = x;
        _this.y = y;
        _this.width = width;
        _this.height = height;
        return _this;
    }
    FilterPrimitive.prototype.createMainElement = function () {
        var element = document.createElementNS(RenderHelper_1.svgNS, "filter");
        element.setAttribute("id", this.id);
        return element;
    };
    FilterPrimitive.prototype.applyElementProperties = function (element, measurer) {
        if (this.id)
            element.setAttribute("id", this.id);
        this.setUnitAttribute(element, "x", this.x);
        this.setUnitAttribute(element, "y", this.y);
        this.setUnitAttribute(element, "width", this.width);
        this.setUnitAttribute(element, "height", this.height);
        this.setPositionCorrectionAttribute(element);
        _super.prototype.applyElementProperties.call(this, element, measurer);
    };
    return FilterPrimitive;
}(Primitive_1.SvgPrimitive));
exports.FilterPrimitive = FilterPrimitive;


/***/ }),
/* 109 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.PrimitiveObject = void 0;
var unit_converter_1 = __webpack_require__(12);
var PrimitiveObject = (function () {
    function PrimitiveObject(style) {
        this.style = style;
    }
    Object.defineProperty(PrimitiveObject.prototype, "strokeWidthPx", {
        get: function () {
            return this.style ? this.style.strokeWidthPx : 0;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(PrimitiveObject.prototype, "strokeOffset", {
        get: function () {
            return this.style ? this.style.strokeOffset : 0;
        },
        enumerable: false,
        configurable: true
    });
    PrimitiveObject.prototype.getUnitVaue = function (value) {
        return typeof value === "number" ? unit_converter_1.UnitConverter.twipsToPixels(value).toString() : value;
    };
    PrimitiveObject.prototype.setUnitAttribute = function (element, key, value) {
        if (value === undefined || value === null)
            return;
        element.setAttribute(key, this.getUnitVaue(value));
    };
    PrimitiveObject.prototype.setPositionCorrectionAttribute = function (element) {
        var transformAttr = this.strokeWidthPx % 2 === 1 ? "translate(" + this.strokeOffset + ", " + this.strokeOffset + ")" : "";
        element.setAttribute("transform", transformAttr);
    };
    return PrimitiveObject;
}());
exports.PrimitiveObject = PrimitiveObject;


/***/ }),
/* 110 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.isColorProperty = void 0;
var COLOR_PROPERTIES = { "stroke": true, "fill": true };
function isColorProperty(propName) {
    return COLOR_PROPERTIES[propName];
}
exports.isColorProperty = isColorProperty;


/***/ }),
/* 111 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.ConnectorPointsCalculatorBase = void 0;
var ConnectorPointsCalculatorBase = (function () {
    function ConnectorPointsCalculatorBase(connector) {
        this.connector = connector;
    }
    return ConnectorPointsCalculatorBase;
}());
exports.ConnectorPointsCalculatorBase = ConnectorPointsCalculatorBase;


/***/ }),
/* 112 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.ChangeShapeParametersHistoryItem = void 0;
var HistoryItem_1 = __webpack_require__(8);
var ChangeShapeParametersHistoryItem = (function (_super) {
    __extends(ChangeShapeParametersHistoryItem, _super);
    function ChangeShapeParametersHistoryItem(shapeKey, parameters) {
        var _this = _super.call(this) || this;
        _this.shapeKey = shapeKey;
        _this.parameters = parameters;
        return _this;
    }
    ChangeShapeParametersHistoryItem.prototype.redo = function (manipulator) {
        var shape = manipulator.model.findShape(this.shapeKey);
        this.oldParameters = shape.parameters.clone();
        manipulator.changeShapeParameters(shape, this.parameters);
    };
    ChangeShapeParametersHistoryItem.prototype.undo = function (manipulator) {
        var shape = manipulator.model.findShape(this.shapeKey);
        manipulator.changeShapeParameters(shape, this.oldParameters);
    };
    return ChangeShapeParametersHistoryItem;
}(HistoryItem_1.HistoryItem));
exports.ChangeShapeParametersHistoryItem = ChangeShapeParametersHistoryItem;


/***/ }),
/* 113 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.DeleteConnectorHistoryItem = void 0;
var HistoryItem_1 = __webpack_require__(8);
var DeleteConnectorHistoryItem = (function (_super) {
    __extends(DeleteConnectorHistoryItem, _super);
    function DeleteConnectorHistoryItem(connectorKey) {
        var _this = _super.call(this) || this;
        _this.connectorKey = connectorKey;
        return _this;
    }
    DeleteConnectorHistoryItem.prototype.redo = function (manipulator) {
        var connector = manipulator.model.findConnector(this.connectorKey);
        this.connector = connector.clone();
        manipulator.deleteConnector(connector);
    };
    DeleteConnectorHistoryItem.prototype.undo = function (manipulator) {
        manipulator.addConnector(this.connector, this.connector.key);
    };
    return DeleteConnectorHistoryItem;
}(HistoryItem_1.HistoryItem));
exports.DeleteConnectorHistoryItem = DeleteConnectorHistoryItem;


/***/ }),
/* 114 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.DeleteShapeHistoryItem = void 0;
var HistoryItem_1 = __webpack_require__(8);
var DeleteShapeHistoryItem = (function (_super) {
    __extends(DeleteShapeHistoryItem, _super);
    function DeleteShapeHistoryItem(shapeKey, allowed) {
        if (allowed === void 0) { allowed = true; }
        var _this = _super.call(this) || this;
        _this.shapeKey = shapeKey;
        _this.allowed = allowed;
        return _this;
    }
    DeleteShapeHistoryItem.prototype.redo = function (manipulator) {
        var shape = manipulator.model.findShape(this.shapeKey);
        this.shape = shape.clone();
        manipulator.deleteShape(shape, this.allowed);
    };
    DeleteShapeHistoryItem.prototype.undo = function (manipulator) {
        manipulator.addShape(this.shape, this.shape.key);
    };
    return DeleteShapeHistoryItem;
}(HistoryItem_1.HistoryItem));
exports.DeleteShapeHistoryItem = DeleteShapeHistoryItem;


/***/ }),
/* 115 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.ResizeShapeHistoryItem = void 0;
var HistoryItem_1 = __webpack_require__(8);
var ResizeShapeHistoryItem = (function (_super) {
    __extends(ResizeShapeHistoryItem, _super);
    function ResizeShapeHistoryItem(shapeKey, position, size) {
        var _this = _super.call(this) || this;
        _this.shapeKey = shapeKey;
        _this.position = position;
        _this.size = size;
        return _this;
    }
    ResizeShapeHistoryItem.prototype.redo = function (manipulator) {
        var shape = manipulator.model.findShape(this.shapeKey);
        this.oldPosition = shape.position.clone();
        this.oldSize = shape.size.clone();
        manipulator.resizeShape(shape, this.position, this.size);
    };
    ResizeShapeHistoryItem.prototype.undo = function (manipulator) {
        var shape = manipulator.model.findShape(this.shapeKey);
        manipulator.resizeShape(shape, this.oldPosition, this.oldSize);
    };
    return ResizeShapeHistoryItem;
}(HistoryItem_1.HistoryItem));
exports.ResizeShapeHistoryItem = ResizeShapeHistoryItem;


/***/ }),
/* 116 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.ChangeCustomDataHistoryItem = void 0;
var HistoryItem_1 = __webpack_require__(8);
var Utils_1 = __webpack_require__(3);
var ChangeCustomDataHistoryItem = (function (_super) {
    __extends(ChangeCustomDataHistoryItem, _super);
    function ChangeCustomDataHistoryItem(itemKey, customData) {
        var _this = _super.call(this) || this;
        _this.itemKey = itemKey;
        _this.customData = Utils_1.ObjectUtils.cloneObject(customData);
        return _this;
    }
    ChangeCustomDataHistoryItem.prototype.redo = function (manipulator) {
        var item = manipulator.model.findItem(this.itemKey);
        this.oldCustomData = Utils_1.ObjectUtils.cloneObject(item.customData);
        manipulator.changeCustomData(item, this.customData);
    };
    ChangeCustomDataHistoryItem.prototype.undo = function (manipulator) {
        var item = manipulator.model.findItem(this.itemKey);
        manipulator.changeCustomData(item, this.oldCustomData);
    };
    return ChangeCustomDataHistoryItem;
}(HistoryItem_1.HistoryItem));
exports.ChangeCustomDataHistoryItem = ChangeCustomDataHistoryItem;


/***/ }),
/* 117 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.ChangeLockedHistoryItem = void 0;
var HistoryItem_1 = __webpack_require__(8);
var ChangeLockedHistoryItem = (function (_super) {
    __extends(ChangeLockedHistoryItem, _super);
    function ChangeLockedHistoryItem(item, locked) {
        var _this = _super.call(this) || this;
        _this.itemKey = item.key;
        _this.locked = locked;
        return _this;
    }
    ChangeLockedHistoryItem.prototype.redo = function (manipulator) {
        var item = manipulator.model.findItem(this.itemKey);
        this.oldLocked = item.locked;
        manipulator.changeLocked(item, this.locked);
    };
    ChangeLockedHistoryItem.prototype.undo = function (manipulator) {
        var item = manipulator.model.findItem(this.itemKey);
        manipulator.changeLocked(item, this.oldLocked);
    };
    return ChangeLockedHistoryItem;
}(HistoryItem_1.HistoryItem));
exports.ChangeLockedHistoryItem = ChangeLockedHistoryItem;


/***/ }),
/* 118 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.ChangeStyleHistoryItemBase = void 0;
var HistoryItem_1 = __webpack_require__(8);
var ChangeStyleHistoryItemBase = (function (_super) {
    __extends(ChangeStyleHistoryItemBase, _super);
    function ChangeStyleHistoryItemBase(itemKey, styleProperty, styleValue) {
        var _this = _super.call(this) || this;
        _this.itemKey = itemKey;
        _this.styleProperty = styleProperty;
        _this.styleValue = styleValue;
        return _this;
    }
    ChangeStyleHistoryItemBase.prototype.redo = function (manipulator) {
        var item = manipulator.model.findItem(this.itemKey);
        this.oldStyleValue = item.style[this.styleProperty];
        manipulator.changeStyle(item, this.styleProperty, this.styleValue);
    };
    ChangeStyleHistoryItemBase.prototype.undo = function (manipulator) {
        var item = manipulator.model.findItem(this.itemKey);
        manipulator.changeStyle(item, this.styleProperty, this.oldStyleValue);
    };
    return ChangeStyleHistoryItemBase;
}(HistoryItem_1.HistoryItem));
exports.ChangeStyleHistoryItemBase = ChangeStyleHistoryItemBase;


/***/ }),
/* 119 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.Importer = void 0;
var Shape_1 = __webpack_require__(14);
var Utils_1 = __webpack_require__(3);
var size_1 = __webpack_require__(2);
var point_1 = __webpack_require__(0);
var ShapeDescriptionManager_1 = __webpack_require__(91);
var Connector_1 = __webpack_require__(6);
var ImageInfo_1 = __webpack_require__(51);
var ImporterBase_1 = __webpack_require__(133);
var ImportUtils_1 = __webpack_require__(95);
var color_1 = __webpack_require__(22);
var Importer = (function (_super) {
    __extends(Importer, _super);
    function Importer(shapeDescriptionManager, json) {
        var _this = _super.call(this, shapeDescriptionManager) || this;
        _this.obj = ImportUtils_1.ImportUtils.parseJSON(json);
        return _this;
    }
    Importer.prototype.getObject = function () {
        return this.obj;
    };
    Importer.prototype.getPageObject = function (obj) {
        return obj["page"];
    };
    Importer.prototype.getShapeObjects = function (obj) {
        return obj["shapes"];
    };
    Importer.prototype.getConnectorObjects = function (obj) {
        return obj["connectors"];
    };
    Importer.prototype.importPageSettings = function (model, pageObj) {
        if (!pageObj)
            return;
        this.assert(pageObj["width"], "number");
        this.assert(pageObj["height"], "number");
        if (typeof pageObj["width"] === "number")
            model.size.width = pageObj["width"];
        if (typeof pageObj["height"] === "number")
            model.size.height = pageObj["height"];
        if (typeof pageObj["pageColor"] === "number")
            model.pageColor = pageObj["pageColor"];
        else if (typeof pageObj["pageColor"] === "string")
            model.pageColor = color_1.ColorUtils.fromString(pageObj["pageColor"]);
        if (typeof pageObj["pageWidth"] === "number")
            model.pageSize.width = pageObj["pageWidth"];
        if (typeof pageObj["pageHeight"] === "number")
            model.pageSize.height = pageObj["pageHeight"];
        if (typeof pageObj["pageLandscape"] === "boolean")
            model.pageLandscape = pageObj["pageLandscape"];
    };
    Importer.prototype.importShape = function (shapeObj) {
        this.assert(shapeObj["key"], "string");
        this.assert(shapeObj["x"], "number");
        this.assert(shapeObj["y"], "number");
        this.assert(shapeObj["type"], "string");
        var shapeType = shapeObj["type"];
        var description = this.shapeDescriptionManager.get(shapeType);
        var position = new point_1.Point(shapeObj["x"], shapeObj["y"]);
        var shape = new Shape_1.Shape(description || ShapeDescriptionManager_1.ShapeDescriptionManager.default, position);
        shape.key = shapeObj["key"];
        if (typeof shapeObj["dataKey"] === "string" || typeof shapeObj["dataKey"] === "number")
            shape.dataKey = shapeObj["dataKey"];
        if (typeof shapeObj["customData"] === "object")
            shape.customData = Utils_1.ObjectUtils.cloneObject(shapeObj["customData"]);
        if (typeof shapeObj["locked"] === "boolean")
            shape.locked = shapeObj["locked"];
        if (typeof shapeObj["width"] === "number")
            shape.size.width = shapeObj["width"];
        if (typeof shapeObj["height"] === "number")
            shape.size.height = shapeObj["height"];
        if (typeof shapeObj["text"] === "string")
            shape.text = shapeObj["text"];
        if (typeof shapeObj["imageUrl"] === "string")
            shape.image = new ImageInfo_1.ImageInfo(shapeObj["imageUrl"]);
        if (shapeObj["parameters"]) {
            shape.parameters.fromObject(shapeObj["parameters"]);
            shape.description.normalizeParameters(shape, shape.parameters);
        }
        if (shapeObj["style"])
            shape.style.fromObject(shapeObj["style"]);
        if (shapeObj["styleText"])
            shape.styleText.fromObject(shapeObj["styleText"]);
        if (typeof shapeObj["zIndex"] === "number")
            shape.zIndex = shapeObj["zIndex"];
        if (Array.isArray(shapeObj["childKeys"]))
            shape["childKeys"] = shapeObj["childKeys"].slice();
        if (typeof shapeObj["expanded"] === "boolean")
            shape.expanded = shapeObj["expanded"];
        if (typeof shapeObj["expandedWidth"] === "number" && typeof shapeObj["expandedHeight"] === "number")
            shape.expandedSize = new size_1.Size(shapeObj["expandedWidth"], shapeObj["expandedHeight"]);
        return shape;
    };
    Importer.prototype.importShapeChildren = function (shapeObj, shape) {
        return [];
    };
    Importer.prototype.importConnector = function (connectorObj) {
        var _this = this;
        this.assert(connectorObj["key"], "string");
        if (!Array.isArray(connectorObj["points"]))
            throw Error("Invalid Format");
        var points = connectorObj["points"].map(function (pt) {
            _this.assert(pt["x"], "number");
            _this.assert(pt["y"], "number");
            return new point_1.Point(pt["x"], pt["y"]);
        });
        var connector = new Connector_1.Connector(points);
        connector.key = connectorObj["key"];
        if (typeof connectorObj["dataKey"] === "string" || typeof connectorObj["dataKey"] === "number")
            connector.dataKey = connectorObj["dataKey"];
        if (typeof connectorObj["customData"] === "object")
            connector.customData = Utils_1.ObjectUtils.cloneObject(connectorObj["customData"]);
        if (typeof connectorObj["locked"] === "boolean")
            connector.locked = connectorObj["locked"];
        connector.endConnectionPointIndex = typeof connectorObj["endConnectionPointIndex"] === "number" ? connectorObj["endConnectionPointIndex"] : -1;
        connector.beginConnectionPointIndex = typeof connectorObj["beginConnectionPointIndex"] === "number" ? connectorObj["beginConnectionPointIndex"] : -1;
        if (connectorObj["endItemKey"] !== undefined)
            this.assert(connectorObj["endItemKey"], "string");
        if (connectorObj["beginItemKey"] !== undefined)
            this.assert(connectorObj["beginItemKey"], "string");
        connector["endItemKey"] = connectorObj["endItemKey"];
        connector["beginItemKey"] = connectorObj["beginItemKey"];
        if (connectorObj["texts"])
            connector.texts.fromObject(connectorObj["texts"]);
        if (connectorObj["properties"])
            connector.properties.fromObject(connectorObj["properties"]);
        if (connectorObj["style"])
            connector.style.fromObject(connectorObj["style"]);
        if (connectorObj["styleText"])
            connector.styleText.fromObject(connectorObj["styleText"]);
        if (typeof connectorObj["zIndex"] === "number")
            connector.zIndex = connectorObj["zIndex"];
        return connector;
    };
    return Importer;
}(ImporterBase_1.ImporterBase));
exports.Importer = Importer;


/***/ }),
/* 120 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.DiamondShapeDescription = void 0;
var ShapeDescription_1 = __webpack_require__(7);
var PathPrimitive_1 = __webpack_require__(5);
var ShapeTypes_1 = __webpack_require__(1);
var DiamondShapeDescription = (function (_super) {
    __extends(DiamondShapeDescription, _super);
    function DiamondShapeDescription(defaultSize, hasDefaultText) {
        if (defaultSize === void 0) { defaultSize = ShapeDescription_1.ShapeDefaultSize.clone(); }
        return _super.call(this, defaultSize, hasDefaultText) || this;
    }
    Object.defineProperty(DiamondShapeDescription.prototype, "key", {
        get: function () { return ShapeTypes_1.ShapeTypes.Diamond; },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(DiamondShapeDescription.prototype, "keepRatioOnAutoSize", {
        get: function () { return false; },
        enumerable: false,
        configurable: true
    });
    DiamondShapeDescription.prototype.createShapePrimitives = function (shape) {
        var rect = shape.rectangle;
        var left = rect.x, top = rect.y, right = rect.right, bottom = rect.bottom;
        var _a = rect.center, cx = _a.x, cy = _a.y;
        return [
            new PathPrimitive_1.PathPrimitive([
                new PathPrimitive_1.PathPrimitiveMoveToCommand(cx, top),
                new PathPrimitive_1.PathPrimitiveLineToCommand(right, cy),
                new PathPrimitive_1.PathPrimitiveLineToCommand(cx, bottom),
                new PathPrimitive_1.PathPrimitiveLineToCommand(left, cy),
                new PathPrimitive_1.PathPrimitiveClosePathCommand()
            ], shape.style)
        ];
    };
    DiamondShapeDescription.prototype.getTextRectangle = function (shape) {
        return shape.rectangle.clone().inflate(-shape.size.width / 4, -shape.size.height / 4);
    };
    DiamondShapeDescription.prototype.getSizeByText = function (textSize, _shape) {
        return textSize.clone().multiply(2, 2);
    };
    return DiamondShapeDescription;
}(ShapeDescription_1.ShapeDescription));
exports.DiamondShapeDescription = DiamondShapeDescription;


/***/ }),
/* 121 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.TextShapeDescription = void 0;
var ShapeDescription_1 = __webpack_require__(7);
var size_1 = __webpack_require__(2);
var ShapeTypes_1 = __webpack_require__(1);
var ClipPathPrimitive_1 = __webpack_require__(56);
var RectaglePrimitive_1 = __webpack_require__(21);
var Utils_1 = __webpack_require__(17);
var TextShapeDescription = (function (_super) {
    __extends(TextShapeDescription, _super);
    function TextShapeDescription() {
        var _this = _super.call(this, new size_1.Size(ShapeDescription_1.ShapeDefaultDimension, ShapeDescription_1.ShapeDefaultDimension * 0.5), true) || this;
        _this.textClipPathId = Utils_1.RenderUtils.generateSvgElementId("clipRect");
        return _this;
    }
    Object.defineProperty(TextShapeDescription.prototype, "key", {
        get: function () { return ShapeTypes_1.ShapeTypes.Text; },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(TextShapeDescription.prototype, "keepRatioOnAutoSize", {
        get: function () { return false; },
        enumerable: false,
        configurable: true
    });
    TextShapeDescription.prototype.createShapePrimitives = function (shape, forToolbox) {
        if (forToolbox) {
            var _a = shape.rectangle, left = _a.x, top_1 = _a.y, width = _a.width, height = _a.height;
            return [
                new ClipPathPrimitive_1.ClipPathPrimitive(this.getTextClipPathId(forToolbox), [
                    new RectaglePrimitive_1.RectanglePrimitive(left, top_1, width, height)
                ])
            ];
        }
        return [];
    };
    TextShapeDescription.prototype.getTextClipPathId = function (forToolbox) {
        return forToolbox ? this.textClipPathId : undefined;
    };
    TextShapeDescription.prototype.getSizeByTextRectangle = function (textSize) {
        return textSize;
    };
    TextShapeDescription.prototype.getSizeByText = function (textSize, shape) {
        return textSize.clone();
    };
    TextShapeDescription.prototype.getTextRectangle = function (shape) {
        return shape.rectangle;
    };
    return TextShapeDescription;
}(ShapeDescription_1.ShapeDescription));
exports.TextShapeDescription = TextShapeDescription;


/***/ }),
/* 122 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.PentagonShapeDescription = void 0;
var PathPrimitive_1 = __webpack_require__(5);
var ShapeTypes_1 = __webpack_require__(1);
var PolygonShapeDescription_1 = __webpack_require__(94);
var DiagramItem_1 = __webpack_require__(9);
var Utils_1 = __webpack_require__(3);
var rectangle_1 = __webpack_require__(13);
var PentagonShapeDescription = (function (_super) {
    __extends(PentagonShapeDescription, _super);
    function PentagonShapeDescription(hasDefaultText) {
        var _this = _super.call(this, hasDefaultText) || this;
        _this.defaultRatio = _this.defaultSize.height / _this.defaultSize.width;
        return _this;
    }
    Object.defineProperty(PentagonShapeDescription.prototype, "key", {
        get: function () { return ShapeTypes_1.ShapeTypes.Pentagon; },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(PentagonShapeDescription.prototype, "angleCount", {
        get: function () { return 5; },
        enumerable: false,
        configurable: true
    });
    PentagonShapeDescription.prototype.createShapePrimitives = function (shape) {
        var rect = shape.rectangle;
        var left = rect.x, top = rect.y, right = rect.right, bottom = rect.bottom, width = rect.width, height = rect.height;
        var cx = rect.center.x;
        var ratio = height / width / this.defaultRatio;
        var angle = Math.PI - this.angle;
        var py = width / 2 * Math.tan(angle / 2) * ratio;
        var y = top + py;
        var px = (height - py) / Math.tan(angle) / ratio;
        var x1 = left + px;
        var x2 = right - px;
        return [
            new PathPrimitive_1.PathPrimitive([
                new PathPrimitive_1.PathPrimitiveMoveToCommand(cx, top),
                new PathPrimitive_1.PathPrimitiveLineToCommand(right, y),
                new PathPrimitive_1.PathPrimitiveLineToCommand(x2, bottom),
                new PathPrimitive_1.PathPrimitiveLineToCommand(x1, bottom),
                new PathPrimitive_1.PathPrimitiveLineToCommand(left, y),
                new PathPrimitive_1.PathPrimitiveClosePathCommand()
            ], shape.style)
        ];
    };
    PentagonShapeDescription.prototype.processConnectionPoint = function (shape, point) {
        var side = shape.getConnectionPointSide(point);
        if (side === DiagramItem_1.ConnectionPointSide.East || side === DiagramItem_1.ConnectionPointSide.West) {
            var rect = shape.rectangle;
            var top_1 = rect.y, width = rect.width, height = rect.height;
            var ratio = height / width / this.defaultRatio;
            var angle = Math.PI - this.angle;
            var py = width / 2 * Math.tan(angle / 2) * ratio;
            var y = top_1 + py;
            if (side === DiagramItem_1.ConnectionPointSide.East)
                point.y = y;
            else if (side === DiagramItem_1.ConnectionPointSide.West)
                point.y = y;
        }
    };
    PentagonShapeDescription.prototype.calculateHeight = function (width) {
        var angle = Math.PI - this.angle;
        var h1 = width / 2 * Math.tan(angle / 2);
        var side = width / 2 / Math.cos(angle / 2);
        var h2 = side * Math.sin(angle);
        return h1 + h2;
    };
    PentagonShapeDescription.prototype.getTextRectangle = function (shape) {
        var textSize = Utils_1.GeometryUtils.getMaxRectangleEnscribedInEllipse(shape.size);
        return rectangle_1.Rectangle.fromGeometry(shape.position.clone().offset((shape.size.width - textSize.width) / 2, (shape.size.height - textSize.height) / 2), textSize);
    };
    PentagonShapeDescription.prototype.getSizeByText = function (textSize, _shape) {
        return Utils_1.GeometryUtils.getEllipseByEnscribedRectangle(textSize);
    };
    return PentagonShapeDescription;
}(PolygonShapeDescription_1.PolygonShapeDescription));
exports.PentagonShapeDescription = PentagonShapeDescription;


/***/ }),
/* 123 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.HexagonShapeDescription = void 0;
var PathPrimitive_1 = __webpack_require__(5);
var ShapeTypes_1 = __webpack_require__(1);
var PolygonShapeDescription_1 = __webpack_require__(94);
var Utils_1 = __webpack_require__(3);
var rectangle_1 = __webpack_require__(13);
var HexagonShapeDescription = (function (_super) {
    __extends(HexagonShapeDescription, _super);
    function HexagonShapeDescription() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    Object.defineProperty(HexagonShapeDescription.prototype, "key", {
        get: function () { return ShapeTypes_1.ShapeTypes.Hexagon; },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(HexagonShapeDescription.prototype, "angleCount", {
        get: function () { return 6; },
        enumerable: false,
        configurable: true
    });
    HexagonShapeDescription.prototype.createShapePrimitives = function (shape) {
        var rect = shape.rectangle;
        var left = rect.x, top = rect.y, right = rect.right, bottom = rect.bottom, width = rect.width;
        var cy = rect.center.y;
        var angle = Math.PI - this.angle;
        var sideX = width / (1 + 2 * Math.cos(angle));
        var x1 = left + (width - sideX) / 2;
        var x2 = x1 + sideX;
        return [
            new PathPrimitive_1.PathPrimitive([
                new PathPrimitive_1.PathPrimitiveMoveToCommand(x1, top),
                new PathPrimitive_1.PathPrimitiveLineToCommand(x2, top),
                new PathPrimitive_1.PathPrimitiveLineToCommand(right, cy),
                new PathPrimitive_1.PathPrimitiveLineToCommand(x2, bottom),
                new PathPrimitive_1.PathPrimitiveLineToCommand(x1, bottom),
                new PathPrimitive_1.PathPrimitiveLineToCommand(left, cy),
                new PathPrimitive_1.PathPrimitiveClosePathCommand()
            ], shape.style)
        ];
    };
    HexagonShapeDescription.prototype.calculateHeight = function (width) {
        var angle = Math.PI - this.angle;
        var sideX = width / (1 + 2 * Math.cos(angle));
        return 2 * sideX * Math.sin(angle);
    };
    HexagonShapeDescription.prototype.getTextRectangle = function (shape) {
        var textSize = Utils_1.GeometryUtils.getMaxRectangleEnscribedInEllipse(shape.size);
        return rectangle_1.Rectangle.fromGeometry(shape.position.clone().offset((shape.size.width - textSize.width) / 2, (shape.size.height - textSize.height) / 2), textSize);
    };
    HexagonShapeDescription.prototype.getSizeByText = function (textSize, _shape) {
        return Utils_1.GeometryUtils.getEllipseByEnscribedRectangle(textSize);
    };
    return HexagonShapeDescription;
}(PolygonShapeDescription_1.PolygonShapeDescription));
exports.HexagonShapeDescription = HexagonShapeDescription;


/***/ }),
/* 124 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.TriangleShapeDescription = void 0;
var ShapeDescription_1 = __webpack_require__(7);
var PathPrimitive_1 = __webpack_require__(5);
var ShapeTypes_1 = __webpack_require__(1);
var ConnectionPoint_1 = __webpack_require__(45);
var DiagramItem_1 = __webpack_require__(9);
var rectangle_1 = __webpack_require__(13);
var size_1 = __webpack_require__(2);
var TriangleShapeDescription = (function (_super) {
    __extends(TriangleShapeDescription, _super);
    function TriangleShapeDescription(hasDefaultText) {
        var _this = _super.call(this, undefined, hasDefaultText) || this;
        _this.defaultSize.height = _this.calculateHeight(ShapeDescription_1.ShapeDefaultDimension);
        return _this;
    }
    Object.defineProperty(TriangleShapeDescription.prototype, "key", {
        get: function () { return ShapeTypes_1.ShapeTypes.Triangle; },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(TriangleShapeDescription.prototype, "keepRatioOnAutoSize", {
        get: function () { return false; },
        enumerable: false,
        configurable: true
    });
    TriangleShapeDescription.prototype.createConnectionPoints = function () {
        return [
            new ConnectionPoint_1.ConnectionPoint(0.5, 0, DiagramItem_1.ConnectionPointSide.North),
            new ConnectionPoint_1.ConnectionPoint(0.75, 0.5, DiagramItem_1.ConnectionPointSide.East),
            new ConnectionPoint_1.ConnectionPoint(0.5, 1, DiagramItem_1.ConnectionPointSide.South),
            new ConnectionPoint_1.ConnectionPoint(0.25, 0.5, DiagramItem_1.ConnectionPointSide.West)
        ];
    };
    TriangleShapeDescription.prototype.createShapePrimitives = function (shape) {
        var rect = shape.rectangle;
        var left = rect.x, top = rect.y, right = rect.right, bottom = rect.bottom;
        return [
            new PathPrimitive_1.PathPrimitive([
                new PathPrimitive_1.PathPrimitiveMoveToCommand(rect.center.x, top),
                new PathPrimitive_1.PathPrimitiveLineToCommand(right, bottom),
                new PathPrimitive_1.PathPrimitiveLineToCommand(left, bottom),
                new PathPrimitive_1.PathPrimitiveClosePathCommand()
            ], shape.style)
        ];
    };
    TriangleShapeDescription.prototype.calculateHeight = function (width) {
        return Math.sqrt(Math.pow(width, 2) - Math.pow(width / 2, 2));
    };
    TriangleShapeDescription.prototype.getTextRectangle = function (shape) {
        return new rectangle_1.Rectangle(shape.position.x + shape.size.width / 4, shape.position.y + shape.size.height / 2, shape.size.width / 2, shape.size.height / 2 - ShapeDescription_1.ShapeTextPadding)
            .nonNegativeSize();
    };
    TriangleShapeDescription.prototype.getSizeByText = function (textSize, _shape) {
        return new size_1.Size(textSize.width * 2, textSize.height * 2 + ShapeDescription_1.ShapeTextPadding);
    };
    return TriangleShapeDescription;
}(ShapeDescription_1.ShapeDescription));
exports.TriangleShapeDescription = TriangleShapeDescription;


/***/ }),
/* 125 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.DocumentShapeDescription = void 0;
var RectangleShapeDescription_1 = __webpack_require__(19);
var ShapeTypes_1 = __webpack_require__(1);
var PathPrimitive_1 = __webpack_require__(5);
var DiagramItem_1 = __webpack_require__(9);
var DocumentShapeDescription = (function (_super) {
    __extends(DocumentShapeDescription, _super);
    function DocumentShapeDescription() {
        return _super.call(this, undefined, true) || this;
    }
    Object.defineProperty(DocumentShapeDescription.prototype, "key", {
        get: function () { return ShapeTypes_1.ShapeTypes.Document; },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(DocumentShapeDescription.prototype, "keepRatioOnAutoSize", {
        get: function () { return false; },
        enumerable: false,
        configurable: true
    });
    DocumentShapeDescription.prototype.createShapePrimitives = function (shape) {
        return this.createDocumentPrimitives(shape.rectangle, shape.style);
    };
    DocumentShapeDescription.prototype.createDocumentPrimitives = function (rect, style) {
        var left = rect.x, top = rect.y, right = rect.right, bottom = rect.bottom, width = rect.width, height = rect.height;
        var cx = rect.center.x;
        var dy = height * DocumentShapeDescription.curveOffsetRatio;
        var primitives = [];
        return primitives.concat([
            new PathPrimitive_1.PathPrimitive([
                new PathPrimitive_1.PathPrimitiveMoveToCommand(left, top),
                new PathPrimitive_1.PathPrimitiveLineToCommand(right, top),
                new PathPrimitive_1.PathPrimitiveLineToCommand(right, bottom),
                new PathPrimitive_1.PathPrimitiveQuadraticCurveToCommand(right - width * 0.25, bottom - 2 * dy, cx, bottom - dy),
                new PathPrimitive_1.PathPrimitiveQuadraticCurveToCommand(left + width * 0.25, bottom + dy, left, bottom - dy),
                new PathPrimitive_1.PathPrimitiveClosePathCommand()
            ], style)
        ]);
    };
    DocumentShapeDescription.prototype.processConnectionPoint = function (shape, point) {
        var side = shape.getConnectionPointSide(point);
        if (side === DiagramItem_1.ConnectionPointSide.South)
            point.y -= shape.size.height * DocumentShapeDescription.curveOffsetRatio;
    };
    DocumentShapeDescription.prototype.getTextRectangle = function (shape) {
        var rect = shape.rectangle;
        return rect.clone().resize(0, -rect.height * DocumentShapeDescription.curveOffsetRatio);
    };
    DocumentShapeDescription.curveOffsetRatio = 0.1;
    return DocumentShapeDescription;
}(RectangleShapeDescription_1.RectangleShapeDescription));
exports.DocumentShapeDescription = DocumentShapeDescription;


/***/ }),
/* 126 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.CustomShapeDescription = void 0;
var ImagePrimitive_1 = __webpack_require__(127);
var rectangle_1 = __webpack_require__(13);
var size_1 = __webpack_require__(2);
var point_1 = __webpack_require__(0);
var ConnectionPoint_1 = __webpack_require__(45);
var DiagramItem_1 = __webpack_require__(9);
var ShapeWithImageDescription_1 = __webpack_require__(128);
var ShapeDescription_1 = __webpack_require__(7);
var ImageInfo_1 = __webpack_require__(51);
var ImageCache_1 = __webpack_require__(46);
var ImageLoader_1 = __webpack_require__(130);
var SvgElementPrimitive_1 = __webpack_require__(231);
var CustomShapeDescription = (function (_super) {
    __extends(CustomShapeDescription, _super);
    function CustomShapeDescription(properties, baseDescription) {
        var _this = _super.call(this, new size_1.Size(properties.defaultWidth || baseDescription && baseDescription.defaultSize.width || ShapeDescription_1.ShapeDefaultDimension, properties.defaultHeight || baseDescription && baseDescription.defaultSize.height || ShapeDescription_1.ShapeDefaultDimension)) || this;
        _this.properties = properties;
        _this.baseDescription = baseDescription;
        _this.imageLoader = new ImageLoader_1.ImageLoader(_this.updateSvgImage.bind(_this));
        _this.defaultText = properties.defaultText !== undefined ? properties.defaultText : baseDescription && baseDescription.getDefaultText();
        _this.defaultImageUrl = properties.defaultImageUrl || baseDescription && baseDescription.getDefaultImageUrl();
        _this.title = properties.title || baseDescription && baseDescription.getTitle() || _this.defaultText || "";
        _this.connectionPoints = _this.createConnectionPoints();
        if (properties.svgUrl) {
            _this.svgImage = new ImageInfo_1.ImageInfo(properties.svgUrl);
            var cachedImage = ImageCache_1.ImageCache.instance.createUnloadedInfoByShapeImageInfo(_this.svgImage);
            _this.imageLoader.load(cachedImage);
        }
        if (properties.svgToolboxUrl) {
            _this.svgToolboxImage = new ImageInfo_1.ImageInfo(properties.svgToolboxUrl);
            var cachedImage = ImageCache_1.ImageCache.instance.createUnloadedInfoByShapeImageInfo(_this.svgToolboxImage);
            _this.imageLoader.load(cachedImage);
        }
        return _this;
    }
    Object.defineProperty(CustomShapeDescription.prototype, "key", {
        get: function () { return this.properties.type; },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(CustomShapeDescription.prototype, "allowEditText", {
        get: function () { return this.properties.allowEditText !== false; },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(CustomShapeDescription.prototype, "allowEditImage", {
        get: function () { return this.baseDescription ? this.baseDescription.allowEditImage : this.properties.allowEditImage === true; },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(CustomShapeDescription.prototype, "enableChildren", {
        get: function () { return this.baseDescription && this.baseDescription.enableChildren; },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(CustomShapeDescription.prototype, "hasTemplate", {
        get: function () { return !!this.properties.createTemplate; },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(CustomShapeDescription.prototype, "minWidth", {
        get: function () { return this.properties.minWidth || this.baseDescription && this.baseDescription.minWidth; },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(CustomShapeDescription.prototype, "minHeight", {
        get: function () { return this.properties.minHeight || this.baseDescription && this.baseDescription.minHeight; },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(CustomShapeDescription.prototype, "maxWidth", {
        get: function () { return this.properties.maxWidth || this.baseDescription && this.baseDescription.maxWidth; },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(CustomShapeDescription.prototype, "maxHeight", {
        get: function () { return this.properties.maxHeight || this.baseDescription && this.baseDescription.maxHeight; },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(CustomShapeDescription.prototype, "keepRatioOnAutoSize", {
        get: function () { return this.properties.keepRatioOnAutoSize; },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(CustomShapeDescription.prototype, "toolboxSize", {
        get: function () {
            if (this.properties.toolboxWidthToHeightRatio)
                return new size_1.Size(this.defaultSize.width, this.defaultSize.width / this.properties.toolboxWidthToHeightRatio);
            return this.defaultSize;
        },
        enumerable: false,
        configurable: true
    });
    CustomShapeDescription.prototype.getTextAngle = function () {
        return (this.baseDescription && this.baseDescription.getTextAngle()) || _super.prototype.getTextAngle.call(this);
    };
    CustomShapeDescription.prototype.getTitle = function () {
        return this.title !== undefined ? this.title : _super.prototype.getTitle.call(this);
    };
    CustomShapeDescription.prototype.getDefaultText = function () {
        return this.defaultText !== undefined ? this.defaultText : _super.prototype.getDefaultText.call(this);
    };
    CustomShapeDescription.prototype.getDefaultImageUrl = function () {
        return this.defaultImageUrl !== undefined ? this.defaultImageUrl : _super.prototype.getDefaultImageUrl.call(this);
    };
    CustomShapeDescription.prototype.allowResizeHorizontally = function (shape) {
        if (this.properties.allowResize === false)
            return false;
        if (this.baseDescription)
            return this.baseDescription.allowResizeHorizontally(shape);
        return _super.prototype.allowResizeHorizontally.call(this, shape);
    };
    CustomShapeDescription.prototype.allowResizeVertically = function (shape) {
        if (this.properties.allowResize === false)
            return false;
        if (this.baseDescription)
            return this.baseDescription.allowResizeVertically(shape);
        return _super.prototype.allowResizeVertically.call(this, shape);
    };
    CustomShapeDescription.prototype.createConnectionPoints = function () {
        if (this.properties && this.properties.connectionPoints && this.properties.connectionPoints.length)
            return this.properties.connectionPoints.map(function (ptObj) {
                if (ptObj && typeof ptObj["x"] === "number" && typeof ptObj["y"] === "number") {
                    var side = typeof ptObj["side"] === "number" ? ptObj["side"] : DiagramItem_1.ConnectionPointSide.Undefined;
                    return new ConnectionPoint_1.ConnectionPoint(ptObj["x"], ptObj["y"], side);
                }
            }).filter(function (pt) { return pt; });
        return _super.prototype.createConnectionPoints.call(this);
    };
    CustomShapeDescription.prototype.getConnectionPointSides = function () {
        var result = {};
        for (var i = 0; i < this.connectionPoints.length; i++) {
            var pointSide = ShapeDescription_1.ShapeDescription.getConnectionPointSideByGeometry(this.connectionPoints[i]);
            if (!result[pointSide])
                result[pointSide] = [];
            result[pointSide].push(i);
        }
        return result;
    };
    CustomShapeDescription.prototype.getConnectionPointIndexForSide = function (side) {
        var connectionPointSides = this.getConnectionPointSides();
        var pointIndexes = connectionPointSides[side];
        if (pointIndexes) {
            var index = Math.floor(pointIndexes.length / 2);
            if (pointIndexes.length % 2 === 0)
                index--;
            return pointIndexes[index];
        }
        else {
            pointIndexes = connectionPointSides[(side + 1) % 4];
            if (pointIndexes)
                return pointIndexes[0];
            else {
                pointIndexes = connectionPointSides[(side + 3) % 4];
                if (pointIndexes)
                    return pointIndexes[pointIndexes.length - 1];
                else {
                    pointIndexes = connectionPointSides[(side + 2) % 4];
                    if (pointIndexes)
                        return pointIndexes[0];
                }
            }
        }
        return side;
    };
    CustomShapeDescription.prototype.createImagePrimitives = function (shape, forToolbox) {
        if (this.baseDescription)
            return this.baseDescription.createImagePrimitives(shape, forToolbox);
        return _super.prototype.createImagePrimitives.call(this, shape, forToolbox);
    };
    CustomShapeDescription.prototype.createShapePrimitives = function (shape, forToolbox) {
        var primitives = [];
        var _a = shape.rectangle, left = _a.x, top = _a.y, width = _a.width, height = _a.height;
        if (this.baseDescription)
            primitives = this.baseDescription.createShapePrimitives(shape, forToolbox);
        else {
            var svgImage = forToolbox && this.svgToolboxImage ? this.svgToolboxImage : this.svgImage;
            if (svgImage) {
                var svgLeft = left + (this.properties.svgLeft && !forToolbox ? this.properties.svgLeft * width : 0);
                var svgTop = top + (this.properties.svgTop && !forToolbox ? this.properties.svgTop * height : 0);
                var svgWidth = this.properties.svgWidth && !forToolbox ? this.properties.svgWidth * width : width;
                var svgHeight = this.properties.svgHeight && !forToolbox ? this.properties.svgHeight * height : height;
                primitives = primitives.concat([
                    new ImagePrimitive_1.ImagePrimitive(svgLeft, svgTop, svgWidth, svgHeight, svgImage.exportUrl)
                ]);
            }
        }
        var createTemplate = forToolbox && this.properties.createToolboxTemplate || this.properties.createTemplate;
        if (createTemplate) {
            var templateLeft = left + (this.properties.templateLeft && !forToolbox ? this.properties.templateLeft * width : 0);
            var templateTop = top + (this.properties.templateTop && !forToolbox ? this.properties.templateTop * height : 0);
            var templateWidth = this.properties.templateWidth && !forToolbox ? this.properties.templateWidth * width : width;
            var templateHeight = this.properties.templateHeight && !forToolbox ? this.properties.templateHeight * height : height;
            var nativeShape = this.properties.apiController ? this.properties.apiController.createNativeShape(shape) : shape.toNative();
            primitives = primitives.concat([
                new SvgElementPrimitive_1.SvgElementPrimitive(templateLeft, templateTop, templateWidth, templateHeight, createTemplate, this.properties.destroyTemplate, nativeShape)
            ]);
        }
        return primitives;
    };
    CustomShapeDescription.prototype.createParameters = function (parameters) {
        if (this.baseDescription)
            return this.baseDescription.createParameters(parameters);
        else
            return _super.prototype.createParameters.call(this, parameters);
    };
    CustomShapeDescription.prototype.normalizeParameters = function (shape, parameters) {
        if (this.baseDescription)
            this.baseDescription.normalizeParameters(shape, parameters);
        else
            _super.prototype.normalizeParameters.call(this, shape, parameters);
    };
    CustomShapeDescription.prototype.modifyParameters = function (shape, parameters, deltaX, deltaY) {
        if (this.baseDescription)
            this.baseDescription.modifyParameters(shape, parameters, deltaX, deltaY);
        else
            _super.prototype.modifyParameters.call(this, shape, parameters, deltaX, deltaY);
    };
    CustomShapeDescription.prototype.getParameterPoints = function (shape) {
        if (this.baseDescription)
            return this.baseDescription.getParameterPoints(shape);
        else
            return _super.prototype.getParameterPoints.call(this, shape);
    };
    CustomShapeDescription.prototype.getTextRectangle = function (shape) {
        if (this.baseDescription)
            return this.baseDescription.getTextRectangle(shape);
        else {
            var _a = shape.rectangle, left = _a.x, top_1 = _a.y, width = _a.width, height = _a.height;
            return new rectangle_1.Rectangle(left + (this.properties.textLeft ? this.properties.textLeft * width : 0), top_1 + (this.properties.textTop ? this.properties.textTop * height : 0), this.properties.textWidth ? this.properties.textWidth * width : width, this.properties.textHeight ? this.properties.textHeight * height : height);
        }
    };
    CustomShapeDescription.prototype.getSizeByText = function (textSize, shape) {
        if (this.baseDescription)
            return this.baseDescription.getSizeByText(textSize, shape);
        else {
            var textWidth = this.properties.textWidth;
            if (!textWidth)
                textWidth = 1;
            var textHeight = this.properties.textHeight;
            if (!textHeight)
                textHeight = 1;
            return new size_1.Size(textSize.width / textWidth, textSize.height / textHeight);
        }
    };
    CustomShapeDescription.prototype.getImageSize = function (shapeSize, includeMargins, forToolbox) {
        if (this.baseDescription) {
            if (this.baseDescription instanceof ShapeWithImageDescription_1.ShapeWithImageDescription)
                return this.baseDescription.getImageSize(shapeSize, includeMargins, forToolbox);
            return size_1.Size.empty();
        }
        return new size_1.Size(this.properties.imageWidth ? this.properties.imageWidth * shapeSize.width : shapeSize.width, this.properties.imageHeight ? this.properties.imageHeight * shapeSize.height : shapeSize.height)
            .nonNegativeSize();
    };
    CustomShapeDescription.prototype.getImagePlacementRectangle = function (rect, forToolbox) {
        if (this.baseDescription) {
            if (this.baseDescription instanceof ShapeWithImageDescription_1.ShapeWithImageDescription)
                return this.baseDescription.getImagePlacementRectangle(rect, forToolbox);
            return rectangle_1.Rectangle.fromGeometry(point_1.Point.zero(), size_1.Size.empty());
        }
        var left = rect.x, top = rect.y, width = rect.width, height = rect.height;
        return new rectangle_1.Rectangle(left + (this.properties.imageLeft && !forToolbox ? this.properties.imageLeft * width : 0), top + (this.properties.imageTop && !forToolbox ? this.properties.imageTop * height : 0), this.properties.imageWidth && !forToolbox ? this.properties.imageWidth * width : width, this.properties.imageHeight && !forToolbox ? this.properties.imageHeight * height : height);
    };
    CustomShapeDescription.prototype.updateSvgImage = function (cacheImageInfo) {
        var isToolboxImage = cacheImageInfo.imageUrl && cacheImageInfo.imageUrl === this.properties.svgToolboxUrl;
        var svgImage = isToolboxImage ? this.svgToolboxImage : this.svgImage;
        if (cacheImageInfo.base64)
            svgImage.loadBase64Content(cacheImageInfo.base64);
        else
            svgImage.setUnableToLoadFlag();
        if (!isToolboxImage)
            this.raiseShapeDescriptionChanged(this);
    };
    return CustomShapeDescription;
}(ShapeWithImageDescription_1.ShapeWithImageDescription));
exports.CustomShapeDescription = CustomShapeDescription;


/***/ }),
/* 127 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.ImagePrimitive = void 0;
var RenderHelper_1 = __webpack_require__(15);
var Primitive_1 = __webpack_require__(24);
var ImagePrimitive = (function (_super) {
    __extends(ImagePrimitive, _super);
    function ImagePrimitive(x, y, width, height, url, preserveAspectRatio, style, className) {
        if (preserveAspectRatio === void 0) { preserveAspectRatio = "none"; }
        var _this = _super.call(this, style, className) || this;
        _this.x = x;
        _this.y = y;
        _this.width = width;
        _this.height = height;
        _this.url = url;
        _this.preserveAspectRatio = preserveAspectRatio;
        return _this;
    }
    ImagePrimitive.prototype.createMainElement = function () {
        return document.createElementNS(RenderHelper_1.svgNS, "image");
    };
    ImagePrimitive.prototype.applyElementProperties = function (element, measurer) {
        this.setUnitAttribute(element, "x", this.x);
        this.setUnitAttribute(element, "y", this.y);
        this.setUnitAttribute(element, "width", this.width);
        this.setUnitAttribute(element, "height", this.height);
        this.setPositionCorrectionAttribute(element);
        element.setAttribute("href", this.url);
        element.setAttribute("preserveAspectRatio", this.preserveAspectRatio);
        _super.prototype.applyElementProperties.call(this, element, measurer);
    };
    return ImagePrimitive;
}(Primitive_1.SvgPrimitive));
exports.ImagePrimitive = ImagePrimitive;


/***/ }),
/* 128 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.ShapeWithImageDescription = exports.SHAPE_IMAGE_CLASSNAMES = exports.ShapeDefaultSize = exports.ShapeDefaultDimension = void 0;
var ShapeDescription_1 = __webpack_require__(7);
var rectangle_1 = __webpack_require__(13);
var size_1 = __webpack_require__(2);
var point_1 = __webpack_require__(0);
var unit_converter_1 = __webpack_require__(12);
var ImagePrimitive_1 = __webpack_require__(127);
var RectaglePrimitive_1 = __webpack_require__(21);
var GroupPrimitive_1 = __webpack_require__(39);
var Utils_1 = __webpack_require__(17);
var ClipPathPrimitive_1 = __webpack_require__(56);
var ShapeImageIndicator_1 = __webpack_require__(129);
exports.ShapeDefaultDimension = 1440;
exports.ShapeDefaultSize = new size_1.Size(exports.ShapeDefaultDimension, exports.ShapeDefaultDimension);
exports.SHAPE_IMAGE_CLASSNAMES = {
    IMAGE: "dxdi-image",
    IMAGE_PLACEHOLDER: "dxdi-image-placeholder",
    LOADING_INDICATOR: "dxdi-spinner",
    USER_PIC: "dxdi-user",
    WARNING_MARK: "dxdi-warning"
};
var ShapeWithImageDescription = (function (_super) {
    __extends(ShapeWithImageDescription, _super);
    function ShapeWithImageDescription(defaultSize, hasDefaultText) {
        if (defaultSize === void 0) { defaultSize = exports.ShapeDefaultSize.clone(); }
        var _this = _super.call(this, defaultSize, hasDefaultText) || this;
        _this.hasDefaultText = hasDefaultText;
        _this.defaultIconSize = 480;
        return _this;
    }
    Object.defineProperty(ShapeWithImageDescription.prototype, "enableImage", {
        get: function () { return true; },
        enumerable: false,
        configurable: true
    });
    ShapeWithImageDescription.prototype.getImageMargin = function (forToolbox) {
        return forToolbox ? unit_converter_1.UnitConverter.pixelsToTwips(2) : unit_converter_1.UnitConverter.pixelsToTwips(3);
    };
    ShapeWithImageDescription.prototype.createImagePrimitives = function (shape, forToolbox) {
        if (!this.enableImage)
            return [];
        var rect = this.getImagePlacementRectangle(shape.rectangle, forToolbox);
        if (forToolbox)
            return this.createImagePlaceholder(rect);
        var imagePrimitives = [];
        if (shape.image.isEmpty || shape.image.unableToLoad)
            imagePrimitives = imagePrimitives.concat(this.createEmptyImagePrimitives(rect, shape.image.unableToLoad));
        else if (shape.image.renderUrl === "")
            imagePrimitives = imagePrimitives.concat(this.createLoadingImagePrimitives(rect));
        else
            imagePrimitives = imagePrimitives.concat(this.createLoadedImagePrimitives(rect, shape.image.renderUrl));
        if (shape.image.renderUrl === "") {
            var clipPathId = Utils_1.RenderUtils.generateSvgElementId("clipImage");
            return [].concat([
                new GroupPrimitive_1.GroupPrimitive(imagePrimitives, exports.SHAPE_IMAGE_CLASSNAMES.IMAGE, undefined, clipPathId),
                new ClipPathPrimitive_1.ClipPathPrimitive(clipPathId, [new RectaglePrimitive_1.RectanglePrimitive(rect.x, rect.y, rect.width, rect.height)])
            ]);
        }
        else
            return imagePrimitives;
    };
    ShapeWithImageDescription.prototype.createImagePlaceholder = function (rect) {
        return [];
    };
    ShapeWithImageDescription.prototype.createLoadedImagePrimitives = function (rect, imageUrl) {
        return [
            new ImagePrimitive_1.ImagePrimitive(rect.x, rect.y, rect.width, rect.height, imageUrl, ShapeWithImageDescription.imageScalingRule, undefined, exports.SHAPE_IMAGE_CLASSNAMES.IMAGE)
        ];
    };
    ShapeWithImageDescription.prototype.createLoadingImagePrimitives = function (rect) {
        var loadingRect = this.getIconPlacementRectangle(rect);
        return [
            ShapeImageIndicator_1.ShapeImageIndicator.createLoadingIndicatorPrimitives(loadingRect.x, loadingRect.y, this.defaultIconSize, unit_converter_1.UnitConverter.pixelsToTwips(5), exports.SHAPE_IMAGE_CLASSNAMES.LOADING_INDICATOR)
        ];
    };
    ShapeWithImageDescription.prototype.createEmptyImagePrimitives = function (rect, showWarning) {
        var loadingRect = this.getIconPlacementRectangle(rect);
        var primitives = [];
        primitives = primitives.concat(this.createEmptyImagePrimitive(loadingRect));
        if (showWarning)
            primitives = primitives.concat(this.createWarningPrimitive(loadingRect));
        return primitives;
    };
    ShapeWithImageDescription.prototype.createEmptyImagePrimitive = function (rect) {
        return new GroupPrimitive_1.GroupPrimitive([]);
    };
    ShapeWithImageDescription.prototype.createWarningPrimitive = function (rect) {
        return new GroupPrimitive_1.GroupPrimitive([]);
    };
    ShapeWithImageDescription.prototype.getIconPlacementRectangle = function (rect) {
        var iconRect = rectangle_1.Rectangle.fromGeometry(new point_1.Point(rect.x, rect.y), new size_1.Size(this.defaultIconSize, this.defaultIconSize));
        if (iconRect.width < rect.width)
            iconRect.x = rect.x + (rect.width - iconRect.width) / 2;
        if (iconRect.height < rect.height)
            iconRect.y = rect.y + (rect.height - iconRect.height) / 2;
        return iconRect;
    };
    ShapeWithImageDescription.imageScalingRule = "xMidYMid meet";
    return ShapeWithImageDescription;
}(ShapeDescription_1.ShapeDescription));
exports.ShapeWithImageDescription = ShapeWithImageDescription;


/***/ }),
/* 129 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.ShapeImageIndicator = void 0;
var EllipsePrimitive_1 = __webpack_require__(55);
var PathPrimitive_1 = __webpack_require__(5);
var GroupPrimitive_1 = __webpack_require__(39);
var browser_1 = __webpack_require__(18);
var RectaglePrimitive_1 = __webpack_require__(21);
var unit_converter_1 = __webpack_require__(12);
var ShapeImageIndicator = (function () {
    function ShapeImageIndicator(x, y, size, borderThickness, className) {
        this.x = x;
        this.y = y;
        this.size = size;
        this.borderThickness = borderThickness;
        this.className = className;
        this.animationStarted = false;
    }
    ShapeImageIndicator.createLoadingIndicatorPrimitives = function (x, y, r, borderThickness, className) {
        var indicator = new ShapeImageIndicator(x, y, r, borderThickness, className);
        return indicator.createLoadingIndicatorPrimitive();
    };
    ShapeImageIndicator.createUserIconPrimitives = function (x, y, r, borderThickness, className) {
        var indicator = new ShapeImageIndicator(x, y, r, borderThickness, className);
        return indicator.createUserIconPrimitive();
    };
    ShapeImageIndicator.createWarningIconPrimitives = function (x, y, size, className) {
        var indicator = new ShapeImageIndicator(x, y, size, undefined, className);
        return indicator.createWarningIconPrimitive();
    };
    ShapeImageIndicator.prototype.rotate = function (element, centerX, centerY, timestamp) {
        if (!this.animationStarted)
            return;
        var angle = (Math.round(timestamp) % 1080) / 3;
        var transformAttributeValue = "rotate(" + angle + " " + centerX + " " + centerY + ")";
        element.setAttribute("transform", transformAttributeValue);
        this.animationRequestId = requestAnimationFrame(function (timestamp) {
            this.rotate(element, centerX, centerY, timestamp);
        }.bind(this));
    };
    ShapeImageIndicator.prototype.onApplyLoadingIndicatorElementProperties = function (element) {
        var _a = [unit_converter_1.UnitConverter.twipsToPixelsF(this.x + this.size / 2), unit_converter_1.UnitConverter.twipsToPixelsF(this.y + this.size / 2)], centerX = _a[0], centerY = _a[1];
        if (browser_1.Browser.IE) {
            this.animationRequestId = requestAnimationFrame(function (timestamp) {
                this.rotate(element, centerX, centerY, timestamp);
            }.bind(this));
            this.animationStarted = true;
        }
        else
            element.style.setProperty("transform-origin", centerX + "px " + centerY + "px");
    };
    ShapeImageIndicator.prototype.center = function () {
        return [unit_converter_1.UnitConverter.twipsToPixelsF(this.x + this.size / 2), unit_converter_1.UnitConverter.twipsToPixelsF(this.y + this.size / 2)];
    };
    ShapeImageIndicator.prototype.createLoadingIndicatorPrimitive = function () {
        var _a = this.center(), centerX = _a[0], centerY = _a[1];
        var radius = unit_converter_1.UnitConverter.twipsToPixelsF(this.size / 2 - this.borderThickness / 2);
        return new GroupPrimitive_1.GroupPrimitive([
            new EllipsePrimitive_1.EllipsePrimitive(centerX + "", centerY + "", radius + "", radius + ""),
            new PathPrimitive_1.PathPrimitive([
                new PathPrimitive_1.PathPrimitiveMoveToCommand((centerX + radius) + "", centerY + ""),
                new PathPrimitive_1.PathPrimitiveArcToCommand(radius + "", radius + "", 0, false, false, centerX + "", (centerY - radius) + "")
            ])
        ], this.className, undefined, undefined, this.onApplyLoadingIndicatorElementProperties.bind(this), this.onBeforeDispose.bind(this));
    };
    ShapeImageIndicator.prototype.createUserIconPrimitive = function () {
        var _a = this.center(), centerX = _a[0], centerY = _a[1];
        var radius = unit_converter_1.UnitConverter.twipsToPixelsF(this.size / 2 - this.borderThickness / 2);
        var sizeInPixels = unit_converter_1.UnitConverter.twipsToPixelsF(this.size);
        return new GroupPrimitive_1.GroupPrimitive([
            new EllipsePrimitive_1.EllipsePrimitive(centerX + "", centerY + "", radius + "", radius + "", undefined, "dxdi-background"),
            new EllipsePrimitive_1.EllipsePrimitive(centerX + "", centerY - sizeInPixels / 8 + "", sizeInPixels / 8 + "", sizeInPixels / 8 + ""),
            new PathPrimitive_1.PathPrimitive([
                new PathPrimitive_1.PathPrimitiveMoveToCommand(centerX + "", centerY + sizeInPixels / 16 + ""),
                new PathPrimitive_1.PathPrimitiveCubicCurveToCommand(centerX + 0.1375 * sizeInPixels + "", centerY + sizeInPixels / 16 + "", centerX + sizeInPixels / 4 + "", centerY
                    + 0.11875 * sizeInPixels + "", centerX + sizeInPixels / 4 + "", centerY + 0.1875 * sizeInPixels + ""),
                new PathPrimitive_1.PathPrimitiveLineToCommand(centerX + sizeInPixels / 4 + "", centerY + sizeInPixels / 4 + ""),
                new PathPrimitive_1.PathPrimitiveLineToCommand(centerX - sizeInPixels / 4 + "", centerY + sizeInPixels / 4 + ""),
                new PathPrimitive_1.PathPrimitiveLineToCommand(centerX - sizeInPixels / 4 + "", centerY + 0.1875 * sizeInPixels + ""),
                new PathPrimitive_1.PathPrimitiveCubicCurveToCommand(centerX - sizeInPixels / 4 + "", centerY + 0.11875 * sizeInPixels + "", centerX - 0.1375 * sizeInPixels + "", centerY
                    + sizeInPixels / 16 + "", centerX + "", centerY + sizeInPixels / 16 + ""),
                new PathPrimitive_1.PathPrimitiveClosePathCommand()
            ])
        ], this.className);
    };
    ShapeImageIndicator.prototype.createWarningIconPrimitive = function () {
        var _a = this.center(), centerX = _a[0], centerY = _a[1];
        var radius = unit_converter_1.UnitConverter.twipsToPixelsF(this.size / 2) - 1;
        var exclamationLineWidth = unit_converter_1.UnitConverter.twipsToPixelsF(this.size / 8);
        return new GroupPrimitive_1.GroupPrimitive([
            new EllipsePrimitive_1.EllipsePrimitive(centerX + "", centerY + "", radius + "", radius + ""),
            new RectaglePrimitive_1.RectanglePrimitive(centerX - exclamationLineWidth / 2 + 0.5 + "", centerY + radius - unit_converter_1.UnitConverter.twipsToPixelsF(this.size / 4) + "", exclamationLineWidth + "", exclamationLineWidth + ""),
            new RectaglePrimitive_1.RectanglePrimitive(centerX - exclamationLineWidth / 2 + 0.5 + "", centerY - radius + unit_converter_1.UnitConverter.twipsToPixelsF(this.size / 4) - exclamationLineWidth + "", exclamationLineWidth + "", radius + "")
        ], this.className);
    };
    ShapeImageIndicator.prototype.onBeforeDispose = function () {
        if (this.animationRequestId)
            cancelAnimationFrame(this.animationRequestId);
        this.animationStarted = false;
    };
    return ShapeImageIndicator;
}());
exports.ShapeImageIndicator = ShapeImageIndicator;


/***/ }),
/* 130 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.ImageLoader = void 0;
var ImageCache_1 = __webpack_require__(46);
var ImageLoader = (function () {
    function ImageLoader(loadedCallback) {
        this.loadedCallback = loadedCallback;
    }
    ImageLoader.prototype.load = function (data) {
        if (data.isLoaded)
            this.loadedCallback(data);
        else if (!data.isLoading)
            this.loadInner(data);
    };
    ImageLoader.prototype.loadInner = function (data) {
        var _this = this;
        if (data.imageUrl)
            this.loadPictureByUrl(data, function () { return _this.finalizeLoading(data, data); });
        else if (data.base64)
            this.loadPictureByBase64(data, function () { return _this.finalizeLoading(data, data); });
        return data;
    };
    ImageLoader.prototype.finalizeLoading = function (loadedData, existingInfo) {
        if (!existingInfo)
            existingInfo = ImageCache_1.ImageCache.instance.getImageData(loadedData.actualId);
        if (!existingInfo.isLoaded)
            ImageCache_1.ImageCache.instance.finalizeLoading(existingInfo, loadedData);
        this.loadedCallback(existingInfo);
    };
    ImageLoader.prototype.loadPictureByBase64 = function (data, imageLoaded) {
        var img = new Image();
        img.onload = function () {
            imageLoaded(data);
        };
        img.src = data.base64;
    };
    ImageLoader.prototype.loadPictureByUrl = function (data, imageLoaded) {
        var _this = this;
        var xhr = new XMLHttpRequest();
        try {
            xhr.onload = function () {
                var reader = new FileReader();
                reader.onloadend = function () {
                    data.base64 = reader.result;
                    _this.loadPictureByBase64(data, function (data) { return imageLoaded(data); });
                };
                reader.readAsDataURL(xhr.response);
            };
            xhr.onerror = function () { return imageLoaded(data); };
            xhr.onloadend = function () {
                if (xhr.status === 404)
                    imageLoaded(data);
            };
            xhr.open("GET", data.imageUrl, true);
            xhr.responseType = "blob";
            data.startLoading();
            xhr.send();
        }
        catch (_a) { }
    };
    return ImageLoader;
}());
exports.ImageLoader = ImageLoader;


/***/ }),
/* 131 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.ContainerDescription = exports.CONTAINER_EXPAND_BUTTON_SIGN_RATIO = exports.CONTAINER_EXPAND_BUTTON_RECT_RATIO = exports.CONTAINER_HEADER_TOOLBOX_SIZE_RATIO = exports.CONTAINER_HEADER_SIZE = void 0;
var ShapeDescription_1 = __webpack_require__(7);
var size_1 = __webpack_require__(2);
var ShapeTypes_1 = __webpack_require__(1);
var RectaglePrimitive_1 = __webpack_require__(21);
var PathPrimitive_1 = __webpack_require__(5);
var Utils_1 = __webpack_require__(17);
var Event_1 = __webpack_require__(11);
var GroupPrimitive_1 = __webpack_require__(39);
var ConnectionPoint_1 = __webpack_require__(45);
var DiagramItem_1 = __webpack_require__(9);
var LocalizationService_1 = __webpack_require__(36);
exports.CONTAINER_HEADER_SIZE = 360;
exports.CONTAINER_HEADER_TOOLBOX_SIZE_RATIO = 0.2;
exports.CONTAINER_EXPAND_BUTTON_RECT_RATIO = 0.5;
exports.CONTAINER_EXPAND_BUTTON_SIGN_RATIO = 0.3;
var ContainerDescription = (function (_super) {
    __extends(ContainerDescription, _super);
    function ContainerDescription(defaultSize) {
        if (defaultSize === void 0) { defaultSize = new size_1.Size(ShapeDescription_1.ShapeDefaultDimension * 2, ShapeDescription_1.ShapeDefaultDimension * 1.5); }
        return _super.call(this, defaultSize, true) || this;
    }
    Object.defineProperty(ContainerDescription.prototype, "enableChildren", {
        get: function () { return true; },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(ContainerDescription.prototype, "keepRatioOnAutoSize", {
        get: function () { return false; },
        enumerable: false,
        configurable: true
    });
    ContainerDescription.prototype.getDefaultText = function () {
        return LocalizationService_1.DiagramLocalizationService.shapeTexts[ShapeTypes_1.ShapeTypes.Container];
    };
    ContainerDescription.prototype.createConnectionPoints = function () {
        return [
            new ConnectionPoint_1.ConnectionPoint(0.25, 0, DiagramItem_1.ConnectionPointSide.North),
            new ConnectionPoint_1.ConnectionPoint(0.5, 0, DiagramItem_1.ConnectionPointSide.North),
            new ConnectionPoint_1.ConnectionPoint(0.75, 0, DiagramItem_1.ConnectionPointSide.North),
            new ConnectionPoint_1.ConnectionPoint(1, 0.25, DiagramItem_1.ConnectionPointSide.East),
            new ConnectionPoint_1.ConnectionPoint(1, 0.5, DiagramItem_1.ConnectionPointSide.East),
            new ConnectionPoint_1.ConnectionPoint(1, 0.75, DiagramItem_1.ConnectionPointSide.East),
            new ConnectionPoint_1.ConnectionPoint(0.75, 1, DiagramItem_1.ConnectionPointSide.South),
            new ConnectionPoint_1.ConnectionPoint(0.5, 1, DiagramItem_1.ConnectionPointSide.South),
            new ConnectionPoint_1.ConnectionPoint(0.25, 1, DiagramItem_1.ConnectionPointSide.South),
            new ConnectionPoint_1.ConnectionPoint(0, 0.75, DiagramItem_1.ConnectionPointSide.West),
            new ConnectionPoint_1.ConnectionPoint(0, 0.5, DiagramItem_1.ConnectionPointSide.West),
            new ConnectionPoint_1.ConnectionPoint(0, 0.25, DiagramItem_1.ConnectionPointSide.West)
        ];
    };
    ContainerDescription.prototype.getConnectionPointIndexForItem = function (item, connectionPointIndex) {
        var shapeConnectionPoints = item && item.getConnectionPoints();
        if (shapeConnectionPoints.length === 4)
            return connectionPointIndex * 3 + 1;
        return connectionPointIndex;
    };
    ContainerDescription.prototype.getConnectionPointIndexForSide = function (side) {
        return side * 3 + 1;
    };
    ContainerDescription.prototype.createShapePrimitives = function (shape, forToolbox) {
        var _a = shape.rectangle, left = _a.x, top = _a.y, width = _a.width, height = _a.height;
        var primitives = [];
        if (shape.expanded)
            primitives = primitives.concat([
                new RectaglePrimitive_1.RectanglePrimitive(left, top, width, height, shape.style)
            ]);
        return primitives.concat(this.createHeaderPrimitives(shape, forToolbox));
    };
    ContainerDescription.prototype.createExpandButtonPrimitives = function (shape, rect) {
        var commands = [
            new PathPrimitive_1.PathPrimitiveMoveToCommand(rect.x + rect.width * ((1 - exports.CONTAINER_EXPAND_BUTTON_SIGN_RATIO) / 2), rect.center.y),
            new PathPrimitive_1.PathPrimitiveLineToCommand(rect.x + rect.width * ((1 - exports.CONTAINER_EXPAND_BUTTON_SIGN_RATIO) / 2 + exports.CONTAINER_EXPAND_BUTTON_SIGN_RATIO), rect.center.y)
        ];
        if (!shape.expanded)
            commands = commands.concat([
                new PathPrimitive_1.PathPrimitiveMoveToCommand(rect.center.x, rect.y + rect.height * ((1 - exports.CONTAINER_EXPAND_BUTTON_SIGN_RATIO) / 2)),
                new PathPrimitive_1.PathPrimitiveLineToCommand(rect.center.x, rect.y + rect.height * ((1 - exports.CONTAINER_EXPAND_BUTTON_SIGN_RATIO) / 2 + exports.CONTAINER_EXPAND_BUTTON_SIGN_RATIO)),
            ]);
        var buttonRect = rect.clone().inflate(-rect.width * (1 - exports.CONTAINER_EXPAND_BUTTON_RECT_RATIO) / 2, -rect.height * (1 - exports.CONTAINER_EXPAND_BUTTON_RECT_RATIO) / 2);
        return [
            new GroupPrimitive_1.GroupPrimitive([
                new RectaglePrimitive_1.RectanglePrimitive(buttonRect.x, buttonRect.y, buttonRect.width, buttonRect.height, shape.style),
                new PathPrimitive_1.PathPrimitive(commands, shape.style)
            ], "shape-expand-btn", null, null, function (el) {
                Utils_1.RenderUtils.setElementEventData(el, Event_1.MouseEventElementType.ShapeExpandButton, shape.key);
            })
        ];
    };
    return ContainerDescription;
}(ShapeDescription_1.ShapeDescription));
exports.ContainerDescription = ContainerDescription;


/***/ }),
/* 132 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.CardBaseDescription = void 0;
var ShapeDescription_1 = __webpack_require__(7);
var rectangle_1 = __webpack_require__(13);
var size_1 = __webpack_require__(2);
var ShapeWithImageDescription_1 = __webpack_require__(128);
var RoundedRectanglePrimitive_1 = __webpack_require__(235);
var PathPrimitive_1 = __webpack_require__(5);
var GroupPrimitive_1 = __webpack_require__(39);
var ShapeImageIndicator_1 = __webpack_require__(129);
var ShapeTypes_1 = __webpack_require__(1);
var LocalizationService_1 = __webpack_require__(36);
var unit_converter_1 = __webpack_require__(12);
var point_1 = __webpack_require__(0);
var CardBaseDescription = (function (_super) {
    __extends(CardBaseDescription, _super);
    function CardBaseDescription(defaultSize) {
        if (defaultSize === void 0) { defaultSize = new size_1.Size(ShapeDescription_1.ShapeDefaultDimension, 26 / 46 * ShapeDescription_1.ShapeDefaultDimension); }
        return _super.call(this, defaultSize, true) || this;
    }
    Object.defineProperty(CardBaseDescription.prototype, "keepRatioOnAutoSize", {
        get: function () { return false; },
        enumerable: false,
        configurable: true
    });
    CardBaseDescription.prototype.getDefaultText = function () {
        return LocalizationService_1.DiagramLocalizationService.shapeTexts[ShapeTypes_1.ShapeTypes.Card];
    };
    CardBaseDescription.prototype.createShapePrimitives = function (shape, forToolbox) {
        var _a = shape.rectangle, left = _a.x, top = _a.y, width = _a.width, height = _a.height;
        return [
            new RoundedRectanglePrimitive_1.RoundedRectanglePrimitive(left, top, width, height, (forToolbox) ? 30 : 60, (forToolbox) ? 30 : 60, shape.style)
        ];
    };
    CardBaseDescription.prototype.createImagePlaceholder = function (rect) {
        return [
            new RoundedRectanglePrimitive_1.RoundedRectanglePrimitive(rect.x, rect.y, rect.width, rect.height, unit_converter_1.UnitConverter.pixelsToTwips(2), unit_converter_1.UnitConverter.pixelsToTwips(2), undefined, ShapeWithImageDescription_1.SHAPE_IMAGE_CLASSNAMES.IMAGE_PLACEHOLDER)
        ];
    };
    CardBaseDescription.prototype.createEmptyImagePrimitive = function (rect) {
        return ShapeImageIndicator_1.ShapeImageIndicator.createUserIconPrimitives(rect.x, rect.y, this.defaultIconSize, unit_converter_1.UnitConverter.pixelsToTwips(1), ShapeWithImageDescription_1.SHAPE_IMAGE_CLASSNAMES.USER_PIC);
    };
    CardBaseDescription.prototype.createWarningPrimitive = function (rect) {
        return ShapeImageIndicator_1.ShapeImageIndicator.createWarningIconPrimitives(rect.x + this.defaultIconSize / 2, rect.y + this.defaultIconSize / 2, this.defaultIconSize / 2, ShapeWithImageDescription_1.SHAPE_IMAGE_CLASSNAMES.WARNING_MARK);
    };
    CardBaseDescription.prototype.getTextRectangle = function (shape) {
        var rect = shape.rectangle;
        var textRectangle = rect.clone().inflate(-ShapeDescription_1.ShapeTextPadding, -ShapeDescription_1.ShapeTextPadding);
        var imgBlockSize = this.getImageSize(rect.createSize(), true);
        if (this.isTextAfterImage)
            textRectangle.moveRectangle(this.isHorizontal ? imgBlockSize.width : 0, this.isHorizontal ? 0 : imgBlockSize.height);
        textRectangle.resize(this.isHorizontal ? -imgBlockSize.width : 0, this.isHorizontal ? 0 : -imgBlockSize.height);
        return textRectangle.nonNegativeSize();
    };
    CardBaseDescription.prototype.getSizeByText = function (textSize, _shape) {
        var size = textSize.clone().offset(ShapeDescription_1.ShapeTextPadding * 2, ShapeDescription_1.ShapeTextPadding * 2);
        var imgBlockSize = this.getImageSizeByTextBlockSize(size);
        if (this.isHorizontal)
            size.width += imgBlockSize.width;
        else
            size.height += imgBlockSize.height;
        return size;
    };
    CardBaseDescription.prototype.createTextPrimitives = function (shape, forToolbox) {
        if (forToolbox)
            return this.createGraphicalTextRepresentation(shape.rectangle);
        else
            return _super.prototype.createTextPrimitives.call(this, shape, forToolbox);
    };
    CardBaseDescription.prototype.createGraphicalTextRepresentation = function (rect) {
        var textRect = new rectangle_1.Rectangle(0, 0, 0, 0);
        var imgBlockSize = this.getImageSize(rect.createSize(), true, true);
        if (this.isHorizontal) {
            var horizontalShift = this.isTextAfterImage ? rect.width / 2 - unit_converter_1.UnitConverter.pixelsToTwips(2) : 0;
            textRect.x = rect.x + horizontalShift + unit_converter_1.UnitConverter.pixelsToTwips(4);
            textRect.y = rect.y + unit_converter_1.UnitConverter.pixelsToTwips(5);
            textRect.width = imgBlockSize.width - unit_converter_1.UnitConverter.pixelsToTwips(4);
            textRect.height = rect.height - unit_converter_1.UnitConverter.pixelsToTwips(6);
        }
        else {
            var verticalShift = this.isTextAfterImage ? rect.height / 2 - unit_converter_1.UnitConverter.pixelsToTwips(2) : 0;
            textRect.x = rect.x + rect.width / 4;
            textRect.y = rect.y + verticalShift + unit_converter_1.UnitConverter.pixelsToTwips(4);
            textRect.width = rect.width / 2;
            textRect.height = imgBlockSize.height - unit_converter_1.UnitConverter.pixelsToTwips(2);
        }
        return this.createTextRepresentationPrimitives(textRect);
    };
    CardBaseDescription.prototype.getImagePlacementRectangle = function (rect, forToolbox) {
        var imageSize = this.getImageSize(rect.createSize(), false, forToolbox);
        var imageRectangle = rectangle_1.Rectangle.fromGeometry(new point_1.Point(rect.x, rect.y), imageSize);
        var imgBlockSize = this.getImageSize(rect.createSize(), true, forToolbox);
        if (this.isHorizontal && this.isTextAfterImage)
            imageRectangle.x += this.getImageMargin(forToolbox);
        else if (this.isHorizontal)
            imageRectangle.x = rect.right - imgBlockSize.width - this.getImageMargin(forToolbox);
        if (!this.isHorizontal && !this.isTextAfterImage)
            imageRectangle.y = rect.bottom - imgBlockSize.height - this.getImageMargin(forToolbox);
        else
            imageRectangle.y += this.getImageMargin(forToolbox);
        if (!this.isHorizontal)
            imageRectangle.x += (rect.width - imageRectangle.width) / 2;
        return imageRectangle;
    };
    CardBaseDescription.prototype.createTextRepresentationPrimitives = function (rect) {
        var lineHeight = unit_converter_1.UnitConverter.pixelsToTwips(unit_converter_1.UnitConverter.twipsToPixels(rect.height / 3));
        return [
            new GroupPrimitive_1.GroupPrimitive([
                new PathPrimitive_1.PathPrimitive([
                    new PathPrimitive_1.PathPrimitiveMoveToCommand(rect.x, rect.y),
                    new PathPrimitive_1.PathPrimitiveLineToCommand(rect.x + rect.width, rect.y)
                ]),
                new PathPrimitive_1.PathPrimitive([
                    new PathPrimitive_1.PathPrimitiveMoveToCommand(rect.x, rect.y + lineHeight),
                    new PathPrimitive_1.PathPrimitiveLineToCommand(rect.x + rect.width, rect.y + lineHeight)
                ]),
                new PathPrimitive_1.PathPrimitive([
                    new PathPrimitive_1.PathPrimitiveMoveToCommand(rect.x, rect.y + lineHeight * 2),
                    new PathPrimitive_1.PathPrimitiveLineToCommand(rect.x + rect.width * 0.66, rect.y + lineHeight * 2)
                ])
            ], "dxdi-shape-text")
        ];
    };
    return CardBaseDescription;
}(ShapeWithImageDescription_1.ShapeWithImageDescription));
exports.CardBaseDescription = CardBaseDescription;


/***/ }),
/* 133 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.ImporterBase = void 0;
var Model_1 = __webpack_require__(62);
var Shape_1 = __webpack_require__(14);
var ImporterBase = (function () {
    function ImporterBase(shapeDescriptionManager) {
        this.shapeDescriptionManager = shapeDescriptionManager;
    }
    ImporterBase.prototype.import = function () {
        var model = new Model_1.DiagramModel();
        var obj = this.getObject();
        this.importPageSettings(model, this.getPageObject(obj));
        var shapes = this.importShapes(this.getShapeObjects(obj));
        for (var i = 0; i < shapes.length; i++) {
            var shape = shapes[i];
            if (model.findItem(shape.key))
                throw Error("Item key is duplicated");
            model.pushItem(shape);
        }
        var connectors = this.importConnectors(this.getConnectorObjects(obj));
        for (var i = 0; i < connectors.length; i++) {
            var connector = connectors[i];
            connector.endItem = model.findItem(connector["endItemKey"]) || undefined;
            delete connector["endItemKey"];
            connector.beginItem = model.findItem(connector["beginItemKey"]) || undefined;
            delete connector["beginItemKey"];
            if (model.findItem(connector.key))
                throw Error("Item key is duplicated");
            model.pushItem(connector);
            this.updateConnections(connector);
        }
        this.updateChildren(model.items, function (key) { return model.findItem(key); });
        return model;
    };
    ImporterBase.prototype.importItems = function (model) {
        var result = [];
        var obj = this.getObject();
        var itemHash = {};
        var shapes = this.importShapes(this.getShapeObjects(obj));
        var key;
        for (var i = 0; i < shapes.length; i++) {
            var shape = shapes[i];
            var oldKey = shape.key;
            key = model.getNextKey();
            shape.key = key;
            itemHash[oldKey] = shape;
            if (shape.dataKey !== undefined)
                shape.dataKey = undefined;
            result.push(shape);
        }
        var connectors = this.importConnectors(this.getConnectorObjects(obj));
        for (var i = 0; i < connectors.length; i++) {
            var connector = connectors[i];
            var oldKey = connector.key;
            key = model.getNextKey();
            connector.key = key;
            itemHash[oldKey] = connector;
            if (connector.dataKey !== undefined)
                connector.dataKey = undefined;
            var endItemKey = connector["endItemKey"];
            connector.endItem = itemHash[endItemKey];
            delete connector["endItemKey"];
            var beginItemKey = connector["beginItemKey"];
            connector.beginItem = itemHash[beginItemKey];
            delete connector["beginItemKey"];
            result.push(connector);
            this.updateConnections(connector);
        }
        this.updateChildren(result, function (key) { return itemHash[key]; });
        return result;
    };
    ImporterBase.prototype.importItemsData = function (model) {
        var obj = this.getObject();
        var shapes = this.importShapes(this.getShapeObjects(obj));
        var shapeDataKeys = {};
        for (var i = 0; i < shapes.length; i++) {
            var srcShape = shapes[i];
            var destShape = void 0;
            if (srcShape.dataKey !== undefined)
                destShape = model.findShapeByDataKey(srcShape.dataKey);
            if (destShape) {
                destShape.dataKey = srcShape.dataKey;
                shapeDataKeys[srcShape.key] = srcShape.dataKey;
                destShape.locked = srcShape.locked;
                destShape.position = srcShape.position.clone();
                destShape.expanded = srcShape.expanded;
                if (srcShape.expandedSize)
                    destShape.expandedSize = srcShape.expandedSize.clone();
                destShape.size = srcShape.size.clone();
                destShape.parameters = srcShape.parameters.clone();
                destShape.style = srcShape.style.clone();
                destShape.styleText = srcShape.styleText.clone();
                destShape.zIndex = srcShape.zIndex;
                destShape.text = srcShape.text;
                destShape.description = srcShape.description;
                destShape.image = srcShape.image.clone();
            }
        }
        var connectors = this.importConnectors(this.getConnectorObjects(obj));
        for (var i = 0; i < connectors.length; i++) {
            var srcConnector = connectors[i];
            var destConnector = void 0;
            if (srcConnector.dataKey !== undefined)
                destConnector = model.findConnectorByDataKey(srcConnector.dataKey);
            if (!destConnector)
                destConnector = model.findConnectorByBeginEndDataKeys(shapeDataKeys[srcConnector["beginItemKey"]], shapeDataKeys[srcConnector["endItemKey"]]);
            if (destConnector) {
                destConnector.dataKey = srcConnector.dataKey;
                destConnector.locked = srcConnector.locked;
                destConnector.points = srcConnector.points.slice();
                destConnector.properties = srcConnector.properties.clone();
                destConnector.style = srcConnector.style.clone();
                destConnector.endConnectionPointIndex = srcConnector.endConnectionPointIndex;
                destConnector.beginConnectionPointIndex = srcConnector.beginConnectionPointIndex;
                destConnector.texts = srcConnector.texts.clone();
                destConnector.styleText = srcConnector.styleText.clone();
                destConnector.zIndex = srcConnector.zIndex;
            }
        }
    };
    ImporterBase.prototype.importShapes = function (shapeObjs) {
        var result = [];
        if (!shapeObjs)
            return result;
        if (!Array.isArray(shapeObjs))
            throw Error("Invalid Format");
        for (var i = 0; i < shapeObjs.length; i++) {
            var shapeObj = shapeObjs[i];
            var shape = this.importShape(shapeObj);
            result.push(shape);
            result = result.concat(this.importShapeChildren(shapeObj, shape));
        }
        return result;
    };
    ImporterBase.prototype.importConnectors = function (connectorObjs) {
        var result = [];
        if (!connectorObjs)
            return result;
        if (!Array.isArray(connectorObjs))
            throw Error("Invalid Format");
        for (var i = 0; i < connectorObjs.length; i++) {
            var shapeObj = connectorObjs[i];
            result.push(this.importConnector(shapeObj));
        }
        return result;
    };
    ImporterBase.prototype.updateChildren = function (items, findItem) {
        items.forEach(function (item) {
            if (item instanceof Shape_1.Shape && item["childKeys"]) {
                item["childKeys"].forEach(function (childKey) {
                    var child = findItem(childKey);
                    if (child) {
                        if (item.children.indexOf(child) === -1)
                            item.children.push(child);
                        child.container = item;
                    }
                });
                delete item["childKeys"];
            }
        });
    };
    ImporterBase.prototype.updateConnections = function (connector) {
        if (connector.endItem)
            if (connector.endItem instanceof Shape_1.Shape) {
                connector.endItem.attachedConnectors.push(connector);
                connector.points[connector.points.length - 1] = connector.endItem.getConnectionPointPosition(connector.endConnectionPointIndex, connector.points[connector.points.length - 2]);
            }
            else {
                connector.endItem = undefined;
                connector.endConnectionPointIndex = -1;
            }
        if (connector.beginItem)
            if (connector.beginItem instanceof Shape_1.Shape) {
                connector.beginItem.attachedConnectors.push(connector);
                connector.points[0] = connector.beginItem.getConnectionPointPosition(connector.beginConnectionPointIndex, connector.points[1]);
            }
            else {
                connector.beginItem = undefined;
                connector.beginConnectionPointIndex = -1;
            }
    };
    ImporterBase.prototype.assert = function (value, type) {
        if (value === undefined)
            throw Error("Invalid Format");
        if (type !== undefined && typeof value !== type)
            throw Error("Invalid Format");
    };
    return ImporterBase;
}());
exports.ImporterBase = ImporterBase;


/***/ }),
/* 134 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.StylePropertyCommandBase = void 0;
var SimpleCommandBase_1 = __webpack_require__(10);
var StylePropertyCommandBase = (function (_super) {
    __extends(StylePropertyCommandBase, _super);
    function StylePropertyCommandBase() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    StylePropertyCommandBase.prototype.lockInputPositionUpdating = function () {
        return true;
    };
    return StylePropertyCommandBase;
}(SimpleCommandBase_1.SimpleCommandBase));
exports.StylePropertyCommandBase = StylePropertyCommandBase;


/***/ }),
/* 135 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.ChangeStylePropertyCommandBase = void 0;
var StylePropertyCommandBase_1 = __webpack_require__(134);
var ChangeStylePropertyCommandBase = (function (_super) {
    __extends(ChangeStylePropertyCommandBase, _super);
    function ChangeStylePropertyCommandBase() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    ChangeStylePropertyCommandBase.prototype.executeCore = function (state, parameter) {
        var _this = this;
        this.control.history.beginTransaction();
        var items = this.control.selection.getSelectedItems();
        parameter = this.processParameter(parameter);
        items.forEach(function (item) {
            var styleProperty = _this.getStyleProperty();
            _this.control.history.addAndRedo(_this.createHistoryItem(item, styleProperty, parameter));
        });
        this.updateInputPosition(parameter);
        this.control.history.endTransaction();
        return true;
    };
    ChangeStylePropertyCommandBase.prototype.getDefaultValue = function () {
        return this.getDefaultStyleObj()[this.getStyleProperty()];
    };
    ChangeStylePropertyCommandBase.prototype.processParameter = function (parameter) {
        return parameter;
    };
    return ChangeStylePropertyCommandBase;
}(StylePropertyCommandBase_1.StylePropertyCommandBase));
exports.ChangeStylePropertyCommandBase = ChangeStylePropertyCommandBase;


/***/ }),
/* 136 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.ChangeConnectorPropertyCommand = void 0;
var ChangeConnectorPropertyHistoryItem_1 = __webpack_require__(88);
var SimpleCommandBase_1 = __webpack_require__(10);
var ChangeConnectorPropertyCommand = (function (_super) {
    __extends(ChangeConnectorPropertyCommand, _super);
    function ChangeConnectorPropertyCommand() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    ChangeConnectorPropertyCommand.prototype.getValue = function () {
        return this.control.selection.inputPosition.getCurrentConnectorPropertyValue(this.getPropertyName());
    };
    ChangeConnectorPropertyCommand.prototype.getDefaultValue = function () {
        return this.getPropertyDefaultValue();
    };
    ChangeConnectorPropertyCommand.prototype.executeCore = function (state, parameter) {
        var _this = this;
        this.control.history.beginTransaction();
        var connectors = this.control.selection.getSelectedConnectors();
        connectors.forEach(function (connector) {
            var propertyName = _this.getPropertyName();
            _this.control.history.addAndRedo(new ChangeConnectorPropertyHistoryItem_1.ChangeConnectorPropertyHistoryItem(connector.key, propertyName, parameter));
        });
        this.control.selection.inputPosition.setConnectorPropertyValue(this.getPropertyName(), parameter);
        this.control.history.endTransaction();
        return true;
    };
    ChangeConnectorPropertyCommand.prototype.lockInputPositionUpdating = function () {
        return true;
    };
    ChangeConnectorPropertyCommand.prototype.isEnabled = function () {
        var connectors = this.control.selection.getSelectedConnectors();
        return _super.prototype.isEnabled.call(this) && connectors.length > 0;
    };
    return ChangeConnectorPropertyCommand;
}(SimpleCommandBase_1.SimpleCommandBase));
exports.ChangeConnectorPropertyCommand = ChangeConnectorPropertyCommand;


/***/ }),
/* 137 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.AutoLayoutTreeVerticalCommand = void 0;
var AutoLayoutCommandBase_1 = __webpack_require__(76);
var WideTree_1 = __webpack_require__(97);
var LayoutSettings_1 = __webpack_require__(20);
var AutoLayoutTreeVerticalCommand = (function (_super) {
    __extends(AutoLayoutTreeVerticalCommand, _super);
    function AutoLayoutTreeVerticalCommand() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    AutoLayoutTreeVerticalCommand.prototype.createLayoutSettings = function () {
        var gridSize = this.control.settings.snapToGrid ? this.control.settings.gridSize : undefined;
        var settings = new LayoutSettings_1.TreeLayoutSettings(gridSize);
        settings.orientation = LayoutSettings_1.DataLayoutOrientation.Vertical;
        return settings;
    };
    AutoLayoutTreeVerticalCommand.prototype.createLayout = function (settings, graph) {
        return new WideTree_1.TreeLayoutBuilder(settings, graph).build();
    };
    return AutoLayoutTreeVerticalCommand;
}(AutoLayoutCommandBase_1.AutoLayoutCommandBase));
exports.AutoLayoutTreeVerticalCommand = AutoLayoutTreeVerticalCommand;


/***/ }),
/* 138 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.GraphLayout = void 0;
var Utils_1 = __webpack_require__(3);
var NodeLayout_1 = __webpack_require__(71);
var GraphLayout = (function () {
    function GraphLayout() {
        this.nodeKeys = [];
        this.nodeToLayout = {};
        this.edgeToPosition = {};
    }
    GraphLayout.prototype.forEachNode = function (callback) {
        var _this = this;
        this.nodeKeys.forEach(function (nk) { return callback(_this.nodeToLayout[nk], nk); });
    };
    GraphLayout.prototype.reduce = function (callback, initValue) {
        var _this = this;
        return this.nodeKeys.reduce(function (acc, key, index) { return callback(acc, _this.nodeToLayout[key], index); }, initValue);
    };
    GraphLayout.prototype.addNode = function (nodeLayout) {
        if (this.nodeToLayout[nodeLayout.key])
            throw Error("Node layout is already registered");
        this.nodeKeys.push(nodeLayout.key);
        this.nodeToLayout[nodeLayout.key] = nodeLayout;
        return nodeLayout;
    };
    GraphLayout.prototype.hasNode = function (key) {
        return !!this.nodeToLayout[key];
    };
    GraphLayout.prototype.addEdge = function (edgeLayout) {
        if (this.edgeToPosition[edgeLayout.key])
            throw Error("Edge layout is already registered");
        this.edgeToPosition[edgeLayout.key] = edgeLayout;
    };
    GraphLayout.prototype.getRectangle = function (includeMargins) {
        var _this = this;
        return Utils_1.GeometryUtils.getCommonRectangle(this.nodeKeys.map(function (nk) { return _this.nodeToLayout[nk].rectangle; }));
    };
    GraphLayout.prototype.offsetNodes = function (deltaX, deltaY) {
        var _this = this;
        if (deltaX === void 0) { deltaX = 0; }
        if (deltaY === void 0) { deltaY = 0; }
        var layout = new GraphLayout();
        this.nodeKeys.forEach(function (nk) {
            var nl = _this.nodeToLayout[nk];
            layout.addNode(new NodeLayout_1.NodeLayout(nl.info, nl.position.clone().offset(deltaX, deltaY)));
        });
        layout.copyEdges(this);
        return layout;
    };
    GraphLayout.prototype.extend = function (layout) {
        var _this = this;
        layout.forEachNode(function (nl) { return _this.addNode(nl); });
        this.copyEdges(layout);
    };
    GraphLayout.prototype.copyEdges = function (source) {
        var _this = this;
        Object.keys(source.edgeToPosition).forEach(function (e) {
            var edge = source.edgeToPosition[e];
            _this.addEdge(new NodeLayout_1.EdgeLayout(edge.key, edge.beginIndex, edge.endIndex));
        });
    };
    return GraphLayout;
}());
exports.GraphLayout = GraphLayout;


/***/ }),
/* 139 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.LayoutBuilder = void 0;
var LayoutSettings_1 = __webpack_require__(20);
var LayoutBuilder = (function () {
    function LayoutBuilder(settings, graph) {
        this.settings = settings;
        this.graph = graph;
    }
    LayoutBuilder.prototype.getBreadthNodeSizeCore = function (node, excludeMargins) {
        var size = this.settings.orientation === LayoutSettings_1.DataLayoutOrientation.Vertical ? node.size.width : node.size.height;
        if (!excludeMargins)
            size += this.settings.orientation === LayoutSettings_1.DataLayoutOrientation.Vertical ? (node.margin.left + node.margin.right) : (node.margin.top + node.margin.bottom);
        return size;
    };
    LayoutBuilder.prototype.getDepthNodeSizeCore = function (node) {
        return this.settings.orientation === LayoutSettings_1.DataLayoutOrientation.Horizontal ?
            (node.size.width + node.margin.left + node.margin.right) :
            (node.size.height + node.margin.top + node.margin.bottom);
    };
    LayoutBuilder.prototype.chooseDirectionValue = function (near, far) {
        return this.settings.direction === LayoutSettings_1.LogicalDirectionKind.Forward ? near : far;
    };
    LayoutBuilder.prototype.getDirectionValue = function (value) {
        return this.settings.direction === LayoutSettings_1.LogicalDirectionKind.Forward ? value : -value;
    };
    LayoutBuilder.prototype.getComponentOffset = function (graphLayout) {
        var rect = graphLayout.getRectangle(true);
        var offset = this.settings.orientation === LayoutSettings_1.DataLayoutOrientation.Vertical ? rect.width : rect.height;
        return offset + this.settings.componentSpacing;
    };
    LayoutBuilder.prototype.setComponentOffset = function (graphLayout, offset) {
        return this.settings.orientation === LayoutSettings_1.DataLayoutOrientation.Vertical ?
            graphLayout.offsetNodes(offset) :
            graphLayout.offsetNodes(0, offset);
    };
    return LayoutBuilder;
}());
exports.LayoutBuilder = LayoutBuilder;


/***/ }),
/* 140 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.CanvasManager = void 0;
var ModelChange_1 = __webpack_require__(99);
var CanvasManagerBase_1 = __webpack_require__(42);
var CanvasManager = (function (_super) {
    __extends(CanvasManager, _super);
    function CanvasManager() {
        var _this = _super !== null && _super.apply(this, arguments) || this;
        _this.pendingChanges = {};
        _this.pendingRemoveChanges = {};
        _this.updatesLock = 0;
        return _this;
    }
    CanvasManager.prototype.beginUpdate = function () {
        this.updatesLock++;
    };
    CanvasManager.prototype.endUpdate = function () {
        this.updatesLock--;
        if (this.updatesLock === 0)
            this.applyPendingChanges();
    };
    CanvasManager.prototype.getPendingChanges = function () {
        var _this = this;
        return Object.keys(this.pendingChanges).map(function (key) { return _this.pendingChanges[key]; });
    };
    CanvasManager.prototype.getPendingRemoveChanges = function () {
        var _this = this;
        return Object.keys(this.pendingRemoveChanges).map(function (key) { return _this.pendingRemoveChanges[key]; });
    };
    CanvasManager.prototype.applyPendingChanges = function () {
        var removeChanges = this.getPendingRemoveChanges();
        if (removeChanges.length) {
            this.applyChangesCore(removeChanges);
            this.pendingRemoveChanges = {};
        }
        var changes = this.getPendingChanges();
        if (changes.length) {
            this.applyChangesCore(changes);
            this.pendingChanges = {};
        }
    };
    CanvasManager.prototype.applyChangesCore = function (changes) {
        var _this = this;
        var changesToReapply = [];
        changes.forEach(function (change) {
            if (!_this.applyChange(change))
                changesToReapply.push(change);
        });
        if (changesToReapply.length && changesToReapply.length !== changes.length)
            this.applyChangesCore(changesToReapply);
    };
    CanvasManager.prototype.postponeChanges = function (changes) {
        var _this = this;
        changes.forEach(function (change) {
            if (change.type === ModelChange_1.ItemChangeType.Remove) {
                _this.pendingRemoveChanges[change.key] = change;
                delete _this.pendingChanges[change.key];
            }
            else if (!_this.pendingChanges[change.key]) {
                if (_this.pendingRemoveChanges[change.key] && change.type !== ModelChange_1.ItemChangeType.Create)
                    throw new Error("Incorrect model changes sequence.");
                _this.pendingChanges[change.key] = change;
            }
            else if (change.type === ModelChange_1.ItemChangeType.Create)
                _this.pendingChanges[change.key] = change;
            else if (change.type === ModelChange_1.ItemChangeType.UpdateStructure) {
                if (_this.pendingChanges[change.key].type === ModelChange_1.ItemChangeType.UpdateProperties)
                    _this.pendingChanges[change.key] = change;
            }
            else if (change.type === ModelChange_1.ItemChangeType.UpdateProperties) {
                if (_this.pendingChanges[change.key].type === ModelChange_1.ItemChangeType.Update)
                    _this.pendingChanges[change.key] = change;
            }
            else if (change.type === ModelChange_1.ItemChangeType.UpdateClassName)
                if (_this.pendingChanges[change.key].type === ModelChange_1.ItemChangeType.UpdateClassName)
                    _this.pendingChanges[change.key] = change;
        });
    };
    CanvasManager.prototype.applyOrPostponeChanges = function (changes) {
        if (this.updatesLock === 0)
            this.applyChangesCore(changes);
        else
            this.postponeChanges(changes);
    };
    CanvasManager.prototype.notifyModelChanged = function (changes) {
        this.applyOrPostponeChanges(changes);
    };
    CanvasManager.prototype.notifyPageColorChanged = function (color) { };
    CanvasManager.prototype.notifyPageSizeChanged = function (pageSize, pageLandscape) { };
    return CanvasManager;
}(CanvasManagerBase_1.CanvasManagerBase));
exports.CanvasManager = CanvasManager;


/***/ }),
/* 141 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.PasteSelectionCommandBase = void 0;
var ClipboardCommand_1 = __webpack_require__(101);
var Importer_1 = __webpack_require__(119);
var Shape_1 = __webpack_require__(14);
var ImportShapeHistoryItem_1 = __webpack_require__(266);
var Connector_1 = __webpack_require__(6);
var ImportConnectorHistoryItem_1 = __webpack_require__(267);
var ModelUtils_1 = __webpack_require__(4);
var SetSelectionHistoryItem_1 = __webpack_require__(68);
var point_1 = __webpack_require__(0);
var unit_converter_1 = __webpack_require__(12);
var PasteSelectionCommandBase = (function (_super) {
    __extends(PasteSelectionCommandBase, _super);
    function PasteSelectionCommandBase() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    PasteSelectionCommandBase.prototype.isEnabled = function () {
        return _super.prototype.isEnabled.call(this) && (this.isPasteSupportedByBrowser() || ClipboardCommand_1.ClipboardCommand.clipboardData !== undefined);
    };
    PasteSelectionCommandBase.prototype.isVisible = function () {
        return this.isPasteSupportedByBrowser() || ClipboardCommand_1.ClipboardCommand.clipboardData !== undefined;
    };
    PasteSelectionCommandBase.prototype.parseClipboardData = function (data) {
        var items = [];
        var importer = new Importer_1.Importer(this.control.shapeDescriptionManager, data);
        items = importer.importItems(this.control.model);
        var offset = this.getEventPositionOffset(items, this.control.contextMenuPosition);
        offset = this.getCorrectedOffsetByModel(items, offset);
        for (var i = 0; i < items.length; i++) {
            var item = items[i];
            if (item instanceof Shape_1.Shape)
                item.position.offsetByPoint(offset);
            else if (item instanceof Connector_1.Connector)
                item.points.forEach(function (p) { return p.offsetByPoint(offset); });
        }
        return items;
    };
    PasteSelectionCommandBase.prototype.getCorrectedOffsetByModel = function (items, baseOffset) {
        var topLeftItem = items.reduce(function (acc, item) {
            var x = item instanceof Shape_1.Shape ? item.position.x : item instanceof Connector_1.Connector ? item.getMinX() : Number.MAX_VALUE;
            var y = item instanceof Shape_1.Shape ? item.position.y : item instanceof Connector_1.Connector ? item.getMinY() : Number.MAX_VALUE;
            if (y < acc.y || (y === acc.y && x < acc.x)) {
                acc.topLeftItem = item;
                acc.x = x;
                acc.y = y;
            }
            return acc;
        }, {
            topLeftItem: items[0],
            x: Number.MAX_VALUE,
            y: Number.MAX_VALUE
        }).topLeftItem;
        if (topLeftItem instanceof Shape_1.Shape) {
            var newPoint = this.getShapeCorrectedPosition(this.control.model, topLeftItem, baseOffset);
            return new point_1.Point(newPoint.x - topLeftItem.position.x, newPoint.y - topLeftItem.position.y);
        }
        else if (topLeftItem instanceof Connector_1.Connector) {
            var newPoints = this.getConnectorCorrectedPoints(this.control.model, topLeftItem, baseOffset);
            return new point_1.Point(topLeftItem.points[0].x - newPoints[0].x, topLeftItem.points[0].y - newPoints[0].y);
        }
    };
    PasteSelectionCommandBase.prototype.executeCore = function (state, parameter) {
        var _this = this;
        var ret = true;
        if (parameter)
            this.performPaste(parameter);
        else
            this.getClipboardData(function (data) {
                ret = _this.execute(data);
            });
        return ret;
    };
    PasteSelectionCommandBase.prototype.addItemForSortingRecursive = function (itemsHashtable, item) {
        if (itemsHashtable[item.key])
            return itemsHashtable[item.key];
        if (item instanceof Connector_1.Connector) {
            if (item.endItem)
                itemsHashtable[item.key] = this.addItemForSortingRecursive(itemsHashtable, item.endItem) - 0.5;
            else if (item.beginItem)
                itemsHashtable[item.key] = this.addItemForSortingRecursive(itemsHashtable, item.beginItem) + 0.5;
            else
                itemsHashtable[item.key] = -1;
            return itemsHashtable[item.key];
        }
        if (item.attachedConnectors.length === 0)
            return itemsHashtable[item.key] = 0;
        else
            for (var i = 0; i < item.attachedConnectors.length; i++) {
                var beginItem = item.attachedConnectors[i].beginItem;
                if (item.attachedConnectors[i].endItem === item && beginItem && beginItem !== item.attachedConnectors[i].endItem)
                    return itemsHashtable[item.key] = this.addItemForSortingRecursive(itemsHashtable, beginItem) + 1;
                else
                    return itemsHashtable[item.key] = 0;
            }
    };
    PasteSelectionCommandBase.prototype.getSortedPasteItems = function (items) {
        var sortedItems = [];
        var connectors = [];
        var itemsHashtable = {};
        for (var i = 0; i < items.length; i++) {
            var item = items[i];
            if (item instanceof Shape_1.Shape)
                sortedItems.push(item);
            else if (item instanceof Connector_1.Connector) {
                connectors.push(item);
                this.addItemForSortingRecursive(itemsHashtable, item);
            }
        }
        connectors.sort(function (a, b) { return itemsHashtable[b.key] - itemsHashtable[a.key]; });
        return sortedItems.concat(connectors);
    };
    PasteSelectionCommandBase.prototype.performPaste = function (data) {
        this.control.beginUpdateCanvas();
        this.control.history.beginTransaction();
        var ids = [];
        var items = this.parseClipboardData(data);
        items = this.getSortedPasteItems(items);
        for (var i = 0; i < items.length; i++) {
            var item = items[i];
            if (item instanceof Shape_1.Shape)
                this.control.history.addAndRedo(new ImportShapeHistoryItem_1.ImportShapeHistoryItem(item));
            else if (item instanceof Connector_1.Connector)
                this.control.history.addAndRedo(new ImportConnectorHistoryItem_1.ImportConnectorHistoryItem(item));
            var containerKey = item.container && item.container.key;
            if (!containerKey || ids.indexOf(containerKey) === -1)
                ids.push(item.key);
        }
        ModelUtils_1.ModelUtils.tryUpdateModelRectangle(this.control.history);
        this.control.history.addAndRedo(new SetSelectionHistoryItem_1.SetSelectionHistoryItem(this.control.selection, ids));
        this.control.history.endTransaction();
        this.control.endUpdateCanvas();
        this.control.barManager.updateItemsState();
    };
    PasteSelectionCommandBase.prototype.getShapeCorrectedPosition = function (model, shape, initOffset) {
        var position = shape.position.clone().offsetByPoint(initOffset);
        while (model.findShapeAtPosition(position))
            position.offset(PasteSelectionCommandBase.positionOffset, PasteSelectionCommandBase.positionOffset);
        return position;
    };
    PasteSelectionCommandBase.prototype.getConnectorCorrectedPoints = function (model, connector, initOffset) {
        var points = connector.points.map(function (p) { return p.clone().offsetByPoint(initOffset); });
        while (model.findConnectorAtPoints(points))
            points.forEach(function (pt) {
                pt.x += PasteSelectionCommandBase.positionOffset;
                pt.y += PasteSelectionCommandBase.positionOffset;
            });
        return points;
    };
    Object.defineProperty(PasteSelectionCommandBase.prototype, "isPermissionsRequired", {
        get: function () { return true; },
        enumerable: false,
        configurable: true
    });
    PasteSelectionCommandBase.positionOffset = unit_converter_1.UnitConverter.pixelsToTwips(10);
    return PasteSelectionCommandBase;
}(ClipboardCommand_1.ClipboardCommand));
exports.PasteSelectionCommandBase = PasteSelectionCommandBase;


/***/ }),
/* 142 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.AutoLayoutLayeredHorizontalCommand = void 0;
var AutoLayoutCommandBase_1 = __webpack_require__(76);
var Sugiyama_1 = __webpack_require__(80);
var LayoutSettings_1 = __webpack_require__(20);
var AutoLayoutLayeredHorizontalCommand = (function (_super) {
    __extends(AutoLayoutLayeredHorizontalCommand, _super);
    function AutoLayoutLayeredHorizontalCommand() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    AutoLayoutLayeredHorizontalCommand.prototype.createLayoutSettings = function () {
        var settings = new LayoutSettings_1.LayoutSettings();
        settings.orientation = LayoutSettings_1.DataLayoutOrientation.Horizontal;
        return settings;
    };
    AutoLayoutLayeredHorizontalCommand.prototype.createLayout = function (settings, graph) {
        return new Sugiyama_1.SugiyamaLayoutBuilder(settings, graph).build();
    };
    return AutoLayoutLayeredHorizontalCommand;
}(AutoLayoutCommandBase_1.AutoLayoutCommandBase));
exports.AutoLayoutLayeredHorizontalCommand = AutoLayoutLayeredHorizontalCommand;


/***/ }),
/* 143 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.AutoLayoutTreeHorizontalCommand = void 0;
var AutoLayoutCommandBase_1 = __webpack_require__(76);
var WideTree_1 = __webpack_require__(97);
var LayoutSettings_1 = __webpack_require__(20);
var AutoLayoutTreeHorizontalCommand = (function (_super) {
    __extends(AutoLayoutTreeHorizontalCommand, _super);
    function AutoLayoutTreeHorizontalCommand() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    AutoLayoutTreeHorizontalCommand.prototype.createLayoutSettings = function () {
        var gridSize = this.control.settings.snapToGrid ? this.control.settings.gridSize : undefined;
        var settings = new LayoutSettings_1.TreeLayoutSettings(gridSize);
        settings.orientation = LayoutSettings_1.DataLayoutOrientation.Horizontal;
        return settings;
    };
    AutoLayoutTreeHorizontalCommand.prototype.createLayout = function (settings, graph) {
        return new WideTree_1.TreeLayoutBuilder(settings, graph).build();
    };
    return AutoLayoutTreeHorizontalCommand;
}(AutoLayoutCommandBase_1.AutoLayoutCommandBase));
exports.AutoLayoutTreeHorizontalCommand = AutoLayoutTreeHorizontalCommand;


/***/ }),
/* 144 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.AutoLayoutLayeredVerticalCommand = void 0;
var AutoLayoutCommandBase_1 = __webpack_require__(76);
var Sugiyama_1 = __webpack_require__(80);
var LayoutSettings_1 = __webpack_require__(20);
var AutoLayoutLayeredVerticalCommand = (function (_super) {
    __extends(AutoLayoutLayeredVerticalCommand, _super);
    function AutoLayoutLayeredVerticalCommand() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    AutoLayoutLayeredVerticalCommand.prototype.createLayoutSettings = function () {
        var settings = new LayoutSettings_1.LayoutSettings();
        settings.orientation = LayoutSettings_1.DataLayoutOrientation.Vertical;
        return settings;
    };
    AutoLayoutLayeredVerticalCommand.prototype.createLayout = function (settings, graph) {
        return new Sugiyama_1.SugiyamaLayoutBuilder(settings, graph).build();
    };
    return AutoLayoutLayeredVerticalCommand;
}(AutoLayoutCommandBase_1.AutoLayoutCommandBase));
exports.AutoLayoutLayeredVerticalCommand = AutoLayoutLayeredVerticalCommand;


/***/ }),
/* 145 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.ChangeLockedCommand = void 0;
var ModelUtils_1 = __webpack_require__(4);
var SimpleCommandBase_1 = __webpack_require__(10);
var ChangeLockedCommand = (function (_super) {
    __extends(ChangeLockedCommand, _super);
    function ChangeLockedCommand() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    ChangeLockedCommand.prototype.isEnabled = function () {
        var _this = this;
        var items = this.control.selection.getSelectedItems(true);
        var enabled = false;
        items.forEach(function (item) { if (item.locked !== _this.getLockState())
            enabled = true; });
        return _super.prototype.isEnabled.call(this) && enabled;
    };
    ChangeLockedCommand.prototype.executeCore = function (state, parameter) {
        ModelUtils_1.ModelUtils.changeSelectionLocked(this.control.history, this.control.model, this.control.selection, this.getLockState());
        return true;
    };
    return ChangeLockedCommand;
}(SimpleCommandBase_1.SimpleCommandBase));
exports.ChangeLockedCommand = ChangeLockedCommand;


/***/ }),
/* 146 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.ChangeShapeImageHistoryItem = void 0;
var HistoryItem_1 = __webpack_require__(8);
var ImageInfo_1 = __webpack_require__(51);
var ChangeShapeImageHistoryItem = (function (_super) {
    __extends(ChangeShapeImageHistoryItem, _super);
    function ChangeShapeImageHistoryItem(item, imageUrl) {
        var _this = _super.call(this) || this;
        _this.shapeKey = item.key;
        _this.imageUrl = imageUrl;
        return _this;
    }
    ChangeShapeImageHistoryItem.prototype.redo = function (manipulator) {
        var item = manipulator.model.findShape(this.shapeKey);
        this.oldImage = item.image;
        manipulator.changeShapeImage(item, new ImageInfo_1.ImageInfo(this.imageUrl));
    };
    ChangeShapeImageHistoryItem.prototype.undo = function (manipulator) {
        var item = manipulator.model.findShape(this.shapeKey);
        manipulator.changeShapeImage(item, this.oldImage);
    };
    return ChangeShapeImageHistoryItem;
}(HistoryItem_1.HistoryItem));
exports.ChangeShapeImageHistoryItem = ChangeShapeImageHistoryItem;


/***/ }),
/* 147 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.MouseHandlerDefaultState = void 0;
var Event_1 = __webpack_require__(11);
var MouseHandlerMoveConnectorPointState_1 = __webpack_require__(305);
var MouseHandlerResizeShapeState_1 = __webpack_require__(306);
var MouseHandlerMoveConnectorSideState_1 = __webpack_require__(307);
var MouseHandlerDragParameterPointState_1 = __webpack_require__(308);
var MouseHandlerCreateConnectorState_1 = __webpack_require__(309);
var MouseHandlerMoveConnectorOrthogonalSideState_1 = __webpack_require__(310);
var MouseHandlerToolboxDraggingState_1 = __webpack_require__(311);
var MouseHandlerMoveConnectorTextState_1 = __webpack_require__(312);
var MouseHandlerDefaultStateBase_1 = __webpack_require__(149);
var MouseHandlerMoveShapeState_1 = __webpack_require__(319);
var Connector_1 = __webpack_require__(6);
var MouseHandlerMoveConnectorState_1 = __webpack_require__(320);
var MouseHandlerDefaultState = (function (_super) {
    __extends(MouseHandlerDefaultState, _super);
    function MouseHandlerDefaultState() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    MouseHandlerDefaultState.prototype.finish = function () {
        this.visualizerManager.resetConnectionPoints();
        _super.prototype.finish.call(this);
    };
    MouseHandlerDefaultState.prototype.onMouseDownCore = function (evt) {
        if (this.handler.canScrollPage(evt))
            this.startScrolling(evt);
        else if (evt.button === Event_1.MouseButton.Left && evt.source.type === Event_1.MouseEventElementType.ConnectorText) {
            this.handler.changeSingleSelection(evt.source.key);
            this.handler.switchState(new MouseHandlerMoveConnectorTextState_1.MouseHandlerMoveConnectorTextState(this.handler, this.history, this.model));
        }
        else if (evt.button === Event_1.MouseButton.Left && evt.source.type === Event_1.MouseEventElementType.ShapeResizeBox)
            this.handler.switchState(new MouseHandlerResizeShapeState_1.MouseHandlerResizeShapeState(this.handler, this.history, this.model, this.selection, this.visualizerManager, this.settings));
        else if (evt.button === Event_1.MouseButton.Left && evt.source.type === Event_1.MouseEventElementType.ShapeParameterBox)
            this.handler.switchState(new MouseHandlerDragParameterPointState_1.MouseHandlerDragParameterPointState(this.handler, this.history, this.model));
        else if (evt.button === Event_1.MouseButton.Left && evt.source.type === Event_1.MouseEventElementType.ConnectorPoint)
            this.handler.switchState(new MouseHandlerMoveConnectorPointState_1.MouseHandlerMoveConnectorPointState(this.handler, this.history, this.model, this.visualizerManager));
        else if (evt.button === Event_1.MouseButton.Left && evt.source.type === Event_1.MouseEventElementType.ConnectorSide)
            this.handler.switchState(new MouseHandlerMoveConnectorSideState_1.MouseHandlerMoveConnectorSideState(this.handler, this.history, this.model));
        else if (evt.button === Event_1.MouseButton.Left && evt.source.type === Event_1.MouseEventElementType.ConnectorOrthogonalSide)
            this.handler.switchState(new MouseHandlerMoveConnectorOrthogonalSideState_1.MouseHandlerMoveConnectorOrthogonalSideState(this.handler, this.history, this.model));
        else if (evt.button === Event_1.MouseButton.Left && evt.source.type === Event_1.MouseEventElementType.ShapeConnectionPoint)
            this.handler.switchState(new MouseHandlerCreateConnectorState_1.MouseHandlerCreateConnectorState(this.handler, this.history, this.model, this.visualizerManager, this.shapeDescriptionManager, this.selection));
        else
            _super.prototype.onMouseDownCore.call(this, evt);
    };
    MouseHandlerDefaultState.prototype.onDragDiagramItemOnMouseDown = function (evt) {
        if (!this.handler.canAddDiagramItemToSelection(evt))
            _super.prototype.onDragDiagramItemOnMouseDown.call(this, evt);
        else if (evt.source.type === Event_1.MouseEventElementType.Shape)
            this.handler.switchState(new MouseHandlerMoveShapeState_1.MouseHandlerMoveShapeState(this.handler, this.history, this.model, this.selection, this.visualizerManager));
        else if (evt.source.type === Event_1.MouseEventElementType.Connector)
            this.handler.switchState(new MouseHandlerMoveConnectorState_1.MouseHandlerMoveConnectorState(this.handler, this.history, this.model, this.selection, this.visualizerManager));
    };
    MouseHandlerDefaultState.prototype.onDragStart = function (evt) {
        this.handler.switchState(new MouseHandlerToolboxDraggingState_1.MouseHandlerBeforeToolboxDraggingState(this.handler, this.history, this.model, this.selection, this.visualizerManager, this.shapeDescriptionManager));
        this.handler.state.onDragStart(evt);
    };
    MouseHandlerDefaultState.prototype.onMouseMoveCore = function (evt) {
        this.updateConnectionsOnMouseMove(evt);
        _super.prototype.onMouseMoveCore.call(this, evt);
    };
    MouseHandlerDefaultState.prototype.onMouseUp = function (evt) {
        if (this.handler.canRemoveDiagramItemToSelection(evt))
            this.handler.removeDiagramItemFromSelection(evt.button, evt.source.key);
        else
            _super.prototype.onMouseUp.call(this, evt);
    };
    MouseHandlerDefaultState.prototype.updateConnectionsOnMouseMove = function (evt) {
        var item = this.model.findItem(evt.source.key);
        this.visualizerManager.updateConnections(item, evt.source.type, evt.source.value);
    };
    MouseHandlerDefaultState.prototype.canDragObjectOnMouseDown = function (key) {
        return true;
    };
    MouseHandlerDefaultState.prototype.canExpandContainerOnMouseDown = function (key) {
        return true;
    };
    MouseHandlerDefaultState.prototype.canClearSelectionOnMouseDown = function () {
        return false;
    };
    MouseHandlerDefaultState.prototype.canSelectOnMouseUp = function (key) {
        return false;
    };
    MouseHandlerDefaultState.prototype.canClearSelectionOnMouseUp = function () {
        return true;
    };
    MouseHandlerDefaultState.prototype.onConnectionPointsShow = function (key, points) {
        var _this = this;
        var shape = this.model.findShape(key);
        if (shape)
            points.forEach(function (point, index) {
                point.allowed = _this.handler.canPerformChangeConnectionOnUpdateUI(undefined, { item: shape, position: Connector_1.ConnectorPosition.Begin, connectionPointIndex: index });
            });
    };
    return MouseHandlerDefaultState;
}(MouseHandlerDefaultStateBase_1.MouseHandlerDefaultStateBase));
exports.MouseHandlerDefaultState = MouseHandlerDefaultState;


/***/ }),
/* 148 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.MouseHandlerMoveConnectorPointStateBase = void 0;
var Connector_1 = __webpack_require__(6);
var Event_1 = __webpack_require__(11);
var MouseHandlerDraggingState_1 = __webpack_require__(34);
var DeleteConnectionHistoryItem_1 = __webpack_require__(67);
var AddConnectionHistoryItem_1 = __webpack_require__(48);
var ModelUtils_1 = __webpack_require__(4);
var MouseHandlerMoveConnectorPointStateBase = (function (_super) {
    __extends(MouseHandlerMoveConnectorPointStateBase, _super);
    function MouseHandlerMoveConnectorPointStateBase(handler, history, model, visualizerManager) {
        var _this = _super.call(this, handler, history) || this;
        _this.model = model;
        _this.visualizerManager = visualizerManager;
        return _this;
    }
    MouseHandlerMoveConnectorPointStateBase.prototype.finish = function () {
        this.visualizerManager.resetConnectionTarget();
        this.visualizerManager.resetConnectionPoints();
        _super.prototype.finish.call(this);
    };
    MouseHandlerMoveConnectorPointStateBase.prototype.onMouseDown = function (evt) {
        _super.prototype.onMouseDown.call(this, evt);
        if (this.connector)
            this.handler.addInteractingItem(this.connector);
    };
    MouseHandlerMoveConnectorPointStateBase.prototype.onMouseMove = function (evt) {
        _super.prototype.onMouseMove.call(this, evt);
        if (!this.allowAttachToObjects(evt, false, false)) {
            this.visualizerManager.resetConnectionTarget();
            this.visualizerManager.resetConnectionPoints();
        }
        else if (this.connector) {
            var item = this.connector.getExtremeItem(this.pointPosition);
            this.visualizerManager.setConnectionTarget(item, evt.source.type);
            var pointIndex = this.connector.getExtremeConnectionPointIndex(this.pointPosition);
            if (!item && this.oppositeConnectionPointIndex !== -1 || !this.allowAttachToObjects(evt, true, false))
                item = this.model.findItem(evt.source.key);
            this.visualizerManager.setConnectionPoints(item, evt.source.type, pointIndex, true);
        }
    };
    MouseHandlerMoveConnectorPointStateBase.prototype.onApplyChanges = function (evt) {
        var point = this.getSnappedPoint(evt, evt.modelPoint);
        if (this.pointPosition !== undefined) {
            if (this.oppositePointPosition === undefined) {
                this.oppositePointPosition = this.getOppositePointPosition();
                this.oppositeItem = this.connector.getExtremeItem(this.oppositePointPosition);
                this.oppositeConnectionPointIndex = this.connector.getExtremeConnectionPointIndex(this.oppositePointPosition);
            }
            this.targetItem = this.model.findItem(evt.source.key);
            var item = this.allowAttachToObjects(evt, true, true) ? this.targetItem : undefined;
            var connectionPointIndex = -1;
            if (evt.source.type === Event_1.MouseEventElementType.ShapeConnectionPoint)
                connectionPointIndex = parseInt(evt.source.value);
            if (item && (evt.source.type === Event_1.MouseEventElementType.Shape || evt.source.type === Event_1.MouseEventElementType.ShapeConnectionPoint) &&
                (this.connector.getExtremeItem(this.oppositePointPosition) !== item ||
                    (connectionPointIndex !== -1 && this.oppositeConnectionPointIndex !== -1 &&
                        connectionPointIndex !== this.oppositeConnectionPointIndex))) {
                if (this.connector.getExtremeItem(this.pointPosition) !== item ||
                    this.connector.getExtremeConnectionPointIndex(this.pointPosition) !== connectionPointIndex) {
                    if (this.connector.getExtremeItem(this.pointPosition))
                        this.history.addAndRedo(new DeleteConnectionHistoryItem_1.DeleteConnectionHistoryItem(this.connector, this.pointPosition));
                    this.history.addAndRedo(new AddConnectionHistoryItem_1.AddConnectionHistoryItem(this.connector, item, connectionPointIndex, this.pointPosition));
                    if (this.oppositeItem)
                        this.updateOppositeItemConnectionPointIndex(connectionPointIndex);
                }
                point = item.getConnectionPointPosition(connectionPointIndex, this.connector.points[this.pointIndex + (this.pointPosition === Connector_1.ConnectorPosition.End ? -1 : 1)]);
                this.visualizerManager.setConnectionPointIndex(connectionPointIndex);
            }
            else if (this.connector.getExtremeItem(this.pointPosition)) {
                this.history.addAndRedo(new DeleteConnectionHistoryItem_1.DeleteConnectionHistoryItem(this.connector, this.pointPosition));
                if (this.oppositeItem)
                    this.updateOppositeItemConnectionPointIndex(this.oppositeConnectionPointIndex);
            }
        }
        ModelUtils_1.ModelUtils.moveConnectorPoint(this.history, this.connector, this.pointIndex, point);
        ModelUtils_1.ModelUtils.updateConnectorAttachedPoints(this.history, this.model, this.connector);
        this.handler.tryUpdateModelSize();
    };
    MouseHandlerMoveConnectorPointStateBase.prototype.updateOppositeItemConnectionPointIndex = function (connectionPointIndex) {
        var pointIndex = connectionPointIndex === -1 ? -1 : this.oppositeConnectionPointIndex;
        if (pointIndex !== this.connector.getExtremeConnectionPointIndex(this.oppositePointPosition)) {
            this.history.addAndRedo(new DeleteConnectionHistoryItem_1.DeleteConnectionHistoryItem(this.connector, this.oppositePointPosition));
            this.history.addAndRedo(new AddConnectionHistoryItem_1.AddConnectionHistoryItem(this.connector, this.oppositeItem, pointIndex, this.oppositePointPosition));
        }
    };
    MouseHandlerMoveConnectorPointStateBase.prototype.onFinishWithChanges = function () {
        ModelUtils_1.ModelUtils.updateConnectorContainer(this.history, this.model, this.connector);
        ModelUtils_1.ModelUtils.deleteConnectorUnnecessaryPoints(this.history, this.connector);
        this.handler.tryUpdateModelSize();
    };
    MouseHandlerMoveConnectorPointStateBase.prototype.getDraggingElementKeys = function () {
        return this.connector ? [this.connector.key] : [];
    };
    MouseHandlerMoveConnectorPointStateBase.prototype.getOppositePointPosition = function () {
        return this.pointPosition === Connector_1.ConnectorPosition.Begin ? Connector_1.ConnectorPosition.End : Connector_1.ConnectorPosition.Begin;
    };
    MouseHandlerMoveConnectorPointStateBase.prototype.allowAttachToObjects = function (evt, checkContainers, checkOppositeItem) {
        if (this.handler.canMultipleSelection(evt))
            return false;
        var connector = this.connector;
        if (connector && evt.source.type === Event_1.MouseEventElementType.Shape) {
            var targetItem_1 = this.model.findItem(evt.source.key);
            if (checkContainers && this.model.findItemContainerCore(connector, function (c) { return c === targetItem_1; }))
                return false;
            if (checkContainers && this.oppositeItem && this.model.findItemContainerCore(this.oppositeItem, function (c) { return c === targetItem_1; }))
                return false;
            if (checkOppositeItem && this.oppositeItem === targetItem_1 && this.oppositeConnectionPointIndex === -1)
                return false;
        }
        return true;
    };
    MouseHandlerMoveConnectorPointStateBase.prototype.onConnectionPointsShow = function (key, points) {
        var _this = this;
        if (this.connector && this.pointPosition !== undefined && (this.connector.endItem && this.connector.endItem.key === key || this.connector.beginItem && this.connector.beginItem.key === key)) {
            var position_1 = this.connector.beginItem && this.connector.beginItem.key === key ? Connector_1.ConnectorPosition.Begin : Connector_1.ConnectorPosition.End;
            points.forEach(function (point, index) {
                point.allowed = _this.handler.canPerformChangeConnectionOnUpdateUI(_this.connector, { item: _this.connector.getExtremeItem(position_1), position: position_1, connectionPointIndex: index });
            });
        }
    };
    MouseHandlerMoveConnectorPointStateBase.prototype.onConnectionTargetShow = function (key, info) {
        if (this.connector && this.pointPosition !== undefined && (this.connector.endItem && this.connector.endItem.key === key || this.connector.beginItem && this.connector.beginItem.key === key)) {
            var position = this.connector.beginItem && this.connector.beginItem.key === key ? Connector_1.ConnectorPosition.Begin : Connector_1.ConnectorPosition.End;
            info.allowed = this.handler.canPerformChangeConnectionOnUpdateUI(this.connector, { item: this.connector.getExtremeItem(position), position: position, connectionPointIndex: -1 });
        }
    };
    return MouseHandlerMoveConnectorPointStateBase;
}(MouseHandlerDraggingState_1.MouseHandlerDraggingState));
exports.MouseHandlerMoveConnectorPointStateBase = MouseHandlerMoveConnectorPointStateBase;


/***/ }),
/* 149 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.MouseHandlerDefaultStateBase = void 0;
var MouseHandlerStateBase_1 = __webpack_require__(40);
var Event_1 = __webpack_require__(11);
var MouseHandlerToggleShapeExpandedState_1 = __webpack_require__(314);
var MouseHandlerSelectionState_1 = __webpack_require__(316);
var MouseHandlerZoomOnWheelState_1 = __webpack_require__(317);
var MouseHandlerScrollingState_1 = __webpack_require__(150);
var unit_converter_1 = __webpack_require__(12);
var MouseHandlerZoomOnPinchState_1 = __webpack_require__(318);
var MouseHandlerDefaultStateBase = (function (_super) {
    __extends(MouseHandlerDefaultStateBase, _super);
    function MouseHandlerDefaultStateBase(handler, history, selection, model, view, visualizerManager, shapeDescriptionManager, settings) {
        var _this = _super.call(this, handler) || this;
        _this.history = history;
        _this.selection = selection;
        _this.model = model;
        _this.view = view;
        _this.visualizerManager = visualizerManager;
        _this.shapeDescriptionManager = shapeDescriptionManager;
        _this.settings = settings;
        return _this;
    }
    MouseHandlerDefaultStateBase.prototype.onKeyDown = function (evt) {
        this.handler.onStartScrollPageByKeyboard(evt);
    };
    MouseHandlerDefaultStateBase.prototype.onKeyUp = function (evt) {
        this.handler.onFinishScrollPageByKeyboard(evt);
    };
    MouseHandlerDefaultStateBase.prototype.onMouseDown = function (evt) {
        if (!this.handler.canFinishTextEditing())
            return;
        this.onMouseDownCore(evt);
        if (this.handler.state !== this)
            this.handler.state.onMouseDown(evt);
    };
    MouseHandlerDefaultStateBase.prototype.onMouseDownCore = function (evt) {
        if (this.handler.canScrollPage(evt))
            this.startScrolling(evt);
        else if (this.hasDiagramItem(evt) && this.canDragObjectOnMouseDown(evt.source.key))
            this.onDragDiagramItemOnMouseDown(evt);
        else if (evt.button === Event_1.MouseButton.Left && evt.source.type === Event_1.MouseEventElementType.ShapeExpandButton && this.canExpandContainerOnMouseDown(evt.source.key))
            this.onShapeExpandBtnMouseDown(evt);
        else {
            if (!this.hasDiagramItem(evt) && this.canClearSelectionOnMouseDown())
                this.clearSelection();
            this.startPoint = evt.modelPoint;
        }
    };
    MouseHandlerDefaultStateBase.prototype.onDragDiagramItemOnMouseDown = function (evt) {
        this.replaceSelection(evt);
    };
    MouseHandlerDefaultStateBase.prototype.onMouseMove = function (evt) {
        this.onMouseMoveCore(evt);
        if (this.handler.state !== this) {
            this.handler.state.onMouseDown(this.handler.mouseDownEvent);
            this.handler.state.onMouseMove(evt);
        }
    };
    MouseHandlerDefaultStateBase.prototype.onMouseMoveCore = function (evt) {
        if (this.startPoint &&
            (Math.abs(this.startPoint.x - evt.modelPoint.x) > MouseHandlerDefaultStateBase.startLimit ||
                Math.abs(this.startPoint.y - evt.modelPoint.y) > MouseHandlerDefaultStateBase.startLimit)) {
            this.processOnMouseMoveAfterLimit(evt);
            this.startPoint = undefined;
        }
    };
    MouseHandlerDefaultStateBase.prototype.processOnMouseMoveAfterLimit = function (evt) {
        if (evt.isTouchMode)
            if (evt.touches.length > 1)
                this.startZooming(evt);
            else
                this.startScrolling(evt);
        else
            this.startSelection(evt);
    };
    MouseHandlerDefaultStateBase.prototype.onMouseUp = function (evt) {
        this.onMouseUpCore(evt);
        if (this.handler.state !== this)
            this.handler.state.onMouseUp(evt);
    };
    MouseHandlerDefaultStateBase.prototype.onMouseUpCore = function (evt) {
        if (evt.source.type === Event_1.MouseEventElementType.Shape && this.canSelectOnMouseUp(evt.source.key))
            this.replaceSelection(evt);
        else if (evt.source.type === Event_1.MouseEventElementType.Connector && this.canSelectOnMouseUp(evt.source.key))
            this.replaceSelection(evt);
        else if (evt.source.type === Event_1.MouseEventElementType.ShapeExpandButton && this.canSelectOnMouseUp(evt.source.key))
            this.replaceSelection(evt);
        else if (this.startPoint && this.canClearSelectionOnMouseUp())
            this.clearSelection();
        this.startPoint = undefined;
    };
    MouseHandlerDefaultStateBase.prototype.onMouseWheel = function (evt) {
        if (this.handler.canStartZoomOnWheel(evt)) {
            this.handler.switchState(new MouseHandlerZoomOnWheelState_1.MouseHandlerZoomOnWheelState(this.handler, this.settings, this.view));
            this.handler.state.onMouseWheel(evt);
            return true;
        }
        return false;
    };
    MouseHandlerDefaultStateBase.prototype.onLongTouch = function (evt) {
        this.replaceMultipleSelection(evt.source.key);
    };
    MouseHandlerDefaultStateBase.prototype.finish = function () {
        this.startPoint = undefined;
    };
    MouseHandlerDefaultStateBase.prototype.startSelection = function (evt) {
        if (evt.button === Event_1.MouseButton.Left)
            this.handler.switchState(new MouseHandlerSelectionState_1.MouseHandlerSelectionState(this.handler, this.selection, this.visualizerManager));
    };
    MouseHandlerDefaultStateBase.prototype.startScrolling = function (evt) {
        if (evt.button === Event_1.MouseButton.Left) {
            this.handler.raiseDragScrollStart();
            this.handler.switchState(new MouseHandlerScrollingState_1.MouseHandlerScrollingState(this.handler, this.view, this.selection));
        }
    };
    MouseHandlerDefaultStateBase.prototype.startZooming = function (evt) {
        this.handler.switchState(new MouseHandlerZoomOnPinchState_1.MouseHandlerZoomOnPinchState(this.handler, this.selection, this.settings, this.view));
    };
    MouseHandlerDefaultStateBase.prototype.inSelection = function (key) {
        return this.selection.hasKey(key);
    };
    MouseHandlerDefaultStateBase.prototype.hasDiagramItem = function (evt) {
        return evt.source.type === Event_1.MouseEventElementType.Shape ||
            evt.source.type === Event_1.MouseEventElementType.Connector;
    };
    MouseHandlerDefaultStateBase.prototype.onShapeExpandBtnMouseDown = function (evt) {
        this.handler.addDiagramItemToSelection(evt);
        this.handler.switchState(new MouseHandlerToggleShapeExpandedState_1.MouseHandlerToggleShapeExpandedState(this.handler, this.history, this.model, this.selection));
    };
    MouseHandlerDefaultStateBase.prototype.replaceSelection = function (evt) {
        if (this.handler.canMultipleSelection(evt))
            this.replaceMultipleSelection(evt.source.key);
        else
            this.handler.changeSingleSelection(evt.source.key);
    };
    MouseHandlerDefaultStateBase.prototype.replaceMultipleSelection = function (key) {
        if (this.selection.hasKey(key))
            this.selection.remove(key);
        else
            this.selection.add(key);
    };
    MouseHandlerDefaultStateBase.prototype.clearSelection = function () {
        this.selection.set([]);
    };
    MouseHandlerDefaultStateBase.startLimit = unit_converter_1.UnitConverter.pixelsToTwips(1);
    return MouseHandlerDefaultStateBase;
}(MouseHandlerStateBase_1.MouseHandlerStateBase));
exports.MouseHandlerDefaultStateBase = MouseHandlerDefaultStateBase;


/***/ }),
/* 150 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.MouseHandlerScrollingState = void 0;
var MouseHandlerStateBase_1 = __webpack_require__(40);
var Event_1 = __webpack_require__(11);
var point_1 = __webpack_require__(0);
var MouseHandlerScrollingState = (function (_super) {
    __extends(MouseHandlerScrollingState, _super);
    function MouseHandlerScrollingState(handler, view, selection) {
        var _this = _super.call(this, handler) || this;
        _this.view = view;
        _this.selection = selection;
        _this.lastOffset = new point_1.Point(0, 0);
        return _this;
    }
    MouseHandlerScrollingState.prototype.onKeyUp = function (evt) {
        this.handler.onFinishScrollPageByKeyboard(evt);
    };
    MouseHandlerScrollingState.prototype.onMouseDown = function (evt) {
        evt.preventDefault = true;
        this.startPoint = this.getPointByEvent(evt);
    };
    MouseHandlerScrollingState.prototype.onMouseMove = function (evt) {
        if (evt.button !== Event_1.MouseButton.Left) {
            this.handler.onFinishScrollPageByMouse(evt);
            return;
        }
        var prevPoint = this.currentPoint || this.startPoint;
        evt.preventDefault = true;
        var point = this.getPointByEvent(evt);
        var actualOffset = this.view.scrollBy(new point_1.Point(point.x - prevPoint.x, point.y - prevPoint.y));
        this.lastOffset = this.lastOffset.clone().offset(actualOffset.x, actualOffset.y);
        this.currentPoint = point;
    };
    MouseHandlerScrollingState.prototype.onMouseUp = function (evt) {
        if (evt.button === Event_1.MouseButton.Left)
            this.handler.onFinishScrollPageByMouse(evt);
        this.handler.switchToDefaultState();
    };
    MouseHandlerScrollingState.prototype.cancelChanges = function () {
        if (this.currentPoint)
            this.view.scrollBy(this.lastOffset.clone().multiply(-1, -1));
    };
    MouseHandlerScrollingState.prototype.finish = function () {
        if (!this.currentPoint || !this.startPoint || this.currentPoint.equals(this.startPoint))
            this.selection.set([]);
        _super.prototype.finish.call(this);
    };
    MouseHandlerScrollingState.prototype.getPointByEvent = function (evt) {
        return evt.offsetPoint;
    };
    return MouseHandlerScrollingState;
}(MouseHandlerStateBase_1.MouseHandlerCancellableState));
exports.MouseHandlerScrollingState = MouseHandlerScrollingState;


/***/ }),
/* 151 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.MouseHandlerDragDiagramItemStateBase = exports.DraggingConnector = void 0;
var vector_1 = __webpack_require__(60);
var ChangeConnectorPointsHistoryItem_1 = __webpack_require__(86);
var ConnectorRenderPoint_1 = __webpack_require__(29);
var ConnectorRenderPointsContext_1 = __webpack_require__(85);
var ModelUtils_1 = __webpack_require__(4);
var ModelOperationSettings_1 = __webpack_require__(16);
var Event_1 = __webpack_require__(11);
var MouseHandlerDraggingState_1 = __webpack_require__(34);
var DraggingConnector = (function () {
    function DraggingConnector(connector) {
        this.connector = connector;
        this.startPoints = connector.points.map(function (x) { return x.clone(); });
        this.startRenderContext = connector.createRenderPointsContext();
    }
    return DraggingConnector;
}());
exports.DraggingConnector = DraggingConnector;
var DraggingShape = (function () {
    function DraggingShape(shape) {
        this.shape = shape;
        this.startPosition = shape.position.clone();
    }
    return DraggingShape;
}());
var MouseHandlerDragDiagramItemStateBase = (function (_super) {
    __extends(MouseHandlerDragDiagramItemStateBase, _super);
    function MouseHandlerDragDiagramItemStateBase(handler, history, model, selection, visualizerManager) {
        var _this = _super.call(this, handler, history) || this;
        _this.model = model;
        _this.selection = selection;
        _this.visualizerManager = visualizerManager;
        _this.startScrollLeft = 0;
        _this.startScrollTop = 0;
        return _this;
    }
    MouseHandlerDragDiagramItemStateBase.prototype.finish = function () {
        this.visualizerManager.resetExtensionLines();
        this.visualizerManager.resetContainerTarget();
        this.visualizerManager.resetConnectionTarget();
        this.visualizerManager.resetConnectionPoints();
        _super.prototype.finish.call(this);
    };
    MouseHandlerDragDiagramItemStateBase.prototype.onMouseDown = function (evt) {
        var _this = this;
        this.handler.addDiagramItemToSelection(evt);
        this.shouldClone = this.handler.canCopySelectedItems(evt);
        this.startPoint = evt.modelPoint;
        this.initDrag();
        this.lockInitDrag = false;
        if (!this.shouldClone)
            this.draggingShapes.forEach(function (draggingShape) { return _this.handler.addInteractingItem(draggingShape.shape, ModelOperationSettings_1.DiagramModelOperation.MoveShape); });
        _super.prototype.onMouseDown.call(this, evt);
    };
    MouseHandlerDragDiagramItemStateBase.prototype.onMouseMove = function (evt) {
        this.mouseMoveEvent = evt;
        if (evt.button !== Event_1.MouseButton.Left) {
            this.cancelChanges();
            this.handler.switchToDefaultState();
        }
        if (!this.canApplyChangesOnMouseMove(this.startPoint, evt.modelPoint))
            return;
        if (this.handler.canCopySelectedItems(evt))
            if (!this.lockInitDrag) {
                this.cancelChanges();
                this.shouldClone = true;
                this.copySelection();
                this.initDrag();
                this.lockInitDrag = true;
            }
        this.onApplyChanges(evt);
        this.onAfterApplyChanges();
        this.updateContainers(evt);
    };
    MouseHandlerDragDiagramItemStateBase.prototype.updateContainers = function (evt) {
        this.visualizerManager.setExtensionLines(this.selection.getSelectedShapes(false, true));
        var container = ModelUtils_1.ModelUtils.findContainerByEventKey(this.model, this.selection, evt.source.key);
        if (container && this.allowInsertToContainer(evt, container))
            this.visualizerManager.setContainerTarget(container, evt.source.type);
        else
            this.visualizerManager.resetContainerTarget();
    };
    MouseHandlerDragDiagramItemStateBase.prototype.onMouseUp = function (evt) {
        _super.prototype.onMouseUp.call(this, evt);
        if (this.handler.canRemoveDiagramItemToSelection(evt) && this.handler.canMultipleSelection(evt))
            this.handler.removeDiagramItemFromSelection(evt.button, evt.source.key);
    };
    MouseHandlerDragDiagramItemStateBase.prototype.onApplyChanges = function (evt) {
        var _this = this;
        this.calculateFixedPosition(evt);
        if (this.draggingShapes.length) {
            var selectedShapes_1 = this.draggingShapes.map(function (ds) { return ds.shape; });
            this.draggingShapes.forEach(function (ds) {
                var shape = ds.shape;
                while (shape.container) {
                    if (selectedShapes_1.indexOf(shape.container) !== -1)
                        return false;
                    shape = shape.container;
                }
                _this.moveShape(ds, evt);
            });
            var firstDraggingShape = this.draggingShapes[0];
            var offset_1 = vector_1.Vector.fromPoints(firstDraggingShape.startPosition.clone(), firstDraggingShape.shape.position.clone());
            if (offset_1.x || offset_1.y)
                this.draggingConnectors.forEach(function (dc) { return _this.moveConnectorCore(dc.connector, dc.startPoints, dc.startRenderContext, offset_1); });
        }
        else
            this.draggingConnectors.forEach(function (x) { return _this.moveConnector(x, evt); });
        var container = ModelUtils_1.ModelUtils.findContainerByEventKey(this.model, this.selection, evt.source.key);
        if (container && this.allowInsertToContainer(evt, container))
            ModelUtils_1.ModelUtils.insertSelectionToContainer(this.history, this.model, this.selection, container);
        else
            ModelUtils_1.ModelUtils.removeSelectionFromContainer(this.history, this.model, this.selection);
        this.handler.tryUpdateModelSize(function (offsetLeft, offsetTop) {
            _this.modelConnectorsWithoutBeginItemInfo.forEach(function (pi) {
                pi.point.x += offsetLeft;
                pi.point.y += offsetTop;
            });
            _this.modelConnectorsWithoutEndItemInfo.forEach(function (pi) {
                pi.point.x += offsetLeft;
                pi.point.y += offsetTop;
            });
        });
    };
    MouseHandlerDragDiagramItemStateBase.prototype.getDraggingElementKeys = function () {
        return this.draggingShapes.map(function (x) { return x.shape.key; }).concat(this.draggingConnectors.map(function (x) { return x.connector.key; }));
    };
    MouseHandlerDragDiagramItemStateBase.prototype.getSnappedPoint = function (evt, point) {
        return this.handler.getSnappedPointOnDragDiagramItem(evt, point, this.fixedX, this.fixedY, this.startPoint);
    };
    MouseHandlerDragDiagramItemStateBase.prototype.initDrag = function () {
        this.selectedItems = ModelUtils_1.ModelUtils.createSelectedItems(this.selection);
        this.initDraggingShapes();
        if (!this.areValidDraggingShapes) {
            this.handler.switchToDefaultState();
            return;
        }
        this.initDraggingConnectors();
        if (!this.areValidDraggingConnectors) {
            this.handler.switchToDefaultState();
            return;
        }
        this.modelConnectorsWithoutBeginItemInfo = this.createModelConnectorsWithoutBeginItemInfo();
        this.modelConnectorsWithoutEndItemInfo = this.createModelConnectorsWithoutEndItemInfo();
    };
    MouseHandlerDragDiagramItemStateBase.prototype.initDraggingShapes = function () {
        this.draggingShapes = this.selection.getSelectedShapes(false, true).map(function (s) { return new DraggingShape(s); });
    };
    MouseHandlerDragDiagramItemStateBase.prototype.initDraggingConnectors = function () {
        var _this = this;
        this.draggingConnectors = [];
        this.draggingConnectorsIndexByKey = {};
        this.selection.getSelectedConnectors(false, true).forEach(function (c) { return _this.registerConnector(c); });
        if (this.shouldClone)
            return;
        this.draggingShapes.forEach(function (x) {
            var attachedConnectors = x.shape.attachedConnectors;
            if (attachedConnectors)
                attachedConnectors.forEach(function (c) {
                    if (!_this.containsDraggingConnectorByKey(c.key))
                        _this.registerConnector(c);
                });
        });
    };
    MouseHandlerDragDiagramItemStateBase.prototype.copySelection = function () {
        var _this = this;
        ModelUtils_1.ModelUtils.cloneSelectionToOffset(this.history, this.model, function (key) {
            var item = _this.model.findItem(key);
            if (item)
                _this.handler.addInteractingItem(item, ModelOperationSettings_1.DiagramModelOperation.AddShape);
        }, this.selection, 0, 0);
    };
    MouseHandlerDragDiagramItemStateBase.prototype.calculateFixedPosition = function (evt) {
        this.fixedX = false;
        this.fixedY = false;
        if (this.handler.canCalculateFixedPosition(evt)) {
            var dx = Math.abs(this.startPoint.x - evt.modelPoint.x);
            var dy = Math.abs(this.startPoint.y - evt.modelPoint.y);
            if (dx < dy)
                this.fixedX = true;
            else
                this.fixedY = true;
        }
    };
    MouseHandlerDragDiagramItemStateBase.prototype.containsDraggingConnectorByKey = function (key) {
        return this.draggingConnectorsIndexByKey[key] !== undefined;
    };
    MouseHandlerDragDiagramItemStateBase.prototype.allowInsertToContainer = function (evt, container) {
        if (this.handler.canMultipleSelection(evt))
            return false;
        return container && container.expanded && ModelUtils_1.ModelUtils.canInsertSelectionToContainer(this.model, this.selection, container);
    };
    MouseHandlerDragDiagramItemStateBase.prototype.registerConnector = function (connector) {
        this.draggingConnectorsIndexByKey[connector.key] = this.draggingConnectors.push(new DraggingConnector(connector)) - 1;
    };
    MouseHandlerDragDiagramItemStateBase.prototype.createModelConnectorsWithoutBeginItemInfo = function () {
        var _this = this;
        var connectors = this.model.findConnectorsCore(function (c) { return !c.beginItem && !_this.containsDraggingConnectorByKey(c.key); });
        return connectors.map(function (c) {
            return {
                connector: c,
                point: c.points[0].clone()
            };
        });
    };
    MouseHandlerDragDiagramItemStateBase.prototype.createModelConnectorsWithoutEndItemInfo = function () {
        var _this = this;
        var connectors = this.model.findConnectorsCore(function (c) { return !c.endItem && !_this.containsDraggingConnectorByKey(c.key); });
        return connectors.map(function (c) {
            return {
                connector: c,
                point: c.points[c.points.length - 1].clone()
            };
        });
    };
    MouseHandlerDragDiagramItemStateBase.prototype.moveConnector = function (dc, evt) {
        var startPoints = dc.startPoints;
        var offset = vector_1.Vector.fromPoints(startPoints[0].clone(), this.getSnappedPoint(evt, startPoints[0]).clone());
        if (offset.x || offset.y)
            this.moveConnectorCore(dc.connector, startPoints, dc.startRenderContext, offset);
    };
    MouseHandlerDragDiagramItemStateBase.prototype.moveConnectorCore = function (connector, startPoints, startRenderContext, offset) {
        if (this.shouldClone || ModelUtils_1.ModelUtils.canMoveConnector(this.selectedItems, connector))
            this.offsetConnector(connector, startPoints, startRenderContext, offset);
        else
            this.changeConnector(connector);
    };
    MouseHandlerDragDiagramItemStateBase.prototype.moveShape = function (ds, evt) {
        var _this = this;
        var shape = ds.shape;
        var position = this.getSnappedPoint(evt, ds.startPosition);
        ModelUtils_1.ModelUtils.setShapePosition(this.history, this.model, shape, position);
        ModelUtils_1.ModelUtils.updateMovingShapeConnections(this.history, shape, this.modelConnectorsWithoutBeginItemInfo, this.modelConnectorsWithoutEndItemInfo, function () {
            _this.visualizerManager.resetConnectionTarget();
            _this.visualizerManager.resetConnectionPoints();
        }, function (shape, connectionPointIndex) {
            _this.visualizerManager.setConnectionTarget(shape, Event_1.MouseEventElementType.Shape);
            _this.visualizerManager.setConnectionPoints(shape, Event_1.MouseEventElementType.Shape, connectionPointIndex, true);
        }, function (connector) { return _this.handler.addInteractingItem(connector); });
        if (!this.draggingConnectors.filter(function (dc) { return !!_this.selectedItems[dc.connector.key]; }).length)
            ModelUtils_1.ModelUtils.updateShapeAttachedConnectors(this.history, this.model, shape);
    };
    MouseHandlerDragDiagramItemStateBase.prototype.offsetConnector = function (connector, startPoints, startRenderContext, offset) {
        var _this = this;
        var newPoints = startPoints.map(function (p) { return _this.offsetPoint(p, offset); });
        if (!newPoints[0].equals(connector.points[0]))
            this.history.addAndRedo(new ChangeConnectorPointsHistoryItem_1.ChangeConnectorPointsHistoryItem(connector.key, newPoints, this.offsetRenderContext(startRenderContext, offset)));
    };
    MouseHandlerDragDiagramItemStateBase.prototype.offsetRenderContext = function (context, offset) {
        var _this = this;
        if (context === undefined)
            return undefined;
        return new ConnectorRenderPointsContext_1.ConnectorRenderPointsContext(context.renderPoints.map(function (p) {
            var newPoint = _this.offsetPoint(p, offset);
            return new ConnectorRenderPoint_1.ConnectorRenderPoint(newPoint.x, newPoint.y, p.pointIndex, p.skipped);
        }), true, context.actualRoutingMode);
    };
    MouseHandlerDragDiagramItemStateBase.prototype.offsetPoint = function (point, offset) {
        var pointOffset = vector_1.Vector.fromPoints(point, this.startPoint);
        return this.startPoint.clone().offset(offset.x - pointOffset.x, offset.y - pointOffset.y);
    };
    MouseHandlerDragDiagramItemStateBase.prototype.changeConnector = function (connector) {
        ModelUtils_1.ModelUtils.removeConnectorIntermediatePoints(this.history, connector);
        ModelUtils_1.ModelUtils.updateConnectorAttachedPoints(this.history, this.model, connector);
    };
    return MouseHandlerDragDiagramItemStateBase;
}(MouseHandlerDraggingState_1.MouseHandlerDraggingState));
exports.MouseHandlerDragDiagramItemStateBase = MouseHandlerDragDiagramItemStateBase;


/***/ }),
/* 152 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.MouseHandlerDefaultReadOnlyState = void 0;
var MouseHandlerDefaultStateBase_1 = __webpack_require__(149);
var MouseHandlerDefaultReadOnlyState = (function (_super) {
    __extends(MouseHandlerDefaultReadOnlyState, _super);
    function MouseHandlerDefaultReadOnlyState() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    MouseHandlerDefaultReadOnlyState.prototype.canDragObjectOnMouseDown = function (key) {
        return false;
    };
    MouseHandlerDefaultReadOnlyState.prototype.canExpandContainerOnMouseDown = function (key) {
        return false;
    };
    MouseHandlerDefaultReadOnlyState.prototype.canClearSelectionOnMouseDown = function () {
        return false;
    };
    MouseHandlerDefaultReadOnlyState.prototype.canSelectOnMouseUp = function (key) {
        return true;
    };
    MouseHandlerDefaultReadOnlyState.prototype.canClearSelectionOnMouseUp = function () {
        return true;
    };
    MouseHandlerDefaultReadOnlyState.prototype.updateConnectionsOnMouseMove = function (evt) {
    };
    return MouseHandlerDefaultReadOnlyState;
}(MouseHandlerDefaultStateBase_1.MouseHandlerDefaultStateBase));
exports.MouseHandlerDefaultReadOnlyState = MouseHandlerDefaultReadOnlyState;


/***/ }),
/* 153 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.ChangeShapeTextHistoryItem = void 0;
var HistoryItem_1 = __webpack_require__(8);
var ChangeShapeTextHistoryItem = (function (_super) {
    __extends(ChangeShapeTextHistoryItem, _super);
    function ChangeShapeTextHistoryItem(item, text) {
        var _this = _super.call(this) || this;
        _this.shapeKey = item.key;
        _this.text = text;
        return _this;
    }
    ChangeShapeTextHistoryItem.prototype.redo = function (manipulator) {
        var item = manipulator.model.findShape(this.shapeKey);
        this.oldText = item.text;
        manipulator.changeShapeText(item, this.text);
    };
    ChangeShapeTextHistoryItem.prototype.undo = function (manipulator) {
        var item = manipulator.model.findShape(this.shapeKey);
        manipulator.changeShapeText(item, this.oldText);
    };
    return ChangeShapeTextHistoryItem;
}(HistoryItem_1.HistoryItem));
exports.ChangeShapeTextHistoryItem = ChangeShapeTextHistoryItem;


/***/ }),
/* 154 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.ContextMenuHandler = void 0;
var Utils_1 = __webpack_require__(3);
var Event_1 = __webpack_require__(11);
var key_1 = __webpack_require__(25);
var batch_updatable_1 = __webpack_require__(81);
var browser_1 = __webpack_require__(18);
var ContextMenuHandler = (function (_super) {
    __extends(ContextMenuHandler, _super);
    function ContextMenuHandler() {
        var _this = _super !== null && _super.apply(this, arguments) || this;
        _this.contextMenuVisible = false;
        _this.textInputStarted = false;
        _this.canHideContextMenu = true;
        _this.onVisibilityChanged = new Utils_1.EventDispatcher();
        return _this;
    }
    ContextMenuHandler.prototype.onMouseDown = function (evt) {
        if (evt.button === Event_1.MouseButton.Left && evt.source.type !== Event_1.MouseEventElementType.Undefined)
            this.hideContextMenu();
    };
    ContextMenuHandler.prototype.onMouseUp = function (evt) {
        if (!browser_1.Browser.MacOSPlatform || browser_1.Browser.MacOSPlatform && this.canHideContextMenu)
            this.hideContextMenu();
        this.canHideContextMenu = true;
    };
    ContextMenuHandler.prototype.onContextMenu = function (evt) {
        if (browser_1.Browser.MacOSPlatform)
            this.canHideContextMenu = false;
        this.showContextMenu(evt.eventPoint, evt.modelPoint);
    };
    ContextMenuHandler.prototype.onFocus = function (evt) { };
    ContextMenuHandler.prototype.onBlur = function (evt) { };
    ContextMenuHandler.prototype.onTextInputFocus = function (evt) { };
    ContextMenuHandler.prototype.onTextInputBlur = function (evt) { };
    ContextMenuHandler.prototype.onLongTouch = function (evt) { };
    ContextMenuHandler.prototype.onKeyDown = function (evt) {
        if (evt.keyCode === key_1.KeyCode.Esc)
            this.hideContextMenu();
    };
    ContextMenuHandler.prototype.onShortcut = function (evt) {
        this.hideContextMenu();
    };
    ContextMenuHandler.prototype.showContextMenu = function (eventPoint, modelPoint) {
        var _this = this;
        if (this.textInputStarted)
            return;
        window.setTimeout(function () {
            _this.onVisibilityChanged.raise1(function (l) { return l.notifyShowContextMenu(eventPoint, modelPoint); });
            _this.contextMenuVisible = true;
        }, 0);
    };
    ContextMenuHandler.prototype.hideContextMenu = function () {
        var _this = this;
        if (this.contextMenuVisible)
            window.setTimeout(function () {
                _this.onVisibilityChanged.raise1(function (l) { return l.notifyHideContextMenu(); });
                _this.contextMenuVisible = false;
            }, 0);
    };
    ContextMenuHandler.prototype.notifyDragStart = function (itemKeys) { };
    ContextMenuHandler.prototype.notifyDragEnd = function (itemKeys) { };
    ContextMenuHandler.prototype.notifyDragScrollStart = function () { };
    ContextMenuHandler.prototype.notifyDragScrollEnd = function () { };
    ContextMenuHandler.prototype.notifyShowContextToolbox = function (modelPoint, getPositionToInsertShapeTo, side, category, callback) { };
    ContextMenuHandler.prototype.notifyHideContextToolbox = function () { };
    ContextMenuHandler.prototype.notifyTextInputStart = function (item, text, position, size) {
        this.textInputStarted = true;
    };
    ContextMenuHandler.prototype.notifyTextInputEnd = function (item, captureFocus) {
        this.textInputStarted = false;
    };
    ContextMenuHandler.prototype.notifyTextInputPermissionsCheck = function (item, allowed) { };
    ContextMenuHandler.prototype.onUpdateUnlocked = function (occurredEvents) { };
    return ContextMenuHandler;
}(batch_updatable_1.BatchUpdatableObject));
exports.ContextMenuHandler = ContextMenuHandler;


/***/ }),
/* 155 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.VisualizerManager = void 0;
var ConnectionTargetVisualizer_1 = __webpack_require__(325);
var ContainerTargetVisualizer_1 = __webpack_require__(326);
var ExtensionLinesVisualizer_1 = __webpack_require__(157);
var Event_1 = __webpack_require__(11);
var ConnectionPointsVisualizer_1 = __webpack_require__(327);
var Shape_1 = __webpack_require__(14);
var Utils_1 = __webpack_require__(3);
var segment_1 = __webpack_require__(33);
var point_1 = __webpack_require__(0);
var CanvasSelectionManager_1 = __webpack_require__(158);
var ModelUtils_1 = __webpack_require__(4);
var ResizeInfoVisualizer_1 = __webpack_require__(328);
var SelectionRectVisualizer_1 = __webpack_require__(329);
var batch_updatable_1 = __webpack_require__(81);
var LocalizationService_1 = __webpack_require__(36);
var VisualizerManager = (function (_super) {
    __extends(VisualizerManager, _super);
    function VisualizerManager(selection, model, eventManager, settings, readOnly) {
        if (readOnly === void 0) { readOnly = settings.readOnly; }
        var _this = _super.call(this) || this;
        _this.selection = selection;
        _this.model = model;
        _this.eventManager = eventManager;
        _this.settings = settings;
        _this.readOnly = readOnly;
        _this.onVisualizersUpdate = new Utils_1.EventDispatcher();
        _this.connectionPointsVisualizer = new ConnectionPointsVisualizer_1.ConnectionPointsVisualizer(_this.onVisualizersUpdate);
        _this.connectionPointsVisualizer = new ConnectionPointsVisualizer_1.ConnectionPointsVisualizer(_this.onVisualizersUpdate);
        _this.connectionTargetVisualizer = new ConnectionTargetVisualizer_1.ConnectionTargetVisualizer(_this.onVisualizersUpdate);
        _this.containerTargetVisualizer = new ContainerTargetVisualizer_1.ContainerTargetVisualizer(_this.onVisualizersUpdate);
        _this.extensionLinesVisualizer = new ExtensionLinesVisualizer_1.ExtensionLinesVisualizer(_this.onVisualizersUpdate);
        _this.resizeInfoVisualizer = new ResizeInfoVisualizer_1.ResizeInfoVisualizer(_this.onVisualizersUpdate);
        _this.selectionRectangleVisualizer = new SelectionRectVisualizer_1.SelectionRectVisualizer(_this.onVisualizersUpdate);
        return _this;
    }
    VisualizerManager.prototype.initialize = function (model) {
        this.model = model;
    };
    VisualizerManager.prototype.onMouseDown = function (evt) {
    };
    VisualizerManager.prototype.onMouseUp = function (evt) {
    };
    VisualizerManager.prototype.onMouseEnter = function (evt) {
    };
    VisualizerManager.prototype.onMouseLeave = function (evt) {
        this.resetConnectionPoints();
        this.resetConnectionTarget();
        this.resetExtensionLines();
        this.resetContainerTarget();
        this.resetResizeInfo();
        this.resetSelectionRectangle();
    };
    VisualizerManager.prototype.onBlur = function (evt) {
    };
    VisualizerManager.prototype.onFocus = function (evt) {
    };
    VisualizerManager.prototype.updateConnections = function (item, type, value) {
        var pointIndex = -1;
        if (value && type === Event_1.MouseEventElementType.ShapeConnectionPoint)
            pointIndex = parseInt(value);
        var preventShowOutside = item && ((!item.allowResizeHorizontally && !item.allowResizeVertically) || item.isLocked);
        this.setConnectionPoints(item, type, pointIndex, preventShowOutside);
    };
    VisualizerManager.prototype.setConnectionPoints = function (item, type, pointIndex, preventShowOutside) {
        if (!this.eventManager.isFocused())
            return;
        if (item && (type === Event_1.MouseEventElementType.Shape || type === Event_1.MouseEventElementType.ShapeResizeBox ||
            type === Event_1.MouseEventElementType.ShapeConnectionPoint) && item !== undefined) {
            var key = item.key;
            var isSelected = this.selection.hasKey(key);
            var points = item.getConnectionPoints();
            this.connectionPointsVisualizer.setPoints(key, points.map(function (pt) { return new ConnectionPointsVisualizer_1.ConnectionPointInfo(pt, item.getConnectionPointSide(pt)); }), pointIndex, isSelected && !preventShowOutside && item.rectangle);
        }
        else
            this.connectionPointsVisualizer.reset();
    };
    VisualizerManager.prototype.setConnectionPointIndex = function (index) {
        this.connectionPointsVisualizer.setPointIndex(index);
    };
    VisualizerManager.prototype.updateConnectionPoints = function () {
        var item = this.model.findItem(this.connectionPointsVisualizer.getKey());
        if (item !== undefined)
            this.connectionPointsVisualizer.update();
        else
            this.connectionPointsVisualizer.reset();
    };
    VisualizerManager.prototype.resetConnectionPoints = function () {
        this.connectionPointsVisualizer.reset();
    };
    VisualizerManager.prototype.setConnectionTarget = function (item, type) {
        if (item && (type === Event_1.MouseEventElementType.Shape ||
            type === Event_1.MouseEventElementType.ShapeConnectionPoint))
            this.connectionTargetVisualizer.setTargetRect(item.key, item.rectangle, item.strokeWidth);
        else
            this.connectionTargetVisualizer.reset();
    };
    VisualizerManager.prototype.resetConnectionTarget = function () {
        this.connectionTargetVisualizer.reset();
    };
    VisualizerManager.prototype.setContainerTarget = function (item, type) {
        if (item && !item.isLocked && (type === Event_1.MouseEventElementType.Shape) && item.enableChildren)
            this.containerTargetVisualizer.setTargetRect(item.key, item.rectangle, item.strokeWidth);
        else
            this.containerTargetVisualizer.reset();
    };
    VisualizerManager.prototype.resetContainerTarget = function () {
        this.containerTargetVisualizer.reset();
    };
    VisualizerManager.prototype.setExtensionLines = function (items) {
        var _this = this;
        if (!this.eventManager.isFocused())
            return;
        this.extensionLinesVisualizer.reset();
        var rect = ModelUtils_1.ModelUtils.createRectangle(items.filter(function (item) { return item; }));
        this.addPageExtensionLines(rect);
        this.model.items.forEach(function (item) {
            if (items.indexOf(item) > -1)
                return;
            if (item instanceof Shape_1.Shape)
                _this.addShapeExtensionLines(item, rect);
        });
    };
    VisualizerManager.prototype.addPageExtensionLines = function (rect) {
        var horPages = Math.round(this.model.size.width / this.model.pageWidth);
        var verPages = Math.round(this.model.size.height / this.model.pageHeight);
        for (var i = 0; i < horPages; i++)
            for (var j = 0; j < verPages; j++) {
                var center = new point_1.Point(i * this.model.pageWidth + this.model.pageWidth / 2, j * this.model.pageHeight + this.model.pageHeight / 2);
                if (Math.abs(rect.center.x - center.x) < this.settings.gridSize / 2) {
                    var segment = new segment_1.Segment(new point_1.Point(rect.center.x, 0), new point_1.Point(rect.center.x, this.model.size.height));
                    this.extensionLinesVisualizer.addSegment(ExtensionLinesVisualizer_1.ExtensionLineType.HorizontalCenterToPageCenter, segment, "");
                }
                if (Math.abs(rect.center.y - center.y) < this.settings.gridSize / 2) {
                    var segment = new segment_1.Segment(new point_1.Point(0, rect.center.y), new point_1.Point(this.model.size.width, rect.center.y));
                    this.extensionLinesVisualizer.addSegment(ExtensionLinesVisualizer_1.ExtensionLineType.VerticalCenterToPageCenter, segment, "");
                }
                if (Math.abs(rect.x - center.x) < this.settings.gridSize / 2) {
                    var segment = new segment_1.Segment(new point_1.Point(rect.x, 0), new point_1.Point(rect.x, this.model.size.height));
                    this.extensionLinesVisualizer.addSegment(ExtensionLinesVisualizer_1.ExtensionLineType.LeftToPageCenter, segment, "");
                }
                if (Math.abs(rect.y - center.y) < this.settings.gridSize / 2) {
                    var segment = new segment_1.Segment(new point_1.Point(0, rect.y), new point_1.Point(this.model.size.width, rect.y));
                    this.extensionLinesVisualizer.addSegment(ExtensionLinesVisualizer_1.ExtensionLineType.TopToPageCenter, segment, "");
                }
                if (Math.abs(rect.right - center.x) < this.settings.gridSize / 2) {
                    var segment = new segment_1.Segment(new point_1.Point(rect.right, 0), new point_1.Point(rect.right, this.model.size.height));
                    this.extensionLinesVisualizer.addSegment(ExtensionLinesVisualizer_1.ExtensionLineType.RightToPageCenter, segment, "");
                }
                if (Math.abs(rect.bottom - center.y) < this.settings.gridSize / 2) {
                    var segment = new segment_1.Segment(new point_1.Point(0, rect.bottom), new point_1.Point(this.model.size.width, rect.bottom));
                    this.extensionLinesVisualizer.addSegment(ExtensionLinesVisualizer_1.ExtensionLineType.BottomToPageCenter, segment, "");
                }
            }
    };
    VisualizerManager.prototype.addShapeExtensionLines = function (shape, rect) {
        var sRect = shape.rectangle;
        var lwCor = shape.strokeWidth - CanvasSelectionManager_1.CanvasSelectionManager.extensionLineWidth;
        var showDistance = true;
        var x1nc;
        var y1nc;
        var x2nc;
        var y2nc;
        var x1;
        var y1;
        var x2;
        var y2;
        if (rect.right < sRect.x) {
            x1nc = rect.right;
            x2nc = sRect.x;
            x1 = x1nc + lwCor + CanvasSelectionManager_1.CanvasSelectionManager.extensionLineOffset;
            x2 = x2nc - CanvasSelectionManager_1.CanvasSelectionManager.extensionLineOffset;
        }
        else if (rect.x > sRect.right) {
            x1nc = rect.x;
            x2nc = sRect.right;
            x1 = x1nc - CanvasSelectionManager_1.CanvasSelectionManager.extensionLineOffset;
            x2 = x2nc + lwCor + CanvasSelectionManager_1.CanvasSelectionManager.extensionLineOffset;
        }
        if (rect.bottom < sRect.y) {
            y1nc = rect.bottom;
            y2nc = sRect.y;
            y1 = y1nc + lwCor + CanvasSelectionManager_1.CanvasSelectionManager.extensionLineOffset;
            y2 = y2nc - CanvasSelectionManager_1.CanvasSelectionManager.extensionLineOffset;
        }
        else if (rect.y > sRect.bottom) {
            y1nc = rect.y;
            y2nc = sRect.bottom;
            y1 = y1nc - CanvasSelectionManager_1.CanvasSelectionManager.extensionLineOffset;
            y2 = y2nc + lwCor + CanvasSelectionManager_1.CanvasSelectionManager.extensionLineOffset;
        }
        if (x1 !== undefined && x2 !== undefined) {
            var distanceText = this.getViewUnitText(Math.abs(x1nc - x2nc));
            if (rect.center.y === sRect.center.y) {
                var segment = new segment_1.Segment(new point_1.Point(x1, rect.center.y), new point_1.Point(x2, sRect.center.y));
                this.extensionLinesVisualizer.addSegment(x1 > x2 ? ExtensionLinesVisualizer_1.ExtensionLineType.VerticalCenterAfter : ExtensionLinesVisualizer_1.ExtensionLineType.VerticalCenterBefore, segment, showDistance ? distanceText : "");
                showDistance = false;
            }
            if (rect.y === sRect.y) {
                var segment = new segment_1.Segment(new point_1.Point(x1, rect.y), new point_1.Point(x2, sRect.y));
                this.extensionLinesVisualizer.addSegment(x1 > x2 ? ExtensionLinesVisualizer_1.ExtensionLineType.TopToTopAfter : ExtensionLinesVisualizer_1.ExtensionLineType.TopToTopBefore, segment, showDistance ? distanceText : "");
            }
            if (rect.bottom === sRect.bottom) {
                var segment = new segment_1.Segment(new point_1.Point(x1, rect.bottom + lwCor), new point_1.Point(x2, sRect.bottom + lwCor));
                this.extensionLinesVisualizer.addSegment(x1 > x2 ? ExtensionLinesVisualizer_1.ExtensionLineType.BottomToBottomAfter : ExtensionLinesVisualizer_1.ExtensionLineType.BottomToBottomBefore, segment, showDistance ? distanceText : "");
            }
            if (rect.y === sRect.bottom) {
                var segment = new segment_1.Segment(new point_1.Point(x1, rect.y), new point_1.Point(x2, sRect.bottom + lwCor));
                this.extensionLinesVisualizer.addSegment(x1 > x2 ? ExtensionLinesVisualizer_1.ExtensionLineType.TopToBottomAfter : ExtensionLinesVisualizer_1.ExtensionLineType.TopToBottomBefore, segment, showDistance ? distanceText : "");
            }
            if (rect.bottom === sRect.y) {
                var segment = new segment_1.Segment(new point_1.Point(x1, rect.bottom + lwCor), new point_1.Point(x2, sRect.y));
                this.extensionLinesVisualizer.addSegment(x1 > x2 ? ExtensionLinesVisualizer_1.ExtensionLineType.BottomToTopAfter : ExtensionLinesVisualizer_1.ExtensionLineType.BottomToTopBefore, segment, showDistance ? distanceText : "");
            }
        }
        if (y1 !== undefined && y2 !== undefined) {
            var distanceText = this.getViewUnitText(Math.abs(y1nc - y2nc));
            if (rect.center.x === sRect.center.x) {
                var segment = new segment_1.Segment(new point_1.Point(rect.center.x, y1), new point_1.Point(sRect.center.x, y2));
                this.extensionLinesVisualizer.addSegment(y1 > y2 ? ExtensionLinesVisualizer_1.ExtensionLineType.HorizontalCenterBelow : ExtensionLinesVisualizer_1.ExtensionLineType.HorizontalCenterAbove, segment, showDistance ? distanceText : "");
                showDistance = false;
            }
            if (rect.x === sRect.x) {
                var segment = new segment_1.Segment(new point_1.Point(rect.x, y1), new point_1.Point(sRect.x, y2));
                this.extensionLinesVisualizer.addSegment(y1 > y2 ? ExtensionLinesVisualizer_1.ExtensionLineType.LeftToLeftBelow : ExtensionLinesVisualizer_1.ExtensionLineType.LeftToLeftAbove, segment, showDistance ? distanceText : "");
            }
            if (rect.right === sRect.right) {
                var segment = new segment_1.Segment(new point_1.Point(rect.right + lwCor, y1), new point_1.Point(sRect.right + lwCor, y2));
                this.extensionLinesVisualizer.addSegment(y1 > y2 ? ExtensionLinesVisualizer_1.ExtensionLineType.RightToRightBelow : ExtensionLinesVisualizer_1.ExtensionLineType.RightToRightAbove, segment, showDistance ? distanceText : "");
            }
            if (rect.x === sRect.right) {
                var segment = new segment_1.Segment(new point_1.Point(rect.x, y1), new point_1.Point(sRect.right + lwCor, y2));
                this.extensionLinesVisualizer.addSegment(y1 > y2 ? ExtensionLinesVisualizer_1.ExtensionLineType.LeftToRightBelow : ExtensionLinesVisualizer_1.ExtensionLineType.LeftToRightAbove, segment, showDistance ? distanceText : "");
            }
            if (rect.right === sRect.x) {
                var segment = new segment_1.Segment(new point_1.Point(rect.right + lwCor, y1), new point_1.Point(sRect.x, y2));
                this.extensionLinesVisualizer.addSegment(y1 > y2 ? ExtensionLinesVisualizer_1.ExtensionLineType.RightToLeftBelow : ExtensionLinesVisualizer_1.ExtensionLineType.RightToLeftAbove, segment, showDistance ? distanceText : "");
            }
        }
    };
    VisualizerManager.prototype.resetExtensionLines = function () {
        this.extensionLinesVisualizer.reset();
    };
    VisualizerManager.prototype.setResizeInfo = function (items) {
        var rect = ModelUtils_1.ModelUtils.createRectangle(items);
        var point = new point_1.Point(rect.center.x, rect.bottom + CanvasSelectionManager_1.CanvasSelectionManager.resizeInfoOffset);
        var text = this.getViewUnitText(rect.width) + " x " + this.getViewUnitText(rect.height);
        this.resizeInfoVisualizer.set(point, text);
    };
    VisualizerManager.prototype.resetResizeInfo = function () {
        this.resizeInfoVisualizer.reset();
    };
    VisualizerManager.prototype.setSelectionRectangle = function (rect) {
        this.selectionRectangleVisualizer.setRectangle(rect);
    };
    VisualizerManager.prototype.resetSelectionRectangle = function () {
        this.selectionRectangleVisualizer.reset();
    };
    VisualizerManager.prototype.getViewUnitText = function (value) {
        return ModelUtils_1.ModelUtils.getUnitText(this.settings.viewUnits, LocalizationService_1.DiagramLocalizationService.unitItems, LocalizationService_1.DiagramLocalizationService.formatUnit, value);
    };
    VisualizerManager.prototype.notifyReadOnlyChanged = function (readOnly) {
        this.readOnly = readOnly;
        if (this.readOnly) {
            this.resetConnectionPoints();
            this.resetConnectionTarget();
            this.resetExtensionLines();
            this.resetContainerTarget();
            this.resetResizeInfo();
            this.resetSelectionRectangle();
        }
    };
    VisualizerManager.prototype.notifyDragStart = function (itemKeys) { };
    VisualizerManager.prototype.notifyDragEnd = function (itemKeys) { };
    VisualizerManager.prototype.notifyDragScrollStart = function () { };
    VisualizerManager.prototype.notifyDragScrollEnd = function () { };
    VisualizerManager.prototype.onUpdateUnlocked = function (occurredEvents) { };
    return VisualizerManager;
}(batch_updatable_1.BatchUpdatableObject));
exports.VisualizerManager = VisualizerManager;


/***/ }),
/* 156 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.TargetVisualizerBase = void 0;
var TargetVisualizerBase = (function () {
    function TargetVisualizerBase(dispatcher) {
        this.dispatcher = dispatcher;
    }
    TargetVisualizerBase.prototype.getKey = function () {
        return this.key;
    };
    TargetVisualizerBase.prototype.setTargetRect = function (key, targetRect, targetStrokeWidth) {
        if (this.key !== key) {
            this.key = key;
            this.targetRect = targetRect;
            this.targetStrokeWidth = targetStrokeWidth;
            this.raiseShow();
        }
    };
    TargetVisualizerBase.prototype.reset = function () {
        if (this.key !== "-1") {
            this.key = "-1";
            this.targetRect = undefined;
            this.targetStrokeWidth = 0;
            this.raiseHide();
        }
    };
    return TargetVisualizerBase;
}());
exports.TargetVisualizerBase = TargetVisualizerBase;


/***/ }),
/* 157 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.ExtensionLinesVisualizer = exports.ExtensionLine = exports.ExtensionLineType = void 0;
var ExtensionLineType;
(function (ExtensionLineType) {
    ExtensionLineType[ExtensionLineType["LeftToLeftAbove"] = 0] = "LeftToLeftAbove";
    ExtensionLineType[ExtensionLineType["LeftToLeftBelow"] = 1] = "LeftToLeftBelow";
    ExtensionLineType[ExtensionLineType["RightToRightAbove"] = 2] = "RightToRightAbove";
    ExtensionLineType[ExtensionLineType["RightToRightBelow"] = 3] = "RightToRightBelow";
    ExtensionLineType[ExtensionLineType["LeftToRightAbove"] = 4] = "LeftToRightAbove";
    ExtensionLineType[ExtensionLineType["LeftToRightBelow"] = 5] = "LeftToRightBelow";
    ExtensionLineType[ExtensionLineType["RightToLeftAbove"] = 6] = "RightToLeftAbove";
    ExtensionLineType[ExtensionLineType["RightToLeftBelow"] = 7] = "RightToLeftBelow";
    ExtensionLineType[ExtensionLineType["TopToTopBefore"] = 8] = "TopToTopBefore";
    ExtensionLineType[ExtensionLineType["TopToTopAfter"] = 9] = "TopToTopAfter";
    ExtensionLineType[ExtensionLineType["BottomToBottomBefore"] = 10] = "BottomToBottomBefore";
    ExtensionLineType[ExtensionLineType["BottomToBottomAfter"] = 11] = "BottomToBottomAfter";
    ExtensionLineType[ExtensionLineType["TopToBottomBefore"] = 12] = "TopToBottomBefore";
    ExtensionLineType[ExtensionLineType["TopToBottomAfter"] = 13] = "TopToBottomAfter";
    ExtensionLineType[ExtensionLineType["BottomToTopBefore"] = 14] = "BottomToTopBefore";
    ExtensionLineType[ExtensionLineType["BottomToTopAfter"] = 15] = "BottomToTopAfter";
    ExtensionLineType[ExtensionLineType["HorizontalCenterAbove"] = 16] = "HorizontalCenterAbove";
    ExtensionLineType[ExtensionLineType["HorizontalCenterBelow"] = 17] = "HorizontalCenterBelow";
    ExtensionLineType[ExtensionLineType["VerticalCenterBefore"] = 18] = "VerticalCenterBefore";
    ExtensionLineType[ExtensionLineType["VerticalCenterAfter"] = 19] = "VerticalCenterAfter";
    ExtensionLineType[ExtensionLineType["VerticalCenterToPageCenter"] = 20] = "VerticalCenterToPageCenter";
    ExtensionLineType[ExtensionLineType["HorizontalCenterToPageCenter"] = 21] = "HorizontalCenterToPageCenter";
    ExtensionLineType[ExtensionLineType["LeftToPageCenter"] = 22] = "LeftToPageCenter";
    ExtensionLineType[ExtensionLineType["RightToPageCenter"] = 23] = "RightToPageCenter";
    ExtensionLineType[ExtensionLineType["TopToPageCenter"] = 24] = "TopToPageCenter";
    ExtensionLineType[ExtensionLineType["BottomToPageCenter"] = 25] = "BottomToPageCenter";
})(ExtensionLineType = exports.ExtensionLineType || (exports.ExtensionLineType = {}));
var ExtensionLine = (function () {
    function ExtensionLine(type, segment, text) {
        this.type = type;
        this.segment = segment;
        this.text = text;
    }
    return ExtensionLine;
}());
exports.ExtensionLine = ExtensionLine;
var ExtensionLinesVisualizer = (function () {
    function ExtensionLinesVisualizer(dispatcher) {
        this.dispatcher = dispatcher;
        this.lines = [];
        this.lineIndexByType = {};
    }
    ExtensionLinesVisualizer.prototype.addSegment = function (type, segment, text) {
        var curIndex = this.lineIndexByType[type];
        if (curIndex === undefined) {
            var line = new ExtensionLine(type, segment, text);
            var index = this.lines.push(line);
            this.lineIndexByType[line.type] = index - 1;
            this.raiseShow();
        }
        else if (segment.length < this.lines[curIndex].segment.length) {
            var line = new ExtensionLine(type, segment, text);
            this.lines.splice(curIndex, 1, line);
            this.raiseShow();
        }
    };
    ExtensionLinesVisualizer.prototype.update = function () {
        this.raiseShow();
    };
    ExtensionLinesVisualizer.prototype.reset = function () {
        if (this.lines.length) {
            this.lines = [];
            this.lineIndexByType = {};
            this.raiseHide();
        }
    };
    ExtensionLinesVisualizer.prototype.raiseShow = function () {
        var _this = this;
        this.dispatcher.raise1(function (l) { return l.notifyExtensionLinesShow(_this.lines); });
    };
    ExtensionLinesVisualizer.prototype.raiseHide = function () {
        this.dispatcher.raise1(function (l) { return l.notifyExtensionLinesHide(); });
    };
    return ExtensionLinesVisualizer;
}());
exports.ExtensionLinesVisualizer = ExtensionLinesVisualizer;


/***/ }),
/* 158 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.CanvasSelectionManager = exports.ACTIVE_SELECTION_CSSCLASS = exports.SELECTION_ELEMENT_CLASSNAMES = void 0;
var CanvasManagerBase_1 = __webpack_require__(42);
var GroupPrimitive_1 = __webpack_require__(39);
var Utils_1 = __webpack_require__(17);
var Event_1 = __webpack_require__(11);
var DiagramItem_1 = __webpack_require__(9);
var Utils_2 = __webpack_require__(3);
var point_1 = __webpack_require__(0);
var ExtensionLinesVisualizer_1 = __webpack_require__(157);
var Shape_1 = __webpack_require__(14);
var Connector_1 = __webpack_require__(6);
var ConnectorProperties_1 = __webpack_require__(32);
var RectaglePrimitive_1 = __webpack_require__(21);
var PathPrimitive_1 = __webpack_require__(5);
var TextPrimitive_1 = __webpack_require__(63);
var EllipsePrimitive_1 = __webpack_require__(55);
var Style_1 = __webpack_require__(26);
var unit_converter_1 = __webpack_require__(12);
var ITextMeasurer_1 = __webpack_require__(43);
var browser_1 = __webpack_require__(18);
var dom_1 = __webpack_require__(27);
var CanvasItemsManager_1 = __webpack_require__(78);
var CanvasManager_1 = __webpack_require__(140);
var metrics_1 = __webpack_require__(35);
var math_1 = __webpack_require__(31);
var ModelUtils_1 = __webpack_require__(4);
var MULTIPLE_SELECTION_KEY = "-1";
exports.SELECTION_ELEMENT_CLASSNAMES = {
    SELECTION_RECTANGLE: "selection-rect",
    CONNECTION_POINT: "connection-point",
    ACTIVE: "active",
    CONTAINER_TARGET: "container-target",
    CONNECTION_TARGET: "connection-target",
    EXTENSION_LINE: "extension-line",
    CONNECTION_MARK: "connection-mark",
    SELECTION_MARK: "selection-mark",
    LOCKED_SELECTION_MARK: "locked-selection-mark",
    ITEMS_SELECTION_RECT: "items-selection-rect",
    CONNECTOR_MULTI_SELECTION: "connector-multi-selection",
    CONNECTOR_SELECTION: "connector-selection",
    CONNECTOR_POINT_MARK: "connector-point-mark",
    CONNECTOR_SELECTION_MASK: "connector-selection-mask",
    CONNECTOR_SIDE_MARK: "connector-side-mark",
    ITEM_SELECTION_RECT: "item-selection-rect",
    ITEM_MULTI_SELECTION: "item-multi-selection-rect"
};
exports.ACTIVE_SELECTION_CSSCLASS = "dxdi-active-selection";
var CanvasSelectionManager = (function (_super) {
    __extends(CanvasSelectionManager, _super);
    function CanvasSelectionManager(parent, zoomLevel, readOnly, dom) {
        var _this = _super.call(this, zoomLevel, dom) || this;
        _this.readOnly = readOnly;
        _this.connectionPointElements = [];
        _this.extensionLineElements = [];
        _this.selectionMap = {};
        _this.parentContainer = parent;
        _this.initializeContainerElements(parent);
        return _this;
    }
    CanvasSelectionManager.prototype.initializeContainerElements = function (parent) {
        this.itemSelectionContainer = this.createAndChangePrimitiveElement(new GroupPrimitive_1.GroupPrimitive([], null), parent);
        this.visualizersContainer = this.createAndChangePrimitiveElement(new GroupPrimitive_1.GroupPrimitive([], null), parent);
        this.selectionMarksContainer = this.createAndChangePrimitiveElement(new GroupPrimitive_1.GroupPrimitive([], null), parent);
    };
    CanvasSelectionManager.prototype.clear = function () {
        Utils_1.RenderUtils.removeContent(this.itemSelectionContainer);
        Utils_1.RenderUtils.removeContent(this.selectionMarksContainer);
        Utils_1.RenderUtils.removeContent(this.visualizersContainer);
        this.selectionRectElement = undefined;
        this.resizeInfoElement = undefined;
        this.connectionPointElements = [];
        this.connectionTargetElement = undefined;
        this.containerTargetElement = undefined;
        this.extensionLineElements = [];
        this.selectionMap = {};
    };
    CanvasSelectionManager.prototype.showSelectionRect = function (rect) {
        dom_1.DomUtils.addClassName(this.parentContainer, exports.ACTIVE_SELECTION_CSSCLASS);
        var primitive = new RectaglePrimitive_1.RectanglePrimitive(rect.x, rect.y, rect.width, rect.height, Style_1.StrokeStyle.default1pxInstance, exports.SELECTION_ELEMENT_CLASSNAMES.SELECTION_RECTANGLE);
        var rectEl = this.getSelectionRectElement(primitive);
        this.changePrimitiveElement(primitive, rectEl);
    };
    CanvasSelectionManager.prototype.hideSelectionRect = function () {
        dom_1.DomUtils.removeClassName(this.parentContainer, exports.ACTIVE_SELECTION_CSSCLASS);
        if (this.selectionRectElement !== undefined)
            this.dom.changeByFunc(this.selectionRectElement, function (e) { return e.style.display = "none"; });
    };
    CanvasSelectionManager.prototype.getSelectionRectElement = function (primitive) {
        if (this.selectionRectElement !== undefined)
            this.dom.changeByFunc(this.selectionRectElement, function (e) { return e.style.display = ""; });
        else
            this.selectionRectElement = this.createPrimitiveElement(primitive, this.visualizersContainer);
        return this.selectionRectElement;
    };
    CanvasSelectionManager.prototype.showResizeInfo = function (point, text) {
        var rectPrimitive = new RectaglePrimitive_1.RectanglePrimitive(point.x, point.y, 0, 0, Style_1.StrokeStyle.default1pxInstance);
        var primitive = new GroupPrimitive_1.GroupPrimitive([
            rectPrimitive,
            new TextPrimitive_1.TextPrimitive(point.x, point.y, text, ITextMeasurer_1.TextOwner.Resize)
        ], "resize-info");
        var groupEl = this.getResizeInfoElement(primitive);
        this.changePrimitiveElement(primitive, groupEl);
        var textSize = this.dom.measurer.measureTextLine(text, null, ITextMeasurer_1.TextOwner.Resize).applyConverter(unit_converter_1.UnitConverter.pixelsToTwips);
        rectPrimitive.width = textSize.width + CanvasSelectionManager.resizeInfoTextOffset * 2;
        rectPrimitive.height = textSize.height + CanvasSelectionManager.resizeInfoTextOffset * 2;
        rectPrimitive.x = point.x - textSize.width / 2 - CanvasSelectionManager.resizeInfoTextOffset;
        rectPrimitive.y = point.y - textSize.height / 2 - CanvasSelectionManager.resizeInfoTextOffset;
        this.changePrimitiveElement(primitive, groupEl);
    };
    CanvasSelectionManager.prototype.hideResizeInfo = function () {
        if (this.resizeInfoElement !== undefined)
            this.dom.changeByFunc(this.resizeInfoElement, function (e) { return e.style.display = "none"; });
    };
    CanvasSelectionManager.prototype.getResizeInfoElement = function (primitive) {
        if (this.resizeInfoElement !== undefined)
            this.dom.changeByFunc(this.resizeInfoElement, function (e) { return e.style.display = ""; });
        else
            this.resizeInfoElement = this.createPrimitiveElement(primitive, this.visualizersContainer);
        return this.resizeInfoElement;
    };
    CanvasSelectionManager.prototype.getConnectionPointClassName = function (active, allowed) {
        var className = exports.SELECTION_ELEMENT_CLASSNAMES.CONNECTION_POINT;
        if (active)
            className += " " + exports.SELECTION_ELEMENT_CLASSNAMES.ACTIVE;
        if (!allowed)
            className += " " + CanvasItemsManager_1.NOT_VALID_CSSCLASS;
        return className;
    };
    CanvasSelectionManager.prototype.showConnectionPoint = function (index, point, key, value, active, allowed) {
        this.showConnectionPointCore(index * 2, point.x, point.y, CanvasSelectionManager.connectionPointLargeSize, CanvasSelectionManager.connectionPointLargeSize, Event_1.MouseEventElementType.ShapeConnectionPoint, key, value, exports.SELECTION_ELEMENT_CLASSNAMES.CONNECTION_POINT + " selector" + (!allowed ? " " + CanvasItemsManager_1.NOT_VALID_CSSCLASS : ""));
        this.showConnectionPointCore(index * 2 + 1, point.x, point.y, CanvasSelectionManager.connectionPointSmallSize, CanvasSelectionManager.connectionPointSmallSize, Event_1.MouseEventElementType.ShapeConnectionPoint, key, value, this.getConnectionPointClassName(active, allowed));
    };
    CanvasSelectionManager.prototype.showConnectionPointCore = function (index, cx, cy, rx, ry, type, key, value, className) {
        var primitive = new EllipsePrimitive_1.EllipsePrimitive(cx, cy, rx, ry, null, className, function (e) { return Utils_1.RenderUtils.setElementEventData(e, type, key, value); });
        var ellEl = this.getConnectionPointElement(primitive, index);
        this.changePrimitiveElement(primitive, ellEl);
    };
    CanvasSelectionManager.prototype.hideConnectionPoints = function () {
        for (var i = 0; i < this.connectionPointElements.length; i++)
            this.dom.changeByFunc(this.connectionPointElements[i], function (e) { return e.style.display = "none"; });
    };
    CanvasSelectionManager.prototype.getConnectionPointElement = function (primitive, index) {
        var ellEl = this.connectionPointElements[index];
        if (ellEl !== undefined)
            this.dom.changeByFunc(ellEl, function (e) { return e.style.display = ""; });
        else {
            ellEl = this.createPrimitiveElement(primitive, this.visualizersContainer);
            this.connectionPointElements[index] = ellEl;
        }
        return ellEl;
    };
    CanvasSelectionManager.prototype.showContainerTarget = function (index, targetRect) {
        var primitive = new RectaglePrimitive_1.RectanglePrimitive(targetRect.x, targetRect.y, targetRect.width, targetRect.height, null, exports.SELECTION_ELEMENT_CLASSNAMES.CONTAINER_TARGET);
        var rectEl = this.getContainerTargetElement(primitive);
        this.changePrimitiveElement(primitive, rectEl);
    };
    CanvasSelectionManager.prototype.hideContainerTarget = function () {
        if (this.containerTargetElement)
            this.dom.changeByFunc(this.containerTargetElement, function (e) { return e.style.display = "none"; });
    };
    CanvasSelectionManager.prototype.getContainerTargetElement = function (primitive) {
        if (this.containerTargetElement !== undefined)
            this.dom.changeByFunc(this.containerTargetElement, function (e) { return e.style.display = ""; });
        else
            this.containerTargetElement = this.createPrimitiveElement(primitive, this.itemSelectionContainer);
        return this.containerTargetElement;
    };
    CanvasSelectionManager.prototype.showConnectionTarget = function (index, targetRect) {
        var primitive = new RectaglePrimitive_1.RectanglePrimitive(targetRect.x, targetRect.y, targetRect.width, targetRect.height, null, exports.SELECTION_ELEMENT_CLASSNAMES.CONNECTION_TARGET);
        var rectEl = this.getConnectionTargetElement(primitive);
        this.changePrimitiveElement(primitive, rectEl);
    };
    CanvasSelectionManager.prototype.hideConnectionTarget = function () {
        if (this.connectionTargetElement)
            this.dom.changeByFunc(this.connectionTargetElement, function (e) { return e.style.display = "none"; });
    };
    CanvasSelectionManager.prototype.getConnectionTargetElement = function (primitive) {
        if (this.connectionTargetElement !== undefined)
            this.dom.changeByFunc(this.connectionTargetElement, function (e) { return e.style.display = ""; });
        else
            this.connectionTargetElement = this.createPrimitiveElement(primitive, this.itemSelectionContainer);
        return this.connectionTargetElement;
    };
    CanvasSelectionManager.prototype.showExtensionLine = function (index, type, startPoint, endPoint, text) {
        var className = exports.SELECTION_ELEMENT_CLASSNAMES.EXTENSION_LINE;
        if (type === ExtensionLinesVisualizer_1.ExtensionLineType.VerticalCenterAfter || type === ExtensionLinesVisualizer_1.ExtensionLineType.VerticalCenterBefore ||
            type === ExtensionLinesVisualizer_1.ExtensionLineType.HorizontalCenterAbove || type === ExtensionLinesVisualizer_1.ExtensionLineType.HorizontalCenterBelow)
            className += " center";
        if (type === ExtensionLinesVisualizer_1.ExtensionLineType.VerticalCenterToPageCenter || type === ExtensionLinesVisualizer_1.ExtensionLineType.HorizontalCenterToPageCenter ||
            type === ExtensionLinesVisualizer_1.ExtensionLineType.LeftToPageCenter || type === ExtensionLinesVisualizer_1.ExtensionLineType.RightToPageCenter ||
            type === ExtensionLinesVisualizer_1.ExtensionLineType.TopToPageCenter || type === ExtensionLinesVisualizer_1.ExtensionLineType.BottomToPageCenter)
            className += " page";
        var x1_1 = 0;
        var y1_1 = 0;
        var x1_2 = 0;
        var y1_2 = 0;
        var x2_1 = 0;
        var y2_1 = 0;
        var x2_2 = 0;
        var y2_2 = 0;
        if (startPoint.y === endPoint.y) {
            x1_1 = startPoint.x - CanvasSelectionManager.extensionLineWidth;
            y1_1 = startPoint.y - CanvasSelectionManager.extensionLineEndingSize;
            x1_2 = startPoint.x - CanvasSelectionManager.extensionLineWidth;
            y1_2 = startPoint.y + CanvasSelectionManager.extensionLineEndingSize;
            x2_1 = endPoint.x - CanvasSelectionManager.extensionLineWidth;
            y2_1 = startPoint.y - CanvasSelectionManager.extensionLineEndingSize;
            x2_2 = endPoint.x - CanvasSelectionManager.extensionLineWidth;
            y2_2 = startPoint.y + CanvasSelectionManager.extensionLineEndingSize;
        }
        else if (startPoint.x === endPoint.x) {
            x1_1 = startPoint.x - CanvasSelectionManager.extensionLineEndingSize;
            y1_1 = startPoint.y - CanvasSelectionManager.extensionLineWidth;
            x1_2 = startPoint.x + CanvasSelectionManager.extensionLineEndingSize;
            y1_2 = startPoint.y - CanvasSelectionManager.extensionLineWidth;
            x2_1 = startPoint.x - CanvasSelectionManager.extensionLineEndingSize;
            y2_1 = endPoint.y - CanvasSelectionManager.extensionLineWidth;
            x2_2 = startPoint.x + CanvasSelectionManager.extensionLineEndingSize;
            y2_2 = endPoint.y - CanvasSelectionManager.extensionLineWidth;
        }
        var sizeLineXCorr = 0;
        var sizeLineYCorr = 0;
        if (type === ExtensionLinesVisualizer_1.ExtensionLineType.RightToRightAbove || type === ExtensionLinesVisualizer_1.ExtensionLineType.RightToRightBelow)
            sizeLineXCorr -= CanvasSelectionManager.extensionLineWidth;
        if (type === ExtensionLinesVisualizer_1.ExtensionLineType.BottomToBottomAfter || type === ExtensionLinesVisualizer_1.ExtensionLineType.BottomToBottomBefore)
            sizeLineYCorr -= CanvasSelectionManager.extensionLineWidth;
        var children = [
            new PathPrimitive_1.PathPrimitive([
                PathPrimitive_1.PathPrimitiveMoveToCommand.fromPoint(startPoint.clone().offset(sizeLineXCorr, sizeLineYCorr)),
                PathPrimitive_1.PathPrimitiveLineToCommand.fromPoint(endPoint.clone().offset(sizeLineXCorr, sizeLineYCorr))
            ], Style_1.StrokeStyle.default1pxInstance, "size-line"),
            new PathPrimitive_1.PathPrimitive([
                new PathPrimitive_1.PathPrimitiveMoveToCommand(x1_1, y1_1),
                new PathPrimitive_1.PathPrimitiveLineToCommand(x1_2, y1_2),
                new PathPrimitive_1.PathPrimitiveMoveToCommand(x2_1, y2_1),
                new PathPrimitive_1.PathPrimitiveLineToCommand(x2_2, y2_2)
            ], Style_1.StrokeStyle.default1pxInstance),
            new TextPrimitive_1.TextPrimitive((endPoint.x + startPoint.x) / 2, (endPoint.y + startPoint.y) / 2, text, ITextMeasurer_1.TextOwner.ExtensionLine, undefined, undefined, undefined, null, undefined, null, CanvasManagerBase_1.PAGE_BG_TEXTFLOOR_FILTER_ID)
        ];
        var primitive = new GroupPrimitive_1.GroupPrimitive(children, className);
        var ellEl = this.getExtensionLineElement(primitive, index);
        this.changePrimitiveElement(primitive, ellEl);
    };
    CanvasSelectionManager.prototype.hideExtensionLines = function () {
        for (var i = 0; i < this.extensionLineElements.length; i++)
            if (this.extensionLineElements[i])
                this.dom.changeByFunc(this.extensionLineElements[i], function (e) { return e.style.display = "none"; });
    };
    CanvasSelectionManager.prototype.getExtensionLineElement = function (primitive, index) {
        var ellEl = this.extensionLineElements[index];
        if (ellEl !== undefined)
            this.dom.changeByFunc(ellEl, function (e) { return e.style.display = ""; });
        else {
            ellEl = this.createPrimitiveElement(primitive, this.visualizersContainer);
            this.extensionLineElements[index] = (ellEl);
        }
        return ellEl;
    };
    CanvasSelectionManager.prototype.getOrCreateShapeSelection = function (shape, usedItems) {
        var element = this.selectionMap[shape.key];
        if (!element) {
            element = new ShapeSelectionElement(this.itemSelectionContainer, this.selectionMarksContainer, this.actualZoom, this.readOnly, this.dom, shape.key, shape.isLocked, shape.rectangle, shape.style, shape.allowResizeHorizontally, shape.allowResizeVertically, shape.description.getParameterPoints(shape));
            this.selectionMap[shape.key] = element;
        }
        usedItems && (usedItems[shape.key] = true);
        return element;
    };
    CanvasSelectionManager.prototype.getOrCreateConnectorSelection = function (connector, usedItems) {
        var element = this.selectionMap[connector.key];
        var points = connector.getRenderPoints();
        if (!element) {
            element = new ConnectorSelectionElement(this.itemSelectionContainer, this.selectionMarksContainer, this.actualZoom, this.readOnly, this.dom, connector.key, connector.isLocked, connector.rectangle, points, connector.style, connector.styleText, connector.enableText, connector.texts.map(function (t) {
                var textInfo = Utils_2.GeometryUtils.getPathPointByPosition(points, t.position);
                return {
                    text: connector.getText(t.position),
                    point: textInfo[0],
                    pointIndex: textInfo[1],
                    pos: t.position
                };
            }).sort(function (a, b) { return a.pos - b.pos; }), connector.points, connector.properties.lineOption);
            this.selectionMap[connector.key] = element;
        }
        usedItems && (usedItems[connector.key] = true);
        return element;
    };
    CanvasSelectionManager.prototype.getOrCreateMultipleSelection = function (usedItems) {
        var element = this.selectionMap[MULTIPLE_SELECTION_KEY];
        if (!element) {
            element = new MultipleSelectionElement(this.itemSelectionContainer, this.selectionMarksContainer, this.actualZoom, this.readOnly, this.dom);
            this.selectionMap[MULTIPLE_SELECTION_KEY] = element;
        }
        usedItems[MULTIPLE_SELECTION_KEY] = true;
        return element;
    };
    CanvasSelectionManager.prototype.getMultipleSelection = function () {
        return this.selectionMap[MULTIPLE_SELECTION_KEY];
    };
    CanvasSelectionManager.prototype.updateShapeSelection = function (shape, multipleSelection) {
        if (shape.key in this.selectionMap) {
            this.getOrCreateShapeSelection(shape).onModelChanged(shape.isLocked, shape.rectangle, shape.style, shape.allowResizeHorizontally, shape.allowResizeVertically, shape.description.getParameterPoints(shape));
            multipleSelection && multipleSelection.onModelItemChanged(shape.key, shape.rectangle);
        }
    };
    CanvasSelectionManager.prototype.updateConnectorSelection = function (connector, multipleSelection) {
        if (connector.key in this.selectionMap) {
            var renderPoints_1 = connector.getRenderPoints();
            this.getOrCreateConnectorSelection(connector)
                .onModelChanged(connector.isLocked, connector.rectangle, renderPoints_1, connector.style, connector.styleText, connector.enableText, connector.texts.map(function (t) {
                var textPos = Utils_2.GeometryUtils.getPathPointByPosition(renderPoints_1, t.position);
                return {
                    text: connector.getText(t.position),
                    pointIndex: textPos[1],
                    pos: t.position,
                    point: textPos[0]
                };
            }).sort(function (a, b) { return a.pos - b.pos; }), connector.points, connector.properties.lineOption);
            multipleSelection && multipleSelection.onModelItemChanged(connector.key, connector.rectangle);
        }
    };
    CanvasSelectionManager.prototype.hideOutdatedSelection = function (updated) {
        var _this = this;
        Object.keys(this.selectionMap)
            .filter(function (k) { return !updated[k]; })
            .forEach(function (k) {
            _this.selectionMap[k].destroy();
            delete _this.selectionMap[k];
        });
    };
    CanvasSelectionManager.prototype.selectionCanBeDrawn = function (item) {
        return !item.container || (item.container.expanded && this.selectionCanBeDrawn(item.container));
    };
    CanvasSelectionManager.prototype.notifySelectionChanged = function (selection) {
        var _this = this;
        var items = selection.getSelectedItems(true).filter(function (item) { return _this.selectionCanBeDrawn(item); });
        var changedItems = {};
        var isMultipleSelection = items.length > 1;
        var shapes = selection.getSelectedShapes(true).filter(function (shape) { return _this.selectionCanBeDrawn(shape); });
        var connectors = selection.getSelectedConnectors(true).filter(function (connector) { return _this.selectionCanBeDrawn(connector); });
        shapes.forEach(function (shape) { return _this.getOrCreateShapeSelection(shape, changedItems).onSelectionChanged(isMultipleSelection); });
        connectors.forEach(function (connector) { return _this.getOrCreateConnectorSelection(connector, changedItems).onSelectionChanged(isMultipleSelection); });
        if (isMultipleSelection) {
            var strokeWidth = items.length > 0 ? items[0].strokeWidth : 0;
            var rectangles_1 = {};
            items.filter(function (i) { return !i.isLocked; }).forEach(function (item) { return rectangles_1[item.key] = item.rectangle; });
            this.getOrCreateMultipleSelection(changedItems).onSelectionChanged(!!shapes.filter(function (i) { return !i.isLocked; }).length, strokeWidth, rectangles_1);
        }
        this.hideOutdatedSelection(changedItems);
    };
    CanvasSelectionManager.prototype.applyChangesCore = function (changes) {
        _super.prototype.applyChangesCore.call(this, changes);
        var multipleSelection = this.getMultipleSelection();
        multipleSelection && multipleSelection.onModelChanged();
    };
    CanvasSelectionManager.prototype.applyChange = function (change) {
        var multipleSelection = this.getMultipleSelection();
        if (change.item instanceof Shape_1.Shape)
            this.updateShapeSelection(change.item, multipleSelection);
        else if (change.item instanceof Connector_1.Connector)
            this.updateConnectorSelection(change.item, multipleSelection);
    };
    CanvasSelectionManager.prototype.notifyPageColorChanged = function (color) { };
    CanvasSelectionManager.prototype.notifyPageSizeChanged = function (pageSize, pageLandscape) { };
    CanvasSelectionManager.prototype.notifyActualZoomChanged = function (actualZoom) {
        var _this = this;
        Object.keys(this.selectionMap).forEach(function (k) { return _this.selectionMap[k].notifyZoomChanged(actualZoom); });
        this.actualZoom = actualZoom;
    };
    CanvasSelectionManager.prototype.notifyViewAdjusted = function (canvasOffset) { };
    CanvasSelectionManager.prototype.notifyReadOnlyChanged = function (readOnly) {
        var _this = this;
        this.readOnly = readOnly;
        Object.keys(this.selectionMap).forEach(function (k) { return _this.selectionMap[k].notifyReadOnlyChanged(readOnly); });
    };
    CanvasSelectionManager.prototype.notifySelectionRectShow = function (rect) {
        this.showSelectionRect(rect.clone().multiply(this.actualZoom, this.actualZoom));
    };
    CanvasSelectionManager.prototype.notifySelectionRectHide = function () {
        this.hideSelectionRect();
    };
    CanvasSelectionManager.prototype.notifyResizeInfoShow = function (point, text) {
        this.showResizeInfo(point.clone().multiply(this.actualZoom, this.actualZoom), text);
    };
    CanvasSelectionManager.prototype.notifyResizeInfoHide = function () {
        this.hideResizeInfo();
    };
    CanvasSelectionManager.prototype.notifyConnectionPointsShow = function (key, points, activePointIndex, outsideRectangle) {
        var _this = this;
        this.hideConnectionPoints();
        points.forEach(function (p, index) {
            var point = p.point.clone().multiply(_this.actualZoom, _this.actualZoom);
            if (outsideRectangle)
                switch (p.side) {
                    case DiagramItem_1.ConnectionPointSide.North:
                        point.y = outsideRectangle.y * _this.actualZoom - CanvasSelectionManager.connectionPointShift;
                        break;
                    case DiagramItem_1.ConnectionPointSide.South:
                        point.y = outsideRectangle.bottom * _this.actualZoom + CanvasSelectionManager.connectionPointShift;
                        break;
                    case DiagramItem_1.ConnectionPointSide.West:
                        point.x = outsideRectangle.x * _this.actualZoom - CanvasSelectionManager.connectionPointShift;
                        break;
                    case DiagramItem_1.ConnectionPointSide.East:
                        point.x = outsideRectangle.right * _this.actualZoom + CanvasSelectionManager.connectionPointShift;
                        break;
                }
            _this.showConnectionPoint(index, point, key, index, index === activePointIndex, p.allowed);
        });
    };
    CanvasSelectionManager.prototype.notifyConnectionPointsHide = function () {
        this.hideConnectionPoints();
    };
    CanvasSelectionManager.prototype.notifyConnectionTargetShow = function (key, info) {
        if (!info.allowed)
            return;
        var rect = CanvasSelectionManager.correctSelectionRect(info.rect.clone().multiply(this.actualZoom, this.actualZoom), info.strokeWidth, CanvasSelectionManager.connectionTargetBorderWidth, this.actualZoom, 0);
        this.showConnectionTarget(0, rect);
    };
    CanvasSelectionManager.prototype.notifyConnectionTargetHide = function () {
        this.hideConnectionTarget();
    };
    CanvasSelectionManager.prototype.notifyContainerTargetShow = function (key, info) {
        var rect = CanvasSelectionManager.correctSelectionRect(info.rect.clone().multiply(this.actualZoom, this.actualZoom), info.strokeWidth, CanvasSelectionManager.connectionTargetBorderWidth, this.actualZoom, 0);
        this.showContainerTarget(0, rect);
    };
    CanvasSelectionManager.prototype.notifyContainerTargetHide = function () {
        this.hideContainerTarget();
    };
    CanvasSelectionManager.prototype.notifyExtensionLinesShow = function (lines) {
        var _this = this;
        this.hideExtensionLines();
        lines.forEach(function (line, index) {
            _this.showExtensionLine(index, line.type, line.segment.startPoint.clone().multiply(_this.actualZoom, _this.actualZoom), line.segment.endPoint.clone().multiply(_this.actualZoom, _this.actualZoom), line.text);
        });
    };
    CanvasSelectionManager.prototype.notifyExtensionLinesHide = function () {
        this.hideExtensionLines();
    };
    CanvasSelectionManager.prototype.notifyDragStart = function (itemKeys) {
        this.dom.changeByFunc(this.selectionMarksContainer, function (e) { return e.style.display = "none"; });
    };
    CanvasSelectionManager.prototype.notifyDragEnd = function (itemKeys) {
        this.dom.changeByFunc(this.selectionMarksContainer, function (e) { return e.style.display = ""; });
    };
    CanvasSelectionManager.prototype.notifyDragScrollStart = function () { };
    CanvasSelectionManager.prototype.notifyDragScrollEnd = function () { };
    CanvasSelectionManager.prototype.notifyTextInputStart = function (item, text, position, size) {
        this.dom.changeByFunc(this.visualizersContainer, function (e) { return e.style.display = "none"; });
    };
    CanvasSelectionManager.prototype.notifyTextInputEnd = function (item, captureFocus) {
        this.dom.changeByFunc(this.visualizersContainer, function (e) { return e.style.display = ""; });
    };
    CanvasSelectionManager.prototype.notifyTextInputPermissionsCheck = function (item, allowed) { };
    CanvasSelectionManager.correctSelectionRect = function (rect, targetLineWidth, selectionLineWidth, zoomLevel, outsideOffset) {
        if (outsideOffset === void 0) { outsideOffset = CanvasSelectionManager.selectionOffset; }
        var evenOddWidth = unit_converter_1.UnitConverter.twipsToPixels(targetLineWidth) % 2 !== unit_converter_1.UnitConverter.twipsToPixels(selectionLineWidth) % 2;
        var corr = Math.ceil(targetLineWidth / 2 * zoomLevel);
        rect = rect.clone().inflate(corr, corr);
        var lwCorr = Math.floor(selectionLineWidth / 2);
        rect.x -= lwCorr;
        rect.y -= lwCorr;
        rect.width += selectionLineWidth;
        rect.height += selectionLineWidth;
        if (evenOddWidth) {
            var correction = CanvasSelectionManager.evenOddSelectionCorrection * (unit_converter_1.UnitConverter.twipsToPixels(selectionLineWidth) % 2 === 1 ? -1 : 1);
            rect = rect.clone().moveRectangle(correction, correction);
        }
        return rect.clone().inflate(outsideOffset, outsideOffset);
    };
    CanvasSelectionManager.selectionMarkSize = unit_converter_1.UnitConverter.pixelsToTwips(10);
    CanvasSelectionManager.lockedSelectionMarkSize = unit_converter_1.UnitConverter.pixelsToTwips(8);
    CanvasSelectionManager.selectionOffset = unit_converter_1.UnitConverter.pixelsToTwips(2);
    CanvasSelectionManager.selectionRectLineWidth = unit_converter_1.UnitConverter.pixelsToTwips(1);
    CanvasSelectionManager.multiSelectionRectLineWidth = unit_converter_1.UnitConverter.pixelsToTwips(1);
    CanvasSelectionManager.connectionPointSmallSize = unit_converter_1.UnitConverter.pixelsToTwips(5);
    CanvasSelectionManager.connectionPointLargeSize = unit_converter_1.UnitConverter.pixelsToTwips(12);
    CanvasSelectionManager.connectionPointShift = unit_converter_1.UnitConverter.pixelsToTwips(16);
    CanvasSelectionManager.connectionTargetBorderWidth = unit_converter_1.UnitConverter.pixelsToTwips(2);
    CanvasSelectionManager.geomertyMarkSize = unit_converter_1.UnitConverter.pixelsToTwips(8);
    CanvasSelectionManager.connectorPointMarkSize = unit_converter_1.UnitConverter.pixelsToTwips(6);
    CanvasSelectionManager.connectorSideMarkSize = unit_converter_1.UnitConverter.pixelsToTwips(6);
    CanvasSelectionManager.extensionLineWidth = unit_converter_1.UnitConverter.pixelsToTwips(1);
    CanvasSelectionManager.extensionLineOffset = unit_converter_1.UnitConverter.pixelsToTwips(1);
    CanvasSelectionManager.extensionLineEndingSize = unit_converter_1.UnitConverter.pixelsToTwips(6);
    CanvasSelectionManager.resizeInfoOffset = unit_converter_1.UnitConverter.pixelsToTwips(16);
    CanvasSelectionManager.resizeInfoTextOffset = unit_converter_1.UnitConverter.pixelsToTwips(2);
    CanvasSelectionManager.resizeInfoLineWidth = unit_converter_1.UnitConverter.pixelsToTwips(1);
    CanvasSelectionManager.evenOddSelectionCorrection = unit_converter_1.UnitConverter.pixelsToTwips(1);
    return CanvasSelectionManager;
}(CanvasManager_1.CanvasManager));
exports.CanvasSelectionManager = CanvasSelectionManager;
var CanvasElement = (function () {
    function CanvasElement(rectsContainer, marksContainer, key, zoomLevel, readOnly, dom) {
        this.rectsContainer = rectsContainer;
        this.marksContainer = marksContainer;
        this.key = key;
        this.zoomLevel = zoomLevel;
        this.readOnly = readOnly;
        this.dom = dom;
        this.elements = {};
        this.updatedElements = {};
    }
    CanvasElement.prototype.notifyZoomChanged = function (zoom) {
        if (this.zoomLevel !== zoom) {
            this.zoomLevel = zoom;
            this.redraw();
        }
    };
    CanvasElement.prototype.notifyReadOnlyChanged = function (readOnly) {
        this.readOnly = readOnly;
        this.redraw();
    };
    CanvasElement.prototype.destroy = function () {
        var _this = this;
        Object.keys(this.elements)
            .forEach(function (key) {
            _this.elements[key].parentNode.removeChild(_this.elements[key]);
            delete _this.elements[key];
        });
    };
    CanvasElement.prototype.redraw = function () {
        var _this = this;
        this.updatedElements = {};
        this.redrawCore();
        Object.keys(this.elements)
            .filter(function (key) { return !_this.updatedElements[key]; })
            .forEach(function (key) {
            _this.elements[key].parentNode.removeChild(_this.elements[key]);
            delete _this.elements[key];
        });
        this.updatedElements = {};
    };
    CanvasElement.prototype.drawSelectionMarks = function (rect, allowResizeHorizontally, allowResizeVertically) {
        if (this.readOnly)
            return;
        var hasEWMarks = allowResizeHorizontally && rect.height > CanvasSelectionManager.selectionMarkSize * 3;
        var hasNSMarks = allowResizeVertically && rect.width > CanvasSelectionManager.selectionMarkSize * 3;
        var hasCornerMarks = allowResizeHorizontally || allowResizeVertically;
        if (hasCornerMarks)
            this.drawSelectionMark(0, new point_1.Point(rect.x, rect.y), CanvasSelectionManager.selectionMarkSize, Event_1.MouseEventElementType.ShapeResizeBox, Event_1.ResizeEventSource.ResizeBox_NW, exports.SELECTION_ELEMENT_CLASSNAMES.SELECTION_MARK);
        if (hasNSMarks && !browser_1.Browser.TouchUI)
            this.drawSelectionMark(1, new point_1.Point(rect.x + rect.width / 2, rect.y), CanvasSelectionManager.selectionMarkSize, Event_1.MouseEventElementType.ShapeResizeBox, Event_1.ResizeEventSource.ResizeBox_N, exports.SELECTION_ELEMENT_CLASSNAMES.SELECTION_MARK);
        if (hasCornerMarks)
            this.drawSelectionMark(2, new point_1.Point(rect.right, rect.y), CanvasSelectionManager.selectionMarkSize, Event_1.MouseEventElementType.ShapeResizeBox, Event_1.ResizeEventSource.ResizeBox_NE, exports.SELECTION_ELEMENT_CLASSNAMES.SELECTION_MARK);
        if (hasEWMarks && !browser_1.Browser.TouchUI)
            this.drawSelectionMark(3, new point_1.Point(rect.right, rect.y + rect.height / 2), CanvasSelectionManager.selectionMarkSize, Event_1.MouseEventElementType.ShapeResizeBox, Event_1.ResizeEventSource.ResizeBox_E, exports.SELECTION_ELEMENT_CLASSNAMES.SELECTION_MARK);
        if (hasCornerMarks)
            this.drawSelectionMark(4, new point_1.Point(rect.right, rect.bottom), CanvasSelectionManager.selectionMarkSize, Event_1.MouseEventElementType.ShapeResizeBox, Event_1.ResizeEventSource.ResizeBox_SE, exports.SELECTION_ELEMENT_CLASSNAMES.SELECTION_MARK);
        if (hasNSMarks && !browser_1.Browser.TouchUI)
            this.drawSelectionMark(5, new point_1.Point(rect.x + rect.width / 2, rect.bottom), CanvasSelectionManager.selectionMarkSize, Event_1.MouseEventElementType.ShapeResizeBox, Event_1.ResizeEventSource.ResizeBox_S, exports.SELECTION_ELEMENT_CLASSNAMES.SELECTION_MARK);
        if (hasCornerMarks)
            this.drawSelectionMark(6, new point_1.Point(rect.x, rect.bottom), CanvasSelectionManager.selectionMarkSize, Event_1.MouseEventElementType.ShapeResizeBox, Event_1.ResizeEventSource.ResizeBox_SW, exports.SELECTION_ELEMENT_CLASSNAMES.SELECTION_MARK);
        if (hasEWMarks && !browser_1.Browser.TouchUI)
            this.drawSelectionMark(7, new point_1.Point(rect.x, rect.y + rect.height / 2), CanvasSelectionManager.selectionMarkSize, Event_1.MouseEventElementType.ShapeResizeBox, Event_1.ResizeEventSource.ResizeBox_W, exports.SELECTION_ELEMENT_CLASSNAMES.SELECTION_MARK);
    };
    CanvasElement.prototype.drawSelectionMark = function (index, point, size, type, value, className) {
        var _this = this;
        this.getOrCreateElement("SM" + index, new RectaglePrimitive_1.RectanglePrimitive(point.x - size / 2, point.y - size / 2, size, size, null, className, undefined, function (el) {
            Utils_1.RenderUtils.setElementEventData(el, type, _this.key, value);
        }), this.marksContainer);
    };
    CanvasElement.prototype.drawSelectionRect = function (rectangle, type, className) {
        var primitive = new RectaglePrimitive_1.RectanglePrimitive(rectangle.x, rectangle.y, rectangle.width, rectangle.height, Style_1.StrokeStyle.default1pxInstance, className, undefined, function (el) {
            Utils_1.RenderUtils.setElementEventData(el, type, "-1", -1);
        });
        this.getOrCreateElement("shapeSelection", primitive, this.rectsContainer);
    };
    CanvasElement.prototype.getOrCreateElement = function (cacheKey, primitive, container) {
        var element = this.elements[cacheKey];
        if (!element) {
            element = primitive.createElement(function (el) { return container.appendChild(el); });
            this.elements[cacheKey] = element;
        }
        this.updatedElements[cacheKey] = true;
        this.dom.changeByPrimitive(element, primitive);
        return element;
    };
    return CanvasElement;
}());
var ItemSelectionElement = (function (_super) {
    __extends(ItemSelectionElement, _super);
    function ItemSelectionElement(rectsContainer, marksContainer, key, zoomLevel, readOnly, dom, isLocked, rectangle) {
        var _this = _super.call(this, rectsContainer, marksContainer, key, zoomLevel, readOnly, dom) || this;
        _this.isLocked = isLocked;
        _this.rectangle = rectangle;
        return _this;
    }
    ItemSelectionElement.prototype.onSelectionChanged = function (isMultipleSelection) {
        if (this.isMultipleSelection !== isMultipleSelection) {
            this.isMultipleSelection = isMultipleSelection;
            this.redraw();
        }
    };
    ItemSelectionElement.prototype.isLockedRender = function () {
        return this.isLocked && !this.readOnly;
    };
    ItemSelectionElement.prototype.drawLockedSelectionMark = function (index, point, size, className) {
        var primitive = new PathPrimitive_1.PathPrimitive([
            new PathPrimitive_1.PathPrimitiveMoveToCommand(point.x - size / 2, point.y - size / 2),
            new PathPrimitive_1.PathPrimitiveLineToCommand(point.x + size / 2, point.y + size / 2),
            new PathPrimitive_1.PathPrimitiveMoveToCommand(point.x + size / 2, point.y - size / 2),
            new PathPrimitive_1.PathPrimitiveLineToCommand(point.x - size / 2, point.y + size / 2)
        ], null, className);
        this.getOrCreateElement("LSM" + index, primitive, this.marksContainer);
    };
    return ItemSelectionElement;
}(CanvasElement));
var MultipleSelectionElement = (function (_super) {
    __extends(MultipleSelectionElement, _super);
    function MultipleSelectionElement(rectsContainer, marksContainer, zoomLevel, readOnly, dom) {
        var _this = _super.call(this, rectsContainer, marksContainer, "-1", zoomLevel, readOnly, dom) || this;
        _this.rectangles = {};
        return _this;
    }
    MultipleSelectionElement.prototype.onModelItemChanged = function (key, rectangle) {
        if (key in this.rectangles)
            this.rectangles[key] = rectangle;
    };
    MultipleSelectionElement.prototype.onModelChanged = function () {
        this.redraw();
    };
    MultipleSelectionElement.prototype.onSelectionChanged = function (needDrawSelectionMarks, strokeWidth, rectangles) {
        this.needDrawSelectionMarks = needDrawSelectionMarks;
        this.strokeWidth = strokeWidth;
        this.rectangles = rectangles;
        this.redraw();
    };
    MultipleSelectionElement.prototype.redrawCore = function () {
        var _this = this;
        var rectKeys = Object.keys(this.rectangles);
        if (!rectKeys.length)
            return;
        var rect = Utils_2.GeometryUtils.getCommonRectangle(rectKeys.map(function (key) { return _this.rectangles[key]; })).clone().multiply(this.zoomLevel, this.zoomLevel);
        var selRect = CanvasSelectionManager.correctSelectionRect(rect, this.strokeWidth, CanvasSelectionManager.selectionRectLineWidth, this.zoomLevel);
        this.drawSelectionRect(selRect, Event_1.MouseEventElementType.SelectionRect, exports.SELECTION_ELEMENT_CLASSNAMES.ITEMS_SELECTION_RECT);
        if (this.needDrawSelectionMarks)
            this.drawSelectionMarks(rect, true, true);
    };
    return MultipleSelectionElement;
}(CanvasElement));
var ShapeSelectionElement = (function (_super) {
    __extends(ShapeSelectionElement, _super);
    function ShapeSelectionElement(rectsContainer, marksContainer, zoomLevel, readOnly, dom, key, isLocked, rectangle, style, allowResizeHorizontally, allowResizeVertically, shapeParameterPoints) {
        var _this = _super.call(this, rectsContainer, marksContainer, key, zoomLevel, readOnly, dom, isLocked, rectangle) || this;
        _this.style = style;
        _this.allowResizeHorizontally = allowResizeHorizontally;
        _this.allowResizeVertically = allowResizeVertically;
        _this.shapeParameterPoints = shapeParameterPoints;
        return _this;
    }
    ShapeSelectionElement.prototype.onModelChanged = function (isLocked, rectangle, style, allowResizeHorizontally, allowResizeVertically, shapeParameterPoints) {
        this.isLocked = isLocked;
        this.rectangle = rectangle;
        this.style = style;
        this.allowResizeHorizontally = allowResizeHorizontally;
        this.allowResizeVertically = allowResizeVertically;
        this.shapeParameterPoints = shapeParameterPoints;
        this.redraw();
    };
    ShapeSelectionElement.prototype.redrawCore = function () {
        var rect = this.rectangle.clone().multiply(this.zoomLevel, this.zoomLevel);
        if (this.isLockedRender())
            this.drawLockedSelection(rect);
        else
            this.drawUnlockedSelection(rect);
    };
    ShapeSelectionElement.prototype.drawLockedSelection = function (rect) {
        this.drawLockedSelectionMark(0, new point_1.Point(rect.x, rect.y), CanvasSelectionManager.lockedSelectionMarkSize, exports.SELECTION_ELEMENT_CLASSNAMES.LOCKED_SELECTION_MARK);
        this.drawLockedSelectionMark(1, new point_1.Point(rect.right, rect.y), CanvasSelectionManager.lockedSelectionMarkSize, exports.SELECTION_ELEMENT_CLASSNAMES.LOCKED_SELECTION_MARK);
        this.drawLockedSelectionMark(2, new point_1.Point(rect.right, rect.bottom), CanvasSelectionManager.lockedSelectionMarkSize, exports.SELECTION_ELEMENT_CLASSNAMES.LOCKED_SELECTION_MARK);
        this.drawLockedSelectionMark(3, new point_1.Point(rect.x, rect.bottom), CanvasSelectionManager.lockedSelectionMarkSize, exports.SELECTION_ELEMENT_CLASSNAMES.LOCKED_SELECTION_MARK);
    };
    ShapeSelectionElement.prototype.drawUnlockedSelection = function (rect) {
        var selRect = CanvasSelectionManager.correctSelectionRect(rect, this.style.strokeWidth, CanvasSelectionManager.selectionRectLineWidth, this.zoomLevel);
        this.drawSelectionRect(selRect, Event_1.MouseEventElementType.SelectionRect, this.isMultipleSelection ? exports.SELECTION_ELEMENT_CLASSNAMES.ITEM_MULTI_SELECTION : exports.SELECTION_ELEMENT_CLASSNAMES.ITEM_SELECTION_RECT);
        if (!this.isMultipleSelection)
            this.drawSelectionMarks(rect, this.allowResizeHorizontally, this.allowResizeVertically);
        this.drawShapeParameterPoints();
    };
    ShapeSelectionElement.prototype.drawShapeParameterPoints = function () {
        var _this = this;
        if (this.readOnly)
            return;
        this.shapeParameterPoints.forEach(function (pp, index) {
            var point = pp.point.clone().multiply(_this.zoomLevel, _this.zoomLevel);
            _this.drawShapeParameterPoint(point, index, pp.key);
        });
    };
    ShapeSelectionElement.prototype.drawShapeParameterPoint = function (point, index, pointKey) {
        var _this = this;
        var size = CanvasSelectionManager.geomertyMarkSize;
        var primitive = new RectaglePrimitive_1.RectanglePrimitive(point.x - size / 2, point.y - size / 2, size, size, null, "geometry-mark", undefined, function (el) {
            Utils_1.RenderUtils.setElementEventData(el, Event_1.MouseEventElementType.ShapeParameterBox, _this.key, pointKey);
        });
        this.getOrCreateElement("pp" + index.toString(), primitive, this.marksContainer);
    };
    return ShapeSelectionElement;
}(ItemSelectionElement));
var ConnectorSelectionElement = (function (_super) {
    __extends(ConnectorSelectionElement, _super);
    function ConnectorSelectionElement(rectsContainer, marksContainer, zoomLevel, readOnly, dom, key, isLocked, rectangle, renderPoints, style, styleText, enableText, texts, points, lineType) {
        var _this = _super.call(this, rectsContainer, marksContainer, key, zoomLevel, readOnly, dom, isLocked, rectangle) || this;
        _this.renderPoints = renderPoints;
        _this.style = style;
        _this.styleText = styleText;
        _this.enableText = enableText;
        _this.texts = texts;
        _this.points = points;
        _this.lineType = lineType;
        return _this;
    }
    ConnectorSelectionElement.prototype.onModelChanged = function (isLocked, rectangle, renderPoints, style, styleText, enableText, texts, points, lineType) {
        this.isLocked = isLocked;
        this.rectangle = rectangle;
        this.renderPoints = renderPoints;
        this.style = style;
        this.styleText = styleText;
        this.enableText = enableText;
        this.texts = texts;
        this.points = points;
        this.lineType = lineType;
        this.redraw();
    };
    ConnectorSelectionElement.prototype.redrawCore = function () {
        if (this.isLockedRender())
            this.drawLockedSelection();
        else
            this.drawUnlockedSelection();
    };
    ConnectorSelectionElement.prototype.drawLockedSelection = function () {
        var _this = this;
        this.renderPoints.forEach(function (pt, index) {
            _this.drawLockedSelectionMark(index, pt, CanvasSelectionManager.lockedSelectionMarkSize, exports.SELECTION_ELEMENT_CLASSNAMES.LOCKED_SELECTION_MARK);
        });
    };
    ConnectorSelectionElement.prototype.drawUnlockedSelection = function () {
        this.drawConnectorSelection();
        if (!this.isMultipleSelection && !this.readOnly)
            this.drawConnectorSelectionMarks();
    };
    ConnectorSelectionElement.prototype.drawConnectorSelection = function () {
        var commands = [];
        var commandsWB = [];
        var className = this.isMultipleSelection ? exports.SELECTION_ELEMENT_CLASSNAMES.CONNECTOR_MULTI_SELECTION : exports.SELECTION_ELEMENT_CLASSNAMES.CONNECTOR_SELECTION;
        this.populateSelectionPrimitiveCommands(commands, commandsWB);
        var primitive = new PathPrimitive_1.PathPrimitive(commands.concat(commandsWB.reverse()), Style_1.StrokeStyle.default1pxInstance, className);
        this.getOrCreateElement("CS", primitive, this.rectsContainer);
    };
    ConnectorSelectionElement.prototype.populateSelectionPrimitiveCommands = function (commands, commandsWB) {
        var texts = this.texts;
        var txtAlign = this.styleText.getAlignment();
        var points = this.createNotSkippedRenderPoints();
        var zoomLevel = this.zoomLevel;
        var strokeWidthPx = this.style.strokeWidthPx;
        var selectionOffset = this.getSelectionOffset(strokeWidthPx);
        var strokeWidthPxIsEvenOdd = strokeWidthPx % 2 === 0;
        var prevPt = points[0];
        var textIndex = 0;
        var offset;
        var distance;
        var nextOffset;
        var nextDistance;
        for (var i = 1, pt = void 0; pt = points[i]; i++) {
            var nextPt = points[i + 1];
            if (offset === undefined) {
                distance = metrics_1.Metrics.euclideanDistance(prevPt, pt);
                if (math_1.MathUtils.numberCloseTo(distance, 0))
                    continue;
                offset = Utils_2.GeometryUtils.getSelectionOffsetPoint(prevPt, pt, distance).multiply(selectionOffset, selectionOffset);
            }
            if (nextPt) {
                nextDistance = metrics_1.Metrics.euclideanDistance(pt, nextPt);
                if (math_1.MathUtils.numberCloseTo(nextDistance, 0))
                    continue;
                nextOffset = Utils_2.GeometryUtils.getSelectionOffsetPoint(pt, nextPt, nextDistance).multiply(selectionOffset, selectionOffset);
            }
            var offsetX = offset.x;
            var offsetY = offset.y;
            var offsetXNegative = -offsetX;
            var offsetYNegative = -offsetY;
            var nextOffsetX = nextOffset && nextOffset.x;
            var nextOffsetY = nextOffset && nextOffset.y;
            var nextOffsetXNegative = nextOffset && -nextOffset.x;
            var nextOffsetYNegative = nextOffset && -nextOffset.y;
            if (strokeWidthPxIsEvenOdd) {
                if (offsetXNegative > 0)
                    offsetXNegative -= CanvasSelectionManager.evenOddSelectionCorrection;
                else if (offsetX > 0)
                    offsetX -= CanvasSelectionManager.evenOddSelectionCorrection;
                if (offsetYNegative > 0)
                    offsetYNegative -= CanvasSelectionManager.evenOddSelectionCorrection;
                else if (offsetY > 0)
                    offsetY -= CanvasSelectionManager.evenOddSelectionCorrection;
                if (nextOffsetXNegative > 0)
                    nextOffsetXNegative -= CanvasSelectionManager.evenOddSelectionCorrection;
                else if (nextOffsetX > 0)
                    nextOffsetX -= CanvasSelectionManager.evenOddSelectionCorrection;
                if (nextOffsetYNegative > 0)
                    nextOffsetYNegative -= CanvasSelectionManager.evenOddSelectionCorrection;
                else if (nextOffsetY > 0)
                    nextOffsetY -= CanvasSelectionManager.evenOddSelectionCorrection;
            }
            while (texts[textIndex] && texts[textIndex].pointIndex <= i) {
                var text = texts[textIndex];
                var size = this.getConnectorSelectionTextSize(text.text, selectionOffset);
                var textPts = Utils_2.GeometryUtils.getSelectionTextStartEndPoints(prevPt, pt, distance, text.point, size, txtAlign);
                if (texts[textIndex].pointIndex < i) {
                    prevPt = textPts[1];
                    commands.push(PathPrimitive_1.PathPrimitiveMoveToCommand.fromPoint(prevPt.clone().offset(offsetX, offsetY).multiply(zoomLevel, zoomLevel)));
                    commandsWB.push(PathPrimitive_1.PathPrimitiveLineToCommand.fromPoint(prevPt.clone().offset(offsetXNegative, offsetYNegative).multiply(zoomLevel, zoomLevel)));
                }
                else {
                    if (!commands.length) {
                        commands.push(PathPrimitive_1.PathPrimitiveMoveToCommand.fromPoint(prevPt.clone().offset(offsetX, offsetY).multiply(zoomLevel, zoomLevel)));
                        commandsWB.push(PathPrimitive_1.PathPrimitiveLineToCommand.fromPoint(prevPt.clone().offset(offsetXNegative, offsetYNegative).multiply(zoomLevel, zoomLevel)));
                    }
                    commands.push(PathPrimitive_1.PathPrimitiveLineToCommand.fromPoint(textPts[0].clone().offset(offsetX, offsetY).multiply(zoomLevel, zoomLevel)));
                    commands.push(PathPrimitive_1.PathPrimitiveMoveToCommand.fromPoint(textPts[1].clone().offset(offsetX, offsetY).multiply(zoomLevel, zoomLevel)));
                    commandsWB.push(PathPrimitive_1.PathPrimitiveMoveToCommand.fromPoint(textPts[0].clone().offset(offsetXNegative, offsetYNegative).multiply(zoomLevel, zoomLevel)));
                    commandsWB.push(PathPrimitive_1.PathPrimitiveLineToCommand.fromPoint(textPts[1].clone().offset(offsetXNegative, offsetYNegative).multiply(zoomLevel, zoomLevel)));
                    prevPt = textPts[1];
                }
                textIndex++;
            }
            if (!commands.length) {
                commands.push(PathPrimitive_1.PathPrimitiveMoveToCommand.fromPoint(prevPt.clone().offset(offsetX, offsetY).multiply(zoomLevel, zoomLevel)));
                commandsWB.push(PathPrimitive_1.PathPrimitiveLineToCommand.fromPoint(prevPt.clone().offset(offsetXNegative, offsetYNegative).multiply(zoomLevel, zoomLevel)));
            }
            if (nextPt) {
                Utils_2.GeometryUtils.addSelectedLinesTo(prevPt, pt, nextPt, offsetX, offsetY, offsetXNegative, offsetYNegative, nextOffsetX, nextOffsetY, nextOffsetXNegative, nextOffsetYNegative, function (x, y) { return commands.push(new PathPrimitive_1.PathPrimitiveLineToCommand(x * zoomLevel, y * zoomLevel)); }, function (x, y) { return commandsWB.push(new PathPrimitive_1.PathPrimitiveLineToCommand(x * zoomLevel, y * zoomLevel)); });
                offset = nextOffset;
                distance = nextDistance;
            }
            else {
                commands.push(PathPrimitive_1.PathPrimitiveLineToCommand.fromPoint(pt.clone().offset(offsetX, offsetY).multiply(zoomLevel, zoomLevel)));
                commandsWB.push(PathPrimitive_1.PathPrimitiveMoveToCommand.fromPoint(pt.clone().offset(offsetXNegative, offsetYNegative).multiply(zoomLevel, zoomLevel)));
            }
            prevPt = pt;
        }
    };
    ConnectorSelectionElement.prototype.createNotSkippedRenderPoints = function () {
        var clonedRenderPoints = this.renderPoints.map(function (p) { return p.clone(); });
        if (this.lineType === ConnectorProperties_1.ConnectorLineOption.Straight) {
            ModelUtils_1.ModelUtils.removeUnnecessaryRenderPoints(clonedRenderPoints);
            return clonedRenderPoints.filter(function (p) { return !p.skipped; });
        }
        ModelUtils_1.ModelUtils.removeUnnecessaryRightAngleRenderPoints(clonedRenderPoints);
        return clonedRenderPoints.filter(function (p) { return !p.skipped; });
    };
    ConnectorSelectionElement.prototype.getSelectionOffset = function (strokeWidthPx) {
        return CanvasSelectionManager.selectionOffset + unit_converter_1.UnitConverter.pixelsToTwips(Math.round(strokeWidthPx / 2) + (strokeWidthPx + 1) % 2);
    };
    ConnectorSelectionElement.prototype.getConnectorSelectionTextSize = function (text, selectionOffset) {
        return this.dom.measurer.measureTextLine(text, this.styleText, ITextMeasurer_1.TextOwner.Connector)
            .applyConverter(unit_converter_1.UnitConverter.pixelsToTwips)
            .clone().offset(selectionOffset, selectionOffset).nonNegativeSize();
    };
    ConnectorSelectionElement.prototype.drawConnectorSelectionMarks = function () {
        var _this = this;
        var pointsCount = this.points.length - 1;
        this.points.forEach(function (pt, index) {
            var isEdgePoint = index === 0 || index === pointsCount;
            var className = isEdgePoint ? exports.SELECTION_ELEMENT_CLASSNAMES.SELECTION_MARK : exports.SELECTION_ELEMENT_CLASSNAMES.CONNECTOR_POINT_MARK;
            var markSize = isEdgePoint ? CanvasSelectionManager.selectionMarkSize : CanvasSelectionManager.connectorPointMarkSize;
            if (isEdgePoint || _this.lineType === ConnectorProperties_1.ConnectorLineOption.Straight)
                _this.drawSelectionMark(index, pt.clone().multiply(_this.zoomLevel, _this.zoomLevel), markSize, Event_1.MouseEventElementType.ConnectorPoint, index, className);
            else
                _this.drawSelectionMark(index, pt.clone().multiply(_this.zoomLevel, _this.zoomLevel), markSize, Event_1.MouseEventElementType.Undefined, -1, className + " disabled");
        });
        this.drawConnectorSideMarks();
    };
    ConnectorSelectionElement.prototype.drawConnectorSideMarks = function () {
        var _this = this;
        var type = (this.lineType === ConnectorProperties_1.ConnectorLineOption.Straight) ?
            Event_1.MouseEventElementType.ConnectorSide : Event_1.MouseEventElementType.ConnectorOrthogonalSide;
        var prevPt;
        var prevPtIndex;
        this.renderPoints.filter(function (rp) { return !rp.skipped; }).forEach(function (pt, index) {
            if (pt.skipped)
                return;
            if (prevPt !== undefined)
                if (_this.canDrawConnectorSideMark(pt, prevPt)) {
                    var classNameSuffix = _this.lineType === ConnectorProperties_1.ConnectorLineOption.Orthogonal ?
                        (pt.x - prevPt.x === 0 ? "vertical" : "horizontal") : "";
                    _this.drawSelectionMark(_this.points.length + index - 1, new point_1.Point(prevPt.x + (pt.x - prevPt.x) / 2, prevPt.y + (pt.y - prevPt.y) / 2).clone().multiply(_this.zoomLevel, _this.zoomLevel), CanvasSelectionManager.connectorSideMarkSize, type, prevPtIndex + "_" + index, exports.SELECTION_ELEMENT_CLASSNAMES.CONNECTOR_SIDE_MARK + " " + classNameSuffix);
                }
            prevPt = pt;
            prevPtIndex = index;
        });
    };
    ConnectorSelectionElement.prototype.canDrawConnectorSideMark = function (current, prev) {
        if (this.lineType === ConnectorProperties_1.ConnectorLineOption.Straight) {
            var minSize = CanvasSelectionManager.selectionMarkSize + CanvasSelectionManager.connectorSideMarkSize;
            return metrics_1.Metrics.euclideanDistance(current, prev) > minSize;
        }
        if (this.lineType === ConnectorProperties_1.ConnectorLineOption.Orthogonal) {
            var hasBeginPoint = prev.pointIndex === 0;
            var hasEndPoint = Utils_2.GeometryUtils.areDuplicatedPoints(this.points[this.points.length - 1], current);
            if (hasBeginPoint && hasEndPoint)
                return metrics_1.Metrics.euclideanDistance(current, prev) > 2 * Connector_1.Connector.minOffset;
            if (!hasBeginPoint && hasEndPoint || hasBeginPoint && !hasEndPoint)
                return metrics_1.Metrics.euclideanDistance(current, prev) > Connector_1.Connector.minOffset;
            var minSize = CanvasSelectionManager.selectionMarkSize + CanvasSelectionManager.connectorSideMarkSize;
            return metrics_1.Metrics.euclideanDistance(current, prev) > minSize;
        }
        return false;
    };
    return ConnectorSelectionElement;
}(ItemSelectionElement));


/***/ }),
/* 159 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.DiagramDraggingEvent = exports.ToolboxDraggingObject = exports.Toolbox = void 0;
var Utils_1 = __webpack_require__(3);
var point_1 = __webpack_require__(0);
var evt_1 = __webpack_require__(65);
var Data_1 = __webpack_require__(44);
var dom_1 = __webpack_require__(27);
var browser_1 = __webpack_require__(18);
var RenderHelper_1 = __webpack_require__(15);
var CanvasItemsManager_1 = __webpack_require__(78);
var TOOLBOX_CSSCLASS = "dxdi-toolbox";
var DRAG_CAPTURED_CSSCLASS = "dxdi-tb-drag-captured";
var START_DRAG_CSSCLASS = "dxdi-tb-start-drag-flag";
var TOUCH_DRAGTIMEOUT_MS = 800;
var Toolbox = (function () {
    function Toolbox(parent, readOnly, allowDragging, shapeDescriptionManager, shapeTypes, getAllowedShapeTypes) {
        this.readOnly = readOnly;
        this.allowDragging = allowDragging;
        this.shapeDescriptionManager = shapeDescriptionManager;
        this.shapeTypes = shapeTypes;
        this.getAllowedShapeTypes = getAllowedShapeTypes;
        this.dragPrepareTimeout = -1;
        this.dragState = DragState.None;
        this.emulateDragEvents = browser_1.Browser.WebKitTouchUI;
        this.onDragOperation = new Utils_1.EventDispatcher();
        this.onClickOperation = new Utils_1.EventDispatcher();
        if (!parent)
            return;
        this.mainElement = this.createMainElement(parent);
        this.attachHandlers(this.mainElement);
    }
    Toolbox.prototype.clean = function (removeElement) {
        this.detachHandlers(this.mainElement);
        if (removeElement)
            removeElement(this.mainElement);
    };
    Toolbox.prototype.createMainElement = function (parent) {
        var element = document.createElement("div");
        element.setAttribute("class", TOOLBOX_CSSCLASS);
        element.draggable = true;
        if (this.emulateDragEvents)
            element.tabIndex = 0;
        parent.appendChild(element);
        return element;
    };
    Toolbox.prototype.attachHandlers = function (element) {
        this.onElementMouseDownHandler = this.onElementMouseDown.bind(this);
        this.onElementMouseUpHandler = this.onElementMouseUp.bind(this);
        this.onMouseDownHandler = this.onMouseDown.bind(this);
        this.onMouseMoveHandler = this.onMouseMove.bind(this);
        this.onMouseUpHandler = this.onMouseUp.bind(this);
        this.onDragStartHandler = this.onDragStart.bind(this);
        this.onTouchMoveHandler = this.onTouchMove.bind(this);
        if (!this.emulateDragEvents)
            RenderHelper_1.RenderHelper.addEventListener(element, "dragstart", this.onDragStartHandler);
        if (Utils_1.EventUtils.isPointerEvents()) {
            this.mouseDownEventName = "pointerdown";
            this.mouseMoveEventName = "pointermove";
            this.mouseUpEventName = "pointerup";
        }
        else {
            this.mouseDownEventName = browser_1.Browser.TouchUI ? "touchstart" : "mousedown";
            this.mouseMoveEventName = browser_1.Browser.TouchUI ? "touchmove" : "mousemove";
            this.mouseUpEventName = browser_1.Browser.TouchUI ? "touchend" : "mouseup";
        }
        RenderHelper_1.RenderHelper.addEventListener(element, "touchmove", this.onTouchMoveHandler);
        RenderHelper_1.RenderHelper.addEventListener(element, this.mouseDownEventName, this.onElementMouseDownHandler);
        RenderHelper_1.RenderHelper.addEventListener(element, this.mouseUpEventName, this.onElementMouseUpHandler);
        RenderHelper_1.RenderHelper.addEventListener(element, this.mouseDownEventName, this.onMouseDownHandler);
        RenderHelper_1.RenderHelper.addEventListener(document, this.mouseMoveEventName, this.onMouseMoveHandler);
        RenderHelper_1.RenderHelper.addEventListener(document, this.mouseUpEventName, this.onMouseUpHandler);
    };
    Toolbox.prototype.detachHandlers = function (element) {
        if (!this.emulateDragEvents)
            RenderHelper_1.RenderHelper.removeEventListener(element, "dragstart", this.onDragStartHandler);
        RenderHelper_1.RenderHelper.removeEventListener(element, "touchmove", this.onTouchMoveHandler);
        RenderHelper_1.RenderHelper.removeEventListener(element, this.mouseDownEventName, this.onElementMouseDownHandler);
        RenderHelper_1.RenderHelper.removeEventListener(element, this.mouseUpEventName, this.onElementMouseUpHandler);
        RenderHelper_1.RenderHelper.removeEventListener(element, this.mouseDownEventName, this.onMouseDownHandler);
        RenderHelper_1.RenderHelper.removeEventListener(document, this.mouseMoveEventName, this.onMouseMoveHandler);
        RenderHelper_1.RenderHelper.removeEventListener(document, this.mouseUpEventName, this.onMouseUpHandler);
    };
    Toolbox.prototype.render = function (filter) {
        if (this.mainElement.childNodes)
            this.mainElement.innerHTML = "";
        var shapeTypes = this.shapeTypes;
        shapeTypes = this.getAllowedShapeTypes ? this.getAllowedShapeTypes(shapeTypes) : shapeTypes;
        shapeTypes = filter ? shapeTypes.filter(filter) : shapeTypes;
        if (shapeTypes.length)
            this.createElements(this.mainElement, shapeTypes);
        return !!shapeTypes.length;
    };
    Toolbox.prototype.createDraggingObject = function (shapeType) {
        var evt = new DiagramDraggingEvent();
        evt.data = shapeType;
        evt.onFinishDragging = this.resetDragState.bind(this);
        evt.onCaptured = this.capture.bind(this);
        return new ToolboxDraggingObject(evt);
    };
    Toolbox.prototype.getDragShapeType = function (element) {
        while (element && !dom_1.DomUtils.hasClassName(element, TOOLBOX_CSSCLASS)) {
            if (element.getAttribute && element.getAttribute("data-tb-type"))
                return element.getAttribute("data-tb-type");
            element = element.parentNode;
        }
        return undefined;
    };
    Toolbox.prototype.getTouchPointFromEvent = function (evt) {
        var touchPosition;
        var touches = evt["touches"];
        if (touches && touches.length > 0)
            touchPosition = new point_1.Point(touches[0].clientX, touches[0].clientY);
        else if (evt.clientX && evt.clientY)
            touchPosition = new point_1.Point(evt.clientX, evt.clientY);
        return touchPosition;
    };
    Toolbox.prototype.onElementMouseDown = function (evt) {
        this.mouseDownShapeType = this.getDragShapeType(evt_1.EvtUtils.getEventSource(evt));
        this.touchDownPoint = this.getTouchPointFromEvent(evt);
    };
    Toolbox.prototype.onElementMouseUp = function (evt) {
        var shapeType = this.getDragShapeType(evt_1.EvtUtils.getEventSource(evt));
        if (shapeType && shapeType === this.mouseDownShapeType)
            this.onClickOperation.raise("notifyToolboxClick", shapeType);
        this.mouseDownShapeType = undefined;
        this.touchDownPoint = undefined;
    };
    Toolbox.prototype.onMouseDown = function (evt) {
        this.setDragState(DragState.Prepare, evt);
        if (browser_1.Browser.TouchUI && Utils_1.EventUtils.isMousePointer(evt))
            this.setDragState(DragState.Start, evt);
    };
    Toolbox.prototype.onDragStart = function (evt) {
        this.setDragState(DragState.Start, evt);
        evt.preventDefault();
    };
    Toolbox.prototype.onTouchMove = function (evt) {
        if (this.draggingObject)
            evt.preventDefault();
    };
    Toolbox.prototype.isLeftButtonPressed = function (evt) {
        return evt_1.EvtUtils.isLeftButtonPressed(evt) ||
            (evt.type === "pointermove" && browser_1.Browser.TouchUI && browser_1.Browser.MacOSMobilePlatform && Utils_1.EventUtils.isMousePointer(evt));
    };
    Toolbox.prototype.onMouseMove = function (evt) {
        if (browser_1.Browser.TouchUI && browser_1.Browser.MacOSMobilePlatform) {
            var currentTouchPoint = this.getTouchPointFromEvent(evt);
            if (this.touchDownPoint && currentTouchPoint && this.touchDownPoint.x === currentTouchPoint.x && this.touchDownPoint.y === currentTouchPoint.y)
                return;
        }
        this.setDragState(this.isLeftButtonPressed(evt) ? DragState.Dragging : DragState.None, evt);
        if (Utils_1.EventUtils.isPointerEvents())
            this.raiseDraggingMouseMove(evt);
    };
    Toolbox.prototype.onMouseUp = function (evt) {
        this.setDragState(DragState.None, evt);
    };
    Toolbox.prototype.updateDraggingElementPosition = function (evtX, evtY) {
        var element = this.draggingObject.element;
        var xPos = evtX - element.offsetWidth / 2;
        var yPos = evtY - element.offsetHeight / 2;
        Data_1.SetAbsoluteX(element, xPos);
        Data_1.SetAbsoluteY(element, yPos);
    };
    Toolbox.prototype.setDragState = function (newState, evt) {
        if (this.readOnly || !this.allowDragging)
            return;
        if (newState === DragState.None && newState === this.dragState)
            return;
        if (this.dragPrepareTimeout > -1) {
            clearTimeout(this.dragPrepareTimeout);
            this.dragPrepareTimeout = -1;
            this.dragPrepareEvent = undefined;
        }
        if (newState - this.dragState > 1 || newState !== DragState.None && newState < this.dragState)
            return;
        this.dragState = newState;
        switch (newState) {
            case DragState.Prepare:
                if (!this.prepareDragging(evt))
                    this.setDragState(DragState.None, evt);
                if (this.emulateDragEvents || !Utils_1.EventUtils.isMousePointer(evt)) {
                    this.dragPrepareTimeout = setTimeout(this.onDragPrepareTimeout.bind(this), TOUCH_DRAGTIMEOUT_MS);
                    this.dragPrepareEvent = evt;
                }
                break;
            case DragState.Start:
                dom_1.DomUtils.addClassName(document.body, "dxdi-dragging");
                this.startDragging(evt);
                break;
            case DragState.Dragging:
                this.doDragging(evt);
                break;
            case DragState.None:
                this.finishDragging(evt);
                break;
        }
    };
    Toolbox.prototype.resetDragState = function () {
        this.setDragState(DragState.None, undefined);
    };
    Toolbox.prototype.onDragPrepareTimeout = function () {
        this.dragPrepareTimeout = -1;
        if (this.dragState === DragState.Prepare)
            this.setDragState(DragState.Start, this.dragPrepareEvent);
        this.dragPrepareEvent = undefined;
    };
    Toolbox.prototype.prepareDragging = function (evt) {
        this.dragStartPoint = new point_1.Point(evt_1.EvtUtils.getEventX(evt), evt_1.EvtUtils.getEventY(evt));
        this.dragStartShapeType = this.getDragShapeType(evt_1.EvtUtils.getEventSource(evt));
        if (Utils_1.EventUtils.isMousePointer(evt))
            dom_1.DomUtils.addClassName(this.mainElement, START_DRAG_CSSCLASS);
        if (this.emulateDragEvents || !Utils_1.EventUtils.isMousePointer(evt))
            Utils_1.HtmlFocusUtils.focusWithPreventScroll(this.mainElement);
        return !!this.dragStartShapeType;
    };
    Toolbox.prototype.startDragging = function (evt) {
        this.draggingObject = this.createDraggingObject(this.dragStartShapeType);
        if (this.dragStartShapeType) {
            this.raiseDragStart(evt);
            this.draggingObject.element = this.createDraggingElement(this.draggingObject);
            if (this.draggingObject.captured !== undefined)
                this.capture(this.draggingObject.captured, true);
            this.updateDraggingElementPosition(this.dragStartPoint.x, this.dragStartPoint.y);
        }
        else
            dom_1.DomUtils.addClassName(document.body, CanvasItemsManager_1.NOT_VALID_CSSCLASS);
    };
    Toolbox.prototype.doDragging = function (evt) {
        if (this.draggingObject.element)
            this.updateDraggingElementPosition(evt_1.EvtUtils.getEventX(evt), evt_1.EvtUtils.getEventY(evt));
    };
    Toolbox.prototype.finishDragging = function (evt) {
        if (this.draggingObject) {
            this.raiseDragEnd(evt);
            var element = this.draggingObject.element;
            if (element)
                element.parentNode.removeChild(element);
            delete this.draggingObject;
        }
        this.dragStartPoint = undefined;
        this.dragStartShapeType = undefined;
        dom_1.DomUtils.removeClassName(this.mainElement, START_DRAG_CSSCLASS);
        dom_1.DomUtils.removeClassName(document.body, CanvasItemsManager_1.NOT_VALID_CSSCLASS);
        setTimeout(function () { return dom_1.DomUtils.removeClassName(document.body, "dxdi-dragging"); }, 500);
    };
    Toolbox.prototype.capture = function (captured, forced) {
        if (this.draggingObject && (this.draggingObject.captured !== captured || forced)) {
            this.draggingObject.captured = captured;
            if (this.draggingObject.element)
                dom_1.DomUtils.toggleClassName(this.draggingObject.element, DRAG_CAPTURED_CSSCLASS, captured);
        }
    };
    Toolbox.prototype.raiseDragStart = function (evt) {
        this.onDragOperation.raise("notifyToolboxDragStart", evt);
    };
    Toolbox.prototype.raiseDragEnd = function (evt) {
        this.onDragOperation.raise("notifyToolboxDragEnd", evt);
    };
    Toolbox.prototype.raiseDraggingMouseMove = function (evt) {
        this.onDragOperation.raise("notifyToolboxDraggingMouseMove", evt);
    };
    Toolbox.prototype.notifyReadOnlyChanged = function (readOnly) {
        this.readOnly = readOnly;
    };
    return Toolbox;
}());
exports.Toolbox = Toolbox;
var DragState;
(function (DragState) {
    DragState[DragState["None"] = -1] = "None";
    DragState[DragState["Prepare"] = 0] = "Prepare";
    DragState[DragState["Start"] = 1] = "Start";
    DragState[DragState["Dragging"] = 2] = "Dragging";
})(DragState || (DragState = {}));
var ToolboxDraggingObject = (function () {
    function ToolboxDraggingObject(evt) {
        this.evt = evt;
    }
    return ToolboxDraggingObject;
}());
exports.ToolboxDraggingObject = ToolboxDraggingObject;
var DiagramDraggingEvent = (function () {
    function DiagramDraggingEvent() {
    }
    return DiagramDraggingEvent;
}());
exports.DiagramDraggingEvent = DiagramDraggingEvent;


/***/ }),
/* 160 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.RightAngleConnectorRoutingMathOperations = void 0;
var segment_1 = __webpack_require__(33);
var math_1 = __webpack_require__(31);
var AStarMetrics_1 = __webpack_require__(161);
var Utils_1 = __webpack_require__(3);
var DiagramItem_1 = __webpack_require__(9);
var RightAngleConnectorRoutingMathOperations = (function () {
    function RightAngleConnectorRoutingMathOperations() {
    }
    RightAngleConnectorRoutingMathOperations.createUnionSegments = function (segments, shouldCreateSegment) {
        var result = [];
        var startRenderPoint = segments[0].startPoint;
        var endRenderPoint = segments[0].endPoint;
        for (var i = 1; i < segments.length; i++) {
            var currentSegment = segments[i];
            if (shouldCreateSegment(endRenderPoint, currentSegment.startPoint)) {
                result.push(new segment_1.Segment(startRenderPoint.clone(), endRenderPoint.clone()));
                startRenderPoint = currentSegment.startPoint;
            }
            endRenderPoint = currentSegment.endPoint;
        }
        result.push(new segment_1.Segment(startRenderPoint, endRenderPoint));
        return result;
    };
    RightAngleConnectorRoutingMathOperations.unionPoints = function (points) {
        var index = 0;
        while (index < points.length - 2)
            if (Utils_1.GeometryUtils.isCorner(points[index], points[index + 1], points[index + 2]))
                index++;
            else {
                points.splice(index + 1, 1);
                index = Math.max(0, index - 1);
            }
    };
    RightAngleConnectorRoutingMathOperations.getTurnDirection = function (angle) {
        if (math_1.MathUtils.numberCloseTo(angle, 0))
            return AStarMetrics_1.RightAngleTurnDirection.Straight;
        if (math_1.MathUtils.numberCloseTo(angle, Math.PI))
            return AStarMetrics_1.RightAngleTurnDirection.Backwards;
        return angle < Math.PI ? AStarMetrics_1.RightAngleTurnDirection.Left : AStarMetrics_1.RightAngleTurnDirection.Right;
    };
    RightAngleConnectorRoutingMathOperations.isSegmentNormal = function (segment, isHorizontal) {
        return isHorizontal ? math_1.MathUtils.numberCloseTo(segment.startPoint.y, segment.endPoint.y) : math_1.MathUtils.numberCloseTo(segment.startPoint.x, segment.endPoint.x);
    };
    RightAngleConnectorRoutingMathOperations.isConnectionRectanleLineIntersected = function (rect, segment, side, excludeBeginPoint, excludeEndPoint, createPoint) {
        switch (side) {
            case DiagramItem_1.ConnectionPointSide.North:
                return Utils_1.GeometryUtils.isLineIntersected(createPoint(rect.x, rect.y), createPoint(rect.right, rect.y), segment, excludeBeginPoint, excludeEndPoint);
            case DiagramItem_1.ConnectionPointSide.South:
                return Utils_1.GeometryUtils.isLineIntersected(createPoint(rect.right, rect.bottom), createPoint(rect.x, rect.bottom), segment, excludeBeginPoint, excludeEndPoint);
            case DiagramItem_1.ConnectionPointSide.West:
                return Utils_1.GeometryUtils.isLineIntersected(createPoint(rect.x, rect.y), createPoint(rect.x, rect.bottom), segment, excludeBeginPoint, excludeEndPoint);
            case DiagramItem_1.ConnectionPointSide.East:
                return Utils_1.GeometryUtils.isLineIntersected(createPoint(rect.right, rect.y), createPoint(rect.right, rect.bottom), segment, excludeBeginPoint, excludeEndPoint);
            default:
                return false;
        }
    };
    RightAngleConnectorRoutingMathOperations.createBeginConnectionSegment = function (beginConnectionSide, beginPoint, offset, createPoint) {
        switch (beginConnectionSide) {
            case DiagramItem_1.ConnectionPointSide.North:
                return new segment_1.Segment(beginPoint, createPoint(beginPoint.x, beginPoint.y - offset));
            case DiagramItem_1.ConnectionPointSide.South:
                return new segment_1.Segment(beginPoint, createPoint(beginPoint.x, beginPoint.y + offset));
            case DiagramItem_1.ConnectionPointSide.West:
                return new segment_1.Segment(beginPoint, createPoint(beginPoint.x - offset, beginPoint.y));
            case DiagramItem_1.ConnectionPointSide.East:
                return new segment_1.Segment(beginPoint, createPoint(beginPoint.x + offset, beginPoint.y));
            default:
                return beginPoint;
        }
    };
    RightAngleConnectorRoutingMathOperations.createEndConnectionSegment = function (endConnectionSide, endPoint, offset, createPoint) {
        switch (endConnectionSide) {
            case DiagramItem_1.ConnectionPointSide.North:
                return new segment_1.Segment(createPoint(endPoint.x, endPoint.y - offset), endPoint);
            case DiagramItem_1.ConnectionPointSide.South:
                return new segment_1.Segment(createPoint(endPoint.x, endPoint.y + offset), endPoint);
            case DiagramItem_1.ConnectionPointSide.West:
                return new segment_1.Segment(createPoint(endPoint.x - offset, endPoint.y), endPoint);
            case DiagramItem_1.ConnectionPointSide.East:
                return new segment_1.Segment(createPoint(endPoint.x + offset, endPoint.y), endPoint);
            default:
                return endPoint;
        }
    };
    return RightAngleConnectorRoutingMathOperations;
}());
exports.RightAngleConnectorRoutingMathOperations = RightAngleConnectorRoutingMathOperations;


/***/ }),
/* 161 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.IntersectedShapeZone = exports.AStarMetrics = exports.IntersectedShapesMetrics = exports.TurnDirectionMetrics = exports.IntersectedShapeMetrics = exports.RightAngleTurnDirection = void 0;
var point_1 = __webpack_require__(0);
var metrics_1 = __webpack_require__(35);
var RightAngleTurnDirection;
(function (RightAngleTurnDirection) {
    RightAngleTurnDirection[RightAngleTurnDirection["Straight"] = 0] = "Straight";
    RightAngleTurnDirection[RightAngleTurnDirection["Left"] = 1] = "Left";
    RightAngleTurnDirection[RightAngleTurnDirection["Right"] = 2] = "Right";
    RightAngleTurnDirection[RightAngleTurnDirection["Backwards"] = 3] = "Backwards";
})(RightAngleTurnDirection = exports.RightAngleTurnDirection || (exports.RightAngleTurnDirection = {}));
var IntersectedShapeMetrics = (function () {
    function IntersectedShapeMetrics(description, shapeMargin) {
        this.description = description;
        this.shapeMargin = shapeMargin;
    }
    IntersectedShapeMetrics.prototype.penalty = function (oldValue, distance, position, item) {
        var rectangle = item.rectangle;
        if (rectangle.containsPoint(position))
            return oldValue + this.description.shape * distance;
        var relativePenalty = this.createRelativeMarginPenalty(position, rectangle, this.shapeMargin);
        if (relativePenalty > 0)
            return oldValue + this.description.margin * relativePenalty * distance;
        return oldValue;
    };
    IntersectedShapeMetrics.prototype.createRelativeMarginPenalty = function (point, rectangle, margin) {
        var isTopPosition = this.isTopPosition(point, rectangle, margin);
        var isLeftPosition = this.isLeftPosition(point, rectangle, margin);
        var isBottomPosition = this.isBottomPosition(point, rectangle, margin);
        var isRightPosition = this.isRightPosition(point, rectangle, margin);
        if (isTopPosition) {
            if (isLeftPosition) {
                var extendedRectangle = rectangle.clone().inflate(margin);
                var extendedTopLeft = extendedRectangle.createPosition();
                var rectangleTopLeft = rectangle.createPosition();
                var topLeftDistance = metrics_1.Metrics.euclideanDistance(rectangleTopLeft, extendedTopLeft);
                var currentDistance = metrics_1.Metrics.euclideanDistance(rectangleTopLeft, point);
                return 1 - currentDistance / topLeftDistance;
            }
            if (isRightPosition) {
                var extendedRectangle = rectangle.clone().inflate(margin);
                var extendedTopRight = new point_1.Point(extendedRectangle.right, extendedRectangle.y);
                var rectangleTopRight = new point_1.Point(rectangle.right, rectangle.y);
                var topRightDistance = metrics_1.Metrics.euclideanDistance(rectangleTopRight, extendedTopRight);
                var currentDistance = metrics_1.Metrics.euclideanDistance(rectangleTopRight, point);
                return 1 - currentDistance / topRightDistance;
            }
            return 1 - (rectangle.y - point.y) / margin;
        }
        if (isBottomPosition) {
            if (isLeftPosition) {
                var extendedRectangle = rectangle.clone().inflate(margin);
                var extendedBottomLeft = new point_1.Point(extendedRectangle.x, extendedRectangle.bottom);
                var rectangleBottomLeft = new point_1.Point(rectangle.x, rectangle.bottom);
                var bottomLeftDistance = metrics_1.Metrics.euclideanDistance(rectangleBottomLeft, extendedBottomLeft);
                var currentDistance = metrics_1.Metrics.euclideanDistance(rectangleBottomLeft, point);
                return 1 - currentDistance / bottomLeftDistance;
            }
            if (isRightPosition) {
                var extendedRectangle = rectangle.clone().inflate(margin);
                var extendedBottomRight = new point_1.Point(extendedRectangle.right, extendedRectangle.bottom);
                var rectangleBottomRight = new point_1.Point(rectangle.right, rectangle.bottom);
                var bottomRightDistance = metrics_1.Metrics.euclideanDistance(rectangleBottomRight, extendedBottomRight);
                var currentDistance = metrics_1.Metrics.euclideanDistance(rectangleBottomRight, point);
                return 1 - currentDistance / bottomRightDistance;
            }
            return 1 - (point.y - rectangle.bottom) / margin;
        }
        if (isLeftPosition)
            return 1 - (rectangle.x - point.x) / margin;
        if (isRightPosition)
            return 1 - (point.x - rectangle.right) / margin;
        return 0;
    };
    IntersectedShapeMetrics.prototype.isTopPosition = function (point, rectangle, margin) {
        return point.x > rectangle.x - margin && point.x < rectangle.right + margin &&
            point.y > rectangle.y - margin && point.y < rectangle.y;
    };
    IntersectedShapeMetrics.prototype.isBottomPosition = function (point, rectangle, margin) {
        return point.x > rectangle.x - margin && point.x < rectangle.right + margin &&
            point.y > rectangle.bottom && point.y < rectangle.bottom + margin;
    };
    IntersectedShapeMetrics.prototype.isLeftPosition = function (point, rectangle, margin) {
        return point.x > rectangle.x - margin && point.x < rectangle.x &&
            point.y > rectangle.y - margin && point.y < rectangle.bottom + margin;
    };
    IntersectedShapeMetrics.prototype.isRightPosition = function (point, rectangle, margin) {
        return point.x > rectangle.right && point.x < rectangle.right + margin &&
            point.y > rectangle.y - margin && point.y < rectangle.bottom + margin;
    };
    return IntersectedShapeMetrics;
}());
exports.IntersectedShapeMetrics = IntersectedShapeMetrics;
var TurnDirectionMetrics = (function () {
    function TurnDirectionMetrics(description) {
        this.description = description;
    }
    TurnDirectionMetrics.prototype.penalty = function (oldValue, turnDirection) {
        switch (turnDirection) {
            case RightAngleTurnDirection.Backwards: return oldValue * this.description.turnBack;
            case RightAngleTurnDirection.Left: return oldValue * this.description.turnLeft;
            case RightAngleTurnDirection.Right: return oldValue * this.description.turnRight;
        }
        return oldValue;
    };
    return TurnDirectionMetrics;
}());
exports.TurnDirectionMetrics = TurnDirectionMetrics;
var IntersectedShapesMetrics = (function () {
    function IntersectedShapesMetrics(shapeMetrics) {
        this.shapeMetrics = shapeMetrics;
    }
    IntersectedShapesMetrics.prototype.penalty = function (oldValue, distance, position, intersectedItems) {
        var _this = this;
        if (!intersectedItems || !intersectedItems.length)
            return oldValue;
        var result = oldValue;
        intersectedItems.forEach(function (item) { return result = _this.shapeMetrics.penalty(result, distance, position, item); });
        return result;
    };
    return IntersectedShapesMetrics;
}());
exports.IntersectedShapesMetrics = IntersectedShapesMetrics;
var AStarMetrics = (function () {
    function AStarMetrics(turnDirectionMetrics, shapesMetrics) {
        this.turnDirectionMetrics = turnDirectionMetrics;
        this.shapesMetrics = shapesMetrics;
    }
    AStarMetrics.prototype.distance = function (point1, point2) {
        return metrics_1.Metrics.manhattanDistance(point1, point2);
    };
    AStarMetrics.prototype.penalty = function (distance, position, turnDirection, intersectedItems) {
        var result = distance;
        result = this.shapesMetrics.penalty(result, distance, position, intersectedItems);
        result = this.turnDirectionMetrics.penalty(result, turnDirection);
        return result;
    };
    return AStarMetrics;
}());
exports.AStarMetrics = AStarMetrics;
var IntersectedShapeZone;
(function (IntersectedShapeZone) {
    IntersectedShapeZone[IntersectedShapeZone["None"] = 0] = "None";
    IntersectedShapeZone[IntersectedShapeZone["Shape"] = 1] = "Shape";
    IntersectedShapeZone[IntersectedShapeZone["Margin"] = 2] = "Margin";
})(IntersectedShapeZone = exports.IntersectedShapeZone || (exports.IntersectedShapeZone = {}));


/***/ }),
/* 162 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.DeleteCommand = void 0;
var ModelUtils_1 = __webpack_require__(4);
var SimpleCommandBase_1 = __webpack_require__(10);
var DeleteCommand = (function (_super) {
    __extends(DeleteCommand, _super);
    function DeleteCommand() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    DeleteCommand.prototype.isEnabled = function () {
        var items = this.control.selection.getSelectedItems();
        return _super.prototype.isEnabled.call(this) && items.length && (items.length > 1 || this.permissionsProvider.canDeleteItems(items));
    };
    DeleteCommand.prototype.executeCore = function (state) {
        var items = this.control.selection.getSelectedItems(true, true);
        this.permissionsProvider.beginDeleteItems(items);
        ModelUtils_1.ModelUtils.deleteSelection(this.control.history, this.control.model, this.control.selection);
        this.permissionsProvider.endDeleteItems();
        return true;
    };
    Object.defineProperty(DeleteCommand.prototype, "isPermissionsRequired", {
        get: function () { return true; },
        enumerable: false,
        configurable: true
    });
    return DeleteCommand;
}(SimpleCommandBase_1.SimpleCommandBase));
exports.DeleteCommand = DeleteCommand;


/***/ }),
/* 163 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

Object.defineProperty(exports, "__esModule", { value: true });
var Flag = (function () {
    function Flag(initValue) {
        if (initValue === void 0) { initValue = 0; }
        this.value = initValue;
    }
    Flag.prototype.get = function (enumVal) {
        return (this.value & enumVal) === enumVal;
    };
    Flag.prototype.set = function (enumVal, newValue) {
        var currVal = (this.value & enumVal) === enumVal;
        if (currVal !== newValue) {
            if (newValue)
                this.value |= enumVal;
            else
                this.value ^= enumVal;
        }
        return this;
    };
    Flag.prototype.add = function (value) {
        this.value |= value;
    };
    Flag.prototype.anyOf = function () {
        var flags = [];
        for (var _i = 0; _i < arguments.length; _i++) {
            flags[_i] = arguments[_i];
        }
        for (var _a = 0, flags_1 = flags; _a < flags_1.length; _a++) {
            var flag = flags_1[_a];
            if ((this.value & flag) === flag)
                return true;
        }
        return false;
    };
    Flag.prototype.getValue = function () {
        return this.value;
    };
    Flag.prototype.clone = function () {
        return new Flag(this.value);
    };
    return Flag;
}());
exports.Flag = Flag;


/***/ }),
/* 164 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

Object.defineProperty(exports, "__esModule", { value: true });
var list_1 = __webpack_require__(105);
var search_1 = __webpack_require__(41);
var fixed_1 = __webpack_require__(106);
var collector_1 = __webpack_require__(169);
var IntervalAlgorithms = (function () {
    function IntervalAlgorithms() {
    }
    IntervalAlgorithms.oneConstainsOtherArraysOfInterval = function (mergedIntervalsA, intervalsB) {
        var shouldBeContais = list_1.ListUtils.deepCopy(intervalsB);
        var currenInterval = shouldBeContais.pop();
        while (currenInterval) {
            if (!list_1.ListUtils.unsafeAnyOf(mergedIntervalsA, function (mergedInterval) { return mergedInterval.containsInterval(currenInterval); }))
                return false;
            currenInterval = shouldBeContais.pop();
        }
        return true;
    };
    IntervalAlgorithms.getIntersection = function (intervalA, intervalB) {
        return IntervalAlgorithms.getIntersectionTemplate(intervalA, intervalB, intervalA);
    };
    IntervalAlgorithms.getIntersectionTemplate = function (intervalA, intervalB, template) {
        var start = Math.max(intervalA.start, intervalB.start);
        var end = Math.min(intervalA.end, intervalB.end);
        if (start > end)
            return null;
        return template.makeByStartEnd(start, end);
    };
    IntervalAlgorithms.getIntersectionNonNullLength = function (intervalA, intervalB) {
        return IntervalAlgorithms.getIntersectionNonNullLengthTemplate(intervalA, intervalB, intervalA);
    };
    IntervalAlgorithms.getIntersectionNonNullLengthTemplate = function (intervalA, intervalB, template) {
        var inters = IntervalAlgorithms.getIntersectionTemplate(intervalA, intervalB, template);
        return inters && inters.length ? inters : null;
    };
    IntervalAlgorithms.getIntersectionsTwoArraysOfInterval = function (intervalsA, intervalsB) {
        return IntervalAlgorithms.getIntersectionsTwoArraysOfIntervalTemplate(intervalsA, intervalsB, intervalsA[0]);
    };
    IntervalAlgorithms.getIntersectionsTwoArraysOfIntervalTemplate = function (intervalsA, intervalsB, template) {
        var result = [];
        var lengthIntervalsA = intervalsA.length;
        var lengthIntervalsB = intervalsB.length;
        var intervalsAIndex = 0;
        var intervalsBIndex = 0;
        var currAInterval = intervalsA[intervalsAIndex];
        var currBInterval = intervalsB[intervalsBIndex];
        var currResultInterval = null;
        while (intervalsAIndex < lengthIntervalsA && intervalsBIndex < lengthIntervalsB) {
            var intersection = IntervalAlgorithms.getIntersectionTemplate(currAInterval, currBInterval, template);
            if (intersection) {
                if (currResultInterval && currResultInterval.end === intersection.start)
                    currResultInterval.length += intersection.length;
                else {
                    currResultInterval = intersection;
                    result.push(currResultInterval);
                }
            }
            if (currAInterval.end < currBInterval.end) {
                intervalsAIndex++;
                currAInterval = intervalsA[intervalsAIndex];
            }
            else {
                intervalsBIndex++;
                currBInterval = intervalsB[intervalsBIndex];
            }
        }
        return result;
    };
    IntervalAlgorithms.getAffectedObjects = function (objects, intervals, getFirstIndex, conflictResolver) {
        if (getFirstIndex === void 0) { getFirstIndex = function (start) {
            return search_1.SearchUtils.normedInterpolationIndexOf(objects, function (obj) { return obj.interval.start; }, start);
        }; }
        if (conflictResolver === void 0) { conflictResolver = function (objectInterval, touchingIntervalLength, touchPoint) {
            return objectInterval.start === touchPoint && touchingIntervalLength === 0;
        }; }
        return IntervalAlgorithms.getAffectedObjectsTemplate(objects, intervals, intervals[0], getFirstIndex, conflictResolver);
    };
    IntervalAlgorithms.getAffectedObjectsTemplate = function (objects, intervals, template, getFirstIndex, conflictResolver) {
        if (getFirstIndex === void 0) { getFirstIndex = function (start) {
            return search_1.SearchUtils.normedInterpolationIndexOf(objects, function (obj) { return obj.interval.start; }, start);
        }; }
        if (conflictResolver === void 0) { conflictResolver = function (objectInterval, touchingIntervalLength, touchPoint) {
            return objectInterval.start === touchPoint && touchingIntervalLength === 0;
        }; }
        var collector = new collector_1.SparseIntervalsCollector(template);
        for (var _i = 0, intervals_1 = intervals; _i < intervals_1.length; _i++) {
            var interval = intervals_1[_i];
            var ind = Math.max(0, getFirstIndex(interval.start, objects));
            for (var obj = void 0; obj = objects[ind]; ind++) {
                var objInterval = obj.interval;
                if (objInterval.start > interval.end)
                    break;
                var intersection = IntervalAlgorithms.getIntersectionTemplate(objInterval, interval, template);
                if (intersection && (intersection.length || conflictResolver(objInterval, interval.length, intersection.start)))
                    collector.add(ind);
            }
        }
        return collector.getIntervals();
    };
    IntervalAlgorithms.handleAffectedObjects = function (objects, intervals, callback, getFirstIndex) {
        if (getFirstIndex === void 0) { getFirstIndex = function (start) {
            return search_1.SearchUtils.normedInterpolationIndexOf(objects, function (obj) { return obj.interval.start; }, start);
        }; }
        var template = new fixed_1.FixedInterval(0, 0);
        for (var _i = 0, intervals_2 = intervals; _i < intervals_2.length; _i++) {
            var interval = intervals_2[_i];
            var ind = Math.max(0, getFirstIndex(interval.start, objects));
            for (var obj = void 0; obj = objects[ind]; ind++) {
                var objInterval = obj.interval;
                if (objInterval.start > interval.end)
                    break;
                var intersection = IntervalAlgorithms.getIntersectionTemplate(objInterval, interval, template);
                if (intersection)
                    callback(obj, ind, interval, intersection);
            }
        }
    };
    IntervalAlgorithms.getMergedIntervals = function (intervals, needSort) {
        return IntervalAlgorithms.getMergedIntervalsTemplate(intervals, needSort, intervals[0]);
    };
    IntervalAlgorithms.getMergedIntervalsTemplate = function (intervals, needSort, template) {
        if (intervals.length < 2)
            return intervals.length > 0 ? [template.makeByStartLength(intervals[0].start, intervals[0].length)] : [];
        var sortedIntervals = needSort ?
            [].concat(intervals).sort(function (a, b) { return a.start - b.start; }) :
            intervals;
        var result = [];
        for (var i = 0, interval = void 0; interval = sortedIntervals[i];) {
            var minBound = interval.start;
            var maxBound = interval.end;
            for (++i; (interval = sortedIntervals[i]) !== undefined && (interval.start <= maxBound); i++) {
                if (interval.end > maxBound)
                    maxBound = interval.end;
            }
            result.push(template.makeByStartEnd(minBound, maxBound));
        }
        return result;
    };
    IntervalAlgorithms.reflectIntervals = function (intervals, bounds) {
        return IntervalAlgorithms.reflectIntervalsTemplate(intervals, bounds, bounds);
    };
    IntervalAlgorithms.reflectIntervalsTemplate = function (intervals, bounds, template) {
        if (!intervals.length)
            return [template.makeByStartLength(bounds.start, bounds.length)];
        var lastIntervalEnd = list_1.ListUtils.last(intervals).end;
        var result = list_1.ListUtils.reducedMap(intervals, function (curr, i) {
            return IntervalAlgorithms.getIntersectionNonNullLengthTemplate(template.makeByStartEnd(intervals[i - 1].end, curr.start), bounds, template);
        }, 1);
        if (bounds.start < intervals[0].start)
            result.unshift(template.makeByStartEnd(bounds.start, intervals[0].start));
        if (bounds.end > lastIntervalEnd)
            result.push(template.makeByStartEnd(lastIntervalEnd, bounds.end));
        return result;
    };
    IntervalAlgorithms.reflectionOfPointOnInterval = function (value, valInterval, targetInterval) {
        return (value - valInterval.start) / valInterval.length * targetInterval.length + targetInterval.start;
    };
    return IntervalAlgorithms;
}());
exports.IntervalAlgorithms = IntervalAlgorithms;


/***/ }),
/* 165 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = __webpack_require__(59);
var MinMax = (function () {
    function MinMax(minElement, maxElement) {
        this.minElement = minElement;
        this.maxElement = maxElement;
    }
    return MinMax;
}());
exports.MinMax = MinMax;
var MinMaxNumber = (function (_super) {
    tslib_1.__extends(MinMaxNumber, _super);
    function MinMaxNumber() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    Object.defineProperty(MinMaxNumber.prototype, "length", {
        get: function () {
            return this.maxElement - this.minElement;
        },
        enumerable: true,
        configurable: true
    });
    return MinMaxNumber;
}(MinMax));
exports.MinMaxNumber = MinMaxNumber;
var ExtendedMin = (function () {
    function ExtendedMin(minElement, minValue) {
        this.minElement = minElement;
        this.minValue = minValue;
    }
    return ExtendedMin;
}());
exports.ExtendedMin = ExtendedMin;
var ExtendedMax = (function () {
    function ExtendedMax(maxElement, maxValue) {
        this.maxElement = maxElement;
        this.maxValue = maxValue;
    }
    return ExtendedMax;
}());
exports.ExtendedMax = ExtendedMax;
var ExtendedMinMax = (function (_super) {
    tslib_1.__extends(ExtendedMinMax, _super);
    function ExtendedMinMax(minElement, minValue, maxElement, maxValue) {
        var _this = _super.call(this, minElement, maxElement) || this;
        _this.minValue = minValue;
        _this.maxValue = maxValue;
        return _this;
    }
    return ExtendedMinMax;
}(MinMax));
exports.ExtendedMinMax = ExtendedMinMax;


/***/ }),
/* 166 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

Object.defineProperty(exports, "__esModule", { value: true });
var Comparers = (function () {
    function Comparers() {
    }
    Comparers.number = function (a, b) {
        return a - b;
    };
    Comparers.string = function (a, b) {
        return ((a === b) ? 0 : ((a > b) ? 1 : -1));
    };
    Comparers.stringIgnoreCase = function (a, b) {
        a = a.toLowerCase();
        b = b.toLowerCase();
        return ((a === b) ? 0 : ((a > b) ? 1 : -1));
    };
    return Comparers;
}());
exports.Comparers = Comparers;
var Equals = (function () {
    function Equals() {
    }
    Equals.simpleType = function (a, b) {
        return a === b;
    };
    Equals.object = function (a, b) {
        return a && b && (a === b || a.equals(b));
    };
    return Equals;
}());
exports.Equals = Equals;


/***/ }),
/* 167 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = __webpack_require__(59);
var const_1 = __webpack_require__(168);
var MutableInterval = (function (_super) {
    tslib_1.__extends(MutableInterval, _super);
    function MutableInterval() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    MutableInterval.prototype.normalizeLength = function () {
        if (this.length < 0)
            this.length = 0;
        return this;
    };
    return MutableInterval;
}(const_1.ConstInterval));
exports.MutableInterval = MutableInterval;


/***/ }),
/* 168 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

Object.defineProperty(exports, "__esModule", { value: true });
var ConstInterval = (function () {
    function ConstInterval() {
    }
    Object.defineProperty(ConstInterval.prototype, "center", {
        get: function () {
            return this.start + (this.length / 2);
        },
        enumerable: true,
        configurable: true
    });
    ConstInterval.prototype.isNormalized = function () {
        return this.end >= this.start;
    };
    ConstInterval.prototype.isCollapsed = function () {
        return this.length === 0;
    };
    ConstInterval.prototype.equals = function (obj) {
        return this.start === obj.start && this.end === obj.end;
    };
    ConstInterval.isCollapsed = function (intervals) {
        return !intervals[1] && intervals[0].isCollapsed();
    };
    ConstInterval.prototype.containsInterval = function (interval) {
        return this.start <= interval.start && this.end >= interval.end;
    };
    ConstInterval.prototype.containsIntervalWithoutEnd = function (interval) {
        return this.start <= interval.start && this.end > interval.end;
    };
    ConstInterval.prototype.contains = function (pos) {
        return this.start <= pos && pos < this.end;
    };
    ConstInterval.prototype.containsWithIntervalEnd = function (val) {
        return this.start <= val && val <= this.end;
    };
    ConstInterval.prototype.containsWithoutIntervalEndAndStart = function (pos) {
        return this.start < pos && pos < this.end;
    };
    return ConstInterval;
}());
exports.ConstInterval = ConstInterval;


/***/ }),
/* 169 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

Object.defineProperty(exports, "__esModule", { value: true });
var intervals_1 = __webpack_require__(170);
var SparseIntervalsCollector = (function () {
    function SparseIntervalsCollector(template) {
        this.intervals = [];
        this.template = template;
    }
    SparseIntervalsCollector.prototype.add = function (index) {
        if (this.curr && this.curr.end === index) {
            this.curr.length++;
            return;
        }
        this.curr = this.template.makeByStartLength(index, 1);
        this.intervals.push(this.curr);
    };
    SparseIntervalsCollector.prototype.getIntervals = function () {
        return new intervals_1.SparseIntervals(this.intervals);
    };
    return SparseIntervalsCollector;
}());
exports.SparseIntervalsCollector = SparseIntervalsCollector;


/***/ }),
/* 170 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

Object.defineProperty(exports, "__esModule", { value: true });
var iterator_1 = __webpack_require__(107);
var objects_iterator_1 = __webpack_require__(171);
var SparseIntervals = (function () {
    function SparseIntervals(list) {
        if (list === void 0) { list = []; }
        this.list = list;
        this._count = 0;
        this._numIntervals = 0;
        for (var _i = 0, list_1 = list; _i < list_1.length; _i++) {
            var curr = list_1[_i];
            this._count += curr.length;
            this._numIntervals++;
        }
    }
    Object.defineProperty(SparseIntervals.prototype, "count", {
        get: function () {
            return this._count;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(SparseIntervals.prototype, "numIntervals", {
        get: function () {
            return this._numIntervals;
        },
        enumerable: true,
        configurable: true
    });
    SparseIntervals.prototype.getInterval = function (index) {
        return this.list[index];
    };
    SparseIntervals.prototype.getNativeIterator = function () {
        return new iterator_1.SparseIntervalsIterator(this);
    };
    SparseIntervals.prototype.getObjectsIterator = function (objects) {
        return new objects_iterator_1.SparseObjectsIterator(this, objects);
    };
    return SparseIntervals;
}());
exports.SparseIntervals = SparseIntervals;


/***/ }),
/* 171 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = __webpack_require__(59);
var iterator_1 = __webpack_require__(107);
var SparseObjectsIterator = (function (_super) {
    tslib_1.__extends(SparseObjectsIterator, _super);
    function SparseObjectsIterator(sparseIntervals, objects) {
        var _this = _super.call(this, sparseIntervals) || this;
        _this.objects = objects;
        return _this;
    }
    SparseObjectsIterator.prototype.initObject = function () {
        this.obj = this.objects[this.index];
    };
    return SparseObjectsIterator;
}(iterator_1.SparseIntervalsIterator));
exports.SparseObjectsIterator = SparseObjectsIterator;


/***/ }),
/* 172 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.TextFloodFilterPrimitive = exports.TextFilterPrimitive = void 0;
var RenderHelper_1 = __webpack_require__(15);
var FilterPrimitive_1 = __webpack_require__(108);
var Model_1 = __webpack_require__(62);
var color_1 = __webpack_require__(22);
var TextFilterPrimitive = (function (_super) {
    __extends(TextFilterPrimitive, _super);
    function TextFilterPrimitive(id, x, y, width, height) {
        if (x === void 0) { x = "-0.05"; }
        if (y === void 0) { y = "-0.05"; }
        if (width === void 0) { width = "1.1"; }
        if (height === void 0) { height = "1.1"; }
        var _this = _super.call(this, id, x, y, width, height) || this;
        _this.id = id;
        _this.x = x;
        _this.y = y;
        _this.width = width;
        _this.height = height;
        return _this;
    }
    TextFilterPrimitive.prototype.createChildElements = function (parent) {
        var feFlood = document.createElementNS(RenderHelper_1.svgNS, "feFlood");
        parent.appendChild(feFlood);
        var feComposite = document.createElementNS(RenderHelper_1.svgNS, "feComposite");
        feComposite.setAttribute("in", "SourceGraphic");
        feComposite.setAttribute("operator", "atop");
        parent.appendChild(feComposite);
    };
    return TextFilterPrimitive;
}(FilterPrimitive_1.FilterPrimitive));
exports.TextFilterPrimitive = TextFilterPrimitive;
var TextFloodFilterPrimitive = (function (_super) {
    __extends(TextFloodFilterPrimitive, _super);
    function TextFloodFilterPrimitive(id, floodColor, x, y, width, height) {
        if (x === void 0) { x = "-0.05"; }
        if (y === void 0) { y = "-0.05"; }
        if (width === void 0) { width = "1.1"; }
        if (height === void 0) { height = "1.1"; }
        var _this = _super.call(this, id, x, y, width, height) || this;
        _this.id = id;
        _this.floodColor = floodColor;
        _this.x = x;
        _this.y = y;
        _this.width = width;
        _this.height = height;
        return _this;
    }
    TextFloodFilterPrimitive.prototype.applyChildrenProperties = function (element) {
        for (var child = void 0, i = 0; child = element.childNodes[i]; i++)
            if (child.nodeName && child.nodeName.toUpperCase() === "FEFLOOD") {
                this.prepareFEFloodNode(child);
                break;
            }
    };
    TextFloodFilterPrimitive.prototype.prepareFEFloodNode = function (node) {
        var colorHash = color_1.ColorUtils.colorToHash(this.floodColor);
        node.setAttribute("flood-color", colorHash);
        node.setAttribute("class", "text-filter-flood");
        if (this.floodColor !== Model_1.DiagramModel.defaultPageColor)
            node.style.setProperty("flood-color", colorHash);
        else
            node.style.setProperty("flood-color", "");
    };
    return TextFloodFilterPrimitive;
}(TextFilterPrimitive));
exports.TextFloodFilterPrimitive = TextFloodFilterPrimitive;


/***/ }),
/* 173 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

Object.defineProperty(exports, "__esModule", { value: true });
var EncodeUtils = (function () {
    function EncodeUtils() {
    }
    EncodeUtils.encodeHtml = function (text) {
        return text
            .replace(/&/g, '&amp;')
            .replace(/</g, '&lt;')
            .replace(/>/g, '&gt;');
    };
    EncodeUtils.decodeHtml = function (text) {
        return text
            .replace(/&amp;/g, '&')
            .replace(/&lt;/g, '<')
            .replace(/&gt;/g, '>');
    };
    EncodeUtils.prepareTextForRequest = function (text) {
        return text
            .replace(/%/g, '%25')
            .replace(/&/g, '%26amp;')
            .replace(/\+/g, '%2B')
            .replace(/</g, '%26lt;')
            .replace(/>/g, '%26gt;')
            .replace(/"/g, '%26quot;');
    };
    EncodeUtils.prepareTextForCallBackRequest = function (text) {
        return text
            .replace(/&/g, '&amp;')
            .replace(/</g, '&lt;')
            .replace(/>/g, '&gt;')
            .replace(/"/g, '&quot;');
    };
    EncodeUtils.decodeViaTextArea = function (html) {
        var textArea = document.createElement('TEXTAREA');
        textArea.innerHTML = html;
        return textArea.value;
    };
    return EncodeUtils;
}());
exports.EncodeUtils = EncodeUtils;


/***/ }),
/* 174 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";


__webpack_require__(175).polyfill();


/***/ }),
/* 175 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";
/**
 * Code refactored from Mozilla Developer Network:
 * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign
 */



function assign(target, firstSource) {
  if (target === undefined || target === null) {
    throw new TypeError('Cannot convert first argument to object');
  }

  var to = Object(target);
  for (var i = 1; i < arguments.length; i++) {
    var nextSource = arguments[i];
    if (nextSource === undefined || nextSource === null) {
      continue;
    }

    var keysArray = Object.keys(Object(nextSource));
    for (var nextIndex = 0, len = keysArray.length; nextIndex < len; nextIndex++) {
      var nextKey = keysArray[nextIndex];
      var desc = Object.getOwnPropertyDescriptor(nextSource, nextKey);
      if (desc !== undefined && desc.enumerable) {
        to[nextKey] = nextSource[nextKey];
      }
    }
  }
  return to;
}

function polyfill() {
  if (!Object.assign) {
    Object.defineProperty(Object, 'assign', {
      enumerable: false,
      configurable: true,
      writable: true,
      value: assign
    });
  }
}

module.exports = {
  assign: assign,
  polyfill: polyfill
};


/***/ }),
/* 176 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

Object.defineProperty(exports, "__esModule", { value: true });
var browser_1 = __webpack_require__(18);
var common_1 = __webpack_require__(50);
var TouchUtils = (function () {
    function TouchUtils() {
    }
    TouchUtils.onEventAttachingToDocument = function (eventName, func) {
        if (browser_1.Browser.MacOSMobilePlatform && TouchUtils.isTouchEventName(eventName)) {
            if (!TouchUtils.documentTouchHandlers[eventName])
                TouchUtils.documentTouchHandlers[eventName] = [];
            TouchUtils.documentTouchHandlers[eventName].push(func);
            return TouchUtils.documentEventAttachingAllowed;
        }
        return true;
    };
    TouchUtils.isTouchEventName = function (eventName) {
        return browser_1.Browser.WebKitTouchUI && (eventName.indexOf('touch') > -1 || eventName.indexOf('gesture') > -1);
    };
    TouchUtils.isTouchEvent = function (evt) {
        return browser_1.Browser.WebKitTouchUI && common_1.isDefined(evt.changedTouches);
    };
    TouchUtils.getEventX = function (evt) {
        return browser_1.Browser.IE ? evt.pageX : evt.changedTouches[0].pageX;
    };
    TouchUtils.getEventY = function (evt) {
        return browser_1.Browser.IE ? evt.pageY : evt.changedTouches[0].pageY;
    };
    TouchUtils.touchMouseDownEventName = browser_1.Browser.WebKitTouchUI ? 'touchstart' : (browser_1.Browser.Edge && browser_1.Browser.MSTouchUI && window.PointerEvent ? 'pointerdown' : 'mousedown');
    TouchUtils.touchMouseUpEventName = browser_1.Browser.WebKitTouchUI ? 'touchend' : (browser_1.Browser.Edge && browser_1.Browser.MSTouchUI && window.PointerEvent ? 'pointerup' : 'mouseup');
    TouchUtils.touchMouseMoveEventName = browser_1.Browser.WebKitTouchUI ? 'touchmove' : (browser_1.Browser.Edge && browser_1.Browser.MSTouchUI && window.PointerEvent ? 'pointermove' : 'mousemove');
    TouchUtils.msTouchDraggableClassName = 'dxMSTouchDraggable';
    TouchUtils.documentTouchHandlers = {};
    TouchUtils.documentEventAttachingAllowed = true;
    return TouchUtils;
}());
exports.TouchUtils = TouchUtils;


/***/ }),
/* 177 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

Object.defineProperty(exports, "__esModule", { value: true });
var browser_1 = __webpack_require__(18);
var base64_1 = __webpack_require__(83);
var common_1 = __webpack_require__(50);
var FileUtils = (function () {
    function FileUtils() {
    }
    FileUtils.loadJavascriptFile = function (srcUri, callback) {
        var _a;
        var headElem = document.getElementsByTagName('head')[0];
        if (!headElem) {
            headElem = document.createElement('head');
            var bodyElem = document.getElementsByTagName('body')[0];
            (_a = bodyElem.parentNode) === null || _a === void 0 ? void 0 : _a.insertBefore(headElem, bodyElem);
        }
        var scriptElem = document.createElement('script');
        scriptElem.onload = callback;
        scriptElem.src = srcUri;
        headElem.appendChild(scriptElem);
        return { htmlScriptElement: scriptElem };
    };
    FileUtils.startDownloadFileLocal = function (content, fileName) {
        if (content instanceof ArrayBuffer)
            content = base64_1.Base64Utils.fromArrayBuffer(content);
        if (common_1.isString(content))
            content = base64_1.Base64Utils.getFileFromBase64(content);
        if (window.navigator.msSaveOrOpenBlob)
            window.navigator.msSaveOrOpenBlob(content, fileName);
        else {
            var a_1 = document.createElement('a');
            var url_1 = URL.createObjectURL(content);
            a_1.href = url_1;
            a_1.download = fileName;
            document.body.appendChild(a_1);
            a_1.click();
            setTimeout(function () {
                document.body.removeChild(a_1);
                window.URL.revokeObjectURL(url_1);
            }, 0);
        }
    };
    FileUtils.createFile = function (fileBits, fileName, options) {
        var _a;
        if (browser_1.Browser.IE || browser_1.Browser.Edge && browser_1.Browser.MajorVersion < 86) {
            var blob = new Blob(fileBits, options);
            blob['lastModifiedDate'] = (_a = options === null || options === void 0 ? void 0 : options.lastModified) !== null && _a !== void 0 ? _a : Date.now();
            blob['name'] = fileName;
            return blob;
        }
        else
            return new File(fileBits, fileName, options);
    };
    FileUtils.isFile = function (file) {
        if (browser_1.Browser.IE || browser_1.Browser.Edge && browser_1.Browser.MajorVersion < 86)
            return (file instanceof File) || (file instanceof Blob && common_1.isDefined(file.name));
        else
            return file instanceof File;
    };
    return FileUtils;
}());
exports.FileUtils = FileUtils;


/***/ }),
/* 178 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var _a, _b, _c;
Object.defineProperty(exports, "__esModule", { value: true });
exports.OpenXmlMimeType = 'application/vnd.openxmlformats-officedocument.wordprocessingml.document';
exports.RtfMimeType = 'application/rtf';
exports.PlainTextMimeType = 'text/plain';
exports.DocmMimeType = 'application/vnd.ms-word.document.macroEnabled.12';
exports.ImagePngMimeType = 'image/png';
exports.ImageGifMimeType = 'image/gif';
exports.ImageJpegMimeType = 'image/jpeg';
exports.ImagePjpegMimeType = 'image/pjpeg';
exports.ImageSvgMimeType = 'image/svg+xml';
exports.ImageTiffMimeType = 'image/tiff';
exports.ImageIcoMimeType = 'image/vnd.microsoft.icon';
exports.ImageWbmpMimeType = 'image/vnd.wap.wbmp';
exports.ImageWebpMimeType = 'image/webp';
var DxMimeType;
(function (DxMimeType) {
    DxMimeType[DxMimeType["Unknown"] = 0] = "Unknown";
    DxMimeType[DxMimeType["OpenXml"] = 1] = "OpenXml";
    DxMimeType[DxMimeType["Rtf"] = 2] = "Rtf";
    DxMimeType[DxMimeType["PlainText"] = 3] = "PlainText";
    DxMimeType[DxMimeType["Docm"] = 4] = "Docm";
    DxMimeType[DxMimeType["Png"] = 5] = "Png";
    DxMimeType[DxMimeType["Gif"] = 6] = "Gif";
    DxMimeType[DxMimeType["Jpeg"] = 7] = "Jpeg";
    DxMimeType[DxMimeType["Pjpeg"] = 8] = "Pjpeg";
    DxMimeType[DxMimeType["Svg"] = 9] = "Svg";
    DxMimeType[DxMimeType["Tiff"] = 10] = "Tiff";
    DxMimeType[DxMimeType["Ico"] = 11] = "Ico";
    DxMimeType[DxMimeType["Wbmp"] = 12] = "Wbmp";
    DxMimeType[DxMimeType["Webp"] = 13] = "Webp";
})(DxMimeType = exports.DxMimeType || (exports.DxMimeType = {}));
var MimeTypeUtils = (function () {
    function MimeTypeUtils() {
    }
    MimeTypeUtils.stringTypeToExtension = function (mimeTypeAsStr) {
        var mimeType = MimeTypeUtils.stringTypeToTypeMap[mimeTypeAsStr];
        return mimeType === undefined ? '' : MimeTypeUtils.typeToExtensionMap[mimeType];
    };
    MimeTypeUtils.typeToExtension = function (mimeType) {
        var ext = MimeTypeUtils.typeToExtensionMap[mimeType];
        return ext !== null && ext !== void 0 ? ext : '';
    };
    MimeTypeUtils.extensionToType = function (extension) {
        extension = extension.toLowerCase();
        if (extension[0] !== '.')
            extension += '.';
        var mimeType = MimeTypeUtils.extensionToTypeMap[extension];
        return mimeType !== null && mimeType !== void 0 ? mimeType : DxMimeType.Unknown;
    };
    MimeTypeUtils.typeToStringType = function (mimeType) {
        var str = MimeTypeUtils.typeToStringTypeMap[mimeType];
        return str !== null && str !== void 0 ? str : '';
    };
    MimeTypeUtils.stringTypeToType = function (mimeTypeAsStr) {
        var mimeType = MimeTypeUtils.stringTypeToTypeMap[mimeTypeAsStr];
        return mimeType === undefined ? DxMimeType.Unknown : mimeType;
    };
    MimeTypeUtils.stringTypeToTypeMap = (_a = {},
        _a[exports.OpenXmlMimeType] = DxMimeType.OpenXml,
        _a[exports.RtfMimeType] = DxMimeType.Rtf,
        _a[exports.PlainTextMimeType] = DxMimeType.PlainText,
        _a[exports.DocmMimeType] = DxMimeType.Docm,
        _a[exports.ImagePngMimeType] = DxMimeType.Png,
        _a[exports.ImageGifMimeType] = DxMimeType.Gif,
        _a[exports.ImageJpegMimeType] = DxMimeType.Jpeg,
        _a[exports.ImagePjpegMimeType] = DxMimeType.Pjpeg,
        _a[exports.ImageSvgMimeType] = DxMimeType.Svg,
        _a[exports.ImageTiffMimeType] = DxMimeType.Tiff,
        _a[exports.ImageIcoMimeType] = DxMimeType.Ico,
        _a[exports.ImageWbmpMimeType] = DxMimeType.Wbmp,
        _a[exports.ImageWebpMimeType] = DxMimeType.Webp,
        _a);
    MimeTypeUtils.typeToStringTypeMap = (_b = {},
        _b[DxMimeType.Unknown] = undefined,
        _b[DxMimeType.OpenXml] = exports.OpenXmlMimeType,
        _b[DxMimeType.Rtf] = exports.RtfMimeType,
        _b[DxMimeType.PlainText] = exports.PlainTextMimeType,
        _b[DxMimeType.Docm] = exports.DocmMimeType,
        _b[DxMimeType.Png] = exports.ImagePngMimeType,
        _b[DxMimeType.Gif] = exports.ImageGifMimeType,
        _b[DxMimeType.Jpeg] = exports.ImageJpegMimeType,
        _b[DxMimeType.Pjpeg] = exports.ImagePjpegMimeType,
        _b[DxMimeType.Svg] = exports.ImageSvgMimeType,
        _b[DxMimeType.Tiff] = exports.ImageTiffMimeType,
        _b[DxMimeType.Ico] = exports.ImageIcoMimeType,
        _b[DxMimeType.Wbmp] = exports.ImageWbmpMimeType,
        _b[DxMimeType.Webp] = exports.ImageWebpMimeType,
        _b);
    MimeTypeUtils.typeToExtensionMap = (_c = {},
        _c[DxMimeType.Unknown] = undefined,
        _c[DxMimeType.OpenXml] = '.docx',
        _c[DxMimeType.Rtf] = '.rtf',
        _c[DxMimeType.PlainText] = '.txt',
        _c[DxMimeType.Docm] = '.docm',
        _c[DxMimeType.Png] = '.png',
        _c[DxMimeType.Gif] = '.gif',
        _c[DxMimeType.Jpeg] = '.jpeg',
        _c[DxMimeType.Pjpeg] = '.pjpeg',
        _c[DxMimeType.Svg] = '.svg',
        _c[DxMimeType.Tiff] = '.tiff',
        _c[DxMimeType.Ico] = '.ico',
        _c[DxMimeType.Wbmp] = '.wbmp',
        _c[DxMimeType.Webp] = '.webp',
        _c);
    MimeTypeUtils.extensionToTypeMap = {
        '.docx': DxMimeType.OpenXml,
        '.rtf': DxMimeType.Rtf,
        '.txt': DxMimeType.PlainText,
        '.docm': DxMimeType.Docm,
        '.png': DxMimeType.Png,
        '.gif': DxMimeType.Gif,
        '.jpeg': DxMimeType.Jpeg,
        '.pjpeg': DxMimeType.Pjpeg,
        '.svg': DxMimeType.Svg,
        '.tiff': DxMimeType.Tiff,
        '.ico': DxMimeType.Ico,
        '.wbmp': DxMimeType.Wbmp,
        '.webp': DxMimeType.Webp,
    };
    return MimeTypeUtils;
}());
exports.MimeTypeUtils = MimeTypeUtils;


/***/ }),
/* 179 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.ConnectorPointsCalculator = void 0;
var ConnectorPointsCalculatorBase_1 = __webpack_require__(111);
var ConnectorRenderPoint_1 = __webpack_require__(29);
var ConnectorPointsCalculator = (function (_super) {
    __extends(ConnectorPointsCalculator, _super);
    function ConnectorPointsCalculator() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    ConnectorPointsCalculator.prototype.getPoints = function () {
        return this.connector.points.map(function (pt, index) { return new ConnectorRenderPoint_1.ConnectorRenderPoint(pt.x, pt.y, index); });
    };
    return ConnectorPointsCalculator;
}(ConnectorPointsCalculatorBase_1.ConnectorPointsCalculatorBase));
exports.ConnectorPointsCalculator = ConnectorPointsCalculator;


/***/ }),
/* 180 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.ConnectorPointsOrthogonalCalculator = void 0;
var rectangle_1 = __webpack_require__(13);
var DiagramItem_1 = __webpack_require__(9);
var ConnectorPointsCalculatorBase_1 = __webpack_require__(111);
var ConnectorPointsOrthogonalUndefinedSideCalculator_1 = __webpack_require__(181);
var ConnectorPointsOrthogonalSouthSideCalculator_1 = __webpack_require__(182);
var ConnectorPointsOrthogonalNorthSideCalculator_1 = __webpack_require__(183);
var ConnectorPointsOrthogonalEastSideCalculator_1 = __webpack_require__(184);
var ConnectorPointsOrthogonalWestSideCalculator_1 = __webpack_require__(185);
var ConnectorRenderPoint_1 = __webpack_require__(29);
var ModelUtils_1 = __webpack_require__(4);
var ConnectorPointsOrthogonalCalculator = (function (_super) {
    __extends(ConnectorPointsOrthogonalCalculator, _super);
    function ConnectorPointsOrthogonalCalculator(connector) {
        var _this = _super.call(this, connector) || this;
        _this.sideCalculators = {};
        _this.sideCalculators[DiagramItem_1.ConnectionPointSide.Undefined] = new ConnectorPointsOrthogonalUndefinedSideCalculator_1.ConnectorPointsOrthogonalUndefinedSideCalculator(_this);
        _this.sideCalculators[DiagramItem_1.ConnectionPointSide.South] = new ConnectorPointsOrthogonalSouthSideCalculator_1.ConnectorPointsOrthogonalSouthSideCalculator(_this);
        _this.sideCalculators[DiagramItem_1.ConnectionPointSide.North] = new ConnectorPointsOrthogonalNorthSideCalculator_1.ConnectorPointsOrthogonalNorthSideCalculator(_this);
        _this.sideCalculators[DiagramItem_1.ConnectionPointSide.East] = new ConnectorPointsOrthogonalEastSideCalculator_1.ConnectorPointsOrthogonalEastSideCalculator(_this);
        _this.sideCalculators[DiagramItem_1.ConnectionPointSide.West] = new ConnectorPointsOrthogonalWestSideCalculator_1.ConnectorPointsOrthogonalWestSideCalculator(_this);
        return _this;
    }
    Object.defineProperty(ConnectorPointsOrthogonalCalculator.prototype, "beginRect", {
        get: function () { return this.connector.beginItem ? this.connector.beginItem.rectangle : undefined; },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(ConnectorPointsOrthogonalCalculator.prototype, "endRect", {
        get: function () { return this.connector.endItem ? this.connector.endItem.rectangle : undefined; },
        enumerable: false,
        configurable: true
    });
    ConnectorPointsOrthogonalCalculator.prototype.getPoints = function () {
        var points = this.connector.points.map(function (pt, index) { return new ConnectorRenderPoint_1.ConnectorRenderPoint(pt.x, pt.y, index); });
        ModelUtils_1.ModelUtils.removeUnnecessaryRenderPoints(points);
        var beginIndex = 0;
        var endIndex = points.length - 1;
        var beginSide = this.getPointSide(points, 0);
        var beginNextSide = this.getPointSide(points, 1);
        var endSide = this.getPointSide(points, points.length - 1);
        var endPrevSide = this.getPointSide(points, points.length - 1 - 1);
        var beginSideCalculator = this.getSideCalculator(beginSide);
        var endSideCalculator = this.getSideCalculator(endSide);
        var originRect = this.beginRect;
        var originPoint = beginSideCalculator.getCorrectOriginPoint(points[beginIndex], originRect);
        var targetPoint = points[beginIndex + 1];
        if (points.length === 2 && beginSideCalculator.isOnSidePoint(originPoint, targetPoint) &&
            beginSideCalculator.isDirectConnectionAllowed(beginNextSide, originPoint, targetPoint)) {
            var directConnectionPoints = beginSideCalculator.getDirectConnectionPoints(originPoint, targetPoint);
            directConnectionPoints.forEach(function (pt) {
                points.splice(beginIndex + 1, 0, pt);
                beginIndex++;
                endIndex++;
            });
        }
        else {
            var bOffsetPoints = beginSideCalculator.getBeginOffsetPoints(beginNextSide, points[beginIndex], points[beginIndex + 1], this.beginRect);
            bOffsetPoints.forEach(function (pt) {
                points.splice(beginIndex + 1, 0, pt);
            });
            beginIndex += bOffsetPoints.length;
            endIndex += bOffsetPoints.length;
            var eOffsetPoints = endSideCalculator.getEndOffsetPoints(endPrevSide, points[endIndex], points[endIndex - 1], this.endRect);
            eOffsetPoints.forEach(function (pt, index) {
                points.splice(endIndex + index, 0, pt);
            });
            this.addMiddlePoints(points, beginIndex, endIndex);
        }
        ModelUtils_1.ModelUtils.removeUnnecessaryRenderPoints(points);
        return points;
    };
    ConnectorPointsOrthogonalCalculator.prototype.getSideCalculator = function (side) {
        return this.sideCalculators[side];
    };
    ConnectorPointsOrthogonalCalculator.prototype.getPointSide = function (points, index) {
        if (index === 0 && this.connector.beginItem) {
            var connectionPointIndex = this.connector.beginConnectionPointIndex;
            return this.connector.beginItem.getConnectionPointSideByIndex(connectionPointIndex, points[1]);
        }
        if (index === points.length - 1 && this.connector.endItem) {
            var connectionPointIndex = this.connector.endConnectionPointIndex;
            return this.connector.endItem.getConnectionPointSideByIndex(connectionPointIndex, points[points.length - 2]);
        }
        return DiagramItem_1.ConnectionPointSide.Undefined;
    };
    ConnectorPointsOrthogonalCalculator.prototype.addMiddlePoints = function (points, beginIndex, endIndex) {
        for (var index = beginIndex; index < endIndex; index++) {
            var nextIndex = index + 1;
            var middlePoint = this.getMiddlePoint(points[index], points[index - 1], index - 1 === 0, points[nextIndex], points[nextIndex + 1], nextIndex + 1 === points.length - 1);
            if (middlePoint !== undefined) {
                points.splice(index + 1, 0, middlePoint);
                index++;
                endIndex++;
            }
        }
    };
    ConnectorPointsOrthogonalCalculator.prototype.getMiddlePoints = function (point1, point2) {
        if (point1.x === point2.x || point1.y === point2.y)
            return [];
        return [
            new ConnectorRenderPoint_1.ConnectorRenderPoint(point1.x, point2.y),
            new ConnectorRenderPoint_1.ConnectorRenderPoint(point2.x, point1.y)
        ];
    };
    ConnectorPointsOrthogonalCalculator.prototype.getMiddlePoint = function (point1, directionPoint1, nextToBegin, point2, directionPoint2, nextToEnd) {
        var _this = this;
        var point;
        var points = this.getMiddlePoints(point1, point2);
        points.forEach(function (pt) {
            var rect1 = _this.createPointsRect(point1, pt);
            var rect2 = _this.createPointsRect(pt, point2);
            var itemRect1 = _this.connector.beginItem ? _this.connector.beginItem.rectangle : undefined;
            var itemRect2 = _this.connector.endItem ? _this.connector.endItem.rectangle : undefined;
            if (itemRect1)
                if (rectangle_1.Rectangle.areIntersected(itemRect1, rect1) || rectangle_1.Rectangle.areIntersected(itemRect1, rect2))
                    return;
            if (itemRect2)
                if (rectangle_1.Rectangle.areIntersected(itemRect2, rect1) || rectangle_1.Rectangle.areIntersected(itemRect2, rect2))
                    return;
            if ((!_this.isReturnPoint(pt, point1, directionPoint1) || _this.isIntermediatePoints(point1, directionPoint1)) &&
                (!_this.isReturnPoint(pt, point2, directionPoint2) || _this.isIntermediatePoints(point2, directionPoint2)))
                if (point === undefined)
                    point = pt;
                else if (_this.isPriorMiddlePoint(pt, point1, directionPoint1, point2, directionPoint2))
                    point = pt;
        });
        if (point === undefined && points.length > 0)
            point = points[0];
        return point;
    };
    ConnectorPointsOrthogonalCalculator.prototype.createPointsRect = function (point1, point2) {
        var result = rectangle_1.Rectangle.fromPoints(point1, point2);
        if (result.width > 0)
            result = result.clone().inflate(-1, 0);
        if (result.height > 0)
            result = result.clone().inflate(0, -1);
        return result;
    };
    ConnectorPointsOrthogonalCalculator.prototype.isPriorMiddlePoint = function (point, point1, directionPoint1, point2, directionPoint2) {
        if (directionPoint1)
            if (point.x === directionPoint1.x || point.y === directionPoint1.y)
                return true;
        if (directionPoint2)
            if (point.x === directionPoint2.x || point.y === directionPoint2.y)
                return true;
        return false;
    };
    ConnectorPointsOrthogonalCalculator.prototype.isReturnPoint = function (point, point1, point2) {
        if (point1 !== undefined && point2 !== undefined) {
            if (point.x === point2.x)
                if (point1.y < point.y && point.y < point2.y || point1.y > point.y && point.y > point2.y)
                    return true;
            if (point.y === point2.y)
                if (point1.x < point.x && point.x < point2.x || point1.x > point.x && point.x > point2.x)
                    return true;
        }
        return false;
    };
    ConnectorPointsOrthogonalCalculator.prototype.isIntermediatePoints = function (point1, point2) {
        return 0 < point1.pointIndex && point1.pointIndex < this.connector.points.length - 1 &&
            0 < point2.pointIndex && point2.pointIndex < this.connector.points.length - 1;
    };
    return ConnectorPointsOrthogonalCalculator;
}(ConnectorPointsCalculatorBase_1.ConnectorPointsCalculatorBase));
exports.ConnectorPointsOrthogonalCalculator = ConnectorPointsOrthogonalCalculator;


/***/ }),
/* 181 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.ConnectorPointsOrthogonalUndefinedSideCalculator = void 0;
var ConnectorPointsOrthogonalSideCalculatorBase_1 = __webpack_require__(52);
var ConnectorRenderPoint_1 = __webpack_require__(29);
var ConnectorPointsOrthogonalUndefinedSideCalculator = (function (_super) {
    __extends(ConnectorPointsOrthogonalUndefinedSideCalculator, _super);
    function ConnectorPointsOrthogonalUndefinedSideCalculator(parent) {
        return _super.call(this, parent) || this;
    }
    ConnectorPointsOrthogonalUndefinedSideCalculator.prototype.getCorrectOriginPoint = function (originPoint, originRect) {
        return originPoint;
    };
    ConnectorPointsOrthogonalUndefinedSideCalculator.prototype.getSameShapeOffsetPoints = function (targetSide, originPoint, targetPoint, originRect) {
        return [];
    };
    ConnectorPointsOrthogonalUndefinedSideCalculator.prototype.getOverlappedPointsOffsetPoints = function (targetSide, originPoint, targetPoint, originRect) {
        return [];
    };
    ConnectorPointsOrthogonalUndefinedSideCalculator.prototype.getBeginOverlappedShapeOffsetPoints = function (targetSide, originPoint, targetPoint, originRect) {
        return [];
    };
    ConnectorPointsOrthogonalUndefinedSideCalculator.prototype.getEndOverlappedShapeOffsetPoints = function (targetSide, originPoint, targetPoint, originRect) {
        return [];
    };
    ConnectorPointsOrthogonalUndefinedSideCalculator.prototype.getBeginOnSideOffsetPoints = function (targetSide, originPoint, targetPoint, originRect) {
        return [];
    };
    ConnectorPointsOrthogonalUndefinedSideCalculator.prototype.getEndOnSideOffsetPoints = function (targetSide, originPoint, targetPoint, originRect) {
        return [];
    };
    ConnectorPointsOrthogonalUndefinedSideCalculator.prototype.getBeginOffSideOffsetPoints = function (targetSide, originPoint, targetPoint, originRect) {
        return [];
    };
    ConnectorPointsOrthogonalUndefinedSideCalculator.prototype.getEndOffSideOffsetPoints = function (targetSide, originPoint, targetPoint, originRect) {
        return [];
    };
    ConnectorPointsOrthogonalUndefinedSideCalculator.prototype.isOnSidePoint = function (originPoint, targetPoint) {
        return true;
    };
    ConnectorPointsOrthogonalUndefinedSideCalculator.prototype.isDirectConnectionAllowed = function (targetSide, originPoint, targetPoint) {
        var calculator = this.getSideCalculator(originPoint, targetPoint);
        if (calculator !== undefined)
            return calculator.isDirectConnectionAllowed(targetSide, originPoint, targetPoint);
        return true;
    };
    ConnectorPointsOrthogonalUndefinedSideCalculator.prototype.getDirectConnectionPoints = function (originPoint, targetPoint) {
        var diffX = Math.abs(targetPoint.x - originPoint.x);
        var diffY = Math.abs(targetPoint.y - originPoint.y);
        if (diffX > diffY) {
            var minX = Math.min(originPoint.x, targetPoint.x);
            var cx = minX + diffX / 2;
            return [
                new ConnectorRenderPoint_1.ConnectorRenderPoint(cx, originPoint.y),
                new ConnectorRenderPoint_1.ConnectorRenderPoint(cx, targetPoint.y)
            ];
        }
        else {
            var minY = Math.min(originPoint.y, targetPoint.y);
            var cy = minY + diffY / 2;
            return [
                new ConnectorRenderPoint_1.ConnectorRenderPoint(originPoint.x, cy),
                new ConnectorRenderPoint_1.ConnectorRenderPoint(targetPoint.x, cy)
            ];
        }
    };
    return ConnectorPointsOrthogonalUndefinedSideCalculator;
}(ConnectorPointsOrthogonalSideCalculatorBase_1.ConnectorPointsOrthogonalSideCalculatorBase));
exports.ConnectorPointsOrthogonalUndefinedSideCalculator = ConnectorPointsOrthogonalUndefinedSideCalculator;


/***/ }),
/* 182 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.ConnectorPointsOrthogonalSouthSideCalculator = void 0;
var DiagramItem_1 = __webpack_require__(9);
var ConnectorPointsOrthogonalSideCalculatorBase_1 = __webpack_require__(52);
var ConnectorRenderPoint_1 = __webpack_require__(29);
var ConnectorPointsOrthogonalSouthSideCalculator = (function (_super) {
    __extends(ConnectorPointsOrthogonalSouthSideCalculator, _super);
    function ConnectorPointsOrthogonalSouthSideCalculator(parent) {
        return _super.call(this, parent) || this;
    }
    ConnectorPointsOrthogonalSouthSideCalculator.prototype.getCorrectOriginPoint = function (originPoint, originRect) {
        if (originPoint.y < originRect.bottom)
            originPoint = originPoint.clone().offset(0, originRect.bottom - originPoint.y);
        return originPoint;
    };
    ConnectorPointsOrthogonalSouthSideCalculator.prototype.getSameShapeOffsetPoints = function (targetSide, originPoint, targetPoint, originRect) {
        switch (targetSide) {
            case DiagramItem_1.ConnectionPointSide.East:
            case DiagramItem_1.ConnectionPointSide.West:
            case DiagramItem_1.ConnectionPointSide.South:
                return [originPoint.clone().offset(0, this.getMinOffset())];
            case DiagramItem_1.ConnectionPointSide.North:
                return this.getAsideOffsetPoints(originPoint, targetPoint, originRect, this.getMinOffset(), this.getMinOffset());
        }
    };
    ConnectorPointsOrthogonalSouthSideCalculator.prototype.getOverlappedPointsOffsetPoints = function (targetSide, originPoint, targetPoint, originRect) {
        switch (targetSide) {
            case DiagramItem_1.ConnectionPointSide.South:
                return [originPoint.clone().offset(0, this.getMinOffset())];
            case DiagramItem_1.ConnectionPointSide.North:
                return [originPoint.clone().offset(0, -this.getMinOffset())];
        }
        return [];
    };
    ConnectorPointsOrthogonalSouthSideCalculator.prototype.getBeginOverlappedShapeOffsetPoints = function (targetSide, originPoint, targetPoint, originRect) {
        switch (targetSide) {
            case DiagramItem_1.ConnectionPointSide.East:
                if (originPoint.y < targetPoint.y)
                    if (originPoint.x > targetPoint.x)
                        return [];
                    else
                        return [originPoint.clone().offset(0, this.getMinOffset())];
                if (originPoint.y > this.endRect.bottom)
                    return this.getAsideOffsetPoints(originPoint, targetPoint, originRect, this.getMinOffset(), this.getMinOffset(), false);
                return [originPoint.clone().offset(0, this.getMinOffset())];
            case DiagramItem_1.ConnectionPointSide.West:
                if (originPoint.y < targetPoint.y)
                    if (originPoint.x < targetPoint.x)
                        return [];
                    else
                        return [originPoint.clone().offset(0, this.getMinOffset())];
                if (originPoint.y > this.endRect.bottom)
                    return this.getAsideOffsetPoints(originPoint, targetPoint, originRect, this.getMinOffset(), this.getMinOffset(), true);
                return [originPoint.clone().offset(0, this.getMinOffset())];
            case DiagramItem_1.ConnectionPointSide.South:
                return [originPoint.clone().offset(0, this.getMinOffset())];
            case DiagramItem_1.ConnectionPointSide.North:
                return this.getAsideOffsetPoints(originPoint, targetPoint, originRect, this.getMinOffset(), this.getMinOffset(), originPoint.x < targetPoint.x);
        }
    };
    ConnectorPointsOrthogonalSouthSideCalculator.prototype.getEndOverlappedShapeOffsetPoints = function (targetSide, originPoint, targetPoint, originRect) {
        switch (targetSide) {
            case DiagramItem_1.ConnectionPointSide.East:
                if (targetPoint.y < originPoint.y)
                    return this.getAsideOffsetPoints(originPoint, targetPoint, originRect, this.getMinOffset(), this.getMinOffset(), false);
                if (originPoint.x < targetPoint.x)
                    return [originPoint.clone().offset(0, this.getMinOffset())];
                return [];
            case DiagramItem_1.ConnectionPointSide.West:
                if (targetPoint.y < originPoint.y)
                    return this.getAsideOffsetPoints(originPoint, targetPoint, originRect, this.getMinOffset(), this.getMinOffset(), true);
                if (originPoint.x > targetPoint.x)
                    return [originPoint.clone().offset(0, this.getMinOffset())];
                return [];
            case DiagramItem_1.ConnectionPointSide.South:
                return [originPoint.clone().offset(0, this.getMinOffset())];
            case DiagramItem_1.ConnectionPointSide.North: {
                var offset = this.getMinOffset();
                if (this.beginRect.bottom > originPoint.y)
                    offset += this.beginRect.bottom - originPoint.y;
                return [originPoint.clone().offset(0, offset)];
            }
        }
    };
    ConnectorPointsOrthogonalSouthSideCalculator.prototype.getBeginOnSideOffsetPoints = function (targetSide, originPoint, targetPoint, originRect) {
        return [originPoint.clone().offset(0, this.getScaleableOffsetY(originPoint, targetPoint, false))];
    };
    ConnectorPointsOrthogonalSouthSideCalculator.prototype.getEndOnSideOffsetPoints = function (targetSide, originPoint, targetPoint, originRect) {
        return [originPoint.clone().offset(0, this.getScaleableOffsetY(originPoint, targetPoint, true))];
    };
    ConnectorPointsOrthogonalSouthSideCalculator.prototype.getBeginOffSideOffsetPoints = function (targetSide, originPoint, targetPoint, originRect) {
        switch (targetSide) {
            case DiagramItem_1.ConnectionPointSide.East:
                if (this.isBeginEndOverlappedX())
                    return this.getScaleableAsideOffsetPoints(originPoint, targetPoint, originRect, false, false);
                break;
            case DiagramItem_1.ConnectionPointSide.West:
                if (this.isBeginEndOverlappedX())
                    return this.getScaleableAsideOffsetPoints(originPoint, targetPoint, originRect, false, true);
                break;
            case DiagramItem_1.ConnectionPointSide.South:
                if (this.isBeginEndOverlappedX())
                    return this.getScaleableAsideOffsetPoints(originPoint, targetPoint, originRect, false);
                break;
            case DiagramItem_1.ConnectionPointSide.Undefined:
            case DiagramItem_1.ConnectionPointSide.North:
                return this.getScaleableAsideOffsetPoints(originPoint, targetPoint, originRect, false);
        }
        return [originPoint.clone().offset(0, this.getScaleableOffsetY(originPoint, targetPoint, false))];
    };
    ConnectorPointsOrthogonalSouthSideCalculator.prototype.getEndOffSideOffsetPoints = function (targetSide, originPoint, targetPoint, originRect) {
        if (targetSide === DiagramItem_1.ConnectionPointSide.Undefined)
            return this.getScaleableAsideOffsetPoints(originPoint, targetPoint, originRect, true);
        else if (this.isBeginEndOverlappedX()) {
            var direction = this.beginRect.center.x > this.endRect.center.x;
            return this.getScaleableAsideOffsetPoints(originPoint, targetPoint, originRect, true, direction);
        }
        return [originPoint.clone().offset(0, this.getScaleableOffsetY(originPoint, targetPoint, true))];
    };
    ConnectorPointsOrthogonalSouthSideCalculator.prototype.getAsideOffsetPoints = function (originPoint, targetPoint, originRect, offset, asideOffset, direction) {
        var points = [];
        if (originRect !== undefined) {
            if (direction === undefined)
                direction = targetPoint.x < originPoint.x;
            if (direction)
                points.push(originPoint.clone().offset(-(originPoint.x - originRect.x + asideOffset), offset));
            else
                points.push(originPoint.clone().offset((originRect.right - originPoint.x + asideOffset), offset));
        }
        points.push(originPoint.clone().offset(0, offset));
        return points;
    };
    ConnectorPointsOrthogonalSouthSideCalculator.prototype.getScaleableAsideOffsetPoints = function (originPoint, targetPoint, originRect, isEnd, direction) {
        var offset = this.getScaleableOffsetY(originPoint, targetPoint, isEnd);
        var asideOffset = this.getScaleableOffsetX(originPoint, targetPoint, isEnd);
        return this.getAsideOffsetPoints(originPoint, targetPoint, originRect, offset, asideOffset, direction);
    };
    ConnectorPointsOrthogonalSouthSideCalculator.prototype.getScaleableOffsetX = function (originPoint, targetPoint, isEnd) {
        if (this.beginRect && this.endRect)
            if (!isEnd && !this.isBeginEndOverlappedX()) {
                var distance = void 0;
                if (targetPoint.x < originPoint.x)
                    distance = this.beginRect.x - this.endRect.right;
                else
                    distance = this.endRect.x - this.beginRect.right;
                if (distance < this.getMinOffset() * 2)
                    return distance / 2;
            }
        return this.getMinOffset();
    };
    ConnectorPointsOrthogonalSouthSideCalculator.prototype.getScaleableOffsetY = function (originPoint, targetPoint, isEnd) {
        if (this.beginRect && this.endRect) {
            var distance = isEnd ? this.beginRect.y - originPoint.y : this.endRect.y - originPoint.y;
            if (distance > 0 && distance < this.getMinOffset() * 2)
                return distance / 2;
        }
        return this.getMinOffset();
    };
    ConnectorPointsOrthogonalSouthSideCalculator.prototype.isOnSidePoint = function (originPoint, targetPoint) {
        return targetPoint.y > originPoint.y;
    };
    ConnectorPointsOrthogonalSouthSideCalculator.prototype.isDirectConnectionAllowed = function (targetSide, originPoint, targetPoint) {
        return targetSide === DiagramItem_1.ConnectionPointSide.North || targetSide === DiagramItem_1.ConnectionPointSide.Undefined;
    };
    ConnectorPointsOrthogonalSouthSideCalculator.prototype.getDirectConnectionPoints = function (originPoint, targetPoint) {
        var cy = originPoint.y + (targetPoint.y - originPoint.y) / 2;
        return [
            new ConnectorRenderPoint_1.ConnectorRenderPoint(originPoint.x, cy),
            new ConnectorRenderPoint_1.ConnectorRenderPoint(targetPoint.x, cy)
        ];
    };
    return ConnectorPointsOrthogonalSouthSideCalculator;
}(ConnectorPointsOrthogonalSideCalculatorBase_1.ConnectorPointsOrthogonalSideCalculatorBase));
exports.ConnectorPointsOrthogonalSouthSideCalculator = ConnectorPointsOrthogonalSouthSideCalculator;


/***/ }),
/* 183 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.ConnectorPointsOrthogonalNorthSideCalculator = void 0;
var DiagramItem_1 = __webpack_require__(9);
var ConnectorPointsOrthogonalSideCalculatorBase_1 = __webpack_require__(52);
var ConnectorRenderPoint_1 = __webpack_require__(29);
var ConnectorPointsOrthogonalNorthSideCalculator = (function (_super) {
    __extends(ConnectorPointsOrthogonalNorthSideCalculator, _super);
    function ConnectorPointsOrthogonalNorthSideCalculator(parent) {
        return _super.call(this, parent) || this;
    }
    ConnectorPointsOrthogonalNorthSideCalculator.prototype.getCorrectOriginPoint = function (originPoint, originRect) {
        if (originPoint.y > originRect.y)
            originPoint = originPoint.clone().offset(0, originRect.y - originPoint.y);
        return originPoint;
    };
    ConnectorPointsOrthogonalNorthSideCalculator.prototype.getSameShapeOffsetPoints = function (targetSide, originPoint, targetPoint, originRect) {
        switch (targetSide) {
            case DiagramItem_1.ConnectionPointSide.East:
            case DiagramItem_1.ConnectionPointSide.West:
            case DiagramItem_1.ConnectionPointSide.North:
                return [originPoint.clone().offset(0, -this.getMinOffset())];
            case DiagramItem_1.ConnectionPointSide.South:
                return this.getAsideOffsetPoints(originPoint, targetPoint, originRect, this.getMinOffset(), this.getMinOffset());
        }
    };
    ConnectorPointsOrthogonalNorthSideCalculator.prototype.getOverlappedPointsOffsetPoints = function (targetSide, originPoint, targetPoint, originRect) {
        switch (targetSide) {
            case DiagramItem_1.ConnectionPointSide.South:
                return [originPoint.clone().offset(0, this.getMinOffset())];
            case DiagramItem_1.ConnectionPointSide.North:
                return [originPoint.clone().offset(0, -this.getMinOffset())];
        }
        return [];
    };
    ConnectorPointsOrthogonalNorthSideCalculator.prototype.getBeginOverlappedShapeOffsetPoints = function (targetSide, originPoint, targetPoint, originRect) {
        switch (targetSide) {
            case DiagramItem_1.ConnectionPointSide.East:
                if (originPoint.y > targetPoint.y)
                    if (originPoint.x > targetPoint.x)
                        return [];
                    else
                        return [originPoint.clone().offset(0, -this.getMinOffset())];
                if (originPoint.y < this.endRect.y)
                    return this.getAsideOffsetPoints(originPoint, targetPoint, originRect, this.getMinOffset(), this.getMinOffset(), false);
                return [originPoint.clone().offset(0, -this.getMinOffset())];
            case DiagramItem_1.ConnectionPointSide.West:
                if (originPoint.y > targetPoint.y)
                    if (originPoint.x < targetPoint.x)
                        return [];
                    else
                        return [originPoint.clone().offset(0, -this.getMinOffset())];
                if (originPoint.y < this.endRect.y)
                    return this.getAsideOffsetPoints(originPoint, targetPoint, originRect, this.getMinOffset(), this.getMinOffset(), true);
                return [originPoint.clone().offset(0, -this.getMinOffset())];
            case DiagramItem_1.ConnectionPointSide.North:
                return [originPoint.clone().offset(0, -this.getMinOffset())];
            case DiagramItem_1.ConnectionPointSide.South:
                return this.getAsideOffsetPoints(originPoint, targetPoint, originRect, this.getMinOffset(), this.getMinOffset(), originPoint.x < targetPoint.x);
        }
    };
    ConnectorPointsOrthogonalNorthSideCalculator.prototype.getEndOverlappedShapeOffsetPoints = function (targetSide, originPoint, targetPoint, originRect) {
        switch (targetSide) {
            case DiagramItem_1.ConnectionPointSide.East:
                if (targetPoint.y > originPoint.y)
                    return this.getAsideOffsetPoints(originPoint, targetPoint, originRect, this.getMinOffset(), this.getMinOffset(), false);
                if (originPoint.x < targetPoint.x)
                    return [originPoint.clone().offset(0, -this.getMinOffset())];
                return [];
            case DiagramItem_1.ConnectionPointSide.West:
                if (targetPoint.y > originPoint.y)
                    return this.getAsideOffsetPoints(originPoint, targetPoint, originRect, this.getMinOffset(), this.getMinOffset(), true);
                if (originPoint.x > targetPoint.x)
                    return [originPoint.clone().offset(0, -this.getMinOffset())];
                return [];
            case DiagramItem_1.ConnectionPointSide.North:
                return [originPoint.clone().offset(0, -this.getMinOffset())];
            case DiagramItem_1.ConnectionPointSide.South: {
                var offset = -this.getMinOffset();
                if (this.beginRect.y < originPoint.y)
                    offset -= originPoint.y - this.beginRect.y;
                return [originPoint.clone().offset(0, offset)];
            }
        }
    };
    ConnectorPointsOrthogonalNorthSideCalculator.prototype.getBeginOnSideOffsetPoints = function (targetSide, originPoint, targetPoint, originRect) {
        return [originPoint.clone().offset(0, -this.getScaleableOffsetY(originPoint, targetPoint, false))];
    };
    ConnectorPointsOrthogonalNorthSideCalculator.prototype.getEndOnSideOffsetPoints = function (targetSide, originPoint, targetPoint, originRect) {
        return [originPoint.clone().offset(0, -this.getScaleableOffsetY(originPoint, targetPoint, true))];
    };
    ConnectorPointsOrthogonalNorthSideCalculator.prototype.getBeginOffSideOffsetPoints = function (targetSide, originPoint, targetPoint, originRect) {
        switch (targetSide) {
            case DiagramItem_1.ConnectionPointSide.East:
                if (this.isBeginEndOverlappedX())
                    return this.getScaleableAsideOffsetPoints(originPoint, targetPoint, originRect, false, false);
                break;
            case DiagramItem_1.ConnectionPointSide.West:
                if (this.isBeginEndOverlappedX())
                    return this.getScaleableAsideOffsetPoints(originPoint, targetPoint, originRect, false, true);
                break;
            case DiagramItem_1.ConnectionPointSide.North:
                if (this.isBeginEndOverlappedX())
                    return this.getScaleableAsideOffsetPoints(originPoint, targetPoint, originRect, false);
                break;
            case DiagramItem_1.ConnectionPointSide.Undefined:
            case DiagramItem_1.ConnectionPointSide.South:
                return this.getScaleableAsideOffsetPoints(originPoint, targetPoint, originRect, false);
        }
        return [originPoint.clone().offset(0, -this.getScaleableOffsetY(originPoint, targetPoint, false))];
    };
    ConnectorPointsOrthogonalNorthSideCalculator.prototype.getEndOffSideOffsetPoints = function (targetSide, originPoint, targetPoint, originRect) {
        if (targetSide === DiagramItem_1.ConnectionPointSide.Undefined)
            return this.getScaleableAsideOffsetPoints(originPoint, targetPoint, originRect, true);
        else if (this.isBeginEndOverlappedX()) {
            var direction = this.beginRect.center.x > this.endRect.center.x;
            return this.getScaleableAsideOffsetPoints(originPoint, targetPoint, originRect, true, direction);
        }
        return [originPoint.clone().offset(0, -this.getScaleableOffsetY(originPoint, targetPoint, true))];
    };
    ConnectorPointsOrthogonalNorthSideCalculator.prototype.getAsideOffsetPoints = function (originPoint, targetPoint, originRect, offset, asideOffset, direction) {
        var points = [];
        if (originRect !== undefined) {
            if (direction === undefined)
                direction = targetPoint.x < originPoint.x;
            if (direction)
                points.push(originPoint.clone().offset(-(originPoint.x - originRect.x + asideOffset), -offset));
            else
                points.push(originPoint.clone().offset((originRect.right - originPoint.x + asideOffset), -offset));
        }
        points.push(originPoint.clone().offset(0, -offset));
        return points;
    };
    ConnectorPointsOrthogonalNorthSideCalculator.prototype.getScaleableAsideOffsetPoints = function (originPoint, targetPoint, originRect, isEnd, direction) {
        var offset = this.getScaleableOffsetY(originPoint, targetPoint, isEnd);
        var asideOffset = this.getScaleableOffsetX(originPoint, targetPoint, isEnd);
        return this.getAsideOffsetPoints(originPoint, targetPoint, originRect, offset, asideOffset, direction);
    };
    ConnectorPointsOrthogonalNorthSideCalculator.prototype.getScaleableOffsetX = function (originPoint, targetPoint, isEnd) {
        if (this.beginRect && this.endRect)
            if (!isEnd && !this.isBeginEndOverlappedX()) {
                var distance = void 0;
                if (targetPoint.x < originPoint.x)
                    distance = this.beginRect.x - this.endRect.right;
                else
                    distance = this.endRect.x - this.beginRect.right;
                if (distance < this.getMinOffset() * 2)
                    return distance / 2;
            }
        return this.getMinOffset();
    };
    ConnectorPointsOrthogonalNorthSideCalculator.prototype.getScaleableOffsetY = function (originPoint, targetPoint, isEnd) {
        if (this.beginRect && this.endRect) {
            var distance = isEnd ? originPoint.y - this.beginRect.bottom : originPoint.y - this.endRect.bottom;
            if (distance > 0 && distance < this.getMinOffset() * 2)
                return distance / 2;
        }
        return this.getMinOffset();
    };
    ConnectorPointsOrthogonalNorthSideCalculator.prototype.isOnSidePoint = function (originPoint, targetPoint) {
        return targetPoint.y < originPoint.y;
    };
    ConnectorPointsOrthogonalNorthSideCalculator.prototype.isDirectConnectionAllowed = function (targetSide, originPoint, targetPoint) {
        return targetSide === DiagramItem_1.ConnectionPointSide.South || targetSide === DiagramItem_1.ConnectionPointSide.Undefined;
    };
    ConnectorPointsOrthogonalNorthSideCalculator.prototype.getDirectConnectionPoints = function (originPoint, targetPoint) {
        var cy = targetPoint.y + (originPoint.y - targetPoint.y) / 2;
        return [
            new ConnectorRenderPoint_1.ConnectorRenderPoint(originPoint.x, cy),
            new ConnectorRenderPoint_1.ConnectorRenderPoint(targetPoint.x, cy)
        ];
    };
    return ConnectorPointsOrthogonalNorthSideCalculator;
}(ConnectorPointsOrthogonalSideCalculatorBase_1.ConnectorPointsOrthogonalSideCalculatorBase));
exports.ConnectorPointsOrthogonalNorthSideCalculator = ConnectorPointsOrthogonalNorthSideCalculator;


/***/ }),
/* 184 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.ConnectorPointsOrthogonalEastSideCalculator = void 0;
var DiagramItem_1 = __webpack_require__(9);
var ConnectorPointsOrthogonalSideCalculatorBase_1 = __webpack_require__(52);
var ConnectorRenderPoint_1 = __webpack_require__(29);
var ConnectorPointsOrthogonalEastSideCalculator = (function (_super) {
    __extends(ConnectorPointsOrthogonalEastSideCalculator, _super);
    function ConnectorPointsOrthogonalEastSideCalculator(parent) {
        return _super.call(this, parent) || this;
    }
    ConnectorPointsOrthogonalEastSideCalculator.prototype.getCorrectOriginPoint = function (originPoint, originRect) {
        if (originPoint.x < originRect.right)
            originPoint = originPoint.clone().offset(originRect.right - originPoint.x, 0);
        return originPoint;
    };
    ConnectorPointsOrthogonalEastSideCalculator.prototype.getSameShapeOffsetPoints = function (targetSide, originPoint, targetPoint, originRect) {
        switch (targetSide) {
            case DiagramItem_1.ConnectionPointSide.North:
            case DiagramItem_1.ConnectionPointSide.South:
            case DiagramItem_1.ConnectionPointSide.East:
                return [originPoint.clone().offset(this.getMinOffset(), 0)];
            case DiagramItem_1.ConnectionPointSide.West:
                return this.getAsideOffsetPoints(originPoint, targetPoint, originRect, this.getMinOffset(), this.getMinOffset());
        }
    };
    ConnectorPointsOrthogonalEastSideCalculator.prototype.getOverlappedPointsOffsetPoints = function (targetSide, originPoint, targetPoint, originRect) {
        switch (targetSide) {
            case DiagramItem_1.ConnectionPointSide.East:
                return [originPoint.clone().offset(this.getMinOffset(), 0)];
            case DiagramItem_1.ConnectionPointSide.West:
                return [originPoint.clone().offset(-this.getMinOffset(), 0)];
        }
        return [];
    };
    ConnectorPointsOrthogonalEastSideCalculator.prototype.getBeginOverlappedShapeOffsetPoints = function (targetSide, originPoint, targetPoint, originRect) {
        switch (targetSide) {
            case DiagramItem_1.ConnectionPointSide.North:
                if (originPoint.x < targetPoint.x)
                    if (originPoint.y < targetPoint.y)
                        return [];
                    else
                        return [originPoint.clone().offset(this.getMinOffset(), 0)];
                if (originPoint.x > this.endRect.right)
                    return this.getAsideOffsetPoints(originPoint, targetPoint, originRect, this.getMinOffset(), this.getMinOffset(), true);
                return [originPoint.clone().offset(this.getMinOffset(), 0)];
            case DiagramItem_1.ConnectionPointSide.South:
                if (originPoint.x < targetPoint.x)
                    if (originPoint.y > targetPoint.y)
                        return [];
                    else
                        return [originPoint.clone().offset(this.getMinOffset(), 0)];
                if (originPoint.x > this.endRect.right)
                    return this.getAsideOffsetPoints(originPoint, targetPoint, originRect, this.getMinOffset(), this.getMinOffset(), false);
                return [originPoint.clone().offset(this.getMinOffset(), 0)];
            case DiagramItem_1.ConnectionPointSide.East:
                return [originPoint.clone().offset(this.getMinOffset(), 0)];
            case DiagramItem_1.ConnectionPointSide.West:
                return this.getAsideOffsetPoints(originPoint, targetPoint, originRect, this.getMinOffset(), this.getMinOffset(), originPoint.y < targetPoint.y);
        }
    };
    ConnectorPointsOrthogonalEastSideCalculator.prototype.getEndOverlappedShapeOffsetPoints = function (targetSide, originPoint, targetPoint, originRect) {
        switch (targetSide) {
            case DiagramItem_1.ConnectionPointSide.East:
                return [originPoint.clone().offset(this.getMinOffset(), 0)];
            case DiagramItem_1.ConnectionPointSide.West: {
                var offset = this.getMinOffset();
                if (this.beginRect.right > originPoint.x)
                    offset += this.beginRect.right - originPoint.x;
                return [originPoint.clone().offset(offset, 0)];
            }
            case DiagramItem_1.ConnectionPointSide.North:
                if (targetPoint.x < originPoint.x)
                    return this.getAsideOffsetPoints(originPoint, targetPoint, originRect, this.getMinOffset(), this.getMinOffset(), true);
                if (originPoint.y > targetPoint.y)
                    return [originPoint.clone().offset(this.getMinOffset(), 0)];
                return [];
            case DiagramItem_1.ConnectionPointSide.South:
                if (targetPoint.x < originPoint.x)
                    return this.getAsideOffsetPoints(originPoint, targetPoint, originRect, this.getMinOffset(), this.getMinOffset(), false);
                if (originPoint.y < targetPoint.y)
                    return [originPoint.clone().offset(this.getMinOffset(), 0)];
                return [];
        }
    };
    ConnectorPointsOrthogonalEastSideCalculator.prototype.getBeginOnSideOffsetPoints = function (targetSide, originPoint, targetPoint, originRect) {
        return [originPoint.clone().offset(this.getScaleableOffsetX(originPoint, targetPoint, false), 0)];
    };
    ConnectorPointsOrthogonalEastSideCalculator.prototype.getEndOnSideOffsetPoints = function (targetSide, originPoint, targetPoint, originRect) {
        return [originPoint.clone().offset(this.getScaleableOffsetX(originPoint, targetPoint, true), 0)];
    };
    ConnectorPointsOrthogonalEastSideCalculator.prototype.getBeginOffSideOffsetPoints = function (targetSide, originPoint, targetPoint, originRect) {
        switch (targetSide) {
            case DiagramItem_1.ConnectionPointSide.South:
                if (this.isBeginEndOverlappedY())
                    return this.getScaleableAsideOffsetPoints(originPoint, targetPoint, originRect, false, false);
                break;
            case DiagramItem_1.ConnectionPointSide.North:
                if (this.isBeginEndOverlappedY())
                    return this.getScaleableAsideOffsetPoints(originPoint, targetPoint, originRect, false, true);
                break;
            case DiagramItem_1.ConnectionPointSide.East:
                if (this.isBeginEndOverlappedY())
                    return this.getScaleableAsideOffsetPoints(originPoint, targetPoint, originRect, false);
                break;
            case DiagramItem_1.ConnectionPointSide.Undefined:
            case DiagramItem_1.ConnectionPointSide.West:
                return this.getScaleableAsideOffsetPoints(originPoint, targetPoint, originRect, false);
        }
        return [originPoint.clone().offset(this.getScaleableOffsetX(originPoint, targetPoint, false), 0)];
    };
    ConnectorPointsOrthogonalEastSideCalculator.prototype.getEndOffSideOffsetPoints = function (targetSide, originPoint, targetPoint, originRect) {
        if (targetSide === DiagramItem_1.ConnectionPointSide.Undefined)
            return this.getScaleableAsideOffsetPoints(originPoint, targetPoint, originRect, true);
        else if (this.isBeginEndOverlappedY()) {
            var direction = this.beginRect.center.y > this.endRect.center.y;
            return this.getScaleableAsideOffsetPoints(originPoint, targetPoint, originRect, true, direction);
        }
        return [originPoint.clone().offset(this.getScaleableOffsetX(originPoint, targetPoint, true), 0)];
    };
    ConnectorPointsOrthogonalEastSideCalculator.prototype.getAsideOffsetPoints = function (originPoint, targetPoint, originRect, offset, asideOffset, direction) {
        var points = [];
        if (originRect !== undefined) {
            if (direction === undefined)
                direction = targetPoint.y < originPoint.y;
            if (direction)
                points.push(originPoint.clone().offset(offset, -(originPoint.y - originRect.y + asideOffset)));
            else
                points.push(originPoint.clone().offset(offset, (originRect.bottom - originPoint.y + asideOffset)));
        }
        points.push(originPoint.clone().offset(offset, 0));
        return points;
    };
    ConnectorPointsOrthogonalEastSideCalculator.prototype.getScaleableAsideOffsetPoints = function (originPoint, targetPoint, originRect, isEnd, direction) {
        var offset = this.getScaleableOffsetX(originPoint, targetPoint, isEnd);
        var asideOffset = this.getScaleableOffsetY(originPoint, targetPoint, isEnd);
        return this.getAsideOffsetPoints(originPoint, targetPoint, originRect, offset, asideOffset, direction);
    };
    ConnectorPointsOrthogonalEastSideCalculator.prototype.getScaleableOffsetX = function (originPoint, targetPoint, isEnd) {
        if (this.beginRect && this.endRect) {
            var distance = isEnd ? this.beginRect.x - originPoint.x : this.endRect.x - originPoint.x;
            if (distance > 0 && distance < this.getMinOffset() * 2)
                return distance / 2;
        }
        return this.getMinOffset();
    };
    ConnectorPointsOrthogonalEastSideCalculator.prototype.getScaleableOffsetY = function (originPoint, targetPoint, isEnd) {
        if (this.beginRect && this.endRect)
            if (!isEnd && !this.isBeginEndOverlappedY()) {
                var distance = void 0;
                if (targetPoint.y < originPoint.y)
                    distance = this.beginRect.y - this.endRect.bottom;
                else
                    distance = this.endRect.y - this.beginRect.bottom;
                if (distance < this.getMinOffset() * 2)
                    return distance / 2;
            }
        return this.getMinOffset();
    };
    ConnectorPointsOrthogonalEastSideCalculator.prototype.isOnSidePoint = function (originPoint, targetPoint) {
        return targetPoint.x > originPoint.x;
    };
    ConnectorPointsOrthogonalEastSideCalculator.prototype.isDirectConnectionAllowed = function (targetSide, originPoint, targetPoint) {
        return targetSide === DiagramItem_1.ConnectionPointSide.West || targetSide === DiagramItem_1.ConnectionPointSide.Undefined;
    };
    ConnectorPointsOrthogonalEastSideCalculator.prototype.getDirectConnectionPoints = function (originPoint, targetPoint) {
        var cx = originPoint.x + (targetPoint.x - originPoint.x) / 2;
        return [
            new ConnectorRenderPoint_1.ConnectorRenderPoint(cx, originPoint.y),
            new ConnectorRenderPoint_1.ConnectorRenderPoint(cx, targetPoint.y)
        ];
    };
    return ConnectorPointsOrthogonalEastSideCalculator;
}(ConnectorPointsOrthogonalSideCalculatorBase_1.ConnectorPointsOrthogonalSideCalculatorBase));
exports.ConnectorPointsOrthogonalEastSideCalculator = ConnectorPointsOrthogonalEastSideCalculator;


/***/ }),
/* 185 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.ConnectorPointsOrthogonalWestSideCalculator = void 0;
var DiagramItem_1 = __webpack_require__(9);
var ConnectorPointsOrthogonalSideCalculatorBase_1 = __webpack_require__(52);
var ConnectorRenderPoint_1 = __webpack_require__(29);
var ConnectorPointsOrthogonalWestSideCalculator = (function (_super) {
    __extends(ConnectorPointsOrthogonalWestSideCalculator, _super);
    function ConnectorPointsOrthogonalWestSideCalculator(parent) {
        return _super.call(this, parent) || this;
    }
    ConnectorPointsOrthogonalWestSideCalculator.prototype.getCorrectOriginPoint = function (originPoint, originRect) {
        if (originPoint.x > originRect.x)
            originPoint = originPoint.clone().offset(originRect.x - originPoint.x, 0);
        return originPoint;
    };
    ConnectorPointsOrthogonalWestSideCalculator.prototype.getSameShapeOffsetPoints = function (targetSide, originPoint, targetPoint, originRect) {
        switch (targetSide) {
            case DiagramItem_1.ConnectionPointSide.North:
            case DiagramItem_1.ConnectionPointSide.South:
            case DiagramItem_1.ConnectionPointSide.West:
                return [originPoint.clone().offset(-this.getMinOffset(), 0)];
            case DiagramItem_1.ConnectionPointSide.East:
                return this.getAsideOffsetPoints(originPoint, targetPoint, originRect, this.getMinOffset(), this.getMinOffset());
        }
    };
    ConnectorPointsOrthogonalWestSideCalculator.prototype.getOverlappedPointsOffsetPoints = function (targetSide, originPoint, targetPoint, originRect) {
        switch (targetSide) {
            case DiagramItem_1.ConnectionPointSide.East:
                return [originPoint.clone().offset(this.getMinOffset(), 0)];
            case DiagramItem_1.ConnectionPointSide.West:
                return [originPoint.clone().offset(-this.getMinOffset(), 0)];
        }
        return [];
    };
    ConnectorPointsOrthogonalWestSideCalculator.prototype.getBeginOverlappedShapeOffsetPoints = function (targetSide, originPoint, targetPoint, originRect) {
        switch (targetSide) {
            case DiagramItem_1.ConnectionPointSide.North:
                if (originPoint.x > targetPoint.x)
                    if (originPoint.y < targetPoint.y)
                        return [];
                    else
                        return [originPoint.clone().offset(-this.getMinOffset(), 0)];
                if (originPoint.x < this.endRect.x)
                    return this.getAsideOffsetPoints(originPoint, targetPoint, originRect, this.getMinOffset(), this.getMinOffset(), true);
                return [originPoint.clone().offset(-this.getMinOffset(), 0)];
            case DiagramItem_1.ConnectionPointSide.South:
                if (originPoint.x > targetPoint.x)
                    if (originPoint.y > targetPoint.y)
                        return [];
                    else
                        return [originPoint.clone().offset(-this.getMinOffset(), 0)];
                if (originPoint.x < this.endRect.x)
                    return this.getAsideOffsetPoints(originPoint, targetPoint, originRect, this.getMinOffset(), this.getMinOffset(), false);
                return [originPoint.clone().offset(-this.getMinOffset(), 0)];
            case DiagramItem_1.ConnectionPointSide.West:
                return [originPoint.clone().offset(-this.getMinOffset(), 0)];
            case DiagramItem_1.ConnectionPointSide.East:
                return this.getAsideOffsetPoints(originPoint, targetPoint, originRect, this.getMinOffset(), this.getMinOffset(), originPoint.y < targetPoint.y);
        }
    };
    ConnectorPointsOrthogonalWestSideCalculator.prototype.getEndOverlappedShapeOffsetPoints = function (targetSide, originPoint, targetPoint, originRect) {
        switch (targetSide) {
            case DiagramItem_1.ConnectionPointSide.East: {
                var offset = -this.getMinOffset();
                if (this.beginRect.x < originPoint.x)
                    offset -= originPoint.x - this.beginRect.x;
                return [originPoint.clone().offset(offset, 0)];
            }
            case DiagramItem_1.ConnectionPointSide.West:
                return [originPoint.clone().offset(-this.getMinOffset(), 0)];
            case DiagramItem_1.ConnectionPointSide.North:
                if (targetPoint.x > originPoint.x)
                    return this.getAsideOffsetPoints(originPoint, targetPoint, originRect, this.getMinOffset(), this.getMinOffset(), true);
                if (originPoint.y > targetPoint.y)
                    return [originPoint.clone().offset(-this.getMinOffset(), 0)];
                return [];
            case DiagramItem_1.ConnectionPointSide.South:
                if (targetPoint.x > originPoint.x)
                    return this.getAsideOffsetPoints(originPoint, targetPoint, originRect, this.getMinOffset(), this.getMinOffset(), false);
                if (originPoint.y < targetPoint.y)
                    return [originPoint.clone().offset(-this.getMinOffset(), 0)];
                return [];
        }
    };
    ConnectorPointsOrthogonalWestSideCalculator.prototype.getBeginOnSideOffsetPoints = function (targetSide, originPoint, targetPoint, originRect) {
        return [originPoint.clone().offset(-this.getScaleableOffsetX(originPoint, false), 0)];
    };
    ConnectorPointsOrthogonalWestSideCalculator.prototype.getEndOnSideOffsetPoints = function (targetSide, originPoint, targetPoint, originRect) {
        return [originPoint.clone().offset(-this.getScaleableOffsetX(originPoint, true), 0)];
    };
    ConnectorPointsOrthogonalWestSideCalculator.prototype.getBeginOffSideOffsetPoints = function (targetSide, originPoint, targetPoint, originRect) {
        switch (targetSide) {
            case DiagramItem_1.ConnectionPointSide.South:
                if (this.isBeginEndOverlappedY())
                    return this.getScaleableAsideOffsetPoints(originPoint, targetPoint, originRect, false, false);
                break;
            case DiagramItem_1.ConnectionPointSide.North:
                if (this.isBeginEndOverlappedY())
                    return this.getScaleableAsideOffsetPoints(originPoint, targetPoint, originRect, false, true);
                break;
            case DiagramItem_1.ConnectionPointSide.West:
                if (this.isBeginEndOverlappedY())
                    return this.getScaleableAsideOffsetPoints(originPoint, targetPoint, originRect, false);
                break;
            case DiagramItem_1.ConnectionPointSide.Undefined:
            case DiagramItem_1.ConnectionPointSide.East:
                return this.getScaleableAsideOffsetPoints(originPoint, targetPoint, originRect, false);
        }
        return [originPoint.clone().offset(-this.getScaleableOffsetX(originPoint, false), 0)];
    };
    ConnectorPointsOrthogonalWestSideCalculator.prototype.getEndOffSideOffsetPoints = function (targetSide, originPoint, targetPoint, originRect) {
        if (targetSide === DiagramItem_1.ConnectionPointSide.Undefined)
            return this.getScaleableAsideOffsetPoints(originPoint, targetPoint, originRect, true);
        else if (this.isBeginEndOverlappedY()) {
            var direction = this.beginRect.center.y > this.endRect.center.y;
            return this.getScaleableAsideOffsetPoints(originPoint, targetPoint, originRect, true, direction);
        }
        return [originPoint.clone().offset(-this.getScaleableOffsetX(originPoint, true), 0)];
    };
    ConnectorPointsOrthogonalWestSideCalculator.prototype.getAsideOffsetPoints = function (originPoint, targetPoint, originRect, offset, asideOffset, direction) {
        var points = [];
        if (originRect !== undefined) {
            if (direction === undefined)
                direction = targetPoint.y < originPoint.y;
            if (direction)
                points.push(originPoint.clone().offset(-offset, -(originPoint.y - originRect.y + asideOffset)));
            else
                points.push(originPoint.clone().offset(-offset, (originRect.bottom - originPoint.y + asideOffset)));
        }
        points.push(originPoint.clone().offset(-offset, 0));
        return points;
    };
    ConnectorPointsOrthogonalWestSideCalculator.prototype.getScaleableAsideOffsetPoints = function (originPoint, targetPoint, originRect, isEnd, direction) {
        var offset = this.getScaleableOffsetX(originPoint, isEnd);
        var asideOffset = this.getScaleableOffsetY(originPoint, targetPoint, isEnd);
        return this.getAsideOffsetPoints(originPoint, targetPoint, originRect, offset, asideOffset, direction);
    };
    ConnectorPointsOrthogonalWestSideCalculator.prototype.getScaleableOffsetX = function (originPoint, isEnd) {
        if (this.beginRect && this.endRect) {
            var distance = isEnd ? originPoint.x - this.beginRect.right : originPoint.x - this.endRect.right;
            if (distance > 0 && distance < this.getMinOffset() * 2)
                return distance / 2;
        }
        return this.getMinOffset();
    };
    ConnectorPointsOrthogonalWestSideCalculator.prototype.getScaleableOffsetY = function (originPoint, targetPoint, isEnd) {
        if (this.beginRect && this.endRect)
            if (!isEnd && !this.isBeginEndOverlappedY()) {
                var distance = void 0;
                if (targetPoint.y < originPoint.y)
                    distance = this.beginRect.y - this.endRect.bottom;
                else
                    distance = this.endRect.y - this.beginRect.bottom;
                if (distance < this.getMinOffset() * 2)
                    return distance / 2;
            }
        return this.getMinOffset();
    };
    ConnectorPointsOrthogonalWestSideCalculator.prototype.isOnSidePoint = function (originPoint, targetPoint) {
        return targetPoint.x < originPoint.x;
    };
    ConnectorPointsOrthogonalWestSideCalculator.prototype.isDirectConnectionAllowed = function (targetSide, originPoint, targetPoint) {
        return targetSide === DiagramItem_1.ConnectionPointSide.East || targetSide === DiagramItem_1.ConnectionPointSide.Undefined;
    };
    ConnectorPointsOrthogonalWestSideCalculator.prototype.getDirectConnectionPoints = function (originPoint, targetPoint) {
        var cx = targetPoint.x + (originPoint.x - targetPoint.x) / 2;
        return [
            new ConnectorRenderPoint_1.ConnectorRenderPoint(cx, originPoint.y),
            new ConnectorRenderPoint_1.ConnectorRenderPoint(cx, targetPoint.y)
        ];
    };
    return ConnectorPointsOrthogonalWestSideCalculator;
}(ConnectorPointsOrthogonalSideCalculatorBase_1.ConnectorPointsOrthogonalSideCalculatorBase));
exports.ConnectorPointsOrthogonalWestSideCalculator = ConnectorPointsOrthogonalWestSideCalculator;


/***/ }),
/* 186 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.ConnectorLineEndingFilledTriangleStrategy = exports.ConnectorLineEndingOutlinedTriangleStrategy = exports.ConnectorLineEndingArrowStrategy = exports.ConnectorLineEndingNoneStrategy = exports.ConnectorLineEndingStrategy = void 0;
var Utils_1 = __webpack_require__(3);
var PathPrimitive_1 = __webpack_require__(5);
var ConnectorLineEndingStrategy = (function () {
    function ConnectorLineEndingStrategy(style) {
        this.style = style;
    }
    ConnectorLineEndingStrategy.prototype.hasCommands = function () {
        return true;
    };
    ConnectorLineEndingStrategy.prototype.needCreateSeparatePrimitive = function () {
        return false;
    };
    ConnectorLineEndingStrategy.prototype.createPrimitive = function () {
        return new PathPrimitive_1.PathPrimitive([], this.getStyle(), this.getCssClass());
    };
    ConnectorLineEndingStrategy.prototype.createCommands = function (point, directionPoint) {
        return [];
    };
    ConnectorLineEndingStrategy.prototype.getStyle = function () {
        var style = this.style.clone();
        style.resetStrokeDashArray();
        return style;
    };
    ConnectorLineEndingStrategy.prototype.getCssClass = function () {
        return undefined;
    };
    return ConnectorLineEndingStrategy;
}());
exports.ConnectorLineEndingStrategy = ConnectorLineEndingStrategy;
var ConnectorLineEndingNoneStrategy = (function (_super) {
    __extends(ConnectorLineEndingNoneStrategy, _super);
    function ConnectorLineEndingNoneStrategy() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    ConnectorLineEndingNoneStrategy.prototype.hasCommands = function () {
        return false;
    };
    return ConnectorLineEndingNoneStrategy;
}(ConnectorLineEndingStrategy));
exports.ConnectorLineEndingNoneStrategy = ConnectorLineEndingNoneStrategy;
var ConnectorLineEndingArrowStrategy = (function (_super) {
    __extends(ConnectorLineEndingArrowStrategy, _super);
    function ConnectorLineEndingArrowStrategy() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    Object.defineProperty(ConnectorLineEndingArrowStrategy.prototype, "arrowHeight", {
        get: function () { return this.style.strokeWidth * 6; },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(ConnectorLineEndingArrowStrategy.prototype, "arrowWidth", {
        get: function () { return this.style.strokeWidth * 2; },
        enumerable: false,
        configurable: true
    });
    ConnectorLineEndingArrowStrategy.prototype.needCreateSeparatePrimitive = function () {
        return !this.style.isDefaultStrokeDashArray();
    };
    ConnectorLineEndingArrowStrategy.prototype.createCommands = function (point, directionPoint) {
        var arrowPoints = this.getArrowPoints(point, directionPoint);
        var commands = [
            new PathPrimitive_1.PathPrimitiveMoveToCommand(arrowPoints.point1.x, arrowPoints.point1.y),
            new PathPrimitive_1.PathPrimitiveLineToCommand(point.x, point.y),
            new PathPrimitive_1.PathPrimitiveLineToCommand(arrowPoints.point2.x, arrowPoints.point2.y)
        ];
        if (!this.style.isDefaultStrokeDashArray())
            commands = commands.concat([
                new PathPrimitive_1.PathPrimitiveMoveToCommand(point.x, point.y),
                new PathPrimitive_1.PathPrimitiveLineToCommand(arrowPoints.point3.x, arrowPoints.point3.y)
            ]);
        return commands;
    };
    ConnectorLineEndingArrowStrategy.prototype.getArrowPoints = function (point, directionPoint) {
        var arrowHeight = this.arrowHeight;
        if (point.x === directionPoint.x) {
            var distance = Math.abs(point.y - directionPoint.y);
            if (distance < arrowHeight)
                arrowHeight = distance;
        }
        if (point.y === directionPoint.y) {
            var distance = Math.abs(point.x - directionPoint.x);
            if (distance < arrowHeight)
                arrowHeight = distance;
        }
        return Utils_1.GeometryUtils.getArrowPoints(point, directionPoint, arrowHeight, this.arrowWidth);
    };
    return ConnectorLineEndingArrowStrategy;
}(ConnectorLineEndingStrategy));
exports.ConnectorLineEndingArrowStrategy = ConnectorLineEndingArrowStrategy;
var ConnectorLineEndingOutlinedTriangleStrategy = (function (_super) {
    __extends(ConnectorLineEndingOutlinedTriangleStrategy, _super);
    function ConnectorLineEndingOutlinedTriangleStrategy() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    ConnectorLineEndingOutlinedTriangleStrategy.prototype.needCreateSeparatePrimitive = function () {
        return true;
    };
    ConnectorLineEndingOutlinedTriangleStrategy.prototype.createCommands = function (point, directionPoint) {
        var arrowPoints = this.getArrowPoints(point, directionPoint);
        return [
            new PathPrimitive_1.PathPrimitiveMoveToCommand(arrowPoints.point1.x, arrowPoints.point1.y),
            new PathPrimitive_1.PathPrimitiveLineToCommand(point.x, point.y),
            new PathPrimitive_1.PathPrimitiveLineToCommand(arrowPoints.point2.x, arrowPoints.point2.y),
            new PathPrimitive_1.PathPrimitiveClosePathCommand()
        ];
    };
    ConnectorLineEndingOutlinedTriangleStrategy.prototype.getCssClass = function () {
        return "outlined-line-ending";
    };
    return ConnectorLineEndingOutlinedTriangleStrategy;
}(ConnectorLineEndingArrowStrategy));
exports.ConnectorLineEndingOutlinedTriangleStrategy = ConnectorLineEndingOutlinedTriangleStrategy;
var ConnectorLineEndingFilledTriangleStrategy = (function (_super) {
    __extends(ConnectorLineEndingFilledTriangleStrategy, _super);
    function ConnectorLineEndingFilledTriangleStrategy() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    ConnectorLineEndingFilledTriangleStrategy.prototype.getStyle = function () {
        var style = _super.prototype.getStyle.call(this);
        style["fill"] = style["stroke"];
        return style;
    };
    ConnectorLineEndingFilledTriangleStrategy.prototype.getCssClass = function () {
        return "filled-line-ending";
    };
    return ConnectorLineEndingFilledTriangleStrategy;
}(ConnectorLineEndingOutlinedTriangleStrategy));
exports.ConnectorLineEndingFilledTriangleStrategy = ConnectorLineEndingFilledTriangleStrategy;


/***/ }),
/* 187 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.ConnectorTexts = exports.ConnectorText = void 0;
var ConnectorText = (function () {
    function ConnectorText(position, value) {
        this.position = position;
        this.value = value;
    }
    return ConnectorText;
}());
exports.ConnectorText = ConnectorText;
var ConnectorTexts = (function () {
    function ConnectorTexts() {
        this.items = {};
    }
    ConnectorTexts.prototype.get = function (position) {
        return this.items[position];
    };
    ConnectorTexts.prototype.set = function (position, text) {
        this.items[position] = text;
    };
    ConnectorTexts.prototype.remove = function (position) {
        delete this.items[position];
    };
    ConnectorTexts.prototype.map = function (callback) {
        var list = [];
        this.forEach(function (t) { return list.push(callback(t)); });
        return list;
    };
    ConnectorTexts.prototype.forEach = function (callback) {
        for (var key in this.items)
            if (Object.prototype.hasOwnProperty.call(this.items, key))
                callback(this.items[key]);
    };
    ConnectorTexts.prototype.count = function () {
        return Object.keys(this.items).length;
    };
    ConnectorTexts.prototype.clone = function () {
        var result = new ConnectorTexts();
        this.forEach(function (t) { result.set(t.position, new ConnectorText(t.position, t.value)); });
        return result;
    };
    ConnectorTexts.prototype.toObject = function () {
        var result = {};
        var modified = false;
        this.forEach(function (t) {
            result[t.position] = t.value;
            modified = true;
        });
        return modified ? result : null;
    };
    ConnectorTexts.prototype.fromObject = function (obj) {
        for (var key in obj)
            if (Object.prototype.hasOwnProperty.call(obj, key)) {
                var position = parseFloat(key);
                if (!isNaN(position) && typeof obj[key] === "string")
                    this.set(position, new ConnectorText(position, obj[key]));
            }
    };
    return ConnectorTexts;
}());
exports.ConnectorTexts = ConnectorTexts;


/***/ }),
/* 188 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.AddConnectorPointHistoryItem = void 0;
var HistoryItem_1 = __webpack_require__(8);
var AddConnectorPointHistoryItem = (function (_super) {
    __extends(AddConnectorPointHistoryItem, _super);
    function AddConnectorPointHistoryItem(connectorKey, pointIndex, point) {
        var _this = _super.call(this) || this;
        _this.connectorKey = connectorKey;
        _this.pointIndex = pointIndex;
        _this.point = point;
        return _this;
    }
    AddConnectorPointHistoryItem.prototype.redo = function (manipulator) {
        var _this = this;
        var connector = manipulator.model.findConnector(this.connectorKey);
        this.renderContext = connector.createRenderPointsContext();
        manipulator.addDeleteConnectorPoint(connector, function (connector) {
            connector.addPoint(_this.pointIndex, _this.point);
            connector.onAddPoint(_this.pointIndex, _this.point);
        });
    };
    AddConnectorPointHistoryItem.prototype.undo = function (manipulator) {
        var _this = this;
        var connector = manipulator.model.findConnector(this.connectorKey);
        manipulator.addDeleteConnectorPoint(connector, function (connector) {
            connector.deletePoint(_this.pointIndex);
            connector.replaceRenderPoints(_this.renderContext);
        });
    };
    return AddConnectorPointHistoryItem;
}(HistoryItem_1.HistoryItem));
exports.AddConnectorPointHistoryItem = AddConnectorPointHistoryItem;


/***/ }),
/* 189 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.InsertToContainerHistoryItem = void 0;
var HistoryItem_1 = __webpack_require__(8);
var InsertToContainerHistoryItem = (function (_super) {
    __extends(InsertToContainerHistoryItem, _super);
    function InsertToContainerHistoryItem(item, container) {
        var _this = _super.call(this) || this;
        _this.containerKey = container.key;
        _this.itemKey = item.key;
        return _this;
    }
    InsertToContainerHistoryItem.prototype.redo = function (manipulator) {
        var item = manipulator.model.findItem(this.itemKey);
        var container = manipulator.model.findShape(this.containerKey);
        manipulator.insertToContainer(item, container);
    };
    InsertToContainerHistoryItem.prototype.undo = function (manipulator) {
        var item = manipulator.model.findItem(this.itemKey);
        manipulator.removeFromContainer(item);
    };
    return InsertToContainerHistoryItem;
}(HistoryItem_1.HistoryItem));
exports.InsertToContainerHistoryItem = InsertToContainerHistoryItem;


/***/ }),
/* 190 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.MoveConnectorRightAnglePointsHistoryItem = exports.MoveConnectorPointHistoryItem = void 0;
var HistoryItem_1 = __webpack_require__(8);
var MoveConnectorPointHistoryItem = (function (_super) {
    __extends(MoveConnectorPointHistoryItem, _super);
    function MoveConnectorPointHistoryItem(connectorKey, pointIndex, newPoint) {
        var _this = _super.call(this) || this;
        _this.connectorKey = connectorKey;
        _this.pointIndex = pointIndex;
        _this.newPoint = newPoint;
        return _this;
    }
    MoveConnectorPointHistoryItem.prototype.redo = function (manipulator) {
        var _this = this;
        var connector = manipulator.model.findConnector(this.connectorKey);
        this.oldPoint = connector.points[this.pointIndex].clone();
        this.renderContext = connector.createRenderPointsContext();
        manipulator.moveConnectorPoint(connector, this.pointIndex, function (connector) {
            connector.movePoint(_this.pointIndex, _this.newPoint);
            connector.onMovePoint(_this.pointIndex, _this.newPoint);
        });
    };
    MoveConnectorPointHistoryItem.prototype.undo = function (manipulator) {
        var _this = this;
        var connector = manipulator.model.findConnector(this.connectorKey);
        manipulator.moveConnectorPoint(connector, this.pointIndex, function (connector) {
            connector.movePoint(_this.pointIndex, _this.oldPoint);
            connector.replaceRenderPoints(_this.renderContext);
        });
    };
    return MoveConnectorPointHistoryItem;
}(HistoryItem_1.HistoryItem));
exports.MoveConnectorPointHistoryItem = MoveConnectorPointHistoryItem;
var MoveConnectorRightAnglePointsHistoryItem = (function (_super) {
    __extends(MoveConnectorRightAnglePointsHistoryItem, _super);
    function MoveConnectorRightAnglePointsHistoryItem(connectorKey, beginPointIndex, newBeginPoint, lastPointIndex, newLastPoint) {
        var _this = _super.call(this) || this;
        _this.connectorKey = connectorKey;
        _this.beginPointIndex = beginPointIndex;
        _this.newBeginPoint = newBeginPoint;
        _this.lastPointIndex = lastPointIndex;
        _this.newLastPoint = newLastPoint;
        return _this;
    }
    MoveConnectorRightAnglePointsHistoryItem.prototype.redo = function (manipulator) {
        var _this = this;
        var connector = manipulator.model.findConnector(this.connectorKey);
        this.oldBeginPoint = connector.points[this.beginPointIndex].clone();
        this.oldLastPoint = connector.points[this.lastPointIndex].clone();
        this.renderContext = connector.createRenderPointsContext();
        manipulator.changeConnectorPoints(connector, function (connector) {
            connector.movePoint(_this.beginPointIndex, _this.newBeginPoint);
            connector.movePoint(_this.lastPointIndex, _this.newLastPoint);
            connector.onMovePoints(_this.beginPointIndex, _this.newBeginPoint, _this.lastPointIndex, _this.newLastPoint);
        });
    };
    MoveConnectorRightAnglePointsHistoryItem.prototype.undo = function (manipulator) {
        var _this = this;
        var connector = manipulator.model.findConnector(this.connectorKey);
        manipulator.changeConnectorPoints(connector, function (connector) {
            connector.movePoint(_this.beginPointIndex, _this.oldBeginPoint);
            connector.movePoint(_this.lastPointIndex, _this.oldLastPoint);
            connector.replaceRenderPoints(_this.renderContext);
        });
    };
    return MoveConnectorRightAnglePointsHistoryItem;
}(HistoryItem_1.HistoryItem));
exports.MoveConnectorRightAnglePointsHistoryItem = MoveConnectorRightAnglePointsHistoryItem;


/***/ }),
/* 191 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.MoveShapeHistoryItem = void 0;
var HistoryItem_1 = __webpack_require__(8);
var MoveShapeHistoryItem = (function (_super) {
    __extends(MoveShapeHistoryItem, _super);
    function MoveShapeHistoryItem(shapeKey, position) {
        var _this = _super.call(this) || this;
        _this.shapeKey = shapeKey;
        _this.position = position;
        return _this;
    }
    MoveShapeHistoryItem.prototype.redo = function (manipulator) {
        var shape = manipulator.model.findShape(this.shapeKey);
        this.oldPosition = shape.position.clone();
        manipulator.moveShape(shape, this.position);
    };
    MoveShapeHistoryItem.prototype.undo = function (manipulator) {
        var shape = manipulator.model.findShape(this.shapeKey);
        manipulator.moveShape(shape, this.oldPosition);
    };
    return MoveShapeHistoryItem;
}(HistoryItem_1.HistoryItem));
exports.MoveShapeHistoryItem = MoveShapeHistoryItem;


/***/ }),
/* 192 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.RemoveFromContainerHistoryItem = void 0;
var HistoryItem_1 = __webpack_require__(8);
var RemoveFromContainerHistoryItem = (function (_super) {
    __extends(RemoveFromContainerHistoryItem, _super);
    function RemoveFromContainerHistoryItem(item) {
        var _this = _super.call(this) || this;
        _this.itemKey = item.key;
        return _this;
    }
    RemoveFromContainerHistoryItem.prototype.redo = function (manipulator) {
        var item = manipulator.model.findItem(this.itemKey);
        this.containerKey = item.container && item.container.key;
        manipulator.removeFromContainer(item);
    };
    RemoveFromContainerHistoryItem.prototype.undo = function (manipulator) {
        var container = manipulator.model.findContainer(this.containerKey);
        var item = manipulator.model.findItem(this.itemKey);
        manipulator.insertToContainer(item, container);
    };
    return RemoveFromContainerHistoryItem;
}(HistoryItem_1.HistoryItem));
exports.RemoveFromContainerHistoryItem = RemoveFromContainerHistoryItem;


/***/ }),
/* 193 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.ModelResizeHistoryItem = void 0;
var HistoryItem_1 = __webpack_require__(8);
var offsets_1 = __webpack_require__(87);
var size_1 = __webpack_require__(2);
var ModelResizeHistoryItem = (function (_super) {
    __extends(ModelResizeHistoryItem, _super);
    function ModelResizeHistoryItem(offset) {
        var _this = _super.call(this) || this;
        _this.offset = offset;
        return _this;
    }
    ModelResizeHistoryItem.prototype.redo = function (manipulator) {
        this.oldSize = manipulator.model.size.clone();
        this.backOffset = new offsets_1.Offsets(-this.offset.left, -this.offset.right, -this.offset.top, -this.offset.bottom);
        var newWidth = Math.max(this.oldSize.width + this.offset.left + this.offset.right, manipulator.model.pageWidth);
        var newHeight = Math.max(this.oldSize.height + this.offset.top + this.offset.bottom, manipulator.model.pageHeight);
        manipulator.changeModelSize(new size_1.Size(newWidth, newHeight), this.offset);
    };
    ModelResizeHistoryItem.prototype.undo = function (manipulator) {
        manipulator.changeModelSize(this.oldSize, this.backOffset);
    };
    return ModelResizeHistoryItem;
}(HistoryItem_1.HistoryItem));
exports.ModelResizeHistoryItem = ModelResizeHistoryItem;


/***/ }),
/* 194 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.UpdatePositionsOnPageResizeHistoryItem = void 0;
var Connector_1 = __webpack_require__(6);
var Shape_1 = __webpack_require__(14);
var HistoryItem_1 = __webpack_require__(8);
var UpdatePositionsOnPageResizeHistoryItem = (function (_super) {
    __extends(UpdatePositionsOnPageResizeHistoryItem, _super);
    function UpdatePositionsOnPageResizeHistoryItem(offset) {
        var _this = _super.call(this) || this;
        _this.offset = offset;
        return _this;
    }
    UpdatePositionsOnPageResizeHistoryItem.prototype.redo = function (manipulator) {
        var _this = this;
        manipulator.model.iterateItems(function (item) {
            if (item instanceof Shape_1.Shape)
                manipulator.moveShape(item, _this.applyOffset(item.position, _this.offset.x, _this.offset.y));
            if (item instanceof Connector_1.Connector)
                manipulator.changeConnectorPoints(item, function (i) { return i.updatePointsOnPageResize(_this.offset.x, _this.offset.y); });
        });
    };
    UpdatePositionsOnPageResizeHistoryItem.prototype.undo = function (manipulator) {
        var _this = this;
        manipulator.model.iterateItems(function (item) {
            if (item instanceof Shape_1.Shape)
                manipulator.moveShape(item, _this.applyOffset(item.position, -_this.offset.x, -_this.offset.y));
            if (item instanceof Connector_1.Connector)
                manipulator.changeConnectorPoints(item, function (i) { return i.updatePointsOnPageResize(-_this.offset.x, -_this.offset.y); });
        });
    };
    UpdatePositionsOnPageResizeHistoryItem.prototype.applyOffset = function (point, offsetX, offsetY) {
        return point.clone().offset(offsetX, offsetY);
    };
    return UpdatePositionsOnPageResizeHistoryItem;
}(HistoryItem_1.HistoryItem));
exports.UpdatePositionsOnPageResizeHistoryItem = UpdatePositionsOnPageResizeHistoryItem;


/***/ }),
/* 195 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.GraphInfo = void 0;
var LayoutUtils_1 = __webpack_require__(196);
var GraphInfo = (function () {
    function GraphInfo(container, sourceGraph) {
        this.container = container;
        this.sourceGraph = sourceGraph;
    }
    Object.defineProperty(GraphInfo.prototype, "graph", {
        get: function () {
            return this._graph || (this._graph = this.getNodeInfoGraph());
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(GraphInfo.prototype, "level", {
        get: function () {
            return this._level !== undefined ? this._level : (this._level = this.getLevel());
        },
        enumerable: false,
        configurable: true
    });
    GraphInfo.prototype.getNodeInfoGraph = function () {
        return this.sourceGraph.cast(LayoutUtils_1.LayoutUtils.shapeToLayout);
    };
    GraphInfo.prototype.getLevel = function () {
        var level = 0;
        if (this.container)
            level = this.getContainerLevel(this.container);
        return level;
    };
    GraphInfo.prototype.getContainerLevel = function (container) {
        var level = 1;
        var parentContainer = container.container;
        if (parentContainer)
            level += this.getContainerLevel(parentContainer);
        return level;
    };
    return GraphInfo;
}());
exports.GraphInfo = GraphInfo;


/***/ }),
/* 196 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.LayoutUtils = void 0;
var NodeLayout_1 = __webpack_require__(71);
var LayoutUtils = (function () {
    function LayoutUtils() {
    }
    LayoutUtils.shapeToLayout = function (shape) {
        var margin = new NodeLayout_1.Margin(0);
        var shapeRect = shape.rectangle;
        shape.attachedConnectors.filter(function (c) { return !c.beginItem || !c.endItem; }).forEach(function (c) {
            var connRect = c.rectangle;
            margin.left = Math.max(margin.left, shapeRect.x - connRect.x);
            margin.right = Math.max(margin.right, connRect.right - shapeRect.right);
            margin.top = Math.max(margin.top, shapeRect.y - connRect.y);
            margin.bottom = Math.max(margin.bottom, connRect.bottom - shapeRect.bottom);
        });
        var layout = new NodeLayout_1.NodeInfo(shape.key, margin, shape.size.clone());
        layout.connectionPoints = shape.description.getConnectionPoints();
        return layout;
    };
    return LayoutUtils;
}());
exports.LayoutUtils = LayoutUtils;


/***/ }),
/* 197 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.CommandBase = void 0;
var CommandBase = (function () {
    function CommandBase(control) {
        this.control = control;
    }
    CommandBase.prototype.execute = function (parameter) {
        if (this.isPermissionsRequired)
            this.permissionsProvider.lockPermissions();
        var state = this.getState();
        if (this.isPermissionsRequired)
            this.permissionsProvider.unlockPermissions();
        if (!state.enabled)
            return false;
        this.control.beginUpdate();
        var executed = false;
        if (this.isPermissionsRequired)
            executed = this.executeWithPermissions(state, parameter);
        else
            executed = this.executeCore(state, parameter);
        this.control.endUpdate();
        if (executed)
            this.updateControlState();
        return executed;
    };
    CommandBase.prototype.executeWithPermissions = function (state, parameter) {
        var executed = false;
        this.permissionsProvider.beginStorePermissions();
        this.control.history.beginTransaction();
        executed = this.executeCore(state, parameter);
        if (!this.permissionsProvider.isStoredPermissionsGranted()) {
            this.permissionsProvider.lockPermissions();
            this.control.history.undoTransaction();
            this.permissionsProvider.unlockPermissions();
            executed = false;
        }
        this.control.history.endTransaction();
        this.permissionsProvider.endStorePermissions();
        return executed;
    };
    CommandBase.prototype.updateControlState = function () {
        if (!this.lockInputPositionUpdating())
            this.control.selection.inputPosition.reset();
        if (!this.lockUIUpdating())
            this.control.barManager.updateItemsState();
    };
    Object.defineProperty(CommandBase.prototype, "permissionsProvider", {
        get: function () { return this.control && this.control.permissionsProvider; },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(CommandBase.prototype, "isPermissionsRequired", {
        get: function () { return false; },
        enumerable: false,
        configurable: true
    });
    CommandBase.prototype.lockUIUpdating = function () {
        return false;
    };
    CommandBase.prototype.lockInputPositionUpdating = function () {
        return false;
    };
    return CommandBase;
}());
exports.CommandBase = CommandBase;


/***/ }),
/* 198 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.SimpleCommandState = void 0;
var SimpleCommandState = (function () {
    function SimpleCommandState(enabled, value, defaultValue, items, visible) {
        this.visible = true;
        this.denyUpdateValue = false;
        this.enabled = enabled;
        this.value = value;
        this.items = items;
        this.visible = visible;
        this.defaultValue = defaultValue;
    }
    return SimpleCommandState;
}());
exports.SimpleCommandState = SimpleCommandState;


/***/ }),
/* 199 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.UndoCommand = void 0;
var SimpleCommandBase_1 = __webpack_require__(10);
var UndoCommand = (function (_super) {
    __extends(UndoCommand, _super);
    function UndoCommand() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    UndoCommand.prototype.executeCore = function (state) {
        this.control.beginUpdateCanvas();
        this.permissionsProvider.lockPermissions();
        this.control.history.undo();
        this.permissionsProvider.unlockPermissions();
        this.control.endUpdateCanvas();
        return true;
    };
    UndoCommand.prototype.isEnabled = function () {
        return _super.prototype.isEnabled.call(this) && this.control.history.canUndo();
    };
    return UndoCommand;
}(SimpleCommandBase_1.SimpleCommandBase));
exports.UndoCommand = UndoCommand;


/***/ }),
/* 200 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.RedoCommand = void 0;
var SimpleCommandBase_1 = __webpack_require__(10);
var RedoCommand = (function (_super) {
    __extends(RedoCommand, _super);
    function RedoCommand() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    RedoCommand.prototype.executeCore = function (state) {
        this.control.beginUpdateCanvas();
        this.permissionsProvider.lockPermissions();
        this.control.history.redo();
        this.permissionsProvider.unlockPermissions();
        this.control.endUpdateCanvas();
        return true;
    };
    RedoCommand.prototype.isEnabled = function () {
        return _super.prototype.isEnabled.call(this) && this.control.history.canRedo();
    };
    return RedoCommand;
}(SimpleCommandBase_1.SimpleCommandBase));
exports.RedoCommand = RedoCommand;


/***/ }),
/* 201 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.ImportCommand = void 0;
var Importer_1 = __webpack_require__(119);
var ExportImportCommandBase_1 = __webpack_require__(57);
var ImportCommand = (function (_super) {
    __extends(ImportCommand, _super);
    function ImportCommand() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    ImportCommand.prototype.executeCore = function (state, parameter) {
        this.permissionsProvider.lockPermissions();
        var data = parameter["data"] ? parameter["data"] : parameter;
        var importer = new Importer_1.Importer(this.control.shapeDescriptionManager, data);
        if (parameter["keepExistingItems"] === true) {
            importer.importItemsData(this.control.model);
            this.control.importItemsData();
        }
        else {
            var model = importer.import();
            this.control.importModel(model);
        }
        this.permissionsProvider.unlockPermissions();
        return true;
    };
    return ImportCommand;
}(ExportImportCommandBase_1.ExportImportCommandBase));
exports.ImportCommand = ImportCommand;


/***/ }),
/* 202 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.ProcessShapeDescription = void 0;
var RectangleShapeDescription_1 = __webpack_require__(19);
var ShapeTypes_1 = __webpack_require__(1);
var ProcessShapeDescription = (function (_super) {
    __extends(ProcessShapeDescription, _super);
    function ProcessShapeDescription() {
        return _super.call(this, undefined, true) || this;
    }
    Object.defineProperty(ProcessShapeDescription.prototype, "key", {
        get: function () { return ShapeTypes_1.ShapeTypes.Process; },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(ProcessShapeDescription.prototype, "keepRatioOnAutoSize", {
        get: function () { return false; },
        enumerable: false,
        configurable: true
    });
    return ProcessShapeDescription;
}(RectangleShapeDescription_1.RectangleShapeDescription));
exports.ProcessShapeDescription = ProcessShapeDescription;


/***/ }),
/* 203 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.DecisionShapeDescription = void 0;
var DiamondShapeDescription_1 = __webpack_require__(120);
var ShapeTypes_1 = __webpack_require__(1);
var size_1 = __webpack_require__(2);
var ShapeDescription_1 = __webpack_require__(7);
var DecisionShapeDescription = (function (_super) {
    __extends(DecisionShapeDescription, _super);
    function DecisionShapeDescription() {
        return _super.call(this, new size_1.Size(ShapeDescription_1.ShapeDefaultDimension, ShapeDescription_1.ShapeDefaultDimension * 0.75), true) || this;
    }
    Object.defineProperty(DecisionShapeDescription.prototype, "key", {
        get: function () { return ShapeTypes_1.ShapeTypes.Decision; },
        enumerable: false,
        configurable: true
    });
    return DecisionShapeDescription;
}(DiamondShapeDescription_1.DiamondShapeDescription));
exports.DecisionShapeDescription = DecisionShapeDescription;


/***/ }),
/* 204 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.ManualInputShapeDescription = void 0;
var RectangleShapeDescription_1 = __webpack_require__(19);
var ShapeTypes_1 = __webpack_require__(1);
var PathPrimitive_1 = __webpack_require__(5);
var DiagramItem_1 = __webpack_require__(9);
var ShapeDescription_1 = __webpack_require__(7);
var ManualInputShapeDescription = (function (_super) {
    __extends(ManualInputShapeDescription, _super);
    function ManualInputShapeDescription() {
        return _super.call(this, undefined, true) || this;
    }
    Object.defineProperty(ManualInputShapeDescription.prototype, "key", {
        get: function () { return ShapeTypes_1.ShapeTypes.ManualInput; },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(ManualInputShapeDescription.prototype, "keepRatioOnAutoSize", {
        get: function () { return false; },
        enumerable: false,
        configurable: true
    });
    ManualInputShapeDescription.prototype.createShapePrimitives = function (shape) {
        var _a = shape.rectangle, left = _a.x, top = _a.y, right = _a.right, bottom = _a.bottom, height = _a.height;
        var y1 = top + height * ManualInputShapeDescription.slopeHeightRatio;
        return [
            new PathPrimitive_1.PathPrimitive([
                new PathPrimitive_1.PathPrimitiveMoveToCommand(left, y1),
                new PathPrimitive_1.PathPrimitiveLineToCommand(right, top),
                new PathPrimitive_1.PathPrimitiveLineToCommand(right, bottom),
                new PathPrimitive_1.PathPrimitiveLineToCommand(left, bottom),
                new PathPrimitive_1.PathPrimitiveClosePathCommand()
            ], shape.style)
        ];
    };
    ManualInputShapeDescription.prototype.processConnectionPoint = function (shape, point) {
        var side = shape.getConnectionPointSide(point);
        if (side === DiagramItem_1.ConnectionPointSide.North)
            point.y += ManualInputShapeDescription.slopeHeightRatio / 2 * shape.size.height;
    };
    ManualInputShapeDescription.prototype.getTextRectangle = function (shape) {
        var yOffset = shape.size.height * ManualInputShapeDescription.slopeHeightRatio;
        return shape.rectangle.clone()
            .moveRectangle(ShapeDescription_1.ShapeTextPadding, yOffset)
            .resize(-ShapeDescription_1.ShapeTextPadding * 2, -yOffset - ShapeDescription_1.ShapeTextPadding)
            .nonNegativeSize();
    };
    ManualInputShapeDescription.slopeHeightRatio = 0.1;
    return ManualInputShapeDescription;
}(RectangleShapeDescription_1.RectangleShapeDescription));
exports.ManualInputShapeDescription = ManualInputShapeDescription;


/***/ }),
/* 205 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.DataShapeDescription = void 0;
var RectangleShapeDescription_1 = __webpack_require__(19);
var ShapeTypes_1 = __webpack_require__(1);
var PathPrimitive_1 = __webpack_require__(5);
var DiagramItem_1 = __webpack_require__(9);
var ShapeDescription_1 = __webpack_require__(7);
var DataShapeDescription = (function (_super) {
    __extends(DataShapeDescription, _super);
    function DataShapeDescription() {
        return _super.call(this, undefined, true) || this;
    }
    Object.defineProperty(DataShapeDescription.prototype, "key", {
        get: function () { return ShapeTypes_1.ShapeTypes.Data; },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(DataShapeDescription.prototype, "keepRatioOnAutoSize", {
        get: function () { return false; },
        enumerable: false,
        configurable: true
    });
    DataShapeDescription.prototype.createShapePrimitives = function (shape) {
        var _a = shape.rectangle, left = _a.x, top = _a.y, right = _a.right, bottom = _a.bottom, width = _a.width, height = _a.height;
        var px = Math.min(Math.max(0, height / Math.tan(DataShapeDescription.slopeAngle)), width);
        var x1 = left + px;
        var x2 = right - px;
        return [
            new PathPrimitive_1.PathPrimitive([
                new PathPrimitive_1.PathPrimitiveMoveToCommand(x1, top),
                new PathPrimitive_1.PathPrimitiveLineToCommand(right, top),
                new PathPrimitive_1.PathPrimitiveLineToCommand(x2, bottom),
                new PathPrimitive_1.PathPrimitiveLineToCommand(left, bottom),
                new PathPrimitive_1.PathPrimitiveClosePathCommand()
            ], shape.style)
        ];
    };
    DataShapeDescription.prototype.processConnectionPoint = function (shape, point) {
        var offset = shape.size.height / Math.tan(DataShapeDescription.slopeAngle);
        var side = shape.getConnectionPointSide(point);
        if (side === DiagramItem_1.ConnectionPointSide.East)
            point.x -= offset / 2;
        else if (side === DiagramItem_1.ConnectionPointSide.West)
            point.x += offset / 2;
    };
    DataShapeDescription.prototype.getTextRectangle = function (shape) {
        var px = Math.min(Math.max(0, shape.size.height / Math.tan(DataShapeDescription.slopeAngle)), shape.size.width);
        return shape.rectangle.clone().moveRectangle(px, ShapeDescription_1.ShapeTextPadding).resize(-px * 2, -ShapeDescription_1.ShapeTextPadding * 2);
    };
    DataShapeDescription.slopeAngle = 81 * Math.PI / 180;
    return DataShapeDescription;
}(RectangleShapeDescription_1.RectangleShapeDescription));
exports.DataShapeDescription = DataShapeDescription;


/***/ }),
/* 206 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.TerminatorShapeDescription = void 0;
var RectangleShapeDescription_1 = __webpack_require__(19);
var ShapeTypes_1 = __webpack_require__(1);
var PathPrimitive_1 = __webpack_require__(5);
var size_1 = __webpack_require__(2);
var ShapeDescription_1 = __webpack_require__(7);
var rectangle_1 = __webpack_require__(13);
var Utils_1 = __webpack_require__(3);
var TerminatorShapeDescription = (function (_super) {
    __extends(TerminatorShapeDescription, _super);
    function TerminatorShapeDescription() {
        return _super.call(this, new size_1.Size(ShapeDescription_1.ShapeDefaultDimension, ShapeDescription_1.ShapeDefaultDimension * 0.5), true) || this;
    }
    Object.defineProperty(TerminatorShapeDescription.prototype, "key", {
        get: function () { return ShapeTypes_1.ShapeTypes.Terminator; },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(TerminatorShapeDescription.prototype, "keepRatioOnAutoSize", {
        get: function () { return false; },
        enumerable: false,
        configurable: true
    });
    TerminatorShapeDescription.prototype.createShapePrimitives = function (shape) {
        var rect = shape.rectangle;
        var left = rect.x, top = rect.y, right = rect.right, bottom = rect.bottom, width = rect.width;
        var cy = rect.center.y;
        var x1 = left + width * TerminatorShapeDescription.curveWidthRatio;
        var x2 = left + width * (1 - TerminatorShapeDescription.curveWidthRatio);
        return [
            new PathPrimitive_1.PathPrimitive([
                new PathPrimitive_1.PathPrimitiveMoveToCommand(x1, top),
                new PathPrimitive_1.PathPrimitiveLineToCommand(x2, top),
                new PathPrimitive_1.PathPrimitiveQuadraticCurveToCommand(right, top, right, cy),
                new PathPrimitive_1.PathPrimitiveQuadraticCurveToCommand(right, bottom, x2, bottom),
                new PathPrimitive_1.PathPrimitiveLineToCommand(x1, bottom),
                new PathPrimitive_1.PathPrimitiveQuadraticCurveToCommand(left, bottom, left, cy),
                new PathPrimitive_1.PathPrimitiveQuadraticCurveToCommand(left, top, x1, top),
                new PathPrimitive_1.PathPrimitiveClosePathCommand()
            ], shape.style)
        ];
    };
    TerminatorShapeDescription.prototype.getTextRectangle = function (shape) {
        var textSize = Utils_1.GeometryUtils.getMaxRectangleEnscribedInEllipse(shape.size);
        return rectangle_1.Rectangle.fromGeometry(shape.position.clone().offset((shape.size.width - textSize.width) / 2, (shape.size.height - textSize.height) / 2), textSize);
    };
    TerminatorShapeDescription.prototype.getSizeByText = function (textSize, _shape) {
        return Utils_1.GeometryUtils.getEllipseByEnscribedRectangle(textSize);
    };
    TerminatorShapeDescription.curveWidthRatio = 0.3;
    return TerminatorShapeDescription;
}(RectangleShapeDescription_1.RectangleShapeDescription));
exports.TerminatorShapeDescription = TerminatorShapeDescription;


/***/ }),
/* 207 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.PredefinedProcessShapeDescription = exports.PredefinedProcessEdgeParameterName = void 0;
var RectangleShapeDescription_1 = __webpack_require__(19);
var ShapeTypes_1 = __webpack_require__(1);
var ShapeParameters_1 = __webpack_require__(37);
var ShapeParameterPoint_1 = __webpack_require__(30);
var point_1 = __webpack_require__(0);
var PathPrimitive_1 = __webpack_require__(5);
exports.PredefinedProcessEdgeParameterName = "e";
var PredefinedProcessShapeDescription = (function (_super) {
    __extends(PredefinedProcessShapeDescription, _super);
    function PredefinedProcessShapeDescription() {
        return _super.call(this, undefined, true) || this;
    }
    Object.defineProperty(PredefinedProcessShapeDescription.prototype, "key", {
        get: function () { return ShapeTypes_1.ShapeTypes.PredefinedProcess; },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(PredefinedProcessShapeDescription.prototype, "keepRatioOnAutoSize", {
        get: function () { return false; },
        enumerable: false,
        configurable: true
    });
    PredefinedProcessShapeDescription.prototype.createShapePrimitives = function (shape) {
        var rect = shape.rectangle;
        var left = rect.x, top = rect.y, right = rect.right, bottom = rect.bottom;
        var x1 = left + shape.parameters.get(exports.PredefinedProcessEdgeParameterName).value;
        var x2 = right - shape.parameters.get(exports.PredefinedProcessEdgeParameterName).value;
        var primitives = _super.prototype.createShapePrimitives.call(this, shape);
        return primitives.concat([
            new PathPrimitive_1.PathPrimitive([
                new PathPrimitive_1.PathPrimitiveMoveToCommand(x1, top),
                new PathPrimitive_1.PathPrimitiveLineToCommand(x1, bottom),
                new PathPrimitive_1.PathPrimitiveMoveToCommand(x2, top),
                new PathPrimitive_1.PathPrimitiveLineToCommand(x2, bottom)
            ], shape.style)
        ]);
    };
    PredefinedProcessShapeDescription.prototype.createParameters = function (parameters) {
        parameters.add(new ShapeParameters_1.ShapeParameter(exports.PredefinedProcessEdgeParameterName, this.defaultSize.width * 0.1));
    };
    PredefinedProcessShapeDescription.prototype.normalizeParameters = function (shape, parameters) {
        this.changeParameterValue(parameters, exports.PredefinedProcessEdgeParameterName, function (p) { return Math.max(PredefinedProcessShapeDescription.minEdge, Math.min(shape.size.width * 0.3, p.value)); });
    };
    PredefinedProcessShapeDescription.prototype.modifyParameters = function (shape, parameters, deltaX, deltaY) {
        this.changeParameterValue(parameters, exports.PredefinedProcessEdgeParameterName, function (p) { return p.value + deltaX; });
        this.normalizeParameters(shape, parameters);
    };
    PredefinedProcessShapeDescription.prototype.getParameterPoints = function (shape) {
        return [
            new ShapeParameterPoint_1.ShapeParameterPoint("c", new point_1.Point(shape.normalizeX(shape.position.x + shape.parameters.get(exports.PredefinedProcessEdgeParameterName).value), shape.position.y))
        ];
    };
    PredefinedProcessShapeDescription.prototype.getTextRectangle = function (shape) {
        var rect = shape.rectangle;
        var dx = shape.parameters.get(exports.PredefinedProcessEdgeParameterName).value;
        return rect.clone().resize(-2 * dx, 0).clone().moveRectangle(dx, 0);
    };
    PredefinedProcessShapeDescription.minEdge = 72;
    return PredefinedProcessShapeDescription;
}(RectangleShapeDescription_1.RectangleShapeDescription));
exports.PredefinedProcessShapeDescription = PredefinedProcessShapeDescription;


/***/ }),
/* 208 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.ArrowUpDownShapeDescription = void 0;
var PathPrimitive_1 = __webpack_require__(5);
var ShapeParameterPoint_1 = __webpack_require__(30);
var point_1 = __webpack_require__(0);
var ArrowVerticalShapeDescription_1 = __webpack_require__(92);
var ShapeTypes_1 = __webpack_require__(1);
var ArrowUpDownShapeDescription = (function (_super) {
    __extends(ArrowUpDownShapeDescription, _super);
    function ArrowUpDownShapeDescription() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    Object.defineProperty(ArrowUpDownShapeDescription.prototype, "key", {
        get: function () { return ShapeTypes_1.ShapeTypes.ArrowUpDown; },
        enumerable: false,
        configurable: true
    });
    ArrowUpDownShapeDescription.prototype.createShapePrimitives = function (shape) {
        var rect = shape.rectangle;
        var left = rect.x, top = rect.y, right = rect.right, bottom = rect.bottom, width = rect.width;
        var cx = rect.center.x;
        var p1dx = (width - shape.parameters.get(ArrowVerticalShapeDescription_1.ArrowVerticalLineWidthParameterName).value) / 2;
        var p0dy = shape.parameters.get(ArrowVerticalShapeDescription_1.ArrowVerticalTriangleHeightParameterName).value;
        var p1x1 = shape.normalizeX(left + p1dx);
        var p0y1 = shape.normalizeY(top + p0dy);
        var p1x2 = shape.normalizeX(right - p1dx);
        var p0y2 = shape.normalizeY(bottom - p0dy);
        return [
            new PathPrimitive_1.PathPrimitive([
                new PathPrimitive_1.PathPrimitiveMoveToCommand(cx, top),
                new PathPrimitive_1.PathPrimitiveLineToCommand(right, p0y1),
                new PathPrimitive_1.PathPrimitiveLineToCommand(p1x2, p0y1),
                new PathPrimitive_1.PathPrimitiveLineToCommand(p1x2, p0y2),
                new PathPrimitive_1.PathPrimitiveLineToCommand(right, p0y2),
                new PathPrimitive_1.PathPrimitiveLineToCommand(cx, bottom),
                new PathPrimitive_1.PathPrimitiveLineToCommand(left, p0y2),
                new PathPrimitive_1.PathPrimitiveLineToCommand(p1x1, p0y2),
                new PathPrimitive_1.PathPrimitiveLineToCommand(p1x1, p0y1),
                new PathPrimitive_1.PathPrimitiveLineToCommand(left, p0y1),
                new PathPrimitive_1.PathPrimitiveClosePathCommand()
            ], shape.style)
        ];
    };
    ArrowUpDownShapeDescription.prototype.normalizeParameters = function (shape, parameters) {
        this.changeParameterValue(parameters, ArrowVerticalShapeDescription_1.ArrowVerticalTriangleHeightParameterName, function (p) { return Math.max(0, Math.min(shape.size.height / 2 - 2 * shape.strokeWidth, p.value)); });
        this.changeParameterValue(parameters, ArrowVerticalShapeDescription_1.ArrowVerticalLineWidthParameterName, function (p) { return Math.max(0, Math.min(shape.size.width, p.value)); });
    };
    ArrowUpDownShapeDescription.prototype.modifyParameters = function (shape, parameters, deltaX, deltaY) {
        this.changeParameterValue(parameters, ArrowVerticalShapeDescription_1.ArrowVerticalTriangleHeightParameterName, function (p) { return p.value + deltaY; });
        this.changeParameterValue(parameters, ArrowVerticalShapeDescription_1.ArrowVerticalLineWidthParameterName, function (p) { return p.value - deltaX * 2; });
        this.normalizeParameters(shape, parameters);
    };
    ArrowUpDownShapeDescription.prototype.getParameterPoints = function (shape) {
        return [
            new ShapeParameterPoint_1.ShapeParameterPoint("c", new point_1.Point(shape.normalizeX(shape.position.x + (shape.size.width - shape.parameters.get(ArrowVerticalShapeDescription_1.ArrowVerticalLineWidthParameterName).value) / 2), shape.normalizeY(shape.position.y + shape.parameters.get(ArrowVerticalShapeDescription_1.ArrowVerticalTriangleHeightParameterName).value)))
        ];
    };
    return ArrowUpDownShapeDescription;
}(ArrowVerticalShapeDescription_1.ArrowVerticalShapeDescription));
exports.ArrowUpDownShapeDescription = ArrowUpDownShapeDescription;


/***/ }),
/* 209 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.ArrowRightShapeDescription = void 0;
var PathPrimitive_1 = __webpack_require__(5);
var ArrowHorizontalShapeDescription_1 = __webpack_require__(93);
var ShapeParameterPoint_1 = __webpack_require__(30);
var point_1 = __webpack_require__(0);
var ShapeTypes_1 = __webpack_require__(1);
var DiagramItem_1 = __webpack_require__(9);
var ArrowRightShapeDescription = (function (_super) {
    __extends(ArrowRightShapeDescription, _super);
    function ArrowRightShapeDescription() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    Object.defineProperty(ArrowRightShapeDescription.prototype, "key", {
        get: function () { return ShapeTypes_1.ShapeTypes.ArrowRight; },
        enumerable: false,
        configurable: true
    });
    ArrowRightShapeDescription.prototype.createShapePrimitives = function (shape) {
        var rect = shape.rectangle;
        var left = rect.x, top = rect.y, right = rect.right, bottom = rect.bottom, width = rect.width, height = rect.height;
        var cy = rect.center.y;
        var p0dx = width - shape.parameters.get(ArrowHorizontalShapeDescription_1.ArrowVerticalTriangleWidthParameterName).value;
        var p1dy = (height - shape.parameters.get(ArrowHorizontalShapeDescription_1.ArrowVerticalLineHeightParameterName).value) / 2;
        var p0x1 = shape.normalizeX(left + p0dx);
        var p1y1 = shape.normalizeY(top + p1dy);
        var p1y2 = shape.normalizeY(bottom - p1dy);
        return [
            new PathPrimitive_1.PathPrimitive([
                new PathPrimitive_1.PathPrimitiveMoveToCommand(left, p1y1),
                new PathPrimitive_1.PathPrimitiveLineToCommand(p0x1, p1y1),
                new PathPrimitive_1.PathPrimitiveLineToCommand(p0x1, top),
                new PathPrimitive_1.PathPrimitiveLineToCommand(right, cy),
                new PathPrimitive_1.PathPrimitiveLineToCommand(p0x1, bottom),
                new PathPrimitive_1.PathPrimitiveLineToCommand(p0x1, p1y2),
                new PathPrimitive_1.PathPrimitiveLineToCommand(left, p1y2),
                new PathPrimitive_1.PathPrimitiveClosePathCommand()
            ], shape.style)
        ];
    };
    ArrowRightShapeDescription.prototype.modifyParameters = function (shape, parameters, deltaX, deltaY) {
        this.changeParameterValue(parameters, ArrowHorizontalShapeDescription_1.ArrowVerticalTriangleWidthParameterName, function (p) { return p.value - deltaX; });
        this.changeParameterValue(parameters, ArrowHorizontalShapeDescription_1.ArrowVerticalLineHeightParameterName, function (p) { return p.value - deltaY * 2; });
        this.normalizeParameters(shape, parameters);
    };
    ArrowRightShapeDescription.prototype.getParameterPoints = function (shape) {
        return [
            new ShapeParameterPoint_1.ShapeParameterPoint("c", new point_1.Point(shape.normalizeX(shape.position.x + shape.size.width - shape.parameters.get(ArrowHorizontalShapeDescription_1.ArrowVerticalTriangleWidthParameterName).value), shape.normalizeY(shape.position.y + (shape.size.height - shape.parameters.get(ArrowHorizontalShapeDescription_1.ArrowVerticalLineHeightParameterName).value) / 2)))
        ];
    };
    ArrowRightShapeDescription.prototype.processConnectionPoint = function (shape, point) {
        var triangleWidth = shape.parameters.get(ArrowHorizontalShapeDescription_1.ArrowVerticalTriangleWidthParameterName).value;
        if (point.x > shape.position.x + shape.size.width - triangleWidth) {
            var tg = shape.size.height / 2 / triangleWidth;
            var delta = (point.x - (shape.position.x + shape.size.width - triangleWidth)) * tg;
            var side = shape.getConnectionPointSide(point);
            if (side === DiagramItem_1.ConnectionPointSide.North)
                point.y += delta;
            else if (side === DiagramItem_1.ConnectionPointSide.South)
                point.y -= delta;
        }
        else
            _super.prototype.processConnectionPoint.call(this, shape, point);
    };
    return ArrowRightShapeDescription;
}(ArrowHorizontalShapeDescription_1.ArrowHorizontalShapeDescription));
exports.ArrowRightShapeDescription = ArrowRightShapeDescription;


/***/ }),
/* 210 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.ArrowUpShapeDescription = void 0;
var PathPrimitive_1 = __webpack_require__(5);
var ShapeParameterPoint_1 = __webpack_require__(30);
var point_1 = __webpack_require__(0);
var ArrowVerticalShapeDescription_1 = __webpack_require__(92);
var ShapeTypes_1 = __webpack_require__(1);
var DiagramItem_1 = __webpack_require__(9);
var ArrowUpShapeDescription = (function (_super) {
    __extends(ArrowUpShapeDescription, _super);
    function ArrowUpShapeDescription() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    Object.defineProperty(ArrowUpShapeDescription.prototype, "key", {
        get: function () { return ShapeTypes_1.ShapeTypes.ArrowUp; },
        enumerable: false,
        configurable: true
    });
    ArrowUpShapeDescription.prototype.createShapePrimitives = function (shape) {
        var rect = shape.rectangle;
        var left = rect.x, top = rect.y, right = rect.right, bottom = rect.bottom, width = rect.width;
        var cx = rect.center.x;
        var p1dx = (width - shape.parameters.get(ArrowVerticalShapeDescription_1.ArrowVerticalLineWidthParameterName).value) / 2;
        var p0dy = shape.parameters.get(ArrowVerticalShapeDescription_1.ArrowVerticalTriangleHeightParameterName).value;
        var p1x1 = shape.normalizeX(left + p1dx);
        var p0y1 = shape.normalizeY(top + p0dy);
        var p1x2 = shape.normalizeX(right - p1dx);
        return [
            new PathPrimitive_1.PathPrimitive([
                new PathPrimitive_1.PathPrimitiveMoveToCommand(cx, top),
                new PathPrimitive_1.PathPrimitiveLineToCommand(right, p0y1),
                new PathPrimitive_1.PathPrimitiveLineToCommand(p1x2, p0y1),
                new PathPrimitive_1.PathPrimitiveLineToCommand(p1x2, bottom),
                new PathPrimitive_1.PathPrimitiveLineToCommand(p1x1, bottom),
                new PathPrimitive_1.PathPrimitiveLineToCommand(p1x1, p0y1),
                new PathPrimitive_1.PathPrimitiveLineToCommand(left, p0y1),
                new PathPrimitive_1.PathPrimitiveClosePathCommand()
            ], shape.style)
        ];
    };
    ArrowUpShapeDescription.prototype.modifyParameters = function (shape, parameters, deltaX, deltaY) {
        this.changeParameterValue(parameters, ArrowVerticalShapeDescription_1.ArrowVerticalTriangleHeightParameterName, function (p) { return p.value + deltaY; });
        this.changeParameterValue(parameters, ArrowVerticalShapeDescription_1.ArrowVerticalLineWidthParameterName, function (p) { return p.value - deltaX * 2; });
        this.normalizeParameters(shape, parameters);
    };
    ArrowUpShapeDescription.prototype.getParameterPoints = function (shape) {
        return [
            new ShapeParameterPoint_1.ShapeParameterPoint("c", new point_1.Point(shape.normalizeX(shape.position.x + (shape.size.width - shape.parameters.get(ArrowVerticalShapeDescription_1.ArrowVerticalLineWidthParameterName).value) / 2), shape.normalizeY(shape.position.y + shape.parameters.get(ArrowVerticalShapeDescription_1.ArrowVerticalTriangleHeightParameterName).value)))
        ];
    };
    ArrowUpShapeDescription.prototype.processConnectionPoint = function (shape, point) {
        var triangleHeight = shape.parameters.get(ArrowVerticalShapeDescription_1.ArrowVerticalTriangleHeightParameterName).value;
        if (point.y < shape.position.y + triangleHeight) {
            var tg = shape.size.width / 2 / triangleHeight;
            var delta = (shape.position.y + triangleHeight - point.y) * tg;
            var side = shape.getConnectionPointSide(point);
            if (side === DiagramItem_1.ConnectionPointSide.East)
                point.x -= delta;
            else if (side === DiagramItem_1.ConnectionPointSide.West)
                point.x += delta;
        }
        else
            _super.prototype.processConnectionPoint.call(this, shape, point);
    };
    return ArrowUpShapeDescription;
}(ArrowVerticalShapeDescription_1.ArrowVerticalShapeDescription));
exports.ArrowUpShapeDescription = ArrowUpShapeDescription;


/***/ }),
/* 211 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.CrossShapeDescription = exports.CrossVerticalWidthParameterName = exports.CrossHorizontalWidthParameterName = void 0;
var ShapeDescription_1 = __webpack_require__(7);
var point_1 = __webpack_require__(0);
var ShapeParameters_1 = __webpack_require__(37);
var ShapeParameterPoint_1 = __webpack_require__(30);
var PathPrimitive_1 = __webpack_require__(5);
var ShapeTypes_1 = __webpack_require__(1);
exports.CrossHorizontalWidthParameterName = "chw";
exports.CrossVerticalWidthParameterName = "cvw";
var CrossShapeDescription = (function (_super) {
    __extends(CrossShapeDescription, _super);
    function CrossShapeDescription() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    Object.defineProperty(CrossShapeDescription.prototype, "key", {
        get: function () { return ShapeTypes_1.ShapeTypes.Cross; },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(CrossShapeDescription.prototype, "keepRatioOnAutoSize", {
        get: function () { return true; },
        enumerable: false,
        configurable: true
    });
    CrossShapeDescription.prototype.createShapePrimitives = function (shape) {
        var rect = shape.rectangle;
        var left = rect.x, top = rect.y, right = rect.right, bottom = rect.bottom, width = rect.width, height = rect.height;
        var p0dx = (width - shape.parameters.get(exports.CrossHorizontalWidthParameterName).value) / 2;
        var p1dy = (height - shape.parameters.get(exports.CrossVerticalWidthParameterName).value) / 2;
        var p0x1 = shape.normalizeX(left + p0dx);
        var p1y1 = shape.normalizeY(top + p1dy);
        var p0x2 = shape.normalizeX(right - p0dx);
        var p1y2 = shape.normalizeY(bottom - p1dy);
        return [
            new PathPrimitive_1.PathPrimitive([
                new PathPrimitive_1.PathPrimitiveMoveToCommand(left, p1y1),
                new PathPrimitive_1.PathPrimitiveLineToCommand(p0x1, p1y1),
                new PathPrimitive_1.PathPrimitiveLineToCommand(p0x1, top),
                new PathPrimitive_1.PathPrimitiveLineToCommand(p0x2, top),
                new PathPrimitive_1.PathPrimitiveLineToCommand(p0x2, p1y1),
                new PathPrimitive_1.PathPrimitiveLineToCommand(right, p1y1),
                new PathPrimitive_1.PathPrimitiveLineToCommand(right, p1y2),
                new PathPrimitive_1.PathPrimitiveLineToCommand(p0x2, p1y2),
                new PathPrimitive_1.PathPrimitiveLineToCommand(p0x2, bottom),
                new PathPrimitive_1.PathPrimitiveLineToCommand(p0x1, bottom),
                new PathPrimitive_1.PathPrimitiveLineToCommand(p0x1, p1y2),
                new PathPrimitive_1.PathPrimitiveLineToCommand(left, p1y2),
                new PathPrimitive_1.PathPrimitiveClosePathCommand()
            ], shape.style)
        ];
    };
    CrossShapeDescription.prototype.createParameters = function (parameters) {
        parameters.addRange([
            new ShapeParameters_1.ShapeParameter(exports.CrossHorizontalWidthParameterName, this.defaultSize.width * 0.2),
            new ShapeParameters_1.ShapeParameter(exports.CrossVerticalWidthParameterName, this.defaultSize.height * 0.2)
        ]);
    };
    CrossShapeDescription.prototype.normalizeParameters = function (shape, parameters) {
        this.changeParameterValue(parameters, exports.CrossHorizontalWidthParameterName, function (p) { return Math.max(0, Math.min(shape.size.width, p.value)); });
        this.changeParameterValue(parameters, exports.CrossVerticalWidthParameterName, function (p) { return Math.max(0, Math.min(shape.size.height, p.value)); });
    };
    CrossShapeDescription.prototype.modifyParameters = function (shape, parameters, deltaX, deltaY) {
        this.changeParameterValue(parameters, exports.CrossHorizontalWidthParameterName, function (p) { return p.value - deltaX * 2; });
        this.changeParameterValue(parameters, exports.CrossVerticalWidthParameterName, function (p) { return p.value - deltaY * 2; });
        this.normalizeParameters(shape, parameters);
    };
    CrossShapeDescription.prototype.getParameterPoints = function (shape) {
        return [
            new ShapeParameterPoint_1.ShapeParameterPoint("c", new point_1.Point(shape.normalizeX(shape.position.x + (shape.size.width - shape.parameters.get(exports.CrossHorizontalWidthParameterName).value) / 2), shape.normalizeY(shape.position.y + (shape.size.height - shape.parameters.get(exports.CrossVerticalWidthParameterName).value) / 2)))
        ];
    };
    CrossShapeDescription.prototype.getTextRectangle = function (shape) {
        return shape.rectangle.clone().inflate(-ShapeDescription_1.ShapeTextPadding, -ShapeDescription_1.ShapeTextPadding);
    };
    CrossShapeDescription.prototype.getSizeByText = function (textSize, _shape) {
        return textSize.clone().offset(ShapeDescription_1.ShapeTextPadding * 2, ShapeDescription_1.ShapeTextPadding * 2);
    };
    return CrossShapeDescription;
}(ShapeDescription_1.ShapeDescription));
exports.CrossShapeDescription = CrossShapeDescription;


/***/ }),
/* 212 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.HeartShapeDescription = void 0;
var ShapeDescription_1 = __webpack_require__(7);
var PathPrimitive_1 = __webpack_require__(5);
var ShapeTypes_1 = __webpack_require__(1);
var ConnectionPoint_1 = __webpack_require__(45);
var DiagramItem_1 = __webpack_require__(9);
var HeartShapeDescription = (function (_super) {
    __extends(HeartShapeDescription, _super);
    function HeartShapeDescription() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    Object.defineProperty(HeartShapeDescription.prototype, "key", {
        get: function () { return ShapeTypes_1.ShapeTypes.Heart; },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(HeartShapeDescription.prototype, "keepRatioOnAutoSize", {
        get: function () { return true; },
        enumerable: false,
        configurable: true
    });
    HeartShapeDescription.prototype.createConnectionPoints = function () {
        return [
            new ConnectionPoint_1.ConnectionPoint(0.5, 0.15, DiagramItem_1.ConnectionPointSide.North),
            new ConnectionPoint_1.ConnectionPoint(1, 0.25, DiagramItem_1.ConnectionPointSide.East),
            new ConnectionPoint_1.ConnectionPoint(0.5, 1, DiagramItem_1.ConnectionPointSide.South),
            new ConnectionPoint_1.ConnectionPoint(0, 0.25, DiagramItem_1.ConnectionPointSide.West)
        ];
    };
    HeartShapeDescription.prototype.createShapePrimitives = function (shape) {
        var rect = shape.rectangle;
        var left = rect.x, top = rect.y, right = rect.right, bottom = rect.bottom, width = rect.width, height = rect.height;
        return [
            new PathPrimitive_1.PathPrimitive([
                new PathPrimitive_1.PathPrimitiveMoveToCommand(right - width * 0.25, top),
                new PathPrimitive_1.PathPrimitiveCubicCurveToCommand(right - width * 0.15, top, right, top + height * 0.1, right, top + height * 0.25),
                new PathPrimitive_1.PathPrimitiveCubicCurveToCommand(right, top + height * 0.3, right - width * 0.02, top + height * 0.35, right - width * 0.05, top + height * 0.4),
                new PathPrimitive_1.PathPrimitiveLineToCommand(rect.center.x, bottom),
                new PathPrimitive_1.PathPrimitiveLineToCommand(left + width * 0.05, top + height * 0.4),
                new PathPrimitive_1.PathPrimitiveCubicCurveToCommand(left + width * 0.02, top + height * 0.35, left, top + height * 0.3, left, top + height * 0.25),
                new PathPrimitive_1.PathPrimitiveCubicCurveToCommand(left, top + height * 0.1, left + width * 0.15, top, left + width * 0.25, top),
                new PathPrimitive_1.PathPrimitiveCubicCurveToCommand(left + width * 0.3, top, left + width * 0.45, top + height * 0.03, left + width * 0.5, top + height * 0.15),
                new PathPrimitive_1.PathPrimitiveCubicCurveToCommand(right - width * 0.45, top + height * 0.03, right - width * 0.3, top, right - width * 0.25, top),
                new PathPrimitive_1.PathPrimitiveClosePathCommand()
            ], shape.style)
        ];
    };
    HeartShapeDescription.prototype.getTextRectangle = function (shape) {
        return shape.rectangle.clone().inflate(-ShapeDescription_1.ShapeTextPadding, -ShapeDescription_1.ShapeTextPadding);
    };
    HeartShapeDescription.prototype.getSizeByText = function (_textSize, shape) {
        return shape.size.clone().offset(ShapeDescription_1.ShapeTextPadding * 2, ShapeDescription_1.ShapeTextPadding * 2);
    };
    return HeartShapeDescription;
}(ShapeDescription_1.ShapeDescription));
exports.HeartShapeDescription = HeartShapeDescription;


/***/ }),
/* 213 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.OctagonShapeDescription = void 0;
var PathPrimitive_1 = __webpack_require__(5);
var ShapeTypes_1 = __webpack_require__(1);
var PolygonShapeDescription_1 = __webpack_require__(94);
var Utils_1 = __webpack_require__(3);
var rectangle_1 = __webpack_require__(13);
var OctagonShapeDescription = (function (_super) {
    __extends(OctagonShapeDescription, _super);
    function OctagonShapeDescription() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    Object.defineProperty(OctagonShapeDescription.prototype, "key", {
        get: function () { return ShapeTypes_1.ShapeTypes.Octagon; },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(OctagonShapeDescription.prototype, "angleCount", {
        get: function () { return 8; },
        enumerable: false,
        configurable: true
    });
    OctagonShapeDescription.prototype.createShapePrimitives = function (shape) {
        var rect = shape.rectangle;
        var left = rect.x, top = rect.y, right = rect.right, bottom = rect.bottom, width = rect.width, height = rect.height;
        var angle = Math.PI - this.angle;
        var sideX = width / (1 + 2 * Math.cos(angle));
        var sideY = height / (1 + 2 * Math.cos(angle));
        var x1 = left + (width - sideX) / 2;
        var x2 = x1 + sideX;
        var y1 = top + (height - sideY) / 2;
        var y2 = y1 + sideY;
        return [
            new PathPrimitive_1.PathPrimitive([
                new PathPrimitive_1.PathPrimitiveMoveToCommand(x1, top),
                new PathPrimitive_1.PathPrimitiveLineToCommand(x2, top),
                new PathPrimitive_1.PathPrimitiveLineToCommand(right, y1),
                new PathPrimitive_1.PathPrimitiveLineToCommand(right, y2),
                new PathPrimitive_1.PathPrimitiveLineToCommand(x2, bottom),
                new PathPrimitive_1.PathPrimitiveLineToCommand(x1, bottom),
                new PathPrimitive_1.PathPrimitiveLineToCommand(left, y2),
                new PathPrimitive_1.PathPrimitiveLineToCommand(left, y1),
                new PathPrimitive_1.PathPrimitiveClosePathCommand()
            ], shape.style)
        ];
    };
    OctagonShapeDescription.prototype.calculateHeight = function (width) {
        return width;
    };
    OctagonShapeDescription.prototype.getTextRectangle = function (shape) {
        var textSize = Utils_1.GeometryUtils.getMaxRectangleEnscribedInEllipse(shape.size);
        return rectangle_1.Rectangle.fromGeometry(shape.position.clone().offset((shape.size.width - textSize.width) / 2, (shape.size.height - textSize.height) / 2), textSize);
    };
    OctagonShapeDescription.prototype.getSizeByText = function (textSize, _shape) {
        return Utils_1.GeometryUtils.getEllipseByEnscribedRectangle(textSize);
    };
    return OctagonShapeDescription;
}(PolygonShapeDescription_1.PolygonShapeDescription));
exports.OctagonShapeDescription = OctagonShapeDescription;


/***/ }),
/* 214 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.StarShapeDescription = exports.StarConvexParameterName = void 0;
var PathPrimitive_1 = __webpack_require__(5);
var ShapeTypes_1 = __webpack_require__(1);
var PentagonShapeDescription_1 = __webpack_require__(122);
var ShapeParameters_1 = __webpack_require__(37);
var ShapeParameterPoint_1 = __webpack_require__(30);
var point_1 = __webpack_require__(0);
var DiagramItem_1 = __webpack_require__(9);
exports.StarConvexParameterName = "sc";
var StarShapeDescription = (function (_super) {
    __extends(StarShapeDescription, _super);
    function StarShapeDescription() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    Object.defineProperty(StarShapeDescription.prototype, "key", {
        get: function () { return ShapeTypes_1.ShapeTypes.Star; },
        enumerable: false,
        configurable: true
    });
    StarShapeDescription.prototype.createShapePrimitives = function (shape) {
        var rect = shape.rectangle;
        var left = rect.x, top = rect.y, right = rect.right, width = rect.width, height = rect.height;
        var bottom = this.getActualBottom(top, rect.bottom, width, height);
        var cx = rect.center.x;
        var cy = top + (bottom - top) / 2;
        var ratio = height / width;
        var angle = Math.PI - this.angle;
        var py = width / 2 * Math.tan(angle / 2) * ratio;
        var y = top + py;
        var px = (height - py) / Math.tan(angle) / ratio;
        var x1 = left + px;
        var x2 = right - px;
        var pDistance = shape.parameters.get(exports.StarConvexParameterName).value;
        var distance = this.getInnerPointDistance(cx, cx, right, cy, top, y);
        return [
            new PathPrimitive_1.PathPrimitive([
                new PathPrimitive_1.PathPrimitiveMoveToCommand(cx, top),
                new PathPrimitive_1.PathPrimitiveLineToCommand(this.getInnerPointPos(cx, cx, right, pDistance, distance), this.getInnerPointPos(cy, top, y, pDistance, distance)),
                new PathPrimitive_1.PathPrimitiveLineToCommand(right, y),
                new PathPrimitive_1.PathPrimitiveLineToCommand(this.getInnerPointPos(cx, right, x2, pDistance, distance), this.getInnerPointPos(cy, y, bottom, pDistance, distance)),
                new PathPrimitive_1.PathPrimitiveLineToCommand(x2, bottom),
                new PathPrimitive_1.PathPrimitiveLineToCommand(this.getInnerPointPos(cx, x2, x1, pDistance, distance), this.getInnerPointPos(cy, bottom, bottom, pDistance, distance)),
                new PathPrimitive_1.PathPrimitiveLineToCommand(x1, bottom),
                new PathPrimitive_1.PathPrimitiveLineToCommand(this.getInnerPointPos(cx, x1, left, pDistance, distance), this.getInnerPointPos(cy, bottom, y, pDistance, distance)),
                new PathPrimitive_1.PathPrimitiveLineToCommand(left, y),
                new PathPrimitive_1.PathPrimitiveLineToCommand(this.getInnerPointPos(cx, left, cx, pDistance, distance), this.getInnerPointPos(cy, y, top, pDistance, distance)),
                new PathPrimitive_1.PathPrimitiveClosePathCommand()
            ], shape.style)
        ];
    };
    StarShapeDescription.prototype.createParameters = function (parameters) {
        parameters.addRange([
            new ShapeParameters_1.ShapeParameter(exports.StarConvexParameterName, 300)
        ]);
    };
    StarShapeDescription.prototype.normalizeParameters = function (shape, parameters) {
        var rect = shape.rectangle;
        var top = rect.y, right = rect.right, width = rect.width, height = rect.height;
        var bottom = this.getActualBottom(top, rect.bottom, width, height);
        var cx = rect.center.x;
        var cy = top + (bottom - top) / 2;
        var ratio = height / width;
        var angle = Math.PI - this.angle;
        var py = width / 2 * Math.tan(angle / 2) * ratio;
        var y = top + py;
        var distance = this.getInnerPointDistance(cx, cx, right, cy, top, y);
        this.changeParameterValue(parameters, exports.StarConvexParameterName, function (p) { return Math.max(0, Math.min(distance, p.value)); });
    };
    StarShapeDescription.prototype.modifyParameters = function (shape, parameters, deltaX, deltaY) {
        var distance = Math.sqrt(Math.pow(deltaX, 2) + Math.pow(deltaY, 2));
        if (deltaX < 0 || deltaY > 0)
            distance = -distance;
        this.changeParameterValue(parameters, exports.StarConvexParameterName, function (p) { return p.value + distance; });
        this.normalizeParameters(shape, parameters);
    };
    StarShapeDescription.prototype.getParameterPoints = function (shape) {
        var rect = shape.rectangle;
        var top = rect.y, right = rect.right, width = rect.width, height = rect.height;
        var bottom = this.getActualBottom(top, rect.bottom, width, height);
        var cx = rect.center.x;
        var cy = top + (bottom - top) / 2;
        var ratio = height / width;
        var angle = Math.PI - this.angle;
        var py = width / 2 * Math.tan(angle / 2) * ratio;
        var y = top + py;
        var pDistance = shape.parameters.get(exports.StarConvexParameterName).value;
        var distance = this.getInnerPointDistance(cx, cx, right, cy, top, y);
        var innerPointX = this.getInnerPointPos(cx, cx, right, pDistance, distance);
        var innerPointY = this.getInnerPointPos(cy, top, y, pDistance, distance);
        return [
            new ShapeParameterPoint_1.ShapeParameterPoint("c", new point_1.Point(innerPointX, innerPointY))
        ];
    };
    StarShapeDescription.prototype.processConnectionPoint = function (shape, point) {
        _super.prototype.processConnectionPoint.call(this, shape, point);
        var side = shape.getConnectionPointSide(point);
        if (side === DiagramItem_1.ConnectionPointSide.South) {
            var rect = shape.rectangle;
            var top_1 = rect.y, right = rect.right, width = rect.width, height = rect.height;
            var bottom = this.getActualBottom(top_1, rect.bottom, width, height);
            var cx = rect.center.x;
            var cy = top_1 + (bottom - top_1) / 2;
            var ratio = height / width;
            var angle = Math.PI - this.angle;
            var py = width / 2 * Math.tan(angle / 2) * ratio;
            var y = top_1 + py;
            var pDistance = shape.parameters.get(exports.StarConvexParameterName).value;
            var distance = this.getInnerPointDistance(cx, cx, right, cy, top_1, y);
            point.y = this.getInnerPointPos(cy, bottom, bottom, pDistance, distance);
        }
    };
    StarShapeDescription.prototype.getInnerPointDistanceByAxis = function (center, edge1, edge2) {
        var edgeX = Math.min(edge1, edge2) + Math.abs(edge1 - edge2) / 2;
        return edgeX - center;
    };
    StarShapeDescription.prototype.getInnerPointPos = function (center, edge1, edge2, pDistance, distance) {
        var ratio = Math.min(1, pDistance / distance);
        return center + this.getInnerPointDistanceByAxis(center, edge1, edge2) * ratio;
    };
    StarShapeDescription.prototype.getInnerPointDistance = function (centerX, edgeX1, edgeX2, centerY, edgeY1, edgeY2) {
        var disX = this.getInnerPointDistanceByAxis(centerX, edgeX1, edgeX2);
        var disY = this.getInnerPointDistanceByAxis(centerY, edgeY1, edgeY2);
        return Math.sqrt(Math.pow(disX, 2) + Math.pow(disY, 2));
    };
    StarShapeDescription.prototype.getActualBottom = function (top, bottom, width, height) {
        var result = top + _super.prototype.calculateHeight.call(this, width) * height / width;
        return result < bottom ? result : bottom;
    };
    StarShapeDescription.prototype.calculateHeight = function (width) {
        return width;
    };
    return StarShapeDescription;
}(PentagonShapeDescription_1.PentagonShapeDescription));
exports.StarShapeDescription = StarShapeDescription;


/***/ }),
/* 215 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.ArrowDownShapeDescription = void 0;
var PathPrimitive_1 = __webpack_require__(5);
var ShapeParameterPoint_1 = __webpack_require__(30);
var point_1 = __webpack_require__(0);
var ArrowVerticalShapeDescription_1 = __webpack_require__(92);
var ShapeTypes_1 = __webpack_require__(1);
var DiagramItem_1 = __webpack_require__(9);
var ArrowDownShapeDescription = (function (_super) {
    __extends(ArrowDownShapeDescription, _super);
    function ArrowDownShapeDescription() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    Object.defineProperty(ArrowDownShapeDescription.prototype, "key", {
        get: function () { return ShapeTypes_1.ShapeTypes.ArrowDown; },
        enumerable: false,
        configurable: true
    });
    ArrowDownShapeDescription.prototype.createShapePrimitives = function (shape) {
        var rect = shape.rectangle;
        var left = rect.x, top = rect.y, right = rect.right, bottom = rect.bottom, width = rect.width, height = rect.height;
        var cx = rect.center.x;
        var p1dx = (width - shape.parameters.get(ArrowVerticalShapeDescription_1.ArrowVerticalLineWidthParameterName).value) / 2;
        var p0dy = height - shape.parameters.get(ArrowVerticalShapeDescription_1.ArrowVerticalTriangleHeightParameterName).value;
        var p1x1 = shape.normalizeX(left + p1dx);
        var p0y1 = shape.normalizeY(top + p0dy);
        var p1x2 = shape.normalizeX(right - p1dx);
        return [
            new PathPrimitive_1.PathPrimitive([
                new PathPrimitive_1.PathPrimitiveMoveToCommand(p1x1, top),
                new PathPrimitive_1.PathPrimitiveLineToCommand(p1x2, top),
                new PathPrimitive_1.PathPrimitiveLineToCommand(p1x2, p0y1),
                new PathPrimitive_1.PathPrimitiveLineToCommand(right, p0y1),
                new PathPrimitive_1.PathPrimitiveLineToCommand(cx, bottom),
                new PathPrimitive_1.PathPrimitiveLineToCommand(left, p0y1),
                new PathPrimitive_1.PathPrimitiveLineToCommand(p1x1, p0y1),
                new PathPrimitive_1.PathPrimitiveClosePathCommand()
            ], shape.style)
        ];
    };
    ArrowDownShapeDescription.prototype.modifyParameters = function (shape, parameters, deltaX, deltaY) {
        this.changeParameterValue(parameters, ArrowVerticalShapeDescription_1.ArrowVerticalTriangleHeightParameterName, function (p) { return p.value - deltaY; });
        this.changeParameterValue(parameters, ArrowVerticalShapeDescription_1.ArrowVerticalLineWidthParameterName, function (p) { return p.value - deltaX * 2; });
        this.normalizeParameters(shape, parameters);
    };
    ArrowDownShapeDescription.prototype.getParameterPoints = function (shape) {
        return [
            new ShapeParameterPoint_1.ShapeParameterPoint("c", new point_1.Point(shape.normalizeX(shape.position.x + (shape.size.width - shape.parameters.get(ArrowVerticalShapeDescription_1.ArrowVerticalLineWidthParameterName).value) / 2), shape.normalizeY(shape.position.y + shape.size.height - shape.parameters.get(ArrowVerticalShapeDescription_1.ArrowVerticalTriangleHeightParameterName).value)))
        ];
    };
    ArrowDownShapeDescription.prototype.processConnectionPoint = function (shape, point) {
        var triangleHeight = shape.parameters.get(ArrowVerticalShapeDescription_1.ArrowVerticalTriangleHeightParameterName).value;
        if (point.y > shape.position.y + shape.size.height - triangleHeight) {
            var tg = shape.size.width / 2 / triangleHeight;
            var delta = (point.y - (shape.position.y + shape.size.height - triangleHeight)) * tg;
            var side = shape.getConnectionPointSide(point);
            if (side === DiagramItem_1.ConnectionPointSide.East)
                point.x -= delta;
            else if (side === DiagramItem_1.ConnectionPointSide.West)
                point.x += delta;
        }
        else
            _super.prototype.processConnectionPoint.call(this, shape, point);
    };
    return ArrowDownShapeDescription;
}(ArrowVerticalShapeDescription_1.ArrowVerticalShapeDescription));
exports.ArrowDownShapeDescription = ArrowDownShapeDescription;


/***/ }),
/* 216 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.ArrowLeftRightShapeDescription = void 0;
var PathPrimitive_1 = __webpack_require__(5);
var ArrowHorizontalShapeDescription_1 = __webpack_require__(93);
var ShapeParameterPoint_1 = __webpack_require__(30);
var point_1 = __webpack_require__(0);
var ShapeTypes_1 = __webpack_require__(1);
var ArrowLeftRightShapeDescription = (function (_super) {
    __extends(ArrowLeftRightShapeDescription, _super);
    function ArrowLeftRightShapeDescription() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    Object.defineProperty(ArrowLeftRightShapeDescription.prototype, "key", {
        get: function () { return ShapeTypes_1.ShapeTypes.ArrowLeftRight; },
        enumerable: false,
        configurable: true
    });
    ArrowLeftRightShapeDescription.prototype.createShapePrimitives = function (shape) {
        var rect = shape.rectangle;
        var left = rect.x, top = rect.y, right = rect.right, bottom = rect.bottom, height = rect.height;
        var cy = rect.center.y;
        var p0dx = shape.parameters.get(ArrowHorizontalShapeDescription_1.ArrowVerticalTriangleWidthParameterName).value;
        var p1dy = (height - shape.parameters.get(ArrowHorizontalShapeDescription_1.ArrowVerticalLineHeightParameterName).value) / 2;
        var p0x1 = shape.normalizeX(left + p0dx);
        var p1y1 = shape.normalizeY(top + p1dy);
        var p0x2 = shape.normalizeX(right - p0dx);
        var p1y2 = shape.normalizeY(bottom - p1dy);
        return [
            new PathPrimitive_1.PathPrimitive([
                new PathPrimitive_1.PathPrimitiveMoveToCommand(left, cy),
                new PathPrimitive_1.PathPrimitiveLineToCommand(p0x1, top),
                new PathPrimitive_1.PathPrimitiveLineToCommand(p0x1, p1y1),
                new PathPrimitive_1.PathPrimitiveLineToCommand(p0x2, p1y1),
                new PathPrimitive_1.PathPrimitiveLineToCommand(p0x2, top),
                new PathPrimitive_1.PathPrimitiveLineToCommand(right, cy),
                new PathPrimitive_1.PathPrimitiveLineToCommand(p0x2, bottom),
                new PathPrimitive_1.PathPrimitiveLineToCommand(p0x2, p1y2),
                new PathPrimitive_1.PathPrimitiveLineToCommand(p0x1, p1y2),
                new PathPrimitive_1.PathPrimitiveLineToCommand(p0x1, bottom),
                new PathPrimitive_1.PathPrimitiveClosePathCommand()
            ], shape.style)
        ];
    };
    ArrowLeftRightShapeDescription.prototype.normalizeParameters = function (shape, parameters) {
        this.changeParameterValue(parameters, ArrowHorizontalShapeDescription_1.ArrowVerticalTriangleWidthParameterName, function (p) { return Math.max(0, Math.min(shape.size.width / 2 - 2 * shape.strokeWidth, p.value)); });
        this.changeParameterValue(parameters, ArrowHorizontalShapeDescription_1.ArrowVerticalLineHeightParameterName, function (p) { return Math.max(0, Math.min(shape.size.height, p.value)); });
    };
    ArrowLeftRightShapeDescription.prototype.modifyParameters = function (shape, parameters, deltaX, deltaY) {
        this.changeParameterValue(parameters, ArrowHorizontalShapeDescription_1.ArrowVerticalTriangleWidthParameterName, function (p) { return p.value + deltaX; });
        this.changeParameterValue(parameters, ArrowHorizontalShapeDescription_1.ArrowVerticalLineHeightParameterName, function (p) { return p.value - deltaY * 2; });
        this.normalizeParameters(shape, parameters);
    };
    ArrowLeftRightShapeDescription.prototype.getParameterPoints = function (shape) {
        return [
            new ShapeParameterPoint_1.ShapeParameterPoint("c", new point_1.Point(shape.normalizeX(shape.position.x + shape.parameters.get(ArrowHorizontalShapeDescription_1.ArrowVerticalTriangleWidthParameterName).value), shape.normalizeY(shape.position.y + (shape.size.height - shape.parameters.get(ArrowHorizontalShapeDescription_1.ArrowVerticalLineHeightParameterName).value) / 2)))
        ];
    };
    return ArrowLeftRightShapeDescription;
}(ArrowHorizontalShapeDescription_1.ArrowHorizontalShapeDescription));
exports.ArrowLeftRightShapeDescription = ArrowLeftRightShapeDescription;


/***/ }),
/* 217 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.ArrowLeftShapeDescription = void 0;
var PathPrimitive_1 = __webpack_require__(5);
var ArrowHorizontalShapeDescription_1 = __webpack_require__(93);
var ShapeParameterPoint_1 = __webpack_require__(30);
var point_1 = __webpack_require__(0);
var ShapeTypes_1 = __webpack_require__(1);
var DiagramItem_1 = __webpack_require__(9);
var ArrowLeftShapeDescription = (function (_super) {
    __extends(ArrowLeftShapeDescription, _super);
    function ArrowLeftShapeDescription() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    Object.defineProperty(ArrowLeftShapeDescription.prototype, "key", {
        get: function () { return ShapeTypes_1.ShapeTypes.ArrowLeft; },
        enumerable: false,
        configurable: true
    });
    ArrowLeftShapeDescription.prototype.createShapePrimitives = function (shape) {
        var rect = shape.rectangle;
        var left = rect.x, top = rect.y, right = rect.right, bottom = rect.bottom, height = rect.height;
        var cy = rect.center.y;
        var p0dx = shape.parameters.get(ArrowHorizontalShapeDescription_1.ArrowVerticalTriangleWidthParameterName).value;
        var p1dy = (height - shape.parameters.get(ArrowHorizontalShapeDescription_1.ArrowVerticalLineHeightParameterName).value) / 2;
        var p0x1 = shape.normalizeX(left + p0dx);
        var p1y1 = shape.normalizeY(top + p1dy);
        var p1y2 = shape.normalizeY(bottom - p1dy);
        return [
            new PathPrimitive_1.PathPrimitive([
                new PathPrimitive_1.PathPrimitiveMoveToCommand(left, cy),
                new PathPrimitive_1.PathPrimitiveLineToCommand(p0x1, top),
                new PathPrimitive_1.PathPrimitiveLineToCommand(p0x1, p1y1),
                new PathPrimitive_1.PathPrimitiveLineToCommand(right, p1y1),
                new PathPrimitive_1.PathPrimitiveLineToCommand(right, p1y2),
                new PathPrimitive_1.PathPrimitiveLineToCommand(p0x1, p1y2),
                new PathPrimitive_1.PathPrimitiveLineToCommand(p0x1, bottom),
                new PathPrimitive_1.PathPrimitiveClosePathCommand()
            ], shape.style)
        ];
    };
    ArrowLeftShapeDescription.prototype.modifyParameters = function (shape, parameters, deltaX, deltaY) {
        this.changeParameterValue(parameters, ArrowHorizontalShapeDescription_1.ArrowVerticalTriangleWidthParameterName, function (p) { return p.value + deltaX; });
        this.changeParameterValue(parameters, ArrowHorizontalShapeDescription_1.ArrowVerticalLineHeightParameterName, function (p) { return p.value - deltaY * 2; });
        this.normalizeParameters(shape, parameters);
    };
    ArrowLeftShapeDescription.prototype.getParameterPoints = function (shape) {
        return [
            new ShapeParameterPoint_1.ShapeParameterPoint("c", new point_1.Point(shape.normalizeX(shape.position.x + shape.parameters.get(ArrowHorizontalShapeDescription_1.ArrowVerticalTriangleWidthParameterName).value), shape.normalizeY(shape.position.y + (shape.size.height - shape.parameters.get(ArrowHorizontalShapeDescription_1.ArrowVerticalLineHeightParameterName).value) / 2)))
        ];
    };
    ArrowLeftShapeDescription.prototype.processConnectionPoint = function (shape, point) {
        var triangleWidth = shape.parameters.get(ArrowHorizontalShapeDescription_1.ArrowVerticalTriangleWidthParameterName).value;
        if (point.x < shape.position.x + triangleWidth) {
            var tg = shape.size.height / 2 / triangleWidth;
            var delta = (shape.position.x + triangleWidth - point.x) * tg;
            var side = shape.getConnectionPointSide(point);
            if (side === DiagramItem_1.ConnectionPointSide.North)
                point.y += delta;
            else if (side === DiagramItem_1.ConnectionPointSide.South)
                point.y -= delta;
        }
        else
            _super.prototype.processConnectionPoint.call(this, shape, point);
    };
    return ArrowLeftShapeDescription;
}(ArrowHorizontalShapeDescription_1.ArrowHorizontalShapeDescription));
exports.ArrowLeftShapeDescription = ArrowLeftShapeDescription;


/***/ }),
/* 218 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.MultipleDocumentsShapeDescription = void 0;
var ShapeTypes_1 = __webpack_require__(1);
var PathPrimitive_1 = __webpack_require__(5);
var DocumentShapeDescription_1 = __webpack_require__(125);
var ClipPathPrimitive_1 = __webpack_require__(56);
var Utils_1 = __webpack_require__(17);
var ShapeDescription_1 = __webpack_require__(7);
var size_1 = __webpack_require__(2);
var MultipleDocumentsShapeDescription = (function (_super) {
    __extends(MultipleDocumentsShapeDescription, _super);
    function MultipleDocumentsShapeDescription() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    Object.defineProperty(MultipleDocumentsShapeDescription.prototype, "key", {
        get: function () { return ShapeTypes_1.ShapeTypes.MultipleDocuments; },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(MultipleDocumentsShapeDescription.prototype, "keepRatioOnAutoSize", {
        get: function () { return false; },
        enumerable: false,
        configurable: true
    });
    MultipleDocumentsShapeDescription.prototype.createShapePrimitives = function (shape, forToolbox) {
        var rect = shape.rectangle;
        var _a = shape.rectangle, width = _a.width, height = _a.height;
        var ratio = forToolbox ? MultipleDocumentsShapeDescription.documentsOffsetRatioForToolbox : MultipleDocumentsShapeDescription.documentsOffsetRatio;
        var documentOffsetX = Math.ceil(width * ratio);
        var documentOffsetY = Math.ceil(height * ratio);
        rect = rect.clone().inflate(-documentOffsetX, -documentOffsetY).clone().moveRectangle(-documentOffsetX, -documentOffsetY);
        var rect1 = rect.clone().moveRectangle(documentOffsetX, documentOffsetY);
        var rect2 = rect1.clone().moveRectangle(documentOffsetX, documentOffsetY);
        var clipPathId = Utils_1.RenderUtils.generateSvgElementId("clipRect");
        var primitives = [];
        return primitives
            .concat(this.createDocumentPrimitives(rect, shape.style, clipPathId + "1", rect1))
            .concat(this.createDocumentPrimitives(rect1, shape.style, clipPathId + "2", rect2))
            .concat(this.createDocumentPrimitives(rect2, shape.style));
    };
    MultipleDocumentsShapeDescription.prototype.createDocumentPrimitives = function (rect, style, clipPathId, clipRect) {
        var left = rect.x, top = rect.y, right = rect.right, bottom = rect.bottom, width = rect.width, height = rect.height;
        var cx = rect.center.x;
        var dy = height * DocumentShapeDescription_1.DocumentShapeDescription.curveOffsetRatio;
        var primitives = [];
        primitives = primitives.concat([
            new PathPrimitive_1.PathPrimitive([
                new PathPrimitive_1.PathPrimitiveMoveToCommand(left, top),
                new PathPrimitive_1.PathPrimitiveLineToCommand(right, top),
                new PathPrimitive_1.PathPrimitiveLineToCommand(right, bottom),
                new PathPrimitive_1.PathPrimitiveQuadraticCurveToCommand(right - width * 0.25, bottom - 2 * dy, cx, bottom - dy),
                new PathPrimitive_1.PathPrimitiveQuadraticCurveToCommand(left + width * 0.25, bottom + dy, left, bottom - dy),
                new PathPrimitive_1.PathPrimitiveClosePathCommand()
            ], style, undefined, clipRect && clipPathId)
        ]);
        if (clipRect && clipPathId)
            primitives = primitives.concat([
                new ClipPathPrimitive_1.ClipPathPrimitive(clipPathId, [
                    new PathPrimitive_1.PathPrimitive([
                        new PathPrimitive_1.PathPrimitiveMoveToCommand(left - style.strokeWidth, top - style.strokeWidth),
                        new PathPrimitive_1.PathPrimitiveLineToCommand(right + style.strokeWidth, top - style.strokeWidth),
                        new PathPrimitive_1.PathPrimitiveLineToCommand(right + style.strokeWidth, clipRect.y),
                        new PathPrimitive_1.PathPrimitiveLineToCommand(clipRect.x, clipRect.y),
                        new PathPrimitive_1.PathPrimitiveLineToCommand(clipRect.x, bottom + style.strokeWidth),
                        new PathPrimitive_1.PathPrimitiveLineToCommand(left - style.strokeWidth, bottom + style.strokeWidth),
                        new PathPrimitive_1.PathPrimitiveClosePathCommand()
                    ])
                ])
            ]);
        return primitives;
    };
    MultipleDocumentsShapeDescription.prototype.getTextRectangle = function (shape) {
        var rect = shape.rectangle;
        var documentOffsetX = rect.width * MultipleDocumentsShapeDescription.documentsOffsetRatio;
        var documentOffsetY = rect.height * MultipleDocumentsShapeDescription.documentsOffsetRatio;
        rect = rect.clone().inflate(-documentOffsetX, -documentOffsetY).clone().moveRectangle(-documentOffsetX, -documentOffsetY);
        var innerRect = rect.clone().moveRectangle(2 * documentOffsetX + ShapeDescription_1.ShapeTextPadding, 2 * documentOffsetY + ShapeDescription_1.ShapeTextPadding);
        return innerRect.clone().resize(-2 * ShapeDescription_1.ShapeTextPadding, -rect.height * DocumentShapeDescription_1.DocumentShapeDescription.curveOffsetRatio - 2 * ShapeDescription_1.ShapeTextPadding);
    };
    MultipleDocumentsShapeDescription.prototype.getSizeByText = function (textSize, _shape) {
        return new size_1.Size((textSize.width + 2 * ShapeDescription_1.ShapeTextPadding) / (1 - 2 * MultipleDocumentsShapeDescription.documentsOffsetRatio), (textSize.height + 2 * ShapeDescription_1.ShapeTextPadding) / ((1 - DocumentShapeDescription_1.DocumentShapeDescription.curveOffsetRatio) * (1 - MultipleDocumentsShapeDescription.documentsOffsetRatio)))
            .nonNegativeSize();
    };
    MultipleDocumentsShapeDescription.documentsOffsetRatio = 0.1;
    MultipleDocumentsShapeDescription.documentsOffsetRatioForToolbox = 0.16;
    return MultipleDocumentsShapeDescription;
}(DocumentShapeDescription_1.DocumentShapeDescription));
exports.MultipleDocumentsShapeDescription = MultipleDocumentsShapeDescription;


/***/ }),
/* 219 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.PreparationShapeDescription = void 0;
var ShapeTypes_1 = __webpack_require__(1);
var size_1 = __webpack_require__(2);
var ShapeDescription_1 = __webpack_require__(7);
var HexagonShapeDescription_1 = __webpack_require__(123);
var PreparationShapeDescription = (function (_super) {
    __extends(PreparationShapeDescription, _super);
    function PreparationShapeDescription() {
        var _this = _super.call(this, true) || this;
        _this.defaultSize = new size_1.Size(ShapeDescription_1.ShapeDefaultDimension, ShapeDescription_1.ShapeDefaultDimension * 0.75);
        return _this;
    }
    Object.defineProperty(PreparationShapeDescription.prototype, "key", {
        get: function () { return ShapeTypes_1.ShapeTypes.Preparation; },
        enumerable: false,
        configurable: true
    });
    return PreparationShapeDescription;
}(HexagonShapeDescription_1.HexagonShapeDescription));
exports.PreparationShapeDescription = PreparationShapeDescription;


/***/ }),
/* 220 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.HardDiskShapeDescription = void 0;
var RectangleShapeDescription_1 = __webpack_require__(19);
var ShapeTypes_1 = __webpack_require__(1);
var PathPrimitive_1 = __webpack_require__(5);
var EllipsePrimitive_1 = __webpack_require__(55);
var ShapeDescription_1 = __webpack_require__(7);
var size_1 = __webpack_require__(2);
var HardDiskShapeDescription = (function (_super) {
    __extends(HardDiskShapeDescription, _super);
    function HardDiskShapeDescription() {
        return _super.call(this, undefined, true) || this;
    }
    Object.defineProperty(HardDiskShapeDescription.prototype, "key", {
        get: function () { return ShapeTypes_1.ShapeTypes.HardDisk; },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(HardDiskShapeDescription.prototype, "keepRatioOnAutoSize", {
        get: function () { return false; },
        enumerable: false,
        configurable: true
    });
    HardDiskShapeDescription.prototype.createShapePrimitives = function (shape) {
        var rect = shape.rectangle;
        var left = rect.x, top = rect.y, right = rect.right, bottom = rect.bottom, width = rect.width;
        var cy = rect.center.y;
        var dx = width * HardDiskShapeDescription.arcWidthRatio;
        return [
            new PathPrimitive_1.PathPrimitive([
                new PathPrimitive_1.PathPrimitiveMoveToCommand(right - dx / 2, top),
                new PathPrimitive_1.PathPrimitiveLineToCommand(left + dx / 2, top),
                new PathPrimitive_1.PathPrimitiveArcToCommand(dx / 2, (bottom - top) / 2, 0, false, false, left + dx / 2, bottom),
                new PathPrimitive_1.PathPrimitiveLineToCommand(right - dx / 2, bottom),
            ], shape.style),
            new EllipsePrimitive_1.EllipsePrimitive(right - dx / 2, cy, dx / 2, (bottom - top) / 2, shape.style)
        ];
    };
    HardDiskShapeDescription.prototype.getTextRectangle = function (shape) {
        var rect = shape.rectangle;
        var dx = rect.width * HardDiskShapeDescription.arcWidthRatio * 1.5;
        return rect.clone()
            .resize(-dx - 2 * ShapeDescription_1.ShapeTextPadding, -2 * ShapeDescription_1.ShapeTextPadding)
            .moveRectangle(ShapeDescription_1.ShapeTextPadding, ShapeDescription_1.ShapeTextPadding)
            .nonNegativeSize();
    };
    HardDiskShapeDescription.prototype.getSizeByText = function (textSize, shape) {
        return new size_1.Size((textSize.width + ShapeDescription_1.ShapeTextPadding * 2) / (1 - 1.5 * HardDiskShapeDescription.arcWidthRatio), shape.size.height + ShapeDescription_1.ShapeTextPadding);
    };
    HardDiskShapeDescription.arcWidthRatio = 0.2;
    return HardDiskShapeDescription;
}(RectangleShapeDescription_1.RectangleShapeDescription));
exports.HardDiskShapeDescription = HardDiskShapeDescription;


/***/ }),
/* 221 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.DatabaseShapeDescription = void 0;
var RectangleShapeDescription_1 = __webpack_require__(19);
var ShapeTypes_1 = __webpack_require__(1);
var PathPrimitive_1 = __webpack_require__(5);
var EllipsePrimitive_1 = __webpack_require__(55);
var DatabaseShapeDescription = (function (_super) {
    __extends(DatabaseShapeDescription, _super);
    function DatabaseShapeDescription() {
        var _this = _super.call(this, undefined, true) || this;
        _this.defaultSize.width = _this.defaultSize.height;
        return _this;
    }
    Object.defineProperty(DatabaseShapeDescription.prototype, "key", {
        get: function () { return ShapeTypes_1.ShapeTypes.Database; },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(DatabaseShapeDescription.prototype, "keepRatioOnAutoSize", {
        get: function () { return false; },
        enumerable: false,
        configurable: true
    });
    DatabaseShapeDescription.prototype.createShapePrimitives = function (shape) {
        var rect = shape.rectangle;
        var left = rect.x, top = rect.y, right = rect.right, bottom = rect.bottom, height = rect.height;
        var cx = rect.center.x;
        var dy = height * DatabaseShapeDescription.arcWidthRatio;
        return [
            new PathPrimitive_1.PathPrimitive([
                new PathPrimitive_1.PathPrimitiveMoveToCommand(right, top + dy / 2),
                new PathPrimitive_1.PathPrimitiveLineToCommand(right, bottom - dy / 2),
                new PathPrimitive_1.PathPrimitiveArcToCommand((right - left) / 2, dy / 2, 0, false, true, left, bottom - dy / 2),
                new PathPrimitive_1.PathPrimitiveLineToCommand(left, top + dy / 2),
            ], shape.style),
            new EllipsePrimitive_1.EllipsePrimitive(cx, top + dy / 2, (right - left) / 2, dy / 2, shape.style)
        ];
    };
    DatabaseShapeDescription.prototype.getTextRectangle = function (shape) {
        var rect = shape.rectangle;
        var dy = rect.height * DatabaseShapeDescription.arcWidthRatio;
        return rect.clone().resize(0, -dy).clone().moveRectangle(0, dy);
    };
    DatabaseShapeDescription.arcWidthRatio = 0.2;
    return DatabaseShapeDescription;
}(RectangleShapeDescription_1.RectangleShapeDescription));
exports.DatabaseShapeDescription = DatabaseShapeDescription;


/***/ }),
/* 222 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.InternalStorageShapeDescription = exports.InternalStorageVerticalEdgeParameterName = exports.InternalStorageHorizontalEdgeParameterName = void 0;
var RectangleShapeDescription_1 = __webpack_require__(19);
var ShapeTypes_1 = __webpack_require__(1);
var ShapeParameters_1 = __webpack_require__(37);
var ShapeParameterPoint_1 = __webpack_require__(30);
var point_1 = __webpack_require__(0);
var PathPrimitive_1 = __webpack_require__(5);
exports.InternalStorageHorizontalEdgeParameterName = "he";
exports.InternalStorageVerticalEdgeParameterName = "ve";
var InternalStorageShapeDescription = (function (_super) {
    __extends(InternalStorageShapeDescription, _super);
    function InternalStorageShapeDescription() {
        return _super.call(this, undefined, true) || this;
    }
    Object.defineProperty(InternalStorageShapeDescription.prototype, "key", {
        get: function () { return ShapeTypes_1.ShapeTypes.InternalStorage; },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(InternalStorageShapeDescription.prototype, "keepRatioOnAutoSize", {
        get: function () { return false; },
        enumerable: false,
        configurable: true
    });
    InternalStorageShapeDescription.prototype.createShapePrimitives = function (shape) {
        var rect = shape.rectangle;
        var left = rect.x, top = rect.y, right = rect.right, bottom = rect.bottom;
        var x = left + shape.parameters.get(exports.InternalStorageHorizontalEdgeParameterName).value;
        var y = top + shape.parameters.get(exports.InternalStorageVerticalEdgeParameterName).value;
        var primitives = _super.prototype.createShapePrimitives.call(this, shape);
        return primitives.concat([
            new PathPrimitive_1.PathPrimitive([
                new PathPrimitive_1.PathPrimitiveMoveToCommand(x, top),
                new PathPrimitive_1.PathPrimitiveLineToCommand(x, bottom),
                new PathPrimitive_1.PathPrimitiveMoveToCommand(left, y),
                new PathPrimitive_1.PathPrimitiveLineToCommand(right, y)
            ], shape.style)
        ]);
    };
    InternalStorageShapeDescription.prototype.createParameters = function (parameters) {
        parameters.addRange([
            new ShapeParameters_1.ShapeParameter(exports.InternalStorageHorizontalEdgeParameterName, this.defaultSize.width * 0.1),
            new ShapeParameters_1.ShapeParameter(exports.InternalStorageVerticalEdgeParameterName, this.defaultSize.width * 0.1)
        ]);
    };
    InternalStorageShapeDescription.prototype.normalizeParameters = function (shape, parameters) {
        this.changeParameterValue(parameters, exports.InternalStorageHorizontalEdgeParameterName, function (p) { return Math.max(InternalStorageShapeDescription.minEdge, Math.min(shape.size.width * 0.3, p.value)); });
        this.changeParameterValue(parameters, exports.InternalStorageVerticalEdgeParameterName, function (p) { return Math.max(InternalStorageShapeDescription.minEdge, Math.min(shape.size.height * 0.3, p.value)); });
    };
    InternalStorageShapeDescription.prototype.modifyParameters = function (shape, parameters, deltaX, deltaY) {
        this.changeParameterValue(parameters, exports.InternalStorageHorizontalEdgeParameterName, function (p) { return p.value + deltaX; });
        this.changeParameterValue(parameters, exports.InternalStorageVerticalEdgeParameterName, function (p) { return p.value + deltaY; });
        this.normalizeParameters(shape, parameters);
    };
    InternalStorageShapeDescription.prototype.getParameterPoints = function (shape) {
        return [
            new ShapeParameterPoint_1.ShapeParameterPoint("c", new point_1.Point(shape.normalizeX(shape.position.x + shape.parameters.get(exports.InternalStorageHorizontalEdgeParameterName).value), shape.normalizeY(shape.position.y + shape.parameters.get(exports.InternalStorageVerticalEdgeParameterName).value)))
        ];
    };
    InternalStorageShapeDescription.prototype.getTextRectangle = function (shape) {
        var rect = shape.rectangle;
        var dx = shape.parameters.get(exports.InternalStorageHorizontalEdgeParameterName).value;
        return rect.clone().resize(-dx, 0).clone().moveRectangle(dx, 0);
    };
    InternalStorageShapeDescription.minEdge = 72;
    return InternalStorageShapeDescription;
}(RectangleShapeDescription_1.RectangleShapeDescription));
exports.InternalStorageShapeDescription = InternalStorageShapeDescription;


/***/ }),
/* 223 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.PaperTapeShapeDescription = void 0;
var RectangleShapeDescription_1 = __webpack_require__(19);
var ShapeTypes_1 = __webpack_require__(1);
var PathPrimitive_1 = __webpack_require__(5);
var DiagramItem_1 = __webpack_require__(9);
var ShapeDescription_1 = __webpack_require__(7);
var size_1 = __webpack_require__(2);
var PaperTapeShapeDescription = (function (_super) {
    __extends(PaperTapeShapeDescription, _super);
    function PaperTapeShapeDescription() {
        return _super.call(this, undefined, true) || this;
    }
    Object.defineProperty(PaperTapeShapeDescription.prototype, "key", {
        get: function () { return ShapeTypes_1.ShapeTypes.PaperTape; },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(PaperTapeShapeDescription.prototype, "keepRatioOnAutoSize", {
        get: function () { return false; },
        enumerable: false,
        configurable: true
    });
    PaperTapeShapeDescription.prototype.createShapePrimitives = function (shape) {
        return this.createDocumentPrimitives(shape.rectangle, shape.style);
    };
    PaperTapeShapeDescription.prototype.createDocumentPrimitives = function (rect, style) {
        var left = rect.x, top = rect.y, right = rect.right, bottom = rect.bottom, width = rect.width, height = rect.height;
        var cx = rect.center.x;
        var dy = height * PaperTapeShapeDescription.curveOffsetRatio;
        var primitives = [];
        return primitives.concat([
            new PathPrimitive_1.PathPrimitive([
                new PathPrimitive_1.PathPrimitiveMoveToCommand(left, top),
                new PathPrimitive_1.PathPrimitiveQuadraticCurveToCommand(left + width * 0.25, top + 2 * dy, cx, top + dy),
                new PathPrimitive_1.PathPrimitiveQuadraticCurveToCommand(right - width * 0.25, top - dy, right, top + dy),
                new PathPrimitive_1.PathPrimitiveLineToCommand(right, bottom),
                new PathPrimitive_1.PathPrimitiveQuadraticCurveToCommand(right - width * 0.25, bottom - 2 * dy, cx, bottom - dy),
                new PathPrimitive_1.PathPrimitiveQuadraticCurveToCommand(left + width * 0.25, bottom + dy, left, bottom - dy),
                new PathPrimitive_1.PathPrimitiveClosePathCommand()
            ], style)
        ]);
    };
    PaperTapeShapeDescription.prototype.processConnectionPoint = function (shape, point) {
        var side = shape.getConnectionPointSide(point);
        if (side === DiagramItem_1.ConnectionPointSide.North)
            point.y += shape.size.height * PaperTapeShapeDescription.curveOffsetRatio;
        if (side === DiagramItem_1.ConnectionPointSide.South)
            point.y -= shape.size.height * PaperTapeShapeDescription.curveOffsetRatio;
    };
    PaperTapeShapeDescription.prototype.getTextRectangle = function (shape) {
        var rect = shape.rectangle;
        return rect.clone().inflate(ShapeDescription_1.ShapeTextPadding, -rect.height * PaperTapeShapeDescription.curveOffsetRatio);
    };
    PaperTapeShapeDescription.prototype.getSizeByText = function (textSize, _shape) {
        return new size_1.Size(textSize.width + ShapeDescription_1.ShapeTextPadding * 2, textSize.height / (1 - 2 * PaperTapeShapeDescription.curveOffsetRatio));
    };
    PaperTapeShapeDescription.curveOffsetRatio = 0.1;
    return PaperTapeShapeDescription;
}(RectangleShapeDescription_1.RectangleShapeDescription));
exports.PaperTapeShapeDescription = PaperTapeShapeDescription;


/***/ }),
/* 224 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.ManualOperationShapeDescription = void 0;
var RectangleShapeDescription_1 = __webpack_require__(19);
var ShapeTypes_1 = __webpack_require__(1);
var PathPrimitive_1 = __webpack_require__(5);
var DiagramItem_1 = __webpack_require__(9);
var ShapeDescription_1 = __webpack_require__(7);
var ManualOperationShapeDescription = (function (_super) {
    __extends(ManualOperationShapeDescription, _super);
    function ManualOperationShapeDescription() {
        return _super.call(this, undefined, true) || this;
    }
    Object.defineProperty(ManualOperationShapeDescription.prototype, "key", {
        get: function () { return ShapeTypes_1.ShapeTypes.ManualOperation; },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(ManualOperationShapeDescription.prototype, "keepRatioOnAutoSize", {
        get: function () { return false; },
        enumerable: false,
        configurable: true
    });
    ManualOperationShapeDescription.prototype.createShapePrimitives = function (shape) {
        var rect = shape.rectangle;
        var _a = shape.rectangle, left = _a.x, top = _a.y, right = _a.right, bottom = _a.bottom, width = _a.width, height = _a.height;
        var px = Math.min(Math.max(0, height / Math.tan(ManualOperationShapeDescription.slopeAngle)), width);
        var cx = rect.center.x;
        var x1 = Math.min(left + px, cx);
        var x2 = Math.max(right - px, cx);
        return [
            new PathPrimitive_1.PathPrimitive([
                new PathPrimitive_1.PathPrimitiveMoveToCommand(left, top),
                new PathPrimitive_1.PathPrimitiveLineToCommand(right, top),
                new PathPrimitive_1.PathPrimitiveLineToCommand(x2, bottom),
                new PathPrimitive_1.PathPrimitiveLineToCommand(x1, bottom),
                new PathPrimitive_1.PathPrimitiveClosePathCommand()
            ], shape.style)
        ];
    };
    ManualOperationShapeDescription.prototype.processConnectionPoint = function (shape, point) {
        var offset = shape.size.height / Math.tan(ManualOperationShapeDescription.slopeAngle);
        var side = shape.getConnectionPointSide(point);
        if (side === DiagramItem_1.ConnectionPointSide.East)
            point.x -= offset / 2;
        else if (side === DiagramItem_1.ConnectionPointSide.West)
            point.x += offset / 2;
    };
    ManualOperationShapeDescription.prototype.getTextRectangle = function (shape) {
        var px = Math.min(Math.max(0, shape.size.height / Math.tan(ManualOperationShapeDescription.slopeAngle)), shape.size.width);
        return shape.rectangle.clone()
            .moveRectangle(px, ShapeDescription_1.ShapeTextPadding)
            .resize(-px * 2, -ShapeDescription_1.ShapeTextPadding * 2)
            .nonNegativeSize();
    };
    ManualOperationShapeDescription.slopeAngle = 81 * Math.PI / 180;
    return ManualOperationShapeDescription;
}(RectangleShapeDescription_1.RectangleShapeDescription));
exports.ManualOperationShapeDescription = ManualOperationShapeDescription;


/***/ }),
/* 225 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.DelayShapeDescription = void 0;
var RectangleShapeDescription_1 = __webpack_require__(19);
var ShapeTypes_1 = __webpack_require__(1);
var PathPrimitive_1 = __webpack_require__(5);
var Utils_1 = __webpack_require__(3);
var ShapeDescription_1 = __webpack_require__(7);
var size_1 = __webpack_require__(2);
var DelayShapeDescription = (function (_super) {
    __extends(DelayShapeDescription, _super);
    function DelayShapeDescription() {
        var _this = _super.call(this, undefined, true) || this;
        _this.defaultSize.width = _this.defaultSize.height;
        return _this;
    }
    Object.defineProperty(DelayShapeDescription.prototype, "key", {
        get: function () { return ShapeTypes_1.ShapeTypes.Delay; },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(DelayShapeDescription.prototype, "keepRatioOnAutoSize", {
        get: function () { return false; },
        enumerable: false,
        configurable: true
    });
    DelayShapeDescription.prototype.createShapePrimitives = function (shape) {
        var rect = shape.rectangle;
        var left = rect.x, top = rect.y, right = rect.right, bottom = rect.bottom;
        var cx = rect.center.x;
        return [
            new PathPrimitive_1.PathPrimitive([
                new PathPrimitive_1.PathPrimitiveMoveToCommand(left, top),
                new PathPrimitive_1.PathPrimitiveLineToCommand(cx, top),
                new PathPrimitive_1.PathPrimitiveArcToCommand((right - left) / 2, (bottom - top) / 2, 0, false, true, cx, bottom),
                new PathPrimitive_1.PathPrimitiveLineToCommand(left, bottom),
                new PathPrimitive_1.PathPrimitiveClosePathCommand()
            ], shape.style)
        ];
    };
    DelayShapeDescription.prototype.getTextRectangle = function (shape) {
        var maxRectInEllipse = Utils_1.GeometryUtils.getMaxRectangleEnscribedInEllipse(shape.size);
        return shape.rectangle.clone().moveRectangle(ShapeDescription_1.ShapeTextPadding, ShapeDescription_1.ShapeTextPadding)
            .setSize({
            width: maxRectInEllipse.width / 2 + shape.size.width / 2 - ShapeDescription_1.ShapeTextPadding,
            height: maxRectInEllipse.height / 2 + shape.size.height / 2 - ShapeDescription_1.ShapeTextPadding
        }).nonNegativeSize();
    };
    DelayShapeDescription.prototype.getSizeByText = function (textSize, _shape) {
        var rectByEllipse = Utils_1.GeometryUtils.getEllipseByEnscribedRectangle(textSize);
        return new size_1.Size(rectByEllipse.width / 2 + textSize.width / 2 + ShapeDescription_1.ShapeTextPadding, rectByEllipse.height / 2 + textSize.height / 2 + ShapeDescription_1.ShapeTextPadding);
    };
    DelayShapeDescription.arcWidthRatio = 0.2;
    return DelayShapeDescription;
}(RectangleShapeDescription_1.RectangleShapeDescription));
exports.DelayShapeDescription = DelayShapeDescription;


/***/ }),
/* 226 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.StoredDataShapeDescription = void 0;
var RectangleShapeDescription_1 = __webpack_require__(19);
var ShapeTypes_1 = __webpack_require__(1);
var PathPrimitive_1 = __webpack_require__(5);
var ShapeDescription_1 = __webpack_require__(7);
var size_1 = __webpack_require__(2);
var StoredDataShapeDescription = (function (_super) {
    __extends(StoredDataShapeDescription, _super);
    function StoredDataShapeDescription() {
        return _super.call(this, undefined, true) || this;
    }
    Object.defineProperty(StoredDataShapeDescription.prototype, "key", {
        get: function () { return ShapeTypes_1.ShapeTypes.StoredData; },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(StoredDataShapeDescription.prototype, "keepRatioOnAutoSize", {
        get: function () { return false; },
        enumerable: false,
        configurable: true
    });
    StoredDataShapeDescription.prototype.createShapePrimitives = function (shape) {
        var rect = shape.rectangle;
        var left = rect.x, top = rect.y, right = rect.right, bottom = rect.bottom, width = rect.width;
        var dx = width * StoredDataShapeDescription.arcWidthRatio;
        return [
            new PathPrimitive_1.PathPrimitive([
                new PathPrimitive_1.PathPrimitiveMoveToCommand(right, top),
                new PathPrimitive_1.PathPrimitiveLineToCommand(left + dx / 2, top),
                new PathPrimitive_1.PathPrimitiveArcToCommand(dx / 2, (bottom - top) / 2, 0, false, false, left + dx / 2, bottom),
                new PathPrimitive_1.PathPrimitiveLineToCommand(right, bottom),
                new PathPrimitive_1.PathPrimitiveArcToCommand(dx / 2, (bottom - top) / 2, 0, false, true, right, top)
            ], shape.style)
        ];
    };
    StoredDataShapeDescription.prototype.getTextRectangle = function (shape) {
        var rect = shape.rectangle;
        var dx = rect.width * StoredDataShapeDescription.arcWidthRatio / 2;
        return rect.clone()
            .resize(-dx - 2 * ShapeDescription_1.ShapeTextPadding, -2 * ShapeDescription_1.ShapeTextPadding)
            .moveRectangle(ShapeDescription_1.ShapeTextPadding, ShapeDescription_1.ShapeTextPadding)
            .nonNegativeSize();
    };
    StoredDataShapeDescription.prototype.getSizeByText = function (textSize, _shape) {
        return new size_1.Size((textSize.width + 2 * ShapeDescription_1.ShapeTextPadding) / (1 - StoredDataShapeDescription.arcWidthRatio / 2), textSize.height + 2 * ShapeDescription_1.ShapeTextPadding);
    };
    StoredDataShapeDescription.arcWidthRatio = 0.2;
    return StoredDataShapeDescription;
}(RectangleShapeDescription_1.RectangleShapeDescription));
exports.StoredDataShapeDescription = StoredDataShapeDescription;


/***/ }),
/* 227 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.MergeShapeDescription = void 0;
var ShapeTypes_1 = __webpack_require__(1);
var rectangle_1 = __webpack_require__(13);
var TriangleShapeDescription_1 = __webpack_require__(124);
var PathPrimitive_1 = __webpack_require__(5);
var ShapeDescription_1 = __webpack_require__(7);
var size_1 = __webpack_require__(2);
var MergeShapeDescription = (function (_super) {
    __extends(MergeShapeDescription, _super);
    function MergeShapeDescription() {
        return _super.call(this, true) || this;
    }
    Object.defineProperty(MergeShapeDescription.prototype, "key", {
        get: function () { return ShapeTypes_1.ShapeTypes.Merge; },
        enumerable: false,
        configurable: true
    });
    MergeShapeDescription.prototype.createShapePrimitives = function (shape) {
        var rect = shape.rectangle;
        var left = rect.x, top = rect.y, right = rect.right, bottom = rect.bottom;
        return [
            new PathPrimitive_1.PathPrimitive([
                new PathPrimitive_1.PathPrimitiveMoveToCommand(left, top),
                new PathPrimitive_1.PathPrimitiveLineToCommand(right, top),
                new PathPrimitive_1.PathPrimitiveLineToCommand(rect.center.x, bottom),
                new PathPrimitive_1.PathPrimitiveClosePathCommand()
            ], shape.style)
        ];
    };
    MergeShapeDescription.prototype.calculateHeight = function (width) {
        return width * 0.75;
    };
    MergeShapeDescription.prototype.getTextRectangle = function (shape) {
        return rectangle_1.Rectangle.fromGeometry(shape.position.clone().offset(shape.size.width / 4, ShapeDescription_1.ShapeTextPadding), new size_1.Size(shape.size.width / 2, shape.size.height / 2 - ShapeDescription_1.ShapeTextPadding));
    };
    MergeShapeDescription.prototype.getSizeByText = function (textSize, _shape) {
        return new size_1.Size(textSize.width * 2, (textSize.height + ShapeDescription_1.ShapeTextPadding) * 2);
    };
    return MergeShapeDescription;
}(TriangleShapeDescription_1.TriangleShapeDescription));
exports.MergeShapeDescription = MergeShapeDescription;


/***/ }),
/* 228 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.DisplayShapeDescription = void 0;
var RectangleShapeDescription_1 = __webpack_require__(19);
var ShapeTypes_1 = __webpack_require__(1);
var PathPrimitive_1 = __webpack_require__(5);
var ShapeDescription_1 = __webpack_require__(7);
var DisplayShapeDescription = (function (_super) {
    __extends(DisplayShapeDescription, _super);
    function DisplayShapeDescription() {
        return _super.call(this, undefined, true) || this;
    }
    Object.defineProperty(DisplayShapeDescription.prototype, "key", {
        get: function () { return ShapeTypes_1.ShapeTypes.Display; },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(DisplayShapeDescription.prototype, "keepRatioOnAutoSize", {
        get: function () { return false; },
        enumerable: false,
        configurable: true
    });
    DisplayShapeDescription.prototype.createShapePrimitives = function (shape) {
        var rect = shape.rectangle;
        var left = rect.x, top = rect.y, right = rect.right, bottom = rect.bottom, width = rect.width;
        var cy = rect.center.y;
        var dx = width * DisplayShapeDescription.arcWidthRatio;
        return [
            new PathPrimitive_1.PathPrimitive([
                new PathPrimitive_1.PathPrimitiveMoveToCommand(right - dx / 2, top),
                new PathPrimitive_1.PathPrimitiveLineToCommand(left + dx / 2, top),
                new PathPrimitive_1.PathPrimitiveLineToCommand(left, cy),
                new PathPrimitive_1.PathPrimitiveLineToCommand(left + dx / 2, bottom),
                new PathPrimitive_1.PathPrimitiveLineToCommand(right - dx / 2, bottom),
                new PathPrimitive_1.PathPrimitiveArcToCommand(dx / 2, (bottom - top) / 2, 0, false, false, right - dx / 2, top)
            ], shape.style),
        ];
    };
    DisplayShapeDescription.prototype.getTextRectangle = function (shape) {
        var dx = shape.size.width * DisplayShapeDescription.arcWidthRatio;
        return shape.rectangle
            .clone()
            .moveRectangle(dx / 2, ShapeDescription_1.ShapeTextPadding)
            .resize(-dx, -ShapeDescription_1.ShapeTextPadding * 2)
            .nonNegativeSize();
    };
    DisplayShapeDescription.arcWidthRatio = 0.2;
    return DisplayShapeDescription;
}(RectangleShapeDescription_1.RectangleShapeDescription));
exports.DisplayShapeDescription = DisplayShapeDescription;


/***/ }),
/* 229 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.OrShapeDescription = void 0;
var ShapeTypes_1 = __webpack_require__(1);
var size_1 = __webpack_require__(2);
var ShapeDescription_1 = __webpack_require__(7);
var EllipseShapeDescription_1 = __webpack_require__(72);
var PathPrimitive_1 = __webpack_require__(5);
var OrShapeDescription = (function (_super) {
    __extends(OrShapeDescription, _super);
    function OrShapeDescription() {
        var _this = _super.call(this, true) || this;
        _this.defaultSize = new size_1.Size(ShapeDescription_1.ShapeDefaultDimension * 0.5, ShapeDescription_1.ShapeDefaultDimension * 0.5);
        return _this;
    }
    Object.defineProperty(OrShapeDescription.prototype, "key", {
        get: function () { return ShapeTypes_1.ShapeTypes.Or; },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(OrShapeDescription.prototype, "keepRatioOnAutoSize", {
        get: function () { return true; },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(OrShapeDescription.prototype, "enableText", {
        get: function () { return false; },
        enumerable: false,
        configurable: true
    });
    OrShapeDescription.prototype.createShapePrimitives = function (shape) {
        var rect = shape.rectangle;
        var left = rect.x, top = rect.y, right = rect.right, bottom = rect.bottom;
        var _a = rect.center, cx = _a.x, cy = _a.y;
        var primitives = [];
        return primitives
            .concat(_super.prototype.createShapePrimitives.call(this, shape))
            .concat([
            new PathPrimitive_1.PathPrimitive([
                new PathPrimitive_1.PathPrimitiveMoveToCommand(cx, top),
                new PathPrimitive_1.PathPrimitiveLineToCommand(cx, bottom),
                new PathPrimitive_1.PathPrimitiveMoveToCommand(left, cy),
                new PathPrimitive_1.PathPrimitiveLineToCommand(right, cy)
            ], shape.style)
        ]);
    };
    return OrShapeDescription;
}(EllipseShapeDescription_1.EllipseShapeDescription));
exports.OrShapeDescription = OrShapeDescription;


/***/ }),
/* 230 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.SummingJunctionShapeDescription = void 0;
var ShapeTypes_1 = __webpack_require__(1);
var size_1 = __webpack_require__(2);
var ShapeDescription_1 = __webpack_require__(7);
var EllipseShapeDescription_1 = __webpack_require__(72);
var PathPrimitive_1 = __webpack_require__(5);
var SummingJunctionShapeDescription = (function (_super) {
    __extends(SummingJunctionShapeDescription, _super);
    function SummingJunctionShapeDescription() {
        var _this = _super.call(this, true) || this;
        _this.defaultSize = new size_1.Size(ShapeDescription_1.ShapeDefaultDimension * 0.5, ShapeDescription_1.ShapeDefaultDimension * 0.5);
        return _this;
    }
    Object.defineProperty(SummingJunctionShapeDescription.prototype, "key", {
        get: function () { return ShapeTypes_1.ShapeTypes.SummingJunction; },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SummingJunctionShapeDescription.prototype, "keepRatioOnAutoSize", {
        get: function () { return true; },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SummingJunctionShapeDescription.prototype, "enableText", {
        get: function () { return false; },
        enumerable: false,
        configurable: true
    });
    SummingJunctionShapeDescription.prototype.createShapePrimitives = function (shape) {
        var rect = shape.rectangle;
        var width = rect.width, height = rect.height;
        var _a = rect.center, cx = _a.x, cy = _a.y;
        var rx = width / 2;
        var ry = height / 2;
        var angle = Math.atan(ry / rx);
        var ex = 1 / Math.sqrt(1 / Math.pow(rx, 2) + Math.pow(Math.tan(angle), 2) / Math.pow(ry, 2));
        var ey = ex * Math.tan(angle);
        var primitives = [];
        return primitives
            .concat(_super.prototype.createShapePrimitives.call(this, shape))
            .concat([
            new PathPrimitive_1.PathPrimitive([
                new PathPrimitive_1.PathPrimitiveMoveToCommand(cx - ex, cy - ey),
                new PathPrimitive_1.PathPrimitiveLineToCommand(cx + ex, cy + ey),
                new PathPrimitive_1.PathPrimitiveMoveToCommand(cx - ex, cy + ey),
                new PathPrimitive_1.PathPrimitiveLineToCommand(cx + ex, cy - ey)
            ], shape.style)
        ]);
    };
    return SummingJunctionShapeDescription;
}(EllipseShapeDescription_1.EllipseShapeDescription));
exports.SummingJunctionShapeDescription = SummingJunctionShapeDescription;


/***/ }),
/* 231 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.SvgElementPrimitive = void 0;
var RenderHelper_1 = __webpack_require__(15);
var Primitive_1 = __webpack_require__(24);
var SvgElementPrimitive = (function (_super) {
    __extends(SvgElementPrimitive, _super);
    function SvgElementPrimitive(x, y, width, height, createContent, destroyContent, data, className, onApplyProperties) {
        var _this = _super.call(this, null, className, undefined, onApplyProperties) || this;
        _this.x = x;
        _this.y = y;
        _this.width = width;
        _this.height = height;
        _this.createContent = createContent;
        _this.destroyContent = destroyContent;
        _this.data = data;
        return _this;
    }
    SvgElementPrimitive.prototype.createMainElement = function () {
        return document.createElementNS(RenderHelper_1.svgNS, "svg");
    };
    SvgElementPrimitive.prototype.applyElementProperties = function (element, measurer) {
        this.setUnitAttribute(element, "x", this.x);
        this.setUnitAttribute(element, "y", this.y);
        this.setUnitAttribute(element, "width", this.width);
        this.setUnitAttribute(element, "height", this.height);
        this.setPositionCorrectionAttribute(element);
        _super.prototype.applyElementProperties.call(this, element, measurer);
    };
    SvgElementPrimitive.prototype.createCustomContent = function (parent) {
        if (this.createContent)
            this.createContent(parent, this.data);
    };
    SvgElementPrimitive.prototype.destroyCustomContent = function (parent) {
        if (this.destroyContent)
            this.destroyContent(parent);
    };
    return SvgElementPrimitive;
}(Primitive_1.SvgPrimitive));
exports.SvgElementPrimitive = SvgElementPrimitive;


/***/ }),
/* 232 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.VerticalContainerDescription = void 0;
var point_1 = __webpack_require__(0);
var size_1 = __webpack_require__(2);
var RectaglePrimitive_1 = __webpack_require__(21);
var rectangle_1 = __webpack_require__(13);
var ShapeTypes_1 = __webpack_require__(1);
var ShapeDescription_1 = __webpack_require__(7);
var ContainerDescription_1 = __webpack_require__(131);
var VerticalContainerDescription = (function (_super) {
    __extends(VerticalContainerDescription, _super);
    function VerticalContainerDescription() {
        return _super.call(this, new size_1.Size(ShapeDescription_1.ShapeDefaultDimension * 2, ShapeDescription_1.ShapeDefaultDimension * 1.5)) || this;
    }
    Object.defineProperty(VerticalContainerDescription.prototype, "key", {
        get: function () { return ShapeTypes_1.ShapeTypes.VerticalContainer; },
        enumerable: false,
        configurable: true
    });
    VerticalContainerDescription.prototype.getExpandedSize = function (shape) {
        return new size_1.Size(shape.size.width, shape.expandedSize.height);
    };
    VerticalContainerDescription.prototype.getCollapsedSize = function (shape) {
        return new size_1.Size(shape.size.width, ContainerDescription_1.CONTAINER_HEADER_SIZE + 2 * shape.strokeWidth);
    };
    VerticalContainerDescription.prototype.allowResizeVertically = function (shape) {
        return shape.expanded;
    };
    VerticalContainerDescription.prototype.createHeaderPrimitives = function (shape, forToolbox) {
        var rect = shape.rectangle;
        var left = rect.x, top = rect.y, width = rect.width;
        var headerSize = this.getHeaderSize(shape, forToolbox);
        var primitives = [];
        primitives = primitives.concat([
            new RectaglePrimitive_1.RectanglePrimitive(left, top, width, headerSize, shape.style)
        ]);
        if (!forToolbox)
            primitives = primitives.concat(this.createExpandButtonPrimitives(shape, new rectangle_1.Rectangle(left, top, headerSize, headerSize)));
        return primitives;
    };
    VerticalContainerDescription.prototype.getClientRectangle = function (shape) {
        var rect = shape.rectangle;
        var headerSize = this.getHeaderSize(shape);
        return rectangle_1.Rectangle.fromGeometry(new point_1.Point(rect.x, rect.y + headerSize), new size_1.Size(rect.width, rect.height - headerSize));
    };
    VerticalContainerDescription.prototype.getTextRectangle = function (shape) {
        var rect = shape.rectangle;
        var headerSize = this.getHeaderSize(shape);
        return rectangle_1.Rectangle.fromGeometry(new point_1.Point(rect.x + headerSize, rect.y), new size_1.Size(rect.width - headerSize, headerSize));
    };
    VerticalContainerDescription.prototype.getSizeByText = function (textSize, shape) {
        var headerSize = this.getHeaderSize(shape);
        return new size_1.Size(Math.max(shape.size.width, textSize.width + headerSize), shape.size.height);
    };
    VerticalContainerDescription.prototype.getHeaderSize = function (shape, forToolbox) {
        var rect = shape.rectangle;
        return forToolbox ? rect.height * ContainerDescription_1.CONTAINER_HEADER_TOOLBOX_SIZE_RATIO : (ContainerDescription_1.CONTAINER_HEADER_SIZE + 2 * shape.strokeWidth);
    };
    return VerticalContainerDescription;
}(ContainerDescription_1.ContainerDescription));
exports.VerticalContainerDescription = VerticalContainerDescription;


/***/ }),
/* 233 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.HorizontalContainerDescription = void 0;
var ShapeDescription_1 = __webpack_require__(7);
var rectangle_1 = __webpack_require__(13);
var size_1 = __webpack_require__(2);
var point_1 = __webpack_require__(0);
var ShapeTypes_1 = __webpack_require__(1);
var ContainerDescription_1 = __webpack_require__(131);
var RectaglePrimitive_1 = __webpack_require__(21);
var TextPrimitive_1 = __webpack_require__(63);
var HorizontalContainerDescription = (function (_super) {
    __extends(HorizontalContainerDescription, _super);
    function HorizontalContainerDescription() {
        return _super.call(this, new size_1.Size(ShapeDescription_1.ShapeDefaultDimension * 2, ShapeDescription_1.ShapeDefaultDimension * 1.5)) || this;
    }
    Object.defineProperty(HorizontalContainerDescription.prototype, "key", {
        get: function () { return ShapeTypes_1.ShapeTypes.HorizontalContainer; },
        enumerable: false,
        configurable: true
    });
    HorizontalContainerDescription.prototype.getExpandedSize = function (shape) {
        return new size_1.Size(shape.expandedSize.width, shape.size.height);
    };
    HorizontalContainerDescription.prototype.getCollapsedSize = function (shape) {
        return new size_1.Size(ContainerDescription_1.CONTAINER_HEADER_SIZE + 2 * shape.strokeWidth, shape.size.height);
    };
    HorizontalContainerDescription.prototype.allowResizeHorizontally = function (shape) {
        return shape.expanded;
    };
    HorizontalContainerDescription.prototype.createHeaderPrimitives = function (shape, forToolbox) {
        var rect = shape.rectangle;
        var left = rect.x, top = rect.y, height = rect.height;
        var headerSize = this.getHeaderSize(shape, forToolbox);
        var primitives = [];
        primitives = primitives.concat([
            new RectaglePrimitive_1.RectanglePrimitive(left, top, headerSize, height, shape.style)
        ]);
        if (!forToolbox)
            primitives = primitives.concat(this.createExpandButtonPrimitives(shape, new rectangle_1.Rectangle(left, top, headerSize, headerSize)));
        return primitives;
    };
    HorizontalContainerDescription.prototype.getClientRectangle = function (shape) {
        var rect = shape.rectangle;
        var headerSize = this.getHeaderSize(shape);
        return rectangle_1.Rectangle.fromGeometry(new point_1.Point(rect.x + headerSize, rect.y), new size_1.Size(rect.width - headerSize, rect.height));
    };
    HorizontalContainerDescription.prototype.getTextRectangle = function (shape) {
        var rect = shape.rectangle;
        var headerSize = this.getHeaderSize(shape);
        return rectangle_1.Rectangle.fromGeometry(new point_1.Point(rect.x, rect.y + headerSize), new size_1.Size(headerSize, rect.height - headerSize))
            .nonNegativeSize();
    };
    HorizontalContainerDescription.prototype.getSizeByText = function (textSize, shape) {
        var headerSize = this.getHeaderSize(shape);
        return new size_1.Size(shape.size.width, Math.max(shape.size.height, Math.max(textSize.width + headerSize, shape.size.height)));
    };
    HorizontalContainerDescription.prototype.getTextEditRectangle = function (shape) {
        var rect = this.getTextRectangle(shape);
        return rectangle_1.Rectangle.fromGeometry(new point_1.Point(rect.x, rect.y + rect.height), new size_1.Size(rect.height, rect.width));
    };
    HorizontalContainerDescription.prototype.getTextAngle = function () {
        return TextPrimitive_1.TextAngle.Angle270deg;
    };
    HorizontalContainerDescription.prototype.getHeaderSize = function (shape, forToolbox) {
        var rect = shape.rectangle;
        return forToolbox ? rect.height * ContainerDescription_1.CONTAINER_HEADER_TOOLBOX_SIZE_RATIO : (ContainerDescription_1.CONTAINER_HEADER_SIZE + 2 * shape.strokeWidth);
    };
    return HorizontalContainerDescription;
}(ContainerDescription_1.ContainerDescription));
exports.HorizontalContainerDescription = HorizontalContainerDescription;


/***/ }),
/* 234 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.CardWithImageOnTopDescription = void 0;
var ShapeDescription_1 = __webpack_require__(7);
var size_1 = __webpack_require__(2);
var ShapeTypes_1 = __webpack_require__(1);
var CardBaseDescription_1 = __webpack_require__(132);
var unit_converter_1 = __webpack_require__(12);
var CardWithImageOnTopDescription = (function (_super) {
    __extends(CardWithImageOnTopDescription, _super);
    function CardWithImageOnTopDescription() {
        var _this = _super.call(this, new size_1.Size(32 / 40 * ShapeDescription_1.ShapeDefaultDimension, ShapeDescription_1.ShapeDefaultDimension)) || this;
        _this.isTextAfterImage = true;
        _this.isHorizontal = false;
        return _this;
    }
    Object.defineProperty(CardWithImageOnTopDescription.prototype, "key", {
        get: function () { return ShapeTypes_1.ShapeTypes.CardWithImageOnTop; },
        enumerable: false,
        configurable: true
    });
    CardWithImageOnTopDescription.prototype.getImageSize = function (shapeSize, includeMargins, forToolbox) {
        var w = shapeSize.width / 2;
        if (unit_converter_1.UnitConverter.twipsToPixels(w) % 2 === 1)
            w -= unit_converter_1.UnitConverter.pixelsToTwips(1);
        var imageSize = Math.max(0, shapeSize.height - (includeMargins ? 0 : 2 * this.getImageMargin(forToolbox)));
        imageSize = Math.min(w, imageSize);
        return new size_1.Size(imageSize, imageSize);
    };
    CardWithImageOnTopDescription.prototype.getImageSizeByTextBlockSize = function (textBlockSize) {
        return this.getImageSize(new size_1.Size(textBlockSize.width, Number.MAX_VALUE), true);
    };
    return CardWithImageOnTopDescription;
}(CardBaseDescription_1.CardBaseDescription));
exports.CardWithImageOnTopDescription = CardWithImageOnTopDescription;


/***/ }),
/* 235 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.RoundedRectanglePrimitive = void 0;
var RenderHelper_1 = __webpack_require__(15);
var RectaglePrimitive_1 = __webpack_require__(21);
var RoundedRectanglePrimitive = (function (_super) {
    __extends(RoundedRectanglePrimitive, _super);
    function RoundedRectanglePrimitive(x, y, width, height, rx, ry, style, className, clipPathId, onApplyProperties) {
        if (rx === void 0) { rx = 0; }
        if (ry === void 0) { ry = 0; }
        var _this = _super.call(this, x, y, width, height, style, className, clipPathId, onApplyProperties) || this;
        _this.x = x;
        _this.y = y;
        _this.width = width;
        _this.height = height;
        _this.rx = rx;
        _this.ry = ry;
        return _this;
    }
    RoundedRectanglePrimitive.prototype.createMainElement = function () {
        return document.createElementNS(RenderHelper_1.svgNS, "rect");
    };
    RoundedRectanglePrimitive.prototype.applyElementProperties = function (element, measurer) {
        this.setUnitAttribute(element, "rx", this.rx);
        this.setUnitAttribute(element, "ry", this.ry);
        _super.prototype.applyElementProperties.call(this, element, measurer);
    };
    return RoundedRectanglePrimitive;
}(RectaglePrimitive_1.RectanglePrimitive));
exports.RoundedRectanglePrimitive = RoundedRectanglePrimitive;


/***/ }),
/* 236 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.ConnectorShapeDescription = void 0;
var ShapeTypes_1 = __webpack_require__(1);
var size_1 = __webpack_require__(2);
var ShapeDescription_1 = __webpack_require__(7);
var EllipseShapeDescription_1 = __webpack_require__(72);
var ConnectorShapeDescription = (function (_super) {
    __extends(ConnectorShapeDescription, _super);
    function ConnectorShapeDescription() {
        var _this = _super.call(this, false) || this;
        _this.defaultSize = new size_1.Size(ShapeDescription_1.ShapeDefaultDimension * 0.5, ShapeDescription_1.ShapeDefaultDimension * 0.5);
        return _this;
    }
    Object.defineProperty(ConnectorShapeDescription.prototype, "key", {
        get: function () { return ShapeTypes_1.ShapeTypes.Connector; },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(ConnectorShapeDescription.prototype, "keepRatioOnAutoSize", {
        get: function () { return true; },
        enumerable: false,
        configurable: true
    });
    return ConnectorShapeDescription;
}(EllipseShapeDescription_1.EllipseShapeDescription));
exports.ConnectorShapeDescription = ConnectorShapeDescription;


/***/ }),
/* 237 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.CardWithImageOnRightDescription = exports.CardWithImageOnLeftDescription = void 0;
var ShapeDescription_1 = __webpack_require__(7);
var ShapeTypes_1 = __webpack_require__(1);
var CardBaseDescription_1 = __webpack_require__(132);
var size_1 = __webpack_require__(2);
var CardWithHorizontalImageDescription = (function (_super) {
    __extends(CardWithHorizontalImageDescription, _super);
    function CardWithHorizontalImageDescription() {
        var _this = _super.call(this, new size_1.Size(1.5 * ShapeDescription_1.ShapeDefaultDimension, 0.5 * ShapeDescription_1.ShapeDefaultDimension)) || this;
        _this.isHorizontal = true;
        return _this;
    }
    CardWithHorizontalImageDescription.prototype.getToolboxHeightToWidthRatio = function (_width, _height) {
        return 26 / 46;
    };
    CardWithHorizontalImageDescription.prototype.getImageSize = function (shapeSize, includeMargins, forToolbox) {
        var imageSize = Math.min(shapeSize.height, shapeSize.width);
        if (!includeMargins)
            imageSize = Math.max(0, imageSize - 2 * this.getImageMargin(forToolbox));
        return new size_1.Size(imageSize, imageSize);
    };
    CardWithHorizontalImageDescription.prototype.getImageSizeByTextBlockSize = function (textBlockSize) {
        return this.getImageSize(new size_1.Size(Number.MAX_VALUE, textBlockSize.height), true);
    };
    return CardWithHorizontalImageDescription;
}(CardBaseDescription_1.CardBaseDescription));
var CardWithImageOnLeftDescription = (function (_super) {
    __extends(CardWithImageOnLeftDescription, _super);
    function CardWithImageOnLeftDescription() {
        var _this = _super !== null && _super.apply(this, arguments) || this;
        _this.isTextAfterImage = true;
        return _this;
    }
    Object.defineProperty(CardWithImageOnLeftDescription.prototype, "key", {
        get: function () { return ShapeTypes_1.ShapeTypes.CardWithImageOnLeft; },
        enumerable: false,
        configurable: true
    });
    return CardWithImageOnLeftDescription;
}(CardWithHorizontalImageDescription));
exports.CardWithImageOnLeftDescription = CardWithImageOnLeftDescription;
var CardWithImageOnRightDescription = (function (_super) {
    __extends(CardWithImageOnRightDescription, _super);
    function CardWithImageOnRightDescription() {
        var _this = _super !== null && _super.apply(this, arguments) || this;
        _this.isTextAfterImage = false;
        return _this;
    }
    Object.defineProperty(CardWithImageOnRightDescription.prototype, "key", {
        get: function () { return ShapeTypes_1.ShapeTypes.CardWithImageOnRight; },
        enumerable: false,
        configurable: true
    });
    return CardWithImageOnRightDescription;
}(CardWithHorizontalImageDescription));
exports.CardWithImageOnRightDescription = CardWithImageOnRightDescription;


/***/ }),
/* 238 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.ExportCommand = void 0;
var Exporter_1 = __webpack_require__(73);
var ExportImportCommandBase_1 = __webpack_require__(57);
var ExportCommand = (function (_super) {
    __extends(ExportCommand, _super);
    function ExportCommand() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    ExportCommand.prototype.executeCore = function (state, parameter) {
        var exporter = new Exporter_1.Exporter();
        var data = exporter.export(this.control.model);
        parameter(data);
        return true;
    };
    return ExportCommand;
}(ExportImportCommandBase_1.ExportImportCommandBase));
exports.ExportCommand = ExportCommand;


/***/ }),
/* 239 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.ToggleFontBoldCommand = void 0;
var ToggleStyleTextPropertyCommand_1 = __webpack_require__(74);
var ToggleFontBoldCommand = (function (_super) {
    __extends(ToggleFontBoldCommand, _super);
    function ToggleFontBoldCommand() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    ToggleFontBoldCommand.prototype.getStyleProperty = function () {
        return "font-weight";
    };
    ToggleFontBoldCommand.prototype.getStylePropertyValue = function () {
        return "bold";
    };
    return ToggleFontBoldCommand;
}(ToggleStyleTextPropertyCommand_1.ToggleStyleTextPropertyCommand));
exports.ToggleFontBoldCommand = ToggleFontBoldCommand;


/***/ }),
/* 240 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.ToggleFontItalicCommand = void 0;
var ToggleStyleTextPropertyCommand_1 = __webpack_require__(74);
var ToggleFontItalicCommand = (function (_super) {
    __extends(ToggleFontItalicCommand, _super);
    function ToggleFontItalicCommand() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    ToggleFontItalicCommand.prototype.getStyleProperty = function () {
        return "font-style";
    };
    ToggleFontItalicCommand.prototype.getStylePropertyValue = function () {
        return "italic";
    };
    return ToggleFontItalicCommand;
}(ToggleStyleTextPropertyCommand_1.ToggleStyleTextPropertyCommand));
exports.ToggleFontItalicCommand = ToggleFontItalicCommand;


/***/ }),
/* 241 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.ToggleFontUnderlineCommand = void 0;
var ToggleStyleTextPropertyCommand_1 = __webpack_require__(74);
var ToggleFontUnderlineCommand = (function (_super) {
    __extends(ToggleFontUnderlineCommand, _super);
    function ToggleFontUnderlineCommand() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    ToggleFontUnderlineCommand.prototype.getStyleProperty = function () {
        return "text-decoration";
    };
    ToggleFontUnderlineCommand.prototype.getStylePropertyValue = function () {
        return "underline";
    };
    return ToggleFontUnderlineCommand;
}(ToggleStyleTextPropertyCommand_1.ToggleStyleTextPropertyCommand));
exports.ToggleFontUnderlineCommand = ToggleFontUnderlineCommand;


/***/ }),
/* 242 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.ChangeFontNameCommand = void 0;
var ChangeStyleTextPropertyCommand_1 = __webpack_require__(96);
var ChangeFontNameCommand = (function (_super) {
    __extends(ChangeFontNameCommand, _super);
    function ChangeFontNameCommand() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    ChangeFontNameCommand.prototype.getStyleProperty = function () {
        return "font-family";
    };
    return ChangeFontNameCommand;
}(ChangeStyleTextPropertyCommand_1.ChangeStyleTextPropertyCommand));
exports.ChangeFontNameCommand = ChangeFontNameCommand;


/***/ }),
/* 243 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.ChangeFontSizeCommand = void 0;
var ChangeStyleTextPropertyCommand_1 = __webpack_require__(96);
var ChangeFontSizeCommand = (function (_super) {
    __extends(ChangeFontSizeCommand, _super);
    function ChangeFontSizeCommand() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    ChangeFontSizeCommand.prototype.getStyleProperty = function () {
        return "font-size";
    };
    return ChangeFontSizeCommand;
}(ChangeStyleTextPropertyCommand_1.ChangeStyleTextPropertyCommand));
exports.ChangeFontSizeCommand = ChangeFontSizeCommand;


/***/ }),
/* 244 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.ChangeFontColorCommand = void 0;
var ChangeStyleTextPropertyCommand_1 = __webpack_require__(96);
var color_1 = __webpack_require__(22);
var ChangeFontColorCommand = (function (_super) {
    __extends(ChangeFontColorCommand, _super);
    function ChangeFontColorCommand() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    ChangeFontColorCommand.prototype.processParameter = function (parameter) {
        return color_1.ColorUtils.stringToHash(parameter);
    };
    ChangeFontColorCommand.prototype.getStyleProperty = function () {
        return "fill";
    };
    return ChangeFontColorCommand;
}(ChangeStyleTextPropertyCommand_1.ChangeStyleTextPropertyCommand));
exports.ChangeFontColorCommand = ChangeFontColorCommand;


/***/ }),
/* 245 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.ChangeFillColorCommand = void 0;
var ChangeStylePropertyCommand_1 = __webpack_require__(75);
var color_1 = __webpack_require__(22);
var ChangeFillColorCommand = (function (_super) {
    __extends(ChangeFillColorCommand, _super);
    function ChangeFillColorCommand() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    ChangeFillColorCommand.prototype.processParameter = function (parameter) {
        return color_1.ColorUtils.stringToHash(parameter);
    };
    ChangeFillColorCommand.prototype.getStyleProperty = function () {
        return "fill";
    };
    return ChangeFillColorCommand;
}(ChangeStylePropertyCommand_1.ChangeStylePropertyCommand));
exports.ChangeFillColorCommand = ChangeFillColorCommand;


/***/ }),
/* 246 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.ChangeStrokeColorCommand = void 0;
var ChangeStylePropertyCommand_1 = __webpack_require__(75);
var color_1 = __webpack_require__(22);
var ChangeStrokeColorCommand = (function (_super) {
    __extends(ChangeStrokeColorCommand, _super);
    function ChangeStrokeColorCommand() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    ChangeStrokeColorCommand.prototype.processParameter = function (parameter) {
        return color_1.ColorUtils.stringToHash(parameter);
    };
    ChangeStrokeColorCommand.prototype.getStyleProperty = function () {
        return "stroke";
    };
    return ChangeStrokeColorCommand;
}(ChangeStylePropertyCommand_1.ChangeStylePropertyCommand));
exports.ChangeStrokeColorCommand = ChangeStrokeColorCommand;


/***/ }),
/* 247 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.TextRightAlignCommand = exports.TextCenterAlignCommand = exports.TextLeftAlignCommand = exports.ChangeTextAlignCommand = void 0;
var ToggleStyleTextPropertyCommand_1 = __webpack_require__(74);
var ChangeTextAlignCommand = (function (_super) {
    __extends(ChangeTextAlignCommand, _super);
    function ChangeTextAlignCommand() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    ChangeTextAlignCommand.prototype.getStyleProperty = function () {
        return "text-anchor";
    };
    return ChangeTextAlignCommand;
}(ToggleStyleTextPropertyCommand_1.ToggleStyleTextPropertyCommand));
exports.ChangeTextAlignCommand = ChangeTextAlignCommand;
var TextLeftAlignCommand = (function (_super) {
    __extends(TextLeftAlignCommand, _super);
    function TextLeftAlignCommand() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    TextLeftAlignCommand.prototype.getStylePropertyValue = function () {
        return "start";
    };
    return TextLeftAlignCommand;
}(ChangeTextAlignCommand));
exports.TextLeftAlignCommand = TextLeftAlignCommand;
var TextCenterAlignCommand = (function (_super) {
    __extends(TextCenterAlignCommand, _super);
    function TextCenterAlignCommand() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    TextCenterAlignCommand.prototype.getStylePropertyValue = function () {
        return "middle";
    };
    return TextCenterAlignCommand;
}(ChangeTextAlignCommand));
exports.TextCenterAlignCommand = TextCenterAlignCommand;
var TextRightAlignCommand = (function (_super) {
    __extends(TextRightAlignCommand, _super);
    function TextRightAlignCommand() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    TextRightAlignCommand.prototype.getStylePropertyValue = function () {
        return "end";
    };
    return TextRightAlignCommand;
}(ChangeTextAlignCommand));
exports.TextRightAlignCommand = TextRightAlignCommand;


/***/ }),
/* 248 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.ChangeConnectorEndLineEndingCommand = exports.ChangeConnectorStartLineEndingCommand = void 0;
var ChangeConnectorPropertyCommand_1 = __webpack_require__(136);
var ConnectorProperties_1 = __webpack_require__(32);
var ChangeConnectorStartLineEndingCommand = (function (_super) {
    __extends(ChangeConnectorStartLineEndingCommand, _super);
    function ChangeConnectorStartLineEndingCommand() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    ChangeConnectorStartLineEndingCommand.prototype.getPropertyName = function () {
        return "startLineEnding";
    };
    ChangeConnectorStartLineEndingCommand.prototype.getPropertyDefaultValue = function () {
        return ConnectorProperties_1.ConnectorLineEnding.None;
    };
    return ChangeConnectorStartLineEndingCommand;
}(ChangeConnectorPropertyCommand_1.ChangeConnectorPropertyCommand));
exports.ChangeConnectorStartLineEndingCommand = ChangeConnectorStartLineEndingCommand;
var ChangeConnectorEndLineEndingCommand = (function (_super) {
    __extends(ChangeConnectorEndLineEndingCommand, _super);
    function ChangeConnectorEndLineEndingCommand() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    ChangeConnectorEndLineEndingCommand.prototype.getPropertyName = function () {
        return "endLineEnding";
    };
    ChangeConnectorEndLineEndingCommand.prototype.getPropertyDefaultValue = function () {
        return ConnectorProperties_1.ConnectorLineEnding.Arrow;
    };
    return ChangeConnectorEndLineEndingCommand;
}(ChangeConnectorPropertyCommand_1.ChangeConnectorPropertyCommand));
exports.ChangeConnectorEndLineEndingCommand = ChangeConnectorEndLineEndingCommand;


/***/ }),
/* 249 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.ChangeConnectorLineOptionCommand = void 0;
var ChangeConnectorPropertyCommand_1 = __webpack_require__(136);
var ConnectorProperties_1 = __webpack_require__(32);
var ChangeConnectorLineOptionCommand = (function (_super) {
    __extends(ChangeConnectorLineOptionCommand, _super);
    function ChangeConnectorLineOptionCommand() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    ChangeConnectorLineOptionCommand.prototype.getPropertyName = function () {
        return "lineOption";
    };
    ChangeConnectorLineOptionCommand.prototype.getPropertyDefaultValue = function () {
        return ConnectorProperties_1.ConnectorLineOption.Straight;
    };
    return ChangeConnectorLineOptionCommand;
}(ChangeConnectorPropertyCommand_1.ChangeConnectorPropertyCommand));
exports.ChangeConnectorLineOptionCommand = ChangeConnectorLineOptionCommand;


/***/ }),
/* 250 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.SelectAllCommand = void 0;
var SimpleCommandBase_1 = __webpack_require__(10);
var SelectAllCommand = (function (_super) {
    __extends(SelectAllCommand, _super);
    function SelectAllCommand() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    SelectAllCommand.prototype.isEnabledInReadOnlyMode = function () {
        return true;
    };
    SelectAllCommand.prototype.executeCore = function (state, parameter) {
        var itemKeys = [];
        this.control.model.iterateItems(function (i) { return itemKeys.push(i.key); });
        this.control.selection.set(itemKeys);
        return true;
    };
    return SelectAllCommand;
}(SimpleCommandBase_1.SimpleCommandBase));
exports.SelectAllCommand = SelectAllCommand;


/***/ }),
/* 251 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.ScrollIntoViewOnUndoHistoryItem = exports.ScrollIntoViewOnRedoHistoryItem = void 0;
var HistoryItem_1 = __webpack_require__(8);
var ScrollIntoViewOnRedoHistoryItem = (function (_super) {
    __extends(ScrollIntoViewOnRedoHistoryItem, _super);
    function ScrollIntoViewOnRedoHistoryItem(view, rectangle) {
        var _this = _super.call(this) || this;
        _this.view = view;
        _this.rectangle = rectangle;
        _this.view = view;
        _this.rectangle = rectangle.clone();
        return _this;
    }
    ScrollIntoViewOnRedoHistoryItem.prototype.redo = function (manipulator) {
        this.view.scrollIntoView(this.rectangle);
    };
    ScrollIntoViewOnRedoHistoryItem.prototype.undo = function (manipulator) { };
    return ScrollIntoViewOnRedoHistoryItem;
}(HistoryItem_1.HistoryItem));
exports.ScrollIntoViewOnRedoHistoryItem = ScrollIntoViewOnRedoHistoryItem;
var ScrollIntoViewOnUndoHistoryItem = (function (_super) {
    __extends(ScrollIntoViewOnUndoHistoryItem, _super);
    function ScrollIntoViewOnUndoHistoryItem(view, rectangle) {
        var _this = _super.call(this) || this;
        _this.view = view;
        _this.rectangle = rectangle;
        _this.view = view;
        _this.rectangle = rectangle.clone();
        return _this;
    }
    ScrollIntoViewOnUndoHistoryItem.prototype.redo = function (manipulator) { };
    ScrollIntoViewOnUndoHistoryItem.prototype.undo = function (manipulator) {
        this.view.scrollIntoView(this.rectangle);
    };
    return ScrollIntoViewOnUndoHistoryItem;
}(HistoryItem_1.HistoryItem));
exports.ScrollIntoViewOnUndoHistoryItem = ScrollIntoViewOnUndoHistoryItem;


/***/ }),
/* 252 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.Tree = void 0;
var Structures_1 = __webpack_require__(38);
var Tree = (function () {
    function Tree(root, parentToChildren) {
        var _this = this;
        this.childToParent = {};
        this.root = root;
        this.parentToChildren = parentToChildren;
        var _loop_1 = function (key) {
            if (!Object.prototype.hasOwnProperty.call(parentToChildren, key))
                return "continue";
            parentToChildren[key].forEach(function (c) { return _this.childToParent[c.key] = key; });
        };
        for (var key in parentToChildren) {
            _loop_1(key);
        }
    }
    Tree.prototype.getChildren = function (node) {
        return node && this.parentToChildren[node.key] ? this.parentToChildren[node.key] : [];
    };
    Tree.prototype.hasChildren = function (node) {
        return this.parentToChildren[node.key] && this.parentToChildren[node.key].length > 0;
    };
    Tree.prototype.iterate = function (callback) {
        this.iterateCore(this.root, 0, callback);
    };
    Tree.createSpanningTree = function (component) {
        var rootKey = Tree.findRoot(component);
        var iterator = component.createIterator(Structures_1.ConnectionMode.Outgoing);
        var parentToChildren = {};
        iterator.skipEdge = (function (e) { return e.to === undefined || iterator.isNodeVisited(e.to); });
        iterator.onNode = function (n) { return parentToChildren[n.key] = []; };
        iterator.onEdge = function (e) {
            var node = component.getNode(e.to);
            node && parentToChildren[e.from].push(node);
        };
        iterator.iterate(rootKey);
        return new Tree(component.getNode(rootKey), parentToChildren);
    };
    Tree.prototype.iterateCore = function (node, level, callback) {
        var _this = this;
        callback(node, level);
        this.getChildren(node).forEach(function (n) { return _this.iterateCore(n, level + 1, callback); });
    };
    Tree.findRoot = function (component) {
        return component.nodes.reduce(function (aggregator, cur) {
            var edges = component.getAdjacentEdges(cur);
            var inc = edges.filter(function (l) { return l.to === cur; }).length;
            var out = edges.filter(function (l) { return l.from === cur; }).length;
            if (aggregator.candidate === undefined || (inc === 0 && aggregator.inc > 0) || (aggregator.inc !== 0 && aggregator.out - aggregator.inc < out - inc)) {
                aggregator.candidate = cur;
                aggregator.inc = inc;
                aggregator.out = out;
            }
            return aggregator;
        }, { inc: -1, out: -1, candidate: undefined }).candidate;
    };
    return Tree;
}());
exports.Tree = Tree;


/***/ }),
/* 253 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.ChangeSnapToGridCommand = void 0;
var SimpleCommandBase_1 = __webpack_require__(10);
var ChangeSnapToGridCommand = (function (_super) {
    __extends(ChangeSnapToGridCommand, _super);
    function ChangeSnapToGridCommand() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    ChangeSnapToGridCommand.prototype.executeCore = function (state, parameter) {
        var newValue = parameter === undefined ? !this.control.settings.snapToGrid : !!parameter;
        if (this.control.settings.snapToGrid !== newValue) {
            this.control.settings.snapToGrid = newValue;
            return true;
        }
        return false;
    };
    ChangeSnapToGridCommand.prototype.getValue = function () {
        return this.control.settings.snapToGrid;
    };
    return ChangeSnapToGridCommand;
}(SimpleCommandBase_1.SimpleCommandBase));
exports.ChangeSnapToGridCommand = ChangeSnapToGridCommand;


/***/ }),
/* 254 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.ChangeGridSizeItemsCommand = exports.ChangeGridSizeCommand = void 0;
var SimpleCommandBase_1 = __webpack_require__(10);
var ChangeGridSizeCommand = (function (_super) {
    __extends(ChangeGridSizeCommand, _super);
    function ChangeGridSizeCommand() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    ChangeGridSizeCommand.prototype.isEnabledInReadOnlyMode = function () {
        return true;
    };
    ChangeGridSizeCommand.prototype.getValue = function () {
        return this.getModelUnit(this.control.settings.gridSize);
    };
    ChangeGridSizeCommand.prototype.executeCore = function (state, parameter) {
        this.control.settings.gridSize = this.getModelUnitTwipsValue(parameter);
        return true;
    };
    ChangeGridSizeCommand.prototype.getItems = function () {
        var _this = this;
        return this.control.settings.gridSizeItems.map(function (s) {
            return { value: _this.getModelUnit(s), text: _this.getViewUnitText(s) };
        });
    };
    return ChangeGridSizeCommand;
}(SimpleCommandBase_1.SimpleCommandBase));
exports.ChangeGridSizeCommand = ChangeGridSizeCommand;
var ChangeGridSizeItemsCommand = (function (_super) {
    __extends(ChangeGridSizeItemsCommand, _super);
    function ChangeGridSizeItemsCommand() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    ChangeGridSizeItemsCommand.prototype.isEnabledInReadOnlyMode = function () {
        return true;
    };
    ChangeGridSizeItemsCommand.prototype.getValue = function () {
        var _this = this;
        return this.control.settings.gridSizeItems.map(function (s) { return _this.getModelUnit(s); });
    };
    ChangeGridSizeItemsCommand.prototype.executeCore = function (state, parameter) {
        var _this = this;
        this.control.settings.gridSizeItems = parameter.map(function (s) { return _this.getModelUnitTwipsValue(s); });
        return true;
    };
    return ChangeGridSizeItemsCommand;
}(SimpleCommandBase_1.SimpleCommandBase));
exports.ChangeGridSizeItemsCommand = ChangeGridSizeItemsCommand;


/***/ }),
/* 255 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.ChangePageLandscapeCommand = void 0;
var ChangePagePropertyCommand_1 = __webpack_require__(77);
var ChangePageLandscapeHistoryItem_1 = __webpack_require__(256);
var ChangePageLandscapeCommand = (function (_super) {
    __extends(ChangePageLandscapeCommand, _super);
    function ChangePageLandscapeCommand() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    ChangePageLandscapeCommand.prototype.getValue = function () {
        return this.control.model.pageLandscape;
    };
    ChangePageLandscapeCommand.prototype.createHistoryItems = function (parameter) {
        return [new ChangePageLandscapeHistoryItem_1.ChangePageLandscapeHistoryItem(parameter)];
    };
    return ChangePageLandscapeCommand;
}(ChangePagePropertyCommand_1.ChangePagePropertyCommand));
exports.ChangePageLandscapeCommand = ChangePageLandscapeCommand;


/***/ }),
/* 256 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.ChangePageLandscapeHistoryItem = void 0;
var HistoryItem_1 = __webpack_require__(8);
var ChangePageLandscapeHistoryItem = (function (_super) {
    __extends(ChangePageLandscapeHistoryItem, _super);
    function ChangePageLandscapeHistoryItem(value) {
        var _this = _super.call(this) || this;
        _this.value = value;
        return _this;
    }
    ChangePageLandscapeHistoryItem.prototype.redo = function (manipulator) {
        this.oldValue = manipulator.model.pageLandscape;
        manipulator.changePageLandscape(this.value);
    };
    ChangePageLandscapeHistoryItem.prototype.undo = function (manipulator) {
        manipulator.changePageLandscape(this.oldValue);
    };
    return ChangePageLandscapeHistoryItem;
}(HistoryItem_1.HistoryItem));
exports.ChangePageLandscapeHistoryItem = ChangePageLandscapeHistoryItem;


/***/ }),
/* 257 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.ChangePageSizeItemsCommand = exports.ChangePageSizeCommand = void 0;
var ChangePagePropertyCommand_1 = __webpack_require__(77);
var size_1 = __webpack_require__(2);
var ChangePageSizeHistoryItem_1 = __webpack_require__(258);
var SimpleCommandBase_1 = __webpack_require__(10);
var ChangePageSizeCommand = (function (_super) {
    __extends(ChangePageSizeCommand, _super);
    function ChangePageSizeCommand() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    ChangePageSizeCommand.prototype.getValue = function () {
        return this.getModelUnitSize(this.control.model.pageSize);
    };
    ChangePageSizeCommand.prototype.createHistoryItems = function (parameter) {
        return [new ChangePageSizeHistoryItem_1.ChangePageSizeHistoryItem(new size_1.Size(this.getModelUnitTwipsValue(parameter.width), this.getModelUnitTwipsValue(parameter.height)))];
    };
    ChangePageSizeCommand.prototype.getItems = function () {
        var _this = this;
        return this.control.settings.pageSizeItems.map(function (i) {
            return {
                value: _this.getModelUnitSize(i.size),
                text: i.text.replace("{width}", _this.getViewUnitText(i.size.width)).replace("{height}", _this.getViewUnitText(i.size.height))
            };
        });
    };
    ChangePageSizeCommand.prototype.getModelUnitSize = function (size) {
        return new size_1.Size(this.getModelUnit(size.width), this.getModelUnit(size.height));
    };
    return ChangePageSizeCommand;
}(ChangePagePropertyCommand_1.ChangePagePropertyCommand));
exports.ChangePageSizeCommand = ChangePageSizeCommand;
var ChangePageSizeItemsCommand = (function (_super) {
    __extends(ChangePageSizeItemsCommand, _super);
    function ChangePageSizeItemsCommand() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    ChangePageSizeItemsCommand.prototype.isEnabled = function () {
        return true;
    };
    ChangePageSizeItemsCommand.prototype.getValue = function () {
        var _this = this;
        return this.control.settings.pageSizeItems.map(function (i) {
            return {
                size: new size_1.Size(_this.getModelUnit(i.width), _this.getModelUnit(i.height)),
                text: i.text
            };
        });
    };
    ChangePageSizeItemsCommand.prototype.executeCore = function (state, parameter) {
        var _this = this;
        this.control.settings.pageSizeItems = parameter.map(function (i) {
            return {
                size: new size_1.Size(_this.getModelUnitTwipsValue(i.width), _this.getModelUnitTwipsValue(i.height)),
                text: i.text
            };
        });
        return true;
    };
    return ChangePageSizeItemsCommand;
}(SimpleCommandBase_1.SimpleCommandBase));
exports.ChangePageSizeItemsCommand = ChangePageSizeItemsCommand;


/***/ }),
/* 258 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.ChangePageSizeHistoryItem = void 0;
var HistoryItem_1 = __webpack_require__(8);
var ChangePageSizeHistoryItem = (function (_super) {
    __extends(ChangePageSizeHistoryItem, _super);
    function ChangePageSizeHistoryItem(size) {
        var _this = _super.call(this) || this;
        _this.size = size;
        return _this;
    }
    ChangePageSizeHistoryItem.prototype.redo = function (manipulator) {
        this.oldSize = manipulator.model.pageSize;
        manipulator.changePageSize(this.size);
    };
    ChangePageSizeHistoryItem.prototype.undo = function (manipulator) {
        manipulator.changePageSize(this.oldSize);
    };
    return ChangePageSizeHistoryItem;
}(HistoryItem_1.HistoryItem));
exports.ChangePageSizeHistoryItem = ChangePageSizeHistoryItem;


/***/ }),
/* 259 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.ExportPngCommand = void 0;
var ExportImageCommand_1 = __webpack_require__(98);
var ExportPngCommand = (function (_super) {
    __extends(ExportPngCommand, _super);
    function ExportPngCommand() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    ExportPngCommand.prototype.getExtension = function () { return "png"; };
    ExportPngCommand.prototype.getExportFunc = function () {
        return this.exporter.exportPng;
    };
    return ExportPngCommand;
}(ExportImageCommand_1.ExportImageCommand));
exports.ExportPngCommand = ExportPngCommand;


/***/ }),
/* 260 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};
var __generator = (this && this.__generator) || function (thisArg, body) {
    var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
    return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
    function verb(n) { return function (v) { return step([n, v]); }; }
    function step(op) {
        if (f) throw new TypeError("Generator is already executing.");
        while (_) try {
            if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
            if (y = 0, t) op = [op[0] & 2, t.value];
            switch (op[0]) {
                case 0: case 1: t = op; break;
                case 4: _.label++; return { value: op[1], done: false };
                case 5: _.label++; y = op[1]; op = [0]; continue;
                case 7: op = _.ops.pop(); _.trys.pop(); continue;
                default:
                    if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
                    if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
                    if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
                    if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
                    if (t[2]) _.ops.pop();
                    _.trys.pop(); continue;
            }
            op = body.call(thisArg, _);
        } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
        if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
    }
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.CanvasExportManager = void 0;
var unit_converter_1 = __webpack_require__(12);
var browser_1 = __webpack_require__(18);
var Utils_1 = __webpack_require__(17);
var CanvasManagerBase_1 = __webpack_require__(42);
var RenderHelper_1 = __webpack_require__(15);
var DOMManipulator_1 = __webpack_require__(100);
var color_1 = __webpack_require__(22);
var EXPORT_IMAGE_QUALITY = 1;
var CanvasExportManager = (function (_super) {
    __extends(CanvasExportManager, _super);
    function CanvasExportManager(itemsContainer, measurer) {
        var _this = _super.call(this, 1, new DOMManipulator_1.ExportDOMManipulator(measurer)) || this;
        _this.itemsContainer = itemsContainer;
        return _this;
    }
    CanvasExportManager.prototype.getSvgImage = function (modelSize, pageColor, exportAsInline, exportForBinaryImage) {
        var svgEl = RenderHelper_1.RenderHelper.createSvgElement(undefined, true);
        var modelAbsSize = modelSize.clone().applyConverter(unit_converter_1.UnitConverter.twipsToPixelsF).clone().applyConverter(Math.ceil);
        Utils_1.RenderUtils.updateSvgElementSize(svgEl, modelAbsSize.width, modelAbsSize.height, true);
        svgEl.style.backgroundColor = color_1.ColorUtils.colorToHash(pageColor);
        this.createTextFloodFilter(undefined, svgEl, pageColor);
        var exportCssRules = !exportAsInline && !browser_1.Browser.IE && this.getExportCssRules();
        if (exportCssRules) {
            var style = document.createElementNS(RenderHelper_1.svgNS, "style");
            style.innerHTML = exportCssRules;
            svgEl.appendChild(style);
        }
        if (exportForBinaryImage) {
            var bk = document.createElementNS(RenderHelper_1.svgNS, "rect");
            bk.setAttributeNS(null, "x", "0");
            bk.setAttributeNS(null, "y", "0");
            bk.setAttributeNS(null, "height", modelAbsSize.height.toString());
            bk.setAttributeNS(null, "width", modelAbsSize.width.toString());
            bk.setAttributeNS(null, "fill", svgEl.style.backgroundColor);
            svgEl.appendChild(bk);
        }
        for (var i = 0; i < this.itemsContainer.childNodes.length; i++) {
            var node = this.itemsContainer.childNodes[i].cloneNode(true);
            if (!exportCssRules)
                this.inlineStyle(node, this.itemsContainer.childNodes[i]);
            svgEl.appendChild(node);
        }
        return svgEl;
    };
    CanvasExportManager.prototype.getSvgImageUrl = function (modelSize, pageColor, exportAsInline) {
        var svgEl = this.getSvgImage(modelSize, pageColor, exportAsInline, false);
        return this.getSvgBase64String(svgEl);
    };
    CanvasExportManager.prototype.getSvgString = function (svgElement) {
        return new XMLSerializer().serializeToString(svgElement);
    };
    CanvasExportManager.prototype.getSvgBase64String = function (svgElement) {
        var xml = this.getSvgString(svgElement);
        return CanvasExportManager.base64Start + this.getBase64EncodeUnicode(xml);
    };
    CanvasExportManager.prototype.getBase64EncodeUnicode = function (s) {
        return btoa(encodeURIComponent(s).replace(/%([0-9A-F]{2})/g, function (match, p1) { return String.fromCharCode(parseInt("0x" + p1, 16)); }));
    };
    CanvasExportManager.prototype.getExportCssRules = function () {
        for (var i = 0; i < document.styleSheets.length; i++) {
            var rules = this.getRules(document.styleSheets[i]);
            if (rules) {
                var cssText = "";
                for (var j = 0; j < rules.length; j++) {
                    var rule = rules[j];
                    var selectorText = this.isCSSStyleRule(rule) ? rule.selectorText : null;
                    if (selectorText && this.checkSelector(selectorText))
                        cssText += rule.cssText + "\n";
                }
                if (cssText.length > 0)
                    return "\n" + cssText;
            }
        }
    };
    CanvasExportManager.prototype.checkSelector = function (selectorText) {
        for (var i = 0; i < CanvasExportManager.exportStyleRules.length; i++)
            if (selectorText.indexOf(CanvasExportManager.exportStyleRules[i]) === 0)
                return true;
        return false;
    };
    CanvasExportManager.prototype.getRules = function (styleSheet) {
        try {
            return this.isCSSStyleSheet(styleSheet) ? styleSheet.rules || styleSheet.cssRules : null;
        }
        catch (_a) { }
    };
    CanvasExportManager.prototype.isCSSStyleSheet = function (stylesheet) {
        return stylesheet.rules !== undefined;
    };
    CanvasExportManager.prototype.isCSSStyleRule = function (rule) {
        return rule.selectorText !== undefined;
    };
    CanvasExportManager.prototype.inlineStyle = function (destNode, srcNode) {
        for (var i = 0; i < destNode.childNodes.length; i++) {
            var child = destNode.childNodes[i];
            if (!child.tagName)
                continue;
            if (child.tagName === "g")
                this.inlineStyle(child, srcNode.childNodes[i]);
            else if (child.style) {
                var style = window.getComputedStyle(srcNode.childNodes[i]);
                if (style !== undefined)
                    for (var index = 0; index < CanvasExportManager.exportStyleAttributes.length; index++) {
                        var styleProperty = CanvasExportManager.exportStyleAttributes[index];
                        child.style.setProperty(styleProperty, style.getPropertyValue(styleProperty));
                    }
                this.inlineStyle(child, srcNode.childNodes[i]);
            }
        }
    };
    CanvasExportManager.prototype.exportSvgImage = function (modelSize, pageColor, callback) {
        callback(this.getSvgImageUrl(modelSize, pageColor, true));
    };
    CanvasExportManager.prototype.exportBinaryImage = function (modelSize, pageColor, mimeType, callback, useCanvgForExportToImage) {
        var modelAbsSize = this.getAbsoluteSize(modelSize).clone().applyConverter(Math.ceil);
        var canvasEl = document.createElement("canvas");
        canvasEl.width = modelAbsSize.width;
        canvasEl.height = modelAbsSize.height;
        var ctx = canvasEl.getContext("2d");
        ctx.fillStyle = color_1.ColorUtils.colorToHash(pageColor);
        ctx.fillRect(0, 0, modelAbsSize.width, modelAbsSize.height);
        if ((useCanvgForExportToImage || browser_1.Browser.IE) && typeof canvg === "object")
            this.exportBinaryImageCanvgAsync(modelSize, pageColor, canvasEl, ctx, mimeType).then(function (dataUrl) { return callback(dataUrl); });
        else if (browser_1.Browser.IE && typeof canvg === "function")
            this.exportBinaryImageCanvgOld(modelSize, pageColor, canvasEl, ctx, mimeType, callback);
        else {
            var imgEl_1 = new Image();
            imgEl_1.width = modelAbsSize.width;
            imgEl_1.height = modelAbsSize.height;
            imgEl_1.setAttribute("crossOrigin", "anonymous");
            imgEl_1.onload = function () {
                ctx.drawImage(imgEl_1, 0, 0);
                callback(canvasEl.toDataURL(mimeType, EXPORT_IMAGE_QUALITY));
            };
            imgEl_1.src = this.getSvgImageUrl(modelSize, pageColor, true);
        }
    };
    CanvasExportManager.prototype.exportBinaryImageCanvgOld = function (modelSize, pageColor, canvasEl, ctx, mimeType, callback) {
        var svgEl = this.getSvgImage(modelSize, pageColor, true, false);
        var svgStr = this.getSvgString(svgEl);
        ctx["drawSvg"](svgStr, 0, 0, null, null, {
            renderCallback: function () {
                callback(canvasEl.toDataURL(mimeType, EXPORT_IMAGE_QUALITY));
            }
        });
    };
    CanvasExportManager.prototype.exportBinaryImageCanvgAsync = function (modelSize, pageColor, canvas, ctx, mimeType) {
        return __awaiter(this, void 0, void 0, function () {
            var svgEl, svgStr, v;
            return __generator(this, function (_a) {
                switch (_a.label) {
                    case 0:
                        svgEl = this.getSvgImage(modelSize, pageColor, true, true);
                        svgStr = this.getSvgString(svgEl);
                        v = canvg.Canvg.fromString(ctx, svgStr);
                        return [4, v.render()];
                    case 1:
                        _a.sent();
                        return [2, canvas.toDataURL(mimeType, EXPORT_IMAGE_QUALITY)];
                }
            });
        });
    };
    CanvasExportManager.prototype.exportPngImage = function (modelSize, pageColor, callback, useCanvgForExportToImage) {
        this.exportBinaryImage(modelSize, pageColor, "image/png", callback, useCanvgForExportToImage);
    };
    CanvasExportManager.prototype.exportJpgImage = function (modelSize, pageColor, callback, useCanvgForExportToImage) {
        this.exportBinaryImage(modelSize, pageColor, "image/jpeg", callback, useCanvgForExportToImage);
    };
    CanvasExportManager.prototype.notifyModelChanged = function (changes) { };
    CanvasExportManager.prototype.notifyPageColorChanged = function (color) { };
    CanvasExportManager.prototype.notifyPageSizeChanged = function (pageSize, pageLandscape) { };
    CanvasExportManager.base64Start = "data:image/svg+xml;base64,";
    CanvasExportManager.exportStyleRules = [
        ".dxdi-canvas .shape ", ".dxdi-canvas .connector ", ".dxdi-canvas text", ".dxdi-canvas.export"
    ];
    CanvasExportManager.exportStyleAttributes = [
        "fill", "stroke", "stroke-width", "stroke-linejoin",
        "font-family", "font-size", "font-weight", "font-style", "text-decoration", "text-anchor"
    ];
    return CanvasExportManager;
}(CanvasManagerBase_1.CanvasManagerBase));
exports.CanvasExportManager = CanvasExportManager;


/***/ }),
/* 261 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.ExportSvgCommand = void 0;
var ExportImageCommand_1 = __webpack_require__(98);
var ExportSvgCommand = (function (_super) {
    __extends(ExportSvgCommand, _super);
    function ExportSvgCommand() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    ExportSvgCommand.prototype.getExtension = function () { return "svg"; };
    ExportSvgCommand.prototype.getExportFunc = function () {
        return this.exporter.exportSvg;
    };
    return ExportSvgCommand;
}(ExportImageCommand_1.ExportImageCommand));
exports.ExportSvgCommand = ExportSvgCommand;


/***/ }),
/* 262 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.ExportJpgCommand = void 0;
var ExportImageCommand_1 = __webpack_require__(98);
var ExportJpgCommand = (function (_super) {
    __extends(ExportJpgCommand, _super);
    function ExportJpgCommand() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    ExportJpgCommand.prototype.getExtension = function () { return "jpg"; };
    ExportJpgCommand.prototype.getExportFunc = function () {
        return this.exporter.exportJpg;
    };
    return ExportJpgCommand;
}(ExportImageCommand_1.ExportImageCommand));
exports.ExportJpgCommand = ExportJpgCommand;


/***/ }),
/* 263 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.CopySelectionCommand = void 0;
var Exporter_1 = __webpack_require__(73);
var ClipboardCommand_1 = __webpack_require__(101);
var CopySelectionCommand = (function (_super) {
    __extends(CopySelectionCommand, _super);
    function CopySelectionCommand() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    CopySelectionCommand.prototype.isEnabled = function () {
        return _super.prototype.isEnabled.call(this) && !this.control.selection.isEmpty(true);
    };
    CopySelectionCommand.prototype.isEnabledInReadOnlyMode = function () {
        return true;
    };
    CopySelectionCommand.prototype.executeCore = function (state) {
        var exporter = new Exporter_1.Exporter();
        var data = exporter.exportItems(this.control.selection.getSelectedItems(true, true));
        this.setClipboardData(data);
        return true;
    };
    return CopySelectionCommand;
}(ClipboardCommand_1.ClipboardCommand));
exports.CopySelectionCommand = CopySelectionCommand;


/***/ }),
/* 264 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.CutSelectionCommand = void 0;
var Exporter_1 = __webpack_require__(73);
var ModelUtils_1 = __webpack_require__(4);
var ClipboardCommand_1 = __webpack_require__(101);
var CutSelectionCommand = (function (_super) {
    __extends(CutSelectionCommand, _super);
    function CutSelectionCommand() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    CutSelectionCommand.prototype.isEnabled = function () {
        var items = this.control.selection.getSelectedItems();
        return _super.prototype.isEnabled.call(this) && items.length && (items.length > 1 || this.permissionsProvider.canDeleteItems(items));
    };
    CutSelectionCommand.prototype.executeCore = function (state) {
        var exporter = new Exporter_1.Exporter();
        var items = this.control.selection.getSelectedItems(true, true);
        var data = exporter.exportItems(items);
        this.permissionsProvider.beginDeleteItems(items);
        this.setClipboardData(data);
        ModelUtils_1.ModelUtils.deleteSelection(this.control.history, this.control.model, this.control.selection);
        this.permissionsProvider.endDeleteItems();
        return true;
    };
    Object.defineProperty(CutSelectionCommand.prototype, "isPermissionsRequired", {
        get: function () { return true; },
        enumerable: false,
        configurable: true
    });
    return CutSelectionCommand;
}(ClipboardCommand_1.ClipboardCommand));
exports.CutSelectionCommand = CutSelectionCommand;


/***/ }),
/* 265 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.PasteSelectionCommand = void 0;
var point_1 = __webpack_require__(0);
var PasteSelectionCommandBase_1 = __webpack_require__(141);
var PasteSelectionCommand = (function (_super) {
    __extends(PasteSelectionCommand, _super);
    function PasteSelectionCommand() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    PasteSelectionCommand.prototype.getEventPositionOffset = function (_items, _evtPosition) {
        return new point_1.Point(0, 0);
    };
    return PasteSelectionCommand;
}(PasteSelectionCommandBase_1.PasteSelectionCommandBase));
exports.PasteSelectionCommand = PasteSelectionCommand;


/***/ }),
/* 266 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.ImportShapeHistoryItem = void 0;
var HistoryItem_1 = __webpack_require__(8);
var ImportShapeHistoryItem = (function (_super) {
    __extends(ImportShapeHistoryItem, _super);
    function ImportShapeHistoryItem(shape) {
        var _this = _super.call(this) || this;
        _this.shape = shape;
        return _this;
    }
    ImportShapeHistoryItem.prototype.redo = function (manipulator) {
        this.shapeKey = this.shape.key;
        manipulator.insertShape(this.shape);
    };
    ImportShapeHistoryItem.prototype.undo = function (manipulator) {
        manipulator.removeShape(manipulator.model.findShape(this.shapeKey), true);
    };
    return ImportShapeHistoryItem;
}(HistoryItem_1.HistoryItem));
exports.ImportShapeHistoryItem = ImportShapeHistoryItem;


/***/ }),
/* 267 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.ImportConnectorHistoryItem = void 0;
var HistoryItem_1 = __webpack_require__(8);
var ImportConnectorHistoryItem = (function (_super) {
    __extends(ImportConnectorHistoryItem, _super);
    function ImportConnectorHistoryItem(connector) {
        var _this = _super.call(this) || this;
        _this.connector = connector;
        return _this;
    }
    ImportConnectorHistoryItem.prototype.redo = function (manipulator) {
        this.connectorKey = this.connector.key;
        manipulator.insertConnector(this.connector);
    };
    ImportConnectorHistoryItem.prototype.undo = function (manipulator) {
        var connector = manipulator.model.findConnector(this.connectorKey);
        manipulator.removeConnector(connector);
    };
    return ImportConnectorHistoryItem;
}(HistoryItem_1.HistoryItem));
exports.ImportConnectorHistoryItem = ImportConnectorHistoryItem;


/***/ }),
/* 268 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.ImportBPMNCommand = void 0;
var BPMNImporter_1 = __webpack_require__(269);
var ModelUtils_1 = __webpack_require__(4);
var AddShapeHistoryItem_1 = __webpack_require__(53);
var point_1 = __webpack_require__(0);
var Connector_1 = __webpack_require__(6);
var AddConnectorHistoryItem_1 = __webpack_require__(66);
var AddConnectionHistoryItem_1 = __webpack_require__(48);
var Sugiyama_1 = __webpack_require__(80);
var LayoutSettings_1 = __webpack_require__(20);
var ExportImportCommandBase_1 = __webpack_require__(57);
var ImportBPMNCommand = (function (_super) {
    __extends(ImportBPMNCommand, _super);
    function ImportBPMNCommand() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    ImportBPMNCommand.prototype.executeCore = function (state, parameter) {
        var importer = new BPMNImporter_1.BPMNImporter(parameter);
        var graph = importer.import();
        this.updateModel(graph);
        return true;
    };
    ImportBPMNCommand.prototype.updateModel = function (graph) {
        var _this = this;
        var externalKeyToModelKey = {};
        var shapes = [];
        var connectors = [];
        this.control.history.beginTransaction();
        graph.items.forEach(function (node) {
            var insert = new AddShapeHistoryItem_1.AddShapeHistoryItem(_this.getShapeDescription(node.type), new point_1.Point(0, 0), node.text, node.key);
            _this.control.history.addAndRedo(insert);
            externalKeyToModelKey[node.key] = insert.shapeKey;
            var shape = _this.control.model.findShape(insert.shapeKey);
            shapes.push(shape);
        });
        graph.edges.forEach(function (edge) {
            var from = _this.control.model.findShape(externalKeyToModelKey[edge.from]);
            var to = _this.control.model.findShape(externalKeyToModelKey[edge.to]);
            var insert = new AddConnectorHistoryItem_1.AddConnectorHistoryItem([from.getConnectionPointPosition(0), to.getConnectionPointPosition(0)]);
            _this.control.history.addAndRedo(insert);
            var connector = _this.control.model.findConnector(insert.connectorKey);
            _this.control.history.addAndRedo(new AddConnectionHistoryItem_1.AddConnectionHistoryItem(connector, from, 0, Connector_1.ConnectorPosition.Begin));
            _this.control.history.addAndRedo(new AddConnectionHistoryItem_1.AddConnectionHistoryItem(connector, to, 0, Connector_1.ConnectorPosition.End));
            connectors.push(connector);
        });
        var settings = new LayoutSettings_1.LayoutSettings();
        var graphInfo = ModelUtils_1.ModelUtils.getGraphInfoByItems(this.control.model, shapes, connectors);
        graphInfo.forEach(function (info) {
            var layout = new Sugiyama_1.SugiyamaLayoutBuilder(settings, info.graph).build();
            var nonGraphItems = ModelUtils_1.ModelUtils.getNonGraphItems(_this.control.model, info.container, layout.nodeToLayout, shapes, connectors);
            ModelUtils_1.ModelUtils.applyLayout(_this.control.history, _this.control.model, undefined, info.graph, layout, nonGraphItems, settings, _this.control.settings.snapToGrid, _this.control.settings.gridSize, false);
        });
        ModelUtils_1.ModelUtils.tryUpdateModelRectangle(this.control.history);
        this.control.history.endTransaction();
    };
    ImportBPMNCommand.prototype.getShapeDescription = function (shapeType) {
        return this.control.shapeDescriptionManager.get(shapeType);
    };
    return ImportBPMNCommand;
}(ExportImportCommandBase_1.ExportImportCommandBase));
exports.ImportBPMNCommand = ImportBPMNCommand;


/***/ }),
/* 269 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.BPMNNode = exports.BPMNImporter = void 0;
var Graph_1 = __webpack_require__(54);
var ShapeTypes_1 = __webpack_require__(1);
var Structures_1 = __webpack_require__(38);
var ImportUtils_1 = __webpack_require__(95);
var BPMNImporter = (function () {
    function BPMNImporter(xml) {
        this.doc = ImportUtils_1.ImportUtils.createDocument(xml);
        this.graph = new Graph_1.Graph([], []);
    }
    BPMNImporter.prototype.import = function () {
        for (var child = void 0, i = 0; child = this.doc.children[i]; i++)
            if (child.nodeName.toUpperCase() === "DEFINITIONS")
                this.onDefinitionsElement(child);
        this.validate();
        return this.graph;
    };
    BPMNImporter.prototype.validate = function () {
        var nodesMap = {};
        this.graph.nodes.forEach(function (n) { return nodesMap[n] = true; });
        for (var i = 0, edge = void 0; edge = this.graph.edges[i]; i++)
            if (!nodesMap[edge.from] || !nodesMap[edge.to]) {
                this.graph.edges.splice(i, 1);
                i--;
            }
    };
    BPMNImporter.prototype.onDefinitionsElement = function (element) {
        this.dataSourceKey = element.getAttribute("id");
        for (var child = void 0, i = 0; child = element.children[i]; i++)
            if (child.nodeName.toUpperCase() === "PROCESS")
                this.onProcessElement(child);
    };
    BPMNImporter.prototype.onProcessElement = function (element) {
        for (var child = void 0, i = 0; child = element.children[i]; i++)
            switch (child.nodeName.toUpperCase()) {
                case "STARTEVENT":
                    this.onStartEventElement(child);
                    break;
                case "SEQUENCEFLOW":
                    this.onSequenceFlowElement(child);
                    break;
                case "SCRIPTTASK":
                    this.onScriptTaskElement(child);
                    break;
                case "USERTASK":
                    this.onUserTaskElement(child);
                    break;
                case "SERVICETASK":
                    this.onServiceTaskElement(child);
                    break;
                case "SENDTASK":
                    this.onSendTaskElement(child);
                    break;
                case "EXCLUSIVEGATEWAY":
                    this.onExclusiveGateway(child);
                    break;
                case "ENDEVENT":
                    this.onEndEventGateway(child);
                    break;
            }
    };
    BPMNImporter.prototype.onStartEventElement = function (element) {
        var node = this.createNode(element);
        node.type = ShapeTypes_1.ShapeTypes.Ellipse;
        node.text = element.getAttribute("name");
        this.graph.addNode(node);
    };
    BPMNImporter.prototype.onSequenceFlowElement = function (element) {
        var fromKey = element.getAttribute("sourceRef");
        var toKey = element.getAttribute("targetRef");
        var edge = this.createEdge(element, fromKey, toKey);
        if (element.hasAttribute("name"))
            edge.text = element.getAttribute("name");
        this.graph.addEdge(edge);
    };
    BPMNImporter.prototype.onScriptTaskElement = function (element) {
        var node = this.createNode(element);
        node.text = element.getAttribute("name");
        this.graph.addNode(node);
    };
    BPMNImporter.prototype.onUserTaskElement = function (element) {
        var node = this.createNode(element);
        node.text = element.getAttribute("name");
        this.graph.addNode(node);
    };
    BPMNImporter.prototype.onServiceTaskElement = function (element) {
        var node = this.createNode(element);
        node.text = element.getAttribute("name");
        this.graph.addNode(node);
    };
    BPMNImporter.prototype.onSendTaskElement = function (element) {
        var node = this.createNode(element);
        node.text = element.getAttribute("name");
        this.graph.addNode(node);
    };
    BPMNImporter.prototype.onExclusiveGateway = function (element) {
        var node = this.createNode(element);
        node.text = element.getAttribute("name");
        node.type = ShapeTypes_1.ShapeTypes.Decision;
        this.graph.addNode(node);
    };
    BPMNImporter.prototype.onEndEventGateway = function (element) {
        var node = this.createNode(element);
        node.text = element.getAttribute("name");
        node.type = ShapeTypes_1.ShapeTypes.Ellipse;
        this.graph.addNode(node);
    };
    BPMNImporter.prototype.createNode = function (element) {
        return new BPMNNode(this.dataSourceKey, element.getAttribute("id"));
    };
    BPMNImporter.prototype.createEdge = function (element, fromKey, toKey) {
        return new BPMNEdge(this.dataSourceKey, element.getAttribute("id"), fromKey, toKey);
    };
    return BPMNImporter;
}());
exports.BPMNImporter = BPMNImporter;
var BPMNNode = (function () {
    function BPMNNode(sourceKey, key) {
        this.sourceKey = sourceKey;
        this.key = key;
        this.type = ShapeTypes_1.ShapeTypes.Rectangle;
    }
    return BPMNNode;
}());
exports.BPMNNode = BPMNNode;
var BPMNEdge = (function (_super) {
    __extends(BPMNEdge, _super);
    function BPMNEdge(sourceKey, key, fromKey, toKey) {
        var _this = _super.call(this, key, fromKey, toKey) || this;
        _this.sourceKey = sourceKey;
        return _this;
    }
    return BPMNEdge;
}(Structures_1.Edge));


/***/ }),
/* 270 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.CycleRemover = void 0;
var Graph_1 = __webpack_require__(54);
var Structures_1 = __webpack_require__(38);
var ListUtils_1 = __webpack_require__(90);
var CycleRemover = (function () {
    function CycleRemover() {
    }
    CycleRemover.removeCycles = function (graph) {
        var feedbackSet = this.getFeedbackSet(graph);
        return this.reverseEdges(graph, feedbackSet);
    };
    CycleRemover.getFeedbackSet = function (graph) {
        var _this = this;
        var feedbackSet = {};
        var nonTrivialStronglyConnectedComponents = this.getNonTrivialStronglyConnectedComponents(graph);
        while (nonTrivialStronglyConnectedComponents.length) {
            nonTrivialStronglyConnectedComponents.forEach(function (g) {
                var maxCyclicEdges = _this.getMaxCyclicEdges(g);
                maxCyclicEdges.forEach(function (e) { return delete feedbackSet[e.reverse().getHashKey()]; });
                maxCyclicEdges.forEach(function (e) { return feedbackSet[e.getHashKey()] = true; });
            });
            nonTrivialStronglyConnectedComponents = this.getNonTrivialStronglyConnectedComponents(this.reverseEdges(graph, feedbackSet).graph);
        }
        return feedbackSet;
    };
    CycleRemover.getMaxCyclicEdges = function (graph) {
        var black = {};
        var gray = {};
        var edgeCycleCount = {};
        var visitedEdges = [];
        var cycles = [];
        var iterator = graph.createIterator(Structures_1.ConnectionMode.Outgoing);
        iterator.visitEachEdgeOnce = false;
        iterator.onNode = function (n) {
            gray[n.key] = true;
        };
        iterator.skipNode = function (n) {
            if (gray[n.key]) {
                var cycle = [];
                for (var i = 0; i < visitedEdges.length; i++) {
                    var e = visitedEdges[i];
                    if (edgeCycleCount[e.key] === undefined)
                        edgeCycleCount[e.key] = 0;
                    edgeCycleCount[e.key]++;
                    cycle.push(e);
                    if (e.from === n.key)
                        break;
                }
                cycles.push(cycle);
            }
            return gray[n.key] || black[n.key];
        };
        iterator.skipEdge = function (e) { return false; };
        iterator.onEdge = function (e) {
            visitedEdges.splice(0, 0, e);
        };
        iterator.onAfterEdge = function (e) {
            visitedEdges.splice(0, 1);
        };
        iterator.onAllEdges = function (e) {
            black[e.key] = true;
            gray[e.key] = false;
        };
        iterator.iterate(graph.nodes[0]);
        var edgeSet = new ListUtils_1.HashSet([], function (e) { return e.key; });
        cycles.forEach(function (c) {
            edgeSet.tryPush(c.reduce(function (max, curr) { return edgeCycleCount[curr.key] > edgeCycleCount[max.key] ? curr : max; }, c[0]));
        });
        return edgeSet.list();
    };
    CycleRemover.reverseEdges = function (graph, feedbackSet) {
        var edges = new ListUtils_1.HashSet([], function (e) { return e.getHashKey(); });
        var reversedEdges = {};
        var removedEdges = {};
        graph.edges.forEach(function (e) {
            if (feedbackSet[e.getHashKey()]) {
                e = e.reverse();
                reversedEdges[e.key] = true;
            }
            if (!edges.tryPush(e)) {
                removedEdges[e.key] = true;
                delete reversedEdges[e.key];
            }
        });
        return {
            graph: new Graph_1.Graph(graph.nodes.map(function (n) { return graph.getNode(n); }), edges.list()),
            reversedEdges: reversedEdges,
            removedEdges: removedEdges
        };
    };
    CycleRemover.getNonTrivialStronglyConnectedComponents = function (graph) {
        return this.getStronglyConnectedComponents(graph).filter(function (g) { return g.edges.length; });
    };
    CycleRemover.getStronglyConnectedComponents = function (graph) {
        var _this = this;
        var nodesStack = [];
        var index = 0;
        var lowIndex = {};
        var lowLink = {};
        var onStack = {};
        var components = [];
        var visitedNodes = {};
        for (var i = 0; i < graph.nodes.length; i++) {
            var nodeKey = graph.nodes[i];
            var iterator = graph.createIterator(Structures_1.ConnectionMode.Outgoing);
            iterator.visitEachEdgeOnce = false;
            iterator.visitEachNodeOnce = false;
            iterator.onNode = function (n) {
                visitedNodes[n.key] = true;
                nodesStack.push(n);
                onStack[n.key] = true;
                lowLink[n.key] = index;
                lowIndex[n.key] = index;
                index++;
            };
            iterator.skipNode = function (n) { return visitedNodes[n.key]; };
            iterator.skipEdge = function (e) {
                var isVisited = visitedNodes[e.to];
                if (isVisited && onStack[e.to])
                    lowLink[e.from] = Math.min(lowLink[e.from], lowIndex[e.to]);
                return isVisited;
            };
            iterator.onAfterEdge = function (e) {
                lowLink[e.from] = Math.min(lowLink[e.from], lowLink[e.to]);
            };
            iterator.onAllEdges = function (n, outgoing) {
                if (outgoing && lowLink[n.key] === lowIndex[n.key])
                    components.push(_this.getStronglyConnectedComponent(graph, n, nodesStack, onStack));
            };
            iterator.iterate(nodeKey);
        }
        return components;
    };
    CycleRemover.getStronglyConnectedComponent = function (graph, root, nodesStack, onStack) {
        var itemsMap = {};
        var nodes = [];
        var edges = [];
        var topStackNode;
        do {
            topStackNode = nodesStack.pop();
            if (!itemsMap[topStackNode.key])
                nodes.push(topStackNode);
            itemsMap[topStackNode.key] = true;
            onStack[topStackNode.key] = false;
        } while (topStackNode !== root);
        nodes.forEach(function (n) {
            var aEdges = graph.getAdjacentEdges(n.key, Structures_1.ConnectionMode.Outgoing);
            edges = edges.concat(aEdges.filter(function (e) { return !itemsMap[e.key] && itemsMap[e.to]; }));
            aEdges.forEach(function (e) { return itemsMap[e.key] = true; });
        });
        return new Graph_1.Graph(nodes, edges);
    };
    return CycleRemover;
}());
exports.CycleRemover = CycleRemover;


/***/ }),
/* 271 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.SendToBackCommand = void 0;
var ChangeZindexHistoryItem_1 = __webpack_require__(102);
var SimpleCommandBase_1 = __webpack_require__(10);
var SendToBackCommand = (function (_super) {
    __extends(SendToBackCommand, _super);
    function SendToBackCommand() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    SendToBackCommand.prototype.isEnabled = function () {
        var items = this.control.selection.getSelectedItems();
        return _super.prototype.isEnabled.call(this) && items.length > 0 && this.needSendToBack(items);
    };
    SendToBackCommand.prototype.executeCore = function (state, parameter) {
        var _this = this;
        this.control.history.beginTransaction();
        var items = this.control.selection.getSelectedItems();
        items.forEach(function (item) {
            var newZIndex = _this.control.model.getIntersectItemsMinZIndex(item) - 1;
            _this.control.history.addAndRedo(new ChangeZindexHistoryItem_1.ChangeZindexHistoryItem(item, newZIndex));
        });
        this.control.history.endTransaction();
        return true;
    };
    SendToBackCommand.prototype.needSendToBack = function (items) {
        var _this = this;
        var _loop_1 = function (i) {
            var zIndex = this_1.control.model.getIntersectItemsMinZIndex(items[i]);
            if (zIndex < items[i].zIndex)
                return { value: true };
            if (zIndex === items[i].zIndex) {
                var result_1 = false;
                var sameZIndexItems = this_1.control.model.getIntersectItems(items[i]).filter(function (item) { return item.zIndex === items[i].zIndex; });
                sameZIndexItems.forEach(function (item) {
                    if (_this.control.model.getItemIndex(item) < _this.control.model.getItemIndex(items[i])) {
                        result_1 = true;
                        return;
                    }
                });
                return { value: result_1 };
            }
        };
        var this_1 = this;
        for (var i = 0; i < items.length; i++) {
            var state_1 = _loop_1(i);
            if (typeof state_1 === "object")
                return state_1.value;
        }
        return false;
    };
    return SendToBackCommand;
}(SimpleCommandBase_1.SimpleCommandBase));
exports.SendToBackCommand = SendToBackCommand;


/***/ }),
/* 272 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.BringToFrontCommand = void 0;
var ChangeZindexHistoryItem_1 = __webpack_require__(102);
var SimpleCommandBase_1 = __webpack_require__(10);
var BringToFrontCommand = (function (_super) {
    __extends(BringToFrontCommand, _super);
    function BringToFrontCommand() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    BringToFrontCommand.prototype.isEnabled = function () {
        var items = this.control.selection.getSelectedItems();
        return _super.prototype.isEnabled.call(this) && items.length > 0 && this.needBringToFront(items);
    };
    BringToFrontCommand.prototype.executeCore = function (state, parameter) {
        var _this = this;
        this.control.history.beginTransaction();
        var items = this.control.selection.getSelectedItems();
        items.forEach(function (item) {
            var newZIndex = _this.control.model.getIntersectItemsMaxZIndex(item) + 1;
            _this.control.history.addAndRedo(new ChangeZindexHistoryItem_1.ChangeZindexHistoryItem(item, newZIndex));
        });
        this.control.history.endTransaction();
        return true;
    };
    BringToFrontCommand.prototype.needBringToFront = function (items) {
        var _this = this;
        var _loop_1 = function (i) {
            var zIndex = this_1.control.model.getIntersectItemsMaxZIndex(items[i]);
            if (zIndex > items[i].zIndex)
                return { value: true };
            if (zIndex === items[i].zIndex) {
                var result_1 = false;
                var sameZIndexItems = this_1.control.model.getIntersectItems(items[i]).filter(function (item) { return item.zIndex === items[i].zIndex; });
                sameZIndexItems.forEach(function (item) {
                    if (_this.control.model.getItemIndex(item) > _this.control.model.getItemIndex(items[i])) {
                        result_1 = true;
                        return;
                    }
                });
                return { value: result_1 };
            }
        };
        var this_1 = this;
        for (var i = 0; i < items.length; i++) {
            var state_1 = _loop_1(i);
            if (typeof state_1 === "object")
                return state_1.value;
        }
        return false;
    };
    return BringToFrontCommand;
}(SimpleCommandBase_1.SimpleCommandBase));
exports.BringToFrontCommand = BringToFrontCommand;


/***/ }),
/* 273 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.MoveStepDownCommand = exports.MoveDownCommand = exports.MoveStepUpCommand = exports.MoveUpCommand = exports.MoveStepRightCommand = exports.MoveRightCommand = exports.MoveStepLeftCommand = exports.MoveLeftCommand = exports.MoveCommand = void 0;
var point_1 = __webpack_require__(0);
var ModelUtils_1 = __webpack_require__(4);
var unit_converter_1 = __webpack_require__(12);
var SimpleCommandBase_1 = __webpack_require__(10);
var __1 = __webpack_require__(58);
var MoveCommand = (function (_super) {
    __extends(MoveCommand, _super);
    function MoveCommand() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    MoveCommand.prototype.isEnabled = function () {
        return _super.prototype.isEnabled.call(this) && !this.control.selection.isEmpty();
    };
    MoveCommand.prototype.executeCore = function (state, parameter) {
        var _this = this;
        this.control.history.beginTransaction();
        var selection = this.control.selection;
        var selectedShapes = selection.getSelectedShapes();
        var selectedShapesWithoutDuplicates = selectedShapes.filter(function (shape) {
            while (shape.container) {
                if (selectedShapes.indexOf(shape.container) !== -1)
                    return false;
                shape = shape.container;
            }
            return true;
        });
        selectedShapesWithoutDuplicates.forEach(function (shape) {
            _this.permissionsProvider.addInteractingItem(shape, __1.DiagramModelOperation.MoveShape);
            var pos = _this.getPosition(shape.position);
            ModelUtils_1.ModelUtils.setShapePosition(_this.control.history, _this.control.model, shape, pos);
            ModelUtils_1.ModelUtils.updateShapeAttachedConnectors(_this.control.history, _this.control.model, shape);
            _this.permissionsProvider.clearInteractingItems();
        });
        var selectedItems = ModelUtils_1.ModelUtils.createSelectedItems(selection);
        selection.getSelectedConnectors().forEach(function (connector) {
            if (ModelUtils_1.ModelUtils.canMoveConnector(selectedItems, connector)) {
                var startPtIndex = connector.beginItem ? 1 : 0;
                var endPtIndex = connector.endItem ? (connector.points.length - 2) : (connector.points.length - 1);
                for (var i = startPtIndex; i <= endPtIndex; i++) {
                    var pos = _this.getPosition(connector.points[i]);
                    ModelUtils_1.ModelUtils.moveConnectorPoint(_this.control.history, connector, i, pos);
                }
            }
        });
        ModelUtils_1.ModelUtils.tryUpdateModelRectangle(this.control.history);
        this.control.history.endTransaction();
        return true;
    };
    Object.defineProperty(MoveCommand.prototype, "isPermissionsRequired", {
        get: function () { return true; },
        enumerable: false,
        configurable: true
    });
    return MoveCommand;
}(SimpleCommandBase_1.SimpleCommandBase));
exports.MoveCommand = MoveCommand;
var MoveLeftCommand = (function (_super) {
    __extends(MoveLeftCommand, _super);
    function MoveLeftCommand() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    MoveLeftCommand.prototype.getPosition = function (position) {
        return position.clone().offset(-unit_converter_1.UnitConverter.pixelsToTwips(1), 0);
    };
    return MoveLeftCommand;
}(MoveCommand));
exports.MoveLeftCommand = MoveLeftCommand;
var MoveStepLeftCommand = (function (_super) {
    __extends(MoveStepLeftCommand, _super);
    function MoveStepLeftCommand() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    MoveStepLeftCommand.prototype.getPosition = function (position) {
        if (this.control.settings.snapToGrid)
            return new point_1.Point(ModelUtils_1.ModelUtils.getSnappedPos(this.control.model, this.control.settings.gridSize, position.x - (this.control.settings.gridSize / 2 + 2), true), position.y);
        else
            return position.clone().offset(-this.control.settings.gridSize, 0);
    };
    return MoveStepLeftCommand;
}(MoveCommand));
exports.MoveStepLeftCommand = MoveStepLeftCommand;
var MoveRightCommand = (function (_super) {
    __extends(MoveRightCommand, _super);
    function MoveRightCommand() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    MoveRightCommand.prototype.getPosition = function (position) {
        return position.clone().offset(unit_converter_1.UnitConverter.pixelsToTwips(1), 0);
    };
    return MoveRightCommand;
}(MoveCommand));
exports.MoveRightCommand = MoveRightCommand;
var MoveStepRightCommand = (function (_super) {
    __extends(MoveStepRightCommand, _super);
    function MoveStepRightCommand() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    MoveStepRightCommand.prototype.getPosition = function (position) {
        if (this.control.settings.snapToGrid)
            return new point_1.Point(ModelUtils_1.ModelUtils.getSnappedPos(this.control.model, this.control.settings.gridSize, position.x + (this.control.settings.gridSize / 2 + 2), true), position.y);
        else
            return position.clone().offset(this.control.settings.gridSize, 0);
    };
    return MoveStepRightCommand;
}(MoveCommand));
exports.MoveStepRightCommand = MoveStepRightCommand;
var MoveUpCommand = (function (_super) {
    __extends(MoveUpCommand, _super);
    function MoveUpCommand() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    MoveUpCommand.prototype.getPosition = function (position) {
        return position.clone().offset(0, -unit_converter_1.UnitConverter.pixelsToTwips(1));
    };
    return MoveUpCommand;
}(MoveCommand));
exports.MoveUpCommand = MoveUpCommand;
var MoveStepUpCommand = (function (_super) {
    __extends(MoveStepUpCommand, _super);
    function MoveStepUpCommand() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    MoveStepUpCommand.prototype.getPosition = function (position) {
        if (this.control.settings.snapToGrid)
            return new point_1.Point(position.x, ModelUtils_1.ModelUtils.getSnappedPos(this.control.model, this.control.settings.gridSize, position.y - (this.control.settings.gridSize / 2 + 2), false));
        else
            return position.clone().offset(0, -this.control.settings.gridSize);
    };
    return MoveStepUpCommand;
}(MoveCommand));
exports.MoveStepUpCommand = MoveStepUpCommand;
var MoveDownCommand = (function (_super) {
    __extends(MoveDownCommand, _super);
    function MoveDownCommand() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    MoveDownCommand.prototype.getPosition = function (position) {
        return position.clone().offset(0, unit_converter_1.UnitConverter.pixelsToTwips(1));
    };
    return MoveDownCommand;
}(MoveCommand));
exports.MoveDownCommand = MoveDownCommand;
var MoveStepDownCommand = (function (_super) {
    __extends(MoveStepDownCommand, _super);
    function MoveStepDownCommand() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    MoveStepDownCommand.prototype.getPosition = function (position) {
        if (this.control.settings.snapToGrid)
            return new point_1.Point(position.x, ModelUtils_1.ModelUtils.getSnappedPos(this.control.model, this.control.settings.gridSize, position.y + (this.control.settings.gridSize / 2 + 2), false));
        else
            return position.clone().offset(0, this.control.settings.gridSize);
    };
    return MoveStepDownCommand;
}(MoveCommand));
exports.MoveStepDownCommand = MoveStepDownCommand;


/***/ }),
/* 274 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.ToggleAutoZoomCommand = exports.ToggleAutoZoomToWidthCommand = exports.ToggleAutoZoomToContentCommand = exports.SwitchAutoZoomCommand = exports.FitToWidthCommand = exports.FitToScreenCommand = exports.ChangeZoomLevelItemsCommand = exports.ChangeZoomLevelTo200Command = exports.ChangeZoomLevelTo150Command = exports.ChangeZoomLevelTo125Command = exports.ChangeZoomLevelTo100Command = exports.ChangeZoomLevelTo75Command = exports.ChangeZoomLevelTo50Command = exports.ChangeZoomLevelTo25Command = exports.ChangeZoomLevelInPercentageCommand = exports.ChangeZoomLevelCommand = void 0;
var SimpleCommandBase_1 = __webpack_require__(10);
var Settings_1 = __webpack_require__(28);
var ChangeZoomLevelCommand = (function (_super) {
    __extends(ChangeZoomLevelCommand, _super);
    function ChangeZoomLevelCommand() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    ChangeZoomLevelCommand.prototype.isEnabledInReadOnlyMode = function () {
        return true;
    };
    ChangeZoomLevelCommand.prototype.getValue = function () {
        return this.control.view.getZoom();
    };
    ChangeZoomLevelCommand.prototype.executeCore = function (state, parameter) {
        this.control.settings.zoomLevel = parameter;
        this.control.settings.autoZoom = Settings_1.AutoZoomMode.Disabled;
        this.control.updateLayout(true);
        return true;
    };
    ChangeZoomLevelCommand.prototype.getItems = function () {
        return this.control.settings.zoomLevelItems.map(function (l) {
            return { value: l, text: l * 100 + "%" };
        });
    };
    return ChangeZoomLevelCommand;
}(SimpleCommandBase_1.SimpleCommandBase));
exports.ChangeZoomLevelCommand = ChangeZoomLevelCommand;
var ChangeZoomLevelInPercentageCommand = (function (_super) {
    __extends(ChangeZoomLevelInPercentageCommand, _super);
    function ChangeZoomLevelInPercentageCommand() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    ChangeZoomLevelInPercentageCommand.prototype.executeCore = function (state, parameter) {
        return _super.prototype.executeCore.call(this, state, parameter / 100);
    };
    ChangeZoomLevelInPercentageCommand.prototype.getValue = function () {
        return this.control.view.getZoom() * 100;
    };
    return ChangeZoomLevelInPercentageCommand;
}(ChangeZoomLevelCommand));
exports.ChangeZoomLevelInPercentageCommand = ChangeZoomLevelInPercentageCommand;
var ChangeZoomLevelExactlyCommand = (function (_super) {
    __extends(ChangeZoomLevelExactlyCommand, _super);
    function ChangeZoomLevelExactlyCommand() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    ChangeZoomLevelExactlyCommand.prototype.getValue = function () {
        return this.control.view.getZoom() === this.exactValue;
    };
    ChangeZoomLevelExactlyCommand.prototype.executeCore = function (state, parameter) {
        _super.prototype.executeCore.call(this, state, this.exactValue);
        return true;
    };
    ChangeZoomLevelExactlyCommand.prototype.getItems = function () {
        return undefined;
    };
    return ChangeZoomLevelExactlyCommand;
}(ChangeZoomLevelCommand));
var ChangeZoomLevelTo25Command = (function (_super) {
    __extends(ChangeZoomLevelTo25Command, _super);
    function ChangeZoomLevelTo25Command() {
        var _this = _super !== null && _super.apply(this, arguments) || this;
        _this.exactValue = 0.25;
        return _this;
    }
    return ChangeZoomLevelTo25Command;
}(ChangeZoomLevelExactlyCommand));
exports.ChangeZoomLevelTo25Command = ChangeZoomLevelTo25Command;
var ChangeZoomLevelTo50Command = (function (_super) {
    __extends(ChangeZoomLevelTo50Command, _super);
    function ChangeZoomLevelTo50Command() {
        var _this = _super !== null && _super.apply(this, arguments) || this;
        _this.exactValue = 0.5;
        return _this;
    }
    return ChangeZoomLevelTo50Command;
}(ChangeZoomLevelExactlyCommand));
exports.ChangeZoomLevelTo50Command = ChangeZoomLevelTo50Command;
var ChangeZoomLevelTo75Command = (function (_super) {
    __extends(ChangeZoomLevelTo75Command, _super);
    function ChangeZoomLevelTo75Command() {
        var _this = _super !== null && _super.apply(this, arguments) || this;
        _this.exactValue = 0.75;
        return _this;
    }
    return ChangeZoomLevelTo75Command;
}(ChangeZoomLevelExactlyCommand));
exports.ChangeZoomLevelTo75Command = ChangeZoomLevelTo75Command;
var ChangeZoomLevelTo100Command = (function (_super) {
    __extends(ChangeZoomLevelTo100Command, _super);
    function ChangeZoomLevelTo100Command() {
        var _this = _super !== null && _super.apply(this, arguments) || this;
        _this.exactValue = 1;
        return _this;
    }
    return ChangeZoomLevelTo100Command;
}(ChangeZoomLevelExactlyCommand));
exports.ChangeZoomLevelTo100Command = ChangeZoomLevelTo100Command;
var ChangeZoomLevelTo125Command = (function (_super) {
    __extends(ChangeZoomLevelTo125Command, _super);
    function ChangeZoomLevelTo125Command() {
        var _this = _super !== null && _super.apply(this, arguments) || this;
        _this.exactValue = 1.25;
        return _this;
    }
    return ChangeZoomLevelTo125Command;
}(ChangeZoomLevelExactlyCommand));
exports.ChangeZoomLevelTo125Command = ChangeZoomLevelTo125Command;
var ChangeZoomLevelTo150Command = (function (_super) {
    __extends(ChangeZoomLevelTo150Command, _super);
    function ChangeZoomLevelTo150Command() {
        var _this = _super !== null && _super.apply(this, arguments) || this;
        _this.exactValue = 1.5;
        return _this;
    }
    return ChangeZoomLevelTo150Command;
}(ChangeZoomLevelExactlyCommand));
exports.ChangeZoomLevelTo150Command = ChangeZoomLevelTo150Command;
var ChangeZoomLevelTo200Command = (function (_super) {
    __extends(ChangeZoomLevelTo200Command, _super);
    function ChangeZoomLevelTo200Command() {
        var _this = _super !== null && _super.apply(this, arguments) || this;
        _this.exactValue = 2;
        return _this;
    }
    return ChangeZoomLevelTo200Command;
}(ChangeZoomLevelExactlyCommand));
exports.ChangeZoomLevelTo200Command = ChangeZoomLevelTo200Command;
var ChangeZoomLevelItemsCommand = (function (_super) {
    __extends(ChangeZoomLevelItemsCommand, _super);
    function ChangeZoomLevelItemsCommand() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    ChangeZoomLevelItemsCommand.prototype.isEnabledInReadOnlyMode = function () {
        return true;
    };
    ChangeZoomLevelItemsCommand.prototype.getValue = function () {
        return this.control.settings.zoomLevelItems;
    };
    ChangeZoomLevelItemsCommand.prototype.executeCore = function (state, parameter) {
        this.control.settings.zoomLevelItems = parameter;
        return true;
    };
    return ChangeZoomLevelItemsCommand;
}(SimpleCommandBase_1.SimpleCommandBase));
exports.ChangeZoomLevelItemsCommand = ChangeZoomLevelItemsCommand;
var FitZoomCommandBase = (function (_super) {
    __extends(FitZoomCommandBase, _super);
    function FitZoomCommandBase() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    FitZoomCommandBase.prototype.isEnabled = function () {
        return _super.prototype.isEnabled.call(this) && !!this.control.render;
    };
    FitZoomCommandBase.prototype.isEnabledInReadOnlyMode = function () {
        return true;
    };
    FitZoomCommandBase.prototype.executeCore = function (state) {
        var zoomLevel = this.getZoomLevel();
        this.control.settings.zoomLevel = zoomLevel;
        this.control.settings.autoZoom = Settings_1.AutoZoomMode.Disabled;
        this.control.updateLayout(true);
        return true;
    };
    return FitZoomCommandBase;
}(SimpleCommandBase_1.SimpleCommandBase));
var FitToScreenCommand = (function (_super) {
    __extends(FitToScreenCommand, _super);
    function FitToScreenCommand() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    FitToScreenCommand.prototype.getZoomLevel = function () {
        return this.control.render.view.getActualAutoZoomLevel(Settings_1.AutoZoomMode.FitContent);
    };
    return FitToScreenCommand;
}(FitZoomCommandBase));
exports.FitToScreenCommand = FitToScreenCommand;
var FitToWidthCommand = (function (_super) {
    __extends(FitToWidthCommand, _super);
    function FitToWidthCommand() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    FitToWidthCommand.prototype.getZoomLevel = function () {
        return this.control.render.view.getActualAutoZoomLevel(Settings_1.AutoZoomMode.FitToWidth);
    };
    return FitToWidthCommand;
}(FitZoomCommandBase));
exports.FitToWidthCommand = FitToWidthCommand;
var SwitchAutoZoomCommand = (function (_super) {
    __extends(SwitchAutoZoomCommand, _super);
    function SwitchAutoZoomCommand() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    SwitchAutoZoomCommand.prototype.isEnabledInReadOnlyMode = function () {
        return true;
    };
    SwitchAutoZoomCommand.prototype.getValue = function () {
        return this.control.settings.autoZoom;
    };
    SwitchAutoZoomCommand.prototype.executeCore = function (state, value) {
        value = parseInt(value);
        if (this.control.settings.autoZoom === value)
            return false;
        if (value === Settings_1.AutoZoomMode.Disabled)
            this.control.settings.zoomLevel = this.control.view.getZoom();
        this.control.settings.autoZoom = value;
        this.control.updateLayout(true);
        return true;
    };
    return SwitchAutoZoomCommand;
}(SimpleCommandBase_1.SimpleCommandBase));
exports.SwitchAutoZoomCommand = SwitchAutoZoomCommand;
var ToggleAutoZoomToContentCommand = (function (_super) {
    __extends(ToggleAutoZoomToContentCommand, _super);
    function ToggleAutoZoomToContentCommand() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    ToggleAutoZoomToContentCommand.prototype.getValue = function () {
        return this.control.settings.autoZoom === Settings_1.AutoZoomMode.FitContent;
    };
    ToggleAutoZoomToContentCommand.prototype.executeCore = function (state, value) {
        return _super.prototype.executeCore.call(this, state, Settings_1.AutoZoomMode.FitContent);
    };
    return ToggleAutoZoomToContentCommand;
}(SwitchAutoZoomCommand));
exports.ToggleAutoZoomToContentCommand = ToggleAutoZoomToContentCommand;
var ToggleAutoZoomToWidthCommand = (function (_super) {
    __extends(ToggleAutoZoomToWidthCommand, _super);
    function ToggleAutoZoomToWidthCommand() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    ToggleAutoZoomToWidthCommand.prototype.getValue = function () {
        return this.control.settings.autoZoom === Settings_1.AutoZoomMode.FitToWidth;
    };
    ToggleAutoZoomToWidthCommand.prototype.executeCore = function (state, value) {
        return _super.prototype.executeCore.call(this, state, Settings_1.AutoZoomMode.FitToWidth);
    };
    return ToggleAutoZoomToWidthCommand;
}(SwitchAutoZoomCommand));
exports.ToggleAutoZoomToWidthCommand = ToggleAutoZoomToWidthCommand;
var ToggleAutoZoomCommand = (function (_super) {
    __extends(ToggleAutoZoomCommand, _super);
    function ToggleAutoZoomCommand() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    ToggleAutoZoomCommand.prototype.isEnabled = function () {
        return _super.prototype.isEnabled.call(this) && !!this.control.render;
    };
    ToggleAutoZoomCommand.prototype.isEnabledInReadOnlyMode = function () {
        return true;
    };
    ToggleAutoZoomCommand.prototype.getValue = function () {
        return this.control.settings.autoZoom;
    };
    ToggleAutoZoomCommand.prototype.executeCore = function (state, value) {
        var newValue;
        if (value === undefined)
            newValue = this.control.settings.autoZoom === Settings_1.AutoZoomMode.Disabled ? Settings_1.AutoZoomMode.FitContent : Settings_1.AutoZoomMode.Disabled;
        else
            newValue = value ? Settings_1.AutoZoomMode.FitContent : Settings_1.AutoZoomMode.Disabled;
        if (this.control.settings.autoZoom === newValue)
            return false;
        if (!newValue)
            this.control.settings.zoomLevel = this.control.view.getZoom();
        this.control.settings.autoZoom = newValue;
        this.control.updateLayout(true);
        return true;
    };
    return ToggleAutoZoomCommand;
}(SimpleCommandBase_1.SimpleCommandBase));
exports.ToggleAutoZoomCommand = ToggleAutoZoomCommand;


/***/ }),
/* 275 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.BindDocumentCommand = void 0;
var DataLayoutParameters_1 = __webpack_require__(103);
var SimpleCommandBase_1 = __webpack_require__(10);
var BindDocumentCommand = (function (_super) {
    __extends(BindDocumentCommand, _super);
    function BindDocumentCommand() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    BindDocumentCommand.prototype.isEnabledInReadOnlyMode = function () {
        return true;
    };
    BindDocumentCommand.prototype.executeCore = function (state, parameter) {
        if (!parameter || !Array.isArray(parameter.nodeDataSource))
            throw Error("Format exception");
        this.performImportData(parameter);
        this.control.updateLayout(true);
        return true;
    };
    BindDocumentCommand.prototype.performImportData = function (parameter) {
        var dataSource = this.control.createDocumentDataSource(parameter.nodeDataSource, parameter.edgeDataSource, parameter.dataParameters, parameter.nodeDataImporter, parameter.edgeDataImporter);
        this.control.beginUpdateCanvas();
        this.permissionsProvider.lockPermissions();
        var layoutParameters = new DataLayoutParameters_1.DataLayoutParameters(this.control.settings, parameter.layoutParameters);
        dataSource.createModelItems(this.control.history, this.control.model, this.control.shapeDescriptionManager, this.control.selection, layoutParameters, this.control.settings.snapToGrid, this.control.settings.gridSize, this.control.measurer);
        this.permissionsProvider.unlockPermissions();
        this.control.endUpdateCanvas();
    };
    return BindDocumentCommand;
}(SimpleCommandBase_1.SimpleCommandBase));
exports.BindDocumentCommand = BindDocumentCommand;


/***/ }),
/* 276 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.UnbindDocumentCommand = void 0;
var ModelUtils_1 = __webpack_require__(4);
var SimpleCommandBase_1 = __webpack_require__(10);
var UnbindDocumentCommand = (function (_super) {
    __extends(UnbindDocumentCommand, _super);
    function UnbindDocumentCommand() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    UnbindDocumentCommand.prototype.isEnabledInReadOnlyMode = function () {
        return true;
    };
    UnbindDocumentCommand.prototype.executeCore = function (state) {
        this.permissionsProvider.lockPermissions();
        this.control.deleteDocumentDataSource();
        ModelUtils_1.ModelUtils.deleteAllItems(this.control.history, this.control.model, this.control.selection);
        this.control.history.clear();
        this.permissionsProvider.unlockPermissions();
        return true;
    };
    return UnbindDocumentCommand;
}(SimpleCommandBase_1.SimpleCommandBase));
exports.UnbindDocumentCommand = UnbindDocumentCommand;


/***/ }),
/* 277 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.LockCommand = void 0;
var ChangeLockedCommand_1 = __webpack_require__(145);
var LockCommand = (function (_super) {
    __extends(LockCommand, _super);
    function LockCommand() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    LockCommand.prototype.getLockState = function () {
        return true;
    };
    return LockCommand;
}(ChangeLockedCommand_1.ChangeLockedCommand));
exports.LockCommand = LockCommand;


/***/ }),
/* 278 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.UnLockCommand = void 0;
var ChangeLockedCommand_1 = __webpack_require__(145);
var UnLockCommand = (function (_super) {
    __extends(UnLockCommand, _super);
    function UnLockCommand() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    UnLockCommand.prototype.getLockState = function () {
        return false;
    };
    return UnLockCommand;
}(ChangeLockedCommand_1.ChangeLockedCommand));
exports.UnLockCommand = UnLockCommand;


/***/ }),
/* 279 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.CloneDownCommand = exports.CloneUpCommand = exports.CloneRightCommand = exports.CloneLeftCommand = exports.CloneCommand = void 0;
var ModelUtils_1 = __webpack_require__(4);
var SimpleCommandBase_1 = __webpack_require__(10);
var CloneCommand = (function (_super) {
    __extends(CloneCommand, _super);
    function CloneCommand() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    CloneCommand.prototype.isEnabled = function () {
        var items = this.control.selection.getSelectedItems();
        return _super.prototype.isEnabled.call(this) && items.length && items.length > 0 && this.permissionsProvider.canAddItems(items);
    };
    CloneCommand.prototype.executeCore = function (state, parameter) {
        var selectionRect = ModelUtils_1.ModelUtils.createRectangle(this.control.selection.getSelectedItems());
        ModelUtils_1.ModelUtils.cloneSelectionToOffset(this.control.history, this.control.model, undefined, this.control.selection, this.getOffsetX(selectionRect), this.getOffsetY(selectionRect));
        return true;
    };
    Object.defineProperty(CloneCommand.prototype, "isPermissionsRequired", {
        get: function () { return true; },
        enumerable: false,
        configurable: true
    });
    CloneCommand.prototype.getOffsetX = function (selectionRect) {
        return 0;
    };
    CloneCommand.prototype.getOffsetY = function (selectionRect) {
        return 0;
    };
    return CloneCommand;
}(SimpleCommandBase_1.SimpleCommandBase));
exports.CloneCommand = CloneCommand;
var CloneLeftCommand = (function (_super) {
    __extends(CloneLeftCommand, _super);
    function CloneLeftCommand() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    CloneLeftCommand.prototype.getOffsetX = function (selectionRect) {
        return -selectionRect.width;
    };
    return CloneLeftCommand;
}(CloneCommand));
exports.CloneLeftCommand = CloneLeftCommand;
var CloneRightCommand = (function (_super) {
    __extends(CloneRightCommand, _super);
    function CloneRightCommand() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    CloneRightCommand.prototype.getOffsetX = function (selectionRect) {
        return selectionRect.width;
    };
    return CloneRightCommand;
}(CloneCommand));
exports.CloneRightCommand = CloneRightCommand;
var CloneUpCommand = (function (_super) {
    __extends(CloneUpCommand, _super);
    function CloneUpCommand() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    CloneUpCommand.prototype.getOffsetY = function (selectionRect) {
        return -selectionRect.height;
    };
    return CloneUpCommand;
}(CloneCommand));
exports.CloneUpCommand = CloneUpCommand;
var CloneDownCommand = (function (_super) {
    __extends(CloneDownCommand, _super);
    function CloneDownCommand() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    CloneDownCommand.prototype.getOffsetY = function (selectionRect) {
        return selectionRect.height;
    };
    return CloneDownCommand;
}(CloneCommand));
exports.CloneDownCommand = CloneDownCommand;


/***/ }),
/* 280 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.ChangeViewUnitsCommand = exports.ChangeUnitsCommand = void 0;
var ChangePagePropertyCommand_1 = __webpack_require__(77);
var ChangeUnitsHistoryItem_1 = __webpack_require__(281);
var SimpleCommandBase_1 = __webpack_require__(10);
var LocalizationService_1 = __webpack_require__(36);
var ChangeUnitsCommand = (function (_super) {
    __extends(ChangeUnitsCommand, _super);
    function ChangeUnitsCommand() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    ChangeUnitsCommand.prototype.isEnabledInReadOnlyMode = function () {
        return true;
    };
    ChangeUnitsCommand.prototype.getValue = function () {
        return this.control.model.units;
    };
    ChangeUnitsCommand.prototype.createHistoryItems = function (parameter) {
        return [new ChangeUnitsHistoryItem_1.ChangeUnitsHistoryItem(parameter)];
    };
    ChangeUnitsCommand.prototype.getItems = function () {
        return Object.keys(LocalizationService_1.DiagramLocalizationService.unitItems).map(function (key) {
            return { value: parseInt(key), text: LocalizationService_1.DiagramLocalizationService.unitItems[key] };
        });
    };
    return ChangeUnitsCommand;
}(ChangePagePropertyCommand_1.ChangePagePropertyCommand));
exports.ChangeUnitsCommand = ChangeUnitsCommand;
var ChangeViewUnitsCommand = (function (_super) {
    __extends(ChangeViewUnitsCommand, _super);
    function ChangeViewUnitsCommand() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    ChangeViewUnitsCommand.prototype.isEnabledInReadOnlyMode = function () {
        return true;
    };
    ChangeViewUnitsCommand.prototype.getValue = function () {
        return this.control.settings.viewUnits;
    };
    ChangeViewUnitsCommand.prototype.executeCore = function (state, parameter) {
        this.control.settings.viewUnits = parameter;
        return true;
    };
    ChangeViewUnitsCommand.prototype.getItems = function () {
        return Object.keys(LocalizationService_1.DiagramLocalizationService.unitItems).map(function (key) {
            return { value: parseInt(key), text: LocalizationService_1.DiagramLocalizationService.unitItems[key] };
        });
    };
    return ChangeViewUnitsCommand;
}(SimpleCommandBase_1.SimpleCommandBase));
exports.ChangeViewUnitsCommand = ChangeViewUnitsCommand;


/***/ }),
/* 281 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.ChangeUnitsHistoryItem = void 0;
var HistoryItem_1 = __webpack_require__(8);
var ChangeUnitsHistoryItem = (function (_super) {
    __extends(ChangeUnitsHistoryItem, _super);
    function ChangeUnitsHistoryItem(units) {
        var _this = _super.call(this) || this;
        _this.units = units;
        return _this;
    }
    ChangeUnitsHistoryItem.prototype.redo = function (manipulator) {
        this.oldUnits = manipulator.model.units;
        manipulator.model.units = this.units;
    };
    ChangeUnitsHistoryItem.prototype.undo = function (manipulator) {
        manipulator.model.units = this.oldUnits;
    };
    return ChangeUnitsHistoryItem;
}(HistoryItem_1.HistoryItem));
exports.ChangeUnitsHistoryItem = ChangeUnitsHistoryItem;


/***/ }),
/* 282 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.ChangePageColorCommand = void 0;
var ChangePagePropertyCommand_1 = __webpack_require__(77);
var ChangePageColorHistoryItem_1 = __webpack_require__(283);
var Model_1 = __webpack_require__(62);
var color_1 = __webpack_require__(22);
var ChangePageColorCommand = (function (_super) {
    __extends(ChangePageColorCommand, _super);
    function ChangePageColorCommand() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    ChangePageColorCommand.prototype.getValue = function () {
        return color_1.ColorUtils.colorToHash(this.control.model.pageColor);
    };
    ChangePageColorCommand.prototype.getDefaultValue = function () {
        return color_1.ColorUtils.colorToHash(Model_1.DiagramModel.defaultPageColor);
    };
    ChangePageColorCommand.prototype.createHistoryItems = function (parameter) {
        return [new ChangePageColorHistoryItem_1.ChangePageColorHistoryItem(color_1.ColorUtils.fromString(parameter))];
    };
    return ChangePageColorCommand;
}(ChangePagePropertyCommand_1.ChangePagePropertyCommand));
exports.ChangePageColorCommand = ChangePageColorCommand;


/***/ }),
/* 283 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.ChangePageColorHistoryItem = void 0;
var HistoryItem_1 = __webpack_require__(8);
var ChangePageColorHistoryItem = (function (_super) {
    __extends(ChangePageColorHistoryItem, _super);
    function ChangePageColorHistoryItem(value) {
        var _this = _super.call(this) || this;
        _this.value = value;
        return _this;
    }
    ChangePageColorHistoryItem.prototype.redo = function (manipulator) {
        this.oldValue = manipulator.model.pageColor;
        manipulator.changePageColor(this.value);
    };
    ChangePageColorHistoryItem.prototype.undo = function (manipulator) {
        manipulator.changePageColor(this.oldValue);
    };
    return ChangePageColorHistoryItem;
}(HistoryItem_1.HistoryItem));
exports.ChangePageColorHistoryItem = ChangePageColorHistoryItem;


/***/ }),
/* 284 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.ChangeShowGridCommand = void 0;
var SimpleCommandBase_1 = __webpack_require__(10);
var ChangeShowGridCommand = (function (_super) {
    __extends(ChangeShowGridCommand, _super);
    function ChangeShowGridCommand() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    ChangeShowGridCommand.prototype.isEnabledInReadOnlyMode = function () {
        return true;
    };
    ChangeShowGridCommand.prototype.executeCore = function (state, parameter) {
        var newValue = parameter === undefined ? !this.control.settings.showGrid : !!parameter;
        if (this.control.settings.showGrid !== newValue) {
            this.control.settings.showGrid = newValue;
            return true;
        }
        return false;
    };
    ChangeShowGridCommand.prototype.getValue = function () {
        return this.control.settings.showGrid;
    };
    return ChangeShowGridCommand;
}(SimpleCommandBase_1.SimpleCommandBase));
exports.ChangeShowGridCommand = ChangeShowGridCommand;


/***/ }),
/* 285 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.ToggleFullscreenCommand = void 0;
var SimpleCommandBase_1 = __webpack_require__(10);
var ToggleFullscreenCommand = (function (_super) {
    __extends(ToggleFullscreenCommand, _super);
    function ToggleFullscreenCommand() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    ToggleFullscreenCommand.prototype.isEnabledInReadOnlyMode = function () {
        return true;
    };
    ToggleFullscreenCommand.prototype.getValue = function () {
        return this.control.settings.fullscreen;
    };
    ToggleFullscreenCommand.prototype.executeCore = function (state, parameter) {
        var newValue = typeof parameter === "boolean" ? parameter : !state.value;
        if (this.control.settings.fullscreen !== newValue) {
            this.control.settings.fullscreen = !state.value;
            this.control.notifyToggleFullscreen(this.control.settings.fullscreen);
        }
        return true;
    };
    return ToggleFullscreenCommand;
}(SimpleCommandBase_1.SimpleCommandBase));
exports.ToggleFullscreenCommand = ToggleFullscreenCommand;


/***/ }),
/* 286 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.ToggleSimpleViewCommand = void 0;
var SimpleCommandBase_1 = __webpack_require__(10);
var ToggleSimpleViewCommand = (function (_super) {
    __extends(ToggleSimpleViewCommand, _super);
    function ToggleSimpleViewCommand() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    ToggleSimpleViewCommand.prototype.isEnabledInReadOnlyMode = function () {
        return true;
    };
    ToggleSimpleViewCommand.prototype.getValue = function () {
        return this.control.settings.simpleView;
    };
    ToggleSimpleViewCommand.prototype.executeCore = function (state, parameter) {
        if (typeof parameter === "boolean")
            this.control.settings.simpleView = parameter;
        else if (parameter === undefined)
            this.control.settings.simpleView = !state.value;
        this.control.updateLayout(true);
        return true;
    };
    return ToggleSimpleViewCommand;
}(SimpleCommandBase_1.SimpleCommandBase));
exports.ToggleSimpleViewCommand = ToggleSimpleViewCommand;


/***/ }),
/* 287 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.ToggleReadOnlyCommand = void 0;
var SimpleCommandBase_1 = __webpack_require__(10);
var ToggleReadOnlyCommand = (function (_super) {
    __extends(ToggleReadOnlyCommand, _super);
    function ToggleReadOnlyCommand() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    ToggleReadOnlyCommand.prototype.isEnabledInReadOnlyMode = function () {
        return true;
    };
    ToggleReadOnlyCommand.prototype.getValue = function () {
        return this.control.settings.readOnly;
    };
    ToggleReadOnlyCommand.prototype.executeCore = function (state, parameter) {
        if (typeof parameter === "boolean")
            this.control.settings.readOnly = parameter;
        else if (parameter === undefined)
            this.control.settings.readOnly = !state.value;
        return true;
    };
    return ToggleReadOnlyCommand;
}(SimpleCommandBase_1.SimpleCommandBase));
exports.ToggleReadOnlyCommand = ToggleReadOnlyCommand;


/***/ }),
/* 288 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.EditShapeImageCommand = void 0;
var EditShapeImageCommandBase_1 = __webpack_require__(104);
var EditShapeImageCommand = (function (_super) {
    __extends(EditShapeImageCommand, _super);
    function EditShapeImageCommand() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    EditShapeImageCommand.prototype.isEnabled = function () {
        var selectedShape = this.getSelectedShape();
        return _super.prototype.isEnabled.call(this) && !selectedShape.image.isEmpty;
    };
    return EditShapeImageCommand;
}(EditShapeImageCommandBase_1.EditShapeImageCommandBase));
exports.EditShapeImageCommand = EditShapeImageCommand;


/***/ }),
/* 289 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.PasteSelectionInPositionCommand = void 0;
var PasteSelectionCommandBase_1 = __webpack_require__(141);
var Shape_1 = __webpack_require__(14);
var Connector_1 = __webpack_require__(6);
var point_1 = __webpack_require__(0);
var PasteSelectionInPositionCommand = (function (_super) {
    __extends(PasteSelectionInPositionCommand, _super);
    function PasteSelectionInPositionCommand() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    PasteSelectionInPositionCommand.prototype.getEventPositionOffset = function (items, evtPosition) {
        var selectionPos = items.reduce(function (min, i) {
            return {
                x: Math.min(min.x, i instanceof Shape_1.Shape ? i.position.x : i instanceof Connector_1.Connector ? i.getMinX() : Number.MAX_VALUE),
                y: Math.min(min.y, i instanceof Shape_1.Shape ? i.position.y : i instanceof Connector_1.Connector ? i.getMinY() : Number.MAX_VALUE)
            };
        }, {
            x: Number.MAX_VALUE,
            y: Number.MAX_VALUE
        });
        var newSelectionPos = this.control.render.getModelPointByEventPoint(evtPosition.x, evtPosition.y);
        return new point_1.Point(newSelectionPos.x - selectionPos.x, newSelectionPos.y - selectionPos.y);
    };
    return PasteSelectionInPositionCommand;
}(PasteSelectionCommandBase_1.PasteSelectionCommandBase));
exports.PasteSelectionInPositionCommand = PasteSelectionInPositionCommand;


/***/ }),
/* 290 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.ImportXMLCommand = void 0;
var XMLImporter_1 = __webpack_require__(291);
var ExportImportCommandBase_1 = __webpack_require__(57);
var ImportXMLCommand = (function (_super) {
    __extends(ImportXMLCommand, _super);
    function ImportXMLCommand() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    ImportXMLCommand.prototype.executeCore = function (state, parameter) {
        var importer = new XMLImporter_1.XmlImporter(this.control.shapeDescriptionManager, parameter);
        var model = importer.import();
        this.control.importModel(model);
        return true;
    };
    return ImportXMLCommand;
}(ExportImportCommandBase_1.ExportImportCommandBase));
exports.ImportXMLCommand = ImportXMLCommand;


/***/ }),
/* 291 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.XmlImporter = void 0;
var Connector_1 = __webpack_require__(6);
var Shape_1 = __webpack_require__(14);
var ImporterBase_1 = __webpack_require__(133);
var ShapeTypes_1 = __webpack_require__(1);
var ShapeDescriptionManager_1 = __webpack_require__(91);
var size_1 = __webpack_require__(2);
var point_1 = __webpack_require__(0);
var ImportUtils_1 = __webpack_require__(95);
var color_1 = __webpack_require__(22);
var unit_converter_1 = __webpack_require__(12);
var XmlImporter = (function (_super) {
    __extends(XmlImporter, _super);
    function XmlImporter(shapeDescriptionManager, xml) {
        var _this = _super.call(this, shapeDescriptionManager) || this;
        _this.doc = ImportUtils_1.ImportUtils.createDocument(xml);
        return _this;
    }
    XmlImporter.prototype.getObject = function () {
        return this.doc;
    };
    XmlImporter.prototype.getPageObject = function (obj) {
        var pageElements = this.doc.querySelectorAll("[ItemKind='DiagramRoot']");
        return pageElements && pageElements[0];
    };
    XmlImporter.prototype.getShapeObjects = function (obj) {
        var shapeObjs = [];
        this.doc.querySelectorAll("[ItemKind='DiagramRoot'] > Children > [ItemKind='DiagramShape']").forEach(function (obj) { shapeObjs.push(obj); });
        this.doc.querySelectorAll("[ItemKind='DiagramRoot'] > Children > [ItemKind='DiagramContainer']").forEach(function (obj) { shapeObjs.push(obj); });
        return shapeObjs;
    };
    XmlImporter.prototype.getConnectorObjects = function (obj) {
        var connectorObjs = [];
        this.doc.querySelectorAll("[ItemKind='DiagramRoot'] > Children > [ItemKind='DiagramConnector']").forEach(function (obj) { connectorObjs.push(obj); });
        return connectorObjs;
    };
    XmlImporter.prototype.importPageSettings = function (model, pageObj) {
        if (!pageObj)
            return;
        var pageSizeAttr = pageObj.getAttribute("PageSize");
        var pageSize = this.getSize(pageSizeAttr);
        if (pageSize) {
            model.size = pageSize.clone();
            model.pageSize = pageSize.clone();
        }
    };
    XmlImporter.prototype.importShape = function (shapeObj) {
        var positionAttr = shapeObj.getAttribute("Position");
        var position = this.getPoint(positionAttr);
        var shapeAttr = shapeObj.getAttribute("Shape");
        var shapeType = this.getShapeType(shapeAttr);
        var description = this.shapeDescriptionManager.get(shapeType);
        var shape = new Shape_1.Shape(description || ShapeDescriptionManager_1.ShapeDescriptionManager.default, position);
        shape.key = this.getItemKey(shapeObj);
        var sizeAttr = shapeObj.getAttribute("Size");
        var size = this.getSize(sizeAttr);
        if (size)
            shape.size = size;
        var contentAttr = shapeObj.getAttribute("Content");
        if (typeof contentAttr === "string")
            shape.text = contentAttr;
        else {
            var headerAttr = shapeObj.getAttribute("Header");
            if (typeof headerAttr === "string")
                shape.text = headerAttr;
        }
        this.importStyle(shapeObj, shape);
        return shape;
    };
    XmlImporter.prototype.importShapeChildren = function (shapeObj, shape) {
        var childShapeObjs = [];
        shapeObj.setAttribute("dxDiagram", "");
        this.doc.querySelectorAll("[dxDiagram] > Children > [ItemKind='DiagramShape']").forEach(function (obj) { childShapeObjs.push(obj); });
        this.doc.querySelectorAll("[dxDiagram] > Children > [ItemKind='DiagramContainer']").forEach(function (obj) { childShapeObjs.push(obj); });
        shapeObj.removeAttribute("dxDiagram");
        var result = [];
        if (!childShapeObjs)
            return result;
        for (var i = 0; i < childShapeObjs.length; i++) {
            var childShapeObj = childShapeObjs[i];
            var childShape = this.importShape(childShapeObj);
            childShape.key = shape.key + "," + childShape.key;
            var rect = shape.clientRectangle;
            childShape.position = childShape.position.clone().offset(rect.x, rect.y);
            if (!shape["childKeys"])
                shape["childKeys"] = [];
            shape["childKeys"].push(childShape.key);
            result.push(childShape);
            result = result.concat(this.importShapeChildren(childShapeObj, childShape));
        }
        return result;
    };
    XmlImporter.prototype.importConnector = function (connectorObj) {
        var _this = this;
        var points = [];
        var beginPointAttr = connectorObj.getAttribute("BeginPoint");
        var beginPoint = this.getPoint(beginPointAttr);
        if (beginPoint)
            points.push(beginPoint);
        var pointsAttr = connectorObj.getAttribute("Points");
        pointsAttr.split(" ").forEach(function (pointAttr) {
            var point = _this.getPoint(pointAttr);
            if (point)
                points.push(point);
        });
        var endPointAttr = connectorObj.getAttribute("EndPoint");
        var endPoint = this.getPoint(endPointAttr);
        if (endPoint)
            points.push(endPoint);
        var connector = new Connector_1.Connector(points);
        connector.key = this.getItemKey(connectorObj);
        var endItemPointIndexAttr = connectorObj.getAttribute("EndItemPointIndex");
        var endItemPointIndex = parseInt(endItemPointIndexAttr);
        connector.endConnectionPointIndex = !isNaN(endItemPointIndex) ? endItemPointIndex : -1;
        var beginItemPointIndexAttr = connectorObj.getAttribute("BeginItemPointIndex");
        var beginItemPointIndex = parseInt(beginItemPointIndexAttr);
        connector.beginConnectionPointIndex = !isNaN(beginItemPointIndex) ? beginItemPointIndex : -1;
        var endItemAttr = connectorObj.getAttribute("EndItem");
        if (endItemAttr !== undefined)
            this.assert(endItemAttr, "string");
        var beginItemAttr = connectorObj.getAttribute("BeginItem");
        if (beginItemAttr !== undefined)
            this.assert(beginItemAttr, "string");
        connector["endItemKey"] = endItemAttr;
        connector["beginItemKey"] = beginItemAttr;
        var contentAttr = connectorObj.getAttribute("Content");
        if (typeof contentAttr === "string")
            connector.setText(contentAttr);
        this.importStyle(connectorObj, connector);
        return connector;
    };
    XmlImporter.prototype.importStyle = function (obj, item) {
        var backgroundAttr = obj.getAttribute("Background");
        if (typeof backgroundAttr === "string")
            item.style["fill"] = this.getColor(backgroundAttr);
        var strokeAttr = obj.getAttribute("Stroke");
        if (typeof strokeAttr === "string")
            item.style["stroke"] = this.getColor(strokeAttr);
        var foregroundAttr = obj.getAttribute("Foreground");
        if (typeof foregroundAttr === "string")
            item.styleText["fill"] = this.getColor(foregroundAttr);
        var fontFamilyAttr = obj.getAttribute("FontFamily");
        if (typeof fontFamilyAttr === "string")
            item.styleText["font-family"] = fontFamilyAttr;
        var fontSizeAttr = obj.getAttribute("FontSize");
        if (typeof fontSizeAttr === "string")
            item.styleText["font-size"] = fontSizeAttr;
        var fontWeightAttr = obj.getAttribute("FontWeight");
        if (fontWeightAttr === "Bold")
            item.styleText["font-weight"] = "bold";
        var fontStyleAttr = obj.getAttribute("FontStyle");
        if (fontStyleAttr === "Italic")
            item.styleText["font-style"] = "italic";
        var textDecorationsAttr = obj.getAttribute("TextDecorations");
        if (textDecorationsAttr === "Underline")
            item.styleText["text-decoration"] = "underline";
        var textAlignmentAttr = obj.getAttribute("TextAlignment");
        if (textAlignmentAttr === "Left")
            item.styleText["text-anchor"] = "start";
        else if (textAlignmentAttr === "Right")
            item.styleText["text-anchor"] = "end";
        else if (textAlignmentAttr === "Center")
            item.styleText["text-anchor"] = "middle";
    };
    XmlImporter.prototype.getShapeType = function (shapeAttr) {
        if (XmlImporter.shapeTypes[shapeAttr])
            return XmlImporter.shapeTypes[shapeAttr];
        if (shapeAttr && shapeAttr.toLowerCase().indexOf("container") > -1)
            return ShapeTypes_1.ShapeTypes.VerticalContainer;
        return ShapeTypes_1.ShapeTypes.Rectangle;
    };
    XmlImporter.prototype.getItemKey = function (obj) {
        return (parseInt(obj.tagName.replace("Item", "")) - 1).toString();
    };
    XmlImporter.prototype.getNumbers = function (s) {
        var parts = s.split(",");
        return parts && parts.length ? parts.map(function (part) { return +part; }) : [];
    };
    XmlImporter.prototype.getSize = function (attrValue) {
        if (attrValue) {
            var numbers = this.getNumbers(attrValue);
            if (numbers.length >= 2) {
                this.assert(numbers[0], "number");
                this.assert(numbers[1], "number");
                return new size_1.Size(unit_converter_1.UnitConverter.pixelsToTwips(numbers[0]), unit_converter_1.UnitConverter.pixelsToTwips(numbers[1]));
            }
        }
    };
    XmlImporter.prototype.getPoint = function (attrValue) {
        if (attrValue) {
            var numbers = this.getNumbers(attrValue);
            if (numbers.length >= 2) {
                this.assert(numbers[0], "number");
                this.assert(numbers[1], "number");
                return new point_1.Point(unit_converter_1.UnitConverter.pixelsToTwips(numbers[0]), unit_converter_1.UnitConverter.pixelsToTwips(numbers[1]));
            }
        }
    };
    XmlImporter.prototype.getColor = function (attrValue) {
        attrValue = attrValue.charAt(0) === "#" ? attrValue.substr(1) : attrValue;
        var color = parseInt(attrValue, 16);
        return !isNaN(color) ? color_1.ColorUtils.colorToHash(color) : undefined;
    };
    XmlImporter.shapeTypes = {
        "BasicShapes.Rectangle": ShapeTypes_1.ShapeTypes.Rectangle,
        "BasicShapes.Ellipse": ShapeTypes_1.ShapeTypes.Ellipse,
        "BasicShapes.Triangle": ShapeTypes_1.ShapeTypes.Triangle,
        "BasicShapes.Pentagon": ShapeTypes_1.ShapeTypes.Pentagon,
        "BasicShapes.Hexagon": ShapeTypes_1.ShapeTypes.Hexagon,
        "BasicShapes.Octagon": ShapeTypes_1.ShapeTypes.Octagon,
        "BasicShapes.Diamond": ShapeTypes_1.ShapeTypes.Diamond,
        "BasicShapes.Cross": ShapeTypes_1.ShapeTypes.Cross,
        "BasicShapes.Star5": ShapeTypes_1.ShapeTypes.Star,
        "BasicFlowchartShapes.StartEnd": ShapeTypes_1.ShapeTypes.Terminator,
        "BasicFlowchartShapes.Data": ShapeTypes_1.ShapeTypes.Data,
        "BasicFlowchartShapes.Database": ShapeTypes_1.ShapeTypes.Database,
        "BasicFlowchartShapes.ExternalData": ShapeTypes_1.ShapeTypes.StoredData,
        "BasicFlowchartShapes.Process": ShapeTypes_1.ShapeTypes.Process,
        "BasicFlowchartShapes.Decision": ShapeTypes_1.ShapeTypes.Decision,
        "BasicFlowchartShapes.Subprocess": ShapeTypes_1.ShapeTypes.PredefinedProcess,
        "BasicFlowchartShapes.Document": ShapeTypes_1.ShapeTypes.Document,
        "BasicFlowchartShapes.Custom1": ShapeTypes_1.ShapeTypes.ManualInput,
        "BasicFlowchartShapes.Custom2": ShapeTypes_1.ShapeTypes.ManualOperation,
        "ArrowShapes.SimpleArrow": ShapeTypes_1.ShapeTypes.ArrowLeft,
        "ArrowShapes.SimpleDoubleArrow": ShapeTypes_1.ShapeTypes.ArrowLeftRight
    };
    return XmlImporter;
}(ImporterBase_1.ImporterBase));
exports.XmlImporter = XmlImporter;


/***/ }),
/* 292 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.InsertShapeImageCommand = void 0;
var EditShapeImageCommandBase_1 = __webpack_require__(104);
var InsertShapeImageCommand = (function (_super) {
    __extends(InsertShapeImageCommand, _super);
    function InsertShapeImageCommand() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    InsertShapeImageCommand.prototype.isEnabled = function () {
        var selectedShape = this.getSelectedShape();
        return _super.prototype.isEnabled.call(this) && selectedShape.image.isEmpty;
    };
    return InsertShapeImageCommand;
}(EditShapeImageCommandBase_1.EditShapeImageCommandBase));
exports.InsertShapeImageCommand = InsertShapeImageCommand;


/***/ }),
/* 293 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.DeleteShapeImageCommand = void 0;
var EditShapeImageCommandBase_1 = __webpack_require__(104);
var DeleteShapeImageCommand = (function (_super) {
    __extends(DeleteShapeImageCommand, _super);
    function DeleteShapeImageCommand() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    DeleteShapeImageCommand.prototype.isEnabled = function () {
        var selectedShape = this.getSelectedShape();
        return _super.prototype.isEnabled.call(this) && !selectedShape.image.isEmpty;
    };
    DeleteShapeImageCommand.prototype.executeCore = function (state, parameter) {
        return _super.prototype.executeCore.call(this, state, undefined);
    };
    return DeleteShapeImageCommand;
}(EditShapeImageCommandBase_1.EditShapeImageCommandBase));
exports.DeleteShapeImageCommand = DeleteShapeImageCommand;


/***/ }),
/* 294 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.ChangeStrokeStyleCommand = void 0;
var ChangeStylePropertyCommand_1 = __webpack_require__(75);
var ChangeStrokeStyleCommand = (function (_super) {
    __extends(ChangeStrokeStyleCommand, _super);
    function ChangeStrokeStyleCommand() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    ChangeStrokeStyleCommand.prototype.getStyleProperty = function () {
        return "stroke-dasharray";
    };
    return ChangeStrokeStyleCommand;
}(ChangeStylePropertyCommand_1.ChangeStylePropertyCommand));
exports.ChangeStrokeStyleCommand = ChangeStrokeStyleCommand;


/***/ }),
/* 295 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.ChangeStrokeWidthCommand = void 0;
var ChangeStylePropertyCommand_1 = __webpack_require__(75);
var ChangeStrokeWidthCommand = (function (_super) {
    __extends(ChangeStrokeWidthCommand, _super);
    function ChangeStrokeWidthCommand() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    ChangeStrokeWidthCommand.prototype.getStyleProperty = function () {
        return "stroke-width";
    };
    return ChangeStrokeWidthCommand;
}(ChangeStylePropertyCommand_1.ChangeStylePropertyCommand));
exports.ChangeStrokeWidthCommand = ChangeStrokeWidthCommand;


/***/ }),
/* 296 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.AutoLayoutTreeVerticalBottomToTopCommand = void 0;
var LayoutSettings_1 = __webpack_require__(20);
var AutoLayoutTreeVerticalCommand_1 = __webpack_require__(137);
var AutoLayoutTreeVerticalBottomToTopCommand = (function (_super) {
    __extends(AutoLayoutTreeVerticalBottomToTopCommand, _super);
    function AutoLayoutTreeVerticalBottomToTopCommand() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    AutoLayoutTreeVerticalBottomToTopCommand.prototype.createLayoutSettings = function () {
        var settings = _super.prototype.createLayoutSettings.call(this);
        settings.direction = LayoutSettings_1.LogicalDirectionKind.Backward;
        return settings;
    };
    return AutoLayoutTreeVerticalBottomToTopCommand;
}(AutoLayoutTreeVerticalCommand_1.AutoLayoutTreeVerticalCommand));
exports.AutoLayoutTreeVerticalBottomToTopCommand = AutoLayoutTreeVerticalBottomToTopCommand;


/***/ }),
/* 297 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.AutoLayoutTreeHorizontalRightToLeftCommand = void 0;
var LayoutSettings_1 = __webpack_require__(20);
var AutoLayoutTreeHorizontalCommand_1 = __webpack_require__(143);
var AutoLayoutTreeHorizontalRightToLeftCommand = (function (_super) {
    __extends(AutoLayoutTreeHorizontalRightToLeftCommand, _super);
    function AutoLayoutTreeHorizontalRightToLeftCommand() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    AutoLayoutTreeHorizontalRightToLeftCommand.prototype.createLayoutSettings = function () {
        var settings = _super.prototype.createLayoutSettings.call(this);
        settings.direction = LayoutSettings_1.LogicalDirectionKind.Backward;
        return settings;
    };
    return AutoLayoutTreeHorizontalRightToLeftCommand;
}(AutoLayoutTreeHorizontalCommand_1.AutoLayoutTreeHorizontalCommand));
exports.AutoLayoutTreeHorizontalRightToLeftCommand = AutoLayoutTreeHorizontalRightToLeftCommand;


/***/ }),
/* 298 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.AutoLayoutLayeredVerticalBottomToTopCommand = void 0;
var LayoutSettings_1 = __webpack_require__(20);
var AutoLayoutLayeredVerticalCommand_1 = __webpack_require__(144);
var AutoLayoutLayeredVerticalBottomToTopCommand = (function (_super) {
    __extends(AutoLayoutLayeredVerticalBottomToTopCommand, _super);
    function AutoLayoutLayeredVerticalBottomToTopCommand() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    AutoLayoutLayeredVerticalBottomToTopCommand.prototype.createLayoutSettings = function () {
        var settings = _super.prototype.createLayoutSettings.call(this);
        settings.direction = LayoutSettings_1.LogicalDirectionKind.Backward;
        return settings;
    };
    return AutoLayoutLayeredVerticalBottomToTopCommand;
}(AutoLayoutLayeredVerticalCommand_1.AutoLayoutLayeredVerticalCommand));
exports.AutoLayoutLayeredVerticalBottomToTopCommand = AutoLayoutLayeredVerticalBottomToTopCommand;


/***/ }),
/* 299 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.AutoLayoutLayeredHorizontalRightToLeftCommand = void 0;
var LayoutSettings_1 = __webpack_require__(20);
var AutoLayoutLayeredHorizontalCommand_1 = __webpack_require__(142);
var AutoLayoutLayeredHorizontalRightToLeftCommand = (function (_super) {
    __extends(AutoLayoutLayeredHorizontalRightToLeftCommand, _super);
    function AutoLayoutLayeredHorizontalRightToLeftCommand() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    AutoLayoutLayeredHorizontalRightToLeftCommand.prototype.createLayoutSettings = function () {
        var settings = _super.prototype.createLayoutSettings.call(this);
        settings.direction = LayoutSettings_1.LogicalDirectionKind.Backward;
        return settings;
    };
    return AutoLayoutLayeredHorizontalRightToLeftCommand;
}(AutoLayoutLayeredHorizontalCommand_1.AutoLayoutLayeredHorizontalCommand));
exports.AutoLayoutLayeredHorizontalRightToLeftCommand = AutoLayoutLayeredHorizontalRightToLeftCommand;


/***/ }),
/* 300 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.ChangeConnectorRoutingModeCommand = void 0;
var SimpleCommandBase_1 = __webpack_require__(10);
var Settings_1 = __webpack_require__(28);
var ChangeConnectorRoutingModeCommand = (function (_super) {
    __extends(ChangeConnectorRoutingModeCommand, _super);
    function ChangeConnectorRoutingModeCommand() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    ChangeConnectorRoutingModeCommand.prototype.getValue = function () {
        return this.control.settings.connectorRoutingMode;
    };
    ChangeConnectorRoutingModeCommand.prototype.executeCore = function (state, parameter) {
        var mode = parameter !== undefined ? parameter : Settings_1.ConnectorRoutingMode.None;
        this.control.settings.connectorRoutingMode = mode;
        return true;
    };
    return ChangeConnectorRoutingModeCommand;
}(SimpleCommandBase_1.SimpleCommandBase));
exports.ChangeConnectorRoutingModeCommand = ChangeConnectorRoutingModeCommand;


/***/ }),
/* 301 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.DiagramControl = void 0;
var point_1 = __webpack_require__(0);
var ModelManipulator_1 = __webpack_require__(302);
var CommandManager_1 = __webpack_require__(82);
var EventManager_1 = __webpack_require__(303);
var Model_1 = __webpack_require__(62);
var Selection_1 = __webpack_require__(332);
var History_1 = __webpack_require__(335);
var BarManager_1 = __webpack_require__(336);
var RenderManager_1 = __webpack_require__(337);
var ShapeDescriptionManager_1 = __webpack_require__(91);
var DocumentDataSource_1 = __webpack_require__(345);
var Settings_1 = __webpack_require__(28);
var ModelOperationSettings_1 = __webpack_require__(16);
var ViewController_1 = __webpack_require__(349);
var ModelUtils_1 = __webpack_require__(4);
var ToolboxManager_1 = __webpack_require__(350);
var Utils_1 = __webpack_require__(3);
var ApiController_1 = __webpack_require__(353);
var ImageCache_1 = __webpack_require__(46);
var PermissionsProvider_1 = __webpack_require__(354);
var ConnectorRoutingModel_1 = __webpack_require__(368);
var TextMeasurer_1 = __webpack_require__(79);
var Connector_1 = __webpack_require__(6);
var DataLayoutParameters_1 = __webpack_require__(103);
var ReloadContentParameters_1 = __webpack_require__(379);
var Utils_2 = __webpack_require__(17);
var _1 = __webpack_require__(58);
var DiagramControl = (function () {
    function DiagramControl() {
        this.updateLockCount = 0;
        this.shouldUpdateItemsByModel = false;
        this.reloadContentNeeded = false;
        this.reloadContentParameters = new ReloadContentParameters_1.ReloadContentParameters();
        this.reloadContentByExternalChangesParameters = new ReloadContentParameters_1.ReloadContentParameters();
        this.settings = new Settings_1.DiagramSettings();
        this.shapeDescriptionManager = new ShapeDescriptionManager_1.ShapeDescriptionManager();
        this.shapeDescriptionManager.onShapeDecriptionChanged.add(this);
        this.model = new Model_1.DiagramModel();
        this.selection = new Selection_1.Selection(this.model);
        this.onNativeAction = new Utils_1.EventDispatcher();
        this.apiController = new ApiController_1.ApiController(this.onNativeAction, this.selection, this.model);
        this.permissionsProvider = new PermissionsProvider_1.PermissionsProvider(this.apiController);
        this.permissionsProvider.onRequestOperation.add(this);
        this.routingModel = new ConnectorRoutingModel_1.ConnectorRoutingModel();
        this.modelManipulator = new ModelManipulator_1.ModelManipulator(this.model, this.routingModel, this.permissionsProvider);
        this.modelManipulator.onModelChanged.add(this.permissionsProvider);
        this.history = new History_1.History(this.modelManipulator);
        this.barManager = new BarManager_1.BarManager(this);
        this.view = new ViewController_1.ViewController(this.settings, this.barManager);
        this.commandManager = new CommandManager_1.CommandManager(this);
        this.eventManager = new EventManager_1.EventManager(this);
        this.settings.onReadOnlyChanged.add(this.eventManager.mouseHandler);
        this.settings.onReadOnlyChanged.add(this.eventManager.visualizersManager);
        this.selection.onChanged.add(this.barManager);
        this.selection.onChanged.add(this.apiController);
        this.selection.onChanged.add(this.permissionsProvider);
        this.modelManipulator.commitItemsCreateChanges();
        this.history.onChanged.add(this);
        this.toolboxManager = new ToolboxManager_1.ToolboxManager(this.shapeDescriptionManager);
        this.settings.onConnectorRoutingModeChanged.add(this.routingModel);
        ImageCache_1.ImageCache.instance.onReadyStateChanged.add(this);
    }
    Object.defineProperty(DiagramControl.prototype, "operationSettings", {
        get: function () {
            return this.permissionsProvider.operationSettings;
        },
        enumerable: false,
        configurable: true
    });
    DiagramControl.prototype.cleanMarkup = function (removeElement) {
        removeElement = removeElement || (function (element) { Utils_2.RenderUtils.removeElement(element); });
        this.toolboxManager.clean(removeElement);
        this.barManager.clean();
        if (this.render) {
            this.settings.onZoomChanged.remove(this.render.view);
            this.settings.onViewChanged.remove(this.render.page);
            this.settings.onViewChanged.remove(this.render.view);
            this.settings.onReadOnlyChanged.remove(this.render);
            this.settings.onReadOnlyChanged.remove(this.render.selection);
            this.eventManager.cleanToolboxes(this.settings.onReadOnlyChanged);
            this.eventManager.onTextInputOperation.remove(this.render.input);
            this.eventManager.onTextInputOperation.remove(this.render.items);
            this.eventManager.onTextInputOperation.remove(this.render.selection);
            this.eventManager.onMouseOperation.remove(this.render.items);
            this.eventManager.onMouseOperation.remove(this.render.selection);
            this.eventManager.onMouseOperation.remove(this.render.view);
            this.eventManager.onMouseOperation.remove(this.render);
            this.eventManager.onVisualizersUpdate.remove(this.render.selection);
            this.modelManipulator.onModelSizeChanged.remove(this.render.view);
            this.modelManipulator.onModelSizeChanged.remove(this.render.page);
            this.modelManipulator.onModelChanged.remove(this.render.items);
            this.modelManipulator.onModelChanged.remove(this.render.page);
            this.modelManipulator.onModelChanged.remove(this.render.selection);
            this.selection.onChanged.remove(this.render.selection);
            this.selection.onChanged.remove(this.render.items);
            this.render.clean(removeElement);
            this.render = undefined;
        }
    };
    DiagramControl.prototype.createDocument = function (parent, scrollView, focusElementsParent) {
        if (!this.measurer)
            this.initMeasurer(parent);
        if (this.render)
            this.render.replaceParent(parent, scrollView);
        else {
            this.render = new RenderManager_1.RenderManager(parent, this.eventManager, this.measurer, {
                pageColor: this.model.pageColor,
                modelSize: this.model.size,
                pageLandscape: this.model.pageLandscape,
                pageSize: this.model.pageSize,
                simpleView: this.settings.simpleView,
                readOnly: this.settings.readOnly,
                contextMenuEnabled: this.settings.contextMenuEnabled,
                gridSize: this.settings.gridSize,
                gridVisible: this.settings.showGrid,
                zoomLevel: this.settings.zoomLevel,
                autoZoom: this.settings.autoZoom,
                rectangle: this.model.getRectangle(true)
            }, scrollView, focusElementsParent);
            this.settings.onZoomChanged.add(this.render.view);
            this.settings.onViewChanged.add(this.render.page);
            this.settings.onViewChanged.add(this.render.view);
            this.settings.onReadOnlyChanged.add(this.render);
            this.settings.onReadOnlyChanged.add(this.render.selection);
            this.eventManager.onTextInputOperation.add(this.render.input);
            this.eventManager.onTextInputOperation.add(this.render.items);
            this.eventManager.onTextInputOperation.add(this.render.selection);
            this.eventManager.onTextInputOperation.add(this);
            this.eventManager.onMouseOperation.add(this.render.items);
            this.eventManager.onMouseOperation.add(this.render.selection);
            this.eventManager.onMouseOperation.add(this.render.view);
            this.eventManager.onMouseOperation.add(this.render);
            this.eventManager.onVisualizersUpdate.add(this.render.selection);
            this.modelManipulator.onModelSizeChanged.add(this.render.view);
            this.modelManipulator.onModelSizeChanged.add(this.render.page);
            this.modelManipulator.onModelChanged.add(this.render.items);
            this.modelManipulator.onModelChanged.add(this.render.page);
            this.modelManipulator.onModelChanged.add(this.render.selection);
            this.selection.onChanged.add(this.render.selection);
            this.selection.onChanged.add(this.render.items);
            this.render.update(false);
            this.render.onNewModel(this.model.items);
            this.modelManipulator.commitItemsCreateChanges();
            this.view.initialize(this.render.view);
            if (this.settings.zoomLevelWasChanged)
                this.raiseCanvasViewActualZoomChanged();
            this.selection.raiseSelectionChanged();
        }
    };
    DiagramControl.prototype.createToolbox = function (parent, renderAsText, shapes, options) {
        var toolbox = this.toolboxManager.create(parent, this.settings.readOnly, true, renderAsText, shapes, this.getToolboxAllowedShapeTypes.bind(this), options);
        this.settings.onReadOnlyChanged.add(toolbox);
        toolbox.onDragOperation.add(this);
        toolbox.onDragOperation.add(this.apiController);
        this.eventManager.registerToolbox(toolbox);
    };
    DiagramControl.prototype.createContextToolbox = function (parent, renderAsText, shapes, options, onClick) {
        if (this.contextToolbox)
            this.cleanContextToolbox(parent);
        this.contextToolbox = this.toolboxManager.create(parent, this.settings.readOnly, false, renderAsText, shapes, this.getToolboxAllowedShapeTypes.bind(this), options);
        this.contextToolbox.onClickOperation.add(this);
        this.contextToolboxOnClick = onClick;
    };
    DiagramControl.prototype.getToolboxAllowedShapeTypes = function (shapeTypes) {
        var _this = this;
        var allowedShapeTypes = [];
        this.permissionsProvider.beginUpdateUI();
        shapeTypes.forEach(function (shapeType) {
            if (_this.permissionsProvider.canAddShapeFromToolbox(shapeType))
                allowedShapeTypes.push(shapeType);
        });
        this.permissionsProvider.endUpdateUI();
        return allowedShapeTypes;
    };
    DiagramControl.prototype.cleanContextToolbox = function (parent) {
        if (this.contextToolbox) {
            this.toolboxManager.clean(undefined, this.contextToolbox);
            this.contextToolbox = undefined;
        }
    };
    DiagramControl.prototype.refreshToolbox = function (toolboxes) {
        this.permissionsProvider.clearCache(ModelOperationSettings_1.DiagramModelOperation.AddShapeFromToolbox);
        this.toolboxManager.refresh(toolboxes);
    };
    DiagramControl.prototype.applyToolboxFilter = function (shapeSubstring, toolboxes) {
        return this.toolboxManager.applyFilter(shapeSubstring, toolboxes);
    };
    DiagramControl.prototype.notifyToolboxClick = function (shapeType) {
        if (this.contextToolboxOnClick)
            this.contextToolboxOnClick(shapeType);
    };
    DiagramControl.prototype.initMeasurer = function (parent) {
        this.measurer = new TextMeasurer_1.TextMeasurer(parent);
    };
    DiagramControl.prototype.onDimensionChanged = function () {
        if (!_1.Browser.TouchUI)
            this.updateLayout(true);
    };
    DiagramControl.prototype.updateLayout = function (resetScroll) {
        if (resetScroll === void 0) { resetScroll = false; }
        this.render && this.render.update(!resetScroll);
    };
    DiagramControl.prototype.captureFocus = function () {
        this.render && this.render.input.captureFocus();
    };
    DiagramControl.prototype.isFocused = function () {
        return !this.render || this.render.input.isFocused();
    };
    DiagramControl.prototype.registerBar = function (bar) {
        this.barManager.registerBar(bar);
    };
    DiagramControl.prototype.updateBarItemsState = function (bar, queryCommands) {
        this.barManager.updateBarItemsState(bar, queryCommands);
    };
    DiagramControl.prototype.getCommand = function (key) {
        return this.commandManager.getCommand(key);
    };
    DiagramControl.prototype.getNativeItemByKey = function (key) {
        var item = this.model.findItem(key);
        return item && this.apiController.createNativeItem(item);
    };
    DiagramControl.prototype.getNativeItemByDataKey = function (dataKey) {
        var item = this.model.findItemByDataKey(dataKey);
        return item && this.apiController.createNativeItem(item);
    };
    DiagramControl.prototype.getNativeItems = function () {
        var _this = this;
        return this.model.items.map(function (item) { return _this.apiController.createNativeItem(item); });
    };
    DiagramControl.prototype.getNativeSelectedItems = function () {
        var _this = this;
        return this.selection.getKeys().map(function (key) { return _this.apiController.createNativeItem(_this.model.findItem(key)); });
    };
    DiagramControl.prototype.setSelectedItems = function (keys) {
        this.selection.set(keys);
    };
    DiagramControl.prototype.scrollToItems = function (keys) {
        var _this = this;
        var rectangle = Utils_1.GeometryUtils.getCommonRectangle(keys.map(function (key) { return _this.model.findItem(key).rectangle; }));
        this.view.scrollIntoView(rectangle);
    };
    DiagramControl.prototype.setInitialStyleProperties = function (style) {
        this.selection.inputPosition.setInitialStyleProperties(style);
    };
    DiagramControl.prototype.setInitialTextStyleProperties = function (style) {
        this.selection.inputPosition.setInitialTextStyleProperties(style);
    };
    DiagramControl.prototype.setInitialConnectorProperties = function (properties) {
        this.selection.inputPosition.setInitialConnectorProperties(properties);
    };
    DiagramControl.prototype.addCustomShapes = function (shapes) {
        var _this = this;
        shapes.forEach(function (shape) {
            shape.apiController = _this.apiController;
            if (shape.defaultWidth)
                shape.defaultWidth = ModelUtils_1.ModelUtils.getTwipsValue(_this.model.units, shape.defaultWidth);
            if (shape.defaultHeight)
                shape.defaultHeight = ModelUtils_1.ModelUtils.getTwipsValue(_this.model.units, shape.defaultHeight);
            if (shape.minWidth)
                shape.minWidth = ModelUtils_1.ModelUtils.getTwipsValue(_this.model.units, shape.minWidth);
            if (shape.minHeight)
                shape.minHeight = ModelUtils_1.ModelUtils.getTwipsValue(_this.model.units, shape.minHeight);
            if (shape.maxWidth)
                shape.maxWidth = ModelUtils_1.ModelUtils.getTwipsValue(_this.model.units, shape.maxWidth);
            if (shape.maxHeight)
                shape.maxHeight = ModelUtils_1.ModelUtils.getTwipsValue(_this.model.units, shape.maxHeight);
            _this.shapeDescriptionManager.registerCustomShape(shape);
        });
    };
    DiagramControl.prototype.removeCustomShapes = function (shapeTypes) {
        var _this = this;
        shapeTypes.forEach(function (shapeType) {
            _this.shapeDescriptionManager.unregisterCustomShape(shapeType);
        });
    };
    DiagramControl.prototype.removeAllCustomShapes = function () {
        this.shapeDescriptionManager.unregisterAllCustomShapes();
    };
    DiagramControl.prototype.importModel = function (model) {
        model.units = this.model.units;
        this.model = model;
        this.model.initializeKeyCounter();
        this.apiController.model = model;
        this.onImportData();
    };
    DiagramControl.prototype.importItemsData = function () {
        this.model.iterateItems(function (item) {
            if (item instanceof Connector_1.Connector)
                item.invalidateRenderPoints();
        });
        this.onImportData();
    };
    DiagramControl.prototype.onImportData = function () {
        if (this.render) {
            this.render.clear();
            this.render.onNewModel(this.model.items);
        }
        this.permissionsProvider.clearCache();
        this.selection.initialize(this.model);
        this.modelManipulator.initialize(this.model, this.routingModel);
        this.history.clear();
        this.eventManager.initialize();
        this.modelManipulator.commitPageChanges();
        this.modelManipulator.commitItemsCreateChanges();
        this.notifyViewChanged();
        this.notifyHistoryChanged();
    };
    DiagramControl.prototype.createDocumentDataSource = function (nodeDataSource, edgeDataSource, parameters, nodeDataImporter, edgeDataImporter) {
        this.documentDataSource = new DocumentDataSource_1.DocumentDataSource(this, nodeDataSource, edgeDataSource, parameters, nodeDataImporter, edgeDataImporter);
        this.apiController.setDataSource(this.documentDataSource);
        return this.documentDataSource;
    };
    DiagramControl.prototype.deleteDocumentDataSource = function () {
        this.apiController.setDataSource(null);
        delete this.documentDataSource;
    };
    DiagramControl.prototype.applyShapeSizeSettings = function (settings) {
        this.settings.applyShapeSizeSettings(settings, this.model.units);
    };
    DiagramControl.prototype.applyOperationSettings = function (settings) {
        this.permissionsProvider.operationSettings.applySettings(settings);
    };
    DiagramControl.prototype.beginUpdateCanvas = function () {
        if (this.render) {
            this.render.items.beginUpdate();
            this.render.selection.beginUpdate();
        }
    };
    DiagramControl.prototype.endUpdateCanvas = function () {
        if (this.render) {
            this.render.items.endUpdate();
            this.render.selection.endUpdate();
        }
    };
    DiagramControl.prototype.beginUpdate = function () {
        this.barManager.beginUpdate();
        this.apiController.beginUpdate();
        this.eventManager.beginUpdate();
    };
    DiagramControl.prototype.endUpdate = function () {
        this.barManager.endUpdate();
        this.apiController.endUpdate();
        this.eventManager.endUpdate();
    };
    DiagramControl.prototype.notifyEdgeInserted = function (data, callback, errorCallback) {
        if (this.onEdgeInserted)
            this.onEdgeInserted(data, callback, errorCallback);
        else
            callback(data);
    };
    DiagramControl.prototype.notifyEdgeUpdated = function (key, data, callback, errorCallback) {
        if (this.onEdgeUpdated)
            this.onEdgeUpdated(key, data, callback, errorCallback);
        else
            callback(key, data);
    };
    DiagramControl.prototype.notifyEdgeRemoved = function (key, data, callback, errorCallback) {
        if (this.onEdgeUpdated)
            this.onEdgeRemoved(key, data, callback, errorCallback);
        else
            callback(key, data);
    };
    DiagramControl.prototype.notifyNodeInserted = function (data, callback, errorCallback) {
        if (this.onNodeInserted)
            this.onNodeInserted(data, callback, errorCallback);
        else
            callback(data);
    };
    DiagramControl.prototype.notifyNodeUpdated = function (key, data, callback, errorCallback) {
        if (this.onNodeUpdated)
            this.onNodeUpdated(key, data, callback, errorCallback);
        else
            callback(key, data);
    };
    DiagramControl.prototype.notifyNodeRemoved = function (key, data, callback, errorCallback) {
        if (this.onNodeRemoved)
            this.onNodeRemoved(key, data, callback, errorCallback);
        else
            callback(key, data);
    };
    DiagramControl.prototype.reloadInsertedItem = function (dataKey) {
        if (this.settings.reloadInsertedItemRequired)
            this.reloadContent(dataKey);
    };
    DiagramControl.prototype.reloadContent = function (dataKey, getData, layoutParameters, isExternalChanges) {
        if (!this.documentDataSource)
            return;
        if (this.isChangesLocked())
            this.reloadContentNeeded = true;
        var addNewHistoryItem = isExternalChanges === true || (isExternalChanges === undefined && !this.reloadContentNeeded);
        var reloadContentParameters = addNewHistoryItem ? this.reloadContentByExternalChangesParameters : this.reloadContentParameters;
        reloadContentParameters.add(dataKey, getData, layoutParameters);
        if (!this.isChangesLocked()) {
            this.reloadContentCore(reloadContentParameters, addNewHistoryItem);
            this.barManager.updateItemsState();
        }
    };
    DiagramControl.prototype.reloadContentCore = function (parameters, addNewHistoryItem) {
        var _this = this;
        var data = parameters.getData && parameters.getData();
        var changes = this.documentDataSource.refetchData(data && data.nodeDataSource, data && data.edgeDataSource);
        this.beginUpdateCanvas();
        this.permissionsProvider.lockPermissions();
        this.documentDataSource.updateModelItems(this.history, this.model, this.shapeDescriptionManager, this.selection, new DataLayoutParameters_1.DataLayoutParameters(this.settings, parameters.layoutParameters), addNewHistoryItem, parameters.dataKeys, function (item) {
            _this.modelManipulator.commitItemUpdateChanges(item);
        }, changes, this.settings.snapToGrid, this.settings.gridSize, this.measurer);
        this.permissionsProvider.unlockPermissions();
        this.endUpdateCanvas();
        parameters.clear();
    };
    DiagramControl.prototype.notifyHistoryChanged = function () {
        if (this.documentDataSource) {
            this.shouldUpdateItemsByModel = true;
            if (!this.settings.readOnly)
                this.notifyDataChanges();
        }
        else
            this.raiseOnChanged();
    };
    DiagramControl.prototype.notifyViewChanged = function () {
        this.settings.notifyViewChanged();
    };
    DiagramControl.prototype.notifyToolboxDragStart = function (evt) {
        this.render.notifyToolboxDragStart(evt);
        if (this.onToolboxDragStart)
            this.onToolboxDragStart();
    };
    DiagramControl.prototype.notifyToolboxDragEnd = function (evt) {
        this.render.notifyToolboxDragEnd(evt);
        if (this.onToolboxDragEnd)
            this.onToolboxDragEnd();
    };
    DiagramControl.prototype.notifyToolboxDraggingMouseMove = function (evt) {
        if (this.render)
            this.render.notifyToolboxDraggingMouseMove(evt);
    };
    DiagramControl.prototype.notifyTextInputStart = function (item, text, position, size) {
        if (this.onTextInputStart)
            this.onTextInputStart();
    };
    DiagramControl.prototype.notifyTextInputEnd = function (item, captureFocus) {
        if (this.onTextInputEnd)
            this.onTextInputEnd();
    };
    DiagramControl.prototype.notifyTextInputPermissionsCheck = function (item, allowed) { };
    DiagramControl.prototype.notifyToggleFullscreen = function (value) {
        if (this.onToggleFullscreen)
            this.onToggleFullscreen(value);
    };
    DiagramControl.prototype.notifyShowContextMenu = function (eventPoint, modelPoint) {
        if (this.onShowContextMenu && this.render) {
            var selection = void 0;
            var selectedItems = this.selection.getSelectedItems(true);
            if (selectedItems.length > 0) {
                var rect = ModelUtils_1.ModelUtils.createRectangle(this.selection.getSelectedItems(true));
                var pos = this.render.getEventPointByModelPoint(rect.createPosition());
                var size = this.render.view.getAbsoluteSize(rect.createSize());
                selection = { x: pos.x, y: pos.y, width: size.width, height: size.height };
            }
            if (eventPoint) {
                this.contextMenuPosition = new point_1.Point(eventPoint.x, eventPoint.y);
                this.onShowContextMenu(eventPoint.x, eventPoint.y, selection);
            }
            else if (modelPoint) {
                var point = this.render.getEventPointByModelPoint(modelPoint);
                this.contextMenuPosition = point.clone();
                this.onShowContextMenu(point.x, point.y, selection);
            }
        }
    };
    DiagramControl.prototype.notifyHideContextMenu = function () {
        if (this.onHideContextMenu && this.render)
            this.onHideContextMenu();
    };
    DiagramControl.prototype.notifyShowContextToolbox = function (modelPoint, getPositionToInsertShapeTo, side, category, callback) {
        if (this.onShowContextToolbox && this.render) {
            var point = this.render.getEventPointByModelPoint(modelPoint);
            this.onShowContextToolbox(point.x, point.y, side, category, callback);
            this.render.view.notifyShowContextToolbox();
        }
    };
    DiagramControl.prototype.notifyHideContextToolbox = function () {
        if (this.onHideContextToolbox && this.render) {
            this.onHideContextToolbox();
            this.render.view.notifyHideContextToolbox();
        }
    };
    DiagramControl.prototype.notifyShapeDescriptionChanged = function (description) {
        this.modelManipulator.updateShapeDescription(description);
    };
    DiagramControl.prototype.notifyImageCacheReadyStateChanged = function (ready) {
        this.barManager.updateItemsState();
    };
    DiagramControl.prototype.raiseCanvasViewActualZoomChanged = function () {
        this.render.view.raiseActualZoomChanged();
    };
    DiagramControl.prototype.notifyRequestOperation = function (operation, args) {
        if (this.requestOperationByDataSource(operation, args))
            return;
        if (this.onRequestOperation)
            this.onRequestOperation(operation, args);
    };
    DiagramControl.prototype.requestOperationByDataSource = function (operation, args) {
        if (!(this.documentDataSource && (this.documentDataSource.IsNodeParentIdMode() || this.documentDataSource.IsNodeItemsMode())))
            return false;
        if (operation === ModelOperationSettings_1.DiagramModelOperation.ChangeConnection) {
            var e = args;
            var shape = e.shape && this.model.findItem(e.shape.id);
            var connector = e.connector && this.model.findItem(e.connector.id);
            if (!(shape && connector))
                return;
            if (e.position === Connector_1.ConnectorPosition.End)
                for (var i = 0; i < shape.attachedConnectors.length; i++) {
                    var attachedConnector = shape.attachedConnectors[i];
                    if (attachedConnector !== connector && attachedConnector.endItem && attachedConnector.endItem === shape) {
                        e.allowed = false;
                        break;
                    }
                }
            if (e.allowed && connector.beginItem && connector.endItem && this.isShapeParent(connector.endItem, connector.beginItem))
                e.allowed = false;
        }
        return !args.allowed;
    };
    DiagramControl.prototype.isShapeParent = function (parentShape, shape) {
        if (parentShape === shape)
            return true;
        for (var i = 0; i < parentShape.attachedConnectors.length; i++) {
            var attachedConnector = parentShape.attachedConnectors[i];
            if (attachedConnector.beginItem === parentShape && attachedConnector.endItem) {
                var childShape = attachedConnector.endItem;
                if (childShape === shape || this.isShapeParent(childShape, shape))
                    return true;
            }
        }
        return false;
    };
    DiagramControl.prototype.isChangesLocked = function () {
        return this.updateLockCount > 0;
    };
    DiagramControl.prototype.beginChangesNotification = function () {
        if (!this.isChangesLocked())
            if (this.changesLockChanged)
                this.changesLockChanged(true);
        this.updateLockCount++;
    };
    DiagramControl.prototype.endChangesNotification = function (preventNotifyReloadContent) {
        var _this = this;
        this.updateLockCount--;
        if (!this.isChangesLocked()) {
            this.changesLockChanged(false);
            if (!preventNotifyReloadContent)
                setTimeout(function () {
                    _this.notifyReloadContent();
                    _this.notifyDataChanges();
                }, 0);
        }
    };
    DiagramControl.prototype.changesLockChanged = function (locked) {
        if (locked)
            this.lockedReadOnly = this.settings.readOnly;
        else
            locked = this.lockedReadOnly;
        this.commandManager.getCommand(CommandManager_1.DiagramCommand.ToggleReadOnly).execute(locked);
    };
    DiagramControl.prototype.notifyDataChanges = function () {
        if (this.isChangesLocked())
            return;
        if (this.shouldUpdateItemsByModel) {
            this.documentDataSource.updateItemsByModel(this.model);
            this.shouldUpdateItemsByModel = false;
        }
        this.raiseOnChanged();
    };
    DiagramControl.prototype.notifyReloadContent = function () {
        if (this.reloadContentNeeded) {
            if (!this.reloadContentParameters.empty)
                this.reloadContentCore(this.reloadContentParameters, false);
            if (!this.reloadContentByExternalChangesParameters.empty)
                this.reloadContentCore(this.reloadContentByExternalChangesParameters, true);
            this.reloadContentNeeded = false;
        }
    };
    DiagramControl.prototype.raiseOnChanged = function () {
        if (this.onChanged)
            this.onChanged();
    };
    return DiagramControl;
}());
exports.DiagramControl = DiagramControl;


/***/ }),
/* 302 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.ModelManipulator = void 0;
var offsets_1 = __webpack_require__(87);
var size_1 = __webpack_require__(2);
var Diagnostics_1 = __webpack_require__(61);
var ImageCache_1 = __webpack_require__(46);
var ImageLoader_1 = __webpack_require__(130);
var ModelOperationSettings_1 = __webpack_require__(16);
var Utils_1 = __webpack_require__(3);
var Connector_1 = __webpack_require__(6);
var ModelChange_1 = __webpack_require__(99);
var ModelUtils_1 = __webpack_require__(4);
var ModelManipulator = (function () {
    function ModelManipulator(model, routingModel, permissionsProvider) {
        this.onModelChanged = new Utils_1.EventDispatcher();
        this.onModelSizeChanged = new Utils_1.EventDispatcher();
        this.initializeCore(model, routingModel);
        this.permissionsProvider = permissionsProvider;
        this.imageLoader = new ImageLoader_1.ImageLoader(this.updateShapeImage.bind(this));
    }
    ModelManipulator.prototype.initialize = function (model, routingModel) {
        this.initializeCore(model, routingModel);
        this.model.loadAllImages(this.imageLoader);
        this.updateModelSize();
    };
    ModelManipulator.prototype.initializeCore = function (model, routingModel) {
        this.model = model;
        this.routingModel = routingModel;
        if (this.routingModel)
            this.routingModel.initialize(model);
    };
    ModelManipulator.prototype.commitPageChanges = function () {
        this.raisePageSizeChanged(this.model.pageSize.clone(), this.model.pageLandscape);
        this.raiseModelSizeChanged(this.model.size.clone());
        this.raisePageColorChanged(this.model.pageColor);
        this.raiseModelRectangleChanged(ModelUtils_1.ModelUtils.createRectangle(this.model.items));
    };
    ModelManipulator.prototype.commitItemsCreateChanges = function () {
        Diagnostics_1.Diagnostics.timer("new model: model changes");
        this.commitItemsChangesCore(ModelChange_1.ItemChangeType.Create, this.model.items);
        Diagnostics_1.Diagnostics.endTimer();
    };
    ModelManipulator.prototype.commitItemUpdateChanges = function (item) {
        this.commitItemsChangesCore(ModelChange_1.ItemChangeType.UpdateStructure, [item]);
    };
    ModelManipulator.prototype.commitItemsChangesCore = function (changeType, items) {
        var changes = [];
        items.forEach(function (item) {
            changes.push(new ModelChange_1.ItemChange(item, changeType));
        });
        if (changes.length)
            this.raiseModelChanged(changes);
    };
    ModelManipulator.prototype.insertToContainer = function (item, container) {
        if (item.container && container && item.container.key !== container.key)
            throw Error("To insert an item to a container it's necessary to remove it from the current container.");
        if (container) {
            if (container.children.indexOf(item) === -1)
                container.children.push(item);
            item.container = container;
            this.raiseModelChanged([new ModelChange_1.ItemChange(item, ModelChange_1.ItemChangeType.Update)]);
        }
    };
    ModelManipulator.prototype.removeFromContainer = function (item) {
        if (item.container) {
            var index = item.container.children.indexOf(item);
            item.container.children.splice(index, 1);
            item.container = undefined;
            this.raiseModelChanged([new ModelChange_1.ItemChange(item, ModelChange_1.ItemChangeType.Update)]);
        }
    };
    ModelManipulator.prototype.changeStyle = function (item, styleProperty, styleValue) {
        this.changeStyleCore(item, item.style, styleProperty, styleValue);
    };
    ModelManipulator.prototype.changeStyleText = function (item, styleProperty, styleValue) {
        this.changeStyleCore(item, item.styleText, styleProperty, styleValue);
    };
    ModelManipulator.prototype.changeStyleCore = function (item, styleObj, styleProperty, styleValue) {
        if (styleValue !== undefined)
            styleObj[styleProperty] = styleValue;
        else
            delete styleObj[styleProperty];
        this.raiseModelChanged([new ModelChange_1.ItemChange(item, ModelChange_1.ItemChangeType.UpdateProperties)]);
    };
    ModelManipulator.prototype.changeZIndex = function (item, zIndex) {
        item.zIndex = zIndex;
        this.raiseModelChanged([new ModelChange_1.ItemChange(item, ModelChange_1.ItemChangeType.Update)]);
    };
    ModelManipulator.prototype.changeLocked = function (item, locked) {
        item.locked = locked;
        this.raiseModelChanged([new ModelChange_1.ItemChange(item, ModelChange_1.ItemChangeType.UpdateClassName)]);
    };
    ModelManipulator.prototype.changeCustomData = function (item, data) {
        item.customData = Utils_1.ObjectUtils.cloneObject(data);
        this.raiseModelChanged([new ModelChange_1.ItemChange(item, ModelChange_1.ItemChangeType.UpdateStructure)]);
    };
    ModelManipulator.prototype.addShape = function (shape, key) {
        if (shape.attachedConnectors.length)
            throw Error("A creating shape should not contain existing connectors.");
        shape.key = key !== undefined ? key : this.model.getNextKey();
        return this.insertShape(shape);
    };
    ModelManipulator.prototype.insertShape = function (shape) {
        this.model.pushItem(shape);
        var allowed = this.permissionsProvider.canAddItems([shape]);
        this.raiseModelChanged([new ModelChange_1.ItemChange(shape, ModelChange_1.ItemChangeType.Create, allowed)]);
        this.model.loadAllImages(this.imageLoader);
        return shape;
    };
    ModelManipulator.prototype.resizeShape = function (shape, position, size) {
        shape.position = position;
        shape.size = size;
        var allowed = this.permissionsProvider.isStoredPermissionsGranted();
        var resizeInteractingItem = this.getInteractingItem(shape, ModelOperationSettings_1.DiagramModelOperation.ResizeShape);
        if (resizeInteractingItem) {
            var oldSize = resizeInteractingItem.size.clone();
            var size_2 = shape.size.clone();
            if (!size_2.equals(oldSize))
                allowed = this.permissionsProvider.canResizeShapes([{ shape: shape, size: size_2, oldSize: oldSize }]);
        }
        var moveInteractingItem = this.getInteractingItem(shape, ModelOperationSettings_1.DiagramModelOperation.MoveShape);
        if (moveInteractingItem) {
            var oldPosition = moveInteractingItem.position.clone();
            var position_1 = shape.position.clone();
            if (!position_1.equals(oldPosition))
                allowed = this.permissionsProvider.canMoveShapes([{ shape: shape, position: position_1, oldPosition: oldPosition }]);
        }
        this.raiseModelChanged([new ModelChange_1.ItemChange(shape, ModelChange_1.ItemChangeType.UpdateProperties, allowed)]);
    };
    ModelManipulator.prototype.moveShape = function (shape, position) {
        shape.position = position;
        var allowed = this.permissionsProvider.isStoredPermissionsGranted();
        var addInteractingItem = this.getInteractingItem(shape, ModelOperationSettings_1.DiagramModelOperation.AddShape);
        if (addInteractingItem)
            allowed = this.permissionsProvider.canAddItems([shape]);
        var moveInteractingItem = this.getInteractingItem(shape, ModelOperationSettings_1.DiagramModelOperation.MoveShape);
        if (moveInteractingItem) {
            var oldPosition = moveInteractingItem.position.clone();
            var position_2 = shape.position.clone();
            if (!position_2.equals(oldPosition))
                allowed = this.permissionsProvider.canMoveShapes([{ shape: shape, position: position_2, oldPosition: oldPosition }]);
        }
        this.raiseModelChanged([new ModelChange_1.ItemChange(shape, ModelChange_1.ItemChangeType.UpdateProperties, allowed)]);
    };
    ModelManipulator.prototype.changeShapeParameters = function (shape, parameters) {
        shape.parameters.forEach(function (p) {
            var parameter = parameters.get(p.key);
            if (parameter)
                p.value = parameter.value;
        });
        this.raiseModelChanged([new ModelChange_1.ItemChange(shape, ModelChange_1.ItemChangeType.UpdateProperties)]);
    };
    ModelManipulator.prototype.changeShapeText = function (shape, text) {
        shape.text = text;
        this.raiseModelChanged([new ModelChange_1.ItemChange(shape, ModelChange_1.ItemChangeType.UpdateStructure)]);
    };
    ModelManipulator.prototype.changeShapeImage = function (shape, image) {
        shape.image = image;
        var cachedImage = ImageCache_1.ImageCache.instance.createUnloadedInfoByShapeImageInfo(image);
        this.imageLoader.load(cachedImage);
        this.raiseModelChanged([new ModelChange_1.ItemChange(shape, ModelChange_1.ItemChangeType.UpdateStructure)]);
    };
    ModelManipulator.prototype.changeShapeExpanded = function (shape, expanded) {
        shape.expanded = expanded;
        shape.toggleExpandedSize();
        this.raiseModelChanged([new ModelChange_1.ItemChange(shape, ModelChange_1.ItemChangeType.UpdateStructure)]);
    };
    ModelManipulator.prototype.deleteShape = function (shape, allowed) {
        if (shape.attachedConnectors.length)
            throw Error("A removing shape should not contain existing connectors.");
        this.removeShape(shape, allowed);
    };
    ModelManipulator.prototype.removeShape = function (shape, allowed) {
        this.model.removeItem(shape);
        this.raiseModelChanged([new ModelChange_1.ItemChange(shape, ModelChange_1.ItemChangeType.Remove, allowed)]);
    };
    ModelManipulator.prototype.updateShapeImage = function (cacheImageInfo) {
        if (!cacheImageInfo.imageUrl)
            return;
        var shapes = this.model.findShapesByImageUrl(cacheImageInfo.imageUrl);
        shapes.forEach(function (shape) {
            if (cacheImageInfo.base64)
                shape.image.loadBase64Content(cacheImageInfo.base64);
            else
                shape.image.setUnableToLoadFlag();
        });
        this.commitItemsChangesCore(ModelChange_1.ItemChangeType.UpdateStructure, shapes);
    };
    ModelManipulator.prototype.updateShapeDescription = function (description) {
        var shapes = this.model.findShapesByDescription(description);
        this.commitItemsChangesCore(ModelChange_1.ItemChangeType.UpdateProperties, shapes);
    };
    ModelManipulator.prototype.addConnector = function (connector, key) {
        if (connector.beginItem || connector.endItem)
            throw Error("Creating connector should not contain begin/end items");
        connector.key = key !== undefined ? key : this.model.getNextKey();
        return this.insertConnector(connector);
    };
    ModelManipulator.prototype.insertConnector = function (connector) {
        this.model.pushItem(connector);
        var routingStrategy = this.routingModel.createStrategy(connector.properties.lineOption);
        if (routingStrategy)
            connector.changeRoutingStrategy(routingStrategy);
        else
            connector.clearRoutingStrategy();
        var allowed = this.permissionsProvider.canAddItems([connector]);
        this.raiseModelChanged([new ModelChange_1.ItemChange(connector, ModelChange_1.ItemChangeType.Create, allowed)]);
        return connector;
    };
    ModelManipulator.prototype.deleteConnector = function (connector) {
        if (connector.beginItem || connector.endItem)
            throw Error("Creating connector should not contain begin/end items");
        this.removeConnector(connector);
    };
    ModelManipulator.prototype.removeConnector = function (connector) {
        this.model.removeItem(connector);
        var allowed = this.permissionsProvider.canDeleteItems([connector]);
        this.raiseModelChanged([new ModelChange_1.ItemChange(connector, ModelChange_1.ItemChangeType.Remove, allowed)]);
    };
    ModelManipulator.prototype.addDeleteConnectorPoint = function (connector, callBack) {
        var oldConnectorPoints = this.getConnectorInteractingPoints(connector);
        callBack(connector);
        this.addDeleteConnectorPointCore(connector, oldConnectorPoints);
    };
    ModelManipulator.prototype.moveConnectorPoint = function (connector, pointIndex, callBack) {
        callBack(connector);
        this.moveConnectorPointCore(connector, pointIndex);
    };
    ModelManipulator.prototype.changeConnectorPoints = function (connector, callBack) {
        var _this = this;
        callBack(connector);
        connector.points.forEach(function (_, i) { return _this.moveConnectorPointCore(connector, i); });
    };
    ModelManipulator.prototype.moveConnectorPointCore = function (connector, pointIndex) {
        var interactingItem = this.getInteractingItem(connector);
        var allowed = this.permissionsProvider.isStoredPermissionsGranted();
        if (interactingItem) {
            var changeConnectionPoints = (0 < pointIndex && pointIndex < connector.points.length - 1);
            changeConnectionPoints = changeConnectionPoints || (pointIndex === 0 && !connector.beginItem);
            changeConnectionPoints = changeConnectionPoints || (pointIndex === connector.points.length - 1 && !connector.endItem);
            if (changeConnectionPoints) {
                var oldConnectorPoints = interactingItem.points.map(function (p) { return p.clone(); });
                var newConnectorPoints = connector.points.map(function (p) { return p.clone(); });
                if (!Utils_1.GeometryUtils.arePointsEqual(oldConnectorPoints, newConnectorPoints))
                    allowed = this.permissionsProvider.canChangeConnectorPoints(connector, oldConnectorPoints, newConnectorPoints);
            }
        }
        this.raiseModelChanged([new ModelChange_1.ItemChange(connector, ModelChange_1.ItemChangeType.UpdateProperties, allowed)]);
    };
    ModelManipulator.prototype.getConnectorInteractingPoints = function (connector) {
        var interactingItem = this.getInteractingItem(connector);
        return interactingItem ? interactingItem.points.map(function (p) { return p.clone(); }) : connector.points.map(function (p) { return p.clone(); });
    };
    ModelManipulator.prototype.addDeleteConnectorPointCore = function (connector, oldConnectorPoints) {
        var allowed = this.permissionsProvider.isStoredPermissionsGranted();
        var newConnectorPoints = connector.points.map(function (p) { return p.clone(); });
        if (!Utils_1.GeometryUtils.arePointsEqual(oldConnectorPoints, newConnectorPoints))
            allowed = this.permissionsProvider.canChangeConnectorPoints(connector, oldConnectorPoints, newConnectorPoints);
        this.raiseModelChanged([new ModelChange_1.ItemChange(connector, ModelChange_1.ItemChangeType.UpdateProperties, allowed)]);
    };
    ModelManipulator.prototype.addConnection = function (connector, item, connectionPointIndex, position) {
        var existingItem = connector.getExtremeItem(position);
        var existingConnectionPointIndex = connector.getExtremeConnectionPointIndex(position);
        if (existingItem === item && existingConnectionPointIndex === connectionPointIndex)
            return;
        else if (existingItem)
            throw Error("Connector is already connected");
        item.attachedConnectors.push(connector);
        if (position === Connector_1.ConnectorPosition.Begin) {
            connector.beginItem = item;
            connector.beginConnectionPointIndex = connectionPointIndex;
        }
        else {
            connector.endItem = item;
            connector.endConnectionPointIndex = connectionPointIndex;
        }
        connector.invalidateRenderPoints();
        var allowed = this.permissionsProvider.canChangeConnection(connector, item, undefined, position, connectionPointIndex);
        this.raiseModelChanged([new ModelChange_1.ItemChange(connector, ModelChange_1.ItemChangeType.UpdateProperties, allowed)]);
    };
    ModelManipulator.prototype.setConnectionPointIndex = function (connector, connectionPointIndex, position) {
        if (!connector.getExtremeItem(position))
            throw Error("Connection should be connected");
        if (position === Connector_1.ConnectorPosition.Begin)
            connector.beginConnectionPointIndex = connectionPointIndex;
        else
            connector.endConnectionPointIndex = connectionPointIndex;
        connector.invalidateRenderPoints();
        var item = connector.getExtremeItem(position);
        var allowed = this.permissionsProvider.canChangeConnection(connector, item, item, position, connectionPointIndex);
        this.raiseModelChanged([new ModelChange_1.ItemChange(connector, ModelChange_1.ItemChangeType.UpdateProperties, allowed)]);
    };
    ModelManipulator.prototype.deleteConnection = function (connector, position) {
        var item = connector.getExtremeItem(position);
        if (!item)
            return;
        item.attachedConnectors.splice(item.attachedConnectors.indexOf(connector), 1);
        if (position === Connector_1.ConnectorPosition.Begin) {
            connector.beginItem = null;
            connector.beginConnectionPointIndex = -1;
        }
        else {
            connector.endItem = null;
            connector.endConnectionPointIndex = -1;
        }
        connector.invalidateRenderPoints();
        var allowed = this.permissionsProvider.canChangeConnection(connector, undefined, item, position, -1);
        this.raiseModelChanged([new ModelChange_1.ItemChange(connector, ModelChange_1.ItemChangeType.UpdateProperties, allowed)]);
    };
    ModelManipulator.prototype.changeConnectorProperty = function (connector, propertyName, value) {
        connector.properties[propertyName] = value;
        if (propertyName === "lineOption") {
            var routingStrategy = this.routingModel ? this.routingModel.createStrategy(connector.properties.lineOption) : undefined;
            if (routingStrategy)
                connector.changeRoutingStrategy(routingStrategy);
            else
                connector.clearRoutingStrategy();
        }
        else
            connector.invalidateRenderPoints();
        this.raiseModelChanged([new ModelChange_1.ItemChange(connector, ModelChange_1.ItemChangeType.UpdateProperties)]);
    };
    ModelManipulator.prototype.changeConnectorText = function (connector, text, position) {
        connector.setText(text, position);
        this.raiseModelChanged([new ModelChange_1.ItemChange(connector, ModelChange_1.ItemChangeType.UpdateStructure)]);
    };
    ModelManipulator.prototype.changeConnectorTextPosition = function (connector, position, newPosition) {
        var text = connector.getText(position);
        connector.setText(null, position);
        connector.setText(text, newPosition);
        this.raiseModelChanged([new ModelChange_1.ItemChange(connector, ModelChange_1.ItemChangeType.UpdateProperties)]);
    };
    ModelManipulator.prototype.changeModelSize = function (size, offset) {
        this.model.size.width = size.width;
        this.model.size.height = size.height;
        this.raiseModelSizeChanged(this.model.size.clone(), offset);
        if (offset.left || offset.top) {
            this.model.snapStartPoint = this.model.snapStartPoint.clone().offset(offset.left, offset.top);
            this.raiseSnapPointChange(this.model.snapStartPoint);
        }
    };
    ModelManipulator.prototype.changePageSize = function (value) {
        if (!this.model.pageSize.equals(value)) {
            this.model.pageSize = value;
            this.model.size = new size_1.Size(this.model.pageWidth, this.model.pageHeight);
            this.raiseModelSizeChanged(this.model.size.clone());
            this.raisePageSizeChanged(this.model.pageSize, this.model.pageLandscape);
        }
    };
    ModelManipulator.prototype.changePageLandscape = function (value) {
        if (this.model.pageLandscape !== value) {
            this.model.pageLandscape = value;
            if (this.model.pageSize.width !== this.model.pageSize.height) {
                this.model.size = new size_1.Size(this.model.pageWidth, this.model.pageHeight);
                this.raiseModelSizeChanged(this.model.size.clone());
                this.raisePageSizeChanged(this.model.pageSize, this.model.pageLandscape);
            }
        }
    };
    ModelManipulator.prototype.changePageColor = function (value) {
        if (this.model.pageColor !== value) {
            this.model.pageColor = value;
            this.raisePageColorChanged(value);
        }
    };
    ModelManipulator.prototype.updateModelSize = function () {
        var offset = this.getModelSizeUpdateOffset();
        if (!offset.isEmpty()) {
            var newWidth = Math.max(this.model.size.width + offset.left + offset.right, this.model.pageWidth);
            var newHeight = Math.max(this.model.size.height + offset.top + offset.bottom, this.model.pageHeight);
            this.model.size = new size_1.Size(newWidth, newHeight);
        }
    };
    ModelManipulator.prototype.getModelSizeUpdateOffset = function () {
        var oldRectangle = this.model.getRectangle(false);
        var newRectangle = this.model.getRectangle(true);
        if (!newRectangle.equals(oldRectangle))
            this.raiseModelRectangleChanged(newRectangle);
        return this.createModelRectangleOffset(newRectangle);
    };
    ModelManipulator.prototype.createModelRectangleOffset = function (rectangle) {
        var pageWidth = this.model.pageWidth;
        var pageHeight = this.model.pageHeight;
        var size = this.model.size;
        return new offsets_1.Offsets(-Math.floor(rectangle.x / pageWidth) * pageWidth, -Math.floor((size.width - rectangle.right) / pageWidth) * pageWidth, -Math.floor(rectangle.y / pageHeight) * this.model.pageHeight, -Math.floor((size.height - rectangle.bottom) / pageHeight) * pageHeight);
    };
    ModelManipulator.prototype.raiseModelChanged = function (changes) {
        this.onModelChanged.raise1(function (l) { return l.notifyModelChanged(changes); });
    };
    ModelManipulator.prototype.raisePageColorChanged = function (color) {
        this.onModelChanged.raise1(function (l) { return l.notifyPageColorChanged(color); });
    };
    ModelManipulator.prototype.raisePageSizeChanged = function (pageSize, pageLandscape) {
        this.onModelChanged.raise1(function (l) { return l.notifyPageSizeChanged(pageSize, pageLandscape); });
    };
    ModelManipulator.prototype.raiseModelSizeChanged = function (size, offset) {
        this.onModelSizeChanged.raise1(function (l) { return l.notifyModelSizeChanged(size, offset); });
    };
    ModelManipulator.prototype.raiseModelRectangleChanged = function (rectangle) {
        this.onModelSizeChanged.raise1(function (l) { return l.notifyModelRectangleChanged(rectangle); });
    };
    ModelManipulator.prototype.raiseSnapPointChange = function (point) {
        this.onModelSizeChanged.raise1(function (l) { return l.notifySnapPointPositionChanged(point); });
    };
    ModelManipulator.prototype.getInteractingItem = function (item, operation) {
        return this.permissionsProvider.getInteractingItem(item, operation);
    };
    return ModelManipulator;
}());
exports.ModelManipulator = ModelManipulator;


/***/ }),
/* 303 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.EventManager = void 0;
var MouseHandler_1 = __webpack_require__(304);
var Utils_1 = __webpack_require__(3);
var TextInputHandler_1 = __webpack_require__(323);
var ContextMenuHandler_1 = __webpack_require__(154);
var ContextMenuTouchHandler_1 = __webpack_require__(324);
var VisualizersManager_1 = __webpack_require__(155);
var VisualizersTouchManager_1 = __webpack_require__(330);
var ContextToolboxHandler_1 = __webpack_require__(331);
var browser_1 = __webpack_require__(18);
var key_1 = __webpack_require__(25);
var EventManager = (function () {
    function EventManager(control) {
        this.onMouseOperation = new Utils_1.EventDispatcher();
        this.onTextInputOperation = new Utils_1.EventDispatcher();
        this.toolboxes = [];
        this.control = control;
        this.visualizersManager = Utils_1.EventUtils.isTouchMode() ?
            new VisualizersTouchManager_1.VisualizerTouchManager(control.selection, control.model, this, control.settings) :
            new VisualizersManager_1.VisualizerManager(control.selection, control.model, this, control.settings);
        this.onMouseOperation.add(this.visualizersManager);
        this.contextMenuHandler = browser_1.Browser.TouchUI ?
            new ContextMenuTouchHandler_1.ContextMenuTouchHandler(control.selection) :
            new ContextMenuHandler_1.ContextMenuHandler();
        this.contextMenuHandler.onVisibilityChanged.add(control);
        this.onMouseOperation.add(this.contextMenuHandler);
        this.onTextInputOperation.add(this.contextMenuHandler);
        this.contextToolboxHandler = new ContextToolboxHandler_1.ContextToolboxHandler();
        this.contextToolboxHandler.onVisibilityChanged.add(control);
        this.contextToolboxHandler.onVisibilityChanged.add(this.contextMenuHandler);
        this.mouseHandler = new MouseHandler_1.MouseHandler(control.history, control.selection, control.model, this, control.settings.readOnly, control.view, this.visualizersManager, this.contextToolboxHandler, control.shapeDescriptionManager, control.settings, control.permissionsProvider);
        this.textInputHandler = new TextInputHandler_1.TextInputHandler(control);
        this.visualizersManager.onVisualizersUpdate.add(this.mouseHandler);
    }
    Object.defineProperty(EventManager.prototype, "onVisualizersUpdate", {
        get: function () {
            return this.visualizersManager.onVisualizersUpdate;
        },
        enumerable: false,
        configurable: true
    });
    EventManager.prototype.registerToolbox = function (toolbox) {
        this.toolboxes.push(toolbox);
    };
    EventManager.prototype.cleanToolboxes = function (eventDispatcher) {
        this.toolboxes.forEach(function (toolbox) {
            eventDispatcher.remove(toolbox);
        });
        this.toolboxes = [];
    };
    EventManager.prototype.initialize = function () {
        this.visualizersManager.initialize(this.control.model);
        this.mouseHandler.initialize(this.control.model);
    };
    EventManager.prototype.beginUpdate = function (lockUpdateCanvas) {
        this.contextMenuHandler.beginUpdate();
        this.visualizersManager.beginUpdate();
    };
    EventManager.prototype.endUpdate = function () {
        this.contextMenuHandler.endUpdate();
        this.visualizersManager.endUpdate();
    };
    EventManager.prototype.onMouseDown = function (evt) {
        this.mouseHandler.onMouseDown(evt);
        this.contextMenuHandler.onMouseDown(evt);
        this.visualizersManager.onMouseDown(evt);
        this.contextToolboxHandler.onMouseDown(evt);
    };
    EventManager.prototype.onMouseMove = function (evt) {
        this.processDragging(evt);
        this.mouseHandler.onMouseMove(evt);
    };
    EventManager.prototype.onMouseUp = function (evt) {
        this.contextToolboxHandler.onMouseUp(evt);
        this.mouseHandler.onMouseUp(evt);
        this.contextMenuHandler.onMouseUp(evt);
        this.visualizersManager.onMouseUp(evt);
        this.processDragging(evt);
    };
    EventManager.prototype.onMouseEnter = function (evt) {
        this.visualizersManager.onMouseEnter(evt);
    };
    EventManager.prototype.onMouseLeave = function (evt) {
        this.visualizersManager.onMouseLeave(evt);
    };
    EventManager.prototype.onDblClick = function (evt) {
        this.mouseHandler.onMouseDblClick(evt);
        this.textInputHandler.onDblClick(evt);
        this.control.apiController.notifyDblClick(evt);
    };
    EventManager.prototype.onClick = function (evt) {
        this.mouseHandler.onMouseClick(evt);
        this.control.apiController.notifyClick(evt);
    };
    EventManager.prototype.onContextMenu = function (evt) {
        this.contextMenuHandler.onContextMenu(evt);
    };
    EventManager.prototype.onLongTouch = function (evt) {
        this.mouseHandler.onLongTouch(evt);
        this.contextMenuHandler.onLongTouch(evt);
    };
    EventManager.prototype.onBlur = function (evt) {
        this.contextMenuHandler.onBlur(evt);
        this.contextToolboxHandler.onBlur(evt);
        this.visualizersManager.onBlur(evt);
    };
    EventManager.prototype.onFocus = function (evt) {
        this.contextMenuHandler.onFocus(evt);
        this.contextToolboxHandler.onFocus(evt);
        this.visualizersManager.onFocus(evt);
    };
    EventManager.prototype.onKeyDown = function (evt) {
        var scCode = evt.getShortcutCode();
        if (this.onShortcut(scCode)) {
            this.visualizersManager.updateConnectionPoints();
            this.contextMenuHandler.onShortcut(evt);
            this.contextToolboxHandler.onShortcut(evt);
            evt.preventDefault = true;
        }
        else if (this.isShortcutForFocusInput(scCode))
            evt.preventDefault = true;
        this.contextMenuHandler.onKeyDown(evt);
        this.contextToolboxHandler.onKeyDown(evt);
        this.mouseHandler.onKeyDown(evt);
    };
    EventManager.prototype.onKeyUp = function (evt) {
        this.mouseHandler.onKeyUp(evt);
    };
    EventManager.prototype.onTextInputBlur = function (evt) {
        this.textInputHandler.onBlur(evt);
        this.contextMenuHandler.onTextInputBlur(evt);
    };
    EventManager.prototype.onTextInputFocus = function (evt) {
        this.textInputHandler.onFocus(evt);
        this.contextMenuHandler.onTextInputFocus(evt);
    };
    EventManager.prototype.onTextInputKeyDown = function (evt) {
        this.textInputHandler.onKeyDown(evt);
    };
    EventManager.prototype.onShortcut = function (code) {
        if (this.control.commandManager.processShortcut(code))
            return true;
        if (this.mouseHandler.onShortcut(code))
            return true;
    };
    EventManager.prototype.isShortcutForFocusInput = function (code) {
        return code === key_1.KeyCode.Delete || code === (key_1.KeyCode.Delete | key_1.ModifierKey.Ctrl) || code === (key_1.KeyCode.Delete | key_1.ModifierKey.Meta) ||
            (code === key_1.KeyCode.Backspace) || code === (key_1.KeyCode.Backspace | key_1.ModifierKey.Ctrl) || code === (key_1.KeyCode.Backspace | key_1.ModifierKey.Shift) || code === (key_1.KeyCode.Backspace | key_1.ModifierKey.Meta) ||
            code === key_1.KeyCode.Home || code === key_1.KeyCode.End ||
            code === key_1.KeyCode.Up || code === (key_1.KeyCode.Up | key_1.ModifierKey.Ctrl) || code === (key_1.KeyCode.Up | key_1.ModifierKey.Meta) ||
            code === key_1.KeyCode.Down || code === (key_1.KeyCode.Down | key_1.ModifierKey.Ctrl) || code === (key_1.KeyCode.Down | key_1.ModifierKey.Meta) ||
            code === key_1.KeyCode.Left || code === (key_1.KeyCode.Left | key_1.ModifierKey.Ctrl) || code === (key_1.KeyCode.Left | key_1.ModifierKey.Meta) ||
            code === key_1.KeyCode.Right || code === (key_1.KeyCode.Right | key_1.ModifierKey.Ctrl) || code === (key_1.KeyCode.Right | key_1.ModifierKey.Meta);
    };
    EventManager.prototype.onPaste = function (evt) {
        if (!this.textInputHandler.isTextInputActive() && this.control.commandManager.processPaste(evt.clipboardData)) {
            this.visualizersManager.updateConnectionPoints();
            evt.preventDefault = true;
        }
    };
    EventManager.prototype.onMouseWheel = function (evt) {
        if (this.mouseHandler.onWheel(evt))
            evt.preventDefault = true;
    };
    EventManager.prototype.isFocused = function () {
        return this.control.isFocused();
    };
    EventManager.prototype.processDragging = function (evt) {
        var draggingEvt = this.getDraggingEvent();
        if (draggingEvt && this.draggingEvent !== draggingEvt) {
            this.draggingEvent = draggingEvt;
            this.mouseHandler.onDragStart(this.draggingEvent);
            this.control.captureFocus();
        }
        else if (!draggingEvt && this.draggingEvent) {
            delete this.draggingEvent;
            this.mouseHandler.onDragEnd(evt);
        }
    };
    EventManager.prototype.getDraggingEvent = function () {
        return this.toolboxes
            .filter(function (t) { return t.draggingObject; })
            .map(function (t) { return t.draggingObject.evt; })[0];
    };
    EventManager.prototype.onDocumentDragStart = function (itemKeys) {
        this.control.beginUpdate();
        this.control.captureFocus();
        this.onMouseOperation.raise("notifyDragStart", itemKeys);
    };
    EventManager.prototype.onDocumentDragEnd = function (itemKeys) {
        this.onMouseOperation.raise("notifyDragEnd", itemKeys);
        this.control.endUpdate();
        this.control.barManager.updateItemsState();
    };
    EventManager.prototype.onDocumentDragScrollStart = function () {
        this.onMouseOperation.raise1(function (l) { return l.notifyDragScrollStart(); });
    };
    EventManager.prototype.onDocumentDragScrollEnd = function () {
        this.onMouseOperation.raise1(function (l) { return l.notifyDragScrollEnd(); });
    };
    EventManager.prototype.onDocumentClick = function (itemKeys) {
        this.control.beginUpdate();
        this.control.endUpdate();
        this.control.barManager.updateItemsState();
    };
    EventManager.prototype.raiseTextInputStart = function (item, text, position, size) {
        this.onTextInputOperation.raise("notifyTextInputStart", item, text, position, size);
    };
    EventManager.prototype.raiseTextInputEnd = function (item, captureFocus) {
        this.onTextInputOperation.raise("notifyTextInputEnd", item, captureFocus);
    };
    EventManager.prototype.raiseTextInputPermissionsCheck = function (item, allowed) {
        this.onTextInputOperation.raise("notifyTextInputPermissionsCheck", item, allowed);
    };
    EventManager.prototype.canFinishTextEditing = function () {
        return this.textInputHandler.canFinishTextEditing();
    };
    return EventManager;
}());
exports.EventManager = EventManager;


/***/ }),
/* 304 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.MouseHandler = void 0;
var MouseHandlerDefaultState_1 = __webpack_require__(147);
var Event_1 = __webpack_require__(11);
var point_1 = __webpack_require__(0);
var ModelUtils_1 = __webpack_require__(4);
var MouseHandlerDefaultReadOnlyTouchState_1 = __webpack_require__(321);
var MouseHandlerDefaultReadOnlyState_1 = __webpack_require__(152);
var MouseHandlerDefaultTouchState_1 = __webpack_require__(322);
var key_1 = __webpack_require__(25);
var Utils_1 = __webpack_require__(3);
var MouseHandler = (function () {
    function MouseHandler(history, selection, model, eventManager, readOnly, view, visualizerManager, contextToolboxHandler, shapeDescriptionManager, settings, permissionsProvider) {
        this.history = history;
        this.selection = selection;
        this.model = model;
        this.eventManager = eventManager;
        this.readOnly = readOnly;
        this.view = view;
        this.visualizerManager = visualizerManager;
        this.contextToolboxHandler = contextToolboxHandler;
        this.shapeDescriptionManager = shapeDescriptionManager;
        this.settings = settings;
        this.permissionsProvider = permissionsProvider;
        this.finishStateLock = 0;
        this.initialize(model);
        this.selection.onChanged.add(this);
    }
    MouseHandler.prototype.initialize = function (model) {
        this.model = model;
        this.allowMultipleSelection = true;
        this.allowCopyDiagramItems = true;
        this.allowSnapToCellOnDragDiagramItem = true;
        this.allowSnapToCellOnDragPoint = true;
        this.allowSnapToCellOnResizeShape = true;
        this.allowFixedDrag = true;
        this.allowZoomOnWheel = true;
        this.allowScrollPage = true;
        this.shouldScrollPage = false;
        this.copyDiagramItemsByCtrlAndShift = false;
        this.startScrollingPageByCtrl = false;
        this.initializeDefaultState();
    };
    MouseHandler.prototype.initializeDefaultState = function () {
        this.defaultState = this.readOnly ?
            (Utils_1.EventUtils.isTouchMode() ?
                new MouseHandlerDefaultReadOnlyTouchState_1.MouseHandlerDefaultReadOnlyTouchState(this, this.history, this.selection, this.model, this.view, this.visualizerManager, this.shapeDescriptionManager, this.settings) :
                new MouseHandlerDefaultReadOnlyState_1.MouseHandlerDefaultReadOnlyState(this, this.history, this.selection, this.model, this.view, this.visualizerManager, this.shapeDescriptionManager, this.settings)) :
            (Utils_1.EventUtils.isTouchMode() ?
                new MouseHandlerDefaultTouchState_1.MouseHandlerDefaultTouchState(this, this.history, this.selection, this.model, this.view, this.visualizerManager, this.shapeDescriptionManager, this.settings) :
                new MouseHandlerDefaultState_1.MouseHandlerDefaultState(this, this.history, this.selection, this.model, this.view, this.visualizerManager, this.shapeDescriptionManager, this.settings));
        this.switchToDefaultState();
    };
    MouseHandler.prototype.onMouseDown = function (evt) {
        this.mouseDownEvent = evt;
        this.state.onMouseDown(evt);
    };
    MouseHandler.prototype.onMouseMove = function (evt) {
        this.state.onMouseMove(evt);
    };
    MouseHandler.prototype.onMouseUp = function (evt) {
        this.state.onMouseUp(evt);
    };
    MouseHandler.prototype.onMouseDblClick = function (evt) {
        this.state.onMouseDblClick(evt);
    };
    MouseHandler.prototype.onMouseClick = function (evt) {
        this.state.onMouseClick(evt);
    };
    MouseHandler.prototype.onLongTouch = function (evt) {
        if (!evt.touches || evt.touches.length > 1)
            return;
        var key = evt.source.key;
        if (key === undefined)
            this.selection.clear();
        else if (this.selection.hasKey(key))
            this.selection.remove(key);
        else
            this.selection.add(key);
    };
    MouseHandler.prototype.onShortcut = function (code) {
        return this.state.onShortcut(code);
    };
    MouseHandler.prototype.onWheel = function (evt) {
        return this.state.onMouseWheel(evt);
    };
    MouseHandler.prototype.onDragStart = function (evt) {
        this.state.onDragStart(evt);
    };
    MouseHandler.prototype.onDragEnd = function (evt) {
        this.state.onDragEnd(evt);
    };
    MouseHandler.prototype.onKeyDown = function (evt) {
        this.state.onKeyDown(evt);
    };
    MouseHandler.prototype.onKeyUp = function (evt) {
        this.state.onKeyUp(evt);
    };
    MouseHandler.prototype.showContextToolbox = function (modelPoint, getPositionToInsertShapeTo, side, category, applyCallback, cancelCallback) {
        this.contextToolboxHandler.showContextToolbox(modelPoint, getPositionToInsertShapeTo, side, category, applyCallback, cancelCallback);
    };
    MouseHandler.prototype.hideContextToolbox = function (applyed) {
        this.contextToolboxHandler.hideContextToolbox(applyed);
    };
    MouseHandler.prototype.canScrollPage = function (evt) {
        if (this.startScrollingPageByCtrl) {
            if (!this.hasCtrlModifier(evt.modifiers))
                return false;
            if (!this.copyDiagramItemsByCtrlAndShift)
                return true;
            return evt.source.type !== Event_1.MouseEventElementType.Shape && evt.source.type !== Event_1.MouseEventElementType.Connector;
        }
        return this.allowScrollPage && this.shouldScrollPage;
    };
    MouseHandler.prototype.canMultipleSelection = function (evt) {
        return this.allowMultipleSelection && this.hasCtrlOrShiftModifier(evt.modifiers);
    };
    MouseHandler.prototype.canCopySelectedItems = function (evt) {
        if (!this.allowCopyDiagramItems)
            return false;
        return this.copyDiagramItemsByCtrlAndShift ? this.hasCtrlAndShiftModifier(evt.modifiers) : this.hasAltModifier(evt.modifiers);
    };
    MouseHandler.prototype.canCalculateFixedPosition = function (evt) {
        if (!this.allowFixedDrag || !this.hasShiftModifier(evt.modifiers))
            return false;
        if (this.copyDiagramItemsByCtrlAndShift && this.hasCtrlModifier(evt.modifiers))
            return false;
        return true;
    };
    MouseHandler.prototype.canStartZoomOnWheel = function (evt) {
        return this.allowZoomOnWheel && this.hasCtrlModifier(evt.modifiers);
    };
    MouseHandler.prototype.canFinishZoomOnWheel = function (evt) {
        return this.allowZoomOnWheel && !this.hasCtrlModifier(evt.modifiers);
    };
    MouseHandler.prototype.onStartScrollPageByKeyboard = function (evt) {
        if (this.canStartScrollingPageByKeyboard(evt)) {
            this.raiseDragScrollStart();
            this.shouldScrollPage = true;
        }
    };
    MouseHandler.prototype.onFinishScrollPageByKeyboard = function (evt) {
        if (this.canEndScrollingPageByKeyboard(evt))
            this.finishScrollingPage();
    };
    MouseHandler.prototype.onFinishScrollPageByMouse = function (evt) {
        if (this.canEndScrollingPage(evt))
            this.finishScrollingPage();
    };
    MouseHandler.prototype.finishScrollingPage = function () {
        this.shouldScrollPage = false;
        this.raiseDragScrollEnd();
        this.switchToDefaultState();
    };
    MouseHandler.prototype.hasCtrlOrShiftModifier = function (key) {
        return this.hasCtrlModifier(key) || this.hasShiftModifier(key);
    };
    MouseHandler.prototype.hasCtrlAndShiftModifier = function (key) {
        return this.hasCtrlModifier(key) && this.hasShiftModifier(key);
    };
    MouseHandler.prototype.hasCtrlModifier = function (key) {
        return (key & key_1.ModifierKey.Ctrl) > 0;
    };
    MouseHandler.prototype.hasAltModifier = function (key) {
        return (key & key_1.ModifierKey.Alt) > 0;
    };
    MouseHandler.prototype.hasShiftModifier = function (key) {
        return (key & key_1.ModifierKey.Shift) > 0;
    };
    MouseHandler.prototype.canStartScrollingPageByKeyboard = function (evt) {
        return !this.startScrollingPageByCtrl && !this.shouldScrollPage && evt.keyCode === key_1.KeyCode.Space;
    };
    MouseHandler.prototype.canEndScrollingPageByKeyboard = function (evt) {
        return !this.startScrollingPageByCtrl && evt.keyCode === key_1.KeyCode.Space;
    };
    MouseHandler.prototype.canEndScrollingPage = function (evt) {
        return this.startScrollingPageByCtrl ? this.hasCtrlModifier(evt.modifiers) : true;
    };
    MouseHandler.prototype.getSnappedPointOnDragDiagramItem = function (evt, basePoint, fixedX, fixedY, startPoint) {
        var snapToCell = this.getSnapToCellOnDragDiagramItem(evt);
        return new point_1.Point(this.getSnappedPos(this.getFixedXPosition(evt, basePoint, fixedX, startPoint), true, snapToCell), this.getSnappedPos(this.getFixedYPosition(evt, basePoint, fixedY, startPoint), false, snapToCell));
    };
    MouseHandler.prototype.getSnappedPointOnDragPoint = function (evt, point, additionalSnappedPoint) {
        var snapToCell = this.getSnapToCellOnDragPoint(evt);
        var x = this.getSnappedPos(point.x, true, snapToCell);
        var y = this.getSnappedPos(point.y, false, snapToCell);
        if (additionalSnappedPoint === undefined)
            return new point_1.Point(x, y);
        else if (Math.pow(point.x - x, 2) + Math.pow(point.y - y, 2) < Math.pow(point.x - additionalSnappedPoint.x, 2) + Math.pow(point.y - additionalSnappedPoint.y, 2))
            return new point_1.Point(x, y);
        else
            return additionalSnappedPoint;
    };
    MouseHandler.prototype.getSnappedOffsetOnDragPoint = function (evt, startPoint) {
        var snapToCell = this.getSnapToCellOnDragPoint(evt);
        return new point_1.Point(this.getSnappedPos(evt.modelPoint.x - startPoint.x, true, snapToCell), this.getSnappedPos(evt.modelPoint.y - startPoint.y, false, snapToCell));
    };
    MouseHandler.prototype.lockAspectRatioOnShapeResize = function (evt) {
        return this.hasShiftModifier(evt.modifiers);
    };
    MouseHandler.prototype.getSnappedPositionOnResizeShape = function (evt, pos, isHorizontal) {
        if (!this.getSnapToCellOnResizeShape(evt))
            return pos;
        return ModelUtils_1.ModelUtils.getSnappedPos(this.model, this.settings.gridSize, pos, isHorizontal);
    };
    MouseHandler.prototype.getSnappedPos = function (pos, isHorizontal, snapToCell) {
        return snapToCell ? ModelUtils_1.ModelUtils.getSnappedPos(this.model, this.settings.gridSize, pos, isHorizontal) : pos;
    };
    MouseHandler.prototype.getFixedXPosition = function (evt, basePoint, fixedX, startPoint) {
        return fixedX ? basePoint.x : basePoint.x + evt.modelPoint.x - startPoint.x;
    };
    MouseHandler.prototype.getFixedYPosition = function (evt, basePoint, fixedY, startPoint) {
        return fixedY ? basePoint.y : basePoint.y + evt.modelPoint.y - startPoint.y;
    };
    MouseHandler.prototype.getSnapToCellOnDragDiagramItem = function (evt) {
        return this.allowSnapToCellOnDragDiagramItem &&
            this.settings.snapToGrid &&
            !this.hasCtrlModifier(evt.modifiers);
    };
    MouseHandler.prototype.getSnapToCellOnDragPoint = function (evt) {
        return this.allowSnapToCellOnDragPoint &&
            this.settings.snapToGrid &&
            !this.hasCtrlModifier(evt.modifiers);
    };
    MouseHandler.prototype.getSnapToCellOnResizeShape = function (evt) {
        return this.allowSnapToCellOnResizeShape &&
            this.settings.snapToGrid &&
            !this.hasCtrlModifier(evt.modifiers);
    };
    MouseHandler.prototype.tryUpdateModelSize = function (processPoints) {
        this.lockPermissions();
        ModelUtils_1.ModelUtils.tryUpdateModelRectangle(this.history, processPoints);
        this.unlockPermissions();
    };
    MouseHandler.prototype.canAddDiagramItemToSelection = function (evt) {
        return evt.source.key && (evt.button === Event_1.MouseButton.Left || evt.button === Event_1.MouseButton.Right);
    };
    MouseHandler.prototype.addDiagramItemToSelection = function (evt) {
        this.pressedDiagramItemKey = evt.source.key;
        this.pressedDiagramItemInSelection = this.selection.hasKey(this.pressedDiagramItemKey);
        if (this.canMultipleSelection(evt))
            this.selection.add(evt.source.key);
        else
            this.changeSingleSelection(evt.source.key);
    };
    MouseHandler.prototype.canRemoveDiagramItemToSelection = function (evt) {
        return this.pressedDiagramItemKey &&
            evt.source.key &&
            this.pressedDiagramItemKey === evt.source.key &&
            (evt.button === Event_1.MouseButton.Left || evt.button === Event_1.MouseButton.Right);
    };
    MouseHandler.prototype.removeDiagramItemFromSelection = function (button, sourceKey) {
        if (this.pressedDiagramItemInSelection && this.selection.getKeys().length > 1 && button === Event_1.MouseButton.Left)
            this.selection.remove(sourceKey);
    };
    MouseHandler.prototype.changeSingleSelection = function (key) {
        if (!this.selection.hasKey(key))
            this.selection.set([key]);
    };
    MouseHandler.prototype.notifySelectionChanged = function (selection) {
        if (this.pressedDiagramItemKey && !this.selection.hasKey(this.pressedDiagramItemKey)) {
            this.pressedDiagramItemKey = undefined;
            this.pressedDiagramItemInSelection = false;
        }
    };
    MouseHandler.prototype.raiseDragStart = function (keys) {
        this.eventManager.onDocumentDragStart(keys);
    };
    MouseHandler.prototype.raiseDragEnd = function (keys) {
        this.eventManager.onDocumentDragEnd(keys);
    };
    MouseHandler.prototype.raiseDragScrollStart = function () {
        this.eventManager.onDocumentDragScrollStart();
    };
    MouseHandler.prototype.raiseDragScrollEnd = function () {
        this.eventManager.onDocumentDragScrollEnd();
    };
    MouseHandler.prototype.raiseClick = function (keys) {
        this.eventManager.onDocumentClick(keys);
    };
    MouseHandler.prototype.beginStorePermissions = function () {
        this.permissionsProvider.beginStorePermissions();
    };
    MouseHandler.prototype.endStorePermissions = function () {
        this.permissionsProvider.endStorePermissions();
    };
    MouseHandler.prototype.isStoredPermissionsGranted = function () {
        return this.permissionsProvider.isStoredPermissionsGranted();
    };
    MouseHandler.prototype.lockPermissions = function () {
        this.permissionsProvider.lockPermissions();
    };
    MouseHandler.prototype.unlockPermissions = function () {
        this.permissionsProvider.unlockPermissions();
    };
    MouseHandler.prototype.canPerformChangeConnection = function (connector, operationParams) {
        var allowed = true;
        if (connector)
            allowed = this.permissionsProvider.canChangeConnection(connector, operationParams.item, operationParams.oldItem, operationParams.position, operationParams.connectionPointIndex);
        else if (operationParams.item)
            allowed = this.permissionsProvider.canChangeConnection(undefined, operationParams.item, operationParams.oldItem, operationParams.position, operationParams.connectionPointIndex);
        return allowed;
    };
    MouseHandler.prototype.canPerformChangeConnectionOnUpdateUI = function (connector, operationParams) {
        this.permissionsProvider.beginUpdateUI();
        var allowed = this.canPerformChangeConnection(connector, operationParams);
        this.permissionsProvider.endUpdateUI();
        return allowed;
    };
    MouseHandler.prototype.canFinishTextEditing = function () {
        return this.eventManager.canFinishTextEditing();
    };
    MouseHandler.prototype.restartState = function () {
        if (this.state && !this.finishStateLock) {
            this.finishStateLock++;
            this.state.finish();
            this.finishStateLock--;
        }
        this.state.start();
    };
    MouseHandler.prototype.switchToDefaultState = function () {
        this.switchState(this.defaultState);
    };
    MouseHandler.prototype.switchState = function (state) {
        this.newState = state;
        if (this.state && !this.finishStateLock) {
            this.finishStateLock++;
            this.state.finish();
            this.finishStateLock--;
        }
        if (this.newState) {
            this.state = this.newState;
            this.state.start();
            this.newState = undefined;
        }
    };
    MouseHandler.prototype.addInteractingItem = function (item, operation) {
        this.permissionsProvider.addInteractingItem(item, operation);
    };
    MouseHandler.prototype.clearInteractingItems = function () {
        this.permissionsProvider.clearInteractingItems();
    };
    MouseHandler.prototype.notifyReadOnlyChanged = function (readOnly) {
        this.readOnly = readOnly;
        this.initializeDefaultState();
    };
    MouseHandler.prototype.notifySelectionRectShow = function (rect) { };
    MouseHandler.prototype.notifySelectionRectHide = function () { };
    MouseHandler.prototype.notifyResizeInfoShow = function (point, text) { };
    MouseHandler.prototype.notifyResizeInfoHide = function () { };
    MouseHandler.prototype.notifyConnectionPointsShow = function (key, points, activePointIndex, outsideRectangle) {
        this.state.onConnectionPointsShow(key, points);
    };
    MouseHandler.prototype.notifyConnectionPointsHide = function () { };
    MouseHandler.prototype.notifyConnectionTargetShow = function (key, info) {
        this.state.onConnectionTargetShow(key, info);
    };
    MouseHandler.prototype.notifyConnectionTargetHide = function () { };
    MouseHandler.prototype.notifyContainerTargetShow = function (key, info) { };
    MouseHandler.prototype.notifyContainerTargetHide = function () { };
    MouseHandler.prototype.notifyExtensionLinesShow = function (lines) { };
    MouseHandler.prototype.notifyExtensionLinesHide = function () { };
    return MouseHandler;
}());
exports.MouseHandler = MouseHandler;


/***/ }),
/* 305 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.MouseHandlerMoveConnectorPointState = void 0;
var point_1 = __webpack_require__(0);
var MouseHandlerMoveConnectorPointStateBase_1 = __webpack_require__(148);
var Connector_1 = __webpack_require__(6);
var ModelUtils_1 = __webpack_require__(4);
var ConnectorProperties_1 = __webpack_require__(32);
var MouseHandlerMoveConnectorPointState = (function (_super) {
    __extends(MouseHandlerMoveConnectorPointState, _super);
    function MouseHandlerMoveConnectorPointState() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    MouseHandlerMoveConnectorPointState.prototype.onMouseDown = function (evt) {
        this.connector = this.model.findConnector(evt.source.key);
        this.pointIndex = parseInt(evt.source.value);
        if (this.pointIndex === 0)
            this.pointPosition = Connector_1.ConnectorPosition.Begin;
        else if (this.pointIndex === this.connector.points.length - 1)
            this.pointPosition = Connector_1.ConnectorPosition.End;
        this.handler.addInteractingItem(this.connector);
        _super.prototype.onMouseDown.call(this, evt);
    };
    MouseHandlerMoveConnectorPointState.prototype.onApplyChanges = function (evt) {
        if (this.connector.properties.lineOption !== ConnectorProperties_1.ConnectorLineOption.Orthogonal ||
            this.pointIndex === 0 || this.pointIndex === this.connector.points.length - 1)
            _super.prototype.onApplyChanges.call(this, evt);
    };
    MouseHandlerMoveConnectorPointState.prototype.onFinishWithChanges = function () {
        _super.prototype.onFinishWithChanges.call(this);
        ModelUtils_1.ModelUtils.deleteConnectorUnnecessaryPoints(this.history, this.connector);
        this.handler.tryUpdateModelSize();
    };
    MouseHandlerMoveConnectorPointState.prototype.getSnappedPoint = function (evt, point) {
        var points = this.connector.points;
        var index = this.pointIndex;
        if (0 < index && index < points.length - 1) {
            var tg = (points[index + 1].y - points[index - 1].y) / (points[index + 1].x - points[index - 1].x);
            var x = point.x;
            var y = points[index + 1].y - (points[index + 1].x - x) * tg;
            return this.handler.getSnappedPointOnDragPoint(evt, point, new point_1.Point(x, y));
        }
        return this.handler.getSnappedPointOnDragPoint(evt, point);
    };
    return MouseHandlerMoveConnectorPointState;
}(MouseHandlerMoveConnectorPointStateBase_1.MouseHandlerMoveConnectorPointStateBase));
exports.MouseHandlerMoveConnectorPointState = MouseHandlerMoveConnectorPointState;


/***/ }),
/* 306 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.MouseHandlerResizeShapeState = void 0;
var size_1 = __webpack_require__(2);
var point_1 = __webpack_require__(0);
var Event_1 = __webpack_require__(11);
var MouseHandlerDraggingState_1 = __webpack_require__(34);
var ModelUtils_1 = __webpack_require__(4);
var ShapeDescription_1 = __webpack_require__(7);
var ModelOperationSettings_1 = __webpack_require__(16);
var MouseHandlerResizeShapeState = (function (_super) {
    __extends(MouseHandlerResizeShapeState, _super);
    function MouseHandlerResizeShapeState(handler, history, model, selection, visualizerManager, settings) {
        var _this = _super.call(this, handler, history) || this;
        _this.model = model;
        _this.selection = selection;
        _this.visualizerManager = visualizerManager;
        _this.settings = settings;
        _this.startScrollLeft = 0;
        _this.startScrollTop = 0;
        _this.rotation = 0;
        return _this;
    }
    MouseHandlerResizeShapeState.prototype.finish = function () {
        this.visualizerManager.resetResizeInfo();
        this.visualizerManager.resetExtensionLines();
        _super.prototype.finish.call(this);
    };
    MouseHandlerResizeShapeState.prototype.onMouseDown = function (evt) {
        var _this = this;
        var source = parseInt(evt.source.value);
        this.resizeEventSource = source;
        this.startPoint = evt.modelPoint;
        this.lockH = source === Event_1.ResizeEventSource.ResizeBox_S || source === Event_1.ResizeEventSource.ResizeBox_N;
        this.lockV = source === Event_1.ResizeEventSource.ResizeBox_E || source === Event_1.ResizeEventSource.ResizeBox_W;
        this.sideH = source === Event_1.ResizeEventSource.ResizeBox_E || source === Event_1.ResizeEventSource.ResizeBox_NE || source === Event_1.ResizeEventSource.ResizeBox_SE;
        this.sideV = source === Event_1.ResizeEventSource.ResizeBox_SE || source === Event_1.ResizeEventSource.ResizeBox_S || source === Event_1.ResizeEventSource.ResizeBox_SW;
        this.shapes = this.selection.getSelectedShapes();
        if (this.shapes.length === 0) {
            this.handler.switchToDefaultState();
            return;
        }
        this.shapes.forEach(function (shape) {
            _this.handler.addInteractingItem(shape, ModelOperationSettings_1.DiagramModelOperation.ResizeShape);
            _this.handler.addInteractingItem(shape, ModelOperationSettings_1.DiagramModelOperation.MoveShape);
        });
        this.connectors = this.selection.getSelectedConnectors();
        this.startRectangle = ModelUtils_1.ModelUtils.createRectangle(this.shapes);
        this.startShapeSizes = this.shapes.map(function (shape) { return shape.size.clone(); });
        this.startShapePositions = this.shapes.map(function (shape) { return shape.position.clone(); });
        this.startConnectorPoints = this.connectors.map(function (c) { return c.points.map(function (p) { return p.clone(); }); });
        _super.prototype.onMouseDown.call(this, evt);
    };
    MouseHandlerResizeShapeState.prototype.onMouseMove = function (evt) {
        _super.prototype.onMouseMove.call(this, evt);
        var shapes = this.selection.getSelectedShapes();
        this.visualizerManager.setExtensionLines(shapes);
    };
    MouseHandlerResizeShapeState.prototype.onApplyChanges = function (evt) {
        var _this = this;
        var rectangle = ModelUtils_1.ModelUtils.createRectangle(this.shapes);
        var minWidth = this.shapes.length === 1 ? this.shapes[0].getMinWidth(this.settings.shapeMinWidth) : ShapeDescription_1.ShapeMinDimension;
        var minHeight = this.shapes.length === 1 ? this.shapes[0].getMinHeight(this.settings.shapeMinHeight) : ShapeDescription_1.ShapeMinDimension;
        var maxWidth = this.shapes.length === 1 ? this.shapes[0].getMaxWidth(this.settings.shapeMaxWidth) : undefined;
        var maxHeight = this.shapes.length === 1 ? this.shapes[0].getMaxHeight(this.settings.shapeMaxHeight) : undefined;
        var size = this.getSize(evt, rectangle.createPosition(), this.startRectangle.createSize(), minWidth, minHeight, maxWidth, maxHeight, this.handler.lockAspectRatioOnShapeResize(evt));
        var pos = this.getPosition(evt, size, this.startRectangle.createSize(), this.startRectangle.createPosition());
        var ratioX = size.width / this.startRectangle.width;
        var ratioY = size.height / this.startRectangle.height;
        this.shapes.forEach(function (shape, index) {
            var shapeWidth = _this.startShapeSizes[index].width * (shape.allowResizeHorizontally ? ratioX : 1);
            shapeWidth = _this.getNormalizedSize(shapeWidth, shape.getMinWidth(_this.settings.shapeMinWidth), shape.getMaxWidth(_this.settings.shapeMaxWidth));
            var shapeHeight = _this.startShapeSizes[index].height * (shape.allowResizeVertically ? ratioY : 1);
            shapeHeight = _this.getNormalizedSize(shapeHeight, shape.getMinHeight(_this.settings.shapeMinHeight), shape.getMaxHeight(_this.settings.shapeMaxHeight));
            var shapeLeft = shape.allowResizeHorizontally ? (pos.x + (_this.startShapePositions[index].x - _this.startRectangle.x) * ratioX) : _this.startShapePositions[index].x;
            var shapeTop = shape.allowResizeVertically ? (pos.y + (_this.startShapePositions[index].y - _this.startRectangle.y) * ratioY) : _this.startShapePositions[index].y;
            ModelUtils_1.ModelUtils.setShapeSize(_this.history, _this.model, shape, new point_1.Point(shapeLeft, shapeTop), new size_1.Size(shapeWidth, shapeHeight));
        });
        this.connectors.forEach(function (connector, index) {
            var startPtIndex = connector.beginItem ? 1 : 0;
            var endPtIndex = connector.endItem ? (connector.points.length - 2) : (connector.points.length - 1);
            for (var i = startPtIndex; i <= endPtIndex; i++) {
                var connectorPtPos = new point_1.Point(pos.x + (_this.startConnectorPoints[index][i].x - _this.startRectangle.x) * ratioX, pos.y + (_this.startConnectorPoints[index][i].y - _this.startRectangle.y) * ratioY);
                ModelUtils_1.ModelUtils.moveConnectorPoint(_this.history, connector, i, connectorPtPos);
            }
        });
        var shapes = this.selection.getSelectedShapes(false, true);
        shapes.forEach(function (shape) {
            ModelUtils_1.ModelUtils.updateShapeAttachedConnectors(_this.history, _this.model, shape);
        });
        this.tryUpdateModelSize();
        this.visualizerManager.setResizeInfo(this.shapes);
    };
    MouseHandlerResizeShapeState.prototype.tryUpdateModelSize = function () {
        var _this = this;
        this.handler.tryUpdateModelSize(function (offsetLeft, offsetTop) {
            _this.startShapePositions.forEach(function (pt) {
                pt.x += offsetLeft;
                pt.y += offsetTop;
            });
            _this.startConnectorPoints.forEach(function (connector) {
                connector.forEach(function (pt) {
                    pt.x += offsetLeft;
                    pt.y += offsetTop;
                });
            });
            _this.startRectangle.x += offsetLeft;
            _this.startRectangle.y += offsetTop;
            _this.startPoint.x += offsetLeft;
            _this.startPoint.y += offsetTop;
        });
    };
    MouseHandlerResizeShapeState.prototype.getDraggingElementKeys = function () {
        return this.shapes.map(function (shape) { return shape.key; });
    };
    MouseHandlerResizeShapeState.prototype.getNormalizedSize = function (value, minValue, maxValue) {
        if (minValue !== undefined)
            value = Math.max(value, minValue);
        if (maxValue !== undefined)
            value = Math.min(value, maxValue);
        return value;
    };
    MouseHandlerResizeShapeState.prototype.getSize = function (evt, position, startSize, minWidth, minHeight, maxWidth, maxHeight, lockAspectRatio) {
        var absDeltaX = evt.modelPoint.x - (this.startScrollLeft - evt.scrollX) - this.startPoint.x;
        var absDeltaY = evt.modelPoint.y - (this.startScrollTop - evt.scrollY) - this.startPoint.y;
        var deltaX = absDeltaX * Math.cos(this.rotation) - (-absDeltaY) * Math.sin(this.rotation);
        var deltaY = -(absDeltaX * Math.sin(this.rotation) + (-absDeltaY) * Math.cos(this.rotation));
        var newWidth;
        var newHeight;
        deltaY = !this.sideV && deltaY > 0 ? Math.min(startSize.height + 1, deltaY) : deltaY;
        deltaX = !this.sideH && deltaX > 0 ? Math.min(startSize.width + 1, deltaX) : deltaX;
        if (!this.lockH && !this.lockV && lockAspectRatio)
            if (Math.abs(deltaX) > Math.abs(deltaY)) {
                newWidth = this.getNormalizedSize(this.sideH ? (startSize.width + deltaX) : (startSize.width - deltaX), minWidth, maxWidth);
                newHeight = startSize.height * (newWidth / startSize.width);
            }
            else {
                newHeight = this.getNormalizedSize(this.sideV ? (startSize.height + deltaY) : (startSize.height - deltaY), minHeight, maxHeight);
                newWidth = startSize.width * (newHeight / startSize.height);
            }
        else {
            deltaX = this.lockH ? 0 : deltaX;
            deltaY = this.lockV ? 0 : deltaY;
            newWidth = this.getNormalizedSize(this.sideH ? (startSize.width + deltaX) : (startSize.width - deltaX), minWidth, maxWidth);
            newHeight = this.getNormalizedSize(this.sideV ? (startSize.height + deltaY) : (startSize.height - deltaY), minHeight, maxHeight);
        }
        if (!this.lockH)
            newWidth = this.getSnappedPosition(evt, position.x + newWidth, true) - position.x;
        if (!this.lockV)
            newHeight = this.getSnappedPosition(evt, position.y + newHeight, false) - position.y;
        return new size_1.Size(newWidth, newHeight);
    };
    MouseHandlerResizeShapeState.prototype.getPosition = function (evt, size, startSize, startPosition) {
        var x = startPosition.x;
        var y = startPosition.y;
        if (this.resizeEventSource === Event_1.ResizeEventSource.ResizeBox_N ||
            this.resizeEventSource === Event_1.ResizeEventSource.ResizeBox_NE ||
            this.resizeEventSource === Event_1.ResizeEventSource.ResizeBox_NW) {
            y += startSize.height - size.height;
            var snappedY = this.getSnappedPosition(evt, y, false);
            size.height += y - snappedY;
            y = snappedY;
        }
        if (this.resizeEventSource === Event_1.ResizeEventSource.ResizeBox_W ||
            this.resizeEventSource === Event_1.ResizeEventSource.ResizeBox_NW ||
            this.resizeEventSource === Event_1.ResizeEventSource.ResizeBox_SW) {
            x += startSize.width - size.width;
            var snappedX = this.getSnappedPosition(evt, x, true);
            size.width += x - snappedX;
            x = snappedX;
        }
        return new point_1.Point(x, y);
    };
    MouseHandlerResizeShapeState.prototype.getSnappedPosition = function (evt, pos, isHorizontal) {
        return this.handler.getSnappedPositionOnResizeShape(evt, pos, isHorizontal);
    };
    return MouseHandlerResizeShapeState;
}(MouseHandlerDraggingState_1.MouseHandlerDraggingState));
exports.MouseHandlerResizeShapeState = MouseHandlerResizeShapeState;


/***/ }),
/* 307 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.MouseHandlerMoveConnectorSideState = void 0;
var MouseHandlerDraggingState_1 = __webpack_require__(34);
var ModelUtils_1 = __webpack_require__(4);
var MouseHandlerMoveConnectorSideState = (function (_super) {
    __extends(MouseHandlerMoveConnectorSideState, _super);
    function MouseHandlerMoveConnectorSideState(handler, history, model) {
        var _this = _super.call(this, handler, history) || this;
        _this.model = model;
        return _this;
    }
    MouseHandlerMoveConnectorSideState.prototype.onMouseDown = function (evt) {
        this.startPoint = evt.modelPoint;
        this.connectorKey = evt.source.key;
        this.pointIndex = parseInt(evt.source.value) + 1;
        _super.prototype.onMouseDown.call(this, evt);
    };
    MouseHandlerMoveConnectorSideState.prototype.onApplyChanges = function (evt) {
        var point = this.getSnappedPoint(evt, evt.modelPoint);
        var connector = this.model.findConnector(this.connectorKey);
        if (!this.pointCreated) {
            this.handler.addInteractingItem(connector);
            ModelUtils_1.ModelUtils.addConnectorPoint(this.history, this.connectorKey, this.pointIndex, point.clone());
            this.pointCreated = true;
        }
        else
            ModelUtils_1.ModelUtils.moveConnectorPoint(this.history, connector, this.pointIndex, point);
        this.handler.tryUpdateModelSize();
    };
    MouseHandlerMoveConnectorSideState.prototype.onFinishWithChanges = function () {
        ModelUtils_1.ModelUtils.deleteConnectorUnnecessaryPoints(this.history, this.model.findConnector(this.connectorKey));
        this.handler.tryUpdateModelSize();
    };
    MouseHandlerMoveConnectorSideState.prototype.getDraggingElementKeys = function () {
        return [this.connectorKey];
    };
    return MouseHandlerMoveConnectorSideState;
}(MouseHandlerDraggingState_1.MouseHandlerDraggingState));
exports.MouseHandlerMoveConnectorSideState = MouseHandlerMoveConnectorSideState;


/***/ }),
/* 308 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.MouseHandlerDragParameterPointState = void 0;
var MouseHandlerDraggingState_1 = __webpack_require__(34);
var ChangeShapeParametersHistoryItem_1 = __webpack_require__(112);
var MouseHandlerDragParameterPointState = (function (_super) {
    __extends(MouseHandlerDragParameterPointState, _super);
    function MouseHandlerDragParameterPointState(handler, history, model) {
        var _this = _super.call(this, handler, history) || this;
        _this.model = model;
        _this.startScrollLeft = 0;
        _this.startScrollTop = 0;
        return _this;
    }
    MouseHandlerDragParameterPointState.prototype.onMouseDown = function (evt) {
        this.startPoint = evt.modelPoint;
        this.shape = this.model.findShape(evt.source.key);
        this.parameterPointKey = evt.source.value;
        this.startParameters = this.shape.parameters.clone();
        _super.prototype.onMouseDown.call(this, evt);
    };
    MouseHandlerDragParameterPointState.prototype.onApplyChanges = function (evt) {
        var offset = this.handler.getSnappedOffsetOnDragPoint(evt, this.startPoint);
        var parameters = this.startParameters.clone();
        this.shape.description.modifyParameters(this.shape, parameters, offset.x, offset.y);
        this.history.addAndRedo(new ChangeShapeParametersHistoryItem_1.ChangeShapeParametersHistoryItem(this.shape.key, parameters));
    };
    MouseHandlerDragParameterPointState.prototype.getDraggingElementKeys = function () {
        return [this.shape.key];
    };
    return MouseHandlerDragParameterPointState;
}(MouseHandlerDraggingState_1.MouseHandlerDraggingState));
exports.MouseHandlerDragParameterPointState = MouseHandlerDragParameterPointState;


/***/ }),
/* 309 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.MouseHandlerCreateConnectorState = void 0;
var Connector_1 = __webpack_require__(6);
var AddConnectionHistoryItem_1 = __webpack_require__(48);
var AddConnectorHistoryItem_1 = __webpack_require__(66);
var DiagramItem_1 = __webpack_require__(9);
var MouseHandlerMoveConnectorPointStateBase_1 = __webpack_require__(148);
var SetSelectionHistoryItem_1 = __webpack_require__(68);
var AddShapeHistoryItem_1 = __webpack_require__(53);
var ModelUtils_1 = __webpack_require__(4);
var DeleteConnectionHistoryItem_1 = __webpack_require__(67);
var DeleteConnectorHistoryItem_1 = __webpack_require__(113);
var MouseHandlerCreateConnectorState = (function (_super) {
    __extends(MouseHandlerCreateConnectorState, _super);
    function MouseHandlerCreateConnectorState(handler, history, model, visualizerManager, shapeDescriptionManager, selection, connectionPointIndex) {
        var _this = _super.call(this, handler, history, model, visualizerManager) || this;
        _this.shapeDescriptionManager = shapeDescriptionManager;
        _this.selection = selection;
        _this.connectionPointIndex = connectionPointIndex;
        return _this;
    }
    MouseHandlerCreateConnectorState.prototype.onMouseDown = function (evt) {
        if (this.connectionPointIndex === undefined)
            this.connectionPointIndex = parseInt(evt.source.value);
        this.connectedItem = this.model.findItem(evt.source.key);
        this.pointIndex = 1;
        this.pointPosition = Connector_1.ConnectorPosition.End;
        _super.prototype.onMouseDown.call(this, evt);
    };
    MouseHandlerCreateConnectorState.prototype.onMouseUp = function (evt) {
        if (this.connector && !this.connector.endItem)
            this.createNewShapeAtConnectorEnd(evt);
        _super.prototype.onMouseUp.call(this, evt);
    };
    MouseHandlerCreateConnectorState.prototype.onApplyChanges = function (evt) {
        var point = this.getSnappedPoint(evt, evt.modelPoint);
        if (!this.connector) {
            var historyItem = new AddConnectorHistoryItem_1.AddConnectorHistoryItem([this.connectedItem.getConnectionPointPosition(this.connectionPointIndex, point), point]);
            this.history.addAndRedo(historyItem);
            this.connector = this.model.findConnector(historyItem.connectorKey);
            this.handler.addInteractingItem(this.connector);
            this.history.addAndRedo(new AddConnectionHistoryItem_1.AddConnectionHistoryItem(this.connector, this.connectedItem, this.connectionPointIndex, Connector_1.ConnectorPosition.Begin));
            ModelUtils_1.ModelUtils.updateNewConnectorProperties(this.history, this.selection, this.connector.key);
        }
        else
            _super.prototype.onApplyChanges.call(this, evt);
    };
    MouseHandlerCreateConnectorState.prototype.checkStoredPermissionsOnFinish = function () {
        if (this.connector && this.connector.endItem)
            _super.prototype.checkStoredPermissionsOnFinish.call(this);
    };
    MouseHandlerCreateConnectorState.prototype.onFinishWithChanges = function () {
        _super.prototype.onFinishWithChanges.call(this);
        this.history.addAndRedo(new SetSelectionHistoryItem_1.SetSelectionHistoryItem(this.selection, [this.connector.key]));
    };
    MouseHandlerCreateConnectorState.prototype.createNewShapeAtConnectorEnd = function (evt) {
        var _this = this;
        var beginShape = this.connector && this.connector.beginItem;
        if (!beginShape)
            return;
        if (this.connector && !this.handler.canPerformChangeConnection(this.connector, { position: Connector_1.ConnectorPosition.End, connectionPointIndex: -1 })) {
            this.cancelChanges();
            return;
        }
        var side = this.getNewShapeSide(this.connector);
        var point = this.getSnappedPoint(evt, evt.modelPoint);
        var category = this.shapeDescriptionManager.getCategoryByDescription(beginShape.description);
        var getPositionToInsertShapeTo = function (shape) {
            var clonedShape = shape.clone();
            clonedShape.position = point.clone();
            var position = _this.getNewShapePosition(clonedShape, side);
            return _this.handler.getSnappedPointOnDragPoint(evt, position);
        };
        this.handler.showContextToolbox(point, getPositionToInsertShapeTo, side, category, function (shapeType) {
            if (!shapeType)
                return;
            _this.handler.beginStorePermissions();
            _this.history.beginTransaction();
            var historyItem = new AddShapeHistoryItem_1.AddShapeHistoryItem(_this.shapeDescriptionManager.get(shapeType), point);
            _this.history.addAndRedo(historyItem);
            var shape = _this.model.findShape(historyItem.shapeKey);
            var container = _this.targetItem && _this.model.findNearestContainer(_this.targetItem.key);
            if (container)
                ModelUtils_1.ModelUtils.insertToContainer(_this.history, _this.model, shape, container);
            var newPosition = _this.getNewShapePosition(shape, side);
            ModelUtils_1.ModelUtils.setShapePosition(_this.history, _this.model, shape, _this.getSnappedPoint(evt, newPosition));
            ModelUtils_1.ModelUtils.updateNewShapeProperties(_this.history, _this.selection, shape.key);
            _this.history.addAndRedo(new AddConnectionHistoryItem_1.AddConnectionHistoryItem(_this.connector, shape, shape.getConnectionPointIndexForSide(side), Connector_1.ConnectorPosition.End));
            if (container)
                ModelUtils_1.ModelUtils.updateConnectorContainer(_this.history, _this.model, _this.connector);
            ModelUtils_1.ModelUtils.updateShapeAttachedConnectors(_this.history, _this.model, shape);
            if (!_this.handler.isStoredPermissionsGranted()) {
                _this.handler.lockPermissions();
                _this.history.undoTransaction();
                _this.handler.unlockPermissions();
                _this.checkNewConnectorPermissions();
            }
            else {
                _this.handler.tryUpdateModelSize();
                _this.history.addAndRedo(new SetSelectionHistoryItem_1.SetSelectionHistoryItem(_this.selection, [shape.key]));
            }
            _this.history.endTransaction();
            _this.handler.endStorePermissions();
            _this.handler.hideContextToolbox(true);
        }, function () {
            _this.checkNewConnectorPermissions();
        });
    };
    MouseHandlerCreateConnectorState.prototype.checkNewConnectorPermissions = function () {
        if (this.connector && !this.handler.canPerformChangeConnection(this.connector, { position: Connector_1.ConnectorPosition.End, connectionPointIndex: -1 })) {
            this.handler.lockPermissions();
            this.history.beginTransaction();
            this.history.addAndRedo(new SetSelectionHistoryItem_1.SetSelectionHistoryItem(this.selection, []));
            if (this.connector.beginItem)
                this.history.addAndRedo(new DeleteConnectionHistoryItem_1.DeleteConnectionHistoryItem(this.connector, Connector_1.ConnectorPosition.Begin));
            if (this.connector.endItem)
                this.history.addAndRedo(new DeleteConnectionHistoryItem_1.DeleteConnectionHistoryItem(this.connector, Connector_1.ConnectorPosition.End));
            this.history.addAndRedo(new DeleteConnectorHistoryItem_1.DeleteConnectorHistoryItem(this.connector.key));
            this.history.endTransaction();
            this.handler.unlockPermissions();
        }
    };
    MouseHandlerCreateConnectorState.prototype.getNewShapePosition = function (shape, side) {
        switch (side) {
            case DiagramItem_1.ConnectionPointSide.North:
                return shape.position.clone().offset(-shape.size.width / 2, 0);
            case DiagramItem_1.ConnectionPointSide.South:
                return shape.position.clone().offset(-shape.size.width / 2, -shape.size.height);
            case DiagramItem_1.ConnectionPointSide.East:
                return shape.position.clone().offset(-shape.size.width, -shape.size.height / 2);
            case DiagramItem_1.ConnectionPointSide.West:
                return shape.position.clone().offset(0, -shape.size.height / 2);
        }
    };
    MouseHandlerCreateConnectorState.prototype.getNewShapeSide = function (connector) {
        var renderPoints = connector.getRenderPoints();
        return MouseHandlerCreateConnectorState.getNewShapeSideByConnectorPoints(renderPoints[renderPoints.length - 1], renderPoints[renderPoints.length - 2]);
    };
    MouseHandlerCreateConnectorState.prototype.getSourceItem = function () {
        return this.connectedItem;
    };
    MouseHandlerCreateConnectorState.getNewShapeSideByConnectorPoints = function (point, directionPoint) {
        if (point.x === directionPoint.x)
            if (point.y > directionPoint.y)
                return DiagramItem_1.ConnectionPointSide.North;
            else
                return DiagramItem_1.ConnectionPointSide.South;
        else if (point.x > directionPoint.x)
            if (point.y === directionPoint.y)
                return DiagramItem_1.ConnectionPointSide.West;
            else if (point.y > directionPoint.y)
                if (Math.abs(point.x - directionPoint.x) > Math.abs(point.y - directionPoint.y))
                    return DiagramItem_1.ConnectionPointSide.West;
                else
                    return DiagramItem_1.ConnectionPointSide.North;
            else if (Math.abs(point.x - directionPoint.x) > Math.abs(point.y - directionPoint.y))
                return DiagramItem_1.ConnectionPointSide.West;
            else
                return DiagramItem_1.ConnectionPointSide.South;
        else if (point.y === directionPoint.y)
            return DiagramItem_1.ConnectionPointSide.East;
        else if (point.y > directionPoint.y)
            if (Math.abs(point.x - directionPoint.x) > Math.abs(point.y - directionPoint.y))
                return DiagramItem_1.ConnectionPointSide.East;
            else
                return DiagramItem_1.ConnectionPointSide.North;
        else if (Math.abs(point.x - directionPoint.x) > Math.abs(point.y - directionPoint.y))
            return DiagramItem_1.ConnectionPointSide.East;
        else
            return DiagramItem_1.ConnectionPointSide.South;
    };
    return MouseHandlerCreateConnectorState;
}(MouseHandlerMoveConnectorPointStateBase_1.MouseHandlerMoveConnectorPointStateBase));
exports.MouseHandlerCreateConnectorState = MouseHandlerCreateConnectorState;


/***/ }),
/* 310 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.MouseHandlerMoveConnectorOrthogonalSideState = void 0;
var point_1 = __webpack_require__(0);
var Connector_1 = __webpack_require__(6);
var DiagramItem_1 = __webpack_require__(9);
var ModelUtils_1 = __webpack_require__(4);
var MouseHandlerDraggingState_1 = __webpack_require__(34);
var MouseHandlerMoveConnectorOrthogonalSideState = (function (_super) {
    __extends(MouseHandlerMoveConnectorOrthogonalSideState, _super);
    function MouseHandlerMoveConnectorOrthogonalSideState(handler, history, model) {
        var _this = _super.call(this, handler, history) || this;
        _this.model = model;
        return _this;
    }
    MouseHandlerMoveConnectorOrthogonalSideState.prototype.onMouseDown = function (evt) {
        this.startPoint = evt.modelPoint;
        this.connector = this.model.findConnector(evt.source.key);
        this.handler.addInteractingItem(this.connector);
        var renderPointIndexes = evt.source.value.split("_");
        var renderPointIndex1 = parseInt(renderPointIndexes[0]);
        var renderPointIndex2 = parseInt(renderPointIndexes[1]);
        var points = this.connector.getRenderPoints(true);
        this.renderPoint1 = points[renderPointIndex1].clone();
        this.renderPoint2 = points[renderPointIndex2].clone();
        this.isVerticalOrientation = this.renderPoint1.x === this.renderPoint2.x;
        if (this.renderPoint1.pointIndex !== -1) {
            this.pointIndex1 = this.renderPoint1.pointIndex;
            if (this.pointIndex1 === 0) {
                this.pointIndex1++;
                this.correctEdgePoint(this.renderPoint1, this.renderPoint2, this.connector.beginItem, this.connector.beginConnectionPointIndex);
            }
            else
                this.point1 = this.connector.points[this.pointIndex1].clone();
        }
        else
            this.pointIndex1 = this.findPointIndex(points, renderPointIndex1, false) + 1;
        if (this.renderPoint2.pointIndex !== -1) {
            this.pointIndex2 = this.renderPoint2.pointIndex;
            if (this.pointIndex2 === this.connector.points.length - 1)
                this.correctEdgePoint(this.renderPoint2, this.renderPoint1, this.connector.endItem, this.connector.endConnectionPointIndex);
            else
                this.point2 = this.connector.points[this.pointIndex2].clone();
        }
        else
            this.pointIndex2 = this.findPointIndex(points, renderPointIndex2, true);
        _super.prototype.onMouseDown.call(this, evt);
    };
    MouseHandlerMoveConnectorOrthogonalSideState.prototype.onApplyChanges = function (evt) {
        var _this = this;
        if (!this.pointCreated) {
            var createdPoint1 = void 0;
            var createdPoint2 = void 0;
            if (this.point1 === undefined) {
                this.point1 = new point_1.Point(this.renderPoint1.x, this.renderPoint1.y);
                ModelUtils_1.ModelUtils.addConnectorPoint(this.history, this.connector.key, this.pointIndex1, this.point1.clone());
                createdPoint1 = this.point1.clone();
                this.pointIndex2++;
            }
            if (this.point2 === undefined) {
                this.point2 = new point_1.Point(this.renderPoint2.x, this.renderPoint2.y);
                ModelUtils_1.ModelUtils.addConnectorPoint(this.history, this.connector.key, this.pointIndex2, this.point2.clone());
                createdPoint2 = this.point2.clone();
            }
            var excludePoints = [];
            if (createdPoint1)
                excludePoints.push(createdPoint1);
            if (createdPoint2)
                excludePoints.push(createdPoint2);
            var unnecessaryPoints = this.createUnnecessaryPoints(this.connector, excludePoints);
            Object.keys(unnecessaryPoints).forEach(function (key) {
                var pointIndex = parseInt(key);
                if (pointIndex < _this.pointIndex1)
                    _this.pointIndex1--;
                if (pointIndex < _this.pointIndex2)
                    _this.pointIndex2--;
            });
            this.pointCreated = true;
        }
        var point = this.getSnappedPoint(evt, evt.modelPoint);
        if (this.isVerticalOrientation) {
            this.point1.x = point.x;
            this.point2.x = point.x;
        }
        else {
            this.point1.y = point.y;
            this.point2.y = point.y;
        }
        ModelUtils_1.ModelUtils.moveConnectorRightAnglePoints(this.history, this.connector, this.point1.clone(), this.pointIndex1, this.point2.clone(), this.pointIndex2);
        this.handler.tryUpdateModelSize();
    };
    MouseHandlerMoveConnectorOrthogonalSideState.prototype.createUnnecessaryPoints = function (connector, excludePoints) {
        var oldRenderPoints = connector.getRenderPoints(true).map(function (p) { return p.clone(); });
        var unnecessaryRenderPoints = ModelUtils_1.ModelUtils.createUnnecessaryRenderPoints(oldRenderPoints.filter(function (p) { return !p.skipped; }).map(function (p) { return p.clone(); }), connector.skippedRenderPoints, function (removedPoint) { return ModelUtils_1.ModelUtils.findFirstPointIndex(oldRenderPoints, function (p) { return p.equals(removedPoint); }); }, function (p) { return !excludePoints.some(function (ep) { return ep.equals(p); }); });
        var result = {};
        if (Object.keys(unnecessaryRenderPoints).length) {
            var points = connector.points.map(function (p) { return p.clone(); });
            var lastPointIndex_1 = points.length - 1;
            points.forEach(function (p, index) {
                if (index !== 0 && index !== lastPointIndex_1 && !ModelUtils_1.ModelUtils.isNecessaryPoint(p, index, unnecessaryRenderPoints))
                    result[index] = p;
            });
        }
        return result;
    };
    MouseHandlerMoveConnectorOrthogonalSideState.prototype.onFinishWithChanges = function () {
        ModelUtils_1.ModelUtils.deleteConnectorUnnecessaryPoints(this.history, this.connector);
        this.handler.tryUpdateModelSize();
    };
    MouseHandlerMoveConnectorOrthogonalSideState.prototype.findPointIndex = function (points, index, direction) {
        var point;
        while (point = points[index]) {
            if (point.pointIndex !== -1)
                return point.pointIndex;
            index += direction ? 1 : -1;
        }
    };
    MouseHandlerMoveConnectorOrthogonalSideState.prototype.correctEdgePoint = function (point, directionPoint, item, connectionPointIndex) {
        var offset = 0;
        if (item) {
            var side = item.getConnectionPointSideByIndex(connectionPointIndex);
            var rect = item.rectangle;
            offset = Connector_1.Connector.minOffset;
            switch (side) {
                case DiagramItem_1.ConnectionPointSide.South:
                    offset += rect.bottom - point.y;
                    break;
                case DiagramItem_1.ConnectionPointSide.North:
                    offset += point.y - rect.y;
                    break;
                case DiagramItem_1.ConnectionPointSide.East:
                    offset += rect.right - point.x;
                    break;
                case DiagramItem_1.ConnectionPointSide.West:
                    offset += point.x - rect.x;
                    break;
            }
        }
        if (this.isVerticalOrientation)
            if (point.y > directionPoint.y)
                point.y -= Math.min(offset, point.y - directionPoint.y);
            else
                point.y += Math.min(offset, directionPoint.y - point.y);
        else if (point.x > directionPoint.x)
            point.x -= Math.min(offset, point.x - directionPoint.x);
        else
            point.x += Math.min(offset, directionPoint.x - point.x);
    };
    MouseHandlerMoveConnectorOrthogonalSideState.prototype.getDraggingElementKeys = function () {
        return [this.connector.key];
    };
    return MouseHandlerMoveConnectorOrthogonalSideState;
}(MouseHandlerDraggingState_1.MouseHandlerDraggingState));
exports.MouseHandlerMoveConnectorOrthogonalSideState = MouseHandlerMoveConnectorOrthogonalSideState;


/***/ }),
/* 311 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.MouseHandlerToolboxDraggingState = exports.MouseHandlerBeforeToolboxDraggingState = void 0;
var Event_1 = __webpack_require__(11);
var point_1 = __webpack_require__(0);
var AddShapeHistoryItem_1 = __webpack_require__(53);
var SetSelectionHistoryItem_1 = __webpack_require__(68);
var MouseHandlerDraggingState_1 = __webpack_require__(34);
var DeleteShapeHistoryItem_1 = __webpack_require__(114);
var ModelUtils_1 = __webpack_require__(4);
var MouseHandlerStateBase_1 = __webpack_require__(40);
var ModelOperationSettings_1 = __webpack_require__(16);
var NON_DOCUMENT_TIMER = 500;
var LOCK_UPDATEPAGESIZE_TIMER = 300;
var MouseHandlerBeforeToolboxDraggingState = (function (_super) {
    __extends(MouseHandlerBeforeToolboxDraggingState, _super);
    function MouseHandlerBeforeToolboxDraggingState(handler, history, model, selection, visualizerManager, shapeDescriptionManager) {
        var _this = _super.call(this, handler) || this;
        _this.history = history;
        _this.model = model;
        _this.selection = selection;
        _this.visualizerManager = visualizerManager;
        _this.shapeDescriptionManager = shapeDescriptionManager;
        _this.isModelEmpty = model.items.length === 0;
        return _this;
    }
    MouseHandlerBeforeToolboxDraggingState.prototype.cancelChanges = function () {
        this.tryRemoveTimer();
    };
    MouseHandlerBeforeToolboxDraggingState.prototype.onDragStart = function (evt) {
        this.dragging = evt;
    };
    MouseHandlerBeforeToolboxDraggingState.prototype.onDragEnd = function (evt) {
        this.cancelChanges();
        this.handler.switchToDefaultState();
    };
    MouseHandlerBeforeToolboxDraggingState.prototype.onMouseMove = function (evt) {
        var _this = this;
        if (evt.source.type > Event_1.MouseEventElementType.Background) {
            this.tryRemoveTimer();
            this.switchToDraggingState(evt, false);
        }
        else if (evt.source.type === Event_1.MouseEventElementType.Background && !this.isModelEmpty) {
            this.savedEvt = evt;
            if (this.nonPageAreaTimer === undefined)
                this.nonPageAreaTimer = setTimeout(function () { return _this.switchToDraggingState(_this.savedEvt, true); }, NON_DOCUMENT_TIMER);
        }
        else if (this.nonPageAreaTimer !== undefined)
            this.tryRemoveTimer();
    };
    MouseHandlerBeforeToolboxDraggingState.prototype.switchToDraggingState = function (evt, skipLockUpdatePageSize) {
        this.handler.switchState(new MouseHandlerToolboxDraggingState(this.handler, this.history, this.model, this.selection, this.visualizerManager, this.shapeDescriptionManager, skipLockUpdatePageSize));
        this.handler.state.onDragStart(this.dragging);
        this.handler.state.onMouseMove(evt);
    };
    MouseHandlerBeforeToolboxDraggingState.prototype.tryRemoveTimer = function () {
        if (this.nonPageAreaTimer !== undefined) {
            clearTimeout(this.nonPageAreaTimer);
            delete this.nonPageAreaTimer;
        }
    };
    MouseHandlerBeforeToolboxDraggingState.prototype.finish = function () {
        this.tryRemoveTimer();
    };
    return MouseHandlerBeforeToolboxDraggingState;
}(MouseHandlerStateBase_1.MouseHandlerCancellableState));
exports.MouseHandlerBeforeToolboxDraggingState = MouseHandlerBeforeToolboxDraggingState;
var MouseHandlerToolboxDraggingState = (function (_super) {
    __extends(MouseHandlerToolboxDraggingState, _super);
    function MouseHandlerToolboxDraggingState(handler, history, model, selection, visualizerManager, shapeDescriptionManager, skipLockUpdatePageSize) {
        var _this = _super.call(this, handler, history) || this;
        _this.model = model;
        _this.selection = selection;
        _this.visualizerManager = visualizerManager;
        _this.shapeDescriptionManager = shapeDescriptionManager;
        if (!skipLockUpdatePageSize)
            _this.updatePageSizeTimer = setTimeout(function () {
                _this.processAndRemoveUpdatePageSizeTimer();
            }, LOCK_UPDATEPAGESIZE_TIMER);
        return _this;
    }
    MouseHandlerToolboxDraggingState.prototype.cancelChanges = function () {
        this.tryRemoveUpdatePageSizeTimer();
        _super.prototype.cancelChanges.call(this);
    };
    MouseHandlerToolboxDraggingState.prototype.tryRemoveUpdatePageSizeTimer = function () {
        if (this.updatePageSizeTimer !== undefined) {
            clearTimeout(this.updatePageSizeTimer);
            delete this.updatePageSizeTimer;
        }
    };
    MouseHandlerToolboxDraggingState.prototype.processAndRemoveUpdatePageSizeTimer = function () {
        if (this.updatePageSizeTimer !== undefined) {
            this.handler.tryUpdateModelSize();
            delete this.updatePageSizeTimer;
        }
    };
    MouseHandlerToolboxDraggingState.prototype.onMouseMove = function (evt) {
        _super.prototype.onMouseMove.call(this, evt);
        var shape = this.model.findShape(this.shapeKey);
        if (shape) {
            this.visualizerManager.setExtensionLines([shape]);
            var container = ModelUtils_1.ModelUtils.findContainerByEventKey(this.model, this.selection, evt.source.key);
            if (container && this.allowInsertToContainer(evt, shape, container))
                this.visualizerManager.setContainerTarget(container, evt.source.type);
            else
                this.visualizerManager.resetContainerTarget();
        }
    };
    MouseHandlerToolboxDraggingState.prototype.getDraggingElementKeys = function () {
        return this.shapeKey === undefined ? [] : [this.shapeKey];
    };
    MouseHandlerToolboxDraggingState.prototype.onApplyChanges = function (evt) {
        var _this = this;
        if (evt.source.type === Event_1.MouseEventElementType.Undefined) {
            this.dragging.onCaptured(false);
            if (this.shapeKey !== undefined && !this.deleteHistoryItem) {
                var shape = this.model.findShape(this.shapeKey);
                ModelUtils_1.ModelUtils.detachConnectors(this.history, shape);
                ModelUtils_1.ModelUtils.removeFromContainer(this.history, this.model, shape);
                this.deleteHistoryItem = new DeleteShapeHistoryItem_1.DeleteShapeHistoryItem(this.shapeKey, true);
                this.history.addAndRedo(this.deleteHistoryItem);
            }
        }
        else {
            this.dragging.onCaptured(true);
            if (this.shapeKey === undefined) {
                this.startPoint = evt.modelPoint;
                this.shapeKey = this.insertToolboxItem(evt);
                var shape_1 = this.model.findShape(this.shapeKey);
                if (shape_1)
                    this.handler.addInteractingItem(shape_1, ModelOperationSettings_1.DiagramModelOperation.AddShape);
            }
            if (this.deleteHistoryItem) {
                this.history.undoTransactionTo(this.deleteHistoryItem);
                delete this.deleteHistoryItem;
            }
            var pos = this.getPosition(evt, this.startShapePosition);
            var shape = this.model.findShape(this.shapeKey);
            ModelUtils_1.ModelUtils.setShapePosition(this.history, this.model, shape, pos);
            ModelUtils_1.ModelUtils.updateMovingShapeConnections(this.history, shape, this.connectorsWithoutBeginItemInfo, this.connectorsWithoutEndItemInfo, function () {
                _this.visualizerManager.resetConnectionTarget();
                _this.visualizerManager.resetConnectionPoints();
            }, function (shape, connectionPointIndex) {
                _this.visualizerManager.setConnectionTarget(shape, Event_1.MouseEventElementType.Shape);
                _this.visualizerManager.setConnectionPoints(shape, Event_1.MouseEventElementType.Shape, connectionPointIndex, true);
            }, function (connector) { return _this.handler.addInteractingItem(connector); });
            ModelUtils_1.ModelUtils.updateShapeAttachedConnectors(this.history, this.model, shape);
            var container = ModelUtils_1.ModelUtils.findContainerByEventKey(this.model, this.selection, evt.source.key);
            if (shape && container && this.allowInsertToContainer(evt, shape, container))
                ModelUtils_1.ModelUtils.insertToContainer(this.history, this.model, shape, container);
            else
                ModelUtils_1.ModelUtils.removeFromContainer(this.history, this.model, shape);
            if (this.updatePageSizeTimer === undefined)
                this.handler.tryUpdateModelSize(function (offsetLeft, offsetTop) {
                    _this.connectorsWithoutBeginItemInfo.forEach(function (pi) {
                        pi.point.x += offsetLeft;
                        pi.point.y += offsetTop;
                    });
                    _this.connectorsWithoutEndItemInfo.forEach(function (pi) {
                        pi.point.x += offsetLeft;
                        pi.point.y += offsetTop;
                    });
                });
        }
    };
    MouseHandlerToolboxDraggingState.prototype.onFinishWithChanges = function () {
        if (!this.deleteHistoryItem)
            this.history.addAndRedo(new SetSelectionHistoryItem_1.SetSelectionHistoryItem(this.selection, [this.shapeKey]));
    };
    MouseHandlerToolboxDraggingState.prototype.onDragStart = function (evt) {
        this.dragging = evt;
        this.connectorsWithoutBeginItemInfo = ModelUtils_1.ModelUtils.getConnectorsWithoutBeginItemInfo(this.model);
        this.connectorsWithoutEndItemInfo = ModelUtils_1.ModelUtils.getConnectorsWithoutEndItemInfo(this.model);
    };
    MouseHandlerToolboxDraggingState.prototype.onDragEnd = function (evt) {
        if (this.shapeKey !== undefined && evt.source.type === Event_1.MouseEventElementType.Undefined)
            this.cancelChanges();
        this.handler.switchToDefaultState();
    };
    MouseHandlerToolboxDraggingState.prototype.finish = function () {
        this.visualizerManager.resetExtensionLines();
        this.visualizerManager.resetContainerTarget();
        this.visualizerManager.resetConnectionTarget();
        this.visualizerManager.resetConnectionPoints();
        this.processAndRemoveUpdatePageSizeTimer();
        this.dragging.onFinishDragging();
        _super.prototype.finish.call(this);
    };
    MouseHandlerToolboxDraggingState.prototype.insertToolboxItem = function (evt) {
        var description = this.shapeDescriptionManager.get(this.dragging.data);
        this.startShapePosition = this.getSnappedPoint(evt, new point_1.Point(evt.modelPoint.x - description.defaultSize.width / 2, evt.modelPoint.y - description.defaultSize.height / 2));
        var historyItem = new AddShapeHistoryItem_1.AddShapeHistoryItem(description, this.startShapePosition);
        this.history.addAndRedo(historyItem);
        ModelUtils_1.ModelUtils.updateNewShapeProperties(this.history, this.selection, historyItem.shapeKey);
        return historyItem.shapeKey;
    };
    MouseHandlerToolboxDraggingState.prototype.allowInsertToContainer = function (evt, item, container) {
        if (this.handler.canMultipleSelection(evt))
            return false;
        return container && container.expanded && ModelUtils_1.ModelUtils.canInsertToContainer(this.model, item, container);
    };
    MouseHandlerToolboxDraggingState.prototype.getPosition = function (evt, basePoint) {
        return this.getSnappedPoint(evt, new point_1.Point(basePoint.x + evt.modelPoint.x - this.startPoint.x, basePoint.y + evt.modelPoint.y - this.startPoint.y));
    };
    return MouseHandlerToolboxDraggingState;
}(MouseHandlerDraggingState_1.MouseHandlerDraggingState));
exports.MouseHandlerToolboxDraggingState = MouseHandlerToolboxDraggingState;


/***/ }),
/* 312 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.MouseHandlerMoveConnectorTextState = void 0;
var MouseHandlerDraggingState_1 = __webpack_require__(34);
var ChangeConnectorTextPositionHistoryItem_1 = __webpack_require__(313);
var ChangeConnectorTextHistoryItem_1 = __webpack_require__(69);
var MouseHandlerMoveConnectorTextState = (function (_super) {
    __extends(MouseHandlerMoveConnectorTextState, _super);
    function MouseHandlerMoveConnectorTextState(handler, history, model) {
        var _this = _super.call(this, handler, history) || this;
        _this.model = model;
        return _this;
    }
    MouseHandlerMoveConnectorTextState.prototype.onMouseDown = function (evt) {
        this.connector = this.model.findConnector(evt.source.key);
        this.position = parseFloat(evt.source.value);
        this.text = this.connector.getText(this.position);
        this.savedText = "";
        _super.prototype.onMouseDown.call(this, evt);
    };
    MouseHandlerMoveConnectorTextState.prototype.onApplyChanges = function (evt) {
        var newPosition = this.connector.getTextPositionByPoint(evt.modelPoint);
        if (newPosition !== this.position) {
            var text = this.connector.getText(newPosition);
            if (text !== "" && text !== this.text) {
                this.history.addAndRedo(new ChangeConnectorTextHistoryItem_1.ChangeConnectorTextHistoryItem(this.connector, newPosition, ""));
                this.savedText = text;
            }
            this.history.addAndRedo(new ChangeConnectorTextPositionHistoryItem_1.ChangeConnectorTextPositionHistoryItem(this.connector, this.position, newPosition));
            if (this.savedText !== "" && this.savedText !== text) {
                this.history.addAndRedo(new ChangeConnectorTextHistoryItem_1.ChangeConnectorTextHistoryItem(this.connector, this.position, this.savedText));
                this.savedText = "";
            }
            this.position = newPosition;
        }
    };
    MouseHandlerMoveConnectorTextState.prototype.getDraggingElementKeys = function () {
        return [this.connector.key];
    };
    return MouseHandlerMoveConnectorTextState;
}(MouseHandlerDraggingState_1.MouseHandlerDraggingState));
exports.MouseHandlerMoveConnectorTextState = MouseHandlerMoveConnectorTextState;


/***/ }),
/* 313 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.ChangeConnectorTextPositionHistoryItem = void 0;
var HistoryItem_1 = __webpack_require__(8);
var ChangeConnectorTextPositionHistoryItem = (function (_super) {
    __extends(ChangeConnectorTextPositionHistoryItem, _super);
    function ChangeConnectorTextPositionHistoryItem(connector, position, newPosition) {
        var _this = _super.call(this) || this;
        _this.connectorKey = connector.key;
        _this.position = position;
        _this.newPosition = newPosition;
        return _this;
    }
    ChangeConnectorTextPositionHistoryItem.prototype.redo = function (manipulator) {
        var connector = manipulator.model.findConnector(this.connectorKey);
        manipulator.changeConnectorTextPosition(connector, this.position, this.newPosition);
    };
    ChangeConnectorTextPositionHistoryItem.prototype.undo = function (manipulator) {
        var connector = manipulator.model.findConnector(this.connectorKey);
        manipulator.changeConnectorTextPosition(connector, this.newPosition, this.position);
    };
    return ChangeConnectorTextPositionHistoryItem;
}(HistoryItem_1.HistoryItem));
exports.ChangeConnectorTextPositionHistoryItem = ChangeConnectorTextPositionHistoryItem;


/***/ }),
/* 314 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.MouseHandlerToggleShapeExpandedState = void 0;
var MouseHandlerStateBase_1 = __webpack_require__(40);
var ToggleShapeExpandedHistoryItem_1 = __webpack_require__(315);
var ModelUtils_1 = __webpack_require__(4);
var MouseHandlerToggleShapeExpandedState = (function (_super) {
    __extends(MouseHandlerToggleShapeExpandedState, _super);
    function MouseHandlerToggleShapeExpandedState(handler, history, model, selection) {
        var _this = _super.call(this, handler) || this;
        _this.history = history;
        _this.model = model;
        _this.selection = selection;
        return _this;
    }
    MouseHandlerToggleShapeExpandedState.prototype.onMouseUp = function (evt) {
        var shape = this.model.findShape(evt.source.key);
        if (shape && !shape.isLocked) {
            this.history.beginTransaction();
            this.history.addAndRedo(new ToggleShapeExpandedHistoryItem_1.ToggleShapeExpandedHistoryItem(shape));
            ModelUtils_1.ModelUtils.updateShapeAttachedConnectors(this.history, this.model, shape);
            ModelUtils_1.ModelUtils.updateContainerConnectorsAttachedPoints(this.history, this.model, shape);
            ModelUtils_1.ModelUtils.updateSelection(this.history, this.selection);
            this.handler.tryUpdateModelSize();
            this.history.endTransaction();
            this.handler.raiseClick([shape.key]);
        }
        this.handler.switchToDefaultState();
    };
    return MouseHandlerToggleShapeExpandedState;
}(MouseHandlerStateBase_1.MouseHandlerStateBase));
exports.MouseHandlerToggleShapeExpandedState = MouseHandlerToggleShapeExpandedState;


/***/ }),
/* 315 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.ToggleShapeExpandedHistoryItem = void 0;
var HistoryItem_1 = __webpack_require__(8);
var ToggleShapeExpandedHistoryItem = (function (_super) {
    __extends(ToggleShapeExpandedHistoryItem, _super);
    function ToggleShapeExpandedHistoryItem(shape) {
        var _this = _super.call(this) || this;
        _this.shapeKey = shape.key;
        _this.expanded = shape.expanded;
        return _this;
    }
    ToggleShapeExpandedHistoryItem.prototype.redo = function (manipulator) {
        var shape = manipulator.model.findShape(this.shapeKey);
        manipulator.changeShapeExpanded(shape, !this.expanded);
    };
    ToggleShapeExpandedHistoryItem.prototype.undo = function (manipulator) {
        var shape = manipulator.model.findShape(this.shapeKey);
        manipulator.changeShapeExpanded(shape, this.expanded);
    };
    return ToggleShapeExpandedHistoryItem;
}(HistoryItem_1.HistoryItem));
exports.ToggleShapeExpandedHistoryItem = ToggleShapeExpandedHistoryItem;


/***/ }),
/* 316 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.MouseHandlerSelectionState = void 0;
var Event_1 = __webpack_require__(11);
var rectangle_1 = __webpack_require__(13);
var MouseHandlerStateBase_1 = __webpack_require__(40);
var MouseHandlerSelectionState = (function (_super) {
    __extends(MouseHandlerSelectionState, _super);
    function MouseHandlerSelectionState(handler, selection, visualizerManager) {
        var _this = _super.call(this, handler) || this;
        _this.selection = selection;
        _this.visualizerManager = visualizerManager;
        return _this;
    }
    MouseHandlerSelectionState.prototype.finish = function () {
        this.handler.raiseDragEnd([]);
        this.visualizerManager.resetSelectionRectangle();
        _super.prototype.finish.call(this);
    };
    MouseHandlerSelectionState.prototype.cancelChanges = function () {
    };
    MouseHandlerSelectionState.prototype.onMouseDown = function (evt) {
        this.startPoint = evt.modelPoint;
        this.handler.raiseDragStart([]);
    };
    MouseHandlerSelectionState.prototype.onMouseMove = function (evt) {
        if (evt.button !== Event_1.MouseButton.Left)
            this.handler.switchToDefaultState();
        else {
            this.rectangle = rectangle_1.Rectangle.fromPoints(this.startPoint, evt.modelPoint);
            this.visualizerManager.setSelectionRectangle(this.rectangle);
        }
    };
    MouseHandlerSelectionState.prototype.onMouseUp = function (evt) {
        if (this.rectangle !== undefined)
            this.selection.selectRect(this.rectangle);
        else
            this.selection.set([]);
        this.rectangle = undefined;
        this.handler.switchToDefaultState();
    };
    return MouseHandlerSelectionState;
}(MouseHandlerStateBase_1.MouseHandlerCancellableState));
exports.MouseHandlerSelectionState = MouseHandlerSelectionState;


/***/ }),
/* 317 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.MouseHandlerZoomOnWheelState = void 0;
var MouseHandlerStateBase_1 = __webpack_require__(40);
var Event_1 = __webpack_require__(11);
var Settings_1 = __webpack_require__(28);
var MouseHandlerZoomOnWheelState = (function (_super) {
    __extends(MouseHandlerZoomOnWheelState, _super);
    function MouseHandlerZoomOnWheelState(handler, settings, view) {
        var _this = _super.call(this, handler) || this;
        _this.settings = settings;
        _this.view = view;
        return _this;
    }
    MouseHandlerZoomOnWheelState.prototype.onMouseWheel = function (evt) {
        if (!this.trySwitchToDefault(evt)) {
            this.settings.zoomLevel = this.view.getNextStepZoom(evt.deltaY < 0);
            if (evt.source.type === Event_1.MouseEventElementType.Background)
                this.view.resetScroll();
            else {
                this.view.scrollTo(evt.modelPoint, evt.offsetPoint);
                this.view.normalize();
            }
            evt.preventDefault = true;
            return true;
        }
        else
            return this.handler.state.onMouseWheel(evt);
    };
    MouseHandlerZoomOnWheelState.prototype.onMouseUp = function (evt) {
        this.handler.switchToDefaultState();
        this.handler.state.onMouseUp(evt);
    };
    MouseHandlerZoomOnWheelState.prototype.onMouseDown = function (evt) {
        this.handler.switchToDefaultState();
        this.handler.state.onMouseDown(evt);
    };
    MouseHandlerZoomOnWheelState.prototype.onMouseMove = function (evt) {
        this.trySwitchToDefault(evt) && this.handler.state.onMouseMove(evt);
    };
    MouseHandlerZoomOnWheelState.prototype.trySwitchToDefault = function (evt) {
        if (this.handler.canFinishZoomOnWheel(evt)) {
            this.handler.switchToDefaultState();
            return true;
        }
        return false;
    };
    MouseHandlerZoomOnWheelState.prototype.start = function () {
        _super.prototype.start.call(this);
        this.settings.zoomLevel = this.view.getZoom();
        this.settings.autoZoom = Settings_1.AutoZoomMode.Disabled;
    };
    return MouseHandlerZoomOnWheelState;
}(MouseHandlerStateBase_1.MouseHandlerStateBase));
exports.MouseHandlerZoomOnWheelState = MouseHandlerZoomOnWheelState;


/***/ }),
/* 318 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.MouseHandlerZoomOnPinchState = void 0;
var Settings_1 = __webpack_require__(28);
var point_1 = __webpack_require__(0);
var MouseHandlerScrollingState_1 = __webpack_require__(150);
var metrics_1 = __webpack_require__(35);
var PINCH_CHANGE_DISTANCE = 1;
var MouseHandlerZoomOnPinchState = (function (_super) {
    __extends(MouseHandlerZoomOnPinchState, _super);
    function MouseHandlerZoomOnPinchState(handler, selection, settings, view) {
        var _this = _super.call(this, handler, view, selection) || this;
        _this.selection = selection;
        _this.settings = settings;
        _this.view = view;
        return _this;
    }
    MouseHandlerZoomOnPinchState.prototype.onMouseDown = function (evt) {
        _super.prototype.onMouseDown.call(this, evt);
        if (evt.touches.length > 1) {
            this.startDistance = this.getTouchDistance(evt);
            this.startZoomLevel = this.settings.zoomLevel;
            this.prevDistance = this.startDistance;
        }
    };
    MouseHandlerZoomOnPinchState.prototype.onMouseMove = function (evt) {
        if (evt.touches.length > 1) {
            var distance = this.getTouchDistance(evt);
            if (Math.abs(this.prevDistance - distance) > PINCH_CHANGE_DISTANCE) {
                this.settings.zoomLevel = this.startZoomLevel * (distance / this.startDistance);
                this.view.scrollTo(this.getMiddleLayoutPoint(evt), this.getMiddleAbsPoint(evt));
                this.view.normalize();
                this.prevDistance = distance;
            }
        }
        _super.prototype.onMouseMove.call(this, evt);
    };
    MouseHandlerZoomOnPinchState.prototype.onMouseUp = function (evt) {
        if (evt.touches.length === 0)
            setTimeout(function () {
                this.handler.switchToDefaultState();
            }.bind(this), 1);
    };
    MouseHandlerZoomOnPinchState.prototype.start = function () {
        _super.prototype.start.call(this);
        this.settings.zoomLevel = this.view.getZoom();
        this.settings.autoZoom = Settings_1.AutoZoomMode.Disabled;
    };
    MouseHandlerZoomOnPinchState.prototype.getTouchDistance = function (evt) {
        var pt0 = new point_1.Point(evt.touches[0].offsetPoint.x, evt.touches[0].offsetPoint.y);
        var pt1 = new point_1.Point(evt.touches[1].offsetPoint.x, evt.touches[1].offsetPoint.y);
        return metrics_1.Metrics.euclideanDistance(pt0, pt1);
    };
    MouseHandlerZoomOnPinchState.prototype.getPointByEvent = function (evt) {
        return this.getMiddleAbsPoint(evt);
    };
    MouseHandlerZoomOnPinchState.prototype.getMiddleAbsPoint = function (evt) {
        if (evt.touches.length > 1)
            return MouseHandlerZoomOnPinchState.getMiddlePointByEvent(evt, function (touch) { return touch.offsetPoint; });
        return evt.offsetPoint;
    };
    MouseHandlerZoomOnPinchState.prototype.getMiddleLayoutPoint = function (evt) {
        if (evt.touches.length > 1)
            return MouseHandlerZoomOnPinchState.getMiddlePointByEvent(evt, function (touch) { return touch.modelPoint; });
        return evt.modelPoint;
    };
    MouseHandlerZoomOnPinchState.getMiddlePointByEvent = function (evt, getPoint) {
        if (evt.touches.length > 1)
            return new point_1.Point((getPoint(evt.touches[0]).x + getPoint(evt.touches[1]).x) / 2, (getPoint(evt.touches[0]).y + getPoint(evt.touches[1]).y) / 2);
    };
    return MouseHandlerZoomOnPinchState;
}(MouseHandlerScrollingState_1.MouseHandlerScrollingState));
exports.MouseHandlerZoomOnPinchState = MouseHandlerZoomOnPinchState;


/***/ }),
/* 319 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.MouseHandlerMoveShapeState = void 0;
var MouseHandlerDragDiagramItemStateBase_1 = __webpack_require__(151);
var MouseHandlerMoveShapeState = (function (_super) {
    __extends(MouseHandlerMoveShapeState, _super);
    function MouseHandlerMoveShapeState(handler, history, model, selection, visualizerManager) {
        var _this = _super.call(this, handler, history, model, selection, visualizerManager) || this;
        _this.model = model;
        _this.selection = selection;
        _this.visualizerManager = visualizerManager;
        return _this;
    }
    Object.defineProperty(MouseHandlerMoveShapeState.prototype, "areValidDraggingShapes", {
        get: function () {
            return this.shouldClone || this.draggingShapes.length > 0;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(MouseHandlerMoveShapeState.prototype, "areValidDraggingConnectors", {
        get: function () {
            return true;
        },
        enumerable: false,
        configurable: true
    });
    return MouseHandlerMoveShapeState;
}(MouseHandlerDragDiagramItemStateBase_1.MouseHandlerDragDiagramItemStateBase));
exports.MouseHandlerMoveShapeState = MouseHandlerMoveShapeState;


/***/ }),
/* 320 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.MouseHandlerMoveConnectorState = void 0;
var ModelUtils_1 = __webpack_require__(4);
var MouseHandlerDragDiagramItemStateBase_1 = __webpack_require__(151);
var MouseHandlerMoveConnectorState = (function (_super) {
    __extends(MouseHandlerMoveConnectorState, _super);
    function MouseHandlerMoveConnectorState(handler, history, model, selection, visualizerManager) {
        var _this = _super.call(this, handler, history, model, selection, visualizerManager) || this;
        _this.model = model;
        _this.selection = selection;
        _this.visualizerManager = visualizerManager;
        return _this;
    }
    Object.defineProperty(MouseHandlerMoveConnectorState.prototype, "areValidDraggingShapes", {
        get: function () {
            return true;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(MouseHandlerMoveConnectorState.prototype, "areValidDraggingConnectors", {
        get: function () {
            var _this = this;
            if (this.shouldClone)
                return this.draggingShapes.length > 0 || this.draggingConnectors.length > 0;
            if (!this.draggingConnectors.length)
                return false;
            if (!this.draggingShapes.length)
                return !this.draggingConnectors.some(function (x) { return !ModelUtils_1.ModelUtils.canMoveConnector(_this.selectedItems, x.connector); });
            return ModelUtils_1.ModelUtils.canMoveConnector(this.selectedItems, this.draggingConnectors[this.draggingConnectorsIndexByKey[this.handler.mouseDownEvent.source.key]].connector);
        },
        enumerable: false,
        configurable: true
    });
    return MouseHandlerMoveConnectorState;
}(MouseHandlerDragDiagramItemStateBase_1.MouseHandlerDragDiagramItemStateBase));
exports.MouseHandlerMoveConnectorState = MouseHandlerMoveConnectorState;


/***/ }),
/* 321 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.MouseHandlerDefaultReadOnlyTouchState = void 0;
var MouseHandlerDefaultReadOnlyState_1 = __webpack_require__(152);
var MouseHandlerDefaultReadOnlyTouchState = (function (_super) {
    __extends(MouseHandlerDefaultReadOnlyTouchState, _super);
    function MouseHandlerDefaultReadOnlyTouchState() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    MouseHandlerDefaultReadOnlyTouchState.prototype.canDragObjectOnMouseDown = function (key) {
        return false;
    };
    MouseHandlerDefaultReadOnlyTouchState.prototype.canExpandContainerOnMouseDown = function (key) {
        return false;
    };
    MouseHandlerDefaultReadOnlyTouchState.prototype.canClearSelectionOnMouseDown = function () {
        return true;
    };
    MouseHandlerDefaultReadOnlyTouchState.prototype.canSelectOnMouseUp = function (key) {
        return !this.inSelection(key);
    };
    MouseHandlerDefaultReadOnlyTouchState.prototype.canClearSelectionOnMouseUp = function () {
        return false;
    };
    return MouseHandlerDefaultReadOnlyTouchState;
}(MouseHandlerDefaultReadOnlyState_1.MouseHandlerDefaultReadOnlyState));
exports.MouseHandlerDefaultReadOnlyTouchState = MouseHandlerDefaultReadOnlyTouchState;


/***/ }),
/* 322 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.MouseHandlerDefaultTouchState = void 0;
var MouseHandlerDefaultState_1 = __webpack_require__(147);
var MouseHandlerDefaultTouchState = (function (_super) {
    __extends(MouseHandlerDefaultTouchState, _super);
    function MouseHandlerDefaultTouchState() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    MouseHandlerDefaultTouchState.prototype.updateConnectionsOnMouseMove = function (evt) {
    };
    MouseHandlerDefaultTouchState.prototype.canDragObjectOnMouseDown = function (key) {
        return this.inSelection(key);
    };
    MouseHandlerDefaultTouchState.prototype.canExpandContainerOnMouseDown = function (key) {
        return true;
    };
    MouseHandlerDefaultTouchState.prototype.canClearSelectionOnMouseDown = function () {
        return true;
    };
    MouseHandlerDefaultTouchState.prototype.canSelectOnMouseUp = function (key) {
        return !this.inSelection(key);
    };
    MouseHandlerDefaultTouchState.prototype.canClearSelectionOnMouseUp = function () {
        return false;
    };
    return MouseHandlerDefaultTouchState;
}(MouseHandlerDefaultState_1.MouseHandlerDefaultState));
exports.MouseHandlerDefaultTouchState = MouseHandlerDefaultTouchState;


/***/ }),
/* 323 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.TextInputHandler = void 0;
var ChangeShapeTextHistoryItem_1 = __webpack_require__(153);
var Event_1 = __webpack_require__(11);
var key_1 = __webpack_require__(25);
var Shape_1 = __webpack_require__(14);
var Connector_1 = __webpack_require__(6);
var ChangeConnectorTextHistoryItem_1 = __webpack_require__(69);
var TextInputHandler = (function () {
    function TextInputHandler(control) {
        this.control = control;
    }
    TextInputHandler.prototype.startTextInput = function (item, position) {
        if (item.isLocked || !item.enableText || !item.allowEditText || this.control.settings.readOnly || !this.canFinishTextEditing())
            return;
        this.control.beginUpdate();
        this.textInputItem = item;
        var allowed = true;
        if (this.textInputItem instanceof Shape_1.Shape) {
            var textRect = this.textInputItem.textEditRectangle;
            allowed = this.control.permissionsProvider.canChangeShapeText(this.textInputItem);
            if (allowed)
                this.control.eventManager.raiseTextInputStart(this.textInputItem, this.textInputItem.text, textRect.createPosition(), textRect.createSize());
        }
        else if (this.textInputItem instanceof Connector_1.Connector) {
            this.textInputPosition = position;
            allowed = this.control.permissionsProvider.canChangeConnectorText(this.textInputItem, this.textInputPosition);
            if (allowed)
                this.control.eventManager.raiseTextInputStart(this.textInputItem, this.textInputItem.getText(this.textInputPosition), this.textInputItem.getTextPoint(this.textInputPosition));
        }
        if (!allowed) {
            delete this.textInputItem;
            this.control.endUpdate();
        }
    };
    TextInputHandler.prototype.endTextInput = function (captureFocus) {
        var textInputItem = this.textInputItem;
        delete this.textInputItem;
        this.control.eventManager.raiseTextInputEnd(textInputItem, captureFocus);
        this.control.endUpdate();
        this.control.barManager.updateItemsState();
    };
    TextInputHandler.prototype.raiseTextInputPermissionsCheck = function (allowed) {
        this.control.eventManager.raiseTextInputPermissionsCheck(this.textInputItem, allowed);
    };
    TextInputHandler.prototype.applyTextInput = function (text, captureFocus) {
        if (!this.canFinishTextEditing(text))
            return;
        var textInputItem = this.textInputItem;
        var textInputPosition = this.textInputPosition;
        this.endTextInput(captureFocus);
        if (textInputItem instanceof Shape_1.Shape) {
            if (textInputItem.text !== text)
                this.control.history.addAndRedo(new ChangeShapeTextHistoryItem_1.ChangeShapeTextHistoryItem(textInputItem, text));
        }
        else if (textInputItem instanceof Connector_1.Connector)
            if (textInputItem.getText(textInputPosition) !== text)
                this.control.history.addAndRedo(new ChangeConnectorTextHistoryItem_1.ChangeConnectorTextHistoryItem(textInputItem, textInputPosition, text));
    };
    TextInputHandler.prototype.canFinishTextEditing = function (text) {
        var allowed = true;
        if (this.isTextInputActive()) {
            var newText = text || this.getTextInputElementValue();
            if (this.textInputItem instanceof Shape_1.Shape)
                allowed = this.control.permissionsProvider.canApplyShapeTextChange(this.textInputItem, newText);
            else if (this.textInputItem instanceof Connector_1.Connector)
                allowed = this.control.permissionsProvider.canApplyConnectorTextChange(this.textInputItem, this.textInputPosition, newText);
            this.raiseTextInputPermissionsCheck(allowed);
        }
        return allowed;
    };
    TextInputHandler.prototype.getTextInputElementValue = function () {
        if (this.control.render)
            return this.control.render.input.getTextInputElementValue();
        return "";
    };
    TextInputHandler.prototype.cancelTextInput = function () {
        this.raiseTextInputPermissionsCheck(true);
        this.endTextInput(true);
    };
    TextInputHandler.prototype.isTextInputActive = function () {
        return this.textInputItem !== undefined;
    };
    TextInputHandler.prototype.processDblClick = function (evt) {
        if (evt.source.type === Event_1.MouseEventElementType.Shape) {
            var shape = this.control.model.findShape(evt.source.key);
            this.startTextInput(shape);
        }
        else if (evt.source.type === Event_1.MouseEventElementType.Connector) {
            var connector = this.control.model.findConnector(evt.source.key);
            var position = connector.getTextPositionByPoint(evt.modelPoint);
            this.startTextInput(connector, position);
        }
        else if (evt.source.type === Event_1.MouseEventElementType.ConnectorText) {
            var connector = this.control.model.findConnector(evt.source.key);
            var position = parseFloat(evt.source.value);
            this.startTextInput(connector, position);
        }
    };
    TextInputHandler.prototype.onDblClick = function (evt) {
        var _this = this;
        setTimeout(function () {
            _this.processDblClick(evt);
        }, 10);
    };
    TextInputHandler.prototype.onKeyDown = function (evt) {
        if (!this.isTextInputActive())
            return;
        if (evt.keyCode === 13 && this.hasCtrlModifier(evt.modifiers)) {
            evt.preventDefault = true;
            this.applyTextInput(evt.inputText, true);
        }
        if (evt.keyCode === 27)
            this.cancelTextInput();
    };
    TextInputHandler.prototype.onBlur = function (evt) {
        if (this.isTextInputActive())
            this.applyTextInput(evt.inputText);
    };
    TextInputHandler.prototype.onFocus = function (evt) {
    };
    TextInputHandler.prototype.hasCtrlModifier = function (key) {
        return (key & key_1.ModifierKey.Ctrl) > 0;
    };
    return TextInputHandler;
}());
exports.TextInputHandler = TextInputHandler;


/***/ }),
/* 324 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.ContextMenuTouchHandler = void 0;
var Event_1 = __webpack_require__(11);
var ContextMenuHandler_1 = __webpack_require__(154);
var ModelUtils_1 = __webpack_require__(4);
var SELECTION_CHANGED_EVENT = 1;
var ContextMenuTouchHandler = (function (_super) {
    __extends(ContextMenuTouchHandler, _super);
    function ContextMenuTouchHandler(selection) {
        var _this = _super.call(this) || this;
        _this.selection = selection;
        _this.contextToolboxVisible = false;
        _this.selection.onChanged.add(_this);
        return _this;
    }
    ContextMenuTouchHandler.prototype.onMouseDown = function (evt) {
        if (evt.source.key === undefined)
            this.hideContextMenu();
    };
    ContextMenuTouchHandler.prototype.onMouseUp = function (evt) {
    };
    ContextMenuTouchHandler.prototype.onFocus = function (evt) {
        var _this = this;
        setTimeout(function () { _this.showContextMenuAtSelection(); }, 1);
    };
    ContextMenuTouchHandler.prototype.onBlur = function (evt) {
        var _this = this;
        setTimeout(function () { _this.hideContextMenu(); }, 1);
    };
    ContextMenuTouchHandler.prototype.onTextInputFocus = function (evt) {
        var _this = this;
        setTimeout(function () { _this.hideContextMenu(); }, 1);
    };
    ContextMenuTouchHandler.prototype.onTextInputBlur = function (evt) {
        var _this = this;
        setTimeout(function () { _this.showContextMenuAtSelection(); }, 1);
    };
    ContextMenuTouchHandler.prototype.onLongTouch = function (evt) {
        if (evt.source.type === Event_1.MouseEventElementType.Document)
            this.showContextMenuAtEmptySelection(evt.modelPoint);
    };
    ContextMenuTouchHandler.prototype.onKeyDown = function (evt) {
    };
    ContextMenuTouchHandler.prototype.onShortcut = function (evt) {
    };
    ContextMenuTouchHandler.prototype.getSelectedItems = function () {
        return this.selection.getSelectedItems(true);
    };
    ContextMenuTouchHandler.prototype.showContextMenuAtSelection = function () {
        if (this.contextToolboxVisible)
            return;
        var items = this.getSelectedItems();
        if (items.length !== 0)
            this.showContextMenu(undefined, ModelUtils_1.ModelUtils.createRectangle(items).createPosition());
    };
    ContextMenuTouchHandler.prototype.showContextMenuAtEmptySelection = function (point) {
        if (this.contextToolboxVisible)
            return;
        var items = this.getSelectedItems();
        if (items.length === 0)
            this.showContextMenu(undefined, point);
    };
    ContextMenuTouchHandler.prototype.notifyDragStart = function (itemKeys) {
        this.hideContextMenu();
    };
    ContextMenuTouchHandler.prototype.notifyDragEnd = function (itemKeys) {
        this.showContextMenuAtSelection();
    };
    ContextMenuTouchHandler.prototype.notifySelectionChanged = function (selection) {
        if (this.isUpdateLocked())
            this.registerOccurredEvent(SELECTION_CHANGED_EVENT);
        else
            this.raiseSelectionChanged();
    };
    ContextMenuTouchHandler.prototype.raiseSelectionChanged = function () {
        var items = this.getSelectedItems();
        if (items.length !== 0)
            this.showContextMenuAtSelection();
        else
            this.hideContextMenu();
    };
    ContextMenuTouchHandler.prototype.onUpdateUnlocked = function (occurredEvents) {
        if (occurredEvents & SELECTION_CHANGED_EVENT)
            this.raiseSelectionChanged();
    };
    ContextMenuTouchHandler.prototype.notifyShowContextToolbox = function (modelPoint, getPositionToInsertShapeTo, side, category, callback) {
        this.contextToolboxVisible = true;
        this.hideContextMenu();
    };
    ContextMenuTouchHandler.prototype.notifyHideContextToolbox = function () {
        this.contextToolboxVisible = false;
        this.showContextMenuAtSelection();
    };
    return ContextMenuTouchHandler;
}(ContextMenuHandler_1.ContextMenuHandler));
exports.ContextMenuTouchHandler = ContextMenuTouchHandler;


/***/ }),
/* 325 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.ConnectionTargetVisualizer = exports.ConnectionTargetInfo = void 0;
var TargetVisualizerBase_1 = __webpack_require__(156);
var ConnectionTargetInfo = (function () {
    function ConnectionTargetInfo(rect, strokeWidth) {
        this.rect = rect;
        this.strokeWidth = strokeWidth;
        this.allowed = true;
    }
    return ConnectionTargetInfo;
}());
exports.ConnectionTargetInfo = ConnectionTargetInfo;
var ConnectionTargetVisualizer = (function (_super) {
    __extends(ConnectionTargetVisualizer, _super);
    function ConnectionTargetVisualizer(dispatcher) {
        return _super.call(this, dispatcher) || this;
    }
    ConnectionTargetVisualizer.prototype.raiseShow = function () {
        var _this = this;
        var info = new ConnectionTargetInfo(this.targetRect, this.targetStrokeWidth);
        this.dispatcher.raise1(function (l) { return l.notifyConnectionTargetShow(_this.key, info); });
    };
    ConnectionTargetVisualizer.prototype.raiseHide = function () {
        this.dispatcher.raise1(function (l) { return l.notifyConnectionTargetHide(); });
    };
    return ConnectionTargetVisualizer;
}(TargetVisualizerBase_1.TargetVisualizerBase));
exports.ConnectionTargetVisualizer = ConnectionTargetVisualizer;


/***/ }),
/* 326 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.ContainerTargetVisualizer = exports.ContainerTargetInfo = void 0;
var TargetVisualizerBase_1 = __webpack_require__(156);
var ContainerTargetInfo = (function () {
    function ContainerTargetInfo(rect, strokeWidth) {
        this.rect = rect;
        this.strokeWidth = strokeWidth;
    }
    return ContainerTargetInfo;
}());
exports.ContainerTargetInfo = ContainerTargetInfo;
var ContainerTargetVisualizer = (function (_super) {
    __extends(ContainerTargetVisualizer, _super);
    function ContainerTargetVisualizer(dispatcher) {
        return _super.call(this, dispatcher) || this;
    }
    ContainerTargetVisualizer.prototype.raiseShow = function () {
        var _this = this;
        var info = new ContainerTargetInfo(this.targetRect, this.targetStrokeWidth);
        this.dispatcher.raise1(function (l) { return l.notifyContainerTargetShow(_this.key, info); });
    };
    ContainerTargetVisualizer.prototype.raiseHide = function () {
        this.dispatcher.raise1(function (l) { return l.notifyContainerTargetHide(); });
    };
    return ContainerTargetVisualizer;
}(TargetVisualizerBase_1.TargetVisualizerBase));
exports.ContainerTargetVisualizer = ContainerTargetVisualizer;


/***/ }),
/* 327 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.ConnectionPointsVisualizer = exports.ConnectionPointInfo = void 0;
var ConnectionPointInfo = (function () {
    function ConnectionPointInfo(point, side) {
        this.point = point;
        this.side = side;
        this.allowed = true;
    }
    return ConnectionPointInfo;
}());
exports.ConnectionPointInfo = ConnectionPointInfo;
var ConnectionPointsVisualizer = (function () {
    function ConnectionPointsVisualizer(dispatcher) {
        this.dispatcher = dispatcher;
    }
    ConnectionPointsVisualizer.prototype.getKey = function () {
        return this.key;
    };
    ConnectionPointsVisualizer.prototype.setPoints = function (key, points, pointIndex, outsideRectangle) {
        if (this.key !== key || this.pointIndex !== pointIndex) {
            this.key = key;
            this.points = points;
            this.pointIndex = pointIndex;
            this.outsideRectangle = outsideRectangle;
            this.raiseShow();
        }
    };
    ConnectionPointsVisualizer.prototype.setPointIndex = function (pointIndex) {
        if (0 <= pointIndex && pointIndex < this.points.length && this.pointIndex !== pointIndex) {
            this.pointIndex = pointIndex;
            this.raiseShow();
        }
    };
    ConnectionPointsVisualizer.prototype.update = function () {
        this.raiseShow();
    };
    ConnectionPointsVisualizer.prototype.reset = function () {
        if (this.key !== "-1") {
            this.key = "-1";
            this.points = [];
            this.pointIndex = -1;
            this.outsideRectangle = undefined;
            this.raiseHide();
        }
    };
    ConnectionPointsVisualizer.prototype.raiseShow = function () {
        var _this = this;
        this.dispatcher.raise1(function (l) { return l.notifyConnectionPointsShow(_this.key, _this.points, _this.pointIndex, _this.outsideRectangle); });
    };
    ConnectionPointsVisualizer.prototype.raiseHide = function () {
        this.dispatcher.raise1(function (l) { return l.notifyConnectionPointsHide(); });
    };
    return ConnectionPointsVisualizer;
}());
exports.ConnectionPointsVisualizer = ConnectionPointsVisualizer;


/***/ }),
/* 328 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.ResizeInfoVisualizer = void 0;
var ResizeInfoVisualizer = (function () {
    function ResizeInfoVisualizer(dispatcher) {
        this.dispatcher = dispatcher;
    }
    ResizeInfoVisualizer.prototype.set = function (point, text) {
        this.point = point;
        this.text = text;
        this.raiseShow();
    };
    ResizeInfoVisualizer.prototype.reset = function () {
        if (this.point !== undefined) {
            this.point = undefined;
            this.text = undefined;
            this.raiseHide();
        }
    };
    ResizeInfoVisualizer.prototype.raiseShow = function () {
        var _this = this;
        this.dispatcher.raise1(function (l) { return l.notifyResizeInfoShow(_this.point, _this.text); });
    };
    ResizeInfoVisualizer.prototype.raiseHide = function () {
        this.dispatcher.raise1(function (l) { return l.notifyResizeInfoHide(); });
    };
    return ResizeInfoVisualizer;
}());
exports.ResizeInfoVisualizer = ResizeInfoVisualizer;


/***/ }),
/* 329 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.SelectionRectVisualizer = void 0;
var SelectionRectVisualizer = (function () {
    function SelectionRectVisualizer(dispatcher) {
        this.dispatcher = dispatcher;
    }
    SelectionRectVisualizer.prototype.setRectangle = function (rect) {
        this.rect = rect;
        this.raiseShow();
    };
    SelectionRectVisualizer.prototype.reset = function () {
        this.rect = undefined;
        this.raiseHide();
    };
    SelectionRectVisualizer.prototype.raiseShow = function () {
        var _this = this;
        this.dispatcher.raise1(function (l) { return l.notifySelectionRectShow(_this.rect); });
    };
    SelectionRectVisualizer.prototype.raiseHide = function () {
        this.dispatcher.raise1(function (l) { return l.notifySelectionRectHide(); });
    };
    return SelectionRectVisualizer;
}());
exports.SelectionRectVisualizer = SelectionRectVisualizer;


/***/ }),
/* 330 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.VisualizerTouchManager = void 0;
var VisualizersManager_1 = __webpack_require__(155);
var Event_1 = __webpack_require__(11);
var SELECTION_CHANGED_EVENT = 1;
var VisualizerTouchManager = (function (_super) {
    __extends(VisualizerTouchManager, _super);
    function VisualizerTouchManager(selection, model, eventManager, settings, readOnly) {
        if (readOnly === void 0) { readOnly = settings.readOnly; }
        var _this = _super.call(this, selection, model, eventManager, settings, readOnly) || this;
        selection.onChanged.add(_this);
        return _this;
    }
    VisualizerTouchManager.prototype.onBlur = function (evt) {
        var _this = this;
        setTimeout(function () { _this.hideConnections(); }, 1);
    };
    VisualizerTouchManager.prototype.onFocus = function (evt) {
        var _this = this;
        setTimeout(function () { _this.showConnections(); }, 1);
    };
    VisualizerTouchManager.prototype.hideConnections = function () {
        if (this.readOnly)
            return;
        this.resetConnectionPoints();
    };
    VisualizerTouchManager.prototype.showConnections = function () {
        if (this.readOnly)
            return;
        if (this.needShowConnections()) {
            var shapes = this.selection.getSelectedShapes();
            if (shapes.length === 1)
                this.setConnectionPoints(shapes[0], Event_1.MouseEventElementType.ShapeConnectionPoint, -1, (!shapes[0].allowResizeHorizontally && !shapes[0].allowResizeVertically) || shapes[0].isLocked);
        }
    };
    VisualizerTouchManager.prototype.needShowConnections = function () {
        var items = this.selection.getSelectedItems();
        var shapes = this.selection.getSelectedShapes();
        return (items.length === 1 && shapes.length === 1);
    };
    VisualizerTouchManager.prototype.notifySelectionChanged = function (selection) {
        if (this.isUpdateLocked())
            this.registerOccurredEvent(SELECTION_CHANGED_EVENT);
        else
            this.raiseSelectionChanged();
    };
    VisualizerTouchManager.prototype.raiseSelectionChanged = function () {
        if (this.needShowConnections())
            this.showConnections();
        else
            this.hideConnections();
    };
    VisualizerTouchManager.prototype.onUpdateUnlocked = function (occurredEvents) {
        if (occurredEvents & SELECTION_CHANGED_EVENT)
            this.raiseSelectionChanged();
    };
    VisualizerTouchManager.prototype.notifyDragStart = function (itemKeys) {
        this.hideConnections();
    };
    VisualizerTouchManager.prototype.notifyDragEnd = function (itemKeys) {
        this.showConnections();
    };
    return VisualizerTouchManager;
}(VisualizersManager_1.VisualizerManager));
exports.VisualizerTouchManager = VisualizerTouchManager;


/***/ }),
/* 331 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.ContextToolboxHandler = void 0;
var Event_1 = __webpack_require__(11);
var Utils_1 = __webpack_require__(3);
var key_1 = __webpack_require__(25);
var browser_1 = __webpack_require__(18);
var ContextToolboxHandler = (function () {
    function ContextToolboxHandler() {
        this.contextToolboxVisible = false;
        this.onVisibilityChanged = new Utils_1.EventDispatcher();
    }
    ContextToolboxHandler.prototype.onMouseDown = function (evt) {
        if (evt.source.type !== Event_1.MouseEventElementType.Undefined)
            this.hideContextToolbox();
    };
    ContextToolboxHandler.prototype.onMouseUp = function (evt) {
        if (evt.source.type !== Event_1.MouseEventElementType.Undefined || !browser_1.Browser.TouchUI)
            this.hideContextToolbox();
    };
    ContextToolboxHandler.prototype.onFocus = function (evt) { };
    ContextToolboxHandler.prototype.onBlur = function (evt) { };
    ContextToolboxHandler.prototype.onKeyDown = function (evt) {
        if (evt.keyCode === key_1.KeyCode.Esc)
            this.hideContextToolbox();
    };
    ContextToolboxHandler.prototype.onShortcut = function (evt) {
        this.hideContextToolbox();
    };
    ContextToolboxHandler.prototype.showContextToolbox = function (modelPoint, getPositionToInsertShapeTo, side, category, applyCallback, cancelCallback) {
        this.onVisibilityChanged.raise1(function (l) { return l.notifyShowContextToolbox(modelPoint, getPositionToInsertShapeTo, side, category, applyCallback); });
        this.contextToolboxVisible = true;
        this.contextToolboxCancelCallback = cancelCallback;
    };
    ContextToolboxHandler.prototype.hideContextToolbox = function (applyed) {
        if (this.contextToolboxVisible) {
            this.onVisibilityChanged.raise1(function (l) { return l.notifyHideContextToolbox(); });
            if (this.contextToolboxCancelCallback) {
                if (!applyed)
                    this.contextToolboxCancelCallback();
                this.contextToolboxCancelCallback = undefined;
            }
            this.contextToolboxVisible = false;
        }
    };
    return ContextToolboxHandler;
}());
exports.ContextToolboxHandler = ContextToolboxHandler;


/***/ }),
/* 332 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.Selection = void 0;
var Utils_1 = __webpack_require__(3);
var InputPosition_1 = __webpack_require__(333);
var Shape_1 = __webpack_require__(14);
var Connector_1 = __webpack_require__(6);
var Data_1 = __webpack_require__(44);
var Selection = (function () {
    function Selection(model) {
        this.onChanged = new Utils_1.EventDispatcher();
        this.inputPosition = new InputPosition_1.InputPosition(this);
        this.onChanged.add(this.inputPosition);
        this.initialize(model);
    }
    Selection.prototype.initialize = function (model) {
        this.model = model;
        this.keys = [];
        this.inputPosition.initialize();
    };
    Selection.prototype.add = function (key) {
        if (this.keys.indexOf(key) < 0) {
            this.keys.push(key);
            this.raiseSelectionChanged();
        }
    };
    Selection.prototype.remove = function (key) {
        if (this.keys.indexOf(key) >= 0) {
            this.keys.splice(this.keys.indexOf(key), 1);
            this.raiseSelectionChanged();
        }
    };
    Selection.prototype.clear = function () {
        if (this.keys.length > 0) {
            this.keys = [];
            this.raiseSelectionChanged();
        }
    };
    Selection.prototype.set = function (keys, forceChange) {
        if (forceChange || !Data_1.Data.ArrayEqual(keys, this.keys)) {
            this.keys = keys;
            this.raiseSelectionChanged();
        }
    };
    Selection.prototype.getKeys = function () {
        return this.keys;
    };
    Selection.prototype.getKey = function (index) {
        return this.keys[index];
    };
    Selection.prototype.getSelectedItemsInsideContainers = function (items) {
        var _this = this;
        var result = items.slice();
        items.forEach(function (item) {
            if (item instanceof Shape_1.Shape) {
                var children = _this.getSelectedItemsInsideContainers(_this.model.getChildren(item));
                children.forEach(function (child) {
                    if (result.indexOf(child) === -1 && !_this.hasKey(child.key))
                        result.push(child);
                });
            }
        });
        return result;
    };
    Selection.prototype.getSelectedItemsCore = function (includeLocked) {
        var _this = this;
        return this.keys.map(function (key) { return _this.model.findItem(key); })
            .filter(function (item) { return item && (includeLocked || !item.isLocked); });
    };
    Selection.prototype.getSelectedItems = function (includeLocked, includeInsideContainers) {
        if (includeInsideContainers)
            return this.getSelectedItemsInsideContainers(this.getSelectedItemsCore(includeLocked));
        return this.getSelectedItemsCore(includeLocked);
    };
    Selection.prototype.getSelectedShapes = function (includeLocked, includeInsideContainers) {
        var _this = this;
        if (includeInsideContainers) {
            var items = this.getSelectedItemsCore(includeLocked);
            return this.getSelectedItemsInsideContainers(items)
                .map(function (item) { return item instanceof Shape_1.Shape ? item : undefined; })
                .filter(function (shape) { return shape; });
        }
        else
            return this.keys.map(function (key) { return _this.model.findShape(key); })
                .filter(function (shape) { return shape && (includeLocked || !shape.isLocked); });
    };
    Selection.prototype.getSelectedConnectors = function (includeLocked, includeInsideContainers) {
        var _this = this;
        if (includeInsideContainers) {
            var items = this.keys.map(function (key) { return _this.model.findItem(key); });
            return this.getSelectedItemsInsideContainers(items)
                .map(function (item) { return item instanceof Connector_1.Connector ? item : undefined; })
                .filter(function (connector) { return connector && (includeLocked || !connector.isLocked); });
        }
        else
            return this.keys.map(function (key) { return _this.model.findConnector(key); })
                .filter(function (conn) { return conn && (includeLocked || !conn.isLocked); });
    };
    Selection.prototype.hasKey = function (key) {
        return this.keys.indexOf(key) >= 0;
    };
    Selection.prototype.isEmpty = function (includeLocked) {
        return !this.getSelectedItems(includeLocked).length;
    };
    Selection.prototype.selectRect = function (rect) {
        var keys = [];
        this.model.iterateItems(function (item) {
            if (item.intersectedByRect(rect))
                keys.push(item.key);
        });
        this.set(keys);
    };
    Selection.prototype.raiseSelectionChanged = function () {
        this.onChanged.raise("notifySelectionChanged", this);
    };
    return Selection;
}());
exports.Selection = Selection;


/***/ }),
/* 333 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.InputPosition = void 0;
var InputPositionProperties_1 = __webpack_require__(334);
var Data_1 = __webpack_require__(44);
var InputPosition = (function () {
    function InputPosition(selection) {
        this.selection = selection;
        this.initialProperties = new InputPositionProperties_1.InputPositionProperties(this.selection);
        this.defaultProperties = new InputPositionProperties_1.InputPositionProperties(this.selection, this.initialProperties, true);
        this.currentProperties = new InputPositionProperties_1.InputPositionProperties(this.selection, this.defaultProperties);
    }
    InputPosition.prototype.initialize = function () {
        this.reset();
        this.defaultProperties.reset();
    };
    InputPosition.prototype.reset = function () {
        this.currentProperties.reset();
    };
    InputPosition.prototype.getDefaultConnectorProperties = function () {
        return this.defaultProperties.getConnectorProperties();
    };
    InputPosition.prototype.getDefaultConnectorPropertyValue = function (propertyName) {
        return this.defaultProperties.getConnectorPropertyValue(propertyName);
    };
    InputPosition.prototype.getCurrentConnectorPropertyValue = function (propertyName) {
        return this.currentProperties.getConnectorPropertyValue(propertyName);
    };
    InputPosition.prototype.setConnectorPropertyValue = function (propertyName, value) {
        this.currentProperties.setConnectorPropertyValue(propertyName, value);
        if (this.selection.isEmpty(true))
            this.defaultProperties.setConnectorPropertyValue(propertyName, value);
    };
    InputPosition.prototype.setInitialConnectorProperties = function (properties) {
        this.defaultProperties.reset();
        this.currentProperties.reset();
        for (var propertyName in properties)
            if (Object.prototype.hasOwnProperty.call(properties, propertyName))
                this.initialProperties.setConnectorPropertyValue(propertyName, properties[propertyName]);
    };
    InputPosition.prototype.getDefaultStyle = function () {
        return this.defaultProperties.getStyle();
    };
    InputPosition.prototype.getDefaultStylePropertyValue = function (propertyName) {
        return this.defaultProperties.getStylePropertyValue(propertyName);
    };
    InputPosition.prototype.getDefaultTextStyle = function () {
        return this.defaultProperties.getTextStyle();
    };
    InputPosition.prototype.getDefaultTextStylePropertyValue = function (propertyName) {
        return this.defaultProperties.getTextStylePropertyValue(propertyName);
    };
    InputPosition.prototype.getCurrentStylePropertyValue = function (propertyName) {
        return this.currentProperties.getStylePropertyValue(propertyName);
    };
    InputPosition.prototype.getCurrentTextStylePropertyValue = function (propertyName) {
        return this.currentProperties.getTextStylePropertyValue(propertyName);
    };
    InputPosition.prototype.setStylePropertyValue = function (propertyName, value) {
        this.currentProperties.setStylePropertyValue(propertyName, value);
        if (this.selection.isEmpty(true))
            this.defaultProperties.setStylePropertyValue(propertyName, value);
    };
    InputPosition.prototype.setTextStylePropertyValue = function (propertyName, value) {
        this.currentProperties.setTextStylePropertyValue(propertyName, value);
        if (this.selection.isEmpty(true))
            this.defaultProperties.setTextStylePropertyValue(propertyName, value);
    };
    InputPosition.prototype.setInitialStyleProperties = function (style) {
        this.defaultProperties.reset();
        this.currentProperties.reset();
        var styleObj = typeof style === "string" ? Data_1.Data.cssTextToObject(style) : style;
        for (var propertyName in styleObj)
            if (Object.prototype.hasOwnProperty.call(styleObj, propertyName))
                this.initialProperties.setStylePropertyValue(propertyName, styleObj[propertyName]);
    };
    InputPosition.prototype.setInitialTextStyleProperties = function (style) {
        this.defaultProperties.reset();
        this.currentProperties.reset();
        var styleObj = typeof style === "string" ? Data_1.Data.cssTextToObject(style) : style;
        for (var propertyName in styleObj)
            if (Object.prototype.hasOwnProperty.call(styleObj, propertyName))
                this.initialProperties.setTextStylePropertyValue(propertyName, styleObj[propertyName]);
    };
    InputPosition.prototype.notifySelectionChanged = function (selection) {
        this.reset();
    };
    return InputPosition;
}());
exports.InputPosition = InputPosition;


/***/ }),
/* 334 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.InputPositionProperties = void 0;
var ConnectorProperties_1 = __webpack_require__(32);
var Style_1 = __webpack_require__(26);
var InputPositionProperties = (function () {
    function InputPositionProperties(selection, baseProperties, disableMergingStyles) {
        this.selection = selection;
        this.baseProperties = baseProperties;
        this.disableMergingStyles = disableMergingStyles;
        this.selection = selection;
    }
    InputPositionProperties.prototype.reset = function () {
        this.connectorProperties = null;
        this.style = null;
        this.textStyle = null;
    };
    InputPositionProperties.prototype.getConnectorProperties = function () {
        if (!this.connectorProperties) {
            this.connectorProperties = this.baseProperties ? this.baseProperties.getConnectorProperties().clone() : new ConnectorProperties_1.ConnectorProperties();
            this.updateConnectorProperties(this.connectorProperties);
        }
        return this.connectorProperties;
    };
    InputPositionProperties.prototype.getConnectorPropertyValue = function (propertyName) {
        return this.getConnectorProperties()[propertyName];
    };
    InputPositionProperties.prototype.setConnectorPropertyValue = function (propertyName, value) {
        this.getConnectorProperties()[propertyName] = value;
    };
    InputPositionProperties.prototype.getStyle = function () {
        if (!this.style) {
            this.style = this.baseProperties ? this.baseProperties.getStyle().clone() : new Style_1.Style();
            if (!this.disableMergingStyles)
                this.updateStyle(this.style, "style");
        }
        return this.style;
    };
    InputPositionProperties.prototype.getStylePropertyValue = function (propertyName) {
        return this.getStyle()[propertyName];
    };
    InputPositionProperties.prototype.setStylePropertyValue = function (propertyName, value) {
        this.getStyle()[propertyName] = value;
    };
    InputPositionProperties.prototype.getTextStyle = function () {
        if (!this.textStyle) {
            this.textStyle = this.baseProperties ? this.baseProperties.getTextStyle().clone() : new Style_1.TextStyle();
            if (!this.disableMergingStyles)
                this.updateStyle(this.textStyle, "styleText");
        }
        return this.textStyle;
    };
    InputPositionProperties.prototype.getTextStylePropertyValue = function (propertyName) {
        return this.getTextStyle()[propertyName];
    };
    InputPositionProperties.prototype.setTextStylePropertyValue = function (propertyName, value) {
        this.getTextStyle()[propertyName] = value;
    };
    InputPositionProperties.prototype.updateConnectorProperties = function (properties) {
        var _this = this;
        var connectors = this.selection.getSelectedConnectors(true);
        properties.forEach(function (propertyName) {
            _this.updatePropertyValue(properties, connectors, function (item) { return item["properties"]; }, propertyName);
        });
    };
    InputPositionProperties.prototype.updateStyle = function (style, stylePropertyName) {
        var _this = this;
        var items = this.selection.getSelectedItems(true);
        style.forEach(function (propertyName) {
            _this.updatePropertyValue(style, items, function (item) { return item[stylePropertyName]; }, propertyName);
        });
    };
    InputPositionProperties.prototype.updatePropertyValue = function (destObj, items, getSrcObj, propertyName) {
        var value;
        var valueAssigned = false;
        items.forEach(function (item) {
            var obj = getSrcObj(item);
            var propertyValue = obj[propertyName];
            if (value === undefined && propertyValue !== undefined) {
                value = propertyValue;
                valueAssigned = true;
            }
            else if (valueAssigned && value !== propertyValue) {
                value = undefined;
                return;
            }
        });
        if (valueAssigned)
            destObj[propertyName] = value;
    };
    return InputPositionProperties;
}());
exports.InputPositionProperties = InputPositionProperties;


/***/ }),
/* 335 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.History = void 0;
var HistoryItem_1 = __webpack_require__(8);
var Utils_1 = __webpack_require__(3);
var History = (function () {
    function History(modelManipulator) {
        this.historyItems = [];
        this.currentIndex = -1;
        this.incrementalId = -1;
        this.transactionLevel = -1;
        this.unmodifiedIndex = -1;
        this.currTransactionId = 0;
        this.onChanged = new Utils_1.EventDispatcher();
        this.modelManipulator = modelManipulator;
    }
    History.prototype.isModified = function () {
        if (this.unmodifiedIndex === this.currentIndex)
            return false;
        var startIndex = Math.min(this.unmodifiedIndex, this.currentIndex);
        var endIndex = Math.max(this.unmodifiedIndex, this.currentIndex);
        for (var i = startIndex + 1; i <= endIndex; i++)
            if (this.historyItems[i].changeModified())
                return true;
        return false;
    };
    History.prototype.undo = function () {
        if (!this.canUndo())
            return;
        this.historyItems[this.currentIndex].undo(this.modelManipulator);
        this.currentIndex--;
        this.raiseChanged();
    };
    History.prototype.redo = function () {
        if (!this.canRedo())
            return;
        if (this.startDataSyncItem) {
            this.startDataSyncItem.undo(this.modelManipulator);
            this.startDataSyncItem = undefined;
        }
        this.currentIndex++;
        this.historyItems[this.currentIndex].redo(this.modelManipulator);
        this.raiseChanged();
    };
    History.prototype.canUndo = function () {
        return this.currentIndex >= 0;
    };
    History.prototype.canRedo = function () {
        return this.currentIndex < this.historyItems.length - 1;
    };
    History.prototype.beginTransaction = function () {
        this.transactionLevel++;
        if (this.transactionLevel === 0)
            this.transaction = new HistoryItem_1.CompositionHistoryItem();
        var id = this.currTransactionId++;
        return id;
    };
    History.prototype.endTransaction = function (isDataSyncTransaction) {
        if (--this.transactionLevel >= 0)
            return;
        var transactionLength = this.transaction.historyItems.length;
        if (transactionLength > 0) {
            var historyItem = transactionLength > 1 ? this.transaction : this.transaction.historyItems.pop();
            if (isDataSyncTransaction)
                this.addDataSyncItem(historyItem);
            else
                this.addInternal(historyItem);
        }
        if (transactionLength > 0 && !isDataSyncTransaction)
            this.raiseChanged();
        delete this.transaction;
    };
    History.prototype.addAndRedo = function (historyItem) {
        this.add(historyItem);
        historyItem.redo(this.modelManipulator);
        this.raiseChanged();
    };
    History.prototype.add = function (historyItem) {
        if (this.transactionLevel >= 0)
            this.transaction.add(historyItem);
        else
            this.addInternal(historyItem);
    };
    History.prototype.addInternal = function (historyItem) {
        if (this.currentIndex < this.historyItems.length - 1) {
            this.historyItems.splice(this.currentIndex + 1);
            this.unmodifiedIndex = Math.min(this.unmodifiedIndex, this.currentIndex);
        }
        this.historyItems.push(historyItem);
        this.currentIndex++;
        this.deleteOldItems();
    };
    History.prototype.addDataSyncItem = function (historyItem) {
        var toHistoryItem = this.historyItems[this.currentIndex];
        if (toHistoryItem) {
            var compositionHistoryItem = void 0;
            if (toHistoryItem instanceof HistoryItem_1.CompositionHistoryItem)
                compositionHistoryItem = toHistoryItem;
            else {
                this.historyItems.splice(this.currentIndex, 1);
                compositionHistoryItem = new HistoryItem_1.CompositionHistoryItem();
                this.historyItems.push(compositionHistoryItem);
                compositionHistoryItem.historyItems.push(toHistoryItem);
            }
            compositionHistoryItem.dataSyncItems.push(historyItem);
        }
        else if (this.historyItems.length)
            this.startDataSyncItem = historyItem;
    };
    History.prototype.deleteOldItems = function () {
        var exceedItemsCount = this.historyItems.length - History.MAX_HISTORY_ITEM_COUNT;
        if (exceedItemsCount > 0 && this.currentIndex > exceedItemsCount) {
            this.historyItems.splice(0, exceedItemsCount);
            this.currentIndex -= exceedItemsCount;
        }
    };
    History.prototype.getNextId = function () {
        this.incrementalId++;
        return this.incrementalId;
    };
    History.prototype.clear = function () {
        this.currentIndex = -1;
        this.unmodifiedIndex = -1;
        this.incrementalId = -1;
        this.historyItems = [];
        delete this.transaction;
        this.transactionLevel = -1;
    };
    History.prototype.resetModified = function () {
        this.unmodifiedIndex = this.currentIndex;
    };
    History.prototype.getCurrentItemId = function () {
        if (this.currentIndex === -1)
            return -1;
        var currentItem = this.historyItems[this.currentIndex];
        if (currentItem.uniqueId === -1)
            currentItem.uniqueId = this.getNextId();
        return currentItem.uniqueId;
    };
    History.prototype.undoTransaction = function () {
        var items = this.transaction.historyItems;
        while (items.length)
            items.pop().undo(this.modelManipulator);
    };
    History.prototype.undoTransactionTo = function (item) {
        var items = this.transaction.historyItems;
        while (items.length) {
            var ti = items.pop();
            ti.undo(this.modelManipulator);
            if (ti === item)
                return;
        }
    };
    History.prototype.raiseChanged = function () {
        if (this.transactionLevel === -1)
            this.onChanged.raise("notifyHistoryChanged");
    };
    History.MAX_HISTORY_ITEM_COUNT = 100;
    return History;
}());
exports.History = History;


/***/ }),
/* 336 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.BarManager = void 0;
var batch_updatable_1 = __webpack_require__(81);
var BarManager = (function (_super) {
    __extends(BarManager, _super);
    function BarManager(control) {
        var _this = _super.call(this) || this;
        _this.bars = [];
        _this.control = control;
        return _this;
    }
    BarManager.prototype.clean = function () {
        var _this = this;
        this.bars.forEach(function (bar) { return bar.onChanged.remove(_this); });
        this.bars = [];
    };
    BarManager.prototype.registerBar = function (bar) {
        this.bars.push(bar);
        bar.onChanged.add(this);
        this.updateBarItemsState(bar);
    };
    BarManager.prototype.updateItemsState = function (queryCommands) {
        if (this.isUpdateLocked())
            return;
        for (var i = 0, bar = void 0; bar = this.bars[i]; i++)
            this.updateBarItemsState(bar, queryCommands);
    };
    BarManager.prototype.updateBarItemsState = function (bar, queryCommands) {
        if (this.isUpdateLocked())
            return;
        this.control.permissionsProvider.beginUpdateUI();
        if (bar.isVisible()) {
            var commandKeys = void 0;
            if (queryCommands) {
                var knownCommandKeys_1 = bar.getCommandKeys().reduce(function (hash, cmd) {
                    hash[cmd] = true;
                    return hash;
                }, {});
                commandKeys = queryCommands.filter(function (cmd) { return knownCommandKeys_1[cmd]; });
            }
            else
                commandKeys = bar.getCommandKeys();
            var length_1 = commandKeys.length;
            for (var j = 0; j < length_1; j++)
                this.updateBarItem(bar, commandKeys[j]);
        }
        this.control.permissionsProvider.endUpdateUI();
    };
    BarManager.prototype.updateBarItem = function (bar, commandKey) {
        var command = this.control.commandManager.getCommand(commandKey);
        if (command) {
            var commandState = command.getState();
            bar.setItemVisible(commandKey, commandState.visible);
            if (commandState.visible) {
                bar.setItemEnabled(commandKey, commandState.enabled);
                if (!commandState.denyUpdateValue) {
                    var itemValue = this.getItemValue(commandState.value);
                    if (commandState.items)
                        bar.setItemSubItems(commandKey, commandState.items);
                    bar.setItemValue(commandKey, itemValue, this.getDefaultItemValue(commandState.defaultValue));
                }
            }
        }
    };
    BarManager.prototype.setEnabled = function (enabled) {
        for (var i = 0, bar = void 0; bar = this.bars[i]; i++)
            bar.setEnabled(enabled);
    };
    BarManager.prototype.notifyBarCommandExecuted = function (commandID, parameter) {
        var executeResult = this.control.commandManager.getCommand(commandID).execute(parameter);
        if (!executeResult)
            this.updateItemsState([commandID]);
    };
    BarManager.prototype.notifyBarUpdateRequested = function () {
        this.updateItemsState();
    };
    BarManager.prototype.notifySelectionChanged = function (_selection) {
        this.updateItemsState();
    };
    BarManager.prototype.onUpdateUnlocked = function (occurredEvents) { };
    BarManager.prototype.getItemValue = function (value) {
        return value;
    };
    BarManager.prototype.getDefaultItemValue = function (value) {
        return value;
    };
    return BarManager;
}(batch_updatable_1.BatchUpdatableObject));
exports.BarManager = BarManager;


/***/ }),
/* 337 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.RenderManager = exports.DBL_CLICK_TIMEOUT = exports.LONG_TOUCH_TIMEOUT = void 0;
var Event_1 = __webpack_require__(11);
var evt_1 = __webpack_require__(65);
var dom_1 = __webpack_require__(27);
var point_1 = __webpack_require__(0);
var key_1 = __webpack_require__(25);
var browser_1 = __webpack_require__(18);
var Utils_1 = __webpack_require__(17);
var CanvasItemsManager_1 = __webpack_require__(78);
var ScrollView_1 = __webpack_require__(338);
var Settings_1 = __webpack_require__(28);
var InputManager_1 = __webpack_require__(339);
var CanvasPageManager_1 = __webpack_require__(340);
var CanvasViewManager_1 = __webpack_require__(342);
var CanvasSelectionManager_1 = __webpack_require__(158);
var AutoScrollController_1 = __webpack_require__(344);
var TextMeasurer_1 = __webpack_require__(79);
var RenderHelper_1 = __webpack_require__(15);
var DOMManipulator_1 = __webpack_require__(100);
var Utils_2 = __webpack_require__(3);
var READONLY_CSSCLASS = "dxdi-read-only";
var TOUCH_ACTION_CSSCLASS = "dxdi-touch-action";
exports.LONG_TOUCH_TIMEOUT = 500;
exports.DBL_CLICK_TIMEOUT = 500;
var RenderManager = (function () {
    function RenderManager(parent, events, measurer, settings, scrollView, focusElementsParent) {
        this.moveLocked = false;
        this.lockMouseMoveTimer = -1;
        this.lastClickElement = undefined;
        this.longTouchTimer = undefined;
        this.dblTouchTimer = undefined;
        this.pointers = {};
        var mainElement = RenderHelper_1.RenderHelper.createMainElement(parent);
        var svgElement = RenderHelper_1.RenderHelper.createSvgElement(mainElement);
        this.scroll = scrollView || new ScrollView_1.NativeScrollView(parent);
        this.measurer = measurer;
        this.dom = new DOMManipulator_1.DOMManipulator(this.measurer);
        this.view = new CanvasViewManager_1.CanvasViewManager(this.scroll, svgElement, settings.modelSize, settings.zoomLevel, settings.autoZoom, settings.simpleView, settings.rectangle, this.dom);
        this.input = new InputManager_1.InputManager(mainElement, this.view, events, this.measurer, settings.zoomLevel, focusElementsParent);
        this.items = new CanvasItemsManager_1.CanvasItemsManager(this.view.canvasElement, settings.zoomLevel, this.dom);
        this.page = new CanvasPageManager_1.CanvasPageManager(this.view.pageElement, settings, this.dom);
        this.selection = new CanvasSelectionManager_1.CanvasSelectionManager(this.view.canvasElement, settings.zoomLevel, settings.readOnly, this.dom);
        this.contextMenuEnabled = settings.contextMenuEnabled;
        this.view.onViewChanged.add(this.page);
        this.view.onViewChanged.add(this.items);
        this.view.onViewChanged.add(this.selection);
        this.view.onViewChanged.add(this.input);
        this.autoScroll = new AutoScrollController_1.AutoScrollController(this.scroll, svgElement, this.view, this.dom);
        this.attachEvents(svgElement);
        this.mainElement = mainElement;
        this.svgElement = svgElement;
        this.events = events;
        this.notifyReadOnlyChanged(settings.readOnly);
    }
    RenderManager.prototype.clean = function (removeElement) {
        this.killLockMouseMoveTimer();
        this.clearLastMouseDownEvent();
        this.detachEvents(this.svgElement);
        this.scroll.detachEvents();
        this.input.detachEvents();
        this.dom.cancelAnimation();
        if (removeElement)
            removeElement(this.mainElement);
    };
    RenderManager.prototype.replaceParent = function (parent, scroll) {
        if (this.mainElement && this.mainElement.parentNode !== parent)
            parent.appendChild(this.mainElement);
        if (scroll && scroll !== this.scroll) {
            this.scroll && this.scroll.detachEvents();
            this.scroll = scroll;
        }
        if (this.measurer instanceof TextMeasurer_1.TextMeasurer)
            this.measurer.replaceParent(parent);
    };
    RenderManager.prototype.update = function (saveScrollPosition) {
        this.view.adjust({ horizontal: !saveScrollPosition, vertical: !saveScrollPosition });
        this.page.redraw();
    };
    RenderManager.prototype.onNewModel = function (items) {
        this.measurer.onNewModel(items, this.dom);
    };
    RenderManager.prototype.clear = function () {
        this.items.clear();
        this.selection.clear();
    };
    RenderManager.prototype.attachPointerEvents = function (svgElement) {
        dom_1.DomUtils.addClassName(svgElement, TOUCH_ACTION_CSSCLASS);
        RenderHelper_1.RenderHelper.addEventListener(svgElement, "pointerdown", this.onPointerDownHandler);
        RenderHelper_1.RenderHelper.addEventListener(browser_1.Browser.TouchUI ? svgElement : document, "pointerup", this.onPointerUpHandler);
        RenderHelper_1.RenderHelper.addEventListener(browser_1.Browser.TouchUI ? svgElement : document, "pointermove", this.onPointerMoveHandler);
        RenderHelper_1.RenderHelper.addEventListener(svgElement, "pointercancel", this.onPointerCancelHandler);
        RenderHelper_1.RenderHelper.addEventListener(svgElement, "pointerleave", this.onPointerLeaveHandler);
    };
    RenderManager.prototype.detachPointerEvents = function (svgElement) {
        RenderHelper_1.RenderHelper.removeEventListener(svgElement, "pointerdown", this.onPointerDownHandler);
        RenderHelper_1.RenderHelper.removeEventListener(browser_1.Browser.TouchUI ? svgElement : document, "pointerup", this.onPointerUpHandler);
        RenderHelper_1.RenderHelper.removeEventListener(browser_1.Browser.TouchUI ? svgElement : document, "pointermove", this.onPointerMoveHandler);
        RenderHelper_1.RenderHelper.removeEventListener(svgElement, "pointercancel", this.onPointerCancelHandler);
        RenderHelper_1.RenderHelper.removeEventListener(svgElement, "pointerleave", this.onPointerLeaveHandler);
        dom_1.DomUtils.removeClassName(svgElement, TOUCH_ACTION_CSSCLASS);
    };
    RenderManager.prototype.attachMouseTouchEvents = function (svgElement) {
        RenderHelper_1.RenderHelper.addEventListener(svgElement, this.mouseDownEventName, this.onMouseDownHandler);
        RenderHelper_1.RenderHelper.addEventListener(document, this.mouseMoveEventName, this.onMouseMoveHandler);
        RenderHelper_1.RenderHelper.addEventListener(document, this.mouseUpEventName, this.onMouseUpHandler);
    };
    RenderManager.prototype.detachMouseTouchEvents = function (svgElement) {
        RenderHelper_1.RenderHelper.removeEventListener(svgElement, this.mouseDownEventName, this.onMouseDownHandler);
        RenderHelper_1.RenderHelper.removeEventListener(document, this.mouseMoveEventName, this.onMouseMoveHandler);
        RenderHelper_1.RenderHelper.removeEventListener(document, this.mouseUpEventName, this.onMouseUpHandler);
    };
    RenderManager.prototype.attachEvents = function (svgElement) {
        this.mouseDownEventName = browser_1.Browser.TouchUI ? "touchstart" : "mousedown";
        this.mouseMoveEventName = browser_1.Browser.TouchUI ? "touchmove" : "mousemove";
        this.mouseUpEventName = browser_1.Browser.TouchUI ? "touchend" : "mouseup";
        this.onPointerDownHandler = this.onPointerDown.bind(this);
        this.onPointerUpHandler = this.onPointerUp.bind(this);
        this.onPointerMoveHandler = this.onPointerMove.bind(this);
        this.onPointerCancelHandler = this.onPointerCancel.bind(this);
        this.onPointerLeaveHandler = this.onPointerLeave.bind(this);
        this.onMouseDownHandler = this.onMouseDown.bind(this);
        this.onMouseEnterHandler = this.onMouseEnter.bind(this);
        this.onMouseLeaveHandler = this.onMouseLeave.bind(this);
        this.onMouseWheelHandler = this.onMouseWheel.bind(this);
        this.onMouseDblClickHandler = this.onMouseDblClick.bind(this);
        this.onContextMenuHandler = this.onContextMenu.bind(this);
        this.onMouseMoveHandler = this.onMouseMove.bind(this);
        this.onMouseUpHandler = this.onMouseUp.bind(this);
        this.onWindowResizelHandler = this.onWindowResize.bind(this);
        this.onOrientationChangeHandler = this.onOrientationChange.bind(this);
        this.onMouseClickHandler = this.onMouseClick.bind(this);
        if (Utils_2.EventUtils.isPointerEvents())
            this.attachPointerEvents(svgElement);
        else {
            this.attachMouseTouchEvents(svgElement);
            RenderHelper_1.RenderHelper.addEventListener(svgElement, "mouseenter", this.onMouseEnterHandler);
            RenderHelper_1.RenderHelper.addEventListener(svgElement, "mouseleave", this.onMouseLeaveHandler);
        }
        RenderHelper_1.RenderHelper.addEventListener(svgElement, "wheel", this.onMouseWheelHandler);
        RenderHelper_1.RenderHelper.addEventListener(svgElement, "dblclick", this.onMouseDblClickHandler);
        RenderHelper_1.RenderHelper.addEventListener(svgElement, "click", this.onMouseClickHandler);
        RenderHelper_1.RenderHelper.addEventListener(svgElement, "contextmenu", this.onContextMenuHandler);
        RenderHelper_1.RenderHelper.addEventListener(window, "resize", this.onWindowResizelHandler);
        RenderHelper_1.RenderHelper.addEventListener(window, "orientationchange", this.onOrientationChangeHandler);
        this.input.mouseWheelHandler = this.onMouseWheelHandler;
    };
    RenderManager.prototype.detachEvents = function (svgElement) {
        if (Utils_2.EventUtils.isPointerEvents())
            this.detachPointerEvents(svgElement);
        else {
            this.detachMouseTouchEvents(svgElement);
            RenderHelper_1.RenderHelper.removeEventListener(svgElement, "mouseenter", this.onMouseEnterHandler);
            RenderHelper_1.RenderHelper.removeEventListener(svgElement, "mouseleave", this.onMouseLeaveHandler);
        }
        RenderHelper_1.RenderHelper.removeEventListener(svgElement, "wheel", this.onMouseWheelHandler);
        RenderHelper_1.RenderHelper.removeEventListener(svgElement, "dblclick", this.onMouseDblClickHandler);
        RenderHelper_1.RenderHelper.removeEventListener(svgElement, "contextmenu", this.onContextMenuHandler);
        RenderHelper_1.RenderHelper.removeEventListener(svgElement, "click", this.onMouseClickHandler);
        RenderHelper_1.RenderHelper.removeEventListener(window, "resize", this.onWindowResizelHandler);
        RenderHelper_1.RenderHelper.removeEventListener(window, "orientationchange", this.onOrientationChangeHandler);
    };
    RenderManager.prototype.setPointerPosition = function (evt) {
        this.pointers[evt.pointerId] = {
            clientX: evt.clientX,
            clientY: evt.clientY
        };
    };
    RenderManager.prototype.clearPointerPosition = function (evt) {
        delete this.pointers[evt.pointerId];
    };
    RenderManager.prototype.onPointerDown = function (evt) {
        this.setPointerPosition(evt);
        if (this.getPointerCount() > 2)
            this.pointers = {};
        this.onMouseDown(evt);
    };
    RenderManager.prototype.onPointerUp = function (evt) {
        this.clearPointerPosition(evt);
        this.onMouseUp(evt);
    };
    RenderManager.prototype.onPointerMove = function (evt) {
        if ((browser_1.Browser.TouchUI && !Utils_2.EventUtils.isMousePointer(evt)) || Utils_2.EventUtils.isLeftButtonPressed(evt))
            this.setPointerPosition(evt);
        this.onMouseMove(evt);
    };
    RenderManager.prototype.onPointerCancel = function (evt) {
        this.clearPointerPosition(evt);
    };
    RenderManager.prototype.onPointerLeave = function (evt) {
        if (Utils_2.EventUtils.isMousePointer(evt))
            this.onMouseLeave(evt);
        this.clearPointerPosition(evt);
    };
    RenderManager.prototype.onMouseDown = function (evt) {
        var _this = this;
        this.lockMouseMove();
        this.input.lockFocus();
        this.autoScroll.onMouseDown(evt);
        this.lastDownMouseEvent = this.createDiagramMouseEvent(evt);
        Utils_1.raiseEvent(evt, this.lastDownMouseEvent, function (e) { return _this.events.onMouseDown(e); });
        if (this.events.canFinishTextEditing())
            this.input.captureFocus();
        if (Utils_2.EventUtils.isTouchEvent(evt))
            this.processTouchDown(evt);
        var srcElement = evt_1.EvtUtils.getEventSource(evt);
        var tagName = srcElement && srcElement.tagName;
        if (browser_1.Browser.TouchUI || tagName.toLowerCase() === "img" || tagName.toLowerCase() === "image") {
            evt_1.EvtUtils.preventEventAndBubble(evt);
            return false;
        }
    };
    RenderManager.prototype.onMouseMove = function (evt) {
        var _this = this;
        if (this.moveLocked)
            return;
        this.autoScroll.onMouseMove(evt, function () { return _this.onMouseMoveCore(evt); });
        this.onMouseMoveCore(evt);
        browser_1.Browser.IE && this.lockMouseMove();
        if (Utils_2.EventUtils.isTouchEvent(evt))
            this.processTouchMove(evt);
    };
    RenderManager.prototype.onMouseMoveCore = function (evt) {
        var _this = this;
        Utils_1.raiseEvent(evt, this.createDiagramMouseEvent(evt), function (e) { return _this.events.onMouseMove(e); });
    };
    RenderManager.prototype.onMouseUp = function (evt) {
        var _this = this;
        this.lockMouseMove();
        var mouseEvent = this.createDiagramMouseEvent(evt);
        Utils_1.raiseEvent(evt, mouseEvent, function (e) { return _this.events.onMouseUp(e); });
        this.autoScroll.onMouseUp(evt);
        if (mouseEvent.source.type !== Event_1.MouseEventElementType.Undefined)
            this.input.captureFocus(true);
        if (Utils_2.EventUtils.isTouchEvent(evt))
            this.processTouchUp(evt);
    };
    RenderManager.prototype.onMouseEnter = function (evt) {
        var _this = this;
        this.autoScroll.onMouseEnter(evt);
        Utils_1.raiseEvent(evt, this.createDiagramMouseEvent(evt), function (e) { return _this.events.onMouseEnter(e); });
    };
    RenderManager.prototype.onMouseLeave = function (evt) {
        var _this = this;
        Utils_1.raiseEvent(evt, this.createDiagramMouseEvent(evt), function (e) { return _this.events.onMouseLeave(e); });
    };
    RenderManager.prototype.onMouseDblClick = function (evt) {
        var _this = this;
        Utils_1.raiseEvent(evt, this.createDiagramMouseEvent(evt), function (e) { return _this.events.onDblClick(e); });
    };
    RenderManager.prototype.onMouseClick = function (evt) {
        var _this = this;
        if (!Utils_2.EventUtils.isTouchEvent(evt))
            Utils_1.raiseEvent(evt, this.createActualMouseClickEvent(evt), function (e) { return _this.events.onClick(e); });
        else if (!Utils_2.EventUtils.isMousePointer(evt))
            this.input.captureFocus();
    };
    RenderManager.prototype.createActualMouseClickEvent = function (evt) {
        if (!this.lastDownMouseEvent)
            return this.createDiagramMouseEvent(evt);
        return new Event_1.DiagramMouseEvent(this.lastDownMouseEvent.modifiers, this.lastDownMouseEvent.button, this.lastDownMouseEvent.offsetPoint.clone(), this.lastDownMouseEvent.modelPoint.clone(), this.lastDownMouseEvent.source, this.createDiagramMouseEventTouches(evt));
    };
    RenderManager.prototype.onContextMenu = function (evt) {
        var _this = this;
        Utils_1.raiseEvent(evt, this.createDiagramContextMenuEvent(evt), function (e) { return _this.events.onContextMenu(e); });
        this.input.captureFocus();
        return evt_1.EvtUtils.preventEventAndBubble(evt);
    };
    RenderManager.prototype.processTouchDown = function (evt) {
        var _this = this;
        this.touchDownPoint = this.getTouchPointFromEvent(evt);
        this.resetLongTouch();
        this.longTouchTimer = setTimeout(function () {
            Utils_1.raiseEvent(evt, _this.createDiagramMouseEvent(evt), function (e) { return _this.events.onLongTouch(e); });
            _this.resetLongTouch();
            _this.resetDblClick();
        }, exports.LONG_TOUCH_TIMEOUT);
    };
    RenderManager.prototype.processTouchMove = function (evt) {
        var currentTouchPoint = this.getTouchPointFromEvent(evt);
        if (this.touchDownPoint && currentTouchPoint && (Math.abs(this.touchDownPoint.x - currentTouchPoint.x) > RenderManager.touchPositionLimit ||
            Math.abs(this.touchDownPoint.y - currentTouchPoint.y) > RenderManager.touchPositionLimit)) {
            this.resetLongTouch();
            this.resetDblClick();
        }
    };
    RenderManager.prototype.getPointers = function () {
        var _this = this;
        return Object.keys(this.pointers).map(function (k) { return _this.pointers[k]; });
    };
    RenderManager.prototype.getPointerCount = function () {
        return Object.keys(this.pointers).length;
    };
    RenderManager.prototype.getTouchPointFromEvent = function (evt) {
        var touchPosition;
        var touches = evt["touches"];
        if (touches && touches.length > 0)
            touchPosition = new point_1.Point(touches[0].clientX, touches[0].clientY);
        else {
            var pointers = this.getPointers();
            if (pointers.length)
                touchPosition = new point_1.Point(pointers[0].clientX, pointers[0].clientY);
        }
        return touchPosition;
    };
    RenderManager.prototype.processTouchUp = function (evt) {
        var _this = this;
        if (this.longTouchTimer !== undefined) {
            Utils_1.raiseEvent(evt, this.createDiagramMouseEvent(evt), function (e) { return _this.events.onClick(e); });
            var element = evt_1.EvtUtils.getEventSource(evt);
            if (this.dblTouchTimer !== undefined && this.lastClickElement === element) {
                Utils_1.raiseEvent(evt, this.createDiagramMouseEvent(evt), function (e) { return _this.events.onDblClick(e); });
                this.resetDblClick();
            }
            else {
                this.resetDblClick();
                this.dblTouchTimer = setTimeout(function () { return _this.dblTouchTimer = undefined; }, exports.DBL_CLICK_TIMEOUT);
            }
            this.lastClickElement = element;
        }
        this.resetLongTouch();
        this.touchDownPoint = undefined;
    };
    RenderManager.prototype.resetLongTouch = function () {
        if (this.longTouchTimer !== undefined)
            clearTimeout(this.longTouchTimer);
        this.longTouchTimer = undefined;
    };
    RenderManager.prototype.resetDblClick = function () {
        if (this.dblTouchTimer !== undefined)
            clearTimeout(this.dblTouchTimer);
        this.dblTouchTimer = undefined;
    };
    RenderManager.prototype.onOrientationChange = function () {
        var _this = this;
        setTimeout(function () { return _this.onWindowResize(); }, 100);
    };
    RenderManager.prototype.onWindowResize = function () {
        var resetTo = { horizontal: false, vertical: false };
        if (this.view.autoZoom !== Settings_1.AutoZoomMode.Disabled) {
            resetTo.horizontal = true;
            resetTo.vertical = true;
        }
        else {
            var oldFitInfo = this.view.checkFitToCanvas();
            var newFitInfo = this.view.checkFitToCanvas(this.scroll.getSize());
            resetTo = { horizontal: oldFitInfo.horizontal !== newFitInfo.horizontal || newFitInfo.horizontal, vertical: oldFitInfo.vertical !== newFitInfo.vertical || newFitInfo.vertical };
        }
        this.view.adjust(resetTo);
    };
    RenderManager.prototype.onMouseWheel = function (evt) {
        var _this = this;
        Utils_1.raiseEvent(evt, this.createDiagramWheelEvent(evt), function (e) { return _this.events.onMouseWheel(e); });
    };
    RenderManager.prototype.notifyModelSizeChanged = function (size, offset) {
        this.view.notifyModelSizeChanged(size, offset);
    };
    RenderManager.prototype.notifyModelRectangleChanged = function (rectangle) {
        this.view.notifyModelRectangleChanged(rectangle);
    };
    RenderManager.prototype.notifyReadOnlyChanged = function (readOnly) {
        dom_1.DomUtils.toggleClassName(this.mainElement, READONLY_CSSCLASS, readOnly);
    };
    RenderManager.prototype.notifyDragStart = function (itemKeys) { };
    RenderManager.prototype.notifyDragEnd = function (itemKeys) { };
    RenderManager.prototype.notifyDragScrollStart = function () {
        this.autoScroll.onDragScrollStart();
    };
    RenderManager.prototype.notifyDragScrollEnd = function () {
        this.autoScroll.onDragScrollEnd();
    };
    RenderManager.prototype.notifyToolboxDragStart = function (evt) {
        this.onMouseEnter(evt);
    };
    RenderManager.prototype.notifyToolboxDragEnd = function (evt) {
        if (evt && Utils_2.EventUtils.isPointerEvents())
            this.onMouseUp(evt);
    };
    RenderManager.prototype.notifyToolboxDraggingMouseMove = function (evt) {
        this.onMouseMove(evt);
    };
    RenderManager.prototype.createDiagramMouseEvent = function (evt) {
        var modifiers = key_1.KeyUtils.getKeyModifiers(evt);
        var button = isLeftButtonPressed(evt) ? Event_1.MouseButton.Left : Event_1.MouseButton.Right;
        var offsetPoint = this.getOffsetPointByEvent(evt);
        var modelPoint = this.getModelPoint(offsetPoint);
        var isTouchMode = Utils_2.EventUtils.isTouchEvent(evt);
        var eventSource = this.getEventSource(evt, isTouchMode);
        var touches = this.createDiagramMouseEventTouches(evt);
        return new Event_1.DiagramMouseEvent(modifiers, button, offsetPoint, modelPoint, eventSource, touches, isTouchMode);
    };
    RenderManager.prototype.createDiagramMouseEventTouches = function (evt) {
        var touches = [];
        if (evt["touches"])
            for (var i = 0; i < evt["touches"].length; i++) {
                var x = evt["touches"][i].clientX;
                var y = evt["touches"][i].clientY;
                var offsetPoint = this.getOffsetPointByEventPoint(x, y);
                var modelPoint = this.getModelPoint(offsetPoint);
                touches.push(new Event_1.DiagramMouseEventTouch(offsetPoint, modelPoint));
            }
        else {
            var pointers = this.getPointers();
            for (var i = 0; i < pointers.length; i++) {
                var x = pointers[i].clientX;
                var y = pointers[i].clientY;
                var offsetPoint = this.getOffsetPointByEventPoint(x, y);
                var modelPoint = this.getModelPoint(offsetPoint);
                touches.push(new Event_1.DiagramMouseEventTouch(offsetPoint, modelPoint));
            }
        }
        return touches;
    };
    RenderManager.prototype.createDiagramContextMenuEvent = function (evt) {
        var modifiers = key_1.KeyUtils.getKeyModifiers(evt);
        var eventPoint = new point_1.Point(evt.pageX, evt.pageY);
        var offsetPoint = this.getOffsetPointByEvent(evt);
        var modelPoint = this.getModelPoint(offsetPoint);
        return new Event_1.DiagramContextMenuEvent(modifiers, eventPoint, modelPoint);
    };
    RenderManager.prototype.createDiagramWheelEvent = function (evt) {
        var modifiers = key_1.KeyUtils.getKeyModifiers(evt);
        var offsetPoint = this.getOffsetPointByEvent(evt);
        var modelPoint = this.view.getModelPoint(offsetPoint);
        var eventSource = this.getEventSource(evt);
        var deltaX = evt.deltaX || (evt["originalEvent"] && evt["originalEvent"].deltaX);
        var deltaY = evt.deltaY || (evt["originalEvent"] && evt["originalEvent"].deltaY);
        return new Event_1.DiagramWheelEvent(modifiers, deltaX, deltaY, offsetPoint, modelPoint, eventSource);
    };
    RenderManager.prototype.getEventSource = function (evt, findByPosition) {
        var element = findByPosition ? evt_1.EvtUtils.getEventSourceByPosition(evt) : evt_1.EvtUtils.getEventSource(evt);
        if (this.isDiagramControl(element))
            while (element && !this.isDocumentContainer(element)) {
                var src_1 = Utils_1.RenderUtils.getElementEventData(element);
                if (src_1 !== undefined)
                    return src_1;
                if (this.input.isTextInputElement(element))
                    return new Event_1.MouseEventSource(Event_1.MouseEventElementType.Document);
                element = element.parentNode;
            }
        var src = new Event_1.MouseEventSource(Event_1.MouseEventElementType.Undefined);
        if (element && this.isDocumentContainer(element))
            src.type = Event_1.MouseEventElementType.Background;
        return src;
    };
    RenderManager.prototype.isDiagramControl = function (element) {
        while (element) {
            if (this.isDocumentContainer(element))
                return true;
            element = element.parentNode;
        }
        return false;
    };
    RenderManager.prototype.isDocumentContainer = function (element) {
        return element === this.mainElement;
    };
    RenderManager.prototype.lockMouseMove = function () {
        var _this = this;
        this.moveLocked = true;
        this.lockMouseMoveTimer = setTimeout(function () {
            _this.moveLocked = false;
            _this.lockMouseMoveTimer = -1;
        }, 10);
    };
    RenderManager.prototype.killLockMouseMoveTimer = function () {
        if (this.lockMouseMoveTimer !== -1) {
            clearTimeout(this.lockMouseMoveTimer);
            this.lockMouseMoveTimer = -1;
        }
    };
    RenderManager.prototype.clearLastMouseDownEvent = function () {
        this.lastDownMouseEvent = undefined;
    };
    RenderManager.prototype.getModelPoint = function (offsetPoint) {
        return this.view.getModelPoint(offsetPoint);
    };
    RenderManager.prototype.getOffsetPointByEvent = function (evt) {
        var clientX = evt_1.EvtUtils.getEventX(evt);
        var clientY = evt_1.EvtUtils.getEventY(evt);
        return this.getOffsetPointByEventPoint(clientX, clientY);
    };
    RenderManager.prototype.getOffsetPointByEventPoint = function (clientX, clientY) {
        var scrollContainer = this.scroll.getScrollContainer();
        var containerX = dom_1.DomUtils.getAbsolutePositionX(scrollContainer);
        var containerY = dom_1.DomUtils.getAbsolutePositionY(scrollContainer);
        return new point_1.Point(clientX - containerX, clientY - containerY);
    };
    RenderManager.prototype.getModelPointByEventPoint = function (clientX, clientY) {
        var offsetPoint = this.getOffsetPointByEventPoint(clientX, clientY);
        return this.view.getModelPoint(offsetPoint);
    };
    RenderManager.prototype.getEventPointByModelPoint = function (point) {
        var pos = this.view.getAbsolutePoint(point);
        var scrollContainer = this.scroll.getScrollContainer();
        return new point_1.Point(dom_1.DomUtils.getAbsolutePositionX(scrollContainer) + pos.x, dom_1.DomUtils.getAbsolutePositionY(scrollContainer) + pos.y);
    };
    RenderManager.touchPositionLimit = 4;
    return RenderManager;
}());
exports.RenderManager = RenderManager;
function isLeftButtonPressed(evt) {
    return !browser_1.Browser.MSTouchUI ? Utils_2.EventUtils.isLeftButtonPressed(evt) : evt.button !== 2;
}


/***/ }),
/* 338 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.NativeScrollView = void 0;
var Utils_1 = __webpack_require__(3);
var size_1 = __webpack_require__(2);
var point_1 = __webpack_require__(0);
var dom_1 = __webpack_require__(27);
var RenderHelper_1 = __webpack_require__(15);
var NativeScrollView = (function () {
    function NativeScrollView(mainElement) {
        this.onScroll = new Utils_1.EventDispatcher();
        this.scrollBarWidth = dom_1.DomUtils.getVerticalScrollBarWidth();
        this.mainElement = mainElement;
        this.attachEvents();
    }
    NativeScrollView.prototype.attachEvents = function () {
        var _this = this;
        this.onScrollHandler = function () { return _this.onScroll.raise1(function (l) { return l.notifyScrollChanged(function () { return _this.getScroll(); }); }); };
        RenderHelper_1.RenderHelper.addEventListener(this.mainElement, "scroll", this.onScrollHandler);
    };
    NativeScrollView.prototype.detachEvents = function () {
        RenderHelper_1.RenderHelper.removeEventListener(this.mainElement, "scroll", this.onScrollHandler);
    };
    NativeScrollView.prototype.getScrollContainer = function () {
        return this.mainElement;
    };
    NativeScrollView.prototype.setScroll = function (left, top) {
        var _this = this;
        this.mainElement.style.overflow = "scroll";
        this.mainElement.scrollLeft = left;
        this.mainElement.scrollTop = top;
        this.mainElement.style.overflow = "";
        this.onScroll.raise1(function (l) { return l.notifyScrollChanged(function () { return _this.getScroll(); }); });
    };
    NativeScrollView.prototype.offsetScroll = function (left, top) {
        var _this = this;
        if (left)
            this.mainElement.scrollLeft += left;
        if (top)
            this.mainElement.scrollTop += top;
        this.onScroll.raise1(function (l) { return l.notifyScrollChanged(function () { return _this.getScroll(); }); });
    };
    NativeScrollView.prototype.getScroll = function () {
        return new point_1.Point(this.mainElement.scrollLeft, this.mainElement.scrollTop);
    };
    NativeScrollView.prototype.getSize = function () {
        var boundingRect = this.mainElement.getBoundingClientRect();
        return new size_1.Size(Math.floor(boundingRect.width), Math.floor(boundingRect.height));
    };
    NativeScrollView.prototype.getScrollBarWidth = function () {
        return this.scrollBarWidth;
    };
    return NativeScrollView;
}());
exports.NativeScrollView = NativeScrollView;


/***/ }),
/* 339 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.InputManager = void 0;
var key_1 = __webpack_require__(25);
var dom_1 = __webpack_require__(27);
var Utils_1 = __webpack_require__(17);
var Event_1 = __webpack_require__(11);
var Shape_1 = __webpack_require__(14);
var Connector_1 = __webpack_require__(6);
var evt_1 = __webpack_require__(65);
var ITextMeasurer_1 = __webpack_require__(43);
var browser_1 = __webpack_require__(18);
var unit_converter_1 = __webpack_require__(12);
var RenderHelper_1 = __webpack_require__(15);
var TextUtils_1 = __webpack_require__(64);
var Utils_2 = __webpack_require__(3);
var TEXT_INPUT_CSSCLASS = "dxdi-text-input";
var InputManager = (function () {
    function InputManager(mainElement, layoutPointResolver, eventManager, textMeasurer, actualZoom, focusElementsParent) {
        this.mainElement = mainElement;
        this.layoutPointResolver = layoutPointResolver;
        this.eventManager = eventManager;
        this.textMeasurer = textMeasurer;
        this.actualZoom = actualZoom;
        this.focusElementsParent = focusElementsParent;
        this.focused = false;
        this.focusLocked = false;
        this.createInputElements(this.mainElement, this.focusElementsParent);
    }
    InputManager.prototype.detachEvents = function () {
        this.detachInputElementEvents();
        this.detachTextInputElementEvents();
    };
    InputManager.prototype.isFocused = function () {
        return this.focused;
    };
    InputManager.prototype.captureFocus = function (keepTextInputFocused) {
        if (keepTextInputFocused && document.activeElement === this.textInputElement)
            Utils_2.HtmlFocusUtils.focusWithPreventScroll(this.textInputElement || this.inputElement);
        else
            Utils_2.HtmlFocusUtils.focusWithPreventScroll(this.inputElement);
    };
    InputManager.prototype.setClipboardData = function (data) {
        this.clipboardInputElement.value = data;
        Utils_2.HtmlFocusUtils.focusWithPreventScroll(this.clipboardInputElement);
        this.clipboardInputElement.select();
        document.execCommand("copy");
        this.captureFocus();
    };
    InputManager.prototype.getClipboardData = function (callback) {
        var _this = this;
        if (navigator && navigator["clipboard"])
            navigator["clipboard"].readText().then(function (clipText) {
                callback(clipText);
                _this.captureFocus();
            }).catch(function () {
                callback("");
                _this.captureFocus();
            });
        else if (browser_1.Browser.IE) {
            this.clipboardInputElement.value = "";
            Utils_2.HtmlFocusUtils.focusWithPreventScroll(this.clipboardInputElement);
            this.clipboardInputElement.select();
            document.execCommand("Paste");
            callback(this.clipboardInputElement.value);
            this.captureFocus();
        }
    };
    InputManager.prototype.isPasteSupportedByBrowser = function () {
        return browser_1.Browser.IE || (browser_1.Browser.WebKitFamily && navigator && navigator["clipboard"] !== undefined);
    };
    InputManager.prototype.createInputElements = function (parent, focusElementsParent) {
        this.createFocusInputElement(focusElementsParent || parent);
        this.createTextInputElement(parent);
        this.createClipboardInputElement(focusElementsParent || parent);
        this.attachInputElementEvents();
    };
    InputManager.prototype.setInputElementFocusHandlerMode = function (captureFocus) {
        this.textInputElementContainer.setAttribute("class", "dxdi-text-input-container");
        if (captureFocus)
            this.captureFocus();
    };
    InputManager.prototype.setInputElementTextInputMode = function (text, position, size, style, className, textAngle) {
        this.textInputElementContainer.setAttribute("class", "dxdi-text-input-container " + className);
        this.textInputElement.value = text;
        this.setTextInputElementBounds(position, size, textAngle);
        this.setTextInputElementStyle(style);
        this.updateTextInputPadding();
        var element = this.textInputElement || this.inputElement;
        Utils_2.HtmlFocusUtils.focusWithPreventScroll(element);
        if (element.select)
            element.select();
    };
    InputManager.prototype.setTextInputElementBounds = function (position, size, textAngle) {
        this.savedTextInputPosition = position;
        this.savedTextInputSize = size;
        this.savedTextInputAngle = textAngle;
        var abs = this.layoutPointResolver.getAbsolutePoint(position, true);
        this.textInputElementContainer.style.left = abs.x + "px";
        this.textInputElementContainer.style.top = abs.y + "px";
        this.textInputElementContainer.style.width = size && size.width + "px" || "0px";
        this.textInputElementContainer.style.height = size && size.height + "px" || "0px";
        var transforms = [];
        this.textInputElementContainer.style.transform = "";
        if (this.actualZoom !== 1)
            transforms.push("scale(" + this.actualZoom + ")");
        if (textAngle)
            transforms.push("rotate(" + textAngle + "deg)");
        this.textInputElementContainer.style.transform = transforms.join(" ");
        this.textInputElement.style.width = size && size.width + "px" || "";
        this.textInputElement.style.height = size && size.height + "px" || "auto";
    };
    InputManager.prototype.setTextInputElementStyle = function (style) {
        this.savedTextInputStyle = style;
        Utils_1.RenderUtils.applyStyleToElement(style, this.textInputElement);
    };
    InputManager.prototype.createFocusInputElement = function (parent) {
        this.inputElement = document.createElement("textarea");
        this.inputElement.readOnly = browser_1.Browser.TouchUI;
        this.inputElement.setAttribute("class", "dxdi-focus-input");
        parent.appendChild(this.inputElement);
    };
    InputManager.prototype.attachInputElementEvents = function () {
        this.onInputBlurHandler = this.onInputBlur.bind(this);
        this.onInputFocusHandler = this.onInputFocus.bind(this);
        this.onInputKeyDownHandler = this.onInputKeyDown.bind(this);
        this.onInputKeyPressHandler = this.onInputKeyPress.bind(this);
        this.onInputKeyUpHandler = this.onInputKeyUp.bind(this);
        this.onPasteHandler = this.onPaste.bind(this);
        RenderHelper_1.RenderHelper.addEventListener(this.inputElement, "blur", this.onInputBlurHandler);
        RenderHelper_1.RenderHelper.addEventListener(this.inputElement, "focus", this.onInputFocusHandler);
        RenderHelper_1.RenderHelper.addEventListener(this.inputElement, "keydown", this.onInputKeyDownHandler);
        RenderHelper_1.RenderHelper.addEventListener(this.inputElement, "keypress", this.onInputKeyPressHandler);
        RenderHelper_1.RenderHelper.addEventListener(this.inputElement, "keyup", this.onInputKeyUpHandler);
        RenderHelper_1.RenderHelper.addEventListener(this.inputElement, "paste", this.onPasteHandler);
    };
    InputManager.prototype.detachInputElementEvents = function () {
        RenderHelper_1.RenderHelper.removeEventListener(this.inputElement, "blur", this.onInputBlurHandler);
        RenderHelper_1.RenderHelper.removeEventListener(this.inputElement, "focus", this.onInputFocusHandler);
        RenderHelper_1.RenderHelper.removeEventListener(this.inputElement, "keydown", this.onInputKeyDownHandler);
        RenderHelper_1.RenderHelper.removeEventListener(this.inputElement, "keypress", this.onInputKeyPressHandler);
        RenderHelper_1.RenderHelper.removeEventListener(this.inputElement, "keyup", this.onInputKeyUpHandler);
        RenderHelper_1.RenderHelper.removeEventListener(this.inputElement, "paste", this.onPasteHandler);
    };
    InputManager.prototype.createTextInputElement = function (parent) {
        this.textInputElementContainer = document.createElement("div");
        this.textInputElementContainer.setAttribute("class", "dxdi-text-input-container");
        parent.appendChild(this.textInputElementContainer);
        this.textInputElement = document.createElement("textarea");
        this.textInputElement.setAttribute("class", TEXT_INPUT_CSSCLASS);
        this.attachTextInputElementEvents();
        this.textInputElementContainer.appendChild(this.textInputElement);
    };
    InputManager.prototype.attachTextInputElementEvents = function () {
        this.onTextInputBlurHandler = this.onTextInputBlur.bind(this);
        this.onTextInputFocusHandler = this.onTextInputFocus.bind(this);
        this.onTextInputKeyDownHandler = this.onTextInputKeyDown.bind(this);
        this.onTextInputMouseWheelHandler = this.onTextInputMouseWheel.bind(this);
        this.onTextInputMouseUpHandler = this.onTextInputMouseUp.bind(this);
        this.onTextInputKeyUpHandler = this.onTextInputKeyUp.bind(this);
        this.onTextInputChangeHandler = this.onTextInputChange.bind(this);
        RenderHelper_1.RenderHelper.addEventListener(this.textInputElement, "mousewheel", this.onTextInputMouseWheelHandler);
        RenderHelper_1.RenderHelper.addEventListener(this.textInputElement, "mouseup", this.onTextInputMouseUpHandler);
        RenderHelper_1.RenderHelper.addEventListener(this.textInputElement, "blur", this.onTextInputBlurHandler);
        RenderHelper_1.RenderHelper.addEventListener(this.textInputElement, "focus", this.onTextInputFocusHandler);
        RenderHelper_1.RenderHelper.addEventListener(this.textInputElement, "keydown", this.onTextInputKeyDownHandler);
        RenderHelper_1.RenderHelper.addEventListener(this.textInputElement, "keyup", this.onTextInputKeyUpHandler);
        RenderHelper_1.RenderHelper.addEventListener(this.textInputElement, "change", this.onTextInputChangeHandler);
    };
    InputManager.prototype.detachTextInputElementEvents = function () {
        RenderHelper_1.RenderHelper.removeEventListener(this.textInputElement, "mousewheel", this.onTextInputMouseWheelHandler);
        RenderHelper_1.RenderHelper.removeEventListener(this.textInputElement, "mouseup", this.onTextInputMouseUpHandler);
        RenderHelper_1.RenderHelper.removeEventListener(this.textInputElement, "blur", this.onTextInputBlurHandler);
        RenderHelper_1.RenderHelper.removeEventListener(this.textInputElement, "focus", this.onTextInputFocusHandler);
        RenderHelper_1.RenderHelper.removeEventListener(this.textInputElement, "keydown", this.onTextInputKeyDownHandler);
        RenderHelper_1.RenderHelper.removeEventListener(this.textInputElement, "keyup", this.onTextInputKeyUpHandler);
        RenderHelper_1.RenderHelper.removeEventListener(this.textInputElement, "change", this.onTextInputChangeHandler);
    };
    InputManager.prototype.createClipboardInputElement = function (parent) {
        this.clipboardInputElement = document.createElement("textarea");
        this.clipboardInputElement.setAttribute("class", "dxdi-clipboard-input");
        parent.appendChild(this.clipboardInputElement);
    };
    InputManager.prototype.blurControl = function () {
        if (!this.focusLocked) {
            this.focused = false;
            dom_1.DomUtils.removeClassName(this.mainElement, "focused");
        }
    };
    InputManager.prototype.focusControl = function () {
        this.focused = true;
        this.focusLocked = false;
        dom_1.DomUtils.addClassName(this.mainElement, "focused");
    };
    InputManager.prototype.updateTextInputPadding = function () {
        var text = this.textInputElement.value;
        if (!this.savedTextInputSize) {
            var measureResults = this.textMeasurer.measureWords(" ", this.savedTextInputStyle, ITextMeasurer_1.TextOwner.Connector);
            var textHeight = TextUtils_1.getLineHeight(measureResults) * ((TextUtils_1.textToParagraphs(text).length || 1) + 1);
            this.textInputElement.style.height = Math.ceil(textHeight) + "px";
        }
        else {
            var measureResults = this.textMeasurer.measureWords(text, this.savedTextInputStyle, ITextMeasurer_1.TextOwner.Shape);
            var textHeight = TextUtils_1.getTextHeight(text, this.savedTextInputSize.width, measureResults, true);
            var top_1 = Math.max(0, (this.savedTextInputSize.height - textHeight) * 0.5);
            this.textInputElement.style.paddingTop = Math.ceil(top_1) + "px";
            this.textInputElement.style.height = Math.floor(this.savedTextInputSize.height) + "px";
        }
    };
    InputManager.prototype.onInputBlur = function (evt) {
        var _this = this;
        this.blurControl();
        Utils_1.raiseEvent(evt, this.getDiagramFocusEvent(evt), function (e) { return _this.eventManager.onBlur(e); });
    };
    InputManager.prototype.onInputFocus = function (evt) {
        var _this = this;
        this.focusControl();
        Utils_1.raiseEvent(evt, this.getDiagramFocusEvent(evt), function (e) { return _this.eventManager.onFocus(e); });
    };
    InputManager.prototype.onInputKeyDown = function (evt) {
        var _this = this;
        Utils_1.raiseEvent(evt, this.getDiagramKeyboardEvent(evt), function (e) { return _this.eventManager.onKeyDown(e); });
    };
    InputManager.prototype.onInputKeyPress = function (evt) {
        if (evt.preventDefault && !(browser_1.Browser.Safari && evt.code === "KeyV"))
            evt.preventDefault();
    };
    InputManager.prototype.onInputKeyUp = function (evt) {
        var _this = this;
        Utils_1.raiseEvent(evt, this.getDiagramKeyboardEvent(evt), function (e) { return _this.eventManager.onKeyUp(e); });
    };
    InputManager.prototype.onTextInputBlur = function (evt) {
        var _this = this;
        if (this.eventManager.canFinishTextEditing()) {
            this.blurControl();
            Utils_1.raiseEvent(evt, this.getDiagramFocusEvent(evt), function (e) { return _this.eventManager.onTextInputBlur(e); });
        }
        else {
            var srcElement = evt_1.EvtUtils.getEventSource(evt);
            if (document.activeElement !== srcElement)
                srcElement.focus();
        }
    };
    InputManager.prototype.onTextInputFocus = function (evt) {
        var _this = this;
        this.focusControl();
        Utils_1.raiseEvent(evt, this.getDiagramFocusEvent(evt), function (e) { return _this.eventManager.onTextInputFocus(e); });
    };
    InputManager.prototype.onTextInputKeyDown = function (evt) {
        var _this = this;
        Utils_1.raiseEvent(evt, this.getDiagramKeyboardEvent(evt), function (e) { return _this.eventManager.onTextInputKeyDown(e); });
    };
    InputManager.prototype.onTextInputKeyUp = function (evt) {
        this.updateTextInputPadding();
    };
    InputManager.prototype.onTextInputChange = function (evt) {
        this.updateTextInputPadding();
    };
    InputManager.prototype.onPaste = function (evt) {
        var _this = this;
        Utils_1.raiseEvent(evt, this.getDiagramClipboardEvent(evt), function (e) { return _this.eventManager.onPaste(e); });
    };
    InputManager.prototype.onTextInputMouseWheel = function (evt) {
        this.mouseWheelHandler && this.mouseWheelHandler(evt);
    };
    InputManager.prototype.onTextInputMouseUp = function (evt) {
        if (evt.stopPropagation)
            evt.stopPropagation();
        evt_1.EvtUtils.cancelBubble(evt);
    };
    InputManager.prototype.getDiagramKeyboardEvent = function (evt) {
        return new Event_1.DiagramKeyboardEvent(key_1.KeyUtils.getKeyModifiers(evt), key_1.KeyUtils.getEventKeyCode(evt), this.textInputElement.value);
    };
    InputManager.prototype.getTextInputElementValue = function () {
        return this.textInputElement.value;
    };
    InputManager.prototype.getDiagramFocusEvent = function (evt) {
        return new Event_1.DiagramFocusEvent(evt.target.value);
    };
    InputManager.prototype.getDiagramClipboardEvent = function (evt) {
        var clipboardData;
        var evtClipboardData = evt.clipboardData || (evt["originalEvent"] && evt["originalEvent"].clipboardData);
        if (evtClipboardData !== undefined)
            clipboardData = evtClipboardData.getData("text/plain");
        else
            clipboardData = window["clipboardData"].getData("Text");
        return new Event_1.DiagramClipboardEvent(clipboardData);
    };
    InputManager.prototype.isTextInputElement = function (element) {
        return typeof element.className === "string" && element.className.indexOf(TEXT_INPUT_CSSCLASS) > -1;
    };
    InputManager.prototype.lockFocus = function () {
        var _this = this;
        this.focusLocked = true;
        setTimeout(function () { return _this.focusLocked = false; }, 10);
    };
    InputManager.prototype.notifyViewAdjusted = function (canvasOffset) { };
    InputManager.prototype.notifyActualZoomChanged = function (actualZoom) {
        this.actualZoom = actualZoom;
        if (this.savedTextInputPosition && this.savedTextInputSize)
            this.setTextInputElementBounds(this.savedTextInputPosition, this.savedTextInputSize, this.savedTextInputAngle);
    };
    InputManager.prototype.notifyTextInputStart = function (item, text, position, size) {
        var className = "";
        var textAngle;
        if (item instanceof Shape_1.Shape) {
            className = "shape-text";
            textAngle = item.textAngle;
        }
        else if (item instanceof Connector_1.Connector)
            className = "connector-text";
        size = size && size.clone().applyConverter(unit_converter_1.UnitConverter.twipsToPixels);
        this.setInputElementTextInputMode(text, position, size, item.styleText, className, textAngle);
    };
    InputManager.prototype.notifyTextInputEnd = function (item, captureFocus) {
        this.setInputElementFocusHandlerMode(captureFocus);
    };
    InputManager.prototype.notifyTextInputPermissionsCheck = function (item, allowed) { };
    return InputManager;
}());
exports.InputManager = InputManager;


/***/ }),
/* 340 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.CanvasPageManager = void 0;
var Style_1 = __webpack_require__(26);
var RectaglePrimitive_1 = __webpack_require__(21);
var PathPrimitive_1 = __webpack_require__(5);
var PatternPrimitive_1 = __webpack_require__(341);
var ClipPathPrimitive_1 = __webpack_require__(56);
var CanvasManagerBase_1 = __webpack_require__(42);
var size_1 = __webpack_require__(2);
var point_1 = __webpack_require__(0);
var Utils_1 = __webpack_require__(17);
var color_1 = __webpack_require__(22);
var unit_converter_1 = __webpack_require__(12);
var GRID_PAGES_LINEWIDTH = 2;
var CanvasPageManager = (function (_super) {
    __extends(CanvasPageManager, _super);
    function CanvasPageManager(parent, settings, dom) {
        var _this = _super.call(this, settings.zoomLevel, dom) || this;
        _this.snapPoint = new point_1.Point(0, 0);
        _this.gridPatternId = Utils_1.RenderUtils.generateSvgElementId("gridPattern");
        _this.pagesGridPatternId = Utils_1.RenderUtils.generateSvgElementId("pagesGridPattern");
        _this.pagesGridClipId = Utils_1.RenderUtils.generateSvgElementId("pagesGridClip");
        _this.pageColor = settings.pageColor;
        _this.modelSize = settings.modelSize;
        _this.simpleView = settings.simpleView;
        _this.gridSize = settings.gridSize;
        _this.gridVisible = settings.gridVisible;
        _this.pageSize = settings.pageLandscape ? new size_1.Size(settings.pageSize.height, settings.pageSize.width) : settings.pageSize;
        _this.canvasViewOffset = new point_1.Point(0, 0);
        _this.initContainers(parent);
        return _this;
    }
    CanvasPageManager.prototype.initContainers = function (parent) {
        this.backgroundContainer = parent;
    };
    CanvasPageManager.prototype.redraw = function () {
        this.redrawPage(this.pageColor);
        this.redrawGrid();
    };
    CanvasPageManager.prototype.redrawPage = function (color) {
        var style = new Style_1.Style();
        style["fill"] = color_1.ColorUtils.colorToHash(color);
        this.getOrCreateElement("page-bg", new RectaglePrimitive_1.RectanglePrimitive(0, 0, "100%", "100%", style, "page"), this.backgroundContainer);
        this.createTextFloodFilter("page-bg-textflood-filter", this.backgroundContainer, color);
    };
    CanvasPageManager.prototype.redrawGrid = function () {
        this.updateGridElements();
        this.updatePagesGridElements();
    };
    CanvasPageManager.prototype.getGridRectElement = function (primitive) {
        if (this.gridRectElement === undefined)
            this.gridRectElement = this.createPrimitiveElement(primitive, this.backgroundContainer);
        return this.gridRectElement;
    };
    CanvasPageManager.prototype.getGridPatternElement = function (primitive) {
        if (this.gridPatternElement === undefined)
            this.gridPatternElement = this.createPrimitiveElement(primitive, this.backgroundContainer);
        return this.gridPatternElement;
    };
    CanvasPageManager.prototype.updateGridElements = function () {
        var _this = this;
        var gridRectPrimitive = new RectaglePrimitive_1.RectanglePrimitive("0", "0", "100%", "100%", null, "grid", null, function (element) {
            element.style.setProperty("fill", Utils_1.RenderUtils.getUrlPathById(_this.gridPatternId));
        });
        var rectEl = this.getGridRectElement(gridRectPrimitive);
        if (!this.gridVisible)
            rectEl.style.display = "none";
        else {
            rectEl.style.display = "";
            this.changePrimitiveElement(gridRectPrimitive, rectEl);
            var absGridSize_1 = unit_converter_1.UnitConverter.twipsToPixelsF(this.gridSize) * this.actualZoom;
            var sizes = [0, 1, 2, 3, 4].map(function (i) { return Math.round(absGridSize_1 * i); });
            var outerPathCommands = [
                new PathPrimitive_1.PathPrimitiveMoveToCommand(sizes[4].toString(), "0"),
                new PathPrimitive_1.PathPrimitiveLineToCommand(sizes[4].toString(), sizes[4].toString()),
                new PathPrimitive_1.PathPrimitiveLineToCommand("0", sizes[4].toString())
            ];
            var innerPathCommands = [];
            for (var i = 1; i <= 3; i++) {
                innerPathCommands.push(new PathPrimitive_1.PathPrimitiveMoveToCommand(sizes[i].toString(), "0"));
                innerPathCommands.push(new PathPrimitive_1.PathPrimitiveLineToCommand(sizes[i].toString(), sizes[4].toString()));
            }
            for (var i = 1; i <= 3; i++) {
                innerPathCommands.push(new PathPrimitive_1.PathPrimitiveMoveToCommand("0", sizes[i].toString()));
                innerPathCommands.push(new PathPrimitive_1.PathPrimitiveLineToCommand(sizes[4].toString(), sizes[i].toString()));
            }
            var commonSize = absGridSize_1 * 4;
            var canvasViewOffset = this.simpleView ? this.canvasViewOffset : point_1.Point.zero();
            var gridPatternPrimitive = new PatternPrimitive_1.PatternPrimitive(this.gridPatternId, [
                this.createGridPathPrimitive(outerPathCommands, "grid-outer-line"),
                this.createGridPathPrimitive(innerPathCommands, "grid-inner-line")
            ], this.createGridPatternPrimitivePosition(canvasViewOffset.x, this.snapPoint.x, commonSize), this.createGridPatternPrimitivePosition(canvasViewOffset.y, this.snapPoint.y, commonSize), commonSize.toString(), commonSize.toString());
            this.changePrimitiveElement(gridPatternPrimitive, this.getGridPatternElement(gridPatternPrimitive));
        }
    };
    CanvasPageManager.prototype.createGridPatternPrimitivePosition = function (offset, coord, commonSize) {
        return (((offset + coord * this.actualZoom) % commonSize - commonSize) % commonSize).toString();
    };
    CanvasPageManager.prototype.createGridPathPrimitive = function (commands, className) {
        return new PathPrimitive_1.PathPrimitive(commands, Style_1.StrokeStyle.default1pxNegativeOffsetInstance, className);
    };
    CanvasPageManager.prototype.getPagesGridRectElement = function (primitive) {
        return this.getOrCreateElement("grid-pages-rect", primitive, this.backgroundContainer);
    };
    CanvasPageManager.prototype.getPagesGridClipPathElement = function (primitive) {
        if (this.pagesGridClipPathElement === undefined)
            this.pagesGridClipPathElement = this.createPrimitiveElement(primitive, this.backgroundContainer);
        return this.pagesGridClipPathElement;
    };
    CanvasPageManager.prototype.getPagesGridPatternElement = function (primitive) {
        if (this.pagesGridPatternElement === undefined)
            this.pagesGridPatternElement = this.createPrimitiveElement(primitive, this.backgroundContainer);
        return this.pagesGridPatternElement;
    };
    CanvasPageManager.prototype.updatePagesGridElements = function () {
        var _this = this;
        var pageAbsSize = this.getAbsoluteSize(this.pageSize);
        var rectPrimitive = new RectaglePrimitive_1.RectanglePrimitive("0", "0", "100%", "100%", null, "grid-page", this.pagesGridClipId, function (element) {
            element.style.setProperty("fill", Utils_1.RenderUtils.getUrlPathById(_this.pagesGridPatternId));
            element.style.setProperty("display", _this.simpleView ? "none" : "");
        });
        this.getPagesGridRectElement(rectPrimitive);
        if (!this.simpleView) {
            var modelSize = this.modelSize.clone().multiply(this.actualZoom, this.actualZoom);
            var pageGridPathCommands = [
                new PathPrimitive_1.PathPrimitiveMoveToCommand((pageAbsSize.width - GRID_PAGES_LINEWIDTH / 2).toString(), "0"),
                new PathPrimitive_1.PathPrimitiveLineToCommand((pageAbsSize.width - GRID_PAGES_LINEWIDTH / 2).toString(), (pageAbsSize.height - GRID_PAGES_LINEWIDTH / 2).toString()),
                new PathPrimitive_1.PathPrimitiveLineToCommand("0", (pageAbsSize.height - GRID_PAGES_LINEWIDTH / 2).toString())
            ];
            var pagesGridPatternPrimitive = new PatternPrimitive_1.PatternPrimitive(this.pagesGridPatternId, [
                new PathPrimitive_1.PathPrimitive(pageGridPathCommands, null, "pages-grid-line")
            ], 0, 0, pageAbsSize.width.toString(), pageAbsSize.height.toString());
            this.changePrimitiveElement(pagesGridPatternPrimitive, this.getPagesGridPatternElement(pagesGridPatternPrimitive));
            var pagesGridClipPathPrimitive = new ClipPathPrimitive_1.ClipPathPrimitive(this.pagesGridClipId, [
                new RectaglePrimitive_1.RectanglePrimitive(0, 0, (unit_converter_1.UnitConverter.twipsToPixelsF(modelSize.width) - GRID_PAGES_LINEWIDTH * 2).toString(), (unit_converter_1.UnitConverter.twipsToPixelsF(modelSize.height) - GRID_PAGES_LINEWIDTH * 2).toString())
            ]);
            this.changePrimitiveElement(pagesGridClipPathPrimitive, this.getPagesGridClipPathElement(pagesGridClipPathPrimitive));
        }
    };
    CanvasPageManager.prototype.notifyModelSizeChanged = function (size, offset) {
        this.modelSize = size.clone();
        this.redraw();
    };
    CanvasPageManager.prototype.notifyModelRectangleChanged = function (rectangle) { };
    CanvasPageManager.prototype.notifySnapPointPositionChanged = function (point) {
        this.snapPoint = point.clone().applyConverter(unit_converter_1.UnitConverter.twipsToPixelsF);
        this.redrawGrid();
    };
    CanvasPageManager.prototype.notifyPageColorChanged = function (color) {
        this.pageColor = color;
        this.redrawPage(this.pageColor);
    };
    CanvasPageManager.prototype.notifyModelChanged = function (changes) { };
    CanvasPageManager.prototype.notifyPageSizeChanged = function (pageSize, pageLandscape) {
        this.pageSize = pageLandscape ? new size_1.Size(pageSize.height, pageSize.width) : pageSize.clone();
        this.redraw();
    };
    CanvasPageManager.prototype.notifyActualZoomChanged = function (actualZoom) {
        this.actualZoom = actualZoom;
        this.redraw();
    };
    CanvasPageManager.prototype.notifyViewAdjusted = function (canvasViewOffset) {
        if (!this.canvasViewOffset.equals(canvasViewOffset)) {
            this.canvasViewOffset = canvasViewOffset;
            if (this.simpleView)
                this.redraw();
        }
    };
    CanvasPageManager.prototype.notifyViewChanged = function (simpleView) {
        this.simpleView = simpleView;
        this.redraw();
    };
    CanvasPageManager.prototype.notifyGridChanged = function (showGrid, gridSize) {
        this.gridVisible = showGrid;
        this.gridSize = gridSize;
        this.redraw();
    };
    return CanvasPageManager;
}(CanvasManagerBase_1.CanvasManagerBase));
exports.CanvasPageManager = CanvasPageManager;


/***/ }),
/* 341 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.PatternPrimitive = void 0;
var RenderHelper_1 = __webpack_require__(15);
var Primitive_1 = __webpack_require__(24);
var PatternPrimitive = (function (_super) {
    __extends(PatternPrimitive, _super);
    function PatternPrimitive(id, children, x, y, width, height, style) {
        var _this = _super.call(this, style) || this;
        _this.id = id;
        _this.x = x;
        _this.y = y;
        _this.width = width;
        _this.height = height;
        _this.children = children;
        return _this;
    }
    PatternPrimitive.prototype.createMainElement = function () {
        var element = document.createElementNS(RenderHelper_1.svgNS, "pattern");
        element.setAttribute("patternUnits", "userSpaceOnUse");
        element.setAttribute("id", this.id);
        return element;
    };
    PatternPrimitive.prototype.applyElementProperties = function (element, measurer) {
        this.setUnitAttribute(element, "x", this.x);
        this.setUnitAttribute(element, "y", this.y);
        this.setUnitAttribute(element, "width", this.width);
        this.setUnitAttribute(element, "height", this.height);
        this.setPositionCorrectionAttribute(element);
        _super.prototype.applyElementProperties.call(this, element, measurer);
    };
    return PatternPrimitive;
}(Primitive_1.SvgPrimitive));
exports.PatternPrimitive = PatternPrimitive;


/***/ }),
/* 342 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.CanvasViewManager = exports.CROP_OFFSET = exports.CANVAS_SCROLL_PADDING = exports.CANVAS_MIN_PADDING = void 0;
var CanvasManagerBase_1 = __webpack_require__(42);
var Settings_1 = __webpack_require__(28);
var Utils_1 = __webpack_require__(3);
var offsets_1 = __webpack_require__(87);
var size_1 = __webpack_require__(2);
var point_1 = __webpack_require__(0);
var GroupPrimitive_1 = __webpack_require__(39);
var ClipPathPrimitive_1 = __webpack_require__(56);
var RectaglePrimitive_1 = __webpack_require__(21);
var Utils_2 = __webpack_require__(17);
var ShadowFilterPrimitive_1 = __webpack_require__(343);
var Style_1 = __webpack_require__(26);
var dom_1 = __webpack_require__(27);
var unit_converter_1 = __webpack_require__(12);
exports.CANVAS_MIN_PADDING = 8;
exports.CANVAS_SCROLL_PADDING = 18;
exports.CROP_OFFSET = 40;
var DRAG_SCROLL_CSSCLASS = "dxdi-drag-scroll";
var DRAG_ITEM_CSSCLASS = "dxdi-drag-item";
var CanvasViewManager = (function (_super) {
    __extends(CanvasViewManager, _super);
    function CanvasViewManager(scrollView, svgElement, modelSize, fixedZoomLevel, autoZoom, simpleView, rectangle, dom) {
        var _this = _super.call(this, fixedZoomLevel, dom) || this;
        _this.svgElement = svgElement;
        _this.paddings = new offsets_1.Offsets(0, 0, 0, 0);
        _this.scroll = new point_1.Point(0, 0);
        _this.crop = offsets_1.Offsets.empty();
        _this.lockAutoZoom = false;
        _this.autoScrollLocker = 0;
        _this.pageClipPathId = Utils_2.RenderUtils.generateSvgElementId("page-clip");
        _this.pageShadowId = Utils_2.RenderUtils.generateSvgElementId("page-shadow");
        _this.onViewChanged = new Utils_1.EventDispatcher();
        scrollView.onScroll.add(_this);
        modelSize = modelSize.clone().applyConverter(unit_converter_1.UnitConverter.twipsToPixelsF);
        _this.scrollView = scrollView;
        _this.modelSize = modelSize;
        _this.simpleView = simpleView;
        _this.fixedZoomLevel = fixedZoomLevel;
        _this.autoZoom = autoZoom;
        _this.crop = _this.rectangleToCrop(rectangle, modelSize);
        _this.updateElements(modelSize.clone().multiply(fixedZoomLevel, fixedZoomLevel), point_1.Point.zero(), simpleView);
        _this.getOrCreateElement("shadow", new ShadowFilterPrimitive_1.ShadowFilterPrimitive(_this.pageShadowId), _this.svgElement);
        _this.containerSize = scrollView.getSize();
        return _this;
    }
    CanvasViewManager.prototype.adjust = function (resetPaddings, saveVerticalScroll) {
        var offset;
        if (!resetPaddings) {
            resetPaddings = { vertical: false, horizontal: false };
            offset = offsets_1.Offsets.empty();
        }
        this.containerSize = this.scrollView.getSize();
        this.adjustCore(this.modelSize, this.fixedZoomLevel, this.autoZoom, this.simpleView, this.crop, resetPaddings, this.containerSize, offset, saveVerticalScroll);
        this.tryNormalizePaddings();
    };
    CanvasViewManager.prototype.notifyModelSizeChanged = function (size, offset) {
        size = size.clone().applyConverter(unit_converter_1.UnitConverter.twipsToPixelsF);
        var resetPaddings = { horizontal: !offset, vertical: !offset };
        this.adjustCore(size, this.fixedZoomLevel, this.autoZoom, this.simpleView, this.crop, resetPaddings, this.containerSize, offset && offset.clone().applyConverter(unit_converter_1.UnitConverter.twipsToPixelsF));
        this.modelSize = size;
    };
    CanvasViewManager.prototype.notifyModelRectangleChanged = function (rectangle) {
        var crop = this.rectangleToCrop(rectangle, this.modelSize);
        if (!this.crop || !this.crop.equals(crop)) {
            if (this.simpleView)
                this.adjustCore(this.modelSize, this.fixedZoomLevel, this.autoZoom, this.simpleView, crop, { horizontal: false, vertical: false }, this.containerSize, offsets_1.Offsets.empty());
            this.crop = crop;
        }
    };
    CanvasViewManager.prototype.notifySnapPointPositionChanged = function (point) { };
    CanvasViewManager.prototype.notifyZoomChanged = function (fixedZoomLevel, autoZoom) {
        this.adjustCore(this.modelSize, fixedZoomLevel, autoZoom, this.simpleView, this.crop, {
            horizontal: false,
            vertical: false
        }, this.containerSize);
        this.fixedZoomLevel = fixedZoomLevel;
        this.autoZoom = autoZoom;
    };
    CanvasViewManager.prototype.notifyViewChanged = function (simpleView) {
        this.adjustCore(this.modelSize, this.fixedZoomLevel, this.autoZoom, simpleView, this.crop, { vertical: true, horizontal: true }, this.containerSize);
        this.simpleView = simpleView;
    };
    CanvasViewManager.prototype.notifyGridChanged = function (showGrid, gridSize) { };
    CanvasViewManager.prototype.notifyDragStart = function (itemKeys) {
        this.lockAutoZoom = true;
        dom_1.DomUtils.addClassName(this.svgElement, DRAG_ITEM_CSSCLASS);
    };
    CanvasViewManager.prototype.notifyDragEnd = function (itemKeys) {
        this.lockAutoZoom = false;
        dom_1.DomUtils.removeClassName(this.svgElement, DRAG_ITEM_CSSCLASS);
        this.adjustAfterDragEnd();
    };
    CanvasViewManager.prototype.adjustAfterDragEnd = function () {
        if (this.autoZoom && !this.autoZoomLocked)
            this.adjust({ horizontal: true, vertical: this.autoZoom === Settings_1.AutoZoomMode.FitContent }, this.autoZoom === Settings_1.AutoZoomMode.FitToWidth);
    };
    CanvasViewManager.prototype.notifyShowContextToolbox = function () {
        this.autoZoomLocked = true;
    };
    CanvasViewManager.prototype.notifyHideContextToolbox = function () {
        this.autoZoomLocked = false;
        this.adjustAfterDragEnd();
    };
    CanvasViewManager.prototype.notifyDragScrollStart = function () {
        dom_1.DomUtils.addClassName(this.svgElement, DRAG_SCROLL_CSSCLASS);
    };
    CanvasViewManager.prototype.notifyDragScrollEnd = function () {
        dom_1.DomUtils.removeClassName(this.svgElement, DRAG_SCROLL_CSSCLASS);
    };
    CanvasViewManager.prototype.notifyScrollChanged = function (getScroll) {
        this.scroll = getScroll();
    };
    CanvasViewManager.prototype.checkFitToCanvas = function (containerSize) {
        containerSize = containerSize || this.containerSize;
        var scrollSize = this.scrollView.getScrollBarWidth();
        containerSize = containerSize.clone().offset(-exports.CANVAS_MIN_PADDING * 2, -exports.CANVAS_MIN_PADDING * 2).nonNegativeSize();
        var modelAbsSize = this.getActualModelSizeWithoutZoom(this.modelSize, this.simpleView, this.crop).clone().multiply(this.actualZoom, this.actualZoom);
        var scrollbars = this.checkScrollBars(containerSize, scrollSize, modelAbsSize, offsets_1.Offsets.empty());
        containerSize = containerSize.clone().offset(scrollbars.vertical ? -scrollSize : 0, scrollbars.horizontal ? -scrollSize : 0).nonNegativeSize();
        return {
            vertical: containerSize.height >= modelAbsSize.height,
            horizontal: containerSize.width >= modelAbsSize.width
        };
    };
    CanvasViewManager.prototype.rectangleToCrop = function (rectangle, modelSize) {
        var absRectangle = rectangle.clone().applyConverter(unit_converter_1.UnitConverter.twipsToPixelsF);
        return new offsets_1.Offsets(this.correctCrop(absRectangle.x), this.correctCrop(modelSize.width - absRectangle.right), this.correctCrop(absRectangle.y), this.correctCrop(modelSize.height - absRectangle.bottom));
    };
    CanvasViewManager.prototype.correctCrop = function (newVal) {
        return exports.CROP_OFFSET * Math.floor(newVal / exports.CROP_OFFSET);
    };
    CanvasViewManager.prototype.setActualZoom = function (actualZoom) {
        if (this.actualZoom !== actualZoom) {
            this.actualZoom = actualZoom;
            this.raiseActualZoomChanged();
        }
    };
    CanvasViewManager.prototype.getActualAutoZoomLevel = function (autoZoom) {
        if (autoZoom === Settings_1.AutoZoomMode.Disabled)
            return this.actualZoom;
        var containerSize = this.containerSize;
        var scrollbarWidth = this.scrollView.getScrollBarWidth();
        var actualModelSizeWithoutZoom = this.getActualModelSizeWithoutZoom(this.modelSize, this.simpleView, this.crop);
        return this.getActualAutoZoom(containerSize, scrollbarWidth, actualModelSizeWithoutZoom, autoZoom);
    };
    CanvasViewManager.prototype.getActualZoom = function (containerSize, scrollbarWidth, actualModelSizeWithoutZoom, fixedZoom, autoZoom) {
        return this.lockAutoZoom ? this.actualZoom :
            autoZoom === Settings_1.AutoZoomMode.Disabled ? fixedZoom : this.getActualAutoZoom(containerSize, scrollbarWidth, actualModelSizeWithoutZoom, autoZoom);
    };
    CanvasViewManager.prototype.getActualAutoZoom = function (containerSize, scrollbarWidth, actualModelSizeWithoutZoom, autoZoom) {
        if (containerSize.width === 0 || containerSize.height === 0)
            return 1;
        if (autoZoom === Settings_1.AutoZoomMode.FitContent)
            return Math.min((containerSize.width - exports.CANVAS_MIN_PADDING * 2) / actualModelSizeWithoutZoom.width, (containerSize.height - exports.CANVAS_MIN_PADDING * 2) / actualModelSizeWithoutZoom.height, 1);
        return Math.min((containerSize.width - exports.CANVAS_MIN_PADDING * 2 - scrollbarWidth) / actualModelSizeWithoutZoom.width, 1);
    };
    CanvasViewManager.prototype.raiseActualZoomChanged = function () {
        var _this = this;
        this.onViewChanged.raise1(function (l) { return l.notifyActualZoomChanged(_this.actualZoom); });
    };
    CanvasViewManager.prototype.tryNormalizePaddings = function () {
        var scrollbarWidth = this.scrollView.getScrollBarWidth();
        var actualModelSize = this.getActualModelSizeWithoutZoom(this.modelSize, this.simpleView, this.crop).clone().multiply(this.actualZoom, this.actualZoom);
        var translate = new point_1.Point(this.paddings.left, this.paddings.top);
        var currentTail = new size_1.Size(this.paddings.right, this.paddings.bottom);
        var tail = this.getTailSpace(translate, this.scroll, actualModelSize, this.containerSize, scrollbarWidth);
        if (!tail.equals(currentTail))
            this.applyChanges(new offsets_1.Offsets(translate.x, tail.width, translate.y, tail.height), actualModelSize, this.simpleView, this.crop.clone().multiply(this.actualZoom));
    };
    CanvasViewManager.prototype.scrollBy = function (offset) {
        var _a, _b, _c;
        var scroll = this.scroll;
        var containerSize = this.containerSize;
        var scrollbarWidth = this.scrollView.getScrollBarWidth();
        var actualModelSize = this.getActualModelSizeWithoutZoom(this.modelSize, this.simpleView, this.crop).clone().multiply(this.actualZoom, this.actualZoom);
        var scrollbars = this.checkScrollBars(containerSize, scrollbarWidth, actualModelSize, this.paddings);
        var translate = new point_1.Point(this.paddings.left, this.paddings.top);
        var tail = new size_1.Size(this.paddings.right, this.paddings.bottom);
        (_a = this.changeScrollByOffset(translate, scroll, tail, actualModelSize, offset, containerSize, scrollbars), scroll = _a.scroll, offset = _a.offset);
        (_b = this.changeTranslateByOffset(translate, tail, offset, scrollbars), translate = _b.translate, offset = _b.offset);
        (_c = this.cropHiddenHead(translate, scroll), translate = _c.translate, scroll = _c.scroll);
        tail = this.getTailSpace(translate, scroll, actualModelSize, containerSize, scrollbarWidth);
        this.applyChanges(new offsets_1.Offsets(translate.x, tail.width, translate.y, tail.height), actualModelSize, this.simpleView, this.crop.clone().multiply(this.actualZoom), scroll);
        return offset;
    };
    CanvasViewManager.prototype.changeScrollByOffset = function (curTranslate, curScroll, curTail, modelSize, curOffset, containerSize, scrollbars) {
        var scroll = curScroll.clone();
        var offset = curOffset.clone();
        if (curOffset.x && scrollbars.horizontal)
            scroll.x -= (offset.x = -this.getScrollDeltaByOffset(curOffset.x, curScroll.x, curTranslate.x + modelSize.width + curTail.width, containerSize.width, scrollbars.vertical));
        if (curOffset.y && scrollbars.vertical)
            scroll.y -= (offset.y = -this.getScrollDeltaByOffset(curOffset.y, curScroll.y, curTranslate.y + modelSize.height + curTail.height, containerSize.height, scrollbars.horizontal));
        return { scroll: scroll, offset: offset };
    };
    CanvasViewManager.prototype.changeTranslateByOffset = function (curTranslate, curTail, curOffset, scrollbars) {
        var translate = curTranslate.clone();
        var offset = curOffset.clone();
        if (curOffset.x && !scrollbars.horizontal)
            translate.x += (offset.x = this.getTranslateDeltaByOffset(curOffset.x, translate.x, curTail.width));
        if (curOffset.y && !scrollbars.vertical)
            translate.y += (offset.y = this.getTranslateDeltaByOffset(curOffset.y, translate.y, curTail.height));
        return { translate: translate, offset: offset };
    };
    CanvasViewManager.prototype.getScrollDeltaByOffset = function (offset, scroll, commonWidth, containerWidth, hasScrollbar) {
        if (offset > 0)
            return -Math.min(scroll, offset);
        var maxScroll = commonWidth - (containerWidth - (hasScrollbar ? this.scrollView.getScrollBarWidth() : 0));
        return Math.min(maxScroll - scroll, -offset);
    };
    CanvasViewManager.prototype.getTranslateDeltaByOffset = function (offset, headPadding, tailPadding) {
        if (!offset)
            return 0;
        return offset < 0 ?
            -Math.min(headPadding - exports.CANVAS_MIN_PADDING, -offset) :
            Math.min(tailPadding - exports.CANVAS_MIN_PADDING, offset);
    };
    CanvasViewManager.prototype.getActualModelSizeWithoutZoom = function (originModelSize, simpleView, crop) {
        return simpleView && crop ? originModelSize.clone().offset(-crop.horizontal, -crop.vertical).nonNegativeSize() : originModelSize;
    };
    CanvasViewManager.prototype.setScrollTo = function (modelPoint, offsetPoint) {
        var containerSize = this.containerSize;
        var shift = this.getVisibileAreaAbsShift();
        var absPoint = modelPoint
            .clone().applyConverter(unit_converter_1.UnitConverter.twipsToPixelsF)
            .clone().multiply(this.actualZoom, this.actualZoom)
            .clone().offset(shift.x, shift.y);
        var scroll = this.scroll;
        if (!offsetPoint) {
            if (absPoint.x < 0)
                scroll.x += absPoint.x - exports.CANVAS_MIN_PADDING;
            if (absPoint.y < 0)
                scroll.y += absPoint.y - exports.CANVAS_MIN_PADDING;
            if (absPoint.x > containerSize.width)
                scroll.x += (absPoint.x - containerSize.width + exports.CANVAS_MIN_PADDING);
            if (absPoint.y > containerSize.height)
                scroll.y += (absPoint.y - containerSize.height + exports.CANVAS_MIN_PADDING);
        }
        else {
            scroll.x += absPoint.x - offsetPoint.x;
            scroll.y += absPoint.y - offsetPoint.y;
        }
        this.setScroll(scroll);
    };
    CanvasViewManager.prototype.scrollIntoView = function (rectangle) {
        rectangle = rectangle
            .clone()
            .applyConverter(unit_converter_1.UnitConverter.twipsToPixelsF)
            .multiply(this.actualZoom, this.actualZoom)
            .moveRectangle(this.paddings.left, this.paddings.top);
        var scroll = this.scroll;
        var container = this.containerSize;
        if (rectangle.x >= scroll.x && rectangle.y >= scroll.y && rectangle.right <= scroll.x + container.width && rectangle.bottom <= scroll.y + container.height)
            return;
        var newScroll = scroll.clone();
        if (rectangle.x < scroll.x)
            newScroll.x = rectangle.x - exports.CANVAS_SCROLL_PADDING;
        else if (rectangle.right > scroll.x + container.width)
            newScroll.x = Math.min(rectangle.x - exports.CANVAS_SCROLL_PADDING, rectangle.right + exports.CANVAS_SCROLL_PADDING - container.width);
        if (rectangle.y < scroll.y)
            newScroll.y = rectangle.y - exports.CANVAS_SCROLL_PADDING;
        else
            newScroll.y = Math.min(rectangle.y - exports.CANVAS_SCROLL_PADDING, rectangle.bottom + exports.CANVAS_SCROLL_PADDING - container.height);
        this.setScroll(newScroll);
    };
    CanvasViewManager.prototype.setScroll = function (pt) {
        var _this = this;
        var modelAbsSize = this.modelSize.clone().multiply(this.actualZoom, this.actualZoom);
        pt.x = Math.max(0, Math.min(pt.x, modelAbsSize.width + this.paddings.horizontal - this.containerSize.width));
        pt.y = Math.max(0, Math.min(pt.y, modelAbsSize.height + this.paddings.vertical - this.containerSize.height));
        this.dom.changeByFunc(null, function () {
            _this.scrollView.setScroll(pt.x, pt.y);
        });
        this.scroll = pt.clone();
    };
    CanvasViewManager.prototype.updateElements = function (modelAbsSize, translate, simpleView) {
        this.updatePageElement(modelAbsSize, translate, simpleView);
        this.updateCanvasElement(translate);
    };
    CanvasViewManager.prototype.updateCanvasElement = function (translate) {
        this.canvasElement = this.getOrCreateElement("dxdi-main", new GroupPrimitive_1.GroupPrimitive([], "dxdi-main", null, null, function (el) {
            el.setAttribute("transform", "translate(" + Math.round(translate.x) + ", " + Math.round(translate.y) + ")");
        }), this.svgElement);
    };
    CanvasViewManager.prototype.updatePageElement = function (modelAbsSize, translate, simpleView) {
        if (simpleView)
            this.updatePageElementCore("", 0, 0, modelAbsSize.width, modelAbsSize.height);
        else {
            var x = translate.x;
            var y = translate.y;
            var modelAbsWidth = modelAbsSize.width;
            var modelAbsHeight = modelAbsSize.height;
            this.createPageShadow(x, y, modelAbsWidth, modelAbsHeight);
            this.updatePageElementCore(this.pageClipPathId, Math.round(x), Math.round(y), modelAbsWidth, modelAbsHeight);
        }
    };
    CanvasViewManager.prototype.createPageShadow = function (left, top, width, height) {
        this.getOrCreateElement("pageShadowRect", new RectaglePrimitive_1.RectanglePrimitive(left.toString(), top.toString(), width.toString(), height.toString(), new Style_1.EmptyStyle({ "filter": Utils_2.RenderUtils.getUrlPathById(this.pageShadowId) }), "dxdi-page-shadow"), this.svgElement, this.svgElement.firstChild);
    };
    CanvasViewManager.prototype.updatePageElementCore = function (groupClipPathId, translateX, translateY, modelAbsWidth, modelAbsHeight) {
        this.pageElement = this.getOrCreateElement("page", new GroupPrimitive_1.GroupPrimitive([], "dxdi-page", null, groupClipPathId, function (el) {
            el.setAttribute("transform", "translate(" + translateX + ", " + translateY + ")");
        }), this.svgElement);
        this.getOrCreateElement("pageClip", this.createPageClipPathPrimitive(modelAbsWidth, modelAbsHeight), this.svgElement);
    };
    CanvasViewManager.prototype.createPageClipPathPrimitive = function (modelAbsWidth, modelAbsHeight) {
        return new ClipPathPrimitive_1.ClipPathPrimitive(this.pageClipPathId, [new RectaglePrimitive_1.RectanglePrimitive(0, 0, modelAbsWidth.toString(), modelAbsHeight.toString())]);
    };
    CanvasViewManager.prototype.adjustCore = function (newModelSize, fixedZoomLevel, autoZoom, simpleView, crop, resetPaddings, containerSize, offset, saveVerticalScroll) {
        var actualModelSizeWithoutZoom = this.getActualModelSizeWithoutZoom(newModelSize, simpleView, crop);
        if (!this.lockAutoZoom && (autoZoom || !offset || !this.modelSize)) {
            var scrollbarWidth = this.scrollView.getScrollBarWidth();
            var actualZoom = this.getActualZoom(containerSize, scrollbarWidth, actualModelSizeWithoutZoom, fixedZoomLevel, autoZoom);
            if (autoZoom && actualZoom === this.actualZoom && (!resetPaddings.horizontal || (!resetPaddings.vertical && !saveVerticalScroll)))
                this.resizeView(actualModelSizeWithoutZoom, actualZoom, containerSize, simpleView, crop, offset || offsets_1.Offsets.empty());
            else {
                this.resetView(actualModelSizeWithoutZoom, actualZoom, containerSize, simpleView, crop, resetPaddings);
                this.setActualZoom(actualZoom);
            }
        }
        else
            this.resizeView(actualModelSizeWithoutZoom, this.actualZoom, containerSize, simpleView, crop, offset);
    };
    CanvasViewManager.prototype.resetView = function (actualModelSizeWithoutZoom, actualZoom, containerSize, simpleView, cropWithoutZoom, toReset) {
        var actualModelSize = actualModelSizeWithoutZoom.clone().multiply(actualZoom, actualZoom);
        var paddings = offsets_1.Offsets.fromNumber(exports.CANVAS_MIN_PADDING);
        toReset = toReset || { horizontal: true, vertical: true };
        if (!toReset.horizontal && this.paddings) {
            paddings.left = this.paddings.left;
            paddings.right = this.paddings.right;
        }
        if (!toReset.vertical && this.paddings) {
            paddings.top = this.paddings.top;
            paddings.bottom = this.paddings.bottom;
        }
        var scrollbars = this.checkScrollBars(containerSize, this.scrollView.getScrollBarWidth(), actualModelSize, paddings);
        var scrollBarWidth = this.scrollView.getScrollBarWidth();
        var scroll = (toReset.horizontal || toReset.vertical) ? this.scroll : undefined;
        if (toReset.horizontal) {
            var paddingsH = Math.max((containerSize.width - (scrollbars.vertical ? scrollBarWidth : 0) - actualModelSize.width) / 2, exports.CANVAS_MIN_PADDING);
            paddings.left = paddingsH;
            paddings.right = paddingsH;
            scroll.x = 0;
        }
        if (toReset.vertical) {
            var paddingsV = Math.max((containerSize.height - (scrollbars.horizontal ? scrollBarWidth : 0) - actualModelSize.height) / 2, exports.CANVAS_MIN_PADDING);
            paddings.top = paddingsV;
            paddings.bottom = paddingsV;
            scroll.y = 0;
        }
        this.applyChanges(paddings, actualModelSize, simpleView, cropWithoutZoom.clone().multiply(actualZoom), scroll);
    };
    CanvasViewManager.prototype.resizeView = function (actualModelSizeWithoutZoom, actualZoom, containerSize, simpleView, cropWithoutZoom, offset) {
        var _a, _b;
        var oldZoom = this.actualZoom;
        var oldCrop = this.simpleView && this.crop ? this.crop.clone().multiply(oldZoom) : offsets_1.Offsets.empty();
        var actualModelSize = actualModelSizeWithoutZoom.clone().multiply(actualZoom, actualZoom);
        offset = offset.clone().multiply(actualZoom);
        var newCrop = simpleView && cropWithoutZoom ? cropWithoutZoom.clone().multiply(actualZoom) : offsets_1.Offsets.empty();
        var translate = new point_1.Point(this.paddings.left, this.paddings.top);
        var scroll = this.scroll;
        (_a = this.applyOffset(translate, scroll, oldCrop, newCrop, offset), translate = _a.translate, scroll = _a.scroll);
        (_b = this.cropHiddenHead(translate, scroll), translate = _b.translate, scroll = _b.scroll);
        var tailSpace = this.getTailSpace(translate, scroll, actualModelSize, containerSize, this.scrollView.getScrollBarWidth());
        if (!simpleView) {
            var maxTailSpaceWidth = containerSize.width - exports.CANVAS_SCROLL_PADDING;
            var maxTailSpaceHeight = containerSize.height - exports.CANVAS_SCROLL_PADDING;
            if (offset.left < 0)
                if (translate.x > maxTailSpaceWidth) {
                    translate.x = maxTailSpaceWidth;
                    scroll.x = 0;
                }
            if (offset.right < 0)
                if (tailSpace.width > maxTailSpaceWidth) {
                    tailSpace.width = maxTailSpaceWidth;
                    if (scroll.x > actualModelSize.width)
                        scroll.x = actualModelSize.width;
                }
            if (offset.top < 0)
                if (translate.y > maxTailSpaceHeight) {
                    translate.y = maxTailSpaceHeight;
                    scroll.y = 0;
                }
            if (offset.bottom < 0)
                if (tailSpace.height > maxTailSpaceHeight) {
                    tailSpace.height = maxTailSpaceHeight;
                    if (scroll.y > actualModelSize.height)
                        scroll.y = actualModelSize.height;
                }
        }
        var newPaddings = new offsets_1.Offsets(translate.x, tailSpace.width, translate.y, tailSpace.height);
        this.applyChanges(newPaddings, actualModelSize, simpleView, newCrop, scroll);
    };
    CanvasViewManager.prototype.applyChanges = function (paddings, actualModelSize, simpleView, crop, scroll) {
        var _this = this;
        var translate = new point_1.Point(paddings.left, paddings.top);
        if (simpleView && crop)
            translate = translate.clone().offset(-crop.left, -crop.top);
        this.updateElements(actualModelSize, translate, simpleView);
        this.setSvgSize(actualModelSize.width + paddings.horizontal, actualModelSize.height + paddings.vertical);
        this.onViewChanged.raise1(function (l) { return l.notifyViewAdjusted(new point_1.Point(translate.x, translate.y)); });
        if (scroll) {
            this.lockAutoScroll();
            scroll && this.dom.changeByFunc(this.scrollView, function (s) {
                s.setScroll(scroll.x, scroll.y);
                _this.unlockAutoScroll();
            });
            this.scroll = scroll;
        }
        this.paddings = paddings;
    };
    CanvasViewManager.prototype.isAutoScrollLocked = function () {
        return this.autoScrollLocker !== 0;
    };
    CanvasViewManager.prototype.lockAutoScroll = function () {
        this.autoScrollLocker++;
    };
    CanvasViewManager.prototype.unlockAutoScroll = function () {
        this.autoScrollLocker--;
    };
    CanvasViewManager.prototype.applyOffset = function (curTranslate, curScroll, oldCrop, newCrop, modelOffset) {
        var translate = curTranslate.clone();
        var scroll = curScroll.clone();
        var offset = this.getActualOffset(oldCrop, newCrop, modelOffset);
        if (offset.left) {
            translate.x = Math.max(exports.CANVAS_MIN_PADDING, translate.x - offset.left);
            scroll.x += offset.left - (curTranslate.x - translate.x);
        }
        if (offset.top) {
            translate.y = Math.max(exports.CANVAS_MIN_PADDING, translate.y - offset.top);
            scroll.y += offset.top - (curTranslate.y - translate.y);
        }
        return { translate: translate, scroll: scroll };
    };
    CanvasViewManager.prototype.cropHiddenHead = function (curTranslate, curScroll) {
        var scroll = curScroll.clone();
        var translate = curTranslate.clone();
        if (scroll.x && translate.x > exports.CANVAS_MIN_PADDING) {
            var delta = translate.x - Math.max(exports.CANVAS_MIN_PADDING, translate.x - scroll.x);
            translate.x -= delta;
            scroll.x -= delta;
        }
        if (scroll.y && translate.y > exports.CANVAS_MIN_PADDING) {
            var delta = translate.y - Math.max(exports.CANVAS_MIN_PADDING, translate.y - scroll.y);
            translate.y -= delta;
            scroll.y -= delta;
        }
        return { translate: translate, scroll: scroll };
    };
    CanvasViewManager.prototype.getTailSpace = function (curTranslate, curScroll, newModelAbsSize, containerSize, scrollbarWidth) {
        var translate = curTranslate.clone();
        var scroll = curScroll.clone();
        var right = Math.max(containerSize.width + scroll.x - (translate.x + newModelAbsSize.width), exports.CANVAS_MIN_PADDING);
        var bottom = Math.max(containerSize.height + scroll.y - (translate.y + newModelAbsSize.height), exports.CANVAS_MIN_PADDING);
        var scrollbars = this.checkScrollBars(containerSize, scrollbarWidth, newModelAbsSize, new offsets_1.Offsets(translate.x, right, translate.y, bottom));
        if (scrollbars.vertical)
            right = Math.max(exports.CANVAS_MIN_PADDING, right - scrollbarWidth);
        if (scrollbars.horizontal)
            bottom = Math.max(exports.CANVAS_MIN_PADDING, bottom - scrollbarWidth);
        return new size_1.Size(right, bottom);
    };
    CanvasViewManager.prototype.getActualOffset = function (oldCrop, newCrop, docOffset) {
        return new offsets_1.Offsets(-(newCrop.left - oldCrop.left) + docOffset.left, -(newCrop.right - oldCrop.right) + docOffset.right, -(newCrop.top - oldCrop.top) + docOffset.top, -(newCrop.bottom - oldCrop.bottom) + docOffset.bottom);
    };
    CanvasViewManager.prototype.checkScrollBars = function (containerSize, scrollBarWidth, modelAbsSize, paddings) {
        var hasHorizontalScroll = containerSize.width < modelAbsSize.width + paddings.horizontal;
        var hasVerticalScroll = containerSize.height < modelAbsSize.height + paddings.vertical;
        if (hasHorizontalScroll && !hasVerticalScroll)
            hasVerticalScroll = containerSize.height - scrollBarWidth < modelAbsSize.height + paddings.vertical;
        if (hasVerticalScroll && !hasHorizontalScroll)
            hasHorizontalScroll = containerSize.width - scrollBarWidth < modelAbsSize.width + paddings.horizontal;
        return { horizontal: hasHorizontalScroll, vertical: hasVerticalScroll };
    };
    CanvasViewManager.prototype.setSvgSize = function (width, height) {
        if (width !== this.lastWidth || height !== this.lastHeight) {
            this.dom.changeByFunc(this.svgElement, function (e) { return Utils_2.RenderUtils.updateSvgElementSize(e, width, height); });
            this.lastWidth = width;
            this.lastHeight = height;
        }
    };
    CanvasViewManager.prototype.getVisibileAreaAbsShift = function (excludeScroll) {
        var scroll = this.scroll;
        var paddings = this.paddings.clone();
        var simpleView = this.simpleView;
        var cropLeft = simpleView && this.crop ? this.crop.left * this.actualZoom : 0;
        var cropTop = simpleView && this.crop ? this.crop.top * this.actualZoom : 0;
        return new point_1.Point(paddings.left - cropLeft - (excludeScroll ? 0 : scroll.x), paddings.top - cropTop - (excludeScroll ? 0 : scroll.y));
    };
    CanvasViewManager.prototype.getModelPoint = function (absolutePoint, checkScrollArea) {
        var shift = this.getVisibileAreaAbsShift();
        var modelPoint = absolutePoint
            .clone().offset(-shift.x, -shift.y)
            .multiply(1 / this.actualZoom, 1 / this.actualZoom);
        if (checkScrollArea) {
            var scrollSize = this.containerSize;
            if (absolutePoint.x < 0 || absolutePoint.y < 0 || absolutePoint.x > scrollSize.width || absolutePoint.y > scrollSize.height)
                return null;
            if (modelPoint.x < 0 || modelPoint.y < 0)
                return null;
            if (modelPoint.x > this.modelSize.width || modelPoint.y > this.modelSize.height)
                return null;
        }
        return modelPoint.clone().applyConverter(unit_converter_1.UnitConverter.pixelsToTwips);
    };
    CanvasViewManager.prototype.getAbsolutePoint = function (modelPoint, excludeScroll, checkScrollArea) {
        var shift = this.getVisibileAreaAbsShift(excludeScroll);
        var absPoint = modelPoint
            .clone().multiply(this.actualZoom, this.actualZoom)
            .clone().applyConverter(unit_converter_1.UnitConverter.twipsToPixelsF)
            .clone().offset(shift.x, shift.y);
        if (checkScrollArea) {
            if (absPoint.x < 0 || absPoint.y < 0)
                return null;
            var scrollSize = this.containerSize;
            if (absPoint.x > scrollSize.width || absPoint.y > scrollSize.height)
                return null;
        }
        return absPoint;
    };
    return CanvasViewManager;
}(CanvasManagerBase_1.CanvasManagerBase));
exports.CanvasViewManager = CanvasViewManager;


/***/ }),
/* 343 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.ShadowFilterPrimitive = void 0;
var FilterPrimitive_1 = __webpack_require__(108);
var RenderHelper_1 = __webpack_require__(15);
var ShadowFilterPrimitive = (function (_super) {
    __extends(ShadowFilterPrimitive, _super);
    function ShadowFilterPrimitive() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    ShadowFilterPrimitive.prototype.createChildElements = function (parent) {
        var feGaussianBlur = document.createElementNS(RenderHelper_1.svgNS, "feGaussianBlur");
        feGaussianBlur.setAttribute("in", "SourceGraphic");
        feGaussianBlur.setAttribute("stdDeviation", "4.6");
        parent.appendChild(feGaussianBlur);
        var feOffset = document.createElementNS(RenderHelper_1.svgNS, "feOffset");
        feOffset.setAttribute("dx", "0");
        feOffset.setAttribute("dy", "0");
        parent.appendChild(feOffset);
        var feMerge = document.createElementNS(RenderHelper_1.svgNS, "feMerge");
        parent.appendChild(feMerge);
        var feMergeNode1 = document.createElementNS(RenderHelper_1.svgNS, "feMergeNode");
        feMerge.appendChild(feMergeNode1);
        var feMergeNode2 = document.createElementNS(RenderHelper_1.svgNS, "feMergeNode");
        feMergeNode2.setAttribute("in", "SourceGraphic");
        feMerge.appendChild(feMergeNode2);
    };
    return ShadowFilterPrimitive;
}(FilterPrimitive_1.FilterPrimitive));
exports.ShadowFilterPrimitive = ShadowFilterPrimitive;


/***/ }),
/* 344 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.AutoScrollController = void 0;
var RenderHelper_1 = __webpack_require__(15);
var dom_1 = __webpack_require__(27);
var size_1 = __webpack_require__(2);
var Utils_1 = __webpack_require__(3);
var SCROLL_EDGE = 40;
var SCROLL_RATIO = 5;
var SCROLL_MAXOFFSET = 5;
var SCROLL_DELAY = 50;
var AutoScrollController = (function () {
    function AutoScrollController(scroll, svgElement, view, dom) {
        this.scroll = scroll;
        this.svgElement = svgElement;
        this.view = view;
        this.dom = dom;
        this.leftButtonPressed = false;
        this.scrollDragging = false;
        this.scrollTimer = -1;
        this.scrollBarWidth = dom_1.DomUtils.getVerticalScrollBarWidth();
    }
    AutoScrollController.prototype.onMouseMove = function (evt, raiseMouseMoveFunc) {
        this.clearScrollTimer();
        if (!Utils_1.EventUtils.isLeftButtonPressed(evt))
            this.leftButtonPressed = false;
        if (this.canAutoScroll())
            this.changeScrollPosition(evt, raiseMouseMoveFunc, false);
    };
    AutoScrollController.prototype.onMouseDown = function (evt) {
        this.leftButtonPressed = !!Utils_1.EventUtils.isLeftButtonPressed(evt);
    };
    AutoScrollController.prototype.onMouseUp = function (evt) {
        this.clearScrollTimer();
        this.leftButtonPressed = false;
    };
    AutoScrollController.prototype.onMouseEnter = function (evt) {
        var _this = this;
        if (Utils_1.EventUtils.isLeftButtonPressed(evt))
            setTimeout(function () {
                _this.leftButtonPressed = true;
            }, 500);
    };
    AutoScrollController.prototype.onDragScrollStart = function () {
        this.scrollDragging = true;
    };
    AutoScrollController.prototype.onDragScrollEnd = function () {
        this.scrollDragging = false;
    };
    AutoScrollController.prototype.canAutoScroll = function () {
        return this.leftButtonPressed && !this.scrollDragging;
    };
    AutoScrollController.prototype.changeScrollPosition = function (evt, raiseMouseMoveFunc, raiseMouseMove) {
        var _this = this;
        var changed = false;
        if (!this.view.isAutoScrollLocked()) {
            var scrollContainer = this.scroll.getScrollContainer();
            var x_1 = evt.pageX - dom_1.DomUtils.getAbsolutePositionX(scrollContainer);
            var y_1 = evt.pageY - dom_1.DomUtils.getAbsolutePositionY(scrollContainer);
            var size = this.scroll.getSize();
            var scrollSize = new size_1.Size(parseFloat(this.svgElement.style.width), parseFloat(this.svgElement.style.height));
            var width_1 = size.width;
            if (size.width < scrollSize.width)
                width_1 -= this.scrollBarWidth;
            var height_1 = size.height;
            if (size.height < scrollSize.height)
                height_1 -= this.scrollBarWidth;
            if (x_1 <= SCROLL_EDGE) {
                this.dom.changeByFunc(null, function () {
                    if (!_this.view.isAutoScrollLocked())
                        _this.scroll.offsetScroll(-_this.getScrollingOffset(x_1), 0);
                });
                changed = true;
            }
            else if (width_1 - SCROLL_EDGE <= x_1) {
                this.dom.changeByFunc(null, function () {
                    if (!_this.view.isAutoScrollLocked())
                        _this.scroll.offsetScroll(_this.getScrollingOffset(width_1 - x_1), 0);
                });
                changed = true;
            }
            if (y_1 <= SCROLL_EDGE) {
                this.dom.changeByFunc(null, function () {
                    if (!_this.view.isAutoScrollLocked())
                        _this.scroll.offsetScroll(0, -_this.getScrollingOffset(y_1));
                });
                changed = true;
            }
            else if (height_1 - SCROLL_EDGE <= y_1) {
                this.dom.changeByFunc(null, function () {
                    if (!_this.view.isAutoScrollLocked())
                        _this.scroll.offsetScroll(0, _this.getScrollingOffset(height_1 - y_1));
                });
                changed = true;
            }
        }
        if (changed || this.view.isAutoScrollLocked())
            this.scrollTimer = window.setTimeout(function () { return _this.changeScrollPosition(evt, raiseMouseMoveFunc, changed); }, SCROLL_DELAY);
        if (raiseMouseMove)
            raiseMouseMoveFunc();
    };
    AutoScrollController.prototype.clearScrollTimer = function () {
        if (this.scrollTimer > -1) {
            window.clearTimeout(this.scrollTimer);
            this.scrollTimer = -1;
        }
    };
    AutoScrollController.prototype.getScrollingOffset = function (edgeOffset) {
        var offset = Math.pow((SCROLL_EDGE - edgeOffset) / SCROLL_RATIO, 2);
        return Math.round(Math.min(offset, SCROLL_MAXOFFSET));
    };
    AutoScrollController.createMainElement = function (parent) {
        var element = document.createElement("div");
        element.setAttribute("class", "dxdi-control");
        parent.appendChild(element);
        return element;
    };
    AutoScrollController.createSvgElement = function (parent, forExport) {
        if (forExport === void 0) { forExport = false; }
        var svgElement = document.createElementNS(RenderHelper_1.svgNS, "svg");
        svgElement.className.baseVal = "dxdi-canvas" + (forExport ? " export" : "");
        parent.appendChild(svgElement);
        return svgElement;
    };
    return AutoScrollController;
}());
exports.AutoScrollController = AutoScrollController;


/***/ }),
/* 345 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.DocumentDataSource = exports.UpdateNodeKeyRelatedObjectsStackAction = exports.UpdateNodeKeyRelatedObjectsStackItem = void 0;
var ShapeTypes_1 = __webpack_require__(1);
var Shape_1 = __webpack_require__(14);
var Connector_1 = __webpack_require__(6);
var DataSource_1 = __webpack_require__(346);
var ModelUtils_1 = __webpack_require__(4);
var Data_1 = __webpack_require__(44);
var Utils_1 = __webpack_require__(3);
var string_1 = __webpack_require__(49);
var math_1 = __webpack_require__(31);
var UpdateNodeKeyRelatedObjectsStackItem = (function () {
    function UpdateNodeKeyRelatedObjectsStackItem(shape, nodeObj) {
        this.shape = shape;
        this.nodeObj = nodeObj;
    }
    return UpdateNodeKeyRelatedObjectsStackItem;
}());
exports.UpdateNodeKeyRelatedObjectsStackItem = UpdateNodeKeyRelatedObjectsStackItem;
var UpdateNodeKeyRelatedObjectsStackAction = (function () {
    function UpdateNodeKeyRelatedObjectsStackAction(kind, nodeObj) {
        this.kind = kind;
        this.nodeObj = nodeObj;
    }
    return UpdateNodeKeyRelatedObjectsStackAction;
}());
exports.UpdateNodeKeyRelatedObjectsStackAction = UpdateNodeKeyRelatedObjectsStackAction;
var DocumentDataSource = (function (_super) {
    __extends(DocumentDataSource, _super);
    function DocumentDataSource(changesListener, nodeDataSource, edgeDataSource, parameters, nodeDataImporter, edgeDataImporter) {
        var _this = _super.call(this, "Document", nodeDataSource, edgeDataSource, parameters, nodeDataImporter, edgeDataImporter) || this;
        _this.changesListener = changesListener;
        _this.nodeInsertingLockCount = 0;
        _this.updateNodeKeyRelatedObjectsCount = 0;
        _this.updateNodeKeyRelatedObjectsStack = [];
        _this.updateNodeKeyRelatedObjectsStackActions = [];
        return _this;
    }
    DocumentDataSource.prototype.updateItemsByModel = function (model) {
        var _this = this;
        this.beginChangesNotification();
        this.deleteNodes(model);
        this.deleteEdges(model);
        model.items.forEach(function (item) {
            if (item instanceof Shape_1.Shape)
                _this.updateNode(model, item);
            if (item instanceof Connector_1.Connector)
                _this.updateEdge(model, item);
        });
        this.endChangesNotification(false);
    };
    DocumentDataSource.prototype.isItemObjectModified = function (item, itemObj, importer) {
        var modified = (importer.setLocked && itemObj.locked !== item.locked) ||
            (importer.setZIndex && itemObj.zIndex !== item.zIndex) ||
            (importer.setCustomData && !Utils_1.ObjectUtils.compareObjects(itemObj.customData, item.customData));
        if (!modified && importer.setStyle) {
            var defaultStyle_1 = item.style.getDefaultInstance();
            item.style.forEach(function (key) {
                if (item.style[key] !== defaultStyle_1[key] && item.style[key] !== (itemObj.style && itemObj.style[key]))
                    modified = true;
            });
        }
        if (!modified && importer.setStyleText) {
            var defaultTextStyle_1 = item.styleText.getDefaultInstance();
            item.styleText.forEach(function (key) {
                if (item.styleText[key] !== defaultTextStyle_1[key] && item.styleText[key] !== (itemObj.styleText && itemObj.styleText[key]))
                    modified = true;
            });
        }
        return modified;
    };
    DocumentDataSource.prototype.setDataObjectKeyRelatedProperty = function (method, dataObj, key, allowAutoGeneratedProperty) {
        if (allowAutoGeneratedProperty || this.autoGeneratedDataKeys[key] === undefined)
            method(dataObj, key);
    };
    DocumentDataSource.prototype.updateItemObjectProperties = function (itemObj, item, importer) {
        if (importer.setCustomData) {
            itemObj.customData = Utils_1.ObjectUtils.cloneObject(item.customData);
            if (itemObj.dataObj && itemObj.customData !== undefined)
                importer.setCustomData(itemObj.dataObj, item.customData);
        }
        if (importer.setLocked) {
            itemObj.locked = item.locked;
            if (itemObj.dataObj && itemObj.locked !== undefined)
                importer.setLocked(itemObj.dataObj, item.locked);
        }
        if (importer.setStyle) {
            var styleObj = item.style.toObject();
            itemObj.style = styleObj;
            if (itemObj.dataObj && itemObj.style !== undefined)
                importer.setStyle(itemObj.dataObj, Data_1.Data.objectToCssText(styleObj));
        }
        if (importer.setStyleText) {
            var styleTextObj = item.styleText.toObject();
            itemObj.styleText = styleTextObj;
            if (itemObj.dataObj && itemObj.styleText !== undefined)
                importer.setStyleText(itemObj.dataObj, Data_1.Data.objectToCssText(styleTextObj));
        }
        if (importer.setZIndex) {
            itemObj.zIndex = item.zIndex;
            if (itemObj.dataObj && itemObj.zIndex !== undefined)
                importer.setZIndex(itemObj.dataObj, item.zIndex);
        }
    };
    DocumentDataSource.prototype.deleteItems = function (dataSourceItems, findItem, getParentArray, callback) {
        var items = dataSourceItems.slice();
        items.forEach(function (item) {
            if (item.key !== undefined && item.key !== null && !findItem(item.key)) {
                var parentArray = getParentArray(item);
                var index = parentArray.indexOf(item.dataObj);
                parentArray.splice(index, 1);
                callback(item, index > -1);
            }
        });
    };
    DocumentDataSource.prototype.updateNode = function (model, shape) {
        var _this = this;
        var nodeObj = this.findNode(shape.dataKey);
        if (!nodeObj) {
            var dataObj = {};
            if (shape.dataKey !== undefined && shape.dataKey !== null)
                this.nodeDataImporter.setKey(dataObj, shape.dataKey);
            nodeObj = this.addNodeInternal(dataObj, shape.description.key, shape.text);
            this.nodeDataSource.push(nodeObj.dataObj);
            this.setDataObjectKeyRelatedProperty(this.nodeDataImporter.setKey, dataObj, nodeObj.key, this.addInternalKeyOnInsert);
            this.updateNodeObjectProperties(shape, nodeObj, model.units);
            this.updateNodeObjectConnectedProperties(shape, nodeObj);
            this.updateNodeObjectKey(shape, nodeObj, nodeObj.dataObj);
            this.beginChangesNotification();
            this.beginNodeInserting();
            this.changesListener.notifyNodeInserted.call(this.changesListener, nodeObj.dataObj, function (data) {
                _this.updateNodeObjectKey(shape, nodeObj, data);
                _this.endNodeInserting();
                _this.endChangesNotification(false);
            }, function (error) {
                _this.endNodeInserting();
                _this.endChangesNotification(false);
            });
        }
        else if (this.isNodeObjectModified(shape, nodeObj, model.units)) {
            this.updateNodeObjectProperties(shape, nodeObj, model.units);
            this.updateNodeObjectConnectedProperties(shape, nodeObj);
            this.beginChangesNotification();
            this.changesListener.notifyNodeUpdated.call(this.changesListener, this.nodeDataImporter.getKey(nodeObj.dataObj || nodeObj.key), nodeObj.dataObj, function (key, data) {
                _this.endChangesNotification(false);
            }, function (error) {
                _this.endChangesNotification(false);
            });
        }
        else
            this.updateNodeObjectConnectedProperties(shape, nodeObj, this.changesListener);
    };
    DocumentDataSource.prototype.areImageUrlsEqual = function (url1, url2) {
        return (url1 === url2) ||
            (string_1.StringUtils.isNullOrEmpty(url1) && string_1.StringUtils.isNullOrEmpty(url2));
    };
    DocumentDataSource.prototype.isNodeObjectModified = function (shape, nodeObj, units) {
        return this.isItemObjectModified(shape, nodeObj, this.nodeDataImporter) ||
            (nodeObj.type !== shape.description.key && !(nodeObj.type === undefined && shape.description.key === ShapeTypes_1.ShapeTypes.Rectangle)) ||
            !this.compareStrings(nodeObj.text, shape.text) ||
            (this.nodeDataImporter.setImage && !this.areImageUrlsEqual(nodeObj.image, shape.image.actualUrl)) ||
            (this.nodeDataImporter.setLeft && !math_1.MathUtils.numberCloseTo(nodeObj.left, ModelUtils_1.ModelUtils.getlUnitValue(units, shape.position.x))) ||
            (this.nodeDataImporter.setTop && !math_1.MathUtils.numberCloseTo(nodeObj.top, ModelUtils_1.ModelUtils.getlUnitValue(units, shape.position.y))) ||
            (this.nodeDataImporter.setWidth && !math_1.MathUtils.numberCloseTo(nodeObj.width, ModelUtils_1.ModelUtils.getlUnitValue(units, shape.size.width))) ||
            (this.nodeDataImporter.setHeight && !math_1.MathUtils.numberCloseTo(nodeObj.height, ModelUtils_1.ModelUtils.getlUnitValue(units, shape.size.height)));
    };
    DocumentDataSource.prototype.updateNodeObjectProperties = function (shape, nodeObj, units) {
        this.updateItemObjectProperties(nodeObj, shape, this.nodeDataImporter);
        if (this.nodeDataImporter.setType) {
            nodeObj.type = shape.description.key;
            this.nodeDataImporter.setType(nodeObj.dataObj, shape.description.key);
        }
        if (this.nodeDataImporter.setText) {
            nodeObj.text = shape.text;
            this.nodeDataImporter.setText(nodeObj.dataObj, shape.text);
        }
        if (this.nodeDataImporter.setImage) {
            nodeObj.image = shape.image.actualUrl;
            this.nodeDataImporter.setImage(nodeObj.dataObj, shape.image.actualUrl === undefined ? null : shape.image.actualUrl);
        }
        if (this.nodeDataImporter.setLeft) {
            var left = ModelUtils_1.ModelUtils.getlUnitValue(units, shape.position.x);
            nodeObj.left = left;
            this.nodeDataImporter.setLeft(nodeObj.dataObj, left);
        }
        if (this.nodeDataImporter.setTop) {
            var top_1 = ModelUtils_1.ModelUtils.getlUnitValue(units, shape.position.y);
            nodeObj.top = top_1;
            this.nodeDataImporter.setTop(nodeObj.dataObj, top_1);
        }
        if (this.nodeDataImporter.setWidth) {
            var width = ModelUtils_1.ModelUtils.getlUnitValue(units, shape.size.width);
            nodeObj.width = width;
            this.nodeDataImporter.setWidth(nodeObj.dataObj, width);
        }
        if (this.nodeDataImporter.setHeight) {
            var height = ModelUtils_1.ModelUtils.getlUnitValue(units, shape.size.height);
            nodeObj.height = height;
            this.nodeDataImporter.setHeight(nodeObj.dataObj, height);
        }
    };
    DocumentDataSource.prototype.updateNodeObjectConnectedProperties = function (shape, nodeObj, changesListener) {
        if (this.useNodeParentId && this.nodeDataImporter.setParentKey !== undefined) {
            var parentKey = this.getParentItemKey(shape);
            var parentItem = this.findNode(parentKey);
            this.updateNodeObjectParentKey(nodeObj, parentItem, changesListener);
        }
        if (this.useNodeContainerId && this.nodeDataImporter.setContainerKey !== undefined) {
            var containerKey = this.getContainerShapeKey(shape);
            var containerItem = this.findNode(containerKey);
            this.updateNodeObjectContainerKey(nodeObj, containerItem, changesListener);
        }
        if (this.useNodeItems && this.nodeDataImporter.setItems !== undefined) {
            var parentKey = this.getParentItemKey(shape);
            var parentItem = this.findNode(parentKey);
            this.updateNodeObjectItems(nodeObj, parentItem, changesListener);
        }
        if (this.useNodeChildren && this.nodeDataImporter.setChildren !== undefined) {
            var containerKey = this.getContainerShapeKey(shape);
            var containerItem = this.findNode(containerKey);
            this.updateNodeObjectChildren(nodeObj, containerItem, changesListener);
        }
    };
    DocumentDataSource.prototype.IsNodeParentIdMode = function () {
        return (this.useNodeParentId && this.nodeDataImporter.setParentKey !== undefined);
    };
    DocumentDataSource.prototype.IsNodeItemsMode = function () {
        return (this.useNodeItems && this.nodeDataImporter.setItems !== undefined);
    };
    DocumentDataSource.prototype.updateNodeObjectParentKey = function (nodeObj, parentNodeObj, changesListener) {
        var parentKey = this.nodeDataImporter.getParentKey(nodeObj.dataObj);
        var newParentKey = parentNodeObj ? this.nodeDataImporter.getKey(parentNodeObj.dataObj) : undefined;
        if (parentKey !== newParentKey && !(this.isRootParentKey(parentKey) && this.isRootParentKey(newParentKey))) {
            this.setDataObjectKeyRelatedProperty(this.nodeDataImporter.setParentKey, nodeObj.dataObj, newParentKey, false);
            if (changesListener)
                if (this.isInUpdateNodeKeyRelatedObjects())
                    this.addToUpdateNodeKeyRelatedObjectsStackAction("shape", nodeObj);
                else
                    this.updateNodeObjectContainerOrParentKeyInternal(nodeObj, changesListener);
        }
    };
    DocumentDataSource.prototype.updateNodeObjectParentKeyInternal = function (nodeObj, changesListener) {
        var _this = this;
        this.beginChangesNotification();
        changesListener.notifyNodeUpdated.call(changesListener, this.nodeDataImporter.getKey(nodeObj.dataObj) || nodeObj.key, nodeObj.dataObj, function (key, data) {
            _this.endChangesNotification(false);
        }, function (error) {
            _this.endChangesNotification(false);
        });
    };
    DocumentDataSource.prototype.updateNodeObjectContainerKey = function (nodeObj, containerNodeObj, changesListener) {
        var containerKey = this.nodeDataImporter.getContainerKey(nodeObj.dataObj);
        var newContainerKey = containerNodeObj ? this.nodeDataImporter.getKey(containerNodeObj.dataObj) : undefined;
        if (containerKey !== newContainerKey && !(this.isRootParentKey(containerKey) && this.isRootParentKey(newContainerKey))) {
            this.setDataObjectKeyRelatedProperty(this.nodeDataImporter.setContainerKey, nodeObj.dataObj, newContainerKey, false);
            if (changesListener)
                if (this.isInUpdateNodeKeyRelatedObjects())
                    this.addToUpdateNodeKeyRelatedObjectsStackAction("shape", nodeObj);
                else
                    this.updateNodeObjectContainerOrParentKeyInternal(nodeObj, changesListener);
        }
    };
    DocumentDataSource.prototype.updateNodeObjectContainerOrParentKeyInternal = function (nodeObj, changesListener) {
        var _this = this;
        this.beginChangesNotification();
        changesListener.notifyNodeUpdated.call(changesListener, this.nodeDataImporter.getKey(nodeObj.dataObj) || nodeObj.key, nodeObj.dataObj, function (key, data) {
            _this.endChangesNotification(false);
        }, function (error) {
            _this.endChangesNotification(false);
        });
    };
    DocumentDataSource.prototype.isRootParentKey = function (key) {
        return key === undefined || key === null || !this.findNode(key);
    };
    DocumentDataSource.prototype.updateNodeObjectItems = function (nodeObj, parentNodeObj, changesListener) {
        var _this = this;
        if (parentNodeObj && nodeObj.parentDataObj !== parentNodeObj.dataObj ||
            !parentNodeObj && nodeObj.parentDataObj)
            if (!parentNodeObj || !this.checkNodeCyrcleItems(nodeObj.dataObj, parentNodeObj.dataObj)) {
                var oldItemsArray = nodeObj.parentDataObj ? this.nodeDataImporter.getItems(nodeObj.parentDataObj) : this.nodeDataSource;
                var index = oldItemsArray.indexOf(nodeObj.dataObj);
                oldItemsArray.splice(index, 1);
                var itemsArray = parentNodeObj ? this.nodeDataImporter.getItems(parentNodeObj.dataObj) : this.nodeDataSource;
                if (!itemsArray)
                    this.nodeDataImporter.setItems(parentNodeObj.dataObj, [nodeObj.dataObj]);
                else
                    itemsArray.push(nodeObj.dataObj);
                nodeObj.parentDataObj = parentNodeObj && parentNodeObj.dataObj;
                if (changesListener) {
                    this.beginChangesNotification();
                    changesListener.notifyNodeUpdated.call(changesListener, this.nodeDataImporter.getKey(nodeObj.dataObj) || nodeObj.key, nodeObj.dataObj, function (key, data) {
                        _this.endChangesNotification(false);
                    }, function (error) {
                        _this.endChangesNotification(false);
                    });
                }
            }
    };
    DocumentDataSource.prototype.updateNodeObjectChildren = function (nodeObj, containerNodeObj, changesListener) {
        var _this = this;
        if (containerNodeObj && nodeObj.containerDataObj !== containerNodeObj.dataObj ||
            !containerNodeObj && nodeObj.containerDataObj) {
            var oldChildrenArray = nodeObj.containerDataObj ? this.nodeDataImporter.getChildren(nodeObj.containerDataObj) : this.nodeDataSource;
            var index = oldChildrenArray.indexOf(nodeObj.dataObj);
            oldChildrenArray.splice(index, 1);
            var childrenArray = containerNodeObj ? this.nodeDataImporter.getChildren(containerNodeObj.dataObj) : this.nodeDataSource;
            if (!childrenArray)
                this.nodeDataImporter.setChildren(containerNodeObj.dataObj, [nodeObj.dataObj]);
            else
                childrenArray.push(nodeObj.dataObj);
            nodeObj.containerDataObj = containerNodeObj && containerNodeObj.dataObj;
            if (changesListener) {
                this.beginChangesNotification();
                changesListener.notifyNodeUpdated.call(changesListener, this.nodeDataImporter.getKey(nodeObj.dataObj) || nodeObj.key, nodeObj.dataObj, function (key, data) {
                    _this.endChangesNotification(false);
                }, function (error) {
                    _this.endChangesNotification(false);
                });
            }
        }
    };
    DocumentDataSource.prototype.checkNodeCyrcleItems = function (nodeDataObj, parentDataObjCandidate) {
        var _this = this;
        var result = false;
        var items = this.nodeDataImporter.getItems(nodeDataObj);
        if (items)
            items.forEach(function (childDataObj) {
                result = result || childDataObj === parentDataObjCandidate ||
                    _this.checkNodeCyrcleItems(childDataObj, parentDataObjCandidate);
            });
        return result;
    };
    DocumentDataSource.prototype.updateNodeObjectKey = function (shape, nodeObj, dataObj) {
        var key = this.nodeDataImporter.getKey(dataObj);
        var dataKeyChanged = false;
        if (key !== undefined && key !== null && key !== nodeObj.key) {
            delete this.autoGeneratedDataKeys[nodeObj.key];
            nodeObj.key = key;
            dataKeyChanged = true;
        }
        shape.dataKey = nodeObj.key;
        if (nodeObj.dataObj !== dataObj) {
            var parentArray = this.getNodeArray(nodeObj);
            var index = parentArray.indexOf(nodeObj.dataObj);
            parentArray.splice(index, 1, dataObj);
            nodeObj.dataObj = dataObj;
        }
        if (dataKeyChanged)
            this.updateNodeKeyRelatedObjects(shape, nodeObj);
    };
    DocumentDataSource.prototype.updateNodeKeyRelatedObjects = function (shape, nodeObj) {
        var _this = this;
        if (this.isInNodeInserting()) {
            this.addToUpdateNodeKeyRelatedObjectsStack(shape, nodeObj);
            return;
        }
        if (this.useNodeParentId && this.nodeDataImporter.setParentKey !== undefined) {
            var childItems = this.getChildItems(shape);
            childItems.forEach(function (item) {
                var childNodeObj = _this.findNode(item.dataKey);
                if (childNodeObj)
                    _this.updateNodeObjectParentKey(childNodeObj, nodeObj, _this.changesListener);
            });
        }
        if (this.useNodeContainerId && this.nodeDataImporter.setContainerKey !== undefined)
            shape.children.forEach(function (item) {
                var childNodeObj = item instanceof Shape_1.Shape ? _this.findNode(item.dataKey) : undefined;
                if (childNodeObj)
                    _this.updateNodeObjectContainerKey(childNodeObj, nodeObj, _this.changesListener);
            });
        if (this.useEdgesArray())
            shape.attachedConnectors.forEach(function (connector) {
                var edgeObj = _this.findEdge(connector.dataKey);
                if (edgeObj) {
                    if (shape === connector.beginItem)
                        _this.updateEdgeObjectFromProperty(nodeObj, edgeObj, _this.changesListener);
                    if (shape === connector.endItem)
                        _this.updateEdgeObjectToProperty(nodeObj, edgeObj, _this.changesListener);
                }
            });
    };
    DocumentDataSource.prototype.deleteNodes = function (model) {
        var _this = this;
        this.deleteItems(this.nodes, function (key) { return model.findShapeByDataKey(key); }, function (item) { return _this.getNodeArray(item); }, function (item, dataModified) {
            var key = (item.dataObj && _this.nodeDataImporter.getKey(item.dataObj)) || item.key;
            var nodeObj = _this.findNode(key);
            if (nodeObj)
                _this.nodes.splice(_this.nodes.indexOf(nodeObj), 1);
            if (dataModified) {
                _this.beginChangesNotification();
                _this.changesListener.notifyNodeRemoved.call(_this.changesListener, key, item.dataObj, function (key, data) {
                    _this.endChangesNotification(false);
                }, function (error) {
                    _this.endChangesNotification(false);
                });
            }
        });
    };
    DocumentDataSource.prototype.getParentItem = function (shape) {
        for (var i = 0; i < shape.attachedConnectors.length; i++)
            if (shape.attachedConnectors[i].endItem === shape)
                return shape.attachedConnectors[i].beginItem;
    };
    DocumentDataSource.prototype.getParentItemKey = function (shape) {
        var parent = this.getParentItem(shape);
        return parent && parent.dataKey;
    };
    DocumentDataSource.prototype.getNodeArray = function (item) {
        var items;
        if (this.useNodeItems && item.parentDataObj)
            items = this.nodeDataImporter.getItems(item.parentDataObj);
        else if (item.containerDataObj)
            items = this.nodeDataImporter.getChildren(item.containerDataObj);
        return items || this.nodeDataSource;
    };
    DocumentDataSource.prototype.getContainerShapeKey = function (shape) {
        return shape.container && shape.container.dataKey;
    };
    DocumentDataSource.prototype.getChildItems = function (shape) {
        var items = [];
        for (var i = 0; i < shape.attachedConnectors.length; i++)
            if (shape.attachedConnectors[i].beginItem === shape)
                if (shape.attachedConnectors[i].endItem)
                    items.push(shape.attachedConnectors[i].endItem);
        return items;
    };
    DocumentDataSource.prototype.updateEdge = function (model, connector) {
        var _this = this;
        var beginDataKey = connector.beginItem ? connector.beginItem.dataKey : undefined;
        var endDataKey = connector.endItem ? connector.endItem.dataKey : undefined;
        var edgeObj = this.findEdge(connector.dataKey);
        if (!edgeObj) {
            var dataObj = this.useEdgesArray() && this.canUpdateEdgeDataSource ? {} : undefined;
            if (dataObj && connector.dataKey !== undefined && connector.dataKey !== null)
                this.edgeDataImporter.setKey(dataObj, connector.dataKey);
            edgeObj = this.addEdgeInternal(dataObj, beginDataKey, endDataKey);
            if (dataObj) {
                this.setDataObjectKeyRelatedProperty(this.edgeDataImporter.setKey, dataObj, edgeObj.key, this.addInternalKeyOnInsert);
                this.edgeDataSource.push(edgeObj.dataObj);
            }
            this.updateEdgeObjectProperties(connector, edgeObj, model.units);
            this.updateEdgeObjectKey(connector, edgeObj, edgeObj.dataObj);
            if (dataObj) {
                this.beginChangesNotification();
                this.beginNodeInserting();
                this.changesListener.notifyEdgeInserted.call(this.changesListener, edgeObj.dataObj, function (data) {
                    _this.updateEdgeObjectKey(connector, edgeObj, data);
                    _this.endNodeInserting();
                    _this.endChangesNotification(false);
                }, function (error) {
                    _this.endNodeInserting();
                    _this.endChangesNotification(false);
                });
            }
        }
        else if (this.isEdgeObjectModified(connector, edgeObj, model.units)) {
            this.updateEdgeObjectProperties(connector, edgeObj, model.units);
            if (edgeObj.dataObj) {
                this.beginChangesNotification();
                this.changesListener.notifyEdgeUpdated.call(this.changesListener, this.edgeDataImporter.getKey(edgeObj.dataObj) || edgeObj.key, edgeObj.dataObj, function (key, data) {
                    _this.endChangesNotification(false);
                }, function (error) {
                    _this.endChangesNotification(false);
                });
            }
        }
    };
    DocumentDataSource.prototype.isEdgeObjectModified = function (connector, edgeObj, units) {
        return this.isItemObjectModified(connector, edgeObj, this.edgeDataImporter) ||
            (edgeObj.from !== null ? edgeObj.from : undefined) !== (connector.beginItem ? connector.beginItem.dataKey : undefined) ||
            (edgeObj.to === null ? undefined : edgeObj.to) !== (connector.endItem ? connector.endItem.dataKey : undefined) ||
            (this.edgeDataImporter.setFromPointIndex && edgeObj.fromPointIndex !== connector.beginConnectionPointIndex) ||
            (this.edgeDataImporter.setToPointIndex && edgeObj.toPointIndex !== connector.endConnectionPointIndex) ||
            (this.edgeDataImporter.setPoints && (!edgeObj.points ||
                !this.pointsAreEqual(edgeObj.points.map(function (ptObj) { return ptObj.x; }), connector.points.map(function (pt) { return ModelUtils_1.ModelUtils.getlUnitValue(units, pt.x); })) ||
                !this.pointsAreEqual(edgeObj.points.map(function (ptObj) { return ptObj.y; }), connector.points.map(function (pt) { return ModelUtils_1.ModelUtils.getlUnitValue(units, pt.y); })))) ||
            (this.edgeDataImporter.setText && !this.compareTexts(edgeObj, connector)) ||
            (this.edgeDataImporter.setLineOption && edgeObj.lineOption !== connector.properties.lineOption) ||
            (this.edgeDataImporter.setStartLineEnding && edgeObj.startLineEnding !== connector.properties.startLineEnding) ||
            (this.edgeDataImporter.setEndLineEnding && edgeObj.endLineEnding !== connector.properties.endLineEnding);
    };
    DocumentDataSource.prototype.pointsAreEqual = function (a, b) {
        var aLen = a.length;
        var bLen = a.length;
        if (aLen !== bLen)
            return false;
        for (var i = 0; i < aLen; i++)
            if (!math_1.MathUtils.numberCloseTo(a[i], b[i]))
                return false;
        return true;
    };
    DocumentDataSource.prototype.updateEdgeObjectFromProperty = function (fromObj, edgeObj, changesListener) {
        edgeObj.from = fromObj && fromObj.key;
        if (edgeObj.dataObj) {
            var fromKey = fromObj && fromObj.dataObj && this.nodeDataImporter.getKey(fromObj.dataObj);
            this.setDataObjectKeyRelatedProperty(this.edgeDataImporter.setFrom, edgeObj.dataObj, fromKey, false);
            if (changesListener)
                if (this.isInUpdateNodeKeyRelatedObjects())
                    this.addToUpdateNodeKeyRelatedObjectsStackAction("edge", edgeObj);
                else
                    this.updateEdgeObjectFromOrToPropertyInternal(edgeObj, changesListener);
        }
    };
    DocumentDataSource.prototype.updateEdgeObjectFromOrToPropertyInternal = function (edgeObj, changesListener) {
        var _this = this;
        this.beginChangesNotification();
        changesListener.notifyEdgeUpdated.call(changesListener, this.nodeDataImporter.getKey(edgeObj.dataObj) || edgeObj.key, edgeObj.dataObj, function (key, data) {
            _this.endChangesNotification(false);
        }, function (error) {
            _this.endChangesNotification(false);
        });
    };
    DocumentDataSource.prototype.updateEdgeObjectToProperty = function (toObj, edgeObj, changesListener) {
        edgeObj.to = toObj && toObj.key;
        if (edgeObj.dataObj) {
            var toKey = toObj && toObj.dataObj && this.nodeDataImporter.getKey(toObj.dataObj);
            this.setDataObjectKeyRelatedProperty(this.edgeDataImporter.setTo, edgeObj.dataObj, toKey, false);
            if (changesListener)
                if (this.isInUpdateNodeKeyRelatedObjects())
                    this.addToUpdateNodeKeyRelatedObjectsStackAction("edge", edgeObj);
                else
                    this.updateEdgeObjectFromOrToPropertyInternal(edgeObj, changesListener);
        }
    };
    DocumentDataSource.prototype.updateEdgeObjectProperties = function (connector, edgeObj, units) {
        this.updateItemObjectProperties(edgeObj, connector, this.edgeDataImporter);
        if (this.edgeDataImporter.setFrom) {
            var fromObj = this.findNode(connector.beginItem && connector.beginItem.dataKey);
            this.updateEdgeObjectFromProperty(fromObj, edgeObj);
        }
        if (this.edgeDataImporter.setTo) {
            var toObj = this.findNode(connector.endItem && connector.endItem.dataKey);
            this.updateEdgeObjectToProperty(toObj, edgeObj);
        }
        if (this.edgeDataImporter.setFromPointIndex) {
            edgeObj.fromPointIndex = connector.beginConnectionPointIndex;
            if (edgeObj.dataObj)
                this.edgeDataImporter.setFromPointIndex(edgeObj.dataObj, connector.beginConnectionPointIndex);
        }
        if (this.edgeDataImporter.setToPointIndex) {
            edgeObj.toPointIndex = connector.endConnectionPointIndex;
            if (edgeObj.dataObj)
                this.edgeDataImporter.setToPointIndex(edgeObj.dataObj, connector.endConnectionPointIndex);
        }
        if (this.edgeDataImporter.setPoints) {
            var points = connector.points.map(function (pt) {
                return {
                    x: ModelUtils_1.ModelUtils.getlUnitValue(units, pt.x),
                    y: ModelUtils_1.ModelUtils.getlUnitValue(units, pt.y)
                };
            });
            edgeObj.points = points;
            if (edgeObj.dataObj)
                this.edgeDataImporter.setPoints(edgeObj.dataObj, points);
        }
        if (this.edgeDataImporter.setText) {
            var text = void 0;
            if (connector.getTextCount() === 1 && connector.getText())
                text = connector.getText();
            var texts_1 = {};
            connector.texts.forEach(function (text) {
                texts_1[text.position] = text.value;
            });
            edgeObj.texts = texts_1;
            if (edgeObj.dataObj) {
                var textVal = "";
                if (text)
                    textVal = text;
                else if (texts_1 && Object.keys(texts_1).length)
                    textVal = texts_1;
                this.edgeDataImporter.setText(edgeObj.dataObj, textVal);
            }
        }
        if (this.edgeDataImporter.setLineOption) {
            edgeObj.lineOption = connector.properties.lineOption;
            if (edgeObj.dataObj)
                this.edgeDataImporter.setLineOption(edgeObj.dataObj, connector.properties.lineOption);
        }
        if (this.edgeDataImporter.setStartLineEnding) {
            edgeObj.startLineEnding = connector.properties.startLineEnding;
            if (edgeObj.dataObj)
                this.edgeDataImporter.setStartLineEnding(edgeObj.dataObj, connector.properties.startLineEnding);
        }
        if (this.edgeDataImporter.setEndLineEnding) {
            edgeObj.endLineEnding = connector.properties.endLineEnding;
            if (edgeObj.dataObj)
                this.edgeDataImporter.setEndLineEnding(edgeObj.dataObj, connector.properties.endLineEnding);
        }
    };
    DocumentDataSource.prototype.updateEdgeObjectKey = function (connector, edgeObj, dataObj) {
        var key = dataObj && this.edgeDataImporter.getKey(dataObj);
        if (key !== undefined && key !== null && key !== edgeObj.key) {
            delete this.autoGeneratedDataKeys[edgeObj.key];
            edgeObj.key = key;
        }
        connector.dataKey = edgeObj.key;
        if (edgeObj.dataObj !== dataObj) {
            var parentArray = this.edgeDataSource;
            var index = parentArray.indexOf(edgeObj.dataObj);
            parentArray.splice(index, 1, dataObj);
            edgeObj.dataObj = dataObj;
        }
    };
    DocumentDataSource.prototype.deleteEdges = function (model) {
        var _this = this;
        this.deleteItems(this.edges, function (key) { return model.findConnectorByDataKey(key); }, function (item) { return _this.edgeDataSource; }, function (item, dataModified) {
            var key = (item.dataObj && _this.edgeDataImporter.getKey(item.dataObj)) || item.key;
            var edgeObj = _this.findEdge(key);
            if (edgeObj)
                _this.edges.splice(_this.edges.indexOf(edgeObj), 1);
            if (dataModified) {
                _this.beginChangesNotification();
                _this.changesListener.notifyEdgeRemoved.call(_this.changesListener, key, item.dataObj, function (key, data) {
                    _this.endChangesNotification(false);
                }, function (error) {
                    _this.endChangesNotification(false);
                });
            }
        });
    };
    DocumentDataSource.prototype.beginNodeInserting = function () {
        this.nodeInsertingLockCount++;
    };
    DocumentDataSource.prototype.endNodeInserting = function () {
        this.nodeInsertingLockCount--;
        if (this.nodeInsertingLockCount === 0)
            this.raiseNodeInsertingStack();
    };
    DocumentDataSource.prototype.isInNodeInserting = function () {
        return this.nodeInsertingLockCount > 0;
    };
    DocumentDataSource.prototype.addToUpdateNodeKeyRelatedObjectsStack = function (shape, nodeObj) {
        var item = new UpdateNodeKeyRelatedObjectsStackItem(shape, nodeObj);
        this.updateNodeKeyRelatedObjectsStack.push(item);
    };
    DocumentDataSource.prototype.raiseNodeInsertingStack = function () {
        this.beginUpdateNodeKeyRelatedObjects();
        while (this.updateNodeKeyRelatedObjectsStack.length > 0) {
            var item = this.updateNodeKeyRelatedObjectsStack[0];
            this.updateNodeKeyRelatedObjects(item.shape, item.nodeObj);
            this.updateNodeKeyRelatedObjectsStack.splice(0, 1);
            if (item.shape.description.hasTemplate && item.nodeObj)
                this.changesListener.reloadInsertedItem(item.nodeObj.key);
        }
        this.endUpdateNodeKeyRelatedObjects();
    };
    DocumentDataSource.prototype.beginUpdateNodeKeyRelatedObjects = function () {
        this.updateNodeKeyRelatedObjectsCount++;
    };
    DocumentDataSource.prototype.endUpdateNodeKeyRelatedObjects = function () {
        this.updateNodeKeyRelatedObjectsCount--;
        if (this.updateNodeKeyRelatedObjectsCount === 0)
            this.raiseUpdateNodeKeyRelatedObjectsStack();
    };
    DocumentDataSource.prototype.isInUpdateNodeKeyRelatedObjects = function () {
        return this.updateNodeKeyRelatedObjectsCount > 0;
    };
    DocumentDataSource.prototype.addToUpdateNodeKeyRelatedObjectsStackAction = function (kind, nodeObj) {
        var item = new UpdateNodeKeyRelatedObjectsStackAction(kind, nodeObj);
        for (var i = 0; i < this.updateNodeKeyRelatedObjectsStackActions.length; i++)
            if ((this.updateNodeKeyRelatedObjectsStackActions[i].kind === kind) && (this.updateNodeKeyRelatedObjectsStackActions[i].nodeObj === nodeObj))
                return;
        this.updateNodeKeyRelatedObjectsStackActions.push(item);
    };
    DocumentDataSource.prototype.raiseUpdateNodeKeyRelatedObjectsStack = function () {
        while (this.updateNodeKeyRelatedObjectsStackActions.length > 0) {
            var item = this.updateNodeKeyRelatedObjectsStackActions[0];
            switch (item.kind) {
                case "shape":
                    this.updateNodeObjectContainerOrParentKeyInternal(item.nodeObj, this.changesListener);
                    break;
                case "edge":
                    this.updateEdgeObjectFromOrToPropertyInternal(item.nodeObj, this.changesListener);
                    break;
            }
            this.updateNodeKeyRelatedObjectsStackActions.splice(0, 1);
        }
    };
    DocumentDataSource.prototype.beginChangesNotification = function () {
        this.changesListener.beginChangesNotification();
    };
    DocumentDataSource.prototype.endChangesNotification = function (preventNotifyChanges) {
        this.changesListener.endChangesNotification(preventNotifyChanges);
    };
    return DocumentDataSource;
}(DataSource_1.DataSource));
exports.DocumentDataSource = DocumentDataSource;


/***/ }),
/* 346 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.DataSource = void 0;
var unit_converter_1 = __webpack_require__(12);
var point_1 = __webpack_require__(0);
var size_1 = __webpack_require__(2);
var AddConnectionHistoryItem_1 = __webpack_require__(48);
var AddConnectorHistoryItem_1 = __webpack_require__(66);
var AddShapeHistoryItem_1 = __webpack_require__(53);
var DeleteConnectionHistoryItem_1 = __webpack_require__(67);
var ResizeShapeHistoryItem_1 = __webpack_require__(115);
var ChangeConnectorPropertyHistoryItem_1 = __webpack_require__(88);
var ChangeConnectorTextHistoryItem_1 = __webpack_require__(69);
var ChangeCustomDataHistoryItem_1 = __webpack_require__(116);
var ChangeLockedHistoryItem_1 = __webpack_require__(117);
var ChangeShapeImageHistoryItem_1 = __webpack_require__(146);
var ChangeShapeTextHistoryItem_1 = __webpack_require__(153);
var ChangeZindexHistoryItem_1 = __webpack_require__(102);
var ChangeStyleHistoryItem_1 = __webpack_require__(89);
var ChangeStyleTextHistoryItem_1 = __webpack_require__(70);
var Connector_1 = __webpack_require__(6);
var ModelUtils_1 = __webpack_require__(4);
var ShapeTypes_1 = __webpack_require__(1);
var ITextMeasurer_1 = __webpack_require__(43);
var Utils_1 = __webpack_require__(3);
var color_1 = __webpack_require__(22);
var Data_1 = __webpack_require__(44);
var Svg_1 = __webpack_require__(110);
var TextUtils_1 = __webpack_require__(64);
var DataImporter_1 = __webpack_require__(347);
var DataSourceItems_1 = __webpack_require__(348);
var ChangeConnectorPointsHistoryItem_1 = __webpack_require__(86);
var DataSource = (function () {
    function DataSource(key, nodeDataSource, edgeDataSource, parameters, nodeDataImporter, edgeDataImporter) {
        this.key = key;
        this.nodes = [];
        this.edges = [];
        this.autoGeneratedDataKeys = {};
        this.addInternalKeyOnInsert = false;
        this.useNodeParentId = false;
        this.useNodeContainerId = false;
        this.useNodeChildren = false;
        this.useNodeItems = false;
        this.canUseAutoSize = false;
        this.canUpdateEdgeDataSource = false;
        this.containers = null;
        if (key === undefined || key === null)
            throw new Error("DataSource key must be specified");
        this.key = key.toString();
        this.loadParameters(parameters || {});
        this.nodeDataImporter = this.createNodeDataImporter(nodeDataImporter);
        this.edgeDataImporter = this.createEdgeDataImporter(edgeDataImporter);
        this.nodeDataSource = nodeDataSource || [];
        this.edgeDataSource = edgeDataSource || [];
        this.canUpdateEdgeDataSource = !!edgeDataSource;
        this.fetchData();
    }
    DataSource.prototype.loadParameters = function (parameters) {
        this.addInternalKeyOnInsert = !!parameters.addInternalKeyOnInsert;
    };
    DataSource.prototype.isAutoGeneratedKey = function (dataKey) {
        return dataKey && !!this.autoGeneratedDataKeys[dataKey];
    };
    DataSource.prototype.createNodeDataImporter = function (source) {
        var result = new DataImporter_1.DataSourceNodeDataImporter();
        if (source)
            this.assignNodeDataImporterProperties(source, result);
        return result;
    };
    DataSource.prototype.createEdgeDataImporter = function (source) {
        var result = new DataImporter_1.DataSourceEdgeDataImporter();
        if (source)
            this.assignEdgeDataImporterProperties(source, result);
        return result;
    };
    DataSource.prototype.assignItemDataImporterProperties = function (source, importer) {
        if (source.getKey)
            importer.getKey = source.getKey;
        if (source.setKey)
            importer.setKey = source.setKey;
        if (source.getCustomData)
            importer.getCustomData = source.getCustomData;
        if (source.setCustomData)
            importer.setCustomData = source.setCustomData;
        if (source.getLocked)
            importer.getLocked = source.getLocked;
        if (source.setLocked)
            importer.setLocked = source.setLocked;
        if (source.getStyle)
            importer.getStyle = source.getStyle;
        if (source.setStyle)
            importer.setStyle = source.setStyle;
        if (source.getStyleText)
            importer.getStyleText = source.getStyleText;
        if (source.setStyleText)
            importer.setStyleText = source.setStyleText;
        if (source.getZIndex)
            importer.getZIndex = source.getZIndex;
        if (source.setZIndex)
            importer.setZIndex = source.setZIndex;
    };
    DataSource.prototype.assignNodeDataImporterProperties = function (source, importer) {
        this.assignItemDataImporterProperties(source, importer);
        if (source.getType)
            importer.getType = source.getType;
        if (source.setType)
            importer.setType = source.setType;
        if (source.getImage)
            importer.getImage = source.getImage;
        if (source.setImage)
            importer.setImage = source.setImage;
        if (source.getText)
            importer.getText = source.getText;
        if (source.setText)
            importer.setText = source.setText;
        if (source.getLeft)
            importer.getLeft = source.getLeft;
        if (source.setLeft)
            importer.setLeft = source.setLeft;
        if (source.getTop)
            importer.getTop = source.getTop;
        if (source.setTop)
            importer.setTop = source.setTop;
        if (source.getWidth)
            importer.getWidth = source.getWidth;
        if (source.setWidth)
            importer.setWidth = source.setWidth;
        if (source.getHeight)
            importer.getHeight = source.getHeight;
        if (source.setHeight)
            importer.setHeight = source.setHeight;
        if (source.getChildren)
            importer.getChildren = source.getChildren;
        if (source.setChildren)
            importer.setChildren = source.setChildren;
        if (source.getParentKey)
            importer.getParentKey = source.getParentKey;
        if (source.setParentKey)
            importer.setParentKey = source.setParentKey;
        if (source.getItems)
            importer.getItems = source.getItems;
        if (source.setItems)
            importer.setItems = source.setItems;
        if (source.getContainerKey)
            importer.getContainerKey = source.getContainerKey;
        if (source.setContainerKey)
            importer.setContainerKey = source.setContainerKey;
    };
    DataSource.prototype.assignEdgeDataImporterProperties = function (source, importer) {
        this.assignItemDataImporterProperties(source, importer);
        if (source.getFrom)
            importer.getFrom = source.getFrom;
        if (source.setFrom)
            importer.setFrom = source.setFrom;
        if (source.getFromPointIndex)
            importer.getFromPointIndex = source.getFromPointIndex;
        if (source.setFromPointIndex)
            importer.setFromPointIndex = source.setFromPointIndex;
        if (source.getTo)
            importer.getTo = source.getTo;
        if (source.setTo)
            importer.setTo = source.setTo;
        if (source.getToPointIndex)
            importer.getToPointIndex = source.getToPointIndex;
        if (source.setToPointIndex)
            importer.setToPointIndex = source.setToPointIndex;
        if (source.getPoints)
            importer.getPoints = source.getPoints;
        if (source.setPoints)
            importer.setPoints = source.setPoints;
        if (source.getText)
            importer.getText = source.getText;
        if (source.setText)
            importer.setText = source.setText;
        if (source.getLineOption)
            importer.getLineOption = source.getLineOption;
        if (source.setLineOption)
            importer.setLineOption = source.setLineOption;
        if (source.getStartLineEnding)
            importer.getStartLineEnding = source.getStartLineEnding;
        if (source.setStartLineEnding)
            importer.setStartLineEnding = source.setStartLineEnding;
        if (source.getEndLineEnding)
            importer.getEndLineEnding = source.getEndLineEnding;
        if (source.setEndLineEnding)
            importer.setEndLineEnding = source.setEndLineEnding;
    };
    DataSource.prototype.fetchData = function () {
        var _this = this;
        this.nodes = [];
        this.edges = [];
        this.autoGeneratedDataKeys = {};
        this.useNodeParentId = this.nodeDataImporter.getParentKey !== undefined;
        this.useNodeContainerId = this.nodeDataImporter.getContainerKey !== undefined;
        this.useNodeItems = this.nodeDataImporter.getItems !== undefined;
        this.useNodeChildren = this.nodeDataImporter.getChildren !== undefined;
        this.canUseAutoSize = this.nodeDataImporter.getWidth === undefined && this.nodeDataImporter.getText !== undefined;
        if (this.useEdgesArray() && this.useNodeParentId)
            throw new Error("You cannot use edges array and parentKey simultaneously.");
        if (this.useEdgesArray() && this.useNodeItems)
            throw new Error("You cannot use edges array and items array simultaneously.");
        if (this.useNodeParentId && this.useNodeItems)
            throw new Error("You cannot use parentKey and items array simultaneously.");
        if (this.useNodeContainerId && this.useNodeChildren)
            throw new Error("You cannot use containerKey and children array simultaneously.");
        this.nodeDataSource.forEach(function (nodeDataObj) {
            _this.addNode(nodeDataObj);
        });
        if (this.useEdgesArray())
            this.edgeDataSource.forEach(function (edgeDataObj) {
                _this.addEdge(edgeDataObj);
            });
        else
            this.nodes.forEach(function (node) {
                _this.addNodeEdgesByParentId(node);
            });
    };
    DataSource.prototype.isContainer = function (itemKey) {
        var _this = this;
        if (!this.containers && this.useNodeContainerId)
            this.containers = this.nodeDataSource
                .map(function (i) { return _this.nodeDataImporter.getContainerKey(i); })
                .filter(function (i) { return i !== undefined && i !== null; })
                .reduce(function (map, i) {
                map[i] = true;
                return map;
            }, {});
        return this.containers && this.containers[itemKey];
    };
    DataSource.prototype.refetchData = function (nodeDataSource, edgeDataSource) {
        var _this = this;
        this.nodeDataSource = nodeDataSource || this.nodeDataSource;
        this.edgeDataSource = edgeDataSource || this.edgeDataSource;
        var oldNodes = this.nodes.slice();
        var oldEdges = this.edges.slice();
        this.fetchData();
        var changedNodes = this.getItemChanges(oldNodes, this.nodes, function (item1, item2) {
            return (item1.key === item2.key) || (item1.dataObj === item2.dataObj);
        });
        var changedEdges = this.getItemChanges(oldEdges, this.edges, function (item1, item2) {
            if (_this.useNodeParentId || _this.useNodeItems)
                return (item1.key === item2.key) || (item1.from === item2.from && item1.to === item2.to);
            return (item1.key === item2.key) || (item1.dataObj === item2.dataObj);
        });
        return { nodes: changedNodes, edges: changedEdges };
    };
    DataSource.prototype.getItemChanges = function (oldItems, newItems, areEqual) {
        var _this = this;
        var remainedItems = oldItems.filter(function (item) { return _this.containsItem(newItems, item, areEqual); });
        var remainedNewItems = newItems.filter(function (item) { return _this.containsItem(oldItems, item, areEqual); });
        var removedItems = oldItems.filter(function (item) { return !_this.containsItem(newItems, item, areEqual); });
        var addedItems = newItems.filter(function (item) { return !_this.containsItem(oldItems, item, areEqual); });
        return {
            remained: remainedItems.map(function (item) { return item.key; }),
            remainedNew: remainedNewItems.map(function (item) { return item.key; }),
            removed: removedItems.map(function (item) { return item.key; }),
            added: addedItems.map(function (item) { return item.key; })
        };
    };
    DataSource.prototype.containsItem = function (items, item, areEqual) {
        var result = false;
        items.forEach(function (i) {
            if (!result && areEqual(i, item))
                result = true;
        });
        return result;
    };
    DataSource.prototype.useEdgesArray = function () {
        return Array.isArray(this.edgeDataSource) && (this.edgeDataSource.length || !(this.useNodeParentId || this.useNodeItems));
    };
    DataSource.prototype.addNode = function (nodeDataObj, parentNodeDataObj, containerKey, containerNodeDataObj) {
        var _this = this;
        var childNodeDataObjs = this.nodeDataImporter.getChildren && this.nodeDataImporter.getChildren(nodeDataObj);
        var hasChildren = childNodeDataObjs && Array.isArray(childNodeDataObjs) && childNodeDataObjs.length;
        var isContainer = hasChildren || this.isContainer(this.nodeDataImporter.getKey(nodeDataObj));
        var type = this.nodeDataImporter.getType && this.nodeDataImporter.getType(nodeDataObj) || (isContainer && ShapeTypes_1.ShapeTypes.VerticalContainer) || ShapeTypes_1.ShapeTypes.Rectangle;
        var text = this.nodeDataImporter.getText && (this.nodeDataImporter.getText(nodeDataObj) || "");
        var node = this.addNodeInternal(nodeDataObj, type, text, parentNodeDataObj, containerKey, containerNodeDataObj);
        this.assignNodeProperties(node, nodeDataObj);
        if (hasChildren)
            childNodeDataObjs.forEach(function (childNodeDataObj) {
                _this.addNode(childNodeDataObj, undefined, node.key, nodeDataObj);
            });
        if (this.useNodeItems) {
            var itemDataObjs = this.nodeDataImporter.getItems(nodeDataObj);
            if (Array.isArray(itemDataObjs) && itemDataObjs.length)
                itemDataObjs.forEach(function (itemDataObj) {
                    var itemNode = _this.addNode(itemDataObj, nodeDataObj, containerKey, containerNodeDataObj);
                    _this.addEdgeInternal(undefined, node.key, itemNode.key);
                });
        }
        return node;
    };
    DataSource.prototype.addNodeEdgesByParentId = function (node) {
        if (this.useNodeParentId) {
            var parentKey = this.nodeDataImporter.getParentKey(node.dataObj);
            if (parentKey !== undefined && parentKey !== null) {
                var parentNode = this.findNode(parentKey);
                if (parentNode)
                    this.addEdgeInternal(undefined, this.getNodeKey(node.dataObj, this.nodeDataImporter.getParentKey), this.getNodeKey(node.dataObj, this.nodeDataImporter.getKey));
            }
        }
    };
    DataSource.prototype.addNodeInternal = function (nodeDataObj, type, text, parentNodeDataObj, containerKey, containerNodeDataObj) {
        var externalKey = this.nodeDataImporter.getKey(nodeDataObj);
        var key = (externalKey !== undefined && externalKey !== null) ? externalKey : ModelUtils_1.ModelUtils.getGuidItemKey();
        var node = new DataSourceItems_1.DataSourceNodeItem(this.key, key, nodeDataObj, type, text, parentNodeDataObj, containerKey, containerNodeDataObj);
        this.nodes.push(node);
        if (externalKey === undefined || externalKey === null) {
            externalKey = key;
            this.autoGeneratedDataKeys[key] = true;
        }
        return node;
    };
    DataSource.prototype.addEdge = function (edgeDataObj) {
        var edge = this.addEdgeInternal(edgeDataObj, this.getNodeKey(edgeDataObj, this.edgeDataImporter.getFrom), this.getNodeKey(edgeDataObj, this.edgeDataImporter.getTo));
        this.assignEdgeProperties(edge, edgeDataObj);
        return edge;
    };
    DataSource.prototype.addEdgeInternal = function (edgeDataObj, from, to) {
        var externalKey = edgeDataObj && this.edgeDataImporter.getKey(edgeDataObj);
        var key = (externalKey !== undefined && externalKey !== null) ? externalKey : ModelUtils_1.ModelUtils.getGuidItemKey();
        var edge = new DataSourceItems_1.DataSourceEdgeItem(this.key, key, edgeDataObj, from, to);
        this.edges.push(edge);
        if (externalKey === undefined || externalKey === null) {
            externalKey = key;
            this.autoGeneratedDataKeys[key] = true;
        }
        return edge;
    };
    DataSource.prototype.assignItemProperties = function (item, dataObj, importer) {
        if (importer.getCustomData)
            item.customData = Utils_1.ObjectUtils.cloneObject(importer.getCustomData(dataObj));
        if (importer.getLocked)
            item.locked = importer.getLocked(dataObj);
        if (importer.getStyle) {
            var style = importer.getStyle(dataObj);
            item.style = typeof style === "string" ? Data_1.Data.cssTextToObject(style) : style;
        }
        if (importer.getStyleText) {
            var style = importer.getStyleText(dataObj);
            item.styleText = typeof style === "string" ? Data_1.Data.cssTextToObject(style) : style;
        }
        if (importer.getZIndex)
            item.zIndex = importer.getZIndex(dataObj);
    };
    DataSource.prototype.assignNodeProperties = function (item, dataObj) {
        this.assignItemProperties(item, dataObj, this.nodeDataImporter);
        if (this.nodeDataImporter.getImage)
            item.image = this.nodeDataImporter.getImage(dataObj);
        if (this.nodeDataImporter.getLeft)
            item.left = this.nodeDataImporter.getLeft(dataObj);
        if (this.nodeDataImporter.getTop)
            item.top = this.nodeDataImporter.getTop(dataObj);
        if (this.nodeDataImporter.getWidth)
            item.width = this.nodeDataImporter.getWidth(dataObj);
        if (this.nodeDataImporter.getHeight)
            item.height = this.nodeDataImporter.getHeight(dataObj);
        if (this.nodeDataImporter.getContainerKey)
            item.containerKey = this.nodeDataImporter.getContainerKey(dataObj);
    };
    DataSource.prototype.assignEdgeProperties = function (item, dataObj) {
        this.assignItemProperties(item, dataObj, this.edgeDataImporter);
        if (this.edgeDataImporter.getFromPointIndex)
            item.fromPointIndex = this.edgeDataImporter.getFromPointIndex(dataObj);
        if (this.edgeDataImporter.getToPointIndex)
            item.toPointIndex = this.edgeDataImporter.getToPointIndex(dataObj);
        if (this.edgeDataImporter.getPoints)
            item.points = this.edgeDataImporter.getPoints(dataObj);
        if (this.edgeDataImporter.getText) {
            var texts = this.edgeDataImporter.getText(dataObj);
            item.texts = {};
            if (typeof texts === "object")
                for (var key in texts) {
                    if (!Object.prototype.hasOwnProperty.call(texts, key))
                        continue;
                    var position = parseFloat(key);
                    var text = texts[key];
                    if (!isNaN(position) && typeof text === "string" && text !== "") {
                        position = Math.min(1, Math.max(0, position));
                        item.texts[position] = text;
                    }
                }
            else if (typeof texts === "string" && texts !== "")
                item.texts[Connector_1.CONNECTOR_DEFAULT_TEXT_POSITION] = texts;
        }
        if (this.edgeDataImporter.getLineOption)
            item.lineOption = this.edgeDataImporter.getLineOption(dataObj);
        if (this.edgeDataImporter.getStartLineEnding)
            item.startLineEnding = this.edgeDataImporter.getStartLineEnding(dataObj);
        if (this.edgeDataImporter.getEndLineEnding)
            item.endLineEnding = this.edgeDataImporter.getEndLineEnding(dataObj);
    };
    DataSource.prototype.findNode = function (key) {
        return this.nodes.filter(function (i) { return key !== undefined && i.key === key; })[0];
    };
    DataSource.prototype.findEdge = function (key) {
        return this.edges.filter(function (i) { return key !== undefined && i.key === key; })[0];
    };
    DataSource.prototype.getNodeKey = function (nodeDataObj, getKey) {
        return getKey(nodeDataObj);
    };
    DataSource.prototype.createModelItems = function (history, model, shapeDescriptionManager, selection, layoutParameters, snapToGrid, gridSize, measurer) {
        var _this = this;
        this.beginChangesNotification();
        history.clear();
        history.beginTransaction();
        ModelUtils_1.ModelUtils.deleteAllItems(history, model, selection);
        model.initializeKeyCounter();
        var DEFAULT_STEP = 2000;
        var rowIndex = 0;
        var colIndex = 0;
        var externalToInnerMap = {};
        var shapes = [];
        var connectors = [];
        this.nodes.forEach(function (node) {
            var point = new point_1.Point(colIndex++ * DEFAULT_STEP, rowIndex * DEFAULT_STEP);
            var shape = _this.createShapeByNode(history, model, selection, shapeDescriptionManager, node, point, layoutParameters, snapToGrid, gridSize, measurer);
            if (node.key !== undefined)
                externalToInnerMap[node.key] = shape.key;
            if (colIndex > 4) {
                colIndex = 0;
                rowIndex++;
            }
            shapes.push(shape);
        });
        this.nodes.forEach(function (node) {
            if (node.containerKey !== undefined && node.containerKey !== null) {
                var shapeKey = externalToInnerMap[node.key];
                var shape = model.findShape(shapeKey);
                var containerShapeKey = externalToInnerMap[node.containerKey];
                var containerShape = model.findShape(containerShapeKey);
                if (containerShape)
                    ModelUtils_1.ModelUtils.insertToContainer(history, model, shape, containerShape);
            }
        });
        this.edges.forEach(function (edge) {
            var toShape = model.findShape(externalToInnerMap[edge.to]);
            var fromShape = model.findShape(externalToInnerMap[edge.from]);
            var connector = _this.createConnectorByEdge(history, model, selection, edge, fromShape, toShape);
            if (connector) {
                connectors.push(connector);
                ModelUtils_1.ModelUtils.updateConnectorContainer(history, model, connector);
            }
        });
        if (layoutParameters.needAutoLayout)
            this.applyLayout(history, model, shapes, connectors, layoutParameters, snapToGrid, gridSize);
        ModelUtils_1.ModelUtils.tryUpdateModelRectangle(history);
        history.endTransaction(true);
        this.endChangesNotification(true);
    };
    DataSource.prototype.updateModelItems = function (history, model, shapeDescriptionManager, selection, layoutParameters, addNewHistoryItem, updateDataKeys, updateTemplateItem, changes, snapToGrid, gridSize, measurer) {
        var _this = this;
        this.beginChangesNotification();
        history.beginTransaction();
        var itemsToUpdate = [];
        var layoutShapes = [];
        var layoutConnectors = [];
        var shapesToRemove = changes.nodes.removed.map(function (key) { return model.findShapeByDataKey(key); }).filter(function (item) { return item; });
        shapesToRemove.forEach(function (shape) {
            shape.attachedConnectors.forEach(function (connector) {
                if (connector.beginItem && connector.beginItem !== shape)
                    layoutShapes.push(connector.beginItem);
                if (connector.endItem && connector.endItem !== shape)
                    layoutShapes.push(connector.endItem);
            });
        });
        ModelUtils_1.ModelUtils.deleteItems(history, model, selection, shapesToRemove, true);
        var connectorsToRemove = changes.edges.removed.map(function (key) { return model.findConnectorByDataKey(key); }).filter(function (item) { return item; });
        connectorsToRemove.forEach(function (connector) {
            if (connector.beginItem)
                layoutShapes.push(connector.beginItem);
            if (connector.endItem)
                layoutShapes.push(connector.endItem);
        });
        ModelUtils_1.ModelUtils.deleteItems(history, model, selection, connectorsToRemove, true);
        layoutShapes = this.purgeLayoutShapes(layoutShapes, shapesToRemove);
        var nodeKeysToUpdate = updateDataKeys || [];
        nodeKeysToUpdate.forEach(function (dataKey) {
            if (changes.nodes.remained.indexOf(dataKey) === -1)
                return;
            var node = _this.findNode(dataKey);
            if (node) {
                var shape = model.findShapeByDataKey(dataKey);
                if (shape) {
                    var position = shape.position.clone();
                    _this.changeShapeByDataItem(history, model, shape, node, position);
                    _this.changeItemByDataItem(history, shape, node);
                }
                else
                    shape = _this.createShapeByNode(history, model, selection, shapeDescriptionManager, node, new point_1.Point(0, 0), layoutParameters, snapToGrid, gridSize, measurer);
                _this.updateShapeContainer(history, model, shape, node);
                layoutShapes.push(shape);
                itemsToUpdate.push(shape);
            }
        });
        changes.nodes.remained.forEach(function (dataKey, index) {
            var shape = model.findShapeByDataKey(dataKey);
            if (shape)
                shape.dataKey = changes.nodes.remainedNew[index];
        });
        changes.nodes.added.forEach(function (dataKey) {
            var node = _this.findNode(dataKey);
            var shape = _this.createShapeByNode(history, model, selection, shapeDescriptionManager, node, new point_1.Point(0, 0), layoutParameters, snapToGrid, gridSize, measurer);
            _this.updateShapeContainer(history, model, shape, node);
            layoutShapes.push(shape);
        });
        changes.edges.added.forEach(function (dataKey) {
            var edge = _this.findEdge(dataKey);
            var fromShape = model.findShapeByDataKey(edge.from);
            var toShape = model.findShapeByDataKey(edge.to);
            var connector = _this.createConnectorByEdge(history, model, selection, edge, fromShape, toShape);
            if (connector) {
                ModelUtils_1.ModelUtils.updateConnectorContainer(history, model, connector);
                layoutConnectors.push(connector);
            }
        });
        var edgeKeysToUpdate = updateDataKeys || [];
        changes.edges.remained.forEach(function (dataKey) {
            var edge = _this.findEdge(dataKey);
            if (edge && ((changes.nodes.added.indexOf(edge.from) !== -1) || (changes.nodes.added.indexOf(edge.to) !== -1)))
                edgeKeysToUpdate.push(dataKey);
        });
        edgeKeysToUpdate.forEach(function (dataKey) {
            if (changes.edges.remained.indexOf(dataKey) === -1)
                return;
            var edge = _this.findEdge(dataKey);
            if (edge) {
                var fromShape = model.findShapeByDataKey(edge.from);
                var toShape = model.findShapeByDataKey(edge.to);
                var connector = model.findConnectorByDataKey(dataKey);
                if (connector) {
                    _this.changeConnectorPointsByDataItem(history, connector, _this.getConnectorPointsByEdge(model, edge, fromShape, toShape));
                    _this.changeConnectorByDataItem(history, model, connector, fromShape, toShape, edge);
                    _this.changeItemByDataItem(history, connector, edge);
                }
                else
                    connector = _this.createConnectorByEdge(history, model, selection, edge, fromShape, toShape);
                if (connector) {
                    ModelUtils_1.ModelUtils.updateConnectorContainer(history, model, connector);
                    layoutConnectors.push(connector);
                    itemsToUpdate.push(connector);
                }
            }
        });
        changes.edges.remained.forEach(function (dataKey, index) {
            var connector = model.findConnectorByDataKey(dataKey);
            if (connector)
                connector.dataKey = changes.edges.remainedNew[index];
        });
        if (itemsToUpdate.length && updateTemplateItem)
            itemsToUpdate.forEach(function (item) { item.hasTemplate && updateTemplateItem(item); });
        if (layoutParameters.needAutoLayout && (layoutShapes.length || layoutConnectors.length))
            this.applyLayout(history, model, layoutShapes, layoutConnectors, layoutParameters, snapToGrid, gridSize);
        ModelUtils_1.ModelUtils.tryUpdateModelRectangle(history);
        history.endTransaction(!addNewHistoryItem);
        this.endChangesNotification(false);
    };
    DataSource.prototype.purgeLayoutShapes = function (layoutShapes, shapesToRemove) {
        var shapesToRemoveKeySet = shapesToRemove.reduce(function (acc, shape) { return (acc[shape.key] = true) && acc; }, {});
        return layoutShapes.reduce(function (acc, shape) {
            if (acc.keySet[shape.key] === undefined && shapesToRemoveKeySet[shape.key] === undefined) {
                acc.uniqueShapes.push(shape);
                acc.keySet[shape.key] = true;
            }
            return acc;
        }, { uniqueShapes: [], keySet: {} }).uniqueShapes;
    };
    DataSource.prototype.applyShapeAutoSize = function (history, measurer, shapeSizeSettings, shape, snapToGrid, gridSize) {
        if (!shape.description.enableText)
            return;
        var shapeTextSize = shape.textRectangle.createSize();
        var shapeSize = shape.size;
        var textHorOffset = shapeTextSize.width - shapeSize.width;
        var textVerOffset = shapeTextSize.height - shapeSize.height;
        var maxWidth = shape.getMaxWidth(shapeSizeSettings.shapeMaxWidth);
        var maxHeight = shape.getMaxHeight(shapeSizeSettings.shapeMaxHeight);
        var sizeToPx = function (size, isHorizontal) { return typeof (size) === "number" ? unit_converter_1.UnitConverter.twipsToPixelsF(size + (isHorizontal ? textHorOffset : textVerOffset)) : undefined; };
        var newShapeTextSize = TextUtils_1.getOptimalTextRectangle(shape.text, shape.styleText, ITextMeasurer_1.TextOwner.Shape, measurer, shapeTextSize.clone().applyConverter(unit_converter_1.UnitConverter.twipsToPixelsF), shape.description.keepRatioOnAutoSize, sizeToPx(shape.getMinWidth(shapeSizeSettings.shapeMinWidth), true), sizeToPx(maxWidth, true), sizeToPx(shape.getMinHeight(shapeSizeSettings.shapeMinHeight), false), sizeToPx(maxHeight, false))
            .clone().applyConverter(unit_converter_1.UnitConverter.pixelsToTwips);
        if (!newShapeTextSize.equals(shapeTextSize)) {
            var shapeNewSize = shape.description.getSizeByText(newShapeTextSize, shape);
            if (snapToGrid && gridSize)
                shapeNewSize = new size_1.Size(Math.min(gridSize * Math.ceil(shapeNewSize.width / gridSize), maxWidth || Number.MAX_VALUE), Math.min(gridSize * Math.ceil(shapeNewSize.height / gridSize), maxHeight || Number.MAX_VALUE));
            history.addAndRedo(new ResizeShapeHistoryItem_1.ResizeShapeHistoryItem(shape.key, shape.position, shapeNewSize));
        }
    };
    DataSource.prototype.applyLayout = function (history, model, shapes, connectors, layoutParameters, snapToGrid, gridSize) {
        var graphInfo = ModelUtils_1.ModelUtils.getGraphInfoByItems(model, shapes, connectors);
        graphInfo.forEach(function (info) {
            var layout = layoutParameters.getLayoutBuilder(info.graph).build();
            var nonGraphItems = ModelUtils_1.ModelUtils.getNonGraphItems(model, info.container, layout.nodeToLayout, shapes, connectors);
            ModelUtils_1.ModelUtils.applyLayout(history, model, info.container, info.graph, layout, nonGraphItems, layoutParameters.layoutSettings, snapToGrid, gridSize, layoutParameters.skipPointIndices);
        });
    };
    DataSource.prototype.changeItemByDataItem = function (history, item, dataItem) {
        if (dataItem.customData !== undefined && !Utils_1.ObjectUtils.compareObjects(dataItem.customData, item.customData))
            history.addAndRedo(new ChangeCustomDataHistoryItem_1.ChangeCustomDataHistoryItem(item.key, dataItem.customData));
        if (dataItem.zIndex !== undefined && dataItem.zIndex !== item.zIndex)
            history.addAndRedo(new ChangeZindexHistoryItem_1.ChangeZindexHistoryItem(item, dataItem.zIndex));
        if (dataItem.style !== undefined)
            for (var key in dataItem.style) {
                if (!Object.prototype.hasOwnProperty.call(dataItem.style, key))
                    continue;
                var value = this.getPreparedStyleValue(dataItem.style[key], Svg_1.isColorProperty(key));
                if (value !== item.style[key])
                    history.addAndRedo(new ChangeStyleHistoryItem_1.ChangeStyleHistoryItem(item.key, key, value));
            }
        var defaultStyle = item.style.getDefaultInstance();
        item.style.forEach(function (key) {
            if ((dataItem.style && dataItem.style[key] === undefined) && item.style[key] !== defaultStyle[key])
                history.addAndRedo(new ChangeStyleHistoryItem_1.ChangeStyleHistoryItem(item.key, key, defaultStyle[key]));
        });
        if (dataItem.styleText !== undefined)
            for (var key in dataItem.styleText) {
                if (!Object.prototype.hasOwnProperty.call(dataItem.styleText, key))
                    continue;
                var value = this.getPreparedStyleValue(dataItem.styleText[key], Svg_1.isColorProperty(key));
                if (value !== item.styleText[key])
                    history.addAndRedo(new ChangeStyleTextHistoryItem_1.ChangeStyleTextHistoryItem(item.key, key, value));
            }
        var defaultTextStyle = item.styleText.getDefaultInstance();
        item.styleText.forEach(function (key) {
            if ((dataItem.styleText && dataItem.styleText[key] === undefined) && item.styleText[key] !== defaultTextStyle[key])
                history.addAndRedo(new ChangeStyleTextHistoryItem_1.ChangeStyleTextHistoryItem(item.key, key, defaultTextStyle[key]));
        });
        if (dataItem.locked !== undefined && dataItem.locked !== item.locked)
            history.addAndRedo(new ChangeLockedHistoryItem_1.ChangeLockedHistoryItem(item, dataItem.locked));
    };
    DataSource.prototype.getPreparedStyleValue = function (value, isColorProperty) {
        if (isColorProperty) {
            var colorValue = color_1.ColorUtils.stringToHash(value);
            if (colorValue !== null)
                value = colorValue;
        }
        return value;
    };
    DataSource.prototype.createShapeByNode = function (history, model, selection, shapeDescriptionManager, node, point, layoutParameters, snapToGrid, gridSize, measurer) {
        var insert = new AddShapeHistoryItem_1.AddShapeHistoryItem(shapeDescriptionManager.get(node.type), point, "", node.key);
        history.addAndRedo(insert);
        var shape = model.findShape(insert.shapeKey);
        ModelUtils_1.ModelUtils.updateNewShapeProperties(history, selection, insert.shapeKey);
        this.changeShapeByDataItem(history, model, shape, node, point);
        this.changeItemByDataItem(history, shape, node);
        if (measurer && this.canUseAutoSize && layoutParameters.autoSizeEnabled)
            this.applyShapeAutoSize(history, measurer, layoutParameters.sizeSettings, shape, snapToGrid, gridSize);
        return shape;
    };
    DataSource.prototype.changeShapeByDataItem = function (history, model, shape, node, point) {
        if (node.left !== undefined)
            point.x = ModelUtils_1.ModelUtils.getTwipsValue(model.units, node.left);
        if (node.top !== undefined)
            point.y = ModelUtils_1.ModelUtils.getTwipsValue(model.units, node.top);
        ModelUtils_1.ModelUtils.setShapePosition(history, model, shape, point, false);
        var size = shape.size.clone();
        if (node.width !== undefined)
            size.width = ModelUtils_1.ModelUtils.getTwipsValue(model.units, node.width);
        if (node.height !== undefined)
            size.height = ModelUtils_1.ModelUtils.getTwipsValue(model.units, node.height);
        ModelUtils_1.ModelUtils.setShapeSize(history, model, shape, point, size);
        ModelUtils_1.ModelUtils.updateShapeAttachedConnectors(history, model, shape);
        if (node.text !== undefined && node.text !== shape.text)
            history.addAndRedo(new ChangeShapeTextHistoryItem_1.ChangeShapeTextHistoryItem(shape, node.text));
        if (node.image !== undefined && node.image !== shape.image.actualUrl)
            history.addAndRedo(new ChangeShapeImageHistoryItem_1.ChangeShapeImageHistoryItem(shape, node.image));
    };
    DataSource.prototype.updateShapeContainer = function (history, model, shape, node) {
        var containerShape = (node.containerKey !== undefined) ? model.findShapeByDataKey(node.containerKey) : undefined;
        if (containerShape !== shape.container)
            if (containerShape)
                ModelUtils_1.ModelUtils.insertToContainer(history, model, shape, containerShape);
            else
                ModelUtils_1.ModelUtils.removeFromContainer(history, model, shape);
    };
    DataSource.prototype.getConnectorPointsByEdge = function (model, edge, fromShape, toShape) {
        var result = [];
        var modelPoints = this.createModelPointFromDataSourceEdgeItemPoints(model.units, edge);
        if (!modelPoints || modelPoints.length <= 1) {
            if (!fromShape || !toShape)
                return undefined;
            result.push(fromShape.position.clone());
            result.push(toShape.position.clone());
            return result;
        }
        var lastIndex = modelPoints.length - 1;
        for (var i = 0; i <= lastIndex; i++) {
            var modelPoint = modelPoints[i];
            if (modelPoint !== null)
                result.push(modelPoint);
            else if (!fromShape && !toShape)
                return undefined;
            else if (i === 0 && fromShape)
                result.push(fromShape.position.clone());
            else if (i === lastIndex && toShape)
                result.push(toShape.position.clone());
        }
        return result;
    };
    DataSource.prototype.createModelPointFromDataSourceEdgeItemPoints = function (units, edge) {
        var _this = this;
        var result = [];
        if (!Array.isArray(edge.points))
            return undefined;
        edge.points.forEach(function (dep) { return result.push(_this.isValidDataSourceEdgeItemPoint(dep) ? _this.createModelPoint(units, dep) : null); });
        return result;
    };
    DataSource.prototype.createModelPoint = function (units, point) {
        return new point_1.Point(ModelUtils_1.ModelUtils.getTwipsValue(units, point.x), ModelUtils_1.ModelUtils.getTwipsValue(units, point.y));
    };
    DataSource.prototype.isValidDataSourceEdgeItemPoint = function (point) {
        return point !== undefined && point !== null &&
            point.x !== undefined && point.y !== undefined &&
            point.x !== null && point.y !== null;
    };
    DataSource.prototype.createConnectorByEdge = function (history, model, selection, edge, fromShape, toShape) {
        var connector;
        var dataKey = edge.key;
        var points = this.getConnectorPointsByEdge(model, edge, fromShape, toShape);
        if (points && points.length > 1) {
            var insert = new AddConnectorHistoryItem_1.AddConnectorHistoryItem(points, dataKey);
            history.addAndRedo(insert);
            connector = model.findConnector(insert.connectorKey);
            ModelUtils_1.ModelUtils.updateNewConnectorProperties(history, selection, insert.connectorKey);
            this.changeConnectorByDataItem(history, model, connector, fromShape, toShape, edge);
            this.changeItemByDataItem(history, connector, edge);
        }
        return connector;
    };
    DataSource.prototype.changeConnectorByDataItem = function (history, model, connector, fromShape, toShape, edge) {
        var fromPointIndex = edge.fromPointIndex !== undefined ? edge.fromPointIndex : connector.beginConnectionPointIndex;
        if (connector.beginItem !== fromShape || connector.beginConnectionPointIndex !== fromPointIndex) {
            if (connector.beginItem)
                history.addAndRedo(new DeleteConnectionHistoryItem_1.DeleteConnectionHistoryItem(connector, Connector_1.ConnectorPosition.Begin));
            if (fromShape)
                history.addAndRedo(new AddConnectionHistoryItem_1.AddConnectionHistoryItem(connector, fromShape, fromPointIndex, Connector_1.ConnectorPosition.Begin));
        }
        var toPointIndex = edge.toPointIndex !== undefined ? edge.toPointIndex : connector.endConnectionPointIndex;
        if (connector.endItem !== toShape || connector.endConnectionPointIndex !== toPointIndex) {
            if (connector.endItem)
                history.addAndRedo(new DeleteConnectionHistoryItem_1.DeleteConnectionHistoryItem(connector, Connector_1.ConnectorPosition.End));
            if (toShape)
                history.addAndRedo(new AddConnectionHistoryItem_1.AddConnectionHistoryItem(connector, toShape, toPointIndex, Connector_1.ConnectorPosition.End));
        }
        ModelUtils_1.ModelUtils.updateConnectorAttachedPoints(history, model, connector);
        if (edge.texts !== undefined && !this.compareTexts(edge, connector)) {
            connector.texts.forEach(function (text) {
                history.addAndRedo(new ChangeConnectorTextHistoryItem_1.ChangeConnectorTextHistoryItem(connector, text.position, undefined));
            });
            for (var key in edge.texts) {
                if (!Object.prototype.hasOwnProperty.call(edge.texts, key))
                    continue;
                var position = parseFloat(key);
                history.addAndRedo(new ChangeConnectorTextHistoryItem_1.ChangeConnectorTextHistoryItem(connector, position, edge.texts[key]));
            }
        }
        if (edge.lineOption !== undefined && edge.lineOption !== connector.properties.lineOption)
            history.addAndRedo(new ChangeConnectorPropertyHistoryItem_1.ChangeConnectorPropertyHistoryItem(connector.key, "lineOption", edge.lineOption));
        if (edge.startLineEnding !== undefined && edge.startLineEnding !== connector.properties.startLineEnding)
            history.addAndRedo(new ChangeConnectorPropertyHistoryItem_1.ChangeConnectorPropertyHistoryItem(connector.key, "startLineEnding", edge.startLineEnding));
        if (edge.endLineEnding !== undefined && edge.endLineEnding !== connector.properties.endLineEnding)
            history.addAndRedo(new ChangeConnectorPropertyHistoryItem_1.ChangeConnectorPropertyHistoryItem(connector.key, "endLineEnding", edge.endLineEnding));
    };
    DataSource.prototype.changeConnectorPointsByDataItem = function (history, connector, newPoints) {
        if (newPoints && newPoints.length > 1 && newPoints.join(",") !== connector.points.join(","))
            history.addAndRedo(new ChangeConnectorPointsHistoryItem_1.ReplaceConnectorPointsHistoryItem(connector.key, newPoints));
    };
    DataSource.prototype.compareTexts = function (edgeObj, connector) {
        var texts = edgeObj.texts || {};
        var result = Object.keys(texts).length === connector.getTextCount();
        if (result)
            for (var key in texts) {
                if (!Object.prototype.hasOwnProperty.call(texts, key))
                    continue;
                var position = parseFloat(key);
                if (!this.compareStrings(connector.getText(position), texts[key]))
                    result = false;
            }
        return result;
    };
    DataSource.prototype.compareStrings = function (str1, str2) {
        if (typeof str1 === "string" && typeof str2 === "string")
            return str1 === str2;
        return this.isEmptyString(str1) && this.isEmptyString(str2);
    };
    DataSource.prototype.isEmptyString = function (str) {
        return str === "" || str === null || str === undefined;
    };
    return DataSource;
}());
exports.DataSource = DataSource;


/***/ }),
/* 347 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.DataSourceEdgeDataImporter = exports.DataSourceNodeDataImporter = exports.DataSourceItemDataImporter = void 0;
var DataSourceItemDataImporter = (function () {
    function DataSourceItemDataImporter() {
        this.getKey = function (obj) { return obj["id"]; };
        this.setKey = function (obj, value) { obj["id"] = value; };
        this.getCustomData = undefined;
        this.setCustomData = undefined;
        this.getLocked = undefined;
        this.setLocked = undefined;
        this.getStyle = undefined;
        this.setStyle = undefined;
        this.getStyleText = undefined;
        this.setStyleText = undefined;
        this.getZIndex = undefined;
        this.setZIndex = undefined;
    }
    return DataSourceItemDataImporter;
}());
exports.DataSourceItemDataImporter = DataSourceItemDataImporter;
var DataSourceNodeDataImporter = (function (_super) {
    __extends(DataSourceNodeDataImporter, _super);
    function DataSourceNodeDataImporter() {
        var _this = _super !== null && _super.apply(this, arguments) || this;
        _this.getType = undefined;
        _this.setType = undefined;
        _this.getText = undefined;
        _this.setText = undefined;
        _this.getImage = undefined;
        _this.setImage = undefined;
        _this.getLeft = undefined;
        _this.setLeft = undefined;
        _this.getTop = undefined;
        _this.setTop = undefined;
        _this.getWidth = undefined;
        _this.setWidth = undefined;
        _this.getHeight = undefined;
        _this.setHeight = undefined;
        _this.getChildren = undefined;
        _this.setChildren = undefined;
        _this.getParentKey = undefined;
        _this.setParentKey = undefined;
        _this.getItems = undefined;
        _this.setItems = undefined;
        _this.getContainerKey = undefined;
        _this.setContainerKey = undefined;
        return _this;
    }
    return DataSourceNodeDataImporter;
}(DataSourceItemDataImporter));
exports.DataSourceNodeDataImporter = DataSourceNodeDataImporter;
var DataSourceEdgeDataImporter = (function (_super) {
    __extends(DataSourceEdgeDataImporter, _super);
    function DataSourceEdgeDataImporter() {
        var _this = _super !== null && _super.apply(this, arguments) || this;
        _this.getFrom = function (obj) { return obj["from"]; };
        _this.setFrom = function (obj, value) { obj["from"] = value; };
        _this.getFromPointIndex = undefined;
        _this.setFromPointIndex = undefined;
        _this.getTo = function (obj) { return obj["to"]; };
        _this.setTo = function (obj, value) { obj["to"] = value; };
        _this.getToPointIndex = undefined;
        _this.setToPointIndex = undefined;
        _this.getPoints = undefined;
        _this.setPoints = undefined;
        _this.getText = undefined;
        _this.setText = undefined;
        _this.getLineOption = undefined;
        _this.setLineOption = undefined;
        _this.getStartLineEnding = undefined;
        _this.setStartLineEnding = undefined;
        _this.getEndLineEnding = undefined;
        _this.setEndLineEnding = undefined;
        return _this;
    }
    return DataSourceEdgeDataImporter;
}(DataSourceItemDataImporter));
exports.DataSourceEdgeDataImporter = DataSourceEdgeDataImporter;


/***/ }),
/* 348 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.DataSourceEdgeItem = exports.DataSourceNodeItem = exports.DataSourceItem = void 0;
var Connector_1 = __webpack_require__(6);
var DataSourceItem = (function () {
    function DataSourceItem(sourceKey, key, dataObj) {
        this.sourceKey = sourceKey;
        this.key = key;
        this.dataObj = dataObj;
    }
    return DataSourceItem;
}());
exports.DataSourceItem = DataSourceItem;
var DataSourceNodeItem = (function (_super) {
    __extends(DataSourceNodeItem, _super);
    function DataSourceNodeItem(sourceKey, key, dataObj, type, text, parentDataObj, containerKey, containerDataObj) {
        var _this = _super.call(this, sourceKey, key, dataObj) || this;
        _this.type = type;
        _this.text = text;
        _this.parentDataObj = parentDataObj;
        _this.containerKey = containerKey;
        _this.containerDataObj = containerDataObj;
        return _this;
    }
    return DataSourceNodeItem;
}(DataSourceItem));
exports.DataSourceNodeItem = DataSourceNodeItem;
var DataSourceEdgeItem = (function (_super) {
    __extends(DataSourceEdgeItem, _super);
    function DataSourceEdgeItem(sourceKey, key, dataObj, from, to) {
        var _this = _super.call(this, sourceKey, key, dataObj) || this;
        _this.sourceKey = sourceKey;
        _this.from = from;
        _this.to = to;
        return _this;
    }
    Object.defineProperty(DataSourceEdgeItem.prototype, "text", {
        get: function () {
            return this.texts && this.texts[Connector_1.CONNECTOR_DEFAULT_TEXT_POSITION];
        },
        enumerable: false,
        configurable: true
    });
    return DataSourceEdgeItem;
}(DataSourceItem));
exports.DataSourceEdgeItem = DataSourceEdgeItem;


/***/ }),
/* 349 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.ViewController = void 0;
var CommandManager_1 = __webpack_require__(82);
var LOG_MIN_ZOOM = Math.log(0.05);
var LOG_MAX_ZOOM = Math.log(3);
var ZOOM_STEPS = 40;
var ZERO_STEP = getStepByZoom(1);
var ZOOMLEVEL_COMMANDS = [CommandManager_1.DiagramCommand.ZoomLevel, CommandManager_1.DiagramCommand.ZoomLevelInPercentage, CommandManager_1.DiagramCommand.Zoom100, CommandManager_1.DiagramCommand.Zoom125, CommandManager_1.DiagramCommand.Zoom200, CommandManager_1.DiagramCommand.Zoom25, CommandManager_1.DiagramCommand.Zoom50, CommandManager_1.DiagramCommand.Zoom75];
var AUTOZOOM_COMMANDS = [CommandManager_1.DiagramCommand.SwitchAutoZoom, CommandManager_1.DiagramCommand.ToggleAutoZoom, CommandManager_1.DiagramCommand.AutoZoomToContent, CommandManager_1.DiagramCommand.AutoZoomToWidth];
var ViewController = (function () {
    function ViewController(settings, bars) {
        this.settings = settings;
        this.bars = bars;
        settings.onZoomChanged.add(this);
        this.autoZoom = settings.autoZoom;
    }
    ViewController.prototype.initialize = function (view) {
        this.view = view;
        this.view.onViewChanged.add(this);
    };
    ViewController.prototype.scrollTo = function (modelPoint, offsetPoint) {
        if (this.view)
            this.view.setScrollTo(modelPoint, offsetPoint);
    };
    ViewController.prototype.scrollBy = function (offset) {
        if (this.view && (offset.x !== 0 || offset.y !== 0))
            return this.view.scrollBy(offset);
        return offset;
    };
    ViewController.prototype.scrollIntoView = function (rectangle) {
        this.view && this.view.scrollIntoView(rectangle);
    };
    ViewController.prototype.normalize = function () {
        this.view.tryNormalizePaddings();
    };
    ViewController.prototype.getNextStepZoom = function (increase) {
        var currentZoomStep = this.getNearestCurrentZoomStep();
        var delta = increase ? 1 : -1;
        var step = Math.min(ZOOM_STEPS - 1, Math.max(0, currentZoomStep + delta));
        if (step !== ZERO_STEP) {
            var logZoom = LOG_MIN_ZOOM + (LOG_MAX_ZOOM - LOG_MIN_ZOOM) * step / (ZOOM_STEPS - 1);
            return Math.exp(logZoom);
        }
        return 1;
    };
    ViewController.prototype.getNearestCurrentZoomStep = function () {
        var zoom = this.getZoom();
        return getStepByZoom(zoom);
    };
    ViewController.prototype.getZoom = function () {
        return this.view ? this.view.actualZoom : this.settings.zoomLevel;
    };
    ViewController.prototype.resetScroll = function () {
        this.view.adjust({ horizontal: true, vertical: true });
    };
    ViewController.prototype.notifyViewAdjusted = function (canvasOffset) { };
    ViewController.prototype.notifyActualZoomChanged = function (actualZoom) {
        this.bars.updateItemsState(ZOOMLEVEL_COMMANDS);
    };
    ViewController.prototype.notifyZoomChanged = function (fixedZoomLevel, autoZoom) {
        if (this.autoZoom !== autoZoom) {
            this.autoZoom = autoZoom;
            this.bars.updateItemsState(AUTOZOOM_COMMANDS);
        }
    };
    return ViewController;
}());
exports.ViewController = ViewController;
function getStepByZoom(zoom) {
    var logZoom = Math.log(zoom);
    return Math.round((logZoom - LOG_MIN_ZOOM) * (ZOOM_STEPS - 1) / (LOG_MAX_ZOOM - LOG_MIN_ZOOM));
}


/***/ }),
/* 350 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.ToolboxManager = void 0;
var TextToolbox_1 = __webpack_require__(351);
var IconToolbox_1 = __webpack_require__(352);
var TextMeasurer_1 = __webpack_require__(79);
var math_1 = __webpack_require__(31);
var ToolboxManager = (function () {
    function ToolboxManager(shapeDescriptionManager) {
        this.shapeDescriptionManager = shapeDescriptionManager;
        this.toolboxes = [];
        this.measurers = {};
    }
    ToolboxManager.prototype.create = function (parent, readOnly, allowDragging, renderAsText, shapes, getAllowedShapeTypes, options) {
        var shapeTypes = Array.isArray(shapes) ? shapes : this.shapeDescriptionManager.getTypesByCategory(shapes);
        var toolbox = renderAsText ?
            new TextToolbox_1.TextToolbox(parent, readOnly, allowDragging, this.shapeDescriptionManager, shapeTypes, getAllowedShapeTypes) :
            new IconToolbox_1.IconToolbox(parent, readOnly, allowDragging, this.shapeDescriptionManager, shapeTypes, getAllowedShapeTypes, options, this.getOrCreateMeasurer(parent));
        toolbox.render();
        this.toolboxes.push(toolbox);
        return toolbox;
    };
    ToolboxManager.prototype.clean = function (removeElement, toolbox) {
        var _this = this;
        if (toolbox) {
            toolbox.clean(removeElement);
            this.toolboxes.splice(this.toolboxes.indexOf(toolbox), 1);
            Object.keys(this.measurers).forEach(function (key) {
                if (_this.measurers[key] === toolbox.measurer)
                    delete _this.measurers[key];
            });
        }
        else {
            for (var i = 0; i < this.toolboxes.length; i++)
                this.toolboxes[i].clean(removeElement);
            this.toolboxes = [];
            this.measurers = {};
        }
    };
    ToolboxManager.prototype.refresh = function (toolboxes) {
        this.toolboxes.forEach(function (toolbox, index) {
            if (!toolboxes || (Array.isArray(toolboxes) && toolboxes.indexOf(index) > -1) || index === toolboxes)
                toolbox.render();
        });
    };
    ToolboxManager.prototype.applyFilter = function (str, toolboxes) {
        var _this = this;
        return this.toolboxes.reduce(function (aggr, toolbox, index) {
            if (!toolboxes || (Array.isArray(toolboxes) && toolboxes.indexOf(index) > -1) || index === toolboxes)
                toolbox.render(function (shapeType) { return _this.searchFilter(shapeType, str, index); }) && aggr.push(index);
            return aggr;
        }, []);
    };
    ToolboxManager.prototype.searchFilter = function (shapeType, str, toolboxIndex, filteringToolboxes) {
        if (!str || (filteringToolboxes && filteringToolboxes.indexOf(toolboxIndex) === -1))
            return true;
        str = str.toLowerCase();
        var shapeDescription = this.shapeDescriptionManager.get(shapeType);
        return shapeDescription.getTitle().toLowerCase().indexOf(str) > -1 ||
            shapeDescription.getDefaultText().toLowerCase().indexOf(str) > -1;
    };
    ToolboxManager.prototype.getOrCreateMeasurer = function (parent) {
        var id = parent.getAttribute("data-dxdiMeasurerID");
        if (!id || !this.measurers[id]) {
            id = math_1.MathUtils.generateGuid();
            this.measurers[id] = new TextMeasurer_1.TextMeasurer(parent);
            parent.setAttribute("data-dxdiMeasurerID", id);
        }
        return this.measurers[id];
    };
    return ToolboxManager;
}());
exports.ToolboxManager = ToolboxManager;


/***/ }),
/* 351 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.TextToolbox = void 0;
var Toolbox_1 = __webpack_require__(159);
var TextToolbox = (function (_super) {
    __extends(TextToolbox, _super);
    function TextToolbox(parent, readOnly, allowDragging, shapeDescriptionManager, shapeTypes, getAllowedShapeTypes) {
        return _super.call(this, parent, readOnly, allowDragging, shapeDescriptionManager, shapeTypes, getAllowedShapeTypes) || this;
    }
    TextToolbox.prototype.createElements = function (element, shapeTypes) {
        var _this = this;
        shapeTypes.forEach(function (shapeType) {
            var description = _this.shapeDescriptionManager.get(shapeType);
            var itemEl = document.createElement("div");
            itemEl.setAttribute("class", "toolbox-text-item");
            itemEl.setAttribute("data-tb-type", shapeType);
            itemEl.textContent = description.getDefaultText() || description.getTitle();
            element.appendChild(itemEl);
        });
    };
    TextToolbox.prototype.createDraggingElement = function (draggingObject) {
        var element = document.createElement("DIV");
        element.setAttribute("class", "dxdi-toolbox-drag-text-item");
        var shapeDescription = this.shapeDescriptionManager.get(draggingObject.evt.data);
        element.textContent = shapeDescription.getDefaultText() || shapeDescription.getTitle();
        document.body.appendChild(element);
        return element;
    };
    return TextToolbox;
}(Toolbox_1.Toolbox));
exports.TextToolbox = TextToolbox;


/***/ }),
/* 352 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.IconToolbox = void 0;
var Toolbox_1 = __webpack_require__(159);
var RenderHelper_1 = __webpack_require__(15);
var Shape_1 = __webpack_require__(14);
var unit_converter_1 = __webpack_require__(12);
var point_1 = __webpack_require__(0);
var TextShapeDescription_1 = __webpack_require__(121);
var Style_1 = __webpack_require__(26);
var CustomShapeDescription_1 = __webpack_require__(126);
var RectaglePrimitive_1 = __webpack_require__(21);
var DEFAULT_SHAPE_ICON_SIZE = 32;
var SHRINK_TEXT_SHAPE_ICON_SIZE = 26;
var SHRINKED_TEXT = "T";
var IconToolbox = (function (_super) {
    __extends(IconToolbox, _super);
    function IconToolbox(parent, readonly, allowDragging, shapeDescriptionManager, shapeTypes, getAllowedShapeTypes, options, measurer) {
        var _this = _super.call(this, parent, readonly, allowDragging, shapeDescriptionManager, shapeTypes, getAllowedShapeTypes) || this;
        _this.options = options;
        _this.measurer = measurer;
        return _this;
    }
    IconToolbox.prototype.createElements = function (element, shapeTypes) {
        var svgElement = document.createElementNS(RenderHelper_1.svgNS, "svg");
        svgElement.className.baseVal = "dxdi-canvas";
        element.appendChild(svgElement);
        this.drawShapeIcons(svgElement, shapeTypes, this.options.toolboxWidth || svgElement.getBoundingClientRect().width);
    };
    IconToolbox.prototype.drawShapeIcons = function (parent, shapeTypes, svgWidth) {
        var _this = this;
        var lineWidth = Style_1.DEFAULT_STROKE_WIDTH;
        var targetWidth = svgWidth - 2 * lineWidth;
        var shapeIconSize = this.options.shapeIconSize;
        if (!shapeIconSize && this.options.shapeIconSpacing && this.options.shapeIconCountInRow)
            shapeIconSize = Math.floor((targetWidth - (this.options.shapeIconCountInRow - 1) * this.options.shapeIconSpacing) / this.options.shapeIconCountInRow);
        if (!shapeIconSize)
            shapeIconSize = DEFAULT_SHAPE_ICON_SIZE;
        shapeIconSize = Math.max(shapeIconSize, this.options.shapeIconSpacing / 2);
        var width = shapeIconSize;
        var iconCountInRow = this.options.shapeIconCountInRow;
        if (!iconCountInRow) {
            iconCountInRow = 1;
            while (width < targetWidth) {
                width += this.options.shapeIconSpacing + shapeIconSize;
                if (width < targetWidth)
                    iconCountInRow++;
            }
        }
        var shapeIconSpacing = (iconCountInRow > 1) ? (targetWidth - shapeIconSize * iconCountInRow) / (iconCountInRow - 1) : 0;
        var xPos = lineWidth;
        var yPos = lineWidth;
        var size = unit_converter_1.UnitConverter.pixelsToTwips(shapeIconSize);
        shapeTypes.forEach(function (shapeType, index) {
            if (index > 0 && index % iconCountInRow === 0) {
                xPos = lineWidth;
                yPos += shapeIconSize + shapeIconSpacing;
            }
            var shapeDescription = _this.shapeDescriptionManager.get(shapeType);
            var shape = _this.createShape(shapeDescription, xPos, yPos, shapeIconSize < SHRINK_TEXT_SHAPE_ICON_SIZE);
            _this.updateShapeIconBounds(shape, shapeIconSize);
            var shapeEl = _this.drawShape(parent, shape);
            _this.drawSelector(shapeEl, unit_converter_1.UnitConverter.pixelsToTwips(xPos), unit_converter_1.UnitConverter.pixelsToTwips(yPos), size);
            xPos += shapeIconSize + shapeIconSpacing;
        });
        parent.style.height = yPos + shapeIconSize + lineWidth + "px";
        parent.style.width = svgWidth + "px";
    };
    IconToolbox.prototype.drawShape = function (parent, shape) {
        var _this = this;
        var primitives = shape.description.createPrimitives(shape, true);
        var gEl = document.createElementNS(RenderHelper_1.svgNS, "g");
        gEl.setAttribute("data-tb-type", shape.description.key.toString());
        gEl.setAttribute("class", "toolbox-item");
        gEl.setAttribute("title", shape.description.getTitle());
        if (this.options.shapeIconAttributes)
            for (var key in this.options.shapeIconAttributes)
                if (Object.prototype.hasOwnProperty.call(this.options.shapeIconAttributes, key))
                    gEl.setAttribute(key, this.options.shapeIconAttributes[key]);
        parent.appendChild(gEl);
        primitives.forEach(function (pr) {
            var el = pr.createElement(function (e) { return gEl.appendChild(e); });
            pr.applyElementProperties(el, _this.measurer);
        });
        return gEl;
    };
    IconToolbox.prototype.drawSelector = function (parent, x, y, size) {
        var _this = this;
        var selectorRect = new RectaglePrimitive_1.RectanglePrimitive(x, y, size, size, undefined, "selector");
        selectorRect.createElement(function (el) {
            selectorRect.applyElementProperties(el, _this.measurer);
            parent.appendChild(el);
        });
    };
    IconToolbox.prototype.createShape = function (shapeDescription, xPos, yPos, shrinkText) {
        var xPosT = unit_converter_1.UnitConverter.pixelsToTwips(xPos);
        var yPosT = unit_converter_1.UnitConverter.pixelsToTwips(yPos);
        var shape = new Shape_1.Shape(shapeDescription, new point_1.Point(xPosT, yPosT), true);
        if (this.needResetShapeText(shapeDescription))
            shape.text = "";
        else if (shrinkText)
            shape.text = SHRINKED_TEXT;
        return shape;
    };
    IconToolbox.prototype.needResetShapeText = function (shapeDescription) {
        if (shapeDescription instanceof TextShapeDescription_1.TextShapeDescription)
            return false;
        if (shapeDescription instanceof CustomShapeDescription_1.CustomShapeDescription && shapeDescription.baseDescription instanceof TextShapeDescription_1.TextShapeDescription)
            return false;
        return true;
    };
    IconToolbox.prototype.updateShapeIconBounds = function (shape, shapeIconSize) {
        var shapeSizeT = unit_converter_1.UnitConverter.pixelsToTwips(shapeIconSize);
        shape.size.height = shape.size.width * shape.getToolboxHeightToWidthRatio();
        if (shape.size.width > shape.size.height) {
            var ratio = shape.size.height / shape.size.width;
            shape.size.width = shapeSizeT;
            shape.size.height = shapeSizeT * ratio;
            shape.position.y = shape.position.y + (shapeSizeT - shape.size.height) / 2;
            shape.parameters.forEach(function (p) { p.value = p.value * shapeSizeT / shape.description.defaultSize.width; });
        }
        else if (shape.size.width < shape.size.height) {
            var ratio = shape.size.width / shape.size.height;
            shape.size.height = shapeSizeT;
            shape.size.width = shapeSizeT * ratio;
            shape.position.x = shape.position.x + (shapeSizeT - shape.size.width) / 2;
            shape.parameters.forEach(function (p) { p.value = p.value * shapeSizeT / shape.description.defaultSize.height; });
        }
        else {
            shape.size.width = shapeSizeT;
            shape.size.height = shapeSizeT;
            shape.parameters.forEach(function (p) { p.value = p.value * shapeSizeT / shape.description.defaultSize.width; });
        }
    };
    IconToolbox.prototype.createDraggingElement = function (draggingObject) {
        var element = document.createElement("DIV");
        element.setAttribute("class", "dxdi-toolbox-drag-item");
        document.body.appendChild(element);
        var svgElement = document.createElementNS(RenderHelper_1.svgNS, "svg");
        svgElement.className.baseVal = "dxdi-canvas";
        element.appendChild(svgElement);
        var shapeDescription = this.shapeDescriptionManager.get(draggingObject.evt.data);
        var shape = this.createShape(shapeDescription, Style_1.DEFAULT_STROKE_WIDTH, Style_1.DEFAULT_STROKE_WIDTH);
        this.drawShape(svgElement, shape);
        element.style.width = unit_converter_1.UnitConverter.twipsToPixels(shape.size.width) + 2 * Style_1.DEFAULT_STROKE_WIDTH + "px";
        element.style.height = unit_converter_1.UnitConverter.twipsToPixels(shape.size.height) + 2 * Style_1.DEFAULT_STROKE_WIDTH + "px";
        return element;
    };
    return IconToolbox;
}(Toolbox_1.Toolbox));
exports.IconToolbox = IconToolbox;


/***/ }),
/* 353 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.ApiController = void 0;
var batch_updatable_1 = __webpack_require__(81);
var Event_1 = __webpack_require__(11);
var ModelUtils_1 = __webpack_require__(4);
var __1 = __webpack_require__(58);
var ApiController = (function (_super) {
    __extends(ApiController, _super);
    function ApiController(events, selection, model) {
        var _this = _super.call(this) || this;
        _this.events = events;
        _this.model = model;
        _this.selection = selection;
        return _this;
    }
    ApiController.prototype.notifySelectionChanged = function (selection) {
        if (this.isUpdateLocked())
            this.registerOccurredEvent(ApiControllerAction.SelectionChanged);
        else
            this.raiseSelectionChanged();
    };
    ApiController.prototype.notifyToolboxDragStart = function () {
        this.events.raise("notifyToolboxItemDragStart");
    };
    ApiController.prototype.notifyToolboxDragEnd = function () {
        this.events.raise("notifyToolboxItemDragEnd");
    };
    ApiController.prototype.notifyToolboxDraggingMouseMove = function () {
    };
    ApiController.prototype.notifyClick = function (evt) {
        var _this = this;
        this.tryRaiseUserAction(evt, function (i) { return _this.events.raise("notifyItemClick", i); });
    };
    ApiController.prototype.notifyDblClick = function (evt) {
        var _this = this;
        this.tryRaiseUserAction(evt, function (i) { return _this.events.raise("notifyItemDblClick", i); });
    };
    ApiController.prototype.createNativeItem = function (item) {
        return item && this.cleanupNativeItem(item.toNative(this.model.units));
    };
    ApiController.prototype.createNativeShape = function (shape) {
        return this.createNativeItem(shape);
    };
    ApiController.prototype.createNativeConnector = function (connector) {
        return this.createNativeItem(connector);
    };
    ApiController.prototype.convertUnit = function (value) {
        return ModelUtils_1.ModelUtils.getlUnitValue(this.model.units, value);
    };
    ApiController.prototype.convertPoint = function (point) {
        return new __1.Point(this.convertUnit(point.x), this.convertUnit(point.y));
    };
    ApiController.prototype.convertSize = function (size) {
        return new __1.Size(this.convertUnit(size.width), this.convertUnit(size.height));
    };
    ApiController.prototype.cleanupNativeItem = function (item) {
        var ds = this.dataSource;
        if (ds) {
            if (ds.isAutoGeneratedKey(item.fromKey))
                item.fromKey = undefined;
            if (ds.isAutoGeneratedKey(item.key))
                item.key = undefined;
            if (ds.isAutoGeneratedKey(item.toKey))
                item.toKey = undefined;
        }
        return item;
    };
    ApiController.prototype.setDataSource = function (dataSource) {
        this.dataSource = dataSource;
    };
    ApiController.prototype.tryRaiseUserAction = function (evt, callEvent) {
        var _this = this;
        if (this.isUserAction(evt)) {
            var item_1 = this.model.findItem(evt.source.key);
            item_1 && this.events.raise1(function (l) { return callEvent(_this.createNativeItem(item_1)); });
        }
    };
    ApiController.prototype.isUserAction = function (evt) {
        return evt.source && (evt.source.type === Event_1.MouseEventElementType.Shape ||
            evt.source.type === Event_1.MouseEventElementType.ShapeExpandButton ||
            evt.source.type === Event_1.MouseEventElementType.ShapeParameterBox ||
            evt.source.type === Event_1.MouseEventElementType.ShapeResizeBox ||
            evt.source.type === Event_1.MouseEventElementType.ShapeConnectionPoint ||
            evt.source.type === Event_1.MouseEventElementType.Connector ||
            evt.source.type === Event_1.MouseEventElementType.ConnectorPoint ||
            evt.source.type === Event_1.MouseEventElementType.ConnectorSide ||
            evt.source.type === Event_1.MouseEventElementType.ConnectorOrthogonalSide ||
            evt.source.type === Event_1.MouseEventElementType.ConnectorText);
    };
    ApiController.prototype.onUpdateUnlocked = function (occurredEvents) {
        if (occurredEvents & ApiControllerAction.SelectionChanged)
            this.raiseSelectionChanged();
    };
    ApiController.prototype.raiseSelectionChanged = function () {
        var _this = this;
        var items = this.selection.getKeys().map(function (key) { return _this.createNativeItem(_this.model.findItem(key)); });
        this.events.raise1(function (l) { return l.notifySelectionChanged(items); });
    };
    return ApiController;
}(batch_updatable_1.BatchUpdatableObject));
exports.ApiController = ApiController;
var ApiControllerAction;
(function (ApiControllerAction) {
    ApiControllerAction[ApiControllerAction["SelectionChanged"] = 1] = "SelectionChanged";
})(ApiControllerAction || (ApiControllerAction = {}));


/***/ }),
/* 354 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.PermissionsProvider = void 0;
var Shape_1 = __webpack_require__(14);
var Utils_1 = __webpack_require__(3);
var ModelOperationSettings_1 = __webpack_require__(16);
var Connector_1 = __webpack_require__(6);
var AddShape_1 = __webpack_require__(355);
var DeleteShape_1 = __webpack_require__(356);
var DeleteConnector_1 = __webpack_require__(357);
var AddShapeFromToolbox_1 = __webpack_require__(358);
var ChangeConnection_1 = __webpack_require__(359);
var ChangeConnectorPoints_1 = __webpack_require__(360);
var BeforeChangeShapeText_1 = __webpack_require__(361);
var BeforeChangeConnectorText_1 = __webpack_require__(362);
var ChangeShapeText_1 = __webpack_require__(363);
var ChangeConnectorText_1 = __webpack_require__(364);
var PermissionsProviderStorage_1 = __webpack_require__(365);
var ResizeShape_1 = __webpack_require__(366);
var MoveShape_1 = __webpack_require__(367);
var PermissionsProvider = (function () {
    function PermissionsProvider(apiController) {
        this.onRequestOperation = new Utils_1.EventDispatcher();
        this.cache = [];
        this.permissionsLockCount = 0;
        this.requestDeleteItems = {};
        this.updateUICount = 0;
        this.apiController = apiController;
        this.operationSettings = new ModelOperationSettings_1.ModelOperationSettings();
        this.storage = new PermissionsProviderStorage_1.PermissionsProviderStorage();
    }
    PermissionsProvider.prototype.notifySelectionChanged = function (_selection) {
        this.clearCache();
    };
    PermissionsProvider.prototype.notifyModelChanged = function (changes) {
        this.clearCache();
    };
    PermissionsProvider.prototype.notifyPageColorChanged = function (color) { };
    PermissionsProvider.prototype.notifyPageSizeChanged = function (pageSize, pageLandscape) { };
    PermissionsProvider.prototype.clearCache = function (operation) {
        if (operation !== undefined)
            this.cache = this.cache.filter(function (entry) { return entry.operation !== operation; });
        else
            this.cache = [];
    };
    PermissionsProvider.prototype.canDeleteItems = function (items) {
        var _this = this;
        var allowed = true;
        items.forEach(function (item) {
            var entity;
            if (item instanceof Shape_1.Shape)
                entity = new DeleteShape_1.DeleteShapeRequestedEntity(_this.apiController, item);
            if (item instanceof Connector_1.Connector)
                entity = new DeleteConnector_1.DeleteConnectorRequestedEntity(_this.apiController, item);
            allowed = allowed && _this.requestOperation(entity);
        });
        return allowed;
    };
    PermissionsProvider.prototype.canAddItems = function (items) {
        var _this = this;
        var allowed = true;
        items.forEach(function (item) {
            if (item instanceof Shape_1.Shape)
                allowed = allowed && _this.requestOperation(new AddShape_1.AddShapeRequestedEntity(_this.apiController, item));
            if (item instanceof Connector_1.Connector) {
                allowed = allowed && _this.canChangeConnection(item, item.beginItem, undefined, Connector_1.ConnectorPosition.Begin, item.beginConnectionPointIndex);
                allowed = allowed && _this.canChangeConnection(item, item.endItem, undefined, Connector_1.ConnectorPosition.End, item.endConnectionPointIndex);
            }
        });
        return allowed;
    };
    PermissionsProvider.prototype.canAddShapeFromToolbox = function (itemType) {
        return this.requestOperation(new AddShapeFromToolbox_1.AddShapeFromToolboxRequestedEntity(this.apiController, itemType));
    };
    PermissionsProvider.prototype.canChangeConnection = function (connector, item, oldItem, position, connectionPointIndex) {
        if (connector && this.requestDeleteItems[connector.key])
            return true;
        if (item === undefined || item === null || item instanceof Shape_1.Shape)
            return this.requestOperation(new ChangeConnection_1.ChangeConnectionRequestedEntity(this.apiController, connector, item, oldItem, position, connectionPointIndex));
        return true;
    };
    PermissionsProvider.prototype.canChangeConnectorPoints = function (connector, oldPoints, points) {
        if (connector && this.requestDeleteItems[connector.key])
            return true;
        return this.requestOperation(new ChangeConnectorPoints_1.ChangeConnectorPointsRequestedEntity(this.apiController, connector, oldPoints, points));
    };
    PermissionsProvider.prototype.canChangeShapeText = function (shape) {
        return this.requestOperation(new BeforeChangeShapeText_1.BeforeChangeShapeTextRequestedEntity(this.apiController, shape));
    };
    PermissionsProvider.prototype.canChangeConnectorText = function (connector, position) {
        return this.requestOperation(new BeforeChangeConnectorText_1.BeforeChangeConnectorTextRequestedEntity(this.apiController, connector, position));
    };
    PermissionsProvider.prototype.canApplyShapeTextChange = function (shape, textToApply) {
        return this.requestOperation(new ChangeShapeText_1.ChangeShapeTextRequestedEntity(this.apiController, shape, textToApply));
    };
    PermissionsProvider.prototype.canApplyConnectorTextChange = function (connector, position, textToApply) {
        return this.requestOperation(new ChangeConnectorText_1.ChangeConnectorTextRequestedEntity(this.apiController, connector, position, textToApply));
    };
    PermissionsProvider.prototype.canResizeShapes = function (shapeInfo) {
        var _this = this;
        var allowed = true;
        shapeInfo.forEach(function (info) {
            allowed = allowed && _this.requestOperation(new ResizeShape_1.ResizeShapeRequestedEntity(_this.apiController, info.shape, info.oldSize, info.size));
        });
        return allowed;
    };
    PermissionsProvider.prototype.canMoveShapes = function (shapeInfo) {
        var _this = this;
        var allowed = true;
        shapeInfo.forEach(function (info) {
            allowed = allowed && _this.requestOperation(new MoveShape_1.MoveShapeRequestedEntity(_this.apiController, info.shape, info.oldPosition, info.position));
        });
        return allowed;
    };
    PermissionsProvider.prototype.requestOperation = function (entity) {
        var allowed = true;
        if (!this.permissionsLockCount) {
            var cachedEntity_1;
            if (this.updateUICount > 0)
                this.cache.forEach(function (item) {
                    if (item.equals(entity)) {
                        cachedEntity_1 = item;
                        return;
                    }
                });
            if (cachedEntity_1)
                allowed = cachedEntity_1.allowed;
            else {
                this.requestOperationCore(entity);
                if (this.updateUICount > 0)
                    this.cache.push(entity);
                allowed = entity.allowed;
            }
            if (this.updateUICount === 0 && this.storage.needStorePermissions()) {
                this.storage.storePermission(entity.storageKey, allowed);
                return this.storage.isStoredPermissionsGranted();
            }
        }
        return allowed;
    };
    PermissionsProvider.prototype.requestOperationCore = function (entity) {
        entity.eventArgs.allowed = this.operationSettings[entity.settingsKey];
        entity.eventArgs.updateUI = this.updateUICount > 0;
        if (entity.allowed)
            this.onRequestOperation.raise("notifyRequestOperation", entity.operation, entity.eventArgs);
    };
    PermissionsProvider.prototype.lockPermissions = function () {
        this.permissionsLockCount++;
    };
    PermissionsProvider.prototype.unlockPermissions = function () {
        this.permissionsLockCount--;
    };
    PermissionsProvider.prototype.beginDeleteItems = function (items) {
        var _this = this;
        items.forEach(function (item) { return _this.requestDeleteItems[item.key] = item; });
    };
    PermissionsProvider.prototype.endDeleteItems = function () {
        this.requestDeleteItems = {};
    };
    PermissionsProvider.prototype.beginUpdateUI = function () {
        this.updateUICount++;
    };
    PermissionsProvider.prototype.endUpdateUI = function () {
        this.updateUICount--;
    };
    PermissionsProvider.prototype.addInteractingItem = function (item, operation) {
        this.storage.addInteractingItem(item, operation);
    };
    PermissionsProvider.prototype.getInteractingItem = function (item, operation) {
        return this.storage.getInteractingItem(item, operation);
    };
    PermissionsProvider.prototype.getInteractingItemCount = function () {
        return this.storage.getInteractingItemCount();
    };
    PermissionsProvider.prototype.clearInteractingItems = function () {
        this.storage.clearInteractingItems();
    };
    PermissionsProvider.prototype.beginStorePermissions = function () {
        this.storage.beginStorePermissions();
    };
    PermissionsProvider.prototype.endStorePermissions = function () {
        this.storage.endStorePermissions();
    };
    PermissionsProvider.prototype.isStoredPermissionsGranted = function () {
        return this.permissionsLockCount > 0 || this.storage.isStoredPermissionsGranted();
    };
    return PermissionsProvider;
}());
exports.PermissionsProvider = PermissionsProvider;


/***/ }),
/* 355 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.AddShapeEventArgs = exports.AddShapeRequestedEntity = void 0;
var ModelOperationSettings_1 = __webpack_require__(16);
var RequestedEntity_1 = __webpack_require__(23);
var AddShapeRequestedEntity = (function (_super) {
    __extends(AddShapeRequestedEntity, _super);
    function AddShapeRequestedEntity(apiController, shape) {
        var _this = _super.call(this, apiController) || this;
        _this.shape = shape;
        return _this;
    }
    Object.defineProperty(AddShapeRequestedEntity.prototype, "operation", {
        get: function () {
            return ModelOperationSettings_1.DiagramModelOperation.AddShape;
        },
        enumerable: false,
        configurable: true
    });
    AddShapeRequestedEntity.prototype.createEventArgs = function () {
        return new AddShapeEventArgs(this.apiController.createNativeShape(this.shape), this.apiController.convertPoint(this.shape.position));
    };
    Object.defineProperty(AddShapeRequestedEntity.prototype, "settingsKey", {
        get: function () {
            return "addShape";
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(AddShapeRequestedEntity.prototype, "storageKey", {
        get: function () {
            return this.settingsKey + "_" + (this.shape && this.shape.key);
        },
        enumerable: false,
        configurable: true
    });
    AddShapeRequestedEntity.prototype.equals = function (other) {
        if (other instanceof AddShapeRequestedEntity)
            return this.shape === other.shape && this.shape.position.equals(other.shape.position);
        return false;
    };
    return AddShapeRequestedEntity;
}(RequestedEntity_1.RequestedEntity));
exports.AddShapeRequestedEntity = AddShapeRequestedEntity;
var AddShapeEventArgs = (function (_super) {
    __extends(AddShapeEventArgs, _super);
    function AddShapeEventArgs(shape, position) {
        var _this = _super.call(this) || this;
        _this.shape = shape;
        _this.position = position;
        return _this;
    }
    return AddShapeEventArgs;
}(RequestedEntity_1.PermissionRequestEventArgs));
exports.AddShapeEventArgs = AddShapeEventArgs;


/***/ }),
/* 356 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.DeleteShapeEventArgs = exports.DeleteShapeRequestedEntity = void 0;
var ModelOperationSettings_1 = __webpack_require__(16);
var RequestedEntity_1 = __webpack_require__(23);
var DeleteShapeRequestedEntity = (function (_super) {
    __extends(DeleteShapeRequestedEntity, _super);
    function DeleteShapeRequestedEntity(apiController, shape) {
        var _this = _super.call(this, apiController) || this;
        _this.shape = shape;
        return _this;
    }
    Object.defineProperty(DeleteShapeRequestedEntity.prototype, "operation", {
        get: function () {
            return ModelOperationSettings_1.DiagramModelOperation.DeleteShape;
        },
        enumerable: false,
        configurable: true
    });
    DeleteShapeRequestedEntity.prototype.createEventArgs = function () {
        return new DeleteShapeEventArgs(this.apiController.createNativeShape(this.shape));
    };
    Object.defineProperty(DeleteShapeRequestedEntity.prototype, "settingsKey", {
        get: function () {
            return "deleteShape";
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(DeleteShapeRequestedEntity.prototype, "storageKey", {
        get: function () {
            return this.settingsKey + "_" + (this.shape && this.shape.key);
        },
        enumerable: false,
        configurable: true
    });
    DeleteShapeRequestedEntity.prototype.equals = function (other) {
        if (other instanceof DeleteShapeRequestedEntity)
            return this.shape === other.shape;
        return false;
    };
    return DeleteShapeRequestedEntity;
}(RequestedEntity_1.RequestedEntity));
exports.DeleteShapeRequestedEntity = DeleteShapeRequestedEntity;
var DeleteShapeEventArgs = (function (_super) {
    __extends(DeleteShapeEventArgs, _super);
    function DeleteShapeEventArgs(shape) {
        var _this = _super.call(this) || this;
        _this.shape = shape;
        return _this;
    }
    return DeleteShapeEventArgs;
}(RequestedEntity_1.PermissionRequestEventArgs));
exports.DeleteShapeEventArgs = DeleteShapeEventArgs;


/***/ }),
/* 357 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.DeleteConnectorEventArgs = exports.DeleteConnectorRequestedEntity = void 0;
var ModelOperationSettings_1 = __webpack_require__(16);
var RequestedEntity_1 = __webpack_require__(23);
var DeleteConnectorRequestedEntity = (function (_super) {
    __extends(DeleteConnectorRequestedEntity, _super);
    function DeleteConnectorRequestedEntity(apiController, connector) {
        var _this = _super.call(this, apiController) || this;
        _this.connector = connector;
        return _this;
    }
    Object.defineProperty(DeleteConnectorRequestedEntity.prototype, "operation", {
        get: function () {
            return ModelOperationSettings_1.DiagramModelOperation.DeleteConnector;
        },
        enumerable: false,
        configurable: true
    });
    DeleteConnectorRequestedEntity.prototype.createEventArgs = function () {
        return new DeleteConnectorEventArgs(this.apiController.createNativeConnector(this.connector));
    };
    Object.defineProperty(DeleteConnectorRequestedEntity.prototype, "settingsKey", {
        get: function () {
            return "deleteConnector";
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(DeleteConnectorRequestedEntity.prototype, "storageKey", {
        get: function () {
            return this.settingsKey + "_" + (this.connector && this.connector.key);
        },
        enumerable: false,
        configurable: true
    });
    DeleteConnectorRequestedEntity.prototype.equals = function (other) {
        if (other instanceof DeleteConnectorRequestedEntity)
            return this.connector === other.connector;
        return false;
    };
    return DeleteConnectorRequestedEntity;
}(RequestedEntity_1.RequestedEntity));
exports.DeleteConnectorRequestedEntity = DeleteConnectorRequestedEntity;
var DeleteConnectorEventArgs = (function (_super) {
    __extends(DeleteConnectorEventArgs, _super);
    function DeleteConnectorEventArgs(connector) {
        var _this = _super.call(this) || this;
        _this.connector = connector;
        return _this;
    }
    return DeleteConnectorEventArgs;
}(RequestedEntity_1.PermissionRequestEventArgs));
exports.DeleteConnectorEventArgs = DeleteConnectorEventArgs;


/***/ }),
/* 358 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.AddShapeFromToolboxEventArgs = exports.AddShapeFromToolboxRequestedEntity = void 0;
var ModelOperationSettings_1 = __webpack_require__(16);
var RequestedEntity_1 = __webpack_require__(23);
var AddShapeFromToolboxRequestedEntity = (function (_super) {
    __extends(AddShapeFromToolboxRequestedEntity, _super);
    function AddShapeFromToolboxRequestedEntity(apiController, shapeType) {
        var _this = _super.call(this, apiController) || this;
        _this.shapeType = shapeType;
        return _this;
    }
    Object.defineProperty(AddShapeFromToolboxRequestedEntity.prototype, "operation", {
        get: function () {
            return ModelOperationSettings_1.DiagramModelOperation.AddShapeFromToolbox;
        },
        enumerable: false,
        configurable: true
    });
    AddShapeFromToolboxRequestedEntity.prototype.createEventArgs = function () {
        return new AddShapeFromToolboxEventArgs(this.shapeType);
    };
    Object.defineProperty(AddShapeFromToolboxRequestedEntity.prototype, "settingsKey", {
        get: function () {
            return "addShapeFromToolbox";
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(AddShapeFromToolboxRequestedEntity.prototype, "storageKey", {
        get: function () {
            return this.settingsKey + "_" + this.shapeType;
        },
        enumerable: false,
        configurable: true
    });
    AddShapeFromToolboxRequestedEntity.prototype.equals = function (other) {
        if (other instanceof AddShapeFromToolboxRequestedEntity)
            return this.shapeType === other.shapeType;
        return false;
    };
    return AddShapeFromToolboxRequestedEntity;
}(RequestedEntity_1.RequestedEntity));
exports.AddShapeFromToolboxRequestedEntity = AddShapeFromToolboxRequestedEntity;
var AddShapeFromToolboxEventArgs = (function (_super) {
    __extends(AddShapeFromToolboxEventArgs, _super);
    function AddShapeFromToolboxEventArgs(shapeType) {
        var _this = _super.call(this) || this;
        _this.shapeType = shapeType;
        return _this;
    }
    return AddShapeFromToolboxEventArgs;
}(RequestedEntity_1.PermissionRequestEventArgs));
exports.AddShapeFromToolboxEventArgs = AddShapeFromToolboxEventArgs;


/***/ }),
/* 359 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.ChangeConnectionEventArgs = exports.ChangeConnectionRequestedEntity = void 0;
var ModelOperationSettings_1 = __webpack_require__(16);
var RequestedEntity_1 = __webpack_require__(23);
var ChangeConnectionRequestedEntity = (function (_super) {
    __extends(ChangeConnectionRequestedEntity, _super);
    function ChangeConnectionRequestedEntity(apiController, connector, shape, oldShape, position, connectionPointIndex) {
        var _this = _super.call(this, apiController) || this;
        _this.connector = connector;
        _this.shape = shape;
        _this.oldShape = oldShape;
        _this.position = position;
        _this.connectionPointIndex = connectionPointIndex;
        return _this;
    }
    Object.defineProperty(ChangeConnectionRequestedEntity.prototype, "operation", {
        get: function () {
            return ModelOperationSettings_1.DiagramModelOperation.ChangeConnection;
        },
        enumerable: false,
        configurable: true
    });
    ChangeConnectionRequestedEntity.prototype.createEventArgs = function () {
        return new ChangeConnectionEventArgs(this.apiController.createNativeConnector(this.connector), this.apiController.createNativeShape(this.shape), this.apiController.createNativeShape(this.oldShape), this.position, this.connectionPointIndex);
    };
    Object.defineProperty(ChangeConnectionRequestedEntity.prototype, "settingsKey", {
        get: function () {
            return "changeConnection";
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(ChangeConnectionRequestedEntity.prototype, "storageKey", {
        get: function () {
            return this.settingsKey + "_" + (this.connector && this.connector.key) + "_" + this.position;
        },
        enumerable: false,
        configurable: true
    });
    ChangeConnectionRequestedEntity.prototype.equals = function (other) {
        if (other instanceof ChangeConnectionRequestedEntity) {
            var connectorsAreEqual = (!this.connector && !other.connector) || (this.connector && other.connector && this.connector === other.connector);
            var shapesAreEqual = (!this.shape && !other.shape) || (this.shape && other.shape && this.shape === other.shape);
            var oldShapesAreEqual = (!this.oldShape && !other.oldShape) || (this.oldShape && other.oldShape && this.oldShape === other.oldShape);
            return shapesAreEqual && oldShapesAreEqual && connectorsAreEqual && this.position === other.position && this.connectionPointIndex === other.connectionPointIndex;
        }
        return false;
    };
    return ChangeConnectionRequestedEntity;
}(RequestedEntity_1.RequestedEntity));
exports.ChangeConnectionRequestedEntity = ChangeConnectionRequestedEntity;
var ChangeConnectionEventArgs = (function (_super) {
    __extends(ChangeConnectionEventArgs, _super);
    function ChangeConnectionEventArgs(connector, shape, oldShape, position, connectionPointIndex) {
        var _this = _super.call(this) || this;
        _this.connector = connector;
        _this.shape = shape;
        _this.oldShape = oldShape;
        _this.position = position;
        _this.connectionPointIndex = connectionPointIndex;
        return _this;
    }
    return ChangeConnectionEventArgs;
}(RequestedEntity_1.PermissionRequestEventArgs));
exports.ChangeConnectionEventArgs = ChangeConnectionEventArgs;


/***/ }),
/* 360 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.ChangeConnectorPointsEventArgs = exports.ChangeConnectorPointsRequestedEntity = void 0;
var ModelOperationSettings_1 = __webpack_require__(16);
var RequestedEntity_1 = __webpack_require__(23);
var Utils_1 = __webpack_require__(3);
var ChangeConnectorPointsRequestedEntity = (function (_super) {
    __extends(ChangeConnectorPointsRequestedEntity, _super);
    function ChangeConnectorPointsRequestedEntity(apiController, connector, oldPoints, points) {
        var _this = _super.call(this, apiController) || this;
        _this.connector = connector;
        _this.oldPoints = oldPoints;
        _this.points = points;
        return _this;
    }
    Object.defineProperty(ChangeConnectorPointsRequestedEntity.prototype, "operation", {
        get: function () {
            return ModelOperationSettings_1.DiagramModelOperation.ChangeConnectorPoints;
        },
        enumerable: false,
        configurable: true
    });
    ChangeConnectorPointsRequestedEntity.prototype.createEventArgs = function () {
        var _this = this;
        return new ChangeConnectorPointsEventArgs(this.apiController.createNativeConnector(this.connector), this.oldPoints.map(function (pt) { return _this.apiController.convertPoint(pt); }), this.points.map(function (pt) { return _this.apiController.convertPoint(pt); }));
    };
    Object.defineProperty(ChangeConnectorPointsRequestedEntity.prototype, "settingsKey", {
        get: function () {
            return "changeConnectorPoints";
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(ChangeConnectorPointsRequestedEntity.prototype, "storageKey", {
        get: function () {
            return this.settingsKey + "_" + (this.connector && this.connector.key);
        },
        enumerable: false,
        configurable: true
    });
    ChangeConnectorPointsRequestedEntity.prototype.equals = function (other) {
        if (other instanceof ChangeConnectorPointsRequestedEntity)
            return this.connector === other.connector &&
                Utils_1.GeometryUtils.arePointsEqual(this.oldPoints, other.oldPoints) &&
                Utils_1.GeometryUtils.arePointsEqual(this.points, other.points);
        return false;
    };
    return ChangeConnectorPointsRequestedEntity;
}(RequestedEntity_1.RequestedEntity));
exports.ChangeConnectorPointsRequestedEntity = ChangeConnectorPointsRequestedEntity;
var ChangeConnectorPointsEventArgs = (function (_super) {
    __extends(ChangeConnectorPointsEventArgs, _super);
    function ChangeConnectorPointsEventArgs(connector, oldPoints, points) {
        var _this = _super.call(this) || this;
        _this.connector = connector;
        _this.oldPoints = oldPoints;
        _this.points = points;
        return _this;
    }
    return ChangeConnectorPointsEventArgs;
}(RequestedEntity_1.PermissionRequestEventArgs));
exports.ChangeConnectorPointsEventArgs = ChangeConnectorPointsEventArgs;


/***/ }),
/* 361 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.BeforeChangeShapeTextEventArgs = exports.BeforeChangeShapeTextRequestedEntity = void 0;
var ModelOperationSettings_1 = __webpack_require__(16);
var RequestedEntity_1 = __webpack_require__(23);
var BeforeChangeShapeTextRequestedEntity = (function (_super) {
    __extends(BeforeChangeShapeTextRequestedEntity, _super);
    function BeforeChangeShapeTextRequestedEntity(apiController, shape) {
        var _this = _super.call(this, apiController) || this;
        _this.shape = shape;
        return _this;
    }
    Object.defineProperty(BeforeChangeShapeTextRequestedEntity.prototype, "operation", {
        get: function () {
            return ModelOperationSettings_1.DiagramModelOperation.BeforeChangeShapeText;
        },
        enumerable: false,
        configurable: true
    });
    BeforeChangeShapeTextRequestedEntity.prototype.createEventArgs = function () {
        return new BeforeChangeShapeTextEventArgs(this.apiController.createNativeShape(this.shape));
    };
    Object.defineProperty(BeforeChangeShapeTextRequestedEntity.prototype, "settingsKey", {
        get: function () {
            return "changeShapeText";
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(BeforeChangeShapeTextRequestedEntity.prototype, "storageKey", {
        get: function () {
            return "before" + this.settingsKey + "_" + (this.shape && this.shape.key);
        },
        enumerable: false,
        configurable: true
    });
    BeforeChangeShapeTextRequestedEntity.prototype.equals = function (other) {
        if (other instanceof BeforeChangeShapeTextRequestedEntity)
            return this.shape === other.shape && this.shape.text === other.shape.text;
        return false;
    };
    return BeforeChangeShapeTextRequestedEntity;
}(RequestedEntity_1.RequestedEntity));
exports.BeforeChangeShapeTextRequestedEntity = BeforeChangeShapeTextRequestedEntity;
var BeforeChangeShapeTextEventArgs = (function (_super) {
    __extends(BeforeChangeShapeTextEventArgs, _super);
    function BeforeChangeShapeTextEventArgs(shape) {
        var _this = _super.call(this) || this;
        _this.shape = shape;
        return _this;
    }
    return BeforeChangeShapeTextEventArgs;
}(RequestedEntity_1.PermissionRequestEventArgs));
exports.BeforeChangeShapeTextEventArgs = BeforeChangeShapeTextEventArgs;


/***/ }),
/* 362 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.BeforeChangeConnectorTextEventArgs = exports.BeforeChangeConnectorTextRequestedEntity = void 0;
var ModelOperationSettings_1 = __webpack_require__(16);
var RequestedEntity_1 = __webpack_require__(23);
var BeforeChangeConnectorTextRequestedEntity = (function (_super) {
    __extends(BeforeChangeConnectorTextRequestedEntity, _super);
    function BeforeChangeConnectorTextRequestedEntity(apiController, connector, position) {
        var _this = _super.call(this, apiController) || this;
        _this.connector = connector;
        _this.position = position;
        return _this;
    }
    Object.defineProperty(BeforeChangeConnectorTextRequestedEntity.prototype, "operation", {
        get: function () {
            return ModelOperationSettings_1.DiagramModelOperation.BeforeChangeConnectorText;
        },
        enumerable: false,
        configurable: true
    });
    BeforeChangeConnectorTextRequestedEntity.prototype.createEventArgs = function () {
        return new BeforeChangeConnectorTextEventArgs(this.apiController.createNativeConnector(this.connector), this.position, this.connector.texts.map(function (t) { return t; }).sort(function (a, b) { return a.position - b.position; }).indexOf(this.connector.texts.get(this.position)));
    };
    Object.defineProperty(BeforeChangeConnectorTextRequestedEntity.prototype, "settingsKey", {
        get: function () {
            return "changeConnectorText";
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(BeforeChangeConnectorTextRequestedEntity.prototype, "storageKey", {
        get: function () {
            return "before" + this.settingsKey + "_" + (this.connector && this.connector.key);
        },
        enumerable: false,
        configurable: true
    });
    BeforeChangeConnectorTextRequestedEntity.prototype.equals = function (other) {
        if (other instanceof BeforeChangeConnectorTextRequestedEntity)
            return this.connector === other.connector && this.position === other.position && this.connector.texts.get(this.position) === other.connector.texts.get(other.position);
        return false;
    };
    return BeforeChangeConnectorTextRequestedEntity;
}(RequestedEntity_1.RequestedEntity));
exports.BeforeChangeConnectorTextRequestedEntity = BeforeChangeConnectorTextRequestedEntity;
var BeforeChangeConnectorTextEventArgs = (function (_super) {
    __extends(BeforeChangeConnectorTextEventArgs, _super);
    function BeforeChangeConnectorTextEventArgs(connector, position, index) {
        var _this = _super.call(this) || this;
        _this.connector = connector;
        _this.position = position;
        _this.index = index;
        return _this;
    }
    return BeforeChangeConnectorTextEventArgs;
}(RequestedEntity_1.PermissionRequestEventArgs));
exports.BeforeChangeConnectorTextEventArgs = BeforeChangeConnectorTextEventArgs;


/***/ }),
/* 363 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.ChangeShapeTextEventArgs = exports.ChangeShapeTextRequestedEntity = void 0;
var ModelOperationSettings_1 = __webpack_require__(16);
var RequestedEntity_1 = __webpack_require__(23);
var ChangeShapeTextRequestedEntity = (function (_super) {
    __extends(ChangeShapeTextRequestedEntity, _super);
    function ChangeShapeTextRequestedEntity(apiController, shape, text) {
        var _this = _super.call(this, apiController) || this;
        _this.shape = shape;
        _this.text = text;
        return _this;
    }
    Object.defineProperty(ChangeShapeTextRequestedEntity.prototype, "operation", {
        get: function () {
            return ModelOperationSettings_1.DiagramModelOperation.ChangeShapeText;
        },
        enumerable: false,
        configurable: true
    });
    ChangeShapeTextRequestedEntity.prototype.createEventArgs = function () {
        return new ChangeShapeTextEventArgs(this.apiController.createNativeShape(this.shape), this.text);
    };
    Object.defineProperty(ChangeShapeTextRequestedEntity.prototype, "settingsKey", {
        get: function () {
            return "changeShapeText";
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(ChangeShapeTextRequestedEntity.prototype, "storageKey", {
        get: function () {
            return this.settingsKey + "_" + (this.shape && this.shape.key);
        },
        enumerable: false,
        configurable: true
    });
    ChangeShapeTextRequestedEntity.prototype.equals = function (other) {
        if (other instanceof ChangeShapeTextRequestedEntity)
            return this.shape === other.shape && this.text === other.text;
        return false;
    };
    return ChangeShapeTextRequestedEntity;
}(RequestedEntity_1.RequestedEntity));
exports.ChangeShapeTextRequestedEntity = ChangeShapeTextRequestedEntity;
var ChangeShapeTextEventArgs = (function (_super) {
    __extends(ChangeShapeTextEventArgs, _super);
    function ChangeShapeTextEventArgs(shape, text) {
        var _this = _super.call(this) || this;
        _this.shape = shape;
        _this.text = text;
        return _this;
    }
    return ChangeShapeTextEventArgs;
}(RequestedEntity_1.PermissionRequestEventArgs));
exports.ChangeShapeTextEventArgs = ChangeShapeTextEventArgs;


/***/ }),
/* 364 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.ChangeConnectorTextEventArgs = exports.ChangeConnectorTextRequestedEntity = void 0;
var ModelOperationSettings_1 = __webpack_require__(16);
var RequestedEntity_1 = __webpack_require__(23);
var ChangeConnectorTextRequestedEntity = (function (_super) {
    __extends(ChangeConnectorTextRequestedEntity, _super);
    function ChangeConnectorTextRequestedEntity(apiController, connector, position, text) {
        var _this = _super.call(this, apiController) || this;
        _this.connector = connector;
        _this.position = position;
        _this.text = text;
        return _this;
    }
    Object.defineProperty(ChangeConnectorTextRequestedEntity.prototype, "operation", {
        get: function () {
            return ModelOperationSettings_1.DiagramModelOperation.ChangeConnectorText;
        },
        enumerable: false,
        configurable: true
    });
    ChangeConnectorTextRequestedEntity.prototype.createEventArgs = function () {
        return new ChangeConnectorTextEventArgs(this.apiController.createNativeConnector(this.connector), this.position, this.connector.texts.map(function (t) { return t; }).sort(function (a, b) { return a.position - b.position; }).indexOf(this.connector.texts.get(this.position)), this.text);
    };
    Object.defineProperty(ChangeConnectorTextRequestedEntity.prototype, "settingsKey", {
        get: function () {
            return "changeConnectorText";
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(ChangeConnectorTextRequestedEntity.prototype, "storageKey", {
        get: function () {
            return this.settingsKey + "_" + (this.connector && this.connector.key);
        },
        enumerable: false,
        configurable: true
    });
    ChangeConnectorTextRequestedEntity.prototype.equals = function (other) {
        if (other instanceof ChangeConnectorTextRequestedEntity)
            return this.connector === other.connector && this.position === other.position && this.text === other.text;
        return false;
    };
    return ChangeConnectorTextRequestedEntity;
}(RequestedEntity_1.RequestedEntity));
exports.ChangeConnectorTextRequestedEntity = ChangeConnectorTextRequestedEntity;
var ChangeConnectorTextEventArgs = (function (_super) {
    __extends(ChangeConnectorTextEventArgs, _super);
    function ChangeConnectorTextEventArgs(connector, position, index, text) {
        var _this = _super.call(this) || this;
        _this.connector = connector;
        _this.position = position;
        _this.index = index;
        _this.text = text;
        return _this;
    }
    return ChangeConnectorTextEventArgs;
}(RequestedEntity_1.PermissionRequestEventArgs));
exports.ChangeConnectorTextEventArgs = ChangeConnectorTextEventArgs;


/***/ }),
/* 365 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.PermissionsProviderStorage = void 0;
var Shape_1 = __webpack_require__(14);
var Connector_1 = __webpack_require__(6);
var PermissionsProviderStorage = (function () {
    function PermissionsProviderStorage() {
        this.interactingItems = {};
        this.storedPermissions = {};
    }
    PermissionsProviderStorage.prototype.addInteractingItem = function (item, operation) {
        var key = this.getInteractingItemKey(item, operation);
        if (this.interactingItems[key] === undefined && (item instanceof Shape_1.Shape || item instanceof Connector_1.Connector))
            this.interactingItems[key] = item.clone();
    };
    PermissionsProviderStorage.prototype.getInteractingItem = function (item, operation) {
        var key = this.getInteractingItemKey(item, operation);
        return this.interactingItems[key];
    };
    PermissionsProviderStorage.prototype.getInteractingItemCount = function () {
        return Object.keys(this.interactingItems).length;
    };
    PermissionsProviderStorage.prototype.clearInteractingItems = function () {
        this.interactingItems = {};
    };
    PermissionsProviderStorage.prototype.getInteractingItemKey = function (item, operation) {
        return item.key + (operation !== undefined ? "_" + operation.toString() : "");
    };
    PermissionsProviderStorage.prototype.needStorePermissions = function () {
        return this.storePermissions;
    };
    PermissionsProviderStorage.prototype.beginStorePermissions = function () {
        this.storePermissions = true;
    };
    PermissionsProviderStorage.prototype.endStorePermissions = function () {
        this.storePermissions = false;
        this.storedPermissions = {};
    };
    PermissionsProviderStorage.prototype.isStoredPermissionsGranted = function () {
        var keys = Object.keys(this.storedPermissions);
        var granted = true;
        for (var i = 0; i < keys.length; i++)
            granted = granted && this.storedPermissions[keys[i]];
        return granted;
    };
    PermissionsProviderStorage.prototype.storePermission = function (key, allowed) {
        this.storedPermissions[key] = allowed;
    };
    return PermissionsProviderStorage;
}());
exports.PermissionsProviderStorage = PermissionsProviderStorage;


/***/ }),
/* 366 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.ResizeShapeEventArgs = exports.ResizeShapeRequestedEntity = void 0;
var ModelOperationSettings_1 = __webpack_require__(16);
var RequestedEntity_1 = __webpack_require__(23);
var ResizeShapeRequestedEntity = (function (_super) {
    __extends(ResizeShapeRequestedEntity, _super);
    function ResizeShapeRequestedEntity(apiController, shape, oldSize, size) {
        var _this = _super.call(this, apiController) || this;
        _this.shape = shape;
        _this.oldSize = oldSize;
        _this.size = size;
        return _this;
    }
    Object.defineProperty(ResizeShapeRequestedEntity.prototype, "operation", {
        get: function () {
            return ModelOperationSettings_1.DiagramModelOperation.ResizeShape;
        },
        enumerable: false,
        configurable: true
    });
    ResizeShapeRequestedEntity.prototype.createEventArgs = function () {
        return new ResizeShapeEventArgs(this.apiController.createNativeShape(this.shape), this.apiController.convertSize(this.oldSize), this.apiController.convertSize(this.size));
    };
    Object.defineProperty(ResizeShapeRequestedEntity.prototype, "settingsKey", {
        get: function () {
            return "resizeShape";
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(ResizeShapeRequestedEntity.prototype, "storageKey", {
        get: function () {
            return this.settingsKey + "_" + (this.shape && this.shape.key);
        },
        enumerable: false,
        configurable: true
    });
    ResizeShapeRequestedEntity.prototype.equals = function (other) {
        if (other instanceof ResizeShapeRequestedEntity)
            return this.shape === other.shape && this.oldSize.equals(other.oldSize) && this.size.equals(other.size);
        return false;
    };
    return ResizeShapeRequestedEntity;
}(RequestedEntity_1.RequestedEntity));
exports.ResizeShapeRequestedEntity = ResizeShapeRequestedEntity;
var ResizeShapeEventArgs = (function (_super) {
    __extends(ResizeShapeEventArgs, _super);
    function ResizeShapeEventArgs(shape, oldSize, size) {
        var _this = _super.call(this) || this;
        _this.shape = shape;
        _this.oldSize = oldSize;
        _this.size = size;
        return _this;
    }
    return ResizeShapeEventArgs;
}(RequestedEntity_1.PermissionRequestEventArgs));
exports.ResizeShapeEventArgs = ResizeShapeEventArgs;


/***/ }),
/* 367 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.MoveShapeEventArgs = exports.MoveShapeRequestedEntity = void 0;
var ModelOperationSettings_1 = __webpack_require__(16);
var RequestedEntity_1 = __webpack_require__(23);
var MoveShapeRequestedEntity = (function (_super) {
    __extends(MoveShapeRequestedEntity, _super);
    function MoveShapeRequestedEntity(apiController, shape, oldPosition, position) {
        var _this = _super.call(this, apiController) || this;
        _this.shape = shape;
        _this.oldPosition = oldPosition;
        _this.position = position;
        return _this;
    }
    Object.defineProperty(MoveShapeRequestedEntity.prototype, "operation", {
        get: function () {
            return ModelOperationSettings_1.DiagramModelOperation.MoveShape;
        },
        enumerable: false,
        configurable: true
    });
    MoveShapeRequestedEntity.prototype.createEventArgs = function () {
        return new MoveShapeEventArgs(this.apiController.createNativeShape(this.shape), this.apiController.convertPoint(this.oldPosition), this.apiController.convertPoint(this.position));
    };
    Object.defineProperty(MoveShapeRequestedEntity.prototype, "settingsKey", {
        get: function () {
            return "moveShape";
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(MoveShapeRequestedEntity.prototype, "storageKey", {
        get: function () {
            return this.settingsKey + "_" + (this.shape && this.shape.key);
        },
        enumerable: false,
        configurable: true
    });
    MoveShapeRequestedEntity.prototype.equals = function (other) {
        if (other instanceof MoveShapeRequestedEntity)
            return this.shape === other.shape && this.oldPosition.equals(other.oldPosition) && this.position.equals(other.position);
        return false;
    };
    return MoveShapeRequestedEntity;
}(RequestedEntity_1.RequestedEntity));
exports.MoveShapeRequestedEntity = MoveShapeRequestedEntity;
var MoveShapeEventArgs = (function (_super) {
    __extends(MoveShapeEventArgs, _super);
    function MoveShapeEventArgs(shape, oldPosition, position) {
        var _this = _super.call(this) || this;
        _this.shape = shape;
        _this.oldPosition = oldPosition;
        _this.position = position;
        return _this;
    }
    return MoveShapeEventArgs;
}(RequestedEntity_1.PermissionRequestEventArgs));
exports.MoveShapeEventArgs = MoveShapeEventArgs;


/***/ }),
/* 368 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.ConnectorRoutingModel = exports.ConnectorRoutingPenaltyDescription = void 0;
var Settings_1 = __webpack_require__(28);
var Shape_1 = __webpack_require__(14);
var Connector_1 = __webpack_require__(6);
var ConnectorProperties_1 = __webpack_require__(32);
var RightAngleConnectorRoutingStrategy_1 = __webpack_require__(369);
var ConnectorRoutingPenaltyDescription = (function () {
    function ConnectorRoutingPenaltyDescription() {
        this.shape = 20.0;
        this.margin = 2.0;
        this.turnBack = 20.0;
        this.turnLeft = 3.1;
        this.turnRight = 3.0;
    }
    return ConnectorRoutingPenaltyDescription;
}());
exports.ConnectorRoutingPenaltyDescription = ConnectorRoutingPenaltyDescription;
var ConnectorRoutingModel = (function () {
    function ConnectorRoutingModel() {
        this.connectorRoutingMode = Settings_1.ConnectorRoutingMode.AllShapesOnly;
        this.shapeMargins = Connector_1.Connector.minOffset;
        this.shouldReverseConnections = true;
        this.shouldResizeConnections = true;
        this.penaltyDescription = new ConnectorRoutingPenaltyDescription();
    }
    ConnectorRoutingModel.prototype.initialize = function (model) {
        this.model = model;
    };
    ConnectorRoutingModel.prototype.createStrategy = function (option) {
        if (this.model !== undefined && this.connectorRoutingMode !== Settings_1.ConnectorRoutingMode.None && option === ConnectorProperties_1.ConnectorLineOption.Orthogonal)
            return new RightAngleConnectorRoutingStrategy_1.RightAngleConnectorRoutingStrategy(this);
        return undefined;
    };
    ConnectorRoutingModel.prototype.getItems = function (beginConnectorShape, endConnectorShape) {
        return this.getShapes(beginConnectorShape, endConnectorShape);
    };
    ConnectorRoutingModel.prototype.notifyConnectorRoutingModeChanged = function (connectorRoutingMode) {
        this.connectorRoutingMode = connectorRoutingMode;
    };
    ConnectorRoutingModel.prototype.getShapes = function (beginConnectorShape, endConnectorShape) {
        if (this.model === undefined || this.connectorRoutingMode === undefined || this.connectorRoutingMode === Settings_1.ConnectorRoutingMode.None)
            return [];
        if (this.connectorRoutingMode === Settings_1.ConnectorRoutingMode.AllShapesOnly)
            return this.model.items.filter(function (i) { return i instanceof Shape_1.Shape; });
        return this.getConnectorShapes(beginConnectorShape, endConnectorShape);
    };
    ConnectorRoutingModel.prototype.getConnectorShapes = function (beginConnectorShape, endConnectorShape) {
        var result = [];
        if (beginConnectorShape)
            result.push(beginConnectorShape);
        if (endConnectorShape && beginConnectorShape !== endConnectorShape)
            result.push(endConnectorShape);
        return result;
    };
    return ConnectorRoutingModel;
}());
exports.ConnectorRoutingModel = ConnectorRoutingModel;


/***/ }),
/* 369 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.RightAngleConnectorRoutingStrategy = void 0;
var segment_1 = __webpack_require__(33);
var ConnectorRenderPoint_1 = __webpack_require__(29);
var RightAngleConnectorRoutingContext_1 = __webpack_require__(370);
var ModelUtils_1 = __webpack_require__(4);
var RightAngleConnectorRoutingStrategy = (function () {
    function RightAngleConnectorRoutingStrategy(model) {
        this.model = model;
    }
    RightAngleConnectorRoutingStrategy.prototype.createRenderPoints = function (points, supportRenderPoints, beginConnectionShape, endConnectionShape, beginConnectionPointIndex, endConnectionPointIndex, container) {
        if (supportRenderPoints.length > 1) {
            var context = new RightAngleConnectorRoutingContext_1.RightAngleConnectorRoutingContext(this.model, points, supportRenderPoints, beginConnectionShape, endConnectionShape, beginConnectionPointIndex, endConnectionPointIndex);
            context.initialize(container);
            if (context.shouldCreateRenderPoints)
                return this.createRenderPointsCore(context);
        }
    };
    RightAngleConnectorRoutingStrategy.prototype.clone = function () {
        return new RightAngleConnectorRoutingStrategy(this.model);
    };
    RightAngleConnectorRoutingStrategy.prototype.onAddPoint = function (points, pointIndex, point, oldRenderPoints) {
        var renderPoints = oldRenderPoints.map(function (p) { return new ConnectorRenderPoint_1.ConnectorRenderPoint(p.x, p.y, p.pointIndex); });
        var renderPointIndex = ModelUtils_1.ModelUtils.findFirstPointIndex(renderPoints, function (p) { return p.equals(point); });
        if (renderPointIndex === 0) {
            renderPoints.splice(1, 0, new ConnectorRenderPoint_1.ConnectorRenderPoint(point.x, point.y, pointIndex));
            return ModelUtils_1.ModelUtils.validateRenderPointIndexes(points, renderPoints, 2);
        }
        var lastRenderPointIndex = renderPoints.length - 1;
        if (renderPointIndex === lastRenderPointIndex) {
            renderPoints.splice(lastRenderPointIndex, 0, new ConnectorRenderPoint_1.ConnectorRenderPoint(point.x, point.y, pointIndex));
            renderPoints[lastRenderPointIndex + 1].pointIndex = pointIndex + 1;
            return renderPoints;
        }
        if (renderPointIndex > 0) {
            var oldRenderPoint = renderPoints[renderPointIndex];
            renderPoints[renderPointIndex] = new ConnectorRenderPoint_1.ConnectorRenderPoint(oldRenderPoint.x, oldRenderPoint.y, pointIndex, oldRenderPoint.skipped);
            return ModelUtils_1.ModelUtils.validateRenderPointIndexes(points, renderPoints, renderPointIndex + 1);
        }
        var firstSegment = new segment_1.Segment(renderPoints[0], renderPoints[1]);
        var newRenderPoint = new ConnectorRenderPoint_1.ConnectorRenderPoint(point.x, point.y);
        if (firstSegment.containsPoint(newRenderPoint)) {
            renderPoints.splice(1, 0, new ConnectorRenderPoint_1.ConnectorRenderPoint(newRenderPoint.x, newRenderPoint.y, -1));
            renderPoints.splice(2, 0, new ConnectorRenderPoint_1.ConnectorRenderPoint(newRenderPoint.x, newRenderPoint.y, pointIndex));
            return ModelUtils_1.ModelUtils.validateRenderPointIndexes(points, renderPoints, 3);
        }
        var lastSegment = new segment_1.Segment(renderPoints[lastRenderPointIndex - 1], renderPoints[lastRenderPointIndex]);
        if (lastSegment.containsPoint(newRenderPoint)) {
            renderPoints.splice(lastRenderPointIndex, 0, new ConnectorRenderPoint_1.ConnectorRenderPoint(newRenderPoint.x, newRenderPoint.y, pointIndex));
            renderPoints.splice(lastRenderPointIndex + 1, 0, new ConnectorRenderPoint_1.ConnectorRenderPoint(newRenderPoint.x, newRenderPoint.y, -1));
            renderPoints[lastRenderPointIndex + 2].pointIndex = pointIndex + 1;
            return renderPoints;
        }
        return oldRenderPoints;
    };
    RightAngleConnectorRoutingStrategy.prototype.onDeletePoint = function (points, pointIndex, oldRenderPoints) {
        var renderPoints = oldRenderPoints.map(function (p) { return new ConnectorRenderPoint_1.ConnectorRenderPoint(p.x, p.y, p.pointIndex); });
        var renderPointIndex = this.getRenderPointIndexByPointIndex(renderPoints, pointIndex);
        if (renderPointIndex === 1) {
            var previuosRenderPoint = renderPoints[0];
            var currentRenderPoint_1 = renderPoints[1];
            if (previuosRenderPoint.equals(currentRenderPoint_1)) {
                renderPoints.splice(1, 1);
                return ModelUtils_1.ModelUtils.validateRenderPointIndexes(points, renderPoints, 1);
            }
            renderPoints[1] = new ConnectorRenderPoint_1.ConnectorRenderPoint(currentRenderPoint_1.x, currentRenderPoint_1.y, -1, currentRenderPoint_1.skipped);
            return ModelUtils_1.ModelUtils.validateRenderPointIndexes(points, renderPoints, 2);
        }
        if (renderPointIndex === 2) {
            var previuosRenderPoint = renderPoints[1];
            var currentRenderPoint_2 = renderPoints[2];
            if (previuosRenderPoint.equals(currentRenderPoint_2)) {
                renderPoints.splice(1, 2);
                return ModelUtils_1.ModelUtils.validateRenderPointIndexes(points, renderPoints, 1);
            }
            renderPoints[2] = new ConnectorRenderPoint_1.ConnectorRenderPoint(currentRenderPoint_2.x, currentRenderPoint_2.y, -1, currentRenderPoint_2.skipped);
            return ModelUtils_1.ModelUtils.validateRenderPointIndexes(points, renderPoints, 3);
        }
        var lastRenderPointIndex = renderPoints.length - 1;
        if (renderPointIndex === lastRenderPointIndex - 1) {
            var currentRenderPoint_3 = renderPoints[lastRenderPointIndex - 1];
            var nextRenderPoint = renderPoints[lastRenderPointIndex];
            if (currentRenderPoint_3.equals(nextRenderPoint)) {
                renderPoints.splice(lastRenderPointIndex - 1, 1);
                return ModelUtils_1.ModelUtils.validateRenderPointIndexes(points, renderPoints, lastRenderPointIndex - 1);
            }
            renderPoints[lastRenderPointIndex - 1] = new ConnectorRenderPoint_1.ConnectorRenderPoint(currentRenderPoint_3.x, currentRenderPoint_3.y, -1, currentRenderPoint_3.skipped);
            return ModelUtils_1.ModelUtils.validateRenderPointIndexes(points, renderPoints, lastRenderPointIndex);
        }
        if (renderPointIndex === lastRenderPointIndex - 2) {
            var currentRenderPoint_4 = renderPoints[lastRenderPointIndex - 2];
            var nextRenderPoint = renderPoints[lastRenderPointIndex - 1];
            if (currentRenderPoint_4.equals(nextRenderPoint)) {
                renderPoints.splice(lastRenderPointIndex - 2, 2);
                return ModelUtils_1.ModelUtils.validateRenderPointIndexes(points, renderPoints, lastRenderPointIndex - 2);
            }
            renderPoints[lastRenderPointIndex - 2] = new ConnectorRenderPoint_1.ConnectorRenderPoint(currentRenderPoint_4.x, currentRenderPoint_4.y, -1, currentRenderPoint_4.skipped);
            return ModelUtils_1.ModelUtils.validateRenderPointIndexes(points, renderPoints, lastRenderPointIndex - 1);
        }
        var currentRenderPoint = renderPoints[renderPointIndex];
        renderPoints[renderPointIndex] = new ConnectorRenderPoint_1.ConnectorRenderPoint(currentRenderPoint.x, currentRenderPoint.y, -1, currentRenderPoint.skipped);
        return ModelUtils_1.ModelUtils.validateRenderPointIndexes(points, renderPoints, renderPointIndex + 1);
    };
    RightAngleConnectorRoutingStrategy.prototype.onMovePoint = function (points, pointIndex, point, oldRenderPoints) {
        if (pointIndex === 0 || pointIndex === points.length - 1)
            return oldRenderPoints;
        var renderPoints = oldRenderPoints.map(function (p) { return new ConnectorRenderPoint_1.ConnectorRenderPoint(p.x, p.y, p.pointIndex); });
        this.onMovePointCore(renderPoints, pointIndex, point);
        ModelUtils_1.ModelUtils.skipUnnecessaryRightAngleRenderPoints(renderPoints);
        return renderPoints;
    };
    RightAngleConnectorRoutingStrategy.prototype.onMovePoints = function (points, beginPointIndex, beginPoint, lastPointIndex, lastPoint, oldRenderPoints) {
        if (beginPointIndex === 0 || lastPointIndex === points.length - 1)
            return oldRenderPoints;
        var renderPoints = oldRenderPoints.map(function (p) { return new ConnectorRenderPoint_1.ConnectorRenderPoint(p.x, p.y, p.pointIndex); });
        this.onMovePointCore(renderPoints, beginPointIndex, beginPoint);
        this.onMovePointCore(renderPoints, lastPointIndex, lastPoint);
        ModelUtils_1.ModelUtils.skipUnnecessaryRightAngleRenderPoints(renderPoints);
        return renderPoints;
    };
    RightAngleConnectorRoutingStrategy.prototype.onMovePointCore = function (newRenderPoints, pointIndex, newPoint) {
        var renderPointIndex = this.getRenderPointIndexByPointIndex(newRenderPoints, pointIndex);
        if (renderPointIndex >= 0) {
            var oldRenderPoint = newRenderPoints[renderPointIndex];
            newRenderPoints[renderPointIndex] = new ConnectorRenderPoint_1.ConnectorRenderPoint(newPoint.x, newPoint.y, pointIndex, oldRenderPoint.skipped);
        }
    };
    RightAngleConnectorRoutingStrategy.prototype.createRenderPointsCore = function (context) {
        var result = [];
        var currentIndex = -1;
        var currentRenderSegment;
        var currentStartCustomPointIndex = -1;
        context.setup();
        var renderSegments = context.renderSegments;
        var endPoint = renderSegments[renderSegments.length - 1].endPoint;
        var points = context.points;
        do {
            this.registerCustomPoints(result, points, currentStartCustomPointIndex + 2, renderSegments[currentIndex + 1].startPointIndex - 1);
            currentIndex++;
            currentRenderSegment = renderSegments[currentIndex];
            currentStartCustomPointIndex = currentRenderSegment.startPointIndex;
            this.registerRenderPoints(result, context.createRoutedPoints(currentRenderSegment.startInfo, currentRenderSegment.endInfo, currentRenderSegment.createProhibitedSegments()), currentStartCustomPointIndex);
        } while (!currentRenderSegment.endPoint.equals(endPoint));
        context.validateRenderPoints(result);
        return result;
    };
    RightAngleConnectorRoutingStrategy.prototype.getRenderPointIndexByPointIndex = function (points, index) {
        return ModelUtils_1.ModelUtils.findFirstPointIndex(points, function (p) { return p.pointIndex === index; });
    };
    RightAngleConnectorRoutingStrategy.prototype.registerRenderPoints = function (resultPath, routedPoints, beginPointIndex) {
        var _this = this;
        routedPoints.forEach(function (p, i) {
            var pointIndex = i === 0 ? beginPointIndex : (i === routedPoints.length - 1 ? beginPointIndex + 1 : -1);
            _this.registerPoint(resultPath, p, pointIndex);
        });
    };
    RightAngleConnectorRoutingStrategy.prototype.registerCustomPoints = function (resultPath, points, startIndex, endIndex) {
        for (var i = startIndex; i <= endIndex; i++)
            this.registerPoint(resultPath, points[i], i);
    };
    RightAngleConnectorRoutingStrategy.prototype.registerPoint = function (resultPath, point, pointIndex) {
        resultPath.push(new ConnectorRenderPoint_1.ConnectorRenderPoint(point.x, point.y, pointIndex));
    };
    return RightAngleConnectorRoutingStrategy;
}());
exports.RightAngleConnectorRoutingStrategy = RightAngleConnectorRoutingStrategy;


/***/ }),
/* 370 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.RightAngleConnectorRoutingContext = exports.IntersectingItemsByPointsContext = exports.CuttingItemsContext = void 0;
var point_1 = __webpack_require__(0);
var segment_1 = __webpack_require__(33);
var vector_1 = __webpack_require__(60);
var DiagramItem_1 = __webpack_require__(9);
var RightAngleConnectorRoutingMathOperations_1 = __webpack_require__(160);
var ConnectorRenderSegment_1 = __webpack_require__(371);
var RoutingGrid_1 = __webpack_require__(373);
var ModelUtils_1 = __webpack_require__(4);
var AStarMetrics_1 = __webpack_require__(161);
var AStarContext_1 = __webpack_require__(374);
var AStarCalculator_1 = __webpack_require__(378);
var Utils_1 = __webpack_require__(3);
var CuttingItemsContext = (function () {
    function CuttingItemsContext() {
        this.cuttingItemKeys = [];
    }
    Object.defineProperty(CuttingItemsContext.prototype, "isEmpty", {
        get: function () {
            return this.cuttingItemKeys.length === 0;
        },
        enumerable: false,
        configurable: true
    });
    CuttingItemsContext.prototype.registerShape = function (key, rect, segments) {
        if (Utils_1.GeometryUtils.areSegmentsCutRectangle(segments, rect)) {
            this.cuttingItemKeys.push(key);
            return true;
        }
        return false;
    };
    return CuttingItemsContext;
}());
exports.CuttingItemsContext = CuttingItemsContext;
var IntersectingItemsByPointsContext = (function () {
    function IntersectingItemsByPointsContext() {
        this.items = {};
    }
    IntersectingItemsByPointsContext.prototype.getOrAddItems = function (point, getItems) {
        if (point) {
            var key = point.toString();
            var item = this.items[key];
            if (item !== undefined)
                return item.items;
            if (getItems) {
                var items = getItems(point);
                this.items[key] = { point: point, items: items };
                return items;
            }
        }
        return undefined;
    };
    return IntersectingItemsByPointsContext;
}());
exports.IntersectingItemsByPointsContext = IntersectingItemsByPointsContext;
var RightAngleConnectorRoutingContext = (function () {
    function RightAngleConnectorRoutingContext(routingModel, points, supportRenderPoints, beginConnectionShape, endConnectionShape, beginConnectionPointIndex, endConnectionPointIndex) {
        this.routingModel = routingModel;
        this.points = points;
        this.supportRenderPoints = supportRenderPoints;
        this.beginConnectionShape = beginConnectionShape;
        this.endConnectionShape = endConnectionShape;
        this.beginConnectionSide = this.getConnectionSide(this.beginConnectionShape, beginConnectionPointIndex, this.beginPoint);
        this.endConnectionSide = this.getConnectionSide(this.endConnectionShape, endConnectionPointIndex, this.endPoint);
        this.ignorableItemKeys = {};
        this.cuttingShapesContext = new CuttingItemsContext();
        this.intersectedItemsByPointsContext = new IntersectingItemsByPointsContext();
        this.isInvalidRenderSegments = true;
    }
    Object.defineProperty(RightAngleConnectorRoutingContext.prototype, "shapeMargins", {
        get: function () {
            return this.routingModel.shapeMargins;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(RightAngleConnectorRoutingContext.prototype, "beginPoint", {
        get: function () {
            return this.points[0];
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(RightAngleConnectorRoutingContext.prototype, "endPoint", {
        get: function () {
            return this.points[this.points.length - 1];
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(RightAngleConnectorRoutingContext.prototype, "hasIntersecting", {
        get: function () {
            return !this.cuttingShapesContext.isEmpty;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(RightAngleConnectorRoutingContext.prototype, "shouldCreateRenderPoints", {
        get: function () {
            return this.isInvalidRenderSegments ||
                (!this.isSmallPath &&
                    (this.hasIntersecting || this.isReversedStartConnection || this.isReversedEndConnection));
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(RightAngleConnectorRoutingContext.prototype, "beginPathPoint", {
        get: function () {
            return this.beginConnectionSegment instanceof segment_1.Segment ? this.beginConnectionSegment.startPoint : this.beginConnectionSegment;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(RightAngleConnectorRoutingContext.prototype, "endPathPoint", {
        get: function () {
            return this.endConnectionSegment instanceof segment_1.Segment ? this.endConnectionSegment.endPoint : this.endConnectionSegment;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(RightAngleConnectorRoutingContext.prototype, "isReversedStartConnection", {
        get: function () {
            if (!this.beginConnectionShape || this.beginConnectionSide === DiagramItem_1.ConnectionPointSide.Undefined)
                return false;
            var beginConnectionSegment = this.beginConnectionSegment;
            return !(beginConnectionSegment instanceof point_1.Point) &&
                this.isReversedConnectionSegment(this.supportSegments[0], beginConnectionSegment);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(RightAngleConnectorRoutingContext.prototype, "isReversedEndConnection", {
        get: function () {
            if (!this.endConnectionShape || this.endConnectionSide === DiagramItem_1.ConnectionPointSide.Undefined)
                return false;
            var endConnectionSegment = this.endConnectionSegment;
            return !(endConnectionSegment instanceof point_1.Point) &&
                this.isReversedConnectionSegment(this.supportSegments[this.supportSegments.length - 1], endConnectionSegment);
        },
        enumerable: false,
        configurable: true
    });
    RightAngleConnectorRoutingContext.prototype.isReversedConnectionSegment = function (supportSegment, connectionSegment) {
        return vector_1.Vector.scalarProduct(vector_1.Vector.fromSegment(supportSegment), vector_1.Vector.fromPoints(connectionSegment.startPoint, connectionSegment.endPoint)) <= 0;
    };
    Object.defineProperty(RightAngleConnectorRoutingContext.prototype, "isSmallPath", {
        get: function () {
            var doubleMargins = 2 * this.routingModel.shapeMargins;
            return Math.abs(this.beginPathPoint.x - this.endPathPoint.x) < doubleMargins &&
                Math.abs(this.beginPathPoint.y - this.endPathPoint.y) < doubleMargins;
        },
        enumerable: false,
        configurable: true
    });
    RightAngleConnectorRoutingContext.prototype.initialize = function (container) {
        this.processContainers(container);
        this.processSupportSegments();
        this.processIntersection();
        this.processConnections();
        this.processRenderSegments();
    };
    RightAngleConnectorRoutingContext.prototype.setup = function () {
        this.processRoutingGrid();
        this.processRoutingMetrics();
    };
    RightAngleConnectorRoutingContext.prototype.createRoutedPoints = function (startInfo, targetInfo, prohibitedSegments) {
        var startPathPoint = startInfo instanceof point_1.Point ? startInfo : startInfo.endPoint;
        var targetPathPoint = targetInfo instanceof point_1.Point ? targetInfo : targetInfo.startPoint;
        var context = this.createAStarContext(startPathPoint, targetPathPoint, prohibitedSegments);
        AStarCalculator_1.AStarCalculator.calculate(context);
        var result = context.path;
        this.addConnectionRoutedPoints(result, startInfo, targetInfo);
        RightAngleConnectorRoutingMathOperations_1.RightAngleConnectorRoutingMathOperations.unionPoints(result);
        return result;
    };
    RightAngleConnectorRoutingContext.prototype.getIntersectedItems = function (point, predicate) {
        var _this = this;
        return this.intersectedItemsByPointsContext.getOrAddItems(point, function (p) { return _this.routingModel
            .getItems(_this.beginConnectionShape, _this.endConnectionShape)
            .filter(function (s) { return !_this.isIgnorableItem(s) && predicate(p, s); }); });
    };
    RightAngleConnectorRoutingContext.prototype.validateRenderPoints = function (result) {
        if (this.isInvalidRenderSegments) {
            RightAngleConnectorRoutingMathOperations_1.RightAngleConnectorRoutingMathOperations.unionPoints(result);
            ModelUtils_1.ModelUtils.validateRenderPointIndexes(this.points, result, 0);
        }
        ModelUtils_1.ModelUtils.skipUnnecessaryRightAngleRenderPoints(result);
    };
    RightAngleConnectorRoutingContext.prototype.processContainers = function (container) {
        if (container)
            this.registerIgnorableShape(container);
        if (this.beginConnectionShape) {
            var beginShapeContainer = this.beginConnectionShape.container;
            if (beginShapeContainer)
                this.registerIgnorableShape(beginShapeContainer);
        }
        if (this.endConnectionShape) {
            var endShapeContainer = this.endConnectionShape.container;
            if (endShapeContainer)
                this.registerIgnorableShape(endShapeContainer);
        }
    };
    RightAngleConnectorRoutingContext.prototype.processSupportSegments = function () {
        this.supportSegments = this.createSupportSegments();
    };
    RightAngleConnectorRoutingContext.prototype.processIntersection = function () {
        var _this = this;
        var shapes = this.routingModel.getItems(this.beginConnectionShape, this.endConnectionShape);
        if (shapes)
            shapes.forEach(function (s) {
                var key = s.key;
                var rect = s.rectangle;
                if (!_this.cuttingShapesContext.registerShape(key, rect, _this.supportSegments)) {
                    if ((!_this.isConnectedByStart(s) && rect.containsPoint(_this.beginPoint)) ||
                        !_this.isConnectedByEnd(s) && rect.containsPoint(_this.endPoint))
                        _this.registerIgnorableShape(s);
                }
                else if (_this.ignorableItemKeys[key] !== undefined)
                    delete _this.ignorableItemKeys[key];
            });
    };
    RightAngleConnectorRoutingContext.prototype.processConnections = function () {
        var beginShapeContainsEndConnection = false;
        var endShapeContainsBeginConnection = false;
        if (this.beginConnectionShape !== this.endConnectionShape) {
            beginShapeContainsEndConnection = this.shapeContainsOtherConnection(this.beginConnectionShape, this.endConnectionShape, this.endPoint);
            endShapeContainsBeginConnection = this.shapeContainsOtherConnection(this.endConnectionShape, this.beginConnectionShape, this.beginPoint);
            if (beginShapeContainsEndConnection)
                this.registerIgnorableShape(this.beginConnectionShape);
            if (endShapeContainsBeginConnection)
                this.registerIgnorableShape(this.endConnectionShape);
        }
        var shapeMargins = this.routingModel.shapeMargins;
        this.beginConnectionSegment = this.createBeginConnectionSegment(shapeMargins, beginShapeContainsEndConnection);
        this.endConnectionSegment = this.createEndConnectionSegment(shapeMargins, endShapeContainsBeginConnection);
    };
    RightAngleConnectorRoutingContext.prototype.processRenderSegments = function () {
        this.isInvalidRenderSegments = false;
        this.renderSegments = this.createRenderSegments();
        for (var i = 0; i < this.renderSegments.length - 1; i++) {
            var renderSegment = this.renderSegments[i];
            var nextRenderSegment = this.renderSegments[i + 1];
            if (renderSegment.endPoint.equals(nextRenderSegment.startPoint)) {
                this.isInvalidRenderSegments = true;
                return;
            }
        }
    };
    RightAngleConnectorRoutingContext.prototype.createGridPoints = function () {
        var result = [];
        this.renderSegments.forEach(function (s) { return s.createGridPoints().forEach(function (p) { return result.push(p); }); });
        return result;
    };
    RightAngleConnectorRoutingContext.prototype.processRoutingGrid = function () {
        this.routingGrid = this.createGrid();
    };
    RightAngleConnectorRoutingContext.prototype.processRoutingMetrics = function () {
        this.metrics = this.createAStarMetrics();
    };
    RightAngleConnectorRoutingContext.prototype.createAStarMetrics = function () {
        return new AStarMetrics_1.AStarMetrics(new AStarMetrics_1.TurnDirectionMetrics(this.routingModel.penaltyDescription), new AStarMetrics_1.IntersectedShapesMetrics(new AStarMetrics_1.IntersectedShapeMetrics(this.routingModel.penaltyDescription, this.routingModel.shapeMargins)));
    };
    RightAngleConnectorRoutingContext.prototype.createAStarContext = function (start, target, prohibitedSegments) {
        return new AStarContext_1.AStarContext(this, start, target, prohibitedSegments, this.routingGrid, this.metrics);
    };
    RightAngleConnectorRoutingContext.prototype.addConnectionRoutedPoints = function (path, startInfo, targetInfo) {
        if (startInfo instanceof segment_1.Segment)
            path.splice(0, 0, startInfo.startPoint);
        if (targetInfo instanceof segment_1.Segment)
            path.push(targetInfo.endPoint);
    };
    RightAngleConnectorRoutingContext.prototype.createSupportSegments = function () {
        var _this = this;
        return this.supportRenderPoints.length <= 1 ? [] : Utils_1.GeometryUtils.createSegments(this.supportRenderPoints).filter(function (s) { return !_this.isCustomSegment(s, _this.supportRenderPoints[0], _this.supportRenderPoints[_this.supportRenderPoints.length - 1]); });
    };
    RightAngleConnectorRoutingContext.prototype.isCustomSegment = function (segment, startSegmentsPoint, endSegmentsPoint) {
        var startRenderPoint = segment.startPoint;
        if (startRenderPoint.equals(startSegmentsPoint))
            return false;
        var endRenderPoint = segment.endPoint;
        if (endRenderPoint.equals(endSegmentsPoint))
            return false;
        return endRenderPoint.pointIndex - startRenderPoint.pointIndex === 1;
    };
    RightAngleConnectorRoutingContext.prototype.createRenderSegments = function () {
        var _this = this;
        var unionRoutingSegments = RightAngleConnectorRoutingMathOperations_1.RightAngleConnectorRoutingMathOperations.createUnionSegments(this.supportSegments, function (ep, sp) { return _this.shouldCreateSegment(ep, sp); });
        var lastIndex = unionRoutingSegments.length - 1;
        return unionRoutingSegments.map(function (s, i) {
            return new ConnectorRenderSegment_1.ConnectorRenderSegment(i > 0 ? new point_1.Point(s.startPoint.x, s.startPoint.y) : _this.beginConnectionSegment, i < lastIndex ? new point_1.Point(s.endPoint.x, s.endPoint.y) : _this.endConnectionSegment, s.startPoint.pointIndex, _this.createPreviousCustomSegment(s.startPoint));
        });
    };
    RightAngleConnectorRoutingContext.prototype.createPreviousCustomSegment = function (startRoutingPoint) {
        var previuosPointIndex = startRoutingPoint.pointIndex - 1;
        return previuosPointIndex >= 0 ? new segment_1.Segment(this.points[previuosPointIndex].clone(), new point_1.Point(startRoutingPoint.x, startRoutingPoint.y)) : undefined;
    };
    RightAngleConnectorRoutingContext.prototype.shouldCreateSegment = function (prevEndPoint, startNextPoint) {
        return !prevEndPoint.equals(startNextPoint) || startNextPoint.pointIndex > 0;
    };
    RightAngleConnectorRoutingContext.prototype.isPathNormal = function (connectionSide) {
        if (connectionSide === DiagramItem_1.ConnectionPointSide.Undefined)
            return true;
        return RightAngleConnectorRoutingMathOperations_1.RightAngleConnectorRoutingMathOperations.isSegmentNormal(new segment_1.Segment(this.beginPoint, this.endPoint), connectionSide === DiagramItem_1.ConnectionPointSide.East || connectionSide === DiagramItem_1.ConnectionPointSide.West);
    };
    RightAngleConnectorRoutingContext.prototype.registerIgnorableShape = function (shape) {
        this.ignorableItemKeys[shape.key] = true;
    };
    RightAngleConnectorRoutingContext.prototype.isConnectedByStart = function (shape) {
        return this.beginConnectionShape && this.beginConnectionShape.key === shape.key && this.beginConnectionSide !== DiagramItem_1.ConnectionPointSide.Undefined;
    };
    RightAngleConnectorRoutingContext.prototype.isConnectedByEnd = function (shape) {
        return this.endConnectionShape && this.endConnectionShape.key === shape.key && this.endConnectionSide !== DiagramItem_1.ConnectionPointSide.Undefined;
    };
    RightAngleConnectorRoutingContext.prototype.getConnectionSide = function (shape, index, point) {
        return shape ? shape.getConnectionPointSideByIndex(index, point) : DiagramItem_1.ConnectionPointSide.Undefined;
    };
    RightAngleConnectorRoutingContext.prototype.shapeContainsOtherConnection = function (targetShape, otherShape, otherPoint) {
        if (!targetShape)
            return false;
        var targetRectangle = targetShape.rectangle;
        return targetRectangle.containsPoint(otherPoint) &&
            (!otherShape || !otherShape.rectangle.equals(targetRectangle));
    };
    RightAngleConnectorRoutingContext.prototype.createBeginConnectionSegment = function (offset, beginShapeContainsEndConnection) {
        if (this.beginConnectionSide === DiagramItem_1.ConnectionPointSide.Undefined)
            return this.createBeginConnectionSegmentCore(offset);
        if (!beginShapeContainsEndConnection || !this.routingModel.shouldReverseConnections) {
            var segment = this.createBeginConnectionSegmentCore(offset);
            if (segment instanceof point_1.Point || !this.routingModel.shouldResizeConnections)
                return segment;
            var startPoint = segment.startPoint;
            var endPoint = segment.endPoint;
            var currentOffset = offset;
            while (this.hasIntersectedItemsByPoint(endPoint, startPoint, this.beginConnectionShape)) {
                currentOffset = currentOffset / 2;
                segment = this.createBeginConnectionSegmentCore(currentOffset);
                endPoint = segment.endPoint;
            }
            return segment;
        }
        if (!this.endConnectionShape)
            return this.createBeginConnectionSegmentCore(-offset);
        if (this.isPathNormal(this.endConnectionSide))
            return this.createBeginConnectionSegmentCore(-offset);
        var reversedSegment = this.createBeginConnectionSegmentCore(-2 * offset);
        if (this.isEndConnectionRectanleLineIntersected(reversedSegment, false, true))
            return this.createBeginConnectionSegmentCore(offset);
        return this.createBeginConnectionSegmentCore(-offset);
    };
    RightAngleConnectorRoutingContext.prototype.hasIntersectedItemsByPoint = function (point, secondPoint, connectionItem) {
        var intersectedItems = this.getIntersectedItems(point, function (p, s) { return s.rectangle.containsPoint(p) && !s.rectangle.containsPoint(secondPoint) && s.key !== connectionItem.key; });
        return intersectedItems !== undefined && intersectedItems.length > 0;
    };
    RightAngleConnectorRoutingContext.prototype.createEndConnectionSegment = function (offset, endShapeContainsBeginConnection) {
        if (this.endConnectionSide === DiagramItem_1.ConnectionPointSide.Undefined)
            return this.createEndConnectionSegmentCore(offset);
        if (!endShapeContainsBeginConnection || !this.routingModel.shouldReverseConnections) {
            var segment = this.createEndConnectionSegmentCore(offset);
            if (segment instanceof point_1.Point || !this.routingModel.shouldResizeConnections)
                return segment;
            var endPoint = segment.endPoint;
            var startPoint = segment.startPoint;
            var currentOffset = offset;
            while (this.hasIntersectedItemsByPoint(startPoint, endPoint, this.endConnectionShape)) {
                currentOffset = currentOffset / 2;
                segment = this.createEndConnectionSegmentCore(currentOffset);
                startPoint = segment.startPoint;
            }
            return segment;
        }
        if (!this.beginConnectionShape)
            return this.createEndConnectionSegmentCore(-offset);
        if (this.isPathNormal(this.beginConnectionSide))
            return this.createEndConnectionSegmentCore(-offset);
        var reversedSegment = this.createEndConnectionSegmentCore(-2 * offset);
        if (this.isBeginConnectionRectanleLineIntersected(reversedSegment, true, false))
            return this.createEndConnectionSegmentCore(offset);
        return this.createEndConnectionSegmentCore(-offset);
    };
    RightAngleConnectorRoutingContext.prototype.createBeginConnectionSegmentCore = function (offset) {
        return RightAngleConnectorRoutingMathOperations_1.RightAngleConnectorRoutingMathOperations.createBeginConnectionSegment(this.beginConnectionSide, this.beginPoint, offset, function (x, y) { return new point_1.Point(x, y); });
    };
    RightAngleConnectorRoutingContext.prototype.createEndConnectionSegmentCore = function (offset) {
        return RightAngleConnectorRoutingMathOperations_1.RightAngleConnectorRoutingMathOperations.createEndConnectionSegment(this.endConnectionSide, this.endPoint, offset, function (x, y) { return new point_1.Point(x, y); });
    };
    RightAngleConnectorRoutingContext.prototype.isBeginConnectionRectanleLineIntersected = function (segment, excludeBeginPoint, excludeEndPoint) {
        return RightAngleConnectorRoutingMathOperations_1.RightAngleConnectorRoutingMathOperations.isConnectionRectanleLineIntersected(this.beginConnectionShape.rectangle, segment, this.beginConnectionSide, excludeBeginPoint, excludeEndPoint, function (x, y) { return new point_1.Point(x, y); });
    };
    RightAngleConnectorRoutingContext.prototype.isEndConnectionRectanleLineIntersected = function (segment, excludeBeginPoint, excludeEndPoint) {
        return RightAngleConnectorRoutingMathOperations_1.RightAngleConnectorRoutingMathOperations.isConnectionRectanleLineIntersected(this.endConnectionShape.rectangle, segment, this.endConnectionSide, excludeBeginPoint, excludeEndPoint, function (x, y) { return new point_1.Point(x, y); });
    };
    RightAngleConnectorRoutingContext.prototype.isIgnorableItem = function (item) {
        return this.ignorableItemKeys[item.key] !== undefined;
    };
    RightAngleConnectorRoutingContext.prototype.createExtendedShapesBounds = function () {
        var _this = this;
        return this.routingModel.getItems(this.beginConnectionShape, this.endConnectionShape).map(function (i) { return i.rectangle.clone().inflate(_this.routingModel.shapeMargins); });
    };
    RightAngleConnectorRoutingContext.prototype.createGrid = function () {
        return RoutingGrid_1.RoutingGrid.create(this.createGridPoints(), this.createExtendedShapesBounds(), function (x, y) { return new point_1.Point(x, y); });
    };
    return RightAngleConnectorRoutingContext;
}());
exports.RightAngleConnectorRoutingContext = RightAngleConnectorRoutingContext;


/***/ }),
/* 371 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.ConnectorRenderSegment = void 0;
var segment_1 = __webpack_require__(33);
var ConnectorProhibitedSegments_1 = __webpack_require__(372);
var ConnectorRenderSegment = (function () {
    function ConnectorRenderSegment(startInfo, endInfo, startPointIndex, previousCustomSegment) {
        this.startInfo = startInfo;
        this.endInfo = endInfo;
        this.startPointIndex = startPointIndex;
        this.previousCustomSegment = previousCustomSegment;
    }
    Object.defineProperty(ConnectorRenderSegment.prototype, "startPathPoint", {
        get: function () {
            return this.startInfo instanceof segment_1.Segment ? this.startInfo.endPoint : this.startInfo;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(ConnectorRenderSegment.prototype, "endPathPoint", {
        get: function () {
            return this.endInfo instanceof segment_1.Segment ? this.endInfo.startPoint : this.endInfo;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(ConnectorRenderSegment.prototype, "startPoint", {
        get: function () {
            return this.startInfo instanceof segment_1.Segment ? this.startInfo.startPoint : this.startInfo;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(ConnectorRenderSegment.prototype, "endPoint", {
        get: function () {
            return this.endInfo instanceof segment_1.Segment ? this.endInfo.endPoint : this.endInfo;
        },
        enumerable: false,
        configurable: true
    });
    ConnectorRenderSegment.prototype.createGridPoints = function () {
        var result = [];
        if (this.endInfo instanceof segment_1.Segment) {
            result.push(this.endInfo.startPoint);
            result.push(this.endInfo.endPoint);
        }
        else
            result.push(this.endInfo);
        return result;
    };
    ConnectorRenderSegment.prototype.createProhibitedSegments = function () {
        if (this.startInfo instanceof segment_1.Segment) {
            var result = this.createProhibitedSegmentsCore(this.startInfo);
            if (this.endInfo instanceof segment_1.Segment) {
                result.addSegment(this.endInfo);
                result.addExludedPoint(this.endInfo.startPoint);
            }
            if (this.previousCustomSegment)
                result.addSegment(this.previousCustomSegment);
            return result;
        }
        if (this.endInfo instanceof segment_1.Segment) {
            var result = this.createProhibitedSegmentsCore(this.endInfo);
            result.addExludedPoint(this.endInfo.startPoint);
            if (this.previousCustomSegment)
                result.addSegment(this.previousCustomSegment);
            return result;
        }
        return this.previousCustomSegment ? this.createProhibitedSegmentsCore(this.previousCustomSegment) : undefined;
    };
    ConnectorRenderSegment.prototype.createProhibitedSegmentsCore = function (segment) {
        var result = new ConnectorProhibitedSegments_1.ConnectorProhibitedSegments();
        result.addSegment(segment);
        return result;
    };
    return ConnectorRenderSegment;
}());
exports.ConnectorRenderSegment = ConnectorRenderSegment;


/***/ }),
/* 372 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.ConnectorProhibitedSegments = void 0;
var ConnectorProhibitedSegments = (function () {
    function ConnectorProhibitedSegments() {
        this.segments = [];
        this.exludedPoints = {};
    }
    ConnectorProhibitedSegments.prototype.addSegment = function (segment) {
        this.segments.push(segment);
    };
    ConnectorProhibitedSegments.prototype.addExludedPoint = function (point) {
        this.exludedPoints[point.toString()] = point;
    };
    ConnectorProhibitedSegments.prototype.allowPoint = function (point) {
        if (this.exludedPoints[point.toString()] === undefined)
            for (var i = 0; i < this.segments.length; i++)
                if (this.segments[i].containsPoint(point))
                    return false;
        return true;
    };
    return ConnectorProhibitedSegments;
}());
exports.ConnectorProhibitedSegments = ConnectorProhibitedSegments;


/***/ }),
/* 373 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.RoutingGrid = void 0;
var search_1 = __webpack_require__(41);
var RoutingGrid = (function () {
    function RoutingGrid(verticalGridLines, horizontalGridLines, createPoint) {
        this.verticalGridLines = verticalGridLines;
        this.horizontalGridLines = horizontalGridLines;
        this.createPoint = createPoint;
    }
    RoutingGrid.create = function (points, boundsSet, createPoint) {
        var _this = this;
        var verticalLines = [];
        var horizontalLines = [];
        var varticalHashMap = {};
        var horizontalHashMap = {};
        boundsSet.forEach(function (x) {
            _this.addLine(x.x, verticalLines, varticalHashMap);
            _this.addLine(x.right, verticalLines, varticalHashMap);
            _this.addLine(x.y, horizontalLines, horizontalHashMap);
            _this.addLine(x.bottom, horizontalLines, horizontalHashMap);
        });
        points.forEach(function (p) {
            _this.addLine(p.x, verticalLines, varticalHashMap);
            _this.addLine(p.y, horizontalLines, horizontalHashMap);
        });
        verticalLines.sort(function (a, b) { return a - b; });
        horizontalLines.sort(function (a, b) { return a - b; });
        return new RoutingGrid(verticalLines, horizontalLines, createPoint);
    };
    RoutingGrid.addLine = function (line, lines, hashMap) {
        if (!hashMap[line]) {
            lines.push(line);
            hashMap[line] = true;
        }
    };
    RoutingGrid.prototype.getNeighborPoints = function (point) {
        var result = [];
        if (!this.horizontalGridLines || !this.horizontalGridLines.length ||
            !this.verticalGridLines || !this.verticalGridLines.length)
            return result;
        var verticalIndex = search_1.SearchUtils.binaryIndexOf(this.verticalGridLines, function (x) { return x - point.x; });
        if (verticalIndex < 0) {
            verticalIndex = ~verticalIndex;
            if (this.isValidArrayIndex(this.verticalGridLines, verticalIndex))
                result.push(this.createPoint(this.verticalGridLines[verticalIndex], point.y));
        }
        else if (this.isValidArrayIndex(this.verticalGridLines, verticalIndex + 1))
            result.push(this.createPoint(this.verticalGridLines[verticalIndex + 1], point.y));
        if (this.isValidArrayIndex(this.verticalGridLines, verticalIndex - 1))
            result.push(this.createPoint(this.verticalGridLines[verticalIndex - 1], point.y));
        var horizontalIndex = search_1.SearchUtils.binaryIndexOf(this.horizontalGridLines, function (y) { return y - point.y; });
        if (horizontalIndex < 0) {
            horizontalIndex = ~horizontalIndex;
            if (this.isValidArrayIndex(this.horizontalGridLines, horizontalIndex))
                result.push(this.createPoint(point.x, this.horizontalGridLines[horizontalIndex]));
        }
        else if (this.isValidArrayIndex(this.horizontalGridLines, horizontalIndex + 1))
            result.push(this.createPoint(point.x, this.horizontalGridLines[horizontalIndex + 1]));
        if (this.isValidArrayIndex(this.horizontalGridLines, horizontalIndex - 1))
            result.push(this.createPoint(point.x, this.horizontalGridLines[horizontalIndex - 1]));
        return result;
    };
    RoutingGrid.prototype.isValidArrayIndex = function (array, index) {
        return array && index >= 0 && index < array.length;
    };
    return RoutingGrid;
}());
exports.RoutingGrid = RoutingGrid;


/***/ }),
/* 374 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.AStarContext = exports.AStarContextBase = void 0;
var SortedQueues_1 = __webpack_require__(375);
var UniqueAStarNodePositions_1 = __webpack_require__(376);
var AStarNode_1 = __webpack_require__(377);
var segment_1 = __webpack_require__(33);
var RightAngleConnectorRoutingMathOperations_1 = __webpack_require__(160);
var Utils_1 = __webpack_require__(3);
var AStarContextBase = (function () {
    function AStarContextBase(startPosition, targetPosition, maxStepsCount) {
        this.startPosition = startPosition;
        this.targetPosition = targetPosition;
        this.maxStepsCount = maxStepsCount;
        this.prohibitedPoints = {};
    }
    Object.defineProperty(AStarContextBase.prototype, "shouldStartContinue", {
        get: function () {
            return this.updatableSet.count > 0 && this.stepsCount < this.maxStepsCount;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(AStarContextBase.prototype, "shouldFinish", {
        get: function () {
            return this.currentNode.position.equals(this.targetPosition);
        },
        enumerable: false,
        configurable: true
    });
    AStarContextBase.prototype.start = function () {
        this.generalSet = new SortedQueues_1.SortedQueues(function (x) { return x.key; });
        this.updatableSet = new UniqueAStarNodePositions_1.UniqueAStarNodePositions();
        var currentNode = new AStarNode_1.AStarNode(this.startPosition, this.getDistance(this.startPosition, this.targetPosition));
        this.currentNode = currentNode;
        this.generalSet.enqueue(currentNode);
        this.updatableSet.add(currentNode.position, currentNode);
        this.stepsCount = 0;
        this.openNode = undefined;
    };
    AStarContextBase.prototype.startContinue = function () {
        this.currentNode = this.generalSet.dequeueMin();
    };
    AStarContextBase.prototype.endContinue = function () {
        var _this = this;
        var currentPosition = this.currentNode.position;
        this.updatableSet.remove(currentPosition);
        this.addProhibitedPoint(currentPosition);
        this.getNeighborPoints(currentPosition).forEach(function (nextPosition) {
            var penalty = _this.getPenalty(_this.currentNode, nextPosition);
            var openNode = _this.updatableSet.getNode(nextPosition);
            if (openNode === undefined) {
                openNode = new AStarNode_1.AStarNode(nextPosition, _this.getDistance(nextPosition, _this.targetPosition));
                openNode.parent = _this.currentNode;
                openNode.penalty = penalty;
                _this.generalSet.enqueue(openNode);
                _this.updatableSet.add(nextPosition, openNode);
            }
            else if (openNode.penalty > penalty) {
                var generalSet = _this.generalSet;
                generalSet.remove(openNode);
                openNode.parent = _this.currentNode;
                openNode.penalty = penalty;
                generalSet.enqueue(openNode);
            }
            _this.openNode = openNode;
        });
        this.stepsCount++;
    };
    AStarContextBase.prototype.finishWithPath = function () {
        this.path = this.currentNode.getPath();
    };
    AStarContextBase.prototype.finishWithoutPath = function () {
        this.path = [];
    };
    return AStarContextBase;
}());
exports.AStarContextBase = AStarContextBase;
var AStarContext = (function (_super) {
    __extends(AStarContext, _super);
    function AStarContext(routingContext, startPosition, targetPosition, prohibitedSegments, grid, metrics) {
        var _this = _super.call(this, startPosition, targetPosition, 10000) || this;
        _this.routingContext = routingContext;
        _this.startPosition = startPosition;
        _this.targetPosition = targetPosition;
        _this.prohibitedSegments = prohibitedSegments;
        _this.grid = grid;
        _this.metrics = metrics;
        return _this;
    }
    AStarContext.prototype.addProhibitedPoint = function (point) {
        this.prohibitedPoints[point.toString()] = point;
    };
    AStarContext.prototype.getNeighborPoints = function (point) {
        var _this = this;
        return this.grid.getNeighborPoints(point).filter(function (p) { return _this.allowPoint(p); });
    };
    AStarContext.prototype.getDistance = function (startPoint, endPoint) {
        return this.metrics.distance(startPoint, endPoint);
    };
    AStarContext.prototype.getPenalty = function (node, nextPoint) {
        var parent = node.parent;
        var currentPosition = node.position;
        var turnDirection = this.getTurnDirection(parent ? Utils_1.GeometryUtils.createAngle(parent.position, currentPosition, nextPoint) : 0);
        var distance = this.getDistance(currentPosition, nextPoint);
        var middlePosition = new segment_1.Segment(currentPosition, nextPoint).center;
        return node.penalty + this.metrics.penalty(distance, middlePosition, turnDirection, this.getIntersectedItems(middlePosition));
    };
    AStarContext.prototype.allowPoint = function (p) {
        return this.prohibitedPoints[p.toString()] === undefined && (!this.prohibitedSegments || this.prohibitedSegments.allowPoint(p));
    };
    AStarContext.prototype.getTurnDirection = function (angle) {
        return RightAngleConnectorRoutingMathOperations_1.RightAngleConnectorRoutingMathOperations.getTurnDirection(angle);
    };
    AStarContext.prototype.getIntersectedItems = function (position) {
        var _this = this;
        var margin = this.routingContext.shapeMargins;
        return this.routingContext.getIntersectedItems(position, function (p, i) { return _this.hasIntersectedItem(p, i, margin); });
    };
    AStarContext.prototype.hasIntersectedItem = function (point, item, margin) {
        if (!this.isIntersectedWithExtendedRectangle(point, item, margin))
            return false;
        if (this.hasOneShapeConnection(item))
            return true;
        return !this.itemContainsConnectionPoints(item);
    };
    AStarContext.prototype.isIntersectedWithExtendedRectangle = function (point, item, margin) {
        return item.rectangle.clone().inflate(margin).containsPoint(point);
    };
    AStarContext.prototype.itemContainsConnectionPoints = function (item) {
        var rectangle = item.rectangle;
        return rectangle.containsPoint(this.routingContext.beginPoint) && rectangle.containsPoint(this.routingContext.endPoint);
    };
    AStarContext.prototype.hasOneShapeConnection = function (item) {
        var connectionPoints = item.getConnectionPoints();
        return this.isConnectionPoint(connectionPoints, this.routingContext.beginPoint) &&
            this.isConnectionPoint(connectionPoints, this.routingContext.endPoint);
    };
    AStarContext.prototype.isConnectionPoint = function (connectionPoints, point) {
        return connectionPoints.filter(function (p) { return p.equals(point); }).length > 0;
    };
    return AStarContext;
}(AStarContextBase));
exports.AStarContext = AStarContext;


/***/ }),
/* 375 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.SortedQueues = void 0;
var search_1 = __webpack_require__(41);
var SortedQueues = (function () {
    function SortedQueues(getKey) {
        this.getKey = getKey;
        this._itemsArrays = {};
        this._sortedKeys = [];
    }
    Object.defineProperty(SortedQueues.prototype, "sortedKeys", {
        get: function () { return this._sortedKeys; },
        enumerable: false,
        configurable: true
    });
    SortedQueues.prototype.getQueue = function (key) {
        return this._itemsArrays[key];
    };
    SortedQueues.prototype.enqueue = function (item) {
        var key = this.getKey(item);
        if (this._itemsArrays[key] === undefined) {
            this._itemsArrays[key] = [item];
            this.addSortedKey(key);
        }
        else
            this._itemsArrays[key].push(item);
    };
    SortedQueues.prototype.remove = function (item) {
        var key = this.getKey(item);
        var itemsArray = this._itemsArrays[key];
        if (itemsArray !== undefined)
            if (!itemsArray.length)
                this.removeCore(key);
            else if (itemsArray[0] === item) {
                itemsArray.shift();
                if (!itemsArray.length)
                    this.removeCore(key);
            }
            else
                this._itemsArrays[key] = itemsArray.filter(function (x) { return x !== item; });
    };
    SortedQueues.prototype.dequeueMin = function () {
        if (!this._sortedKeys.length)
            return undefined;
        var key = this._sortedKeys[0];
        var itemsArray = this._itemsArrays[key];
        var item = itemsArray.shift();
        if (!itemsArray.length)
            this.removeCore(key);
        return item;
    };
    SortedQueues.prototype.removeCore = function (key) {
        delete this._itemsArrays[key];
        this.removeSortedKey(key);
    };
    SortedQueues.prototype.removeSortedKey = function (key) {
        var sortedPointIndex = search_1.SearchUtils.binaryIndexOf(this._sortedKeys, function (x) { return x - key; });
        if (sortedPointIndex >= 0)
            this.sortedKeys.splice(sortedPointIndex, 1);
    };
    SortedQueues.prototype.addSortedKey = function (key) {
        var sortedPointIndex = search_1.SearchUtils.binaryIndexOf(this._sortedKeys, function (x) { return x - key; });
        if (sortedPointIndex < 0)
            this._sortedKeys.splice(-(sortedPointIndex + 1), 0, key);
    };
    return SortedQueues;
}());
exports.SortedQueues = SortedQueues;


/***/ }),
/* 376 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.UniqueAStarNodePositions = void 0;
var UniqueAStarNodePositions = (function () {
    function UniqueAStarNodePositions(getKey) {
        if (getKey === void 0) { getKey = function (key) { return key.toString(); }; }
        this.getKey = getKey;
        this.items = {};
    }
    Object.defineProperty(UniqueAStarNodePositions.prototype, "count", {
        get: function () { return Object.keys(this.items).length; },
        enumerable: false,
        configurable: true
    });
    UniqueAStarNodePositions.prototype.getNode = function (position) {
        var item = this.items[this.getKey(position)];
        return item !== undefined ? item.node : undefined;
    };
    UniqueAStarNodePositions.prototype.add = function (position, node) {
        var key = this.getKey(position);
        if (this.items[key] === undefined)
            this.items[key] = { position: position, node: node };
    };
    UniqueAStarNodePositions.prototype.remove = function (position) {
        var key = this.getKey(position);
        if (this.items[key] !== undefined)
            delete this.items[key];
    };
    return UniqueAStarNodePositions;
}());
exports.UniqueAStarNodePositions = UniqueAStarNodePositions;


/***/ }),
/* 377 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.AStarNode = void 0;
var AStarNode = (function () {
    function AStarNode(position, distance) {
        this.position = position;
        this.distance = distance;
        this.penalty = 0;
    }
    Object.defineProperty(AStarNode.prototype, "key", {
        get: function () { return this.distance + this.penalty; },
        enumerable: false,
        configurable: true
    });
    AStarNode.prototype.getPath = function () {
        var result = [];
        var currentNode = this;
        while (currentNode !== undefined) {
            result.splice(0, 0, currentNode.position);
            currentNode = currentNode.parent;
        }
        return result;
    };
    return AStarNode;
}());
exports.AStarNode = AStarNode;


/***/ }),
/* 378 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.AStarCalculator = void 0;
var AStarCalculator = (function () {
    function AStarCalculator() {
    }
    AStarCalculator.calculate = function (context) {
        if (context) {
            var callBack = this.start(context);
            while (callBack)
                callBack = callBack(context);
        }
    };
    AStarCalculator.start = function (context) {
        context.start();
        return context.shouldStartContinue ? AStarCalculator.startContinue : AStarCalculator.finishWithPath;
    };
    AStarCalculator.startContinue = function (context) {
        context.startContinue();
        return context.shouldFinish ? AStarCalculator.finishWithPath : AStarCalculator.endContinue;
    };
    AStarCalculator.endContinue = function (context) {
        context.endContinue();
        return context.shouldStartContinue ? AStarCalculator.startContinue : AStarCalculator.finishWithoutPath;
    };
    AStarCalculator.finishWithPath = function (context) {
        context.finishWithPath();
    };
    AStarCalculator.finishWithoutPath = function (context) {
        context.finishWithoutPath();
    };
    return AStarCalculator;
}());
exports.AStarCalculator = AStarCalculator;


/***/ }),
/* 379 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.ReloadContentParameters = void 0;
var ReloadContentParameters = (function () {
    function ReloadContentParameters() {
        this.isEmpty = true;
    }
    ReloadContentParameters.prototype.add = function (dataKey, getData, layoutParameters) {
        if (dataKey !== undefined) {
            if (this._dataKeys === undefined)
                this._dataKeys = [];
            if (Array.isArray(dataKey))
                this._dataKeys = this._dataKeys.concat(dataKey);
            else
                this._dataKeys.push(dataKey);
        }
        this._getData = this._getData || getData;
        this._layoutParameters = this._layoutParameters || layoutParameters;
        this.isEmpty = false;
    };
    ReloadContentParameters.prototype.clear = function () {
        this.isEmpty = true;
        this._dataKeys = undefined;
        this._getData = undefined;
        this._layoutParameters = undefined;
    };
    Object.defineProperty(ReloadContentParameters.prototype, "empty", {
        get: function () { return this.isEmpty; },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(ReloadContentParameters.prototype, "dataKeys", {
        get: function () { return this._dataKeys; },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(ReloadContentParameters.prototype, "getData", {
        get: function () { return this._getData; },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(ReloadContentParameters.prototype, "layoutParameters", {
        get: function () { return this._layoutParameters; },
        enumerable: false,
        configurable: true
    });
    return ReloadContentParameters;
}());
exports.ReloadContentParameters = ReloadContentParameters;


/***/ }),
/* 380 */
/***/ (function(module, exports, __webpack_require__) {

// extracted by mini-css-extract-plugin

/***/ })
/******/ ]);
});