{"version":3,"file":"deloitte.vca.blazor.js.flows.bundle.js","mappings":";2BACA,IAAIA,EAAsB,CCA1BA,EAAwB,CAACC,EAASC,KACjC,IAAI,IAAIC,KAAOD,EACXF,EAAoBI,EAAEF,EAAYC,KAASH,EAAoBI,EAAEH,EAASE,IAC5EE,OAAOC,eAAeL,EAASE,EAAK,CAAEI,YAAY,EAAMC,IAAKN,EAAWC,IAE1E,ECNDH,EAAwB,CAACS,EAAKC,IAAUL,OAAOM,UAAUC,eAAeC,KAAKJ,EAAKC,GCClFV,EAAyBC,IACH,oBAAXa,QAA0BA,OAAOC,aAC1CV,OAAOC,eAAeL,EAASa,OAAOC,YAAa,CAAEC,MAAO,WAE7DX,OAAOC,eAAeL,EAAS,aAAc,CAAEe,OAAO,GAAO,6hGCD9D,MAAMC,EAAU,qBACVC,EAAW,iBACXC,EAAU,mBACVC,EAAU,gBACVC,EAAW,iBACXC,EAAU,oBACVC,EAAS,eACTC,EAAY,kBAEZC,EAAY,kBACZC,EAAY,kBACZC,EAAS,eACTC,EAAY,kBACZC,EAAY,kBAEZC,EAAa,mBACbC,EAAiB,uBACjBC,EAAc,oBACdC,EAAa,wBACbC,EAAa,wBACbC,EAAU,qBACVC,EAAW,sBACXC,EAAW,sBACXC,EAAW,sBACXC,EAAkB,6BAClBC,EAAY,uBACZC,EAAY,uBAEZC,EAAiB,CACnB,CAACzB,IAAU,EACX,CAACC,IAAW,EACZ,CAACa,IAAiB,EAClB,CAACC,IAAc,EACf,CAACb,IAAU,EACX,CAACC,IAAU,EACX,CAACa,IAAa,EACd,CAACC,IAAa,EACd,CAACC,IAAU,EACX,CAACC,IAAW,EACZ,CAACC,IAAW,EACZ,CAACd,IAAS,EACV,CAACC,IAAY,EACb,CAACC,IAAY,EACb,CAACC,IAAY,EACb,CAACC,IAAS,EACV,CAACC,IAAY,EACb,CAACC,IAAY,EACb,CAACS,IAAW,EACZ,CAACC,IAAkB,EACnB,CAACC,IAAY,EACb,CAACC,IAAY,EACb,CAAC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I,cA7HjG,cAA4B,GACxB,QAAAthI,GACI,OAAO,GAAwB,CAC3B1O,KAAM,gBACN6mD,MAAO,UACP9lB,MAAO,CACH1e,KAAM,CACF0wC,OAAQ,UACR8Y,YAAa,EACbqC,aAAc,CACVvpD,EAAG,wBAIfgkD,OAAQ,CAAC,CACL5nC,MAAO,CACHjd,KAAM,CACF7E,IAAK,OACLZ,MAAO,aACPC,OAAQ,aACRtC,EAAG,YACHH,EAAG,YACHk3C,OAAQ,UACR6Y,OAAQ,WAEZ5lC,KAAM,CACF61B,WAAY,SACZv1B,mBAAoB,SACpByhC,KAAM,QACNvlC,SAAU,GACV6sG,WAAY,0BACZC,WAAY,OACZtpG,KAAM,kBAInB,GAA2B7sC,UAAUuV,SAC5C,GAwF4GuhI,cArFhH,cAA4B,GACxB,QAAAvhI,GACI,OAAO,GAAwB,CAC3B1O,KAAM,gBACN6mD,MAAO,UACP9lB,MAAO,CACH1e,KAAM,CACF0wC,OAAQ,UACR8Y,YAAa,EACbqC,aAAc,CACVvpD,EAAG,sBAEP2pD,aAAc,CACV3pD,EAAG,wBAIfgkD,OAAQ,CAAC,CACL5nC,MAAO,CACHjd,KAAM,CACF7E,IAAK,OACLZ,MAAO,aACPC,OAAQ,aACRtC,EAAG,YACHH,EAAG,YACHk3C,OAAQ,UACR6Y,OAAQ,WAEZ5lC,KAAM,CACF61B,WAAY,SACZv1B,mBAAoB,SACpByhC,KAAM,QACNvlC,SAAU,GACV6sG,WAAY,0BACZC,WAAY,OACZtpG,KAAM,iBAInB,GAA2B7sC,UAAUuV,SAC5C,GA6C2Hk4H","sources":["webpack://vca/webpack/bootstrap","webpack://vca/webpack/runtime/define property getters","webpack://vca/webpack/runtime/hasOwnProperty shorthand","webpack://vca/webpack/runtime/make namespace object","webpack://vca/./node_modules/@joint/core/src/util/utilHelpers.mjs","webpack://vca/./node_modules/@joint/core/src/mvc/Data.mjs","webpack://vca/./node_modules/@joint/core/src/mvc/Dom/vars.mjs","webpack://vca/./node_modules/@joint/core/src/mvc/Dom/Event.mjs","webpack://vca/./node_modules/@joint/core/src/mvc/Dom/Dom.mjs","webpack://vca/./node_modules/@joint/core/src/g/geometry.helpers.mjs","webpack://vca/./node_modules/@joint/core/src/g/line.bearing.mjs","webpack://vca/./node_modules/@joint/core/src/g/line.squaredLength.mjs","webpack://vca/./node_modules/@joint/core/src/g/line.length.mjs","webpack://vca/./node_modules/@joint/core/src/g/types.mjs","webpack://vca/./node_modules/@joint/core/src/g/point.mjs","webpack://vca/./node_modules/@joint/core/src/g/line.mjs","webpack://vca/./node_modules/@joint/core/src/g/ellipse.mjs","webpack://vca/./node_modules/@joint/core/src/g/rect.mjs","webpack://vca/./node_modules/@joint/core/src/g/points.mjs","webpack://vca/./node_modules/@joint/core/src/g/polyline.mjs","webpack://vca/./node_modules/@joint/core/src/g/curve.mjs","webpack://vca/./node_modules/@joint/core/src/g/extend.mjs","webpack://vca/./node_modules/@joint/core/src/g/path.mjs","webpack://vca/./node_modules/@joint/core/src/g/bezier.mjs","webpack://vca/./node_modules/@joint/core/src/g/polygon.mjs","webpack://vca/./node_modules/@joint/core/src/g/intersection.mjs","webpack://vca/./node_modules/@joint/core/src/g/index.mjs","webpack://vca/./node_modules/@joint/core/src/V/index.mjs","webpack://vca/./node_modules/@joint/core/src/mvc/Dom/methods.mjs","webpack://vca/./node_modules/@joint/core/src/mvc/Dom/animations.mjs","webpack://vca/./node_modules/@joint/core/src/mvc/Dom/props.mjs","webpack://vca/./node_modules/@joint/core/src/config/index.mjs","webpack://vca/./node_modules/@joint/core/src/mvc/Dom/events.mjs","webpack://vca/./node_modules/@joint/core/src/mvc/Dom/index.mjs","webpack://vca/./node_modules/@joint/core/src/util/util.mjs","webpack://vca/./node_modules/@joint/core/src/mvc/Events.mjs","webpack://vca/./node_modules/@joint/core/src/mvc/mvcUtils.mjs","webpack://vca/./node_modules/@joint/core/src/mvc/Model.mjs","webpack://vca/./node_modules/@joint/core/src/util/cloneCells.mjs","webpack://vca/./node_modules/@joint/core/src/dia/attributes/props.mjs","webpack://vca/./node_modules/@joint/core/src/dia/attributes/legacy.mjs","webpack://vca/./node_modules/@joint/core/src/util/calc.mjs","webpack://vca/./node_modules/@joint/core/src/dia/attributes/text.mjs","webpack://vca/./node_modules/@joint/core/src/dia/attributes/connection.mjs","webpack://vca/./node_modules/@joint/core/src/dia/attributes/shape.mjs","webpack://vca/./node_modules/@joint/core/src/dia/attributes/defs.mjs","webpack://vca/./node_modules/@joint/core/src/dia/attributes/offset.mjs","webpack://vca/./node_modules/@joint/core/src/dia/attributes/index.mjs","webpack://vca/./node_modules/@joint/core/src/dia/Cell.mjs","webpack://vca/./node_modules/@joint/core/src/layout/ports/port.mjs","webpack://vca/./node_modules/@joint/core/src/layout/ports/portLabel.mjs","webpack://vca/./node_modules/@joint/core/src/dia/ports.mjs","webpack://vca/./node_modules/@joint/core/src/dia/Element.mjs","webpack://vca/./node_modules/@joint/core/src/dia/Link.mjs","webpack://vca/./node_modules/@joint/core/src/env/index.mjs","webpack://vca/./node_modules/@joint/core/src/shapes/standard.mjs","webpack://vca/./node_modules/@joint/core/src/util/getRectPoint.mjs","webpack://vca/./node_modules/@joint/core/src/mvc/Collection.mjs","webpack://vca/./node_modules/@joint/core/src/util/wrappers.mjs","webpack://vca/./node_modules/@joint/core/src/dia/Graph.mjs","webpack://vca/./node_modules/@joint/core/src/mvc/ViewBase.mjs","webpack://vca/./node_modules/@joint/core/src/mvc/View.mjs","webpack://vca/./node_modules/@joint/core/src/dia/HighlighterView.mjs","webpack://vca/./node_modules/@joint/core/src/dia/attributes/eval.mjs","webpack://vca/./node_modules/@joint/core/src/dia/CellView.mjs","webpack://vca/./node_modules/@joint/core/src/dia/ElementView.mjs","webpack://vca/./node_modules/@joint/core/src/routers/normal.mjs","webpack://vca/./node_modules/@joint/core/src/routers/oneSide.mjs","webpack://vca/./node_modules/@joint/core/src/routers/orthogonal.mjs","webpack://vca/./node_modules/@joint/core/src/routers/manhattan.mjs","webpack://vca/./node_modules/@joint/core/src/routers/metro.mjs","webpack://vca/./node_modules/@joint/core/src/routers/rightAngle.mjs","webpack://vca/./node_modules/@joint/core/src/connectors/straight.mjs","webpack://vca/./node_modules/@joint/core/src/connectors/jumpover.mjs","webpack://vca/./node_modules/@joint/core/src/connectors/normal.mjs","webpack://vca/./node_modules/@joint/core/src/connectors/rounded.mjs","webpack://vca/./node_modules/@joint/core/src/connectors/smooth.mjs","webpack://vca/./node_modules/@joint/core/src/connectors/curve.mjs","webpack://vca/./node_modules/@joint/core/src/dia/LinkView.mjs","webpack://vca/./node_modules/@joint/core/src/dia/PaperLayer.mjs","webpack://vca/./node_modules/@joint/core/src/highlighters/stroke.mjs","webpack://vca/./node_modules/@joint/core/src/highlighters/mask.mjs","webpack://vca/./node_modules/@joint/core/src/highlighters/opacity.mjs","webpack://vca/./node_modules/@joint/core/src/highlighters/addClass.mjs","webpack://vca/./node_modules/@joint/core/src/highlighters/list.mjs","webpack://vca/./node_modules/@joint/core/src/linkAnchors/index.mjs","webpack://vca/./node_modules/@joint/core/src/connectionPoints/index.mjs","webpack://vca/./node_modules/@joint/core/src/anchors/index.mjs","webpack://vca/./node_modules/@joint/core/src/dia/layers/GridLayer.mjs","webpack://vca/./node_modules/@joint/core/src/dia/Paper.mjs","webpack://vca/./node_modules/@joint/core/src/dia/ToolView.mjs","webpack://vca/./node_modules/@joint/core/src/linkTools/Vertices.mjs","webpack://vca/./node_modules/@joint/core/src/connectionStrategies/index.mjs","webpack://vca/./node_modules/@joint/core/src/linkTools/Segments.mjs","webpack://vca/./node_modules/@joint/core/src/cellTools/helpers.mjs","webpack://vca/./node_modules/@joint/core/src/dia/ToolsView.mjs","webpack://vca/./src/flows.ts"],"sourcesContent":["// The require scope\nvar __webpack_require__ = {};\n\n","// define getter functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","// code is inspired by https://github.com/lodash/lodash\n\n/* eslint-disable no-case-declarations */\n// -- helper constants\nconst argsTag = '[object Arguments]';\nconst arrayTag = '[object Array]';\nconst boolTag = '[object Boolean]';\nconst dateTag = '[object Date]';\nconst errorTag = '[object Error]';\nconst funcTag = '[object Function]';\nconst mapTag = '[object Map]';\nconst numberTag = '[object Number]';\nconst nullTag = '[object Null]';\nconst objectTag = '[object Object]';\nconst regexpTag = '[object RegExp]';\nconst setTag = '[object Set]';\nconst stringTag = '[object String]';\nconst symbolTag = '[object Symbol]';\nconst undefinedTag = '[object Undefined]';\nconst weakMapTag = '[object WeakMap]';\nconst arrayBufferTag = '[object ArrayBuffer]';\nconst dataViewTag = '[object DataView]';\nconst float32Tag = '[object Float32Array]';\nconst float64Tag = '[object Float64Array]';\nconst int8Tag = '[object Int8Array]';\nconst int16Tag = '[object Int16Array]';\nconst int32Tag = '[object Int32Array]';\nconst uint8Tag = '[object Uint8Array]';\nconst uint8ClampedTag = '[object Uint8ClampedArray]';\nconst uint16Tag = '[object Uint16Array]';\nconst uint32Tag = '[object Uint32Array]';\n\nconst CLONEABLE_TAGS = {\n [argsTag]: true,\n [arrayTag]: true,\n [arrayBufferTag]: true,\n [dataViewTag]: true,\n [boolTag]: true,\n [dateTag]: true,\n [float32Tag]: true,\n [float64Tag]: true,\n [int8Tag]: true,\n [int16Tag]: true,\n [int32Tag]: true,\n [mapTag]: true,\n [numberTag]: true,\n [objectTag]: true,\n [regexpTag]: true,\n [setTag]: true,\n [stringTag]: true,\n [symbolTag]: true,\n [uint8Tag]: true,\n [uint8ClampedTag]: true,\n [uint16Tag]: true,\n [uint32Tag]: true,\n [errorTag]: false,\n [funcTag]: false,\n [weakMapTag]: false,\n};\n\n/** Used to compose unicode character classes. */\nconst rsAstralRange = '\\\\ud800-\\\\udfff';\nconst rsComboMarksRange = '\\\\u0300-\\\\u036f';\nconst reComboHalfMarksRange = '\\\\ufe20-\\\\ufe2f';\nconst rsComboSymbolsRange = '\\\\u20d0-\\\\u20ff';\nconst rsComboMarksExtendedRange = '\\\\u1ab0-\\\\u1aff';\nconst rsComboMarksSupplementRange = '\\\\u1dc0-\\\\u1dff';\nconst rsComboRange = rsComboMarksRange + reComboHalfMarksRange + rsComboSymbolsRange + rsComboMarksExtendedRange + rsComboMarksSupplementRange;\nconst rsDingbatRange = '\\\\u2700-\\\\u27bf';\nconst rsLowerRange = 'a-z\\\\xdf-\\\\xf6\\\\xf8-\\\\xff';\nconst rsMathOpRange = '\\\\xac\\\\xb1\\\\xd7\\\\xf7';\nconst rsNonCharRange = '\\\\x00-\\\\x2f\\\\x3a-\\\\x40\\\\x5b-\\\\x60\\\\x7b-\\\\xbf';\nconst rsPunctuationRange = '\\\\u2000-\\\\u206f';\nconst rsSpaceRange = ' \\\\t\\\\x0b\\\\f\\\\xa0\\\\ufeff\\\\n\\\\r\\\\u2028\\\\u2029\\\\u1680\\\\u180e\\\\u2000\\\\u2001\\\\u2002\\\\u2003\\\\u2004\\\\u2005\\\\u2006\\\\u2007\\\\u2008\\\\u2009\\\\u200a\\\\u202f\\\\u205f\\\\u3000';\nconst rsUpperRange = 'A-Z\\\\xc0-\\\\xd6\\\\xd8-\\\\xde';\nconst rsVarRange = '\\\\ufe0e\\\\ufe0f';\nconst rsBreakRange = rsMathOpRange + rsNonCharRange + rsPunctuationRange + rsSpaceRange;\n\n/** Used to compose unicode capture groups. */\nconst rsApos = '[\\'\\u2019]';\nconst rsBreak = `[${rsBreakRange}]`;\nconst rsCombo = `[${rsComboRange}]`;\nconst rsDigit = '\\\\d';\nconst rsDingbat = `[${rsDingbatRange}]`;\nconst rsLower = `[${rsLowerRange}]`;\nconst rsMisc = `[^${rsAstralRange}${rsBreakRange + rsDigit + rsDingbatRange + rsLowerRange + rsUpperRange}]`;\nconst rsFitz = '\\\\ud83c[\\\\udffb-\\\\udfff]';\nconst rsModifier = `(?:${rsCombo}|${rsFitz})`;\nconst rsNonAstral = `[^${rsAstralRange}]`;\nconst rsRegional = '(?:\\\\ud83c[\\\\udde6-\\\\uddff]){2}';\nconst rsSurrPair = '[\\\\ud800-\\\\udbff][\\\\udc00-\\\\udfff]';\nconst rsUpper = `[${rsUpperRange}]`;\nconst rsZWJ = '\\\\u200d';\n\n/** Used to compose unicode regexes. */\nconst rsMiscLower = `(?:${rsLower}|${rsMisc})`;\nconst rsMiscUpper = `(?:${rsUpper}|${rsMisc})`;\nconst rsOptContrLower = `(?:${rsApos}(?:d|ll|m|re|s|t|ve))?`;\nconst rsOptContrUpper = `(?:${rsApos}(?:D|LL|M|RE|S|T|VE))?`;\nconst reOptMod = `${rsModifier}?`;\nconst rsOptVar = `[${rsVarRange}]?`;\nconst rsOptJoin = `(?:${rsZWJ}(?:${[rsNonAstral, rsRegional, rsSurrPair].join('|')})${rsOptVar + reOptMod})*`;\nconst rsOrdLower = '\\\\d*(?:1st|2nd|3rd|(?![123])\\\\dth)(?=\\\\b|[A-Z_])';\nconst rsOrdUpper = '\\\\d*(?:1ST|2ND|3RD|(?![123])\\\\dTH)(?=\\\\b|[a-z_])';\nconst rsSeq = rsOptVar + reOptMod + rsOptJoin;\nconst rsEmoji = `(?:${[rsDingbat, rsRegional, rsSurrPair].join('|')})${rsSeq}`;\n\nconst reUnicodeWords = RegExp([\n `${rsUpper}?${rsLower}+${rsOptContrLower}(?=${[rsBreak, rsUpper, '$'].join('|')})`,\n `${rsMiscUpper}+${rsOptContrUpper}(?=${[rsBreak, rsUpper + rsMiscLower, '$'].join('|')})`,\n `${rsUpper}?${rsMiscLower}+${rsOptContrLower}`,\n `${rsUpper}+${rsOptContrUpper}`,\n rsOrdUpper,\n rsOrdLower,\n `${rsDigit}+`,\n rsEmoji\n].join('|'), 'g');\n\nconst LARGE_ARRAY_SIZE = 200;\nconst HASH_UNDEFINED = '__hash_undefined__';\n\n// Used to match `toStringTag` values of typed arrays\nconst reTypedTag = /^\\[object (?:Float(?:32|64)|(?:Int|Uint)(?:8|16|32)|Uint8Clamped)Array\\]$/;\n\n// Used to compose unicode capture groups\nconst rsAstral = `[${rsAstralRange}]`;\n\n// Used to compose unicode regexes\nconst rsNonAstralCombo = `${rsNonAstral}${rsCombo}?`;\nconst rsSymbol = `(?:${[rsNonAstralCombo, rsCombo, rsRegional, rsSurrPair, rsAstral].join('|')})`;\n\n// Used to match [string symbols](https://mathiasbynens.be/notes/javascript-unicode)\nconst reUnicode = RegExp(`${rsFitz}(?=${rsFitz})|${rsSymbol + rsSeq}`, 'g');\n\nconst reIsDeepProp = /\\.|\\[(?:[^[\\]]*|([\"'])(?:(?!\\1)[^\\\\]|\\\\.)*?\\1)\\]/;\nconst reIsPlainProp = /^\\w*$/;\n\nconst charCodeOfDot = '.'.charCodeAt(0);\nconst reEscapeChar = /\\\\(\\\\)?/g;\nconst rePropName = RegExp(\n // Match anything that isn't a dot or bracket.\n '[^.[\\\\]]+' + '|' +\n // Or match property names within brackets.\n '\\\\[(?:' +\n // Match a non-string expression.\n '([^\"\\'][^[]*)' + '|' +\n // Or match strings (supports escaping characters).\n '([\"\\'])((?:(?!\\\\2)[^\\\\\\\\]|\\\\\\\\.)*?)\\\\2' +\n ')\\\\]'+ '|' +\n // Or match \"\" as the space between consecutive dots or empty brackets.\n '(?=(?:\\\\.|\\\\[\\\\])(?:\\\\.|\\\\[\\\\]|$))'\n , 'g');\nconst reIsUint = /^(?:0|[1-9]\\d*)$/;\n\nconst hasUnicodeWord = RegExp.prototype.test.bind(\n /[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/\n);\n\nconst MAX_ARRAY_INDEX = 4294967295 - 1;\n\n/** Used to match words composed of alphanumeric characters. */\n// eslint-disable-next-line no-control-regex\nconst reAsciiWord = /[^\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\x7f]+/g;\n\n\n\n// -- helper functions\nconst hasUnicode = (string) => {\n return reUnicode.test(string);\n};\n\nconst unicodeToArray = (string) => {\n return string.match(reUnicode) || [];\n};\n\nconst asciiToArray = (string) => {\n return string.split('');\n};\n\nconst stringToArray = (string) => {\n return hasUnicode(string) ? unicodeToArray(string) : asciiToArray(string);\n};\n\nconst values = (object) => {\n if (object == null) {\n return [];\n }\n\n return keys(object).map((key) => object[key]);\n};\n\nconst keys = (object) => {\n return isArrayLike(object) ? arrayLikeKeys(object) : Object.keys(Object(object));\n};\n\nconst baseKeys = (object) => {\n if (!isPrototype(object)) {\n return Object.keys(object);\n }\n var result = [];\n for (var key in Object(object)) {\n if (hasOwnProperty.call(object, key) && key != 'constructor') {\n result.push(key);\n }\n }\n\n return result;\n};\n\nconst arrayLikeKeys = (value, inherited) => {\n const isArr = Array.isArray(value);\n const isArg = !isArr && isObjectLike(value) && getTag(value) === argsTag;\n const isType = !isArr && !isArg && isTypedArray(value);\n const skipIndexes = isArr || isArg || isType;\n const length = value.length;\n const result = new Array(skipIndexes ? length : 0);\n let index = skipIndexes ? -1 : length;\n while (++index < length) {\n result[index] = `${index}`;\n }\n for (const key in value) {\n if ((inherited || hasOwnProperty.call(value, key)) &&\n !(skipIndexes && (\n // Safari 9 has enumerable `arguments.length` in strict mode.\n key === 'length' ||\n // Skip index properties.\n isIndex(key, length)\n ))\n ) {\n result.push(key);\n }\n }\n return result;\n};\n\nconst assocIndexOf = (array, key) => {\n let { length } = array;\n while (length--) {\n if (eq(array[length][0], key)) {\n return length;\n }\n }\n return -1;\n};\n\nconst eq = (value, other) => {\n return value === other || (value !== value && other !== other);\n};\n\nconst isObjectLike = (value) => {\n return value != null && typeof value == 'object';\n};\n\nconst isIterateeCall = (value, index, object) => {\n if (!isObject(object)) {\n return false;\n }\n const type = typeof index;\n\n const isPossibleIteratee = type == 'number' ?\n (isArrayLike(object) && index > -1 && index < object.length) :\n (type == 'string' && index in object);\n\n if (isPossibleIteratee) {\n return eq(object[index], value);\n }\n return false;\n};\n\nconst isSet = (value) => {\n return isObjectLike(value) && getTag(value) == setTag;\n};\n\nconst isMap = (value) => {\n return isObjectLike(value) && getTag(value) == mapTag;\n};\n\nconst isPrototype = (value) => {\n const Ctor = value && value.constructor;\n const proto = (typeof Ctor === 'function' && Ctor.prototype) || Object.prototype;\n\n return value === proto;\n};\n\nconst assignValue = (object, key, value) => {\n const objValue = object[key];\n if (!(hasOwnProperty.call(object, key) && eq(objValue, value)) ||\n (value === undefined && !(key in object))) {\n object[key] = value;\n }\n};\n\nconst copyObject = (source, props, object) => {\n let index = -1;\n const length = props.length;\n\n while (++index < length) {\n const key = props[index];\n assignValue(object, key, source[key]);\n }\n return object;\n};\n\nconst isArrayLike = (value) => {\n return value != null && typeof value !== 'function' && typeof value.length === 'number' &&\n value.length > -1 && value.length % 1 === 0;\n};\n\nconst isSymbol = (value) => {\n return typeof value == 'symbol' ||\n (isObjectLike(value) && getTag(value) === symbolTag);\n};\n\nconst initCloneArray = (array) => {\n const length = array.length;\n let result = new array.constructor(length);\n\n if (length && typeof array[0] == 'string' && hasOwnProperty.call(array, 'index')) {\n result.index = array.index;\n result.input = array.input;\n }\n\n return result;\n};\n\nconst copyArray = (source, array) => {\n let index = -1;\n const length = source.length;\n\n array || (array = new Array(length));\n while (++index < length) {\n array[index] = source[index];\n }\n return array;\n};\n\nconst getTag = (value) => {\n if (value == null) {\n return value === undefined ? undefinedTag : nullTag;\n }\n\n return Object.prototype.toString.call(value);\n};\n\nconst cloneArrayBuffer = (arrayBuffer) => {\n const result = new arrayBuffer.constructor(arrayBuffer.byteLength);\n new Uint8Array(result).set(new Uint8Array(arrayBuffer));\n return result;\n};\n\nconst cloneTypedArray = (typedArray, isDeep) => {\n const buffer = isDeep ? cloneArrayBuffer(typedArray.buffer) : typedArray.buffer;\n return new typedArray.constructor(buffer, typedArray.byteOffset, typedArray.length);\n};\n\nconst cloneRegExp = (regexp) =>{\n const result = new regexp.constructor(regexp.source, /\\w*$/.exec(regexp));\n result.lastIndex = regexp.lastIndex;\n return result;\n};\n\nconst initCloneObject = (object) => {\n return (typeof object.constructor == 'function' && !isPrototype(object))\n ? Object.create(Object.getPrototypeOf(object))\n : {};\n};\n\nconst getSymbols = (object) => {\n if (object == null) {\n return [];\n }\n\n object = Object(object);\n const symbols = Object.getOwnPropertySymbols(object);\n\n return symbols.filter((symbol) => propertyIsEnumerable.call(object, symbol));\n};\n\nconst copySymbols = (source, object) => {\n return copyObject(source, getSymbols(source), object);\n};\n\nfunction cloneDataView(dataView, isDeep) {\n const buffer = isDeep ? cloneArrayBuffer(dataView.buffer) : dataView.buffer;\n return new dataView.constructor(buffer, dataView.byteOffset, dataView.byteLength);\n}\n\nconst initCloneByTag = (object, tag, isDeep) => {\n const Constructor = object.constructor;\n switch(tag) {\n case arrayBufferTag:\n return cloneArrayBuffer(object, isDeep);\n case boolTag:\n case dateTag:\n return new Constructor(+object);\n case dataViewTag:\n return cloneDataView(object, isDeep);\n case float32Tag:\n case float64Tag:\n case int8Tag:\n case int16Tag:\n case int32Tag:\n case uint8Tag:\n case uint8ClampedTag:\n case uint16Tag:\n case uint32Tag:\n return cloneTypedArray(object, isDeep);\n case mapTag:\n return new Constructor(object);\n case numberTag:\n case stringTag:\n return new Constructor(object);\n case regexpTag:\n return cloneRegExp(object);\n case setTag:\n return new Constructor;\n case symbolTag:\n return Symbol.prototype.valueOf ? Object(Symbol.prototype.valueOf.call(object)) : {};\n }\n};\n\nconst isTypedArray = (value) => {\n return isObjectLike(value) && reTypedTag.test(getTag(value));\n};\n\nconst getAllKeys = (object) => {\n const result = Object.keys(object);\n if(!Array.isArray(object) && object != null) {\n result.push(...getSymbols(Object(object)));\n }\n\n return result;\n};\n\nconst getSymbolsIn = (object) => {\n const result = [];\n while (object) {\n result.push(...getSymbols(object));\n object = Object.getPrototypeOf(Object(object));\n }\n\n return result;\n};\n\nconst getAllKeysIn = (object) => {\n const result = [];\n\n for (const key in object) {\n result.push(key);\n }\n\n if (!Array.isArray(object)) {\n result.push(...getSymbolsIn(object));\n }\n\n return result;\n};\n\nconst getMapData = ({ __data__ }, key) => {\n const data = __data__;\n return isKeyable(key)\n ? data[typeof key === 'string' ? 'string' : 'hash']\n : data.map;\n};\n\nconst equalObjects = (object, other, equalFunc, stack) => {\n const objProps = getAllKeys(object);\n const objLength = objProps.length;\n const othProps = getAllKeys(other);\n const othLength = othProps.length;\n\n if (objLength != othLength) {\n return false;\n }\n let key;\n let index = objLength;\n while (index--) {\n key = objProps[index];\n if (!(hasOwnProperty.call(other, key))) {\n return false;\n }\n }\n\n const objStacked = stack.get(object);\n const othStacked = stack.get(other);\n if (objStacked && othStacked) {\n return objStacked == other && othStacked == object;\n }\n let result = true;\n stack.set(object, other);\n stack.set(other, object);\n\n let compared;\n let skipCtor;\n\n while (++index < objLength) {\n key = objProps[index];\n const objValue = object[key];\n const othValue = other[key];\n\n if (!(compared === undefined\n ? (objValue === othValue || equalFunc(objValue, othValue, stack))\n : compared\n )) {\n result = false;\n break;\n }\n skipCtor || (skipCtor = key == 'constructor');\n }\n\n if (result && !skipCtor) {\n const objCtor = object.constructor;\n const othCtor = other.constructor;\n\n if (objCtor != othCtor &&\n ('constructor' in object && 'constructor' in other) &&\n !(typeof objCtor === 'function' && objCtor instanceof objCtor &&\n typeof othCtor === 'function' && othCtor instanceof othCtor)) {\n result = false;\n }\n }\n stack['delete'](object);\n stack['delete'](other);\n return result;\n};\n\nconst baseIsEqual = (value, other, stack) => {\n if (value === other) {\n return true;\n }\n if (value == null || other == null || (!isObjectLike(value) && !isObjectLike(other))) {\n return value !== value && other !== other;\n }\n\n return baseIsEqualDeep(value, other, baseIsEqual, stack);\n};\n\nconst baseIsEqualDeep = (object, other, equalFunc, stack) => {\n let objIsArr = Array.isArray(object);\n const othIsArr = Array.isArray(other);\n let objTag = objIsArr ? arrayTag : getTag(object);\n let othTag = othIsArr ? arrayTag : getTag(other);\n\n objTag = objTag == argsTag ? objectTag : objTag;\n othTag = othTag == argsTag ? objectTag : othTag;\n\n let objIsObj = objTag == objectTag;\n const othIsObj = othTag == objectTag;\n const isSameTag = objTag == othTag;\n\n if (isSameTag && !objIsObj) {\n stack || (stack = new Stack);\n return (objIsArr || isTypedArray(object))\n ? equalArrays(object, other, false, equalFunc, stack)\n : equalByTag(object, other, objTag, equalFunc, stack);\n }\n\n const objIsWrapped = objIsObj && hasOwnProperty.call(object, '__wrapped__');\n const othIsWrapped = othIsObj && hasOwnProperty.call(other, '__wrapped__');\n\n if (objIsWrapped || othIsWrapped) {\n const objUnwrapped = objIsWrapped ? object.value() : object;\n const othUnwrapped = othIsWrapped ? other.value() : other;\n\n stack || (stack = new Stack);\n return equalFunc(objUnwrapped, othUnwrapped, stack);\n }\n\n if (!isSameTag) {\n return false;\n }\n\n stack || (stack = new Stack);\n return equalObjects(object, other, equalFunc, stack);\n};\n\nconst equalArrays = (array, other, compareUnordered, equalFunc, stack) => {\n const isPartial = false;\n const arrLength = array.length;\n const othLength = other.length;\n\n if (arrLength != othLength && !(isPartial && othLength > arrLength)) {\n return false;\n }\n // Assume cyclic values are equal.\n const arrStacked = stack.get(array);\n const othStacked = stack.get(other);\n if (arrStacked && othStacked) {\n return arrStacked == other && othStacked == array;\n }\n let index = -1;\n let result = true;\n const seen = compareUnordered ? new SetCache : undefined;\n\n stack.set(array, other);\n stack.set(other, array);\n\n while (++index < arrLength) {\n let compared;\n const arrValue = array[index];\n const othValue = other[index];\n\n if (compared !== undefined) {\n if (compared) {\n continue;\n }\n result = false;\n break;\n }\n\n if (seen) {\n if (!some(other, (othValue, othIndex) => {\n if (!cacheHas(seen, othIndex) &&\n (arrValue === othValue || equalFunc(arrValue, othValue, stack))) {\n return seen.push(othIndex);\n }\n })) {\n result = false;\n break;\n }\n } else if (!(\n arrValue === othValue ||\n equalFunc(arrValue, othValue, stack)\n )) {\n result = false;\n break;\n }\n }\n stack['delete'](array);\n stack['delete'](other);\n return result;\n};\n\nconst some = (array, predicate) => {\n let index = -1;\n const length = array == null ? 0 : array.length;\n\n while (++index < length) {\n if (predicate(array[index], index, array)) {\n return true;\n }\n }\n return false;\n};\n\nconst cacheHas = (cache, key) => {\n return cache.has(key);\n};\n\nconst compareArrayBufferTag = (object, other, equalFunc, stack) => {\n if ((object.byteLength != other.byteLength) ||\n !equalFunc(new Uint8Array(object), new Uint8Array(other), stack)) {\n return false;\n }\n return true;\n};\n\nconst equalByTag = (object, other, tag, equalFunc, stack) => {\n\n switch (tag) {\n case dataViewTag:\n if ((object.byteLength != other.byteLength) ||\n (object.byteOffset != other.byteOffset)) {\n return false;\n }\n object = object.buffer;\n other = other.buffer;\n return compareArrayBufferTag(object, other, equalFunc, stack);\n case arrayBufferTag:\n return compareArrayBufferTag(object, other, equalFunc, stack);\n case boolTag:\n case dateTag:\n case numberTag:\n return eq(+object, +other);\n case errorTag:\n return object.name == other.name && object.message == other.message;\n case regexpTag:\n case stringTag:\n return object == `${other}`;\n case mapTag:\n // This use of 'var' is intentional. Don't remove if replacing all instances.\n var convert = mapToArray;\n // Intentional fallthrough\n // eslint-disable-next-line no-fallthrough\n case setTag:\n convert || (convert = setToArray);\n\n if (object.size != other.size) {\n return false;\n }\n // Assume cyclic values are equal.\n const stacked = stack.get(object);\n if (stacked) {\n return stacked == other;\n }\n\n // Recursively compare objects (susceptible to call stack limits).\n stack.set(object, other);\n const result = equalArrays(convert(object), convert(other), true, equalFunc, stack);\n stack['delete'](object);\n return result;\n case symbolTag:\n return Symbol.prototype.valueOf.call(object) == Symbol.prototype.valueOf.call(other);\n }\n\n return false;\n};\n\nconst mapToArray = (map) => {\n let index = -1;\n let result = Array(map.size);\n\n map.forEach((value, key) => {\n result[++index] = [key, value];\n });\n return result;\n};\n\nconst setToArray = (set) => {\n let index = -1;\n const result = new Array(set.size);\n\n set.forEach((value) => {\n result[++index] = value;\n });\n return result;\n};\n\nconst isKey = (value, object) => {\n if (Array.isArray(value)) {\n return false;\n }\n const type = typeof value;\n if (type === 'number' || type === 'boolean' || value == null || isSymbol(value)) {\n return true;\n }\n return reIsPlainProp.test(value) || !reIsDeepProp.test(value) ||\n (object != null && value in Object(object));\n};\n\nconst stringToPath = (string) => {\n const result = [];\n if (string.charCodeAt(0) === charCodeOfDot) {\n result.push('');\n }\n string.replace(rePropName, (match, expression, quote, subString) => {\n let key = match;\n if (quote) {\n key = subString.replace(reEscapeChar, '$1');\n }\n else if (expression) {\n key = expression.trim();\n }\n result.push(key);\n });\n return result;\n};\n\nconst castPath = (path, object) => {\n if (Array.isArray(path)) {\n return path;\n }\n\n return isKey(path, object) ? [path] : stringToPath(`${path}`);\n};\n\nconst get = (object, path) => {\n path = castPath(path, object);\n\n let index = 0;\n const length = path.length;\n\n while (object != null && index < length) {\n object = object[toKey(path[index])];\n index++;\n }\n\n return (index && index == length) ? object : undefined;\n};\n\nfunction compareAscending(value, other) {\n if (value !== other) {\n const valIsDefined = value !== undefined;\n const valIsNull = value === null;\n const valIsReflexive = value === value;\n const valIsSymbol = isSymbol(value);\n\n const othIsDefined = other !== undefined;\n const othIsNull = other === null;\n const othIsReflexive = other === other;\n const othIsSymbol = isSymbol(other);\n\n if ((!othIsNull && !othIsSymbol && !valIsSymbol && value > other) ||\n (valIsSymbol && othIsDefined && othIsReflexive && !othIsNull && !othIsSymbol) ||\n (valIsNull && othIsDefined && othIsReflexive) ||\n (!valIsDefined && othIsReflexive) ||\n !valIsReflexive) {\n return 1;\n }\n if ((!valIsNull && !valIsSymbol && !othIsSymbol && value < other) ||\n (othIsSymbol && valIsDefined && valIsReflexive && !valIsNull && !valIsSymbol) ||\n (othIsNull && valIsDefined && valIsReflexive) ||\n (!othIsDefined && valIsReflexive) ||\n !othIsReflexive) {\n return -1;\n }\n }\n return 0;\n}\n\nfunction compareMultiple(object, other, orders) {\n let index = -1;\n const objCriteria = object.criteria;\n const othCriteria = other.criteria;\n const length = objCriteria.length;\n const ordersLength = orders.length;\n\n while (++index < length) {\n const order = index < ordersLength ? orders[index] : null;\n const cmpFn = (order && typeof order === 'function') ? order : compareAscending;\n const result = cmpFn(objCriteria[index], othCriteria[index]);\n if (result) {\n if (order && typeof order !== 'function') {\n return result * (order == 'desc' ? -1 : 1);\n }\n return result;\n }\n }\n\n return object.index - other.index;\n}\n\nconst diff = (array, values) => {\n let includes = (array, value) => {\n const length = array == null ? 0 : array.length;\n return !!length && array.indexOf(value) > -1;\n };\n let isCommon = true;\n const result = [];\n const valuesLength = values.length;\n\n if (!array.length) {\n return result;\n }\n\n if (values.length >= LARGE_ARRAY_SIZE) {\n includes = (cache, key) => cache.has(key);\n isCommon = false;\n values = new SetCache(values);\n }\n\n outer:\n for (let key in array) {\n let value = array[key];\n const computed = value;\n\n value = (value !== 0) ? value : 0;\n if (isCommon && computed === computed) {\n let valuesIndex = valuesLength;\n while (valuesIndex--) {\n if (values[valuesIndex] === computed) {\n continue outer;\n }\n }\n result.push(value);\n }\n else if (!includes(values, computed)) {\n result.push(value);\n }\n }\n\n return result;\n};\n\nconst intersect = (arrays) => {\n const includes = (array, value) => {\n const length = array == null ? 0 : array.length;\n return !!length && array.indexOf(value) > -1;\n };\n const cacheHas = (cache, key) => cache.has(key);\n const length = arrays[0].length;\n const othLength = arrays.length;\n const caches = new Array(othLength);\n const result = [];\n\n let array;\n let maxLength = Infinity;\n let othIndex = othLength;\n\n while (othIndex--) {\n array = arrays[othIndex];\n\n maxLength = Math.min(array.length, maxLength);\n caches[othIndex] = length >= 120 && array.length >= 120\n ? new SetCache(othIndex && array)\n : undefined;\n }\n array = arrays[0];\n\n let index = -1;\n const seen = caches[0];\n\n outer:\n while (++index < length && result.length < maxLength) {\n let value = array[index];\n const computed = value;\n\n value = (value !== 0) ? value : 0;\n if (!(seen\n ? cacheHas(seen, computed)\n : includes(result, computed)\n )) {\n othIndex = othLength;\n while (--othIndex) {\n const cache = caches[othIndex];\n if (!(cache\n ? cacheHas(cache, computed)\n : includes(arrays[othIndex], computed))\n ) {\n continue outer;\n }\n }\n if (seen) {\n seen.push(computed);\n }\n result.push(value);\n }\n }\n return result;\n};\n\nconst toKey = (value) => {\n if (typeof value === 'string' || isSymbol(value)) {\n return value;\n }\n const result = `${value}`;\n return (result == '0' && (1 / value) == -Infinity) ? '-0' : result;\n};\n\nconst baseClone = (value, isDeep = false, isFlat = false, isFull = true, customizer, key, object, stack) => {\n let result;\n\n if (customizer) {\n result = object ? customizer(value, key, object, stack) : customizer(value);\n }\n\n if (result !== undefined) {\n return result;\n }\n\n if (!isObject(value)) {\n return value;\n }\n\n const isArr = Array.isArray(value);\n const tag = getTag(value);\n\n if (isArr) {\n result = initCloneArray(value);\n\n if (!isDeep) {\n return copyArray(value, result);\n }\n } else {\n const isFunc = typeof value === 'function';\n\n if (tag === objectTag || tag === argsTag || (isFunc && !object)) {\n result = (isFlat || isFunc) ? {} : initCloneObject(value);\n if (!isDeep) {\n return isFlat ?\n copySymbolsIn(value, copyObject(value, Object.keys(value), result)) :\n copySymbols(value, Object.assign(result, value));\n }\n } else {\n if (isFunc || !CLONEABLE_TAGS[tag]) {\n return object ? value : {};\n }\n result = initCloneByTag(value, tag, isDeep);\n }\n }\n\n stack || (stack = new Stack);\n const stacked = stack.get(value);\n\n if (stacked) {\n return stacked;\n }\n\n stack.set(value, result);\n\n if (isMap(value)) {\n value.forEach((subValue, key) => {\n result.set(key, baseClone(subValue, isDeep, isFlat, isFull, customizer, key, value, stack));\n });\n\n return result;\n }\n\n if (isSet(value)) {\n value.forEach(subValue => {\n result.add(baseClone(subValue, isDeep, isFlat, isFull, customizer, subValue, value, stack));\n });\n\n return result;\n }\n\n if(isTypedArray(value)) {\n return result;\n }\n\n const keysFunc = isFull\n ? (isFlat ? getAllKeysIn : getAllKeys)\n : (isFlat ? keysIn : keys);\n\n const props = isArr ? undefined : keysFunc(value);\n\n (props || value).forEach((subValue, key) => {\n if (props) {\n key = subValue;\n subValue = value[key];\n }\n\n assignValue(result, key, baseClone(subValue, isDeep, isFlat, isFull, customizer, key, value, stack));\n });\n\n return result;\n};\n\nconst copySymbolsIn = (source, object) => {\n return copyObject(source, getSymbolsIn(source), object);\n};\n\nconst parent = (object, path) => {\n return path.length < 2 ? object : get(object, path.slice(0, -1));\n};\n\nconst set = (object, path, value) => {\n if (!isObject(object)) {\n return object;\n }\n path = castPath(path, object);\n\n const length = path.length;\n const lastIndex = length - 1;\n\n let index = -1;\n let nested = object;\n\n while (nested != null && ++index < length) {\n const key = toKey(path[index]);\n let newValue = value;\n\n if (index != lastIndex) {\n const objValue = nested[key];\n newValue = undefined;\n if (newValue === undefined) {\n newValue = isObject(objValue)\n ? objValue\n : (isIndex(path[index + 1]) ? [] : {});\n }\n }\n assignValue(nested, key, newValue);\n nested = nested[key];\n }\n return object;\n};\n\nconst isIndex = (value, length) => {\n const type = typeof value;\n length = length == null ? Number.MAX_SAFE_INTEGER : length;\n\n return !!length &&\n (type === 'number' ||\n (type !== 'symbol' && reIsUint.test(value))) &&\n (value > -1 && value % 1 == 0 && value < length);\n};\n\nconst unset = (object, path) => {\n path = castPath(path, object);\n object = parent(object, path);\n const lastSegment = path[path.length - 1];\n return object == null || delete object[toKey(lastSegment)];\n};\n\nconst isKeyable = (value) => {\n const type = typeof value;\n return (type === 'string' || type === 'number' || type === 'symbol' || type === 'boolean')\n ? (value !== '__proto__')\n : (value === null);\n};\n\nconst keysIn = (object) => {\n const result = [];\n for (const key in object) {\n result.push(key);\n }\n return result;\n};\n\nconst toPlainObject = (value) => {\n value = Object(value);\n const result = {};\n for (const key in value) {\n result[key] = value[key];\n }\n return result;\n};\n\nconst safeGet = (object, key) => {\n if (key === 'constructor' && typeof object[key] === 'function') {\n return;\n }\n\n if (key == '__proto__') {\n return;\n }\n\n return object[key];\n};\n\nfunction createAssigner(assigner, isMerge = false) {\n return (object, ...sources) => {\n let index = -1;\n let length = sources.length;\n let customizer = length > 1 ? sources[length - 1] : undefined;\n const guard = length > 2 ? sources[2] : undefined;\n\n customizer = (assigner.length > 3 && typeof customizer === 'function')\n ? (length--, customizer)\n : isMerge ? (a, b) => {\n if (Array.isArray(a) && !Array.isArray(b)) {\n return b;\n }\n } : undefined;\n\n if (guard && isIterateeCall(sources[0], sources[1], guard)) {\n customizer = length < 3 ? undefined : customizer;\n length = 1;\n }\n object = Object(object);\n while (++index < length) {\n const source = sources[index];\n if (source) {\n assigner(object, source, index, customizer);\n }\n }\n return object;\n };\n}\n\nconst baseMerge = (object, source, srcIndex, customizer, stack) => {\n if (object === source) {\n return;\n }\n\n forIn(source, (srcValue, key) => {\n if (isObject(srcValue)) {\n stack || (stack = new Stack);\n baseMergeDeep(object, source, key, srcIndex, baseMerge, customizer, stack);\n } else {\n let newValue = customizer\n ? customizer(object[key], srcValue, `${key}`, object, source, stack)\n : undefined;\n\n if (newValue === undefined) {\n newValue = srcValue;\n }\n\n assignMergeValue(object, key, newValue);\n }\n }, keysIn);\n};\n\nconst baseMergeDeep = (object, source, key, srcIndex, mergeFunc, customizer, stack) => {\n const objValue = safeGet(object, key);\n const srcValue = safeGet(source, key);\n const stacked = stack.get(srcValue);\n\n if (stacked) {\n assignMergeValue(object, key, stacked);\n return;\n }\n\n let newValue = customizer\n ? customizer(objValue, srcValue, `${key}`, object, source, stack)\n : undefined;\n\n let isCommon = newValue === undefined;\n\n if (isCommon) {\n const isArr = Array.isArray(srcValue);\n const isTyped = !isArr && isTypedArray(srcValue);\n\n newValue = srcValue;\n if (isArr || isTyped) {\n if (Array.isArray(objValue)) {\n newValue = objValue;\n }\n else if (isObjectLike(objValue) && isArrayLike(objValue)) {\n newValue = copyArray(objValue);\n }\n else if (isTyped) {\n isCommon = false;\n newValue = cloneTypedArray(srcValue, true);\n }\n else {\n newValue = [];\n }\n }\n else if (isPlainObject(srcValue) || isArguments(srcValue)) {\n newValue = objValue;\n if (isArguments(objValue)) {\n newValue = toPlainObject(objValue);\n }\n else if (typeof objValue === 'function' || !isObject(objValue)) {\n newValue = initCloneObject(srcValue);\n }\n }\n else {\n isCommon = false;\n }\n }\n if (isCommon) {\n // Recursively merge objects and arrays (susceptible to call stack limits).\n stack.set(srcValue, newValue);\n mergeFunc(newValue, srcValue, srcIndex, customizer, stack);\n stack['delete'](srcValue);\n }\n assignMergeValue(object, key, newValue);\n};\n\nconst assignMergeValue = (object, key, value) => {\n if ((value !== undefined && !eq(object[key], value)) ||\n (value === undefined && !(key in object))) {\n assignValue(object, key, value);\n }\n};\n\nfunction baseFor(object, iteratee, keysFunc) {\n const iterable = Object(object);\n const props = keysFunc(object);\n let { length } = props;\n let index = -1;\n\n while (length--) {\n const key = props[++index];\n if (iteratee(iterable[key], key, iterable) === false) {\n break;\n }\n }\n return object;\n}\n\nconst baseForOwn = (object, iteratee) => {\n return object && baseFor(object, iteratee, keys);\n};\n\nconst baseEach = (collection, iteratee) => {\n if (collection == null) {\n return collection;\n }\n if (!isArrayLike(collection)) {\n return baseForOwn(collection, iteratee);\n }\n const length = collection.length;\n const iterable = Object(collection);\n let index = -1;\n\n while (++index < length) {\n if (iteratee(iterable[index], index, iterable) === false) {\n break;\n }\n }\n return collection;\n};\n\nfunction last(array) {\n const length = array == null ? 0 : array.length;\n return length ? array[length - 1] : undefined;\n}\n\nconst createSet = (Set && (1 / setToArray(new Set([undefined,-0]))[1]) == 1 / 0)\n ? (values) => new Set(values)\n : () => {};\n\nfunction customDefaultsMerge(objValue, srcValue, key, object, source, stack) {\n if (isObject(objValue) && isObject(srcValue)) {\n // Recursively merge objects and arrays (susceptible to call stack limits).\n stack.set(srcValue, objValue);\n baseMerge(objValue, srcValue, undefined, customDefaultsMerge, stack);\n stack['delete'](srcValue);\n }\n return objValue;\n}\n\nfunction baseOrderBy(collection, iteratees, orders) {\n if (iteratees.length) {\n iteratees = iteratees.map((iteratee) => {\n if (Array.isArray(iteratee)) {\n return (value) => get(value, iteratee.length === 1 ? iteratee[0] : iteratee);\n }\n\n return iteratee;\n });\n } else {\n iteratees = [(value) => value];\n }\n\n let criteriaIndex = -1;\n let eachIndex = -1;\n\n const result = isArrayLike(collection) ? new Array(collection.length) : [];\n\n baseEach(collection, (value) => {\n const criteria = iteratees.map((iteratee) => iteratee(value));\n\n result[++eachIndex] = {\n criteria,\n index: ++criteriaIndex,\n value\n };\n });\n\n return baseSortBy(result, (object, other) => compareMultiple(object, other, orders));\n}\n\nfunction baseSortBy(array, comparer) {\n let { length } = array;\n\n array.sort(comparer);\n while (length--) {\n array[length] = array[length].value;\n }\n return array;\n}\n\nfunction isStrictComparable(value) {\n return value === value && !isObject(value);\n}\n\nfunction matchesStrictComparable(key, srcValue) {\n return (object) => {\n if (object == null) {\n return false;\n }\n return object[key] === srcValue &&\n (srcValue !== undefined || (key in Object(object)));\n };\n}\n\nfunction hasIn(object, path) {\n return object != null && hasPath(object, path, baseHasIn);\n}\n\nfunction baseMatchesProperty(path, srcValue) {\n if (isKey(path) && isStrictComparable(srcValue)) {\n return matchesStrictComparable(toKey(path), srcValue);\n }\n return (object) => {\n const objValue = get(object, path);\n return (objValue === undefined && objValue === srcValue)\n ? hasIn(object, path)\n : baseIsEqual(srcValue, objValue);\n };\n}\n\nfunction baseMatches(source) {\n const matchData = getMatchData(source);\n if (matchData.length === 1 && matchData[0][2]) {\n return matchesStrictComparable(matchData[0][0], matchData[0][1]);\n }\n return (object) => object === source || baseIsMatch(object, source, matchData);\n}\n\nfunction getMatchData(object) {\n const result = keys(object);\n let length = result.length;\n\n while (length--) {\n const key = result[length];\n const value = object[key];\n result[length] = [key, value, isStrictComparable(value)];\n }\n return result;\n}\n\nfunction baseIsMatch(object, source, matchData, customizer) {\n let index = matchData.length;\n const length = index;\n const noCustomizer = !customizer;\n\n if (object == null) {\n return !length;\n }\n let data;\n let result;\n object = Object(object);\n while (index--) {\n data = matchData[index];\n if ((noCustomizer && data[2])\n ? data[1] !== object[data[0]]\n : !(data[0] in object)\n ) {\n return false;\n }\n }\n while (++index < length) {\n data = matchData[index];\n const key = data[0];\n const objValue = object[key];\n const srcValue = data[1];\n\n if (noCustomizer && data[2]) {\n if (objValue === undefined && !(key in object)) {\n return false;\n }\n } else {\n const stack = new Stack;\n if (customizer) {\n result = customizer(objValue, srcValue, key, object, source, stack);\n }\n if (!(result === undefined\n ? baseIsEqual(srcValue, objValue, stack)\n : result\n )) {\n return false;\n }\n }\n }\n return true;\n}\n\nfunction property(path) {\n return isKey(path) ? baseProperty(toKey(path)) : basePropertyDeep(path);\n}\n\nfunction baseProperty(key) {\n return (object) => object == null ? undefined : object[key];\n}\n\nfunction basePropertyDeep(path) {\n return (object) => get(object, path);\n}\n\nfunction baseIteratee(value) {\n if (typeof value == 'function') {\n return value;\n }\n if (value == null) {\n return (val) => val;\n }\n if (typeof value == 'object') {\n return Array.isArray(value)\n ? baseMatchesProperty(value[0], value[1])\n : baseMatches(value);\n }\n return property(value);\n}\n\nfunction getIteratee() {\n const result = baseIteratee;\n return arguments.length ? result(arguments[0], arguments[1]) : result;\n}\n\nconst arrayReduce = (array, iteratee, accumulator, initAccum) => {\n let index = -1;\n const length = array == null ? 0 : array.length;\n\n if (initAccum && length) {\n accumulator = array[++index];\n }\n while (++index < length) {\n accumulator = iteratee(accumulator, array[index], index, array);\n }\n return accumulator;\n};\n\nconst baseReduce = (collection, iteratee, accumulator, initAccum, eachFunc) => {\n eachFunc(collection, (value, index, collection) => {\n accumulator = initAccum\n ? (initAccum = false, value)\n : iteratee(accumulator, value, index, collection);\n });\n return accumulator;\n};\n\nfunction reduce(collection, iteratee, accumulator) {\n const func = Array.isArray(collection) ? arrayReduce : baseReduce;\n const initAccum = arguments.length < 3;\n return func(collection, iteratee, accumulator, initAccum, baseEach);\n}\n\nconst isFlattenable = (value) => {\n return Array.isArray(value) || isArguments(value) ||\n !!(value && value[Symbol.isConcatSpreadable]);\n};\n\nfunction baseFlatten(array, depth, predicate, isStrict, result) {\n let index = -1;\n const length = array.length;\n\n predicate || (predicate = isFlattenable);\n result || (result = []);\n\n while (++index < length) {\n var value = array[index];\n if (depth > 0 && predicate(value)) {\n if (depth > 1) {\n // Recursively flatten arrays (susceptible to call stack limits).\n baseFlatten(value, depth - 1, predicate, isStrict, result);\n } else {\n result.push(...value);\n }\n } else if (!isStrict) {\n result[result.length] = value;\n }\n }\n return result;\n}\n\nconst isArguments = (value) => {\n return isObjectLike(value) && getTag(value) == '[object Arguments]';\n};\n\nconst basePick = (object, paths) => {\n return basePickBy(object, paths, (value, path) => hasIn(object, path));\n};\n\nconst basePickBy = (object, paths, predicate) => {\n let index = -1;\n const length = paths.length;\n const result = {};\n\n while (++index < length) {\n const path = paths[index];\n const value = get(object, path);\n if (predicate(value, path)) {\n set(result, castPath(path, object), value);\n }\n }\n return result;\n};\n\nconst isLength = (value) => {\n return typeof value == 'number' &&\n value > -1 && value % 1 == 0 && value <= Number.MAX_SAFE_INTEGER;\n};\n\nconst baseHasIn = (object, key) =>{\n return object != null && key in Object(object);\n};\n\nconst hasPath = (object, path, hasFunc) => {\n path = castPath(path, object);\n\n var index = -1,\n length = path.length,\n result = false;\n\n while (++index < length) {\n var key = toKey(path[index]);\n if (!(result = object != null && hasFunc(object, key))) {\n break;\n }\n object = object[key];\n }\n if (result || ++index != length) {\n return result;\n }\n length = object == null ? 0 : object.length;\n return !!length && isLength(length) && isIndex(key, length) &&\n (Array.isArray(object) || isArguments(object));\n};\n\nconst asciiWords = (string) => {\n return string.match(reAsciiWord);\n};\n\nconst unicodeWords = (string) => {\n return string.match(reUnicodeWords);\n};\n\nconst words = (string, pattern) => {\n if (pattern === undefined) {\n const result = hasUnicodeWord(string) ? unicodeWords(string) : asciiWords(string);\n return result || [];\n }\n return string.match(pattern) || [];\n};\n\nconst castSlice = (array, start, end) => {\n const { length } = array;\n end = end === undefined ? length : end;\n return (!start && end >= length) ? array : array.slice(start, end);\n};\n\nconst upperFirst = createCaseFirst('toUpperCase');\n\nfunction createCaseFirst(methodName) {\n return (string) => {\n if (!string) {\n return '';\n }\n\n const strSymbols = hasUnicode(string)\n ? stringToArray(string)\n : undefined;\n\n const chr = strSymbols\n ? strSymbols[0]\n : string[0];\n\n const trailing = strSymbols\n ? castSlice(strSymbols, 1).join('')\n : string.slice(1);\n\n return chr[methodName]() + trailing;\n };\n}\n\nexport function matches(source) {\n return baseMatches(baseClone(source, true));\n}\n\n// -- helper classes\nclass Stack {\n constructor(entries) {\n const data = this.__data__ = new ListCache(entries);\n this.size = data.size;\n }\n\n clear() {\n this.__data__ = new ListCache;\n this.size = 0;\n }\n\n delete(key) {\n const data = this.__data__;\n const result = data['delete'](key);\n\n this.size = data.size;\n return result;\n }\n\n get(key) {\n return this.__data__.get(key);\n }\n\n has(key) {\n return this.__data__.has(key);\n }\n\n set(key, value) {\n let data = this.__data__;\n if (data instanceof ListCache) {\n const pairs = data.__data__;\n if (pairs.length < LARGE_ARRAY_SIZE - 1) {\n pairs.push([key, value]);\n this.size = ++data.size;\n return this;\n }\n data = this.__data__ = new MapCache(pairs);\n }\n data.set(key, value);\n this.size = data.size;\n return this;\n }\n}\n\nclass ListCache {\n constructor(entries) {\n let index = -1;\n const length = entries == null ? 0 : entries.length;\n\n this.clear();\n while (++index < length) {\n const entry = entries[index];\n this.set(entry[0], entry[1]);\n }\n }\n\n clear() {\n this.__data__ = [];\n this.size = 0;\n }\n\n delete(key) {\n const data = this.__data__;\n const index = assocIndexOf(data, key);\n\n if (index < 0) {\n return false;\n }\n const lastIndex = data.length - 1;\n if (index == lastIndex) {\n data.pop();\n } else {\n data.splice(index, 1);\n }\n --this.size;\n return true;\n }\n\n get(key) {\n const data = this.__data__;\n const index = assocIndexOf(data, key);\n return index < 0 ? undefined : data[index][1];\n }\n\n has(key) {\n return assocIndexOf(this.__data__, key) > -1;\n }\n\n set(key, value) {\n const data = this.__data__;\n const index = assocIndexOf(data, key);\n\n if (index < 0) {\n ++this.size;\n data.push([key, value]);\n } else {\n data[index][1] = value;\n }\n return this;\n }\n}\n\nclass MapCache {\n constructor(entries) {\n let index = -1;\n const length = entries == null ? 0 : entries.length;\n\n this.clear();\n while (++index < length) {\n const entry = entries[index];\n this.set(entry[0], entry[1]);\n }\n }\n\n clear() {\n this.size = 0;\n this.__data__ = {\n 'hash': new Hash,\n 'map': new Map,\n 'string': new Hash\n };\n }\n\n delete(key) {\n const result = getMapData(this, key)['delete'](key);\n this.size -= result ? 1 : 0;\n return result;\n }\n\n get(key) {\n return getMapData(this, key).get(key);\n }\n\n has(key) {\n return getMapData(this, key).has(key);\n }\n\n set(key, value) {\n const data = getMapData(this, key);\n const size = data.size;\n\n data.set(key, value);\n this.size += data.size == size ? 0 : 1;\n return this;\n }\n}\n\nclass Hash {\n constructor(entries) {\n let index = -1;\n const length = entries == null ? 0 : entries.length;\n\n this.clear();\n while (++index < length) {\n const entry = entries[index];\n this.set(entry[0], entry[1]);\n }\n }\n\n clear() {\n this.__data__ = Object.create(null);\n this.size = 0;\n }\n\n delete(key) {\n const result = this.has(key) && delete this.__data__[key];\n this.size -= result ? 1 : 0;\n return result;\n }\n\n get(key) {\n const data = this.__data__;\n const result = data[key];\n return result === HASH_UNDEFINED ? undefined : result;\n }\n\n has(key) {\n const data = this.__data__;\n return data[key] !== undefined;\n }\n\n set(key, value) {\n const data = this.__data__;\n this.size += this.has(key) ? 0 : 1;\n data[key] = value === undefined ? HASH_UNDEFINED : value;\n return this;\n }\n}\n\nclass SetCache {\n constructor(values) {\n let index = -1;\n const length = values == null ? 0 : values.length;\n\n this.__data__ = new MapCache;\n while (++index < length) {\n this.add(values[index]);\n }\n }\n\n add(value) {\n this.__data__.set(value, HASH_UNDEFINED);\n return this;\n }\n\n has(value) {\n return this.__data__.has(value);\n }\n}\n\nSetCache.prototype.push = SetCache.prototype.add;\n\n// -- top level functions\n\nexport const isBoolean = function(value) {\n var toString = Object.prototype.toString;\n return value === true || value === false || (!!value && typeof value === 'object' && toString.call(value) === boolTag);\n};\n\nexport const isObject = function(value) {\n return !!value && (typeof value === 'object' || typeof value === 'function');\n};\n\nexport const isNumber = function(value) {\n var toString = Object.prototype.toString;\n return typeof value === 'number' || (!!value && typeof value === 'object' && toString.call(value) === numberTag);\n};\n\nexport const isString = function(value) {\n var toString = Object.prototype.toString;\n return typeof value === 'string' || (!!value && typeof value === 'object' && toString.call(value) === stringTag);\n};\n\nexport const assign = createAssigner((object, source) => {\n if (isPrototype(source) || isArrayLike(source)) {\n copyObject(source, keys(source), object);\n return;\n }\n for (var key in source) {\n if (hasOwnProperty.call(source, key)) {\n assignValue(object, key, source[key]);\n }\n }\n});\n\nexport const mixin = assign;\n\nexport const deepMixin = mixin;\n\nexport const supplement = (object, ...sources) => {\n let index = -1;\n let length = sources.length;\n const guard = length > 2 ? sources[2] : undefined;\n\n if (guard && isIterateeCall(sources[0], sources[1], guard)) {\n length = 1;\n }\n\n while (++index < length) {\n const source = sources[index];\n\n if (source == null) {\n continue;\n }\n\n const props = Object.keys(source);\n const propsLength = props.length;\n let propsIndex = -1;\n\n while (++propsIndex < propsLength) {\n const key = props[propsIndex];\n const value = object[key];\n\n if (value === undefined ||\n (eq(value, Object.prototype[key]) && !hasOwnProperty.call(object, key))) {\n object[key] = source[key];\n }\n }\n }\n\n return object;\n};\n\nexport const defaults = supplement;\n\nexport const deepSupplement = function defaultsDeep(...args) {\n args.push(undefined, customDefaultsMerge);\n return merge.apply(undefined, args);\n};\n\nexport const defaultsDeep = deepSupplement;\n\n// _.invokeMap\nexport const invoke = (collection, path, ...args) => {\n let index = -1;\n const isFunc = typeof path === 'function';\n const result = isArrayLike(collection) ? new Array(collection.length) : [];\n\n baseEach(collection, (value) => {\n result[++index] = isFunc ? path.apply(value, args) : invokeProperty(value, path, ...args);\n });\n\n return result;\n};\n\n// _.invoke\nexport const invokeProperty = (object, path, ...args) => {\n path = castPath(path, object);\n object = parent(object, path);\n const func = object == null ? object : object[toKey(last(path))];\n return func == null ? undefined : func.apply(object, args);\n};\n\nexport const sortedIndex = (array, value, iteratee) => {\n let low = 0;\n let high = array == null ? 0 : array.length;\n if (high == 0) {\n return 0;\n }\n\n iteratee = getIteratee(iteratee, 2);\n value = iteratee(value);\n\n const valIsNaN = value !== value;\n const valIsNull = value === null;\n const valIsSymbol = isSymbol(value);\n const valIsUndefined = value === undefined;\n\n while (low < high) {\n let setLow;\n const mid = Math.floor((low + high) / 2);\n const computed = iteratee(array[mid]);\n const othIsDefined = computed !== undefined;\n const othIsNull = computed === null;\n const othIsReflexive = computed === computed;\n const othIsSymbol = isSymbol(computed);\n\n if (valIsNaN) {\n setLow = othIsReflexive;\n } else if (valIsUndefined) {\n setLow = othIsReflexive &&othIsDefined;\n } else if (valIsNull) {\n setLow = othIsReflexive && othIsDefined && !othIsNull;\n } else if (valIsSymbol) {\n setLow = othIsReflexive && othIsDefined && !othIsNull && !othIsSymbol;\n } else if (othIsNull || othIsSymbol) {\n setLow = false;\n } else {\n setLow = computed < value;\n }\n if (setLow) {\n low = mid + 1;\n } else {\n high = mid;\n }\n }\n return Math.min(high, MAX_ARRAY_INDEX);\n};\n\nexport const uniq = (array, iteratee) => {\n let index = -1;\n let includes = (array, value) => {\n const length = array == null ? 0 : array.length;\n return !!length && array.indexOf(value) > -1;\n };\n iteratee = getIteratee(iteratee, 2);\n let isCommon = true;\n\n const { length } = array;\n const result = [];\n let seen = result;\n\n if (length >= LARGE_ARRAY_SIZE) {\n const set = iteratee ? null : createSet(array);\n if (set) {\n return setToArray(set);\n }\n isCommon = false;\n includes = (cache, key) => cache.has(key);\n seen = new SetCache;\n } else {\n seen = iteratee ? [] : result;\n }\n outer:\n while (++index < length) {\n let value = array[index];\n const computed = iteratee ? iteratee(value) : value;\n\n value = (value !== 0) ? value : 0;\n if (isCommon && computed === computed) {\n let seenIndex = seen.length;\n while (seenIndex--) {\n if (seen[seenIndex] === computed) {\n continue outer;\n }\n }\n if (iteratee) {\n seen.push(computed);\n }\n result.push(value);\n }\n else if (!includes(seen, computed)) {\n if (seen !== result) {\n seen.push(computed);\n }\n result.push(value);\n }\n }\n return result;\n};\n\nexport const clone = (value) => baseClone(value);\n\nexport const cloneDeep = (value) => baseClone(value, true);\n\nexport const isEmpty = (value) => {\n if (value == null) {\n return true;\n }\n if (isArrayLike(value) &&\n (Array.isArray(value) || typeof value === 'string' || typeof value.splice === 'function' ||\n isTypedArray(value) || isArguments(value))) {\n return !value.length;\n }\n const tag = getTag(value);\n if (tag == '[object Map]' || tag == '[object Set]') {\n return !value.size;\n }\n if (isPrototype(value)) {\n return !baseKeys(value).length;\n }\n for (const key in value) {\n if (hasOwnProperty.call(value, key)) {\n return false;\n }\n }\n return true;\n};\nexport const isEqual = (object, other) => baseIsEqual(object, other);\n\nexport const isFunction = (value) => typeof value === 'function';\n\nexport const isPlainObject = (value) => {\n if (!isObjectLike(value) || getTag(value) != '[object Object]') {\n return false;\n }\n if (Object.getPrototypeOf(value) === null) {\n return true;\n }\n let proto = value;\n while (Object.getPrototypeOf(proto) !== null) {\n proto = Object.getPrototypeOf(proto);\n }\n return Object.getPrototypeOf(value) === proto;\n};\n\nexport const toArray = (value) => {\n if (!value) {\n return [];\n }\n\n if (isArrayLike(value)) {\n return isString(value) ? stringToArray(value) : copyArray(value);\n }\n\n if (Symbol.iterator && Symbol.iterator in Object(value)) {\n const iterator = value[Symbol.iterator]();\n let data;\n const result = [];\n\n while (!(data = iterator.next()).done) {\n result.push(data.value);\n }\n return result;\n }\n\n const tag = getTag(value);\n const func = tag == mapTag ? mapToArray : (tag == setTag ? setToArray : values);\n\n return func(value);\n};\n\nexport function debounce(func, wait, opt) {\n if (typeof func !== 'function') {\n throw new TypeError('Expected a function');\n }\n\n let lastArgs;\n let lastThis;\n let maxWait;\n let result;\n let timerId;\n let lastCallTime;\n let lastInvokeTime = 0;\n let leading = false;\n let maxing = false;\n let trailing = true;\n\n const useRaf = (!wait && wait !== 0 && window && typeof window.requestAnimationFrame === 'function');\n\n wait = +wait || 0;\n\n if (isObject(opt)) {\n leading = !!opt.leading;\n maxing = 'maxWait' in opt;\n maxWait = maxing ? Math.max(+opt.maxWait || 0, wait) : maxWait;\n trailing = 'trailing' in opt ? !!opt.trailing : trailing;\n }\n\n function invokeFunc(time) {\n const args = lastArgs;\n const thisArg = lastThis;\n\n lastArgs = lastThis = undefined;\n lastInvokeTime = time;\n result = func.apply(thisArg, args);\n return result;\n }\n\n function startTimer(pendingFunc, wait) {\n if (useRaf) {\n window.cancelAnimationFrame(timerId);\n return window.requestAnimationFrame(pendingFunc);\n }\n return setTimeout(pendingFunc, wait);\n }\n\n function cancelTimer(id) {\n if (useRaf) {\n return window.cancelAnimationFrame(id);\n }\n clearTimeout(id);\n }\n\n function leadingEdge(time) {\n lastInvokeTime = time;\n timerId = startTimer(timerExpired, wait);\n return leading ? invokeFunc(time) : result;\n }\n\n function remainingWait(time) {\n const timeSinceLastCall = time - lastCallTime;\n const timeSinceLastInvoke = time - lastInvokeTime;\n const timeWaiting = wait - timeSinceLastCall;\n\n return maxing ? Math.min(timeWaiting, maxWait - timeSinceLastInvoke) : timeWaiting;\n }\n\n function shouldInvoke(time) {\n const timeSinceLastCall = time - lastCallTime;\n const timeSinceLastInvoke = time - lastInvokeTime;\n\n return (lastCallTime === undefined || (timeSinceLastCall >= wait) || (timeSinceLastCall < 0) ||\n (maxing && timeSinceLastInvoke >= maxWait));\n }\n\n function timerExpired() {\n const time = Date.now();\n if (shouldInvoke(time)) {\n return trailingEdge(time);\n }\n timerId = startTimer(timerExpired, remainingWait(time));\n }\n\n function trailingEdge(time) {\n timerId = undefined;\n\n if (trailing && lastArgs) {\n return invokeFunc(time);\n }\n lastArgs = lastThis = undefined;\n return result;\n }\n\n function debounced(...args) {\n const time = Date.now();\n const isInvoking = shouldInvoke(time);\n\n lastArgs = args;\n lastThis = this;\n lastCallTime = time;\n\n if (isInvoking) {\n if (timerId === undefined) {\n return leadingEdge(lastCallTime);\n }\n if (maxing) {\n timerId = startTimer(timerExpired, wait);\n return invokeFunc(lastCallTime);\n }\n }\n if (timerId === undefined) {\n timerId = startTimer(timerExpired, wait);\n }\n return result;\n }\n\n debounced.cancel = () => {\n if (timerId !== undefined) {\n cancelTimer(timerId);\n }\n lastInvokeTime = 0;\n lastArgs = lastCallTime = lastThis = timerId = undefined;\n };\n debounced.flush = () => timerId === undefined ? result : trailingEdge(Date.now());\n debounced.pending = () => timerId !== undefined;\n\n return debounced;\n}\n\nexport const groupBy = (collection, iteratee) => {\n iteratee = getIteratee(iteratee, 2);\n\n return reduce(collection, (result, value, key) => {\n key = iteratee(value);\n if (hasOwnProperty.call(result, key)) {\n result[key].push(value);\n } else {\n assignValue(result, key, [value]);\n }\n return result;\n }, {});\n};\n\nexport const sortBy = (collection, iteratees = []) => {\n if (collection == null) {\n return [];\n }\n\n const length = iteratees.length;\n if (length > 1 && isIterateeCall(collection, iteratees[0], iteratees[1])) {\n iteratees = [];\n } else if (length > 2 && isIterateeCall(iteratees[0], iteratees[1], iteratees[2])) {\n iteratees = [iteratees[0]];\n }\n\n if (!Array.isArray(iteratees)) {\n iteratees = [getIteratee(iteratees, 2)];\n }\n\n return baseOrderBy(collection, iteratees.flat(1), []);\n};\n\nexport const flattenDeep = (array) => {\n const length = array == null ? 0 : array.length;\n return length ? baseFlatten(array, Infinity) : [];\n};\n\nexport const without = (array, ...values) => isArrayLike(array) ? diff(array, values) : [];\n\nexport const difference = (array, ...values) =>\n isObjectLike(array) && isArrayLike(array) ?\n diff(array, values.flat(1)) : [];\n\nexport const intersection = (...arrays) => {\n const mapped = arrays.map((array) =>\n isObjectLike(array) && isArrayLike(array) ?\n array : []\n );\n\n return mapped.length && mapped[0] === arrays[0] ?\n intersect(mapped) : [];\n};\n\nexport const union = (...arrays) => {\n const array = arrays.flat(1);\n return uniq(array);\n};\n\nexport const has = (object, key) => {\n if (object == null) {\n return false;\n }\n\n if (typeof key === 'string') {\n key = key.split('.');\n }\n\n let index = -1;\n let value = object;\n\n while (++index < key.length) {\n if (!value || !hasOwnProperty.call(value, key[index])) {\n return false;\n }\n value = value[key[index]];\n }\n\n return true;\n};\n\nexport const result = (object, path, defaultValue) => {\n path = castPath(path, object);\n\n let index = -1;\n let length = path.length;\n\n if (!length) {\n length = 1;\n object = undefined;\n }\n while (++index < length) {\n let value = object == null ? undefined : object[toKey(path[index])];\n if (value === undefined) {\n index = length;\n value = defaultValue;\n }\n object = typeof value === 'function' ? value.call(object) : value;\n }\n return object;\n};\n\nexport const omit = (object, ...paths) => {\n let result = {};\n if (object == null) {\n return result;\n }\n let isDeep = false;\n paths = paths.flat(1).map((path) => {\n path = castPath(path, object);\n isDeep || (isDeep = path.length > 1);\n return path;\n });\n copyObject(object, getAllKeysIn(object), result);\n if (isDeep) {\n result = baseClone(result, true, true, true, (value) => isPlainObject(value) ? undefined : value);\n }\n let length = paths.length;\n while (length--) {\n unset(result, paths[length]);\n }\n return result;\n};\n\nexport const pick = (object, ...paths) => {\n return object == null ? {} : basePick(object, paths.flat(Infinity));\n};\n\nexport const bindAll = (object, ...methodNames) => {\n methodNames.flat(1).forEach((key) => {\n key = toKey(key);\n assignValue(object, key, object[key].bind(object));\n });\n return object;\n};\n\nexport const forIn = (object, iteratee = (value) => value) => {\n let index = -1;\n const iterable = Object(object);\n const props = isArrayLike(object) ? arrayLikeKeys(object, true) : keysIn(object);\n let length = props.length;\n\n while(length--) {\n const key = props[++index];\n if (iteratee(iterable[key], key, iterable) === false) {\n break;\n }\n }\n};\n\nexport const camelCase = (string = '') => (\n words(`${string}`.replace(/['\\u2019]/g, ''))\n .reduce((result, word, index) => {\n word = word.toLowerCase();\n return result + (index ? upperFirst(word) : word);\n }, '')\n);\n\nlet idCounter = 0;\n\nexport const uniqueId = (prefix = '') => {\n const id = ++idCounter;\n return `${prefix}` + id;\n};\n\nexport const merge = createAssigner((object, source, srcIndex, customizer) => {\n baseMerge(object, source, srcIndex, customizer);\n}, true);\n","class Data {\n\n constructor() {\n this.map = new WeakMap();\n }\n\n has(obj, key) {\n if (key === undefined) return this.map.has(obj);\n return key in this.map.get(obj);\n }\n\n create(obj) {\n if (!this.has(obj)) this.map.set(obj, Object.create(null));\n return this.get(obj);\n }\n\n get(obj, key) {\n if (!this.has(obj)) return undefined;\n const data = this.map.get(obj);\n if (key === undefined) return data;\n return data[key];\n }\n\n set(obj, key, value) {\n if (key === undefined) return;\n const data = this.create(obj);\n if (typeof key === 'string') {\n data[key] = value;\n } else {\n Object.assign(data, key);\n }\n }\n\n remove(obj, key) {\n if (!this.has(obj)) return;\n if (key === undefined) {\n this.map.delete(obj);\n } else {\n const data = this.map.get(obj);\n delete data[key];\n }\n }\n}\n\nexport default Data;\n\n","import Data from '../Data.mjs';\n\nexport const dataPriv = new Data();\n\nexport const dataUser = new Data();\n","export const Event = function(src, props) {\n // Allow instantiation without the 'new' keyword\n if (!(this instanceof Event)) {\n return new Event(src, props);\n }\n\n // Event object\n if (src && src.type) {\n this.originalEvent = src;\n this.type = src.type;\n\n // Events bubbling up the document may have been marked as prevented\n // by a handler lower down the tree; reflect the correct value.\n this.isDefaultPrevented = src.defaultPrevented\n ? returnTrue\n : returnFalse;\n\n // Create target properties\n this.target = src.target;\n this.currentTarget = src.currentTarget;\n this.relatedTarget = src.relatedTarget;\n\n // Event type\n } else {\n this.type = src;\n }\n\n // Put explicitly provided properties onto the event object\n if (props) {\n Object.assign(this, props);\n }\n\n // Create a timestamp if incoming event doesn't have one\n this.timeStamp = (src && src.timeStamp) || Date.now();\n\n // Mark it as fixed\n this.envelope = true;\n};\n\n// $.Event is based on DOM3 Events as specified by the ECMAScript Language Binding\n// https://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html\nEvent.prototype = {\n constructor: Event,\n isDefaultPrevented: returnFalse,\n isPropagationStopped: returnFalse,\n isImmediatePropagationStopped: returnFalse,\n preventDefault: function() {\n const evt = this.originalEvent;\n this.isDefaultPrevented = returnTrue;\n if (evt) {\n evt.preventDefault();\n }\n },\n stopPropagation: function() {\n const evt = this.originalEvent;\n this.isPropagationStopped = returnTrue;\n if (evt) {\n evt.stopPropagation();\n }\n },\n stopImmediatePropagation: function() {\n const evt = this.originalEvent;\n this.isImmediatePropagationStopped = returnTrue;\n if (evt) {\n evt.stopImmediatePropagation();\n }\n this.stopPropagation();\n },\n};\n\n// Includes all common event props including KeyEvent and MouseEvent specific props\n[\n 'altKey',\n 'bubbles',\n 'cancelable',\n 'changedTouches',\n 'ctrlKey',\n 'detail',\n 'eventPhase',\n 'metaKey',\n 'pageX',\n 'pageY',\n 'shiftKey',\n 'view',\n 'char',\n 'code',\n 'charCode',\n 'key',\n 'keyCode',\n 'button',\n 'buttons',\n 'clientX',\n 'clientY',\n 'offsetX',\n 'offsetY',\n 'pointerId',\n 'pointerType',\n 'screenX',\n 'screenY',\n 'targetTouches',\n 'toElement',\n 'touches',\n 'which',\n].forEach((name) => addProp(name));\n\nfunction addProp(name) {\n Object.defineProperty(Event.prototype, name, {\n enumerable: true,\n configurable: true,\n get: function() {\n return this.originalEvent ? this.originalEvent[name] : undefined;\n },\n set: function(value) {\n Object.defineProperty(this, name, {\n enumerable: true,\n configurable: true,\n writable: true,\n value: value,\n });\n },\n });\n}\n\nfunction returnTrue() {\n return true;\n}\n\nfunction returnFalse() {\n return false;\n}\n","\n/*!\n * jQuery JavaScript Library v4.0.0-pre+c98597ea.dirty\n * https://jquery.com/\n *\n * Copyright OpenJS Foundation and other contributors\n * Released under the MIT license\n * https://jquery.org/license\n *\n * Date: 2023-11-24T14:04Z\n */\n\nimport { uniq, isEmpty } from '../../util/utilHelpers.mjs';\nimport { dataPriv, dataUser } from './vars.mjs';\nimport { Event } from './Event.mjs';\n\nconst document = (typeof window !== 'undefined') ? window.document : null;\nconst documentElement = document && document.documentElement;\n\nconst rTypeNamespace = /^([^.]*)(?:\\.(.+)|)/;\n\n// Only count HTML whitespace\n// Other whitespace should count in values\n// https://infra.spec.whatwg.org/#ascii-whitespace\nconst rNotHtmlWhite = /[^\\x20\\t\\r\\n\\f]+/g;\n\n// Define a local copy of $\nconst $ = function(selector) {\n // The $ object is actually just the init constructor 'enhanced'\n // Need init if $ is called (just allow error to be thrown if not included)\n return new $.Dom(selector);\n};\n\n$.fn = $.prototype = {\n constructor: $,\n // The default length of a $ object is 0\n length: 0,\n};\n\n// A global GUID counter for objects\n$.guid = 1;\n\n// User data storage\n$.data = dataUser;\n\n$.merge = function(first, second) {\n let len = +second.length;\n let i = first.length;\n for (let j = 0; j < len; j++) {\n first[i++] = second[j];\n }\n first.length = i;\n return first;\n};\n\n$.parseHTML = function(string) {\n // Inline events will not execute when the HTML is parsed; this includes, for example, sending GET requests for images.\n const context = document.implementation.createHTMLDocument();\n // Set the base href for the created document so any parsed elements with URLs\n // are based on the document's URL\n const base = context.createElement('base');\n base.href = document.location.href;\n context.head.appendChild(base);\n\n context.body.innerHTML = string;\n // remove scripts\n const scripts = context.getElementsByTagName('script');\n for (let i = 0; i < scripts.length; i++) {\n scripts[i].remove();\n }\n return Array.from(context.body.childNodes);\n};\n\nif (typeof Symbol === 'function') {\n $.fn[Symbol.iterator] = Array.prototype[Symbol.iterator];\n}\n\n$.fn.toArray = function() {\n return Array.from(this);\n};\n\n// Take an array of elements and push it onto the stack\n// (returning the new matched element set)\n$.fn.pushStack = function(elements) {\n // Build a new $ matched element set\n const ret = $.merge(this.constructor(), elements);\n // Add the old object onto the stack (as a reference)\n ret.prevObject = this;\n // Return the newly-formed element set\n return ret;\n};\n\n$.fn.find = function(selector) {\n const [el] = this;\n const ret = this.pushStack([]);\n if (!el) return ret;\n // Early return if context is not an element, document or document fragment\n const { nodeType } = el;\n if (nodeType !== 1 && nodeType !== 9 && nodeType !== 11) {\n return ret;\n }\n if (typeof selector !== 'string') {\n if (el !== selector && el.contains(selector)) {\n $.merge(ret, [selector]);\n }\n } else {\n $.merge(ret, el.querySelectorAll(selector));\n }\n return ret;\n};\n\n$.fn.add = function(selector, context) {\n const newElements = $(selector, context).toArray();\n const prevElements = this.toArray();\n const ret = this.pushStack([]);\n $.merge(ret, uniq(prevElements.concat(newElements)));\n return ret;\n};\n\n$.fn.addBack = function() {\n return this.add(this.prevObject);\n};\n\n$.fn.filter = function(selector) {\n const matches = [];\n for (let i = 0; i < this.length; i++) {\n const node = this[i];\n if (!node.matches(selector)) continue;\n matches.push(node);\n }\n return this.pushStack(matches);\n};\n\n// A simple way to check for HTML strings\n// Prioritize #id over to avoid XSS via location.hash (trac-9521)\n// Strict HTML recognition (trac-11290: must start with <)\n// Shortcut simple #id case for speed\nconst rQuickExpr = /^(?:\\s*(<[\\w\\W]+>)[^>]*|#([\\w-]+))$/;\n\nfunction isObviousHtml(input) {\n return (\n input[0] === '<' && input[input.length - 1] === '>' && input.length >= 3\n );\n}\n\nconst Dom = function(selector) {\n if (!selector) {\n // HANDLE: $(\"\"), $(null), $(undefined), $(false)\n return this;\n }\n if (typeof selector === 'function') {\n // HANDLE: $(function)\n // Shortcut for document ready\n throw new Error('function not supported');\n }\n if (arguments.length > 1) {\n throw new Error('selector with context not supported');\n }\n if (selector.nodeType) {\n // HANDLE: $(DOMElement)\n this[0] = selector;\n this.length = 1;\n return this;\n }\n let match;\n if (isObviousHtml(selector + '')) {\n // Handle obvious HTML strings\n // Assume that strings that start and end with <> are HTML and skip\n // the regex check. This also handles browser-supported HTML wrappers\n // like TrustedHTML.\n match = [null, selector, null];\n } else if (typeof selector === 'string') {\n // Handle HTML strings or selectors\n match = rQuickExpr.exec(selector);\n } else {\n // Array-like\n return $.merge(this, selector);\n }\n if (!match || !match[1]) {\n // HANDLE: $(expr)\n return $root.find(selector);\n }\n // Match html or make sure no context is specified for #id\n // Note: match[1] may be a string or a TrustedHTML wrapper\n if (match[1]) {\n // HANDLE: $(html) -> $(array)\n $.merge(this, $.parseHTML(match[1]));\n return this;\n }\n // HANDLE: $(#id)\n const el = document.getElementById(match[2]);\n if (el) {\n // Inject the element directly into the $ object\n this[0] = el;\n this.length = 1;\n }\n return this;\n};\n\n$.Dom = Dom;\n\n// Give the init function the $ prototype for later instantiation\nDom.prototype = $.fn;\n\n// Events\n\n$.Event = Event;\n\n$.event = {\n special: Object.create(null),\n};\n\n$.event.has = function(elem, eventType) {\n const events = dataPriv.get(elem, 'events');\n if (!events) return false;\n if (!eventType) return true;\n return Array.isArray(events[eventType]) && events[eventType].length > 0;\n};\n\n$.event.on = function(elem, types, selector, data, fn, one) {\n\n // Types can be a map of types/handlers\n if (typeof types === 'object') {\n // ( types-Object, selector, data )\n if (typeof selector !== 'string') {\n // ( types-Object, data )\n data = data || selector;\n selector = undefined;\n }\n for (let type in types) {\n $.event.on(elem, type, selector, data, types[type], one);\n }\n return elem;\n }\n\n if (data == null && fn == null) {\n // ( types, fn )\n fn = selector;\n data = selector = undefined;\n } else if (fn == null) {\n if (typeof selector === 'string') {\n // ( types, selector, fn )\n fn = data;\n data = undefined;\n } else {\n // ( types, data, fn )\n fn = data;\n data = selector;\n selector = undefined;\n }\n }\n if (!fn) {\n return elem;\n }\n if (one === 1) {\n const origFn = fn;\n fn = function(event) {\n // Can use an empty set, since event contains the info\n $().off(event);\n return origFn.apply(this, arguments);\n };\n\n // Use same guid so caller can remove using origFn\n fn.guid = origFn.guid || (origFn.guid = $.guid++);\n }\n for (let i = 0; i < elem.length; i++) {\n $.event.add(elem[i], types, fn, data, selector);\n }\n};\n\n$.event.add = function(elem, types, handler, data, selector) {\n // Only attach events to objects for which we can store data\n if (typeof elem != 'object') {\n return;\n }\n\n const elemData = dataPriv.create(elem);\n\n // Caller can pass in an object of custom data in lieu of the handler\n let handleObjIn;\n if (handler.handler) {\n handleObjIn = handler;\n handler = handleObjIn.handler;\n selector = handleObjIn.selector;\n }\n\n // Ensure that invalid selectors throw exceptions at attach time\n // Evaluate against documentElement in case elem is a non-element node (e.g., document)\n if (selector) {\n documentElement.matches(selector);\n }\n\n // Make sure that the handler has a unique ID, used to find/remove it later\n if (!handler.guid) {\n handler.guid = $.guid++;\n }\n\n // Init the element's event structure and main handler, if this is the first\n let events;\n if (!(events = elemData.events)) {\n events = elemData.events = Object.create(null);\n }\n let eventHandle;\n if (!(eventHandle = elemData.handle)) {\n eventHandle = elemData.handle = function(e) {\n // Discard the second event of a $.event.trigger() and\n // when an event is called after a page has unloaded\n return (typeof $ !== 'undefined')\n ? $.event.dispatch.apply(elem, arguments)\n : undefined;\n };\n }\n\n // Handle multiple events separated by a space\n const typesArr = (types || '').match(rNotHtmlWhite) || [''];\n let i = typesArr.length;\n while (i--) {\n const [, origType, ns = ''] = rTypeNamespace.exec(typesArr[i]);\n // There *must* be a type, no attaching namespace-only handlers\n if (!origType) {\n continue;\n }\n\n const namespaces = ns.split('.').sort();\n // If event changes its type, use the special event handlers for the changed type\n let special = $.event.special[origType];\n // If selector defined, determine special event api type, otherwise given type\n const type = (special && (selector ? special.delegateType : special.bindType)) || origType;\n // Update special based on newly reset type\n special = $.event.special[type];\n // handleObj is passed to all event handlers\n const handleObj = Object.assign(\n {\n type: type,\n origType: origType,\n data: data,\n handler: handler,\n guid: handler.guid,\n selector: selector,\n namespace: namespaces.join('.'),\n },\n handleObjIn\n );\n\n let handlers;\n // Init the event handler queue if we're the first\n if (!(handlers = events[type])) {\n handlers = events[type] = [];\n handlers.delegateCount = 0;\n\n // Only use addEventListener if the special events handler returns false\n if (\n !special || !special.setup ||\n special.setup.call(elem, data, namespaces, eventHandle) === false\n ) {\n if (elem.addEventListener) {\n elem.addEventListener(type, eventHandle);\n }\n }\n }\n\n if (special && special.add) {\n special.add.call(elem, handleObj);\n if (!handleObj.handler.guid) {\n handleObj.handler.guid = handler.guid;\n }\n }\n\n // Add to the element's handler list, delegates in front\n if (selector) {\n handlers.splice(handlers.delegateCount++, 0, handleObj);\n } else {\n handlers.push(handleObj);\n }\n }\n};\n\n// Detach an event or set of events from an element\n$.event.remove = function(elem, types, handler, selector, mappedTypes) {\n\n const elemData = dataPriv.get(elem);\n if (!elemData || !elemData.events) return;\n const events = elemData.events;\n\n // Once for each type.namespace in types; type may be omitted\n const typesArr = (types || '').match(rNotHtmlWhite) || [''];\n let i = typesArr.length;\n while (i--) {\n const [, origType, ns = ''] = rTypeNamespace.exec(typesArr[i]);\n // Unbind all events (on this namespace, if provided) for the element\n if (!origType) {\n for (const type in events) {\n $.event.remove(\n elem,\n type + typesArr[i],\n handler,\n selector,\n true\n );\n }\n continue;\n }\n\n const special = $.event.special[origType];\n const type = (special && (selector ? special.delegateType : special.bindType)) || origType;\n const handlers = events[type];\n if (!handlers || handlers.length === 0) continue;\n\n const namespaces = ns.split('.').sort();\n const rNamespace = ns\n ? new RegExp('(^|\\\\.)' + namespaces.join('\\\\.(?:.*\\\\.|)') + '(\\\\.|$)')\n : null;\n\n // Remove matching events\n const origCount = handlers.length;\n let j = origCount;\n while (j--) {\n const handleObj = handlers[j];\n\n if (\n (mappedTypes || origType === handleObj.origType) &&\n (!handler || handler.guid === handleObj.guid) &&\n (!rNamespace || rNamespace.test(handleObj.namespace)) &&\n (!selector ||\n selector === handleObj.selector ||\n (selector === '**' && handleObj.selector))\n ) {\n handlers.splice(j, 1);\n if (handleObj.selector) {\n handlers.delegateCount--;\n }\n if (special && special.remove) {\n special.remove.call(elem, handleObj);\n }\n }\n }\n\n // Remove generic event handler if we removed something and no more handlers exist\n // (avoids potential for endless recursion during removal of special event handlers)\n if (origCount && handlers.length === 0) {\n if (\n !special || !special.teardown ||\n special.teardown.call(elem, namespaces, elemData.handle) === false\n ) {\n // This \"if\" is needed for plain objects\n if (elem.removeEventListener) {\n elem.removeEventListener(type, elemData.handle);\n }\n }\n delete events[type];\n }\n }\n\n // Remove data if it's no longer used\n if (isEmpty(events)) {\n dataPriv.remove(elem, 'handle');\n dataPriv.remove(elem, 'events');\n }\n};\n\n$.event.dispatch = function(nativeEvent) {\n\n const elem = this;\n // Make a writable $.Event from the native event object\n const event = $.event.fix(nativeEvent);\n event.delegateTarget = elem;\n // Use the fix-ed $.Event rather than the (read-only) native event\n const args = Array.from(arguments);\n args[0] = event;\n\n const eventsData = dataPriv.get(elem, 'events');\n const handlers = (eventsData && eventsData[event.type]) || [];\n const special = $.event.special[event.type];\n\n // Call the preDispatch hook for the mapped type, and let it bail if desired\n if (special && special.preDispatch) {\n if (special.preDispatch.call(elem, event) === false) return;\n }\n\n // Determine handlers\n const handlerQueue = $.event.handlers.call(elem, event, handlers);\n\n // Run delegates first; they may want to stop propagation beneath us\n let i = 0;\n let matched;\n while ((matched = handlerQueue[i++]) && !event.isPropagationStopped()) {\n event.currentTarget = matched.elem;\n let j = 0;\n let handleObj;\n while (\n (handleObj = matched.handlers[j++]) &&\n !event.isImmediatePropagationStopped()\n ) {\n\n event.handleObj = handleObj;\n event.data = handleObj.data;\n\n const origSpecial = $.event.special[handleObj.origType];\n let handler;\n if (origSpecial && origSpecial.handle) {\n handler = origSpecial.handle;\n } else {\n handler = handleObj.handler;\n }\n\n const ret = handler.apply(matched.elem, args);\n if (ret !== undefined) {\n if ((event.result = ret) === false) {\n event.preventDefault();\n event.stopPropagation();\n }\n }\n }\n }\n\n // Call the postDispatch hook for the mapped type\n if (special && special.postDispatch) {\n special.postDispatch.call(elem, event);\n }\n\n return event.result;\n};\n\n$.event.handlers = function(event, handlers) {\n\n const delegateCount = handlers.delegateCount;\n const handlerQueue = [];\n\n // Find delegate handlers\n if (\n delegateCount &&\n // Support: Firefox <=42 - 66+\n // Suppress spec-violating clicks indicating a non-primary pointer button (trac-3861)\n // https://www.w3.org/TR/DOM-Level-3-Events/#event-type-click\n // Support: IE 11+\n // ...but not arrow key \"clicks\" of radio inputs, which can have `button` -1 (gh-2343)\n !(event.type === 'click' && event.button >= 1)\n ) {\n for (let cur = event.target; cur !== this; cur = cur.parentNode || this) {\n // Don't check non-elements (trac-13208)\n // Don't process clicks on disabled elements (trac-6911, trac-8165, trac-11382, trac-11764)\n if (\n cur.nodeType === 1 &&\n !(event.type === 'click' && cur.disabled === true)\n ) {\n const matchedHandlers = [];\n const matchedSelectors = {};\n for (let i = 0; i < delegateCount; i++) {\n const handleObj = handlers[i];\n // Don't conflict with Object.prototype properties (trac-13203)\n const sel = handleObj.selector + ' ';\n if (matchedSelectors[sel] === undefined) {\n matchedSelectors[sel] = cur.matches(sel);\n }\n if (matchedSelectors[sel]) {\n matchedHandlers.push(handleObj);\n }\n }\n if (matchedHandlers.length) {\n handlerQueue.push({\n elem: cur,\n handlers: matchedHandlers,\n });\n }\n }\n }\n }\n\n // Add the remaining (directly-bound) handlers\n if (delegateCount < handlers.length) {\n handlerQueue.push({\n elem: this,\n handlers: handlers.slice(delegateCount),\n });\n }\n\n return handlerQueue;\n};\n\n$.event.fix = function(originalEvent) {\n return originalEvent.envelope ? originalEvent : new Event(originalEvent);\n};\n\n// A central reference to the root $(document)\nconst $root = $(document);\n\nexport { $ as default };\n","// Declare shorthands to the most used math functions.\nconst {\n round,\n floor,\n PI\n} = Math;\n\nexport const scale = {\n\n // Return the `value` from the `domain` interval scaled to the `range` interval.\n linear: function(domain, range, value) {\n\n var domainSpan = domain[1] - domain[0];\n var rangeSpan = range[1] - range[0];\n return (((value - domain[0]) / domainSpan) * rangeSpan + range[0]) || 0;\n }\n};\n\nexport const normalizeAngle = function(angle) {\n\n return (angle % 360) + (angle < 0 ? 360 : 0);\n};\n\nexport const snapToGrid = function(value, gridSize) {\n\n return gridSize * round(value / gridSize);\n};\n\nexport const toDeg = function(rad) {\n\n return (180 * rad / PI) % 360;\n};\n\nexport const toRad = function(deg, over360) {\n\n over360 = over360 || false;\n deg = over360 ? deg : (deg % 360);\n return deg * PI / 180;\n};\n\n// Return a random integer from the interval [min,max], inclusive.\nexport const random = function(min, max) {\n\n if (max === undefined) {\n // use first argument as max, min is 0\n max = (min === undefined) ? 1 : min;\n min = 0;\n\n } else if (max < min) {\n // switch max and min\n const temp = min;\n min = max;\n max = temp;\n }\n\n return floor((Math.random() * (max - min + 1)) + min);\n};\n\n","// @return the bearing (cardinal direction) of the line. For example N, W, or SE.\n// @returns {String} One of the following bearings : NE, E, SE, S, SW, W, NW, N.\nimport { toDeg, toRad } from './geometry.helpers.mjs';\n\nconst {\n cos,\n sin,\n atan2\n} = Math;\n\nexport const bearing = function(p, q) {\n\n var lat1 = toRad(p.y);\n var lat2 = toRad(q.y);\n var lon1 = p.x;\n var lon2 = q.x;\n var dLon = toRad(lon2 - lon1);\n var y = sin(dLon) * cos(lat2);\n var x = cos(lat1) * sin(lat2) - sin(lat1) * cos(lat2) * cos(dLon);\n var brng = toDeg(atan2(y, x));\n\n var bearings = ['NE', 'E', 'SE', 'S', 'SW', 'W', 'NW', 'N'];\n\n var index = brng - 22.5;\n if (index < 0)\n index += 360;\n index = parseInt(index / 45);\n\n return bearings[index];\n};\n","// @return {integer} length without sqrt\n// @note for applications where the exact length is not necessary (e.g. compare only)\nexport const squaredLength = function(start, end) {\n\n var x0 = start.x;\n var y0 = start.y;\n var x1 = end.x;\n var y1 = end.y;\n return (x0 -= x1) * x0 + (y0 -= y1) * y0;\n};\n","import { squaredLength } from './line.squaredLength.mjs';\n\nexport const length = function(start, end) {\n return Math.sqrt(squaredLength(start, end));\n};\n","export const types = {\n Point: 1,\n Line: 2,\n Ellipse: 3,\n Rect: 4,\n Polyline: 5,\n Polygon: 6,\n Curve: 7,\n Path: 8\n};\n","/*\n Point is the most basic object consisting of x/y coordinate.\n\n Possible instantiations are:\n * `Point(10, 20)`\n * `new Point(10, 20)`\n * `Point('10 20')`\n * `Point(Point(10, 20))`\n*/\nimport { normalizeAngle, random, snapToGrid, toDeg, toRad } from './geometry.helpers.mjs';\nimport { bearing } from './line.bearing.mjs';\nimport { squaredLength } from './line.squaredLength.mjs';\nimport { length } from './line.length.mjs';\nimport { types } from './types.mjs';\n\nconst {\n abs,\n cos,\n sin,\n sqrt,\n min,\n max,\n atan2,\n round,\n pow,\n PI\n} = Math;\n\nexport const Point = function(x, y) {\n\n if (!(this instanceof Point)) {\n return new Point(x, y);\n }\n\n if (typeof x === 'string') {\n var xy = x.split(x.indexOf('@') === -1 ? ' ' : '@');\n x = parseFloat(xy[0]);\n y = parseFloat(xy[1]);\n\n } else if (Object(x) === x) {\n y = x.y;\n x = x.x;\n }\n\n this.x = x === undefined ? 0 : x;\n this.y = y === undefined ? 0 : y;\n};\n\n// Alternative constructor, from polar coordinates.\n// @param {number} Distance.\n// @param {number} Angle in radians.\n// @param {point} [optional] Origin.\nPoint.fromPolar = function(distance, angle, origin) {\n\n origin = new Point(origin);\n var x = abs(distance * cos(angle));\n var y = abs(distance * sin(angle));\n var deg = normalizeAngle(toDeg(angle));\n\n if (deg < 90) {\n y = -y;\n\n } else if (deg < 180) {\n x = -x;\n y = -y;\n\n } else if (deg < 270) {\n x = -x;\n }\n\n return new Point(origin.x + x, origin.y + y);\n};\n\n// Create a point with random coordinates that fall into the range `[x1, x2]` and `[y1, y2]`.\nPoint.random = function(x1, x2, y1, y2) {\n\n return new Point(random(x1, x2), random(y1, y2));\n};\n\nPoint.prototype = {\n\n type: types.Point,\n\n chooseClosest: function(points) {\n\n var n = points.length;\n if (n === 1) return new Point(points[0]);\n var closest = null;\n var minSqrDistance = Infinity;\n for (var i = 0; i < n; i++) {\n var p = new Point(points[i]);\n var sqrDistance = this.squaredDistance(p);\n if (sqrDistance < minSqrDistance) {\n closest = p;\n minSqrDistance = sqrDistance;\n }\n }\n return closest;\n },\n\n // If point lies outside rectangle `r`, return the nearest point on the boundary of rect `r`,\n // otherwise return point itself.\n // (see Squeak Smalltalk, Point>>adhereTo:)\n adhereToRect: function(r) {\n\n if (r.containsPoint(this)) {\n return this;\n }\n\n this.x = min(max(this.x, r.x), r.x + r.width);\n this.y = min(max(this.y, r.y), r.y + r.height);\n return this;\n },\n\n // Compute the angle between vector from me to p1 and the vector from me to p2.\n // ordering of points p1 and p2 is important!\n // theta function's angle convention:\n // returns angles between 0 and 180 when the angle is counterclockwise\n // returns angles between 180 and 360 to convert clockwise angles into counterclockwise ones\n // returns NaN if any of the points p1, p2 is coincident with this point\n angleBetween: function(p1, p2) {\n\n var angleBetween = (this.equals(p1) || this.equals(p2)) ? NaN : (this.theta(p2) - this.theta(p1));\n\n if (angleBetween < 0) {\n angleBetween += 360; // correction to keep angleBetween between 0 and 360\n }\n\n return angleBetween;\n },\n\n // Return the bearing between me and the given point.\n bearing: function(point) {\n return bearing(this, point);\n },\n\n // Returns change in angle from my previous position (-dx, -dy) to my new position\n // relative to ref point.\n changeInAngle: function(dx, dy, ref) {\n\n // Revert the translation and measure the change in angle around x-axis.\n return this.clone().offset(-dx, -dy).theta(ref) - this.theta(ref);\n },\n\n clone: function() {\n\n return new Point(this);\n },\n\n // Returns the cross product of this point relative to two other points\n // this point is the common point\n // point p1 lies on the first vector, point p2 lies on the second vector\n // watch out for the ordering of points p1 and p2!\n // positive result indicates a clockwise (\"right\") turn from first to second vector\n // negative result indicates a counterclockwise (\"left\") turn from first to second vector\n // zero indicates that the first and second vector are collinear\n // note that the above directions are reversed from the usual answer on the Internet\n // that is because we are in a left-handed coord system (because the y-axis points downward)\n cross: function(p1, p2) {\n\n return (p1 && p2) ? (((p2.x - this.x) * (p1.y - this.y)) - ((p2.y - this.y) * (p1.x - this.x))) : NaN;\n },\n\n difference: function(dx, dy) {\n\n if ((Object(dx) === dx)) {\n dy = dx.y;\n dx = dx.x;\n }\n\n return new Point(this.x - (dx || 0), this.y - (dy || 0));\n },\n\n // Returns distance between me and point `p`.\n distance: function(p) {\n return length(this, p);\n },\n\n // Returns the dot product of this point with given other point\n dot: function(p) {\n\n return p ? (this.x * p.x + this.y * p.y) : NaN;\n },\n\n equals: function(p) {\n\n return !!p &&\n this.x === p.x &&\n this.y === p.y;\n },\n\n // Linear interpolation\n lerp: function(p, t) {\n\n var x = this.x;\n var y = this.y;\n return new Point((1 - t) * x + t * p.x, (1 - t) * y + t * p.y);\n },\n\n magnitude: function() {\n\n return sqrt((this.x * this.x) + (this.y * this.y)) || 0.01;\n },\n\n // Returns a manhattan (taxi-cab) distance between me and point `p`.\n manhattanDistance: function(p) {\n\n return abs(p.x - this.x) + abs(p.y - this.y);\n },\n\n // Move point on line starting from ref ending at me by\n // distance distance.\n move: function(ref, distance) {\n\n var theta = toRad((new Point(ref)).theta(this));\n var offset = this.offset(cos(theta) * distance, -sin(theta) * distance);\n return offset;\n },\n\n // Scales x and y such that the distance between the point and the origin (0,0) is equal to the given length.\n normalize: function(length) {\n\n var scale = (length || 1) / this.magnitude();\n return this.scale(scale, scale);\n },\n\n // Offset me by the specified amount.\n offset: function(dx, dy) {\n\n if ((Object(dx) === dx)) {\n dy = dx.y;\n dx = dx.x;\n }\n\n this.x += dx || 0;\n this.y += dy || 0;\n return this;\n },\n\n // Returns a point that is the reflection of me with\n // the center of inversion in ref point.\n reflection: function(ref) {\n\n return (new Point(ref)).move(this, this.distance(ref));\n },\n\n // Rotate point by angle around origin.\n // Angle is flipped because this is a left-handed coord system (y-axis points downward).\n rotate: function(origin, angle) {\n\n if (angle === 0) return this;\n\n origin = origin || new Point(0, 0);\n\n angle = toRad(normalizeAngle(-angle));\n var cosAngle = cos(angle);\n var sinAngle = sin(angle);\n\n var x = (cosAngle * (this.x - origin.x)) - (sinAngle * (this.y - origin.y)) + origin.x;\n var y = (sinAngle * (this.x - origin.x)) + (cosAngle * (this.y - origin.y)) + origin.y;\n\n this.x = x;\n this.y = y;\n return this;\n },\n\n round: function(precision) {\n\n let f = 1; // case 0\n if (precision) {\n switch (precision) {\n case 1: f = 10; break;\n case 2: f = 100; break;\n case 3: f = 1000; break;\n default: f = pow(10, precision); break;\n }\n }\n\n this.x = round(this.x * f) / f;\n this.y = round(this.y * f) / f;\n return this;\n },\n\n // Scale point with origin.\n scale: function(sx, sy, origin) {\n\n origin = (origin && new Point(origin)) || new Point(0, 0);\n this.x = origin.x + sx * (this.x - origin.x);\n this.y = origin.y + sy * (this.y - origin.y);\n return this;\n },\n\n snapToGrid: function(gx, gy) {\n\n this.x = snapToGrid(this.x, gx);\n this.y = snapToGrid(this.y, gy || gx);\n return this;\n },\n\n squaredDistance: function(p) {\n return squaredLength(this, p);\n },\n\n // Compute the angle between me and `p` and the x axis.\n // (cartesian-to-polar coordinates conversion)\n // Return theta angle in degrees.\n theta: function(p) {\n\n p = new Point(p);\n\n // Invert the y-axis.\n var y = -(p.y - this.y);\n var x = p.x - this.x;\n var rad = atan2(y, x); // defined for all 0 corner cases\n\n // Correction for III. and IV. quadrant.\n if (rad < 0) {\n rad = 2 * PI + rad;\n }\n\n return 180 * rad / PI;\n },\n\n toJSON: function() {\n\n return { x: this.x, y: this.y };\n },\n\n // Converts rectangular to polar coordinates.\n // An origin can be specified, otherwise it's 0@0.\n toPolar: function(o) {\n\n o = (o && new Point(o)) || new Point(0, 0);\n var x = this.x;\n var y = this.y;\n this.x = sqrt((x - o.x) * (x - o.x) + (y - o.y) * (y - o.y)); // r\n this.y = toRad(o.theta(new Point(x, y)));\n return this;\n },\n\n toString: function() {\n\n return this.x + '@' + this.y;\n },\n\n serialize: function() {\n\n return this.x + ',' + this.y;\n },\n\n update: function(x, y) {\n\n if ((Object(x) === x)) {\n y = x.y;\n x = x.x;\n }\n\n this.x = x || 0;\n this.y = y || 0;\n return this;\n },\n\n // Compute the angle between the vector from 0,0 to me and the vector from 0,0 to p.\n // Returns NaN if p is at 0,0.\n vectorAngle: function(p) {\n\n var zero = new Point(0, 0);\n return zero.angleBetween(this, p);\n }\n};\n\nPoint.prototype.translate = Point.prototype.offset;\n\n// For backwards compatibility:\nexport const point = Point;\n","import { Point } from './point.mjs';\nimport { Rect } from './rect.mjs';\nimport { bearing } from './line.bearing.mjs';\nimport { squaredLength } from './line.squaredLength.mjs';\nimport { length } from './line.length.mjs';\nimport { types } from './types.mjs';\n\nconst {\n max,\n min\n} = Math;\n\nexport const Line = function(p1, p2) {\n\n if (!(this instanceof Line)) {\n return new Line(p1, p2);\n }\n\n if (p1 instanceof Line) {\n return new Line(p1.start, p1.end);\n }\n\n this.start = new Point(p1);\n this.end = new Point(p2);\n};\n\nLine.prototype = {\n\n type: types.Line,\n\n // @returns the angle of incline of the line.\n angle: function() {\n\n var horizontalPoint = new Point(this.start.x + 1, this.start.y);\n return this.start.angleBetween(this.end, horizontalPoint);\n },\n\n bbox: function() {\n\n var left = min(this.start.x, this.end.x);\n var top = min(this.start.y, this.end.y);\n var right = max(this.start.x, this.end.x);\n var bottom = max(this.start.y, this.end.y);\n\n return new Rect(left, top, (right - left), (bottom - top));\n },\n\n // @return the bearing (cardinal direction) of the line. For example N, W, or SE.\n // @returns {String} One of the following bearings : NE, E, SE, S, SW, W, NW, N.\n bearing: function() {\n return bearing(this.start, this.end);\n },\n\n clone: function() {\n\n return new Line(this.start, this.end);\n },\n\n // @return {point} the closest point on the line to point `p`\n closestPoint: function(p) {\n\n return this.pointAt(this.closestPointNormalizedLength(p));\n },\n\n closestPointLength: function(p) {\n\n return this.closestPointNormalizedLength(p) * this.length();\n },\n\n // @return {number} the normalized length of the closest point on the line to point `p`\n closestPointNormalizedLength: function(p) {\n\n var product = this.vector().dot((new Line(this.start, p)).vector());\n var cpNormalizedLength = min(1, max(0, product / this.squaredLength()));\n\n // cpNormalizedLength returns `NaN` if this line has zero length\n // we can work with that - if `NaN`, return 0\n if (cpNormalizedLength !== cpNormalizedLength) return 0; // condition evaluates to `true` if and only if cpNormalizedLength is `NaN`\n // (`NaN` is the only value that is not equal to itself)\n\n return cpNormalizedLength;\n },\n\n closestPointTangent: function(p) {\n\n return this.tangentAt(this.closestPointNormalizedLength(p));\n },\n\n // Returns `true` if the point lies on the line.\n containsPoint: function(p) {\n\n var start = this.start;\n var end = this.end;\n\n if (start.cross(p, end) !== 0) return false;\n // else: cross product of 0 indicates that this line and the vector to `p` are collinear\n\n var length = this.length();\n if ((new Line(start, p)).length() > length) return false;\n if ((new Line(p, end)).length() > length) return false;\n // else: `p` lies between start and end of the line\n\n return true;\n },\n\n // Divides the line into two at requested `ratio` between 0 and 1.\n divideAt: function(ratio) {\n\n var dividerPoint = this.pointAt(ratio);\n\n // return array with two lines\n return [\n new Line(this.start, dividerPoint),\n new Line(dividerPoint, this.end)\n ];\n },\n\n // Divides the line into two at requested `length`.\n divideAtLength: function(length) {\n\n var dividerPoint = this.pointAtLength(length);\n\n // return array with two new lines\n return [\n new Line(this.start, dividerPoint),\n new Line(dividerPoint, this.end)\n ];\n },\n\n equals: function(l) {\n\n return !!l &&\n this.start.x === l.start.x &&\n this.start.y === l.start.y &&\n this.end.x === l.end.x &&\n this.end.y === l.end.y;\n },\n\n // @return {point} Point where I'm intersecting a line.\n // @return [point] Points where I'm intersecting a rectangle.\n // @see Squeak Smalltalk, LineSegment>>intersectionWith:\n intersect: function(shape, opt) {\n\n if (shape && shape.intersectionWithLine) {\n var intersection = shape.intersectionWithLine(this, opt);\n\n // Backwards compatibility\n if (intersection && (shape instanceof Line)) {\n intersection = intersection[0];\n }\n\n return intersection;\n }\n\n return null;\n },\n\n intersectionWithLine: function(line) {\n\n var pt1Dir = new Point(this.end.x - this.start.x, this.end.y - this.start.y);\n var pt2Dir = new Point(line.end.x - line.start.x, line.end.y - line.start.y);\n var det = (pt1Dir.x * pt2Dir.y) - (pt1Dir.y * pt2Dir.x);\n var deltaPt = new Point(line.start.x - this.start.x, line.start.y - this.start.y);\n var alpha = (deltaPt.x * pt2Dir.y) - (deltaPt.y * pt2Dir.x);\n var beta = (deltaPt.x * pt1Dir.y) - (deltaPt.y * pt1Dir.x);\n\n if (det === 0 || alpha * det < 0 || beta * det < 0) {\n // No intersection found.\n return null;\n }\n\n if (det > 0) {\n if (alpha > det || beta > det) {\n return null;\n }\n\n } else {\n if (alpha < det || beta < det) {\n return null;\n }\n }\n\n return [new Point(\n this.start.x + (alpha * pt1Dir.x / det),\n this.start.y + (alpha * pt1Dir.y / det)\n )];\n },\n\n isDifferentiable: function() {\n\n return !this.start.equals(this.end);\n },\n\n // @return {double} length of the line\n length: function() {\n return length(this.start, this.end);\n },\n\n // @return {point} my midpoint\n midpoint: function() {\n\n return new Point(\n (this.start.x + this.end.x) / 2,\n (this.start.y + this.end.y) / 2\n );\n },\n\n parallel: function(distance) {\n const l = this.clone();\n if (!this.isDifferentiable()) return l;\n const { start, end } = l;\n const eRef = start.clone().rotate(end, 270);\n const sRef = end.clone().rotate(start, 90);\n start.move(sRef, distance);\n end.move(eRef, distance);\n return l;\n },\n\n // @return {point} my point at 't' <0,1>\n pointAt: function(t) {\n\n var start = this.start;\n var end = this.end;\n\n if (t <= 0) return start.clone();\n if (t >= 1) return end.clone();\n\n return start.lerp(end, t);\n },\n\n pointAtLength: function(length) {\n\n var start = this.start;\n var end = this.end;\n\n var fromStart = true;\n if (length < 0) {\n fromStart = false; // negative lengths mean start calculation from end point\n length = -length; // absolute value\n }\n\n var lineLength = this.length();\n if (length >= lineLength) return (fromStart ? end.clone() : start.clone());\n\n return this.pointAt((fromStart ? (length) : (lineLength - length)) / lineLength);\n },\n\n // @return {number} the offset of the point `p` from the line. + if the point `p` is on the right side of the line, - if on the left and 0 if on the line.\n pointOffset: function(p) {\n\n // Find the sign of the determinant of vectors (start,end), where p is the query point.\n p = new Point(p);\n var start = this.start;\n var end = this.end;\n var determinant = ((end.x - start.x) * (p.y - start.y) - (end.y - start.y) * (p.x - start.x));\n\n return determinant / this.length();\n },\n\n rotate: function(origin, angle) {\n\n this.start.rotate(origin, angle);\n this.end.rotate(origin, angle);\n return this;\n },\n\n round: function(precision) {\n\n this.start.round(precision);\n this.end.round(precision);\n return this;\n },\n\n scale: function(sx, sy, origin) {\n\n this.start.scale(sx, sy, origin);\n this.end.scale(sx, sy, origin);\n return this;\n },\n\n // @return {number} scale the line so that it has the requested length\n setLength: function(length) {\n\n var currentLength = this.length();\n if (!currentLength) return this;\n\n var scaleFactor = length / currentLength;\n return this.scale(scaleFactor, scaleFactor, this.start);\n },\n\n // @return {integer} length without sqrt\n // @note for applications where the exact length is not necessary (e.g. compare only)\n squaredLength: function() {\n return squaredLength(this.start, this.end);\n },\n\n tangentAt: function(t) {\n\n if (!this.isDifferentiable()) return null;\n\n var start = this.start;\n var end = this.end;\n\n var tangentStart = this.pointAt(t); // constrains `t` between 0 and 1\n\n var tangentLine = new Line(start, end);\n tangentLine.translate(tangentStart.x - start.x, tangentStart.y - start.y); // move so that tangent line starts at the point requested\n\n return tangentLine;\n },\n\n tangentAtLength: function(length) {\n\n if (!this.isDifferentiable()) return null;\n\n var start = this.start;\n var end = this.end;\n\n var tangentStart = this.pointAtLength(length);\n\n var tangentLine = new Line(start, end);\n tangentLine.translate(tangentStart.x - start.x, tangentStart.y - start.y); // move so that tangent line starts at the point requested\n\n return tangentLine;\n },\n\n toString: function() {\n\n return this.start.toString() + ' ' + this.end.toString();\n },\n\n serialize: function() {\n\n return this.start.serialize() + ' ' + this.end.serialize();\n },\n\n translate: function(tx, ty) {\n\n this.start.translate(tx, ty);\n this.end.translate(tx, ty);\n return this;\n },\n\n // @return vector {point} of the line\n vector: function() {\n\n return new Point(this.end.x - this.start.x, this.end.y - this.start.y);\n }\n};\n\n// For backwards compatibility:\nLine.prototype.intersection = Line.prototype.intersect;\n\n\n// For backwards compatibility:\nexport const line = Line;\n","import { Rect } from './rect.mjs';\nimport { Point } from './point.mjs';\nimport { types } from './types.mjs';\n\nconst {\n sqrt,\n round,\n pow\n} = Math;\n\nexport const Ellipse = function(c, a, b) {\n\n if (!(this instanceof Ellipse)) {\n return new Ellipse(c, a, b);\n }\n\n if (c instanceof Ellipse) {\n return new Ellipse(new Point(c.x, c.y), c.a, c.b);\n }\n\n c = new Point(c);\n this.x = c.x;\n this.y = c.y;\n this.a = a;\n this.b = b;\n};\n\nEllipse.fromRect = function(rect) {\n\n rect = new Rect(rect);\n return new Ellipse(rect.center(), rect.width / 2, rect.height / 2);\n};\n\nEllipse.prototype = {\n\n type: types.Ellipse,\n\n bbox: function() {\n\n return new Rect(this.x - this.a, this.y - this.b, 2 * this.a, 2 * this.b);\n },\n\n /**\n * @returns {g.Point}\n */\n center: function() {\n\n return new Point(this.x, this.y);\n },\n\n clone: function() {\n\n return new Ellipse(this);\n },\n\n /**\n * @param {g.Point} p\n * @returns {boolean}\n */\n containsPoint: function(p) {\n\n return this.normalizedDistance(p) <= 1;\n },\n\n equals: function(ellipse) {\n\n return !!ellipse &&\n ellipse.x === this.x &&\n ellipse.y === this.y &&\n ellipse.a === this.a &&\n ellipse.b === this.b;\n },\n\n // inflate by dx and dy\n // @param dx {delta_x} representing additional size to x\n // @param dy {delta_y} representing additional size to y -\n // dy param is not required -> in that case y is sized by dx\n inflate: function(dx, dy) {\n if (dx === undefined) {\n dx = 0;\n }\n\n if (dy === undefined) {\n dy = dx;\n }\n\n this.a += 2 * dx;\n this.b += 2 * dy;\n\n return this;\n },\n\n intersectionWithLine: function(line) {\n\n var intersections = [];\n var a1 = line.start;\n var a2 = line.end;\n var rx = this.a;\n var ry = this.b;\n var dir = line.vector();\n var diff = a1.difference(new Point(this));\n var mDir = new Point(dir.x / (rx * rx), dir.y / (ry * ry));\n var mDiff = new Point(diff.x / (rx * rx), diff.y / (ry * ry));\n\n var a = dir.dot(mDir);\n var b = dir.dot(mDiff);\n var c = diff.dot(mDiff) - 1.0;\n var d = b * b - a * c;\n\n if (d < 0) {\n return null;\n } else if (d > 0) {\n var root = sqrt(d);\n var ta = (-b - root) / a;\n var tb = (-b + root) / a;\n\n if ((ta < 0 || 1 < ta) && (tb < 0 || 1 < tb)) {\n // if ((ta < 0 && tb < 0) || (ta > 1 && tb > 1)) outside else inside\n return null;\n } else {\n if (0 <= ta && ta <= 1) intersections.push(a1.lerp(a2, ta));\n if (0 <= tb && tb <= 1) intersections.push(a1.lerp(a2, tb));\n }\n } else {\n var t = -b / a;\n if (0 <= t && t <= 1) {\n intersections.push(a1.lerp(a2, t));\n } else {\n // outside\n return null;\n }\n }\n\n return intersections;\n },\n\n // Find point on me where line from my center to\n // point p intersects my boundary.\n // @param {number} angle If angle is specified, intersection with rotated ellipse is computed.\n intersectionWithLineFromCenterToPoint: function(p, angle) {\n\n p = new Point(p);\n\n if (angle) p.rotate(new Point(this.x, this.y), angle);\n\n var dx = p.x - this.x;\n var dy = p.y - this.y;\n var result;\n\n if (dx === 0) {\n result = this.bbox().pointNearestToPoint(p);\n if (angle) return result.rotate(new Point(this.x, this.y), -angle);\n return result;\n }\n\n var m = dy / dx;\n var mSquared = m * m;\n var aSquared = this.a * this.a;\n var bSquared = this.b * this.b;\n\n var x = sqrt(1 / ((1 / aSquared) + (mSquared / bSquared)));\n x = dx < 0 ? -x : x;\n\n var y = m * x;\n result = new Point(this.x + x, this.y + y);\n\n if (angle) return result.rotate(new Point(this.x, this.y), -angle);\n return result;\n },\n\n /**\n * @param {g.Point} point\n * @returns {number} result < 1 - inside ellipse, result == 1 - on ellipse boundary, result > 1 - outside\n */\n normalizedDistance: function(point) {\n\n var x0 = point.x;\n var y0 = point.y;\n var a = this.a;\n var b = this.b;\n var x = this.x;\n var y = this.y;\n\n return ((x0 - x) * (x0 - x)) / (a * a) + ((y0 - y) * (y0 - y)) / (b * b);\n },\n\n round: function(precision) {\n\n let f = 1; // case 0\n if (precision) {\n switch (precision) {\n case 1: f = 10; break;\n case 2: f = 100; break;\n case 3: f = 1000; break;\n default: f = pow(10, precision); break;\n }\n }\n\n this.x = round(this.x * f) / f;\n this.y = round(this.y * f) / f;\n this.a = round(this.a * f) / f;\n this.b = round(this.b * f) / f;\n return this;\n },\n\n /** Compute angle between tangent and x axis\n * @param {g.Point} p Point of tangency, it has to be on ellipse boundaries.\n * @returns {number} angle between tangent and x axis\n */\n tangentTheta: function(p) {\n\n var refPointDelta = 30;\n var x0 = p.x;\n var y0 = p.y;\n var a = this.a;\n var b = this.b;\n var center = this.bbox().center();\n var m = center.x;\n var n = center.y;\n\n var q1 = x0 > center.x + a / 2;\n var q3 = x0 < center.x - a / 2;\n\n var y, x;\n if (q1 || q3) {\n y = x0 > center.x ? y0 - refPointDelta : y0 + refPointDelta;\n x = (a * a / (x0 - m)) - (a * a * (y0 - n) * (y - n)) / (b * b * (x0 - m)) + m;\n\n } else {\n x = y0 > center.y ? x0 + refPointDelta : x0 - refPointDelta;\n y = (b * b / (y0 - n)) - (b * b * (x0 - m) * (x - m)) / (a * a * (y0 - n)) + n;\n }\n\n return (new Point(x, y)).theta(p);\n\n },\n\n toString: function() {\n\n return (new Point(this.x, this.y)).toString() + ' ' + this.a + ' ' + this.b;\n }\n};\n\n// For backwards compatibility:\nexport const ellipse = Ellipse;\n","import { toRad } from './geometry.helpers.mjs';\nimport { Line } from './line.mjs';\nimport { Point } from './point.mjs';\nimport { Ellipse } from './ellipse.mjs';\nimport { types } from './types.mjs';\n\nconst {\n abs,\n cos,\n sin,\n min,\n max,\n round,\n pow\n} = Math;\n\nexport const Rect = function(x, y, w, h) {\n\n if (!(this instanceof Rect)) {\n return new Rect(x, y, w, h);\n }\n\n if ((Object(x) === x)) {\n y = x.y;\n w = x.width;\n h = x.height;\n x = x.x;\n }\n\n this.x = x === undefined ? 0 : x;\n this.y = y === undefined ? 0 : y;\n this.width = w === undefined ? 0 : w;\n this.height = h === undefined ? 0 : h;\n};\n\nRect.fromEllipse = function(e) {\n\n e = new Ellipse(e);\n return new Rect(e.x - e.a, e.y - e.b, 2 * e.a, 2 * e.b);\n};\n\nRect.fromPointUnion = function(...points) {\n\n if (points.length === 0) return null;\n\n const p = new Point();\n let minX, minY, maxX, maxY;\n minX = minY = Infinity;\n maxX = maxY = -Infinity;\n\n for (let i = 0; i < points.length; i++) {\n p.update(points[i]);\n const x = p.x;\n const y = p.y;\n\n if (x < minX) minX = x;\n if (x > maxX) maxX = x;\n if (y < minY) minY = y;\n if (y > maxY) maxY = y;\n }\n\n return new Rect(minX, minY, maxX - minX, maxY - minY);\n};\n\nRect.fromRectUnion = function(...rects) {\n\n if (rects.length === 0) return null;\n\n const r = new Rect();\n let minX, minY, maxX, maxY;\n minX = minY = Infinity;\n maxX = maxY = -Infinity;\n\n for (let i = 0; i < rects.length; i++) {\n r.update(rects[i]);\n const x = r.x;\n const y = r.y;\n const mX = x + r.width;\n const mY = y + r.height;\n\n if (x < minX) minX = x;\n if (mX > maxX) maxX = mX;\n if (y < minY) minY = y;\n if (mY > maxY) maxY = mY;\n }\n\n return new Rect(minX, minY, maxX - minX, maxY - minY);\n};\n\nRect.prototype = {\n\n type: types.Rect,\n\n // Find my bounding box when I'm rotated with the center of rotation in the center of me.\n // @return r {rectangle} representing a bounding box\n bbox: function(angle) {\n return this.clone().rotateAroundCenter(angle);\n },\n\n rotateAroundCenter: function(angle) {\n if (!angle) return this;\n const { width, height } = this;\n const theta = toRad(angle);\n const st = abs(sin(theta));\n const ct = abs(cos(theta));\n const w = width * ct + height * st;\n const h = width * st + height * ct;\n this.x += (width - w) / 2;\n this.y += (height - h) / 2;\n this.width = w;\n this.height = h;\n return this;\n },\n\n bottomLeft: function() {\n\n return new Point(this.x, this.y + this.height);\n },\n\n bottomLine: function() {\n\n return new Line(this.bottomLeft(), this.bottomRight());\n },\n\n bottomMiddle: function() {\n\n return new Point(this.x + this.width / 2, this.y + this.height);\n },\n\n center: function() {\n\n return new Point(this.x + this.width / 2, this.y + this.height / 2);\n },\n\n clone: function() {\n\n return new Rect(this);\n },\n\n // @return {bool} true if point p is inside me.\n // @param {bool} strict If true, the point has to be strictly inside (not on the border).\n containsPoint: function(p, opt) {\n let x, y;\n if (!p || (typeof p === 'string')) {\n // Backwards compatibility: if the point is not provided,\n // the point is considered to be the origin [0, 0].\n ({ x, y } = new Point(p));\n } else {\n // Do not create a new Point object if the point is already a Point-like object.\n ({ x = 0, y = 0 } = p);\n }\n return opt && opt.strict\n ? (x > this.x && x < this.x + this.width && y > this.y && y < this.y + this.height)\n : x >= this.x && x <= this.x + this.width && y >= this.y && y <= this.y + this.height;\n },\n\n // @return {bool} true if rectangle `r` is inside me.\n containsRect: function(r) {\n\n var r0 = new Rect(this).normalize();\n var r1 = new Rect(r).normalize();\n var w0 = r0.width;\n var h0 = r0.height;\n var w1 = r1.width;\n var h1 = r1.height;\n\n if (!w0 || !h0 || !w1 || !h1) {\n // At least one of the dimensions is 0\n return false;\n }\n\n var x0 = r0.x;\n var y0 = r0.y;\n var x1 = r1.x;\n var y1 = r1.y;\n\n w1 += x1;\n w0 += x0;\n h1 += y1;\n h0 += y0;\n\n return x0 <= x1 && w1 <= w0 && y0 <= y1 && h1 <= h0;\n },\n\n corner: function() {\n\n return new Point(this.x + this.width, this.y + this.height);\n },\n\n // @return {boolean} true if rectangles are equal.\n equals: function(r) {\n\n var mr = (new Rect(this)).normalize();\n var nr = (new Rect(r)).normalize();\n return mr.x === nr.x && mr.y === nr.y && mr.width === nr.width && mr.height === nr.height;\n },\n\n // inflate by dx and dy, recompute origin [x, y]\n // @param dx {delta_x} representing additional size to x\n // @param dy {delta_y} representing additional size to y -\n // dy param is not required -> in that case y is sized by dx\n inflate: function(dx, dy) {\n\n if (dx === undefined) {\n dx = 0;\n }\n\n if (dy === undefined) {\n dy = dx;\n }\n\n this.x -= dx;\n this.y -= dy;\n this.width += 2 * dx;\n this.height += 2 * dy;\n\n return this;\n },\n\n // @return {rect} if rectangles intersect, {null} if not.\n intersect: function(r) {\n\n var myOrigin = this.origin();\n var myCorner = this.corner();\n var rOrigin = r.origin();\n var rCorner = r.corner();\n\n // No intersection found\n if (rCorner.x <= myOrigin.x ||\n rCorner.y <= myOrigin.y ||\n rOrigin.x >= myCorner.x ||\n rOrigin.y >= myCorner.y) return null;\n\n var x = max(myOrigin.x, rOrigin.x);\n var y = max(myOrigin.y, rOrigin.y);\n\n return new Rect(x, y, min(myCorner.x, rCorner.x) - x, min(myCorner.y, rCorner.y) - y);\n },\n\n intersectionWithLine: function(line) {\n\n var r = this;\n var rectLines = [r.topLine(), r.rightLine(), r.bottomLine(), r.leftLine()];\n var points = [];\n var dedupeArr = [];\n var pt, i;\n\n var n = rectLines.length;\n for (i = 0; i < n; i++) {\n\n pt = line.intersect(rectLines[i]);\n if (pt !== null && dedupeArr.indexOf(pt.toString()) < 0) {\n points.push(pt);\n dedupeArr.push(pt.toString());\n }\n }\n\n return points.length > 0 ? points : null;\n },\n\n // Find point on my boundary where line starting\n // from my center ending in point p intersects me.\n // @param {number} angle If angle is specified, intersection with rotated rectangle is computed.\n intersectionWithLineFromCenterToPoint: function(p, angle) {\n\n p = new Point(p);\n var center = new Point(this.x + this.width / 2, this.y + this.height / 2);\n var result;\n\n if (angle) p.rotate(center, angle);\n\n // (clockwise, starting from the top side)\n var sides = [\n this.topLine(),\n this.rightLine(),\n this.bottomLine(),\n this.leftLine()\n ];\n var connector = new Line(center, p);\n\n for (var i = sides.length - 1; i >= 0; --i) {\n var intersection = sides[i].intersection(connector);\n if (intersection !== null) {\n result = intersection;\n break;\n }\n }\n if (result && angle) result.rotate(center, -angle);\n return result;\n },\n\n leftLine: function() {\n\n return new Line(this.topLeft(), this.bottomLeft());\n },\n\n leftMiddle: function() {\n\n return new Point(this.x, this.y + this.height / 2);\n },\n\n maxRectScaleToFit: function(rect, origin) {\n\n rect = new Rect(rect);\n origin || (origin = rect.center());\n\n var sx1, sx2, sx3, sx4, sy1, sy2, sy3, sy4;\n var ox = origin.x;\n var oy = origin.y;\n\n // Here we find the maximal possible scale for all corner points (for x and y axis) of the rectangle,\n // so when the scale is applied the point is still inside the rectangle.\n\n sx1 = sx2 = sx3 = sx4 = sy1 = sy2 = sy3 = sy4 = Infinity;\n\n // Top Left\n var p1 = rect.topLeft();\n if (p1.x < ox) {\n sx1 = (this.x - ox) / (p1.x - ox);\n }\n if (p1.y < oy) {\n sy1 = (this.y - oy) / (p1.y - oy);\n }\n // Bottom Right\n var p2 = rect.bottomRight();\n if (p2.x > ox) {\n sx2 = (this.x + this.width - ox) / (p2.x - ox);\n }\n if (p2.y > oy) {\n sy2 = (this.y + this.height - oy) / (p2.y - oy);\n }\n // Top Right\n var p3 = rect.topRight();\n if (p3.x > ox) {\n sx3 = (this.x + this.width - ox) / (p3.x - ox);\n }\n if (p3.y < oy) {\n sy3 = (this.y - oy) / (p3.y - oy);\n }\n // Bottom Left\n var p4 = rect.bottomLeft();\n if (p4.x < ox) {\n sx4 = (this.x - ox) / (p4.x - ox);\n }\n if (p4.y > oy) {\n sy4 = (this.y + this.height - oy) / (p4.y - oy);\n }\n\n return {\n sx: min(sx1, sx2, sx3, sx4),\n sy: min(sy1, sy2, sy3, sy4)\n };\n },\n\n maxRectUniformScaleToFit: function(rect, origin) {\n\n var scale = this.maxRectScaleToFit(rect, origin);\n return min(scale.sx, scale.sy);\n },\n\n // Move and expand me.\n // @param r {rectangle} representing deltas\n moveAndExpand: function(r) {\n\n this.x += r.x || 0;\n this.y += r.y || 0;\n this.width += r.width || 0;\n this.height += r.height || 0;\n return this;\n },\n\n // Normalize the rectangle; i.e., make it so that it has a non-negative width and height.\n // If width < 0 the function swaps the left and right corners,\n // and it swaps the top and bottom corners if height < 0\n // like in http://qt-project.org/doc/qt-4.8/qrectf.html#normalized\n normalize: function() {\n\n var newx = this.x;\n var newy = this.y;\n var newwidth = this.width;\n var newheight = this.height;\n if (this.width < 0) {\n newx = this.x + this.width;\n newwidth = -this.width;\n }\n if (this.height < 0) {\n newy = this.y + this.height;\n newheight = -this.height;\n }\n this.x = newx;\n this.y = newy;\n this.width = newwidth;\n this.height = newheight;\n return this;\n },\n\n // Offset me by the specified amount.\n offset: function(dx, dy) {\n\n // pretend that this is a point and call offset()\n // rewrites x and y according to dx and dy\n return Point.prototype.offset.call(this, dx, dy);\n },\n\n origin: function() {\n\n return new Point(this.x, this.y);\n },\n\n // @return {point} a point on my boundary nearest to the given point.\n // @see Squeak Smalltalk, Rectangle>>pointNearestTo:\n pointNearestToPoint: function(point) {\n\n point = new Point(point);\n if (this.containsPoint(point)) {\n var side = this.sideNearestToPoint(point);\n switch (side) {\n case 'right':\n return new Point(this.x + this.width, point.y);\n case 'left':\n return new Point(this.x, point.y);\n case 'bottom':\n return new Point(point.x, this.y + this.height);\n case 'top':\n return new Point(point.x, this.y);\n }\n }\n return point.adhereToRect(this);\n },\n\n rightLine: function() {\n\n return new Line(this.topRight(), this.bottomRight());\n },\n\n rightMiddle: function() {\n\n return new Point(this.x + this.width, this.y + this.height / 2);\n },\n\n round: function(precision) {\n\n let f = 1; // case 0\n if (precision) {\n switch (precision) {\n case 1: f = 10; break;\n case 2: f = 100; break;\n case 3: f = 1000; break;\n default: f = pow(10, precision); break;\n }\n }\n\n this.x = round(this.x * f) / f;\n this.y = round(this.y * f) / f;\n this.width = round(this.width * f) / f;\n this.height = round(this.height * f) / f;\n return this;\n },\n\n // Scale rectangle with origin.\n scale: function(sx, sy, origin) {\n\n origin = this.origin().scale(sx, sy, origin);\n this.x = origin.x;\n this.y = origin.y;\n this.width *= sx;\n this.height *= sy;\n return this;\n },\n\n // @return {string} (left|right|top|bottom) side which is nearest to point\n // @see Squeak Smalltalk, Rectangle>>sideNearestTo:\n sideNearestToPoint: function(point) {\n\n point = new Point(point);\n var distToLeft = point.x - this.x;\n var distToRight = (this.x + this.width) - point.x;\n var distToTop = point.y - this.y;\n var distToBottom = (this.y + this.height) - point.y;\n var closest = distToLeft;\n var side = 'left';\n\n if (distToRight < closest) {\n closest = distToRight;\n side = 'right';\n }\n if (distToTop < closest) {\n closest = distToTop;\n side = 'top';\n }\n if (distToBottom < closest) {\n // closest = distToBottom;\n side = 'bottom';\n }\n return side;\n },\n\n snapToGrid: function(gx, gy) {\n\n var origin = this.origin().snapToGrid(gx, gy);\n var corner = this.corner().snapToGrid(gx, gy);\n this.x = origin.x;\n this.y = origin.y;\n this.width = corner.x - origin.x;\n this.height = corner.y - origin.y;\n return this;\n },\n\n toJSON: function() {\n\n return { x: this.x, y: this.y, width: this.width, height: this.height };\n },\n\n topLine: function() {\n\n return new Line(this.topLeft(), this.topRight());\n },\n\n topMiddle: function() {\n\n return new Point(this.x + this.width / 2, this.y);\n },\n\n topRight: function() {\n\n return new Point(this.x + this.width, this.y);\n },\n\n toString: function() {\n\n return this.origin().toString() + ' ' + this.corner().toString();\n },\n\n // @return {rect} representing the union of both rectangles.\n union: function(rect) {\n\n return Rect.fromRectUnion(this, rect);\n },\n\n update: function(x, y, w, h) {\n\n if ((Object(x) === x)) {\n y = x.y;\n w = x.width;\n h = x.height;\n x = x.x;\n }\n\n this.x = x || 0;\n this.y = y || 0;\n this.width = w || 0;\n this.height = h || 0;\n return this;\n }\n};\n\nRect.prototype.bottomRight = Rect.prototype.corner;\n\nRect.prototype.topLeft = Rect.prototype.origin;\n\nRect.prototype.translate = Rect.prototype.offset;\n\n// For backwards compatibility:\nexport const rect = Rect;\n","export function parsePoints(svgString) {\n\n // Step 1: Discard surrounding spaces\n const trimmedString = svgString.trim();\n if (trimmedString === '') return [];\n\n const points = [];\n\n // Step 2: Split at commas (+ their surrounding spaces) or at multiple spaces\n // ReDoS mitigation: Have an anchor at the beginning of each alternation\n // Note: This doesn't simplify double (or more) commas - causes empty coords\n // This regex is used by `split()`, so it doesn't need to use /g\n const coords = trimmedString.split(/\\b\\s*,\\s*|,\\s*|\\s+/);\n\n const numCoords = coords.length;\n for (let i = 0; i < numCoords; i += 2) {\n // Step 3: Convert each coord to number\n // Note: If the coord cannot be converted to a number, it will be `NaN`\n // Note: If the coord is empty (\"\", e.g. from \",,\" input), it will be `0`\n // Note: If we end up with an odd number of coords, the last point's second coord will be `NaN`\n points.push({ x: +coords[i], y: +coords[i + 1] });\n }\n return points;\n}\n\nexport function clonePoints(points) {\n const numPoints = points.length;\n if (numPoints === 0) return [];\n const newPoints = [];\n for (let i = 0; i < numPoints; i++) {\n const point = points[i].clone();\n newPoints.push(point);\n }\n return newPoints;\n}\n\n// Returns a convex-hull polyline from this polyline.\n// Implements the Graham scan (https://en.wikipedia.org/wiki/Graham_scan).\n// Output polyline starts at the first element of the original polyline that is on the hull, then continues clockwise.\n// Minimal polyline is found (only vertices of the hull are reported, no collinear points).\nexport function convexHull(points) {\n\n const { abs } = Math;\n\n var i;\n var n;\n\n var numPoints = points.length;\n if (numPoints === 0) return []; // if points array is empty\n\n // step 1: find the starting point - point with the lowest y (if equality, highest x)\n var startPoint;\n for (i = 0; i < numPoints; i++) {\n if (startPoint === undefined) {\n // if this is the first point we see, set it as start point\n startPoint = points[i];\n\n } else if (points[i].y < startPoint.y) {\n // start point should have lowest y from all points\n startPoint = points[i];\n\n } else if ((points[i].y === startPoint.y) && (points[i].x > startPoint.x)) {\n // if two points have the lowest y, choose the one that has highest x\n // there are no points to the right of startPoint - no ambiguity about theta 0\n // if there are several coincident start point candidates, first one is reported\n startPoint = points[i];\n }\n }\n\n // step 2: sort the list of points\n // sorting by angle between line from startPoint to point and the x-axis (theta)\n\n // step 2a: create the point records = [point, originalIndex, angle]\n var sortedPointRecords = [];\n for (i = 0; i < numPoints; i++) {\n\n var angle = startPoint.theta(points[i]);\n if (angle === 0) {\n angle = 360; // give highest angle to start point\n // the start point will end up at end of sorted list\n // the start point will end up at beginning of hull points list\n }\n\n var entry = [points[i], i, angle];\n sortedPointRecords.push(entry);\n }\n\n // step 2b: sort the list in place\n sortedPointRecords.sort(function(record1, record2) {\n // returning a negative number here sorts record1 before record2\n // if first angle is smaller than second, first angle should come before second\n\n var sortOutput = record1[2] - record2[2]; // negative if first angle smaller\n if (sortOutput === 0) {\n // if the two angles are equal, sort by originalIndex\n sortOutput = record2[1] - record1[1]; // negative if first index larger\n // coincident points will be sorted in reverse-numerical order\n // so the coincident points with lower original index will be considered first\n }\n\n return sortOutput;\n });\n\n // step 2c: duplicate start record from the top of the stack to the bottom of the stack\n if (sortedPointRecords.length > 2) {\n var startPointRecord = sortedPointRecords[sortedPointRecords.length - 1];\n sortedPointRecords.unshift(startPointRecord);\n }\n\n // step 3a: go through sorted points in order and find those with right turns\n // we want to get our results in clockwise order\n var insidePoints = {}; // dictionary of points with left turns - cannot be on the hull\n var hullPointRecords = []; // stack of records with right turns - hull point candidates\n\n var currentPointRecord;\n var currentPoint;\n var lastHullPointRecord;\n var lastHullPoint;\n var secondLastHullPointRecord;\n var secondLastHullPoint;\n while (sortedPointRecords.length !== 0) {\n\n currentPointRecord = sortedPointRecords.pop();\n currentPoint = currentPointRecord[0];\n\n // check if point has already been discarded\n // keys for insidePoints are stored in the form 'point.x@point.y@@originalIndex'\n if (insidePoints.hasOwnProperty(currentPointRecord[0] + '@@' + currentPointRecord[1])) {\n // this point had an incorrect turn at some previous iteration of this loop\n // this disqualifies it from possibly being on the hull\n continue;\n }\n\n var correctTurnFound = false;\n while (!correctTurnFound) {\n\n if (hullPointRecords.length < 2) {\n // not enough points for comparison, just add current point\n hullPointRecords.push(currentPointRecord);\n correctTurnFound = true;\n\n } else {\n lastHullPointRecord = hullPointRecords.pop();\n lastHullPoint = lastHullPointRecord[0];\n secondLastHullPointRecord = hullPointRecords.pop();\n secondLastHullPoint = secondLastHullPointRecord[0];\n\n var crossProduct = secondLastHullPoint.cross(lastHullPoint, currentPoint);\n\n if (crossProduct < 0) {\n // found a right turn\n hullPointRecords.push(secondLastHullPointRecord);\n hullPointRecords.push(lastHullPointRecord);\n hullPointRecords.push(currentPointRecord);\n correctTurnFound = true;\n\n } else if (crossProduct === 0) {\n // the three points are collinear\n // three options:\n // there may be a 180 or 0 degree angle at lastHullPoint\n // or two of the three points are coincident\n var THRESHOLD = 1e-10; // we have to take rounding errors into account\n var angleBetween = lastHullPoint.angleBetween(secondLastHullPoint, currentPoint);\n if (abs(angleBetween - 180) < THRESHOLD) { // rounding around 180 to 180\n // if the cross product is 0 because the angle is 180 degrees\n // discard last hull point (add to insidePoints)\n //insidePoints.unshift(lastHullPoint);\n insidePoints[lastHullPointRecord[0] + '@@' + lastHullPointRecord[1]] = lastHullPoint;\n // reenter second-to-last hull point (will be last at next iter)\n hullPointRecords.push(secondLastHullPointRecord);\n // do not do anything with current point\n // correct turn not found\n\n } else if (lastHullPoint.equals(currentPoint) || secondLastHullPoint.equals(lastHullPoint)) {\n // if the cross product is 0 because two points are the same\n // discard last hull point (add to insidePoints)\n //insidePoints.unshift(lastHullPoint);\n insidePoints[lastHullPointRecord[0] + '@@' + lastHullPointRecord[1]] = lastHullPoint;\n // reenter second-to-last hull point (will be last at next iter)\n hullPointRecords.push(secondLastHullPointRecord);\n // do not do anything with current point\n // correct turn not found\n\n } else if (abs(((angleBetween + 1) % 360) - 1) < THRESHOLD) { // rounding around 0 and 360 to 0\n // if the cross product is 0 because the angle is 0 degrees\n // remove last hull point from hull BUT do not discard it\n // reenter second-to-last hull point (will be last at next iter)\n hullPointRecords.push(secondLastHullPointRecord);\n // put last hull point back into the sorted point records list\n sortedPointRecords.push(lastHullPointRecord);\n // we are switching the order of the 0deg and 180deg points\n // correct turn not found\n }\n\n } else {\n // found a left turn\n // discard last hull point (add to insidePoints)\n //insidePoints.unshift(lastHullPoint);\n insidePoints[lastHullPointRecord[0] + '@@' + lastHullPointRecord[1]] = lastHullPoint;\n // reenter second-to-last hull point (will be last at next iter of loop)\n hullPointRecords.push(secondLastHullPointRecord);\n // do not do anything with current point\n // correct turn not found\n }\n }\n }\n }\n // at this point, hullPointRecords contains the output points in clockwise order\n // the points start with lowest-y,highest-x startPoint, and end at the same point\n\n // step 3b: remove duplicated startPointRecord from the end of the array\n if (hullPointRecords.length > 2) {\n hullPointRecords.pop();\n }\n\n // step 4: find the lowest originalIndex record and put it at the beginning of hull\n var lowestHullIndex; // the lowest originalIndex on the hull\n var indexOfLowestHullIndexRecord = -1; // the index of the record with lowestHullIndex\n n = hullPointRecords.length;\n for (i = 0; i < n; i++) {\n\n var currentHullIndex = hullPointRecords[i][1];\n\n if (lowestHullIndex === undefined || currentHullIndex < lowestHullIndex) {\n lowestHullIndex = currentHullIndex;\n indexOfLowestHullIndexRecord = i;\n }\n }\n\n var hullPointRecordsReordered = [];\n if (indexOfLowestHullIndexRecord > 0) {\n var newFirstChunk = hullPointRecords.slice(indexOfLowestHullIndexRecord);\n var newSecondChunk = hullPointRecords.slice(0, indexOfLowestHullIndexRecord);\n hullPointRecordsReordered = newFirstChunk.concat(newSecondChunk);\n\n } else {\n hullPointRecordsReordered = hullPointRecords;\n }\n\n var hullPoints = [];\n n = hullPointRecordsReordered.length;\n for (i = 0; i < n; i++) {\n hullPoints.push(hullPointRecordsReordered[i][0]);\n }\n\n return hullPoints;\n}\n","import { Rect } from './rect.mjs';\nimport { Point } from './point.mjs';\nimport { Line } from './line.mjs';\nimport { types } from './types.mjs';\nimport { clonePoints, parsePoints, convexHull } from './points.mjs';\n\n\nexport const Polyline = function(points) {\n\n if (!(this instanceof Polyline)) {\n return new Polyline(points);\n }\n\n if (typeof points === 'string') {\n return new Polyline.parse(points);\n }\n\n this.points = (Array.isArray(points) ? points.map(Point) : []);\n};\n\nPolyline.parse = function(svgString) {\n return new Polyline(parsePoints(svgString));\n};\n\nPolyline.fromRect = function(rect) {\n return new Polyline([\n rect.topLeft(),\n rect.topRight(),\n rect.bottomRight(),\n rect.bottomLeft(),\n rect.topLeft(),\n ]);\n};\n\nPolyline.prototype = {\n\n type: types.Polyline,\n\n bbox: function() {\n\n var x1 = Infinity;\n var x2 = -Infinity;\n var y1 = Infinity;\n var y2 = -Infinity;\n\n var points = this.points;\n var numPoints = points.length;\n if (numPoints === 0) return null; // if points array is empty\n\n for (var i = 0; i < numPoints; i++) {\n\n var point = points[i];\n var x = point.x;\n var y = point.y;\n\n if (x < x1) x1 = x;\n if (x > x2) x2 = x;\n if (y < y1) y1 = y;\n if (y > y2) y2 = y;\n }\n\n return new Rect(x1, y1, x2 - x1, y2 - y1);\n },\n\n clone: function() {\n return new Polyline(clonePoints(this.points));\n },\n\n closestPoint: function(p) {\n\n var cpLength = this.closestPointLength(p);\n\n return this.pointAtLength(cpLength);\n },\n\n closestPointLength: function(p) {\n\n var points = this.lengthPoints();\n var numPoints = points.length;\n if (numPoints === 0) return 0; // if points array is empty\n if (numPoints === 1) return 0; // if there is only one point\n\n var cpLength;\n var minSqrDistance = Infinity;\n var length = 0;\n var n = numPoints - 1;\n for (var i = 0; i < n; i++) {\n\n var line = new Line(points[i], points[i + 1]);\n var lineLength = line.length();\n\n var cpNormalizedLength = line.closestPointNormalizedLength(p);\n var cp = line.pointAt(cpNormalizedLength);\n\n var sqrDistance = cp.squaredDistance(p);\n if (sqrDistance < minSqrDistance) {\n minSqrDistance = sqrDistance;\n cpLength = length + (cpNormalizedLength * lineLength);\n }\n\n length += lineLength;\n }\n\n return cpLength;\n },\n\n closestPointNormalizedLength: function(p) {\n\n var cpLength = this.closestPointLength(p);\n if (cpLength === 0) return 0; // shortcut\n\n var length = this.length();\n if (length === 0) return 0; // prevents division by zero\n\n return cpLength / length;\n },\n\n closestPointTangent: function(p) {\n\n var cpLength = this.closestPointLength(p);\n\n return this.tangentAtLength(cpLength);\n },\n\n // Returns `true` if the area surrounded by the polyline contains the point `p`.\n // Implements the even-odd SVG algorithm (self-intersections are \"outside\").\n // (Uses horizontal rays to the right of `p` to look for intersections.)\n // Closes open polylines (always imagines a final closing segment).\n containsPoint: function(p) {\n\n var points = this.points;\n var numPoints = points.length;\n if (numPoints === 0) return false; // shortcut (this polyline has no points)\n\n var x = p.x;\n var y = p.y;\n\n // initialize a final closing segment by creating one from last-first points on polyline\n var startIndex = numPoints - 1; // start of current polyline segment\n var endIndex = 0; // end of current polyline segment\n var numIntersections = 0;\n var segment = new Line();\n var ray = new Line();\n var rayEnd = new Point();\n for (; endIndex < numPoints; endIndex++) {\n var start = points[startIndex];\n var end = points[endIndex];\n if (p.equals(start)) return true; // shortcut (`p` is a point on polyline)\n // current polyline segment\n segment.start = start;\n segment.end = end;\n if (segment.containsPoint(p)) return true; // shortcut (`p` lies on a polyline segment)\n\n // do we have an intersection?\n if (((y <= start.y) && (y > end.y)) || ((y > start.y) && (y <= end.y))) {\n // this conditional branch IS NOT entered when `segment` is collinear/coincident with `ray`\n // (when `y === start.y === end.y`)\n // this conditional branch IS entered when `segment` touches `ray` at only one point\n // (e.g. when `y === start.y !== end.y`)\n // since this branch is entered again for the following segment, the two touches cancel out\n\n var xDifference = (((start.x - x) > (end.x - x)) ? (start.x - x) : (end.x - x));\n if (xDifference >= 0) {\n // segment lies at least partially to the right of `p`\n rayEnd.x = x + xDifference;\n rayEnd.y = y; // right\n ray.start = p;\n ray.end = rayEnd;\n if (segment.intersect(ray)) {\n // an intersection was detected to the right of `p`\n numIntersections++;\n }\n } // else: `segment` lies completely to the left of `p` (i.e. no intersection to the right)\n }\n\n // move to check the next polyline segment\n startIndex = endIndex;\n }\n\n // returns `true` for odd numbers of intersections (even-odd algorithm)\n return ((numIntersections % 2) === 1);\n },\n\n close: function() {\n const { start, end, points } = this;\n if (start && end && !start.equals(end)) {\n points.push(start.clone());\n }\n return this;\n },\n\n lengthPoints: function() {\n return this.points;\n },\n\n convexHull: function() {\n return new Polyline(convexHull(this.points));\n },\n\n // Checks whether two polylines are exactly the same.\n // If `p` is undefined or null, returns false.\n equals: function(p) {\n\n if (!p) return false;\n\n var points = this.points;\n var otherPoints = p.points;\n\n var numPoints = points.length;\n if (otherPoints.length !== numPoints) return false; // if the two polylines have different number of points, they cannot be equal\n\n for (var i = 0; i < numPoints; i++) {\n\n var point = points[i];\n var otherPoint = p.points[i];\n\n // as soon as an inequality is found in points, return false\n if (!point.equals(otherPoint)) return false;\n }\n\n // if no inequality found in points, return true\n return true;\n },\n\n intersectionWithLine: function(l) {\n var line = new Line(l);\n var intersections = [];\n var points = this.lengthPoints();\n var l2 = new Line();\n for (var i = 0, n = points.length - 1; i < n; i++) {\n l2.start = points[i];\n l2.end = points[i + 1];\n var int = line.intersectionWithLine(l2);\n if (int) intersections.push(int[0]);\n }\n return (intersections.length > 0) ? intersections : null;\n },\n\n isDifferentiable: function() {\n\n var points = this.points;\n var numPoints = points.length;\n if (numPoints === 0) return false;\n\n var line = new Line();\n var n = numPoints - 1;\n for (var i = 0; i < n; i++) {\n line.start = points[i];\n line.end = points[i + 1];\n // as soon as a differentiable line is found between two points, return true\n if (line.isDifferentiable()) return true;\n }\n\n // if no differentiable line is found between pairs of points, return false\n return false;\n },\n\n length: function() {\n\n var points = this.lengthPoints();\n var numPoints = points.length;\n if (numPoints === 0) return 0; // if points array is empty\n\n var length = 0;\n var n = numPoints - 1;\n for (var i = 0; i < n; i++) {\n length += points[i].distance(points[i + 1]);\n }\n\n return length;\n },\n\n pointAt: function(ratio) {\n\n var points = this.lengthPoints();\n var numPoints = points.length;\n if (numPoints === 0) return null; // if points array is empty\n if (numPoints === 1) return points[0].clone(); // if there is only one point\n\n if (ratio <= 0) return points[0].clone();\n if (ratio >= 1) return points[numPoints - 1].clone();\n\n var polylineLength = this.length();\n var length = polylineLength * ratio;\n\n return this.pointAtLength(length);\n },\n\n pointAtLength: function(length) {\n\n var points = this.lengthPoints();\n var numPoints = points.length;\n if (numPoints === 0) return null; // if points array is empty\n if (numPoints === 1) return points[0].clone(); // if there is only one point\n\n var fromStart = true;\n if (length < 0) {\n fromStart = false; // negative lengths mean start calculation from end point\n length = -length; // absolute value\n }\n\n var l = 0;\n var n = numPoints - 1;\n for (var i = 0; i < n; i++) {\n var index = (fromStart ? i : (n - 1 - i));\n\n var a = points[index];\n var b = points[index + 1];\n var line = new Line(a, b);\n var d = a.distance(b);\n\n if (length <= (l + d)) {\n return line.pointAtLength((fromStart ? 1 : -1) * (length - l));\n }\n\n l += d;\n }\n\n // if length requested is higher than the length of the polyline, return last endpoint\n var lastPoint = (fromStart ? points[numPoints - 1] : points[0]);\n return lastPoint.clone();\n },\n\n round: function(precision) {\n\n var points = this.points;\n var numPoints = points.length;\n\n for (var i = 0; i < numPoints; i++) {\n points[i].round(precision);\n }\n\n return this;\n },\n\n scale: function(sx, sy, origin) {\n\n var points = this.points;\n var numPoints = points.length;\n\n for (var i = 0; i < numPoints; i++) {\n points[i].scale(sx, sy, origin);\n }\n\n return this;\n },\n\n simplify: function(opt = {}) {\n\n const points = this.points;\n if (points.length < 3) return this; // we need at least 3 points\n\n // TODO: we may also accept startIndex and endIndex to specify where to start and end simplification\n\n // Due to the nature of the algorithm, we do not use 0 as the default value for `threshold`\n // because of the rounding errors that can occur when comparing distances.\n const threshold = opt.threshold || 1e-10; // = max distance of middle point from chord to be simplified\n\n // start at the beginning of the polyline and go forward\n let currentIndex = 0;\n // we need at least one intermediate point (3 points) in every iteration\n // as soon as that stops being true, we know we reached the end of the polyline\n while (points[currentIndex + 2]) {\n const firstIndex = currentIndex;\n const middleIndex = (currentIndex + 1);\n const lastIndex = (currentIndex + 2);\n\n const firstPoint = points[firstIndex];\n const middlePoint = points[middleIndex];\n const lastPoint = points[lastIndex];\n\n const chord = new Line(firstPoint, lastPoint); // = connection between first and last point\n const closestPoint = chord.closestPoint(middlePoint); // = closest point on chord from middle point\n const closestPointDistance = closestPoint.distance(middlePoint);\n if (closestPointDistance <= threshold) {\n // middle point is close enough to the chord = simplify\n // 1) remove middle point:\n points.splice(middleIndex, 1);\n // 2) in next iteration, investigate the newly-created triplet of points\n // - do not change `currentIndex`\n // = (first point stays, point after removed point becomes middle point)\n } else {\n // middle point is far from the chord\n // 1) preserve middle point\n // 2) in next iteration, move `currentIndex` by one step:\n currentIndex += 1;\n // = (point after first point becomes first point)\n }\n }\n\n // `points` array was modified in-place\n return this;\n },\n\n tangentAt: function(ratio) {\n\n var points = this.lengthPoints();\n var numPoints = points.length;\n if (numPoints === 0) return null; // if points array is empty\n if (numPoints === 1) return null; // if there is only one point\n\n if (ratio < 0) ratio = 0;\n if (ratio > 1) ratio = 1;\n\n var polylineLength = this.length();\n var length = polylineLength * ratio;\n\n return this.tangentAtLength(length);\n },\n\n tangentAtLength: function(length) {\n\n var points = this.lengthPoints();\n var numPoints = points.length;\n if (numPoints === 0) return null; // if points array is empty\n if (numPoints === 1) return null; // if there is only one point\n\n var fromStart = true;\n if (length < 0) {\n fromStart = false; // negative lengths mean start calculation from end point\n length = -length; // absolute value\n }\n\n var lastValidLine; // differentiable (with a tangent)\n var l = 0; // length so far\n var n = numPoints - 1;\n for (var i = 0; i < n; i++) {\n var index = (fromStart ? i : (n - 1 - i));\n\n var a = points[index];\n var b = points[index + 1];\n var line = new Line(a, b);\n var d = a.distance(b);\n\n if (line.isDifferentiable()) { // has a tangent line (line length is not 0)\n if (length <= (l + d)) {\n return line.tangentAtLength((fromStart ? 1 : -1) * (length - l));\n }\n\n lastValidLine = line;\n }\n\n l += d;\n }\n\n // if length requested is higher than the length of the polyline, return last valid endpoint\n if (lastValidLine) {\n var ratio = (fromStart ? 1 : 0);\n return lastValidLine.tangentAt(ratio);\n }\n\n // if no valid line, return null\n return null;\n },\n\n toString: function() {\n\n return this.points + '';\n },\n\n translate: function(tx, ty) {\n\n var points = this.points;\n var numPoints = points.length;\n\n for (var i = 0; i < numPoints; i++) {\n points[i].translate(tx, ty);\n }\n\n return this;\n },\n\n // Return svgString that can be used to recreate this line.\n serialize: function() {\n\n var points = this.points;\n var numPoints = points.length;\n if (numPoints === 0) return ''; // if points array is empty\n\n var output = '';\n for (var i = 0; i < numPoints; i++) {\n\n var point = points[i];\n output += point.x + ',' + point.y + ' ';\n }\n\n return output.trim();\n }\n};\n\nObject.defineProperty(Polyline.prototype, 'start', {\n // Getter for the first point of the polyline.\n\n configurable: true,\n\n enumerable: true,\n\n get: function() {\n\n var points = this.points;\n var numPoints = points.length;\n if (numPoints === 0) return null; // if points array is empty\n\n return this.points[0];\n },\n});\n\nObject.defineProperty(Polyline.prototype, 'end', {\n // Getter for the last point of the polyline.\n\n configurable: true,\n\n enumerable: true,\n\n get: function() {\n\n var points = this.points;\n var numPoints = points.length;\n if (numPoints === 0) return null; // if points array is empty\n\n return this.points[numPoints - 1];\n },\n});\n","import { Point } from './point.mjs';\nimport { Rect } from './rect.mjs';\nimport { Line } from './line.mjs';\nimport { Polyline } from './polyline.mjs';\nimport { types } from './types.mjs';\n\nconst {\n abs,\n sqrt,\n min,\n max,\n pow\n} = Math;\n\nexport const Curve = function(p1, p2, p3, p4) {\n\n if (!(this instanceof Curve)) {\n return new Curve(p1, p2, p3, p4);\n }\n\n if (p1 instanceof Curve) {\n return new Curve(p1.start, p1.controlPoint1, p1.controlPoint2, p1.end);\n }\n\n this.start = new Point(p1);\n this.controlPoint1 = new Point(p2);\n this.controlPoint2 = new Point(p3);\n this.end = new Point(p4);\n};\n\n// Curve passing through points.\n// Ported from C# implementation by Oleg V. Polikarpotchkin and Peter Lee (http://www.codeproject.com/KB/graphics/BezierSpline.aspx).\n// @param {array} points Array of points through which the smooth line will go.\n// @return {array} curves.\nCurve.throughPoints = (function() {\n\n // Get open-ended Bezier Spline Control Points.\n // @param knots Input Knot Bezier spline points (At least two points!).\n // @param firstControlPoints Output First Control points. Array of knots.length - 1 length.\n // @param secondControlPoints Output Second Control points. Array of knots.length - 1 length.\n function getCurveControlPoints(knots) {\n\n var firstControlPoints = [];\n var secondControlPoints = [];\n var n = knots.length - 1;\n var i;\n\n // Special case: Bezier curve should be a straight line.\n if (n == 1) {\n // 3P1 = 2P0 + P3\n firstControlPoints[0] = new Point(\n (2 * knots[0].x + knots[1].x) / 3,\n (2 * knots[0].y + knots[1].y) / 3\n );\n\n // P2 = 2P1 – P0\n secondControlPoints[0] = new Point(\n 2 * firstControlPoints[0].x - knots[0].x,\n 2 * firstControlPoints[0].y - knots[0].y\n );\n\n return [firstControlPoints, secondControlPoints];\n }\n\n // Calculate first Bezier control points.\n // Right hand side vector.\n var rhs = [];\n\n // Set right hand side X values.\n for (i = 1; i < n - 1; i++) {\n rhs[i] = 4 * knots[i].x + 2 * knots[i + 1].x;\n }\n\n rhs[0] = knots[0].x + 2 * knots[1].x;\n rhs[n - 1] = (8 * knots[n - 1].x + knots[n].x) / 2.0;\n\n // Get first control points X-values.\n var x = getFirstControlPoints(rhs);\n\n // Set right hand side Y values.\n for (i = 1; i < n - 1; ++i) {\n rhs[i] = 4 * knots[i].y + 2 * knots[i + 1].y;\n }\n\n rhs[0] = knots[0].y + 2 * knots[1].y;\n rhs[n - 1] = (8 * knots[n - 1].y + knots[n].y) / 2.0;\n\n // Get first control points Y-values.\n var y = getFirstControlPoints(rhs);\n\n // Fill output arrays.\n for (i = 0; i < n; i++) {\n // First control point.\n firstControlPoints.push(new Point(x[i], y[i]));\n\n // Second control point.\n if (i < n - 1) {\n secondControlPoints.push(new Point(\n 2 * knots [i + 1].x - x[i + 1],\n 2 * knots[i + 1].y - y[i + 1]\n ));\n\n } else {\n secondControlPoints.push(new Point(\n (knots[n].x + x[n - 1]) / 2,\n (knots[n].y + y[n - 1]) / 2\n ));\n }\n }\n\n return [firstControlPoints, secondControlPoints];\n }\n\n // Solves a tridiagonal system for one of coordinates (x or y) of first Bezier control points.\n // @param rhs Right hand side vector.\n // @return Solution vector.\n function getFirstControlPoints(rhs) {\n\n var n = rhs.length;\n // `x` is a solution vector.\n var x = [];\n var tmp = [];\n var b = 2.0;\n\n x[0] = rhs[0] / b;\n\n // Decomposition and forward substitution.\n for (var i = 1; i < n; i++) {\n tmp[i] = 1 / b;\n b = (i < n - 1 ? 4.0 : 3.5) - tmp[i];\n x[i] = (rhs[i] - x[i - 1]) / b;\n }\n\n for (i = 1; i < n; i++) {\n // Backsubstitution.\n x[n - i - 1] -= tmp[n - i] * x[n - i];\n }\n\n return x;\n }\n\n return function(points) {\n\n if (!points || (Array.isArray(points) && points.length < 2)) {\n throw new Error('At least 2 points are required');\n }\n\n var controlPoints = getCurveControlPoints(points);\n\n var curves = [];\n var n = controlPoints[0].length;\n for (var i = 0; i < n; i++) {\n\n var controlPoint1 = new Point(controlPoints[0][i].x, controlPoints[0][i].y);\n var controlPoint2 = new Point(controlPoints[1][i].x, controlPoints[1][i].y);\n\n curves.push(new Curve(points[i], controlPoint1, controlPoint2, points[i + 1]));\n }\n\n return curves;\n };\n})();\n\nCurve.prototype = {\n\n type: types.Curve,\n\n // Returns a bbox that tightly envelops the curve.\n bbox: function() {\n\n var start = this.start;\n var controlPoint1 = this.controlPoint1;\n var controlPoint2 = this.controlPoint2;\n var end = this.end;\n\n var x0 = start.x;\n var y0 = start.y;\n var x1 = controlPoint1.x;\n var y1 = controlPoint1.y;\n var x2 = controlPoint2.x;\n var y2 = controlPoint2.y;\n var x3 = end.x;\n var y3 = end.y;\n\n var points = new Array(); // local extremes\n var tvalues = new Array(); // t values of local extremes\n var bounds = [new Array(), new Array()];\n\n var a, b, c, t;\n var t1, t2;\n var b2ac, sqrtb2ac;\n\n for (var i = 0; i < 2; ++i) {\n\n if (i === 0) {\n b = 6 * x0 - 12 * x1 + 6 * x2;\n a = -3 * x0 + 9 * x1 - 9 * x2 + 3 * x3;\n c = 3 * x1 - 3 * x0;\n\n } else {\n b = 6 * y0 - 12 * y1 + 6 * y2;\n a = -3 * y0 + 9 * y1 - 9 * y2 + 3 * y3;\n c = 3 * y1 - 3 * y0;\n }\n\n if (abs(a) < 1e-12) { // Numerical robustness\n if (abs(b) < 1e-12) { // Numerical robustness\n continue;\n }\n\n t = -c / b;\n if ((0 < t) && (t < 1)) tvalues.push(t);\n\n continue;\n }\n\n b2ac = b * b - 4 * c * a;\n sqrtb2ac = sqrt(b2ac);\n\n if (b2ac < 0) continue;\n\n t1 = (-b + sqrtb2ac) / (2 * a);\n if ((0 < t1) && (t1 < 1)) tvalues.push(t1);\n\n t2 = (-b - sqrtb2ac) / (2 * a);\n if ((0 < t2) && (t2 < 1)) tvalues.push(t2);\n }\n\n var j = tvalues.length;\n var jlen = j;\n var mt;\n var x, y;\n\n while (j--) {\n t = tvalues[j];\n mt = 1 - t;\n\n x = (mt * mt * mt * x0) + (3 * mt * mt * t * x1) + (3 * mt * t * t * x2) + (t * t * t * x3);\n bounds[0][j] = x;\n\n y = (mt * mt * mt * y0) + (3 * mt * mt * t * y1) + (3 * mt * t * t * y2) + (t * t * t * y3);\n bounds[1][j] = y;\n\n points[j] = { X: x, Y: y };\n }\n\n tvalues[jlen] = 0;\n tvalues[jlen + 1] = 1;\n\n points[jlen] = { X: x0, Y: y0 };\n points[jlen + 1] = { X: x3, Y: y3 };\n\n bounds[0][jlen] = x0;\n bounds[1][jlen] = y0;\n\n bounds[0][jlen + 1] = x3;\n bounds[1][jlen + 1] = y3;\n\n tvalues.length = jlen + 2;\n bounds[0].length = jlen + 2;\n bounds[1].length = jlen + 2;\n points.length = jlen + 2;\n\n var left = min.apply(null, bounds[0]);\n var top = min.apply(null, bounds[1]);\n var right = max.apply(null, bounds[0]);\n var bottom = max.apply(null, bounds[1]);\n\n return new Rect(left, top, (right - left), (bottom - top));\n },\n\n clone: function() {\n\n return new Curve(this.start, this.controlPoint1, this.controlPoint2, this.end);\n },\n\n // Returns the point on the curve closest to point `p`\n closestPoint: function(p, opt) {\n\n return this.pointAtT(this.closestPointT(p, opt));\n },\n\n closestPointLength: function(p, opt) {\n\n opt = opt || {};\n var precision = (opt.precision === undefined) ? this.PRECISION : opt.precision;\n var subdivisions = (opt.subdivisions === undefined) ? this.getSubdivisions({ precision: precision }) : opt.subdivisions;\n var localOpt = { precision: precision, subdivisions: subdivisions };\n\n return this.lengthAtT(this.closestPointT(p, localOpt), localOpt);\n },\n\n closestPointNormalizedLength: function(p, opt) {\n\n opt = opt || {};\n var precision = (opt.precision === undefined) ? this.PRECISION : opt.precision;\n var subdivisions = (opt.subdivisions === undefined) ? this.getSubdivisions({ precision: precision }) : opt.subdivisions;\n var localOpt = { precision: precision, subdivisions: subdivisions };\n\n var cpLength = this.closestPointLength(p, localOpt);\n if (!cpLength) return 0;\n\n var length = this.length(localOpt);\n if (length === 0) return 0;\n\n return cpLength / length;\n },\n\n // Returns `t` of the point on the curve closest to point `p`\n closestPointT: function(p, opt) {\n\n opt = opt || {};\n var precision = (opt.precision === undefined) ? this.PRECISION : opt.precision;\n var subdivisions = (opt.subdivisions === undefined) ? this.getSubdivisions({ precision: precision }) : opt.subdivisions;\n // does not use localOpt\n\n // identify the subdivision that contains the point:\n var investigatedSubdivision;\n var investigatedSubdivisionStartT; // assume that subdivisions are evenly spaced\n var investigatedSubdivisionEndT;\n var distFromStart; // distance of point from start of baseline\n var distFromEnd; // distance of point from end of baseline\n var chordLength; // distance between start and end of the subdivision\n var minSumDist; // lowest observed sum of the two distances\n var n = subdivisions.length;\n var subdivisionSize = (n ? (1 / n) : 0);\n for (var i = 0; i < n; i++) {\n\n var currentSubdivision = subdivisions[i];\n\n var startDist = currentSubdivision.start.distance(p);\n var endDist = currentSubdivision.end.distance(p);\n var sumDist = startDist + endDist;\n\n // check that the point is closest to current subdivision and not any other\n if (!minSumDist || (sumDist < minSumDist)) {\n investigatedSubdivision = currentSubdivision;\n\n investigatedSubdivisionStartT = i * subdivisionSize;\n investigatedSubdivisionEndT = (i + 1) * subdivisionSize;\n\n distFromStart = startDist;\n distFromEnd = endDist;\n\n chordLength = currentSubdivision.start.distance(currentSubdivision.end);\n\n minSumDist = sumDist;\n }\n }\n\n var precisionRatio = pow(10, -precision);\n\n // recursively divide investigated subdivision:\n // until distance between baselinePoint and closest path endpoint is within 10^(-precision)\n // then return the closest endpoint of that final subdivision\n while (true) {\n\n // check if we have reached at least one required observed precision\n // - calculated as: the difference in distances from point to start and end divided by the distance\n // - note that this function is not monotonic = it doesn't converge stably but has \"teeth\"\n // - the function decreases while one of the endpoints is fixed but \"jumps\" whenever we switch\n // - this criterion works well for points lying far away from the curve\n var startPrecisionRatio = (distFromStart ? (abs(distFromStart - distFromEnd) / distFromStart) : 0);\n var endPrecisionRatio = (distFromEnd ? (abs(distFromStart - distFromEnd) / distFromEnd) : 0);\n var hasRequiredPrecision = ((startPrecisionRatio < precisionRatio) || (endPrecisionRatio < precisionRatio));\n\n // check if we have reached at least one required minimal distance\n // - calculated as: the subdivision chord length multiplied by precisionRatio\n // - calculation is relative so it will work for arbitrarily large/small curves and their subdivisions\n // - this is a backup criterion that works well for points lying \"almost at\" the curve\n var hasMinimalStartDistance = (distFromStart ? (distFromStart < (chordLength * precisionRatio)) : true);\n var hasMinimalEndDistance = (distFromEnd ? (distFromEnd < (chordLength * precisionRatio)) : true);\n var hasMinimalDistance = (hasMinimalStartDistance || hasMinimalEndDistance);\n\n // do we stop now?\n if (hasRequiredPrecision || hasMinimalDistance) {\n return ((distFromStart <= distFromEnd) ? investigatedSubdivisionStartT : investigatedSubdivisionEndT);\n }\n\n // otherwise, set up for next iteration\n var divided = investigatedSubdivision.divide(0.5);\n subdivisionSize /= 2;\n\n var startDist1 = divided[0].start.distance(p);\n var endDist1 = divided[0].end.distance(p);\n var sumDist1 = startDist1 + endDist1;\n\n var startDist2 = divided[1].start.distance(p);\n var endDist2 = divided[1].end.distance(p);\n var sumDist2 = startDist2 + endDist2;\n\n if (sumDist1 <= sumDist2) {\n investigatedSubdivision = divided[0];\n\n investigatedSubdivisionEndT -= subdivisionSize; // subdivisionSize was already halved\n\n distFromStart = startDist1;\n distFromEnd = endDist1;\n\n } else {\n investigatedSubdivision = divided[1];\n\n investigatedSubdivisionStartT += subdivisionSize; // subdivisionSize was already halved\n\n distFromStart = startDist2;\n distFromEnd = endDist2;\n }\n }\n },\n\n closestPointTangent: function(p, opt) {\n\n return this.tangentAtT(this.closestPointT(p, opt));\n },\n\n // Returns `true` if the area surrounded by the curve contains the point `p`.\n // Implements the even-odd algorithm (self-intersections are \"outside\").\n // Closes open curves (always imagines a closing segment).\n // Precision may be adjusted by passing an `opt` object.\n containsPoint: function(p, opt) {\n\n var polyline = this.toPolyline(opt);\n return polyline.containsPoint(p);\n },\n\n // Divides the curve into two at requested `ratio` between 0 and 1 with precision better than `opt.precision`; optionally using `opt.subdivisions` provided.\n // For a function that uses `t`, use Curve.divideAtT().\n divideAt: function(ratio, opt) {\n\n if (ratio <= 0) return this.divideAtT(0);\n if (ratio >= 1) return this.divideAtT(1);\n\n var t = this.tAt(ratio, opt);\n\n return this.divideAtT(t);\n },\n\n // Divides the curve into two at requested `length` with precision better than requested `opt.precision`; optionally using `opt.subdivisions` provided.\n divideAtLength: function(length, opt) {\n\n var t = this.tAtLength(length, opt);\n\n return this.divideAtT(t);\n },\n\n // Divides the curve into two at point defined by `t` between 0 and 1.\n // Using de Casteljau's algorithm (http://math.stackexchange.com/a/317867).\n // Additional resource: https://pomax.github.io/bezierinfo/#decasteljau\n divideAtT: function(t) {\n\n var start = this.start;\n var controlPoint1 = this.controlPoint1;\n var controlPoint2 = this.controlPoint2;\n var end = this.end;\n\n // shortcuts for `t` values that are out of range\n if (t <= 0) {\n return [\n new Curve(start, start, start, start),\n new Curve(start, controlPoint1, controlPoint2, end)\n ];\n }\n\n if (t >= 1) {\n return [\n new Curve(start, controlPoint1, controlPoint2, end),\n new Curve(end, end, end, end)\n ];\n }\n\n var dividerPoints = this.getSkeletonPoints(t);\n\n var startControl1 = dividerPoints.startControlPoint1;\n var startControl2 = dividerPoints.startControlPoint2;\n var divider = dividerPoints.divider;\n var dividerControl1 = dividerPoints.dividerControlPoint1;\n var dividerControl2 = dividerPoints.dividerControlPoint2;\n\n // return array with two new curves\n return [\n new Curve(start, startControl1, startControl2, divider),\n new Curve(divider, dividerControl1, dividerControl2, end)\n ];\n },\n\n // Returns the distance between the curve's start and end points.\n endpointDistance: function() {\n\n return this.start.distance(this.end);\n },\n\n // Checks whether two curves are exactly the same.\n equals: function(c) {\n\n return !!c &&\n this.start.x === c.start.x &&\n this.start.y === c.start.y &&\n this.controlPoint1.x === c.controlPoint1.x &&\n this.controlPoint1.y === c.controlPoint1.y &&\n this.controlPoint2.x === c.controlPoint2.x &&\n this.controlPoint2.y === c.controlPoint2.y &&\n this.end.x === c.end.x &&\n this.end.y === c.end.y;\n },\n\n // Returns five helper points necessary for curve division.\n getSkeletonPoints: function(t) {\n\n var start = this.start;\n var control1 = this.controlPoint1;\n var control2 = this.controlPoint2;\n var end = this.end;\n\n // shortcuts for `t` values that are out of range\n if (t <= 0) {\n return {\n startControlPoint1: start.clone(),\n startControlPoint2: start.clone(),\n divider: start.clone(),\n dividerControlPoint1: control1.clone(),\n dividerControlPoint2: control2.clone()\n };\n }\n\n if (t >= 1) {\n return {\n startControlPoint1: control1.clone(),\n startControlPoint2: control2.clone(),\n divider: end.clone(),\n dividerControlPoint1: end.clone(),\n dividerControlPoint2: end.clone()\n };\n }\n\n var midpoint1 = (new Line(start, control1)).pointAt(t);\n var midpoint2 = (new Line(control1, control2)).pointAt(t);\n var midpoint3 = (new Line(control2, end)).pointAt(t);\n\n var subControl1 = (new Line(midpoint1, midpoint2)).pointAt(t);\n var subControl2 = (new Line(midpoint2, midpoint3)).pointAt(t);\n\n var divider = (new Line(subControl1, subControl2)).pointAt(t);\n\n var output = {\n startControlPoint1: midpoint1,\n startControlPoint2: subControl1,\n divider: divider,\n dividerControlPoint1: subControl2,\n dividerControlPoint2: midpoint3\n };\n\n return output;\n },\n\n // Returns a list of curves whose flattened length is better than `opt.precision`.\n // That is, observed difference in length between recursions is less than 10^(-3) = 0.001 = 0.1%\n // (Observed difference is not real precision, but close enough as long as special cases are covered)\n // As a rule of thumb, increasing `precision` by 1 requires 2 more iterations (= levels of division operations)\n // - Precision 0 (endpointDistance) - 0 iterations => total of 2^0 - 1 = 0 operations (1 subdivision)\n // - Precision 1 (<10% error) - 2 iterations => total of 2^2 - 1 = 3 operations (4 subdivisions)\n // - Precision 2 (<1% error) - 4 iterations => total of 2^4 - 1 = 15 operations requires 4 division operations on all elements (15 operations total) (16 subdivisions)\n // - Precision 3 (<0.1% error) - 6 iterations => total of 2^6 - 1 = 63 operations - acceptable when drawing (64 subdivisions)\n // - Precision 4 (<0.01% error) - 8 iterations => total of 2^8 - 1 = 255 operations - high resolution, can be used to interpolate `t` (256 subdivisions)\n // (Variation of 1 recursion worse or better is possible depending on the curve, doubling/halving the number of operations accordingly)\n getSubdivisions: function(opt) {\n\n opt = opt || {};\n var precision = (opt.precision === undefined) ? this.PRECISION : opt.precision;\n // not using opt.subdivisions\n // not using localOpt\n\n var start = this.start;\n var control1 = this.controlPoint1;\n var control2 = this.controlPoint2;\n var end = this.end;\n\n var subdivisions = [new Curve(start, control1, control2, end)];\n if (precision === 0) return subdivisions;\n\n // special case #1: point-like curves\n // - no need to calculate subdivisions, they would all be identical\n var isPoint = !this.isDifferentiable();\n if (isPoint) return subdivisions;\n\n var previousLength = this.endpointDistance();\n\n var precisionRatio = pow(10, -precision);\n\n // special case #2: sine-like curves may have the same observed length in iteration 0 and 1 - skip iteration 1\n // - not a problem for further iterations because cubic curves cannot have more than two local extrema\n // - (i.e. cubic curves cannot intersect the baseline more than once)\n // - therefore starting from iteration = 2 ensures that subsequent iterations do not produce sampling with equal length\n // - (unless it's a straight-line curve, see below)\n var minIterations = 2; // = 2*1\n\n // special case #3: straight-line curves have the same observed length in all iterations\n // - this causes observed precision ratio to always be 0 (= lower than `precisionRatio`, which is our exit condition)\n // - we enforce the expected number of iterations = 2 * precision\n var isLine = ((control1.cross(start, end) === 0) && (control2.cross(start, end) === 0));\n if (isLine) {\n minIterations = (2 * precision);\n }\n\n // recursively divide curve at `t = 0.5`\n // until we reach `minIterations`\n // and until the difference between observed length at subsequent iterations is lower than `precision`\n var iteration = 0;\n while (true) {\n iteration += 1;\n\n // divide all subdivisions\n var newSubdivisions = [];\n var numSubdivisions = subdivisions.length;\n for (var i = 0; i < numSubdivisions; i++) {\n\n var currentSubdivision = subdivisions[i];\n var divided = currentSubdivision.divide(0.5); // dividing at t = 0.5 (not at middle length!)\n newSubdivisions.push(divided[0], divided[1]);\n }\n\n // measure new length\n var length = 0;\n var numNewSubdivisions = newSubdivisions.length;\n for (var j = 0; j < numNewSubdivisions; j++) {\n\n var currentNewSubdivision = newSubdivisions[j];\n length += currentNewSubdivision.endpointDistance();\n }\n\n // check if we have reached minimum number of iterations\n if (iteration >= minIterations) {\n\n // check if we have reached required observed precision\n var observedPrecisionRatio = ((length !== 0) ? ((length - previousLength) / length) : 0);\n if (observedPrecisionRatio < precisionRatio) {\n return newSubdivisions;\n }\n }\n\n // otherwise, set up for next iteration\n subdivisions = newSubdivisions;\n previousLength = length;\n }\n },\n\n isDifferentiable: function() {\n\n var start = this.start;\n var control1 = this.controlPoint1;\n var control2 = this.controlPoint2;\n var end = this.end;\n\n return !(start.equals(control1) && control1.equals(control2) && control2.equals(end));\n },\n\n // Returns flattened length of the curve with precision better than `opt.precision`; or using `opt.subdivisions` provided.\n length: function(opt) {\n\n opt = opt || {};\n var precision = (opt.precision === undefined) ? this.PRECISION : opt.precision; // opt.precision only used in getSubdivisions() call\n var subdivisions = (opt.subdivisions === undefined) ? this.getSubdivisions({ precision: precision }) : opt.subdivisions;\n // not using localOpt\n\n var length = 0;\n var n = subdivisions.length;\n for (var i = 0; i < n; i++) {\n\n var currentSubdivision = subdivisions[i];\n length += currentSubdivision.endpointDistance();\n }\n\n return length;\n },\n\n // Returns distance along the curve up to `t` with precision better than requested `opt.precision`. (Not using `opt.subdivisions`.)\n lengthAtT: function(t, opt) {\n\n if (t <= 0) return 0;\n\n opt = opt || {};\n var precision = (opt.precision === undefined) ? this.PRECISION : opt.precision;\n // not using opt.subdivisions\n // not using localOpt\n\n var subCurve = this.divide(t)[0];\n var subCurveLength = subCurve.length({ precision: precision });\n\n return subCurveLength;\n },\n\n // Returns point at requested `ratio` between 0 and 1 with precision better than `opt.precision`; optionally using `opt.subdivisions` provided.\n // Mirrors Line.pointAt() function.\n // For a function that tracks `t`, use Curve.pointAtT().\n pointAt: function(ratio, opt) {\n\n if (ratio <= 0) return this.start.clone();\n if (ratio >= 1) return this.end.clone();\n\n var t = this.tAt(ratio, opt);\n\n return this.pointAtT(t);\n },\n\n // Returns point at requested `length` with precision better than requested `opt.precision`; optionally using `opt.subdivisions` provided.\n pointAtLength: function(length, opt) {\n\n var t = this.tAtLength(length, opt);\n\n return this.pointAtT(t);\n },\n\n // Returns the point at provided `t` between 0 and 1.\n // `t` does not track distance along curve as it does in Line objects.\n // Non-linear relationship, speeds up and slows down as curve warps!\n // For linear length-based solution, use Curve.pointAt().\n pointAtT: function(t) {\n\n if (t <= 0) return this.start.clone();\n if (t >= 1) return this.end.clone();\n\n return this.getSkeletonPoints(t).divider;\n },\n\n // Default precision\n PRECISION: 3,\n\n round: function(precision) {\n\n this.start.round(precision);\n this.controlPoint1.round(precision);\n this.controlPoint2.round(precision);\n this.end.round(precision);\n return this;\n },\n\n scale: function(sx, sy, origin) {\n\n this.start.scale(sx, sy, origin);\n this.controlPoint1.scale(sx, sy, origin);\n this.controlPoint2.scale(sx, sy, origin);\n this.end.scale(sx, sy, origin);\n return this;\n },\n\n // Returns a tangent line at requested `ratio` with precision better than requested `opt.precision`; or using `opt.subdivisions` provided.\n tangentAt: function(ratio, opt) {\n\n if (!this.isDifferentiable()) return null;\n\n if (ratio < 0) ratio = 0;\n else if (ratio > 1) ratio = 1;\n\n var t = this.tAt(ratio, opt);\n\n return this.tangentAtT(t);\n },\n\n // Returns a tangent line at requested `length` with precision better than requested `opt.precision`; or using `opt.subdivisions` provided.\n tangentAtLength: function(length, opt) {\n\n if (!this.isDifferentiable()) return null;\n\n var t = this.tAtLength(length, opt);\n\n return this.tangentAtT(t);\n },\n\n // Returns a tangent line at requested `t`.\n tangentAtT: function(t) {\n\n if (!this.isDifferentiable()) return null;\n\n if (t < 0) t = 0;\n else if (t > 1) t = 1;\n\n var skeletonPoints = this.getSkeletonPoints(t);\n\n var p1 = skeletonPoints.startControlPoint2;\n var p2 = skeletonPoints.dividerControlPoint1;\n\n var tangentStart = skeletonPoints.divider;\n\n var tangentLine = new Line(p1, p2);\n tangentLine.translate(tangentStart.x - p1.x, tangentStart.y - p1.y); // move so that tangent line starts at the point requested\n\n return tangentLine;\n },\n\n // Returns `t` at requested `ratio` with precision better than requested `opt.precision`; optionally using `opt.subdivisions` provided.\n tAt: function(ratio, opt) {\n\n if (ratio <= 0) return 0;\n if (ratio >= 1) return 1;\n\n opt = opt || {};\n var precision = (opt.precision === undefined) ? this.PRECISION : opt.precision;\n var subdivisions = (opt.subdivisions === undefined) ? this.getSubdivisions({ precision: precision }) : opt.subdivisions;\n var localOpt = { precision: precision, subdivisions: subdivisions };\n\n var curveLength = this.length(localOpt);\n var length = curveLength * ratio;\n\n return this.tAtLength(length, localOpt);\n },\n\n // Returns `t` at requested `length` with precision better than requested `opt.precision`; optionally using `opt.subdivisions` provided.\n // Uses `precision` to approximate length within `precision` (always underestimates)\n // Then uses a binary search to find the `t` of a subdivision endpoint that is close (within `precision`) to the `length`, if the curve was as long as approximated\n // As a rule of thumb, increasing `precision` by 1 causes the algorithm to go 2^(precision - 1) deeper\n // - Precision 0 (chooses one of the two endpoints) - 0 levels\n // - Precision 1 (chooses one of 5 points, <10% error) - 1 level\n // - Precision 2 (<1% error) - 3 levels\n // - Precision 3 (<0.1% error) - 7 levels\n // - Precision 4 (<0.01% error) - 15 levels\n tAtLength: function(length, opt) {\n\n var fromStart = true;\n if (length < 0) {\n fromStart = false; // negative lengths mean start calculation from end point\n length = -length; // absolute value\n }\n\n opt = opt || {};\n var precision = (opt.precision === undefined) ? this.PRECISION : opt.precision;\n var subdivisions = (opt.subdivisions === undefined) ? this.getSubdivisions({ precision: precision }) : opt.subdivisions;\n var localOpt = { precision: precision, subdivisions: subdivisions };\n\n // identify the subdivision that contains the point at requested `length`:\n var investigatedSubdivision;\n var investigatedSubdivisionStartT; // assume that subdivisions are evenly spaced\n var investigatedSubdivisionEndT;\n //var baseline; // straightened version of subdivision to investigate\n //var baselinePoint; // point on the baseline that is the requested distance away from start\n var baselinePointDistFromStart; // distance of baselinePoint from start of baseline\n var baselinePointDistFromEnd; // distance of baselinePoint from end of baseline\n var l = 0; // length so far\n var n = subdivisions.length;\n var subdivisionSize = 1 / n;\n for (var i = 0; i < n; i++) {\n var index = (fromStart ? i : (n - 1 - i));\n\n var currentSubdivision = subdivisions[i];\n var d = currentSubdivision.endpointDistance(); // length of current subdivision\n\n if (length <= (l + d)) {\n investigatedSubdivision = currentSubdivision;\n\n investigatedSubdivisionStartT = index * subdivisionSize;\n investigatedSubdivisionEndT = (index + 1) * subdivisionSize;\n\n baselinePointDistFromStart = (fromStart ? (length - l) : ((d + l) - length));\n baselinePointDistFromEnd = (fromStart ? ((d + l) - length) : (length - l));\n\n break;\n }\n\n l += d;\n }\n\n if (!investigatedSubdivision) return (fromStart ? 1 : 0); // length requested is out of range - return maximum t\n // note that precision affects what length is recorded\n // (imprecise measurements underestimate length by up to 10^(-precision) of the precise length)\n // e.g. at precision 1, the length may be underestimated by up to 10% and cause this function to return 1\n\n var curveLength = this.length(localOpt);\n\n var precisionRatio = pow(10, -precision);\n\n // recursively divide investigated subdivision:\n // until distance between baselinePoint and closest path endpoint is within 10^(-precision)\n // then return the closest endpoint of that final subdivision\n while (true) {\n\n // check if we have reached required observed precision\n var observedPrecisionRatio;\n\n observedPrecisionRatio = ((curveLength !== 0) ? (baselinePointDistFromStart / curveLength) : 0);\n if (observedPrecisionRatio < precisionRatio) return investigatedSubdivisionStartT;\n observedPrecisionRatio = ((curveLength !== 0) ? (baselinePointDistFromEnd / curveLength) : 0);\n if (observedPrecisionRatio < precisionRatio) return investigatedSubdivisionEndT;\n\n // otherwise, set up for next iteration\n var newBaselinePointDistFromStart;\n var newBaselinePointDistFromEnd;\n\n var divided = investigatedSubdivision.divide(0.5);\n subdivisionSize /= 2;\n\n var baseline1Length = divided[0].endpointDistance();\n var baseline2Length = divided[1].endpointDistance();\n\n if (baselinePointDistFromStart <= baseline1Length) { // point at requested length is inside divided[0]\n investigatedSubdivision = divided[0];\n\n investigatedSubdivisionEndT -= subdivisionSize; // sudivisionSize was already halved\n\n newBaselinePointDistFromStart = baselinePointDistFromStart;\n newBaselinePointDistFromEnd = baseline1Length - newBaselinePointDistFromStart;\n\n } else { // point at requested length is inside divided[1]\n investigatedSubdivision = divided[1];\n\n investigatedSubdivisionStartT += subdivisionSize; // subdivisionSize was already halved\n\n newBaselinePointDistFromStart = baselinePointDistFromStart - baseline1Length;\n newBaselinePointDistFromEnd = baseline2Length - newBaselinePointDistFromStart;\n }\n\n baselinePointDistFromStart = newBaselinePointDistFromStart;\n baselinePointDistFromEnd = newBaselinePointDistFromEnd;\n }\n },\n\n // Returns an array of points that represents the curve when flattened, up to `opt.precision`; or using `opt.subdivisions` provided.\n // Flattened length is no more than 10^(-precision) away from real curve length.\n toPoints: function(opt) {\n\n opt = opt || {};\n var precision = (opt.precision === undefined) ? this.PRECISION : opt.precision; // opt.precision only used in getSubdivisions() call\n var subdivisions = (opt.subdivisions === undefined) ? this.getSubdivisions({ precision: precision }) : opt.subdivisions;\n // not using localOpt\n\n var points = [subdivisions[0].start.clone()];\n var n = subdivisions.length;\n for (var i = 0; i < n; i++) {\n\n var currentSubdivision = subdivisions[i];\n points.push(currentSubdivision.end.clone());\n }\n\n return points;\n },\n\n // Returns a polyline that represents the curve when flattened, up to `opt.precision`; or using `opt.subdivisions` provided.\n // Flattened length is no more than 10^(-precision) away from real curve length.\n toPolyline: function(opt) {\n\n return new Polyline(this.toPoints(opt));\n },\n\n toString: function() {\n\n return this.start + ' ' + this.controlPoint1 + ' ' + this.controlPoint2 + ' ' + this.end;\n },\n\n translate: function(tx, ty) {\n\n this.start.translate(tx, ty);\n this.controlPoint1.translate(tx, ty);\n this.controlPoint2.translate(tx, ty);\n this.end.translate(tx, ty);\n return this;\n }\n};\n\nCurve.prototype.divide = Curve.prototype.divideAtT;\n","// Local helper function.\n// Add properties from arguments on top of properties from `obj`.\n// This allows for rudimentary inheritance.\n// - The `obj` argument acts as parent.\n// - This function creates a new object that inherits all `obj` properties and adds/replaces those that are present in arguments.\n// - A high-level example: calling `extend(Vehicle, Car)` would be akin to declaring `class Car extends Vehicle`.\nexport function extend(obj) {\n // In JavaScript, the combination of a constructor function (e.g. `g.Line = function(...) {...}`) and prototype (e.g. `g.Line.prototype = {...}) is akin to a C++ class.\n // - When inheritance is not necessary, we can leave it at that. (This would be akin to calling extend with only `obj`.)\n // - But, what if we wanted the `g.Line` quasiclass to inherit from another quasiclass (let's call it `g.GeometryObject`) in JavaScript?\n // - First, realize that both of those quasiclasses would still have their own separate constructor function.\n // - So what we are actually saying is that we want the `g.Line` prototype to inherit from `g.GeometryObject` prototype.\n // - This method provides a way to do exactly that.\n // - It copies parent prototype's properties, then adds extra ones from child prototype/overrides parent prototype properties with child prototype properties.\n // - Therefore, to continue with the example above:\n // - `g.Line.prototype = extend(g.GeometryObject.prototype, linePrototype)`\n // - Where `linePrototype` is a properties object that looks just like `g.Line.prototype` does right now.\n // - Then, `g.Line` would allow the programmer to access to all methods currently in `g.Line.Prototype`, plus any non-overridden methods from `g.GeometryObject.prototype`.\n // - In that aspect, `g.GeometryObject` would then act like the parent of `g.Line`.\n // - Multiple inheritance is also possible, if multiple arguments are provided.\n // - What if we wanted to add another level of abstraction between `g.GeometryObject` and `g.Line` (let's call it `g.LinearObject`)?\n // - `g.Line.prototype = extend(g.GeometryObject.prototype, g.LinearObject.prototype, linePrototype)`\n // - The ancestors are applied in order of appearance.\n // - That means that `g.Line` would have inherited from `g.LinearObject` that would have inherited from `g.GeometryObject`.\n // - Any number of ancestors may be provided.\n // - Note that neither `obj` nor any of the arguments need to actually be prototypes of any JavaScript quasiclass, that was just a simplified explanation.\n // - We can create a new object composed from the properties of any number of other objects (since they do not have a constructor, we can think of those as interfaces).\n // - `extend({ a: 1, b: 2 }, { b: 10, c: 20 }, { c: 100, d: 200 })` gives `{ a: 1, b: 10, c: 100, d: 200 }`.\n // - Basically, with this function, we can emulate the `extends` keyword as well as the `implements` keyword.\n // - Therefore, both of the following are valid:\n // - `Lineto.prototype = extend(Line.prototype, segmentPrototype, linetoPrototype)`\n // - `Moveto.prototype = extend(segmentPrototype, movetoPrototype)`\n\n var i;\n var n;\n\n var args = [];\n n = arguments.length;\n for (i = 1; i < n; i++) { // skip over obj\n args.push(arguments[i]);\n }\n\n if (!obj) throw new Error('Missing a parent object.');\n var child = Object.create(obj);\n\n n = args.length;\n for (i = 0; i < n; i++) {\n\n var src = args[i];\n\n var inheritedProperty;\n var key;\n for (key in src) {\n\n if (src.hasOwnProperty(key)) {\n delete child[key]; // delete property inherited from parent\n inheritedProperty = Object.getOwnPropertyDescriptor(src, key); // get new definition of property from src\n Object.defineProperty(child, key, inheritedProperty); // re-add property with new definition (includes getter/setter methods)\n }\n }\n }\n\n return child;\n}\n","// Accepts path data string, array of segments, array of Curves and/or Lines, or a Polyline.\n// Path created is not guaranteed to be a valid (serializable) path (might not start with an M).\nimport { Polyline } from './polyline.mjs';\nimport { Rect } from './rect.mjs';\nimport { Point } from './point.mjs';\nimport { Line } from './line.mjs';\nimport { Curve } from './curve.mjs';\nimport { types } from './types.mjs';\nimport { extend } from './extend.mjs';\nexport const Path = function(arg) {\n\n if (!(this instanceof Path)) {\n return new Path(arg);\n }\n\n if (typeof arg === 'string') { // create from a path data string\n return new Path.parse(arg);\n }\n\n this.segments = [];\n\n var i;\n var n;\n\n if (!arg) {\n // don't do anything\n\n } else if (Array.isArray(arg) && arg.length !== 0) { // if arg is a non-empty array\n // flatten one level deep\n // so we can chain arbitrary Path.createSegment results\n arg = arg.reduce(function(acc, val) {\n return acc.concat(val);\n }, []);\n\n n = arg.length;\n if (arg[0].isSegment) { // create from an array of segments\n for (i = 0; i < n; i++) {\n\n var segment = arg[i];\n\n this.appendSegment(segment);\n }\n\n } else { // create from an array of Curves and/or Lines\n var previousObj = null;\n for (i = 0; i < n; i++) {\n\n var obj = arg[i];\n\n if (!((obj instanceof Line) || (obj instanceof Curve))) {\n throw new Error('Cannot construct a path segment from the provided object.');\n }\n\n if (i === 0) this.appendSegment(Path.createSegment('M', obj.start));\n\n // if objects do not link up, moveto segments are inserted to cover the gaps\n if (previousObj && !previousObj.end.equals(obj.start)) this.appendSegment(Path.createSegment('M', obj.start));\n\n if (obj instanceof Line) {\n this.appendSegment(Path.createSegment('L', obj.end));\n\n } else if (obj instanceof Curve) {\n this.appendSegment(Path.createSegment('C', obj.controlPoint1, obj.controlPoint2, obj.end));\n }\n\n previousObj = obj;\n }\n }\n\n } else if (arg.isSegment) { // create from a single segment\n this.appendSegment(arg);\n\n } else if (arg instanceof Line) { // create from a single Line\n this.appendSegment(Path.createSegment('M', arg.start));\n this.appendSegment(Path.createSegment('L', arg.end));\n\n } else if (arg instanceof Curve) { // create from a single Curve\n this.appendSegment(Path.createSegment('M', arg.start));\n this.appendSegment(Path.createSegment('C', arg.controlPoint1, arg.controlPoint2, arg.end));\n\n } else if (arg instanceof Polyline) { // create from a Polyline\n if (!(arg.points && (arg.points.length !== 0))) return; // if Polyline has no points, leave Path empty\n\n n = arg.points.length;\n for (i = 0; i < n; i++) {\n\n var point = arg.points[i];\n\n if (i === 0) this.appendSegment(Path.createSegment('M', point));\n else this.appendSegment(Path.createSegment('L', point));\n }\n\n } else { // unknown object\n throw new Error('Cannot construct a path from the provided object.');\n }\n};\n\n// More permissive than V.normalizePathData and Path.prototype.serialize.\n// Allows path data strings that do not start with a Moveto command (unlike SVG specification).\n// Does not require spaces between elements; commas are allowed, separators may be omitted when unambiguous (e.g. 'ZM10,10', 'L1.6.8', 'M100-200').\n// Allows for command argument chaining.\n// Throws an error if wrong number of arguments is provided with a command.\n// Throws an error if an unrecognized path command is provided (according to Path.segmentTypes). Only a subset of SVG commands is currently supported (L, C, M, Z).\nPath.parse = function(pathData) {\n\n if (!pathData) return new Path();\n\n var path = new Path();\n\n var commandRe = /(?:[a-zA-Z] *)(?:(?:-?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)? *,? *)|(?:-?\\.\\d+ *,? *))+|(?:[a-zA-Z] *)(?! |\\d|-|\\.)/g;\n var commands = pathData.match(commandRe);\n\n var numCommands = commands.length;\n for (var i = 0; i < numCommands; i++) {\n\n var command = commands[i];\n var argRe = /(?:[a-zA-Z])|(?:(?:-?\\d+(?:\\.\\d+)?(?:e[-+]?\\d+)?))|(?:(?:-?\\.\\d+))/g;\n var args = command.match(argRe);\n\n var segment = Path.createSegment.apply(this, args); // args = [type, coordinate1, coordinate2...]\n path.appendSegment(segment);\n }\n\n return path;\n};\n\n// Create a segment or an array of segments.\n// Accepts unlimited points/coords arguments after `type`.\nPath.createSegment = function(type) {\n\n if (!type) throw new Error('Type must be provided.');\n\n var segmentConstructor = Path.segmentTypes[type];\n if (!segmentConstructor) throw new Error(type + ' is not a recognized path segment type.');\n\n var args = [];\n var n = arguments.length;\n for (var i = 1; i < n; i++) { // do not add first element (`type`) to args array\n args.push(arguments[i]);\n }\n\n return applyToNew(segmentConstructor, args);\n};\n\nPath.prototype = {\n\n type: types.Path,\n\n // Accepts one segment or an array of segments as argument.\n // Throws an error if argument is not a segment or an array of segments.\n appendSegment: function(arg) {\n\n var segments = this.segments;\n var numSegments = segments.length;\n // works even if path has no segments\n\n var currentSegment;\n\n var previousSegment = ((numSegments !== 0) ? segments[numSegments - 1] : null); // if we are appending to an empty path, previousSegment is null\n var nextSegment = null;\n\n if (!Array.isArray(arg)) { // arg is a segment\n if (!arg || !arg.isSegment) throw new Error('Segment required.');\n\n currentSegment = this.prepareSegment(arg, previousSegment, nextSegment);\n segments.push(currentSegment);\n\n } else { // arg is an array of segments\n // flatten one level deep\n // so we can chain arbitrary Path.createSegment results\n arg = arg.reduce(function(acc, val) {\n return acc.concat(val);\n }, []);\n\n if (!arg[0].isSegment) throw new Error('Segments required.');\n\n var n = arg.length;\n for (var i = 0; i < n; i++) {\n\n var currentArg = arg[i];\n currentSegment = this.prepareSegment(currentArg, previousSegment, nextSegment);\n segments.push(currentSegment);\n previousSegment = currentSegment;\n }\n }\n },\n\n // Returns the bbox of the path.\n // If path has no segments, returns null.\n // If path has only invisible segments, returns bbox of the end point of last segment.\n bbox: function() {\n\n var segments = this.segments;\n var numSegments = segments.length;\n if (numSegments === 0) return null; // if segments is an empty array\n\n var bbox;\n for (var i = 0; i < numSegments; i++) {\n\n var segment = segments[i];\n if (segment.isVisible) {\n var segmentBBox = segment.bbox();\n bbox = bbox ? bbox.union(segmentBBox) : segmentBBox;\n }\n }\n\n if (bbox) return bbox;\n\n // if the path has only invisible elements, return end point of last segment\n var lastSegment = segments[numSegments - 1];\n return new Rect(lastSegment.end.x, lastSegment.end.y, 0, 0);\n },\n\n // Returns a new path that is a clone of this path.\n clone: function() {\n\n var segments = this.segments;\n var numSegments = segments.length;\n // works even if path has no segments\n\n var path = new Path();\n for (var i = 0; i < numSegments; i++) {\n\n var segment = segments[i].clone();\n path.appendSegment(segment);\n }\n\n return path;\n },\n\n closestPoint: function(p, opt) {\n\n var t = this.closestPointT(p, opt);\n if (!t) return null;\n\n return this.pointAtT(t);\n },\n\n closestPointLength: function(p, opt) {\n\n opt = opt || {};\n var precision = (opt.precision === undefined) ? this.PRECISION : opt.precision;\n var segmentSubdivisions = (opt.segmentSubdivisions === undefined) ? this.getSegmentSubdivisions({ precision: precision }) : opt.segmentSubdivisions;\n var localOpt = { precision: precision, segmentSubdivisions: segmentSubdivisions };\n\n var t = this.closestPointT(p, localOpt);\n if (!t) return 0;\n\n return this.lengthAtT(t, localOpt);\n },\n\n closestPointNormalizedLength: function(p, opt) {\n\n opt = opt || {};\n var precision = (opt.precision === undefined) ? this.PRECISION : opt.precision;\n var segmentSubdivisions = (opt.segmentSubdivisions === undefined) ? this.getSegmentSubdivisions({ precision: precision }) : opt.segmentSubdivisions;\n var localOpt = { precision: precision, segmentSubdivisions: segmentSubdivisions };\n\n var cpLength = this.closestPointLength(p, localOpt);\n if (cpLength === 0) return 0; // shortcut\n\n var length = this.length(localOpt);\n if (length === 0) return 0; // prevents division by zero\n\n return cpLength / length;\n },\n\n // Private function.\n closestPointT: function(p, opt) {\n\n var segments = this.segments;\n var numSegments = segments.length;\n if (numSegments === 0) return null; // if segments is an empty array\n\n opt = opt || {};\n var precision = (opt.precision === undefined) ? this.PRECISION : opt.precision;\n var segmentSubdivisions = (opt.segmentSubdivisions === undefined) ? this.getSegmentSubdivisions({ precision: precision }) : opt.segmentSubdivisions;\n // not using localOpt\n\n var closestPointT;\n var minSquaredDistance = Infinity;\n for (var i = 0; i < numSegments; i++) {\n\n var segment = segments[i];\n var subdivisions = segmentSubdivisions[i];\n\n if (segment.isVisible) {\n var segmentClosestPointT = segment.closestPointT(p, {\n precision: precision,\n subdivisions: subdivisions\n });\n var segmentClosestPoint = segment.pointAtT(segmentClosestPointT);\n var squaredDistance = (new Line(segmentClosestPoint, p)).squaredLength();\n\n if (squaredDistance < minSquaredDistance) {\n closestPointT = { segmentIndex: i, value: segmentClosestPointT };\n minSquaredDistance = squaredDistance;\n }\n }\n }\n\n if (closestPointT) return closestPointT;\n\n // if no visible segment, return end of last segment\n return { segmentIndex: numSegments - 1, value: 1 };\n },\n\n closestPointTangent: function(p, opt) {\n\n var segments = this.segments;\n var numSegments = segments.length;\n if (numSegments === 0) return null; // if segments is an empty array\n\n opt = opt || {};\n var precision = (opt.precision === undefined) ? this.PRECISION : opt.precision;\n var segmentSubdivisions = (opt.segmentSubdivisions === undefined) ? this.getSegmentSubdivisions({ precision: precision }) : opt.segmentSubdivisions;\n // not using localOpt\n\n var closestPointTangent;\n var minSquaredDistance = Infinity;\n for (var i = 0; i < numSegments; i++) {\n\n var segment = segments[i];\n var subdivisions = segmentSubdivisions[i];\n\n if (segment.isDifferentiable()) {\n var segmentClosestPointT = segment.closestPointT(p, {\n precision: precision,\n subdivisions: subdivisions\n });\n var segmentClosestPoint = segment.pointAtT(segmentClosestPointT);\n var squaredDistance = (new Line(segmentClosestPoint, p)).squaredLength();\n\n if (squaredDistance < minSquaredDistance) {\n closestPointTangent = segment.tangentAtT(segmentClosestPointT);\n minSquaredDistance = squaredDistance;\n }\n }\n }\n\n if (closestPointTangent) return closestPointTangent;\n\n // if no valid segment, return null\n return null;\n },\n\n // Returns `true` if the area surrounded by the path contains the point `p`.\n // Implements the even-odd algorithm (self-intersections are \"outside\").\n // Closes open paths (always imagines a final closing segment).\n // Precision may be adjusted by passing an `opt` object.\n containsPoint: function(p, opt) {\n\n var polylines = this.toPolylines(opt);\n if (!polylines) return false; // shortcut (this path has no polylines)\n\n var numPolylines = polylines.length;\n\n // how many component polylines does `p` lie within?\n var numIntersections = 0;\n for (var i = 0; i < numPolylines; i++) {\n var polyline = polylines[i];\n if (polyline.containsPoint(p)) {\n // `p` lies within this polyline\n numIntersections++;\n }\n }\n\n // returns `true` for odd numbers of intersections (even-odd algorithm)\n return ((numIntersections % 2) === 1);\n },\n\n // Divides the path into two at requested `ratio` between 0 and 1 with precision better than `opt.precision`; optionally using `opt.subdivisions` provided.\n divideAt: function(ratio, opt) {\n\n var segments = this.segments;\n var numSegments = segments.length;\n if (numSegments === 0) return null; // if segments is an empty array\n\n if (ratio < 0) ratio = 0;\n if (ratio > 1) ratio = 1;\n\n opt = opt || {};\n var precision = (opt.precision === undefined) ? this.PRECISION : opt.precision;\n var segmentSubdivisions = (opt.segmentSubdivisions === undefined) ? this.getSegmentSubdivisions({ precision: precision }) : opt.segmentSubdivisions;\n var localOpt = { precision: precision, segmentSubdivisions: segmentSubdivisions };\n\n var pathLength = this.length(localOpt);\n var length = pathLength * ratio;\n\n return this.divideAtLength(length, localOpt);\n },\n\n // Divides the path into two at requested `length` with precision better than requested `opt.precision`; optionally using `opt.subdivisions` provided.\n divideAtLength: function(length, opt) {\n\n var numSegments = this.segments.length;\n if (numSegments === 0) return null; // if segments is an empty array\n\n var fromStart = true;\n if (length < 0) {\n fromStart = false; // negative lengths mean start calculation from end point\n length = -length; // absolute value\n }\n\n opt = opt || {};\n var precision = (opt.precision === undefined) ? this.PRECISION : opt.precision;\n var segmentSubdivisions = (opt.segmentSubdivisions === undefined) ? this.getSegmentSubdivisions({ precision: precision }) : opt.segmentSubdivisions;\n // not using localOpt\n\n var i;\n var segment;\n\n // identify the segment to divide:\n\n var l = 0; // length so far\n var divided;\n var dividedSegmentIndex;\n var lastValidSegment; // visible AND differentiable\n var lastValidSegmentIndex;\n var t;\n for (i = 0; i < numSegments; i++) {\n var index = (fromStart ? i : (numSegments - 1 - i));\n\n segment = this.getSegment(index);\n var subdivisions = segmentSubdivisions[index];\n var d = segment.length({ precision: precision, subdivisions: subdivisions });\n\n if (segment.isDifferentiable()) { // segment is not just a point\n lastValidSegment = segment;\n lastValidSegmentIndex = index;\n\n if (length <= (l + d)) {\n dividedSegmentIndex = index;\n divided = segment.divideAtLength(((fromStart ? 1 : -1) * (length - l)), {\n precision: precision,\n subdivisions: subdivisions\n });\n break;\n }\n }\n\n l += d;\n }\n\n if (!lastValidSegment) { // no valid segment found\n return null;\n }\n\n // else: the path contains at least one valid segment\n\n if (!divided) { // the desired length is greater than the length of the path\n dividedSegmentIndex = lastValidSegmentIndex;\n t = (fromStart ? 1 : 0);\n divided = lastValidSegment.divideAtT(t);\n }\n\n // create a copy of this path and replace the identified segment with its two divided parts:\n\n var pathCopy = this.clone();\n pathCopy.replaceSegment(dividedSegmentIndex, divided);\n\n var divisionStartIndex = dividedSegmentIndex;\n var divisionMidIndex = dividedSegmentIndex + 1;\n var divisionEndIndex = dividedSegmentIndex + 2;\n\n // do not insert the part if it looks like a point\n if (!divided[0].isDifferentiable()) {\n pathCopy.removeSegment(divisionStartIndex);\n divisionMidIndex -= 1;\n divisionEndIndex -= 1;\n }\n\n // insert a Moveto segment to ensure secondPath will be valid:\n var movetoEnd = pathCopy.getSegment(divisionMidIndex).start;\n pathCopy.insertSegment(divisionMidIndex, Path.createSegment('M', movetoEnd));\n divisionEndIndex += 1;\n\n // do not insert the part if it looks like a point\n if (!divided[1].isDifferentiable()) {\n pathCopy.removeSegment(divisionEndIndex - 1);\n divisionEndIndex -= 1;\n }\n\n // ensure that Closepath segments in secondPath will be assigned correct subpathStartSegment:\n\n var secondPathSegmentIndexConversion = divisionEndIndex - divisionStartIndex - 1;\n for (i = divisionEndIndex; i < pathCopy.segments.length; i++) {\n\n var originalSegment = this.getSegment(i - secondPathSegmentIndexConversion);\n segment = pathCopy.getSegment(i);\n\n if ((segment.type === 'Z') && !originalSegment.subpathStartSegment.end.equals(segment.subpathStartSegment.end)) {\n // pathCopy segment's subpathStartSegment is different from original segment's one\n // convert this Closepath segment to a Lineto and replace it in pathCopy\n var convertedSegment = Path.createSegment('L', originalSegment.end);\n pathCopy.replaceSegment(i, convertedSegment);\n }\n }\n\n // distribute pathCopy segments into two paths and return those:\n\n var firstPath = new Path(pathCopy.segments.slice(0, divisionMidIndex));\n var secondPath = new Path(pathCopy.segments.slice(divisionMidIndex));\n\n return [firstPath, secondPath];\n },\n\n // Checks whether two paths are exactly the same.\n // If `p` is undefined or null, returns false.\n equals: function(p) {\n\n if (!p) return false;\n\n var segments = this.segments;\n var otherSegments = p.segments;\n\n var numSegments = segments.length;\n if (otherSegments.length !== numSegments) return false; // if the two paths have different number of segments, they cannot be equal\n\n for (var i = 0; i < numSegments; i++) {\n\n var segment = segments[i];\n var otherSegment = otherSegments[i];\n\n // as soon as an inequality is found in segments, return false\n if ((segment.type !== otherSegment.type) || (!segment.equals(otherSegment))) return false;\n }\n\n // if no inequality found in segments, return true\n return true;\n },\n\n // Accepts negative indices.\n // Throws an error if path has no segments.\n // Throws an error if index is out of range.\n getSegment: function(index) {\n\n var segments = this.segments;\n var numSegments = segments.length;\n if (numSegments === 0) throw new Error('Path has no segments.');\n\n if (index < 0) index = numSegments + index; // convert negative indices to positive\n if (index >= numSegments || index < 0) throw new Error('Index out of range.');\n\n return segments[index];\n },\n\n // Returns an array of segment subdivisions, with precision better than requested `opt.precision`.\n getSegmentSubdivisions: function(opt) {\n\n var segments = this.segments;\n var numSegments = segments.length;\n // works even if path has no segments\n\n opt = opt || {};\n var precision = (opt.precision === undefined) ? this.PRECISION : opt.precision;\n // not using opt.segmentSubdivisions\n // not using localOpt\n\n var segmentSubdivisions = [];\n for (var i = 0; i < numSegments; i++) {\n\n var segment = segments[i];\n var subdivisions = segment.getSubdivisions({ precision: precision });\n segmentSubdivisions.push(subdivisions);\n }\n\n return segmentSubdivisions;\n },\n\n // Returns an array of subpaths of this path.\n // Invalid paths are validated first.\n // Returns `[]` if path has no segments.\n getSubpaths: function() {\n\n const validatedPath = this.clone().validate();\n\n const segments = validatedPath.segments;\n const numSegments = segments.length;\n\n const subpaths = [];\n for (let i = 0; i < numSegments; i++) {\n\n const segment = segments[i];\n if (segment.isSubpathStart) {\n // we encountered a subpath start segment\n // create a new path for segment, and push it to list of subpaths\n subpaths.push(new Path(segment));\n\n } else {\n // append current segment to the last subpath\n subpaths[subpaths.length - 1].appendSegment(segment);\n }\n }\n\n return subpaths;\n },\n\n // Insert `arg` at given `index`.\n // `index = 0` means insert at the beginning.\n // `index = segments.length` means insert at the end.\n // Accepts negative indices, from `-1` to `-(segments.length + 1)`.\n // Accepts one segment or an array of segments as argument.\n // Throws an error if index is out of range.\n // Throws an error if argument is not a segment or an array of segments.\n insertSegment: function(index, arg) {\n\n var segments = this.segments;\n var numSegments = segments.length;\n // works even if path has no segments\n\n // note that these are incremented compared to getSegments()\n // we can insert after last element (note that this changes the meaning of index -1)\n if (index < 0) index = numSegments + index + 1; // convert negative indices to positive\n if (index > numSegments || index < 0) throw new Error('Index out of range.');\n\n var currentSegment;\n\n var previousSegment = null;\n var nextSegment = null;\n\n if (numSegments !== 0) {\n if (index >= 1) {\n previousSegment = segments[index - 1];\n nextSegment = previousSegment.nextSegment; // if we are inserting at end, nextSegment is null\n\n } else { // if index === 0\n // previousSegment is null\n nextSegment = segments[0];\n }\n }\n\n if (!Array.isArray(arg)) {\n if (!arg || !arg.isSegment) throw new Error('Segment required.');\n\n currentSegment = this.prepareSegment(arg, previousSegment, nextSegment);\n segments.splice(index, 0, currentSegment);\n\n } else {\n // flatten one level deep\n // so we can chain arbitrary Path.createSegment results\n arg = arg.reduce(function(acc, val) {\n return acc.concat(val);\n }, []);\n\n if (!arg[0].isSegment) throw new Error('Segments required.');\n\n var n = arg.length;\n for (var i = 0; i < n; i++) {\n\n var currentArg = arg[i];\n currentSegment = this.prepareSegment(currentArg, previousSegment, nextSegment);\n segments.splice((index + i), 0, currentSegment); // incrementing index to insert subsequent segments after inserted segments\n previousSegment = currentSegment;\n }\n }\n },\n\n intersectionWithLine: function(line, opt) {\n\n var intersection = null;\n var polylines = this.toPolylines(opt);\n if (!polylines) return null;\n for (var i = 0, n = polylines.length; i < n; i++) {\n var polyline = polylines[i];\n var polylineIntersection = line.intersect(polyline);\n if (polylineIntersection) {\n intersection || (intersection = []);\n if (Array.isArray(polylineIntersection)) {\n Array.prototype.push.apply(intersection, polylineIntersection);\n } else {\n intersection.push(polylineIntersection);\n }\n }\n }\n\n return intersection;\n },\n\n isDifferentiable: function() {\n\n var segments = this.segments;\n var numSegments = segments.length;\n\n for (var i = 0; i < numSegments; i++) {\n\n var segment = segments[i];\n // as soon as a differentiable segment is found in segments, return true\n if (segment.isDifferentiable()) return true;\n }\n\n // if no differentiable segment is found in segments, return false\n return false;\n },\n\n // Checks whether current path segments are valid.\n // Note that d is allowed to be empty - should disable rendering of the path.\n isValid: function() {\n\n var segments = this.segments;\n var isValid = (segments.length === 0) || (segments[0].type === 'M'); // either empty or first segment is a Moveto\n return isValid;\n },\n\n // Returns length of the path, with precision better than requested `opt.precision`; or using `opt.segmentSubdivisions` provided.\n // If path has no segments, returns 0.\n length: function(opt) {\n\n var segments = this.segments;\n var numSegments = segments.length;\n if (numSegments === 0) return 0; // if segments is an empty array\n\n opt = opt || {};\n var precision = (opt.precision === undefined) ? this.PRECISION : opt.precision; // opt.precision only used in getSegmentSubdivisions() call\n var segmentSubdivisions = (opt.segmentSubdivisions === undefined) ? this.getSegmentSubdivisions({ precision: precision }) : opt.segmentSubdivisions;\n // not using localOpt\n\n var length = 0;\n for (var i = 0; i < numSegments; i++) {\n\n var segment = segments[i];\n var subdivisions = segmentSubdivisions[i];\n length += segment.length({ subdivisions: subdivisions });\n }\n\n return length;\n },\n\n // Private function.\n lengthAtT: function(t, opt) {\n\n var segments = this.segments;\n var numSegments = segments.length;\n if (numSegments === 0) return 0; // if segments is an empty array\n\n var segmentIndex = t.segmentIndex;\n if (segmentIndex < 0) return 0; // regardless of t.value\n\n var tValue = t.value;\n if (segmentIndex >= numSegments) {\n segmentIndex = numSegments - 1;\n tValue = 1;\n } else if (tValue < 0) tValue = 0;\n else if (tValue > 1) tValue = 1;\n\n opt = opt || {};\n var precision = (opt.precision === undefined) ? this.PRECISION : opt.precision;\n var segmentSubdivisions = (opt.segmentSubdivisions === undefined) ? this.getSegmentSubdivisions({ precision: precision }) : opt.segmentSubdivisions;\n // not using localOpt\n\n var subdivisions;\n var length = 0;\n for (var i = 0; i < segmentIndex; i++) {\n\n var segment = segments[i];\n subdivisions = segmentSubdivisions[i];\n length += segment.length({ precisison: precision, subdivisions: subdivisions });\n }\n\n segment = segments[segmentIndex];\n subdivisions = segmentSubdivisions[segmentIndex];\n length += segment.lengthAtT(tValue, { precisison: precision, subdivisions: subdivisions });\n\n return length;\n },\n\n // Returns point at requested `ratio` between 0 and 1, with precision better than requested `opt.precision`; optionally using `opt.segmentSubdivisions` provided.\n pointAt: function(ratio, opt) {\n\n var segments = this.segments;\n var numSegments = segments.length;\n if (numSegments === 0) return null; // if segments is an empty array\n\n if (ratio <= 0) return this.start.clone();\n if (ratio >= 1) return this.end.clone();\n\n opt = opt || {};\n var precision = (opt.precision === undefined) ? this.PRECISION : opt.precision;\n var segmentSubdivisions = (opt.segmentSubdivisions === undefined) ? this.getSegmentSubdivisions({ precision: precision }) : opt.segmentSubdivisions;\n var localOpt = { precision: precision, segmentSubdivisions: segmentSubdivisions };\n\n var pathLength = this.length(localOpt);\n var length = pathLength * ratio;\n\n return this.pointAtLength(length, localOpt);\n },\n\n // Returns point at requested `length`, with precision better than requested `opt.precision`; optionally using `opt.segmentSubdivisions` provided.\n // Accepts negative length.\n pointAtLength: function(length, opt) {\n\n var segments = this.segments;\n var numSegments = segments.length;\n if (numSegments === 0) return null; // if segments is an empty array\n\n if (length === 0) return this.start.clone();\n\n var fromStart = true;\n if (length < 0) {\n fromStart = false; // negative lengths mean start calculation from end point\n length = -length; // absolute value\n }\n\n opt = opt || {};\n var precision = (opt.precision === undefined) ? this.PRECISION : opt.precision;\n var segmentSubdivisions = (opt.segmentSubdivisions === undefined) ? this.getSegmentSubdivisions({ precision: precision }) : opt.segmentSubdivisions;\n // not using localOpt\n\n var lastVisibleSegment;\n var l = 0; // length so far\n for (var i = 0; i < numSegments; i++) {\n var index = (fromStart ? i : (numSegments - 1 - i));\n\n var segment = segments[index];\n var subdivisions = segmentSubdivisions[index];\n var d = segment.length({ precision: precision, subdivisions: subdivisions });\n\n if (segment.isVisible) {\n if (length <= (l + d)) {\n return segment.pointAtLength(((fromStart ? 1 : -1) * (length - l)), {\n precision: precision,\n subdivisions: subdivisions\n });\n }\n\n lastVisibleSegment = segment;\n }\n\n l += d;\n }\n\n // if length requested is higher than the length of the path, return last visible segment endpoint\n if (lastVisibleSegment) return (fromStart ? lastVisibleSegment.end : lastVisibleSegment.start);\n\n // if no visible segment, return last segment end point (no matter if fromStart or no)\n var lastSegment = segments[numSegments - 1];\n return lastSegment.end.clone();\n },\n\n // Private function.\n pointAtT: function(t) {\n\n var segments = this.segments;\n var numSegments = segments.length;\n if (numSegments === 0) return null; // if segments is an empty array\n\n var segmentIndex = t.segmentIndex;\n if (segmentIndex < 0) return segments[0].pointAtT(0);\n if (segmentIndex >= numSegments) return segments[numSegments - 1].pointAtT(1);\n\n var tValue = t.value;\n if (tValue < 0) tValue = 0;\n else if (tValue > 1) tValue = 1;\n\n return segments[segmentIndex].pointAtT(tValue);\n },\n\n // Default precision\n PRECISION: 3,\n\n // Helper method for adding segments.\n prepareSegment: function(segment, previousSegment, nextSegment) {\n\n // insert after previous segment and before previous segment's next segment\n segment.previousSegment = previousSegment;\n segment.nextSegment = nextSegment;\n if (previousSegment) previousSegment.nextSegment = segment;\n if (nextSegment) nextSegment.previousSegment = segment;\n\n var updateSubpathStart = segment;\n if (segment.isSubpathStart) {\n segment.subpathStartSegment = segment; // assign self as subpath start segment\n updateSubpathStart = nextSegment; // start updating from next segment\n }\n\n // assign previous segment's subpath start (or self if it is a subpath start) to subsequent segments\n if (updateSubpathStart) this.updateSubpathStartSegment(updateSubpathStart);\n\n return segment;\n },\n\n // Remove the segment at `index`.\n // Accepts negative indices, from `-1` to `-segments.length`.\n // Throws an error if path has no segments.\n // Throws an error if index is out of range.\n removeSegment: function(index) {\n\n var segments = this.segments;\n var numSegments = segments.length;\n if (numSegments === 0) throw new Error('Path has no segments.');\n\n if (index < 0) index = numSegments + index; // convert negative indices to positive\n if (index >= numSegments || index < 0) throw new Error('Index out of range.');\n\n var removedSegment = segments.splice(index, 1)[0];\n var previousSegment = removedSegment.previousSegment;\n var nextSegment = removedSegment.nextSegment;\n\n // link the previous and next segments together (if present)\n if (previousSegment) previousSegment.nextSegment = nextSegment; // may be null\n if (nextSegment) nextSegment.previousSegment = previousSegment; // may be null\n\n // if removed segment used to start a subpath, update all subsequent segments until another subpath start segment is reached\n if (removedSegment.isSubpathStart && nextSegment) this.updateSubpathStartSegment(nextSegment);\n },\n\n // Replace the segment at `index` with `arg`.\n // Accepts negative indices, from `-1` to `-segments.length`.\n // Accepts one segment or an array of segments as argument.\n // Throws an error if path has no segments.\n // Throws an error if index is out of range.\n // Throws an error if argument is not a segment or an array of segments.\n replaceSegment: function(index, arg) {\n\n var segments = this.segments;\n var numSegments = segments.length;\n if (numSegments === 0) throw new Error('Path has no segments.');\n\n if (index < 0) index = numSegments + index; // convert negative indices to positive\n if (index >= numSegments || index < 0) throw new Error('Index out of range.');\n\n var currentSegment;\n\n var replacedSegment = segments[index];\n var previousSegment = replacedSegment.previousSegment;\n var nextSegment = replacedSegment.nextSegment;\n\n var updateSubpathStart = replacedSegment.isSubpathStart; // boolean: is an update of subpath starts necessary?\n\n if (!Array.isArray(arg)) {\n if (!arg || !arg.isSegment) throw new Error('Segment required.');\n\n currentSegment = this.prepareSegment(arg, previousSegment, nextSegment);\n segments.splice(index, 1, currentSegment); // directly replace\n\n if (updateSubpathStart && currentSegment.isSubpathStart) updateSubpathStart = false; // already updated by `prepareSegment`\n\n } else {\n // flatten one level deep\n // so we can chain arbitrary Path.createSegment results\n arg = arg.reduce(function(acc, val) {\n return acc.concat(val);\n }, []);\n\n if (!arg[0].isSegment) throw new Error('Segments required.');\n\n segments.splice(index, 1);\n\n var n = arg.length;\n for (var i = 0; i < n; i++) {\n\n var currentArg = arg[i];\n currentSegment = this.prepareSegment(currentArg, previousSegment, nextSegment);\n segments.splice((index + i), 0, currentSegment); // incrementing index to insert subsequent segments after inserted segments\n previousSegment = currentSegment;\n\n if (updateSubpathStart && currentSegment.isSubpathStart) updateSubpathStart = false; // already updated by `prepareSegment`\n }\n }\n\n // if replaced segment used to start a subpath and no new subpath start was added, update all subsequent segments until another subpath start segment is reached\n if (updateSubpathStart && nextSegment) this.updateSubpathStartSegment(nextSegment);\n },\n\n round: function(precision) {\n\n var segments = this.segments;\n var numSegments = segments.length;\n\n for (var i = 0; i < numSegments; i++) {\n\n var segment = segments[i];\n segment.round(precision);\n }\n\n return this;\n },\n\n scale: function(sx, sy, origin) {\n\n var segments = this.segments;\n var numSegments = segments.length;\n\n for (var i = 0; i < numSegments; i++) {\n\n var segment = segments[i];\n segment.scale(sx, sy, origin);\n }\n\n return this;\n },\n\n segmentAt: function(ratio, opt) {\n\n var index = this.segmentIndexAt(ratio, opt);\n if (!index) return null;\n\n return this.getSegment(index);\n },\n\n // Accepts negative length.\n segmentAtLength: function(length, opt) {\n\n var index = this.segmentIndexAtLength(length, opt);\n if (!index) return null;\n\n return this.getSegment(index);\n },\n\n segmentIndexAt: function(ratio, opt) {\n\n var segments = this.segments;\n var numSegments = segments.length;\n if (numSegments === 0) return null; // if segments is an empty array\n\n if (ratio < 0) ratio = 0;\n if (ratio > 1) ratio = 1;\n\n opt = opt || {};\n var precision = (opt.precision === undefined) ? this.PRECISION : opt.precision;\n var segmentSubdivisions = (opt.segmentSubdivisions === undefined) ? this.getSegmentSubdivisions({ precision: precision }) : opt.segmentSubdivisions;\n var localOpt = { precision: precision, segmentSubdivisions: segmentSubdivisions };\n\n var pathLength = this.length(localOpt);\n var length = pathLength * ratio;\n\n return this.segmentIndexAtLength(length, localOpt);\n },\n\n // Accepts negative length.\n segmentIndexAtLength: function(length, opt) {\n\n var segments = this.segments;\n var numSegments = segments.length;\n if (numSegments === 0) return null; // if segments is an empty array\n\n var fromStart = true;\n if (length < 0) {\n fromStart = false; // negative lengths mean start calculation from end point\n length = -length; // absolute value\n }\n\n opt = opt || {};\n var precision = (opt.precision === undefined) ? this.PRECISION : opt.precision;\n var segmentSubdivisions = (opt.segmentSubdivisions === undefined) ? this.getSegmentSubdivisions({ precision: precision }) : opt.segmentSubdivisions;\n // not using localOpt\n\n var lastVisibleSegmentIndex = null;\n var l = 0; // length so far\n for (var i = 0; i < numSegments; i++) {\n var index = (fromStart ? i : (numSegments - 1 - i));\n\n var segment = segments[index];\n var subdivisions = segmentSubdivisions[index];\n var d = segment.length({ precision: precision, subdivisions: subdivisions });\n\n if (segment.isVisible) {\n if (length <= (l + d)) return index;\n lastVisibleSegmentIndex = index;\n }\n\n l += d;\n }\n\n // if length requested is higher than the length of the path, return last visible segment index\n // if no visible segment, return null\n return lastVisibleSegmentIndex;\n },\n\n // Returns a string that can be used to reconstruct the path.\n // Additional error checking compared to toString (must start with M segment).\n serialize: function() {\n\n if (!this.isValid()) throw new Error('Invalid path segments.');\n\n return this.toString();\n },\n\n // Returns tangent line at requested `ratio` between 0 and 1, with precision better than requested `opt.precision`; optionally using `opt.segmentSubdivisions` provided.\n tangentAt: function(ratio, opt) {\n\n var segments = this.segments;\n var numSegments = segments.length;\n if (numSegments === 0) return null; // if segments is an empty array\n\n if (ratio < 0) ratio = 0;\n if (ratio > 1) ratio = 1;\n\n opt = opt || {};\n var precision = (opt.precision === undefined) ? this.PRECISION : opt.precision;\n var segmentSubdivisions = (opt.segmentSubdivisions === undefined) ? this.getSegmentSubdivisions({ precision: precision }) : opt.segmentSubdivisions;\n var localOpt = { precision: precision, segmentSubdivisions: segmentSubdivisions };\n\n var pathLength = this.length(localOpt);\n var length = pathLength * ratio;\n\n return this.tangentAtLength(length, localOpt);\n },\n\n // Returns tangent line at requested `length`, with precision better than requested `opt.precision`; optionally using `opt.segmentSubdivisions` provided.\n // Accepts negative length.\n tangentAtLength: function(length, opt) {\n\n var segments = this.segments;\n var numSegments = segments.length;\n if (numSegments === 0) return null; // if segments is an empty array\n\n var fromStart = true;\n if (length < 0) {\n fromStart = false; // negative lengths mean start calculation from end point\n length = -length; // absolute value\n }\n\n opt = opt || {};\n var precision = (opt.precision === undefined) ? this.PRECISION : opt.precision;\n var segmentSubdivisions = (opt.segmentSubdivisions === undefined) ? this.getSegmentSubdivisions({ precision: precision }) : opt.segmentSubdivisions;\n // not using localOpt\n\n var lastValidSegment; // visible AND differentiable (with a tangent)\n var l = 0; // length so far\n for (var i = 0; i < numSegments; i++) {\n var index = (fromStart ? i : (numSegments - 1 - i));\n\n var segment = segments[index];\n var subdivisions = segmentSubdivisions[index];\n var d = segment.length({ precision: precision, subdivisions: subdivisions });\n\n if (segment.isDifferentiable()) {\n if (length <= (l + d)) {\n return segment.tangentAtLength(((fromStart ? 1 : -1) * (length - l)), {\n precision: precision,\n subdivisions: subdivisions\n });\n }\n\n lastValidSegment = segment;\n }\n\n l += d;\n }\n\n // if length requested is higher than the length of the path, return tangent of endpoint of last valid segment\n if (lastValidSegment) {\n var t = (fromStart ? 1 : 0);\n return lastValidSegment.tangentAtT(t);\n }\n\n // if no valid segment, return null\n return null;\n },\n\n // Private function.\n tangentAtT: function(t) {\n\n var segments = this.segments;\n var numSegments = segments.length;\n if (numSegments === 0) return null; // if segments is an empty array\n\n var segmentIndex = t.segmentIndex;\n if (segmentIndex < 0) return segments[0].tangentAtT(0);\n if (segmentIndex >= numSegments) return segments[numSegments - 1].tangentAtT(1);\n\n var tValue = t.value;\n if (tValue < 0) tValue = 0;\n else if (tValue > 1) tValue = 1;\n\n return segments[segmentIndex].tangentAtT(tValue);\n },\n\n toPoints: function(opt) {\n\n var segments = this.segments;\n var numSegments = segments.length;\n if (numSegments === 0) return null; // if segments is an empty array\n\n opt = opt || {};\n var precision = (opt.precision === undefined) ? this.PRECISION : opt.precision;\n var segmentSubdivisions = (opt.segmentSubdivisions === undefined) ? this.getSegmentSubdivisions({ precision: precision }) : opt.segmentSubdivisions;\n\n var points = [];\n var partialPoints = [];\n for (var i = 0; i < numSegments; i++) {\n var segment = segments[i];\n if (segment.isVisible) {\n var currentSegmentSubdivisions = segmentSubdivisions[i];\n if (currentSegmentSubdivisions.length > 0) {\n var subdivisionPoints = currentSegmentSubdivisions.map(function(curve) {\n return curve.start;\n });\n Array.prototype.push.apply(partialPoints, subdivisionPoints);\n } else {\n partialPoints.push(segment.start);\n }\n } else if (partialPoints.length > 0) {\n partialPoints.push(segments[i - 1].end);\n points.push(partialPoints);\n partialPoints = [];\n }\n }\n\n if (partialPoints.length > 0) {\n partialPoints.push(this.end);\n points.push(partialPoints);\n }\n return points;\n },\n\n toPolylines: function(opt) {\n\n var polylines = [];\n var points = this.toPoints(opt);\n if (!points) return null;\n for (var i = 0, n = points.length; i < n; i++) {\n polylines.push(new Polyline(points[i]));\n }\n\n return polylines;\n },\n\n toString: function() {\n\n var segments = this.segments;\n var numSegments = segments.length;\n\n var pathData = '';\n for (var i = 0; i < numSegments; i++) {\n\n var segment = segments[i];\n pathData += segment.serialize() + ' ';\n }\n\n return pathData.trim();\n },\n\n translate: function(tx, ty) {\n\n var segments = this.segments;\n var numSegments = segments.length;\n\n for (var i = 0; i < numSegments; i++) {\n\n var segment = segments[i];\n segment.translate(tx, ty);\n }\n\n return this;\n },\n\n // Helper method for updating subpath start of segments, starting with the one provided.\n updateSubpathStartSegment: function(segment) {\n\n var previousSegment = segment.previousSegment; // may be null\n while (segment && !segment.isSubpathStart) {\n\n // assign previous segment's subpath start segment to this segment\n if (previousSegment) segment.subpathStartSegment = previousSegment.subpathStartSegment; // may be null\n else segment.subpathStartSegment = null; // if segment had no previous segment, assign null - creates an invalid path!\n\n previousSegment = segment;\n segment = segment.nextSegment; // move on to the segment after etc.\n }\n },\n\n // If the path is not valid, insert M 0 0 at the beginning.\n // Path with no segments is considered valid, so nothing is inserted.\n validate: function() {\n\n if (!this.isValid()) this.insertSegment(0, Path.createSegment('M', 0, 0));\n return this;\n }\n};\n\nObject.defineProperty(Path.prototype, 'start', {\n // Getter for the first visible endpoint of the path.\n\n configurable: true,\n\n enumerable: true,\n\n get: function() {\n\n var segments = this.segments;\n var numSegments = segments.length;\n if (numSegments === 0) return null;\n\n for (var i = 0; i < numSegments; i++) {\n\n var segment = segments[i];\n if (segment.isVisible) return segment.start;\n }\n\n // if no visible segment, return last segment end point\n return segments[numSegments - 1].end;\n }\n});\n\nObject.defineProperty(Path.prototype, 'end', {\n // Getter for the last visible endpoint of the path.\n\n configurable: true,\n\n enumerable: true,\n\n get: function() {\n\n var segments = this.segments;\n var numSegments = segments.length;\n if (numSegments === 0) return null;\n\n for (var i = numSegments - 1; i >= 0; i--) {\n\n var segment = segments[i];\n if (segment.isVisible) return segment.end;\n }\n\n // if no visible segment, return last segment end point\n return segments[numSegments - 1].end;\n }\n});\n\n\n// Local helper function.\n// Use an array of arguments to call a constructor (function called with `new`).\n// Adapted from https://stackoverflow.com/a/8843181/2263595\n// It is not necessary to use this function if the arguments can be passed separately (i.e. if the number of arguments is limited).\n// - If that is the case, use `new constructor(arg1, arg2)`, for example.\n// It is not necessary to use this function if the function that needs an array of arguments is not supposed to be used as a constructor.\n// - If that is the case, use `f.apply(thisArg, [arg1, arg2...])`, for example.\nfunction applyToNew(constructor, argsArray) {\n // The `new` keyword can only be applied to functions that take a limited number of arguments.\n // - We can fake that with .bind().\n // - It calls a function (`constructor`, here) with the arguments that were provided to it - effectively transforming an unlimited number of arguments into limited.\n // - So `new (constructor.bind(thisArg, arg1, arg2...))`\n // - `thisArg` can be anything (e.g. null) because `new` keyword resets context to the constructor object.\n // We need to pass in a variable number of arguments to the bind() call.\n // - We can use .apply().\n // - So `new (constructor.bind.apply(constructor, [thisArg, arg1, arg2...]))`\n // - `thisArg` can still be anything because `new` overwrites it.\n // Finally, to make sure that constructor.bind overwriting is not a problem, we switch to `Function.prototype.bind`.\n // - So, the final version is `new (Function.prototype.bind.apply(constructor, [thisArg, arg1, arg2...]))`\n\n // The function expects `argsArray[0]` to be `thisArg`.\n // - This means that whatever is sent as the first element will be ignored.\n // - The constructor will only see arguments starting from argsArray[1].\n // - So, a new dummy element is inserted at the start of the array.\n argsArray.unshift(null);\n\n return new (Function.prototype.bind.apply(constructor, argsArray));\n}\n\n// Path segment interface:\nvar segmentPrototype = {\n\n // virtual\n bbox: function() {\n\n throw new Error('Declaration missing for virtual function.');\n },\n\n // virtual\n clone: function() {\n\n throw new Error('Declaration missing for virtual function.');\n },\n\n // virtual\n closestPoint: function() {\n\n throw new Error('Declaration missing for virtual function.');\n },\n\n // virtual\n closestPointLength: function() {\n\n throw new Error('Declaration missing for virtual function.');\n },\n\n // virtual\n closestPointNormalizedLength: function() {\n\n throw new Error('Declaration missing for virtual function.');\n },\n\n // Redirect calls to closestPointNormalizedLength() function if closestPointT() is not defined for segment.\n closestPointT: function(p) {\n\n if (this.closestPointNormalizedLength) return this.closestPointNormalizedLength(p);\n\n throw new Error('Neither closestPointT() nor closestPointNormalizedLength() function is implemented.');\n },\n\n // virtual\n closestPointTangent: function() {\n\n throw new Error('Declaration missing for virtual function.');\n },\n\n // virtual\n divideAt: function() {\n\n throw new Error('Declaration missing for virtual function.');\n },\n\n // virtual\n divideAtLength: function() {\n\n throw new Error('Declaration missing for virtual function.');\n },\n\n // Redirect calls to divideAt() function if divideAtT() is not defined for segment.\n divideAtT: function(t) {\n\n if (this.divideAt) return this.divideAt(t);\n\n throw new Error('Neither divideAtT() nor divideAt() function is implemented.');\n },\n\n // virtual\n equals: function() {\n\n throw new Error('Declaration missing for virtual function.');\n },\n\n // virtual\n getSubdivisions: function() {\n\n throw new Error('Declaration missing for virtual function.');\n },\n\n // virtual\n isDifferentiable: function() {\n\n throw new Error('Declaration missing for virtual function.');\n },\n\n isSegment: true,\n\n isSubpathStart: false, // true for Moveto segments\n\n isVisible: true, // false for Moveto segments\n\n // virtual\n length: function() {\n\n throw new Error('Declaration missing for virtual function.');\n },\n\n // Return a fraction of result of length() function if lengthAtT() is not defined for segment.\n lengthAtT: function(t) {\n\n if (t <= 0) return 0;\n\n var length = this.length();\n\n if (t >= 1) return length;\n\n return length * t;\n },\n\n nextSegment: null, // needed for subpath start segment updating\n\n // virtual\n pointAt: function() {\n\n throw new Error('Declaration missing for virtual function.');\n },\n\n // virtual\n pointAtLength: function() {\n\n throw new Error('Declaration missing for virtual function.');\n },\n\n // Redirect calls to pointAt() function if pointAtT() is not defined for segment.\n pointAtT: function(t) {\n\n if (this.pointAt) return this.pointAt(t);\n\n throw new Error('Neither pointAtT() nor pointAt() function is implemented.');\n },\n\n previousSegment: null, // needed to get segment start property\n\n // virtual\n round: function() {\n\n throw new Error('Declaration missing for virtual function.');\n },\n\n subpathStartSegment: null, // needed to get Closepath segment end property\n\n // virtual\n scale: function() {\n\n throw new Error('Declaration missing for virtual function.');\n },\n\n // virtual\n serialize: function() {\n\n throw new Error('Declaration missing for virtual function.');\n },\n\n // virtual\n tangentAt: function() {\n\n throw new Error('Declaration missing for virtual function.');\n },\n\n // virtual\n tangentAtLength: function() {\n\n throw new Error('Declaration missing for virtual function.');\n },\n\n // Redirect calls to tangentAt() function if tangentAtT() is not defined for segment.\n tangentAtT: function(t) {\n\n if (this.tangentAt) return this.tangentAt(t);\n\n throw new Error('Neither tangentAtT() nor tangentAt() function is implemented.');\n },\n\n // virtual\n toString: function() {\n\n throw new Error('Declaration missing for virtual function.');\n },\n\n // virtual\n translate: function() {\n\n throw new Error('Declaration missing for virtual function.');\n }\n};\n\n// usually directly assigned\n// getter for Closepath\nObject.defineProperty(segmentPrototype, 'end', {\n\n configurable: true,\n\n enumerable: true,\n\n writable: true\n});\n\n// always a getter\n// always throws error for Moveto\nObject.defineProperty(segmentPrototype, 'start', {\n // get a reference to the end point of previous segment\n\n configurable: true,\n\n enumerable: true,\n\n get: function() {\n\n if (!this.previousSegment) throw new Error('Missing previous segment. (This segment cannot be the first segment of a path; OR segment has not yet been added to a path.)');\n\n return this.previousSegment.end;\n }\n});\n\n// virtual\nObject.defineProperty(segmentPrototype, 'type', {\n\n configurable: true,\n\n enumerable: true,\n\n get: function() {\n\n throw new Error('Bad segment declaration. No type specified.');\n }\n});\n\n// Path segment implementations:\nvar Lineto = function() {\n\n var args = [];\n var n = arguments.length;\n for (var i = 0; i < n; i++) {\n args.push(arguments[i]);\n }\n\n if (!(this instanceof Lineto)) { // switching context of `this` to Lineto when called without `new`\n return applyToNew(Lineto, args);\n }\n\n if (n === 0) {\n throw new Error('Lineto constructor expects a line, 1 point, or 2 coordinates (none provided).');\n }\n\n var outputArray;\n\n if (args[0] instanceof Line) { // lines provided\n if (n === 1) {\n this.end = args[0].end.clone();\n return this;\n\n } else {\n throw new Error('Lineto constructor expects a line, 1 point, or 2 coordinates (' + n + ' lines provided).');\n }\n\n } else if (typeof args[0] === 'string' || typeof args[0] === 'number') { // coordinates provided\n if (n === 2) {\n this.end = new Point(+args[0], +args[1]);\n return this;\n\n } else if (n < 2) {\n throw new Error('Lineto constructor expects a line, 1 point, or 2 coordinates (' + n + ' coordinates provided).');\n\n } else { // this is a poly-line segment\n var segmentCoords;\n outputArray = [];\n for (i = 0; i < n; i += 2) { // coords come in groups of two\n\n segmentCoords = args.slice(i, i + 2); // will send one coord if args.length not divisible by 2\n outputArray.push(applyToNew(Lineto, segmentCoords));\n }\n return outputArray;\n }\n\n } else { // points provided (needs to be last to also cover plain objects with x and y)\n if (n === 1) {\n this.end = new Point(args[0]);\n return this;\n\n } else { // this is a poly-line segment\n var segmentPoint;\n outputArray = [];\n for (i = 0; i < n; i += 1) {\n\n segmentPoint = args[i];\n outputArray.push(new Lineto(segmentPoint));\n }\n return outputArray;\n }\n }\n};\n\nvar linetoPrototype = {\n\n clone: function() {\n\n return new Lineto(this.end);\n },\n\n divideAt: function(ratio) {\n\n var line = new Line(this.start, this.end);\n var divided = line.divideAt(ratio);\n return [\n new Lineto(divided[0]),\n new Lineto(divided[1])\n ];\n },\n\n divideAtLength: function(length) {\n\n var line = new Line(this.start, this.end);\n var divided = line.divideAtLength(length);\n return [\n new Lineto(divided[0]),\n new Lineto(divided[1])\n ];\n },\n\n getSubdivisions: function() {\n\n return [];\n },\n\n isDifferentiable: function() {\n\n if (!this.previousSegment) return false;\n\n return !this.start.equals(this.end);\n },\n\n round: function(precision) {\n\n this.end.round(precision);\n return this;\n },\n\n scale: function(sx, sy, origin) {\n\n this.end.scale(sx, sy, origin);\n return this;\n },\n\n serialize: function() {\n\n var end = this.end;\n return this.type + ' ' + end.x + ' ' + end.y;\n },\n\n toString: function() {\n\n return this.type + ' ' + this.start + ' ' + this.end;\n },\n\n translate: function(tx, ty) {\n\n this.end.translate(tx, ty);\n return this;\n }\n};\n\nObject.defineProperty(linetoPrototype, 'type', {\n\n configurable: true,\n\n enumerable: true,\n\n value: 'L'\n});\n\nLineto.prototype = extend(segmentPrototype, Line.prototype, linetoPrototype);\n\nvar Curveto = function() {\n\n var args = [];\n var n = arguments.length;\n for (var i = 0; i < n; i++) {\n args.push(arguments[i]);\n }\n\n if (!(this instanceof Curveto)) { // switching context of `this` to Curveto when called without `new`\n return applyToNew(Curveto, args);\n }\n\n if (n === 0) {\n throw new Error('Curveto constructor expects a curve, 3 points, or 6 coordinates (none provided).');\n }\n\n var outputArray;\n\n if (args[0] instanceof Curve) { // curves provided\n if (n === 1) {\n this.controlPoint1 = args[0].controlPoint1.clone();\n this.controlPoint2 = args[0].controlPoint2.clone();\n this.end = args[0].end.clone();\n return this;\n\n } else {\n throw new Error('Curveto constructor expects a curve, 3 points, or 6 coordinates (' + n + ' curves provided).');\n }\n\n } else if (typeof args[0] === 'string' || typeof args[0] === 'number') { // coordinates provided\n if (n === 6) {\n this.controlPoint1 = new Point(+args[0], +args[1]);\n this.controlPoint2 = new Point(+args[2], +args[3]);\n this.end = new Point(+args[4], +args[5]);\n return this;\n\n } else if (n < 6) {\n throw new Error('Curveto constructor expects a curve, 3 points, or 6 coordinates (' + n + ' coordinates provided).');\n\n } else { // this is a poly-bezier segment\n var segmentCoords;\n outputArray = [];\n for (i = 0; i < n; i += 6) { // coords come in groups of six\n\n segmentCoords = args.slice(i, i + 6); // will send fewer than six coords if args.length not divisible by 6\n outputArray.push(applyToNew(Curveto, segmentCoords));\n }\n return outputArray;\n }\n\n } else { // points provided (needs to be last to also cover plain objects with x and y)\n if (n === 3) {\n this.controlPoint1 = new Point(args[0]);\n this.controlPoint2 = new Point(args[1]);\n this.end = new Point(args[2]);\n return this;\n\n } else if (n < 3) {\n throw new Error('Curveto constructor expects a curve, 3 points, or 6 coordinates (' + n + ' points provided).');\n\n } else { // this is a poly-bezier segment\n var segmentPoints;\n outputArray = [];\n for (i = 0; i < n; i += 3) { // points come in groups of three\n\n segmentPoints = args.slice(i, i + 3); // will send fewer than three points if args.length is not divisible by 3\n outputArray.push(applyToNew(Curveto, segmentPoints));\n }\n return outputArray;\n }\n }\n};\n\nvar curvetoPrototype = {\n\n clone: function() {\n\n return new Curveto(this.controlPoint1, this.controlPoint2, this.end);\n },\n\n divideAt: function(ratio, opt) {\n\n var curve = new Curve(this.start, this.controlPoint1, this.controlPoint2, this.end);\n var divided = curve.divideAt(ratio, opt);\n return [\n new Curveto(divided[0]),\n new Curveto(divided[1])\n ];\n },\n\n divideAtLength: function(length, opt) {\n\n var curve = new Curve(this.start, this.controlPoint1, this.controlPoint2, this.end);\n var divided = curve.divideAtLength(length, opt);\n return [\n new Curveto(divided[0]),\n new Curveto(divided[1])\n ];\n },\n\n divideAtT: function(t) {\n\n var curve = new Curve(this.start, this.controlPoint1, this.controlPoint2, this.end);\n var divided = curve.divideAtT(t);\n return [\n new Curveto(divided[0]),\n new Curveto(divided[1])\n ];\n },\n\n isDifferentiable: function() {\n\n if (!this.previousSegment) return false;\n\n var start = this.start;\n var control1 = this.controlPoint1;\n var control2 = this.controlPoint2;\n var end = this.end;\n\n return !(start.equals(control1) && control1.equals(control2) && control2.equals(end));\n },\n\n round: function(precision) {\n\n this.controlPoint1.round(precision);\n this.controlPoint2.round(precision);\n this.end.round(precision);\n return this;\n },\n\n scale: function(sx, sy, origin) {\n\n this.controlPoint1.scale(sx, sy, origin);\n this.controlPoint2.scale(sx, sy, origin);\n this.end.scale(sx, sy, origin);\n return this;\n },\n\n serialize: function() {\n\n var c1 = this.controlPoint1;\n var c2 = this.controlPoint2;\n var end = this.end;\n return this.type + ' ' + c1.x + ' ' + c1.y + ' ' + c2.x + ' ' + c2.y + ' ' + end.x + ' ' + end.y;\n },\n\n toString: function() {\n\n return this.type + ' ' + this.start + ' ' + this.controlPoint1 + ' ' + this.controlPoint2 + ' ' + this.end;\n },\n\n translate: function(tx, ty) {\n\n this.controlPoint1.translate(tx, ty);\n this.controlPoint2.translate(tx, ty);\n this.end.translate(tx, ty);\n return this;\n }\n};\n\nObject.defineProperty(curvetoPrototype, 'type', {\n\n configurable: true,\n\n enumerable: true,\n\n value: 'C'\n});\n\nCurveto.prototype = extend(segmentPrototype, Curve.prototype, curvetoPrototype);\n\nvar Moveto = function() {\n\n var args = [];\n var n = arguments.length;\n for (var i = 0; i < n; i++) {\n args.push(arguments[i]);\n }\n\n if (!(this instanceof Moveto)) { // switching context of `this` to Moveto when called without `new`\n return applyToNew(Moveto, args);\n }\n\n if (n === 0) {\n throw new Error('Moveto constructor expects a line, a curve, 1 point, or 2 coordinates (none provided).');\n }\n\n var outputArray;\n\n if (args[0] instanceof Line) { // lines provided\n if (n === 1) {\n this.end = args[0].end.clone();\n return this;\n\n } else {\n throw new Error('Moveto constructor expects a line, a curve, 1 point, or 2 coordinates (' + n + ' lines provided).');\n }\n\n } else if (args[0] instanceof Curve) { // curves provided\n if (n === 1) {\n this.end = args[0].end.clone();\n return this;\n\n } else {\n throw new Error('Moveto constructor expects a line, a curve, 1 point, or 2 coordinates (' + n + ' curves provided).');\n }\n\n } else if (typeof args[0] === 'string' || typeof args[0] === 'number') { // coordinates provided\n if (n === 2) {\n this.end = new Point(+args[0], +args[1]);\n return this;\n\n } else if (n < 2) {\n throw new Error('Moveto constructor expects a line, a curve, 1 point, or 2 coordinates (' + n + ' coordinates provided).');\n\n } else { // this is a moveto-with-subsequent-poly-line segment\n var segmentCoords;\n outputArray = [];\n for (i = 0; i < n; i += 2) { // coords come in groups of two\n\n segmentCoords = args.slice(i, i + 2); // will send one coord if args.length not divisible by 2\n if (i === 0) outputArray.push(applyToNew(Moveto, segmentCoords));\n else outputArray.push(applyToNew(Lineto, segmentCoords));\n }\n return outputArray;\n }\n\n } else { // points provided (needs to be last to also cover plain objects with x and y)\n if (n === 1) {\n this.end = new Point(args[0]);\n return this;\n\n } else { // this is a moveto-with-subsequent-poly-line segment\n var segmentPoint;\n outputArray = [];\n for (i = 0; i < n; i += 1) { // points come one by one\n\n segmentPoint = args[i];\n if (i === 0) outputArray.push(new Moveto(segmentPoint));\n else outputArray.push(new Lineto(segmentPoint));\n }\n return outputArray;\n }\n }\n};\n\nvar movetoPrototype = {\n\n bbox: function() {\n\n return null;\n },\n\n clone: function() {\n\n return new Moveto(this.end);\n },\n\n closestPoint: function() {\n\n return this.end.clone();\n },\n\n closestPointNormalizedLength: function() {\n\n return 0;\n },\n\n closestPointLength: function() {\n\n return 0;\n },\n\n closestPointT: function() {\n\n return 1;\n },\n\n closestPointTangent: function() {\n\n return null;\n },\n\n divideAt: function() {\n\n return [\n this.clone(),\n this.clone()\n ];\n },\n\n divideAtLength: function() {\n\n return [\n this.clone(),\n this.clone()\n ];\n },\n\n equals: function(m) {\n\n return this.end.equals(m.end);\n },\n\n getSubdivisions: function() {\n\n return [];\n },\n\n isDifferentiable: function() {\n\n return false;\n },\n\n isSubpathStart: true,\n\n isVisible: false,\n\n length: function() {\n\n return 0;\n },\n\n lengthAtT: function() {\n\n return 0;\n },\n\n pointAt: function() {\n\n return this.end.clone();\n },\n\n pointAtLength: function() {\n\n return this.end.clone();\n },\n\n pointAtT: function() {\n\n return this.end.clone();\n },\n\n round: function(precision) {\n\n this.end.round(precision);\n return this;\n },\n\n scale: function(sx, sy, origin) {\n\n this.end.scale(sx, sy, origin);\n return this;\n },\n\n serialize: function() {\n\n var end = this.end;\n return this.type + ' ' + end.x + ' ' + end.y;\n },\n\n tangentAt: function() {\n\n return null;\n },\n\n tangentAtLength: function() {\n\n return null;\n },\n\n tangentAtT: function() {\n\n return null;\n },\n\n toString: function() {\n\n return this.type + ' ' + this.end;\n },\n\n translate: function(tx, ty) {\n\n this.end.translate(tx, ty);\n return this;\n }\n};\n\nObject.defineProperty(movetoPrototype, 'start', {\n\n configurable: true,\n\n enumerable: true,\n\n get: function() {\n\n throw new Error('Illegal access. Moveto segments should not need a start property.');\n }\n});\n\nObject.defineProperty(movetoPrototype, 'type', {\n\n configurable: true,\n\n enumerable: true,\n\n value: 'M'\n});\n\nMoveto.prototype = extend(segmentPrototype, movetoPrototype); // does not inherit from any other geometry object\n\nvar Closepath = function() {\n\n var args = [];\n var n = arguments.length;\n for (var i = 0; i < n; i++) {\n args.push(arguments[i]);\n }\n\n if (!(this instanceof Closepath)) { // switching context of `this` to Closepath when called without `new`\n return applyToNew(Closepath, args);\n }\n\n if (n > 0) {\n throw new Error('Closepath constructor expects no arguments.');\n }\n\n return this;\n};\n\nvar closepathPrototype = {\n\n clone: function() {\n\n return new Closepath();\n },\n\n divideAt: function(ratio) {\n\n var line = new Line(this.start, this.end);\n var divided = line.divideAt(ratio);\n return [\n // if we didn't actually cut into the segment, first divided part can stay as Z\n (divided[1].isDifferentiable() ? new Lineto(divided[0]) : this.clone()),\n new Lineto(divided[1])\n ];\n },\n\n divideAtLength: function(length) {\n\n var line = new Line(this.start, this.end);\n var divided = line.divideAtLength(length);\n return [\n // if we didn't actually cut into the segment, first divided part can stay as Z\n (divided[1].isDifferentiable() ? new Lineto(divided[0]) : this.clone()),\n new Lineto(divided[1])\n ];\n },\n\n getSubdivisions: function() {\n\n return [];\n },\n\n isDifferentiable: function() {\n\n if (!this.previousSegment || !this.subpathStartSegment) return false;\n\n return !this.start.equals(this.end);\n },\n\n round: function() {\n\n return this;\n },\n\n scale: function() {\n\n return this;\n },\n\n serialize: function() {\n\n return this.type;\n },\n\n toString: function() {\n\n return this.type + ' ' + this.start + ' ' + this.end;\n },\n\n translate: function() {\n\n return this;\n }\n};\n\nObject.defineProperty(closepathPrototype, 'end', {\n // get a reference to the end point of subpath start segment\n\n configurable: true,\n\n enumerable: true,\n\n get: function() {\n\n if (!this.subpathStartSegment) throw new Error('Missing subpath start segment. (This segment needs a subpath start segment (e.g. Moveto); OR segment has not yet been added to a path.)');\n\n return this.subpathStartSegment.end;\n }\n});\n\nObject.defineProperty(closepathPrototype, 'type', {\n\n configurable: true,\n\n enumerable: true,\n\n value: 'Z'\n});\n\nClosepath.prototype = extend(segmentPrototype, Line.prototype, closepathPrototype);\n\nvar segmentTypes = Path.segmentTypes = {\n L: Lineto,\n C: Curveto,\n M: Moveto,\n Z: Closepath,\n z: Closepath\n};\n\nPath.regexSupportedData = new RegExp('^[\\\\s\\\\d' + Object.keys(segmentTypes).join('') + ',.]*$');\n\nPath.isDataSupported = function(data) {\n\n if (typeof data !== 'string') return false;\n return this.regexSupportedData.test(data);\n};\n","import { Path } from './path.mjs';\nimport { Curve } from './curve.mjs';\nimport { Point } from './point.mjs';\n\nexport const bezier = {\n\n // Cubic Bezier curve path through points.\n // @deprecated\n // @param {array} points Array of points through which the smooth line will go.\n // @return {array} SVG Path commands as an array\n curveThroughPoints: function(points) {\n\n console.warn('deprecated');\n\n return new Path(Curve.throughPoints(points)).serialize();\n },\n\n // Get open-ended Bezier Spline Control Points.\n // @deprecated\n // @param knots Input Knot Bezier spline points (At least two points!).\n // @param firstControlPoints Output First Control points. Array of knots.length - 1 length.\n // @param secondControlPoints Output Second Control points. Array of knots.length - 1 length.\n getCurveControlPoints: function(knots) {\n\n console.warn('deprecated');\n\n var firstControlPoints = [];\n var secondControlPoints = [];\n var n = knots.length - 1;\n var i;\n\n // Special case: Bezier curve should be a straight line.\n if (n == 1) {\n // 3P1 = 2P0 + P3\n firstControlPoints[0] = new Point(\n (2 * knots[0].x + knots[1].x) / 3,\n (2 * knots[0].y + knots[1].y) / 3\n );\n\n // P2 = 2P1 – P0\n secondControlPoints[0] = new Point(\n 2 * firstControlPoints[0].x - knots[0].x,\n 2 * firstControlPoints[0].y - knots[0].y\n );\n\n return [firstControlPoints, secondControlPoints];\n }\n\n // Calculate first Bezier control points.\n // Right hand side vector.\n var rhs = [];\n\n // Set right hand side X values.\n for (i = 1; i < n - 1; i++) {\n rhs[i] = 4 * knots[i].x + 2 * knots[i + 1].x;\n }\n\n rhs[0] = knots[0].x + 2 * knots[1].x;\n rhs[n - 1] = (8 * knots[n - 1].x + knots[n].x) / 2.0;\n\n // Get first control points X-values.\n var x = this.getFirstControlPoints(rhs);\n\n // Set right hand side Y values.\n for (i = 1; i < n - 1; ++i) {\n rhs[i] = 4 * knots[i].y + 2 * knots[i + 1].y;\n }\n\n rhs[0] = knots[0].y + 2 * knots[1].y;\n rhs[n - 1] = (8 * knots[n - 1].y + knots[n].y) / 2.0;\n\n // Get first control points Y-values.\n var y = this.getFirstControlPoints(rhs);\n\n // Fill output arrays.\n for (i = 0; i < n; i++) {\n // First control point.\n firstControlPoints.push(new Point(x[i], y[i]));\n\n // Second control point.\n if (i < n - 1) {\n secondControlPoints.push(new Point(\n 2 * knots [i + 1].x - x[i + 1],\n 2 * knots[i + 1].y - y[i + 1]\n ));\n\n } else {\n secondControlPoints.push(new Point(\n (knots[n].x + x[n - 1]) / 2,\n (knots[n].y + y[n - 1]) / 2)\n );\n }\n }\n\n return [firstControlPoints, secondControlPoints];\n },\n\n // Divide a Bezier curve into two at point defined by value 't' <0,1>.\n // Using deCasteljau algorithm. http://math.stackexchange.com/a/317867\n // @deprecated\n // @param control points (start, control start, control end, end)\n // @return a function that accepts t and returns 2 curves.\n getCurveDivider: function(p0, p1, p2, p3) {\n\n console.warn('deprecated');\n\n var curve = new Curve(p0, p1, p2, p3);\n\n return function divideCurve(t) {\n\n var divided = curve.divide(t);\n\n return [{\n p0: divided[0].start,\n p1: divided[0].controlPoint1,\n p2: divided[0].controlPoint2,\n p3: divided[0].end\n }, {\n p0: divided[1].start,\n p1: divided[1].controlPoint1,\n p2: divided[1].controlPoint2,\n p3: divided[1].end\n }];\n };\n },\n\n // Solves a tridiagonal system for one of coordinates (x or y) of first Bezier control points.\n // @deprecated\n // @param rhs Right hand side vector.\n // @return Solution vector.\n getFirstControlPoints: function(rhs) {\n\n console.warn('deprecated');\n\n var n = rhs.length;\n // `x` is a solution vector.\n var x = [];\n var tmp = [];\n var b = 2.0;\n\n x[0] = rhs[0] / b;\n\n // Decomposition and forward substitution.\n for (var i = 1; i < n; i++) {\n tmp[i] = 1 / b;\n b = (i < n - 1 ? 4.0 : 3.5) - tmp[i];\n x[i] = (rhs[i] - x[i - 1]) / b;\n }\n\n for (i = 1; i < n; i++) {\n // Backsubstitution.\n x[n - i - 1] -= tmp[n - i] * x[n - i];\n }\n\n return x;\n },\n\n // Solves an inversion problem -- Given the (x, y) coordinates of a point which lies on\n // a parametric curve x = x(t)/w(t), y = y(t)/w(t), find the parameter value t\n // which corresponds to that point.\n // @deprecated\n // @param control points (start, control start, control end, end)\n // @return a function that accepts a point and returns t.\n getInversionSolver: function(p0, p1, p2, p3) {\n\n console.warn('deprecated');\n\n var curve = new Curve(p0, p1, p2, p3);\n\n return function solveInversion(p) {\n\n return curve.closestPointT(p);\n };\n }\n};\n","import { Point } from './point.mjs';\nimport { Polyline } from './polyline.mjs';\nimport { extend } from './extend.mjs';\nimport { types } from './types.mjs';\nimport { clonePoints, parsePoints, convexHull } from './points.mjs';\n\nexport const Polygon = function(points) {\n\n if (!(this instanceof Polygon)) {\n return new Polygon(points);\n }\n\n if (typeof points === 'string') {\n return new Polygon.parse(points);\n }\n\n this.points = (Array.isArray(points) ? points.map(Point) : []);\n};\n\nPolygon.parse = function(svgString) {\n return new Polygon(parsePoints(svgString));\n};\n\nPolygon.fromRect = function(rect) {\n return new Polygon([\n rect.topLeft(),\n rect.topRight(),\n rect.bottomRight(),\n rect.bottomLeft()\n ]);\n};\n\nPolygon.prototype = extend(Polyline.prototype, {\n\n type: types.Polygon,\n\n clone: function() {\n return new Polygon(clonePoints(this.points));\n },\n\n convexHull: function() {\n return new Polygon(convexHull(this.points));\n },\n\n lengthPoints: function() {\n const { start, end, points } = this;\n if (points.length <= 1 || start.equals(end)) return points;\n return [...points, start.clone()];\n }\n\n});\n","import { Line } from './line.mjs';\nimport { Polygon } from './polygon.mjs';\nimport { Rect } from './rect.mjs';\nimport { types } from './types.mjs';\n\nexport function exists(shape1, shape2, shape1opt, shape2opt) {\n switch (shape1.type) {\n case types.Line: {\n switch (shape2.type) {\n case types.Line: {\n return lineWithLine(shape1, shape2);\n }\n }\n break;\n }\n case types.Ellipse: {\n switch (shape2.type) {\n case types.Line: {\n return ellipseWithLine(shape1, shape2);\n }\n case types.Ellipse: {\n return ellipseWithEllipse(shape1, shape2);\n }\n }\n break;\n }\n case types.Rect: {\n switch (shape2.type) {\n case types.Line: {\n return rectWithLine(shape1, shape2);\n }\n case types.Ellipse: {\n return rectWithEllipse(shape1, shape2);\n }\n case types.Rect: {\n return rectWithRect(shape1, shape2);\n }\n }\n break;\n }\n case types.Polyline: {\n switch (shape2.type) {\n case types.Line: {\n return polylineWithLine(shape1, shape2);\n }\n case types.Ellipse: {\n return polylineWithEllipse(shape1, shape2);\n }\n case types.Rect: {\n return polylineWithRect(shape1, shape2);\n }\n case types.Polyline: {\n return polylineWithPolyline(shape1, shape2);\n }\n }\n break;\n }\n case types.Polygon: {\n switch (shape2.type) {\n case types.Line: {\n return polygonWithLine(shape1, shape2);\n }\n case types.Ellipse: {\n return polygonWithEllipse(shape1, shape2);\n }\n case types.Rect: {\n return polygonWithRect(shape1, shape2);\n }\n case types.Polyline: {\n return polygonWithPolyline(shape1, shape2);\n }\n case types.Polygon: {\n return polygonWithPolygon(shape1, shape2);\n }\n }\n break;\n }\n case types.Path: {\n switch (shape2.type) {\n case types.Line: {\n return pathWithLine(shape1, shape2, shape1opt);\n }\n case types.Ellipse: {\n return pathWithEllipse(shape1, shape2, shape1opt);\n }\n case types.Rect: {\n return pathWithRect(shape1, shape2, shape1opt);\n }\n case types.Polyline: {\n return pathWithPolyline(shape1, shape2, shape1opt);\n }\n case types.Polygon: {\n return pathWithPolygon(shape1, shape2, shape1opt);\n }\n case types.Path: {\n return pathWithPath(shape1, shape2, shape1opt, shape2opt);\n }\n }\n break;\n }\n }\n // None of the cases above\n switch (shape2.type) {\n case types.Ellipse:\n case types.Rect:\n case types.Polyline:\n case types.Polygon:\n case types.Path: {\n return exists(shape2, shape1, shape2opt, shape1opt);\n }\n default: {\n throw Error(`The intersection for ${shape1} and ${shape2} could not be found.`);\n }\n }\n}\n\n/* Line */\n\nexport function lineWithLine(line1, line2) {\n const x1 = line1.start.x;\n const y1 = line1.start.y;\n const x2 = line1.end.x;\n const y2 = line1.end.y;\n const x3 = line2.start.x;\n const y3 = line2.start.y;\n const x4 = line2.end.x;\n const y4 = line2.end.y;\n const s1x = x2 - x1;\n const s1y = y2 - y1;\n const s2x = x4 - x3;\n const s2y = y4 - y3;\n const s3x = x1 - x3;\n const s3y = y1 - y3;\n const p = s1x * s2y - s2x * s1y;\n const s = (s1x * s3y - s1y * s3x) / p;\n const t = (s2x * s3y - s2y * s3x) / p;\n return s >= 0 && s <= 1 && t >= 0 && t <= 1;\n}\n\n/* Ellipse */\n\nexport function ellipseWithLine(ellipse, line) {\n const rex = ellipse.a;\n const rey = ellipse.b;\n const xe = ellipse.x;\n const ye = ellipse.y;\n const x1 = line.start.x - xe;\n const x2 = line.end.x - xe;\n const y1 = line.start.y - ye;\n const y2 = line.end.y - ye;\n const rex_2 = rex * rex;\n const rey_2 = rey * rey;\n const dx = x2 - x1;\n const dy = y2 - y1;\n const A = dx * dx / rex_2 + dy * dy / rey_2;\n const B = 2 * x1 * dx / rex_2 + 2 * y1 * dy / rey_2;\n const C = x1 * x1 / rex_2 + y1 * y1 / rey_2 - 1;\n const D = B * B - 4 * A * C;\n if (D === 0) {\n const t = -B / 2 / A;\n return t >= 0 && t <= 1;\n } else if (D > 0) {\n const sqrt = Math.sqrt(D);\n const t1 = (-B + sqrt) / 2 / A;\n const t2 = (-B - sqrt) / 2 / A;\n return (t1 >= 0 && t1 <= 1) || (t2 >= 0 && t2 <= 1);\n }\n return false;\n}\n\nexport function ellipseWithEllipse(ellipse1, ellipse2) {\n return _ellipsesIntersection(ellipse1, 0, ellipse2, 0);\n}\n\n/* Rect */\n\nexport function rectWithLine(rect, line) {\n const { start, end } = line;\n const { x, y, width, height } = rect;\n if (\n (start.x > x + width && end.x > x + width)\n || (start.x < x && end.x < x)\n || (start.y > y + height && end.y > y + height)\n || (start.y < y && end.y < y)\n ) {\n return false;\n }\n if (rect.containsPoint(line.start) || rect.containsPoint(line.end)) {\n return true;\n }\n return lineWithLine(rect.topLine(), line)\n || lineWithLine(rect.rightLine(), line)\n || lineWithLine(rect.bottomLine(), line)\n || lineWithLine(rect.leftLine(), line);\n}\n\nexport function rectWithEllipse(rect, ellipse) {\n if (!rectWithRect(rect, Rect.fromEllipse(ellipse))) return false;\n return polygonWithEllipse(Polygon.fromRect(rect), ellipse);\n}\n\nexport function rectWithRect(rect1, rect2) {\n return rect1.x < rect2.x + rect2.width\n && rect1.x + rect1.width > rect2.x\n && rect1.y < rect2.y + rect2.height\n && rect1.y + rect1.height > rect2.y;\n}\n\n/* Polyline */\n\nexport function polylineWithLine(polyline, line) {\n return _polylineWithLine(polyline, line, { interior: false });\n}\n\nexport function polylineWithEllipse(polyline, ellipse) {\n return _polylineWithEllipse(polyline, ellipse, { interior: false });\n}\n\nexport function polylineWithRect(polyline, rect) {\n return _polylineWithRect(polyline, rect, { interior: false });\n}\n\nexport function polylineWithPolyline(polyline1, polyline2) {\n return _polylineWithPolyline(polyline1, polyline2, { interior: false });\n}\n\n/* Polygon */\n\nexport function polygonWithLine(polygon, line) {\n return _polylineWithLine(polygon, line, { interior: true });\n}\n\nexport function polygonWithEllipse(polygon, ellipse) {\n return _polylineWithEllipse(polygon, ellipse, { interior: true });\n}\n\nexport function polygonWithRect(polygon, rect) {\n return _polylineWithRect(polygon, rect, { interior: true });\n}\n\nexport function polygonWithPolyline(polygon, polyline) {\n return _polylineWithPolyline(polygon, polyline, { interior: true });\n}\n\nexport function polygonWithPolygon(polygon1, polygon2) {\n return _polylineWithPolygon(polygon1, polygon2, { interior: true });\n}\n\n/* Path */\n\nexport function pathWithLine(path, line, pathOpt) {\n return path.getSubpaths().some(subpath => {\n const [polyline] = subpath.toPolylines(pathOpt);\n const { type } = subpath.getSegment(-1);\n if (type === 'Z') {\n return polygonWithLine(polyline, line);\n } else {\n return polylineWithLine(polyline, line);\n }\n });\n}\n\nexport function pathWithEllipse(path, ellipse, pathOpt) {\n return path.getSubpaths().some(subpath => {\n const [polyline] = subpath.toPolylines(pathOpt);\n const { type } = subpath.getSegment(-1);\n if (type === 'Z') {\n return polygonWithEllipse(polyline, ellipse);\n } else {\n return polylineWithEllipse(polyline, ellipse);\n }\n });\n}\n\nexport function pathWithRect(path, rect, pathOpt) {\n return pathWithPolygon(path, Polygon.fromRect(rect), pathOpt);\n}\n\nexport function pathWithPolyline(path, polyline, pathOpt) {\n return _pathWithPolyline(path, polyline, pathOpt, { interior: false });\n}\n\nexport function pathWithPolygon(path, polygon, pathOpt) {\n return _pathWithPolyline(path, polygon, pathOpt, { interior: true });\n}\n\nexport function pathWithPath(path1, path2, pathOpt1, pathOpt2) {\n return path1.getSubpaths().some(subpath => {\n const [polyline1] = subpath.toPolylines(pathOpt1);\n const { type } = subpath.getSegment(-1);\n if (type === 'Z') {\n return pathWithPolygon(path2, polyline1, pathOpt2);\n } else {\n return pathWithPolyline(path2, polyline1, pathOpt2);\n }\n });\n}\n\nfunction _polylineWithLine(polyline, line, opt = {}) {\n const { interior = false } = opt;\n let thisPoints;\n if (interior) {\n if (polyline.containsPoint(line.start)) {\n // If any point of the polyline lies inside this polygon (interior = true)\n // there is an intersection (we've chosen the start point)\n return true;\n }\n const { start, end, points } = polyline;\n thisPoints = end.equals(start) ? points : [...points, start];\n } else {\n thisPoints = polyline.points;\n }\n const { length } = thisPoints;\n const segment = new Line();\n for (let i = 0; i < length - 1; i++) {\n segment.start = thisPoints[i];\n segment.end = thisPoints[i + 1];\n if (lineWithLine(line, segment)) {\n return true;\n }\n }\n return false;\n}\n\nfunction _polylineWithEllipse(polyline, ellipse, opt = {}) {\n const { start, end, points } = polyline;\n if (ellipse.containsPoint(start)) {\n return true;\n }\n let thisPoints;\n const { interior = false } = opt;\n if (interior) {\n if (polyline.containsPoint(ellipse.center())) {\n // If any point of the ellipse lies inside this polygon (interior = true)\n // there is an intersection (we've chosen the center point)\n return true;\n }\n thisPoints = end.equals(start) ? points : [...points, start];\n } else {\n thisPoints = points;\n }\n\n const { length } = thisPoints;\n const segment = new Line();\n for (let i = 0; i < length - 1; i++) {\n segment.start = thisPoints[i];\n segment.end = thisPoints[i + 1];\n if (ellipseWithLine(ellipse, segment)) {\n return true;\n }\n }\n return false;\n}\n\nfunction _polylineWithRect(polyline, rect, opt) {\n const polygon = Polygon.fromRect(rect);\n return _polylineWithPolygon(polyline, polygon, opt);\n}\n\nfunction _pathWithPolyline(path, polyline1, pathOpt, opt) {\n return path.getSubpaths().some(subpath => {\n const [polyline2] = subpath.toPolylines(pathOpt);\n const { type } = subpath.getSegment(-1);\n if (type === 'Z') {\n return _polylineWithPolygon(polyline1, polyline2, opt);\n } else {\n return _polylineWithPolyline(polyline1, polyline2, opt);\n }\n });\n}\n\nfunction _polylineWithPolyline(polyline1, polyline2, opt = {}) {\n const { interior = false } = opt;\n let thisPolyline;\n if (interior) {\n const { start } = polyline2;\n if (polyline1.containsPoint(start)) {\n // If any point of the polyline lies inside this polygon (interior = true)\n // there is an intersection (we've chosen the start point)\n return true;\n }\n thisPolyline = polyline1.clone().close();\n } else {\n thisPolyline = polyline1;\n }\n const otherPoints = polyline2.points;\n const { length } = otherPoints;\n const segment = new Line();\n for (let i = 0; i < length - 1; i++) {\n segment.start = otherPoints[i];\n segment.end = otherPoints[i + 1];\n if (polylineWithLine(thisPolyline, segment)) {\n return true;\n }\n }\n return false;\n}\n\nfunction _polylineWithPolygon(polyline, polygon, opt) {\n return polygon.containsPoint(polyline.start) || _polylineWithPolyline(polyline, polygon.clone().close(), opt);\n}\n\nfunction _ellipsesIntersection(e1, w1, e2, w2) {\n const { cos, sin } = Math;\n const sinW1 = sin(w1);\n const cosW1 = cos(w1);\n const sinW2 = sin(w2);\n const cosW2 = cos(w2);\n const sinW1s = sinW1 * sinW1;\n const cosW1s = cosW1 * cosW1;\n const sinCos1 = sinW1 * cosW1;\n const sinW2s = sinW2 * sinW2;\n const cosW2s = cosW2 * cosW2;\n const sinCos2 = sinW2 * cosW2;\n const a1s = e1.a * e1.a;\n const b1s = e1.b * e1.b;\n const a2s = e2.a * e2.a;\n const b2s = e2.b * e2.b;\n const A1 = a1s * sinW1s + b1s * cosW1s;\n const A2 = a2s * sinW2s + b2s * cosW2s;\n const B1 = a1s * cosW1s + b1s * sinW1s;\n const B2 = a2s * cosW2s + b2s * sinW2s;\n let C1 = 2 * (b1s - a1s) * sinCos1;\n let C2 = 2 * (b2s - a2s) * sinCos2;\n let D1 = (-2 * A1 * e1.x - C1 * e1.y);\n let D2 = (-2 * A2 * e2.x - C2 * e2.y);\n let E1 = (-C1 * e1.x - 2 * B1 * e1.y);\n let E2 = (-C2 * e2.x - 2 * B2 * e2.y);\n const F1 = A1 * e1.x * e1.x + B1 * e1.y * e1.y + C1 * e1.x * e1.y - a1s * b1s;\n const F2 = A2 * e2.x * e2.x + B2 * e2.y * e2.y + C2 * e2.x * e2.y - a2s * b2s;\n\n C1 = C1 / 2;\n C2 = C2 / 2;\n D1 = D1 / 2;\n D2 = D2 / 2;\n E1 = E1 / 2;\n E2 = E2 / 2;\n\n const l3 = det3([\n [A1, C1, D1],\n [C1, B1, E1],\n [D1, E1, F1]\n ]);\n const l0 = det3([\n [A2, C2, D2],\n [C2, B2, E2],\n [D2, E2, F2]\n ]);\n const l2 = 0.33333333 * (det3([\n [A2, C1, D1],\n [C2, B1, E1],\n [D2, E1, F1]\n ]) + det3([\n [A1, C2, D1],\n [C1, B2, E1],\n [D1, E2, F1]\n ]) + det3([\n [A1, C1, D2],\n [C1, B1, E2],\n [D1, E1, F2]\n ]));\n const l1 = 0.33333333 * (det3([\n [A1, C2, D2],\n [C1, B2, E2],\n [D1, E2, F2]\n ]) + det3([\n [A2, C1, D2],\n [C2, B1, E2],\n [D2, E1, F2]\n ]) + det3([\n [A2, C2, D1],\n [C2, B2, E1],\n [D2, E2, F1]\n ]));\n\n const delta1 = det2([\n [l3, l2],\n [l2, l1]\n ]);\n const delta2 = det2([\n [l3, l1],\n [l2, l0]\n ]);\n const delta3 = det2([\n [l2, l1],\n [l1, l0]\n ]);\n\n const dP = det2([\n [2 * delta1, delta2],\n [delta2, 2 * delta3]\n ]);\n\n if (dP > 0 && (l1 > 0 || l2 > 0)) {\n return false;\n }\n return true;\n}\n\nfunction det2(m) {\n return m[0][0] * m[1][1] - m[0][1] * m[1][0];\n}\n\nfunction det3(m) {\n return m[0][0] * m[1][1] * m[2][2] -\n m[0][0] * m[1][2] * m[2][1] -\n m[0][1] * m[1][0] * m[2][2] +\n m[0][1] * m[1][2] * m[2][0] +\n m[0][2] * m[1][0] * m[2][1] -\n m[0][2] * m[1][1] * m[2][0];\n}\n","// Geometry library.\n// -----------------\n\nexport * from './geometry.helpers.mjs';\nexport * from './bezier.mjs';\nexport * from './curve.mjs';\nexport * from './ellipse.mjs';\nexport * from './line.mjs';\nexport * from './path.mjs';\nexport * from './point.mjs';\nexport * from './polyline.mjs';\nexport * from './polygon.mjs';\nexport * from './rect.mjs';\nexport * from './types.mjs';\n\nimport * as _intersection from './intersection.mjs';\nexport const intersection = _intersection;\n","// Vectorizer.\n// -----------\n\n// A tiny library for making your life easier when dealing with SVG.\n// The only Vectorizer dependency is the Geometry library.\n\nimport * as g from '../g/index.mjs';\n\nconst V = (function() {\n\n var hasSvg = typeof window === 'object' && !!window.SVGAngle;\n\n // SVG support is required.\n if (!hasSvg) {\n\n // Return a function that throws an error when it is used.\n return function() {\n throw new Error('SVG is required to use Vectorizer.');\n };\n }\n\n // XML namespaces.\n var ns = {\n svg: 'http://www.w3.org/2000/svg',\n xmlns: 'http://www.w3.org/2000/xmlns/',\n xml: 'http://www.w3.org/XML/1998/namespace',\n xlink: 'http://www.w3.org/1999/xlink',\n xhtml: 'http://www.w3.org/1999/xhtml'\n };\n\n var SVGVersion = '1.1';\n\n // Declare shorthands to the most used math functions.\n var math = Math;\n var PI = math.PI;\n var atan2 = math.atan2;\n var sqrt = math.sqrt;\n var min = math.min;\n var max = math.max;\n var cos = math.cos;\n var sin = math.sin;\n\n var V = function(el, attrs, children) {\n\n // This allows using V() without the new keyword.\n if (!(this instanceof V)) {\n return V.apply(Object.create(V.prototype), arguments);\n }\n\n if (!el) return;\n\n if (V.isV(el)) {\n el = el.node;\n }\n\n attrs = attrs || {};\n\n if (V.isString(el)) {\n\n el = el.trim();\n\n if (el.toLowerCase() === 'svg') {\n\n // Create a new SVG canvas.\n el = V.createSvgDocument();\n\n } else if (el[0] === '<') {\n\n // Create element from an SVG string.\n // Allows constructs of type: `document.appendChild(V('').node)`.\n\n var svgDoc = V.createSvgDocument(el);\n\n // Note that `V()` might also return an array should the SVG string passed as\n // the first argument contain more than one root element.\n if (svgDoc.childNodes.length > 1) {\n\n // Map child nodes to `V`s.\n var arrayOfVels = [];\n var i, len;\n\n for (i = 0, len = svgDoc.childNodes.length; i < len; i++) {\n\n var childNode = svgDoc.childNodes[i];\n arrayOfVels.push(new V(document.importNode(childNode, true)));\n }\n\n return arrayOfVels;\n }\n\n el = document.importNode(svgDoc.firstChild, true);\n\n } else {\n\n el = document.createElementNS(ns.svg, el);\n }\n\n V.ensureId(el);\n }\n\n this.node = el;\n\n this.setAttributes(attrs);\n\n if (children) {\n this.append(children);\n }\n\n return this;\n };\n\n var VPrototype = V.prototype;\n\n Object.defineProperty(VPrototype, 'id', {\n enumerable: true,\n get: function() {\n return this.node.id;\n },\n set: function(id) {\n this.node.id = id;\n }\n });\n\n /**\n * @param {SVGGElement} toElem\n * @returns {SVGMatrix}\n */\n VPrototype.getTransformToElement = function(target) {\n var node = this.node;\n if (V.isSVGGraphicsElement(target) && V.isSVGGraphicsElement(node)) {\n var targetCTM = V.toNode(target).getScreenCTM();\n var nodeCTM = node.getScreenCTM();\n if (targetCTM && nodeCTM) {\n return targetCTM.inverse().multiply(nodeCTM);\n }\n }\n // Could not get actual transformation matrix\n return V.createSVGMatrix();\n };\n\n /**\n * @param {SVGMatrix} matrix\n * @param {Object=} opt\n * @returns {Vectorizer|SVGMatrix} Setter / Getter\n */\n VPrototype.transform = function(matrix, opt) {\n\n var node = this.node;\n if (V.isUndefined(matrix)) {\n return V.transformStringToMatrix(this.attr('transform'));\n }\n\n if (opt && opt.absolute) {\n return this.attr('transform', V.matrixToTransformString(matrix));\n }\n\n var svgTransform = V.createSVGTransform(matrix);\n node.transform.baseVal.appendItem(svgTransform);\n return this;\n };\n\n VPrototype.translate = function(tx, ty, opt) {\n\n opt = opt || {};\n ty = ty || 0;\n\n var transformAttr = this.attr('transform') || '';\n var transform = V.parseTransformString(transformAttr);\n transformAttr = transform.value;\n // Is it a getter?\n if (V.isUndefined(tx)) {\n return transform.translate;\n }\n\n transformAttr = transformAttr.replace(/translate\\([^)]*\\)/g, '').trim();\n\n var newTx = opt.absolute ? tx : transform.translate.tx + tx;\n var newTy = opt.absolute ? ty : transform.translate.ty + ty;\n var newTranslate = 'translate(' + newTx + ',' + newTy + ')';\n\n // Note that `translate()` is always the first transformation. This is\n // usually the desired case.\n this.attr('transform', (newTranslate + ' ' + transformAttr).trim());\n return this;\n };\n\n VPrototype.rotate = function(angle, cx, cy, opt) {\n\n opt = opt || {};\n\n var transformAttr = this.attr('transform') || '';\n var transform = V.parseTransformString(transformAttr);\n transformAttr = transform.value;\n\n // Is it a getter?\n if (V.isUndefined(angle)) {\n return transform.rotate;\n }\n\n transformAttr = transformAttr.replace(/rotate\\([^)]*\\)/g, '').trim();\n\n angle %= 360;\n\n var newAngle = opt.absolute ? angle : transform.rotate.angle + angle;\n var newOrigin = (cx !== undefined && cy !== undefined) ? ',' + cx + ',' + cy : '';\n var newRotate = 'rotate(' + newAngle + newOrigin + ')';\n\n this.attr('transform', (transformAttr + ' ' + newRotate).trim());\n return this;\n };\n\n // Note that `scale` as the only transformation does not combine with previous values.\n VPrototype.scale = function(sx, sy) {\n\n sy = V.isUndefined(sy) ? sx : sy;\n\n var transformAttr = this.attr('transform') || '';\n var transform = V.parseTransformString(transformAttr);\n transformAttr = transform.value;\n\n // Is it a getter?\n if (V.isUndefined(sx)) {\n return transform.scale;\n }\n\n transformAttr = transformAttr.replace(/scale\\([^)]*\\)/g, '').trim();\n\n var newScale = 'scale(' + sx + ',' + sy + ')';\n\n this.attr('transform', (transformAttr + ' ' + newScale).trim());\n return this;\n };\n\n // Get SVGRect that contains coordinates and dimension of the real bounding box,\n // i.e. after transformations are applied.\n // If `target` is specified, bounding box will be computed relatively to `target` element.\n VPrototype.bbox = function(withoutTransformations, target) {\n\n var box;\n var node = this.node;\n var ownerSVGElement = node.ownerSVGElement;\n\n // If the element is not in the live DOM, it does not have a bounding box defined and\n // so fall back to 'zero' dimension element.\n if (!ownerSVGElement) {\n return new g.Rect(0, 0, 0, 0);\n }\n\n try {\n\n box = node.getBBox();\n\n } catch (e) {\n\n // Fallback for IE.\n box = {\n x: node.clientLeft,\n y: node.clientTop,\n width: node.clientWidth,\n height: node.clientHeight\n };\n }\n\n if (withoutTransformations) {\n return new g.Rect(box);\n }\n\n var matrix = this.getTransformToElement(target || ownerSVGElement);\n\n return V.transformRect(box, matrix);\n };\n\n // Returns an SVGRect that contains coordinates and dimensions of the real bounding box,\n // i.e. after transformations are applied.\n // Fixes a browser implementation bug that returns incorrect bounding boxes for groups of svg elements.\n // Takes an (Object) `opt` argument (optional) with the following attributes:\n // (Object) `target` (optional): if not undefined, transform bounding boxes relative to `target`; if undefined, transform relative to this\n // (Boolean) `recursive` (optional): if true, recursively enter all groups and get a union of element bounding boxes (svg bbox fix); if false or undefined, return result of native function this.node.getBBox();\n VPrototype.getBBox = function(opt) {\n\n var options = {};\n\n var outputBBox;\n var node = this.node;\n var ownerSVGElement = node.ownerSVGElement;\n\n // If the element is not in the live DOM, it does not have a bounding box defined and\n // so fall back to 'zero' dimension element.\n // If the element is not an SVGGraphicsElement, we could not measure the bounding box either\n if (!ownerSVGElement || !V.isSVGGraphicsElement(node)) {\n return new g.Rect(0, 0, 0, 0);\n }\n\n if (opt) {\n if (opt.target) { // check if target exists\n options.target = V.toNode(opt.target); // works for V objects, jquery objects, and node objects\n }\n if (opt.recursive) {\n options.recursive = opt.recursive;\n }\n }\n\n if (!options.recursive) {\n try {\n outputBBox = node.getBBox();\n } catch (e) {\n // Fallback for IE.\n outputBBox = {\n x: node.clientLeft,\n y: node.clientTop,\n width: node.clientWidth,\n height: node.clientHeight\n };\n }\n\n if (!options.target) {\n // transform like this (that is, not at all)\n return new g.Rect(outputBBox);\n } else {\n // transform like target\n var matrix = this.getTransformToElement(options.target);\n return V.transformRect(outputBBox, matrix);\n }\n } else { // if we want to calculate the bbox recursively\n // browsers report correct bbox around svg elements (one that envelops the path lines tightly)\n // but some browsers fail to report the same bbox when the elements are in a group (returning a looser bbox that also includes control points, like node.getClientRect())\n // this happens even if we wrap a single svg element into a group!\n // this option setting makes the function recursively enter all the groups from this and deeper, get bboxes of the elements inside, then return a union of those bboxes\n\n var children = this.children();\n var n = children.length;\n\n if (n === 0) {\n return this.getBBox({ target: options.target, recursive: false });\n }\n\n // recursion's initial pass-through setting:\n // recursive passes-through just keep the target as whatever was set up here during the initial pass-through\n if (!options.target) {\n // transform children/descendants like this (their parent/ancestor)\n options.target = this;\n } // else transform children/descendants like target\n\n for (var i = 0; i < n; i++) {\n var currentChild = children[i];\n\n var childBBox;\n\n // if currentChild is not a group element, get its bbox with a nonrecursive call\n if (currentChild.children().length === 0) {\n childBBox = currentChild.getBBox({ target: options.target, recursive: false });\n } else {\n // if currentChild is a group element (determined by checking the number of children), enter it with a recursive call\n childBBox = currentChild.getBBox({ target: options.target, recursive: true });\n }\n\n if (!outputBBox) {\n // if this is the first iteration\n outputBBox = childBBox;\n } else {\n // make a new bounding box rectangle that contains this child's bounding box and previous bounding box\n outputBBox = outputBBox.union(childBBox);\n }\n }\n\n return outputBBox;\n }\n };\n\n // Text() helpers\n\n function createTextPathNode(attrs, vel) {\n attrs || (attrs = {});\n var textPathElement = V('textPath');\n var d = attrs.d;\n if (d && attrs['xlink:href'] === undefined) {\n // If `opt.attrs` is a plain string, consider it to be directly the\n // SVG path data for the text to go along (this is a shortcut).\n // Otherwise if it is an object and contains the `d` property, then this is our path.\n // Wrap the text in the SVG element that points\n // to a path defined by `opt.attrs` inside the `` element.\n var linkedPath = V('path').attr('d', d).appendTo(vel.defs());\n textPathElement.attr('xlink:href', '#' + linkedPath.id);\n }\n if (V.isObject(attrs)) {\n // Set attributes on the ``. The most important one\n // is the `xlink:href` that points to our newly created `` element in ``.\n // Note that we also allow the following construct:\n // `t.text('my text', { textPath: { 'xlink:href': '#my-other-path' } })`.\n // In other words, one can completely skip the auto-creation of the path\n // and use any other arbitrary path that is in the document.\n textPathElement.attr(attrs);\n }\n return textPathElement.node;\n }\n\n function annotateTextLine(lineNode, lineAnnotations, opt) {\n opt || (opt = {});\n var includeAnnotationIndices = opt.includeAnnotationIndices;\n var eol = opt.eol;\n var lineHeight = opt.lineHeight;\n var baseSize = opt.baseSize;\n var maxFontSize = 0;\n var fontMetrics = {};\n var lastJ = lineAnnotations.length - 1;\n for (var j = 0; j <= lastJ; j++) {\n var annotation = lineAnnotations[j];\n var fontSize = null;\n if (V.isObject(annotation)) {\n var annotationAttrs = annotation.attrs;\n var vTSpan = V('tspan', annotationAttrs);\n var tspanNode = vTSpan.node;\n var t = annotation.t;\n if (eol && j === lastJ) t += eol;\n tspanNode.textContent = t;\n // Per annotation className\n var annotationClass = annotationAttrs['class'];\n if (annotationClass) vTSpan.addClass(annotationClass);\n // If `opt.includeAnnotationIndices` is `true`,\n // set the list of indices of all the applied annotations\n // in the `annotations` attribute. This list is a comma\n // separated list of indices.\n if (includeAnnotationIndices) vTSpan.attr('annotations', annotation.annotations);\n // Check for max font size\n fontSize = parseFloat(annotationAttrs['font-size']);\n if (!isFinite(fontSize)) fontSize = baseSize;\n if (fontSize && fontSize > maxFontSize) maxFontSize = fontSize;\n } else {\n if (eol && j === lastJ) annotation += eol;\n tspanNode = document.createTextNode(annotation || ' ');\n if (baseSize && baseSize > maxFontSize) maxFontSize = baseSize;\n }\n lineNode.appendChild(tspanNode);\n }\n\n if (maxFontSize) fontMetrics.maxFontSize = maxFontSize;\n if (lineHeight) {\n fontMetrics.lineHeight = lineHeight;\n } else if (maxFontSize) {\n fontMetrics.lineHeight = (maxFontSize * 1.2);\n }\n return fontMetrics;\n }\n\n var emRegex = /em$/;\n\n function convertEmToPx(em, fontSize) {\n var numerical = parseFloat(em);\n if (emRegex.test(em)) return numerical * fontSize;\n return numerical;\n }\n\n function calculateDY(alignment, linesMetrics, baseSizePx, lineHeight) {\n if (!Array.isArray(linesMetrics)) return 0;\n var n = linesMetrics.length;\n if (!n) return 0;\n var lineMetrics = linesMetrics[0];\n var flMaxFont = convertEmToPx(lineMetrics.maxFontSize, baseSizePx) || baseSizePx;\n var rLineHeights = 0;\n var lineHeightPx = convertEmToPx(lineHeight, baseSizePx);\n for (var i = 1; i < n; i++) {\n lineMetrics = linesMetrics[i];\n var iLineHeight = convertEmToPx(lineMetrics.lineHeight, baseSizePx) || lineHeightPx;\n rLineHeights += iLineHeight;\n }\n var llMaxFont = convertEmToPx(lineMetrics.maxFontSize, baseSizePx) || baseSizePx;\n var dy;\n switch (alignment) {\n case 'middle':\n dy = (flMaxFont / 2) - (0.15 * llMaxFont) - (rLineHeights / 2);\n break;\n case 'bottom':\n dy = -(0.25 * llMaxFont) - rLineHeights;\n break;\n default:\n case 'top':\n dy = (0.8 * flMaxFont);\n break;\n }\n return dy;\n }\n\n VPrototype.text = function(content, opt) {\n\n if (content && typeof content !== 'string') throw new Error('Vectorizer: text() expects the first argument to be a string.');\n\n // Replace all spaces with the Unicode No-break space (http://www.fileformat.info/info/unicode/char/a0/index.htm).\n // IE would otherwise collapse all spaces into one.\n content = V.sanitizeText(content);\n opt || (opt = {});\n // Should we allow the text to be selected?\n var displayEmpty = opt.displayEmpty;\n // End of Line character\n var eol = opt.eol;\n // Text along path\n var textPath = opt.textPath;\n // Vertical shift\n var verticalAnchor = opt.textVerticalAnchor;\n var namedVerticalAnchor = (verticalAnchor === 'middle' || verticalAnchor === 'bottom' || verticalAnchor === 'top');\n // Horizontal shift applied to all the lines but the first.\n var x = opt.x;\n if (x === undefined) x = this.attr('x') || 0;\n // Annotations\n var iai = opt.includeAnnotationIndices;\n var annotations = opt.annotations;\n if (annotations && !V.isArray(annotations)) annotations = [annotations];\n // Shift all the but first by one line (`1em`)\n var defaultLineHeight = opt.lineHeight;\n var autoLineHeight = (defaultLineHeight === 'auto');\n var lineHeight = (autoLineHeight) ? '1.5em' : (defaultLineHeight || '1em');\n // Clearing the element\n this.empty();\n this.attr({\n // Preserve spaces. In other words, we do not want consecutive spaces to get collapsed to one.\n 'xml:space': 'preserve',\n // An empty text gets rendered into the DOM in webkit-based browsers.\n // In order to unify this behaviour across all browsers\n // we rather hide the text element when it's empty.\n 'display': (content || displayEmpty) ? null : 'none'\n });\n\n // Set default font-size if none\n var fontSize = parseFloat(this.attr('font-size'));\n if (!fontSize) {\n fontSize = 16;\n if (namedVerticalAnchor || annotations) this.attr('font-size', fontSize);\n }\n\n var doc = document;\n var containerNode;\n if (textPath) {\n // Now all the ``s will be inside the ``.\n if (typeof textPath === 'string') textPath = { d: textPath };\n containerNode = createTextPathNode(textPath, this);\n } else {\n containerNode = doc.createDocumentFragment();\n }\n var offset = 0;\n var lines = content.split('\\n');\n var linesMetrics = [];\n var annotatedY;\n for (var i = 0, lastI = lines.length - 1; i <= lastI; i++) {\n var dy = lineHeight;\n var lineClassName = 'v-line';\n var lineNode = doc.createElementNS(ns.svg, 'tspan');\n var line = lines[i];\n var lineMetrics;\n if (line) {\n if (annotations) {\n // Find the *compacted* annotations for this line.\n var lineAnnotations = V.annotateString(line, annotations, {\n offset: -offset,\n includeAnnotationIndices: iai\n });\n lineMetrics = annotateTextLine(lineNode, lineAnnotations, {\n includeAnnotationIndices: iai,\n eol: (i !== lastI && eol),\n lineHeight: (autoLineHeight) ? null : lineHeight,\n baseSize: fontSize\n });\n // Get the line height based on the biggest font size in the annotations for this line.\n var iLineHeight = lineMetrics.lineHeight;\n if (iLineHeight && autoLineHeight && i !== 0) dy = iLineHeight;\n if (i === 0) annotatedY = lineMetrics.maxFontSize * 0.8;\n } else {\n if (eol && i !== lastI) line += eol;\n lineNode.textContent = line;\n }\n } else {\n // Make sure the textContent is never empty. If it is, add a dummy\n // character and make it invisible, making the following lines correctly\n // relatively positioned. `dy=1em` won't work with empty lines otherwise.\n lineNode.textContent = '-';\n lineClassName += ' v-empty-line';\n // 'opacity' needs to be specified with fill, stroke. Opacity without specification\n // is not applied in Firefox\n var lineNodeStyle = lineNode.style;\n lineNodeStyle.fillOpacity = 0;\n lineNodeStyle.strokeOpacity = 0;\n if (annotations) {\n // Empty line with annotations.\n lineMetrics = {};\n lineAnnotations = V.findAnnotationsAtIndex(annotations, offset);\n let lineFontSize = fontSize;\n // Check if any of the annotations overrides the font size.\n for (let j = lineAnnotations.length; j > 0; j--) {\n const attrs = lineAnnotations[j - 1].attrs;\n if (!attrs || !('font-size' in attrs)) continue;\n const fs = parseFloat(attrs['font-size']);\n if (isFinite(fs)) {\n lineFontSize = fs;\n break;\n }\n }\n if (autoLineHeight) {\n if (i > 0) {\n dy = lineFontSize * 1.2;\n } else {\n annotatedY = lineFontSize * 0.8;\n }\n }\n // The font size is important for the native selection box height.\n lineNode.setAttribute('font-size', lineFontSize);\n lineMetrics.maxFontSize = lineFontSize;\n }\n }\n if (lineMetrics) linesMetrics.push(lineMetrics);\n if (i > 0) lineNode.setAttribute('dy', dy);\n // Firefox requires 'x' to be set on the first line when inside a text path\n if (i > 0 || textPath) lineNode.setAttribute('x', x);\n lineNode.className.baseVal = lineClassName;\n containerNode.appendChild(lineNode);\n offset += line.length + 1; // + 1 = newline character.\n }\n // Y Alignment calculation\n if (namedVerticalAnchor) {\n if (annotations) {\n dy = calculateDY(verticalAnchor, linesMetrics, fontSize, lineHeight);\n } else if (verticalAnchor === 'top') {\n // A shortcut for top alignment. It does not depend on font-size nor line-height\n dy = '0.8em';\n } else {\n var rh; // remaining height\n if (lastI > 0) {\n rh = parseFloat(lineHeight) || 1;\n rh *= lastI;\n if (!emRegex.test(lineHeight)) rh /= fontSize;\n } else {\n // Single-line text\n rh = 0;\n }\n switch (verticalAnchor) {\n case 'middle':\n dy = (0.3 - (rh / 2)) + 'em';\n break;\n case 'bottom':\n dy = (-rh - 0.3) + 'em';\n break;\n }\n }\n } else {\n if (verticalAnchor === 0) {\n dy = '0em';\n } else if (verticalAnchor) {\n dy = verticalAnchor;\n } else {\n // No vertical anchor is defined\n dy = 0;\n // Backwards compatibility - we change the `y` attribute instead of `dy`.\n if (this.attr('y') === null) this.attr('y', annotatedY || '0.8em');\n }\n }\n containerNode.firstChild.setAttribute('dy', dy);\n // Appending lines to the element.\n this.append(containerNode);\n return this;\n };\n\n /**\n * @public\n * @param {string} name\n * @returns {Vectorizer}\n */\n VPrototype.removeAttr = function(name) {\n\n const trueName = attributeNames[name];\n\n const { ns, local } = V.qualifyAttr(trueName);\n const el = this.node;\n\n if (ns) {\n if (el.hasAttributeNS(ns, local)) {\n el.removeAttributeNS(ns, local);\n }\n } else if (el.hasAttribute(trueName)) {\n el.removeAttribute(trueName);\n }\n return this;\n };\n\n VPrototype.attr = function(name, value) {\n\n if (V.isUndefined(name)) {\n\n // Return all attributes.\n var attributes = this.node.attributes;\n var attrs = {};\n\n for (var i = 0; i < attributes.length; i++) {\n attrs[attributes[i].name] = attributes[i].value;\n }\n\n return attrs;\n }\n\n if (V.isString(name) && V.isUndefined(value)) {\n return this.node.getAttribute(attributeNames[name]);\n }\n\n if (typeof name === 'object') {\n\n for (var attrName in name) {\n if (name.hasOwnProperty(attrName)) {\n this.setAttribute(attrName, name[attrName]);\n }\n }\n\n } else {\n\n this.setAttribute(name, value);\n }\n\n return this;\n };\n\n VPrototype.normalizePath = function() {\n\n var tagName = this.tagName();\n if (tagName === 'PATH') {\n this.attr('d', V.normalizePathData(this.attr('d')));\n }\n\n return this;\n };\n\n VPrototype.remove = function() {\n\n if (this.node.parentNode) {\n this.node.parentNode.removeChild(this.node);\n }\n\n return this;\n };\n\n VPrototype.empty = function() {\n\n while (this.node.firstChild) {\n this.node.removeChild(this.node.firstChild);\n }\n\n return this;\n };\n\n /**\n * @private\n * @param {object} attrs\n * @returns {Vectorizer}\n */\n VPrototype.setAttributes = function(attrs) {\n\n for (var key in attrs) {\n if (attrs.hasOwnProperty(key)) {\n this.setAttribute(key, attrs[key]);\n }\n }\n\n return this;\n };\n\n VPrototype.append = function(els) {\n\n if (!V.isArray(els)) {\n els = [els];\n }\n\n for (var i = 0, len = els.length; i < len; i++) {\n this.node.appendChild(V.toNode(els[i])); // lgtm [js/xss-through-dom]\n }\n\n return this;\n };\n\n VPrototype.prepend = function(els) {\n\n var child = this.node.firstChild;\n return child ? V(child).before(els) : this.append(els);\n };\n\n VPrototype.before = function(els) {\n\n var node = this.node;\n var parent = node.parentNode;\n\n if (parent) {\n\n if (!V.isArray(els)) {\n els = [els];\n }\n\n for (var i = 0, len = els.length; i < len; i++) {\n parent.insertBefore(V.toNode(els[i]), node);\n }\n }\n\n return this;\n };\n\n VPrototype.appendTo = function(node) {\n V.toNode(node).appendChild(this.node); // lgtm [js/xss-through-dom]\n return this;\n };\n\n VPrototype.svg = function() {\n\n return this.node instanceof window.SVGSVGElement ? this : V(this.node.ownerSVGElement);\n };\n\n VPrototype.tagName = function() {\n\n return this.node.tagName.toUpperCase();\n };\n\n VPrototype.defs = function() {\n var context = this.svg() || this;\n var defsNode = context.node.getElementsByTagName('defs')[0];\n if (defsNode) return V(defsNode);\n return V('defs').appendTo(context);\n };\n\n VPrototype.clone = function() {\n\n var clone = V(this.node.cloneNode(true/* deep */));\n // Note that clone inherits also ID. Therefore, we need to change it here.\n clone.node.id = V.uniqueId();\n return clone;\n };\n\n VPrototype.findOne = function(selector) {\n\n var found = this.node.querySelector(selector);\n return found ? V(found) : undefined;\n };\n\n VPrototype.find = function(selector) {\n\n var vels = [];\n var nodes = this.node.querySelectorAll(selector);\n\n if (nodes) {\n\n // Map DOM elements to `V`s.\n for (var i = 0; i < nodes.length; i++) {\n vels.push(V(nodes[i]));\n }\n }\n\n return vels;\n };\n\n // Returns an array of V elements made from children of this.node.\n VPrototype.children = function() {\n\n var children = this.node.childNodes;\n\n var outputArray = [];\n for (var i = 0; i < children.length; i++) {\n var currentChild = children[i];\n if (currentChild.nodeType === 1) {\n outputArray.push(V(children[i]));\n }\n }\n return outputArray;\n };\n\n // Returns the V element from parentNode of this.node.\n VPrototype.parent = function() {\n return V(this.node.parentNode) || null;\n },\n\n // Find an index of an element inside its container.\n VPrototype.index = function() {\n\n var index = 0;\n var node = this.node.previousSibling;\n\n while (node) {\n // nodeType 1 for ELEMENT_NODE\n if (node.nodeType === 1) index++;\n node = node.previousSibling;\n }\n\n return index;\n };\n\n VPrototype.findParentByClass = function(className, terminator) {\n\n var ownerSVGElement = this.node.ownerSVGElement;\n var node = this.node.parentNode;\n\n while (node && node !== terminator && node !== ownerSVGElement) {\n\n var vel = V(node);\n if (vel.hasClass(className)) {\n return vel;\n }\n\n node = node.parentNode;\n }\n\n return null;\n };\n\n // https://jsperf.com/get-common-parent\n VPrototype.contains = function(el) {\n\n var a = this.node;\n var b = V.toNode(el);\n var bup = b && b.parentNode;\n\n return (a === bup) || !!(bup && bup.nodeType === 1 && (a.compareDocumentPosition(bup) & 16));\n };\n\n // Convert global point into the coordinate space of this element.\n VPrototype.toLocalPoint = function(x, y) {\n\n var svg = this.svg().node;\n\n var p = svg.createSVGPoint();\n p.x = x;\n p.y = y;\n\n try {\n\n var globalPoint = p.matrixTransform(svg.getScreenCTM().inverse());\n var globalToLocalMatrix = this.getTransformToElement(svg).inverse();\n\n } catch (e) {\n // IE9 throws an exception in odd cases. (`Unexpected call to method or property access`)\n // We have to make do with the original coordianates.\n return p;\n }\n\n return globalPoint.matrixTransform(globalToLocalMatrix);\n };\n\n VPrototype.translateCenterToPoint = function(p) {\n\n var bbox = this.getBBox({ target: this.svg() });\n var center = bbox.center();\n\n this.translate(p.x - center.x, p.y - center.y);\n return this;\n };\n\n // Efficiently auto-orient an element. This basically implements the orient=auto attribute\n // of markers. The easiest way of understanding on what this does is to imagine the element is an\n // arrowhead. Calling this method on the arrowhead makes it point to the `position` point while\n // being auto-oriented (properly rotated) towards the `reference` point.\n // `target` is the element relative to which the transformations are applied. Usually a viewport.\n VPrototype.translateAndAutoOrient = function(position, reference, target) {\n\n position = new g.Point(position);\n reference = new g.Point(reference);\n target || (target = this.svg());\n\n // Clean-up previously set transformations except the scale. If we didn't clean up the\n // previous transformations then they'd add up with the old ones. Scale is an exception as\n // it doesn't add up, consider: `this.scale(2).scale(2).scale(2)`. The result is that the\n // element is scaled by the factor 2, not 8.\n var scale = this.scale();\n this.attr('transform', '');\n var bbox = this.getBBox({ target: target }).scale(scale.sx, scale.sy);\n\n // 1. Translate to origin.\n var translateToOrigin = V.createSVGTransform();\n translateToOrigin.setTranslate(-bbox.x - bbox.width / 2, -bbox.y - bbox.height / 2);\n\n // 2. Rotate around origin.\n var rotateAroundOrigin = V.createSVGTransform();\n var angle = position.angleBetween(reference, position.clone().offset(1, 0));\n if (angle) rotateAroundOrigin.setRotate(angle, 0, 0);\n\n // 3. Translate to the `position` + the offset (half my width) towards the `reference` point.\n var translateFromOrigin = V.createSVGTransform();\n var finalPosition = position.clone().move(reference, bbox.width / 2);\n translateFromOrigin.setTranslate(2 * position.x - finalPosition.x, 2 * position.y - finalPosition.y);\n\n // 4. Get the current transformation matrix of this node\n var ctm = this.getTransformToElement(target);\n\n // 5. Apply transformations and the scale\n var transform = V.createSVGTransform();\n transform.setMatrix(\n translateFromOrigin.matrix.multiply(\n rotateAroundOrigin.matrix.multiply(\n translateToOrigin.matrix.multiply(\n ctm.scale(scale.sx, scale.sy)))));\n\n this.attr('transform', V.matrixToTransformString(transform.matrix));\n\n return this;\n };\n\n VPrototype.animateAlongPath = function(attrs, path) {\n\n path = V.toNode(path);\n\n var id = V.ensureId(path);\n var animateMotion = V('animateMotion', attrs);\n var mpath = V('mpath', { 'xlink:href': '#' + id });\n\n animateMotion.append(mpath);\n\n this.append(animateMotion);\n try {\n animateMotion.node.beginElement();\n } catch (e) {\n // Fallback for IE 9.\n // Run the animation programmatically if FakeSmile (`http://leunen.me/fakesmile/`) present\n if (document.documentElement.getAttribute('smiling') === 'fake') {\n /* global getTargets:true, Animator:true, animators:true id2anim:true */\n // Register the animation. (See `https://answers.launchpad.net/smil/+question/203333`)\n var animation = animateMotion.node;\n animation.animators = [];\n\n var animationID = animation.getAttribute('id');\n if (animationID) id2anim[animationID] = animation;\n\n var targets = getTargets(animation);\n for (var i = 0, len = targets.length; i < len; i++) {\n var target = targets[i];\n var animator = new Animator(animation, target, i);\n animators.push(animator);\n animation.animators[i] = animator;\n animator.register();\n }\n }\n }\n return this;\n };\n\n\n // Split a string into an array of tokens.\n // https://infra.spec.whatwg.org/#ascii-whitespace\n const noHTMLWhitespaceRegex = /[^\\x20\\t\\r\\n\\f]+/g;\n function getTokenList(str) {\n if (!V.isString(str)) return [];\n return str.trim().match(noHTMLWhitespaceRegex) || [];\n }\n\n VPrototype.hasClass = function(className) {\n if (!V.isString(className)) return false;\n return this.node.classList.contains(className.trim());\n };\n\n VPrototype.addClass = function(className) {\n this.node.classList.add(...getTokenList(className));\n return this;\n };\n\n VPrototype.removeClass = function(className) {\n this.node.classList.remove(...getTokenList(className));\n return this;\n };\n\n VPrototype.toggleClass = function(className, toAdd) {\n const tokens = getTokenList(className);\n for (let i = 0; i < tokens.length; i++) {\n this.node.classList.toggle(tokens[i], toAdd);\n }\n return this;\n };\n\n // Interpolate path by discrete points. The precision of the sampling\n // is controlled by `interval`. In other words, `sample()` will generate\n // a point on the path starting at the beginning of the path going to the end\n // every `interval` pixels.\n // The sampler can be very useful for e.g. finding intersection between two\n // paths (finding the two closest points from two samples).\n VPrototype.sample = function(interval) {\n\n interval = interval || 1;\n var node = this.node;\n var length = node.getTotalLength();\n var samples = [];\n var distance = 0;\n var sample;\n while (distance < length) {\n sample = node.getPointAtLength(distance);\n samples.push({ x: sample.x, y: sample.y, distance: distance });\n distance += interval;\n }\n return samples;\n };\n\n VPrototype.convertToPath = function() {\n\n var path = V('path');\n path.attr(this.attr());\n var d = this.convertToPathData();\n if (d) {\n path.attr('d', d);\n }\n return path;\n };\n\n VPrototype.convertToPathData = function() {\n\n var tagName = this.tagName();\n\n switch (tagName) {\n case 'PATH':\n return this.attr('d');\n case 'LINE':\n return V.convertLineToPathData(this.node);\n case 'POLYGON':\n return V.convertPolygonToPathData(this.node);\n case 'POLYLINE':\n return V.convertPolylineToPathData(this.node);\n case 'ELLIPSE':\n return V.convertEllipseToPathData(this.node);\n case 'CIRCLE':\n return V.convertCircleToPathData(this.node);\n case 'RECT':\n return V.convertRectToPathData(this.node);\n }\n\n throw new Error(tagName + ' cannot be converted to PATH.');\n };\n\n V.prototype.toGeometryShape = function() {\n var x, y, width, height, cx, cy, r, rx, ry, points, d, x1, x2, y1, y2;\n switch (this.tagName()) {\n\n case 'RECT':\n x = parseFloat(this.attr('x')) || 0;\n y = parseFloat(this.attr('y')) || 0;\n width = parseFloat(this.attr('width')) || 0;\n height = parseFloat(this.attr('height')) || 0;\n return new g.Rect(x, y, width, height);\n\n case 'CIRCLE':\n cx = parseFloat(this.attr('cx')) || 0;\n cy = parseFloat(this.attr('cy')) || 0;\n r = parseFloat(this.attr('r')) || 0;\n return new g.Ellipse({ x: cx, y: cy }, r, r);\n\n case 'ELLIPSE':\n cx = parseFloat(this.attr('cx')) || 0;\n cy = parseFloat(this.attr('cy')) || 0;\n rx = parseFloat(this.attr('rx')) || 0;\n ry = parseFloat(this.attr('ry')) || 0;\n return new g.Ellipse({ x: cx, y: cy }, rx, ry);\n\n case 'POLYLINE':\n points = V.getPointsFromSvgNode(this);\n return new g.Polyline(points);\n\n case 'POLYGON':\n points = V.getPointsFromSvgNode(this);\n if (points.length > 1) points.push(points[0]);\n return new g.Polyline(points);\n\n case 'PATH':\n d = this.attr('d');\n if (!g.Path.isDataSupported(d)) d = V.normalizePathData(d);\n return new g.Path(d);\n\n case 'LINE':\n x1 = parseFloat(this.attr('x1')) || 0;\n y1 = parseFloat(this.attr('y1')) || 0;\n x2 = parseFloat(this.attr('x2')) || 0;\n y2 = parseFloat(this.attr('y2')) || 0;\n return new g.Line({ x: x1, y: y1 }, { x: x2, y: y2 });\n }\n\n // Anything else is a rectangle\n return this.getBBox();\n };\n\n // Find the intersection of a line starting in the center\n // of the SVG `node` ending in the point `ref`.\n // `target` is an SVG element to which `node`s transformations are relative to.\n // Note that `ref` point must be in the coordinate system of the `target` for this function to work properly.\n // Returns a point in the `target` coordinate system (the same system as `ref` is in) if\n // an intersection is found. Returns `undefined` otherwise.\n VPrototype.findIntersection = function(ref, target) {\n\n var svg = this.svg().node;\n target = target || svg;\n var bbox = this.getBBox({ target: target });\n var center = bbox.center();\n\n if (!bbox.intersectionWithLineFromCenterToPoint(ref)) return undefined;\n\n var spot;\n var tagName = this.tagName();\n\n // Little speed up optimization for `` element. We do not do conversion\n // to path element and sampling but directly calculate the intersection through\n // a transformed geometrical rectangle.\n if (tagName === 'RECT') {\n\n var gRect = new g.Rect(\n parseFloat(this.attr('x') || 0),\n parseFloat(this.attr('y') || 0),\n parseFloat(this.attr('width')),\n parseFloat(this.attr('height'))\n );\n // Get the rect transformation matrix with regards to the SVG document.\n var rectMatrix = this.getTransformToElement(target);\n // Decompose the matrix to find the rotation angle.\n var rectMatrixComponents = V.decomposeMatrix(rectMatrix);\n // Now we want to rotate the rectangle back so that we\n // can use `intersectionWithLineFromCenterToPoint()` passing the angle as the second argument.\n var resetRotation = svg.createSVGTransform();\n resetRotation.setRotate(-rectMatrixComponents.rotation, center.x, center.y);\n var rect = V.transformRect(gRect, resetRotation.matrix.multiply(rectMatrix));\n spot = (new g.Rect(rect)).intersectionWithLineFromCenterToPoint(ref, rectMatrixComponents.rotation);\n\n } else if (tagName === 'PATH' || tagName === 'POLYGON' || tagName === 'POLYLINE' || tagName === 'CIRCLE' || tagName === 'ELLIPSE') {\n\n var pathNode = (tagName === 'PATH') ? this : this.convertToPath();\n var samples = pathNode.sample();\n var minDistance = Infinity;\n var closestSamples = [];\n\n var i, sample, gp, centerDistance, refDistance, distance;\n\n for (i = 0; i < samples.length; i++) {\n\n sample = samples[i];\n // Convert the sample point in the local coordinate system to the global coordinate system.\n gp = V.createSVGPoint(sample.x, sample.y);\n gp = gp.matrixTransform(this.getTransformToElement(target));\n sample = new g.Point(gp);\n centerDistance = sample.distance(center);\n // Penalize a higher distance to the reference point by 10%.\n // This gives better results. This is due to\n // inaccuracies introduced by rounding errors and getPointAtLength() returns.\n refDistance = sample.distance(ref) * 1.1;\n distance = centerDistance + refDistance;\n\n if (distance < minDistance) {\n minDistance = distance;\n closestSamples = [{ sample: sample, refDistance: refDistance }];\n } else if (distance < minDistance + 1) {\n closestSamples.push({ sample: sample, refDistance: refDistance });\n }\n }\n\n closestSamples.sort(function(a, b) {\n return a.refDistance - b.refDistance;\n });\n\n if (closestSamples[0]) {\n spot = closestSamples[0].sample;\n }\n }\n\n return spot;\n };\n\n /**\n * @private\n * @param {string} name\n * @param {string} value\n * @returns {Vectorizer}\n */\n VPrototype.setAttribute = function(name, value) {\n\n const el = this.node;\n\n if (value === null) {\n this.removeAttr(name);\n return this;\n }\n\n const trueName = attributeNames[name];\n\n const { ns } = V.qualifyAttr(trueName);\n if (ns) {\n // Attribute names can be namespaced. E.g. `image` elements\n // have a `xlink:href` attribute to set the source of the image.\n el.setAttributeNS(ns, trueName, value);\n } else if (trueName === 'id') {\n el.id = value;\n } else {\n el.setAttribute(trueName, value);\n }\n\n return this;\n };\n\n // Create an SVG document element.\n // If `content` is passed, it will be used as the SVG content of the `` root element.\n V.createSvgDocument = function(content) {\n\n if (content) {\n const XMLString = `${content}`;\n const { documentElement } = V.parseXML(XMLString, { async: false });\n return documentElement;\n }\n\n const svg = document.createElementNS(ns.svg, 'svg');\n svg.setAttributeNS(ns.xmlns, 'xmlns:xlink', ns.xlink);\n svg.setAttribute('version', SVGVersion);\n return svg;\n };\n\n V.createSVGStyle = function(stylesheet) {\n const { node } = V('style', { type: 'text/css' }, [\n V.createCDATASection(stylesheet)\n ]);\n return node;\n },\n\n V.createCDATASection = function(data = '') {\n const xml = document.implementation.createDocument(null, 'xml', null);\n return xml.createCDATASection(data);\n };\n\n V.idCounter = 0;\n\n // A function returning a unique identifier for this client session with every call.\n V.uniqueId = function() {\n\n return 'v-' + (++V.idCounter);\n };\n\n V.toNode = function(el) {\n\n return V.isV(el) ? el.node : (el.nodeName && el || el[0]);\n };\n\n V.ensureId = function(node) {\n\n node = V.toNode(node);\n return node.id || (node.id = V.uniqueId());\n };\n\n // Replace all spaces with the Unicode No-break space (http://www.fileformat.info/info/unicode/char/a0/index.htm).\n // IE would otherwise collapse all spaces into one. This is used in the text() method but it is\n // also exposed so that the programmer can use it in case he needs to. This is useful e.g. in tests\n // when you want to compare the actual DOM text content without having to add the unicode character in\n // the place of all spaces.\n V.sanitizeText = function(text) {\n\n return (text || '').replace(/ /g, '\\u00A0');\n };\n\n V.isUndefined = function(value) {\n\n return typeof value === 'undefined';\n };\n\n V.isString = function(value) {\n\n return typeof value === 'string';\n };\n\n V.isObject = function(value) {\n\n return value && (typeof value === 'object');\n };\n\n V.isArray = Array.isArray;\n\n V.parseXML = function(data, opt) {\n\n opt = opt || {};\n\n var xml;\n\n try {\n var parser = new DOMParser();\n\n if (!V.isUndefined(opt.async)) {\n parser.async = opt.async;\n }\n\n xml = parser.parseFromString(data, 'text/xml');\n } catch (error) {\n xml = undefined;\n }\n\n if (!xml || xml.getElementsByTagName('parsererror').length) {\n throw new Error('Invalid XML: ' + data);\n }\n\n return xml;\n };\n\n // Create an empty object which does not inherit any properties from `Object.prototype`.\n // This is useful when we want to use an object as a dictionary without having to\n // worry about inherited properties such as `toString`, `valueOf` etc.\n const _attributeNames = Object.create(null);\n\n // List of attributes for which not to split camel case words.\n // It contains known SVG attribute names and may be extended with user-defined attribute names.\n [\n 'baseFrequency',\n 'baseProfile',\n 'clipPathUnits',\n 'contentScriptType',\n 'contentStyleType',\n 'diffuseConstant',\n 'edgeMode',\n 'externalResourcesRequired',\n 'filterRes', // deprecated\n 'filterUnits',\n 'gradientTransform',\n 'gradientUnits',\n 'kernelMatrix',\n 'kernelUnitLength',\n 'keyPoints',\n 'lengthAdjust',\n 'limitingConeAngle',\n 'markerHeight',\n 'markerUnits',\n 'markerWidth',\n 'maskContentUnits',\n 'maskUnits',\n 'numOctaves',\n 'pathLength',\n 'patternContentUnits',\n 'patternTransform',\n 'patternUnits',\n 'pointsAtX',\n 'pointsAtY',\n 'pointsAtZ',\n 'preserveAlpha',\n 'preserveAspectRatio',\n 'primitiveUnits',\n 'refX',\n 'refY',\n 'requiredExtensions',\n 'requiredFeatures',\n 'specularConstant',\n 'specularExponent',\n 'spreadMethod',\n 'startOffset',\n 'stdDeviation',\n 'stitchTiles',\n 'surfaceScale',\n 'systemLanguage',\n 'tableValues',\n 'targetX',\n 'targetY',\n 'textLength',\n 'viewBox',\n 'viewTarget', // deprecated\n 'xChannelSelector',\n 'yChannelSelector',\n 'zoomAndPan' // deprecated\n ].forEach((name) => _attributeNames[name] = name);\n\n _attributeNames['xlinkShow'] = 'xlink:show';\n _attributeNames['xlinkRole'] = 'xlink:role';\n _attributeNames['xlinkActuate'] = 'xlink:actuate';\n _attributeNames['xlinkHref'] = 'xlink:href';\n _attributeNames['xlinkType'] = 'xlink:type';\n _attributeNames['xlinkTitle'] = 'xlink:title';\n _attributeNames['xmlBase'] = 'xml:base';\n _attributeNames['xmlLang'] = 'xml:lang';\n _attributeNames['xmlSpace'] = 'xml:space';\n\n const attributeNames = new Proxy(_attributeNames, {\n get(cache, name) {\n // The cache is a dictionary of attribute names. See `_attributeNames` above.\n // If the attribute name is not in the cache, it means that it is not\n // a camel-case attribute name. In that case, we need to convert\n // the attribute name to dash-separated words.\n if (!V.supportCamelCaseAttributes) return name;\n if (name in cache) {\n return cache[name];\n }\n // Convert camel case to dash-separated words.\n return (cache[name] = name.replace(/[A-Z]/g, '-$&').toLowerCase());\n }\n });\n\n // Dictionary of attribute names\n Object.defineProperty(V, 'attributeNames', {\n enumerable: true,\n value: attributeNames,\n writable: false,\n });\n\n // Should camel case attributes be supported?\n Object.defineProperty(V, 'supportCamelCaseAttributes', {\n enumerable: true,\n value: true,\n writable: true,\n });\n\n /**\n * @param {string} name\n * @returns {{ns: string|null, local: string}} namespace and attribute name\n */\n V.qualifyAttr = function(name) {\n\n if (name.indexOf(':') !== -1) {\n var combinedKey = name.split(':');\n return {\n ns: ns[combinedKey[0]],\n local: combinedKey[1]\n };\n }\n\n return {\n ns: null,\n local: name\n };\n };\n\n // Note: This regex allows multiple commas as separator which is incorrect in SVG\n // This regex is used by `split()`, so it doesn't need to use /g\n V.transformSeparatorRegex = /[ ,]+/;\n // Note: All following regexes are more restrictive than SVG specification\n // ReDoS mitigation: Use an anchor at the beginning of the match\n // ReDoS mitigation: Avoid backtracking (uses `[^()]+` instead of `.*?`)\n // ReDoS mitigation: Don't match initial `(` inside repeated part\n // The following regex needs to use /g (= cannot use capturing groups)\n V.transformRegex = /\\b\\w+\\([^()]+\\)/g;\n // The following regexes need to use capturing groups (= cannot use /g)\n V.transformFunctionRegex = /\\b(\\w+)\\(([^()]+)\\)/;\n V.transformTranslateRegex = /\\btranslate\\(([^()]+)\\)/;\n V.transformRotateRegex = /\\brotate\\(([^()]+)\\)/;\n V.transformScaleRegex = /\\bscale\\(([^()]+)\\)/;\n\n V.transformStringToMatrix = function(transform) {\n\n // Initialize result matrix as identity matrix\n let transformationMatrix = V.createSVGMatrix();\n\n // Note: Multiple transform functions are allowed in `transform` string\n // `match()` returns `null` if none found\n const transformMatches = transform && transform.match(V.transformRegex);\n if (!transformMatches) {\n // Return identity matrix\n return transformationMatrix;\n }\n\n const numMatches = transformMatches.length;\n for (let i = 0; i < numMatches; i++) {\n\n const transformMatch = transformMatches[i];\n // Use same regex as above, but with capturing groups\n // `match()` returns values of capturing groups as `[1]`, `[2]`\n const transformFunctionMatch = transformMatch.match(V.transformFunctionRegex);\n if (transformFunctionMatch) {\n\n let sx, sy, tx, ty, angle;\n let ctm = V.createSVGMatrix();\n const transformFunction = transformFunctionMatch[1].toLowerCase();\n const args = transformFunctionMatch[2].split(V.transformSeparatorRegex);\n switch (transformFunction) {\n\n case 'scale':\n sx = parseFloat(args[0]);\n sy = (args[1] === undefined) ? sx : parseFloat(args[1]);\n ctm = ctm.scaleNonUniform(sx, sy);\n break;\n\n case 'translate':\n tx = parseFloat(args[0]);\n ty = parseFloat(args[1]);\n ctm = ctm.translate(tx, ty);\n break;\n\n case 'rotate':\n angle = parseFloat(args[0]);\n tx = parseFloat(args[1]) || 0;\n ty = parseFloat(args[2]) || 0;\n if (tx !== 0 || ty !== 0) {\n ctm = ctm.translate(tx, ty).rotate(angle).translate(-tx, -ty);\n } else {\n ctm = ctm.rotate(angle);\n }\n break;\n\n case 'skewx':\n angle = parseFloat(args[0]);\n ctm = ctm.skewX(angle);\n break;\n\n case 'skewy':\n angle = parseFloat(args[0]);\n ctm = ctm.skewY(angle);\n break;\n\n case 'matrix':\n ctm.a = parseFloat(args[0]);\n ctm.b = parseFloat(args[1]);\n ctm.c = parseFloat(args[2]);\n ctm.d = parseFloat(args[3]);\n ctm.e = parseFloat(args[4]);\n ctm.f = parseFloat(args[5]);\n break;\n\n default:\n continue;\n }\n\n // Multiply current transformation into result matrix\n transformationMatrix = transformationMatrix.multiply(ctm);\n }\n\n }\n return transformationMatrix;\n };\n\n V.matrixToTransformString = function(matrix) {\n matrix || (matrix = true);\n\n return 'matrix(' +\n (matrix.a !== undefined ? matrix.a : 1) + ',' +\n (matrix.b !== undefined ? matrix.b : 0) + ',' +\n (matrix.c !== undefined ? matrix.c : 0) + ',' +\n (matrix.d !== undefined ? matrix.d : 1) + ',' +\n (matrix.e !== undefined ? matrix.e : 0) + ',' +\n (matrix.f !== undefined ? matrix.f : 0) +\n ')';\n };\n\n V.parseTransformString = function(transform) {\n\n var translate, rotate, scale;\n\n if (transform) {\n\n var separator = V.transformSeparatorRegex;\n\n // Special handling for `transform` with one or more matrix functions\n if (transform.trim().indexOf('matrix') >= 0) {\n\n // Convert EVERYTHING in `transform` string to a matrix\n // Will combine ALL matrixes * ALL translates * ALL scales * ALL rotates\n // Note: In non-matrix case, we only take first one of each (if any)\n var matrix = V.transformStringToMatrix(transform);\n var decomposedMatrix = V.decomposeMatrix(matrix);\n\n // Extract `translate`, `scale`, `rotate` from matrix\n translate = [decomposedMatrix.translateX, decomposedMatrix.translateY];\n scale = [decomposedMatrix.scaleX, decomposedMatrix.scaleY];\n rotate = [decomposedMatrix.rotation];\n\n // Rewrite `transform` string in `translate scale rotate` format\n var transformations = [];\n if (translate[0] !== 0 || translate[1] !== 0) {\n transformations.push('translate(' + translate + ')');\n }\n if (scale[0] !== 1 || scale[1] !== 1) {\n transformations.push('scale(' + scale + ')');\n }\n if (rotate[0] !== 0) {\n transformations.push('rotate(' + rotate + ')');\n }\n transform = transformations.join(' ');\n\n } else {\n\n // Extract `translate`, `rotate`, `scale` functions from `transform` string\n // Note: We only detect the first match of each (if any)\n // `match()` returns value of capturing group as `[1]`\n const translateMatch = transform.match(V.transformTranslateRegex);\n if (translateMatch) {\n translate = translateMatch[1].split(separator);\n }\n const rotateMatch = transform.match(V.transformRotateRegex);\n if (rotateMatch) {\n rotate = rotateMatch[1].split(separator);\n }\n const scaleMatch = transform.match(V.transformScaleRegex);\n if (scaleMatch) {\n scale = scaleMatch[1].split(separator);\n }\n }\n }\n\n var sx = (scale && scale[0]) ? parseFloat(scale[0]) : 1;\n\n return {\n value: transform,\n translate: {\n tx: (translate && translate[0]) ? parseInt(translate[0], 10) : 0,\n ty: (translate && translate[1]) ? parseInt(translate[1], 10) : 0\n },\n rotate: {\n angle: (rotate && rotate[0]) ? parseInt(rotate[0], 10) : 0,\n cx: (rotate && rotate[1]) ? parseInt(rotate[1], 10) : undefined,\n cy: (rotate && rotate[2]) ? parseInt(rotate[2], 10) : undefined\n },\n scale: {\n sx: sx,\n sy: (scale && scale[1]) ? parseFloat(scale[1]) : sx\n }\n };\n };\n\n V.deltaTransformPoint = function(matrix, point) {\n\n var dx = point.x * matrix.a + point.y * matrix.c + 0;\n var dy = point.x * matrix.b + point.y * matrix.d + 0;\n return { x: dx, y: dy };\n };\n\n V.decomposeMatrix = function(matrix) {\n\n // @see https://gist.github.com/2052247\n\n // calculate delta transform point\n var px = V.deltaTransformPoint(matrix, { x: 0, y: 1 });\n var py = V.deltaTransformPoint(matrix, { x: 1, y: 0 });\n\n // calculate skew\n var skewX = ((180 / PI) * atan2(px.y, px.x) - 90);\n var skewY = ((180 / PI) * atan2(py.y, py.x));\n\n return {\n\n translateX: matrix.e,\n translateY: matrix.f,\n scaleX: sqrt(matrix.a * matrix.a + matrix.b * matrix.b),\n scaleY: sqrt(matrix.c * matrix.c + matrix.d * matrix.d),\n skewX: skewX,\n skewY: skewY,\n rotation: skewX // rotation is the same as skew x\n };\n };\n\n // Return the `scale` transformation from the following equation:\n // `translate(tx, ty) . rotate(angle) . scale(sx, sy) === matrix(a,b,c,d,e,f)`\n V.matrixToScale = function(matrix) {\n\n var a, b, c, d;\n if (matrix) {\n a = V.isUndefined(matrix.a) ? 1 : matrix.a;\n d = V.isUndefined(matrix.d) ? 1 : matrix.d;\n b = matrix.b;\n c = matrix.c;\n } else {\n a = d = 1;\n }\n return {\n sx: b ? sqrt(a * a + b * b) : a,\n sy: c ? sqrt(c * c + d * d) : d\n };\n };\n\n // Return the `rotate` transformation from the following equation:\n // `translate(tx, ty) . rotate(angle) . scale(sx, sy) === matrix(a,b,c,d,e,f)`\n V.matrixToRotate = function(matrix) {\n\n var p = { x: 0, y: 1 };\n if (matrix) {\n p = V.deltaTransformPoint(matrix, p);\n }\n\n return {\n angle: g.normalizeAngle(g.toDeg(atan2(p.y, p.x)) - 90)\n };\n };\n\n // Return the `translate` transformation from the following equation:\n // `translate(tx, ty) . rotate(angle) . scale(sx, sy) === matrix(a,b,c,d,e,f)`\n V.matrixToTranslate = function(matrix) {\n\n return {\n tx: (matrix && matrix.e) || 0,\n ty: (matrix && matrix.f) || 0\n };\n };\n\n V.isV = function(object) {\n\n return object instanceof V;\n };\n\n // For backwards compatibility:\n V.isVElement = V.isV;\n\n // Element implements `getBBox()`, `getCTM()` and `getScreenCTM()`\n // https://developer.mozilla.org/en-US/docs/Web/API/SVGGraphicsElement\n V.isSVGGraphicsElement = function(node) {\n if (!node) return false;\n node = V.toNode(node);\n // IE/Edge does not implement SVGGraphicsElement interface, thus check for `getScreenCTM` below\n return node instanceof SVGElement && typeof node.getScreenCTM === 'function';\n };\n\n var svgDocument = V('svg').node;\n\n V.createSVGMatrix = function(matrix) {\n\n var svgMatrix = svgDocument.createSVGMatrix();\n for (var component in matrix) {\n svgMatrix[component] = matrix[component];\n }\n\n return svgMatrix;\n };\n\n V.createSVGTransform = function(matrix) {\n\n if (!V.isUndefined(matrix)) {\n\n if (!(matrix instanceof SVGMatrix)) {\n matrix = V.createSVGMatrix(matrix);\n }\n\n return svgDocument.createSVGTransformFromMatrix(matrix);\n }\n\n return svgDocument.createSVGTransform();\n };\n\n V.createSVGPoint = function(x, y) {\n\n var p = svgDocument.createSVGPoint();\n p.x = x;\n p.y = y;\n return p;\n };\n\n V.transformRect = function(r, matrix) {\n\n var p = svgDocument.createSVGPoint();\n\n p.x = r.x;\n p.y = r.y;\n var corner1 = p.matrixTransform(matrix);\n\n p.x = r.x + r.width;\n p.y = r.y;\n var corner2 = p.matrixTransform(matrix);\n\n p.x = r.x + r.width;\n p.y = r.y + r.height;\n var corner3 = p.matrixTransform(matrix);\n\n p.x = r.x;\n p.y = r.y + r.height;\n var corner4 = p.matrixTransform(matrix);\n\n var minX = min(corner1.x, corner2.x, corner3.x, corner4.x);\n var maxX = max(corner1.x, corner2.x, corner3.x, corner4.x);\n var minY = min(corner1.y, corner2.y, corner3.y, corner4.y);\n var maxY = max(corner1.y, corner2.y, corner3.y, corner4.y);\n\n return new g.Rect(minX, minY, maxX - minX, maxY - minY);\n };\n\n V.transformPoint = function(p, matrix) {\n\n return new g.Point(V.createSVGPoint(p.x, p.y).matrixTransform(matrix));\n };\n\n V.transformLine = function(l, matrix) {\n\n return new g.Line(\n V.transformPoint(l.start, matrix),\n V.transformPoint(l.end, matrix)\n );\n };\n\n V.transformPolyline = function(p, matrix) {\n\n var inPoints = (p instanceof g.Polyline) ? p.points : p;\n if (!V.isArray(inPoints)) inPoints = [];\n var outPoints = [];\n for (var i = 0, n = inPoints.length; i < n; i++) outPoints[i] = V.transformPoint(inPoints[i], matrix);\n return new g.Polyline(outPoints);\n };\n\n // Convert a style represented as string (e.g. `'fill=\"blue\"; stroke=\"red\"'`) to\n // an object (`{ fill: 'blue', stroke: 'red' }`).\n V.styleToObject = function(styleString) {\n var ret = {};\n var styles = styleString.split(';');\n for (var i = 0; i < styles.length; i++) {\n var style = styles[i];\n var pair = style.split('=');\n ret[pair[0].trim()] = pair[1].trim();\n }\n return ret;\n };\n\n // Inspired by d3.js https://github.com/mbostock/d3/blob/master/src/svg/arc.js\n V.createSlicePathData = function(innerRadius, outerRadius, startAngle, endAngle) {\n\n var svgArcMax = 2 * PI - 1e-6;\n var r0 = innerRadius;\n var r1 = outerRadius;\n var a0 = startAngle;\n var a1 = endAngle;\n var da = (a1 < a0 && (da = a0, a0 = a1, a1 = da), a1 - a0);\n var df = da < PI ? '0' : '1';\n var c0 = cos(a0);\n var s0 = sin(a0);\n var c1 = cos(a1);\n var s1 = sin(a1);\n\n return (da >= svgArcMax)\n ? (r0\n ? 'M0,' + r1\n + 'A' + r1 + ',' + r1 + ' 0 1,1 0,' + (-r1)\n + 'A' + r1 + ',' + r1 + ' 0 1,1 0,' + r1\n + 'M0,' + r0\n + 'A' + r0 + ',' + r0 + ' 0 1,0 0,' + (-r0)\n + 'A' + r0 + ',' + r0 + ' 0 1,0 0,' + r0\n + 'Z'\n : 'M0,' + r1\n + 'A' + r1 + ',' + r1 + ' 0 1,1 0,' + (-r1)\n + 'A' + r1 + ',' + r1 + ' 0 1,1 0,' + r1\n + 'Z')\n : (r0\n ? 'M' + r1 * c0 + ',' + r1 * s0\n + 'A' + r1 + ',' + r1 + ' 0 ' + df + ',1 ' + r1 * c1 + ',' + r1 * s1\n + 'L' + r0 * c1 + ',' + r0 * s1\n + 'A' + r0 + ',' + r0 + ' 0 ' + df + ',0 ' + r0 * c0 + ',' + r0 * s0\n + 'Z'\n : 'M' + r1 * c0 + ',' + r1 * s0\n + 'A' + r1 + ',' + r1 + ' 0 ' + df + ',1 ' + r1 * c1 + ',' + r1 * s1\n + 'L0,0'\n + 'Z');\n };\n\n // Merge attributes from object `b` with attributes in object `a`.\n // Note that this modifies the object `a`.\n // Also important to note that attributes are merged but CSS classes are concatenated.\n V.mergeAttrs = function(a, b) {\n\n for (var attr in b) {\n\n if (attr === 'class') {\n // Concatenate classes.\n a[attr] = a[attr] ? a[attr] + ' ' + b[attr] : b[attr];\n } else if (attr === 'style') {\n // `style` attribute can be an object.\n if (V.isObject(a[attr]) && V.isObject(b[attr])) {\n // `style` stored in `a` is an object.\n a[attr] = V.mergeAttrs(a[attr], b[attr]);\n } else if (V.isObject(a[attr])) {\n // `style` in `a` is an object but it's a string in `b`.\n // Convert the style represented as a string to an object in `b`.\n a[attr] = V.mergeAttrs(a[attr], V.styleToObject(b[attr]));\n } else if (V.isObject(b[attr])) {\n // `style` in `a` is a string, in `b` it's an object.\n a[attr] = V.mergeAttrs(V.styleToObject(a[attr]), b[attr]);\n } else {\n // Both styles are strings.\n a[attr] = V.mergeAttrs(V.styleToObject(a[attr]), V.styleToObject(b[attr]));\n }\n } else {\n a[attr] = b[attr];\n }\n }\n\n return a;\n };\n\n V.annotateString = function(t, annotations, opt) {\n\n annotations = annotations || [];\n opt = opt || {};\n\n var offset = opt.offset || 0;\n var compacted = [];\n var batch;\n var ret = [];\n var item;\n var prev;\n\n for (var i = 0; i < t.length; i++) {\n\n item = ret[i] = t[i];\n\n for (var j = 0; j < annotations.length; j++) {\n\n var annotation = annotations[j];\n var start = annotation.start + offset;\n var end = annotation.end + offset;\n\n if (i >= start && i < end) {\n // Annotation applies.\n if (V.isObject(item)) {\n // There is more than one annotation to be applied => Merge attributes.\n item.attrs = V.mergeAttrs(V.mergeAttrs({}, item.attrs), annotation.attrs);\n } else {\n item = ret[i] = { t: t[i], attrs: annotation.attrs };\n }\n if (opt.includeAnnotationIndices) {\n (item.annotations || (item.annotations = [])).push(j);\n }\n }\n }\n\n prev = ret[i - 1];\n\n if (!prev) {\n\n batch = item;\n\n } else if (V.isObject(item) && V.isObject(prev)) {\n // Both previous item and the current one are annotations. If the attributes\n // didn't change, merge the text.\n if (JSON.stringify(item.attrs) === JSON.stringify(prev.attrs)) {\n batch.t += item.t;\n } else {\n compacted.push(batch);\n batch = item;\n }\n\n } else if (V.isObject(item)) {\n // Previous item was a string, current item is an annotation.\n compacted.push(batch);\n batch = item;\n\n } else if (V.isObject(prev)) {\n // Previous item was an annotation, current item is a string.\n compacted.push(batch);\n batch = item;\n\n } else {\n // Both previous and current item are strings.\n batch = (batch || '') + item;\n }\n }\n\n if (batch) {\n compacted.push(batch);\n }\n\n return compacted;\n };\n\n V.findAnnotationsAtIndex = function(annotations, index) {\n\n var found = [];\n\n if (annotations) {\n\n annotations.forEach(function(annotation) {\n\n if (annotation.start < index && index <= annotation.end) {\n found.push(annotation);\n }\n });\n }\n\n return found;\n };\n\n V.findAnnotationsBetweenIndexes = function(annotations, start, end) {\n\n var found = [];\n\n if (annotations) {\n\n annotations.forEach(function(annotation) {\n\n if ((start >= annotation.start && start < annotation.end) || (end > annotation.start && end <= annotation.end) || (annotation.start >= start && annotation.end < end)) {\n found.push(annotation);\n }\n });\n }\n\n return found;\n };\n\n // Shift all the text annotations after character `index` by `offset` positions.\n V.shiftAnnotations = function(annotations, index, offset) {\n\n if (annotations) {\n\n annotations.forEach(function(annotation) {\n\n if (annotation.start < index && annotation.end >= index) {\n annotation.end += offset;\n } else if (annotation.start >= index) {\n annotation.start += offset;\n annotation.end += offset;\n }\n });\n }\n\n return annotations;\n };\n\n V.convertLineToPathData = function(line) {\n\n line = V(line);\n var d = [\n 'M', line.attr('x1'), line.attr('y1'),\n 'L', line.attr('x2'), line.attr('y2')\n ].join(' ');\n return d;\n };\n\n V.convertPolygonToPathData = function(polygon) {\n\n var points = V.getPointsFromSvgNode(polygon);\n if (points.length === 0) return null;\n\n return V.svgPointsToPath(points) + ' Z';\n };\n\n V.convertPolylineToPathData = function(polyline) {\n\n var points = V.getPointsFromSvgNode(polyline);\n if (points.length === 0) return null;\n\n return V.svgPointsToPath(points);\n };\n\n V.svgPointsToPath = function(points) {\n\n for (var i = 0, n = points.length; i < n; i++) {\n points[i] = points[i].x + ' ' + points[i].y;\n }\n\n return 'M ' + points.join(' L');\n };\n\n V.getPointsFromSvgNode = function(node) {\n\n node = V.toNode(node);\n var points = [];\n var nodePoints = node.points;\n if (nodePoints) {\n for (var i = 0, n = nodePoints.numberOfItems; i < n; i++) {\n points.push(nodePoints.getItem(i));\n }\n }\n\n return points;\n };\n\n V.KAPPA = 0.551784;\n\n V.convertCircleToPathData = function(circle) {\n\n circle = V(circle);\n var cx = parseFloat(circle.attr('cx')) || 0;\n var cy = parseFloat(circle.attr('cy')) || 0;\n var r = parseFloat(circle.attr('r'));\n var cd = r * V.KAPPA; // Control distance.\n\n var d = [\n 'M', cx, cy - r, // Move to the first point.\n 'C', cx + cd, cy - r, cx + r, cy - cd, cx + r, cy, // I. Quadrant.\n 'C', cx + r, cy + cd, cx + cd, cy + r, cx, cy + r, // II. Quadrant.\n 'C', cx - cd, cy + r, cx - r, cy + cd, cx - r, cy, // III. Quadrant.\n 'C', cx - r, cy - cd, cx - cd, cy - r, cx, cy - r, // IV. Quadrant.\n 'Z'\n ].join(' ');\n return d;\n };\n\n V.convertEllipseToPathData = function(ellipse) {\n\n ellipse = V(ellipse);\n var cx = parseFloat(ellipse.attr('cx')) || 0;\n var cy = parseFloat(ellipse.attr('cy')) || 0;\n var rx = parseFloat(ellipse.attr('rx'));\n var ry = parseFloat(ellipse.attr('ry')) || rx;\n var cdx = rx * V.KAPPA; // Control distance x.\n var cdy = ry * V.KAPPA; // Control distance y.\n\n var d = [\n 'M', cx, cy - ry, // Move to the first point.\n 'C', cx + cdx, cy - ry, cx + rx, cy - cdy, cx + rx, cy, // I. Quadrant.\n 'C', cx + rx, cy + cdy, cx + cdx, cy + ry, cx, cy + ry, // II. Quadrant.\n 'C', cx - cdx, cy + ry, cx - rx, cy + cdy, cx - rx, cy, // III. Quadrant.\n 'C', cx - rx, cy - cdy, cx - cdx, cy - ry, cx, cy - ry, // IV. Quadrant.\n 'Z'\n ].join(' ');\n return d;\n };\n\n V.convertRectToPathData = function(rect) {\n\n rect = V(rect);\n\n return V.rectToPath({\n x: parseFloat(rect.attr('x')) || 0,\n y: parseFloat(rect.attr('y')) || 0,\n width: parseFloat(rect.attr('width')) || 0,\n height: parseFloat(rect.attr('height')) || 0,\n rx: parseFloat(rect.attr('rx')) || 0,\n ry: parseFloat(rect.attr('ry')) || 0\n });\n };\n\n // Convert a rectangle to SVG path commands. `r` is an object of the form:\n // `{ x: [number], y: [number], width: [number], height: [number], top-ry: [number], top-ry: [number], bottom-rx: [number], bottom-ry: [number] }`,\n // where `x, y, width, height` are the usual rectangle attributes and [top-/bottom-]rx/ry allows for\n // specifying radius of the rectangle for all its sides (as opposed to the built-in SVG rectangle\n // that has only `rx` and `ry` attributes).\n V.rectToPath = function(r) {\n\n var d;\n var x = r.x;\n var y = r.y;\n var width = r.width;\n var height = r.height;\n var topRx = min(r.rx || r['top-rx'] || 0, width / 2);\n var bottomRx = min(r.rx || r['bottom-rx'] || 0, width / 2);\n var topRy = min(r.ry || r['top-ry'] || 0, height / 2);\n var bottomRy = min(r.ry || r['bottom-ry'] || 0, height / 2);\n\n if (topRx || bottomRx || topRy || bottomRy) {\n d = [\n 'M', x, y + topRy,\n 'v', height - topRy - bottomRy,\n 'a', bottomRx, bottomRy, 0, 0, 0, bottomRx, bottomRy,\n 'h', width - 2 * bottomRx,\n 'a', bottomRx, bottomRy, 0, 0, 0, bottomRx, -bottomRy,\n 'v', -(height - bottomRy - topRy),\n 'a', topRx, topRy, 0, 0, 0, -topRx, -topRy,\n 'h', -(width - 2 * topRx),\n 'a', topRx, topRy, 0, 0, 0, -topRx, topRy,\n 'Z'\n ];\n } else {\n d = [\n 'M', x, y,\n 'H', x + width,\n 'V', y + height,\n 'H', x,\n 'V', y,\n 'Z'\n ];\n }\n\n return d.join(' ');\n };\n\n // Take a path data string\n // Return a normalized path data string\n // If data cannot be parsed, return 'M 0 0'\n // Highly inspired by Raphael Library (www.raphael.com)\n V.normalizePathData = (function() {\n\n var spaces = '\\x09\\x0a\\x0b\\x0c\\x0d\\x20\\xa0\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000\\u2028\\u2029';\n var pathCommand = new RegExp('([a-z])[' + spaces + ',]*((-?\\\\d*\\\\.?\\\\d*(?:e[\\\\-+]?\\\\d+)?[' + spaces + ']*,?[' + spaces + ']*)+)', 'ig');\n var pathValues = new RegExp('(-?\\\\d*\\\\.?\\\\d*(?:e[\\\\-+]?\\\\d+)?)[' + spaces + ']*,?[' + spaces + ']*', 'ig');\n\n var math = Math;\n var PI = math.PI;\n var sin = math.sin;\n var cos = math.cos;\n var tan = math.tan;\n var asin = math.asin;\n var sqrt = math.sqrt;\n var abs = math.abs;\n\n function q2c(x1, y1, ax, ay, x2, y2) {\n\n var _13 = 1 / 3;\n var _23 = 2 / 3;\n return [(_13 * x1) + (_23 * ax), (_13 * y1) + (_23 * ay), (_13 * x2) + (_23 * ax), (_13 * y2) + (_23 * ay), x2, y2];\n }\n\n function rotate(x, y, rad) {\n\n var X = (x * cos(rad)) - (y * sin(rad));\n var Y = (x * sin(rad)) + (y * cos(rad));\n return { x: X, y: Y };\n }\n\n function a2c(x1, y1, rx, ry, angle, large_arc_flag, sweep_flag, x2, y2, recursive) {\n // for more information of where this math came from visit:\n // http://www.w3.org/TR/SVG11/implnote.html#ArcImplementationNotes\n var _120 = (PI * 120) / 180;\n var rad = (PI / 180) * (+angle || 0);\n var res = [];\n var xy;\n\n if (!recursive) {\n xy = rotate(x1, y1, -rad);\n x1 = xy.x;\n y1 = xy.y;\n\n xy = rotate(x2, y2, -rad);\n x2 = xy.x;\n y2 = xy.y;\n\n var x = (x1 - x2) / 2;\n var y = (y1 - y2) / 2;\n var h = ((x * x) / (rx * rx)) + ((y * y) / (ry * ry));\n\n if (h > 1) {\n h = sqrt(h);\n rx = h * rx;\n ry = h * ry;\n }\n\n var rx2 = rx * rx;\n var ry2 = ry * ry;\n\n var k = ((large_arc_flag == sweep_flag) ? -1 : 1) * sqrt(abs(((rx2 * ry2) - (rx2 * y * y) - (ry2 * x * x)) / ((rx2 * y * y) + (ry2 * x * x))));\n if (!Number.isFinite(k)) {\n // Arc is a single point\n return [x1, y1, x2, y2, x2, y2];\n }\n\n var cx = ((k * rx * y) / ry) + ((x1 + x2) / 2);\n var cy = ((k * -ry * x) / rx) + ((y1 + y2) / 2);\n\n var f1 = asin(((y1 - cy) / ry).toFixed(9));\n var f2 = asin(((y2 - cy) / ry).toFixed(9));\n\n f1 = ((x1 < cx) ? (PI - f1) : f1);\n f2 = ((x2 < cx) ? (PI - f2) : f2);\n\n if (f1 < 0) f1 = (PI * 2) + f1;\n if (f2 < 0) f2 = (PI * 2) + f2;\n\n if (sweep_flag && (f1 > f2)) f1 = f1 - (PI * 2);\n if (!sweep_flag && (f2 > f1)) f2 = f2 - (PI * 2);\n\n } else {\n f1 = recursive[0];\n f2 = recursive[1];\n cx = recursive[2];\n cy = recursive[3];\n }\n\n var df = f2 - f1;\n if (abs(df) > _120) {\n var f2old = f2;\n var x2old = x2;\n var y2old = y2;\n f2 = f1 + (_120 * ((sweep_flag && (f2 > f1)) ? 1 : -1));\n x2 = cx + (rx * cos(f2));\n y2 = cy + (ry * sin(f2));\n res = a2c(x2, y2, rx, ry, angle, 0, sweep_flag, x2old, y2old, [f2, f2old, cx, cy]);\n }\n\n df = f2 - f1;\n\n var c1 = cos(f1);\n var s1 = sin(f1);\n var c2 = cos(f2);\n var s2 = sin(f2);\n var t = tan(df / 4);\n var hx = (4 / 3) * (rx * t);\n var hy = (4 / 3) * (ry * t);\n var m1 = [x1, y1];\n var m2 = [x1 + (hx * s1), y1 - (hy * c1)];\n var m3 = [x2 + (hx * s2), y2 - (hy * c2)];\n var m4 = [x2, y2];\n\n m2[0] = (2 * m1[0]) - m2[0];\n m2[1] = (2 * m1[1]) - m2[1];\n\n if (recursive) {\n return [m2, m3, m4].concat(res);\n } else {\n res = [m2, m3, m4].concat(res).join().split(',');\n var newres = [];\n var ii = res.length;\n for (var i = 0; i < ii; i++) {\n newres[i] = (i % 2) ? rotate(res[i - 1], res[i], rad).y : rotate(res[i], res[i + 1], rad).x;\n }\n return newres;\n }\n }\n\n function parsePathString(pathString) {\n\n if (!pathString) return null;\n\n var paramCounts = { a: 7, c: 6, h: 1, l: 2, m: 2, q: 4, s: 4, t: 2, v: 1, z: 0 };\n var data = [];\n\n String(pathString).replace(pathCommand, function(a, b, c) {\n\n var params = [];\n var name = b.toLowerCase();\n c.replace(pathValues, function(a, b) {\n if (b) params.push(+b);\n });\n\n if ((name === 'm') && (params.length > 2)) {\n data.push([b].concat(params.splice(0, 2)));\n name = 'l';\n b = ((b === 'm') ? 'l' : 'L');\n }\n\n while (params.length >= paramCounts[name]) {\n data.push([b].concat(params.splice(0, paramCounts[name])));\n if (!paramCounts[name]) break;\n }\n });\n\n return data;\n }\n\n function pathToAbsolute(pathArray) {\n\n if (!Array.isArray(pathArray) || !Array.isArray(pathArray && pathArray[0])) { // rough assumption\n pathArray = parsePathString(pathArray);\n }\n\n // if invalid string, return 'M 0 0'\n if (!pathArray || !pathArray.length) return [['M', 0, 0]];\n\n var res = [];\n var x = 0;\n var y = 0;\n var mx = 0;\n var my = 0;\n var start = 0;\n var pa0;\n\n var ii = pathArray.length;\n for (var i = start; i < ii; i++) {\n\n var r = [];\n res.push(r);\n\n var pa = pathArray[i];\n pa0 = pa[0];\n\n if (pa0 != pa0.toUpperCase()) {\n r[0] = pa0.toUpperCase();\n\n var jj;\n var j;\n switch (r[0]) {\n case 'A':\n r[1] = pa[1];\n r[2] = pa[2];\n r[3] = pa[3];\n r[4] = pa[4];\n r[5] = pa[5];\n r[6] = +pa[6] + x;\n r[7] = +pa[7] + y;\n break;\n\n case 'V':\n r[1] = +pa[1] + y;\n break;\n\n case 'H':\n r[1] = +pa[1] + x;\n break;\n\n case 'M':\n mx = +pa[1] + x;\n my = +pa[2] + y;\n\n jj = pa.length;\n for (j = 1; j < jj; j++) {\n r[j] = +pa[j] + ((j % 2) ? x : y);\n }\n break;\n\n default:\n jj = pa.length;\n for (j = 1; j < jj; j++) {\n r[j] = +pa[j] + ((j % 2) ? x : y);\n }\n break;\n }\n } else {\n var kk = pa.length;\n for (var k = 0; k < kk; k++) {\n r[k] = pa[k];\n }\n }\n\n switch (r[0]) {\n case 'Z':\n x = +mx;\n y = +my;\n break;\n\n case 'H':\n x = r[1];\n break;\n\n case 'V':\n y = r[1];\n break;\n\n case 'M':\n mx = r[r.length - 2];\n my = r[r.length - 1];\n x = r[r.length - 2];\n y = r[r.length - 1];\n break;\n\n default:\n x = r[r.length - 2];\n y = r[r.length - 1];\n break;\n }\n }\n\n return res;\n }\n\n function normalize(path) {\n\n var p = pathToAbsolute(path);\n var attrs = { x: 0, y: 0, bx: 0, by: 0, X: 0, Y: 0, qx: null, qy: null };\n\n function processPath(path, d, pcom) {\n\n var nx, ny;\n\n if (!path) return ['C', d.x, d.y, d.x, d.y, d.x, d.y];\n\n if (!(path[0] in { T: 1, Q: 1 })) {\n d.qx = null;\n d.qy = null;\n }\n\n switch (path[0]) {\n case 'M':\n d.X = path[1];\n d.Y = path[2];\n break;\n\n case 'A':\n if (parseFloat(path[1]) === 0 || parseFloat(path[2]) === 0) {\n // https://www.w3.org/TR/SVG/paths.html#ArcOutOfRangeParameters\n // \"If either rx or ry is 0, then this arc is treated as a\n // straight line segment (a \"lineto\") joining the endpoints.\"\n path = ['L', path[6], path[7]];\n } else {\n path = ['C'].concat(a2c.apply(0, [d.x, d.y].concat(path.slice(1))));\n }\n break;\n\n case 'S':\n if (pcom === 'C' || pcom === 'S') { // In 'S' case we have to take into account, if the previous command is C/S.\n nx = (d.x * 2) - d.bx; // And reflect the previous\n ny = (d.y * 2) - d.by; // command's control point relative to the current point.\n } else { // or some else or nothing\n nx = d.x;\n ny = d.y;\n }\n path = ['C', nx, ny].concat(path.slice(1));\n break;\n\n case 'T':\n if (pcom === 'Q' || pcom === 'T') { // In 'T' case we have to take into account, if the previous command is Q/T.\n d.qx = (d.x * 2) - d.qx; // And make a reflection similar\n d.qy = (d.y * 2) - d.qy; // to case 'S'.\n } else { // or something else or nothing\n d.qx = d.x;\n d.qy = d.y;\n }\n path = ['C'].concat(q2c(d.x, d.y, d.qx, d.qy, path[1], path[2]));\n break;\n\n case 'Q':\n d.qx = path[1];\n d.qy = path[2];\n path = ['C'].concat(q2c(d.x, d.y, path[1], path[2], path[3], path[4]));\n break;\n\n case 'H':\n path = ['L'].concat(path[1], d.y);\n break;\n\n case 'V':\n path = ['L'].concat(d.x, path[1]);\n break;\n\n case 'L':\n break;\n\n case 'Z':\n break;\n }\n\n return path;\n }\n\n function fixArc(pp, i) {\n\n if (pp[i].length > 7) {\n\n pp[i].shift();\n var pi = pp[i];\n\n while (pi.length) {\n pcoms[i] = 'A'; // if created multiple 'C's, their original seg is saved\n pp.splice(i++, 0, ['C'].concat(pi.splice(0, 6)));\n }\n\n pp.splice(i, 1);\n ii = p.length;\n }\n }\n\n var pcoms = []; // path commands of original path p\n var pfirst = ''; // temporary holder for original path command\n var pcom = ''; // holder for previous path command of original path\n\n var ii = p.length;\n for (var i = 0; i < ii; i++) {\n if (p[i]) pfirst = p[i][0]; // save current path command\n\n if (pfirst !== 'C') { // C is not saved yet, because it may be result of conversion\n pcoms[i] = pfirst; // Save current path command\n if (i > 0) pcom = pcoms[i - 1]; // Get previous path command pcom\n }\n\n p[i] = processPath(p[i], attrs, pcom); // Previous path command is inputted to processPath\n\n if (pcoms[i] !== 'A' && pfirst === 'C') pcoms[i] = 'C'; // 'A' is the only command\n // which may produce multiple 'C's\n // so we have to make sure that 'C' is also 'C' in original path\n\n fixArc(p, i); // fixArc adds also the right amount of 'A's to pcoms\n\n var seg = p[i];\n var seglen = seg.length;\n\n attrs.x = seg[seglen - 2];\n attrs.y = seg[seglen - 1];\n\n attrs.bx = parseFloat(seg[seglen - 4]) || attrs.x;\n attrs.by = parseFloat(seg[seglen - 3]) || attrs.y;\n }\n\n // make sure normalized path data string starts with an M segment\n if (!p[0][0] || p[0][0] !== 'M') {\n p.unshift(['M', 0, 0]);\n }\n\n return p;\n }\n\n return function(pathData) {\n return normalize(pathData).join(',').split(',').join(' ');\n };\n })();\n\n V.namespace = ns;\n\n V.g = g;\n\n return V;\n\n})();\n\nexport default V;\n","import { camelCase } from '../../util/utilHelpers.mjs';\nimport $ from './Dom.mjs';\nimport V from '../../V/index.mjs';\nimport { dataPriv, dataUser } from './vars.mjs';\n\n// Manipulation\n\nfunction cleanNodesData(nodes) {\n let i = nodes.length;\n while (i--) cleanNodeData(nodes[i]);\n}\n\nfunction cleanNodeData(node) {\n $.event.remove(node);\n dataPriv.remove(node);\n dataUser.remove(node);\n}\n\nfunction removeNodes(nodes) {\n for (let i = 0; i < nodes.length; i++) {\n const node = nodes[i];\n if (node.parentNode) {\n node.parentNode.removeChild(node);\n }\n }\n}\n\nexport function remove() {\n for (let i = 0; i < this.length; i++) {\n const node = this[i];\n cleanNodeData(node);\n cleanNodesData(node.getElementsByTagName('*'));\n }\n removeNodes(this);\n return this;\n}\n\nexport function detach() {\n removeNodes(this);\n return this;\n}\n\nexport function empty() {\n for (let i = 0; i < this.length; i++) {\n const node = this[i];\n if (node.nodeType === 1) {\n cleanNodesData(node.getElementsByTagName('*'));\n // Remove any remaining nodes\n node.textContent = '';\n }\n }\n return this;\n}\n\nexport function clone() {\n const clones = [];\n for (let i = 0; i < this.length; i++) {\n clones.push(this[i].cloneNode(true));\n }\n return this.pushStack(clones);\n}\n\nexport function html(html) {\n const [el] = this;\n if (!el) return null;\n if (arguments.length === 0) return el.innerHTML;\n if (html === undefined) return this; // do nothing\n cleanNodesData(dataPriv, el.getElementsByTagName('*'));\n if (typeof html === 'string' || typeof html === 'number') {\n el.innerHTML = html;\n } else {\n el.innerHTML = '';\n return this.append(html);\n }\n return this;\n}\n\nexport function append(...nodes) {\n const [parent] = this;\n if (!parent) return this;\n nodes.forEach((node) => {\n if (!node) return;\n if (typeof node === 'string') {\n parent.append(...$.parseHTML(node));\n } else if (node.toString() === '[object Object]') {\n // $ object\n this.append(...Array.from(node));\n } else if (Array.isArray(node)) {\n this.append(...node);\n } else {\n // DOM node\n parent.appendChild(node);\n }\n });\n return this;\n}\n\nexport function prepend(...nodes) {\n const [parent] = this;\n if (!parent) return this;\n nodes.forEach((node) => {\n if (!node) return;\n if (typeof node === 'string') {\n parent.prepend(...$.parseHTML(node));\n } else if (node.toString() === '[object Object]') {\n // $ object\n this.prepend(...Array.from(node));\n } else if (Array.isArray(node)) {\n this.prepend(...node);\n } else {\n // DOM node\n parent.insertBefore(node, parent.firstChild);\n }\n });\n return this;\n}\n\nexport function appendTo(parent) {\n $(parent).append(this);\n return this;\n}\n\nexport function prependTo(parent) {\n $(parent).prepend(this);\n return this;\n}\n\n// Styles and attributes\n\nconst requireUnits = {};\n[\n 'width', 'height', 'top', 'bottom', 'left', 'right',\n 'padding', 'paddingTop', 'paddingBottom', 'paddingLeft', 'paddingRight',\n 'margin', 'marginTop', 'marginBottom', 'marginLeft', 'marginRight',\n].forEach((cssProp) => {\n requireUnits[cssProp] = true;\n});\n\nfunction setCSSProperty(el, name, value) {\n if (typeof value === 'number' && requireUnits[camelCase(name)]) {\n value += 'px';\n }\n el.style[name] = value;\n}\n\nexport function css(name, value) {\n let styles;\n if (typeof name === 'string') {\n if (value === undefined) {\n const [el] = this;\n if (!el) return null;\n return el.style[name];\n } else {\n styles = { [name]: value };\n }\n } else if (!name) {\n throw new Error('no styles provided');\n } else {\n styles = name;\n }\n for (let style in styles) {\n if (styles.hasOwnProperty(style)) {\n for (let i = 0; i < this.length; i++) {\n setCSSProperty(this[i], style, styles[style]);\n }\n }\n }\n return this;\n}\n\nexport function data(name, value) {\n if (arguments.length < 2) {\n const [el] = this;\n if (!el) return null;\n if (name === undefined) {\n return el.dataset;\n }\n return el.dataset[name];\n }\n for (let i = 0; i < this.length; i++) {\n this[i].dataset[name] = value;\n }\n return this;\n}\n\n// Classes\n\nfunction setNodesClass(method, nodes, args) {\n for (let i = 0; i < nodes.length; i++) {\n const node = nodes[i];\n V.prototype[method].apply({ node }, args);\n }\n}\n\nexport function removeClass() {\n setNodesClass('removeClass', this, arguments);\n return this;\n}\n\nexport function addClass() {\n setNodesClass('addClass', this, arguments);\n return this;\n}\n\nexport function toggleClass() {\n setNodesClass('toggleClass', this, arguments);\n return this;\n}\n\nexport function hasClass() {\n const [node] = this;\n if (!node) return false;\n return V.prototype.hasClass.apply({ node }, arguments);\n}\n\n// Traversing\n\nexport function children(selector) {\n const matches = [];\n for(let i = 0; i < this.length; i++) {\n const node = this[i];\n let children = Array.from(node.children);\n if (typeof selector === 'string') {\n children = children.filter(child => child.matches(selector));\n }\n matches.push(...children);\n }\n return this.pushStack(matches);\n}\n\nexport function closest(selector) {\n const closest = [];\n for (let i = 0; i < this.length; i++) {\n const el = this[i];\n if (typeof selector === 'string') {\n const closestEl = el.closest(selector);\n if (closestEl) {\n closest.push(closestEl);\n }\n } else {\n const [ancestorEl] = $(selector);\n if (ancestorEl && ancestorEl.contains(el)) {\n closest.push(ancestorEl);\n }\n }\n }\n return this.pushStack(closest);\n}\n\n// Events\n\nexport function on(types, selector, data, fn) {\n $.event.on(this, types, selector, data, fn);\n return this;\n}\n\nexport function one(types, selector, data, fn) {\n $.event.on(this, types, selector, data, fn, 1);\n return this;\n}\n\nexport function off(types, selector, fn) {\n if (types && types.preventDefault && types.handleObj) {\n // ( event ) dispatched $.Event\n const handleObj = types.handleObj;\n $(types.delegateTarget).off(\n handleObj.namespace\n ? handleObj.origType + '.' + handleObj.namespace\n : handleObj.origType,\n handleObj.selector,\n handleObj.handler\n );\n return this;\n }\n if (typeof types === 'object') {\n // ( types-object [, selector] )\n for (let type in types) {\n this.off(type, selector, types[type]);\n }\n return this;\n }\n if (selector === false || typeof selector === 'function') {\n // ( types [, fn] )\n fn = selector;\n selector = undefined;\n }\n for (let i = 0; i < this.length; i++) {\n $.event.remove(this[i], types, fn, selector);\n }\n return this;\n}\n\n// Measurements\n\nexport function width() {\n const [el] = this;\n if (el === window) return el.document.documentElement.clientWidth;\n else if (!el) return undefined;\n const styles = window.getComputedStyle(el);\n const height = el.offsetWidth;\n const borderTopWidth = parseFloat(styles.borderTopWidth);\n const borderBottomWidth = parseFloat(styles.borderBottomWidth);\n const paddingTop = parseFloat(styles.paddingTop);\n const paddingBottom = parseFloat(styles.paddingBottom);\n return height - borderBottomWidth - borderTopWidth - paddingTop - paddingBottom;\n}\n\nexport function height() {\n const [el] = this;\n if (el === window) return el.document.documentElement.clientHeight;\n if (!el) return undefined;\n const styles = window.getComputedStyle(el);\n const width = el.offsetHeight;\n const borderLeftWidth = parseFloat(styles.borderLeftWidth);\n const borderRightWidth = parseFloat(styles.borderRightWidth);\n const paddingLeft = parseFloat(styles.paddingLeft);\n const paddingRight = parseFloat(styles.paddingRight);\n return width - borderLeftWidth - borderRightWidth - paddingLeft - paddingRight;\n}\n\nexport function position() {\n const [el] = this;\n if (!el) return;\n let $el = $(el);\n let offsetParent;\n let offset;\n let doc;\n let parentOffset = { top: 0, left: 0 };\n // position:fixed elements are offset from the viewport, which itself always has zero offset\n if ($el.css('position') === 'fixed') {\n // Assume position:fixed implies availability of getBoundingClientRect\n offset = el.getBoundingClientRect();\n } else {\n offset = $el.offset();\n // Account for the *real* offset parent, which can be the document or its root element\n // when a statically positioned element is identified\n doc = el.ownerDocument;\n offsetParent = el.offsetParent || doc.documentElement;\n const $parentOffset = $(offsetParent);\n const parentOffsetElementPosition = $parentOffset.css('position') || 'static';\n while ( offsetParent && (offsetParent === doc.body || offsetParent === doc.documentElement) && parentOffsetElementPosition === 'static') {\n offsetParent = offsetParent.parentNode;\n }\n if (offsetParent && offsetParent !== el && offsetParent.nodeType === 1) {\n // Incorporate borders into its offset, since they are outside its content origin\n const offsetParentStyles = window.getComputedStyle(offsetParent);\n const borderTopWidth = parseFloat(offsetParentStyles.borderTopWidth) || 0;\n const borderLeftWidth = parseFloat(offsetParentStyles.borderLeftWidth) || 0;\n parentOffset = $parentOffset.offset();\n parentOffset.top += borderTopWidth;\n parentOffset.left += borderLeftWidth;\n }\n }\n const marginTop = parseFloat(window.getComputedStyle(el).marginTop) || 0;\n const marginLeft = parseFloat(window.getComputedStyle(el).marginLeft) || 0;\n // Subtract parent offsets and element margins\n return {\n top: offset.top - parentOffset.top - marginTop,\n left: offset.left - parentOffset.left - marginLeft\n };\n}\n\nexport function offset(coordinates) {\n const [el] = this;\n // Getter\n if (coordinates === undefined) {\n if (!el) return null;\n if (!el.getClientRects().length) {\n return { top: 0, left: 0 };\n }\n const rect = el.getBoundingClientRect();\n return {\n top: rect.top + window.scrollY,\n left: rect.left + window.scrollX\n };\n }\n // Setter\n if (!el) return this;\n const currentStyle = window.getComputedStyle(el);\n if (currentStyle.position === 'static') {\n this.css('position', 'relative');\n }\n const currentOffset = this.offset();\n const topDifference = coordinates.top - currentOffset.top;\n const leftDifference = coordinates.left - currentOffset.left;\n this.css({\n top: (parseFloat(currentStyle.top) || 0) + topDifference + 'px',\n left: (parseFloat(currentStyle.left) || 0) + leftDifference + 'px'\n });\n return this;\n}\n\n","import $ from './Dom.mjs';\nimport { dataPriv } from './vars.mjs';\n\nconst animationKey = 'animationFrameId';\nconst cssReset = {};\n\ncssReset['transition-property'] =\ncssReset['transition-duration'] =\ncssReset['transition-delay'] =\ncssReset['transition-timing-function'] =\ncssReset['animation-name'] =\ncssReset['animation-duration'] =\ncssReset['animation-delay'] =\ncssReset['animation-timing-function'] = '';\n\nexport function animate(properties, opt = {}) {\n this.stop();\n for (let i = 0; i < this.length; i++) {\n animateNode(this[i], properties, opt);\n }\n return this;\n}\n\nfunction animateNode(el, properties, opt = {}) {\n\n let {\n duration = 400,\n easing = 'ease-in-out',\n delay = 0,\n complete\n } = opt;\n\n const delayId = setTimeout(function() {\n\n const $el = $(el);\n let fired = false;\n let endEvent = 'transitionend';\n\n // Convert milliseconds to seconds for CSS\n duration = duration / 1000;\n delay = delay / 1000;\n\n // Set up CSS values for transition or keyframe animation\n const cssValues = {};\n if (typeof properties === 'string') {\n // Keyframe animation\n cssValues['animation-name'] = properties;\n cssValues['animation-duration'] = duration + 's';\n cssValues['animation-delay'] = delay + 's';\n cssValues['animation-timing-function'] = easing;\n endEvent = 'animationend';\n } else {\n // CSS transitions\n const transitionProperties = [];\n for (var key in properties) {\n if (properties.hasOwnProperty(key)) {\n cssValues[key] = properties[key];\n transitionProperties.push(key);\n }\n }\n\n if (duration > 0) {\n cssValues['transition-property'] = transitionProperties.join(', ');\n cssValues['transition-duration'] = duration + 's';\n cssValues['transition-delay'] = delay + 's';\n cssValues['transition-timing-function'] = easing;\n }\n }\n\n const wrappedCallback = function(event){\n if (event) {\n if (event.target !== event.currentTarget) return; // makes sure the event didn't bubble from \"below\"\n event.target.removeEventListener(endEvent, wrappedCallback);\n } else {\n el.removeEventListener(endEvent, wrappedCallback); // triggered by setTimeout\n }\n fired = true;\n $el.css(cssReset);\n complete && complete.call(el);\n };\n\n if (duration > 0){\n el.addEventListener(endEvent, wrappedCallback);\n // transitionEnd is not always firing on older Android phones\n // so make sure it gets fired\n const callbackId = setTimeout(function() {\n if (fired) return;\n wrappedCallback(null);\n }, ((duration + delay) * 1000) + 25);\n\n dataPriv.set(el, animationKey, {\n id: callbackId,\n stop: () => {\n clearTimeout(callbackId);\n el.removeEventListener(endEvent, wrappedCallback);\n }\n });\n }\n\n $el.css(cssValues);\n\n if (duration <= 0) {\n wrappedCallback(null);\n }\n });\n\n dataPriv.set(el, animationKey, {\n stop: () => clearTimeout(delayId)\n });\n}\n\nexport function stop() {\n for (let i = 0; i < this.length; i++) {\n const el = this[i];\n const animation = dataPriv.get(el, animationKey);\n if (!animation) continue;\n animation.stop();\n dataPriv.remove(el, animationKey);\n }\n this.css(cssReset);\n return this;\n}\n","const propertySetters = {\n outerWidth: 'offsetWidth',\n outerHeight: 'offsetHeight',\n innerWidth: 'clientWidth',\n innerHeight: 'clientHeight',\n scrollLeft: 'scrollLeft',\n scrollTop: 'scrollTop',\n val: 'value',\n text: 'textContent',\n};\n\nconst propertiesMap = {\n disabled: 'disabled',\n value: 'value',\n text: 'textContent',\n};\n\nfunction prop(name, value) {\n if (!name) throw new Error('no property provided');\n if (arguments.length === 1) {\n const [el] = this;\n if (!el) return null;\n return el[name];\n }\n if (value === undefined) return this;\n for (let i = 0; i < this.length; i++) {\n this[i][name] = value;\n }\n return this;\n}\n\nfunction attr(name, value) {\n let attributes;\n if (typeof name === 'string') {\n if (value === undefined) {\n const [el] = this;\n if (!el) return null;\n return el.getAttribute(name);\n } else {\n attributes = { [name]: value };\n }\n } else if (!name) {\n throw new Error('no attributes provided');\n } else {\n attributes = name;\n }\n for (let attr in attributes) {\n if (attributes.hasOwnProperty(attr)) {\n const value = attributes[attr];\n if (propertiesMap[attr]) {\n this.prop(propertiesMap[attr], value);\n continue;\n }\n for (let i = 0; i < this.length; i++) {\n if (value === null) {\n this[i].removeAttribute(attr);\n } else {\n this[i].setAttribute(attr, value);\n }\n }\n }\n }\n return this;\n}\n\nconst methods = {\n prop,\n attr\n};\n\nObject.keys(propertySetters).forEach(methodName => {\n methods[methodName] = function(...args) {\n return this.prop(propertySetters[methodName], ...args);\n };\n});\n\nexport default methods;\n","export const config = {\n // When set to `true` the cell selectors could be defined as CSS selectors.\n // If not, only JSON Markup selectors are taken into account.\n useCSSSelectors: false,\n // The class name prefix config is for advanced use only.\n // Be aware that if you change the prefix, the JointJS CSS will no longer function properly.\n classNamePrefix: 'joint-',\n defaultTheme: 'default',\n // The maximum delay required for two consecutive touchend events to be interpreted\n // as a double-tap.\n doubleTapInterval: 300\n};\n","// TODO: should not read config outside the mvc package\nimport { config } from '../../config/index.mjs';\nimport $ from './Dom.mjs';\n\n\n// Special events\n\nconst special = Object.create(null);\n\nexport default special;\n\nspecial.load = {\n // Prevent triggered image.load events from bubbling to window.load\n noBubble: true,\n};\n\n// Create mouseenter/leave events using mouseover/out and event-time checks\n// so that event delegation works in $.\n// Do the same for pointerenter/pointerleave and pointerover/pointerout\n[\n ['mouseenter', 'mouseover'],\n ['mouseleave', 'mouseout'],\n ['pointerenter', 'pointerover'],\n ['pointerleave', 'pointerout'],\n].forEach(([orig, fix]) => {\n special[orig] = {\n delegateType: fix,\n bindType: fix,\n handle: function(event) {\n const target = this;\n const related = event.relatedTarget;\n const handleObj = event.handleObj;\n let ret;\n // For mouseenter/leave call the handler if related is outside the target.\n // NB: No relatedTarget if the mouse left/entered the browser window\n if (!related || !target.contains(related)) {\n event.type = handleObj.origType;\n ret = handleObj.handler.apply(target, arguments);\n event.type = fix;\n }\n return ret;\n },\n };\n});\n\n\n// Gestures\n\nconst maxDelay = config.doubleTapInterval;\nconst minDelay = 30;\n\nspecial.dbltap = {\n bindType: 'touchend',\n delegateType: 'touchend',\n handle: function(event, ...args) {\n const { handleObj, target } = event;\n const targetData = $.data.create(target);\n const now = new Date().getTime();\n const delta = 'lastTouch' in targetData ? now - targetData.lastTouch : 0;\n if (delta < maxDelay && delta > minDelay) {\n targetData.lastTouch = null;\n event.type = handleObj.origType;\n // let $ handle the triggering of \"dbltap\" event handlers\n handleObj.handler.call(this, event, ...args);\n } else {\n targetData.lastTouch = now;\n }\n }\n};\n","import { default as $ } from './Dom.mjs';\nimport * as methods from './methods.mjs';\nimport * as animations from './animations.mjs';\nimport { default as props } from './props.mjs';\nimport { default as special } from './events.mjs';\n\nObject.assign($.fn, methods);\nObject.assign($.fn, animations);\nObject.assign($.fn, props);\nObject.assign($.event.special, special);\n\nexport default $;\n\n","import $ from '../mvc/Dom/index.mjs';\nimport V from '../V/index.mjs';\nimport { config } from '../config/index.mjs';\nimport {\n isBoolean,\n isObject,\n isNumber,\n isString,\n mixin,\n deepMixin,\n supplement,\n defaults,\n defaultsDeep,\n deepSupplement,\n assign,\n invoke,\n invokeProperty,\n sortedIndex,\n uniq,\n clone,\n cloneDeep,\n isEmpty,\n isEqual,\n isFunction,\n isPlainObject,\n toArray,\n debounce,\n groupBy,\n sortBy,\n flattenDeep,\n without,\n difference,\n intersection,\n union,\n has,\n result,\n omit,\n pick,\n bindAll,\n forIn,\n camelCase,\n uniqueId,\n merge\n} from './utilHelpers.mjs';\n\nexport const addClassNamePrefix = function(className) {\n\n if (!className) return className;\n\n return className.toString().split(' ').map(function(_className) {\n\n if (_className.substr(0, config.classNamePrefix.length) !== config.classNamePrefix) {\n _className = config.classNamePrefix + _className;\n }\n\n return _className;\n\n }).join(' ');\n};\n\nexport const removeClassNamePrefix = function(className) {\n\n if (!className) return className;\n\n return className.toString().split(' ').map(function(_className) {\n\n if (_className.substr(0, config.classNamePrefix.length) === config.classNamePrefix) {\n _className = _className.substr(config.classNamePrefix.length);\n }\n\n return _className;\n\n }).join(' ');\n};\n\nexport const parseDOMJSON = function(json, namespace) {\n\n const selectors = {};\n const groupSelectors = {};\n const svgNamespace = V.namespace.svg;\n\n const ns = namespace || svgNamespace;\n const fragment = document.createDocumentFragment();\n\n const parseNode = function(siblingsDef, parentNode, ns) {\n for (let i = 0; i < siblingsDef.length; i++) {\n const nodeDef = siblingsDef[i];\n\n // Text node\n if (typeof nodeDef === 'string') {\n const textNode = document.createTextNode(nodeDef);\n parentNode.appendChild(textNode);\n continue;\n }\n\n // TagName\n if (!nodeDef.hasOwnProperty('tagName')) throw new Error('json-dom-parser: missing tagName');\n const tagName = nodeDef.tagName;\n\n let node;\n\n // Namespace URI\n if (nodeDef.hasOwnProperty('namespaceURI')) ns = nodeDef.namespaceURI;\n node = document.createElementNS(ns, tagName);\n const svg = (ns === svgNamespace);\n\n const wrapperNode = (svg) ? V(node) : $(node);\n // Attributes\n const attributes = nodeDef.attributes;\n if (attributes) wrapperNode.attr(attributes);\n // Style\n const style = nodeDef.style;\n if (style) $(node).css(style);\n // ClassName\n if (nodeDef.hasOwnProperty('className')) {\n const className = nodeDef.className;\n if (svg) {\n node.className.baseVal = className;\n } else {\n node.className = className;\n }\n }\n // TextContent\n if (nodeDef.hasOwnProperty('textContent')) {\n node.textContent = nodeDef.textContent;\n }\n // Selector\n if (nodeDef.hasOwnProperty('selector')) {\n const nodeSelector = nodeDef.selector;\n if (selectors[nodeSelector]) throw new Error('json-dom-parser: selector must be unique');\n selectors[nodeSelector] = node;\n wrapperNode.attr('joint-selector', nodeSelector);\n }\n // Groups\n if (nodeDef.hasOwnProperty('groupSelector')) {\n let nodeGroups = nodeDef.groupSelector;\n if (!Array.isArray(nodeGroups)) nodeGroups = [nodeGroups];\n for (let j = 0; j < nodeGroups.length; j++) {\n const nodeGroup = nodeGroups[j];\n let group = groupSelectors[nodeGroup];\n if (!group) group = groupSelectors[nodeGroup] = [];\n group.push(node);\n }\n }\n\n parentNode.appendChild(node);\n\n // Children\n const childrenDef = nodeDef.children;\n if (Array.isArray(childrenDef)) {\n parseNode(childrenDef, node, ns);\n }\n }\n };\n parseNode(json, fragment, ns);\n return {\n fragment: fragment,\n selectors: selectors,\n groupSelectors: groupSelectors\n };\n};\n\n// Return a simple hash code from a string. See http://werxltd.com/wp/2010/05/13/javascript-implementation-of-javas-string-hashcode-method/.\nexport const hashCode = function(str) {\n\n let hash = 0;\n if (str.length === 0) return hash;\n for (let i = 0; i < str.length; i++) {\n const c = str.charCodeAt(i);\n hash = ((hash << 5) - hash) + c;\n hash = hash & hash; // Convert to 32bit integer\n }\n return hash;\n};\n\nexport const getByPath = function(obj, path, delimiter) {\n\n var keys = Array.isArray(path) ? path : path.split(delimiter || '/');\n var key;\n var i = 0;\n var length = keys.length;\n while (i < length) {\n key = keys[i++];\n if (Object(obj) === obj && key in obj) {\n obj = obj[key];\n } else {\n return undefined;\n }\n }\n return obj;\n};\n\nconst isGetSafe = function(obj, key) {\n // Prevent prototype pollution\n // https://snyk.io/vuln/SNYK-JS-JSON8MERGEPATCH-1038399\n if (typeof key !== 'string' && typeof key !== 'number') {\n key = String(key);\n }\n if (key === 'constructor' && typeof obj[key] === 'function') {\n return false;\n }\n if (key === '__proto__') {\n return false;\n }\n return true;\n};\n\nexport const setByPath = function(obj, path, value, delimiter) {\n\n const keys = Array.isArray(path) ? path : path.split(delimiter || '/');\n const last = keys.length - 1;\n let diver = obj;\n let i = 0;\n\n for (; i < last; i++) {\n const key = keys[i];\n if (!isGetSafe(diver, key)) return obj;\n const value = diver[key];\n // diver creates an empty object if there is no nested object under such a key.\n // This means that one can populate an empty nested object with setByPath().\n diver = value || (diver[key] = {});\n }\n\n diver[keys[last]] = value;\n\n return obj;\n};\n\nexport const unsetByPath = function(obj, path, delimiter) {\n\n const keys = Array.isArray(path) ? path : path.split(delimiter || '/');\n const last = keys.length - 1;\n let diver = obj;\n let i = 0;\n\n for (; i < last; i++) {\n const key = keys[i];\n if (!isGetSafe(diver, key)) return obj;\n const value = diver[key];\n if (!value) return obj;\n diver = value;\n }\n\n delete diver[keys[last]];\n\n return obj;\n};\n\nexport const flattenObject = function(obj, delim, stop) {\n\n delim = delim || '/';\n var ret = {};\n\n for (var key in obj) {\n\n if (!obj.hasOwnProperty(key)) continue;\n\n var shouldGoDeeper = typeof obj[key] === 'object';\n if (shouldGoDeeper && stop && stop(obj[key])) {\n shouldGoDeeper = false;\n }\n\n if (shouldGoDeeper) {\n\n var flatObject = flattenObject(obj[key], delim, stop);\n\n for (var flatKey in flatObject) {\n if (!flatObject.hasOwnProperty(flatKey)) continue;\n ret[key + delim + flatKey] = flatObject[flatKey];\n }\n\n } else {\n\n ret[key] = obj[key];\n }\n }\n\n return ret;\n};\n\nexport const uuid = function() {\n\n // credit: http://stackoverflow.com/posts/2117523/revisions\n\n return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {\n var r = (Math.random() * 16) | 0;\n var v = (c === 'x') ? r : (r & 0x3 | 0x8);\n return v.toString(16);\n });\n};\n\n// Generates global unique id and stores it as a property of the object, if provided.\nexport const guid = function(obj) {\n\n guid.id = guid.id || 1;\n\n if (obj === undefined) {\n return 'j_' + guid.id++;\n }\n\n obj.id = (obj.id === undefined ? 'j_' + guid.id++ : obj.id);\n return obj.id;\n};\n\nexport const toKebabCase = function(string) {\n\n return string.replace(/[A-Z]/g, '-$&').toLowerCase();\n};\n\nexport const normalizeEvent = function(evt) {\n\n if (evt.normalized) return evt;\n\n const { originalEvent, target } = evt;\n\n // If the event is a touch event, normalize it to a mouse event.\n const touch = originalEvent && originalEvent.changedTouches && originalEvent.changedTouches[0];\n if (touch) {\n for (let property in touch) {\n // copy all the properties from the first touch that are not\n // defined on TouchEvent (clientX, clientY, pageX, pageY, screenX, screenY, identifier, ...)\n if (evt[property] === undefined) {\n evt[property] = touch[property];\n }\n }\n }\n // IE: evt.target could be set to SVGElementInstance for SVGUseElement\n if (target) {\n const useElement = target.correspondingUseElement;\n if (useElement) evt.target = useElement;\n }\n\n evt.normalized = true;\n\n return evt;\n};\n\nexport const normalizeWheel = function(evt) {\n // Sane values derived empirically\n const PIXEL_STEP = 10;\n const LINE_HEIGHT = 40;\n const PAGE_HEIGHT = 800;\n\n let sX = 0, sY = 0, pX = 0, pY = 0;\n\n // Legacy\n if ('detail' in evt) { sY = evt.detail; }\n if ('wheelDelta' in evt) { sY = -evt.wheelDelta / 120; }\n if ('wheelDeltaY' in evt) { sY = -evt.wheelDeltaY / 120; }\n if ('wheelDeltaX' in evt) { sX = -evt.wheelDeltaX / 120; }\n\n // side scrolling on FF with DOMMouseScroll\n if ( 'axis' in evt && evt.axis === evt.HORIZONTAL_AXIS ) {\n sX = sY;\n sY = 0;\n }\n\n pX = 'deltaX' in evt ? evt.deltaX : sX * PIXEL_STEP;\n pY = 'deltaY' in evt ? evt.deltaY : sY * PIXEL_STEP;\n\n if ((pX || pY) && evt.deltaMode) {\n if (evt.deltaMode == 1) {\n pX *= LINE_HEIGHT;\n pY *= LINE_HEIGHT;\n } else {\n pX *= PAGE_HEIGHT;\n pY *= PAGE_HEIGHT;\n }\n }\n\n // macOS switches deltaX and deltaY automatically when scrolling with shift key, so this is needed in other cases\n if (evt.deltaX === 0 && evt.deltaY !== 0 && evt.shiftKey) {\n pX = pY;\n pY = 0;\n sX = sY;\n sY = 0;\n }\n\n // Fall-back if spin cannot be determined\n if (pX && !sX) { sX = (pX < 1) ? -1 : 1; }\n if (pY && !sY) { sY = (pY < 1) ? -1 : 1; }\n\n return {\n spinX : sX,\n spinY : sY,\n deltaX : pX,\n deltaY : pY,\n };\n};\n\nexport const cap = function(val, max) {\n return val > max ? max : val < -max ? -max : val;\n};\n\nexport const nextFrame = (function() {\n\n var raf;\n\n if (typeof window !== 'undefined') {\n\n raf = window.requestAnimationFrame ||\n window.webkitRequestAnimationFrame ||\n window.mozRequestAnimationFrame ||\n window.oRequestAnimationFrame ||\n window.msRequestAnimationFrame;\n }\n\n if (!raf) {\n\n var lastTime = 0;\n\n raf = function(callback) {\n\n var currTime = new Date().getTime();\n var timeToCall = Math.max(0, 16 - (currTime - lastTime));\n var id = setTimeout(function() {\n callback(currTime + timeToCall);\n }, timeToCall);\n\n lastTime = currTime + timeToCall;\n\n return id;\n };\n }\n\n return function(callback, context, ...rest) {\n return (context !== undefined)\n ? raf(callback.bind(context, ...rest))\n : raf(callback);\n };\n\n})();\n\nexport const cancelFrame = (function() {\n\n var caf;\n var client = typeof window != 'undefined';\n\n if (client) {\n\n caf = window.cancelAnimationFrame ||\n window.webkitCancelAnimationFrame ||\n window.webkitCancelRequestAnimationFrame ||\n window.msCancelAnimationFrame ||\n window.msCancelRequestAnimationFrame ||\n window.oCancelAnimationFrame ||\n window.oCancelRequestAnimationFrame ||\n window.mozCancelAnimationFrame ||\n window.mozCancelRequestAnimationFrame;\n }\n\n caf = caf || clearTimeout;\n\n return client ? caf.bind(window) : caf;\n\n})();\n\nexport const isPercentage = function(val) {\n\n return isString(val) && val.slice(-1) === '%';\n};\n\nexport const parseCssNumeric = function(val, restrictUnits) {\n\n function getUnit(validUnitExp) {\n\n // one or more numbers, followed by\n // any number of (\n // `.`, followed by\n // one or more numbers\n // ), followed by\n // `validUnitExp`, followed by\n // end of string\n var matches = new RegExp('(?:\\\\d+(?:\\\\.\\\\d+)*)(' + validUnitExp + ')$').exec(val);\n\n if (!matches) return null;\n return matches[1];\n }\n\n var number = parseFloat(val);\n\n // if `val` cannot be parsed as a number, return `null`\n if (Number.isNaN(number)) return null;\n\n // else: we know `output.value`\n var output = {};\n output.value = number;\n\n // determine the unit\n var validUnitExp;\n if (restrictUnits == null) {\n // no restriction\n // accept any unit, as well as no unit\n validUnitExp = '[A-Za-z]*';\n\n } else if (Array.isArray(restrictUnits)) {\n // if this is an empty array, top restriction - return `null`\n if (restrictUnits.length === 0) return null;\n\n // else: restriction - an array of valid unit strings\n validUnitExp = restrictUnits.join('|');\n\n } else if (isString(restrictUnits)) {\n // restriction - a single valid unit string\n validUnitExp = restrictUnits;\n }\n var unit = getUnit(validUnitExp);\n\n // if we found no matches for `restrictUnits`, return `null`\n if (unit === null) return null;\n\n // else: we know the unit\n output.unit = unit;\n return output;\n};\n\nconst NO_SPACE = 0;\n\nfunction splitWordWithEOL(word, eol) {\n const eolWords = word.split(eol);\n let n = 1;\n for (let j = 0, jl = eolWords.length - 1; j < jl; j++) {\n const replacement = [];\n if (j > 0 || eolWords[0] !== '') replacement.push(NO_SPACE);\n replacement.push(eol);\n if (j < jl - 1 || eolWords[jl] !== '') replacement.push(NO_SPACE);\n eolWords.splice(n, 0, ...replacement);\n n += replacement.length + 1;\n }\n return eolWords.filter(word => word !== '');\n}\n\n\nfunction getLineHeight(heightValue, textElement) {\n if (heightValue === null) {\n // Default 1em lineHeight\n return textElement.getBBox().height;\n }\n\n switch (heightValue.unit) {\n case 'em':\n return textElement.getBBox().height * heightValue.value;\n case 'px':\n case '':\n return heightValue.value;\n }\n}\n\nexport const breakText = function(text, size, styles = {}, opt = {}) {\n\n var width = size.width;\n var height = size.height;\n\n var svgDocument = opt.svgDocument || V('svg').node;\n var textSpan = V('tspan').node;\n var textElement = V('text').attr(styles).append(textSpan).node;\n var textNode = document.createTextNode('');\n\n // Prevent flickering\n textElement.style.opacity = 0;\n // Prevent FF from throwing an uncaught exception when `getBBox()`\n // called on element that is not in the render tree (is not measurable).\n // .getComputedTextLength() returns always 0 in this case.\n // Note that the `textElement` resp. `textSpan` can become hidden\n // when it's appended to the DOM and a `display: none` CSS stylesheet\n // rule gets applied.\n textElement.style.display = 'block';\n textSpan.style.display = 'block';\n\n textSpan.appendChild(textNode);\n svgDocument.appendChild(textElement); // lgtm [js/xss-through-dom]\n\n if (!opt.svgDocument) {\n\n document.body.appendChild(svgDocument);\n }\n\n const preserveSpaces = opt.preserveSpaces;\n const space = ' ';\n const separator = (opt.separator || opt.separator === '') ? opt.separator : space;\n // If separator is a RegExp, we use the space character to join words together again (not ideal)\n const separatorChar = (typeof separator === 'string') ? separator : space;\n var eol = opt.eol || '\\n';\n var hyphen = opt.hyphen ? new RegExp(opt.hyphen) : /[^\\w\\d\\u00C0-\\u1FFF\\u2800-\\uFFFD]/;\n var maxLineCount = opt.maxLineCount;\n if (!isNumber(maxLineCount)) maxLineCount = Infinity;\n\n var words = text.split(separator);\n var full = [];\n var lines = [];\n var p, h;\n var lineHeight;\n\n if (preserveSpaces) {\n V(textSpan).attr('xml:space', 'preserve');\n }\n\n for (var i = 0, l = 0, len = words.length; i < len; i++) {\n\n var word = words[i];\n\n if (!word && !preserveSpaces) continue;\n if (typeof word !== 'string') continue;\n\n var isEol = false;\n if (eol && word.indexOf(eol) >= 0) {\n // word contains end-of-line character\n if (word.length > 1) {\n // separate word and continue cycle\n const eolWords = splitWordWithEOL(words[i], eol);\n words.splice(i, 1, ...eolWords);\n i--;\n len = words.length;\n continue;\n } else {\n // creates a new line\n if (preserveSpaces && typeof words[i - 1] === 'string' ) {\n words.splice(i, NO_SPACE, '', NO_SPACE);\n len += 2;\n i--;\n continue;\n }\n lines[++l] = (!preserveSpaces || typeof words[i + 1] === 'string') ? '' : undefined;\n isEol = true;\n }\n }\n\n if (!isEol) {\n\n let data;\n if (preserveSpaces) {\n data = lines[l] !== undefined ? lines[l] + separatorChar + word : word;\n } else {\n data = lines[l] ? lines[l] + separatorChar + word : word;\n }\n\n textNode.data = data;\n\n if (textSpan.getComputedTextLength() <= width) {\n\n // the current line fits\n lines[l] = data;\n\n if (p || h) {\n // We were partitioning. Put rest of the word onto next line\n full[l++] = true;\n\n // cancel partitioning and splitting by hyphens\n p = 0;\n h = 0;\n }\n\n } else {\n\n if (!lines[l] || p) {\n\n var partition = !!p;\n\n p = word.length - 1;\n\n if (partition || !p) {\n\n // word has only one character.\n if (!p) {\n\n if (!lines[l]) {\n\n // we won't fit this text within our rect\n lines = [];\n\n break;\n }\n\n // partitioning didn't help on the non-empty line\n // try again, but this time start with a new line\n\n // cancel partitions created\n words.splice(i, 2, word + words[i + 1]);\n\n // adjust word length\n len--;\n\n full[l++] = true;\n i--;\n\n continue;\n }\n\n // move last letter to the beginning of the next word\n words[i] = word.substring(0, p);\n const nextWord = words[i + 1];\n words[i + 1] = word.substring(p) + (nextWord === undefined || nextWord === NO_SPACE ? '' : nextWord);\n\n } else {\n\n if (h) {\n // cancel splitting and put the words together again\n words.splice(i, 2, words[i] + words[i + 1]);\n h = 0;\n } else {\n var hyphenIndex = word.search(hyphen);\n if (hyphenIndex > -1 && hyphenIndex !== word.length - 1 && hyphenIndex !== 0) {\n h = hyphenIndex + 1;\n p = 0;\n }\n\n // We initiate partitioning or splitting\n // split the long word into two words\n words.splice(i, 1, word.substring(0, h || p), word.substring(h|| p));\n // adjust words length\n len++;\n\n }\n\n if (l && !full[l - 1]) {\n // if the previous line is not full, try to fit max part of\n // the current word there\n l--;\n }\n }\n\n if (!preserveSpaces || lines[l] !== '') {\n i--;\n }\n\n continue;\n }\n\n l++;\n i--;\n }\n }\n var lastL = null;\n\n if (lines.length > maxLineCount) {\n\n lastL = maxLineCount - 1;\n\n } else if (height !== undefined) {\n\n // if size.height is defined we have to check whether the height of the entire\n // text exceeds the rect height\n\n if (lineHeight === undefined && textNode.data !== '') {\n\n // use the same defaults as in V.prototype.text\n if (styles.lineHeight === 'auto') {\n lineHeight = getLineHeight({ value: 1.5, unit: 'em' }, textElement);\n } else {\n const parsed = parseCssNumeric(styles.lineHeight, ['em', 'px', '']);\n\n lineHeight = getLineHeight(parsed, textElement);\n }\n }\n\n if (lineHeight * lines.length > height) {\n // remove overflowing lines\n lastL = Math.floor(height / lineHeight) - 1;\n }\n }\n\n if (lastL !== null) {\n\n lines.splice(lastL + 1);\n\n // add ellipsis\n var ellipsis = opt.ellipsis;\n if (!ellipsis || lastL < 0) break;\n if (typeof ellipsis !== 'string') ellipsis = '\\u2026';\n\n var lastLine = lines[lastL];\n if (!lastLine && !isEol) break;\n var k = lastLine.length;\n var lastLineWithOmission, lastChar;\n do {\n lastChar = lastLine[k];\n lastLineWithOmission = lastLine.substring(0, k);\n if (!lastChar) {\n lastLineWithOmission += separatorChar;\n } else if (lastChar.match(separator)) {\n lastLineWithOmission += lastChar;\n }\n lastLineWithOmission += ellipsis;\n textNode.data = lastLineWithOmission;\n if (textSpan.getComputedTextLength() <= width) {\n lines[lastL] = lastLineWithOmission;\n break;\n }\n k--;\n } while (k >= 0);\n break;\n }\n }\n\n if (opt.svgDocument) {\n\n // svg document was provided, remove the text element only\n svgDocument.removeChild(textElement);\n\n } else {\n\n // clean svg document\n document.body.removeChild(svgDocument);\n }\n\n return lines.join(eol);\n};\n\n// Sanitize HTML\n// Based on https://gist.github.com/ufologist/5a0da51b2b9ef1b861c30254172ac3c9\n// Parses a string into an array of DOM nodes.\n// Then outputs it back as a string.\nexport const sanitizeHTML = function(html) {\n\n // Ignores tags that are invalid inside a
tag (e.g. , )\n const [outputEl] = $.parseHTML('
' + html + '
');\n\n Array.from(outputEl.getElementsByTagName('*')).forEach(function(node) { // for all nodes\n const names = node.getAttributeNames();\n names.forEach(function(name) {\n const value = node.getAttribute(name);\n // Remove attribute names that start with \"on\" (e.g. onload, onerror...).\n // Remove attribute values that start with \"javascript:\" pseudo protocol (e.g. `href=\"javascript:alert(1)\"`).\n if (name.startsWith('on') || value.startsWith('javascript:' || value.startsWith('data:') || value.startsWith('vbscript:'))) {\n node.removeAttribute(name);\n }\n });\n });\n\n return outputEl.innerHTML;\n};\n\n// Download `blob` as file with `fileName`.\n// Does not work in IE9.\nexport const downloadBlob = function(blob, fileName) {\n\n if (window.navigator.msSaveBlob) { // requires IE 10+\n // pulls up a save dialog\n window.navigator.msSaveBlob(blob, fileName);\n\n } else { // other browsers\n // downloads directly in Chrome and Safari\n\n // presents a save/open dialog in Firefox\n // Firefox bug: `from` field in save dialog always shows `from:blob:`\n // https://bugzilla.mozilla.org/show_bug.cgi?id=1053327\n\n var url = window.URL.createObjectURL(blob);\n var link = document.createElement('a');\n\n link.href = url;\n link.download = fileName;\n document.body.appendChild(link);\n\n link.click();\n\n document.body.removeChild(link);\n window.URL.revokeObjectURL(url); // mark the url for garbage collection\n }\n};\n\n// Download `dataUri` as file with `fileName`.\n// Does not work in IE9.\nexport const downloadDataUri = function(dataUri, fileName) {\n\n const blob = dataUriToBlob(dataUri);\n downloadBlob(blob, fileName);\n};\n\n// Convert an uri-encoded data component (possibly also base64-encoded) to a blob.\nexport const dataUriToBlob = function(dataUri) {\n\n // first, make sure there are no newlines in the data uri\n dataUri = dataUri.replace(/\\s/g, '');\n dataUri = decodeURIComponent(dataUri);\n\n var firstCommaIndex = dataUri.indexOf(','); // split dataUri as `dataTypeString`,`data`\n\n var dataTypeString = dataUri.slice(0, firstCommaIndex); // e.g. 'data:image/jpeg;base64'\n var mimeString = dataTypeString.split(':')[1].split(';')[0]; // e.g. 'image/jpeg'\n\n var data = dataUri.slice(firstCommaIndex + 1);\n var decodedString;\n if (dataTypeString.indexOf('base64') >= 0) { // data may be encoded in base64\n decodedString = atob(data); // decode data\n } else {\n // convert the decoded string to UTF-8\n decodedString = unescape(encodeURIComponent(data));\n }\n // write the bytes of the string to a typed array\n var ia = new Uint8Array(decodedString.length);\n for (var i = 0; i < decodedString.length; i++) {\n ia[i] = decodedString.charCodeAt(i);\n }\n\n return new Blob([ia], { type: mimeString }); // return the typed array as Blob\n};\n\n// Read an image at `url` and return it as base64-encoded data uri.\n// The mime type of the image is inferred from the `url` file extension.\n// If data uri is provided as `url`, it is returned back unchanged.\n// `callback` is a method with `err` as first argument and `dataUri` as second argument.\n// Works with IE9.\nexport const imageToDataUri = function(url, callback) {\n\n if (!url || url.substr(0, 'data:'.length) === 'data:') {\n // No need to convert to data uri if it is already in data uri.\n\n // This not only convenient but desired. For example,\n // IE throws a security error if data:image/svg+xml is used to render\n // an image to the canvas and an attempt is made to read out data uri.\n // Now if our image is already in data uri, there is no need to render it to the canvas\n // and so we can bypass this error.\n\n // Keep the async nature of the function.\n return setTimeout(function() {\n callback(null, url);\n }, 0);\n }\n\n // chrome, IE10+\n var modernHandler = function(xhr, callback) {\n\n if (xhr.status === 200) {\n\n var reader = new FileReader();\n\n reader.onload = function(evt) {\n var dataUri = evt.target.result;\n callback(null, dataUri);\n };\n\n reader.onerror = function() {\n callback(new Error('Failed to load image ' + url));\n };\n\n reader.readAsDataURL(xhr.response);\n } else {\n callback(new Error('Failed to load image ' + url));\n }\n };\n\n var legacyHandler = function(xhr, callback) {\n\n var Uint8ToString = function(u8a) {\n var CHUNK_SZ = 0x8000;\n var c = [];\n for (var i = 0; i < u8a.length; i += CHUNK_SZ) {\n c.push(String.fromCharCode.apply(null, u8a.subarray(i, i + CHUNK_SZ)));\n }\n return c.join('');\n };\n\n if (xhr.status === 200) {\n\n var bytes = new Uint8Array(xhr.response);\n\n var suffix = (url.split('.').pop()) || 'png';\n var map = {\n 'svg': 'svg+xml'\n };\n var meta = 'data:image/' + (map[suffix] || suffix) + ';base64,';\n var b64encoded = meta + btoa(Uint8ToString(bytes));\n callback(null, b64encoded);\n } else {\n callback(new Error('Failed to load image ' + url));\n }\n };\n\n var xhr = new XMLHttpRequest();\n\n xhr.open('GET', url, true);\n xhr.addEventListener('error', function() {\n callback(new Error('Failed to load image ' + url));\n });\n\n xhr.responseType = window.FileReader ? 'blob' : 'arraybuffer';\n\n xhr.addEventListener('load', function() {\n if (window.FileReader) {\n modernHandler(xhr, callback);\n } else {\n legacyHandler(xhr, callback);\n }\n });\n\n xhr.send();\n};\n\nexport const getElementBBox = function(el) {\n\n var $el = $(el);\n if ($el.length === 0) {\n throw new Error('Element not found');\n }\n\n var element = $el[0];\n var doc = element.ownerDocument;\n var clientBBox = element.getBoundingClientRect();\n\n var strokeWidthX = 0;\n var strokeWidthY = 0;\n\n // Firefox correction\n if (element.ownerSVGElement) {\n\n var vel = V(element);\n var bbox = vel.getBBox({ target: vel.svg() });\n\n // if FF getBoundingClientRect includes stroke-width, getBBox doesn't.\n // To unify this across all browsers we need to adjust the final bBox with `stroke-width` value.\n strokeWidthX = (clientBBox.width - bbox.width);\n strokeWidthY = (clientBBox.height - bbox.height);\n }\n\n return {\n x: clientBBox.left + window.pageXOffset - doc.documentElement.offsetLeft + strokeWidthX / 2,\n y: clientBBox.top + window.pageYOffset - doc.documentElement.offsetTop + strokeWidthY / 2,\n width: clientBBox.width - strokeWidthX,\n height: clientBBox.height - strokeWidthY\n };\n};\n\n\n// Highly inspired by the jquery.sortElements plugin by Padolsey.\n// See http://james.padolsey.com/javascript/sorting-elements-with-jquery/.\nexport const sortElements = function(elements, comparator) {\n\n elements = $(elements).toArray();\n var placements = elements.map(function(sortElement) {\n\n var parentNode = sortElement.parentNode;\n // Since the element itself will change position, we have\n // to have some way of storing it's original position in\n // the DOM. The easiest way is to have a 'flag' node:\n var nextSibling = parentNode.insertBefore(document.createTextNode(''), sortElement.nextSibling);\n\n return function() {\n\n if (parentNode === this) {\n throw new Error('You can\\'t sort elements if any one is a descendant of another.');\n }\n\n // Insert before flag:\n parentNode.insertBefore(this, nextSibling);\n // Remove flag:\n parentNode.removeChild(nextSibling);\n };\n });\n\n elements.sort(comparator);\n for (var i = 0; i < placements.length; i++) {\n placements[i].call(elements[i]);\n }\n return elements;\n};\n\n// Sets attributes on the given element and its descendants based on the selector.\n// `attrs` object: { [SELECTOR1]: { attrs1 }, [SELECTOR2]: { attrs2}, ... } e.g. { 'input': { color : 'red' }}\nexport const setAttributesBySelector = function(element, attrs) {\n\n var $element = $(element);\n\n forIn(attrs, function(attrs, selector) {\n var $elements = $element.find(selector).addBack().filter(selector);\n // Make a special case for setting classes.\n // We do not want to overwrite any existing class.\n if (has(attrs, 'class')) {\n $elements.addClass(attrs['class']);\n attrs = omit(attrs, 'class');\n }\n $elements.attr(attrs);\n });\n};\n\n// Return a new object with all four sides (top, right, bottom, left) in it.\n// Value of each side is taken from the given argument (either number or object).\n// Default value for a side is 0.\n// Examples:\n// normalizeSides(5) --> { top: 5, right: 5, bottom: 5, left: 5 }\n// normalizeSides({ horizontal: 5 }) --> { top: 0, right: 5, bottom: 0, left: 5 }\n// normalizeSides({ left: 5 }) --> { top: 0, right: 0, bottom: 0, left: 5 }\n// normalizeSides({ horizontal: 10, left: 5 }) --> { top: 0, right: 10, bottom: 0, left: 5 }\n// normalizeSides({ horizontal: 0, left: 5 }) --> { top: 0, right: 0, bottom: 0, left: 5 }\nexport const normalizeSides = function(box) {\n\n if (Object(box) !== box) { // `box` is not an object\n var val = 0; // `val` left as 0 if `box` cannot be understood as finite number\n if (isFinite(box)) val = +box; // actually also accepts string numbers (e.g. '100')\n\n return { top: val, right: val, bottom: val, left: val };\n }\n\n // `box` is an object\n var top, right, bottom, left;\n top = right = bottom = left = 0;\n\n if (isFinite(box.vertical)) top = bottom = +box.vertical;\n if (isFinite(box.horizontal)) right = left = +box.horizontal;\n\n if (isFinite(box.top)) top = +box.top; // overwrite vertical\n if (isFinite(box.right)) right = +box.right; // overwrite horizontal\n if (isFinite(box.bottom)) bottom = +box.bottom; // overwrite vertical\n if (isFinite(box.left)) left = +box.left; // overwrite horizontal\n\n return { top: top, right: right, bottom: bottom, left: left };\n};\n\nexport const timing = {\n\n linear: function(t) {\n return t;\n },\n\n quad: function(t) {\n return t * t;\n },\n\n cubic: function(t) {\n return t * t * t;\n },\n\n inout: function(t) {\n if (t <= 0) return 0;\n if (t >= 1) return 1;\n var t2 = t * t;\n var t3 = t2 * t;\n return 4 * (t < .5 ? t3 : 3 * (t - t2) + t3 - .75);\n },\n\n exponential: function(t) {\n return Math.pow(2, 10 * (t - 1));\n },\n\n bounce: function(t) {\n for (var a = 0, b = 1; 1; a += b, b /= 2) {\n if (t >= (7 - 4 * a) / 11) {\n var q = (11 - 6 * a - 11 * t) / 4;\n return -q * q + b * b;\n }\n }\n },\n\n reverse: function(f) {\n return function(t) {\n return 1 - f(1 - t);\n };\n },\n\n reflect: function(f) {\n return function(t) {\n return .5 * (t < .5 ? f(2 * t) : (2 - f(2 - 2 * t)));\n };\n },\n\n clamp: function(f, n, x) {\n n = n || 0;\n x = x || 1;\n return function(t) {\n var r = f(t);\n return r < n ? n : r > x ? x : r;\n };\n },\n\n back: function(s) {\n if (!s) s = 1.70158;\n return function(t) {\n return t * t * ((s + 1) * t - s);\n };\n },\n\n elastic: function(x) {\n if (!x) x = 1.5;\n return function(t) {\n return Math.pow(2, 10 * (t - 1)) * Math.cos(20 * Math.PI * x / 3 * t);\n };\n }\n};\n\nexport const interpolate = {\n\n number: function(a, b) {\n var d = b - a;\n return function(t) {\n return a + d * t;\n };\n },\n\n object: function(a, b) {\n var s = Object.keys(a);\n return function(t) {\n var i, p;\n var r = {};\n for (i = s.length - 1; i != -1; i--) {\n p = s[i];\n r[p] = a[p] + (b[p] - a[p]) * t;\n }\n return r;\n };\n },\n\n hexColor: function(a, b) {\n\n var ca = parseInt(a.slice(1), 16);\n var cb = parseInt(b.slice(1), 16);\n var ra = ca & 0x0000ff;\n var rd = (cb & 0x0000ff) - ra;\n var ga = ca & 0x00ff00;\n var gd = (cb & 0x00ff00) - ga;\n var ba = ca & 0xff0000;\n var bd = (cb & 0xff0000) - ba;\n\n return function(t) {\n\n var r = (ra + rd * t) & 0x000000ff;\n var g = (ga + gd * t) & 0x0000ff00;\n var b = (ba + bd * t) & 0x00ff0000;\n\n return '#' + (1 << 24 | r | g | b).toString(16).slice(1);\n };\n },\n\n unit: function(a, b) {\n\n var r = /(-?[0-9]*.[0-9]*)(px|em|cm|mm|in|pt|pc|%)/;\n var ma = r.exec(a);\n var mb = r.exec(b);\n var p = mb[1].indexOf('.');\n var f = p > 0 ? mb[1].length - p - 1 : 0;\n a = +ma[1];\n var d = +mb[1] - a;\n var u = ma[2];\n\n return function(t) {\n return (a + d * t).toFixed(f) + u;\n };\n }\n};\n\n// SVG filters.\n// (values in parentheses are default values)\nexport const filter = {\n\n // `color` ... outline color ('blue')\n // `width`... outline width (1)\n // `opacity` ... outline opacity (1)\n // `margin` ... gap between outline and the element (2)\n outline: function(args) {\n\n var tpl = '';\n\n var margin = Number.isFinite(args.margin) ? args.margin : 2;\n var width = Number.isFinite(args.width) ? args.width : 1;\n\n return template(tpl)({\n color: args.color || 'blue',\n opacity: Number.isFinite(args.opacity) ? args.opacity : 1,\n outerRadius: margin + width,\n innerRadius: margin\n });\n },\n\n // `color` ... color ('red')\n // `width`... width (1)\n // `blur` ... blur (0)\n // `opacity` ... opacity (1)\n highlight: function(args) {\n\n var tpl = '';\n\n return template(tpl)({\n color: args.color || 'red',\n width: Number.isFinite(args.width) ? args.width : 1,\n blur: Number.isFinite(args.blur) ? args.blur : 0,\n opacity: Number.isFinite(args.opacity) ? args.opacity : 1\n });\n },\n\n // `x` ... horizontal blur (2)\n // `y` ... vertical blur (optional)\n blur: function(args) {\n\n var x = Number.isFinite(args.x) ? args.x : 2;\n\n return template('')({\n stdDeviation: Number.isFinite(args.y) ? [x, args.y] : x\n });\n },\n\n // `dx` ... horizontal shift (0)\n // `dy` ... vertical shift (0)\n // `blur` ... blur (4)\n // `color` ... color ('black')\n // `opacity` ... opacity (1)\n dropShadow: function(args) {\n\n var tpl = 'SVGFEDropShadowElement' in window\n ? ''\n : '';\n\n return template(tpl)({\n dx: args.dx || 0,\n dy: args.dy || 0,\n opacity: Number.isFinite(args.opacity) ? args.opacity : 1,\n color: args.color || 'black',\n blur: Number.isFinite(args.blur) ? args.blur : 4\n });\n },\n\n // `amount` ... the proportion of the conversion (1). A value of 1 (default) is completely grayscale. A value of 0 leaves the input unchanged.\n grayscale: function(args) {\n\n var amount = Number.isFinite(args.amount) ? args.amount : 1;\n\n return template('')({\n a: 0.2126 + 0.7874 * (1 - amount),\n b: 0.7152 - 0.7152 * (1 - amount),\n c: 0.0722 - 0.0722 * (1 - amount),\n d: 0.2126 - 0.2126 * (1 - amount),\n e: 0.7152 + 0.2848 * (1 - amount),\n f: 0.0722 - 0.0722 * (1 - amount),\n g: 0.2126 - 0.2126 * (1 - amount),\n h: 0.0722 + 0.9278 * (1 - amount)\n });\n },\n\n // `amount` ... the proportion of the conversion (1). A value of 1 (default) is completely sepia. A value of 0 leaves the input unchanged.\n sepia: function(args) {\n\n var amount = Number.isFinite(args.amount) ? args.amount : 1;\n\n return template('')({\n a: 0.393 + 0.607 * (1 - amount),\n b: 0.769 - 0.769 * (1 - amount),\n c: 0.189 - 0.189 * (1 - amount),\n d: 0.349 - 0.349 * (1 - amount),\n e: 0.686 + 0.314 * (1 - amount),\n f: 0.168 - 0.168 * (1 - amount),\n g: 0.272 - 0.272 * (1 - amount),\n h: 0.534 - 0.534 * (1 - amount),\n i: 0.131 + 0.869 * (1 - amount)\n });\n },\n\n // `amount` ... the proportion of the conversion (1). A value of 0 is completely un-saturated. A value of 1 (default) leaves the input unchanged.\n saturate: function(args) {\n\n var amount = Number.isFinite(args.amount) ? args.amount : 1;\n\n return template('')({\n amount: 1 - amount\n });\n },\n\n // `angle` ... the number of degrees around the color circle the input samples will be adjusted (0).\n hueRotate: function(args) {\n\n return template('')({\n angle: args.angle || 0\n });\n },\n\n // `amount` ... the proportion of the conversion (1). A value of 1 (default) is completely inverted. A value of 0 leaves the input unchanged.\n invert: function(args) {\n\n var amount = Number.isFinite(args.amount) ? args.amount : 1;\n\n return template('')({\n amount: amount,\n amount2: 1 - amount\n });\n },\n\n // `amount` ... proportion of the conversion (1). A value of 0 will create an image that is completely black. A value of 1 (default) leaves the input unchanged.\n brightness: function(args) {\n\n return template('')({\n amount: Number.isFinite(args.amount) ? args.amount : 1\n });\n },\n\n // `amount` ... proportion of the conversion (1). A value of 0 will create an image that is completely black. A value of 1 (default) leaves the input unchanged.\n contrast: function(args) {\n\n var amount = Number.isFinite(args.amount) ? args.amount : 1;\n\n return template('')({\n amount: amount,\n amount2: .5 - amount / 2\n });\n }\n};\n\nexport const format = {\n\n // Formatting numbers via the Python Format Specification Mini-language.\n // See http://docs.python.org/release/3.1.3/library/string.html#format-specification-mini-language.\n // Heavilly inspired by the D3.js library implementation.\n number: function(specifier, value, locale) {\n\n locale = locale || {\n\n currency: ['$', ''],\n decimal: '.',\n thousands: ',',\n grouping: [3]\n };\n\n // See Python format specification mini-language: http://docs.python.org/release/3.1.3/library/string.html#format-specification-mini-language.\n // [[fill]align][sign][symbol][0][width][,][.precision][type]\n var re = /(?:([^{])?([<>=^]))?([+\\- ])?([$#])?(0)?(\\d+)?(,)?(\\.-?\\d+)?([a-z%])?/i;\n\n var match = re.exec(specifier);\n var fill = match[1] || ' ';\n var align = match[2] || '>';\n var sign = match[3] || '';\n var symbol = match[4] || '';\n var zfill = match[5];\n var width = +match[6];\n var comma = match[7];\n var precision = match[8];\n var type = match[9];\n var scale = 1;\n var prefix = '';\n var suffix = '';\n var integer = false;\n\n if (precision) precision = +precision.substring(1);\n\n if (zfill || fill === '0' && align === '=') {\n zfill = fill = '0';\n align = '=';\n if (comma) width -= Math.floor((width - 1) / 4);\n }\n\n switch (type) {\n case 'n':\n comma = true;\n type = 'g';\n break;\n case '%':\n scale = 100;\n suffix = '%';\n type = 'f';\n break;\n case 'p':\n scale = 100;\n suffix = '%';\n type = 'r';\n break;\n case 'b':\n case 'o':\n case 'x':\n case 'X':\n if (symbol === '#') prefix = '0' + type.toLowerCase();\n break;\n case 'c':\n case 'd':\n integer = true;\n precision = 0;\n break;\n case 's':\n scale = -1;\n type = 'r';\n break;\n }\n\n if (symbol === '$') {\n prefix = locale.currency[0];\n suffix = locale.currency[1];\n }\n\n // If no precision is specified for `'r'`, fallback to general notation.\n if (type == 'r' && !precision) type = 'g';\n\n // Ensure that the requested precision is in the supported range.\n if (precision != null) {\n if (type == 'g') precision = Math.max(1, Math.min(21, precision));\n else if (type == 'e' || type == 'f') precision = Math.max(0, Math.min(20, precision));\n }\n\n var zcomma = zfill && comma;\n\n // Return the empty string for floats formatted as ints.\n if (integer && (value % 1)) return '';\n\n // Convert negative to positive, and record the sign prefix.\n var negative = value < 0 || value === 0 && 1 / value < 0 ? (value = -value, '-') : sign;\n\n var fullSuffix = suffix;\n\n // Apply the scale, computing it from the value's exponent for si format.\n // Preserve the existing suffix, if any, such as the currency symbol.\n if (scale < 0) {\n var unit = this.prefix(value, precision);\n value = unit.scale(value);\n fullSuffix = unit.symbol + suffix;\n } else {\n value *= scale;\n }\n\n // Convert to the desired precision.\n value = this.convert(type, value, precision);\n\n // Break the value into the integer part (before) and decimal part (after).\n var i = value.lastIndexOf('.');\n var before = i < 0 ? value : value.substring(0, i);\n var after = i < 0 ? '' : locale.decimal + value.substring(i + 1);\n\n function formatGroup(value) {\n\n var i = value.length;\n var t = [];\n var j = 0;\n var g = locale.grouping[0];\n while (i > 0 && g > 0) {\n t.push(value.substring(i -= g, i + g));\n g = locale.grouping[j = (j + 1) % locale.grouping.length];\n }\n return t.reverse().join(locale.thousands);\n }\n\n // If the fill character is not `'0'`, grouping is applied before padding.\n if (!zfill && comma && locale.grouping) {\n\n before = formatGroup(before);\n }\n\n var length = prefix.length + before.length + after.length + (zcomma ? 0 : negative.length);\n var padding = length < width ? new Array(length = width - length + 1).join(fill) : '';\n\n // If the fill character is `'0'`, grouping is applied after padding.\n if (zcomma) before = formatGroup(padding + before);\n\n // Apply prefix.\n negative += prefix;\n\n // Rejoin integer and decimal parts.\n value = before + after;\n\n return (align === '<' ? negative + value + padding\n : align === '>' ? padding + negative + value\n : align === '^' ? padding.substring(0, length >>= 1) + negative + value + padding.substring(length)\n : negative + (zcomma ? value : padding + value)) + fullSuffix;\n },\n\n // Formatting string via the Python Format string.\n // See https://docs.python.org/2/library/string.html#format-string-syntax)\n string: function(formatString, value) {\n\n var fieldDelimiterIndex;\n var fieldDelimiter = '{';\n var endPlaceholder = false;\n var formattedStringArray = [];\n\n while ((fieldDelimiterIndex = formatString.indexOf(fieldDelimiter)) !== -1) {\n\n var pieceFormattedString, formatSpec, fieldName;\n\n pieceFormattedString = formatString.slice(0, fieldDelimiterIndex);\n\n if (endPlaceholder) {\n formatSpec = pieceFormattedString.split(':');\n fieldName = formatSpec.shift().split('.');\n pieceFormattedString = value;\n\n for (var i = 0; i < fieldName.length; i++)\n pieceFormattedString = pieceFormattedString[fieldName[i]];\n\n if (formatSpec.length)\n pieceFormattedString = this.number(formatSpec, pieceFormattedString);\n }\n\n formattedStringArray.push(pieceFormattedString);\n\n formatString = formatString.slice(fieldDelimiterIndex + 1);\n endPlaceholder = !endPlaceholder;\n fieldDelimiter = (endPlaceholder) ? '}' : '{';\n }\n formattedStringArray.push(formatString);\n\n return formattedStringArray.join('');\n },\n\n convert: function(type, value, precision) {\n\n switch (type) {\n case 'b':\n return value.toString(2);\n case 'c':\n return String.fromCharCode(value);\n case 'o':\n return value.toString(8);\n case 'x':\n return value.toString(16);\n case 'X':\n return value.toString(16).toUpperCase();\n case 'g':\n return value.toPrecision(precision);\n case 'e':\n return value.toExponential(precision);\n case 'f':\n return value.toFixed(precision);\n case 'r':\n return (value = this.round(value, this.precision(value, precision))).toFixed(Math.max(0, Math.min(20, this.precision(value * (1 + 1e-15), precision))));\n default:\n return value + '';\n }\n },\n\n round: function(value, precision) {\n\n return precision\n ? Math.round(value * (precision = Math.pow(10, precision))) / precision\n : Math.round(value);\n },\n\n precision: function(value, precision) {\n\n return precision - (value ? Math.ceil(Math.log(value) / Math.LN10) : 1);\n },\n\n prefix: function(value, precision) {\n\n var prefixes = ['y', 'z', 'a', 'f', 'p', 'n', 'µ', 'm', '', 'k', 'M', 'G', 'T', 'P', 'E', 'Z', 'Y'].map(function(d, i) {\n var k = Math.pow(10, Math.abs(8 - i) * 3);\n return {\n scale: i > 8 ? function(d) {\n return d / k;\n } : function(d) {\n return d * k;\n },\n symbol: d\n };\n });\n\n var i = 0;\n if (value) {\n if (value < 0) value *= -1;\n if (precision) value = this.round(value, this.precision(value, precision));\n i = 1 + Math.floor(1e-12 + Math.log(value) / Math.LN10);\n i = Math.max(-24, Math.min(24, Math.floor((i <= 0 ? i + 1 : i - 1) / 3) * 3));\n }\n return prefixes[8 + i / 3];\n }\n};\n\n/*\n Pre-compile the HTML to be used as a template.\n*/\nexport const template = function(html) {\n\n /*\n Must support the variation in templating syntax found here:\n https://lodash.com/docs#template\n */\n var regex = /<%= ([^ ]+) %>|\\$\\{ ?([^{} ]+) ?\\}|\\{\\{([^{} ]+)\\}\\}/g;\n\n return function(data) {\n\n data = data || {};\n\n return html.replace(regex, function(match) {\n\n var args = Array.from(arguments);\n var attr = args.slice(1, 4).find(function(_attr) {\n return !!_attr;\n });\n\n var attrArray = attr.split('.');\n var value = data[attrArray.shift()];\n\n while (value !== undefined && attrArray.length) {\n value = value[attrArray.shift()];\n }\n\n return value !== undefined ? value : '';\n });\n };\n};\n\n/**\n * @param {Element} el Element, which content is intent to display in full-screen mode, 'window.top.document.body' is default.\n */\nexport const toggleFullScreen = function(el) {\n\n var topDocument = window.top.document;\n el = el || topDocument.body;\n\n function prefixedResult(el, prop) {\n\n var prefixes = ['webkit', 'moz', 'ms', 'o', ''];\n for (var i = 0; i < prefixes.length; i++) {\n var prefix = prefixes[i];\n var propName = prefix ? (prefix + prop) : (prop.substr(0, 1).toLowerCase() + prop.substr(1));\n if (el[propName] !== undefined) {\n return isFunction(el[propName]) ? el[propName]() : el[propName];\n }\n }\n }\n\n if (prefixedResult(topDocument, 'FullscreenElement') || prefixedResult(topDocument, 'FullScreenElement')) {\n prefixedResult(topDocument, 'ExitFullscreen') || // Spec.\n prefixedResult(topDocument, 'CancelFullScreen'); // Firefox\n } else {\n prefixedResult(el, 'RequestFullscreen') || // Spec.\n prefixedResult(el, 'RequestFullScreen'); // Firefox\n }\n};\n\nfunction findDifference(obj, baseObj, currentDepth, maxDepth) {\n\n if (currentDepth === maxDepth) {\n return {};\n }\n\n const diff = {};\n\n Object.keys(obj).forEach((key) => {\n\n const objValue = obj[key];\n const baseValue = baseObj[key];\n\n if (!Array.isArray(objValue) && !Array.isArray(baseValue) && isObject(objValue) && isObject(baseValue)) {\n\n const nestedDepth = currentDepth + 1;\n const nestedDiff = findDifference(objValue, baseValue, nestedDepth, maxDepth);\n\n if (Object.keys(nestedDiff).length > 0) {\n diff[key] = nestedDiff;\n } else if ((currentDepth === 0 || nestedDepth === maxDepth)) {\n diff[key] = {};\n }\n\n } else if (!isEqual(objValue, baseValue)) {\n diff[key] = objValue;\n }\n });\n\n return diff;\n}\n\nexport function objectDifference(object, base, opt) {\n\n const { maxDepth = Number.POSITIVE_INFINITY } = opt || {};\n\n return findDifference(object, base, 0, maxDepth);\n}\n\nexport {\n isBoolean,\n isObject,\n isNumber,\n isString,\n mixin,\n deepMixin,\n supplement,\n defaults,\n deepSupplement,\n defaultsDeep,\n assign,\n invoke,\n invokeProperty,\n sortedIndex,\n uniq,\n clone,\n cloneDeep,\n isEmpty,\n isEqual,\n isFunction,\n isPlainObject,\n toArray,\n debounce,\n groupBy,\n sortBy,\n flattenDeep,\n without,\n difference,\n intersection,\n union,\n has,\n result,\n omit,\n pick,\n bindAll,\n forIn,\n camelCase,\n uniqueId,\n merge\n};\n\nexport const noop = function() {\n};\n","import {\n isEmpty,\n uniqueId \n} from '../util/util.mjs';\n\n// Events\n// ---------------\n\n// A module that can be mixed in to *any object* in order to provide it with\n// a custom event channel. You may bind a callback to an event with `on` or\n// remove with `off`; `trigger`-ing an event fires all callbacks in\n// succession.\n//\n// const object = {};\n// assign(object, Events);\n// object.on('expand', function(){ alert('expanded'); });\n// object.trigger('expand');\n//\nexport var Events = {};\n\n// Regular expression used to split event strings.\nvar eventSplitter = /\\s+/;\n\n// A private global variable to share between listeners and listenees.\nvar _listening;\n\n// Iterates over the standard `event, callback` (as well as the fancy multiple\n// space-separated events `\"change blur\", callback` and jQuery-style event\n// maps `{event: callback}`).\nvar eventsApi = function(iteratee, events, name, callback, opts) {\n var i = 0, names;\n if (name && typeof name === 'object') {\n // Handle event maps.\n if (callback !== void 0 && 'context' in opts && opts.context === void 0) opts.context = callback;\n for (names = Object.keys(name); i < names.length ; i++) {\n events = eventsApi(iteratee, events, names[i], name[names[i]], opts);\n }\n } else if (name && eventSplitter.test(name)) {\n // Handle space-separated event names by delegating them individually.\n for (names = name.split(eventSplitter); i < names.length; i++) {\n events = iteratee(events, names[i], callback, opts);\n }\n } else {\n // Finally, standard events.\n events = iteratee(events, name, callback, opts);\n }\n return events;\n};\n\n// Bind an event to a `callback` function. Passing `\"all\"` will bind\n// the callback to all events fired.\nEvents.on = function(name, callback, context) {\n this._events = eventsApi(onApi, this._events || {}, name, callback, {\n context: context,\n ctx: this,\n listening: _listening\n });\n\n if (_listening) {\n var listeners = this._listeners || (this._listeners = {});\n listeners[_listening.id] = _listening;\n // Allow the listening to use a counter, instead of tracking\n // callbacks for library interop\n _listening.interop = false;\n }\n\n return this;\n};\n\n// Inversion-of-control versions of `on`. Tell *this* object to listen to\n// an event in another object... keeping track of what it's listening to\n// for easier unbinding later.\nEvents.listenTo = function(obj, name, callback) {\n if (!obj) return this;\n var id = obj._listenId || (obj._listenId = uniqueId('l'));\n var listeningTo = this._listeningTo || (this._listeningTo = {});\n var listening = _listening = listeningTo[id];\n\n // This object is not listening to any other events on `obj` yet.\n // Setup the necessary references to track the listening callbacks.\n if (!listening) {\n this._listenId || (this._listenId = uniqueId('l'));\n listening = _listening = listeningTo[id] = new Listening(this, obj);\n }\n\n // Bind callbacks on obj.\n var error = tryCatchOn(obj, name, callback, this);\n _listening = void 0;\n\n if (error) throw error;\n // If the target obj is not Events, track events manually.\n if (listening.interop) listening.on(name, callback);\n\n return this;\n};\n\n// The reducing API that adds a callback to the `events` object.\nvar onApi = function(events, name, callback, options) {\n if (callback) {\n var handlers = events[name] || (events[name] = []);\n var context = options.context, ctx = options.ctx, listening = options.listening;\n if (listening) listening.count++;\n\n handlers.push({ callback: callback, context: context, ctx: context || ctx, listening: listening });\n }\n return events;\n};\n\n// An try-catch guarded #on function, to prevent poisoning the global\n// `_listening` variable.\nvar tryCatchOn = function(obj, name, callback, context) {\n try {\n obj.on(name, callback, context);\n } catch (e) {\n return e;\n }\n};\n\n// Remove one or many callbacks. If `context` is null, removes all\n// callbacks with that function. If `callback` is null, removes all\n// callbacks for the event. If `name` is null, removes all bound\n// callbacks for all events.\nEvents.off = function(name, callback, context) {\n if (!this._events) return this;\n this._events = eventsApi(offApi, this._events, name, callback, {\n context: context,\n listeners: this._listeners\n });\n\n return this;\n};\n\n// Tell this object to stop listening to either specific events ... or\n// to every object it's currently listening to.\nEvents.stopListening = function(obj, name, callback) {\n var listeningTo = this._listeningTo;\n if (!listeningTo) return this;\n\n var ids = obj ? [obj._listenId] : Object.keys(listeningTo);\n for (var i = 0; i < ids.length; i++) {\n var listening = listeningTo[ids[i]];\n\n // If listening doesn't exist, this object is not currently\n // listening to obj. Break out early.\n if (!listening) break;\n\n listening.obj.off(name, callback, this);\n if (listening.interop) listening.off(name, callback);\n }\n if (isEmpty(listeningTo)) this._listeningTo = void 0;\n\n return this;\n};\n\n// The reducing API that removes a callback from the `events` object.\nvar offApi = function(events, name, callback, options) {\n if (!events) return;\n\n var context = options.context, listeners = options.listeners;\n var i = 0, names;\n\n // Delete all event listeners and \"drop\" events.\n if (!name && !context && !callback) {\n if(listeners != null) {\n for (names = Object.keys(listeners); i < names.length; i++) {\n listeners[names[i]].cleanup();\n }\n }\n return;\n }\n names = name ? [name] : Object.keys(events);\n for (; i < names.length; i++) {\n name = names[i];\n var handlers = events[name];\n\n // Bail out if there are no events stored.\n if (!handlers) break;\n\n // Find any remaining events.\n var remaining = [];\n for (var j = 0; j < handlers.length; j++) {\n var handler = handlers[j];\n if (\n callback && callback !== handler.callback &&\n callback !== handler.callback._callback ||\n context && context !== handler.context\n ) {\n remaining.push(handler);\n } else {\n var listening = handler.listening;\n if (listening) listening.off(name, callback);\n }\n }\n\n // Replace events if there are any remaining. Otherwise, clean up.\n if (remaining.length) {\n events[name] = remaining;\n } else {\n delete events[name];\n }\n }\n\n return events;\n};\n\n// Bind an event to only be triggered a single time. After the first time\n// the callback is invoked, its listener will be removed. If multiple events\n// are passed in using the space-separated syntax, the handler will fire\n// once for each event, not once for a combination of all events.\nEvents.once = function(name, callback, context) {\n// Map the event into a `{event: once}` object.\n var events = eventsApi(onceMap, {}, name, callback, this.off.bind(this));\n if (typeof name === 'string' && context == null) callback = void 0;\n return this.on(events, callback, context);\n};\n\n// Inversion-of-control versions of `once`.\nEvents.listenToOnce = function(obj, name, callback) {\n// Map the event into a `{event: once}` object.\n var events = eventsApi(onceMap, {}, name, callback, this.stopListening.bind(this, obj));\n return this.listenTo(obj, events);\n};\n\n// Reduces the event callbacks into a map of `{event: onceWrapper}`.\n// `offer` unbinds the `onceWrapper` after it has been called.\nvar onceMap = function(map, name, callback, offer) {\n if (callback) {\n var once = map[name] = onceInvoke(function() {\n offer(name, once);\n callback.apply(this, arguments);\n });\n once._callback = callback;\n }\n return map;\n};\n\n// Creates a function that is restricted to invoking 'func' once.\n// Repeat calls to the function return the value of the first invocation.\nvar onceInvoke = function(func) {\n var result;\n if (typeof func != 'function') {\n throw new TypeError('Expected a function');\n }\n var n = 2;\n return function() {\n if (--n > 0) {\n result = func.apply(this, arguments);\n }\n if (n <= 1) {\n func = undefined;\n }\n return result;\n };\n};\n\n// Trigger one or many events, firing all bound callbacks. Callbacks are\n// passed the same arguments as `trigger` is, apart from the event name\n// (unless you're listening on `\"all\"`, which will cause your callback to\n// receive the true name of the event as the first argument).\nEvents.trigger = function(name) {\n if (!this._events) return this;\n\n var length = Math.max(0, arguments.length - 1);\n var args = Array(length);\n for (var i = 0; i < length; i++) args[i] = arguments[i + 1];\n\n eventsApi(triggerApi, this._events, name, void 0, args);\n return this;\n};\n\n// Handles triggering the appropriate event callbacks.\nvar triggerApi = function(objEvents, name, callback, args) {\n if (objEvents) {\n var events = objEvents[name];\n var allEvents = objEvents.all;\n if (events && allEvents) allEvents = allEvents.slice();\n if (events) triggerEvents(events, args);\n if (allEvents) triggerEvents(allEvents, [name].concat(args));\n }\n return objEvents;\n};\n\n// A difficult-to-believe, but optimized internal dispatch function for\n// triggering events. Tries to keep the usual cases speedy (most internal\n// events have 3 arguments).\nvar triggerEvents = function(events, args) {\n var ev, i = -1, l = events.length, a1 = args[0], a2 = args[1], a3 = args[2];\n switch (args.length) {\n case 0: while (++i < l) (ev = events[i]).callback.call(ev.ctx); return;\n case 1: while (++i < l) (ev = events[i]).callback.call(ev.ctx, a1); return;\n case 2: while (++i < l) (ev = events[i]).callback.call(ev.ctx, a1, a2); return;\n case 3: while (++i < l) (ev = events[i]).callback.call(ev.ctx, a1, a2, a3); return;\n default: while (++i < l) (ev = events[i]).callback.apply(ev.ctx, args); return;\n }\n};\n\n// A listening class that tracks and cleans up memory bindings\n// when all callbacks have been offed.\nvar Listening = function(listener, obj) {\n this.id = listener._listenId;\n this.listener = listener;\n this.obj = obj;\n this.interop = true;\n this.count = 0;\n this._events = void 0;\n};\n\nListening.prototype.on = Events.on;\n\n// Offs a callback (or several).\n// Uses an optimized counter if the listenee uses Events.\n// Otherwise, falls back to manual tracking to support events\n// library interop.\nListening.prototype.off = function(name, callback) {\n var cleanup;\n if (this.interop) {\n this._events = eventsApi(offApi, this._events, name, callback, {\n context: void 0,\n listeners: void 0\n });\n cleanup = !this._events;\n } else {\n this.count--;\n cleanup = this.count === 0;\n }\n if (cleanup) this.cleanup();\n};\n\n// Cleans up memory bindings between the listener and the listenee.\nListening.prototype.cleanup = function() {\n delete this.listener._listeningTo[this.obj._listenId];\n if (!this.interop) delete this.obj._listeners[this.id];\n};\n\n// Aliases for backwards compatibility.\nEvents.bind = Events.on;\nEvents.unbind = Events.off;\n","import {\n assign,\n forIn,\n has,\n isFunction,\n isObject,\n isString\n} from '../util/util.mjs';\nimport { matches } from '../util/utilHelpers.mjs';\n\n// Helpers\n// -------\n\n// Helper function to correctly set up the prototype chain for subclasses.\n// Similar to `goog.inherits`, but uses a hash of prototype properties and\n// class properties to be extended.\nexport var extend = function(protoProps, staticProps) {\n var parent = this;\n var child;\n\n // The constructor function for the new subclass is either defined by you\n // (the \"constructor\" property in your `extend` definition), or defaulted\n // by us to simply call the parent constructor.\n if (protoProps && has(protoProps, 'constructor')) {\n child = protoProps.constructor;\n } else {\n child = function(){ return parent.apply(this, arguments); };\n }\n\n // Add static properties to the constructor function, if supplied.\n assign(child, parent, staticProps);\n\n // Set the prototype chain to inherit from `parent`, without calling\n // `parent`'s constructor function and add the prototype properties.\n child.prototype = Object.assign(Object.create(parent.prototype), protoProps);\n child.prototype.constructor = child;\n\n // Set a convenience property in case the parent's prototype is needed\n // later.\n child.__super__ = parent.prototype;\n\n return child;\n};\n\n// Proxy class methods to functions, wrapping the model's\n// `attributes` object or collection's `models` array behind the scenes.\n//\n// `Function#apply` can be slow so we use the method's arg count, if we know it.\nvar addMethod = function(base, length, method, attribute) {\n switch (length) {\n case 1: return function() {\n return base[method](this[attribute]);\n };\n case 2: return function(value) {\n return base[method](this[attribute], value);\n };\n case 3: return function(iteratee, context) {\n return base[method](this[attribute], cb(iteratee, this), context);\n };\n case 4: return function(iteratee, defaultVal, context) {\n return base[method](this[attribute], cb(iteratee, this), defaultVal, context);\n };\n default: return function() {\n var args = Array.prototype.slice.call(arguments);\n args.unshift(this[attribute]);\n return base[method].apply(base, args);\n };\n }\n};\n\nexport var addMethodsUtil = function(Class, base, methods, attribute) {\n forIn(methods, function(length, method) {\n if (base[method]) Class.prototype[method] = addMethod(base, length, method, attribute);\n });\n};\n\n// Support `collection.sortBy('attr')`.\nvar cb = function(iteratee, instance) {\n if (isFunction(iteratee)) return iteratee;\n if (isObject(iteratee) && !instance._isModel(iteratee)) return modelMatcher(iteratee);\n if (isString(iteratee)) return function(model) { return model.get(iteratee); };\n return iteratee;\n};\n\nvar modelMatcher = function(attrs) {\n var matcher = matches(attrs);\n return function(model) {\n return matcher(model.attributes);\n };\n};\n","import { Events } from './Events.mjs';\nimport { extend } from './mvcUtils.mjs';\nimport {\n assign,\n clone,\n defaults,\n has,\n isEqual,\n isEmpty,\n result,\n uniqueId\n} from '../util/util.mjs';\n\n// Model\n// --------------\n\n// **Models** are the basic data object in the framework --\n// frequently representing a row in a table in a database on your server.\n// A discrete chunk of data and a bunch of useful, related methods for\n// performing computations and transformations on that data.\n\n// Create a new model with the specified attributes. A client id (`cid`)\n// is automatically generated and assigned for you.\n\nexport var Model = function(attributes, options) {\n var attrs = attributes || {};\n options || (options = {});\n this.preinitialize.apply(this, arguments);\n this.cid = uniqueId(this.cidPrefix);\n this.attributes = {};\n if (options.collection) this.collection = options.collection;\n var attributeDefaults = result(this, 'defaults');\n\n // Just _.defaults would work fine, but the additional _.extends\n // is in there for historical reasons. See #3843.\n attrs = defaults(assign({}, attributeDefaults, attrs), attributeDefaults);\n\n this.set(attrs, options);\n this.changed = {};\n this.initialize.apply(this, arguments);\n};\n\n// Attach all inheritable methods to the Model prototype.\nassign(Model.prototype, Events, {\n\n // A hash of attributes whose current and previous value differ.\n changed: null,\n\n // The value returned during the last failed validation.\n validationError: null,\n\n // The default name for the JSON `id` attribute is `\"id\"`. MongoDB and\n // CouchDB users may want to set this to `\"_id\"`.\n idAttribute: 'id',\n\n // The prefix is used to create the client id which is used to identify models locally.\n // You may want to override this if you're experiencing name clashes with model ids.\n cidPrefix: 'c',\n\n // preinitialize is an empty function by default. You can override it with a function\n // or object. preinitialize will run before any instantiation logic is run in the Model.\n preinitialize: function(){},\n\n // Initialize is an empty function by default. Override it with your own\n // initialization logic.\n initialize: function(){},\n\n // Return a copy of the model's `attributes` object.\n toJSON: function(options) {\n return clone(this.attributes);\n },\n\n // Get the value of an attribute.\n get: function(attr) {\n return this.attributes[attr];\n },\n\n // Returns `true` if the attribute contains a value that is not null\n // or undefined.\n has: function(attr) {\n return this.get(attr) != null;\n },\n\n // Set a hash of model attributes on the object, firing `\"change\"`. This is\n // the core primitive operation of a model, updating the data and notifying\n // anyone who needs to know about the change in state. The heart of the beast.\n set: function(key, val, options) {\n if (key == null) return this;\n\n // Handle both `\"key\", value` and `{key: value}` -style arguments.\n var attrs;\n if (typeof key === 'object') {\n attrs = key;\n options = val;\n } else {\n (attrs = {})[key] = val;\n }\n\n options || (options = {});\n\n // Run validation.\n if (!this._validate(attrs, options)) return false;\n\n // Extract attributes and options.\n var unset = options.unset;\n var silent = options.silent;\n var changes = [];\n var changing = this._changing;\n this._changing = true;\n\n if (!changing) {\n this._previousAttributes = clone(this.attributes);\n this.changed = {};\n }\n\n var current = this.attributes;\n var changed = this.changed;\n var prev = this._previousAttributes;\n\n // For each `set` attribute, update or delete the current value.\n for (var attr in attrs) {\n val = attrs[attr];\n if (!isEqual(current[attr], val)) changes.push(attr);\n if (!isEqual(prev[attr], val)) {\n changed[attr] = val;\n } else {\n delete changed[attr];\n }\n unset ? delete current[attr] : current[attr] = val;\n }\n\n // Update the `id`.\n if (this.idAttribute in attrs) {\n var prevId = this.id;\n this.id = this.get(this.idAttribute);\n this.trigger('changeId', this, prevId, options);\n }\n\n // Trigger all relevant attribute changes.\n if (!silent) {\n if (changes.length) this._pending = options;\n for (var i = 0; i < changes.length; i++) {\n this.trigger('change:' + changes[i], this, current[changes[i]], options);\n }\n }\n\n // You might be wondering why there's a `while` loop here. Changes can\n // be recursively nested within `\"change\"` events.\n if (changing) return this;\n if (!silent) {\n while (this._pending) {\n options = this._pending;\n this._pending = false;\n this.trigger('change', this, options);\n }\n }\n this._pending = false;\n this._changing = false;\n return this;\n },\n\n // Remove an attribute from the model, firing `\"change\"`. `unset` is a noop\n // if the attribute doesn't exist.\n unset: function(attr, options) {\n return this.set(attr, void 0, assign({}, options, { unset: true }));\n },\n\n // Clear all attributes on the model, firing `\"change\"`.\n clear: function(options) {\n var attrs = {};\n for (var key in this.attributes) attrs[key] = void 0;\n return this.set(attrs, assign({}, options, { unset: true }));\n },\n\n // Determine if the model has changed since the last `\"change\"` event.\n // If you specify an attribute name, determine if that attribute has changed.\n hasChanged: function(attr) {\n if (attr == null) return !isEmpty(this.changed);\n return has(this.changed, attr);\n },\n\n // Return an object containing all the attributes that have changed, or\n // false if there are no changed attributes. Useful for determining what\n // parts of a view need to be updated and/or what attributes need to be\n // persisted to the server. Unset attributes will be set to undefined.\n // You can also pass an attributes object to diff against the model,\n // determining if there *would be* a change.\n changedAttributes: function(diff) {\n if (!diff) return this.hasChanged() ? clone(this.changed) : false;\n var old = this._changing ? this._previousAttributes : this.attributes;\n var changed = {};\n var hasChanged;\n for (var attr in diff) {\n var val = diff[attr];\n if (isEqual(old[attr], val)) continue;\n changed[attr] = val;\n hasChanged = true;\n }\n return hasChanged ? changed : false;\n },\n\n // Get the previous value of an attribute, recorded at the time the last\n // `\"change\"` event was fired.\n previous: function(attr) {\n if (attr == null || !this._previousAttributes) return null;\n return this._previousAttributes[attr];\n },\n\n // Get all of the attributes of the model at the time of the previous\n // `\"change\"` event.\n previousAttributes: function() {\n return clone(this._previousAttributes);\n },\n\n // Create a new model with identical attributes to this one.\n clone: function() {\n return new this.constructor(this.attributes);\n },\n\n // Check if the model is currently in a valid state.\n isValid: function(options) {\n return this._validate({}, assign({}, options, { validate: true }));\n },\n\n // Run validation against the next complete set of model attributes,\n // returning `true` if all is well. Otherwise, fire an `\"invalid\"` event.\n _validate: function(attrs, options) {\n if (!options.validate || !this.validate) return true;\n attrs = assign({}, this.attributes, attrs);\n var error = this.validationError = this.validate(attrs, options) || null;\n if (!error) return true;\n this.trigger('invalid', this, error, assign(options, { validationError: error }));\n return false;\n }\n\n});\n\n// Set up inheritance for the model.\nModel.extend = extend;\n","import { uniq, toArray, isEmpty } from './util.mjs';\n\n// Clone `cells` returning an object that maps the original cell ID to the clone. The number\n// of clones is exactly the same as the `cells.length`.\n// This function simply clones all the `cells`. However, it also reconstructs\n// all the `source/target` and `parent/embed` references within the `cells`.\n// This is the main difference from the `cell.clone()` method. The\n// `cell.clone()` method works on one single cell only.\n// For example, for a graph: `A --- L ---> B`, `cloneCells([A, L, B])`\n// returns `[A2, L2, B2]` resulting to a graph: `A2 --- L2 ---> B2`, i.e.\n// the source and target of the link `L2` is changed to point to `A2` and `B2`.\nexport function cloneCells(cells) {\n\n cells = uniq(cells);\n\n // A map of the form [original cell ID] -> [clone] helping\n // us to reconstruct references for source/target and parent/embeds.\n // This is also the returned value.\n const cloneMap = toArray(cells).reduce(function(map, cell) {\n map[cell.id] = cell.clone();\n return map;\n }, {});\n\n toArray(cells).forEach(function(cell) {\n\n const clone = cloneMap[cell.id];\n // assert(clone exists)\n\n if (clone.isLink()) {\n const source = clone.source();\n const target = clone.target();\n if (source.id && cloneMap[source.id]) {\n // Source points to an element and the element is among the clones.\n // => Update the source of the cloned link.\n clone.prop('source/id', cloneMap[source.id].id);\n }\n if (target.id && cloneMap[target.id]) {\n // Target points to an element and the element is among the clones.\n // => Update the target of the cloned link.\n clone.prop('target/id', cloneMap[target.id].id);\n }\n }\n\n // Find the parent of the original cell\n const parent = cell.get('parent');\n if (parent && cloneMap[parent]) {\n clone.set('parent', cloneMap[parent].id);\n }\n\n // Find the embeds of the original cell\n const embeds = toArray(cell.get('embeds')).reduce(function(newEmbeds, embed) {\n // Embedded cells that are not being cloned can not be carried\n // over with other embedded cells.\n if (cloneMap[embed]) {\n newEmbeds.push(cloneMap[embed].id);\n }\n return newEmbeds;\n }, []);\n\n if (!isEmpty(embeds)) {\n clone.set('embeds', embeds);\n }\n });\n\n return cloneMap;\n}\n\n","import { isPlainObject } from '../../util/util.mjs';\n\nconst validPropertiesList = ['checked', 'selected', 'disabled', 'readOnly', 'contentEditable', 'value', 'indeterminate'];\n\nconst validProperties = validPropertiesList.reduce((acc, key) => {\n acc[key] = true;\n return acc;\n}, {});\n\nconst props = {\n qualify: function(properties) {\n return isPlainObject(properties);\n },\n set: function(properties, _, node) {\n Object.keys(properties).forEach(function(key) {\n if (validProperties[key] && key in node) {\n const value = properties[key];\n if (node.tagName === 'SELECT' && Array.isArray(value)) {\n Array.from(node.options).forEach(function(option, index) {\n option.selected = value.includes(option.value);\n });\n } else {\n node[key] = value;\n }\n }\n });\n }\n};\n\nexport default props;\n","import { Point } from '../../g/index.mjs';\nimport { isPercentage } from '../../util/util.mjs';\n\nfunction positionWrapper(axis, dimension, origin) {\n return function(value, refBBox) {\n var valuePercentage = isPercentage(value);\n value = parseFloat(value);\n if (valuePercentage) {\n value /= 100;\n }\n\n var delta;\n if (isFinite(value)) {\n var refOrigin = refBBox[origin]();\n if (valuePercentage || value > 0 && value < 1) {\n delta = refOrigin[axis] + refBBox[dimension] * value;\n } else {\n delta = refOrigin[axis] + value;\n }\n }\n\n var point = Point();\n point[axis] = delta || 0;\n return point;\n };\n}\n\nfunction setWrapper(attrName, dimension) {\n return function(value, refBBox) {\n var isValuePercentage = isPercentage(value);\n value = parseFloat(value);\n if (isValuePercentage) {\n value /= 100;\n }\n\n var attrs = {};\n if (isFinite(value)) {\n var attrValue = (isValuePercentage || value >= 0 && value <= 1)\n ? value * refBBox[dimension]\n : Math.max(value + refBBox[dimension], 0);\n attrs[attrName] = attrValue;\n }\n\n return attrs;\n };\n}\n\nconst legacyAttributesNS = {\n\n // if `refX` is in [0, 1] then `refX` is a fraction of bounding box width\n // if `refX` is < 0 then `refX`'s absolute values is the right coordinate of the bounding box\n // otherwise, `refX` is the left coordinate of the bounding box\n 'ref-x': {\n position: positionWrapper('x', 'width', 'origin')\n },\n\n 'ref-y': {\n position: positionWrapper('y', 'height', 'origin')\n },\n\n // `ref-dx` and `ref-dy` define the offset of the sub-element relative to the right and/or bottom\n // coordinate of the reference element.\n\n 'ref-dx': {\n position: positionWrapper('x', 'width', 'corner')\n },\n\n 'ref-dy': {\n position: positionWrapper('y', 'height', 'corner')\n },\n\n // 'ref-width'/'ref-height' defines the width/height of the sub-element relatively to\n // the reference element size\n // val in 0..1 ref-width = 0.75 sets the width to 75% of the ref. el. width\n // val < 0 || val > 1 ref-height = -20 sets the height to the ref. el. height shorter by 20\n\n 'ref-width': {\n set: setWrapper('width', 'width')\n },\n\n 'ref-height': {\n set: setWrapper('height', 'height')\n },\n\n 'ref-rx': {\n set: setWrapper('rx', 'width')\n },\n\n 'ref-ry': {\n set: setWrapper('ry', 'height')\n },\n\n 'ref-cx': {\n set: setWrapper('cx', 'width')\n },\n\n 'ref-cy': {\n set: setWrapper('cy', 'height')\n },\n\n 'ref-r-inscribed': {\n set: (function(attrName) {\n var widthFn = setWrapper(attrName, 'width');\n var heightFn = setWrapper(attrName, 'height');\n return function(value, refBBox) {\n var fn = (refBBox.height > refBBox.width) ? widthFn : heightFn;\n return fn(value, refBBox);\n };\n })('r')\n },\n\n 'ref-r-circumscribed': {\n set: function(value, refBBox) {\n var isValuePercentage = isPercentage(value);\n value = parseFloat(value);\n if (isValuePercentage) {\n value /= 100;\n }\n\n var diagonalLength = Math.sqrt((refBBox.height * refBBox.height) + (refBBox.width * refBBox.width));\n\n var rValue;\n if (isFinite(value)) {\n if (isValuePercentage || value >= 0 && value <= 1) rValue = value * diagonalLength;\n else rValue = Math.max(value + diagonalLength, 0);\n }\n\n return { r: rValue };\n }\n },\n};\n\n// NOTE: refX & refY are SVG attributes that define the reference point of the marker.\n// That's why we need to define both variants: `refX` and `ref-x` (and `refY` and `ref-y`).\nlegacyAttributesNS['refX'] = legacyAttributesNS['ref-x'];\nlegacyAttributesNS['refY'] = legacyAttributesNS['ref-y'];\n\n// This allows to combine both absolute and relative positioning\n// refX: 50%, refX2: 20\nlegacyAttributesNS['ref-x2'] = legacyAttributesNS['ref-x'];\nlegacyAttributesNS['ref-y2'] = legacyAttributesNS['ref-y'];\nlegacyAttributesNS['ref-width2'] = legacyAttributesNS['ref-width'];\nlegacyAttributesNS['ref-height2'] = legacyAttributesNS['ref-height'];\n\n// Aliases\nlegacyAttributesNS['ref-r'] = legacyAttributesNS['ref-r-inscribed'];\n\nexport default legacyAttributesNS;\n","const props = {\n x: 'x',\n y: 'y',\n width: 'w',\n height: 'h',\n minimum: 's',\n maximum: 'l',\n diagonal: 'd'\n};\nconst propsList = Object.keys(props).map(key => props[key]).join('');\nconst numberPattern = '[-+]?[0-9]*\\\\.?[0-9]+(?:[eE][-+]?[0-9]+)?';\nconst findSpacesRegex = /\\s/g;\nconst parseFormulaRegExp = new RegExp(`^(${numberPattern}\\\\*)?([${propsList}])(/${numberPattern})?([-+]{1,2}${numberPattern})?$`, 'g');\n\nfunction throwInvalid(expression) {\n throw new Error(`Invalid calc() expression: ${expression}`);\n}\n\n/*\n* Evaluate the given calc formula.\n* e.g. 'w + 10' in a rect 100x100 -> 110\n*/\nexport function evalCalcFormula(formula, rect) {\n const match = parseFormulaRegExp.exec(formula.replace(findSpacesRegex, ''));\n if (!match) throwInvalid(formula);\n parseFormulaRegExp.lastIndex = 0; // reset regex results for the next run\n const [,multiply, property, divide, add] = match;\n const { x, y, width, height } = rect;\n let value = 0;\n switch (property) {\n case props.width: {\n value = width;\n break;\n }\n case props.height: {\n value = height;\n break;\n }\n case props.x: {\n value = x;\n break;\n }\n case props.y: {\n value = y;\n break;\n }\n case props.minimum: {\n value = Math.min(height, width);\n break;\n }\n case props.maximum: {\n value = Math.max(height, width);\n break;\n }\n case props.diagonal: {\n value = Math.sqrt((height * height) + (width * width));\n break;\n }\n }\n if (multiply) {\n // e.g \"2*\"\n value *= parseFloat(multiply);\n }\n if (divide) {\n // e.g \"/2\"\n value /= parseFloat(divide.slice(1));\n }\n if (add) {\n value += evalAddExpression(add);\n }\n return value;\n}\n\nfunction evalAddExpression(addExpression) {\n if (!addExpression) return 0;\n const [sign] = addExpression;\n switch (sign) {\n case '+': {\n return parseFloat(addExpression.substr(1));\n }\n case '-': {\n return -parseFloat(addExpression.substr(1));\n }\n }\n return parseFloat(addExpression);\n}\n\n/*\n* Check if the given value is a calc expression.\n* e.g. 'calc(10 + 100)' -> true\n*/\nexport function isCalcExpression(value) {\n return typeof value === 'string' && value.includes('calc');\n}\n\nconst calcStart = 'calc(';\nconst calcStartOffset = calcStart.length;\n\n/*\n* Evaluate all calc formulas in the given expression.\n* e.g. 'calc(w + 10)' in rect 100x100 -> '110'\n*/\nexport function evalCalcExpression(expression, rect) {\n let value = expression;\n let startSearchIndex = 0;\n do {\n let calcIndex = value.indexOf(calcStart, startSearchIndex);\n if (calcIndex === -1) return value;\n let calcEndIndex = calcIndex + calcStartOffset;\n let brackets = 1;\n findClosingBracket: do {\n switch (value[calcEndIndex]) {\n case '(': {\n brackets++;\n break;\n }\n case ')': {\n brackets--;\n if (brackets === 0) break findClosingBracket;\n break;\n }\n case undefined: {\n // Could not find the closing bracket.\n throwInvalid(value);\n }\n }\n calcEndIndex++;\n } while (true);\n // Get the calc() expression without nested calcs (recursion)\n let expression = value.slice(calcIndex + calcStartOffset, calcEndIndex);\n if (isCalcExpression(expression)) {\n expression = evalCalcExpression(expression, rect);\n }\n // Eval the calc() expression without nested calcs.\n const calcValue = String(evalCalcFormula(expression, rect));\n // Replace the calc() expression and continue search\n value = value.slice(0, calcIndex) + calcValue + value.slice(calcEndIndex + 1);\n startSearchIndex = calcIndex + calcValue.length;\n } while (true);\n}\n","import { assign, isPlainObject, isObject, isPercentage, breakText } from '../../util/util.mjs';\nimport { isCalcExpression, evalCalcExpression } from '../../util/calc.mjs';\nimport $ from '../../mvc/Dom/index.mjs';\nimport V from '../../V/index.mjs';\n\nfunction isTextInUse(_value, _node, attrs) {\n return (attrs.text !== undefined);\n}\n\nconst FONT_ATTRIBUTES = ['font-weight', 'font-family', 'font-size', 'letter-spacing', 'text-transform'];\n\nconst textAttributesNS = {\n\n 'line-height': {\n qualify: isTextInUse\n },\n\n 'text-vertical-anchor': {\n qualify: isTextInUse\n },\n\n 'text-path': {\n qualify: isTextInUse\n },\n\n 'annotations': {\n qualify: isTextInUse\n },\n\n 'eol': {\n qualify: isTextInUse\n },\n\n 'display-empty': {\n qualify: isTextInUse\n },\n\n 'text': {\n qualify: function(_text, _node, attrs) {\n const textWrap = attrs['text-wrap'];\n return !textWrap || !isPlainObject(textWrap);\n },\n unset: function(node) {\n node.textContent = '';\n },\n set: function(text, refBBox, node, attrs) {\n const cacheName = 'joint-text';\n const cache = $.data.get(node, cacheName);\n const lineHeight = attrs['line-height'];\n const textVerticalAnchor = attrs['text-vertical-anchor'];\n const displayEmpty = attrs['display-empty'];\n const fontSize = attrs['font-size'];\n const annotations = attrs.annotations;\n const eol = attrs.eol;\n const x = attrs.x;\n let textPath = attrs['text-path'];\n // Update the text only if there was a change in the string\n // or any of its attributes.\n const textHash = JSON.stringify([text, lineHeight, annotations, textVerticalAnchor, eol, displayEmpty, textPath, x, fontSize]);\n if (cache === undefined || cache !== textHash) {\n // Chrome bug:\n // positions defined as `em` are not updated\n // when container `font-size` change.\n if (fontSize) node.setAttribute('font-size', fontSize);\n // Text Along Path Selector\n if (isObject(textPath)) {\n const pathSelector = textPath.selector;\n if (typeof pathSelector === 'string') {\n const pathNode = this.findNode(pathSelector);\n if (pathNode instanceof SVGPathElement) {\n textPath = assign({ 'xlink:href': '#' + pathNode.id }, textPath);\n }\n }\n }\n V(node).text('' + text, {\n lineHeight,\n annotations,\n textPath,\n x,\n textVerticalAnchor,\n eol,\n displayEmpty\n });\n $.data.set(node, cacheName, textHash);\n }\n }\n },\n\n 'text-wrap': {\n qualify: isPlainObject,\n set: function(value, refBBox, node, attrs) {\n var size = {};\n // option `width`\n var width = value.width || 0;\n if (isPercentage(width)) {\n size.width = refBBox.width * parseFloat(width) / 100;\n } else if (isCalcExpression(width)) {\n size.width = Number(evalCalcExpression(width, refBBox));\n } else {\n if (value.width === null) {\n // breakText() requires width to be specified.\n size.width = Infinity;\n } else if (width <= 0) {\n size.width = refBBox.width + width;\n } else {\n size.width = width;\n }\n }\n // option `height`\n var height = value.height || 0;\n if (isPercentage(height)) {\n size.height = refBBox.height * parseFloat(height) / 100;\n } else if (isCalcExpression(height)) {\n size.height = Number(evalCalcExpression(height, refBBox));\n } else {\n if (value.height === null) {\n // if height is not specified breakText() does not\n // restrict the height of the text.\n } else if (height <= 0) {\n size.height = refBBox.height + height;\n } else {\n size.height = height;\n }\n }\n // option `text`\n var wrappedText;\n var text = value.text;\n if (text === undefined) text = attrs.text;\n if (text !== undefined) {\n\n const breakTextFn = value.breakText || breakText;\n const computedStyles = getComputedStyle(node);\n const wrapFontAttributes = {};\n // The font size attributes must be set on the node\n // to get the correct text wrapping.\n // TODO: set the native SVG attributes before special attributes\n for (let i = 0; i < FONT_ATTRIBUTES.length; i++) {\n const name = FONT_ATTRIBUTES[i];\n if (name in attrs) {\n node.setAttribute(name, attrs[name]);\n }\n // Note: computedStyles is a live object\n // i.e. the properties are evaluated when accessed.\n wrapFontAttributes[name] = computedStyles[name];\n }\n\n // The `line-height` attribute in SVG is JoinJS specific.\n // TODO: change the `lineHeight` to breakText option.\n wrapFontAttributes.lineHeight = attrs['line-height'];\n\n wrappedText = breakTextFn('' + text, size, wrapFontAttributes, {\n // Provide an existing SVG Document here\n // instead of creating a temporary one over again.\n svgDocument: this.paper.svg,\n ellipsis: value.ellipsis,\n hyphen: value.hyphen,\n separator: value.separator,\n maxLineCount: value.maxLineCount,\n preserveSpaces: value.preserveSpaces\n });\n } else {\n wrappedText = '';\n }\n textAttributesNS.text.set.call(this, wrappedText, refBBox, node, attrs);\n },\n // We expose the font attributes list to allow\n // the user to take other custom font attributes into account\n // when wrapping the text.\n FONT_ATTRIBUTES\n },\n\n 'title': {\n qualify: function(title, node) {\n // HTMLElement title is specified via an attribute (i.e. not an element)\n return node instanceof SVGElement;\n },\n unset: function(node) {\n $.data.remove(node, 'joint-title');\n const titleNode = node.firstElementChild;\n if (titleNode) {\n titleNode.remove();\n }\n },\n set: function(title, refBBox, node) {\n var cacheName = 'joint-title';\n var cache = $.data.get(node, cacheName);\n if (cache === undefined || cache !== title) {\n $.data.set(node, cacheName, title);\n if (node.tagName === 'title') {\n // The target node is a element.\n node.textContent = title;\n return;\n }\n // Generally <title> element should be the first child element of its parent.\n var firstChild = node.firstElementChild;\n if (firstChild && firstChild.tagName === 'title') {\n // Update an existing title\n firstChild.textContent = title;\n } else {\n // Create a new title\n var titleNode = document.createElementNS(node.namespaceURI, 'title');\n titleNode.textContent = title;\n node.insertBefore(titleNode, firstChild);\n }\n }\n }\n },\n};\n\nexport default textAttributesNS;\n","import { Point } from '../../g/index.mjs';\n\nfunction atConnectionWrapper(method, opt) {\n var zeroVector = new Point(1, 0);\n return function(value) {\n var p, angle;\n var tangent = this[method](value);\n if (tangent) {\n angle = (opt.rotate) ? tangent.vector().vectorAngle(zeroVector) : 0;\n p = tangent.start;\n } else {\n p = this.path.start;\n angle = 0;\n }\n if (angle === 0) return { transform: 'translate(' + p.x + ',' + p.y + ')' };\n return { transform: 'translate(' + p.x + ',' + p.y + ') rotate(' + angle + ')' };\n };\n}\n\nfunction isLinkView() {\n return this.model.isLink();\n}\n\nconst connectionAttributesNS = {\n\n 'connection': {\n qualify: isLinkView,\n unset: 'd',\n set: function({ stubs = 0 }) {\n let d;\n if (isFinite(stubs) && stubs !== 0) {\n let offset;\n if (stubs < 0) {\n offset = (this.getConnectionLength() + stubs) / 2;\n } else {\n offset = stubs;\n }\n const path = this.getConnection();\n const segmentSubdivisions = this.getConnectionSubdivisions();\n const sourceParts = path.divideAtLength(offset, { segmentSubdivisions });\n const targetParts = path.divideAtLength(-offset, { segmentSubdivisions });\n if (sourceParts && targetParts) {\n d = `${sourceParts[0].serialize()} ${targetParts[1].serialize()}`;\n }\n }\n\n return { d: d || this.getSerializedConnection() };\n }\n },\n\n 'at-connection-length-keep-gradient': {\n qualify: isLinkView,\n unset: 'transform',\n set: atConnectionWrapper('getTangentAtLength', { rotate: true })\n },\n\n 'at-connection-length-ignore-gradient': {\n qualify: isLinkView,\n unset: 'transform',\n set: atConnectionWrapper('getTangentAtLength', { rotate: false })\n },\n\n 'at-connection-ratio-keep-gradient': {\n qualify: isLinkView,\n unset: 'transform',\n set: atConnectionWrapper('getTangentAtRatio', { rotate: true })\n },\n\n 'at-connection-ratio-ignore-gradient': {\n qualify: isLinkView,\n unset: 'transform',\n set: atConnectionWrapper('getTangentAtRatio', { rotate: false })\n }\n\n};\n\nconnectionAttributesNS['at-connection-length'] = connectionAttributesNS['at-connection-length-keep-gradient'];\nconnectionAttributesNS['at-connection-ratio'] = connectionAttributesNS['at-connection-ratio-keep-gradient'];\n\nexport default connectionAttributesNS;\n","import { Path, Polyline } from '../../g/index.mjs';\nimport $ from '../../mvc/Dom/index.mjs';\nimport V from '../../V/index.mjs';\n\nfunction shapeWrapper(shapeConstructor, opt) {\n var cacheName = 'joint-shape';\n var resetOffset = opt && opt.resetOffset;\n return function(value, refBBox, node) {\n var cache = $.data.get(node, cacheName);\n if (!cache || cache.value !== value) {\n // only recalculate if value has changed\n var cachedShape = shapeConstructor(value);\n cache = {\n value: value,\n shape: cachedShape,\n shapeBBox: cachedShape.bbox()\n };\n $.data.set(node, cacheName, cache);\n }\n\n var shape = cache.shape.clone();\n var shapeBBox = cache.shapeBBox.clone();\n var shapeOrigin = shapeBBox.origin();\n var refOrigin = refBBox.origin();\n\n shapeBBox.x = refOrigin.x;\n shapeBBox.y = refOrigin.y;\n\n var fitScale = refBBox.maxRectScaleToFit(shapeBBox, refOrigin);\n // `maxRectScaleToFit` can give Infinity if width or height is 0\n var sx = (shapeBBox.width === 0 || refBBox.width === 0) ? 1 : fitScale.sx;\n var sy = (shapeBBox.height === 0 || refBBox.height === 0) ? 1 : fitScale.sy;\n\n shape.scale(sx, sy, shapeOrigin);\n if (resetOffset) {\n shape.translate(-shapeOrigin.x, -shapeOrigin.y);\n }\n\n return shape;\n };\n}\n\n// `d` attribute for SVGPaths\nfunction dWrapper(opt) {\n function pathConstructor(value) {\n return new Path(V.normalizePathData(value));\n }\n\n var shape = shapeWrapper(pathConstructor, opt);\n return function(value, refBBox, node) {\n var path = shape(value, refBBox, node);\n return {\n d: path.serialize()\n };\n };\n}\n\n// `points` attribute for SVGPolylines and SVGPolygons\nfunction pointsWrapper(opt) {\n var shape = shapeWrapper(Polyline, opt);\n return function(value, refBBox, node) {\n var polyline = shape(value, refBBox, node);\n return {\n points: polyline.serialize()\n };\n };\n}\n\nconst shapeAttributesNS = {\n\n 'ref-d-reset-offset': {\n unset: 'd',\n set: dWrapper({ resetOffset: true })\n },\n\n 'ref-d-keep-offset': {\n unset: 'd',\n set: dWrapper({ resetOffset: false })\n },\n\n 'ref-points-reset-offset': {\n unset: 'points',\n set: pointsWrapper({ resetOffset: true })\n },\n\n 'ref-points-keep-offset': {\n unset: 'points',\n set: pointsWrapper({ resetOffset: false })\n },\n};\n\n// Aliases\nshapeAttributesNS['ref-d'] = shapeAttributesNS['ref-d-reset-offset'];\nshapeAttributesNS['ref-points'] = shapeAttributesNS['ref-points-reset-offset'];\n\nexport default shapeAttributesNS;\n","import { assign, isPlainObject } from '../../util/util.mjs';\n\nfunction contextMarker(context) {\n var marker = {};\n // Stroke\n // The context 'fill' is disregarded here. The usual case is to use the marker with a connection\n // (for which 'fill' attribute is set to 'none').\n var stroke = context.stroke;\n if (typeof stroke === 'string') {\n marker['stroke'] = stroke;\n marker['fill'] = stroke;\n }\n // Opacity\n // Again the context 'fill-opacity' is ignored.\n var strokeOpacity = context['stroke-opacity'];\n if (strokeOpacity === undefined) strokeOpacity = context.opacity;\n if (strokeOpacity !== undefined) {\n marker['stroke-opacity'] = strokeOpacity;\n marker['fill-opacity'] = strokeOpacity;\n }\n return marker;\n}\n\nfunction setPaintURL(def) {\n const { paper } = this;\n const url = (def.type === 'pattern')\n ? paper.definePattern(def)\n : paper.defineGradient(def);\n return `url(#${url})`;\n}\n\nconst defsAttributesNS = {\n\n 'source-marker': {\n qualify: isPlainObject,\n unset: 'marker-start',\n set: function(marker, refBBox, node, attrs) {\n marker = assign(contextMarker(attrs), marker);\n return { 'marker-start': 'url(#' + this.paper.defineMarker(marker) + ')' };\n }\n },\n\n 'target-marker': {\n qualify: isPlainObject,\n unset: 'marker-end',\n set: function(marker, refBBox, node, attrs) {\n marker = assign(contextMarker(attrs), { 'transform': 'rotate(180)' }, marker);\n return { 'marker-end': 'url(#' + this.paper.defineMarker(marker) + ')' };\n }\n },\n\n 'vertex-marker': {\n qualify: isPlainObject,\n unset: 'marker-mid',\n set: function(marker, refBBox, node, attrs) {\n marker = assign(contextMarker(attrs), marker);\n return { 'marker-mid': 'url(#' + this.paper.defineMarker(marker) + ')' };\n }\n },\n\n 'fill': {\n qualify: isPlainObject,\n set: setPaintURL\n },\n\n 'stroke': {\n qualify: isPlainObject,\n set: setPaintURL\n },\n\n 'filter': {\n qualify: isPlainObject,\n set: function(filter) {\n return 'url(#' + this.paper.defineFilter(filter) + ')';\n }\n },\n};\n\nexport default defsAttributesNS;\n","\n// Offset attributes require the cell view to be rendered before they can be applied\n// (they must be appended to the DOM).\n\nimport { Point } from '../../g/index.mjs';\nimport { isPercentage } from '../../util/util.mjs';\n\nfunction offsetWrapper(axis, dimension, corner) {\n return function(value, nodeBBox) {\n var delta;\n if (value === 'middle') {\n delta = nodeBBox[dimension] / 2;\n } else if (value === corner) {\n delta = nodeBBox[dimension];\n } else if (isFinite(value)) {\n // TODO: or not to do a breaking change?\n delta = (value > -1 && value < 1) ? (-nodeBBox[dimension] * value) : -value;\n } else if (isPercentage(value)) {\n delta = nodeBBox[dimension] * parseFloat(value) / 100;\n } else {\n delta = 0;\n }\n\n var point = new Point();\n point[axis] = -(nodeBBox[axis] + delta);\n return point;\n };\n}\n\nconst offsetAttributesNS = {\n\n // `x-alignment` when set to `middle` causes centering of the sub-element around its new x coordinate.\n // `x-alignment` when set to `right` uses the x coordinate as referenced to the right of the bbox.\n 'x-alignment': {\n offset: offsetWrapper('x', 'width', 'right')\n },\n\n // `y-alignment` when set to `middle` causes centering of the sub-element around its new y coordinate.\n // `y-alignment` when set to `bottom` uses the y coordinate as referenced to the bottom of the bbox.\n 'y-alignment': {\n offset: offsetWrapper('y', 'height', 'bottom')\n },\n\n 'reset-offset': {\n offset: function(val, nodeBBox) {\n return (val)\n ? { x: -nodeBBox.x, y: -nodeBBox.y }\n : { x: 0, y: 0 };\n }\n },\n};\n\nexport default offsetAttributesNS;\n","import { assign, isPlainObject } from '../../util/util.mjs';\nimport $ from '../../mvc/Dom/index.mjs';\nimport V from '../../V/index.mjs';\n\nimport props from './props.mjs';\nimport legacyAttributesNS from './legacy.mjs';\nimport textAttributesNS from './text.mjs';\nimport connectionAttributesNS from './connection.mjs';\nimport shapeAttributesNS from './shape.mjs';\nimport defsAttributesNS from './defs.mjs';\nimport offsetAttributesNS from './offset.mjs';\n\nfunction setIfChangedWrapper(attribute) {\n return function setIfChanged(value, _, node) {\n const vel = V(node);\n if (vel.attr(attribute) === value) return;\n vel.attr(attribute, value);\n };\n}\n\nconst attributesNS = {\n\n 'ref': {\n // We do not set `ref` attribute directly on an element.\n // The attribute itself does not qualify for relative positioning.\n },\n\n 'href': {\n set: setIfChangedWrapper('href')\n },\n\n 'xlink:href': {\n set: setIfChangedWrapper('xlink:href')\n },\n\n // `port` attribute contains the `id` of the port that the underlying magnet represents.\n 'port': {\n set: function(port) {\n return (port === null || port.id === undefined) ? port : port.id;\n }\n },\n\n // `style` attribute is special in the sense that it sets the CSS style of the sub-element.\n 'style': {\n qualify: isPlainObject,\n set: function(styles, refBBox, node) {\n $(node).css(styles);\n }\n },\n\n 'html': {\n unset: function(node) {\n $(node).empty();\n },\n set: function(html, refBBox, node) {\n $(node).html(html + '');\n }\n },\n\n // Properties setter (set various properties on the node)\n props,\n};\n\nassign(attributesNS, legacyAttributesNS);\nassign(attributesNS, textAttributesNS);\nassign(attributesNS, connectionAttributesNS);\nassign(attributesNS, shapeAttributesNS);\nassign(attributesNS, defsAttributesNS);\nassign(attributesNS, offsetAttributesNS);\n\nexport const attributes = attributesNS;\n\n","import {\n uniqueId,\n union,\n result,\n merge,\n forIn,\n isObject,\n isEqual,\n isString,\n cloneDeep,\n omit,\n uuid,\n isEmpty,\n assign,\n uniq,\n toArray,\n setByPath,\n unsetByPath,\n getByPath,\n timing,\n interpolate,\n nextFrame,\n without,\n cancelFrame,\n defaultsDeep,\n has,\n sortBy,\n defaults,\n objectDifference\n} from '../util/util.mjs';\nimport { Model } from '../mvc/Model.mjs';\nimport { cloneCells } from '../util/cloneCells.mjs';\nimport { attributes } from './attributes/index.mjs';\nimport * as g from '../g/index.mjs';\n\n\n// Cell base model.\n// --------------------------\n\nconst attributesMerger = function(a, b) {\n if (Array.isArray(a)) {\n return b;\n }\n};\n\nfunction removeEmptyAttributes(obj) {\n\n // Remove toplevel empty attributes\n for (const key in obj) {\n\n const objValue = obj[key];\n const isRealObject = isObject(objValue) && !Array.isArray(objValue);\n\n if (!isRealObject) continue;\n\n if (isEmpty(objValue)) {\n delete obj[key];\n }\n }\n}\n\nexport const Cell = Model.extend({\n\n // This is the same as mvc.Model with the only difference that is uses util.merge\n // instead of just _.extend. The reason is that we want to mixin attributes set in upper classes.\n constructor: function(attributes, options) {\n\n var defaults;\n var attrs = attributes || {};\n if (typeof this.preinitialize === 'function') {\n // Check to support an older version\n this.preinitialize.apply(this, arguments);\n }\n this.cid = uniqueId('c');\n this.attributes = {};\n if (options && options.collection) this.collection = options.collection;\n if (options && options.parse) attrs = this.parse(attrs, options) || {};\n if ((defaults = result(this, 'defaults'))) {\n //<custom code>\n // Replaced the call to _.defaults with util.merge.\n const customizer = (options && options.mergeArrays === true) ? false : attributesMerger;\n attrs = merge({}, defaults, attrs, customizer);\n //</custom code>\n }\n this.set(attrs, options);\n this.changed = {};\n this.initialize.apply(this, arguments);\n },\n\n translate: function(dx, dy, opt) {\n\n throw new Error('Must define a translate() method.');\n },\n\n toJSON: function(opt) {\n\n const { ignoreDefaults, ignoreEmptyAttributes = false } = opt || {};\n const defaults = result(this.constructor.prototype, 'defaults');\n\n if (ignoreDefaults === false) {\n // Return all attributes without omitting the defaults\n const finalAttributes = cloneDeep(this.attributes);\n\n if (!ignoreEmptyAttributes) return finalAttributes;\n\n removeEmptyAttributes(finalAttributes);\n\n return finalAttributes;\n }\n\n let defaultAttributes = {};\n let attributes = cloneDeep(this.attributes);\n\n if (ignoreDefaults === true) {\n // Compare all attributes with the defaults\n defaultAttributes = defaults;\n } else {\n // Compare only the specified attributes with the defaults, use `attrs` as a default if not specified\n const differentiateKeys = Array.isArray(ignoreDefaults) ? ignoreDefaults : ['attrs'];\n\n differentiateKeys.forEach((key) => {\n defaultAttributes[key] = defaults[key] || {};\n });\n }\n\n // Omit `id` and `type` attribute from the defaults since it should be always present\n const finalAttributes = objectDifference(attributes, omit(defaultAttributes, 'id', 'type'), { maxDepth: 4 });\n\n if (ignoreEmptyAttributes) {\n removeEmptyAttributes(finalAttributes);\n }\n\n return finalAttributes;\n },\n\n initialize: function(options) {\n\n const idAttribute = this.getIdAttribute();\n if (!options || options[idAttribute] === undefined) {\n this.set(idAttribute, this.generateId(), { silent: true });\n }\n\n this._transitionIds = {};\n this._scheduledTransitionIds = {};\n\n // Collect ports defined in `attrs` and keep collecting whenever `attrs` object changes.\n this.processPorts();\n this.on('change:attrs', this.processPorts, this);\n },\n\n getIdAttribute: function() {\n return this.idAttribute || 'id';\n },\n\n generateId: function() {\n return uuid();\n },\n\n /**\n * @deprecated\n */\n processPorts: function() {\n\n // Whenever `attrs` changes, we extract ports from the `attrs` object and store it\n // in a more accessible way. Also, if any port got removed and there were links that had `target`/`source`\n // set to that port, we remove those links as well (to follow the same behaviour as\n // with a removed element).\n\n var previousPorts = this.ports;\n\n // Collect ports from the `attrs` object.\n var ports = {};\n forIn(this.get('attrs'), function(attrs, selector) {\n\n if (attrs && attrs.port) {\n\n // `port` can either be directly an `id` or an object containing an `id` (and potentially other data).\n if (attrs.port.id !== undefined) {\n ports[attrs.port.id] = attrs.port;\n } else {\n ports[attrs.port] = { id: attrs.port };\n }\n }\n });\n\n // Collect ports that have been removed (compared to the previous ports) - if any.\n // Use hash table for quick lookup.\n var removedPorts = {};\n forIn(previousPorts, function(port, id) {\n\n if (!ports[id]) removedPorts[id] = true;\n });\n\n // Remove all the incoming/outgoing links that have source/target port set to any of the removed ports.\n if (this.graph && !isEmpty(removedPorts)) {\n\n var inboundLinks = this.graph.getConnectedLinks(this, { inbound: true });\n inboundLinks.forEach(function(link) {\n\n if (removedPorts[link.get('target').port]) link.remove();\n });\n\n var outboundLinks = this.graph.getConnectedLinks(this, { outbound: true });\n outboundLinks.forEach(function(link) {\n\n if (removedPorts[link.get('source').port]) link.remove();\n });\n }\n\n // Update the `ports` object.\n this.ports = ports;\n },\n\n remove: function(opt = {}) {\n\n // Store the graph in a variable because `this.graph` won't be accessible\n // after `this.trigger('remove', ...)` down below.\n const { graph, collection } = this;\n if (!graph) {\n // The collection is a common mvc collection (not the graph collection).\n if (collection) collection.remove(this, opt);\n return this;\n }\n\n graph.startBatch('remove');\n\n // First, unembed this cell from its parent cell if there is one.\n const parentCell = this.getParentCell();\n if (parentCell) {\n parentCell.unembed(this, opt);\n }\n\n // Remove also all the cells, which were embedded into this cell\n const embeddedCells = this.getEmbeddedCells();\n for (let i = 0, n = embeddedCells.length; i < n; i++) {\n const embed = embeddedCells[i];\n if (embed) {\n embed.remove(opt);\n }\n }\n\n this.trigger('remove', this, graph.attributes.cells, opt);\n\n graph.stopBatch('remove');\n\n return this;\n },\n\n toFront: function(opt) {\n var graph = this.graph;\n if (graph) {\n opt = defaults(opt || {}, { foregroundEmbeds: true });\n\n let cells;\n if (opt.deep) {\n cells = this.getEmbeddedCells({ deep: true, breadthFirst: opt.breadthFirst !== false, sortSiblings: opt.foregroundEmbeds });\n cells.unshift(this);\n } else {\n cells = [this];\n }\n\n const sortedCells = opt.foregroundEmbeds ? cells : sortBy(cells, cell => cell.z());\n\n const maxZ = graph.maxZIndex();\n let z = maxZ - cells.length + 1;\n\n const collection = graph.get('cells');\n\n let shouldUpdate = (collection.toArray().indexOf(sortedCells[0]) !== (collection.length - cells.length));\n if (!shouldUpdate) {\n shouldUpdate = sortedCells.some(function(cell, index) {\n return cell.z() !== z + index;\n });\n }\n\n if (shouldUpdate) {\n this.startBatch('to-front');\n\n z = z + cells.length;\n\n sortedCells.forEach(function(cell, index) {\n cell.set('z', z + index, opt);\n });\n\n this.stopBatch('to-front');\n }\n }\n\n return this;\n },\n\n toBack: function(opt) {\n var graph = this.graph;\n if (graph) {\n opt = defaults(opt || {}, { foregroundEmbeds: true });\n\n let cells;\n if (opt.deep) {\n cells = this.getEmbeddedCells({ deep: true, breadthFirst: opt.breadthFirst !== false, sortSiblings: opt.foregroundEmbeds });\n cells.unshift(this);\n } else {\n cells = [this];\n }\n\n const sortedCells = opt.foregroundEmbeds ? cells : sortBy(cells, cell => cell.z());\n\n let z = graph.minZIndex();\n\n var collection = graph.get('cells');\n\n let shouldUpdate = (collection.toArray().indexOf(sortedCells[0]) !== 0);\n if (!shouldUpdate) {\n shouldUpdate = sortedCells.some(function(cell, index) {\n return cell.z() !== z + index;\n });\n }\n\n if (shouldUpdate) {\n this.startBatch('to-back');\n\n z -= cells.length;\n\n sortedCells.forEach(function(cell, index) {\n cell.set('z', z + index, opt);\n });\n\n this.stopBatch('to-back');\n }\n }\n\n return this;\n },\n\n parent: function(parent, opt) {\n\n // getter\n if (parent === undefined) return this.get('parent');\n // setter\n return this.set('parent', parent, opt);\n },\n\n embed: function(cell, opt = {}) {\n const cells = Array.isArray(cell) ? cell : [cell];\n if (!this.canEmbed(cells)) {\n throw new Error('Recursive embedding not allowed.');\n }\n if (opt.reparent) {\n const parents = uniq(cells.map(c => c.getParentCell()));\n\n // Unembed cells from their current parents.\n parents.forEach((parent) => {\n // Cell doesn't have to be embedded.\n if (!parent) return;\n\n // Pass all the `cells` since the `dia.Cell._unembedCells` method can handle cases\n // where not all elements of `cells` are embedded in the same parent.\n parent._unembedCells(cells, opt);\n });\n\n } else if (cells.some(c => c.isEmbedded() && this.id !== c.parent())) {\n throw new Error('Embedding of already embedded cells is not allowed.');\n }\n this._embedCells(cells, opt);\n return this;\n },\n\n unembed: function(cell, opt) {\n const cells = Array.isArray(cell) ? cell : [cell];\n this._unembedCells(cells, opt);\n return this;\n },\n\n canEmbed: function(cell) {\n const cells = Array.isArray(cell) ? cell : [cell];\n return cells.every(c => this !== c && !this.isEmbeddedIn(c));\n },\n\n _embedCells: function(cells, opt) {\n const batchName = 'embed';\n this.startBatch(batchName);\n const embeds = assign([], this.get('embeds'));\n cells.forEach(cell => {\n // We keep all element ids after link ids.\n embeds[cell.isLink() ? 'unshift' : 'push'](cell.id);\n cell.parent(this.id, opt);\n });\n this.set('embeds', uniq(embeds), opt);\n this.stopBatch(batchName);\n },\n\n _unembedCells: function(cells, opt) {\n const batchName = 'unembed';\n this.startBatch(batchName);\n cells.forEach(cell => cell.unset('parent', opt));\n this.set('embeds', without(this.get('embeds'), ...cells.map(cell => cell.id)), opt);\n this.stopBatch(batchName);\n },\n\n getParentCell: function() {\n\n // unlike link.source/target, cell.parent stores id directly as a string\n var parentId = this.parent();\n var graph = this.graph;\n\n return (parentId && graph && graph.getCell(parentId)) || null;\n },\n\n // Return an array of ancestor cells.\n // The array is ordered from the parent of the cell\n // to the most distant ancestor.\n getAncestors: function() {\n\n var ancestors = [];\n\n if (!this.graph) {\n return ancestors;\n }\n\n var parentCell = this.getParentCell();\n while (parentCell) {\n ancestors.push(parentCell);\n parentCell = parentCell.getParentCell();\n }\n\n return ancestors;\n },\n\n getEmbeddedCells: function(opt) {\n\n opt = opt || {};\n\n // Cell models can only be retrieved when this element is part of a collection.\n // There is no way this element knows about other cells otherwise.\n // This also means that calling e.g. `translate()` on an element with embeds before\n // adding it to a graph does not translate its embeds.\n if (!this.graph) {\n return [];\n }\n\n if (opt.deep) {\n if (opt.breadthFirst) {\n return this._getEmbeddedCellsBfs(opt.sortSiblings);\n } else {\n return this._getEmbeddedCellsDfs(opt.sortSiblings);\n }\n }\n\n const embeddedIds = this.get('embeds');\n if (isEmpty(embeddedIds)) {\n return [];\n }\n\n let cells = embeddedIds.map(this.graph.getCell, this.graph);\n if (opt.sortSiblings) {\n cells = sortBy(cells, cell => cell.z());\n }\n\n return cells;\n },\n\n _getEmbeddedCellsBfs: function(sortSiblings) {\n const cells = [];\n\n const queue = [];\n queue.push(this);\n\n while (queue.length > 0) {\n const current = queue.shift();\n cells.push(current);\n\n const embeddedCells = current.getEmbeddedCells({ sortSiblings: sortSiblings });\n\n queue.push(...embeddedCells);\n }\n cells.shift();\n\n return cells;\n },\n\n _getEmbeddedCellsDfs: function(sortSiblings) {\n const cells = [];\n\n const stack = [];\n stack.push(this);\n\n while (stack.length > 0) {\n const current = stack.pop();\n cells.push(current);\n\n const embeddedCells = current.getEmbeddedCells({ sortSiblings: sortSiblings });\n\n // When using the stack, cells that are embedded last are processed first.\n // To maintain the original order, we need to push the cells in reverse order\n for (let i = embeddedCells.length - 1; i >= 0; --i) {\n stack.push(embeddedCells[i]);\n }\n }\n cells.shift();\n\n return cells;\n },\n\n isEmbeddedIn: function(cell, opt) {\n\n var cellId = isString(cell) ? cell : cell.id;\n var parentId = this.parent();\n\n opt = assign({ deep: true }, opt);\n\n // See getEmbeddedCells().\n if (this.graph && opt.deep) {\n\n while (parentId) {\n if (parentId === cellId) {\n return true;\n }\n parentId = this.graph.getCell(parentId).parent();\n }\n\n return false;\n\n } else {\n\n // When this cell is not part of a collection check\n // at least whether it's a direct child of given cell.\n return parentId === cellId;\n }\n },\n\n // Whether or not the cell is embedded in any other cell.\n isEmbedded: function() {\n\n return !!this.parent();\n },\n\n // Isolated cloning. Isolated cloning has two versions: shallow and deep (pass `{ deep: true }` in `opt`).\n // Shallow cloning simply clones the cell and returns a new cell with different ID.\n // Deep cloning clones the cell and all its embedded cells recursively.\n clone: function(opt) {\n\n opt = opt || {};\n\n if (!opt.deep) {\n // Shallow cloning.\n\n var clone = Model.prototype.clone.apply(this, arguments);\n // We don't want the clone to have the same ID as the original.\n clone.set(this.getIdAttribute(), this.generateId());\n // A shallow cloned element does not carry over the original embeds.\n clone.unset('embeds');\n // And can not be embedded in any cell\n // as the clone is not part of the graph.\n clone.unset('parent');\n\n return clone;\n\n } else {\n // Deep cloning.\n\n // For a deep clone, simply call `graph.cloneCells()` with the cell and all its embedded cells.\n return toArray(cloneCells([this].concat(this.getEmbeddedCells({ deep: true }))));\n }\n },\n\n // A convenient way to set nested properties.\n // This method merges the properties you'd like to set with the ones\n // stored in the cell and makes sure change events are properly triggered.\n // You can either set a nested property with one object\n // or use a property path.\n // The most simple use case is:\n // `cell.prop('name/first', 'John')` or\n // `cell.prop({ name: { first: 'John' } })`.\n // Nested arrays are supported too:\n // `cell.prop('series/0/data/0/degree', 50)` or\n // `cell.prop({ series: [ { data: [ { degree: 50 } ] } ] })`.\n prop: function(props, value, opt) {\n\n var delim = '/';\n var _isString = isString(props);\n\n if (_isString || Array.isArray(props)) {\n // Get/set an attribute by a special path syntax that delimits\n // nested objects by the colon character.\n\n if (arguments.length > 1) {\n\n var path;\n var pathArray;\n\n if (_isString) {\n path = props;\n pathArray = path.split('/');\n } else {\n path = props.join(delim);\n pathArray = props.slice();\n }\n\n var property = pathArray[0];\n var pathArrayLength = pathArray.length;\n\n const options = opt || {};\n options.propertyPath = path;\n options.propertyValue = value;\n options.propertyPathArray = pathArray;\n if (!('rewrite' in options)) {\n options.rewrite = false;\n }\n\n var update = {};\n // Initialize the nested object. Sub-objects are either arrays or objects.\n // An empty array is created if the sub-key is an integer. Otherwise, an empty object is created.\n // Note that this imposes a limitation on object keys one can use with Inspector.\n // Pure integer keys will cause issues and are therefore not allowed.\n var initializer = update;\n var prevProperty = property;\n\n for (var i = 1; i < pathArrayLength; i++) {\n var pathItem = pathArray[i];\n var isArrayIndex = Number.isFinite(_isString ? Number(pathItem) : pathItem);\n initializer = initializer[prevProperty] = isArrayIndex ? [] : {};\n prevProperty = pathItem;\n }\n\n // Fill update with the `value` on `path`.\n update = setByPath(update, pathArray, value, '/');\n\n var baseAttributes = merge({}, this.attributes);\n // if rewrite mode enabled, we replace value referenced by path with\n // the new one (we don't merge).\n options.rewrite && unsetByPath(baseAttributes, path, '/');\n\n // Merge update with the model attributes.\n var attributes = merge(baseAttributes, update);\n // Finally, set the property to the updated attributes.\n return this.set(property, attributes[property], options);\n\n } else {\n\n return getByPath(this.attributes, props, delim);\n }\n }\n\n const options = value || {};\n // Note: '' is not the path to the root. It's a path with an empty string i.e. { '': {}}.\n options.propertyPath = null;\n options.propertyValue = props;\n options.propertyPathArray = [];\n if (!('rewrite' in options)) {\n options.rewrite = false;\n }\n\n // Create a new object containing only the changed attributes.\n const changedAttributes = {};\n for (const key in props) {\n // Merging the values of changed attributes with the current ones.\n const { changedValue } = merge({}, { changedValue: this.attributes[key] }, { changedValue: props[key] });\n changedAttributes[key] = changedValue;\n }\n\n return this.set(changedAttributes, options);\n },\n\n // A convenient way to unset nested properties\n removeProp: function(path, opt) {\n\n opt = opt || {};\n\n var pathArray = Array.isArray(path) ? path : path.split('/');\n\n // Once a property is removed from the `attrs` attribute\n // the cellView will recognize a `dirty` flag and re-render itself\n // in order to remove the attribute from SVG element.\n var property = pathArray[0];\n if (property === 'attrs') opt.dirty = true;\n\n if (pathArray.length === 1) {\n // A top level property\n return this.unset(path, opt);\n }\n\n // A nested property\n var nestedPath = pathArray.slice(1);\n var propertyValue = this.get(property);\n if (propertyValue === undefined || propertyValue === null) return this;\n propertyValue = cloneDeep(propertyValue);\n\n unsetByPath(propertyValue, nestedPath, '/');\n\n return this.set(property, propertyValue, opt);\n },\n\n // A convenient way to set nested attributes.\n attr: function(attrs, value, opt) {\n\n var args = Array.from(arguments);\n if (args.length === 0) {\n return this.get('attrs');\n }\n\n if (Array.isArray(attrs)) {\n args[0] = ['attrs'].concat(attrs);\n } else if (isString(attrs)) {\n // Get/set an attribute by a special path syntax that delimits\n // nested objects by the colon character.\n args[0] = 'attrs/' + attrs;\n\n } else {\n\n args[0] = { 'attrs' : attrs };\n }\n\n return this.prop.apply(this, args);\n },\n\n // A convenient way to unset nested attributes\n removeAttr: function(path, opt) {\n\n if (Array.isArray(path)) {\n\n return this.removeProp(['attrs'].concat(path));\n }\n\n return this.removeProp('attrs/' + path, opt);\n },\n\n transition: function(path, value, opt, delim) {\n\n delim = delim || '/';\n\n var defaults = {\n duration: 100,\n delay: 10,\n timingFunction: timing.linear,\n valueFunction: interpolate.number\n };\n\n opt = assign(defaults, opt);\n\n var firstFrameTime = 0;\n var interpolatingFunction;\n\n var setter = function(runtime) {\n\n var id, progress, propertyValue;\n\n firstFrameTime = firstFrameTime || runtime;\n runtime -= firstFrameTime;\n progress = runtime / opt.duration;\n\n if (progress < 1) {\n this._transitionIds[path] = id = nextFrame(setter);\n } else {\n progress = 1;\n delete this._transitionIds[path];\n }\n\n propertyValue = interpolatingFunction(opt.timingFunction(progress));\n\n opt.transitionId = id;\n\n this.prop(path, propertyValue, opt);\n\n if (!id) this.trigger('transition:end', this, path);\n\n }.bind(this);\n\n const { _scheduledTransitionIds } = this;\n let initialId;\n\n var initiator = (callback) => {\n\n if (_scheduledTransitionIds[path]) {\n _scheduledTransitionIds[path] = without(_scheduledTransitionIds[path], initialId);\n if (_scheduledTransitionIds[path].length === 0) {\n delete _scheduledTransitionIds[path];\n }\n }\n\n this.stopPendingTransitions(path, delim);\n\n interpolatingFunction = opt.valueFunction(getByPath(this.attributes, path, delim), value);\n\n this._transitionIds[path] = nextFrame(callback);\n\n this.trigger('transition:start', this, path);\n\n };\n\n initialId = setTimeout(initiator, opt.delay, setter);\n\n _scheduledTransitionIds[path] || (_scheduledTransitionIds[path] = []);\n _scheduledTransitionIds[path].push(initialId);\n\n return initialId;\n },\n\n getTransitions: function() {\n return union(\n Object.keys(this._transitionIds),\n Object.keys(this._scheduledTransitionIds)\n );\n },\n\n stopScheduledTransitions: function(path, delim = '/') {\n const { _scheduledTransitionIds = {}} = this;\n let transitions = Object.keys(_scheduledTransitionIds);\n if (path) {\n const pathArray = path.split(delim);\n transitions = transitions.filter((key) => {\n return isEqual(pathArray, key.split(delim).slice(0, pathArray.length));\n });\n }\n transitions.forEach((key) => {\n const transitionIds = _scheduledTransitionIds[key];\n // stop the initiator\n transitionIds.forEach(transitionId => clearTimeout(transitionId));\n delete _scheduledTransitionIds[key];\n // Note: we could trigger transition:cancel` event here\n });\n return this;\n },\n\n stopPendingTransitions(path, delim = '/') {\n const { _transitionIds = {}} = this;\n let transitions = Object.keys(_transitionIds);\n if (path) {\n const pathArray = path.split(delim);\n transitions = transitions.filter((key) => {\n return isEqual(pathArray, key.split(delim).slice(0, pathArray.length));\n });\n }\n transitions.forEach((key) => {\n const transitionId = _transitionIds[key];\n // stop the setter\n cancelFrame(transitionId);\n delete _transitionIds[key];\n this.trigger('transition:end', this, key);\n });\n },\n\n stopTransitions: function(path, delim = '/') {\n this.stopScheduledTransitions(path, delim);\n this.stopPendingTransitions(path, delim);\n return this;\n },\n\n // A shorcut making it easy to create constructs like the following:\n // `var el = (new joint.shapes.standard.Rectangle()).addTo(graph)`.\n addTo: function(graph, opt) {\n\n graph.addCell(this, opt);\n return this;\n },\n\n // A shortcut for an equivalent call: `paper.findViewByModel(cell)`\n // making it easy to create constructs like the following:\n // `cell.findView(paper).highlight()`\n findView: function(paper) {\n\n return paper.findViewByModel(this);\n },\n\n isElement: function() {\n\n return false;\n },\n\n isLink: function() {\n\n return false;\n },\n\n startBatch: function(name, opt) {\n\n if (this.graph) { this.graph.startBatch(name, assign({}, opt, { cell: this })); }\n return this;\n },\n\n stopBatch: function(name, opt) {\n\n if (this.graph) { this.graph.stopBatch(name, assign({}, opt, { cell: this })); }\n return this;\n },\n\n getChangeFlag: function(attributes) {\n\n var flag = 0;\n if (!attributes) return flag;\n for (var key in attributes) {\n if (!attributes.hasOwnProperty(key) || !this.hasChanged(key)) continue;\n flag |= attributes[key];\n }\n return flag;\n },\n\n angle: function() {\n\n // To be overridden.\n return 0;\n },\n\n position: function() {\n\n // To be overridden.\n return new g.Point(0, 0);\n },\n\n z: function() {\n return this.get('z') || 0;\n },\n\n getPointFromConnectedLink: function() {\n\n // To be overridden\n return new g.Point();\n },\n\n getBBox: function() {\n\n // To be overridden\n return new g.Rect(0, 0, 0, 0);\n },\n\n getPointRotatedAroundCenter(angle, x, y) {\n const point = new g.Point(x, y);\n if (angle) point.rotate(this.getBBox().center(), angle);\n return point;\n },\n\n getAbsolutePointFromRelative(x, y) {\n // Rotate the position to take the model angle into account\n return this.getPointRotatedAroundCenter(\n -this.angle(),\n // Transform the relative position to absolute\n this.position().offset(x, y)\n );\n },\n\n getRelativePointFromAbsolute(x, y) {\n return this\n // Rotate the coordinates to mitigate the element's rotation.\n .getPointRotatedAroundCenter(this.angle(), x, y)\n // Transform the absolute position into relative\n .difference(this.position());\n }\n\n}, {\n\n getAttributeDefinition: function(attrName) {\n\n var defNS = this.attributes;\n var globalDefNS = attributes;\n return (defNS && defNS[attrName]) || globalDefNS[attrName];\n },\n\n define: function(type, defaults, protoProps, staticProps) {\n\n protoProps = assign({\n defaults: defaultsDeep({ type: type }, defaults, this.prototype.defaults)\n }, protoProps);\n\n var Cell = this.extend(protoProps, staticProps);\n // es5 backward compatibility\n /* eslint-disable no-undef */\n if (typeof joint !== 'undefined' && has(joint, 'shapes')) {\n setByPath(joint.shapes, type, Cell, '.');\n }\n /* eslint-enable no-undef */\n return Cell;\n }\n});\n\n","import * as g from '../../g/index.mjs';\nimport * as util from '../../util/index.mjs';\n\nfunction portTransformAttrs(point, angle, opt) {\n\n var trans = point.toJSON();\n\n trans.angle = angle || 0;\n\n return util.defaults({}, opt, trans);\n}\n\nfunction lineLayout(ports, p1, p2, elBBox) {\n return ports.map(function(port, index, ports) {\n var p = this.pointAt(((index + 0.5) / ports.length));\n // `dx`,`dy` per port offset option\n if (port.dx || port.dy) {\n p.offset(port.dx || 0, port.dy || 0);\n }\n return portTransformAttrs(p.round(), 0, argTransform(elBBox, port));\n }, g.line(p1, p2));\n}\n\nfunction ellipseLayout(ports, elBBox, startAngle, stepFn) {\n\n var center = elBBox.center();\n var ratio = elBBox.width / elBBox.height;\n var p1 = elBBox.topMiddle();\n\n var ellipse = g.Ellipse.fromRect(elBBox);\n\n return ports.map(function(port, index, ports) {\n\n var angle = startAngle + stepFn(index, ports.length);\n var p2 = p1.clone()\n .rotate(center, -angle)\n .scale(ratio, 1, center);\n\n var theta = port.compensateRotation ? -ellipse.tangentTheta(p2) : 0;\n\n // `dx`,`dy` per port offset option\n if (port.dx || port.dy) {\n p2.offset(port.dx || 0, port.dy || 0);\n }\n\n // `dr` delta radius option\n if (port.dr) {\n p2.move(center, port.dr);\n }\n\n return portTransformAttrs(p2.round(), theta, argTransform(elBBox, port));\n });\n}\n\n\nfunction argTransform(bbox, args) {\n let { x, y, angle } = args;\n if (util.isPercentage(x)) {\n x = parseFloat(x) / 100 * bbox.width;\n } else if (util.isCalcExpression(x)) {\n x = Number(util.evalCalcExpression(x, bbox));\n }\n if (util.isPercentage(y)) {\n y = parseFloat(y) / 100 * bbox.height;\n } else if (util.isCalcExpression(y)) {\n y = Number(util.evalCalcExpression(y, bbox));\n }\n return { x, y, angle };\n}\n\n// Creates a point stored in arguments\nfunction argPoint(bbox, args) {\n const { x, y } = argTransform(bbox, args);\n return new g.Point(x || 0, y || 0);\n}\n\n\n/**\n * @param {Array<Object>} ports\n * @param {g.Rect} elBBox\n * @param {Object=} opt opt Group options\n * @returns {Array<g.Point>}\n */\nexport const absolute = function(ports, elBBox) {\n return ports.map(port => {\n const transformation = argPoint(elBBox, port).round().toJSON();\n transformation.angle = port.angle || 0;\n return transformation;\n });\n};\n\n/**\n * @param {Array<Object>} ports\n * @param {g.Rect} elBBox\n * @param {Object=} opt opt Group options\n * @returns {Array<g.Point>}\n */\nexport const fn = function(ports, elBBox, opt) {\n return opt.fn(ports, elBBox, opt);\n};\n\n/**\n * @param {Array<Object>} ports\n * @param {g.Rect} elBBox\n * @param {Object=} opt opt Group options\n * @returns {Array<g.Point>}\n */\nexport const line = function(ports, elBBox, opt) {\n\n var start = argPoint(elBBox, opt.start || elBBox.origin());\n var end = argPoint(elBBox, opt.end || elBBox.corner());\n\n return lineLayout(ports, start, end, elBBox);\n};\n\n/**\n * @param {Array<Object>} ports\n * @param {g.Rect} elBBox\n * @param {Object=} opt opt Group options\n * @returns {Array<g.Point>}\n */\nexport const left = function(ports, elBBox, opt) {\n return lineLayout(ports, elBBox.origin(), elBBox.bottomLeft(), elBBox);\n};\n\n/**\n * @param {Array<Object>} ports\n * @param {g.Rect} elBBox\n * @param {Object=} opt opt Group options\n * @returns {Array<g.Point>}\n */\nexport const right = function(ports, elBBox, opt) {\n return lineLayout(ports, elBBox.topRight(), elBBox.corner(), elBBox);\n};\n\n/**\n * @param {Array<Object>} ports\n * @param {g.Rect} elBBox\n * @param {Object=} opt opt Group options\n * @returns {Array<g.Point>}\n */\nexport const top = function(ports, elBBox, opt) {\n return lineLayout(ports, elBBox.origin(), elBBox.topRight(), elBBox);\n};\n\n/**\n * @param {Array<Object>} ports\n * @param {g.Rect} elBBox\n * @param {Object=} opt opt Group options\n * @returns {Array<g.Point>}\n */\nexport const bottom = function(ports, elBBox, opt) {\n return lineLayout(ports, elBBox.bottomLeft(), elBBox.corner(), elBBox);\n};\n\n/**\n * @param {Array<Object>} ports\n * @param {g.Rect} elBBox\n * @param {Object=} opt Group options\n * @returns {Array<g.Point>}\n */\nexport const ellipseSpread = function(ports, elBBox, opt) {\n\n var startAngle = opt.startAngle || 0;\n var stepAngle = opt.step || 360 / ports.length;\n\n return ellipseLayout(ports, elBBox, startAngle, function(index) {\n return index * stepAngle;\n });\n};\n\n/**\n * @param {Array<Object>} ports\n * @param {g.Rect} elBBox\n * @param {Object=} opt Group options\n * @returns {Array<g.Point>}\n */\nexport const ellipse = function(ports, elBBox, opt) {\n\n var startAngle = opt.startAngle || 0;\n var stepAngle = opt.step || 20;\n\n return ellipseLayout(ports, elBBox, startAngle, function(index, count) {\n return (index + 0.5 - count / 2) * stepAngle;\n });\n};\n\n","import * as g from '../../g/index.mjs';\nimport * as util from '../../util/index.mjs';\n\nfunction labelAttributes(opt1, opt2) {\n\n // use value from `opt2` if it is missing in `opt1`\n // use value from this object if it is missing in `opt2` as well\n return util.defaultsDeep({}, opt1, opt2, {\n x: 0,\n y: 0,\n angle: 0,\n attrs: {}\n });\n}\n\nfunction getBBoxAngles(elBBox) {\n\n var center = elBBox.center();\n\n var tl = center.theta(elBBox.origin());\n var bl = center.theta(elBBox.bottomLeft());\n var br = center.theta(elBBox.corner());\n var tr = center.theta(elBBox.topRight());\n\n return [tl, tr, br, bl];\n}\n\nfunction outsideLayout(portPosition, elBBox, autoOrient, opt) {\n\n opt = util.defaults({}, opt, { offset: 15 });\n var angle = elBBox.center().theta(portPosition);\n\n var tx, ty, y, textAnchor;\n var offset = opt.offset;\n var orientAngle = 0;\n\n const [topLeftAngle, bottomLeftAngle, bottomRightAngle, topRightAngle] = getBBoxAngles(elBBox);\n if ((angle < bottomLeftAngle) || (angle > bottomRightAngle)) {\n y = '.3em';\n tx = offset;\n ty = 0;\n textAnchor = 'start';\n } else if (angle < topLeftAngle) {\n tx = 0;\n ty = -offset;\n if (autoOrient) {\n orientAngle = -90;\n textAnchor = 'start';\n y = '.3em';\n } else {\n textAnchor = 'middle';\n y = '0';\n }\n } else if (angle < topRightAngle) {\n y = '.3em';\n tx = -offset;\n ty = 0;\n textAnchor = 'end';\n } else {\n tx = 0;\n ty = offset;\n if (autoOrient) {\n orientAngle = 90;\n textAnchor = 'start';\n y = '.3em';\n } else {\n textAnchor = 'middle';\n y = '.6em';\n }\n }\n\n var round = Math.round;\n return labelAttributes(opt, {\n x: round(tx),\n y: round(ty),\n angle: orientAngle,\n attrs: { labelText: { y, textAnchor }}\n });\n}\n\nfunction insideLayout(portPosition, elBBox, autoOrient, opt) {\n\n opt = util.defaults({}, opt, { offset: 15 });\n var angle = elBBox.center().theta(portPosition);\n\n var tx, ty, y, textAnchor;\n var offset = opt.offset;\n var orientAngle = 0;\n\n const [topLeftAngle, bottomLeftAngle, bottomRightAngle, topRightAngle] = getBBoxAngles(elBBox);\n if ((angle < bottomLeftAngle) || (angle > bottomRightAngle)) {\n y = '.3em';\n tx = -offset;\n ty = 0;\n textAnchor = 'end';\n } else if (angle < topLeftAngle) {\n tx = 0;\n ty = offset;\n if (autoOrient) {\n orientAngle = 90;\n textAnchor = 'start';\n y = '.3em';\n } else {\n textAnchor = 'middle';\n y = '.6em';\n }\n } else if (angle < topRightAngle) {\n y = '.3em';\n tx = offset;\n ty = 0;\n textAnchor = 'start';\n } else {\n tx = 0;\n ty = -offset;\n if (autoOrient) {\n orientAngle = -90;\n textAnchor = 'start';\n y = '.3em';\n } else {\n textAnchor = 'middle';\n y = '0';\n }\n }\n\n var round = Math.round;\n return labelAttributes(opt, {\n x: round(tx),\n y: round(ty),\n angle: orientAngle,\n attrs: { labelText: { y, textAnchor }}\n });\n}\n\nfunction radialLayout(portCenterOffset, autoOrient, opt) {\n\n opt = util.defaults({}, opt, { offset: 20 });\n\n var origin = g.point(0, 0);\n var angle = -portCenterOffset.theta(origin);\n var orientAngle = angle;\n var offset = portCenterOffset.clone()\n .move(origin, opt.offset)\n .difference(portCenterOffset)\n .round();\n\n var y = '.3em';\n var textAnchor;\n\n if ((angle + 90) % 180 === 0) {\n textAnchor = autoOrient ? 'end' : 'middle';\n if (!autoOrient && angle === -270) {\n y = '0em';\n }\n } else if (angle > -270 && angle < -90) {\n textAnchor = 'start';\n orientAngle = angle - 180;\n } else {\n textAnchor = 'end';\n }\n\n var round = Math.round;\n return labelAttributes(opt, {\n x: round(offset.x),\n y: round(offset.y),\n angle: ((autoOrient) ? orientAngle : 0),\n attrs: { labelText: { y, textAnchor }}\n });\n}\n\nexport const manual = function(_portPosition, _elBBox, opt) {\n return labelAttributes(opt);\n};\n\nexport const left = function(portPosition, elBBox, opt) {\n return labelAttributes(opt, {\n x: -15,\n attrs: { labelText: { y: '.3em', textAnchor: 'end' }},\n });\n};\n\nexport const right = function(portPosition, elBBox, opt) {\n return labelAttributes(opt, {\n x: 15,\n attrs: { labelText: { y: '.3em', textAnchor: 'start' }},\n });\n};\n\nexport const top = function(portPosition, elBBox, opt) {\n return labelAttributes(opt, {\n y: -15,\n attrs: { labelText: { y: '0', textAnchor: 'middle' }},\n });\n};\n\nexport const bottom = function(portPosition, elBBox, opt) {\n return labelAttributes(opt, {\n y: 15,\n attrs: { labelText: { y: '.6em', textAnchor: 'middle' }},\n });\n};\n\nexport const outsideOriented = function(portPosition, elBBox, opt) {\n return outsideLayout(portPosition, elBBox, true, opt);\n};\n\nexport const outside = function(portPosition, elBBox, opt) {\n return outsideLayout(portPosition, elBBox, false, opt);\n};\n\nexport const insideOriented = function(portPosition, elBBox, opt) {\n return insideLayout(portPosition, elBBox, true, opt);\n};\n\nexport const inside = function(portPosition, elBBox, opt) {\n return insideLayout(portPosition, elBBox, false, opt);\n};\n\nexport const radial = function(portPosition, elBBox, opt) {\n return radialLayout(portPosition.difference(elBBox.center()), false, opt);\n};\n\nexport const radialOriented = function(portPosition, elBBox, opt) {\n return radialLayout(portPosition.difference(elBBox.center()), true, opt);\n};\n","import * as util from '../util/index.mjs';\nimport V from '../V/index.mjs';\nimport { Rect, Point } from '../g/index.mjs';\nimport * as Port from '../layout/ports/port.mjs';\nimport * as PortLabel from '../layout/ports/portLabel.mjs';\n\nvar PortData = function(data) {\n\n var clonedData = util.cloneDeep(data) || {};\n this.ports = [];\n this.groups = {};\n this.portLayoutNamespace = Port;\n this.portLabelLayoutNamespace = PortLabel;\n\n this._init(clonedData);\n};\n\nPortData.prototype = {\n\n getPorts: function() {\n return this.ports;\n },\n\n getGroup: function(name) {\n return this.groups[name] || {};\n },\n\n getPortsByGroup: function(groupName) {\n\n return this.ports.filter(function(port) {\n return port.group === groupName;\n });\n },\n\n getGroupPortsMetrics: function(groupName, elBBox) {\n\n var group = this.getGroup(groupName);\n var ports = this.getPortsByGroup(groupName);\n\n var groupPosition = group.position || {};\n var groupPositionName = groupPosition.name;\n var namespace = this.portLayoutNamespace;\n if (!namespace[groupPositionName]) {\n groupPositionName = 'left';\n }\n\n var groupArgs = groupPosition.args || {};\n var portsArgs = ports.map(function(port) {\n return port && port.position && port.position.args;\n });\n var groupPortTransformations = namespace[groupPositionName](portsArgs, elBBox, groupArgs);\n\n var accumulator = {\n ports: ports,\n result: []\n };\n\n util.toArray(groupPortTransformations).reduce(function(res, portTransformation, index) {\n var port = res.ports[index];\n res.result.push({\n portId: port.id,\n portTransformation: portTransformation,\n labelTransformation: this._getPortLabelLayout(port, Point(portTransformation), elBBox),\n portAttrs: port.attrs,\n portSize: port.size,\n labelSize: port.label.size\n });\n return res;\n }.bind(this), accumulator);\n\n return accumulator.result;\n },\n\n _getPortLabelLayout: function(port, portPosition, elBBox) {\n\n var namespace = this.portLabelLayoutNamespace;\n var labelPosition = port.label.position.name || 'left';\n\n if (namespace[labelPosition]) {\n return namespace[labelPosition](portPosition, elBBox, port.label.position.args);\n }\n\n return null;\n },\n\n _init: function(data) {\n\n // prepare groups\n if (util.isObject(data.groups)) {\n var groups = Object.keys(data.groups);\n for (var i = 0, n = groups.length; i < n; i++) {\n var key = groups[i];\n this.groups[key] = this._evaluateGroup(data.groups[key]);\n }\n }\n\n // prepare ports\n var ports = util.toArray(data.items);\n for (var j = 0, m = ports.length; j < m; j++) {\n this.ports.push(this._evaluatePort(ports[j]));\n }\n },\n\n _evaluateGroup: function(group) {\n\n return util.merge(group, {\n position: this._getPosition(group.position, true),\n label: this._getLabel(group, true)\n });\n },\n\n _evaluatePort: function(port) {\n\n var evaluated = util.assign({}, port);\n\n var group = this.getGroup(port.group);\n\n evaluated.markup = evaluated.markup || group.markup;\n evaluated.attrs = util.merge({}, group.attrs, evaluated.attrs);\n evaluated.position = this._createPositionNode(group, evaluated);\n evaluated.label = util.merge({}, group.label, this._getLabel(evaluated));\n evaluated.z = this._getZIndex(group, evaluated);\n evaluated.size = util.assign({}, group.size, evaluated.size);\n\n return evaluated;\n },\n\n _getZIndex: function(group, port) {\n\n if (util.isNumber(port.z)) {\n return port.z;\n }\n if (util.isNumber(group.z) || group.z === 'auto') {\n return group.z;\n }\n return 'auto';\n },\n\n _createPositionNode: function(group, port) {\n\n return util.merge({\n name: 'left',\n args: {}\n }, group.position, { args: port.args });\n },\n\n _getPosition: function(position, setDefault) {\n\n var args = {};\n var positionName;\n\n if (util.isFunction(position)) {\n positionName = 'fn';\n args.fn = position;\n } else if (util.isString(position)) {\n positionName = position;\n } else if (position === undefined) {\n positionName = setDefault ? 'left' : null;\n } else if (Array.isArray(position)) {\n positionName = 'absolute';\n args.x = position[0];\n args.y = position[1];\n } else if (util.isObject(position)) {\n positionName = position.name;\n util.assign(args, position.args);\n }\n\n var result = { args: args };\n\n if (positionName) {\n result.name = positionName;\n }\n return result;\n },\n\n _getLabel: function(item, setDefaults) {\n\n var label = item.label || {};\n\n var ret = label;\n ret.position = this._getPosition(label.position, setDefaults);\n\n return ret;\n }\n};\n\nexport const elementPortPrototype = {\n\n _initializePorts: function() {\n\n this._createPortData();\n this.on('change:ports', function() {\n\n this._processRemovedPort();\n this._createPortData();\n }, this);\n },\n\n /**\n * remove links tied wiht just removed element\n * @private\n */\n _processRemovedPort: function() {\n\n var current = this.get('ports') || {};\n var currentItemsMap = {};\n\n util.toArray(current.items).forEach(function(item) {\n currentItemsMap[item.id] = true;\n });\n\n var previous = this.previous('ports') || {};\n var removed = {};\n\n util.toArray(previous.items).forEach(function(item) {\n if (!currentItemsMap[item.id]) {\n removed[item.id] = true;\n }\n });\n\n var graph = this.graph;\n if (graph && !util.isEmpty(removed)) {\n\n var inboundLinks = graph.getConnectedLinks(this, { inbound: true });\n inboundLinks.forEach(function(link) {\n\n if (removed[link.get('target').port]) link.remove();\n });\n\n var outboundLinks = graph.getConnectedLinks(this, { outbound: true });\n outboundLinks.forEach(function(link) {\n\n if (removed[link.get('source').port]) link.remove();\n });\n }\n },\n\n /**\n * @returns {boolean}\n */\n hasPorts: function() {\n\n var ports = this.prop('ports/items');\n return Array.isArray(ports) && ports.length > 0;\n },\n\n /**\n * @param {string} id\n * @returns {boolean}\n */\n hasPort: function(id) {\n\n return this.getPortIndex(id) !== -1;\n },\n\n /**\n * @returns {Array<object>}\n */\n getPorts: function() {\n\n return util.cloneDeep(this.prop('ports/items')) || [];\n },\n\n /**\n * @returns {Array<object>}\n */\n getGroupPorts: function(groupName) {\n const groupPorts = util.toArray(this.prop(['ports','items'])).filter(port => port.group === groupName);\n return util.cloneDeep(groupPorts);\n },\n\n /**\n * @param {string} id\n * @returns {object}\n */\n getPort: function(id) {\n\n return util.cloneDeep(util.toArray(this.prop('ports/items')).find(function(port) {\n return port.id && port.id === id;\n }));\n },\n\n getPortGroupNames: function() {\n return Object.keys(this._portSettingsData.groups);\n },\n\n /**\n * @param {string} groupName\n * @returns {Object<portId, {x: number, y: number, angle: number}>}\n */\n getPortsPositions: function(groupName) {\n\n var portsMetrics = this._portSettingsData.getGroupPortsMetrics(groupName, Rect(this.size()));\n\n return portsMetrics.reduce(function(positions, metrics) {\n var transformation = metrics.portTransformation;\n positions[metrics.portId] = {\n x: transformation.x,\n y: transformation.y,\n angle: transformation.angle\n };\n return positions;\n }, {});\n },\n\n /**\n * @param {string|Port} port port id or port\n * @returns {number} port index\n */\n getPortIndex: function(port) {\n\n var id = util.isObject(port) ? port.id : port;\n\n if (!this._isValidPortId(id)) {\n return -1;\n }\n\n return util.toArray(this.prop('ports/items')).findIndex(function(item) {\n return item.id === id;\n });\n },\n\n /**\n * @param {object} port\n * @param {object} [opt]\n * @returns {joint.dia.Element}\n */\n addPort: function(port, opt) {\n\n if (!util.isObject(port) || Array.isArray(port)) {\n throw new Error('Element: addPort requires an object.');\n }\n\n var ports = util.assign([], this.prop('ports/items'));\n ports.push(port);\n this.prop('ports/items', ports, opt);\n\n return this;\n },\n\n /**\n * @param {string|Port|number} before\n * @param {object} port\n * @param {object} [opt]\n * @returns {joint.dia.Element}\n */\n insertPort: function(before, port, opt) {\n const index = (typeof before === 'number') ? before : this.getPortIndex(before);\n\n if (!util.isObject(port) || Array.isArray(port)) {\n throw new Error('dia.Element: insertPort requires an object.');\n }\n\n const ports = util.assign([], this.prop('ports/items'));\n ports.splice(index, 0, port);\n this.prop('ports/items', ports, opt);\n\n return this;\n },\n\n /**\n * @param {string} portId\n * @param {string|object=} path\n * @param {*=} value\n * @param {object=} opt\n * @returns {joint.dia.Element}\n */\n portProp: function(portId, path, value, opt) {\n\n var index = this.getPortIndex(portId);\n\n if (index === -1) {\n throw new Error('Element: unable to find port with id ' + portId);\n }\n\n var args = Array.prototype.slice.call(arguments, 1);\n if (Array.isArray(path)) {\n args[0] = ['ports', 'items', index].concat(path);\n } else if (util.isString(path)) {\n\n // Get/set an attribute by a special path syntax that delimits\n // nested objects by the colon character.\n args[0] = ['ports/items/', index, '/', path].join('');\n\n } else {\n\n args = ['ports/items/' + index];\n if (util.isPlainObject(path)) {\n args.push(path);\n args.push(value);\n }\n }\n\n return this.prop.apply(this, args);\n },\n\n _validatePorts: function() {\n\n var portsAttr = this.get('ports') || {};\n\n var errorMessages = [];\n portsAttr = portsAttr || {};\n var ports = util.toArray(portsAttr.items);\n\n ports.forEach(function(p) {\n\n if (typeof p !== 'object') {\n errorMessages.push('Element: invalid port ', p);\n }\n\n if (!this._isValidPortId(p.id)) {\n p.id = this.generatePortId();\n }\n }, this);\n\n if (util.uniq(ports, 'id').length !== ports.length) {\n errorMessages.push('Element: found id duplicities in ports.');\n }\n\n return errorMessages;\n },\n\n generatePortId: function() {\n return this.generateId();\n },\n\n /**\n * @param {string} id port id\n * @returns {boolean}\n * @private\n */\n _isValidPortId: function(id) {\n\n return id !== null && id !== undefined && !util.isObject(id);\n },\n\n addPorts: function(ports, opt) {\n\n if (ports.length) {\n this.prop('ports/items', util.assign([], this.prop('ports/items')).concat(ports), opt);\n }\n\n return this;\n },\n\n removePort: function(port, opt) {\n const options = opt || {};\n const index = this.getPortIndex(port);\n if (index !== -1) {\n const ports = util.assign([], this.prop(['ports', 'items']));\n ports.splice(index, 1);\n options.rewrite = true;\n this.startBatch('port-remove');\n this.prop(['ports', 'items'], ports, options);\n this.stopBatch('port-remove');\n }\n return this;\n },\n\n removePorts: function(portsForRemoval, opt) {\n let options, newPorts;\n if (Array.isArray(portsForRemoval)) {\n options = opt || {};\n if (portsForRemoval.length === 0) return this.this;\n const currentPorts = util.assign([], this.prop(['ports', 'items']));\n newPorts = currentPorts.filter(function(cp) {\n return !portsForRemoval.some(function(rp) {\n const rpId = util.isObject(rp) ? rp.id : rp;\n return cp.id === rpId;\n });\n });\n } else {\n options = portsForRemoval || {};\n newPorts = [];\n }\n this.startBatch('port-remove');\n options.rewrite = true;\n this.prop(['ports', 'items'], newPorts, options);\n this.stopBatch('port-remove');\n return this;\n },\n\n /**\n * @private\n */\n _createPortData: function() {\n\n var err = this._validatePorts();\n\n if (err.length > 0) {\n this.set('ports', this.previous('ports'));\n throw new Error(err.join(' '));\n }\n\n var prevPortData;\n\n if (this._portSettingsData) {\n\n prevPortData = this._portSettingsData.getPorts();\n }\n\n this._portSettingsData = new PortData(this.get('ports'));\n\n var curPortData = this._portSettingsData.getPorts();\n\n if (prevPortData) {\n\n var added = curPortData.filter(function(item) {\n if (!prevPortData.find(function(prevPort) {\n return prevPort.id === item.id;\n })) {\n return item;\n }\n });\n\n var removed = prevPortData.filter(function(item) {\n if (!curPortData.find(function(curPort) {\n return curPort.id === item.id;\n })) {\n return item;\n }\n });\n\n if (removed.length > 0) {\n this.trigger('ports:remove', this, removed);\n }\n\n if (added.length > 0) {\n this.trigger('ports:add', this, added);\n }\n }\n }\n};\n\nexport const elementViewPortPrototype = {\n\n portContainerMarkup: 'g',\n portMarkup: [{\n tagName: 'circle',\n selector: 'circle',\n attributes: {\n 'r': 10,\n 'fill': '#FFFFFF',\n 'stroke': '#000000'\n }\n }],\n portLabelMarkup: [{\n tagName: 'text',\n selector: 'text',\n attributes: {\n 'fill': '#000000'\n }\n }],\n /** @type {Object<string, {portElement: Vectorizer, portLabelElement: Vectorizer}>} */\n _portElementsCache: null,\n\n /**\n * @private\n */\n _initializePorts: function() {\n this._cleanPortsCache();\n },\n\n /**\n * @typedef {Object} Port\n *\n * @property {string} id\n * @property {Object} position\n * @property {Object} label\n * @property {Object} attrs\n * @property {string} markup\n * @property {string} group\n */\n\n /**\n * @private\n */\n _refreshPorts: function() {\n\n this._removePorts();\n this._cleanPortsCache();\n this._renderPorts();\n },\n\n _cleanPortsCache: function() {\n this._portElementsCache = {};\n },\n\n /**\n * @private\n */\n _renderPorts: function() {\n\n // references to rendered elements without z-index\n var elementReferences = [];\n var elem = this._getContainerElement();\n\n for (var i = 0, count = elem.node.childNodes.length; i < count; i++) {\n elementReferences.push(elem.node.childNodes[i]);\n }\n\n var portsGropsByZ = util.groupBy(this.model._portSettingsData.getPorts(), 'z');\n var withoutZKey = 'auto';\n\n // render non-z first\n util.toArray(portsGropsByZ[withoutZKey]).forEach(function(port) {\n var portElement = this._getPortElement(port);\n elem.append(portElement);\n elementReferences.push(portElement);\n }, this);\n\n var groupNames = Object.keys(portsGropsByZ);\n for (var k = 0; k < groupNames.length; k++) {\n var groupName = groupNames[k];\n if (groupName !== withoutZKey) {\n var z = parseInt(groupName, 10);\n this._appendPorts(portsGropsByZ[groupName], z, elementReferences);\n }\n }\n\n this._updatePorts();\n },\n\n /**\n * @returns {V}\n * @private\n */\n _getContainerElement: function() {\n\n return this.rotatableNode || this.vel;\n },\n\n /**\n * @param {Array<Port>}ports\n * @param {number} z\n * @param refs\n * @private\n */\n _appendPorts: function(ports, z, refs) {\n\n var containerElement = this._getContainerElement();\n var portElements = util.toArray(ports).map(this._getPortElement, this);\n\n if (refs[z] || z < 0) {\n V(refs[Math.max(z, 0)]).before(portElements);\n } else {\n containerElement.append(portElements);\n }\n },\n\n /**\n * Try to get element from cache,\n * @param port\n * @returns {*}\n * @private\n */\n _getPortElement: function(port) {\n\n if (this._portElementsCache[port.id]) {\n return this._portElementsCache[port.id].portElement;\n }\n return this._createPortElement(port);\n },\n\n findPortNodes: function(portId, selector) {\n const portCache = this._portElementsCache[portId];\n if (!portCache) return [];\n if (!selector) return [portCache.portContentElement.node];\n const portRoot = portCache.portElement.node;\n const portSelectors = portCache.portSelectors;\n return this.findBySelector(selector, portRoot, portSelectors);\n },\n\n findPortNode: function(portId, selector) {\n const [node = null] = this.findPortNodes(portId, selector);\n return node;\n },\n\n /**\n * @private\n */\n _updatePorts: function() {\n\n // layout ports without group\n this._updatePortGroup(undefined);\n // layout ports with explicit group\n var groupsNames = Object.keys(this.model._portSettingsData.groups);\n groupsNames.forEach(this._updatePortGroup, this);\n },\n\n /**\n * @private\n */\n _removePorts: function() {\n util.invoke(this._portElementsCache, 'portElement.remove');\n },\n\n /**\n * @param {Port} port\n * @returns {V}\n * @private\n */\n _createPortElement: function(port) {\n\n let portElement;\n let labelElement;\n let labelSelectors;\n let portSelectors;\n\n var portContainerElement = V(this.portContainerMarkup).addClass('joint-port');\n\n var portMarkup = this._getPortMarkup(port);\n if (Array.isArray(portMarkup)) {\n var portDoc = this.parseDOMJSON(portMarkup, portContainerElement.node);\n var portFragment = portDoc.fragment;\n if (portFragment.childNodes.length > 1) {\n portElement = V('g').append(portFragment);\n } else {\n portElement = V(portFragment.firstChild);\n }\n portSelectors = portDoc.selectors;\n } else {\n portElement = V(portMarkup);\n if (Array.isArray(portElement)) {\n portElement = V('g').append(portElement);\n }\n }\n\n if (!portElement) {\n throw new Error('ElementView: Invalid port markup.');\n }\n\n portElement.attr({\n 'port': port.id,\n 'port-group': port.group\n });\n\n // If the port ID is a number, we need to add\n // extra information to the port element to distinguish\n // between ports with the same ID but different types.\n if (util.isNumber(port.id)) {\n portElement.attr('port-id-type', 'number');\n }\n\n const labelMarkupDef = this._getPortLabelMarkup(port.label);\n if (Array.isArray(labelMarkupDef)) {\n // JSON Markup\n const { fragment, selectors } = this.parseDOMJSON(labelMarkupDef, portContainerElement.node);\n const childCount = fragment.childNodes.length;\n if (childCount > 0) {\n labelSelectors = selectors;\n labelElement = (childCount === 1) ? V(fragment.firstChild) : V('g').append(fragment);\n }\n } else {\n // String Markup\n labelElement = V(labelMarkupDef);\n if (Array.isArray(labelElement)) {\n labelElement = V('g').append(labelElement);\n }\n }\n\n var portContainerSelectors;\n if (portSelectors && labelSelectors) {\n for (var key in labelSelectors) {\n if (portSelectors[key] && key !== this.selector) throw new Error('ElementView: selectors within port must be unique.');\n }\n portContainerSelectors = util.assign({}, portSelectors, labelSelectors);\n } else {\n portContainerSelectors = portSelectors || labelSelectors || {};\n }\n\n // The `portRootSelector` points to the root SVGNode of the port.\n // Either the implicit wrapping group <g/> in case the port consist of multiple SVGNodes.\n // Or the single SVGNode of the port.\n const portRootSelector = 'portRoot';\n // The `labelRootSelector` points to the root SVGNode of the label.\n const labelRootSelector = 'labelRoot';\n // The `labelTextSelector` points to all text SVGNodes of the label.\n const labelTextSelector = 'labelText';\n\n if (!(portRootSelector in portContainerSelectors)) {\n portContainerSelectors[portRootSelector] = portElement.node;\n }\n\n if (labelElement) {\n const labelNode = labelElement.node;\n if (!(labelRootSelector in portContainerSelectors)) {\n portContainerSelectors[labelRootSelector] = labelNode;\n }\n if (!(labelTextSelector in portContainerSelectors)) {\n // If the label is a <text> element, we can use it directly.\n // Otherwise, we need to find the <text> element within the label.\n const labelTextNode = (labelElement.tagName() === 'TEXT')\n ? labelNode\n : Array.from(labelNode.querySelectorAll('text'));\n portContainerSelectors[labelTextSelector] = labelTextNode;\n if (!labelSelectors) labelSelectors = {};\n labelSelectors[labelTextSelector] = labelTextNode;\n }\n }\n\n portContainerElement.append(portElement.addClass('joint-port-body'));\n if (labelElement) {\n portContainerElement.append(labelElement.addClass('joint-port-label'));\n }\n\n this._portElementsCache[port.id] = {\n portElement: portContainerElement,\n portLabelElement: labelElement,\n portSelectors: portContainerSelectors,\n portLabelSelectors: labelSelectors,\n portContentElement: portElement,\n portContentSelectors: portSelectors\n };\n\n return portContainerElement;\n },\n\n /**\n * @param {string=} groupName\n * @private\n */\n _updatePortGroup: function(groupName) {\n\n var elementBBox = Rect(this.model.size());\n var portsMetrics = this.model._portSettingsData.getGroupPortsMetrics(groupName, elementBBox);\n\n for (var i = 0, n = portsMetrics.length; i < n; i++) {\n var metrics = portsMetrics[i];\n var portId = metrics.portId;\n var cached = this._portElementsCache[portId] || {};\n var portTransformation = metrics.portTransformation;\n var labelTransformation = metrics.labelTransformation;\n if (labelTransformation && cached.portLabelElement) {\n this.updateDOMSubtreeAttributes(cached.portLabelElement.node, labelTransformation.attrs, {\n rootBBox: new Rect(metrics.labelSize),\n selectors: cached.portLabelSelectors\n });\n this.applyPortTransform(cached.portLabelElement, labelTransformation, (-portTransformation.angle || 0));\n }\n this.updateDOMSubtreeAttributes(cached.portElement.node, metrics.portAttrs, {\n rootBBox: new Rect(metrics.portSize),\n selectors: cached.portSelectors\n });\n this.applyPortTransform(cached.portElement, portTransformation);\n }\n },\n\n /**\n * @param {Vectorizer} element\n * @param {{dx:number, dy:number, angle: number, attrs: Object, x:number: y:number}} transformData\n * @param {number=} initialAngle\n * @constructor\n */\n applyPortTransform: function(element, transformData, initialAngle) {\n\n var matrix = V.createSVGMatrix()\n .rotate(initialAngle || 0)\n .translate(transformData.x || 0, transformData.y || 0)\n .rotate(transformData.angle || 0);\n\n element.transform(matrix, { absolute: true });\n },\n\n /**\n * @param {Port} port\n * @returns {string}\n * @private\n */\n _getPortMarkup: function(port) {\n\n return port.markup || this.model.get('portMarkup') || this.model.portMarkup || this.portMarkup;\n },\n\n /**\n * @param {Object} label\n * @returns {string}\n * @private\n */\n _getPortLabelMarkup: function(label) {\n\n return label.markup || this.model.get('portLabelMarkup') || this.model.portLabelMarkup || this.portLabelMarkup;\n }\n};\n\n","import { Cell } from './Cell.mjs';\nimport { Point, toRad, normalizeAngle, Rect } from '../g/index.mjs';\nimport { isNumber, isObject, interpolate, assign, invoke, normalizeSides } from '../util/index.mjs';\nimport { elementPortPrototype } from './ports.mjs';\n\n// Element base model.\n// -----------------------------\n\nexport const Element = Cell.extend({\n\n defaults: {\n position: { x: 0, y: 0 },\n size: { width: 1, height: 1 },\n angle: 0\n },\n\n initialize: function() {\n\n this._initializePorts();\n Cell.prototype.initialize.apply(this, arguments);\n },\n\n /**\n * @abstract\n */\n _initializePorts: function() {\n // implemented in ports.js\n },\n\n _refreshPorts: function() {\n // implemented in ports.js\n },\n\n isElement: function() {\n\n return true;\n },\n\n position: function(x, y, opt) {\n\n const isSetter = isNumber(y);\n opt = (isSetter ? opt : x) || {};\n const { parentRelative, deep, restrictedArea } = opt;\n\n\n // option `parentRelative` for setting the position relative to the element's parent.\n let parentPosition;\n if (parentRelative) {\n\n // Getting the parent's position requires the collection.\n // Cell.parent() holds cell id only.\n if (!this.graph) throw new Error('Element must be part of a graph.');\n\n const parent = this.getParentCell();\n if (parent && !parent.isLink()) {\n parentPosition = parent.get('position');\n }\n }\n\n if (isSetter) {\n\n if (parentPosition) {\n x += parentPosition.x;\n y += parentPosition.y;\n }\n\n if (deep || restrictedArea) {\n const { x: x0, y: y0 } = this.get('position');\n this.translate(x - x0, y - y0, opt);\n } else {\n this.set('position', { x, y }, opt);\n }\n\n return this;\n\n } else { // Getter returns a geometry point.\n\n const elementPosition = Point(this.get('position'));\n return parentRelative\n ? elementPosition.difference(parentPosition)\n : elementPosition;\n }\n },\n\n translate: function(tx, ty, opt) {\n\n tx = tx || 0;\n ty = ty || 0;\n\n if (tx === 0 && ty === 0) {\n // Like nothing has happened.\n return this;\n }\n\n opt = opt || {};\n // Pass the initiator of the translation.\n opt.translateBy = opt.translateBy || this.id;\n\n var position = this.get('position') || { x: 0, y: 0 };\n var ra = opt.restrictedArea;\n if (ra && opt.translateBy === this.id) {\n\n if (typeof ra === 'function') {\n\n var newPosition = ra.call(this, position.x + tx, position.y + ty, opt);\n\n tx = newPosition.x - position.x;\n ty = newPosition.y - position.y;\n\n } else {\n // We are restricting the translation for the element itself only. We get\n // the bounding box of the element including all its embeds.\n // All embeds have to be translated the exact same way as the element.\n var bbox = this.getBBox({ deep: true });\n //- - - - - - - - - - - - -> ra.x + ra.width\n // - - - -> position.x |\n // -> bbox.x\n // ▓▓▓▓▓▓▓ |\n // ░░░░░░░▓▓▓▓▓▓▓\n // ░░░░░░░░░ |\n // ▓▓▓▓▓▓▓▓░░░░░░░\n // ▓▓▓▓▓▓▓▓ |\n // <-dx-> | restricted area right border\n // <-width-> | ░ translated element\n // <- - bbox.width - -> ▓ embedded element\n var dx = position.x - bbox.x;\n var dy = position.y - bbox.y;\n // Find the maximal/minimal coordinates that the element can be translated\n // while complies the restrictions.\n var x = Math.max(ra.x + dx, Math.min(ra.x + ra.width + dx - bbox.width, position.x + tx));\n var y = Math.max(ra.y + dy, Math.min(ra.y + ra.height + dy - bbox.height, position.y + ty));\n // recalculate the translation taking the restrictions into account.\n tx = x - position.x;\n ty = y - position.y;\n }\n }\n\n var translatedPosition = {\n x: position.x + tx,\n y: position.y + ty\n };\n\n // To find out by how much an element was translated in event 'change:position' handlers.\n opt.tx = tx;\n opt.ty = ty;\n\n if (opt.transition) {\n\n if (!isObject(opt.transition)) opt.transition = {};\n\n this.transition('position', translatedPosition, assign({}, opt.transition, {\n valueFunction: interpolate.object\n }));\n\n // Recursively call `translate()` on all the embeds cells.\n invoke(this.getEmbeddedCells(), 'translate', tx, ty, opt);\n\n } else {\n\n this.startBatch('translate', opt);\n this.set('position', translatedPosition, opt);\n invoke(this.getEmbeddedCells(), 'translate', tx, ty, opt);\n this.stopBatch('translate', opt);\n }\n\n return this;\n },\n\n size: function(width, height, opt) {\n\n var currentSize = this.get('size');\n // Getter\n // () signature\n if (width === undefined) {\n return {\n width: currentSize.width,\n height: currentSize.height\n };\n }\n // Setter\n // (size, opt) signature\n if (isObject(width)) {\n opt = height;\n height = isNumber(width.height) ? width.height : currentSize.height;\n width = isNumber(width.width) ? width.width : currentSize.width;\n }\n\n return this.resize(width, height, opt);\n },\n\n resize: function(width, height, opt) {\n\n opt = opt || {};\n\n this.startBatch('resize', opt);\n\n if (opt.direction) {\n\n var currentSize = this.get('size');\n\n switch (opt.direction) {\n\n case 'left':\n case 'right':\n // Don't change height when resizing horizontally.\n height = currentSize.height;\n break;\n\n case 'top':\n case 'bottom':\n // Don't change width when resizing vertically.\n width = currentSize.width;\n break;\n }\n\n // Get the angle and clamp its value between 0 and 360 degrees.\n var angle = normalizeAngle(this.get('angle') || 0);\n\n // This is a rectangle in size of the un-rotated element.\n var bbox = this.getBBox();\n\n var origin;\n\n if (angle) {\n\n var quadrant = {\n 'top-right': 0,\n 'right': 0,\n 'top-left': 1,\n 'top': 1,\n 'bottom-left': 2,\n 'left': 2,\n 'bottom-right': 3,\n 'bottom': 3\n }[opt.direction];\n\n if (opt.absolute) {\n\n // We are taking the element's rotation into account\n quadrant += Math.floor((angle + 45) / 90);\n quadrant %= 4;\n }\n\n // Pick the corner point on the element, which meant to stay on its place before and\n // after the rotation.\n var fixedPoint = bbox[['bottomLeft', 'corner', 'topRight', 'origin'][quadrant]]();\n\n // Find an image of the previous indent point. This is the position, where is the\n // point actually located on the screen.\n var imageFixedPoint = Point(fixedPoint).rotate(bbox.center(), -angle);\n\n // Every point on the element rotates around a circle with the centre of rotation\n // in the middle of the element while the whole element is being rotated. That means\n // that the distance from a point in the corner of the element (supposed its always rect) to\n // the center of the element doesn't change during the rotation and therefore it equals\n // to a distance on un-rotated element.\n // We can find the distance as DISTANCE = (ELEMENTWIDTH/2)^2 + (ELEMENTHEIGHT/2)^2)^0.5.\n var radius = Math.sqrt((width * width) + (height * height)) / 2;\n\n // Now we are looking for an angle between x-axis and the line starting at image of fixed point\n // and ending at the center of the element. We call this angle `alpha`.\n\n // The image of a fixed point is located in n-th quadrant. For each quadrant passed\n // going anti-clockwise we have to add 90 degrees. Note that the first quadrant has index 0.\n //\n // 3 | 2\n // --c-- Quadrant positions around the element's center `c`\n // 0 | 1\n //\n var alpha = quadrant * Math.PI / 2;\n\n // Add an angle between the beginning of the current quadrant (line parallel with x-axis or y-axis\n // going through the center of the element) and line crossing the indent of the fixed point and the center\n // of the element. This is the angle we need but on the un-rotated element.\n alpha += Math.atan(quadrant % 2 == 0 ? height / width : width / height);\n\n // Lastly we have to deduct the original angle the element was rotated by and that's it.\n alpha -= toRad(angle);\n\n // With this angle and distance we can easily calculate the centre of the un-rotated element.\n // Note that fromPolar constructor accepts an angle in radians.\n var center = Point.fromPolar(radius, alpha, imageFixedPoint);\n\n // The top left corner on the un-rotated element has to be half a width on the left\n // and half a height to the top from the center. This will be the origin of rectangle\n // we were looking for.\n origin = Point(center).offset(width / -2, height / -2);\n\n } else {\n // calculation for the origin Point when there is no rotation of the element\n origin = bbox.topLeft();\n\n switch (opt.direction) {\n case 'top':\n case 'top-right':\n origin.offset(0, bbox.height - height);\n break;\n case 'left':\n case 'bottom-left':\n origin.offset(bbox.width -width, 0);\n break;\n case 'top-left':\n origin.offset(bbox.width - width, bbox.height - height);\n break;\n }\n }\n\n // Resize the element (before re-positioning it).\n this.set('size', { width: width, height: height }, opt);\n\n // Finally, re-position the element.\n this.position(origin.x, origin.y, opt);\n\n } else {\n\n // Resize the element.\n this.set('size', { width: width, height: height }, opt);\n }\n\n this.stopBatch('resize', opt);\n\n return this;\n },\n\n scale: function(sx, sy, origin, opt) {\n\n var scaledBBox = this.getBBox().scale(sx, sy, origin);\n this.startBatch('scale', opt);\n this.position(scaledBBox.x, scaledBBox.y, opt);\n this.resize(scaledBBox.width, scaledBBox.height, opt);\n this.stopBatch('scale');\n return this;\n },\n\n fitEmbeds: function(opt) {\n\n return this.fitToChildren(opt);\n },\n\n fitToChildren: function(opt = {}) {\n\n // Getting the children's size and position requires the collection.\n // Cell.get('embeds') holds an array of cell ids only.\n const { graph } = this;\n if (!graph) throw new Error('Element must be part of a graph.');\n\n const childElements = this.getEmbeddedCells().filter(cell => cell.isElement());\n if (childElements.length === 0) return this;\n\n this.startBatch('fit-embeds', opt);\n\n if (opt.deep) {\n // `opt.deep = true` means \"fit to all descendants\".\n // As the first action of the fitting algorithm, recursively apply `fitToChildren()` on all descendants.\n // - i.e. the algorithm is applied in reverse-depth order - start from deepest descendant, then go up (= this element).\n invoke(childElements, 'fitToChildren', opt);\n }\n\n // Set new size and position of this element, based on:\n // - union of bboxes of all children\n // - inflated by given `opt.padding`\n this._fitToElements(Object.assign({ elements: childElements }, opt));\n\n this.stopBatch('fit-embeds');\n\n return this;\n },\n\n fitParent: function(opt = {}) {\n\n const { graph } = this;\n if (!graph) throw new Error('Element must be part of a graph.');\n\n // When `opt.deep = true`, we want `opt.terminator` to be the last ancestor processed.\n // If the current element is `opt.terminator`, it means that this element has already been processed as parent so we can exit now.\n if (opt.deep && opt.terminator && ((opt.terminator === this) || (opt.terminator === this.id))) return this;\n\n const parentElement = this.getParentCell();\n if (!parentElement || !parentElement.isElement()) return this;\n\n // Get all children of parent element (i.e. this element + any sibling elements).\n const siblingElements = parentElement.getEmbeddedCells().filter(cell => cell.isElement());\n if (siblingElements.length === 0) return this;\n\n this.startBatch('fit-parent', opt);\n\n // Set new size and position of parent element, based on:\n // - union of bboxes of all children of parent element (i.e. this element + any sibling elements)\n // - inflated by given `opt.padding`\n parentElement._fitToElements(Object.assign({ elements: siblingElements }, opt));\n\n if (opt.deep) {\n // `opt.deep = true` means \"fit all ancestors to their respective children\".\n // As the last action of the fitting algorithm, recursively apply `fitParent()` on all ancestors.\n // - i.e. the algorithm is applied in reverse-depth order - start from deepest descendant (= this element), then go up.\n parentElement.fitParent(opt);\n }\n\n this.stopBatch('fit-parent');\n\n return this;\n },\n\n // Assumption: This element is part of a graph.\n _fitToElements: function(opt = {}) {\n\n const elementsBBox = this.graph.getCellsBBox(opt.elements);\n // If no `opt.elements` were provided, do nothing.\n if (!elementsBBox) return;\n\n const { expandOnly, shrinkOnly } = opt;\n // This combination is meaningless, do nothing.\n if (expandOnly && shrinkOnly) return;\n\n // Calculate new size and position of this element based on:\n // - union of bboxes of `opt.elements`\n // - inflated by `opt.padding` (if not provided, all four properties = 0)\n let { x, y, width, height } = elementsBBox;\n const { left, right, top, bottom } = normalizeSides(opt.padding);\n x -= left;\n y -= top;\n width += left + right;\n height += bottom + top;\n let resultBBox = new Rect(x, y, width, height);\n\n if (expandOnly) {\n // Non-shrinking is enforced by taking union of this element's current bbox with bbox calculated from `opt.elements`.\n resultBBox = this.getBBox().union(resultBBox);\n\n } else if (shrinkOnly) {\n // Non-expansion is enforced by taking intersection of this element's current bbox with bbox calculated from `opt.elements`.\n const intersectionBBox = this.getBBox().intersect(resultBBox);\n // If all children are outside this element's current bbox, then `intersectionBBox` is `null` - does not make sense, do nothing.\n if (!intersectionBBox) return;\n\n resultBBox = intersectionBBox;\n }\n\n // Set the new size and position of this element.\n this.set({\n position: { x: resultBBox.x, y: resultBBox.y },\n size: { width: resultBBox.width, height: resultBBox.height }\n }, opt);\n },\n\n // Rotate element by `angle` degrees, optionally around `origin` point.\n // If `origin` is not provided, it is considered to be the center of the element.\n // If `absolute` is `true`, the `angle` is considered is absolute, i.e. it is not\n // the difference from the previous angle.\n rotate: function(angle, absolute, origin, opt) {\n\n if (origin) {\n\n var center = this.getBBox().center();\n var size = this.get('size');\n var position = this.get('position');\n center.rotate(origin, this.get('angle') - angle);\n var dx = center.x - size.width / 2 - position.x;\n var dy = center.y - size.height / 2 - position.y;\n this.startBatch('rotate', { angle: angle, absolute: absolute, origin: origin });\n this.position(position.x + dx, position.y + dy, opt);\n this.rotate(angle, absolute, null, opt);\n this.stopBatch('rotate');\n\n } else {\n\n this.set('angle', absolute ? angle : (this.get('angle') + angle) % 360, opt);\n }\n\n return this;\n },\n\n angle: function() {\n return normalizeAngle(this.get('angle') || 0);\n },\n\n getBBox: function(opt = {}) {\n\n const { graph, attributes } = this;\n const { deep, rotate } = opt;\n\n if (deep && graph) {\n // Get all the embedded elements using breadth first algorithm.\n const elements = this.getEmbeddedCells({ deep: true, breadthFirst: true });\n // Add the model itself.\n elements.push(this);\n // Note: the default of getCellsBBox() is rotate=true and can't be\n // changed without a breaking change\n return graph.getCellsBBox(elements, opt);\n }\n\n const { angle = 0, position: { x, y }, size: { width, height }} = attributes;\n const bbox = new Rect(x, y, width, height);\n if (rotate) {\n bbox.rotateAroundCenter(angle);\n }\n return bbox;\n },\n\n getPointFromConnectedLink: function(link, endType) {\n // Center of the model\n var bbox = this.getBBox();\n var center = bbox.center();\n // Center of a port\n var endDef = link.get(endType);\n if (!endDef) return center;\n var portId = endDef.port;\n if (!portId || !this.hasPort(portId)) return center;\n var portGroup = this.portProp(portId, ['group']);\n var portsPositions = this.getPortsPositions(portGroup);\n var portCenter = new Point(portsPositions[portId]).offset(bbox.origin());\n var angle = this.angle();\n if (angle) portCenter.rotate(center, -angle);\n return portCenter;\n }\n});\n\nassign(Element.prototype, elementPortPrototype);\n\n","import { Cell } from './Cell.mjs';\nimport { clone, isPlainObject, isFunction, isString, isNumber } from '../util/index.mjs';\nimport { Point, Polyline } from '../g/index.mjs';\n\n// Link base model.\n// --------------------------\n\nexport const Link = Cell.extend({\n\n // may be overwritten by user to change default label (its markup, size, attrs, position)\n defaultLabel: undefined,\n\n // deprecated\n // may be overwritten by user to change default label markup\n // lower priority than defaultLabel.markup\n labelMarkup: undefined,\n\n // private\n _builtins: {\n defaultLabel: {\n // builtin default markup:\n // used if neither defaultLabel.markup\n // nor label.markup is set\n markup: [\n {\n tagName: 'rect',\n selector: 'rect' // faster than tagName CSS selector\n }, {\n tagName: 'text',\n selector: 'text' // faster than tagName CSS selector\n }\n ],\n // builtin default attributes:\n // applied only if builtin default markup is used\n attrs: {\n text: {\n fill: '#000000',\n fontSize: 14,\n textAnchor: 'middle',\n textVerticalAnchor: 'middle',\n pointerEvents: 'none'\n },\n rect: {\n ref: 'text',\n fill: '#ffffff',\n rx: 3,\n ry: 3,\n x: 'calc(x)',\n y: 'calc(y)',\n width: 'calc(w)',\n height: 'calc(h)'\n }\n },\n // builtin default position:\n // used if neither defaultLabel.position\n // nor label.position is set\n position: {\n distance: 0.5\n }\n }\n },\n\n defaults: {\n source: {},\n target: {}\n },\n\n isLink: function() {\n\n return true;\n },\n\n disconnect: function(opt) {\n\n return this.set({\n source: { x: 0, y: 0 },\n target: { x: 0, y: 0 }\n }, opt);\n },\n\n source: function(source, args, opt) {\n\n // getter\n if (source === undefined) {\n return clone(this.get('source'));\n }\n\n // setter\n var setSource;\n var setOpt;\n\n // `source` is a cell\n // take only its `id` and combine with `args`\n var isCellProvided = source instanceof Cell;\n if (isCellProvided) { // three arguments\n setSource = clone(args) || {};\n setSource.id = source.id;\n setOpt = opt;\n return this.set('source', setSource, setOpt);\n }\n\n // `source` is a point-like object\n // for example, a g.Point\n // take only its `x` and `y` and combine with `args`\n var isPointProvided = !isPlainObject(source);\n if (isPointProvided) { // three arguments\n setSource = clone(args) || {};\n setSource.x = source.x;\n setSource.y = source.y;\n setOpt = opt;\n return this.set('source', setSource, setOpt);\n }\n\n // `source` is an object\n // no checking\n // two arguments\n setSource = source;\n setOpt = args;\n return this.set('source', setSource, setOpt);\n },\n\n target: function(target, args, opt) {\n\n // getter\n if (target === undefined) {\n return clone(this.get('target'));\n }\n\n // setter\n var setTarget;\n var setOpt;\n\n // `target` is a cell\n // take only its `id` argument and combine with `args`\n var isCellProvided = target instanceof Cell;\n if (isCellProvided) { // three arguments\n setTarget = clone(args) || {};\n setTarget.id = target.id;\n setOpt = opt;\n return this.set('target', setTarget, setOpt);\n }\n\n // `target` is a point-like object\n // for example, a g.Point\n // take only its `x` and `y` and combine with `args`\n var isPointProvided = !isPlainObject(target);\n if (isPointProvided) { // three arguments\n setTarget = clone(args) || {};\n setTarget.x = target.x;\n setTarget.y = target.y;\n setOpt = opt;\n return this.set('target', setTarget, setOpt);\n }\n\n // `target` is an object\n // no checking\n // two arguments\n setTarget = target;\n setOpt = args;\n return this.set('target', setTarget, setOpt);\n },\n\n router: function(name, args, opt) {\n\n // getter\n if (name === undefined) {\n var router = this.get('router');\n if (!router) {\n return null;\n }\n if (typeof router === 'object') return clone(router);\n return router; // e.g. a function\n }\n\n // setter\n var isRouterProvided = ((typeof name === 'object') || (typeof name === 'function'));\n var localRouter = isRouterProvided ? name : { name: name, args: args };\n var localOpt = isRouterProvided ? args : opt;\n\n return this.set('router', localRouter, localOpt);\n },\n\n connector: function(name, args, opt) {\n\n // getter\n if (name === undefined) {\n var connector = this.get('connector');\n if (!connector) {\n return null;\n }\n if (typeof connector === 'object') return clone(connector);\n return connector; // e.g. a function\n }\n\n // setter\n var isConnectorProvided = ((typeof name === 'object' || typeof name === 'function'));\n var localConnector = isConnectorProvided ? name : { name: name, args: args };\n var localOpt = isConnectorProvided ? args : opt;\n\n return this.set('connector', localConnector, localOpt);\n },\n\n // Labels API\n\n // A convenient way to set labels. Currently set values will be mixined with `value` if used as a setter.\n label: function(idx, label, opt) {\n\n var labels = this.labels();\n\n idx = (isFinite(idx) && idx !== null) ? (idx | 0) : 0;\n if (idx < 0) idx = labels.length + idx;\n\n // getter\n if (arguments.length <= 1) return this.prop(['labels', idx]);\n // setter\n return this.prop(['labels', idx], label, opt);\n },\n\n labels: function(labels, opt) {\n\n // getter\n if (arguments.length === 0) {\n labels = this.get('labels');\n if (!Array.isArray(labels)) return [];\n return labels.slice();\n }\n // setter\n if (!Array.isArray(labels)) labels = [];\n return this.set('labels', labels, opt);\n },\n\n hasLabels: function() {\n const { labels } = this.attributes;\n return Array.isArray(labels) && labels.length > 0;\n },\n\n insertLabel: function(idx, label, opt) {\n\n if (!label) throw new Error('dia.Link: no label provided');\n\n var labels = this.labels();\n var n = labels.length;\n idx = (isFinite(idx) && idx !== null) ? (idx | 0) : n;\n if (idx < 0) idx = n + idx + 1;\n\n labels.splice(idx, 0, label);\n return this.labels(labels, opt);\n },\n\n // convenience function\n // add label to end of labels array\n appendLabel: function(label, opt) {\n\n return this.insertLabel(-1, label, opt);\n },\n\n removeLabel: function(idx, opt) {\n\n var labels = this.labels();\n idx = (isFinite(idx) && idx !== null) ? (idx | 0) : -1;\n\n labels.splice(idx, 1);\n return this.labels(labels, opt);\n },\n\n // Vertices API\n\n vertex: function(idx, vertex, opt) {\n\n var vertices = this.vertices();\n\n idx = (isFinite(idx) && idx !== null) ? (idx | 0) : 0;\n if (idx < 0) idx = vertices.length + idx;\n\n // getter\n if (arguments.length <= 1) return this.prop(['vertices', idx]);\n\n // setter\n var setVertex = this._normalizeVertex(vertex);\n return this.prop(['vertices', idx], setVertex, opt);\n },\n\n vertices: function(vertices, opt) {\n\n // getter\n if (arguments.length === 0) {\n vertices = this.get('vertices');\n if (!Array.isArray(vertices)) return [];\n return vertices.slice();\n }\n\n // setter\n if (!Array.isArray(vertices)) vertices = [];\n var setVertices = [];\n for (var i = 0; i < vertices.length; i++) {\n var vertex = vertices[i];\n var setVertex = this._normalizeVertex(vertex);\n setVertices.push(setVertex);\n }\n return this.set('vertices', setVertices, opt);\n },\n\n insertVertex: function(idx, vertex, opt) {\n\n if (!vertex) throw new Error('dia.Link: no vertex provided');\n\n var vertices = this.vertices();\n var n = vertices.length;\n idx = (isFinite(idx) && idx !== null) ? (idx | 0) : n;\n if (idx < 0) idx = n + idx + 1;\n\n var setVertex = this._normalizeVertex(vertex);\n vertices.splice(idx, 0, setVertex);\n return this.vertices(vertices, opt);\n },\n\n removeVertex: function(idx, opt) {\n\n var vertices = this.vertices();\n idx = (isFinite(idx) && idx !== null) ? (idx | 0) : -1;\n\n vertices.splice(idx, 1);\n return this.vertices(vertices, opt);\n },\n\n _normalizeVertex: function(vertex) {\n\n // is vertex a point-like object?\n // for example, a g.Point\n var isPointProvided = !isPlainObject(vertex);\n if (isPointProvided) return { x: vertex.x, y: vertex.y };\n\n // else: return vertex unchanged\n return vertex;\n },\n\n // Transformations\n\n translate: function(tx, ty, opt) {\n\n // enrich the option object\n opt = opt || {};\n opt.translateBy = opt.translateBy || this.id;\n opt.tx = tx;\n opt.ty = ty;\n\n return this.applyToPoints(function(p) {\n return { x: (p.x || 0) + tx, y: (p.y || 0) + ty };\n }, opt);\n },\n\n scale: function(sx, sy, origin, opt) {\n\n return this.applyToPoints(function(p) {\n return Point(p).scale(sx, sy, origin).toJSON();\n }, opt);\n },\n\n applyToPoints: function(fn, opt) {\n\n if (!isFunction(fn)) {\n throw new TypeError('dia.Link: applyToPoints expects its first parameter to be a function.');\n }\n\n var attrs = {};\n\n var { source, target } = this.attributes;\n if (!source.id) {\n attrs.source = fn(source);\n }\n if (!target.id) {\n attrs.target = fn(target);\n }\n\n var vertices = this.vertices();\n if (vertices.length > 0) {\n attrs.vertices = vertices.map(fn);\n }\n\n return this.set(attrs, opt);\n },\n\n getSourcePoint: function() {\n var sourceCell = this.getSourceCell();\n if (!sourceCell) return new Point(this.source());\n return sourceCell.getPointFromConnectedLink(this, 'source');\n },\n\n getTargetPoint: function() {\n var targetCell = this.getTargetCell();\n if (!targetCell) return new Point(this.target());\n return targetCell.getPointFromConnectedLink(this, 'target');\n },\n\n getPointFromConnectedLink: function(/* link, endType */) {\n return this.getPolyline().pointAt(0.5);\n },\n\n getPolyline: function() {\n const points = [\n this.getSourcePoint(),\n ...this.vertices().map(Point),\n this.getTargetPoint()\n ];\n return new Polyline(points);\n },\n\n getBBox: function() {\n return this.getPolyline().bbox();\n },\n\n reparent: function(opt) {\n\n var newParent;\n\n if (this.graph) {\n\n var source = this.getSourceElement();\n var target = this.getTargetElement();\n var prevParent = this.getParentCell();\n\n if (source && target) {\n if (source === target || source.isEmbeddedIn(target)) {\n newParent = target;\n } else if (target.isEmbeddedIn(source)) {\n newParent = source;\n } else {\n newParent = this.graph.getCommonAncestor(source, target);\n }\n }\n\n if (prevParent && (!newParent || newParent.id !== prevParent.id)) {\n // Unembed the link if source and target has no common ancestor\n // or common ancestor changed\n prevParent.unembed(this, opt);\n }\n\n if (newParent) {\n newParent.embed(this, opt);\n }\n }\n\n return newParent;\n },\n\n hasLoop: function(opt) {\n\n opt = opt || {};\n\n var { source, target } = this.attributes;\n var sourceId = source.id;\n var targetId = target.id;\n\n if (!sourceId || !targetId) {\n // Link \"pinned\" to the paper does not have a loop.\n return false;\n }\n\n var loop = sourceId === targetId;\n\n // Note that there in the deep mode a link can have a loop,\n // even if it connects only a parent and its embed.\n // A loop \"target equals source\" is valid in both shallow and deep mode.\n if (!loop && opt.deep && this.graph) {\n\n var sourceElement = this.getSourceCell();\n var targetElement = this.getTargetCell();\n\n loop = sourceElement.isEmbeddedIn(targetElement) || targetElement.isEmbeddedIn(sourceElement);\n }\n\n return loop;\n },\n\n // unlike source(), this method returns null if source is a point\n getSourceCell: function() {\n\n const { graph, attributes } = this;\n var source = attributes.source;\n return (source && source.id && graph && graph.getCell(source.id)) || null;\n },\n\n getSourceElement: function() {\n var cell = this;\n var visited = {};\n do {\n if (visited[cell.id]) return null;\n visited[cell.id] = true;\n cell = cell.getSourceCell();\n } while (cell && cell.isLink());\n return cell;\n },\n\n // unlike target(), this method returns null if target is a point\n getTargetCell: function() {\n\n const { graph, attributes } = this;\n var target = attributes.target;\n return (target && target.id && graph && graph.getCell(target.id)) || null;\n },\n\n getTargetElement: function() {\n var cell = this;\n var visited = {};\n do {\n if (visited[cell.id]) return null;\n visited[cell.id] = true;\n cell = cell.getTargetCell();\n } while (cell && cell.isLink());\n return cell;\n },\n\n // Returns the common ancestor for the source element,\n // target element and the link itself.\n getRelationshipAncestor: function() {\n\n var connectionAncestor;\n\n if (this.graph) {\n\n var cells = [\n this,\n this.getSourceElement(), // null if source is a point\n this.getTargetElement() // null if target is a point\n ].filter(function(item) {\n return !!item;\n });\n\n connectionAncestor = this.graph.getCommonAncestor.apply(this.graph, cells);\n }\n\n return connectionAncestor || null;\n },\n\n // Is source, target and the link itself embedded in a given cell?\n isRelationshipEmbeddedIn: function(cell) {\n\n var cellId = (isString(cell) || isNumber(cell)) ? cell : cell.id;\n var ancestor = this.getRelationshipAncestor();\n\n return !!ancestor && (ancestor.id === cellId || ancestor.isEmbeddedIn(cellId));\n },\n\n // Get resolved default label.\n _getDefaultLabel: function() {\n\n var defaultLabel = this.get('defaultLabel') || this.defaultLabel || {};\n\n var label = {};\n label.markup = defaultLabel.markup || this.get('labelMarkup') || this.labelMarkup;\n label.position = defaultLabel.position;\n label.attrs = defaultLabel.attrs;\n label.size = defaultLabel.size;\n\n return label;\n }\n}, {\n\n endsEqual: function(a, b) {\n\n var portsEqual = a.port === b.port || !a.port && !b.port;\n return a.id === b.id && portsEqual;\n }\n});\n\n","export const env = {\n\n _results: {},\n\n _tests: {\n\n svgforeignobject: function() {\n return !!document.createElementNS &&\n /SVGForeignObject/.test(({}).toString.call(document.createElementNS('http://www.w3.org/2000/svg', 'foreignObject')));\n },\n\n // works for iOS browsers too\n isSafari: function() {\n return /Safari/.test(navigator.userAgent) && /Apple Computer/.test(navigator.vendor);\n }\n },\n\n addTest: function(name, fn) {\n\n return this._tests[name] = fn;\n },\n\n test: function(name) {\n\n var fn = this._tests[name];\n\n if (!fn) {\n throw new Error('Test not defined (\"' + name + '\"). Use `joint.env.addTest(name, fn) to add a new test.`');\n }\n\n var result = this._results[name];\n\n if (typeof result !== 'undefined') {\n return result;\n }\n\n try {\n result = fn();\n } catch (error) {\n result = false;\n }\n\n // Cache the test result.\n this._results[name] = result;\n\n return result;\n }\n};\n","import V from '../V/index.mjs';\nimport { Element } from '../dia/Element.mjs';\nimport { Link as LinkBase } from '../dia/Link.mjs';\nimport { isPercentage, assign } from '../util/index.mjs';\nimport { attributes } from '../dia/attributes/index.mjs';\nimport { env } from '../env/index.mjs';\n\n\n// ELEMENTS\n\nexport const Rectangle = Element.define('standard.Rectangle', {\n attrs: {\n root: {\n cursor: 'move'\n },\n body: {\n width: 'calc(w)',\n height: 'calc(h)',\n strokeWidth: 2,\n stroke: '#000000',\n fill: '#FFFFFF'\n },\n label: {\n textVerticalAnchor: 'middle',\n textAnchor: 'middle',\n x: 'calc(w/2)',\n y: 'calc(h/2)',\n fontSize: 14,\n fill: '#333333'\n }\n }\n}, {\n markup: [{\n tagName: 'rect',\n selector: 'body',\n }, {\n tagName: 'text',\n selector: 'label'\n }]\n});\n\nexport const Circle = Element.define('standard.Circle', {\n attrs: {\n root: {\n cursor: 'move'\n },\n body: {\n cx: 'calc(s/2)',\n cy: 'calc(s/2)',\n r: 'calc(s/2)',\n strokeWidth: 2,\n stroke: '#333333',\n fill: '#FFFFFF'\n },\n label: {\n textVerticalAnchor: 'middle',\n textAnchor: 'middle',\n x: 'calc(w/2)',\n y: 'calc(h/2)',\n fontSize: 14,\n fill: '#333333'\n }\n }\n}, {\n markup: [{\n tagName: 'circle',\n selector: 'body'\n }, {\n tagName: 'text',\n selector: 'label'\n }]\n});\n\nexport const Ellipse = Element.define('standard.Ellipse', {\n attrs: {\n root: {\n cursor: 'move'\n },\n body: {\n cx: 'calc(w/2)',\n cy: 'calc(h/2)',\n rx: 'calc(w/2)',\n ry: 'calc(h/2)',\n strokeWidth: 2,\n stroke: '#333333',\n fill: '#FFFFFF'\n },\n label: {\n textVerticalAnchor: 'middle',\n textAnchor: 'middle',\n x: 'calc(w/2)',\n y: 'calc(h/2)',\n fontSize: 14,\n fill: '#333333'\n }\n }\n}, {\n markup: [{\n tagName: 'ellipse',\n selector: 'body'\n }, {\n tagName: 'text',\n selector: 'label'\n }]\n});\n\nexport const Path = Element.define('standard.Path', {\n attrs: {\n root: {\n cursor: 'move'\n },\n body: {\n d: 'M 0 0 H calc(w) V calc(h) H 0 Z',\n strokeWidth: 2,\n stroke: '#333333',\n fill: '#FFFFFF'\n },\n label: {\n textVerticalAnchor: 'middle',\n textAnchor: 'middle',\n x: 'calc(w/2)',\n y: 'calc(h/2)',\n fontSize: 14,\n fill: '#333333'\n }\n }\n}, {\n markup: [{\n tagName: 'path',\n selector: 'body'\n }, {\n tagName: 'text',\n selector: 'label'\n }]\n});\n\nexport const Polygon = Element.define('standard.Polygon', {\n attrs: {\n root: {\n cursor: 'move'\n },\n body: {\n points: '0 0 calc(w) 0 calc(w) calc(h) 0 calc(h)',\n strokeWidth: 2,\n stroke: '#333333',\n fill: '#FFFFFF'\n },\n label: {\n textVerticalAnchor: 'middle',\n textAnchor: 'middle',\n x: 'calc(w/2)',\n y: 'calc(h/2)',\n fontSize: 14,\n fill: '#333333'\n }\n }\n}, {\n markup: [{\n tagName: 'polygon',\n selector: 'body'\n }, {\n tagName: 'text',\n selector: 'label'\n }]\n});\n\nexport const Polyline = Element.define('standard.Polyline', {\n attrs: {\n root: {\n cursor: 'move'\n },\n body: {\n points: '0 0 calc(w) 0 calc(w) calc(h) 0 calc(h)',\n strokeWidth: 2,\n stroke: '#333333',\n fill: '#FFFFFF'\n },\n label: {\n textVerticalAnchor: 'middle',\n textAnchor: 'middle',\n x: 'calc(w/2)',\n y: 'calc(h/2)',\n fontSize: 14,\n fill: '#333333'\n }\n }\n}, {\n markup: [{\n tagName: 'polyline',\n selector: 'body'\n }, {\n tagName: 'text',\n selector: 'label'\n }]\n});\n\nexport const Image = Element.define('standard.Image', {\n attrs: {\n root: {\n cursor: 'move'\n },\n image: {\n width: 'calc(w)',\n height: 'calc(h)',\n // xlinkHref: '[URL]'\n },\n label: {\n textVerticalAnchor: 'top',\n textAnchor: 'middle',\n x: 'calc(w/2)',\n y: 'calc(h+10)',\n fontSize: 14,\n fill: '#333333'\n }\n }\n}, {\n markup: [{\n tagName: 'image',\n selector: 'image'\n }, {\n tagName: 'text',\n selector: 'label'\n }]\n});\n\nexport const BorderedImage = Element.define('standard.BorderedImage', {\n attrs: {\n root: {\n cursor: 'move'\n },\n border: {\n width: 'calc(w)',\n height: 'calc(h)',\n stroke: '#333333',\n strokeWidth: 2\n },\n background: {\n width: 'calc(w-1)',\n height: 'calc(h-1)',\n x: 0.5,\n y: 0.5,\n fill: '#FFFFFF'\n },\n image: {\n // xlinkHref: '[URL]'\n width: 'calc(w-1)',\n height: 'calc(h-1)',\n x: 0.5,\n y: 0.5\n },\n label: {\n textVerticalAnchor: 'top',\n textAnchor: 'middle',\n x: 'calc(w/2)',\n y: 'calc(h+10)',\n fontSize: 14,\n fill: '#333333'\n }\n }\n}, {\n markup: [{\n tagName: 'rect',\n selector: 'background',\n attributes: {\n 'stroke': 'none'\n }\n }, {\n tagName: 'image',\n selector: 'image'\n }, {\n tagName: 'rect',\n selector: 'border',\n attributes: {\n 'fill': 'none'\n }\n }, {\n tagName: 'text',\n selector: 'label'\n }]\n});\n\nexport const EmbeddedImage = Element.define('standard.EmbeddedImage', {\n attrs: {\n root: {\n cursor: 'move'\n },\n body: {\n width: 'calc(w)',\n height: 'calc(h)',\n stroke: '#333333',\n fill: '#FFFFFF',\n strokeWidth: 2\n },\n image: {\n // xlinkHref: '[URL]'\n width: 'calc(0.3*w)',\n height: 'calc(h-20)',\n x: 10,\n y: 10,\n preserveAspectRatio: 'xMidYMin'\n },\n label: {\n textVerticalAnchor: 'top',\n textAnchor: 'left',\n x: 'calc(0.3*w+20)', // 10 + 10\n y: 10,\n fontSize: 14,\n fill: '#333333'\n }\n }\n}, {\n markup: [{\n tagName: 'rect',\n selector: 'body'\n }, {\n tagName: 'image',\n selector: 'image'\n }, {\n tagName: 'text',\n selector: 'label'\n }]\n});\n\nexport const InscribedImage = Element.define('standard.InscribedImage', {\n attrs: {\n root: {\n cursor: 'move'\n },\n border: {\n rx: 'calc(w/2)',\n ry: 'calc(h/2)',\n cx: 'calc(w/2)',\n cy: 'calc(h/2)',\n stroke: '#333333',\n strokeWidth: 2\n },\n background: {\n rx: 'calc(w/2)',\n ry: 'calc(h/2)',\n cx: 'calc(w/2)',\n cy: 'calc(h/2)',\n fill: '#FFFFFF'\n },\n image: {\n // The image corners touch the border when its size is Math.sqrt(2) / 2 = 0.707.. ~= 70%\n width: 'calc(0.68*w)',\n height: 'calc(0.68*h)',\n // The image offset is calculated as (100% - 68%) / 2\n x: 'calc(0.16*w)',\n y: 'calc(0.16*h)',\n preserveAspectRatio: 'xMidYMid'\n // xlinkHref: '[URL]'\n },\n label: {\n textVerticalAnchor: 'top',\n textAnchor: 'middle',\n x: 'calc(w/2)',\n y: 'calc(h+10)',\n fontSize: 14,\n fill: '#333333'\n }\n }\n}, {\n markup: [{\n tagName: 'ellipse',\n selector: 'background'\n }, {\n tagName: 'image',\n selector: 'image'\n }, {\n tagName: 'ellipse',\n selector: 'border',\n attributes: {\n 'fill': 'none'\n }\n }, {\n tagName: 'text',\n selector: 'label'\n }]\n});\n\nexport const HeaderedRectangle = Element.define('standard.HeaderedRectangle', {\n attrs: {\n root: {\n cursor: 'move'\n },\n body: {\n width: 'calc(w)',\n height: 'calc(h)',\n strokeWidth: 2,\n stroke: '#000000',\n fill: '#FFFFFF'\n },\n header: {\n width: 'calc(w)',\n height: 30,\n strokeWidth: 2,\n stroke: '#000000',\n fill: '#FFFFFF'\n },\n headerText: {\n textVerticalAnchor: 'middle',\n textAnchor: 'middle',\n x: 'calc(w/2)',\n y: 15,\n fontSize: 16,\n fill: '#333333'\n },\n bodyText: {\n textVerticalAnchor: 'middle',\n textAnchor: 'middle',\n x: 'calc(w/2)',\n y: 'calc(h/2+15)',\n fontSize: 14,\n fill: '#333333'\n }\n }\n}, {\n markup: [{\n tagName: 'rect',\n selector: 'body'\n }, {\n tagName: 'rect',\n selector: 'header'\n }, {\n tagName: 'text',\n selector: 'headerText'\n }, {\n tagName: 'text',\n selector: 'bodyText'\n }]\n});\n\nvar CYLINDER_TILT = 10;\n\nexport const Cylinder = Element.define('standard.Cylinder', {\n attrs: {\n root: {\n cursor: 'move'\n },\n body: {\n lateralArea: CYLINDER_TILT,\n fill: '#FFFFFF',\n stroke: '#333333',\n strokeWidth: 2\n },\n top: {\n cx: 'calc(w/2)',\n cy: CYLINDER_TILT,\n rx: 'calc(w/2)',\n ry: CYLINDER_TILT,\n fill: '#FFFFFF',\n stroke: '#333333',\n strokeWidth: 2\n },\n label: {\n textVerticalAnchor: 'middle',\n textAnchor: 'middle',\n x: 'calc(w/2)',\n y: 'calc(h+15)',\n fontSize: 14,\n fill: '#333333'\n }\n }\n}, {\n markup: [{\n tagName: 'path',\n selector: 'body'\n }, {\n tagName: 'ellipse',\n selector: 'top'\n }, {\n tagName: 'text',\n selector: 'label'\n }],\n\n topRy: function(t, opt) {\n // getter\n if (t === undefined) return this.attr('body/lateralArea');\n\n // setter\n var bodyAttrs = { lateralArea: t };\n\n var isPercentageSetter = isPercentage(t);\n var ty = (isPercentageSetter) ? `calc(${parseFloat(t) / 100}*h)` : t;\n var topAttrs = { cy: ty, ry: ty };\n\n return this.attr({ body: bodyAttrs, top: topAttrs }, opt);\n }\n\n}, {\n attributes: {\n 'lateral-area': {\n set: function(t, refBBox) {\n var isPercentageSetter = isPercentage(t);\n if (isPercentageSetter) t = parseFloat(t) / 100;\n\n var x = refBBox.x;\n var y = refBBox.y;\n var w = refBBox.width;\n var h = refBBox.height;\n\n // curve control point variables\n var rx = w / 2;\n var ry = isPercentageSetter ? (h * t) : t;\n\n var kappa = V.KAPPA;\n var cx = kappa * rx;\n var cy = kappa * (isPercentageSetter ? (h * t) : t);\n\n // shape variables\n var xLeft = x;\n var xCenter = x + (w / 2);\n var xRight = x + w;\n\n var ySideTop = y + ry;\n var yCurveTop = ySideTop - ry;\n var ySideBottom = y + h - ry;\n var yCurveBottom = y + h;\n\n // return calculated shape\n var data = [\n 'M', xLeft, ySideTop,\n 'L', xLeft, ySideBottom,\n 'C', x, (ySideBottom + cy), (xCenter - cx), yCurveBottom, xCenter, yCurveBottom,\n 'C', (xCenter + cx), yCurveBottom, xRight, (ySideBottom + cy), xRight, ySideBottom,\n 'L', xRight, ySideTop,\n 'C', xRight, (ySideTop - cy), (xCenter + cx), yCurveTop, xCenter, yCurveTop,\n 'C', (xCenter - cx), yCurveTop, xLeft, (ySideTop - cy), xLeft, ySideTop,\n 'Z'\n ];\n return { d: data.join(' ') };\n },\n unset: 'd'\n }\n }\n});\n\nvar foLabelMarkup = {\n tagName: 'foreignObject',\n selector: 'foreignObject',\n attributes: {\n 'overflow': 'hidden'\n },\n children: [{\n tagName: 'div',\n namespaceURI: 'http://www.w3.org/1999/xhtml',\n selector: 'label',\n style: {\n width: '100%',\n height: '100%',\n position: 'static',\n backgroundColor: 'transparent',\n textAlign: 'center',\n margin: 0,\n padding: '0px 5px',\n boxSizing: 'border-box',\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'center'\n }\n }]\n};\n\nvar svgLabelMarkup = {\n tagName: 'text',\n selector: 'label',\n attributes: {\n 'text-anchor': 'middle'\n }\n};\n\nvar labelMarkup = (env.test('svgforeignobject')) ? foLabelMarkup : svgLabelMarkup;\n\nexport const TextBlock = Element.define('standard.TextBlock', {\n attrs: {\n root: {\n cursor: 'move'\n },\n body: {\n width: 'calc(w)',\n height: 'calc(h)',\n stroke: '#333333',\n fill: '#ffffff',\n strokeWidth: 2\n },\n foreignObject: {\n width: 'calc(w)',\n height: 'calc(h)',\n },\n label: {\n style: {\n fontSize: 14\n }\n }\n }\n}, {\n markup: [{\n tagName: 'rect',\n selector: 'body'\n }, labelMarkup]\n}, {\n attributes: {\n text: {\n set: function(text, refBBox, node, attrs) {\n if (node instanceof HTMLElement) {\n node.textContent = text;\n } else {\n // No foreign object\n var style = attrs['style'] || {};\n var wrapValue = { text, width: -5, height: '100%' };\n var wrapAttrs = assign({ 'text-vertical-anchor': 'middle' }, style);\n attributes['text-wrap'].set.call(this, wrapValue, refBBox, node, wrapAttrs);\n return { fill: style.color || null };\n }\n },\n unset: function(node) {\n node.textContent = '';\n if (node instanceof SVGElement) {\n return 'fill';\n }\n },\n position: function(text, refBBox, node) {\n // No foreign object\n if (node instanceof SVGElement) return refBBox.center();\n }\n }\n }\n});\n\n// LINKS\n\nexport const Link = LinkBase.define('standard.Link', {\n attrs: {\n line: {\n connection: true,\n stroke: '#333333',\n strokeWidth: 2,\n strokeLinejoin: 'round',\n targetMarker: {\n 'type': 'path',\n 'd': 'M 10 -5 0 0 10 5 z'\n }\n },\n wrapper: {\n connection: true,\n strokeWidth: 10,\n strokeLinejoin: 'round'\n }\n }\n}, {\n markup: [{\n tagName: 'path',\n selector: 'wrapper',\n attributes: {\n 'fill': 'none',\n 'cursor': 'pointer',\n 'stroke': 'transparent',\n 'stroke-linecap': 'round'\n }\n }, {\n tagName: 'path',\n selector: 'line',\n attributes: {\n 'fill': 'none',\n 'pointer-events': 'none'\n }\n }]\n});\n\nexport const DoubleLink = LinkBase.define('standard.DoubleLink', {\n attrs: {\n line: {\n connection: true,\n stroke: '#DDDDDD',\n strokeWidth: 4,\n strokeLinejoin: 'round',\n targetMarker: {\n type: 'path',\n stroke: '#000000',\n d: 'M 10 -3 10 -10 -2 0 10 10 10 3'\n }\n },\n outline: {\n connection: true,\n stroke: '#000000',\n strokeWidth: 6,\n strokeLinejoin: 'round'\n }\n }\n}, {\n markup: [{\n tagName: 'path',\n selector: 'outline',\n attributes: {\n 'fill': 'none',\n 'cursor': 'pointer'\n }\n }, {\n tagName: 'path',\n selector: 'line',\n attributes: {\n 'fill': 'none',\n 'pointer-events': 'none'\n }\n }]\n});\n\nexport const ShadowLink = LinkBase.define('standard.ShadowLink', {\n attrs: {\n line: {\n connection: true,\n stroke: '#FF0000',\n strokeWidth: 20,\n strokeLinejoin: 'round',\n targetMarker: {\n 'type': 'path',\n 'stroke': 'none',\n 'd': 'M 0 -10 -10 0 0 10 z'\n },\n sourceMarker: {\n 'type': 'path',\n 'stroke': 'none',\n 'd': 'M -10 -10 0 0 -10 10 0 10 0 -10 z'\n }\n },\n shadow: {\n connection: true,\n transform: 'translate(3,6)',\n stroke: '#000000',\n strokeOpacity: 0.2,\n strokeWidth: 20,\n strokeLinejoin: 'round',\n targetMarker: {\n 'type': 'path',\n 'd': 'M 0 -10 -10 0 0 10 z',\n 'stroke': 'none'\n },\n sourceMarker: {\n 'type': 'path',\n 'stroke': 'none',\n 'd': 'M -10 -10 0 0 -10 10 0 10 0 -10 z'\n }\n }\n }\n}, {\n markup: [{\n tagName: 'path',\n selector: 'shadow',\n attributes: {\n 'fill': 'none',\n 'pointer-events': 'none'\n }\n }, {\n tagName: 'path',\n selector: 'line',\n attributes: {\n 'fill': 'none',\n 'cursor': 'pointer'\n }\n }]\n});\n","import * as g from '../g/index.mjs';\n\nexport const Positions = {\n TOP: 'top',\n RIGHT: 'right',\n BOTTOM: 'bottom',\n LEFT: 'left',\n TOP_LEFT: 'top-left',\n TOP_RIGHT: 'top-right',\n BOTTOM_LEFT: 'bottom-left',\n BOTTOM_RIGHT: 'bottom-right',\n CENTER: 'center',\n};\n\nexport function getRectPoint(rect, position) {\n const r = new g.Rect(rect);\n switch (position) {\n case undefined:\n throw new Error('Position required');\n\n // Middle Points\n case Positions.LEFT:\n case 'leftMiddle':\n return r.leftMiddle();\n\n case Positions.RIGHT:\n case 'rightMiddle':\n return r.rightMiddle();\n\n case Positions.TOP:\n case 'topMiddle':\n return r.topMiddle();\n\n case Positions.BOTTOM:\n case 'bottomMiddle':\n return r.bottomMiddle();\n\n // Corners\n case Positions.TOP_LEFT:\n case 'topLeft':\n case 'origin':\n return r.topLeft();\n\n case Positions.TOP_RIGHT:\n case 'topRight':\n return r.topRight();\n\n case Positions.BOTTOM_LEFT:\n case 'bottomLeft':\n return r.bottomLeft();\n\n case Positions.BOTTOM_RIGHT:\n case 'bottomRight':\n case 'corner':\n return r.bottomRight();\n\n // Center\n case Positions.CENTER:\n return r.center();\n\n // TODO: calc(), percentage etc.\n default:\n throw new Error(`Unknown position: ${position}`);\n }\n}\n","import { Events } from './Events.mjs';\nimport { Model } from './Model.mjs';\nimport { extend, addMethodsUtil } from './mvcUtils.mjs';\nimport {\n assign,\n clone,\n isFunction,\n isString,\n sortBy,\n toArray\n} from '../util/util.mjs';\n\n\n// Collection\n// -------------------\n\n// If models tend to represent a single row of data, a Collection is\n// more analogous to a table full of data ... or a small slice or page of that\n// table, or a collection of rows that belong together for a particular reason\n// -- all of the messages in this particular folder, all of the documents\n// belonging to this particular author, and so on. Collections maintain\n// indexes of their models, both in order, and for lookup by `id`.\n\n// Create a new **Collection**, perhaps to contain a specific type of `model`.\n// If a `comparator` is specified, the Collection will maintain\n// its models in sort order, as they're added and removed.\nexport var Collection = function(models, options) {\n options || (options = {});\n this.preinitialize.apply(this, arguments);\n if (options.model) this.model = options.model;\n if (options.comparator !== void 0) this.comparator = options.comparator;\n this._reset();\n this.initialize.apply(this, arguments);\n if (models) this.reset(models, assign({ silent: true }, options));\n};\n\n// Default options for `Collection#set`.\nvar setOptions = { add: true, remove: true, merge: true };\nvar addOptions = { add: true, remove: false };\n\n// Splices `insert` into `array` at index `at`.\nvar splice = function(array, insert, at) {\n at = Math.min(Math.max(at, 0), array.length);\n var tail = Array(array.length - at);\n var length = insert.length;\n var i;\n for (i = 0; i < tail.length; i++) tail[i] = array[i + at];\n for (i = 0; i < length; i++) array[i + at] = insert[i];\n for (i = 0; i < tail.length; i++) array[i + length + at] = tail[i];\n};\n\n// Define the Collection's inheritable methods.\nassign(Collection.prototype, Events, {\n\n // The default model for a collection is just a **Model**.\n // This should be overridden in most cases.\n model: Model,\n\n\n // preinitialize is an empty function by default. You can override it with a function\n // or object. preinitialize will run before any instantiation logic is run in the Collection.\n preinitialize: function(){},\n\n // Initialize is an empty function by default. Override it with your own\n // initialization logic.\n initialize: function(){},\n\n // The JSON representation of a Collection is an array of the\n // models' attributes.\n toJSON: function(options) {\n return this.map(function(model) { return model.toJSON(options); });\n },\n\n // Add a model, or list of models to the set. `models` may be\n // Models or raw JavaScript objects to be converted to Models, or any\n // combination of the two.\n add: function(models, options) {\n return this.set(models, assign({ merge: false }, options, addOptions));\n },\n\n // Remove a model, or a list of models from the set.\n remove: function(models, options) {\n options = assign({}, options);\n var singular = !Array.isArray(models);\n models = singular ? [models] : models.slice();\n var removed = this._removeModels(models, options);\n if (!options.silent && removed.length) {\n options.changes = { added: [], merged: [], removed: removed };\n this.trigger('update', this, options);\n }\n return singular ? removed[0] : removed;\n },\n\n // Update a collection by `set`-ing a new list of models, adding new ones,\n // removing models that are no longer present, and merging models that\n // already exist in the collection, as necessary. Similar to **Model#set**,\n // the core operation for updating the data contained by the collection.\n set: function(models, options) {\n if (models == null) return;\n\n options = assign({}, setOptions, options);\n\n var singular = !Array.isArray(models);\n models = singular ? [models] : models.slice();\n\n var at = options.at;\n if (at != null) at = +at;\n if (at > this.length) at = this.length;\n if (at < 0) at += this.length + 1;\n\n var set = [];\n var toAdd = [];\n var toMerge = [];\n var toRemove = [];\n var modelMap = {};\n\n var add = options.add;\n var merge = options.merge;\n var remove = options.remove;\n\n var sort = false;\n var sortable = this.comparator && at == null && options.sort !== false;\n var sortAttr = isString(this.comparator) ? this.comparator : null;\n\n // Turn bare objects into model references, and prevent invalid models\n // from being added.\n var model, i;\n for (i = 0; i < models.length; i++) {\n model = models[i];\n\n // If a duplicate is found, prevent it from being added and\n // optionally merge it into the existing model.\n var existing = this.get(model);\n if (existing) {\n if (merge && model !== existing) {\n var attrs = this._isModel(model) ? model.attributes : model;\n existing.set(attrs, options);\n toMerge.push(existing);\n if (sortable && !sort) sort = existing.hasChanged(sortAttr);\n }\n if (!modelMap[existing.cid]) {\n modelMap[existing.cid] = true;\n set.push(existing);\n }\n models[i] = existing;\n\n // If this is a new, valid model, push it to the `toAdd` list.\n } else if (add) {\n model = models[i] = this._prepareModel(model, options);\n if (model) {\n toAdd.push(model);\n this._addReference(model, options);\n modelMap[model.cid] = true;\n set.push(model);\n }\n }\n }\n\n // Remove stale models.\n if (remove) {\n for (i = 0; i < this.length; i++) {\n model = this.models[i];\n if (!modelMap[model.cid]) toRemove.push(model);\n }\n if (toRemove.length) this._removeModels(toRemove, options);\n }\n\n // See if sorting is needed, update `length` and splice in new models.\n var orderChanged = false;\n var replace = !sortable && add && remove;\n if (set.length && replace) {\n orderChanged = this.length !== set.length || this.models.some(function(m, index) {\n return m !== set[index];\n });\n this.models.length = 0;\n splice(this.models, set, 0);\n this.length = this.models.length;\n } else if (toAdd.length) {\n if (sortable) sort = true;\n splice(this.models, toAdd, at == null ? this.length : at);\n this.length = this.models.length;\n }\n\n // Silently sort the collection if appropriate.\n if (sort) this.sort({ silent: true });\n\n // Unless silenced, it's time to fire all appropriate add/sort/update events.\n if (!options.silent) {\n for (i = 0; i < toAdd.length; i++) {\n if (at != null) options.index = at + i;\n model = toAdd[i];\n model.trigger('add', model, this, options);\n }\n if (sort || orderChanged) this.trigger('sort', this, options);\n if (toAdd.length || toRemove.length || toMerge.length) {\n options.changes = {\n added: toAdd,\n removed: toRemove,\n merged: toMerge\n };\n this.trigger('update', this, options);\n }\n }\n\n // Return the added (or merged) model (or models).\n return singular ? models[0] : models;\n },\n\n // When you have more items than you want to add or remove individually,\n // you can reset the entire set with a new list of models, without firing\n // any granular `add` or `remove` events. Fires `reset` when finished.\n // Useful for bulk operations and optimizations.\n reset: function(models, options) {\n options = options ? clone(options) : {};\n for (var i = 0; i < this.models.length; i++) {\n this._removeReference(this.models[i], options);\n }\n options.previousModels = this.models;\n this._reset();\n models = this.add(models, assign({ silent: true }, options));\n if (!options.silent) this.trigger('reset', this, options);\n return models;\n },\n\n // Add a model to the end of the collection.\n push: function(model, options) {\n return this.add(model, assign({ at: this.length }, options));\n },\n\n // Remove a model from the end of the collection.\n pop: function(options) {\n var model = this.at(this.length - 1);\n return this.remove(model, options);\n },\n\n // Add a model to the beginning of the collection.\n unshift: function(model, options) {\n return this.add(model, assign({ at: 0 }, options));\n },\n\n // Remove a model from the beginning of the collection.\n shift: function(options) {\n var model = this.at(0);\n return this.remove(model, options);\n },\n\n // Slice out a sub-array of models from the collection.\n slice: function() {\n return Array.prototype.slice.apply(this.models, arguments);\n },\n\n // Get a model from the set by id, cid, model object with id or cid\n // properties, or an attributes object that is transformed through modelId.\n get: function(obj) {\n if (obj == null) return void 0;\n return this._byId[obj] ||\n this._byId[this.modelId(this._isModel(obj) ? obj.attributes : obj, obj.idAttribute)] ||\n obj.cid && this._byId[obj.cid];\n },\n\n // Returns `true` if the model is in the collection.\n has: function(obj) {\n return this.get(obj) != null;\n },\n\n // Get the model at the given index.\n at: function(index) {\n if (index < 0) index += this.length;\n return this.models[index];\n },\n\n // Force the collection to re-sort itself. You don't need to call this under\n // normal circumstances, as the set will maintain sort order as each item\n // is added.\n sort: function(options) {\n var comparator = this.comparator;\n if (!comparator) throw new Error('Cannot sort a set without a comparator');\n options || (options = {});\n\n var length = comparator.length;\n if (isFunction(comparator)) comparator = comparator.bind(this);\n\n // Run sort based on type of `comparator`.\n if (length === 1 || isString(comparator)) {\n this.models = this.sortBy(comparator);\n } else {\n this.models.sort(comparator);\n }\n if (!options.silent) this.trigger('sort', this, options);\n return this;\n },\n\n // Create a new collection with an identical list of models as this one.\n clone: function() {\n return new this.constructor(this.models, {\n model: this.model,\n comparator: this.comparator\n });\n },\n\n // Define how to uniquely identify models in the collection.\n modelId: function(attrs, idAttribute) {\n return attrs[idAttribute || this.model.prototype.idAttribute || 'id'];\n },\n\n // Get an iterator of all models in this collection.\n values: function() {\n return new CollectionIterator(this, ITERATOR_VALUES);\n },\n\n // Get an iterator of all model IDs in this collection.\n keys: function() {\n return new CollectionIterator(this, ITERATOR_KEYS);\n },\n\n // Get an iterator of all [ID, model] tuples in this collection.\n entries: function() {\n return new CollectionIterator(this, ITERATOR_KEYSVALUES);\n },\n\n // Iterate over elements of the collection, and invoke fn for each element\n each: function(fn, context) {\n this.models.forEach(fn, context);\n },\n\n // Iterate over elements of collection, and return an array of all elements fn returns truthy for\n filter: function(fn, context) {\n return this.models.filter(fn, context);\n },\n\n find: function(fn, context) {\n return this.models.find(fn, context);\n },\n\n findIndex: function(fn, context) {\n return this.models.findIndex(fn, context);\n },\n\n // Return the first model of the collection\n first: function() {\n return this.models[0];\n },\n\n // Return true if value is in the collection\n includes: function(value) {\n return this.models.includes(value);\n },\n\n // Return the last model of the collection\n last: function() {\n return this.models[this.models.length - 1];\n },\n\n // Return true if collection has no elements\n isEmpty: function() {\n return !this.models.length;\n },\n\n // Create an array of values by running each element in the collection through fn\n map: function(fn, context) {\n return this.models.map(fn, context);\n },\n\n // Runs \"reducer\" fn over all elements in the collection, in ascending-index order, and accumulates them into a single value\n reduce: function(fn, initAcc = this.first()) {\n return this.models.reduce(fn, initAcc);\n },\n\n // Private method to reset all internal state. Called when the collection\n // is first initialized or reset.\n _reset: function() {\n this.length = 0;\n this.models = [];\n this._byId = {};\n },\n\n // Prepare a hash of attributes (or other model) to be added to this\n // collection.\n _prepareModel: function(attrs, options) {\n if (this._isModel(attrs)) {\n if (!attrs.collection) attrs.collection = this;\n return attrs;\n }\n options = options ? clone(options) : {};\n options.collection = this;\n\n var model;\n if (this.model.prototype) {\n model = new this.model(attrs, options);\n } else {\n // ES class methods didn't have prototype\n model = this.model(attrs, options);\n }\n\n if (!model.validationError) return model;\n this.trigger('invalid', this, model.validationError, options);\n return false;\n },\n\n // Internal method called by both remove and set.\n _removeModels: function(models, options) {\n var removed = [];\n for (var i = 0; i < models.length; i++) {\n var model = this.get(models[i]);\n if (!model) continue;\n\n var index = this.models.indexOf(model);\n this.models.splice(index, 1);\n this.length--;\n\n // Remove references before triggering 'remove' event to prevent an\n // infinite loop. #3693\n delete this._byId[model.cid];\n var id = this.modelId(model.attributes, model.idAttribute);\n if (id != null) delete this._byId[id];\n\n if (!options.silent) {\n options.index = index;\n model.trigger('remove', model, this, options);\n }\n\n removed.push(model);\n this._removeReference(model, options);\n }\n if (models.length > 0 && !options.silent) delete options.index;\n return removed;\n },\n\n // Method for checking whether an object should be considered a model for\n // the purposes of adding to the collection.\n _isModel: function(model) {\n return model instanceof Model;\n },\n\n // Internal method to create a model's ties to a collection.\n _addReference: function(model, options) {\n this._byId[model.cid] = model;\n var id = this.modelId(model.attributes, model.idAttribute);\n if (id != null) this._byId[id] = model;\n model.on('all', this._onModelEvent, this);\n },\n\n // Internal method to sever a model's ties to a collection.\n _removeReference: function(model, options) {\n delete this._byId[model.cid];\n var id = this.modelId(model.attributes, model.idAttribute);\n if (id != null) delete this._byId[id];\n if (this === model.collection) delete model.collection;\n model.off('all', this._onModelEvent, this);\n },\n\n // Internal method called every time a model in the set fires an event.\n // Sets need to update their indexes when models change ids. All other\n // events simply proxy through. \"add\" and \"remove\" events that originate\n // in other collections are ignored.\n _onModelEvent: function(event, model, collection, options) {\n if (model) {\n if ((event === 'add' || event === 'remove') && collection !== this) return;\n if (event === 'changeId') {\n var prevId = this.modelId(model.previousAttributes(), model.idAttribute);\n var id = this.modelId(model.attributes, model.idAttribute);\n if (prevId != null) delete this._byId[prevId];\n if (id != null) this._byId[id] = model;\n }\n }\n this.trigger.apply(this, arguments);\n }\n\n});\n\n// Defining an @@iterator method implements JavaScript's Iterable protocol.\n// In modern ES2015 browsers, this value is found at Symbol.iterator.\nvar $$iterator = typeof Symbol === 'function' && Symbol.iterator;\nif ($$iterator) {\n Collection.prototype[$$iterator] = Collection.prototype.values;\n}\n\n// CollectionIterator\n// ------------------\n\n// A CollectionIterator implements JavaScript's Iterator protocol, allowing the\n// use of `for of` loops in modern browsers and interoperation between\n// Collection and other JavaScript functions and third-party libraries\n// which can operate on Iterables.\nvar CollectionIterator = function(collection, kind) {\n this._collection = collection;\n this._kind = kind;\n this._index = 0;\n};\n\n// This \"enum\" defines the three possible kinds of values which can be emitted\n// by a CollectionIterator that correspond to the values(), keys() and entries()\n// methods on Collection, respectively.\nvar ITERATOR_VALUES = 1;\nvar ITERATOR_KEYS = 2;\nvar ITERATOR_KEYSVALUES = 3;\n\n// All Iterators should themselves be Iterable.\nif ($$iterator) {\n CollectionIterator.prototype[$$iterator] = function() {\n return this;\n };\n}\n\nCollectionIterator.prototype.next = function() {\n if (this._collection) {\n\n // Only continue iterating if the iterated collection is long enough.\n if (this._index < this._collection.length) {\n var model = this._collection.at(this._index);\n this._index++;\n\n // Construct a value depending on what kind of values should be iterated.\n var value;\n if (this._kind === ITERATOR_VALUES) {\n value = model;\n } else {\n var id = this._collection.modelId(model.attributes, model.idAttribute);\n if (this._kind === ITERATOR_KEYS) {\n value = id;\n } else { // ITERATOR_KEYSVALUES\n value = [id, model];\n }\n }\n return { value: value, done: false };\n }\n\n // Once exhausted, remove the reference to the collection so future\n // calls to the next method always return done.\n this._collection = void 0;\n }\n\n return { value: void 0, done: true };\n};\n\n// Methods that we want to implement on the Collection.\nvar collectionMethods = { toArray: 1, sortBy: 3 };\n\n\n// Mix in each method as a proxy to `Collection#models`.\n\nvar config = [ Collection, collectionMethods, 'models' ];\n\nfunction addMethods(config) {\n var Base = config[0],\n methods = config[1],\n attribute = config[2];\n\n const methodsToAdd = {\n sortBy,\n toArray\n };\n\n addMethodsUtil(Base, methodsToAdd, methods, attribute);\n}\n\naddMethods(config);\n\n// Set up inheritance for the collection.\nCollection.extend = extend;\n","import { Cell } from '../dia/Cell.mjs';\nimport { isFunction, isString, toArray } from './util.mjs';\n\nexport const wrapWith = function(object, methods, wrapper) {\n\n if (isString(wrapper)) {\n\n if (!wrappers[wrapper]) {\n throw new Error('Unknown wrapper: \"' + wrapper + '\"');\n }\n\n wrapper = wrappers[wrapper];\n }\n\n if (!isFunction(wrapper)) {\n throw new Error('Wrapper must be a function.');\n }\n\n toArray(methods).forEach(function(method) {\n object[method] = wrapper(object[method]);\n });\n};\n\nexport const wrappers = {\n\n cells: function(fn) {\n\n return function() {\n\n var args = Array.from(arguments);\n var n = args.length;\n var cells = n > 0 && args[0] || [];\n var opt = n > 1 && args[n - 1] || {};\n\n if (!Array.isArray(cells)) {\n\n if (opt instanceof Cell) {\n cells = args;\n } else if (cells instanceof Cell) {\n if (args.length > 1) {\n args.pop();\n }\n cells = args;\n }\n }\n\n if (opt instanceof Cell) {\n opt = {};\n }\n\n return fn.call(this, cells, opt);\n };\n }\n\n};\n\n","import * as util from '../util/index.mjs';\nimport * as g from '../g/index.mjs';\n\nimport { Model } from '../mvc/Model.mjs';\nimport { Collection } from '../mvc/Collection.mjs';\nimport { wrappers, wrapWith } from '../util/wrappers.mjs';\nimport { cloneCells } from '../util/index.mjs';\n\nconst GraphCells = Collection.extend({\n\n initialize: function(models, opt) {\n\n // Set the optional namespace where all model classes are defined.\n if (opt.cellNamespace) {\n this.cellNamespace = opt.cellNamespace;\n } else {\n /* eslint-disable no-undef */\n this.cellNamespace = typeof joint !== 'undefined' && util.has(joint, 'shapes') ? joint.shapes : null;\n /* eslint-enable no-undef */\n }\n\n\n this.graph = opt.graph;\n },\n\n model: function(attrs, opt) {\n\n const collection = opt.collection;\n const namespace = collection.cellNamespace;\n const { type } = attrs;\n\n // Find the model class based on the `type` attribute in the cell namespace\n const ModelClass = util.getByPath(namespace, type, '.');\n if (!ModelClass) {\n throw new Error(`dia.Graph: Could not find cell constructor for type: '${type}'. Make sure to add the constructor to 'cellNamespace'.`);\n }\n\n return new ModelClass(attrs, opt);\n },\n\n _addReference: function(model, options) {\n Collection.prototype._addReference.apply(this, arguments);\n // If not in `dry` mode and the model does not have a graph reference yet,\n // set the reference.\n if (!options.dry && !model.graph) {\n model.graph = this.graph;\n }\n },\n\n _removeReference: function(model, options) {\n Collection.prototype._removeReference.apply(this, arguments);\n // If not in `dry` mode and the model has a reference to this exact graph,\n // remove the reference.\n if (!options.dry && model.graph === this.graph) {\n model.graph = null;\n }\n },\n\n // `comparator` makes it easy to sort cells based on their `z` index.\n comparator: function(model) {\n\n return model.get('z') || 0;\n }\n});\n\n\nexport const Graph = Model.extend({\n\n initialize: function(attrs, opt) {\n\n opt = opt || {};\n\n // Passing `cellModel` function in the options object to graph allows for\n // setting models based on attribute objects. This is especially handy\n // when processing JSON graphs that are in a different than JointJS format.\n var cells = new GraphCells([], {\n model: opt.cellModel,\n cellNamespace: opt.cellNamespace,\n graph: this\n });\n Model.prototype.set.call(this, 'cells', cells);\n\n // Make all the events fired in the `cells` collection available.\n // to the outside world.\n cells.on('all', this.trigger, this);\n\n // JointJS automatically doesn't trigger re-sort if models attributes are changed later when\n // they're already in the collection. Therefore, we're triggering sort manually here.\n this.on('change:z', this._sortOnChangeZ, this);\n\n // `joint.dia.Graph` keeps an internal data structure (an adjacency list)\n // for fast graph queries. All changes that affect the structure of the graph\n // must be reflected in the `al` object. This object provides fast answers to\n // questions such as \"what are the neighbours of this node\" or \"what\n // are the sibling links of this link\".\n\n // Outgoing edges per node. Note that we use a hash-table for the list\n // of outgoing edges for a faster lookup.\n // [nodeId] -> Object [edgeId] -> true\n this._out = {};\n // Ingoing edges per node.\n // [nodeId] -> Object [edgeId] -> true\n this._in = {};\n // `_nodes` is useful for quick lookup of all the elements in the graph, without\n // having to go through the whole cells array.\n // [node ID] -> true\n this._nodes = {};\n // `_edges` is useful for quick lookup of all the links in the graph, without\n // having to go through the whole cells array.\n // [edgeId] -> true\n this._edges = {};\n\n this._batches = {};\n\n cells.on('add', this._restructureOnAdd, this);\n cells.on('remove', this._restructureOnRemove, this);\n cells.on('reset', this._restructureOnReset, this);\n cells.on('change:source', this._restructureOnChangeSource, this);\n cells.on('change:target', this._restructureOnChangeTarget, this);\n cells.on('remove', this._removeCell, this);\n },\n\n _sortOnChangeZ: function() {\n\n this.get('cells').sort();\n },\n\n _restructureOnAdd: function(cell) {\n\n if (cell.isLink()) {\n this._edges[cell.id] = true;\n var { source, target } = cell.attributes;\n if (source.id) {\n (this._out[source.id] || (this._out[source.id] = {}))[cell.id] = true;\n }\n if (target.id) {\n (this._in[target.id] || (this._in[target.id] = {}))[cell.id] = true;\n }\n } else {\n this._nodes[cell.id] = true;\n }\n },\n\n _restructureOnRemove: function(cell) {\n\n if (cell.isLink()) {\n delete this._edges[cell.id];\n var { source, target } = cell.attributes;\n if (source.id && this._out[source.id] && this._out[source.id][cell.id]) {\n delete this._out[source.id][cell.id];\n }\n if (target.id && this._in[target.id] && this._in[target.id][cell.id]) {\n delete this._in[target.id][cell.id];\n }\n } else {\n delete this._nodes[cell.id];\n }\n },\n\n _restructureOnReset: function(cells) {\n\n // Normalize into an array of cells. The original `cells` is GraphCells mvc collection.\n cells = cells.models;\n\n this._out = {};\n this._in = {};\n this._nodes = {};\n this._edges = {};\n\n cells.forEach(this._restructureOnAdd, this);\n },\n\n _restructureOnChangeSource: function(link) {\n\n var prevSource = link.previous('source');\n if (prevSource.id && this._out[prevSource.id]) {\n delete this._out[prevSource.id][link.id];\n }\n var source = link.attributes.source;\n if (source.id) {\n (this._out[source.id] || (this._out[source.id] = {}))[link.id] = true;\n }\n },\n\n _restructureOnChangeTarget: function(link) {\n\n var prevTarget = link.previous('target');\n if (prevTarget.id && this._in[prevTarget.id]) {\n delete this._in[prevTarget.id][link.id];\n }\n var target = link.get('target');\n if (target.id) {\n (this._in[target.id] || (this._in[target.id] = {}))[link.id] = true;\n }\n },\n\n // Return all outbound edges for the node. Return value is an object\n // of the form: [edgeId] -> true\n getOutboundEdges: function(node) {\n\n return (this._out && this._out[node]) || {};\n },\n\n // Return all inbound edges for the node. Return value is an object\n // of the form: [edgeId] -> true\n getInboundEdges: function(node) {\n\n return (this._in && this._in[node]) || {};\n },\n\n toJSON: function(opt = {}) {\n\n // JointJS does not recursively call `toJSON()` on attributes that are themselves models/collections.\n // It just clones the attributes. Therefore, we must call `toJSON()` on the cells collection explicitly.\n var json = Model.prototype.toJSON.apply(this, arguments);\n json.cells = this.get('cells').toJSON(opt.cellAttributes);\n return json;\n },\n\n fromJSON: function(json, opt) {\n\n if (!json.cells) {\n\n throw new Error('Graph JSON must contain cells array.');\n }\n\n return this.set(json, opt);\n },\n\n set: function(key, val, opt) {\n\n var attrs;\n\n // Handle both `key`, value and {key: value} style arguments.\n if (typeof key === 'object') {\n attrs = key;\n opt = val;\n } else {\n (attrs = {})[key] = val;\n }\n\n // Make sure that `cells` attribute is handled separately via resetCells().\n if (attrs.hasOwnProperty('cells')) {\n this.resetCells(attrs.cells, opt);\n attrs = util.omit(attrs, 'cells');\n }\n\n // The rest of the attributes are applied via original set method.\n return Model.prototype.set.call(this, attrs, opt);\n },\n\n clear: function(opt) {\n\n opt = util.assign({}, opt, { clear: true });\n\n var collection = this.get('cells');\n\n if (collection.length === 0) return this;\n\n this.startBatch('clear', opt);\n\n // The elements come after the links.\n var cells = collection.sortBy(function(cell) {\n return cell.isLink() ? 1 : 2;\n });\n\n do {\n\n // Remove all the cells one by one.\n // Note that all the links are removed first, so it's\n // safe to remove the elements without removing the connected\n // links first.\n cells.shift().remove(opt);\n\n } while (cells.length > 0);\n\n this.stopBatch('clear');\n\n return this;\n },\n\n _prepareCell: function(cell) {\n\n let attrs;\n if (cell instanceof Model) {\n attrs = cell.attributes;\n } else {\n attrs = cell;\n }\n\n if (!util.isString(attrs.type)) {\n throw new TypeError('dia.Graph: cell type must be a string.');\n }\n\n return cell;\n },\n\n minZIndex: function() {\n\n var firstCell = this.get('cells').first();\n return firstCell ? (firstCell.get('z') || 0) : 0;\n },\n\n maxZIndex: function() {\n\n var lastCell = this.get('cells').last();\n return lastCell ? (lastCell.get('z') || 0) : 0;\n },\n\n addCell: function(cell, opt) {\n\n if (Array.isArray(cell)) {\n\n return this.addCells(cell, opt);\n }\n\n if (cell instanceof Model) {\n\n if (!cell.has('z')) {\n cell.set('z', this.maxZIndex() + 1);\n }\n\n } else if (cell.z === undefined) {\n\n cell.z = this.maxZIndex() + 1;\n }\n\n this.get('cells').add(this._prepareCell(cell, opt), opt || {});\n\n return this;\n },\n\n addCells: function(cells, opt) {\n\n if (cells.length === 0) return this;\n\n cells = util.flattenDeep(cells);\n opt.maxPosition = opt.position = cells.length - 1;\n\n this.startBatch('add', opt);\n cells.forEach(function(cell) {\n this.addCell(cell, opt);\n opt.position--;\n }, this);\n this.stopBatch('add', opt);\n\n return this;\n },\n\n // When adding a lot of cells, it is much more efficient to\n // reset the entire cells collection in one go.\n // Useful for bulk operations and optimizations.\n resetCells: function(cells, opt) {\n\n var preparedCells = util.toArray(cells).map(function(cell) {\n return this._prepareCell(cell, opt);\n }, this);\n this.get('cells').reset(preparedCells, opt);\n\n return this;\n },\n\n removeCells: function(cells, opt) {\n\n if (cells.length) {\n\n this.startBatch('remove');\n util.invoke(cells, 'remove', opt);\n this.stopBatch('remove');\n }\n\n return this;\n },\n\n _removeCell: function(cell, collection, options) {\n\n options = options || {};\n\n if (!options.clear) {\n // Applications might provide a `disconnectLinks` option set to `true` in order to\n // disconnect links when a cell is removed rather then removing them. The default\n // is to remove all the associated links.\n if (options.disconnectLinks) {\n\n this.disconnectLinks(cell, options);\n\n } else {\n\n this.removeLinks(cell, options);\n }\n }\n // Silently remove the cell from the cells collection. Silently, because\n // `joint.dia.Cell.prototype.remove` already triggers the `remove` event which is\n // then propagated to the graph model. If we didn't remove the cell silently, two `remove` events\n // would be triggered on the graph model.\n this.get('cells').remove(cell, { silent: true });\n },\n\n transferCellEmbeds: function(sourceCell, targetCell, opt = {}) {\n\n const batchName = 'transfer-embeds';\n this.startBatch(batchName);\n\n // Embed children of the source cell in the target cell.\n const children = sourceCell.getEmbeddedCells();\n targetCell.embed(children, { ...opt, reparent: true });\n\n this.stopBatch(batchName);\n },\n\n transferCellConnectedLinks: function(sourceCell, targetCell, opt = {}) {\n\n const batchName = 'transfer-connected-links';\n this.startBatch(batchName);\n\n // Reconnect all the links connected to the old cell to the new cell.\n const connectedLinks = this.getConnectedLinks(sourceCell, opt);\n connectedLinks.forEach((link) => {\n\n if (link.getSourceCell() === sourceCell) {\n link.prop(['source', 'id'], targetCell.id, opt);\n }\n\n if (link.getTargetCell() === sourceCell) {\n link.prop(['target', 'id'], targetCell.id, opt);\n }\n });\n\n this.stopBatch(batchName);\n },\n\n // Get a cell by `id`.\n getCell: function(id) {\n\n return this.get('cells').get(id);\n },\n\n getCells: function() {\n\n return this.get('cells').toArray();\n },\n\n getElements: function() {\n\n return this.get('cells').toArray().filter(cell => cell.isElement());\n },\n\n getLinks: function() {\n\n return this.get('cells').toArray().filter(cell => cell.isLink());\n },\n\n getFirstCell: function() {\n\n return this.get('cells').first();\n },\n\n getLastCell: function() {\n\n return this.get('cells').last();\n },\n\n // Get all inbound and outbound links connected to the cell `model`.\n getConnectedLinks: function(model, opt) {\n\n opt = opt || {};\n\n var indirect = opt.indirect;\n var inbound = opt.inbound;\n var outbound = opt.outbound;\n if ((inbound === undefined) && (outbound === undefined)) {\n inbound = outbound = true;\n }\n\n // the final array of connected link models\n var links = [];\n // a hash table of connected edges of the form: [edgeId] -> true\n // used for quick lookups to check if we already added a link\n var edges = {};\n\n if (outbound) {\n addOutbounds(this, model);\n }\n if (inbound) {\n addInbounds(this, model);\n }\n\n function addOutbounds(graph, model) {\n util.forIn(graph.getOutboundEdges(model.id), function(_, edge) {\n // skip links that were already added\n // (those must be self-loop links)\n // (because they are inbound and outbound edges of the same two elements)\n if (edges[edge]) return;\n var link = graph.getCell(edge);\n links.push(link);\n edges[edge] = true;\n if (indirect) {\n if (inbound) addInbounds(graph, link);\n if (outbound) addOutbounds(graph, link);\n }\n }.bind(graph));\n if (indirect && model.isLink()) {\n var outCell = model.getTargetCell();\n if (outCell && outCell.isLink()) {\n if (!edges[outCell.id]) {\n links.push(outCell);\n addOutbounds(graph, outCell);\n }\n }\n }\n }\n\n function addInbounds(graph, model) {\n util.forIn(graph.getInboundEdges(model.id), function(_, edge) {\n // skip links that were already added\n // (those must be self-loop links)\n // (because they are inbound and outbound edges of the same two elements)\n if (edges[edge]) return;\n var link = graph.getCell(edge);\n links.push(link);\n edges[edge] = true;\n if (indirect) {\n if (inbound) addInbounds(graph, link);\n if (outbound) addOutbounds(graph, link);\n }\n }.bind(graph));\n if (indirect && model.isLink()) {\n var inCell = model.getSourceCell();\n if (inCell && inCell.isLink()) {\n if (!edges[inCell.id]) {\n links.push(inCell);\n addInbounds(graph, inCell);\n }\n }\n }\n }\n\n // if `deep` option is `true`, check also all the links that are connected to any of the descendant cells\n if (opt.deep) {\n\n var embeddedCells = model.getEmbeddedCells({ deep: true });\n\n // in the first round, we collect all the embedded elements\n var embeddedElements = {};\n embeddedCells.forEach(function(cell) {\n if (cell.isElement()) {\n embeddedElements[cell.id] = true;\n }\n });\n\n embeddedCells.forEach(function(cell) {\n if (cell.isLink()) return;\n if (outbound) {\n util.forIn(this.getOutboundEdges(cell.id), function(exists, edge) {\n if (!edges[edge]) {\n var edgeCell = this.getCell(edge);\n var { source, target } = edgeCell.attributes;\n var sourceId = source.id;\n var targetId = target.id;\n\n // if `includeEnclosed` option is falsy, skip enclosed links\n if (!opt.includeEnclosed\n && (sourceId && embeddedElements[sourceId])\n && (targetId && embeddedElements[targetId])) {\n return;\n }\n\n links.push(this.getCell(edge));\n edges[edge] = true;\n }\n }.bind(this));\n }\n if (inbound) {\n util.forIn(this.getInboundEdges(cell.id), function(exists, edge) {\n if (!edges[edge]) {\n var edgeCell = this.getCell(edge);\n var { source, target } = edgeCell.attributes;\n var sourceId = source.id;\n var targetId = target.id;\n\n // if `includeEnclosed` option is falsy, skip enclosed links\n if (!opt.includeEnclosed\n && (sourceId && embeddedElements[sourceId])\n && (targetId && embeddedElements[targetId])) {\n return;\n }\n\n links.push(this.getCell(edge));\n edges[edge] = true;\n }\n }.bind(this));\n }\n }, this);\n }\n\n return links;\n },\n\n getNeighbors: function(model, opt) {\n\n opt || (opt = {});\n\n var inbound = opt.inbound;\n var outbound = opt.outbound;\n if (inbound === undefined && outbound === undefined) {\n inbound = outbound = true;\n }\n\n var neighbors = this.getConnectedLinks(model, opt).reduce(function(res, link) {\n\n var { source, target } = link.attributes;\n var loop = link.hasLoop(opt);\n\n // Discard if it is a point, or if the neighbor was already added.\n if (inbound && util.has(source, 'id') && !res[source.id]) {\n\n var sourceElement = this.getCell(source.id);\n if (sourceElement.isElement()) {\n if (loop || (sourceElement && sourceElement !== model && (!opt.deep || !sourceElement.isEmbeddedIn(model)))) {\n res[source.id] = sourceElement;\n }\n }\n }\n\n // Discard if it is a point, or if the neighbor was already added.\n if (outbound && util.has(target, 'id') && !res[target.id]) {\n\n var targetElement = this.getCell(target.id);\n if (targetElement.isElement()) {\n if (loop || (targetElement && targetElement !== model && (!opt.deep || !targetElement.isEmbeddedIn(model)))) {\n res[target.id] = targetElement;\n }\n }\n }\n\n return res;\n }.bind(this), {});\n\n if (model.isLink()) {\n if (inbound) {\n var sourceCell = model.getSourceCell();\n if (sourceCell && sourceCell.isElement() && !neighbors[sourceCell.id]) {\n neighbors[sourceCell.id] = sourceCell;\n }\n }\n if (outbound) {\n var targetCell = model.getTargetCell();\n if (targetCell && targetCell.isElement() && !neighbors[targetCell.id]) {\n neighbors[targetCell.id] = targetCell;\n }\n }\n }\n\n return util.toArray(neighbors);\n },\n\n getCommonAncestor: function(/* cells */) {\n\n var cellsAncestors = Array.from(arguments).map(function(cell) {\n\n var ancestors = [];\n var parentId = cell.get('parent');\n\n while (parentId) {\n\n ancestors.push(parentId);\n parentId = this.getCell(parentId).get('parent');\n }\n\n return ancestors;\n\n }, this);\n\n cellsAncestors = cellsAncestors.sort(function(a, b) {\n return a.length - b.length;\n });\n\n var commonAncestor = util.toArray(cellsAncestors.shift()).find(function(ancestor) {\n return cellsAncestors.every(function(cellAncestors) {\n return cellAncestors.includes(ancestor);\n });\n });\n\n return this.getCell(commonAncestor);\n },\n\n // Find the whole branch starting at `element`.\n // If `opt.deep` is `true`, take into account embedded elements too.\n // If `opt.breadthFirst` is `true`, use the Breadth-first search algorithm, otherwise use Depth-first search.\n getSuccessors: function(element, opt) {\n\n opt = opt || {};\n var res = [];\n // Modify the options so that it includes the `outbound` neighbors only. In other words, search forwards.\n this.search(element, function(el) {\n if (el !== element) {\n res.push(el);\n }\n }, util.assign({}, opt, { outbound: true }));\n return res;\n },\n\n cloneCells: cloneCells,\n // Clone the whole subgraph (including all the connected links whose source/target is in the subgraph).\n // If `opt.deep` is `true`, also take into account all the embedded cells of all the subgraph cells.\n // Return a map of the form: [original cell ID] -> [clone].\n cloneSubgraph: function(cells, opt) {\n\n var subgraph = this.getSubgraph(cells, opt);\n return this.cloneCells(subgraph);\n },\n\n // Return `cells` and all the connected links that connect cells in the `cells` array.\n // If `opt.deep` is `true`, return all the cells including all their embedded cells\n // and all the links that connect any of the returned cells.\n // For example, for a single shallow element, the result is that very same element.\n // For two elements connected with a link: `A --- L ---> B`, the result for\n // `getSubgraph([A, B])` is `[A, L, B]`. The same goes for `getSubgraph([L])`, the result is again `[A, L, B]`.\n getSubgraph: function(cells, opt) {\n\n opt = opt || {};\n\n var subgraph = [];\n // `cellMap` is used for a quick lookup of existence of a cell in the `cells` array.\n var cellMap = {};\n var elements = [];\n var links = [];\n\n util.toArray(cells).forEach(function(cell) {\n if (!cellMap[cell.id]) {\n subgraph.push(cell);\n cellMap[cell.id] = cell;\n if (cell.isLink()) {\n links.push(cell);\n } else {\n elements.push(cell);\n }\n }\n\n if (opt.deep) {\n var embeds = cell.getEmbeddedCells({ deep: true });\n embeds.forEach(function(embed) {\n if (!cellMap[embed.id]) {\n subgraph.push(embed);\n cellMap[embed.id] = embed;\n if (embed.isLink()) {\n links.push(embed);\n } else {\n elements.push(embed);\n }\n }\n });\n }\n });\n\n links.forEach(function(link) {\n // For links, return their source & target (if they are elements - not points).\n var { source, target } = link.attributes;\n if (source.id && !cellMap[source.id]) {\n var sourceElement = this.getCell(source.id);\n subgraph.push(sourceElement);\n cellMap[sourceElement.id] = sourceElement;\n elements.push(sourceElement);\n }\n if (target.id && !cellMap[target.id]) {\n var targetElement = this.getCell(target.id);\n subgraph.push(this.getCell(target.id));\n cellMap[targetElement.id] = targetElement;\n elements.push(targetElement);\n }\n }, this);\n\n elements.forEach(function(element) {\n // For elements, include their connected links if their source/target is in the subgraph;\n var links = this.getConnectedLinks(element, opt);\n links.forEach(function(link) {\n var { source, target } = link.attributes;\n if (!cellMap[link.id] && source.id && cellMap[source.id] && target.id && cellMap[target.id]) {\n subgraph.push(link);\n cellMap[link.id] = link;\n }\n });\n }, this);\n\n return subgraph;\n },\n\n // Find all the predecessors of `element`. This is a reverse operation of `getSuccessors()`.\n // If `opt.deep` is `true`, take into account embedded elements too.\n // If `opt.breadthFirst` is `true`, use the Breadth-first search algorithm, otherwise use Depth-first search.\n getPredecessors: function(element, opt) {\n\n opt = opt || {};\n var res = [];\n // Modify the options so that it includes the `inbound` neighbors only. In other words, search backwards.\n this.search(element, function(el) {\n if (el !== element) {\n res.push(el);\n }\n }, util.assign({}, opt, { inbound: true }));\n return res;\n },\n\n // Perform search on the graph.\n // If `opt.breadthFirst` is `true`, use the Breadth-first Search algorithm, otherwise use Depth-first search.\n // By setting `opt.inbound` to `true`, you can reverse the direction of the search.\n // If `opt.deep` is `true`, take into account embedded elements too.\n // `iteratee` is a function of the form `function(element) {}`.\n // If `iteratee` explicitly returns `false`, the searching stops.\n search: function(element, iteratee, opt) {\n\n opt = opt || {};\n if (opt.breadthFirst) {\n this.bfs(element, iteratee, opt);\n } else {\n this.dfs(element, iteratee, opt);\n }\n },\n\n // Breadth-first search.\n // If `opt.deep` is `true`, take into account embedded elements too.\n // If `opt.inbound` is `true`, reverse the search direction (it's like reversing all the link directions).\n // `iteratee` is a function of the form `function(element, distance) {}`.\n // where `element` is the currently visited element and `distance` is the distance of that element\n // from the root `element` passed the `bfs()`, i.e. the element we started the search from.\n // Note that the `distance` is not the shortest or longest distance, it is simply the number of levels\n // crossed till we visited the `element` for the first time. It is especially useful for tree graphs.\n // If `iteratee` explicitly returns `false`, the searching stops.\n bfs: function(element, iteratee, opt = {}) {\n\n const visited = {};\n const distance = {};\n const queue = [];\n\n queue.push(element);\n distance[element.id] = 0;\n\n while (queue.length > 0) {\n var next = queue.shift();\n if (visited[next.id]) continue;\n visited[next.id] = true;\n if (iteratee.call(this, next, distance[next.id]) === false) continue;\n const neighbors = this.getNeighbors(next, opt);\n for (let i = 0, n = neighbors.length; i < n; i++) {\n const neighbor = neighbors[i];\n distance[neighbor.id] = distance[next.id] + 1;\n queue.push(neighbor);\n }\n }\n },\n\n // Depth-first search.\n // If `opt.deep` is `true`, take into account embedded elements too.\n // If `opt.inbound` is `true`, reverse the search direction (it's like reversing all the link directions).\n // `iteratee` is a function of the form `function(element, distance) {}`.\n // If `iteratee` explicitly returns `false`, the search stops.\n dfs: function(element, iteratee, opt = {}) {\n\n const visited = {};\n const distance = {};\n const queue = [];\n\n queue.push(element);\n distance[element.id] = 0;\n\n while (queue.length > 0) {\n const next = queue.pop();\n if (visited[next.id]) continue;\n visited[next.id] = true;\n if (iteratee.call(this, next, distance[next.id]) === false) continue;\n const neighbors = this.getNeighbors(next, opt);\n const lastIndex = queue.length;\n for (let i = 0, n = neighbors.length; i < n; i++) {\n const neighbor = neighbors[i];\n distance[neighbor.id] = distance[next.id] + 1;\n queue.splice(lastIndex, 0, neighbor);\n }\n }\n },\n\n // Get all the roots of the graph. Time complexity: O(|V|).\n getSources: function() {\n\n var sources = [];\n util.forIn(this._nodes, function(exists, node) {\n if (!this._in[node] || util.isEmpty(this._in[node])) {\n sources.push(this.getCell(node));\n }\n }.bind(this));\n return sources;\n },\n\n // Get all the leafs of the graph. Time complexity: O(|V|).\n getSinks: function() {\n\n var sinks = [];\n util.forIn(this._nodes, function(exists, node) {\n if (!this._out[node] || util.isEmpty(this._out[node])) {\n sinks.push(this.getCell(node));\n }\n }.bind(this));\n return sinks;\n },\n\n // Return `true` if `element` is a root. Time complexity: O(1).\n isSource: function(element) {\n\n return !this._in[element.id] || util.isEmpty(this._in[element.id]);\n },\n\n // Return `true` if `element` is a leaf. Time complexity: O(1).\n isSink: function(element) {\n\n return !this._out[element.id] || util.isEmpty(this._out[element.id]);\n },\n\n // Return `true` is `elementB` is a successor of `elementA`. Return `false` otherwise.\n isSuccessor: function(elementA, elementB) {\n\n var isSuccessor = false;\n this.search(elementA, function(element) {\n if (element === elementB && element !== elementA) {\n isSuccessor = true;\n return false;\n }\n }, { outbound: true });\n return isSuccessor;\n },\n\n // Return `true` is `elementB` is a predecessor of `elementA`. Return `false` otherwise.\n isPredecessor: function(elementA, elementB) {\n\n var isPredecessor = false;\n this.search(elementA, function(element) {\n if (element === elementB && element !== elementA) {\n isPredecessor = true;\n return false;\n }\n }, { inbound: true });\n return isPredecessor;\n },\n\n // Return `true` is `elementB` is a neighbor of `elementA`. Return `false` otherwise.\n // `opt.deep` controls whether to take into account embedded elements as well. See `getNeighbors()`\n // for more details.\n // If `opt.outbound` is set to `true`, return `true` only if `elementB` is a successor neighbor.\n // Similarly, if `opt.inbound` is set to `true`, return `true` only if `elementB` is a predecessor neighbor.\n isNeighbor: function(elementA, elementB, opt) {\n\n opt = opt || {};\n\n var inbound = opt.inbound;\n var outbound = opt.outbound;\n if ((inbound === undefined) && (outbound === undefined)) {\n inbound = outbound = true;\n }\n\n var isNeighbor = false;\n\n this.getConnectedLinks(elementA, opt).forEach(function(link) {\n\n var { source, target } = link.attributes;\n\n // Discard if it is a point.\n if (inbound && util.has(source, 'id') && (source.id === elementB.id)) {\n isNeighbor = true;\n return false;\n }\n\n // Discard if it is a point, or if the neighbor was already added.\n if (outbound && util.has(target, 'id') && (target.id === elementB.id)) {\n isNeighbor = true;\n return false;\n }\n });\n\n return isNeighbor;\n },\n\n // Disconnect links connected to the cell `model`.\n disconnectLinks: function(model, opt) {\n\n this.getConnectedLinks(model).forEach(function(link) {\n\n link.set((link.attributes.source.id === model.id ? 'source' : 'target'), { x: 0, y: 0 }, opt);\n });\n },\n\n // Remove links connected to the cell `model` completely.\n removeLinks: function(model, opt) {\n\n util.invoke(this.getConnectedLinks(model), 'remove', opt);\n },\n\n // Find all cells at given point\n\n findElementsAtPoint: function(point, opt) {\n return this._filterAtPoint(this.getElements(), point, opt);\n },\n\n findLinksAtPoint: function(point, opt) {\n return this._filterAtPoint(this.getLinks(), point, opt);\n },\n\n findCellsAtPoint: function(point, opt) {\n return this._filterAtPoint(this.getCells(), point, opt);\n },\n\n _filterAtPoint: function(cells, point, opt = {}) {\n return cells.filter(el => el.getBBox({ rotate: true }).containsPoint(point, opt));\n },\n\n // Find all cells in given area\n\n findElementsInArea: function(area, opt = {}) {\n return this._filterInArea(this.getElements(), area, opt);\n },\n\n findLinksInArea: function(area, opt = {}) {\n return this._filterInArea(this.getLinks(), area, opt);\n },\n\n findCellsInArea: function(area, opt = {}) {\n return this._filterInArea(this.getCells(), area, opt);\n },\n\n _filterInArea: function(cells, area, opt = {}) {\n const r = new g.Rect(area);\n const { strict = false } = opt;\n const method = strict ? 'containsRect' : 'intersect';\n return cells.filter(el => r[method](el.getBBox({ rotate: true })));\n },\n\n // Find all cells under the given element.\n\n findElementsUnderElement: function(element, opt) {\n return this._filterCellsUnderElement(this.getElements(), element, opt);\n },\n\n findLinksUnderElement: function(element, opt) {\n return this._filterCellsUnderElement(this.getLinks(), element, opt);\n },\n\n findCellsUnderElement: function(element, opt) {\n return this._filterCellsUnderElement(this.getCells(), element, opt);\n },\n\n _isValidElementUnderElement: function(el1, el2) {\n return el1.id !== el2.id && !el1.isEmbeddedIn(el2);\n },\n\n _isValidLinkUnderElement: function(link, el) {\n return (\n link.source().id !== el.id &&\n link.target().id !== el.id &&\n !link.isEmbeddedIn(el)\n );\n },\n\n _validateCellsUnderElement: function(cells, element) {\n return cells.filter(cell => {\n return cell.isLink()\n ? this._isValidLinkUnderElement(cell, element)\n : this._isValidElementUnderElement(cell, element);\n });\n },\n\n _getFindUnderElementGeometry: function(element, searchBy = 'bbox') {\n const bbox = element.getBBox({ rotate: true });\n return (searchBy !== 'bbox') ? util.getRectPoint(bbox, searchBy) : bbox;\n },\n\n _filterCellsUnderElement: function(cells, element, opt = {}) {\n const geometry = this._getFindUnderElementGeometry(element, opt.searchBy);\n const filteredCells = (geometry.type === g.types.Point)\n ? this._filterAtPoint(cells, geometry)\n : this._filterInArea(cells, geometry, opt);\n return this._validateCellsUnderElement(filteredCells, element);\n },\n\n // @deprecated use `findElementsInArea` instead\n findModelsInArea: function(area, opt) {\n return this.findElementsInArea(area, opt);\n },\n\n // @deprecated use `findElementsAtPoint` instead\n findModelsFromPoint: function(point) {\n return this.findElementsAtPoint(point);\n },\n\n // @deprecated use `findModelsUnderElement` instead\n findModelsUnderElement: function(element, opt) {\n return this.findElementsUnderElement(element, opt);\n },\n\n // Return bounding box of all elements.\n getBBox: function() {\n\n return this.getCellsBBox(this.getCells());\n },\n\n // Return the bounding box of all cells in array provided.\n getCellsBBox: function(cells, opt = {}) {\n const { rotate = true } = opt;\n return util.toArray(cells).reduce(function(memo, cell) {\n const rect = cell.getBBox({ rotate });\n if (!rect) return memo;\n if (memo) {\n return memo.union(rect);\n }\n return rect;\n }, null);\n },\n\n translate: function(dx, dy, opt) {\n\n // Don't translate cells that are embedded in any other cell.\n var cells = this.getCells().filter(function(cell) {\n return !cell.isEmbedded();\n });\n\n util.invoke(cells, 'translate', dx, dy, opt);\n\n return this;\n },\n\n resize: function(width, height, opt) {\n\n return this.resizeCells(width, height, this.getCells(), opt);\n },\n\n resizeCells: function(width, height, cells, opt) {\n\n // `getBBox` method returns `null` if no elements provided.\n // i.e. cells can be an array of links\n var bbox = this.getCellsBBox(cells);\n if (bbox) {\n var sx = Math.max(width / bbox.width, 0);\n var sy = Math.max(height / bbox.height, 0);\n util.invoke(cells, 'scale', sx, sy, bbox.origin(), opt);\n }\n\n return this;\n },\n\n startBatch: function(name, data) {\n\n data = data || {};\n this._batches[name] = (this._batches[name] || 0) + 1;\n\n return this.trigger('batch:start', util.assign({}, data, { batchName: name }));\n },\n\n stopBatch: function(name, data) {\n\n data = data || {};\n this._batches[name] = (this._batches[name] || 0) - 1;\n\n return this.trigger('batch:stop', util.assign({}, data, { batchName: name }));\n },\n\n hasActiveBatch: function(name) {\n\n const batches = this._batches;\n let names;\n\n if (arguments.length === 0) {\n names = Object.keys(batches);\n } else if (Array.isArray(name)) {\n names = name;\n } else {\n names = [name];\n }\n\n return names.some((batch) => batches[batch] > 0);\n }\n\n}, {\n\n validations: {\n\n multiLinks: function(graph, link) {\n\n // Do not allow multiple links to have the same source and target.\n var { source, target } = link.attributes;\n\n if (source.id && target.id) {\n\n var sourceModel = link.getSourceCell();\n if (sourceModel) {\n\n var connectedLinks = graph.getConnectedLinks(sourceModel, { outbound: true });\n var sameLinks = connectedLinks.filter(function(_link) {\n\n var { source: _source, target: _target } = _link.attributes;\n return _source && _source.id === source.id &&\n (!_source.port || (_source.port === source.port)) &&\n _target && _target.id === target.id &&\n (!_target.port || (_target.port === target.port));\n\n });\n\n if (sameLinks.length > 1) {\n return false;\n }\n }\n }\n\n return true;\n },\n\n linkPinning: function(_graph, link) {\n var { source, target } = link.attributes;\n return source.id && target.id;\n }\n }\n\n});\n\nwrapWith(Graph.prototype, ['resetCells', 'addCells', 'removeCells'], wrappers.cells);\n","import $ from './Dom/index.mjs';\n\nimport { Events } from './Events.mjs';\nimport { extend } from './mvcUtils.mjs';\nimport {\n assign,\n isFunction,\n pick,\n result,\n uniqueId\n} from '../util/util.mjs';\n\n// ViewBase\n// -------------\n\n// ViewBases are almost more convention than they are actual code. A View\n// is simply a JavaScript object that represents a logical chunk of UI in the\n// DOM. This might be a single item, an entire list, a sidebar or panel, or\n// even the surrounding frame which wraps your whole app. Defining a chunk of\n// UI as a **View** allows you to define your DOM events declaratively, without\n// having to worry about render order ... and makes it easy for the view to\n// react to specific changes in the state of your models.\n\n// Creating a ViewBase creates its initial element outside of the DOM,\n// if an existing element is not provided...\nexport var ViewBase = function(options) {\n this.cid = uniqueId('view');\n this.preinitialize.apply(this, arguments);\n assign(this, pick(options, viewOptions));\n this._ensureElement();\n this.initialize.apply(this, arguments);\n};\n\n// Cached regex to split keys for `delegate`.\nvar delegateEventSplitter = /^(\\S+)\\s*(.*)$/;\n\n// List of view options to be set as properties.\n// TODO: `style` attribute is not supported in ViewBase class yet, but only in View class that extends ViewBase.\nvar viewOptions = ['model', 'collection', 'el', 'id', 'attributes', 'className', 'tagName', 'events', 'style'];\n\n// Set up all inheritable **ViewBase** properties and methods.\nassign(ViewBase.prototype, Events, {\n\n // The default `tagName` of a View's element is `\"div\"`.\n tagName: 'div',\n\n // mvc.$ delegate for element lookup, scoped to DOM elements within the\n // current view. This should be preferred to global lookups where possible.\n $: function(selector) {\n return this.$el.find(selector);\n },\n\n // preinitialize is an empty function by default. You can override it with a function\n // or object. preinitialize will run before any instantiation logic is run in the View\n preinitialize: function(){},\n\n // Initialize is an empty function by default. Override it with your own\n // initialization logic.\n initialize: function(){},\n\n // **render** is the core function that your view should override, in order\n // to populate its element (`this.el`), with the appropriate HTML. The\n // convention is for **render** to always return `this`.\n render: function() {\n return this;\n },\n\n // Remove this view by taking the element out of the DOM, and removing any\n // applicable Events listeners.\n remove: function() {\n this._removeElement();\n this.stopListening();\n return this;\n },\n\n // Remove this view's element from the document and all event listeners\n // attached to it. Exposed for subclasses using an alternative DOM\n // manipulation API.\n _removeElement: function() {\n this.$el.remove();\n },\n\n // Change the view's element (`this.el` property) and re-delegate the\n // view's events on the new element.\n setElement: function(element) {\n this.undelegateEvents();\n this._setElement(element);\n this.delegateEvents();\n return this;\n },\n\n // Creates the `this.el` and `this.$el` references for this view using the\n // given `el`. `el` can be a CSS selector or an HTML string, a mvc.$\n // context or an element. Subclasses can override this to utilize an\n // alternative DOM manipulation API and are only required to set the\n // `this.el` property.\n _setElement: function(el) {\n this.$el = el instanceof $ ? el : $(el);\n this.el = this.$el[0];\n },\n\n // Set callbacks, where `this.events` is a hash of\n //\n // *{\"event selector\": \"callback\"}*\n //\n // {\n // 'mousedown .title': 'edit',\n // 'click .button': 'save',\n // 'click .open': function(e) { ... }\n // }\n //\n // pairs. Callbacks will be bound to the view, with `this` set properly.\n // Uses event delegation for efficiency.\n // Omitting the selector binds the event to `this.el`.\n delegateEvents: function(events) {\n events || (events = result(this, 'events'));\n if (!events) return this;\n this.undelegateEvents();\n for (var key in events) {\n var method = events[key];\n if (!isFunction(method)) method = this[method];\n if (!method) continue;\n var match = key.match(delegateEventSplitter);\n this.delegate(match[1], match[2], method.bind(this));\n }\n return this;\n },\n\n // Add a single event listener to the view's element (or a child element\n // using `selector`). This only works for delegate-able events: not `focus`,\n // `blur`, and not `change`, `submit`, and `reset` in Internet Explorer.\n delegate: function(eventName, selector, listener) {\n this.$el.on(eventName + '.delegateEvents' + this.cid, selector, listener);\n return this;\n },\n\n // Clears all callbacks previously bound to the view by `delegateEvents`.\n // You usually don't need to use this, but may wish to if you have multiple\n // viewbases attached to the same DOM element.\n undelegateEvents: function() {\n if (this.$el) this.$el.off('.delegateEvents' + this.cid);\n return this;\n },\n\n // A finer-grained `undelegateEvents` for removing a single delegated event.\n // `selector` and `listener` are both optional.\n undelegate: function(eventName, selector, listener) {\n this.$el.off(eventName + '.delegateEvents' + this.cid, selector, listener);\n return this;\n },\n\n // Produces a DOM element to be assigned to your view. Exposed for\n // subclasses using an alternative DOM manipulation API.\n _createElement: function(tagName) {\n return document.createElement(tagName);\n },\n\n // Ensure that the View has a DOM element to render into.\n // If `this.el` is a string, pass it through `$()`, take the first\n // matching element, and re-assign it to `el`. Otherwise, create\n // an element from the `id`, `className` and `tagName` properties.\n _ensureElement: function() {\n if (!this.el) {\n var attrs = assign({}, result(this, 'attributes'));\n if (this.id) attrs.id = result(this, 'id');\n if (this.className) attrs['class'] = result(this, 'className');\n this.setElement(this._createElement(result(this, 'tagName')));\n this._setAttributes(attrs);\n } else {\n this.setElement(result(this, 'el'));\n }\n },\n\n // Set attributes from a hash on this view's element. Exposed for\n // subclasses using an alternative DOM manipulation API.\n _setAttributes: function(attributes) {\n this.$el.attr(attributes);\n }\n\n});\n\n// Set up inheritance for the view.\nViewBase.extend = extend;\n","import $ from './Dom/index.mjs';\nimport * as util from '../util/index.mjs';\nimport V from '../V/index.mjs';\nimport { ViewBase } from './ViewBase.mjs';\nimport { config } from '../config/index.mjs';\n\nexport const views = {};\n\nexport const View = ViewBase.extend({\n\n options: {},\n theme: null,\n themeClassNamePrefix: util.addClassNamePrefix('theme-'),\n requireSetThemeOverride: false,\n defaultTheme: config.defaultTheme,\n children: null,\n childNodes: null,\n\n DETACHABLE: true,\n UPDATE_PRIORITY: 2,\n FLAG_INSERT: 1<<30,\n FLAG_REMOVE: 1<<29,\n FLAG_INIT: 1<<28,\n\n constructor: function(options) {\n\n this.requireSetThemeOverride = options && !!options.theme;\n this.options = util.assign({}, this.options, options);\n\n ViewBase.call(this, options);\n },\n\n initialize: function() {\n\n views[this.cid] = this;\n\n this.setTheme(this.options.theme || this.defaultTheme);\n this.init();\n },\n\n unmount: function() {\n if (this.svgElement) {\n this.vel.remove();\n } else {\n this.$el.remove();\n }\n },\n\n isMounted: function() {\n return this.el.parentNode !== null;\n },\n\n renderChildren: function(children) {\n children || (children = util.result(this, 'children'));\n if (children) {\n var isSVG = this.svgElement;\n var namespace = V.namespace[isSVG ? 'svg' : 'xhtml'];\n var doc = util.parseDOMJSON(children, namespace);\n (isSVG ? this.vel : this.$el).empty().append(doc.fragment);\n this.childNodes = doc.selectors;\n }\n return this;\n },\n\n findAttributeNode: function(attributeName, node) {\n let currentNode = node;\n while (currentNode && currentNode.nodeType === 1) {\n // attribute found\n // (empty value does not count as attribute found)\n if (currentNode.getAttribute(attributeName)) return currentNode;\n // do not climb up the DOM\n if (currentNode === this.el) return null;\n // try parent node\n currentNode = currentNode.parentNode;\n }\n return null;\n },\n\n findAttribute: function(attributeName, node) {\n const matchedNode = this.findAttributeNode(attributeName, node);\n return matchedNode && matchedNode.getAttribute(attributeName);\n },\n\n // Override the mvc ViewBase `_ensureElement()` method in order to create an\n // svg element (e.g., `<g>`) node that wraps all the nodes of the Cell view.\n // Expose class name setter as a separate method.\n _ensureElement: function() {\n if (!this.el) {\n var tagName = util.result(this, 'tagName');\n var attrs = util.assign({}, util.result(this, 'attributes'));\n var style = util.assign({}, util.result(this, 'style'));\n if (this.id) attrs.id = util.result(this, 'id');\n this.setElement(this._createElement(tagName));\n this._setAttributes(attrs);\n this._setStyle(style);\n } else {\n this.setElement(util.result(this, 'el'));\n }\n this._ensureElClassName();\n },\n\n _setAttributes: function(attrs) {\n if (this.svgElement) {\n this.vel.attr(attrs);\n } else {\n this.$el.attr(attrs);\n }\n },\n\n _setStyle: function(style) {\n this.$el.css(style);\n },\n\n _createElement: function(tagName) {\n if (this.svgElement) {\n return document.createElementNS(V.namespace.svg, tagName);\n } else {\n return document.createElement(tagName);\n }\n },\n\n // Utilize an alternative DOM manipulation API by\n // adding an element reference wrapped in Vectorizer.\n _setElement: function(el) {\n this.$el = el instanceof $ ? el : $(el);\n this.el = this.$el[0];\n if (this.svgElement) this.vel = V(this.el);\n },\n\n _ensureElClassName: function() {\n var className = util.result(this, 'className');\n if (!className) return;\n var prefixedClassName = util.addClassNamePrefix(className);\n // Note: className removal here kept for backwards compatibility only\n if (this.svgElement) {\n this.vel.removeClass(className).addClass(prefixedClassName);\n } else {\n this.$el.removeClass(className).addClass(prefixedClassName);\n }\n },\n\n init: function() {\n // Intentionally empty.\n // This method is meant to be overridden.\n },\n\n onRender: function() {\n // Intentionally empty.\n // This method is meant to be overridden.\n },\n\n confirmUpdate: function() {\n // Intentionally empty.\n // This method is meant to be overridden.\n return 0;\n },\n\n setTheme: function(theme, opt) {\n\n opt = opt || {};\n\n // Theme is already set, override is required, and override has not been set.\n // Don't set the theme.\n if (this.theme && this.requireSetThemeOverride && !opt.override) {\n return this;\n }\n\n this.removeThemeClassName();\n this.addThemeClassName(theme);\n this.onSetTheme(this.theme/* oldTheme */, theme/* newTheme */);\n this.theme = theme;\n\n return this;\n },\n\n addThemeClassName: function(theme) {\n\n theme = theme || this.theme;\n if (!theme) return this;\n\n var className = this.themeClassNamePrefix + theme;\n\n if (this.svgElement) {\n this.vel.addClass(className);\n } else {\n this.$el.addClass(className);\n }\n\n return this;\n },\n\n removeThemeClassName: function(theme) {\n\n theme = theme || this.theme;\n\n var className = this.themeClassNamePrefix + theme;\n\n if (this.svgElement) {\n this.vel.removeClass(className);\n } else {\n this.$el.removeClass(className);\n }\n\n return this;\n },\n\n onSetTheme: function(oldTheme, newTheme) {\n // Intentionally empty.\n // This method is meant to be overridden.\n },\n\n remove: function() {\n\n this.onRemove();\n this.undelegateDocumentEvents();\n\n views[this.cid] = null;\n\n ViewBase.prototype.remove.apply(this, arguments);\n\n return this;\n },\n\n onRemove: function() {\n // Intentionally empty.\n // This method is meant to be overridden.\n },\n\n getEventNamespace: function() {\n // Returns a per-session unique namespace\n return '.joint-event-ns-' + this.cid;\n },\n\n delegateElementEvents: function(element, events, data) {\n if (!events) return this;\n data || (data = {});\n var eventNS = this.getEventNamespace();\n for (var eventName in events) {\n var method = events[eventName];\n if (typeof method !== 'function') method = this[method];\n if (!method) continue;\n $(element).on(eventName + eventNS, data, method.bind(this));\n }\n return this;\n },\n\n undelegateElementEvents: function(element) {\n $(element).off(this.getEventNamespace());\n return this;\n },\n\n delegateDocumentEvents: function(events, data) {\n events || (events = util.result(this, 'documentEvents'));\n return this.delegateElementEvents(document, events, data);\n },\n\n undelegateDocumentEvents: function() {\n return this.undelegateElementEvents(document);\n },\n\n eventData: function(evt, data) {\n if (!evt) throw new Error('eventData(): event object required.');\n var currentData = evt.data;\n var key = '__' + this.cid + '__';\n if (data === undefined) {\n if (!currentData) return {};\n return currentData[key] || {};\n }\n currentData || (currentData = evt.data = {});\n currentData[key] || (currentData[key] = {});\n util.assign(currentData[key], data);\n return this;\n },\n\n stopPropagation: function(evt) {\n this.eventData(evt, { propagationStopped: true });\n return this;\n },\n\n isPropagationStopped: function(evt) {\n return !!this.eventData(evt).propagationStopped;\n }\n\n}, {\n\n extend: function() {\n\n var args = Array.from(arguments);\n\n // Deep clone the prototype and static properties objects.\n // This prevents unexpected behavior where some properties are overwritten outside of this function.\n var protoProps = args[0] && util.assign({}, args[0]) || {};\n var staticProps = args[1] && util.assign({}, args[1]) || {};\n\n // Need the real render method so that we can wrap it and call it later.\n var renderFn = protoProps.render || (this.prototype && this.prototype.render) || null;\n\n /*\n Wrap the real render method so that:\n .. `onRender` is always called.\n .. `this` is always returned.\n */\n protoProps.render = function() {\n\n if (typeof renderFn === 'function') {\n // Call the original render method.\n renderFn.apply(this, arguments);\n }\n\n if (this.render.__render__ === renderFn) {\n // Should always call onRender() method.\n // Should call it only once when renderFn is actual prototype method i.e. not the wrapper\n this.onRender();\n }\n\n // Should always return itself.\n return this;\n };\n\n protoProps.render.__render__ = renderFn;\n\n return ViewBase.extend.call(this, protoProps, staticProps);\n }\n});\n","import * as mvc from '../mvc/index.mjs';\nimport V from '../V/index.mjs';\nimport { isPlainObject, result } from '../util/util.mjs';\n\nfunction toArray(obj) {\n if (!obj) return [];\n if (Array.isArray(obj)) return obj;\n return [obj];\n}\n\nexport const HighlighterView = mvc.View.extend({\n\n tagName: 'g',\n svgElement: true,\n className: 'highlight',\n\n HIGHLIGHT_FLAG: 1,\n UPDATE_PRIORITY: 3,\n DETACHABLE: false,\n UPDATABLE: true,\n MOUNTABLE: true,\n\n cellView: null,\n nodeSelector: null,\n node: null,\n updateRequested: false,\n postponedUpdate: false,\n transformGroup: null,\n detachedTransformGroup: null,\n\n requestUpdate(cellView, nodeSelector) {\n const { paper } = cellView;\n this.cellView = cellView;\n this.nodeSelector = nodeSelector;\n if (paper) {\n this.updateRequested = true;\n paper.requestViewUpdate(this, this.HIGHLIGHT_FLAG, this.UPDATE_PRIORITY);\n }\n },\n\n confirmUpdate() {\n // The cellView is now rendered/updated since it has a higher update priority.\n this.updateRequested = false;\n const { cellView, nodeSelector } = this;\n if (!cellView.isMounted()) {\n this.postponedUpdate = true;\n return 0;\n }\n this.update(cellView, nodeSelector);\n this.mount();\n this.transform();\n return 0;\n },\n\n findNode(cellView, nodeSelector = null) {\n let el;\n if (typeof nodeSelector === 'string') {\n el = cellView.findNode(nodeSelector);\n } else if (isPlainObject(nodeSelector)) {\n const isLink = cellView.model.isLink();\n const { label = null, port, selector } = nodeSelector;\n if (isLink && label !== null) {\n // Link Label Selector\n el = cellView.findLabelNode(label, selector);\n } else if (!isLink && port) {\n // Element Port Selector\n el = cellView.findPortNode(port, selector);\n } else {\n // Cell Selector\n el = cellView.findNode(selector);\n }\n } else if (nodeSelector) {\n el = V.toNode(nodeSelector);\n if (!(el instanceof SVGElement)) el = null;\n }\n return el ? el : null;\n },\n\n getNodeMatrix(cellView, node) {\n const { options } = this;\n const { layer } = options;\n const { rotatableNode } = cellView;\n const nodeMatrix = cellView.getNodeMatrix(node);\n if (rotatableNode) {\n if (layer) {\n if (rotatableNode.contains(node)) {\n return nodeMatrix;\n }\n // The node is outside of the rotatable group.\n // Compensate the rotation set by transformGroup.\n return cellView.getRootRotateMatrix().inverse().multiply(nodeMatrix);\n } else {\n return cellView.getNodeRotateMatrix(node).multiply(nodeMatrix);\n }\n }\n return nodeMatrix;\n },\n\n mount() {\n const { MOUNTABLE, cellView, el, options, transformGroup, detachedTransformGroup, postponedUpdate, nodeSelector } = this;\n if (!MOUNTABLE || transformGroup) return;\n if (postponedUpdate) {\n // The cellView was not mounted when the update was requested.\n // The update was postponed until the cellView is mounted.\n this.update(cellView, nodeSelector);\n this.transform();\n return;\n }\n const { vel: cellViewRoot, paper } = cellView;\n const { layer: layerName } = options;\n if (layerName) {\n let vGroup;\n if (detachedTransformGroup) {\n vGroup = detachedTransformGroup;\n this.detachedTransformGroup = null;\n } else {\n vGroup = V('g').addClass('highlight-transform').append(el);\n }\n this.transformGroup = vGroup;\n paper.getLayerView(layerName).insertSortedNode(vGroup.node, options.z);\n } else {\n // TODO: prepend vs append\n if (!el.parentNode || el.nextSibling) {\n // Not appended yet or not the last child\n cellViewRoot.append(el);\n }\n }\n },\n\n unmount() {\n const { MOUNTABLE, transformGroup, vel } = this;\n if (!MOUNTABLE) return;\n if (transformGroup) {\n this.transformGroup = null;\n this.detachedTransformGroup = transformGroup;\n transformGroup.remove();\n } else {\n vel.remove();\n }\n },\n\n transform() {\n const { transformGroup, cellView, updateRequested } = this;\n if (!transformGroup || cellView.model.isLink() || updateRequested) return;\n const translateMatrix = cellView.getRootTranslateMatrix();\n const rotateMatrix = cellView.getRootRotateMatrix();\n const transformMatrix = translateMatrix.multiply(rotateMatrix);\n transformGroup.attr('transform', V.matrixToTransformString(transformMatrix));\n },\n\n update() {\n const { node: prevNode, cellView, nodeSelector, updateRequested, id } = this;\n if (updateRequested) return;\n this.postponedUpdate = false;\n const node = this.node = this.findNode(cellView, nodeSelector);\n if (prevNode) {\n this.unhighlight(cellView, prevNode);\n }\n if (node) {\n this.highlight(cellView, node);\n this.mount();\n } else {\n this.unmount();\n cellView.notify('cell:highlight:invalid', id, this);\n }\n },\n\n onRemove() {\n const { node, cellView, id, constructor } = this;\n if (node) {\n this.unhighlight(cellView, node);\n }\n this.unmount();\n constructor._removeRef(cellView, id);\n },\n\n highlight(_cellView, _node) {\n // to be overridden\n },\n\n unhighlight(_cellView, _node) {\n // to be overridden\n },\n\n // Update Attributes\n\n listenToUpdateAttributes(cellView) {\n const attributes = result(this, 'UPDATE_ATTRIBUTES');\n if (!Array.isArray(attributes) || attributes.length === 0) return;\n this.listenTo(cellView.model, 'change', this.onCellAttributeChange);\n },\n\n onCellAttributeChange() {\n const { cellView } = this;\n if (!cellView) return;\n const { model, paper } = cellView;\n const attributes = result(this, 'UPDATE_ATTRIBUTES');\n if (!attributes.some(attribute => model.hasChanged(attribute))) return;\n paper.requestViewUpdate(this, this.HIGHLIGHT_FLAG, this.UPDATE_PRIORITY);\n }\n\n}, {\n\n _views: {},\n\n // Used internally by CellView highlight()\n highlight: function(cellView, node, opt) {\n const id = this.uniqueId(node, opt);\n this.add(cellView, node, id, opt);\n },\n\n // Used internally by CellView unhighlight()\n unhighlight: function(cellView, node, opt) {\n const id = this.uniqueId(node, opt);\n this.remove(cellView, id);\n },\n\n get(cellView, id = null) {\n const { cid } = cellView;\n const { _views } = this;\n const refs = _views[cid];\n if (id === null) {\n // all highlighters\n const views = [];\n if (!refs) return views;\n for (let hid in refs) {\n const ref = refs[hid];\n if (ref instanceof this) {\n views.push(ref);\n }\n }\n return views;\n } else {\n // single highlighter\n if (!refs) return null;\n if (id in refs) {\n const ref = refs[id];\n if (ref instanceof this) return ref;\n }\n return null;\n }\n },\n\n add(cellView, nodeSelector, id, opt = {}) {\n if (!id) throw new Error('dia.HighlighterView: An ID required.');\n // Search the existing view amongst all the highlighters\n const previousView = HighlighterView.get(cellView, id);\n if (previousView) previousView.remove();\n const view = new this(opt);\n view.id = id;\n this._addRef(cellView, id, view);\n view.requestUpdate(cellView, nodeSelector);\n view.listenToUpdateAttributes(cellView);\n return view;\n },\n\n _addRef(cellView, id, view) {\n const { cid } = cellView;\n const { _views } = this;\n let refs = _views[cid];\n if (!refs) refs = _views[cid] = {};\n refs[id] = view;\n },\n\n _removeRef(cellView, id) {\n const { cid } = cellView;\n const { _views } = this;\n const refs = _views[cid];\n if (!refs) return;\n if (id) delete refs[id];\n for (let _ in refs) return;\n delete _views[cid];\n },\n\n remove(cellView, id = null) {\n toArray(this.get(cellView, id)).forEach(view => {\n view.remove();\n });\n },\n\n getAll(paper, id = null) {\n const views = [];\n const { _views } = this;\n for (let cid in _views) {\n for (let hid in _views[cid]) {\n const view = _views[cid][hid];\n if (view.cellView.paper === paper && view instanceof this && (id === null || hid === id)) {\n views.push(view);\n }\n }\n }\n return views;\n },\n\n removeAll(paper, id = null) {\n this.getAll(paper, id).forEach(view => view.remove());\n },\n\n update(cellView, id = null, dirty = false) {\n toArray(this.get(cellView, id)).forEach(view => {\n if (dirty || view.UPDATABLE) view.update();\n });\n },\n\n transform(cellView, id = null) {\n toArray(this.get(cellView, id)).forEach(view => {\n if (view.UPDATABLE) view.transform();\n });\n },\n\n unmount(cellView, id = null) {\n toArray(this.get(cellView, id)).forEach(view => view.unmount());\n },\n\n mount(cellView, id = null) {\n toArray(this.get(cellView, id)).forEach(view => view.mount());\n },\n\n uniqueId(node, opt = '') {\n return V.ensureId(node) + JSON.stringify(opt);\n }\n\n});\n","import { isCalcExpression, evalCalcExpression } from '../../util/calc.mjs';\n\nconst calcAttributesList = [\n 'transform',\n 'x',\n 'y',\n 'cx',\n 'cy',\n 'dx',\n 'dy',\n 'x1',\n 'y1',\n 'x2',\n 'y2',\n 'points',\n 'd',\n 'r',\n 'rx',\n 'ry',\n 'width',\n 'height',\n 'stroke-width',\n 'font-size',\n];\n\nconst positiveValueList = [\n 'r',\n 'rx',\n 'ry',\n 'width',\n 'height',\n 'stroke-width',\n 'font-size',\n];\n\nconst calcAttributes = calcAttributesList.reduce((acc, attrName) => {\n acc[attrName] = true;\n return acc;\n}, {});\n\nconst positiveValueAttributes = positiveValueList.reduce((acc, attrName) => {\n acc[attrName] = true;\n return acc;\n}, {});\n\nexport function evalAttributes(attrs, refBBox) {\n const evalAttrs = {};\n for (let attrName in attrs) {\n if (!attrs.hasOwnProperty(attrName)) continue;\n evalAttrs[attrName] = evalAttribute(attrName, attrs[attrName], refBBox);\n }\n return evalAttrs;\n}\n\nexport function evalAttribute(attrName, attrValue, refBBox) {\n if (attrName in calcAttributes && isCalcExpression(attrValue)) {\n let evalAttrValue = evalCalcExpression(attrValue, refBBox);\n if (attrName in positiveValueAttributes) {\n evalAttrValue = Math.max(0, evalAttrValue);\n }\n return evalAttrValue;\n }\n return attrValue;\n}\n","import { config } from '../config/index.mjs';\nimport { View } from '../mvc/index.mjs';\nimport {\n assign,\n guid,\n omit,\n parseDOMJSON,\n isFunction,\n isObject,\n isPlainObject,\n isBoolean,\n isEmpty,\n isString,\n result,\n sortedIndex,\n merge,\n uniq\n} from '../util/index.mjs';\nimport { Point, Rect, intersection } from '../g/index.mjs';\nimport V from '../V/index.mjs';\nimport $ from '../mvc/Dom/index.mjs';\nimport { HighlighterView } from './HighlighterView.mjs';\nimport { evalAttributes, evalAttribute } from './attributes/eval.mjs';\n\nconst HighlightingTypes = {\n DEFAULT: 'default',\n EMBEDDING: 'embedding',\n CONNECTING: 'connecting',\n MAGNET_AVAILABILITY: 'magnetAvailability',\n ELEMENT_AVAILABILITY: 'elementAvailability'\n};\n\nconst Flags = {\n TOOLS: 'TOOLS',\n};\n\n// CellView base view and controller.\n// --------------------------------------------\n\n// This is the base view and controller for `ElementView` and `LinkView`.\nexport const CellView = View.extend({\n\n tagName: 'g',\n\n svgElement: true,\n\n selector: 'root',\n\n metrics: null,\n\n className: function() {\n\n var classNames = ['cell'];\n var type = this.model.get('type');\n\n if (type) {\n\n type.toLowerCase().split('.').forEach(function(value, index, list) {\n classNames.push('type-' + list.slice(0, index + 1).join('-'));\n });\n }\n\n return classNames.join(' ');\n },\n\n _presentationAttributes: null,\n _flags: null,\n\n setFlags: function() {\n var flags = {};\n var attributes = {};\n var shift = 0;\n var i, n, label;\n var presentationAttributes = result(this, 'presentationAttributes');\n for (var attribute in presentationAttributes) {\n if (!presentationAttributes.hasOwnProperty(attribute)) continue;\n var labels = presentationAttributes[attribute];\n if (!Array.isArray(labels)) labels = [labels];\n for (i = 0, n = labels.length; i < n; i++) {\n label = labels[i];\n var flag = flags[label];\n if (!flag) {\n flag = flags[label] = 1<<(shift++);\n }\n attributes[attribute] |= flag;\n }\n }\n var initFlag = result(this, 'initFlag');\n if (!Array.isArray(initFlag)) initFlag = [initFlag];\n for (i = 0, n = initFlag.length; i < n; i++) {\n label = initFlag[i];\n if (!flags[label]) flags[label] = 1<<(shift++);\n }\n\n // 26 - 30 are reserved for paper flags\n // 31+ overflows maximal number\n if (shift > 25) throw new Error('dia.CellView: Maximum number of flags exceeded.');\n\n this._flags = flags;\n this._presentationAttributes = attributes;\n },\n\n hasFlag: function(flag, label) {\n return flag & this.getFlag(label);\n },\n\n removeFlag: function(flag, label) {\n return flag ^ (flag & this.getFlag(label));\n },\n\n getFlag: function(label) {\n var flags = this._flags;\n if (!flags) return 0;\n var flag = 0;\n if (Array.isArray(label)) {\n for (var i = 0, n = label.length; i < n; i++) flag |= flags[label[i]];\n } else {\n flag |= flags[label];\n }\n return flag;\n },\n\n attributes: function() {\n var cell = this.model;\n return {\n 'model-id': cell.id,\n 'data-type': cell.attributes.type\n };\n },\n\n constructor: function(options) {\n\n // Make sure a global unique id is assigned to this view. Store this id also to the properties object.\n // The global unique id makes sure that the same view can be rendered on e.g. different machines and\n // still be associated to the same object among all those clients. This is necessary for real-time\n // collaboration mechanism.\n options.id = options.id || guid(this);\n\n View.call(this, options);\n },\n\n initialize: function() {\n\n this.setFlags();\n\n View.prototype.initialize.apply(this, arguments);\n\n this.cleanNodesCache();\n\n this.startListening();\n },\n\n startListening: function() {\n this.listenTo(this.model, 'change', this.onAttributesChange);\n },\n\n onAttributesChange: function(model, opt) {\n var flag = model.getChangeFlag(this._presentationAttributes);\n if (opt.updateHandled || !flag) return;\n if (opt.dirty && this.hasFlag(flag, 'UPDATE')) flag |= this.getFlag('RENDER');\n // TODO: tool changes does not need to be sync\n // Fix Segments tools\n if (opt.tool) opt.async = false;\n this.requestUpdate(flag, opt);\n },\n\n requestUpdate: function(flags, opt) {\n const { paper } = this;\n if (paper && flags > 0) {\n paper.requestViewUpdate(this, flags, this.UPDATE_PRIORITY, opt);\n }\n },\n\n parseDOMJSON: function(markup, root) {\n\n var doc = parseDOMJSON(markup);\n var selectors = doc.selectors;\n var groups = doc.groupSelectors;\n for (var group in groups) {\n if (selectors[group]) throw new Error('dia.CellView: ambiguous group selector');\n selectors[group] = groups[group];\n }\n if (root) {\n var rootSelector = this.selector;\n if (selectors[rootSelector]) throw new Error('dia.CellView: ambiguous root selector.');\n selectors[rootSelector] = root;\n }\n return { fragment: doc.fragment, selectors: selectors };\n },\n\n // Return `true` if cell link is allowed to perform a certain UI `feature`.\n // Example: `can('labelMove')`.\n can: function(feature) {\n\n var interactive = isFunction(this.options.interactive)\n ? this.options.interactive(this)\n : this.options.interactive;\n\n return (isObject(interactive) && interactive[feature] !== false) ||\n (isBoolean(interactive) && interactive !== false);\n },\n\n findBySelector: function(selector, root, selectors) {\n\n // These are either descendants of `this.$el` of `this.$el` itself.\n // `.` is a special selector used to select the wrapping `<g>` element.\n if (!selector || selector === '.') return [root];\n if (selectors) {\n var nodes = selectors[selector];\n if (nodes) {\n if (Array.isArray(nodes)) return nodes;\n return [nodes];\n }\n }\n\n // Maintaining backwards compatibility\n // e.g. `circle:first` would fail with querySelector() call\n if (this.useCSSSelectors) return $(root).find(selector).toArray();\n\n return [];\n },\n\n findNodes: function(selector) {\n return this.findBySelector(selector, this.el, this.selectors);\n },\n\n findNode: function(selector) {\n const [node = null] = this.findNodes(selector);\n return node;\n },\n\n notify: function(eventName) {\n\n if (this.paper) {\n\n var args = Array.prototype.slice.call(arguments, 1);\n\n // Trigger the event on both the element itself and also on the paper.\n this.trigger.apply(this, [eventName].concat(args));\n\n // Paper event handlers receive the view object as the first argument.\n this.paper.trigger.apply(this.paper, [eventName, this].concat(args));\n }\n },\n\n getBBox: function(opt) {\n\n var bbox;\n if (opt && opt.useModelGeometry) {\n var model = this.model;\n bbox = model.getBBox().bbox(model.angle());\n } else {\n bbox = this.getNodeBBox(this.el);\n }\n\n return this.paper.localToPaperRect(bbox);\n },\n\n getNodeBBox: function(magnet) {\n\n const rect = this.getNodeBoundingRect(magnet);\n const transformMatrix = this.getRootTranslateMatrix().multiply(this.getNodeRotateMatrix(magnet));\n const magnetMatrix = this.getNodeMatrix(magnet);\n return V.transformRect(rect, transformMatrix.multiply(magnetMatrix));\n },\n\n getNodeRotateMatrix(node) {\n if (!this.rotatableNode || this.rotatableNode.contains(node)) {\n // Rotate transformation is applied to all nodes when no rotatableGroup\n // is present or to nodes inside the rotatableGroup only.\n return this.getRootRotateMatrix();\n }\n // Nodes outside the rotatable group\n return V.createSVGMatrix();\n },\n\n getNodeUnrotatedBBox: function(magnet) {\n\n var rect = this.getNodeBoundingRect(magnet);\n var magnetMatrix = this.getNodeMatrix(magnet);\n var translateMatrix = this.getRootTranslateMatrix();\n return V.transformRect(rect, translateMatrix.multiply(magnetMatrix));\n },\n\n getRootTranslateMatrix: function() {\n\n var model = this.model;\n var position = model.position();\n var mt = V.createSVGMatrix().translate(position.x, position.y);\n return mt;\n },\n\n getRootRotateMatrix: function() {\n\n var mr = V.createSVGMatrix();\n var model = this.model;\n var angle = model.angle();\n if (angle) {\n var bbox = model.getBBox();\n var cx = bbox.width / 2;\n var cy = bbox.height / 2;\n mr = mr.translate(cx, cy).rotate(angle).translate(-cx, -cy);\n }\n return mr;\n },\n\n _notifyHighlight: function(eventName, el, opt = {}) {\n const { el: rootNode } = this;\n let node;\n if (typeof el === 'string') {\n node = this.findNode(el) || rootNode;\n } else {\n [node = rootNode] = this.$(el);\n }\n // set partial flag if the highlighted element is not the entire view.\n opt.partial = (node !== rootNode);\n // translate type flag into a type string\n if (opt.type === undefined) {\n let type;\n switch (true) {\n case opt.embedding:\n type = HighlightingTypes.EMBEDDING;\n break;\n case opt.connecting:\n type = HighlightingTypes.CONNECTING;\n break;\n case opt.magnetAvailability:\n type = HighlightingTypes.MAGNET_AVAILABILITY;\n break;\n case opt.elementAvailability:\n type = HighlightingTypes.ELEMENT_AVAILABILITY;\n break;\n default:\n type = HighlightingTypes.DEFAULT;\n break;\n }\n opt.type = type;\n }\n this.notify(eventName, node, opt);\n return this;\n },\n\n highlight: function(el, opt) {\n return this._notifyHighlight('cell:highlight', el, opt);\n },\n\n unhighlight: function(el, opt = {}) {\n return this._notifyHighlight('cell:unhighlight', el, opt);\n },\n\n // Find the closest element that has the `magnet` attribute set to `true`. If there was not such\n // an element found, return the root element of the cell view.\n findMagnet: function(el) {\n\n const root = this.el;\n let magnet = this.$(el)[0];\n if (!magnet) {\n magnet = root;\n }\n\n do {\n const magnetAttribute = magnet.getAttribute('magnet');\n const isMagnetRoot = (magnet === root);\n if ((magnetAttribute || isMagnetRoot) && magnetAttribute !== 'false') {\n return magnet;\n }\n if (isMagnetRoot) {\n // If the overall cell has set `magnet === false`, then return `undefined` to\n // announce there is no magnet found for this cell.\n // This is especially useful to set on cells that have 'ports'. In this case,\n // only the ports have set `magnet === true` and the overall element has `magnet === false`.\n return undefined;\n }\n magnet = magnet.parentNode;\n } while (magnet);\n\n return undefined;\n },\n\n findProxyNode: function(el, type) {\n el || (el = this.el);\n const nodeSelector = el.getAttribute(`${type}-selector`);\n if (nodeSelector) {\n const proxyNode = this.findNode(nodeSelector);\n if (proxyNode) return proxyNode;\n }\n return el;\n },\n\n // Construct a unique selector for the `el` element within this view.\n // `prevSelector` is being collected through the recursive call.\n // No value for `prevSelector` is expected when using this method.\n getSelector: function(el, prevSelector) {\n\n var selector;\n\n if (el === this.el) {\n if (typeof prevSelector === 'string') selector = ':scope > ' + prevSelector;\n return selector;\n }\n\n if (el) {\n\n var nthChild = V(el).index() + 1;\n selector = el.tagName + ':nth-child(' + nthChild + ')';\n\n if (prevSelector) {\n selector += ' > ' + prevSelector;\n }\n\n selector = this.getSelector(el.parentNode, selector);\n }\n\n return selector;\n },\n\n addLinkFromMagnet: function(magnet, x, y) {\n\n var paper = this.paper;\n var graph = paper.model;\n\n var link = paper.getDefaultLink(this, magnet);\n link.set({\n source: this.getLinkEnd(magnet, x, y, link, 'source'),\n target: { x: x, y: y }\n }).addTo(graph, {\n async: false,\n ui: true\n });\n\n return link.findView(paper);\n },\n\n getLinkEnd: function(magnet, ...args) {\n\n const model = this.model;\n const id = model.id;\n // Find a node with the `port` attribute set on it.\n const portNode = this.findAttributeNode('port', magnet);\n // Find a unique `selector` of the element under pointer that is a magnet.\n const selector = magnet.getAttribute('joint-selector');\n\n const end = { id: id };\n if (selector != null) end.magnet = selector;\n if (portNode != null) {\n let port = portNode.getAttribute('port');\n if (portNode.getAttribute('port-id-type') === 'number') {\n port = parseInt(port, 10);\n }\n end.port = port;\n if (!model.hasPort(port) && !selector) {\n // port created via the `port` attribute (not API)\n end.selector = this.getSelector(magnet);\n }\n } else if (selector == null && this.el !== magnet) {\n end.selector = this.getSelector(magnet);\n }\n\n return this.customizeLinkEnd(end, magnet, ...args);\n },\n\n customizeLinkEnd: function(end, magnet, x, y, link, endType) {\n const { paper } = this;\n const { connectionStrategy } = paper.options;\n if (typeof connectionStrategy === 'function') {\n var strategy = connectionStrategy.call(paper, end, this, magnet, new Point(x, y), link, endType, paper);\n if (strategy) return strategy;\n }\n return end;\n },\n\n getMagnetFromLinkEnd: function(end) {\n\n var port = end.port;\n var selector = end.magnet;\n var model = this.model;\n var magnet;\n if (port != null && model.isElement() && model.hasPort(port)) {\n magnet = this.findPortNode(port, selector) || this.el;\n } else {\n if (!selector) selector = end.selector;\n if (!selector && port != null) {\n // link end has only `id` and `port` property referencing\n // a port created via the `port` attribute (not API).\n selector = '[port=\"' + port + '\"]';\n }\n magnet = this.findNode(selector);\n }\n\n return this.findProxyNode(magnet, 'magnet');\n },\n\n dragLinkStart: function(evt, magnet, x, y) {\n this.model.startBatch('add-link');\n const linkView = this.addLinkFromMagnet(magnet, x, y);\n // backwards compatibility events\n linkView.notifyPointerdown(evt, x, y);\n linkView.eventData(evt, linkView.startArrowheadMove('target', { whenNotAllowed: 'remove' }));\n this.eventData(evt, { linkView });\n },\n\n dragLink: function(evt, x, y) {\n var data = this.eventData(evt);\n var linkView = data.linkView;\n if (linkView) {\n linkView.pointermove(evt, x, y);\n } else {\n var paper = this.paper;\n var magnetThreshold = paper.options.magnetThreshold;\n var currentTarget = this.getEventTarget(evt);\n var targetMagnet = data.targetMagnet;\n if (magnetThreshold === 'onleave') {\n // magnetThreshold when the pointer leaves the magnet\n if (targetMagnet === currentTarget || V(targetMagnet).contains(currentTarget)) return;\n } else {\n // magnetThreshold defined as a number of movements\n if (paper.eventData(evt).mousemoved <= magnetThreshold) return;\n }\n this.dragLinkStart(evt, targetMagnet, x, y);\n }\n },\n\n dragLinkEnd: function(evt, x, y) {\n var data = this.eventData(evt);\n var linkView = data.linkView;\n if (!linkView) return;\n linkView.pointerup(evt, x, y);\n this.model.stopBatch('add-link');\n },\n\n getAttributeDefinition: function(attrName) {\n\n return this.model.constructor.getAttributeDefinition(attrName);\n },\n\n setNodeAttributes: function(node, attrs) {\n\n if (!isEmpty(attrs)) {\n if (node instanceof SVGElement) {\n V(node).attr(attrs);\n } else {\n $(node).attr(attrs);\n }\n }\n },\n\n processNodeAttributes: function(node, attrs) {\n\n var attrName, attrVal, def, i, n;\n var normalAttrs, setAttrs, positionAttrs, offsetAttrs;\n var relatives = [];\n const rawAttrs = {};\n for (attrName in attrs) {\n if (!attrs.hasOwnProperty(attrName)) continue;\n rawAttrs[V.attributeNames[attrName]] = attrs[attrName];\n }\n // divide the attributes between normal and special\n for (attrName in rawAttrs) {\n if (!rawAttrs.hasOwnProperty(attrName)) continue;\n attrVal = rawAttrs[attrName];\n def = this.getAttributeDefinition(attrName);\n if (def) {\n if (attrVal === null) {\n // Assign the unset attribute name.\n let unsetAttrName;\n if (isFunction(def.unset)) {\n unsetAttrName = def.unset.call(this, node, rawAttrs, this);\n } else {\n unsetAttrName = def.unset;\n }\n if (!unsetAttrName && isString(def.set)) {\n // We unset an alias attribute.\n unsetAttrName = def.set;\n }\n if (!unsetAttrName) {\n // There is no alias for the attribute. We unset the attribute itself.\n unsetAttrName = attrName;\n }\n // Unset the attribute.\n if (isString(unsetAttrName) && unsetAttrName) {\n // Unset a single attribute.\n normalAttrs || (normalAttrs = {});\n // values takes precedence over unset values\n if (unsetAttrName in normalAttrs) continue;\n normalAttrs[unsetAttrName] = attrVal;\n } else if (Array.isArray(unsetAttrName) && unsetAttrName.length > 0) {\n // Unset multiple attributes.\n normalAttrs || (normalAttrs = {});\n for (i = 0, n = unsetAttrName.length; i < n; i++) {\n const attrName = unsetAttrName[i];\n // values takes precedence over unset values\n if (attrName in normalAttrs) continue;\n normalAttrs[attrName] = attrVal;\n }\n }\n // The unset value is neither a string nor an array.\n // The attribute is not unset.\n } else {\n if (!isFunction(def.qualify) || def.qualify.call(this, attrVal, node, rawAttrs, this)) {\n if (isString(def.set)) {\n // An alias e.g 'xlink:href' -> 'href'\n normalAttrs || (normalAttrs = {});\n normalAttrs[def.set] = attrVal;\n }\n relatives.push(attrName, def);\n } else {\n normalAttrs || (normalAttrs = {});\n normalAttrs[attrName] = attrVal;\n }\n }\n } else {\n normalAttrs || (normalAttrs = {});\n normalAttrs[attrName] = attrVal;\n }\n }\n\n // handle the rest of attributes via related method\n // from the special attributes namespace.\n for (i = 0, n = relatives.length; i < n; i+=2) {\n attrName = relatives[i];\n def = relatives[i+1];\n attrVal = attrs[attrName];\n if (isFunction(def.set)) {\n setAttrs || (setAttrs = {});\n setAttrs[attrName] = attrVal;\n }\n if (isFunction(def.position)) {\n positionAttrs || (positionAttrs = {});\n positionAttrs[attrName] = attrVal;\n }\n if (isFunction(def.offset)) {\n offsetAttrs || (offsetAttrs = {});\n offsetAttrs[attrName] = attrVal;\n }\n }\n\n return {\n raw: rawAttrs,\n normal: normalAttrs,\n set: setAttrs,\n position: positionAttrs,\n offset: offsetAttrs\n };\n },\n\n updateRelativeAttributes: function(node, attrs, refBBox, opt) {\n\n opt || (opt = {});\n\n var attrName, attrVal, def;\n var evalAttrs = evalAttributes(attrs.raw || {}, refBBox);\n var nodeAttrs = attrs.normal || {};\n for (const nodeAttrName in nodeAttrs) {\n nodeAttrs[nodeAttrName] = evalAttrs[nodeAttrName];\n }\n var setAttrs = attrs.set;\n var positionAttrs = attrs.position;\n var offsetAttrs = attrs.offset;\n\n for (attrName in setAttrs) {\n attrVal = evalAttrs[attrName];\n def = this.getAttributeDefinition(attrName);\n // SET - set function should return attributes to be set on the node,\n // which will affect the node dimensions based on the reference bounding\n // box. e.g. `width`, `height`, `d`, `rx`, `ry`, `points\n var setResult = def.set.call(this, attrVal, refBBox.clone(), node, evalAttrs, this);\n if (isObject(setResult)) {\n assign(nodeAttrs, setResult);\n } else if (setResult !== undefined) {\n nodeAttrs[attrName] = setResult;\n }\n }\n\n if (node instanceof HTMLElement) {\n // TODO: setting the `transform` attribute on HTMLElements\n // via `node.style.transform = 'matrix(...)';` would introduce\n // a breaking change (e.g. basic.TextBlock).\n this.setNodeAttributes(node, nodeAttrs);\n return;\n }\n\n // The final translation of the subelement.\n var nodeTransform = nodeAttrs.transform;\n var nodeMatrix = V.transformStringToMatrix(nodeTransform);\n var nodePosition = Point(nodeMatrix.e, nodeMatrix.f);\n if (nodeTransform) {\n nodeAttrs = omit(nodeAttrs, 'transform');\n nodeMatrix.e = nodeMatrix.f = 0;\n }\n\n // Calculate node scale determined by the scalable group\n // only if later needed.\n var sx, sy, translation;\n if (positionAttrs || offsetAttrs) {\n var nodeScale = this.getNodeScale(node, opt.scalableNode);\n sx = nodeScale.sx;\n sy = nodeScale.sy;\n }\n\n var positioned = false;\n for (attrName in positionAttrs) {\n attrVal = evalAttrs[attrName];\n def = this.getAttributeDefinition(attrName);\n // POSITION - position function should return a point from the\n // reference bounding box. The default position of the node is x:0, y:0 of\n // the reference bounding box or could be further specify by some\n // SVG attributes e.g. `x`, `y`\n translation = def.position.call(this, attrVal, refBBox.clone(), node, evalAttrs, this);\n if (translation) {\n nodePosition.offset(Point(translation).scale(sx, sy));\n positioned || (positioned = true);\n }\n }\n\n // The node bounding box could depend on the `size` set from the previous loop.\n // Here we know, that all the size attributes have been already set.\n this.setNodeAttributes(node, nodeAttrs);\n\n var offseted = false;\n if (offsetAttrs) {\n // Check if the node is visible\n var nodeBoundingRect = this.getNodeBoundingRect(node);\n if (nodeBoundingRect.width > 0 && nodeBoundingRect.height > 0) {\n var nodeBBox = V.transformRect(nodeBoundingRect, nodeMatrix).scale(1 / sx, 1 / sy);\n for (attrName in offsetAttrs) {\n attrVal = evalAttrs[attrName];\n def = this.getAttributeDefinition(attrName);\n // OFFSET - offset function should return a point from the element\n // bounding box. The default offset point is x:0, y:0 (origin) or could be further\n // specify with some SVG attributes e.g. `text-anchor`, `cx`, `cy`\n translation = def.offset.call(this, attrVal, nodeBBox, node, evalAttrs, this);\n if (translation) {\n nodePosition.offset(Point(translation).scale(sx, sy));\n offseted || (offseted = true);\n }\n }\n }\n }\n\n // Do not touch node's transform attribute if there is no transformation applied.\n if (nodeTransform !== undefined || positioned || offseted) {\n // Round the coordinates to 1 decimal point.\n nodePosition.round(1);\n nodeMatrix.e = nodePosition.x;\n nodeMatrix.f = nodePosition.y;\n node.setAttribute('transform', V.matrixToTransformString(nodeMatrix));\n // TODO: store nodeMatrix metrics?\n }\n },\n\n getNodeScale: function(node, scalableNode) {\n\n // Check if the node is a descendant of the scalable group.\n var sx, sy;\n if (scalableNode && scalableNode.contains(node)) {\n var scale = scalableNode.scale();\n sx = 1 / scale.sx;\n sy = 1 / scale.sy;\n } else {\n sx = 1;\n sy = 1;\n }\n\n return { sx: sx, sy: sy };\n },\n\n cleanNodesCache: function() {\n this.metrics = {};\n },\n\n cleanNodeCache: function(node) {\n const id = node.id;\n if (!id) return;\n delete this.metrics[id];\n },\n\n nodeCache: function(magnet) {\n\n var metrics = this.metrics;\n // Don't use cache? It most likely a custom view with overridden update.\n if (!metrics) return {};\n var id = V.ensureId(magnet);\n var value = metrics[id];\n if (!value) value = metrics[id] = {};\n return value;\n },\n\n getNodeData: function(magnet) {\n\n var metrics = this.nodeCache(magnet);\n if (!metrics.data) metrics.data = {};\n return metrics.data;\n },\n\n getNodeBoundingRect: function(magnet) {\n\n var metrics = this.nodeCache(magnet);\n if (metrics.boundingRect === undefined) metrics.boundingRect = V(magnet).getBBox();\n return new Rect(metrics.boundingRect);\n },\n\n getNodeMatrix: function(magnet) {\n\n const metrics = this.nodeCache(magnet);\n if (metrics.magnetMatrix === undefined) {\n const { rotatableNode, el } = this;\n let target;\n if (rotatableNode && rotatableNode.contains(magnet)) {\n target = rotatableNode;\n } else {\n target = el;\n }\n metrics.magnetMatrix = V(magnet).getTransformToElement(target);\n }\n return V.createSVGMatrix(metrics.magnetMatrix);\n },\n\n getNodeShape: function(magnet) {\n\n var metrics = this.nodeCache(magnet);\n if (metrics.geometryShape === undefined) metrics.geometryShape = V(magnet).toGeometryShape();\n return metrics.geometryShape.clone();\n },\n\n isNodeConnection: function(node) {\n return this.model.isLink() && (!node || node === this.el);\n },\n\n findNodesAttributes: function(attrs, root, selectorCache, selectors) {\n\n var i, n, nodeAttrs, nodeId;\n var nodesAttrs = {};\n var mergeIds = [];\n for (var selector in attrs) {\n if (!attrs.hasOwnProperty(selector)) continue;\n nodeAttrs = attrs[selector];\n if (!isPlainObject(nodeAttrs)) continue; // Not a valid selector-attributes pair\n var selected = selectorCache[selector] = this.findBySelector(selector, root, selectors);\n for (i = 0, n = selected.length; i < n; i++) {\n var node = selected[i];\n nodeId = V.ensureId(node);\n // \"unique\" selectors are selectors that referencing a single node (defined by `selector`)\n // groupSelector referencing a single node is not \"unique\"\n var unique = (selectors && selectors[selector] === node);\n var prevNodeAttrs = nodesAttrs[nodeId];\n if (prevNodeAttrs) {\n // Note, that nodes referenced by deprecated `CSS selectors` are not taken into account.\n // e.g. css:`.circle` and selector:`circle` can be applied in a random order\n if (!prevNodeAttrs.array) {\n mergeIds.push(nodeId);\n prevNodeAttrs.array = true;\n prevNodeAttrs.attributes = [prevNodeAttrs.attributes];\n prevNodeAttrs.selectedLength = [prevNodeAttrs.selectedLength];\n }\n var attributes = prevNodeAttrs.attributes;\n var selectedLength = prevNodeAttrs.selectedLength;\n if (unique) {\n // node referenced by `selector`\n attributes.unshift(nodeAttrs);\n selectedLength.unshift(-1);\n } else {\n // node referenced by `groupSelector`\n var sortIndex = sortedIndex(selectedLength, n);\n attributes.splice(sortIndex, 0, nodeAttrs);\n selectedLength.splice(sortIndex, 0, n);\n }\n } else {\n nodesAttrs[nodeId] = {\n attributes: nodeAttrs,\n selectedLength: unique ? -1 : n,\n node: node,\n array: false\n };\n }\n }\n }\n\n for (i = 0, n = mergeIds.length; i < n; i++) {\n nodeId = mergeIds[i];\n nodeAttrs = nodesAttrs[nodeId];\n nodeAttrs.attributes = merge({}, ...nodeAttrs.attributes.reverse());\n }\n\n return nodesAttrs;\n },\n\n getEventTarget: function(evt, opt = {}) {\n const { target, type, clientX = 0, clientY = 0 } = evt;\n if (\n // Explicitly defined `fromPoint` option\n opt.fromPoint ||\n // Touchmove/Touchend event's target is not reflecting the element under the coordinates as mousemove does.\n // It holds the element when a touchstart triggered.\n type === 'touchmove' || type === 'touchend' ||\n // Pointermove/Pointerup event with the pointer captured\n ('pointerId' in evt && target.hasPointerCapture(evt.pointerId))\n ) {\n return document.elementFromPoint(clientX, clientY);\n }\n\n return target;\n },\n\n // Default is to process the `model.attributes.attrs` object and set attributes on subelements based on the selectors,\n // unless `attrs` parameter was passed.\n updateDOMSubtreeAttributes: function(rootNode, attrs, opt) {\n\n opt || (opt = {});\n opt.rootBBox || (opt.rootBBox = Rect());\n opt.selectors || (opt.selectors = this.selectors); // selector collection to use\n\n // Cache table for query results and bounding box calculation.\n // Note that `selectorCache` needs to be invalidated for all\n // `updateAttributes` calls, as the selectors might pointing\n // to nodes designated by an attribute or elements dynamically\n // created.\n var selectorCache = {};\n var bboxCache = {};\n var relativeItems = [];\n var relativeRefItems = [];\n var item, node, nodeAttrs, nodeData, processedAttrs;\n\n var roAttrs = opt.roAttributes;\n var nodesAttrs = this.findNodesAttributes(roAttrs || attrs, rootNode, selectorCache, opt.selectors);\n // `nodesAttrs` are different from all attributes, when\n // rendering only attributes sent to this method.\n var nodesAllAttrs = (roAttrs)\n ? this.findNodesAttributes(attrs, rootNode, selectorCache, opt.selectors)\n : nodesAttrs;\n\n for (var nodeId in nodesAttrs) {\n nodeData = nodesAttrs[nodeId];\n nodeAttrs = nodeData.attributes;\n node = nodeData.node;\n processedAttrs = this.processNodeAttributes(node, nodeAttrs);\n\n if (!processedAttrs.set && !processedAttrs.position && !processedAttrs.offset && !processedAttrs.raw.ref) {\n // Set all the normal attributes right on the SVG/HTML element.\n this.setNodeAttributes(node, evalAttributes(processedAttrs.normal, opt.rootBBox));\n\n } else {\n\n var nodeAllAttrs = nodesAllAttrs[nodeId] && nodesAllAttrs[nodeId].attributes;\n var refSelector = (nodeAllAttrs && (nodeAttrs.ref === undefined))\n ? nodeAllAttrs.ref\n : nodeAttrs.ref;\n\n var refNode;\n if (refSelector) {\n refNode = (selectorCache[refSelector] || this.findBySelector(refSelector, rootNode, opt.selectors))[0];\n if (!refNode) {\n throw new Error('dia.CellView: \"' + refSelector + '\" reference does not exist.');\n }\n } else {\n refNode = null;\n }\n\n item = {\n node: node,\n refNode: refNode,\n processedAttributes: processedAttrs,\n allAttributes: nodeAllAttrs\n };\n\n if (refNode) {\n // If an element in the list is positioned relative to this one, then\n // we want to insert this one before it in the list.\n var itemIndex = relativeRefItems.findIndex(function(item) {\n return item.refNode === node;\n });\n\n if (itemIndex > -1) {\n relativeRefItems.splice(itemIndex, 0, item);\n } else {\n relativeRefItems.push(item);\n }\n } else {\n // A node with no ref attribute. To be updated before the nodes referencing other nodes.\n // The order of no-ref-items is not specified/important.\n relativeItems.push(item);\n }\n }\n }\n\n relativeItems.push(...relativeRefItems);\n\n for (let i = 0, n = relativeItems.length; i < n; i++) {\n item = relativeItems[i];\n node = item.node;\n refNode = item.refNode;\n\n // Find the reference element bounding box. If no reference was provided, we\n // use the optional bounding box.\n const refNodeId = refNode ? V.ensureId(refNode) : '';\n let refBBox = bboxCache[refNodeId];\n if (!refBBox) {\n // Get the bounding box of the reference element using to the common ancestor\n // transformation space.\n //\n // @example 1\n // <g transform=\"translate(11, 13)\">\n // <rect @selector=\"b\" x=\"1\" y=\"2\" width=\"3\" height=\"4\"/>\n // <rect @selector=\"a\"/>\n // </g>\n //\n // In this case, the reference bounding box can not be affected\n // by the `transform` attribute of the `<g>` element,\n // because the exact transformation will be applied to the `a` element\n // as well as to the `b` element.\n //\n // @example 2\n // <g transform=\"translate(11, 13)\">\n // <rect @selector=\"b\" x=\"1\" y=\"2\" width=\"3\" height=\"4\"/>\n // </g>\n // <rect @selector=\"a\"/>\n //\n // In this case, the reference bounding box have to be affected by the\n // `transform` attribute of the `<g>` element, because the `a` element\n // is not descendant of the `<g>` element and will not be affected\n // by the transformation.\n refBBox = bboxCache[refNodeId] = (refNode)\n ? V(refNode).getBBox({ target: getCommonAncestorNode(node, refNode) })\n : opt.rootBBox;\n }\n\n if (roAttrs) {\n // if there was a special attribute affecting the position amongst passed-in attributes\n // we have to merge it with the rest of the element's attributes as they are necessary\n // to update the position relatively (i.e `ref-x` && 'ref-dx')\n processedAttrs = this.processNodeAttributes(node, item.allAttributes);\n this.mergeProcessedAttributes(processedAttrs, item.processedAttributes);\n\n } else {\n processedAttrs = item.processedAttributes;\n }\n\n this.updateRelativeAttributes(node, processedAttrs, refBBox, opt);\n }\n },\n\n mergeProcessedAttributes: function(processedAttrs, roProcessedAttrs) {\n\n processedAttrs.set || (processedAttrs.set = {});\n processedAttrs.position || (processedAttrs.position = {});\n processedAttrs.offset || (processedAttrs.offset = {});\n\n assign(processedAttrs.set, roProcessedAttrs.set);\n assign(processedAttrs.position, roProcessedAttrs.position);\n assign(processedAttrs.offset, roProcessedAttrs.offset);\n\n // Handle also the special transform property.\n var transform = processedAttrs.normal && processedAttrs.normal.transform;\n if (transform !== undefined && roProcessedAttrs.normal) {\n roProcessedAttrs.normal.transform = transform;\n }\n processedAttrs.normal = roProcessedAttrs.normal;\n },\n\n // Lifecycle methods\n\n // Called when the view is attached to the DOM,\n // as result of `cell.addTo(graph)` being called (isInitialMount === true)\n // or `paper.options.viewport` returning `true` (isInitialMount === false).\n onMount(isInitialMount) {\n if (isInitialMount) return;\n this.mountTools();\n HighlighterView.mount(this);\n },\n\n // Called when the view is detached from the DOM,\n // as result of `paper.options.viewport` returning `false`.\n onDetach() {\n this.unmountTools();\n HighlighterView.unmount(this);\n },\n\n // Called when the view is removed from the DOM\n // as result of `cell.remove()`.\n onRemove: function() {\n this.removeTools();\n this.removeHighlighters();\n },\n\n _toolsView: null,\n\n hasTools: function(name) {\n var toolsView = this._toolsView;\n if (!toolsView) return false;\n if (!name) return true;\n return (toolsView.getName() === name);\n },\n\n addTools: function(toolsView) {\n\n this.removeTools();\n\n if (toolsView) {\n this._toolsView = toolsView;\n toolsView.configure({ relatedView: this });\n toolsView.listenTo(this.paper, 'tools:event', this.onToolEvent.bind(this));\n }\n return this;\n },\n\n unmountTools() {\n const toolsView = this._toolsView;\n if (toolsView) toolsView.unmount();\n return this;\n },\n\n mountTools() {\n const toolsView = this._toolsView;\n // Prevent unnecessary re-appending of the tools.\n if (toolsView && !toolsView.isMounted()) toolsView.mount();\n return this;\n },\n\n updateTools: function(opt) {\n\n var toolsView = this._toolsView;\n if (toolsView) toolsView.update(opt);\n return this;\n },\n\n removeTools: function() {\n\n var toolsView = this._toolsView;\n if (toolsView) {\n toolsView.remove();\n this._toolsView = null;\n }\n return this;\n },\n\n hideTools: function() {\n\n var toolsView = this._toolsView;\n if (toolsView) toolsView.hide();\n return this;\n },\n\n showTools: function() {\n\n var toolsView = this._toolsView;\n if (toolsView) toolsView.show();\n return this;\n },\n\n onToolEvent: function(event) {\n switch (event) {\n case 'remove':\n this.removeTools();\n break;\n case 'hide':\n this.hideTools();\n break;\n case 'show':\n this.showTools();\n break;\n }\n },\n\n removeHighlighters: function() {\n HighlighterView.remove(this);\n },\n\n updateHighlighters: function(dirty = false) {\n HighlighterView.update(this, null, dirty);\n },\n\n transformHighlighters: function() {\n HighlighterView.transform(this);\n },\n\n // Interaction. The controller part.\n // ---------------------------------\n\n preventDefaultInteraction(evt) {\n this.eventData(evt, { defaultInteractionPrevented: true });\n },\n\n isDefaultInteractionPrevented(evt) {\n const { defaultInteractionPrevented = false } = this.eventData(evt);\n return defaultInteractionPrevented;\n },\n\n // Interaction is handled by the paper and delegated to the view in interest.\n // `x` & `y` parameters passed to these functions represent the coordinates already snapped to the paper grid.\n // If necessary, real coordinates can be obtained from the `evt` event object.\n\n // These functions are supposed to be overridden by the views that inherit from `joint.dia.Cell`,\n // i.e. `joint.dia.Element` and `joint.dia.Link`.\n\n pointerdblclick: function(evt, x, y) {\n\n this.notify('cell:pointerdblclick', evt, x, y);\n },\n\n pointerclick: function(evt, x, y) {\n\n this.notify('cell:pointerclick', evt, x, y);\n },\n\n contextmenu: function(evt, x, y) {\n\n this.notify('cell:contextmenu', evt, x, y);\n },\n\n pointerdown: function(evt, x, y) {\n\n const { model } = this;\n const { graph } = model;\n if (graph) {\n model.startBatch('pointer');\n this.eventData(evt, { graph });\n }\n\n this.notify('cell:pointerdown', evt, x, y);\n },\n\n pointermove: function(evt, x, y) {\n\n this.notify('cell:pointermove', evt, x, y);\n },\n\n pointerup: function(evt, x, y) {\n\n const { graph } = this.eventData(evt);\n\n this.notify('cell:pointerup', evt, x, y);\n\n if (graph) {\n // we don't want to trigger event on model as model doesn't\n // need to be member of collection anymore (remove)\n graph.stopBatch('pointer', { cell: this.model });\n }\n },\n\n mouseover: function(evt) {\n\n this.notify('cell:mouseover', evt);\n },\n\n mouseout: function(evt) {\n\n this.notify('cell:mouseout', evt);\n },\n\n mouseenter: function(evt) {\n\n this.notify('cell:mouseenter', evt);\n },\n\n mouseleave: function(evt) {\n\n this.notify('cell:mouseleave', evt);\n },\n\n mousewheel: function(evt, x, y, delta) {\n\n this.notify('cell:mousewheel', evt, x, y, delta);\n },\n\n onevent: function(evt, eventName, x, y) {\n\n this.notify(eventName, evt, x, y);\n },\n\n onmagnet: function() {\n\n // noop\n },\n\n magnetpointerdblclick: function() {\n\n // noop\n },\n\n magnetcontextmenu: function() {\n\n // noop\n },\n\n checkMouseleave(evt) {\n const { paper, model } = this;\n if (paper.isAsync()) {\n // Make sure the source/target views are updated before this view.\n // It's not 100% bulletproof (see below) but it's a good enough solution for now.\n // The connected cells could be links as well. In that case, we would\n // need to recursively go through all the connected links and update\n // their source/target views as well.\n if (model.isLink()) {\n // The `this.sourceView` and `this.targetView` might not be updated yet.\n // We need to find the view by the model.\n const sourceElement = model.getSourceElement();\n if (sourceElement) {\n const sourceView = paper.findViewByModel(sourceElement);\n if (sourceView) {\n paper.dumpView(sourceView);\n paper.checkViewVisibility(sourceView);\n }\n }\n const targetElement = model.getTargetElement();\n if (targetElement) {\n const targetView = paper.findViewByModel(targetElement);\n if (targetView) {\n paper.dumpView(targetView);\n paper.checkViewVisibility(targetView);\n }\n }\n }\n // Do the updates of the current view synchronously now\n paper.dumpView(this);\n paper.checkViewVisibility(this);\n }\n const target = this.getEventTarget(evt, { fromPoint: true });\n const view = paper.findView(target);\n if (view === this) return;\n // Leaving the current view\n this.mouseleave(evt);\n if (!view) return;\n // Entering another view\n view.mouseenter(evt);\n },\n\n setInteractivity: function(value) {\n\n this.options.interactive = value;\n },\n\n isIntersecting: function(geometryShape, geometryData) {\n return intersection.exists(geometryShape, this.getNodeBBox(this.el), geometryData);\n },\n\n isEnclosedIn: function(geometryRect) {\n return geometryRect.containsRect(this.getNodeBBox(this.el));\n },\n\n isInArea: function(geometryRect, options = {}) {\n if (options.strict) {\n return this.isEnclosedIn(geometryRect);\n }\n return this.isIntersecting(geometryRect);\n },\n\n isAtPoint: function(point, options) {\n return this.getNodeBBox(this.el).containsPoint(point, options);\n }\n\n}, {\n\n Flags,\n\n Highlighting: HighlightingTypes,\n\n addPresentationAttributes: function(presentationAttributes) {\n return merge({}, result(this.prototype, 'presentationAttributes'), presentationAttributes, function(a, b) {\n if (!a || !b) return;\n if (typeof a === 'string') a = [a];\n if (typeof b === 'string') b = [b];\n if (Array.isArray(a) && Array.isArray(b)) return uniq(a.concat(b));\n });\n },\n\n evalAttribute,\n\n});\n\n\nObject.defineProperty(CellView.prototype, 'useCSSSelectors', {\n get() {\n const localUse = this.model.useCSSSelectors;\n if (localUse !== undefined) return localUse;\n return config.useCSSSelectors;\n }\n});\n\n// TODO: Move to Vectorizer library.\nfunction getCommonAncestorNode(node1, node2) {\n let parent = node1;\n do {\n if (parent.contains(node2)) return parent;\n parent = parent.parentNode;\n } while (parent);\n return null;\n}\n\n\n","import { assign, isFunction, toArray } from '../util/index.mjs';\nimport { CellView } from './CellView.mjs';\nimport { Cell } from './Cell.mjs';\nimport V from '../V/index.mjs';\nimport { elementViewPortPrototype } from './ports.mjs';\nimport { Rect, snapToGrid } from '../g/index.mjs';\n\nconst Flags = {\n TOOLS: CellView.Flags.TOOLS,\n UPDATE: 'UPDATE',\n TRANSLATE: 'TRANSLATE',\n RESIZE: 'RESIZE',\n PORTS: 'PORTS',\n ROTATE: 'ROTATE',\n RENDER: 'RENDER'\n};\n\nconst DragActions = {\n MOVE: 'move',\n MAGNET: 'magnet',\n};\n// Element base view and controller.\n// -------------------------------------------\n\nexport const ElementView = CellView.extend({\n\n /**\n * @abstract\n */\n _removePorts: function() {\n // implemented in ports.js\n },\n\n /**\n *\n * @abstract\n */\n _renderPorts: function() {\n // implemented in ports.js\n },\n\n className: function() {\n\n var classNames = CellView.prototype.className.apply(this).split(' ');\n\n classNames.push('element');\n\n return classNames.join(' ');\n },\n\n initialize: function() {\n\n CellView.prototype.initialize.apply(this, arguments);\n\n this._initializePorts();\n },\n\n presentationAttributes: {\n 'attrs': [Flags.UPDATE],\n 'position': [Flags.TRANSLATE, Flags.TOOLS],\n 'size': [Flags.RESIZE, Flags.PORTS, Flags.TOOLS],\n 'angle': [Flags.ROTATE, Flags.TOOLS],\n 'markup': [Flags.RENDER],\n 'ports': [Flags.PORTS],\n },\n\n initFlag: [Flags.RENDER],\n\n UPDATE_PRIORITY: 0,\n\n confirmUpdate: function(flag, opt) {\n\n const { useCSSSelectors } = this;\n if (this.hasFlag(flag, Flags.PORTS)) {\n this._removePorts();\n this._cleanPortsCache();\n }\n let transformHighlighters = false;\n if (this.hasFlag(flag, Flags.RENDER)) {\n this.render();\n this.updateTools(opt);\n this.updateHighlighters(true);\n transformHighlighters = true;\n flag = this.removeFlag(flag, [Flags.RENDER, Flags.UPDATE, Flags.RESIZE, Flags.TRANSLATE, Flags.ROTATE, Flags.PORTS, Flags.TOOLS]);\n } else {\n let updateHighlighters = false;\n\n // Skip this branch if render is required\n if (this.hasFlag(flag, Flags.RESIZE)) {\n this.resize(opt);\n updateHighlighters = true;\n // Resize method is calling `update()` internally\n flag = this.removeFlag(flag, [Flags.RESIZE, Flags.UPDATE]);\n if (useCSSSelectors) {\n // `resize()` rendered the ports when useCSSSelectors are enabled\n flag = this.removeFlag(flag, Flags.PORTS);\n }\n }\n if (this.hasFlag(flag, Flags.UPDATE)) {\n this.update(this.model, null, opt);\n flag = this.removeFlag(flag, Flags.UPDATE);\n updateHighlighters = true;\n if (useCSSSelectors) {\n // `update()` will render ports when useCSSSelectors are enabled\n flag = this.removeFlag(flag, Flags.PORTS);\n }\n }\n if (this.hasFlag(flag, Flags.TRANSLATE)) {\n this.translate();\n flag = this.removeFlag(flag, Flags.TRANSLATE);\n transformHighlighters = true;\n }\n if (this.hasFlag(flag, Flags.ROTATE)) {\n this.rotate();\n flag = this.removeFlag(flag, Flags.ROTATE);\n transformHighlighters = true;\n }\n if (this.hasFlag(flag, Flags.PORTS)) {\n this._renderPorts();\n updateHighlighters = true;\n flag = this.removeFlag(flag, Flags.PORTS);\n }\n\n if (updateHighlighters) {\n this.updateHighlighters(false);\n }\n }\n\n if (transformHighlighters) {\n this.transformHighlighters();\n }\n\n if (this.hasFlag(flag, Flags.TOOLS)) {\n this.updateTools(opt);\n flag = this.removeFlag(flag, Flags.TOOLS);\n }\n\n return flag;\n },\n\n /**\n * @abstract\n */\n _initializePorts: function() {\n\n },\n\n update: function(_, renderingOnlyAttrs) {\n\n this.cleanNodesCache();\n\n // When CSS selector strings are used, make sure no rule matches port nodes.\n const { useCSSSelectors } = this;\n if (useCSSSelectors) this._removePorts();\n\n var model = this.model;\n var modelAttrs = model.attr();\n this.updateDOMSubtreeAttributes(this.el, modelAttrs, {\n rootBBox: new Rect(model.size()),\n selectors: this.selectors,\n scalableNode: this.scalableNode,\n rotatableNode: this.rotatableNode,\n // Use rendering only attributes if they differs from the model attributes\n roAttributes: (renderingOnlyAttrs === modelAttrs) ? null : renderingOnlyAttrs\n });\n\n if (useCSSSelectors) {\n this._renderPorts();\n }\n },\n\n rotatableSelector: 'rotatable',\n scalableSelector: 'scalable',\n scalableNode: null,\n rotatableNode: null,\n\n // `prototype.markup` is rendered by default. Set the `markup` attribute on the model if the\n // default markup is not desirable.\n renderMarkup: function() {\n\n var element = this.model;\n var markup = element.get('markup') || element.markup;\n if (!markup) throw new Error('dia.ElementView: markup required');\n if (Array.isArray(markup)) return this.renderJSONMarkup(markup);\n if (typeof markup === 'string') return this.renderStringMarkup(markup);\n throw new Error('dia.ElementView: invalid markup');\n },\n\n renderJSONMarkup: function(markup) {\n\n var doc = this.parseDOMJSON(markup, this.el);\n var selectors = this.selectors = doc.selectors;\n this.rotatableNode = V(selectors[this.rotatableSelector]) || null;\n this.scalableNode = V(selectors[this.scalableSelector]) || null;\n // Fragment\n this.vel.append(doc.fragment);\n },\n\n renderStringMarkup: function(markup) {\n\n var vel = this.vel;\n vel.append(V(markup));\n // Cache transformation groups\n this.rotatableNode = vel.findOne('.rotatable');\n this.scalableNode = vel.findOne('.scalable');\n\n var selectors = this.selectors = {};\n selectors[this.selector] = this.el;\n },\n\n render: function() {\n\n this.vel.empty();\n this.renderMarkup();\n if (this.scalableNode) {\n // Double update is necessary for elements with the scalable group only\n // Note the resize() triggers the other `update`.\n this.update();\n }\n this.resize();\n if (this.rotatableNode) {\n // Translate transformation is applied on `this.el` while the rotation transformation\n // on `this.rotatableNode`\n this.rotate();\n this.translate();\n } else {\n this.updateTransformation();\n }\n if (!this.useCSSSelectors) this._renderPorts();\n return this;\n },\n\n resize: function(opt) {\n\n if (this.scalableNode) return this.sgResize(opt);\n if (this.model.attributes.angle) this.rotate();\n this.update();\n },\n\n translate: function() {\n\n if (this.rotatableNode) return this.rgTranslate();\n this.updateTransformation();\n },\n\n rotate: function() {\n\n if (this.rotatableNode) {\n this.rgRotate();\n // It's necessary to call the update for the nodes outside\n // the rotatable group referencing nodes inside the group\n this.update();\n return;\n }\n this.updateTransformation();\n },\n\n updateTransformation: function() {\n\n var transformation = this.getTranslateString();\n var rotateString = this.getRotateString();\n if (rotateString) transformation += ' ' + rotateString;\n this.vel.attr('transform', transformation);\n },\n\n getTranslateString: function() {\n\n const { x, y } = this.model.position();\n return `translate(${x},${y})`;\n },\n\n getRotateString: function() {\n\n const angle = this.model.angle();\n if (!angle) return null;\n const { width, height } = this.model.size();\n return `rotate(${angle},${width / 2},${height / 2})`;\n },\n\n // Rotatable & Scalable Group\n // always slower, kept mainly for backwards compatibility\n\n rgRotate: function() {\n\n this.rotatableNode.attr('transform', this.getRotateString());\n },\n\n rgTranslate: function() {\n\n this.vel.attr('transform', this.getTranslateString());\n },\n\n sgResize: function(opt) {\n\n var model = this.model;\n var angle = model.angle();\n var size = model.size();\n var scalable = this.scalableNode;\n\n // Getting scalable group's bbox.\n // Due to a bug in webkit's native SVG .getBBox implementation, the bbox of groups with path children includes the paths' control points.\n // To work around the issue, we need to check whether there are any path elements inside the scalable group.\n var recursive = false;\n if (scalable.node.getElementsByTagName('path').length > 0) {\n // If scalable has at least one descendant that is a path, we need to switch to recursive bbox calculation.\n // If there are no path descendants, group bbox calculation works and so we can use the (faster) native function directly.\n recursive = true;\n }\n var scalableBBox = scalable.getBBox({ recursive: recursive });\n\n // Make sure `scalableBbox.width` and `scalableBbox.height` are not zero which can happen if the element does not have any content. By making\n // the width/height 1, we prevent HTML errors of the type `scale(Infinity, Infinity)`.\n var sx = (size.width / (scalableBBox.width || 1));\n var sy = (size.height / (scalableBBox.height || 1));\n scalable.attr('transform', 'scale(' + sx + ',' + sy + ')');\n\n // Now the interesting part. The goal is to be able to store the object geometry via just `x`, `y`, `angle`, `width` and `height`\n // Order of transformations is significant but we want to reconstruct the object always in the order:\n // resize(), rotate(), translate() no matter of how the object was transformed. For that to work,\n // we must adjust the `x` and `y` coordinates of the object whenever we resize it (because the origin of the\n // rotation changes). The new `x` and `y` coordinates are computed by canceling the previous rotation\n // around the center of the resized object (which is a different origin then the origin of the previous rotation)\n // and getting the top-left corner of the resulting object. Then we clean up the rotation back to what it originally was.\n\n // Cancel the rotation but now around a different origin, which is the center of the scaled object.\n var rotatable = this.rotatableNode;\n var rotation = rotatable && rotatable.attr('transform');\n if (rotation) {\n\n rotatable.attr('transform', rotation + ' rotate(' + (-angle) + ',' + (size.width / 2) + ',' + (size.height / 2) + ')');\n var rotatableBBox = scalable.getBBox({ target: this.paper.cells });\n\n // Store new x, y and perform rotate() again against the new rotation origin.\n model.set('position', { x: rotatableBBox.x, y: rotatableBBox.y }, assign({ updateHandled: true }, opt));\n this.translate();\n this.rotate();\n }\n\n // Update must always be called on non-rotated element. Otherwise, relative positioning\n // would work with wrong (rotated) bounding boxes.\n this.update();\n },\n\n // Embedding mode methods.\n // -----------------------\n\n prepareEmbedding: function(data = {}) {\n\n const element = data.model || this.model;\n const paper = data.paper || this.paper;\n const graph = paper.model;\n\n const initialZIndices = data.initialZIndices = {};\n const embeddedCells = element.getEmbeddedCells({ deep: true });\n const connectedLinks = graph.getConnectedLinks(element, { deep: true, includeEnclosed: true });\n\n // Note: an embedded cell can be a connect link, but it's fine\n // to iterate over the cell twice.\n [\n element,\n ...embeddedCells,\n ...connectedLinks\n ].forEach(cell => initialZIndices[cell.id] = cell.attributes.z);\n\n element.startBatch('to-front');\n\n // Bring the model to the front with all his embeds.\n element.toFront({ deep: true, ui: true });\n\n // Note that at this point cells in the collection are not sorted by z index (it's running in the batch, see\n // the dia.Graph._sortOnChangeZ), so we can't assume that the last cell in the collection has the highest z.\n const maxZ = graph.getElements().reduce((max, cell) => Math.max(max, cell.attributes.z || 0), 0);\n\n // Move to front also all the inbound and outbound links that are connected\n // to any of the element descendant. If we bring to front only embedded elements,\n // links connected to them would stay in the background.\n connectedLinks.forEach((link) => {\n if (link.attributes.z <= maxZ) {\n link.set('z', maxZ + 1, { ui: true });\n }\n });\n\n element.stopBatch('to-front');\n\n // Before we start looking for suitable parent we remove the current one.\n const parentId = element.parent();\n if (parentId) {\n const parent = graph.getCell(parentId);\n parent.unembed(element, { ui: true });\n data.initialParentId = parentId;\n } else {\n data.initialParentId = null;\n }\n },\n\n processEmbedding: function(data = {}, evt, x, y) {\n\n const model = data.model || this.model;\n const paper = data.paper || this.paper;\n const graph = paper.model;\n const { findParentBy, frontParentOnly, validateEmbedding } = paper.options;\n\n let candidates;\n if (isFunction(findParentBy)) {\n candidates = toArray(findParentBy.call(graph, this, evt, x, y));\n } else if (findParentBy === 'pointer') {\n candidates = graph.findElementsAtPoint({ x, y });\n } else {\n candidates = graph.findElementsUnderElement(model, { searchBy: findParentBy });\n }\n\n candidates = candidates.filter((el) => {\n return (el instanceof Cell) && (model.id !== el.id) && !el.isEmbeddedIn(model);\n });\n\n if (frontParentOnly) {\n // pick the element with the highest `z` index\n candidates = candidates.slice(-1);\n }\n\n let newCandidateView = null;\n const prevCandidateView = data.candidateEmbedView;\n\n // iterate over all candidates starting from the last one (has the highest z-index).\n for (let i = candidates.length - 1; i >= 0; i--) {\n const candidate = candidates[i];\n if (prevCandidateView && prevCandidateView.model.id == candidate.id) {\n // candidate remains the same\n newCandidateView = prevCandidateView;\n break;\n } else {\n const view = candidate.findView(paper);\n if (!isFunction(validateEmbedding) || validateEmbedding.call(paper, this, view)) {\n // flip to the new candidate\n newCandidateView = view;\n break;\n }\n }\n }\n\n if (newCandidateView && newCandidateView != prevCandidateView) {\n // A new candidate view found. Highlight the new one.\n this.clearEmbedding(data);\n data.candidateEmbedView = newCandidateView.highlight(\n newCandidateView.findProxyNode(null, 'container'),\n { embedding: true }\n );\n }\n\n if (!newCandidateView && prevCandidateView) {\n // No candidate view found. Unhighlight the previous candidate.\n this.clearEmbedding(data);\n }\n },\n\n clearEmbedding: function(data) {\n\n data || (data = {});\n\n var candidateView = data.candidateEmbedView;\n if (candidateView) {\n // No candidate view found. Unhighlight the previous candidate.\n candidateView.unhighlight(\n candidateView.findProxyNode(null, 'container'),\n { embedding: true }\n );\n data.candidateEmbedView = null;\n }\n },\n\n finalizeEmbedding: function(data = {}) {\n\n const candidateView = data.candidateEmbedView;\n const element = data.model || this.model;\n const paper = data.paper || this.paper;\n\n if (candidateView) {\n\n // We finished embedding. Candidate view is chosen to become the parent of the model.\n candidateView.model.embed(element, { ui: true });\n candidateView.unhighlight(candidateView.findProxyNode(null, 'container'), { embedding: true });\n\n data.candidateEmbedView = null;\n\n } else {\n\n const { validateUnembedding } = paper.options;\n const { initialParentId } = data;\n // The element was originally embedded into another element.\n // The interaction would unembed the element. Let's validate\n // if the element can be unembedded.\n if (\n initialParentId &&\n typeof validateUnembedding === 'function' &&\n !validateUnembedding.call(paper, this)\n ) {\n this._disallowUnembed(data);\n return;\n }\n }\n\n paper.model.getConnectedLinks(element, { deep: true }).forEach(link => {\n link.reparent({ ui: true });\n });\n },\n\n _disallowUnembed: function(data) {\n const { model, whenNotAllowed = 'revert' } = data;\n const element = model || this.model;\n const paper = data.paper || this.paper;\n const graph = paper.model;\n switch (whenNotAllowed) {\n case 'remove': {\n element.remove({ ui: true });\n break;\n }\n case 'revert': {\n const { initialParentId, initialPosition, initialZIndices } = data;\n // Revert the element's position (and the position of its embedded cells if any)\n if (initialPosition) {\n const { x, y } = initialPosition;\n element.position(x, y, { deep: true, ui: true });\n }\n // Revert all the z-indices changed during the embedding\n if (initialZIndices) {\n Object.keys(initialZIndices).forEach(id => {\n const cell = graph.getCell(id);\n if (cell) {\n cell.set('z', initialZIndices[id], { ui: true });\n }\n });\n }\n // Revert the original parent\n const parent = graph.getCell(initialParentId);\n if (parent) {\n parent.embed(element, { ui: true });\n }\n break;\n }\n }\n },\n\n getTargetParentView: function(evt) {\n const { candidateEmbedView = null } = this.eventData(evt);\n return candidateEmbedView;\n },\n\n getDelegatedView: function() {\n\n var view = this;\n var model = view.model;\n var paper = view.paper;\n\n while (view) {\n if (model.isLink()) break;\n if (!model.isEmbedded() || view.can('stopDelegation')) return view;\n model = model.getParentCell();\n view = paper.findViewByModel(model);\n }\n\n return null;\n },\n\n findProxyNode: function(el, type) {\n el || (el = this.el);\n const nodeSelector = el.getAttribute(`${type}-selector`);\n if (nodeSelector) {\n const port = this.findAttribute('port', el);\n if (port) {\n const proxyPortNode = this.findPortNode(port, nodeSelector);\n if (proxyPortNode) return proxyPortNode;\n } else {\n const proxyNode = this.findNode(nodeSelector);\n if (proxyNode) return proxyNode;\n }\n }\n return el;\n },\n\n // Interaction. The controller part.\n // ---------------------------------\n\n notifyPointerdown(evt, x, y) {\n CellView.prototype.pointerdown.call(this, evt, x, y);\n this.notify('element:pointerdown', evt, x, y);\n },\n\n notifyPointermove(evt, x, y) {\n CellView.prototype.pointermove.call(this, evt, x, y);\n this.notify('element:pointermove', evt, x, y);\n },\n\n notifyPointerup(evt, x, y) {\n this.notify('element:pointerup', evt, x, y);\n CellView.prototype.pointerup.call(this, evt, x, y);\n },\n\n pointerdblclick: function(evt, x, y) {\n\n CellView.prototype.pointerdblclick.apply(this, arguments);\n this.notify('element:pointerdblclick', evt, x, y);\n },\n\n pointerclick: function(evt, x, y) {\n\n CellView.prototype.pointerclick.apply(this, arguments);\n this.notify('element:pointerclick', evt, x, y);\n },\n\n contextmenu: function(evt, x, y) {\n\n CellView.prototype.contextmenu.apply(this, arguments);\n this.notify('element:contextmenu', evt, x, y);\n },\n\n pointerdown: function(evt, x, y) {\n\n this.notifyPointerdown(evt, x, y);\n this.dragStart(evt, x, y);\n },\n\n pointermove: function(evt, x, y) {\n\n const data = this.eventData(evt);\n const { targetMagnet, action, delegatedView } = data;\n\n if (targetMagnet) {\n this.magnetpointermove(evt, targetMagnet, x, y);\n }\n\n switch (action) {\n case DragActions.MAGNET:\n this.dragMagnet(evt, x, y);\n break;\n case DragActions.MOVE:\n (delegatedView || this).drag(evt, x, y);\n // eslint: no-fallthrough=false\n default:\n if (data.preventPointerEvents) break;\n this.notifyPointermove(evt, x, y);\n break;\n }\n\n // Make sure the element view data is passed along.\n // It could have been wiped out in the handlers above.\n this.eventData(evt, data);\n },\n\n pointerup: function(evt, x, y) {\n\n const data = this.eventData(evt);\n const { targetMagnet, action, delegatedView } = data;\n\n if (targetMagnet) {\n this.magnetpointerup(evt, targetMagnet, x, y);\n }\n\n switch (action) {\n case DragActions.MAGNET:\n this.dragMagnetEnd(evt, x, y);\n break;\n case DragActions.MOVE:\n (delegatedView || this).dragEnd(evt, x, y);\n // eslint: no-fallthrough=false\n default:\n if (data.preventPointerEvents) break;\n this.notifyPointerup(evt, x, y);\n }\n\n if (targetMagnet) {\n this.magnetpointerclick(evt, targetMagnet, x, y);\n }\n\n this.checkMouseleave(evt);\n },\n\n mouseover: function(evt) {\n\n CellView.prototype.mouseover.apply(this, arguments);\n this.notify('element:mouseover', evt);\n },\n\n mouseout: function(evt) {\n\n CellView.prototype.mouseout.apply(this, arguments);\n this.notify('element:mouseout', evt);\n },\n\n mouseenter: function(evt) {\n\n CellView.prototype.mouseenter.apply(this, arguments);\n this.notify('element:mouseenter', evt);\n },\n\n mouseleave: function(evt) {\n\n CellView.prototype.mouseleave.apply(this, arguments);\n this.notify('element:mouseleave', evt);\n },\n\n mousewheel: function(evt, x, y, delta) {\n\n CellView.prototype.mousewheel.apply(this, arguments);\n this.notify('element:mousewheel', evt, x, y, delta);\n },\n\n onmagnet: function(evt, x, y) {\n\n const { currentTarget: targetMagnet } = evt;\n this.magnetpointerdown(evt, targetMagnet, x, y);\n this.eventData(evt, { targetMagnet });\n this.dragMagnetStart(evt, x, y);\n },\n\n magnetpointerdown: function(evt, magnet, x, y) {\n\n this.notify('element:magnet:pointerdown', evt, magnet, x, y);\n },\n\n magnetpointermove: function(evt, magnet, x, y) {\n\n this.notify('element:magnet:pointermove', evt, magnet, x, y);\n },\n\n magnetpointerup: function(evt, magnet, x, y) {\n\n this.notify('element:magnet:pointerup', evt, magnet, x, y);\n },\n\n magnetpointerdblclick: function(evt, magnet, x, y) {\n\n this.notify('element:magnet:pointerdblclick', evt, magnet, x, y);\n },\n\n magnetcontextmenu: function(evt, magnet, x, y) {\n\n this.notify('element:magnet:contextmenu', evt, magnet, x, y);\n },\n\n // Drag Start Handlers\n\n dragStart: function(evt, x, y) {\n\n if (this.isDefaultInteractionPrevented(evt)) return;\n\n var view = this.getDelegatedView();\n if (!view || !view.can('elementMove')) return;\n\n this.eventData(evt, {\n action: DragActions.MOVE,\n delegatedView: view\n });\n\n const position = view.model.position();\n view.eventData(evt, {\n initialPosition: position,\n pointerOffset: position.difference(x, y),\n restrictedArea: this.paper.getRestrictedArea(view, x, y)\n });\n },\n\n dragMagnetStart: function(evt, x, y) {\n\n const { paper } = this;\n const isPropagationAlreadyStopped = evt.isPropagationStopped();\n if (isPropagationAlreadyStopped) {\n // Special case when the propagation was already stopped\n // on the `element:magnet:pointerdown` event.\n // Do not trigger any `element:pointer*` events\n // but still start the magnet dragging.\n this.eventData(evt, { preventPointerEvents: true });\n }\n\n if (this.isDefaultInteractionPrevented(evt) || !this.can('addLinkFromMagnet')) {\n // Stop the default action, which is to start dragging a link.\n return;\n }\n\n const { targetMagnet = evt.currentTarget } = this.eventData(evt);\n evt.stopPropagation();\n\n // Invalid (Passive) magnet. Start dragging the element.\n if (!paper.options.validateMagnet.call(paper, this, targetMagnet, evt)) {\n if (isPropagationAlreadyStopped) {\n // Do not trigger `element:pointerdown` and start element dragging\n // if the propagation was stopped.\n this.dragStart(evt, x, y);\n // The `element:pointerdown` event is not triggered because\n // of `preventPointerEvents` flag.\n } else {\n // We need to reset the action\n // to `MOVE` so that the element is dragged.\n this.pointerdown(evt, x, y);\n }\n return;\n }\n\n // Valid magnet. Start dragging a link.\n if (paper.options.magnetThreshold <= 0) {\n this.dragLinkStart(evt, targetMagnet, x, y);\n }\n this.eventData(evt, { action: DragActions.MAGNET });\n },\n\n // Drag Handlers\n\n drag: function(evt, x, y) {\n\n var paper = this.paper;\n var grid = paper.options.gridSize;\n var element = this.model;\n var data = this.eventData(evt);\n var { pointerOffset, restrictedArea, embedding } = data;\n\n // Make sure the new element's position always snaps to the current grid\n var elX = snapToGrid(x + pointerOffset.x, grid);\n var elY = snapToGrid(y + pointerOffset.y, grid);\n\n element.position(elX, elY, { restrictedArea, deep: true, ui: true });\n\n if (paper.options.embeddingMode) {\n if (!embedding) {\n // Prepare the element for embedding only if the pointer moves.\n // We don't want to do unnecessary action with the element\n // if an user only clicks/dblclicks on it.\n this.prepareEmbedding(data);\n embedding = true;\n }\n this.processEmbedding(data, evt, x, y);\n }\n\n this.eventData(evt, {\n embedding\n });\n },\n\n dragMagnet: function(evt, x, y) {\n this.dragLink(evt, x, y);\n },\n\n // Drag End Handlers\n\n dragEnd: function(evt, x, y) {\n\n var data = this.eventData(evt);\n if (data.embedding) this.finalizeEmbedding(data);\n },\n\n dragMagnetEnd: function(evt, x, y) {\n this.dragLinkEnd(evt, x, y);\n },\n\n magnetpointerclick: function(evt, magnet, x, y) {\n var paper = this.paper;\n if (paper.eventData(evt).mousemoved > paper.options.clickThreshold) return;\n this.notify('element:magnet:pointerclick', evt, magnet, x, y);\n }\n\n}, {\n\n Flags: Flags,\n});\n\nassign(ElementView.prototype, elementViewPortPrototype);\n","// Does not make any changes to vertices.\n// Returns the arguments that are passed to it, unchanged.\nexport const normal = function(vertices, opt, linkView) {\n\n return vertices;\n};\n","import * as util from '../util/index.mjs';\n\n// Routes the link always to/from a certain side\n//\n// Arguments:\n// padding ... gap between the element and the first vertex. :: Default 40.\n// side ... 'left' | 'right' | 'top' | 'bottom' :: Default 'bottom'.\n//\nexport const oneSide = function(vertices, opt, linkView) {\n\n var side = opt.side || 'bottom';\n var padding = util.normalizeSides(opt.padding || 40);\n\n // LinkView contains cached source an target bboxes.\n // Note that those are Geometry rectangle objects.\n var sourceBBox = linkView.sourceBBox;\n var targetBBox = linkView.targetBBox;\n var sourcePoint = sourceBBox.center();\n var targetPoint = targetBBox.center();\n\n var coordinate, dimension, direction;\n\n switch (side) {\n case 'bottom':\n direction = 1;\n coordinate = 'y';\n dimension = 'height';\n break;\n case 'top':\n direction = -1;\n coordinate = 'y';\n dimension = 'height';\n break;\n case 'left':\n direction = -1;\n coordinate = 'x';\n dimension = 'width';\n break;\n case 'right':\n direction = 1;\n coordinate = 'x';\n dimension = 'width';\n break;\n default:\n throw new Error('Router: invalid side');\n }\n\n // move the points from the center of the element to outside of it.\n sourcePoint[coordinate] += direction * (sourceBBox[dimension] / 2 + padding[side]);\n targetPoint[coordinate] += direction * (targetBBox[dimension] / 2 + padding[side]);\n\n // make link orthogonal (at least the first and last vertex).\n if ((direction * (sourcePoint[coordinate] - targetPoint[coordinate])) > 0) {\n targetPoint[coordinate] = sourcePoint[coordinate];\n } else {\n sourcePoint[coordinate] = targetPoint[coordinate];\n }\n\n return [sourcePoint].concat(vertices, targetPoint);\n};\n","import * as g from '../g/index.mjs';\nimport * as util from '../util/index.mjs';\n\n// bearing -> opposite bearing\nvar opposites = {\n N: 'S',\n S: 'N',\n E: 'W',\n W: 'E'\n};\n\n// bearing -> radians\nvar radians = {\n N: -Math.PI / 2 * 3,\n S: -Math.PI / 2,\n E: 0,\n W: Math.PI\n};\n\n// HELPERS //\n\n// returns a point `p` where lines p,p1 and p,p2 are perpendicular and p is not contained\n// in the given box\nfunction freeJoin(p1, p2, bbox) {\n\n var p = new g.Point(p1.x, p2.y);\n if (bbox.containsPoint(p)) p = new g.Point(p2.x, p1.y);\n // kept for reference\n // if (bbox.containsPoint(p)) p = null;\n\n return p;\n}\n\n// returns either width or height of a bbox based on the given bearing\nfunction getBBoxSize(bbox, bearing) {\n\n return bbox[(bearing === 'W' || bearing === 'E') ? 'width' : 'height'];\n}\n\n// simple bearing method (calculates only orthogonal cardinals)\nfunction getBearing(from, to) {\n\n if (from.x === to.x) return (from.y > to.y) ? 'N' : 'S';\n if (from.y === to.y) return (from.x > to.x) ? 'W' : 'E';\n return null;\n}\n\n// transform point to a rect\nfunction getPointBox(p) {\n\n return new g.Rect(p.x, p.y, 0, 0);\n}\n\nfunction getPaddingBox(opt) {\n\n // if both provided, opt.padding wins over opt.elementPadding\n var sides = util.normalizeSides(opt.padding || opt.elementPadding || 20);\n\n return {\n x: -sides.left,\n y: -sides.top,\n width: sides.left + sides.right,\n height: sides.top + sides.bottom\n };\n}\n\n// return source bbox\nfunction getSourceBBox(linkView, opt) {\n\n return linkView.sourceBBox.clone().moveAndExpand(getPaddingBox(opt));\n}\n\n// return target bbox\nfunction getTargetBBox(linkView, opt) {\n\n return linkView.targetBBox.clone().moveAndExpand(getPaddingBox(opt));\n}\n\n// return source anchor\nfunction getSourceAnchor(linkView, opt) {\n\n if (linkView.sourceAnchor) return linkView.sourceAnchor;\n\n // fallback: center of bbox\n var sourceBBox = getSourceBBox(linkView, opt);\n return sourceBBox.center();\n}\n\n// return target anchor\nfunction getTargetAnchor(linkView, opt) {\n\n if (linkView.targetAnchor) return linkView.targetAnchor;\n\n // fallback: center of bbox\n var targetBBox = getTargetBBox(linkView, opt);\n return targetBBox.center(); // default\n}\n\n// PARTIAL ROUTERS //\n\nfunction vertexVertex(from, to, bearing) {\n\n var p1 = new g.Point(from.x, to.y);\n var p2 = new g.Point(to.x, from.y);\n var d1 = getBearing(from, p1);\n var d2 = getBearing(from, p2);\n var opposite = opposites[bearing];\n\n var p = (d1 === bearing || (d1 !== opposite && (d2 === opposite || d2 !== bearing))) ? p1 : p2;\n\n return { points: [p], direction: getBearing(p, to) };\n}\n\nfunction elementVertex(from, to, fromBBox) {\n\n var p = freeJoin(from, to, fromBBox);\n\n return { points: [p], direction: getBearing(p, to) };\n}\n\nfunction vertexElement(from, to, toBBox, bearing) {\n\n var route = {};\n\n var points = [new g.Point(from.x, to.y), new g.Point(to.x, from.y)];\n var freePoints = points.filter(function(pt) {\n return !toBBox.containsPoint(pt);\n });\n var freeBearingPoints = freePoints.filter(function(pt) {\n return getBearing(pt, from) !== bearing;\n });\n\n var p;\n\n if (freeBearingPoints.length > 0) {\n // Try to pick a point which bears the same direction as the previous segment.\n\n p = freeBearingPoints.filter(function(pt) {\n return getBearing(from, pt) === bearing;\n }).pop();\n p = p || freeBearingPoints[0];\n\n route.points = [p];\n route.direction = getBearing(p, to);\n\n } else {\n // Here we found only points which are either contained in the element or they would create\n // a link segment going in opposite direction from the previous one.\n // We take the point inside element and move it outside the element in the direction the\n // route is going. Now we can join this point with the current end (using freeJoin).\n\n p = util.difference(points, freePoints)[0];\n\n var p2 = (new g.Point(to)).move(p, -getBBoxSize(toBBox, bearing) / 2);\n var p1 = freeJoin(p2, from, toBBox);\n\n route.points = [p1, p2];\n route.direction = getBearing(p2, to);\n }\n\n return route;\n}\n\nfunction elementElement(from, to, fromBBox, toBBox) {\n\n var route = elementVertex(to, from, toBBox);\n var p1 = route.points[0];\n\n if (fromBBox.containsPoint(p1)) {\n\n route = elementVertex(from, to, fromBBox);\n var p2 = route.points[0];\n\n if (toBBox.containsPoint(p2)) {\n\n var fromBorder = (new g.Point(from)).move(p2, -getBBoxSize(fromBBox, getBearing(from, p2)) / 2);\n var toBorder = (new g.Point(to)).move(p1, -getBBoxSize(toBBox, getBearing(to, p1)) / 2);\n var mid = (new g.Line(fromBorder, toBorder)).midpoint();\n\n var startRoute = elementVertex(from, mid, fromBBox);\n var endRoute = vertexVertex(mid, to, startRoute.direction);\n\n route.points = [startRoute.points[0], endRoute.points[0]];\n route.direction = endRoute.direction;\n }\n }\n\n return route;\n}\n\n// Finds route for situations where one element is inside the other.\n// Typically the route is directed outside the outer element first and\n// then back towards the inner element.\nfunction insideElement(from, to, fromBBox, toBBox, bearing) {\n\n var route = {};\n var boundary = fromBBox.union(toBBox).inflate(1);\n\n // start from the point which is closer to the boundary\n var reversed = boundary.center().distance(to) > boundary.center().distance(from);\n var start = reversed ? to : from;\n var end = reversed ? from : to;\n\n var p1, p2, p3;\n\n if (bearing) {\n // Points on circle with radius equals 'W + H` are always outside the rectangle\n // with width W and height H if the center of that circle is the center of that rectangle.\n p1 = g.Point.fromPolar(boundary.width + boundary.height, radians[bearing], start);\n p1 = boundary.pointNearestToPoint(p1).move(p1, -1);\n\n } else {\n p1 = boundary.pointNearestToPoint(start).move(start, 1);\n }\n\n p2 = freeJoin(p1, end, boundary);\n\n if (p1.round().equals(p2.round())) {\n p2 = g.Point.fromPolar(boundary.width + boundary.height, g.toRad(p1.theta(start)) + Math.PI / 2, end);\n p2 = boundary.pointNearestToPoint(p2).move(end, 1).round();\n p3 = freeJoin(p1, p2, boundary);\n route.points = reversed ? [p2, p3, p1] : [p1, p3, p2];\n\n } else {\n route.points = reversed ? [p2, p1] : [p1, p2];\n }\n\n route.direction = reversed ? getBearing(p1, to) : getBearing(p2, to);\n\n return route;\n}\n\n// MAIN ROUTER //\n\n// Return points through which a connection needs to be drawn in order to obtain an orthogonal link\n// routing from source to target going through `vertices`.\nexport function orthogonal(vertices, opt, linkView) {\n\n var sourceBBox = getSourceBBox(linkView, opt);\n var targetBBox = getTargetBBox(linkView, opt);\n\n var sourceAnchor = getSourceAnchor(linkView, opt);\n var targetAnchor = getTargetAnchor(linkView, opt);\n\n // if anchor lies outside of bbox, the bbox expands to include it\n sourceBBox = sourceBBox.union(getPointBox(sourceAnchor));\n targetBBox = targetBBox.union(getPointBox(targetAnchor));\n\n vertices = util.toArray(vertices).map(g.Point);\n vertices.unshift(sourceAnchor);\n vertices.push(targetAnchor);\n\n var bearing; // bearing of previous route segment\n\n var orthogonalVertices = []; // the array of found orthogonal vertices to be returned\n for (var i = 0, max = vertices.length - 1; i < max; i++) {\n\n var route = null;\n\n var from = vertices[i];\n var to = vertices[i + 1];\n\n var isOrthogonal = !!getBearing(from, to);\n\n if (i === 0) { // source\n\n if (i + 1 === max) { // route source -> target\n\n // Expand one of the elements by 1px to detect situations when the two\n // elements are positioned next to each other with no gap in between.\n if (sourceBBox.intersect(targetBBox.clone().inflate(1))) {\n route = insideElement(from, to, sourceBBox, targetBBox);\n\n } else if (!isOrthogonal) {\n route = elementElement(from, to, sourceBBox, targetBBox);\n }\n\n } else { // route source -> vertex\n\n if (sourceBBox.containsPoint(to)) {\n route = insideElement(from, to, sourceBBox, getPointBox(to).moveAndExpand(getPaddingBox(opt)));\n\n } else if (!isOrthogonal) {\n route = elementVertex(from, to, sourceBBox);\n }\n }\n\n } else if (i + 1 === max) { // route vertex -> target\n\n // prevent overlaps with previous line segment\n var isOrthogonalLoop = isOrthogonal && getBearing(to, from) === bearing;\n\n if (targetBBox.containsPoint(from) || isOrthogonalLoop) {\n route = insideElement(from, to, getPointBox(from).moveAndExpand(getPaddingBox(opt)), targetBBox, bearing);\n\n } else if (!isOrthogonal) {\n route = vertexElement(from, to, targetBBox, bearing);\n }\n\n } else if (!isOrthogonal) { // route vertex -> vertex\n route = vertexVertex(from, to, bearing);\n }\n\n // applicable to all routes:\n\n // set bearing for next iteration\n if (route) {\n Array.prototype.push.apply(orthogonalVertices, route.points);\n bearing = route.direction;\n\n } else {\n // orthogonal route and not looped\n bearing = getBearing(from, to);\n }\n\n // push `to` point to identified orthogonal vertices array\n if (i + 1 < max) {\n orthogonalVertices.push(to);\n }\n }\n\n return orthogonalVertices;\n}\n","import * as g from '../g/index.mjs';\nimport * as util from '../util/index.mjs';\nimport { orthogonal } from './orthogonal.mjs';\n\nvar config = {\n\n // size of the step to find a route (the grid of the manhattan pathfinder)\n step: 10,\n\n // the number of route finding loops that cause the router to abort\n // returns fallback route instead\n maximumLoops: 2000,\n\n // the number of decimal places to round floating point coordinates\n precision: 1,\n\n // maximum change of direction\n maxAllowedDirectionChange: 90,\n\n // should the router use perpendicular linkView option?\n // does not connect anchor of element but rather a point close-by that is orthogonal\n // this looks much better\n perpendicular: true,\n\n // should the source and/or target not be considered as obstacles?\n excludeEnds: [], // 'source', 'target'\n\n // should certain types of elements not be considered as obstacles?\n excludeTypes: [],\n\n // possible starting directions from an element\n startDirections: ['top', 'right', 'bottom', 'left'],\n\n // possible ending directions to an element\n endDirections: ['top', 'right', 'bottom', 'left'],\n\n // specify the directions used above and what they mean\n directionMap: {\n top: { x: 0, y: -1 },\n right: { x: 1, y: 0 },\n bottom: { x: 0, y: 1 },\n left: { x: -1, y: 0 }\n },\n\n // cost of an orthogonal step\n cost: function() {\n\n return this.step;\n },\n\n // an array of directions to find next points on the route\n // different from start/end directions\n directions: function() {\n\n var step = this.step;\n var cost = this.cost();\n\n return [\n { offsetX: step, offsetY: 0, cost: cost },\n { offsetX: -step, offsetY: 0, cost: cost },\n { offsetX: 0, offsetY: step, cost: cost },\n { offsetX: 0, offsetY: -step, cost: cost }\n ];\n },\n\n // a penalty received for direction change\n penalties: function() {\n\n return {\n 0: 0,\n 45: this.step / 2,\n 90: this.step / 2\n };\n },\n\n // padding applied on the element bounding boxes\n paddingBox: function() {\n\n var step = this.step;\n\n return {\n x: -step,\n y: -step,\n width: 2 * step,\n height: 2 * step\n };\n },\n\n // A function that determines whether a given point is an obstacle or not.\n // If used, the `padding`, `excludeEnds`and `excludeTypes` options are ignored.\n // (point: dia.Point) => boolean;\n isPointObstacle: null,\n\n // a router to use when the manhattan router fails\n // (one of the partial routes returns null)\n fallbackRouter: function(vertices, opt, linkView) {\n\n if (!util.isFunction(orthogonal)) {\n throw new Error('Manhattan requires the orthogonal router as default fallback.');\n }\n\n return orthogonal(vertices, util.assign({}, config, opt), linkView);\n },\n\n /* Deprecated */\n // a simple route used in situations when main routing method fails\n // (exceed max number of loop iterations, inaccessible)\n fallbackRoute: function(from, to, opt) {\n\n return null; // null result will trigger the fallbackRouter\n\n // left for reference:\n /*// Find an orthogonal route ignoring obstacles.\n\n var point = ((opt.previousDirAngle || 0) % 180 === 0)\n ? new g.Point(from.x, to.y)\n : new g.Point(to.x, from.y);\n\n return [point];*/\n },\n\n // if a function is provided, it's used to route the link while dragging an end\n // i.e. function(from, to, opt) { return []; }\n draggingRoute: null\n};\n\n// HELPER CLASSES //\n\n// Map of obstacles\n// Helper structure to identify whether a point lies inside an obstacle.\nfunction ObstacleMap(opt) {\n\n this.map = {};\n this.options = opt;\n // tells how to divide the paper when creating the elements map\n this.mapGridSize = 100;\n}\n\nObstacleMap.prototype.build = function(graph, link) {\n\n var opt = this.options;\n\n // source or target element could be excluded from set of obstacles\n var excludedEnds = util.toArray(opt.excludeEnds).reduce(function(res, item) {\n\n var end = link.get(item);\n if (end) {\n var cell = graph.getCell(end.id);\n if (cell) {\n res.push(cell);\n }\n }\n\n return res;\n }, []);\n\n // Exclude any embedded elements from the source and the target element.\n var excludedAncestors = [];\n\n var source = graph.getCell(link.get('source').id);\n if (source) {\n excludedAncestors = util.union(excludedAncestors, source.getAncestors().map(function(cell) {\n return cell.id;\n }));\n }\n\n var target = graph.getCell(link.get('target').id);\n if (target) {\n excludedAncestors = util.union(excludedAncestors, target.getAncestors().map(function(cell) {\n return cell.id;\n }));\n }\n\n // Builds a map of all elements for quicker obstacle queries (i.e. is a point contained\n // in any obstacle?) (a simplified grid search).\n // The paper is divided into smaller cells, where each holds information about which\n // elements belong to it. When we query whether a point lies inside an obstacle we\n // don't need to go through all obstacles, we check only those in a particular cell.\n var mapGridSize = this.mapGridSize;\n\n graph.getElements().reduce(function(map, element) {\n\n var isExcludedType = util.toArray(opt.excludeTypes).includes(element.get('type'));\n var isExcludedEnd = excludedEnds.find(function(excluded) {\n return excluded.id === element.id;\n });\n var isExcludedAncestor = excludedAncestors.includes(element.id);\n\n var isExcluded = isExcludedType || isExcludedEnd || isExcludedAncestor;\n if (!isExcluded) {\n var bbox = element.getBBox().moveAndExpand(opt.paddingBox);\n\n var origin = bbox.origin().snapToGrid(mapGridSize);\n var corner = bbox.corner().snapToGrid(mapGridSize);\n\n for (var x = origin.x; x <= corner.x; x += mapGridSize) {\n for (var y = origin.y; y <= corner.y; y += mapGridSize) {\n var gridKey = x + '@' + y;\n map[gridKey] = map[gridKey] || [];\n map[gridKey].push(bbox);\n }\n }\n }\n\n return map;\n }, this.map);\n\n return this;\n};\n\nObstacleMap.prototype.isPointAccessible = function(point) {\n\n var mapKey = point.clone().snapToGrid(this.mapGridSize).toString();\n\n return util.toArray(this.map[mapKey]).every(function(obstacle) {\n return !obstacle.containsPoint(point);\n });\n};\n\n// Sorted Set\n// Set of items sorted by given value.\nfunction SortedSet() {\n this.items = [];\n this.hash = {};\n this.values = {};\n this.OPEN = 1;\n this.CLOSE = 2;\n}\n\nSortedSet.prototype.add = function(item, value) {\n\n if (this.hash[item]) {\n // item removal\n this.items.splice(this.items.indexOf(item), 1);\n } else {\n this.hash[item] = this.OPEN;\n }\n\n this.values[item] = value;\n\n var index = util.sortedIndex(this.items, item, function(i) {\n return this.values[i];\n }.bind(this));\n\n this.items.splice(index, 0, item);\n};\n\nSortedSet.prototype.remove = function(item) {\n\n this.hash[item] = this.CLOSE;\n};\n\nSortedSet.prototype.isOpen = function(item) {\n\n return this.hash[item] === this.OPEN;\n};\n\nSortedSet.prototype.isClose = function(item) {\n\n return this.hash[item] === this.CLOSE;\n};\n\nSortedSet.prototype.isEmpty = function() {\n\n return this.items.length === 0;\n};\n\nSortedSet.prototype.pop = function() {\n\n var item = this.items.shift();\n this.remove(item);\n return item;\n};\n\n// HELPERS //\n\n// return source bbox\nfunction getSourceBBox(linkView, opt) {\n\n // expand by padding box\n if (opt && opt.paddingBox) return linkView.sourceBBox.clone().moveAndExpand(opt.paddingBox);\n\n return linkView.sourceBBox.clone();\n}\n\n// return target bbox\nfunction getTargetBBox(linkView, opt) {\n\n // expand by padding box\n if (opt && opt.paddingBox) return linkView.targetBBox.clone().moveAndExpand(opt.paddingBox);\n\n return linkView.targetBBox.clone();\n}\n\n// return source anchor\nfunction getSourceAnchor(linkView, opt) {\n\n if (linkView.sourceAnchor) return linkView.sourceAnchor;\n\n // fallback: center of bbox\n var sourceBBox = getSourceBBox(linkView, opt);\n return sourceBBox.center();\n}\n\n// return target anchor\nfunction getTargetAnchor(linkView, opt) {\n\n if (linkView.targetAnchor) return linkView.targetAnchor;\n\n // fallback: center of bbox\n var targetBBox = getTargetBBox(linkView, opt);\n return targetBBox.center(); // default\n}\n\n// returns a direction index from start point to end point\n// corrects for grid deformation between start and end\nfunction getDirectionAngle(start, end, numDirections, grid, opt) {\n\n var quadrant = 360 / numDirections;\n var angleTheta = start.theta(fixAngleEnd(start, end, grid, opt));\n var normalizedAngle = g.normalizeAngle(angleTheta + (quadrant / 2));\n return quadrant * Math.floor(normalizedAngle / quadrant);\n}\n\n// helper function for getDirectionAngle()\n// corrects for grid deformation\n// (if a point is one grid steps away from another in both dimensions,\n// it is considered to be 45 degrees away, even if the real angle is different)\n// this causes visible angle discrepancies if `opt.step` is much larger than `paper.gridSize`\nfunction fixAngleEnd(start, end, grid, opt) {\n\n var step = opt.step;\n\n var diffX = end.x - start.x;\n var diffY = end.y - start.y;\n\n var gridStepsX = diffX / grid.x;\n var gridStepsY = diffY / grid.y;\n\n var distanceX = gridStepsX * step;\n var distanceY = gridStepsY * step;\n\n return new g.Point(start.x + distanceX, start.y + distanceY);\n}\n\n// return the change in direction between two direction angles\nfunction getDirectionChange(angle1, angle2) {\n\n var directionChange = Math.abs(angle1 - angle2);\n return (directionChange > 180) ? (360 - directionChange) : directionChange;\n}\n\n// fix direction offsets according to current grid\nfunction getGridOffsets(directions, grid, opt) {\n\n var step = opt.step;\n\n util.toArray(opt.directions).forEach(function(direction) {\n\n direction.gridOffsetX = (direction.offsetX / step) * grid.x;\n direction.gridOffsetY = (direction.offsetY / step) * grid.y;\n });\n}\n\n// get grid size in x and y dimensions, adapted to source and target positions\nfunction getGrid(step, source, target) {\n\n return {\n source: source.clone(),\n x: getGridDimension(target.x - source.x, step),\n y: getGridDimension(target.y - source.y, step)\n };\n}\n\n// helper function for getGrid()\nfunction getGridDimension(diff, step) {\n\n // return step if diff = 0\n if (!diff) return step;\n\n var absDiff = Math.abs(diff);\n var numSteps = Math.round(absDiff / step);\n\n // return absDiff if less than one step apart\n if (!numSteps) return absDiff;\n\n // otherwise, return corrected step\n var roundedDiff = numSteps * step;\n var remainder = absDiff - roundedDiff;\n var stepCorrection = remainder / numSteps;\n\n return step + stepCorrection;\n}\n\n// return a clone of point snapped to grid\nfunction snapToGrid(point, grid) {\n\n var source = grid.source;\n\n var snappedX = g.snapToGrid(point.x - source.x, grid.x) + source.x;\n var snappedY = g.snapToGrid(point.y - source.y, grid.y) + source.y;\n\n return new g.Point(snappedX, snappedY);\n}\n\n// round the point to opt.precision\nfunction round(point, precision) {\n\n return point.round(precision);\n}\n\n// snap to grid and then round the point\nfunction align(point, grid, precision) {\n\n return round(snapToGrid(point.clone(), grid), precision);\n}\n\n// return a string representing the point\n// string is rounded in both dimensions\nfunction getKey(point) {\n\n return point.clone().toString();\n}\n\n// return a normalized vector from given point\n// used to determine the direction of a difference of two points\nfunction normalizePoint(point) {\n\n return new g.Point(\n point.x === 0 ? 0 : Math.abs(point.x) / point.x,\n point.y === 0 ? 0 : Math.abs(point.y) / point.y\n );\n}\n\n// PATHFINDING //\n\n// reconstructs a route by concatenating points with their parents\nfunction reconstructRoute(parents, points, tailPoint, from, to, grid, opt) {\n\n var route = [];\n\n var prevDiff = normalizePoint(to.difference(tailPoint));\n\n // tailPoint is assumed to be aligned already\n var currentKey = getKey(tailPoint);\n var parent = parents[currentKey];\n\n var point;\n while (parent) {\n\n // point is assumed to be aligned already\n point = points[currentKey];\n\n var diff = normalizePoint(point.difference(parent));\n if (!diff.equals(prevDiff)) {\n route.unshift(point);\n prevDiff = diff;\n }\n\n // parent is assumed to be aligned already\n currentKey = getKey(parent);\n parent = parents[currentKey];\n }\n\n // leadPoint is assumed to be aligned already\n var leadPoint = points[currentKey];\n\n var fromDiff = normalizePoint(leadPoint.difference(from));\n if (!fromDiff.equals(prevDiff)) {\n route.unshift(leadPoint);\n }\n\n return route;\n}\n\n// heuristic method to determine the distance between two points\nfunction estimateCost(from, endPoints) {\n\n var min = Infinity;\n\n for (var i = 0, len = endPoints.length; i < len; i++) {\n var cost = from.manhattanDistance(endPoints[i]);\n if (cost < min) min = cost;\n }\n\n return min;\n}\n\n// find points around the bbox taking given directions into account\n// lines are drawn from anchor in given directions, intersections recorded\n// if anchor is outside bbox, only those directions that intersect get a rect point\n// the anchor itself is returned as rect point (representing some directions)\n// (since those directions are unobstructed by the bbox)\nfunction getRectPoints(anchor, bbox, directionList, grid, opt) {\n\n var precision = opt.precision;\n var directionMap = opt.directionMap;\n\n var anchorCenterVector = anchor.difference(bbox.center());\n\n var keys = util.isObject(directionMap) ? Object.keys(directionMap) : [];\n var dirList = util.toArray(directionList);\n var rectPoints = keys.reduce(function(res, key) {\n\n if (dirList.includes(key)) {\n var direction = directionMap[key];\n\n // create a line that is guaranteed to intersect the bbox if bbox is in the direction\n // even if anchor lies outside of bbox\n var endpoint = new g.Point(\n anchor.x + direction.x * (Math.abs(anchorCenterVector.x) + bbox.width),\n anchor.y + direction.y * (Math.abs(anchorCenterVector.y) + bbox.height)\n );\n var intersectionLine = new g.Line(anchor, endpoint);\n\n // get the farther intersection, in case there are two\n // (that happens if anchor lies next to bbox)\n var intersections = intersectionLine.intersect(bbox) || [];\n var numIntersections = intersections.length;\n var farthestIntersectionDistance;\n var farthestIntersection = null;\n for (var i = 0; i < numIntersections; i++) {\n var currentIntersection = intersections[i];\n var distance = anchor.squaredDistance(currentIntersection);\n if ((farthestIntersectionDistance === undefined) || (distance > farthestIntersectionDistance)) {\n farthestIntersectionDistance = distance;\n farthestIntersection = currentIntersection;\n }\n }\n\n // if an intersection was found in this direction, it is our rectPoint\n if (farthestIntersection) {\n var point = align(farthestIntersection, grid, precision);\n\n // if the rectPoint lies inside the bbox, offset it by one more step\n if (bbox.containsPoint(point)) {\n point = align(point.offset(direction.x * grid.x, direction.y * grid.y), grid, precision);\n }\n\n // then add the point to the result array\n // aligned\n res.push(point);\n }\n }\n\n return res;\n }, []);\n\n // if anchor lies outside of bbox, add it to the array of points\n if (!bbox.containsPoint(anchor)) {\n // aligned\n rectPoints.push(align(anchor, grid, precision));\n }\n\n return rectPoints;\n}\n\n// finds the route between two points/rectangles (`from`, `to`) implementing A* algorithm\n// rectangles get rect points assigned by getRectPoints()\nfunction findRoute(from, to, isPointObstacle, opt) {\n\n var precision = opt.precision;\n\n // Get grid for this route.\n\n var sourceAnchor, targetAnchor;\n\n if (from instanceof g.Rect) { // `from` is sourceBBox\n sourceAnchor = round(getSourceAnchor(this, opt).clone(), precision);\n } else {\n sourceAnchor = round(from.clone(), precision);\n }\n\n if (to instanceof g.Rect) { // `to` is targetBBox\n targetAnchor = round(getTargetAnchor(this, opt).clone(), precision);\n } else {\n targetAnchor = round(to.clone(), precision);\n }\n\n var grid = getGrid(opt.step, sourceAnchor, targetAnchor);\n\n // Get pathfinding points.\n\n var start, end; // aligned with grid by definition\n var startPoints, endPoints; // assumed to be aligned with grid already\n\n // set of points we start pathfinding from\n if (from instanceof g.Rect) { // `from` is sourceBBox\n start = sourceAnchor;\n startPoints = getRectPoints(start, from, opt.startDirections, grid, opt);\n\n } else {\n start = sourceAnchor;\n startPoints = [start];\n }\n\n // set of points we want the pathfinding to finish at\n if (to instanceof g.Rect) { // `to` is targetBBox\n end = targetAnchor;\n endPoints = getRectPoints(targetAnchor, to, opt.endDirections, grid, opt);\n\n } else {\n end = targetAnchor;\n endPoints = [end];\n }\n\n // take into account only accessible rect points (those not under obstacles)\n startPoints = startPoints.filter(p => !isPointObstacle(p));\n endPoints = endPoints.filter(p => !isPointObstacle(p));\n\n // Check that there is an accessible route point on both sides.\n // Otherwise, use fallbackRoute().\n if (startPoints.length > 0 && endPoints.length > 0) {\n\n // The set of tentative points to be evaluated, initially containing the start points.\n // Rounded to nearest integer for simplicity.\n var openSet = new SortedSet();\n // Keeps reference to actual points for given elements of the open set.\n var points = {};\n // Keeps reference to a point that is immediate predecessor of given element.\n var parents = {};\n // Cost from start to a point along best known path.\n var costs = {};\n\n for (var i = 0, n = startPoints.length; i < n; i++) {\n // startPoint is assumed to be aligned already\n var startPoint = startPoints[i];\n\n var key = getKey(startPoint);\n\n openSet.add(key, estimateCost(startPoint, endPoints));\n points[key] = startPoint;\n costs[key] = 0;\n }\n\n var previousRouteDirectionAngle = opt.previousDirectionAngle; // undefined for first route\n var isPathBeginning = (previousRouteDirectionAngle === undefined);\n\n // directions\n var direction, directionChange;\n var directions = opt.directions;\n getGridOffsets(directions, grid, opt);\n\n var numDirections = directions.length;\n\n var endPointsKeys = util.toArray(endPoints).reduce(function(res, endPoint) {\n // endPoint is assumed to be aligned already\n\n var key = getKey(endPoint);\n res.push(key);\n return res;\n }, []);\n\n // main route finding loop\n var loopsRemaining = opt.maximumLoops;\n while (!openSet.isEmpty() && loopsRemaining > 0) {\n\n // remove current from the open list\n var currentKey = openSet.pop();\n var currentPoint = points[currentKey];\n var currentParent = parents[currentKey];\n var currentCost = costs[currentKey];\n\n var isRouteBeginning = (currentParent === undefined); // undefined for route starts\n var isStart = currentPoint.equals(start); // (is source anchor or `from` point) = can leave in any direction\n\n var previousDirectionAngle;\n if (!isRouteBeginning) previousDirectionAngle = getDirectionAngle(currentParent, currentPoint, numDirections, grid, opt); // a vertex on the route\n else if (!isPathBeginning) previousDirectionAngle = previousRouteDirectionAngle; // beginning of route on the path\n else if (!isStart) previousDirectionAngle = getDirectionAngle(start, currentPoint, numDirections, grid, opt); // beginning of path, start rect point\n else previousDirectionAngle = null; // beginning of path, source anchor or `from` point\n\n // check if we reached any endpoint\n var samePoints = startPoints.length === endPoints.length;\n if (samePoints) {\n for (var j = 0; j < startPoints.length; j++) {\n if (!startPoints[j].equals(endPoints[j])) {\n samePoints = false;\n break;\n }\n }\n }\n var skipEndCheck = (isRouteBeginning && samePoints);\n if (!skipEndCheck && (endPointsKeys.indexOf(currentKey) >= 0)) {\n opt.previousDirectionAngle = previousDirectionAngle;\n return reconstructRoute(parents, points, currentPoint, start, end, grid, opt);\n }\n\n // go over all possible directions and find neighbors\n for (i = 0; i < numDirections; i++) {\n direction = directions[i];\n\n var directionAngle = direction.angle;\n directionChange = getDirectionChange(previousDirectionAngle, directionAngle);\n\n // if the direction changed rapidly, don't use this point\n // any direction is allowed for starting points\n if (!(isPathBeginning && isStart) && directionChange > opt.maxAllowedDirectionChange) continue;\n\n var neighborPoint = align(currentPoint.clone().offset(direction.gridOffsetX, direction.gridOffsetY), grid, precision);\n var neighborKey = getKey(neighborPoint);\n\n // Closed points from the openSet were already evaluated.\n if (openSet.isClose(neighborKey) || isPointObstacle(neighborPoint)) continue;\n\n // We can only enter end points at an acceptable angle.\n if (endPointsKeys.indexOf(neighborKey) >= 0) { // neighbor is an end point\n\n var isNeighborEnd = neighborPoint.equals(end); // (is target anchor or `to` point) = can be entered in any direction\n\n if (!isNeighborEnd) {\n var endDirectionAngle = getDirectionAngle(neighborPoint, end, numDirections, grid, opt);\n var endDirectionChange = getDirectionChange(directionAngle, endDirectionAngle);\n\n if (endDirectionChange > opt.maxAllowedDirectionChange) continue;\n }\n }\n\n // The current direction is ok.\n\n var neighborCost = direction.cost;\n var neighborPenalty = isStart ? 0 : opt.penalties[directionChange]; // no penalties for start point\n var costFromStart = currentCost + neighborCost + neighborPenalty;\n\n if (!openSet.isOpen(neighborKey) || (costFromStart < costs[neighborKey])) {\n // neighbor point has not been processed yet\n // or the cost of the path from start is lower than previously calculated\n\n points[neighborKey] = neighborPoint;\n parents[neighborKey] = currentPoint;\n costs[neighborKey] = costFromStart;\n openSet.add(neighborKey, costFromStart + estimateCost(neighborPoint, endPoints));\n }\n }\n\n loopsRemaining--;\n }\n }\n\n // no route found (`to` point either wasn't accessible or finding route took\n // way too much calculation)\n return opt.fallbackRoute.call(this, start, end, opt);\n}\n\n// resolve some of the options\nfunction resolveOptions(opt) {\n\n opt.directions = util.result(opt, 'directions');\n opt.penalties = util.result(opt, 'penalties');\n opt.paddingBox = util.result(opt, 'paddingBox');\n opt.padding = util.result(opt, 'padding');\n\n if (opt.padding) {\n // if both provided, opt.padding wins over opt.paddingBox\n var sides = util.normalizeSides(opt.padding);\n opt.paddingBox = {\n x: -sides.left,\n y: -sides.top,\n width: sides.left + sides.right,\n height: sides.top + sides.bottom\n };\n }\n\n util.toArray(opt.directions).forEach(function(direction) {\n\n var point1 = new g.Point(0, 0);\n var point2 = new g.Point(direction.offsetX, direction.offsetY);\n\n direction.angle = g.normalizeAngle(point1.theta(point2));\n });\n}\n\n// initialization of the route finding\nfunction router(vertices, opt, linkView) {\n\n resolveOptions(opt);\n\n // enable/disable linkView perpendicular option\n linkView.options.perpendicular = !!opt.perpendicular;\n\n var sourceBBox = getSourceBBox(linkView, opt);\n var targetBBox = getTargetBBox(linkView, opt);\n\n var sourceAnchor = getSourceAnchor(linkView, opt);\n //var targetAnchor = getTargetAnchor(linkView, opt);\n\n // pathfinding\n let isPointObstacle;\n if (typeof opt.isPointObstacle === 'function') {\n isPointObstacle = opt.isPointObstacle;\n } else {\n const map = new ObstacleMap(opt);\n map.build(linkView.paper.model, linkView.model);\n isPointObstacle = (point) => !map.isPointAccessible(point);\n }\n\n var oldVertices = util.toArray(vertices).map(g.Point);\n var newVertices = [];\n var tailPoint = sourceAnchor; // the origin of first route's grid, does not need snapping\n\n // find a route by concatenating all partial routes (routes need to pass through vertices)\n // source -> vertex[1] -> ... -> vertex[n] -> target\n var to, from;\n\n for (var i = 0, len = oldVertices.length; i <= len; i++) {\n\n var partialRoute = null;\n\n from = to || sourceBBox;\n to = oldVertices[i];\n\n if (!to) {\n // this is the last iteration\n // we ran through all vertices in oldVertices\n // 'to' is not a vertex.\n\n to = targetBBox;\n\n // If the target is a point (i.e. it's not an element), we\n // should use dragging route instead of main routing method if it has been provided.\n var isEndingAtPoint = !linkView.model.get('source').id || !linkView.model.get('target').id;\n\n if (isEndingAtPoint && util.isFunction(opt.draggingRoute)) {\n // Make sure we are passing points only (not rects).\n var dragFrom = (from === sourceBBox) ? sourceAnchor : from;\n var dragTo = to.origin();\n\n partialRoute = opt.draggingRoute.call(linkView, dragFrom, dragTo, opt);\n }\n }\n\n // if partial route has not been calculated yet use the main routing method to find one\n partialRoute = partialRoute || findRoute.call(linkView, from, to, isPointObstacle, opt);\n\n if (partialRoute === null) { // the partial route cannot be found\n return opt.fallbackRouter(vertices, opt, linkView);\n }\n\n var leadPoint = partialRoute[0];\n\n // remove the first point if the previous partial route had the same point as last\n if (leadPoint && leadPoint.equals(tailPoint)) partialRoute.shift();\n\n // save tailPoint for next iteration\n tailPoint = partialRoute[partialRoute.length - 1] || tailPoint;\n\n Array.prototype.push.apply(newVertices, partialRoute);\n }\n\n return newVertices;\n}\n\n// public function\nexport const manhattan = function(vertices, opt, linkView) {\n return router(vertices, util.assign({}, config, opt), linkView);\n};\n","import { manhattan } from './manhattan.mjs';\nimport * as util from '../util/index.mjs';\nimport * as g from '../g/index.mjs';\n\nvar config = {\n\n maxAllowedDirectionChange: 45,\n\n // cost of a diagonal step\n diagonalCost: function() {\n\n var step = this.step;\n return Math.ceil(Math.sqrt(step * step << 1));\n },\n\n // an array of directions to find next points on the route\n // different from start/end directions\n directions: function() {\n\n var step = this.step;\n var cost = this.cost();\n var diagonalCost = this.diagonalCost();\n\n return [\n { offsetX: step, offsetY: 0, cost: cost },\n { offsetX: step, offsetY: step, cost: diagonalCost },\n { offsetX: 0, offsetY: step, cost: cost },\n { offsetX: -step, offsetY: step, cost: diagonalCost },\n { offsetX: -step, offsetY: 0, cost: cost },\n { offsetX: -step, offsetY: -step, cost: diagonalCost },\n { offsetX: 0, offsetY: -step, cost: cost },\n { offsetX: step, offsetY: -step, cost: diagonalCost }\n ];\n },\n\n // a simple route used in situations when main routing method fails\n // (exceed max number of loop iterations, inaccessible)\n fallbackRoute: function(from, to, opt) {\n\n // Find a route which breaks by 45 degrees ignoring all obstacles.\n\n var theta = from.theta(to);\n\n var route = [];\n\n var a = { x: to.x, y: from.y };\n var b = { x: from.x, y: to.y };\n\n if (theta % 180 > 90) {\n var t = a;\n a = b;\n b = t;\n }\n\n var p1 = (theta % 90) < 45 ? a : b;\n var l1 = new g.Line(from, p1);\n\n var alpha = 90 * Math.ceil(theta / 90);\n\n var p2 = g.Point.fromPolar(l1.squaredLength(), g.toRad(alpha + 135), p1);\n var l2 = new g.Line(to, p2);\n\n var intersectionPoint = l1.intersection(l2);\n var point = intersectionPoint ? intersectionPoint : to;\n\n var directionFrom = intersectionPoint ? point : from;\n\n var quadrant = 360 / opt.directions.length;\n var angleTheta = directionFrom.theta(to);\n var normalizedAngle = g.normalizeAngle(angleTheta + (quadrant / 2));\n var directionAngle = quadrant * Math.floor(normalizedAngle / quadrant);\n\n opt.previousDirectionAngle = directionAngle;\n\n if (point) route.push(point.round());\n route.push(to);\n\n return route;\n }\n};\n\n// public function\nexport const metro = function(vertices, opt, linkView) {\n\n if (!util.isFunction(manhattan)) {\n throw new Error('Metro requires the manhattan router.');\n }\n\n return manhattan(vertices, util.assign({}, config, opt), linkView);\n};\n\n","import * as g from '../g/index.mjs';\n\nconst Directions = {\n AUTO: 'auto',\n LEFT: 'left',\n RIGHT: 'right',\n TOP: 'top',\n BOTTOM: 'bottom',\n ANCHOR_SIDE: 'anchor-side',\n MAGNET_SIDE: 'magnet-side'\n};\n\nconst DEFINED_DIRECTIONS = [Directions.LEFT, Directions.RIGHT, Directions.TOP, Directions.BOTTOM];\n\nconst OPPOSITE_DIRECTIONS = {\n [Directions.LEFT]: Directions.RIGHT,\n [Directions.RIGHT]: Directions.LEFT,\n [Directions.TOP]: Directions.BOTTOM,\n [Directions.BOTTOM]: Directions.TOP\n};\n\nconst VERTICAL_DIRECTIONS = [Directions.TOP, Directions.BOTTOM];\n\nconst ANGLE_DIRECTION_MAP = {\n 0: Directions.RIGHT,\n 180: Directions.LEFT,\n 270: Directions.TOP,\n 90: Directions.BOTTOM\n};\n\nfunction getSegmentAngle(line) {\n // TODO: the angle() method is general and therefore unnecessarily heavy for orthogonal links\n return line.angle();\n}\n\nfunction simplifyPoints(points) {\n // TODO: use own more efficient implementation (filter points that do not change direction).\n // To simplify segments that are almost aligned (start and end points differ by e.g. 0.5px), use a threshold of 1.\n return new g.Polyline(points).simplify({ threshold: 1 }).points;\n}\n\nfunction resolveSides(source, target) {\n const { point: sourcePoint, x0: sx0, y0: sy0, view: sourceView, bbox: sourceBBox, direction: sourceDirection } = source;\n const { point: targetPoint, x0: tx0, y0: ty0, view: targetView, bbox: targetBBox, direction: targetDirection } = target;\n\n let sourceSide;\n\n if (!sourceView) {\n const sourceLinkAnchorBBox = new g.Rect(sx0, sy0, 0, 0);\n sourceSide = DEFINED_DIRECTIONS.includes(sourceDirection) ? sourceDirection : sourceLinkAnchorBBox.sideNearestToPoint(targetPoint);\n } else if (sourceView.model.isLink()) {\n sourceSide = getDirectionForLinkConnection(targetPoint, sourcePoint, sourceView);\n } else if (sourceDirection === Directions.ANCHOR_SIDE) {\n sourceSide = sourceBBox.sideNearestToPoint(sourcePoint);\n } else if (sourceDirection === Directions.MAGNET_SIDE) {\n sourceSide = sourceView.model.getBBox().sideNearestToPoint(sourcePoint);\n } else {\n sourceSide = sourceDirection;\n }\n\n let targetSide;\n\n if (!targetView) {\n const targetLinkAnchorBBox = new g.Rect(tx0, ty0, 0, 0);\n targetSide = DEFINED_DIRECTIONS.includes(targetDirection) ? targetDirection : targetLinkAnchorBBox.sideNearestToPoint(sourcePoint);\n } else if (targetView.model.isLink()) {\n targetSide = getDirectionForLinkConnection(sourcePoint, targetPoint, targetView);\n } else if (targetDirection === Directions.ANCHOR_SIDE) {\n targetSide = targetBBox.sideNearestToPoint(targetPoint);\n } else if (targetDirection === Directions.MAGNET_SIDE) {\n targetSide = targetView.model.getBBox().sideNearestToPoint(targetPoint);\n } else {\n targetSide = targetDirection;\n }\n\n return [sourceSide, targetSide];\n}\n\nfunction resolveForTopSourceSide(source, target, nextInLine) {\n const { x0: sx0, y0: sy0, width, height, point: anchor, margin } = source;\n const sx1 = sx0 + width;\n const sy1 = sy0 + height;\n const smx0 = sx0 - margin;\n const smx1 = sx1 + margin;\n const smy0 = sy0 - margin;\n\n const { x: ax } = anchor;\n const { x0: tx, y0: ty } = target;\n\n if (tx === ax && ty < sy0) return Directions.BOTTOM;\n if (tx < ax && ty < smy0) {\n if (nextInLine.point.x === ax) return Directions.BOTTOM;\n return Directions.RIGHT;\n }\n if (tx > ax && ty < smy0) {\n if (nextInLine.point.x === ax) return Directions.BOTTOM;\n return Directions.LEFT;\n }\n if (tx < smx0 && ty > smy0) return Directions.TOP;\n if (tx > smx1 && ty > smy0) return Directions.TOP;\n if (tx >= smx0 && tx <= ax && ty > sy1) {\n if (nextInLine.point.x < tx) {\n return Directions.RIGHT;\n }\n return Directions.LEFT;\n }\n if (tx <= smx1 && tx >= ax && ty > sy1) {\n if (nextInLine.point.x < tx) {\n return Directions.RIGHT;\n }\n return Directions.LEFT;\n }\n\n return Directions.BOTTOM;\n}\n\nfunction resolveForBottomSourceSide(source, target, nextInLine) {\n const { x0: sx0, y0: sy0, width, height, point: anchor, margin } = source;\n const sx1 = sx0 + width;\n const sy1 = sy0 + height;\n const smx0 = sx0 - margin;\n const smx1 = sx1 + margin;\n const smy1 = sy1 + margin;\n\n const { x: ax } = anchor;\n const { x0: tx, y0: ty } = target;\n\n if (tx === ax && ty > sy1) return Directions.TOP;\n if (tx < ax && ty > smy1) {\n if (nextInLine.point.x === ax) return Directions.TOP;\n return Directions.RIGHT;\n }\n if (tx > ax && ty > smy1) {\n if (nextInLine.point.x === ax) return Directions.TOP;\n return Directions.LEFT;\n }\n if (tx < smx0 && ty < smy1) return Directions.BOTTOM;\n if (tx > smx1 && ty < smy1) return Directions.BOTTOM;\n if (tx >= smx0 && tx <= ax && ty < sy0) {\n if (nextInLine.point.x < tx) {\n return Directions.RIGHT;\n }\n return Directions.LEFT;\n }\n if (tx <= smx1 && tx >= ax && ty < sy0) {\n if (nextInLine.point.x < tx) {\n return Directions.RIGHT;\n }\n return Directions.LEFT;\n }\n\n return Directions.TOP;\n}\n\nfunction resolveForLeftSourceSide(source, target, nextInLine) {\n const { y0: sy0, x0: sx0, width, height, point: anchor, margin } = source;\n const sx1 = sx0 + width;\n const sy1 = sy0 + height;\n const smx0 = sx0 - margin;\n const smy0 = sy0 - margin;\n const smy1 = sy1 + margin;\n\n const { x: ax, y: ay } = anchor;\n const { x0: tx, y0: ty } = target;\n\n if (tx < ax && ty === ay) return Directions.RIGHT;\n if (tx <= smx0 && ty < ay) return Directions.BOTTOM;\n if (tx <= smx0 && ty > ay) return Directions.TOP;\n if (tx >= smx0 && ty < smy0) return Directions.LEFT;\n if (tx >= smx0 && ty > smy1) return Directions.LEFT;\n if (tx > sx1 && ty >= smy0 && ty <= ay) {\n if (nextInLine.point.y < ty) {\n return Directions.BOTTOM;\n }\n\n return Directions.TOP;\n }\n if (tx > sx1 && ty <= smy1 && ty >= ay) {\n if (nextInLine.point.y < ty) {\n return Directions.BOTTOM;\n }\n\n return Directions.TOP;\n }\n\n return Directions.RIGHT;\n}\n\nfunction resolveForRightSourceSide(source, target, nextInLine) {\n const { y0: sy0, x0: sx0, width, height, point: anchor, margin } = source;\n const sx1 = sx0 + width;\n const sy1 = sy0 + height;\n const smx1 = sx1 + margin;\n const smy0 = sy0 - margin;\n const smy1 = sy1 + margin;\n\n const { x: ax, y: ay } = anchor;\n const { x0: tx, y0: ty } = target;\n\n if (tx > ax && ty === ay) return Directions.LEFT;\n if (tx >= smx1 && ty < ay) return Directions.BOTTOM;\n if (tx >= smx1 && ty > ay) return Directions.TOP;\n if (tx <= smx1 && ty < smy0) return Directions.RIGHT;\n if (tx <= smx1 && ty > smy1) return Directions.RIGHT;\n if (tx < sx0 && ty >= smy0 && ty <= ay) {\n if (nextInLine.point.y < ty) {\n return Directions.BOTTOM;\n }\n\n return Directions.TOP;\n }\n if (tx < sx0 && ty <= smy1 && ty >= ay) {\n if (nextInLine.point.y < ty) {\n return Directions.BOTTOM;\n }\n\n return Directions.TOP;\n }\n\n return Directions.LEFT;\n}\n\nfunction resolveInitialDirection(source, target, nextInLine) {\n const [sourceSide] = resolveSides(source, target);\n\n switch (sourceSide) {\n case Directions.TOP:\n return resolveForTopSourceSide(source, target, nextInLine);\n case Directions.RIGHT:\n return resolveForRightSourceSide(source, target, nextInLine);\n case Directions.BOTTOM:\n return resolveForBottomSourceSide(source, target, nextInLine);\n case Directions.LEFT:\n return resolveForLeftSourceSide(source, target, nextInLine);\n }\n}\n\nfunction getDirectionForLinkConnection(linkOrigin, connectionPoint, linkView) {\n const tangent = linkView.getTangentAtLength(linkView.getClosestPointLength(connectionPoint));\n const roundedAngle = Math.round(getSegmentAngle(tangent) / 90) * 90;\n\n if (roundedAngle % 180 === 0 && linkOrigin.y === connectionPoint.y) {\n return linkOrigin.x < connectionPoint.x ? Directions.LEFT : Directions.RIGHT;\n } else if (linkOrigin.x === connectionPoint.x) {\n return linkOrigin.y < connectionPoint.y ? Directions.TOP : Directions.BOTTOM;\n }\n\n switch (roundedAngle) {\n case 0:\n case 180:\n case 360:\n return linkOrigin.y < connectionPoint.y ? Directions.TOP : Directions.BOTTOM;\n case 90:\n case 270:\n return linkOrigin.x < connectionPoint.x ? Directions.LEFT : Directions.RIGHT;\n }\n}\n\nfunction pointDataFromAnchor(view, point, bbox, direction, isPort, fallBackAnchor, margin) {\n if (direction === Directions.AUTO) {\n direction = isPort ? Directions.MAGNET_SIDE : Directions.ANCHOR_SIDE;\n }\n\n const isElement = view && view.model.isElement();\n\n const {\n x: x0,\n y: y0,\n width = 0,\n height = 0\n } = isElement ? g.Rect.fromRectUnion(bbox, view.model.getBBox()) : fallBackAnchor;\n\n return {\n point,\n x0,\n y0,\n view,\n bbox,\n width,\n height,\n direction,\n margin: isElement ? margin : 0\n };\n}\n\nfunction pointDataFromVertex({ x, y }) {\n const point = new g.Point(x, y);\n\n return {\n point,\n x0: point.x,\n y0: point.y,\n view: null,\n bbox: new g.Rect(x, y, 0, 0),\n width: 0,\n height: 0,\n direction: null,\n margin: 0\n };\n}\n\nfunction getOutsidePoint(side, pointData, margin) {\n const outsidePoint = pointData.point.clone();\n\n const { x0, y0, width, height } = pointData;\n\n switch (side) {\n case 'left':\n outsidePoint.x = x0 - margin;\n break;\n case 'right':\n outsidePoint.x = x0 + width + margin;\n break;\n case 'top':\n outsidePoint.y = y0 - margin;\n break;\n case 'bottom':\n outsidePoint.y = y0 + height + margin;\n break;\n }\n\n return outsidePoint;\n}\n\nfunction createLoop(from, to, { dx = 0, dy = 0 }) {\n const p1 = { x: from.point.x + dx, y: from.point.y + dy };\n const p2 = { x: to.point.x + dx, y: to.point.y + dy };\n\n return [from.point, p1, p2, to.point];\n}\n\nfunction loopSegment(from, to, connectionSegmentAngle, margin) {\n // Find out the loop coordinates.\n const angle = g.normalizeAngle(connectionSegmentAngle - 90);\n\n let dx = 0;\n let dy = 0;\n\n if (angle === 90) {\n dy = -margin;\n } else if (angle === 180) {\n dx = -margin;\n } else if (angle === 270) {\n dy = margin;\n } else if (angle === 0) {\n dx = margin;\n }\n\n const loopRoute = createLoop(from, to, { dx, dy });\n\n const secondCreatedPoint = loopRoute[2];\n const loopEndSegment = new g.Line(to.point, secondCreatedPoint);\n // The direction in which the loop should continue.\n const continueDirection = ANGLE_DIRECTION_MAP[getSegmentAngle(loopEndSegment)];\n\n return {\n loopRoute,\n continueDirection\n };\n}\n\n// Calculates the distances along the horizontal axis for the left and right route.\nfunction getHorizontalDistance(source, target) {\n\n const { x0: sx0, x1: sx1, outsidePoint: sourcePoint } = source;\n const { x0: tx0, x1: tx1, outsidePoint: targetPoint } = target;\n\n // Furthest left boundary\n let leftBoundary = Math.min(sx0, tx0);\n // Furthest right boundary\n let rightBoundary = Math.max(sx1, tx1);\n\n // If the source and target elements are on the same side, we need to figure out what shape defines the boundary.\n if (source.direction === target.direction) {\n\n const aboveShape = source.y0 < target.y0 ? source : target;\n const belowShape = aboveShape === source ? target : source;\n\n // The source and target anchors are on the top => then the `aboveShape` defines the boundary.\n // The source and target anchors are on the bottom => then the `belowShape` defines the boundary.\n const boundaryDefiningShape = source.direction === Directions.TOP ? aboveShape : belowShape;\n\n leftBoundary = boundaryDefiningShape.x0;\n rightBoundary = boundaryDefiningShape.x1;\n }\n\n const { x: sox } = sourcePoint;\n const { x: tox } = targetPoint;\n\n // Calculate the distances for the left route\n const leftDistance1 = Math.abs(sox - leftBoundary);\n const leftDistance2 = Math.abs(tox - leftBoundary);\n const leftD = leftDistance1 + leftDistance2;\n\n // Calculate the distances for the right route\n const rightDistance1 = Math.abs(sox - rightBoundary);\n const rightDistance2 = Math.abs(tox - rightBoundary);\n const rightD = rightDistance1 + rightDistance2;\n\n return [leftD, rightD];\n}\n\n// Calculates the distances along the vertical axis for the top and bottom route.\nfunction getVerticalDistance(source, target) {\n\n const { y0: sy0, y1: sy1, outsidePoint: sourcePoint } = source;\n const { y0: ty0, y1: ty1, outsidePoint: targetPoint } = target;\n\n // Furthest top boundary\n let topBoundary = Math.min(sy0, ty0);\n // Furthest bottom boundary\n let bottomBoundary = Math.max(sy1, ty1);\n\n // If the source and target elements are on the same side, we need to figure out what shape defines the boundary.\n if (source.direction === target.direction) {\n\n const leftShape = source.x0 < target.x0 ? source : target;\n const rightShape = leftShape === source ? target : source;\n\n // The source and target anchors are on the left => then the `leftShape` defines the boundary.\n // The source and target anchors are on the right => then the `rightShape` defines the boundary.\n const boundaryDefiningShape = source.direction === Directions.LEFT ? leftShape : rightShape;\n\n topBoundary = boundaryDefiningShape.y0;\n bottomBoundary = boundaryDefiningShape.y1; \n }\n\n const { y: soy } = sourcePoint;\n const { y: toy } = targetPoint;\n\n // Calculate the distances for the top route\n const topDistance1 = Math.abs(soy - topBoundary);\n const topDistance2 = Math.abs(toy - topBoundary);\n const topD = topDistance1 + topDistance2;\n\n // Calculate the distances for the bottom route\n const bottomDistance1 = Math.abs(soy - bottomBoundary);\n const bottomDistance2 = Math.abs(toy - bottomBoundary);\n const bottomD = bottomDistance1 + bottomDistance2;\n\n return [topD, bottomD];\n}\n\n// Inflate bbox in 3 directions depending on the direction of the anchor\n// don't inflate in the opposite direction of the anchor\nfunction moveAndExpandBBox(bbox, direction, margin) {\n switch (direction) {\n case Directions.LEFT:\n bbox.inflate(0, margin).moveAndExpand({ x: -margin, width: margin });\n break;\n case Directions.RIGHT:\n bbox.inflate(0, margin).moveAndExpand({ width: margin });\n break;\n case Directions.TOP:\n bbox.inflate(margin, 0).moveAndExpand({ y: -margin, height: margin });\n break;\n case Directions.BOTTOM:\n bbox.inflate(margin, 0).moveAndExpand({ height: margin });\n break;\n }\n\n return bbox;\n}\n\nfunction routeBetweenPoints(source, target, opt = {}) {\n const { point: sourcePoint, x0: sx0, y0: sy0, width: sourceWidth, height: sourceHeight, margin: sourceMargin } = source;\n const { point: targetPoint, x0: tx0, y0: ty0, width: targetWidth, height: targetHeight, margin: targetMargin } = target;\n const { targetInSourceBBox = false } = opt;\n\n const tx1 = tx0 + targetWidth;\n const ty1 = ty0 + targetHeight;\n const sx1 = sx0 + sourceWidth;\n const sy1 = sy0 + sourceHeight;\n\n // Key coordinates including the margin\n const smx0 = sx0 - sourceMargin;\n const smx1 = sx1 + sourceMargin;\n const smy0 = sy0 - sourceMargin;\n const smy1 = sy1 + sourceMargin;\n\n const tmx0 = tx0 - targetMargin;\n const tmx1 = tx1 + targetMargin;\n const tmy0 = ty0 - targetMargin;\n const tmy1 = ty1 + targetMargin;\n\n const [sourceSide, targetSide] = resolveSides(source, target);\n\n const sourceOutsidePoint = getOutsidePoint(sourceSide, { point: sourcePoint, x0: sx0, y0: sy0, width: sourceWidth, height: sourceHeight }, sourceMargin);\n const targetOutsidePoint = getOutsidePoint(targetSide, { point: targetPoint, x0: tx0, y0: ty0, width: targetWidth, height: targetHeight }, targetMargin);\n\n const { x: sox, y: soy } = sourceOutsidePoint;\n const { x: tox, y: toy } = targetOutsidePoint;\n const tcx = (tx0 + tx1) / 2;\n const tcy = (ty0 + ty1) / 2;\n const scx = (sx0 + sx1) / 2;\n const scy = (sy0 + sy1) / 2;\n const middleOfVerticalSides = (scx < tcx ? (sx1 + tx0) : (tx1 + sx0)) / 2;\n const middleOfHorizontalSides = (scy < tcy ? (sy1 + ty0) : (ty1 + sy0)) / 2;\n\n const sourceBBox = new g.Rect(sx0, sy0, sourceWidth, sourceHeight);\n const targetBBox = new g.Rect(tx0, ty0, targetWidth, targetHeight);\n const inflatedSourceBBox = sourceBBox.clone().inflate(sourceMargin);\n const inflatedTargetBBox = targetBBox.clone().inflate(targetMargin);\n\n const sourceForDistance = Object.assign({}, source, { x1: sx1, y1: sy1, outsidePoint: sourceOutsidePoint, direction: sourceSide });\n const targetForDistance = Object.assign({}, target, { x1: tx1, y1: ty1, outsidePoint: targetOutsidePoint, direction: targetSide });\n\n // Distances used to determine the shortest route along the connections on horizontal sides for\n // bottom => bottom\n // top => bottom\n // bottom => top\n // top => top\n const [leftD, rightD] = getHorizontalDistance(sourceForDistance, targetForDistance);\n\n // Distances used to determine the shortest route along the connection on vertical sides for\n // left => left\n // left => right\n // right => right\n // right => left\n const [topD, bottomD] = getVerticalDistance(sourceForDistance, targetForDistance);\n\n // All possible combinations of source and target sides\n if (sourceSide === 'left' && targetSide === 'right') {\n const isPointInsideSource = inflatedSourceBBox.containsPoint(targetOutsidePoint);\n const isPointInsideTarget = inflatedTargetBBox.containsPoint(sourceOutsidePoint);\n\n // Use S-shaped connection\n if (isPointInsideSource || isPointInsideTarget) {\n const middleOfAnchors = (soy + toy) / 2;\n \n return [\n { x: sox, y: soy },\n { x: sox, y: middleOfAnchors },\n { x: tox, y: middleOfAnchors },\n { x: tox, y: toy }\n ];\n }\n\n if (smx0 < tox) {\n let y = middleOfHorizontalSides;\n let x1 = sox;\n let x2 = tox;\n\n const isUpwardsShorter = topD < bottomD;\n\n // If the source and target elements overlap, we need to make sure the connection\n // goes around the target element.\n if ((y >= smy0 && y <= smy1) || (y >= tmy0 && y <= tmy1)) {\n if (smy1 >= tmy0 && isUpwardsShorter) {\n y = Math.min(tmy0, smy0);\n } else if (smy0 <= tmy1 && !isUpwardsShorter) {\n y = Math.max(tmy1, smy1);\n }\n\n // This handles the case when the source and target elements overlap as well as\n // the case when the source is to the left of the target element.\n x1 = Math.min(sox, tmx0);\n x2 = Math.max(tox, smx1);\n \n // This is an edge case when the source and target intersect and\n if ((isUpwardsShorter && soy < ty0) || (!isUpwardsShorter && soy > ty1)) {\n // the path should no longer rely on minimal x boundary in `x1`\n x1 = sox;\n } else if ((isUpwardsShorter && toy < sy0) || (!isUpwardsShorter && toy > sy1)) {\n // the path should no longer rely on maximal x boundary in `x2`\n x2 = tox;\n }\n }\n\n return [\n { x: x1, y: soy },\n { x: x1, y },\n { x: x2, y },\n { x: x2, y: toy }\n ];\n }\n\n const x = (sox + tox) / 2;\n return [\n { x, y: soy },\n { x, y: toy },\n ];\n } else if (sourceSide === 'right' && targetSide === 'left') {\n const isPointInsideSource = inflatedSourceBBox.containsPoint(targetOutsidePoint);\n const isPointInsideTarget = inflatedTargetBBox.containsPoint(sourceOutsidePoint);\n\n // Use S-shaped connection\n if (isPointInsideSource || isPointInsideTarget) {\n const middleOfAnchors = (soy + toy) / 2;\n \n return [\n { x: sox, y: soy },\n { x: sox, y: middleOfAnchors },\n { x: tox, y: middleOfAnchors },\n { x: tox, y: toy }\n ];\n }\n\n if (smx1 > tox) {\n let y = middleOfHorizontalSides;\n let x1 = sox;\n let x2 = tox;\n\n const isUpwardsShorter = topD < bottomD;\n\n // If the source and target elements overlap, we need to make sure the connection\n // goes around the target element.\n if ((y >= smy0 && y <= smy1) || (y >= tmy0 && y <= tmy1)) {\n if (smy1 >= tmy0 && isUpwardsShorter) {\n y = Math.min(tmy0, smy0);\n } else if (smy0 <= tmy1 && !isUpwardsShorter) {\n y = Math.max(tmy1, smy1);\n }\n\n // This handles the case when the source and target elements overlap as well as\n // the case when the source is to the left of the target element.\n x1 = Math.max(sox, tmx1);\n x2 = Math.min(tox, smx0);\n\n // This is an edge case when the source and target intersect and\n if ((isUpwardsShorter && soy < ty0) || (!isUpwardsShorter && soy > ty1)) {\n // the path should no longer rely on maximal x boundary in `x1`\n x1 = sox;\n } else if ((isUpwardsShorter && toy < sy0) || (!isUpwardsShorter && toy > sy1)) {\n // the path should no longer rely on minimal x boundary in `x2`\n x2 = tox;\n }\n }\n\n return [\n { x: x1, y: soy },\n { x: x1, y },\n { x: x2, y },\n { x: x2, y: toy }\n ];\n }\n\n const x = (sox + tox) / 2;\n return [\n { x, y: soy },\n { x, y: toy }\n ];\n } else if (sourceSide === 'top' && targetSide === 'bottom') {\n const isPointInsideSource = inflatedSourceBBox.containsPoint(targetOutsidePoint);\n const isPointInsideTarget = inflatedTargetBBox.containsPoint(sourceOutsidePoint);\n\n // Use S-shaped connection\n if (isPointInsideSource || isPointInsideTarget) {\n const middleOfAnchors = (sox + tox) / 2;\n\n return [\n { x: sox, y: soy },\n { x: middleOfAnchors, y: soy },\n { x: middleOfAnchors, y: toy },\n { x: tox, y: toy }\n ];\n }\n\n if (smy0 < toy) {\n let x = middleOfVerticalSides;\n let y1 = soy;\n let y2 = toy;\n\n const isLeftShorter = leftD < rightD;\n\n // If the source and target elements overlap, we need to make sure the connection\n // goes around the target element.\n if ((x >= smx0 && x <= smx1) || (x >= tmx0 && x <= tmx1)) {\n if (smx1 >= tmx0 && isLeftShorter) {\n x = Math.min(tmx0, smx0);\n } else if (smx0 <= tmx1 && !isLeftShorter) {\n x = Math.max(tmx1, smx1);\n }\n\n // This handles the case when the source and target elements overlap as well as\n // the case when the source is to the left of the target element.\n y1 = Math.min(soy, tmy0);\n y2 = Math.max(toy, smy1);\n\n // This is an edge case when the source and target intersect and\n if ((isLeftShorter && sox < tx0) || (!isLeftShorter && sox > tx1)) {\n // the path should no longer rely on minimal y boundary in `y1`\n y1 = soy;\n } else if ((isLeftShorter && tox < sx0) || (!isLeftShorter && tox > sx1)) {\n // the path should no longer rely on maximal y boundary in `y2`\n y2 = toy;\n }\n }\n\n return [\n { x: sox, y: y1 },\n { x, y: y1 },\n { x, y: y2 },\n { x: tox, y: y2 }\n ];\n }\n\n const y = (soy + toy) / 2;\n return [\n { x: sox, y },\n { x: tox, y }\n ];\n } else if (sourceSide === 'bottom' && targetSide === 'top') {\n const isPointInsideSource = inflatedSourceBBox.containsPoint(targetOutsidePoint);\n const isPointInsideTarget = inflatedTargetBBox.containsPoint(sourceOutsidePoint);\n\n // Use S-shaped connection\n if (isPointInsideSource || isPointInsideTarget) {\n const middleOfAnchors = (sox + tox) / 2;\n\n return [\n { x: sox, y: soy },\n { x: middleOfAnchors, y: soy },\n { x: middleOfAnchors, y: toy },\n { x: tox, y: toy }\n ];\n }\n\n if (smy1 > toy) {\n let x = middleOfVerticalSides;\n let y1 = soy;\n let y2 = toy;\n \n const isLeftShorter = leftD < rightD;\n\n // If the source and target elements overlap, we need to make sure the connection\n // goes around the target element.\n if ((x >= smx0 && x <= smx1) || (x >= tmx0 && x <= tmx1)) {\n if (smx1 >= tmx0 && isLeftShorter) {\n x = Math.min(tmx0, smx0);\n } else if (smx0 <= tmx1 && !isLeftShorter) {\n x = Math.max(tmx1, smx1);\n }\n\n // This handles the case when the source and target elements overlap as well as\n // the case when the source is to the left of the target element.\n y1 = Math.max(soy, tmy1);\n y2 = Math.min(toy, smy0);\n\n // This is an edge case when the source and target intersect and\n if ((isLeftShorter && sox < tx0) || (!isLeftShorter && sox > tx1)) {\n // the path should no longer rely on maximal y boundary in `y1`\n y1 = soy;\n } else if ((isLeftShorter && tox < sx0) || (!isLeftShorter && tox > sx1)) {\n // the path should no longer rely on minimal y boundary in `y2`\n y2 = toy;\n }\n }\n\n return [\n { x: sox, y: y1 },\n { x, y: y1 },\n { x, y: y2 },\n { x: tox, y: y2 }\n ];\n }\n\n const y = (soy + toy) / 2;\n return [\n { x: sox, y },\n { x: tox, y }\n ];\n } else if (sourceSide === 'top' && targetSide === 'top') {\n const useUShapeConnection =\n targetInSourceBBox ||\n g.intersection.rectWithRect(inflatedSourceBBox, targetBBox) ||\n (soy <= ty0 && (inflatedSourceBBox.bottomRight().x <= tox || inflatedSourceBBox.bottomLeft().x >= tox)) ||\n (soy >= ty0 && (inflatedTargetBBox.bottomRight().x <= sox || inflatedTargetBBox.bottomLeft().x >= sox));\n\n // U-shape connection is a straight line if `sox` and `tox` are the same\n if (useUShapeConnection && sox !== tox) {\n return [\n { x: sox, y: Math.min(soy, toy) },\n { x: tox, y: Math.min(soy, toy) }\n ];\n }\n\n let x;\n let y1 = Math.min((sy1 + ty0) / 2, toy);\n let y2 = Math.min((sy0 + ty1) / 2, soy);\n\n if (toy < soy) {\n // Use the shortest path along the connections on horizontal sides\n if (rightD > leftD) {\n x = Math.min(sox, tmx0);\n } else {\n x = Math.max(sox, tmx1);\n }\n } else {\n if (rightD > leftD) {\n x = Math.min(tox, smx0);\n } else {\n x = Math.max(tox, smx1);\n }\n }\n\n return [\n { x: sox, y: y2 },\n { x, y: y2 },\n { x, y: y1 },\n { x: tox, y: y1 }\n ];\n } else if (sourceSide === 'bottom' && targetSide === 'bottom') {\n const useUShapeConnection =\n targetInSourceBBox ||\n g.intersection.rectWithRect(inflatedSourceBBox, targetBBox) ||\n (soy >= toy && (inflatedSourceBBox.topRight().x <= tox || inflatedSourceBBox.topLeft().x >= tox)) ||\n (soy <= toy && (inflatedTargetBBox.topRight().x <= sox || inflatedTargetBBox.topLeft().x >= sox));\n\n // U-shape connection is a straight line if `sox` and `tox` are the same\n if (useUShapeConnection && sox !== tox) {\n return [\n { x: sox, y: Math.max(soy, toy) },\n { x: tox, y: Math.max(soy, toy) }\n ];\n }\n\n let x;\n let y1 = Math.max((sy0 + ty1) / 2, toy);\n let y2 = Math.max((sy1 + ty0) / 2, soy);\n\n if (toy > soy) {\n // Use the shortest path along the connections on horizontal sides\n if (rightD > leftD) {\n x = Math.min(sox, tmx0);\n } else {\n x = Math.max(sox, tmx1);\n }\n } else {\n if (rightD > leftD) {\n x = Math.min(tox, smx0);\n } else {\n x = Math.max(tox, smx1);\n }\n }\n\n return [\n { x: sox, y: y2 },\n { x, y: y2 },\n { x, y: y1 },\n { x: tox, y: y1 }\n ];\n } else if (sourceSide === 'left' && targetSide === 'left') {\n const useUShapeConnection = \n targetInSourceBBox ||\n g.intersection.rectWithRect(inflatedSourceBBox, targetBBox) ||\n (sox <= tox && (inflatedSourceBBox.bottomRight().y <= toy || inflatedSourceBBox.topRight().y >= toy)) ||\n (sox >= tox && (inflatedTargetBBox.bottomRight().y <= soy || inflatedTargetBBox.topRight().y >= soy));\n\n // U-shape connection is a straight line if `soy` and `toy` are the same\n if (useUShapeConnection && soy !== toy) {\n return [\n { x: Math.min(sox, tox), y: soy },\n { x: Math.min(sox, tox), y: toy }\n ];\n }\n\n let y;\n let x1 = Math.min((sx1 + tx0) / 2, tox);\n let x2 = Math.min((sx0 + tx1) / 2, sox);\n\n if (tox > sox) {\n if (topD <= bottomD) {\n y = Math.min(smy0, toy);\n } else {\n y = Math.max(smy1, toy);\n }\n } else {\n if (topD <= bottomD) {\n y = Math.min(tmy0, soy);\n } else {\n y = Math.max(tmy1, soy);\n }\n }\n\n return [\n { x: x2, y: soy },\n { x: x2, y },\n { x: x1, y },\n { x: x1, y: toy }\n ];\n } else if (sourceSide === 'right' && targetSide === 'right') {\n const useUShapeConnection =\n targetInSourceBBox ||\n g.intersection.rectWithRect(inflatedSourceBBox, targetBBox) ||\n (sox >= tox && (inflatedSourceBBox.bottomLeft().y <= toy || inflatedSourceBBox.topLeft().y >= toy)) ||\n (sox <= tox && (inflatedTargetBBox.bottomLeft().y <= soy || inflatedTargetBBox.topLeft().y >= soy));\n\n // U-shape connection is a straight line if `soy` and `toy` are the same\n if (useUShapeConnection && soy !== toy) {\n return [\n { x: Math.max(sox, tox), y: soy },\n { x: Math.max(sox, tox), y: toy }\n ];\n }\n\n let y;\n let x1 = Math.max((sx0 + tx1) / 2, tox);\n let x2 = Math.max((sx1 + tx0) / 2, sox);\n\n if (tox <= sox) {\n if (topD <= bottomD) {\n y = Math.min(smy0, toy);\n } else {\n y = Math.max(smy1, toy);\n }\n } else {\n if (topD <= bottomD) {\n y = Math.min(tmy0, soy);\n } else {\n y = Math.max(tmy1, soy);\n }\n }\n\n return [\n { x: x2, y: soy },\n { x: x2, y },\n { x: x1, y },\n { x: x1, y: toy }\n ];\n } else if (sourceSide === 'top' && targetSide === 'right') {\n const isPointInsideSource = inflatedSourceBBox.containsPoint(targetPoint);\n\n // The target point is inside the source element\n if (isPointInsideSource) {\n if (sox <= tmx1) {\n const x = Math.max(sox + sourceMargin, tox);\n const y = Math.min(smy0, tmy0);\n\n // Target anchor is on the right side of the source anchor\n return [\n { x: sox, y },\n { x: x, y },\n { x: x, y: toy }\n ];\n }\n\n // Target anchor is on the left side of the source anchor\n // Subtract the `sourceMargin` since the source anchor is on the right side of the target anchor\n const anchorMiddleX = (sox - sourceMargin + tox) / 2;\n\n return [\n { x: sox, y: soy },\n { x: anchorMiddleX, y: soy },\n { x: anchorMiddleX, y: toy }\n ];\n }\n\n if (smy0 > toy) {\n if (sox < tox) {\n let y = tmy0;\n\n if (tmy1 <= smy0 && tmx1 >= sox) {\n y = middleOfHorizontalSides;\n }\n\n return [\n { x: sox, y },\n { x: tox, y },\n { x: tox, y: toy }\n ];\n }\n\n return [{ x: sox, y: toy }];\n }\n\n const x = Math.max(middleOfVerticalSides, tmx1);\n\n if (sox > tox && sy1 >= toy) {\n return [\n { x: sox, y: soy },\n { x, y: soy },\n { x, y: toy }\n ];\n }\n\n if (x > smx0 && soy < ty1) {\n const y = Math.min(smy0, tmy0);\n const x = Math.max(smx1, tmx1);\n return [\n { x: sox, y },\n { x, y },\n { x, y: toy }\n ];\n }\n\n return [\n { x: sox, y: soy },\n { x, y: soy },\n { x, y: toy }\n ];\n } else if (sourceSide === 'top' && targetSide === 'left') {\n const isPointInsideSource = inflatedSourceBBox.containsPoint(targetPoint);\n\n // The target point is inside the source element\n if (isPointInsideSource) {\n if (sox >= tmx0) {\n const x = Math.min(sox - sourceMargin, tox);\n const y = Math.min(smy0, tmy0);\n\n // Target anchor is on the left side of the source anchor\n return [\n { x: sox, y },\n { x: x, y },\n { x: x, y: toy }\n ];\n }\n\n // Target anchor is on the right side of the source anchor\n // Add the `sourceMargin` since the source anchor is on the left side of the target anchor\n const anchorMiddleX = (sox + sourceMargin + tox) / 2;\n\n return [\n { x: sox, y: soy },\n { x: anchorMiddleX, y: soy },\n { x: anchorMiddleX, y: toy }\n ];\n }\n\n if (smy0 > toy) {\n if (sox > tox) {\n let y = tmy0;\n\n if (tmy1 <= smy0 && tmx0 <= sox) {\n y = middleOfHorizontalSides;\n }\n\n return [\n { x: sox, y },\n { x: tox, y },\n { x: tox, y: toy }\n ];\n }\n\n return [{ x: sox, y: toy }];\n }\n\n const x = Math.min(tmx0, middleOfVerticalSides);\n\n if (sox < tox && sy1 >= toy) {\n return [\n { x: sox, y: soy },\n { x, y: soy },\n { x, y: toy }];\n }\n\n if (x < smx1 && soy < ty1) {\n const y = Math.min(smy0, tmy0);\n const x = Math.min(smx0, tmx0);\n return [\n { x: sox, y },\n { x, y },\n { x, y: toy }\n ];\n }\n\n return [\n { x: sox, y: soy },\n { x, y: soy },\n { x, y: toy }\n ];\n } else if (sourceSide === 'bottom' && targetSide === 'right') {\n const isPointInsideSource = inflatedSourceBBox.containsPoint(targetPoint);\n\n // The target point is inside the source element\n if (isPointInsideSource) {\n if (sox <= tmx1) {\n const x = Math.max(sox + sourceMargin, tox);\n const y = Math.max(smy1, tmy1);\n\n // Target anchor is on the right side of the source anchor\n return [\n { x: sox, y },\n { x, y },\n { x, y: toy }\n ];\n }\n\n // Target anchor is on the left side of the source anchor\n // Subtract the `sourceMargin` since the source anchor is on the right side of the target anchor\n const anchorMiddleX = (sox - sourceMargin + tox) / 2;\n\n return [\n { x: sox, y: soy },\n { x: anchorMiddleX, y: soy },\n { x: anchorMiddleX, y: toy }\n ];\n }\n\n if (smy1 < toy) {\n if (sox < tox) {\n let y = tmy1;\n\n if (tmy0 >= smy1 && tmx1 >= sox) {\n y = middleOfHorizontalSides;\n }\n\n return [\n { x: sox, y },\n { x: tox, y },\n { x: tox, y: toy }\n ];\n }\n\n return [{ x: sox, y: toy }];\n }\n\n const x = Math.max(middleOfVerticalSides, tmx1);\n\n if (sox > tox && sy0 <= toy) {\n return [\n { x: sox, y: soy },\n { x, y: soy },\n { x, y: toy }\n ];\n }\n\n if (x > smx0 && soy > ty0) {\n const y = Math.max(smy1, tmy1);\n const x = Math.max(smx1, tmx1);\n return [\n { x: sox, y },\n { x, y },\n { x, y: toy }\n ];\n }\n\n return [\n { x: sox, y: soy },\n { x, y: soy },\n { x, y: toy }\n ];\n } else if (sourceSide === 'bottom' && targetSide === 'left') {\n const isPointInsideSource = inflatedSourceBBox.containsPoint(targetPoint);\n\n // The target point is inside the source element\n if (isPointInsideSource) {\n if (sox >= tmx0) {\n const x = Math.min(sox - sourceMargin, tox);\n const y = Math.max(smy1, tmy1);\n\n // Target anchor is on the left side of the source anchor\n return [\n { x: sox, y },\n { x, y },\n { x, y: toy }\n ];\n }\n\n // Target anchor is on the right side of the source anchor\n // Add the `sourceMargin` since the source anchor is on the left side of the target anchor\n const anchorMiddleX = (sox + sourceMargin + tox) / 2;\n\n return [\n { x: sox, y: soy },\n { x: anchorMiddleX, y: soy },\n { x: anchorMiddleX, y: toy }\n ];\n }\n\n if (smy1 < toy) {\n if (sox > tox) {\n let y = tmy1;\n\n if (tmy0 >= smy1 && tmx0 <= sox) {\n y = middleOfHorizontalSides;\n }\n\n return [\n { x: sox, y },\n { x: tox, y },\n { x: tox, y: toy }\n ];\n }\n\n return [{ x: sox, y: toy }];\n }\n\n const x = Math.min(tmx0, middleOfVerticalSides);\n\n if (sox < tox && sy0 <= toy) {\n return [\n { x: sox, y: soy },\n { x, y: soy },\n { x, y: toy }\n ];\n }\n\n if (x < smx1 && soy > ty0) {\n const y = Math.max(smy1, tmy1);\n const x = Math.min(smx0, tmx0);\n return [\n { x: sox, y },\n { x, y },\n { x, y: toy }\n ];\n }\n\n return [\n { x: sox, y: soy },\n { x, y: soy },\n { x, y: toy }\n ];\n } else if (sourceSide === 'left' && targetSide === 'bottom') {\n const isPointInsideSource = inflatedSourceBBox.containsPoint(targetPoint);\n\n // The target point is inside the source element\n if (isPointInsideSource) {\n if (soy <= tmy1) {\n const x = Math.min(smx0, tmx0);\n const y = Math.max(soy + sourceMargin, toy);\n\n return [\n { x, y: soy },\n { x, y },\n { x: tox, y }\n ];\n }\n\n // Target anchor is above the source anchor\n const anchorMiddleY = (soy - sourceMargin + toy) / 2;\n\n return [\n { x: sox, y: soy },\n { x: sox, y: anchorMiddleY },\n { x: tox, y: anchorMiddleY }\n ];\n }\n\n if (smx0 > tox) {\n if (soy < toy) {\n let x = tmx0;\n\n if (tmx1 <= smx0 && tmy1 >= soy) {\n x = middleOfVerticalSides;\n }\n\n return [\n { x, y: soy },\n { x, y: toy },\n { x: tox, y: toy }\n ];\n }\n\n return [{ x: tox, y: soy }];\n }\n\n const y = Math.max(tmy1, middleOfHorizontalSides);\n\n if (soy > toy && sx1 >= tox) {\n return [\n { x: sox, y: soy },\n { x: sox, y },\n { x: tox, y }\n ];\n }\n\n if (y > smy0 && sox < tx1) {\n const x = Math.min(smx0, tmx0);\n const y = Math.max(smy1, tmy1);\n\n return [\n { x, y: soy },\n { x, y },\n { x: tox, y }\n ];\n }\n\n return [\n { x: sox, y: soy },\n { x: sox, y },\n { x: tox, y }\n ];\n } else if (sourceSide === 'left' && targetSide === 'top') {\n const isPointInsideSource = inflatedSourceBBox.containsPoint(targetPoint);\n\n // The target point is inside the source element\n if (isPointInsideSource) {\n if (soy >= tmy0) {\n const y = Math.min(soy - sourceMargin, toy);\n const x = Math.min(smx0, tmx0);\n\n // Target anchor is on the top side of the source anchor\n return [\n { x, y: soy },\n { x, y },\n { x: tox, y }\n ];\n }\n\n // Target anchor is below the source anchor\n // Add the `sourceMargin` since the source anchor is above the target anchor\n const anchorMiddleY = (soy + sourceMargin + toy) / 2;\n\n return [\n { x: sox, y: soy },\n { x: sox, y: anchorMiddleY },\n { x: tox, y: anchorMiddleY }\n ];\n }\n\n if (smx0 > tox) {\n if (soy > toy) {\n let x = tmx0;\n\n if (tmx1 <= smx0 && tmy0 <= soy) {\n x = middleOfVerticalSides;\n }\n\n return [\n { x, y: soy },\n { x, y: toy },\n { x: tox, y: toy }\n ];\n }\n\n return [{ x: tox, y: soy }];\n }\n\n const y = Math.min(tmy0, middleOfHorizontalSides);\n\n if (soy < toy && sx1 >= tox) {\n return [\n { x: sox, y: soy },\n { x: sox, y },\n { x: tox, y }];\n }\n\n if (y < smy1 && sox < tx1) {\n const x = Math.min(smx0, tmx0);\n const y = Math.min(smy0, tmy0);\n return [\n { x, y: soy },\n { x, y },\n { x: tox, y }\n ];\n }\n\n return [\n { x: sox, y: soy },\n { x: sox, y },\n { x: tox, y }\n ];\n } else if (sourceSide === 'right' && targetSide === 'top') {\n const isPointInsideSource = inflatedSourceBBox.containsPoint(targetPoint);\n\n // The target point is inside the source element\n if (isPointInsideSource) {\n if (soy >= tmy0) {\n const x = Math.max(smx1, tmx1);\n const y = Math.min(soy - sourceMargin, toy);\n\n // Target anchor is on the top side of the source anchor\n return [\n { x, y: soy },\n { x, y }, // Path adjustment for right side start\n { x: tox, y }\n ];\n }\n\n // Target anchor is below the source anchor\n // Adjust sourceMargin calculation since the source anchor is now on the right\n const anchorMiddleY = (soy + sourceMargin + toy) / 2;\n\n return [\n { x: sox, y: soy },\n { x: sox, y: anchorMiddleY },\n { x: tox, y: anchorMiddleY }\n ];\n }\n\n if (smx1 < tox) {\n if (soy > toy) {\n let x = tmx1;\n\n if (tmx0 >= smx1 && tmy0 <= soy) {\n x = middleOfVerticalSides;\n }\n\n return [\n { x, y: soy },\n { x, y: toy },\n { x: tox, y: toy }\n ];\n }\n\n return [{ x: tox, y: soy }];\n }\n\n const y = Math.min(tmy0, middleOfHorizontalSides);\n\n if (soy < toy && sx0 <= tox) {\n return [\n { x: sox, y: soy },\n { x: sox, y },\n { x: tox, y }];\n }\n\n if (y < smy1 && sox > tx0) {\n const x = Math.max(smx1, tmx1);\n const y = Math.min(smy0, tmy0);\n\n return [\n { x, y: soy },\n { x, y },\n { x: tox, y }\n ];\n }\n\n return [\n { x: sox, y: soy },\n { x: sox, y },\n { x: tox, y }\n ];\n } else if (sourceSide === 'right' && targetSide === 'bottom') {\n const isPointInsideSource = inflatedSourceBBox.containsPoint(targetPoint);\n\n // The target point is inside the source element\n if (isPointInsideSource) {\n if (soy <= tmy1) {\n const x = Math.max(smx1, tmx1);\n const y = Math.max(soy + sourceMargin, toy);\n\n return [\n { x, y: soy },\n { x, y },\n { x: tox, y }\n ];\n }\n\n // Target anchor is above the source anchor\n const anchorMiddleY = (soy - sourceMargin + toy) / 2;\n\n return [\n { x: sox, y: soy },\n { x: sox, y: anchorMiddleY },\n { x: tox, y: anchorMiddleY }\n ];\n }\n\n if (smx1 < tox) {\n if (soy < toy) {\n let x = tmx1;\n\n if (tmx0 >= smx1 && tmy1 >= soy) {\n x = middleOfVerticalSides;\n }\n\n return [\n { x, y: soy },\n { x, y: toy },\n { x: tox, y: toy }\n ];\n }\n\n return [{ x: tox, y: soy }];\n }\n\n const y = Math.max(tmy1, middleOfHorizontalSides);\n\n if (soy > toy && sx0 <= tox) {\n return [\n { x: sox, y: soy },\n { x: sox, y },\n { x: tox, y }\n ];\n }\n\n if (y > smy0 && sox > tx0) {\n const x = Math.max(smx1, tmx1);\n const y = Math.max(smy1, tmy1);\n\n return [\n { x, y: soy },\n { x, y },\n { x: tox, y }\n ];\n }\n\n return [\n { x: sox, y: soy },\n { x: sox, y },\n { x: tox, y }\n ];\n }\n}\n\nfunction getLoopCoordinates(direction, angle, margin) {\n const isHorizontal = direction === Directions.LEFT || direction === Directions.RIGHT;\n\n let dx = 0;\n let dy = 0;\n\n switch (g.normalizeAngle(Math.round(angle))) {\n case 0:\n case 90:\n dx = isHorizontal ? 0 : margin;\n dy = isHorizontal ? margin : 0;\n break;\n case 180:\n case 270:\n dx = isHorizontal ? 0 : -margin;\n dy = isHorizontal ? -margin : 0;\n break;\n }\n\n return { dx, dy };\n}\n\nfunction rightAngleRouter(vertices, opt, linkView) {\n const { sourceDirection = Directions.AUTO, targetDirection = Directions.AUTO } = opt;\n const margin = opt.margin || 20;\n const useVertices = opt.useVertices || false;\n\n const isSourcePort = !!linkView.model.source().port;\n const sourcePoint = pointDataFromAnchor(linkView.sourceView, linkView.sourceAnchor, linkView.sourceBBox, sourceDirection, isSourcePort, linkView.sourceAnchor, margin);\n\n const isTargetPort = !!linkView.model.target().port;\n const targetPoint = pointDataFromAnchor(linkView.targetView, linkView.targetAnchor, linkView.targetBBox, targetDirection, isTargetPort, linkView.targetAnchor, margin);\n\n let resultVertices = [];\n\n if (!useVertices || vertices.length === 0) {\n return simplifyPoints(routeBetweenPoints(sourcePoint, targetPoint));\n }\n\n const verticesData = vertices.map((v) => pointDataFromVertex(v));\n const [firstVertex] = verticesData;\n\n const [resolvedSourceDirection] = resolveSides(sourcePoint, firstVertex);\n const isElement = sourcePoint.view && sourcePoint.view.model.isElement();\n const sourceBBox = isElement ? moveAndExpandBBox(sourcePoint.view.model.getBBox(), resolvedSourceDirection, margin) : null;\n const isVertexInside = isElement ? sourceBBox.containsPoint(firstVertex.point) : false;\n\n if (isVertexInside) {\n const outsidePoint = getOutsidePoint(resolvedSourceDirection, sourcePoint, margin);\n const firstPointOverlap = outsidePoint.equals(firstVertex.point);\n\n const alignsVertically = sourcePoint.point.x === firstVertex.point.x;\n const alignsHorizontally = sourcePoint.point.y === firstVertex.point.y;\n\n const isVerticalAndAligns = alignsVertically && (resolvedSourceDirection === Directions.TOP || resolvedSourceDirection === Directions.BOTTOM);\n const isHorizontalAndAligns = alignsHorizontally && (resolvedSourceDirection === Directions.LEFT || resolvedSourceDirection === Directions.RIGHT);\n\n const firstSegment = new g.Line(sourcePoint.point, outsidePoint);\n const isVertexOnSegment = firstSegment.containsPoint(firstVertex.point);\n\n const isVertexAlignedAndInside = isVertexInside && (isHorizontalAndAligns || isVerticalAndAligns);\n\n \n\n if (firstPointOverlap) {\n resultVertices.push(sourcePoint.point, firstVertex.point);\n // Set the access direction as the opposite of the source direction that will be used to connect the route with the next vertex\n firstVertex.direction = OPPOSITE_DIRECTIONS[resolvedSourceDirection];\n } else if (isVertexOnSegment || isVertexAlignedAndInside) {\n // Case where there is a need to create a loop\n const angle = getSegmentAngle(isVertexOnSegment ? firstSegment : new g.Line(sourcePoint.point, firstVertex.point));\n const { dx, dy } = getLoopCoordinates(resolvedSourceDirection, angle, margin);\n\n const loop = createLoop({ point: outsidePoint }, firstVertex, { dx, dy });\n const secondCreatedPoint = loop[2];\n const loopEndSegment = new g.Line(firstVertex.point, secondCreatedPoint);\n\n const accessDirection = ANGLE_DIRECTION_MAP[getSegmentAngle(loopEndSegment)];\n firstVertex.direction = accessDirection;\n resultVertices.push(...loop);\n } else {\n // No need to create a route, use the `routeBetweenPoints` to construct a route\n firstVertex.direction = resolvedSourceDirection;\n firstVertex.margin = margin;\n resultVertices.push(...routeBetweenPoints(sourcePoint, firstVertex, { targetInSourceBBox: true }), firstVertex.point);\n }\n } else {\n // The first point responsible for the initial direction of the route\n const next = verticesData[1] || targetPoint;\n const direction = resolveInitialDirection(sourcePoint, firstVertex, next);\n firstVertex.direction = direction;\n\n resultVertices.push(...routeBetweenPoints(sourcePoint, firstVertex), firstVertex.point);\n }\n\n for (let i = 0; i < verticesData.length - 1; i++) {\n const from = verticesData[i];\n const to = verticesData[i + 1];\n\n const connectionSegment = new g.Line(from.point, to.point);\n const connectionSegmentAngle = getSegmentAngle(connectionSegment);\n if (connectionSegmentAngle % 90 === 0) {\n // Segment is horizontal or vertical\n const connectionDirection = ANGLE_DIRECTION_MAP[connectionSegmentAngle];\n\n const simplifiedRoute = simplifyPoints([...resultVertices, from.point]);\n // const simplifiedRoute2 = simplifyPoints([from.point, ...resultVertices]);\n // Find out the direction that is used to connect the current route with the next vertex\n const accessSegment = new g.Line(simplifiedRoute[simplifiedRoute.length - 2], simplifiedRoute[simplifiedRoute.length - 1]);\n // const accessSegment2 = new g.Line(simplifiedRoute2[simplifiedRoute2.length - 2], simplifiedRoute2[simplifiedRoute2.length - 1]);\n const accessDirection = ANGLE_DIRECTION_MAP[Math.round(getSegmentAngle(accessSegment))];\n // const accessDirection2 = ANGLE_DIRECTION_MAP[Math.round(getSegmentAngle(accessSegment2))];\n // console.log(accessDirection);\n // console.log(accessDirection2);\n // if (accessDirection !== accessDirection2) {\n // console.log('error');\n // }\n // console.log('------------------');\n\n if (connectionDirection !== OPPOSITE_DIRECTIONS[accessDirection]) {\n // The directions are not opposite, so we can connect the vertices directly\n resultVertices.push(from.point, to.point);\n const [, toDirection] = resolveSides(from, to);\n to.direction = toDirection;\n } else {\n // The directions are overlapping, so we need to create a loop\n const { loopRoute, continueDirection } = loopSegment(from, to, connectionSegmentAngle, margin);\n to.direction = continueDirection;\n // Constructing a loop\n resultVertices.push(...loopRoute);\n }\n\n continue;\n }\n\n // Vertices are not aligned vertically nor horizontally\n // so we need to route between them\n\n const [fromDirection, toDirection] = resolveDirection(from, to);\n\n from.direction = fromDirection;\n to.direction = toDirection;\n\n resultVertices.push(...routeBetweenPoints(from, to), to.point);\n }\n\n const lastVertex = verticesData[verticesData.length - 1];\n\n if (targetPoint.view && targetPoint.view.model.isElement()) {\n const [, resolvedTargetDirection] = resolveSides(lastVertex, targetPoint);\n const outsidePoint = getOutsidePoint(resolvedTargetDirection, targetPoint, margin);\n\n // the last point of `simplified` array is the last defined vertex\n // this will ensure that the last segment continues in a straight line\n const simplified = simplifyPoints([...resultVertices, lastVertex.point]);\n const simplifiedSegment = new g.Line(simplified[simplified.length - 2], simplified[simplified.length - 1]);\n const simplifiedSegmentAngle = Math.round(getSegmentAngle(simplifiedSegment));\n const definedDirection = ANGLE_DIRECTION_MAP[simplifiedSegmentAngle];\n\n const lastPointOverlap = outsidePoint.equals(lastVertex.point);\n\n if (!lastPointOverlap || (lastPointOverlap && definedDirection === resolvedTargetDirection)) {\n\n lastVertex.direction = definedDirection;\n\n let lastSegmentRoute = routeBetweenPoints(lastVertex, targetPoint);\n const [p1, p2] = simplifyPoints([...lastSegmentRoute, targetPoint.point]);\n\n const lastSegment = new g.Line(p1, p2);\n const roundedLastSegmentAngle = Math.round(getSegmentAngle(lastSegment));\n const lastSegmentDirection = ANGLE_DIRECTION_MAP[roundedLastSegmentAngle];\n\n const targetBBox = moveAndExpandBBox(targetPoint.view.model.getBBox(), resolvedTargetDirection, margin);\n\n const alignsVertically = lastVertex.point.x === targetPoint.point.x;\n const alignsHorizontally = lastVertex.point.y === targetPoint.point.y;\n const isVertexInside = targetBBox.containsPoint(lastVertex.point);\n\n const isVerticalAndAligns = alignsVertically && (resolvedTargetDirection === Directions.TOP || resolvedTargetDirection === Directions.BOTTOM);\n const isHorizontalAndAligns = alignsHorizontally && (resolvedTargetDirection === Directions.LEFT || resolvedTargetDirection === Directions.RIGHT);\n\n \n if (!lastPointOverlap && isVertexInside && (isHorizontalAndAligns || isVerticalAndAligns)) {\n // Handle special cases when the last vertex is inside the target element\n // and in is aligned with the connection point => construct a loop\n const { dx, dy } = getLoopCoordinates(resolvedTargetDirection, simplifiedSegmentAngle, margin);\n lastSegmentRoute = createLoop(lastVertex, { point: outsidePoint }, { dx, dy });\n } else if (isVertexInside && resolvedTargetDirection !== OPPOSITE_DIRECTIONS[definedDirection]) {\n lastVertex.margin = margin;\n lastVertex.direction = resolvedTargetDirection;\n lastSegmentRoute = routeBetweenPoints(lastVertex, targetPoint);\n } else if (lastSegmentDirection !== definedDirection && definedDirection === OPPOSITE_DIRECTIONS[lastSegmentDirection]) {\n lastVertex.margin = margin;\n lastSegmentRoute = routeBetweenPoints(lastVertex, targetPoint);\n }\n\n resultVertices.push(...lastSegmentRoute);\n }\n } else {\n // since the target is only a point we can apply the same logic as if we connected two verticesData\n const from = lastVertex;\n const to = targetPoint;\n\n const connectionSegment = new g.Line(from.point, to.point);\n const connectionSegmentAngle = getSegmentAngle(connectionSegment);\n if (connectionSegmentAngle % 90 === 0) {\n // Segment is horizontal or vertical\n const connectionDirection = ANGLE_DIRECTION_MAP[connectionSegmentAngle];\n\n const simplifiedRoute = simplifyPoints(resultVertices);\n // Find out the direction that is used to connect the current route with the next vertex\n const accessSegment = new g.Line(simplifiedRoute[simplifiedRoute.length - 2], from.point);\n const accessDirection = ANGLE_DIRECTION_MAP[Math.round(getSegmentAngle(accessSegment))];\n\n if (connectionDirection !== OPPOSITE_DIRECTIONS[accessDirection]) {\n // The directions are not opposite, so we can connect the vertices directly by adding the first point\n // the target point is handled separately\n resultVertices.push(from.point);\n } else {\n // The directions are overlapping, so we need to create a loop\n const { loopRoute } = loopSegment(from, to, connectionSegmentAngle, margin);\n // Remove the last point since it is the target that is handled separately\n loopRoute.pop();\n // Constructing a loop\n resultVertices.push(...loopRoute);\n }\n } else {\n // The last vertex and the target are not aligned vertically nor horizontally\n // so we need to route between them\n const [fromDirection, toDirection] = resolveDirection(from, to);\n\n from.direction = fromDirection;\n to.direction = toDirection;\n\n resultVertices.push(...routeBetweenPoints(from, to));\n }\n }\n\n return simplifyPoints(resultVertices);\n}\n\nfunction resolveDirection(from, to) {\n const accessDirection = from.direction;\n const isDirectionVertical = VERTICAL_DIRECTIONS.includes(accessDirection);\n\n let sourceDirection = from.direction;\n let targetDirection = to.direction;\n\n if (isDirectionVertical) {\n const isToAbove = from.point.y > to.point.y;\n const dx = to.point.x - from.point.x;\n\n if (accessDirection === Directions.BOTTOM) {\n // If isToAbove === false and we need figure out if to go left or right\n sourceDirection = isToAbove ? OPPOSITE_DIRECTIONS[accessDirection] : dx >= 0 ? Directions.RIGHT : Directions.LEFT;\n\n if (dx > 0) {\n targetDirection = isToAbove ? Directions.LEFT : Directions.TOP;\n } else if (dx < 0) {\n targetDirection = isToAbove ? Directions.RIGHT : Directions.TOP;\n }\n } else {\n // If isToAbove === true and we need figure out if to go left or right\n sourceDirection = isToAbove ? dx >= 0 ? Directions.RIGHT : Directions.LEFT : OPPOSITE_DIRECTIONS[accessDirection];\n\n if (dx > 0) {\n targetDirection = isToAbove ? Directions.BOTTOM : Directions.LEFT;\n } else if (dx < 0) {\n targetDirection = isToAbove ? Directions.BOTTOM : Directions.RIGHT;\n }\n }\n } else {\n const isToLeft = from.point.x > to.point.x;\n const dy = to.point.y - from.point.y;\n\n if (accessDirection === Directions.RIGHT) {\n sourceDirection = isToLeft ? OPPOSITE_DIRECTIONS[accessDirection] : dy >= 0 ? Directions.BOTTOM : Directions.TOP;\n\n if (dy > 0) {\n targetDirection = isToLeft ? Directions.TOP : Directions.LEFT;\n } else if (dy < 0) {\n targetDirection = isToLeft ? Directions.BOTTOM : Directions.LEFT;\n }\n } else {\n sourceDirection = isToLeft ? dy >= 0 ? Directions.BOTTOM : Directions.TOP : OPPOSITE_DIRECTIONS[accessDirection];\n\n if (dy > 0) {\n targetDirection = isToLeft ? Directions.RIGHT : Directions.TOP;\n } else if (dy < 0) {\n targetDirection = isToLeft ? Directions.RIGHT : Directions.BOTTOM;\n }\n }\n }\n\n return [sourceDirection, targetDirection];\n}\n\nrightAngleRouter.Directions = Directions;\n\nexport const rightAngle = rightAngleRouter;\n","import * as g from '../g/index.mjs';\n\nconst CornerTypes = {\n POINT: 'point',\n CUBIC: 'cubic',\n LINE: 'line',\n GAP: 'gap'\n};\n\nconst DEFINED_CORNER_TYPES = Object.values(CornerTypes);\n\nconst CORNER_RADIUS = 10;\nconst PRECISION = 1;\n\nexport const straight = function(sourcePoint, targetPoint, routePoints = [], opt = {}) {\n\n const {\n cornerType = CornerTypes.POINT,\n cornerRadius = CORNER_RADIUS,\n cornerPreserveAspectRatio = false,\n precision = PRECISION,\n raw = false\n } = opt;\n\n if (DEFINED_CORNER_TYPES.indexOf(cornerType) === -1) {\n // unknown `cornerType` provided => error\n throw new Error('Invalid `cornerType` provided to `straight` connector.');\n }\n\n let path;\n\n if ((cornerType === CornerTypes.POINT) || !cornerRadius) {\n // default option => normal connector\n // simply connect all points with straight lines\n const points = [sourcePoint].concat(routePoints).concat([targetPoint]);\n const polyline = new g.Polyline(points);\n path = new g.Path(polyline);\n\n } else {\n // `cornerType` is not unknown and not 'point' (default) => must be one of other valid types\n path = new g.Path();\n\n // add initial gap segment = to source point\n path.appendSegment(g.Path.createSegment('M', sourcePoint));\n\n let nextDistance;\n const routePointsLength = routePoints.length;\n for (let i = 0; i < routePointsLength; i++) {\n\n const curr = new g.Point(routePoints[i]);\n const prev = (routePoints[i - 1] || sourcePoint);\n const next = (routePoints[i + 1] || targetPoint);\n const prevDistance = (nextDistance || (curr.distance(prev) / 2)); // try to re-use previously-computed `nextDistance`\n nextDistance = (curr.distance(next) / 2);\n\n let startMove, endMove;\n if (!cornerPreserveAspectRatio) {\n // `startMove` and `endMove` may be different\n // (this happens when next or previous path point is closer than `2 * cornerRadius`)\n startMove = -Math.min(cornerRadius, prevDistance);\n endMove = -Math.min(cornerRadius, nextDistance);\n } else {\n // force `startMove` and `endMove` to be the same\n startMove = endMove = -Math.min(cornerRadius, prevDistance, nextDistance);\n }\n\n // to find `cornerStart` and `cornerEnd`, the logic is as follows (using `cornerStart` as example):\n // - find a point lying on the line `prev - startMove` such that...\n // - ...the point lies `abs(startMove)` distance away from `curr`...\n // - ...and its coordinates are rounded to whole numbers\n const cornerStart = curr.clone().move(prev, startMove).round(precision);\n const cornerEnd = curr.clone().move(next, endMove).round(precision);\n\n // add in-between straight segment = from previous route point to corner start point\n // (may have zero length)\n path.appendSegment(g.Path.createSegment('L', cornerStart));\n\n // add corner segment = from corner start point to corner end point\n switch (cornerType) {\n case CornerTypes.CUBIC: {\n // corner is rounded\n const _13 = (1 / 3);\n const _23 = (2 / 3);\n const control1 = new g.Point((_13 * cornerStart.x) + (_23 * curr.x), (_23 * curr.y) + (_13 * cornerStart.y));\n const control2 = new g.Point((_13 * cornerEnd.x) + (_23 * curr.x), (_23 * curr.y) + (_13 * cornerEnd.y));\n path.appendSegment(g.Path.createSegment('C', control1, control2, cornerEnd));\n break;\n }\n case CornerTypes.LINE: {\n // corner has bevel\n path.appendSegment(g.Path.createSegment('L', cornerEnd));\n break;\n }\n case CornerTypes.GAP: {\n // corner has empty space\n path.appendSegment(g.Path.createSegment('M', cornerEnd));\n break;\n }\n // default: no segment is created\n }\n }\n\n // add final straight segment = from last corner end point to target point\n // (= or from start point to end point, if there are no route points)\n // (may have zero length)\n path.appendSegment(g.Path.createSegment('L', targetPoint));\n }\n\n return ((raw) ? path : path.serialize());\n};\n","import * as util from '../util/index.mjs';\nimport * as g from '../g/index.mjs';\n\n// default size of jump if not specified in options\nvar JUMP_SIZE = 5;\n\n// available jump types\n// first one taken as default\nvar JUMP_TYPES = ['arc', 'gap', 'cubic'];\n\n// default radius\nvar RADIUS = 0;\n\n// takes care of math. error for case when jump is too close to end of line\nvar CLOSE_PROXIMITY_PADDING = 1;\n\n// list of connector types not to jump over.\nvar IGNORED_CONNECTORS = ['smooth'];\n\n// internal constants for round segment\nvar _13 = 1 / 3;\nvar _23 = 2 / 3;\n\nfunction sortPointsAscending(p1, p2) {\n\n let { x: x1, y: y1 } = p1;\n let { x: x2, y: y2 } = p2;\n\n if (x1 > x2) {\n\n let swap = x1;\n x1 = x2;\n x2 = swap;\n\n swap = y1;\n y1 = y2;\n y2 = swap;\n }\n\n if (y1 > y2) {\n let swap = x1;\n x1 = x2;\n x2 = swap;\n\n swap = y1;\n y1 = y2;\n y2 = swap;\n }\n\n return [new g.Point(x1, y1), new g.Point(x2, y2)];\n}\n\nfunction overlapExists(line1, line2) {\n\n const [{ x: x1, y: y1 }, { x: x2, y: y2 }] = sortPointsAscending(line1.start, line1.end);\n const [{ x: x3, y: y3 }, { x: x4, y: y4 }] = sortPointsAscending(line2.start, line2.end);\n\n const xMatch = x1 <= x4 && x3 <= x2;\n const yMatch = y1 <= y4 && y3 <= y2;\n\n return xMatch && yMatch;\n}\n\n/**\n * Transform start/end and route into series of lines\n * @param {g.point} sourcePoint start point\n * @param {g.point} targetPoint end point\n * @param {g.point[]} route optional list of route\n * @return {g.line[]} [description]\n */\nfunction createLines(sourcePoint, targetPoint, route) {\n // make a flattened array of all points\n var points = [].concat(sourcePoint, route, targetPoint);\n return points.reduce(function(resultLines, point, idx) {\n // if there is a next point, make a line with it\n var nextPoint = points[idx + 1];\n if (nextPoint != null) {\n resultLines[idx] = g.line(point, nextPoint);\n }\n return resultLines;\n }, []);\n}\n\nfunction setupUpdating(jumpOverLinkView) {\n var paper = jumpOverLinkView.paper;\n var updateList = paper._jumpOverUpdateList;\n\n // first time setup for this paper\n if (updateList == null) {\n updateList = paper._jumpOverUpdateList = [];\n var graph = paper.model;\n graph.on('batch:stop', function() {\n if (this.hasActiveBatch()) return;\n updateJumpOver(paper);\n });\n graph.on('reset', function() {\n updateList = paper._jumpOverUpdateList = [];\n });\n }\n\n // add this link to a list so it can be updated when some other link is updated\n if (updateList.indexOf(jumpOverLinkView) < 0) {\n updateList.push(jumpOverLinkView);\n\n // watch for change of connector type or removal of link itself\n // to remove the link from a list of jump over connectors\n jumpOverLinkView.listenToOnce(jumpOverLinkView.model, 'change:connector remove', function() {\n updateList.splice(updateList.indexOf(jumpOverLinkView), 1);\n });\n }\n}\n\n/**\n * Handler for a batch:stop event to force\n * update of all registered links with jump over connector\n * @param {object} batchEvent optional object with info about batch\n */\nfunction updateJumpOver(paper) {\n var updateList = paper._jumpOverUpdateList;\n for (var i = 0; i < updateList.length; i++) {\n const linkView = updateList[i];\n const updateFlag = linkView.getFlag(linkView.constructor.Flags.CONNECTOR);\n linkView.requestUpdate(updateFlag);\n }\n}\n\n/**\n * Utility function to collect all intersection points of a single\n * line against group of other lines.\n * @param {g.line} line where to find points\n * @param {g.line[]} crossCheckLines lines to cross\n * @return {g.point[]} list of intersection points\n */\nfunction findLineIntersections(line, crossCheckLines) {\n return util.toArray(crossCheckLines).reduce(function(res, crossCheckLine) {\n var intersection = line.intersection(crossCheckLine);\n if (intersection) {\n res.push(intersection);\n }\n return res;\n }, []);\n}\n\n/**\n * Sorting function for list of points by their distance.\n * @param {g.point} p1 first point\n * @param {g.point} p2 second point\n * @return {number} squared distance between points\n */\nfunction sortPoints(p1, p2) {\n return g.line(p1, p2).squaredLength();\n}\n\n/**\n * Split input line into multiple based on intersection points.\n * @param {g.line} line input line to split\n * @param {g.point[]} intersections points where to split the line\n * @param {number} jumpSize the size of jump arc (length empty spot on a line)\n * @return {g.line[]} list of lines being split\n */\nfunction createJumps(line, intersections, jumpSize) {\n return intersections.reduce(function(resultLines, point, idx) {\n // skipping points that were merged with the previous line\n // to make bigger arc over multiple lines that are close to each other\n if (point.skip === true) {\n return resultLines;\n }\n\n // always grab the last line from buffer and modify it\n var lastLine = resultLines.pop() || line;\n\n // calculate start and end of jump by moving by a given size of jump\n var jumpStart = g.point(point).move(lastLine.start, -(jumpSize));\n var jumpEnd = g.point(point).move(lastLine.start, +(jumpSize));\n\n // now try to look at the next intersection point\n var nextPoint = intersections[idx + 1];\n if (nextPoint != null) {\n var distance = jumpEnd.distance(nextPoint);\n if (distance <= jumpSize) {\n // next point is close enough, move the jump end by this\n // difference and mark the next point to be skipped\n jumpEnd = nextPoint.move(lastLine.start, distance);\n nextPoint.skip = true;\n }\n } else {\n // this block is inside of `else` as an optimization so the distance is\n // not calculated when we know there are no other intersection points\n var endDistance = jumpStart.distance(lastLine.end);\n // if the end is too close to possible jump, draw remaining line instead of a jump\n if (endDistance < jumpSize * 2 + CLOSE_PROXIMITY_PADDING) {\n resultLines.push(lastLine);\n return resultLines;\n }\n }\n\n var startDistance = jumpEnd.distance(lastLine.start);\n if (startDistance < jumpSize * 2 + CLOSE_PROXIMITY_PADDING) {\n // if the start of line is too close to jump, draw that line instead of a jump\n resultLines.push(lastLine);\n return resultLines;\n }\n\n // finally create a jump line\n var jumpLine = g.line(jumpStart, jumpEnd);\n // it's just simple line but with a `isJump` property\n jumpLine.isJump = true;\n\n resultLines.push(\n g.line(lastLine.start, jumpStart),\n jumpLine,\n g.line(jumpEnd, lastLine.end)\n );\n return resultLines;\n }, []);\n}\n\n/**\n * Assemble `D` attribute of a SVG path by iterating given lines.\n * @param {g.line[]} lines source lines to use\n * @param {number} jumpSize the size of jump arc (length empty spot on a line)\n * @param {number} radius the radius\n * @return {string}\n */\nfunction buildPath(lines, jumpSize, jumpType, radius) {\n\n var path = new g.Path();\n var segment;\n\n // first move to the start of a first line\n segment = g.Path.createSegment('M', lines[0].start);\n path.appendSegment(segment);\n\n // make a paths from lines\n util.toArray(lines).forEach(function(line, index) {\n\n if (line.isJump) {\n var angle, diff;\n\n var control1, control2;\n\n if (jumpType === 'arc') { // approximates semicircle with 2 curves\n angle = -90;\n // determine rotation of arc based on difference between points\n diff = line.start.difference(line.end);\n // make sure the arc always points up (or right)\n var xAxisRotate = Number((diff.x < 0) || (diff.x === 0 && diff.y < 0));\n if (xAxisRotate) angle += 180;\n\n var midpoint = line.midpoint();\n var centerLine = new g.Line(midpoint, line.end).rotate(midpoint, angle);\n\n var halfLine;\n\n // first half\n halfLine = new g.Line(line.start, midpoint);\n\n control1 = halfLine.pointAt(2 / 3).rotate(line.start, angle);\n control2 = centerLine.pointAt(1 / 3).rotate(centerLine.end, -angle);\n\n segment = g.Path.createSegment('C', control1, control2, centerLine.end);\n path.appendSegment(segment);\n\n // second half\n halfLine = new g.Line(midpoint, line.end);\n\n control1 = centerLine.pointAt(1 / 3).rotate(centerLine.end, angle);\n control2 = halfLine.pointAt(1 / 3).rotate(line.end, -angle);\n\n segment = g.Path.createSegment('C', control1, control2, line.end);\n path.appendSegment(segment);\n\n } else if (jumpType === 'gap') {\n segment = g.Path.createSegment('M', line.end);\n path.appendSegment(segment);\n\n } else if (jumpType === 'cubic') { // approximates semicircle with 1 curve\n angle = line.start.theta(line.end);\n\n var xOffset = jumpSize * 0.6;\n var yOffset = jumpSize * 1.35;\n\n // determine rotation of arc based on difference between points\n diff = line.start.difference(line.end);\n // make sure the arc always points up (or right)\n xAxisRotate = Number((diff.x < 0) || (diff.x === 0 && diff.y < 0));\n if (xAxisRotate) yOffset *= -1;\n\n control1 = g.Point(line.start.x + xOffset, line.start.y + yOffset).rotate(line.start, angle);\n control2 = g.Point(line.end.x - xOffset, line.end.y + yOffset).rotate(line.end, angle);\n\n segment = g.Path.createSegment('C', control1, control2, line.end);\n path.appendSegment(segment);\n }\n\n } else {\n var nextLine = lines[index + 1];\n if (radius == 0 || !nextLine || nextLine.isJump) {\n segment = g.Path.createSegment('L', line.end);\n path.appendSegment(segment);\n } else {\n buildRoundedSegment(radius, path, line.end, line.start, nextLine.end);\n }\n }\n });\n\n return path;\n}\n\nfunction buildRoundedSegment(offset, path, curr, prev, next) {\n var prevDistance = curr.distance(prev) / 2;\n var nextDistance = curr.distance(next) / 2;\n\n var startMove = -Math.min(offset, prevDistance);\n var endMove = -Math.min(offset, nextDistance);\n\n var roundedStart = curr.clone().move(prev, startMove).round();\n var roundedEnd = curr.clone().move(next, endMove).round();\n\n var control1 = new g.Point((_13 * roundedStart.x) + (_23 * curr.x), (_23 * curr.y) + (_13 * roundedStart.y));\n var control2 = new g.Point((_13 * roundedEnd.x) + (_23 * curr.x), (_23 * curr.y) + (_13 * roundedEnd.y));\n\n var segment;\n segment = g.Path.createSegment('L', roundedStart);\n path.appendSegment(segment);\n\n segment = g.Path.createSegment('C', control1, control2, roundedEnd);\n path.appendSegment(segment);\n}\n\n/**\n * Actual connector function that will be run on every update.\n * @param {g.point} sourcePoint start point of this link\n * @param {g.point} targetPoint end point of this link\n * @param {g.point[]} route of this link\n * @param {object} opt options\n * @property {number} size optional size of a jump arc\n * @return {string} created `D` attribute of SVG path\n */\nexport const jumpover = function(sourcePoint, targetPoint, route, opt) { // eslint-disable-line max-params\n\n setupUpdating(this);\n\n var raw = opt.raw;\n var jumpSize = opt.size || JUMP_SIZE;\n var jumpType = opt.jump && ('' + opt.jump).toLowerCase();\n var radius = opt.radius || RADIUS;\n var ignoreConnectors = opt.ignoreConnectors || IGNORED_CONNECTORS;\n\n // grab the first jump type as a default if specified one is invalid\n if (JUMP_TYPES.indexOf(jumpType) === -1) {\n jumpType = JUMP_TYPES[0];\n }\n\n var paper = this.paper;\n var graph = paper.model;\n var allLinks = graph.getLinks();\n\n // there is just one link, draw it directly\n if (allLinks.length === 1) {\n return buildPath(\n createLines(sourcePoint, targetPoint, route),\n jumpSize, jumpType, radius\n );\n }\n\n var thisModel = this.model;\n var thisIndex = allLinks.indexOf(thisModel);\n var defaultConnector = paper.options.defaultConnector || {};\n\n // not all links are meant to be jumped over.\n var links = allLinks.filter(function(link, idx) {\n\n var connector = link.get('connector') || defaultConnector;\n\n // avoid jumping over links with connector type listed in `ignored connectors`.\n if (util.toArray(ignoreConnectors).includes(connector.name)) {\n return false;\n }\n // filter out links that are above this one and have the same connector type\n // otherwise there would double hoops for each intersection\n if (idx > thisIndex) {\n return connector.name !== 'jumpover';\n }\n return true;\n });\n\n // find views for all links\n var linkViews = links.map(function(link) {\n return paper.findViewByModel(link);\n });\n\n // create lines for this link\n var thisLines = createLines(\n sourcePoint,\n targetPoint,\n route\n );\n\n // create lines for all other links\n var linkLines = linkViews.map(function(linkView) {\n if (linkView == null) {\n return [];\n }\n if (linkView === this) {\n return thisLines;\n }\n return createLines(\n linkView.sourcePoint,\n linkView.targetPoint,\n linkView.route\n );\n }, this);\n\n // transform lines for this link by splitting with jump lines at\n // points of intersection with other links\n var jumpingLines = thisLines.reduce(function(resultLines, thisLine) {\n // iterate all links and grab the intersections with this line\n // these are then sorted by distance so the line can be split more easily\n var intersections = links.reduce(function(res, link, i) {\n // don't intersection with itself\n if (link !== thisModel) {\n\n const linkLinesToTest = linkLines[i].slice();\n const overlapIndex = linkLinesToTest.findIndex((line) => overlapExists(thisLine, line));\n\n // Overlap occurs and the end point of one segment lies on thisLine\n if (overlapIndex > -1 && thisLine.containsPoint(linkLinesToTest[overlapIndex].end)) {\n // Remove the next segment because there will never be a jump\n linkLinesToTest.splice(overlapIndex + 1, 1);\n }\n const lineIntersections = findLineIntersections(thisLine, linkLinesToTest);\n res.push.apply(res, lineIntersections);\n }\n return res;\n }, []).sort(function(a, b) {\n return sortPoints(thisLine.start, a) - sortPoints(thisLine.start, b);\n });\n\n if (intersections.length > 0) {\n // split the line based on found intersection points\n resultLines.push.apply(resultLines, createJumps(thisLine, intersections, jumpSize));\n } else {\n // without any intersection the line goes uninterrupted\n resultLines.push(thisLine);\n }\n return resultLines;\n }, []);\n\n var path = buildPath(jumpingLines, jumpSize, jumpType, radius);\n return (raw) ? path : path.serialize();\n};\n","import { straight } from './straight.mjs';\n\nexport const normal = function(sourcePoint, targetPoint, route = [], opt = {}) {\n\n const { raw } = opt;\n const localOpt = {\n cornerType: 'point',\n raw\n };\n\n return straight(sourcePoint, targetPoint, route, localOpt);\n};\n","import { straight } from './straight.mjs';\n\nconst CORNER_RADIUS = 10;\nconst PRECISION = 0;\n\nexport const rounded = function(sourcePoint, targetPoint, route = [], opt = {}) {\n\n const { radius = CORNER_RADIUS, raw } = opt;\n const localOpt = {\n cornerType: 'cubic',\n cornerRadius: radius,\n precision: PRECISION,\n raw\n };\n\n return straight(sourcePoint, targetPoint, route, localOpt);\n};\n","import * as g from '../g/index.mjs';\n\nexport const smooth = function(sourcePoint, targetPoint, route, opt) {\n\n var raw = opt && opt.raw;\n var path;\n\n if (route && route.length !== 0) {\n\n var points = [sourcePoint].concat(route).concat([targetPoint]);\n var curves = g.Curve.throughPoints(points);\n\n path = new g.Path(curves);\n\n } else {\n // if we have no route, use a default cubic bezier curve\n // cubic bezier requires two control points\n // the control points have `x` midway between source and target\n // this produces an S-like curve\n\n path = new g.Path();\n\n var segment;\n\n segment = g.Path.createSegment('M', sourcePoint);\n path.appendSegment(segment);\n\n if ((Math.abs(sourcePoint.x - targetPoint.x)) >= (Math.abs(sourcePoint.y - targetPoint.y))) {\n var controlPointX = (sourcePoint.x + targetPoint.x) / 2;\n\n segment = g.Path.createSegment('C', controlPointX, sourcePoint.y, controlPointX, targetPoint.y, targetPoint.x, targetPoint.y);\n path.appendSegment(segment);\n\n } else {\n var controlPointY = (sourcePoint.y + targetPoint.y) / 2;\n\n segment = g.Path.createSegment('C', sourcePoint.x, controlPointY, targetPoint.x, controlPointY, targetPoint.x, targetPoint.y);\n path.appendSegment(segment);\n\n }\n }\n\n return (raw) ? path : path.serialize();\n};\n","import { Path, Point, Curve } from '../g/index.mjs';\n\nconst Directions = {\n AUTO: 'auto',\n HORIZONTAL: 'horizontal',\n VERTICAL: 'vertical',\n CLOSEST_POINT: 'closest-point',\n OUTWARDS: 'outwards'\n};\n\nconst TangentDirections = {\n UP: 'up',\n DOWN: 'down',\n LEFT: 'left',\n RIGHT: 'right',\n AUTO: 'auto',\n CLOSEST_POINT: 'closest-point',\n OUTWARDS: 'outwards'\n};\n\nexport const curve = function(sourcePoint, targetPoint, route = [], opt = {}, linkView) {\n const raw = Boolean(opt.raw);\n // distanceCoefficient - a coefficient of the tangent vector length relative to the distance between points.\n // angleTangentCoefficient - a coefficient of the end tangents length in the case of angles larger than 45 degrees.\n // tension - a Catmull-Rom curve tension parameter.\n // sourceTangent - a tangent vector along the curve at the sourcePoint.\n // sourceDirection - a unit direction vector along the curve at the sourcePoint.\n // targetTangent - a tangent vector along the curve at the targetPoint.\n // targetDirection - a unit direction vector along the curve at the targetPoint.\n // precision - a rounding precision for path values.\n const { direction = Directions.AUTO, precision = 3 } = opt;\n const options = {\n coeff: opt.distanceCoefficient || 0.6,\n angleTangentCoefficient: opt.angleTangentCoefficient || 80,\n tau: opt.tension || 0.5,\n sourceTangent: opt.sourceTangent ? new Point(opt.sourceTangent) : null,\n targetTangent: opt.targetTangent ? new Point(opt.targetTangent) : null,\n rotate: Boolean(opt.rotate)\n };\n if (typeof opt.sourceDirection === 'string')\n options.sourceDirection = opt.sourceDirection;\n else if (typeof opt.sourceDirection === 'number')\n options.sourceDirection = new Point(1, 0).rotate(null, opt.sourceDirection);\n else\n options.sourceDirection = opt.sourceDirection ? new Point(opt.sourceDirection).normalize() : null;\n\n if (typeof opt.targetDirection === 'string')\n options.targetDirection = opt.targetDirection;\n else if (typeof opt.targetDirection === 'number')\n options.targetDirection = new Point(1, 0).rotate(null, opt.targetDirection);\n else\n options.targetDirection = opt.targetDirection ? new Point(opt.targetDirection).normalize() : null;\n\n const completeRoute = [sourcePoint, ...route, targetPoint].map(p => new Point(p));\n\n // The calculation of a sourceTangent\n let sourceTangent;\n if (options.sourceTangent) {\n sourceTangent = options.sourceTangent;\n } else {\n const sourceDirection = getSourceTangentDirection(linkView, completeRoute, direction, options);\n const tangentLength = completeRoute[0].distance(completeRoute[1]) * options.coeff;\n const pointsVector = completeRoute[1].difference(completeRoute[0]).normalize();\n const angle = angleBetweenVectors(sourceDirection, pointsVector);\n if (angle > Math.PI / 4) {\n const updatedLength = tangentLength + (angle - Math.PI / 4) * options.angleTangentCoefficient;\n sourceTangent = sourceDirection.clone().scale(updatedLength, updatedLength);\n } else {\n sourceTangent = sourceDirection.clone().scale(tangentLength, tangentLength);\n }\n }\n\n // The calculation of a targetTangent\n let targetTangent;\n if (options.targetTangent) {\n targetTangent = options.targetTangent;\n } else {\n const targetDirection = getTargetTangentDirection(linkView, completeRoute, direction, options);\n const last = completeRoute.length - 1;\n const tangentLength = completeRoute[last - 1].distance(completeRoute[last]) * options.coeff;\n const pointsVector = completeRoute[last - 1].difference(completeRoute[last]).normalize();\n const angle = angleBetweenVectors(targetDirection, pointsVector);\n if (angle > Math.PI / 4) {\n const updatedLength = tangentLength + (angle - Math.PI / 4) * options.angleTangentCoefficient;\n targetTangent = targetDirection.clone().scale(updatedLength, updatedLength);\n } else {\n targetTangent = targetDirection.clone().scale(tangentLength, tangentLength);\n }\n }\n\n const catmullRomCurves = createCatmullRomCurves(completeRoute, sourceTangent, targetTangent, options);\n const bezierCurves = catmullRomCurves.map(curve => catmullRomToBezier(curve, options));\n const path = new Path(bezierCurves).round(precision);\n\n return (raw) ? path : path.serialize();\n};\ncurve.Directions = Directions;\ncurve.TangentDirections = TangentDirections;\n\nfunction getHorizontalSourceDirection(linkView, route, options) {\n const { sourceBBox } = linkView;\n\n let sourceSide;\n let rotation;\n if (!linkView.sourceView) {\n if (sourceBBox.x > route[1].x)\n sourceSide = 'right';\n else\n sourceSide = 'left';\n } else {\n rotation = linkView.sourceView.model.angle();\n if (options.rotate && rotation) {\n const unrotatedBBox = linkView.sourceView.getNodeUnrotatedBBox(linkView.sourceView.el);\n const sourcePoint = route[0].clone();\n sourcePoint.rotate(sourceBBox.center(), rotation);\n sourceSide = unrotatedBBox.sideNearestToPoint(sourcePoint);\n } else {\n sourceSide = sourceBBox.sideNearestToPoint(route[0]);\n }\n }\n\n let direction;\n switch (sourceSide) {\n case 'left':\n direction = new Point(-1, 0);\n break;\n case 'right':\n default:\n direction = new Point(1, 0);\n break;\n }\n\n if (options.rotate && rotation) {\n direction.rotate(null, -rotation);\n }\n\n return direction;\n}\n\nfunction getHorizontalTargetDirection(linkView, route, options) {\n const { targetBBox } = linkView;\n\n let targetSide;\n let rotation;\n if (!linkView.targetView) {\n if (targetBBox.x > route[route.length - 2].x)\n targetSide = 'left';\n else\n targetSide = 'right';\n } else {\n rotation = linkView.targetView.model.angle();\n if (options.rotate && rotation) {\n const unrotatedBBox = linkView.targetView.getNodeUnrotatedBBox(linkView.targetView.el);\n const targetPoint = route[route.length - 1].clone();\n targetPoint.rotate(targetBBox.center(), rotation);\n targetSide = unrotatedBBox.sideNearestToPoint(targetPoint);\n } else {\n targetSide = targetBBox.sideNearestToPoint(route[route.length - 1]);\n }\n }\n\n let direction;\n switch (targetSide) {\n case 'left':\n direction = new Point(-1, 0);\n break;\n case 'right':\n default:\n direction = new Point(1, 0);\n break;\n }\n\n if (options.rotate && rotation) {\n direction.rotate(null, -rotation);\n }\n\n return direction;\n}\n\nfunction getVerticalSourceDirection(linkView, route, options) {\n const { sourceBBox } = linkView;\n\n let sourceSide;\n let rotation;\n if (!linkView.sourceView) {\n if (sourceBBox.y > route[1].y)\n sourceSide = 'bottom';\n else\n sourceSide = 'top';\n } else {\n rotation = linkView.sourceView.model.angle();\n if (options.rotate && rotation) {\n const unrotatedBBox = linkView.sourceView.getNodeUnrotatedBBox(linkView.sourceView.el);\n const sourcePoint = route[0].clone();\n sourcePoint.rotate(sourceBBox.center(), rotation);\n sourceSide = unrotatedBBox.sideNearestToPoint(sourcePoint);\n } else {\n sourceSide = sourceBBox.sideNearestToPoint(route[0]);\n }\n }\n\n let direction;\n switch (sourceSide) {\n case 'top':\n direction = new Point(0, -1);\n break;\n case 'bottom':\n default:\n direction = new Point(0, 1);\n break;\n }\n\n if (options.rotate && rotation) {\n direction.rotate(null, -rotation);\n }\n\n return direction;\n}\n\nfunction getVerticalTargetDirection(linkView, route, options) {\n const { targetBBox } = linkView;\n\n let targetSide;\n let rotation;\n if (!linkView.targetView) {\n if (targetBBox.y > route[route.length - 2].y)\n targetSide = 'top';\n else\n targetSide = 'bottom';\n } else {\n rotation = linkView.targetView.model.angle();\n if (options.rotate && rotation) {\n const unrotatedBBox = linkView.targetView.getNodeUnrotatedBBox(linkView.targetView.el);\n const targetPoint = route[route.length - 1].clone();\n targetPoint.rotate(targetBBox.center(), rotation);\n targetSide = unrotatedBBox.sideNearestToPoint(targetPoint);\n } else {\n targetSide = targetBBox.sideNearestToPoint(route[route.length - 1]);\n }\n }\n\n\n let direction;\n switch (targetSide) {\n case 'top':\n direction = new Point(0, -1);\n break;\n case 'bottom':\n default:\n direction = new Point(0, 1);\n break;\n }\n\n if (options.rotate && rotation) {\n direction.rotate(null, -rotation);\n }\n\n return direction;\n}\n\nfunction getAutoSourceDirection(linkView, route, options) {\n const { sourceBBox } = linkView;\n\n let sourceSide;\n let rotation;\n if (!linkView.sourceView) {\n sourceSide = sourceBBox.sideNearestToPoint(route[1]);\n } else {\n rotation = linkView.sourceView.model.angle();\n if (options.rotate && rotation) {\n const unrotatedBBox = linkView.sourceView.getNodeUnrotatedBBox(linkView.sourceView.el);\n const sourcePoint = route[0].clone();\n sourcePoint.rotate(sourceBBox.center(), rotation);\n sourceSide = unrotatedBBox.sideNearestToPoint(sourcePoint);\n } else {\n sourceSide = sourceBBox.sideNearestToPoint(route[0]);\n }\n }\n\n let direction;\n switch (sourceSide) {\n case 'top':\n direction = new Point(0, -1);\n break;\n case 'bottom':\n direction = new Point(0, 1);\n break;\n case 'right':\n direction = new Point(1, 0);\n break;\n case 'left':\n direction = new Point(-1, 0);\n break;\n }\n\n if (options.rotate && rotation) {\n direction.rotate(null, -rotation);\n }\n\n return direction;\n}\n\nfunction getAutoTargetDirection(linkView, route, options) {\n const { targetBBox } = linkView;\n\n let targetSide;\n let rotation;\n if (!linkView.targetView) {\n targetSide = targetBBox.sideNearestToPoint(route[route.length - 2]);\n } else {\n rotation = linkView.targetView.model.angle();\n if (options.rotate && rotation) {\n const unrotatedBBox = linkView.targetView.getNodeUnrotatedBBox(linkView.targetView.el);\n const targetPoint = route[route.length - 1].clone();\n targetPoint.rotate(targetBBox.center(), rotation);\n targetSide = unrotatedBBox.sideNearestToPoint(targetPoint);\n } else {\n targetSide = targetBBox.sideNearestToPoint(route[route.length - 1]);\n }\n }\n\n let direction;\n switch (targetSide) {\n case 'top':\n direction = new Point(0, -1);\n break;\n case 'bottom':\n direction = new Point(0, 1);\n break;\n case 'right':\n direction = new Point(1, 0);\n break;\n case 'left':\n direction = new Point(-1, 0);\n break;\n }\n\n if (options.rotate && rotation) {\n direction.rotate(null, -rotation);\n }\n\n return direction;\n}\n\nfunction getClosestPointSourceDirection(linkView, route, options) {\n return route[1].difference(route[0]).normalize();\n}\n\nfunction getClosestPointTargetDirection(linkView, route, options) {\n const last = route.length - 1;\n return route[last - 1].difference(route[last]).normalize();\n}\n\nfunction getOutwardsSourceDirection(linkView, route, options) {\n const { sourceBBox } = linkView;\n const sourceCenter = sourceBBox.center();\n return route[0].difference(sourceCenter).normalize();\n}\n\nfunction getOutwardsTargetDirection(linkView, route, options) {\n const { targetBBox } = linkView;\n const targetCenter = targetBBox.center();\n return route[route.length - 1].difference(targetCenter).normalize();\n}\n\nfunction getSourceTangentDirection(linkView, route, direction, options) {\n if (options.sourceDirection) {\n switch (options.sourceDirection) {\n case TangentDirections.UP:\n return new Point(0, -1);\n case TangentDirections.DOWN:\n return new Point(0, 1);\n case TangentDirections.LEFT:\n return new Point(-1, 0);\n case TangentDirections.RIGHT:\n return new Point(1, 0);\n case TangentDirections.AUTO:\n return getAutoSourceDirection(linkView, route, options);\n case TangentDirections.CLOSEST_POINT:\n return getClosestPointSourceDirection(linkView, route, options);\n case TangentDirections.OUTWARDS:\n return getOutwardsSourceDirection(linkView, route, options);\n default:\n return options.sourceDirection;\n }\n }\n\n switch (direction) {\n case Directions.HORIZONTAL:\n return getHorizontalSourceDirection(linkView, route, options);\n case Directions.VERTICAL:\n return getVerticalSourceDirection(linkView, route, options);\n case Directions.CLOSEST_POINT:\n return getClosestPointSourceDirection(linkView, route, options);\n case Directions.OUTWARDS:\n return getOutwardsSourceDirection(linkView, route, options);\n case Directions.AUTO:\n default:\n return getAutoSourceDirection(linkView, route, options);\n }\n}\n\nfunction getTargetTangentDirection(linkView, route, direction, options) {\n if (options.targetDirection) {\n switch (options.targetDirection) {\n case TangentDirections.UP:\n return new Point(0, -1);\n case TangentDirections.DOWN:\n return new Point(0, 1);\n case TangentDirections.LEFT:\n return new Point(-1, 0);\n case TangentDirections.RIGHT:\n return new Point(1, 0);\n case TangentDirections.AUTO:\n return getAutoTargetDirection(linkView, route, options);\n case TangentDirections.CLOSEST_POINT:\n return getClosestPointTargetDirection(linkView, route, options);\n case TangentDirections.OUTWARDS:\n return getOutwardsTargetDirection(linkView, route, options);\n default:\n return options.targetDirection;\n }\n }\n\n switch (direction) {\n case Directions.HORIZONTAL:\n return getHorizontalTargetDirection(linkView, route, options);\n case Directions.VERTICAL:\n return getVerticalTargetDirection(linkView, route, options);\n case Directions.CLOSEST_POINT:\n return getClosestPointTargetDirection(linkView, route, options);\n case Directions.OUTWARDS:\n return getOutwardsTargetDirection(linkView, route, options);\n case Directions.AUTO:\n default:\n return getAutoTargetDirection(linkView, route, options);\n }\n}\n\nfunction rotateVector(vector, angle) {\n const cos = Math.cos(angle);\n const sin = Math.sin(angle);\n const x = cos * vector.x - sin * vector.y;\n const y = sin * vector.x + cos * vector.y;\n vector.x = x;\n vector.y = y;\n}\n\nfunction angleBetweenVectors(v1, v2) {\n let cos = v1.dot(v2) / (v1.magnitude() * v2.magnitude());\n if (cos < -1) cos = -1;\n if (cos > 1) cos = 1;\n return Math.acos(cos);\n}\n\nfunction determinant(v1, v2) {\n return v1.x * v2.y - v1.y * v2.x;\n}\n\nfunction createCatmullRomCurves(points, sourceTangent, targetTangent, options) {\n const { tau, coeff } = options;\n const distances = [];\n const tangents = [];\n const catmullRomCurves = [];\n const n = points.length - 1;\n\n for (let i = 0; i < n; i++) {\n distances[i] = points[i].distance(points[i + 1]);\n }\n\n tangents[0] = sourceTangent;\n tangents[n] = targetTangent;\n\n // The calculation of tangents of vertices\n for (let i = 1; i < n; i++) {\n let tpPrev;\n let tpNext;\n if (i === 1) {\n tpPrev = points[i - 1].clone().offset(tangents[i - 1].x, tangents[i - 1].y);\n } else {\n tpPrev = points[i - 1].clone();\n }\n if (i === n - 1) {\n tpNext = points[i + 1].clone().offset(tangents[i + 1].x, tangents[i + 1].y);\n } else {\n tpNext = points[i + 1].clone();\n }\n const v1 = tpPrev.difference(points[i]).normalize();\n const v2 = tpNext.difference(points[i]).normalize();\n const vAngle = angleBetweenVectors(v1, v2);\n\n let rot = (Math.PI - vAngle) / 2;\n let t;\n const vectorDeterminant = determinant(v1, v2);\n let pointsDeterminant;\n pointsDeterminant = determinant(points[i].difference(points[i + 1]), points[i].difference(points[i - 1]));\n if (vectorDeterminant < 0) {\n rot = -rot;\n }\n if ((vAngle < Math.PI / 2) && ((rot < 0 && pointsDeterminant < 0) || (rot > 0 && pointsDeterminant > 0))) {\n rot = rot - Math.PI;\n }\n t = v2.clone();\n rotateVector(t, rot);\n\n const t1 = t.clone();\n const t2 = t.clone();\n const scaleFactor1 = distances[i - 1] * coeff;\n const scaleFactor2 = distances[i] * coeff;\n t1.scale(scaleFactor1, scaleFactor1);\n t2.scale(scaleFactor2, scaleFactor2);\n\n tangents[i] = [t1, t2];\n }\n\n // The building of a Catmull-Rom curve based of tangents of points\n for (let i = 0; i < n; i++) {\n let p0;\n let p3;\n if (i === 0) {\n p0 = points[i + 1].difference(tangents[i].x / tau, tangents[i].y / tau);\n } else {\n p0 = points[i + 1].difference(tangents[i][1].x / tau, tangents[i][1].y / tau);\n }\n if (i === n - 1) {\n p3 = points[i].clone().offset(tangents[i + 1].x / tau, tangents[i + 1].y / tau);\n } else {\n p3 = points[i].difference(tangents[i + 1][0].x / tau, tangents[i + 1][0].y / tau);\n }\n\n catmullRomCurves[i] = [p0, points[i], points[i + 1], p3];\n }\n return catmullRomCurves;\n}\n\n// The function to convert Catmull-Rom curve to Bezier curve using the tension (tau)\nfunction catmullRomToBezier(points, options) {\n const { tau } = options;\n\n const bcp1 = new Point();\n bcp1.x = points[1].x + (points[2].x - points[0].x) / (6 * tau);\n bcp1.y = points[1].y + (points[2].y - points[0].y) / (6 * tau);\n\n const bcp2 = new Point();\n bcp2.x = points[2].x + (points[3].x - points[1].x) / (6 * tau);\n bcp2.y = points[2].y + (points[3].y - points[1].y) / (6 * tau);\n return new Curve(\n points[1],\n bcp1,\n bcp2,\n points[2]\n );\n}\n","import { CellView } from './CellView.mjs';\nimport { Link } from './Link.mjs';\nimport V from '../V/index.mjs';\nimport { addClassNamePrefix, merge, assign, isObject, isFunction, clone, isPercentage, result, isEqual } from '../util/index.mjs';\nimport { Point, Line, Path, normalizeAngle, Rect, Polyline, intersection } from '../g/index.mjs';\nimport * as routers from '../routers/index.mjs';\nimport * as connectors from '../connectors/index.mjs';\nimport { env } from '../env/index.mjs';\n\nconst Flags = {\n TOOLS: CellView.Flags.TOOLS,\n RENDER: 'RENDER',\n UPDATE: 'UPDATE',\n LABELS: 'LABELS',\n SOURCE: 'SOURCE',\n TARGET: 'TARGET',\n CONNECTOR: 'CONNECTOR'\n};\n\n// Link base view and controller.\n// ----------------------------------------\n\nexport const LinkView = CellView.extend({\n\n className: function() {\n\n var classNames = CellView.prototype.className.apply(this).split(' ');\n\n classNames.push('link');\n\n return classNames.join(' ');\n },\n\n _labelCache: null,\n _labelSelectors: null,\n _V: null,\n _dragData: null, // deprecated\n\n metrics: null,\n decimalsRounding: 2,\n\n initialize: function() {\n\n CellView.prototype.initialize.apply(this, arguments);\n\n // `_.labelCache` is a mapping of indexes of labels in the `this.get('labels')` array to\n // `<g class=\"label\">` nodes wrapped by Vectorizer. This allows for quick access to the\n // nodes in `updateLabelPosition()` in order to update the label positions.\n this._labelCache = {};\n\n // a cache of label selectors\n this._labelSelectors = {};\n\n // cache of default markup nodes\n this._V = {};\n\n // connection path metrics\n this.cleanNodesCache();\n },\n\n presentationAttributes: {\n markup: [Flags.RENDER],\n attrs: [Flags.UPDATE],\n router: [Flags.UPDATE],\n connector: [Flags.CONNECTOR],\n labels: [Flags.LABELS, Flags.TOOLS],\n labelMarkup: [Flags.LABELS],\n vertices: [Flags.UPDATE],\n source: [Flags.SOURCE, Flags.UPDATE],\n target: [Flags.TARGET, Flags.UPDATE]\n },\n\n initFlag: [Flags.RENDER, Flags.SOURCE, Flags.TARGET, Flags.TOOLS],\n\n UPDATE_PRIORITY: 1,\n EPSILON: 1e-6,\n\n confirmUpdate: function(flags, opt) {\n\n opt || (opt = {});\n\n if (this.hasFlag(flags, Flags.SOURCE)) {\n if (!this.updateEndProperties('source')) return flags;\n flags = this.removeFlag(flags, Flags.SOURCE);\n }\n\n if (this.hasFlag(flags, Flags.TARGET)) {\n if (!this.updateEndProperties('target')) return flags;\n flags = this.removeFlag(flags, Flags.TARGET);\n }\n\n const { paper, sourceView, targetView } = this;\n if (paper && ((sourceView && !paper.isViewMounted(sourceView)) || (targetView && !paper.isViewMounted(targetView)))) {\n // Wait for the sourceView and targetView to be rendered\n return flags;\n }\n\n if (this.hasFlag(flags, Flags.RENDER)) {\n this.render();\n this.updateHighlighters(true);\n this.updateTools(opt);\n flags = this.removeFlag(flags, [Flags.RENDER, Flags.UPDATE, Flags.LABELS, Flags.TOOLS, Flags.CONNECTOR]);\n\n if (env.test('isSafari')) {\n this.__fixSafariBug268376();\n }\n\n return flags;\n }\n\n let updateHighlighters = false;\n\n const { model } = this;\n const { attributes } = model;\n let updateLabels = this.hasFlag(flags, Flags.LABELS);\n\n if (updateLabels) {\n this.onLabelsChange(model, attributes.labels, opt);\n flags = this.removeFlag(flags, Flags.LABELS);\n updateHighlighters = true;\n }\n\n const updateAll = this.hasFlag(flags, Flags.UPDATE);\n const updateConnector = this.hasFlag(flags, Flags.CONNECTOR);\n if (updateAll || updateConnector) {\n if (!updateAll) {\n // Keep the current route and update the geometry\n this.updatePath();\n this.updateDOM();\n } else if (opt.translateBy && model.isRelationshipEmbeddedIn(opt.translateBy)) {\n // The link is being translated by an ancestor that will\n // shift source point, target point and all vertices\n // by an equal distance.\n this.translate(opt.tx, opt.ty);\n } else {\n this.update();\n }\n this.updateTools(opt);\n flags = this.removeFlag(flags, [Flags.UPDATE, Flags.TOOLS, Flags.CONNECTOR]);\n updateLabels = false;\n updateHighlighters = true;\n }\n\n if (updateLabels) {\n this.updateLabelPositions();\n }\n\n if (updateHighlighters) {\n this.updateHighlighters();\n }\n\n if (this.hasFlag(flags, Flags.TOOLS)) {\n this.updateTools(opt);\n flags = this.removeFlag(flags, Flags.TOOLS);\n }\n\n return flags;\n },\n\n __fixSafariBug268376: function() {\n // Safari has a bug where any change after the first render is not reflected in the DOM.\n // https://bugs.webkit.org/show_bug.cgi?id=268376\n const { el } = this;\n const childNodes = Array.from(el.childNodes);\n const fragment = document.createDocumentFragment();\n for (let i = 0, n = childNodes.length; i < n; i++) {\n el.removeChild(childNodes[i]);\n fragment.appendChild(childNodes[i]);\n }\n el.appendChild(fragment);\n },\n\n requestConnectionUpdate: function(opt) {\n this.requestUpdate(this.getFlag(Flags.UPDATE), opt);\n },\n\n isLabelsRenderRequired: function(opt = {}) {\n\n const previousLabels = this.model.previous('labels');\n if (!previousLabels) return true;\n\n // Here is an optimization for cases when we know, that change does\n // not require re-rendering of all labels.\n if (('propertyPathArray' in opt) && ('propertyValue' in opt)) {\n // The label is setting by `prop()` method\n var pathArray = opt.propertyPathArray || [];\n var pathLength = pathArray.length;\n if (pathLength > 1) {\n // We are changing a single label here e.g. 'labels/0/position'\n var labelExists = !!previousLabels[pathArray[1]];\n if (labelExists) {\n if (pathLength === 2) {\n // We are changing the entire label. Need to check if the\n // markup is also being changed.\n return ('markup' in Object(opt.propertyValue));\n } else if (pathArray[2] !== 'markup') {\n // We are changing a label property but not the markup\n return false;\n }\n }\n }\n }\n\n return true;\n },\n\n onLabelsChange: function(_link, _labels, opt) {\n\n // Note: this optimization works in async=false mode only\n if (this.isLabelsRenderRequired(opt)) {\n this.renderLabels();\n } else {\n this.updateLabels();\n }\n },\n\n // Rendering.\n // ----------\n\n render: function() {\n\n this.vel.empty();\n this.unmountLabels();\n this._V = {};\n this.renderMarkup();\n // rendering labels has to be run after the link is appended to DOM tree. (otherwise <Text> bbox\n // returns zero values)\n this.renderLabels();\n this.update();\n\n return this;\n },\n\n renderMarkup: function() {\n\n var link = this.model;\n var markup = link.get('markup') || link.markup;\n if (!markup) throw new Error('dia.LinkView: markup required');\n if (Array.isArray(markup)) return this.renderJSONMarkup(markup);\n if (typeof markup === 'string') return this.renderStringMarkup(markup);\n throw new Error('dia.LinkView: invalid markup');\n },\n\n renderJSONMarkup: function(markup) {\n\n var doc = this.parseDOMJSON(markup, this.el);\n // Selectors\n this.selectors = doc.selectors;\n // Fragment\n this.vel.append(doc.fragment);\n },\n\n renderStringMarkup: function(markup) {\n\n // A special markup can be given in the `properties.markup` property. This might be handy\n // if e.g. arrowhead markers should be `<image>` elements or any other element than `<path>`s.\n // `.connection`, `.connection-wrap`, `.marker-source` and `.marker-target` selectors\n // of elements with special meaning though. Therefore, those classes should be preserved in any\n // special markup passed in `properties.markup`.\n var children = V(markup);\n // custom markup may contain only one children\n if (!Array.isArray(children)) children = [children];\n\n this.vel.append(children);\n },\n\n _getLabelMarkup: function(labelMarkup) {\n\n if (!labelMarkup) return undefined;\n\n if (Array.isArray(labelMarkup)) return this.parseDOMJSON(labelMarkup, null);\n if (typeof labelMarkup === 'string') return this._getLabelStringMarkup(labelMarkup);\n throw new Error('dia.linkView: invalid label markup');\n },\n\n _getLabelStringMarkup: function(labelMarkup) {\n\n var children = V(labelMarkup);\n var fragment = document.createDocumentFragment();\n\n if (!Array.isArray(children)) {\n fragment.appendChild(children.node);\n\n } else {\n for (var i = 0, n = children.length; i < n; i++) {\n var currentChild = children[i].node;\n fragment.appendChild(currentChild);\n }\n }\n\n return { fragment: fragment, selectors: {}}; // no selectors\n },\n\n // Label markup fragment may come wrapped in <g class=\"label\" />, or not.\n // If it doesn't, add the <g /> container here.\n _normalizeLabelMarkup: function(markup) {\n\n if (!markup) return undefined;\n\n var fragment = markup.fragment;\n if (!(markup.fragment instanceof DocumentFragment) || !markup.fragment.hasChildNodes()) throw new Error('dia.LinkView: invalid label markup.');\n\n var vNode;\n var childNodes = fragment.childNodes;\n\n if ((childNodes.length > 1) || childNodes[0].nodeName.toUpperCase() !== 'G') {\n // default markup fragment is not wrapped in <g />\n // add a <g /> container\n vNode = V('g').append(fragment);\n } else {\n vNode = V(childNodes[0]);\n }\n\n vNode.addClass('label');\n\n return { node: vNode.node, selectors: markup.selectors };\n },\n\n renderLabels: function() {\n\n var cache = this._V;\n var vLabels = cache.labels;\n var labelCache = this._labelCache = {};\n var labelSelectors = this._labelSelectors = {};\n var model = this.model;\n var labels = model.attributes.labels || [];\n var labelsCount = labels.length;\n\n if (labelsCount === 0) {\n if (vLabels) vLabels.remove();\n return this;\n }\n\n if (vLabels) {\n vLabels.empty();\n } else {\n // there is no label container in the markup but some labels are defined\n // add a <g class=\"labels\" /> container\n vLabels = cache.labels = V('g').addClass('labels');\n if (this.options.labelsLayer) {\n vLabels.addClass(addClassNamePrefix(result(this, 'className')));\n vLabels.attr('model-id', model.id);\n }\n }\n\n for (var i = 0; i < labelsCount; i++) {\n\n var label = labels[i];\n var labelMarkup = this._normalizeLabelMarkup(this._getLabelMarkup(label.markup));\n var labelNode;\n var selectors;\n if (labelMarkup) {\n\n labelNode = labelMarkup.node;\n selectors = labelMarkup.selectors;\n\n } else {\n\n var builtinDefaultLabel = model._builtins.defaultLabel;\n var builtinDefaultLabelMarkup = this._normalizeLabelMarkup(this._getLabelMarkup(builtinDefaultLabel.markup));\n var defaultLabel = model._getDefaultLabel();\n var defaultLabelMarkup = this._normalizeLabelMarkup(this._getLabelMarkup(defaultLabel.markup));\n var defaultMarkup = defaultLabelMarkup || builtinDefaultLabelMarkup;\n\n labelNode = defaultMarkup.node;\n selectors = defaultMarkup.selectors;\n }\n\n labelNode.setAttribute('label-idx', i); // assign label-idx\n vLabels.append(labelNode);\n labelCache[i] = labelNode; // cache node for `updateLabels()` so it can just update label node positions\n\n var rootSelector = this.selector;\n if (selectors[rootSelector]) throw new Error('dia.LinkView: ambiguous label root selector.');\n selectors[rootSelector] = labelNode;\n\n labelSelectors[i] = selectors; // cache label selectors for `updateLabels()`\n }\n if (!vLabels.parent()) {\n this.mountLabels();\n }\n\n this.updateLabels();\n\n return this;\n },\n\n mountLabels: function() {\n const { el, paper, model, _V, options } = this;\n const { labels: vLabels } = _V;\n if (!vLabels || !model.hasLabels()) return;\n const { node } = vLabels;\n if (options.labelsLayer) {\n paper.getLayerView(options.labelsLayer).insertSortedNode(node, model.get('z'));\n } else {\n if (node.parentNode !== el) {\n el.appendChild(node);\n }\n }\n },\n\n unmountLabels: function() {\n const { options, _V } = this;\n if (!_V) return;\n const { labels: vLabels } = _V;\n if (vLabels && options.labelsLayer) {\n vLabels.remove();\n }\n },\n\n findLabelNodes: function(labelIndex, selector) {\n const labelRoot = this._labelCache[labelIndex];\n if (!labelRoot) return [];\n const labelSelectors = this._labelSelectors[labelIndex];\n return this.findBySelector(selector, labelRoot, labelSelectors);\n },\n\n findLabelNode: function(labelIndex, selector) {\n const [node = null] = this.findLabelNodes(labelIndex, selector);\n return node;\n },\n\n // merge default label attrs into label attrs (or use built-in default label attrs if neither is provided)\n // keep `undefined` or `null` because `{}` means something else\n _mergeLabelAttrs: function(hasCustomMarkup, labelAttrs, defaultLabelAttrs, builtinDefaultLabelAttrs) {\n\n if (labelAttrs === null) return null;\n if (labelAttrs === undefined) {\n\n if (defaultLabelAttrs === null) return null;\n if (defaultLabelAttrs === undefined) {\n\n if (hasCustomMarkup) return undefined;\n return builtinDefaultLabelAttrs;\n }\n\n if (hasCustomMarkup) return defaultLabelAttrs;\n return merge({}, builtinDefaultLabelAttrs, defaultLabelAttrs);\n }\n\n if (hasCustomMarkup) return merge({}, defaultLabelAttrs, labelAttrs);\n return merge({}, builtinDefaultLabelAttrs, defaultLabelAttrs, labelAttrs);\n },\n\n // merge default label size into label size (no built-in default)\n // keep `undefined` or `null` because `{}` means something else\n _mergeLabelSize: function(labelSize, defaultLabelSize) {\n\n if (labelSize === null) return null;\n if (labelSize === undefined) {\n\n if (defaultLabelSize === null) return null;\n if (defaultLabelSize === undefined) return undefined;\n\n return defaultLabelSize;\n }\n\n return merge({}, defaultLabelSize, labelSize);\n },\n\n updateLabels: function() {\n\n if (!this._V.labels) return this;\n\n if (!this.paper.options.labelLayer) {\n // If there is no label layer, the cache needs to be cleared\n // of the root node because the labels are attached\n // to it and could affect the bounding box.\n this.cleanNodeCache(this.el);\n }\n\n var model = this.model;\n var labels = model.get('labels') || [];\n var canLabelMove = this.can('labelMove');\n\n var builtinDefaultLabel = model._builtins.defaultLabel;\n var builtinDefaultLabelAttrs = builtinDefaultLabel.attrs;\n\n var defaultLabel = model._getDefaultLabel();\n var defaultLabelMarkup = defaultLabel.markup;\n var defaultLabelAttrs = defaultLabel.attrs;\n var defaultLabelSize = defaultLabel.size;\n\n for (var i = 0, n = labels.length; i < n; i++) {\n\n var labelNode = this._labelCache[i];\n labelNode.setAttribute('cursor', (canLabelMove ? 'move' : 'default'));\n\n var selectors = this._labelSelectors[i];\n\n var label = labels[i];\n var labelMarkup = label.markup;\n var labelAttrs = label.attrs;\n var labelSize = label.size;\n\n var attrs = this._mergeLabelAttrs(\n (labelMarkup || defaultLabelMarkup),\n labelAttrs,\n defaultLabelAttrs,\n builtinDefaultLabelAttrs\n );\n\n var size = this._mergeLabelSize(\n labelSize,\n defaultLabelSize\n );\n\n this.updateDOMSubtreeAttributes(labelNode, attrs, {\n rootBBox: new Rect(size),\n selectors: selectors\n });\n }\n\n return this;\n },\n\n // remove vertices that lie on (or nearly on) straight lines within the link\n // return the number of removed points\n removeRedundantLinearVertices: function(opt) {\n\n const SIMPLIFY_THRESHOLD = 0.001;\n\n const link = this.model;\n const vertices = link.vertices();\n const routePoints = [this.sourceAnchor, ...vertices, this.targetAnchor];\n const numRoutePoints = routePoints.length;\n\n // put routePoints into a polyline and try to simplify\n const polyline = new Polyline(routePoints);\n polyline.simplify({ threshold: SIMPLIFY_THRESHOLD });\n const polylinePoints = polyline.points.map((point) => (point.toJSON())); // JSON of points after simplification\n const numPolylinePoints = polylinePoints.length; // number of points after simplification\n\n // shortcut if simplification did not remove any redundant vertices:\n if (numRoutePoints === numPolylinePoints) return 0;\n\n // else: set simplified polyline points as link vertices\n // remove first and last polyline points again (= source/target anchors)\n link.vertices(polylinePoints.slice(1, numPolylinePoints - 1), opt);\n return (numRoutePoints - numPolylinePoints);\n },\n\n getEndView: function(type) {\n switch (type) {\n case 'source':\n return this.sourceView || null;\n case 'target':\n return this.targetView || null;\n default:\n throw new Error('dia.LinkView: type parameter required.');\n }\n },\n\n getEndAnchor: function(type) {\n switch (type) {\n case 'source':\n return new Point(this.sourceAnchor);\n case 'target':\n return new Point(this.targetAnchor);\n default:\n throw new Error('dia.LinkView: type parameter required.');\n }\n },\n\n getEndConnectionPoint: function(type) {\n switch (type) {\n case 'source':\n return new Point(this.sourcePoint);\n case 'target':\n return new Point(this.targetPoint);\n default:\n throw new Error('dia.LinkView: type parameter required.');\n }\n },\n\n getEndMagnet: function(type) {\n switch (type) {\n case 'source':\n var sourceView = this.sourceView;\n if (!sourceView) break;\n return this.sourceMagnet || sourceView.el;\n case 'target':\n var targetView = this.targetView;\n if (!targetView) break;\n return this.targetMagnet || targetView.el;\n default:\n throw new Error('dia.LinkView: type parameter required.');\n }\n return null;\n },\n\n\n // Updating.\n // ---------\n\n update: function() {\n this.updateRoute();\n this.updatePath();\n this.updateDOM();\n return this;\n },\n\n translate: function(tx = 0, ty = 0) {\n const { route, path } = this;\n if (!route || !path) return;\n // translate the route\n const polyline = new Polyline(route);\n polyline.translate(tx, ty);\n this.route = polyline.points;\n // translate source and target connection and anchor points.\n this.sourcePoint.offset(tx, ty);\n this.targetPoint.offset(tx, ty);\n this.sourceAnchor.offset(tx, ty);\n this.targetAnchor.offset(tx, ty);\n // translate the geometry path\n path.translate(tx, ty);\n this.updateDOM();\n },\n\n updateDOM() {\n const { el, model, selectors } = this;\n this.cleanNodesCache();\n // update SVG attributes defined by 'attrs/'.\n this.updateDOMSubtreeAttributes(el, model.attr(), { selectors });\n // update the label position etc.\n this.updateLabelPositions();\n // *Deprecated*\n // Local perpendicular flag (as opposed to one defined on paper).\n // Could be enabled inside a connector/router. It's valid only\n // during the update execution.\n this.options.perpendicular = null;\n },\n\n updateRoute: function() {\n const { model } = this;\n const vertices = model.vertices();\n // 1. Find Anchors\n const anchors = this.findAnchors(vertices);\n const sourceAnchor = this.sourceAnchor = anchors.source;\n const targetAnchor = this.targetAnchor = anchors.target;\n // 2. Find Route\n const route = this.findRoute(vertices);\n this.route = route;\n // 3. Find Connection Points\n var connectionPoints = this.findConnectionPoints(route, sourceAnchor, targetAnchor);\n this.sourcePoint = connectionPoints.source;\n this.targetPoint = connectionPoints.target;\n },\n\n updatePath: function() {\n const { route, sourcePoint, targetPoint } = this;\n // 4. Find Connection\n const path = this.findPath(route, sourcePoint.clone(), targetPoint.clone());\n this.path = path;\n },\n\n findAnchorsOrdered: function(firstEndType, firstRef, secondEndType, secondRef) {\n\n var firstAnchor, secondAnchor;\n var firstAnchorRef, secondAnchorRef;\n var model = this.model;\n var firstDef = model.get(firstEndType);\n var secondDef = model.get(secondEndType);\n var firstView = this.getEndView(firstEndType);\n var secondView = this.getEndView(secondEndType);\n var firstMagnet = this.getEndMagnet(firstEndType);\n var secondMagnet = this.getEndMagnet(secondEndType);\n\n // Anchor first\n if (firstView) {\n if (firstRef) {\n firstAnchorRef = new Point(firstRef);\n } else if (secondView) {\n firstAnchorRef = secondMagnet;\n } else {\n firstAnchorRef = new Point(secondDef);\n }\n firstAnchor = this.getAnchor(firstDef.anchor, firstView, firstMagnet, firstAnchorRef, firstEndType);\n } else {\n firstAnchor = new Point(firstDef);\n }\n\n // Anchor second\n if (secondView) {\n secondAnchorRef = new Point(secondRef || firstAnchor);\n secondAnchor = this.getAnchor(secondDef.anchor, secondView, secondMagnet, secondAnchorRef, secondEndType);\n } else {\n secondAnchor = new Point(secondDef);\n }\n\n var res = {};\n res[firstEndType] = firstAnchor;\n res[secondEndType] = secondAnchor;\n return res;\n },\n\n findAnchors: function(vertices) {\n\n var model = this.model;\n var firstVertex = vertices[0];\n var lastVertex = vertices[vertices.length - 1];\n\n if (model.target().priority && !model.source().priority) {\n // Reversed order\n return this.findAnchorsOrdered('target', lastVertex, 'source', firstVertex);\n }\n\n // Usual order\n return this.findAnchorsOrdered('source', firstVertex, 'target', lastVertex);\n },\n\n findConnectionPoints: function(route, sourceAnchor, targetAnchor) {\n\n var firstWaypoint = route[0];\n var lastWaypoint = route[route.length - 1];\n var model = this.model;\n var sourceDef = model.get('source');\n var targetDef = model.get('target');\n var sourceView = this.sourceView;\n var targetView = this.targetView;\n var paperOptions = this.paper.options;\n var sourceMagnet, targetMagnet;\n\n // Connection Point Source\n var sourcePoint;\n if (sourceView && !sourceView.isNodeConnection(this.sourceMagnet)) {\n sourceMagnet = (this.sourceMagnet || sourceView.el);\n var sourceConnectionPointDef = sourceDef.connectionPoint || paperOptions.defaultConnectionPoint;\n var sourcePointRef = firstWaypoint || targetAnchor;\n var sourceLine = new Line(sourcePointRef, sourceAnchor);\n sourcePoint = this.getConnectionPoint(\n sourceConnectionPointDef,\n sourceView,\n sourceMagnet,\n sourceLine,\n 'source'\n );\n } else {\n sourcePoint = sourceAnchor;\n }\n // Connection Point Target\n var targetPoint;\n if (targetView && !targetView.isNodeConnection(this.targetMagnet)) {\n targetMagnet = (this.targetMagnet || targetView.el);\n var targetConnectionPointDef = targetDef.connectionPoint || paperOptions.defaultConnectionPoint;\n var targetPointRef = lastWaypoint || sourceAnchor;\n var targetLine = new Line(targetPointRef, targetAnchor);\n targetPoint = this.getConnectionPoint(\n targetConnectionPointDef,\n targetView,\n targetMagnet,\n targetLine,\n 'target'\n );\n } else {\n targetPoint = targetAnchor;\n }\n\n return {\n source: sourcePoint,\n target: targetPoint\n };\n },\n\n getAnchor: function(anchorDef, cellView, magnet, ref, endType) {\n\n var isConnection = cellView.isNodeConnection(magnet);\n var paperOptions = this.paper.options;\n if (!anchorDef) {\n if (isConnection) {\n anchorDef = paperOptions.defaultLinkAnchor;\n } else {\n if (this.options.perpendicular) {\n // Backwards compatibility\n // See `manhattan` router for more details\n anchorDef = { name: 'perpendicular' };\n } else {\n anchorDef = paperOptions.defaultAnchor;\n }\n }\n }\n\n if (!anchorDef) throw new Error('Anchor required.');\n var anchorFn;\n if (typeof anchorDef === 'function') {\n anchorFn = anchorDef;\n } else {\n var anchorName = anchorDef.name;\n var anchorNamespace = isConnection ? 'linkAnchorNamespace' : 'anchorNamespace';\n anchorFn = paperOptions[anchorNamespace][anchorName];\n if (typeof anchorFn !== 'function') throw new Error('Unknown anchor: ' + anchorName);\n }\n var anchor = anchorFn.call(\n this,\n cellView,\n magnet,\n ref,\n anchorDef.args || {},\n endType,\n this\n );\n if (!anchor) return new Point();\n return anchor.round(this.decimalsRounding);\n },\n\n\n getConnectionPoint: function(connectionPointDef, view, magnet, line, endType) {\n\n var connectionPoint;\n var anchor = line.end;\n var paperOptions = this.paper.options;\n\n if (!connectionPointDef) return anchor;\n var connectionPointFn;\n if (typeof connectionPointDef === 'function') {\n connectionPointFn = connectionPointDef;\n } else {\n var connectionPointName = connectionPointDef.name;\n connectionPointFn = paperOptions.connectionPointNamespace[connectionPointName];\n if (typeof connectionPointFn !== 'function') throw new Error('Unknown connection point: ' + connectionPointName);\n }\n connectionPoint = connectionPointFn.call(this, line, view, magnet, connectionPointDef.args || {}, endType, this);\n if (!connectionPoint) return anchor;\n return connectionPoint.round(this.decimalsRounding);\n },\n\n isIntersecting: function(geometryShape, geometryData) {\n const connection = this.getConnection();\n if (!connection) return false;\n return intersection.exists(\n geometryShape,\n connection,\n geometryData,\n { segmentSubdivisions: this.getConnectionSubdivisions() },\n );\n },\n\n isEnclosedIn: function(geometryRect) {\n const connection = this.getConnection();\n if (!connection) return false;\n const bbox = connection.bbox();\n if (!bbox) return false;\n return geometryRect.containsRect(bbox);\n },\n\n isAtPoint: function(point /*, options */) {\n // Note: `strict` option is not applicable for links.\n // There is currently no method to determine if a path contains a point.\n const area = new Rect(point);\n // Intersection with a zero-size area is not possible.\n area.inflate(this.EPSILON);\n return this.isIntersecting(area);\n },\n\n // combine default label position with built-in default label position\n _getDefaultLabelPositionProperty: function() {\n\n var model = this.model;\n\n var builtinDefaultLabel = model._builtins.defaultLabel;\n var builtinDefaultLabelPosition = builtinDefaultLabel.position;\n\n var defaultLabel = model._getDefaultLabel();\n var defaultLabelPosition = this._normalizeLabelPosition(defaultLabel.position);\n\n return merge({}, builtinDefaultLabelPosition, defaultLabelPosition);\n },\n\n // if label position is a number, normalize it to a position object\n // this makes sure that label positions can be merged properly\n _normalizeLabelPosition: function(labelPosition) {\n\n if (typeof labelPosition === 'number') return { distance: labelPosition, offset: null, angle: 0, args: null };\n return labelPosition;\n },\n\n // expects normalized position properties\n // e.g. `this._normalizeLabelPosition(labelPosition)` and `this._getDefaultLabelPositionProperty()`\n _mergeLabelPositionProperty: function(normalizedLabelPosition, normalizedDefaultLabelPosition) {\n\n if (normalizedLabelPosition === null) return null;\n if (normalizedLabelPosition === undefined) {\n\n if (normalizedDefaultLabelPosition === null) return null;\n return normalizedDefaultLabelPosition;\n }\n\n return merge({}, normalizedDefaultLabelPosition, normalizedLabelPosition);\n },\n\n updateLabelPositions: function() {\n\n if (!this._V.labels) return this;\n\n var path = this.path;\n if (!path) return this;\n\n // This method assumes all the label nodes are stored in the `this._labelCache` hash table\n // by their indices in the `this.get('labels')` array. This is done in the `renderLabels()` method.\n\n var model = this.model;\n var labels = model.get('labels') || [];\n if (!labels.length) return this;\n\n var defaultLabelPosition = this._getDefaultLabelPositionProperty();\n\n for (var idx = 0, n = labels.length; idx < n; idx++) {\n var labelNode = this._labelCache[idx];\n if (!labelNode) continue;\n var label = labels[idx];\n var labelPosition = this._normalizeLabelPosition(label.position);\n var position = this._mergeLabelPositionProperty(labelPosition, defaultLabelPosition);\n var transformationMatrix = this._getLabelTransformationMatrix(position);\n labelNode.setAttribute('transform', V.matrixToTransformString(transformationMatrix));\n this._cleanLabelMatrices(idx);\n }\n\n return this;\n },\n\n _cleanLabelMatrices: function(index) {\n // Clean magnetMatrix for all nodes of the label.\n // Cached BoundingRect does not need to updated when the position changes\n // TODO: this doesn't work for labels with XML String markups.\n const { metrics, _labelSelectors } = this;\n const selectors = _labelSelectors[index];\n if (!selectors) return;\n for (let selector in selectors) {\n const { id } = selectors[selector];\n if (id && (id in metrics)) delete metrics[id].magnetMatrix;\n }\n },\n\n updateEndProperties: function(endType) {\n\n const { model, paper } = this;\n const endViewProperty = `${endType}View`;\n const endDef = model.get(endType);\n const endId = endDef && endDef.id;\n\n if (!endId) {\n // the link end is a point ~ rect 0x0\n this[endViewProperty] = null;\n this.updateEndMagnet(endType);\n return true;\n }\n\n const endModel = paper.getModelById(endId);\n if (!endModel) throw new Error('LinkView: invalid ' + endType + ' cell.');\n\n const endView = endModel.findView(paper);\n if (!endView) {\n // A view for a model should always exist\n return false;\n }\n\n this[endViewProperty] = endView;\n this.updateEndMagnet(endType);\n return true;\n },\n\n updateEndMagnet: function(endType) {\n\n const endMagnetProperty = `${endType}Magnet`;\n const endView = this.getEndView(endType);\n if (endView) {\n let connectedMagnet = endView.getMagnetFromLinkEnd(this.model.get(endType));\n if (connectedMagnet === endView.el) connectedMagnet = null;\n this[endMagnetProperty] = connectedMagnet;\n } else {\n this[endMagnetProperty] = null;\n }\n },\n\n _getLabelPositionProperty: function(idx) {\n\n return (this.model.label(idx).position || {});\n },\n\n _getLabelPositionAngle: function(idx) {\n\n var labelPosition = this._getLabelPositionProperty(idx);\n return (labelPosition.angle || 0);\n },\n\n _getLabelPositionArgs: function(idx) {\n\n var labelPosition = this._getLabelPositionProperty(idx);\n return labelPosition.args;\n },\n\n _getDefaultLabelPositionArgs: function() {\n\n var defaultLabel = this.model._getDefaultLabel();\n var defaultLabelPosition = defaultLabel.position || {};\n return defaultLabelPosition.args;\n },\n\n // merge default label position args into label position args\n // keep `undefined` or `null` because `{}` means something else\n _mergeLabelPositionArgs: function(labelPositionArgs, defaultLabelPositionArgs) {\n\n if (labelPositionArgs === null) return null;\n if (labelPositionArgs === undefined) {\n\n if (defaultLabelPositionArgs === null) return null;\n return defaultLabelPositionArgs;\n }\n\n return merge({}, defaultLabelPositionArgs, labelPositionArgs);\n },\n\n // Add default label at given position at end of `labels` array.\n // Four signatures:\n // - obj, obj = point, opt\n // - obj, num, obj = point, angle, opt\n // - num, num, obj = x, y, opt\n // - num, num, num, obj = x, y, angle, opt\n // Assigns relative coordinates by default:\n // `opt.absoluteDistance` forces absolute coordinates.\n // `opt.reverseDistance` forces reverse absolute coordinates (if absoluteDistance = true).\n // `opt.absoluteOffset` forces absolute coordinates for offset.\n // Additional args:\n // `opt.keepGradient` auto-adjusts the angle of the label to match path gradient at position.\n // `opt.ensureLegibility` rotates labels so they are never upside-down.\n addLabel: function(p1, p2, p3, p4) {\n\n // normalize data from the four possible signatures\n var localX;\n var localY;\n var localAngle = 0;\n var localOpt;\n if (typeof p1 !== 'number') {\n // {x, y} object provided as first parameter\n localX = p1.x;\n localY = p1.y;\n if (typeof p2 === 'number') {\n // angle and opt provided as second and third parameters\n localAngle = p2;\n localOpt = p3;\n } else {\n // opt provided as second parameter\n localOpt = p2;\n }\n } else {\n // x and y provided as first and second parameters\n localX = p1;\n localY = p2;\n if (typeof p3 === 'number') {\n // angle and opt provided as third and fourth parameters\n localAngle = p3;\n localOpt = p4;\n } else {\n // opt provided as third parameter\n localOpt = p3;\n }\n }\n\n // merge label position arguments\n var defaultLabelPositionArgs = this._getDefaultLabelPositionArgs();\n var labelPositionArgs = localOpt;\n var positionArgs = this._mergeLabelPositionArgs(labelPositionArgs, defaultLabelPositionArgs);\n\n // append label to labels array\n var label = { position: this.getLabelPosition(localX, localY, localAngle, positionArgs) };\n var idx = -1;\n this.model.insertLabel(idx, label, localOpt);\n return idx;\n },\n\n // Add a new vertex at calculated index to the `vertices` array.\n addVertex: function(x, y, opt) {\n\n // accept input in form `{ x, y }, opt` or `x, y, opt`\n var isPointProvided = (typeof x !== 'number');\n var localX = isPointProvided ? x.x : x;\n var localY = isPointProvided ? x.y : y;\n var localOpt = isPointProvided ? y : opt;\n\n var vertex = { x: localX, y: localY };\n var idx = this.getVertexIndex(localX, localY);\n this.model.insertVertex(idx, vertex, localOpt);\n return idx;\n },\n\n // Send a token (an SVG element, usually a circle) along the connection path.\n // Example: `link.findView(paper).sendToken(V('circle', { r: 7, fill: 'green' }).node)`\n // `opt.duration` is optional and is a time in milliseconds that the token travels from the source to the target of the link. Default is `1000`.\n // `opt.direction` is optional and it determines whether the token goes from source to target or other way round (`reverse`)\n // `opt.connection` is an optional selector to the connection path.\n // `callback` is optional and is a function to be called once the token reaches the target.\n sendToken: function(token, opt, callback) {\n\n function onAnimationEnd(vToken, callback) {\n return function() {\n vToken.remove();\n if (typeof callback === 'function') {\n callback();\n }\n };\n }\n\n var duration, isReversed, selector;\n if (isObject(opt)) {\n duration = opt.duration;\n isReversed = (opt.direction === 'reverse');\n selector = opt.connection;\n } else {\n // Backwards compatibility\n duration = opt;\n isReversed = false;\n selector = null;\n }\n\n duration = duration || 1000;\n\n var animationAttributes = {\n dur: duration + 'ms',\n repeatCount: 1,\n calcMode: 'linear',\n fill: 'freeze'\n };\n\n if (isReversed) {\n animationAttributes.keyPoints = '1;0';\n animationAttributes.keyTimes = '0;1';\n }\n\n var vToken = V(token);\n var connection;\n if (typeof selector === 'string') {\n // Use custom connection path.\n connection = this.findNode(selector);\n } else {\n // Select connection path automatically.\n var cache = this._V;\n connection = (cache.connection) ? cache.connection.node : this.el.querySelector('path');\n }\n\n if (!(connection instanceof SVGPathElement)) {\n throw new Error('dia.LinkView: token animation requires a valid connection path.');\n }\n\n vToken\n .appendTo(this.paper.cells)\n .animateAlongPath(animationAttributes, connection);\n\n setTimeout(onAnimationEnd(vToken, callback), duration);\n },\n\n findRoute: function(vertices) {\n\n vertices || (vertices = []);\n\n var namespace = this.paper.options.routerNamespace || routers;\n var router = this.model.router();\n var defaultRouter = this.paper.options.defaultRouter;\n\n if (!router) {\n if (defaultRouter) router = defaultRouter;\n else return vertices.map(Point); // no router specified\n }\n\n var routerFn = isFunction(router) ? router : namespace[router.name];\n if (!isFunction(routerFn)) {\n throw new Error('dia.LinkView: unknown router: \"' + router.name + '\".');\n }\n\n var args = router.args || {};\n\n var route = routerFn.call(\n this, // context\n vertices, // vertices\n args, // options\n this // linkView\n );\n\n if (!route) return vertices.map(Point);\n return route;\n },\n\n // Return the `d` attribute value of the `<path>` element representing the link\n // between `source` and `target`.\n findPath: function(route, sourcePoint, targetPoint) {\n\n var namespace = this.paper.options.connectorNamespace || connectors;\n var connector = this.model.connector();\n var defaultConnector = this.paper.options.defaultConnector;\n\n if (!connector) {\n connector = defaultConnector || {};\n }\n\n var connectorFn = isFunction(connector) ? connector : namespace[connector.name];\n if (!isFunction(connectorFn)) {\n throw new Error('dia.LinkView: unknown connector: \"' + connector.name + '\".');\n }\n\n var args = clone(connector.args || {});\n args.raw = true; // Request raw g.Path as the result.\n\n var path = connectorFn.call(\n this, // context\n sourcePoint, // start point\n targetPoint, // end point\n route, // vertices\n args, // options\n this // linkView\n );\n\n if (typeof path === 'string') {\n // Backwards compatibility for connectors not supporting `raw` option.\n path = new Path(V.normalizePathData(path));\n }\n\n return path;\n },\n\n // Public API.\n // -----------\n\n getConnection: function() {\n\n var path = this.path;\n if (!path) return null;\n\n return path.clone();\n },\n\n getSerializedConnection: function() {\n\n var path = this.path;\n if (!path) return null;\n\n var metrics = this.metrics;\n if (metrics.hasOwnProperty('data')) return metrics.data;\n var data = path.serialize();\n metrics.data = data;\n return data;\n },\n\n getConnectionSubdivisions: function() {\n\n var path = this.path;\n if (!path) return null;\n\n var metrics = this.metrics;\n if (metrics.hasOwnProperty('segmentSubdivisions')) return metrics.segmentSubdivisions;\n var subdivisions = path.getSegmentSubdivisions();\n metrics.segmentSubdivisions = subdivisions;\n return subdivisions;\n },\n\n getConnectionLength: function() {\n\n var path = this.path;\n if (!path) return 0;\n\n var metrics = this.metrics;\n if (metrics.hasOwnProperty('length')) return metrics.length;\n var length = path.length({ segmentSubdivisions: this.getConnectionSubdivisions() });\n metrics.length = length;\n return length;\n },\n\n getPointAtLength: function(length) {\n\n var path = this.path;\n if (!path) return null;\n\n return path.pointAtLength(length, { segmentSubdivisions: this.getConnectionSubdivisions() });\n },\n\n getPointAtRatio: function(ratio) {\n\n var path = this.path;\n if (!path) return null;\n if (isPercentage(ratio)) ratio = parseFloat(ratio) / 100;\n return path.pointAt(ratio, { segmentSubdivisions: this.getConnectionSubdivisions() });\n },\n\n getTangentAtLength: function(length) {\n\n var path = this.path;\n if (!path) return null;\n\n return path.tangentAtLength(length, { segmentSubdivisions: this.getConnectionSubdivisions() });\n },\n\n getTangentAtRatio: function(ratio) {\n\n var path = this.path;\n if (!path) return null;\n\n return path.tangentAt(ratio, { segmentSubdivisions: this.getConnectionSubdivisions() });\n },\n\n getClosestPoint: function(point) {\n\n var path = this.path;\n if (!path) return null;\n\n return path.closestPoint(point, { segmentSubdivisions: this.getConnectionSubdivisions() });\n },\n\n getClosestPointLength: function(point) {\n\n var path = this.path;\n if (!path) return null;\n\n return path.closestPointLength(point, { segmentSubdivisions: this.getConnectionSubdivisions() });\n },\n\n getClosestPointRatio: function(point) {\n\n var path = this.path;\n if (!path) return null;\n\n return path.closestPointNormalizedLength(point, { segmentSubdivisions: this.getConnectionSubdivisions() });\n },\n\n // Get label position object based on two provided coordinates, x and y.\n // (Used behind the scenes when user moves labels around.)\n // Two signatures:\n // - num, num, obj = x, y, options\n // - num, num, num, obj = x, y, angle, options\n // Accepts distance/offset options = `absoluteDistance: boolean`, `reverseDistance: boolean`, `absoluteOffset: boolean`\n // - `absoluteOffset` is necessary in order to move beyond connection endpoints\n // Additional options = `keepGradient: boolean`, `ensureLegibility: boolean`\n getLabelPosition: function(x, y, p3, p4) {\n\n var position = {};\n\n // normalize data from the two possible signatures\n var localAngle = 0;\n var localOpt;\n if (typeof p3 === 'number') {\n // angle and opt provided as third and fourth argument\n localAngle = p3;\n localOpt = p4;\n } else {\n // opt provided as third argument\n localOpt = p3;\n }\n\n // save localOpt as `args` of the position object that is passed along\n if (localOpt) position.args = localOpt;\n\n // identify distance/offset settings\n var isDistanceRelative = !(localOpt && localOpt.absoluteDistance); // relative by default\n var isDistanceAbsoluteReverse = (localOpt && localOpt.absoluteDistance && localOpt.reverseDistance); // non-reverse by default\n var isOffsetAbsolute = localOpt && localOpt.absoluteOffset; // offset is non-absolute by default\n\n // find closest point t\n var path = this.path;\n var pathOpt = { segmentSubdivisions: this.getConnectionSubdivisions() };\n var labelPoint = new Point(x, y);\n var t = path.closestPointT(labelPoint, pathOpt);\n\n // DISTANCE:\n var labelDistance = path.lengthAtT(t, pathOpt);\n if (isDistanceRelative) labelDistance = (labelDistance / this.getConnectionLength()) || 0; // fix to prevent NaN for 0 length\n if (isDistanceAbsoluteReverse) labelDistance = (-1 * (this.getConnectionLength() - labelDistance)) || 1; // fix for end point (-0 => 1)\n position.distance = labelDistance;\n\n // OFFSET:\n // use absolute offset if:\n // - opt.absoluteOffset is true,\n // - opt.absoluteOffset is not true but there is no tangent\n var tangent;\n if (!isOffsetAbsolute) tangent = path.tangentAtT(t);\n var labelOffset;\n if (tangent) {\n labelOffset = tangent.pointOffset(labelPoint);\n } else {\n var closestPoint = path.pointAtT(t);\n var labelOffsetDiff = labelPoint.difference(closestPoint);\n labelOffset = { x: labelOffsetDiff.x, y: labelOffsetDiff.y };\n }\n position.offset = labelOffset;\n\n // ANGLE:\n position.angle = localAngle;\n\n return position;\n },\n\n _getLabelTransformationMatrix: function(labelPosition) {\n\n var labelDistance;\n var labelAngle = 0;\n var args = {};\n if (typeof labelPosition === 'number') {\n labelDistance = labelPosition;\n } else if (typeof labelPosition.distance === 'number') {\n args = labelPosition.args || {};\n labelDistance = labelPosition.distance;\n labelAngle = labelPosition.angle || 0;\n } else {\n throw new Error('dia.LinkView: invalid label position distance.');\n }\n\n var isDistanceRelative = ((labelDistance > 0) && (labelDistance <= 1));\n\n var labelOffset = 0;\n var labelOffsetCoordinates = { x: 0, y: 0 };\n if (labelPosition.offset) {\n var positionOffset = labelPosition.offset;\n if (typeof positionOffset === 'number') labelOffset = positionOffset;\n if (positionOffset.x) labelOffsetCoordinates.x = positionOffset.x;\n if (positionOffset.y) labelOffsetCoordinates.y = positionOffset.y;\n }\n\n var isOffsetAbsolute = ((labelOffsetCoordinates.x !== 0) || (labelOffsetCoordinates.y !== 0) || labelOffset === 0);\n\n var isKeepGradient = args.keepGradient;\n var isEnsureLegibility = args.ensureLegibility;\n\n var path = this.path;\n var pathOpt = { segmentSubdivisions: this.getConnectionSubdivisions() };\n\n var distance = isDistanceRelative ? (labelDistance * this.getConnectionLength()) : labelDistance;\n var tangent = path.tangentAtLength(distance, pathOpt);\n\n var translation;\n var angle = labelAngle;\n if (tangent) {\n if (isOffsetAbsolute) {\n translation = tangent.start.clone();\n translation.offset(labelOffsetCoordinates);\n } else {\n var normal = tangent.clone();\n normal.rotate(tangent.start, -90);\n normal.setLength(labelOffset);\n translation = normal.end;\n }\n\n if (isKeepGradient) {\n angle = (tangent.angle() + labelAngle);\n if (isEnsureLegibility) {\n angle = normalizeAngle(((angle + 90) % 180) - 90);\n }\n }\n\n } else {\n // fallback - the connection has zero length\n translation = path.start.clone();\n if (isOffsetAbsolute) translation.offset(labelOffsetCoordinates);\n }\n\n return V.createSVGMatrix()\n .translate(translation.x, translation.y)\n .rotate(angle);\n },\n\n getLabelCoordinates: function(labelPosition) {\n\n var transformationMatrix = this._getLabelTransformationMatrix(labelPosition);\n return new Point(transformationMatrix.e, transformationMatrix.f);\n },\n\n getVertexIndex: function(x, y) {\n\n var model = this.model;\n var vertices = model.vertices();\n\n var vertexLength = this.getClosestPointLength(new Point(x, y));\n\n var idx = 0;\n for (var n = vertices.length; idx < n; idx++) {\n var currentVertex = vertices[idx];\n var currentVertexLength = this.getClosestPointLength(currentVertex);\n if (vertexLength < currentVertexLength) break;\n }\n\n return idx;\n },\n\n // Interaction. The controller part.\n // ---------------------------------\n\n notifyPointerdown(evt, x, y) {\n CellView.prototype.pointerdown.call(this, evt, x, y);\n this.notify('link:pointerdown', evt, x, y);\n },\n\n notifyPointermove(evt, x, y) {\n CellView.prototype.pointermove.call(this, evt, x, y);\n this.notify('link:pointermove', evt, x, y);\n },\n\n notifyPointerup(evt, x, y) {\n this.notify('link:pointerup', evt, x, y);\n CellView.prototype.pointerup.call(this, evt, x, y);\n },\n\n pointerdblclick: function(evt, x, y) {\n\n CellView.prototype.pointerdblclick.apply(this, arguments);\n this.notify('link:pointerdblclick', evt, x, y);\n },\n\n pointerclick: function(evt, x, y) {\n\n CellView.prototype.pointerclick.apply(this, arguments);\n this.notify('link:pointerclick', evt, x, y);\n },\n\n contextmenu: function(evt, x, y) {\n\n CellView.prototype.contextmenu.apply(this, arguments);\n this.notify('link:contextmenu', evt, x, y);\n },\n\n pointerdown: function(evt, x, y) {\n\n this.notifyPointerdown(evt, x, y);\n this.dragStart(evt, x, y);\n },\n\n pointermove: function(evt, x, y) {\n\n // Backwards compatibility\n var dragData = this._dragData;\n if (dragData) this.eventData(evt, dragData);\n\n var data = this.eventData(evt);\n switch (data.action) {\n\n case 'label-move':\n this.dragLabel(evt, x, y);\n break;\n\n case 'arrowhead-move':\n this.dragArrowhead(evt, x, y);\n break;\n\n case 'move':\n this.drag(evt, x, y);\n break;\n }\n\n // Backwards compatibility\n if (dragData) assign(dragData, this.eventData(evt));\n\n this.notifyPointermove(evt, x, y);\n },\n\n pointerup: function(evt, x, y) {\n\n // Backwards compatibility\n var dragData = this._dragData;\n if (dragData) {\n this.eventData(evt, dragData);\n this._dragData = null;\n }\n\n var data = this.eventData(evt);\n switch (data.action) {\n\n case 'label-move':\n this.dragLabelEnd(evt, x, y);\n break;\n\n case 'arrowhead-move':\n this.dragArrowheadEnd(evt, x, y);\n break;\n\n case 'move':\n this.dragEnd(evt, x, y);\n }\n\n this.notifyPointerup(evt, x, y);\n this.checkMouseleave(evt);\n },\n\n mouseover: function(evt) {\n\n CellView.prototype.mouseover.apply(this, arguments);\n this.notify('link:mouseover', evt);\n },\n\n mouseout: function(evt) {\n\n CellView.prototype.mouseout.apply(this, arguments);\n this.notify('link:mouseout', evt);\n },\n\n mouseenter: function(evt) {\n\n CellView.prototype.mouseenter.apply(this, arguments);\n this.notify('link:mouseenter', evt);\n },\n\n mouseleave: function(evt) {\n\n CellView.prototype.mouseleave.apply(this, arguments);\n this.notify('link:mouseleave', evt);\n },\n\n mousewheel: function(evt, x, y, delta) {\n\n CellView.prototype.mousewheel.apply(this, arguments);\n this.notify('link:mousewheel', evt, x, y, delta);\n },\n\n onlabel: function(evt, x, y) {\n\n this.notifyPointerdown(evt, x, y);\n\n this.dragLabelStart(evt, x, y);\n\n var stopPropagation = this.eventData(evt).stopPropagation;\n if (stopPropagation) evt.stopPropagation();\n },\n\n // Drag Start Handlers\n\n dragLabelStart: function(evt, x, y) {\n\n if (this.can('labelMove')) {\n\n if (this.isDefaultInteractionPrevented(evt)) return;\n\n var labelNode = evt.currentTarget;\n var labelIdx = parseInt(labelNode.getAttribute('label-idx'), 10);\n\n var defaultLabelPosition = this._getDefaultLabelPositionProperty();\n var initialLabelPosition = this._normalizeLabelPosition(this._getLabelPositionProperty(labelIdx));\n var position = this._mergeLabelPositionProperty(initialLabelPosition, defaultLabelPosition);\n\n var coords = this.getLabelCoordinates(position);\n var dx = coords.x - x; // how much needs to be added to cursor x to get to label x\n var dy = coords.y - y; // how much needs to be added to cursor y to get to label y\n\n var positionAngle = this._getLabelPositionAngle(labelIdx);\n var labelPositionArgs = this._getLabelPositionArgs(labelIdx);\n var defaultLabelPositionArgs = this._getDefaultLabelPositionArgs();\n var positionArgs = this._mergeLabelPositionArgs(labelPositionArgs, defaultLabelPositionArgs);\n\n this.eventData(evt, {\n action: 'label-move',\n labelIdx: labelIdx,\n dx: dx,\n dy: dy,\n positionAngle: positionAngle,\n positionArgs: positionArgs,\n stopPropagation: true\n });\n\n } else {\n\n // Backwards compatibility:\n // If labels can't be dragged no default action is triggered.\n this.eventData(evt, { stopPropagation: true });\n }\n\n this.paper.delegateDragEvents(this, evt.data);\n },\n\n dragArrowheadStart: function(evt, x, y) {\n\n if (!this.can('arrowheadMove')) return;\n\n var arrowheadNode = evt.target;\n var arrowheadType = arrowheadNode.getAttribute('end');\n var data = this.startArrowheadMove(arrowheadType, { ignoreBackwardsCompatibility: true });\n\n this.eventData(evt, data);\n },\n\n dragStart: function(evt, x, y) {\n\n if (this.isDefaultInteractionPrevented(evt)) return;\n\n if (!this.can('linkMove')) return;\n\n this.eventData(evt, {\n action: 'move',\n dx: x,\n dy: y\n });\n },\n\n // Drag Handlers\n dragLabel: function(evt, x, y) {\n\n var data = this.eventData(evt);\n var label = { position: this.getLabelPosition((x + data.dx), (y + data.dy), data.positionAngle, data.positionArgs) };\n if (this.paper.options.snapLabels) delete label.position.offset;\n // The `touchmove' events are not fired\n // when the original event target is removed from the DOM.\n // The labels are currently re-rendered completely when only\n // the position changes. This is why we need to make sure that\n // the label is updated synchronously.\n // TODO: replace `touchmove` with `pointermove` (breaking change).\n const setOptions = { ui: true };\n if (this.paper.isAsync() && evt.type === 'touchmove') {\n setOptions.async = false;\n }\n this.model.label(data.labelIdx, label, setOptions);\n },\n\n dragArrowhead: function(evt, x, y) {\n if (this.paper.options.snapLinks) {\n const isSnapped = this._snapArrowhead(evt, x, y);\n if (!isSnapped && this.paper.options.snapLinksSelf) {\n this._snapArrowheadSelf(evt, x, y);\n }\n } else {\n if (this.paper.options.snapLinksSelf) {\n this._snapArrowheadSelf(evt, x, y);\n } else {\n this._connectArrowhead(this.getEventTarget(evt), x, y, this.eventData(evt));\n }\n }\n },\n\n drag: function(evt, x, y) {\n\n var data = this.eventData(evt);\n this.model.translate(x - data.dx, y - data.dy, { ui: true });\n this.eventData(evt, {\n dx: x,\n dy: y\n });\n },\n\n // Drag End Handlers\n\n dragLabelEnd: function() {\n // noop\n },\n\n dragArrowheadEnd: function(evt, x, y) {\n\n var data = this.eventData(evt);\n var paper = this.paper;\n\n if (paper.options.snapLinks) {\n this._snapArrowheadEnd(data);\n } else {\n this._connectArrowheadEnd(data, x, y);\n }\n\n if (!paper.linkAllowed(this)) {\n // If the changed link is not allowed, revert to its previous state.\n this._disallow(data);\n } else {\n this._finishEmbedding(data);\n this._notifyConnectEvent(data, evt);\n }\n\n this._afterArrowheadMove(data);\n },\n\n dragEnd: function() {\n // noop\n },\n\n _disallow: function(data) {\n\n switch (data.whenNotAllowed) {\n\n case 'remove':\n this.model.remove({ ui: true });\n break;\n\n case 'revert':\n default:\n this.model.set(data.arrowhead, data.initialEnd, { ui: true });\n break;\n }\n },\n\n _finishEmbedding: function(data) {\n\n // Reparent the link if embedding is enabled\n if (this.paper.options.embeddingMode && this.model.reparent()) {\n // Make sure we don't reverse to the original 'z' index (see afterArrowheadMove()).\n data.z = null;\n }\n },\n\n _notifyConnectEvent: function(data, evt) {\n\n var arrowhead = data.arrowhead;\n var initialEnd = data.initialEnd;\n var currentEnd = this.model.prop(arrowhead);\n var endChanged = currentEnd && !Link.endsEqual(initialEnd, currentEnd);\n if (endChanged) {\n var paper = this.paper;\n if (initialEnd.id) {\n this.notify('link:disconnect', evt, paper.findViewByModel(initialEnd.id), data.initialMagnet, arrowhead);\n }\n if (currentEnd.id) {\n this.notify('link:connect', evt, paper.findViewByModel(currentEnd.id), data.magnetUnderPointer, arrowhead);\n }\n }\n },\n\n _snapToPoints: function(snapPoint, points, radius) {\n let closestPointX = null;\n let closestDistanceX = Infinity;\n\n let closestPointY = null;\n let closestDistanceY = Infinity;\n\n let x = snapPoint.x;\n let y = snapPoint.y;\n\n for (let i = 0; i < points.length; i++) {\n const distX = Math.abs(points[i].x - snapPoint.x);\n if (distX < closestDistanceX) {\n closestDistanceX = distX;\n closestPointX = points[i];\n }\n\n const distY = Math.abs(points[i].y - snapPoint.y);\n if (distY < closestDistanceY) {\n closestDistanceY = distY;\n closestPointY = points[i];\n }\n }\n\n if (closestDistanceX < radius) {\n x = closestPointX.x;\n }\n if (closestDistanceY < radius) {\n y = closestPointY.y;\n }\n\n return { x, y };\n },\n\n _snapArrowheadSelf: function(evt, x, y) {\n\n const { paper, model } = this;\n const { snapLinksSelf } = paper.options;\n const data = this.eventData(evt);\n const radius = snapLinksSelf.radius || 20;\n\n const anchor = this.getEndAnchor(data.arrowhead === 'source' ? 'target' : 'source');\n const vertices = model.vertices();\n const points = [anchor, ...vertices];\n\n const snapPoint = this._snapToPoints({ x: x, y: y }, points, radius);\n\n const point = paper.localToClientPoint(snapPoint);\n this._connectArrowhead(document.elementFromPoint(point.x, point.y), snapPoint.x, snapPoint.y, this.eventData(evt));\n },\n\n _snapArrowhead: function(evt, x, y) {\n\n const { paper } = this;\n const { snapLinks, connectionStrategy } = paper.options;\n const data = this.eventData(evt);\n let isSnapped = false;\n // checking view in close area of the pointer\n\n var r = snapLinks.radius || 50;\n var viewsInArea = paper.findElementViewsInArea(\n { x: x - r, y: y - r, width: 2 * r, height: 2 * r },\n snapLinks.findInAreaOptions\n );\n\n var prevClosestView = data.closestView || null;\n var prevClosestMagnet = data.closestMagnet || null;\n var prevMagnetProxy = data.magnetProxy || null;\n\n data.closestView = data.closestMagnet = data.magnetProxy = null;\n\n var minDistance = Number.MAX_VALUE;\n var pointer = new Point(x, y);\n\n viewsInArea.forEach(function(view) {\n const candidates = [];\n // skip connecting to the element in case '.': { magnet: false } attribute present\n if (view.el.getAttribute('magnet') !== 'false') {\n candidates.push({\n bbox: view.model.getBBox(),\n magnet: view.el\n });\n }\n\n view.$('[magnet]').toArray().forEach(magnet => {\n candidates.push({\n bbox: view.getNodeBBox(magnet),\n magnet\n });\n });\n\n candidates.forEach(candidate => {\n const { magnet, bbox } = candidate;\n // find distance from the center of the model to pointer coordinates\n const distance = bbox.center().squaredDistance(pointer);\n // the connection is looked up in a circle area by `distance < r`\n if (distance < minDistance) {\n const isAlreadyValidated = prevClosestMagnet === magnet;\n if (isAlreadyValidated || paper.options.validateConnection.apply(\n paper, data.validateConnectionArgs(view, (view.el === magnet) ? null : magnet)\n )) {\n minDistance = distance;\n data.closestView = view;\n data.closestMagnet = magnet;\n }\n }\n });\n\n }, this);\n\n var end;\n var magnetProxy = null;\n var closestView = data.closestView;\n var closestMagnet = data.closestMagnet;\n if (closestMagnet) {\n magnetProxy = data.magnetProxy = closestView.findProxyNode(closestMagnet, 'highlighter');\n }\n var endType = data.arrowhead;\n var newClosestMagnet = (prevClosestMagnet !== closestMagnet);\n if (prevClosestView && newClosestMagnet) {\n prevClosestView.unhighlight(prevMagnetProxy, {\n connecting: true,\n snapping: true\n });\n }\n\n if (closestView) {\n const { prevEnd, prevX, prevY } = data;\n data.prevX = x;\n data.prevY = y;\n isSnapped = true;\n\n if (!newClosestMagnet) {\n if (typeof connectionStrategy !== 'function' || (prevX === x && prevY === y)) {\n // the magnet has not changed and the link's end does not depend on the x and y\n return isSnapped;\n }\n }\n\n end = closestView.getLinkEnd(closestMagnet, x, y, this.model, endType);\n if (!newClosestMagnet && isEqual(prevEnd, end)) {\n // the source/target json has not changed\n return isSnapped;\n }\n\n data.prevEnd = end;\n\n if (newClosestMagnet) {\n closestView.highlight(magnetProxy, {\n connecting: true,\n snapping: true\n });\n }\n\n } else {\n\n end = { x: x, y: y };\n }\n\n this.model.set(endType, end || { x: x, y: y }, { ui: true });\n\n if (prevClosestView) {\n this.notify('link:snap:disconnect', evt, prevClosestView, prevClosestMagnet, endType);\n }\n if (closestView) {\n this.notify('link:snap:connect', evt, closestView, closestMagnet, endType);\n }\n\n return isSnapped;\n },\n\n _snapArrowheadEnd: function(data) {\n\n // Finish off link snapping.\n // Everything except view unhighlighting was already done on pointermove.\n var closestView = data.closestView;\n var closestMagnet = data.closestMagnet;\n if (closestView && closestMagnet) {\n\n closestView.unhighlight(data.magnetProxy, { connecting: true, snapping: true });\n data.magnetUnderPointer = closestView.findMagnet(closestMagnet);\n }\n\n data.closestView = data.closestMagnet = null;\n },\n\n _connectArrowhead: function(target, x, y, data) {\n\n // checking views right under the pointer\n const { paper, model } = this;\n\n if (data.eventTarget !== target) {\n // Unhighlight the previous view under pointer if there was one.\n if (data.magnetProxy) {\n data.viewUnderPointer.unhighlight(data.magnetProxy, {\n connecting: true\n });\n }\n\n const viewUnderPointer = data.viewUnderPointer = paper.findView(target);\n if (viewUnderPointer) {\n // If we found a view that is under the pointer, we need to find the closest\n // magnet based on the real target element of the event.\n const magnetUnderPointer = data.magnetUnderPointer = viewUnderPointer.findMagnet(target);\n const magnetProxy = data.magnetProxy = viewUnderPointer.findProxyNode(magnetUnderPointer, 'highlighter');\n\n if (magnetUnderPointer && this.paper.options.validateConnection.apply(\n paper,\n data.validateConnectionArgs(viewUnderPointer, magnetUnderPointer)\n )) {\n // If there was no magnet found, do not highlight anything and assume there\n // is no view under pointer we're interested in reconnecting to.\n // This can only happen if the overall element has the attribute `'.': { magnet: false }`.\n if (magnetProxy) {\n viewUnderPointer.highlight(magnetProxy, {\n connecting: true\n });\n }\n } else {\n // This type of connection is not valid. Disregard this magnet.\n data.magnetUnderPointer = null;\n data.magnetProxy = null;\n }\n } else {\n // Make sure we'll unset previous magnet.\n data.magnetUnderPointer = null;\n data.magnetProxy = null;\n }\n }\n\n data.eventTarget = target;\n\n model.set(data.arrowhead, { x: x, y: y }, { ui: true });\n },\n\n _connectArrowheadEnd: function(data = {}, x, y) {\n\n const { model } = this;\n const { viewUnderPointer, magnetUnderPointer, magnetProxy, arrowhead } = data;\n\n if (!magnetUnderPointer || !magnetProxy || !viewUnderPointer) return;\n\n viewUnderPointer.unhighlight(magnetProxy, { connecting: true });\n\n // The link end is taken from the magnet under the pointer, not the proxy.\n const end = viewUnderPointer.getLinkEnd(magnetUnderPointer, x, y, model, arrowhead);\n model.set(arrowhead, end, { ui: true });\n },\n\n _beforeArrowheadMove: function(data) {\n\n data.z = this.model.get('z');\n this.model.toFront();\n\n // Let the pointer propagate through the link view elements so that\n // the `evt.target` is another element under the pointer, not the link itself.\n var style = this.el.style;\n data.pointerEvents = style.pointerEvents;\n style.pointerEvents = 'none';\n\n if (this.paper.options.markAvailable) {\n this._markAvailableMagnets(data);\n }\n },\n\n _afterArrowheadMove: function(data) {\n\n if (data.z !== null) {\n this.model.set('z', data.z, { ui: true });\n data.z = null;\n }\n\n // Put `pointer-events` back to its original value. See `_beforeArrowheadMove()` for explanation.\n this.el.style.pointerEvents = data.pointerEvents;\n\n if (this.paper.options.markAvailable) {\n this._unmarkAvailableMagnets(data);\n }\n },\n\n _createValidateConnectionArgs: function(arrowhead) {\n // It makes sure the arguments for validateConnection have the following form:\n // (source view, source magnet, target view, target magnet and link view)\n var args = [];\n\n args[4] = arrowhead;\n args[5] = this;\n\n var oppositeArrowhead;\n var i = 0;\n var j = 0;\n\n if (arrowhead === 'source') {\n i = 2;\n oppositeArrowhead = 'target';\n } else {\n j = 2;\n oppositeArrowhead = 'source';\n }\n\n var end = this.model.get(oppositeArrowhead);\n\n if (end.id) {\n var view = args[i] = this.paper.findViewByModel(end.id);\n var magnet = view.getMagnetFromLinkEnd(end);\n if (magnet === view.el) magnet = undefined;\n args[i + 1] = magnet;\n }\n\n function validateConnectionArgs(cellView, magnet) {\n args[j] = cellView;\n args[j + 1] = cellView.el === magnet ? undefined : magnet;\n return args;\n }\n\n return validateConnectionArgs;\n },\n\n _markAvailableMagnets: function(data) {\n\n function isMagnetAvailable(view, magnet) {\n var paper = view.paper;\n var validate = paper.options.validateConnection;\n return validate.apply(paper, this.validateConnectionArgs(view, magnet));\n }\n\n var paper = this.paper;\n var elements = paper.model.getCells();\n data.marked = {};\n\n for (var i = 0, n = elements.length; i < n; i++) {\n var view = elements[i].findView(paper);\n\n if (!view) {\n continue;\n }\n\n var magnets = Array.prototype.slice.call(view.el.querySelectorAll('[magnet]'));\n if (view.el.getAttribute('magnet') !== 'false') {\n // Element wrapping group is also a magnet\n magnets.push(view.el);\n }\n\n var availableMagnets = magnets.filter(isMagnetAvailable.bind(data, view));\n\n if (availableMagnets.length > 0) {\n // highlight all available magnets\n for (var j = 0, m = availableMagnets.length; j < m; j++) {\n view.highlight(availableMagnets[j], { magnetAvailability: true });\n }\n // highlight the entire view\n view.highlight(null, { elementAvailability: true });\n\n data.marked[view.model.id] = availableMagnets;\n }\n }\n },\n\n _unmarkAvailableMagnets: function(data) {\n\n var markedKeys = Object.keys(data.marked);\n var id;\n var markedMagnets;\n\n for (var i = 0, n = markedKeys.length; i < n; i++) {\n id = markedKeys[i];\n markedMagnets = data.marked[id];\n\n var view = this.paper.findViewByModel(id);\n if (view) {\n for (var j = 0, m = markedMagnets.length; j < m; j++) {\n view.unhighlight(markedMagnets[j], { magnetAvailability: true });\n }\n view.unhighlight(null, { elementAvailability: true });\n }\n }\n\n data.marked = null;\n },\n\n startArrowheadMove: function(end, opt) {\n\n opt || (opt = {});\n\n // Allow to delegate events from an another view to this linkView in order to trigger arrowhead\n // move without need to click on the actual arrowhead dom element.\n var data = {\n action: 'arrowhead-move',\n arrowhead: end,\n whenNotAllowed: opt.whenNotAllowed || 'revert',\n initialMagnet: this[end + 'Magnet'] || (this[end + 'View'] ? this[end + 'View'].el : null),\n initialEnd: clone(this.model.get(end)),\n validateConnectionArgs: this._createValidateConnectionArgs(end)\n };\n\n this._beforeArrowheadMove(data);\n\n if (opt.ignoreBackwardsCompatibility !== true) {\n this._dragData = data;\n }\n\n return data;\n },\n\n // Lifecycle methods\n\n onMount: function() {\n CellView.prototype.onMount.apply(this, arguments);\n this.mountLabels();\n },\n\n onDetach: function() {\n CellView.prototype.onDetach.apply(this, arguments);\n this.unmountLabels();\n },\n\n onRemove: function() {\n CellView.prototype.onRemove.apply(this, arguments);\n this.unmountLabels();\n }\n\n}, {\n\n Flags: Flags,\n});\n\nObject.defineProperty(LinkView.prototype, 'sourceBBox', {\n\n enumerable: true,\n\n get: function() {\n var sourceView = this.sourceView;\n if (!sourceView) {\n var sourceDef = this.model.source();\n return new Rect(sourceDef.x, sourceDef.y);\n }\n var sourceMagnet = this.sourceMagnet;\n if (sourceView.isNodeConnection(sourceMagnet)) {\n return new Rect(this.sourceAnchor);\n }\n return sourceView.getNodeBBox(sourceMagnet || sourceView.el);\n }\n\n});\n\nObject.defineProperty(LinkView.prototype, 'targetBBox', {\n\n enumerable: true,\n\n get: function() {\n var targetView = this.targetView;\n if (!targetView) {\n var targetDef = this.model.target();\n return new Rect(targetDef.x, targetDef.y);\n }\n var targetMagnet = this.targetMagnet;\n if (targetView.isNodeConnection(targetMagnet)) {\n return new Rect(this.targetAnchor);\n }\n return targetView.getNodeBBox(targetMagnet || targetView.el);\n }\n});\n\n","import { View } from '../mvc/index.mjs';\nimport { addClassNamePrefix } from '../util/util.mjs';\n\nexport const LayersNames = {\n GRID: 'grid',\n CELLS: 'cells',\n BACK: 'back',\n FRONT: 'front',\n TOOLS: 'tools',\n LABELS: 'labels'\n};\n\nexport const PaperLayer = View.extend({\n\n tagName: 'g',\n svgElement: true,\n pivotNodes: null,\n defaultTheme: null,\n\n options: {\n name: ''\n },\n\n className: function() {\n return addClassNamePrefix(`${this.options.name}-layer`);\n },\n\n init: function() {\n this.pivotNodes = {};\n },\n\n insertSortedNode: function(node, z) {\n this.el.insertBefore(node, this.insertPivot(z));\n },\n\n insertNode: function(node) {\n const { el } = this;\n if (node.parentNode !== el) {\n el.appendChild(node);\n }\n },\n\n insertPivot: function(z) {\n const { el, pivotNodes } = this;\n z = +z;\n z || (z = 0);\n let pivotNode = pivotNodes[z];\n if (pivotNode) return pivotNode;\n pivotNode = pivotNodes[z] = document.createComment('z-index:' + (z + 1));\n let neighborZ = -Infinity;\n for (let currentZ in pivotNodes) {\n currentZ = +currentZ;\n if (currentZ < z && currentZ > neighborZ) {\n neighborZ = currentZ;\n if (neighborZ === z - 1) continue;\n }\n }\n if (neighborZ !== -Infinity) {\n const neighborPivot = pivotNodes[neighborZ];\n // Insert After\n el.insertBefore(pivotNode, neighborPivot.nextSibling);\n } else {\n // First Child\n el.insertBefore(pivotNode, el.firstChild);\n }\n return pivotNode;\n },\n\n removePivots: function() {\n const { el, pivotNodes } = this;\n for (let z in pivotNodes) el.removeChild(pivotNodes[z]);\n this.pivotNodes = {};\n }\n\n});\n","import { assign } from '../util/index.mjs';\nimport V from '../V/index.mjs';\nimport { HighlighterView } from '../dia/HighlighterView.mjs';\n\nexport const stroke = HighlighterView.extend({\n\n tagName: 'path',\n className: 'highlight-stroke',\n attributes: {\n 'pointer-events': 'none',\n 'fill': 'none'\n },\n\n options: {\n padding: 3,\n rx: 0,\n ry: 0,\n useFirstSubpath: false,\n attrs: {\n 'stroke-width': 3,\n 'stroke': '#FEB663'\n }\n },\n\n getPathData(cellView, node) {\n const { options } = this;\n const { useFirstSubpath } = options;\n let d;\n try {\n const vNode = V(node);\n d = vNode.convertToPathData().trim();\n if (vNode.tagName() === 'PATH' && useFirstSubpath) {\n const secondSubpathIndex = d.search(/.M/i) + 1;\n if (secondSubpathIndex > 0) {\n d = d.substr(0, secondSubpathIndex);\n }\n }\n } catch (error) {\n // Failed to get path data from magnet element.\n // Draw a rectangle around the node instead.\n const nodeBBox = cellView.getNodeBoundingRect(node);\n d = V.rectToPath(assign({}, options, nodeBBox.toJSON()));\n }\n return d;\n },\n\n highlightConnection(cellView) {\n this.vel.attr('d', cellView.getSerializedConnection());\n },\n\n highlightNode(cellView, node) {\n const { vel, options } = this;\n const { padding, layer } = options;\n let highlightMatrix = this.getNodeMatrix(cellView, node);\n // Add padding to the highlight element.\n if (padding) {\n if (!layer && node === cellView.el) {\n // If the highlighter is appended to the cellView\n // and we measure the size of the cellView wrapping group\n // it's necessary to remove the highlighter first\n vel.remove();\n }\n let nodeBBox = cellView.getNodeBoundingRect(node);\n const cx = nodeBBox.x + (nodeBBox.width / 2);\n const cy = nodeBBox.y + (nodeBBox.height / 2);\n nodeBBox = V.transformRect(nodeBBox, highlightMatrix);\n const width = Math.max(nodeBBox.width, 1);\n const height = Math.max(nodeBBox.height, 1);\n const sx = (width + padding) / width;\n const sy = (height + padding) / height;\n const paddingMatrix = V.createSVGMatrix({\n a: sx,\n b: 0,\n c: 0,\n d: sy,\n e: cx - sx * cx,\n f: cy - sy * cy\n });\n highlightMatrix = highlightMatrix.multiply(paddingMatrix);\n }\n vel.attr({\n 'd': this.getPathData(cellView, node),\n 'transform': V.matrixToTransformString(highlightMatrix)\n });\n },\n\n highlight(cellView, node) {\n const { vel, options } = this;\n vel.attr(options.attrs);\n if (options.nonScalingStroke) {\n vel.attr('vector-effect', 'non-scaling-stroke');\n }\n if (cellView.isNodeConnection(node)) {\n this.highlightConnection(cellView);\n } else {\n this.highlightNode(cellView, node);\n }\n }\n\n});\n","import V from '../V/index.mjs';\nimport { HighlighterView } from '../dia/HighlighterView.mjs';\n\nconst MASK_CLIP = 20;\n\nfunction forEachDescendant(vel, fn) {\n const descendants = vel.children();\n while (descendants.length > 0) {\n const descendant = descendants.shift();\n if (fn(descendant)) {\n descendants.push(...descendant.children());\n }\n }\n}\n\nexport const mask = HighlighterView.extend({\n\n tagName: 'rect',\n className: 'highlight-mask',\n attributes: {\n 'pointer-events': 'none'\n },\n\n options: {\n padding: 3,\n maskClip: MASK_CLIP,\n deep: false,\n attrs: {\n 'stroke': '#FEB663',\n 'stroke-width': 3,\n 'stroke-linecap': 'butt',\n 'stroke-linejoin': 'miter',\n }\n },\n\n VISIBLE: 'white',\n INVISIBLE: 'black',\n\n MASK_ROOT_ATTRIBUTE_BLACKLIST: [\n 'marker-start',\n 'marker-end',\n 'marker-mid',\n 'transform',\n 'stroke-dasharray',\n 'class',\n ],\n\n MASK_CHILD_ATTRIBUTE_BLACKLIST: [\n 'stroke',\n 'fill',\n 'stroke-width',\n 'stroke-opacity',\n 'stroke-dasharray',\n 'fill-opacity',\n 'marker-start',\n 'marker-end',\n 'marker-mid',\n 'class',\n ],\n\n // TODO: change the list to a function callback\n MASK_REPLACE_TAGS: [\n 'FOREIGNOBJECT',\n 'IMAGE',\n 'USE',\n 'TEXT',\n 'TSPAN',\n 'TEXTPATH'\n ],\n\n // TODO: change the list to a function callback\n MASK_REMOVE_TAGS: [\n 'TEXT',\n 'TSPAN',\n 'TEXTPATH'\n ],\n\n transformMaskChild(cellView, childEl) {\n const {\n MASK_CHILD_ATTRIBUTE_BLACKLIST,\n MASK_REPLACE_TAGS,\n MASK_REMOVE_TAGS\n } = this;\n const childTagName = childEl.tagName();\n // Do not include the element in the mask's image\n if (!V.isSVGGraphicsElement(childEl) || MASK_REMOVE_TAGS.includes(childTagName)) {\n childEl.remove();\n return false;\n }\n // Replace the element with a rectangle\n if (MASK_REPLACE_TAGS.includes(childTagName)) {\n // Note: clone() method does not change the children ids\n const originalChild = cellView.vel.findOne(`#${childEl.id}`);\n if (originalChild) {\n const { node: originalNode } = originalChild;\n let childBBox = cellView.getNodeBoundingRect(originalNode);\n if (cellView.model.isElement()) {\n childBBox = V.transformRect(childBBox, cellView.getNodeMatrix(originalNode));\n }\n const replacement = V('rect', childBBox.toJSON());\n const { x: ox, y: oy } = childBBox.center();\n const { angle, cx = ox, cy = oy } = originalChild.rotate();\n if (angle) replacement.rotate(angle, cx, cy);\n // Note: it's not important to keep the same sibling index since all subnodes are filled\n childEl.parent().append(replacement);\n }\n childEl.remove();\n return false;\n }\n // Keep the element, but clean it from certain attributes\n MASK_CHILD_ATTRIBUTE_BLACKLIST.forEach(attrName => {\n if (attrName === 'fill' && childEl.attr('fill') === 'none') return;\n childEl.removeAttr(attrName);\n });\n return true;\n },\n\n transformMaskRoot(_cellView, rootEl) {\n const { MASK_ROOT_ATTRIBUTE_BLACKLIST } = this;\n MASK_ROOT_ATTRIBUTE_BLACKLIST.forEach(attrName => {\n rootEl.removeAttr(attrName);\n });\n },\n\n getMaskShape(cellView, vel) {\n const { options, MASK_REPLACE_TAGS } = this;\n const { deep } = options;\n const tagName = vel.tagName();\n let maskRoot;\n if (tagName === 'G') {\n if (!deep) return null;\n maskRoot = vel.clone();\n forEachDescendant(maskRoot, maskChild => this.transformMaskChild(cellView, maskChild));\n } else {\n if (MASK_REPLACE_TAGS.includes(tagName)) return null;\n maskRoot = vel.clone();\n }\n this.transformMaskRoot(cellView, maskRoot);\n return maskRoot;\n },\n\n getMaskId() {\n return `highlight-mask-${this.cid}`;\n },\n\n getMask(cellView, vNode) {\n\n const { VISIBLE, INVISIBLE, options } = this;\n const { padding, attrs } = options;\n // support both `strokeWidth` and `stroke-width` attribute names\n const strokeWidth = parseFloat(V('g').attr(attrs).attr('stroke-width'));\n const hasNodeFill = vNode.attr('fill') !== 'none';\n let magnetStrokeWidth = parseFloat(vNode.attr('stroke-width'));\n if (isNaN(magnetStrokeWidth)) magnetStrokeWidth = 1;\n // stroke of the invisible shape\n const minStrokeWidth = magnetStrokeWidth + padding * 2;\n // stroke of the visible shape\n const maxStrokeWidth = minStrokeWidth + strokeWidth * 2;\n let maskEl = this.getMaskShape(cellView, vNode);\n if (!maskEl) {\n const nodeBBox = cellView.getNodeBoundingRect(vNode.node);\n // Make sure the rect is visible\n nodeBBox.inflate(nodeBBox.width ? 0 : 0.5, nodeBBox.height ? 0 : 0.5);\n maskEl = V('rect', nodeBBox.toJSON());\n }\n maskEl.attr(attrs);\n return V('mask', {\n 'id': this.getMaskId()\n }).append([\n maskEl.clone().attr({\n 'fill': hasNodeFill ? VISIBLE : 'none',\n 'stroke': VISIBLE,\n 'stroke-width': maxStrokeWidth\n }),\n maskEl.clone().attr({\n 'fill': hasNodeFill ? INVISIBLE : 'none',\n 'stroke': INVISIBLE,\n 'stroke-width': minStrokeWidth\n })\n ]);\n },\n\n removeMask(paper) {\n const maskNode = paper.svg.getElementById(this.getMaskId());\n if (maskNode) {\n paper.defs.removeChild(maskNode);\n }\n },\n\n addMask(paper, maskEl) {\n paper.defs.appendChild(maskEl.node);\n },\n\n highlight(cellView, node) {\n const { options, vel } = this;\n const { padding, attrs, maskClip = MASK_CLIP, layer } = options;\n const color = ('stroke' in attrs) ? attrs['stroke'] : '#000000';\n if (!layer && node === cellView.el) {\n // If the highlighter is appended to the cellView\n // and we measure the size of the cellView wrapping group\n // it's necessary to remove the highlighter first\n vel.remove();\n }\n const highlighterBBox = cellView.getNodeBoundingRect(node).inflate(padding + maskClip);\n const highlightMatrix = this.getNodeMatrix(cellView, node);\n const maskEl = this.getMask(cellView, V(node));\n this.addMask(cellView.paper, maskEl);\n vel.attr(highlighterBBox.toJSON());\n vel.attr({\n 'transform': V.matrixToTransformString(highlightMatrix),\n 'mask': `url(#${maskEl.id})`,\n 'fill': color\n });\n },\n\n unhighlight(cellView) {\n this.removeMask(cellView.paper);\n }\n\n});\n","import { HighlighterView } from '../dia/HighlighterView.mjs';\n\nexport const opacity = HighlighterView.extend({\n\n UPDATABLE: false,\n MOUNTABLE: false,\n\n highlight: function(_cellView, node) {\n const { alphaValue = 0.3 } = this.options;\n node.style.opacity = alphaValue;\n },\n\n unhighlight: function(_cellView, node) {\n node.style.opacity = '';\n }\n\n});\n","import * as util from '../util/index.mjs';\nimport V from '../V/index.mjs';\nimport { HighlighterView } from '../dia/HighlighterView.mjs';\n\nconst className = util.addClassNamePrefix('highlighted');\n\nexport const addClass = HighlighterView.extend({\n\n UPDATABLE: false,\n MOUNTABLE: false,\n\n options: {\n className\n },\n\n highlight: function(_cellView, node) {\n V(node).addClass(this.options.className);\n },\n\n unhighlight: function(_cellView, node) {\n V(node).removeClass(this.options.className);\n }\n\n}, {\n // Backwards Compatibility\n className\n});\n","import { Rect } from '../g/index.mjs';\nimport { HighlighterView } from '../dia/HighlighterView.mjs';\nimport {\n normalizeSides,\n isEqual,\n} from '../util/index.mjs';\nimport {\n Positions,\n getRectPoint,\n} from '../util/getRectPoint.mjs';\n\nconst Directions = {\n ROW: 'row',\n COLUMN: 'column'\n};\n\nexport const list = HighlighterView.extend({\n\n tagName: 'g',\n MOUNTABLE: true,\n UPDATE_ATTRIBUTES: function() {\n return [this.options.attribute];\n },\n\n _prevItems: null,\n\n highlight(elementView, node) {\n const element = elementView.model;\n const { attribute, size = 20, gap = 5, direction = Directions.ROW } = this.options;\n if (!attribute) throw new Error('List: attribute is required');\n const normalizedSize = (typeof size === 'number') ? { width: size, height: size } : size;\n const isRowDirection = (direction === Directions.ROW);\n const itemWidth = isRowDirection ? normalizedSize.width : normalizedSize.height;\n let items = element.get(attribute);\n if (!Array.isArray(items)) items = [];\n const prevItems = this._prevItems || [];\n const comparison = items.map((item, index) => isEqual(prevItems[index], items[index]));\n if (prevItems.length !== items.length || comparison.some(unchanged => !unchanged)) {\n const prevEls = this.vel.children();\n const itemsEls = items.map((item, index) => {\n const prevEl = (index in prevEls) ? prevEls[index].node : null;\n if (comparison[index]) return prevEl;\n const itemEl = this.createListItem(item, normalizedSize, prevEl);\n if (!itemEl) return null;\n if (!(itemEl instanceof SVGElement)) throw new Error('List: item must be an SVGElement');\n itemEl.dataset.index = index;\n itemEl.dataset.attribute = attribute;\n const offset = index * (itemWidth + gap);\n itemEl.setAttribute('transform', (isRowDirection)\n ? `translate(${offset}, 0)`\n : `translate(0, ${offset})`\n );\n return itemEl;\n });\n this.vel.empty().append(itemsEls);\n this._prevItems = items;\n }\n const itemsCount = items.length;\n const length = (itemsCount === 0)\n ? 0\n : (itemsCount * itemWidth + (itemsCount - 1) * gap);\n const listSize = (isRowDirection)\n ? { width: length, height: normalizedSize.height }\n : { width: normalizedSize.width, height: length };\n\n this.position(element, listSize);\n },\n\n position(element, listSize) {\n const { vel, options } = this;\n const { margin = 5, position = 'top-left' } = options;\n const { width, height } = element.size();\n const { left, right, top, bottom } = normalizeSides(margin);\n const bbox = new Rect(left, top, width - (left + right), height - (top + bottom));\n let { x, y } = getRectPoint(bbox, position);\n // x\n switch (position) {\n case Positions.CENTER:\n case Positions.TOP:\n case Positions.BOTTOM: {\n x -= listSize.width / 2;\n break;\n }\n case Positions.RIGHT:\n case Positions.BOTTOM_RIGHT:\n case Positions.TOP_RIGHT: {\n x -= listSize.width;\n break;\n }\n }\n // y\n switch (position) {\n case Positions.CENTER:\n case Positions.RIGHT:\n case Positions.LEFT: {\n y -= listSize.height / 2;\n break;\n }\n case Positions.BOTTOM:\n case Positions.BOTTOM_RIGHT:\n case Positions.BOTTOM_LEFT: {\n y -= listSize.height;\n break;\n }\n }\n vel.attr('transform', `translate(${x}, ${y})`);\n }\n}, {\n Directions,\n Positions\n});\n","import { Line, Point } from '../g/index.mjs';\nimport { isPercentage } from '../util/index.mjs';\n\nfunction connectionRatio(view, _magnet, _refPoint, opt) {\n\n var ratio = ('ratio' in opt) ? opt.ratio : 0.5;\n return view.getPointAtRatio(ratio);\n}\n\nfunction connectionLength(view, _magnet, _refPoint, opt) {\n\n var length = ('length' in opt) ? opt.length : 20;\n return view.getPointAtLength(length);\n}\n\nfunction _connectionPerpendicular(view, _magnet, refPoint, opt) {\n\n var OFFSET = 1e6;\n var path = view.getConnection();\n var segmentSubdivisions = view.getConnectionSubdivisions();\n var verticalLine = new Line(refPoint.clone().offset(0, OFFSET), refPoint.clone().offset(0, -OFFSET));\n var horizontalLine = new Line(refPoint.clone().offset(OFFSET, 0), refPoint.clone().offset(-OFFSET, 0));\n var verticalIntersections = verticalLine.intersect(path, { segmentSubdivisions: segmentSubdivisions });\n var horizontalIntersections = horizontalLine.intersect(path, { segmentSubdivisions: segmentSubdivisions });\n var intersections = [];\n if (verticalIntersections) Array.prototype.push.apply(intersections, verticalIntersections);\n if (horizontalIntersections) Array.prototype.push.apply(intersections, horizontalIntersections);\n if (intersections.length > 0) return refPoint.chooseClosest(intersections);\n if ('fallbackAt' in opt) {\n return getPointAtLink(view, opt.fallbackAt);\n }\n return connectionClosest(view, _magnet, refPoint, opt);\n}\n\nfunction _connectionClosest(view, _magnet, refPoint, _opt) {\n\n var closestPoint = view.getClosestPoint(refPoint);\n if (!closestPoint) return new Point();\n return closestPoint;\n}\n\nexport function resolveRef(fn) {\n return function(view, magnet, ref, opt) {\n if (ref instanceof Element) {\n var refView = this.paper.findView(ref);\n var refPoint;\n if (refView) {\n if (refView.isNodeConnection(ref)) {\n var distance = ('fixedAt' in opt) ? opt.fixedAt : '50%';\n refPoint = getPointAtLink(refView, distance);\n } else {\n refPoint = refView.getNodeBBox(ref).center();\n }\n } else {\n // Something went wrong\n refPoint = new Point();\n }\n return fn.call(this, view, magnet, refPoint, opt);\n }\n return fn.apply(this, arguments);\n };\n}\n\nfunction getPointAtLink(view, value) {\n var parsedValue = parseFloat(value);\n if (isPercentage(value)) {\n return view.getPointAtRatio(parsedValue / 100);\n } else {\n return view.getPointAtLength(parsedValue);\n }\n}\n\n// joint.linkAnchors\nexport { connectionRatio, connectionLength };\nexport const connectionPerpendicular = resolveRef(_connectionPerpendicular);\nexport const connectionClosest = resolveRef(_connectionClosest);\n","import * as g from '../g/index.mjs';\nimport V from '../V/index.mjs';\nimport * as util from '../util/index.mjs';\n\nfunction offsetPoint(p1, p2, offset) {\n if (util.isPlainObject(offset)) {\n const { x, y } = offset;\n if (isFinite(y)) {\n const line = new g.Line(p2, p1);\n const { start, end } = line.parallel(y);\n p2 = start;\n p1 = end;\n }\n offset = x;\n }\n if (!isFinite(offset)) return p1;\n var length = p1.distance(p2);\n if (offset === 0 && length > 0) return p1;\n return p1.move(p2, -Math.min(offset, length - 1));\n}\n\nfunction stroke(magnet) {\n\n var stroke = magnet.getAttribute('stroke-width');\n if (stroke === null) return 0;\n return parseFloat(stroke) || 0;\n}\n\nfunction alignLine(line, type, offset = 0) {\n let coordinate, a, b, direction;\n const { start, end } = line;\n switch (type) {\n case 'left':\n coordinate = 'x';\n a = end;\n b = start;\n direction = -1;\n break;\n case 'right':\n coordinate = 'x';\n a = start;\n b = end;\n direction = 1;\n break;\n case 'top':\n coordinate = 'y';\n a = end;\n b = start;\n direction = -1;\n break;\n case 'bottom':\n coordinate = 'y';\n a = start;\n b = end;\n direction = 1;\n break;\n default:\n return;\n }\n if (start[coordinate] < end[coordinate]) {\n a[coordinate] = b[coordinate];\n } else {\n b[coordinate] = a[coordinate];\n }\n if (isFinite(offset)) {\n a[coordinate] += direction * offset;\n b[coordinate] += direction * offset;\n }\n}\n\n// Connection Points\n\nfunction anchorConnectionPoint(line, _view, _magnet, opt) {\n let { offset, alignOffset, align } = opt;\n if (align) alignLine(line, align, alignOffset);\n return offsetPoint(line.end, line.start, offset);\n}\n\nfunction bboxIntersection(line, view, magnet, opt) {\n\n var bbox = view.getNodeBBox(magnet);\n if (opt.stroke) bbox.inflate(stroke(magnet) / 2);\n var intersections = line.intersect(bbox);\n var cp = (intersections)\n ? line.start.chooseClosest(intersections)\n : line.end;\n return offsetPoint(cp, line.start, opt.offset);\n}\n\nfunction rectangleIntersection(line, view, magnet, opt) {\n\n var angle = view.model.angle();\n if (angle === 0) {\n return bboxIntersection(line, view, magnet, opt);\n }\n\n var bboxWORotation = view.getNodeUnrotatedBBox(magnet);\n if (opt.stroke) bboxWORotation.inflate(stroke(magnet) / 2);\n var center = bboxWORotation.center();\n var lineWORotation = line.clone().rotate(center, angle);\n var intersections = lineWORotation.setLength(1e6).intersect(bboxWORotation);\n var cp = (intersections)\n ? lineWORotation.start.chooseClosest(intersections).rotate(center, -angle)\n : line.end;\n return offsetPoint(cp, line.start, opt.offset);\n}\n\nfunction findShapeNode(magnet) {\n if (!magnet) return null;\n var node = magnet;\n do {\n var tagName = node.tagName;\n if (typeof tagName !== 'string') return null;\n tagName = tagName.toUpperCase();\n if (tagName === 'G') {\n node = node.firstElementChild;\n } else if (tagName === 'TITLE') {\n node = node.nextElementSibling;\n } else break;\n } while (node);\n return node;\n}\n\nvar BNDR_SUBDIVISIONS = 'segmentSubdivisons';\nvar BNDR_SHAPE_BBOX = 'shapeBBox';\n\nfunction boundaryIntersection(line, view, magnet, opt) {\n\n var node, intersection;\n var selector = opt.selector;\n var anchor = line.end;\n\n if (typeof selector === 'string') {\n node = view.findNode(selector);\n } else if (selector === false) {\n node = magnet;\n } else if (Array.isArray(selector)) {\n node = util.getByPath(magnet, selector);\n } else {\n node = findShapeNode(magnet);\n }\n\n if (!V.isSVGGraphicsElement(node)) {\n if (node === magnet || !V.isSVGGraphicsElement(magnet)) return anchor;\n node = magnet;\n }\n\n var localShape = view.getNodeShape(node);\n var magnetMatrix = view.getNodeMatrix(node);\n var translateMatrix = view.getRootTranslateMatrix();\n var rotateMatrix = view.getRootRotateMatrix();\n var targetMatrix = translateMatrix.multiply(rotateMatrix).multiply(magnetMatrix);\n var localMatrix = targetMatrix.inverse();\n var localLine = V.transformLine(line, localMatrix);\n var localRef = localLine.start.clone();\n var data = view.getNodeData(node);\n\n if (opt.insideout === false) {\n if (!data[BNDR_SHAPE_BBOX]) data[BNDR_SHAPE_BBOX] = localShape.bbox();\n var localBBox = data[BNDR_SHAPE_BBOX];\n if (localBBox.containsPoint(localRef)) return anchor;\n }\n\n // Caching segment subdivisions for paths\n var pathOpt;\n if (localShape instanceof g.Path) {\n var precision = opt.precision || 2;\n if (!data[BNDR_SUBDIVISIONS]) data[BNDR_SUBDIVISIONS] = localShape.getSegmentSubdivisions({ precision: precision });\n pathOpt = {\n precision: precision,\n segmentSubdivisions: data[BNDR_SUBDIVISIONS]\n };\n }\n\n if (opt.extrapolate === true) localLine.setLength(1e6);\n\n intersection = localLine.intersect(localShape, pathOpt);\n if (intersection) {\n // More than one intersection\n if (V.isArray(intersection)) intersection = localRef.chooseClosest(intersection);\n } else if (opt.sticky === true) {\n // No intersection, find the closest point instead\n if (localShape instanceof g.Rect) {\n intersection = localShape.pointNearestToPoint(localRef);\n } else if (localShape instanceof g.Ellipse) {\n intersection = localShape.intersectionWithLineFromCenterToPoint(localRef);\n } else {\n intersection = localShape.closestPoint(localRef, pathOpt);\n }\n }\n\n var cp = (intersection) ? V.transformPoint(intersection, targetMatrix) : anchor;\n var cpOffset = opt.offset || 0;\n if (opt.stroke) cpOffset += stroke(node) / 2;\n\n return offsetPoint(cp, line.start, cpOffset);\n}\n\nexport const anchor = anchorConnectionPoint;\nexport const bbox = bboxIntersection;\nexport const rectangle = rectangleIntersection;\nexport const boundary = boundaryIntersection;\n","import * as util from '../util/index.mjs';\nimport { toRad } from '../g/index.mjs';\nimport { resolveRef } from '../linkAnchors/index.mjs';\n\nfunction bboxWrapper(method) {\n\n return function(view, magnet, ref, opt) {\n\n var rotate = !!opt.rotate;\n var bbox = (rotate) ? view.getNodeUnrotatedBBox(magnet) : view.getNodeBBox(magnet);\n var anchor = bbox[method]();\n\n var dx = opt.dx;\n if (dx) {\n var dxPercentage = util.isPercentage(dx);\n dx = parseFloat(dx);\n if (isFinite(dx)) {\n if (dxPercentage) {\n dx /= 100;\n dx *= bbox.width;\n }\n anchor.x += dx;\n }\n }\n\n var dy = opt.dy;\n if (dy) {\n var dyPercentage = util.isPercentage(dy);\n dy = parseFloat(dy);\n if (isFinite(dy)) {\n if (dyPercentage) {\n dy /= 100;\n dy *= bbox.height;\n }\n anchor.y += dy;\n }\n }\n\n return (rotate) ? anchor.rotate(view.model.getBBox().center(), -view.model.angle()) : anchor;\n };\n}\n\nfunction _perpendicular(view, magnet, refPoint, opt) {\n\n var angle = view.model.angle();\n var bbox = view.getNodeBBox(magnet);\n var anchor = bbox.center();\n var topLeft = bbox.origin();\n var bottomRight = bbox.corner();\n\n var padding = opt.padding;\n if (!isFinite(padding)) padding = 0;\n\n if ((topLeft.y + padding) <= refPoint.y && refPoint.y <= (bottomRight.y - padding)) {\n var dy = (refPoint.y - anchor.y);\n anchor.x += (angle === 0 || angle === 180) ? 0 : dy * 1 / Math.tan(toRad(angle));\n anchor.y += dy;\n } else if ((topLeft.x + padding) <= refPoint.x && refPoint.x <= (bottomRight.x - padding)) {\n var dx = (refPoint.x - anchor.x);\n anchor.y += (angle === 90 || angle === 270) ? 0 : dx * Math.tan(toRad(angle));\n anchor.x += dx;\n }\n\n return anchor;\n}\n\nfunction _midSide(view, magnet, refPoint, opt) {\n\n var rotate = !!opt.rotate;\n var bbox, angle, center;\n if (rotate) {\n bbox = view.getNodeUnrotatedBBox(magnet);\n center = view.model.getBBox().center();\n angle = view.model.angle();\n } else {\n bbox = view.getNodeBBox(magnet);\n }\n\n var padding = opt.padding;\n if (isFinite(padding)) bbox.inflate(padding);\n\n if (rotate) refPoint.rotate(center, angle);\n\n var side = bbox.sideNearestToPoint(refPoint);\n var anchor;\n switch (side) {\n case 'left':\n anchor = bbox.leftMiddle();\n break;\n case 'right':\n anchor = bbox.rightMiddle();\n break;\n case 'top':\n anchor = bbox.topMiddle();\n break;\n case 'bottom':\n anchor = bbox.bottomMiddle();\n break;\n }\n\n return (rotate) ? anchor.rotate(center, -angle) : anchor;\n}\n\n// Can find anchor from model, when there is no selector or the link end\n// is connected to a port\nfunction _modelCenter(view, _magnet, _refPoint, opt, endType) {\n return view.model.getPointFromConnectedLink(this.model, endType).offset(opt.dx, opt.dy);\n}\n\n//joint.anchors\nexport const center = bboxWrapper('center');\nexport const top = bboxWrapper('topMiddle');\nexport const bottom = bboxWrapper('bottomMiddle');\nexport const left = bboxWrapper('leftMiddle');\nexport const right = bboxWrapper('rightMiddle');\nexport const topLeft = bboxWrapper('origin');\nexport const topRight = bboxWrapper('topRight');\nexport const bottomLeft = bboxWrapper('bottomLeft');\nexport const bottomRight = bboxWrapper('corner');\nexport const perpendicular = resolveRef(_perpendicular);\nexport const midSide = resolveRef(_midSide);\nexport const modelCenter = _modelCenter;\n\n","import { PaperLayer } from '../PaperLayer.mjs';\nimport {\n isFunction,\n isString,\n defaults,\n omit,\n assign,\n merge,\n} from '../../util/index.mjs';\nimport V from '../../V/index.mjs';\n\nexport const GridLayer = PaperLayer.extend({\n\n style: {\n 'pointer-events': 'none'\n },\n\n _gridCache: null,\n _gridSettings: null,\n\n init() {\n PaperLayer.prototype.init.apply(this, arguments);\n const { options: { paper }} = this;\n this._gridCache = null;\n this._gridSettings = [];\n this.listenTo(paper, 'transform resize', this.updateGrid);\n },\n\n setGrid(drawGrid) {\n this._gridSettings = this.getGridSettings(drawGrid);\n this.renderGrid();\n },\n\n getGridSettings(drawGrid) {\n const gridSettings = [];\n if (drawGrid) {\n const optionsList = Array.isArray(drawGrid) ? drawGrid : [drawGrid || {}];\n optionsList.forEach((item) => {\n gridSettings.push(...this._resolveDrawGridOption(item));\n });\n }\n return gridSettings;\n },\n\n removeGrid() {\n const { _gridCache: grid } = this;\n if (!grid) return;\n grid.root.remove();\n this._gridCache = null;\n },\n\n renderGrid() {\n\n const { options: { paper }} = this;\n const { _gridSettings: gridSettings } = this;\n\n this.removeGrid();\n\n if (gridSettings.length === 0) return;\n\n const gridSize = paper.options.drawGridSize || paper.options.gridSize;\n if (gridSize <= 1) {\n return;\n }\n\n const refs = this._getGridRefs();\n\n gridSettings.forEach((gridLayerSetting, index) => {\n\n const id = this._getPatternId(index);\n const options = merge({}, gridLayerSetting);\n const { scaleFactor = 1 } = options;\n options.width = gridSize * scaleFactor || 1;\n options.height = gridSize * scaleFactor || 1;\n\n let vPattern;\n if (!refs.exist(id)) {\n vPattern = V('pattern', { id: id, patternUnits: 'userSpaceOnUse' }, V(options.markup));\n refs.add(id, vPattern);\n } else {\n vPattern = refs.get(id);\n }\n\n if (isFunction(options.render)) {\n options.render(vPattern.node.firstChild, options, paper);\n }\n vPattern.attr({\n width: options.width,\n height: options.height\n });\n });\n\n refs.root.appendTo(this.el);\n this.updateGrid();\n },\n\n updateGrid() {\n\n const { _gridCache: grid, _gridSettings: gridSettings, options: { paper }} = this;\n if (!grid) return;\n const { root: vSvg, patterns } = grid;\n const { x, y, width, height } = paper.getArea();\n vSvg.attr({ x, y, width, height });\n for (const patternId in patterns) {\n const vPattern = patterns[patternId];\n vPattern.attr({ x: -x, y: -y });\n }\n gridSettings.forEach((options, index) => {\n if (isFunction(options.update)) {\n const vPattern = patterns[this._getPatternId(index)];\n options.update(vPattern.node.firstChild, options, paper);\n }\n });\n },\n\n _getPatternId(index) {\n return `pattern_${this.options.paper.cid}_${index}`;\n },\n\n _getGridRefs() {\n let { _gridCache: grid } = this;\n if (grid) return grid;\n const defsVEl = V('defs');\n const svgVEl = V('svg', { width: '100%', height: '100%' }, [defsVEl]);\n grid = this._gridCache = {\n root: svgVEl,\n patterns: {},\n add: function(id, patternVEl) {\n const rectVEl = V('rect', { width: '100%', height: '100%', fill: `url(#${id})` });\n defsVEl.append(patternVEl);\n svgVEl.append(rectVEl);\n this.patterns[id] = patternVEl;\n },\n get: function(id) {\n return this.patterns[id];\n },\n exist: function(id) {\n return this.patterns[id] !== undefined;\n }\n };\n return grid;\n },\n\n _resolveDrawGridOption(opt) {\n\n var namespace = this.options.patterns;\n if (isString(opt) && Array.isArray(namespace[opt])) {\n return namespace[opt].map(function(item) {\n return assign({}, item);\n });\n }\n\n var options = opt || { args: [{}] };\n var isArray = Array.isArray(options);\n var name = options.name;\n\n if (!isArray && !name && !options.markup) {\n name = 'dot';\n }\n\n if (name && Array.isArray(namespace[name])) {\n var pattern = namespace[name].map(function(item) {\n return assign({}, item);\n });\n\n var args = Array.isArray(options.args) ? options.args : [options.args || {}];\n\n defaults(args[0], omit(opt, 'args'));\n for (var i = 0; i < args.length; i++) {\n if (pattern[i]) {\n assign(pattern[i], args[i]);\n }\n }\n return pattern;\n }\n\n return isArray ? options : [options];\n },\n\n});\n","import V from '../V/index.mjs';\nimport {\n isNumber,\n assign,\n nextFrame,\n isObject,\n cancelFrame,\n defaults,\n defaultsDeep,\n addClassNamePrefix,\n normalizeSides,\n isFunction,\n isPlainObject,\n getByPath,\n sortElements,\n isString,\n guid,\n normalizeEvent,\n normalizeWheel,\n cap,\n debounce,\n omit,\n result,\n camelCase,\n cloneDeep,\n invoke,\n hashCode,\n filter as _filter,\n parseDOMJSON,\n toArray,\n has\n} from '../util/index.mjs';\nimport { ViewBase } from '../mvc/ViewBase.mjs';\nimport { Rect, Point, toRad } from '../g/index.mjs';\nimport { View, views } from '../mvc/index.mjs';\nimport { CellView } from './CellView.mjs';\nimport { ElementView } from './ElementView.mjs';\nimport { LinkView } from './LinkView.mjs';\nimport { Cell } from './Cell.mjs';\nimport { Graph } from './Graph.mjs';\nimport { LayersNames, PaperLayer } from './PaperLayer.mjs';\nimport * as highlighters from '../highlighters/index.mjs';\nimport * as linkAnchors from '../linkAnchors/index.mjs';\nimport * as connectionPoints from '../connectionPoints/index.mjs';\nimport * as anchors from '../anchors/index.mjs';\n\nimport $ from '../mvc/Dom/index.mjs';\nimport { GridLayer } from './layers/GridLayer.mjs';\n\nconst sortingTypes = {\n NONE: 'sorting-none',\n APPROX: 'sorting-approximate',\n EXACT: 'sorting-exact'\n};\n\nconst WHEEL_CAP = 50;\nconst WHEEL_WAIT_MS = 20;\nconst MOUNT_BATCH_SIZE = 1000;\nconst UPDATE_BATCH_SIZE = Infinity;\nconst MIN_PRIORITY = 9007199254740991; // Number.MAX_SAFE_INTEGER\n\nconst HighlightingTypes = CellView.Highlighting;\n\nconst defaultHighlighting = {\n [HighlightingTypes.DEFAULT]: {\n name: 'stroke',\n options: {\n padding: 3\n }\n },\n [HighlightingTypes.MAGNET_AVAILABILITY]: {\n name: 'addClass',\n options: {\n className: 'available-magnet'\n }\n },\n [HighlightingTypes.ELEMENT_AVAILABILITY]: {\n name: 'addClass',\n options: {\n className: 'available-cell'\n }\n }\n};\n\nconst defaultLayers = [{\n name: LayersNames.GRID,\n}, {\n name: LayersNames.BACK,\n}, {\n name: LayersNames.CELLS,\n}, {\n name: LayersNames.LABELS,\n}, {\n name: LayersNames.FRONT\n}, {\n name: LayersNames.TOOLS\n}];\n\nexport const Paper = View.extend({\n\n className: 'paper',\n\n options: {\n\n width: 800,\n height: 600,\n gridSize: 1,\n // Whether or not to draw the grid lines on the paper's DOM element.\n // e.g drawGrid: true, drawGrid: { color: 'red', thickness: 2 }\n drawGrid: false,\n // If not set, the size of the visual grid is the same as the `gridSize`.\n drawGridSize: null,\n\n // Whether or not to draw the background on the paper's DOM element.\n // e.g. background: { color: 'lightblue', image: '/paper-background.png', repeat: 'flip-xy' }\n background: false,\n\n elementView: ElementView,\n linkView: LinkView,\n snapLabels: false, // false, true\n snapLinks: false, // false, true, { radius: value }\n snapLinksSelf: false, // false, true, { radius: value }\n\n // Should the link labels be rendered into its own layer?\n // `false` - the labels are part of the links\n // `true` - the labels are appended to LayersName.LABELS\n // [LayersName] - the labels are appended to the layer specified\n labelsLayer: false,\n\n // When set to FALSE, an element may not have more than 1 link with the same source and target element.\n multiLinks: true,\n\n // For adding custom guard logic.\n guard: function(evt, view) {\n\n // FALSE means the event isn't guarded.\n return false;\n },\n\n highlighting: defaultHighlighting,\n\n // Prevent the default context menu from being displayed.\n preventContextMenu: true,\n\n // Prevent the default action for blank:pointer<action>.\n preventDefaultBlankAction: true,\n\n // Prevent the default action for cell:pointer<action>.\n preventDefaultViewAction: true,\n\n // Restrict the translation of elements by given bounding box.\n // Option accepts a boolean:\n // true - the translation is restricted to the paper area\n // false - no restrictions\n // A method:\n // restrictTranslate: function(elementView) {\n // var parentId = elementView.model.get('parent');\n // return parentId && this.model.getCell(parentId).getBBox();\n // },\n // Or a bounding box:\n // restrictTranslate: { x: 10, y: 10, width: 790, height: 590 }\n restrictTranslate: false,\n\n // Marks all available magnets with 'available-magnet' class name and all available cells with\n // 'available-cell' class name. Marks them when dragging a link is started and unmark\n // when the dragging is stopped.\n markAvailable: false,\n\n // Defines what link model is added to the graph after an user clicks on an active magnet.\n // Value could be the mvc.model or a function returning the mvc.model\n // defaultLink: (elementView, magnet) => {\n // return condition ? new customLink1() : new customLink2()\n // }\n defaultLink: function() {\n // Do not create hard dependency on the joint.shapes.standard namespace (by importing the standard.Link model directly)\n const { cellNamespace } = this.model.get('cells');\n const ctor = getByPath(cellNamespace, ['standard', 'Link']);\n if (!ctor) throw new Error('dia.Paper: no default link model found. Use `options.defaultLink` to specify a default link model.');\n return new ctor();\n },\n\n // A connector that is used by links with no connector defined on the model.\n // e.g. { name: 'rounded', args: { radius: 5 }} or a function\n defaultConnector: { name: 'normal' },\n\n // A router that is used by links with no router defined on the model.\n // e.g. { name: 'oneSide', args: { padding: 10 }} or a function\n defaultRouter: { name: 'normal' },\n\n defaultAnchor: { name: 'center' },\n\n defaultLinkAnchor: { name: 'connectionRatio' },\n\n defaultConnectionPoint: { name: 'boundary' },\n\n /* CONNECTING */\n\n connectionStrategy: null,\n\n // Check whether to add a new link to the graph when user clicks on an a magnet.\n validateMagnet: function(_cellView, magnet, _evt) {\n return magnet.getAttribute('magnet') !== 'passive';\n },\n\n // Check whether to allow or disallow the link connection while an arrowhead end (source/target)\n // being changed.\n validateConnection: function(cellViewS, _magnetS, cellViewT, _magnetT, end, _linkView) {\n return (end === 'target' ? cellViewT : cellViewS) instanceof ElementView;\n },\n\n /* EMBEDDING */\n\n // Enables embedding. Re-parent the dragged element with elements under it and makes sure that\n // all links and elements are visible taken the level of embedding into account.\n embeddingMode: false,\n\n // Check whether to allow or disallow the element embedding while an element being translated.\n validateEmbedding: function(childView, parentView) {\n // by default all elements can be in relation child-parent\n return true;\n },\n\n // Check whether to allow or disallow an embedded element to be unembedded / to become a root.\n validateUnembedding: function(childView) {\n // by default all elements can become roots\n return true;\n },\n\n // Determines the way how a cell finds a suitable parent when it's dragged over the paper.\n // The cell with the highest z-index (visually on the top) will be chosen.\n findParentBy: 'bbox', // 'bbox'|'center'|'origin'|'corner'|'topRight'|'bottomLeft'\n\n // If enabled only the element on the very front is taken into account for the embedding.\n // If disabled the elements under the dragged view are tested one by one\n // (from front to back) until a valid parent found.\n frontParentOnly: true,\n\n // Interactive flags. See online docs for the complete list of interactive flags.\n interactive: {\n labelMove: false\n },\n\n // When set to true the links can be pinned to the paper.\n // i.e. link source/target can be a point e.g. link.get('source') ==> { x: 100, y: 100 };\n linkPinning: true,\n\n // Custom validation after an interaction with a link ends.\n // Recognizes a function. If `false` is returned, the link is disallowed (removed or reverted)\n // (linkView, paper) => boolean\n allowLink: null,\n\n // Allowed number of mousemove events after which the pointerclick event will be still triggered.\n clickThreshold: 0,\n\n // Number of required mousemove events before the first pointermove event will be triggered.\n moveThreshold: 0,\n\n // Number of required mousemove events before a link is created out of the magnet.\n // Or string `onleave` so the link is created when the pointer leaves the magnet\n magnetThreshold: 0,\n\n // Rendering Options\n\n sorting: sortingTypes.APPROX,\n\n frozen: false,\n\n autoFreeze: false,\n\n // no docs yet\n onViewUpdate: function(view, flag, priority, opt, paper) {\n // Do not update connected links when:\n // 1. the view was just inserted (added to the graph and rendered)\n // 2. the view was just mounted (added back to the paper by viewport function)\n // 3. the change was marked as `isolate`.\n // 4. the view model was just removed from the graph\n if ((flag & (view.FLAG_INSERT | view.FLAG_REMOVE)) || opt.mounting || opt.isolate) return;\n paper.requestConnectedLinksUpdate(view, priority, opt);\n },\n\n // no docs yet\n onViewPostponed: function(view, flag, paper) {\n return paper.forcePostponedViewUpdate(view, flag);\n },\n\n beforeRender: null, // function(opt, paper) { },\n\n afterRender: null, // function(stats, opt, paper) {\n\n viewport: null,\n\n // Default namespaces\n\n cellViewNamespace: null,\n\n routerNamespace: null,\n\n connectorNamespace: null,\n\n highlighterNamespace: highlighters,\n\n anchorNamespace: anchors,\n\n linkAnchorNamespace: linkAnchors,\n\n connectionPointNamespace: connectionPoints,\n\n overflow: false\n },\n\n events: {\n 'dblclick': 'pointerdblclick',\n 'dbltap': 'pointerdblclick',\n 'contextmenu': 'contextmenu',\n 'mousedown': 'pointerdown',\n 'touchstart': 'pointerdown',\n 'mouseover': 'mouseover',\n 'mouseout': 'mouseout',\n 'mouseenter': 'mouseenter',\n 'mouseleave': 'mouseleave',\n 'wheel': 'mousewheel',\n 'mouseenter .joint-cell': 'mouseenter',\n 'mouseleave .joint-cell': 'mouseleave',\n 'mouseenter .joint-tools': 'mouseenter',\n 'mouseleave .joint-tools': 'mouseleave',\n 'dblclick .joint-cell [magnet]': 'magnetpointerdblclick',\n 'contextmenu .joint-cell [magnet]': 'magnetcontextmenu',\n 'mousedown .joint-link .label': 'onlabel', // interaction with link label\n 'touchstart .joint-link .label': 'onlabel',\n 'dragstart .joint-cell image': 'onImageDragStart' // firefox fix\n },\n\n documentEvents: {\n 'mousemove': 'pointermove',\n 'touchmove': 'pointermove',\n 'mouseup': 'pointerup',\n 'touchend': 'pointerup',\n 'touchcancel': 'pointerup'\n },\n\n /* CSS within the SVG document\n * 1. Adding vector-effect: non-scaling-stroke; to prevent the stroke width from scaling for\n * elements that use the `scalable` group.\n */\n stylesheet: /*css*/`\n .joint-element .scalable * {\n vector-effect: non-scaling-stroke;\n }\n `,\n\n svg: null,\n viewport: null,\n defs: null,\n tools: null,\n layers: null,\n\n // For storing the current transformation matrix (CTM) of the paper's viewport.\n _viewportMatrix: null,\n // For verifying whether the CTM is up-to-date. The viewport transform attribute\n // could have been manipulated directly.\n _viewportTransformString: null,\n // Updates data (priorities, unmounted views etc.)\n _updates: null,\n // Paper Layers\n _layers: null,\n\n SORT_DELAYING_BATCHES: ['add', 'to-front', 'to-back'],\n UPDATE_DELAYING_BATCHES: ['translate'],\n // If you interact with these elements,\n // the default interaction such as `element move` is prevented.\n FORM_CONTROL_TAG_NAMES: ['TEXTAREA', 'INPUT', 'BUTTON', 'SELECT', 'OPTION'] ,\n // If you interact with these elements, the events are not propagated to the paper\n // i.e. paper events such as `element:pointerdown` are not triggered.\n GUARDED_TAG_NAMES: [\n // Guard <select> for consistency. When you click on it:\n // Chrome: triggers `pointerdown`, `pointerup`, `pointerclick` to open\n // Firefox: triggers `pointerdown` on open, `pointerup` (and `pointerclick` only if you haven't moved).\n // on close. However, if you open and then close by clicking elsewhere on the page,\n // no other event is triggered.\n // Safari: when you open it, it triggers `pointerdown`. That's it.\n 'SELECT',\n ],\n MIN_SCALE: 1e-6,\n\n // Default find buffer for the findViewsInArea and findViewsAtPoint methods.\n // The find buffer is used to extend the area of the search\n // to mitigate the differences between the model and view geometry.\n DEFAULT_FIND_BUFFER: 200,\n\n init: function() {\n\n const { options } = this;\n if (!options.cellViewNamespace) {\n /* eslint-disable no-undef */\n options.cellViewNamespace = typeof joint !== 'undefined' && has(joint, 'shapes') ? joint.shapes : null;\n /* eslint-enable no-undef */\n }\n\n const model = this.model = options.model || new Graph;\n\n // Layers (SVGGroups)\n this._layers = {};\n\n this.cloneOptions();\n this.render();\n this._setDimensions();\n this.startListening();\n\n // Hash of all cell views.\n this._views = {};\n\n // Mouse wheel events buffer\n this._mw_evt_buffer = {\n event: null,\n deltas: [],\n };\n\n // Render existing cells in the graph\n this.resetViews(model.attributes.cells.models);\n // Start the Rendering Loop\n if (!this.isFrozen() && this.isAsync()) this.updateViewsAsync();\n },\n\n _resetUpdates: function() {\n if (this._updates && this._updates.id) cancelFrame(this._updates.id);\n\n return this._updates = {\n id: null,\n priorities: [{}, {}, {}],\n unmountedCids: [],\n mountedCids: [],\n unmounted: {},\n mounted: {},\n count: 0,\n keyFrozen: false,\n freezeKey: null,\n sort: false,\n disabled: false,\n idle: false\n };\n },\n\n startListening: function() {\n var model = this.model;\n this.listenTo(model, 'add', this.onCellAdded)\n .listenTo(model, 'remove', this.onCellRemoved)\n .listenTo(model, 'change', this.onCellChange)\n .listenTo(model, 'reset', this.onGraphReset)\n .listenTo(model, 'sort', this.onGraphSort)\n .listenTo(model, 'batch:stop', this.onGraphBatchStop);\n this.on('cell:highlight', this.onCellHighlight)\n .on('cell:unhighlight', this.onCellUnhighlight)\n .on('transform', this.update);\n },\n\n onCellAdded: function(cell, _, opt) {\n var position = opt.position;\n if (this.isAsync() || !isNumber(position)) {\n this.renderView(cell, opt);\n } else {\n if (opt.maxPosition === position) this.freeze({ key: 'addCells' });\n this.renderView(cell, opt);\n if (position === 0) this.unfreeze({ key: 'addCells' });\n }\n },\n\n onCellRemoved: function(cell, _, opt) {\n const view = this.findViewByModel(cell);\n if (view) this.requestViewUpdate(view, view.FLAG_REMOVE, view.UPDATE_PRIORITY, opt);\n },\n\n onCellChange: function(cell, opt) {\n if (cell === this.model.attributes.cells) return;\n if (cell.hasChanged('z') && this.options.sorting === sortingTypes.APPROX) {\n const view = this.findViewByModel(cell);\n if (view) this.requestViewUpdate(view, view.FLAG_INSERT, view.UPDATE_PRIORITY, opt);\n }\n },\n\n onGraphReset: function(collection, opt) {\n this.resetLayers();\n this.resetViews(collection.models, opt);\n },\n\n onGraphSort: function() {\n if (this.model.hasActiveBatch(this.SORT_DELAYING_BATCHES)) return;\n this.sortViews();\n },\n\n onGraphBatchStop: function(data) {\n if (this.isFrozen()) return;\n var name = data && data.batchName;\n var graph = this.model;\n if (!this.isAsync()) {\n var updateDelayingBatches = this.UPDATE_DELAYING_BATCHES;\n if (updateDelayingBatches.includes(name) && !graph.hasActiveBatch(updateDelayingBatches)) {\n this.updateViews(data);\n }\n }\n var sortDelayingBatches = this.SORT_DELAYING_BATCHES;\n if (sortDelayingBatches.includes(name) && !graph.hasActiveBatch(sortDelayingBatches)) {\n this.sortViews();\n }\n },\n\n cloneOptions: function() {\n\n const { options } = this;\n const {\n defaultConnector,\n defaultRouter,\n defaultConnectionPoint,\n defaultAnchor,\n defaultLinkAnchor,\n highlighting,\n cellViewNamespace,\n interactive\n } = options;\n\n // Default cellView namespace for ES5\n /* eslint-disable no-undef */\n if (!cellViewNamespace && typeof joint !== 'undefined' && has(joint, 'shapes')) {\n options.cellViewNamespace = joint.shapes;\n }\n /* eslint-enable no-undef */\n\n // Here if a function was provided, we can not clone it, as this would result in loosing the function.\n // If the default is used, the cloning is necessary in order to prevent modifying the options on prototype.\n if (!isFunction(defaultConnector)) {\n options.defaultConnector = cloneDeep(defaultConnector);\n }\n if (!isFunction(defaultRouter)) {\n options.defaultRouter = cloneDeep(defaultRouter);\n }\n if (!isFunction(defaultConnectionPoint)) {\n options.defaultConnectionPoint = cloneDeep(defaultConnectionPoint);\n }\n if (!isFunction(defaultAnchor)) {\n options.defaultAnchor = cloneDeep(defaultAnchor);\n }\n if (!isFunction(defaultLinkAnchor)) {\n options.defaultLinkAnchor = cloneDeep(defaultLinkAnchor);\n }\n if (isPlainObject(interactive)) {\n options.interactive = assign({}, interactive);\n }\n if (isPlainObject(highlighting)) {\n // Return the default highlighting options into the user specified options.\n options.highlighting = defaultsDeep({}, highlighting, defaultHighlighting);\n }\n },\n\n children: function() {\n var ns = V.namespace;\n return [{\n namespaceURI: ns.xhtml,\n tagName: 'div',\n className: addClassNamePrefix('paper-background'),\n selector: 'background',\n style: {\n position: 'absolute',\n inset: 0\n }\n }, {\n namespaceURI: ns.svg,\n tagName: 'svg',\n attributes: {\n 'width': '100%',\n 'height': '100%',\n 'xmlns:xlink': ns.xlink\n },\n selector: 'svg',\n style: {\n position: 'absolute',\n inset: 0\n },\n children: [{\n // Append `<defs>` element to the SVG document. This is useful for filters and gradients.\n // It's desired to have the defs defined before the viewport (e.g. to make a PDF document pick up defs properly).\n tagName: 'defs',\n selector: 'defs'\n }, {\n tagName: 'g',\n className: addClassNamePrefix('layers'),\n selector: 'layers'\n }]\n }];\n },\n\n hasLayerView(layerName) {\n return (layerName in this._layers);\n },\n\n getLayerView(layerName) {\n const { _layers } = this;\n if (layerName in _layers) return _layers[layerName];\n throw new Error(`dia.Paper: Unknown layer \"${layerName}\"`);\n },\n\n getLayerNode(layerName) {\n return this.getLayerView(layerName).el;\n },\n\n render: function() {\n\n this.renderChildren();\n const { el, childNodes, options, stylesheet } = this;\n const { svg, defs, layers } = childNodes;\n\n el.style.position = 'relative';\n svg.style.overflow = options.overflow ? 'visible' : 'hidden';\n\n this.svg = svg;\n this.defs = defs;\n this.layers = layers;\n\n this.renderLayers();\n\n V.ensureId(svg);\n\n this.addStylesheet(stylesheet);\n\n if (options.background) {\n this.drawBackground(options.background);\n }\n\n if (options.drawGrid) {\n this.setGrid(options.drawGrid);\n }\n\n return this;\n },\n\n addStylesheet: function(css) {\n if (!css) return;\n V(this.svg).prepend(V.createSVGStyle(css));\n },\n\n createLayer(name) {\n switch (name) {\n case LayersNames.GRID:\n return new GridLayer({ name, paper: this, patterns: this.constructor.gridPatterns });\n default:\n return new PaperLayer({ name });\n }\n },\n\n renderLayers: function(layers = defaultLayers) {\n this.removeLayers();\n // TODO: Layers to be read from the graph `layers` attribute\n layers.forEach(({ name, sorted }) => {\n const layerView = this.createLayer(name);\n this.layers.appendChild(layerView.el);\n this._layers[name] = layerView;\n });\n // Throws an exception if doesn't exist\n const cellsLayerView = this.getLayerView(LayersNames.CELLS);\n const toolsLayerView = this.getLayerView(LayersNames.TOOLS);\n const labelsLayerView = this.getLayerView(LayersNames.LABELS);\n // backwards compatibility\n this.tools = toolsLayerView.el;\n this.cells = this.viewport = cellsLayerView.el;\n // user-select: none;\n cellsLayerView.vel.addClass(addClassNamePrefix('viewport'));\n labelsLayerView.vel.addClass(addClassNamePrefix('viewport'));\n cellsLayerView.el.style.webkitUserSelect = 'none';\n cellsLayerView.el.style.userSelect = 'none';\n labelsLayerView.el.style.webkitUserSelect = 'none';\n labelsLayerView.el.style.userSelect = 'none';\n },\n\n removeLayers: function() {\n const { _layers } = this;\n Object.keys(_layers).forEach(name => {\n _layers[name].remove();\n delete _layers[name];\n });\n },\n\n resetLayers: function() {\n const { _layers } = this;\n Object.keys(_layers).forEach(name => {\n _layers[name].removePivots();\n });\n },\n\n update: function() {\n\n if (this._background) {\n this.updateBackgroundImage(this._background);\n }\n\n return this;\n },\n\n scale: function(sx, sy, data) {\n const ctm = this.matrix();\n // getter\n if (sx === undefined) {\n return V.matrixToScale(ctm);\n }\n // setter\n if (sy === undefined) {\n sy = sx;\n }\n sx = Math.max(sx || 0, this.MIN_SCALE);\n sy = Math.max(sy || 0, this.MIN_SCALE);\n ctm.a = sx;\n ctm.d = sy;\n this.matrix(ctm, data);\n return this;\n },\n\n scaleUniformAtPoint: function(scale, point, data) {\n const { a: sx, d: sy, e: tx, f: ty } = this.matrix();\n scale = Math.max(scale || 0, this.MIN_SCALE);\n if (scale === sx && scale === sy) {\n // The scale is the same as the current one.\n return this;\n }\n const matrix = V.createSVGMatrix()\n .translate(\n tx - point.x * (scale - sx),\n ty - point.y * (scale - sy)\n )\n .scale(scale, scale);\n this.matrix(matrix, data);\n return this;\n },\n\n translate: function(tx, ty, data) {\n const ctm = this.matrix();\n // getter\n if (tx === undefined) {\n return V.matrixToTranslate(ctm);\n }\n // setter\n tx || (tx = 0);\n ty || (ty = 0);\n if (ctm.e === tx && ctm.f === ty) return this;\n ctm.e = tx;\n ctm.f = ty;\n this.matrix(ctm, data);\n return this;\n },\n\n matrix: function(ctm, data = {}) {\n\n var viewport = this.layers;\n\n // Getter:\n if (ctm === undefined) {\n\n var transformString = viewport.getAttribute('transform');\n\n if ((this._viewportTransformString || null) === transformString) {\n // It's ok to return the cached matrix. The transform attribute has not changed since\n // the matrix was stored.\n ctm = this._viewportMatrix;\n } else {\n // The viewport transform attribute has changed. Measure the matrix and cache again.\n ctm = viewport.getCTM();\n this._viewportMatrix = ctm;\n this._viewportTransformString = transformString;\n }\n\n // Clone the cached current transformation matrix.\n // If no matrix previously stored the identity matrix is returned.\n return V.createSVGMatrix(ctm);\n }\n\n // Setter:\n const prev = this.matrix();\n const current = V.createSVGMatrix(ctm);\n const currentTransformString = this._viewportTransformString;\n const ctmString = V.matrixToTransformString(current);\n if (ctmString === currentTransformString) {\n // The new transform string is the same as the current one.\n // No need to update the transform attribute.\n return this;\n }\n if (!currentTransformString && V.matrixToTransformString() === ctmString) {\n // The current transform string is empty and the new one is an identity matrix.\n // No need to update the transform attribute.\n return this;\n }\n\n const { a, d, e, f } = current;\n\n viewport.setAttribute('transform', ctmString);\n this._viewportMatrix = current;\n this._viewportTransformString = viewport.getAttribute('transform');\n\n // scale event\n if (a !== prev.a || d !== prev.d) {\n this.trigger('scale', a, d, data);\n }\n\n // translate event\n if (e !== prev.e || f !== prev.f) {\n this.trigger('translate', e, f, data);\n }\n\n this.trigger('transform', current, data);\n return this;\n },\n\n clientMatrix: function() {\n\n return V.createSVGMatrix(this.cells.getScreenCTM());\n },\n\n requestConnectedLinksUpdate: function(view, priority, opt) {\n if (view instanceof CellView) {\n var model = view.model;\n var links = this.model.getConnectedLinks(model);\n for (var j = 0, n = links.length; j < n; j++) {\n var link = links[j];\n var linkView = this.findViewByModel(link);\n if (!linkView) continue;\n var flagLabels = ['UPDATE'];\n if (link.getTargetCell() === model) flagLabels.push('TARGET');\n if (link.getSourceCell() === model) flagLabels.push('SOURCE');\n var nextPriority = Math.max(priority + 1, linkView.UPDATE_PRIORITY);\n this.scheduleViewUpdate(linkView, linkView.getFlag(flagLabels), nextPriority, opt);\n }\n }\n },\n\n forcePostponedViewUpdate: function(view, flag) {\n if (!view || !(view instanceof CellView)) return false;\n var model = view.model;\n if (model.isElement()) return false;\n if ((flag & view.getFlag(['SOURCE', 'TARGET'])) === 0) {\n var dumpOptions = { silent: true };\n // LinkView is waiting for the target or the source cellView to be rendered\n // This can happen when the cells are not in the viewport.\n var sourceFlag = 0;\n var sourceView = this.findViewByModel(model.getSourceCell());\n if (sourceView && !this.isViewMounted(sourceView)) {\n sourceFlag = this.dumpView(sourceView, dumpOptions);\n view.updateEndMagnet('source');\n }\n var targetFlag = 0;\n var targetView = this.findViewByModel(model.getTargetCell());\n if (targetView && !this.isViewMounted(targetView)) {\n targetFlag = this.dumpView(targetView, dumpOptions);\n view.updateEndMagnet('target');\n }\n if (sourceFlag === 0 && targetFlag === 0) {\n // If leftover flag is 0, all view updates were done.\n return !this.dumpView(view, dumpOptions);\n }\n }\n return false;\n },\n\n requestViewUpdate: function(view, flag, priority, opt) {\n opt || (opt = {});\n this.scheduleViewUpdate(view, flag, priority, opt);\n var isAsync = this.isAsync();\n if (this.isFrozen() || (isAsync && opt.async !== false)) return;\n if (this.model.hasActiveBatch(this.UPDATE_DELAYING_BATCHES)) return;\n var stats = this.updateViews(opt);\n if (isAsync) this.notifyAfterRender(stats, opt);\n },\n\n scheduleViewUpdate: function(view, type, priority, opt) {\n const { _updates: updates, options } = this;\n if (updates.idle) {\n if (options.autoFreeze) {\n updates.idle = false;\n this.unfreeze();\n }\n }\n const { FLAG_REMOVE, FLAG_INSERT, UPDATE_PRIORITY, cid } = view;\n let priorityUpdates = updates.priorities[priority];\n if (!priorityUpdates) priorityUpdates = updates.priorities[priority] = {};\n // Move higher priority updates to this priority\n if (priority > UPDATE_PRIORITY) {\n // Not the default priority for this view. It's most likely a link view\n // connected to another link view, which triggered the update.\n // TODO: If there is an update scheduled with a lower priority already, we should\n // change the requested priority to the lowest one. Does not seem to be critical\n // right now, as it \"only\" results in multiple updates on the same view.\n for (let i = priority - 1; i >= UPDATE_PRIORITY; i--) {\n const prevPriorityUpdates = updates.priorities[i];\n if (!prevPriorityUpdates || !(cid in prevPriorityUpdates)) continue;\n priorityUpdates[cid] |= prevPriorityUpdates[cid];\n delete prevPriorityUpdates[cid];\n }\n }\n let currentType = priorityUpdates[cid] || 0;\n // Prevent cycling\n if ((currentType & type) === type) return;\n if (!currentType) updates.count++;\n if (type & FLAG_REMOVE && currentType & FLAG_INSERT) {\n // When a view is removed we need to remove the insert flag as this is a reinsert\n priorityUpdates[cid] ^= FLAG_INSERT;\n } else if (type & FLAG_INSERT && currentType & FLAG_REMOVE) {\n // When a view is added we need to remove the remove flag as this is view was previously removed\n priorityUpdates[cid] ^= FLAG_REMOVE;\n }\n priorityUpdates[cid] |= type;\n const viewUpdateFn = options.onViewUpdate;\n if (typeof viewUpdateFn === 'function') viewUpdateFn.call(this, view, type, priority, opt || {}, this);\n },\n\n dumpViewUpdate: function(view) {\n if (!view) return 0;\n var updates = this._updates;\n var cid = view.cid;\n var priorityUpdates = updates.priorities[view.UPDATE_PRIORITY];\n var flag = this.registerMountedView(view) | priorityUpdates[cid];\n delete priorityUpdates[cid];\n return flag;\n },\n\n dumpView: function(view, opt = {}) {\n const flag = this.dumpViewUpdate(view);\n if (!flag) return 0;\n const shouldNotify = !opt.silent;\n if (shouldNotify) this.notifyBeforeRender(opt);\n const leftover = this.updateView(view, flag, opt);\n if (shouldNotify) {\n const stats = { updated: 1, priority: view.UPDATE_PRIORITY };\n this.notifyAfterRender(stats, opt);\n }\n return leftover;\n },\n\n updateView: function(view, flag, opt) {\n if (!view) return 0;\n const { FLAG_REMOVE, FLAG_INSERT, FLAG_INIT, model } = view;\n if (view instanceof CellView) {\n if (flag & FLAG_REMOVE) {\n this.removeView(model);\n return 0;\n }\n if (flag & FLAG_INSERT) {\n const isInitialInsert = !!(flag & FLAG_INIT);\n if (isInitialInsert) {\n flag ^= FLAG_INIT;\n }\n this.insertView(view, isInitialInsert);\n flag ^= FLAG_INSERT;\n }\n }\n if (!flag) return 0;\n return view.confirmUpdate(flag, opt || {});\n },\n\n requireView: function(model, opt) {\n var view = this.findViewByModel(model);\n if (!view) return null;\n this.dumpView(view, opt);\n return view;\n },\n\n registerUnmountedView: function(view) {\n var cid = view.cid;\n var updates = this._updates;\n if (cid in updates.unmounted) return 0;\n var flag = updates.unmounted[cid] |= view.FLAG_INSERT;\n updates.unmountedCids.push(cid);\n delete updates.mounted[cid];\n return flag;\n },\n\n registerMountedView: function(view) {\n var cid = view.cid;\n var updates = this._updates;\n if (cid in updates.mounted) return 0;\n updates.mounted[cid] = true;\n updates.mountedCids.push(cid);\n var flag = updates.unmounted[cid] || 0;\n delete updates.unmounted[cid];\n return flag;\n },\n\n isViewMounted: function(view) {\n if (!view) return false;\n var cid = view.cid;\n var updates = this._updates;\n return (cid in updates.mounted);\n },\n\n dumpViews: function(opt) {\n var passingOpt = defaults({}, opt, { viewport: null });\n this.checkViewport(passingOpt);\n this.updateViews(passingOpt);\n },\n\n // Synchronous views update\n updateViews: function(opt) {\n this.notifyBeforeRender(opt);\n let batchStats;\n let updateCount = 0;\n let batchCount = 0;\n let priority = MIN_PRIORITY;\n do {\n batchCount++;\n batchStats = this.updateViewsBatch(opt);\n updateCount += batchStats.updated;\n priority = Math.min(batchStats.priority, priority);\n } while (!batchStats.empty);\n const stats = { updated: updateCount, batches: batchCount, priority };\n this.notifyAfterRender(stats, opt);\n return stats;\n },\n\n hasScheduledUpdates: function() {\n const priorities = this._updates.priorities;\n const priorityIndexes = Object.keys(priorities); // convert priorities to a dense array\n let i = priorityIndexes.length;\n while (i > 0 && i--) {\n // a faster way how to check if an object is empty\n for (let _key in priorities[priorityIndexes[i]]) return true;\n }\n return false;\n },\n\n updateViewsAsync: function(opt, data) {\n opt || (opt = {});\n data || (data = { processed: 0, priority: MIN_PRIORITY });\n const { _updates: updates, options } = this;\n const id = updates.id;\n if (id) {\n cancelFrame(id);\n if (data.processed === 0 && this.hasScheduledUpdates()) {\n this.notifyBeforeRender(opt);\n }\n const stats = this.updateViewsBatch(opt);\n const passingOpt = defaults({}, opt, {\n mountBatchSize: MOUNT_BATCH_SIZE - stats.mounted,\n unmountBatchSize: MOUNT_BATCH_SIZE - stats.unmounted\n });\n const checkStats = this.checkViewport(passingOpt);\n const unmountCount = checkStats.unmounted;\n const mountCount = checkStats.mounted;\n let processed = data.processed;\n const total = updates.count;\n if (stats.updated > 0) {\n // Some updates have been just processed\n processed += stats.updated + stats.unmounted;\n stats.processed = processed;\n data.priority = Math.min(stats.priority, data.priority);\n if (stats.empty && mountCount === 0) {\n stats.unmounted += unmountCount;\n stats.mounted += mountCount;\n stats.priority = data.priority;\n this.notifyAfterRender(stats, opt);\n data.processed = 0;\n data.priority = MIN_PRIORITY;\n updates.count = 0;\n } else {\n data.processed = processed;\n }\n } else {\n if (!updates.idle) {\n if (options.autoFreeze) {\n this.freeze();\n updates.idle = true;\n this.trigger('render:idle', opt);\n }\n }\n }\n // Progress callback\n const progressFn = opt.progress;\n if (total && typeof progressFn === 'function') {\n progressFn.call(this, stats.empty, processed, total, stats, this);\n }\n // The current frame could have been canceled in a callback\n if (updates.id !== id) return;\n }\n if (updates.disabled) {\n throw new Error('dia.Paper: can not unfreeze the paper after it was removed');\n }\n updates.id = nextFrame(this.updateViewsAsync, this, opt, data);\n },\n\n notifyBeforeRender: function(opt = {}) {\n let beforeFn = opt.beforeRender;\n if (typeof beforeFn !== 'function') {\n beforeFn = this.options.beforeRender;\n if (typeof beforeFn !== 'function') return;\n }\n beforeFn.call(this, opt, this);\n },\n\n notifyAfterRender: function(stats, opt = {}) {\n let afterFn = opt.afterRender;\n if (typeof afterFn !== 'function') {\n afterFn = this.options.afterRender;\n }\n if (typeof afterFn === 'function') {\n afterFn.call(this, stats, opt, this);\n }\n this.trigger('render:done', stats, opt);\n },\n\n updateViewsBatch: function(opt) {\n opt || (opt = {});\n var batchSize = opt.batchSize || UPDATE_BATCH_SIZE;\n var updates = this._updates;\n var updateCount = 0;\n var postponeCount = 0;\n var unmountCount = 0;\n var mountCount = 0;\n var maxPriority = MIN_PRIORITY;\n var empty = true;\n var options = this.options;\n var priorities = updates.priorities;\n var viewportFn = 'viewport' in opt ? opt.viewport : options.viewport;\n if (typeof viewportFn !== 'function') viewportFn = null;\n var postponeViewFn = options.onViewPostponed;\n if (typeof postponeViewFn !== 'function') postponeViewFn = null;\n var priorityIndexes = Object.keys(priorities); // convert priorities to a dense array\n main: for (var i = 0, n = priorityIndexes.length; i < n; i++) {\n var priority = +priorityIndexes[i];\n var priorityUpdates = priorities[priority];\n for (var cid in priorityUpdates) {\n if (updateCount >= batchSize) {\n empty = false;\n break main;\n }\n var view = views[cid];\n if (!view) {\n // This should not occur\n delete priorityUpdates[cid];\n continue;\n }\n var currentFlag = priorityUpdates[cid];\n if ((currentFlag & view.FLAG_REMOVE) === 0) {\n // We should never check a view for viewport if we are about to remove the view\n var isDetached = cid in updates.unmounted;\n if (view.DETACHABLE && viewportFn && !viewportFn.call(this, view, !isDetached, this)) {\n // Unmount View\n if (!isDetached) {\n this.registerUnmountedView(view);\n this.detachView(view);\n }\n updates.unmounted[cid] |= currentFlag;\n delete priorityUpdates[cid];\n unmountCount++;\n continue;\n }\n // Mount View\n if (isDetached) {\n currentFlag |= view.FLAG_INSERT;\n mountCount++;\n }\n currentFlag |= this.registerMountedView(view);\n }\n var leftoverFlag = this.updateView(view, currentFlag, opt);\n if (leftoverFlag > 0) {\n // View update has not finished completely\n priorityUpdates[cid] = leftoverFlag;\n if (!postponeViewFn || !postponeViewFn.call(this, view, leftoverFlag, this) || priorityUpdates[cid]) {\n postponeCount++;\n empty = false;\n continue;\n }\n }\n if (maxPriority > priority) maxPriority = priority;\n updateCount++;\n delete priorityUpdates[cid];\n }\n }\n return {\n priority: maxPriority,\n updated: updateCount,\n postponed: postponeCount,\n unmounted: unmountCount,\n mounted: mountCount,\n empty: empty\n };\n },\n\n getUnmountedViews: function() {\n const updates = this._updates;\n const unmountedCids = Object.keys(updates.unmounted);\n const n = unmountedCids.length;\n const unmountedViews = new Array(n);\n for (var i = 0; i < n; i++) {\n unmountedViews[i] = views[unmountedCids[i]];\n }\n return unmountedViews;\n },\n\n getMountedViews: function() {\n const updates = this._updates;\n const mountedCids = Object.keys(updates.mounted);\n const n = mountedCids.length;\n const mountedViews = new Array(n);\n for (var i = 0; i < n; i++) {\n mountedViews[i] = views[mountedCids[i]];\n }\n return mountedViews;\n },\n\n checkUnmountedViews: function(viewportFn, opt) {\n opt || (opt = {});\n var mountCount = 0;\n if (typeof viewportFn !== 'function') viewportFn = null;\n var batchSize = 'mountBatchSize' in opt ? opt.mountBatchSize : Infinity;\n var updates = this._updates;\n var unmountedCids = updates.unmountedCids;\n var unmounted = updates.unmounted;\n for (var i = 0, n = Math.min(unmountedCids.length, batchSize); i < n; i++) {\n var cid = unmountedCids[i];\n if (!(cid in unmounted)) continue;\n var view = views[cid];\n if (!view) continue;\n if (view.DETACHABLE && viewportFn && !viewportFn.call(this, view, false, this)) {\n // Push at the end of all unmounted ids, so this can be check later again\n unmountedCids.push(cid);\n continue;\n }\n mountCount++;\n var flag = this.registerMountedView(view);\n if (flag) this.scheduleViewUpdate(view, flag, view.UPDATE_PRIORITY, { mounting: true });\n }\n // Get rid of views, that have been mounted\n unmountedCids.splice(0, i);\n return mountCount;\n },\n\n checkMountedViews: function(viewportFn, opt) {\n opt || (opt = {});\n var unmountCount = 0;\n if (typeof viewportFn !== 'function') return unmountCount;\n var batchSize = 'unmountBatchSize' in opt ? opt.unmountBatchSize : Infinity;\n var updates = this._updates;\n var mountedCids = updates.mountedCids;\n var mounted = updates.mounted;\n for (var i = 0, n = Math.min(mountedCids.length, batchSize); i < n; i++) {\n var cid = mountedCids[i];\n if (!(cid in mounted)) continue;\n var view = views[cid];\n if (!view) continue;\n if (!view.DETACHABLE || viewportFn.call(this, view, true, this)) {\n // Push at the end of all mounted ids, so this can be check later again\n mountedCids.push(cid);\n continue;\n }\n unmountCount++;\n var flag = this.registerUnmountedView(view);\n if (flag) this.detachView(view);\n }\n // Get rid of views, that have been unmounted\n mountedCids.splice(0, i);\n return unmountCount;\n },\n\n checkViewVisibility: function(cellView, opt = {}) {\n let viewportFn = 'viewport' in opt ? opt.viewport : this.options.viewport;\n if (typeof viewportFn !== 'function') viewportFn = null;\n const updates = this._updates;\n const { mounted, unmounted } = updates;\n const visible = !cellView.DETACHABLE || !viewportFn || viewportFn.call(this, cellView, false, this);\n\n let isUnmounted = false;\n let isMounted = false;\n\n if (cellView.cid in mounted && !visible) {\n const flag = this.registerUnmountedView(cellView);\n if (flag) this.detachView(cellView);\n const i = updates.mountedCids.indexOf(cellView.cid);\n updates.mountedCids.splice(i, 1);\n isUnmounted = true;\n }\n\n if (!isUnmounted && cellView.cid in unmounted && visible) {\n const i = updates.unmountedCids.indexOf(cellView.cid);\n updates.unmountedCids.splice(i, 1);\n var flag = this.registerMountedView(cellView);\n if (flag) this.scheduleViewUpdate(cellView, flag, cellView.UPDATE_PRIORITY, { mounting: true });\n isMounted = true;\n }\n\n return {\n mounted: isMounted ? 1 : 0,\n unmounted: isUnmounted ? 1 : 0\n };\n },\n\n checkViewport: function(opt) {\n var passingOpt = defaults({}, opt, {\n mountBatchSize: Infinity,\n unmountBatchSize: Infinity\n });\n var viewportFn = 'viewport' in passingOpt ? passingOpt.viewport : this.options.viewport;\n var unmountedCount = this.checkMountedViews(viewportFn, passingOpt);\n if (unmountedCount > 0) {\n // Do not check views, that have been just unmounted and pushed at the end of the cids array\n var unmountedCids = this._updates.unmountedCids;\n passingOpt.mountBatchSize = Math.min(unmountedCids.length - unmountedCount, passingOpt.mountBatchSize);\n }\n var mountedCount = this.checkUnmountedViews(viewportFn, passingOpt);\n return {\n mounted: mountedCount,\n unmounted: unmountedCount\n };\n },\n\n freeze: function(opt) {\n opt || (opt = {});\n var updates = this._updates;\n var key = opt.key;\n var isFrozen = this.options.frozen;\n var freezeKey = updates.freezeKey;\n if (key && key !== freezeKey) {\n // key passed, but the paper is already freezed with another key\n if (isFrozen && freezeKey) return;\n updates.freezeKey = key;\n updates.keyFrozen = isFrozen;\n }\n this.options.frozen = true;\n var id = updates.id;\n updates.id = null;\n if (this.isAsync() && id) cancelFrame(id);\n },\n\n unfreeze: function(opt) {\n opt || (opt = {});\n var updates = this._updates;\n var key = opt.key;\n var freezeKey = updates.freezeKey;\n // key passed, but the paper is already freezed with another key\n if (key && freezeKey && key !== freezeKey) return;\n updates.freezeKey = null;\n // key passed, but the paper is already freezed\n if (key && key === freezeKey && updates.keyFrozen) return;\n if (this.isAsync()) {\n this.freeze();\n this.updateViewsAsync(opt);\n } else {\n this.updateViews(opt);\n }\n this.options.frozen = updates.keyFrozen = false;\n if (updates.sort) {\n this.sortViews();\n updates.sort = false;\n }\n },\n\n isAsync: function() {\n return !!this.options.async;\n },\n\n isFrozen: function() {\n return !!this.options.frozen;\n },\n\n isExactSorting: function() {\n return this.options.sorting === sortingTypes.EXACT;\n },\n\n onRemove: function() {\n\n this.freeze();\n this._updates.disabled = true;\n //clean up all DOM elements/views to prevent memory leaks\n this.removeLayers();\n this.removeViews();\n },\n\n getComputedSize: function() {\n\n var options = this.options;\n var w = options.width;\n var h = options.height;\n if (!isNumber(w)) w = this.el.clientWidth;\n if (!isNumber(h)) h = this.el.clientHeight;\n return { width: w, height: h };\n },\n\n setDimensions: function(width, height, data = {}) {\n const { options } = this;\n const { width: currentWidth, height: currentHeight } = options;\n let w = (width === undefined) ? currentWidth : width;\n let h = (height === undefined) ? currentHeight : height;\n if (currentWidth === w && currentHeight === h) return;\n options.width = w;\n options.height = h;\n this._setDimensions();\n const computedSize = this.getComputedSize();\n this.trigger('resize', computedSize.width, computedSize.height, data);\n },\n\n _setDimensions: function() {\n const { options } = this;\n let w = options.width;\n let h = options.height;\n if (isNumber(w)) w = `${Math.round(w)}px`;\n if (isNumber(h)) h = `${Math.round(h)}px`;\n this.$el.css({\n width: (w === null) ? '' : w,\n height: (h === null) ? '' : h\n });\n },\n\n // Expand/shrink the paper to fit the content.\n // Alternatively signature function(opt)\n fitToContent: function(gridWidth, gridHeight, padding, opt) {\n\n if (isObject(gridWidth)) {\n // first parameter is an option object\n opt = gridWidth;\n } else {\n // Support for a deprecated signature\n opt = assign({ gridWidth, gridHeight, padding }, opt);\n }\n\n const { x, y, width, height } = this.getFitToContentArea(opt);\n const { sx, sy } = this.scale();\n\n this.translate(-x * sx, -y * sy, opt);\n this.setDimensions(width * sx, height * sy, opt);\n\n return new Rect(x, y, width, height);\n },\n\n getFitToContentArea: function(opt = {}) {\n\n // Calculate the paper size to accommodate all the graph's elements.\n\n const gridWidth = opt.gridWidth || 1;\n const gridHeight = opt.gridHeight || 1;\n const padding = normalizeSides(opt.padding || 0);\n\n const minWidth = Math.max(opt.minWidth || 0, gridWidth);\n const minHeight = Math.max(opt.minHeight || 0, gridHeight);\n const maxWidth = opt.maxWidth || Number.MAX_VALUE;\n const maxHeight = opt.maxHeight || Number.MAX_VALUE;\n const newOrigin = opt.allowNewOrigin;\n\n const area = ('contentArea' in opt) ? new Rect(opt.contentArea) : this.getContentArea(opt);\n const { sx, sy } = this.scale();\n area.x *= sx;\n area.y *= sy;\n area.width *= sx;\n area.height *= sy;\n\n let calcWidth = Math.ceil((area.width + area.x) / gridWidth);\n let calcHeight = Math.ceil((area.height + area.y) / gridHeight);\n if (!opt.allowNegativeBottomRight) {\n calcWidth = Math.max(calcWidth, 1);\n calcHeight = Math.max(calcHeight, 1);\n }\n calcWidth *= gridWidth;\n calcHeight *= gridHeight;\n\n let tx = 0;\n if ((newOrigin === 'negative' && area.x < 0) || (newOrigin === 'positive' && area.x >= 0) || newOrigin === 'any') {\n tx = Math.ceil(-area.x / gridWidth) * gridWidth;\n tx += padding.left;\n calcWidth += tx;\n }\n\n let ty = 0;\n if ((newOrigin === 'negative' && area.y < 0) || (newOrigin === 'positive' && area.y >= 0) || newOrigin === 'any') {\n ty = Math.ceil(-area.y / gridHeight) * gridHeight;\n ty += padding.top;\n calcHeight += ty;\n }\n\n calcWidth += padding.right;\n calcHeight += padding.bottom;\n\n // Make sure the resulting width and height are greater than minimum.\n calcWidth = Math.max(calcWidth, minWidth);\n calcHeight = Math.max(calcHeight, minHeight);\n\n // Make sure the resulting width and height are lesser than maximum.\n calcWidth = Math.min(calcWidth, maxWidth);\n calcHeight = Math.min(calcHeight, maxHeight);\n\n return new Rect(-tx / sx, -ty / sy, calcWidth / sx, calcHeight / sy);\n },\n\n transformToFitContent: function(opt) {\n opt || (opt = {});\n\n let contentBBox, contentLocalOrigin;\n if ('contentArea' in opt) {\n const contentArea = opt.contentArea;\n contentBBox = this.localToPaperRect(contentArea);\n contentLocalOrigin = new Point(contentArea);\n } else {\n contentBBox = this.getContentBBox(opt);\n contentLocalOrigin = this.paperToLocalPoint(contentBBox);\n }\n\n if (!contentBBox.width || !contentBBox.height) return;\n\n defaults(opt, {\n padding: 0,\n preserveAspectRatio: true,\n scaleGrid: null,\n minScale: 0,\n maxScale: Number.MAX_VALUE,\n verticalAlign: 'top',\n horizontalAlign: 'left',\n //minScaleX\n //minScaleY\n //maxScaleX\n //maxScaleY\n //fittingBBox\n });\n\n const padding = normalizeSides(opt.padding);\n\n const minScaleX = opt.minScaleX || opt.minScale;\n const maxScaleX = opt.maxScaleX || opt.maxScale;\n const minScaleY = opt.minScaleY || opt.minScale;\n const maxScaleY = opt.maxScaleY || opt.maxScale;\n\n let fittingBBox;\n if (opt.fittingBBox) {\n fittingBBox = opt.fittingBBox;\n } else {\n const currentTranslate = this.translate();\n const computedSize = this.getComputedSize();\n fittingBBox = {\n x: currentTranslate.tx,\n y: currentTranslate.ty,\n width: computedSize.width,\n height: computedSize.height\n };\n }\n\n fittingBBox = new Rect(fittingBBox).moveAndExpand({\n x: padding.left,\n y: padding.top,\n width: -padding.left - padding.right,\n height: -padding.top - padding.bottom\n });\n\n const ctm = this.matrix();\n const { a: sx, d: sy, e: tx, f: ty } = ctm;\n\n let newSx = fittingBBox.width / contentBBox.width * sx;\n let newSy = fittingBBox.height / contentBBox.height * sy;\n\n if (opt.preserveAspectRatio) {\n newSx = newSy = Math.min(newSx, newSy);\n }\n\n // snap scale to a grid\n if (opt.scaleGrid) {\n\n const gridSize = opt.scaleGrid;\n\n newSx = gridSize * Math.floor(newSx / gridSize);\n newSy = gridSize * Math.floor(newSy / gridSize);\n }\n\n // scale min/max boundaries\n newSx = Math.min(maxScaleX, Math.max(minScaleX, newSx));\n newSy = Math.min(maxScaleY, Math.max(minScaleY, newSy));\n\n const scaleDiff = {\n x: newSx / sx,\n y: newSy / sy\n };\n\n let newOx = fittingBBox.x - contentLocalOrigin.x * newSx - tx;\n let newOy = fittingBBox.y - contentLocalOrigin.y * newSy - ty;\n\n switch (opt.verticalAlign) {\n case 'middle':\n newOy = newOy + (fittingBBox.height - contentBBox.height * scaleDiff.y) / 2;\n break;\n case 'bottom':\n newOy = newOy + (fittingBBox.height - contentBBox.height * scaleDiff.y);\n break;\n case 'top':\n default:\n break;\n }\n\n switch (opt.horizontalAlign) {\n case 'middle':\n newOx = newOx + (fittingBBox.width - contentBBox.width * scaleDiff.x) / 2;\n break;\n case 'right':\n newOx = newOx + (fittingBBox.width - contentBBox.width * scaleDiff.x);\n break;\n case 'left':\n default:\n break;\n }\n\n ctm.a = newSx;\n ctm.d = newSy;\n ctm.e = newOx;\n ctm.f = newOy;\n this.matrix(ctm, opt);\n },\n\n scaleContentToFit: function(opt) {\n this.transformToFitContent(opt);\n },\n\n // Return the dimensions of the content area in local units (without transformations).\n getContentArea: function(opt) {\n\n if (opt && opt.useModelGeometry) {\n return this.model.getBBox() || new Rect();\n }\n\n return V(this.cells).getBBox();\n },\n\n // Return the dimensions of the content bbox in the paper units (as it appears on screen).\n getContentBBox: function(opt) {\n\n return this.localToPaperRect(this.getContentArea(opt));\n },\n\n // Returns a geometry rectangle representing the entire\n // paper area (coordinates from the left paper border to the right one\n // and the top border to the bottom one).\n getArea: function() {\n\n return this.paperToLocalRect(this.getComputedSize());\n },\n\n getRestrictedArea: function(...args) {\n\n const { restrictTranslate } = this.options;\n\n let restrictedArea;\n if (isFunction(restrictTranslate)) {\n // A method returning a bounding box\n restrictedArea = restrictTranslate.apply(this, args);\n } else if (restrictTranslate === true) {\n // The paper area\n restrictedArea = this.getArea();\n } else if (!restrictTranslate) {\n // falsy value\n restrictedArea = null;\n } else {\n // any other value\n restrictedArea = new Rect(restrictTranslate);\n }\n\n return restrictedArea;\n },\n\n createViewForModel: function(cell) {\n\n const { options } = this;\n // A class taken from the paper options.\n var optionalViewClass;\n\n // A default basic class (either dia.ElementView or dia.LinkView)\n var defaultViewClass;\n\n // A special class defined for this model in the corresponding namespace.\n // e.g. joint.shapes.standard.Rectangle searches for joint.shapes.standard.RectangleView\n var namespace = options.cellViewNamespace;\n var type = cell.get('type') + 'View';\n var namespaceViewClass = getByPath(namespace, type, '.');\n\n if (cell.isLink()) {\n optionalViewClass = options.linkView;\n defaultViewClass = LinkView;\n } else {\n optionalViewClass = options.elementView;\n defaultViewClass = ElementView;\n }\n\n // a) the paper options view is a class (deprecated)\n // 1. search the namespace for a view\n // 2. if no view was found, use view from the paper options\n // b) the paper options view is a function\n // 1. call the function from the paper options\n // 2. if no view was return, search the namespace for a view\n // 3. if no view was found, use the default\n var ViewClass = (optionalViewClass.prototype instanceof ViewBase)\n ? namespaceViewClass || optionalViewClass\n : optionalViewClass.call(this, cell) || namespaceViewClass || defaultViewClass;\n\n return new ViewClass({\n model: cell,\n interactive: options.interactive,\n labelsLayer: options.labelsLayer === true ? LayersNames.LABELS : options.labelsLayer\n });\n },\n\n removeView: function(cell) {\n\n const { id } = cell;\n const { _views, _updates } = this;\n const view = _views[id];\n if (view) {\n var { cid } = view;\n const { mounted, unmounted } = _updates;\n view.remove();\n delete _views[id];\n delete mounted[cid];\n delete unmounted[cid];\n }\n return view;\n },\n\n renderView: function(cell, opt) {\n\n const { id } = cell;\n const views = this._views;\n let view, flag;\n let create = true;\n if (id in views) {\n view = views[id];\n if (view.model === cell) {\n flag = view.FLAG_INSERT;\n create = false;\n } else {\n // The view for this `id` already exist.\n // The cell is a new instance of the model with identical id\n // We simply remove the existing view and create a new one\n this.removeView(cell);\n }\n }\n if (create) {\n view = views[id] = this.createViewForModel(cell);\n view.paper = this;\n flag = this.registerUnmountedView(view) | this.FLAG_INIT | view.getFlag(result(view, 'initFlag'));\n }\n this.requestViewUpdate(view, flag, view.UPDATE_PRIORITY, opt);\n return view;\n },\n\n onImageDragStart: function() {\n // This is the only way to prevent image dragging in Firefox that works.\n // Setting -moz-user-select: none, draggable=\"false\" attribute or user-drag: none didn't help.\n\n return false;\n },\n\n resetViews: function(cells, opt) {\n opt || (opt = {});\n cells || (cells = []);\n this._resetUpdates();\n // clearing views removes any event listeners\n this.removeViews();\n // Allows to unfreeze normally while in the idle state using autoFreeze option\n const key = this.options.autoFreeze ? null : 'reset';\n this.freeze({ key });\n for (var i = 0, n = cells.length; i < n; i++) {\n this.renderView(cells[i], opt);\n }\n this.unfreeze({ key });\n this.sortViews();\n },\n\n removeViews: function() {\n\n invoke(this._views, 'remove');\n\n this._views = {};\n },\n\n sortViews: function() {\n\n if (!this.isExactSorting()) {\n // noop\n return;\n }\n if (this.isFrozen()) {\n // sort views once unfrozen\n this._updates.sort = true;\n return;\n }\n this.sortViewsExact();\n },\n\n sortViewsExact: function() {\n\n // Run insertion sort algorithm in order to efficiently sort DOM elements according to their\n // associated model `z` attribute.\n\n var cellNodes = Array.from(this.cells.childNodes).filter(node => node.getAttribute('model-id'));\n var cells = this.model.get('cells');\n\n sortElements(cellNodes, function(a, b) {\n var cellA = cells.get(a.getAttribute('model-id'));\n var cellB = cells.get(b.getAttribute('model-id'));\n var zA = cellA.attributes.z || 0;\n var zB = cellB.attributes.z || 0;\n return (zA === zB) ? 0 : (zA < zB) ? -1 : 1;\n });\n },\n\n insertView: function(view, isInitialInsert) {\n const layerView = this.getLayerView(LayersNames.CELLS);\n const { el, model } = view;\n switch (this.options.sorting) {\n case sortingTypes.APPROX:\n layerView.insertSortedNode(el, model.get('z'));\n break;\n case sortingTypes.EXACT:\n default:\n layerView.insertNode(el);\n break;\n }\n view.onMount(isInitialInsert);\n },\n\n detachView(view) {\n view.unmount();\n view.onDetach();\n },\n\n // Find the first view climbing up the DOM tree starting at element `el`. Note that `el` can also\n // be a selector or a jQuery object.\n findView: function($el) {\n\n var el = isString($el)\n ? this.cells.querySelector($el)\n : $el instanceof $ ? $el[0] : $el;\n\n var id = this.findAttribute('model-id', el);\n if (id) return this._views[id];\n\n return undefined;\n },\n\n // Find a view for a model `cell`. `cell` can also be a string or number representing a model `id`.\n findViewByModel: function(cell) {\n\n var id = (isString(cell) || isNumber(cell)) ? cell : (cell && cell.id);\n\n return this._views[id];\n },\n\n // Find all views at given point\n findViewsFromPoint: function(p) {\n\n p = new Point(p);\n\n var views = this.model.getElements().map(this.findViewByModel, this);\n\n return views.filter(function(view) {\n return view && view.vel.getBBox({ target: this.cells }).containsPoint(p);\n }, this);\n },\n\n // Find all views in given area\n findViewsInArea: function(rect, opt) {\n\n opt = defaults(opt || {}, { strict: false });\n rect = new Rect(rect);\n\n var views = this.model.getElements().map(this.findViewByModel, this);\n var method = opt.strict ? 'containsRect' : 'intersect';\n\n return views.filter(function(view) {\n return view && rect[method](view.vel.getBBox({ target: this.cells }));\n }, this);\n },\n\n findElementViewsInArea(plainArea, opt) {\n return this._filterViewsInArea(\n plainArea,\n (extArea, findOpt) => this.model.findElementsInArea(extArea, findOpt),\n opt\n );\n },\n\n findLinkViewsInArea: function(plainArea, opt) {\n return this._filterViewsInArea(\n plainArea,\n (extArea, findOpt) => this.model.findLinksInArea(extArea, findOpt),\n opt\n );\n },\n\n findCellViewsInArea: function(plainArea, opt) {\n return this._filterViewsInArea(\n plainArea,\n (extArea, findOpt) => this.model.findCellsInArea(extArea, findOpt),\n opt\n );\n },\n\n findElementViewsAtPoint: function(plainPoint, opt) {\n return this._filterViewsAtPoint(\n plainPoint,\n (extArea) => this.model.findElementsInArea(extArea),\n opt\n );\n },\n\n findLinkViewsAtPoint: function(plainPoint, opt) {\n return this._filterViewsAtPoint(\n plainPoint,\n (extArea) => this.model.findLinksInArea(extArea),\n opt,\n );\n },\n\n findCellViewsAtPoint: function(plainPoint, opt) {\n return this._filterViewsAtPoint(\n plainPoint,\n // Note: we do not want to pass `opt` to `findCellsInArea`\n // because the `strict` option works differently for querying at a point\n (extArea) => this.model.findCellsInArea(extArea),\n opt\n );\n },\n\n _findInExtendedArea: function(area, findCellsFn, opt = {}) {\n const {\n buffer = this.DEFAULT_FIND_BUFFER,\n } = opt;\n const extendedArea = (new Rect(area)).inflate(buffer);\n const cellsInExtendedArea = findCellsFn(extendedArea, opt);\n return cellsInExtendedArea.map(element => this.findViewByModel(element));\n },\n\n _filterViewsInArea: function(plainArea, findCells, opt = {}) {\n const area = new Rect(plainArea);\n const viewsInExtendedArea = this._findInExtendedArea(area, findCells, opt);\n const viewsInArea = viewsInExtendedArea.filter(view => {\n if (!view) return false;\n return view.isInArea(area, opt);\n });\n return viewsInArea;\n },\n\n _filterViewsAtPoint: function(plainPoint, findCells, opt = {}) {\n const area = new Rect(plainPoint); // zero-size area\n const viewsInExtendedArea = this._findInExtendedArea(area, findCells, opt);\n const viewsAtPoint = viewsInExtendedArea.filter(view => {\n if (!view) return false;\n return view.isAtPoint(plainPoint, opt);\n });\n return viewsAtPoint;\n },\n\n removeTools: function() {\n this.dispatchToolsEvent('remove');\n return this;\n },\n\n hideTools: function() {\n this.dispatchToolsEvent('hide');\n return this;\n },\n\n showTools: function() {\n this.dispatchToolsEvent('show');\n return this;\n },\n\n dispatchToolsEvent: function(event, ...args) {\n if (typeof event !== 'string') return;\n this.trigger('tools:event', event, ...args);\n },\n\n\n getModelById: function(id) {\n\n return this.model.getCell(id);\n },\n\n snapToGrid: function(x, y) {\n\n // Convert global coordinates to the local ones of the `viewport`. Otherwise,\n // improper transformation would be applied when the viewport gets transformed (scaled/rotated).\n return this.clientToLocalPoint(x, y).snapToGrid(this.options.gridSize);\n },\n\n localToPaperPoint: function(x, y) {\n // allow `x` to be a point and `y` undefined\n var localPoint = new Point(x, y);\n var paperPoint = V.transformPoint(localPoint, this.matrix());\n return paperPoint;\n },\n\n localToPaperRect: function(x, y, width, height) {\n // allow `x` to be a rectangle and rest arguments undefined\n var localRect = new Rect(x, y, width, height);\n var paperRect = V.transformRect(localRect, this.matrix());\n return paperRect;\n },\n\n paperToLocalPoint: function(x, y) {\n // allow `x` to be a point and `y` undefined\n var paperPoint = new Point(x, y);\n var localPoint = V.transformPoint(paperPoint, this.matrix().inverse());\n return localPoint;\n },\n\n paperToLocalRect: function(x, y, width, height) {\n // allow `x` to be a rectangle and rest arguments undefined\n var paperRect = new Rect(x, y, width, height);\n var localRect = V.transformRect(paperRect, this.matrix().inverse());\n return localRect;\n },\n\n localToClientPoint: function(x, y) {\n // allow `x` to be a point and `y` undefined\n var localPoint = new Point(x, y);\n var clientPoint = V.transformPoint(localPoint, this.clientMatrix());\n return clientPoint;\n },\n\n localToClientRect: function(x, y, width, height) {\n // allow `x` to be a point and `y` undefined\n var localRect = new Rect(x, y, width, height);\n var clientRect = V.transformRect(localRect, this.clientMatrix());\n return clientRect;\n },\n\n // Transform client coordinates to the paper local coordinates.\n // Useful when you have a mouse event object and you'd like to get coordinates\n // inside the paper that correspond to `evt.clientX` and `evt.clientY` point.\n // Example: var localPoint = paper.clientToLocalPoint({ x: evt.clientX, y: evt.clientY });\n clientToLocalPoint: function(x, y) {\n // allow `x` to be a point and `y` undefined\n var clientPoint = new Point(x, y);\n var localPoint = V.transformPoint(clientPoint, this.clientMatrix().inverse());\n return localPoint;\n },\n\n clientToLocalRect: function(x, y, width, height) {\n // allow `x` to be a point and `y` undefined\n var clientRect = new Rect(x, y, width, height);\n var localRect = V.transformRect(clientRect, this.clientMatrix().inverse());\n return localRect;\n },\n\n localToPagePoint: function(x, y) {\n\n return this.localToPaperPoint(x, y).offset(this.pageOffset());\n },\n\n localToPageRect: function(x, y, width, height) {\n\n return this.localToPaperRect(x, y, width, height).offset(this.pageOffset());\n },\n\n pageToLocalPoint: function(x, y) {\n\n var pagePoint = new Point(x, y);\n var paperPoint = pagePoint.difference(this.pageOffset());\n return this.paperToLocalPoint(paperPoint);\n },\n\n pageToLocalRect: function(x, y, width, height) {\n\n var pageOffset = this.pageOffset();\n var paperRect = new Rect(x, y, width, height);\n paperRect.x -= pageOffset.x;\n paperRect.y -= pageOffset.y;\n return this.paperToLocalRect(paperRect);\n },\n\n clientOffset: function() {\n\n var clientRect = this.svg.getBoundingClientRect();\n return new Point(clientRect.left, clientRect.top);\n },\n\n pageOffset: function() {\n\n return this.clientOffset().offset(window.scrollX, window.scrollY);\n },\n\n linkAllowed: function(linkView) {\n\n if (!(linkView instanceof LinkView)) {\n throw new Error('Must provide a linkView.');\n }\n\n var link = linkView.model;\n var paperOptions = this.options;\n var graph = this.model;\n var ns = graph.constructor.validations;\n\n if (!paperOptions.multiLinks) {\n if (!ns.multiLinks.call(this, graph, link)) return false;\n }\n\n if (!paperOptions.linkPinning) {\n // Link pinning is not allowed and the link is not connected to the target.\n if (!ns.linkPinning.call(this, graph, link)) return false;\n }\n\n if (typeof paperOptions.allowLink === 'function') {\n if (!paperOptions.allowLink.call(this, linkView, this)) return false;\n }\n\n return true;\n },\n\n getDefaultLink: function(cellView, magnet) {\n\n return isFunction(this.options.defaultLink)\n // default link is a function producing link model\n ? this.options.defaultLink.call(this, cellView, magnet)\n // default link is the mvc model\n : this.options.defaultLink.clone();\n },\n\n // Cell highlighting.\n // ------------------\n\n resolveHighlighter: function(opt = {}) {\n\n let { highlighter: highlighterDef, type } = opt;\n const { highlighting,highlighterNamespace } = this.options;\n\n /*\n Expecting opt.highlighter to have the following structure:\n {\n name: 'highlighter-name',\n options: {\n some: 'value'\n }\n }\n */\n if (highlighterDef === undefined) {\n\n // Is highlighting disabled?\n if (!highlighting) return false;\n // check for built-in types\n if (type) {\n highlighterDef = highlighting[type];\n // Is a specific type highlight disabled?\n if (highlighterDef === false) return false;\n }\n if (!highlighterDef) {\n // Type not defined use default highlight\n highlighterDef = highlighting['default'];\n }\n }\n\n // Do nothing if opt.highlighter is falsy.\n // This allows the case to not highlight cell(s) in certain cases.\n // For example, if you want to NOT highlight when embedding elements\n // or use a custom highlighter.\n if (!highlighterDef) return false;\n\n // Allow specifying a highlighter by name.\n if (isString(highlighterDef)) {\n highlighterDef = {\n name: highlighterDef\n };\n }\n\n const name = highlighterDef.name;\n const highlighter = highlighterNamespace[name];\n\n // Highlighter validation\n if (!highlighter) {\n throw new Error('Unknown highlighter (\"' + name + '\")');\n }\n if (typeof highlighter.highlight !== 'function') {\n throw new Error('Highlighter (\"' + name + '\") is missing required highlight() method');\n }\n if (typeof highlighter.unhighlight !== 'function') {\n throw new Error('Highlighter (\"' + name + '\") is missing required unhighlight() method');\n }\n\n return {\n highlighter,\n options: highlighterDef.options || {},\n name\n };\n },\n\n onCellHighlight: function(cellView, magnetEl, opt) {\n const highlighterDescriptor = this.resolveHighlighter(opt);\n if (!highlighterDescriptor) return;\n const { highlighter, options } = highlighterDescriptor;\n highlighter.highlight(cellView, magnetEl, options);\n },\n\n onCellUnhighlight: function(cellView, magnetEl, opt) {\n const highlighterDescriptor = this.resolveHighlighter(opt);\n if (!highlighterDescriptor) return;\n const { highlighter, options } = highlighterDescriptor;\n highlighter.unhighlight(cellView, magnetEl, options);\n },\n\n // Interaction.\n // ------------\n\n pointerdblclick: function(evt) {\n\n evt.preventDefault();\n\n // magnetpointerdblclick can stop propagation\n\n evt = normalizeEvent(evt);\n\n var view = this.findView(evt.target);\n if (this.guard(evt, view)) return;\n\n var localPoint = this.snapToGrid(evt.clientX, evt.clientY);\n\n if (view) {\n view.pointerdblclick(evt, localPoint.x, localPoint.y);\n\n } else {\n this.trigger('blank:pointerdblclick', evt, localPoint.x, localPoint.y);\n }\n },\n\n pointerclick: function(evt) {\n\n // magnetpointerclick can stop propagation\n\n var data = this.eventData(evt);\n // Trigger event only if mouse has not moved.\n if (data.mousemoved <= this.options.clickThreshold) {\n\n evt = normalizeEvent(evt);\n\n var view = this.findView(evt.target);\n if (this.guard(evt, view)) return;\n\n var localPoint = this.snapToGrid(evt.clientX, evt.clientY);\n\n if (view) {\n view.pointerclick(evt, localPoint.x, localPoint.y);\n\n } else {\n this.trigger('blank:pointerclick', evt, localPoint.x, localPoint.y);\n }\n }\n },\n\n contextmenu: function(evt) {\n\n if (this.options.preventContextMenu) evt.preventDefault();\n\n if (this.contextMenuFired) {\n this.contextMenuFired = false;\n return;\n }\n\n evt = normalizeEvent(evt);\n\n this.contextMenuTrigger(evt);\n },\n\n contextMenuTrigger: function(evt) {\n var view = this.findView(evt.target);\n if (this.guard(evt, view)) return;\n\n var localPoint = this.snapToGrid(evt.clientX, evt.clientY);\n\n if (view) {\n view.contextmenu(evt, localPoint.x, localPoint.y);\n\n } else {\n this.trigger('blank:contextmenu', evt, localPoint.x, localPoint.y);\n }\n },\n\n pointerdown: function(evt) {\n\n evt = normalizeEvent(evt);\n\n const { target, button } = evt;\n const view = this.findView(target);\n const isContextMenu = (button === 2);\n\n if (view) {\n\n if (!isContextMenu && this.guard(evt, view)) return;\n\n const isTargetFormNode = this.FORM_CONTROL_TAG_NAMES.includes(target.tagName);\n\n if (this.options.preventDefaultViewAction && !isTargetFormNode) {\n // If the target is a form element, we do not want to prevent the default action.\n // For example, we want to be able to select text in a text input or\n // to be able to click on a checkbox.\n evt.preventDefault();\n }\n\n if (isTargetFormNode) {\n // If the target is a form element, we do not want to start dragging the element.\n // For example, we want to be able to select text by dragging the mouse.\n view.preventDefaultInteraction(evt);\n }\n\n // Custom event\n const eventEvt = this.customEventTrigger(evt, view);\n if (eventEvt) {\n // `onevent` could have stopped propagation\n if (eventEvt.isPropagationStopped()) return;\n\n evt.data = eventEvt.data;\n }\n\n // Element magnet\n const magnetNode = target.closest('[magnet]');\n if (magnetNode && view.el !== magnetNode && view.el.contains(magnetNode)) {\n const magnetEvt = normalizeEvent(new $.Event(evt.originalEvent, {\n data: evt.data,\n // Originally the event listener was attached to the magnet element.\n currentTarget: magnetNode\n }));\n this.onmagnet(magnetEvt);\n if (magnetEvt.isDefaultPrevented()) {\n evt.preventDefault();\n }\n // `onmagnet` stops propagation when `addLinkFromMagnet` is allowed\n if (magnetEvt.isPropagationStopped()) {\n // `magnet:pointermove` and `magnet:pointerup` events must be fired\n if (isContextMenu) return;\n this.delegateDragEvents(view, magnetEvt.data);\n return;\n }\n evt.data = magnetEvt.data;\n }\n }\n\n if (isContextMenu) {\n this.contextMenuFired = true;\n const contextmenuEvt = new $.Event(evt.originalEvent, { type: 'contextmenu', data: evt.data });\n this.contextMenuTrigger(contextmenuEvt);\n } else {\n const localPoint = this.snapToGrid(evt.clientX, evt.clientY);\n if (view) {\n view.pointerdown(evt, localPoint.x, localPoint.y);\n } else {\n if (this.options.preventDefaultBlankAction) {\n evt.preventDefault();\n }\n this.trigger('blank:pointerdown', evt, localPoint.x, localPoint.y);\n }\n\n this.delegateDragEvents(view, evt.data);\n }\n\n },\n\n pointermove: function(evt) {\n\n // mouse moved counter\n var data = this.eventData(evt);\n if (!data.mousemoved) {\n data.mousemoved = 0;\n // Make sure that events like `mouseenter` and `mouseleave` are\n // not triggered while the user is dragging a cellView.\n this.undelegateEvents();\n // Note: the events are undelegated after the first `pointermove` event.\n // Not on `pointerdown` to make sure that `dbltap` is recognized.\n }\n\n var mousemoved = ++data.mousemoved;\n\n if (mousemoved <= this.options.moveThreshold) return;\n\n evt = normalizeEvent(evt);\n\n var localPoint = this.snapToGrid(evt.clientX, evt.clientY);\n\n var view = data.sourceView;\n if (view) {\n view.pointermove(evt, localPoint.x, localPoint.y);\n } else {\n this.trigger('blank:pointermove', evt, localPoint.x, localPoint.y);\n }\n\n this.eventData(evt, data);\n },\n\n pointerup: function(evt) {\n\n this.undelegateDocumentEvents();\n\n var normalizedEvt = normalizeEvent(evt);\n\n var localPoint = this.snapToGrid(normalizedEvt.clientX, normalizedEvt.clientY);\n\n var view = this.eventData(evt).sourceView;\n if (view) {\n view.pointerup(normalizedEvt, localPoint.x, localPoint.y);\n } else {\n this.trigger('blank:pointerup', normalizedEvt, localPoint.x, localPoint.y);\n }\n\n if (!normalizedEvt.isPropagationStopped()) {\n this.pointerclick(new $.Event(evt.originalEvent, { type: 'click', data: evt.data }));\n }\n\n this.delegateEvents();\n },\n\n mouseover: function(evt) {\n\n evt = normalizeEvent(evt);\n\n var view = this.findView(evt.target);\n if (this.guard(evt, view)) return;\n\n if (view) {\n view.mouseover(evt);\n\n } else {\n if (this.el === evt.target) return; // prevent border of paper from triggering this\n this.trigger('blank:mouseover', evt);\n }\n },\n\n mouseout: function(evt) {\n\n evt = normalizeEvent(evt);\n\n var view = this.findView(evt.target);\n if (this.guard(evt, view)) return;\n\n if (view) {\n view.mouseout(evt);\n\n } else {\n if (this.el === evt.target) return; // prevent border of paper from triggering this\n this.trigger('blank:mouseout', evt);\n }\n },\n\n mouseenter: function(evt) {\n\n evt = normalizeEvent(evt);\n\n const {\n target, // The EventTarget the pointing device entered to\n relatedTarget, // The EventTarget the pointing device exited from\n currentTarget // The EventTarget on which the event listener was registered\n } = evt;\n const view = this.findView(target);\n if (this.guard(evt, view)) return;\n const relatedView = this.findView(relatedTarget);\n if (view) {\n if (relatedView === view) {\n // Mouse left a cell tool\n return;\n }\n view.mouseenter(evt);\n if (this.el.contains(relatedTarget)) {\n // The pointer remains inside the paper.\n return;\n }\n }\n if (relatedView) {\n return;\n }\n // prevent double `mouseenter` event if the `relatedTarget` is outside the paper\n // (mouseenter method would be fired twice)\n if (currentTarget === this.el) {\n // `paper` (more descriptive), not `blank`\n this.trigger('paper:mouseenter', evt);\n }\n },\n\n mouseleave: function(evt) {\n\n evt = normalizeEvent(evt);\n\n const {\n target, // The EventTarget the pointing device exited from\n relatedTarget, // The EventTarget the pointing device entered to\n currentTarget // The EventTarget on which the event listener was registered\n } = evt;\n const view = this.findView(target);\n if (this.guard(evt, view)) return;\n const relatedView = this.findView(relatedTarget);\n if (view) {\n if (relatedView === view) {\n // Mouse entered a cell tool\n return;\n }\n view.mouseleave(evt);\n if (this.el.contains(relatedTarget)) {\n // The pointer has exited a cellView. The pointer is still inside of the paper.\n return;\n }\n }\n if (relatedView) {\n // The pointer has entered a new cellView\n return;\n }\n // prevent double `mouseleave` event if the `relatedTarget` is outside the paper\n // (mouseleave method would be fired twice)\n if (currentTarget === this.el) {\n // There is no cellView under the pointer, nor the blank area of the paper\n this.trigger('paper:mouseleave', evt);\n }\n },\n\n _processMouseWheelEvtBuf: debounce(function() {\n const { event, deltas } = this._mw_evt_buffer;\n const deltaY = deltas.reduce((acc, deltaY) => acc + cap(deltaY, WHEEL_CAP), 0);\n\n const scale = Math.pow(0.995, deltaY); // 1.005 for inverted pinch/zoom\n const { x, y } = this.clientToLocalPoint(event.clientX, event.clientY);\n this.trigger('paper:pinch', event, x, y, scale);\n\n this._mw_evt_buffer = {\n event: null,\n deltas: [],\n };\n }, WHEEL_WAIT_MS, { maxWait: WHEEL_WAIT_MS }),\n\n mousewheel: function(evt) {\n\n evt = normalizeEvent(evt);\n\n const view = this.findView(evt.target);\n if (this.guard(evt, view)) return;\n\n const originalEvent = evt.originalEvent;\n const localPoint = this.snapToGrid(originalEvent.clientX, originalEvent.clientY);\n const { deltaX, deltaY } = normalizeWheel(originalEvent);\n\n const pinchHandlers = this._events['paper:pinch'];\n\n // Touchpad devices will send a fake CTRL press when a pinch is performed\n //\n // We also check if there are any subscribers to paper:pinch event. If there are none,\n // just skip the entire block of code (we don't want to blindly call\n // .preventDefault() if we really don't have to).\n if (evt.ctrlKey && pinchHandlers && pinchHandlers.length > 0) {\n // This is a pinch gesture, it's safe to assume that we must call .preventDefault()\n originalEvent.preventDefault();\n this._mw_evt_buffer.event = evt;\n this._mw_evt_buffer.deltas.push(deltaY);\n this._processMouseWheelEvtBuf();\n } else {\n const delta = Math.max(-1, Math.min(1, originalEvent.wheelDelta));\n if (view) {\n view.mousewheel(evt, localPoint.x, localPoint.y, delta);\n\n } else {\n this.trigger('blank:mousewheel', evt, localPoint.x, localPoint.y, delta);\n }\n\n this.trigger('paper:pan', evt, deltaX, deltaY);\n }\n },\n\n onevent: function(evt) {\n\n var eventNode = evt.currentTarget;\n var eventName = eventNode.getAttribute('event');\n if (eventName) {\n var view = this.findView(eventNode);\n if (view) {\n\n evt = normalizeEvent(evt);\n if (this.guard(evt, view)) return;\n\n var localPoint = this.snapToGrid(evt.clientX, evt.clientY);\n view.onevent(evt, eventName, localPoint.x, localPoint.y);\n }\n }\n },\n\n magnetEvent: function(evt, handler) {\n\n var magnetNode = evt.currentTarget;\n var magnetValue = magnetNode.getAttribute('magnet');\n if (magnetValue) {\n var view = this.findView(magnetNode);\n if (view) {\n evt = normalizeEvent(evt);\n if (this.guard(evt, view)) return;\n var localPoint = this.snapToGrid(evt.clientX, evt.clientY);\n handler.call(this, view, evt, magnetNode, localPoint.x, localPoint.y);\n }\n }\n },\n\n onmagnet: function(evt) {\n\n if (evt.button === 2) {\n this.contextMenuFired = true;\n this.magnetContextMenuFired = true;\n const contextmenuEvt = new $.Event(evt.originalEvent, {\n type: 'contextmenu',\n data: evt.data,\n currentTarget: evt.currentTarget,\n });\n this.magnetContextMenuTrigger(contextmenuEvt);\n if (contextmenuEvt.isPropagationStopped()) {\n evt.stopPropagation();\n }\n } else {\n this.magnetEvent(evt, function(view, evt, _, x, y) {\n view.onmagnet(evt, x, y);\n });\n }\n },\n\n magnetpointerdblclick: function(evt) {\n\n this.magnetEvent(evt, function(view, evt, magnet, x, y) {\n view.magnetpointerdblclick(evt, magnet, x, y);\n });\n },\n\n magnetcontextmenu: function(evt) {\n if (this.options.preventContextMenu) evt.preventDefault();\n\n if (this.magnetContextMenuFired) {\n this.magnetContextMenuFired = false;\n return;\n }\n\n this.magnetContextMenuTrigger(evt);\n },\n\n magnetContextMenuTrigger: function(evt) {\n this.magnetEvent(evt, function(view, evt, magnet, x, y) {\n view.magnetcontextmenu(evt, magnet, x, y);\n });\n },\n\n onlabel: function(evt) {\n\n var labelNode = evt.currentTarget;\n\n var view = this.findView(labelNode);\n if (!view) return;\n\n evt = normalizeEvent(evt);\n if (this.guard(evt, view)) return;\n\n // Custom event\n const eventEvt = this.customEventTrigger(evt, view, labelNode);\n if (eventEvt) {\n // `onevent` could have stopped propagation\n if (eventEvt.isPropagationStopped()) return;\n\n evt.data = eventEvt.data;\n }\n\n var localPoint = this.snapToGrid(evt.clientX, evt.clientY);\n view.onlabel(evt, localPoint.x, localPoint.y);\n },\n\n getPointerArgs(evt) {\n const normalizedEvt = normalizeEvent(evt);\n const { x, y } = this.snapToGrid(normalizedEvt.clientX, normalizedEvt.clientY);\n return [normalizedEvt, x, y];\n },\n\n delegateDragEvents: function(view, data) {\n\n data || (data = {});\n this.eventData({ data: data }, { sourceView: view || null, mousemoved: 0 });\n this.delegateDocumentEvents(null, data);\n },\n\n // Guard the specified event. If the event should be ignored, guard returns `true`.\n // Otherwise, it returns `false`.\n guard: function(evt, view) {\n\n if (evt.type === 'mousedown' && evt.button === 2) {\n // handled as `contextmenu` type\n return true;\n }\n\n if (this.options.guard && this.options.guard(evt, view)) {\n return true;\n }\n\n if (evt.data && evt.data.guarded !== undefined) {\n return evt.data.guarded;\n }\n\n const { target } = evt;\n\n if (this.GUARDED_TAG_NAMES.includes(target.tagName)) {\n return true;\n }\n\n if (view && view.model && (view.model instanceof Cell)) {\n return false;\n }\n\n if (this.el === target || this.svg.contains(target)) {\n return false;\n }\n\n return true; // Event guarded. Paper should not react on it in any way.\n },\n\n setGridSize: function(gridSize) {\n const { options } = this;\n options.gridSize = gridSize;\n if (options.drawGrid && !options.drawGridSize) {\n // Do not redraw the grid if the `drawGridSize` is set.\n this.getLayerView(LayersNames.GRID).renderGrid();\n }\n return this;\n },\n\n setGrid: function(drawGrid) {\n this.getLayerView(LayersNames.GRID).setGrid(drawGrid);\n return this;\n },\n\n updateBackgroundImage: function(opt) {\n\n opt = opt || {};\n\n var backgroundPosition = opt.position || 'center';\n var backgroundSize = opt.size || 'auto auto';\n\n var currentScale = this.scale();\n var currentTranslate = this.translate();\n\n // backgroundPosition\n if (isObject(backgroundPosition)) {\n var x = currentTranslate.tx + (currentScale.sx * (backgroundPosition.x || 0));\n var y = currentTranslate.ty + (currentScale.sy * (backgroundPosition.y || 0));\n backgroundPosition = x + 'px ' + y + 'px';\n }\n\n // backgroundSize\n if (isObject(backgroundSize)) {\n backgroundSize = new Rect(backgroundSize).scale(currentScale.sx, currentScale.sy);\n backgroundSize = backgroundSize.width + 'px ' + backgroundSize.height + 'px';\n }\n\n const { background } = this.childNodes;\n background.style.backgroundSize = backgroundSize;\n background.style.backgroundPosition = backgroundPosition;\n },\n\n drawBackgroundImage: function(img, opt) {\n\n // Clear the background image if no image provided\n if (!(img instanceof HTMLImageElement)) {\n this.childNodes.background.style.backgroundImage = '';\n return;\n }\n\n if (!this._background || this._background.id !== opt.id) {\n // Draw only the last image requested (see drawBackground())\n return;\n }\n\n opt = opt || {};\n\n var backgroundImage;\n var backgroundSize = opt.size;\n var backgroundRepeat = opt.repeat || 'no-repeat';\n var backgroundOpacity = opt.opacity || 1;\n var backgroundQuality = Math.abs(opt.quality) || 1;\n var backgroundPattern = this.constructor.backgroundPatterns[camelCase(backgroundRepeat)];\n\n if (isFunction(backgroundPattern)) {\n // 'flip-x', 'flip-y', 'flip-xy', 'watermark' and custom\n img.width *= backgroundQuality;\n img.height *= backgroundQuality;\n var canvas = backgroundPattern(img, opt);\n if (!(canvas instanceof HTMLCanvasElement)) {\n throw new Error('dia.Paper: background pattern must return an HTML Canvas instance');\n }\n\n backgroundImage = canvas.toDataURL('image/png');\n backgroundRepeat = 'repeat';\n if (isObject(backgroundSize)) {\n // recalculate the tile size if an object passed in\n backgroundSize.width *= canvas.width / img.width;\n backgroundSize.height *= canvas.height / img.height;\n } else if (backgroundSize === undefined) {\n // calculate the tile size if no provided\n opt.size = {\n width: canvas.width / backgroundQuality,\n height: canvas.height / backgroundQuality\n };\n }\n } else {\n // backgroundRepeat:\n // no-repeat', 'round', 'space', 'repeat', 'repeat-x', 'repeat-y'\n backgroundImage = img.src;\n if (backgroundSize === undefined) {\n // pass the image size for the backgroundSize if no size provided\n opt.size = {\n width: img.width,\n height: img.height\n };\n }\n }\n\n this.childNodes.background.style.opacity = backgroundOpacity;\n this.childNodes.background.style.backgroundRepeat = backgroundRepeat;\n this.childNodes.background.style.backgroundImage = `url(${backgroundImage})`;\n\n this.updateBackgroundImage(opt);\n },\n\n updateBackgroundColor: function(color) {\n\n this.$el.css('backgroundColor', color || '');\n },\n\n drawBackground: function(opt) {\n\n opt = opt || {};\n\n this.updateBackgroundColor(opt.color);\n\n if (opt.image) {\n opt = this._background = cloneDeep(opt);\n guid(opt);\n var img = document.createElement('img');\n img.onload = this.drawBackgroundImage.bind(this, img, opt);\n img.src = opt.image;\n } else {\n this.drawBackgroundImage(null);\n this._background = null;\n }\n\n return this;\n },\n\n setInteractivity: function(value) {\n\n this.options.interactive = value;\n\n invoke(this._views, 'setInteractivity', value);\n },\n\n // Paper definitions.\n // ------------------\n\n isDefined: function(defId) {\n\n return !!this.svg.getElementById(defId);\n },\n\n defineFilter: function(filter) {\n\n if (!isObject(filter)) {\n throw new TypeError('dia.Paper: defineFilter() requires 1. argument to be an object.');\n }\n\n var filterId = filter.id;\n var name = filter.name;\n // Generate a hash code from the stringified filter definition. This gives us\n // a unique filter ID for different definitions.\n if (!filterId) {\n filterId = name + this.svg.id + hashCode(JSON.stringify(filter));\n }\n // If the filter already exists in the document,\n // we're done and we can just use it (reference it using `url()`).\n // If not, create one.\n if (!this.isDefined(filterId)) {\n\n var namespace = _filter;\n var filterSVGString = namespace[name] && namespace[name](filter.args || {});\n if (!filterSVGString) {\n throw new Error('Non-existing filter ' + name);\n }\n\n // SVG <filter/> attributes\n var filterAttrs = assign({\n filterUnits: 'userSpaceOnUse',\n }, filter.attrs, {\n id: filterId\n });\n\n V(filterSVGString, filterAttrs).appendTo(this.defs);\n }\n\n return filterId;\n },\n\n defineGradient: function(gradient) {\n if (!isObject(gradient)) {\n throw new TypeError('dia.Paper: defineGradient() requires 1. argument to be an object.');\n }\n const { svg, defs } = this;\n const {\n type,\n // Generate a hash code from the stringified filter definition. This gives us\n // a unique filter ID for different definitions.\n id = type + svg.id + hashCode(JSON.stringify(gradient)),\n stops,\n attrs = {}\n } = gradient;\n // If the gradient already exists in the document,\n // we're done and we can just use it (reference it using `url()`).\n if (this.isDefined(id)) return id;\n // If not, create one.\n const stopVEls = toArray(stops).map(({ offset, color, opacity }) => {\n return V('stop').attr({\n 'offset': offset,\n 'stop-color': color,\n 'stop-opacity': Number.isFinite(opacity) ? opacity : 1\n });\n });\n const gradientVEl = V(type, attrs, stopVEls);\n gradientVEl.id = id;\n gradientVEl.appendTo(defs);\n return id;\n },\n\n definePattern: function(pattern) {\n if (!isObject(pattern)) {\n throw new TypeError('dia.Paper: definePattern() requires 1. argument to be an object.');\n }\n const { svg, defs } = this;\n const {\n // Generate a hash code from the stringified filter definition. This gives us\n // a unique filter ID for different definitions.\n id = svg.id + hashCode(JSON.stringify(pattern)),\n markup,\n attrs = {}\n } = pattern;\n if (!markup) {\n throw new TypeError('dia.Paper: definePattern() requires markup.');\n }\n // If the gradient already exists in the document,\n // we're done and we can just use it (reference it using `url()`).\n if (this.isDefined(id)) return id;\n // If not, create one.\n const patternVEl = V('pattern', {\n patternUnits: 'userSpaceOnUse'\n });\n patternVEl.id = id;\n patternVEl.attr(attrs);\n if (typeof markup === 'string') {\n patternVEl.append(V(markup));\n } else {\n const { fragment } = parseDOMJSON(markup);\n patternVEl.append(fragment);\n }\n patternVEl.appendTo(defs);\n return id;\n },\n\n defineMarker: function(marker) {\n if (!isObject(marker)) {\n throw new TypeError('dia.Paper: defineMarker() requires the first argument to be an object.');\n }\n const { svg, defs } = this;\n const {\n // Generate a hash code from the stringified filter definition. This gives us\n // a unique filter ID for different definitions.\n id = svg.id + hashCode(JSON.stringify(marker)),\n // user-provided markup\n // (e.g. defined when creating link via `attrs/line/sourceMarker/markup`)\n markup,\n // user-provided attributes\n // (e.g. defined when creating link via `attrs/line/sourceMarker/attrs`)\n // note: `transform` attrs are ignored by browsers\n attrs = {},\n // deprecated - use `attrs/markerUnits` instead (which has higher priority)\n markerUnits = 'userSpaceOnUse'\n } = marker;\n // If the marker already exists in the document,\n // we're done and we can just use it (reference it using `url()`).\n if (this.isDefined(id)) return id;\n // If not, create one.\n const markerVEl = V('marker', {\n orient: 'auto',\n overflow: 'visible',\n markerUnits: markerUnits\n });\n markerVEl.id = id;\n markerVEl.attr(attrs);\n let markerContentVEl;\n if (markup) {\n let markupVEl;\n if (typeof markup === 'string') {\n // Marker object has a `markup` property of type string.\n // - Construct V from the provided string.\n markupVEl = V(markup);\n // `markupVEl` is now either a single VEl, or an array of VEls.\n // - Coerce it to an array.\n markupVEl = (Array.isArray(markupVEl) ? markupVEl : [markupVEl]);\n } else {\n // Marker object has a `markup` property of type object.\n // - Construct V from the object by parsing it as DOM JSON.\n const { fragment } = parseDOMJSON(markup);\n markupVEl = V(fragment).children();\n }\n // `markupVEl` is an array with one or more VEls inside.\n // - If there are multiple VEls, wrap them in a newly-constructed <g> element\n if (markupVEl.length > 1) {\n markerContentVEl = V('g').append(markupVEl);\n } else {\n markerContentVEl = markupVEl[0];\n }\n } else {\n // Marker object is a flat structure.\n // - Construct a new V of type `marker.type`.\n const { type = 'path' } = marker;\n markerContentVEl = V(type);\n }\n // `markerContentVEl` is a single VEl.\n // Assign additional attributes to it (= context attributes + marker attributes):\n // - Attribute values are taken from non-special properties of `marker`.\n const markerAttrs = omit(marker, 'type', 'id', 'markup', 'attrs', 'markerUnits');\n const markerAttrsKeys = Object.keys(markerAttrs);\n markerAttrsKeys.forEach((key) => {\n const value = markerAttrs[key];\n const markupValue = markerContentVEl.attr(key); // value coming from markupVEl (if any) = higher priority\n if (markupValue == null) {\n // Default logic:\n markerContentVEl.attr(key, value);\n } else {\n // Properties with special logic should be added as cases to this switch block:\n switch(key) {\n case 'transform':\n // - Prepend `transform` to existing value.\n markerContentVEl.attr(key, (value + ' ' + markupValue));\n break;\n }\n }\n });\n markerContentVEl.appendTo(markerVEl);\n markerVEl.appendTo(defs);\n return id;\n },\n\n customEventTrigger: function(evt, view, rootNode = view.el) {\n\n const eventNode = evt.target.closest('[event]');\n\n if (eventNode && rootNode !== eventNode && view.el.contains(eventNode)) {\n const eventEvt = normalizeEvent(new $.Event(evt.originalEvent, {\n data: evt.data,\n // Originally the event listener was attached to the event element.\n currentTarget: eventNode\n }));\n\n this.onevent(eventEvt);\n\n if (eventEvt.isDefaultPrevented()) {\n evt.preventDefault();\n }\n\n return eventEvt;\n }\n\n return null;\n }\n\n}, {\n\n sorting: sortingTypes,\n\n Layers: LayersNames,\n\n backgroundPatterns: {\n\n flipXy: function(img) {\n // d b\n // q p\n\n var canvas = document.createElement('canvas');\n var imgWidth = img.width;\n var imgHeight = img.height;\n\n canvas.width = 2 * imgWidth;\n canvas.height = 2 * imgHeight;\n\n var ctx = canvas.getContext('2d');\n // top-left image\n ctx.drawImage(img, 0, 0, imgWidth, imgHeight);\n // xy-flipped bottom-right image\n ctx.setTransform(-1, 0, 0, -1, canvas.width, canvas.height);\n ctx.drawImage(img, 0, 0, imgWidth, imgHeight);\n // x-flipped top-right image\n ctx.setTransform(-1, 0, 0, 1, canvas.width, 0);\n ctx.drawImage(img, 0, 0, imgWidth, imgHeight);\n // y-flipped bottom-left image\n ctx.setTransform(1, 0, 0, -1, 0, canvas.height);\n ctx.drawImage(img, 0, 0, imgWidth, imgHeight);\n\n return canvas;\n },\n\n flipX: function(img) {\n // d b\n // d b\n\n var canvas = document.createElement('canvas');\n var imgWidth = img.width;\n var imgHeight = img.height;\n\n canvas.width = imgWidth * 2;\n canvas.height = imgHeight;\n\n var ctx = canvas.getContext('2d');\n // left image\n ctx.drawImage(img, 0, 0, imgWidth, imgHeight);\n // flipped right image\n ctx.translate(2 * imgWidth, 0);\n ctx.scale(-1, 1);\n ctx.drawImage(img, 0, 0, imgWidth, imgHeight);\n\n return canvas;\n },\n\n flipY: function(img) {\n // d d\n // q q\n\n var canvas = document.createElement('canvas');\n var imgWidth = img.width;\n var imgHeight = img.height;\n\n canvas.width = imgWidth;\n canvas.height = imgHeight * 2;\n\n var ctx = canvas.getContext('2d');\n // top image\n ctx.drawImage(img, 0, 0, imgWidth, imgHeight);\n // flipped bottom image\n ctx.translate(0, 2 * imgHeight);\n ctx.scale(1, -1);\n ctx.drawImage(img, 0, 0, imgWidth, imgHeight);\n\n return canvas;\n },\n\n watermark: function(img, opt) {\n // d\n // d\n\n opt = opt || {};\n\n var imgWidth = img.width;\n var imgHeight = img.height;\n\n var canvas = document.createElement('canvas');\n canvas.width = imgWidth * 3;\n canvas.height = imgHeight * 3;\n\n var ctx = canvas.getContext('2d');\n var angle = isNumber(opt.watermarkAngle) ? -opt.watermarkAngle : -20;\n var radians = toRad(angle);\n var stepX = canvas.width / 4;\n var stepY = canvas.height / 4;\n\n for (var i = 0; i < 4; i++) {\n for (var j = 0; j < 4; j++) {\n if ((i + j) % 2 > 0) {\n // reset the current transformations\n ctx.setTransform(1, 0, 0, 1, (2 * i - 1) * stepX, (2 * j - 1) * stepY);\n ctx.rotate(radians);\n ctx.drawImage(img, -imgWidth / 2, -imgHeight / 2, imgWidth, imgHeight);\n }\n }\n }\n\n return canvas;\n }\n },\n\n gridPatterns: {\n dot: [{\n color: '#AAAAAA',\n thickness: 1,\n markup: 'rect',\n render: function(el, opt) {\n V(el).attr({\n width: opt.thickness,\n height: opt.thickness,\n fill: opt.color\n });\n }\n }],\n fixedDot: [{\n color: '#AAAAAA',\n thickness: 1,\n markup: 'rect',\n render: function(el, opt) {\n V(el).attr({ fill: opt.color });\n },\n update: function(el, opt, paper) {\n const { sx, sy } = paper.scale();\n const width = sx <= 1 ? opt.thickness : opt.thickness / sx;\n const height = sy <= 1 ? opt.thickness : opt.thickness / sy;\n V(el).attr({ width, height });\n }\n }],\n mesh: [{\n color: '#AAAAAA',\n thickness: 1,\n markup: 'path',\n render: function(el, opt) {\n\n var d;\n var width = opt.width;\n var height = opt.height;\n var thickness = opt.thickness;\n\n if (width - thickness >= 0 && height - thickness >= 0) {\n d = ['M', width, 0, 'H0 M0 0 V0', height].join(' ');\n } else {\n d = 'M 0 0 0 0';\n }\n\n V(el).attr({ 'd': d, stroke: opt.color, 'stroke-width': opt.thickness });\n }\n }],\n doubleMesh: [{\n color: '#AAAAAA',\n thickness: 1,\n markup: 'path',\n render: function(el, opt) {\n\n var d;\n var width = opt.width;\n var height = opt.height;\n var thickness = opt.thickness;\n\n if (width - thickness >= 0 && height - thickness >= 0) {\n d = ['M', width, 0, 'H0 M0 0 V0', height].join(' ');\n } else {\n d = 'M 0 0 0 0';\n }\n\n V(el).attr({ 'd': d, stroke: opt.color, 'stroke-width': opt.thickness });\n }\n }, {\n color: '#000000',\n thickness: 3,\n scaleFactor: 4,\n markup: 'path',\n render: function(el, opt) {\n\n var d;\n var width = opt.width;\n var height = opt.height;\n var thickness = opt.thickness;\n\n if (width - thickness >= 0 && height - thickness >= 0) {\n d = ['M', width, 0, 'H0 M0 0 V0', height].join(' ');\n } else {\n d = 'M 0 0 0 0';\n }\n\n V(el).attr({ 'd': d, stroke: opt.color, 'stroke-width': opt.thickness });\n }\n }]\n }\n});\n\n","import * as mvc from '../mvc/index.mjs';\n\nexport const ToolView = mvc.View.extend({\n name: null,\n tagName: 'g',\n className: 'tool',\n svgElement: true,\n _visible: true,\n _visibleExplicit: true,\n\n init: function() {\n var name = this.name;\n if (name) this.vel.attr('data-tool-name', name);\n },\n\n configure: function(view, toolsView) {\n this.relatedView = view;\n this.paper = view.paper;\n this.parentView = toolsView;\n this.simulateRelatedView(this.el);\n // Delegate events in case the ToolView was removed from the DOM and reused.\n this.delegateEvents();\n return this;\n },\n\n simulateRelatedView: function(el) {\n if (el) el.setAttribute('model-id', this.relatedView.model.id);\n },\n\n getName: function() {\n return this.name;\n },\n\n // Evaluate the visibility of the tool and update the `display` CSS property\n updateVisibility: function() {\n const isVisible = this.computeVisibility();\n this.el.style.display = isVisible ? '' : 'none';\n this._visible = isVisible;\n },\n\n // Evaluate the visibility of the tool. The method returns `true` if the tool\n // should be visible in the DOM.\n computeVisibility() {\n if (!this.isExplicitlyVisible()) return false;\n const { visibility } = this.options;\n if (typeof visibility !== 'function') return true;\n return !!visibility.call(this, this.relatedView, this);\n },\n\n show: function() {\n this._visibleExplicit = true;\n this.updateVisibility();\n },\n\n hide: function() {\n this._visibleExplicit = false;\n this.updateVisibility();\n },\n\n // The method returns `false` if the `hide()` method was called on the tool.\n isExplicitlyVisible: function() {\n return !!this._visibleExplicit;\n },\n\n // The method returns `false` if the tool is not visible (it has `display: none`).\n // This can happen if the `hide()` method was called or the tool is not visible\n // because of the `visibility` option was evaluated to `false`.\n isVisible: function() {\n return !!this._visible;\n },\n\n focus: function() {\n var opacity = this.options.focusOpacity;\n if (isFinite(opacity)) this.el.style.opacity = opacity;\n this.parentView.focusTool(this);\n },\n\n blur: function() {\n this.el.style.opacity = '';\n this.parentView.blurTool(this);\n },\n\n update: function() {\n // to be overridden\n },\n\n guard: function(evt) {\n // Let the context-menu event bubble up to the relatedView\n const { paper, relatedView } = this;\n if (!paper || !relatedView) return true;\n return paper.guard(evt, relatedView);\n }\n});\n\n","import * as g from '../g/index.mjs';\nimport * as util from '../util/index.mjs';\nimport * as mvc from '../mvc/index.mjs';\nimport { ToolView } from '../dia/ToolView.mjs';\nimport V from '../V/index.mjs';\n\n\n// Vertex Handles\nvar VertexHandle = mvc.View.extend({\n tagName: 'circle',\n svgElement: true,\n className: 'marker-vertex',\n events: {\n mousedown: 'onPointerDown',\n touchstart: 'onPointerDown',\n dblclick: 'onDoubleClick',\n dbltap: 'onDoubleClick'\n },\n documentEvents: {\n mousemove: 'onPointerMove',\n touchmove: 'onPointerMove',\n mouseup: 'onPointerUp',\n touchend: 'onPointerUp',\n touchcancel: 'onPointerUp'\n },\n attributes: {\n 'r': 6,\n 'fill': '#33334F',\n 'stroke': '#FFFFFF',\n 'stroke-width': 2,\n 'cursor': 'move'\n },\n position: function(x, y) {\n const { vel, options } = this;\n const { scale } = options;\n let matrix = V.createSVGMatrix().translate(x, y);\n if (scale) matrix = matrix.scale(scale);\n vel.transform(matrix, { absolute: true });\n },\n onPointerDown: function(evt) {\n if (this.options.guard(evt)) return;\n evt.stopPropagation();\n evt.preventDefault();\n this.options.paper.undelegateEvents();\n this.delegateDocumentEvents(null, evt.data);\n this.trigger('will-change', this, evt);\n },\n onPointerMove: function(evt) {\n this.trigger('changing', this, evt);\n },\n onDoubleClick: function(evt) {\n this.trigger('remove', this, evt);\n },\n onPointerUp: function(evt) {\n this.trigger('changed', this, evt);\n this.undelegateDocumentEvents();\n this.options.paper.delegateEvents();\n }\n});\n\nexport const Vertices = ToolView.extend({\n name: 'vertices',\n options: {\n handleClass: VertexHandle,\n snapRadius: 20,\n redundancyRemoval: true,\n vertexAdding: true,\n // vertexRemoving: true,\n // vertexMoving: true,\n stopPropagation: true,\n scale: null\n },\n children: [{\n tagName: 'path',\n selector: 'connection',\n className: 'joint-vertices-path',\n attributes: {\n 'fill': 'none',\n 'stroke': 'transparent',\n 'stroke-width': 10,\n 'cursor': 'cell'\n }\n }],\n handles: null,\n interactiveLinkNode: null,\n events: {\n 'mousedown .joint-vertices-path': 'onPathPointerDown',\n 'touchstart .joint-vertices-path': 'onPathPointerDown'\n },\n linkEvents: {\n mousedown: 'onLinkPointerDown',\n touchstart: 'onLinkPointerDown'\n },\n onRender: function() {\n const { vertexAdding } = this.options;\n if (vertexAdding) {\n const { interactiveLinkNode = null } = vertexAdding;\n if (interactiveLinkNode) {\n this.delegateLinkEvents(interactiveLinkNode);\n } else {\n this.renderChildren();\n this.updatePath();\n }\n }\n this.resetHandles();\n this.renderHandles();\n return this;\n },\n delegateLinkEvents: function(selector) {\n this.undelegateLinkEvents();\n const el = this.relatedView.findNode(selector);\n if (!el) {\n console.warn(`Interactive link node \"${selector}\" not found.`);\n return;\n }\n el.classList.add('joint-vertices-path');\n this.interactiveLinkNode = el;\n this.delegateElementEvents(el, this.linkEvents);\n },\n undelegateLinkEvents: function() {\n const el = this.interactiveLinkNode;\n if (!el) return;\n this.undelegateElementEvents(el);\n el.classList.remove('joint-vertices-path');\n this.interactiveLinkNode = null;\n },\n update: function() {\n var relatedView = this.relatedView;\n var vertices = relatedView.model.vertices();\n if (vertices.length === this.handles.length) {\n this.updateHandles();\n } else {\n this.resetHandles();\n this.renderHandles();\n }\n if (this.options.vertexAdding) {\n this.updatePath();\n }\n return this;\n },\n resetHandles: function() {\n var handles = this.handles;\n this.handles = [];\n this.stopListening();\n if (!Array.isArray(handles)) return;\n for (var i = 0, n = handles.length; i < n; i++) {\n handles[i].remove();\n }\n },\n renderHandles: function() {\n var relatedView = this.relatedView;\n var vertices = relatedView.model.vertices();\n for (var i = 0, n = vertices.length; i < n; i++) {\n var vertex = vertices[i];\n var handle = new (this.options.handleClass)({\n index: i,\n paper: this.paper,\n scale: this.options.scale,\n guard: evt => this.guard(evt)\n });\n handle.render();\n handle.position(vertex.x, vertex.y);\n this.simulateRelatedView(handle.el);\n handle.vel.appendTo(this.el);\n this.handles.push(handle);\n this.startHandleListening(handle);\n }\n },\n updateHandles: function() {\n var relatedView = this.relatedView;\n var vertices = relatedView.model.vertices();\n for (var i = 0, n = vertices.length; i < n; i++) {\n var vertex = vertices[i];\n var handle = this.handles[i];\n if (!handle) return;\n handle.position(vertex.x, vertex.y);\n }\n },\n updatePath: function() {\n if (this.interactiveLinkNode) return;\n const connection = this.childNodes.connection;\n if (connection) connection.setAttribute('d', this.relatedView.getSerializedConnection());\n },\n startHandleListening: function(handle) {\n const { vertexRemoving = true, vertexMoving = true } = this.options;\n if (vertexMoving) {\n this.listenTo(handle, 'will-change', this.onHandleWillChange);\n this.listenTo(handle, 'changing', this.onHandleChanging);\n this.listenTo(handle, 'changed', this.onHandleChanged);\n }\n if (vertexRemoving) {\n this.listenTo(handle, 'remove', this.onHandleRemove);\n }\n },\n getNeighborPoints: function(index) {\n var linkView = this.relatedView;\n var vertices = linkView.model.vertices();\n var prev = (index > 0) ? vertices[index - 1] : linkView.sourceAnchor;\n var next = (index < vertices.length - 1) ? vertices[index + 1] : linkView.targetAnchor;\n return {\n prev: new g.Point(prev),\n next: new g.Point(next)\n };\n },\n onHandleWillChange: function(_handle, evt) {\n this.focus();\n const { relatedView, options } = this;\n relatedView.model.startBatch('vertex-move', { ui: true, tool: this.cid });\n if (!options.stopPropagation) relatedView.notifyPointerdown(...relatedView.paper.getPointerArgs(evt));\n },\n onHandleChanging: function(handle, evt) {\n const { options, relatedView: linkView } = this;\n var index = handle.options.index;\n var [normalizedEvent, x, y] = linkView.paper.getPointerArgs(evt);\n var vertex = { x, y };\n this.snapVertex(vertex, index);\n linkView.model.vertex(index, vertex, { ui: true, tool: this.cid });\n handle.position(vertex.x, vertex.y);\n if (!options.stopPropagation) linkView.notifyPointermove(normalizedEvent, x, y);\n },\n onHandleChanged: function(_handle, evt) {\n const { options, relatedView: linkView } = this;\n if (options.vertexAdding) this.updatePath();\n if (!options.redundancyRemoval) {\n linkView.checkMouseleave(util.normalizeEvent(evt));\n return;\n }\n var verticesRemoved = linkView.removeRedundantLinearVertices({ ui: true, tool: this.cid });\n if (verticesRemoved) this.render();\n this.blur();\n linkView.model.stopBatch('vertex-move', { ui: true, tool: this.cid });\n if (this.eventData(evt).vertexAdded) {\n linkView.model.stopBatch('vertex-add', { ui: true, tool: this.cid });\n }\n var [normalizedEvt, x, y] = linkView.paper.getPointerArgs(evt);\n if (!options.stopPropagation) linkView.notifyPointerup(normalizedEvt, x, y);\n linkView.checkMouseleave(normalizedEvt);\n },\n snapVertex: function(vertex, index) {\n var snapRadius = this.options.snapRadius;\n if (snapRadius > 0) {\n var neighbors = this.getNeighborPoints(index);\n var prev = neighbors.prev;\n var next = neighbors.next;\n if (Math.abs(vertex.x - prev.x) < snapRadius) {\n vertex.x = prev.x;\n } else if (Math.abs(vertex.x - next.x) < snapRadius) {\n vertex.x = next.x;\n }\n if (Math.abs(vertex.y - prev.y) < snapRadius) {\n vertex.y = neighbors.prev.y;\n } else if (Math.abs(vertex.y - next.y) < snapRadius) {\n vertex.y = next.y;\n }\n }\n },\n onHandleRemove: function(handle, evt) {\n var index = handle.options.index;\n var linkView = this.relatedView;\n linkView.model.removeVertex(index, { ui: true });\n if (this.options.vertexAdding) this.updatePath();\n linkView.checkMouseleave(util.normalizeEvent(evt));\n },\n onPathPointerDown: function(evt) {\n if (this.guard(evt)) return;\n evt.stopPropagation();\n evt.preventDefault();\n var normalizedEvent = util.normalizeEvent(evt);\n var vertex = this.paper.snapToGrid(normalizedEvent.clientX, normalizedEvent.clientY).toJSON();\n var relatedView = this.relatedView;\n relatedView.model.startBatch('vertex-add', { ui: true, tool: this.cid });\n var index = relatedView.getVertexIndex(vertex.x, vertex.y);\n this.snapVertex(vertex, index);\n relatedView.model.insertVertex(index, vertex, { ui: true, tool: this.cid });\n this.update();\n var handle = this.handles[index];\n this.eventData(normalizedEvent, { vertexAdded: true });\n handle.onPointerDown(normalizedEvent);\n },\n onLinkPointerDown: function(evt) {\n this.relatedView.preventDefaultInteraction(evt);\n this.onPathPointerDown(evt);\n },\n onRemove: function() {\n this.resetHandles();\n this.undelegateLinkEvents();\n }\n}, {\n VertexHandle: VertexHandle // keep as class property\n});\n","import * as util from '../util/index.mjs';\n\nfunction abs2rel(absolute, max) {\n\n if (max === 0) return '0%';\n // round to 3 decimal places\n const dp = 1000;\n const relative = Math.round(absolute / max * 100 * dp) / dp;\n return `${relative}%`;\n}\n\nfunction pin(relative) {\n\n return function(end, view, magnet, coords) {\n var fn = (view.isNodeConnection(magnet)) ? pinnedLinkEnd : pinnedElementEnd;\n return fn(relative, end, view, magnet, coords);\n };\n}\n\nfunction pinnedElementEnd(relative, end, view, magnet, coords) {\n\n var angle = view.model.angle();\n var bbox = view.getNodeUnrotatedBBox(magnet);\n var origin = view.model.getBBox().center();\n coords.rotate(origin, angle);\n var dx = coords.x - bbox.x;\n var dy = coords.y - bbox.y;\n\n if (relative) {\n dx = abs2rel(dx, bbox.width);\n dy = abs2rel(dy, bbox.height);\n }\n\n end.anchor = {\n name: 'topLeft',\n args: {\n dx: dx,\n dy: dy,\n rotate: true\n }\n };\n\n return end;\n}\n\nfunction pinnedLinkEnd(relative, end, view, _magnet, coords) {\n\n var connection = view.getConnection();\n if (!connection) return end;\n var length = connection.closestPointLength(coords);\n if (relative) {\n var totalLength = connection.length();\n end.anchor = {\n name: 'connectionRatio',\n args: {\n ratio: length / totalLength\n }\n };\n } else {\n end.anchor = {\n name: 'connectionLength',\n args: {\n length: length\n }\n };\n }\n return end;\n}\n\nexport const useDefaults = util.noop;\nexport const pinAbsolute = pin(false);\nexport const pinRelative = pin(true);\n\n","import * as g from '../g/index.mjs';\nimport V from '../V/index.mjs';\nimport * as util from '../util/index.mjs';\nimport * as mvc from '../mvc/index.mjs';\nimport { ToolView } from '../dia/ToolView.mjs';\nimport { getAnchor } from '../cellTools/helpers.mjs';\n\nvar SegmentHandle = mvc.View.extend({\n tagName: 'g',\n svgElement: true,\n className: 'marker-segment',\n events: {\n mousedown: 'onPointerDown',\n touchstart: 'onPointerDown'\n },\n documentEvents: {\n mousemove: 'onPointerMove',\n touchmove: 'onPointerMove',\n mouseup: 'onPointerUp',\n touchend: 'onPointerUp',\n touchcancel: 'onPointerUp'\n },\n children: [{\n tagName: 'line',\n selector: 'line',\n attributes: {\n 'stroke': '#33334F',\n 'stroke-width': 2,\n 'fill': 'none',\n 'pointer-events': 'none'\n }\n }, {\n tagName: 'rect',\n selector: 'handle',\n attributes: {\n 'width': 20,\n 'height': 8,\n 'x': -10,\n 'y': -4,\n 'rx': 4,\n 'ry': 4,\n 'fill': '#33334F',\n 'stroke': '#FFFFFF',\n 'stroke-width': 2\n }\n }],\n onRender: function() {\n this.renderChildren();\n },\n position: function(x, y, angle, view) {\n const { scale } = this.options;\n let matrix = V.createSVGMatrix().translate(x, y).rotate(angle);\n if (scale) matrix = matrix.scale(scale);\n\n var handle = this.childNodes.handle;\n handle.setAttribute('transform', V.matrixToTransformString(matrix));\n handle.setAttribute('cursor', (angle % 180 === 0) ? 'row-resize' : 'col-resize');\n\n var viewPoint = view.getClosestPoint(new g.Point(x, y));\n var line = this.childNodes.line;\n line.setAttribute('x1', x);\n line.setAttribute('y1', y);\n line.setAttribute('x2', viewPoint.x);\n line.setAttribute('y2', viewPoint.y);\n },\n onPointerDown: function(evt) {\n if (this.options.guard(evt)) return;\n this.trigger('change:start', this, evt);\n evt.stopPropagation();\n evt.preventDefault();\n this.options.paper.undelegateEvents();\n this.delegateDocumentEvents(null, evt.data);\n },\n onPointerMove: function(evt) {\n this.trigger('changing', this, evt);\n },\n onPointerUp: function(evt) {\n this.undelegateDocumentEvents();\n this.options.paper.delegateEvents();\n this.trigger('change:end', this, evt);\n },\n show: function() {\n this.el.style.display = '';\n },\n hide: function() {\n this.el.style.display = 'none';\n }\n});\n\nexport const Segments = ToolView.extend({\n name: 'segments',\n precision: .5,\n options: {\n handleClass: SegmentHandle,\n segmentLengthThreshold: 40,\n redundancyRemoval: true,\n anchor: getAnchor,\n snapRadius: 10,\n snapHandle: true,\n stopPropagation: true\n },\n handles: null,\n onRender: function() {\n this.resetHandles();\n var relatedView = this.relatedView;\n var vertices = relatedView.model.vertices();\n vertices.unshift(relatedView.sourcePoint);\n vertices.push(relatedView.targetPoint);\n for (var i = 0, n = vertices.length; i < n - 1; i++) {\n var vertex = vertices[i];\n var nextVertex = vertices[i + 1];\n var handle = this.renderHandle(vertex, nextVertex);\n this.simulateRelatedView(handle.el);\n this.handles.push(handle);\n handle.options.index = i;\n }\n return this;\n },\n renderHandle: function(vertex, nextVertex) {\n var handle = new (this.options.handleClass)({\n paper: this.paper,\n scale: this.options.scale,\n guard: evt => this.guard(evt)\n });\n handle.render();\n this.updateHandle(handle, vertex, nextVertex);\n handle.vel.appendTo(this.el);\n this.startHandleListening(handle);\n return handle;\n },\n update: function() {\n this.render();\n return this;\n },\n startHandleListening: function(handle) {\n this.listenTo(handle, 'change:start', this.onHandleChangeStart);\n this.listenTo(handle, 'changing', this.onHandleChanging);\n this.listenTo(handle, 'change:end', this.onHandleChangeEnd);\n },\n resetHandles: function() {\n var handles = this.handles;\n this.handles = [];\n this.stopListening();\n if (!Array.isArray(handles)) return;\n for (var i = 0, n = handles.length; i < n; i++) {\n handles[i].remove();\n }\n },\n shiftHandleIndexes: function(value) {\n var handles = this.handles;\n for (var i = 0, n = handles.length; i < n; i++) handles[i].options.index += value;\n },\n resetAnchor: function(type, anchor) {\n var relatedModel = this.relatedView.model;\n if (anchor) {\n relatedModel.prop([type, 'anchor'], anchor, {\n rewrite: true,\n ui: true,\n tool: this.cid\n });\n } else {\n relatedModel.removeProp([type, 'anchor'], {\n ui: true,\n tool: this.cid\n });\n }\n },\n snapHandle: function(handle, position, data) {\n\n var index = handle.options.index;\n var linkView = this.relatedView;\n var link = linkView.model;\n var vertices = link.vertices();\n var axis = handle.options.axis;\n var prev = vertices[index - 2] || data.sourceAnchor;\n var next = vertices[index + 1] || data.targetAnchor;\n var snapRadius = this.options.snapRadius;\n if (Math.abs(position[axis] - prev[axis]) < snapRadius) {\n position[axis] = prev[axis];\n } else if (Math.abs(position[axis] - next[axis]) < snapRadius) {\n position[axis] = next[axis];\n }\n return position;\n },\n\n onHandleChanging: function(handle, evt) {\n\n const { options } = this;\n var data = this.eventData(evt);\n var relatedView = this.relatedView;\n var paper = relatedView.paper;\n var index = handle.options.index - 1;\n var normalizedEvent = util.normalizeEvent(evt);\n var coords = paper.snapToGrid(normalizedEvent.clientX, normalizedEvent.clientY);\n var position = this.snapHandle(handle, coords.clone(), data);\n var axis = handle.options.axis;\n var offset = (this.options.snapHandle) ? 0 : (coords[axis] - position[axis]);\n var link = relatedView.model;\n var vertices = util.cloneDeep(link.vertices());\n var anchorFn = this.options.anchor;\n if (typeof anchorFn !== 'function') anchorFn = null;\n\n const handleIndex = handle.options.index;\n\n const vertexPoints = [relatedView.sourcePoint.clone(), ...vertices, relatedView.targetPoint.clone()];\n let indexOffset = 0;\n\n // check if vertex before handle vertex exists\n if (handleIndex - 1 >= 0) {\n const v1 = vertexPoints[handleIndex - 1];\n const v2 = vertexPoints[handleIndex];\n\n const theta = new g.Line(v1, v2).vector().theta();\n\n // check only non-orthogonal segments\n if (theta % 90 !== 0) {\n vertices.splice(handleIndex - 1, 0, data.originalVertices[handleIndex - 1]);\n indexOffset++;\n this.shiftHandleIndexes(1);\n }\n }\n\n var vertex = vertices[index + indexOffset];\n var nextVertex = vertices[index + 1 + indexOffset];\n\n // check if vertex after handle vertex exists\n if (handleIndex + 2 < vertexPoints.length) {\n const v1 = vertexPoints[handleIndex + 1];\n const v2 = vertexPoints[handleIndex + 2];\n\n const theta = new g.Line(v1, v2).vector().theta();\n\n // check only non-orthogonal segments\n if (theta % 90 !== 0) {\n const isSingleVertex = data.originalVertices.length === 1;\n const origVIndex = isSingleVertex ? 0 : handleIndex;\n const additionalOffset = data.firstHandleShifted && !isSingleVertex ? 1 : 0;\n let nextVIndex = 1 + indexOffset;\n vertices.splice(handleIndex + nextVIndex, 0, data.originalVertices[origVIndex - additionalOffset]);\n }\n }\n\n // First Segment\n var sourceView = relatedView.sourceView;\n var sourceBBox = relatedView.sourceBBox;\n var changeSourceAnchor = false;\n var deleteSourceAnchor = false;\n if (!vertex) {\n vertex = relatedView.sourceAnchor.toJSON();\n vertex[axis] = position[axis];\n if (sourceBBox.containsPoint(vertex)) {\n vertex[axis] = position[axis];\n changeSourceAnchor = true;\n } else {\n // we left the area of the source magnet for the first time\n vertices.unshift(vertex);\n this.shiftHandleIndexes(1);\n data.firstHandleShifted = true;\n deleteSourceAnchor = true;\n }\n } else if (index === 0) {\n if (sourceBBox.containsPoint(vertex)) {\n vertices.shift();\n this.shiftHandleIndexes(-1);\n changeSourceAnchor = true;\n } else {\n vertex[axis] = position[axis];\n deleteSourceAnchor = true;\n }\n } else {\n vertex[axis] = position[axis];\n }\n\n if (anchorFn && sourceView) {\n if (changeSourceAnchor) {\n var sourceAnchorPosition = data.sourceAnchor.clone();\n sourceAnchorPosition[axis] = position[axis];\n var sourceAnchor = anchorFn.call(relatedView, sourceAnchorPosition, sourceView, relatedView.sourceMagnet || sourceView.el, 'source', relatedView);\n this.resetAnchor('source', sourceAnchor);\n }\n if (deleteSourceAnchor) {\n this.resetAnchor('source', data.sourceAnchorDef);\n }\n }\n\n // Last segment\n var targetView = relatedView.targetView;\n var targetBBox = relatedView.targetBBox;\n var changeTargetAnchor = false;\n var deleteTargetAnchor = false;\n if (!nextVertex) {\n nextVertex = relatedView.targetAnchor.toJSON();\n nextVertex[axis] = position[axis];\n if (targetBBox.containsPoint(nextVertex)) {\n changeTargetAnchor = true;\n } else {\n // we left the area of the target magnet for the first time\n vertices.push(nextVertex);\n deleteTargetAnchor = true;\n }\n } else if (index === vertices.length - 2) {\n if (targetBBox.containsPoint(nextVertex)) {\n vertices.pop();\n changeTargetAnchor = true;\n } else {\n nextVertex[axis] = position[axis];\n deleteTargetAnchor = true;\n }\n } else {\n nextVertex[axis] = position[axis];\n }\n\n if (anchorFn && targetView) {\n if (changeTargetAnchor) {\n var targetAnchorPosition = data.targetAnchor.clone();\n targetAnchorPosition[axis] = position[axis];\n var targetAnchor = anchorFn.call(relatedView, targetAnchorPosition, targetView, relatedView.targetMagnet || targetView.el, 'target', relatedView);\n this.resetAnchor('target', targetAnchor);\n }\n if (deleteTargetAnchor) {\n this.resetAnchor('target', data.targetAnchorDef);\n }\n }\n if (vertices.some(v => !v)) {\n // This can happen when the link is using a smart routing and the number of\n // vertices is not the same as the number of route points.\n throw new Error('Segments: incompatible router in use');\n }\n link.vertices(vertices, { ui: true, tool: this.cid });\n this.updateHandle(handle, vertex, nextVertex, offset);\n if (!options.stopPropagation) relatedView.notifyPointermove(normalizedEvent, coords.x, coords.y);\n },\n onHandleChangeStart: function(handle, evt) {\n const { options, handles, relatedView: linkView } = this;\n const { model, paper } = linkView;\n var index = handle.options.index;\n if (!Array.isArray(handles)) return;\n for (var i = 0, n = handles.length; i < n; i++) {\n if (i !== index) handles[i].hide();\n }\n this.focus();\n this.eventData(evt, {\n sourceAnchor: linkView.sourceAnchor.clone(),\n targetAnchor: linkView.targetAnchor.clone(),\n sourceAnchorDef: util.clone(model.prop(['source', 'anchor'])),\n targetAnchorDef: util.clone(model.prop(['target', 'anchor'])),\n originalVertices: util.cloneDeep(model.vertices()),\n firstHandleShifted: false\n });\n model.startBatch('segment-move', { ui: true, tool: this.cid });\n if (!options.stopPropagation) linkView.notifyPointerdown(...paper.getPointerArgs(evt));\n },\n onHandleChangeEnd: function(_handle, evt) {\n const { options, relatedView: linkView }= this;\n const { paper, model } = linkView;\n if (options.redundancyRemoval) {\n linkView.removeRedundantLinearVertices({ ui: true, tool: this.cid });\n }\n const normalizedEvent = util.normalizeEvent(evt);\n const coords = paper.snapToGrid(normalizedEvent.clientX, normalizedEvent.clientY);\n this.render();\n this.blur();\n model.stopBatch('segment-move', { ui: true, tool: this.cid });\n if (!options.stopPropagation) linkView.notifyPointerup(normalizedEvent, coords.x, coords.y);\n linkView.checkMouseleave(normalizedEvent);\n },\n updateHandle: function(handle, vertex, nextVertex, offset) {\n var vertical = Math.abs(vertex.x - nextVertex.x) < this.precision;\n var horizontal = Math.abs(vertex.y - nextVertex.y) < this.precision;\n if (vertical || horizontal) {\n var segmentLine = new g.Line(vertex, nextVertex);\n var length = segmentLine.length();\n if (length < this.options.segmentLengthThreshold) {\n handle.hide();\n } else {\n var position = segmentLine.midpoint();\n var axis = (vertical) ? 'x' : 'y';\n position[axis] += offset || 0;\n var angle = segmentLine.vector().vectorAngle(new g.Point(1, 0));\n handle.position(position.x, position.y, angle, this.relatedView);\n handle.show();\n handle.options.axis = axis;\n }\n } else {\n handle.hide();\n }\n },\n onRemove: function() {\n this.resetHandles();\n }\n}, {\n SegmentHandle: SegmentHandle // keep as class property\n});\n","import * as connectionStrategies from '../connectionStrategies/index.mjs';\n\nexport function getViewBBox(view, useModelGeometry) {\n const { model } = view;\n if (useModelGeometry) return model.getBBox();\n return (model.isLink()) ? view.getConnection().bbox() : view.getNodeUnrotatedBBox(view.el);\n}\n\nexport function getAnchor(coords, view, magnet) {\n // take advantage of an existing logic inside of the\n // pin relative connection strategy\n var end = connectionStrategies.pinRelative.call(\n this.paper,\n {},\n view,\n magnet,\n coords,\n this.model\n );\n return end.anchor;\n}\n\nexport function snapAnchor(coords, view, magnet, type, relatedView, toolView) {\n var snapRadius = toolView.options.snapRadius;\n var isSource = (type === 'source');\n var refIndex = (isSource ? 0 : -1);\n var ref = this.model.vertex(refIndex) || this.getEndAnchor(isSource ? 'target' : 'source');\n if (ref) {\n if (Math.abs(ref.x - coords.x) < snapRadius) coords.x = ref.x;\n if (Math.abs(ref.y - coords.y) < snapRadius) coords.y = ref.y;\n }\n return coords;\n}\n","import * as mvc from '../mvc/index.mjs';\nimport * as util from '../util/index.mjs';\nimport { CellView } from './CellView.mjs';\nimport { LayersNames } from './PaperLayer.mjs';\nimport { ToolView } from './ToolView.mjs';\n\nexport const ToolsView = mvc.View.extend({\n tagName: 'g',\n className: 'tools',\n svgElement: true,\n tools: null,\n isRendered: false,\n options: {\n tools: null,\n relatedView: null,\n name: null,\n // layer?: LayersNames.TOOLS\n // z?: number\n },\n\n configure: function(options) {\n options = util.assign(this.options, options);\n var tools = options.tools;\n if (!Array.isArray(tools)) return this;\n var relatedView = options.relatedView;\n if (!(relatedView instanceof CellView)) return this;\n var views = this.tools = [];\n for (var i = 0, n = tools.length; i < n; i++) {\n var tool = tools[i];\n if (!(tool instanceof ToolView)) continue;\n tool.configure(relatedView, this);\n this.vel.append(tool.el);\n views.push(tool);\n }\n this.isRendered = false;\n relatedView.requestUpdate(relatedView.getFlag('TOOLS'));\n return this;\n },\n\n getName: function() {\n return this.options.name;\n },\n\n update: function(opt) {\n\n opt || (opt = {});\n const tools = this.tools;\n if (!tools) return this;\n const n = tools.length;\n const wasRendered = this.isRendered;\n for (let i = 0; i < n; i++) {\n const tool = tools[i];\n tool.updateVisibility();\n if (!tool.isVisible()) continue;\n if (this.ensureToolRendered(tools, i) && opt.tool !== tool.cid) {\n tool.update();\n }\n }\n if (!this.isRendered && n > 0) {\n // None of the tools is visible\n // Note: ToolsView with no tools are always mounted\n return this;\n }\n if (!this.isMounted()) {\n this.mount();\n }\n if (!wasRendered) {\n // Make sure tools are visible (if they were hidden and the tool removed)\n this.blurTool();\n }\n return this;\n },\n\n ensureToolRendered(tools, i) {\n if (!this.isRendered) {\n // There is at least one visible tool\n this.isRendered = Array(tools.length).fill(false);\n }\n if (!this.isRendered[i]) {\n // First update executes render()\n tools[i].render();\n this.isRendered[i] = true;\n return false;\n }\n return true;\n },\n\n focusTool: function(focusedTool) {\n\n var tools = this.tools;\n if (!tools) return this;\n for (var i = 0, n = tools.length; i < n; i++) {\n var tool = tools[i];\n if (focusedTool === tool) {\n tool.show();\n } else {\n tool.hide();\n }\n }\n return this;\n },\n\n blurTool: function(blurredTool) {\n var tools = this.tools;\n if (!tools) return this;\n for (var i = 0, n = tools.length; i < n; i++) {\n var tool = tools[i];\n if (tool !== blurredTool && !tool.isExplicitlyVisible()) {\n tool.show();\n // Check if the tool is conditionally visible too\n if (tool.isVisible()) {\n this.ensureToolRendered(tools, i) && tool.update();\n }\n }\n }\n return this;\n },\n\n hide: function() {\n return this.focusTool(null);\n },\n\n show: function() {\n this.blurTool(null);\n // If this the first time the tools are shown, make sure they are mounted\n if (!this.isMounted()) {\n this.mount();\n }\n return this;\n },\n\n onRemove: function() {\n var tools = this.tools;\n if (!tools) return this;\n for (var i = 0, n = tools.length; i < n; i++) {\n tools[i].remove();\n }\n this.tools = null;\n },\n\n mount: function() {\n const { options, el } = this;\n const { relatedView, layer = LayersNames.TOOLS, z } = options;\n if (relatedView) {\n if (layer) {\n relatedView.paper.getLayerView(layer).insertSortedNode(el, z);\n } else {\n relatedView.el.appendChild(el);\n }\n }\n return this;\n }\n\n});\n","import * as joint from '@joint/core';\r\n\r\ninterface FlowEditorOptions {\r\n container: HTMLElement;\r\n width: number;\r\n height: number;\r\n dotNetHelper: any;\r\n futureStateMode: boolean;\r\n}\r\n\r\ninterface FlowPreviewOptions {\r\n container: HTMLElement;\r\n graphJson: string;\r\n}\r\n\r\nenum ShapeType {\r\n CorporationCFC = 1,\r\n BranchThirdParty = 2,\r\n Partnership = 3,\r\n HybridEntity = 4,\r\n ReverseHybridEntity = 5,\r\n DRE = 6,\r\n Group = 7,\r\n}\r\n\r\nenum TransactionType {\r\n ServiceFee,\r\n Royalty,\r\n IPTransfer,\r\n}\r\n\r\nenum FlowType {\r\n Physical,\r\n Legal,\r\n Payment,\r\n Service,\r\n IPTransfer,\r\n IPLicense,\r\n Agreement,\r\n Miscellaneous,\r\n}\r\n\r\nenum Jurisdiction {\r\n US = 1,\r\n NonUS = 2,\r\n Mixed = 3,\r\n}\r\n\r\nenum PaymentType {\r\n Royalty = 0,\r\n ServiceFee = 1,\r\n BuySell = 2,\r\n}\r\n\r\nclass DefaultValues {\r\n static readonly PrimaryColor: string = '#000000';\r\n static readonly SecondaryColor: string = '#0D838F';\r\n static readonly EmphasizedColor: string = '#87BC24';\r\n static readonly ThirdPartyColor: string = '#52575B';\r\n}\r\n\r\ntype LinkTypeColor = {\r\n type: string;\r\n color: string;\r\n};\r\n\r\nconst linkTypeColors: readonly LinkTypeColor[] = [\r\n { type: 'PhysicalLink', color: '#CE1210' },\r\n { type: 'LegalLink', color: '#99C13C' },\r\n { type: 'PaymentLink', color: '#9B9B9D' },\r\n { type: 'ServiceLink', color: 'black' },\r\n { type: 'IPTransferLink', color: '#FFA500' },\r\n { type: 'IPLicenseLink', color: '#8E25AB' },\r\n { type: 'AgreementLink', color: '#256F8C' },\r\n { type: 'MiscellaneousLink', color: '#EB8100' }\r\n];\r\n\r\nclass Node extends joint.dia.Element {\r\n //_entityIds: string[] = [];\r\n get entityIds() {\r\n return this.prop('entityIds');\r\n }\r\n set entityIds(value: string[]) {\r\n this.prop('entityIds', value);\r\n }\r\n\r\n get isNewEntity() {\r\n return this.prop('isNewEntity');\r\n }\r\n set isNewEntity(value: boolean) {\r\n this.prop('isNewEntity', value);\r\n }\r\n\r\n public setColor(color: string) {\r\n this.attr('body/fill', color);\r\n }\r\n\r\n get functions() {\r\n return this.prop('functions');\r\n }\r\n set functions(value: string[]) {\r\n this.removeProp('functions');\r\n this.prop('functions', value);\r\n }\r\n\r\n public setColorByJurisdiction(jurisdiction: Jurisdiction) {\r\n switch (jurisdiction) {\r\n case Jurisdiction.US:\r\n this.setColor(DefaultValues.PrimaryColor);\r\n break;\r\n case Jurisdiction.NonUS:\r\n this.setColor(DefaultValues.SecondaryColor);\r\n break;\r\n case Jurisdiction.Mixed: // overridden in EntityGroup\r\n this.setColor(DefaultValues.PrimaryColor);\r\n break;\r\n default:\r\n this.setColor(DefaultValues.PrimaryColor);\r\n break;\r\n }\r\n }\r\n\r\n public setLabel(label: string) {\r\n // if the string is too long, split on all spaces and add a newline where the string exceeds a certain length\r\n if (label.length > 15) {\r\n var splitLabel = '';\r\n var words = label.split(' ');\r\n var lineLength = 0;\r\n words.forEach(word => {\r\n if (lineLength + word.length > 15) {\r\n splitLabel += '\\n' + word + ' ';\r\n lineLength = word.length;\r\n } else {\r\n splitLabel += word + ' ';\r\n lineLength += word.length;\r\n }\r\n });\r\n\r\n this.attr('label/text', splitLabel.trim());\r\n } else {\r\n this.attr('label/text', label);\r\n }\r\n }\r\n\r\n public setSecondaryLabel(label: string) {\r\n // if the string is too long, split on all spaces and add a newline where the string exceeds a certain length\r\n if (label.length > 15) {\r\n var splitLabel = '';\r\n var words = label.split(' ');\r\n var lineLength = 0;\r\n words.forEach(word => {\r\n if (lineLength + word.length > 15) {\r\n splitLabel += '\\n' + word + ' ';\r\n lineLength = word.length;\r\n } else {\r\n splitLabel += word + ' ';\r\n lineLength += word.length;\r\n }\r\n });\r\n this.attr('label2/text', splitLabel.trim());\r\n } else {\r\n this.attr('label2/text', label);\r\n }\r\n }\r\n\r\n public async setFunctionIcon(iconName: string): Promise<void> {\r\n try {\r\n const iconPath = `/icons/functions/${iconName}.svg`;\r\n\r\n const response = await fetch(iconPath);\r\n if (!response.ok) {\r\n throw new Error(`HTTP error! Status: ${response.status}`);\r\n }\r\n const svgContent = await response.text();\r\n const encodedSvg = encodeURIComponent(svgContent);\r\n\r\n this.attr({\r\n functionIcon: {\r\n 'xlink:href': `data:image/svg+xml;utf8,${encodedSvg}`\r\n }\r\n });\r\n } catch (error) {\r\n console.error('Failed to load SVG:', error);\r\n }\r\n }\r\n\r\n public async addFunctionIcons(functions: string[]): Promise<void> {\r\n console.debug(\"old functions: \", this.functions)\r\n console.debug(\"new functions: \", functions)\r\n this.functions = functions;\r\n const iconSize = 30;\r\n const padding = 5;\r\n const elementWidth = 170;\r\n const elementHeight = 100;\r\n\r\n //// Check if there is already a functionIcon with a non-empty href\r\n //const existingIconHref = this.attr('functionIcon/xlink:href');\r\n //let startX;\r\n //let startY = iconSize;\r\n\r\n //if (existingIconHref && existingIconHref !== '') {\r\n // // If there's an existing icon, start to the left of it\r\n // startX = elementWidth - (functions.length * iconSize + (functions.length - 1) * padding) - padding;\r\n //} else {\r\n // // If no existing icon, start from the left side of the element\r\n // startX = (iconSize / 2);\r\n //}\r\n\r\n //for (let i = 0; i < functions.length; i++) {\r\n // const functionName = functions[i];\r\n\r\n // try {\r\n // const iconPath = `/icons/functions/${functionName}.svg`;\r\n\r\n // const response = await fetch(iconPath);\r\n // if (!response.ok) {\r\n // throw new Error(`HTTP error! Status: ${response.status}`);\r\n // }\r\n // const svgContent = await response.text();\r\n // const encodedSvg = encodeURIComponent(svgContent);\r\n\r\n // const refX = (startX / elementWidth) * 100 + '%';\r\n // const refY = (startY / elementHeight) * 100 + '%';\r\n\r\n // this.attr({\r\n // [`functionIcon${i}`]: {\r\n // 'xlink:href': `data:image/svg+xml;utf8,${encodedSvg}`,\r\n // width: iconSize,\r\n // height: iconSize,\r\n // refX: refX,\r\n // refY: refY,\r\n // }\r\n // });\r\n\r\n // startX += iconSize + padding;\r\n\r\n // } catch (error) {\r\n // console.error(`Failed to load SVG for ${functionName}:`, error);\r\n // }\r\n //}\r\n }\r\n}\r\n\r\ninterface EntityNodeOptions {\r\n jurisdiction: Jurisdiction;\r\n shape: ShapeType;\r\n label: string;\r\n entityIds: string[];\r\n functions: string[];\r\n isNewEntity: boolean;\r\n}\r\n\r\ninterface MenuOption {\r\n text: string;\r\n action: () => void | any;\r\n subMenu?: MenuOption[];\r\n}\r\n\r\nenum ToolMode {\r\n AddFlow,\r\n AddTransaction,\r\n DrawRectangle,\r\n MoveExpense,\r\n MoveRevenue,\r\n MoveFunction,\r\n}\r\n\r\nconst toolModesWithTargetSelection = [ToolMode.AddFlow, ToolMode.AddTransaction, ToolMode.MoveExpense, ToolMode.MoveRevenue, ToolMode.MoveFunction];\r\n\r\nexport class FlowEditor {\r\n private readonly namespace = joint.shapes;\r\n private paper: joint.dia.Paper;\r\n private graph: joint.dia.Graph;\r\n private dotNetHelper: any;\r\n private readonly futureStateMode: boolean;\r\n private readonly container: HTMLElement;\r\n\r\n // context variables\r\n private activeTool: ToolMode | null = null;\r\n // for adding flows\r\n private flowTypeToCreate: FlowType | null = null;\r\n // for adding transactions\r\n private transactionTypeToCreate: TransactionType | null = null;\r\n // for adding flows or transactions\r\n private selectedElement: joint.dia.Element | null = null;\r\n private hoveredElementClickDisabled: boolean = false;\r\n // for moving functions\r\n private functionNameToMove: string | null = null;\r\n // for drawing rectangles\r\n private startRectangle: { x: number, y: number } | null = null;\r\n private tempRectangleElement: DrawnRectangle | null = null;\r\n // for panning the paper\r\n private panStartPosition: { x: number, y: number } | null = null;\r\n\r\n\r\n public getGraphJson() {\r\n var graphJson = JSON.stringify(this.graph?.toJSON());\r\n return graphJson;\r\n }\r\n\r\n\r\n public setGraphJson(graphJson: string) {\r\n console.debug('setGraphJson');\r\n this.closeMenus();\r\n\r\n if (graphJson) {\r\n console.debug('loading graph from JSON');\r\n this.paper.model.fromJSON(JSON.parse(graphJson), { cellNamespace: this.namespace });\r\n\r\n this.graph.getElements().forEach(element => {\r\n if (element instanceof Node) {\r\n let markup = element.get('markup');\r\n\r\n if (!Array.isArray(markup)) {\r\n markup = [markup];\r\n }\r\n\r\n // clean-up unused function icon markup\r\n const newMarkup = markup.filter(markupElement =>\r\n typeof markupElement === 'object' && 'tagName' in markupElement && markupElement.tagName !== 'image' && !markupElement.selector.includes('functionIcon')\r\n );\r\n\r\n element.set('markup', newMarkup);\r\n\r\n // backwards compatibility check for entity ids with spaces in them (in case flows were created before spaces were disallowed)\r\n const entityIds = element.entityIds;\r\n if (entityIds.some(id => id.includes(' '))) {\r\n element.entityIds = entityIds.map(id => id.replace(' ', '_'));\r\n }\r\n\r\n // backwards compatibility check for populating flow legend with entities created before svgPath property was defined\r\n if (element.get('type') !== null && !element.get('svgPath')) {\r\n const entityType = element.get('type');\r\n const svgPath = `/icons/${entityType}.svg`;\r\n element.set('svgPath', svgPath);\r\n }\r\n }\r\n });\r\n\r\n // TEMP workaround for populating flow legend with links created before custom link classes were defined\r\n this.graph.getLinks().forEach(link => {\r\n\r\n // delete instances of MiscellaneousLink\r\n if (link instanceof MiscellaneousLink) {\r\n link.remove();\r\n return;\r\n }\r\n // and check legacy flows by colorMiscellaneousLinks\r\n else if (link.attributes.type === 'standard.Link' && link.attributes.attrs?.line?.stroke === '#EB8100') {\r\n link.remove();\r\n return;\r\n }\r\n\r\n if (link.attributes.type === 'standard.Link' && link.attributes.attrs?.line?.stroke) {\r\n const linkColor = link.attributes.attrs.line.stroke;\r\n const matchingLink = linkTypeColors.find(lc => lc.color === linkColor);\r\n\r\n if (matchingLink) {\r\n link.attributes.color = linkColor;\r\n link.attributes.type = matchingLink.type;\r\n }\r\n }\r\n\r\n });\r\n\r\n this.paper.scale(1, 1);\r\n this.paper.transformToFitContent({ verticalAlign: 'middle', horizontalAlign: 'middle', minScale: 1, maxScale: 1 });\r\n } else {\r\n console.debug('creating new graph');\r\n this.paper.model.clear();\r\n }\r\n console.debug('setGraphJson done');\r\n }\r\n\r\n\r\n\r\n // Invoked by C#\r\n private setRectangleMode(value: boolean) {\r\n console.debug('rectangle mode ' + value)\r\n this.activeTool = value ? ToolMode.DrawRectangle : null;\r\n }\r\n\r\n private drawRectangle(evt: joint.dia.Event, x: number, y: number) {\r\n if (this.startRectangle) {\r\n console.debug('drawing rectangle')\r\n this.tempRectangleElement?.remove();\r\n\r\n // Create the rectangle shape (if it is big enough to be visible, based on gridSize)\r\n if (Math.abs(x - this.startRectangle.x) >= this.paper.options.gridSize\r\n && Math.abs(y - this.startRectangle.y) >= this.paper.options.gridSize) {\r\n\r\n this.tempRectangleElement = new DrawnRectangle({\r\n size: {\r\n width: Math.abs(x - this.startRectangle.x),\r\n height: Math.abs(y - this.startRectangle.y)\r\n },\r\n position: {\r\n x: this.startRectangle.x > x ? x : this.startRectangle.x,\r\n y: this.startRectangle.y > y ? y : this.startRectangle.y\r\n },\r\n });\r\n\r\n // Add the shape to the graph\r\n this.graph.addCell(this.tempRectangleElement);\r\n }\r\n }\r\n }\r\n\r\n private async addTransaction(source: Node, target: Node, transactionType: TransactionType) {\r\n // if the source and target are the same, do nothing\r\n if (source.id != target.id) {\r\n\r\n // Determine success based on transaction type and future state mode\r\n switch (transactionType) {\r\n case TransactionType.ServiceFee:\r\n this.futureStateMode ? await this.addPaymentByDialog(source, target, PaymentType.ServiceFee, FlowType.Service) : true;\r\n break;\r\n case TransactionType.Royalty:\r\n this.futureStateMode ? await this.addPaymentByDialog(source, target, PaymentType.Royalty, FlowType.IPLicense) : true;\r\n break;\r\n case TransactionType.IPTransfer:\r\n this.futureStateMode ? await this.addIPTransferByDialog(target, source, FlowType.IPTransfer) : true;\r\n break;\r\n default:\r\n throw new Error(\"Unsupported transaction type\");\r\n }\r\n }\r\n }\r\n\r\n private addFlow(source: joint.dia.Element, target: joint.dia.Element, flowType: FlowType, label?: string | null, stepId?: string) {\r\n if (source.id != target.id) {\r\n let newLink: joint.shapes.standard.Link;\r\n\r\n switch (flowType) {\r\n case FlowType.Physical:\r\n newLink = new (joint.shapes as any).PhysicalLink();\r\n break;\r\n case FlowType.Legal:\r\n newLink = new (joint.shapes as any).LegalLink();\r\n break;\r\n case FlowType.Payment:\r\n newLink = new (joint.shapes as any).PaymentLink();\r\n break;\r\n case FlowType.Service:\r\n newLink = new (joint.shapes as any).ServiceLink();\r\n break;\r\n case FlowType.IPTransfer:\r\n newLink = new (joint.shapes as any).IPTransferLink();\r\n break;\r\n case FlowType.IPLicense:\r\n newLink = new (joint.shapes as any).IPLicenseLink();\r\n break;\r\n case FlowType.Agreement:\r\n newLink = new (joint.shapes as any).AgreementLink();\r\n break;\r\n case FlowType.Miscellaneous:\r\n newLink = new (joint.shapes as any).MiscellaneousLink();\r\n break;\r\n }\r\n\r\n if (stepId) {\r\n newLink.prop('stepId', stepId);\r\n }\r\n\r\n newLink.source(source);\r\n newLink.target(target);\r\n var sourceEntityIds = (source as Node).entityIds;\r\n var targetEntityIds = (target as Node).entityIds;\r\n\r\n if (!stepId && this.futureStateMode == true) {\r\n // call C# to add AddRelationshipStep\r\n stepId = this.dotNetHelper.invokeMethod('AddRelationshipStep', sourceEntityIds, targetEntityIds, newLink.labels()[0]?.attrs.text.text, flowType);\r\n newLink.prop('stepId', stepId);\r\n }\r\n\r\n this.graph.addCell(newLink);\r\n\r\n this.dotNetHelper.invokeMethodAsync('SetFlowLegendItems');\r\n }\r\n }\r\n\r\n // called from C#\r\n private addFlowBetweenEntities(sourceEntityId: string, targetEntityId: string, flowType: FlowType, label: string, stepId: string): void {\r\n const sourceNode = this.graph.getElements().find(node => node instanceof Node && node.entityIds.includes(sourceEntityId));\r\n const targetNode = this.graph.getElements().find(node => node instanceof Node && node.entityIds.includes(targetEntityId));\r\n\r\n if (sourceNode && targetNode) {\r\n this.addFlow(sourceNode, targetNode, flowType, label, stepId);\r\n }\r\n }\r\n\r\n // called from C#\r\n private removeFlowBetweenEntities(sourceEntityId: string, targetEntityId: string, flowType: FlowType): void {\r\n const links = this.graph.getLinks();\r\n const linkToRemove = links.filter(link => {\r\n const sourceNode = link.getSourceElement() as Node;\r\n const targetNode = link.getTargetElement() as Node;\r\n const sourceEntityIds = sourceNode.entityIds;\r\n const targetEntityIds = targetNode.entityIds;\r\n let linkType;\r\n switch (flowType) {\r\n case FlowType.Physical:\r\n linkType = 'PhysicalLink';\r\n break;\r\n case FlowType.Legal:\r\n linkType = 'LegalLink';\r\n break;\r\n case FlowType.Payment:\r\n linkType = 'PaymentLink';\r\n break;\r\n case FlowType.Service:\r\n linkType = 'ServiceLink';\r\n break;\r\n case FlowType.IPTransfer:\r\n linkType = 'IPTransferLink';\r\n break;\r\n case FlowType.IPLicense:\r\n linkType = 'IPLicenseLink';\r\n break;\r\n case FlowType.Agreement:\r\n linkType = 'AgreementLink';\r\n break;\r\n case FlowType.Miscellaneous:\r\n linkType = 'MiscellaneousLink';\r\n break;\r\n }\r\n\r\n return sourceEntityIds.includes(sourceEntityId) && targetEntityIds.includes(targetEntityId) && link.attributes.type === linkType;\r\n });\r\n\r\n linkToRemove.forEach(link => {\r\n link.remove();\r\n });\r\n\r\n this.dotNetHelper.invokeMethodAsync('SetFlowLegendItems');\r\n }\r\n\r\n // Called from C#\r\n private removeFlowByStepId(stepId: string): void {\r\n const links = this.graph.getLinks();\r\n const linksToRemove = links.filter(link => link.prop('stepId') === stepId);\r\n if (linksToRemove) {\r\n linksToRemove.forEach(link => link.remove());\r\n this.dotNetHelper.invokeMethodAsync('SetFlowLegendItems');\r\n }\r\n }\r\n\r\n // Called from C#\r\n private toggleFlowElementVisibility(flowType: string, isVisible: boolean) {\r\n let elements;\r\n elements = this.graph.getCells().filter(cell => {\r\n return cell.attributes.type?.toLowerCase().replace('link', '') === flowType.toLowerCase().replace('link', '');\r\n });\r\n\r\n elements.forEach(element => {\r\n // Show/Hide entity cells\r\n element.attr('body/display', isVisible ? 'block' : 'none');\r\n const elementView = this.paper.findViewByModel(element);\r\n\r\n if (elementView) {\r\n const children = elementView.el.querySelectorAll('*');\r\n children.forEach((child: SVGElement) => {\r\n child.setAttribute('display', isVisible ? 'block' : 'none');\r\n });\r\n }\r\n\r\n if (element instanceof joint.shapes.standard.Link) {\r\n element.attr('line/display', isVisible ? 'block' : 'none');\r\n element.label(0, {\r\n attrs: {\r\n text: { display: isVisible ? 'block' : 'none' },\r\n rect: { display: isVisible ? 'block' : 'none' }\r\n }\r\n });\r\n }\r\n\r\n });\r\n\r\n this.dotNetHelper.invokeMethodAsync('SetFlowLegendItems');\r\n }\r\n\r\n private openMenu(cell: joint.dia.Cell, x: number, y: number) {\r\n // 1. Create Menu\r\n var menu = document.createElement('div');\r\n menu.className = 'flow-editor-menu';\r\n\r\n // 2. Position Menu\r\n menu.style.top = y + 'px'; //evt.pageY\r\n menu.style.left = x + 'px'; //evt.pageX\r\n\r\n // 3. Add Menu Options\r\n var options: MenuOption[] = [];\r\n\r\n if (cell instanceof EmptyElement || cell instanceof EmptyThirdParty) {\r\n options = [\r\n //{ text: 'Choose Entity(s)', action: async () => { await this.chooseEntities(cell) } },\r\n { text: null, action: null },\r\n { text: 'Delete', action: () => { cell.remove() } },\r\n ];\r\n } else if (cell instanceof DrawnRectangle) {\r\n options = [\r\n { text: 'Edit Label', action: () => { this.changeElementPrimaryText(cell) } },\r\n { text: null, action: null },\r\n { text: 'Delete', action: () => { cell.remove() } },\r\n ];\r\n } else if (cell instanceof Node) {\r\n if (this.futureStateMode) {\r\n options = [\r\n {\r\n text: 'Add Transaction', action: null,\r\n subMenu: [\r\n { text: 'Pay a Service Fee to...', action: () => { this.beginAddTransaction(cell, TransactionType.ServiceFee) } },\r\n { text: 'Pay a Royalty Fee to...', action: () => { this.beginAddTransaction(cell, TransactionType.Royalty) } },\r\n { text: 'Transfer IP to...', action: () => { this.beginAddTransaction(cell, TransactionType.IPTransfer) } },\r\n ]\r\n },\r\n { text: 'Move Revenues to...', action: () => { this.beginMoveRevenue(cell) } },\r\n { text: 'Move Expenses to...', action: () => { this.beginMoveExpense(cell) } },\r\n ];\r\n\r\n if (!(cell instanceof EntityGroup)) {\r\n // Ability to add, remove, or edit existing functions\r\n options = options.concat([\r\n {\r\n text: 'Edit Function(s)',\r\n action: () => {\r\n this.dotNetHelper.invokeMethodAsync('EditEntityFunctions', cell.entityIds[0], cell.functions)\r\n }\r\n },\r\n ]);\r\n // Move an existing function\r\n if (cell.functions?.length > 0) {\r\n options = options.concat([\r\n {\r\n text: 'Move Function', action: null,\r\n subMenu: cell.functions.map((functionName, index) => {\r\n return {\r\n text: functionName,\r\n action: () => { this.beginMoveFunction(cell, functionName) }\r\n };\r\n })\r\n }\r\n ]);\r\n }\r\n // No existing functions to move\r\n else {\r\n options = options.concat([\r\n {\r\n text: 'Move Function', action: () => null,\r\n subMenu: [\r\n {\r\n text: 'No functions available', action: () => null\r\n }\r\n ]\r\n },\r\n ]);\r\n }\r\n }\r\n\r\n options.push({ text: null, action: null });\r\n }\r\n\r\n options = options.concat([\r\n {\r\n text: 'Add Flow', action: null,\r\n subMenu: [\r\n { text: 'Physical', action: () => { this.beginAddFlow(cell, FlowType.Physical) } },\r\n { text: 'Legal Title', action: () => { this.beginAddFlow(cell, FlowType.Legal) } },\r\n { text: 'Payment', action: () => { this.beginAddFlow(cell, FlowType.Payment) } },\r\n { text: 'Service', action: () => { this.beginAddFlow(cell, FlowType.Service) } },\r\n { text: 'IP Transfer', action: () => { this.beginAddFlow(cell, FlowType.IPTransfer) } },\r\n { text: 'IP License', action: () => { this.beginAddFlow(cell, FlowType.IPLicense) } },\r\n { text: 'Agreement', action: () => { this.beginAddFlow(cell, FlowType.Agreement) } },\r\n //TODO: cleanup Miscellaneous flows throughout solution\r\n //{ text: 'Miscellaneous', action: () => { this.beginAddFlow(cell, FlowType.Miscellaneous) } },\r\n ]\r\n },\r\n { text: null, action: null },\r\n ]);\r\n\r\n if (this.futureStateMode) {\r\n if (cell.isNewEntity) {\r\n options = options.concat([\r\n { text: 'Edit P&L', action: () => { this.addPnlByDialog(cell) } }\r\n ]);\r\n }\r\n options = options.concat([\r\n { text: 'Preview P&L', action: () => { this.dotNetHelper.invokeMethodAsync('PreviewPnlByDialog', cell.entityIds, cell.attr('label/text')) } },\r\n ]);\r\n }\r\n\r\n // TODO: After design is agreed upon, re-implement function icons feature...\r\n //const functionIconOptions = [\r\n // { text: 'Commercial', action: () => { this.changeFunctionIcon(cell, 'Commercial') } },\r\n // { text: 'Deliver', action: () => { this.changeFunctionIcon(cell, 'Deliver') } },\r\n // { text: 'Develop', action: () => { this.changeFunctionIcon(cell, 'Develop') } },\r\n // { text: 'Digital IP', action: () => { this.changeFunctionIcon(cell, 'Digital IP') } },\r\n // { text: 'eCommerce', action: () => { this.changeFunctionIcon(cell, 'eCommerce') } },\r\n // { text: 'ESG', action: () => { this.changeFunctionIcon(cell, 'ESG') } },\r\n // { text: 'Headquarter Oversight', action: () => { this.changeFunctionIcon(cell, 'Headquarter Oversight') } },\r\n // { text: 'Internal Support', action: () => { this.changeFunctionIcon(cell, 'Internal Support') } },\r\n // { text: 'Logistics', action: () => { this.changeFunctionIcon(cell, 'Logistics') } },\r\n // { text: 'Make', action: () => { this.changeFunctionIcon(cell, 'Make') } },\r\n // { text: 'Market', action: () => { this.changeFunctionIcon(cell, 'Market') } },\r\n // { text: 'Quality', action: () => { this.changeFunctionIcon(cell, 'Quality') } },\r\n // { text: 'Regulatory Process', action: () => { this.changeFunctionIcon(cell, 'Regulatory Process') } },\r\n // { text: 'Retail', action: () => { this.changeFunctionIcon(cell, 'Retail') } },\r\n // { text: 'Sell', action: () => { this.changeFunctionIcon(cell, 'Sell') } },\r\n // { text: 'Services', action: () => { this.changeFunctionIcon(cell, 'Services') } },\r\n // { text: 'Source', action: () => { this.changeFunctionIcon(cell, 'Source') } },\r\n // { text: 'Strategy', action: () => { this.changeFunctionIcon(cell, 'Strategy') } },\r\n // { text: 'US Legal IP', action: () => { this.changeFunctionIcon(cell, 'US Legal IP') } },\r\n // { text: 'US Newly Developed IP', action: () => { this.changeFunctionIcon(cell, 'US Newly Developed IP') } },\r\n // { text: 'Warehousing', action: () => { this.changeFunctionIcon(cell, 'Warehousing') } },\r\n // { text: 'Wholesale', action: () => { this.changeFunctionIcon(cell, 'Wholesale') } }\r\n //];\r\n\r\n //if (cell.attr('functionIcon/xlink:href')) {\r\n // functionIconOptions.unshift({ text: 'None', action: () => { this.changeFunctionIcon(cell, 'None') } });\r\n //}\r\n\r\n options = options.concat([\r\n { text: 'Edit Color', action: () => { this.changeElementColor(cell) } },\r\n { text: 'Edit Primary Label', action: () => { this.changeElementPrimaryText(cell) } },\r\n { text: cell.attr('label2/text') === '' ? 'Add Secondary Label' : 'Edit Secondary Label', action: () => { this.changeElementSecondaryText(cell) } },\r\n //{\r\n // text: cell.attr('functionIcon/xlink:href') === '' ? 'Add Function Icon' : 'Edit Function Icon',\r\n // action: null,\r\n // subMenu: functionIconOptions\r\n //},\r\n { text: null, action: null },\r\n { text: 'Delete', action: () => { this.confirmDeleteElement(cell) } },\r\n ]);\r\n\r\n } else if (cell instanceof joint.shapes.standard.Link) {\r\n var sourceNode = cell.getSourceElement() as Node;\r\n var targetNode = cell.getTargetElement() as Node;\r\n\r\n options = [\r\n { text: 'Edit Label', action: () => { this.changeLinkText(cell) } },\r\n { text: null, action: null },\r\n { text: 'Delete Flow', action: () => { this.confirmDeleteRelationship(cell) } },\r\n ];\r\n }\r\n\r\n options.forEach(option => {\r\n var menuOption = document.createElement('div');\r\n\r\n if (option.text == null && option.action == null) {\r\n menuOption.className = 'flow-editor-menu-divider';\r\n menu.appendChild(menuOption);\r\n return;\r\n }\r\n\r\n menuOption.className = 'flow-editor-menu-option';\r\n var menuText = document.createElement('span');\r\n menuText.textContent = option.text;\r\n menuOption.appendChild(menuText);\r\n\r\n if (option.subMenu) {\r\n var arrow = document.createElement('span');\r\n arrow.textContent = '>';\r\n menuOption.appendChild(arrow);\r\n }\r\n\r\n menu.appendChild(menuOption);\r\n\r\n menuOption.addEventListener('click', async () => {\r\n if (option.subMenu) {\r\n // if there is a sub-menu, open it\r\n var bounds = menuOption.getBoundingClientRect();\r\n var x = bounds.left + bounds.width;\r\n var y = bounds.top;\r\n this.openSubMenu(x, y, option.subMenu);\r\n } else {\r\n // else perform the action\r\n await option.action();\r\n await this.closeMenus();\r\n }\r\n });\r\n });\r\n\r\n // 4. Show Menu\r\n menu.style.visibility = 'hidden'; // hide the menu to calculate the height\r\n document.body.appendChild(menu);\r\n\r\n // Calculate the distance between the bottom of the div and the bottom of the window to avoid collisions\r\n var divBottom = menu.offsetTop + menu.offsetHeight;\r\n var windowHeight = window.innerHeight || document.documentElement.clientHeight;\r\n var distanceToBottom = windowHeight - divBottom;\r\n\r\n console.debug(\"divBottom: \" + divBottom);\r\n console.debug(\"windowHeight: \" + windowHeight);\r\n console.debug(\"distanceToBottom: \" + distanceToBottom);\r\n\r\n // Check if the distance will cause the menu to go off the screen\r\n if (distanceToBottom < 0) {\r\n menu.style.top = (menu.offsetTop - menu.offsetHeight) + 'px';\r\n }\r\n menu.style.visibility = 'visible';\r\n }\r\n\r\n public openSubMenu(x: number, y: number, options: MenuOption[]) {\r\n // close any other sub-menus that are open\r\n this.closeSubMenus();\r\n\r\n // 1. Create Sub-Menu\r\n var menu = document.createElement('div');\r\n menu.className = 'flow-editor-menu';\r\n menu.classList.add('flow-editor-submenu');\r\n\r\n // 2. Position Menu\r\n menu.style.top = y + 'px';\r\n menu.style.left = x + 'px';\r\n\r\n menu.style.maxHeight = '200px';\r\n menu.style.overflowY = 'scroll';\r\n\r\n // 3. Add Menu Options\r\n options.forEach(option => {\r\n var menuOption = document.createElement('div');\r\n\r\n if (option.text == null && option.action == null) {\r\n menuOption.className = 'flow-editor-menu-divider';\r\n menu.appendChild(menuOption);\r\n return;\r\n }\r\n\r\n menuOption.className = 'flow-editor-menu-option';\r\n var menuText = document.createElement('span');\r\n menuText.textContent = option.text;\r\n menuOption.appendChild(menuText);\r\n menu.appendChild(menuOption);\r\n\r\n menuOption.addEventListener('click', async () => {\r\n if (option.subMenu) {\r\n // if there is a sub-menu, open it\r\n var bounds = menuOption.getBoundingClientRect();\r\n var x = bounds.left + bounds.width;\r\n var y = bounds.top;\r\n this.openSubMenu(x, y, option.subMenu);\r\n } else {\r\n // else perform the action\r\n await option.action();\r\n await this.closeMenus();\r\n }\r\n });\r\n });\r\n\r\n // 4. Show Menu\r\n menu.style.visibility = 'hidden'; // hide the menu to calculate the height\r\n document.body.appendChild(menu);\r\n\r\n // Calculate the distance between the bottom of the div and the bottom of the window to avoid collisions\r\n var divBottom = menu.offsetTop + menu.offsetHeight;\r\n var windowHeight = window.innerHeight || document.documentElement.clientHeight;\r\n var distanceToBottom = windowHeight - divBottom;\r\n\r\n console.debug(\"divBottom: \" + divBottom);\r\n console.debug(\"windowHeight: \" + windowHeight);\r\n console.debug(\"distanceToBottom: \" + distanceToBottom);\r\n\r\n // Check if the distance will cause the menu to go off the screen\r\n if (distanceToBottom < 0) {\r\n menu.style.top = (menu.offsetTop - menu.offsetHeight) + 'px';\r\n }\r\n\r\n // Calculate the distance between the right of the div and the right of the window to avoid horizontal collisions\r\n var divRight = menu.offsetLeft + menu.offsetWidth;\r\n var windowWidth = window.innerWidth || document.documentElement.clientWidth;\r\n var distanceToRight = windowWidth - divRight;\r\n\r\n\r\n // Check if the distance will cause the menu to go off the screen\r\n if (distanceToRight < 0) {\r\n menu.style.left = (menu.offsetLeft - menu.offsetWidth) + 'px';\r\n }\r\n\r\n menu.style.visibility = 'visible';\r\n }\r\n\r\n public closeMenus() {\r\n // 1. Retrieve all open menus\r\n var openMenus = Array.from(document.getElementsByClassName('flow-editor-menu'));\r\n\r\n // 2. Close all open menus\r\n openMenus.forEach(menu => {\r\n menu.remove();\r\n });\r\n }\r\n\r\n public closeSubMenus() {\r\n // retrieve all open sub-menus\r\n var openSubMenus = Array.from(document.getElementsByClassName('flow-editor-submenu'));\r\n\r\n // close all open sub-menus\r\n openSubMenus.forEach(menu => {\r\n menu.remove();\r\n });\r\n }\r\n\r\n private beginAddTransaction(sourceElement: Node, transactionType: TransactionType) {\r\n\r\n // set the activeTool\r\n this.activeTool = ToolMode.AddTransaction;\r\n\r\n // set context variables\r\n this.selectedElement = sourceElement;\r\n this.transactionTypeToCreate = transactionType;\r\n\r\n // add a border filter to the element to indicate that it is selected\r\n sourceElement.attr('body/filter', { name: 'highlight', args: { color: 'orange', width: 3, opacity: 0.75, blur: 5, } });\r\n this.closeMenus();\r\n }\r\n\r\n private beginAddFlow(sourceElement: Node, flowType: FlowType) {\r\n // set the activeTool\r\n this.activeTool = ToolMode.AddFlow;\r\n\r\n // set context variables\r\n this.selectedElement = sourceElement;\r\n this.flowTypeToCreate = flowType;\r\n\r\n // add a border filter to the element to indicate that it is selected\r\n sourceElement.attr('body/filter', { name: 'highlight', args: { color: 'orange', width: 3, opacity: 0.75, blur: 5, } });\r\n this.closeMenus();\r\n }\r\n\r\n private beginMoveExpense(sourceElement: Node) {\r\n // set the activeTool\r\n this.activeTool = ToolMode.MoveExpense;\r\n\r\n // set context variables\r\n this.selectedElement = sourceElement;\r\n\r\n // add a border filter to the element to indicate that it is selected\r\n sourceElement.attr('body/filter', { name: 'highlight', args: { color: 'orange', width: 3, opacity: 0.75, blur: 5, } });\r\n this.closeMenus();\r\n }\r\n\r\n private beginMoveRevenue(sourceElement: Node) {\r\n // set the activeTool\r\n this.activeTool = ToolMode.MoveRevenue;\r\n\r\n // set context variables\r\n this.selectedElement = sourceElement;\r\n\r\n // add a border filter to the element to indicate that it is selected\r\n sourceElement.attr('body/filter', { name: 'highlight', args: { color: 'orange', width: 3, opacity: 0.75, blur: 5, } });\r\n this.closeMenus();\r\n }\r\n\r\n private beginMoveFunction(sourceElement: Node, functionName: string) {\r\n // set the activeTool\r\n this.activeTool = ToolMode.MoveFunction;\r\n\r\n // set context variables\r\n this.selectedElement = sourceElement;\r\n this.functionNameToMove = functionName;\r\n\r\n // add a border filter to the element to indicate that it is selected\r\n sourceElement.attr('body/filter', { name: 'highlight', args: { color: 'orange', width: 3, opacity: 0.75, blur: 5, } });\r\n this.closeMenus();\r\n }\r\n\r\n private async addPaymentByDialog(source: Node, target: Node, paymentType: PaymentType, flowType: FlowType): Promise<void> {\r\n var sourceEntityIds = source.entityIds ?? [];\r\n var targetEntityIds = target.entityIds ?? [];\r\n var sourceLabel = source.attr('label/text');\r\n var targetLabel = target.attr('label/text');\r\n\r\n var dialogResult = paymentType === PaymentType.ServiceFee\r\n ? await this.dotNetHelper.invokeMethodAsync('AddServiceFeeByDialog', sourceEntityIds, targetEntityIds, sourceLabel, targetLabel)\r\n : await this.dotNetHelper.invokeMethodAsync('AddRoyaltyFeeByDialog', sourceEntityIds, targetEntityIds, sourceLabel, targetLabel);\r\n\r\n // Bind new step's ID with the flow/link created\r\n if (dialogResult) {\r\n const stepId = dialogResult.data[0].id;\r\n\r\n // Add the Service or Royalty flow\r\n this.addFlow(target, source, flowType, null, stepId);\r\n // Add the Payment flow\r\n this.addFlow(source, target, FlowType.Payment, null, stepId);\r\n }\r\n }\r\n\r\n private async addIPTransferByDialog(source: Node, target: Node, flowType: FlowType): Promise<void> {\r\n var sourceEntityIds = source.entityIds ?? [];\r\n var targetEntityIds = target.entityIds ?? [];\r\n var sourceLabel = source.attr('label/text');\r\n var targetLabel = target.attr('label/text');\r\n\r\n var dialogResult = await this.dotNetHelper.invokeMethodAsync('AddIPTransferStepByDialog', sourceEntityIds, targetEntityIds, sourceLabel, targetLabel);\r\n\r\n // Bind new step's ID with the flow/link created\r\n if (dialogResult) {\r\n const stepId = dialogResult.data[0].id;\r\n\r\n // Add the IP Transfer flow\r\n this.addFlow(target, source, flowType, null, stepId);\r\n // Add the Payment flow\r\n this.addFlow(source, target, FlowType.Payment, null, stepId);\r\n }\r\n }\r\n\r\n private async addPnlByDialog(node: Node) {\r\n var entityId = node.entityIds[0]; // there should only be one entity id (for a new entity)\r\n\r\n await this.dotNetHelper.invokeMethodAsync('EditPnlByDialog', entityId);\r\n }\r\n\r\n public async addEntityNode() {\r\n console.debug(\"addEntityNode\")\r\n\r\n var entityIdsToExclude: string[] = [];\r\n this.graph.getElements().forEach(node => {\r\n if (node instanceof Node) {\r\n entityIdsToExclude.push(...node.entityIds);\r\n }\r\n });\r\n\r\n var results: EntityNodeOptions[] = await this.dotNetHelper.invokeMethodAsync('SearchEntitiesByDialog', entityIdsToExclude);\r\n if (results != null) {\r\n var x = (this.container.offsetWidth / 2) - (results.length * 45);\r\n var y = (this.container.offsetHeight / 2) - (results.length * 45);\r\n console.debug(results);\r\n\r\n results.forEach(result => {\r\n // create the new type of element based on the incoming entity(s)\r\n var newElement: Node = this.CreateEntityNode(result.shape);\r\n\r\n // set the entityIds of the new element\r\n newElement.entityIds = result.entityIds;\r\n\r\n // set the label of the new element\r\n newElement.setLabel(result.label);\r\n\r\n // set the color of the new element\r\n newElement.setColorByJurisdiction(result.jurisdiction);\r\n\r\n newElement.position(x, y);\r\n newElement.resize(170, 100);\r\n this.graph.addCell(newElement);\r\n\r\n // set the functions\r\n if (result.functions && result.functions.length > 0) {\r\n newElement.addFunctionIcons(result.functions);\r\n }\r\n\r\n x = x + 45;\r\n y = y + 45;\r\n });\r\n\r\n await this.dotNetHelper.invokeMethodAsync('SetFlowLegendItems');\r\n }\r\n }\r\n\r\n public async addThirdPartyNode() {\r\n console.debug(\"addThirdPartyNode\")\r\n\r\n var entityIdsToExclude: string[] = [];\r\n this.graph.getElements().forEach(node => {\r\n if (node instanceof Node) {\r\n entityIdsToExclude.push(...node.entityIds);\r\n }\r\n });\r\n\r\n var results: EntityNodeOptions[] = await this.dotNetHelper.invokeMethodAsync('SearchExternalEntitiesByDialog', entityIdsToExclude);\r\n if (results != null) {\r\n var x = (this.container.offsetWidth / 2) - (results.length * 45);\r\n var y = (this.container.offsetHeight / 2) - (results.length * 45);\r\n console.debug(results);\r\n\r\n results.forEach(result => {\r\n // create the new type of element based on the incoming entity(s)\r\n var newElement: Node = this.CreateEntityNode(result.shape);\r\n // set the entityIds of the new element\r\n newElement.entityIds = result.entityIds;\r\n\r\n // set the label of the new element\r\n newElement.setLabel(result.label);\r\n\r\n // set the color of the new element\r\n newElement.setColorByJurisdiction(result.jurisdiction);\r\n\r\n newElement.position(x, y);\r\n newElement.resize(170, 100);\r\n this.graph.addCell(newElement);\r\n\r\n x = x + 45;\r\n y = y + 45;\r\n\r\n });\r\n await this.dotNetHelper.invokeMethodAsync('SetFlowLegendItems');\r\n }\r\n }\r\n\r\n //// TODO: allow changing the entity for a node that was already added.\r\n //// This should call C# to update any Future State steps that are associated with the existing entity.\r\n //private async chooseEntities(element: joint.dia.Element) {\r\n // // first get all entity ids from all nodes in the graph to exclude from search\r\n // var entityIdsToExclude: string[] = [];\r\n // this.graph.getElements().forEach(node => {\r\n // if (node instanceof Node) {\r\n // entityIdsToExclude.push(...node.entityIds);\r\n // }\r\n // });\r\n\r\n // var results: EntityNodeOptions[];\r\n\r\n // if (element instanceof EmptyThirdParty || element instanceof BranchThirdParty) {\r\n // results = await this.dotNetHelper.invokeMethodAsync('SearchExternalEntitiesByDialog', entityIdsToExclude);\r\n // }\r\n // else {\r\n // results = await this.dotNetHelper.invokeMethodAsync('SearchEntitiesByDialog', entityIdsToExclude);\r\n // }\r\n // //console.log('result: ' + result);\r\n\r\n // if (results != null) {\r\n // // do something\r\n // }\r\n //}\r\n\r\n // called from C# \r\n public async updateEntityFunctions(entityId: string, functionNames: string[]) {\r\n var entityNode = this.graph.getElements().find(e => e instanceof Node && e.entityIds.includes(entityId)) as Node;\r\n console.log(entityNode, functionNames);\r\n entityNode?.addFunctionIcons(functionNames);\r\n }\r\n\r\n // called from C# to add a new entity node to the graph\r\n public async addEntityByEntityNodeOptions(options: EntityNodeOptions) {\r\n console.debug(options);\r\n\r\n // check if the any of the element ids already exist in the graph\r\n var element = this.graph.getElements().find(e => e instanceof Node &&\r\n e.entityIds.filter(id => options.entityIds.includes(id)).length > 0);\r\n\r\n if (element) {\r\n console.debug('error: cannot add duplicate entity id(s) to graph');\r\n return;\r\n }\r\n\r\n var newElement: Node = this.CreateEntityNode(options.shape);\r\n\r\n // set the entityIds of the new element\r\n newElement.entityIds = options.entityIds;\r\n\r\n // set the label of the new element\r\n newElement.setLabel(options.label);\r\n\r\n // set the color of the new element\r\n newElement.setColorByJurisdiction(options.jurisdiction);\r\n\r\n // set the isNewEntity property of the new element\r\n newElement.isNewEntity = options.isNewEntity;\r\n\r\n // set the position of the new element to the center of the container\r\n var position = [this.container.offsetWidth / 2, this.container.offsetHeight / 2];\r\n console.debug(position)\r\n\r\n // check if another entity element is already positioned at the same location\r\n do {\r\n var overlappingPositionElement = this.graph.getElements().find(e => e instanceof Node &&\r\n e.position().x === position[0] &&\r\n e.position().y === position[1]);\r\n\r\n if (overlappingPositionElement) {\r\n console.debug('overlapping element')\r\n position[0] = position[0] + 45;\r\n position[1] = position[1] + 45;\r\n\r\n console.debug(position)\r\n }\r\n console.debug('no overlapping element')\r\n }\r\n while (overlappingPositionElement);\r\n\r\n newElement.position(position[0], position[1]);\r\n newElement.resize(170, 100);\r\n\r\n // Add function icons\r\n if (options.functions && options.functions.length > 0) {\r\n await newElement.addFunctionIcons(options.functions);\r\n }\r\n\r\n this.graph.addCell(newElement);\r\n await this.dotNetHelper.invokeMethodAsync('SetFlowLegendItems');\r\n\r\n\r\n }\r\n\r\n // called from C# to replace an entity node with a new one\r\n public async replaceEntityNodeByEntityId(entityId: string, options: EntityNodeOptions) {\r\n var element = this.graph.getElements().find(e => e instanceof Node &&\r\n e.entityIds.length == 1 && e.entityIds[0] == entityId);\r\n\r\n if (element) {\r\n var newElement: Node = this.CreateEntityNode(options.shape);\r\n\r\n // set the entityIds of the new element\r\n newElement.entityIds = options.entityIds;\r\n\r\n // set the label of the new element\r\n newElement.setLabel(options.label);\r\n\r\n // set the color of the new element\r\n newElement.setColorByJurisdiction(options.jurisdiction);\r\n\r\n newElement.position(element.attributes.position.x, element.attributes.position.y);\r\n newElement.resize(170, 100);\r\n this.graph.addCell(newElement);\r\n\r\n // set the functions\r\n if (options.functions && options.functions.length > 0) {\r\n newElement.addFunctionIcons(options.functions);\r\n }\r\n\r\n // update any existing links to reference the new element\r\n var links = this.graph.getConnectedLinks(element);\r\n links.forEach(link => {\r\n if (link.get('source').id === element.id) {\r\n link.source(newElement);\r\n }\r\n if (link.get('target').id === element.id) {\r\n link.target(newElement);\r\n }\r\n });\r\n\r\n // remove the original element\r\n element.remove();\r\n await this.dotNetHelper.invokeMethodAsync('SetFlowLegendItems');\r\n }\r\n }\r\n\r\n private async confirmDeleteElement(element: joint.dia.Element) {\r\n if (this.futureStateMode && element instanceof Node) {\r\n var entityIds = element.entityIds ?? [];\r\n var label = element.attr('label/text');\r\n\r\n var result = await this.dotNetHelper.invokeMethodAsync('ConfirmDeleteEntityByDialog', entityIds, label);\r\n if (result) {\r\n element.remove();\r\n }\r\n }\r\n else {\r\n element.remove();\r\n }\r\n await this.dotNetHelper.invokeMethodAsync('SetFlowLegendItems');\r\n }\r\n\r\n private async confirmDeleteRelationship(link: joint.shapes.standard.Link) {\r\n if (this.futureStateMode) {\r\n var sourceNode = link.getSourceElement() as Node;\r\n var targetNode = link.getTargetElement() as Node;\r\n var sourceEntityIds = sourceNode.entityIds ?? [];\r\n var targetEntityIds = targetNode.entityIds ?? [];\r\n var stepId = link.prop('stepId');\r\n\r\n var result = await this.dotNetHelper.invokeMethodAsync('ConfirmDeleteRelationshipByDialog', sourceEntityIds, targetEntityIds, stepId);\r\n if (result) {\r\n // TODO: for now we decided not to add RemoveRelationshipSteps because there's no way to visualize them. \r\n //if (!link.prop('stepId')){\r\n // if no step id exists on the link, call C# to add RemoveRelationshipStep (in theory this link is from the Current State)\r\n // if a step id exists, the link was added by a different step, or is associated with an AddRelationshipStep (added in FS)\r\n //await this.dotNetHelper.invokeMethodAsync('RemoveRelationshipStep', sourceEntityIds, targetEntityIds, link.labels()[0]?.attrs.text.text);\r\n //}\r\n link.remove();\r\n await this.dotNetHelper.invokeMethodAsync('SetFlowLegendItems');\r\n }\r\n }\r\n else {\r\n link.remove();\r\n await this.dotNetHelper.invokeMethodAsync('SetFlowLegendItems');\r\n }\r\n }\r\n\r\n // called from C# to remove an entity node from the graph\r\n public async removeEntityNodeByEntityId(entityId: string) {\r\n var element = this.graph.getElements().find(e => e instanceof Node &&\r\n e.entityIds.length == 1 && e.entityIds[0] == entityId);\r\n\r\n if (element) {\r\n element.remove();\r\n await this.dotNetHelper.invokeMethodAsync('SetFlowLegendItems');\r\n }\r\n }\r\n\r\n public async addFunctionToEntityNode(entityId: string, functionName: string) {\r\n var element = this.graph.getElements().find(e => e instanceof Node &&\r\n e.entityIds.length == 1 && e.entityIds[0] == entityId) as Node;\r\n\r\n if (element) {\r\n element.functions.push(functionName);\r\n this.updateEntityFunctions(entityId, element.functions);\r\n }\r\n }\r\n\r\n public async removeFunctionFromEntityNode(entityId: string, functionName: string) {\r\n var element = this.graph.getElements().find(e => e instanceof Node &&\r\n e.entityIds.length == 1 && e.entityIds[0] == entityId) as Node;\r\n\r\n if (element) {\r\n var updatedFunctions = element.functions.filter(f => f !== functionName);\r\n this.updateEntityFunctions(entityId, updatedFunctions);\r\n }\r\n }\r\n\r\n public async onMoveFunctionStepDelete(sourceEntityId: string, targetEntityId: string, functionName: string) {\r\n this.removeFunctionFromEntityNode(targetEntityId, functionName);\r\n this.addFunctionToEntityNode(sourceEntityId, functionName);\r\n }\r\n\r\n public resetToolMode() {\r\n this.activeTool = null;\r\n\r\n if (this.selectedElement) {\r\n this.selectedElement.attr('body/filter', null);\r\n this.selectedElement = null;\r\n }\r\n\r\n this.flowTypeToCreate = null;\r\n this.transactionTypeToCreate = null;\r\n\r\n this.startRectangle = null;\r\n this.tempRectangleElement?.remove();\r\n\r\n this.graph.getElements().forEach(element => {\r\n if (element instanceof Node) {\r\n element.attr('body/filter', null);\r\n }\r\n });\r\n }\r\n\r\n private async changeElementPrimaryText(element: Node | DrawnRectangle) {\r\n // get the current text of the entity\r\n var oldText = element.attr('label/text');\r\n\r\n var newText = await this.dotNetHelper.invokeMethodAsync('EditTextByDialog', oldText);\r\n console.debug('newText: ' + newText);\r\n\r\n // if newText is not null (allow empty strings)\r\n if (newText != null) {\r\n element.setLabel(newText);\r\n }\r\n }\r\n\r\n private async changeElementSecondaryText(element: Node) {\r\n // get the current text of the entity\r\n var oldText = element.attr('label2/text');\r\n\r\n var newText = await this.dotNetHelper.invokeMethodAsync('EditTextByDialog', oldText);\r\n console.debug('newText: ' + newText);\r\n\r\n // if newText is not null (allow empty strings)\r\n if (newText != null) {\r\n element.setSecondaryLabel(newText);\r\n }\r\n }\r\n\r\n private async changeFunctionIcon(element: Node, functionName: string) {\r\n\r\n try {\r\n\r\n if (functionName === \"None\") {\r\n element.attr('functionIcon/xlink:href', '');\r\n return;\r\n }\r\n\r\n const iconPath = `/icons/functions/${functionName}.svg`;\r\n const response = await fetch(iconPath);\r\n\r\n if (!response.ok) {\r\n throw new Error(`Error fetching Function Icon path: ${response.status}`);\r\n }\r\n const svgContent = await response.text();\r\n\r\n const encodedSvgContent = encodeURIComponent(svgContent);\r\n\r\n if (element.attr('functionIcon')) {\r\n element.attr({\r\n functionIcon: {\r\n 'xlink:href': `data:image/svg+xml;charset=utf8,${encodedSvgContent}`,\r\n width: 30,\r\n height: 30,\r\n refX: '20%',\r\n refY: '10%',\r\n }\r\n });\r\n } else {\r\n element.setFunctionIcon(functionName);\r\n }\r\n } catch (error) {\r\n console.error('Error loading or setting SVG:', error);\r\n }\r\n }\r\n\r\n\r\n private async changeLinkText(link: joint.shapes.standard.Link) {\r\n // get the current text of the link\r\n var oldText = link.labels()[0]?.attrs.text.text;\r\n //var oldLabelPosition = link.labels()[0]?.position;\r\n\r\n var newText = await this.dotNetHelper.invokeMethodAsync('EditTextByDialog', oldText);\r\n //console.debug('newText: ' + newText);\r\n\r\n // if newText is not null (allow empty strings)\r\n if (newText != null) {\r\n link.label(0, {\r\n attrs: {\r\n text: {\r\n text: newText\r\n }\r\n }\r\n });\r\n }\r\n }\r\n\r\n private async changeElementColor(element: joint.dia.Element) {\r\n // get the current color of the entity\r\n var oldColor = element.attr('body/fill');\r\n\r\n var color = await this.dotNetHelper.invokeMethodAsync('ChooseColorByDialog', oldColor);\r\n\r\n // if color is not null or empty string\r\n if (color) {\r\n element.attr('body/fill', color);\r\n }\r\n }\r\n\r\n private CreateEntityNode(shapeType: ShapeType): any {\r\n switch (shapeType) {\r\n case ShapeType.CorporationCFC:\r\n return new CorporationCFC();\r\n break;\r\n case ShapeType.BranchThirdParty:\r\n return new BranchThirdParty();\r\n break;\r\n case ShapeType.Partnership:\r\n return new Partnership();\r\n break;\r\n case ShapeType.HybridEntity:\r\n return new HybridEntity();\r\n break;\r\n case ShapeType.ReverseHybridEntity:\r\n return new ReverseHybrid();\r\n break;\r\n case ShapeType.DRE:\r\n return new Disregarded();\r\n break;\r\n case ShapeType.Group:\r\n return new EntityGroup();\r\n break;\r\n default:\r\n return new CorporationCFC();\r\n break;\r\n }\r\n }\r\n\r\n constructor(options: FlowEditorOptions) {\r\n this.graph = new joint.dia.Graph({}, { cellNamespace: this.namespace });\r\n\r\n this.graph.on('add remove change', (cell) => {\r\n // if we need to perform some logic when an alement is added, removed, changed\r\n });\r\n\r\n this.paper = new joint.dia.Paper({\r\n el: options.container,\r\n model: this.graph,\r\n width: null, // this is controlled by CSS\r\n height: null, // this is controlled by CSS\r\n gridSize: 15,\r\n drawGrid: {\r\n name: 'dot', args: { color: 'black' }\r\n },\r\n interactive: {\r\n linkMove: true,\r\n labelMove: true,\r\n },\r\n snapLabels: true,\r\n labelsLayer: true,\r\n moveThreshold: 1,\r\n restrictTranslate: true,\r\n cellViewNamespace: this.namespace\r\n });\r\n\r\n this.dotNetHelper = options.dotNetHelper;\r\n this.futureStateMode = options.futureStateMode;\r\n this.container = options.container;\r\n\r\n console.debug('futureStateMode: ' + options.futureStateMode)\r\n\r\n var verticesTool = new joint.linkTools.Vertices({\r\n snapRadius: 30,\r\n stopPropagation: false,\r\n });\r\n\r\n var segmentsTool = new joint.linkTools.Segments({\r\n snapRadius: 15,\r\n stopPropagation: false,\r\n });\r\n\r\n var toolsView = new joint.dia.ToolsView({\r\n tools: [\r\n verticesTool,\r\n segmentsTool,\r\n ],\r\n });\r\n\r\n this.paper.on('link:mouseenter', function (linkView) {\r\n linkView.addTools(toolsView);\r\n });\r\n\r\n this.paper.on('blank:mouseover', () => {\r\n this.paper.removeTools();\r\n });\r\n\r\n this.paper.on({\r\n 'element:mouseenter': (cellView, evt) => {\r\n //console.log('Element mouse enter');\r\n\r\n if (cellView.model instanceof Node\r\n && this.selectedElement\r\n && this.selectedElement.id != cellView.model.id\r\n && this.activeTool in toolModesWithTargetSelection) {\r\n\r\n // the only valid tool that targets third party entities is AddFlow\r\n if (!(cellView.model instanceof BranchThirdParty) || this.activeTool == ToolMode.AddFlow) {\r\n cellView.model.attr('body/filter', { name: 'highlight', args: { color: 'purple', width: 3, opacity: 0.75, blur: 5, } });\r\n } else {\r\n // ignore if this element is clicked\r\n joint.highlighters.addClass.add(cellView, 'root', 'not-allowed-highlighter', { className: 'not-allowed' });\r\n this.hoveredElementClickDisabled = true;\r\n }\r\n }\r\n },\r\n 'element:mouseleave': (cellView, evt) => {\r\n //console.log('Element mouse leave');\r\n\r\n if (cellView.model instanceof Node\r\n && this.selectedElement\r\n && this.selectedElement.id != cellView.model.id\r\n && this.activeTool in toolModesWithTargetSelection) {\r\n\r\n cellView.model.attr('body/filter', null);\r\n }\r\n\r\n joint.highlighters.addClass.remove(cellView, 'not-allowed-highlighter');\r\n this.hoveredElementClickDisabled = false;\r\n },\r\n 'element.pointerup': (cellView, evt) => {\r\n evt.stopPropagation();\r\n console.log('Element pointer up');\r\n },\r\n 'element:pointerclick': async (cellView, evt, x, y) => {\r\n evt.stopPropagation();\r\n if (this.hoveredElementClickDisabled) {\r\n // ignore the click event\r\n return;\r\n }\r\n\r\n console.log('Element pointer click - selectedElement is ' + this.selectedElement?.id);\r\n this.closeMenus();\r\n\r\n const element = cellView.model;\r\n\r\n // If an element is already selected, and it is not the same as this clicked element\r\n if (this.selectedElement && this.selectedElement != element) {\r\n\r\n if (this.activeTool == ToolMode.AddTransaction && this.selectedElement instanceof Node && element instanceof Node) {\r\n // add a link between the selected element and the current element\r\n this.addTransaction(this.selectedElement, element, this.transactionTypeToCreate);\r\n } else if (this.activeTool == ToolMode.AddFlow) {\r\n // add a link between the selected element and the current element\r\n this.addFlow(this.selectedElement, element, this.flowTypeToCreate);\r\n } else if (this.activeTool == ToolMode.MoveExpense) {\r\n // add a Transfer Expense step between the selected element and the current element\r\n var sourceEntityIds = (this.selectedElement as Node).entityIds ?? []\r\n var targetEntityIds = (element as Node).entityIds ?? [];\r\n var sourceLabel = (this.selectedElement as Node).attr('label/text');\r\n var targetLabel = (element as Node).attr('label/text');\r\n await this.dotNetHelper.invokeMethodAsync('AddTransferExpenseStepByDialog', sourceEntityIds, targetEntityIds, sourceLabel, targetLabel);\r\n } else if (this.activeTool == ToolMode.MoveRevenue) {\r\n // add a Transfer Revenue step between the selected element and the current element\r\n var sourceEntityIds = (this.selectedElement as Node).entityIds ?? [];\r\n var targetEntityIds = (element as Node).entityIds ?? [];\r\n var sourceLabel = (this.selectedElement as Node).attr('label/text');\r\n var targetLabel = (element as Node).attr('label/text');\r\n await this.dotNetHelper.invokeMethodAsync('AddTransferRevenueStepByDialog', sourceEntityIds, targetEntityIds, sourceLabel, targetLabel);\r\n } else if (this.activeTool == ToolMode.MoveFunction) {\r\n // add a Move Function step between the selected element and the current element\r\n var sourceEntityIds = (this.selectedElement as Node).entityIds ?? [];\r\n var targetEntityIds = (element as Node).entityIds ?? [];\r\n var sourceLabel = (this.selectedElement as Node).attr('label/text');\r\n var targetLabel = (element as Node).attr('label/text');\r\n await this.dotNetHelper.invokeMethodAsync('AddMoveFunctionStep', sourceEntityIds, targetEntityIds, this.functionNameToMove);\r\n }\r\n\r\n this.dotNetHelper.invokeMethodAsync('SetFlowLegendItems');\r\n\r\n // reset the selected element\r\n this.resetToolMode();\r\n }\r\n else { // Else, open a menu for the current element\r\n this.openMenu(element, evt.pageX, evt.pageY);\r\n }\r\n },\r\n 'link:pointerclick': (cellView, evt) => {\r\n evt.stopPropagation();\r\n console.log('Link pointer click');\r\n this.closeMenus();\r\n\r\n var link = cellView.model;\r\n this.openMenu(link, evt.pageX, evt.pageY);\r\n },\r\n 'element:pointermove': (cellView, evt, x, y) => {\r\n // Logic for handling pointer down events (e.g., drag start)\r\n //evt.stopPropagation();\r\n console.log('Element pointer move');\r\n this.closeMenus();\r\n this.resetToolMode();\r\n },\r\n // we have no use case for double clicking at this time.\r\n //'element:pointerdblclick': (cellView, evt, x, y) => {\r\n // // Logic for handling double click events on elements\r\n // evt.stopPropagation();\r\n // console.log('Element double click');\r\n //},\r\n 'blank:pointerdown': (evt, x, y) => {\r\n // Logic for handling pointer down events on the blank paper\r\n //evt.stopPropagation();\r\n console.log('Blank pointer down');\r\n this.closeMenus();\r\n\r\n if (this.activeTool == ToolMode.DrawRectangle) {\r\n this.startRectangle = { x: x, y: y };\r\n console.debug('starting draw rectangle')\r\n }\r\n else {\r\n this.resetToolMode();\r\n\r\n // Logic to start panning the paper\r\n var scale = this.paper.scale();\r\n this.panStartPosition = { x: x * scale.sx, y: y * scale.sy };\r\n }\r\n },\r\n 'blank:pointerup': async (evt, x, y) => {\r\n // Logic for handling pointer up events on the blank paper\r\n //evt.stopPropagation();\r\n console.log('Blank pointer up');\r\n this.closeMenus();\r\n\r\n if (this.activeTool == ToolMode.DrawRectangle && this.startRectangle) {\r\n this.startRectangle = null;\r\n this.tempRectangleElement?.setLabel(\"Click to edit text\");\r\n this.tempRectangleElement = null;\r\n await this.dotNetHelper.invokeMethodAsync('SetRectangleMode', false);\r\n } else {\r\n // Logic to stop panning the paper\r\n this.panStartPosition = null;\r\n }\r\n },\r\n 'blank:pointermove': (evt, x, y) => {\r\n // Logic for handling pointer move events on the blank paper\r\n console.log('Blank pointer move');\r\n if (this.activeTool == ToolMode.DrawRectangle) {\r\n this.drawRectangle(evt, x, y);\r\n }\r\n },\r\n 'element:label:pointerclick': (cellView, evt) => {\r\n evt.stopPropagation();\r\n console.log('Element label pointer click');\r\n this.closeMenus();\r\n this.changeElementPrimaryText(cellView.model);\r\n },\r\n });\r\n\r\n // Panning and Zooming\r\n // General approach from: https://medium.com/@ishaanshettigar/guide-panning-and-zooming-in-jointjs-for-free-step-by-step-tutorial-4a56590d2761\r\n\r\n // handle panning the paper\r\n // https://stackoverflow.com/questions/28431384/how-to-make-a-paper-draggable\r\n this.container.addEventListener('mousemove', (evt) => {\r\n if (this.panStartPosition) {\r\n this.paper.translate(\r\n evt.offsetX - this.panStartPosition.x,\r\n evt.offsetY - this.panStartPosition.y);\r\n }\r\n });\r\n\r\n // handle zooming the paper\r\n // https://stackoverflow.com/a/69196310\r\n this.paper.on(\"blank:mousewheel\", (evt, x, y, delta) => {\r\n evt.preventDefault();\r\n const oldscale = this.paper.scale().sx;\r\n const newscale = oldscale + 0.2 * delta * oldscale\r\n\r\n if (newscale > 0.2 && newscale < 5) {\r\n this.paper.scale(newscale, newscale);\r\n this.paper.translate(-x * newscale + evt.offsetX, -y * newscale + evt.offsetY);\r\n }\r\n });\r\n\r\n // handle resize of the window\r\n window.addEventListener('resize', () => {\r\n console.log('window resize');\r\n var currentScale = this.paper.scale();\r\n this.paper.transformToFitContent({ verticalAlign: 'middle', horizontalAlign: 'middle', minScale: currentScale.sx, maxScale: currentScale.sx });\r\n });\r\n }\r\n\r\n public dispose() {\r\n this.closeMenus();\r\n }\r\n}\r\n\r\nexport function createFlowEditor(options: FlowEditorOptions): FlowEditor {\r\n return new FlowEditor(options);\r\n}\r\n\r\nexport class FlowPreview {\r\n private readonly namespace = joint.shapes;\r\n private paper: joint.dia.Paper;\r\n private graph: joint.dia.Graph;\r\n\r\n constructor(options: FlowPreviewOptions) {\r\n this.graph = new joint.dia.Graph({}, { cellNamespace: this.namespace });\r\n\r\n this.paper = new joint.dia.Paper({\r\n el: options.container,\r\n model: this.graph,\r\n width: options.container.offsetWidth,\r\n height: options.container.offsetHeight,\r\n interactive: false,\r\n cellViewNamespace: this.namespace,\r\n });\r\n\r\n this.paper.model.fromJSON(JSON.parse(options.graphJson), { cellNamespace: this.namespace });\r\n this.paper.transformToFitContent({ verticalAlign: 'middle', horizontalAlign: 'middle', maxScale: 2 });\r\n }\r\n}\r\n\r\nexport function createFlowPreview(options) {\r\n try {\r\n const graphJson = JSON.parse(options.graphJson);\r\n return new FlowPreview(options);\r\n } catch (error) {\r\n console.error('Invalid JSON input', error);\r\n console.error('Options:', options);\r\n }\r\n}\r\n\r\n\r\n// Define a custom element to represent an Empty Node\r\nexport class EmptyElement extends Node {\r\n defaults() {\r\n return {\r\n type: 'EmptyElement',\r\n svg: '',\r\n attrs: {\r\n body: {\r\n fill: 'white',\r\n stroke: 'white',\r\n strokeWidth: 2,\r\n width: 'calc(w)',\r\n height: 'calc(h)',\r\n rx: 10,\r\n ry: 10,\r\n class: 'orange-dashed-border',\r\n },\r\n label: {\r\n //refX: '50%',\r\n //refY: '50%',\r\n //refDx: 0,\r\n //refDy: 0,\r\n textAnchor: 'middle',\r\n textVerticalAnchor: 'middle',\r\n x: 'calc(0.5*w)',\r\n y: 'calc(0.5*h)',\r\n fill: 'black',\r\n fontSize: 14,\r\n fontFamily: '\"Open Sans\", sans-serif',\r\n fontWeight: 'bold',\r\n text: 'Click to\\nchoose Entity(s)',\r\n }\r\n },\r\n markup: [{\r\n tagName: 'rect',\r\n selector: 'body'\r\n },\r\n {\r\n tagName: 'text',\r\n selector: 'label'\r\n }],\r\n }\r\n }\r\n}\r\nObject.assign(joint.shapes, { EmptyElement });\r\n\r\nexport class EmptyThirdParty extends Node {\r\n defaults() {\r\n return {\r\n type: 'EmptyThirdParty',\r\n svgPath: '/icons/BranchThirdParty.svg',\r\n attrs: {\r\n body: {\r\n fill: 'gray',\r\n stroke: 'white',\r\n strokeWidth: 2,\r\n width: 'calc(w)',\r\n height: 'calc(h)',\r\n rx: 'calc(w / 2)',\r\n ry: 'calc(h / 2)',\r\n cx: 'calc(w / 2)',\r\n cy: 'calc(h / 2)',\r\n class: 'orange-dashed-border',\r\n },\r\n label: {\r\n textAnchor: 'middle',\r\n textVerticalAnchor: 'middle',\r\n x: 'calc(0.5*w)',\r\n y: 'calc(0.5*h)',\r\n fill: 'black',\r\n fontSize: 14,\r\n fontFamily: '\"Open Sans\", sans-serif',\r\n fontWeight: 'bold',\r\n text: 'Click to choose\\nThird Party(s)',\r\n }\r\n },\r\n markup: [{\r\n tagName: 'ellipse',\r\n selector: 'body'\r\n },\r\n {\r\n tagName: 'text',\r\n selector: 'label'\r\n }],\r\n }\r\n }\r\n}\r\nObject.assign(joint.shapes, { EmptyThirdParty });\r\n\r\n// Define a custom element to represent a Corporation/CFC Entity Node\r\nexport class CorporationCFC extends Node {\r\n defaults() {\r\n return {\r\n type: 'CorporationCFC',\r\n svgPath: '/icons/Corporation.svg',\r\n attrs: {\r\n body: {\r\n fill: '#0A2065',\r\n stroke: 'white',\r\n strokeWidth: 2,\r\n width: 'calc(w)',\r\n height: 'calc(h)',\r\n rx: 10,\r\n ry: 10,\r\n },\r\n label: {\r\n textAnchor: 'middle',\r\n textVerticalAnchor: 'middle',\r\n x: 'calc(0.5*w)',\r\n y: 'calc(0.5*h)',\r\n fill: 'white',\r\n fontSize: 14,\r\n fontFamily: '\"Open Sans\", sans-serif',\r\n fontWeight: 'bold',\r\n text: 'Corporation',\r\n },\r\n label2: {\r\n textAnchor: 'middle',\r\n textVerticalAnchor: 'middle',\r\n x: 'calc(0.5*w)',\r\n y: 'calc(0.75*h)',\r\n fill: 'white',\r\n fontSize: 14,\r\n fontFamily: '\"Open Sans\", sans-serif',\r\n text: '',\r\n }\r\n },\r\n markup: [{\r\n tagName: 'rect',\r\n selector: 'body'\r\n }, {\r\n tagName: 'text',\r\n selector: 'label'\r\n }, {\r\n tagName: 'text',\r\n selector: 'label2'\r\n }],\r\n }\r\n }\r\n}\r\nObject.assign(joint.shapes, { CorporationCFC });\r\n\r\n// Define a custom element to represent a Branch/Third Party Entity Node\r\nexport class BranchThirdParty extends Node {\r\n defaults() {\r\n return {\r\n type: 'BranchThirdParty',\r\n svgPath: '/icons/BranchThirdParty.svg',\r\n attrs: {\r\n body: {\r\n fill: 'gray',\r\n stroke: 'white',\r\n strokeWidth: 2,\r\n width: 'calc(w)',\r\n height: 'calc(h)',\r\n rx: 'calc(w / 2)',\r\n ry: 'calc(h / 2)',\r\n cx: 'calc(w / 2)',\r\n cy: 'calc(h / 2)',\r\n },\r\n label: {\r\n textAnchor: 'middle',\r\n textVerticalAnchor: 'middle',\r\n x: 'calc(0.5*w)',\r\n y: 'calc(0.5*h)',\r\n fill: 'white',\r\n fontSize: 14,\r\n fontFamily: '\"Open Sans\", sans-serif',\r\n fontWeight: 'bold',\r\n text: 'Corporation',\r\n },\r\n label2: {\r\n textAnchor: 'middle',\r\n textVerticalAnchor: 'middle',\r\n x: 'calc(0.5*w)',\r\n y: 'calc(0.75*h)',\r\n fill: 'white',\r\n fontSize: 14,\r\n fontFamily: '\"Open Sans\", sans-serif',\r\n text: '',\r\n }\r\n },\r\n markup: [{\r\n tagName: 'ellipse',\r\n selector: 'body'\r\n }, {\r\n tagName: 'text',\r\n selector: 'label'\r\n }, {\r\n tagName: 'text',\r\n selector: 'label2'\r\n }],\r\n }\r\n }\r\n\r\n setColorByJurisdiction(jurisdiction: Jurisdiction) {\r\n // Third Parties are always gray\r\n this.setColor(DefaultValues.ThirdPartyColor);\r\n }\r\n}\r\nObject.assign(joint.shapes, { BranchThirdParty });\r\n\r\n// Define a custom element to represent a Partnership Entity Node\r\nexport class Partnership extends Node {\r\n defaults() {\r\n return {\r\n type: 'Partnership',\r\n svgPath: '/icons/Partnership.svg',\r\n attrs: {\r\n body: {\r\n fill: '#0A2065',\r\n stroke: 'white',\r\n strokeWidth: 2,\r\n width: 'calc(w)',\r\n height: 'calc(h)',\r\n points: '0,calc(h), calc(w/2),0, calc(w),calc(h)'\r\n },\r\n label: {\r\n textAnchor: 'middle',\r\n textVerticalAnchor: 'middle',\r\n refY: 0.25,\r\n x: 'calc(0.5*w)',\r\n y: 'calc(0.5*h)',\r\n fill: 'white',\r\n fontSize: 14,\r\n fontFamily: '\"Open Sans\", sans-serif',\r\n fontWeight: 'bold',\r\n text: 'Corporation',\r\n },\r\n label2: {\r\n textAnchor: 'middle',\r\n textVerticalAnchor: 'middle',\r\n refY: 0.25,\r\n x: 'calc(0.5*w)',\r\n y: 'calc(0.75*h)',\r\n fill: 'white',\r\n fontSize: 14,\r\n fontFamily: '\"Open Sans\", sans-serif',\r\n text: '',\r\n }\r\n },\r\n markup: [{\r\n tagName: 'polygon',\r\n selector: 'body'\r\n }, {\r\n tagName: 'text',\r\n selector: 'label'\r\n }, {\r\n tagName: 'text',\r\n selector: 'label2'\r\n }],\r\n }\r\n }\r\n}\r\nObject.assign(joint.shapes, { Partnership });\r\n\r\n\r\n// Define a custom element to represent a Hybrid Entity Node\r\nexport class HybridEntity extends Node {\r\n defaults() {\r\n return {\r\n type: 'HybridEntity',\r\n svgPath: '/icons/HybridEntity.svg',\r\n attrs: {\r\n body: {\r\n fill: '#0A2065',\r\n stroke: 'white',\r\n strokeWidth: 2,\r\n width: 'calc(w)',\r\n height: 'calc(h)',\r\n d: 'M 0 0 L calc(w) 0 L calc(w) calc(h) L 0 calc(h) Z M 0 calc(h) L calc(w/2) 0 L calc(w) calc(h)'\r\n },\r\n label: {\r\n textAnchor: 'middle',\r\n textVerticalAnchor: 'middle',\r\n x: 'calc(0.5*w)',\r\n y: 'calc(0.5*h)',\r\n fill: 'white',\r\n fontSize: 14,\r\n fontFamily: '\"Open Sans\", sans-serif',\r\n fontWeight: 'bold',\r\n text: 'Corporation',\r\n },\r\n label2: {\r\n textAnchor: 'middle',\r\n textVerticalAnchor: 'middle',\r\n x: 'calc(0.5*w)',\r\n y: 'calc(0.75*h)',\r\n fill: 'white',\r\n fontSize: 14,\r\n fontFamily: '\"Open Sans\", sans-serif',\r\n text: '',\r\n }\r\n },\r\n markup: [{\r\n tagName: 'path',\r\n selector: 'body'\r\n }, {\r\n tagName: 'text',\r\n selector: 'label'\r\n }, {\r\n tagName: 'text',\r\n selector: 'label2'\r\n }],\r\n }\r\n }\r\n}\r\nObject.assign(joint.shapes, { HybridEntity });\r\n\r\n// Define a custom element to represent a Reverse Hybrid Entity Node\r\nexport class ReverseHybrid extends Node {\r\n defaults() {\r\n return {\r\n type: 'ReverseHybrid',\r\n svgPath: '/icons/ReverseHybrid.svg',\r\n attrs: {\r\n body: {\r\n fill: '#0A2065',\r\n stroke: 'white',\r\n strokeWidth: 2,\r\n width: 'calc(w)',\r\n height: 'calc(h)',\r\n transform: 'rotate(180 calc(w/2) calc(h/2))',\r\n d: 'M 0 0 L calc(w) 0 L calc(w) calc(h) L 0 calc(h) Z M 0 calc(h) L calc(w/2) 0 L calc(w) calc(h)'\r\n },\r\n label: {\r\n textAnchor: 'middle',\r\n textVerticalAnchor: 'middle',\r\n x: 'calc(0.5*w)',\r\n y: 'calc(0.5*h)',\r\n fill: 'white',\r\n fontSize: 14,\r\n fontFamily: '\"Open Sans\", sans-serif',\r\n fontWeight: 'bold',\r\n text: 'Corporation',\r\n },\r\n label2: {\r\n textAnchor: 'middle',\r\n textVerticalAnchor: 'middle',\r\n x: 'calc(0.5*w)',\r\n y: 'calc(0.75*h)',\r\n fill: 'white',\r\n fontSize: 14,\r\n fontFamily: '\"Open Sans\", sans-serif',\r\n text: '',\r\n }\r\n },\r\n markup: [{\r\n tagName: 'path',\r\n selector: 'body'\r\n }, {\r\n tagName: 'text',\r\n selector: 'label'\r\n }, {\r\n tagName: 'text',\r\n selector: 'label2'\r\n }],\r\n }\r\n }\r\n}\r\nObject.assign(joint.shapes, { ReverseHybrid });\r\n\r\n// Define a custom element to represent a DRE Entity Node\r\nexport class Disregarded extends Node {\r\n defaults() {\r\n return {\r\n type: 'Disregarded',\r\n svgPath: '/icons/Disregarded.svg',\r\n attrs: {\r\n body: {\r\n fill: '#0A2065',\r\n stroke: 'white',\r\n strokeWidth: 2,\r\n width: 'calc(w)',\r\n height: 'calc(h)',\r\n rx: 10,\r\n ry: 10,\r\n },\r\n body2: {\r\n fill: 'transparent',\r\n stroke: 'white',\r\n strokeWidth: 2,\r\n rx: 'calc(w / 2)',\r\n ry: 'calc(h / 2)',\r\n cx: 'calc(w / 2)',\r\n cy: 'calc(h / 2)',\r\n },\r\n label: {\r\n textAnchor: 'middle',\r\n textVerticalAnchor: 'middle',\r\n x: 'calc(0.5*w)',\r\n y: 'calc(0.5*h)',\r\n fill: 'white',\r\n fontSize: 14,\r\n fontFamily: '\"Open Sans\", sans-serif',\r\n fontWeight: 'bold',\r\n text: 'Corporation',\r\n },\r\n label2: {\r\n textAnchor: 'middle',\r\n textVerticalAnchor: 'middle',\r\n x: 'calc(0.5*w)',\r\n y: 'calc(0.75*h)',\r\n fill: 'white',\r\n fontSize: 14,\r\n fontFamily: '\"Open Sans\", sans-serif',\r\n text: '',\r\n }\r\n },\r\n markup: [{\r\n tagName: 'rect',\r\n selector: 'body'\r\n }, {\r\n tagName: 'ellipse',\r\n selector: 'body2'\r\n }, {\r\n tagName: 'text',\r\n selector: 'label'\r\n }, {\r\n tagName: 'text',\r\n selector: 'label2'\r\n }],\r\n }\r\n }\r\n}\r\nObject.assign(joint.shapes, { Disregarded });\r\n\r\n// Define a custom element to represent an Entity Group Node\r\nexport class EntityGroup extends Node {\r\n defaults() {\r\n return {\r\n type: 'EntityGroup',\r\n svgPath: '/icons/EntityGroup.svg',\r\n attrs: {\r\n body: {\r\n fill: '#0A2065',\r\n stroke: 'white',\r\n strokeWidth: 2,\r\n width: 'calc(w)',\r\n height: 'calc(h)',\r\n rx: 10,\r\n ry: 10,\r\n x: -5,\r\n y: -5,\r\n },\r\n body2: {\r\n fill: '#0A2065',\r\n stroke: 'white',\r\n strokeWidth: 2,\r\n width: 'calc(w)',\r\n height: 'calc(h)',\r\n rx: 10,\r\n ry: 10,\r\n x: 5,\r\n y: 5,\r\n },\r\n label: {\r\n textAnchor: 'middle',\r\n textVerticalAnchor: 'middle',\r\n x: 'calc(0.5*w)',\r\n y: 'calc(0.5*h)',\r\n fill: 'white',\r\n fontSize: 14,\r\n fontFamily: '\"Open Sans\", sans-serif',\r\n fontWeight: 'bold',\r\n text: '',\r\n },\r\n label2: {\r\n textAnchor: 'middle',\r\n textVerticalAnchor: 'middle',\r\n x: 'calc(0.5*w)',\r\n y: 'calc(0.75*h)',\r\n fill: 'white',\r\n fontSize: 14,\r\n fontFamily: '\"Open Sans\", sans-serif',\r\n text: '',\r\n }\r\n },\r\n markup: [{\r\n tagName: 'rect',\r\n selector: 'body2'\r\n },\r\n {\r\n tagName: 'rect',\r\n selector: 'body'\r\n },\r\n {\r\n tagName: 'text',\r\n selector: 'label'\r\n },\r\n {\r\n tagName: 'text',\r\n selector: 'label2'\r\n }],\r\n }\r\n }\r\n\r\n setColor(color: string) {\r\n this.attr('body/fill', color);\r\n this.attr('body2/fill', color);\r\n }\r\n\r\n setColorByJurisdiction(jurisdiction: Jurisdiction) {\r\n switch (jurisdiction) {\r\n case Jurisdiction.US:\r\n this.setColor(DefaultValues.PrimaryColor);\r\n break;\r\n case Jurisdiction.NonUS:\r\n this.setColor(DefaultValues.SecondaryColor);\r\n break;\r\n case Jurisdiction.Mixed:\r\n this.attr('body/fill', DefaultValues.PrimaryColor);\r\n this.attr('body2/fill', DefaultValues.SecondaryColor);\r\n break;\r\n default:\r\n this.setColor(DefaultValues.PrimaryColor);\r\n break;\r\n }\r\n }\r\n}\r\nObject.assign(joint.shapes, { EntityGroup });\r\n\r\n// Define a custom element to represent a drawn rectangle\r\nexport class DrawnRectangle extends joint.shapes.standard.Rectangle {\r\n defaults() {\r\n return {\r\n type: 'DrawnRectangle',\r\n attrs: {\r\n body: {\r\n fill: 'none',\r\n stroke: 'black',\r\n strokeWidth: 3,\r\n width: 'calc(w)',\r\n height: 'calc(h)',\r\n },\r\n 'label-background': {\r\n ref: 'label',\r\n fill: 'white',\r\n stroke: '#D0D0CE',\r\n strokeWidth: 1,\r\n width: 'calc(w+12)',\r\n height: 'calc(h+10)',\r\n x: 'calc(x-6)',\r\n y: 'calc(y-5)',\r\n rx: 1,\r\n ry: 1,\r\n },\r\n label: {\r\n textAnchor: 'middle',\r\n textVerticalAnchor: 'top',\r\n x: 'calc(0.5*w)',\r\n y: '-7',\r\n fill: 'black',\r\n fontSize: 14,\r\n fontFamily: '\"Open Sans\", sans-serif',\r\n fontWeight: 'bold',\r\n text: '',\r\n cursor: 'text',\r\n event: 'element:label:pointerclick',\r\n },\r\n },\r\n markup: [{\r\n tagName: 'rect',\r\n selector: 'body'\r\n },\r\n {\r\n tagName: 'rect',\r\n selector: 'label-background'\r\n }, {\r\n tagName: 'text',\r\n selector: 'label'\r\n }],\r\n }\r\n }\r\n\r\n public setLabel(label: string) {\r\n this.attr('label/text', label);\r\n }\r\n}\r\n\r\nObject.assign(joint.shapes, { DrawnRectangle });\r\n\r\nexport class PhysicalLink extends joint.shapes.standard.Link {\r\n defaults() {\r\n return joint.util.defaultsDeep({\r\n type: 'PhysicalLink',\r\n color: '#CE1210', // custom attribute - metadata only\r\n attrs: {\r\n line: {\r\n stroke: '#CE1210',\r\n strokeWidth: 3,\r\n targetMarker: {\r\n d: 'M 10 -5 0 0 10 5 Z',\r\n }\r\n },\r\n },\r\n labels: [{\r\n attrs: {\r\n rect: {\r\n ref: 'text',\r\n width: 'calc(w+12)',\r\n height: 'calc(h+10)',\r\n x: 'calc(x-6)',\r\n y: 'calc(y-5)',\r\n stroke: '#D0D0CE',\r\n cursor: 'pointer',\r\n },\r\n text: {\r\n textAnchor: 'middle',\r\n textVerticalAnchor: 'middle',\r\n fill: 'black',\r\n fontSize: 14,\r\n fontFamily: '\"Open Sans\", sans-serif',\r\n fontWeight: 'bold',\r\n text: 'Physical',\r\n }\r\n }\r\n }]\r\n }, joint.shapes.standard.Link.prototype.defaults);\r\n }\r\n}\r\n\r\nexport class LegalLink extends joint.shapes.standard.Link {\r\n defaults() {\r\n return joint.util.defaultsDeep({\r\n type: 'LegalLink',\r\n color: '#99C13C', // custom attribute - metadata only\r\n dashed: true, // custom attribute - metadata only\r\n attrs: {\r\n line: {\r\n stroke: '#99C13C',\r\n strokeWidth: 3,\r\n strokeDasharray: '6, 5',\r\n targetMarker: {\r\n d: 'M 10 -5 0 0 10 5 Z',\r\n }\r\n },\r\n },\r\n labels: [{\r\n attrs: {\r\n rect: {\r\n ref: 'text',\r\n width: 'calc(w+12)',\r\n height: 'calc(h+10)',\r\n x: 'calc(x-6)',\r\n y: 'calc(y-5)',\r\n stroke: '#D0D0CE',\r\n cursor: 'pointer',\r\n },\r\n text: {\r\n textAnchor: 'middle',\r\n textVerticalAnchor: 'middle',\r\n fill: 'black',\r\n fontSize: 14,\r\n fontFamily: '\"Open Sans\", sans-serif',\r\n fontWeight: 'bold',\r\n text: 'Legal Title',\r\n }\r\n }\r\n }]\r\n }, joint.shapes.standard.Link.prototype.defaults);\r\n }\r\n}\r\n\r\nexport class PaymentLink extends joint.shapes.standard.Link {\r\n defaults() {\r\n return joint.util.defaultsDeep({\r\n type: 'PaymentLink',\r\n color: '#9B9B9D', // custom attribute - metadata only\r\n dashed: true, // custom attribute - metadata only\r\n attrs: {\r\n line: {\r\n stroke: '#9B9B9D',\r\n strokeWidth: 3,\r\n strokeDasharray: '6, 5',\r\n targetMarker: {\r\n d: 'M 10 -5 0 0 10 5 Z',\r\n }\r\n },\r\n },\r\n labels: [{\r\n attrs: {\r\n rect: {\r\n ref: 'text',\r\n width: 'calc(w+12)',\r\n height: 'calc(h+10)',\r\n x: 'calc(x-6)',\r\n y: 'calc(y-5)',\r\n stroke: '#D0D0CE',\r\n cursor: 'pointer',\r\n },\r\n text: {\r\n textAnchor: 'middle',\r\n textVerticalAnchor: 'middle',\r\n fill: 'black',\r\n fontSize: 14,\r\n fontFamily: '\"Open Sans\", sans-serif',\r\n fontWeight: 'bold',\r\n text: 'Payment',\r\n }\r\n }\r\n }]\r\n }, joint.shapes.standard.Link.prototype.defaults);\r\n }\r\n}\r\n\r\nclass ServiceLink extends joint.shapes.standard.Link {\r\n defaults() {\r\n return joint.util.defaultsDeep({\r\n type: 'ServiceLink',\r\n color: 'black', // custom attribute - metadata only\r\n attrs: {\r\n line: {\r\n stroke: 'black',\r\n strokeWidth: 3,\r\n targetMarker: {\r\n d: 'M 10 -5 0 0 10 5 Z',\r\n }\r\n },\r\n },\r\n labels: [{\r\n attrs: {\r\n rect: {\r\n ref: 'text',\r\n width: 'calc(w+12)',\r\n height: 'calc(h+10)',\r\n x: 'calc(x-6)',\r\n y: 'calc(y-5)',\r\n stroke: '#D0D0CE',\r\n cursor: 'pointer',\r\n },\r\n text: {\r\n textAnchor: 'middle',\r\n textVerticalAnchor: 'middle',\r\n fill: 'black',\r\n fontSize: 14,\r\n fontFamily: '\"Open Sans\", sans-serif',\r\n fontWeight: 'bold',\r\n text: 'Service',\r\n }\r\n }\r\n }]\r\n }, joint.shapes.standard.Link.prototype.defaults);\r\n }\r\n}\r\n\r\nclass IPTransferLink extends joint.shapes.standard.Link {\r\n defaults() {\r\n return joint.util.defaultsDeep({\r\n type: 'IPTransferLink',\r\n color: '#FFA500', // custom attribute - metadata only\r\n attrs: {\r\n line: {\r\n stroke: '#FFA500',\r\n strokeWidth: 3,\r\n targetMarker: {\r\n d: 'M 10 -5 0 0 10 5 Z',\r\n }\r\n },\r\n },\r\n labels: [{\r\n attrs: {\r\n rect: {\r\n ref: 'text',\r\n width: 'calc(w+12)',\r\n height: 'calc(h+10)',\r\n x: 'calc(x-6)',\r\n y: 'calc(y-5)',\r\n stroke: '#D0D0CE',\r\n cursor: 'pointer',\r\n },\r\n text: {\r\n textAnchor: 'middle',\r\n textVerticalAnchor: 'middle',\r\n fill: 'black',\r\n fontSize: 14,\r\n fontFamily: '\"Open Sans\", sans-serif',\r\n fontWeight: 'bold',\r\n text: 'IP Transfer',\r\n }\r\n }\r\n }]\r\n }, joint.shapes.standard.Link.prototype.defaults);\r\n }\r\n}\r\n\r\nclass IPLicenseLink extends joint.shapes.standard.Link {\r\n defaults() {\r\n return joint.util.defaultsDeep({\r\n type: 'IPLicenseLink',\r\n color: '#8E25AB', // custom attribute - metadata only\r\n attrs: {\r\n line: {\r\n stroke: '#8E25AB',\r\n strokeWidth: 3,\r\n targetMarker: {\r\n d: 'M 10 -5 0 0 10 5 Z',\r\n }\r\n },\r\n },\r\n labels: [{\r\n attrs: {\r\n rect: {\r\n ref: 'text',\r\n width: 'calc(w+12)',\r\n height: 'calc(h+10)',\r\n x: 'calc(x-6)',\r\n y: 'calc(y-5)',\r\n stroke: '#D0D0CE',\r\n cursor: 'pointer',\r\n },\r\n text: {\r\n textAnchor: 'middle',\r\n textVerticalAnchor: 'middle',\r\n fill: 'black',\r\n fontSize: 14,\r\n fontFamily: '\"Open Sans\", sans-serif',\r\n fontWeight: 'bold',\r\n text: 'IP License',\r\n }\r\n }\r\n }]\r\n }, joint.shapes.standard.Link.prototype.defaults);\r\n }\r\n}\r\n\r\nclass AgreementLink extends joint.shapes.standard.Link {\r\n defaults() {\r\n return joint.util.defaultsDeep({\r\n type: 'AgreementLink',\r\n color: '#256F8C', // custom attribute - metadata only\r\n attrs: {\r\n line: {\r\n stroke: '#256F8C',\r\n strokeWidth: 3,\r\n targetMarker: {\r\n d: 'M 10 -5 0 0 10 5 Z',\r\n },\r\n sourceMarker: {\r\n d: 'M 10 -5 0 0 10 5 Z',\r\n }\r\n },\r\n },\r\n labels: [{\r\n attrs: {\r\n rect: {\r\n ref: 'text',\r\n width: 'calc(w+12)',\r\n height: 'calc(h+10)',\r\n x: 'calc(x-6)',\r\n y: 'calc(y-5)',\r\n stroke: '#D0D0CE',\r\n cursor: 'pointer',\r\n },\r\n text: {\r\n textAnchor: 'middle',\r\n textVerticalAnchor: 'middle',\r\n fill: 'black',\r\n fontSize: 14,\r\n fontFamily: '\"Open Sans\", sans-serif',\r\n fontWeight: 'bold',\r\n text: 'Agreement',\r\n }\r\n }\r\n }]\r\n }, joint.shapes.standard.Link.prototype.defaults);\r\n }\r\n}\r\n\r\nclass MiscellaneousLink extends joint.shapes.standard.Link {\r\n defaults() {\r\n return joint.util.defaultsDeep({\r\n type: 'MiscellaneousLink',\r\n color: '#EB8100', // custom attribute - metadata only\r\n dashed: true, // custom attribute - metadata only\r\n attrs: {\r\n line: {\r\n stroke: '#EB8100',\r\n strokeWidth: 3,\r\n strokeDasharray: '6, 5',\r\n targetMarker: {\r\n d: 'M 10 -5 0 0 10 5 Z',\r\n }\r\n },\r\n },\r\n labels: [{\r\n attrs: {\r\n rect: {\r\n ref: 'text',\r\n width: 'calc(w+12)',\r\n height: 'calc(h+10)',\r\n x: 'calc(x-6)',\r\n y: 'calc(y-5)',\r\n stroke: '#D0D0CE',\r\n cursor: 'pointer',\r\n },\r\n text: {\r\n textAnchor: 'middle',\r\n textVerticalAnchor: 'middle',\r\n fill: 'black',\r\n fontSize: 14,\r\n fontFamily: '\"Open Sans\", sans-serif',\r\n fontWeight: 'bold',\r\n text: 'Miscellaneous',\r\n }\r\n }\r\n }]\r\n }, joint.shapes.standard.Link.prototype.defaults);\r\n }\r\n}\r\n\r\nObject.assign(joint.shapes, { PhysicalLink, LegalLink, PaymentLink, ServiceLink, IPTransferLink, IPLicenseLink, AgreementLink, MiscellaneousLink });\r\n"],"names":["__webpack_require__","exports","definition","key","o","Object","defineProperty","enumerable","get","obj","prop","prototype","hasOwnProperty","call","Symbol","toStringTag","value","argsTag","arrayTag","boolTag","dateTag","errorTag","funcTag","mapTag","numberTag","objectTag","regexpTag","setTag","stringTag","symbolTag","weakMapTag","arrayBufferTag","dataViewTag","float32Tag","float64Tag","int8Tag","int16Tag","int32Tag","uint8Tag","uint8ClampedTag","uint16Tag","uint32Tag","CLONEABLE_TAGS","rsAstralRange","rsDingbatRange","rsLowerRange","rsUpperRange","rsBreakRange","rsMathOpRange","rsApos","rsBreak","rsCombo","rsDingbat","rsLower","rsMisc","rsFitz","rsNonAstral","rsRegional","rsSurrPair","rsUpper","rsMiscLower","rsMiscUpper","rsOptContrLower","rsOptContrUpper","reOptMod","rsOptVar","rsSeq","join","rsEmoji","reUnicodeWords","RegExp","HASH_UNDEFINED","reTypedTag","rsSymbol","reUnicode","reIsDeepProp","reIsPlainProp","charCodeOfDot","charCodeAt","reEscapeChar","rePropName","reIsUint","hasUnicodeWord","test","bind","reAsciiWord","hasUnicode","string","stringToArray","match","unicodeToArray","split","asciiToArray","values","object","keys","map","isArrayLike","arrayLikeKeys","inherited","isArr","Array","isArray","isArg","isObjectLike","getTag","isType","isTypedArray","skipIndexes","length","result","index","isIndex","push","assocIndexOf","array","eq","other","isIterateeCall","isObject","type","isPrototype","Ctor","constructor","assignValue","objValue","undefined","copyObject","source","props","isSymbol","copyArray","toString","cloneArrayBuffer","arrayBuffer","byteLength","Uint8Array","set","cloneTypedArray","typedArray","isDeep","buffer","byteOffset","initCloneObject","create","getPrototypeOf","getSymbols","getOwnPropertySymbols","filter","symbol","propertyIsEnumerable","getAllKeys","getSymbolsIn","getAllKeysIn","getMapData","__data__","data","isKeyable","baseIsEqual","stack","baseIsEqualDeep","equalFunc","objIsArr","othIsArr","objTag","othTag","objIsObj","othIsObj","isSameTag","Stack","equalArrays","equalByTag","objIsWrapped","othIsWrapped","objUnwrapped","othUnwrapped","objProps","objLength","objStacked","othStacked","skipCtor","othValue","objCtor","othCtor","equalObjects","compareUnordered","arrLength","arrStacked","seen","SetCache","compared","arrValue","some","othIndex","cacheHas","predicate","cache","has","compareArrayBufferTag","tag","name","message","convert","mapToArray","setToArray","size","stacked","valueOf","forEach","isKey","castPath","path","replace","expression","quote","subString","trim","stringToPath","toKey","compareAscending","valIsDefined","valIsNull","valIsReflexive","valIsSymbol","othIsDefined","othIsNull","othIsReflexive","othIsSymbol","diff","includes","indexOf","isCommon","valuesLength","outer","computed","valuesIndex","baseClone","isFlat","isFull","customizer","input","initCloneArray","isFunc","copySymbolsIn","copySymbols","assign","Constructor","dataView","cloneDataView","regexp","exec","lastIndex","cloneRegExp","initCloneByTag","isMap","subValue","isSet","add","keysIn","slice","nested","newValue","Number","MAX_SAFE_INTEGER","unset","lastSegment","safeGet","createAssigner","assigner","isMerge","sources","guard","a","b","baseMerge","srcIndex","srcValue","baseMergeDeep","assignMergeValue","mergeFunc","isTyped","isPlainObject","isArguments","toPlainObject","baseEach","collection","iteratee","keysFunc","iterable","baseFor","baseForOwn","createSet","Set","customDefaultsMerge","baseOrderBy","iteratees","orders","criteriaIndex","eachIndex","criteria","sort","objCriteria","othCriteria","ordersLength","order","compareMultiple","baseSortBy","isStrictComparable","matchesStrictComparable","hasIn","hasPath","baseHasIn","baseMatches","matchData","getMatchData","baseIsMatch","baseIteratee","val","basePropertyDeep","property","getIteratee","arguments","arrayReduce","accumulator","initAccum","baseReduce","eachFunc","isFlattenable","isConcatSpreadable","baseFlatten","depth","isStrict","hasFunc","upperFirst","strSymbols","chr","trailing","start","end","castSlice","entries","this","ListCache","clear","pairs","LARGE_ARRAY_SIZE","MapCache","entry","pop","splice","Hash","Map","isNumber","isString","defaults","propsLength","propsIndex","defaultsDeep","args","merge","apply","invoke","invokeProperty","func","last","sortedIndex","low","high","valIsNaN","valIsUndefined","setLow","mid","Math","floor","min","uniq","seenIndex","clone","cloneDeep","isEmpty","baseKeys","isEqual","proto","toArray","iterator","next","done","sortBy","flat","flattenDeep","Infinity","without","difference","union","arrays","defaultValue","paths","pick","basePickBy","basePick","camelCase","pattern","unicodeWords","asciiWords","words","reduce","word","toLowerCase","idCounter","uniqueId","prefix","WeakMap","remove","delete","dataPriv","dataUser","Event","src","originalEvent","isDefaultPrevented","defaultPrevented","returnTrue","returnFalse","target","currentTarget","relatedTarget","timeStamp","Date","now","envelope","isPropagationStopped","isImmediatePropagationStopped","preventDefault","evt","stopPropagation","stopImmediatePropagation","configurable","writable","addProp","window","document","documentElement","rTypeNamespace","rNotHtmlWhite","selector","Dom","fn","guid","first","second","len","i","j","parseHTML","context","implementation","createHTMLDocument","base","createElement","href","location","head","appendChild","body","innerHTML","scripts","getElementsByTagName","from","childNodes","pushStack","elements","ret","prevObject","find","el","nodeType","contains","querySelectorAll","newElements","prevElements","concat","addBack","matches","node","rQuickExpr","Error","$root","getElementById","event","special","elem","eventType","events","on","types","one","origFn","off","handler","elemData","handleObjIn","eventHandle","handle","e","dispatch","typesArr","origType","ns","namespaces","delegateType","bindType","handleObj","namespace","handlers","delegateCount","setup","addEventListener","mappedTypes","rNamespace","origCount","teardown","removeEventListener","nativeEvent","fix","delegateTarget","eventsData","preDispatch","handlerQueue","matched","origSpecial","postDispatch","button","cur","parentNode","disabled","matchedHandlers","matchedSelectors","sel","round","PI","scale","linear","domain","range","domainSpan","rangeSpan","normalizeAngle","angle","snapToGrid","gridSize","toDeg","rad","toRad","deg","over360","random","max","temp","cos","sin","atan2","bearing","p","q","lat1","y","lat2","lon1","x","lon2","dLon","parseInt","squaredLength","x0","y0","sqrt","Point","Line","Ellipse","Rect","Polyline","Polygon","Curve","Path","abs","pow","xy","parseFloat","fromPolar","distance","origin","x1","x2","y1","y2","chooseClosest","points","n","closest","minSqrDistance","sqrDistance","squaredDistance","adhereToRect","r","containsPoint","width","height","angleBetween","p1","p2","equals","NaN","theta","point","changeInAngle","dx","dy","ref","offset","cross","dot","lerp","t","magnitude","manhattanDistance","move","normalize","reflection","rotate","cosAngle","sinAngle","precision","f","sx","sy","gx","gy","toJSON","toPolar","serialize","update","vectorAngle","translate","horizontalPoint","bbox","left","top","right","bottom","closestPoint","pointAt","closestPointNormalizedLength","closestPointLength","product","vector","cpNormalizedLength","closestPointTangent","tangentAt","divideAt","ratio","dividerPoint","divideAtLength","pointAtLength","l","intersect","shape","opt","intersectionWithLine","intersection","line","pt1Dir","pt2Dir","det","deltaPt","alpha","beta","isDifferentiable","midpoint","parallel","eRef","sRef","fromStart","lineLength","pointOffset","setLength","currentLength","scaleFactor","tangentStart","tangentLine","tangentAtLength","tx","ty","c","fromRect","rect","center","normalizedDistance","ellipse","inflate","intersections","a1","a2","rx","ry","dir","mDir","mDiff","d","root","ta","tb","intersectionWithLineFromCenterToPoint","pointNearestToPoint","m","mSquared","aSquared","bSquared","tangentTheta","q1","q3","w","h","fromEllipse","fromPointUnion","minX","minY","maxX","maxY","fromRectUnion","rects","mX","mY","rotateAroundCenter","st","ct","bottomLeft","bottomLine","bottomRight","bottomMiddle","strict","containsRect","r0","r1","w0","h0","w1","h1","corner","mr","nr","myOrigin","myCorner","rOrigin","rCorner","pt","rectLines","topLine","rightLine","leftLine","dedupeArr","sides","connector","topLeft","leftMiddle","maxRectScaleToFit","sx1","sx2","sx3","sx4","sy1","sy2","sy3","sy4","ox","oy","p3","topRight","p4","maxRectUniformScaleToFit","moveAndExpand","newx","newy","newwidth","newheight","sideNearestToPoint","rightMiddle","distToLeft","distToRight","distToTop","side","topMiddle","parsePoints","svgString","trimmedString","coords","numCoords","clonePoints","numPoints","newPoints","convexHull","startPoint","sortedPointRecords","record1","record2","sortOutput","startPointRecord","unshift","currentPointRecord","currentPoint","lastHullPointRecord","lastHullPoint","secondLastHullPointRecord","secondLastHullPoint","lowestHullIndex","insidePoints","hullPointRecords","correctTurnFound","crossProduct","indexOfLowestHullIndexRecord","currentHullIndex","hullPointRecordsReordered","newFirstChunk","newSecondChunk","hullPoints","parse","cpLength","lengthPoints","startIndex","endIndex","numIntersections","segment","ray","rayEnd","xDifference","close","otherPoints","otherPoint","l2","int","simplify","threshold","currentIndex","middleIndex","firstPoint","middlePoint","lastPoint","lastValidLine","output","controlPoint1","controlPoint2","extend","child","inheritedProperty","getOwnPropertyDescriptor","throughPoints","getFirstControlPoints","rhs","tmp","controlPoints","knots","firstControlPoints","secondControlPoints","getCurveControlPoints","curves","t1","t2","b2ac","sqrtb2ac","x3","y3","tvalues","bounds","mt","jlen","X","Y","pointAtT","closestPointT","PRECISION","localOpt","subdivisions","getSubdivisions","lengthAtT","investigatedSubdivision","investigatedSubdivisionStartT","investigatedSubdivisionEndT","distFromStart","distFromEnd","chordLength","minSumDist","subdivisionSize","currentSubdivision","startDist","endDist","sumDist","precisionRatio","startPrecisionRatio","endPrecisionRatio","divided","divide","startDist1","endDist1","sumDist1","startDist2","endDist2","tangentAtT","toPolyline","divideAtT","tAt","tAtLength","dividerPoints","getSkeletonPoints","startControl1","startControlPoint1","startControl2","startControlPoint2","divider","dividerControl1","dividerControlPoint1","dividerControl2","dividerControlPoint2","endpointDistance","control1","control2","midpoint1","midpoint2","midpoint3","subControl1","subControl2","previousLength","minIterations","iteration","newSubdivisions","numSubdivisions","numNewSubdivisions","skeletonPoints","baselinePointDistFromStart","baselinePointDistFromEnd","curveLength","newBaselinePointDistFromStart","newBaselinePointDistFromEnd","baseline1Length","baseline2Length","toPoints","arg","segments","acc","isSegment","appendSegment","previousObj","createSegment","applyToNew","argsArray","Function","pathData","commands","numCommands","segmentConstructor","segmentTypes","currentSegment","numSegments","previousSegment","currentArg","prepareSegment","isVisible","segmentBBox","segmentSubdivisions","getSegmentSubdivisions","minSquaredDistance","segmentClosestPointT","segmentClosestPoint","segmentIndex","polylines","toPolylines","numPolylines","dividedSegmentIndex","lastValidSegment","lastValidSegmentIndex","getSegment","pathCopy","replaceSegment","divisionStartIndex","divisionMidIndex","divisionEndIndex","removeSegment","movetoEnd","insertSegment","secondPathSegmentIndexConversion","originalSegment","subpathStartSegment","convertedSegment","otherSegments","otherSegment","getSubpaths","validate","subpaths","isSubpathStart","nextSegment","polyline","polylineIntersection","isValid","tValue","precisison","lastVisibleSegment","updateSubpathStart","updateSubpathStartSegment","removedSegment","replacedSegment","segmentAt","segmentIndexAt","segmentAtLength","segmentIndexAtLength","lastVisibleSegmentIndex","partialPoints","currentSegmentSubdivisions","subdivisionPoints","curve","segmentPrototype","Lineto","outputArray","segmentPoint","segmentCoords","linetoPrototype","Curveto","segmentPoints","curvetoPrototype","c1","c2","Moveto","movetoPrototype","Closepath","closepathPrototype","L","C","M","Z","z","regexSupportedData","isDataSupported","bezier","curveThroughPoints","console","warn","getCurveDivider","p0","getInversionSolver","exists","shape1","shape2","shape1opt","shape2opt","lineWithLine","ellipseWithLine","ellipseWithEllipse","rectWithLine","rectWithEllipse","rectWithRect","polylineWithLine","polylineWithEllipse","polylineWithRect","polylineWithPolyline","polygonWithLine","polygonWithEllipse","polygonWithRect","polygonWithPolyline","polygonWithPolygon","pathWithLine","pathWithEllipse","pathWithRect","pathWithPolyline","pathWithPolygon","pathWithPath","line1","line2","s1x","s1y","s2x","s2y","s3x","s3y","s","rex","rey","xe","ye","rex_2","rey_2","A","B","D","ellipse1","ellipse2","e1","e2","sinW1","cosW1","sinW2","cosW2","sinW1s","cosW1s","sinCos1","sinW2s","cosW2s","sinCos2","a1s","b1s","a2s","b2s","A1","A2","B1","B2","C1","C2","D1","D2","E1","E2","F1","F2","l3","det3","l0","l1","delta1","det2","delta2","delta3","_ellipsesIntersection","rect1","rect2","_polylineWithLine","interior","_polylineWithEllipse","_polylineWithRect","polyline1","polyline2","_polylineWithPolyline","polygon","polygon1","polygon2","_polylineWithPolygon","pathOpt","subpath","_pathWithPolyline","path1","path2","pathOpt1","pathOpt2","thisPoints","thisPolyline","SVGAngle","svg","xmlns","xml","xlink","xhtml","math","V","attrs","children","isV","createSvgDocument","svgDoc","arrayOfVels","childNode","importNode","firstChild","createElementNS","ensureId","setAttributes","append","VPrototype","annotateTextLine","lineNode","lineAnnotations","includeAnnotationIndices","eol","lineHeight","baseSize","maxFontSize","fontMetrics","lastJ","annotation","fontSize","annotationAttrs","vTSpan","tspanNode","textContent","annotationClass","addClass","attr","annotations","isFinite","createTextNode","id","getTransformToElement","isSVGGraphicsElement","targetCTM","toNode","getScreenCTM","nodeCTM","inverse","multiply","createSVGMatrix","transform","matrix","isUndefined","transformStringToMatrix","absolute","matrixToTransformString","svgTransform","createSVGTransform","baseVal","appendItem","transformAttr","parseTransformString","newTranslate","cx","cy","newRotate","newScale","withoutTransformations","box","ownerSVGElement","getBBox","clientLeft","clientTop","clientWidth","clientHeight","transformRect","outputBBox","options","recursive","childBBox","currentChild","emRegex","convertEmToPx","em","numerical","text","content","sanitizeText","displayEmpty","textPath","verticalAnchor","textVerticalAnchor","namedVerticalAnchor","iai","defaultLineHeight","autoLineHeight","empty","containerNode","doc","vel","textPathElement","linkedPath","appendTo","defs","createTextPathNode","createDocumentFragment","annotatedY","lines","linesMetrics","lastI","lineMetrics","lineClassName","annotateString","iLineHeight","lineNodeStyle","style","fillOpacity","strokeOpacity","lineFontSize","findAnnotationsAtIndex","fs","setAttribute","className","alignment","baseSizePx","flMaxFont","rLineHeights","lineHeightPx","llMaxFont","calculateDY","rh","removeAttr","trueName","attributeNames","local","qualifyAttr","hasAttributeNS","removeAttributeNS","hasAttribute","removeAttribute","attributes","getAttribute","attrName","normalizePath","tagName","normalizePathData","removeChild","els","prepend","before","parent","insertBefore","SVGSVGElement","toUpperCase","defsNode","cloneNode","findOne","found","querySelector","vels","nodes","previousSibling","findParentByClass","terminator","hasClass","bup","compareDocumentPosition","toLocalPoint","createSVGPoint","globalPoint","matrixTransform","globalToLocalMatrix","translateCenterToPoint","translateAndAutoOrient","position","reference","translateToOrigin","setTranslate","rotateAroundOrigin","setRotate","translateFromOrigin","finalPosition","ctm","setMatrix","animateAlongPath","animateMotion","mpath","beginElement","animation","animators","animationID","id2anim","targets","getTargets","animator","Animator","register","noHTMLWhitespaceRegex","getTokenList","str","classList","removeClass","toggleClass","toAdd","tokens","toggle","sample","interval","getTotalLength","samples","getPointAtLength","convertToPath","convertToPathData","convertLineToPathData","convertPolygonToPathData","convertPolylineToPathData","convertEllipseToPathData","convertCircleToPathData","convertRectToPathData","toGeometryShape","getPointsFromSvgNode","findIntersection","spot","gRect","rectMatrix","rectMatrixComponents","decomposeMatrix","resetRotation","rotation","gp","refDistance","minDistance","closestSamples","setAttributeNS","XMLString","parseXML","async","createSVGStyle","stylesheet","createCDATASection","createDocument","nodeName","parser","DOMParser","parseFromString","error","_attributeNames","Proxy","supportCamelCaseAttributes","combinedKey","transformSeparatorRegex","transformRegex","transformFunctionRegex","transformTranslateRegex","transformRotateRegex","transformScaleRegex","transformationMatrix","transformMatches","numMatches","transformFunctionMatch","transformFunction","scaleNonUniform","skewX","skewY","separator","decomposedMatrix","translateX","translateY","scaleX","scaleY","transformations","translateMatch","rotateMatch","scaleMatch","deltaTransformPoint","px","py","matrixToScale","matrixToRotate","matrixToTranslate","isVElement","SVGElement","svgDocument","svgMatrix","component","SVGMatrix","createSVGTransformFromMatrix","corner1","corner2","corner3","corner4","transformPoint","transformLine","transformPolyline","inPoints","outPoints","styleToObject","styleString","styles","pair","createSlicePathData","innerRadius","outerRadius","startAngle","endAngle","svgArcMax","a0","da","df","c0","s0","s1","mergeAttrs","batch","item","prev","compacted","JSON","stringify","findAnnotationsBetweenIndexes","shiftAnnotations","svgPointsToPath","nodePoints","numberOfItems","getItem","KAPPA","circle","cd","cdx","cdy","rectToPath","topRx","bottomRx","topRy","bottomRy","spaces","pathCommand","pathValues","tan","asin","q2c","ax","ay","_13","_23","a2c","large_arc_flag","sweep_flag","_120","res","f1","f2","rx2","ry2","k","toFixed","f2old","x2old","y2old","s2","hx","hy","m1","m2","m3","m4","newres","ii","pathArray","pathString","paramCounts","v","String","params","parsePathString","pa0","mx","my","jj","pa","kk","pathToAbsolute","bx","by","qx","qy","processPath","pcom","nx","ny","T","Q","fixArc","pp","shift","pi","pcoms","pfirst","seg","seglen","g","cleanNodesData","cleanNodeData","removeNodes","detach","clones","html","prependTo","requireUnits","setCSSProperty","css","dataset","setNodesClass","method","closestEl","ancestorEl","getComputedStyle","offsetWidth","borderTopWidth","borderBottomWidth","paddingTop","paddingBottom","offsetHeight","borderLeftWidth","borderRightWidth","paddingLeft","paddingRight","offsetParent","$el","parentOffset","getBoundingClientRect","ownerDocument","$parentOffset","parentOffsetElementPosition","offsetParentStyles","marginTop","marginLeft","coordinates","getClientRects","scrollY","scrollX","currentStyle","currentOffset","topDifference","leftDifference","cssProp","animationKey","cssReset","animate","properties","stop","animateNode","duration","easing","delay","complete","delayId","setTimeout","fired","endEvent","cssValues","transitionProperties","wrappedCallback","callbackId","clearTimeout","propertySetters","outerWidth","outerHeight","innerWidth","innerHeight","scrollLeft","scrollTop","propertiesMap","methods","methodName","load","noBubble","orig","related","dbltap","targetData","getTime","delta","lastTouch","addClassNamePrefix","_className","substr","parseDOMJSON","json","selectors","groupSelectors","svgNamespace","fragment","parseNode","siblingsDef","nodeDef","textNode","namespaceURI","wrapperNode","nodeSelector","nodeGroups","groupSelector","nodeGroup","group","childrenDef","hashCode","hash","getByPath","delimiter","isGetSafe","setByPath","diver","unsetByPath","normalizeEvent","normalized","touch","changedTouches","useElement","correspondingUseElement","nextFrame","raf","requestAnimationFrame","webkitRequestAnimationFrame","mozRequestAnimationFrame","oRequestAnimationFrame","msRequestAnimationFrame","lastTime","callback","currTime","timeToCall","rest","cancelFrame","client","caf","cancelAnimationFrame","webkitCancelAnimationFrame","webkitCancelRequestAnimationFrame","msCancelAnimationFrame","msCancelRequestAnimationFrame","oCancelAnimationFrame","oCancelRequestAnimationFrame","mozCancelAnimationFrame","mozCancelRequestAnimationFrame","isPercentage","parseCssNumeric","restrictUnits","number","isNaN","validUnitExp","unit","getUnit","splitWordWithEOL","eolWords","jl","replacement","getLineHeight","heightValue","textElement","breakText","textSpan","opacity","display","preserveSpaces","separatorChar","hyphen","maxLineCount","full","isEol","getComputedTextLength","partition","substring","nextWord","hyphenIndex","search","lastL","ellipsis","lastLine","lastLineWithOmission","lastChar","normalizeSides","vertical","horizontal","timing","quad","cubic","inout","t3","exponential","bounce","reverse","reflect","clamp","back","elastic","interpolate","hexColor","ca","cb","ra","rd","ga","gd","ba","bd","ma","mb","u","outline","margin","template","color","highlight","blur","stdDeviation","dropShadow","tpl","grayscale","amount","sepia","saturate","hueRotate","invert","amount2","brightness","contrast","regex","attrArray","_attr","findDifference","baseObj","currentDepth","maxDepth","baseValue","nestedDepth","nestedDiff","objectDifference","POSITIVE_INFINITY","_listening","Events","eventSplitter","eventsApi","opts","names","_events","onApi","ctx","listening","_listeners","interop","listenTo","_listenId","listeningTo","_listeningTo","Listening","tryCatchOn","count","offApi","listeners","stopListening","ids","remaining","_callback","cleanup","once","onceMap","listenToOnce","offer","onceInvoke","TypeError","trigger","triggerApi","objEvents","allEvents","all","triggerEvents","ev","a3","listener","unbind","protoProps","staticProps","__super__","instance","_isModel","modelMatcher","model","matcher","Model","preinitialize","cid","cidPrefix","attributeDefaults","changed","initialize","cloneCells","cells","cloneMap","cell","isLink","embeds","newEmbeds","embed","validationError","idAttribute","_validate","silent","changes","changing","_changing","_previousAttributes","current","prevId","_pending","hasChanged","changedAttributes","old","previous","previousAttributes","validProperties","qualify","_","option","selected","positionWrapper","axis","dimension","refBBox","valuePercentage","refOrigin","setWrapper","isValuePercentage","attrValue","legacyAttributesNS","widthFn","heightFn","rValue","diagonalLength","minimum","maximum","diagonal","propsList","numberPattern","findSpacesRegex","parseFormulaRegExp","throwInvalid","evalCalcFormula","formula","addExpression","sign","evalAddExpression","isCalcExpression","evalCalcExpression","startSearchIndex","calcIndex","calcEndIndex","calcStart","brackets","findClosingBracket","calcValue","isTextInUse","_value","_node","FONT_ATTRIBUTES","textAttributesNS","_text","textWrap","cacheName","textHash","pathSelector","pathNode","findNode","SVGPathElement","wrappedText","breakTextFn","computedStyles","wrapFontAttributes","paper","title","titleNode","firstElementChild","atConnectionWrapper","zeroVector","tangent","isLinkView","connectionAttributesNS","stubs","getConnectionLength","getConnection","getConnectionSubdivisions","sourceParts","targetParts","getSerializedConnection","shapeWrapper","shapeConstructor","resetOffset","cachedShape","shapeBBox","shapeOrigin","fitScale","dWrapper","pointsWrapper","shapeAttributesNS","contextMarker","marker","stroke","setPaintURL","def","definePattern","defineGradient","defineMarker","defineFilter","offsetWrapper","nodeBBox","setIfChangedWrapper","attribute","attributesNS","port","legacy","connection","attributesMerger","removeEmptyAttributes","Cell","mergeArrays","ignoreDefaults","ignoreEmptyAttributes","finalAttributes","defaultAttributes","getIdAttribute","generateId","_transitionIds","_scheduledTransitionIds","processPorts","previousPorts","ports","removedPorts","graph","getConnectedLinks","inbound","link","outbound","startBatch","parentCell","getParentCell","unembed","embeddedCells","getEmbeddedCells","stopBatch","toFront","foregroundEmbeds","deep","breadthFirst","sortSiblings","sortedCells","maxZIndex","shouldUpdate","toBack","minZIndex","canEmbed","reparent","_unembedCells","isEmbedded","_embedCells","every","isEmbeddedIn","batchName","parentId","getCell","getAncestors","ancestors","_getEmbeddedCellsBfs","_getEmbeddedCellsDfs","embeddedIds","queue","cellId","_isString","pathArrayLength","propertyPath","propertyValue","propertyPathArray","rewrite","initializer","prevProperty","pathItem","isArrayIndex","baseAttributes","changedValue","removeProp","dirty","nestedPath","transition","delim","timingFunction","valueFunction","interpolatingFunction","firstFrameTime","setter","runtime","progress","transitionId","initialId","stopPendingTransitions","getTransitions","stopScheduledTransitions","transitions","stopTransitions","addTo","addCell","findView","findViewByModel","isElement","getChangeFlag","flag","getPointFromConnectedLink","getPointRotatedAroundCenter","getAbsolutePointFromRelative","getRelativePointFromAbsolute","getAttributeDefinition","defNS","globalDefNS","define","joint","shapes","portTransformAttrs","trans","lineLayout","elBBox","argTransform","ellipseLayout","stepFn","compensateRotation","dr","argPoint","transformation","ellipseSpread","stepAngle","step","labelAttributes","opt1","opt2","getBBoxAngles","tl","bl","br","outsideLayout","portPosition","autoOrient","textAnchor","orientAngle","topLeftAngle","bottomLeftAngle","bottomRightAngle","topRightAngle","labelText","insideLayout","radialLayout","portCenterOffset","manual","_portPosition","_elBBox","outsideOriented","outside","insideOriented","inside","radial","radialOriented","PortData","clonedData","groups","portLayoutNamespace","portLabelLayoutNamespace","_init","getPorts","getGroup","getPortsByGroup","groupName","getGroupPortsMetrics","groupPosition","groupPositionName","groupArgs","portsArgs","groupPortTransformations","portTransformation","portId","labelTransformation","_getPortLabelLayout","portAttrs","portSize","labelSize","label","labelPosition","_evaluateGroup","items","_evaluatePort","_getPosition","_getLabel","evaluated","markup","_createPositionNode","_getZIndex","setDefault","positionName","setDefaults","elementPortPrototype","_initializePorts","_createPortData","_processRemovedPort","currentItemsMap","removed","hasPorts","hasPort","getPortIndex","getGroupPorts","groupPorts","getPort","getPortGroupNames","_portSettingsData","getPortsPositions","positions","metrics","_isValidPortId","findIndex","addPort","insertPort","portProp","_validatePorts","portsAttr","errorMessages","generatePortId","addPorts","removePort","removePorts","portsForRemoval","newPorts","cp","rp","rpId","prevPortData","err","curPortData","added","prevPort","curPort","elementViewPortPrototype","portContainerMarkup","portMarkup","portLabelMarkup","_portElementsCache","_cleanPortsCache","_refreshPorts","_removePorts","_renderPorts","elementReferences","_getContainerElement","portsGropsByZ","withoutZKey","portElement","_getPortElement","groupNames","_appendPorts","_updatePorts","rotatableNode","refs","containerElement","portElements","_createPortElement","findPortNodes","portCache","portContentElement","portRoot","portSelectors","findBySelector","findPortNode","_updatePortGroup","labelElement","labelSelectors","portContainerElement","_getPortMarkup","portDoc","portFragment","labelMarkupDef","_getPortLabelMarkup","childCount","portContainerSelectors","portRootSelector","labelRootSelector","labelTextSelector","labelNode","labelTextNode","portLabelElement","portLabelSelectors","portContentSelectors","elementBBox","portsMetrics","cached","updateDOMSubtreeAttributes","rootBBox","applyPortTransform","element","transformData","initialAngle","isSetter","parentRelative","restrictedArea","parentPosition","elementPosition","translateBy","newPosition","translatedPosition","currentSize","resize","direction","quadrant","fixedPoint","imageFixedPoint","radius","atan","scaledBBox","fitEmbeds","fitToChildren","childElements","_fitToElements","fitParent","parentElement","siblingElements","elementsBBox","getCellsBBox","expandOnly","shrinkOnly","padding","resultBBox","intersectionBBox","endType","endDef","portGroup","portsPositions","portCenter","Link","defaultLabel","labelMarkup","_builtins","fill","pointerEvents","disconnect","setSource","setOpt","setTarget","router","isRouterProvided","localRouter","isConnectorProvided","localConnector","idx","labels","hasLabels","insertLabel","appendLabel","removeLabel","vertex","vertices","setVertex","_normalizeVertex","setVertices","insertVertex","removeVertex","applyToPoints","getSourcePoint","sourceCell","getSourceCell","getTargetPoint","targetCell","getTargetCell","getPolyline","newParent","getSourceElement","getTargetElement","prevParent","getCommonAncestor","hasLoop","sourceId","targetId","loop","sourceElement","targetElement","visited","getRelationshipAncestor","connectionAncestor","isRelationshipEmbeddedIn","ancestor","_getDefaultLabel","endsEqual","portsEqual","env","_results","_tests","svgforeignobject","isSafari","navigator","userAgent","vendor","addTest","Rectangle","cursor","strokeWidth","Circle","Image","image","BorderedImage","border","background","EmbeddedImage","preserveAspectRatio","InscribedImage","HeaderedRectangle","header","headerText","bodyText","Cylinder","lateralArea","bodyAttrs","topAttrs","isPercentageSetter","kappa","xCenter","xRight","ySideTop","yCurveTop","ySideBottom","yCurveBottom","backgroundColor","textAlign","boxSizing","alignItems","justifyContent","TextBlock","foreignObject","HTMLElement","wrapValue","wrapAttrs","strokeLinejoin","targetMarker","wrapper","DoubleLink","ShadowLink","sourceMarker","shadow","Positions","TOP","RIGHT","BOTTOM","LEFT","TOP_LEFT","TOP_RIGHT","BOTTOM_LEFT","BOTTOM_RIGHT","CENTER","getRectPoint","Collection","models","comparator","_reset","reset","setOptions","addOptions","insert","at","tail","singular","_removeModels","merged","toMerge","toRemove","modelMap","sortable","sortAttr","existing","_prepareModel","_addReference","orderChanged","_removeReference","previousModels","_byId","modelId","CollectionIterator","ITERATOR_VALUES","ITERATOR_KEYS","ITERATOR_KEYSVALUES","each","initAcc","_onModelEvent","$$iterator","config","kind","_collection","_kind","_index","Class","defaultVal","addMethod","addMethodsUtil","wrappers","GraphCells","cellNamespace","ModelClass","dry","Graph","cellModel","_sortOnChangeZ","_out","_in","_nodes","_edges","_batches","_restructureOnAdd","_restructureOnRemove","_restructureOnReset","_restructureOnChangeSource","_restructureOnChangeTarget","_removeCell","prevSource","prevTarget","getOutboundEdges","getInboundEdges","cellAttributes","fromJSON","resetCells","_prepareCell","firstCell","lastCell","addCells","maxPosition","preparedCells","removeCells","disconnectLinks","removeLinks","transferCellEmbeds","transferCellConnectedLinks","getCells","getElements","getLinks","getFirstCell","getLastCell","indirect","links","edges","addOutbounds","edge","addInbounds","outCell","inCell","embeddedElements","edgeCell","includeEnclosed","getNeighbors","neighbors","cellsAncestors","commonAncestor","cellAncestors","getSuccessors","cloneSubgraph","subgraph","getSubgraph","cellMap","getPredecessors","bfs","dfs","neighbor","getSources","getSinks","sinks","isSource","isSink","isSuccessor","elementA","elementB","isPredecessor","isNeighbor","findElementsAtPoint","_filterAtPoint","findLinksAtPoint","findCellsAtPoint","findElementsInArea","area","_filterInArea","findLinksInArea","findCellsInArea","findElementsUnderElement","_filterCellsUnderElement","findLinksUnderElement","findCellsUnderElement","_isValidElementUnderElement","el1","el2","_isValidLinkUnderElement","_validateCellsUnderElement","_getFindUnderElementGeometry","searchBy","geometry","filteredCells","findModelsInArea","findModelsFromPoint","findModelsUnderElement","memo","resizeCells","hasActiveBatch","batches","validations","multiLinks","sourceModel","_link","_source","_target","linkPinning","_graph","wrapWith","ViewBase","viewOptions","_ensureElement","delegateEventSplitter","$","render","_removeElement","setElement","undelegateEvents","_setElement","delegateEvents","delegate","eventName","undelegate","_createElement","_setAttributes","views","View","theme","themeClassNamePrefix","requireSetThemeOverride","defaultTheme","DETACHABLE","UPDATE_PRIORITY","FLAG_INSERT","FLAG_REMOVE","FLAG_INIT","setTheme","init","unmount","svgElement","isMounted","renderChildren","isSVG","findAttributeNode","attributeName","currentNode","findAttribute","matchedNode","_setStyle","_ensureElClassName","prefixedClassName","onRender","confirmUpdate","override","removeThemeClassName","addThemeClassName","onSetTheme","oldTheme","newTheme","onRemove","undelegateDocumentEvents","getEventNamespace","delegateElementEvents","eventNS","undelegateElementEvents","delegateDocumentEvents","eventData","currentData","propagationStopped","renderFn","__render__","HighlighterView","HIGHLIGHT_FLAG","UPDATABLE","MOUNTABLE","cellView","updateRequested","postponedUpdate","transformGroup","detachedTransformGroup","requestUpdate","requestViewUpdate","mount","findLabelNode","getNodeMatrix","layer","nodeMatrix","getRootRotateMatrix","getNodeRotateMatrix","cellViewRoot","layerName","vGroup","getLayerView","insertSortedNode","nextSibling","translateMatrix","getRootTranslateMatrix","rotateMatrix","transformMatrix","prevNode","unhighlight","notify","_removeRef","_cellView","listenToUpdateAttributes","onCellAttributeChange","_views","hid","previousView","view","_addRef","getAll","removeAll","calcAttributes","positiveValueAttributes","evalAttributes","evalAttrs","evalAttribute","evalAttrValue","HighlightingTypes","DEFAULT","EMBEDDING","CONNECTING","MAGNET_AVAILABILITY","ELEMENT_AVAILABILITY","CellView","classNames","list","_presentationAttributes","_flags","setFlags","flags","presentationAttributes","initFlag","hasFlag","getFlag","removeFlag","cleanNodesCache","startListening","onAttributesChange","updateHandled","tool","rootSelector","can","feature","interactive","useCSSSelectors","findNodes","useModelGeometry","getNodeBBox","localToPaperRect","magnet","getNodeBoundingRect","magnetMatrix","getNodeUnrotatedBBox","_notifyHighlight","rootNode","partial","embedding","connecting","magnetAvailability","elementAvailability","findMagnet","magnetAttribute","isMagnetRoot","findProxyNode","proxyNode","getSelector","prevSelector","nthChild","addLinkFromMagnet","getDefaultLink","getLinkEnd","ui","portNode","customizeLinkEnd","connectionStrategy","strategy","getMagnetFromLinkEnd","dragLinkStart","linkView","notifyPointerdown","startArrowheadMove","whenNotAllowed","dragLink","pointermove","magnetThreshold","getEventTarget","targetMagnet","mousemoved","dragLinkEnd","pointerup","setNodeAttributes","processNodeAttributes","attrVal","normalAttrs","setAttrs","positionAttrs","offsetAttrs","relatives","rawAttrs","unsetAttrName","raw","normal","updateRelativeAttributes","nodeAttrs","nodeAttrName","setResult","translation","nodeTransform","nodePosition","nodeScale","getNodeScale","scalableNode","positioned","offseted","nodeBoundingRect","cleanNodeCache","nodeCache","getNodeData","boundingRect","getNodeShape","geometryShape","isNodeConnection","findNodesAttributes","selectorCache","nodeId","nodesAttrs","mergeIds","unique","prevNodeAttrs","selectedLength","sortIndex","clientX","clientY","fromPoint","hasPointerCapture","pointerId","elementFromPoint","nodeData","processedAttrs","bboxCache","relativeItems","relativeRefItems","roAttrs","roAttributes","nodesAllAttrs","refNode","nodeAllAttrs","refSelector","processedAttributes","allAttributes","itemIndex","refNodeId","getCommonAncestorNode","mergeProcessedAttributes","roProcessedAttrs","onMount","isInitialMount","mountTools","onDetach","unmountTools","removeTools","removeHighlighters","_toolsView","hasTools","toolsView","getName","addTools","configure","relatedView","onToolEvent","updateTools","hideTools","hide","showTools","show","updateHighlighters","transformHighlighters","preventDefaultInteraction","defaultInteractionPrevented","isDefaultInteractionPrevented","pointerdblclick","pointerclick","contextmenu","pointerdown","mouseover","mouseout","mouseenter","mouseleave","mousewheel","onevent","onmagnet","magnetpointerdblclick","magnetcontextmenu","checkMouseleave","isAsync","sourceView","dumpView","checkViewVisibility","targetView","setInteractivity","isIntersecting","geometryData","isEnclosedIn","geometryRect","isInArea","isAtPoint","Flags","TOOLS","Highlighting","addPresentationAttributes","node1","node2","localUse","UPDATE","TRANSLATE","RESIZE","PORTS","ROTATE","RENDER","DragActions","ElementView","renderingOnlyAttrs","modelAttrs","rotatableSelector","scalableSelector","renderMarkup","renderJSONMarkup","renderStringMarkup","updateTransformation","sgResize","rgTranslate","rgRotate","getTranslateString","rotateString","getRotateString","scalable","scalableBBox","rotatable","rotatableBBox","prepareEmbedding","initialZIndices","connectedLinks","maxZ","initialParentId","processEmbedding","findParentBy","frontParentOnly","validateEmbedding","candidates","newCandidateView","prevCandidateView","candidateEmbedView","candidate","clearEmbedding","candidateView","finalizeEmbedding","validateUnembedding","_disallowUnembed","initialPosition","getTargetParentView","getDelegatedView","proxyPortNode","notifyPointermove","notifyPointerup","dragStart","action","delegatedView","magnetpointermove","dragMagnet","drag","preventPointerEvents","magnetpointerup","dragMagnetEnd","dragEnd","magnetpointerclick","magnetpointerdown","dragMagnetStart","pointerOffset","getRestrictedArea","isPropagationAlreadyStopped","validateMagnet","grid","elX","elY","embeddingMode","clickThreshold","oneSide","coordinate","sourceBBox","targetBBox","sourcePoint","targetPoint","opposites","N","S","E","W","radians","freeJoin","getBBoxSize","getBearing","to","getPointBox","getPaddingBox","elementPadding","getSourceBBox","getTargetBBox","vertexVertex","d1","d2","opposite","elementVertex","fromBBox","vertexElement","toBBox","route","freePoints","freeBearingPoints","elementElement","fromBorder","toBorder","startRoute","endRoute","insideElement","boundary","reversed","orthogonal","sourceAnchor","getSourceAnchor","targetAnchor","getTargetAnchor","orthogonalVertices","isOrthogonal","isOrthogonalLoop","maximumLoops","maxAllowedDirectionChange","perpendicular","excludeEnds","excludeTypes","startDirections","endDirections","directionMap","cost","directions","offsetX","offsetY","penalties","paddingBox","isPointObstacle","fallbackRouter","fallbackRoute","draggingRoute","ObstacleMap","mapGridSize","SortedSet","OPEN","CLOSE","getDirectionAngle","numDirections","angleTheta","diffX","diffY","distanceX","distanceY","fixAngleEnd","normalizedAngle","getDirectionChange","angle1","angle2","directionChange","getGridDimension","absDiff","numSteps","align","snappedX","snappedY","getKey","normalizePoint","reconstructRoute","parents","tailPoint","prevDiff","currentKey","leadPoint","estimateCost","endPoints","getRectPoints","anchor","directionList","anchorCenterVector","dirList","rectPoints","farthestIntersectionDistance","endpoint","farthestIntersection","currentIntersection","findRoute","startPoints","openSet","costs","previousRouteDirectionAngle","previousDirectionAngle","isPathBeginning","gridOffsetX","gridOffsetY","getGridOffsets","endPointsKeys","endPoint","loopsRemaining","currentParent","currentCost","isRouteBeginning","isStart","samePoints","directionAngle","neighborPoint","neighborKey","isClose","costFromStart","isOpen","build","excludedEnds","excludedAncestors","isExcludedType","isExcludedEnd","excluded","isExcludedAncestor","gridKey","isPointAccessible","mapKey","obstacle","manhattan","point1","point2","resolveOptions","oldVertices","newVertices","partialRoute","dragFrom","dragTo","diagonalCost","ceil","intersectionPoint","directionFrom","metro","Directions","AUTO","ANCHOR_SIDE","MAGNET_SIDE","DEFINED_DIRECTIONS","OPPOSITE_DIRECTIONS","VERTICAL_DIRECTIONS","ANGLE_DIRECTION_MAP","getSegmentAngle","simplifyPoints","resolveSides","sx0","sy0","sourceDirection","tx0","ty0","targetDirection","sourceSide","targetSide","getDirectionForLinkConnection","sourceLinkAnchorBBox","targetLinkAnchorBBox","linkOrigin","connectionPoint","getTangentAtLength","getClosestPointLength","roundedAngle","pointDataFromAnchor","isPort","fallBackAnchor","getOutsidePoint","pointData","outsidePoint","createLoop","loopSegment","connectionSegmentAngle","loopRoute","secondCreatedPoint","loopEndSegment","continueDirection","moveAndExpandBBox","routeBetweenPoints","sourceWidth","sourceHeight","sourceMargin","targetWidth","targetHeight","targetMargin","targetInSourceBBox","tx1","ty1","smx0","smx1","smy0","smy1","tmx0","tmx1","tmy0","tmy1","sourceOutsidePoint","targetOutsidePoint","sox","soy","tox","toy","middleOfVerticalSides","middleOfHorizontalSides","inflatedSourceBBox","inflatedTargetBBox","sourceForDistance","targetForDistance","leftD","rightD","leftBoundary","rightBoundary","aboveShape","belowShape","boundaryDefiningShape","getHorizontalDistance","topD","bottomD","topBoundary","bottomBoundary","leftShape","rightShape","getVerticalDistance","isPointInsideSource","isPointInsideTarget","middleOfAnchors","isUpwardsShorter","isLeftShorter","anchorMiddleX","anchorMiddleY","getLoopCoordinates","isHorizontal","rightAngleRouter","useVertices","isSourcePort","isTargetPort","resultVertices","verticesData","pointDataFromVertex","firstVertex","resolvedSourceDirection","isVertexInside","firstPointOverlap","alignsVertically","alignsHorizontally","isVerticalAndAligns","isHorizontalAndAligns","firstSegment","isVertexOnSegment","isVertexAlignedAndInside","accessDirection","nextInLine","resolveForTopSourceSide","resolveForRightSourceSide","resolveForBottomSourceSide","resolveForLeftSourceSide","resolveInitialDirection","connectionDirection","simplifiedRoute","accessSegment","toDirection","fromDirection","resolveDirection","lastVertex","resolvedTargetDirection","simplified","simplifiedSegment","simplifiedSegmentAngle","definedDirection","lastPointOverlap","lastSegmentRoute","roundedLastSegmentAngle","lastSegmentDirection","isDirectionVertical","isToAbove","isToLeft","rightAngle","CornerTypes","POINT","CUBIC","LINE","GAP","DEFINED_CORNER_TYPES","CORNER_RADIUS","straight","routePoints","cornerType","cornerRadius","cornerPreserveAspectRatio","nextDistance","routePointsLength","curr","prevDistance","startMove","endMove","cornerStart","cornerEnd","JUMP_TYPES","IGNORED_CONNECTORS","sortPointsAscending","swap","createLines","resultLines","nextPoint","sortPoints","buildPath","jumpSize","jumpType","isJump","xAxisRotate","halfLine","centerLine","xOffset","yOffset","nextLine","roundedStart","roundedEnd","buildRoundedSegment","jumpover","jumpOverLinkView","updateList","_jumpOverUpdateList","updateFlag","CONNECTOR","updateJumpOver","setupUpdating","jump","ignoreConnectors","allLinks","thisModel","thisIndex","defaultConnector","linkViews","thisLines","linkLines","jumpingLines","thisLine","linkLinesToTest","overlapIndex","x4","y4","overlapExists","lineIntersections","crossCheckLines","crossCheckLine","findLineIntersections","skip","jumpStart","jumpEnd","jumpLine","createJumps","rounded","smooth","controlPointX","controlPointY","HORIZONTAL","VERTICAL","CLOSEST_POINT","OUTWARDS","TangentDirections","UP","DOWN","Boolean","coeff","distanceCoefficient","angleTangentCoefficient","tau","tension","sourceTangent","targetTangent","completeRoute","getAutoSourceDirection","getClosestPointSourceDirection","getOutwardsSourceDirection","unrotatedBBox","getHorizontalSourceDirection","getVerticalSourceDirection","getSourceTangentDirection","tangentLength","angleBetweenVectors","updatedLength","getAutoTargetDirection","getClosestPointTargetDirection","getOutwardsTargetDirection","getHorizontalTargetDirection","getVerticalTargetDirection","getTargetTangentDirection","catmullRomCurves","distances","tangents","tpPrev","tpNext","v1","v2","vAngle","rot","vectorDeterminant","determinant","pointsDeterminant","rotateVector","scaleFactor1","scaleFactor2","createCatmullRomCurves","bezierCurves","bcp1","bcp2","catmullRomToBezier","sourceCenter","targetCenter","acos","LABELS","SOURCE","TARGET","LinkView","_labelCache","_labelSelectors","_V","_dragData","decimalsRounding","EPSILON","updateEndProperties","isViewMounted","__fixSafariBug268376","updateLabels","onLabelsChange","updateAll","updateConnector","updatePath","updateDOM","updateLabelPositions","requestConnectionUpdate","isLabelsRenderRequired","previousLabels","pathLength","_labels","renderLabels","unmountLabels","_getLabelMarkup","_getLabelStringMarkup","_normalizeLabelMarkup","vNode","DocumentFragment","hasChildNodes","vLabels","labelCache","labelsCount","labelsLayer","builtinDefaultLabel","builtinDefaultLabelMarkup","defaultMarkup","mountLabels","findLabelNodes","labelIndex","labelRoot","_mergeLabelAttrs","hasCustomMarkup","labelAttrs","defaultLabelAttrs","builtinDefaultLabelAttrs","_mergeLabelSize","defaultLabelSize","labelLayer","canLabelMove","defaultLabelMarkup","removeRedundantLinearVertices","numRoutePoints","polylinePoints","numPolylinePoints","getEndView","getEndAnchor","getEndConnectionPoint","getEndMagnet","sourceMagnet","updateRoute","anchors","findAnchors","connectionPoints","findConnectionPoints","findPath","findAnchorsOrdered","firstEndType","firstRef","secondEndType","secondRef","firstAnchor","secondAnchor","firstAnchorRef","secondAnchorRef","firstDef","secondDef","firstView","secondView","firstMagnet","secondMagnet","getAnchor","priority","firstWaypoint","lastWaypoint","sourceDef","targetDef","paperOptions","sourceConnectionPointDef","defaultConnectionPoint","sourceLine","getConnectionPoint","targetConnectionPointDef","targetLine","anchorDef","anchorFn","isConnection","defaultLinkAnchor","defaultAnchor","anchorName","connectionPointDef","connectionPointFn","connectionPointName","connectionPointNamespace","_getDefaultLabelPositionProperty","builtinDefaultLabelPosition","defaultLabelPosition","_normalizeLabelPosition","_mergeLabelPositionProperty","normalizedLabelPosition","normalizedDefaultLabelPosition","_getLabelTransformationMatrix","_cleanLabelMatrices","endViewProperty","endId","updateEndMagnet","endModel","getModelById","endView","endMagnetProperty","connectedMagnet","_getLabelPositionProperty","_getLabelPositionAngle","_getLabelPositionArgs","_getDefaultLabelPositionArgs","_mergeLabelPositionArgs","labelPositionArgs","defaultLabelPositionArgs","addLabel","localX","localY","localAngle","positionArgs","getLabelPosition","addVertex","isPointProvided","getVertexIndex","sendToken","token","isReversed","animationAttributes","dur","repeatCount","calcMode","keyPoints","keyTimes","vToken","onAnimationEnd","routerNamespace","defaultRouter","routerFn","connectorNamespace","connectorFn","getPointAtRatio","getTangentAtRatio","getClosestPoint","getClosestPointRatio","labelOffset","isDistanceRelative","absoluteDistance","isDistanceAbsoluteReverse","reverseDistance","isOffsetAbsolute","absoluteOffset","labelPoint","labelDistance","labelOffsetDiff","labelAngle","labelOffsetCoordinates","positionOffset","isKeepGradient","keepGradient","isEnsureLegibility","ensureLegibility","getLabelCoordinates","vertexLength","currentVertex","dragData","dragLabel","dragArrowhead","dragLabelEnd","dragArrowheadEnd","onlabel","dragLabelStart","labelIdx","initialLabelPosition","positionAngle","delegateDragEvents","dragArrowheadStart","arrowheadType","ignoreBackwardsCompatibility","snapLabels","snapLinks","_snapArrowhead","snapLinksSelf","_snapArrowheadSelf","_connectArrowhead","_snapArrowheadEnd","_connectArrowheadEnd","linkAllowed","_finishEmbedding","_notifyConnectEvent","_disallow","_afterArrowheadMove","arrowhead","initialEnd","currentEnd","initialMagnet","magnetUnderPointer","_snapToPoints","snapPoint","closestPointX","closestDistanceX","closestPointY","closestDistanceY","distX","distY","localToClientPoint","isSnapped","viewsInArea","findElementViewsInArea","findInAreaOptions","prevClosestView","closestView","prevClosestMagnet","closestMagnet","prevMagnetProxy","magnetProxy","MAX_VALUE","pointer","validateConnection","validateConnectionArgs","newClosestMagnet","snapping","prevEnd","prevX","prevY","eventTarget","viewUnderPointer","_beforeArrowheadMove","markAvailable","_markAvailableMagnets","_unmarkAvailableMagnets","_createValidateConnectionArgs","oppositeArrowhead","isMagnetAvailable","marked","magnets","availableMagnets","markedMagnets","markedKeys","LayersNames","GRID","CELLS","BACK","FRONT","PaperLayer","pivotNodes","insertPivot","insertNode","pivotNode","createComment","neighborZ","currentZ","neighborPivot","removePivots","useFirstSubpath","getPathData","secondSubpathIndex","highlightConnection","highlightNode","highlightMatrix","paddingMatrix","nonScalingStroke","MASK_CLIP","mask","maskClip","VISIBLE","INVISIBLE","MASK_ROOT_ATTRIBUTE_BLACKLIST","MASK_CHILD_ATTRIBUTE_BLACKLIST","MASK_REPLACE_TAGS","MASK_REMOVE_TAGS","transformMaskChild","childEl","childTagName","originalChild","originalNode","transformMaskRoot","rootEl","getMaskShape","maskRoot","descendants","descendant","forEachDescendant","maskChild","getMaskId","getMask","hasNodeFill","magnetStrokeWidth","minStrokeWidth","maxStrokeWidth","maskEl","removeMask","maskNode","addMask","highlighterBBox","alphaValue","ROW","COLUMN","UPDATE_ATTRIBUTES","_prevItems","elementView","gap","normalizedSize","isRowDirection","itemWidth","prevItems","comparison","unchanged","prevEls","itemsEls","prevEl","itemEl","createListItem","itemsCount","listSize","connectionRatio","_magnet","_refPoint","connectionLength","resolveRef","Element","refPoint","refView","getPointAtLink","fixedAt","parsedValue","connectionPerpendicular","OFFSET","verticalLine","horizontalLine","verticalIntersections","horizontalIntersections","fallbackAt","connectionClosest","_opt","offsetPoint","bboxIntersection","BNDR_SUBDIVISIONS","BNDR_SHAPE_BBOX","_view","alignOffset","alignLine","rectangle","bboxWORotation","lineWORotation","nextElementSibling","findShapeNode","localShape","targetMatrix","localMatrix","localLine","localRef","insideout","extrapolate","sticky","cpOffset","bboxWrapper","dxPercentage","dyPercentage","midSide","modelCenter","GridLayer","_gridCache","_gridSettings","updateGrid","setGrid","drawGrid","getGridSettings","renderGrid","gridSettings","_resolveDrawGridOption","removeGrid","drawGridSize","_getGridRefs","gridLayerSetting","_getPatternId","vPattern","exist","patternUnits","vSvg","patterns","getArea","patternId","defsVEl","svgVEl","patternVEl","rectVEl","sortingTypes","NONE","APPROX","EXACT","UPDATE_BATCH_SIZE","MIN_PRIORITY","defaultHighlighting","defaultLayers","Paper","highlighting","preventContextMenu","preventDefaultBlankAction","preventDefaultViewAction","restrictTranslate","defaultLink","ctor","_evt","cellViewS","_magnetS","cellViewT","_magnetT","_linkView","childView","parentView","labelMove","allowLink","moveThreshold","sorting","frozen","autoFreeze","onViewUpdate","mounting","isolate","requestConnectedLinksUpdate","onViewPostponed","forcePostponedViewUpdate","beforeRender","afterRender","viewport","cellViewNamespace","highlighterNamespace","anchorNamespace","linkAnchorNamespace","overflow","documentEvents","tools","layers","_viewportMatrix","_viewportTransformString","_updates","_layers","SORT_DELAYING_BATCHES","UPDATE_DELAYING_BATCHES","FORM_CONTROL_TAG_NAMES","GUARDED_TAG_NAMES","MIN_SCALE","DEFAULT_FIND_BUFFER","cloneOptions","_setDimensions","_mw_evt_buffer","deltas","resetViews","isFrozen","updateViewsAsync","_resetUpdates","priorities","unmountedCids","mountedCids","unmounted","mounted","keyFrozen","freezeKey","idle","onCellAdded","onCellRemoved","onCellChange","onGraphReset","onGraphSort","onGraphBatchStop","onCellHighlight","onCellUnhighlight","renderView","freeze","unfreeze","resetLayers","sortViews","updateDelayingBatches","updateViews","sortDelayingBatches","inset","hasLayerView","getLayerNode","renderLayers","addStylesheet","drawBackground","createLayer","gridPatterns","removeLayers","sorted","layerView","cellsLayerView","toolsLayerView","labelsLayerView","webkitUserSelect","userSelect","_background","updateBackgroundImage","scaleUniformAtPoint","transformString","getCTM","currentTransformString","ctmString","clientMatrix","flagLabels","nextPriority","scheduleViewUpdate","dumpOptions","sourceFlag","targetFlag","stats","notifyAfterRender","updates","priorityUpdates","prevPriorityUpdates","currentType","viewUpdateFn","dumpViewUpdate","registerMountedView","shouldNotify","notifyBeforeRender","leftover","updateView","updated","removeView","isInitialInsert","insertView","requireView","registerUnmountedView","dumpViews","passingOpt","checkViewport","batchStats","updateCount","batchCount","updateViewsBatch","hasScheduledUpdates","priorityIndexes","_key","processed","mountBatchSize","unmountBatchSize","checkStats","unmountCount","mountCount","total","progressFn","beforeFn","afterFn","batchSize","postponeCount","maxPriority","viewportFn","postponeViewFn","main","currentFlag","isDetached","detachView","leftoverFlag","postponed","getUnmountedViews","unmountedViews","getMountedViews","mountedViews","checkUnmountedViews","checkMountedViews","visible","isUnmounted","unmountedCount","isExactSorting","removeViews","getComputedSize","setDimensions","currentWidth","currentHeight","computedSize","fitToContent","gridWidth","gridHeight","getFitToContentArea","minWidth","minHeight","maxWidth","maxHeight","newOrigin","allowNewOrigin","contentArea","getContentArea","calcWidth","calcHeight","allowNegativeBottomRight","transformToFitContent","contentBBox","contentLocalOrigin","getContentBBox","paperToLocalPoint","scaleGrid","minScale","maxScale","verticalAlign","horizontalAlign","minScaleX","maxScaleX","minScaleY","maxScaleY","fittingBBox","currentTranslate","newSx","newSy","scaleDiff","newOx","newOy","scaleContentToFit","paperToLocalRect","createViewForModel","optionalViewClass","defaultViewClass","namespaceViewClass","onImageDragStart","sortViewsExact","cellNodes","placements","sortElement","cellA","cellB","zA","zB","sortElements","findViewsFromPoint","findViewsInArea","plainArea","_filterViewsInArea","extArea","findOpt","findLinkViewsInArea","findCellViewsInArea","findElementViewsAtPoint","plainPoint","_filterViewsAtPoint","findLinkViewsAtPoint","findCellViewsAtPoint","_findInExtendedArea","findCellsFn","findCells","dispatchToolsEvent","clientToLocalPoint","localToPaperPoint","localPoint","localRect","paperPoint","paperRect","localToClientRect","clientPoint","clientToLocalRect","clientRect","localToPagePoint","pageOffset","localToPageRect","pageToLocalPoint","pageToLocalRect","clientOffset","resolveHighlighter","highlighter","highlighterDef","magnetEl","highlighterDescriptor","contextMenuFired","contextMenuTrigger","isContextMenu","isTargetFormNode","eventEvt","customEventTrigger","magnetNode","magnetEvt","contextmenuEvt","normalizedEvt","_processMouseWheelEvtBuf","wait","lastArgs","lastThis","maxWait","timerId","lastCallTime","lastInvokeTime","leading","maxing","useRaf","invokeFunc","time","thisArg","startTimer","pendingFunc","shouldInvoke","timeSinceLastCall","timerExpired","trailingEdge","timeSinceLastInvoke","timeWaiting","remainingWait","debounced","isInvoking","leadingEdge","cancel","cancelTimer","flush","pending","debounce","deltaY","deltaX","sX","sY","pX","pY","detail","wheelDelta","wheelDeltaY","wheelDeltaX","HORIZONTAL_AXIS","deltaMode","shiftKey","spinX","spinY","normalizeWheel","pinchHandlers","ctrlKey","eventNode","magnetEvent","magnetContextMenuFired","magnetContextMenuTrigger","getPointerArgs","guarded","setGridSize","backgroundPosition","backgroundSize","currentScale","drawBackgroundImage","img","HTMLImageElement","backgroundImage","backgroundRepeat","repeat","backgroundOpacity","backgroundQuality","quality","backgroundPattern","backgroundPatterns","canvas","HTMLCanvasElement","toDataURL","updateBackgroundColor","onload","isDefined","defId","filterId","filterSVGString","filterAttrs","filterUnits","gradient","stops","stopVEls","gradientVEl","markerUnits","markerVEl","orient","markerContentVEl","markupVEl","markerAttrs","markupValue","Layers","flipXy","imgWidth","imgHeight","getContext","drawImage","setTransform","flipX","flipY","watermark","watermarkAngle","stepX","stepY","thickness","fixedDot","mesh","doubleMesh","ToolView","_visible","_visibleExplicit","simulateRelatedView","updateVisibility","computeVisibility","isExplicitlyVisible","visibility","focus","focusOpacity","focusTool","blurTool","VertexHandle","mousedown","touchstart","dblclick","mousemove","touchmove","mouseup","touchend","touchcancel","onPointerDown","onPointerMove","onDoubleClick","onPointerUp","Vertices","handleClass","snapRadius","redundancyRemoval","vertexAdding","handles","interactiveLinkNode","linkEvents","delegateLinkEvents","resetHandles","renderHandles","undelegateLinkEvents","updateHandles","startHandleListening","vertexRemoving","vertexMoving","onHandleWillChange","onHandleChanging","onHandleChanged","onHandleRemove","getNeighborPoints","_handle","normalizedEvent","snapVertex","vertexAdded","onPathPointerDown","onLinkPointerDown","abs2rel","pin","relative","pinnedLinkEnd","pinnedElementEnd","totalLength","pinRelative","SegmentHandle","viewPoint","Segments","segmentLengthThreshold","snapHandle","nextVertex","renderHandle","updateHandle","onHandleChangeStart","onHandleChangeEnd","shiftHandleIndexes","resetAnchor","relatedModel","handleIndex","vertexPoints","indexOffset","originalVertices","isSingleVertex","origVIndex","additionalOffset","firstHandleShifted","nextVIndex","changeSourceAnchor","deleteSourceAnchor","sourceAnchorPosition","sourceAnchorDef","changeTargetAnchor","deleteTargetAnchor","targetAnchorPosition","targetAnchorDef","segmentLine","ToolsView","isRendered","wasRendered","ensureToolRendered","focusedTool","blurredTool","ShapeType","TransactionType","FlowType","Jurisdiction","PaymentType","DefaultValues","PrimaryColor","SecondaryColor","EmphasizedColor","ThirdPartyColor","linkTypeColors","Node","entityIds","isNewEntity","setColor","functions","setColorByJurisdiction","jurisdiction","US","NonUS","Mixed","setLabel","splitLabel","setSecondaryLabel","setFunctionIcon","iconName","iconPath","response","fetch","ok","status","svgContent","encodedSvg","encodeURIComponent","functionIcon","addFunctionIcons","debug","ToolMode","toolModesWithTargetSelection","AddFlow","AddTransaction","MoveExpense","MoveRevenue","MoveFunction","FlowEditor","getGraphJson","setGraphJson","graphJson","closeMenus","newMarkup","markupElement","svgPath","MiscellaneousLink","linkColor","matchingLink","lc","setRectangleMode","activeTool","DrawRectangle","drawRectangle","startRectangle","tempRectangleElement","DrawnRectangle","addTransaction","transactionType","ServiceFee","futureStateMode","addPaymentByDialog","Service","Royalty","IPLicense","IPTransfer","addIPTransferByDialog","addFlow","flowType","stepId","newLink","Physical","Legal","Payment","Agreement","Miscellaneous","sourceEntityIds","targetEntityIds","dotNetHelper","invokeMethod","invokeMethodAsync","addFlowBetweenEntities","sourceEntityId","targetEntityId","sourceNode","targetNode","removeFlowBetweenEntities","linkType","removeFlowByStepId","linksToRemove","toggleFlowElementVisibility","openMenu","menu","EmptyElement","EmptyThirdParty","changeElementPrimaryText","subMenu","beginAddTransaction","beginMoveRevenue","beginMoveExpense","EntityGroup","functionName","beginMoveFunction","beginAddFlow","addPnlByDialog","changeElementColor","changeElementSecondaryText","confirmDeleteElement","changeLinkText","confirmDeleteRelationship","menuOption","menuText","arrow","openSubMenu","divBottom","offsetTop","windowHeight","distanceToBottom","closeSubMenus","overflowY","divRight","offsetLeft","getElementsByClassName","selectedElement","transactionTypeToCreate","flowTypeToCreate","functionNameToMove","paymentType","sourceLabel","targetLabel","dialogResult","entityId","addEntityNode","entityIdsToExclude","results","container","newElement","CreateEntityNode","addThirdPartyNode","updateEntityFunctions","functionNames","entityNode","log","addEntityByEntityNodeOptions","overlappingPositionElement","replaceEntityNodeByEntityId","removeEntityNodeByEntityId","addFunctionToEntityNode","removeFunctionFromEntityNode","updatedFunctions","onMoveFunctionStepDelete","resetToolMode","oldText","newText","changeFunctionIcon","encodedSvgContent","refX","refY","oldColor","shapeType","CorporationCFC","BranchThirdParty","Partnership","HybridEntity","ReverseHybridEntity","ReverseHybrid","DRE","Disregarded","Group","hoveredElementClickDisabled","panStartPosition","linkMove","verticesTool","segmentsTool","pageX","pageY","oldscale","newscale","dispose","createFlowEditor","FlowPreview","createFlowPreview","class","fontFamily","fontWeight","label2","body2","PhysicalLink","LegalLink","dashed","strokeDasharray","PaymentLink","ServiceLink","IPTransferLink","IPLicenseLink","AgreementLink"],"sourceRoot":""}