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IAAI+C,SAAS/C,GAASA,GAE3FigB,GAAMjE,eAAiBgE,GAEvBC,GAAMW,QAAUX,GAEhBY,EAAO7vD,QAAUivD,E","sources":["webpack://RPGDialogue/./node_modules/plotboilerplate/src/cjs/utils/algorithms/getContrastColor.js","webpack://RPGDialogue/./node_modules/plotboilerplate/src/cjs/utils/datastructures/Color.js","webpack://RPGDialogue/./node_modules/plotboilerplate/src/cjs/utils/io/FileDrop.js","webpack://RPGDialogue/./node_modules/plotboilerplate/src/esm/UIDGenerator.js","webpack://RPGDialogue/./node_modules/plotboilerplate/src/esm/VertexAttr.js","webpack://RPGDialogue/./node_modules/plotboilerplate/src/esm/VertexListeners.js","webpack://RPGDialogue/./node_modules/plotboilerplate/src/esm/Vertex.js","webpack://RPGDialogue/./node_modules/plotboilerplate/src/esm/Polygon.js","webpack://RPGDialogue/./node_modules/plotboilerplate/src/esm/Bounds.js","webpack://RPGDialogue/./node_modules/plotboilerplate/src/esm/VertTuple.js","webpack://RPGDialogue/./node_modules/plotboilerplate/src/esm/Vector.js","webpack://RPGDialogue/./node_modules/plotboilerplate/src/esm/CubicBezierCurve.js","webpack://RPGDialogue/./node_modules/plotboilerplate/src/esm/BezierPath.js","webpack://RPGDialogue/./node_modules/plotboilerplate/src/esm/Line.js","webpack://RPGDialogue/./node_modules/plotboilerplate/src/esm/Circle.js","webpack://RPGDialogue/./node_modules/plotboilerplate/src/esm/CircleSector.js","webpack://RPGDialogue/./node_modules/plotboilerplate/src/esm/drawutilssvg.js","webpack://RPGDialogue/./node_modules/plotboilerplate/src/esm/draw.js","webpack://RPGDialogue/./node_modules/plotboilerplate/src/esm/drawgl.js","webpack://RPGDialogue/./node_modules/plotboilerplate/src/esm/Triangle.js","webpack://RPGDialogue/./node_modules/plotboilerplate/src/esm/geomutils.js","webpack://RPGDialogue/./node_modules/plotboilerplate/src/esm/Grid.js","webpack://RPGDialogue/./node_modules/plotboilerplate/src/esm/KeyHandler.js","webpack://RPGDialogue/./node_modules/plotboilerplate/src/esm/MouseHandler.js","webpack://RPGDialogue/./node_modules/plotboilerplate/src/esm/PBImage.js","webpack://RPGDialogue/./node_modules/plotboilerplate/src/esm/PBText.js","webpack://RPGDialogue/./node_modules/alloyfinger-typescript/src/esm/alloy_finger.js","webpack://RPGDialogue/./node_modules/alloyfinger-typescript/src/esm/index.js","webpack://RPGDialogue/./node_modules/plotboilerplate/src/esm/VEllipse.js","webpack://RPGDialogue/./node_modules/plotboilerplate/src/esm/VEllipseSector.js","webpack://RPGDialogue/./node_modules/plotboilerplate/src/esm/PlotBoilerplate.js","webpack://RPGDialogue/./node_modules/axios/dist/browser/axios.cjs"],"sourcesContent":["\"use strict\";\n/**\n * @author Original from Martin Sojka. Ported to TypesScript by Ikaros Kappler\n * @date   2020-11-10\n */\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.getContrastColor = void 0;\nvar Color_1 = require(\"../datastructures/Color\");\nvar BLACK = Color_1.Color.makeRGB(0, 0, 0);\nvar WHITE = Color_1.Color.makeRGB(255, 255, 255);\n/**\n * Contrast color algorithm by Martin Sojka's.\n * Found at\n *    https://gamedev.stackexchange.com/questions/38536/given-a-rgb-color-x-how-to-find-the-most-contrasting-color-y/38542#38542\n *\n * @requires Color\n */\nvar getContrastColor = function (color) {\n    // r,g,b in [0..1]\n    var gamma = 2.2;\n    var L = 0.2126 * Math.pow(color.r, gamma) + 0.7152 * Math.pow(color.g, gamma) + 0.0722 * Math.pow(color.b, gamma);\n    var use_black = L > Math.pow(0.5, gamma);\n    return use_black ? BLACK : WHITE;\n};\nexports.getContrastColor = getContrastColor;\n//# sourceMappingURL=getContrastColor.js.map","\"use strict\";\n/**\n * @author Extended, bugfixed and ported to TypeScript by Ikaros Kappler.\n * @modified 2018-xx-xx Added a clone() function.\n * @modified 2018-xx-xx Allowing leading '#' in the makeHEX() function.\n * @modified 2018-11-28 Fixed the checkHEX() function to accept 000000.\n * @modified 2019-11-18 Added a generic parse(string) function that detects the format.\n * @modified 2020-01-09 Fixed a bug in the parse(string) function. Hex colors with only three elements were considered faulty.\n * @modified 2020-10-23 Ported to Typescript.\n * @modified 2021-02-08 Fixed a lot of es2015 compatibility issues.\n * @modified 2021-02-08 Added basic tsdoc/jsdoc comments.\n * @modified 2021-11-05 Fixing the regex to parse rgba-strings.\n * @modified 2021-11-05 Added return value `this` to all modifier functions (for chaining).\n * @modified 2021-11-07 Changed the behavior of `darken` and `lighten`: the passed value is handled relative now which makes values much easier predictable and makes the change feel more 'natural'.\n * @modified 2021-11-07 Did the same with `saturate` and `desaturate`.\n * @modified 2021-11-07 Did the same with the `fadein` and `fadeout` functions.\n * @modified 2021-11-07 Added setRed, setGreen, setBlue, setHue, setSaturation, setLiminance functions.\n * @modified 2022-05-11 Modified the `clone` function by just copying the numeric calues, not re-calculating the whole color.\n * @modified 2022-05-11 Fixed the `interpolate` function.\n * @modified 2023-01-23 Added `Color.set(Color)` function to set all values (r,g,b,h,s,l,a) simultanoeusly.\n * @version 0.0.12\n **/\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.Color = void 0;\n/**\n * @classdesc A color class, inspired by neolitec's Javascript class.\n *    Original found at\n *      https://gist.github.com/neolitec/1344610\n *    Thanks to neolitec\n */\nvar Color = /** @class */ (function () {\n    /**\n     * Construct a new color with `r=0 g=0 b=0`.\n     *\n     * Consider using the `makeHex`, `makeRGB` or `makeHSL` functions.\n     *\n     * @constructor\n     * @instance\n     * @memberof Color\n     */\n    function Color() {\n        this.r = this.g = this.b = 0;\n        this.h = this.s = this.l = 0;\n        this.a = 1;\n    }\n    // --- RGB ----------------------------------\n    /**\n     * Get this color as a CSS `rgb` string.\n     *\n     * Consult this for details: https://developer.mozilla.org/en-US/docs/Web/CSS/color_value\n     *\n     * @method cssRGB\n     * @instance\n     * @memberof Color\n     * @return {string} This color as a CSS rgb string.\n     */\n    Color.prototype.cssRGB = function () {\n        return \"rgb(\" + Math.round(255 * this.r) + \",\" + Math.round(255 * this.g) + \",\" + Math.round(255 * this.b) + \")\";\n    };\n    /**\n     * Get this color as a CSS `rgba` string.\n     *\n     * Consult this for details: https://developer.mozilla.org/en-US/docs/Web/CSS/color_value\n     *\n     * @method cssRGBA\n     * @instance\n     * @memberof Color\n     * @return {string} This color as a CSS rgba string.\n     */\n    Color.prototype.cssRGBA = function () {\n        return \"rgba(\" + Math.round(255 * this.r) + \",\" + Math.round(255 * this.g) + \",\" + Math.round(255 * this.b) + \",\" + this.a + \")\";\n    };\n    /**\n     * Get the red component of this RGB(A)color. This method just returns the `r` color attribute.\n     *\n     * @method red\n     * @instance\n     * @memberof Color\n     * @return {number} A value between 0.0 and 1.0.\n     */\n    Color.prototype.red = function () {\n        return this.r;\n    };\n    /**\n     * Get the green component of this RGB(A) color. This method just returns the `g` color attribute.\n     *\n     * @method green\n     * @instance\n     * @memberof Color\n     * @return {number} A value between 0.0 and 1.0.\n     */\n    Color.prototype.green = function () {\n        return this.g;\n    };\n    /**\n     * Get the blue component of this RGB(A) color. This method just returns the `b` color attribute.\n     *\n     * @method blue\n     * @instance\n     * @memberof Color\n     * @return {number} A value between 0.0 and 1.0.\n     */\n    Color.prototype.blue = function () {\n        return this.b;\n    };\n    Color.prototype.set = function (color) {\n        this.r = color.r;\n        this.g = color.g;\n        this.b = color.b;\n        this.a = color.a;\n        this.h = color.h;\n        this.s = color.s;\n        this.l = color.l;\n        return this;\n    };\n    Color.prototype.setRed = function (r) {\n        this.r = r;\n        return this;\n    };\n    Color.prototype.setBlue = function (b) {\n        this.b = b;\n        Color.Converter.RGBToHSL(this);\n        return this;\n    };\n    Color.prototype.setAlpha = function (a) {\n        this.a = a;\n        Color.Converter.RGBToHSL(this);\n        return this;\n    };\n    Color.prototype.setGreen = function (g) {\n        this.g = g;\n        Color.Converter.RGBToHSL(this);\n        return this;\n    };\n    Color.prototype.setHue = function (h) {\n        this.h = h;\n        Color.Converter.HSLToRGB(this);\n        return this;\n    };\n    Color.prototype.setSaturation = function (s) {\n        this.s = s;\n        Color.Converter.HSLToRGB(this);\n        return this;\n    };\n    Color.prototype.setLuminance = function (l) {\n        this.l = l;\n        Color.Converter.HSLToRGB(this);\n        return this;\n    };\n    // --- HSL ----------------------------------\n    /**\n     * Get this color as a CSS `hsl` string.\n     *\n     * @method cssHSL\n     * @instance\n     * @memberof Color\n     * @return {string} This color as a CSS hsl string.\n     */\n    Color.prototype.cssHSL = function () {\n        return \"hsl(\" + Math.round(360 * this.h) + \",\" + Math.round(100 * this.s) + \"%,\" + Math.round(100 * this.l) + \"%)\";\n    };\n    /**\n     * Get this color as a CSS `hsla` string.\n     *\n     * @method cssHSLA\n     * @instance\n     * @memberof Color\n     * @return {string} This color as a CSS hsla string.\n     */\n    Color.prototype.cssHSLA = function () {\n        return (\"hsla(\" +\n            Math.round(360 * this.h) +\n            \",\" +\n            Math.round(100 * this.s) +\n            \"%,\" +\n            Math.round(100 * this.l) +\n            \"%,\" +\n            Math.round(this.a) +\n            \")\");\n    };\n    /**\n     * Get the hue component of this HSL(A) color. This method just returns the `h` color attribute.\n     *\n     * @method hue\n     * @instance\n     * @memberof Color\n     * @return {number} A value between 0.0 and 1.0.\n     */\n    Color.prototype.hue = function () {\n        return this.h;\n    };\n    /**\n     * Get the saturation component of this HSL(A) color. This method just returns the `s` color attribute.\n     *\n     * @method saturation\n     * @instance\n     * @memberof Color\n     * @return {number} A value between 0.0 and 1.0.\n     */\n    Color.prototype.saturation = function () {\n        return this.s;\n    };\n    /**\n     * Get the lightness component of this HSL(A) color. This method just returns the `l` color attribute.\n     *\n     * @method lightness\n     * @instance\n     * @memberof Color\n     * @return {number} A value between 0.0 and 1.0.\n     */\n    Color.prototype.lightness = function () {\n        return this.l;\n    };\n    // --- HEX ----------------------------------\n    /**\n     * Get this color as a CSS-HEX string (non-alpha): #rrggbb\n     *\n     * @method cssHEX\n     * @instance\n     * @memberof Color\n     * @return {string} This color as a CSS-HEX string.\n     */\n    Color.prototype.cssHEX = function () {\n        return (\"#\" +\n            (255 * this.r < 16 ? \"0\" : \"\") +\n            Math.round(255 * this.r).toString(16) +\n            (255 * this.g < 16 ? \"0\" : \"\") +\n            Math.round(255 * this.g).toString(16) +\n            (255 * this.b < 16 ? \"0\" : \"\") +\n            Math.round(255 * this.b).toString(16));\n    };\n    // --- Transparency ----------------------------------\n    /**\n     * Get the alpha channel (transparency) of this color.\n     *\n     * @method alpha\n     * @instance\n     * @memberof Color\n     * @return {number} A value between 0.0 and 1.0.\n     */\n    Color.prototype.alpha = function () {\n        return this.a;\n    };\n    // --- Modifiers ----------------------------------\n    //   saturate(v: string | number): Color {\n    //     if (\"string\" == typeof v && v.indexOf(\"%\") > -1 && (v = parseInt(v)) != NaN) {\n    //       this.s += v / 100;\n    //     } else if (\"number\" == typeof v) {\n    //       // range 255\n    //       this.s += v / 255;\n    //     } else {\n    //       throw new Error(\"error: bad modifier format (percent or number)\");\n    //     }\n    //     if (this.s > 1) this.s = 1;\n    //     else if (this.s < 0) this.s = 0;\n    //     Color.Converter.HSLToRGB(this);\n    //     return this;\n    //   }\n    Color.prototype.saturate = function (v) {\n        if (\"string\" == typeof v && v.indexOf(\"%\") > -1 && (v = parseInt(v)) != NaN) {\n            this.s += (1 - this.s) * (v / 100);\n        }\n        else if (\"number\" == typeof v) {\n            if (v >= -0.0 && v <= 1.0) {\n                // range 255\n                this.s += (1 - this.s) * v;\n            }\n            else {\n                // range 0-1\n                this.s += (1 - this.s) * (v / 255);\n            }\n        }\n        else {\n            throw new Error(\"error: bad modifier format (percent or number)\");\n        }\n        if (this.s > 1)\n            this.s = 1;\n        else if (this.s < 0)\n            this.s = 0;\n        Color.Converter.HSLToRGB(this);\n        return this;\n    };\n    Color.prototype.desaturate = function (v) {\n        if (\"string\" == typeof v && v.indexOf(\"%\") > -1 && (v = parseInt(v)) != NaN) {\n            this.s -= v / 100;\n        }\n        else if (\"number\" == typeof v) {\n            if (v >= 0.0 && v <= 1.0) {\n                // range 255\n                this.s -= this.s * v;\n            }\n            else {\n                // range 0-1\n                this.s -= this.s * (v / 255);\n            }\n        }\n        else {\n            throw new Error(\"error: bad modifier format (percent or number)\");\n        }\n        if (this.s > 1)\n            this.s = 1;\n        else if (this.s < 0)\n            this.s = 0;\n        Color.Converter.HSLToRGB(this);\n        return this;\n    };\n    //   lighten(v: string | number): Color {\n    //     if (\"string\" == typeof v && v.indexOf(\"%\") > -1 && (v = parseInt(v)) != NaN) {\n    //       this.l += v / 100;\n    //     } else if (\"number\" == typeof v) {\n    //       if (v >= -1.0 && v <= 1.0) {\n    //         // range 0.0...1.0\n    //         this.l += v;\n    //       } else {\n    //         // range 255\n    //         this.l += v / 255;\n    //       }\n    //     } else {\n    //       throw new Error(\"error: bad modifier format (percent or number)\");\n    //     }\n    //     if (this.l > 1) this.l = 1;\n    //     else if (this.l < 0) this.l = 0;\n    //     Color.Converter.HSLToRGB(this);\n    //     return this;\n    //   }\n    Color.prototype.lighten = function (v) {\n        if (\"string\" == typeof v && v.indexOf(\"%\") > -1 && (v = parseInt(v)) != NaN) {\n            this.l += (1 - this.l) * (v / 100);\n        }\n        else if (\"number\" == typeof v) {\n            if (v >= 0.0 && v <= 1.0) {\n                // range 0.0...1.0\n                this.l += (1 - this.l) * v;\n            }\n            else {\n                // range 255\n                this.l += (1 - this.l) * (v / 255);\n            }\n        }\n        else {\n            throw new Error(\"error: bad modifier format (percent or number)\");\n        }\n        if (this.l > 1)\n            this.l = 1;\n        else if (this.l < 0)\n            this.l = 0;\n        Color.Converter.HSLToRGB(this);\n        return this;\n    };\n    Color.prototype.darken = function (v) {\n        if (\"string\" == typeof v && v.indexOf(\"%\") > -1 && (v = parseInt(v)) != NaN) {\n            this.l -= this.l * (v / 100);\n        }\n        else if (\"number\" == typeof v) {\n            if (v >= 0.0 && v <= 1.0) {\n                // range 0.0...1.0\n                this.l -= this.l * v;\n            }\n            else {\n                // range 255\n                this.l -= this.l * (v / 255);\n            }\n        }\n        else {\n            throw new Error(\"error: bad modifier format (percent or number)\");\n        }\n        if (this.l > 1)\n            this.l = 1;\n        else if (this.l < 0)\n            this.l = 0;\n        Color.Converter.HSLToRGB(this);\n        return this;\n    };\n    Color.prototype.fadein = function (v) {\n        if (\"string\" == typeof v && v.indexOf(\"%\") > -1 && (v = parseInt(v)) != NaN) {\n            this.a += (1 - this.a) * (v / 100);\n        }\n        else if (\"number\" == typeof v) {\n            if (v >= 0.0 && v <= 1.0) {\n                // range 0-1\n                this.a += (1 - this.a) * v;\n            }\n            else {\n                // range 255\n                this.a += (1 - this.a) * (v / 255);\n            }\n        }\n        else {\n            throw new Error(\"error: bad modifier format (percent or number)\");\n        }\n        console.log(\"New alpha\", this.a);\n        if (this.a > 1)\n            this.a = 1;\n        else if (this.a < 0)\n            this.a = 0;\n        Color.Converter.HSLToRGB(this);\n        return this;\n    };\n    Color.prototype.fadeout = function (v) {\n        if (\"string\" == typeof v && v.indexOf(\"%\") > -1 && (v = parseInt(v)) != NaN) {\n            this.a -= v / 100;\n        }\n        else if (\"number\" == typeof v) {\n            if (v >= 0.0 && v <= 1.0) {\n                // range 0-1\n                this.a -= v;\n            }\n            else {\n                // range 255\n                this.a -= v / 255;\n            }\n        }\n        else {\n            throw new Error(\"error: bad modifier format (percent or number)\");\n        }\n        if (this.a > 1)\n            this.a = 1;\n        else if (this.a < 0)\n            this.a = 0;\n        Color.Converter.HSLToRGB(this);\n        return this;\n    };\n    Color.prototype.spin = function (v) {\n        if (\"string\" == typeof v && v.indexOf(\"%\") > -1 && (v = parseInt(v)) != NaN)\n            this.h += v / 100;\n        else if (\"number\" == typeof v)\n            // range 360\n            this.h += v / 360;\n        else\n            throw new Error(\"error: bad modifier format (percent or number)\");\n        if (this.h > 1)\n            this.h = 1;\n        else if (this.h < 0)\n            this.h = 0;\n        Color.Converter.HSLToRGB(this);\n        return this;\n    };\n    Color.makeRGB = function () {\n        var args = [];\n        for (var _i = 0; _i < arguments.length; _i++) {\n            args[_i] = arguments[_i];\n        }\n        var c = new Color();\n        var sanitized;\n        if (arguments.length < 3 || arguments.length > 4)\n            throw new Error(\"error: 3 or 4 arguments\");\n        sanitized = Color.Sanitizer.RGB(arguments[0], arguments[1], arguments[2]);\n        c.r = sanitized[0];\n        c.g = sanitized[1];\n        c.b = sanitized[2];\n        if (arguments.length == 4) {\n            c.a = arguments[3];\n        }\n        else {\n            c.a = 1.0;\n        }\n        Color.Converter.RGBToHSL(c);\n        return c;\n    };\n    Color.makeHSL = function () {\n        var args = [];\n        for (var _i = 0; _i < arguments.length; _i++) {\n            args[_i] = arguments[_i];\n        }\n        var c = new Color();\n        var sanitized;\n        if (arguments.length < 3 || arguments.length > 4)\n            throw new Error(\"error: 3 or 4 arguments\");\n        sanitized = Color.Sanitizer.HSL(arguments[0], arguments[1], arguments[2]);\n        c.h = sanitized[0];\n        c.s = sanitized[1];\n        c.l = sanitized[2];\n        if (arguments.length == 4)\n            c.a = arguments[3];\n        else\n            c.a = 1.0;\n        Color.Converter.HSLToRGB(c);\n        return c;\n    };\n    Color.makeHEX = function (value) {\n        var c = new Color(), sanitized;\n        // Edit Ika 2018-0308\n        // Allow leading '#'\n        if (value && value.startsWith(\"#\"))\n            value = value.substr(1);\n        Color.Validator.checkHEX(value);\n        if (value.length == 3) {\n            sanitized = Color.Sanitizer.RGB(parseInt(value.substr(0, 1) + value.substr(0, 1), 16), parseInt(value.substr(1, 1) + value.substr(1, 1), 16), parseInt(value.substr(2, 1) + value.substr(2, 1), 16));\n        }\n        else if (value.length == 6) {\n            sanitized = Color.Sanitizer.RGB(parseInt(value.substr(0, 2), 16), parseInt(value.substr(2, 2), 16), parseInt(value.substr(4, 2), 16));\n        }\n        else\n            throw new Error(\"error: 3 or 6 arguments\");\n        c.r = sanitized[0];\n        c.g = sanitized[1];\n        c.b = sanitized[2];\n        c.a = 1.0; // TODO: Accept #xxxxxxxx (8 chars, too, for alpha)\n        Color.Converter.RGBToHSL(c);\n        return c;\n    };\n    /**\n     * Parse the given color string. Currently only these formate are recognized: hex, rgb, rgba.\n     *\n     * @method parse\n     * @static\n     * @memberof Color\n     * @param {string} str - The string representation to parse.\n     * @return {Color} The color instance that's represented by the given string.\n     */\n    Color.parse = function (str) {\n        if (typeof str == \"undefined\") {\n            return null;\n        }\n        if ((str = str.trim().toLowerCase()).length == 0) {\n            return null;\n        }\n        if (str.startsWith(\"#\"))\n            return Color.makeHEX(str.substring(1, str.length));\n        if (str.startsWith(\"rgb\")) {\n            var parts = str.match(/^rgba?\\(\\s*(\\d{1,3})\\s*,\\s*(\\d{1,3})\\s*,\\s*(\\d{1,3})\\s*,?\\s*(\\d*(?:\\.\\d+\\s*)?)\\)$/);\n            if (!parts) {\n                throw \"Unrecognized color format (2): \" + str;\n            }\n            // [ str, r, g, b, a|undefined ]\n            //   console.log(\"parts\", parts);\n            if (parts.length <= 4 || typeof parts[4] == \"undefined\" || parts[4] == \"\") {\n                return Color.makeRGB(parts[1], parts[2], parts[3]);\n            }\n            else {\n                return Color.makeRGB(parts[1], parts[2], parts[3], Number(parts[4]));\n            }\n        }\n        else {\n            throw \"Unrecognized color format (1): \" + str;\n        }\n    };\n    /**\n     * Create a clone of this color (RGB).\n     *\n     * @method clone\n     * @instance\n     * @memberof Color\n     * @return {Color} A clone of this color (in RGB mode).\n     */\n    Color.prototype.clone = function () {\n        // return Color.makeRGB(this.r, this.g, this.b, this.a);\n        var col = new Color();\n        col.r = this.r;\n        col.g = this.g;\n        col.b = this.b;\n        col.a = this.a;\n        col.h = this.h;\n        col.s = this.s;\n        col.l = this.l;\n        return col;\n    };\n    /**\n     * Interpolate this color on the RGB scale.\n     *\n     * @method interpolate\n     * @instance\n     * @memberof Color\n     * @param {Color} c - The color to interpolate to.\n     * @param {number} t - An interpolation value between 0.0 and 1.0.\n     * @return {Color} A clone of this color (in RGB mode).\n     */\n    Color.prototype.interpolate = function (c, t) {\n        this.r += (c.r - this.r) * t;\n        this.g += (c.g - this.g) * t;\n        this.b += (c.b - this.b) * t;\n        this.a += (c.a - this.a) * t;\n        return this;\n    };\n    Color.Sanitizer = {\n        RGB: function () {\n            var args = [];\n            for (var _i = 0; _i < arguments.length; _i++) {\n                args[_i] = arguments[_i];\n            }\n            var o = [];\n            if (arguments.length == 0) {\n                return [];\n            }\n            // const allAreFrac = Color.testFrac( arguments );\n            for (var i = 0; i < arguments.length; i++) {\n                var c = arguments[i];\n                if (\"string\" == typeof c && c.indexOf(\"%\") > -1) {\n                    if ((c = parseInt(c)) == NaN)\n                        throw new Error(\"Bad format\");\n                    if (c < 0 || c > 100)\n                        throw new Error(\"Bad format\");\n                    o[i] = c / 100;\n                }\n                else {\n                    if (\"string\" == typeof c && (c = parseInt(c)) == NaN) {\n                        throw new Error(\"Bad format\");\n                    }\n                    if (c < 0) {\n                        throw new Error(\"Bad format\");\n                    }\n                    //else if( allAreFrac ) o[i] = c; // c >= 0 && c <= 1 (all)\n                    else if (c >= 0 && c < 1) {\n                        o[i] = c;\n                    }\n                    // else if(c >= 0.0 && c <= 1.0) o[i] = c;\n                    else if (c >= 1 && c < 256) {\n                        o[i] = c / 255;\n                    }\n                    // ???\n                    // else if(c >= 0 && c < 256) o[i] = c/255;\n                    else\n                        throw new Error(\"Bad format (\" + c + \")\");\n                }\n            }\n            return o;\n        },\n        HSL: function () {\n            var args = [];\n            for (var _i = 0; _i < arguments.length; _i++) {\n                args[_i] = arguments[_i];\n            }\n            if (arguments.length < 3 || arguments.length > 4)\n                throw new Error(\"3 or 4 arguments required\");\n            var h = arguments[0], s = arguments[1], l = arguments[2];\n            if (\"string\" == typeof h && (h = parseFloat(h)) == NaN)\n                throw new Error(\"Bad format for hue\");\n            if (h < 0 || h > 360)\n                throw new Error(\"Hue out of range (0..360)\");\n            else if (((\"\" + h).indexOf(\".\") > -1 && h > 1) || (\"\" + h).indexOf(\".\") == -1)\n                h /= 360;\n            if (\"string\" == typeof s && s.indexOf(\"%\") > -1) {\n                if ((s = parseInt(s)) == NaN)\n                    throw new Error(\"Bad format for saturation\");\n                if (s < 0 || s > 100)\n                    throw new Error(\"Bad format for saturation\");\n                s /= 100;\n            }\n            else if (s < 0 || s > 1)\n                throw new Error(\"Bad format for saturation\");\n            if (\"string\" == typeof l && l.indexOf(\"%\") > -1) {\n                if ((l = parseInt(l)) == NaN)\n                    throw new Error(\"Bad format for lightness\");\n                if (l < 0 || l > 100)\n                    throw new Error(\"Bad format for lightness\");\n                l /= 100;\n            }\n            else if (l < 0 || l > 1)\n                throw new Error(\"Bad format for lightness\");\n            return [h, s, l];\n        }\n    }; // ENd sanitizer\n    Color.Validator = {\n        /**\n         * Check a hexa color (without #)\n         */\n        checkHEX: function (value) {\n            if (value.length != 6 && value.length != 3)\n                throw new Error(\"Hexa color: bad length (\" + value.length + \"),\" + value);\n            value = value.toLowerCase();\n            //for( var i in value ) {\n            for (var i = 0; i < value.length; i++) {\n                var c = value.charCodeAt(i);\n                if (!((c >= 48 && c <= 57) || (c >= 97 && c <= 102)))\n                    throw new Error(\"Hexa color: out of range for \\\"\" + value + \"\\\" at position \" + i + \".\");\n            }\n        }\n    };\n    Color.Converter = {\n        /**\n         * Calculates HSL Color.\n         * RGB must be normalized.\n         * http://mjijackson.com/2008/02/rgb-to-hsl-and-rgb-to-hsv-color-model-conversion-algorithms-in-javascript\n         */\n        RGBToHSL: function (color) {\n            var r = color.r;\n            var g = color.g;\n            var b = color.b;\n            var max = Math.max(r, g, b);\n            var min = Math.min(r, g, b);\n            color.l = (max + min) / 2;\n            if (max == min) {\n                color.h = color.s = 0; // achromatic\n            }\n            else {\n                var d = max - min;\n                color.s = color.l > 0.5 ? d / (2 - max - min) : d / (max + min);\n                switch (max) {\n                    case r:\n                        color.h = (g - b) / d + (g < b ? 6 : 0);\n                        break;\n                    case g:\n                        color.h = (b - r) / d + 2;\n                        break;\n                    case b:\n                        color.h = (r - g) / d + 4;\n                        break;\n                }\n                color.h /= 6;\n            }\n        },\n        /**\n         * Calculates RGB color (nomalized).\n         * HSL must be normalized.\n         *\n         * http://mjijackson.com/2008/02/rgb-to-hsl-and-rgb-to-hsv-color-model-conversion-algorithms-in-javascript\n         */\n        HSLToRGB: function (color) {\n            var h = color.h;\n            var s = color.s;\n            var l = color.l;\n            if (s == 0) {\n                color.r = color.g = color.b = l; // achromatic\n            }\n            else {\n                var q = l < 0.5 ? l * (1 + s) : l + s - l * s;\n                var p = 2 * l - q;\n                color.r = Color.Converter.hue2rgb(p, q, h + 1 / 3);\n                color.g = Color.Converter.hue2rgb(p, q, h);\n                color.b = Color.Converter.hue2rgb(p, q, h - 1 / 3);\n            }\n        },\n        hue2rgb: function (p, q, t) {\n            if (t < 0)\n                t += 1;\n            if (t > 1)\n                t -= 1;\n            if (t < 1 / 6)\n                return p + (q - p) * 6 * t;\n            if (t < 1 / 2)\n                return q;\n            if (t < 2 / 3)\n                return p + (q - p) * (2 / 3 - t) * 6;\n            return p;\n        }\n    };\n    return Color;\n}()); // END class\nexports.Color = Color;\n//# sourceMappingURL=Color.js.map","\"use strict\";\n/**\n * A basic IO handler for file drop (Drag-and-drop).\n *\n * Example use:\n * ```javascript\n *  var body = document.getElememtByTagName(\"body\")[0];\n *  var fileDrop = new FileDrop(body);\n *    fileDrop.onFileJSONDropped(function (jsonObject) {\n *    console.log(\"jsonObject\", jsonObject);\n *  });\n * ```\n *\n * @author   Ikaros Kappler\n * @date     2021-10-13\n * @modified 2022-01-31 (ported from the ngdg project, then generalized)\n * @modified 2023-01-03 Fixing some minor type issues and adding SVG reading capabilities.\n * @version  2.1.0\n */\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.FileDrop = void 0;\nvar FileDrop = /** @class */ (function () {\n    /**\n     *\n     * @param {HTMLElement} element - The element you wish to operate as the drop zone (like <body/>).\n     */\n    function FileDrop(element) {\n        var _this = this;\n        /**\n         * Internally handle a drop event.\n         *\n         * @param {DragEvent} event\n         * @returns {void}\n         */\n        this.handleDropEvent = function (event) {\n            event.preventDefault();\n            event.stopPropagation();\n            _this.element.style.opacity = \"1.0\";\n            if (!event.dataTransfer || !event.dataTransfer.files || event.dataTransfer.files.length === 0) {\n                // No files were dropped\n                return;\n            }\n            if (event.dataTransfer.files.length > 1) {\n                // Multiple file drop is not nupported\n                return;\n            }\n            // if (!this.fileDroppedCallbackJSON) {\n            //   // No handling callback defined.\n            //   return;\n            // }\n            if (event.dataTransfer.files[0]) {\n                var file_1 = event.dataTransfer.files[0];\n                // console.log(\"file\", file);\n                if (file_1.type.match(/json.*/) && _this.fileDroppedCallbackJSON !== null) {\n                    var reader = new FileReader();\n                    reader.onload = function (readEvent) {\n                        if (!readEvent.target) {\n                            console.warn(\"Cannot process JSON ProgressEvent data: target is null.\");\n                            return;\n                        }\n                        // Finished reading file data.\n                        var jsonObject = JSON.parse(readEvent.target.result);\n                        // TODO: what happens on fail?\n                        _this.fileDroppedCallbackJSON && _this.fileDroppedCallbackJSON(jsonObject);\n                    };\n                    reader.readAsText(file_1); // start reading the file data.\n                }\n                else if (file_1.type.match(/text\\/plain.*/) && _this.fileDroppedCallbackText) {\n                    var reader = new FileReader();\n                    reader.onload = function (readEvent) {\n                        if (!readEvent.target) {\n                            console.warn(\"Cannot process Text ProgressEvent data: target is null.\");\n                            return;\n                        }\n                        // Finished reading file data.\n                        _this.fileDroppedCallbackText && _this.fileDroppedCallbackText(readEvent.target.result);\n                    };\n                    reader.readAsText(file_1); // start reading the file data.\n                }\n                else if (_this.fileDroppedCallbackBinary) {\n                    var reader = new FileReader();\n                    reader.onload = function (readEvent) {\n                        if (!readEvent.target) {\n                            console.warn(\"Cannot process Binary ProgressEvent data: target is null.\");\n                            return;\n                        }\n                        // Finished reading file data.\n                        _this.fileDroppedCallbackBinary &&\n                            _this.fileDroppedCallbackBinary(new Blob([readEvent.target.result]), file_1);\n                    };\n                    reader.readAsBinaryString(file_1); // start reading the file data.\n                }\n                else if (_this.fileDroppedCallbackSVG) {\n                    var reader = new FileReader();\n                    reader.onload = function (readEvent) {\n                        if (!readEvent.target) {\n                            console.warn(\"Cannot process SVG ProgressEvent data: target is null.\");\n                            return;\n                        }\n                        var parser = new DOMParser();\n                        var doc = parser.parseFromString(readEvent.target.result, \"image/svg+xml\");\n                        // Finished reading file data.\n                        _this.fileDroppedCallbackSVG && _this.fileDroppedCallbackSVG(doc);\n                    };\n                    reader.readAsText(file_1); // start reading the file data.\n                }\n            }\n        };\n        /**\n         * Toggles the drop sensitive element's opacity to 0.5.\n         *\n         * @param {DragEvent} event - The event.\n         */\n        this.handleDragOverEvent = function (event) {\n            event.preventDefault();\n            event.stopPropagation();\n            _this.element.style.opacity = \"0.5\";\n        };\n        /**\n         * Restored the drop sensitive element's opacity back to 1.0.\n         *\n         * @param {DragEvent} event - The event.\n         */\n        this.handleDragLeaveEvent = function (event) {\n            event.preventDefault();\n            event.stopPropagation();\n            _this.element.style.opacity = \"1.0\";\n        };\n        this.element = element;\n        // Init the drop listeners\n        element.addEventListener(\"drop\", this.handleDropEvent.bind(this));\n        element.addEventListener(\"dragover\", this.handleDragOverEvent.bind(this));\n        element.addEventListener(\"dragleave\", this.handleDragLeaveEvent.bind(this));\n    }\n    /**\n     * Install the JSON (MIME type json*) file drop callback. Note than only one callback can be installed\n     * in this implementation. Calling this method multiple times will overwrite previously\n     * installed listeners.\n     *\n     * The callback will receive the dropped file content as an object (parsed JSON).\n     *\n     * @param {(data:object)=>void} callback\n     */\n    FileDrop.prototype.onFileJSONDropped = function (callback) {\n        this.fileDroppedCallbackJSON = callback;\n    };\n    /**\n     * Install the text file (MIME type text/plain) drop callback. Note than only one callback can be installed\n     * in this implementation. Calling this method multiple times will overwrite previously\n     * installed listeners.\n     *\n     * The callback will receive the dropped file content as a string.\n     *\n     * @param {(data:object)=>void} callback\n     */\n    FileDrop.prototype.onFileTextDropped = function (callback) {\n        this.fileDroppedCallbackText = callback;\n    };\n    FileDrop.prototype.onFileSVGDropped = function (callback) {\n        this.fileDroppedCallbackSVG = callback;\n    };\n    /**\n     * Removes all listeners (drop, dragover and dragleave).\n     */\n    FileDrop.prototype.destroy = function () {\n        this.element.removeEventListener(\"drop\", this.handleDropEvent);\n        this.element.removeEventListener(\"dragover\", this.handleDragOverEvent);\n        this.element.removeEventListener(\"dragleave\", this.handleDragLeaveEvent);\n    };\n    return FileDrop;\n}());\nexports.FileDrop = FileDrop;\n//# sourceMappingURL=FileDrop.js.map","/**\n * @classdesc A static UIDGenerator.\n *\n * @author  Ikaros Kappler\n * @date    2021-01-20\n * @version 1.0.0\n */\nexport class UIDGenerator {\n    static next() {\n        return `${UIDGenerator.current++}`;\n    }\n}\nUIDGenerator.current = 0;\n//# sourceMappingURL=UIDGenerator.js.map","/**\n * @author   Ikaros Kappler\n * @date     2018-08-26\n * @modified 2018-11-17 Added the 'isSelected' attribute.\n * @modified 2018-11-27 Added the global model for instantiating with custom attributes.\n * @modified 2019-03-20 Added JSDoc tags.\n * @modified 2020-02-29 Added the 'selectable' attribute.\n * @modified 2020-03-23 Ported to Typescript from JS.\n * @version  1.1.1\n *\n * @file VertexAttr\n * @public\n **/\n/**\n * @classdesc The VertexAttr is a helper class to wrap together additional attributes\n * to vertices that do not belong to the 'standard canonical' vertex implementation.<br>\n * <br>\n * This is some sort of 'userData' object, but the constructor uses a global model\n * to obtain a (configurable) default attribute set to all instances.<br>\n */\nexport class VertexAttr {\n    /**\n     * The constructor.\n     *\n     * Attributes will be initialized as defined in the model object\n     * which serves as a singleton.\n     *\n     * @constructor\n     * @name VertexAttr\n     **/\n    constructor() {\n        this.draggable = true;\n        this.selectable = true;\n        this.isSelected = false;\n        this.visible = true;\n        for (var key in VertexAttr.model)\n            this[key] = VertexAttr.model[key];\n    }\n    ;\n}\n/**\n * This is the global attribute model. Set these object on the initialization\n * of your app to gain all VertexAttr instances have these attributes.\n *\n * @type {object}\n **/\nVertexAttr.model = {\n    draggable: true,\n    selectable: true,\n    isSelected: false,\n    visible: true\n};\n//# sourceMappingURL=VertexAttr.js.map","/**\n * @author   Ikaros Kappler\n * @date     2018-08-27\n * @modified 2018-11-28 Added the vertex-param to the constructor and extended the event. Vertex events now have a 'params' attribute object.\n * @modified 2019-03-20 Added JSDoc tags.\n * @modified 2020-02-22 Added 'return this' to the add* functions (for chanining).\n * @modified 2020-03-23 Ported to Typescript from JS.\n * @modified 2020-11-17 Added the `click` handler.\n * @version  1.1.0\n *\n * @file VertexListeners\n * @public\n **/\n/**\n * @classdesc An event listeners wrapper. This is just a set of three listener\n *              queues (drag, dragStart, dragEnd) and their respective firing\n *              functions.\n *\n */\nexport class VertexListeners {\n    /**\n     * The constructor.\n     *\n     * @constructor\n     * @name VertexListeners\n     * @param {Vertex} vertex - The vertex to use these listeners on (just a backward reference).\n     **/\n    constructor(vertex) {\n        this.click = [];\n        this.drag = [];\n        this.dragStart = [];\n        this.dragEnd = [];\n        this.vertex = vertex;\n    }\n    /**\n     * Add a click listener.\n     *\n     * @method addClickListener\n     * @param {VertexListeners~dragListener} listener - The click listener to add (a callback).\n     * @return {VertexListeners} this (for chaining)\n     * @instance\n     * @memberof VertexListeners\n     **/\n    addClickListener(listener) {\n        VertexListeners._addListener(this.click, listener);\n        return this;\n    }\n    /**\n     * The click listener is a function with a single drag event param.\n     * @callback VertexListeners~clickListener\n     * @param {Event} e - The (extended) click event.\n     */\n    /**\n     * Remove a drag listener.\n     *\n     * @method removeDragListener\n     * @param {VertexListeners~dragListener} listener - The drag listener to remove (a callback).\n     * @return {VertexListeners} this (for chaining)\n     * @instance\n     * @memberof VertexListeners\n     **/\n    removeClickListener(listener) {\n        this.click = VertexListeners._removeListener(this.click, listener);\n        return this;\n    }\n    /**\n     * The click listener is a function with a single drag event param.\n     * @callback VertexListeners~clickListener\n     * @param {Event} e - The (extended) click event.\n     */\n    /**\n     * Add a drag listener.\n     *\n     * @method addDragListener\n     * @param {VertexListeners~dragListener} listener - The drag listener to add (a callback).\n     * @return {VertexListeners} this (for chaining)\n     * @instance\n     * @memberof VertexListeners\n     **/\n    addDragListener(listener) {\n        VertexListeners._addListener(this.drag, listener);\n        return this;\n    }\n    /**\n     * The drag listener is a function with a single drag event param.\n     * @callback VertexListeners~dragListener\n     * @param {Event} e - The (extended) drag event.\n     */\n    /**\n     * Remove a drag listener.\n     *\n     * @method removeDragListener\n     * @param {VertexListeners~dragListener} listener - The drag listener to remove (a callback).\n     * @return {VertexListeners} this (for chaining)\n     * @instance\n     * @memberof VertexListeners\n     **/\n    removeDragListener(listener) {\n        this.drag = VertexListeners._removeListener(this.drag, listener);\n        return this;\n    }\n    /**\n     * Add a dragStart listener.\n     *\n     * @method addDragListener\n     * @param {VertexListeners~dragStartListener} listener - The drag-start listener to add (a callback).\n     * @return {VertexListeners} this (for chaining)\n     * @instance\n     * @memberof VertexListeners\n     **/\n    addDragStartListener(listener) {\n        VertexListeners._addListener(this.dragStart, listener);\n        return this;\n    }\n    /**\n     * The drag-start listener is a function with a single drag event param.\n     * @callback VertexListeners~dragStartListener\n     * @param {Event} e - The (extended) drag event.\n     */\n    /**\n     * Remove a dragStart listener.\n     *\n     * @method addDragStartListener\n     * @param {VertexListeners~dragListener} listener - The drag listener to remove (a callback).\n     * @return {VertexListeners} this (for chaining)\n     * @instance\n     * @memberof VertexListeners\n     **/\n    removeDragStartListener(listener) {\n        this.dragStart = VertexListeners._removeListener(this.dragStart, listener);\n        return this;\n    }\n    /**\n     * Add a dragEnd listener.\n     *\n     * @method addDragListener\n     * @param {VertexListeners~dragEndListener} listener - The drag-end listener to add (a callback).\n     * @return {VertexListeners} this (for chaining)\n     * @instance\n     * @memberof VertexListeners\n     **/\n    addDragEndListener(listener) {\n        // this.dragEnd.push( listener );\n        VertexListeners._addListener(this.dragEnd, listener);\n        return this;\n    }\n    /**\n     * The drag-end listener is a function with a single drag event param.\n     * @callback VertexListeners~dragEndListener\n     * @param {Event} e - The (extended) drag event.\n     */\n    /**\n     * Remove a drag listener.\n     *\n     * @method removeDragEndListener\n     * @param {VertexListeners~clickListener} listener - The drag listener to remove (a callback).\n     * @return {VertexListeners} this (for chaining)\n     * @instance\n     * @memberof VertexListeners\n     **/\n    removeDragEndListener(listener) {\n        // this.drag.push( listener );\n        this.dragEnd = VertexListeners._removeListener(this.dragEnd, listener);\n        return this;\n    }\n    /**\n     * Fire a click event with the given event instance to all\n     * installed click listeners.\n     *\n     * @method fireClickEvent\n     * @param {VertEvent|XMouseEvent} e - The click event itself to be fired to all installed drag listeners.\n     * @return {void}\n     * @instance\n     * @memberof VertexListeners\n     **/\n    fireClickEvent(e) {\n        VertexListeners._fireEvent(this, this.click, e);\n    }\n    /**\n     * Fire a drag event with the given event instance to all\n     * installed drag listeners.\n     *\n     * @method fireDragEvent\n     * @param {VertEvent|XMouseEvent} e - The drag event itself to be fired to all installed drag listeners.\n     * @return {void}\n     * @instance\n     * @memberof VertexListeners\n     **/\n    fireDragEvent(e) {\n        VertexListeners._fireEvent(this, this.drag, e);\n    }\n    /**\n     * Fire a dragStart event with the given event instance to all\n     * installed drag-start listeners.\n     *\n     * @method fireDragStartEvent\n     * @param {VertEvent|XMouseEvent} e - The drag-start event itself to be fired to all installed dragStart listeners.\n     * @return {void}\n     * @instance\n     * @memberof VertexListeners\n     **/\n    fireDragStartEvent(e) {\n        VertexListeners._fireEvent(this, this.dragStart, e);\n    }\n    /**\n     * Fire a dragEnd event with the given event instance to all\n     * installed drag-end listeners.\n     *\n     * @method fireDragEndEvent\n     * @param {VertEvent|XMouseEvent} e - The drag-end event itself to be fired to all installed dragEnd listeners.\n     * @return {void}\n     * @instance\n     * @memberof VertexListeners\n     **/\n    fireDragEndEvent(e) {\n        VertexListeners._fireEvent(this, this.dragEnd, e);\n    }\n    /**\n     * Removes all listeners from this listeners object.\n     */\n    removeAllListeners() {\n        this.click = [];\n        this.drag = [];\n        this.dragStart = [];\n        this.dragEnd = [];\n    }\n    /**\n     * @private\n     **/\n    static _fireEvent(_self, listeners, e) {\n        const ve = e;\n        if (typeof ve.params == \"undefined\")\n            ve.params = { vertex: _self.vertex };\n        else\n            ve.params.vertex = _self.vertex;\n        for (var i in listeners) {\n            listeners[i](ve);\n        }\n    }\n    /**\n     * @private\n     */\n    static _addListener(listeners, newListener) {\n        for (var i in listeners) {\n            if (listeners[i] == newListener)\n                return false;\n        }\n        listeners.push(newListener);\n        return true;\n    }\n    /**\n     * @private\n     */\n    static _removeListener(listeners, oldListener) {\n        for (var i = 0; i < listeners.length; i++) {\n            if (listeners[i] == oldListener)\n                return listeners.splice(i, 1);\n        }\n        return listeners;\n    }\n}\n//# sourceMappingURL=VertexListeners.js.map","/**\n * @author   Ikaros Kappler\n * @date     2012-10-17\n * @modified 2018-04-03 Refactored the code of october 2012 into a new class.\n * @modified 2018-04-28 Added some documentation.\n * @modified 2018-08-16 Added the set() function.\n * @modified 2018-08-26 Added VertexAttr.\n * @modified 2018-10-31 Extended the constructor by object{x,y}.\n * @modified 2018-11-19 Extended the set(number,number) function to set(Vertex).\n * @modified 2018-11-28 Added 'this' to the VertexAttr constructor.\n * @modified 2018-12-05 Added the sub(...) function. Changed the signature of the add() function! add(Vertex) and add(number,number) are now possible.\n * @modified 2018-12-21 (It's winter solstice) Added the inv()-function.\n * @modified 2019-01-30 Added the setX(Number) and setY(Number) functions.\n * @modified 2019-02-19 Added the difference(Vertex) function.\n * @modified 2019-03-20 Added JSDoc tags.\n * @modified 2019-04-24 Added the randomVertex(ViewPort) function.\n * @modified 2019-11-07 Added toSVGString(object) function.\n * @modified 2019-11-18 Added the rotate(number,Vertex) function.\n * @modified 2019-11-21 Fixed a bug in the rotate(...) function (elements were moved).\n * @modified 2020-03-06 Added functions invX() and invY().\n * @modified 2020-03-23 Ported to Typescript from JS.\n * @modified 2020-05-26 Added functions addX(number) and addY(number).\n * @modified 2020-10-30 Changed the warnings in `sub(...)` and `add(...)` into real errors.\n * @modified 2021-03-01 Changed the second param `center` in the `rotate` function from Vertex to XYCoords.\n * @modified 2021-12-01 Changed the type of param of `scale` to XYCoords.\n * @modified 2021-12-01 Added function `scaleXY` for non uniform scaling.\n * @modified 2021-12-17 Added the functions `lerp` and `lerpAbs` for linear interpolations.\n * @modified 2022-01-31 Added `Vertex.utils.arrayToJSON`.\n * @modified 2022-02-02 Added the `destroy` method.\n * @modified 2022-02-02 Cleared the `Vertex.toSVGString` function (deprecated). Use `drawutilssvg` instead.\n * @modified 2022-11-28 Added the `subXY`, `subX` and `subY` methods to the `Vertex` class.\n * @version  2.8.0\n *\n * @file Vertex\n * @public\n **/\nimport { VertexAttr } from \"./VertexAttr\";\nimport { UIDGenerator } from \"./UIDGenerator\";\nimport { VertexListeners } from \"./VertexListeners\";\n/**\n * @classdesc A vertex is a pair of two numbers.<br>\n * <br>\n * It is used to identify a 2-dimensional point on the x-y-plane.\n *\n * @requires IVertexAttr\n * @requires SVGSerializable\n * @requires UID\n * @requires UIDGenerator\n * @requires VertexAttr\n * @requires VertexListeners\n * @requires XYCoords\n *\n */\nexport class Vertex {\n    /**\n     * The constructor for the vertex class.\n     *\n     * @constructor\n     * @name Vertex\n     * @param {number} x - The x-coordinate of the new vertex.\n     * @param {number} y - The y-coordinate of the new vertex.\n     **/\n    constructor(x, y) {\n        /**\n         * Required to generate proper CSS classes and other class related IDs.\n         **/\n        this.className = \"Vertex\";\n        this.uid = UIDGenerator.next();\n        if (typeof x == \"undefined\") {\n            this.x = 0;\n            this.y = 0;\n        }\n        else if (typeof x == \"number\" && typeof y == \"number\") {\n            this.x = x;\n            this.y = y;\n        }\n        else {\n            const tuple = x;\n            if (typeof tuple.x == \"number\" && typeof tuple.y == \"number\") {\n                this.x = tuple.x;\n                this.y = tuple.y;\n            }\n            else {\n                if (typeof x == \"number\")\n                    this.x = x;\n                else if (typeof x == \"undefined\")\n                    this.x = 0;\n                else\n                    this.x = NaN;\n                if (typeof y == \"number\")\n                    this.y = y;\n                else if (typeof y == \"undefined\")\n                    this.y = 0;\n                else\n                    this.y = NaN;\n            }\n        }\n        this.attr = new VertexAttr();\n        this.listeners = new VertexListeners(this);\n    }\n    /**\n     * Set the x- and y- component of this vertex.\n     *\n     * @method set\n     * @param {number} x - The new x-component.\n     * @param {number} y - The new y-component.\n     * @return {Vertex} this\n     * @instance\n     * @memberof Vertex\n     **/\n    set(x, y) {\n        if (typeof x == \"number\" && typeof y == \"number\") {\n            this.x = x;\n            this.y = y;\n        }\n        else {\n            const tuple = x;\n            if (typeof tuple.x == \"number\" && typeof tuple.y == \"number\") {\n                this.x = tuple.x;\n                this.y = tuple.y;\n            }\n            else {\n                if (typeof x == \"number\")\n                    this.x = x;\n                else if (typeof x == \"undefined\")\n                    this.x = 0;\n                else\n                    this.x = NaN;\n                if (typeof y == \"number\")\n                    this.y = y;\n                else if (typeof y == \"undefined\")\n                    this.y = 0;\n                else\n                    this.y = NaN;\n            }\n        }\n        return this;\n    }\n    /**\n     * Set the x-component of this vertex.\n     *\n     * @method setX\n     * @param {number} x - The new x-component.\n     * @return {Vertex} this\n     * @instance\n     * @memberof Vertex\n     **/\n    setX(x) {\n        this.x = x;\n        return this;\n    }\n    /**\n     * Set the y-component of this vertex.\n     *\n     * @method setY\n     * @param {number} y - The new y-component.\n     * @return {Vertex} this\n     * @instance\n     * @memberof Vertex\n     **/\n    setY(y) {\n        this.y = y;\n        return this;\n    }\n    /**\n     * Set the x-component if this vertex to the inverse of its value.\n     *\n     * @method invX\n     * @return {Vertex} this\n     * @instance\n     * @memberof Vertex\n     **/\n    invX() {\n        this.x = -this.x;\n        return this;\n    }\n    /**\n     * Set the y-component if this vertex to the inverse of its value.\n     *\n     * @method invY\n     * @return {Vertex} this\n     * @instance\n     * @memberof Vertex\n     **/\n    invY() {\n        this.y = -this.y;\n        return this;\n    }\n    /**\n     * Add the passed amount to x- and y- component of this vertex.<br>\n     * <br>\n     * This function works with add( {number}, {number} ) and\n     * add( {Vertex} ), as well.\n     *\n     * @method add\n     * @param {(number|Vertex)} x - The amount to add to x (or a vertex itself).\n     * @param {number=} y - The amount to add to y.\n     * @return {Vertex} this\n     * @instance\n     * @memberof Vertex\n     **/\n    add(x, y) {\n        if (typeof x == \"number\" && typeof y == \"number\") {\n            this.x += x;\n            this.y += y;\n        }\n        else {\n            const tuple = x;\n            if (typeof tuple.x == \"number\" && typeof tuple.y == \"number\") {\n                this.x += tuple.x;\n                this.y += tuple.y;\n            }\n            else {\n                if (typeof x == \"number\")\n                    this.x += x;\n                else\n                    throw `Cannot add ${typeof x} to numeric x component!`;\n                if (typeof y == \"number\")\n                    this.y += y;\n                else\n                    throw `Cannot add ${typeof y} to numeric y component!`;\n            }\n        }\n        return this;\n    }\n    /**\n     * Add the passed amounts to the x- and y- components of this vertex.\n     *\n     * @method addXY\n     * @param {number} x - The amount to add to x.\n     * @param {number} y - The amount to add to y.\n     * @return {Vertex} this\n     * @instance\n     * @memberof Vertex\n     **/\n    addXY(amountX, amountY) {\n        this.x += amountX;\n        this.y += amountY;\n        return this;\n    }\n    /**\n     * Add the passed amounts to the x-component of this vertex.\n     *\n     * @method addX\n     * @param {number} x - The amount to add to x.\n     * @return {Vertex} this\n     * @instance\n     * @memberof Vertex\n     **/\n    addX(amountX) {\n        this.x += amountX;\n        return this;\n    }\n    /**\n     * Add the passed amounts to the y-component of this vertex.\n     *\n     * @method addY\n     * @param {number} y - The amount to add to y.\n     * @return {Vertex} this\n     * @instance\n     * @memberof Vertex\n     **/\n    addY(amountY) {\n        this.y += amountY;\n        return this;\n    }\n    /**\n     * Substract the passed amount from x- and y- component of this vertex.<br>\n     * <br>\n     * This function works with sub( {number}, {number} ) and\n     * sub( {Vertex} ), as well.\n     *\n     * @method sub\n     * @param {(number|Vertex)} x - The amount to substract from x (or a vertex itself).\n     * @param {number=} y - The amount to substract from y.\n     * @return {Vertex} this\n     * @instance\n     * @memberof Vertex\n     **/\n    sub(x, y) {\n        if (typeof x == \"number\" && typeof y == \"number\") {\n            this.x -= x;\n            this.y -= y;\n        }\n        else {\n            const tuple = x;\n            if (typeof tuple.x == \"number\" && typeof tuple.y == \"number\") {\n                this.x -= tuple.x;\n                this.y -= tuple.y;\n            }\n            else {\n                if (typeof x == \"number\")\n                    this.x -= x;\n                else\n                    throw `Cannot add ${typeof x} to numeric x component!`;\n                if (typeof y == \"number\")\n                    this.y -= y;\n                else\n                    throw `Cannot add ${typeof y} to numeric y component!`;\n            }\n        }\n        return this;\n    }\n    /**\n     * Substract the passed amounts from the x- and y- components of this vertex.\n     *\n     * @method subXY\n     * @param {number} x - The amount to substract from x.\n     * @param {number} y - The amount to substract from y.\n     * @return {Vertex} this\n     * @instance\n     * @memberof Vertex\n     **/\n    subXY(amountX, amountY) {\n        this.x -= amountX;\n        this.y -= amountY;\n        return this;\n    }\n    /**\n     * Substract the passed amounts from the x-component of this vertex.\n     *\n     * @method addX\n     * @param {number} x - The amount to substract from x.\n     * @return {Vertex} this\n     * @instance\n     * @memberof Vertex\n     **/\n    subX(amountX) {\n        this.x -= amountX;\n        return this;\n    }\n    /**\n     * Substract the passed amounts from the y-component of this vertex.\n     *\n     * @method subY\n     * @param {number} y - The amount to substract from y.\n     * @return {Vertex} this\n     * @instance\n     * @memberof Vertex\n     **/\n    subY(amountY) {\n        this.y -= amountY;\n        return this;\n    }\n    /**\n     * Check if this vertex equals the passed one.\n     * <br>\n     * This function uses an internal epsilon as tolerance.\n     *\n     * @method equals\n     * @param {Vertex} vertex - The vertex to compare this with.\n     * @return {boolean}\n     * @instance\n     * @memberof Vertex\n     **/\n    equals(vertex) {\n        var eqX = Math.abs(this.x - vertex.x) < Vertex.EPSILON;\n        var eqY = Math.abs(this.y - vertex.y) < Vertex.EPSILON;\n        var result = eqX && eqY;\n        return result;\n    }\n    /**\n     * Create a copy of this vertex.\n     *\n     * @method clone\n     * @return {Vertex} A new vertex, an exact copy of this.\n     * @instance\n     * @memberof Vertex\n     **/\n    clone() {\n        return new Vertex(this.x, this.y);\n    }\n    /**\n     * Get the distance to the passed point (in euclidean metric)\n     *\n     * @method distance\n     * @param {XYCoords} vert - The vertex to measure the distance to.\n     * @return {number}\n     * @instance\n     * @memberof Vertex\n     **/\n    distance(vert) {\n        return Math.sqrt(Math.pow(vert.x - this.x, 2) + Math.pow(vert.y - this.y, 2));\n    }\n    /**\n     * Get the angle of this point (relative to (0,0) or to the given other origin point).\n     *\n     * @method angle\n     * @param {XYCoords} origin - The vertex to measure the angle from.\n     * @return {number}\n     * @instance\n     * @memberof Vertex\n     **/\n    angle(origin) {\n        const a = typeof origin === \"undefined\"\n            ? Math.PI / 2 - Math.atan2(this.x, this.y)\n            : Math.PI / 2 - Math.atan2(origin.x - this.x, origin.y - this.y);\n        // Map to positive value\n        return a < 0 ? Math.PI * 2 + a : a;\n    }\n    /**\n     * Get the difference to the passed point.<br>\n     * <br>\n     * The difference is (vert.x-this.x, vert.y-this.y).\n     *\n     * @method difference\n     * @param {Vertex} vert - The vertex to measure the x-y-difference to.\n     * @return {Vertex} A new vertex.\n     * @instance\n     * @memberof Vertex\n     **/\n    difference(vert) {\n        return new Vertex(vert.x - this.x, vert.y - this.y);\n    }\n    /**\n     * This is a vector-like behavior and 'scales' this vertex\n     * towards/from a given center by one uniform scale factor.\n     *\n     * @method scale\n     * @param {number} factor - The factor to 'scale' this vertex; 1.0 means no change.\n     * @param {XYCoords=} center - The origin of scaling; default is (0,0).\n     * @return {Vertex} this\n     * @instance\n     * @memberof Vertex\n     **/\n    scale(factor, center) {\n        return this.scaleXY({ x: factor, y: factor }, center);\n    }\n    /**\n     * Perform a linear interpolation towards the given target vertex.\n     * The amount value `t` is relative, `t=0.0` means no change, `t=1.0`\n     * means this point will be moved to the exact target position.\n     *\n     * `t=0.5` will move this point to the middle of the connecting\n     * linear segment.\n     *\n     * @param {XYCoords} target - The target position to lerp this vertex to.\n     * @param {number} t - The relative amount, usually in [0..1], but other values will work, too.\n     * @returns\n     */\n    lerp(target, t) {\n        var diff = this.difference(target);\n        // return new Vertex(this.x + diff.x * t, this.y + diff.y * t);\n        this.x += diff.x * t;\n        this.y += diff.y * t;\n        return this;\n    }\n    /**\n     * Perform a linear interpolation towards the given target vertex (absolute variant).\n     * The amount value `t` is absolute, which means the lerp amount is a direct distance\n     * value. This point will have move the amount of the passed distance `u`.\n     *\n     * @param {XYCoords} target - The target position to lerp this vertex to.\n     * @param {number} t - The absolute move amount to use to lerping.\n     * @returns\n     */\n    lerpAbs(target, u) {\n        var dist = this.distance(target);\n        var diff = this.difference(target);\n        var step = { x: diff.x / dist, y: diff.y / dist };\n        // return new Vertex(this.x + step.x * u, this.y + step.y * u);\n        this.x += step.x * u;\n        this.y += step.y * u;\n        return this;\n    }\n    /**\n     * This is a vector-like behavior and 'scales' this vertex\n     * towards/from a given center by two independent x- and y- scale factors.\n     *\n     * @method scale\n     * @param {number} factor - The factor to 'scale' this vertex; 1.0 means no change.\n     * @param {XYCoords=} center - The origin of scaling; default is (0,0).\n     * @return {Vertex} this\n     * @instance\n     * @memberof Vertex\n     **/\n    scaleXY(factors, center) {\n        if (!center || typeof center === \"undefined\") {\n            center = { x: 0, y: 0 };\n        }\n        this.x = center.x + (this.x - center.x) * factors.x;\n        this.y = center.y + (this.y - center.y) * factors.y;\n        return this;\n    }\n    /**\n     * This is a vector-like behavior and 'rotates' this vertex\n     * around given center.\n     *\n     * @method rotate\n     * @param {number} angle - The angle to 'rotate' this vertex; 0.0 means no change.\n     * @param {XYCoords=} center - The center of rotation; default is (0,0).\n     * @return {Vertex} this\n     * @instance\n     * @memberof Vertex\n     **/\n    rotate(angle, center) {\n        if (!center || typeof center === \"undefined\") {\n            center = { x: 0, y: 0 };\n        }\n        this.sub(center);\n        angle += Math.atan2(this.y, this.x);\n        let len = this.distance(Vertex.ZERO); // {x:0,y:0});\n        this.x = len * Math.cos(angle);\n        this.y = len * Math.sin(angle);\n        this.add(center);\n        return this;\n    }\n    /**\n     * Multiply both components of this vertex with the given scalar.<br>\n     * <br>\n     * Note: as in<br>\n     *    https://threejs.org/docs/#api/math/Vector2.multiplyScalar\n     *\n     * @method multiplyScalar\n     * @param {number} scalar - The scale factor; 1.0 means no change.\n     * @return {Vertex} this\n     * @instance\n     * @memberof Vertex\n     **/\n    multiplyScalar(scalar) {\n        this.x *= scalar;\n        this.y *= scalar;\n        return this;\n    }\n    /**\n     * Round the two components x and y of this vertex.\n     *\n     * @method round\n     * @return {Vertex} this\n     * @instance\n     * @memberof Vertex\n     **/\n    round() {\n        this.x = Math.round(this.x);\n        this.y = Math.round(this.y);\n        return this;\n    }\n    /**\n     * Change this vertex (x,y) to its inverse (-x,-y).\n     *\n     * @method inv\n     * @return {Vertex} this\n     * @instance\n     * @memberof Vertex\n     **/\n    inv() {\n        this.x = -this.x;\n        this.y = -this.y;\n        return this;\n    }\n    /**\n     * Get a string representation of this vertex.\n     *\n     * @method toString\n     * @return {string} The string representation of this vertex.\n     * @instance\n     * @memberof Vertex\n     **/\n    toString() {\n        return \"(\" + this.x + \",\" + this.y + \")\";\n    }\n    /**\n     * This function should invalidate any installed listeners and invalidate this object.\n     * After calling this function the object might not hold valid data any more and\n     * should not be used.\n     */\n    destroy() {\n        this.listeners.removeAllListeners();\n        this.isDestroyed = true;\n    }\n    /**\n     * Create a new random vertex inside the given viewport.\n     *\n     * @param {ViewPort} viewPort - A {min:Vertex, max:Vertex} viewport specifying the bounds.\n     * @return A new vertex with a random position.\n     **/\n    static randomVertex(viewPort) {\n        return new Vertex(viewPort.min.x + Math.random() * (viewPort.max.x - viewPort.min.x), viewPort.min.y + Math.random() * (viewPort.max.y - viewPort.min.y));\n    }\n}\nVertex.ZERO = new Vertex(0, 0);\n/**\n * An epsilon for comparison\n *\n * @private\n * @readonly\n **/\nVertex.EPSILON = 1.0e-6;\nVertex.utils = {\n    /**\n     * Generate a four-point arrow head, starting at the vector end minus the\n     * arrow head length.\n     *\n     * The first vertex in the returned array is guaranteed to be the located\n     * at the vector line end minus the arrow head length.\n     *\n     *\n     * Due to performance all params are required.\n     *\n     * The params scaleX and scaleY are required for the case that the scaling is not uniform (x and y\n     * scaling different). Arrow heads should not look distored on non-uniform scaling.\n     *\n     * If unsure use 1.0 for scaleX and scaleY (=no distortion).\n     * For headlen use 8, it's a good arrow head size.\n     *\n     * Example:\n     *    buildArrowHead( new Vertex(0,0), new Vertex(50,100), 8, 1.0, 1.0 )\n     *\n     * @param {Vertex} zA - The start vertex of the vector to calculate the arrow head for.\n     * @param {Vertex} zB - The end vertex of the vector.\n     * @param {number} headlen - The length of the arrow head (along the vector direction. A good value is 12).\n     * @param {number} scaleX  - The horizontal scaling during draw.\n     * @param {number} scaleY  - the vertical scaling during draw.\n     **/\n    // @DEPRECATED: use Vector.utils.buildArrowHead instead!!!\n    buildArrowHead: (zA, zB, headlen, scaleX, scaleY) => {\n        // console.warn('This function is deprecated! Use Vector.utils.buildArrowHead instead!');\n        var angle = Math.atan2((zB.y - zA.y) * scaleY, (zB.x - zA.x) * scaleX);\n        var vertices = [];\n        vertices.push(new Vertex(zB.x * scaleX - headlen * Math.cos(angle), zB.y * scaleY - headlen * Math.sin(angle)));\n        vertices.push(new Vertex(zB.x * scaleX - headlen * 1.35 * Math.cos(angle - Math.PI / 8), zB.y * scaleY - headlen * 1.35 * Math.sin(angle - Math.PI / 8)));\n        vertices.push(new Vertex(zB.x * scaleX, zB.y * scaleY));\n        vertices.push(new Vertex(zB.x * scaleX - headlen * 1.35 * Math.cos(angle + Math.PI / 8), zB.y * scaleY - headlen * 1.35 * Math.sin(angle + Math.PI / 8)));\n        return vertices;\n    },\n    /**\n     * Convert the given vertices (array) to a JSON string.\n     *\n     * @param {number?} precision - (optional) The numeric precision to be used (number of precision digits).\n     * @returns {string}\n     */\n    arrayToJSON(vertices, precision) {\n        return JSON.stringify(vertices.map(function (vert) {\n            return typeof precision === undefined\n                ? { x: vert.x, y: vert.y }\n                : { x: Number(vert.x.toFixed(precision)), y: Number(vert.y.toFixed(precision)) };\n        }));\n    }\n};\n//# sourceMappingURL=Vertex.js.map","/**\n * @author   Ikaros Kappler\n * @date     2018-04-14\n * @modified 2018-11-17 Added the containsVert function.\n * @modified 2018-12-04 Added the toSVGString function.\n * @modified 2019-03-20 Added JSDoc tags.\n * @modified 2019-10-25 Added the scale function.\n * @modified 2019-11-06 JSDoc update.\n * @modified 2019-11-07 Added toCubicBezierPath(number) function.\n * @modified 2019-11-22 Added the rotate(number,Vertex) function.\n * @modified 2020-03-24 Ported this class from vanilla-JS to Typescript.\n * @modified 2020-10-30 Added the `addVertex` function.\n * @modified 2020-10-31 Added the `getVertexAt` function.\n * @modified 2020-11-06 Added the `move` function.\n * @modified 2020-11-10 Added the `getBounds` function.\n * @modified 2020-11-11 Generalized `move(Vertex)` to `move(XYCoords)`.\n * @modified 2021-01-20 Added UID.\n * @modified 2021-01-29 Added the `signedArea` function (was global function in the demos before).\n * @modified 2021-01-29 Added the `isClockwise` function.\n * @modified 2021-01-29 Added the `area` function.\n * @modified 2021-01-29 Changed the param type for `containsVert` from Vertex to XYCoords.\n * @modified 2021-12-14 Added the `perimeter()` function.\n * @modified 2021-12-16 Added the `getEvenDistributionPolygon()` function.\n * @modified 2022-02-02 Added the `destroy` method.\n * @modified 2022-02-02 Cleared the `Polygon.toSVGString` function (deprecated). Use `drawutilssvg` instead.\n * @modified 2022-03-08 Added the `Polygon.clone()` function.\n * @version 1.10.0\n *\n * @file Polygon\n * @public\n **/\nimport { BezierPath } from \"./BezierPath\";\nimport { Bounds } from \"./Bounds\";\nimport { UIDGenerator } from \"./UIDGenerator\";\nimport { Vertex } from \"./Vertex\";\n/**\n * @classdesc A polygon class. Any polygon consists of an array of vertices; polygons can be open or closed.\n *\n * @requires BezierPath\n * @requires Bounds\n * @requires SVGSerializabe\n * @requires UID\n * @requires UIDGenerator\n * @requires Vertex\n * @requires XYCoords\n */\nexport class Polygon {\n    /**\n     * The constructor.\n     *\n     * @constructor\n     * @name Polygon\n     * @param {Vertex[]} vertices - An array of 2d vertices that shape the polygon.\n     * @param {boolean} isOpen - Indicates if the polygon should be rendered as an open or closed shape.\n     **/\n    constructor(vertices, isOpen) {\n        /**\n         * Required to generate proper CSS classes and other class related IDs.\n         **/\n        this.className = \"Polygon\";\n        this.uid = UIDGenerator.next();\n        if (typeof vertices == \"undefined\")\n            vertices = [];\n        this.vertices = vertices;\n        this.isOpen = isOpen || false;\n    }\n    /**\n     * Add a vertex to the end of the `vertices` array.\n     *\n     * @method addVert\n     * @param {Vertex} vert - The vertex to add.\n     * @instance\n     * @memberof Polygon\n     **/\n    addVertex(vert) {\n        this.vertices.push(vert);\n    }\n    /**\n     * Get the polygon vertex at the given position (index).\n     *\n     * The index may exceed the total vertex count, and will be wrapped around then (modulo).\n     *\n     * For k >= 0:\n     *  - getVertexAt( vertices.length )     == getVertexAt( 0 )\n     *  - getVertexAt( vertices.length + k ) == getVertexAt( k )\n     *  - getVertexAt( -k )                  == getVertexAt( vertices.length -k )\n     *\n     * @metho getVertexAt\n     * @param {number} index - The index of the desired vertex.\n     * @instance\n     * @memberof Polygon\n     * @return {Vertex} At the given index.\n     **/\n    getVertexAt(index) {\n        if (index < 0)\n            return this.vertices[this.vertices.length - (Math.abs(index) % this.vertices.length)];\n        else\n            return this.vertices[index % this.vertices.length];\n    }\n    /**\n     * Move the polygon's vertices by the given amount.\n     *\n     * @method move\n     * @param {XYCoords} amount - The amount to move.\n     * @instance\n     * @memberof Polygon\n     * @return {Polygon} this for chaining\n     **/\n    move(amount) {\n        for (var i in this.vertices) {\n            this.vertices[i].add(amount);\n        }\n        return this;\n    }\n    /**\n     * Check if the given vertex is inside this polygon.<br>\n     * <br>\n     * Ray-casting algorithm found at<br>\n     *    https://stackoverflow.com/questions/22521982/check-if-point-inside-a-polygon\n     *\n     * @method containsVert\n     * @param {XYCoords} vert - The vertex to check. The new x-component.\n     * @return {boolean} True if the passed vertex is inside this polygon. The polygon is considered closed.\n     * @instance\n     * @memberof Polygon\n     **/\n    containsVert(vert) {\n        // ray-casting algorithm based on\n        //    http://www.ecse.rpi.edu/Homepages/wrf/Research/Short_Notes/pnpoly.html\n        var inside = false;\n        for (var i = 0, j = this.vertices.length - 1; i < this.vertices.length; j = i++) {\n            let xi = this.vertices[i].x, yi = this.vertices[i].y;\n            let xj = this.vertices[j].x, yj = this.vertices[j].y;\n            var intersect = yi > vert.y != yj > vert.y && vert.x < ((xj - xi) * (vert.y - yi)) / (yj - yi) + xi;\n            if (intersect)\n                inside = !inside;\n        }\n        return inside;\n    }\n    /**\n     * Calculate the area of the given polygon (unsigned).\n     *\n     * Note that this does not work for self-intersecting polygons.\n     *\n     * @method area\n     * @instance\n     * @memberof Polygon\n     * @return {number}\n     */\n    area() {\n        return Polygon.utils.area(this.vertices);\n    }\n    /**\n     * Calulate the signed polyon area by interpreting the polygon as a matrix\n     * and calculating its determinant.\n     *\n     * @method signedArea\n     * @instance\n     * @memberof Polygon\n     * @return {number}\n     */\n    signedArea() {\n        return Polygon.utils.signedArea(this.vertices);\n    }\n    /**\n     * Get the winding order of this polgon: clockwise or counterclockwise.\n     *\n     * @method isClockwise\n     * @instance\n     * @memberof Polygon\n     * @return {boolean}\n     */\n    isClockwise() {\n        return Polygon.utils.signedArea(this.vertices) < 0;\n    }\n    /**\n     * Get the perimeter of this polygon.\n     * The perimeter is the absolute length of the outline.\n     *\n     * If this polygon is open then the last segment (connecting the first and the\n     * last vertex) will be skipped.\n     *\n     * @method perimeter\n     * @instance\n     * @memberof Polygon\n     * @return {number}\n     */\n    perimeter() {\n        let length = 0;\n        for (var i = 1; i < this.vertices.length; i++) {\n            length += this.vertices[i - 1].distance(this.vertices[i]);\n        }\n        if (!this.isOpen && this.vertices.length > 1) {\n            length += this.vertices[0].distance(this.vertices[this.vertices.length - 1]);\n        }\n        return length;\n    }\n    /**\n     * Scale the polygon relative to the given center.\n     *\n     * @method scale\n     * @param {number} factor - The scale factor.\n     * @param {Vertex} center - The center of scaling.\n     * @return {Polygon} this, for chaining.\n     * @instance\n     * @memberof Polygon\n     **/\n    scale(factor, center) {\n        for (var i in this.vertices) {\n            if (typeof this.vertices[i].scale == \"function\")\n                this.vertices[i].scale(factor, center);\n            else\n                console.log(\"There seems to be a null vertex!\", this.vertices[i]);\n        }\n        return this;\n    }\n    /**\n     * Rotate the polygon around the given center.\n     *\n     * @method rotate\n     * @param {number} angle  - The rotation angle.\n     * @param {Vertex} center - The center of rotation.\n     * @instance\n     * @memberof Polygon\n     * @return {Polygon} this, for chaining.\n     **/\n    rotate(angle, center) {\n        for (var i in this.vertices) {\n            this.vertices[i].rotate(angle, center);\n        }\n        return this;\n    }\n    /**\n     * Convert this polygon into a new polygon with n evenly distributed vertices.\n     *\n     * @param {number} pointCount - Must not be negative.\n     */\n    getEvenDistributionPolygon(pointCount) {\n        if (pointCount <= 0) {\n            throw new Error(\"pointCount must be larger than zero; is \" + pointCount + \".\");\n        }\n        const result = new Polygon([], this.isOpen);\n        if (this.vertices.length === 0) {\n            return result;\n        }\n        // Fetch and add the start point from the source polygon\n        let polygonPoint = new Vertex(this.vertices[0]);\n        result.vertices.push(polygonPoint);\n        if (this.vertices.length === 1) {\n            return result;\n        }\n        const perimeter = this.perimeter();\n        const stepSize = perimeter / pointCount;\n        const n = this.vertices.length;\n        let polygonIndex = 1;\n        let nextPolygonPoint = new Vertex(this.vertices[1]);\n        let segmentLength = polygonPoint.distance(nextPolygonPoint);\n        let loopMax = this.isOpen ? n : n + 1;\n        let curSegmentU = stepSize;\n        var i = 1;\n        while (i < pointCount && polygonIndex < loopMax) {\n            // Check if next eq point is inside this segment\n            if (curSegmentU < segmentLength) {\n                let newPoint = polygonPoint.clone().lerpAbs(nextPolygonPoint, curSegmentU);\n                result.vertices.push(newPoint);\n                curSegmentU += stepSize;\n                i++;\n            }\n            else {\n                polygonIndex++;\n                polygonPoint = nextPolygonPoint;\n                nextPolygonPoint = new Vertex(this.vertices[polygonIndex % n]);\n                curSegmentU = curSegmentU - segmentLength;\n                segmentLength = polygonPoint.distance(nextPolygonPoint);\n            }\n        }\n        return result;\n    }\n    /**\n     * Get the bounding box (bounds) of this polygon.\n     *\n     * @method getBounds\n     * @instance\n     * @memberof Polygon\n     * @return {Bounds} The rectangular bounds of this polygon.\n     **/\n    getBounds() {\n        return Bounds.computeFromVertices(this.vertices);\n    }\n    /**\n     * Create a deep copy of this polygon.\n     *\n     * @return {Polygon} The cloned polygon.\n     */\n    clone() {\n        return new Polygon(this.vertices.map(vert => vert.clone()), this.isOpen);\n    }\n    /**\n     * Convert this polygon to a sequence of quadratic Bézier curves.<br>\n     * <br>\n     * The first vertex in the returned array is the start point.<br>\n     * The following sequence are pairs of control-point-and-end-point:\n     * <pre>startPoint, controlPoint0, pathPoint1, controlPoint1, pathPoint2, controlPoint2, ..., endPoint</pre>\n     *\n     * @method toQuadraticBezierData\n     * @return {Vertex[]}  An array of 2d vertices that shape the quadratic Bézier curve.\n     * @instance\n     * @memberof Polygon\n     **/\n    toQuadraticBezierData() {\n        if (this.vertices.length < 3)\n            return [];\n        var qbezier = [];\n        var cc0 = this.vertices[0];\n        var cc1 = this.vertices[1];\n        var edgeCenter = new Vertex(cc0.x + (cc1.x - cc0.x) / 2, cc0.y + (cc1.y - cc0.y) / 2);\n        qbezier.push(edgeCenter);\n        var limit = this.isOpen ? this.vertices.length : this.vertices.length + 1;\n        for (var t = 1; t < limit; t++) {\n            cc0 = this.vertices[t % this.vertices.length];\n            cc1 = this.vertices[(t + 1) % this.vertices.length];\n            var edgeCenter = new Vertex(cc0.x + (cc1.x - cc0.x) / 2, cc0.y + (cc1.y - cc0.y) / 2);\n            qbezier.push(cc0);\n            qbezier.push(edgeCenter);\n            cc0 = cc1;\n        }\n        return qbezier;\n    }\n    /**\n     * Convert this polygon to a quadratic bezier curve, represented as an SVG data string.\n     *\n     * @method toQuadraticBezierSVGString\n     * @return {string} The 'd' part for an SVG 'path' element.\n     * @instance\n     * @memberof Polygon\n     **/\n    toQuadraticBezierSVGString() {\n        var qdata = this.toQuadraticBezierData();\n        if (qdata.length == 0)\n            return \"\";\n        var buffer = [\"M \" + qdata[0].x + \" \" + qdata[0].y];\n        for (var i = 1; i < qdata.length; i += 2) {\n            buffer.push(\"Q \" + qdata[i].x + \" \" + qdata[i].y + \", \" + qdata[i + 1].x + \" \" + qdata[i + 1].y);\n        }\n        return buffer.join(\" \");\n    }\n    /**\n     * Convert this polygon to a sequence of cubic Bézier curves.<br>\n     * <br>\n     * The first vertex in the returned array is the start point.<br>\n     * The following sequence are triplets of (first-control-point, secnond-control-point, end-point):<br>\n     * <pre>startPoint, controlPoint0_0, controlPoint1_1, pathPoint1, controlPoint1_0, controlPoint1_1, ..., endPoint</pre>\n     *\n     * @method toCubicBezierData\n     * @param {number=} threshold - An optional threshold (default=1.0) how strong the curve segments\n     *                              should over-/under-drive. Should be between 0.0 and 1.0 for best\n     *                              results but other values are allowed.\n     * @return {Vertex[]}  An array of 2d vertices that shape the cubic Bézier curve.\n     * @instance\n     * @memberof Polygon\n     **/\n    toCubicBezierData(threshold) {\n        if (typeof threshold == \"undefined\")\n            threshold = 1.0;\n        if (this.vertices.length < 3)\n            return [];\n        var cbezier = [];\n        var a = this.vertices[0];\n        var b = this.vertices[1];\n        var edgeCenter = new Vertex(a.x + (b.x - a.x) / 2, a.y + (b.y - a.y) / 2);\n        cbezier.push(edgeCenter);\n        var limit = this.isOpen ? this.vertices.length - 1 : this.vertices.length;\n        for (var t = 0; t < limit; t++) {\n            var a = this.vertices[t % this.vertices.length];\n            var b = this.vertices[(t + 1) % this.vertices.length];\n            var c = this.vertices[(t + 2) % this.vertices.length];\n            var aCenter = new Vertex(a.x + (b.x - a.x) / 2, a.y + (b.y - a.y) / 2);\n            var bCenter = new Vertex(b.x + (c.x - b.x) / 2, b.y + (c.y - b.y) / 2);\n            var a2 = new Vertex(aCenter.x + (b.x - aCenter.x) * threshold, aCenter.y + (b.y - aCenter.y) * threshold);\n            var b0 = new Vertex(bCenter.x + (b.x - bCenter.x) * threshold, bCenter.y + (b.y - bCenter.y) * threshold);\n            cbezier.push(a2);\n            cbezier.push(b0);\n            cbezier.push(bCenter);\n        }\n        return cbezier;\n    }\n    /**\n     * Convert this polygon to a cubic bezier curve, represented as an SVG data string.\n     *\n     * @method toCubicBezierSVGString\n     * @return {string} The 'd' part for an SVG 'path' element.\n     * @instance\n     * @memberof Polygon\n     **/\n    toCubicBezierSVGString(threshold) {\n        var qdata = this.toCubicBezierData(threshold);\n        if (qdata.length == 0)\n            return \"\";\n        var buffer = [\"M \" + qdata[0].x + \" \" + qdata[0].y];\n        for (var i = 1; i < qdata.length; i += 3) {\n            buffer.push(\"C \" +\n                qdata[i].x +\n                \" \" +\n                qdata[i].y +\n                \", \" +\n                qdata[i + 1].x +\n                \" \" +\n                qdata[i + 1].y +\n                \", \" +\n                qdata[i + 2].x +\n                \" \" +\n                qdata[i + 2].y);\n        }\n        return buffer.join(\" \");\n    }\n    /**\n     * Convert this polygon to a cubic bezier path instance.\n     *\n     * @method toCubicBezierPath\n     * @param {number} threshold - The threshold, usually from 0.0 to 1.0.\n     * @return {BezierPath}      - A bezier path instance.\n     * @instance\n     * @memberof Polygon\n     **/\n    toCubicBezierPath(threshold) {\n        var qdata = this.toCubicBezierData(threshold);\n        // Conver the linear path vertices to a two-dimensional path array\n        var pathdata = [];\n        for (var i = 0; i + 3 < qdata.length; i += 3) {\n            pathdata.push([qdata[i], qdata[i + 3], qdata[i + 1], qdata[i + 2]]);\n        }\n        return BezierPath.fromArray(pathdata);\n    }\n    /**\n     * This function should invalidate any installed listeners and invalidate this object.\n     * After calling this function the object might not hold valid data any more and\n     * should not be used.\n     */\n    destroy() {\n        for (var i = 0; i < this.vertices.length; i++) {\n            this.vertices[i].destroy();\n        }\n        this.isDestroyed = true;\n    }\n}\nPolygon.utils = {\n    /**\n     * Calculate the area of the given polygon (unsigned).\n     *\n     * Note that this does not work for self-intersecting polygons.\n     *\n     * @name area\n     * @return {number}\n     */\n    area(vertices) {\n        // Found at:\n        //    https://stackoverflow.com/questions/16285134/calculating-polygon-area\n        let total = 0.0;\n        for (var i = 0, l = vertices.length; i < l; i++) {\n            const addX = vertices[i].x;\n            const addY = vertices[(i + 1) % l].y;\n            const subX = vertices[(i + 1) % l].x;\n            const subY = vertices[i].y;\n            total += addX * addY * 0.5;\n            total -= subX * subY * 0.5;\n        }\n        return Math.abs(total);\n    },\n    /**\n     * Calulate the signed polyon area by interpreting the polygon as a matrix\n     * and calculating its determinant.\n     *\n     * @name signedArea\n     * @return {number}\n     */\n    signedArea(vertices) {\n        let sum = 0;\n        const n = vertices.length;\n        for (var i = 0; i < n; i++) {\n            const j = (i + 1) % n;\n            sum += (vertices[j].x - vertices[i].x) * (vertices[i].y + vertices[j].y);\n        }\n        return sum;\n    }\n};\n//# sourceMappingURL=Polygon.js.map","/**\n * @author   Ikaros Kappler\n * @date     2020-05-11\n * @modified 2020-10-30 Added the static computeFromVertices function.\n * @modified 2020-11-19 Set min, max, width and height to private.\n * @modified 2021-02-02 Added the `toPolygon` method.\n * @modified 2021-06-21 (mid-summer) Added `getCenter` method.\n * @modified 2022-02-01 Added the `toString` function.\n * @modified 2022-10-09 Added the `fromDimension` function.\n * @modified 2022-11-28 Added the `clone` method.\n * @version  1.6.0\n **/\nimport { Polygon } from \"./Polygon\";\nimport { Vertex } from \"./Vertex\";\n/**\n * @classdesc A bounds class with min and max values. Implementing IBounds.\n *\n * @requires XYCoords\n * @requires Vertex\n * @requires IBounds\n **/\nexport class Bounds {\n    /**\n     * The constructor.\n     *\n     * @constructor\n     * @name Bounds\n     * @param {XYCoords} min - The min values (x,y) as a XYCoords tuple.\n     * @param {XYCoords} max - The max values (x,y) as a XYCoords tuple.\n     **/\n    constructor(min, max) {\n        this.min = min;\n        this.max = max;\n        this.width = max.x - min.x;\n        this.height = max.y - min.y;\n    }\n    /**\n     * Convert this rectangular bounding box to a polygon with four vertices.\n     *\n     * @method toPolygon\n     * @instance\n     * @memberof Bounds\n     * @return {Polygon} This bound rectangle as a polygon.\n     */\n    toPolygon() {\n        return new Polygon([new Vertex(this.min), new Vertex(this.max.x, this.min.y), new Vertex(this.max), new Vertex(this.min.x, this.max.y)], false);\n    }\n    /**\n     * Get the center of this boinding box.\n     *\n     * @method getCenter\n     * @instance\n     * @memberof Bounds\n     * @returns {Vertex} The center of these bounds.\n     */\n    getCenter() {\n        return new Vertex(this.min.x + (this.max.x - this.min.x) / 2.0, this.min.y + (this.max.y - this.min.y) / 2);\n    }\n    /**\n     * Convert these bounds to a human readable form.\n     *\n     * Note: the returned format might change in the future, so please do not\n     * rely on the returned string format.\n     *\n     * @method toString\n     * @instance\n     * @memberof Bounds\n     * @returns {string} Get these bounds in a human readable form.\n     */\n    toString() {\n        return `{ min: ${this.min.toString()}, max : ${this.max.toString()}, width: ${this.width}, height : ${this.height} }`;\n    }\n    /**\n     * Clone this bounds object (create a deep clone).\n     *\n     * @method clone\n     * @instance\n     * @memberof Bounds\n     * @returns {Bounds} Creates a deep clone of this bounds object.\n     */\n    clone() {\n        return new Bounds({ x: this.min.x, y: this.min.y }, { x: this.max.x, y: this.max.y });\n    }\n    /**\n     * Compute the minimal bounding box for a given set of vertices.\n     *\n     * An empty vertex array will return an empty bounding box located at (0,0).\n     *\n     * @static\n     * @method computeFromVertices\n     * @memberof Bounds\n     * @param {Array<Vertex>} vertices - The set of vertices you want to get the bounding box for.\n     * @return The minimal Bounds for the given vertices.\n     **/\n    static computeFromVertices(vertices) {\n        if (vertices.length == 0)\n            return new Bounds(new Vertex(0, 0), new Vertex(0, 0));\n        let xMin = vertices[0].x;\n        let xMax = vertices[0].x;\n        let yMin = vertices[0].y;\n        let yMax = vertices[0].y;\n        let vert;\n        for (var i in vertices) {\n            vert = vertices[i];\n            xMin = Math.min(xMin, vert.x);\n            xMax = Math.max(xMax, vert.x);\n            yMin = Math.min(yMin, vert.y);\n            yMax = Math.max(yMax, vert.y);\n        }\n        return new Bounds(new Vertex(xMin, yMin), new Vertex(xMax, yMax));\n    }\n    /**\n     * Create a new `Bounds` instance just from `width` and `height`, located at (0,0) or the optionally given origin.\n     *\n     * @param {number} width - The width of the bounds\n     * @param {number} height  - The height of the bounds\n     * @param {XYCoords={x:0,y:0}} origin - [optional] A origin to locate the new Bounds object at.\n     * @returns {Bounds} A new `Bounds` instance width given width and height, located at (0,0) or the given origin..\n     */\n    static fromDimension(width, height, origin) {\n        return new Bounds(origin !== null && origin !== void 0 ? origin : { x: 0, y: 0 }, { x: (origin ? origin.x : 0) + width, y: (origin ? origin.y : 0) + height });\n    }\n} // END class bounds\n//# sourceMappingURL=Bounds.js.map","/**\n * @author Ikaros Kappler\n * @date   2020-03-24\n * @modified 2020-05-04 Fixed a serious bug in the pointDistance function.\n * @modified 2020-05-12 The angle(line) param was still not optional. Changed that.\n * @modified 2020-11-11 Generalized the `add` and `sub` param from `Vertex` to `XYCoords`.\n * @modified 2020-12-04 Changed`vtutils.dist2` params from `Vertex` to `XYCoords` (generalized).\n * @modified 2020-12-04 Changed `getClosestT` param from `Vertex` to `XYCoords` (generalized).\n * @modified 2020-12-04 Added the `hasPoint(XYCoords)` function.\n * @modified 2021-01-20 Added UID.\n * @modified 2022-02-02 Added the `destroy` method.\n * @version 1.2.0\n */\nimport { Vertex } from \"./Vertex\";\nimport { UIDGenerator } from \"./UIDGenerator\";\n/**\n * @classdesc An abstract base classes for vertex tuple constructs, like Lines or Vectors.\n * @abstract\n * @requires UID\n * @requires Vertex\n * @requires XYCoords\n */\nexport class VertTuple {\n    /**\n     * Creates an instance.\n     *\n     * @constructor\n     * @name VertTuple\n     * @param {Vertex} a The tuple's first point.\n     * @param {Vertex} b The tuple's second point.\n     **/\n    constructor(a, b, factory) {\n        this.uid = UIDGenerator.next();\n        this.a = a;\n        this.b = b;\n        this.factory = factory;\n    }\n    /**\n     * Get the length of this line.\n     *\n     * @method length\n     * @instance\n     * @memberof VertTuple\n     **/\n    length() {\n        return Math.sqrt(Math.pow(this.b.x - this.a.x, 2) + Math.pow(this.b.y - this.a.y, 2));\n    }\n    /**\n     * Set the length of this vector to the given amount. This only works if this\n     * vector is not a null vector.\n     *\n     * @method setLength\n     * @param {number} length - The desired length.\n     * @memberof VertTuple\n     * @return {T} this (for chaining)\n     **/\n    setLength(length) {\n        return this.scale(length / this.length());\n    }\n    /**\n     * Substract the given vertex from this line's end points.\n     *\n     * @method sub\n     * @param {XYCoords} amount The amount (x,y) to substract.\n     * @return {VertTuple} this\n     * @instance\n     * @memberof VertTuple\n     **/\n    sub(amount) {\n        this.a.sub(amount);\n        this.b.sub(amount);\n        return this;\n    }\n    /**\n     * Add the given vertex to this line's end points.\n     *\n     * @method add\n     * @param {XYCoords} amount The amount (x,y) to add.\n     * @return {Line} this\n     * @instance\n     * @memberof VertTuple\n     **/\n    add(amount) {\n        this.a.add(amount);\n        this.b.add(amount);\n        return this;\n    }\n    /**\n     * Normalize this line (set to length 1).\n     *\n     * @method normalize\n     * @return {VertTuple} this\n     * @instance\n     * @memberof VertTuple\n     **/\n    normalize() {\n        this.b.set(this.a.x + (this.b.x - this.a.x) / this.length(), this.a.y + (this.b.y - this.a.y) / this.length());\n        return this;\n    }\n    /**\n     * Scale this line by the given factor.\n     *\n     * @method scale\n     * @param {number} factor The factor for scaling (1.0 means no scale).\n     * @return {VertTuple} this\n     * @instance\n     * @memberof VertTuple\n     **/\n    scale(factor) {\n        this.b.set(this.a.x + (this.b.x - this.a.x) * factor, this.a.y + (this.b.y - this.a.y) * factor);\n        return this;\n    }\n    /**\n     * Move this line to a new location.\n     *\n     * @method moveTo\n     * @param {Vertex} newA - The new desired location of 'a'. Vertex 'b' will be moved, too.\n     * @return {VertTuple} this\n     * @instance\n     * @memberof VertTuple\n     **/\n    moveTo(newA) {\n        let diff = this.a.difference(newA);\n        this.a.add(diff);\n        this.b.add(diff);\n        return this;\n    }\n    /**\n     * Get the angle between this and the passed line (in radians).\n     *\n     * @method angle\n     * @param {VertTuple} line - (optional) The line to calculate the angle to. If null the baseline (x-axis) will be used.\n     * @return {number} this\n     * @instance\n     * @memberof VertTuple\n     **/\n    angle(line) {\n        if (line == null || typeof line == \"undefined\") {\n            line = this.factory(new Vertex(0, 0), new Vertex(100, 0));\n        }\n        // Compute the angle from x axis and the return the difference :)\n        const v0 = this.b.clone().sub(this.a);\n        const v1 = line.b.clone().sub(line.a);\n        // Thank you, Javascript, for this second atan function. No additional math is needed here!\n        // The result might be negative, but isn't it usually nicer to determine angles in positive values only?\n        return Math.atan2(v1.x, v1.y) - Math.atan2(v0.x, v0.y);\n    }\n    /**\n     * Get line point at position t in [0 ... 1]:<br>\n     * <pre>[P(0)]=[A]--------------------[P(t)]------[B]=[P(1)]</pre><br>\n     * <br>\n     * The counterpart of this function is Line.getClosestT(Vertex).\n     *\n     * @method vertAt\n     * @param {number} t The position scalar.\n     * @return {Vertex} The vertex a position t.\n     * @instance\n     * @memberof VertTuple\n     **/\n    vertAt(t) {\n        return new Vertex(this.a.x + (this.b.x - this.a.x) * t, this.a.y + (this.b.y - this.a.y) * t);\n    }\n    /**\n     * Get the denominator of this and the given line.\n     *\n     * If the denominator is zero (or close to zero) both line are co-linear.\n     *\n     * @method denominator\n     * @param {VertTuple} line\n     * @instance\n     * @memberof VertTuple\n     * @return {Number}\n     **/\n    denominator(line) {\n        // http://jsfiddle.net/justin_c_rounds/Gd2S2/\n        return (line.b.y - line.a.y) * (this.b.x - this.a.x) - (line.b.x - line.a.x) * (this.b.y - this.a.y);\n    }\n    /**\n     * Checks if this and the given line are co-linear.\n     *\n     * The constant Vertex.EPSILON is used for tolerance.\n     *\n     * @method colinear\n     * @param {VertTuple} line\n     * @instance\n     * @memberof VertTuple\n     * @return true if both lines are co-linear.\n     */\n    colinear(line) {\n        return Math.abs(this.denominator(line)) < Vertex.EPSILON;\n    }\n    /**\n     * Get the closest position T from this line to the specified point.\n     *\n     * The counterpart for this function is Line.vertAt(Number).\n     *\n     * @name getClosetT\n     * @method getClosestT\n     * @param {XYCoords} p The point (vertex) to measure the distance to.\n     * @return {number} The line position t of minimal distance to p.\n     * @instance\n     * @memberof VertTuple\n     **/\n    getClosestT(p) {\n        var l2 = VertTuple.vtutils.dist2(this.a, this.b);\n        if (l2 === 0)\n            return 0;\n        var t = ((p.x - this.a.x) * (this.b.x - this.a.x) + (p.y - this.a.y) * (this.b.y - this.a.y)) / l2;\n        // Do not wrap to [0,1] here.\n        // Other results are of interest, too.\n        // t = Math.max(0, Math.min(1, t));\n        return t;\n    }\n    /**\n     * Check if the given point is located on this line. Optionally also check if\n     * that point is located between point `a` and `b`.\n     *\n     * @method hasPoint\n     * @param {Vertex} point The point to check.\n     * @param {boolean=} insideBoundsOnly If set to to true (default=false) the point must be between start and end point of the line.\n     * @return {boolean} True if the given point is on this line.\n     * @instance\n     * @memberof VertTuple\n     */\n    hasPoint(point, insideBoundsOnly) {\n        const t = this.getClosestT(point);\n        // Compare to pointDistance?\n        if (typeof insideBoundsOnly !== \"undefined\" && insideBoundsOnly) {\n            const distance = Math.sqrt(VertTuple.vtutils.dist2(point, this.vertAt(t)));\n            return distance < Vertex.EPSILON && t >= 0 && t <= 1;\n        }\n        else {\n            return t >= 0 && t <= 1;\n        }\n    }\n    /**\n     * Get the closest point on this line to the specified point.\n     *\n     * @method getClosestPoint\n     * @param {Vertex} p The point (vertex) to measre the distance to.\n     * @return {Vertex} The point on the line that is closest to p.\n     * @instance\n     * @memberof VertTuple\n     **/\n    getClosestPoint(p) {\n        var t = this.getClosestT(p);\n        return this.vertAt(t);\n    }\n    /**\n     * The the minimal distance between this line and the specified point.\n     *\n     * @method pointDistance\n     * @param {Vertex} p The point (vertex) to measre the distance to.\n     * @return {number} The absolute minimal distance.\n     * @instance\n     * @memberof VertTuple\n     **/\n    pointDistance(p) {\n        // Taken From:\n        // https://stackoverflow.com/questions/849211/shortest-distance-between-a-point-and-a-line-segment\n        return Math.sqrt(VertTuple.vtutils.dist2(p, this.vertAt(this.getClosestT(p))));\n    }\n    /**\n     * Create a deep clone of this instance.\n     *\n     * @method cloneLine\n     * @return {T} A type safe clone if this instance.\n     * @instance\n     * @memberof VertTuple\n     **/\n    clone() {\n        return this.factory(this.a.clone(), this.b.clone());\n    }\n    /**\n     * Create a string representation of this line.\n     *\n     * @method totring\n     * @return {string} The string representing this line.\n     * @instance\n     * @memberof VertTuple\n     **/\n    toString() {\n        return \"{ a : \" + this.a.toString() + \", b : \" + this.b.toString() + \" }\";\n    }\n    /**\n     * This function should invalidate any installed listeners and invalidate this object.\n     * After calling this function the object might not hold valid data any more and\n     * should not be used.\n     */\n    destroy() {\n        this.a.destroy();\n        this.b.destroy();\n        this.isDestroyed = true;\n    }\n}\n/**\n * @private\n **/\nVertTuple.vtutils = {\n    dist2: (v, w) => {\n        return (v.x - w.x) * (v.x - w.x) + (v.y - w.y) * (v.y - w.y);\n    }\n};\n//# sourceMappingURL=VertTuple.js.map","/**\n * @author   Ikaros Kappler\n * @date     2019-01-30\n * @modified 2019-02-23 Added the toSVGString function, overriding Line.toSVGString.\n * @modified 2019-03-20 Added JSDoc tags.\n * @modified 2019-04-19 Added the clone function (overriding Line.clone()).\n * @modified 2019-09-02 Added the Vector.perp() function.\n * @modified 2019-09-02 Added the Vector.inverse() function.\n * @modified 2019-12-04 Added the Vector.inv() function.\n * @modified 2020-03-23 Ported to Typescript from JS.\n * @modified 2021-01-20 Added UID.\n * @modified 2022-02-02 Added the `destroy` method.\n * @modified 2022-02-02 Cleared the `Vector.toSVGString` function (deprecated). Use `drawutilssvg` instead.\n * @modified 2022-10-25 Added the `getOrthogonal` method.\n * @version  1.5.0\n *\n * @file Vector\n * @public\n **/\nimport { VertTuple } from \"./VertTuple\";\nimport { Vertex } from \"./Vertex\";\n/**\n * @classdesc A vector (Vertex,Vertex) is a line with a visible direction.<br>\n *            <br>\n *            Vectors are drawn with an arrow at their end point.<br>\n *            <b>The Vector class extends the Line class.</b>\n *\n * @requires VertTuple\n * @requires Vertex\n **/\nexport class Vector extends VertTuple {\n    /**\n     * The constructor.\n     *\n     * @constructor\n     * @name Vector\n     * @extends Line\n     * @param {Vertex} vertA - The start vertex of the vector.\n     * @param {Vertex} vertB - The end vertex of the vector.\n     **/\n    constructor(vertA, vertB) {\n        super(vertA, vertB, (a, b) => new Vector(a, b));\n        /**\n         * Required to generate proper CSS classes and other class related IDs.\n         **/\n        this.className = \"Vector\";\n    }\n    /**\n     * Get the perpendicular of this vector which is located at a.\n     *\n     * @param {Number} t The position on the vector.\n     * @return {Vector} A new vector being the perpendicular of this vector sitting on a.\n     **/\n    perp() {\n        var v = this.clone();\n        v.sub(this.a);\n        v = new Vector(new Vertex(), new Vertex(-v.b.y, v.b.x));\n        v.a.add(this.a);\n        v.b.add(this.a);\n        return v;\n    }\n    /**\n     * The inverse of a vector is a vector with the same magnitude but oppose direction.\n     *\n     * Please not that the origin of this vector changes here: a->b becomes b->a.\n     *\n     * @return {Vector}\n     **/\n    inverse() {\n        var tmp = this.a;\n        this.a = this.b;\n        this.b = tmp;\n        return this;\n    }\n    /**\n     * This function computes the inverse of the vector, which means 'a' stays untouched.\n     *\n     * @return {Vector} this for chaining.\n     **/\n    inv() {\n        this.b.x = this.a.x - (this.b.x - this.a.x);\n        this.b.y = this.a.y - (this.b.y - this.a.y);\n        return this;\n    }\n    /**\n     * Get the intersection if this vector and the specified vector.\n     *\n     * @method intersection\n     * @param {Vector} line The second vector.\n     * @return {Vertex} The intersection (may lie outside the end-points).\n     * @instance\n     * @memberof Line\n     **/\n    intersection(line) {\n        var denominator = this.denominator(line);\n        if (denominator == 0)\n            return null;\n        var a = this.a.y - line.a.y;\n        var b = this.a.x - line.a.x;\n        var numerator1 = (line.b.x - line.a.x) * a - (line.b.y - line.a.y) * b;\n        var numerator2 = (this.b.x - this.a.x) * a - (this.b.y - this.a.y) * b;\n        a = numerator1 / denominator; // NaN if parallel lines\n        b = numerator2 / denominator;\n        // TODO:\n        // FOR A VECTOR THE LINE-INTERSECTION MUST BE ON BOTH VECTORS\n        // if we cast these lines infinitely in both directions, they intersect here:\n        return new Vertex(this.a.x + a * (this.b.x - this.a.x), this.a.y + a * (this.b.y - this.a.y));\n    }\n    /**\n     * Get the orthogonal \"vector\" of this vector (rotated by 90° clockwise).\n     *\n     * @name getOrthogonal\n     * @method getOrthogonal\n     * @return {Vector} A new vector with the same length that stands on this vector's point a.\n     * @instance\n     * @memberof Vector\n     **/\n    getOrthogonal() {\n        // Orthogonal of vector (0,0)->(x,y) is (0,0)->(-y,x)\n        const linePoint = this.a.clone();\n        const startPoint = this.b.clone().sub(this.a);\n        const tmp = startPoint.x;\n        startPoint.x = -startPoint.y;\n        startPoint.y = tmp;\n        return new Vector(linePoint, startPoint.add(this.a));\n    }\n}\nVector.utils = {\n    /**\n     * Generate a four-point arrow head, starting at the vector end minus the\n     * arrow head length.\n     *\n     * The first vertex in the returned array is guaranteed to be the located\n     * at the vector line end minus the arrow head length.\n     *\n     *\n     * Due to performance all params are required.\n     *\n     * The params scaleX and scaleY are required for the case that the scaling is not uniform (x and y\n     * scaling different). Arrow heads should not look distored on non-uniform scaling.\n     *\n     * If unsure use 1.0 for scaleX and scaleY (=no distortion).\n     * For headlen use 8, it's a good arrow head size.\n     *\n     * Example:\n     *    buildArrowHead( new Vertex(0,0), new Vertex(50,100), 8, 1.0, 1.0 )\n     *\n     * @param {Vertex} zA - The start vertex of the vector to calculate the arrow head for.\n     * @param {Vertex} zB - The end vertex of the vector.\n     * @param {number} headlen - The length of the arrow head (along the vector direction. A good value is 12).\n     * @param {number} scaleX  - The horizontal scaling during draw.\n     * @param {number} scaleY  - the vertical scaling during draw.\n     **/\n    buildArrowHead: (zA, zB, headlen, scaleX, scaleY) => {\n        const angle = Math.atan2((zB.y - zA.y) * scaleY, (zB.x - zA.x) * scaleX);\n        const vertices = [];\n        vertices.push(new Vertex(zB.x * scaleX - headlen * Math.cos(angle), zB.y * scaleY - headlen * Math.sin(angle)));\n        vertices.push(new Vertex(zB.x * scaleX - headlen * 1.35 * Math.cos(angle - Math.PI / 8), zB.y * scaleY - headlen * 1.35 * Math.sin(angle - Math.PI / 8)));\n        vertices.push(new Vertex(zB.x * scaleX, zB.y * scaleY));\n        vertices.push(new Vertex(zB.x * scaleX - headlen * 1.35 * Math.cos(angle + Math.PI / 8), zB.y * scaleY - headlen * 1.35 * Math.sin(angle + Math.PI / 8)));\n        return vertices;\n    }\n};\n//# sourceMappingURL=Vector.js.map","/**\n * @author   Ikaros Kappler\n * @date     2013-08-15\n * @modified 2018-08-16 Added a closure. Removed the wrapper class 'IKRS'. Replaced class THREE.Vector2 by Vertex class.\n * @modified 2018-11-19 Added the fromArray(Array) function.\n * @modified 2018-11-28 Added the locateCurveByPoint(Vertex) function.\n * @modified 2018-12-04 Added the toSVGPathData() function.\n * @modified 2019-03-20 Added JSDoc tags.\n * @modified 2019-03-23 Changed the signatures of getPoint, getPointAt and getTangent (!version 2.0).\n * @modified 2019-12-02 Fixed the updateArcLength function. It used the wrong pointAt function (was renamed before).\n * @modified 2020-02-06 Added the getSubCurveAt(number,number) function.\n * @modified 2020-02-06 Fixed a serious bug in the arc lenght calculation (length was never reset, urgh).\n * @modified 2020-02-07 Added the isInstance(any) function.\n * @modified 2020-02-10 Added the reverse() function.\n * @modified 2020-02-10 Fixed the translate(...) function (returning 'this' was missing).\n * @modified 2020-03-24 Ported this class from vanilla JS to Typescript.\n * @modified 2020-06-03 Added the getBounds() function.\n * @modified 2020-07-14 Changed the moveCurvePoint(...,Vertex) to moveCurvePoint(...,XYCoords), which is more generic.\n * @modified 2020-07-24 Added the getClosestT function and the helper function locateIntervalByDistance(...).\n * @modified 2021-01-20 Added UID.\n * @modified 2022-02-02 Added the `destroy` method.\n * @modified 2022-02-02 Cleared the `toSVGPathData` function (deprecated). Use `drawutilssvg` instead.\n * @modified 2022-10-17 The `CubicBezierCurve` class now implements the new `PathSegment` interface.\n * @version 2.7.1\n *\n * @file CubicBezierCurve\n * @public\n **/\nimport { Bounds } from \"./Bounds\";\nimport { UIDGenerator } from \"./UIDGenerator\";\nimport { Vertex } from \"./Vertex\";\nimport { Vector } from \"./Vector\";\n/**\n * @classdesc A refactored cubic bezier curve class.\n *\n * @requires Bounds\n * @requires Vertex\n * @requires Vector\n * @requires XYCoords\n * @requires UID\n * @requires UIDGenerator\n */\nexport class CubicBezierCurve {\n    /**\n     * The constructor.\n     *\n     * @constructor\n     * @name CubicBezierCurve\n     * @param {Vertex} startPoint - The Bézier curve's start point.\n     * @param {Vertex} endPoint   - The Bézier curve's end point.\n     * @param {Vertex} startControlPoint - The Bézier curve's start control point.\n     * @param {Vertex} endControlPoint   - The Bézier curve's end control point.\n     **/\n    constructor(startPoint, endPoint, startControlPoint, endControlPoint) {\n        /** @constant {number} */\n        this.START_POINT = CubicBezierCurve.START_POINT;\n        /** @constant {number} */\n        this.START_CONTROL_POINT = CubicBezierCurve.START_CONTROL_POINT;\n        /** @constant {number} */\n        this.END_CONTROL_POINT = CubicBezierCurve.END_CONTROL_POINT;\n        /** @constant {number} */\n        this.END_POINT = CubicBezierCurve.END_POINT;\n        this.uid = UIDGenerator.next();\n        this.startPoint = startPoint;\n        this.startControlPoint = startControlPoint;\n        this.endPoint = endPoint;\n        this.endControlPoint = endControlPoint;\n        this.curveIntervals = 30;\n        // An array of vertices\n        this.segmentCache = [];\n        // An array of floats\n        this.segmentLengths = [];\n        // float\n        // this.arcLength = null;\n        this.updateArcLengths();\n    }\n    /**\n     * Move the given curve point (the start point, end point or one of the two\n     * control points).\n     *\n     * @method moveCurvePoint\n     * @param {number} pointID - The numeric identicator of the point to move. Use one of the four eBezierPoint constants.\n     * @param {XYCoords} moveAmount - The amount to move the specified point by.\n     * @param {boolean} moveControlPoint - Move the control points along with their path point (if specified point is a path point).\n     * @param {boolean} updateArcLengths - Specifiy if the internal arc segment buffer should be updated.\n     * @instance\n     * @memberof CubicBezierCurve\n     * @return {void}\n     **/\n    moveCurvePoint(pointID, moveAmount, moveControlPoint, updateArcLengths) {\n        if (pointID == this.START_POINT) {\n            this.getStartPoint().add(moveAmount);\n            if (moveControlPoint)\n                this.getStartControlPoint().add(moveAmount);\n        }\n        else if (pointID == this.START_CONTROL_POINT) {\n            this.getStartControlPoint().add(moveAmount);\n        }\n        else if (pointID == this.END_CONTROL_POINT) {\n            this.getEndControlPoint().add(moveAmount);\n        }\n        else if (pointID == this.END_POINT) {\n            this.getEndPoint().add(moveAmount);\n            if (moveControlPoint)\n                this.getEndControlPoint().add(moveAmount);\n        }\n        else {\n            console.log(`[CubicBezierCurve.moveCurvePoint] pointID '${pointID}' invalid.`);\n        }\n        if (updateArcLengths)\n            this.updateArcLengths();\n    }\n    /**\n     * Translate the whole curve by the given {x,y} amount: moves all four points.\n     *\n     * @method translate\n     * @param {Vertex} amount - The amount to translate this curve by.\n     * @instance\n     * @memberof CubicBezierCurve\n     * @return {CubicBezierCurve} this (for chaining).\n     **/\n    translate(amount) {\n        this.startPoint.add(amount);\n        this.startControlPoint.add(amount);\n        this.endControlPoint.add(amount);\n        this.endPoint.add(amount);\n        return this;\n    }\n    /**\n     * Reverse this curve, means swapping start- and end-point and swapping\n     * start-control- and end-control-point.\n     *\n     * @method reverse\n     * @instance\n     * @memberof CubicBezierCurve\n     * @return {CubicBezierCurve} this (for chaining).\n     **/\n    reverse() {\n        let tmp = this.startPoint;\n        this.startPoint = this.endPoint;\n        this.endPoint = tmp;\n        tmp = this.startControlPoint;\n        this.startControlPoint = this.endControlPoint;\n        this.endControlPoint = tmp;\n        return this;\n    }\n    /**\n     * Get the total curve length.<br>\n     * <br>\n     * As not all Bézier curved have a closed formula to calculate their lengths, this\n     * implementation uses a segment buffer (with a length of 30 segments). So the\n     * returned length is taken from the arc segment buffer.<br>\n     * <br>\n     * Note that if the curve points were changed and the segment buffer was not\n     * updated this function might return wrong (old) values.\n     *\n     * @method getLength\n     * @instance\n     * @memberof CubicBezierCurve\n     * @return {number} >= 0\n     **/\n    getLength() {\n        return this.arcLength;\n    }\n    /**\n     * Uptate the internal arc segment buffer and their lengths.<br>\n     * <br>\n     * All class functions update the buffer automatically; if any\n     * curve point is changed by other reasons you should call this\n     * function to keep actual values in the buffer.\n     *\n     * @method updateArcLengths\n     * @instance\n     * @memberof CubicBezierCurve\n     * @return {void}\n     **/\n    updateArcLengths() {\n        let pointA = this.startPoint.clone();\n        let pointB = new Vertex(0, 0);\n        let curveStep = 1.0 / this.curveIntervals;\n        // Clear segment cache\n        this.segmentCache = [];\n        // Push start point into buffer\n        this.segmentCache.push(this.startPoint);\n        this.segmentLengths = [];\n        let newLength = 0.0;\n        var t = 0.0;\n        let tmpLength;\n        while (t <= 1.0) {\n            pointB = this.getPointAt(t);\n            // Store point into cache\n            this.segmentCache.push(pointB);\n            // Calculate segment length\n            tmpLength = pointA.distance(pointB);\n            this.segmentLengths.push(tmpLength);\n            newLength += tmpLength;\n            pointA = pointB;\n            t += curveStep;\n        }\n        this.arcLength = newLength;\n    }\n    /**\n     * Get a 't' (relative position on curve) with the closest distance to point 'p'.\n     *\n     * The returned number is 0.0 <= t <= 1.0. Use the getPointAt(t) function to retrieve the actual curve point.\n     *\n     * This function uses a recursive approach by cutting the curve into several linear segments.\n     *\n     * @param {Vertex} p - The point to find the closest position ('t' on the curve).\n     * @return {number}\n     **/\n    getClosestT(p) {\n        // We would like to have an error that's not larger than 1.0.\n        var desiredEpsilon = 1.0;\n        var result = { t: 0, tPrev: 0.0, tNext: 1.0 };\n        var iteration = 0;\n        do {\n            result = this.locateIntervalByDistance(p, result.tPrev, result.tNext, this.curveIntervals);\n            iteration++;\n            // Be sure: stop after 4 iterations\n        } while (iteration < 4 && this.getPointAt(result.tPrev).distance(this.getPointAt(result.tNext)) > desiredEpsilon);\n        return result.t;\n    }\n    /**\n     * This helper function locates the 't' on a fixed step interval with the minimal distance\n     * between the curve (at 't') and the given point.\n     *\n     * Furthermore you must specify a sub curve (start 't' and end 't') you want to search on.\n     * Using tStart=0.0 and tEnd=1.0 will search on the full curve.\n     *\n     * @param {Vertex} p - The point to find the closest curve point for.\n     * @param {number} tStart - The start position (start 't' of the sub curve). Should be >= 0.0.\n     * @param {number} tEnd - The end position (end 't' of the sub curve). Should be <= 1.0.\n     * @param {number} stepCount - The number of steps to check within the interval.\n     *\n     * @return {object} - An object with t, tPrev and tNext (numbers).\n     **/\n    locateIntervalByDistance(p, tStart, tEnd, stepCount) {\n        var minIndex = -1;\n        var minDist = 0;\n        var t = 0.0;\n        const tDiff = tEnd - tStart;\n        for (var i = 0; i <= stepCount; i++) {\n            t = tStart + tDiff * (i / stepCount);\n            var vert = this.getPointAt(t);\n            var dist = vert.distance(p);\n            if (minIndex == -1 || dist < minDist) {\n                minIndex = i;\n                minDist = dist;\n            }\n        }\n        return {\n            t: tStart + tDiff * (minIndex / stepCount),\n            tPrev: tStart + tDiff * (Math.max(0, minIndex - 1) / stepCount),\n            tNext: tStart + tDiff * (Math.min(stepCount, minIndex + 1) / stepCount)\n        };\n    }\n    /**\n     * Get the bounds of this bezier curve.\n     *\n     * The bounds are approximated by the underlying segment buffer; the more segment there are,\n     * the more accurate will be the returned bounds.\n     *\n     * @return {Bounds} The bounds of this curve.\n     **/\n    getBounds() {\n        var min = new Vertex(Number.POSITIVE_INFINITY, Number.POSITIVE_INFINITY);\n        var max = new Vertex(Number.NEGATIVE_INFINITY, Number.NEGATIVE_INFINITY);\n        let v;\n        for (var i = 0; i < this.segmentCache.length; i++) {\n            v = this.segmentCache[i];\n            min.x = Math.min(min.x, v.x);\n            min.y = Math.min(min.y, v.y);\n            max.x = Math.max(max.x, v.x);\n            max.y = Math.max(max.y, v.y);\n        }\n        return new Bounds(min, max);\n    }\n    /**\n     * Get the start point of the curve.<br>\n     * <br>\n     * This function just returns this.startPoint.\n     *\n     * @method getStartPoint\n     * @instance\n     * @memberof CubicBezierCurve\n     * @return {Vertex} this.startPoint\n     **/\n    getStartPoint() {\n        return this.startPoint;\n    }\n    /**\n     * Get the end point of the curve.<br>\n     * <br>\n     * This function just returns this.endPoint.\n     *\n     * @method getEndPoint\n     * @instance\n     * @memberof CubicBezierCurve\n     * @return {Vertex} this.endPoint\n     **/\n    getEndPoint() {\n        return this.endPoint;\n    }\n    /**\n     * Get the start control point of the curve.<br>\n     * <br>\n     * This function just returns this.startControlPoint.\n     *\n     * @method getStartControlPoint\n     * @instance\n     * @memberof CubicBezierCurve\n     * @return {Vertex} this.startControlPoint\n     **/\n    getStartControlPoint() {\n        return this.startControlPoint;\n    }\n    /**\n     * Get the end control point of the curve.<br>\n     * <br>\n     * This function just returns this.endControlPoint.\n     *\n     * @method getEndControlPoint\n     * @instance\n     * @memberof CubicBezierCurve\n     * @return {Vertex} this.endControlPoint\n     **/\n    getEndControlPoint() {\n        return this.endControlPoint;\n    }\n    /**\n     * Get one of the four curve points specified by the passt point ID.\n     *\n     * @method getEndControlPoint\n     * @param {number} id - One of START_POINT, START_CONTROL_POINT, END_CONTROL_POINT or END_POINT.\n     * @instance\n     * @memberof CubicBezierCurve\n     * @return {Vertex}\n     **/\n    getPointByID(id) {\n        if (id == this.START_POINT)\n            return this.startPoint;\n        if (id == this.END_POINT)\n            return this.endPoint;\n        if (id == this.START_CONTROL_POINT)\n            return this.startControlPoint;\n        if (id == this.END_CONTROL_POINT)\n            return this.endControlPoint;\n        throw new Error(`Invalid point ID '${id}'.`);\n    }\n    /**\n     * Get the curve point at a given position t, where t is in [0,1].<br>\n     * <br>\n     * @see Line.pointAt\n     *\n     * @method getPointAt\n     * @param {number} t - The position on the curve in [0,1] (0 means at\n     *                     start point, 1 means at end point, other values address points in bertween).\n     * @instance\n     * @memberof CubicBezierCurve\n     * @return {Vertex}\n     **/\n    getPointAt(t) {\n        // Perform some powerful math magic\n        const x = this.startPoint.x * Math.pow(1.0 - t, 3) +\n            this.startControlPoint.x * 3 * t * Math.pow(1.0 - t, 2) +\n            this.endControlPoint.x * 3 * Math.pow(t, 2) * (1.0 - t) +\n            this.endPoint.x * Math.pow(t, 3);\n        const y = this.startPoint.y * Math.pow(1.0 - t, 3) +\n            this.startControlPoint.y * 3 * t * Math.pow(1.0 - t, 2) +\n            this.endControlPoint.y * 3 * Math.pow(t, 2) * (1.0 - t) +\n            this.endPoint.y * Math.pow(t, 3);\n        return new Vertex(x, y);\n    }\n    /**\n     * Get the curve point at a given position u, where u is in [0,arcLength].<br>\n     * <br>\n     * @see CubicBezierCurve.getPointAt\n     *\n     * @method getPoint\n     * @param {number} u - The position on the curve in [0,arcLength] (0 means at\n     *                     start point, arcLength means at end point, other values address points in bertween).\n     * @instance\n     * @memberof CubicBezierCurve\n     * @return {Vertex}\n     **/\n    getPoint(u) {\n        return this.getPointAt(u / this.arcLength);\n    }\n    /**\n     * Get the curve tangent vector at a given absolute curve position t in [0,1].<br>\n     * <br>\n     * Note that the returned tangent vector (end point) is not normalized and relative to (0,0).\n     *\n     * @method getTangent\n     * @param {number} t - The position on the curve in [0,1].\n     * @instance\n     * @memberof CubicBezierCurve\n     * @return {Vertex}\n     **/\n    getTangentAt(t) {\n        const a = this.getStartPoint();\n        const b = this.getStartControlPoint();\n        const c = this.getEndControlPoint();\n        const d = this.getEndPoint();\n        // This is the shortened one\n        const t2 = t * t;\n        // (1 - t)^2 = (1-t)*(1-t) = 1 - t - t + t^2 = 1 - 2*t + t^2\n        const nt2 = 1 - 2 * t + t2;\n        const tX = -3 * a.x * nt2 + b.x * (3 * nt2 - 6 * (t - t2)) + c.x * (6 * (t - t2) - 3 * t2) + 3 * d.x * t2;\n        const tY = -3 * a.y * nt2 + b.y * (3 * nt2 - 6 * (t - t2)) + c.y * (6 * (t - t2) - 3 * t2) + 3 * d.y * t2;\n        // Note: my implementation does NOT normalize tangent vectors!\n        return new Vertex(tX, tY);\n    }\n    /**\n     * Get a sub curve at the given start end end offsets (values between 0.0 and 1.0).\n     *\n     * tStart >= tEnd is allowed, you will get a reversed sub curve then.\n     *\n     * @method getSubCurveAt\n     * @param {number} tStart – The start offset of the desired sub curve (must be in [0..1]).\n     * @param {number} tEnd – The end offset if the desired cub curve (must be in [0..1]).\n     * @instance\n     * @memberof CubicBezierCurve\n     * @return {CubicBezierCurve} The sub curve as a new curve.\n     **/\n    getSubCurveAt(tStart, tEnd) {\n        const startVec = new Vector(this.getPointAt(tStart), this.getTangentAt(tStart));\n        const endVec = new Vector(this.getPointAt(tEnd), this.getTangentAt(tEnd).inv());\n        // Tangents are relative. Make absolute.\n        startVec.b.add(startVec.a);\n        endVec.b.add(endVec.a);\n        // This 'splits' the curve at the given point at t.\n        startVec.scale(0.33333333 * (tEnd - tStart));\n        endVec.scale(0.33333333 * (tEnd - tStart));\n        // Draw the bezier curve\n        // pb.draw.cubicBezier( startVec.a, endVec.a, startVec.b, endVec.b, '#8800ff', 2 );\n        return new CubicBezierCurve(startVec.a, endVec.a, startVec.b, endVec.b);\n    }\n    /**\n     * Convert a relative curve position u to the absolute curve position t.\n     *\n     * @method convertU2t\n     * @param {number} u - The relative position on the curve in [0,arcLength].\n     * @instance\n     * @memberof CubicBezierCurve\n     * @return {number}\n     **/\n    convertU2T(u) {\n        return Math.max(0.0, Math.min(1.0, u / this.arcLength));\n    }\n    /**\n     * Get the curve tangent vector at a given relative position u in [0,arcLength].<br>\n     * <br>\n     * Note that the returned tangent vector (end point) is not normalized.\n     *\n     * @method getTangent\n     * @param {number} u - The position on the curve in [0,arcLength].\n     * @instance\n     * @memberof CubicBezierCurve\n     * @return {Vertex}\n     **/\n    getTangent(u) {\n        return this.getTangentAt(this.convertU2T(u));\n    }\n    /**\n     * Get the curve perpendicular at a given relative position u in [0,arcLength] as a vector.<br>\n     * <br>\n     * Note that the returned vector (end point) is not normalized.\n     *\n     * @method getPerpendicular\n     * @param {number} u - The relative position on the curve in [0,arcLength].\n     * @instance\n     * @memberof CubicBezierCurve\n     * @return {Vertex}\n     **/\n    getPerpendicular(u) {\n        return this.getPerpendicularAt(this.convertU2T(u));\n    }\n    /**\n     * Get the curve perpendicular at a given absolute position t in [0,1] as a vector.<br>\n     * <br>\n     * Note that the returned vector (end point) is not normalized.\n     *\n     * @method getPerpendicularAt\n     * @param {number} u - The absolute position on the curve in [0,1].\n     * @instance\n     * @memberof CubicBezierCurve\n     * @return {Vertex}\n     **/\n    getPerpendicularAt(t) {\n        const tangentVector = this.getTangentAt(t);\n        return new Vertex(tangentVector.y, -tangentVector.x);\n    }\n    /**\n     * Clone this Bézier curve (deep clone).\n     *\n     * @method clone\n     * @instance\n     * @memberof CubicBezierCurve\n     * @return {CubicBezierCurve}\n     **/\n    clone() {\n        return new CubicBezierCurve(this.getStartPoint().clone(), this.getEndPoint().clone(), this.getStartControlPoint().clone(), this.getEndControlPoint().clone());\n    }\n    //---BEGIN PathSegment-------------------------\n    /**\n     * Get the tangent's end point at the start point of this segment.\n     *\n     * @method getStartTangent\n     * @memberof PathSegment\n     * @return {Vertex} The end point of the starting point's tangent.\n     */\n    getStartTangent() {\n        return this.startControlPoint;\n    }\n    /**\n     * Get the tangent's end point at the end point of this segment.\n     *\n     * @method getEndTangent\n     * @memberof PathSegment\n     * @return {Vertex} The end point of the ending point's tangent.\n     */\n    getEndTangent() {\n        return this.endControlPoint;\n    }\n    //---END PathSegment-------------------------\n    /**\n     * Check if this and the specified curve are equal.<br>\n     * <br>\n     * All four points need to be equal for this, the Vertex.equals function is used.<br>\n     * <br>\n     * Please note that this function is not type safe (comparison with any object will fail).\n     *\n     * @method clone\n     * @param {CubicBezierCurve} curve - The curve to compare with.\n     * @instance\n     * @memberof CubicBezierCurve\n     * @return {boolean}\n     **/\n    equals(curve) {\n        // Note: in the earlier vanilla-JS version this was callable with plain objects.\n        //       Let's see if this restricted version works out.\n        if (!curve)\n            return false;\n        if (!curve.startPoint || !curve.endPoint || !curve.startControlPoint || !curve.endControlPoint)\n            return false;\n        return (this.startPoint.equals(curve.startPoint) &&\n            this.endPoint.equals(curve.endPoint) &&\n            this.startControlPoint.equals(curve.startControlPoint) &&\n            this.endControlPoint.equals(curve.endControlPoint));\n    }\n    /**\n     * This function should invalidate any installed listeners and invalidate this object.\n     * After calling this function the object might not hold valid data any more and\n     * should not be used.\n     */\n    destroy() {\n        this.startPoint.destroy();\n        this.endPoint.destroy();\n        this.startControlPoint.destroy();\n        this.endControlPoint.destroy();\n        this.isDestroyed = true;\n    }\n    /**\n     * Quick check for class instance.\n     * Is there a better way?\n     *\n     * @method isInstance\n     * @param {any} obj - Check if the passed object/value is an instance of CubicBezierCurve.\n     * @instance\n     * @memberof CubicBezierCurve\n     * @return {boolean}\n     **/\n    static isInstance(obj) {\n        // Note: check this again\n        /* OLD VANILLA JS IMPLEMENTATION */\n        /* if( typeof obj != \"object\" )\n            return false;\n        function hasXY(v) {\n            return typeof v != \"undefined\" && typeof v.x == \"number\" && typeof v.y == \"number\";\n        }\n        return typeof obj.startPoint == \"object\" && hasXY(obj.startPoint)\n            && typeof obj.endPoint == \"object\" && hasXY(obj.endPoint)\n            && typeof obj.startControlPoint == \"object\" && hasXY(obj.startControlPoint)\n            && typeof obj.endControlPoint == \"object\" && hasXY(obj.endControlPoint);\n        */\n        return obj instanceof CubicBezierCurve;\n    }\n    /**\n     * Convert this curve to a JSON string.\n     *\n     * @method toJSON\n     * @param {boolean=} [prettyFormat=false] - If set to true the function will add line breaks.\n     * @instance\n     * @memberof CubicBezierCurve\n     * @return {string} The JSON data.\n     **/\n    toJSON(prettyFormat) {\n        var jsonString = \"{ \" + // begin object\n            (prettyFormat ? \"\\n\\t\" : \"\") +\n            '\"startPoint\" : [' +\n            this.getStartPoint().x +\n            \",\" +\n            this.getStartPoint().y +\n            \"], \" +\n            (prettyFormat ? \"\\n\\t\" : \"\") +\n            '\"endPoint\" : [' +\n            this.getEndPoint().x +\n            \",\" +\n            this.getEndPoint().y +\n            \"], \" +\n            (prettyFormat ? \"\\n\\t\" : \"\") +\n            '\"startControlPoint\": [' +\n            this.getStartControlPoint().x +\n            \",\" +\n            this.getStartControlPoint().y +\n            \"], \" +\n            (prettyFormat ? \"\\n\\t\" : \"\") +\n            '\"endControlPoint\" : [' +\n            this.getEndControlPoint().x +\n            \",\" +\n            this.getEndControlPoint().y +\n            \"]\" +\n            (prettyFormat ? \"\\n\\t\" : \"\") +\n            \" }\"; // end object\n        return jsonString;\n    }\n    /**\n     * Parse a Bézier curve from the given JSON string.\n     *\n     * @method fromJSON\n     * @param {string} jsonString - The JSON data to parse.\n     * @memberof CubicBezierCurve\n     * @static\n     * @throws An exception if the JSON string is malformed.\n     * @return {CubicBezierCurve}\n     **/\n    static fromJSON(jsonString) {\n        var obj = JSON.parse(jsonString);\n        return CubicBezierCurve.fromObject(obj);\n    }\n    /**\n     * Try to convert the passed object to a CubicBezierCurve.\n     *\n     * @method fromObject\n     * @param {object} obj - The object to convert.\n     * @memberof CubicBezierCurve\n     * @static\n     * @throws An exception if the passed object is malformed.\n     * @return {CubicBezierCurve}\n     **/\n    static fromObject(obj) {\n        if (typeof obj !== \"object\")\n            throw \"Can only build from object.\";\n        if (!obj.startPoint)\n            throw 'Object member \"startPoint\" missing.';\n        if (!obj.endPoint)\n            throw 'Object member \"endPoint\" missing.';\n        if (!obj.startControlPoint)\n            throw 'Object member \"startControlPoint\" missing.';\n        if (!obj.endControlPoint)\n            throw 'Object member \"endControlPoint\" missing.';\n        return new CubicBezierCurve(new Vertex(obj.startPoint[0], obj.startPoint[1]), new Vertex(obj.endPoint[0], obj.endPoint[1]), new Vertex(obj.startControlPoint[0], obj.startControlPoint[1]), new Vertex(obj.endControlPoint[0], obj.endControlPoint[1]));\n    }\n    /**\n     * Convert a 4-element array of vertices to a cubic bézier curve.\n     *\n     * @method fromArray\n     * @param {Vertex[]} arr -  [ startVertex, endVertex, startControlVertex, endControlVertex ]\n     * @memberof CubicBezierCurve\n     * @throws An exception if the passed array is malformed.\n     * @return {CubicBezierCurve}\n     **/\n    static fromArray(arr) {\n        if (!Array.isArray(arr))\n            throw \"Can only build from object.\";\n        if (arr.length != 4)\n            throw \"Can only build from array with four elements.\";\n        return new CubicBezierCurve(arr[0], arr[1], arr[2], arr[3]);\n    }\n}\n/** @constant {number} */\nCubicBezierCurve.START_POINT = 0;\n/** @constant {number} */\nCubicBezierCurve.START_CONTROL_POINT = 1;\n/** @constant {number} */\nCubicBezierCurve.END_CONTROL_POINT = 2;\n/** @constant {number} */\nCubicBezierCurve.END_POINT = 3;\n//# sourceMappingURL=CubicBezierCurve.js.map","/**\n * @author Ikaros Kappler\n * @date 2013-08-19\n * @modified 2018-08-16 Added closure. Removed the 'IKRS' wrapper.\n * @modified 2018-11-20 Added circular auto-adjustment.\n * @modified 2018-11-25 Added the point constants to the BezierPath class itself.\n * @modified 2018-11-28 Added the locateCurveByStartPoint() function.\n * @modified 2018-12-04 Added the toSVGString() function.\n * @modified 2019-03-23 Added JSDoc tags.\n * @modified 2019-03-23 Changed the fuctions getPoint and getPointAt to match semantics in the Line class.\n * @modified 2019-11-18 Fixed the clone function: adjustCircular attribute was not cloned.\n * @modified 2019-12-02 Removed some excessive comments.\n * @modified 2019-12-04 Fixed the missing obtainHandleLengths behavior in the adjustNeightbourControlPoint function.\n * @modified 2020-02-06 Added function locateCurveByEndPoint( Vertex ).\n * @modified 2020-02-11 Added 'return this' to the scale(Vertex,number) and to the translate(Vertex) function.\n * @modified 2020-03-24 Ported this class from vanilla-JS to Typescript.\n * @modified 2020-06-03 Made the private helper function _locateUIndex to a private function.\n * @modified 2020-06-03 Added the getBounds() function.\n * @modified 2020-07-14 Changed the moveCurvePoint(...,Vertex) to moveCurvePoint(...,XYCoords).\n * @modified 2020-07-24 Added the getClosestT(Vertex) function.\n * @modified 2020-12-29 Constructor is now private (no explicit use intended).\n * @modified 2021-05-25 Added BezierPath.fromReducedList( Array<number> ).\n * @modified 2022-01-31 Added `BezierPath.getEvenDistributionVertices(number)`.\n * @modified 2022-02-02 Added the `destroy` method.\n * @modified 2022-02-02 Cleared the `toSVGString` function (deprecated). Use `drawutilssvg` instead.\n * @version 2.5.0\n *\n * @file BezierPath\n * @public\n **/\nimport { Bounds } from \"./Bounds\";\nimport { CubicBezierCurve } from \"./CubicBezierCurve\";\nimport { UIDGenerator } from \"./UIDGenerator\";\nimport { Vertex } from \"./Vertex\";\n/**\n * @classdesc A BezierPath class.\n *\n * This was refactored from an older project.\n *\n * @requires Bounds\n * @requires Vertex\n * @requires CubicBezierCurve\n * @requires XYCoords\n * @requires SVGSerializable\n * @requires UID\n * @requires UIDGenerator\n **/\nexport class BezierPath {\n    /**\n     * The constructor.<br>\n     * <br>\n     * This constructor expects a sequence of path points and will approximate\n     * the location of control points by picking some between the points.<br>\n     * You should consider just constructing empty paths and then add more curves later using\n     * the addCurve() function.\n     *\n     * @constructor\n     * @name BezierPath\n     * @param {Vertex[]} pathPoints - An array of path vertices (no control points).\n     **/\n    constructor(pathPoints) {\n        /**\n         * Required to generate proper CSS classes and other class related IDs.\n         **/\n        this.className = \"BezierPath\";\n        /** @constant {number} */\n        this.START_POINT = 0;\n        /** @constant {number} */\n        this.START_CONTROL_POINT = 1;\n        /** @constant {number} */\n        this.END_CONTROL_POINT = 2;\n        /** @constant {number} */\n        this.END_POINT = 3;\n        this.uid = UIDGenerator.next();\n        if (!pathPoints)\n            pathPoints = [];\n        this.totalArcLength = 0.0;\n        // Set this flag to true if you want the first point and\n        // last point of the path to be auto adjusted, too.\n        this.adjustCircular = false;\n        this.bezierCurves = [];\n    }\n    /**\n     * Add a cubic bezier curve to the end of this path.\n     *\n     * @method addCurve\n     * @param {CubicBezierCurve} curve - The curve to be added to the end of the path.\n     * @instance\n     * @memberof BezierPath\n     * @return {void}\n     **/\n    addCurve(curve) {\n        if (curve == null || typeof curve == \"undefined\")\n            throw \"Cannot add null curve to bézier path.\";\n        this.bezierCurves.push(curve);\n        if (this.bezierCurves.length > 1) {\n            curve.startPoint = this.bezierCurves[this.bezierCurves.length - 2].endPoint;\n            this.adjustSuccessorControlPoint(this.bezierCurves.length - 2, // curveIndex,\n            true, // obtainHandleLength,\n            true // updateArcLengths\n            );\n        }\n        else {\n            this.totalArcLength += curve.getLength();\n        }\n    }\n    /**\n     * Locate the curve with the given start point (function returns the index).\n     *\n     * @method locateCurveByStartPoint\n     * @param {Vertex} point - The (curve start-) point to look for.\n     * @instance\n     * @memberof BezierPath\n     * @return {number} The curve index or -1 if curve (start-) point not found\n     **/\n    locateCurveByStartPoint(point) {\n        // for( var i in this.bezierCurves ) {\n        for (var i = 0; i < this.bezierCurves.length; i++) {\n            if (this.bezierCurves[i].startPoint.equals(point))\n                return i;\n        }\n        return -1;\n    }\n    /**\n     * Locate the curve with the given end point (function returns the index).\n     *\n     * @method locateCurveByEndPoint\n     * @param {Vertex} point - The (curve end-) point to look for.\n     * @instance\n     * @memberof BezierPath\n     * @return {number} The curve index or -1 if curve (end-) point not found\n     **/\n    locateCurveByEndPoint(point) {\n        // for( var i in this.bezierCurves ) {\n        for (var i = 0; i < this.bezierCurves.length; i++) {\n            if (this.bezierCurves[i].endPoint.equals(point))\n                return i;\n        }\n        return -1;\n    }\n    /**\n     * Locate the curve with the given start point (function returns the index).\n     *\n     * @method locateCurveByStartControlPoint\n     * @param {Vertex} point - The (curve endt-) point to look for.\n     * @instance\n     * @memberof BezierPath\n     * @return {number} The curve index or -1 if curve (end-) point not found\n     **/\n    locateCurveByStartControlPoint(point) {\n        // for( var i in this.bezierCurves ) {\n        for (var i = 0; i < this.bezierCurves.length; i++) {\n            if (this.bezierCurves[i].startControlPoint.equals(point))\n                return i;\n        }\n        return -1;\n    }\n    // +---------------------------------------------------------------------------------\n    // | Locate the curve with the given end control point.\n    // |\n    // | @param point:Vertex The point to look for.\n    // | @return Number The index or -1 if not found.\n    // +-------------------------------\n    locateCurveByEndControlPoint(point) {\n        // for( var i in this.bezierCurves ) {\n        for (var i = 0; i < this.bezierCurves.length; i++) {\n            if (this.bezierCurves[i].endControlPoint.equals(point))\n                return i;\n        }\n        return -1;\n    }\n    /**\n     * Get the total length of this path.<br>\n     * <br>\n     * Note that the returned value comes from the curve buffer. Unregistered changes\n     * to the curve points will result in invalid path length values.\n     *\n     * @method getLength\n     * @instance\n     * @memberof BezierPath\n     * @return {number} The (buffered) length of the path.\n     **/\n    getLength() {\n        return this.totalArcLength;\n    }\n    /**\n     * This function is internally called whenever the curve or path configuration\n     * changed. It updates the attribute that stores the path length information.<br>\n     * <br>\n     * If you perform any unregistered changes to the curve points you should call\n     * this function afterwards to update the curve buffer. Not updating may\n     * result in unexpected behavior.\n     *\n     * @method updateArcLengths\n     * @instance\n     * @memberof BezierPath\n     * @return {void}\n     **/\n    updateArcLengths() {\n        this.totalArcLength = 0.0;\n        for (var i = 0; i < this.bezierCurves.length; i++) {\n            this.bezierCurves[i].updateArcLengths();\n            this.totalArcLength += this.bezierCurves[i].getLength();\n        }\n    }\n    /**\n     * Get the number of curves in this path.\n     *\n     * @method getCurveCount\n     * @instance\n     * @memberof BezierPath\n     * @return {number} The number of curves in this path.\n     **/\n    getCurveCount() {\n        return this.bezierCurves.length;\n    }\n    /**\n     * Get the cubic bezier curve at the given index.\n     *\n     * @method getCurveAt\n     * @param {number} index - The curve index from 0 to getCurveCount()-1.\n     * @instance\n     * @memberof BezierPath\n     * @return {CubicBezierCurve} The curve at the specified index.\n     **/\n    getCurveAt(curveIndex) {\n        return this.bezierCurves[curveIndex];\n    }\n    /**\n     * Remove the end point of this path (which removes the last curve from this path).<br>\n     * <br>\n     * Please note that this function does never remove the first curve, thus the path\n     * cannot be empty after this call.\n     *\n     * @method removeEndPoint\n     * @instance\n     * @memberof BezierPath\n     * @return {boolean} Indicating if the last curve was removed.\n     **/\n    /*\n      BezierPath.prototype.removeEndPoint = function() {\n      if( this.bezierCurves.length <= 1 )\n          return false;\n      \n      var newArray = [ this.bezierCurves.length-1 ];\n      for( var i = 0; i < this.bezierCurves.length-1; i++ ) {\n          newArray[i] = this.bezierCurves[i];\n      }\n      \n      // Update arc length\n      this.totalArcLength -= this.bezierCurves[ this.bezierCurves.length-1 ].getLength();\n      this.bezierCurves = newArray;\n      return true;\n      }\n      */\n    /**\n     * Remove the start point of this path (which removes the first curve from this path).<br>\n     * <br>\n     * Please note that this function does never remove the last curve, thus the path\n     * cannot be empty after this call.<br>\n     *\n     * @method removeStartPoint\n     * @instance\n     * @memberof BezierPath\n     * @return {boolean} Indicating if the first curve was removed.\n     **/\n    /*\n      BezierPath.prototype.removeStartPoint = function() {\n  \n      if( this.bezierCurves.length <= 1 )\n          return false;\n  \n      var newArray = [ this.bezierCurves.length-1 ];\n      for( var i = 1; i < this.bezierCurves.length; i++ ) {\n  \n          newArray[i-1] = this.bezierCurves[i];\n  \n      }\n      \n      // Update arc length\n      this.totalArcLength -= this.bezierCurves[ 0 ].getLength();\n      this.bezierCurves = newArray;\n      \n      return true;\n      }\n      */\n    /**\n     * Removes a path point inside the path.\n     *\n     * This function joins the bezier curve at the given index with\n     * its predecessor, which means that the start point at the given\n     * curve index will be removed.\n     *\n     * @method joinAt\n     * @param {number} curveIndex - The index of the curve to be joined with its predecessor.\n     * @instance\n     * @memberof BezierPath\n     * @return {boolean} True if the passed index indicated an inner vertex and the two curves were joined.\n     **/\n    /*\n      BezierPath.prototype.joinAt = function( curveIndex ) {\n  \n      if( curveIndex < 0 || curveIndex >= this.bezierCurves.length )\n          return false;\n      \n      var leftCurve  = this.bezierCurves[ curveIndex-1 ];\n      var rightCurve = this.bezierCurves[ curveIndex ];\n  \n      // Make the length of the new handle double that long\n      var leftControlPoint = leftCurve.getStartControlPoint().clone();\n      leftControlPoint.sub( leftCurve.getStartPoint() );\n      leftControlPoint.multiplyScalar( 2.0 );\n      leftControlPoint.add( leftCurve.getStartPoint() );\n      \n      var rightControlPoint = rightCurve.getEndControlPoint().clone();\n      rightControlPoint.sub( rightCurve.getEndPoint() );\n      rightControlPoint.multiplyScalar( 2.0 );\n      rightControlPoint.add( rightCurve.getEndPoint() );\n  \n      var newCurve = new IKRS.CubicBezierCurve( leftCurve.getStartPoint(),\n                            rightCurve.getEndPoint(),\n                            leftControlPoint,\n                            rightControlPoint\n                          );\n      // Place into array\n      var newArray = [ this.bezierCurves.length - 1 ];\n  \n      for( var i = 0; i < curveIndex-1; i++ )\n          newArray[ i ] = this.bezierCurves[i];\n      \n      newArray[ curveIndex-1 ] = newCurve;\n      \n      // Shift trailing curves left\n      for( var i = curveIndex; i+1 < this.bezierCurves.length; i++ )\n          newArray[ i ] = this.bezierCurves[ i+1 ];\n          \n      this.bezierCurves = newArray;\n      this.updateArcLengths();\n  \n      return true;\n      }\n      */\n    /**\n     * Add a new inner curve point to the path.<br>\n     * <br>\n     * This function splits the bezier curve at the given index and given\n     * curve segment index.\n     *\n     * @method splitAt\n     * @param {number} curveIndex - The index of the curve to split.\n     * @param {nunber} segmentIndex - The index of the curve segment where the split should be performed.\n     * @instance\n     * @memberof BezierPath\n     * @return {boolean} True if the passed indices were valid and the path was split.\n     **/\n    /*\n      BezierPath.prototype.splitAt = function( curveIndex,\n                           segmentIndex\n                         ) {\n      // Must be a valid curve index\n      if( curveIndex < 0 || curveIndex >= this.bezierCurves.length )\n          return false;\n  \n      var oldCurve = this.bezierCurves[ curveIndex ];\n  \n      // Segment must be an INNER point!\n      // (the outer points are already bezier end/start points!)\n      if( segmentIndex < 1 || segmentIndex-1 >= oldCurve.segmentCache.length )\n          return false;\n  \n      // Make room for a new curve\n      for( var c = this.bezierCurves.length; c > curveIndex; c-- ) {\n          // Move one position to the right\n          this.bezierCurves[ c ] = this.bezierCurves[ c-1 ];\n      }\n  \n      // Accumulate segment lengths\n      var u = 0;\n      for( var i = 0; i < segmentIndex; i++ )\n          u += oldCurve.segmentLengths[i];\n      //var tangent = oldCurve.getTangentAt( u );\n      var tangent = oldCurve.getTangent( u );\n      tangent = tangent.multiplyScalar( 0.25 );\n  \n      var leftEndControlPoint = oldCurve.segmentCache[ segmentIndex ].clone();\n      leftEndControlPoint.sub( tangent );\n      \n      var rightStartControlPoint = oldCurve.segmentCache[ segmentIndex ].clone();\n      rightStartControlPoint.add( tangent );\n      \n      // Make the old existing handles a quarter that long\n      var leftStartControlPoint = oldCurve.getStartControlPoint().clone();\n      // move to (0,0)\n      leftStartControlPoint.sub( oldCurve.getStartPoint() );\n      leftStartControlPoint.multiplyScalar( 0.25 );\n      leftStartControlPoint.add( oldCurve.getStartPoint() );\n  \n      var rightEndControlPoint = oldCurve.getEndControlPoint().clone();\n      // move to (0,0)\n      rightEndControlPoint.sub( oldCurve.getEndPoint() );\n      rightEndControlPoint.multiplyScalar( 0.25 );\n      rightEndControlPoint.add( oldCurve.getEndPoint() );\n  \n      var newLeft  = new CubicBezierCurve( oldCurve.getStartPoint(),                      // old start point\n                           oldCurve.segmentCache[ segmentIndex ],         // new end point\n                           leftStartControlPoint,                         // old start control point\n                           leftEndControlPoint                            // new end control point\n                         );\n      var newRight = new CubicBezierCurve( oldCurve.segmentCache[ segmentIndex ],         // new start point\n                           oldCurve.getEndPoint(),                        // old end point\n                           rightStartControlPoint,                        // new start control point\n                           rightEndControlPoint                           // old end control point\n                         );\n      \n      // Insert split curve(s) at free index\n      this.bezierCurves[ curveIndex ]     = newLeft;\n      this.bezierCurves[ curveIndex + 1 ] = newRight;\n      \n      // Update total arc length, even if there is only a very little change!\n      this.totalArcLength -= oldCurve.getLength();\n      this.totalArcLength += newLeft.getLength();\n      this.totalArcLength += newRight.getLength();\n  \n      return true;\n      };\n      */\n    /*\n      insertVertexAt( t:number ) : void {\n      console.log('Inserting vertex at', t );\n      // Find the curve index\n      var u : number = 0;\n      var curveIndex : number = -1;\n      var localT : number = 0.0;\n      for( var i = 0; curveIndex == -1 && i < this.bezierCurves.length; i++ ) {\n          \n      }\n      }; */\n    /**\n     * Move the whole bezier path by the given (x,y)-amount.\n     *\n     * @method translate\n     * @param {Vertex} amount - The amount to be added (amount.x and amount.y)\n     *                          to each vertex of the curve.\n     * @instance\n     * @memberof BezierPath\n     * @return {BezierPath} this for chaining\n     **/\n    translate(amount) {\n        for (var i = 0; i < this.bezierCurves.length; i++) {\n            var curve = this.bezierCurves[i];\n            curve.getStartPoint().add(amount);\n            curve.getStartControlPoint().add(amount);\n            curve.getEndControlPoint().add(amount);\n        }\n        // Don't forget to translate the last curve's last point\n        var curve = this.bezierCurves[this.bezierCurves.length - 1];\n        curve.getEndPoint().add(amount);\n        this.updateArcLengths();\n        return this;\n    }\n    /**\n     * Scale the whole bezier path by the given uniform factor.\n     *\n     * @method scale\n     * @param {Vertex} anchor - The scale origin to scale from.\n     * @param {number} scaleFactor - The scalar to be multiplied with.\n     * @instance\n     * @memberof BezierPath\n     * @return {BezierPath} this for chaining.\n     **/\n    scale(anchor, scaleFactor) {\n        // var scaleFactors : XYCoords = { x : scaleFactor, y : scaleFactor };\n        // for (var i = 0; i < this.bezierCurves.length; i++) {\n        //   var curve = this.bezierCurves[i];\n        //   curve.getStartPoint().scale(scaleFactor, anchor);\n        //   curve.getStartControlPoint().scale(scaleFactor, anchor);\n        //   curve.getEndControlPoint().scale(scaleFactor, anchor);\n        //   // Do NOT scale the end point here!\n        //   // Don't forget that the curves are connected and on curve's end point\n        //   // the the successor's start point (same instance)!\n        // }\n        // // Finally move the last end point (was not scaled yet)\n        // if (this.bezierCurves.length > 0 && !this.adjustCircular) {\n        //   this.bezierCurves[this.bezierCurves.length - 1].getEndPoint().scale(scaleFactor, anchor);\n        // }\n        // this.updateArcLengths();\n        // return this;\n        return this.scaleXY({ x: scaleFactor, y: scaleFactor }, anchor);\n    }\n    /**\n     * Scale the whole bezier path by the given (x,y)-factors.\n     *\n     * @method scale\n     * @param {Vertex} anchor - The scale origin to scale from.\n     * @param {number} amount - The scalar to be multiplied with.\n     * @instance\n     * @memberof BezierPath\n     * @return {BezierPath} this for chaining.\n     **/\n    scaleXY(scaleFactors, anchor) {\n        for (var i = 0; i < this.bezierCurves.length; i++) {\n            var curve = this.bezierCurves[i];\n            curve.getStartPoint().scaleXY(scaleFactors, anchor);\n            curve.getStartControlPoint().scaleXY(scaleFactors, anchor);\n            curve.getEndControlPoint().scaleXY(scaleFactors, anchor);\n            // Do NOT scale the end point here!\n            // Don't forget that the curves are connected and on curve's end point\n            // the the successor's start point (same instance)!\n        }\n        // Finally move the last end point (was not scaled yet)\n        if (this.bezierCurves.length > 0 && !this.adjustCircular) {\n            this.bezierCurves[this.bezierCurves.length - 1].getEndPoint().scaleXY(scaleFactors, anchor);\n        }\n        this.updateArcLengths();\n        return this;\n    }\n    /**\n     * Rotate the whole bezier path around a point..\n     *\n     * @method rotate\n     * @param {Vertex} angle  - The angle to rotate this path by.\n     * @param {Vertex} center - The rotation center.\n     * @instance\n     * @memberof BezierPath\n     * @return {void}\n     **/\n    rotate(angle, center) {\n        for (var i = 0; i < this.bezierCurves.length; i++) {\n            var curve = this.bezierCurves[i];\n            curve.getStartPoint().rotate(angle, center);\n            curve.getStartControlPoint().rotate(angle, center);\n            curve.getEndControlPoint().rotate(angle, center);\n            // Do NOT rotate the end point here!\n            // Don't forget that the curves are connected and on curve's end point\n            // the the successor's start point (same instance)!\n        }\n        // Finally move the last end point (was not scaled yet)\n        if (this.bezierCurves.length > 0 && !this.adjustCircular) {\n            this.bezierCurves[this.bezierCurves.length - 1].getEndPoint().rotate(angle, center);\n        }\n    }\n    /**\n     * Get the 't' position on this curve with the minimal distance to point p.\n     *\n     * @param {Vertex} p - The point to find the closest curve point for.\n     * @return {number} A value t with 0.0 <= t <= 1.0.\n     **/\n    getClosestT(p) {\n        // Find the spline to extract the value from\n        var minIndex = -1;\n        var minDist = 0.0;\n        var dist = 0.0;\n        var curveT = 0.0;\n        var uMin = 0.0;\n        var u = 0.0;\n        for (var i = 0; i < this.bezierCurves.length; i++) {\n            curveT = this.bezierCurves[i].getClosestT(p);\n            dist = this.bezierCurves[i].getPointAt(curveT).distance(p);\n            if (minIndex == -1 || dist < minDist) {\n                minIndex = i;\n                minDist = dist;\n                uMin = u + curveT * this.bezierCurves[i].getLength();\n            }\n            u += this.bezierCurves[i].getLength();\n        }\n        return Math.max(0.0, Math.min(1.0, uMin / this.totalArcLength));\n    }\n    /**\n     * Get the point on the bézier path at the given relative path location.\n     *\n     * @method getPoint\n     * @param {number} u - The relative path position: <pre>0 <= u <= this.getLength()</pre>\n     * @instance\n     * @memberof BezierPath\n     * @return {Vertex} The point at the relative path position.\n     **/\n    getPoint(u) {\n        if (u < 0 || u > this.totalArcLength) {\n            console.warn(\"[BezierPath.getPoint(u)] u is out of bounds: \" + u + \".\");\n            u = Math.min(this.totalArcLength, Math.max(u, 0));\n        }\n        // Find the spline to extract the value from\n        var i = 0;\n        var uTemp = 0.0;\n        while (i < this.bezierCurves.length && uTemp + this.bezierCurves[i].getLength() < u) {\n            uTemp += this.bezierCurves[i].getLength();\n            i++;\n        }\n        // if u == arcLength\n        //   -> i is max\n        if (i >= this.bezierCurves.length)\n            return this.bezierCurves[this.bezierCurves.length - 1].getEndPoint().clone();\n        var bCurve = this.bezierCurves[i];\n        var relativeU = u - uTemp;\n        return bCurve.getPoint(relativeU);\n    }\n    /**\n     * Get the point on the bézier path at the given path fraction.\n     *\n     * @method getPointAt\n     * @param {number} t - The absolute path position: <pre>0.0 <= t <= 1.0</pre>\n     * @instance\n     * @memberof BezierPath\n     * @return {Vertex} The point at the absolute path position.\n     **/\n    getPointAt(t) {\n        return this.getPoint(t * this.totalArcLength);\n    }\n    /**\n     * Get the tangent of the bézier path at the given path fraction.<br>\n     * <br>\n     * Note that the returned vector is not normalized.\n     *\n     * @method getTangentAt\n     * @param {number} t - The absolute path position: <pre>0.0 <= t <= 1.0</pre>\n     * @instance\n     * @memberof BezierPath\n     * @return {Vertex} The tangent vector at the absolute path position.\n     **/\n    getTangentAt(t) {\n        return this.getTangent(t * this.totalArcLength);\n    }\n    /**\n     *  Get the tangent of the bézier path at the given path location.<br>\n     * <br>\n     * Note that the returned vector is not normalized.\n     *\n     * @method getTangent\n     * @param {number} u - The relative path position: <pre>0 <= u <= getLength()</pre>\n     * @instance\n     * @memberof BezierPath\n     * @return {Vertex} The tangent vector at the relative path position.\n     **/\n    getTangent(u) {\n        if (u < 0 || u > this.totalArcLength) {\n            console.warn(\"[BezierPath.getTangent(u)] u is out of bounds: \" + u + \".\");\n            // return undefined;\n            u = Math.min(this.totalArcLength, Math.max(0, u));\n        }\n        // Find the spline to extract the value from\n        var i = 0;\n        var uTemp = 0.0;\n        while (i < this.bezierCurves.length && uTemp + this.bezierCurves[i].getLength() < u) {\n            uTemp += this.bezierCurves[i].getLength();\n            i++;\n        }\n        var bCurve = this.bezierCurves[i];\n        var relativeU = u - uTemp;\n        return bCurve.getTangent(relativeU);\n    }\n    /**\n     * Get the perpendicular of the bézier path at the given absolute path location (fraction).<br>\n     * <br>\n     * Note that the returned vector is not normalized.\n     *\n     * @method getPerpendicularAt\n     * @param {number} t - The absolute path position: <pre>0.0 <= t <= 1.0</pre>\n     * @instance\n     * @memberof BezierPath\n     * @return {Vertex} The perpendicluar vector at the absolute path position.\n     **/\n    getPerpendicularAt(t) {\n        return this.getPerpendicular(t * this.totalArcLength);\n    }\n    /**\n     * Get the perpendicular of the bézier path at the given relative path location.<br>\n     * <br>\n     * Note that the returned vector is not normalized.\n     *\n     * @method getPerpendicular\n     * @param {number} u - The relative path position: <pre>0 <= u <= getLength()</pre>\n     * @instance\n     * @memberof BezierPath\n     * @return {Vertex} The perpendicluar vector at the relative path position.\n     **/\n    getPerpendicular(u) {\n        if (u < 0 || u > this.totalArcLength) {\n            console.log(\"[BezierPath.getPerpendicular(u)] u is out of bounds: \" + u + \".\");\n            u = Math.min(this.totalArcLength, Math.max(0, u));\n        }\n        // Find the spline to extract the value from\n        var uResult = BezierPath._locateUIndex(this, u);\n        var bCurve = this.bezierCurves[uResult.i];\n        var relativeU = u - uResult.uPart;\n        return bCurve.getPerpendicular(relativeU);\n    }\n    /**\n     * This is a helper function to locate the curve index for a given\n     * absolute path position u.\n     *\n     * I decided to put this into privat scope as it is really specific. Maybe\n     * put this into a utils wrapper.\n     *\n     * Returns:\n     * - {number} i - the index of the containing curve.\n     * - {number} uPart - the absolute curve length sum (length from the beginning to u, should equal u itself).\n     * - {number} uBefore - the absolute curve length for all segments _before_ the matched curve (usually uBefore <= uPart).\n     **/\n    static _locateUIndex(path, u) {\n        var i = 0;\n        var uTemp = 0.0;\n        var uBefore = 0.0;\n        while (i < path.bezierCurves.length && uTemp + path.bezierCurves[i].getLength() < u) {\n            uTemp += path.bezierCurves[i].getLength();\n            if (i + 1 < path.bezierCurves.length)\n                uBefore += path.bezierCurves[i].getLength();\n            i++;\n        }\n        return { i: i, uPart: uTemp, uBefore: uBefore };\n    }\n    /**\n     * Get a specific sub path from this path. The start and end position are specified by\n     * ratio number in [0..1].\n     *\n     * 0.0 is at the beginning of the path.\n     * 1.0 is at the end of the path.\n     *\n     * Values below 0 or beyond 1 are cropped down to the [0..1] interval.\n     *\n     * startT > endT is allowed, the returned sub path will have inverse direction then.\n     *\n     * @method getSubPathAt\n     * @param {number} startT - The start position of the sub path.\n     * @param {number} endT - The end position of the sub path.\n     * @instance\n     * @memberof BezierPath\n     * @return {BezierPath} The desired sub path in the bounds [startT..endT].\n     **/\n    getSubPathAt(startT, endT) {\n        startT = Math.max(0, startT);\n        endT = Math.min(1.0, endT);\n        let startU = startT * this.totalArcLength;\n        let endU = endT * this.totalArcLength;\n        var uStartResult = BezierPath._locateUIndex(this, startU); // { i:int, uPart:float, uBefore:float }\n        var uEndResult = BezierPath._locateUIndex(this, endU); // { i:int, uPart:float, uBefore:float }\n        var firstT = (startU - uStartResult.uBefore) / this.bezierCurves[uStartResult.i].getLength();\n        if (uStartResult.i == uEndResult.i) {\n            // Subpath begins and ends in the same path segment (just get a simple sub curve from that path element).\n            var lastT = (endU - uEndResult.uBefore) / this.bezierCurves[uEndResult.i].getLength();\n            var firstCurve = this.bezierCurves[uStartResult.i].getSubCurveAt(firstT, lastT);\n            return BezierPath.fromArray([firstCurve]);\n        }\n        else {\n            var curves = [];\n            if (uStartResult.i > uEndResult.i) {\n                // Back to front direction\n                var firstCurve = this.bezierCurves[uStartResult.i].getSubCurveAt(firstT, 0.0);\n                curves.push(firstCurve);\n                for (var i = uStartResult.i - 1; i > uEndResult.i; i--) {\n                    curves.push(this.bezierCurves[i].clone().reverse());\n                }\n                var lastT = (endU - uEndResult.uBefore) / this.bezierCurves[uEndResult.i].getLength();\n                curves.push(this.bezierCurves[uEndResult.i].getSubCurveAt(1.0, lastT));\n            }\n            else {\n                // Front to back direction\n                var firstCurve = this.bezierCurves[uStartResult.i].getSubCurveAt(firstT, 1.0);\n                curves.push(firstCurve);\n                for (var i = uStartResult.i + 1; i < uEndResult.i && i < this.bezierCurves.length; i++) {\n                    curves.push(this.bezierCurves[i].clone());\n                }\n                var lastT = (endU - uEndResult.uBefore) / this.bezierCurves[uEndResult.i].getLength();\n                curves.push(this.bezierCurves[uEndResult.i].getSubCurveAt(0, lastT));\n            }\n            return BezierPath.fromArray(curves);\n        }\n    }\n    /**\n     * This function moves the addressed curve point (or control point) with\n     * keeping up the path's curve integrity.<br>\n     * <br>\n     * Thus is done by moving neighbour- and control- points as needed.\n     *\n     * @method moveCurvePoint\n     * @param {number} curveIndex - The curve index to move a point from.\n     * @param {number} pointID - One of the curve's four point IDs (START_POINT,\n     *                           START_CONTROL_POINT, END_CONTRO_POINT or END_POINT).\n     * @param {XYCoords} moveAmount - The amount to move the addressed vertex by.\n     * @instance\n     * @memberof BezierPath\n     * @return {void}\n     **/\n    moveCurvePoint(curveIndex, pointID, moveAmount) {\n        var bCurve = this.getCurveAt(curveIndex);\n        bCurve.moveCurvePoint(pointID, moveAmount, true, // move control point, too\n        true // updateArcLengths\n        );\n        // If inner point and NOT control point\n        //  --> move neightbour\n        if (pointID == this.START_POINT && (curveIndex > 0 || this.adjustCircular)) {\n            // Set predecessor's control point!\n            var predecessor = this.getCurveAt(curveIndex - 1 < 0 ? this.bezierCurves.length + (curveIndex - 1) : curveIndex - 1);\n            predecessor.moveCurvePoint(this.END_CONTROL_POINT, moveAmount, true, // move control point, too\n            false // updateArcLengths\n            );\n        }\n        else if (pointID == this.END_POINT && (curveIndex + 1 < this.bezierCurves.length || this.adjustCircular)) {\n            // Set successcor\n            var successor = this.getCurveAt((curveIndex + 1) % this.bezierCurves.length);\n            successor.moveCurvePoint(this.START_CONTROL_POINT, moveAmount, true, // move control point, too\n            false // updateArcLengths\n            );\n        }\n        else if (pointID == this.START_CONTROL_POINT && curveIndex > 0) {\n            this.adjustPredecessorControlPoint(curveIndex, true, // obtain handle length?\n            false // update arc lengths\n            );\n        }\n        else if (pointID == this.END_CONTROL_POINT && curveIndex + 1 < this.getCurveCount()) {\n            this.adjustSuccessorControlPoint(curveIndex, true, // obtain handle length?\n            false // update arc lengths\n            );\n        }\n        // Don't forget to update the arc lengths!\n        // Note: this can be optimized as only two curves have changed their lengths!\n        this.updateArcLengths();\n    }\n    /**\n     * This helper function adjusts the given point's predecessor's control point.\n     *\n     * @method adjustPredecessorControlPoint\n     * @param {number} curveIndex - The curve index to move a point from.\n     * @param {boolean} obtainHandleLength - Moves the point with keeping the original handle length.\n     * @param {boolean} updateArcLength - The amount to move the addressed vertex by.\n     * @instance\n     * @private\n     * @memberof BezierPath\n     * @return {void}\n     **/\n    adjustPredecessorControlPoint(curveIndex, obtainHandleLength, updateArcLengths) {\n        if (!this.adjustCircular && curveIndex <= 0)\n            return; // false;\n        var mainCurve = this.getCurveAt(curveIndex);\n        var neighbourCurve = this.getCurveAt(curveIndex - 1 < 0 ? this.getCurveCount() + (curveIndex - 1) : curveIndex - 1);\n        BezierPath.adjustNeighbourControlPoint(mainCurve, neighbourCurve, mainCurve.getStartPoint(), // the reference point\n        mainCurve.getStartControlPoint(), // the dragged control point\n        neighbourCurve.getEndPoint(), // the neighbour's point\n        neighbourCurve.getEndControlPoint(), // the neighbour's control point to adjust\n        obtainHandleLength, updateArcLengths);\n    }\n    /**\n     * This helper function adjusts the given point's successor's control point.\n     *\n     * @method adjustSuccessorControlPoint\n     * @param {number} curveIndex - The curve index to move a point from.\n     * @param {boolean} obtainHandleLength - Moves the point with keeping the original handle length.\n     * @param {boolean} updateArcLength - The amount to move the addressed vertex by.\n     * @instance\n     * @private\n     * @memberof BezierPath\n     * @return {void}\n     **/\n    adjustSuccessorControlPoint(curveIndex, obtainHandleLength, updateArcLengths) {\n        if (!this.adjustCircular && curveIndex + 1 > this.getCurveCount())\n            return; //  false;\n        var mainCurve = this.getCurveAt(curveIndex);\n        var neighbourCurve = this.getCurveAt((curveIndex + 1) % this.getCurveCount());\n        /* return */ BezierPath.adjustNeighbourControlPoint(mainCurve, neighbourCurve, mainCurve.getEndPoint(), // the reference point\n        mainCurve.getEndControlPoint(), // the dragged control point\n        neighbourCurve.getStartPoint(), // the neighbour's point\n        neighbourCurve.getStartControlPoint(), // the neighbour's control point to adjust\n        obtainHandleLength, updateArcLengths);\n    }\n    /**\n     * This helper function adjusts the given point's successor's control point.\n     *\n     * @method adjustNeighbourControlPoint\n     * @param {CubicBezierCurve} mainCurve\n     * @param {CubicBezierCurve} neighbourCurve\n     * @param {Vertex} mainPoint\n     * @param {Vertex} mainControlPoint\n     * @param {Vertex} neighbourPoint\n     * @param {Vertex} neighbourControlPoint\n     * @param {boolean} obtainHandleLengths\n     * @param {boolean} updateArcLengths\n     * @instance\n     * @private\n     * @memberof BezierPath\n     * @return {void}\n     **/\n    static adjustNeighbourControlPoint(_mainCurve, // TODO: remove param\n    neighbourCurve, mainPoint, mainControlPoint, neighbourPoint, neighbourControlPoint, obtainHandleLengths, _updateArcLengths // TODO: remove param\n    ) {\n        // Calculate start handle length\n        var mainHandleBounds = new Vertex(mainControlPoint.x - mainPoint.x, mainControlPoint.y - mainPoint.y);\n        var neighbourHandleBounds = new Vertex(neighbourControlPoint.x - neighbourPoint.x, neighbourControlPoint.y - neighbourPoint.y);\n        var mainHandleLength = Math.sqrt(Math.pow(mainHandleBounds.x, 2) + Math.pow(mainHandleBounds.y, 2));\n        var neighbourHandleLength = Math.sqrt(Math.pow(neighbourHandleBounds.x, 2) + Math.pow(neighbourHandleBounds.y, 2));\n        if (mainHandleLength <= 0.1)\n            return; // no secure length available for division? What about zoom? Use EPSILON?\n        // Just invert the main handle (keep length or not?\n        if (obtainHandleLengths) {\n            neighbourControlPoint.set(neighbourPoint.x - mainHandleBounds.x * (neighbourHandleLength / mainHandleLength), neighbourPoint.y - mainHandleBounds.y * (neighbourHandleLength / mainHandleLength));\n        }\n        else {\n            neighbourControlPoint.set(neighbourPoint.x - mainHandleBounds.x, neighbourPoint.y - mainHandleBounds.y);\n        }\n        neighbourCurve.updateArcLengths();\n    }\n    /**\n     * Get the bounds of this Bézier path.\n     *\n     * Note the the curves' underlyung segment buffers are used to determine the bounds. The more\n     * elements the segment buffers have, the more precise the returned bounds will be.\n     *\n     * @return {Bounds} The bounds of this Bézier path.\n     **/\n    getBounds() {\n        const min = new Vertex(Number.POSITIVE_INFINITY, Number.POSITIVE_INFINITY);\n        const max = new Vertex(Number.NEGATIVE_INFINITY, Number.NEGATIVE_INFINITY);\n        var b;\n        for (var i = 0; i < this.bezierCurves.length; i++) {\n            b = this.bezierCurves[i].getBounds();\n            min.x = Math.min(min.x, b.min.x);\n            min.y = Math.min(min.y, b.min.y);\n            max.x = Math.max(max.x, b.max.x);\n            max.y = Math.max(max.y, b.max.y);\n        }\n        return new Bounds(min, max);\n    }\n    /**\n     * Get n 'equally' distributed vertices along this Bézier path.\n     *\n     * As the changing curvature of the B slines makes prediction of distances difficult, the\n     * returned vertices' distances are only relatively equal:\n     *  - the distance grows where curvature is large.\n     *  - the distance shrinks where curvature is small.\n     *\n     * Only the distance mean of all consecutive is 1/n-th of the total arc length.\n     *\n     * Usually this approximation is good enough for most use cases.\n     *\n     * @param {number} pointCount - (must be at least 2) The number of desired points (start and end point included).\n     * @return {Array<Vertex>}\n     */\n    getEvenDistributionVertices(pointCount) {\n        if (pointCount < 2) {\n            throw new Error(\"pointCount must be larger than one; is \" + pointCount + \".\");\n        }\n        const result = [];\n        if (this.bezierCurves.length === 0) {\n            return result;\n        }\n        // Fetch and add the start point from the source polygon\n        var polygonPoint = new Vertex(this.bezierCurves[0].startPoint);\n        result.push(polygonPoint);\n        // if (this.bezierCurves.length === 1) {\n        //   return result;\n        // }\n        const perimeter = this.totalArcLength;\n        const stepSize = perimeter / (pointCount - 1);\n        const n = this.bezierCurves.length;\n        let curveIndex = 0;\n        let segmentLength = this.bezierCurves[0].arcLength;\n        let curSegmentU = stepSize;\n        let i = 1;\n        while (i < pointCount && curveIndex < n) {\n            // Check if next eq point is inside this segment\n            if (curSegmentU < segmentLength) {\n                var newPoint = this.bezierCurves[curveIndex].getPoint(curSegmentU);\n                result.push(newPoint);\n                curSegmentU += stepSize;\n                i++;\n            }\n            else {\n                curveIndex++;\n                curSegmentU = curSegmentU - segmentLength;\n                segmentLength = curveIndex < n ? this.bezierCurves[curveIndex].arcLength : 0;\n            }\n        }\n        result.push(new Vertex(this.bezierCurves[n - 1].endPoint));\n        return result;\n    }\n    /**\n     * Clone this BezierPath (deep clone).\n     *\n     * @method clone\n     * @instance\n     * @memberof BezierPath\n     * @return {BezierPath}\n     **/\n    clone() {\n        var path = new BezierPath(undefined);\n        for (var i = 0; i < this.bezierCurves.length; i++) {\n            path.bezierCurves.push(this.bezierCurves[i].clone());\n            // Connect splines\n            if (i > 0)\n                path.bezierCurves[i - 1].endPoint = path.bezierCurves[i].startPoint;\n        }\n        path.updateArcLengths();\n        path.adjustCircular = this.adjustCircular;\n        return path;\n    }\n    /**\n     * Compare this and the passed Bézier path.\n     *\n     * @method equals\n     * @param {BezierPath} path - The pass to compare with.\n     * @instance\n     * @memberof BezierPath\n     * @return {boolean}\n     **/\n    equals(path) {\n        if (!path)\n            return false;\n        // Check if path contains the credentials\n        if (!path.bezierCurves)\n            return false;\n        if (typeof path.bezierCurves.length == \"undefined\")\n            return false;\n        if (path.bezierCurves.length != this.bezierCurves.length)\n            return false;\n        for (var i = 0; i < this.bezierCurves.length; i++) {\n            if (!this.bezierCurves[i].equals(path.bezierCurves[i]))\n                return false;\n        }\n        return true;\n    }\n    /**\n     * This function should invalidate any installed listeners and invalidate this object.\n     * After calling this function the object might not hold valid data any more and\n     * should not be used.\n     */\n    destroy() {\n        for (var i = 0; i < this.bezierCurves.length; i++) {\n            this.bezierCurves[i].destroy();\n        }\n        this.isDestroyed = true;\n    }\n    /**\n     * Create a JSON string representation of this bézier curve.\n     *\n     * @method toJSON\n     * @param {boolean} prettyFormat - If true then the function will add line breaks.\n     * @instance\n     * @memberof BezierPath\n     * @return {string} The JSON string.\n     **/\n    toJSON(prettyFormat) {\n        var buffer = [];\n        buffer.push(\"[\"); // array begin\n        for (var i = 0; i < this.bezierCurves.length; i++) {\n            if (i > 0)\n                buffer.push(\",\");\n            if (prettyFormat)\n                buffer.push(\"\\n\\t\");\n            else\n                buffer.push(\" \");\n            buffer.push(this.bezierCurves[i].toJSON(prettyFormat));\n        }\n        if (this.bezierCurves.length != 0)\n            buffer.push(\" \");\n        buffer.push(\"]\"); // array end\n        return buffer.join(\"\"); // Convert to string, with empty separator.\n    }\n    /**\n     * Parse a BezierPath from the given JSON string.\n     *\n     * @method fromJSON\n     * @param {string} jsonString - The string with the JSON data.\n     * @throw An error if the string is not JSON or does not contain a bezier path object.\n     * @static\n     * @memberof BezierPath\n     * @return {BezierPath} The parsed bezier path instance.\n     **/\n    static fromJSON(jsonString) {\n        var obj = JSON.parse(jsonString);\n        return BezierPath.fromArray(obj);\n    }\n    /**\n     * Create a BezierPath instance from the given array.\n     *\n     * @method fromArray\n     * @param {Vertex[][]} arr - A two-dimensional array containing the bezier path vertices.\n     * @throw An error if the array does not contain proper bezier path data.\n     * @static\n     * @memberof BezierPath\n     * @return {BezierPath} The bezier path instance retrieved from the array data.\n     **/\n    static fromArray(obj) {\n        if (!Array.isArray(obj))\n            throw \"[BezierPath.fromArray] Passed object must be an array.\";\n        const arr = obj; // FORCE?\n        if (arr.length < 1)\n            throw \"[BezierPath.fromArray] Passed array must contain at least one bezier curve (has \" + arr.length + \").\";\n        // Create an empty bezier path\n        var bPath = new BezierPath(undefined);\n        var lastCurve = null;\n        for (var i = 0; i < arr.length; i++) {\n            // Convert object (or array?) to bezier curve\n            var bCurve;\n            if (CubicBezierCurve.isInstance(arr[i])) {\n                bCurve = arr[i].clone();\n            }\n            else if (0 in arr[i] && 1 in arr[i] && 2 in arr[i] && 3 in arr[i]) {\n                if (!arr[i][0] || !arr[i][1] || !arr[i][2] || !arr[i][3])\n                    throw \"Cannot convert path data to BezierPath instance. At least one element is undefined (index=\" + i + \"): \" + arr[i];\n                bCurve = CubicBezierCurve.fromArray(arr[i]);\n            }\n            else {\n                bCurve = CubicBezierCurve.fromObject(arr[i]);\n            }\n            // Set curve start point?\n            // (avoid duplicate point instances!)\n            if (lastCurve)\n                bCurve.startPoint = lastCurve.endPoint;\n            // Add to path's internal list\n            bPath.bezierCurves.push(bCurve);\n            // bPath.totalArcLength += bCurve.getLength();\n            lastCurve = bCurve;\n        }\n        bPath.updateArcLengths();\n        // Bezier segments added. Done\n        return bPath;\n    }\n    /**\n     * This function converts the bezier path into a string containing\n     * integer values only.\n     * The points' float values are rounded to 1 digit after the comma.\n     *\n     * The returned string represents a JSON array (with leading '[' and\n     * trailing ']', the separator is ',').\n     *\n     * @method toReducedListRepresentation\n     * @param {number} digits - The number of digits to be used after the comma '.'.\n     * @instance\n     * @memberof BezierPath\n     * @return {string} The reduced list representation of this path.\n     **/\n    toReducedListRepresentation(digits) {\n        if (typeof digits == \"undefined\")\n            digits = 1;\n        var buffer = [];\n        buffer.push(\"[\"); // array begin\n        for (var i = 0; i < this.bezierCurves.length; i++) {\n            var curve = this.bezierCurves[i];\n            buffer.push(curve.getStartPoint().x.toFixed(digits));\n            buffer.push(\",\");\n            buffer.push(curve.getStartPoint().y.toFixed(digits));\n            buffer.push(\",\");\n            buffer.push(curve.getStartControlPoint().x.toFixed(digits));\n            buffer.push(\",\");\n            buffer.push(curve.getStartControlPoint().y.toFixed(digits));\n            buffer.push(\",\");\n            buffer.push(curve.getEndControlPoint().x.toFixed(digits));\n            buffer.push(\",\");\n            buffer.push(curve.getEndControlPoint().y.toFixed(digits));\n            buffer.push(\",\");\n        }\n        if (this.bezierCurves.length != 0) {\n            var curve = this.bezierCurves[this.bezierCurves.length - 1];\n            buffer.push(curve.getEndPoint().x.toFixed(digits));\n            buffer.push(\",\");\n            buffer.push(curve.getEndPoint().y.toFixed(digits));\n        }\n        buffer.push(\"]\"); // array end\n        return buffer.join(\"\"); // Convert to string, with empty separator.\n    }\n    /**\n     * Parse a BezierPath instance from the reduced list representation.<br>\n     * <br>\n     * The passed string must represent a JSON array containing numbers only.\n     *\n     * @method fromReducedListRepresentation\n     * @param {string} listJSON - The number of digits to be used after the floating point.\n     * @throw An error if the string is malformed.\n     * @instance\n     * @memberof BezierPath\n     * @return {BezierPath} The bezier path instance retrieved from the string.\n     **/\n    static fromReducedListRepresentation(listJSON, adjustCircular) {\n        // Parse the array\n        var pointArray = JSON.parse(listJSON);\n        if (!pointArray.length) {\n            console.log(\"Cannot parse bezier path from non-array object nor from empty point list.\");\n            throw \"Cannot parse bezier path from non-array object nor from empty point list.\";\n        }\n        if (pointArray.length < 8) {\n            console.log(\"Cannot build bezier path. The passed array must contain at least 8 elements (numbers).\");\n            throw \"Cannot build bezier path. The passed array must contain at least 8 elements (numbers).\";\n        }\n        return BezierPath.fromReducedList(pointArray, adjustCircular);\n    }\n    /**\n     * Convert a reduced list representation (array of numeric coordinates) to a BezierPath instance.\n     *\n     * The array's length must be 6*n + 2:\n     *  - [sx, sy,  scx, scy,  ecx, ecy, ... , ex,  ey ]\n     *     |                               |   |     |\n     *     +--- sequence of curves --------+   +-end-+\n     *\n     * @param {number[]} pointArray\n     * @returns BezierPath\n     */\n    static fromReducedList(pointArray, adjustCircular) {\n        // Convert to object\n        var bezierPath = new BezierPath(null); // No points yet\n        var startPoint = new Vertex();\n        var startControlPoint;\n        var endControlPoint;\n        var endPoint;\n        var i = 0;\n        do {\n            if (i == 0) {\n                // firstStartPoint =\n                startPoint = new Vertex(pointArray[i], pointArray[i + 1]);\n            }\n            startControlPoint = new Vertex(pointArray[i + 2], pointArray[i + 3]);\n            endControlPoint = new Vertex(pointArray[i + 4], pointArray[i + 5]);\n            // if (i + 8 >= pointArray.length) {\n            //   endPoint = firstStartPoint;\n            // } else {\n            endPoint = new Vertex(pointArray[i + 6], pointArray[i + 7]);\n            // }\n            var bCurve = new CubicBezierCurve(startPoint, endPoint, startControlPoint, endControlPoint);\n            bezierPath.bezierCurves.push(bCurve);\n            startPoint = endPoint;\n            i += 6;\n        } while (i + 2 < pointArray.length);\n        bezierPath.adjustCircular = adjustCircular !== null && adjustCircular !== void 0 ? adjustCircular : false;\n        if (adjustCircular) {\n            bezierPath.bezierCurves[bezierPath.bezierCurves.length - 1].endPoint = bezierPath.bezierCurves[0].startPoint;\n        }\n        bezierPath.updateArcLengths();\n        return bezierPath;\n    }\n}\n// +---------------------------------------------------------------------------------\n// | These constants equal the values from CubicBezierCurve.\n// +-------------------------------\n/** @constant {number} */\nBezierPath.START_POINT = 0;\n/** @constant {number} */\nBezierPath.START_CONTROL_POINT = 1;\n/** @constant {number} */\nBezierPath.END_CONTROL_POINT = 2;\n/** @constant {number} */\nBezierPath.END_POINT = 3;\n//# sourceMappingURL=BezierPath.js.map","/**\n * @author   Ikaros Kappler\n * @date     2016-03-12\n * @modified 2018-12-05 Refactored the code from the morley-triangle script.\n * @modified 2019-03-20 Added JSDoc tags.\n * @modified 2019-04-28 Fixed a bug in the Line.sub( Vertex ) function (was not working).\n * @modified 2019-09-02 Added the Line.add( Vertex ) function.\n * @modified 2019-09-02 Added the Line.denominator( Line ) function.\n * @modified 2019-09-02 Added the Line.colinear( Line ) function.\n * @modified 2019-09-02 Fixed an error in the Line.intersection( Line ) function (class Point was renamed to Vertex).\n * @modified 2019-12-15 Added the Line.moveTo(Vertex) function.\n * @modified 2020-03-16 The Line.angle(Line) parameter is now optional. The baseline (x-axis) will be used if not defined.\n * @modified 2020-03-23 Ported to Typescript from JS.\n * @modified 2020-12-04 The `intersection` function returns undefined if both lines are parallel.\n * @modified 2022-02-02 Added the `destroy` method.\n * @modified 2022-10-09 Changed the actual return value of the `intersection` function to null (was undefined before).\n * @modified 2022-10-17 Adding these methods from the `PathSegment` interface: getStartPoint, getEndPoint, revert.\n * @version  2.3.0\n *\n * @file Line\n * @public\n **/\nimport { VertTuple } from \"./VertTuple\";\nimport { Vertex } from \"./Vertex\";\n/**\n * @classdesc A line consists of two vertices a and b.<br>\n * <br>\n * This is some refactored code from my 'Morley Triangle' test<br>\n *   https://github.com/IkarosKappler/morleys-trisector-theorem\n *\n * @requires Vertex\n */\nexport class Line extends VertTuple {\n    /**\n     * Creates an instance of Line.\n     *\n     * @constructor\n     * @name Line\n     * @param {Vertex} a The line's first point.\n     * @param {Vertex} b The line's second point.\n     **/\n    constructor(a, b) {\n        super(a, b, (a, b) => new Line(a, b));\n        /**\n         * Required to generate proper CSS classes and other class related IDs.\n         **/\n        this.className = \"Line\";\n    }\n    /**\n     * Get the intersection if this line and the specified line.\n     *\n     * @method intersection\n     * @param {Line} line The second line.\n     * @return {Vertex|undefined} The intersection (may lie outside the end-points) or `undefined` if both lines are parallel.\n     * @instance\n     * @memberof Line\n     **/\n    // !!! DO NOT MOVE TO VertTuple\n    intersection(line) {\n        const denominator = this.denominator(line);\n        if (denominator == 0) {\n            return null;\n        }\n        let a = this.a.y - line.a.y;\n        let b = this.a.x - line.a.x;\n        const numerator1 = (line.b.x - line.a.x) * a - (line.b.y - line.a.y) * b;\n        const numerator2 = (this.b.x - this.a.x) * a - (this.b.y - this.a.y) * b;\n        a = numerator1 / denominator; // NaN if parallel lines\n        b = numerator2 / denominator;\n        // Catch NaN?\n        const x = this.a.x + a * (this.b.x - this.a.x);\n        const y = this.a.y + a * (this.b.y - this.a.y);\n        if (isNaN(a) || isNaN(x) || isNaN(y)) {\n            return null;\n        }\n        // if we cast these lines infinitely in both directions, they intersect here:\n        return new Vertex(x, y);\n    }\n    //--- Implement PathSegment ---\n    /**\n     * Get the start point of this path segment.\n     *\n     * @method getStartPoint\n     * @memberof PathSegment\n     * @return {Vertex} The start point of this path segment.\n     */\n    getStartPoint() {\n        return this.a;\n    }\n    /**\n     * Get the end point of this path segment.\n     *\n     * @method getEndPoint\n     * @memberof PathSegment\n     * @return {Vertex} The end point of this path segment.\n     */\n    getEndPoint() {\n        return this.b;\n    }\n    /**\n     * Get the tangent's end point at the start point of this segment.\n     *\n     * @method getStartTangent\n     * @memberof PathSegment\n     * @return {Vertex} The end point of the starting point's tangent.\n     */\n    getStartTangent() {\n        return this.b;\n    }\n    /**\n     * Get the tangent's end point at the end point of this segment.\n     *\n     * @method getEndTangent\n     * @memberof PathSegment\n     * @return {Vertex} The end point of the ending point's tangent.\n     */\n    getEndTangent() {\n        return this.a;\n    }\n    /**\n     * Inverse this path segment (in-place) and return this same instance (useful for chaining).\n     *\n     * @method reverse\n     * @memberof PathSegment\n     * @return {PathSegment} This path segment instance (for chaining).\n     */\n    reverse() {\n        var tmp = this.a;\n        this.a = this.b;\n        this.b = tmp;\n        return this;\n    }\n}\n//# sourceMappingURL=Line.js.map","/**\n * @author   Ikaros Kappler\n * @date     2020-05-04\n * @modified 2020-05-09 Ported to typescript.\n * @modified 2020-05-25 Added the vertAt and tangentAt functions.\n * @mofidied 2020-09-07 Added the circleIntersection(Circle) function.\n * @modified 2020-09-07 Changed the vertAt function by switching sin and cos! The old version did not return the correct vertex (by angle) accoring to the assumed circle math.\n * @modified 2020-10-16 Added the containsCircle(...) function.\n * @modified 2021-01-20 Added UID.\n * @modified 2022-02-02 Added the `destroy` method.\n * @modified 2022-02-02 Cleared the `toSVGString` function (deprecated). Use `drawutilssvg` instead.\n * @modified 2022-08-15 Added the `containsPoint` function.\n * @modified 2022-08-23 Added the `lineIntersection` function.\n * @modified 2022-08-23 Added the `closestPoint` function.\n * @version  1.4.0\n **/\nimport { Line } from \"./Line\";\nimport { UIDGenerator } from \"./UIDGenerator\";\nimport { Vector } from \"./Vector\";\nimport { Vertex } from \"./Vertex\";\n/**\n * @classdesc A simple circle: center point and radius.\n *\n * @requires Line\n * @requires Vector\n * @requires VertTuple\n * @requires Vertex\n * @requires SVGSerializale\n * @requires UID\n * @requires UIDGenerator\n **/\nexport class Circle {\n    /**\n     * Create a new circle with given center point and radius.\n     *\n     * @constructor\n     * @name Circle\n     * @param {Vertex} center - The center point of the circle.\n     * @param {number} radius - The radius of the circle.\n     */\n    constructor(center, radius) {\n        /**\n         * Required to generate proper CSS classes and other class related IDs.\n         **/\n        this.className = \"Circle\";\n        this.uid = UIDGenerator.next();\n        this.center = center;\n        this.radius = radius;\n    }\n    /**\n     * Check if the given circle is fully contained inside this circle.\n     *\n     * @method containsPoint\n     * @param {XYCoords} point - The point to check if it is contained in this circle.\n     * @instance\n     * @memberof Circle\n     * @return {boolean} `true` if the given point is inside this circle.\n     */\n    containsPoint(point) {\n        return this.center.distance(point) < this.radius;\n    }\n    /**\n     * Check if the given circle is fully contained inside this circle.\n     *\n     * @method containsCircle\n     * @param {Circle} circle - The circle to check if it is contained in this circle.\n     * @instance\n     * @memberof Circle\n     * @return {boolean} `true` if any only if the given circle is completely inside this circle.\n     */\n    containsCircle(circle) {\n        return this.center.distance(circle.center) + circle.radius < this.radius;\n    }\n    /**\n     * Calculate the distance from this circle to the given line.\n     *\n     * * If the line does not intersect this ciecle then the returned\n     *   value will be the minimal distance.\n     * * If the line goes through this circle then the returned value\n     *   will be max inner distance and it will be negative.\n     *\n     * @method lineDistance\n     * @param {Line} line - The line to measure the distance to.\n     * @return {number} The minimal distance from the outline of this circle to the given line.\n     * @instance\n     * @memberof Circle\n     */\n    lineDistance(line) {\n        const closestPointOnLine = line.getClosestPoint(this.center);\n        return closestPointOnLine.distance(this.center) - this.radius;\n    }\n    /**\n     * Get the vertex on the this circle for the given angle.\n     *\n     * @method vertAt\n     * @param {number} angle - The angle (in radians) to use.\n     * @return {Vertex} The vertex (point) at the given angle.\n     * @instance\n     * @memberof Circle\n     **/\n    vertAt(angle) {\n        // Find the point on the circle respective the angle. Then move relative to center.\n        return Circle.circleUtils.vertAt(angle, this.radius).add(this.center);\n    }\n    /**\n     * Get a tangent line of this circle for a given angle.\n     *\n     * Point a of the returned line is located on the circle, the length equals the radius.\n     *\n     * @method tangentAt\n     * @instance\n     * @param {number} angle - The angle (in radians) to use.\n     * @return {Line} The tangent line.\n     * @memberof Circle\n     **/\n    tangentAt(angle) {\n        const pointA = Circle.circleUtils.vertAt(angle, this.radius);\n        // Construct the perpendicular of the line in point a. Then move relative to center.\n        return new Vector(pointA, new Vertex(0, 0)).add(this.center).perp();\n    }\n    /**\n     * Calculate the intersection points (if exists) with the given circle.\n     *\n     * @method circleIntersection\n     * @instance\n     * @memberof Circle\n     * @param {Circle} circle\n     * @return {Line|null} The intersection points (as a line) or null if the two circles do not intersect.\n     **/\n    circleIntersection(circle) {\n        // Circles do not intersect at all?\n        if (this.center.distance(circle.center) > this.radius + circle.radius) {\n            return null;\n        }\n        // One circle is fully inside the other?\n        if (this.center.distance(circle.center) < Math.abs(this.radius - circle.radius)) {\n            return null;\n        }\n        // Based on the C++ implementation by Robert King\n        //    https://stackoverflow.com/questions/3349125/circle-circle-intersection-points\n        // and the 'Circles and spheres' article by Paul Bourke.\n        //    http://paulbourke.net/geometry/circlesphere/\n        //\n        // This is the original C++ implementation:\n        //\n        // pair<Point, Point> intersections(Circle c) {\n        //    Point P0(x, y);\n        //    Point P1(c.x, c.y);\n        //    float d, a, h;\n        //    d = P0.distance(P1);\n        //    a = (r*r - c.r*c.r + d*d)/(2*d);\n        //    h = sqrt(r*r - a*a);\n        //    Point P2 = P1.sub(P0).scale(a/d).add(P0);\n        //    float x3, y3, x4, y4;\n        //    x3 = P2.x + h*(P1.y - P0.y)/d;\n        //    y3 = P2.y - h*(P1.x - P0.x)/d;\n        //    x4 = P2.x - h*(P1.y - P0.y)/d;\n        //    y4 = P2.y + h*(P1.x - P0.x)/d;\n        //    return pair<Point, Point>(Point(x3, y3), Point(x4, y4));\n        // }\n        var p0 = this.center;\n        var p1 = circle.center;\n        var d = p0.distance(p1);\n        var a = (this.radius * this.radius - circle.radius * circle.radius + d * d) / (2 * d);\n        var h = Math.sqrt(this.radius * this.radius - a * a);\n        var p2 = p1.clone().scale(a / d, p0);\n        var x3 = p2.x + (h * (p1.y - p0.y)) / d;\n        var y3 = p2.y - (h * (p1.x - p0.x)) / d;\n        var x4 = p2.x - (h * (p1.y - p0.y)) / d;\n        var y4 = p2.y + (h * (p1.x - p0.x)) / d;\n        return new Line(new Vertex(x3, y3), new Vertex(x4, y4));\n    }\n    /**\n     * Calculate the intersection points (if exists) with the given infinite line (defined by two points).\n     *\n     * @method lineIntersection\n     * @instance\n     * @memberof Circle\n     * @param {Vertex} a- The first of the two points defining the line.\n     * @param {Vertex} b - The second of the two points defining the line.\n     * @return {Line|null} The intersection points (as a line) or null if this circle does not intersect the line given.\n     **/\n    lineIntersection(a, b) {\n        // Based on the math from\n        //    https://mathworld.wolfram.com/Circle-LineIntersection.html\n        const interA = new Vertex();\n        const interB = new Vertex();\n        // First do a transformation, because the calculation is based on a cicle at (0,0)\n        const transA = new Vertex(a).sub(this.center);\n        const transB = new Vertex(b).sub(this.center);\n        const diff = transA.difference(transB);\n        // There is a special case if diff.y=0, where the intersection is not calcuatable.\n        // Use an non-zero epsilon here to approximate this case.\n        // TODO for the future: find a better solution\n        if (Math.abs(diff.y) === 0) {\n            diff.y = 0.000001;\n        }\n        const dist = transA.distance(transB);\n        const det = transA.x * transB.y - transA.y * transB.x;\n        const distSquared = dist * dist;\n        const radiusSquared = this.radius * this.radius;\n        // Check if circle and line have an intersection at all\n        if (radiusSquared * distSquared - det * det < 0) {\n            return null;\n        }\n        const belowSqrt = this.radius * this.radius * dist * dist - det * det;\n        const sqrt = Math.sqrt(belowSqrt);\n        interA.x = (det * diff.y + Math.sign(diff.y) * diff.x * sqrt) / distSquared;\n        interB.x = (det * diff.y - Math.sign(diff.y) * diff.x * sqrt) / distSquared;\n        interA.y = (-det * diff.x + Math.abs(diff.y) * sqrt) / distSquared;\n        interB.y = (-det * diff.x - Math.abs(diff.y) * sqrt) / distSquared;\n        return new Line(interA.add(this.center), interB.add(this.center));\n        // return new Line(interA, interB);\n    }\n    /**\n     * Calculate the closest point on the outline of this circle to the given point.\n     *\n     * @method closestPoint\n     * @instance\n     * @memberof Circle\n     * @param {XYCoords} vert - The point to find the closest circle point for.\n     * @return {Vertex} The closest point on this circle.\n     **/\n    closestPoint(vert) {\n        const lineIntersection = this.lineIntersection(this.center, vert);\n        if (!lineIntersection) {\n            // Note: this case should not happen as a radial from the center always intersect this circle.\n            return new Vertex();\n        }\n        // Return closed of both\n        if (lineIntersection.a.distance(vert) < lineIntersection.b.distance(vert)) {\n            return lineIntersection.a;\n        }\n        else {\n            return lineIntersection.b;\n        }\n    }\n    /**\n     * This function should invalidate any installed listeners and invalidate this object.\n     * After calling this function the object might not hold valid data any more and\n     * should not be used.\n     */\n    destroy() {\n        this.center.destroy();\n        this.isDestroyed = true;\n    }\n} // END class\nCircle.circleUtils = {\n    vertAt: (angle, radius) => {\n        /* return new Vertex( Math.sin(angle) * radius,\n                     Math.cos(angle) * radius ); */\n        return new Vertex(Math.cos(angle) * radius, Math.sin(angle) * radius);\n    }\n};\n//# sourceMappingURL=Circle.js.map","/**\n * @author   Ikaros Kappler\n * @date     2020-12-17\n * @modified 2021-01-20 Added UID.\n * @modified 2021-02-26 Fixed an error in the svg-arc-calculation (case angle<90deg and anti-clockwise).\n * @version  1.1.1\n **/\nimport { UIDGenerator } from \"./UIDGenerator\";\n/**\n * @classdesc A simple circle sector: circle, start- and end-angle.\n *\n * @requires Line\n * @requires SVGSerializale\n * @requires UID\n * @requires UIDGenerator\n * @requires XYCoords\n **/\nexport class CircleSector {\n    /**\n     * Create a new circle sector with given circle, start- and end-angle.\n     *\n     * @constructor\n     * @name CircleSector\n     * @param {Circle} circle - The circle.\n     * @param {number} startAngle - The start angle of the sector.\n     * @param {number} endAngle - The end angle of the sector.\n     */\n    constructor(circle, startAngle, endAngle) {\n        /**\n         * Required to generate proper CSS classes and other class related IDs.\n         **/\n        this.className = \"CircleSector\";\n        this.uid = UIDGenerator.next();\n        this.circle = circle;\n        this.startAngle = startAngle;\n        this.endAngle = endAngle;\n    }\n    /**\n     * This function should invalidate any installed listeners and invalidate this object.\n     * After calling this function the object might not hold valid data any more and\n     * should not be used.\n     */\n    destroy() {\n        this.circle.destroy();\n        this.isDestroyed = true;\n    }\n} // END class\nCircleSector.circleSectorUtils = {\n    /**\n     * Helper function to convert polar circle coordinates to cartesian coordinates.\n     *\n     * TODO: generalize for ellipses (two radii).\n     *\n     * @param {number} angle - The angle in radians.\n     */\n    polarToCartesian: (centerX, centerY, radius, angle) => {\n        return {\n            x: centerX + radius * Math.cos(angle),\n            y: centerY + radius * Math.sin(angle)\n        };\n    },\n    /**\n     * Helper function to convert a circle section as SVG arc params (for the `d` attribute).\n     * Found at: https://stackoverflow.com/questions/5736398/how-to-calculate-the-svg-path-for-an-arc-of-a-circle\n     *\n     * TODO: generalize for ellipses (two radii).\n     *\n     * @param {boolean} options.moveToStart - If false (default=true) the initial 'Move' command will not be used.\n     * @return [ 'A', radiusx, radiusy, rotation=0, largeArcFlag=1|0, sweepFlag=0, endx, endy ]\n     */\n    describeSVGArc: (x, y, radius, startAngle, endAngle, options) => {\n        if (typeof options === \"undefined\")\n            options = { moveToStart: true };\n        const end = CircleSector.circleSectorUtils.polarToCartesian(x, y, radius, endAngle);\n        const start = CircleSector.circleSectorUtils.polarToCartesian(x, y, radius, startAngle);\n        // Split full circles into two halves.\n        // Some browsers have problems to render full circles (described by start==end).\n        if (Math.PI * 2 - Math.abs(startAngle - endAngle) < 0.001) {\n            const firstHalf = CircleSector.circleSectorUtils.describeSVGArc(x, y, radius, startAngle, startAngle + (endAngle - startAngle) / 2, options);\n            const secondHalf = CircleSector.circleSectorUtils.describeSVGArc(x, y, radius, startAngle + (endAngle - startAngle) / 2, endAngle, options);\n            return firstHalf.concat(secondHalf);\n        }\n        // Boolean stored as integers (0|1).\n        const diff = endAngle - startAngle;\n        var largeArcFlag;\n        var sweepFlag;\n        if (diff < 0) {\n            largeArcFlag = Math.abs(diff) < Math.PI ? 1 : 0;\n            sweepFlag = 1;\n        }\n        else {\n            largeArcFlag = Math.abs(diff) > Math.PI ? 1 : 0;\n            sweepFlag = 1;\n        }\n        const pathData = [];\n        if (options.moveToStart) {\n            pathData.push(\"M\", start.x, start.y);\n        }\n        pathData.push(\"A\", radius, radius, 0, largeArcFlag, sweepFlag, end.x, end.y);\n        return pathData;\n    }\n};\n//# sourceMappingURL=CircleSector.js.map","/**\n * Draws elements into an SVG node.\n *\n * Note that this library uses buffers and draw cycles. To draw onto an SVG canvas, do this:\n *   const drawLib = new drawutilssvg( svgNode, ... );\n *   const fillLib = drawLib.copyInstance(true);\n *   // Begin draw cycle\n *   drawLib.beginDrawCycle(time);\n *   // ... draw or fill your stuff ...\n *   drawLib.endDrawCycle(time); // Here the elements become visible\n *\n * @author   Ikaros Kappler\n * @date     2021-01-03\n * @modified 2021-01-24 Fixed the `fillShapes` attribute in the copyInstance function.\n * @modified 2021-01-26 Changed the `isPrimary` (default true) attribute to `isSecondary` (default false).\n * @modified 2021-02-03 Added the static `createSvg` function.\n * @modified 2021-02-03 Fixed the currentId='background' bug on the clear() function.\n * @modified 2021-02-03 Fixed CSSProperty `stroke-width` (was line-width before, which is wrong).\n * @modified 2021-02-03 Added the static `HEAD_XML` attribute.\n * @modified 2021-02-19 Added the static helper function `transformPathData(...)` for svg path transformations (scale and translate).\n * @modified 2021-02-22 Added the static helper function `copyPathData(...)`.\n * @modified 2021-02-22 Added the `path` drawing function to draw SVG path data.\n * @modified 2021-03-01 Fixed a bug in the `clear` function (curClassName was not cleared).\n * @modified 2021-03-29 Fixed a bug in the `text` function (second y param was wrong, used x here).\n * @modified 2021-03-29 Moved this file from `src/ts/utils/helpers/` to `src/ts/`.\n * @modified 2021-03-31 Added 'ellipseSector' the the class names.\n * @modified 2021-03-31 Implemented buffering using a buffer <g> node and the beginDrawCycle and endDrawCycle methods.\n * @modified 2021-05-31 Added the `setConfiguration` function from `DrawLib`.\n * @modified 2021-11-15 Adding more parameters tot the `text()` function: fontSize, textAlign, fontFamily, lineHeight.\n * @modified 2021-11-19 Fixing the `label(text,x,y)` position.\n * @modified 2021-11-19 Added the `color` param to the `label(...)` function.\n * @modified 2022-02-03 Added the `lineWidth` param to the `crosshair` function.\n * @modified 2022-02-03 Added the `cross(...)` function.\n * @modified 2022-03-26 Added the private `nodeDefs` and `bufferedNodeDefs` attributes.\n * @modified 2022-03-26 Added the `texturedPoly` function to draw textures polygons.\n * @modified 2022-07-26 Adding `alpha` to the `image(...)` function.\n * @modified 2022-11-10 Tweaking some type issues.\n * @modified 2023-02-04 Fixed a typo in the CSS classname for cubic Bézier paths: cubicBezier (was cubierBezier).\n * @modified 2023-02-10 The methods `setCurrentClassName` and `setCurrentId` also accept `null` now.\n * @version  1.6.4\n **/\nimport { CircleSector } from \"./CircleSector\";\nimport { CubicBezierCurve } from \"./CubicBezierCurve\";\nimport { Vertex } from \"./Vertex\";\nimport { UIDGenerator } from \"./UIDGenerator\";\nconst RAD_TO_DEG = 180 / Math.PI;\n/**\n * @classdesc A helper class for basic SVG drawing operations. This class should\n * be compatible to the default 'draw' class.\n *\n * @requires CubicBzierCurvce\n * @requires Polygon\n * @requires Vertex\n * @requires XYCoords\n */\nexport class drawutilssvg {\n    /**\n     * The constructor.\n     *\n     * @constructor\n     * @name drawutilssvg\n     * @param {SVGElement} svgNode - The SVG node to use.\n     * @param {XYCoords} offset - The draw offset to use.\n     * @param {XYCoords} scale - The scale factors to use.\n     * @param {XYDimension} canvasSize - The initial canvas size (use setSize to change).\n     * @param {boolean} fillShapes - Indicates if the constructed drawutils should fill all drawn shapes (if possible).\n     * @param {DrawConfig} drawConfig - The default draw config to use for CSS fallback styles.\n     * @param {boolean=} isSecondary - (optional) Indicates if this is the primary or secondary instance. Only primary instances manage child nodes.\n     * @param {SVGGElement=} gNode - (optional) Primary and seconday instances share the same &lt;g> node.\n     **/\n    constructor(svgNode, offset, scale, canvasSize, fillShapes, drawConfig, isSecondary, gNode, bufferGNode, nodeDefs, bufferNodeDefs) {\n        this.svgNode = svgNode;\n        this.offset = new Vertex(0, 0).set(offset);\n        this.scale = new Vertex(1, 1).set(scale);\n        this.fillShapes = fillShapes;\n        this.isSecondary = Boolean(isSecondary);\n        this.drawlibConfiguration = {};\n        this.cache = new Map();\n        this.setSize(canvasSize);\n        if (isSecondary) {\n            this.gNode = gNode;\n            this.bufferGNode = bufferGNode;\n            this.nodeDefs = nodeDefs;\n            this.bufferedNodeDefs = bufferNodeDefs;\n        }\n        else {\n            this.addStyleDefs(drawConfig);\n            this.addDefsNode();\n            this.gNode = this.createSVGNode(\"g\");\n            this.bufferGNode = this.createSVGNode(\"g\");\n            this.svgNode.appendChild(this.gNode);\n        }\n    }\n    /**\n     * Adds a default style defintion based on the passed DrawConfig.\n     * Twaek the draw config to change default colors or line thicknesses.\n     *\n     * @param {DrawConfig} drawConfig\n     */\n    addStyleDefs(drawConfig) {\n        this.nodeStyle = this.createSVGNode(\"style\");\n        this.svgNode.appendChild(this.nodeStyle);\n        // Which default styles to add? -> All from the DrawConfig.\n        // Compare with DrawConfig interface\n        const keys = {\n            // \"bezier\": \"CubicBezierCurve\", // TODO: is this correct?\n            \"bezierPath\": \"BezierPath\",\n            \"polygon\": \"Polygon\",\n            \"triangle\": \"Triangle\",\n            \"ellipse\": \"Ellipse\",\n            \"ellipseSector\": \"EllipseSector\",\n            \"circle\": \"Circle\",\n            \"circleSector\": \"CircleSector\",\n            \"vertex\": \"Vertex\",\n            \"line\": \"Line\",\n            \"vector\": \"Vector\",\n            \"image\": \"Image\",\n            \"text\": \"Text\"\n        };\n        // Question: why isn't this working if the svgNode is created dynamically? (nodeStyle.sheet is null)\n        const rules = [];\n        for (var k in keys) {\n            const className = keys[k];\n            const drawSettings = drawConfig[k];\n            if (drawSettings) {\n                rules.push(`.${className} { fill : none; stroke: ${drawSettings.color}; stroke-width: ${drawSettings.lineWidth}px }`);\n            }\n            else {\n                console.warn(`Warning: your draw config is missing the key '${k}' which is required.`);\n            }\n        }\n        this.nodeStyle.innerHTML = rules.join(\"\\n\");\n    }\n    /**\n     * Adds the internal <defs> node.\n     */\n    addDefsNode() {\n        this.nodeDefs = this.createSVGNode(\"defs\");\n        // this.svgNode.appendChild(this.nodeDefs);\n        this.bufferedNodeDefs = this.createSVGNode(\"defs\");\n        this.svgNode.appendChild(this.nodeDefs);\n    }\n    /**\n     * This is a simple way to include custom CSS class mappings to the style defs of the generated SVG.\n     *\n     * The mapping should be of the form\n     *   [style-class] -> [style-def-string]\n     *\n     * Example:\n     *   \"rect.red\" -> \"fill: #ff0000; border: 1px solid red\"\n     *\n     * @param {Map<string,string>} defs\n     */\n    addCustomStyleDefs(defs) {\n        const buffer = [];\n        defs.forEach((value, key) => {\n            buffer.push(key + \" { \" + value + \" }\");\n        });\n        this.nodeStyle.innerHTML += \"\\n/* Custom styles */\\n\" + buffer.join(\"\\n\");\n    }\n    /**\n     * Retieve an old (cached) element.\n     * Only if both – key and nodeName – match, the element will be returned (null otherwise).\n     *\n     * @method findElement\n     * @private\n     * @memberof drawutilssvg\n     * @instance\n     * @param {UID} key - The key of the desired element (used when re-drawing).\n     * @param {string} nodeName - The expected node name.\n     */\n    findElement(key, nodeName) {\n        if (!key) {\n            return null;\n        }\n        var node = this.cache.get(key);\n        if (node && node.nodeName.toUpperCase() === nodeName.toUpperCase()) {\n            this.cache.delete(key);\n            return node;\n        }\n        return null;\n    }\n    /**\n     * Create a new DOM node &lt;svg&gt; in the SVG namespace.\n     *\n     * @method createSVGNode\n     * @private\n     * @memberof drawutilssvg\n     * @instance\n     * @param {string} nodeName - The node name (tag-name).\n     * @return {SVGElement} A new element in the SVG namespace with the given node name.\n     */\n    createSVGNode(nodeName) {\n        return document.createElementNS(\"http://www.w3.org/2000/svg\", nodeName);\n    }\n    /**\n     * Make a new SVG node (or recycle an old one) with the given node name (circle, path, line, rect, ...).\n     *\n     * This function is used in draw cycles to re-use old DOM nodes (in hope to boost performance).\n     *\n     * @method makeNode\n     * @private\n     * @instance\n     * @memberof drawutilssvg\n     * @param {string} nodeName - The node name.\n     * @return {SVGElement} The new node, which is not yet added to any document.\n     */\n    makeNode(nodeName) {\n        // Try to find node in current DOM cache.\n        // Unique node keys are strictly necessary.\n        // Try to recycle an old element from cache.\n        var node = this.findElement(this.curId, nodeName);\n        if (!node) {\n            // If no such old elements exists (key not found, tag name not matching),\n            // then create a new one.\n            node = this.createSVGNode(nodeName);\n        }\n        if (this.drawlibConfiguration.blendMode) {\n            node.style[\"mix-blend-mode\"] = this.drawlibConfiguration.blendMode;\n        }\n        return node;\n    }\n    /**\n     * This is the final helper function for drawing and filling stuff and binding new\n     * nodes to the SVG document.\n     * It is not intended to be used from the outside.\n     *\n     * When in draw mode it draws the current shape.\n     * When in fill mode it fills the current shape.\n     *\n     * This function is usually only called internally.\n     *\n     * @method _bindFillDraw\n     * @private\n     * @instance\n     * @memberof drawutilssvg\n     * @param {SVGElement} node - The node to draw/fill and bind.\n     * @param {string} className - The class name(s) to use.\n     * @param {string} color - A stroke/fill color to use.\n     * @param {number=1} lineWidth - (optional) A line width to use for drawing (default is 1).\n     * @return {SVGElement} The node itself (for chaining).\n     */\n    _bindFillDraw(node, className, color, lineWidth) {\n        if (this.curClassName) {\n            node.setAttribute(\"class\", `${className} ${this.curClassName}`);\n        }\n        else {\n            node.setAttribute(\"class\", className);\n        }\n        node.setAttribute(\"fill\", this.fillShapes && color ? color : \"none\");\n        node.setAttribute(\"stroke\", this.fillShapes ? \"none\" : color || \"none\");\n        node.setAttribute(\"stroke-width\", `${lineWidth || 1}`);\n        if (this.curId) {\n            node.setAttribute(\"id\", `${this.curId}`); // Maybe React-style 'key' would be better?\n        }\n        if (!node.parentNode) {\n            // Attach to DOM only if not already attached\n            this.bufferGNode.appendChild(node);\n        }\n        return node;\n    }\n    /**\n     * Sets the size and view box of the document. Call this if canvas size changes.\n     *\n     * @method setSize\n     * @instance\n     * @memberof drawutilssvg\n     * @param {XYDimension} canvasSize - The new canvas size.\n     */\n    setSize(canvasSize) {\n        this.canvasSize = canvasSize;\n        this.svgNode.setAttribute(\"viewBox\", `0 0 ${this.canvasSize.width} ${this.canvasSize.height}`);\n        this.svgNode.setAttribute(\"width\", `${this.canvasSize.width}`);\n        this.svgNode.setAttribute(\"height\", `${this.canvasSize.height}`);\n    }\n    /**\n     * Creates a 'shallow' (non deep) copy of this instance. This implies\n     * that under the hood the same gl context and gl program will be used.\n     */\n    copyInstance(fillShapes) {\n        var copy = new drawutilssvg(this.svgNode, this.offset, this.scale, this.canvasSize, fillShapes, null, // no DrawConfig\n        true, // isSecondary\n        this.gNode, this.bufferGNode, this.nodeDefs, this.bufferedNodeDefs);\n        return copy;\n    }\n    /**\n     * Set the current drawlib configuration.\n     *\n     * @name setConfiguration\n     * @method\n     * @param {DrawLibConfiguration} configuration - The new configuration settings to use for the next render methods.\n     */\n    setConfiguration(configuration) {\n        this.drawlibConfiguration = configuration;\n    }\n    /**\n     * This method shouled be called each time the currently drawn `Drawable` changes.\n     * It is used by some libraries for identifying elemente on re-renders.\n     *\n     * @name setCurrentId\n     * @method\n     * @param {UID|null} uid - A UID identifying the currently drawn element(s).\n     * @instance\n     * @memberof drawutilssvg\n     **/\n    setCurrentId(uid) {\n        this.curId = uid;\n    }\n    /**\n     * This method shouled be called each time the currently drawn `Drawable` changes.\n     * Determine the class name for further usage here.\n     *\n     * @name setCurrentClassName\n     * @method\n     * @param {string|null} className - A class name for further custom use cases.\n     * @instance\n     * @memberof drawutilssvg\n     **/\n    setCurrentClassName(className) {\n        this.curClassName = className;\n    }\n    /**\n     * Called before each draw cycle.\n     * This is required for compatibility with other draw classes in the library.\n     *\n     * @name beginDrawCycle\n     * @method\n     * @param {UID=} uid - (optional) A UID identifying the currently drawn element(s).\n     * @instance\n     * @memberof drawutilssvg\n     **/\n    beginDrawCycle(renderTime) {\n        // Clear non-recycable elements from last draw cycle.\n        this.cache.clear();\n        // Clearing an SVG is equivalent to removing all its child elements.\n        for (var i = 0; i < this.bufferGNode.childNodes.length; i++) {\n            // Hide all nodes here. Don't throw them away.\n            // We can probably re-use them in the next draw cycle.\n            var child = this.bufferGNode.childNodes[i];\n            this.cache.set(child.getAttribute(\"id\"), child);\n        }\n        this.removeAllChildNodes();\n    }\n    /**\n     * Called after each draw cycle.\n     *\n     * This is required for compatibility with other draw classes in the library (like drawgl).\n     *\n     * @name endDrawCycle\n     * @method\n     * @param {number} renderTime\n     * @instance\n     **/\n    endDrawCycle(renderTime) {\n        if (!this.isSecondary) {\n            // All elements are drawn into the buffer; they are NOT yet visible, not did the browser perform any\n            // layout updates.\n            // Replace the old <g>-node with the buffer node.\n            //   https://stackoverflow.com/questions/27442464/how-to-update-a-svg-image-without-seeing-a-blinking\n            this.svgNode.replaceChild(this.bufferedNodeDefs, this.nodeDefs);\n            this.svgNode.replaceChild(this.bufferGNode, this.gNode);\n        }\n        const tmpGNode = this.gNode;\n        this.gNode = this.bufferGNode;\n        this.bufferGNode = tmpGNode;\n        const tmpDefsNode = this.nodeDefs;\n        this.nodeDefs = this.bufferedNodeDefs;\n        this.bufferedNodeDefs = tmpDefsNode;\n    }\n    _x(x) {\n        return this.offset.x + this.scale.x * x;\n    }\n    _y(y) {\n        return this.offset.y + this.scale.y * y;\n    }\n    /**\n     * Draw the line between the given two points with the specified (CSS-) color.\n     *\n     * @method line\n     * @param {Vertex} zA - The start point of the line.\n     * @param {Vertex} zB - The end point of the line.\n     * @param {string} color - Any valid CSS color string.\n     * @param {number=1} lineWidth? - [optional] The line's width.\n     * @return {void}\n     * @instance\n     * @memberof drawutilssvg\n     **/\n    line(zA, zB, color, lineWidth) {\n        const line = this.makeNode(\"line\");\n        line.setAttribute(\"x1\", `${this._x(zA.x)}`);\n        line.setAttribute(\"y1\", `${this._y(zA.y)}`);\n        line.setAttribute(\"x2\", `${this._x(zB.x)}`);\n        line.setAttribute(\"y2\", `${this._y(zB.y)}`);\n        return this._bindFillDraw(line, \"line\", color, lineWidth || 1);\n    }\n    /**\n     * Draw a line and an arrow at the end (zB) of the given line with the specified (CSS-) color.\n     *\n     * @method arrow\n     * @param {Vertex} zA - The start point of the arrow-line.\n     * @param {Vertex} zB - The end point of the arrow-line.\n     * @param {string} color - Any valid CSS color string.\n     * @param {number=} lineWidth - (optional) The line width to use; default is 1.\n     * @return {void}\n     * @instance\n     * @memberof drawutilssvg\n     **/\n    arrow(zA, zB, color, lineWidth) {\n        const node = this.makeNode(\"path\");\n        var headlen = 8; // length of head in pixels\n        var vertices = Vertex.utils.buildArrowHead(zA, zB, headlen, this.scale.x, this.scale.y);\n        const d = [\"M\", this._x(zA.x), this._y(zA.y)];\n        for (var i = 0; i <= vertices.length; i++) {\n            d.push(\"L\");\n            // Note: only use offset here (the vertices are already scaled)\n            d.push(this.offset.x + vertices[i % vertices.length].x);\n            d.push(this.offset.y + vertices[i % vertices.length].y);\n        }\n        node.setAttribute(\"d\", d.join(\" \"));\n        return this._bindFillDraw(node, \"arrow\", color, lineWidth || 1);\n    }\n    /**\n     * Draw an image at the given position with the given size.<br>\n     * <br>\n     * Note: SVG images may have resizing issues at the moment.Draw a line and an arrow at the end (zB) of the given line with the specified (CSS-) color.\n     *\n     * @method image\n     * @param {Image} image - The image object to draw.\n     * @param {Vertex} position - The position to draw the the upper left corner at.\n     * @param {Vertex} size - The x/y-size to draw the image with.\n     * @param {number=0.0} alpha - (optional, default=0.0) The transparency (1.0=opaque, 0.0=transparent).\n     * @return {void}\n     * @instance\n     * @memberof drawutilssvg\n     **/\n    image(image, position, size, alpha = 1.0) {\n        const node = this.makeNode(\"image\");\n        // We need to re-adjust the image if it was not yet fully loaded before.\n        const setImageSize = (image) => {\n            if (image.naturalWidth) {\n                const ratioX = size.x / image.naturalWidth;\n                const ratioY = size.y / image.naturalHeight;\n                node.setAttribute(\"width\", `${image.naturalWidth * this.scale.x}`);\n                node.setAttribute(\"height\", `${image.naturalHeight * this.scale.y}`);\n                node.setAttribute(\"display\", null); // Dislay when loaded\n                // if (alpha) {\n                node.setAttribute(\"opacity\", `${alpha}`);\n                // }\n                node.setAttribute(\"transform\", `translate(${this._x(position.x)} ${this._y(position.y)}) scale(${ratioX} ${ratioY})`);\n            }\n        };\n        image.addEventListener(\"load\", event => {\n            setImageSize(image);\n        });\n        // Safari has a transform-origin bug.\n        // Use x=0, y=0 and translate/scale instead (see above)\n        node.setAttribute(\"x\", `${0}`);\n        node.setAttribute(\"y\", `${0}`);\n        node.setAttribute(\"display\", \"none\"); // Hide before loaded\n        setImageSize(image);\n        node.setAttribute(\"href\", image.src);\n        return this._bindFillDraw(node, \"image\", null, null);\n    }\n    /**\n     * Draw an image at the given position with the given size.<br>\n     * <br>\n     * Note: SVG images may have resizing issues at the moment.Draw a line and an arrow at the end (zB) of the given line with the specified (CSS-) color.\n     *\n     * @method texturedPoly\n     * @param {Image} textureImage - The image object to draw.\n     * @param {Bounds} textureSize - The texture size to use; these are the original bounds to map the polygon vertices to.\n     * @param {Polygon} polygon - The polygon to use as clip path.\n     * @param {Vertex} polygonPosition - The polygon's position (relative), measured at the bounding box's center.\n     * @param {number} rotation - The rotation to use for the polygon (and for the texture).\n     * @return {void}\n     * @instance\n     * @memberof drawutilssvg\n     **/\n    texturedPoly(textureImage, textureSize, polygon, polygonPosition, rotation) {\n        const basePolygonBounds = polygon.getBounds();\n        const rotatedScalingOrigin = new Vertex(textureSize.min).clone().rotate(rotation, polygonPosition);\n        const rotationCenter = polygonPosition.clone().add(rotatedScalingOrigin.difference(textureSize.min).inv());\n        // Create something like this\n        // ...\n        //    <defs>\n        //       <clipPath id=\"shape\">\n        //         <path fill=\"none\" d=\"...\"/>\n        //       </clipPath>\n        //    </defs>\n        //    ...\n        //    <g clip-path=\"url(#shape)\">\n        //       <g transform=\"scale(...)\">\n        //          <image width=\"643\" height=\"643\" transform=\"rotate(...)\" xlink:href=\"https://s3-us-west-2.amazonaws.com/s.cdpn.io/222579/beagle400.jpg\" >\n        //       </g>\n        //    </g>\n        //    </image>\n        // ...\n        const clipPathNode = this.makeNode(\"clipPath\");\n        const clipPathId = `clippath_${UIDGenerator.next()}`; // TODO: use a better UUID generator here?\n        clipPathNode.setAttribute(\"id\", clipPathId);\n        const gNode = this.makeNode(\"g\");\n        const imageNode = this.makeNode(\"image\");\n        imageNode.setAttribute(\"x\", `${this._x(rotatedScalingOrigin.x)}`);\n        imageNode.setAttribute(\"y\", `${this._y(rotatedScalingOrigin.y)}`);\n        imageNode.setAttribute(\"width\", `${textureSize.width}`);\n        imageNode.setAttribute(\"height\", `${textureSize.height}`);\n        imageNode.setAttribute(\"href\", textureImage.src);\n        // imageNode.setAttribute(\"opacity\", \"0.5\");\n        // SVG rotations in degrees\n        imageNode.setAttribute(\"transform\", `rotate(${rotation * RAD_TO_DEG}, ${this._x(rotatedScalingOrigin.x)}, ${this._y(rotatedScalingOrigin.y)})`);\n        const pathNode = this.makeNode(\"path\");\n        const pathData = [];\n        if (polygon.vertices.length > 0) {\n            const self = this;\n            pathData.push(\"M\", `${this._x(polygon.vertices[0].x)}`, `${this._y(polygon.vertices[0].y)}`);\n            for (var i = 1; i < polygon.vertices.length; i++) {\n                pathData.push(\"L\", `${this._x(polygon.vertices[i].x)}`, `${this._y(polygon.vertices[i].y)}`);\n            }\n        }\n        pathNode.setAttribute(\"d\", pathData.join(\" \"));\n        clipPathNode.appendChild(pathNode);\n        this.bufferedNodeDefs.appendChild(clipPathNode);\n        gNode.appendChild(imageNode);\n        gNode.setAttribute(\"transform-origin\", `${this._x(rotatedScalingOrigin.x)} ${this._y(rotatedScalingOrigin.y)}`);\n        gNode.setAttribute(\"transform\", `scale(${this.scale.x}, ${this.scale.y})`);\n        const clipNode = this.makeNode(\"g\");\n        clipNode.appendChild(gNode);\n        clipNode.setAttribute(\"clip-path\", `url(#${clipPathId})`);\n        // TODO: check if the image class is correct here or if we should use a 'clippedImage' class here\n        this._bindFillDraw(clipNode, \"image\", null, null); // No color, no lineWidth\n        return clipNode;\n    }\n    /**\n     * Draw the given (cubic) bézier curve.\n     *\n     * @method cubicBezier\n     * @param {Vertex} startPoint - The start point of the cubic Bézier curve\n     * @param {Vertex} endPoint   - The end point the cubic Bézier curve.\n     * @param {Vertex} startControlPoint - The start control point the cubic Bézier curve.\n     * @param {Vertex} endControlPoint   - The end control point the cubic Bézier curve.\n     * @param {string} color - The CSS color to draw the curve with.\n     * @param {number} lineWidth - (optional) The line width to use.\n     * @return {void}\n     * @instance\n     * @memberof drawutilssvg\n     */\n    cubicBezier(startPoint, endPoint, startControlPoint, endControlPoint, color, lineWidth) {\n        if (startPoint instanceof CubicBezierCurve) {\n            return this.cubicBezier(startPoint.startPoint, startPoint.endPoint, startPoint.startControlPoint, startPoint.endControlPoint, color, lineWidth);\n        }\n        const node = this.makeNode(\"path\");\n        // Draw curve\n        const d = [\n            \"M\",\n            this._x(startPoint.x),\n            this._y(startPoint.y),\n            \"C\",\n            this._x(startControlPoint.x),\n            this._y(startControlPoint.y),\n            this._x(endControlPoint.x),\n            this._y(endControlPoint.y),\n            this._x(endPoint.x),\n            this._y(endPoint.y)\n        ];\n        node.setAttribute(\"d\", d.join(\" \"));\n        return this._bindFillDraw(node, \"cubicBezier\", color, lineWidth);\n    }\n    /**\n     * Draw the given (cubic) Bézier path.\n     *\n     * The given path must be an array with n*3+1 vertices, where n is the number of\n     * curves in the path:\n     * <pre> [ point1, point1_startControl, point2_endControl, point2, point2_startControl, point3_endControl, point3, ... pointN_endControl, pointN ]</pre>\n     *\n     * @method cubicBezierPath\n     * @param {Vertex[]} path - The cubic bezier path as described above.\n     * @param {string} color - The CSS colot to draw the path with.\n     * @param {number=1} lineWidth - (optional) The line width to use.\n     * @return {void}\n     * @instance\n     * @memberof drawutilssvg\n     */\n    cubicBezierPath(path, color, lineWidth) {\n        const node = this.makeNode(\"path\");\n        if (!path || path.length == 0)\n            return node;\n        // Draw curve\n        const d = [\"M\", this._x(path[0].x), this._y(path[0].y)];\n        // Draw curve path\n        var endPoint;\n        var startControlPoint;\n        var endControlPoint;\n        for (var i = 1; i < path.length; i += 3) {\n            startControlPoint = path[i];\n            endControlPoint = path[i + 1];\n            endPoint = path[i + 2];\n            d.push(\"C\", this._x(startControlPoint.x), this._y(startControlPoint.y), this._x(endControlPoint.x), this._y(endControlPoint.y), this._x(endPoint.x), this._y(endPoint.y));\n        }\n        node.setAttribute(\"d\", d.join(\" \"));\n        return this._bindFillDraw(node, \"cubicBezierPath\", color, lineWidth || 1);\n    }\n    /**\n     * Draw the given handle and handle point (used to draw interactive Bézier curves).\n     *\n     * The colors for this are fixed and cannot be specified.\n     *\n     * @method handle\n     * @param {Vertex} startPoint - The start of the handle.\n     * @param {Vertex} endPoint - The end point of the handle.\n     * @return {void}\n     * @instance\n     * @memberof drawutilssvg\n     */\n    handle(startPoint, endPoint) {\n        // TODO: redefine methods like these into an abstract class?\n        this.point(startPoint, \"rgb(0,32,192)\");\n        this.square(endPoint, 5, \"rgba(0,128,192,0.5)\");\n    }\n    /**\n     * Draw a handle line (with a light grey).\n     *\n     * @method handleLine\n     * @param {Vertex} startPoint - The start point to draw the handle at.\n     * @param {Vertex} endPoint - The end point to draw the handle at.\n     * @return {void}\n     * @instance\n     * @memberof drawutilssvg\n     */\n    handleLine(startPoint, endPoint) {\n        this.line(startPoint, endPoint, \"rgb(192,192,192)\");\n    }\n    /**\n     * Draw a 1x1 dot with the specified (CSS-) color.\n     *\n     * @method dot\n     * @param {Vertex} p - The position to draw the dot at.\n     * @param {string} color - The CSS color to draw the dot with.\n     * @return {void}\n     * @instance\n     * @memberof drawutilssvg\n     */\n    dot(p, color) {\n        const node = this.makeNode(\"line\");\n        return this._bindFillDraw(node, \"dot\", color, 1);\n    }\n    /**\n     * Draw the given point with the specified (CSS-) color and radius 3.\n     *\n     * @method point\n     * @param {Vertex} p - The position to draw the point at.\n     * @param {string} color - The CSS color to draw the point with.\n     * @return {void}\n     * @instance\n     * @memberof drawutilssvg\n     */\n    point(p, color) {\n        var radius = 3;\n        const node = this.makeNode(\"circle\");\n        node.setAttribute(\"cx\", `${this._x(p.x)}`);\n        node.setAttribute(\"cy\", `${this._y(p.y)}`);\n        node.setAttribute(\"r\", `${radius}`);\n        return this._bindFillDraw(node, \"point\", color, 1);\n    }\n    /**\n     * Draw a circle with the specified (CSS-) color and radius.<br>\n     * <br>\n     * Note that if the x- and y- scales are different the result will be an ellipse rather than a circle.\n     *\n     * @method circle\n     * @param {Vertex} center - The center of the circle.\n     * @param {number} radius - The radius of the circle.\n     * @param {string} color - The CSS color to draw the circle with.\n     * @param {number=} lineWidth - (optional) The line width to use; default is 1.\n     * @return {void}\n     * @instance\n     * @memberof drawutilssvg\n     */\n    circle(center, radius, color, lineWidth) {\n        // Todo: draw ellipse when scalex!=scaley\n        const node = this.makeNode(\"circle\");\n        node.setAttribute(\"cx\", `${this._x(center.x)}`);\n        node.setAttribute(\"cy\", `${this._y(center.y)}`);\n        node.setAttribute(\"r\", `${radius * this.scale.x}`); // y?\n        return this._bindFillDraw(node, \"circle\", color, lineWidth || 1);\n    }\n    /**\n     * Draw a circular arc (section of a circle) with the given CSS color.\n     *\n     * @method circleArc\n     * @param {Vertex} center - The center of the circle.\n     * @param {number} radius - The radius of the circle.\n     * @param {number} startAngle - The angle to start at.\n     * @param {number} endAngle - The angle to end at.\n     * @param {string} color - The CSS color to draw the circle with.\n     * @return {void}\n     * @instance\n     * @memberof drawutilssvg\n     */\n    circleArc(center, radius, startAngle, endAngle, color, lineWidth) {\n        const node = this.makeNode(\"path\");\n        const arcData = CircleSector.circleSectorUtils.describeSVGArc(this._x(center.x), this._y(center.y), radius * this.scale.x, // y?\n        startAngle, endAngle);\n        node.setAttribute(\"d\", arcData.join(\" \"));\n        return this._bindFillDraw(node, \"circleArc\", color, lineWidth || 1);\n    }\n    /**\n     * Draw an ellipse with the specified (CSS-) color and thw two radii.\n     *\n     * @method ellipse\n     * @param {Vertex} center - The center of the ellipse.\n     * @param {number} radiusX - The radius of the ellipse.\n     * @param {number} radiusY - The radius of the ellipse.\n     * @param {string} color - The CSS color to draw the ellipse with.\n     * @param {number=} lineWidth - (optional) The line width to use; default is 1.\n     * @param {number=} rotation - (optional, default=0) The rotation of the ellipse.\n     * @return {void}\n     * @instance\n     * @memberof drawutilssvg\n     */\n    ellipse(center, radiusX, radiusY, color, lineWidth, rotation) {\n        if (typeof rotation === \"undefined\") {\n            rotation = 0.0;\n        }\n        const node = this.makeNode(\"ellipse\");\n        node.setAttribute(\"cx\", `${this._x(center.x)}`);\n        node.setAttribute(\"cy\", `${this._y(center.y)}`);\n        node.setAttribute(\"rx\", `${radiusX * this.scale.x}`);\n        node.setAttribute(\"ry\", `${radiusY * this.scale.y}`);\n        // node.setAttribute( 'style', `transform: rotate(${rotation} ${center.x} ${center.y})` );\n        node.setAttribute(\"transform\", `rotate(${(rotation * 180) / Math.PI} ${this._x(center.x)} ${this._y(center.y)})`);\n        return this._bindFillDraw(node, \"ellipse\", color, lineWidth || 1);\n    }\n    /**\n     * Draw square at the given center, size and with the specified (CSS-) color.<br>\n     * <br>\n     * Note that if the x-scale and the y-scale are different the result will be a rectangle rather than a square.\n     *\n     * @method square\n     * @param {XYCoords} center - The center of the square.\n     * @param {Vertex} size - The size of the square.\n     * @param {string} color - The CSS color to draw the square with.\n     * @param {number=} lineWidth - (optional) The line width to use; default is 1.\n     * @return {void}\n     * @instance\n     * @memberof drawutilssvg\n     */\n    square(center, size, color, lineWidth) {\n        const node = this.makeNode(\"rectangle\");\n        node.setAttribute(\"x\", `${this._x(center.x - size / 2.0)}`);\n        node.setAttribute(\"y\", `${this._y(center.y - size / 2.0)}`);\n        node.setAttribute(\"width\", `${size * this.scale.x}`);\n        node.setAttribute(\"height\", `${size * this.scale.y}`);\n        return this._bindFillDraw(node, \"square\", color, lineWidth || 1);\n    }\n    /**\n     * Draw a rectangle.\n     *\n     * @param {XYCoords} position - The upper left corner of the rectangle.\n     * @param {number} width - The width of the rectangle.\n     * @param {number} height - The height of the rectangle.\n     * @param {string} color - The color to use.\n     * @param {number=1} lineWidth - (optional) The line with to use (default is 1).\n     **/\n    rect(position, width, height, color, lineWidth) {\n        const node = this.makeNode(\"rect\");\n        node.setAttribute(\"x\", `${this._x(position.x)}`);\n        node.setAttribute(\"y\", `${this._y(position.y)}`);\n        node.setAttribute(\"width\", `${width * this.scale.x}`);\n        node.setAttribute(\"height\", `${height * this.scale.y}`);\n        return this._bindFillDraw(node, \"rect\", color, lineWidth || 1);\n    }\n    /**\n     * Draw a grid of horizontal and vertical lines with the given (CSS-) color.\n     *\n     * @method grid\n     * @param {Vertex} center - The center of the grid.\n     * @param {number} width - The total width of the grid (width/2 each to the left and to the right).\n     * @param {number} height - The total height of the grid (height/2 each to the top and to the bottom).\n     * @param {number} sizeX - The horizontal grid size.\n     * @param {number} sizeY - The vertical grid size.\n     * @param {string} color - The CSS color to draw the grid with.\n     * @return {void}\n     * @instance\n     * @memberof drawutilssvg\n     */\n    grid(center, width, height, sizeX, sizeY, color) {\n        const node = this.makeNode(\"path\");\n        const d = [];\n        var yMin = -Math.ceil((height * 0.5) / sizeY) * sizeY;\n        var yMax = height / 2;\n        for (var x = -Math.ceil((width * 0.5) / sizeX) * sizeX; x < width / 2; x += sizeX) {\n            d.push(\"M\", this._x(center.x + x), this._y(center.y + yMin));\n            d.push(\"L\", this._x(center.x + x), this._y(center.y + yMax));\n        }\n        var xMin = -Math.ceil((width * 0.5) / sizeX) * sizeX;\n        var xMax = width / 2;\n        for (var y = -Math.ceil((height * 0.5) / sizeY) * sizeY; y < height / 2; y += sizeY) {\n            d.push(\"M\", this._x(center.x + xMin), this._y(center.y + y));\n            d.push(\"L\", this._x(center.x + xMax), this._y(center.y + y));\n        }\n        node.setAttribute(\"d\", d.join(\" \"));\n        return this._bindFillDraw(node, \"grid\", color, 1);\n    }\n    /**\n     * Draw a raster of crosshairs in the given grid.<br>\n     *\n     * This works analogue to the grid() function\n     *\n     * @method raster\n     * @param {Vertex} center - The center of the raster.\n     * @param {number} width - The total width of the raster (width/2 each to the left and to the right).\n     * @param {number} height - The total height of the raster (height/2 each to the top and to the bottom).\n     * @param {number} sizeX - The horizontal raster size.\n     * @param {number} sizeY - The vertical raster size.\n     * @param {string} color - The CSS color to draw the raster with.\n     * @return {void}\n     * @instance\n     * @memberof drawutilssvg\n     */\n    raster(center, width, height, sizeX, sizeY, color) {\n        const node = this.makeNode(\"path\");\n        const d = [];\n        for (var x = -Math.ceil((width * 0.5) / sizeX) * sizeX; x < width / 2; x += sizeX) {\n            for (var y = -Math.ceil((height * 0.5) / sizeY) * sizeY; y < height / 2; y += sizeY) {\n                // Draw a crosshair\n                d.push(\"M\", this._x(center.x + x) - 4, this._y(center.y + y));\n                d.push(\"L\", this._x(center.x + x) + 4, this._y(center.y + y));\n                d.push(\"M\", this._x(center.x + x), this._y(center.y + y) - 4);\n                d.push(\"L\", this._x(center.x + x), this._y(center.y + y) + 4);\n            }\n        }\n        node.setAttribute(\"d\", d.join(\" \"));\n        return this._bindFillDraw(node, \"raster\", color, 1);\n    }\n    /**\n     * Draw a diamond handle (square rotated by 45°) with the given CSS color.\n     *\n     * It is an inherent featur of the handle functions that the drawn elements are not scaled and not\n     * distorted. So even if the user zooms in or changes the aspect ratio, the handles will be drawn\n     * as even shaped diamonds.\n     *\n     * @method diamondHandle\n     * @param {Vertex} center - The center of the diamond.\n     * @param {Vertex} size - The x/y-size of the diamond.\n     * @param {string} color - The CSS color to draw the diamond with.\n     * @return {void}\n     * @instance\n     * @memberof drawutilssvg\n     */\n    diamondHandle(center, size, color) {\n        const node = this.makeNode(\"path\");\n        const d = [\n            \"M\",\n            this._x(center.x) - size / 2.0,\n            this._y(center.y),\n            \"L\",\n            this._x(center.x),\n            this._y(center.y) - size / 2.0,\n            \"L\",\n            this._x(center.x) + size / 2.0,\n            this._y(center.y),\n            \"L\",\n            this._x(center.x),\n            this._y(center.y) + size / 2.0,\n            \"Z\"\n        ];\n        node.setAttribute(\"d\", d.join(\" \"));\n        return this._bindFillDraw(node, \"diamondHandle\", color, 1);\n    }\n    /**\n     * Draw a square handle with the given CSS color.<br>\n     * <br>\n     * It is an inherent featur of the handle functions that the drawn elements are not scaled and not\n     * distorted. So even if the user zooms in or changes the aspect ratio, the handles will be drawn\n     * as even shaped squares.\n     *\n     * @method squareHandle\n     * @param {Vertex} center - The center of the square.\n     * @param {Vertex} size - The x/y-size of the square.\n     * @param {string} color - The CSS color to draw the square with.\n     * @return {void}\n     * @instance\n     * @memberof drawutilssvg\n     */\n    squareHandle(center, size, color) {\n        const node = this.makeNode(\"rect\");\n        node.setAttribute(\"x\", `${this._x(center.x) - size / 2.0}`);\n        node.setAttribute(\"y\", `${this._y(center.y) - size / 2.0}`);\n        node.setAttribute(\"width\", `${size}`);\n        node.setAttribute(\"height\", `${size}`);\n        return this._bindFillDraw(node, \"squareHandle\", color, 1);\n    }\n    /**\n     * Draw a circle handle with the given CSS color.<br>\n     * <br>\n     * It is an inherent featur of the handle functions that the drawn elements are not scaled and not\n     * distorted. So even if the user zooms in or changes the aspect ratio, the handles will be drawn\n     * as even shaped circles.\n     *\n     * @method circleHandle\n     * @param {Vertex} center - The center of the circle.\n     * @param {number} radius - The radius of the circle.\n     * @param {string} color - The CSS color to draw the circle with.\n     * @return {void}\n     * @instance\n     * @memberof drawutilssvg\n     */\n    circleHandle(center, radius, color) {\n        radius = radius || 3;\n        const node = this.makeNode(\"circle\");\n        node.setAttribute(\"cx\", `${this._x(center.x)}`);\n        node.setAttribute(\"cy\", `${this._y(center.y)}`);\n        node.setAttribute(\"r\", `${radius}`);\n        return this._bindFillDraw(node, \"circleHandle\", color, 1);\n    }\n    /**\n     * Draw a crosshair with given radius and color at the given position.<br>\n     * <br>\n     * Note that the crosshair radius will not be affected by scaling.\n     *\n     * @method crosshair\n     * @param {XYCoords} center - The center of the crosshair.\n     * @param {number} radius - The radius of the crosshair.\n     * @param {string} color - The CSS color to draw the crosshair with.\n     * @param {number=0.5} lineWidth - (optional, default=0.5) The line width to use.\n     * @return {void}\n     * @instance\n     * @memberof drawutilssvg\n     */\n    crosshair(center, radius, color, lineWidth) {\n        const node = this.makeNode(\"path\");\n        const d = [\n            \"M\",\n            this._x(center.x) - radius,\n            this._y(center.y),\n            \"L\",\n            this._x(center.x) + radius,\n            this._y(center.y),\n            \"M\",\n            this._x(center.x),\n            this._y(center.y) - radius,\n            \"L\",\n            this._x(center.x),\n            this._y(center.y) + radius\n        ];\n        node.setAttribute(\"d\", d.join(\" \"));\n        return this._bindFillDraw(node, \"crosshair\", color, lineWidth || 0.5);\n    }\n    /**\n     * Draw a cross with diagonal axes with given radius, color and lineWidth at the given position.<br>\n     * <br>\n     * Note that the x's radius will not be affected by scaling.\n     *\n     * @method crosshair\n     * @param {XYCoords} center - The center of the crosshair.\n     * @param {number} radius - The radius of the crosshair.\n     * @param {string} color - The CSS color to draw the crosshair with.\n     * @param {number=1} lineWidth - (optional, default=1.0) The line width to use.\n     * @return {void}\n     * @instance\n     * @memberof drawutils\n     */\n    cross(center, radius, color, lineWidth) {\n        const node = this.makeNode(\"path\");\n        const d = [\n            \"M\",\n            this._x(center.x) - radius,\n            this._y(center.y) - radius,\n            \"L\",\n            this._x(center.x) + radius,\n            this._y(center.y) + radius,\n            \"M\",\n            this._x(center.x) - radius,\n            this._y(center.y) + radius,\n            \"L\",\n            this._x(center.x) + radius,\n            this._y(center.y) - radius\n        ];\n        node.setAttribute(\"d\", d.join(\" \"));\n        return this._bindFillDraw(node, \"cross\", color, lineWidth || 1.0);\n    }\n    /**\n     * Draw a polygon.\n     *\n     * @method polygon\n     * @param {Polygon} polygon - The polygon to draw.\n     * @param {string} color - The CSS color to draw the polygon with.\n     * @param {number=} lineWidth - (optional) The line width to use; default is 1.\n     * @return {void}\n     * @instance\n     * @memberof drawutilssvg\n     */\n    polygon(polygon, color, lineWidth) {\n        return this.polyline(polygon.vertices, polygon.isOpen, color, lineWidth);\n    }\n    /**\n     * Draw a polygon line (alternative function to the polygon).\n     *\n     * @method polyline\n     * @param {Vertex[]} vertices - The polygon vertices to draw.\n     * @param {boolan}   isOpen   - If true the polyline will not be closed at its end.\n     * @param {string}   color    - The CSS color to draw the polygon with.\n     * @param {number=} lineWidth - (optional) The line width to use; default is 1.\n     * @return {void}\n     * @instance\n     * @memberof drawutilssvg\n     */\n    polyline(vertices, isOpen, color, lineWidth) {\n        const node = this.makeNode(\"path\");\n        if (vertices.length == 0)\n            return node;\n        // Draw curve\n        const d = [\"M\", this._x(vertices[0].x), this._y(vertices[0].y)];\n        var n = vertices.length;\n        for (var i = 1; i < n; i++) {\n            d.push(\"L\", this._x(vertices[i].x), this._y(vertices[i].y));\n        }\n        if (!isOpen)\n            d.push(\"Z\");\n        node.setAttribute(\"d\", d.join(\" \"));\n        return this._bindFillDraw(node, \"polygon\", color, lineWidth || 1);\n    }\n    /**\n     * Draw a text at the given relative position.\n     *\n     * @method text\n     * @param {string} text - The text to draw.\n     * @param {number} x - The x-position to draw the text at.\n     * @param {number} y - The y-position to draw the text at.\n     * @param {string=} options.color - The Color to use.\n     * @param {string=} options.fontFamily - The font family to use.\n     * @param {number=} options.fontSize - The font size (in pixels) to use.\n     * @param {FontStyle=} options.fontStyle - The font style to use.\n     * @param {FontWeight=} options.fontWeight - The font weight to use.\n     * @param {number=} options.lineHeight - The line height (in pixels) to use.\n     * @param {number=} options.rotation - The (optional) rotation in radians.\n     * @param {string=} options.textAlign - The text align to use. According to the specifiactions (https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/textAlign) valid values are `\"left\" || \"right\" || \"center\" || \"start\" || \"end\"`.\n     * @return {void}\n     * @instance\n     * @memberof drawutils\n     */\n    text(text, x, y, options) {\n        var _a, _b, _c;\n        options = options || {};\n        const color = options.color || \"black\";\n        const lineHeight = ((_b = (_a = options.lineHeight) !== null && _a !== void 0 ? _a : options.fontSize) !== null && _b !== void 0 ? _b : 0) * this.scale.x;\n        // https://www.w3.org/TR/SVG/text.html#TextAnchorProperty\n        //    start | middle | end\n        const textAlign = options.textAlign === \"left\" || options.textAlign === \"start\"\n            ? \"start\"\n            : options.textAlign === \"center\"\n                ? \"middle\"\n                : options.textAlign === \"right\" || options.textAlign === \"end\"\n                    ? \"end\"\n                    : \"start\";\n        const transformOrigin = `${this._x(x)}px ${this._y(y)}px`;\n        const translate = `translate(${this._x(x)} ${this._y(y) + lineHeight / 2})`;\n        // Safari has a transform-origin/rotation bug.\n        // It's essential to use rotate(r,x,y) here. \"rotate(r)\"\" with transform-origin(x,y) won't do the job.\n        // And rotate and translate cannot be used is combination on a text object.\n        // So wrap the text inside a <g>, translate the <g>, and rotate the text inside.\n        const rotate = options.rotation ? `rotate(${options.rotation * RAD_TO_DEG} 0 0)` : ``;\n        const node = this.makeNode(\"g\");\n        const curId = this.curId;\n        this.curId = curId + \"_text\";\n        const textNode = this.makeNode(\"text\");\n        node.appendChild(textNode);\n        textNode.setAttribute(\"font-family\", (_c = options.fontFamily) !== null && _c !== void 0 ? _c : \"\"); // May be undefined\n        textNode.setAttribute(\"font-size\", options.fontSize ? `${options.fontSize * this.scale.x}` : \"\");\n        textNode.setAttribute(\"font-style\", options.fontStyle ? `${options.fontStyle}` : \"\");\n        textNode.setAttribute(\"font-weight\", options.fontWeight ? `${options.fontWeight}` : \"\");\n        textNode.setAttribute(\"text-anchor\", textAlign);\n        textNode.setAttribute(\"transform-origin\", \"0 0\");\n        textNode.setAttribute(\"transform\", rotate);\n        node.setAttribute(\"transform-origin\", transformOrigin);\n        node.setAttribute(\"transform\", translate);\n        textNode.innerHTML = text;\n        // Restore old ID\n        this.curId = curId;\n        return this._bindFillDraw(node, \"text\", color, 1);\n    }\n    /**\n     * Draw a non-scaling text label at the given position.\n     *\n     * @method label\n     * @param {string} text - The text to draw.\n     * @param {number} x - The x-position to draw the text at.\n     * @param {number} y - The y-position to draw the text at.\n     * @param {number=} rotation - The (optional) rotation in radians.\n     * @param {string=\"black\"} color - The color to use (default is black).\n     * @return {void}\n     * @instance\n     * @memberof drawutilssvg\n     */\n    label(text, x, y, rotation, color) {\n        const node = this.makeNode(\"text\");\n        // For some strange reason SVG rotation transforms use degrees instead of radians\n        node.setAttribute(\"transform\", `translate(${x},${y}), rotate(${((rotation || 0) / Math.PI) * 180})`);\n        node.setAttribute(\"font-family\", \"Arial\");\n        node.setAttribute(\"font-size\", \"9pt\");\n        node.setAttribute(\"font-style\", \"normal\");\n        node.setAttribute(\"font-weight\", \"lighter\");\n        node.innerHTML = text;\n        return this._bindFillDraw(node, \"label\", color || \"black\", null);\n    }\n    /**\n     * Draw an SVG-like path given by the specified path data.\n     *\n     * @method path\n     * @param {SVGPathData} pathData - An array of path commands and params.\n     * @param {string=null} color - (optional) The color to draw this path with (default is null).\n     * @param {number=1} lineWidth - (optional) the line width to use (default is 1).\n     * @param {boolean=false} options.inplace - (optional) If set to true then path transforamtions (scale and translate) will be done in-place in the array. This can boost the performance.\n     * @instance\n     * @memberof drawutils\n     * @return {R} An instance representing the drawn path.\n     */\n    path(pathData, color, lineWidth, options) {\n        const node = this.makeNode(\"path\");\n        // Transform the path: in-place (fast) or copy (slower)\n        const d = options && options.inplace ? pathData : drawutilssvg.copyPathData(pathData);\n        drawutilssvg.transformPathData(d, this.offset, this.scale);\n        node.setAttribute(\"d\", d.join(\" \"));\n        return this._bindFillDraw(node, \"path\", color, lineWidth);\n    }\n    /**\n     * Due to gl compatibility there is a generic 'clear' function required\n     * to avoid accessing the context object itself directly.\n     *\n     * This function just fills the whole canvas with a single color.\n     *\n     * @param {string} color - The color to clear with.\n     * @return {void}\n     * @instance\n     * @memberof drawutilssvg\n     **/\n    clear(color) {\n        // If this isn't the primary handler then do not remove anything here.\n        // The primary handler will do that (no double work).\n        if (this.isSecondary) {\n            return;\n        }\n        // Add a covering rect with the given background color\n        this.curId = \"background\";\n        this.curClassName = undefined;\n        const node = this.makeNode(\"rect\");\n        // For some strange reason SVG rotation transforms use degrees instead of radians\n        // Note that the background does not scale with the zoom level (always covers full element)\n        node.setAttribute(\"x\", \"0\");\n        node.setAttribute(\"y\", \"0\");\n        node.setAttribute(\"width\", `${this.canvasSize.width}`);\n        node.setAttribute(\"height\", `${this.canvasSize.height}`);\n        // Bind this special element into the document\n        this._bindFillDraw(node, this.curId, null, null);\n        node.setAttribute(\"fill\", typeof color === \"undefined\" ? \"none\" : color);\n        // Clear the current ID again\n        this.curId = undefined;\n    }\n    /**\n     * A private helper function to clear all SVG nodes from the &gt;g> node.\n     *\n     * @private\n     */\n    removeAllChildNodes() {\n        while (this.bufferGNode.lastChild) {\n            this.bufferGNode.removeChild(this.bufferGNode.lastChild);\n        }\n        while (this.bufferedNodeDefs.lastChild) {\n            this.bufferedNodeDefs.removeChild(this.bufferedNodeDefs.lastChild);\n        }\n    }\n    /**\n     * Create a new and empty `SVGElement` &lt;svg&gt; in the svg-namespace.\n     *\n     * @name createSvg\n     * @static\n     * @memberof drawutilssvg\n     * @return SVGElement\n     */\n    static createSvg() {\n        return document.createElementNS(\"http://www.w3.org/2000/svg\", \"svg\");\n    }\n    /**\n     * Create a copy of the given path data. As path data only consists of strings and numbers,\n     * the copy will be shallow by definition.\n     *\n     * @name copyPathData\n     * @static\n     * @memberof drawutilssvg\n     */\n    static copyPathData(data) {\n        const copy = new Array(data.length);\n        for (var i = 0, n = data.length; i < n; i++) {\n            copy[i] = data[i];\n        }\n        return copy;\n    }\n    /**\n     * Transform the given path data (translate and scale. rotating is not intended here).\n     *\n     * @name transformPathData\n     * @static\n     * @memberof drawutilssvg\n     * @param {SVGPathParams} data - The data to transform.\n     * @param {XYCoords} offset - The translation offset (neutral is x=0, y=0).\n     * @param {XYCoords} scale - The scale factors (neutral is x=1, y=1).\n     */\n    static transformPathData(data, offset, scale) {\n        // Scale and translate {x,y}\n        const _stx = (index) => {\n            data[index] = offset.x + scale.x * Number(data[index]);\n        };\n        const _sty = (index) => {\n            data[index] = offset.y + scale.y * Number(data[index]);\n        };\n        // scale only {x,y}\n        const _sx = (index) => {\n            data[index] = scale.x * Number(data[index]);\n        };\n        const _sy = (index) => {\n            data[index] = scale.y * Number(data[index]);\n        };\n        var i = 0;\n        var lastPoint = { x: NaN, y: NaN };\n        // \"save last point\"\n        var _slp = (index) => {\n            lastPoint.x = Number(data[index]);\n            lastPoint.y = Number(data[index + 1]);\n        };\n        while (i < data.length) {\n            const cmd = data[i];\n            switch (cmd) {\n                case \"M\":\n                // MoveTo: M|m x y\n                case \"L\":\n                // LineTo L|l x y\n                case \"T\":\n                    // Shorthand/smooth quadratic Bézier curveto: T|t x y\n                    _stx(i + 1);\n                    _sty(i + 2);\n                    _slp(i + 1);\n                    i += 3;\n                    break;\n                case \"m\":\n                // MoveTo: M|m x y\n                case \"l\":\n                // LineTo L|l x y\n                case \"t\":\n                    // Shorthand/smooth quadratic Bézier curveto: T|t x y\n                    _sx(i + 1);\n                    _sy(i + 2);\n                    _slp(i + 1);\n                    i += 3;\n                    break;\n                case \"H\":\n                    // HorizontalLineTo: H|h x\n                    _stx(i + 1);\n                    lastPoint.x = Number(data[i + 1]);\n                    i += 2;\n                    break;\n                case \"h\":\n                    // HorizontalLineTo: H|h x\n                    _sx(i + 1);\n                    lastPoint.x = Number(data[i + 1]);\n                    i += 2;\n                    break;\n                case \"V\":\n                    // VerticalLineTo: V|v y\n                    _sty(i + 1);\n                    lastPoint.y = Number(data[i + 1]);\n                    i += 2;\n                    break;\n                case \"v\":\n                    // VerticalLineTo: V|v y\n                    _sy(i + 1);\n                    lastPoint.y = Number(data[i + 1]);\n                    i += 2;\n                    break;\n                case \"C\":\n                    // CurveTo: C|c x1 y1 x2 y2 x y\n                    _stx(i + 1);\n                    _sty(i + 2);\n                    _stx(i + 3);\n                    _sty(i + 4);\n                    _stx(i + 5);\n                    _sty(i + 6);\n                    _slp(i + 5);\n                    i += 7;\n                    break;\n                case \"c\":\n                    // CurveTo: C|c x1 y1 x2 y2 x y\n                    _sx(i + 1);\n                    _sy(i + 2);\n                    _sx(i + 3);\n                    _sy(i + 4);\n                    _sx(i + 5);\n                    _sy(i + 6);\n                    _slp(i + 5);\n                    i += 7;\n                    break;\n                case \"S\":\n                case \"Q\":\n                    // Shorthand-/SmoothCurveTo: S|s x2 y2 x y\n                    // QuadraticCurveTo: Q|q x1 y1 x y\n                    _stx(i + 1);\n                    _sty(i + 2);\n                    _stx(i + 3);\n                    _sty(i + 4);\n                    _slp(i + 3);\n                    i += 5;\n                    break;\n                case \"s\":\n                case \"q\":\n                    // Shorthand-/SmoothCurveTo: S|s x2 y2 x y\n                    // QuadraticCurveTo: Q|q x1 y1 x y\n                    _sx(i + 1);\n                    _sy(i + 2);\n                    _sx(i + 3);\n                    _sy(i + 4);\n                    _slp(i + 3);\n                    i += 5;\n                    break;\n                case \"A\":\n                    // EllipticalArcTo: A|a rx ry x-axis-rotation large-arc-flag sweep-flag x y\n                    // Uniform scale: just scale\n                    // NOTE: here is something TODO\n                    //  * if scalex!=scaleY this won't work\n                    //  * Arcs have to be converted to Bézier curves here in that case\n                    _sx(i + 1);\n                    _sy(i + 2);\n                    _stx(i + 6);\n                    _sty(i + 7);\n                    _slp(i + 6);\n                    // Update the arc flag when x _or_ y scale is negative\n                    if ((scale.x < 0 && scale.y >= 0) || (scale.x >= 0 && scale.y < 0)) {\n                        data[i + 5] = data[i + 5] ? 0 : 1;\n                    }\n                    i += 8;\n                    break;\n                case \"a\":\n                    // EllipticalArcTo: A|a rx ry x-axis-rotation large-arc-flag sweep-flag x y\n                    _sx(i + 1);\n                    _sy(i + 2);\n                    _sx(i + 6);\n                    _sy(i + 7);\n                    _slp(i + 6);\n                    i += 8;\n                    break;\n                case \"z\":\n                case \"Z\":\n                    // ClosePath: Z|z (no arguments)\n                    // lastPoint.x = firstPoint.x;\n                    // lastPoint.y = firstPoint.y;\n                    i++;\n                    break;\n                // Safepoint: continue reading token by token until something is recognized again\n                default:\n                    i++;\n            }\n        } // END while\n    } // END transformPathData\n}\ndrawutilssvg.HEAD_XML = [\n    '<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>',\n    '<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.0//EN\" ',\n    '         \"http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd\">',\n    \"\"\n].join(\"\\n\");\n//# sourceMappingURL=drawutilssvg.js.map","/**\n * @author   Ikaros Kappler\n * @date     2018-04-22\n * @modified 2018-08-16 Added the curve() function to draw cubic bézier curves.\n * @modified 2018-10-23 Recognizing the offset param in the circle() function.\n * @modified 2018-11-27 Added the diamondHandle() function.\n * @modified 2018-11-28 Added the grid() function and the ellipse() function.\n * @modified 2018-11-30 Renamed the text() function to label() as it is not scaling.\n * @modified 2018-12-06 Added a test function for drawing arc in SVG style.\n * @modified 2018-12-09 Added the dot(Vertex,color) function (copied from Feigenbaum-plot-script).\n * @modified 2019-01-30 Added the arrow(Vertex,Vertex,color) function for drawing arrow heads.\n * @modified 2019-01-30 Added the image(Image,Vertex,Vertex) function for drawing images.\n * @modified 2019-04-27 Fixed a severe drawing bug in the arrow(...) function. Scaling arrows did not work properly.\n * @modified 2019-04-28 Added Math.round to the dot() drawing parameters to really draw a singlt dot.\n * @modified 2019-06-07 Fixed an issue in the cubicBezier() function. Paths were always closed.\n * @modified 2019-10-03 Added the beginDrawCycle hook.\n * @modified 2019-10-25 Polygons are no longer drawn with dashed lines (solid lines instead).\n * @modified 2019-11-18 Added the polyline function.\n * @modified 2019-11-22 Added a second workaround for th drawImage bug in Safari.\n * @modified 2019-12-07 Added the 'lineWidth' param to the line(...) function.\n * @modified 2019-12-07 Added the 'lineWidth' param to the cubicBezier(...) function.\n * @modified 2019-12-11 Added the 'color' param to the label(...) function.\n * @modified 2019-12-18 Added the quadraticBezier(...) function (for the sake of approximating Lissajous curves).\n * @modified 2019-12-20 Added the 'lineWidth' param to the polyline(...) function.\n * @modified 2020-01-09 Added the 'lineWidth' param to the ellipse(...) function.\n * @modified 2020-03-25 Ported this class from vanilla-JS to Typescript.\n * @modified 2020-05-05 Added the 'lineWidth' param to the circle(...) function.\n * @modified 2020-05-12 Drawing any handles (square, circle, diamond) with lineWidth 1 now; this was not reset before.\n * @modified 2020-06-22 Added a context.clearRect() call to the clear() function; clearing with alpha channel did not work as expected.\n * @modified 2020-09-07 Added the circleArc(...) function to draw sections of circles.\n * @modified 2020-10-06 Removed the .closePath() instruction from the circleArc function.\n * @modified 2020-10-15 Re-added the text() function.\n * @modified 2020-10-28 Added the path(Path2D) function.\n * @modified 2020-12-28 Added the `singleSegment` mode (test).\n * @modified 2021-01-05 Added the image-loaded/broken check.\n * @modified 2021-01-24 Added the `setCurrentId` function from the `DrawLib` interface.\n * @modified 2021-02-22 Added the `path` drawing function to draw SVG path data.\n * @modified 2021-03-31 Added the `endDrawCycle` function from `DrawLib`.\n * @modified 2021-05-31 Added the `setConfiguration` function from `DrawLib`.\n * @modified 2021-11-12 Adding more parameters tot the `text()` function: fontSize, textAlign, fontFamily, lineHeight.\n * @modified 2021-11-19 Added the `color` param to the `label(...)` function.\n * @modified 2022-02-03 Added the `lineWidth` param to the `crosshair` function.\n * @modified 2022-02-03 Added the `cross(...)` function.\n * @modified 2022-03-27 Added the `texturedPoly` function.\n * @modified 2022-06-01 Tweaked the `polyline` function; lineWidth now scales with scale.x.\n * @modified 2022-07-26 Adding `alpha` to the `image(...)` function.\n * @modified 2022-08-23 Fixed a type issue in the `polyline` function.\n * @modified 2022-08-23 Fixed a type issue in the `setConfiguration` function.\n * @modified 2022-08-23 Fixed a type issue in the `path` function.\n * @modified 2023-02-10 The methods `setCurrentClassName` and `setCurrentId` also accept `null` now.\n * @version  1.12.4\n **/\nimport { CubicBezierCurve } from \"./CubicBezierCurve\";\nimport { Vertex } from \"./Vertex\";\nimport { drawutilssvg } from \"./drawutilssvg\";\n// Todo: rename this class to Drawutils?\n/**\n * @classdesc A wrapper class for basic drawing operations.\n *\n * @requires CubicBzierCurvce\n * @requires Polygon\n * @requires Vertex\n * @requires XYCoords\n */\nexport class drawutils {\n    /**\n     * The constructor.\n     *\n     * @constructor\n     * @name drawutils\n     * @param {anvasRenderingContext2D} context - The drawing context.\n     * @param {boolean} fillShaped - Indicates if the constructed drawutils should fill all drawn shapes (if possible).\n     **/\n    constructor(context, fillShapes) {\n        this.ctx = context;\n        this.offset = new Vertex(0, 0);\n        this.scale = new Vertex(1, 1);\n        this.fillShapes = fillShapes;\n    }\n    /**\n     * Called before each draw cycle.\n     * @param {UID=} uid - (optional) A UID identifying the currently drawn element(s).\n     **/\n    beginDrawCycle(renderTime) {\n        // NOOP\n    }\n    /**\n     * Called after each draw cycle.\n     *\n     * This is required for compatibility with other draw classes in the library (like drawgl).\n     *\n     * @name endDrawCycle\n     * @method\n     * @param {number} renderTime\n     * @instance\n     **/\n    endDrawCycle(renderTime) {\n        // NOOP\n    }\n    /**\n     * Set the current drawlib configuration.\n     *\n     * @name setConfiguration\n     * @method\n     * @param {DrawLibConfiguration} configuration - The new configuration settings to use for the next render methods.\n     */\n    setConfiguration(configuration) {\n        this.ctx.globalCompositeOperation = configuration.blendMode || \"source-over\";\n    }\n    /**\n     * This method shouled be called each time the currently drawn `Drawable` changes.\n     * It is used by some libraries for identifying elemente on re-renders.\n     *\n     * @name setCurrentId\n     * @method\n     * @param {UID|null} uid - A UID identifying the currently drawn element(s).\n     **/\n    setCurrentId(uid) {\n        // NOOP\n    }\n    /**\n     * This method shouled be called each time the currently drawn `Drawable` changes.\n     * Determine the class name for further usage here.\n     *\n     * @name setCurrentClassName\n     * @method\n     * @param {string|null} className - A class name for further custom use cases.\n     **/\n    setCurrentClassName(className) {\n        // NOOP\n    }\n    /**\n     * Draw the line between the given two points with the specified (CSS-) color.\n     *\n     * @method line\n     * @param {Vertex} zA - The start point of the line.\n     * @param {Vertex} zB - The end point of the line.\n     * @param {string} color - Any valid CSS color string.\n     * @param {number} lineWidth? - [optional] The line's width.\n     * @return {void}\n     * @instance\n     * @memberof drawutils\n     **/\n    line(zA, zB, color, lineWidth) {\n        this.ctx.save();\n        this.ctx.beginPath();\n        this.ctx.moveTo(this.offset.x + zA.x * this.scale.x, this.offset.y + zA.y * this.scale.y);\n        this.ctx.lineTo(this.offset.x + zB.x * this.scale.x, this.offset.y + zB.y * this.scale.y);\n        this.ctx.strokeStyle = color;\n        this.ctx.lineWidth = lineWidth || 1;\n        this.ctx.stroke();\n        this.ctx.restore();\n    }\n    /**\n     * Draw a line and an arrow at the end (zB) of the given line with the specified (CSS-) color.\n     *\n     * @method arrow\n     * @param {Vertex} zA - The start point of the arrow-line.\n     * @param {Vertex} zB - The end point of the arrow-line.\n     * @param {string} color - Any valid CSS color string.\n     * @param {number=} lineWidth - (optional) The line width to use; default is 1.\n     * @return {void}\n     * @instance\n     * @memberof drawutils\n     **/\n    arrow(zA, zB, color, lineWidth) {\n        var headlen = 8; // length of head in pixels\n        // var vertices = PlotBoilerplate.utils.buildArrowHead( zA, zB, headlen, this.scale.x, this.scale.y );\n        // var vertices : Array<Vertex> = Vertex.utils.buildArrowHead( zA, zB, headlen, this.scale.x, this.scale.y );\n        this.ctx.save();\n        this.ctx.beginPath();\n        var vertices = Vertex.utils.buildArrowHead(zA, zB, headlen, this.scale.x, this.scale.y);\n        this.ctx.moveTo(this.offset.x + zA.x * this.scale.x, this.offset.y + zA.y * this.scale.y);\n        for (var i = 0; i < vertices.length; i++) {\n            this.ctx.lineTo(this.offset.x + vertices[i].x, this.offset.y + vertices[i].y);\n        }\n        this.ctx.lineTo(this.offset.x + vertices[0].x, this.offset.y + vertices[0].y);\n        this.ctx.lineWidth = lineWidth || 1;\n        this._fillOrDraw(color);\n        this.ctx.restore();\n    }\n    /**\n     * Draw an image at the given position with the given size.<br>\n     * <br>\n     * Note: SVG images may have resizing issues at the moment.Draw a line and an arrow at the end (zB) of the given line with the specified (CSS-) color.\n     *\n     * @method image\n     * @param {Image} image - The image object to draw.\n     * @param {Vertex} position - The position to draw the the upper left corner at.\n     * @param {Vertex} size - The x/y-size to draw the image with.\n     * @param {number=0.0} alpha - (optional, default=0.0) The transparency (1.0=opaque, 0.0=transparent).\n     * @return {void}\n     * @instance\n     * @memberof drawutils\n     **/\n    image(image, position, size, alpha = 1.0) {\n        if (!image.complete || !image.naturalWidth) {\n            // Avoid drawing un-unloaded or broken images\n            return;\n        }\n        this.ctx.save();\n        this.ctx.globalAlpha = alpha;\n        // Note that there is a Safari bug with the 3 or 5 params variant.\n        // Only the 9-param varaint works.\n        this.ctx.drawImage(image, 0, 0, image.naturalWidth - 1, // There is this horrible Safari bug (fixed in newer versions)\n        image.naturalHeight - 1, // To avoid errors substract 1 here.\n        this.offset.x + position.x * this.scale.x, this.offset.y + position.y * this.scale.y, size.x * this.scale.x, size.y * this.scale.y);\n        this.ctx.restore();\n    }\n    /**\n     * Draw an image at the given position with the given size.<br>\n     * <br>\n     * Note: SVG images may have resizing issues at the moment.Draw a line and an arrow at the end (zB) of the given line with the specified (CSS-) color.\n     *\n     * @method texturedPoly\n     * @param {Image} textureImage - The image object to draw.\n     * @param {Bounds} textureSize - The texture size to use; these are the original bounds to map the polygon vertices to.\n     * @param {Polygon} polygon - The polygon to use as clip path.\n     * @param {Vertex} polygonPosition - The polygon's position (relative), measured at the bounding box's center.\n     * @param {number} rotation - The rotation to use for the polygon (and for the texture).\n     * @param {XYCoords={x:0,y:0}} rotationCenter - (optional) The rotational center; default is center of bounding box.\n     * @return {void}\n     * @instance\n     * @memberof drawutils\n     **/\n    texturedPoly(textureImage, textureSize, polygon, polygonPosition, rotation) {\n        var basePolygonBounds = polygon.getBounds();\n        var targetCenterDifference = polygonPosition.clone().difference(basePolygonBounds.getCenter());\n        // var rotationalOffset = rotationCenter ? polygonPosition.difference(rotationCenter) : { x: 0, y: 0 };\n        // var rotationalOffset = { x: 0, y: 0 };\n        var tileCenter = basePolygonBounds.getCenter().sub(targetCenterDifference);\n        // Get the position offset of the polygon\n        var targetTextureSize = new Vertex(textureSize.width, textureSize.height);\n        // var targetTextureOffset = new Vertex(-textureSize.width / 2, -textureSize.height / 2).sub(targetCenterDifference);\n        var targetTextureOffset = new Vertex(textureSize.min.x, textureSize.min.y).sub(polygonPosition);\n        this.ctx.save();\n        // this.ctx.translate(this.offset.x + rotationCenter.x * this.scale.x, this.offset.y + rotationCenter.y * this.scale.y);\n        this.ctx.translate(this.offset.x + polygonPosition.x * this.scale.x, this.offset.y + polygonPosition.y * this.scale.y);\n        drawutils.helpers.clipPoly(this.ctx, {\n            x: -polygonPosition.x * this.scale.x,\n            y: -polygonPosition.y * this.scale.y\n        }, this.scale, polygon.vertices);\n        this.ctx.scale(this.scale.x, this.scale.y);\n        this.ctx.rotate(rotation);\n        this.ctx.drawImage(textureImage, 0, 0, textureImage.naturalWidth - 1, // There is this horrible Safari bug (fixed in newer versions)\n        textureImage.naturalHeight - 1, // To avoid errors substract 1 here.\n        targetTextureOffset.x, // * this.scale.x,\n        targetTextureOffset.y, // * this.scale.y,\n        targetTextureSize.x, //  * this.scale.x,\n        targetTextureSize.y // * this.scale.y\n        );\n        this.ctx.restore();\n    }\n    _texturedPoly(textureImage, textureSize, polygon, polygonPosition, rotation, rotationCenter = { x: 0, y: 0 }) {\n        var basePolygonBounds = polygon.getBounds();\n        var targetCenterDifference = polygonPosition.clone().difference(basePolygonBounds.getCenter());\n        var rotationalOffset = rotationCenter ? polygonPosition.difference(rotationCenter) : { x: 0, y: 0 };\n        // var rotationalOffset = { x: 0, y: 0 };\n        var tileCenter = basePolygonBounds.getCenter().sub(targetCenterDifference);\n        // Get the position offset of the polygon\n        var targetTextureSize = new Vertex(textureSize.width, textureSize.height);\n        var targetTextureOffset = new Vertex(-textureSize.width / 2, -textureSize.height / 2).sub(targetCenterDifference);\n        this.ctx.save();\n        // this.ctx.translate(\n        //   this.offset.x + (tileCenter.x - rotationalOffset.x * 0 + targetTextureOffset.x * 0.0) * this.scale.x,\n        //   this.offset.y + (tileCenter.y - rotationalOffset.y * 0 + targetTextureOffset.y * 0.0) * this.scale.y\n        // );\n        this.ctx.translate(this.offset.x + (tileCenter.x - rotationalOffset.x * 0 + targetTextureOffset.x * 0.0) * this.scale.x, this.offset.y + (tileCenter.y - rotationalOffset.y * 0 + targetTextureOffset.y * 0.0) * this.scale.y);\n        this.ctx.rotate(rotation);\n        drawutils.helpers.clipPoly(this.ctx, {\n            x: (-targetCenterDifference.x * 1 - tileCenter.x - rotationalOffset.x) * this.scale.x,\n            y: (-targetCenterDifference.y * 1 - tileCenter.y - rotationalOffset.y) * this.scale.y\n        }, this.scale, polygon.vertices);\n        this.ctx.drawImage(textureImage, 0, 0, textureImage.naturalWidth - 1, // There is this horrible Safari bug (fixed in newer versions)\n        textureImage.naturalHeight - 1, // To avoid errors substract 1 here.\n        (-polygonPosition.x + targetTextureOffset.x * 1 - rotationalOffset.x * 1) * this.scale.x, (-polygonPosition.y + targetTextureOffset.y * 1 - rotationalOffset.y * 1) * this.scale.y, targetTextureSize.x * this.scale.x, targetTextureSize.y * this.scale.y);\n        // const scaledTextureSize = new Bounds(\n        //   new Vertex(\n        //     -polygonPosition.x + targetTextureOffset.x - rotationalOffset.x,\n        //     -polygonPosition.y + targetTextureOffset.y - rotationalOffset.y\n        //   ).scaleXY(this.scale, rotationCenter),\n        //   new Vertex(\n        //     -polygonPosition.x + targetTextureOffset.x - rotationalOffset.x + targetTextureSize.x,\n        //     -polygonPosition.y + targetTextureOffset.y - rotationalOffset.y + targetTextureSize.y\n        //   ).scaleXY(this.scale, rotationCenter)\n        // );\n        // this.ctx.drawImage(\n        //   textureImage,\n        //   0,\n        //   0,\n        //   textureImage.naturalWidth - 1, // There is this horrible Safari bug (fixed in newer versions)\n        //   textureImage.naturalHeight - 1, // To avoid errors substract 1 here.\n        //   scaledTextureSize.min.x,\n        //   scaledTextureSize.min.y,\n        //   scaledTextureSize.width,\n        //   scaledTextureSize.height\n        // );\n        this.ctx.restore();\n    }\n    /**\n     * Draw a rectangle.\n     *\n     * @param {XYCoords} position - The upper left corner of the rectangle.\n     * @param {number} width - The width of the rectangle.\n     * @param {number} height - The height of the rectangle.\n     * @param {string} color - The color to use.\n     * @param {number=1} lineWidth - (optional) The line with to use (default is 1).\n     **/\n    rect(position, width, height, color, lineWidth) {\n        this.ctx.save();\n        this.ctx.beginPath();\n        this.ctx.moveTo(this.offset.x + position.x * this.scale.x, this.offset.y + position.y * this.scale.y);\n        this.ctx.lineTo(this.offset.x + (position.x + width) * this.scale.x, this.offset.y + position.y * this.scale.y);\n        this.ctx.lineTo(this.offset.x + (position.x + width) * this.scale.x, this.offset.y + (position.y + height) * this.scale.y);\n        this.ctx.lineTo(this.offset.x + position.x * this.scale.x, this.offset.y + (position.y + height) * this.scale.y);\n        // this.ctx.lineTo( this.offset.x+position.x*this.scale.x, this.offset.y+position.y*this.scale.y );\n        this.ctx.closePath();\n        this.ctx.lineWidth = lineWidth || 1;\n        this._fillOrDraw(color);\n        this.ctx.restore();\n    }\n    // +---------------------------------------------------------------------------------\n    // | This is the final helper function for drawing and filling stuff. It is not\n    // | intended to be used from the outside.\n    // |\n    // | When in draw mode it draws the current shape.\n    // | When in fill mode it fills the current shape.\n    // |\n    // | This function is usually only called internally.\n    // |\n    // | @param color A stroke/fill color to use.\n    // +-------------------------------\n    // TODO: convert this to a STATIC function.\n    _fillOrDraw(color) {\n        if (this.fillShapes) {\n            this.ctx.fillStyle = color;\n            this.ctx.fill();\n        }\n        else {\n            this.ctx.strokeStyle = color;\n            this.ctx.stroke();\n        }\n    }\n    /**\n     * Draw the given (cubic) bézier curve.\n     *\n     * @method cubicBezier\n     * @param {Vertex} startPoint - The start point of the cubic Bézier curve\n     * @param {Vertex} endPoint   - The end point the cubic Bézier curve.\n     * @param {Vertex} startControlPoint - The start control point the cubic Bézier curve.\n     * @param {Vertex} endControlPoint   - The end control point the cubic Bézier curve.\n     * @param {string} color - The CSS color to draw the curve with.\n     * @param {number} lineWidth - (optional) The line width to use.\n     * @return {void}\n     * @instance\n     * @memberof drawutils\n     */\n    cubicBezier(startPoint, endPoint, startControlPoint, endControlPoint, color, lineWidth) {\n        if (startPoint instanceof CubicBezierCurve) {\n            this.cubicBezier(startPoint.startPoint, startPoint.endPoint, startPoint.startControlPoint, startPoint.endControlPoint, color, lineWidth);\n            return;\n        }\n        // Draw curve\n        this.ctx.save();\n        this.ctx.beginPath();\n        this.ctx.moveTo(this.offset.x + startPoint.x * this.scale.x, this.offset.y + startPoint.y * this.scale.y);\n        this.ctx.bezierCurveTo(this.offset.x + startControlPoint.x * this.scale.x, this.offset.y + startControlPoint.y * this.scale.y, this.offset.x + endControlPoint.x * this.scale.x, this.offset.y + endControlPoint.y * this.scale.y, this.offset.x + endPoint.x * this.scale.x, this.offset.y + endPoint.y * this.scale.y);\n        //this.ctx.closePath();\n        this.ctx.lineWidth = lineWidth || 2;\n        this._fillOrDraw(color);\n        this.ctx.restore();\n    }\n    /**\n     * Draw the given (quadratic) bézier curve.\n     *\n     * @method quadraticBezier\n     * @param {Vertex} startPoint   - The start point of the cubic Bézier curve\n     * @param {Vertex} controlPoint - The control point the cubic Bézier curve.\n     * @param {Vertex} endPoint     - The end control point the cubic Bézier curve.\n     * @param {string} color        - The CSS color to draw the curve with.\n     * @param {number|string} lineWidth - (optional) The line width to use.\n     * @return {void}\n     * @instance\n     * @memberof drawutils\n     */\n    quadraticBezier(startPoint, controlPoint, endPoint, color, lineWidth) {\n        // Draw curve\n        this.ctx.save();\n        this.ctx.beginPath();\n        this.ctx.moveTo(this.offset.x + startPoint.x * this.scale.x, this.offset.y + startPoint.y * this.scale.y);\n        this.ctx.quadraticCurveTo(this.offset.x + controlPoint.x * this.scale.x, this.offset.y + controlPoint.y * this.scale.y, this.offset.x + endPoint.x * this.scale.x, this.offset.y + endPoint.y * this.scale.y);\n        this.ctx.lineWidth = lineWidth || 2;\n        this._fillOrDraw(color);\n        this.ctx.restore();\n    }\n    /**\n     * Draw the given (cubic) Bézier path.\n     *\n     * The given path must be an array with n*3+1 vertices, where n is the number of\n     * curves in the path:\n     * <pre> [ point1, point1_startControl, point2_endControl, point2, point2_startControl, point3_endControl, point3, ... pointN_endControl, pointN ]</pre>\n     *\n     * @method cubicBezierPath\n     * @param {Vertex[]} path - The cubic bezier path as described above.\n     * @param {string} color - The CSS colot to draw the path with.\n     * @param {number=1} lineWidth - (optional) The line width to use.\n     * @return {void}\n     * @instance\n     * @memberof drawutils\n     */\n    cubicBezierPath(path, color, lineWidth) {\n        if (!path || path.length == 0)\n            return;\n        // Draw curve\n        this.ctx.save();\n        this.ctx.beginPath();\n        var endPoint;\n        var startControlPoint;\n        var endControlPoint;\n        this.ctx.moveTo(this.offset.x + path[0].x * this.scale.x, this.offset.y + path[0].y * this.scale.y);\n        for (var i = 1; i < path.length; i += 3) {\n            startControlPoint = path[i];\n            endControlPoint = path[i + 1];\n            endPoint = path[i + 2];\n            this.ctx.bezierCurveTo(this.offset.x + startControlPoint.x * this.scale.x, this.offset.y + startControlPoint.y * this.scale.y, this.offset.x + endControlPoint.x * this.scale.x, this.offset.y + endControlPoint.y * this.scale.y, this.offset.x + endPoint.x * this.scale.x, this.offset.y + endPoint.y * this.scale.y);\n        }\n        this.ctx.closePath();\n        this.ctx.lineWidth = lineWidth || 1;\n        this._fillOrDraw(color);\n        this.ctx.restore();\n    }\n    /**\n     * Draw the given handle and handle point (used to draw interactive Bézier curves).\n     *\n     * The colors for this are fixed and cannot be specified.\n     *\n     * @method handle\n     * @param {Vertex} startPoint - The start of the handle.\n     * @param {Vertex} endPoint - The end point of the handle.\n     * @return {void}\n     * @instance\n     * @memberof drawutils\n     */\n    handle(startPoint, endPoint) {\n        // Draw handles\n        // (No need to save and restore here)\n        this.point(startPoint, \"rgb(0,32,192)\");\n        this.square(endPoint, 5, \"rgba(0,128,192,0.5)\");\n    }\n    /**\n     * Draw a handle line (with a light grey).\n     *\n     * @method handleLine\n     * @param {Vertex} startPoint - The start point to draw the handle at.\n     * @param {Vertex} endPoint - The end point to draw the handle at.\n     * @return {void}\n     * @instance\n     * @memberof drawutils\n     */\n    handleLine(startPoint, endPoint) {\n        // Draw handle lines\n        this.line(startPoint, endPoint, \"rgb(192,192,192)\");\n    }\n    /**\n     * Draw a 1x1 dot with the specified (CSS-) color.\n     *\n     * @method dot\n     * @param {Vertex} p - The position to draw the dot at.\n     * @param {string} color - The CSS color to draw the dot with.\n     * @return {void}\n     * @instance\n     * @memberof drawutils\n     */\n    dot(p, color) {\n        this.ctx.save();\n        this.ctx.beginPath();\n        this.ctx.moveTo(Math.round(this.offset.x + this.scale.x * p.x), Math.round(this.offset.y + this.scale.y * p.y));\n        this.ctx.lineTo(Math.round(this.offset.x + this.scale.x * p.x + 1), Math.round(this.offset.y + this.scale.y * p.y + 1));\n        this.ctx.closePath();\n        this.ctx.lineWidth = 1;\n        this._fillOrDraw(color);\n        this.ctx.restore();\n    }\n    /**\n     * Draw the given point with the specified (CSS-) color and radius 3.\n     *\n     * @method point\n     * @param {Vertex} p - The position to draw the point at.\n     * @param {string} color - The CSS color to draw the point with.\n     * @return {void}\n     * @instance\n     * @memberof drawutils\n     */\n    point(p, color) {\n        var radius = 3;\n        this.ctx.beginPath();\n        this.ctx.arc(this.offset.x + p.x * this.scale.x, this.offset.y + p.y * this.scale.y, radius, 0, 2 * Math.PI, false);\n        this.ctx.closePath();\n        this.ctx.lineWidth = 1;\n        this._fillOrDraw(color);\n    }\n    /**\n     * Draw a circle with the specified (CSS-) color and radius.<br>\n     * <br>\n     * Note that if the x- and y- scales are different the result will be an ellipse rather than a circle.\n     *\n     * @method circle\n     * @param {Vertex} center - The center of the circle.\n     * @param {number} radius - The radius of the circle.\n     * @param {string} color - The CSS color to draw the circle with.\n     * @param {number} lineWidth - The line width (optional, default=1).\n     * @return {void}\n     * @instance\n     * @memberof drawutils\n     */\n    circle(center, radius, color, lineWidth) {\n        this.ctx.beginPath();\n        this.ctx.ellipse(this.offset.x + center.x * this.scale.x, this.offset.y + center.y * this.scale.y, radius * this.scale.x, radius * this.scale.y, 0.0, 0.0, Math.PI * 2);\n        this.ctx.closePath();\n        this.ctx.lineWidth = lineWidth || 1;\n        this._fillOrDraw(color);\n    }\n    /**\n       * Draw a circular arc (section of a circle) with the given CSS color.\n       *\n       * @method circleArc\n       * @param {Vertex} center - The center of the circle.\n       * @param {number} radius - The radius of the circle.\n       * @param {number} startAngle - The angle to start at.\n       * @param {number} endAngle - The angle to end at.\n       * @param {string=#000000} color - The CSS color to draw the circle with.\n       * @param {number=1} lineWidth - The line width to use\n       // * @param {boolean=false} options.asSegment - If `true` then no beginPath and no draw will be applied (as part of larger path).\n       * @return {void}\n       * @instance\n       * @memberof drawutils\n       */\n    circleArc(center, radius, startAngle, endAngle, color, lineWidth, options) {\n        if (!options || !options.asSegment) {\n            this.ctx.beginPath();\n        }\n        this.ctx.ellipse(this.offset.x + center.x * this.scale.x, this.offset.y + center.y * this.scale.y, radius * this.scale.x, radius * this.scale.y, 0.0, startAngle, endAngle, false);\n        if (!options || !options.asSegment) {\n            // this.ctx.closePath();\n            this.ctx.lineWidth = lineWidth || 1;\n            this._fillOrDraw(color || \"#000000\");\n        }\n    }\n    /**\n     * Draw an ellipse with the specified (CSS-) color and thw two radii.\n     *\n     * @method ellipse\n     * @param {Vertex} center - The center of the ellipse.\n     * @param {number} radiusX - The radius of the ellipse.\n     * @param {number} radiusY - The radius of the ellipse.\n     * @param {string} color - The CSS color to draw the ellipse with.\n     * @param {number} lineWidth=1 - An optional line width param (default is 1).\n     * @param {number=} rotation - (optional, default=0) The rotation of the ellipse.\n     * @return {void}\n     * @instance\n     * @memberof drawutils\n     */\n    ellipse(center, radiusX, radiusY, color, lineWidth, rotation) {\n        if (typeof rotation === \"undefined\") {\n            rotation = 0.0;\n        }\n        this.ctx.beginPath();\n        this.ctx.ellipse(this.offset.x + center.x * this.scale.x, this.offset.y + center.y * this.scale.y, radiusX * this.scale.x, radiusY * this.scale.y, rotation, 0.0, Math.PI * 2);\n        this.ctx.closePath();\n        this.ctx.lineWidth = lineWidth || 1;\n        this._fillOrDraw(color);\n    }\n    /**\n     * Draw square at the given center, size and with the specified (CSS-) color.<br>\n     * <br>\n     * Note that if the x-scale and the y-scale are different the result will be a rectangle rather than a square.\n     *\n     * @method square\n     * @param {XYCoords} center - The center of the square.\n     * @param {number} size - The size of the square.\n     * @param {string} color - The CSS color to draw the square with.\n     * @param {number} lineWidth - The line with to use (optional, default is 1).\n     * @return {void}\n     * @instance\n     * @memberof drawutils\n     */\n    square(center, size, color, lineWidth) {\n        this.ctx.beginPath();\n        this.ctx.rect(this.offset.x + (center.x - size / 2.0) * this.scale.x, this.offset.y + (center.y - size / 2.0) * this.scale.y, size * this.scale.x, size * this.scale.y);\n        this.ctx.closePath();\n        this.ctx.lineWidth = lineWidth || 1;\n        this._fillOrDraw(color);\n    }\n    /**\n     * Draw a grid of horizontal and vertical lines with the given (CSS-) color.\n     *\n     * @method grid\n     * @param {Vertex} center - The center of the grid.\n     * @param {number} width - The total width of the grid (width/2 each to the left and to the right).\n     * @param {number} height - The total height of the grid (height/2 each to the top and to the bottom).\n     * @param {number} sizeX - The horizontal grid size.\n     * @param {number} sizeY - The vertical grid size.\n     * @param {string} color - The CSS color to draw the grid with.\n     * @return {void}\n     * @instance\n     * @memberof drawutils\n     */\n    grid(center, width, height, sizeX, sizeY, color) {\n        this.ctx.beginPath();\n        var yMin = -Math.ceil((height * 0.5) / sizeY) * sizeY;\n        var yMax = height / 2;\n        for (var x = -Math.ceil((width * 0.5) / sizeX) * sizeX; x < width / 2; x += sizeX) {\n            this.ctx.moveTo(this.offset.x + (center.x + x) * this.scale.x, this.offset.y + (center.y + yMin) * this.scale.y);\n            this.ctx.lineTo(this.offset.x + (center.x + x) * this.scale.x, this.offset.y + (center.y + yMax) * this.scale.y);\n        }\n        var xMin = -Math.ceil((width * 0.5) / sizeX) * sizeX; // -Math.ceil((height*0.5)/sizeY)*sizeY;\n        var xMax = width / 2; // height/2;\n        for (var y = -Math.ceil((height * 0.5) / sizeY) * sizeY; y < height / 2; y += sizeY) {\n            this.ctx.moveTo(this.offset.x + (center.x + xMin) * this.scale.x - 4, this.offset.y + (center.y + y) * this.scale.y);\n            this.ctx.lineTo(this.offset.x + (center.x + xMax) * this.scale.x + 4, this.offset.y + (center.y + y) * this.scale.y);\n        }\n        this.ctx.strokeStyle = color;\n        this.ctx.lineWidth = 1.0;\n        this.ctx.stroke();\n        this.ctx.closePath();\n    }\n    /**\n     * Draw a raster of crosshairs in the given grid.<br>\n     *\n     * This works analogue to the grid() function\n     *\n     * @method raster\n     * @param {Vertex} center - The center of the raster.\n     * @param {number} width - The total width of the raster (width/2 each to the left and to the right).\n     * @param {number} height - The total height of the raster (height/2 each to the top and to the bottom).\n     * @param {number} sizeX - The horizontal raster size.\n     * @param {number} sizeY - The vertical raster size.\n     * @param {string} color - The CSS color to draw the raster with.\n     * @return {void}\n     * @instance\n     * @memberof drawutils\n     */\n    raster(center, width, height, sizeX, sizeY, color) {\n        this.ctx.save();\n        this.ctx.beginPath();\n        for (var x = -Math.ceil((width * 0.5) / sizeX) * sizeX; x < width / 2; x += sizeX) {\n            for (var y = -Math.ceil((height * 0.5) / sizeY) * sizeY; y < height / 2; y += sizeY) {\n                // Draw a crosshair\n                this.ctx.moveTo(this.offset.x + (center.x + x) * this.scale.x - 4, this.offset.y + (center.y + y) * this.scale.y);\n                this.ctx.lineTo(this.offset.x + (center.x + x) * this.scale.x + 4, this.offset.y + (center.y + y) * this.scale.y);\n                this.ctx.moveTo(this.offset.x + (center.x + x) * this.scale.x, this.offset.y + (center.y + y) * this.scale.y - 4);\n                this.ctx.lineTo(this.offset.x + (center.x + x) * this.scale.x, this.offset.y + (center.y + y) * this.scale.y + 4);\n            }\n        }\n        this.ctx.strokeStyle = color;\n        this.ctx.lineWidth = 1.0;\n        this.ctx.stroke();\n        this.ctx.closePath();\n        this.ctx.restore();\n    }\n    /**\n     * Draw a diamond handle (square rotated by 45°) with the given CSS color.\n     *\n     * It is an inherent feature of the handle functions that the drawn elements are not scaled and not\n     * distorted. So even if the user zooms in or changes the aspect ratio, the handles will be drawn\n     * as even shaped diamonds.\n     *\n     * @method diamondHandle\n     * @param {Vertex} center - The center of the diamond.\n     * @param {Vertex} size - The x/y-size of the diamond.\n     * @param {string} color - The CSS color to draw the diamond with.\n     * @return {void}\n     * @instance\n     * @memberof drawutils\n     */\n    diamondHandle(center, size, color) {\n        this.ctx.beginPath();\n        this.ctx.moveTo(this.offset.x + center.x * this.scale.x - size / 2.0, this.offset.y + center.y * this.scale.y);\n        this.ctx.lineTo(this.offset.x + center.x * this.scale.x, this.offset.y + center.y * this.scale.y - size / 2.0);\n        this.ctx.lineTo(this.offset.x + center.x * this.scale.x + size / 2.0, this.offset.y + center.y * this.scale.y);\n        this.ctx.lineTo(this.offset.x + center.x * this.scale.x, this.offset.y + center.y * this.scale.y + size / 2.0);\n        this.ctx.closePath();\n        this.ctx.lineWidth = 1;\n        this._fillOrDraw(color);\n    }\n    /**\n     * Draw a square handle with the given CSS color.<br>\n     * <br>\n     * It is an inherent feature of the handle functions that the drawn elements are not scaled and not\n     * distorted. So even if the user zooms in or changes the aspect ratio, the handles will be drawn\n     * as even shaped squares.\n     *\n     * @method squareHandle\n     * @param {Vertex} center - The center of the square.\n     * @param {Vertex} size - The x/y-size of the square.\n     * @param {string} color - The CSS color to draw the square with.\n     * @return {void}\n     * @instance\n     * @memberof drawutils\n     */\n    squareHandle(center, size, color) {\n        this.ctx.beginPath();\n        this.ctx.rect(this.offset.x + center.x * this.scale.x - size / 2.0, this.offset.y + center.y * this.scale.y - size / 2.0, size, size);\n        this.ctx.closePath();\n        this.ctx.lineWidth = 1;\n        this._fillOrDraw(color);\n    }\n    /**\n     * Draw a circle handle with the given CSS color.<br>\n     * <br>\n     * It is an inherent feature of the handle functions that the drawn elements are not scaled and not\n     * distorted. So even if the user zooms in or changes the aspect ratio, the handles will be drawn\n     * as even shaped circles.\n     *\n     * @method circleHandle\n     * @param {Vertex} center - The center of the circle.\n     * @param {number} radius - The radius of the circle.\n     * @param {string} color - The CSS color to draw the circle with.\n     * @return {void}\n     * @instance\n     * @memberof drawutils\n     */\n    circleHandle(center, radius, color) {\n        radius = radius || 3;\n        this.ctx.beginPath();\n        this.ctx.arc(this.offset.x + center.x * this.scale.x, this.offset.y + center.y * this.scale.y, radius, 0, 2 * Math.PI, false);\n        this.ctx.closePath();\n        this.ctx.lineWidth = 1;\n        this._fillOrDraw(color);\n    }\n    /**\n     * Draw a crosshair with given radius and color at the given position.<br>\n     * <br>\n     * Note that the crosshair radius will not be affected by scaling.\n     *\n     * @method crosshair\n     * @param {XYCoords} center - The center of the crosshair.\n     * @param {number} radius - The radius of the crosshair.\n     * @param {string} color - The CSS color to draw the crosshair with.\n     * @param {number=0.5} lineWidth - (optional, default=0.5) The line width to use.\n     * @return {void}\n     * @instance\n     * @memberof drawutils\n     */\n    crosshair(center, radius, color, lineWidth) {\n        this.ctx.save();\n        this.ctx.beginPath();\n        this.ctx.moveTo(this.offset.x + center.x * this.scale.x - radius, this.offset.y + center.y * this.scale.y);\n        this.ctx.lineTo(this.offset.x + center.x * this.scale.x + radius, this.offset.y + center.y * this.scale.y);\n        this.ctx.moveTo(this.offset.x + center.x * this.scale.x, this.offset.y + center.y * this.scale.y - radius);\n        this.ctx.lineTo(this.offset.x + center.x * this.scale.x, this.offset.y + center.y * this.scale.y + radius);\n        this.ctx.strokeStyle = color;\n        this.ctx.lineWidth = lineWidth || 0.5;\n        this.ctx.stroke();\n        this.ctx.closePath();\n        this.ctx.restore();\n    }\n    /**\n     * Draw a cross with diagonal axes with given radius, color and lineWidth at the given position.<br>\n     * <br>\n     * Note that the x's radius will not be affected by scaling.\n     *\n     * @method crosshair\n     * @param {XYCoords} center - The center of the crosshair.\n     * @param {number} radius - The radius of the crosshair.\n     * @param {string} color - The CSS color to draw the crosshair with.\n     * @param {number=1} lineWidth - (optional, default=1.0) The line width to use.\n     * @return {void}\n     * @instance\n     * @memberof drawutils\n     */\n    cross(center, radius, color, lineWidth) {\n        this.ctx.save();\n        this.ctx.beginPath();\n        this.ctx.moveTo(this.offset.x + center.x * this.scale.x - radius, this.offset.y + center.y * this.scale.y - radius);\n        this.ctx.lineTo(this.offset.x + center.x * this.scale.x + radius, this.offset.y + center.y * this.scale.y + radius);\n        this.ctx.moveTo(this.offset.x + center.x * this.scale.x - radius, this.offset.y + center.y * this.scale.y + radius);\n        this.ctx.lineTo(this.offset.x + center.x * this.scale.x + radius, this.offset.y + center.y * this.scale.y - radius);\n        this.ctx.strokeStyle = color;\n        this.ctx.lineWidth = lineWidth || 1.0;\n        this.ctx.stroke();\n        this.ctx.closePath();\n        this.ctx.restore();\n    }\n    /**\n     * Draw a polygon.\n     *\n     * @method polygon\n     * @param {Polygon}  polygon - The polygon to draw.\n     * @param {string}   color - The CSS color to draw the polygon with.\n     * @param {string}   lineWidth - The line width to use.\n     * @return {void}\n     * @instance\n     * @memberof drawutils\n     */\n    polygon(polygon, color, lineWidth) {\n        this.polyline(polygon.vertices, polygon.isOpen, color, lineWidth);\n    }\n    /**\n     * Draw a polygon line (alternative function to the polygon).\n     *\n     * @method polyline\n     * @param {Vertex[]} vertices   - The polygon vertices to draw.\n     * @param {boolan}   isOpen     - If true the polyline will not be closed at its end.\n     * @param {string}   color      - The CSS color to draw the polygon with.\n     * @param {number}   lineWidth  - The line width (default is 1.0);\n     * @return {void}\n     * @instance\n     * @memberof drawutils\n     */\n    polyline(vertices, isOpen, color, lineWidth) {\n        if (vertices.length <= 1) {\n            return;\n        }\n        this.ctx.save();\n        this.ctx.beginPath();\n        this.ctx.lineWidth = (lineWidth || 1.0) * this.scale.x;\n        this.ctx.moveTo(this.offset.x + vertices[0].x * this.scale.x, this.offset.y + vertices[0].y * this.scale.y);\n        for (var i = 0; i < vertices.length; i++) {\n            this.ctx.lineTo(this.offset.x + vertices[i].x * this.scale.x, this.offset.y + vertices[i].y * this.scale.y);\n        }\n        if (!isOpen)\n            // && vertices.length > 2 )\n            this.ctx.closePath();\n        this._fillOrDraw(color);\n        this.ctx.closePath();\n        this.ctx.setLineDash([]);\n        this.ctx.restore();\n    }\n    /**\n     * Draw a text at the given relative position.\n     *\n     * @method text\n     * @param {string} text - The text to draw.\n     * @param {number} x - The x-position to draw the text at.\n     * @param {number} y - The y-position to draw the text at.\n     * @param {string=} options.color - The Color to use.\n     * @param {string=} options.fontFamily - The font family to use.\n     * @param {number=} options.fontSize - The font size (in pixels) to use.\n     * @param {FontStyle=} options.fontStyle - The font style to use.\n     * @param {FontWeight=} options.fontWeight - The font weight to use.\n     * @param {number=} options.lineHeight - The line height (in pixels) to use.\n     * @param {number=} options.rotation - The (optional) rotation in radians.\n     * @param {string=} options.textAlign - The text align to use. According to the specifiactions (https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/textAlign) valid values are `\"left\" || \"right\" || \"center\" || \"start\" || \"end\"`.\n     * @return {void}\n     * @instance\n     * @memberof drawutils\n     */\n    text(text, x, y, options) {\n        // See https://stackoverflow.com/a/23523697\n        var _a, _b, _c;\n        options = options || {};\n        this.ctx.save();\n        let relX = this.offset.x + x * this.scale.x;\n        let relY = this.offset.y + y * this.scale.y;\n        const color = options.color || \"black\";\n        if (options.fontSize || options.fontFamily) {\n            // Scaling of text only works in uniform mode\n            this.ctx.font =\n                (options.fontWeight ? options.fontWeight + \" \" : \"\") +\n                    (options.fontStyle ? options.fontStyle + \" \" : \"\") +\n                    (options.fontSize ? options.fontSize * this.scale.x + \"px \" : \" \") +\n                    (options.fontFamily\n                        ? options.fontFamily.indexOf(\" \") === -1\n                            ? options.fontFamily\n                            : `\"${options.fontFamily}\"`\n                        : \"Arial\");\n        }\n        if (options.textAlign) {\n            this.ctx.textAlign = options.textAlign;\n        }\n        const rotation = (_a = options.rotation) !== null && _a !== void 0 ? _a : 0.0;\n        const lineHeight = ((_c = (_b = options.lineHeight) !== null && _b !== void 0 ? _b : options.fontSize) !== null && _c !== void 0 ? _c : 0) * this.scale.x;\n        this.ctx.translate(relX, relY);\n        this.ctx.rotate(rotation);\n        if (this.fillShapes) {\n            this.ctx.fillStyle = color;\n            this.ctx.fillText(text, 0, lineHeight / 2);\n        }\n        else {\n            this.ctx.strokeStyle = color;\n            this.ctx.strokeText(text, 0, lineHeight / 2);\n        }\n        // this.ctx.translate(-relX, -relY);\n        // this.ctx.rotate(-rotation); // is this necessary before 'restore()'?\n        this.ctx.restore();\n    }\n    /**\n     * Draw a non-scaling text label at the given position.\n     *\n     * Note that these are absolute label positions, they are not affected by offset or scale.\n     *\n     * @method label\n     * @param {string} text - The text to draw.\n     * @param {number} x - The x-position to draw the text at.\n     * @param {number} y - The y-position to draw the text at.\n     * @param {number=} rotation - The (optional) rotation in radians (default=0).\n     * @param {string=} color - The color to render the text with (default=black).\n     * @return {void}\n     * @instance\n     * @memberof drawutils\n     */\n    label(text, x, y, rotation, color) {\n        this.ctx.save();\n        this.ctx.font = \"lighter 9pt Arial\";\n        this.ctx.translate(x, y);\n        if (typeof rotation !== \"undefined\")\n            this.ctx.rotate(rotation);\n        this.ctx.fillStyle = color || \"black\";\n        if (this.fillShapes) {\n            this.ctx.fillText(text, 0, 0);\n        }\n        else {\n            this.ctx.strokeText(text, 0, 0);\n        }\n        this.ctx.restore();\n    }\n    /**\n     * Draw an SVG-like path given by the specified path data.\n     *\n     *\n     * @method path\n     * @param {SVGPathData} pathData - An array of path commands and params.\n     * @param {string=null} color - (optional) The color to draw this path with (default is null).\n     * @param {number=1} lineWidth - (optional) the line width to use (default is 1).\n     * @param {boolean=false} options.inplace - (optional) If set to true then path transforamtions (scale and translate) will be done in-place in the array. This can boost the performance.\n     * @instance\n     * @memberof drawutils\n     * @return {R} An instance representing the drawn path.\n     */\n    path(pathData, color, lineWidth, options) {\n        const d = options && options.inplace ? pathData : drawutilssvg.copyPathData(pathData);\n        drawutilssvg.transformPathData(d, this.offset, this.scale);\n        if (color) {\n            this.ctx.strokeStyle = color;\n        }\n        this.ctx.lineWidth = lineWidth || 1;\n        if (this.fillShapes) {\n            if (color) {\n                this.ctx.fillStyle = color;\n            }\n            this.ctx.fill(new Path2D(d.join(\" \")));\n        }\n        else {\n            if (color) {\n                this.ctx.strokeStyle = color;\n            }\n            this.ctx.stroke(new Path2D(d.join(\" \")));\n        }\n    }\n    /**\n     * Due to gl compatibility there is a generic 'clear' function required\n     * to avoid accessing the context object itself directly.\n     *\n     * This function just fills the whole canvas with a single color.\n     *\n     * @param {string} color - The color to clear with.\n     **/\n    clear(color) {\n        this.ctx.clearRect(0, 0, this.ctx.canvas.width, this.ctx.canvas.height);\n        this.ctx.fillStyle = color;\n        this.ctx.fillRect(0, 0, this.ctx.canvas.width, this.ctx.canvas.height);\n    }\n}\ndrawutils.helpers = {\n    // A helper function to define the clipping path.\n    // This could be a candidate for the draw library.\n    clipPoly: (ctx, offset, scale, vertices) => {\n        ctx.beginPath();\n        // Set clip mask\n        ctx.moveTo(offset.x + vertices[0].x * scale.x, offset.y + vertices[0].y * scale.y);\n        for (var i = 1; i < vertices.length; i++) {\n            const vert = vertices[i];\n            ctx.lineTo(offset.x + vert.x * scale.x, offset.y + vert.y * scale.y);\n        }\n        ctx.closePath();\n        ctx.clip();\n    }\n};\n//# sourceMappingURL=draw.js.map","/**\n * @author   Ikaros Kappler\n * @date     2019-09-18\n * @modified 2019-10-03 Added the beginDrawCycle hook.\n * @modified 2020-03-25 Ported stub to Typescript.\n * @modified 2020-10-15 Re-added the text() function.\n * @modified 2021-01-24 Added the `setCurrentId` function.\n * @modified 2021-05-31 Added the `setConfiguration` function from `DrawLib`.\n * @modified 2022-02-03 Added the `lineWidth` param to the `crosshair` function.\n * @modified 2022-02-03 Added the `cross(...)` function.\n * @modified 2022-03-27 Added the `texturedPoly` function.\n * @modified 2022-07-26 Adding `alpha` to the `image(...)` function.\n * @modified 2023-02-10 The methods `setCurrentClassName` and `setCurrentId` also accept `null` now.\n * @version  0.0.9\n **/\nimport { Vertex } from \"./Vertex\";\n/**\n * @classdesc A wrapper class for basic drawing operations. This is the WebGL\n * implementation whih sould work with shaders.\n *\n * @requires CubicBzierCurvce\n * @requires Polygon\n * @requires SVGSerializable\n * @requires Vertex\n * @requires XYCoords\n */\nexport class drawutilsgl {\n    /**\n     * The constructor.\n     *\n     * @constructor\n     * @name drawutils\n     * @param {WebGLRenderingContext|null} context - The drawing context.\n     * @param {boolean} fillShaped - Indicates if the constructed drawutils should fill all drawn shapes (if possible).\n     **/\n    constructor(context, fillShapes) {\n        this.gl = context;\n        this.offset = new Vertex(0, 0);\n        this.scale = new Vertex(1, 1);\n        this.fillShapes = fillShapes;\n        this._zindex = 0.0;\n        if (context == null || typeof context === \"undefined\")\n            return;\n        this.glutils = new GLU(context);\n        // PROBLEM: CANNOT USE MULTIPLE SHADER PROGRAM INSTANCES ON THE SAME CONTEXT!\n        // SOLUTION: USE SHARED SHADER PROGRAM!!! ... somehow ...\n        // This needs to be considered in the overlying component; both draw-instances need to\n        // share their gl context.\n        // That's what the copyInstace(boolean) method is good for.\n        this._vertShader = this.glutils.compileShader(drawutilsgl.vertCode, this.gl.VERTEX_SHADER);\n        this._fragShader = this.glutils.compileShader(drawutilsgl.fragCode, this.gl.FRAGMENT_SHADER);\n        this._program = this.glutils.makeProgram(this._vertShader, this._fragShader);\n        // Create an empty buffer object\n        this.vertex_buffer = this.gl.createBuffer();\n        // Bind appropriate array buffer to it\n        // this.gl.bindBuffer(this.gl.ARRAY_BUFFER, this.vertex_buffer);\n        console.log(\"gl initialized\");\n    }\n    _x2rel(x) {\n        return ((this.scale.x * x + this.offset.x) / this.gl.canvas.width) * 2.0 - 1.0;\n    }\n    _y2rel(y) {\n        return ((this.offset.y - this.scale.y * y) / this.gl.canvas.height) * 2.0 - 1.0;\n    }\n    /**\n     * Creates a 'shallow' (non deep) copy of this instance. This implies\n     * that under the hood the same gl context and gl program will be used.\n     */\n    copyInstance(fillShapes) {\n        var copy = new drawutilsgl(null, fillShapes);\n        copy.gl = this.gl;\n        copy.glutils = this.glutils;\n        copy._vertShader = this._vertShader;\n        copy._fragShader = this._fragShader;\n        copy._program = this._program;\n        return copy;\n    }\n    /**\n     * Called before each draw cycle.\n     * @param {number} renderTime\n     **/\n    beginDrawCycle(renderTime) {\n        this._zindex = 0.0;\n        this.renderTime = renderTime;\n    }\n    /**\n     * Called after each draw cycle.\n     *\n     * This is required for compatibility with other draw classes in the library (like drawgl).\n     *\n     * @name endDrawCycle\n     * @method\n     * @param {number} renderTime\n     * @instance\n     **/\n    endDrawCycle(renderTime) {\n        // NOOP\n    }\n    /**\n     * Set the current drawlib configuration.\n     *\n     * @name setConfiguration\n     * @method\n     * @param {DrawLibConfiguration} configuration - The new configuration settings to use for the next render methods.\n     */\n    setConfiguration(configuration) {\n        // TODO\n    }\n    /**\n     * This method shouled be called each time the currently drawn `Drawable` changes.\n     * It is used by some libraries for identifying elemente on re-renders.\n     *\n     * @name setCurrentId\n     * @method\n     * @param {UID|null} uid - A UID identifying the currently drawn element(s).es.\n     **/\n    setCurrentId(uid) {\n        // NOOP\n        this.curId = uid;\n    }\n    /**\n     * This method shouled be called each time the currently drawn `Drawable` changes.\n     * Determine the class name for further usage here.\n     *\n     * @name setCurrentClassName\n     * @method\n     * @param {string|null} className - A class name for further custom use cases.\n     **/\n    setCurrentClassName(className) {\n        // NOOP\n    }\n    /**\n     * Draw the line between the given two points with the specified (CSS-) color.\n     *\n     * @method line\n     * @param {Vertex} zA - The start point of the line.\n     * @param {Vertex} zB - The end point of the line.\n     * @param {string} color - Any valid CSS color string.\n     * @return {void}\n     * @instance\n     * @memberof drawutils\n     **/\n    line(zA, zB, color) {\n        const vertices = new Float32Array(6);\n        vertices[0] = this._x2rel(zA.x);\n        vertices[1] = this._y2rel(zA.y);\n        vertices[2] = this._zindex;\n        vertices[3] = this._x2rel(zB.x);\n        vertices[4] = this._y2rel(zB.y);\n        vertices[5] = this._zindex;\n        this._zindex += 0.001;\n        // Create an empty buffer object\n        // const vertex_buffer = this.gl.createBuffer();\n        // Bind appropriate array buffer to it\n        this.gl.bindBuffer(this.gl.ARRAY_BUFFER, this.vertex_buffer);\n        // Pass the vertex data to the buffer\n        this.gl.bufferData(this.gl.ARRAY_BUFFER, vertices, this.gl.STATIC_DRAW);\n        // Bind vertex buffer object\n        // this.gl.bindBuffer(this.gl.ARRAY_BUFFER, vertex_buffer);\n        // Get the attribute location\n        var coord = this.gl.getAttribLocation(this._program, \"position\");\n        // Point an attribute to the currently bound VBO\n        this.gl.vertexAttribPointer(coord, 3, this.gl.FLOAT, false, 0, 0);\n        // Enable the attribute\n        this.gl.enableVertexAttribArray(coord);\n        // Unbind the buffer?\n        //this.gl.bindBuffer(this.gl.ARRAY_BUFFER, null);\n        // Set the view port\n        this.gl.viewport(0, 0, this.gl.canvas.width, this.gl.canvas.height);\n        let uRotationVector = this.gl.getUniformLocation(this._program, \"uRotationVector\");\n        // let radians = currentAngle * Math.PI / 180.0;\n        let currentRotation = [0.0, 1.0];\n        //currentRotation[0] = Math.sin(radians);\n        //currentRotation[1] = Math.cos(radians);\n        this.gl.uniform2fv(uRotationVector, currentRotation);\n        this.gl.lineWidth(5);\n        // Draw the line\n        this.gl.drawArrays(this.gl.LINES, 0, vertices.length / 3);\n        // POINTS, LINE_STRIP, LINE_LOOP, LINES,\n        // TRIANGLE_STRIP,TRIANGLE_FAN, TRIANGLES\n    }\n    /**\n     * Draw a line and an arrow at the end (zB) of the given line with the specified (CSS-) color.\n     *\n     * @method arrow\n     * @param {Vertex} zA - The start point of the arrow-line.\n     * @param {Vertex} zB - The end point of the arrow-line.\n     * @param {string} color - Any valid CSS color string.\n     * @return {void}\n     * @instance\n     * @memberof drawutils\n     **/\n    arrow(zA, zB, color) {\n        // NOT YET IMPLEMENTED\n    }\n    /**\n     * Draw an image at the given position with the given size.<br>\n     * <br>\n     * Note: SVG images may have resizing issues at the moment.Draw a line and an arrow at the end (zB) of the given line with the specified (CSS-) color.\n     *\n     * @method image\n     * @param {Image} image - The image object to draw.\n     * @param {Vertex} position - The position to draw the the upper left corner at.\n     * @param {Vertex} size - The x/y-size to draw the image with.\n     * @param {number=0.0} alpha - (optional, default=0.0) The transparency (0.0=opaque, 1.0=transparent).\n     * @return {void}\n     * @instance\n     * @memberof drawutils\n     **/\n    image(image, position, size, alpha = 0.0) {\n        // NOT YET IMPLEMENTED\n    }\n    /**\n     * Draw an image at the given position with the given size.<br>\n     * <br>\n     * Note: SVG images may have resizing issues at the moment.Draw a line and an arrow at the end (zB) of the given line with the specified (CSS-) color.\n     *\n     * @method texturedPoly\n     * @param {Image} textureImage - The image object to draw.\n     * @param {Bounds} textureSize - The texture size to use; these are the original bounds to map the polygon vertices to.\n     * @param {Polygon} polygon - The polygon to use as clip path.\n     * @param {Vertex} polygonPosition - The polygon's position (relative), measured at the bounding box's center.\n     * @param {number} rotation - The rotation to use for the polygon (and for the texture).\n     * @return {void}\n     * @instance\n     * @memberof drawutilsgl\n     **/\n    texturedPoly(textureImage, textureSize, polygon, polygonPosition, rotation) {\n        // NOT YET IMPLEMENTED\n    }\n    // +---------------------------------------------------------------------------------\n    // | This is the final helper function for drawing and filling stuff. It is not\n    // | intended to be used from the outside.\n    // |\n    // | When in draw mode it draws the current shape.\n    // | When in fill mode it fills the current shape.\n    // |\n    // | This function is usually only called internally.\n    // |\n    // | @param color A stroke/fill color to use.\n    // +-------------------------------\n    _fillOrDraw(color) {\n        // NOT YET IMPLEMENTED\n    }\n    /**\n     * Draw the given (cubic) bézier curve.\n     *\n     * @method cubicBezier\n     * @param {Vertex} startPoint - The start point of the cubic Bézier curve\n     * @param {Vertex} endPoint   - The end point the cubic Bézier curve.\n     * @param {Vertex} startControlPoint - The start control point the cubic Bézier curve.\n     * @param {Vertex} endControlPoint   - The end control point the cubic Bézier curve.\n     * @param {string} color - The CSS color to draw the curve with.\n     * @param {number=} lineWidth - (optional) The line width to use; default is 1.\n     * @return {void}\n     * @instance\n     * @memberof drawutils\n     */\n    cubicBezier(startPoint, endPoint, startControlPoint, endControlPoint, color, lineWidth) {\n        // NOT YET IMPLEMENTED\n    }\n    /**\n     * Draw the given (cubic) Bézier path.\n     *\n     * The given path must be an array with n*3+1 vertices, where n is the number of\n     * curves in the path:\n     * <pre> [ point1, point1_startControl, point2_endControl, point2, point2_startControl, point3_endControl, point3, ... pointN_endControl, pointN ]</pre>\n     *\n     * @method cubicBezierPath\n     * @param {Vertex[]} path - The cubic bezier path as described above.\n     * @param {string} color - The CSS colot to draw the path with.\n     * @param {number=} lineWidth - (optional) The line width to use; default is 1.\n     * @return {void}\n     * @instance\n     * @memberof drawutils\n     */\n    cubicBezierPath(path, color, lineWidth) {\n        // NOT YET IMPLEMENTED\n    }\n    /**\n     * Draw the given handle and handle point (used to draw interactive Bézier curves).\n     *\n     * The colors for this are fixed and cannot be specified.\n     *\n     * @method handle\n     * @param {Vertex} startPoint - The start of the handle.\n     * @param {Vertex} endPoint - The end point of the handle.\n     * @return {void}\n     * @instance\n     * @memberof drawutils\n     */\n    handle(startPoint, endPoint) {\n        // NOT YET IMPLEMENTED\n    }\n    /**\n     * Draw a handle line (with a light grey).\n     *\n     * @method handleLine\n     * @param {Vertex} startPoint - The start point to draw the handle at.\n     * @param {Vertex} endPoint - The end point to draw the handle at.\n     * @return {void}\n     * @instance\n     * @memberof drawutils\n     */\n    handleLine(startPoint, endPoint) {\n        // NOT YET IMPLEMENTED\n    }\n    /**\n     * Draw a 1x1 dot with the specified (CSS-) color.\n     *\n     * @method dot\n     * @param {Vertex} p - The position to draw the dot at.\n     * @param {string} color - The CSS color to draw the dot with.\n     * @return {void}\n     * @instance\n     * @memberof drawutils\n     */\n    dot(p, color) {\n        // NOT YET IMPLEMENTED\n    }\n    /**\n     * Draw the given point with the specified (CSS-) color and radius 3.\n     *\n     * @method point\n     * @param {Vertex} p - The position to draw the point at.\n     * @param {string} color - The CSS color to draw the point with.\n     * @return {void}\n     * @instance\n     * @memberof drawutils\n     */\n    point(p, color) {\n        // NOT YET IMPLEMENTED\n    }\n    /**\n     * Draw a circle with the specified (CSS-) color and radius.<br>\n     * <br>\n     * Note that if the x- and y- scales are different the result will be an ellipse rather than a circle.\n     *\n     * @method circle\n     * @param {Vertex} center - The center of the circle.\n     * @param {number} radius - The radius of the circle.\n     * @param {string} color - The CSS color to draw the circle with.\n     * @param {number=} lineWidth - (optional) The line width to use; default is 1.\n     * @return {void}\n     * @instance\n     * @memberof drawutils\n     */\n    circle(center, radius, color, lineWidth) {\n        // NOT YET IMPLEMENTED\n    }\n    /**\n     * Draw a circular arc (section of a circle) with the given CSS color.\n     *\n     * @method circleArc\n     * @param {Vertex} center - The center of the circle.\n     * @param {number} radius - The radius of the circle.\n     * @param {number} startAngle - The angle to start at.\n     * @param {number} endAngle - The angle to end at.\n     * @param {string} color - The CSS color to draw the circle with.\n     * @return {void}\n     * @instance\n     * @memberof drawutils\n     */\n    circleArc(center, radius, startAngle, endAngle, color, lineWidth) {\n        // NOT YET IMPLEMENTED\n    }\n    /**\n     * Draw an ellipse with the specified (CSS-) color and thw two radii.\n     *\n     * @method ellipse\n     * @param {Vertex} center - The center of the ellipse.\n     * @param {number} radiusX - The radius of the ellipse.\n     * @param {number} radiusY - The radius of the ellipse.\n     * @param {string} color - The CSS color to draw the ellipse with.\n     * @param {number=} lineWidth - (optional) The line width to use; default is 1.\n     * @param {number=} rotation - (optional, default=0) The rotation of the ellipse.\n     * @return {void}\n     * @instance\n     * @memberof drawutils\n     */\n    ellipse(center, radiusX, radiusY, color, lineWidth, rotation) {\n        // NOT YET IMPLEMENTED\n    }\n    /**\n     * Draw square at the given center, size and with the specified (CSS-) color.<br>\n     * <br>\n     * Note that if the x-scale and the y-scale are different the result will be a rectangle rather than a square.\n     *\n     * @method square\n     * @param {XYCords} center - The center of the square.\n     * @param {Vertex} size - The size of the square.\n     * @param {string} color - The CSS color to draw the square with.\n     * @param {number=} lineWidth - (optional) The line width to use; default is 1.\n     * @return {void}\n     * @instance\n     * @memberof drawutils\n     */\n    square(center, size, color, lineWidth) {\n        // NOT YET IMPLEMENTED\n    }\n    /**\n     * Draw a rectangle.\n     *\n     * @param {XYCoords} position - The upper left corner of the rectangle.\n     * @param {number} width - The width of the rectangle.\n     * @param {number} height - The height of the rectangle.\n     * @param {string} color - The color to use.\n     * @param {number=1} lineWidth - (optional) The line with to use (default is 1).\n     **/\n    rect(position, width, height, color, lineWidth) {\n        // NOT YET IMPLEMENTED\n    }\n    /**\n     * Draw a grid of horizontal and vertical lines with the given (CSS-) color.\n     *\n     * @method grid\n     * @param {Vertex} center - The center of the grid.\n     * @param {number} width - The total width of the grid (width/2 each to the left and to the right).\n     * @param {number} height - The total height of the grid (height/2 each to the top and to the bottom).\n     * @param {number} sizeX - The horizontal grid size.\n     * @param {number} sizeY - The vertical grid size.\n     * @param {string} color - The CSS color to draw the grid with.\n     * @return {void}\n     * @instance\n     * @memberof drawutils\n     */\n    grid(center, width, height, sizeX, sizeY, color) {\n        // NOT YET IMPLEMENTED\n    }\n    /**\n     * Draw a raster of crosshairs in the given grid.<br>\n     *\n     * This works analogue to the grid() function\n     *\n     * @method raster\n     * @param {Vertex} center - The center of the raster.\n     * @param {number} width - The total width of the raster (width/2 each to the left and to the right).\n     * @param {number} height - The total height of the raster (height/2 each to the top and to the bottom).\n     * @param {number} sizeX - The horizontal raster size.\n     * @param {number} sizeY - The vertical raster size.\n     * @param {string} color - The CSS color to draw the raster with.\n     * @return {void}\n     * @instance\n     * @memberof drawutils\n     */\n    raster(center, width, height, sizeX, sizeY, color) {\n        // NOT YET IMPLEMENTED\n    }\n    /**\n     * Draw a diamond handle (square rotated by 45°) with the given CSS color.\n     *\n     * It is an inherent featur of the handle functions that the drawn elements are not scaled and not\n     * distorted. So even if the user zooms in or changes the aspect ratio, the handles will be drawn\n     * as even shaped diamonds.\n     *\n     * @method diamondHandle\n     * @param {Vertex} center - The center of the diamond.\n     * @param {Vertex} size - The x/y-size of the diamond.\n     * @param {string} color - The CSS color to draw the diamond with.\n     * @return {void}\n     * @instance\n     * @memberof drawutils\n     */\n    diamondHandle(center, size, color) {\n        // NOT YET IMPLEMENTED\n    }\n    /**\n     * Draw a square handle with the given CSS color.<br>\n     * <br>\n     * It is an inherent featur of the handle functions that the drawn elements are not scaled and not\n     * distorted. So even if the user zooms in or changes the aspect ratio, the handles will be drawn\n     * as even shaped squares.\n     *\n     * @method squareHandle\n     * @param {Vertex} center - The center of the square.\n     * @param {Vertex} size - The x/y-size of the square.\n     * @param {string} color - The CSS color to draw the square with.\n     * @return {void}\n     * @instance\n     * @memberof drawutils\n     */\n    squareHandle(center, size, color) {\n        // NOT YET IMPLEMENTED\n    }\n    /**\n     * Draw a circle handle with the given CSS color.<br>\n     * <br>\n     * It is an inherent featur of the handle functions that the drawn elements are not scaled and not\n     * distorted. So even if the user zooms in or changes the aspect ratio, the handles will be drawn\n     * as even shaped circles.\n     *\n     * @method circleHandle\n     * @param {Vertex} center - The center of the circle.\n     * @param {number} radius - The radius of the circle.\n     * @param {string} color - The CSS color to draw the circle with.\n     * @return {void}\n     * @instance\n     * @memberof drawutils\n     */\n    circleHandle(center, size, color) {\n        // NOT YET IMPLEMENTED\n    }\n    /**\n     * Draw a crosshair with given radius and color at the given position.<br>\n     * <br>\n     * Note that the crosshair radius will not be affected by scaling.\n     *\n     * @method crosshair\n     * @param {XYCoords} center - The center of the crosshair.\n     * @param {number} radius - The radius of the crosshair.\n     * @param {string} color - The CSS color to draw the crosshair with.\n     * @param {number=0.5} lineWidth - (optional, default=0.5) The line width to use.\n     * @return {void}\n     * @instance\n     * @memberof drawutils\n     */\n    crosshair(center, radius, color, lineWidth) {\n        // NOT YET IMPLEMENTED\n    }\n    /**\n     * Draw a cross with diagonal axes with given radius, color and lineWidth at the given position.<br>\n     * <br>\n     * Note that the x's radius will not be affected by scaling.\n     *\n     * @method crosshair\n     * @param {XYCoords} center - The center of the crosshair.\n     * @param {number} radius - The radius of the crosshair.\n     * @param {string} color - The CSS color to draw the crosshair with.\n     * @param {number=1} lineWidth - (optional, default=1.0) The line width to use.\n     * @return {void}\n     * @instance\n     * @memberof drawutils\n     */\n    cross(center, radius, color, lineWidth) {\n        // NOT YET IMPLEMENTED\n    }\n    /**\n     * Draw a polygon.\n     *\n     * @method polygon\n     * @param {Polygon} polygon - The polygon to draw.\n     * @param {string} color - The CSS color to draw the polygon with.\n     * @return {void}\n     * @instance\n     * @memberof drawutils\n     */\n    polygon(polygon, color, lineWidth) {\n        const vertices = new Float32Array(polygon.vertices.length * 3);\n        for (var i = 0; i < polygon.vertices.length; i++) {\n            vertices[i * 3 + 0] = this._x2rel(polygon.vertices[i].x);\n            vertices[i * 3 + 1] = this._y2rel(polygon.vertices[i].y);\n            vertices[i * 3 + 2] = this._zindex;\n        }\n        this._zindex += 0.001;\n        //console.log( vertices );\n        // Create an empty buffer object\n        // const vertex_buffer = this.gl.createBuffer();\n        // Bind appropriate array buffer to it\n        this.gl.bindBuffer(this.gl.ARRAY_BUFFER, this.vertex_buffer);\n        // Pass the vertex data to the buffer\n        this.gl.bufferData(this.gl.ARRAY_BUFFER, vertices, this.gl.STATIC_DRAW);\n        // Bind vertex buffer object\n        // this.gl.bindBuffer(this.gl.ARRAY_BUFFER, vertex_buffer);\n        // Get the attribute location\n        var coord = this.gl.getAttribLocation(this._program, \"position\");\n        // Point an attribute to the currently bound VBO\n        this.gl.vertexAttribPointer(coord, 3, this.gl.FLOAT, false, 0, 0);\n        // Enable the attribute\n        this.gl.enableVertexAttribArray(coord);\n        // Unbind the buffer?\n        this.gl.bindBuffer(this.gl.ARRAY_BUFFER, null);\n        // Set the view port\n        this.gl.viewport(0, 0, this.gl.canvas.width, this.gl.canvas.height);\n        let uRotationVector = this.gl.getUniformLocation(this._program, \"uRotationVector\");\n        // let radians = currentAngle * Math.PI / 180.0;\n        let currentRotation = [0.0, 1.0];\n        //currentRotation[0] = Math.sin(radians);\n        //currentRotation[1] = Math.cos(radians);\n        this.gl.uniform2fv(uRotationVector, currentRotation);\n        // Draw the polygon\n        this.gl.drawArrays(this.gl.TRIANGLE_FAN, 0, vertices.length / 3);\n        // POINTS, LINE_STRIP, LINE_LOOP, LINES,\n        // TRIANGLE_STRIP,TRIANGLE_FAN, TRIANGLES\n    }\n    /**\n     * Draw a polygon line (alternative function to the polygon).\n     *\n     * @method polyline\n     * @param {Vertex[]} vertices - The polygon vertices to draw.\n     * @param {boolan}   isOpen   - If true the polyline will not be closed at its end.\n     * @param {string}   color    - The CSS color to draw the polygon with.\n     * @param {number=}  lineWidth - (optional) The line width to use; default is 1.\n     * @return {void}\n     * @instance\n     * @memberof drawutils\n     */\n    polyline(vertices, isOpen, color, lineWidth) {\n        // NOT YET IMPLEMENTED\n    }\n    /**\n     * Draw a text at the given relative position.\n     *\n     * @method text\n     * @param {string} text - The text to draw.\n     * @param {number} x - The x-position to draw the text at.\n     * @param {number} y - The y-position to draw the text at.\n     * @param {string=} options.color - The Color to use.\n     * @param {string=} options.fontFamily - The font family to use.\n     * @param {number=} options.fontSize - The font size (in pixels) to use.\n     * @param {FontStyle=} options.fontStyle - The font style to use.\n     * @param {FontWeight=} options.fontWeight - The font weight to use.\n     * @param {number=} options.lineHeight - The line height (in pixels) to use.\n     * @param {number=} options.rotation - The (optional) rotation in radians.\n     * @param {string=} options.textAlign - The text align to use. According to the specifiactions (https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/textAlign) valid values are `\"left\" || \"right\" || \"center\" || \"start\" || \"end\"`.\n     * @return {void}\n     * @instance\n     * @memberof drawutils\n     */\n    text(text, x, y, options) {\n        // NOT YET IMPLEMENTED\n    }\n    /**\n     * Draw a non-scaling text label at the given position.\n     *\n     * @method label\n     * @param {string} text - The text to draw.\n     * @param {number} x - The x-position to draw the text at.\n     * @param {number} y - The y-position to draw the text at.\n     * @param {number=} rotation - The (aoptional) rotation in radians.\n     * @param {string=\"black\"} color - The color to use (default is black).\n     * @return {void}\n     * @instance\n     * @memberof drawutils\n     */\n    label(text, x, y, rotation, color) {\n        // NOT YET IMPLEMENTED\n    }\n    /**\n     * Draw an SVG-like path given by the specified path data.\n     *\n     * @method path\n     * @param {SVGPathData} pathData - An array of path commands and params.\n     * @param {string=null} color - (optional) The color to draw this path with (default is null).\n     * @param {number=1} lineWidth - (optional) the line width to use (default is 1).\n     * @param {boolean=false} options.inplace - (optional) If set to true then path transforamtions (scale and translate) will be done in-place in the array. This can boost the performance.\n     * @instance\n     * @memberof drawutils\n     * @return {R} An instance representing the drawn path.\n     */\n    path(pathData, color, lineWidth, options) {\n        // NOT YET IMPLEMENTED\n    }\n    /**\n     * Due to gl compatibility there is a generic 'clear' function required\n     * to avoid accessing the context object itself directly.\n     *\n     * This function just fills the whole canvas with a single color.\n     *\n     * @param {string} color - The color to clear with.\n     **/\n    clear(color) {\n        // NOT YET IMPLEMENTED\n        // if( typeof color == 'string' )\n        // color = Color.parse(color); // Color class does not yet exist in TS\n        // Clear the canvas\n        this.gl.clearColor(1.0, 1.0, 1.0, 1.0);\n        // Enable the depth test\n        this.gl.enable(this.gl.DEPTH_TEST);\n        // Clear the color and depth buffer\n        this.gl.clear(this.gl.COLOR_BUFFER_BIT | this.gl.DEPTH_BUFFER_BIT);\n    }\n}\n// Vertex shader source code\ndrawutilsgl.vertCode = `\n    precision mediump float;\n\n    attribute vec3 position;\n\n    uniform vec2 uRotationVector;\n\n    void main(void) {\n\tvec2 rotatedPosition = vec2(\n\t    position.x * uRotationVector.y +\n\t\tposition.y * uRotationVector.x,\n\t    position.y * uRotationVector.y -\n\t\tposition.x * uRotationVector.x\n\t);\n\n\tgl_Position = vec4(rotatedPosition, position.z, 1.0);\n    }`;\n// Fragment shader source code\ndrawutilsgl.fragCode = `\n    precision highp float;\n\n    void main(void) {\n\tgl_FragColor = vec4(0.0,0.75,1.0,1.0);\n    }`;\n/**\n * Some GL helper utils.\n **/\nclass GLU {\n    constructor(gl) {\n        this.gl = gl;\n    }\n    bufferData(verts) {\n        // Create an empty buffer object\n        var vbuffer = this.gl.createBuffer();\n        // Bind appropriate array buffer to it\n        this.gl.bindBuffer(this.gl.ARRAY_BUFFER, vbuffer);\n        // Pass the vertex data to the buffer\n        this.gl.bufferData(this.gl.ARRAY_BUFFER, verts, this.gl.STATIC_DRAW);\n        // Unbind the buffer\n        this.gl.bindBuffer(this.gl.ARRAY_BUFFER, null);\n        return vbuffer;\n    }\n    /*=================== Shaders ====================*/\n    compileShader(shaderCode, shaderType) {\n        // Create a vertex shader object\n        var shader = this.gl.createShader(shaderType);\n        // Attach vertex shader source code\n        this.gl.shaderSource(shader, shaderCode);\n        // Compile the vertex shader\n        this.gl.compileShader(shader);\n        const vertStatus = this.gl.getShaderParameter(shader, this.gl.COMPILE_STATUS);\n        if (!vertStatus) {\n            console.warn(\"Error in shader:\" + this.gl.getShaderInfoLog(shader));\n            this.gl.deleteShader(shader);\n            return null;\n        }\n        return shader;\n    }\n    makeProgram(vertShader, fragShader) {\n        // Create a shader program object to store\n        // the combined shader program\n        var program = this.gl.createProgram();\n        // Attach a vertex shader\n        this.gl.attachShader(program, vertShader);\n        // Attach a fragment shader\n        this.gl.attachShader(program, fragShader);\n        // Link both the programs\n        this.gl.linkProgram(program);\n        // Use the combined shader program object\n        this.gl.useProgram(program);\n        /*======= Do some cleanup ======*/\n        this.gl.detachShader(program, vertShader);\n        this.gl.detachShader(program, fragShader);\n        this.gl.deleteShader(vertShader);\n        this.gl.deleteShader(fragShader);\n        return program;\n    }\n}\n//# sourceMappingURL=drawgl.js.map","/**\n * @author    Ikaros Kappler\n * @date_init 2012-10-17 (Wrote a first version of this in that year).\n * @date      2018-04-03 (Refactored the code into a new class).\n * @modified  2018-04-28 Added some documentation.\n * @modified  2019-09-11 Added the scaleToCentroid(Number) function (used by the walking triangle demo).\n * @modified  2019-09-12 Added beautiful JSDoc compliable comments.\n * @modified  2019-11-07 Added to toSVG(options) function to make Triangles renderable as SVG.\n * @modified  2019-12-09 Fixed the determinant() function. The calculation was just wrong.\n * @modified  2020-03-16 (Corona times) Added the 'fromArray' function.\n * @modified  2020-03-17 Added the Triangle.toPolygon() function.\n * @modified  2020-03-17 Added proper JSDoc comments.\n * @modified  2020-03-25 Ported this class from vanilla-JS to Typescript.\n * @modified  2020-05-09 Added the new Circle class (ported to Typescript from the demos).\n * @modified  2020-05-12 Added getIncircularTriangle() function.\n * @modified  2020-05-12 Added getIncircle() function.\n * @modified  2020-05-12 Fixed the signature of getCircumcirle(). Was still a generic object.\n * @modified  2020-06-18 Added the `getIncenter` function.\n * @modified  2020-12-28 Added the `getArea` function.\n * @modified  2021-01-20 Added UID.\n * @modified  2021-01-22 Always updating circumcircle when retieving it.\n * @modified  2022-02-02 Added the `destroy` method.\n * @modified  2022-02-02 Cleared the `Triangle.toSVGString` function (deprecated). Use `drawutilssvg` instead.\n * @version   2.6.0\n *\n * @file Triangle\n * @fileoverview A simple triangle class: three vertices.\n * @public\n **/\nimport { Bounds } from \"./Bounds\";\nimport { Circle } from \"./Circle\";\nimport { Line } from \"./Line\";\nimport { Polygon } from \"./Polygon\";\nimport { UIDGenerator } from \"./UIDGenerator\";\nimport { Vertex } from \"./Vertex\";\nimport { geomutils } from \"./geomutils\";\n/**\n * @classdesc A triangle class for triangulations.\n *\n * The class was written for a Delaunay trinagulation demo so it might\n * contain some strange and unexpected functions.\n *\n * @requires Bounds\n * @requires Circle\n * @requires Line\n * @requires Vertex\n * @requires Polygon\n * @requires SVGSerializale\n * @requires UID\n * @requires UIDGenerator\n * @requires geomutils\n *\n */\nexport class Triangle {\n    /**\n     * The constructor.\n     *\n     * @constructor\n     * @name Triangle\n     * @param {Vertex} a - The first vertex of the triangle.\n     * @param {Vertex} b - The second vertex of the triangle.\n     * @param {Vertex} c - The third vertex of the triangle.\n     **/\n    constructor(a, b, c) {\n        /**\n         * Required to generate proper CSS classes and other class related IDs.\n         **/\n        this.className = \"Triangle\";\n        this.uid = UIDGenerator.next();\n        this.a = a;\n        this.b = b;\n        this.c = c;\n        this.calcCircumcircle();\n    }\n    /**\n     * Create a new triangle from the given array of vertices.\n     *\n     * The array must have at least three vertices, otherwise an error will be raised.\n     * This function will not create copies of the vertices.\n     *\n     * @method fromArray\n     * @static\n     * @param {Array<Vertex>} arr - The required array with at least three vertices.\n     * @memberof Vertex\n     * @return {Triangle}\n     **/\n    static fromArray(arr) {\n        if (arr.length < 3)\n            throw `Cannot create triangle from array with less than three vertices (${arr.length})`;\n        return new Triangle(arr[0], arr[1], arr[2]);\n    }\n    /**\n     * Get the area of this triangle. The returned area is never negative.\n     *\n     * If you are interested in the signed area, please consider using the\n     * `Triangle.utils.signedArea` helper function. This method just returns\n     * the absolute value of the signed area.\n     *\n     * @method getArea\n     * @instance\n     * @memberof Triangle\n     * @return {number} The non-negative area of this triangle.\n     */\n    getArea() {\n        return Math.abs(Triangle.utils.signedArea(this.a.x, this.a.y, this.b.x, this.b.y, this.c.x, this.c.y));\n    }\n    /**\n     * Get the centroid of this triangle.\n     *\n     * The centroid is the average midpoint for each side.\n     *\n     * @method getCentroid\n     * @return {Vertex} The centroid\n     * @instance\n     * @memberof Triangle\n     **/\n    getCentroid() {\n        return new Vertex((this.a.x + this.b.x + this.c.x) / 3, (this.a.y + this.b.y + this.c.y) / 3);\n    }\n    /**\n     * Scale the triangle towards its centroid.\n     *\n     * @method scaleToCentroid\n     * @param {number} - The scale factor to use. That can be any scalar.\n     * @return {Triangle} this (for chaining)\n     * @instance\n     * @memberof Triangle\n     */\n    scaleToCentroid(factor) {\n        let centroid = this.getCentroid();\n        this.a.scale(factor, centroid);\n        this.b.scale(factor, centroid);\n        this.c.scale(factor, centroid);\n        return this;\n    }\n    /**\n     * Get the circumcircle of this triangle.\n     *\n     * The circumcircle is that unique circle on which all three\n     * vertices of this triangle are located on.\n     *\n     * Please note that for performance reasons any changes to vertices will not reflect in changes\n     * of the circumcircle (center or radius). Please call the calcCirumcircle() function\n     * after triangle vertex changes.\n     *\n     * @method getCircumcircle\n     * @return {Object} - { center:Vertex, radius:float }\n     * @instance\n     * @memberof Triangle\n     */\n    getCircumcircle() {\n        // if( !this.center || !this.radius )\n        this.calcCircumcircle();\n        return new Circle(this.center.clone(), this.radius);\n    }\n    /**\n     * Check if this triangle and the passed triangle share an\n     * adjacent edge.\n     *\n     * For edge-checking Vertex.equals is used which uses an\n     * an epsilon for comparison.\n     *\n     * @method isAdjacent\n     * @param {Triangle} tri - The second triangle to check adjacency with.\n     * @return {boolean} - True if this and the passed triangle have at least one common edge.\n     * @instance\n     * @memberof Triangle\n     */\n    isAdjacent(tri) {\n        var a = this.a.equals(tri.a) || this.a.equals(tri.b) || this.a.equals(tri.c);\n        var b = this.b.equals(tri.a) || this.b.equals(tri.b) || this.b.equals(tri.c);\n        var c = this.c.equals(tri.a) || this.c.equals(tri.b) || this.c.equals(tri.c);\n        return (a && b) || (a && c) || (b && c);\n    }\n    /**\n     * Get that vertex of this triangle (a,b,c) that is not vert1 nor vert2 of\n     * the passed two.\n     *\n     * @method getThirdVertex\n     * @param {Vertex} vert1 - The first vertex.\n     * @param {Vertex} vert2 - The second vertex.\n     * @return {Vertex} - The third vertex of this triangle that makes up the whole triangle with vert1 and vert2.\n     * @instance\n     * @memberof Triangle\n     */\n    getThirdVertex(vert1, vert2) {\n        if ((this.a.equals(vert1) && this.b.equals(vert2)) || (this.a.equals(vert2) && this.b.equals(vert1)))\n            return this.c;\n        if ((this.b.equals(vert1) && this.c.equals(vert2)) || (this.b.equals(vert2) && this.c.equals(vert1)))\n            return this.a;\n        //if( this.c.equals(vert1) && this.a.equals(vert2) || this.c.equals(vert2) && this.a.equals(vert1) )\n        return this.b;\n    }\n    /**\n     * Re-compute the circumcircle of this triangle (if the vertices\n     * have changed).\n     *\n     * The circumcenter and radius are stored in this.center and\n     * this.radius. There is a third result: radius_squared (for internal computations).\n     *\n     * @method calcCircumcircle\n     * @return void\n     * @instance\n     * @memberof Triangle\n     */\n    calcCircumcircle() {\n        // From\n        //    http://www.exaflop.org/docs/cgafaq/cga1.html\n        const A = this.b.x - this.a.x;\n        const B = this.b.y - this.a.y;\n        const C = this.c.x - this.a.x;\n        const D = this.c.y - this.a.y;\n        const E = A * (this.a.x + this.b.x) + B * (this.a.y + this.b.y);\n        const F = C * (this.a.x + this.c.x) + D * (this.a.y + this.c.y);\n        const G = 2.0 * (A * (this.c.y - this.b.y) - B * (this.c.x - this.b.x));\n        let dx, dy;\n        if (Math.abs(G) < Triangle.EPSILON) {\n            // Collinear - find extremes and use the midpoint\n            const bounds = this.bounds();\n            this.center = new Vertex((bounds.min.x + bounds.max.x) / 2, (bounds.min.y + bounds.max.y) / 2);\n            dx = this.center.x - bounds.min.x;\n            dy = this.center.y - bounds.min.y;\n        }\n        else {\n            const cx = (D * E - B * F) / G;\n            const cy = (A * F - C * E) / G;\n            this.center = new Vertex(cx, cy);\n            dx = this.center.x - this.a.x;\n            dy = this.center.y - this.a.y;\n        }\n        this.radius_squared = dx * dx + dy * dy;\n        this.radius = Math.sqrt(this.radius_squared);\n    } // END calcCircumcircle\n    /**\n     * Check if the passed vertex is inside this triangle's\n     * circumcircle.\n     *\n     * @method inCircumcircle\n     * @param {Vertex} v - The vertex to check.\n     * @return {boolean}\n     * @instance\n     * @memberof Triangle\n     */\n    inCircumcircle(v) {\n        const dx = this.center.x - v.x;\n        const dy = this.center.y - v.y;\n        const dist_squared = dx * dx + dy * dy;\n        return dist_squared <= this.radius_squared;\n    }\n    /**\n     * Get the rectangular bounds for this triangle.\n     *\n     * @method bounds\n     * @return {Bounds} - The min/max bounds of this triangle.\n     * @instance\n     * @memberof Triangle\n     */\n    bounds() {\n        return new Bounds(new Vertex(Triangle.utils.min3(this.a.x, this.b.x, this.c.x), Triangle.utils.min3(this.a.y, this.b.y, this.c.y)), new Vertex(Triangle.utils.max3(this.a.x, this.b.x, this.c.x), Triangle.utils.max3(this.a.y, this.b.y, this.c.y)));\n    }\n    /**\n     * Convert this triangle to a polygon instance.\n     *\n     * Plase note that this conversion does not perform a deep clone.\n     *\n     * @method toPolygon\n     * @return {Polygon} A new polygon representing this triangle.\n     * @instance\n     * @memberof Triangle\n     **/\n    toPolygon() {\n        return new Polygon([this.a, this.b, this.c]);\n    }\n    /**\n     * Get the determinant of this triangle.\n     *\n     * @method determinant\n     * @return {number} - The determinant (float).\n     * @instance\n     * @memberof Triangle\n     */\n    determinant() {\n        // (b.y - a.y)*(c.x - b.x) - (c.y - b.y)*(b.x - a.x);\n        return (this.b.y - this.a.y) * (this.c.x - this.b.x) - (this.c.y - this.b.y) * (this.b.x - this.a.x);\n    }\n    /**\n     * Checks if the passed vertex (p) is inside this triangle.\n     *\n     * Note: matrix determinants rock.\n     *\n     * @method containsPoint\n     * @param {Vertex} p - The vertex to check.\n     * @return {boolean}\n     * @instance\n     * @memberof Triangle\n     */\n    containsPoint(p) {\n        return Triangle.utils.pointIsInTriangle(p.x, p.y, this.a.x, this.a.y, this.b.x, this.b.y, this.c.x, this.c.y);\n    }\n    /**\n     * Get that inner triangle which defines the maximal incircle.\n     *\n     * @return {Triangle} The triangle of those points in this triangle that define the incircle.\n     */\n    getIncircularTriangle() {\n        const lineA = new Line(this.a, this.b);\n        const lineB = new Line(this.b, this.c);\n        const lineC = new Line(this.c, this.a);\n        const bisector1 = geomutils.nsectAngle(this.b, this.a, this.c, 2)[0]; // bisector of first angle (in b)\n        const bisector2 = geomutils.nsectAngle(this.c, this.b, this.a, 2)[0]; // bisector of second angle (in c)\n        // Cast to non-null here because we know there _is_ an intersection\n        const intersection = bisector1.intersection(bisector2);\n        // Find the closest points on one of the polygon lines (all have same distance by construction)\n        const circleIntersA = lineA.getClosestPoint(intersection);\n        const circleIntersB = lineB.getClosestPoint(intersection);\n        const circleIntersC = lineC.getClosestPoint(intersection);\n        return new Triangle(circleIntersA, circleIntersB, circleIntersC);\n    }\n    /**\n     * Get the incircle of this triangle. That is the circle that touches each side\n     * of this triangle in exactly one point.\n     *\n     * Note this just calls getIncircularTriangle().getCircumcircle()\n     *\n     * @return {Circle} The incircle of this triangle.\n     */\n    getIncircle() {\n        return this.getIncircularTriangle().getCircumcircle();\n    }\n    /**\n     * Get the incenter of this triangle (which is the center of the circumcircle).\n     *\n     * Note: due to performance reasonst the incenter is buffered inside the triangle because\n     *       computing it is relatively expensive. If a, b or c have changed you should call the\n     *       calcCircumcircle() function first, otherwise you might get wrong results.\n     * @return Vertex The incenter of this triangle.\n     **/\n    getIncenter() {\n        if (!this.center || !this.radius)\n            this.calcCircumcircle();\n        return this.center.clone();\n    }\n    /**\n     * Converts this triangle into a human-readable string.\n     *\n     * @method toString\n     * @return {string}\n     * @instance\n     * @memberof Triangle\n     */\n    toString() {\n        return \"{ a : \" + this.a.toString() + \", b : \" + this.b.toString() + \", c : \" + this.c.toString() + \"}\";\n    }\n    /**\n     * This function should invalidate any installed listeners and invalidate this object.\n     * After calling this function the object might not hold valid data any more and\n     * should not be used.\n     */\n    destroy() {\n        this.a.destroy();\n        this.b.destroy();\n        this.c.destroy();\n        this.isDestroyed = true;\n    }\n}\n/**\n * An epsilon for comparison.\n * This should be the same epsilon as in Vertex.\n *\n * @private\n **/\nTriangle.EPSILON = 1.0e-6;\nTriangle.utils = {\n    // Used in the bounds() function.\n    max3(a, b, c) {\n        return a >= b && a >= c ? a : b >= a && b >= c ? b : c;\n    },\n    min3(a, b, c) {\n        return a <= b && a <= c ? a : b <= a && b <= c ? b : c;\n    },\n    signedArea(p0x, p0y, p1x, p1y, p2x, p2y) {\n        return 0.5 * (-p1y * p2x + p0y * (-p1x + p2x) + p0x * (p1y - p2y) + p1x * p2y);\n    },\n    /**\n     * Used by the containsPoint() function.\n     *\n     * @private\n     **/\n    pointIsInTriangle(px, py, p0x, p0y, p1x, p1y, p2x, p2y) {\n        //\n        // Point-in-Triangle test found at\n        //   http://stackoverflow.com/questions/2049582/how-to-determine-a-point-in-a-2d-triangle\n        // var area : number = 1/2*(-p1y*p2x + p0y*(-p1x + p2x) + p0x*(p1y - p2y) + p1x*p2y);\n        var area = Triangle.utils.signedArea(p0x, p0y, p1x, p1y, p2x, p2y);\n        var s = (1 / (2 * area)) * (p0y * p2x - p0x * p2y + (p2y - p0y) * px + (p0x - p2x) * py);\n        var t = (1 / (2 * area)) * (p0x * p1y - p0y * p1x + (p0y - p1y) * px + (p1x - p0x) * py);\n        return s > 0 && t > 0 && 1 - s - t > 0;\n    }\n};\n//# sourceMappingURL=Triangle.js.map","/**\n * @author   Ikaros Kappler\n * @date     2019-02-03\n * @modified 2021-03-01 Added `wrapMax` function.\n * @version  1.1.0\n **/\nimport { Line } from \"./Line\";\nimport { Triangle } from \"./Triangle\";\n/**\n * A collection of usefull geometry utilities.\n *\n * @global\n **/\nexport const geomutils = {\n    /**\n     * Compute the n-section of the angle – described as a triangle (A,B,C) – in point A.\n     *\n     * @param {Vertex} pA - The first triangle point.\n     * @param {Vertex} pB - The second triangle point.\n     * @param {Vertex} pC - The third triangle point.\n     * @param {number} n - The number of desired angle sections (example: 2 means the angle will be divided into two sections,\n     *                      means an returned array with length 1, the middle line).\n     *\n     * @return {Line[]} An array of n-1 lines secting the given angle in point A into n equal sized angle sections. The lines' first vertex is A.\n     */\n    nsectAngle(pA, pB, pC, n) {\n        const triangle = new Triangle(pA, pB, pC);\n        const lineAB = new Line(pA, pB);\n        const lineAC = new Line(pA, pC);\n        // Compute the difference; this is the angle between AB and AC\n        var insideAngle = lineAB.angle(lineAC);\n        // We want the inner angles of the triangle, not the outer angle;\n        //   which one is which depends on the triangle 'direction'\n        const clockwise = triangle.determinant() > 0;\n        // For convenience convert the angle [-PI,PI] to [0,2*PI]\n        if (insideAngle < 0)\n            insideAngle = 2 * Math.PI + insideAngle;\n        if (!clockwise)\n            insideAngle = (2 * Math.PI - insideAngle) * (-1);\n        // Scale the rotated lines to the max leg length (looks better)\n        const lineLength = Math.max(lineAB.length(), lineAC.length());\n        const scaleFactor = lineLength / lineAB.length();\n        var result = [];\n        for (var i = 1; i < n; i++) {\n            // Compute the i-th inner sector line\n            result.push(new Line(pA, pB.clone().rotate((-i * (insideAngle / n)), pA)).scale(scaleFactor));\n        }\n        return result;\n    },\n    /**\n     * Wrap the value (e.g. an angle) into the given range of [0,max).\n     *\n     * @name wrapMax\n     * @param {number} x - The value to wrap.\n     * @param {number} max - The max bound to use for the range.\n     * @return {number} The wrapped value inside the range [0,max).\n     */\n    wrapMax(x, max) {\n        // Found at\n        //    https://stackoverflow.com/questions/4633177/c-how-to-wrap-a-float-to-the-interval-pi-pi\n        return (max + (x % max)) % max;\n    },\n    /**\n     * Wrap the value (e.g. an angle) into the given range of [min,max).\n     *\n     * @name wrapMinMax\n     * @param {number} x - The value to wrap.\n     * @param {number} min - The min bound to use for the range.\n     * @param {number} max - The max bound to use for the range.\n     * @return {number} The wrapped value inside the range [min,max).\n     */\n    // Currently un-used\n    wrapMinMax(x, min, max) {\n        return min + geomutils.wrapMax(x - min, max - min);\n    }\n};\n//# sourceMappingURL=geomutils.js.map","/**\n * @author   Ikaros Kappler\n * @date     2018-11-28\n * @modified 2018-12-09 Added the utils: baseLog(Number,Number) and mapRasterScale(Number,Number).\n * @version  1.0.1\n *\n * @file Grid\n * @fileoverview Note that the PlotBoilerplate already has a Grid instance member. The Grid is not meant\n *               to be added to the canvas as a drawable as it encapsulates more an abstract concept of the canvas\n *               rather than a drawable object.\n * @public\n **/\n/**\n * @classdesc A grid class with vertical and horizontal lines (or a raster).\n *\n * Note that the PlotBoilerplate already has a Grid instance member. The Grid is not meant\n * to be added to the canvas as a drawable as it encapsulates more an abstract concept of the canvas\n * rather than a drawable object.\n *\n * @requires Vertex\n */\nexport class Grid {\n    /**\n     * The constructor.\n     *\n     * @constructor\n     * @name Grid\n     * @param {Vertex} center - The offset of the grid (default is [0,0]).\n     * @param {Vertex} size   - The x- and y-size of the grid.\n     **/\n    constructor(center, size) {\n        this.center = center;\n        this.size = size;\n    }\n    ;\n}\n/**\n * @memberof Grid\n **/\nGrid.utils = {\n    /**\n     * Calculate the logarithm of the given number (num) to a given base.<br>\n     * <br>\n     * This function returns the number l with<br>\n     *  <pre>num == Math.pow(base,l)</pre>\n     *\n     * @member baseLog\n     * @function\n     * @memberof Grid\n     * @inner\n     * @param {number} base - The base to calculate the logarithm to.\n     * @param {number} num  - The number to calculate the logarithm for.\n     * @return {number} <pre>log(base)/log(num)</pre>\n     **/\n    baseLog: (base, num) => { return Math.log(base) / Math.log(num); },\n    /**\n     * Calculate the raster scale for a given logarithmic mapping.<br>\n     * <br>\n     * Example (with adjustFactor=2):<br>\n     * <pre>\n     * If scale is 4.33, then the mapping is 1/2 (because 2^2 <= 4.33 <= 2^3)<br>\n     * If scale is 0.33, then the mapping is 2 because (2^(1/2) >= 0.33 >= 2^(1/4)\n     * </pre>\n     *\n     * @member mapRasterScale\n     * @function\n     * @memberof Grid\n     * @inner\n     * @param {number} adjustFactor The base for the logarithmic raster scaling when zoomed.\n     * @param {number} scale        The currently used scale factor.\n     * @return {number}\n     **/\n    mapRasterScale: (adjustFactor, scale) => {\n        var gf = 1.0;\n        if (scale >= 1) {\n            gf = Math.abs(Math.floor(1 / Grid.utils.baseLog(adjustFactor, scale)));\n            gf = 1 / Math.pow(adjustFactor, gf);\n        }\n        else {\n            gf = Math.abs(Math.floor(Grid.utils.baseLog(1 / adjustFactor, 1 / (scale + 1))));\n        }\n        return gf;\n    }\n};\n//# sourceMappingURL=Grid.js.map","/**\n * @author   Ikaros Kappler\n * @date     2018-11-11 (Alaaf)\n * @modified 2020-03-28 Ported this class from vanilla-JS to Typescript.\n * @modified 2020-07-28 Changed the `delete` key code from 8 to 46.\n * @modified 2020-10-04 Changed `window` to `globalThis`.\n * @modified 2020-10-04 Added extended JSDoc.\n * @modified 2022-02-02 Added the `destroy` method.\n * @version  1.1.0\n *\n * @file KeyHandler\n * @public\n **/\n/**\n * @classdesc A generic key handler.\n *\n * Example\n * =======\n * @example\n *      // Javascript\n *\tnew KeyHandler( { trackAll : true } )\n *\t    .down('enter',function() { console.log('ENTER was hit.'); } )\n *\t    .press('enter',function() { console.log('ENTER was pressed.'); } )\n *\t    .up('enter',function() { console.log('ENTER was released.'); } )\n *\n *          .down('e',function() { console.log('e was hit. shift is pressed?',keyHandler.isDown('shift')); } )\n *\n *\t    .up('windows',function() { console.log('windows was released.'); } )\n *\t;\n */\nexport class KeyHandler {\n    /**\n     * The constructor.\n     *\n     * @constructor\n     * @instance\n     * @memberof KeyHandler\n     * @param {HTMLElement} options.element (optional) The HTML element to listen on; if null then 'window' will be used.\n     * @param {boolean} options.trackAll (optional) Set to true if you want to keep track of _all_ keys (keyStatus).\n     **/\n    constructor(options) {\n        this.downListeners = [];\n        this.pressListeners = [];\n        this.upListeners = [];\n        this.keyStates = {};\n        options = options || {};\n        this.element = options.element ? options.element : globalThis;\n        this.downListeners = [];\n        this.pressListeners = [];\n        this.upListeners = [];\n        this.keyStates = [];\n        // This could be made configurable in a later version. It allows to\n        // keep track of the key status no matter if there are any listeners\n        // on the key or not.\n        this.trackAllKeys = options.trackAll || false;\n        // Install the listeners\n        this.installListeners();\n    }\n    /**\n     * A helper function to fire key events from this KeyHandler.\n     *\n     * @param {KeyboardEvent} event - The key event to fire.\n     * @param {Array<XKeyListener>} listener - The listeners to fire to.\n     */\n    fireEvent(event, listeners) {\n        let hasListener = false;\n        for (var i in listeners) {\n            var lis = listeners[i];\n            if (lis.keyCode != event.keyCode)\n                continue;\n            lis.listener(event);\n            hasListener = true;\n        }\n        return hasListener;\n    }\n    /**\n     * Internal function to fire a new keydown event to all listeners.\n     * You should not call this function on your own unless you know what you do.\n     *\n     * @name fireDownEvent\n     * @memberof KeyHandler\n     * @instance\n     * @private\n     * @param {KeyboardEvent} e\n     * @param {KeyHandler} handler\n     * @return {void}\n     */\n    fireDownEvent(e, handler) {\n        if (handler.fireEvent(e, handler.downListeners) || handler.trackAllKeys) {\n            // Down event has listeners. Update key state.\n            handler.keyStates[e.keyCode] = \"down\";\n        }\n    }\n    /**\n     * Internal function to fire a new keypress event to all listeners.\n     * You should not call this function on your own unless you know what you do.\n     *\n     * @name firePressEvent\n     * @memberof KeyHandler\n     * @instance\n     * @private\n     * @param {KeyboardEvent} e\n     * @param {KeyHandler} handler\n     * @return void\n     */\n    firePressEvent(e, handler) {\n        handler.fireEvent(e, handler.pressListeners);\n    }\n    /**\n     * Internal function to fire a new keyup event to all listeners.\n     * You should not call this function on your own unless you know what you do.\n     *\n     * @name fireUpEvent\n     * @memberof KeyHandler\n     * @instance\n     * @private\n     * @param {KeyboardEvent} e\n     * @param {KeyHandler} handler\n     * @return {void}\n     */\n    fireUpEvent(e, handler) {\n        if (handler.fireEvent(e, handler.upListeners) || handler.trackAllKeys) {\n            // Up event has listeners. Clear key state.\n            delete handler.keyStates[e.keyCode];\n        }\n    }\n    /**\n     * Resolve the key/name code.\n     */\n    static key2code(key) {\n        if (typeof key == \"number\")\n            return key;\n        if (typeof key != \"string\")\n            throw \"Unknown key name or key type (should be a string or integer): \" + key;\n        if (KeyHandler.KEY_CODES[key])\n            return KeyHandler.KEY_CODES[key];\n        throw \"Unknown key (cannot resolve key code): \" + key;\n    }\n    /**\n     * Install the required listeners into the initially passed element.\n     *\n     * By default the listeners are installed into the root element specified on\n     * construction (or 'window').\n     */\n    installListeners() {\n        var _self = this;\n        this.element.addEventListener(\"keydown\", (this._keyDownListener = (e) => {\n            _self.fireDownEvent(e, _self);\n        }));\n        this.element.addEventListener(\"keypress\", (this._keyPressListener = (e) => {\n            _self.firePressEvent(e, _self);\n        }));\n        this.element.addEventListener(\"keyup\", (this._keyUpListener = (e) => {\n            _self.fireUpEvent(e, _self);\n        }));\n    }\n    /**\n     *  Remove all installed event listeners from the underlying element.\n     */\n    releaseListeners() {\n        this.element.removeEventListener(\"keydown\", this._keyDownListener);\n        this.element.removeEventListener(\"keypress\", this._keyPressListener);\n        this.element.removeEventListener(\"keyup\", this._keyUpListener);\n    }\n    /**\n     * Listen for key down. This function allows chaining.\n     *\n     * Example: new KeyHandler().down('enter',function() {console.log('Enter hit.')});\n     *\n     * @name down\n     * @memberof KeyHandler\n     * @instance\n     * @param {string|number} key -  Any key identifier, key code or one from the KEY_CODES list.\n     * @param {(e:KeyboardEvent)=>void} e -  The callback to be triggered.\n     * @return {KeyHandler} this\n     */\n    down(key, listener) {\n        this.downListeners.push({ key: key, keyCode: KeyHandler.key2code(key), listener: listener });\n        return this;\n    }\n    /**\n     * Listen for key press.\n     *\n     * Example: new KeyHandler().press('enter',function() {console.log('Enter pressed.')});\n     *\n     * @name press\n     * @memberof KeyHandler\n     * @instance\n     * @param {string|number} key - Any key identifier, key code or one from the KEY_CODES list.\n     * @param {(e:KeyboardEvent)=>void} listener - The callback to be triggered.\n     * @return {KeyHandler} this\n     */\n    press(key, listener) {\n        this.pressListeners.push({ key: key, keyCode: KeyHandler.key2code(key), listener: listener });\n        return this;\n    }\n    /**\n     * Listen for key up.\n     *\n     * Example: new KeyHandler().up('enter',function() {console.log('Enter released.')});\n     *\n     * @name up\n     * @memberof KeyHandler\n     * @instance\n     * @param {string} key - Any key identifier, key code or one from the KEY_CODES list.\n     * @param {(e:KeyboardEvent)=>void)} e - The callback to be triggered.\n     * @return {KeyHandler} this\n     */\n    up(key, listener) {\n        this.upListeners.push({ key: key, keyCode: KeyHandler.key2code(key), listener: listener });\n        return this;\n    }\n    /**\n     * Check if a specific key is currently held pressed.\n     *\n     * @param {string|number} key - Any key identifier, key code or one from the KEY_CODES list.\n     */\n    isDown(key) {\n        if (typeof key == \"number\")\n            return this.keyStates[key] ? true : false;\n        else\n            return this.keyStates[KeyHandler.key2code(key)] ? true : false;\n    }\n    /**\n     * This function should invalidate any installed listeners and invalidate this object.\n     * After calling this function the object might not hold valid data any more and\n     * should not be used any more.\n     */\n    destroy() {\n        this.releaseListeners();\n    }\n}\n/**\n * Source:\n * https://keycode.info/\n */\n// prettier-ignore\nKeyHandler.KEY_CODES = {\n    'break': 3,\n    'backspace': 8,\n    // 'delete'\t : 8, // alternate: 46\n    'tab': 9,\n    'clear': 12,\n    'enter': 13,\n    'shift': 16,\n    'ctrl': 17,\n    'alt': 18,\n    'pause': 19,\n    // 'break'\t         : 19,\n    'capslock': 20,\n    'hangul': 21,\n    'hanja': 25,\n    'escape': 27,\n    'conversion': 28,\n    'non-conversion': 29,\n    'spacebar': 32,\n    'pageup': 33,\n    'pagedown': 34,\n    'end': 35,\n    'home': 36,\n    'leftarrow': 37,\n    'uparrow': 38,\n    'rightarrow': 39,\n    'downarrow': 40,\n    'select': 41,\n    'print': 42,\n    'execute': 43,\n    'printscreen': 44,\n    'insert': 45,\n    'delete': 46,\n    'help': 47,\n    '0': 48,\n    '1': 49,\n    '2': 50,\n    '3': 51,\n    '4': 52,\n    '5': 53,\n    '6': 54,\n    '7': 55,\n    '8': 56,\n    '9': 57,\n    ':': 58,\n    'semicolon (firefox)': 59,\n    'equals': 59,\n    '<': 60,\n    'equals (firefox)': 61,\n    'ß': 63,\n    '@ (firefox)': 64,\n    'a': 65,\n    'b': 66,\n    'c': 67,\n    'd': 68,\n    'e': 69,\n    'f': 70,\n    'g': 71,\n    'h': 72,\n    'i': 73,\n    'j': 74,\n    'k': 75,\n    'l': 76,\n    'm': 77,\n    'n': 78,\n    'o': 79,\n    'p': 80,\n    'q': 81,\n    'r': 82,\n    's': 83,\n    't': 84,\n    'u': 85,\n    'v': 86,\n    'w': 87,\n    'x': 88,\n    'y': 89,\n    'z': 90,\n    'windows': 91,\n    'leftcommand': 91,\n    'chromebooksearch': 91,\n    'rightwindowkey': 92,\n    'windowsmenu': 93,\n    'rightcommant': 93,\n    'sleep': 95,\n    'numpad0': 96,\n    'numpad1': 97,\n    'numpad2': 98,\n    'numpad3': 99,\n    'numpad4': 100,\n    'numpad5': 101,\n    'numpad6': 102,\n    'numpad7': 103,\n    'numpad8': 104,\n    'numpad9': 105,\n    'multiply': 106,\n    'add': 107,\n    'numpadperiod': 108,\n    'subtract': 109,\n    'decimalpoint': 110,\n    'divide': 111,\n    'f1': 112,\n    'f2': 113,\n    'f3': 114,\n    'f4': 115,\n    'f5': 116,\n    'f6': 117,\n    'f7': 118,\n    'f8': 119,\n    'f9': 120,\n    'f10': 121,\n    'f11': 122,\n    'f12': 123,\n    'f13': 124,\n    'f14': 125,\n    'f15': 126,\n    'f16': 127,\n    'f17': 128,\n    'f18': 129,\n    'f19': 130,\n    'f20': 131,\n    'f21': 132,\n    'f22': 133,\n    'f23': 134,\n    'f24': 135,\n    'numlock': 144,\n    'scrolllock': 145,\n    '^': 160,\n    '!': 161,\n    // '؛' \t : 162 // (arabic semicolon)\n    '#': 163,\n    '$': 164,\n    'ù': 165,\n    'pagebackward': 166,\n    'pageforward': 167,\n    'refresh': 168,\n    'closingparen': 169,\n    '*': 170,\n    '~+*': 171,\n    // 'home'\t         : 172,\n    'minus': 173,\n    // 'mute'           : 173,\n    // 'unmute'\t : 173,\n    'decreasevolumelevel': 174,\n    'increasevolumelevel': 175,\n    'next': 176,\n    'previous': 177,\n    'stop': 178,\n    'play/pause': 179,\n    'email': 180,\n    'mute': 181,\n    'unmute': 181,\n    //'decreasevolumelevel'\t182 // firefox\n    //'increasevolumelevel'\t183 // firefox\n    'semicolon': 186,\n    'ñ': 186,\n    'equal': 187,\n    'comma': 188,\n    'dash': 189,\n    'period': 190,\n    'forwardslash': 191,\n    'ç': 191,\n    'grave accent': 192,\n    //'ñ' 192,\n    'æ': 192,\n    'ö': 192,\n    '?': 193,\n    '/': 193,\n    '°': 193,\n    // 'numpadperiod'\t : 194, // chrome\n    'openbracket': 219,\n    'backslash': 220,\n    'closebracket': 221,\n    'å': 221,\n    'singlequote': 222,\n    'ø': 222,\n    'ä': 222,\n    '`': 223,\n    // 'left or right ⌘ key (firefox)'\t224\n    'altgr': 225,\n    // '< /git >, left back slash'\t226\n    'GNOME Compose Key': 230,\n    'XF86Forward': 233,\n    'XF86Back': 234,\n    'alphanumeric': 240,\n    'hiragana': 242,\n    'katakana': 242,\n    'half-width': 243,\n    'full-width': 243,\n    'kanji': 244,\n    'unlocktrackpad': 251,\n    'toggletouchpad': 255\n};\n//# sourceMappingURL=KeyHandler.js.map","/**\n * @author   Ikaros Kappler\n * @date     2018-03-19\n * @modified 2018-04-28 Added the param 'wasDragged'.\n * @modified 2018-08-16 Added the param 'dragAmount'.\n * @modified 2018-08-27 Added the param 'element'.\n * @modified 2018-11-11 Changed the scope from a simple global var to a member of window/_context.\n * @modified 2018-11-19 Renamed the 'mousedown' function to 'down' and the 'mouseup' function to 'up'.\n * @modified 2018-11-28 Added the 'wheel' listener.\n * @modified 2018-12-09 Cleaned up some code.\n * @modified 2019-02-10 Cleaned up some more code.\n * @modified 2020-03-25 Ported this class from vanilla-JS to Typescript.\n * @modified 2020-04-08 Fixed the click event (internally fired a 'mouseup' event) (1.0.10)\n * @modified 2020-04-08 Added the optional 'name' property. (1.0.11)\n * @modified 2020-04-08 The new version always installs internal listenrs to track drag events even\n *                      if there is no external drag listener installed (1.1.0).\n * @modified 2020-10-04 Added extended JSDoc comments.\n * @modified 2020-11-25 Added the `isTouchEvent` param.\n * @modified 2021-01-10 The mouse handler is now also working with SVGElements.\n * @modified 2022-08-16 Fixed a bug in the mouse button detection.\n * @version  1.2.1\n *\n * @file MouseHandler\n * @public\n **/\nexport class XMouseEvent extends MouseEvent {\n}\nexport class XWheelEvent extends WheelEvent {\n}\n/**\n * @classdesc A simple mouse handler for demos.\n * Use to avoid load massive libraries like jQuery.\n *\n * @requires XYCoords\n */\nexport class MouseHandler {\n    /**\n     * The constructor.\n     *\n     * Pass the DOM element you want to receive mouse events from.\n     *\n     * Usage\n     * =====\n     * @example\n     *   // Javascript\n     *   new MouseHandler( document.getElementById('mycanvas') )\n     *\t    .drag( function(e) {\n     *\t\tconsole.log( 'Mouse dragged: ' + JSON.stringify(e) );\n     *\t\tif( e.params.leftMouse ) ;\n     *\t\telse if( e.params.rightMouse ) ;\n     *\t    } )\n     *\t    .move( function(e) {\n     *\t\tconsole.log( 'Mouse moved: ' + JSON.stringify(e.params) );\n     *\t    } )\n     *          .up( function(e) {\n     *              console.log( 'Mouse up. Was dragged?', e.params.wasDragged );\n     *          } )\n     *          .down( function(e) {\n     *              console.log( 'Mouse down.' );\n     *          } )\n     *          .click( function(e) {\n     *              console.log( 'Click.' );\n     *          } )\n     *          .wheel( function(e) {\n     *              console.log( 'Wheel. delta='+e.deltaY );\n     *          } )\n     *\n     * @example\n     *   // Typescript\n     *   new MouseHandler( document.getElementById('mycanvas') )\n     *\t    .drag( (e:XMouseEvent) => {\n     *\t\tconsole.log( 'Mouse dragged: ' + JSON.stringify(e) );\n     *\t\tif( e.params.leftMouse ) ;\n     *\t\telse if( e.params.rightMouse ) ;\n     *\t    } )\n     *\t    .move( (e:XMouseEvent) => {\n     *\t\tconsole.log( 'Mouse moved: ' + JSON.stringify(e.params) );\n     *\t    } )\n     *          .up( (e:XMouseEvent) => {\n     *              console.log( 'Mouse up. Was dragged?', e.params.wasDragged );\n     *          } )\n     *          .down( (e:XMouseEvent) => {\n     *              console.log( 'Mouse down.' );\n     *          } )\n     *          .click( (e:XMouseEvent) => {\n     *              console.log( 'Click.' );\n     *          } )\n     *          .wheel( (e:XWheelEvent) => {\n     *              console.log( 'Wheel. delta='+e.deltaY );\n     *          } )\n     *\n     * @constructor\n     * @instance\n     * @memberof MouseHandler\n     * @param {HTMLElement} element\n     **/\n    constructor(element, name) {\n        this.mouseDownPos = undefined;\n        this.mouseDragPos = undefined;\n        // TODO: cc\n        // private mousePos       : { x:number, y:number }|undefined = undefined;\n        this.mouseButton = -1;\n        this.listeners = {};\n        this.installed = {};\n        this.handlers = {};\n        // +----------------------------------------------------------------------\n        // | Some private vars to store the current mouse/position/button state.\n        // +-------------------------------------------------\n        this.name = name;\n        this.element = element;\n        this.mouseDownPos = undefined;\n        this.mouseDragPos = undefined;\n        // this.mousePos     = null;\n        this.mouseButton = -1;\n        this.listeners = {};\n        this.installed = {};\n        this.handlers = {};\n        // +----------------------------------------------------------------------\n        // | Define the internal event handlers.\n        // |\n        // | They will dispatch the modified event (relative mouse position,\n        // | drag offset, ...) to the callbacks.\n        // +-------------------------------------------------\n        const _self = this;\n        this.handlers[\"mousemove\"] = (e) => {\n            if (_self.listeners.mousemove)\n                _self.listeners.mousemove(_self.mkParams(e, \"mousemove\"));\n            if (_self.mouseDragPos && _self.listeners.drag)\n                _self.listeners.drag(_self.mkParams(e, \"drag\"));\n            if (_self.mouseDownPos)\n                _self.mouseDragPos = _self.relPos(e);\n        };\n        this.handlers[\"mouseup\"] = (e) => {\n            if (_self.listeners.mouseup)\n                _self.listeners.mouseup(_self.mkParams(e, \"mouseup\"));\n            _self.mouseDragPos = undefined;\n            _self.mouseDownPos = undefined;\n            _self.mouseButton = -1;\n        };\n        this.handlers[\"mousedown\"] = (e) => {\n            _self.mouseDragPos = _self.relPos(e);\n            _self.mouseDownPos = _self.relPos(e);\n            _self.mouseButton = e.button;\n            if (_self.listeners.mousedown)\n                _self.listeners.mousedown(_self.mkParams(e, \"mousedown\"));\n        };\n        this.handlers[\"click\"] = (e) => {\n            if (_self.listeners.click)\n                _self.listeners.click(_self.mkParams(e, \"click\"));\n        };\n        this.handlers[\"wheel\"] = (e) => {\n            if (_self.listeners.wheel)\n                _self.listeners.wheel(_self.mkParams(e, \"wheel\"));\n        };\n        this.element.addEventListener(\"mousemove\", this.handlers[\"mousemove\"]);\n        this.element.addEventListener(\"mouseup\", this.handlers[\"mouseup\"]);\n        this.element.addEventListener(\"mousedown\", this.handlers[\"mousedown\"]);\n        this.element.addEventListener(\"click\", this.handlers[\"click\"]);\n        this.element.addEventListener(\"wheel\", this.handlers[\"wheel\"]);\n    }\n    /**\n     * Get relative position from the given MouseEvent.\n     *\n     * @name relPos\n     * @memberof MouseHandler\n     * @instance\n     * @private\n     * @param {MouseEvent} e - The mouse event to get the relative position for.\n     * @return {XYCoords} The relative mouse coordinates.\n     */\n    relPos(e) {\n        return { x: e.offsetX, y: e.offsetY };\n    }\n    /**\n     * Build the extended event params.\n     *\n     * @name mkParams\n     * @memberof MouseHandler\n     * @instance\n     * @private\n     * @param {MouseEvent} event - The mouse event to get the relative position for.\n     * @param {string} eventName - The name of the firing event.\n     * @return {XMouseEvent}\n     */\n    mkParams(event, eventName) {\n        var _a, _b;\n        const rel = this.relPos(event);\n        const xEvent = event;\n        xEvent.params = {\n            element: this.element,\n            name: eventName,\n            isTouchEvent: false,\n            pos: rel,\n            button: event.button,\n            leftButton: event.button === 0,\n            middleButton: event.button === 1,\n            rightButton: event.button === 2,\n            mouseDownPos: (_a = this.mouseDownPos) !== null && _a !== void 0 ? _a : { x: NaN, y: NaN },\n            draggedFrom: (_b = this.mouseDragPos) !== null && _b !== void 0 ? _b : { x: NaN, y: NaN },\n            wasDragged: this.mouseDownPos != null && (this.mouseDownPos.x != rel.x || this.mouseDownPos.y != rel.y),\n            dragAmount: this.mouseDragPos != null ? { x: rel.x - this.mouseDragPos.x, y: rel.y - this.mouseDragPos.y } : { x: 0, y: 0 }\n        };\n        return xEvent;\n    }\n    /**\n     * Install a new listener.\n     * Please note that this mouse handler can only handle one listener per event type.\n     *\n     * @name listenFor\n     * @memberof MouseHandler\n     * @instance\n     * @private\n     * @param {string} eventName - The name of the firing event to listen for.\n     * @return {void}\n     */\n    listenFor(eventName) {\n        if (this.installed[eventName])\n            return;\n        // In the new version 1.1.0 has all internal listeners installed by default.\n        this.installed[eventName] = true;\n    }\n    /**\n     * Un-install a new listener.\n     *\n     * @name listenFor\n     * @memberof MouseHandler\n     * @instance\n     * @private\n     * @param {string} eventName - The name of the firing event to unlisten for.\n     * @return {void}\n     */\n    unlistenFor(eventName) {\n        if (!this.installed[eventName])\n            return;\n        // In the new version 1.1.0 has all internal listeners installed by default.\n        delete this.installed[eventName];\n    }\n    /**\n     * Installer function to listen for a specific event: mouse-drag.\n     * Pass your callbacks here.\n     *\n     * Note: this support chaining.\n     *\n     * @name drag\n     * @memberof MouseHandler\n     * @instance\n     * @param {XMouseCallback} callback - The drag-callback to listen for.\n     * @return {MouseHandler} this\n     */\n    drag(callback) {\n        if (this.listeners.drag)\n            this.throwAlreadyInstalled(\"drag\");\n        this.listeners.drag = callback;\n        this.listenFor(\"mousedown\");\n        this.listenFor(\"mousemove\");\n        this.listenFor(\"mouseup\");\n        return this;\n    }\n    /**\n     * Installer function to listen for a specific event: mouse-move.\n     * Pass your callbacks here.\n     *\n     * Note: this support chaining.\n     *\n     * @name move\n     * @memberof MouseHandler\n     * @instance\n     * @param {XMouseCallback} callback - The move-callback to listen for.\n     * @return {MouseHandler} this\n     */\n    move(callback) {\n        if (this.listeners.mousemove)\n            this.throwAlreadyInstalled(\"mousemove\");\n        this.listenFor(\"mousemove\");\n        this.listeners.mousemove = callback;\n        return this;\n    }\n    /**\n     * Installer function to listen for a specific event: mouse-up.\n     * Pass your callbacks here.\n     *\n     * Note: this support chaining.\n     *\n     * @name up\n     * @memberof MouseHandler\n     * @instance\n     * @param {XMouseCallback} callback - The up-callback to listen for.\n     * @return {MouseHandler} this\n     */\n    up(callback) {\n        if (this.listeners.mouseup)\n            this.throwAlreadyInstalled(\"mouseup\");\n        this.listenFor(\"mouseup\");\n        this.listeners.mouseup = callback;\n        return this;\n    }\n    /**\n     * Installer function to listen for a specific event: mouse-down.\n     * Pass your callbacks here.\n     *\n     * Note: this support chaining.\n     *\n     * @name down\n     * @memberof MouseHandler\n     * @instance\n     * @param {XMouseCallback} callback - The down-callback to listen for.\n     * @return {MouseHandler} this\n     */\n    down(callback) {\n        if (this.listeners.mousedown)\n            this.throwAlreadyInstalled(\"mousedown\");\n        this.listenFor(\"mousedown\");\n        this.listeners.mousedown = callback;\n        return this;\n    }\n    /**\n     * Installer function to listen for a specific event: mouse-click.\n     * Pass your callbacks here.\n     *\n     * Note: this support chaining.\n     *\n     * @name click\n     * @memberof MouseHandler\n     * @instance\n     * @param {XMouseCallback} callback - The click-callback to listen for.\n     * @return {MouseHandler} this\n     */\n    click(callback) {\n        if (this.listeners.click)\n            this.throwAlreadyInstalled(\"click\");\n        this.listenFor(\"click\");\n        this.listeners.click = callback;\n        return this;\n    }\n    /**\n     * Installer function to listen for a specific event: mouse-wheel.\n     * Pass your callbacks here.\n     *\n     * Note: this support chaining.\n     *\n     * @name wheel\n     * @memberof MouseHandler\n     * @instance\n     * @param {XWheelCallback} callback - The wheel-callback to listen for.\n     * @return {MouseHandler} this\n     */\n    wheel(callback) {\n        if (this.listeners.wheel)\n            this.throwAlreadyInstalled(\"wheel\");\n        this.listenFor(\"wheel\");\n        this.listeners.wheel = callback;\n        return this;\n    }\n    /**\n     * An internal function to throw events.\n     *\n     * @name throwAlreadyInstalled\n     * @memberof MouseHandler\n     * @instance\n     * @private\n     * @param {string} name - The name of the event.\n     * @return {void}\n     */\n    throwAlreadyInstalled(name) {\n        throw `This MouseHandler already has a '${name}' callback. To keep the code simple there is only room for one.`;\n    }\n    /**\n     * Call this when your work is done.\n     *\n     * The function will un-install all event listeners.\n     *\n     * @name destroy\n     * @memberof MouseHandler\n     * @instance\n     * @private\n     * @return {void}\n     */\n    destroy() {\n        this.unlistenFor(\"mousedown\");\n        this.unlistenFor(\"mousemove\");\n        this.unlistenFor(\"moseup\");\n        this.unlistenFor(\"click\");\n        this.unlistenFor(\"wheel\");\n        this.element.removeEventListener(\"mousemove\", this.handlers[\"mousemove\"]);\n        this.element.removeEventListener(\"mouseup\", this.handlers[\"mousedown\"]);\n        this.element.removeEventListener(\"mousedown\", this.handlers[\"mousedown\"]);\n        this.element.removeEventListener(\"click\", this.handlers[\"click\"]);\n        this.element.removeEventListener(\"wheel\", this.handlers[\"wheel\"]);\n    }\n}\n//# sourceMappingURL=MouseHandler.js.map","/**\n * @author   Ikaros Kappler\n * @date     2019-01-30\n * @modified 2019-03-23 Added JSDoc tags.\n * @modified 2020-03-25 Ported this class from vanilla-JS to Typescript.\n * @modified 2021-01-20 Added UID.\n * @modified 2022-02-02 Added the `destroy` method.\n * @modified 2022-02-02 Cleared the `PBImage.toSVGString` function (deprecated). Use `drawutilssvg` instead.\n * @version 1.2.0\n *\n * @file PBImage\n * @fileoverview As native Image objects have only a position and with\n *               and height thei are not suitable for UI dragging interfaces.\n * @public\n **/\nimport { UIDGenerator } from \"./UIDGenerator\";\n/**\n * @classdesc A wrapper for image objects. Has an upper left and a lower right corner point.\n *\n * @requires Vertex\n * @requires SVGSerializable\n * @requires UID\n * @requires UIDGenerator\n */\nexport class PBImage {\n    /**\n     * The constructor.\n     *\n     * @constructor\n     * @name PBImage\n     * @param {Image} image - The actual image.\n     * @param {Vertex} upperLeft - The upper left corner.\n     * @param {Vertex} lowerRight - The lower right corner.\n     **/\n    constructor(image, upperLeft, lowerRight) {\n        /**\n         * Required to generate proper CSS classes and other class related IDs.\n         **/\n        this.className = \"PBImage\";\n        this.uid = UIDGenerator.next();\n        this.image = image;\n        this.upperLeft = upperLeft;\n        this.lowerRight = lowerRight;\n    }\n    /**\n     * This function should invalidate any installed listeners and invalidate this object.\n     * After calling this function the object might not hold valid data any more and\n     * should not be used.\n     */\n    destroy() {\n        this.upperLeft.destroy();\n        this.lowerRight.destroy();\n        this.isDestroyed = true;\n    }\n}\n//# sourceMappingURL=PBImage.js.map","/**\n * @author   Ikaros Kappler\n * @date     2021-11-16\n * @modified 2022-02-02 Added the `destroy` method.\n * @version  1.1.0\n **/\nimport { UIDGenerator } from \"./UIDGenerator\";\nimport { Vertex } from \"./Vertex\";\n/**\n * @classdesc A simple text element: position, fontSize, fontFamily, color, textAlign, lineHeight and rotation.\n *\n * @requires FontOptions\n * @requires FontSize\n * @requires FontStyle\n * @requires FontWeight\n * @requires Vertex\n * @requires SVGSerializale\n * @requires UID\n * @requires UIDGenerator\n **/\nexport class PBText {\n    /**\n     * Create a new circle with given center point and radius.\n     *\n     * @constructor\n     * @name Circle\n     * @param {Vertex} center - The center point of the circle.\n     * @param {number} radius - The radius of the circle.\n     */\n    constructor(text, anchor, options) {\n        /**\n         * Required to generate proper CSS classes and other class related IDs.\n         **/\n        this.className = \"PBText\";\n        this.uid = UIDGenerator.next();\n        this.text = text;\n        this.anchor = anchor !== null && anchor !== void 0 ? anchor : new Vertex();\n        this.color = options.color;\n        this.fontFamily = options.fontFamily;\n        this.fontSize = options.fontSize;\n        this.fontStyle = options.fontStyle;\n        this.fontWeight = options.fontWeight;\n        this.lineHeight = options.lineHeight;\n        this.textAlign = options.textAlign;\n        this.rotation = options.rotation;\n    }\n    /**\n     * This function should invalidate any installed listeners and invalidate this object.\n     * After calling this function the object might not hold valid data any more and\n     * should not be used.\n     */\n    destroy() {\n        this.anchor.destroy();\n        this.isDestroyed = true;\n    }\n} // END class\n//# sourceMappingURL=PBText.js.map","/* Port from AlloyFinger v0.1.15\n * Original by dntzhang\n * Typescript port by Ikaros Kappler\n * Github: https://github.com/IkarosKappler/AlloyFinger-Typescript\n *\n * @date    2021-02-10 (Typescript port)\n * @version 0.1.18\n */\n;\n/**\n * Tiny math function to calculate the length of a vector in euclidean space.\n *\n * @param {XYCoords} v - The vector in {x,y} notation.\n * @return {number} The length of the vector.\n */\nconst getLen = (v) => {\n    return Math.sqrt(v.x * v.x + v.y * v.y);\n};\n/**\n * Tiny math function to calculate the dot product of two vectors.\n *\n * @param {XYCoords} v1 - The first vector in {x,y} notation.\n * @param {XYCoords} v2 - The second vector in {x,y} notation.\n * @return {number} The dot product of both vectors.\n */\nconst dot = (v1, v2) => {\n    return v1.x * v2.x + v1.y * v2.y;\n};\n/**\n * Tiny math function to calculate the angle between two vectors.\n *\n * @param {XYCoords} v1 - The first vector in {x,y} notation.\n * @param {XYCoords} v2 - The second vector in {x,y} notation.\n * @return {number} The angle (in radians) between the two vectors.\n */\nconst getAngle = (v1, v2) => {\n    const mr = getLen(v1) * getLen(v2);\n    if (mr === 0)\n        return 0;\n    var r = dot(v1, v2) / mr;\n    if (r > 1)\n        r = 1;\n    return Math.acos(r);\n};\n/**\n * Tiny math function to calculate the cross product of two vectors.\n *\n * @param {XYCoords} v1 - The first vector in {x,y} notation.\n * @param {XYCoords} v2 - The second vector in {x,y} notation.\n * @return {number} The cross product of both vectors.\n */\nconst cross = (v1, v2) => {\n    return v1.x * v2.y - v2.x * v1.y;\n};\n/**\n * Tiny math function to calculate the rotate-angle (in degrees) for two vectors.\n *\n * @param {XYCoords} v1 - The first vector in {x,y} notation.\n * @param {XYCoords} v2 - The second vector in {x,y} notation.\n * @return {number} The rotate-angle in degrees for the two vectors.\n */\nconst getRotateAngle = (v1, v2) => {\n    var angle = getAngle(v1, v2);\n    if (cross(v1, v2) > 0) {\n        angle *= -1;\n    }\n    return angle * 180 / Math.PI;\n};\n/**\n * A HandlerAdmin holds all the added event handlers for one kind of event type.\n */\nclass HandlerAdmin {\n    constructor(el) {\n        this.handlers = [];\n        this.el = el;\n    }\n    ;\n    add(handler) {\n        this.handlers.push(handler);\n    }\n    ;\n    del(handler) {\n        if (!handler)\n            this.handlers = [];\n        for (var i = this.handlers.length; i >= 0; i--) {\n            if (this.handlers[i] === handler) {\n                this.handlers.splice(i, 1);\n            }\n        }\n    }\n    ;\n    dispatch(..._args) {\n        for (var i = 0, len = this.handlers.length; i < len; i++) {\n            const handler = this.handlers[i];\n            if (typeof handler === 'function') {\n                handler.apply(this.el, arguments);\n            }\n        }\n    }\n    ;\n} // END class HandlerAdmin\n/**\n * A wrapper for handler functions; converts the passed handler function into a HadlerAdmin instance..\n */\nconst wrapFunc = (el, handler) => {\n    const handlerAdmin = new HandlerAdmin(el);\n    handlerAdmin.add(handler);\n    return handlerAdmin;\n};\n/**\n * @classdesc The AlloyFinger main class. Use this to add handler functions for\n *            touch events to any HTML- or SVG-Element.\n **/\nexport class AlloyFinger {\n    constructor(el, option) {\n        this.element = typeof el == 'string' ? document.querySelector(el) : el;\n        // Fancy stuff: change `this` from the start-, move-, end- and cancel-function.\n        //    https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_objects/Function/bind\n        this.start = this.start.bind(this);\n        this.move = this.move.bind(this);\n        this.end = this.end.bind(this);\n        this.cancel = this.cancel.bind(this);\n        this.element.addEventListener(\"touchstart\", this.start, false);\n        this.element.addEventListener(\"touchmove\", this.move, false);\n        this.element.addEventListener(\"touchend\", this.end, false);\n        this.element.addEventListener(\"touchcancel\", this.cancel, false);\n        this.preV = { x: null, y: null };\n        this.pinchStartLen = null;\n        this.zoom = 1;\n        this.isDoubleTap = false;\n        const noop = () => { };\n        this.rotate = wrapFunc(this.element, option.rotate || noop);\n        this.touchStart = wrapFunc(this.element, option.touchStart || noop);\n        this.multipointStart = wrapFunc(this.element, option.multipointStart || noop);\n        this.multipointEnd = wrapFunc(this.element, option.multipointEnd || noop);\n        this.pinch = wrapFunc(this.element, option.pinch || noop);\n        this.swipe = wrapFunc(this.element, option.swipe || noop);\n        this.tap = wrapFunc(this.element, option.tap || noop);\n        this.doubleTap = wrapFunc(this.element, option.doubleTap || noop);\n        this.longTap = wrapFunc(this.element, option.longTap || noop);\n        this.singleTap = wrapFunc(this.element, option.singleTap || noop);\n        this.pressMove = wrapFunc(this.element, option.pressMove || noop);\n        this.twoFingerPressMove = wrapFunc(this.element, option.twoFingerPressMove || noop);\n        this.touchMove = wrapFunc(this.element, option.touchMove || noop);\n        this.touchEnd = wrapFunc(this.element, option.touchEnd || noop);\n        this.touchCancel = wrapFunc(this.element, option.touchCancel || noop);\n        this._cancelAllHandler = this.cancelAll.bind(this);\n        if (globalThis && typeof globalThis.addEventListener === \"function\") {\n            globalThis.addEventListener('scroll', this._cancelAllHandler);\n        }\n        this.delta = null;\n        this.last = null;\n        this.now = null;\n        this.tapTimeout = null;\n        this.singleTapTimeout = null;\n        this.longTapTimeout = null;\n        this.swipeTimeout = null;\n        this.x1 = this.x2 = this.y1 = this.y2 = null;\n        this.preTapPosition = { x: null, y: null };\n    }\n    ;\n    start(evt) {\n        if (!evt.touches)\n            return;\n        const _self = this;\n        this.now = Date.now();\n        this.x1 = evt.touches[0].pageX;\n        this.y1 = evt.touches[0].pageY;\n        this.delta = this.now - (this.last || this.now);\n        this.touchStart.dispatch(evt, this.element);\n        if (this.preTapPosition.x !== null) {\n            this.isDoubleTap = (this.delta > 0 && this.delta <= 250 && Math.abs(this.preTapPosition.x - this.x1) < 30 && Math.abs(this.preTapPosition.y - this.y1) < 30);\n            if (this.isDoubleTap)\n                clearTimeout(this.singleTapTimeout);\n        }\n        this.preTapPosition.x = this.x1;\n        this.preTapPosition.y = this.y1;\n        this.last = this.now;\n        const preV = this.preV;\n        const len = evt.touches.length;\n        if (len > 1) {\n            this._cancelLongTap();\n            this._cancelSingleTap();\n            const v = { x: evt.touches[1].pageX - this.x1, y: evt.touches[1].pageY - this.y1 };\n            preV.x = v.x;\n            preV.y = v.y;\n            this.pinchStartLen = getLen(preV);\n            this.multipointStart.dispatch(evt, this.element);\n        }\n        this._preventTap = false;\n        this.longTapTimeout = setTimeout((() => {\n            _self.longTap.dispatch(evt, _self.element);\n            _self._preventTap = true;\n        }).bind(_self), 750);\n    }\n    ;\n    move(event) {\n        if (!event.touches)\n            return;\n        const afEvent = event;\n        const preV = this.preV;\n        const len = event.touches.length;\n        const currentX = event.touches[0].pageX;\n        const currentY = event.touches[0].pageY;\n        this.isDoubleTap = false;\n        if (len > 1) {\n            const sCurrentX = afEvent.touches[1].pageX;\n            const sCurrentY = afEvent.touches[1].pageY;\n            const v = { x: afEvent.touches[1].pageX - currentX, y: afEvent.touches[1].pageY - currentY };\n            if (preV.x !== null) {\n                if (this.pinchStartLen > 0) {\n                    afEvent.zoom = getLen(v) / this.pinchStartLen;\n                    this.pinch.dispatch(afEvent, this.element);\n                }\n                afEvent.angle = getRotateAngle(v, preV);\n                this.rotate.dispatch(afEvent, this.element);\n            }\n            preV.x = v.x;\n            preV.y = v.y;\n            if (this.x2 !== null && this.sx2 !== null) {\n                afEvent.deltaX = (currentX - this.x2 + sCurrentX - this.sx2) / 2;\n                afEvent.deltaY = (currentY - this.y2 + sCurrentY - this.sy2) / 2;\n            }\n            else {\n                afEvent.deltaX = 0;\n                afEvent.deltaY = 0;\n            }\n            this.twoFingerPressMove.dispatch(afEvent, this.element);\n            this.sx2 = sCurrentX;\n            this.sy2 = sCurrentY;\n        }\n        else {\n            if (this.x2 !== null) {\n                afEvent.deltaX = currentX - this.x2;\n                afEvent.deltaY = currentY - this.y2;\n                //move事件中添加对当前触摸点到初始触摸点的判断，\n                //如果曾经大于过某个距离(比如10),就认为是移动到某个地方又移回来，应该不再触发tap事件才对。\n                //\n                // translation:\n                //    Add the judgment of the current touch point to the initial touch point in the event,\n                //    If it has been greater than a certain distance (such as 10), it is considered to be\n                //    moved to a certain place and then moved back, and the tap event should no longer be triggered.\n                const movedX = Math.abs(this.x1 - this.x2);\n                const movedY = Math.abs(this.y1 - this.y2);\n                if (movedX > 10 || movedY > 10) {\n                    this._preventTap = true;\n                }\n            }\n            else {\n                afEvent.deltaX = 0;\n                afEvent.deltaY = 0;\n            }\n            this.pressMove.dispatch(afEvent, this.element);\n        }\n        this.touchMove.dispatch(afEvent, this.element);\n        this._cancelLongTap();\n        this.x2 = currentX;\n        this.y2 = currentY;\n        if (len > 1) {\n            event.preventDefault();\n        }\n    }\n    ; // END move\n    end(event) {\n        if (!event.changedTouches)\n            return;\n        const afEvent = event;\n        this._cancelLongTap();\n        const self = this;\n        if (afEvent.touches.length < 2) {\n            this.multipointEnd.dispatch(afEvent, this.element);\n            this.sx2 = this.sy2 = null;\n        }\n        //swipe\n        if ((this.x2 && Math.abs(this.x1 - this.x2) > 30) ||\n            (this.y2 && Math.abs(this.y1 - this.y2) > 30)) {\n            afEvent.direction = this._swipeDirection(this.x1, this.x2, this.y1, this.y2);\n            this.swipeTimeout = setTimeout(function () {\n                self.swipe.dispatch(afEvent, self.element);\n            }, 0);\n        }\n        else {\n            this.tapTimeout = setTimeout(function () {\n                if (!self._preventTap) {\n                    self.tap.dispatch(afEvent, self.element);\n                }\n                // trigger double tap immediately\n                if (self.isDoubleTap) {\n                    self.doubleTap.dispatch(afEvent, self.element);\n                    self.isDoubleTap = false;\n                }\n            }, 0);\n            if (!self.isDoubleTap) {\n                self.singleTapTimeout = setTimeout(function () {\n                    self.singleTap.dispatch(afEvent, self.element);\n                }, 250);\n            }\n        }\n        this.touchEnd.dispatch(afEvent, this.element);\n        this.preV.x = 0;\n        this.preV.y = 0;\n        this.zoom = 1;\n        this.pinchStartLen = null;\n        this.x1 = this.x2 = this.y1 = this.y2 = null;\n    }\n    ; // END end\n    cancelAll() {\n        this._preventTap = true;\n        clearTimeout(this.singleTapTimeout);\n        clearTimeout(this.tapTimeout);\n        clearTimeout(this.longTapTimeout);\n        clearTimeout(this.swipeTimeout);\n    }\n    ;\n    cancel(evt) {\n        this.cancelAll();\n        this.touchCancel.dispatch(evt, this.element);\n    }\n    ;\n    _cancelLongTap() {\n        clearTimeout(this.longTapTimeout);\n    }\n    ;\n    _cancelSingleTap() {\n        clearTimeout(this.singleTapTimeout);\n    }\n    ;\n    _swipeDirection(x1, x2, y1, y2) {\n        return Math.abs(x1 - x2) >= Math.abs(y1 - y2) ? (x1 - x2 > 0 ? 'Left' : 'Right') : (y1 - y2 > 0 ? 'Up' : 'Down');\n    }\n    ;\n    on(evt, handler) {\n        if (this[evt]) {\n            // Force the generic parameter into it's expected candidate here ;)\n            const admin = this[evt];\n            admin.add(handler);\n        }\n    }\n    ;\n    off(evt, handler) {\n        if (this[evt]) {\n            // Force the generic parameter into it's expected candidate here ;)\n            const admin = this[evt];\n            admin.del(handler);\n        }\n    }\n    ;\n    destroy() {\n        if (this.singleTapTimeout) {\n            clearTimeout(this.singleTapTimeout);\n        }\n        if (this.tapTimeout) {\n            clearTimeout(this.tapTimeout);\n        }\n        if (this.longTapTimeout) {\n            clearTimeout(this.longTapTimeout);\n        }\n        if (this.swipeTimeout) {\n            clearTimeout(this.swipeTimeout);\n        }\n        this.element.removeEventListener(\"touchstart\", this.start);\n        this.element.removeEventListener(\"touchmove\", this.move);\n        this.element.removeEventListener(\"touchend\", this.end);\n        this.element.removeEventListener(\"touchcancel\", this.cancel);\n        this.rotate.del();\n        this.touchStart.del();\n        this.multipointStart.del();\n        this.multipointEnd.del();\n        this.pinch.del();\n        this.swipe.del();\n        this.tap.del();\n        this.doubleTap.del();\n        this.longTap.del();\n        this.singleTap.del();\n        this.pressMove.del();\n        this.twoFingerPressMove.del();\n        this.touchMove.del();\n        this.touchEnd.del();\n        this.touchCancel.del();\n        this.preV = this.pinchStartLen = this.zoom = this.isDoubleTap = this.delta = this.last = this.now = this.tapTimeout = this.singleTapTimeout = this.longTapTimeout = this.swipeTimeout = this.x1 = this.x2 = this.y1 = this.y2 = this.preTapPosition = this.rotate = this.touchStart = this.multipointStart = this.multipointEnd = this.pinch = this.swipe = this.tap = this.doubleTap = this.longTap = this.singleTap = this.pressMove = this.touchMove = this.touchEnd = this.touchCancel = this.twoFingerPressMove = null;\n        if (globalThis && typeof globalThis.removeEventListener === \"function\") {\n            globalThis.removeEventListener('scroll', this._cancelAllHandler);\n        }\n    }\n    ; // END destroy\n}\n;\nexport default AlloyFinger;\n//# sourceMappingURL=alloy_finger.js.map","/**\n * TypeScript port by Ikaros Kappler.\n *\n * Original file from https://github.com/AlloyTeam/AlloyFinger\n *\n * @date 2021-02-10\n */\nimport { AlloyFinger } from './alloy_finger';\nexport { AlloyFinger };\nexport default AlloyFinger;\n//# sourceMappingURL=index.js.map","/**\n * @author   Ikaros Kappler\n * @date     2018-11-28\n * @modified 2018-12-04 Added the toSVGString function.\n * @modified 2020-03-25 Ported this class from vanilla-JS to Typescript.\n * @modified 2021-01-20 Added UID.\n * @modified 2021-02-14 Added functions `radiusH` and `radiusV`.\n * @modified 2021-02-26 Added helper function `decribeSVGArc(...)`.\n * @modified 2021-03-01 Added attribute `rotation` to allow rotation of ellipses.\n * @modified 2021-03-03 Added the `vertAt` and `perimeter` methods.\n * @modified 2021-03-05 Added the `getFoci`, `normalAt` and `tangentAt` methods.\n * @modified 2021-03-09 Added the `clone` and `rotate` methods.\n * @modified 2021-03-10 Added the `toCubicBezier` method.\n * @modified 2021-03-15 Added `VEllipse.quarterSegmentCount` and `VEllipse.scale` functions.\n * @modified 2021-03-19 Added the `VEllipse.rotate` function.\n * @modified 2022-02-02 Added the `destroy` method.\n * @modified 2022-02-02 Cleared the `VEllipse.toSVGString` function (deprecated). Use `drawutilssvg` instead.\n * @version  1.3.0\n *\n * @file VEllipse\n * @fileoverview Ellipses with a center and an x- and a y-axis (stored as a vertex).\n **/\nimport { Line } from \"./Line\";\nimport { Vector } from \"./Vector\";\nimport { Vertex } from \"./Vertex\";\nimport { UIDGenerator } from \"./UIDGenerator\";\nimport { CubicBezierCurve } from \"./CubicBezierCurve\";\n/**\n * @classdesc An ellipse class based on two vertices [centerX,centerY] and [radiusX,radiusY].\n *\n * @requires SVGSerializable\n * @requires UID\n * @requires UIDGenerator\n * @requires Vertex\n */\nexport class VEllipse {\n    /**\n     * The constructor.\n     *\n     * @constructor\n     * @param {Vertex} center - The ellipses center.\n     * @param {Vertex} axis - The x- and y-axis (the two radii encoded in a control point).\n     * @param {Vertex} rotation - [optional, default=0] The rotation of this ellipse.\n     * @name VEllipse\n     **/\n    constructor(center, axis, rotation) {\n        /**\n         * Required to generate proper CSS classes and other class related IDs.\n         **/\n        this.className = \"VEllipse\";\n        this.uid = UIDGenerator.next();\n        this.center = center;\n        this.axis = axis;\n        this.rotation = rotation || 0.0;\n    }\n    /**\n     * Clone this ellipse (deep clone).\n     *\n     * @return {VEllipse} A copy of this ellipse.s\n     */\n    clone() {\n        return new VEllipse(this.center.clone(), this.axis.clone(), this.rotation);\n    }\n    /**\n     * Get the non-negative horizonal radius of this ellipse.\n     *\n     * @method radiusH\n     * @instance\n     * @memberof VEllipse\n     * @return {number} The unsigned horizontal radius of this ellipse.\n     */\n    radiusH() {\n        return Math.abs(this.signedRadiusH());\n    }\n    /**\n     * Get the signed horizonal radius of this ellipse.\n     *\n     * @method signedRadiusH\n     * @instance\n     * @memberof VEllipse\n     * @return {number} The signed horizontal radius of this ellipse.\n     */\n    signedRadiusH() {\n        // return Math.abs(this.axis.x - this.center.x);\n        // Rotate axis back to origin before calculating radius\n        // return Math.abs(new Vertex(this.axis).rotate(-this.rotation,this.center).x - this.center.x);\n        return new Vertex(this.axis).rotate(-this.rotation, this.center).x - this.center.x;\n    }\n    /**\n     * Get the non-negative vertical radius of this ellipse.\n     *\n     * @method radiusV\n     * @instance\n     * @memberof VEllipse\n     * @return {number} The unsigned vertical radius of this ellipse.\n     */\n    radiusV() {\n        return Math.abs(this.signedRadiusV());\n    }\n    /**\n     * Get the signed vertical radius of this ellipse.\n     *\n     * @method radiusV\n     * @instance\n     * @memberof VEllipse\n     * @return {number} The signed vertical radius of this ellipse.\n     */\n    signedRadiusV() {\n        // return Math.abs(this.axis.y - this.center.y);\n        // Rotate axis back to origin before calculating radius\n        // return Math.abs(new Vertex(this.axis).rotate(-this.rotation,this.center).y - this.center.y);\n        return new Vertex(this.axis).rotate(-this.rotation, this.center).y - this.center.y;\n    }\n    /**\n     * Scale this ellipse by the given factor from the center point. The factor will be applied to both radii.\n     *\n     * @method scale\n     * @instance\n     * @memberof VEllipse\n     * @param {number} factor - The factor to scale by.\n     * @return {VEllipse} this for chaining.\n     */\n    scale(factor) {\n        this.axis.scale(factor, this.center);\n        return this;\n    }\n    /**\n     * Rotate this ellipse around its center.\n     *\n     * @method rotate\n     * @instance\n     * @memberof VEllipse\n     * @param {number} angle - The angle to rotate by.\n     * @returns {VEllipse} this for chaining.\n     */\n    rotate(angle) {\n        this.axis.rotate(angle, this.center);\n        this.rotation += angle;\n        return this;\n    }\n    /**\n     * Get the vertex on the ellipse's outline at the given angle.\n     *\n     * @method vertAt\n     * @instance\n     * @memberof VEllipse\n     * @param {number} angle - The angle to determine the vertex at.\n     * @return {Vertex} The vertex on the outline at the given angle.\n     */\n    vertAt(angle) {\n        // Tanks to Narasinham for the vertex-on-ellipse equations\n        // https://math.stackexchange.com/questions/22064/calculating-a-point-that-lies-on-an-ellipse-given-an-angle\n        const a = this.radiusH();\n        const b = this.radiusV();\n        return new Vertex(VEllipse.utils.polarToCartesian(this.center.x, this.center.y, a, b, angle)).rotate(this.rotation, this.center);\n    }\n    /**\n     * Get the normal vector at the given angle.\n     * The normal vector is the vector that intersects the ellipse in a 90 degree angle\n     * at the given point (speicified by the given angle).\n     *\n     * Length of desired normal vector can be specified, default is 1.0.\n     *\n     * @method normalAt\n     * @instance\n     * @memberof VEllipse\n     * @param {number} angle - The angle to get the normal vector at.\n     * @param {number=1.0} length - [optional, default=1] The length of the returned vector.\n     */\n    normalAt(angle, length) {\n        const point = this.vertAt(angle);\n        const foci = this.getFoci();\n        // Calculate the angle between [point,focusA] and [point,focusB]\n        const angleA = new Line(point, foci[0]).angle();\n        const angleB = new Line(point, foci[1]).angle();\n        const centerAngle = angleA + (angleB - angleA) / 2.0;\n        const endPointA = point.clone().addX(50).clone().rotate(centerAngle, point);\n        const endPointB = point\n            .clone()\n            .addX(50)\n            .clone()\n            .rotate(Math.PI + centerAngle, point);\n        if (this.center.distance(endPointA) < this.center.distance(endPointB)) {\n            return new Vector(point, endPointB);\n        }\n        else {\n            return new Vector(point, endPointA);\n        }\n    }\n    /**\n     * Get the tangent vector at the given angle.\n     * The tangent vector is the vector that touches the ellipse exactly at the given given\n     * point (speicified by the given angle).\n     *\n     * Note that the tangent is just 90 degree rotated normal vector.\n     *\n     * Length of desired tangent vector can be specified, default is 1.0.\n     *\n     * @method tangentAt\n     * @instance\n     * @memberof VEllipse\n     * @param {number} angle - The angle to get the tangent vector at.\n     * @param {number=1.0} length - [optional, default=1] The length of the returned vector.\n     */\n    tangentAt(angle, length) {\n        const normal = this.normalAt(angle, length);\n        // Rotate the normal by 90 degrees, then it is the tangent.\n        normal.b.rotate(Math.PI / 2, normal.a);\n        return normal;\n    }\n    /**\n     * Get the perimeter of this ellipse.\n     *\n     * @method perimeter\n     * @instance\n     * @memberof VEllipse\n     * @return {number}\n     */\n    perimeter() {\n        // This method does not use an iterative approximation to determine the perimeter, but it uses\n        // a wonderful closed approximation found by Srinivasa Ramanujan.\n        // Matt Parker made a neat video about it:\n        //    https://www.youtube.com/watch?v=5nW3nJhBHL0\n        const a = this.radiusH();\n        const b = this.radiusV();\n        return Math.PI * (3 * (a + b) - Math.sqrt((3 * a + b) * (a + 3 * b)));\n    }\n    /**\n     * Get the two foci of this ellipse.\n     *\n     * @method getFoci\n     * @instance\n     * @memberof VEllipse\n     * @return {Array<Vertex>} An array with two elements, the two focal points of the ellipse (foci).\n     */\n    getFoci() {\n        // https://www.mathopenref.com/ellipsefoci.html\n        const rh = this.radiusH();\n        const rv = this.radiusV();\n        const sdiff = rh * rh - rv * rv;\n        // f is the distance of each focs to the center.\n        const f = Math.sqrt(Math.abs(sdiff));\n        // Foci on x- or y-axis?\n        if (sdiff < 0) {\n            return [\n                this.center.clone().addY(f).rotate(this.rotation, this.center),\n                this.center.clone().addY(-f).rotate(this.rotation, this.center)\n            ];\n        }\n        else {\n            return [\n                this.center.clone().addX(f).rotate(this.rotation, this.center),\n                this.center.clone().addX(-f).rotate(this.rotation, this.center)\n            ];\n        }\n    }\n    /**\n     * Get equally distributed points on the outline of this ellipse.\n     *\n     * @param {number} pointCount - The number of points.\n     * @returns {Array<Vertex>}\n     */\n    getEquidistantVertices(pointCount) {\n        const angles = VEllipse.utils.equidistantVertAngles(this.radiusH(), this.radiusV(), pointCount);\n        const result = [];\n        for (var i = 0; i < angles.length; i++) {\n            result.push(this.vertAt(angles[i]));\n        }\n        return result;\n    }\n    /**\n     * Convert this ellipse into cubic Bézier curves.\n     *\n     * @param {number=3} quarterSegmentCount - The number of segments per base elliptic quarter (default is 3, min is 1).\n     * @param {number=0.666666} threshold - The Bézier threshold (default value 0.666666 approximates the ellipse with best results\n     * but you might wish to use other values)\n     * @return {Array<CubicBezierCurve>} An array of cubic Bézier curves representing this ellipse.\n     */\n    toCubicBezier(quarterSegmentCount, threshold) {\n        // Math by Luc Maisonobe\n        //    http://www.spaceroots.org/documents/ellipse/node22.html\n        // Note that ellipses with radiusH=0 or radiusV=0 cannot be represented as Bézier curves.\n        // Return a single line here (as a Bézier curve)\n        // if (Math.abs(this.radiusV()) < 0.00001) {\n        //   const radiusH = this.radiusH();\n        //   return [\n        //     new CubicBezierCurve(\n        //       this.center.clone().addX(radiusH),\n        //       this.center.clone().addX(-radiusH),\n        //       this.center.clone(),\n        //       this.center.clone()\n        //     )\n        //   ]; // TODO: test horizontal line ellipse\n        // }\n        // if (Math.abs(this.radiusH()) < 0.00001) {\n        //   const radiusV = this.radiusV();\n        //   return [\n        //     new CubicBezierCurve(\n        //       this.center.clone().addY(radiusV),\n        //       this.center.clone().addY(-radiusV),\n        //       this.center.clone(),\n        //       this.center.clone()\n        //     )\n        //   ]; // TODO: test vertical line ellipse\n        // }\n        // At least 4, but 16 seems to be a good value.\n        const segmentCount = Math.max(1, quarterSegmentCount || 3) * 4;\n        threshold = typeof threshold === \"undefined\" ? 0.666666 : threshold;\n        const radiusH = this.radiusH();\n        const radiusV = this.radiusV();\n        const curves = [];\n        const angles = VEllipse.utils.equidistantVertAngles(radiusH, radiusV, segmentCount);\n        let curAngle = angles[0];\n        let startPoint = this.vertAt(curAngle);\n        for (var i = 0; i < angles.length; i++) {\n            let nextAngle = angles[(i + 1) % angles.length];\n            let endPoint = this.vertAt(nextAngle);\n            if (Math.abs(radiusV) < 0.0001 || Math.abs(radiusH) < 0.0001) {\n                // Distorted ellipses can only be approximated by linear Bézier segments\n                let diff = startPoint.difference(endPoint);\n                let curve = new CubicBezierCurve(startPoint.clone(), endPoint.clone(), startPoint.clone().addXY(diff.x * 0.333, diff.y * 0.333), endPoint.clone().addXY(-diff.x * 0.333, -diff.y * 0.333));\n                curves.push(curve);\n            }\n            else {\n                let startTangent = this.tangentAt(curAngle);\n                let endTangent = this.tangentAt(nextAngle);\n                // Find intersection\n                let intersection = startTangent.intersection(endTangent);\n                // What if intersection is undefined?\n                // --> This *can* not happen if segmentCount > 2 and height and width of the ellipse are not zero.\n                let startDiff = startPoint.difference(intersection);\n                let endDiff = endPoint.difference(intersection);\n                let curve = new CubicBezierCurve(startPoint.clone(), endPoint.clone(), startPoint.clone().add(startDiff.scale(threshold)), endPoint.clone().add(endDiff.scale(threshold)));\n                curves.push(curve);\n            }\n            startPoint = endPoint;\n            curAngle = nextAngle;\n        }\n        return curves;\n    }\n    /**\n     * This function should invalidate any installed listeners and invalidate this object.\n     * After calling this function the object might not hold valid data any more and\n     * should not be used.\n     */\n    destroy() {\n        this.center.destroy();\n        this.axis.destroy();\n        this.isDestroyed = true;\n    }\n}\n/**\n * A static collection of ellipse-related helper functions.\n * @static\n */\nVEllipse.utils = {\n    /**\n     * Calculate a particular point on the outline of the given ellipse (center plus two radii plus angle).\n     *\n     * @name polarToCartesian\n     * @param {number} centerX - The x coordinate of the elliptic center.\n     * @param {number} centerY - The y coordinate of the elliptic center.\n     * @param {number} radiusH - The horizontal radius of the ellipse.\n     * @param {number} radiusV - The vertical radius of the ellipse.\n     * @param {number} angle - The angle (in radians) to get the desired outline point for.\n     * @reutn {XYCoords} The outlont point in absolute x-y-coordinates.\n     */\n    polarToCartesian: (centerX, centerY, radiusH, radiusV, angle) => {\n        // Tanks to Narasinham for the vertex-on-ellipse equations\n        // https://math.stackexchange.com/questions/22064/calculating-a-point-that-lies-on-an-ellipse-given-an-angle\n        var s = Math.sin(Math.PI / 2 - angle);\n        var c = Math.cos(Math.PI / 2 - angle);\n        return {\n            x: centerX + (radiusH * radiusV * s) / Math.sqrt(Math.pow(radiusH * c, 2) + Math.pow(radiusV * s, 2)),\n            y: centerY + (radiusH * radiusV * c) / Math.sqrt(Math.pow(radiusH * c, 2) + Math.pow(radiusV * s, 2))\n        };\n    },\n    /**\n     * Get the `theta` for a given `phi` (used to determine equidistant points on ellipse).\n     *\n     * @param radiusH\n     * @param radiusV\n     * @param phi\n     * @returns {number} theta\n     */\n    phiToTheta: (radiusH, radiusV, phi) => {\n        //  See https://math.stackexchange.com/questions/172766/calculating-equidistant-points-around-an-ellipse-arc\n        var tanPhi = Math.tan(phi);\n        var tanPhi2 = tanPhi * tanPhi;\n        var theta = -Math.PI / 2 + phi + Math.atan(((radiusH - radiusV) * tanPhi) / (radiusV + radiusH * tanPhi2));\n        return theta;\n    },\n    /**\n     * Get n equidistant points on the elliptic arc.\n     *\n     * @param pointCount\n     * @returns\n     */\n    equidistantVertAngles: (radiusH, radiusV, pointCount) => {\n        const angles = [];\n        for (var i = 0; i < pointCount; i++) {\n            var phi = Math.PI / 2.0 + ((Math.PI * 2) / pointCount) * i;\n            let theta = VEllipse.utils.phiToTheta(radiusH, radiusV, phi);\n            angles[i] = theta;\n        }\n        return angles;\n    }\n}; // END utils\n//# sourceMappingURL=VEllipse.js.map","/**\n * Implementation of elliptic sectors.\n * Note that sectors are constructed in clockwise direction.\n *\n * @author   Ikaros Kappler\n * @date     2021-02-26\n * @modified 2022-02-02 Added the `destroy` method.\n * @modified 2022-11-01 Tweaked the `endpointToCenterParameters` function to handle negative values, too, without errors.\n * @version  1.1.1\n */\nimport { CubicBezierCurve } from \"./CubicBezierCurve\";\nimport { geomutils } from \"./geomutils\";\nimport { Line } from \"./Line\";\nimport { UIDGenerator } from \"./UIDGenerator\";\nimport { VEllipse } from \"./VEllipse\";\nimport { Vertex } from \"./Vertex\";\n/**\n * @classdesc A class for elliptic sectors.\n *\n * @requires Line\n * @requires Vector\n * @requires VertTuple\n * @requires Vertex\n * @requires SVGSerializale\n * @requires UID\n * @requires UIDGenerator\n **/\nexport class VEllipseSector {\n    /**\n     * Create a new elliptic sector from the given ellipse and two angles.\n     *\n     * Note that the direction from start to end goes clockwise, and that start and end angle\n     * will be wrapped to [0,PI*2).\n     *\n     * @constructor\n     * @name VEllipseSector\n     * @param {VEllipse} - The underlying ellipse to use.\n     * @param {number} startAngle - The start angle of the sector.\n     * @param {numner} endAngle - The end angle of the sector.\n     */\n    constructor(ellipse, startAngle, endAngle) {\n        /**\n         * Required to generate proper CSS classes and other class related IDs.\n         **/\n        this.className = \"VEllipseSector\";\n        this.uid = UIDGenerator.next();\n        this.ellipse = ellipse;\n        this.startAngle = geomutils.wrapMinMax(startAngle, 0, Math.PI * 2);\n        this.endAngle = geomutils.wrapMinMax(endAngle, 0, Math.PI * 2);\n    }\n    /**\n     * Convert this elliptic sector into cubic Bézier curves.\n     *\n     * @param {number=3} quarterSegmentCount - The number of segments per base elliptic quarter (default is 3, min is 1).\n     * @param {number=0.666666} threshold - The Bézier threshold (default value 0.666666 approximates the ellipse with best results\n     * but you might wish to use other values)\n     * @return {Array<CubicBezierCurve>} An array of cubic Bézier curves representing the elliptic sector.\n     */\n    toCubicBezier(quarterSegmentCount, threshold) {\n        // There are at least 4 segments required (dour quarters) to approximate a whole\n        // ellipse with Bézier curves.\n        // A visually 'good' approximation should have 12; this seems to be a good value (anything multiple of 4).\n        const segmentCount = Math.max(1, quarterSegmentCount || 3) * 4;\n        threshold = typeof threshold === \"undefined\" ? 0.666666 : threshold;\n        const radiusH = this.ellipse.radiusH();\n        const radiusV = this.ellipse.radiusV();\n        var startAngle = VEllipseSector.ellipseSectorUtils.normalizeAngle(this.startAngle);\n        var endAngle = VEllipseSector.ellipseSectorUtils.normalizeAngle(this.endAngle);\n        // Find all angles inside start and end\n        var angles = VEllipseSector.ellipseSectorUtils.equidistantVertAngles(radiusH, radiusV, startAngle, endAngle, segmentCount);\n        angles = [startAngle].concat(angles).concat([endAngle]);\n        const curves = [];\n        let curAngle = angles[0];\n        let startPoint = this.ellipse.vertAt(curAngle);\n        for (var i = 0; i + 1 < angles.length; i++) {\n            let nextAngle = angles[(i + 1) % angles.length];\n            let endPoint = this.ellipse.vertAt(nextAngle);\n            let startTangent = this.ellipse.tangentAt(curAngle);\n            let endTangent = this.ellipse.tangentAt(nextAngle);\n            // Distorted ellipses can only be approximated by linear Bézier segments\n            if (Math.abs(radiusV) < 0.0001 || Math.abs(radiusH) < 0.0001) {\n                let diff = startPoint.difference(endPoint);\n                let curve = new CubicBezierCurve(startPoint.clone(), endPoint.clone(), startPoint.clone().addXY(diff.x * 0.333, diff.y * 0.333), endPoint.clone().addXY(-diff.x * 0.333, -diff.y * 0.333));\n                curves.push(curve);\n            }\n            else {\n                // Find intersection\n                let intersection = startTangent.intersection(endTangent);\n                // What if intersection is undefined?\n                // --> This *can* not happen if segmentCount > 2 and height and width of the ellipse are not zero.\n                if (intersection) {\n                    // It's VERY LIKELY hat this ALWAYS happens; it's just a typesave variant.\n                    // Intersection cannot be null.\n                    let startDiff = startPoint.difference(intersection);\n                    let endDiff = endPoint.difference(intersection);\n                    let curve = new CubicBezierCurve(startPoint.clone(), endPoint.clone(), startPoint.clone().add(startDiff.scale(threshold)), endPoint.clone().add(endDiff.scale(threshold)));\n                    curves.push(curve);\n                }\n            }\n            startPoint = endPoint;\n            curAngle = nextAngle;\n        }\n        return curves;\n    }\n    /**\n     * This function should invalidate any installed listeners and invalidate this object.\n     * After calling this function the object might not hold valid data any more and\n     * should not be used.\n     */\n    destroy() {\n        this.ellipse.destroy();\n        this.isDestroyed = true;\n    }\n}\nVEllipseSector.ellipseSectorUtils = {\n    /**\n     * Helper function to convert an elliptic section to SVG arc params (for the `d` attribute).\n     * Inspiration found at:\n     *    https://stackoverflow.com/questions/5736398/how-to-calculate-the-svg-path-for-an-arc-of-a-circle\n     *\n     * @param {boolean} options.moveToStart - If false (default=true) the initial 'Move' command will not be used.\n     * @return [ 'A', radiusH, radiusV, rotation, largeArcFlag=1|0, sweepFlag=0, endx, endy ]\n     */\n    describeSVGArc: (x, y, radiusH, radiusV, startAngle, endAngle, rotation, options) => {\n        if (typeof options === \"undefined\")\n            options = { moveToStart: true };\n        if (typeof rotation === \"undefined\")\n            rotation = 0.0;\n        // Important note: this function only works if start- and end-angle are within\n        // one whole circle [x,x+2*PI].\n        // Revelations of more than 2*PI might result in unexpected arcs.\n        // -> Use the geomutils.wrapMax( angle, 2*PI )\n        startAngle = geomutils.wrapMax(startAngle, Math.PI * 2);\n        endAngle = geomutils.wrapMax(endAngle, Math.PI * 2);\n        // Find the start- and end-point on the rotated ellipse\n        // XYCoords to Vertex (for rotation)\n        var end = new Vertex(VEllipse.utils.polarToCartesian(x, y, radiusH, radiusV, endAngle));\n        var start = new Vertex(VEllipse.utils.polarToCartesian(x, y, radiusH, radiusV, startAngle));\n        end.rotate(rotation, { x: x, y: y });\n        start.rotate(rotation, { x: x, y: y });\n        // Boolean stored as integers (0|1).\n        var diff = endAngle - startAngle;\n        var largeArcFlag;\n        if (diff < 0) {\n            largeArcFlag = Math.abs(diff) < Math.PI ? 1 : 0;\n        }\n        else {\n            largeArcFlag = Math.abs(diff) > Math.PI ? 1 : 0;\n        }\n        const sweepFlag = 1;\n        const pathData = [];\n        if (options.moveToStart) {\n            pathData.push(\"M\", start.x, start.y);\n        }\n        // Arc rotation in degrees, not radians.\n        const r2d = 180 / Math.PI;\n        pathData.push(\"A\", radiusH, radiusV, rotation * r2d, largeArcFlag, sweepFlag, end.x, end.y);\n        return pathData;\n    },\n    /**\n     * Helper function to find second-kind elliptic angles, so that the euclidean distance along the the\n     * elliptic sector is the same for all.\n     *\n     * Note that this is based on the full ellipse calculuation and start and end will be cropped; so the\n     * distance from the start angle to the first angle and/or the distance from the last angle to\n     * the end angle may be different to the others.\n     *\n     * Furthermore the computation is only possible on un-rotated ellipses; if your source ellipse has\n     * a rotation on the plane please 'rotate' the result angles afterwards to find matching angles.\n     *\n     * Returned angles are normalized to the interval `[ 0, PI*2 ]`.\n     *\n     * @param {number} radiusH - The first (horizonal) radius of the ellipse.\n     * @param {number} radiusV - The second (vertical) radius of the ellipse.\n     * @param {number} startAngle - The opening angle of your elliptic sector (please use normalized angles).\n     * @param {number} endAngle - The closing angle of your elliptic sector (please use normalized angles).\n     * @param {number} fullEllipsePointCount - The number of base segments to use from the source ellipse (12 or 16 are good numbers).\n     * @return {Array<number>} An array of n angles inside startAngle and endAngle (where n <= fullEllipsePointCount).\n     */\n    equidistantVertAngles: (radiusH, radiusV, startAngle, endAngle, fullEllipsePointCount) => {\n        var ellipseAngles = VEllipse.utils.equidistantVertAngles(radiusH, radiusV, fullEllipsePointCount);\n        ellipseAngles = ellipseAngles.map((angle) => VEllipseSector.ellipseSectorUtils.normalizeAngle(angle));\n        var angleIsInRange = (angle) => {\n            if (startAngle < endAngle)\n                return angle >= startAngle && angle <= endAngle;\n            else\n                return angle >= startAngle || (angle <= endAngle && angle >= 0);\n        };\n        // Drop all angles outside the sector\n        var ellipseAngles = ellipseAngles.filter(angleIsInRange);\n        // Now we need to sort the angles to the first one in the array is the closest to startAngle.\n        // --> find the angle that is closest to the start angle\n        var startIndex = VEllipseSector.ellipseSectorUtils.findClosestToStartAngle(startAngle, endAngle, ellipseAngles);\n        // Bring all angles into the correct order\n        //    Idea: use splice or slice here?\n        var angles = [];\n        for (var i = 0; i < ellipseAngles.length; i++) {\n            angles.push(ellipseAngles[(startIndex + i) % ellipseAngles.length]);\n        }\n        return angles;\n    },\n    findClosestToStartAngle: (startAngle, endAngle, ellipseAngles) => {\n        // Note: endAngle > 0 && startAngle > 0\n        if (startAngle > endAngle) {\n            const n = ellipseAngles.length;\n            for (var i = 0; i < n; i++) {\n                const ea = geomutils.wrapMinMax(ellipseAngles[i], 0, Math.PI * 2);\n                if (ea >= startAngle && ea >= endAngle) {\n                    return i;\n                }\n            }\n        }\n        return 0;\n    },\n    normalizeAngle: (angle) => (angle < 0 ? Math.PI * 2 + angle : angle),\n    /**\n     * Convert the elliptic arc from endpoint parameters to center parameters as described\n     * in the w3c svg arc implementation note.\n     *\n     * https://www.w3.org/TR/SVG/implnote.html#ArcConversionEndpointToCenter\n     *\n     * @param {number} x1 - The x component of the start point (end of last SVG command).\n     * @param {number} y1 - The y component of the start point (end of last SVG command).\n     * @param {number} rx - The first (horizontal) radius of the ellipse.\n     * @param {number} ry - The second (vertical) radius of the ellipse.\n     * @param {number} phi - The ellipse's rotational angle (angle of axis rotation) in radians (not in degrees as the SVG command uses!)\n     * @param {boolean} fa - The large-arc-flag (boolean, not 0 or 1).\n     * @param {boolean} fs - The sweep-flag (boolean, not 0 or 1).\n     * @param {number} x2 - The x component of the end point (end of last SVG command).\n     * @param {number} y2 - The y component of the end point (end of last SVG command).\n     * @returns\n     */\n    endpointToCenterParameters(x1, y1, rx, ry, phi, fa, fs, x2, y2) {\n        // console.log(\"endpointToCenterParameters\", x1, y1, phi, rx, ry, fa, fs, x2, y2);\n        // Thanks to\n        //    https://observablehq.com/@toja/ellipse-and-elliptical-arc-conversion\n        const abs = Math.abs;\n        const sin = Math.sin;\n        const cos = Math.cos;\n        const sqrt = Math.sqrt;\n        const pow = (n) => {\n            return n * n;\n        };\n        const sinphi = sin(phi);\n        const cosphi = cos(phi);\n        // Step 1: simplify through translation/rotation\n        const x = (cosphi * (x1 - x2)) / 2 + (sinphi * (y1 - y2)) / 2;\n        const y = (-sinphi * (x1 - x2)) / 2 + (cosphi * (y1 - y2)) / 2;\n        const px = pow(x), py = pow(y), prx = pow(rx), pry = pow(ry);\n        // correct of out-of-range radii\n        const L = px / prx + py / pry;\n        if (L > 1) {\n            rx = sqrt(L) * abs(rx);\n            ry = sqrt(L) * abs(ry);\n        }\n        else {\n            rx = abs(rx);\n            ry = abs(ry);\n        }\n        // Step 2 + 3: compute center\n        const sign = fa === fs ? -1 : 1;\n        // const M: number = sqrt((prx * pry - prx * py - pry * px) / (prx * py + pry * px)) * sign;\n        const M = sqrt(Math.abs((prx * pry - prx * py - pry * px) / (prx * py + pry * px))) * sign;\n        const _cx = (M * (rx * y)) / ry;\n        const _cy = (M * (-ry * x)) / rx;\n        const cx = cosphi * _cx - sinphi * _cy + (x1 + x2) / 2;\n        const cy = sinphi * _cx + cosphi * _cy + (y1 + y2) / 2;\n        // Step 4: Compute start and end angle\n        const center = new Vertex(cx, cy);\n        const axis = center.clone().addXY(rx, ry);\n        const ellipse = new VEllipse(center, axis, 0);\n        // console.log(\"VELLIPSE::::::\", ellipse);\n        ellipse.rotate(phi);\n        const startAngle = new Line(ellipse.center, new Vertex(x1, y1)).angle();\n        const endAngle = new Line(ellipse.center, new Vertex(x2, y2)).angle();\n        return new VEllipseSector(ellipse, startAngle - phi, endAngle - phi);\n    }\n}; // END ellipseSectorUtils\n//# sourceMappingURL=VEllipseSector.js.map","/**\n * @author   Ikaros Kappler\n * @date     2018-10-23\n * @modified 2018-11-19 Added multi-select and multi-drag.\n * @modified 2018-12-04 Added basic SVG export.\n * @modified 2018-12-09 Extended the constructor (canvas).\n * @modified 2018-12-18 Added the config.redrawOnResize param.\n * @modified 2018-12-18 Added the config.defaultCanvas{Width,Height} params.\n * @modified 2018-12-19 Added CSS scaling.\n * @modified 2018-12-28 Removed the unused 'drawLabel' param. Added the 'enableMouse' and 'enableKeys' params.\n * @modified 2018-12-29 Added the 'drawOrigin' param.\n * @modified 2018-12-29 Renamed the 'autoCenterOffset' param to 'autoAdjustOffset'. Added the params 'offsetAdjustXPercent' and 'offsetAdjustYPercent'.\n * @modified 2019-01-14 Added params 'drawBezierHandleLines' and 'drawBezierHandlePoints'. Added the 'redraw' praam to the add() function.\n * @modified 2019-01-16 Added params 'drawHandleLines' and 'drawHandlePoints'. Added the new params to the dat.gui interface.\n * @modified 2019-01-30 Added the 'Vector' type (extending the Line class).\n * @modified 2019-01-30 Added the 'PBImage' type (a wrapper for images).\n * @modified 2019-02-02 Added the 'canvasWidthFactor' and 'canvasHeightFactor' params.\n * @modified 2019-02-03 Removed the drawBackgroundImage() function, with had no purpose at all. Just add an image to the drawables-list.\n * @modified 2019-02-06 Vertices (instace of Vertex) can now be added. Added the 'draggable' attribute to the vertex attributes.\n * @modified 2019-02-10 Fixed a draggable-bug in PBImage handling (scaling was not possible).\n * @modified 2019-02-10 Added the 'enableTouch' option (default is true).\n * @modified 2019-02-14 Added the console for debugging (setConsole(object)).\n * @modified 2019-02-19 Added two new constants: DEFAULT_CLICK_TOLERANCE and DEFAULT_TOUCH_TOLERANCE.\n * @modified 2019-02-19 Added the second param to the locatePointNear(Vertex,Number) function.\n * @modified 2019-02-20 Removed the 'loadFile' entry from the GUI as it was experimental and never in use.\n * @modified 2019-02-23 Removed the 'rebuild' function as it had no purpose.\n * @modified 2019-02-23 Added scaling of the click-/touch-tolerance with the CSS scale.\n * @modified 2019-03-23 Added JSDoc tags. Changed the default value of config.drawOrigin to false.\n * @modified 2019-04-03 Fixed the touch-drag position detection for canvas elements that are not located at document position (0,0).\n * @modified 2019-04-03 Tweaked the fit-to-parent function to work with paddings and borders.\n * @modified 2019-04-28 Added the preClear callback param (called before the canvas was cleared on redraw and before any elements are drawn).\n * @modified 2019-09-18 Added basics for WebGL support (strictly experimental).\n * @modified 2019-10-03 Added the .beginDrawCycle call in the redraw function.\n * @modified 2019-11-06 Added fetch.num, fetch.val, fetch.bool, fetch.func functions.\n * @modified 2019-11-13 Fixed an issue with the mouse-sensitive area around vertices (were affected by zoom).\n * @modified 2019-11-13 Added the 'enableMouseWheel' param.\n * @modified 2019-11-18 Added the Triangle class as a regular drawable element.\n * @modified 2019-11-18 The add function now works with arrays, too.\n * @modified 2019-11-18 Added the _handleColor helper function to determine the render color of non-draggable vertices.\n * @modified 2019-11-19 Fixed a bug in the resizeCanvas function; retina resolution was not possible.\n * @modified 2019-12-04 Added relative positioned zooming.\n * @modified 2019-12-04 Added offsetX and offsetY params.\n * @modified 2019-12-04 Added an 'Set to fullsize retina' button to the GUI config.\n * @modified 2019-12-07 Added the drawConfig for lines, polygons, ellipse, triangles, bezier curves and image control lines.\n * @modified 2019-12-08 Fixed a css scale bug in the viewport() function.\n * @modified 2019-12-08 Added the drawconfig UI panel (line colors and line widths).\n * @modified 2020-02-06 Added handling for the end- and end-control-points of non-cirular Bézier paths (was still missing).\n * @modified 2020-02-06 Fixed a drag-amount bug in the move handling of end points of Bezier paths (control points was not properly moved when non circular).\n * @modified 2020-03-28 Ported this class from vanilla-JS to Typescript.\n * @modified 2020-03-29 Fixed the enableSVGExport flag (read enableEport before).\n * @modified 2020-05-09 Included the Cirlcle class.\n * @modified 2020-06-22 Added the rasterScaleX and rasterScaleY config params.\n * @modified 2020-06-03 Fixed the selectedVerticesOnPolyon(Polygon) function: non-selectable vertices were selected too, before.\n * @modified 2020-07-06 Replacing Touchy.js by AlloyFinger.js\n * @modified 2020-07-27 Added the getVertexNear(XYCoords,number) function\n * @modified 2020-07-27 Extended the remove(Drawable) function: vertices are now removed, too.\n * @modified 2020-07-28 Added PlotBoilerplate.revertMousePosition(number,number) –  the inverse function of transformMousePosition(...).\n * @modified 2020-07-31 Added PlotBoilerplate.getDraggedElementCount() to check wether any elements are currently being dragged.\n * @modified 2020-08-19 Added the VertexAttributes.visible attribute to make vertices invisible.\n * @modified 2020-11-17 Added pure click handling (no dragEnd and !wasMoved jiggliny any more) to the PlotBoilerplate.\n * @modified 2020-12-11 Added the `removeAll(boolean)` function.\n * @modified 2020-12-17 Added the `CircleSector` drawable.\n * @modified 2021-01-04 Avoiding multiple redraw call on adding multiple Drawables (array).\n * @modified 2021-01-08 Added param `draw:DraLib<void>` to the methods `drawVertices`, `drawGrid` and `drawSelectPolygon`.\n * @modified 2021-01-08 Added the customizable `drawAll(...)` function.\n * @modified 2021-01-09 Added the `drawDrawable(...)` function.\n * @modified 2021-01-10 Added the `eventCatcher` element (used to track mouse events on SVGs).\n * @modified 2021-01-26 Fixed SVG resizing.\n * @modified 2021-01-26 Replaced the old SVGBuilder by the new `drawutilssvg` library.\n * @modified 2021-02-08 Fixed a lot of es2015 compatibility issues.\n * @modified 2021-02-18 Adding `adjustOffset(boolean)` function.\n * @modified 2021-03-01 Updated the `PlotBoilerplate.draw(...)` function: ellipses are now rotate-able.\n * @modified 2021-03-03 Added the `VEllipseSector` drawable.\n * @modified 2021-03-29 Clearing `currentClassName` and `currentId` after drawing each drawable.\n * @modified 2021-04-25 Extending `remove` to accept arrays of drawables.\n * @modified 2021-11-16 Adding the `PBText` drawable.\n * @modified 2022-08-01 Added `title` to the params.\n * @modified 2022-10-25 Added the `origin` to the default draw config.\n * @modified 2022-11-06 Adding an XML declaration to the SVG export routine.\n * @modified 2022-11-23 Added the `drawRaster` (default=true) option to the config/drawconfig.\n * @modified 2023-02-04 Fixed a bug in the `drawDrawable` function; fill's current classname was not set.\n * @modified 2023-02-10 Fixing an issue of the `style.position` setting when `fitToParent=true` from `absolute` to `static` (default).\n * @modified 2023-02-10 Cleaning up most type errors in the main class (mostly null checks).\n * @modified 2023-02-10 Adding `enableZoom` and `enablePan` (both default true) to have the option to disable these functions.\n * @version  1.17.2\n *\n * @file PlotBoilerplate\n * @fileoverview The main class.\n * @public\n **/\nvar _a;\nimport AlloyFinger from \"alloyfinger-typescript\";\nimport { drawutils } from \"./draw\";\nimport { drawutilsgl } from \"./drawgl\";\nimport { drawutilssvg } from \"./drawutilssvg\";\nimport { BezierPath } from \"./BezierPath\";\nimport { Bounds } from \"./Bounds\";\nimport { Circle } from \"./Circle\";\nimport { CircleSector } from \"./CircleSector\";\nimport { Grid } from \"./Grid\";\nimport { KeyHandler } from \"./KeyHandler\";\nimport { Line } from \"./Line\";\nimport { MouseHandler } from \"./MouseHandler\";\nimport { PBImage } from \"./PBImage\";\nimport { Polygon } from \"./Polygon\";\nimport { Triangle } from \"./Triangle\";\nimport { VEllipse } from \"./VEllipse\";\nimport { VEllipseSector } from \"./VEllipseSector\";\nimport { Vector } from \"./Vector\";\nimport { Vertex } from \"./Vertex\";\nimport { VertexAttr } from \"./VertexAttr\";\nimport { PBText } from \"./PBText\";\n/**\n * @classdesc The main class of the PlotBoilerplate.\n *\n * @requires Vertex\n * @requires Line\n * @requires Vector\n * @requires Polygon\n * @requires PBImage\n * @requires VEllipse\n * @requires Circle\n * @requires MouseHandler\n * @requires KeyHandler\n * @requires VertexAttr\n * @requires CubicBezierCurve\n * @requires BezierPath\n * @requires Drawable\n * @requires DrawConfig\n * @requires IHooks\n * @requires PBParams\n * @requires Triangle\n * @requires drawutils\n * @requires drawutilsgl\n * @requires SVGSerializable\n * @requires XYCoords\n * @requires XYDimension\n */\nexport class PlotBoilerplate {\n    /**\n     * The constructor.\n     *\n     * @constructor\n     * @name PlotBoilerplate\n     * @public\n     * @param {object} config={} - The configuration.\n     * @param {HTMLCanvasElement} config.canvas - Your canvas element in the DOM (required).\n     * @param {boolean=} [config.fullSize=true] - If set to true the canvas will gain full window size.\n     * @param {boolean=} [config.fitToParent=true] - If set to true the canvas will gain the size of its parent container (overrides fullSize).\n     * @param {number=}  [config.scaleX=1.0] - The initial x-zoom. Default is 1.0.\n     * @param {number=}  [config.scaleY=1.0] - The initial y-zoom. Default is 1.0.\n     * @param {number=}  [config.offsetX=1.0] - The initial x-offset. Default is 0.0. Note that autoAdjustOffset=true overrides these values.\n     * @param {number=}  [config.offsetY=1.0] - The initial y-offset. Default is 0.0. Note that autoAdjustOffset=true overrides these values.\n     * @param {boolean=} [config.rasterGrid=true] - If set to true the background grid will be drawn rastered.\n     * @param {boolean=} [config.rasterScaleX=1.0] - Define the default horizontal raster scale (default=1.0).\n     * @param {boolean=} [config.rasterScaleY=1.0] - Define the default vertical raster scale (default=1.0).\n     * @param {number=}  [config.rasterAdjustFactor=1.0] - The exponential limit for wrapping down the grid. (2.0 means: halve the grid each 2.0*n zoom step).\n     * @param {boolean=} [config.drawOrigin=false] - Draw a crosshair at (0,0).\n     * @param {boolean=} [config.autoAdjustOffset=true] -  When set to true then the origin of the XY plane will\n     *                         be re-adjusted automatically (see the params\n     *                         offsetAdjust{X,Y}Percent for more).\n     * @param {number=}  [config.offsetAdjustXPercent=50] - The x-fallback position for the origin after\n     *                         resizing the canvas.\n     * @param {number=}  [config.offsetAdjustYPercent=50] - The y-fallback position for the origin after\n     *                         resizing the canvas.\n     * @param {number=}  [config.defaultCanvasWidth=1024] - The canvas size fallback (width) if no automatic resizing\n     *                         is switched on.\n     * @param {number=}  [config.defaultCanvasHeight=768] - The canvas size fallback (height) if no automatic resizing\n     *                         is switched on.\n     * @param {number=}  [config.canvasWidthFactor=1.0] - Scaling factor (width) upon the canvas size.\n     *                         In combination with cssScale{X,Y} this can be used to obtain\n     *                         sub pixel resolutions for retina displays.\n     * @param {number=}  [config.canvasHeightFactor=1.0] - Scaling factor (height) upon the canvas size.\n     *                         In combination with cssScale{X,Y} this can be used to obtain\n     *                         sub pixel resolutions for retina displays.\n     * @param {number=}  [config.cssScaleX=1.0] - Visually resize the canvas (horizontally) using CSS transforms (scale).\n     * @param {number=}  [config.cssScaleY=1.0] - Visually resize the canvas (vertically) using CSS transforms (scale).\n     * @param {boolan=}  [config.cssUniformScale=true] - CSS scale x and y obtaining aspect ratio.\n     * @param {boolean=} [config.autoDetectRetina=true] - When set to true (default) the canvas will try to use the display's pixel ratio.\n     * @param {string=}  [config.backgroundColor=#ffffff] - The backround color.\n     * @param {boolean=} [config.redrawOnResize=true] - Switch auto-redrawing on resize on/off (some applications\n     *                         might want to prevent automatic redrawing to avoid data loss from the draw buffer).\n     * @param {boolean=} [config.drawBezierHandleLines=true] - Indicates if Bézier curve handles should be drawn (used for\n     *                         editors, no required in pure visualizations).\n     * @param {boolean=} [config.drawBezierHandlePoints=true] - Indicates if Bézier curve handle points should be drawn.\n     * @param {function=} [config.preClear=null] - A callback function that will be triggered just before the\n     *                         draw function clears the canvas (before anything else was drawn).\n     * @param {function=} [config.preDraw=null] - A callback function that will be triggered just before the draw\n     *                         function starts.\n     * @param {function=} [config.postDraw=null] - A callback function that will be triggered right after the drawing\n     *                         process finished.\n     * @param {boolean=} [config.enableMouse=true] - Indicates if the application should handle mouse events for you.\n     * @param {boolean=} [config.enableTouch=true] - Indicates if the application should handle touch events for you.\n     * @param {boolean=} [config.enableKeys=true] - Indicates if the application should handle key events for you.\n     * @param {boolean=} [config.enableMouseWheel=true] - Indicates if the application should handle mouse wheel events for you.\n     * @param {boolean=} [config.enablePan=true] - (default true) Set to false if you want to disable panning completely.\n     * @param {boolean=} [config.enableZoom=true] - (default true) Set to false if you want to disable zooming completely.\n     * @param {boolean=} [config.enableGL=false] - Indicates if the application should use the experimental WebGL features (not recommended).\n     * @param {boolean=} [config.enableSVGExport=true] - Indicates if the SVG export should be enabled (default is true).\n     *                                                   Note that changes from the postDraw hook might not be visible in the export.\n     * @param {string=} [config.title=null] - Specify any hover tile here. It will be attached as a `title` attribute to the most elevated element.\n     */\n    constructor(config) {\n        var _a, _b;\n        /**\n         * A discrete timestamp to identify single render cycles.\n         * Note that using system time milliseconds is not a safe way to identify render frames, as on modern powerful machines\n         * multiple frames might be rendered within each millisecond.\n         * @member {number}\n         * @memberof plotboilerplate\n         * @instance\n         * @private\n         */\n        this.renderTime = 0;\n        // This should be in some static block ...\n        VertexAttr.model = {\n            bezierAutoAdjust: false,\n            renderTime: 0,\n            selectable: true,\n            isSelected: false,\n            draggable: true,\n            visible: true\n        };\n        if (typeof config.canvas == \"undefined\") {\n            throw \"No canvas specified.\";\n        }\n        /**\n         * A global config that's attached to the dat.gui control interface.\n         *\n         * @member {Object}\n         * @memberof PlotBoilerplate\n         * @instance\n         */\n        const f = PlotBoilerplate.utils.fetch;\n        this.config = {\n            canvas: config.canvas,\n            fullSize: f.val(config, \"fullSize\", true),\n            fitToParent: f.bool(config, \"fitToParent\", true),\n            scaleX: f.num(config, \"scaleX\", 1.0),\n            scaleY: f.num(config, \"scaleY\", 1.0),\n            offsetX: f.num(config, \"offsetX\", 0.0),\n            offsetY: f.num(config, \"offsetY\", 0.0),\n            rasterGrid: f.bool(config, \"rasterGrid\", true),\n            drawRaster: f.bool(config, \"drawRaster\", true),\n            rasterScaleX: f.num(config, \"rasterScaleX\", 1.0),\n            rasterScaleY: f.num(config, \"rasterScaleY\", 1.0),\n            rasterAdjustFactor: f.num(config, \"rasterAdjustdFactror\", 2.0),\n            drawOrigin: f.bool(config, \"drawOrigin\", false),\n            autoAdjustOffset: f.val(config, \"autoAdjustOffset\", true),\n            offsetAdjustXPercent: f.num(config, \"offsetAdjustXPercent\", 50),\n            offsetAdjustYPercent: f.num(config, \"offsetAdjustYPercent\", 50),\n            backgroundColor: config.backgroundColor || \"#ffffff\",\n            redrawOnResize: f.bool(config, \"redrawOnResize\", true),\n            defaultCanvasWidth: f.num(config, \"defaultCanvasWidth\", PlotBoilerplate.DEFAULT_CANVAS_WIDTH),\n            defaultCanvasHeight: f.num(config, \"defaultCanvasHeight\", PlotBoilerplate.DEFAULT_CANVAS_HEIGHT),\n            canvasWidthFactor: f.num(config, \"canvasWidthFactor\", 1.0),\n            canvasHeightFactor: f.num(config, \"canvasHeightFactor\", 1.0),\n            cssScaleX: f.num(config, \"cssScaleX\", 1.0),\n            cssScaleY: f.num(config, \"cssScaleY\", 1.0),\n            cssUniformScale: f.bool(config, \"cssUniformScale\", true),\n            saveFile: () => {\n                _self.hooks.saveFile(_self);\n            },\n            setToRetina: () => {\n                _self._setToRetina();\n            },\n            autoDetectRetina: f.bool(config, \"autoDetectRetina\", true),\n            enableSVGExport: f.bool(config, \"enableSVGExport\", true),\n            // Listeners/observers\n            preClear: f.func(config, \"preClear\", null),\n            preDraw: f.func(config, \"preDraw\", null),\n            postDraw: f.func(config, \"postDraw\", null),\n            // Interaction\n            enableMouse: f.bool(config, \"enableMouse\", true),\n            enableTouch: f.bool(config, \"enableTouch\", true),\n            enableKeys: f.bool(config, \"enableKeys\", true),\n            enableMouseWheel: f.bool(config, \"enableMouseWheel\", true),\n            enableZoom: f.bool(config, \"enableZoom\", true),\n            enablePan: f.bool(config, \"enablePan\", true),\n            // Experimental (and unfinished)\n            enableGL: f.bool(config, \"enableGL\", false)\n        }; // END confog\n        /**\n         * Configuration for drawing things.\n         *\n         * @member {Object}\n         * @memberof PlotBoilerplate\n         * @instance\n         */\n        this.drawConfig = {\n            drawVertices: true,\n            drawBezierHandleLines: f.bool(config, \"drawBezierHandleLines\", true),\n            drawBezierHandlePoints: f.bool(config, \"drawBezierHandlePoints\", true),\n            drawHandleLines: f.bool(config, \"drawHandleLines\", true),\n            drawHandlePoints: f.bool(config, \"drawHandlePoints\", true),\n            drawGrid: f.bool(config, \"drawGrid\", true),\n            drawRaster: f.bool(config, \"drawRaster\", true),\n            bezier: {\n                color: \"#00a822\",\n                lineWidth: 2,\n                handleLine: {\n                    color: \"rgba(180,180,180,0.5)\",\n                    lineWidth: 1\n                },\n                pathVertex: {\n                    color: \"#B400FF\",\n                    lineWidth: 1,\n                    fill: true\n                },\n                controlVertex: {\n                    color: \"#B8D438\",\n                    lineWidth: 1,\n                    fill: true\n                }\n            },\n            polygon: {\n                color: \"#0022a8\",\n                lineWidth: 1\n            },\n            triangle: {\n                color: \"#6600ff\",\n                lineWidth: 1\n            },\n            ellipse: {\n                color: \"#2222a8\",\n                lineWidth: 1\n            },\n            ellipseSector: {\n                color: \"#a822a8\",\n                lineWidth: 2\n            },\n            circle: {\n                color: \"#22a8a8\",\n                lineWidth: 2\n            },\n            circleSector: {\n                color: \"#2280a8\",\n                lineWidth: 1\n            },\n            vertex: {\n                color: \"#a8a8a8\",\n                lineWidth: 1\n            },\n            selectedVertex: {\n                color: \"#c08000\",\n                lineWidth: 2\n            },\n            line: {\n                color: \"#a844a8\",\n                lineWidth: 1\n            },\n            vector: {\n                color: \"#ff44a8\",\n                lineWidth: 1\n            },\n            image: {\n                color: \"#a8a8a8\",\n                lineWidth: 1\n            },\n            text: {\n                color: \"rgba(192,0,128,0.5)\",\n                lineWidth: 1,\n                fill: true,\n                anchor: true\n            },\n            origin: {\n                color: \"#000000\"\n            }\n        }; // END drawConfig\n        // +---------------------------------------------------------------------------------\n        // | Object members.\n        // +-------------------------------\n        this.grid = new Grid(new Vertex(0, 0), new Vertex(50, 50));\n        this.canvasSize = { width: PlotBoilerplate.DEFAULT_CANVAS_WIDTH, height: PlotBoilerplate.DEFAULT_CANVAS_HEIGHT };\n        const canvasElement = typeof config.canvas == \"string\" ? document.querySelector(config.canvas) : config.canvas;\n        // Which renderer to use: Canvas2D, WebGL (experimental) or SVG?\n        if (canvasElement.tagName.toLowerCase() === \"canvas\") {\n            this.canvas = canvasElement;\n            this.eventCatcher = this.canvas;\n            if (this.config.enableGL && typeof drawutilsgl === \"undefined\") {\n                console.warn(`Cannot use webgl. Package was compiled without experimental gl support. Please use plotboilerplate-glsupport.min.js instead.`);\n                console.warn(`Disabling GL and falling back to Canvas2D.`);\n                this.config.enableGL = false;\n            }\n            if (this.config.enableGL) {\n                // Override the case 'null' here. If GL is not supported, well then nothing works.\n                const ctx = this.canvas.getContext(\"webgl\"); // webgl-experimental?\n                this.draw = new drawutilsgl(ctx, false);\n                // PROBLEM: same instance of fill and draw when using WebGL.\n                //          Shader program cannot be duplicated on the same context.\n                this.fill = this.draw.copyInstance(true);\n                console.warn(\"Initialized with experimental mode enableGL=true. Note that this is not yet fully implemented.\");\n            }\n            else {\n                // Override the case 'null' here. If context creation is not supported, well then nothing works.\n                const ctx = this.canvas.getContext(\"2d\");\n                this.draw = new drawutils(ctx, false);\n                this.fill = new drawutils(ctx, true);\n            }\n        }\n        else if (canvasElement.tagName.toLowerCase() === \"svg\") {\n            if (typeof drawutilssvg === \"undefined\")\n                throw `The svg draw library is not yet integrated part of PlotBoilerplate. Please include ./src/js/utils/helpers/drawutils.svg into your document.`;\n            this.canvas = canvasElement;\n            this.draw = new drawutilssvg(this.canvas, new Vertex(), // offset\n            new Vertex(), // scale\n            this.canvasSize, false, // fillShapes=false\n            this.drawConfig, false // isSecondary=false\n            );\n            this.fill = this.draw.copyInstance(true); // fillShapes=true\n            if (this.canvas.parentElement) {\n                this.eventCatcher = document.createElement(\"div\");\n                this.eventCatcher.style.position = \"absolute\";\n                this.eventCatcher.style.left = \"0\";\n                this.eventCatcher.style.top = \"0\";\n                this.eventCatcher.style.cursor = \"pointer\";\n                this.canvas.parentElement.style.position = \"relative\";\n                this.canvas.parentElement.appendChild(this.eventCatcher);\n            }\n            else {\n                this.eventCatcher = document.body;\n            }\n        }\n        else {\n            throw \"Element is neither a canvas nor an svg element.\";\n        }\n        // At this point the event cacher element is deinfed and located at highest elevation.\n        // Set `title` attribut?\n        if (config.title) {\n            this.eventCatcher.setAttribute(\"title\", config.title);\n        }\n        this.draw.scale.set((_a = this.config.scaleX) !== null && _a !== void 0 ? _a : 1.0, this.config.scaleY);\n        this.fill.scale.set((_b = this.config.scaleX) !== null && _b !== void 0 ? _b : 1.0, this.config.scaleY);\n        this.vertices = [];\n        this.selectPolygon = null;\n        this.draggedElements = [];\n        this.drawables = [];\n        this.console = console;\n        this.hooks = {\n            // This is changable from the outside\n            saveFile: PlotBoilerplate._saveFile\n        };\n        var _self = this;\n        globalThis.addEventListener(\"resize\", () => _self.resizeCanvas());\n        this.resizeCanvas();\n        if (config.autoDetectRetina) {\n            this._setToRetina();\n        }\n        this.installInputListeners();\n        // Apply the configured CSS scale.\n        this.updateCSSscale();\n        // Init\n        this.redraw();\n        // Gain focus\n        this.canvas.focus();\n    } // END constructor\n    /**\n     * This function opens a save-as file dialog and – once an output file is\n     * selected – stores the current canvas contents as an SVG image.\n     *\n     * It is the default hook for saving files and can be overwritten.\n     *\n     * @method _saveFile\n     * @instance\n     * @memberof PlotBoilerplate\n     * @return {void}\n     * @private\n     **/\n    static _saveFile(pb) {\n        // Create fake SVG node\n        const svgNode = document.createElementNS(\"http://www.w3.org/2000/svg\", \"svg\");\n        // Draw everything to fake node.\n        var tosvgDraw = new drawutilssvg(svgNode, pb.draw.offset, pb.draw.scale, pb.canvasSize, false, // fillShapes=false\n        pb.drawConfig);\n        var tosvgFill = tosvgDraw.copyInstance(true); // fillShapes=true\n        tosvgDraw.beginDrawCycle(0);\n        tosvgFill.beginDrawCycle(0);\n        if (pb.config.preClear) {\n            pb.config.preClear();\n        }\n        tosvgDraw.clear(pb.config.backgroundColor || \"white\");\n        if (pb.config.preDraw) {\n            pb.config.preDraw(tosvgDraw, tosvgFill);\n        }\n        pb.drawAll(0, tosvgDraw, tosvgFill);\n        pb.drawVertices(0, tosvgDraw);\n        if (pb.config.postDraw)\n            pb.config.postDraw(tosvgDraw, tosvgFill);\n        tosvgDraw.endDrawCycle(0);\n        tosvgFill.endDrawCycle(0);\n        // Full support in all browsers \\o/\n        //    https://caniuse.com/xml-serializer\n        var serializer = new XMLSerializer();\n        var svgCode = serializer.serializeToString(svgNode);\n        // Add: '<?xml version=\"1.0\" encoding=\"utf-8\"?>\\n' ?\n        var blob = new Blob(['<?xml version=\"1.0\" encoding=\"utf-8\"?>\\n' + svgCode], { type: \"image/svg;charset=utf-8\" });\n        // See documentation for FileSaver.js for usage.\n        //    https://github.com/eligrey/FileSaver.js\n        if (typeof globalThis[\"saveAs\"] !== \"function\")\n            throw \"Cannot save file; did you load the ./utils/savefile helper function and the eligrey/SaveFile library?\";\n        var _saveAs = globalThis[\"saveAs\"];\n        _saveAs(blob, \"plotboilerplate.svg\");\n    }\n    /**\n     * This function sets the canvas resolution to factor 2.0 (or the preferred pixel ratio of your device) for retina displays.\n     * Please not that in non-GL mode this might result in very slow rendering as the canvas buffer size may increase.\n     *\n     * @method _setToRetina\n     * @instance\n     * @memberof PlotBoilerplate\n     * @return {void}\n     * @private\n     **/\n    _setToRetina() {\n        this.config.autoDetectRetina = true;\n        const pixelRatio = globalThis.devicePixelRatio || 1;\n        this.config.cssScaleX = this.config.cssScaleY = 1.0 / pixelRatio;\n        this.config.canvasWidthFactor = this.config.canvasHeightFactor = pixelRatio;\n        this.resizeCanvas();\n        this.updateCSSscale();\n    }\n    /**\n     * Set the current zoom and draw offset to fit the given bounds.\n     *\n     * This method currently restores the aspect zoom ratio.\n     *\n     **/\n    fitToView(bounds) {\n        const canvasCenter = new Vertex(this.canvasSize.width / 2.0, this.canvasSize.height / 2.0);\n        const canvasRatio = this.canvasSize.width / this.canvasSize.height;\n        const ratio = bounds.width / bounds.height;\n        // Find the new draw offset\n        const center = new Vertex(bounds.max.x - bounds.width / 2.0, bounds.max.y - bounds.height / 2.0)\n            .inv()\n            .addXY(this.canvasSize.width / 2.0, this.canvasSize.height / 2.0);\n        this.setOffset(center);\n        if (canvasRatio < ratio) {\n            const newUniformZoom = this.canvasSize.width / bounds.width;\n            this.setZoom(newUniformZoom, newUniformZoom, canvasCenter);\n        }\n        else {\n            const newUniformZoom = this.canvasSize.height / bounds.height;\n            this.setZoom(newUniformZoom, newUniformZoom, canvasCenter);\n        }\n        this.redraw();\n    }\n    /**\n     * Set the console for this instance.\n     *\n     * @method setConsole\n     * @param {Console} con - The new console object (default is globalThis.console).\n     * @instance\n     * @memberof PlotBoilerplate\n     * @return {void}\n     **/\n    setConsole(con) {\n        this.console = con;\n    }\n    /**\n     * Update the CSS scale for the canvas depending onf the cssScale{X,Y} settings.<br>\n     * <br>\n     * This function is usually only used inernally.\n     *\n     * @method updateCSSscale\n     * @instance\n     * @memberof PlotBoilerplate\n     * @return {void}\n     * @private\n     **/\n    updateCSSscale() {\n        var _a, _b, _c, _d;\n        if (this.config.cssUniformScale) {\n            PlotBoilerplate.utils.setCSSscale(this.canvas, (_a = this.config.cssScaleX) !== null && _a !== void 0 ? _a : 1.0, (_b = this.config.cssScaleX) !== null && _b !== void 0 ? _b : 1.0);\n        }\n        else {\n            PlotBoilerplate.utils.setCSSscale(this.canvas, (_c = this.config.cssScaleX) !== null && _c !== void 0 ? _c : 1.0, (_d = this.config.cssScaleY) !== null && _d !== void 0 ? _d : 1.0);\n        }\n    }\n    /**\n     * Add a drawable object.<br>\n     * <br>\n     * This must be either:<br>\n     * <pre>\n     *  * a Vertex\n     *  * a Line\n     *  * a Vector\n     *  * a VEllipse\n     *  * a VEllipseSector\n     *  * a Circle\n     *  * a Polygon\n     *  * a Triangle\n     *  * a BezierPath\n     *  * a BPImage\n     * </pre>\n     *\n     * @param {Drawable|Drawable[]} drawable - The drawable (of one of the allowed class instance) to add.\n     * @param {boolean} [redraw=true] - If true the function will trigger redraw after the drawable(s) was/were added.\n     * @method add\n     * @instance\n     * @memberof PlotBoilerplate\n     * @return {void}\n     **/\n    add(drawable, redraw) {\n        if (Array.isArray(drawable)) {\n            const arr = drawable;\n            for (var i = 0; i < arr.length; i++) {\n                this.add(arr[i], false);\n            }\n        }\n        else if (drawable instanceof Vertex) {\n            this.drawables.push(drawable);\n            this.vertices.push(drawable);\n        }\n        else if (drawable instanceof Line) {\n            // Add some lines\n            this.drawables.push(drawable);\n            this.vertices.push(drawable.a);\n            this.vertices.push(drawable.b);\n        }\n        else if (drawable instanceof Vector) {\n            this.drawables.push(drawable);\n            this.vertices.push(drawable.a);\n            this.vertices.push(drawable.b);\n        }\n        else if (drawable instanceof VEllipse) {\n            this.vertices.push(drawable.center);\n            this.vertices.push(drawable.axis);\n            this.drawables.push(drawable);\n            drawable.center.listeners.addDragListener((event) => {\n                drawable.axis.add(event.params.dragAmount);\n            });\n        }\n        else if (drawable instanceof VEllipseSector) {\n            this.vertices.push(drawable.ellipse.center);\n            this.vertices.push(drawable.ellipse.axis);\n            this.drawables.push(drawable);\n            drawable.ellipse.center.listeners.addDragListener((event) => {\n                drawable.ellipse.axis.add(event.params.dragAmount);\n            });\n        }\n        else if (drawable instanceof Circle) {\n            this.vertices.push(drawable.center);\n            this.drawables.push(drawable);\n        }\n        else if (drawable instanceof CircleSector) {\n            this.vertices.push(drawable.circle.center);\n            this.drawables.push(drawable);\n        }\n        else if (drawable instanceof Polygon) {\n            this.drawables.push(drawable);\n            for (var i = 0; i < drawable.vertices.length; i++) {\n                this.vertices.push(drawable.vertices[i]);\n            }\n        }\n        else if (drawable instanceof Triangle) {\n            this.drawables.push(drawable);\n            this.vertices.push(drawable.a);\n            this.vertices.push(drawable.b);\n            this.vertices.push(drawable.c);\n        }\n        else if (drawable instanceof BezierPath) {\n            this.drawables.push(drawable);\n            const bezierPath = drawable;\n            for (var i = 0; i < bezierPath.bezierCurves.length; i++) {\n                if (!drawable.adjustCircular && i == 0) {\n                    this.vertices.push(bezierPath.bezierCurves[i].startPoint);\n                }\n                this.vertices.push(bezierPath.bezierCurves[i].endPoint);\n                this.vertices.push(bezierPath.bezierCurves[i].startControlPoint);\n                this.vertices.push(bezierPath.bezierCurves[i].endControlPoint);\n                bezierPath.bezierCurves[i].startControlPoint.attr.selectable = false;\n                bezierPath.bezierCurves[i].endControlPoint.attr.selectable = false;\n            }\n            PlotBoilerplate.utils.enableBezierPathAutoAdjust(drawable);\n        }\n        else if (drawable instanceof PBImage) {\n            this.vertices.push(drawable.upperLeft);\n            this.vertices.push(drawable.lowerRight);\n            this.drawables.push(drawable);\n            // Todo: think about a IDragEvent interface\n            drawable.upperLeft.listeners.addDragListener((e) => {\n                drawable.lowerRight.add(e.params.dragAmount);\n            });\n            drawable.lowerRight.attr.selectable = false;\n        }\n        else if (drawable instanceof PBText) {\n            this.vertices.push(drawable.anchor);\n            this.drawables.push(drawable);\n            drawable.anchor.attr.selectable = false;\n        }\n        else {\n            throw \"Cannot add drawable of unrecognized type: \" + typeof drawable + \".\";\n        }\n        // This is a workaround for backwards compatibility when the 'redraw' param was not yet present.\n        if (redraw || typeof redraw == \"undefined\")\n            this.redraw();\n    }\n    /**\n     * Remove a drawable object.<br>\n     * <br>\n     * This must be either:<br>\n     * <pre>\n     *  * a Vertex\n     *  * a Line\n     *  * a Vector\n     *  * a VEllipse\n     *  * a Circle\n     *  * a Polygon\n     *  * a BezierPath\n     *  * a BPImage\n     *  * a Triangle\n     * </pre>\n     *\n     * @param {Drawable|Array<Drawable>} drawable - The drawable (of one of the allowed class instance) to remove.\n     * @param {boolean} [redraw=false]\n     * @method remove\n     * @instance\n     * @memberof PlotBoilerplate\n     * @return {void}\n     **/\n    remove(drawable, redraw, removeWithVertices) {\n        if (Array.isArray(drawable)) {\n            for (var i = 0; i < drawable.length; i++) {\n                this.remove(drawable[i], false, removeWithVertices);\n            }\n            if (redraw) {\n                this.redraw();\n            }\n            return;\n        }\n        if (drawable instanceof Vertex) {\n            this.removeVertex(drawable, false);\n            if (redraw) {\n                this.redraw();\n            }\n        }\n        for (var i = 0; i < this.drawables.length; i++) {\n            if (this.drawables[i] === drawable || this.drawables[i].uid === drawable.uid) {\n                this.drawables.splice(i, 1);\n                if (removeWithVertices) {\n                    // Check if some listeners need to be removed\n                    if (drawable instanceof Line) {\n                        // Add some lines\n                        this.removeVertex(drawable.a, false);\n                        this.removeVertex(drawable.b, false);\n                    }\n                    else if (drawable instanceof Vector) {\n                        this.removeVertex(drawable.a, false);\n                        this.removeVertex(drawable.b, false);\n                    }\n                    else if (drawable instanceof VEllipse) {\n                        this.removeVertex(drawable.center, false);\n                        this.removeVertex(drawable.axis, false);\n                    }\n                    else if (drawable instanceof VEllipseSector) {\n                        this.removeVertex(drawable.ellipse.center);\n                        this.removeVertex(drawable.ellipse.axis);\n                    }\n                    else if (drawable instanceof Circle) {\n                        this.removeVertex(drawable.center, false);\n                    }\n                    else if (drawable instanceof CircleSector) {\n                        this.removeVertex(drawable.circle.center, false);\n                    }\n                    else if (drawable instanceof Polygon) {\n                        // for( var i in drawable.vertices )\n                        for (var i = 0; i < drawable.vertices.length; i++)\n                            this.removeVertex(drawable.vertices[i], false);\n                    }\n                    else if (drawable instanceof Triangle) {\n                        this.removeVertex(drawable.a, false);\n                        this.removeVertex(drawable.b, false);\n                        this.removeVertex(drawable.c, false);\n                    }\n                    else if (drawable instanceof BezierPath) {\n                        for (var i = 0; i < drawable.bezierCurves.length; i++) {\n                            this.removeVertex(drawable.bezierCurves[i].startPoint, false);\n                            this.removeVertex(drawable.bezierCurves[i].startControlPoint, false);\n                            this.removeVertex(drawable.bezierCurves[i].endControlPoint, false);\n                            if (i + 1 == drawable.bezierCurves.length) {\n                                this.removeVertex(drawable.bezierCurves[i].endPoint, false);\n                            }\n                        }\n                    }\n                    else if (drawable instanceof PBImage) {\n                        this.removeVertex(drawable.upperLeft, false);\n                        this.removeVertex(drawable.lowerRight, false);\n                    }\n                    else if (drawable instanceof PBText) {\n                        this.removeVertex(drawable.anchor, false);\n                    }\n                } // END removeWithVertices\n                if (redraw) {\n                    this.redraw();\n                }\n            }\n        }\n    }\n    /**\n     * Remove a vertex from the vertex list.<br>\n     *\n     * @param {Vertex} vert - The vertex to remove.\n     * @param {boolean} [redraw=false]\n     * @method removeVertex\n     * @instance\n     * @memberof PlotBoilerplate\n     * @return {void}\n     **/\n    removeVertex(vert, redraw) {\n        for (var i = 0; i < this.vertices.length; i++) {\n            if (this.vertices[i] === vert) {\n                this.vertices.splice(i, 1);\n                if (redraw) {\n                    this.redraw();\n                }\n                return;\n            }\n        }\n    }\n    /**\n     * Remove all elements.\n     *\n     * If you want to keep the vertices, pass `true`.\n     *\n     * @method removeAll\n     * @param {boolean=false} keepVertices\n     * @instance\n     * @memberof PlotBoilerplate\n     * @return {void}\n     */\n    removeAll(keepVertices) {\n        this.drawables = [];\n        if (!Boolean(keepVertices)) {\n            this.vertices = [];\n        }\n        this.redraw();\n    }\n    /**\n     * Find the vertex near the given position.\n     *\n     * The position is the absolute vertex position, not the x-y-coordinates on the canvas.\n     *\n     * @param {XYCoords} position - The position of the vertex to search for.\n     * @param {number} pixelTolerance - A radius around the position to include into the search.\n     *                                  Note that the tolerance will be scaled up/down when zoomed.\n     * @return The vertex near the given position or undefined if none was found there.\n     **/\n    getVertexNear(pixelPosition, pixelTolerance) {\n        var _a, _b;\n        const p = this.locatePointNear(this.transformMousePosition(pixelPosition.x, pixelPosition.y), pixelTolerance / Math.min((_a = this.config.cssScaleX) !== null && _a !== void 0 ? _a : 1.0, (_b = this.config.cssScaleY) !== null && _b !== void 0 ? _b : 1.0));\n        if (p && p.typeName == \"vertex\") {\n            return this.vertices[p.vindex];\n        }\n        return undefined;\n    }\n    /**\n     * Draw the grid with the current config settings.<br>\n     *\n     * This function is usually only used internally.\n     *\n     * @method drawGrid\n     * @param {DrawLib} draw - The drawing library to use to draw lines.\n     * @private\n     * @instance\n     * @memberof PlotBoilerplate\n     * @return {void}\n     **/\n    drawGrid(draw) {\n        if (typeof draw === \"undefined\") {\n            draw = this.draw;\n        }\n        const gScale = {\n            x: (Grid.utils.mapRasterScale(this.config.rasterAdjustFactor, this.draw.scale.x) * this.config.rasterScaleX) /\n                this.config.cssScaleX,\n            y: (Grid.utils.mapRasterScale(this.config.rasterAdjustFactor, this.draw.scale.y) * this.config.rasterScaleY) /\n                this.config.cssScaleY\n        };\n        var gSize = { width: this.grid.size.x * gScale.x, height: this.grid.size.y * gScale.y };\n        var cs = { width: this.canvasSize.width / 2, height: this.canvasSize.height / 2 };\n        var offset = this.draw.offset.clone().inv();\n        // console.log( \"drawGrid\", gScale, gSize, cs, offset );\n        offset.x =\n            ((Math.round(offset.x + cs.width) / Math.round(gSize.width)) * gSize.width) / this.draw.scale.x +\n                (((this.draw.offset.x - cs.width) / this.draw.scale.x) % gSize.width);\n        offset.y =\n            ((Math.round(offset.y + cs.height) / Math.round(gSize.height)) * gSize.height) / this.draw.scale.y +\n                (((this.draw.offset.y - cs.height) / this.draw.scale.x) % gSize.height);\n        if (this.drawConfig.drawGrid) {\n            draw.setCurrentClassName(null);\n            if (this.config.rasterGrid) {\n                // TODO: move config member to drawConfig\n                draw.setCurrentId(\"raster\");\n                draw.raster(offset, this.canvasSize.width / this.draw.scale.x, this.canvasSize.height / this.draw.scale.y, gSize.width, gSize.height, \"rgba(0,128,255,0.125)\");\n            }\n            else {\n                draw.setCurrentId(\"grid\");\n                draw.grid(offset, this.canvasSize.width / this.draw.scale.x, this.canvasSize.height / this.draw.scale.y, gSize.width, gSize.height, \"rgba(0,128,255,0.095)\");\n            }\n        }\n    }\n    /**\n     * Draw the origin with the current config settings.<br>\n     *\n     * This function is usually only used internally.\n     *\n     * @method drawOrigin\n     * @param {DrawLib} draw - The drawing library to use to draw lines.\n     * @private\n     * @instance\n     * @memberof PlotBoilerplate\n     * @return {void}\n     **/\n    drawOrigin(draw) {\n        // Add a crosshair to mark the origin\n        draw.setCurrentId(\"origin\");\n        draw.crosshair({ x: 0, y: 0 }, 10, this.drawConfig.origin.color);\n    }\n    /**\n     * This is just a tiny helper function to determine the render color of vertices.\n     **/\n    _handleColor(h, color) {\n        return h.attr.isSelected ? this.drawConfig.selectedVertex.color : h.attr.draggable ? color : \"rgba(128,128,128,0.5)\";\n    }\n    /**\n     * Draw all drawables.\n     *\n     * This function is usually only used internally.\n     *\n     * @method drawDrawables\n     * @param {number} renderTime - The current render time. It will be used to distinct\n     *                              already draw vertices from non-draw-yet vertices.\n     * @param {DrawLib} draw - The drawing library to use to draw lines.\n     * @param {DrawLib} fill - The drawing library to use to fill areas.\n     * @instance\n     * @memberof PlotBoilerplate\n     * @return {void}\n     **/\n    drawDrawables(renderTime, draw, fill) {\n        for (var i in this.drawables) {\n            var d = this.drawables[i];\n            this.draw.setCurrentId(d.uid);\n            this.fill.setCurrentId(d.uid);\n            this.draw.setCurrentClassName(d.className);\n            this.fill.setCurrentClassName(d.className);\n            this.drawDrawable(d, renderTime, draw, fill);\n        }\n    }\n    /**\n     * Draw the given drawable.\n     *\n     * This function is usually only used internally.\n     *\n     * @method drawDrawable\n     * @param {Drawable} d - The drawable to draw.\n     * @param {number} renderTime - The current render time. It will be used to distinct\n     *                              already draw vertices from non-draw-yet vertices.\n     * @param {DrawLib} draw - The drawing library to use to draw lines.\n     * @param {DrawLib} fill - The drawing library to use to fill areas.\n     * @instance\n     * @memberof PlotBoilerplate\n     * @return {void}\n     **/\n    drawDrawable(d, renderTime, draw, fill) {\n        if (d instanceof BezierPath) {\n            var curveIndex = 0;\n            for (var c in d.bezierCurves) {\n                // Restore these settings again in each loop (will be overwritten)\n                this.draw.setCurrentId(`${d.uid}-${curveIndex}`);\n                this.fill.setCurrentId(`${d.uid}-${curveIndex}`);\n                this.draw.setCurrentClassName(d.className);\n                this.fill.setCurrentClassName(d.className);\n                draw.cubicBezier(d.bezierCurves[c].startPoint, d.bezierCurves[c].endPoint, d.bezierCurves[c].startControlPoint, d.bezierCurves[c].endControlPoint, this.drawConfig.bezier.color, this.drawConfig.bezier.lineWidth);\n                if (this.drawConfig.drawBezierHandlePoints && this.drawConfig.drawHandlePoints) {\n                    if (d.bezierCurves[c].startPoint.attr.visible) {\n                        const df = this.drawConfig.bezier.pathVertex.fill ? fill : draw;\n                        df.setCurrentId(`${d.uid}_h0`);\n                        df.setCurrentClassName(`${d.className}-start-handle`);\n                        if (d.bezierCurves[c].startPoint.attr.bezierAutoAdjust) {\n                            df.squareHandle(d.bezierCurves[c].startPoint, 5, this._handleColor(d.bezierCurves[c].startPoint, this.drawConfig.bezier.pathVertex.color));\n                        }\n                        else {\n                            df.diamondHandle(d.bezierCurves[c].startPoint, 7, this._handleColor(d.bezierCurves[c].startPoint, this.drawConfig.bezier.pathVertex.color));\n                        }\n                    }\n                    d.bezierCurves[c].startPoint.attr.renderTime = renderTime;\n                    if (d.bezierCurves[c].endPoint.attr.visible) {\n                        const df = this.drawConfig.bezier.pathVertex.fill ? fill : draw;\n                        df.setCurrentId(`${d.uid}_h0`);\n                        df.setCurrentClassName(`${d.className}-start-handle`);\n                        if (d.bezierCurves[c].endPoint.attr.bezierAutoAdjust) {\n                            df.squareHandle(d.bezierCurves[c].endPoint, 5, this._handleColor(d.bezierCurves[c].endPoint, this.drawConfig.bezier.pathVertex.color));\n                        }\n                        else {\n                            df.diamondHandle(d.bezierCurves[c].endPoint, 7, this._handleColor(d.bezierCurves[c].endPoint, this.drawConfig.bezier.pathVertex.color));\n                        }\n                    }\n                    if (d.bezierCurves[c].startControlPoint.attr.visible) {\n                        const df = this.drawConfig.bezier.controlVertex.fill ? fill : draw;\n                        df.setCurrentId(`${d.uid}_h2`);\n                        df.setCurrentClassName(`${d.className}-start-control-handle`);\n                        df.circleHandle(d.bezierCurves[c].startControlPoint, 3, this._handleColor(d.bezierCurves[c].startControlPoint, this.drawConfig.bezier.controlVertex.color));\n                    }\n                    if (d.bezierCurves[c].endControlPoint.attr.visible) {\n                        const df = this.drawConfig.bezier.controlVertex.fill ? fill : draw;\n                        df.setCurrentId(`${d.uid}_h3`);\n                        df.setCurrentClassName(`${d.className}-end-control-handle`);\n                        df.circleHandle(d.bezierCurves[c].endControlPoint, 3, this._handleColor(d.bezierCurves[c].endControlPoint, this.drawConfig.bezier.controlVertex.color));\n                    }\n                    d.bezierCurves[c].startPoint.attr.renderTime = renderTime;\n                    d.bezierCurves[c].endPoint.attr.renderTime = renderTime;\n                    d.bezierCurves[c].startControlPoint.attr.renderTime = renderTime;\n                    d.bezierCurves[c].endControlPoint.attr.renderTime = renderTime;\n                }\n                else {\n                    d.bezierCurves[c].startPoint.attr.renderTime = renderTime;\n                    d.bezierCurves[c].endPoint.attr.renderTime = renderTime;\n                    d.bezierCurves[c].startControlPoint.attr.renderTime = renderTime;\n                    d.bezierCurves[c].endControlPoint.attr.renderTime = renderTime;\n                }\n                if (this.drawConfig.drawBezierHandleLines && this.drawConfig.drawHandleLines) {\n                    draw.setCurrentId(`${d.uid}_l0`);\n                    draw.setCurrentClassName(`${d.className}-start-line`);\n                    draw.line(d.bezierCurves[c].startPoint, d.bezierCurves[c].startControlPoint, this.drawConfig.bezier.handleLine.color, this.drawConfig.bezier.handleLine.lineWidth);\n                    draw.setCurrentId(`${d.uid}_l1`);\n                    draw.setCurrentClassName(`${d.className}-end-line`);\n                    draw.line(d.bezierCurves[c].endPoint, d.bezierCurves[c].endControlPoint, this.drawConfig.bezier.handleLine.color, this.drawConfig.bezier.handleLine.lineWidth);\n                }\n                curveIndex++;\n            } // END for\n        }\n        else if (d instanceof Polygon) {\n            draw.polygon(d, this.drawConfig.polygon.color, this.drawConfig.polygon.lineWidth);\n            if (!this.drawConfig.drawHandlePoints) {\n                for (var i in d.vertices) {\n                    d.vertices[i].attr.renderTime = renderTime;\n                }\n            }\n        }\n        else if (d instanceof Triangle) {\n            draw.polyline([d.a, d.b, d.c], false, this.drawConfig.triangle.color, this.drawConfig.triangle.lineWidth);\n            if (!this.drawConfig.drawHandlePoints)\n                d.a.attr.renderTime = d.b.attr.renderTime = d.c.attr.renderTime = renderTime;\n        }\n        else if (d instanceof VEllipse) {\n            if (this.drawConfig.drawHandleLines) {\n                draw.setCurrentId(`${d.uid}_e0`);\n                draw.setCurrentClassName(`${d.className}-v-line`);\n                // draw.line( d.center.clone().add(0,d.axis.y-d.center.y), d.axis, '#c8c8c8' );\n                draw.line(d.center.clone().add(0, d.signedRadiusV()).rotate(d.rotation, d.center), d.axis, \"#c8c8c8\");\n                draw.setCurrentId(`${d.uid}_e1`);\n                draw.setCurrentClassName(`${d.className}-h-line`);\n                // draw.line( d.center.clone().add(d.axis.x-d.center.x,0), d.axis, '#c8c8c8' );\n                draw.line(d.center.clone().add(d.signedRadiusH(), 0).rotate(d.rotation, d.center), d.axis, \"#c8c8c8\");\n            }\n            draw.setCurrentId(d.uid);\n            draw.setCurrentClassName(`${d.className}`);\n            draw.ellipse(d.center, \n            // Math.abs(d.axis.x-d.center.x), Math.abs(d.axis.y-d.center.y),\n            d.radiusH(), d.radiusV(), this.drawConfig.ellipse.color, this.drawConfig.ellipse.lineWidth, d.rotation);\n            if (!this.drawConfig.drawHandlePoints) {\n                d.center.attr.renderTime = renderTime;\n                d.axis.attr.renderTime = renderTime;\n            }\n        }\n        else if (d instanceof VEllipseSector) {\n            draw.setCurrentId(d.uid);\n            draw.setCurrentClassName(`${d.className}`);\n            /* draw.ellipse( d.center,\n                    // Math.abs(d.axis.x-d.center.x), Math.abs(d.axis.y-d.center.y),\n                    d.radiusH(), d.radiusV(),\n                    this.drawConfig.ellipse.color,\n                    this.drawConfig.ellipse.lineWidth,\n                    d.rotation ); */\n            const data = VEllipseSector.ellipseSectorUtils.describeSVGArc(d.ellipse.center.x, d.ellipse.center.y, d.ellipse.radiusH(), d.ellipse.radiusV(), d.startAngle, d.endAngle, d.ellipse.rotation, { moveToStart: true });\n            draw.path(data, this.drawConfig.ellipseSector.color, this.drawConfig.ellipseSector.lineWidth);\n        }\n        else if (d instanceof Circle) {\n            draw.circle(d.center, d.radius, this.drawConfig.circle.color, this.drawConfig.circle.lineWidth);\n        }\n        else if (d instanceof CircleSector) {\n            draw.circleArc(d.circle.center, d.circle.radius, d.startAngle, d.endAngle, this.drawConfig.circleSector.color, this.drawConfig.circleSector.lineWidth);\n        }\n        else if (d instanceof Vertex) {\n            if (this.drawConfig.drawVertices && (!d.attr.selectable || !d.attr.draggable) && d.attr.visible) {\n                // Draw as special point (grey)\n                draw.circleHandle(d, 7, this.drawConfig.vertex.color);\n                d.attr.renderTime = renderTime;\n            }\n        }\n        else if (d instanceof Line) {\n            draw.line(d.a, d.b, this.drawConfig.line.color, this.drawConfig.line.lineWidth);\n            if (!this.drawConfig.drawHandlePoints || !d.a.attr.selectable)\n                d.a.attr.renderTime = renderTime;\n            if (!this.drawConfig.drawHandlePoints || !d.b.attr.selectable)\n                d.b.attr.renderTime = renderTime;\n        }\n        else if (d instanceof Vector) {\n            draw.arrow(d.a, d.b, this.drawConfig.vector.color);\n            if (this.drawConfig.drawHandlePoints && d.b.attr.selectable && d.b.attr.visible) {\n                draw.setCurrentId(`${d.uid}_h0`);\n                draw.setCurrentClassName(`${d.className}-handle`);\n                draw.circleHandle(d.b, 3, \"#a8a8a8\");\n            }\n            else {\n                d.b.attr.renderTime = renderTime;\n            }\n            if (!this.drawConfig.drawHandlePoints || !d.a.attr.selectable)\n                d.a.attr.renderTime = renderTime;\n            if (!this.drawConfig.drawHandlePoints || !d.b.attr.selectable)\n                d.b.attr.renderTime = renderTime;\n        }\n        else if (d instanceof PBImage) {\n            if (this.drawConfig.drawHandleLines) {\n                draw.setCurrentId(`${d.uid}_l0`);\n                draw.setCurrentClassName(`${d.className}-line`);\n                draw.line(d.upperLeft, d.lowerRight, this.drawConfig.image.color, this.drawConfig.image.lineWidth);\n            }\n            fill.setCurrentId(d.uid);\n            fill.image(d.image, d.upperLeft, d.lowerRight.clone().sub(d.upperLeft));\n            if (this.drawConfig.drawHandlePoints) {\n                draw.setCurrentId(`${d.uid}_h0`);\n                draw.setCurrentClassName(`${d.className}-lower-right`);\n                draw.circleHandle(d.lowerRight, 3, this.drawConfig.image.color);\n                d.lowerRight.attr.renderTime = renderTime;\n            }\n        }\n        else if (d instanceof PBText) {\n            fill.setCurrentId(d.uid);\n            fill.text(d.text, d.anchor.x, d.anchor.y, d);\n            if (this.drawConfig.text.anchor) {\n                draw.setCurrentId(`${d.uid}_a0`);\n                draw.setCurrentClassName(`${d.className}-anchor`);\n                (this.drawConfig.text.fill ? fill : draw).point(d.anchor, this.drawConfig.text.color);\n            }\n            d.anchor.attr.renderTime = renderTime;\n        }\n        else {\n            console.error(\"Cannot draw object. Unknown class.\");\n        }\n        draw.setCurrentClassName(null);\n        draw.setCurrentId(null);\n        fill.setCurrentClassName(null);\n        fill.setCurrentId(null);\n    }\n    /**\n     * Draw the select-polygon (if there is one).\n     *\n     * This function is usually only used internally.\n     *\n     * @method drawSelectPolygon\n     * @private\n     * @instance\n     * @memberof PlotBoilerplate\n     * @return {void}\n     **/\n    drawSelectPolygon(draw) {\n        // Draw select polygon?\n        if (this.selectPolygon != null && this.selectPolygon.vertices.length > 0) {\n            draw.setCurrentId(this.selectPolygon.uid);\n            draw.polygon(this.selectPolygon, \"#888888\");\n            draw.crosshair(this.selectPolygon.vertices[0], 3, \"#008888\");\n        }\n    }\n    /**\n     * Draw all vertices that were not yet drawn with the given render time.<br>\n     * <br>\n     * This function is usually only used internally.\n     *\n     * @method drawVertices\n     * @private\n     * @param {number} renderTime - The current render time. It is used to distinct\n     *                              already draw vertices from non-draw-yet vertices.\n     * @instance\n     * @memberof PlotBoilerplate\n     * @return {void}\n     **/\n    drawVertices(renderTime, draw) {\n        // Draw all vertices as small squares if they were not already drawn by other objects\n        for (var i in this.vertices) {\n            if (this.drawConfig.drawVertices && this.vertices[i].attr.renderTime != renderTime && this.vertices[i].attr.visible) {\n                draw.setCurrentId(this.vertices[i].uid);\n                draw.squareHandle(this.vertices[i], 5, this._handleColor(this.vertices[i], \"rgb(0,128,192)\"));\n                this.vertices[i].attr.renderTime = renderTime;\n            }\n        }\n    }\n    /**\n     * Trigger redrawing of all objects.<br>\n     * <br>\n     * Usually this function is automatically called when objects change.\n     *\n     * @method redraw\n     * @instance\n     * @memberof PlotBoilerplate\n     * @return {void}\n     **/\n    redraw() {\n        const renderTime = this.renderTime++;\n        // Tell the drawing library that a new drawing cycle begins (required for the GL lib).\n        this.draw.beginDrawCycle(renderTime);\n        this.fill.beginDrawCycle(renderTime);\n        if (this.config.preClear)\n            this.config.preClear();\n        this.clear();\n        if (this.config.preDraw)\n            this.config.preDraw(this.draw, this.fill);\n        this.drawAll(renderTime, this.draw, this.fill);\n        if (this.config.postDraw)\n            this.config.postDraw(this.draw, this.fill);\n        this.draw.endDrawCycle(renderTime);\n        this.fill.endDrawCycle(renderTime);\n    }\n    /**\n     * Draw all: drawables, grid, select-polygon and vertices.\n     *\n     * @method drawAll\n     * @instance\n     * @memberof PlotBoilerplate\n     * @return {void}\n     **/\n    drawAll(renderTime, draw, fill) {\n        if (this.config.drawRaster) {\n            this.drawGrid(draw);\n        }\n        if (this.config.drawOrigin) {\n            this.drawOrigin(draw);\n        }\n        this.drawDrawables(renderTime, draw, fill);\n        this.drawVertices(renderTime, draw);\n        this.drawSelectPolygon(draw);\n        // Clear IDs and classnames (postDraw hook might draw somthing and the do not want\n        // to interfered with that).\n        draw.setCurrentId(null);\n        draw.setCurrentClassName(null);\n    } // END redraw\n    /**\n     * This function clears the canvas with the configured background color.<br>\n     * <br>\n     * This function is usually only used internally.\n     *\n     * @method clear\n     * @private\n     * @instance\n     * @memberof PlotBoilerplate\n     * @return {void}\n     **/\n    clear() {\n        // Note that elements might have an alpha channel. Clear the scene first.\n        this.draw.clear(this.config.backgroundColor || \"white\");\n    }\n    /**\n     * Clear the selection.<br>\n     * <br>\n     * This function is usually only used internally.\n     *\n     * @method clearSelection\n     * @private\n     * @param {boolean=} [redraw=false] - Indicates if the redraw function should be triggered.\n     * @instance\n     * @memberof PlotBoilerplate\n     * @return {PlotBoilerplate} this\n     **/\n    clearSelection(redraw) {\n        for (var i in this.vertices)\n            this.vertices[i].attr.isSelected = false;\n        if (redraw)\n            this.redraw();\n        return this;\n    }\n    /**\n     * Get the current view port.\n     *\n     * @method viewport\n     * @instance\n     * @memberof PlotBoilerplate\n     * @return {Bounds} The current viewport.\n     **/\n    viewport() {\n        var _a, _b;\n        return new Bounds(this.transformMousePosition(0, 0), this.transformMousePosition(this.canvasSize.width * ((_a = this.config.cssScaleX) !== null && _a !== void 0 ? _a : 1.0), this.canvasSize.height * ((_b = this.config.cssScaleY) !== null && _b !== void 0 ? _b : 1.0)));\n    }\n    /**\n     * Trigger the saveFile.hook.\n     *\n     * @method saveFile\n     * @instance\n     * @memberof PlotBoilerplate\n     * @return {void}\n     **/\n    saveFile() {\n        this.hooks.saveFile(this);\n    }\n    /**\n     * Internal helper function used to get 'float' properties from elements.\n     * Used to determine border withs and paddings that were defined using CSS.\n     */\n    // TODO: this was moved to the DOM utils\n    getFProp(elem, propName) {\n        return parseFloat(globalThis.getComputedStyle(elem, null).getPropertyValue(propName));\n    }\n    /**\n     * Get the available inner space of the given container.\n     *\n     * Size minus padding minus border.\n     **/\n    // TODO: this was moved to the DOM utils\n    getAvailableContainerSpace() {\n        const _self = this;\n        const container = _self.canvas.parentNode; // Element | Document | DocumentFragment;\n        _self.canvas.style.display = \"none\";\n        var padding = this.getFProp(container, \"padding\") || 0, border = this.getFProp(_self.canvas, \"border-width\") || 0, pl = this.getFProp(container, \"padding-left\") || padding, pr = this.getFProp(container, \"padding-right\") || padding, pt = this.getFProp(container, \"padding-top\") || padding, pb = this.getFProp(container, \"padding-bottom\") || padding, bl = this.getFProp(_self.canvas, \"border-left-width\") || border, br = this.getFProp(_self.canvas, \"border-right-width\") || border, bt = this.getFProp(_self.canvas, \"border-top-width\") || border, bb = this.getFProp(_self.canvas, \"border-bottom-width\") || border;\n        var w = container.clientWidth;\n        var h = container.clientHeight;\n        _self.canvas.style.display = \"block\";\n        return { width: w - pl - pr - bl - br, height: h - pt - pb - bt - bb };\n    }\n    /**\n     * This function resizes the canvas to the required settings (toggles fullscreen).<br>\n     * <br>\n     * This function is usually only used internally but feel free to call it if resizing required.\n     *\n     * @method resizeCanvas\n     * @instance\n     * @memberof PlotBoilerplate\n     * @return {void}\n     **/\n    resizeCanvas() {\n        var _a, _b, _c, _d, _e, _f;\n        const _self = this;\n        const _setSize = (w, h) => {\n            var _a, _b;\n            w *= (_a = _self.config.canvasWidthFactor) !== null && _a !== void 0 ? _a : 1.0;\n            h *= (_b = _self.config.canvasHeightFactor) !== null && _b !== void 0 ? _b : 1.0;\n            _self.canvasSize.width = w;\n            _self.canvasSize.height = h;\n            if (_self.canvas instanceof HTMLCanvasElement) {\n                _self.canvas.width = w;\n                _self.canvas.height = h;\n            }\n            else if (_self.canvas instanceof SVGElement) {\n                this.canvas.setAttribute(\"viewBox\", `0 0 ${w} ${h}`);\n                this.canvas.setAttribute(\"width\", `${w}`);\n                this.canvas.setAttribute(\"height\", `${h}`);\n                this.draw.setSize(_self.canvasSize); // No need to set size to this.fill (instance copy)\n                this.eventCatcher.style.width = `${w}px`;\n                this.eventCatcher.style.height = `${h}px`;\n            }\n            else {\n                console.error(\"Error: cannot resize canvas element because it seems neither be a HTMLCanvasElement nor an SVGElement.\");\n            }\n            if (_self.config.autoAdjustOffset) {\n                // _self.draw.offset.x = _self.fill.offset.x = _self.config.offsetX = w*(_self.config.offsetAdjustXPercent/100);\n                // _self.draw.offset.y = _self.fill.offset.y = _self.config.offsetY = h*(_self.config.offsetAdjustYPercent/100);\n                _self.adjustOffset(false);\n            }\n        };\n        if (_self.config.fullSize && !_self.config.fitToParent) {\n            // Set editor size\n            var width = globalThis.innerWidth || document.documentElement.clientWidth || document.body.clientWidth;\n            var height = globalThis.innerHeight || document.documentElement.clientHeight || document.body.clientHeight;\n            _self.canvas.style.position = \"absolute\";\n            _self.canvas.style.width = ((_a = _self.config.canvasWidthFactor) !== null && _a !== void 0 ? _a : 1.0) * width + \"px\";\n            _self.canvas.style.height = ((_b = _self.config.canvasWidthFactor) !== null && _b !== void 0 ? _b : 1.0) * height + \"px\";\n            _self.canvas.style.top = \"0px\";\n            _self.canvas.style.left = \"0px\";\n            _setSize(width, height);\n        }\n        else if (_self.config.fitToParent) {\n            // Set editor size\n            _self.canvas.style.position = \"static\";\n            const space = this.getAvailableContainerSpace();\n            _self.canvas.style.width = ((_c = _self.config.canvasWidthFactor) !== null && _c !== void 0 ? _c : 1.0) * space.width + \"px\";\n            _self.canvas.style.height = ((_d = _self.config.canvasHeightFactor) !== null && _d !== void 0 ? _d : 1.0) * space.height + \"px\";\n            _self.canvas.style.top = \"\";\n            _self.canvas.style.left = \"\";\n            _setSize(space.width, space.height);\n        }\n        else {\n            _self.canvas.style.width = \"\";\n            _self.canvas.style.height = \"\";\n            _setSize((_e = _self.config.defaultCanvasWidth) !== null && _e !== void 0 ? _e : 1024, (_f = _self.config.defaultCanvasHeight) !== null && _f !== void 0 ? _f : 768);\n        }\n        if (_self.config.redrawOnResize)\n            _self.redraw();\n    }\n    /**\n     *  Add all vertices inside the polygon to the current selection.<br>\n     *\n     * @method selectVerticesInPolygon\n     * @param {Polygon} polygon - The polygonal selection area.\n     * @instance\n     * @memberof PlotBoilerplate\n     * @return {void}\n     **/\n    selectVerticesInPolygon(polygon) {\n        for (var i in this.vertices) {\n            if (this.vertices[i].attr.selectable && polygon.containsVert(this.vertices[i]))\n                this.vertices[i].attr.isSelected = true;\n        }\n    }\n    /**\n     * (Helper) Locates the point (index) at the passed position. Using an internal tolerance of 7 pixels.\n     *\n     * The result is an object { type : 'bpath', pindex, cindex, pid }\n     *\n     * Returns false if no point is near the passed position.\n     *\n     * @method locatePointNear\n     * @param {Vertex} point - The polygonal selection area.\n     * @param {number=} [tolerance=7] - The tolerance to use identtifying vertices.\n     * @private\n     * @return {IDraggable} Or false if none found.\n     **/\n    locatePointNear(point, tolerance) {\n        const _self = this;\n        if (typeof tolerance == \"undefined\")\n            tolerance = 7;\n        // Apply the zoom (the tolerant area should not shrink or grow when zooming)\n        tolerance /= _self.draw.scale.x;\n        // Search in vertices\n        for (var vindex = 0; vindex < _self.vertices.length; vindex++) {\n            var vert = _self.vertices[vindex];\n            if ((vert.attr.draggable || vert.attr.selectable) && vert.distance(point) < tolerance) {\n                // { type : 'vertex', vindex : vindex };\n                return new PlotBoilerplate.Draggable(vert, PlotBoilerplate.Draggable.VERTEX).setVIndex(vindex);\n            }\n        }\n        return null;\n    }\n    /**\n     * Handle left-click event.<br>\n     *\n     * @method handleClick\n     * @param {number} x - The click X position on the canvas.\n     * @param {number} y - The click Y position on the canvas.\n     * @private\n     * @return {void}\n     **/\n    handleClick(e) {\n        const _self = this;\n        var point = this.locatePointNear(_self.transformMousePosition(e.params.pos.x, e.params.pos.y), PlotBoilerplate.DEFAULT_CLICK_TOLERANCE / Math.min(_self.config.cssScaleX || 1.0, _self.config.cssScaleY || 1.0));\n        if (point) {\n            _self.vertices[point.vindex].listeners.fireClickEvent(e);\n            if (this.keyHandler && this.keyHandler.isDown(\"shift\")) {\n                if (point.typeName == \"bpath\") {\n                    let vert = _self.paths[point.pindex].bezierCurves[point.cindex].getPointByID(point.pid);\n                    if (vert.attr.selectable)\n                        vert.attr.isSelected = !vert.attr.isSelected;\n                }\n                else if (point.typeName == \"vertex\") {\n                    let vert = _self.vertices[point.vindex];\n                    if (vert.attr.selectable)\n                        vert.attr.isSelected = !vert.attr.isSelected;\n                }\n                _self.redraw();\n            }\n            else if (this.keyHandler && this.keyHandler.isDown(\"y\")) {\n                _self.vertices[point.vindex].attr.bezierAutoAdjust = !_self.vertices[point.vindex].attr.bezierAutoAdjust;\n                _self.redraw();\n            }\n        }\n        else if (_self.selectPolygon != null) {\n            const vert = _self.transformMousePosition(e.params.pos.x, e.params.pos.y);\n            _self.selectPolygon.vertices.push(new Vertex(vert.x, vert.y));\n            _self.redraw();\n        }\n    }\n    /**\n     * Transforms the given x-y-(mouse-)point to coordinates respecting the view offset\n     * and the zoom settings.\n     *\n     * @method transformMousePosition\n     * @param {number} x - The x position relative to the canvas.\n     * @param {number} y - The y position relative to the canvas.\n     * @instance\n     * @memberof PlotBoilerplate\n     * @return {XYCoords} A simple object <pre>{ x : Number, y : Number }</pre> with the transformed coordinates.\n     **/\n    transformMousePosition(x, y) {\n        return {\n            x: (x / this.config.cssScaleX - this.config.offsetX) / this.config.scaleX,\n            y: (y / this.config.cssScaleY - this.config.offsetY) / this.config.scaleY\n        };\n    }\n    /**\n     * Revert a transformed mouse position back to canvas coordinates.\n     *\n     * This is the inverse function of `transformMousePosition`.\n     *\n     * @method revertMousePosition\n     * @param {number} x - The x component of the position to revert.\n     * @param {number} y - The y component of the position to revert.\n     * @instance\n     * @memberof PlotBoilerplate\n     * @return {XYCoords} The canvas coordinates for the given position.\n     **/\n    revertMousePosition(x, y) {\n        return { x: x / this.config.cssScaleX + this.config.offsetX, y: y / this.config.cssScaleY + this.config.offsetY };\n    }\n    /**\n     * Determine if any elements are currently being dragged (on mouse move or touch move).\n     *\n     * @method getDraggedElementCount\n     * @instance\n     * @memberof PlotBoilerplate\n     * @return {number} The number of elements that are currently being dragged.\n     **/\n    getDraggedElementCount() {\n        return this.draggedElements.length;\n    }\n    /**\n     * (Helper) The mouse-down handler.\n     *\n     * It selects vertices for dragging.\n     *\n     * @method mouseDownHandler.\n     * @param {XMouseEvent} e - The event to handle\n     * @private\n     * @return {void}\n     **/\n    mouseDownHandler(e) {\n        const _self = this;\n        if (e.button != 0)\n            return; // Only react on left mouse or touch events\n        var draggablePoint = _self.locatePointNear(_self.transformMousePosition(e.params.pos.x, e.params.pos.y), PlotBoilerplate.DEFAULT_CLICK_TOLERANCE / Math.min(_self.config.cssScaleX, _self.config.cssScaleY));\n        if (!draggablePoint)\n            return;\n        // Drag all selected elements?\n        if (draggablePoint.typeName == \"vertex\" && _self.vertices[draggablePoint.vindex].attr.isSelected) {\n            // Multi drag\n            // for( var i in _self.vertices ) {\n            for (var i = 0; i < _self.vertices.length; i++) {\n                if (_self.vertices[i].attr.isSelected) {\n                    _self.draggedElements.push(new PlotBoilerplate.Draggable(_self.vertices[i], PlotBoilerplate.Draggable.VERTEX).setVIndex(i));\n                    _self.vertices[i].listeners.fireDragStartEvent(e);\n                }\n            }\n        }\n        else {\n            // Single drag\n            if (!_self.vertices[draggablePoint.vindex].attr.draggable)\n                return;\n            _self.draggedElements.push(draggablePoint);\n            if (draggablePoint.typeName == \"bpath\")\n                _self.paths[draggablePoint.pindex].bezierCurves[draggablePoint.cindex]\n                    .getPointByID(draggablePoint.pid)\n                    .listeners.fireDragStartEvent(e);\n            else if (draggablePoint.typeName == \"vertex\")\n                _self.vertices[draggablePoint.vindex].listeners.fireDragStartEvent(e);\n        }\n        _self.redraw();\n    }\n    /**\n     * The mouse-drag handler.\n     *\n     * It moves selected elements around or performs the panning if the ctrl-key if\n     * hold down.\n     *\n     * @method mouseDragHandler.\n     * @param {XMouseEvent} e - The event to handle\n     * @private\n     * @return {void}\n     **/\n    mouseDragHandler(e) {\n        const _self = this;\n        const oldDragAmount = { x: e.params.dragAmount.x, y: e.params.dragAmount.y };\n        e.params.dragAmount.x /= _self.config.cssScaleX;\n        e.params.dragAmount.y /= _self.config.cssScaleY;\n        // Important note to: this.keyHandler.isDown('ctrl')\n        //    We should not use this for any input.\n        //    Reason: most browsers use [Ctrl]+[t] to create new browser tabs.\n        //            If so, the key-up event for [Ctrl] will be fired in the _new tab_,\n        //            not this one. So this tab will never receive any [Ctrl-down] events\n        //            until next keypress; the implication is, that [Ctrl] would still\n        //            considered to be pressed which is not true.\n        if (this.keyHandler && (this.keyHandler.isDown(\"alt\") || this.keyHandler.isDown(\"spacebar\"))) {\n            if (!this.config.enablePan) {\n                return;\n            }\n            _self.setOffset(_self.draw.offset.clone().add(e.params.dragAmount));\n            _self.redraw();\n        }\n        else {\n            // Convert drag amount by scaling\n            // Warning: this possibly invalidates the dragEvent for other listeners!\n            //          Rethink the solution when other features are added.\n            e.params.dragAmount.x /= _self.draw.scale.x;\n            e.params.dragAmount.y /= _self.draw.scale.y;\n            for (var i in _self.draggedElements) {\n                var p = _self.draggedElements[i];\n                if (p.typeName == \"bpath\") {\n                    _self.paths[p.pindex].moveCurvePoint(p.cindex, p.pid, new Vertex(e.params.dragAmount.x, e.params.dragAmount.y));\n                    _self.paths[p.pindex].bezierCurves[p.cindex].getPointByID(p.pid).listeners.fireDragEvent(e);\n                }\n                else if (p.typeName == \"vertex\") {\n                    if (!_self.vertices[p.vindex].attr.draggable)\n                        continue;\n                    _self.vertices[p.vindex].add(e.params.dragAmount);\n                    _self.vertices[p.vindex].listeners.fireDragEvent(e);\n                }\n            }\n        }\n        // Restore old event values!\n        e.params.dragAmount.x = oldDragAmount.x;\n        e.params.dragAmount.y = oldDragAmount.y;\n        _self.redraw();\n    }\n    /**\n     * The mouse-up handler.\n     *\n     * It clears the dragging-selection.\n     *\n     * @method mouseUpHandler.\n     * @param {XMouseEvent} e - The event to handle\n     * @private\n     * @return {void}\n     **/\n    mouseUpHandler(e) {\n        const _self = this;\n        if (e.button != 0)\n            return; // Only react on left mouse;\n        if (!e.params.wasDragged) {\n            _self.handleClick(e); // e.params.pos.x, e.params.pos.y );\n        }\n        for (var i in _self.draggedElements) {\n            var p = _self.draggedElements[i];\n            if (p.typeName == \"bpath\") {\n                _self.paths[p.pindex].bezierCurves[p.cindex].getPointByID(p.pid).listeners.fireDragEndEvent(e);\n            }\n            else if (p.typeName == \"vertex\") {\n                _self.vertices[p.vindex].listeners.fireDragEndEvent(e);\n            }\n        }\n        _self.draggedElements = [];\n        _self.redraw();\n    }\n    /**\n     * The mouse-wheel handler.\n     *\n     * It performs the zooming.\n     *\n     * @method mouseWheelHandler.\n     * @param {XMouseEvent} e - The event to handle\n     * @private\n     * @return {void}\n     **/\n    mouseWheelHandler(e) {\n        if (!this.config.enableZoom) {\n            return;\n        }\n        var zoomStep = 1.25; // Make configurable?\n        // CHANGED replaced _self by this\n        const _self = this;\n        const we = e;\n        if (we.deltaY < 0) {\n            _self.setZoom(_self.config.scaleX * zoomStep, _self.config.scaleY * zoomStep, new Vertex(e.params.pos.x, e.params.pos.y));\n        }\n        else if (we.deltaY > 0) {\n            _self.setZoom(_self.config.scaleX / zoomStep, _self.config.scaleY / zoomStep, new Vertex(e.params.pos.x, e.params.pos.y));\n        }\n        e.preventDefault();\n        _self.redraw();\n    }\n    /**\n     * Re-adjust the configured offset depending on the current canvas size and zoom (scaleX and scaleY).\n     *\n     * @method adjustOffset\n     * @param {boolean=false} redraw - [optional] If set the canvas will redraw with the new offset (default=false).\n     * @return {void}\n     **/\n    adjustOffset(redraw) {\n        this.draw.offset.x =\n            this.fill.offset.x =\n                this.config.offsetX =\n                    this.canvasSize.width * (this.config.offsetAdjustXPercent / 100);\n        this.draw.offset.y =\n            this.fill.offset.y =\n                this.config.offsetY =\n                    this.canvasSize.height * (this.config.offsetAdjustYPercent / 100);\n        if (redraw) {\n            this.redraw();\n        }\n    }\n    /**\n     * Set the new draw offset.\n     *\n     * Note: the function will not trigger any redraws.\n     *\n     * @param {Vertex} newOffset - The new draw offset to use.\n     **/\n    setOffset(newOffset) {\n        this.draw.offset.set(newOffset);\n        this.fill.offset.set(newOffset);\n        this.config.offsetX = newOffset.x;\n        this.config.offsetY = newOffset.y;\n    }\n    /**\n     * Set a new zoom value (and re-adjust the draw offset).\n     *\n     * Note: the function will not trigger any redraws.\n     *\n     * @param {number} zoomFactorX - The new horizontal zoom value.\n     * @param {number} zoomFactorY - The new vertical zoom value.\n     * @param {Vertex} interactionPos - The position of mouse/touch interaction.\n     **/\n    setZoom(zoomFactorX, zoomFactorY, interactionPos) {\n        let oldPos = this.transformMousePosition(interactionPos.x, interactionPos.y);\n        this.draw.scale.x = this.fill.scale.x = this.config.scaleX = Math.max(zoomFactorX, 0.01);\n        this.draw.scale.y = this.fill.scale.y = this.config.scaleY = Math.max(zoomFactorY, 0.01);\n        let newPos = this.transformMousePosition(interactionPos.x, interactionPos.y);\n        let newOffsetX = this.draw.offset.x + (newPos.x - oldPos.x) * this.draw.scale.x;\n        let newOffsetY = this.draw.offset.y + (newPos.y - oldPos.y) * this.draw.scale.y;\n        this.setOffset({ x: newOffsetX, y: newOffsetY });\n    }\n    installInputListeners() {\n        var _self = this;\n        if (this.config.enableMouse) {\n            // Install a mouse handler on the canvas.\n            new MouseHandler(this.eventCatcher ? this.eventCatcher : this.canvas)\n                .down((e) => {\n                _self.mouseDownHandler(e);\n            })\n                .drag((e) => {\n                _self.mouseDragHandler(e);\n            })\n                .up((e) => {\n                _self.mouseUpHandler(e);\n            });\n        }\n        else {\n            _self.console.log(\"Mouse interaction disabled.\");\n        }\n        if (this.config.enableMouseWheel) {\n            // Install a mouse handler on the canvas.\n            new MouseHandler(this.eventCatcher ? this.eventCatcher : this.canvas).wheel((e) => {\n                _self.mouseWheelHandler(e);\n            });\n        }\n        else {\n            _self.console.log(\"Mouse wheel interaction disabled.\");\n        }\n        if (this.config.enableTouch) {\n            // Install a touch handler on the canvas.\n            const relPos = (pos) => {\n                const bounds = _self.canvas.getBoundingClientRect();\n                return { x: pos.x - bounds.left, y: pos.y - bounds.top };\n            };\n            // Make PB work together with both, AlloyFinger as a esm module or a commonjs function.\n            if (typeof globalThis[\"AlloyFinger\"] === \"function\" || typeof globalThis[\"createAlloyFinger\"] === \"function\") {\n                try {\n                    var touchMovePos = null;\n                    var touchDownPos = null;\n                    var draggedElement = null;\n                    var multiTouchStartScale = null;\n                    const clearTouch = () => {\n                        touchMovePos = null;\n                        touchDownPos = null;\n                        draggedElement = null;\n                        multiTouchStartScale = null;\n                        _self.draggedElements = [];\n                    };\n                    const afProps = {\n                        // touchStart: (evt: TouchEvent) => {\n                        touchStart: (evt) => {\n                            if (evt.touches.length == 1) {\n                                touchMovePos = new Vertex(relPos({ x: evt.touches[0].clientX, y: evt.touches[0].clientY }));\n                                touchDownPos = new Vertex(relPos({ x: evt.touches[0].clientX, y: evt.touches[0].clientY }));\n                                draggedElement = _self.locatePointNear(_self.transformMousePosition(touchMovePos.x, touchMovePos.y), PlotBoilerplate.DEFAULT_TOUCH_TOLERANCE / Math.min(_self.config.cssScaleX, _self.config.cssScaleY));\n                                if (draggedElement && draggedElement.typeName == \"vertex\") {\n                                    var draggingVertex = _self.vertices[draggedElement.vindex];\n                                    var fakeEvent = {\n                                        params: {\n                                            isTouchEvent: true,\n                                            dragAmount: { x: 0, y: 0 },\n                                            wasDragged: false,\n                                            mouseDownPos: touchDownPos.clone(),\n                                            mouseDragPos: touchDownPos.clone(),\n                                            vertex: draggingVertex\n                                        }\n                                    };\n                                    _self.draggedElements = [draggedElement];\n                                    draggingVertex.listeners.fireDragStartEvent(fakeEvent);\n                                }\n                            }\n                        },\n                        touchMove: (evt) => {\n                            if (evt.touches.length == 1 && draggedElement) {\n                                evt.preventDefault();\n                                evt.stopPropagation();\n                                if (!touchDownPos || !touchMovePos) {\n                                    return;\n                                }\n                                var rel = relPos({ x: evt.touches[0].clientX, y: evt.touches[0].clientY });\n                                var trans = _self.transformMousePosition(rel.x, rel.y);\n                                var diff = new Vertex(_self.transformMousePosition(touchMovePos.x, touchMovePos.y)).difference(trans);\n                                if (draggedElement.typeName == \"vertex\") {\n                                    if (!_self.vertices[draggedElement.vindex].attr.draggable)\n                                        return;\n                                    _self.vertices[draggedElement.vindex].add(diff);\n                                    var draggingVertex = _self.vertices[draggedElement.vindex];\n                                    var fakeEvent = {\n                                        isTouchEvent: true,\n                                        params: {\n                                            dragAmount: diff.clone(),\n                                            wasDragged: true,\n                                            mouseDownPos: touchDownPos.clone(),\n                                            mouseDragPos: touchDownPos.clone().add(diff),\n                                            vertex: draggingVertex\n                                        }\n                                    };\n                                    draggingVertex.listeners.fireDragEvent(fakeEvent);\n                                    _self.redraw();\n                                }\n                                touchMovePos = new Vertex(rel);\n                            }\n                            else if (evt.touches.length == 2) {\n                                if (!this.config.enablePan) {\n                                    return;\n                                }\n                                // If at least two fingers touch and move, then change the draw offset (panning).\n                                evt.preventDefault();\n                                evt.stopPropagation();\n                                _self.setOffset(_self.draw.offset\n                                    .clone()\n                                    .addXY(evt.deltaX, evt.deltaY)); // Apply zoom?\n                                _self.redraw();\n                            }\n                        },\n                        touchEnd: (evt) => {\n                            // Note: e.touches.length is 0 here\n                            if (draggedElement && draggedElement.typeName == \"vertex\") {\n                                if (!touchDownPos) {\n                                    return;\n                                }\n                                var draggingVertex = _self.vertices[draggedElement.vindex];\n                                var fakeEvent = {\n                                    isTouchEvent: true,\n                                    params: {\n                                        dragAmount: { x: 0, y: 0 },\n                                        wasDragged: false,\n                                        mouseDownPos: touchDownPos.clone(),\n                                        mouseDragPos: touchDownPos.clone(),\n                                        vertex: draggingVertex\n                                    }\n                                };\n                                // Check if vertex was moved\n                                if (touchMovePos && touchDownPos && touchDownPos.distance(touchMovePos) < 0.001) {\n                                    // if( e.touches.length == 1 && diff.x == 0 && diff.y == 0 ) {\n                                    draggingVertex.listeners.fireClickEvent(fakeEvent);\n                                }\n                                else {\n                                    draggingVertex.listeners.fireDragEndEvent(fakeEvent);\n                                }\n                            }\n                            clearTouch();\n                        },\n                        touchCancel: (evt) => {\n                            clearTouch();\n                        },\n                        multipointStart: (evt) => {\n                            multiTouchStartScale = _self.draw.scale.clone();\n                        },\n                        multipointEnd: (evt) => {\n                            multiTouchStartScale = null;\n                        },\n                        pinch: (evt) => {\n                            if (!this.config.enableZoom) {\n                                return;\n                            }\n                            const touchItem0 = evt.touches.item(0);\n                            const touchItem1 = evt.touches.item(1);\n                            if (!evt.touches || !multiTouchStartScale || !touchItem0 || !touchItem1) {\n                                return;\n                            }\n                            // For pinching there must be at least two touch items\n                            const fingerA = new Vertex(touchItem0.clientX, touchItem0.clientY);\n                            const fingerB = new Vertex(touchItem1.clientX, touchItem1.clientY);\n                            const center = new Line(fingerA, fingerB).vertAt(0.5);\n                            _self.setZoom(multiTouchStartScale.x * evt.zoom, multiTouchStartScale.y * evt.zoom, center);\n                            _self.redraw();\n                        }\n                    }; // END afProps\n                    if (window[\"createAlloyFinger\"]) {\n                        window[\"createAlloyFinger\"](this.eventCatcher ? this.eventCatcher : this.canvas, afProps);\n                    }\n                    else {\n                        /* tslint:disable-next-line */\n                        new AlloyFinger(this.eventCatcher ? this.eventCatcher : this.canvas, afProps);\n                    }\n                }\n                catch (e) {\n                    console.error(\"Failed to initialize AlloyFinger!\");\n                    console.error(e);\n                }\n            }\n            else if (globalThis[\"Touchy\"] && typeof globalThis[\"Touchy\"] == \"function\") {\n                console.error(\"[Deprecation] Found Touchy which is not supported any more. Please use AlloyFinger instead.\");\n                // Convert absolute touch positions to relative DOM element position (relative to canvas)\n            }\n            else {\n                console.warn(\"Cannot initialize the touch handler. AlloyFinger is missig. Did you include it?\");\n            }\n        }\n        else {\n            _self.console.log(\"Touch interaction disabled.\");\n        }\n        if (this.config.enableKeys) {\n            // Install key handler\n            this.keyHandler = new KeyHandler({ trackAll: true })\n                .down(\"escape\", function () {\n                _self.clearSelection(true);\n            })\n                .down(\"shift\", function () {\n                _self.selectPolygon = new Polygon();\n                _self.redraw();\n            })\n                .up(\"shift\", function () {\n                // Find and select vertices in the drawn area\n                if (_self.selectPolygon == null)\n                    return;\n                _self.selectVerticesInPolygon(_self.selectPolygon);\n                _self.selectPolygon = null;\n                _self.redraw();\n            });\n        } // END IF enableKeys?\n        else {\n            _self.console.log(\"Keyboard interaction disabled.\");\n        }\n    }\n    /**\n     * Creates a control GUI (a dat.gui instance) for this\n     * plot boilerplate instance.\n     *\n     * @method createGUI\n     * @instance\n     * @memberof PlotBoilerplate\n     * @return {dat.gui.GUI}\n     **/\n    createGUI(props) {\n        // This function moved to the helper utils.\n        // We do not want to include the whole dat.GUI package.\n        if (globalThis[\"utils\"] && typeof globalThis[\"utils\"].createGUI == \"function\")\n            return globalThis[\"utils\"].createGUI(this, props);\n        else\n            throw \"Cannot create dat.GUI instance; did you load the ./utils/creategui helper function an the dat.GUI library?\";\n    }\n} // END class PlotBoilerplate\n/** @constant {number} */\nPlotBoilerplate.DEFAULT_CANVAS_WIDTH = 1024;\n/** @constant {number} */\nPlotBoilerplate.DEFAULT_CANVAS_HEIGHT = 768;\n/** @constant {number} */\nPlotBoilerplate.DEFAULT_CLICK_TOLERANCE = 8;\n/** @constant {number} */\nPlotBoilerplate.DEFAULT_TOUCH_TOLERANCE = 32;\n/**\n * A wrapper class for draggable items (mostly vertices).\n * @private\n **/\nPlotBoilerplate.Draggable = (_a = class {\n        constructor(item, typeName) {\n            this.item = item;\n            this.typeName = typeName;\n        }\n        isVertex() {\n            return this.typeName == PlotBoilerplate.Draggable.VERTEX;\n        }\n        setVIndex(vindex) {\n            this.vindex = vindex;\n            return this;\n        }\n    },\n    _a.VERTEX = \"vertex\",\n    _a);\n/**\n * A set of helper functions.\n **/\nPlotBoilerplate.utils = {\n    /**\n     * Merge the elements in the 'extension' object into the 'base' object based on\n     * the keys of 'base'.\n     *\n     * @param {Object} base\n     * @param {Object} extension\n     * @return {Object} base extended by the new attributes.\n     **/\n    safeMergeByKeys: (base, extension) => {\n        for (var k in extension) {\n            if (!extension.hasOwnProperty(k))\n                continue;\n            if (base.hasOwnProperty(k)) {\n                var typ = typeof base[k];\n                try {\n                    if (typ == \"boolean\")\n                        base[k] = !!JSON.parse(extension[k]);\n                    else if (typ == \"number\")\n                        base[k] = JSON.parse(extension[k]) * 1;\n                    else if (typ == \"function\" && typeof extension[k] == \"function\")\n                        base[k] = extension[k];\n                    else\n                        base[k] = extension[k];\n                }\n                catch (e) {\n                    console.error(\"error in key \", k, extension[k], e);\n                }\n            }\n            else {\n                base[k] = extension[k];\n            }\n        }\n        return base;\n    },\n    /**\n     * A helper function to scale elements (usually the canvas) using CSS.\n     *\n     * transform-origin is at (0,0).\n     *\n     * @param {HTMLElement} element - The DOM element to scale.\n     * @param {number} scaleX The - X scale factor.\n     * @param {number} scaleY The - Y scale factor.\n     * @return {void}\n     **/\n    setCSSscale: (element, scaleX, scaleY) => {\n        element.style[\"transform-origin\"] = \"0 0\";\n        if (scaleX == 1.0 && scaleY == 1.0) {\n            // element.style.transform = null;\n            element.style.removeProperty(\"transform\");\n        }\n        else\n            element.style.transform = \"scale(\" + scaleX + \",\" + scaleY + \")\";\n    },\n    // A helper for fetching data from objects.\n    fetch: {\n        /**\n         * A helper function to the the object property value specified by the given key.\n         *\n         * @param {any} object   - The object to get the property's value from. Must not be null.\n         * @param {string} key      - The key of the object property (the name).\n         * @param {any}    fallback - A default value if the key does not exist.\n         **/\n        val: (obj, key, fallback) => {\n            if (!obj.hasOwnProperty(key))\n                return fallback;\n            if (typeof obj[key] == \"undefined\")\n                return fallback;\n            return obj[key];\n        },\n        /**\n         * A helper function to the the object property numeric value specified by the given key.\n         *\n         * @param {any}    object   - The object to get the property's value from. Must not be null.\n         * @param {string} key      - The key of the object property (the name).\n         * @param {number} fallback - A default value if the key does not exist.\n         * @return {number}\n         **/\n        num: (obj, key, fallback) => {\n            if (!obj.hasOwnProperty(key))\n                return fallback;\n            if (typeof obj[key] === \"number\")\n                return obj[key];\n            else {\n                try {\n                    return JSON.parse(obj[key]) * 1;\n                }\n                catch (e) {\n                    return fallback;\n                }\n            }\n        },\n        /**\n         * A helper function to the the object property boolean value specified by the given key.\n         *\n         * @param {any}     object   - The object to get the property's value from. Must not be null.\n         * @param {string}  key      - The key of the object property (the name).\n         * @param {boolean} fallback - A default value if the key does not exist.\n         * @return {boolean}\n         **/\n        bool: (obj, key, fallback) => {\n            if (!obj.hasOwnProperty(key))\n                return fallback;\n            if (typeof obj[key] == \"boolean\")\n                return obj[key];\n            else {\n                try {\n                    return !!JSON.parse(obj[key]);\n                }\n                catch (e) {\n                    return fallback;\n                }\n            }\n        },\n        /**\n         * A helper function to the the object property function-value specified by the given key.\n         *\n         * @param {any}      object   - The object to get the property's value from. Must not be null.\n         * @param {string}   key      - The key of the object property (the name).\n         * @param {function} fallback - A default value if the key does not exist.\n         * @return {function}\n         **/\n        func: (obj, key, fallback) => {\n            if (!obj.hasOwnProperty(key))\n                return fallback;\n            if (typeof obj[key] !== \"function\")\n                return fallback;\n            return obj[key];\n        }\n    },\n    /**\n     * Installs vertex listeners to the path's vertices so that controlpoints\n     * move with their path points when dragged.\n     *\n     * Bézier path points with attr.bezierAutoAdjust==true will have their\n     * two control points audo-updated if moved, too (keep path connections smooth).\n     *\n     * @param {BezierPath} bezierPath - The path to use auto-adjustment for.\n     **/\n    enableBezierPathAutoAdjust: (bezierPath) => {\n        for (var i = 0; i < bezierPath.bezierCurves.length; i++) {\n            // This should be wrapped into the BezierPath implementation.\n            bezierPath.bezierCurves[i].startPoint.listeners.addDragListener(function (e) {\n                var cindex = bezierPath.locateCurveByStartPoint(e.params.vertex);\n                bezierPath.bezierCurves[cindex].startPoint.addXY(-e.params.dragAmount.x, -e.params.dragAmount.y);\n                bezierPath.moveCurvePoint(cindex * 1, bezierPath.START_POINT, e.params.dragAmount);\n                bezierPath.updateArcLengths();\n            });\n            bezierPath.bezierCurves[i].startControlPoint.listeners.addDragListener(function (e) {\n                var cindex = bezierPath.locateCurveByStartControlPoint(e.params.vertex);\n                if (!bezierPath.bezierCurves[cindex].startPoint.attr.bezierAutoAdjust)\n                    return;\n                bezierPath.adjustPredecessorControlPoint(cindex * 1, true, // obtain handle length?\n                false // update arc lengths\n                );\n                bezierPath.updateArcLengths();\n            });\n            bezierPath.bezierCurves[i].endControlPoint.listeners.addDragListener(function (e) {\n                var cindex = bezierPath.locateCurveByEndControlPoint(e.params.vertex);\n                if (!bezierPath.bezierCurves[cindex % bezierPath.bezierCurves.length].endPoint.attr.bezierAutoAdjust)\n                    return;\n                bezierPath.adjustSuccessorControlPoint(cindex * 1, true, // obtain handle length?\n                false // update arc lengths\n                );\n                bezierPath.updateArcLengths();\n            });\n            if (i + 1 == bezierPath.bezierCurves.length) {\n                // && !bezierPath.adjustCircular ) {\n                // Move last control point with the end point (if not circular)\n                bezierPath.bezierCurves[bezierPath.bezierCurves.length - 1].endPoint.listeners.addDragListener(function (e) {\n                    if (!bezierPath.adjustCircular) {\n                        var cindex = bezierPath.locateCurveByEndPoint(e.params.vertex);\n                        bezierPath.moveCurvePoint(cindex * 1, bezierPath.END_CONTROL_POINT, new Vertex({ x: e.params.dragAmount.x, y: e.params.dragAmount.y }));\n                    }\n                    bezierPath.updateArcLengths();\n                });\n            }\n        } // END for\n    }\n}; // END utils\nexport default PlotBoilerplate;\n//# sourceMappingURL=PlotBoilerplate.js.map","// Axios v1.4.0 Copyright (c) 2023 Matt Zabriskie and contributors\n'use strict';\n\nfunction bind(fn, thisArg) {\n  return function wrap() {\n    return fn.apply(thisArg, arguments);\n  };\n}\n\n// utils is a library of generic helper functions non-specific to axios\n\nconst {toString} = Object.prototype;\nconst {getPrototypeOf} = Object;\n\nconst kindOf = (cache => thing => {\n    const str = toString.call(thing);\n    return cache[str] || (cache[str] = str.slice(8, -1).toLowerCase());\n})(Object.create(null));\n\nconst kindOfTest = (type) => {\n  type = type.toLowerCase();\n  return (thing) => kindOf(thing) === type\n};\n\nconst typeOfTest = type => thing => typeof thing === type;\n\n/**\n * Determine if a value is an Array\n *\n * @param {Object} val The value to test\n *\n * @returns {boolean} True if value is an Array, otherwise false\n */\nconst {isArray} = Array;\n\n/**\n * Determine if a value is undefined\n *\n * @param {*} val The value to test\n *\n * @returns {boolean} True if the value is undefined, otherwise false\n */\nconst isUndefined = typeOfTest('undefined');\n\n/**\n * Determine if a value is a Buffer\n *\n * @param {*} val The value to test\n *\n * @returns {boolean} True if value is a Buffer, otherwise false\n */\nfunction isBuffer(val) {\n  return val !== null && !isUndefined(val) && val.constructor !== null && !isUndefined(val.constructor)\n    && isFunction(val.constructor.isBuffer) && val.constructor.isBuffer(val);\n}\n\n/**\n * Determine if a value is an ArrayBuffer\n *\n * @param {*} val The value to test\n *\n * @returns {boolean} True if value is an ArrayBuffer, otherwise false\n */\nconst isArrayBuffer = kindOfTest('ArrayBuffer');\n\n\n/**\n * Determine if a value is a view on an ArrayBuffer\n *\n * @param {*} val The value to test\n *\n * @returns {boolean} True if value is a view on an ArrayBuffer, otherwise false\n */\nfunction isArrayBufferView(val) {\n  let result;\n  if ((typeof ArrayBuffer !== 'undefined') && (ArrayBuffer.isView)) {\n    result = ArrayBuffer.isView(val);\n  } else {\n    result = (val) && (val.buffer) && (isArrayBuffer(val.buffer));\n  }\n  return result;\n}\n\n/**\n * Determine if a value is a String\n *\n * @param {*} val The value to test\n *\n * @returns {boolean} True if value is a String, otherwise false\n */\nconst isString = typeOfTest('string');\n\n/**\n * Determine if a value is a Function\n *\n * @param {*} val The value to test\n * @returns {boolean} True if value is a Function, otherwise false\n */\nconst isFunction = typeOfTest('function');\n\n/**\n * Determine if a value is a Number\n *\n * @param {*} val The value to test\n *\n * @returns {boolean} True if value is a Number, otherwise false\n */\nconst isNumber = typeOfTest('number');\n\n/**\n * Determine if a value is an Object\n *\n * @param {*} thing The value to test\n *\n * @returns {boolean} True if value is an Object, otherwise false\n */\nconst isObject = (thing) => thing !== null && typeof thing === 'object';\n\n/**\n * Determine if a value is a Boolean\n *\n * @param {*} thing The value to test\n * @returns {boolean} True if value is a Boolean, otherwise false\n */\nconst isBoolean = thing => thing === true || thing === false;\n\n/**\n * Determine if a value is a plain Object\n *\n * @param {*} val The value to test\n *\n * @returns {boolean} True if value is a plain Object, otherwise false\n */\nconst isPlainObject = (val) => {\n  if (kindOf(val) !== 'object') {\n    return false;\n  }\n\n  const prototype = getPrototypeOf(val);\n  return (prototype === null || prototype === Object.prototype || Object.getPrototypeOf(prototype) === null) && !(Symbol.toStringTag in val) && !(Symbol.iterator in val);\n};\n\n/**\n * Determine if a value is a Date\n *\n * @param {*} val The value to test\n *\n * @returns {boolean} True if value is a Date, otherwise false\n */\nconst isDate = kindOfTest('Date');\n\n/**\n * Determine if a value is a File\n *\n * @param {*} val The value to test\n *\n * @returns {boolean} True if value is a File, otherwise false\n */\nconst isFile = kindOfTest('File');\n\n/**\n * Determine if a value is a Blob\n *\n * @param {*} val The value to test\n *\n * @returns {boolean} True if value is a Blob, otherwise false\n */\nconst isBlob = kindOfTest('Blob');\n\n/**\n * Determine if a value is a FileList\n *\n * @param {*} val The value to test\n *\n * @returns {boolean} True if value is a File, otherwise false\n */\nconst isFileList = kindOfTest('FileList');\n\n/**\n * Determine if a value is a Stream\n *\n * @param {*} val The value to test\n *\n * @returns {boolean} True if value is a Stream, otherwise false\n */\nconst isStream = (val) => isObject(val) && isFunction(val.pipe);\n\n/**\n * Determine if a value is a FormData\n *\n * @param {*} thing The value to test\n *\n * @returns {boolean} True if value is an FormData, otherwise false\n */\nconst isFormData = (thing) => {\n  let kind;\n  return thing && (\n    (typeof FormData === 'function' && thing instanceof FormData) || (\n      isFunction(thing.append) && (\n        (kind = kindOf(thing)) === 'formdata' ||\n        // detect form-data instance\n        (kind === 'object' && isFunction(thing.toString) && thing.toString() === '[object FormData]')\n      )\n    )\n  )\n};\n\n/**\n * Determine if a value is a URLSearchParams object\n *\n * @param {*} val The value to test\n *\n * @returns {boolean} True if value is a URLSearchParams object, otherwise false\n */\nconst isURLSearchParams = kindOfTest('URLSearchParams');\n\n/**\n * Trim excess whitespace off the beginning and end of a string\n *\n * @param {String} str The String to trim\n *\n * @returns {String} The String freed of excess whitespace\n */\nconst trim = (str) => str.trim ?\n  str.trim() : str.replace(/^[\\s\\uFEFF\\xA0]+|[\\s\\uFEFF\\xA0]+$/g, '');\n\n/**\n * Iterate over an Array or an Object invoking a function for each item.\n *\n * If `obj` is an Array callback will be called passing\n * the value, index, and complete array for each item.\n *\n * If 'obj' is an Object callback will be called passing\n * the value, key, and complete object for each property.\n *\n * @param {Object|Array} obj The object to iterate\n * @param {Function} fn The callback to invoke for each item\n *\n * @param {Boolean} [allOwnKeys = false]\n * @returns {any}\n */\nfunction forEach(obj, fn, {allOwnKeys = false} = {}) {\n  // Don't bother if no value provided\n  if (obj === null || typeof obj === 'undefined') {\n    return;\n  }\n\n  let i;\n  let l;\n\n  // Force an array if not already something iterable\n  if (typeof obj !== 'object') {\n    /*eslint no-param-reassign:0*/\n    obj = [obj];\n  }\n\n  if (isArray(obj)) {\n    // Iterate over array values\n    for (i = 0, l = obj.length; i < l; i++) {\n      fn.call(null, obj[i], i, obj);\n    }\n  } else {\n    // Iterate over object keys\n    const keys = allOwnKeys ? Object.getOwnPropertyNames(obj) : Object.keys(obj);\n    const len = keys.length;\n    let key;\n\n    for (i = 0; i < len; i++) {\n      key = keys[i];\n      fn.call(null, obj[key], key, obj);\n    }\n  }\n}\n\nfunction findKey(obj, key) {\n  key = key.toLowerCase();\n  const keys = Object.keys(obj);\n  let i = keys.length;\n  let _key;\n  while (i-- > 0) {\n    _key = keys[i];\n    if (key === _key.toLowerCase()) {\n      return _key;\n    }\n  }\n  return null;\n}\n\nconst _global = (() => {\n  /*eslint no-undef:0*/\n  if (typeof globalThis !== \"undefined\") return globalThis;\n  return typeof self !== \"undefined\" ? self : (typeof window !== 'undefined' ? window : global)\n})();\n\nconst isContextDefined = (context) => !isUndefined(context) && context !== _global;\n\n/**\n * Accepts varargs expecting each argument to be an object, then\n * immutably merges the properties of each object and returns result.\n *\n * When multiple objects contain the same key the later object in\n * the arguments list will take precedence.\n *\n * Example:\n *\n * ```js\n * var result = merge({foo: 123}, {foo: 456});\n * console.log(result.foo); // outputs 456\n * ```\n *\n * @param {Object} obj1 Object to merge\n *\n * @returns {Object} Result of all merge properties\n */\nfunction merge(/* obj1, obj2, obj3, ... */) {\n  const {caseless} = isContextDefined(this) && this || {};\n  const result = {};\n  const assignValue = (val, key) => {\n    const targetKey = caseless && findKey(result, key) || key;\n    if (isPlainObject(result[targetKey]) && isPlainObject(val)) {\n      result[targetKey] = merge(result[targetKey], val);\n    } else if (isPlainObject(val)) {\n      result[targetKey] = merge({}, val);\n    } else if (isArray(val)) {\n      result[targetKey] = val.slice();\n    } else {\n      result[targetKey] = val;\n    }\n  };\n\n  for (let i = 0, l = arguments.length; i < l; i++) {\n    arguments[i] && forEach(arguments[i], assignValue);\n  }\n  return result;\n}\n\n/**\n * Extends object a by mutably adding to it the properties of object b.\n *\n * @param {Object} a The object to be extended\n * @param {Object} b The object to copy properties from\n * @param {Object} thisArg The object to bind function to\n *\n * @param {Boolean} [allOwnKeys]\n * @returns {Object} The resulting value of object a\n */\nconst extend = (a, b, thisArg, {allOwnKeys}= {}) => {\n  forEach(b, (val, key) => {\n    if (thisArg && isFunction(val)) {\n      a[key] = bind(val, thisArg);\n    } else {\n      a[key] = val;\n    }\n  }, {allOwnKeys});\n  return a;\n};\n\n/**\n * Remove byte order marker. This catches EF BB BF (the UTF-8 BOM)\n *\n * @param {string} content with BOM\n *\n * @returns {string} content value without BOM\n */\nconst stripBOM = (content) => {\n  if (content.charCodeAt(0) === 0xFEFF) {\n    content = content.slice(1);\n  }\n  return content;\n};\n\n/**\n * Inherit the prototype methods from one constructor into another\n * @param {function} constructor\n * @param {function} superConstructor\n * @param {object} [props]\n * @param {object} [descriptors]\n *\n * @returns {void}\n */\nconst inherits = (constructor, superConstructor, props, descriptors) => {\n  constructor.prototype = Object.create(superConstructor.prototype, descriptors);\n  constructor.prototype.constructor = constructor;\n  Object.defineProperty(constructor, 'super', {\n    value: superConstructor.prototype\n  });\n  props && Object.assign(constructor.prototype, props);\n};\n\n/**\n * Resolve object with deep prototype chain to a flat object\n * @param {Object} sourceObj source object\n * @param {Object} [destObj]\n * @param {Function|Boolean} [filter]\n * @param {Function} [propFilter]\n *\n * @returns {Object}\n */\nconst toFlatObject = (sourceObj, destObj, filter, propFilter) => {\n  let props;\n  let i;\n  let prop;\n  const merged = {};\n\n  destObj = destObj || {};\n  // eslint-disable-next-line no-eq-null,eqeqeq\n  if (sourceObj == null) return destObj;\n\n  do {\n    props = Object.getOwnPropertyNames(sourceObj);\n    i = props.length;\n    while (i-- > 0) {\n      prop = props[i];\n      if ((!propFilter || propFilter(prop, sourceObj, destObj)) && !merged[prop]) {\n        destObj[prop] = sourceObj[prop];\n        merged[prop] = true;\n      }\n    }\n    sourceObj = filter !== false && getPrototypeOf(sourceObj);\n  } while (sourceObj && (!filter || filter(sourceObj, destObj)) && sourceObj !== Object.prototype);\n\n  return destObj;\n};\n\n/**\n * Determines whether a string ends with the characters of a specified string\n *\n * @param {String} str\n * @param {String} searchString\n * @param {Number} [position= 0]\n *\n * @returns {boolean}\n */\nconst endsWith = (str, searchString, position) => {\n  str = String(str);\n  if (position === undefined || position > str.length) {\n    position = str.length;\n  }\n  position -= searchString.length;\n  const lastIndex = str.indexOf(searchString, position);\n  return lastIndex !== -1 && lastIndex === position;\n};\n\n\n/**\n * Returns new array from array like object or null if failed\n *\n * @param {*} [thing]\n *\n * @returns {?Array}\n */\nconst toArray = (thing) => {\n  if (!thing) return null;\n  if (isArray(thing)) return thing;\n  let i = thing.length;\n  if (!isNumber(i)) return null;\n  const arr = new Array(i);\n  while (i-- > 0) {\n    arr[i] = thing[i];\n  }\n  return arr;\n};\n\n/**\n * Checking if the Uint8Array exists and if it does, it returns a function that checks if the\n * thing passed in is an instance of Uint8Array\n *\n * @param {TypedArray}\n *\n * @returns {Array}\n */\n// eslint-disable-next-line func-names\nconst isTypedArray = (TypedArray => {\n  // eslint-disable-next-line func-names\n  return thing => {\n    return TypedArray && thing instanceof TypedArray;\n  };\n})(typeof Uint8Array !== 'undefined' && getPrototypeOf(Uint8Array));\n\n/**\n * For each entry in the object, call the function with the key and value.\n *\n * @param {Object<any, any>} obj - The object to iterate over.\n * @param {Function} fn - The function to call for each entry.\n *\n * @returns {void}\n */\nconst forEachEntry = (obj, fn) => {\n  const generator = obj && obj[Symbol.iterator];\n\n  const iterator = generator.call(obj);\n\n  let result;\n\n  while ((result = iterator.next()) && !result.done) {\n    const pair = result.value;\n    fn.call(obj, pair[0], pair[1]);\n  }\n};\n\n/**\n * It takes a regular expression and a string, and returns an array of all the matches\n *\n * @param {string} regExp - The regular expression to match against.\n * @param {string} str - The string to search.\n *\n * @returns {Array<boolean>}\n */\nconst matchAll = (regExp, str) => {\n  let matches;\n  const arr = [];\n\n  while ((matches = regExp.exec(str)) !== null) {\n    arr.push(matches);\n  }\n\n  return arr;\n};\n\n/* Checking if the kindOfTest function returns true when passed an HTMLFormElement. */\nconst isHTMLForm = kindOfTest('HTMLFormElement');\n\nconst toCamelCase = str => {\n  return str.toLowerCase().replace(/[-_\\s]([a-z\\d])(\\w*)/g,\n    function replacer(m, p1, p2) {\n      return p1.toUpperCase() + p2;\n    }\n  );\n};\n\n/* Creating a function that will check if an object has a property. */\nconst hasOwnProperty = (({hasOwnProperty}) => (obj, prop) => hasOwnProperty.call(obj, prop))(Object.prototype);\n\n/**\n * Determine if a value is a RegExp object\n *\n * @param {*} val The value to test\n *\n * @returns {boolean} True if value is a RegExp object, otherwise false\n */\nconst isRegExp = kindOfTest('RegExp');\n\nconst reduceDescriptors = (obj, reducer) => {\n  const descriptors = Object.getOwnPropertyDescriptors(obj);\n  const reducedDescriptors = {};\n\n  forEach(descriptors, (descriptor, name) => {\n    if (reducer(descriptor, name, obj) !== false) {\n      reducedDescriptors[name] = descriptor;\n    }\n  });\n\n  Object.defineProperties(obj, reducedDescriptors);\n};\n\n/**\n * Makes all methods read-only\n * @param {Object} obj\n */\n\nconst freezeMethods = (obj) => {\n  reduceDescriptors(obj, (descriptor, name) => {\n    // skip restricted props in strict mode\n    if (isFunction(obj) && ['arguments', 'caller', 'callee'].indexOf(name) !== -1) {\n      return false;\n    }\n\n    const value = obj[name];\n\n    if (!isFunction(value)) return;\n\n    descriptor.enumerable = false;\n\n    if ('writable' in descriptor) {\n      descriptor.writable = false;\n      return;\n    }\n\n    if (!descriptor.set) {\n      descriptor.set = () => {\n        throw Error('Can not rewrite read-only method \\'' + name + '\\'');\n      };\n    }\n  });\n};\n\nconst toObjectSet = (arrayOrString, delimiter) => {\n  const obj = {};\n\n  const define = (arr) => {\n    arr.forEach(value => {\n      obj[value] = true;\n    });\n  };\n\n  isArray(arrayOrString) ? define(arrayOrString) : define(String(arrayOrString).split(delimiter));\n\n  return obj;\n};\n\nconst noop = () => {};\n\nconst toFiniteNumber = (value, defaultValue) => {\n  value = +value;\n  return Number.isFinite(value) ? value : defaultValue;\n};\n\nconst ALPHA = 'abcdefghijklmnopqrstuvwxyz';\n\nconst DIGIT = '0123456789';\n\nconst ALPHABET = {\n  DIGIT,\n  ALPHA,\n  ALPHA_DIGIT: ALPHA + ALPHA.toUpperCase() + DIGIT\n};\n\nconst generateString = (size = 16, alphabet = ALPHABET.ALPHA_DIGIT) => {\n  let str = '';\n  const {length} = alphabet;\n  while (size--) {\n    str += alphabet[Math.random() * length|0];\n  }\n\n  return str;\n};\n\n/**\n * If the thing is a FormData object, return true, otherwise return false.\n *\n * @param {unknown} thing - The thing to check.\n *\n * @returns {boolean}\n */\nfunction isSpecCompliantForm(thing) {\n  return !!(thing && isFunction(thing.append) && thing[Symbol.toStringTag] === 'FormData' && thing[Symbol.iterator]);\n}\n\nconst toJSONObject = (obj) => {\n  const stack = new Array(10);\n\n  const visit = (source, i) => {\n\n    if (isObject(source)) {\n      if (stack.indexOf(source) >= 0) {\n        return;\n      }\n\n      if(!('toJSON' in source)) {\n        stack[i] = source;\n        const target = isArray(source) ? [] : {};\n\n        forEach(source, (value, key) => {\n          const reducedValue = visit(value, i + 1);\n          !isUndefined(reducedValue) && (target[key] = reducedValue);\n        });\n\n        stack[i] = undefined;\n\n        return target;\n      }\n    }\n\n    return source;\n  };\n\n  return visit(obj, 0);\n};\n\nconst isAsyncFn = kindOfTest('AsyncFunction');\n\nconst isThenable = (thing) =>\n  thing && (isObject(thing) || isFunction(thing)) && isFunction(thing.then) && isFunction(thing.catch);\n\nvar utils = {\n  isArray,\n  isArrayBuffer,\n  isBuffer,\n  isFormData,\n  isArrayBufferView,\n  isString,\n  isNumber,\n  isBoolean,\n  isObject,\n  isPlainObject,\n  isUndefined,\n  isDate,\n  isFile,\n  isBlob,\n  isRegExp,\n  isFunction,\n  isStream,\n  isURLSearchParams,\n  isTypedArray,\n  isFileList,\n  forEach,\n  merge,\n  extend,\n  trim,\n  stripBOM,\n  inherits,\n  toFlatObject,\n  kindOf,\n  kindOfTest,\n  endsWith,\n  toArray,\n  forEachEntry,\n  matchAll,\n  isHTMLForm,\n  hasOwnProperty,\n  hasOwnProp: hasOwnProperty, // an alias to avoid ESLint no-prototype-builtins detection\n  reduceDescriptors,\n  freezeMethods,\n  toObjectSet,\n  toCamelCase,\n  noop,\n  toFiniteNumber,\n  findKey,\n  global: _global,\n  isContextDefined,\n  ALPHABET,\n  generateString,\n  isSpecCompliantForm,\n  toJSONObject,\n  isAsyncFn,\n  isThenable\n};\n\n/**\n * Create an Error with the specified message, config, error code, request and response.\n *\n * @param {string} message The error message.\n * @param {string} [code] The error code (for example, 'ECONNABORTED').\n * @param {Object} [config] The config.\n * @param {Object} [request] The request.\n * @param {Object} [response] The response.\n *\n * @returns {Error} The created error.\n */\nfunction AxiosError(message, code, config, request, response) {\n  Error.call(this);\n\n  if (Error.captureStackTrace) {\n    Error.captureStackTrace(this, this.constructor);\n  } else {\n    this.stack = (new Error()).stack;\n  }\n\n  this.message = message;\n  this.name = 'AxiosError';\n  code && (this.code = code);\n  config && (this.config = config);\n  request && (this.request = request);\n  response && (this.response = response);\n}\n\nutils.inherits(AxiosError, Error, {\n  toJSON: function toJSON() {\n    return {\n      // Standard\n      message: this.message,\n      name: this.name,\n      // Microsoft\n      description: this.description,\n      number: this.number,\n      // Mozilla\n      fileName: this.fileName,\n      lineNumber: this.lineNumber,\n      columnNumber: this.columnNumber,\n      stack: this.stack,\n      // Axios\n      config: utils.toJSONObject(this.config),\n      code: this.code,\n      status: this.response && this.response.status ? this.response.status : null\n    };\n  }\n});\n\nconst prototype$1 = AxiosError.prototype;\nconst descriptors = {};\n\n[\n  'ERR_BAD_OPTION_VALUE',\n  'ERR_BAD_OPTION',\n  'ECONNABORTED',\n  'ETIMEDOUT',\n  'ERR_NETWORK',\n  'ERR_FR_TOO_MANY_REDIRECTS',\n  'ERR_DEPRECATED',\n  'ERR_BAD_RESPONSE',\n  'ERR_BAD_REQUEST',\n  'ERR_CANCELED',\n  'ERR_NOT_SUPPORT',\n  'ERR_INVALID_URL'\n// eslint-disable-next-line func-names\n].forEach(code => {\n  descriptors[code] = {value: code};\n});\n\nObject.defineProperties(AxiosError, descriptors);\nObject.defineProperty(prototype$1, 'isAxiosError', {value: true});\n\n// eslint-disable-next-line func-names\nAxiosError.from = (error, code, config, request, response, customProps) => {\n  const axiosError = Object.create(prototype$1);\n\n  utils.toFlatObject(error, axiosError, function filter(obj) {\n    return obj !== Error.prototype;\n  }, prop => {\n    return prop !== 'isAxiosError';\n  });\n\n  AxiosError.call(axiosError, error.message, code, config, request, response);\n\n  axiosError.cause = error;\n\n  axiosError.name = error.name;\n\n  customProps && Object.assign(axiosError, customProps);\n\n  return axiosError;\n};\n\n// eslint-disable-next-line strict\nvar httpAdapter = null;\n\n/**\n * Determines if the given thing is a array or js object.\n *\n * @param {string} thing - The object or array to be visited.\n *\n * @returns {boolean}\n */\nfunction isVisitable(thing) {\n  return utils.isPlainObject(thing) || utils.isArray(thing);\n}\n\n/**\n * It removes the brackets from the end of a string\n *\n * @param {string} key - The key of the parameter.\n *\n * @returns {string} the key without the brackets.\n */\nfunction removeBrackets(key) {\n  return utils.endsWith(key, '[]') ? key.slice(0, -2) : key;\n}\n\n/**\n * It takes a path, a key, and a boolean, and returns a string\n *\n * @param {string} path - The path to the current key.\n * @param {string} key - The key of the current object being iterated over.\n * @param {string} dots - If true, the key will be rendered with dots instead of brackets.\n *\n * @returns {string} The path to the current key.\n */\nfunction renderKey(path, key, dots) {\n  if (!path) return key;\n  return path.concat(key).map(function each(token, i) {\n    // eslint-disable-next-line no-param-reassign\n    token = removeBrackets(token);\n    return !dots && i ? '[' + token + ']' : token;\n  }).join(dots ? '.' : '');\n}\n\n/**\n * If the array is an array and none of its elements are visitable, then it's a flat array.\n *\n * @param {Array<any>} arr - The array to check\n *\n * @returns {boolean}\n */\nfunction isFlatArray(arr) {\n  return utils.isArray(arr) && !arr.some(isVisitable);\n}\n\nconst predicates = utils.toFlatObject(utils, {}, null, function filter(prop) {\n  return /^is[A-Z]/.test(prop);\n});\n\n/**\n * Convert a data object to FormData\n *\n * @param {Object} obj\n * @param {?Object} [formData]\n * @param {?Object} [options]\n * @param {Function} [options.visitor]\n * @param {Boolean} [options.metaTokens = true]\n * @param {Boolean} [options.dots = false]\n * @param {?Boolean} [options.indexes = false]\n *\n * @returns {Object}\n **/\n\n/**\n * It converts an object into a FormData object\n *\n * @param {Object<any, any>} obj - The object to convert to form data.\n * @param {string} formData - The FormData object to append to.\n * @param {Object<string, any>} options\n *\n * @returns\n */\nfunction toFormData(obj, formData, options) {\n  if (!utils.isObject(obj)) {\n    throw new TypeError('target must be an object');\n  }\n\n  // eslint-disable-next-line no-param-reassign\n  formData = formData || new (FormData)();\n\n  // eslint-disable-next-line no-param-reassign\n  options = utils.toFlatObject(options, {\n    metaTokens: true,\n    dots: false,\n    indexes: false\n  }, false, function defined(option, source) {\n    // eslint-disable-next-line no-eq-null,eqeqeq\n    return !utils.isUndefined(source[option]);\n  });\n\n  const metaTokens = options.metaTokens;\n  // eslint-disable-next-line no-use-before-define\n  const visitor = options.visitor || defaultVisitor;\n  const dots = options.dots;\n  const indexes = options.indexes;\n  const _Blob = options.Blob || typeof Blob !== 'undefined' && Blob;\n  const useBlob = _Blob && utils.isSpecCompliantForm(formData);\n\n  if (!utils.isFunction(visitor)) {\n    throw new TypeError('visitor must be a function');\n  }\n\n  function convertValue(value) {\n    if (value === null) return '';\n\n    if (utils.isDate(value)) {\n      return value.toISOString();\n    }\n\n    if (!useBlob && utils.isBlob(value)) {\n      throw new AxiosError('Blob is not supported. Use a Buffer instead.');\n    }\n\n    if (utils.isArrayBuffer(value) || utils.isTypedArray(value)) {\n      return useBlob && typeof Blob === 'function' ? new Blob([value]) : Buffer.from(value);\n    }\n\n    return value;\n  }\n\n  /**\n   * Default visitor.\n   *\n   * @param {*} value\n   * @param {String|Number} key\n   * @param {Array<String|Number>} path\n   * @this {FormData}\n   *\n   * @returns {boolean} return true to visit the each prop of the value recursively\n   */\n  function defaultVisitor(value, key, path) {\n    let arr = value;\n\n    if (value && !path && typeof value === 'object') {\n      if (utils.endsWith(key, '{}')) {\n        // eslint-disable-next-line no-param-reassign\n        key = metaTokens ? key : key.slice(0, -2);\n        // eslint-disable-next-line no-param-reassign\n        value = JSON.stringify(value);\n      } else if (\n        (utils.isArray(value) && isFlatArray(value)) ||\n        ((utils.isFileList(value) || utils.endsWith(key, '[]')) && (arr = utils.toArray(value))\n        )) {\n        // eslint-disable-next-line no-param-reassign\n        key = removeBrackets(key);\n\n        arr.forEach(function each(el, index) {\n          !(utils.isUndefined(el) || el === null) && formData.append(\n            // eslint-disable-next-line no-nested-ternary\n            indexes === true ? renderKey([key], index, dots) : (indexes === null ? key : key + '[]'),\n            convertValue(el)\n          );\n        });\n        return false;\n      }\n    }\n\n    if (isVisitable(value)) {\n      return true;\n    }\n\n    formData.append(renderKey(path, key, dots), convertValue(value));\n\n    return false;\n  }\n\n  const stack = [];\n\n  const exposedHelpers = Object.assign(predicates, {\n    defaultVisitor,\n    convertValue,\n    isVisitable\n  });\n\n  function build(value, path) {\n    if (utils.isUndefined(value)) return;\n\n    if (stack.indexOf(value) !== -1) {\n      throw Error('Circular reference detected in ' + path.join('.'));\n    }\n\n    stack.push(value);\n\n    utils.forEach(value, function each(el, key) {\n      const result = !(utils.isUndefined(el) || el === null) && visitor.call(\n        formData, el, utils.isString(key) ? key.trim() : key, path, exposedHelpers\n      );\n\n      if (result === true) {\n        build(el, path ? path.concat(key) : [key]);\n      }\n    });\n\n    stack.pop();\n  }\n\n  if (!utils.isObject(obj)) {\n    throw new TypeError('data must be an object');\n  }\n\n  build(obj);\n\n  return formData;\n}\n\n/**\n * It encodes a string by replacing all characters that are not in the unreserved set with\n * their percent-encoded equivalents\n *\n * @param {string} str - The string to encode.\n *\n * @returns {string} The encoded string.\n */\nfunction encode$1(str) {\n  const charMap = {\n    '!': '%21',\n    \"'\": '%27',\n    '(': '%28',\n    ')': '%29',\n    '~': '%7E',\n    '%20': '+',\n    '%00': '\\x00'\n  };\n  return encodeURIComponent(str).replace(/[!'()~]|%20|%00/g, function replacer(match) {\n    return charMap[match];\n  });\n}\n\n/**\n * It takes a params object and converts it to a FormData object\n *\n * @param {Object<string, any>} params - The parameters to be converted to a FormData object.\n * @param {Object<string, any>} options - The options object passed to the Axios constructor.\n *\n * @returns {void}\n */\nfunction AxiosURLSearchParams(params, options) {\n  this._pairs = [];\n\n  params && toFormData(params, this, options);\n}\n\nconst prototype = AxiosURLSearchParams.prototype;\n\nprototype.append = function append(name, value) {\n  this._pairs.push([name, value]);\n};\n\nprototype.toString = function toString(encoder) {\n  const _encode = encoder ? function(value) {\n    return encoder.call(this, value, encode$1);\n  } : encode$1;\n\n  return this._pairs.map(function each(pair) {\n    return _encode(pair[0]) + '=' + _encode(pair[1]);\n  }, '').join('&');\n};\n\n/**\n * It replaces all instances of the characters `:`, `$`, `,`, `+`, `[`, and `]` with their\n * URI encoded counterparts\n *\n * @param {string} val The value to be encoded.\n *\n * @returns {string} The encoded value.\n */\nfunction encode(val) {\n  return encodeURIComponent(val).\n    replace(/%3A/gi, ':').\n    replace(/%24/g, '$').\n    replace(/%2C/gi, ',').\n    replace(/%20/g, '+').\n    replace(/%5B/gi, '[').\n    replace(/%5D/gi, ']');\n}\n\n/**\n * Build a URL by appending params to the end\n *\n * @param {string} url The base of the url (e.g., http://www.google.com)\n * @param {object} [params] The params to be appended\n * @param {?object} options\n *\n * @returns {string} The formatted url\n */\nfunction buildURL(url, params, options) {\n  /*eslint no-param-reassign:0*/\n  if (!params) {\n    return url;\n  }\n  \n  const _encode = options && options.encode || encode;\n\n  const serializeFn = options && options.serialize;\n\n  let serializedParams;\n\n  if (serializeFn) {\n    serializedParams = serializeFn(params, options);\n  } else {\n    serializedParams = utils.isURLSearchParams(params) ?\n      params.toString() :\n      new AxiosURLSearchParams(params, options).toString(_encode);\n  }\n\n  if (serializedParams) {\n    const hashmarkIndex = url.indexOf(\"#\");\n\n    if (hashmarkIndex !== -1) {\n      url = url.slice(0, hashmarkIndex);\n    }\n    url += (url.indexOf('?') === -1 ? '?' : '&') + serializedParams;\n  }\n\n  return url;\n}\n\nclass InterceptorManager {\n  constructor() {\n    this.handlers = [];\n  }\n\n  /**\n   * Add a new interceptor to the stack\n   *\n   * @param {Function} fulfilled The function to handle `then` for a `Promise`\n   * @param {Function} rejected The function to handle `reject` for a `Promise`\n   *\n   * @return {Number} An ID used to remove interceptor later\n   */\n  use(fulfilled, rejected, options) {\n    this.handlers.push({\n      fulfilled,\n      rejected,\n      synchronous: options ? options.synchronous : false,\n      runWhen: options ? options.runWhen : null\n    });\n    return this.handlers.length - 1;\n  }\n\n  /**\n   * Remove an interceptor from the stack\n   *\n   * @param {Number} id The ID that was returned by `use`\n   *\n   * @returns {Boolean} `true` if the interceptor was removed, `false` otherwise\n   */\n  eject(id) {\n    if (this.handlers[id]) {\n      this.handlers[id] = null;\n    }\n  }\n\n  /**\n   * Clear all interceptors from the stack\n   *\n   * @returns {void}\n   */\n  clear() {\n    if (this.handlers) {\n      this.handlers = [];\n    }\n  }\n\n  /**\n   * Iterate over all the registered interceptors\n   *\n   * This method is particularly useful for skipping over any\n   * interceptors that may have become `null` calling `eject`.\n   *\n   * @param {Function} fn The function to call for each interceptor\n   *\n   * @returns {void}\n   */\n  forEach(fn) {\n    utils.forEach(this.handlers, function forEachHandler(h) {\n      if (h !== null) {\n        fn(h);\n      }\n    });\n  }\n}\n\nvar InterceptorManager$1 = InterceptorManager;\n\nvar transitionalDefaults = {\n  silentJSONParsing: true,\n  forcedJSONParsing: true,\n  clarifyTimeoutError: false\n};\n\nvar URLSearchParams$1 = typeof URLSearchParams !== 'undefined' ? URLSearchParams : AxiosURLSearchParams;\n\nvar FormData$1 = typeof FormData !== 'undefined' ? FormData : null;\n\nvar Blob$1 = typeof Blob !== 'undefined' ? Blob : null;\n\n/**\n * Determine if we're running in a standard browser environment\n *\n * This allows axios to run in a web worker, and react-native.\n * Both environments support XMLHttpRequest, but not fully standard globals.\n *\n * web workers:\n *  typeof window -> undefined\n *  typeof document -> undefined\n *\n * react-native:\n *  navigator.product -> 'ReactNative'\n * nativescript\n *  navigator.product -> 'NativeScript' or 'NS'\n *\n * @returns {boolean}\n */\nconst isStandardBrowserEnv = (() => {\n  let product;\n  if (typeof navigator !== 'undefined' && (\n    (product = navigator.product) === 'ReactNative' ||\n    product === 'NativeScript' ||\n    product === 'NS')\n  ) {\n    return false;\n  }\n\n  return typeof window !== 'undefined' && typeof document !== 'undefined';\n})();\n\n/**\n * Determine if we're running in a standard browser webWorker environment\n *\n * Although the `isStandardBrowserEnv` method indicates that\n * `allows axios to run in a web worker`, the WebWorker will still be\n * filtered out due to its judgment standard\n * `typeof window !== 'undefined' && typeof document !== 'undefined'`.\n * This leads to a problem when axios post `FormData` in webWorker\n */\n const isStandardBrowserWebWorkerEnv = (() => {\n  return (\n    typeof WorkerGlobalScope !== 'undefined' &&\n    // eslint-disable-next-line no-undef\n    self instanceof WorkerGlobalScope &&\n    typeof self.importScripts === 'function'\n  );\n})();\n\n\nvar platform = {\n  isBrowser: true,\n  classes: {\n    URLSearchParams: URLSearchParams$1,\n    FormData: FormData$1,\n    Blob: Blob$1\n  },\n  isStandardBrowserEnv,\n  isStandardBrowserWebWorkerEnv,\n  protocols: ['http', 'https', 'file', 'blob', 'url', 'data']\n};\n\nfunction toURLEncodedForm(data, options) {\n  return toFormData(data, new platform.classes.URLSearchParams(), Object.assign({\n    visitor: function(value, key, path, helpers) {\n      if (platform.isNode && utils.isBuffer(value)) {\n        this.append(key, value.toString('base64'));\n        return false;\n      }\n\n      return helpers.defaultVisitor.apply(this, arguments);\n    }\n  }, options));\n}\n\n/**\n * It takes a string like `foo[x][y][z]` and returns an array like `['foo', 'x', 'y', 'z']\n *\n * @param {string} name - The name of the property to get.\n *\n * @returns An array of strings.\n */\nfunction parsePropPath(name) {\n  // foo[x][y][z]\n  // foo.x.y.z\n  // foo-x-y-z\n  // foo x y z\n  return utils.matchAll(/\\w+|\\[(\\w*)]/g, name).map(match => {\n    return match[0] === '[]' ? '' : match[1] || match[0];\n  });\n}\n\n/**\n * Convert an array to an object.\n *\n * @param {Array<any>} arr - The array to convert to an object.\n *\n * @returns An object with the same keys and values as the array.\n */\nfunction arrayToObject(arr) {\n  const obj = {};\n  const keys = Object.keys(arr);\n  let i;\n  const len = keys.length;\n  let key;\n  for (i = 0; i < len; i++) {\n    key = keys[i];\n    obj[key] = arr[key];\n  }\n  return obj;\n}\n\n/**\n * It takes a FormData object and returns a JavaScript object\n *\n * @param {string} formData The FormData object to convert to JSON.\n *\n * @returns {Object<string, any> | null} The converted object.\n */\nfunction formDataToJSON(formData) {\n  function buildPath(path, value, target, index) {\n    let name = path[index++];\n    const isNumericKey = Number.isFinite(+name);\n    const isLast = index >= path.length;\n    name = !name && utils.isArray(target) ? target.length : name;\n\n    if (isLast) {\n      if (utils.hasOwnProp(target, name)) {\n        target[name] = [target[name], value];\n      } else {\n        target[name] = value;\n      }\n\n      return !isNumericKey;\n    }\n\n    if (!target[name] || !utils.isObject(target[name])) {\n      target[name] = [];\n    }\n\n    const result = buildPath(path, value, target[name], index);\n\n    if (result && utils.isArray(target[name])) {\n      target[name] = arrayToObject(target[name]);\n    }\n\n    return !isNumericKey;\n  }\n\n  if (utils.isFormData(formData) && utils.isFunction(formData.entries)) {\n    const obj = {};\n\n    utils.forEachEntry(formData, (name, value) => {\n      buildPath(parsePropPath(name), value, obj, 0);\n    });\n\n    return obj;\n  }\n\n  return null;\n}\n\nconst DEFAULT_CONTENT_TYPE = {\n  'Content-Type': undefined\n};\n\n/**\n * It takes a string, tries to parse it, and if it fails, it returns the stringified version\n * of the input\n *\n * @param {any} rawValue - The value to be stringified.\n * @param {Function} parser - A function that parses a string into a JavaScript object.\n * @param {Function} encoder - A function that takes a value and returns a string.\n *\n * @returns {string} A stringified version of the rawValue.\n */\nfunction stringifySafely(rawValue, parser, encoder) {\n  if (utils.isString(rawValue)) {\n    try {\n      (parser || JSON.parse)(rawValue);\n      return utils.trim(rawValue);\n    } catch (e) {\n      if (e.name !== 'SyntaxError') {\n        throw e;\n      }\n    }\n  }\n\n  return (encoder || JSON.stringify)(rawValue);\n}\n\nconst defaults = {\n\n  transitional: transitionalDefaults,\n\n  adapter: ['xhr', 'http'],\n\n  transformRequest: [function transformRequest(data, headers) {\n    const contentType = headers.getContentType() || '';\n    const hasJSONContentType = contentType.indexOf('application/json') > -1;\n    const isObjectPayload = utils.isObject(data);\n\n    if (isObjectPayload && utils.isHTMLForm(data)) {\n      data = new FormData(data);\n    }\n\n    const isFormData = utils.isFormData(data);\n\n    if (isFormData) {\n      if (!hasJSONContentType) {\n        return data;\n      }\n      return hasJSONContentType ? JSON.stringify(formDataToJSON(data)) : data;\n    }\n\n    if (utils.isArrayBuffer(data) ||\n      utils.isBuffer(data) ||\n      utils.isStream(data) ||\n      utils.isFile(data) ||\n      utils.isBlob(data)\n    ) {\n      return data;\n    }\n    if (utils.isArrayBufferView(data)) {\n      return data.buffer;\n    }\n    if (utils.isURLSearchParams(data)) {\n      headers.setContentType('application/x-www-form-urlencoded;charset=utf-8', false);\n      return data.toString();\n    }\n\n    let isFileList;\n\n    if (isObjectPayload) {\n      if (contentType.indexOf('application/x-www-form-urlencoded') > -1) {\n        return toURLEncodedForm(data, this.formSerializer).toString();\n      }\n\n      if ((isFileList = utils.isFileList(data)) || contentType.indexOf('multipart/form-data') > -1) {\n        const _FormData = this.env && this.env.FormData;\n\n        return toFormData(\n          isFileList ? {'files[]': data} : data,\n          _FormData && new _FormData(),\n          this.formSerializer\n        );\n      }\n    }\n\n    if (isObjectPayload || hasJSONContentType ) {\n      headers.setContentType('application/json', false);\n      return stringifySafely(data);\n    }\n\n    return data;\n  }],\n\n  transformResponse: [function transformResponse(data) {\n    const transitional = this.transitional || defaults.transitional;\n    const forcedJSONParsing = transitional && transitional.forcedJSONParsing;\n    const JSONRequested = this.responseType === 'json';\n\n    if (data && utils.isString(data) && ((forcedJSONParsing && !this.responseType) || JSONRequested)) {\n      const silentJSONParsing = transitional && transitional.silentJSONParsing;\n      const strictJSONParsing = !silentJSONParsing && JSONRequested;\n\n      try {\n        return JSON.parse(data);\n      } catch (e) {\n        if (strictJSONParsing) {\n          if (e.name === 'SyntaxError') {\n            throw AxiosError.from(e, AxiosError.ERR_BAD_RESPONSE, this, null, this.response);\n          }\n          throw e;\n        }\n      }\n    }\n\n    return data;\n  }],\n\n  /**\n   * A timeout in milliseconds to abort a request. If set to 0 (default) a\n   * timeout is not created.\n   */\n  timeout: 0,\n\n  xsrfCookieName: 'XSRF-TOKEN',\n  xsrfHeaderName: 'X-XSRF-TOKEN',\n\n  maxContentLength: -1,\n  maxBodyLength: -1,\n\n  env: {\n    FormData: platform.classes.FormData,\n    Blob: platform.classes.Blob\n  },\n\n  validateStatus: function validateStatus(status) {\n    return status >= 200 && status < 300;\n  },\n\n  headers: {\n    common: {\n      'Accept': 'application/json, text/plain, */*'\n    }\n  }\n};\n\nutils.forEach(['delete', 'get', 'head'], function forEachMethodNoData(method) {\n  defaults.headers[method] = {};\n});\n\nutils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {\n  defaults.headers[method] = utils.merge(DEFAULT_CONTENT_TYPE);\n});\n\nvar defaults$1 = defaults;\n\n// RawAxiosHeaders whose duplicates are ignored by node\n// c.f. https://nodejs.org/api/http.html#http_message_headers\nconst ignoreDuplicateOf = utils.toObjectSet([\n  'age', 'authorization', 'content-length', 'content-type', 'etag',\n  'expires', 'from', 'host', 'if-modified-since', 'if-unmodified-since',\n  'last-modified', 'location', 'max-forwards', 'proxy-authorization',\n  'referer', 'retry-after', 'user-agent'\n]);\n\n/**\n * Parse headers into an object\n *\n * ```\n * Date: Wed, 27 Aug 2014 08:58:49 GMT\n * Content-Type: application/json\n * Connection: keep-alive\n * Transfer-Encoding: chunked\n * ```\n *\n * @param {String} rawHeaders Headers needing to be parsed\n *\n * @returns {Object} Headers parsed into an object\n */\nvar parseHeaders = rawHeaders => {\n  const parsed = {};\n  let key;\n  let val;\n  let i;\n\n  rawHeaders && rawHeaders.split('\\n').forEach(function parser(line) {\n    i = line.indexOf(':');\n    key = line.substring(0, i).trim().toLowerCase();\n    val = line.substring(i + 1).trim();\n\n    if (!key || (parsed[key] && ignoreDuplicateOf[key])) {\n      return;\n    }\n\n    if (key === 'set-cookie') {\n      if (parsed[key]) {\n        parsed[key].push(val);\n      } else {\n        parsed[key] = [val];\n      }\n    } else {\n      parsed[key] = parsed[key] ? parsed[key] + ', ' + val : val;\n    }\n  });\n\n  return parsed;\n};\n\nconst $internals = Symbol('internals');\n\nfunction normalizeHeader(header) {\n  return header && String(header).trim().toLowerCase();\n}\n\nfunction normalizeValue(value) {\n  if (value === false || value == null) {\n    return value;\n  }\n\n  return utils.isArray(value) ? value.map(normalizeValue) : String(value);\n}\n\nfunction parseTokens(str) {\n  const tokens = Object.create(null);\n  const tokensRE = /([^\\s,;=]+)\\s*(?:=\\s*([^,;]+))?/g;\n  let match;\n\n  while ((match = tokensRE.exec(str))) {\n    tokens[match[1]] = match[2];\n  }\n\n  return tokens;\n}\n\nconst isValidHeaderName = (str) => /^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(str.trim());\n\nfunction matchHeaderValue(context, value, header, filter, isHeaderNameFilter) {\n  if (utils.isFunction(filter)) {\n    return filter.call(this, value, header);\n  }\n\n  if (isHeaderNameFilter) {\n    value = header;\n  }\n\n  if (!utils.isString(value)) return;\n\n  if (utils.isString(filter)) {\n    return value.indexOf(filter) !== -1;\n  }\n\n  if (utils.isRegExp(filter)) {\n    return filter.test(value);\n  }\n}\n\nfunction formatHeader(header) {\n  return header.trim()\n    .toLowerCase().replace(/([a-z\\d])(\\w*)/g, (w, char, str) => {\n      return char.toUpperCase() + str;\n    });\n}\n\nfunction buildAccessors(obj, header) {\n  const accessorName = utils.toCamelCase(' ' + header);\n\n  ['get', 'set', 'has'].forEach(methodName => {\n    Object.defineProperty(obj, methodName + accessorName, {\n      value: function(arg1, arg2, arg3) {\n        return this[methodName].call(this, header, arg1, arg2, arg3);\n      },\n      configurable: true\n    });\n  });\n}\n\nclass AxiosHeaders {\n  constructor(headers) {\n    headers && this.set(headers);\n  }\n\n  set(header, valueOrRewrite, rewrite) {\n    const self = this;\n\n    function setHeader(_value, _header, _rewrite) {\n      const lHeader = normalizeHeader(_header);\n\n      if (!lHeader) {\n        throw new Error('header name must be a non-empty string');\n      }\n\n      const key = utils.findKey(self, lHeader);\n\n      if(!key || self[key] === undefined || _rewrite === true || (_rewrite === undefined && self[key] !== false)) {\n        self[key || _header] = normalizeValue(_value);\n      }\n    }\n\n    const setHeaders = (headers, _rewrite) =>\n      utils.forEach(headers, (_value, _header) => setHeader(_value, _header, _rewrite));\n\n    if (utils.isPlainObject(header) || header instanceof this.constructor) {\n      setHeaders(header, valueOrRewrite);\n    } else if(utils.isString(header) && (header = header.trim()) && !isValidHeaderName(header)) {\n      setHeaders(parseHeaders(header), valueOrRewrite);\n    } else {\n      header != null && setHeader(valueOrRewrite, header, rewrite);\n    }\n\n    return this;\n  }\n\n  get(header, parser) {\n    header = normalizeHeader(header);\n\n    if (header) {\n      const key = utils.findKey(this, header);\n\n      if (key) {\n        const value = this[key];\n\n        if (!parser) {\n          return value;\n        }\n\n        if (parser === true) {\n          return parseTokens(value);\n        }\n\n        if (utils.isFunction(parser)) {\n          return parser.call(this, value, key);\n        }\n\n        if (utils.isRegExp(parser)) {\n          return parser.exec(value);\n        }\n\n        throw new TypeError('parser must be boolean|regexp|function');\n      }\n    }\n  }\n\n  has(header, matcher) {\n    header = normalizeHeader(header);\n\n    if (header) {\n      const key = utils.findKey(this, header);\n\n      return !!(key && this[key] !== undefined && (!matcher || matchHeaderValue(this, this[key], key, matcher)));\n    }\n\n    return false;\n  }\n\n  delete(header, matcher) {\n    const self = this;\n    let deleted = false;\n\n    function deleteHeader(_header) {\n      _header = normalizeHeader(_header);\n\n      if (_header) {\n        const key = utils.findKey(self, _header);\n\n        if (key && (!matcher || matchHeaderValue(self, self[key], key, matcher))) {\n          delete self[key];\n\n          deleted = true;\n        }\n      }\n    }\n\n    if (utils.isArray(header)) {\n      header.forEach(deleteHeader);\n    } else {\n      deleteHeader(header);\n    }\n\n    return deleted;\n  }\n\n  clear(matcher) {\n    const keys = Object.keys(this);\n    let i = keys.length;\n    let deleted = false;\n\n    while (i--) {\n      const key = keys[i];\n      if(!matcher || matchHeaderValue(this, this[key], key, matcher, true)) {\n        delete this[key];\n        deleted = true;\n      }\n    }\n\n    return deleted;\n  }\n\n  normalize(format) {\n    const self = this;\n    const headers = {};\n\n    utils.forEach(this, (value, header) => {\n      const key = utils.findKey(headers, header);\n\n      if (key) {\n        self[key] = normalizeValue(value);\n        delete self[header];\n        return;\n      }\n\n      const normalized = format ? formatHeader(header) : String(header).trim();\n\n      if (normalized !== header) {\n        delete self[header];\n      }\n\n      self[normalized] = normalizeValue(value);\n\n      headers[normalized] = true;\n    });\n\n    return this;\n  }\n\n  concat(...targets) {\n    return this.constructor.concat(this, ...targets);\n  }\n\n  toJSON(asStrings) {\n    const obj = Object.create(null);\n\n    utils.forEach(this, (value, header) => {\n      value != null && value !== false && (obj[header] = asStrings && utils.isArray(value) ? value.join(', ') : value);\n    });\n\n    return obj;\n  }\n\n  [Symbol.iterator]() {\n    return Object.entries(this.toJSON())[Symbol.iterator]();\n  }\n\n  toString() {\n    return Object.entries(this.toJSON()).map(([header, value]) => header + ': ' + value).join('\\n');\n  }\n\n  get [Symbol.toStringTag]() {\n    return 'AxiosHeaders';\n  }\n\n  static from(thing) {\n    return thing instanceof this ? thing : new this(thing);\n  }\n\n  static concat(first, ...targets) {\n    const computed = new this(first);\n\n    targets.forEach((target) => computed.set(target));\n\n    return computed;\n  }\n\n  static accessor(header) {\n    const internals = this[$internals] = (this[$internals] = {\n      accessors: {}\n    });\n\n    const accessors = internals.accessors;\n    const prototype = this.prototype;\n\n    function defineAccessor(_header) {\n      const lHeader = normalizeHeader(_header);\n\n      if (!accessors[lHeader]) {\n        buildAccessors(prototype, _header);\n        accessors[lHeader] = true;\n      }\n    }\n\n    utils.isArray(header) ? header.forEach(defineAccessor) : defineAccessor(header);\n\n    return this;\n  }\n}\n\nAxiosHeaders.accessor(['Content-Type', 'Content-Length', 'Accept', 'Accept-Encoding', 'User-Agent', 'Authorization']);\n\nutils.freezeMethods(AxiosHeaders.prototype);\nutils.freezeMethods(AxiosHeaders);\n\nvar AxiosHeaders$1 = AxiosHeaders;\n\n/**\n * Transform the data for a request or a response\n *\n * @param {Array|Function} fns A single function or Array of functions\n * @param {?Object} response The response object\n *\n * @returns {*} The resulting transformed data\n */\nfunction transformData(fns, response) {\n  const config = this || defaults$1;\n  const context = response || config;\n  const headers = AxiosHeaders$1.from(context.headers);\n  let data = context.data;\n\n  utils.forEach(fns, function transform(fn) {\n    data = fn.call(config, data, headers.normalize(), response ? response.status : undefined);\n  });\n\n  headers.normalize();\n\n  return data;\n}\n\nfunction isCancel(value) {\n  return !!(value && value.__CANCEL__);\n}\n\n/**\n * A `CanceledError` is an object that is thrown when an operation is canceled.\n *\n * @param {string=} message The message.\n * @param {Object=} config The config.\n * @param {Object=} request The request.\n *\n * @returns {CanceledError} The created error.\n */\nfunction CanceledError(message, config, request) {\n  // eslint-disable-next-line no-eq-null,eqeqeq\n  AxiosError.call(this, message == null ? 'canceled' : message, AxiosError.ERR_CANCELED, config, request);\n  this.name = 'CanceledError';\n}\n\nutils.inherits(CanceledError, AxiosError, {\n  __CANCEL__: true\n});\n\n/**\n * Resolve or reject a Promise based on response status.\n *\n * @param {Function} resolve A function that resolves the promise.\n * @param {Function} reject A function that rejects the promise.\n * @param {object} response The response.\n *\n * @returns {object} The response.\n */\nfunction settle(resolve, reject, response) {\n  const validateStatus = response.config.validateStatus;\n  if (!response.status || !validateStatus || validateStatus(response.status)) {\n    resolve(response);\n  } else {\n    reject(new AxiosError(\n      'Request failed with status code ' + response.status,\n      [AxiosError.ERR_BAD_REQUEST, AxiosError.ERR_BAD_RESPONSE][Math.floor(response.status / 100) - 4],\n      response.config,\n      response.request,\n      response\n    ));\n  }\n}\n\nvar cookies = platform.isStandardBrowserEnv ?\n\n// Standard browser envs support document.cookie\n  (function standardBrowserEnv() {\n    return {\n      write: function write(name, value, expires, path, domain, secure) {\n        const cookie = [];\n        cookie.push(name + '=' + encodeURIComponent(value));\n\n        if (utils.isNumber(expires)) {\n          cookie.push('expires=' + new Date(expires).toGMTString());\n        }\n\n        if (utils.isString(path)) {\n          cookie.push('path=' + path);\n        }\n\n        if (utils.isString(domain)) {\n          cookie.push('domain=' + domain);\n        }\n\n        if (secure === true) {\n          cookie.push('secure');\n        }\n\n        document.cookie = cookie.join('; ');\n      },\n\n      read: function read(name) {\n        const match = document.cookie.match(new RegExp('(^|;\\\\s*)(' + name + ')=([^;]*)'));\n        return (match ? decodeURIComponent(match[3]) : null);\n      },\n\n      remove: function remove(name) {\n        this.write(name, '', Date.now() - 86400000);\n      }\n    };\n  })() :\n\n// Non standard browser env (web workers, react-native) lack needed support.\n  (function nonStandardBrowserEnv() {\n    return {\n      write: function write() {},\n      read: function read() { return null; },\n      remove: function remove() {}\n    };\n  })();\n\n/**\n * Determines whether the specified URL is absolute\n *\n * @param {string} url The URL to test\n *\n * @returns {boolean} True if the specified URL is absolute, otherwise false\n */\nfunction isAbsoluteURL(url) {\n  // A URL is considered absolute if it begins with \"<scheme>://\" or \"//\" (protocol-relative URL).\n  // RFC 3986 defines scheme name as a sequence of characters beginning with a letter and followed\n  // by any combination of letters, digits, plus, period, or hyphen.\n  return /^([a-z][a-z\\d+\\-.]*:)?\\/\\//i.test(url);\n}\n\n/**\n * Creates a new URL by combining the specified URLs\n *\n * @param {string} baseURL The base URL\n * @param {string} relativeURL The relative URL\n *\n * @returns {string} The combined URL\n */\nfunction combineURLs(baseURL, relativeURL) {\n  return relativeURL\n    ? baseURL.replace(/\\/+$/, '') + '/' + relativeURL.replace(/^\\/+/, '')\n    : baseURL;\n}\n\n/**\n * Creates a new URL by combining the baseURL with the requestedURL,\n * only when the requestedURL is not already an absolute URL.\n * If the requestURL is absolute, this function returns the requestedURL untouched.\n *\n * @param {string} baseURL The base URL\n * @param {string} requestedURL Absolute or relative URL to combine\n *\n * @returns {string} The combined full path\n */\nfunction buildFullPath(baseURL, requestedURL) {\n  if (baseURL && !isAbsoluteURL(requestedURL)) {\n    return combineURLs(baseURL, requestedURL);\n  }\n  return requestedURL;\n}\n\nvar isURLSameOrigin = platform.isStandardBrowserEnv ?\n\n// Standard browser envs have full support of the APIs needed to test\n// whether the request URL is of the same origin as current location.\n  (function standardBrowserEnv() {\n    const msie = /(msie|trident)/i.test(navigator.userAgent);\n    const urlParsingNode = document.createElement('a');\n    let originURL;\n\n    /**\n    * Parse a URL to discover it's components\n    *\n    * @param {String} url The URL to be parsed\n    * @returns {Object}\n    */\n    function resolveURL(url) {\n      let href = url;\n\n      if (msie) {\n        // IE needs attribute set twice to normalize properties\n        urlParsingNode.setAttribute('href', href);\n        href = urlParsingNode.href;\n      }\n\n      urlParsingNode.setAttribute('href', href);\n\n      // urlParsingNode provides the UrlUtils interface - http://url.spec.whatwg.org/#urlutils\n      return {\n        href: urlParsingNode.href,\n        protocol: urlParsingNode.protocol ? urlParsingNode.protocol.replace(/:$/, '') : '',\n        host: urlParsingNode.host,\n        search: urlParsingNode.search ? urlParsingNode.search.replace(/^\\?/, '') : '',\n        hash: urlParsingNode.hash ? urlParsingNode.hash.replace(/^#/, '') : '',\n        hostname: urlParsingNode.hostname,\n        port: urlParsingNode.port,\n        pathname: (urlParsingNode.pathname.charAt(0) === '/') ?\n          urlParsingNode.pathname :\n          '/' + urlParsingNode.pathname\n      };\n    }\n\n    originURL = resolveURL(window.location.href);\n\n    /**\n    * Determine if a URL shares the same origin as the current location\n    *\n    * @param {String} requestURL The URL to test\n    * @returns {boolean} True if URL shares the same origin, otherwise false\n    */\n    return function isURLSameOrigin(requestURL) {\n      const parsed = (utils.isString(requestURL)) ? resolveURL(requestURL) : requestURL;\n      return (parsed.protocol === originURL.protocol &&\n          parsed.host === originURL.host);\n    };\n  })() :\n\n  // Non standard browser envs (web workers, react-native) lack needed support.\n  (function nonStandardBrowserEnv() {\n    return function isURLSameOrigin() {\n      return true;\n    };\n  })();\n\nfunction parseProtocol(url) {\n  const match = /^([-+\\w]{1,25})(:?\\/\\/|:)/.exec(url);\n  return match && match[1] || '';\n}\n\n/**\n * Calculate data maxRate\n * @param {Number} [samplesCount= 10]\n * @param {Number} [min= 1000]\n * @returns {Function}\n */\nfunction speedometer(samplesCount, min) {\n  samplesCount = samplesCount || 10;\n  const bytes = new Array(samplesCount);\n  const timestamps = new Array(samplesCount);\n  let head = 0;\n  let tail = 0;\n  let firstSampleTS;\n\n  min = min !== undefined ? min : 1000;\n\n  return function push(chunkLength) {\n    const now = Date.now();\n\n    const startedAt = timestamps[tail];\n\n    if (!firstSampleTS) {\n      firstSampleTS = now;\n    }\n\n    bytes[head] = chunkLength;\n    timestamps[head] = now;\n\n    let i = tail;\n    let bytesCount = 0;\n\n    while (i !== head) {\n      bytesCount += bytes[i++];\n      i = i % samplesCount;\n    }\n\n    head = (head + 1) % samplesCount;\n\n    if (head === tail) {\n      tail = (tail + 1) % samplesCount;\n    }\n\n    if (now - firstSampleTS < min) {\n      return;\n    }\n\n    const passed = startedAt && now - startedAt;\n\n    return passed ? Math.round(bytesCount * 1000 / passed) : undefined;\n  };\n}\n\nfunction progressEventReducer(listener, isDownloadStream) {\n  let bytesNotified = 0;\n  const _speedometer = speedometer(50, 250);\n\n  return e => {\n    const loaded = e.loaded;\n    const total = e.lengthComputable ? e.total : undefined;\n    const progressBytes = loaded - bytesNotified;\n    const rate = _speedometer(progressBytes);\n    const inRange = loaded <= total;\n\n    bytesNotified = loaded;\n\n    const data = {\n      loaded,\n      total,\n      progress: total ? (loaded / total) : undefined,\n      bytes: progressBytes,\n      rate: rate ? rate : undefined,\n      estimated: rate && total && inRange ? (total - loaded) / rate : undefined,\n      event: e\n    };\n\n    data[isDownloadStream ? 'download' : 'upload'] = true;\n\n    listener(data);\n  };\n}\n\nconst isXHRAdapterSupported = typeof XMLHttpRequest !== 'undefined';\n\nvar xhrAdapter = isXHRAdapterSupported && function (config) {\n  return new Promise(function dispatchXhrRequest(resolve, reject) {\n    let requestData = config.data;\n    const requestHeaders = AxiosHeaders$1.from(config.headers).normalize();\n    const responseType = config.responseType;\n    let onCanceled;\n    function done() {\n      if (config.cancelToken) {\n        config.cancelToken.unsubscribe(onCanceled);\n      }\n\n      if (config.signal) {\n        config.signal.removeEventListener('abort', onCanceled);\n      }\n    }\n\n    if (utils.isFormData(requestData)) {\n      if (platform.isStandardBrowserEnv || platform.isStandardBrowserWebWorkerEnv) {\n        requestHeaders.setContentType(false); // Let the browser set it\n      } else {\n        requestHeaders.setContentType('multipart/form-data;', false); // mobile/desktop app frameworks\n      }\n    }\n\n    let request = new XMLHttpRequest();\n\n    // HTTP basic authentication\n    if (config.auth) {\n      const username = config.auth.username || '';\n      const password = config.auth.password ? unescape(encodeURIComponent(config.auth.password)) : '';\n      requestHeaders.set('Authorization', 'Basic ' + btoa(username + ':' + password));\n    }\n\n    const fullPath = buildFullPath(config.baseURL, config.url);\n\n    request.open(config.method.toUpperCase(), buildURL(fullPath, config.params, config.paramsSerializer), true);\n\n    // Set the request timeout in MS\n    request.timeout = config.timeout;\n\n    function onloadend() {\n      if (!request) {\n        return;\n      }\n      // Prepare the response\n      const responseHeaders = AxiosHeaders$1.from(\n        'getAllResponseHeaders' in request && request.getAllResponseHeaders()\n      );\n      const responseData = !responseType || responseType === 'text' || responseType === 'json' ?\n        request.responseText : request.response;\n      const response = {\n        data: responseData,\n        status: request.status,\n        statusText: request.statusText,\n        headers: responseHeaders,\n        config,\n        request\n      };\n\n      settle(function _resolve(value) {\n        resolve(value);\n        done();\n      }, function _reject(err) {\n        reject(err);\n        done();\n      }, response);\n\n      // Clean up request\n      request = null;\n    }\n\n    if ('onloadend' in request) {\n      // Use onloadend if available\n      request.onloadend = onloadend;\n    } else {\n      // Listen for ready state to emulate onloadend\n      request.onreadystatechange = function handleLoad() {\n        if (!request || request.readyState !== 4) {\n          return;\n        }\n\n        // The request errored out and we didn't get a response, this will be\n        // handled by onerror instead\n        // With one exception: request that using file: protocol, most browsers\n        // will return status as 0 even though it's a successful request\n        if (request.status === 0 && !(request.responseURL && request.responseURL.indexOf('file:') === 0)) {\n          return;\n        }\n        // readystate handler is calling before onerror or ontimeout handlers,\n        // so we should call onloadend on the next 'tick'\n        setTimeout(onloadend);\n      };\n    }\n\n    // Handle browser request cancellation (as opposed to a manual cancellation)\n    request.onabort = function handleAbort() {\n      if (!request) {\n        return;\n      }\n\n      reject(new AxiosError('Request aborted', AxiosError.ECONNABORTED, config, request));\n\n      // Clean up request\n      request = null;\n    };\n\n    // Handle low level network errors\n    request.onerror = function handleError() {\n      // Real errors are hidden from us by the browser\n      // onerror should only fire if it's a network error\n      reject(new AxiosError('Network Error', AxiosError.ERR_NETWORK, config, request));\n\n      // Clean up request\n      request = null;\n    };\n\n    // Handle timeout\n    request.ontimeout = function handleTimeout() {\n      let timeoutErrorMessage = config.timeout ? 'timeout of ' + config.timeout + 'ms exceeded' : 'timeout exceeded';\n      const transitional = config.transitional || transitionalDefaults;\n      if (config.timeoutErrorMessage) {\n        timeoutErrorMessage = config.timeoutErrorMessage;\n      }\n      reject(new AxiosError(\n        timeoutErrorMessage,\n        transitional.clarifyTimeoutError ? AxiosError.ETIMEDOUT : AxiosError.ECONNABORTED,\n        config,\n        request));\n\n      // Clean up request\n      request = null;\n    };\n\n    // Add xsrf header\n    // This is only done if running in a standard browser environment.\n    // Specifically not if we're in a web worker, or react-native.\n    if (platform.isStandardBrowserEnv) {\n      // Add xsrf header\n      const xsrfValue = (config.withCredentials || isURLSameOrigin(fullPath))\n        && config.xsrfCookieName && cookies.read(config.xsrfCookieName);\n\n      if (xsrfValue) {\n        requestHeaders.set(config.xsrfHeaderName, xsrfValue);\n      }\n    }\n\n    // Remove Content-Type if data is undefined\n    requestData === undefined && requestHeaders.setContentType(null);\n\n    // Add headers to the request\n    if ('setRequestHeader' in request) {\n      utils.forEach(requestHeaders.toJSON(), function setRequestHeader(val, key) {\n        request.setRequestHeader(key, val);\n      });\n    }\n\n    // Add withCredentials to request if needed\n    if (!utils.isUndefined(config.withCredentials)) {\n      request.withCredentials = !!config.withCredentials;\n    }\n\n    // Add responseType to request if needed\n    if (responseType && responseType !== 'json') {\n      request.responseType = config.responseType;\n    }\n\n    // Handle progress if needed\n    if (typeof config.onDownloadProgress === 'function') {\n      request.addEventListener('progress', progressEventReducer(config.onDownloadProgress, true));\n    }\n\n    // Not all browsers support upload events\n    if (typeof config.onUploadProgress === 'function' && request.upload) {\n      request.upload.addEventListener('progress', progressEventReducer(config.onUploadProgress));\n    }\n\n    if (config.cancelToken || config.signal) {\n      // Handle cancellation\n      // eslint-disable-next-line func-names\n      onCanceled = cancel => {\n        if (!request) {\n          return;\n        }\n        reject(!cancel || cancel.type ? new CanceledError(null, config, request) : cancel);\n        request.abort();\n        request = null;\n      };\n\n      config.cancelToken && config.cancelToken.subscribe(onCanceled);\n      if (config.signal) {\n        config.signal.aborted ? onCanceled() : config.signal.addEventListener('abort', onCanceled);\n      }\n    }\n\n    const protocol = parseProtocol(fullPath);\n\n    if (protocol && platform.protocols.indexOf(protocol) === -1) {\n      reject(new AxiosError('Unsupported protocol ' + protocol + ':', AxiosError.ERR_BAD_REQUEST, config));\n      return;\n    }\n\n\n    // Send the request\n    request.send(requestData || null);\n  });\n};\n\nconst knownAdapters = {\n  http: httpAdapter,\n  xhr: xhrAdapter\n};\n\nutils.forEach(knownAdapters, (fn, value) => {\n  if(fn) {\n    try {\n      Object.defineProperty(fn, 'name', {value});\n    } catch (e) {\n      // eslint-disable-next-line no-empty\n    }\n    Object.defineProperty(fn, 'adapterName', {value});\n  }\n});\n\nvar adapters = {\n  getAdapter: (adapters) => {\n    adapters = utils.isArray(adapters) ? adapters : [adapters];\n\n    const {length} = adapters;\n    let nameOrAdapter;\n    let adapter;\n\n    for (let i = 0; i < length; i++) {\n      nameOrAdapter = adapters[i];\n      if((adapter = utils.isString(nameOrAdapter) ? knownAdapters[nameOrAdapter.toLowerCase()] : nameOrAdapter)) {\n        break;\n      }\n    }\n\n    if (!adapter) {\n      if (adapter === false) {\n        throw new AxiosError(\n          `Adapter ${nameOrAdapter} is not supported by the environment`,\n          'ERR_NOT_SUPPORT'\n        );\n      }\n\n      throw new Error(\n        utils.hasOwnProp(knownAdapters, nameOrAdapter) ?\n          `Adapter '${nameOrAdapter}' is not available in the build` :\n          `Unknown adapter '${nameOrAdapter}'`\n      );\n    }\n\n    if (!utils.isFunction(adapter)) {\n      throw new TypeError('adapter is not a function');\n    }\n\n    return adapter;\n  },\n  adapters: knownAdapters\n};\n\n/**\n * Throws a `CanceledError` if cancellation has been requested.\n *\n * @param {Object} config The config that is to be used for the request\n *\n * @returns {void}\n */\nfunction throwIfCancellationRequested(config) {\n  if (config.cancelToken) {\n    config.cancelToken.throwIfRequested();\n  }\n\n  if (config.signal && config.signal.aborted) {\n    throw new CanceledError(null, config);\n  }\n}\n\n/**\n * Dispatch a request to the server using the configured adapter.\n *\n * @param {object} config The config that is to be used for the request\n *\n * @returns {Promise} The Promise to be fulfilled\n */\nfunction dispatchRequest(config) {\n  throwIfCancellationRequested(config);\n\n  config.headers = AxiosHeaders$1.from(config.headers);\n\n  // Transform request data\n  config.data = transformData.call(\n    config,\n    config.transformRequest\n  );\n\n  if (['post', 'put', 'patch'].indexOf(config.method) !== -1) {\n    config.headers.setContentType('application/x-www-form-urlencoded', false);\n  }\n\n  const adapter = adapters.getAdapter(config.adapter || defaults$1.adapter);\n\n  return adapter(config).then(function onAdapterResolution(response) {\n    throwIfCancellationRequested(config);\n\n    // Transform response data\n    response.data = transformData.call(\n      config,\n      config.transformResponse,\n      response\n    );\n\n    response.headers = AxiosHeaders$1.from(response.headers);\n\n    return response;\n  }, function onAdapterRejection(reason) {\n    if (!isCancel(reason)) {\n      throwIfCancellationRequested(config);\n\n      // Transform response data\n      if (reason && reason.response) {\n        reason.response.data = transformData.call(\n          config,\n          config.transformResponse,\n          reason.response\n        );\n        reason.response.headers = AxiosHeaders$1.from(reason.response.headers);\n      }\n    }\n\n    return Promise.reject(reason);\n  });\n}\n\nconst headersToObject = (thing) => thing instanceof AxiosHeaders$1 ? thing.toJSON() : thing;\n\n/**\n * Config-specific merge-function which creates a new config-object\n * by merging two configuration objects together.\n *\n * @param {Object} config1\n * @param {Object} config2\n *\n * @returns {Object} New object resulting from merging config2 to config1\n */\nfunction mergeConfig(config1, config2) {\n  // eslint-disable-next-line no-param-reassign\n  config2 = config2 || {};\n  const config = {};\n\n  function getMergedValue(target, source, caseless) {\n    if (utils.isPlainObject(target) && utils.isPlainObject(source)) {\n      return utils.merge.call({caseless}, target, source);\n    } else if (utils.isPlainObject(source)) {\n      return utils.merge({}, source);\n    } else if (utils.isArray(source)) {\n      return source.slice();\n    }\n    return source;\n  }\n\n  // eslint-disable-next-line consistent-return\n  function mergeDeepProperties(a, b, caseless) {\n    if (!utils.isUndefined(b)) {\n      return getMergedValue(a, b, caseless);\n    } else if (!utils.isUndefined(a)) {\n      return getMergedValue(undefined, a, caseless);\n    }\n  }\n\n  // eslint-disable-next-line consistent-return\n  function valueFromConfig2(a, b) {\n    if (!utils.isUndefined(b)) {\n      return getMergedValue(undefined, b);\n    }\n  }\n\n  // eslint-disable-next-line consistent-return\n  function defaultToConfig2(a, b) {\n    if (!utils.isUndefined(b)) {\n      return getMergedValue(undefined, b);\n    } else if (!utils.isUndefined(a)) {\n      return getMergedValue(undefined, a);\n    }\n  }\n\n  // eslint-disable-next-line consistent-return\n  function mergeDirectKeys(a, b, prop) {\n    if (prop in config2) {\n      return getMergedValue(a, b);\n    } else if (prop in config1) {\n      return getMergedValue(undefined, a);\n    }\n  }\n\n  const mergeMap = {\n    url: valueFromConfig2,\n    method: valueFromConfig2,\n    data: valueFromConfig2,\n    baseURL: defaultToConfig2,\n    transformRequest: defaultToConfig2,\n    transformResponse: defaultToConfig2,\n    paramsSerializer: defaultToConfig2,\n    timeout: defaultToConfig2,\n    timeoutMessage: defaultToConfig2,\n    withCredentials: defaultToConfig2,\n    adapter: defaultToConfig2,\n    responseType: defaultToConfig2,\n    xsrfCookieName: defaultToConfig2,\n    xsrfHeaderName: defaultToConfig2,\n    onUploadProgress: defaultToConfig2,\n    onDownloadProgress: defaultToConfig2,\n    decompress: defaultToConfig2,\n    maxContentLength: defaultToConfig2,\n    maxBodyLength: defaultToConfig2,\n    beforeRedirect: defaultToConfig2,\n    transport: defaultToConfig2,\n    httpAgent: defaultToConfig2,\n    httpsAgent: defaultToConfig2,\n    cancelToken: defaultToConfig2,\n    socketPath: defaultToConfig2,\n    responseEncoding: defaultToConfig2,\n    validateStatus: mergeDirectKeys,\n    headers: (a, b) => mergeDeepProperties(headersToObject(a), headersToObject(b), true)\n  };\n\n  utils.forEach(Object.keys(Object.assign({}, config1, config2)), function computeConfigValue(prop) {\n    const merge = mergeMap[prop] || mergeDeepProperties;\n    const configValue = merge(config1[prop], config2[prop], prop);\n    (utils.isUndefined(configValue) && merge !== mergeDirectKeys) || (config[prop] = configValue);\n  });\n\n  return config;\n}\n\nconst VERSION = \"1.4.0\";\n\nconst validators$1 = {};\n\n// eslint-disable-next-line func-names\n['object', 'boolean', 'number', 'function', 'string', 'symbol'].forEach((type, i) => {\n  validators$1[type] = function validator(thing) {\n    return typeof thing === type || 'a' + (i < 1 ? 'n ' : ' ') + type;\n  };\n});\n\nconst deprecatedWarnings = {};\n\n/**\n * Transitional option validator\n *\n * @param {function|boolean?} validator - set to false if the transitional option has been removed\n * @param {string?} version - deprecated version / removed since version\n * @param {string?} message - some message with additional info\n *\n * @returns {function}\n */\nvalidators$1.transitional = function transitional(validator, version, message) {\n  function formatMessage(opt, desc) {\n    return '[Axios v' + VERSION + '] Transitional option \\'' + opt + '\\'' + desc + (message ? '. ' + message : '');\n  }\n\n  // eslint-disable-next-line func-names\n  return (value, opt, opts) => {\n    if (validator === false) {\n      throw new AxiosError(\n        formatMessage(opt, ' has been removed' + (version ? ' in ' + version : '')),\n        AxiosError.ERR_DEPRECATED\n      );\n    }\n\n    if (version && !deprecatedWarnings[opt]) {\n      deprecatedWarnings[opt] = true;\n      // eslint-disable-next-line no-console\n      console.warn(\n        formatMessage(\n          opt,\n          ' has been deprecated since v' + version + ' and will be removed in the near future'\n        )\n      );\n    }\n\n    return validator ? validator(value, opt, opts) : true;\n  };\n};\n\n/**\n * Assert object's properties type\n *\n * @param {object} options\n * @param {object} schema\n * @param {boolean?} allowUnknown\n *\n * @returns {object}\n */\n\nfunction assertOptions(options, schema, allowUnknown) {\n  if (typeof options !== 'object') {\n    throw new AxiosError('options must be an object', AxiosError.ERR_BAD_OPTION_VALUE);\n  }\n  const keys = Object.keys(options);\n  let i = keys.length;\n  while (i-- > 0) {\n    const opt = keys[i];\n    const validator = schema[opt];\n    if (validator) {\n      const value = options[opt];\n      const result = value === undefined || validator(value, opt, options);\n      if (result !== true) {\n        throw new AxiosError('option ' + opt + ' must be ' + result, AxiosError.ERR_BAD_OPTION_VALUE);\n      }\n      continue;\n    }\n    if (allowUnknown !== true) {\n      throw new AxiosError('Unknown option ' + opt, AxiosError.ERR_BAD_OPTION);\n    }\n  }\n}\n\nvar validator = {\n  assertOptions,\n  validators: validators$1\n};\n\nconst validators = validator.validators;\n\n/**\n * Create a new instance of Axios\n *\n * @param {Object} instanceConfig The default config for the instance\n *\n * @return {Axios} A new instance of Axios\n */\nclass Axios {\n  constructor(instanceConfig) {\n    this.defaults = instanceConfig;\n    this.interceptors = {\n      request: new InterceptorManager$1(),\n      response: new InterceptorManager$1()\n    };\n  }\n\n  /**\n   * Dispatch a request\n   *\n   * @param {String|Object} configOrUrl The config specific for this request (merged with this.defaults)\n   * @param {?Object} config\n   *\n   * @returns {Promise} The Promise to be fulfilled\n   */\n  request(configOrUrl, config) {\n    /*eslint no-param-reassign:0*/\n    // Allow for axios('example/url'[, config]) a la fetch API\n    if (typeof configOrUrl === 'string') {\n      config = config || {};\n      config.url = configOrUrl;\n    } else {\n      config = configOrUrl || {};\n    }\n\n    config = mergeConfig(this.defaults, config);\n\n    const {transitional, paramsSerializer, headers} = config;\n\n    if (transitional !== undefined) {\n      validator.assertOptions(transitional, {\n        silentJSONParsing: validators.transitional(validators.boolean),\n        forcedJSONParsing: validators.transitional(validators.boolean),\n        clarifyTimeoutError: validators.transitional(validators.boolean)\n      }, false);\n    }\n\n    if (paramsSerializer != null) {\n      if (utils.isFunction(paramsSerializer)) {\n        config.paramsSerializer = {\n          serialize: paramsSerializer\n        };\n      } else {\n        validator.assertOptions(paramsSerializer, {\n          encode: validators.function,\n          serialize: validators.function\n        }, true);\n      }\n    }\n\n    // Set config.method\n    config.method = (config.method || this.defaults.method || 'get').toLowerCase();\n\n    let contextHeaders;\n\n    // Flatten headers\n    contextHeaders = headers && utils.merge(\n      headers.common,\n      headers[config.method]\n    );\n\n    contextHeaders && utils.forEach(\n      ['delete', 'get', 'head', 'post', 'put', 'patch', 'common'],\n      (method) => {\n        delete headers[method];\n      }\n    );\n\n    config.headers = AxiosHeaders$1.concat(contextHeaders, headers);\n\n    // filter out skipped interceptors\n    const requestInterceptorChain = [];\n    let synchronousRequestInterceptors = true;\n    this.interceptors.request.forEach(function unshiftRequestInterceptors(interceptor) {\n      if (typeof interceptor.runWhen === 'function' && interceptor.runWhen(config) === false) {\n        return;\n      }\n\n      synchronousRequestInterceptors = synchronousRequestInterceptors && interceptor.synchronous;\n\n      requestInterceptorChain.unshift(interceptor.fulfilled, interceptor.rejected);\n    });\n\n    const responseInterceptorChain = [];\n    this.interceptors.response.forEach(function pushResponseInterceptors(interceptor) {\n      responseInterceptorChain.push(interceptor.fulfilled, interceptor.rejected);\n    });\n\n    let promise;\n    let i = 0;\n    let len;\n\n    if (!synchronousRequestInterceptors) {\n      const chain = [dispatchRequest.bind(this), undefined];\n      chain.unshift.apply(chain, requestInterceptorChain);\n      chain.push.apply(chain, responseInterceptorChain);\n      len = chain.length;\n\n      promise = Promise.resolve(config);\n\n      while (i < len) {\n        promise = promise.then(chain[i++], chain[i++]);\n      }\n\n      return promise;\n    }\n\n    len = requestInterceptorChain.length;\n\n    let newConfig = config;\n\n    i = 0;\n\n    while (i < len) {\n      const onFulfilled = requestInterceptorChain[i++];\n      const onRejected = requestInterceptorChain[i++];\n      try {\n        newConfig = onFulfilled(newConfig);\n      } catch (error) {\n        onRejected.call(this, error);\n        break;\n      }\n    }\n\n    try {\n      promise = dispatchRequest.call(this, newConfig);\n    } catch (error) {\n      return Promise.reject(error);\n    }\n\n    i = 0;\n    len = responseInterceptorChain.length;\n\n    while (i < len) {\n      promise = promise.then(responseInterceptorChain[i++], responseInterceptorChain[i++]);\n    }\n\n    return promise;\n  }\n\n  getUri(config) {\n    config = mergeConfig(this.defaults, config);\n    const fullPath = buildFullPath(config.baseURL, config.url);\n    return buildURL(fullPath, config.params, config.paramsSerializer);\n  }\n}\n\n// Provide aliases for supported request methods\nutils.forEach(['delete', 'get', 'head', 'options'], function forEachMethodNoData(method) {\n  /*eslint func-names:0*/\n  Axios.prototype[method] = function(url, config) {\n    return this.request(mergeConfig(config || {}, {\n      method,\n      url,\n      data: (config || {}).data\n    }));\n  };\n});\n\nutils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {\n  /*eslint func-names:0*/\n\n  function generateHTTPMethod(isForm) {\n    return function httpMethod(url, data, config) {\n      return this.request(mergeConfig(config || {}, {\n        method,\n        headers: isForm ? {\n          'Content-Type': 'multipart/form-data'\n        } : {},\n        url,\n        data\n      }));\n    };\n  }\n\n  Axios.prototype[method] = generateHTTPMethod();\n\n  Axios.prototype[method + 'Form'] = generateHTTPMethod(true);\n});\n\nvar Axios$1 = Axios;\n\n/**\n * A `CancelToken` is an object that can be used to request cancellation of an operation.\n *\n * @param {Function} executor The executor function.\n *\n * @returns {CancelToken}\n */\nclass CancelToken {\n  constructor(executor) {\n    if (typeof executor !== 'function') {\n      throw new TypeError('executor must be a function.');\n    }\n\n    let resolvePromise;\n\n    this.promise = new Promise(function promiseExecutor(resolve) {\n      resolvePromise = resolve;\n    });\n\n    const token = this;\n\n    // eslint-disable-next-line func-names\n    this.promise.then(cancel => {\n      if (!token._listeners) return;\n\n      let i = token._listeners.length;\n\n      while (i-- > 0) {\n        token._listeners[i](cancel);\n      }\n      token._listeners = null;\n    });\n\n    // eslint-disable-next-line func-names\n    this.promise.then = onfulfilled => {\n      let _resolve;\n      // eslint-disable-next-line func-names\n      const promise = new Promise(resolve => {\n        token.subscribe(resolve);\n        _resolve = resolve;\n      }).then(onfulfilled);\n\n      promise.cancel = function reject() {\n        token.unsubscribe(_resolve);\n      };\n\n      return promise;\n    };\n\n    executor(function cancel(message, config, request) {\n      if (token.reason) {\n        // Cancellation has already been requested\n        return;\n      }\n\n      token.reason = new CanceledError(message, config, request);\n      resolvePromise(token.reason);\n    });\n  }\n\n  /**\n   * Throws a `CanceledError` if cancellation has been requested.\n   */\n  throwIfRequested() {\n    if (this.reason) {\n      throw this.reason;\n    }\n  }\n\n  /**\n   * Subscribe to the cancel signal\n   */\n\n  subscribe(listener) {\n    if (this.reason) {\n      listener(this.reason);\n      return;\n    }\n\n    if (this._listeners) {\n      this._listeners.push(listener);\n    } else {\n      this._listeners = [listener];\n    }\n  }\n\n  /**\n   * Unsubscribe from the cancel signal\n   */\n\n  unsubscribe(listener) {\n    if (!this._listeners) {\n      return;\n    }\n    const index = this._listeners.indexOf(listener);\n    if (index !== -1) {\n      this._listeners.splice(index, 1);\n    }\n  }\n\n  /**\n   * Returns an object that contains a new `CancelToken` and a function that, when called,\n   * cancels the `CancelToken`.\n   */\n  static source() {\n    let cancel;\n    const token = new CancelToken(function executor(c) {\n      cancel = c;\n    });\n    return {\n      token,\n      cancel\n    };\n  }\n}\n\nvar CancelToken$1 = CancelToken;\n\n/**\n * Syntactic sugar for invoking a function and expanding an array for arguments.\n *\n * Common use case would be to use `Function.prototype.apply`.\n *\n *  ```js\n *  function f(x, y, z) {}\n *  var args = [1, 2, 3];\n *  f.apply(null, args);\n *  ```\n *\n * With `spread` this example can be re-written.\n *\n *  ```js\n *  spread(function(x, y, z) {})([1, 2, 3]);\n *  ```\n *\n * @param {Function} callback\n *\n * @returns {Function}\n */\nfunction spread(callback) {\n  return function wrap(arr) {\n    return callback.apply(null, arr);\n  };\n}\n\n/**\n * Determines whether the payload is an error thrown by Axios\n *\n * @param {*} payload The value to test\n *\n * @returns {boolean} True if the payload is an error thrown by Axios, otherwise false\n */\nfunction isAxiosError(payload) {\n  return utils.isObject(payload) && (payload.isAxiosError === true);\n}\n\nconst HttpStatusCode = {\n  Continue: 100,\n  SwitchingProtocols: 101,\n  Processing: 102,\n  EarlyHints: 103,\n  Ok: 200,\n  Created: 201,\n  Accepted: 202,\n  NonAuthoritativeInformation: 203,\n  NoContent: 204,\n  ResetContent: 205,\n  PartialContent: 206,\n  MultiStatus: 207,\n  AlreadyReported: 208,\n  ImUsed: 226,\n  MultipleChoices: 300,\n  MovedPermanently: 301,\n  Found: 302,\n  SeeOther: 303,\n  NotModified: 304,\n  UseProxy: 305,\n  Unused: 306,\n  TemporaryRedirect: 307,\n  PermanentRedirect: 308,\n  BadRequest: 400,\n  Unauthorized: 401,\n  PaymentRequired: 402,\n  Forbidden: 403,\n  NotFound: 404,\n  MethodNotAllowed: 405,\n  NotAcceptable: 406,\n  ProxyAuthenticationRequired: 407,\n  RequestTimeout: 408,\n  Conflict: 409,\n  Gone: 410,\n  LengthRequired: 411,\n  PreconditionFailed: 412,\n  PayloadTooLarge: 413,\n  UriTooLong: 414,\n  UnsupportedMediaType: 415,\n  RangeNotSatisfiable: 416,\n  ExpectationFailed: 417,\n  ImATeapot: 418,\n  MisdirectedRequest: 421,\n  UnprocessableEntity: 422,\n  Locked: 423,\n  FailedDependency: 424,\n  TooEarly: 425,\n  UpgradeRequired: 426,\n  PreconditionRequired: 428,\n  TooManyRequests: 429,\n  RequestHeaderFieldsTooLarge: 431,\n  UnavailableForLegalReasons: 451,\n  InternalServerError: 500,\n  NotImplemented: 501,\n  BadGateway: 502,\n  ServiceUnavailable: 503,\n  GatewayTimeout: 504,\n  HttpVersionNotSupported: 505,\n  VariantAlsoNegotiates: 506,\n  InsufficientStorage: 507,\n  LoopDetected: 508,\n  NotExtended: 510,\n  NetworkAuthenticationRequired: 511,\n};\n\nObject.entries(HttpStatusCode).forEach(([key, value]) => {\n  HttpStatusCode[value] = key;\n});\n\nvar HttpStatusCode$1 = HttpStatusCode;\n\n/**\n * Create an instance of Axios\n *\n * @param {Object} defaultConfig The default config for the instance\n *\n * @returns {Axios} A new instance of Axios\n */\nfunction createInstance(defaultConfig) {\n  const context = new Axios$1(defaultConfig);\n  const instance = bind(Axios$1.prototype.request, context);\n\n  // Copy axios.prototype to instance\n  utils.extend(instance, Axios$1.prototype, context, {allOwnKeys: true});\n\n  // Copy context to instance\n  utils.extend(instance, context, null, {allOwnKeys: true});\n\n  // Factory for creating new instances\n  instance.create = function create(instanceConfig) {\n    return createInstance(mergeConfig(defaultConfig, instanceConfig));\n  };\n\n  return instance;\n}\n\n// Create the default instance to be exported\nconst axios = createInstance(defaults$1);\n\n// Expose Axios class to allow class inheritance\naxios.Axios = Axios$1;\n\n// Expose Cancel & CancelToken\naxios.CanceledError = CanceledError;\naxios.CancelToken = CancelToken$1;\naxios.isCancel = isCancel;\naxios.VERSION = VERSION;\naxios.toFormData = toFormData;\n\n// Expose AxiosError class\naxios.AxiosError = AxiosError;\n\n// alias for CanceledError for backward compatibility\naxios.Cancel = axios.CanceledError;\n\n// Expose all/spread\naxios.all = function all(promises) {\n  return Promise.all(promises);\n};\n\naxios.spread = spread;\n\n// Expose isAxiosError\naxios.isAxiosError = isAxiosError;\n\n// Expose mergeConfig\naxios.mergeConfig = mergeConfig;\n\naxios.AxiosHeaders = AxiosHeaders$1;\n\naxios.formToJSON = thing => formDataToJSON(utils.isHTMLForm(thing) ? new FormData(thing) : thing);\n\naxios.HttpStatusCode = HttpStatusCode$1;\n\naxios.default = axios;\n\nmodule.exports = axios;\n//# sourceMappingURL=axios.cjs.map\n"],"names":["Object","defineProperty","exports","value","getContrastColor","Color_1","BLACK","Color","makeRGB","WHITE","color","gamma","Math","pow","r","g","b","this","h","s","l","a","prototype","cssRGB","round","cssRGBA","red","green","blue","set","setRed","setBlue","Converter","RGBToHSL","setAlpha","setGreen","setHue","HSLToRGB","setSaturation","setLuminance","cssHSL","cssHSLA","hue","saturation","lightness","cssHEX","toString","alpha","saturate","v","indexOf","NaN","parseInt","Error","desaturate","lighten","darken","fadein","console","log","fadeout","spin","args","_i","arguments","length","sanitized","c","Sanitizer","RGB","makeHSL","HSL","makeHEX","startsWith","substr","Validator","checkHEX","parse","str","trim","toLowerCase","substring","parts","match","Number","clone","col","interpolate","t","o","i","parseFloat","charCodeAt","max","min","d","q","p","hue2rgb","FileDrop","element","_this","handleDropEvent","event","preventDefault","stopPropagation","style","opacity","dataTransfer","files","file_1","type","fileDroppedCallbackJSON","reader","FileReader","onload","readEvent","target","jsonObject","JSON","result","warn","readAsText","fileDroppedCallbackText","fileDroppedCallbackBinary","Blob","readAsBinaryString","fileDroppedCallbackSVG","doc","DOMParser","parseFromString","handleDragOverEvent","handleDragLeaveEvent","addEventListener","bind","onFileJSONDropped","callback","onFileTextDropped","onFileSVGDropped","destroy","removeEventListener","UIDGenerator","next","current","VertexAttr","constructor","key","draggable","selectable","isSelected","visible","model","VertexListeners","vertex","click","drag","dragStart","dragEnd","addClickListener","listener","_addListener","removeClickListener","_removeListener","addDragListener","removeDragListener","addDragStartListener","removeDragStartListener","addDragEndListener","removeDragEndListener","fireClickEvent","e","_fireEvent","fireDragEvent","fireDragStartEvent","fireDragEndEvent","removeAllListeners","_self","listeners","ve","params","newListener","push","oldListener","splice","Vertex","x","y","className","uid","tuple","attr","setX","setY","invX","invY","add","addXY","amountX","amountY","addX","addY","sub","subXY","subX","subY","equals","eqX","abs","EPSILON","eqY","distance","vert","sqrt","angle","origin","PI","atan2","difference","scale","factor","center","scaleXY","lerp","diff","lerpAbs","u","dist","step","factors","rotate","len","ZERO","cos","sin","multiplyScalar","scalar","inv","isDestroyed","randomVertex","viewPort","random","utils","buildArrowHead","zA","zB","headlen","scaleX","scaleY","vertices","arrayToJSON","precision","stringify","map","undefined","toFixed","Polygon","isOpen","addVertex","getVertexAt","index","move","amount","containsVert","inside","j","xi","yi","xj","yj","area","signedArea","isClockwise","perimeter","getEvenDistributionPolygon","pointCount","polygonPoint","stepSize","n","polygonIndex","nextPolygonPoint","segmentLength","loopMax","curSegmentU","newPoint","getBounds","Bounds","computeFromVertices","toQuadraticBezierData","qbezier","cc0","cc1","edgeCenter","limit","toQuadraticBezierSVGString","qdata","buffer","join","toCubicBezierData","threshold","cbezier","aCenter","bCenter","a2","b0","toCubicBezierSVGString","toCubicBezierPath","pathdata","BezierPath","fromArray","total","sum","width","height","toPolygon","getCenter","xMin","xMax","yMin","yMax","fromDimension","VertTuple","factory","setLength","normalize","moveTo","newA","line","v0","v1","vertAt","denominator","colinear","getClosestT","l2","vtutils","dist2","hasPoint","point","insideBoundsOnly","getClosestPoint","pointDistance","w","Vector","vertA","vertB","super","perp","inverse","tmp","intersection","numerator1","numerator2","getOrthogonal","linePoint","startPoint","CubicBezierCurve","endPoint","startControlPoint","endControlPoint","START_POINT","START_CONTROL_POINT","END_CONTROL_POINT","END_POINT","curveIntervals","segmentCache","segmentLengths","updateArcLengths","moveCurvePoint","pointID","moveAmount","moveControlPoint","getStartPoint","getStartControlPoint","getEndControlPoint","getEndPoint","translate","reverse","getLength","arcLength","pointA","pointB","curveStep","newLength","tmpLength","getPointAt","tPrev","tNext","iteration","locateIntervalByDistance","tStart","tEnd","stepCount","minIndex","minDist","tDiff","POSITIVE_INFINITY","NEGATIVE_INFINITY","getPointByID","id","getPoint","getTangentAt","t2","nt2","tX","tY","getSubCurveAt","startVec","endVec","convertU2T","getTangent","getPerpendicular","getPerpendicularAt","tangentVector","getStartTangent","getEndTangent","curve","isInstance","obj","toJSON","prettyFormat","fromJSON","jsonString","fromObject","arr","Array","isArray","pathPoints","totalArcLength","adjustCircular","bezierCurves","addCurve","adjustSuccessorControlPoint","locateCurveByStartPoint","locateCurveByEndPoint","locateCurveByStartControlPoint","locateCurveByEndControlPoint","getCurveCount","getCurveAt","curveIndex","anchor","scaleFactor","scaleFactors","curveT","uMin","uTemp","relativeU","uResult","_locateUIndex","bCurve","uPart","path","uBefore","getSubPathAt","startT","endT","startU","endU","uStartResult","uEndResult","firstT","lastT","firstCurve","curves","adjustPredecessorControlPoint","obtainHandleLength","mainCurve","neighbourCurve","adjustNeighbourControlPoint","_mainCurve","mainPoint","mainControlPoint","neighbourPoint","neighbourControlPoint","obtainHandleLengths","_updateArcLengths","mainHandleBounds","neighbourHandleBounds","mainHandleLength","neighbourHandleLength","getEvenDistributionVertices","bPath","lastCurve","toReducedListRepresentation","digits","fromReducedListRepresentation","listJSON","pointArray","fromReducedList","bezierPath","Line","isNaN","Circle","radius","containsPoint","containsCircle","circle","lineDistance","circleUtils","tangentAt","circleIntersection","p0","p1","p2","x3","y3","x4","y4","lineIntersection","interA","interB","transA","transB","det","distSquared","belowSqrt","sign","closestPoint","CircleSector","startAngle","endAngle","circleSectorUtils","polarToCartesian","centerX","centerY","describeSVGArc","options","moveToStart","end","start","firstHalf","secondHalf","concat","largeArcFlag","sweepFlag","pathData","RAD_TO_DEG","drawutilssvg","svgNode","offset","canvasSize","fillShapes","drawConfig","isSecondary","gNode","bufferGNode","nodeDefs","bufferNodeDefs","Boolean","drawlibConfiguration","cache","Map","setSize","bufferedNodeDefs","addStyleDefs","addDefsNode","createSVGNode","appendChild","nodeStyle","keys","rules","k","drawSettings","lineWidth","innerHTML","addCustomStyleDefs","defs","forEach","findElement","nodeName","node","get","toUpperCase","delete","document","createElementNS","makeNode","curId","blendMode","_bindFillDraw","curClassName","setAttribute","parentNode","copyInstance","setConfiguration","configuration","setCurrentId","setCurrentClassName","beginDrawCycle","renderTime","clear","childNodes","child","getAttribute","removeAllChildNodes","endDrawCycle","replaceChild","tmpGNode","tmpDefsNode","_x","_y","arrow","image","position","size","setImageSize","naturalWidth","ratioX","ratioY","naturalHeight","src","texturedPoly","textureImage","textureSize","polygon","polygonPosition","rotation","rotatedScalingOrigin","clipPathNode","clipPathId","imageNode","pathNode","clipNode","cubicBezier","cubicBezierPath","handle","square","handleLine","dot","circleArc","arcData","ellipse","radiusX","radiusY","rect","grid","sizeX","sizeY","ceil","raster","diamondHandle","squareHandle","circleHandle","crosshair","cross","polyline","text","_a","_b","_c","lineHeight","fontSize","textAlign","transformOrigin","textNode","fontFamily","fontStyle","fontWeight","label","inplace","copyPathData","transformPathData","lastChild","removeChild","createSvg","data","copy","_stx","_sty","_sx","_sy","lastPoint","_slp","HEAD_XML","drawutils","context","ctx","globalCompositeOperation","save","beginPath","lineTo","strokeStyle","stroke","restore","_fillOrDraw","complete","globalAlpha","drawImage","basePolygonBounds","targetCenterDifference","targetTextureSize","targetTextureOffset","helpers","clipPoly","_texturedPoly","rotationCenter","rotationalOffset","tileCenter","closePath","fillStyle","fill","bezierCurveTo","quadraticBezier","controlPoint","quadraticCurveTo","arc","asSegment","setLineDash","relX","relY","font","fillText","strokeText","Path2D","clearRect","canvas","fillRect","clip","drawutilsgl","gl","_zindex","glutils","GLU","_vertShader","compileShader","vertCode","VERTEX_SHADER","_fragShader","fragCode","FRAGMENT_SHADER","_program","makeProgram","vertex_buffer","createBuffer","_x2rel","_y2rel","Float32Array","bindBuffer","ARRAY_BUFFER","bufferData","STATIC_DRAW","coord","getAttribLocation","vertexAttribPointer","FLOAT","enableVertexAttribArray","viewport","uRotationVector","getUniformLocation","uniform2fv","drawArrays","LINES","TRIANGLE_FAN","clearColor","enable","DEPTH_TEST","COLOR_BUFFER_BIT","DEPTH_BUFFER_BIT","verts","vbuffer","shaderCode","shaderType","shader","createShader","shaderSource","getShaderParameter","COMPILE_STATUS","getShaderInfoLog","deleteShader","vertShader","fragShader","program","createProgram","attachShader","linkProgram","useProgram","detachShader","Triangle","calcCircumcircle","getArea","getCentroid","scaleToCentroid","centroid","getCircumcircle","isAdjacent","tri","getThirdVertex","vert1","vert2","A","B","C","D","E","F","G","dx","dy","bounds","cx","cy","radius_squared","inCircumcircle","min3","max3","determinant","pointIsInTriangle","getIncircularTriangle","lineA","lineB","lineC","bisector1","geomutils","nsectAngle","bisector2","circleIntersA","circleIntersB","circleIntersC","getIncircle","getIncenter","p0x","p0y","p1x","p1y","p2x","p2y","px","py","pA","pB","pC","triangle","lineAB","lineAC","insideAngle","clockwise","wrapMax","wrapMinMax","Grid","baseLog","base","num","mapRasterScale","adjustFactor","gf","floor","KeyHandler","downListeners","pressListeners","upListeners","keyStates","globalThis","trackAllKeys","trackAll","installListeners","fireEvent","hasListener","lis","keyCode","fireDownEvent","handler","firePressEvent","fireUpEvent","key2code","KEY_CODES","_keyDownListener","_keyPressListener","_keyUpListener","releaseListeners","down","press","up","isDown","XMouseEvent","MouseEvent","XWheelEvent","WheelEvent","MouseHandler","name","mouseDownPos","mouseDragPos","mouseButton","installed","handlers","mousemove","mkParams","relPos","mouseup","button","mousedown","wheel","offsetX","offsetY","eventName","rel","xEvent","isTouchEvent","pos","leftButton","middleButton","rightButton","draggedFrom","wasDragged","dragAmount","listenFor","unlistenFor","throwAlreadyInstalled","PBImage","upperLeft","lowerRight","PBText","getLen","getRotateAngle","v2","mr","acos","getAngle","HandlerAdmin","el","del","dispatch","_args","apply","wrapFunc","handlerAdmin","AlloyFinger","option","querySelector","cancel","preV","pinchStartLen","zoom","isDoubleTap","noop","touchStart","multipointStart","multipointEnd","pinch","swipe","tap","doubleTap","longTap","singleTap","pressMove","twoFingerPressMove","touchMove","touchEnd","touchCancel","_cancelAllHandler","cancelAll","delta","last","now","tapTimeout","singleTapTimeout","longTapTimeout","swipeTimeout","x1","x2","y1","y2","preTapPosition","evt","touches","Date","pageX","pageY","clearTimeout","_cancelLongTap","_cancelSingleTap","_preventTap","setTimeout","afEvent","currentX","currentY","sCurrentX","sCurrentY","sx2","deltaX","deltaY","sy2","movedX","movedY","changedTouches","self","direction","_swipeDirection","on","off","VEllipse","axis","radiusH","signedRadiusH","radiusV","signedRadiusV","normalAt","foci","getFoci","angleA","centerAngle","endPointA","endPointB","normal","rh","rv","sdiff","f","getEquidistantVertices","angles","equidistantVertAngles","toCubicBezier","quarterSegmentCount","segmentCount","curAngle","nextAngle","startTangent","endTangent","startDiff","endDiff","phiToTheta","phi","tanPhi","tan","tanPhi2","atan","theta","VEllipseSector","ellipseSectorUtils","normalizeAngle","r2d","fullEllipsePointCount","ellipseAngles","filter","startIndex","findClosestToStartAngle","ea","endpointToCenterParameters","rx","ry","fa","fs","sinphi","cosphi","prx","pry","L","M","_cx","_cy","PlotBoilerplate","config","bezierAutoAdjust","fetch","fullSize","val","fitToParent","bool","rasterGrid","drawRaster","rasterScaleX","rasterScaleY","rasterAdjustFactor","drawOrigin","autoAdjustOffset","offsetAdjustXPercent","offsetAdjustYPercent","backgroundColor","redrawOnResize","defaultCanvasWidth","DEFAULT_CANVAS_WIDTH","defaultCanvasHeight","DEFAULT_CANVAS_HEIGHT","canvasWidthFactor","canvasHeightFactor","cssScaleX","cssScaleY","cssUniformScale","saveFile","hooks","setToRetina","_setToRetina","autoDetectRetina","enableSVGExport","preClear","func","preDraw","postDraw","enableMouse","enableTouch","enableKeys","enableMouseWheel","enableZoom","enablePan","enableGL","drawVertices","drawBezierHandleLines","drawBezierHandlePoints","drawHandleLines","drawHandlePoints","drawGrid","bezier","pathVertex","controlVertex","ellipseSector","circleSector","selectedVertex","vector","canvasElement","tagName","eventCatcher","getContext","draw","parentElement","createElement","left","top","cursor","body","title","selectPolygon","draggedElements","drawables","_saveFile","resizeCanvas","installInputListeners","updateCSSscale","redraw","focus","pb","tosvgDraw","tosvgFill","drawAll","svgCode","XMLSerializer","serializeToString","blob","_saveAs","pixelRatio","devicePixelRatio","fitToView","canvasCenter","canvasRatio","ratio","setOffset","newUniformZoom","setZoom","setConsole","con","_d","setCSSscale","drawable","enableBezierPathAutoAdjust","remove","removeWithVertices","removeVertex","removeAll","keepVertices","getVertexNear","pixelPosition","pixelTolerance","locatePointNear","transformMousePosition","typeName","vindex","gScale","gSize","cs","_handleColor","drawDrawables","drawDrawable","df","error","drawSelectPolygon","clearSelection","getFProp","elem","propName","getComputedStyle","getPropertyValue","getAvailableContainerSpace","container","display","padding","border","pl","pr","pt","bl","br","bt","bb","clientWidth","clientHeight","_e","_f","_setSize","HTMLCanvasElement","SVGElement","adjustOffset","innerWidth","documentElement","innerHeight","space","selectVerticesInPolygon","tolerance","Draggable","VERTEX","setVIndex","handleClick","DEFAULT_CLICK_TOLERANCE","keyHandler","paths","pindex","cindex","pid","revertMousePosition","getDraggedElementCount","mouseDownHandler","draggablePoint","mouseDragHandler","oldDragAmount","mouseUpHandler","mouseWheelHandler","zoomStep","we","newOffset","zoomFactorX","zoomFactorY","interactionPos","oldPos","newPos","newOffsetX","newOffsetY","getBoundingClientRect","touchMovePos","touchDownPos","draggedElement","multiTouchStartScale","clearTouch","afProps","clientX","clientY","DEFAULT_TOUCH_TOLERANCE","draggingVertex","fakeEvent","trans","touchItem0","item","touchItem1","fingerA","fingerB","window","createGUI","props","isVertex","safeMergeByKeys","extension","hasOwnProperty","typ","removeProperty","transform","fallback","fn","thisArg","getPrototypeOf","kindOf","create","thing","call","slice","kindOfTest","typeOfTest","isUndefined","isArrayBuffer","isString","isFunction","isNumber","isObject","isPlainObject","Symbol","toStringTag","iterator","isDate","isFile","isBlob","isFileList","isURLSearchParams","allOwnKeys","getOwnPropertyNames","findKey","_key","_global","isContextDefined","isTypedArray","TypedArray","Uint8Array","isHTMLForm","prop","isRegExp","reduceDescriptors","reducer","descriptors","getOwnPropertyDescriptors","reducedDescriptors","descriptor","defineProperties","ALPHA","DIGIT","ALPHABET","ALPHA_DIGIT","isAsyncFn","isBuffer","isFormData","kind","FormData","append","isArrayBufferView","ArrayBuffer","isView","isBoolean","isStream","pipe","merge","caseless","assignValue","targetKey","extend","replace","stripBOM","content","inherits","superConstructor","assign","toFlatObject","sourceObj","destObj","propFilter","merged","endsWith","searchString","String","lastIndex","toArray","forEachEntry","done","pair","matchAll","regExp","matches","exec","hasOwnProp","freezeMethods","enumerable","writable","toObjectSet","arrayOrString","delimiter","define","split","toCamelCase","m","toFiniteNumber","defaultValue","isFinite","global","generateString","alphabet","isSpecCompliantForm","toJSONObject","stack","visit","source","reducedValue","isThenable","then","catch","AxiosError","message","code","request","response","captureStackTrace","description","number","fileName","lineNumber","columnNumber","status","prototype$1","from","customProps","axiosError","cause","isVisitable","removeBrackets","renderKey","dots","token","predicates","test","toFormData","formData","TypeError","metaTokens","indexes","visitor","defaultVisitor","useBlob","convertValue","toISOString","Buffer","some","isFlatArray","exposedHelpers","build","pop","encode$1","charMap","encodeURIComponent","AxiosURLSearchParams","_pairs","encode","buildURL","url","_encode","serializeFn","serialize","serializedParams","hashmarkIndex","encoder","InterceptorManager$1","use","fulfilled","rejected","synchronous","runWhen","eject","transitionalDefaults","silentJSONParsing","forcedJSONParsing","clarifyTimeoutError","platform","isBrowser","classes","URLSearchParams","isStandardBrowserEnv","product","navigator","isStandardBrowserWebWorkerEnv","WorkerGlobalScope","importScripts","protocols","formDataToJSON","buildPath","isNumericKey","isLast","arrayToObject","entries","parsePropPath","DEFAULT_CONTENT_TYPE","defaults","transitional","adapter","transformRequest","headers","contentType","getContentType","hasJSONContentType","isObjectPayload","setContentType","isNode","toURLEncodedForm","formSerializer","_FormData","env","rawValue","parser","stringifySafely","transformResponse","JSONRequested","responseType","strictJSONParsing","ERR_BAD_RESPONSE","timeout","xsrfCookieName","xsrfHeaderName","maxContentLength","maxBodyLength","validateStatus","common","method","defaults$1","ignoreDuplicateOf","$internals","normalizeHeader","header","normalizeValue","matchHeaderValue","isHeaderNameFilter","AxiosHeaders","valueOrRewrite","rewrite","setHeader","_value","_header","_rewrite","lHeader","setHeaders","rawHeaders","parsed","parseHeaders","tokens","tokensRE","parseTokens","has","matcher","deleted","deleteHeader","format","normalized","char","formatHeader","targets","asStrings","first","computed","accessor","accessors","defineAccessor","accessorName","methodName","arg1","arg2","arg3","configurable","buildAccessors","AxiosHeaders$1","transformData","fns","isCancel","__CANCEL__","CanceledError","ERR_CANCELED","cookies","write","expires","domain","secure","cookie","toGMTString","read","RegExp","decodeURIComponent","buildFullPath","baseURL","requestedURL","relativeURL","combineURLs","isURLSameOrigin","msie","userAgent","urlParsingNode","originURL","resolveURL","href","protocol","host","search","hash","hostname","port","pathname","charAt","location","requestURL","progressEventReducer","isDownloadStream","bytesNotified","_speedometer","samplesCount","bytes","timestamps","firstSampleTS","head","tail","chunkLength","startedAt","bytesCount","passed","speedometer","loaded","lengthComputable","progressBytes","rate","progress","estimated","knownAdapters","http","xhr","XMLHttpRequest","Promise","resolve","reject","requestData","requestHeaders","onCanceled","cancelToken","unsubscribe","signal","auth","username","password","unescape","btoa","fullPath","onloadend","responseHeaders","getAllResponseHeaders","ERR_BAD_REQUEST","settle","err","responseText","statusText","open","paramsSerializer","onreadystatechange","readyState","responseURL","onabort","ECONNABORTED","onerror","ERR_NETWORK","ontimeout","timeoutErrorMessage","ETIMEDOUT","xsrfValue","withCredentials","setRequestHeader","onDownloadProgress","onUploadProgress","upload","abort","subscribe","aborted","parseProtocol","send","adapters","nameOrAdapter","throwIfCancellationRequested","throwIfRequested","dispatchRequest","reason","headersToObject","mergeConfig","config1","config2","getMergedValue","mergeDeepProperties","valueFromConfig2","defaultToConfig2","mergeDirectKeys","mergeMap","timeoutMessage","decompress","beforeRedirect","transport","httpAgent","httpsAgent","socketPath","responseEncoding","configValue","VERSION","validators$1","deprecatedWarnings","validator","version","formatMessage","opt","desc","opts","ERR_DEPRECATED","assertOptions","schema","allowUnknown","ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","validators","Axios","instanceConfig","interceptors","configOrUrl","contextHeaders","boolean","function","requestInterceptorChain","synchronousRequestInterceptors","interceptor","unshift","responseInterceptorChain","promise","chain","newConfig","onFulfilled","onRejected","getUri","generateHTTPMethod","isForm","Axios$1","CancelToken","executor","resolvePromise","_listeners","onfulfilled","_resolve","CancelToken$1","HttpStatusCode","Continue","SwitchingProtocols","Processing","EarlyHints","Ok","Created","Accepted","NonAuthoritativeInformation","NoContent","ResetContent","PartialContent","MultiStatus","AlreadyReported","ImUsed","MultipleChoices","MovedPermanently","Found","SeeOther","NotModified","UseProxy","Unused","TemporaryRedirect","PermanentRedirect","BadRequest","Unauthorized","PaymentRequired","Forbidden","NotFound","MethodNotAllowed","NotAcceptable","ProxyAuthenticationRequired","RequestTimeout","Conflict","Gone","LengthRequired","PreconditionFailed","PayloadTooLarge","UriTooLong","UnsupportedMediaType","RangeNotSatisfiable","ExpectationFailed","ImATeapot","MisdirectedRequest","UnprocessableEntity","Locked","FailedDependency","TooEarly","UpgradeRequired","PreconditionRequired","TooManyRequests","RequestHeaderFieldsTooLarge","UnavailableForLegalReasons","InternalServerError","NotImplemented","BadGateway","ServiceUnavailable","GatewayTimeout","HttpVersionNotSupported","VariantAlsoNegotiates","InsufficientStorage","LoopDetected","NotExtended","NetworkAuthenticationRequired","HttpStatusCode$1","axios","createInstance","defaultConfig","instance","Cancel","all","promises","spread","isAxiosError","payload","formToJSON","default","module"],"sourceRoot":""}