UNPKG

@progress/kendo-ui

Version:

This package is part of the [Kendo UI for jQuery](http://www.telerik.com/kendo-ui) suite.

1,715 lines (1,346 loc) 358 kB
module.exports = /******/ (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] = { /******/ exports: {}, /******/ id: moduleId, /******/ loaded: false /******/ }; /******/ // Execute the module function /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); /******/ // Flag the module as loaded /******/ module.loaded = 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; /******/ // __webpack_public_path__ /******/ __webpack_require__.p = ""; /******/ // Load entry module and return exports /******/ return __webpack_require__(0); /******/ }) /************************************************************************/ /******/ ({ /***/ 0: /***/ (function(module, exports, __webpack_require__) { module.exports = __webpack_require__(955); /***/ }), /***/ 3: /***/ (function(module, exports) { module.exports = function() { throw new Error("define cannot be used indirect"); }; /***/ }), /***/ 955: /***/ (function(module, exports, __webpack_require__) { var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;/*********************************************************************** * WARNING: this file is auto-generated. If you change it directly, * your modifications will eventually be lost. The source code is in * `kendo-drawing` repository, you should make your changes there and * run `src-modules/sync.sh` in this repository. */ (function(f, define) { !(__WEBPACK_AMD_DEFINE_ARRAY__ = [ __webpack_require__(956), __webpack_require__(957), __webpack_require__(958) ], __WEBPACK_AMD_DEFINE_FACTORY__ = (f), __WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ? (__WEBPACK_AMD_DEFINE_FACTORY__.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__)) : __WEBPACK_AMD_DEFINE_FACTORY__), __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)); })(function() { (function($) { /* jshint eqnull:true */ /* jshint -W058 */ /* jshint -W069 */ /* jshint latedef: nofunc */ /* jshint shadow: true */ /* jshint unused: false */ window.kendo = window.kendo || {}; var kendoDrawing = kendo.drawing; var kendoDrawingUtil = kendoDrawing.util; var extendStatic = kendoDrawingUtil.extendStatic; var Class = kendo.Class; var kendoUtil = kendo.util; var support = kendo.support; var supportBrowser = support.browser; var createPromise = kendoDrawingUtil.createPromise; var promiseAll = kendoDrawingUtil.promiseAll; var HasObservers = (function(Class$$1) { function HasObservers() { Class$$1.apply(this, arguments); } extendStatic(HasObservers, Class$$1); HasObservers.prototype = Object.create( Class$$1 && Class$$1.prototype ); HasObservers.prototype.constructor = HasObservers; HasObservers.fn = HasObservers.prototype; HasObservers.fn.init = HasObservers.fn.constructor; HasObservers.prototype.observers = function observers() { this._observers = this._observers || []; return this._observers; }; HasObservers.prototype.addObserver = function addObserver(element) { if (!this._observers) { this._observers = [ element ]; } else { this._observers.push(element); } return this; }; HasObservers.prototype.removeObserver = function removeObserver(element) { var observers = this.observers(); var index = observers.indexOf(element); if (index !== -1) { observers.splice(index, 1); } return this; }; HasObservers.prototype.trigger = function trigger(methodName, event) { var observers = this._observers; if (observers && !this._suspended) { for (var idx = 0; idx < observers.length; idx++) { var observer = observers[idx]; if (observer[methodName]) { observer[methodName](event); } } } return this; }; HasObservers.prototype.optionsChange = function optionsChange(e) { if (e === void 0) { e = {}; } e.element = this; this.trigger("optionsChange", e); }; HasObservers.prototype.geometryChange = function geometryChange() { this.trigger("geometryChange", { element: this }); }; HasObservers.prototype.suspend = function suspend() { this._suspended = (this._suspended || 0) + 1; return this; }; HasObservers.prototype.resume = function resume() { this._suspended = Math.max((this._suspended || 0) - 1, 0); return this; }; HasObservers.prototype._observerField = function _observerField(field, value) { if (this[field]) { this[field].removeObserver(this); } this[field] = value; value.addObserver(this); }; return HasObservers; }(Class)); function append$1$1(first, second) { first.push.apply(first, second); return first; } /* eslint-disable key-spacing,no-multi-spaces,no-param-reassign */ var literals = { 1 : "i", 10 : "x", 100 : "c", 2 : "ii", 20 : "xx", 200 : "cc", 3 : "iii", 30 : "xxx", 300 : "ccc", 4 : "iv", 40 : "xl", 400 : "cd", 5 : "v", 50 : "l", 500 : "d", 6 : "vi", 60 : "lx", 600 : "dc", 7 : "vii", 70 : "lxx", 700 : "dcc", 8 : "viii", 80 : "lxxx", 800 : "dccc", 9 : "ix", 90 : "xc", 900 : "cm", 1000 : "m" }; function arabicToRoman(n) { var values = [ 1000, 900 , 800, 700, 600, 500, 400, 300, 200, 100, 90 , 80 , 70 , 60 , 50 , 40 , 30 , 20 , 10 , 9 , 8 , 7 , 6 , 5 , 4 , 3 , 2 , 1 ]; var roman = ""; while (n > 0) { if (n < values[0]) { values.shift(); } else { roman += literals[values[0]]; n -= values[0]; } } return roman; } var UNDEFINED = "undefined"; function defined(value) { return typeof value !== UNDEFINED; } var defId = 1; function definitionId() { return "kdef" + defId++; } var DEG_TO_RAD = Math.PI / 180; var MAX_NUM = Number.MAX_VALUE; var MIN_NUM = -Number.MAX_VALUE; function deg(radians) { return radians / DEG_TO_RAD; } var fromCharCode = String.fromCharCode; // Encodes a string as UTF-8 function encodeUTF8(input) { var output = ""; for (var i = 0; i < input.length; i++) { var code = input.charCodeAt(i); if (0xD800 <= code && code <= 0xDBFF) { var hi = code; var low = input.charCodeAt(++i); if (!isNaN(low)) { // Combine high and low surrogate // See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/charCodeAt code = (hi - 0xD800) * 0x400 + (low - 0xDC00) + 0x10000; } } if (code < 0x80) { // One byte output += fromCharCode(code); } else if (code < 0x800) { // Two bytes output += fromCharCode(0xC0 | (code >>> 6)); output += fromCharCode(0x80 | (code & 0x3f)); } else if (code < 0x10000) { // Three bytes output += fromCharCode(0xE0 | (code >>> 12)); output += fromCharCode(0x80 | (code >>> 6 & 0x3f)); output += fromCharCode(0x80 | (code & 0x3f)); } else if (code < 0x10FFFF) { // Four bytes output += fromCharCode(0xF0 | (code >>> 18)); output += fromCharCode(0x80 | (code >>> 12 & 0x3f)); output += fromCharCode(0x80 | (code >>> 6 & 0x3f)); output += fromCharCode(0x80 | (code & 0x3f)); } } return output; } // Encodes a string as UTF-16 big-endian var KEY_STR = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="; function encodeBase64(input) { var output = ""; var i = 0; var utfInput = encodeUTF8(input); while (i < utfInput.length) { var chr1 = utfInput.charCodeAt(i++); var chr2 = utfInput.charCodeAt(i++); var chr3 = utfInput.charCodeAt(i++); var enc1 = chr1 >> 2; var enc2 = ((chr1 & 3) << 4) | (chr2 >> 4); var enc3 = ((chr2 & 15) << 2) | (chr3 >> 6); var enc4 = chr3 & 63; if (isNaN(chr2)) { enc3 = enc4 = 64; } else if (isNaN(chr3)) { enc4 = 64; } output = output + KEY_STR.charAt(enc1) + KEY_STR.charAt(enc2) + KEY_STR.charAt(enc3) + KEY_STR.charAt(enc4); } return output; } function eventCoordinates(e) { if (defined((e.x || {}).location)) { return { x: e.x.location, y: e.y.location }; } return { x: e.pageX || e.clientX || 0, y: e.pageY || e.clientY || 0 }; } function eventElement(e) { if (e === void 0) { e = {}; } return e.touch ? e.touch.initialTouch : e.target; } function isTransparent(color) { return color === "" || color === null || color === "none" || color === "transparent" || !defined(color); } function last(array) { if (array) { return array[array.length - 1]; } } function limitValue(value, min, max) { return Math.max(Math.min(value, max), min); } /* eslint-disable no-multi-spaces, key-spacing, indent, camelcase, space-before-blocks, eqeqeq, brace-style */ /* eslint-disable space-infix-ops, space-before-function-paren, array-bracket-spacing, object-curly-spacing */ /* eslint-disable no-nested-ternary, max-params, default-case, no-else-return, no-empty */ /* eslint-disable no-param-reassign, no-var, block-scoped-var */ // mergeSort is stable. function mergeSort(a, cmp) { if (a.length < 2) { return a.slice(); } function merge(a, b) { var r = [], ai = 0, bi = 0, i = 0; while (ai < a.length && bi < b.length) { if (cmp(a[ai], b[bi]) <= 0) { r[i++] = a[ai++]; } else { r[i++] = b[bi++]; } } if (ai < a.length) { r.push.apply(r, a.slice(ai)); } if (bi < b.length) { r.push.apply(r, b.slice(bi)); } return r; } return (function sort(a) { if (a.length <= 1) { return a; } var m = Math.floor(a.length / 2); var left = a.slice(0, m); var right = a.slice(m); left = sort(left); right = sort(right); return merge(left, right); })(a); } var now = Date.now || function() { return new Date().getTime(); }; function rad(degrees) { return degrees * DEG_TO_RAD; } function pow(p) { if (p) { return Math.pow(10, p); } return 1; } function round(value, precision) { var power = pow(precision); return Math.round(value * power) / power; } function valueOrDefault(value, defaultValue) { return defined(value) ? value : defaultValue; } function bindEvents(element, events) { for (var eventName in events) { var eventNames = eventName.trim().split(" "); for (var idx = 0; idx < eventNames.length; idx++) { element.addEventListener(eventNames[idx], events[eventName], false); } } } function elementOffset(element) { var box = element.getBoundingClientRect(); var documentElement = document.documentElement; return { top: box.top + (window.pageYOffset || documentElement.scrollTop) - (documentElement.clientTop || 0), left: box.left + (window.pageXOffset || documentElement.scrollLeft) - (documentElement.clientLeft || 0) }; } function elementStyles(element, styles) { var result = {}; var style = window.getComputedStyle(element) || {}; var stylesArray = Array.isArray(styles) ? styles : [ styles ]; for (var idx = 0; idx < stylesArray.length; idx++) { var field = stylesArray[idx]; result[field] = style[field]; } return result; } function getPixels(value) { if (isNaN(value)) { return value; } return value + "px"; } function elementSize(element, size) { if (size) { var width = size.width; var height = size.height; if (defined(width)) { element.style.width = getPixels(width); } if (defined(height)) { element.style.height = getPixels(height); } } else { var size$1 = elementStyles(element, [ 'width', 'height' ]); return { width: parseInt(size$1.width, 10), height: parseInt(size$1.height, 10) }; } } function unbindEvents(element, events) { if (events === void 0) { events = {}; } for (var name in events) { var eventNames = name.trim().split(" "); for (var idx = 0; idx < eventNames.length; idx++) { element.removeEventListener(eventNames[idx], events[name], false); } } } function elementPadding(element) { var ref = elementStyles(element, [ "paddingLeft", "paddingTop" ]); var paddingLeft = ref.paddingLeft; var paddingTop = ref.paddingTop; return { top: parseFloat(paddingTop), left: parseFloat(paddingLeft) }; } var Matrix = (function (Class$$1) { function Matrix(a, b, c, d, e, f) { if (a === void 0) { a = 0; } if (b === void 0) { b = 0; } if (c === void 0) { c = 0; } if (d === void 0) { d = 0; } if (e === void 0) { e = 0; } if (f === void 0) { f = 0; } Class$$1.call(this); this.a = a; this.b = b; this.c = c; this.d = d; this.e = e; this.f = f; } extendStatic(Matrix, Class$$1); Matrix.prototype = Object.create( Class$$1 && Class$$1.prototype ); Matrix.prototype.constructor = Matrix; Matrix.fn = Matrix.prototype; Matrix.fn.init = Matrix.fn.constructor; Matrix.prototype.multiplyCopy = function multiplyCopy (matrix) { return new Matrix( this.a * matrix.a + this.c * matrix.b, this.b * matrix.a + this.d * matrix.b, this.a * matrix.c + this.c * matrix.d, this.b * matrix.c + this.d * matrix.d, this.a * matrix.e + this.c * matrix.f + this.e, this.b * matrix.e + this.d * matrix.f + this.f ); }; Matrix.prototype.invert = function invert () { var ref = this; var a = ref.a; var b = ref.b; var d = ref.c; var e = ref.d; var g = ref.e; var h = ref.f; var det = a * e - b * d; if (det === 0) { return null; } return new Matrix(e / det, -b / det, -d / det, a / det, (d * h - e * g) / det, (b * g - a * h) / det); }; Matrix.prototype.clone = function clone () { return new Matrix(this.a, this.b, this.c, this.d, this.e, this.f); }; Matrix.prototype.equals = function equals (other) { if (!other) { return false; } return this.a === other.a && this.b === other.b && this.c === other.c && this.d === other.d && this.e === other.e && this.f === other.f; }; Matrix.prototype.round = function round$1 (precision) { this.a = round(this.a, precision); this.b = round(this.b, precision); this.c = round(this.c, precision); this.d = round(this.d, precision); this.e = round(this.e, precision); this.f = round(this.f, precision); return this; }; Matrix.prototype.toArray = function toArray (precision) { var result = [ this.a, this.b, this.c, this.d, this.e, this.f ]; if (defined(precision)) { for (var i = 0; i < result.length; i++) { result[i] = round(result[i], precision); } } return result; }; Matrix.prototype.toString = function toString (precision, separator) { if (separator === void 0) { separator = ","; } return this.toArray(precision).join(separator); }; Matrix.translate = function translate (x, y) { return new Matrix(1, 0, 0, 1, x, y); }; Matrix.unit = function unit () { return new Matrix(1, 0, 0, 1, 0, 0); }; Matrix.rotate = function rotate (angle, x, y) { var matrix = new Matrix(); matrix.a = Math.cos(rad(angle)); matrix.b = Math.sin(rad(angle)); matrix.c = -matrix.b; matrix.d = matrix.a; matrix.e = (x - x * matrix.a + y * matrix.b) || 0; matrix.f = (y - y * matrix.a - x * matrix.b) || 0; return matrix; }; Matrix.scale = function scale (scaleX, scaleY) { return new Matrix(scaleX, 0, 0, scaleY, 0, 0); }; return Matrix; }(Class)); Matrix.IDENTITY = Matrix.unit(); var matrixRegexp = /matrix\((.*)\)/; function parseMatrix(matrixString) { var match = matrixString.match(matrixRegexp); if (match === null || match.length !== 2) { return Matrix.unit(); } var members = match[1].split(',').map(function (x) { return parseFloat(x); }); return new (Function.prototype.bind.apply( Matrix, [ null ].concat( members) )); } function transformMatrix(element) { var transform = getComputedStyle(element).transform; if (transform === 'none') { return Matrix.unit(); } return parseMatrix(transform); } function elementScale(element) { if (!element) { return Matrix.unit(); } var matrix = transformMatrix(element); var parent = element.parentElement; while (parent) { var parentMatrix = transformMatrix(parent); matrix = matrix.multiplyCopy(parentMatrix); parent = parent.parentElement; } matrix.b = matrix.c = matrix.e = matrix.f = 0; return matrix; } var util = { append: append$1$1, arabicToRoman: arabicToRoman, createPromise: createPromise, defined: defined, definitionId: definitionId, deg: deg, encodeBase64: encodeBase64, eventCoordinates: eventCoordinates, eventElement: eventElement, isTransparent: isTransparent, last: last, limitValue: limitValue, mergeSort: mergeSort, now: now, promiseAll: promiseAll, rad: rad, round: round, valueOrDefault: valueOrDefault, bindEvents: bindEvents, elementOffset: elementOffset, elementSize: elementSize, elementStyles: elementStyles, unbindEvents: unbindEvents, elementPadding: elementPadding, elementScale: elementScale, DEG_TO_RAD: DEG_TO_RAD, MAX_NUM: MAX_NUM, MIN_NUM: MIN_NUM }; var toString$1 = {}.toString; var OptionsStore = (function (HasObservers$$1) { function OptionsStore(options, prefix) { var this$1 = this; if (prefix === void 0) { prefix = ""; } HasObservers$$1.call(this); this.prefix = prefix; for (var field in options) { var member = options[field]; member = this$1._wrap(member, field); this$1[field] = member; } } extendStatic(OptionsStore, HasObservers$$1); OptionsStore.prototype = Object.create( HasObservers$$1 && HasObservers$$1.prototype ); OptionsStore.prototype.constructor = OptionsStore; OptionsStore.fn = OptionsStore.prototype; OptionsStore.fn.init = OptionsStore.fn.constructor; OptionsStore.prototype.get = function get (field) { var parts = field.split("."); var result = this; while (parts.length && result) { var part = parts.shift(); result = result[part]; } return result; }; OptionsStore.prototype.set = function set (field, value) { var current = this.get(field); if (current !== value) { this._set(field, this._wrap(value, field)); this.optionsChange({ field: this.prefix + field, value: value }); } }; OptionsStore.prototype._set = function _set (field, value) { var this$1 = this; var composite = field.indexOf(".") >= 0; var parentObj = this; var fieldName = field; if (composite) { var parts = fieldName.split("."); var prefix = this.prefix; while (parts.length > 1) { fieldName = parts.shift(); prefix += fieldName + "."; var obj = parentObj[fieldName]; if (!obj) { obj = new OptionsStore({}, prefix); obj.addObserver(this$1); parentObj[fieldName] = obj; } parentObj = obj; } fieldName = parts[0]; } parentObj._clear(fieldName); parentObj[fieldName] = value; }; OptionsStore.prototype._clear = function _clear (field) { var current = this[field]; if (current && current.removeObserver) { current.removeObserver(this); } }; OptionsStore.prototype._wrap = function _wrap (object, field) { var type = toString$1.call(object); var wrapped = object; if (wrapped !== null && defined(wrapped) && type === "[object Object]") { if (!(object instanceof OptionsStore) && !(object instanceof Class)) { wrapped = new OptionsStore(wrapped, this.prefix + field + "."); } wrapped.addObserver(this); } return wrapped; }; return OptionsStore; }(HasObservers)); function setAccessor(field) { return function(value) { if (this[field] !== value) { this[field] = value; this.geometryChange(); } return this; }; } function getAccessor(field) { return function() { return this[field]; }; } function defineAccessors(fn, fields) { for (var i = 0; i < fields.length; i++) { var name = fields[i]; var capitalized = name.charAt(0).toUpperCase() + name.substring(1, name.length); fn["set" + capitalized] = setAccessor(name); fn["get" + capitalized] = getAccessor(name); } } var withAccessors = function (TBase, names) { var result = (function (TBase) { function result () { TBase.apply(this, arguments); }extendStatic(result, TBase); result.prototype = Object.create( TBase && TBase.prototype ); result.prototype.constructor = result; result.fn = result.prototype; result.fn.init = result.fn.constructor; return result; }(TBase)); defineAccessors(result.prototype, names); return result; }; function toMatrix(transformation) { if (transformation && typeof transformation.matrix === "function") { return transformation.matrix(); } return transformation; } var Point = (function (superclass) { function Point(x, y) { superclass.call(this); this.x = x || 0; this.y = y || 0; } extendStatic(Point, superclass); Point.prototype = Object.create( superclass && superclass.prototype ); Point.prototype.constructor = Point; Point.fn = Point.prototype; Point.fn.init = Point.fn.constructor; var staticAccessors = { ZERO: {} }; Point.prototype.equals = function equals (other) { return other && other.x === this.x && other.y === this.y; }; Point.prototype.clone = function clone () { return new Point(this.x, this.y); }; Point.prototype.rotate = function rotate (angle, origin) { var originPoint = Point.create(origin) || Point.ZERO; return this.transform(Matrix.rotate(angle, originPoint.x, originPoint.y)); }; Point.prototype.translate = function translate (x, y) { this.x += x; this.y += y; this.geometryChange(); return this; }; Point.prototype.translateWith = function translateWith (point) { return this.translate(point.x, point.y); }; Point.prototype.move = function move (x, y) { this.x = this.y = 0; return this.translate(x, y); }; Point.prototype.scale = function scale (scaleX, scaleY) { if (scaleY === void 0) { scaleY = scaleX; } this.x *= scaleX; this.y *= scaleY; this.geometryChange(); return this; }; Point.prototype.scaleCopy = function scaleCopy (scaleX, scaleY) { return this.clone().scale(scaleX, scaleY); }; Point.prototype.transform = function transform (transformation) { var matrix = toMatrix(transformation); var ref = this; var x = ref.x; var y = ref.y; this.x = matrix.a * x + matrix.c * y + matrix.e; this.y = matrix.b * x + matrix.d * y + matrix.f; this.geometryChange(); return this; }; Point.prototype.transformCopy = function transformCopy (transformation) { var point = this.clone(); if (transformation) { point.transform(transformation); } return point; }; Point.prototype.distanceTo = function distanceTo (point) { var dx = this.x - point.x; var dy = this.y - point.y; return Math.sqrt(dx * dx + dy * dy); }; Point.prototype.round = function round$1 (digits) { this.x = round(this.x, digits); this.y = round(this.y, digits); this.geometryChange(); return this; }; Point.prototype.toArray = function toArray (digits) { var doRound = defined(digits); var x = doRound ? round(this.x, digits) : this.x; var y = doRound ? round(this.y, digits) : this.y; return [ x, y ]; }; Point.prototype.toString = function toString (digits, separator) { if (separator === void 0) { separator = " "; } var ref = this; var x = ref.x; var y = ref.y; if (defined(digits)) { x = round(x, digits); y = round(y, digits); } return x + separator + y; }; Point.create = function create (arg0, arg1) { if (defined(arg0)) { if (arg0 instanceof Point) { return arg0; } else if (arguments.length === 1 && arg0.length === 2) { return new Point(arg0[0], arg0[1]); } return new Point(arg0, arg1); } }; Point.min = function min () { var arguments$1 = arguments; var minX = MAX_NUM; var minY = MAX_NUM; for (var i = 0; i < arguments.length; i++) { var point = arguments$1[i]; minX = Math.min(point.x, minX); minY = Math.min(point.y, minY); } return new Point(minX, minY); }; Point.max = function max () { var arguments$1 = arguments; var maxX = MIN_NUM; var maxY = MIN_NUM; for (var i = 0; i < arguments.length; i++) { var point = arguments$1[i]; maxX = Math.max(point.x, maxX); maxY = Math.max(point.y, maxY); } return new Point(maxX, maxY); }; Point.minPoint = function minPoint () { return new Point(MIN_NUM, MIN_NUM); }; Point.maxPoint = function maxPoint () { return new Point(MAX_NUM, MAX_NUM); }; staticAccessors.ZERO.get = function () { return new Point(0, 0); }; Object.defineProperties( Point, staticAccessors ); return Point; }(withAccessors(HasObservers, [ "x", "y" ]))); var Size = (function (superclass) { function Size(width, height) { superclass.call(this); this.width = width || 0; this.height = height || 0; } extendStatic(Size, superclass); Size.prototype = Object.create( superclass && superclass.prototype ); Size.prototype.constructor = Size; Size.fn = Size.prototype; Size.fn.init = Size.fn.constructor; var staticAccessors = { ZERO: {} }; Size.prototype.equals = function equals (other) { return other && other.width === this.width && other.height === this.height; }; Size.prototype.clone = function clone () { return new Size(this.width, this.height); }; Size.prototype.toArray = function toArray (digits) { var doRound = defined(digits); var width = doRound ? round(this.width, digits) : this.width; var height = doRound ? round(this.height, digits) : this.height; return [ width, height ]; }; Size.create = function create (arg0, arg1) { if (defined(arg0)) { if (arg0 instanceof Size) { return arg0; } else if (arguments.length === 1 && arg0.length === 2) { return new Size(arg0[0], arg0[1]); } return new Size(arg0, arg1); } }; staticAccessors.ZERO.get = function () { return new Size(0, 0); }; Object.defineProperties( Size, staticAccessors ); return Size; }(withAccessors(HasObservers, [ "width", "height" ]))); var Rect = (function (HasObservers$$1) { function Rect(origin, size, cornerRadius) { if (origin === void 0) { origin = new Point(); } if (size === void 0) { size = new Size(); } if (cornerRadius === void 0) { cornerRadius = 0; } HasObservers$$1.call(this); this.setOrigin(origin); this.setSize(size); this.setCornerRadius(cornerRadius); } extendStatic(Rect, HasObservers$$1); Rect.prototype = Object.create( HasObservers$$1 && HasObservers$$1.prototype ); Rect.prototype.constructor = Rect; Rect.fn = Rect.prototype; Rect.fn.init = Rect.fn.constructor; Rect.prototype.clone = function clone () { return new Rect( this.origin.clone(), this.size.clone() ); }; Rect.prototype.equals = function equals (other) { return other && other.origin.equals(this.origin) && other.size.equals(this.size); }; Rect.prototype.setOrigin = function setOrigin (value) { this._observerField("origin", Point.create(value)); this.geometryChange(); return this; }; Rect.prototype.getOrigin = function getOrigin () { return this.origin; }; Rect.prototype.setCornerRadius = function setCornerRadius (radius) { this.cornerRadius = Array.isArray(radius) ? radius : [ radius, radius ]; this.geometryChange(); return this; }; Rect.prototype.getCornerRadius = function getCornerRadius () { return this.cornerRadius; }; Rect.prototype.setSize = function setSize (value) { this._observerField("size", Size.create(value)); this.geometryChange(); return this; }; Rect.prototype.getSize = function getSize () { return this.size; }; Rect.prototype.width = function width () { return this.size.width; }; Rect.prototype.height = function height () { return this.size.height; }; Rect.prototype.topLeft = function topLeft () { return this.origin.clone(); }; Rect.prototype.bottomRight = function bottomRight () { return this.origin.clone().translate(this.width(), this.height()); }; Rect.prototype.topRight = function topRight () { return this.origin.clone().translate(this.width(), 0); }; Rect.prototype.bottomLeft = function bottomLeft () { return this.origin.clone().translate(0, this.height()); }; Rect.prototype.center = function center () { return this.origin.clone().translate(this.width() / 2, this.height() / 2); }; Rect.prototype.bbox = function bbox (matrix) { var tl = this.topLeft().transformCopy(matrix); var tr = this.topRight().transformCopy(matrix); var br = this.bottomRight().transformCopy(matrix); var bl = this.bottomLeft().transformCopy(matrix); return Rect.fromPoints(tl, tr, br, bl); }; Rect.prototype.transformCopy = function transformCopy (m) { return Rect.fromPoints( this.topLeft().transform(m), this.bottomRight().transform(m) ); }; Rect.prototype.expand = function expand (x, y) { if (y === void 0) { y = x; } this.size.width += 2 * x; this.size.height += 2 * y; this.origin.translate(-x, -y); return this; }; Rect.prototype.expandCopy = function expandCopy (x, y) { return this.clone().expand(x, y); }; Rect.prototype.containsPoint = function containsPoint (point) { var origin = this.origin; var bottomRight = this.bottomRight(); return !(point.x < origin.x || point.y < origin.y || bottomRight.x < point.x || bottomRight.y < point.y); }; Rect.prototype._isOnPath = function _isOnPath (point, width) { var rectOuter = this.expandCopy(width, width); var rectInner = this.expandCopy(-width, -width); return rectOuter.containsPoint(point) && !rectInner.containsPoint(point); }; Rect.fromPoints = function fromPoints () { var topLeft = Point.min.apply(null, arguments); var bottomRight = Point.max.apply(null, arguments); var size = new Size( bottomRight.x - topLeft.x, bottomRight.y - topLeft.y ); return new Rect(topLeft, size); }; Rect.union = function union (a, b) { return Rect.fromPoints( Point.min(a.topLeft(), b.topLeft()), Point.max(a.bottomRight(), b.bottomRight()) ); }; Rect.intersect = function intersect (a, b) { var rect1 = { left: a.topLeft().x, top: a.topLeft().y, right: a.bottomRight().x, bottom: a.bottomRight().y }; var rect2 = { left: b.topLeft().x, top: b.topLeft().y, right: b.bottomRight().x, bottom: b.bottomRight().y }; if (rect1.left <= rect2.right && rect2.left <= rect1.right && rect1.top <= rect2.bottom && rect2.top <= rect1.bottom) { return Rect.fromPoints( new Point(Math.max(rect1.left, rect2.left), Math.max(rect1.top, rect2.top)), new Point(Math.min(rect1.right, rect2.right), Math.min(rect1.bottom, rect2.bottom)) ); } }; return Rect; }(HasObservers)); var Transformation = (function (HasObservers$$1) { function Transformation(matrix) { if (matrix === void 0) { matrix = Matrix.unit(); } HasObservers$$1.call(this); this._matrix = matrix; } extendStatic(Transformation, HasObservers$$1); Transformation.prototype = Object.create( HasObservers$$1 && HasObservers$$1.prototype ); Transformation.prototype.constructor = Transformation; Transformation.fn = Transformation.prototype; Transformation.fn.init = Transformation.fn.constructor; Transformation.prototype.clone = function clone () { return new Transformation( this._matrix.clone() ); }; Transformation.prototype.equals = function equals (other) { return other && other._matrix.equals(this._matrix); }; Transformation.prototype.translate = function translate (x, y) { this._matrix = this._matrix.multiplyCopy(Matrix.translate(x, y)); this._optionsChange(); return this; }; Transformation.prototype.scale = function scale (scaleX, scaleY, origin) { if (scaleY === void 0) { scaleY = scaleX; } if (origin === void 0) { origin = null; } var originPoint = origin; if (originPoint) { originPoint = Point.create(originPoint); this._matrix = this._matrix.multiplyCopy(Matrix.translate(originPoint.x, originPoint.y)); } this._matrix = this._matrix.multiplyCopy(Matrix.scale(scaleX, scaleY)); if (originPoint) { this._matrix = this._matrix.multiplyCopy(Matrix.translate(-originPoint.x, -originPoint.y)); } this._optionsChange(); return this; }; Transformation.prototype.rotate = function rotate (angle, origin) { var originPoint = Point.create(origin) || Point.ZERO; this._matrix = this._matrix.multiplyCopy(Matrix.rotate(angle, originPoint.x, originPoint.y)); this._optionsChange(); return this; }; Transformation.prototype.multiply = function multiply (transformation) { var matrix = toMatrix(transformation); this._matrix = this._matrix.multiplyCopy(matrix); this._optionsChange(); return this; }; Transformation.prototype.matrix = function matrix (value) { if (value) { this._matrix = value; this._optionsChange(); return this; } return this._matrix; }; Transformation.prototype._optionsChange = function _optionsChange () { this.optionsChange({ field: "transform", value: this }); }; return Transformation; }(HasObservers)); function transform$1(matrix) { if (matrix === null) { return null; } if (matrix instanceof Transformation) { return matrix; } return new Transformation(matrix); } var Element$1 = (function (HasObservers$$1) { function Element(options) { HasObservers$$1.call(this); this._initOptions(options); } extendStatic(Element, HasObservers$$1); Element.prototype = Object.create( HasObservers$$1 && HasObservers$$1.prototype ); Element.prototype.constructor = Element; Element.fn = Element.prototype; Element.fn.init = Element.fn.constructor; var prototypeAccessors = { nodeType: {} }; prototypeAccessors.nodeType.get = function () { return "Rect"; }; Element.prototype._initOptions = function _initOptions (options) { if (options === void 0) { options = {}; } var clip = options.clip; var transform = options.transform; if (transform) { options.transform = transform$1(transform); } if (clip && !clip.id) { clip.id = definitionId(); } this.options = new OptionsStore(options); this.options.addObserver(this); }; Element.prototype.transform = function transform (value) { if (defined(value)) { this.options.set("transform", transform$1(value)); } else { return this.options.get("transform"); } }; Element.prototype.parentTransform = function parentTransform () { var element = this; var parentMatrix; while (element.parent) { element = element.parent; var transformation = element.transform(); if (transformation) { parentMatrix = transformation.matrix().multiplyCopy(parentMatrix || Matrix.unit()); } } if (parentMatrix) { return transform$1(parentMatrix); } }; Element.prototype.currentTransform = function currentTransform (parentTransform) { if (parentTransform === void 0) { parentTransform = this.parentTransform(); } var elementTransform = this.transform(); var elementMatrix = toMatrix(elementTransform); var parentMatrix = toMatrix(parentTransform); var combinedMatrix; if (elementMatrix && parentMatrix) { combinedMatrix = parentMatrix.multiplyCopy(elementMatrix); } else { combinedMatrix = elementMatrix || parentMatrix; } if (combinedMatrix) { return transform$1(combinedMatrix); } }; Element.prototype.visible = function visible (value) { if (defined(value)) { this.options.set("visible", value); return this; } return this.options.get("visible") !== false; }; Element.prototype.clip = function clip (value) { var options = this.options; if (defined(value)) { if (value && !value.id) { value.id = definitionId(); } options.set("clip", value); return this; } return options.get("clip"); }; Element.prototype.opacity = function opacity (value) { if (defined(value)) { this.options.set("opacity", value); return this; } return valueOrDefault(this.options.get("opacity"), 1); }; Element.prototype.clippedBBox = function clippedBBox (transformation) { var bbox = this._clippedBBox(transformation); if (bbox) { var clip = this.clip(); return clip ? Rect.intersect(bbox, clip.bbox(transformation)) : bbox; } }; Element.prototype.containsPoint = function containsPoint (point, parentTransform) { if (this.visible()) { var transform = this.currentTransform(parentTransform); var transformedPoint = point; if (transform) { transformedPoint = point.transformCopy(transform.matrix().invert()); } return (this._hasFill() && this._containsPoint(transformedPoint)) || (this._isOnPath && this._hasStroke() && this._isOnPath(transformedPoint)); } return false; }; Element.prototype._hasFill = function _hasFill () { var fill = this.options.fill; return fill && !isTransparent(fill.color); }; Element.prototype._hasStroke = function _hasStroke () { var stroke = this.options.stroke; return stroke && stroke.width > 0 && !isTransparent(stroke.color); }; Element.prototype._clippedBBox = function _clippedBBox (transformation) { return this.bbox(transformation); }; Object.defineProperties( Element.prototype, prototypeAccessors ); return Element; }(HasObservers)); function ellipseExtremeAngles(center, rx, ry, matrix) { var extremeX = 0; var extremeY = 0; if (matrix) { extremeX = Math.atan2(matrix.c * ry, matrix.a * rx); if (matrix.b !== 0) { extremeY = Math.atan2(matrix.d * ry, matrix.b * rx); } } return { x: extremeX, y: extremeY }; } var PI_DIV_2 = Math.PI / 2; var Circle$2 = (function (superclass) { function Circle(center, radius) { if (center === void 0) { center = new Point(); } if (radius === void 0) { radius = 0; } superclass.call(this); this.setCenter(center); this.setRadius(radius); } extendStatic(Circle, superclass); Circle.prototype = Object.create( superclass && superclass.prototype ); Circle.prototype.constructor = Circle; Circle.fn = Circle.prototype; Circle.fn.init = Circle.fn.constructor; Circle.prototype.setCenter = function setCenter (value) { this._observerField("center", Point.create(value)); this.geometryChange(); return this; }; Circle.prototype.getCenter = function getCenter () { return this.center; }; Circle.prototype.equals = function equals (other) { return other && other.center.equals(this.center) && other.radius === this.radius; }; Circle.prototype.clone = function clone () { return new Circle(this.center.clone(), this.radius); }; Circle.prototype.pointAt = function pointAt (angle) { return this._pointAt(rad(angle)); }; Circle.prototype.bbox = function bbox (matrix) { var this$1 = this; var extremeAngles = ellipseExtremeAngles(this.center, this.radius, this.radius, matrix); var minPoint = Point.maxPoint(); var maxPoint = Point.minPoint(); for (var i = 0; i < 4; i++) { var currentPointX = this$1._pointAt(extremeAngles.x + i * PI_DIV_2).transformCopy(matrix); var currentPointY = this$1._pointAt(extremeAngles.y + i * PI_DIV_2).transformCopy(matrix); var currentPoint = new Point(currentPointX.x, currentPointY.y); minPoint = Point.min(minPoint, currentPoint); maxPoint = Point.max(maxPoint, currentPoint); } return Rect.fromPoints(minPoint, maxPoint); }; Circle.prototype._pointAt = function _pointAt (angle) { var ref = this; var center = ref.center; var radius = ref.radius; return new Point( center.x + radius * Math.cos(angle), center.y + radius * Math.sin(angle) ); }; Circle.prototype.containsPoint = function containsPoint (point) { var ref = this; var center = ref.center; var radius = ref.radius; var inCircle = Math.pow(point.x - center.x, 2) + Math.pow(point.y - center.y, 2) <= Math.pow(radius, 2); return inCircle; }; Circle.prototype._isOnPath = function _isOnPath (point, width) { var ref = this; var center = ref.center; var radius = ref.radius; var pointDistance = center.distanceTo(point); return radius - width <= pointDistance && pointDistance <= radius + width; }; return Circle; }(withAccessors(HasObservers, [ "radius" ]))); var GRADIENT = "Gradient"; var paintable = function (TBase) { return ( (function (TBase) { function anonymous () { TBase.apply(this, arguments); } extendStatic(anonymous, TBase); anonymous.prototype = Object.create( TBase && TBase.prototype ); anonymous.prototype.constructor = anonymous; anonymous.fn = anonymous.prototype; anonymous.fn.init = anonymous.fn.constructor; anonymous.prototype.fill = function fill (color, opacity) { var options = this.options; if (defined(color)) { if (color && color.nodeType !== GRADIENT) { var newFill = { color: color }; if (defined(opacity)) { newFill.opacity = opacity; } options.set("fill", newFill); } else { options.set("fill", color); } return this; } return options.get("fill"); }; anonymous.prototype.stroke = function stroke (color, width, opacity) { if (defined(color)) { this.options.set("stroke.color", color); if (defined(width)) { this.options.set("stroke.width", width); } if (defined(opacity)) { this.options.set("stroke.opacity", opacity); } return this; } return this.options.get("stroke"); }; return anonymous; }(TBase)) ); }; var IDENTITY_MATRIX_HASH = Matrix.IDENTITY.toString(); var measurable = function (TBase) { return ( (function (TBase) { function anonymous () { TBase.apply(this, arguments); } extendStatic(anonymous, TBase); anonymous.prototype = Object.create( TBase && TBase.prototype ); anonymous.prototype.constructor = anonymous; anonymous.fn = anonymous.prototype; anonymous.fn.init = anonymous.fn.constructor; anonymous.prototype.bbox = function bbox (transformation) { var combinedMatrix = toMatrix(this.currentTransform(transformation)); var matrixHash = combinedMatrix ? combinedMatrix.toString() : IDENTITY_MATRIX_HASH; var bbox; if