jmgraph 3.2.28 → 3.2.29
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/jmgraph.core.min.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).jmGraph={})}(this,function(t){"use strict";function e(e,t){var n,i=Object.keys(e);return Object.getOwnPropertySymbols&&(n=Object.getOwnPropertySymbols(e),t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),i.push.apply(i,n)),i}function s(i){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?e(Object(r),!0).forEach(function(t){var e,n;e=i,t=r[n=t],n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t}):Object.getOwnPropertyDescriptors?Object.defineProperties(i,Object.getOwnPropertyDescriptors(r)):e(Object(r)).forEach(function(t){Object.defineProperty(i,t,Object.getOwnPropertyDescriptor(r,t))})}return i}function d(t){return(d="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function h(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function i(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}function l(t,e,n){return e&&i(t.prototype,e),n&&i(t,n),t}function u(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&o(t,e)}function r(t){return(r=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function o(t,e){return(o=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function a(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(t){return!1}}function c(t,e,n){return(c=a()?Reflect.construct:function(t,e,n){var i=[null];i.push.apply(i,e);i=new(Function.bind.apply(t,i));return n&&o(i,n.prototype),i}).apply(null,arguments)}function n(t){var n="function"==typeof Map?new Map:void 0;return function(t){if(null===t||-1===Function.toString.call(t).indexOf("[native code]"))return t;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==n){if(n.has(t))return n.get(t);n.set(t,e)}function e(){return c(t,arguments,r(this).constructor)}return e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),o(e,t)}(t)}function f(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function p(t,e){return!e||"object"!=typeof e&&"function"!=typeof e?f(t):e}function v(n){var i=a();return function(){var t,e=r(n);return p(this,i?(t=r(this).constructor,Reflect.construct(e,arguments,t)):e.apply(this,arguments))}}function y(t,e,n){return(y="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(t,e,n){t=function(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=r(t)););return t}(t,e);if(t){e=Object.getOwnPropertyDescriptor(t,e);return e.get?e.get.call(n):e.value}})(t,e,n||t)}function g(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var i,r,o=[],s=!0,a=!1;try{for(n=n.call(t);!(s=(i=n.next()).done)&&(o.push(i.value),!e||o.length!==e);s=!0);}catch(t){a=!0,r=t}finally{try{s||null==n.return||n.return()}finally{if(a)throw r}}return o}}(t,e)||m(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function x(t){return function(t){if(Array.isArray(t))return b(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||m(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function m(t,e){if(t){if("string"==typeof t)return b(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return"Map"===(n="Object"===n&&t.constructor?t.constructor.name:n)||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?b(t,e):void 0}}function b(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,i=new Array(e);n<e;n++)i[n]=t[n];return i}function _(t,e){var n="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!n){if(Array.isArray(t)||(n=m(t))||e&&t&&"number"==typeof t.length){n&&(t=n);var i=0,e=function(){};return{s:e,n:function(){return i>=t.length?{done:!0}:{done:!1,value:t[i++]}},e:function(t){throw t},f:e}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var r,o=!0,s=!1;return{s:function(){n=n.call(t)},n:function(){var t=n.next();return o=t.done,t},e:function(t){s=!0,r=t},f:function(){try{o||null==n.return||n.return()}finally{if(s)throw r}}}}var w=function(){u(a,n(Array));var s=v(a);function a(){var t;h(this,a);for(var e=[],n=arguments.length,i=new Array(n),r=0;r<n;r++)i[r]=arguments[r];if(i&&i.length&&Array.isArray(i[0])){for(var o=0;o<i[0].length;o++)e.push(i[0][o]);t=s.call.apply(s,[this].concat(e))}else t=s.call(this);return t.option={},t.type="jmList",p(t)}return l(a,[{key:"add",value:function(t){if(t&&Array.isArray(t)){for(var e=0;e<t.length;e++)this.includes(t[e])||this.push(t[e]);return t}return"object"==d(t)&&this.includes(t)||this.push(t),t}},{key:"remove",value:function(t){for(var e=this.length-1;0<=e;e--)this[e]==t&&this.removeAt(e)}},{key:"removeAt",value:function(t){var e;this.length>t&&(e=this[t],this.splice(t,1),this.option.removeHandler&&this.option.removeHandler.call(this,e,t))}},{key:"contain",value:function(t){return this.includes(t)}},{key:"get",value:function(t){return"function"==typeof t?this.find(t):this[t]}},{key:"each",value:function(t,e){if(t&&"function"==typeof t)if(e){for(var n=this.length-1;0<=n;n--)if(!1===t.call(this,n,this[n]))break}else for(var i=this.length,r=0;r<i;r++)if(!1===t.call(this,r,this[r]))break}},{key:"count",value:function(t){if(t&&"function"==typeof t){for(var e=0,n=this.length,i=0;i<n;i++)t(this[i])&&e++;return e}return this.length}},{key:"clear",value:function(){this.splice(0,this.length)}}]),a}(),k={aliceblue:"#f0f8ff",antiquewhite:"#faebd7",aqua:"#00ffff",aquamarine:"#7fffd4",azure:"#f0ffff",beige:"#f5f5dc",bisque:"#ffe4c4",black:"#000000",blanchedalmond:"#ffebcd",blue:"#0000ff",blueviolet:"#8a2be2",brown:"#a52a2a",burlywood:"#deb887",cadetblue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",cornflowerblue:"#6495ed",cornsilk:"#fff8dc",crimson:"#dc143c",cyan:"#00ffff",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b",darkgray:"#a9a9a9",darkgreen:"#006400",darkkhaki:"#bdb76b",darkmagenta:"#8b008b",darkolivegreen:"#556b2f",darkorange:"#ff8c00",darkorchid:"#9932cc",darkred:"#8b0000",darksalmon:"#e9967a",darkseagreen:"#8fbc8f",darkslateblue:"#483d8b",darkslategray:"#2f4f4f",darkslategrey:"#2f4f4f",darkturquoise:"#00ced1",darkviolet:"#9400d3",deeppink:"#ff1493",deepskyblue:"#00bfff",dimgray:"#696969",dimgrey:"#696969",dodgerblue:"#1e90ff",firebrick:"#b22222",floralwhite:"#fffaf0",forestgreen:"#228b22",fuchsia:"#ff00ff",gainsboro:"#dcdcdc",ghostwhite:"#f8f8ff",gold:"#ffd700",goldenrod:"#daa520",gray:"#808080",green:"#008000",greenyellow:"#adff2f",grey:"#808080",honeydew:"#f0fff0",hotpink:"#ff69b4",indianred:"#cd5c5c",indigo:"#4b0082",ivory:"#fffff0",khaki:"#f0e68c",lavender:"#e6e6fa",lavenderblush:"#fff0f5",lawngreen:"#7cfc00",lemonchiffon:"#fffacd",lightblue:"#add8e6",lightcoral:"#f08080",lightcyan:"#e0ffff",lightgoldenrodyellow:"#fafad2",lightgrey:"#d3d3d3",lightgreen:"#90ee90",lightpink:"#ffb6c1",lightsalmon:"#ffa07a",lightseagreen:"#20b2aa",lightskyblue:"#87cefa",lightslategray:"#778899",lightslategrey:"#778899",lightsteelblue:"#b0c4de",lightyellow:"#ffffe0",lime:"#00ff00",limegreen:"#32cd32",linen:"#faf0e6",magenta:"#ff00ff",maroon:"#800000",mediumaquamarine:"#66cdaa",mediumblue:"#0000cd",mediumorchid:"#ba55d3",mediumpurple:"#9370d8",mediumseagreen:"#3cb371",mediumslateblue:"#7b68ee",mediumspringgreen:"#00fa9a",mediumturquoise:"#48d1cc",mediumvioletred:"#c71585",midnightblue:"#191970",mintcream:"#f5fffa",mistyrose:"#ffe4e1",moccasin:"#ffe4b5",navajowhite:"#ffdead",navy:"#000080",oldlace:"#fdf5e6",olive:"#808000",olivedrab:"#6b8e23",orange:"#ffa500",orangered:"#ff4500",orchid:"#da70d6",palegoldenrod:"#eee8aa",palegreen:"#98fb98",paleturquoise:"#afeeee",palevioletred:"#d87093",papayawhip:"#ffefd5",peachpuff:"#ffdab9",peru:"#cd853f",pink:"#ffc0cb",plum:"#dda0dd",powderblue:"#b0e0e6",purple:"#800080",red:"#ff0000",rebeccapurple:"#663399",rosybrown:"#bc8f8f",royalblue:"#4169e1",saddlebrown:"#8b4513",salmon:"#fa8072",sandybrown:"#f4a460",seagreen:"#2e8b57",seashell:"#fff5ee",sienna:"#a0522d",silver:"#c0c0c0",skyblue:"#87ceeb",slateblue:"#6a5acd",slategray:"#708090",slategrey:"#708090",snow:"#fffafa",springgreen:"#00ff7f",steelblue:"#4682b4",tan:"#d2b48c",teal:"#008080",thistle:"#d8bfd8",tomato:"#ff6347",turquoise:"#40e0d0",violet:"#ee82ee",wheat:"#f5deb3",white:"#ffffff",whitesmoke:"#f5f5f5",yellow:"#ffff00",yellowgreen:"#9acd32",transparent:"rgba(0,0,0,0)",activeborder:"#bfcaca",activecaption:"#000080",appworkspace:"#ababab",background:"#636363",buttonface:"#c0c0c0",buttonhighlight:"#dedede",buttonshadow:"#808080",buttontext:"#000000",captiontext:"#000000",graytext:"#808080",highlight:"#b3d4fc",highlighttext:"#000000",inactiveborder:"#d4d0c8",inactivecaption:"#bfbbb0",inactivecaptiontext:"#545454",infobackground:"#fbfcc5",infotext:"#000000",menu:"#c0c0c0",menutext:"#000000",scrollbar:"#c0c0c0",threeddarkshadow:"#696969",threedface:"#c0c0c0",threedhighlight:"#dfdfdf",threedlightshadow:"#dcdcdc",threedshadow:"#808080",window:"#ffffff",windowframe:"#646464",windowtext:"#000000"},A=function(){function t(){h(this,t)}return l(t,null,[{key:"clone",value:function(t,e){var n=2<arguments.length&&void 0!==arguments[2]&&arguments[2],i=3<arguments.length&&void 0!==arguments[3]?arguments[3]:null,r=4<arguments.length&&void 0!==arguments[4]?arguments[4]:0,o=5<arguments.length&&void 0!==arguments[5]?arguments[5]:null;if("function"==typeof i){var s=i(t,n,r);if(s)return s}if(o=o||new WeakMap,"boolean"==typeof e&&(n=e,e=void 0),!t||"object"!==d(t))return void 0!==e?e:t;if(o.has(t))return o.get(t);if(Array.isArray(t)){if(this.isType(t,w))return new w(t);if(n){var a=[];o.set(t,a);for(var h=0;h<t.length;h++)a.push(this.clone(t[h],void 0,n,i,r+1,o));return a}return t.slice(0)}if(t.tagName||t.getContext||t.emit)return t;o.set(t,e=e||{}),t.__proto__&&(e.__proto__=t.__proto__);var l,u=_(Object.keys(t).concat(Object.getOwnPropertySymbols(t)));try{for(u.s();!(l=u.n()).done;){var c,f=l.value;"constructor"!==f&&((c=t[f])&&(c.tagName||c.getContext||c.emit)?e[f]=c:"object"!==d(e[f])&&void 0!==e[f]||(e[f]=this.clone(c,e[f],n,i,r+1,o)))}}catch(t){u.e(t)}finally{u.f()}return e}},{key:"bindEvent",value:function(t,e,n,i){if(e&&e.indexOf&&-1!=e.indexOf(" "))for(var r=e.split(" "),o=0;o<r.length;o++)this.bindEvent(t,r[o],n,i);return t.attachEvent?t.attachEvent("on"+e,n,i):t.addEventListener&&t.addEventListener(e,n,i),{name:e,target:t,fun:n}}},{key:"removeEvent",value:function(t,e,n){return t.removeEventListener?t.removeEventListener(e,n,!1):t.detachEvent?(t.detachEvent("on"+e,n),!0):void(t["on"+e]=null)}},{key:"getElementPosition",value:function(t){var e={top:0,left:0};if(!t)return e;if(t.offsetParent)for(;t.offsetParent;)e.top+=t.offsetTop,e.left+=t.offsetLeft,t=t.offsetParent;else t.x?e.left+=t.x:t.y&&(e.top+=t.y);return e}},{key:"getEventPosition",value:function(t,e){var n=(t=t||event).isWXMiniApp,i=!1,r=t.changedTouches||t.targetTouches||t.touches,o=t.target||t.srcElement;r&&r.length&&((t=r[0]).target||(t.target=o),i=!0);var s=t.pageX||t.x;void 0===s&&(s=t.clientX+(document.documentElement.scrollLeft||document.body.scrollLeft));var a=t.pageY||t.y;void 0===a&&(a=t.clientY+(document.documentElement.scrollTop||document.body.scrollTop));var h=t.offsetX,l=t.offsetY;return void 0===h&&void 0===l&&(l=n?(h=t.x,t.y):(h=s-(o=this.getElementPosition(o)).left,a-o.top)),e&&(e.x&&(h/=e.x),e.y&&(l/=e.y)),{pageX:s,pageY:a,clientX:t.clientX,clientY:t.clientY,offsetX:h,offsetY:l,layerX:t.layerX,layerY:t.layerY,screenX:t.screenX,screenY:t.screenY,x:h,y:l,isTouch:i,touches:r,isWXMiniApp:n}}},{key:"isType",value:function(t,e){return!(!t||"object"!==d(t))&&t.constructor===e}},{key:"pointInPolygon",value:function(t,e,n){n=n||1,n/=2;var i=e.length;if(!e||0==i)return 0;if(1==i)return Math.abs(e[0].x-t.x)<=n&&Math.abs(e[0].y-t.y)<=n?1:0;if(2==i)return this.pointOnLine(t,e[0],e[1],n);for(var r=0;r<i;r++)if(Math.abs(e[r].x-t.x)<=n&&Math.abs(e[r].y-t.y)<=n)return 1;return this.rayCasting(t,e,n)}},{key:"pointOnLine",value:function(t,e,n,i){var r=Math.min(e.x,n.x),o=Math.max(e.x,n.x),s=Math.min(e.y,n.y),a=Math.max(e.y,n.y);if(r-t.x>i||t.x-o>i)return 0;if(s-t.y>i||t.y-a>i)return 0;if(e.x==n.x)return Math.abs(e.x-t.x)<=i&&(t.y-e.y)*(t.y-n.y)<=0?1:0;if(e.y==n.y)return Math.abs(e.y-t.y)<=i&&(t.x-e.x)*(t.x-n.x)<=0?1:0;if(Math.abs(e.x-t.x)<i&&Math.abs(e.y-t.y)<i)return 1;if(Math.abs(n.x-t.x)<i&&Math.abs(n.y-t.y)<i)return 1;if(t.y==e.y||t.y==n.y)return 0;n=(n.x-e.x)/(n.y-e.y)*(t.y-e.y),n=(t.y-e.y)/Math.sqrt(n*n+(t.y-e.y)*(t.y-e.y))*(t.x-e.x-n);return Math.abs(n)<=i?1:0}},{key:"rayCasting",value:function(t,e,n){for(var i=e.length,r=!1,o=t.y,s=t.x,a=0,h=i-1;a<i;h=a++){var l=e[a].y,u=e[h].y,c=e[a].x,f=e[h].x;o<l!=o<u&&s<(f-c)*(o-l)/(u-l)+c&&(r=!r)}return r?2:0}},{key:"checkOutSide",value:function(t,e,n){var i={left:0,right:0,top:0,bottom:0};return n.x<0?i.left=e.left+n.x-t.left:0<n.x&&(i.right=e.right+n.x-t.right),n.y<0?i.top=e.top+n.y-t.top:0<n.y&&(i.bottom=e.bottom+n.y-t.bottom),i}},{key:"rotatePoints",value:function(t,e,n){if(!n||!t)return t;var i=Math.cos(n),r=Math.sin(n);if(Array.isArray(t))for(var o,s,a=0;a<t.length;a++)t[a]&&(o=t[a].x-e.x,s=t[a].y-e.y,t[a].x=o*i-s*r+e.x,t[a].y=o*r+s*i+e.y);else{var h=t.x-e.x,n=t.y-e.y;t.x=h*i-n*r+e.x,t.y=h*r+n*i+e.y}return t}},{key:"trimStart",value:function(t,e){if(e=e||" ",t&&0<t.length){var n=t[0];if(n===e||0<=e.indexOf(n))return t=t.substring(1),this.trimStart(t,e)}return t}},{key:"trimEnd",value:function(t,e){if(e=e||" ",t&&0<t.length){var n=t[t.length-1];if(n===e||0<=e.indexOf(n))return t=t.substring(0,t.length-1),this.trimStart(t,e)}return t}},{key:"trim",value:function(t,e){return this.trimEnd(this.trimStart(t,e),e)}},{key:"checkPercent",value:function(t){if("string"==typeof t&&"%"==(t=this.trim(t))[t.length-1])return t}},{key:"percentToNumber",value:function(t){var e;return"string"!=typeof t||(e=this.checkPercent(t))&&(t=this.trim(e,"% "),t/=100),t}},{key:"hexToNumber",value:function(t){if("string"!=typeof t)return t;for(var e=0,n=(t=t.toLowerCase()).length,i=0;i<n;i++){var r="0123456789abcdef".indexOf(t[i]);if(0!=r){for(var o=1;o<n-i;o++)r*=16;e+=r}}return e}},{key:"numberToHex",value:function(t){for(var e="";0<t;){e="0123456789abcdef"[t%16]+e;t=Math.floor(t/16)}return e}},{key:"hexToRGBA",value:function(t){if("string"!=typeof t)return t;if(t=this.trim(t),this.__hexToRGBA_Cache=this.__hexToRGBA_Cache||{},this.__hexToRGBA_Cache[t])return this.__hexToRGBA_Cache[t];var e,n=t;return"#"==(n=k[n]?k[n]:n)[0]&&(e={a:1},8<=n.length?(e.a=n.substr(1,2),e.g=n.substr(5,2),e.b=n.substr(7,2),e.r=n.substr(3,2),e.a=Number((this.hexToNumber(e.a)/255).toFixed(4)),e.r=this.hexToNumber(e.r||0),e.g=this.hexToNumber(e.g||0),e.b=this.hexToNumber(e.b||0),n=e):7===n.length||4===n.length?(4===n.length?(e.g=n.substr(2,1),e.g=e.g+e.g,e.b=n.substr(3,1),e.b=e.b+e.b,e.r=n.substr(1,1),e.r=e.r+e.r):(e.g=n.substr(3,2),e.b=n.substr(5,2),e.r=n.substr(1,2)),e.r=this.hexToNumber(e.r||0),e.g=this.hexToNumber(e.g||0),e.b=this.hexToNumber(e.b||0),n=e):5===n.length&&(e.a=n.substr(1,1),e.g=n.substr(3,1),e.b=n.substr(4,1),e.r=n.substr(2,1),e.r=this.hexToNumber(e.r||0),e.g=this.hexToNumber(e.g||0),e.b=this.hexToNumber(e.b||0),e.a=Number((this.hexToNumber(e.a)/255).toFixed(4)),n=e)),"string"!=typeof n||(e=n.match(/rgb(a)?\s*\(\s*([\d\.]+)\s*,\s*([\d\.]+)\s*,\s*([\d\.]+)\s*(,\s*[\d\.]+)?\s*\)/i))&&6===e.length&&(n={r:Number(e[2]),g:Number(e[3]),b:Number(e[4]),a:Number(this.trimStart(e[5]||"1",","))}),this.__hexToRGBA_Cache[t]=n}},{key:"rgbToDecimal",value:function(t){return(t=this.clone(t)).r=this.byteToDecimal(t.r),t.g=this.byteToDecimal(t.g),t.b=this.byteToDecimal(t.b),t}},{key:"byteToDecimal",value:function(t){return t/255}},{key:"toColor",value:function(t,e,n,i){if("string"==typeof t&&t){if("#"===(t=this.trim(t))[0]&&(4===t.length||7===t.length))return t;var r=this.hexToRGBA(t);if("string"==typeof r)return r;t=void 0!==r.r?r.r:t,e=void 0!==r.g?r.g:e,n=void 0!==r.b?r.b:n,i=void 0!==r.a?r.a:i}return t&&"object"===d(t)&&(e=t.g,n=t.b,i=t.a||1,t=t.r),void 0!==t&&void 0!==e&&void 0!==n?void 0!==i?"rgba("+t+","+e+","+n+","+i+")":"rgb("+t+","+e+","+n+")":t}},{key:"requestAnimationFrame",value:function(t,e){return(e&&e.requestAnimationFrame?e.requestAnimationFrame:"undefined"!=typeof window&&window.requestAnimationFrame?window.requestAnimationFrame:setTimeout)(t,20)}},{key:"cancelAnimationFrame",value:function(t,e){return(e&&e.cancelAnimationFrame?e.cancelAnimationFrame:"undefined"!=typeof window&&window.cancelAnimationFrame?window.cancelAnimationFrame:clearTimeout)(t)}}]),t}(),T=0,C=function(){function e(t){h(this,e),t&&"jmGraph"==t.type&&(this.graph=t),this.id=++T}return l(e,[{key:"is",value:function(t){return"string"==typeof t?this.type==t:this instanceof t}},{key:"animate",value:function(){if(this.is("jmGraph")){if(1<arguments.length){this.animateHandles||(this.animateHandles=new w);var t=[];if(2<arguments.length)for(var e=2;e<arguments.length;e++)t.push(e<0||arguments.length<=e?void 0:arguments[e]);this.animateHandles.add({millisec:(arguments.length<=1?void 0:arguments[1])||20,handle:arguments.length<=0?void 0:arguments[0],params:t})}var o;this.animateHandles&&0<this.animateHandles.count()&&((o=this).dispatcher=setTimeout(function(n){n=n||o;var t,i=[],r=Date.now();for(t in n.animateHandles.each(function(t,e){try{e&&e.handle&&(!e.times||r-e.times>=e.millisec)&&(!1===e.handle.apply(n,e.params)&&i.push(e),e.times=r)}catch(t){e&&i.push(e)}}),i)n.animateHandles.remove(i[t]);n.animate()},10,this))}else{var n=this.graph;n&&n.animate.apply(n,arguments)}}}]),e}(),E=Symbol("properties"),P=function(){u(i,C);var n=v(i);function i(t){var e;return h(this,i),(e=n.call(this))[E]={},t&&t.mode&&(e.mode=t.mode),e}return l(i,[{key:"property",value:function(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];if(e){var i=this[E],r=e[0];if(1<e.length){var o=e[1],o={oldValue:i[r],newValue:o};return i[r]=e[1],this.emit&&this.emit("propertyChange",r,o),e[1]}if(r)return i[r]}}},{key:"needUpdate",get:function(){return this.property("needUpdate")},set:function(t){this.property("needUpdate",t),t&&!this.is("jmGraph")&&this.graph&&(this.graph.needUpdate=!0)}},{key:"graph",get:function(){return this.property("graph")||this.property("graph",this.findParent("jmGraph"))},set:function(t){return this.property("graph",t)}},{key:"mode",get:function(){var t=this.property("mode");return t||(this.is("jmGraph")?this.property("mode")||"2d":(null===(t=this.graph)||void 0===t?void 0:t.mode)||"2d")},set:function(t){return this.property("mode",t)}},{key:"requestAnimationFrame",value:function(t){return A.requestAnimationFrame(t,this.graph?this.graph.canvas:null)}},{key:"cancelAnimationFrame",value:function(t){return A.cancelAnimationFrame(t,this.graph?this.graph.canvas:null)}}]),i}(),S=function(){function r(t,e,n,i){h(this,r),"string"!=typeof t||e||n||i?(this.x=t,this.y=e,this.blur=n,this.color=i):this.fromString(t)}return l(r,[{key:"fromString",value:function(t){if(t){t=t.match(/\s*([^,]+)\s*,\s*([^,]+)\s*(,[^,]+)?\s*(,[\s\S]+)?\s*/i);return t&&(this.x=t[1]||0,this.y=t[2]||0,t[3]&&(t[3]=A.trim(t[3],", "),0===t[3].indexOf("#")||/^rgb/i.test(t[3])?this.color=t[3]:this.blur=A.trim(t[3],", ")),t[4]&&(this.color=A.trim(t[4],", "))),this}}},{key:"toString",value:function(){var t=this.x+","+this.y;return this.blur&&(t+=","+this.blur),this.color&&(t+=","+this.color),t}}]),r}(),R=function(){function i(t){if(h(this,i),this.stops=new w,t&&"object"==d(t)){for(var e in t)"stops"!==e&&(this[e]=t[e]);var n;t.stops&&Array.isArray(t.stops)&&(n=this.stops).push.apply(n,x(t.stops))}else"string"==typeof t&&this.fromString(t)}return l(i,[{key:"addStop",value:function(t,e){this.stops.add({offset:Number(t),color:e})}},{key:"toGradient",value:function(t){var i,e=t.context||t,n=t.absoluteBounds||t.getAbsoluteBounds(),r=this.x1||0,o=this.y1||0,s=this.x2,a=this.y2,h=t.getLocation(),l=0;(l=(l=h.radius?2*h.radius:l)||Math.min(h.width||0,h.height||0))<=0&&(l=Math.max(n.width||0,n.height||0,100));var u,c=n.width||l,f=n.height||l;A.checkPercent(r)?r=A.percentToNumber(r)*c:"number"==typeof r&&0<=r&&r<=1?r*=c:"string"==typeof r&&(h=parseFloat(r),isNaN(h)||(r=h)),A.checkPercent(s)?s=A.percentToNumber(s)*c:"number"==typeof s&&0<=s&&s<=1?s*=c:"string"==typeof s&&(u=parseFloat(s),isNaN(u)||(s=u)),A.checkPercent(o)?o=A.percentToNumber(o)*f:"number"==typeof o&&0<=o&&o<=1?o*=f:"string"==typeof o&&(u=parseFloat(o),isNaN(u)||(o=u)),A.checkPercent(a)?a=A.percentToNumber(a)*f:"number"==typeof a&&0<=a&&a<=1?a*=f:"string"==typeof a&&(d=parseFloat(a),isNaN(d)||(a=d));var r=Number(r)||0,o=Number(o)||0,s=Number(s)||0,a=Number(a)||0,d=r+(n.left||0),r=o+(n.top||0),o=s+(n.left||0),s=a+(n.top||0);if("linear"===this.type?"webgl"===t.mode&&t.webglControl?(i=t.webglControl.createLinearGradient(d,r,o,s,n)).key=this.toString():e.createLinearGradient&&(i=e.createLinearGradient(d,r,o,s)):"radial"===this.type&&(a=this.r1||0,p=this.r2,l<=0&&(l=Math.max(n.width||0,n.height||0,1)),A.checkPercent(a)?(a=A.percentToNumber(a),a*=l):"number"==typeof a&&0<=a&&a<=1?a*=l:"string"==typeof a&&(a=parseFloat(a)||0),A.checkPercent(p)?(p=A.percentToNumber(p),p*=l):"number"==typeof p&&0<=p&&p<=1?p*=l:"string"==typeof p&&(p=parseFloat(p)),(null==p||isNaN(Number(p))||Number(p)<=0)&&(p=l/2),a=Number(a)||0,p=Number(p)||l/2,"webgl"===t.mode&&t.webglControl?(i=t.webglControl.createRadialGradient(d,r,a,o,s,p,n)).key=this.toString():e.createRadialGradient?i=e.createRadialGradient(d,r,a,o,s,p):e.createCircularGradient&&(i=e.createCircularGradient(d,r,p))),i)return this.stops.each(function(t,e){var n=A.toColor(e.color);i&&i.addColorStop(e.offset,n)}),i;var p=this.stops.get(0);return p&&p.color||"#000"}},{key:"fromString",value:function(t){var e,n,i;t?!(i=t.match(/(linear|radial)-gradient\s*\(\s*([\s\S]+)\)/i))||i.length<3?console.warn('jmGradient: 无效的渐变字符串格式: "'+t+'"'):"linear"===(e=i[1].toLowerCase())||"radial"===e?(this.type=e,n=A.trim(i[2]),(t=this._findSplitIndex(n))<0?console.warn('jmGradient: 无法解析渐变内容: "'+n+'"'):(i=n.substring(0,t).trim(),(t=n.substring(t+1).trim())?("linear"===this.type?this._parseLinearParams(i):this._parseRadialParams(i),0===(i=this._parseColorStops(t))?console.warn('jmGradient: 未找到有效的颜色停止点: "'+t+'"'):i<2&&console.warn("jmGradient: 颜色停止点至少需要2个,当前只有 "+i+" 个")):console.warn("jmGradient: 未找到颜色停止点"))):console.warn('jmGradient: 不支持的渐变类型 "'+e+'",仅支持 linear 和 radial'):console.warn("jmGradient: 渐变字符串为空")}},{key:"_findSplitIndex",value:function(t){for(var e=0,n=0;n<t.length;n++){var i=t[n];if("("===i)e++;else if(")"===i)e--;else if(","===i&&0===e)return n}return-1}},{key:"isValid",value:function(){return!!this.type&&("linear"===this.type?void 0!==this.x1||void 0!==this.x2||void 0!==this._angle:"radial"===this.type&&(this.stops&&2<=this.stops.length))}},{key:"_parseLinearParams",value:function(t){var e,t=A.trim(t);t.startsWith("to ")?(e=t.substring(3).toLowerCase().trim(),e=this._directionToAngle(e),this._angle=e.angle,this.x1=e.x1,this.y1=e.y1,this.x2=e.x2,this.y2=e.y2):this._hasAngleUnit(t)?(e=this._parseAngle(t),this._angle=e,e=this._angleToCoords(e),this.x1=e.x1,this.y1=e.y1,this.x2=e.x2,this.y2=e.y2):t.startsWith("at ")?t.match(/at\s+(.+)/i)&&this._parseRadialParams(t):4<=(t=t.split(/\s+/)).length?(this.x1=t[0],this.y1=t[1],this.x2=t[2],this.y2=t[3]):2===t.length&&(this.x1=0,this.y1=0,this.x2=t[0],this.y2=t[1])}},{key:"_parseRadialParams",value:function(t){var e=A.trim(t);this.shape="ellipse",this.position={x:"50%",y:"50%"};var n=e.match(/^(.+?)\s+at\s+(.+)$/i);n?(t=A.trim(n[1]),n=A.trim(n[2]),this._parseRadialShape(t),this._parseRadialPosition(n)):e.startsWith("circle")||e.startsWith("ellipse")?(this._parseRadialShape(e),this.x1="50%",this.y1="50%",this.x2="50%",this.y2="50%"):(3<=(e=e.split(/\s+/)).length&&(this.x1=e[0],this.y1=e[1],this.r1=e[2]),6<=e.length&&(this.x2=e[3],this.y2=e[4],this.r2=e[5])),void 0===this.x1&&void 0===this.y1&&(this.x1="50%",this.y1="50%"),void 0===this.x2&&void 0===this.y2&&(this.x2="50%",this.y2="50%"),void 0===this.r2&&(this.r2="50%")}},{key:"_parseRadialShape",value:function(t){var e;t.startsWith("circle")?(this.shape="circle",(e=t.match(/circle\s*\(\s*([^)]+)\s*\)/i))&&(this.r2=A.trim(e[1]))):t.startsWith("ellipse")&&(this.shape="ellipse",!(t=t.match(/ellipse\s*\(\s*([^)]+)\s*\)/i))||2<=(t=A.trim(t[1]).split(/\s+/)).length&&(this.rx=t[0],this.ry=t[1]))}},{key:"_parseRadialPosition",value:function(t){t=t.split(/\s+/);2<=t.length&&(this.x1=t[0],this.y1=t[1],this.x2=t[0],this.y2=t[1])}},{key:"_parseColorStops",value:function(t){if(!t)return 0;for(var e=this._splitColorStops(t),n=-1,i=0,r=0;r<e.length;r++){var o,s,a=A.trim(e[r]);a&&((s=this._parseSingleColorStop(a))&&(o=s.color,a=s.offset,"transparent"===o&&(o="rgba(0,0,0,0)"),this._isValidColor(o)?null!==(s=null===(s=this._normalizeOffset(a))?0===r?0:r===e.length-1?1:null!==(a=this._findNextOffset(e,r))?(n+a)/2:Math.min(1,n+(1-n)/(e.length-r)):s)&&((s<0||1<s)&&(console.warn("jmGradient: 颜色偏移量 "+s+" 超出有效范围 [0, 1],将调整为有效范围"),s=Math.max(0,Math.min(1,s))),n=s,this.addStop(s,o),i++):console.warn('jmGradient: 无效的颜色格式 "'+o+'"')))}return i}},{key:"_splitColorStops",value:function(t){for(var e=[],n=0,i="",r=0;r<t.length;r++){var o=t[r];"("===o?(n++,i+=o):")"===o?(n--,i+=o):","===o&&0===n?(e.push(i.trim()),i=""):i+=o}return i.trim()&&e.push(i.trim()),e}},{key:"_parseSingleColorStop",value:function(t){var e=t.match(/^(#[a-fA-F0-9]{3,8})\s*(\d+(?:\.\d+)?%?)?$/i);if(e)return{color:e[1],offset:e[2]||null};e=t.match(/^(rgba?\s*\([^)]+\))\s*(\d+(?:\.\d+)?%?)?$/i);if(e)return{color:e[1],offset:e[2]||null};e=t.match(/^(hsla?\s*\([^)]+\))\s*(\d+(?:\.\d+)?%?)?$/i);if(e)return{color:e[1],offset:e[2]||null};t=t.match(/^([a-zA-Z]+)\s*(\d+(?:\.\d+)?%?)?$/i);return t&&this._isValidColor(t[1])?{color:t[1],offset:t[2]||null}:null}},{key:"_findNextOffset",value:function(t,e){for(var n=e+1;n<t.length;n++){var i=this._parseSingleColorStop(A.trim(t[n]));if(i&&i.offset)return this._normalizeOffset(i.offset)}return null}},{key:"_isValidColor",value:function(t){if(!t)return!1;if(/^#([a-fA-F0-9]{3,8})$/.test(t))return!0;if(/^rgba?\s*\(\s*\d{1,3}\s*,\s*\d{1,3}\s*,\s*\d{1,3}\s*(,\s*[\d.]+\s*)?\)$/i.test(t))return!0;return!!/^hsla?\s*\(\s*\d{1,3}\s*,\s*\d{1,3}%?\s*,\s*\d{1,3}%?\s*(,\s*[\d.]+\s*)?\)$/i.test(t)||(!!k[t.toLowerCase()]||!!/^[a-zA-Z]+$/.test(t))}},{key:"_normalizeOffset",value:function(t){if(!t)return null;if((t=A.trim(t)).endsWith("%"))return parseFloat(t)/100;t=parseFloat(t);return isNaN(t)?null:1<t?t/100:t}},{key:"_hasAngleUnit",value:function(t){return/^-?\d+(\.\d+)?\s*(deg|rad|grad|turn)$/i.test(t)}},{key:"_parseAngle",value:function(t){t=(t=A.trim(t)).match(/^(-?\d+(\.\d+)?)\s*(deg|rad|grad|turn)?$/i);if(!t)return 0;var e=parseFloat(t[1]);switch((t[3]||"deg").toLowerCase()){case"deg":return e*Math.PI/180;case"rad":return e;case"grad":return e*Math.PI/200;case"turn":return 2*e*Math.PI;default:return e*Math.PI/180}}},{key:"_angleToCoords",value:function(t){var e=Math.cos(t),t=-Math.sin(t);return{x1:Math.round(1e3*(.5-.5*e))/1e3,y1:Math.round(1e3*(.5+.5*t))/1e3,x2:Math.round(1e3*(.5+.5*e))/1e3,y2:Math.round(1e3*(.5-.5*t))/1e3}}},{key:"_directionToAngle",value:function(t){var e={"to top":{angle:0,x1:"50%",y1:"100%",x2:"50%",y2:"0%"},"to bottom":{angle:Math.PI,x1:"50%",y1:"0%",x2:"50%",y2:"100%"},"to left":{angle:-Math.PI/2,x1:"100%",y1:"50%",x2:"0%",y2:"50%"},"to right":{angle:Math.PI/2,x1:"0%",y1:"50%",x2:"100%",y2:"50%"},"to top left":{angle:3*-Math.PI/4,x1:"100%",y1:"100%",x2:"0%",y2:"0%"},"to top right":{angle:-Math.PI/4,x1:"0%",y1:"100%",x2:"100%",y2:"0%"},"to bottom left":{angle:3*Math.PI/4,x1:"100%",y1:"0%",x2:"0%",y2:"100%"},"to bottom right":{angle:Math.PI/4,x1:"0%",y1:"0%",x2:"100%",y2:"100%"},top:{angle:0,x1:"50%",y1:"100%",x2:"50%",y2:"0%"},bottom:{angle:Math.PI,x1:"50%",y1:"0%",x2:"50%",y2:"100%"},left:{angle:-Math.PI/2,x1:"100%",y1:"50%",x2:"0%",y2:"50%"},right:{angle:Math.PI/2,x1:"0%",y1:"50%",x2:"100%",y2:"50%"}},n=e[t];if(n)return n;var i=t.match(/to\s+(top|bottom|left|right)/i);if(i){n=i[1].toLowerCase(),i=t.replace(i[0],"").trim();if(i){i="to ".concat(n," ").concat(i);if(e[i])return e[i]}}return{angle:0,x1:"50%",y1:"100%",x2:"50%",y2:"0%"}}},{key:"toString",value:function(){var n=this.type+"-gradient(";return"linear"==this.type?n+=this.x1+" "+this.y1+" "+this.x2+" "+this.y2:n+=this.x1+" "+this.y1+" "+this.r1+" "+this.x2+" "+this.y2+" "+this.r2,this.stops.each(function(t,e){n+=","+e.color+" "+e.offset}),n+")"}}]),i}(),M=function(){function n(t){if(h(this,n),this.filters=[],"string"==typeof t)this.fromString(t);else if(t&&"object"===d(t))for(var e in t)"constructor"!==e&&"filters"!==e&&this.addFilter(e,t[e])}return l(n,[{key:"addFilter",value:function(t,e){var n;t=t.toLowerCase().trim(),"string"==typeof e&&(e=parseFloat(e)),isNaN(e)||(n={blur:"blur",grayscale:"grayscale",greyscale:"grayscale",sepia:"sepia",brightness:"brightness",contrast:"contrast",saturate:"saturate","hue-rotate":"hueRotate",hueRotate:"hueRotate",invert:"invert",opacity:"opacity"}[t])&&((t=this.filters.find(function(t){return t.name===n}))?t.value=e:this.filters.push({name:n,value:e}))}},{key:"fromString",value:function(t){if(t&&"string"==typeof t)for(var e=/([a-zA-Z-]+)\s*\(\s*([^)]+)\s*\)/g;null!==(i=e.exec(t));){var n=i[1],i=i[2].replace(/[a-z%]+$/i,"").trim(),i=parseFloat(i);isNaN(i)||this.addFilter(n,i)}}},{key:"toString",value:function(){return this.filters.map(function(t){switch(t.name){case"blur":return"blur(".concat(t.value,"px)");case"hueRotate":return"hue-rotate(".concat(t.value,"deg)");default:return"".concat(t.name,"(").concat(t.value,")")}}).join(" ")}},{key:"toCanvasFilter",value:function(){return 0===this.filters.length?"none":this.toString()}},{key:"has",value:function(e){return this.filters.some(function(t){return t.name===e})}},{key:"get",value:function(e){var t=this.filters.find(function(t){return t.name===e});return t?t.value:void 0}},{key:"remove",value:function(e){var t=this.filters.findIndex(function(t){return t.name===e});-1<t&&this.filters.splice(t,1)}},{key:"clear",value:function(){this.filters=[]}}]),n}(),N=function(){function n(t,e){h(this,n),this.container=t,this.target=e||t,this.mouseHandler=new F(this,t,e),this.keyHandler=new B(this,t,e)}return l(n,[{key:"touchStart",value:function(t){if((t=t||window.event).eventName="touchstart",this.container.raiseEvent("touchstart",t),(t.target||t.srcElement)==this.target)return!1}},{key:"touchMove",value:function(t){if((t=t||window.event).eventName="touchmove",this.container.raiseEvent("touchmove",t),(t.target||t.srcElement)==this.target)return!1}},{key:"touchEnd",value:function(t){if((t=t||window.event).eventName="touchend",this.container.raiseEvent("touchend",t),(t.target||t.srcElement)==this.target)return!1}},{key:"touchCancel",value:function(t){if((t=t||window.event).eventName="touchcancel",this.container.raiseEvent("touchcancel",t),(t.target||t.srcElement)==this.target)return!1}},{key:"tap",value:function(t){if((t=t||window.event).eventName="tap",this.container.raiseEvent("tap",t),(t.target||t.srcElement)==this.target)return!1}},{key:"destroy",value:function(){this.mouseHandler.destroy(),this.keyHandler.destroy()}}]),n}(),F=function(){function i(t,e,n){h(this,i),this.instance=t,this.container=e,this.target=n||e,this.eventEvents={},this.init(t,e,n)}return l(i,[{key:"init",value:function(e,n,t){var i=this.target,r="undefined"!=typeof document?document:null;this.eventEvents.mousedown=A.bindEvent(this.target,"mousedown",function(t){(t=t||window.event).eventName="mousedown",n.raiseEvent("mousedown",t)}),this.eventEvents.mousemove=A.bindEvent(this.target,"mousemove",function(t){if((t=t||window.event).eventName="mousemove",(t.target||t.srcElement)==i)return n.raiseEvent("mousemove",t),t.preventDefault&&t.preventDefault(),!1}),this.eventEvents.mouseover=A.bindEvent(this.target,"mouseover",function(t){(t=t||window.event).eventName="mouseover",n.raiseEvent("mouseover",t)}),this.eventEvents.mouseleave=A.bindEvent(this.target,"mouseleave",function(t){(t=t||window.event).eventName="mouseleave",n.raiseEvent("mouseleave",t)}),this.eventEvents.mouseout=A.bindEvent(this.target,"mouseout",function(t){(t=t||window.event).eventName="mouseout",n.raiseEvent("mouseout",t)}),r&&(this.eventEvents.mouseup=A.bindEvent(r,"mouseup",function(t){if(!((t=t||window.event).eventName="mouseup")===n.raiseEvent("mouseup",t))return t.preventDefault&&t.preventDefault(),!1})),this.eventEvents.dblclick=A.bindEvent(this.target,"dblclick",function(t){(t=t||window.event).eventName="dblclick",n.raiseEvent("dblclick",t)}),this.eventEvents.click=A.bindEvent(this.target,"click",function(t){(t=t||window.event).eventName="click",n.raiseEvent("click",t)}),r&&(this.eventEvents.resize=A.bindEvent(r,"resize",function(t){return(t=t||window.event).eventName="resize",n.raiseEvent("resize",t)})),this.eventEvents.touchstart=A.bindEvent(this.target,"touchstart",function(t){return t.eventName="touchstart",e.touchStart(t)},{passive:!1}),this.eventEvents.touchmove=A.bindEvent(this.target,"touchmove",function(t){return t.eventName="touchmove",e.touchMove(t)},{passive:!1}),r&&(this.eventEvents.touchend=A.bindEvent(r,"touchend",function(t){return t.eventName="touchend",e.touchEnd(t)},{passive:!1})),r&&(this.eventEvents.touchcancel=A.bindEvent(r,"touchcancel",function(t){return t.eventName="touchcancel",e.touchCancel(t)},{passive:!1}))}},{key:"destroy",value:function(){for(var t in this.eventEvents){var e=this.eventEvents[t];e&&e.fun&&A.removeEvent(e.target,t,e.fun)}}}]),i}(),B=function(){function i(t,e,n){h(this,i),this.instance=t,this.container=e,this.target=n||e,this.eventEvents={},this.init(e,n)}return l(i,[{key:"init",value:function(n,t){function i(t){return!(t=t.srcElement||t.target)||"INPUT"!=t.tagName&&"TEXTAREA"!=t.tagName&&"ANCHOR"!=t.tagName&&"FORM"!=t.tagName&&"FILE"!=t.tagName&&"IMG"!=t.tagName&&"HIDDEN"!=t.tagName&&"RADIO"!=t.tagName&&"TEXT"!=t.tagName}var e="undefined"!=typeof document?document:null;e&&(this.eventEvents.keypress=A.bindEvent(e,"keypress",function(t){if(t=t||window.event,i(t)){var e=n.raiseEvent("keypress",t);return!1===e&&t.preventDefault&&t.preventDefault(),e}})),e&&(this.eventEvents.keydown=A.bindEvent(e,"keydown",function(t){if(t=t||window.event,i(t)){var e=n.raiseEvent("keydown",t);return!1===e&&t.preventDefault&&t.preventDefault(),e}})),e&&(this.eventEvents.keyup=A.bindEvent(e,"keyup",function(t){if(t=t||window.event,i(t)){var e=n.raiseEvent("keyup",t);return!1===e&&t.preventDefault&&t.preventDefault(),e}}))}},{key:"destroy",value:function(){for(var t in this.eventEvents){var e=this.eventEvents[t];e&&e.fun&&A.removeEvent(e.target,t,e.fun)}}}]),i}();function O(t,e,n){n=n||2;var i,r,o,s,a,h=e&&e.length,l=h?e[0]*n:t.length,u=D(t,0,l,n,!0),c=[];if(!u||u.next===u.prev)return c;if(h&&(u=function(t,e,n,i){var r,o,s,a,h=[];for(r=0,o=e.length;r<o;r++)s=e[r]*i,a=r<o-1?e[r+1]*i:t.length,(a=D(t,s,a,i,!1))===a.next&&(a.steiner=!0),h.push(function(t){var e=t,n=t;for(;(e.x<n.x||e.x===n.x&&e.y<n.y)&&(n=e),e=e.next,e!==t;);return n}(a));for(h.sort(j),r=0;r<h.length;r++)n=function(t,e){var n=function(t,e){var n,i=e,r=t.x,o=t.y,s=-1/0;do{if(o<=i.y&&o>=i.next.y&&i.next.y!==i.y){var a=i.x+(o-i.y)*(i.next.x-i.x)/(i.next.y-i.y);if(a<=r&&s<a&&(s=a,n=i.x<i.next.x?i:i.next,a===r))return n}}while(i=i.next,i!==e);if(!n)return null;var h,l=n,u=n.x,c=n.y,f=1/0;i=n;for(;r>=i.x&&i.x>=u&&r!==i.x&&U(o<c?r:s,o,u,c,o<c?s:r,o,i.x,i.y)&&(h=Math.abs(o-i.y)/(r-i.x),V(i,t)&&(h<f||h===f&&(i.x>n.x||i.x===n.x&&function(t,e){return G(t.prev,t,e.prev)<0&&G(e.next,t,t.next)<0}(n,i)))&&(n=i,f=h)),i=i.next,i!==l;);return n}(t,e);if(!n)return e;t=H(n,t);return I(t,t.next),I(n,n.next)}(h[r],n);return n}(t,e,u,n)),t.length>80*n){for(var f=i=t[0],d=r=t[1],p=n;p<l;p+=n)(o=t[p])<f&&(f=o),(s=t[p+1])<d&&(d=s),i<o&&(i=o),r<s&&(r=s);a=0!==(a=Math.max(i-f,r-d))?32767/a:0}return L(u,c,n,f,d,a,0),c}function D(t,e,n,i,r){var o,s;if(r===0<J(t,e,n,i))for(o=e;o<n;o+=i)s=Z(o,t[o],t[o+1],s);else for(o=n-i;e<=o;o-=i)s=Z(o,t[o],t[o+1],s);return s&&Y(s,s.next)&&($(s),s=s.next),s}function I(t,e){if(!t)return t;e=e||t;var n,i=t;do{if(n=!1,i.steiner||!Y(i,i.next)&&0!==G(i.prev,i,i.next))i=i.next;else{if($(i),(i=e=i.prev)===i.next)break;n=!0}}while(n||i!==e);return e}function L(t,e,n,i,r,o,s){if(t){!s&&o&&function(t,e,n,i){var r=t;for(;0===r.z&&(r.z=z(r.x,r.y,e,n,i)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next,r!==t;);r.prevZ.nextZ=null,r.prevZ=null,function(t){var e,n,i,r,o,s,a,h,l=1;do{for(n=t,o=t=null,s=0;n;){for(s++,i=n,e=a=0;e<l&&(a++,i=i.nextZ);e++);for(h=l;0<a||0<h&&i;)0!==a&&(0===h||!i||n.z<=i.z)?(n=(r=n).nextZ,a--):(i=(r=i).nextZ,h--),o?o.nextZ=r:t=r,r.prevZ=o,o=r;n=i}}while(o.nextZ=null,l*=2,1<s)}(r)}(t,i,r,o);for(var a,h,l=t;t.prev!==t.next;)if(a=t.prev,h=t.next,o?function(t,e,n,i){var r=t.prev,o=t,s=t.next;if(0<=G(r,o,s))return!1;var a=r.x,h=o.x,l=s.x,u=r.y,c=o.y,f=s.y,d=a<h?a<l?a:l:h<l?h:l,p=u<c?u<f?u:f:c<f?c:f,v=h<a?l<a?a:l:l<h?h:l,y=c<u?f<u?u:f:f<c?c:f,g=z(d,p,e,n,i),m=z(v,y,e,n,i),x=t.prevZ,b=t.nextZ;for(;x&&x.z>=g&&b&&b.z<=m;){if(x.x>=d&&x.x<=v&&x.y>=p&&x.y<=y&&x!==r&&x!==s&&U(a,u,h,c,l,f,x.x,x.y)&&0<=G(x.prev,x,x.next))return!1;if(x=x.prevZ,b.x>=d&&b.x<=v&&b.y>=p&&b.y<=y&&b!==r&&b!==s&&U(a,u,h,c,l,f,b.x,b.y)&&0<=G(b.prev,b,b.next))return!1;b=b.nextZ}for(;x&&x.z>=g;){if(x.x>=d&&x.x<=v&&x.y>=p&&x.y<=y&&x!==r&&x!==s&&U(a,u,h,c,l,f,x.x,x.y)&&0<=G(x.prev,x,x.next))return!1;x=x.prevZ}for(;b&&b.z<=m;){if(b.x>=d&&b.x<=v&&b.y>=p&&b.y<=y&&b!==r&&b!==s&&U(a,u,h,c,l,f,b.x,b.y)&&0<=G(b.prev,b,b.next))return!1;b=b.nextZ}return!0}(t,i,r,o):function(t){var e=t.prev,n=t,t=t.next;if(0<=G(e,n,t))return!1;var i=e.x,r=n.x,o=t.x,s=e.y,a=n.y,h=t.y,l=i<r?i<o?i:o:r<o?r:o,u=s<a?s<h?s:h:a<h?a:h,c=r<i?o<i?i:o:o<r?r:o,f=a<s?h<s?s:h:h<a?a:h,d=t.next;for(;d!==e;){if(d.x>=l&&d.x<=c&&d.y>=u&&d.y<=f&&U(i,s,r,a,o,h,d.x,d.y)&&0<=G(d.prev,d,d.next))return!1;d=d.next}return!0}(t))e.push(a.i/n|0),e.push(t.i/n|0),e.push(h.i/n|0),$(t),t=h.next,l=h.next;else if((t=h)===l){s?1===s?L(t=function(t,e,n){var i=t;do{var r=i.prev,o=i.next.next}while(!Y(r,o)&&X(r,i,i.next,o)&&V(r,o)&&V(o,r)&&(e.push(r.i/n|0),e.push(i.i/n|0),e.push(o.i/n|0),$(i),$(i.next),i=t=o),i=i.next,i!==t);return I(i)}(I(t),e,n),e,n,i,r,o,2):2===s&&function(t,e,n,i,r,o){var s=t;do{for(var a=s.next.next;a!==s.prev;){if(s.i!==a.i&&function(t,e){return t.next.i!==e.i&&t.prev.i!==e.i&&!function(t,e){var n=t;do{if(n.i!==t.i&&n.next.i!==t.i&&n.i!==e.i&&n.next.i!==e.i&&X(n,n.next,t,e))return!0}while(n=n.next,n!==t);return!1}(t,e)&&(V(t,e)&&V(e,t)&&function(t,e){var n=t,i=!1,r=(t.x+e.x)/2,o=(t.y+e.y)/2;for(;n.y>o!=n.next.y>o&&n.next.y!==n.y&&r<(n.next.x-n.x)*(o-n.y)/(n.next.y-n.y)+n.x&&(i=!i),n=n.next,n!==t;);return i}(t,e)&&(G(t.prev,t,e.prev)||G(t,e.prev,e))||Y(t,e)&&0<G(t.prev,t,t.next)&&0<G(e.prev,e,e.next))}(s,a)){var h=H(s,a);return s=I(s,s.next),h=I(h,h.next),L(s,e,n,i,r,o,0),L(h,e,n,i,r,o,0)}a=a.next}}while(s=s.next,s!==t)}(t,e,n,i,r,o):L(I(t),e,n,i,r,o,1);break}}}function j(t,e){return t.x-e.x}function z(t,e,n,i,r){return(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=(t-n)*r|0)|t<<8))|t<<4))|t<<2))|t<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-i)*r|0)|e<<8))|e<<4))|e<<2))|e<<1))<<1}function U(t,e,n,i,r,o,s,a){return(t-s)*(o-a)<=(r-s)*(e-a)&&(n-s)*(e-a)<=(t-s)*(i-a)&&(r-s)*(i-a)<=(n-s)*(o-a)}function G(t,e,n){return(e.y-t.y)*(n.x-e.x)-(e.x-t.x)*(n.y-e.y)}function Y(t,e){return t.x===e.x&&t.y===e.y}function X(t,e,n,i){var r=q(G(t,e,n)),o=q(G(t,e,i)),s=q(G(n,i,t)),a=q(G(n,i,e));return r!==o&&s!==a||(0===r&&W(t,n,e)||(0===o&&W(t,i,e)||(0===s&&W(n,t,i)||!(0!==a||!W(n,e,i)))))}function W(t,e,n){return e.x<=Math.max(t.x,n.x)&&e.x>=Math.min(t.x,n.x)&&e.y<=Math.max(t.y,n.y)&&e.y>=Math.min(t.y,n.y)}function q(t){return 0<t?1:t<0?-1:0}function V(t,e){return G(t.prev,t,t.next)<0?0<=G(t,e,t.next)&&0<=G(t,t.prev,e):G(t,e,t.prev)<0||G(t,t.next,e)<0}function H(t,e){var n=new K(t.i,t.x,t.y),i=new K(e.i,e.x,e.y),r=t.next,o=e.prev;return(t.next=e).prev=t,(n.next=r).prev=n,(i.next=n).prev=i,(o.next=i).prev=o,i}function Z(t,e,n,i){n=new K(t,e,n);return i?(n.next=i.next,(n.prev=i).next.prev=n,i.next=n):(n.prev=n).next=n,n}function $(t){t.next.prev=t.prev,t.prev.next=t.next,t.prevZ&&(t.prevZ.nextZ=t.nextZ),t.nextZ&&(t.nextZ.prevZ=t.prevZ)}function K(t,e,n){this.i=t,this.x=e,this.y=n,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}function J(t,e,n,i){for(var r=0,o=e,s=n-i;o<n;o+=i)r+=(t[s]-t[o])*(t[o+1]+t[s+1]),s=o;return r}O.deviation=function(t,e,n,i){var r=e&&e.length,o=r?e[0]*n:t.length,s=Math.abs(J(t,0,o,n));if(r)for(var a=0,h=e.length;a<h;a++){var l=e[a]*n,u=a<h-1?e[a+1]*n:t.length;s-=Math.abs(J(t,l,u,n))}for(var c=0,a=0;a<i.length;a+=3){var f=i[a]*n,d=i[a+1]*n,p=i[a+2]*n;c+=Math.abs((t[f]-t[p])*(t[1+d]-t[1+f])-(t[f]-t[d])*(t[1+p]-t[1+f]))}return 0===s&&0===c?0:Math.abs((c-s)/s)},O.flatten=function(t){for(var e=t[0][0].length,n={vertices:[],holes:[],dimensions:e},i=0,r=0;r<t.length;r++){for(var o=0;o<t[r].length;o++)for(var s=0;s<e;s++)n.vertices.push(t[r][o][s]);0<r&&(i+=t[r-1].length,n.holes.push(i))}return n};var Q=function(){function n(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:"linear",e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{};h(this,n),this.type=t||"linear",this.x1=e.x1||0,this.y1=e.y1||0,this.r1=e.r1||0,this.x2=e.x2||0,this.y2=e.y2||0,this.r2=e.r2||0,this.bounds=e.bounds||{left:0,top:0,width:0,height:0},this.control=e.control,this.stops=[],this._sortedStops=null,this._paramsHash=null}return l(n,[{key:"addColorStop",value:function(t,e){this.stops.push({offset:Math.max(0,Math.min(1,t)),color:e}),this._sortedStops=null,this._paramsHash=null}},{key:"_getSortedStops",value:function(){if(this._sortedStops)return this._sortedStops;var i=this.control&&this.control.graph&&this.control.graph.utils;return this._sortedStops=this.stops.map(function(t){var e=t.color;if("object"!==d(e=i&&"string"==typeof e?i.hexToRGBA(e):e)||null===e)return{offset:t.offset,r:0,g:0,b:0,a:1};var n=1<e.r||1<e.g||1<e.b?255:1;return{offset:t.offset,r:(void 0!==e.r?e.r:0)/n,g:(void 0!==e.g?e.g:0)/n,b:(void 0!==e.b?e.b:0)/n,a:void 0!==e.a?e.a:1}}).sort(function(t,e){return t.offset-e.offset}),this._sortedStops}},{key:"toUniformParams",value:function(){for(var t=this._getSortedStops(),e=Math.min(t.length,16),n=new Float32Array(5*e),i=0;i<e;i++){var r=t[i];n[5*i+0]=r.offset,n[5*i+1]=r.r,n[5*i+2]=r.g,n[5*i+3]=r.b,n[5*i+4]=r.a}return{gradientType:"radial"===this.type?2:1,gradientStart:new Float32Array([this.x1,this.y1,"radial"===this.type?Math.max(0,this.r1):0,0]),gradientEnd:new Float32Array([this.x2,this.y2,"radial"===this.type?Math.max(0,this.r2):0,0]),stopCount:e,stops:n}}},{key:"invalidateCache",value:function(){this._sortedStops=null,this._paramsHash=null}},{key:"toString",value:function(){var e=this.type+"-gradient(";return"linear"==this.type?e+=this.x1+" "+this.y1+" "+this.x2+" "+this.y2:e+=this.x1+" "+this.y1+" "+this.r1+" "+this.x2+" "+this.y2+" "+this.r2,this.stops.forEach(function(t){e+=","+t.color+" "+t.offset}),e+")"}}]),n}();function tt(t,e,n){e=t.createShader(e);return t.shaderSource(e,n),t.compileShader(e),e}var et={float:1,vec2:2,vec3:3,vec4:4,int:1,ivec2:2,ivec3:3,ivec4:4,bool:1,bvec2:2,bvec3:3,bvec4:4,mat2:4,mat3:9,mat4:16,sampler2D:1},nt=function(t){return et[t]},it=null,rt={FLOAT:"float",FLOAT_VEC2:"vec2",FLOAT_VEC3:"vec3",FLOAT_VEC4:"vec4",INT:"int",INT_VEC2:"ivec2",INT_VEC3:"ivec3",INT_VEC4:"ivec4",BOOL:"bool",BOOL_VEC2:"bvec2",BOOL_VEC3:"bvec3",BOOL_VEC4:"bvec4",FLOAT_MAT2:"mat2",FLOAT_MAT3:"mat3",FLOAT_MAT4:"mat4",SAMPLER_2D:"sampler2D"},ot=function(t,e){if(!it){var n=Object.keys(rt);it={};for(var i=0;i<n.length;++i){var r=n[i];it[t[r]]=rt[r]}}return it[e]};function st(t,e,n){var i=tt(t,t.VERTEX_SHADER,e),e=tt(t,t.FRAGMENT_SHADER,n),n=t.createProgram();return t.attachShader(n,i),t.attachShader(n,e),t.linkProgram(n),t.getProgramParameter(n,t.LINK_STATUS)||(console.error("PError: Could not initialize shader."),console.error("gl.VALIDATE_STATUS",t.getProgramParameter(n,t.VALIDATE_STATUS)),console.error("gl.getError()",t.getError()),""!==t.getProgramInfoLog(n)&&console.warn("Warning: gl.getProgramInfoLog()",t.getProgramInfoLog(n)),t.deleteProgram(n)),at(t,n),t.deleteShader(i),t.deleteShader(e),{program:n,attrs:function(t,e){for(var n={},i=t.getProgramParameter(e,t.ACTIVE_ATTRIBUTES),r=0;r<i;r++){var o=t.getActiveAttrib(e,r),s=ot(t,o.type);n[o.name]={attribData:o,size:nt(s),type:s,location:t.getAttribLocation(e,o.name)}}return n}(t,n),uniforms:function(t,e){for(var n={},i=t.getProgramParameter(e,t.ACTIVE_UNIFORMS),r=0;r<i;r++){var o=t.getActiveUniform(e,r),s=o.name.replace(/\[.*?\]/,""),a=ot(t,o.type);n[s]={uniformData:o,type:a,size:o.size,location:t.getUniformLocation(e,s)}}return n}(t,n)}}function at(t,e){return t.useProgram(e)}function ht(t,e,n,i){var r=2<arguments.length&&void 0!==n?n:t.ARRAY_BUFFER,n=3<arguments.length&&void 0!==i?i:t.STATIC_DRAW,i=t.createBuffer();if(!i)throw Error("创建缓冲区对象失败");return t.bindBuffer(r,i),t.bufferData(r,e.buffer||e,n),{type:r,drawType:n,buffer:i,unitSize:e.BYTES_PER_ELEMENT}}function lt(t){var e=t.createTexture();return t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,1),t.activeTexture(t.TEXTURE0),t.bindTexture(t.TEXTURE_2D,e),t.texParameterf(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,t.NEAREST),t.texParameterf(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameterf(t.TEXTURE_2D,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameterf(t.TEXTURE_2D,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE),e}var ut="\n attribute vec4 a_position;\n attribute vec4 a_color;\n attribute vec2 a_text_coord;\n uniform vec2 a_center_point; // 当前canvas的中心位置\n uniform float a_point_size; // 点的大小\n uniform int a_type;\n varying vec4 v_color;\n varying vec2 v_text_coord;\n varying float v_type;\n\n ".concat("\n vec4 translatePosition(vec4 point, float x, float y) {\n point.x = (point.x-x)/x;\n point.y = (y-point.y)/y;\n return point;\n }","\n\n void main() {\n gl_PointSize = a_point_size == 0.0? 1.0 : a_point_size;\n v_type = float(a_type);\n vec4 pos = translatePosition(a_position, a_center_point.x, a_center_point.y);\n gl_Position = pos;\n v_color = a_color;\n if(a_type == 2 || a_type == 5) {\n v_text_coord = a_position.xy;\n }\n }\n"),ct="\n precision mediump float;\n uniform sampler2D u_sample;\n uniform vec4 v_texture_bounds; // 纹理的左上坐标和大小 x,y,z,w\n uniform vec4 v_single_color;\n // GLSL 渐变 uniforms\n uniform int u_gradient_type; // 0=无 1=线性 2=径向\n uniform vec4 u_gradient_start; // 线性:{x1,y1,0,0} 径向:{cx,cy,r1,0}\n uniform vec4 u_gradient_end; // 线性:{x2,y2,0,0} 径向:{cx,cy,r2,0}\n uniform int u_gradient_stop_count;\n uniform float u_gradient_offsets[".concat(16,"];\n uniform vec4 u_gradient_colors[").concat(16,"]; // {r, g, b, a} 0~1 范围\n varying float v_type;\n varying vec4 v_color;\n varying vec2 v_text_coord;\n\n ").concat("\n vec2 translateTexturePosition(in vec2 point, vec4 bounds) {\n point.x = (point.x-bounds.x)/bounds.z; // 离左上角位置的X长比上纹理宽 0-1\n point.y = 1.0-(point.y-bounds.y)/bounds.w; // 离左上角位置的Y长比上高,因为纹理坐标是左下角起,所以要用1-\n return point;\n }","\n\n // 在 sorted stops 中按 t 值采样颜色\n // 兼容 GLSL ES 1.0:循环仅与常量比较,无 break/continue\n vec4 sampleGradient(float t) {\n t = clamp(t, 0.0, 1.0);\n // 正向扫描:始终遍历 MAX_STOPS-1 次,找到 t 所在段并覆盖结果\n float localT = 0.0;\n vec4 c0 = u_gradient_colors[0];\n vec4 c1 = u_gradient_colors[0];\n for(int i = 0; i < ").concat(15,"; i++) {\n float s0 = u_gradient_offsets[i];\n float s1 = u_gradient_offsets[i + 1];\n if(t >= s0) {\n float range = s1 - s0;\n localT = range > 0.0001 ? clamp((t - s0) / range, 0.0, 1.0) : 0.0;\n c0 = u_gradient_colors[i];\n c1 = u_gradient_colors[i + 1];\n }\n }\n return mix(c0, c1, localT);\n }\n\n void main() {\n // 如果是fill,则直接填充颜色\n if(v_type == 1.0) {\n gl_FragColor = v_single_color;\n }\n // 渐变色 (旧方式,顶点颜色插值)\n else if(v_type == 3.0) {\n gl_FragColor = v_color;\n }\n // GLSL 渐变填充 (type=5)\n else if(v_type == 5.0) {\n float t;\n if(u_gradient_type == 2) {\n // 径向渐变\n vec2 d = v_text_coord - u_gradient_start.xy;\n float dist = length(d);\n float r1 = u_gradient_start.z;\n float r2 = u_gradient_end.z;\n float range = r2 - r1;\n t = range > 0.001 ? (dist - r1) / range : 0.0;\n } else {\n // 线性渐变\n vec2 dir = u_gradient_end.xy - u_gradient_start.xy;\n float lenSq = dot(dir, dir);\n if(lenSq > 0.001) {\n vec2 pos = v_text_coord - u_gradient_start.xy;\n t = dot(pos, dir) / lenSq;\n } else {\n t = 0.0;\n }\n }\n gl_FragColor = sampleGradient(t) * v_single_color.a;\n }\n else if(v_type == 2.0) {\n vec2 pos = translateTexturePosition(v_text_coord, v_texture_bounds);\n gl_FragColor = texture2D(u_sample, pos);\n }\n else {\n float r = distance(gl_PointCoord, vec2(0.5, 0.5));\n //根据距离设置片元\n if(r <= 0.5){\n // 方形区域片元距离几何中心半径小于0.5,像素颜色设置红色\n gl_FragColor = v_single_color;\n }else {\n // 方形区域距离几何中心半径不小于0.5的片元剪裁舍弃掉:\n discard;\n }\n }\n }\n"),ft=function(){function n(t,e){h(this,n),this.graph=t,this.option=e||{},this.style={globalAlpha:1},this.stateStack=[],this.transformMatrix=[1,0,0,1,0,0]}return l(n,[{key:"context",get:function(){if(this.graph)return this.graph.context}},{key:"save",value:function(){this.stateStack.push({transformMatrix:x(this.transformMatrix),style:s({},this.style)})}},{key:"restore",value:function(){var t;0<this.stateStack.length&&(t=this.stateStack.pop(),this.transformMatrix=t.transformMatrix,this.style=t.style)}},{key:"translate",value:function(t,e){this.transformMatrix[4]+=t*this.transformMatrix[0]+e*this.transformMatrix[2],this.transformMatrix[5]+=t*this.transformMatrix[1]+e*this.transformMatrix[3]}},{key:"scale",value:function(t,e){this.transformMatrix[0]*=t,this.transformMatrix[1]*=t,this.transformMatrix[2]*=e,this.transformMatrix[3]*=e}},{key:"rotate",value:function(t){var e=Math.cos(t),n=Math.sin(t),i=g(this.transformMatrix,4),r=i[0],o=i[1],t=i[2],i=i[3];this.transformMatrix[0]=r*e-o*n,this.transformMatrix[1]=r*n+o*e,this.transformMatrix[2]=t*e-i*n,this.transformMatrix[3]=t*n+i*e}},{key:"transform",value:function(t,e,n,i,r,o){var s=g(this.transformMatrix,6),a=s[0],h=s[1],l=s[2],u=s[3],c=s[4],s=s[5];this.transformMatrix[0]=t*a+e*l,this.transformMatrix[1]=t*h+e*u,this.transformMatrix[2]=n*a+i*l,this.transformMatrix[3]=n*h+i*u,this.transformMatrix[4]=r*a+o*l+c,this.transformMatrix[5]=r*h+o*u+s}},{key:"applyTransform",value:function(t){var e=g(this.transformMatrix,6),n=e[0],i=e[1],r=e[2],o=e[3],s=e[4],e=e[5];return{x:n*t.x+r*t.y+s,y:i*t.x+o*t.y+e}}},{key:"_measureCtx",get:function(){if(!this.__measureCtx)try{var t;"undefined"!=typeof document&&((t=document.createElement("canvas")).width=t.height=1,this.__measureCtx=t.getContext("2d"))}catch(t){this.__measureCtx=null}return this.__measureCtx}},{key:"program",get:function(){return this.graph.context.pathProgram||(this.graph.context.pathProgram=this.createProgram(ut,ct))}},{key:"setStyle",value:function(){var t,e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:this.style;"string"==typeof e&&((t={})[e]=1<arguments.length&&void 0!==arguments[1]?arguments[1]:"",e=t),this.style=s(s({},this.style),e)}},{key:"convertColor",value:function(t){return!this.isGradient(t)&&"object"===d(t="string"==typeof t&&"string"==typeof(t=this.graph.utils.hexToRGBA(t))?this.__parseCSSColor(t):t)&&void 0!==t.r?this.graph.utils.rgbToDecimal(t):t}},{key:"__parseCSSColor",value:function(t){var e=this._measureCtx;if(!e)return{r:0,g:0,b:0,a:0};try{e.clearRect(0,0,1,1),e.fillStyle="#000000",e.fillStyle=t,e.fillRect(0,0,1,1);var n=g(e.getImageData(0,0,1,1).data,4),i=n[0],r=n[1],o=n[2],s=n[3];return"#000000"===e.fillStyle&&"#000000"!==t&&"black"!==t?{r:0,g:0,b:0,a:0}:{r:i,g:r,b:o,a:s/255}}catch(t){return{r:0,g:0,b:0,a:0}}}},{key:"createProgram",value:function(t,e){return st(this.context,t,e)}},{key:"useProgram",value:function(){var t=(t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:this.program).program||t;return this.context.__curent_program===t?t:(at(this.context,t.program||t),this.context.__curent_program=t)}},{key:"getAttribLocation",value:function(t){return this.context.getAttribLocation(this.program.program,t)}},{key:"getUniformLocation",value:function(t){return this.context.getUniformLocation(this.program.program,t)}},{key:"writeVertexAttrib",value:function(t,e){var n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:2,i=3<arguments.length&&void 0!==arguments[3]?arguments[3]:0,r=4<arguments.length&&void 0!==arguments[4]?arguments[4]:0,o=5<arguments.length&&void 0!==arguments[5]?arguments[5]:this.context.FLOAT;return t.attr=e,function(t,e,n,i,r,o,s){return i=3<arguments.length&&void 0!==i?i:2,r=4<arguments.length&&void 0!==r?r:0,o=5<arguments.length&&void 0!==o?o:0,s=6<arguments.length&&void 0!==s?s:t.FLOAT,t.bindBuffer(e.type,e.buffer),t.vertexAttribPointer(n.location,i,s,!1,r*e.unitSize,o),t.enableVertexAttribArray(n.location),e}(this.context,t,e,n,i,r,o)}},{key:"disableVertexAttribArray",value:function(t){try{return t?this.context.disableVertexAttribArray(t.location):t}catch(t){console.error(t)}return t}},{key:"createFloat32Buffer",value:function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:this.context.ARRAY_BUFFER,n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:this.context.STATIC_DRAW;return s({data:t},function(t,e,n,i){return n=2<arguments.length&&void 0!==n?n:t.ARRAY_BUFFER,i=3<arguments.length&&void 0!==i?i:t.STATIC_DRAW,ht(t,new Float32Array(e),n,i)}(this.context,t,e,n))}},{key:"createUint16Buffer",value:function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:this.context.ARRAY_BUFFER,n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:this.context.STATIC_DRAW;return s({data:t},function(t,e,n,i){return n=2<arguments.length&&void 0!==n?n:t.ARRAY_BUFFER,i=3<arguments.length&&void 0!==i?i:t.STATIC_DRAW,ht(t,new Uint16Array(e),n,i)}(this.context,t,e,n))}},{key:"deleteBuffer",value:function(e){try{if(!e)return;var t=e.buffer||e;if(t)return n=this.context,i=t,void n.deleteBuffer(i.buffer||i)}catch(t){console.log(e),console.error(t)}var n,i;return e}},{key:"create2DTexture",value:function(){return lt(this.context)}},{key:"createImgTexture",value:function(t){return e=this.context,n=t,t=lt(e),e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,n),{texture:t};var e,n}},{key:"createDataTexture",value:function(t){return e=this.context,n=t,i=new Uint8Array(n.data||n),t=lt(e),e.texImage2D(e.TEXTURE_2D,0,e.RGBA,n.width||1,n.height||1,0,e.RGBA,e.UNSIGNED_BYTE,i),{texture:t};var e,n,i}},{key:"deleteTexture",value:function(t){try{return e=this.context,n=t.texture||t,e.deleteTexture(n)}catch(t){console.error(t)}var e,n;return t}},{key:"earCutPoints",value:function(t){return O(this.pointsToArray(t))}},{key:"earCutPointsToTriangles",value:function(t){this.earCutCache=this.earCutCache||(this.earCutCache={});var e=t.length,e=e+"_"+t[0].x+"_"+t[0].y+"_"+t[e-1].x+"_"+t[e-1].y;if(this.earCutCache[e])return this.earCutCache[e];for(var n=this.earCutPoints(t),i=[],r=0;r<n.length;r+=3){var o=t[n[r]],s=t[n[r+1]],a=t[n[r+2]];i.push([o,s,a])}return this.earCutCache[e]=i}},{key:"pointsToArray",value:function(t){var e;return(e=[]).concat.apply(e,x(t.map(function(t){return[t.x,t.y]})))}},{key:"arrayToPoints",value:function(t){for(var e=[],n=0;n<t.length;n+=2)e.push({x:t[n],y:t[n+1]});return e}},{key:"createLinearGradient",value:function(t,e,n,i,r){return new Q("linear",{x1:t,y1:e,x2:n,y2:i,bounds:r,control:this})}},{key:"createRadialGradient",value:function(t,e,n,i,r,o,s){return new Q("radial",{x1:t,y1:e,r1:n,x2:i,y2:r,r2:o,bounds:s,control:this})}},{key:"isGradient",value:function(t){return t&&t instanceof Q}},{key:"testSize",value:function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:this.style,n=this._measureCtx;if(!n)return{width:15,height:e.fontSize||15};n.save&&n.save(),(e.font||e.fontSize)&&(n.font=e.font||e.fontSize+"px "+e.fontFamily);t=n.measureText?n.measureText(t):{width:15};return n.restore&&n.restore(),t.height=e.fontSize?parseInt(e.fontSize):15,t}}]),n}(),dt=function(){u(i,ft);var n=v(i);function i(t,e){return h(this,i),(t=n.call(this,t,e)).isRegular=e.isRegular||!1,t.needCut=e.needCut||!1,t.control=e.control,t.points=[],t.__cachedBuffers=[],t.__cachedTexture=null,t.__cachedTextureKey=null,t}return l(i,[{key:"dispose",value:function(){var t,e=_(this.__cachedBuffers);try{for(e.s();!(t=e.n()).done;){var n=t.value;this.deleteBuffer(n)}}catch(t){e.e(t)}finally{e.f()}this.__cachedBuffers=[],this.__cachedTexture&&(this.deleteTexture(this.__cachedTexture),this.__cachedTexture=null,this.__cachedTextureKey=null)}},{key:"getOrCreateBuffer",value:function(t,e){var n=this.__cachedBuffers.find(function(t){return t.attr===e});if(n){var i=this.context,r=new Float32Array(t);return i.bindBuffer(i.ARRAY_BUFFER,n.buffer),i.bufferData(i.ARRAY_BUFFER,r,i.DYNAMIC_DRAW),n.data=t,n}return(n=this.createFloat32Buffer(t)).attr=e,this.__cachedBuffers.push(n),n}},{key:"applyTransform",value:function(t){return y(r(i.prototype),"applyTransform",this).call(this,t)}},{key:"setParentBounds",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:this.parentAbsoluteBounds;t&&(this.parentAbsoluteBounds=t);var e=this.graph.width/2,t=this.graph.height/2;this.__lastCenterX===e&&this.__lastCenterY===t||(this.context.uniform2f(this.program.uniforms.a_center_point.location,e,t),this.__lastCenterX=e,this.__lastCenterY=t)}},{key:"setFragColor",value:function(t){if(!Array.isArray(t))return void 0===(t=this.convertColor(t)).a&&(t.a=1),this.context.uniform4f(this.program.uniforms.v_single_color.location,t.r,t.g,t.b,t.a*this.style.globalAlpha),null;var e,n=[],i=_(t);try{for(i.s();!(e=i.n()).done;){var r=e.value;void 0===(r=this.convertColor(r)).a&&(r.a=1),n.push(r.r,r.g,r.b,r.a*this.style.globalAlpha)}}catch(t){i.e(t)}finally{i.f()}t=this.createFloat32Buffer(n);return this.writeVertexAttrib(t,this.program.attrs.a_color,4,0,0),t.attr=this.program.attrs.a_color,t}},{key:"beginDraw",value:function(){this.useProgram()}},{key:"draw",value:function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:this.parentAbsoluteBounds;this.setParentBounds(e),this.points=t}},{key:"endDraw",value:function(){this.points&&delete this.points,this.pathPoints&&delete this.pathPoints,this.needClose=!1}},{key:"closePath",value:function(){this.needClose=!0}},{key:"writePoints",value:function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:this.program.attrs.a_position,n=[],i=g(this.transformMatrix,6),r=i[0],o=i[1],s=i[2],a=i[3],h=i[4],i=i[5],l=this.parentAbsoluteBounds.left,u=this.parentAbsoluteBounds.top;if(1===r&&0===o&&0===s&&1===a&&0===h&&0===i)for(var c=0;c<t.length;c++)n.push(t[c].x+l,t[c].y+u);else{var f,d=_(t);try{for(d.s();!(f=d.n()).done;){var p=f.value,v=this.applyTransform(p);n.push(v.x+l,v.y+u)}}catch(t){d.e(t)}finally{d.f()}}a=new Float32Array(n),h=this.context;if(0<this.__cachedBuffers.length){i=this.__cachedBuffers.find(function(t){return t.attr===e});if(i)return h.bindBuffer(h.ARRAY_BUFFER,i.buffer),h.bufferData(h.ARRAY_BUFFER,a,h.DYNAMIC_DRAW),i.data=n,this.writeVertexAttrib(i,e,2,0,0),i}h=this.createFloat32Buffer(a,h.ARRAY_BUFFER,h.DYNAMIC_DRAW);return this.writeVertexAttrib(h,e,2,0,0),h.attr=e,this.__cachedBuffers.push(h),h}},{key:"genLinePoints",value:function(t,e){var n=[t],i=e.x-t.x,r=e.y-t.y;if(0!=i||0!=r)for(var o=Math.sqrt(Math.pow(i,2)+Math.pow(r,2)),s=i/o,a=r/o,h=.5;h<o;h+=.5){var l=t.x+s*h,u=t.y+a*h;n.push({x:l,y:u})}return n.push(e),n}},{key:"pathToPoints",value:function(){for(var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:this.points,e=null,n=[],i=0;i<t.length;i++){var r,o=t[i];e&&!o.m?(r=this.genLinePoints(e,o),n.push.apply(n,x(r))):e&&!n.includes(e)&&n.push(e),e=o}return n.includes(e)||n.push(e),n}},{key:"equalPoint",value:function(t,e){return t.x===e.x&&t.y===e.y}},{key:"splitSubPaths",value:function(t){for(var e=[],n=[],i=0;i<t.length;i++){var r=t[i];r.m&&0<n.length&&(e.push(n),n=[]),n.push(r)}0<n.length&&e.push(n);for(var o=-1,s=0,a=0;a<e.length;a++){var h=Math.abs(this.polygonArea(e[a]));o<h&&(o=h,s=a)}for(var l=e[s],u=[],c=0;c<e.length;c++)c!==s&&u.push(e[c]);return{outerPoints:l,holes:u}}},{key:"polygonArea",value:function(t){for(var e=0,n=t.length,i=0;i<n;i++){var r=(i+1)%n;e+=t[i].x*t[r].y,e-=t[r].x*t[i].y}return e/2}},{key:"fillWithHoles",value:function(t,e){var n,i=this,r=2<arguments.length&&void 0!==arguments[2]&&arguments[2],o=x(t),s=[],a=_(e);try{for(a.s();!(n=a.n()).done;){var h=n.value;s.push(o.length),o.push.apply(o,x(h))}}catch(t){a.e(t)}finally{a.f()}var l,u=[],c=_(o);try{for(c.s();!(l=c.n()).done;){var f=l.value;u.push(f.x,f.y)}}catch(t){c.e(t)}finally{c.f()}var d=O(u,s,2);if(d&&!(d.length<3)){for(var p=[],v=[],y=0;y<d.length;y++){var g=o[d[y]];p.push(g.x,g.y),r&&v.push(g.x,g.y)}var m=this.context,t=new Float32Array(p),e=this.__cachedBuffers.find(function(t){return t.attr===i.program.attrs.a_position});e?(m.bindBuffer(m.ARRAY_BUFFER,e.buffer),m.bufferData(m.ARRAY_BUFFER,t,m.DYNAMIC_DRAW)):((e=this.createFloat32Buffer(t,m.ARRAY_BUFFER,m.DYNAMIC_DRAW)).attr=this.program.attrs.a_position,this.__cachedBuffers.push(e)),this.writeVertexAttrib(e,this.program.attrs.a_position,2,0,0),r&&v.length&&(t=new Float32Array(v),(e=this.__cachedBuffers.find(function(t){return t.attr===i.program.attrs.a_text_coord}))?(m.bindBuffer(m.ARRAY_BUFFER,e.buffer),m.bufferData(m.ARRAY_BUFFER,t,m.DYNAMIC_DRAW)):((e=this.createFloat32Buffer(t,m.ARRAY_BUFFER,m.DYNAMIC_DRAW)).attr=this.program.attrs.a_text_coord,this.__cachedBuffers.push(e)),this.writeVertexAttrib(e,this.program.attrs.a_text_coord,2,0,0)),m.drawArrays(m.TRIANGLES,0,p.length/2)}}},{key:"pathToLines",value:function(t){for(var e=null,n=[],i=0;i<t.length;i++){var r=t[i];!e||r.m||e.x==r.x&&e.y==r.y||n.push({start:e,end:r}),e=r}return n}},{key:"cutLines",value:function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:0,n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:0;if(t&&t.length<3)return t;for(n=Math.max(e+1,n);e<t.length;){for(var i=t[e];n<t.length;){var r=t[n];if(this.equalPoint(i.start,r.start)||this.equalPoint(i.end,r.end)||this.equalPoint(i.start,r.end)||this.equalPoint(i.end,r.start))n++;else{var o,s,a=!1,h=this.getIntersection(i,r);if(h&&(this.equalPoint(i.start,h)||this.equalPoint(i.end,h)||(o={start:i.start,end:h},s={start:h,end:i.end},t.splice(e,1,o,s),a=!0,n++),this.equalPoint(r.start,h)||this.equalPoint(r.end,h)||(s={start:r.start,end:h},r={start:h,end:r.end},t.splice(n,1,s,r),n++)),n++,a)return this.cutLines(t,e,n)}}n=++e+1}return t}},{key:"getIntersection",value:function(t,e){if(this.equalPoint(t.start,e.start)||this.equalPoint(t.start,e.end))return t.start;if(this.equalPoint(t.end,e.start)||this.equalPoint(t.end,e.end))return t.end;var n=(t.start.x-e.start.x)*(t.end.y-e.start.y)-(t.start.y-e.start.y)*(t.end.x-e.start.x),i=(t.start.x-e.end.x)*(t.end.y-e.end.y)-(t.start.y-e.end.y)*(t.end.x-e.end.x);if(0<n*i)return null;e=(e.start.x-t.start.x)*(e.end.y-t.start.y)-(e.start.y-t.start.y)*(e.end.x-t.start.x);if(0<e*(e+n-i))return null;if(i==n)return null;i=e/(i-n),n=i*(t.end.x-t.start.x),i*=t.end.y-t.start.y;return{x:t.start.x+n,y:t.start.y+i}}},{key:"getIntersectionLines",value:function(t,e,n){var i=3<arguments.length&&void 0!==arguments[3]?arguments[3]:t.end,r=4<arguments.length&&void 0!==arguments[4]?arguments[4]:[],o=5<arguments.length&&void 0!==arguments[5]?arguments[5]:null,s={line:t,polygons:[]};if(r.push(i),o&&this.equalPoint(o.line.start,i))return r.unshift(o.line.start),o.polygons.push(r),s;for(;n<e.length;n++){var a=e[n];this.equalPoint(i,a.start)?r.includes(a.end)||this.getIntersectionLines(a,e,n+1,a.end,x(r),o||s):this.equalPoint(i,a.end)&&(r.includes(a.start)||this.getIntersectionLines(a,e,n+1,a.start,x(r),o||s))}return s}},{key:"getPolygon",value:function(t){var e=[];if((n=this.pathToLines(t))&&2<n.length)for(var n=this.cutLines(n),i=0;i<n.length-1;i++){var r=n[i],r=this.getIntersectionLines(r,n,i+1);r.polygons.length&&e.push.apply(e,x(r.polygons))}return e}},{key:"getTriangles",value:function(t){this.trianglesCache=this.trianglesCache||(this.trianglesCache={});var e=t.length,e=e+"_"+t[0].x+"_"+t[0].y+"_"+t[e-1].x+"_"+t[e-1].y;if(this.trianglesCache[e])return this.trianglesCache[e];var n=[],t=this.getPolygon(t);if(t.length){var i,r=_(t);try{for(r.s();!(i=r.n()).done;){var o=i.value,s=this.earCutPointsToTriangles(o);n.push.apply(n,x(s))}}catch(t){r.e(t)}finally{r.f()}}return this.trianglesCache[e]=n}},{key:"stroke",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:this.points,e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:this.style.strokeStyle,n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:this.style.lineWidth;if(t&&t.length){var i=null;if(e&&(i=this.setFragColor(e)),n&&this.context.uniform1f(this.program.uniforms.a_point_size.location,n),this.program.uniforms.a_type&&this.context.uniform1i(this.program.uniforms.a_type.location,1===t.length?4:1),t&&t.length){var r=n<=1.2,e=t.some&&t.some(function(t){return t.m}),n=!e&&this.needCut;if(r&&(e||n))if(e){for(var o=[],s=0;s<t.length;s++)t[s].m&&0<o.length&&(this.writePoints(o),this.context.drawArrays(this.context.LINE_LOOP,0,o.length),o=[]),o.push(t[s]);1<o.length&&(this.writePoints(o),this.context.drawArrays(this.context.LINE_LOOP,0,o.length))}else n&&(e=Math.floor(t.length/2),n=t.slice(0,e),e=t.slice(e),1<n.length&&(this.writePoints(n),this.context.drawArrays(this.context.LINE_LOOP,0,n.length)),1<e.length&&(this.writePoints(e),this.context.drawArrays(this.context.LINE_LOOP,0,e.length)));else t=r?t:this.pathToPoints(t),this.writePoints(t),this.context.drawArrays(r?this.context.LINE_LOOP:this.context.POINTS,0,t.length)}i&&this.disableVertexAttribArray(i&&i.attr)}}},{key:"fill",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{left:0,top:0,width:0,height:0},e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:1;this.points&&this.points.length&&(this.style.fillStyle&&this.fillColor(this.style.fillStyle,this.points,t,e),this.style.fillImage&&this.fillImage(this.style.fillImage,this.points,t,e))}},{key:"fillColor",value:function(t,e,n){var i=3<arguments.length&&void 0!==arguments[3]?arguments[3]:1;if(this.isGradient(t))return this.fillGradient(t,e,n);this.context.uniform1i(this.program.uniforms.a_type.location,i);t=this.setFragColor(t);this.fillPolygons(e),t&&this.disableVertexAttribArray(t&&t.attr)}},{key:"fillGradient",value:function(t,e,n){var i=t.toUniformParams();if(i){if(this.context.uniform1i(this.program.uniforms.a_type.location,5),this.context.uniform4f(this.program.uniforms.v_single_color.location,1,1,1,this.style.globalAlpha),this.program.uniforms.u_gradient_type&&this.context.uniform1i(this.program.uniforms.u_gradient_type.location,i.gradientType),this.program.uniforms.u_gradient_start&&this.context.uniform4fv(this.program.uniforms.u_gradient_start.location,i.gradientStart),this.program.uniforms.u_gradient_end&&this.context.uniform4fv(this.program.uniforms.u_gradient_end.location,i.gradientEnd),this.program.uniforms.u_gradient_stop_count&&this.context.uniform1i(this.program.uniforms.u_gradient_stop_count.location,i.stopCount),this.program.uniforms.u_gradient_offsets){for(var r=new Float32Array(16),o=0;o<i.stopCount;o++)r[o]=i.stops[5*o];for(var s=i.stopCount;s<16;s++)r[s]=2;this.context.uniform1fv(this.program.uniforms.u_gradient_offsets.location,r)}if(this.program.uniforms.u_gradient_colors){for(var a=new Float32Array(64),h=0;h<i.stopCount;h++)a[4*h+0]=i.stops[5*h+1],a[4*h+1]=i.stops[5*h+2],a[4*h+2]=i.stops[5*h+3],a[4*h+3]=i.stops[5*h+4];if(0<i.stopCount)for(var l=i.stops[5*(i.stopCount-1)+1],u=i.stops[5*(i.stopCount-1)+2],c=i.stops[5*(i.stopCount-1)+3],f=i.stops[5*(i.stopCount-1)+4],d=i.stopCount;d<16;d++)a[4*d+0]=l,a[4*d+1]=u,a[4*d+2]=c,a[4*d+3]=f;this.context.uniform4fv(this.program.uniforms.u_gradient_colors.location,a)}this.fillPolygons(e,!0),this.disableVertexAttribArray(this.program.attrs.a_text_coord)}}},{key:"fillImage",value:function(t,e,n){var i,r;t&&(i=null,t instanceof ImageData?(r="".concat(t.width,"_").concat(t.height,"_").concat(n.width,"_").concat(n.height,"_").concat(n.left,"_").concat(n.top),this.__cachedTexture&&this.__cachedTextureKey===r?i=this.__cachedTexture:(i=this.createDataTexture(t),this.__cachedTexture&&this.deleteTexture(this.__cachedTexture),this.__cachedTexture=i,this.__cachedTextureKey=r)):i=this.createImgTexture(t),this.context.uniform1i(this.program.uniforms.u_sample.location,0),this.context.uniform4f(this.program.uniforms.v_texture_bounds.location,n.left+this.parentAbsoluteBounds.left,n.top+this.parentAbsoluteBounds.top,n.width,n.height),this.fillTexture(e),t instanceof ImageData||this.deleteTexture(i))}},{key:"fillTexture",value:function(t){t&&t.length&&(this.context.uniform1i(this.program.uniforms.a_type.location,2),this.fillPolygons(t,!0),this.disableVertexAttribArray(this.program.attrs.a_text_coord))}},{key:"fillPolygons",value:function(t){var e=this,n=1<arguments.length&&void 0!==arguments[1]&&arguments[1];if(t.length<=3)return this.writePoints(t),n&&this.writePoints(t,this.program.attrs.a_text_coord),void this.context.drawArrays(this.context.TRIANGLE_FAN,0,t.length);if(this.isRegular){if(t.some&&t.some(function(t){return t.m})){var i=this.splitSubPaths(t),r=i.outerPoints,i=i.holes;return void this.fillWithHoles(r,i,n)}if(this.needCut&&6<=t.length){var o=Math.floor(t.length/2),s=t.slice(0,o),o=t.slice(o);return void(Math.abs(this.polygonArea(s))<=Math.abs(this.polygonArea(o))?this.fillWithHoles(o,[s],n):this.fillWithHoles(s,[o],n))}return this.writePoints(t),n&&this.writePoints(t,this.program.attrs.a_text_coord),void this.context.drawArrays(this.context.TRIANGLE_FAN,0,t.length)}s=this.needCut?this.earCutPointsToTriangles(t):this.getTriangles(t);if(s.length){var a,h=[],l=[],u=_(s);try{for(u.s();!(a=u.n()).done;){var c,f=_(a.value);try{for(f.s();!(c=f.n()).done;){var d=c.value;h.push(d.x,d.y),n&&l.push(d.x,d.y)}}catch(t){f.e(t)}finally{f.f()}}}catch(t){u.e(t)}finally{u.f()}o=new Float32Array(h),t=this.context,s=this.__cachedBuffers.find(function(t){return t.attr===e.program.attrs.a_position});s?(t.bindBuffer(t.ARRAY_BUFFER,s.buffer),t.bufferData(t.ARRAY_BUFFER,o,t.DYNAMIC_DRAW)):((s=this.createFloat32Buffer(o,t.ARRAY_BUFFER,t.DYNAMIC_DRAW)).attr=this.program.attrs.a_position,this.__cachedBuffers.push(s)),this.writeVertexAttrib(s,this.program.attrs.a_position,2,0,0),n&&l.length&&(o=new Float32Array(l),(s=this.__cachedBuffers.find(function(t){return t.attr===e.program.attrs.a_text_coord}))?(t.bindBuffer(t.ARRAY_BUFFER,s.buffer),t.bufferData(t.ARRAY_BUFFER,o,t.DYNAMIC_DRAW)):((s=this.createFloat32Buffer(o,t.ARRAY_BUFFER,t.DYNAMIC_DRAW)).attr=this.program.attrs.a_text_coord,this.__cachedBuffers.push(s)),this.writeVertexAttrib(s,this.program.attrs.a_text_coord,2,0,0)),t.drawArrays(t.TRIANGLES,0,h.length/2)}}},{key:"drawImage",value:function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:0,n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:0,i=3<arguments.length&&void 0!==arguments[3]?arguments[3]:t.width,r=4<arguments.length&&void 0!==arguments[4]?arguments[4]:t.height,i=i||t.width,r=r||t.height;this.fillImage(t,this.points,{left:e,top:n,width:i,height:r})}},{key:"drawText",value:function(t,e,n,i){if(!i.width||!i.height)return null;if("undefined"==typeof document)return null;var r=this.__textCanvas;r||(r=document.createElement("canvas"),this.__textCanvas=r),r.width=i.width,r.height=i.height;var o=r.getContext("2d",{willReadFrequently:!0});o.clearRect(0,0,r.width,r.height),o.font=this.style.font||this.style.fontSize+"px "+this.style.fontFamily,e-=i.left,n-=i.top,this.style.fillStyle&&(o.fillStyle=this.graph.utils.toColor(this.style.fillStyle)),this.style.strokeStyle&&(o.strokeStyle=this.graph.utils.toColor(this.style.strokeStyle)),this.style.shadowColor&&(o.shadowColor=this.graph.utils.toColor(this.style.shadowColor)),this.style.shadowBlur&&(o.shadowBlur=this.style.shadowBlur),void 0!==this.style.shadowOffsetX&&(o.shadowOffsetX=this.style.shadowOffsetX),void 0!==this.style.shadowOffsetY&&(o.shadowOffsetY=this.style.shadowOffsetY),this.style.textAlign&&(o.textAlign=this.style.textAlign),this.style.textBaseline&&(o.textBaseline=this.style.textBaseline),this.style.fillStyle&&o.fillText&&(this.style.maxWidth?o.fillText(t,e,n,this.style.maxWidth):o.fillText(t,e,n)),this.style.strokeStyle&&o.strokeText&&(this.style.maxWidth?o.strokeText(t,e,n,this.style.maxWidth):o.strokeText(t,e,n));r=o.getImageData(0,0,r.width,r.height);this.fillImage(r,this.points,i)}}]),i}(),pt={fill:"fillStyle",fillImage:"fillImage",stroke:"strokeStyle","shadow.blur":"shadowBlur","shadow.x":"shadowOffsetX","shadow.y":"shadowOffsetY","shadow.color":"shadowColor",lineWidth:"lineWidth",miterLimit:"miterLimit",fillStyle:"fillStyle",strokeStyle:"strokeStyle",font:"font",opacity:"globalAlpha",textAlign:"textAlign",textBaseline:"textBaseline",shadowBlur:"shadowBlur",shadowOffsetX:"shadowOffsetX",shadowOffsetY:"shadowOffsetY",shadowColor:"shadowColor",lineJoin:"lineJoin",lineCap:"lineCap",lineDashOffset:"lineDashOffset",globalCompositeOperation:"globalCompositeOperation"},vt=function(){u(r,P);var i=v(r);function r(t,e){var n;return h(this,r),(n=i.call(this,t=t||{})).property("type",e||(this instanceof r?this.constructor:void 0).name),n.style=t&&t.style?t.style:{},n.width=t.width||0,n.height=t.height||0,n.hitArea=t.hitArea||null,t.position&&(n.position=t.position),n.graph=t.graph||null,n.zIndex=t.zIndex||0,n.interactive=void 0!==t.interactive&&t.interactive,"webgl"===n.mode&&(n.webglControl=new dt(n.graph,{style:n.style,control:f(n),isRegular:t.isRegular,needCut:t.needCut})),n.initializing(),n.on=n.bind,n.option=t,n}return l(r,[{key:"type",get:function(){return this.property("type")}},{key:"context",get:function(){var t=this.property("context");if(t)return t;if(this.is("jmGraph")&&this.canvas&&this.canvas.getContext)return this.context=this.canvas.getContext(this.mode||"2d");t=this.graph;return t?t.context:t.canvas.getContext(this.mode||"2d")},set:function(t){return this.property("context",t)}},{key:"style",get:function(){return this.property("style")||this.property("style",{})},set:function(t){return this.needUpdate=!0,this.property("style",t)}},{key:"visible",get:function(){var t=this.property("visible");return t=void 0===t?this.property("visible",!0):t},set:function(t){return this.needUpdate=!0,this.property("visible",t)}},{key:"interactive",get:function(){return this.property("interactive")},set:function(t){return this.property("interactive",t)}},{key:"hitArea",get:function(){return this.property("hitArea")},set:function(t){return this.property("hitArea",t)}},{key:"children",get:function(){return this.property("children")||this.property("children",new w)},set:function(t){return this.needUpdate=!0,this.property("children",t)}},{key:"width",get:function(){var t=this.property("width");return t=void 0===t?this.property("width",0):t},set:function(t){return this.needUpdate=!0,this.property("width",t)}},{key:"height",get:function(){var t=this.property("height");return t=void 0===t?this.property("height",0):t},set:function(t){return this.needUpdate=!0,this.property("height",t)}},{key:"zIndex",get:function(){return this.property("zIndex")||this.property("zIndex",0)},set:function(t){return this.property("zIndex",t),this.children.sort(),this.needUpdate=!0,t}},{key:"cursor",get:function(){var t=this.graph;if(t)return t.css("cursor")},set:function(t){var e=this.graph;e&&e.css("cursor",t)}},{key:"initializing",value:function(){var e=this;this.children=this.children||new w;var n=this.children.add;this.children.add=function(t){if("object"===d(t))return t.parent&&t.parent!=e&&t.parent.children&&t.parent.children.remove(t),t.parent=e,this.contain(t)&&this.oremove(t),n.call(this,t),t.emit("add",t),e.needUpdate=!0,e.graph&&(t.graph=e.graph),this.sort(),t},this.children.oremove=this.children.remove,this.children.remove=function(t){"object"===d(t)&&(t.parent=null,t.graph=null,t.remove(!0),this.oremove(t),e.needUpdate=!0)},this.children.sort=function(){var t,i={};for(t in this.each(function(t,e){var n;e&&(!(n=e.zIndex)&&e.style&&e.style.zIndex&&(n=Number(e.style.zIndex),isNaN(n)&&(n=e.style.zIndex||0)),(i[n]||(i[n]=[])).push(e))}),this.splice(0,this.length),i)n.call(this,i[t])},this.children.clear=function(){this.each(function(t,e){this.remove(e)},!0)},this.needUpdate=!0}},{key:"setStyle",value:function(t){var u=this;if(t=t||this.style){var e,n,i=function t(e,n,i){if(e){var r=e;if("function"==typeof r)try{r=r.call(u)}catch(t){return void console.warn(t)}var o,s=d(r),i=pt[i||n];if(r instanceof R||"string"==s&&-1<r.indexOf("-gradient"))t((r="string"==s&&-1<r.indexOf("-gradient")?new R(r):r).toGradient(u),i||n);else if(i)u.webglControl?u.webglControl.setStyle(i,r):("string"==s&&-1<["fillStyle","strokeStyle","shadowColor"].indexOf(i)&&(r=A.toColor(r)),u.context[i]=r);else switch(n){case"shadow":if("string"==s){t(new S(r),n);break}for(var a in r)t(r[a],a,n+"."+a);break;case"translate":break;case"rotation":if(void 0===r.angle||isNaN(r.angle))break;r=u.getRotation(r),u.__translateAbsolutePosition=u.toAbsolutePoint({x:r.x,y:r.y}),u.context.translate&&u.context.translate(u.__translateAbsolutePosition.x,u.__translateAbsolutePosition.y),u.context.rotate&&u.context.rotate(r.angle),u.context.translate&&u.context.translate(-u.__translateAbsolutePosition.x,-u.__translateAbsolutePosition.y);break;case"transform":if(!u.context.transform)break;Array.isArray(r)?u.context.transform.apply(u.context,r):"object"==d(r)&&u.context.transform(r.scaleX||1,r.skewX||0,r.skewY||0,r.scaleY||1,r.offsetX||0,r.offsetY||0);break;case"cursor":u.cursor=r;break;case"lineDash":if(!u.context.setLineDash)break;"string"==typeof r?o=r.split(",").map(function(t){return parseFloat(t.trim())}).filter(function(t){return!isNaN(t)}):Array.isArray(r)&&(o=r.map(function(t){return parseFloat(t)}).filter(function(t){return!isNaN(t)})),o&&o.length?u.context.setLineDash(o):u.context.setLineDash([]);break;case"lineDashOffset":if(!u.context.setLineDash)break;u.context.lineDashOffset=Number(r)||0;break;case"filter":if(void 0===u.context.filter)break;r instanceof M?u.context.filter=r.toCanvasFilter():"string"==typeof r?u.context.filter=r||"none":"object"===d(r)&&(u.context.filter=new M(r).toCanvasFilter());break;case"globalCompositeOperation":if(!u.context.globalCompositeOperation)break;u.context.globalCompositeOperation=r;break;case"clipPath":if(!u.context.clip)break;if(r&&r.points&&0<r.points.length){var h=(u.parent&&u.parent.absoluteBounds?u.parent:u).absoluteBounds;u.context.beginPath(),u.context.moveTo(r.points[0].x+(h?h.left:0),r.points[0].y+(h?h.top:0));for(var l=1;l<r.points.length;l++)r.points[l].m?u.context.moveTo(r.points[l].x+(h?h.left:0),r.points[l].y+(h?h.top:0)):u.context.lineTo(r.points[l].x+(h?h.left:0),r.points[l].y+(h?h.top:0));r.style&&r.style.close&&u.context.closePath(),u.context.clip()}break;case"mask":if(!u.context.globalCompositeOperation)break;u.__mask=r;break;case"shadowColor":u.webglControl?u.webglControl.setStyle("shadowColor",r):u.context.shadowColor=A.toColor(r);break;case"shadowBlur":u.webglControl?u.webglControl.setStyle("shadowBlur",r):u.context.shadowBlur=Number(r)||0;break;case"shadowOffsetX":u.webglControl?u.webglControl.setStyle("shadowOffsetX",r):u.context.shadowOffsetX=Number(r)||0;break;case"shadowOffsetY":u.webglControl?u.webglControl.setStyle("shadowOffsetY",r):u.context.shadowOffsetY=Number(r)||0}}};for(e in this.translate&&i(this.translate,"translate"),this.transform&&i(this.transform,"transform"),t)"constructor"!==e&&("string"==(n=d(t[e]))&&-1<t[e].indexOf("-gradient")?t[e]=new R(t[e]):"string"==n&&"shadow"==e?t[e]=new S(t[e]):"string"==n&&"filter"==e&&(t[e]=new M(t[e])),i(t[e],e))}}},{key:"getBounds",value:function(t){if(this.bounds&&!t)return this.bounds;var e={};if("jmGraph"==this.type&&this.canvas)"function"==typeof this.canvas.width?e.right=this.canvas.width():this.width&&(e.right=this.width),"function"==typeof this.canvas.height?e.bottom=this.canvas.height():this.height&&(e.bottom=this.height);else if(this.points&&0<this.points.length){var n,i=_(this.points);try{for(i.s();!(n=i.n()).done;){var r=n.value;(void 0===e.left||e.left>r.x)&&(e.left=r.x),(void 0===e.top||e.top>r.y)&&(e.top=r.y),(void 0===e.right||e.right<r.x)&&(e.right=r.x),(void 0===e.bottom||e.bottom<r.y)&&(e.bottom=r.y)}}catch(t){i.e(t)}finally{i.f()}}else!this.getLocation||(t=this.getLocation())&&(e.left=t.left,e.top=t.top,e.right=t.left+t.width,e.bottom=t.top+t.height);return void 0===e.left&&(e.left=0),void 0===e.top&&(e.top=0),void 0===e.right&&(e.right=0),void 0===e.bottom&&(e.bottom=0),e.width=e.right-e.left,e.height=e.bottom-e.top,this.bounds=e}},{key:"getRotationBounds",value:function(){var t=(t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:null)||this.getRotation(),e=this.getBounds();if(!t||!t.angle)return e;var n,i={width:0,height:0,oldBounds:e},r=[];this.points&&0<this.points.length?r=A.clone(this.points,!0):!this.getLocation||(n=this.getLocation())&&r.push({x:n.left,y:n.top},{x:n.left+n.width,y:n.top},{x:n.left+n.width,y:n.top+n.height},{x:n.left,y:n.top+n.height});var o,s=_(r=A.rotatePoints(r,{x:t.x+e.left,y:t.y+e.top},t.angle));try{for(s.s();!(o=s.n()).done;){var a=o.value;(void 0===i.left||i.left>a.x)&&(i.left=a.x),(void 0===i.top||i.top>a.y)&&(i.top=a.y),(void 0===i.right||i.right<a.x)&&(i.right=a.x),(void 0===i.bottom||i.bottom<a.y)&&(i.bottom=a.y)}}catch(t){s.e(t)}finally{s.f()}return i.left||(i.left=0),i.top||(i.top=0),i.right||(i.right=0),i.bottom||(i.bottom=0),i.width=i.right-i.left,i.height=i.bottom-i.top,i}},{key:"getLocation",value:function(){var t=this.location={left:0,top:0,width:0,height:0},e=this.parent&&(A.checkPercent(this.width)||A.checkPercent(this.height)||this.position&&A.checkPercent(this.position.x)||this.position&&A.checkPercent(this.position.y));t.position="function"==typeof this.position?this.position():e?A.clone(this.position):this.position,t.center=this.center&&"function"==typeof this.center?this.center():e?A.clone(this.center):this.center,t.start=this.start&&"function"==typeof this.start?this.start():e?A.clone(this.start):this.start,t.end=this.end&&"function"==typeof this.end?this.end():e?A.clone(this.end):this.end,t.radius=this.radius,t.width=this.width,t.height=this.height;var n=this.style.margin,n=e&&n?A.clone(n,{}):n||{};return n.left=n.left||0,n.top=n.top||0,n.right=n.right||0,n.bottom=n.bottom||0,t.position?(t.left=t.position.x,t.top=t.position.y):(t.left=n.left,t.top=n.top),this.parent&&(n=this.parent.getBounds(),A.checkPercent(t.left)&&(t.left=A.percentToNumber(t.left)*n.width),A.checkPercent(t.top)&&(t.top=A.percentToNumber(t.top)*n.height),A.checkPercent(t.width)&&(t.width=A.percentToNumber(t.width)*n.width),A.checkPercent(t.height)&&(t.height=A.percentToNumber(t.height)*n.height),t.center&&(A.checkPercent(t.center.x)&&(t.center.x=A.percentToNumber(t.center.x)*n.width),A.checkPercent(t.center.y)&&(t.center.y=A.percentToNumber(t.center.y)*n.height)),t.radius&&A.checkPercent(t.radius)&&(t.radius=A.percentToNumber(t.radius)*Math.min(n.width,n.height))),t}},{key:"getRotation",value:function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:null;return(t=t||A.clone(this.style.rotation))?(e=e||this.getBounds(),void 0===t.x&&(t.x="50%"),void 0===t.y&&(t.y="50%"),A.checkPercent(t.x)&&(t.x=A.percentToNumber(t.x)*e.width),A.checkPercent(t.y)&&(t.y=A.percentToNumber(t.y)*e.height)):(t=this.parent&&this.parent.getRotation?this.parent.getRotation():null)&&(e=e||this.getBounds(),t.x-=e.left,t.y-=e.top),s(s({},t),{},{bounds:e})}},{key:"getTranslate",value:function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:null;if(!(t=t||this.style.translate))return{x:0,y:0};t={x:t.x||0,y:t.y||0};return A.checkPercent(t.x)&&(!e&&this.parent&&(e=this.parent.getBounds()),t.x=A.percentToNumber(t.x)*e.width),A.checkPercent(t.y)&&(!e&&this.parent&&(e=this.parent.getBounds()),t.y=A.percentToNumber(t.y)*e.height),t}},{key:"remove",value:function(){this.parent&&this.parent.children.remove(this)}},{key:"offset",value:function(t,e,n,i){n=!1!==n;var r=this.getLocation(!0),o=!1;if(r.position&&(r.left+=t,r.top+=e,this.position.x=r.left,this.position.y=r.top,o=!0),r.center&&(this.center.x=r.center.x+t,this.center.y=r.center.y+e,o=!0),r.start&&"object"==d(r.start)&&(this.start.x=r.start.x+t,this.start.y=r.start.y+e,o=!0),r.end&&"object"==d(r.end)&&(this.end.x=r.end.x+t,this.end.y=r.end.y+e,o=!0),0==o&&this.cpoints){var s=(this.cpoints,this.cpoints);if(s){for(var a=s.length,h=0;h<a;h++)s[h].x+=t,s[h].y+=e;o=!0}}if(0==o&&this.points){for(var l=this.points.length,u=0;u<l;u++)this.points[u].x+=t,this.points[u].y+=e;o=!0}this.emit("move",{offsetX:t,offsetY:e,trans:n,evt:i}),this.needUpdate=!0}},{key:"getAbsoluteBounds",value:function(){var t=this.getBounds();if(this.parent&&this.parent.absoluteBounds){var e=this.parent.absoluteBounds||this.parent.getAbsoluteBounds();return{left:e.left+t.left,top:e.top+t.top,right:e.left+t.right,bottom:e.top+t.bottom,width:t.width,height:t.height}}return t}},{key:"toAbsolutePoint",value:function(t){var e;return(t.x||t.y)&&(e=this.absoluteBounds||this.getAbsoluteBounds(),t.x=(t.x||0)+e.left,t.y=(t.y||0)+e.top),t}},{key:"toLocalPosition",value:function(t){var e=this.absoluteBounds||this.getAbsoluteBounds();return!!e&&{x:t.x-e.left,y:t.y-e.top}}},{key:"beginDraw",value:function(){this.getLocation(!0),this.context.beginPath&&this.context.beginPath(),this.webglControl&&this.webglControl.beginDraw&&this.webglControl.beginDraw()}},{key:"endDraw",value:function(){var t,e;this.style.close&&(this.webglControl&&this.webglControl.closePath(),this.context.closePath&&this.context.closePath()),this.webglControl?((e=this.style.fill||this.style.fillStyle)&&(t=this.getBounds(),this.webglControl.fill(t)),!this.style.stroke&&(e||this.is("jmGraph"))||this.webglControl.stroke(),this.webglControl.endDraw&&this.webglControl.endDraw()):((e=this.style.fill||this.style.fillStyle)&&this.context.fill&&this.context.fill(),(this.style.stroke||!e&&!this.is("jmGraph"))&&this.context.stroke&&this.context.stroke()),this.needUpdate=!1}},{key:"draw",value:function(){if(this.points&&0<this.points.length){var t=(this.parent&&this.parent.absoluteBounds?this.parent:this).absoluteBounds;if(this.webglControl)this.webglControl.setParentBounds(t),this.webglControl.draw(this.points);else if(this.context&&this.context.moveTo){this.context.moveTo(this.points[0].x+t.left,this.points[0].y+t.top);for(var e=this.points.length,n=1;n<e;n++){var i=this.points[n];i.m?this.context.moveTo(i.x+t.left,i.y+t.top):this.context.lineTo(i.x+t.left,i.y+t.top)}}}}},{key:"paint",value:function(t){if(!1!==t&&!1!==this.visible){this.initPoints&&this.initPoints(),this.bounds=null,this.absoluteBounds=this.getAbsoluteBounds();t=!0;!this.is("jmGraph")&&this.graph&&(this.absoluteBounds.left>=this.graph.width||this.absoluteBounds.top>=this.graph.height||this.absoluteBounds.right<=0||this.absoluteBounds.bottom<=0)&&(t=!1),this.context.save&&this.context.save(),this.emit("beginDraw",this),this.setStyle();var e=this.style.mask||this.__mask;if(e&&e.points&&this.context.globalCompositeOperation){t&&this.beginDraw&&this.beginDraw(),t&&this.draw&&this.draw(),t&&this.endDraw&&this.endDraw(),this.context.globalCompositeOperation="destination-in",e.initPoints&&e.initPoints();var n=(e.parent&&e.parent.absoluteBounds?e.parent:this).absoluteBounds;if(this.context.beginPath(),e.points&&0<e.points.length){this.context.moveTo(e.points[0].x+(n?n.left:0),e.points[0].y+(n?n.top:0));for(var i=1;i<e.points.length;i++)e.points[i].m?this.context.moveTo(e.points[i].x+(n?n.left:0),e.points[i].y+(n?n.top:0)):this.context.lineTo(e.points[i].x+(n?n.left:0),e.points[i].y+(n?n.top:0));e.style&&e.style.close&&this.context.closePath()}this.context.fillStyle="#ffffff",this.context.fill(),this.context.globalCompositeOperation="source-over"}else t&&this.beginDraw&&this.beginDraw(),t&&this.draw&&this.draw(),t&&this.endDraw&&this.endDraw();this.children&&this.children.each(function(t,e){e&&e.paint&&e.paint()}),this.emit("endDraw",this),this.context.restore&&this.context.restore(),this.needUpdate=!1}}},{key:"getEvent",value:function(t){return this.__events?this.__events[t]:null}},{key:"bind",value:function(t,e){if(t&&-1<t.indexOf(" ")){var n,i=_(t=t.split(" "));try{for(i.s();!(n=i.n()).done;){var r=n.value;r&&this.bind(r,e)}}catch(t){i.e(t)}finally{i.f()}}else{t=this.getEvent(t)||function(t,e){return this.__events||(this.__events={}),this.__events[t]=e}.call(this,t,new w);t.contain(e)||t.add(e)}}},{key:"unbind",value:function(t,e){if(t&&-1<t.indexOf(" ")){var n,i=_(t=t.split(" "));try{for(i.s();!(n=i.n()).done;){var r=n.value;r&&this.unbind(r,e)}}catch(t){i.e(t)}finally{i.f()}}else{t=this.getEvent(t);t&&(e?t.remove(e):t.clear())}}},{key:"emit",value:function(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];return 2<e.length?this.runEventHandle(e[0],e.slice(1)):2===e.length?this.runEventHandle(e[0],[e[1]]):this.runEventHandle(e[0],[]),this}},{key:"runEventHandle",value:function(t,n){var i,e=this.getEvent(t);return e&&("mousemove"===t&&"jmResize"==this.type&&console.log("resize mousemove",n,e),i=this,Array.isArray(n)||(n=[n]),e.each(function(t,e){!1===e.apply(i,n)&&(n.cancel=!0)})),n.cancel}},{key:"checkPoint",value:function(t,e){if("jmGraph"==this.type){var n=this.getPosition();return t.pageX>n.right||t.pageX<n.left?!1:!(t.pageY>n.bottom||t.pageY<n.top)}var i=this.getBounds();if(this.hitArea){var r=this.hitArea.x+i.left,o=this.hitArea.y+i.top,s=this.hitArea.width+i.left,n=this.hitArea.height+i.top;return t.x>s||t.x<r?!1:!(t.y>n||t.y<o)}var a=this.points;if(a&&a.length||((a=[]).push({x:i.left,y:i.top}),a.push({x:i.right,y:i.top}),a.push({x:i.right,y:i.bottom}),a.push({x:i.left,y:i.bottom}),a.push({x:i.left,y:i.top})),e=Number(e||this.style.touchPadding||this.style.lineWidth||1),a&&a.length){o=this.getRotation(null,i);if(o&&o.angle&&(a=A.clone(a,!0),a=A.rotatePoints(a,{x:o.x+i.left,y:o.y+i.top},o.angle||0)),2<a.length&&(!this.style.fill||this.style.stroke)){for(var h=0,l=a.length,u=h+1;u<=l;u=++h+1)if(u==l){if(this.style.close)if(A.pointInPolygon(t,[a[h],a[0]],e))return!0}else if(A.pointInPolygon(t,[a[h],a[u]],e))return!0;if(!this.style.fill)return!1}return A.pointInPolygon(t,a,e)}return!(t.x>i.right||t.x<i.left)&&!(t.y>i.bottom||t.y<i.top)}},{key:"raiseEvent",value:function(n,i){if(!1!==this.visible){var t;i.position||(o=this.graph,i.isWXMiniApp=o.isWXMiniApp,e=i.srcElement||i.target,t=A.getEventPosition(i),i={position:t,button:0==i.button||t.isTouch?1:i.button,keyCode:i.keyCode||i.charCode||i.which,ctrlKey:i.ctrlKey,cancel:!1,event:i,srcElement:e,isWXMiniApp:o.isWXMiniApp}),i.path=i.path||[];var r=!1;if(this.children&&this.children.each(function(t,e){if(!0!==i.cancel&&(r=!1===e.raiseEvent(n,i)||r))return!1},!0),r)return!1;var e=(this.parent&&this.parent.absoluteBounds?this.parent:this).absoluteBounds;if(!e)return!1;i.position.x=i.position.offsetX-e.left,i.position.y=i.position.offsetY-e.top;var o=!1!==this.interactive&&this.checkPoint(i.position);return"mousemove"!==n||"jmGraph"!=this.type||o||console.log("mousemove out",i.position,e),o?(i.target||(i.target=this),this.runEventAndPopEvent(n,i),this.focused||"mousemove"!==n&&"touchmove"!==n||(this.focused=!0,this.raiseEvent("mousemove"===n?"mouseover":"touchover",i))):!1===this.interactive||o||!this.focused||"mousemove"!==n&&"touchmove"!==n||(this.focused=!1,this.runEventHandle("mousemove"===n?"mouseleave":"touchleave",i)),!1===i.cancel}}},{key:"runEventAndPopEvent",value:function(t,e){!0!==e.cancel&&(e.path.push(this),this.runEventHandle(t,e))}},{key:"clearEvents",value:function(t){t=this.getEvent(t);t&&t.clear()}},{key:"findParent",value:function(t){if("string"==typeof t){if(this.type==t)return this}else if(this.is(t))return this;return this.parent?this.parent.findParent(t):null}},{key:"canMove",value:function(t,e){var o;return this.__mvMonitor||(this.__mvMonitor={},this.__mvMonitor.mouseDown=!1,this.__mvMonitor.curposition={x:0,y:0},(o=this).__mvMonitor.mv=function(t){var e=o;if(e.__mvMonitor.mouseDown){e.parent.bounds=null;var n,i=t.position.offsetX-e.__mvMonitor.curposition.x,r=t.position.offsetY-e.__mvMonitor.curposition.y;return e.option.lockSide&&(n=e.bounds||e.getAbsoluteBounds(),((n=A.checkOutSide(e.option.lockSide,n,{x:i,y:r})).left<0&&i<0||0<n.right&&0<i)&&(i=0),(n.top<0&&r<0||0<n.bottom&&0<r)&&(r=0)),(i||r)&&(e.offset(i,r,!0,t),i&&(e.__mvMonitor.curposition.x=t.position.offsetX),r&&(e.__mvMonitor.curposition.y=t.position.offsetY)),!1}},this.__mvMonitor.mu=function(t){var e=o;e.__mvMonitor.mouseDown&&(e.__mvMonitor.mouseDown=!1,e.emit("moveend",{position:e.__mvMonitor.curposition}))},this.__mvMonitor.ml=function(){var t=o;if(t.__mvMonitor.mouseDown)return t.__mvMonitor.mouseDown=!1,t.emit("moveend",{position:t.__mvMonitor.curposition}),!1},this.__mvMonitor.md=function(t){if(!this.__mvMonitor.mouseDown)return 0==t.button||1==t.button?(this.__mvMonitor.mouseDown=!0,this.__mvMonitor.curposition.x=t.position.offsetX,this.__mvMonitor.curposition.y=t.position.offsetY,this.emit("movestart",{position:this.__mvMonitor.curposition}),!(t.cancel=!0)):void 0}),e=e||this.graph,!1!==t?(e.bind("mousemove",this.__mvMonitor.mv),e.bind("mouseup",this.__mvMonitor.mu),e.bind("mouseleave",this.__mvMonitor.ml),this.bind("mousedown",this.__mvMonitor.md),e.bind("touchmove",this.__mvMonitor.mv),e.bind("touchend",this.__mvMonitor.mu),this.bind("touchstart",this.__mvMonitor.md)):(e.unbind("mousemove",this.__mvMonitor.mv),e.unbind("mouseup",this.__mvMonitor.mu),e.unbind("mouseleave",this.__mvMonitor.ml),this.unbind("mousedown",this.__mvMonitor.md),e.unbind("touchmove",this.__mvMonitor.mv),e.unbind("touchend",this.__mvMonitor.mu),this.unbind("touchstart",this.__mvMonitor.md)),this.interactive=!0,this}}]),r}(),yt=function(){u(i,vt);var n=v(i);function i(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:"jmPath";return h(this,i),(e=n.call(this,t,e)).points=t&&t.points?t.points:[],e}return l(i,[{key:"points",get:function(){return this.property("points")},set:function(t){return this.needUpdate=!0,this.property("points",t)}},{key:"toSVG",value:function(){if(!this.points||0===this.points.length)return"";var t="",e=this.points;t+="M ".concat(e[0].x," ").concat(e[0].y);for(var n=1;n<e.length;n++){var i=e[n];i.m?t+=" M ".concat(i.x," ").concat(i.y):t+=" L ".concat(i.x," ").concat(i.y)}this.style&&this.style.close&&(t+=" Z");var r='<path d="'+t+'"';return this.style&&(this.style.fill&&(r+=' fill="'+this.style.fill+'"'),this.style.stroke&&(r+=' stroke="'+this.style.stroke+'"'),this.style.lineWidth&&(r+=' stroke-width="'+this.style.lineWidth+'"'),this.style.opacity&&(r+=' opacity="'+this.style.opacity+'"')),r+="/>"}}]),i}(),gt=function(){u(o,vt);var r=v(o);function o(t,e,n){var i;return h(this,o),"function"==typeof e&&(n=e,e={}),(e=e||{}).interactive=!0,e.isRegular=!0,(i=r.call(this,e,"jmGraph")).option=e||{},i.devicePixelRatio=1,i.util=i.utils=A,i.mode=e.mode||"2d",i.scaleFactor=1,i.translation={x:0,y:0},"undefined"!=typeof wx&&wx.canIUse&&wx.canIUse("canvas")?("string"==typeof t&&(t=wx.createSelectorQuery().select("#"+t)),i.isWXMiniApp=!0,i.container=t):("string"==typeof t&&"undefined"!=typeof document?t=document.getElementById(t):t.length&&(t=t[0]),t.getContext||"undefined"==typeof document?i.container=t.parentElement:(i.container=t,e=document.createElement("canvas"),t.appendChild(e),e.width=t.offsetWidth||t.clientWidth,e.height=t.offsetHeight||t.clientHeight,t=e)),i.canvas=t,"webgl"===i.mode?i.context=t.getContext(i.mode,{preserveDrawingBuffer:!0}):i.context=t.getContext(i.mode),"webgl"===i.mode&&(i.context.enable(i.context.BLEND),i.context.blendFunc(i.context.SRC_ALPHA,i.context.ONE_MINUS_SRC_ALPHA),A.bindEvent(t,"webglcontextlost",function(t){console.log("canvas webglcontextlost",t),i.emit("webglcontextlost",t)}),A.bindEvent(t,"webglcontextrestored",function(t){console.log("canvas webglcontextrestored",t),i.emit("webglcontextrestored",t)})),i.__init(n),i}return l(o,[{key:"__init",value:function(t){this.shapes=Object.assign({path:yt},this.option.shapes),this.on("beginDraw",function(){this.context.translate&&this.context.translate(.5,.5),this.context.translate&&this.context.scale&&(this.context.translate(this.translation.x,this.translation.y),this.context.scale(this.scaleFactor,this.scaleFactor))}),this.on("endDraw",function(){this.context.translate&&this.context.translate(-.5,-.5),this.context.translate&&this.context.scale&&(this.context.scale(1/this.scaleFactor,1/this.scaleFactor),this.context.translate(-this.translation.x,-this.translation.y))});var e="undefined"!=typeof window&&1<window.devicePixelRatio?window.devicePixelRatio:1;this.isWXMiniApp&&(e=wx.getWindowInfo().pixelRatio||1),this.devicePixelRatio=e,this.dprScaleSize=1<this.devicePixelRatio?this.devicePixelRatio:2,0<this.option.width&&(this.width=this.option.width),0<this.option.height&&(this.height=this.option.height),this.resize(),this.eventHandler=new N(this,this.canvas.canvas||this.canvas),this.option.autoRefresh&&this.autoRefresh(),t&&t(this)}},{key:"resize",value:function(t,e){this.canvas&&(this.__normalSize=this.__normalSize||{width:0,height:0},t=t||this.__normalSize.width||this.width,e=e||this.__normalSize.height||this.height,t&&(this.__normalSize.width=t),e&&(this.__normalSize.height=e),this.css("width",t+"px"),this.css("height",e+"px"),"2d"===this.mode?(this.canvas.height=e*this.dprScaleSize,this.canvas.width=t*this.dprScaleSize,1!==this.dprScaleSize&&this.context.scale&&this.context.scale(this.dprScaleSize,this.dprScaleSize)):(this.canvas.width=t,this.canvas.height=e),this.context.viewport&&this.context.viewport(0,0,t,e),this.needUpdate=!0)}},{key:"width",get:function(){return this.__normalSize&&this.__normalSize.width?this.__normalSize.width:this.canvas?this.canvas.width:0},set:function(t){return this.needUpdate=!0,this.canvas&&this.resize(t),t}},{key:"height",get:function(){return this.__normalSize&&this.__normalSize.height?this.__normalSize.height:this.canvas?this.canvas.height:0},set:function(t){return this.needUpdate=!0,this.canvas&&this.resize(0,t),t}},{key:"getPosition",value:function(){var t=this.isWXMiniApp?{left:0,top:0}:A.getElementPosition(this.canvas.canvas||this.canvas);return t.width=this.width,t.height=this.height,t.right=t.left+t.width,t.bottom=t.top+t.height,t}},{key:"registerShape",value:function(t,e){this.shapes[t]=e}},{key:"createShape",value:function(t,e){if(t="string"==typeof t?this.shapes[t]:t)return(e=e||{}).graph=this,new t(e)}},{key:"createShadow",value:function(t,e,n,i){return new S(t,e,n,i)}},{key:"createLinearGradient",value:function(t,e,n,i){return new R({type:"linear",x1:t,y1:e,x2:n,y2:i,stops:4<arguments.length&&void 0!==arguments[4]?arguments[4]:[]})}},{key:"createRadialGradient",value:function(t,e,n,i,r,o){return new R({type:"radial",x1:t,y1:e,r1:n,x2:i,y2:r,r2:o,stops:6<arguments.length&&void 0!==arguments[6]?arguments[6]:[]})}},{key:"refresh",value:function(){this.redraw()}},{key:"redraw",value:function(t,e){this.clear(t||this.width,e||this.height),this.paint()}},{key:"clear",value:function(t,e){t&&e||(t=this.width,e=this.height),this.context.clearRect?(this.style&&this.style.fill&&(this.points=[{x:0,y:0},{x:t,y:0},{x:t,y:e},{x:0,y:e}],this.style.close=!0),this.context.clearRect(0,0,t,e)):"webgl"===this.mode&&this.context.clear&&(this.style&&this.style.fill?(e=this.utils.hexToRGBA(this.style.fill),this.__lastClearColor=e,this.context.clearColor(e.r,e.g,e.b,e.a)):this.__lastClearColor?this.context.clearColor(this.__lastClearColor.r,this.__lastClearColor.g,this.__lastClearColor.b,this.__lastClearColor.a):(this.__lastClearColor={r:0,g:0,b:0,a:0},this.context.clearColor(0,0,0,0)),this.context.clear(this.context.COLOR_BUFFER_BIT))}},{key:"css",value:function(t,e){if(this.canvas&&this.canvas.style)return void 0!==e&&(this.canvas.style[t]=e),this.canvas.style[t]}},{key:"createPath",value:function(t,e){return this.createShape("path",s({points:t,style:e},2<arguments.length&&void 0!==arguments[2]?arguments[2]:{}))}},{key:"createLine",value:function(t,e,n){return this.createShape("line",{start:t,end:e,style:n})}},{key:"zoomOut",value:function(){this.scale(.9,.9)}},{key:"zoomIn",value:function(){this.scale(1.1,1.1)}},{key:"zoomActual",value:function(){this.scaleSize?this.scale(1/this.scaleSize.x,1/this.scaleSize.y):this.scale(1,1)}},{key:"scale",value:function(t,e){this.normalSize||(this.normalSize={width:this.canvas.width,height:this.canvas.height}),this.scaleSize?this.scaleSize={x:t*this.scaleSize.x,y:e*this.scaleSize.y}:this.scaleSize={x:1,y:1},this.canvas.style&&(this.canvas.style.transform="scale(".concat(this.scaleSize.x,", ").concat(this.scaleSize.y,")"))}},{key:"setZoom",value:function(t,e,n){if("number"!=typeof t||isNaN(t))return console.warn("jmGraph: setZoom - 无效的缩放因子"),this;var i,r;return t=Math.max(.1,Math.min(10,t)),void 0!==e&&void 0!==n&&(i=this.scaleFactor,r=t,this.translation.x=e-(e-this.translation.x)*(r/i),this.translation.y=n-(n-this.translation.y)*(r/i)),this.scaleFactor=t,this.needUpdate=!0,this.redraw(),this}},{key:"pan",value:function(t,e){return"number"!=typeof t||"number"!=typeof e||isNaN(t)||isNaN(e)?console.warn("jmGraph: pan - 无效的平移参数"):(this.translation.x+=t,this.translation.y+=e,this.needUpdate=!0,this.redraw()),this}},{key:"resetTransform",value:function(){return this.scaleFactor=1,this.translation={x:0,y:0},this.needUpdate=!0,this.redraw(),this}},{key:"toDataURL",value:function(){return this.canvas.toDataURL?this.canvas.toDataURL():""}},{key:"exportToPNG",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:"jmgraph-export",e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:"image/png",n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:.9;try{this.redraw();var i=this.canvas.toDataURL(e,n);this.downloadFile(i,t,"png")}catch(t){console.error("jmGraph: exportToPNG - 导出失败",t)}}},{key:"exportToJPEG",value:function(){this.exportToPNG(0<arguments.length&&void 0!==arguments[0]?arguments[0]:"jmgraph-export","image/jpeg",1<arguments.length&&void 0!==arguments[1]?arguments[1]:.9)}},{key:"exportToSVG",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:"jmgraph-export";try{var e=this.toSVG(),n=new Blob([e],{type:"image/svg+xml;charset=utf-8"}),i=URL.createObjectURL(n);this.downloadFile(i,t,"svg"),setTimeout(function(){return URL.revokeObjectURL(i)},100)}catch(t){console.error("jmGraph: exportToSVG - 导出失败",t)}}},{key:"toSVG",value:function(){var n='<svg width="'.concat(this.width,'" height="').concat(this.height,'" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ').concat(this.width," ").concat(this.height,'">');return this.style&&this.style.fill&&(n+='<rect width="100%" height="100%" fill="'.concat(this.style.fill,'"/>')),this.children.each(function(t,e){e.toSVG&&(n+=e.toSVG())}),n+="</svg>"}},{key:"downloadFile",value:function(t,e,n){var i=document.createElement("a");i.href=t,i.download="".concat(e,".").concat(n),document.body.appendChild(i),i.click(),document.body.removeChild(i)}},{key:"autoRefresh",value:function(n){if(!this.___isAutoRefreshing){var i=this;this.___isAutoRefreshing=!0;var r=Date.now();return i.__requestAnimationFrameFunHandler&&this.cancelAnimationFrame(i.__requestAnimationFrameFunHandler),i.__requestAnimationFrameFunHandler=this.requestAnimationFrame(function t(){var e;i.destroyed?i.___isAutoRefreshing=!1:(i.needUpdate&&i.redraw(),e=Date.now()-r,i.emit("update",e),i.__requestAnimationFrameFunHandler=i.requestAnimationFrame(t),n&&n())}),this}}},{key:"destroy",value:function(){this.eventHandler.destroy(),this.destroyed=!0}}],[{key:"create",value:function(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];return c(o,e)}}]),o}();t.default=gt,t.jmControl=vt,t.jmEvents=N,t.jmFilter=M,t.jmGradient=R,t.jmGraph=gt,t.jmList=w,t.jmPath=yt,t.jmProperty=P,t.jmShadow=S,t.jmUtils=A,Object.defineProperty(t,"__esModule",{value:!0})});
|
|
1
|
+
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).jmGraph={})}(this,function(t){"use strict";function e(e,t){var n,i=Object.keys(e);return Object.getOwnPropertySymbols&&(n=Object.getOwnPropertySymbols(e),t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),i.push.apply(i,n)),i}function s(i){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?e(Object(r),!0).forEach(function(t){var e,n;e=i,t=r[n=t],n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t}):Object.getOwnPropertyDescriptors?Object.defineProperties(i,Object.getOwnPropertyDescriptors(r)):e(Object(r)).forEach(function(t){Object.defineProperty(i,t,Object.getOwnPropertyDescriptor(r,t))})}return i}function d(t){return(d="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function h(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function i(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}function l(t,e,n){return e&&i(t.prototype,e),n&&i(t,n),t}function u(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&o(t,e)}function r(t){return(r=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function o(t,e){return(o=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function a(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(t){return!1}}function c(t,e,n){return(c=a()?Reflect.construct:function(t,e,n){var i=[null];i.push.apply(i,e);i=new(Function.bind.apply(t,i));return n&&o(i,n.prototype),i}).apply(null,arguments)}function n(t){var n="function"==typeof Map?new Map:void 0;return function(t){if(null===t||-1===Function.toString.call(t).indexOf("[native code]"))return t;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==n){if(n.has(t))return n.get(t);n.set(t,e)}function e(){return c(t,arguments,r(this).constructor)}return e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),o(e,t)}(t)}function f(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function p(t,e){return!e||"object"!=typeof e&&"function"!=typeof e?f(t):e}function v(n){var i=a();return function(){var t,e=r(n);return p(this,i?(t=r(this).constructor,Reflect.construct(e,arguments,t)):e.apply(this,arguments))}}function y(t,e,n){return(y="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(t,e,n){t=function(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=r(t)););return t}(t,e);if(t){e=Object.getOwnPropertyDescriptor(t,e);return e.get?e.get.call(n):e.value}})(t,e,n||t)}function g(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var i,r,o=[],s=!0,a=!1;try{for(n=n.call(t);!(s=(i=n.next()).done)&&(o.push(i.value),!e||o.length!==e);s=!0);}catch(t){a=!0,r=t}finally{try{s||null==n.return||n.return()}finally{if(a)throw r}}return o}}(t,e)||m(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function x(t){return function(t){if(Array.isArray(t))return b(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||m(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function m(t,e){if(t){if("string"==typeof t)return b(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return"Map"===(n="Object"===n&&t.constructor?t.constructor.name:n)||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?b(t,e):void 0}}function b(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,i=new Array(e);n<e;n++)i[n]=t[n];return i}function _(t,e){var n="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!n){if(Array.isArray(t)||(n=m(t))||e&&t&&"number"==typeof t.length){n&&(t=n);var i=0,e=function(){};return{s:e,n:function(){return i>=t.length?{done:!0}:{done:!1,value:t[i++]}},e:function(t){throw t},f:e}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var r,o=!0,s=!1;return{s:function(){n=n.call(t)},n:function(){var t=n.next();return o=t.done,t},e:function(t){s=!0,r=t},f:function(){try{o||null==n.return||n.return()}finally{if(s)throw r}}}}var w=function(){u(a,n(Array));var s=v(a);function a(){var t;h(this,a);for(var e=[],n=arguments.length,i=new Array(n),r=0;r<n;r++)i[r]=arguments[r];if(i&&i.length&&Array.isArray(i[0])){for(var o=0;o<i[0].length;o++)e.push(i[0][o]);t=s.call.apply(s,[this].concat(e))}else t=s.call(this);return t.option={},t.type="jmList",p(t)}return l(a,[{key:"add",value:function(t){if(t&&Array.isArray(t)){for(var e=0;e<t.length;e++)this.includes(t[e])||this.push(t[e]);return t}return"object"==d(t)&&this.includes(t)||this.push(t),t}},{key:"remove",value:function(t){for(var e=this.length-1;0<=e;e--)this[e]==t&&this.removeAt(e)}},{key:"removeAt",value:function(t){var e;this.length>t&&(e=this[t],this.splice(t,1),this.option.removeHandler&&this.option.removeHandler.call(this,e,t))}},{key:"contain",value:function(t){return this.includes(t)}},{key:"get",value:function(t){return"function"==typeof t?this.find(t):this[t]}},{key:"each",value:function(t,e){if(t&&"function"==typeof t)if(e){for(var n=this.length-1;0<=n;n--)if(!1===t.call(this,n,this[n]))break}else for(var i=this.length,r=0;r<i;r++)if(!1===t.call(this,r,this[r]))break}},{key:"count",value:function(t){if(t&&"function"==typeof t){for(var e=0,n=this.length,i=0;i<n;i++)t(this[i])&&e++;return e}return this.length}},{key:"clear",value:function(){this.splice(0,this.length)}}]),a}(),k={aliceblue:"#f0f8ff",antiquewhite:"#faebd7",aqua:"#00ffff",aquamarine:"#7fffd4",azure:"#f0ffff",beige:"#f5f5dc",bisque:"#ffe4c4",black:"#000000",blanchedalmond:"#ffebcd",blue:"#0000ff",blueviolet:"#8a2be2",brown:"#a52a2a",burlywood:"#deb887",cadetblue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",cornflowerblue:"#6495ed",cornsilk:"#fff8dc",crimson:"#dc143c",cyan:"#00ffff",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b",darkgray:"#a9a9a9",darkgreen:"#006400",darkkhaki:"#bdb76b",darkmagenta:"#8b008b",darkolivegreen:"#556b2f",darkorange:"#ff8c00",darkorchid:"#9932cc",darkred:"#8b0000",darksalmon:"#e9967a",darkseagreen:"#8fbc8f",darkslateblue:"#483d8b",darkslategray:"#2f4f4f",darkslategrey:"#2f4f4f",darkturquoise:"#00ced1",darkviolet:"#9400d3",deeppink:"#ff1493",deepskyblue:"#00bfff",dimgray:"#696969",dimgrey:"#696969",dodgerblue:"#1e90ff",firebrick:"#b22222",floralwhite:"#fffaf0",forestgreen:"#228b22",fuchsia:"#ff00ff",gainsboro:"#dcdcdc",ghostwhite:"#f8f8ff",gold:"#ffd700",goldenrod:"#daa520",gray:"#808080",green:"#008000",greenyellow:"#adff2f",grey:"#808080",honeydew:"#f0fff0",hotpink:"#ff69b4",indianred:"#cd5c5c",indigo:"#4b0082",ivory:"#fffff0",khaki:"#f0e68c",lavender:"#e6e6fa",lavenderblush:"#fff0f5",lawngreen:"#7cfc00",lemonchiffon:"#fffacd",lightblue:"#add8e6",lightcoral:"#f08080",lightcyan:"#e0ffff",lightgoldenrodyellow:"#fafad2",lightgrey:"#d3d3d3",lightgreen:"#90ee90",lightpink:"#ffb6c1",lightsalmon:"#ffa07a",lightseagreen:"#20b2aa",lightskyblue:"#87cefa",lightslategray:"#778899",lightslategrey:"#778899",lightsteelblue:"#b0c4de",lightyellow:"#ffffe0",lime:"#00ff00",limegreen:"#32cd32",linen:"#faf0e6",magenta:"#ff00ff",maroon:"#800000",mediumaquamarine:"#66cdaa",mediumblue:"#0000cd",mediumorchid:"#ba55d3",mediumpurple:"#9370d8",mediumseagreen:"#3cb371",mediumslateblue:"#7b68ee",mediumspringgreen:"#00fa9a",mediumturquoise:"#48d1cc",mediumvioletred:"#c71585",midnightblue:"#191970",mintcream:"#f5fffa",mistyrose:"#ffe4e1",moccasin:"#ffe4b5",navajowhite:"#ffdead",navy:"#000080",oldlace:"#fdf5e6",olive:"#808000",olivedrab:"#6b8e23",orange:"#ffa500",orangered:"#ff4500",orchid:"#da70d6",palegoldenrod:"#eee8aa",palegreen:"#98fb98",paleturquoise:"#afeeee",palevioletred:"#d87093",papayawhip:"#ffefd5",peachpuff:"#ffdab9",peru:"#cd853f",pink:"#ffc0cb",plum:"#dda0dd",powderblue:"#b0e0e6",purple:"#800080",red:"#ff0000",rebeccapurple:"#663399",rosybrown:"#bc8f8f",royalblue:"#4169e1",saddlebrown:"#8b4513",salmon:"#fa8072",sandybrown:"#f4a460",seagreen:"#2e8b57",seashell:"#fff5ee",sienna:"#a0522d",silver:"#c0c0c0",skyblue:"#87ceeb",slateblue:"#6a5acd",slategray:"#708090",slategrey:"#708090",snow:"#fffafa",springgreen:"#00ff7f",steelblue:"#4682b4",tan:"#d2b48c",teal:"#008080",thistle:"#d8bfd8",tomato:"#ff6347",turquoise:"#40e0d0",violet:"#ee82ee",wheat:"#f5deb3",white:"#ffffff",whitesmoke:"#f5f5f5",yellow:"#ffff00",yellowgreen:"#9acd32",transparent:"rgba(0,0,0,0)",activeborder:"#bfcaca",activecaption:"#000080",appworkspace:"#ababab",background:"#636363",buttonface:"#c0c0c0",buttonhighlight:"#dedede",buttonshadow:"#808080",buttontext:"#000000",captiontext:"#000000",graytext:"#808080",highlight:"#b3d4fc",highlighttext:"#000000",inactiveborder:"#d4d0c8",inactivecaption:"#bfbbb0",inactivecaptiontext:"#545454",infobackground:"#fbfcc5",infotext:"#000000",menu:"#c0c0c0",menutext:"#000000",scrollbar:"#c0c0c0",threeddarkshadow:"#696969",threedface:"#c0c0c0",threedhighlight:"#dfdfdf",threedlightshadow:"#dcdcdc",threedshadow:"#808080",window:"#ffffff",windowframe:"#646464",windowtext:"#000000"},A=function(){function t(){h(this,t)}return l(t,null,[{key:"clone",value:function(t,e){var n=2<arguments.length&&void 0!==arguments[2]&&arguments[2],i=3<arguments.length&&void 0!==arguments[3]?arguments[3]:null,r=4<arguments.length&&void 0!==arguments[4]?arguments[4]:0,o=5<arguments.length&&void 0!==arguments[5]?arguments[5]:null;if("function"==typeof i){var s=i(t,n,r);if(s)return s}if(o=o||new WeakMap,"boolean"==typeof e&&(n=e,e=void 0),!t||"object"!==d(t))return void 0!==e?e:t;if(o.has(t))return o.get(t);if(Array.isArray(t)){if(this.isType(t,w))return new w(t);if(n){var a=[];o.set(t,a);for(var h=0;h<t.length;h++)a.push(this.clone(t[h],void 0,n,i,r+1,o));return a}return t.slice(0)}if(t.tagName||t.getContext||t.emit)return t;o.set(t,e=e||{}),t.__proto__&&(e.__proto__=t.__proto__);var l,u=_(Object.keys(t).concat(Object.getOwnPropertySymbols(t)));try{for(u.s();!(l=u.n()).done;){var c,f=l.value;"constructor"!==f&&((c=t[f])&&(c.tagName||c.getContext||c.emit)?e[f]=c:"object"!==d(e[f])&&void 0!==e[f]||(e[f]=this.clone(c,e[f],n,i,r+1,o)))}}catch(t){u.e(t)}finally{u.f()}return e}},{key:"bindEvent",value:function(t,e,n,i){if(e&&e.indexOf&&-1!=e.indexOf(" "))for(var r=e.split(" "),o=0;o<r.length;o++)this.bindEvent(t,r[o],n,i);return t.attachEvent?t.attachEvent("on"+e,n,i):t.addEventListener&&t.addEventListener(e,n,i),{name:e,target:t,fun:n}}},{key:"removeEvent",value:function(t,e,n){return t.removeEventListener?t.removeEventListener(e,n,!1):t.detachEvent?(t.detachEvent("on"+e,n),!0):void(t["on"+e]=null)}},{key:"getElementPosition",value:function(t){var e={top:0,left:0};if(!t)return e;if(t.offsetParent)for(;t.offsetParent;)e.top+=t.offsetTop,e.left+=t.offsetLeft,t=t.offsetParent;else t.x?e.left+=t.x:t.y&&(e.top+=t.y);return e}},{key:"getEventPosition",value:function(t,e){var n=(t=t||event).isWXMiniApp,i=!1,r=t.changedTouches||t.targetTouches||t.touches,o=t.target||t.srcElement;r&&r.length&&((t=r[0]).target||(t.target=o),i=!0);var s=t.pageX||t.x;void 0===s&&(s=t.clientX+(document.documentElement.scrollLeft||document.body.scrollLeft));var a=t.pageY||t.y;void 0===a&&(a=t.clientY+(document.documentElement.scrollTop||document.body.scrollTop));var h=t.offsetX,l=t.offsetY;return void 0===h&&void 0===l&&(l=n?(h=t.x,t.y):(h=s-(o=this.getElementPosition(o)).left,a-o.top)),e&&(e.x&&(h/=e.x),e.y&&(l/=e.y)),{pageX:s,pageY:a,clientX:t.clientX,clientY:t.clientY,offsetX:h,offsetY:l,layerX:t.layerX,layerY:t.layerY,screenX:t.screenX,screenY:t.screenY,x:h,y:l,isTouch:i,touches:r,isWXMiniApp:n}}},{key:"isType",value:function(t,e){return!(!t||"object"!==d(t))&&t.constructor===e}},{key:"pointInPolygon",value:function(t,e,n){n=n||1,n/=2;var i=e.length;if(!e||0==i)return 0;if(1==i)return Math.abs(e[0].x-t.x)<=n&&Math.abs(e[0].y-t.y)<=n?1:0;if(2==i)return this.pointOnLine(t,e[0],e[1],n);for(var r=0;r<i;r++)if(Math.abs(e[r].x-t.x)<=n&&Math.abs(e[r].y-t.y)<=n)return 1;return this.rayCasting(t,e,n)}},{key:"pointOnLine",value:function(t,e,n,i){var r=Math.min(e.x,n.x),o=Math.max(e.x,n.x),s=Math.min(e.y,n.y),a=Math.max(e.y,n.y);if(r-t.x>i||t.x-o>i)return 0;if(s-t.y>i||t.y-a>i)return 0;if(e.x==n.x)return Math.abs(e.x-t.x)<=i&&(t.y-e.y)*(t.y-n.y)<=0?1:0;if(e.y==n.y)return Math.abs(e.y-t.y)<=i&&(t.x-e.x)*(t.x-n.x)<=0?1:0;if(Math.abs(e.x-t.x)<i&&Math.abs(e.y-t.y)<i)return 1;if(Math.abs(n.x-t.x)<i&&Math.abs(n.y-t.y)<i)return 1;if(t.y==e.y||t.y==n.y)return 0;n=(n.x-e.x)/(n.y-e.y)*(t.y-e.y),n=(t.y-e.y)/Math.sqrt(n*n+(t.y-e.y)*(t.y-e.y))*(t.x-e.x-n);return Math.abs(n)<=i?1:0}},{key:"rayCasting",value:function(t,e,n){for(var i=e.length,r=!1,o=t.y,s=t.x,a=0,h=i-1;a<i;h=a++){var l=e[a].y,u=e[h].y,c=e[a].x,f=e[h].x;o<l!=o<u&&s<(f-c)*(o-l)/(u-l)+c&&(r=!r)}return r?2:0}},{key:"checkOutSide",value:function(t,e,n){var i={left:0,right:0,top:0,bottom:0};return n.x<0?i.left=e.left+n.x-t.left:0<n.x&&(i.right=e.right+n.x-t.right),n.y<0?i.top=e.top+n.y-t.top:0<n.y&&(i.bottom=e.bottom+n.y-t.bottom),i}},{key:"rotatePoints",value:function(t,e,n){if(!n||!t)return t;var i=Math.cos(n),r=Math.sin(n);if(Array.isArray(t))for(var o,s,a=0;a<t.length;a++)t[a]&&(o=t[a].x-e.x,s=t[a].y-e.y,t[a].x=o*i-s*r+e.x,t[a].y=o*r+s*i+e.y);else{var h=t.x-e.x,n=t.y-e.y;t.x=h*i-n*r+e.x,t.y=h*r+n*i+e.y}return t}},{key:"trimStart",value:function(t,e){if(e=e||" ",t&&0<t.length){var n=t[0];if(n===e||0<=e.indexOf(n))return t=t.substring(1),this.trimStart(t,e)}return t}},{key:"trimEnd",value:function(t,e){if(e=e||" ",t&&0<t.length){var n=t[t.length-1];if(n===e||0<=e.indexOf(n))return t=t.substring(0,t.length-1),this.trimStart(t,e)}return t}},{key:"trim",value:function(t,e){return this.trimEnd(this.trimStart(t,e),e)}},{key:"checkPercent",value:function(t){if("string"==typeof t&&"%"==(t=this.trim(t))[t.length-1])return t}},{key:"percentToNumber",value:function(t){var e;return"string"!=typeof t||(e=this.checkPercent(t))&&(t=this.trim(e,"% "),t/=100),t}},{key:"hexToNumber",value:function(t){if("string"!=typeof t)return t;for(var e=0,n=(t=t.toLowerCase()).length,i=0;i<n;i++){var r="0123456789abcdef".indexOf(t[i]);if(0!=r){for(var o=1;o<n-i;o++)r*=16;e+=r}}return e}},{key:"numberToHex",value:function(t){for(var e="";0<t;){e="0123456789abcdef"[t%16]+e;t=Math.floor(t/16)}return e}},{key:"hexToRGBA",value:function(t){if("string"!=typeof t)return t;if(t=this.trim(t),this.__hexToRGBA_Cache=this.__hexToRGBA_Cache||{},this.__hexToRGBA_Cache[t])return this.__hexToRGBA_Cache[t];var e,n=t;return"#"==(n=k[n]?k[n]:n)[0]&&(e={a:1},8<=n.length?(e.a=n.substr(1,2),e.g=n.substr(5,2),e.b=n.substr(7,2),e.r=n.substr(3,2),e.a=Number((this.hexToNumber(e.a)/255).toFixed(4)),e.r=this.hexToNumber(e.r||0),e.g=this.hexToNumber(e.g||0),e.b=this.hexToNumber(e.b||0),n=e):7===n.length||4===n.length?(4===n.length?(e.g=n.substr(2,1),e.g=e.g+e.g,e.b=n.substr(3,1),e.b=e.b+e.b,e.r=n.substr(1,1),e.r=e.r+e.r):(e.g=n.substr(3,2),e.b=n.substr(5,2),e.r=n.substr(1,2)),e.r=this.hexToNumber(e.r||0),e.g=this.hexToNumber(e.g||0),e.b=this.hexToNumber(e.b||0),n=e):5===n.length&&(e.a=n.substr(1,1),e.g=n.substr(3,1),e.b=n.substr(4,1),e.r=n.substr(2,1),e.r=this.hexToNumber(e.r||0),e.g=this.hexToNumber(e.g||0),e.b=this.hexToNumber(e.b||0),e.a=Number((this.hexToNumber(e.a)/255).toFixed(4)),n=e)),"string"!=typeof n||(e=n.match(/rgb(a)?\s*\(\s*([\d\.]+)\s*,\s*([\d\.]+)\s*,\s*([\d\.]+)\s*(,\s*[\d\.]+)?\s*\)/i))&&6===e.length&&(n={r:Number(e[2]),g:Number(e[3]),b:Number(e[4]),a:Number(this.trimStart(e[5]||"1",","))}),this.__hexToRGBA_Cache[t]=n}},{key:"rgbToDecimal",value:function(t){return(t=this.clone(t)).r=this.byteToDecimal(t.r),t.g=this.byteToDecimal(t.g),t.b=this.byteToDecimal(t.b),t}},{key:"byteToDecimal",value:function(t){return t/255}},{key:"toColor",value:function(t,e,n,i){if("string"==typeof t&&t){if("#"===(t=this.trim(t))[0]&&(4===t.length||7===t.length))return t;var r=this.hexToRGBA(t);if("string"==typeof r)return r;t=void 0!==r.r?r.r:t,e=void 0!==r.g?r.g:e,n=void 0!==r.b?r.b:n,i=void 0!==r.a?r.a:i}return t&&"object"===d(t)&&(e=t.g,n=t.b,i=t.a||1,t=t.r),void 0!==t&&void 0!==e&&void 0!==n?void 0!==i?"rgba("+t+","+e+","+n+","+i+")":"rgb("+t+","+e+","+n+")":t}},{key:"requestAnimationFrame",value:function(t,e){return(e&&e.requestAnimationFrame?e.requestAnimationFrame:"undefined"!=typeof window&&window.requestAnimationFrame?window.requestAnimationFrame:setTimeout)(t,20)}},{key:"cancelAnimationFrame",value:function(t,e){return(e&&e.cancelAnimationFrame?e.cancelAnimationFrame:"undefined"!=typeof window&&window.cancelAnimationFrame?window.cancelAnimationFrame:clearTimeout)(t)}}]),t}(),T=0,C=function(){function e(t){h(this,e),t&&"jmGraph"==t.type&&(this.graph=t),this.id=++T}return l(e,[{key:"is",value:function(t){return"string"==typeof t?this.type==t:this instanceof t}},{key:"animate",value:function(){if(this.is("jmGraph")){if(1<arguments.length){this.animateHandles||(this.animateHandles=new w);var t=[];if(2<arguments.length)for(var e=2;e<arguments.length;e++)t.push(e<0||arguments.length<=e?void 0:arguments[e]);this.animateHandles.add({millisec:(arguments.length<=1?void 0:arguments[1])||20,handle:arguments.length<=0?void 0:arguments[0],params:t})}var o;this.animateHandles&&0<this.animateHandles.count()&&((o=this).dispatcher=setTimeout(function(n){n=n||o;var t,i=[],r=Date.now();for(t in n.animateHandles.each(function(t,e){try{e&&e.handle&&(!e.times||r-e.times>=e.millisec)&&(!1===e.handle.apply(n,e.params)&&i.push(e),e.times=r)}catch(t){e&&i.push(e)}}),i)n.animateHandles.remove(i[t]);n.animate()},10,this))}else{var n=this.graph;n&&n.animate.apply(n,arguments)}}}]),e}(),E=Symbol("properties"),P=function(){u(i,C);var n=v(i);function i(t){var e;return h(this,i),(e=n.call(this))[E]={},t&&t.mode&&(e.mode=t.mode),e}return l(i,[{key:"property",value:function(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];if(e){var i=this[E],r=e[0];if(1<e.length){var o=e[1],o={oldValue:i[r],newValue:o};return i[r]=e[1],this.emit&&this.emit("propertyChange",r,o),e[1]}if(r)return i[r]}}},{key:"needUpdate",get:function(){return this.property("needUpdate")},set:function(t){this.property("needUpdate",t),t&&!this.is("jmGraph")&&this.graph&&(this.graph.needUpdate=!0)}},{key:"graph",get:function(){return this.property("graph")||this.property("graph",this.findParent("jmGraph"))},set:function(t){return this.property("graph",t)}},{key:"mode",get:function(){var t=this.property("mode");return t||(this.is("jmGraph")?this.property("mode")||"2d":(null===(t=this.graph)||void 0===t?void 0:t.mode)||"2d")},set:function(t){return this.property("mode",t)}},{key:"requestAnimationFrame",value:function(t){return A.requestAnimationFrame(t,this.graph?this.graph.canvas:null)}},{key:"cancelAnimationFrame",value:function(t){return A.cancelAnimationFrame(t,this.graph?this.graph.canvas:null)}}]),i}(),S=function(){function r(t,e,n,i){h(this,r),"string"!=typeof t||e||n||i?(this.x=t,this.y=e,this.blur=n,this.color=i):this.fromString(t)}return l(r,[{key:"fromString",value:function(t){if(t){t=t.match(/\s*([^,]+)\s*,\s*([^,]+)\s*(,[^,]+)?\s*(,[\s\S]+)?\s*/i);return t&&(this.x=t[1]||0,this.y=t[2]||0,t[3]&&(t[3]=A.trim(t[3],", "),0===t[3].indexOf("#")||/^rgb/i.test(t[3])?this.color=t[3]:this.blur=A.trim(t[3],", ")),t[4]&&(this.color=A.trim(t[4],", "))),this}}},{key:"toString",value:function(){var t=this.x+","+this.y;return this.blur&&(t+=","+this.blur),this.color&&(t+=","+this.color),t}}]),r}(),R=function(){function i(t){if(h(this,i),this.stops=new w,t&&"object"==d(t)){for(var e in t)"stops"!==e&&(this[e]=t[e]);var n;t.stops&&Array.isArray(t.stops)&&(n=this.stops).push.apply(n,x(t.stops))}else"string"==typeof t&&this.fromString(t)}return l(i,[{key:"addStop",value:function(t,e){this.stops.add({offset:Number(t),color:e})}},{key:"toGradient",value:function(t){var i,e=t.context||t,n=t.absoluteBounds||t.getAbsoluteBounds(),r=this.x1||0,o=this.y1||0,s=this.x2,a=this.y2,h=t.getLocation(),l=0;(l=(l=h.radius?2*h.radius:l)||Math.min(h.width||0,h.height||0))<=0&&(l=Math.max(n.width||0,n.height||0,100));var u,c=n.width||l,f=n.height||l;A.checkPercent(r)?r=A.percentToNumber(r)*c:"number"==typeof r&&0<=r&&r<=1?r*=c:"string"==typeof r&&(h=parseFloat(r),isNaN(h)||(r=h)),A.checkPercent(s)?s=A.percentToNumber(s)*c:"number"==typeof s&&0<=s&&s<=1?s*=c:"string"==typeof s&&(u=parseFloat(s),isNaN(u)||(s=u)),A.checkPercent(o)?o=A.percentToNumber(o)*f:"number"==typeof o&&0<=o&&o<=1?o*=f:"string"==typeof o&&(u=parseFloat(o),isNaN(u)||(o=u)),A.checkPercent(a)?a=A.percentToNumber(a)*f:"number"==typeof a&&0<=a&&a<=1?a*=f:"string"==typeof a&&(d=parseFloat(a),isNaN(d)||(a=d));var r=Number(r)||0,o=Number(o)||0,s=Number(s)||0,a=Number(a)||0,d=r+(n.left||0),r=o+(n.top||0),o=s+(n.left||0),s=a+(n.top||0);if("linear"===this.type?"webgl"===t.mode&&t.webglControl?(i=t.webglControl.createLinearGradient(d,r,o,s,n)).key=this.toString():e.createLinearGradient&&(i=e.createLinearGradient(d,r,o,s)):"radial"===this.type&&(a=this.r1||0,p=this.r2,l<=0&&(l=Math.max(n.width||0,n.height||0,1)),A.checkPercent(a)?(a=A.percentToNumber(a),a*=l):"number"==typeof a&&0<=a&&a<=1?a*=l:"string"==typeof a&&(a=parseFloat(a)||0),A.checkPercent(p)?(p=A.percentToNumber(p),p*=l):"number"==typeof p&&0<=p&&p<=1?p*=l:"string"==typeof p&&(p=parseFloat(p)),(null==p||isNaN(Number(p))||Number(p)<=0)&&(p=l/2),a=Number(a)||0,p=Number(p)||l/2,"webgl"===t.mode&&t.webglControl?(i=t.webglControl.createRadialGradient(d,r,a,o,s,p,n)).key=this.toString():e.createRadialGradient?i=e.createRadialGradient(d,r,a,o,s,p):e.createCircularGradient&&(i=e.createCircularGradient(d,r,p))),i)return this.stops.each(function(t,e){var n=A.toColor(e.color);i&&i.addColorStop(e.offset,n)}),i;var p=this.stops.get(0);return p&&p.color||"#000"}},{key:"fromString",value:function(t){var e,n,i;t?!(i=t.match(/(linear|radial)-gradient\s*\(\s*([\s\S]+)\)/i))||i.length<3?console.warn('jmGradient: 无效的渐变字符串格式: "'+t+'"'):"linear"===(e=i[1].toLowerCase())||"radial"===e?(this.type=e,n=A.trim(i[2]),(t=this._findSplitIndex(n))<0?console.warn('jmGradient: 无法解析渐变内容: "'+n+'"'):(i=n.substring(0,t).trim(),(t=n.substring(t+1).trim())?("linear"===this.type?this._parseLinearParams(i):this._parseRadialParams(i),0===(i=this._parseColorStops(t))?console.warn('jmGradient: 未找到有效的颜色停止点: "'+t+'"'):i<2&&console.warn("jmGradient: 颜色停止点至少需要2个,当前只有 "+i+" 个")):console.warn("jmGradient: 未找到颜色停止点"))):console.warn('jmGradient: 不支持的渐变类型 "'+e+'",仅支持 linear 和 radial'):console.warn("jmGradient: 渐变字符串为空")}},{key:"_findSplitIndex",value:function(t){for(var e=0,n=0;n<t.length;n++){var i=t[n];if("("===i)e++;else if(")"===i)e--;else if(","===i&&0===e)return n}return-1}},{key:"isValid",value:function(){return!!this.type&&("linear"===this.type?void 0!==this.x1||void 0!==this.x2||void 0!==this._angle:"radial"===this.type&&(this.stops&&2<=this.stops.length))}},{key:"_parseLinearParams",value:function(t){var e,t=A.trim(t);t.startsWith("to ")?(e=t.substring(3).toLowerCase().trim(),e=this._directionToAngle(e),this._angle=e.angle,this.x1=e.x1,this.y1=e.y1,this.x2=e.x2,this.y2=e.y2):this._hasAngleUnit(t)?(e=this._parseAngle(t),this._angle=e,e=this._angleToCoords(e),this.x1=e.x1,this.y1=e.y1,this.x2=e.x2,this.y2=e.y2):t.startsWith("at ")?t.match(/at\s+(.+)/i)&&this._parseRadialParams(t):4<=(t=t.split(/\s+/)).length?(this.x1=t[0],this.y1=t[1],this.x2=t[2],this.y2=t[3]):2===t.length&&(this.x1=0,this.y1=0,this.x2=t[0],this.y2=t[1])}},{key:"_parseRadialParams",value:function(t){var e=A.trim(t);this.shape="ellipse",this.position={x:"50%",y:"50%"};var n=e.match(/^(.+?)\s+at\s+(.+)$/i);n?(t=A.trim(n[1]),n=A.trim(n[2]),this._parseRadialShape(t),this._parseRadialPosition(n)):e.startsWith("circle")||e.startsWith("ellipse")?(this._parseRadialShape(e),this.x1="50%",this.y1="50%",this.x2="50%",this.y2="50%"):(3<=(e=e.split(/\s+/)).length&&(this.x1=e[0],this.y1=e[1],this.r1=e[2]),6<=e.length&&(this.x2=e[3],this.y2=e[4],this.r2=e[5])),void 0===this.x1&&void 0===this.y1&&(this.x1="50%",this.y1="50%"),void 0===this.x2&&void 0===this.y2&&(this.x2="50%",this.y2="50%"),void 0===this.r2&&(this.r2="50%")}},{key:"_parseRadialShape",value:function(t){var e;t.startsWith("circle")?(this.shape="circle",(e=t.match(/circle\s*\(\s*([^)]+)\s*\)/i))&&(this.r2=A.trim(e[1]))):t.startsWith("ellipse")&&(this.shape="ellipse",!(t=t.match(/ellipse\s*\(\s*([^)]+)\s*\)/i))||2<=(t=A.trim(t[1]).split(/\s+/)).length&&(this.rx=t[0],this.ry=t[1]))}},{key:"_parseRadialPosition",value:function(t){t=t.split(/\s+/);2<=t.length&&(this.x1=t[0],this.y1=t[1],this.x2=t[0],this.y2=t[1])}},{key:"_parseColorStops",value:function(t){if(!t)return 0;for(var e=this._splitColorStops(t),n=-1,i=0,r=0;r<e.length;r++){var o,s,a=A.trim(e[r]);a&&((s=this._parseSingleColorStop(a))&&(o=s.color,a=s.offset,"transparent"===o&&(o="rgba(0,0,0,0)"),this._isValidColor(o)?null!==(s=null===(s=this._normalizeOffset(a))?0===r?0:r===e.length-1?1:null!==(a=this._findNextOffset(e,r))?(n+a)/2:Math.min(1,n+(1-n)/(e.length-r)):s)&&((s<0||1<s)&&(console.warn("jmGradient: 颜色偏移量 "+s+" 超出有效范围 [0, 1],将调整为有效范围"),s=Math.max(0,Math.min(1,s))),n=s,this.addStop(s,o),i++):console.warn('jmGradient: 无效的颜色格式 "'+o+'"')))}return i}},{key:"_splitColorStops",value:function(t){for(var e=[],n=0,i="",r=0;r<t.length;r++){var o=t[r];"("===o?(n++,i+=o):")"===o?(n--,i+=o):","===o&&0===n?(e.push(i.trim()),i=""):i+=o}return i.trim()&&e.push(i.trim()),e}},{key:"_parseSingleColorStop",value:function(t){var e=t.match(/^(#[a-fA-F0-9]{3,8})\s*(\d+(?:\.\d+)?%?)?$/i);if(e)return{color:e[1],offset:e[2]||null};e=t.match(/^(rgba?\s*\([^)]+\))\s*(\d+(?:\.\d+)?%?)?$/i);if(e)return{color:e[1],offset:e[2]||null};e=t.match(/^(hsla?\s*\([^)]+\))\s*(\d+(?:\.\d+)?%?)?$/i);if(e)return{color:e[1],offset:e[2]||null};t=t.match(/^([a-zA-Z]+)\s*(\d+(?:\.\d+)?%?)?$/i);return t&&this._isValidColor(t[1])?{color:t[1],offset:t[2]||null}:null}},{key:"_findNextOffset",value:function(t,e){for(var n=e+1;n<t.length;n++){var i=this._parseSingleColorStop(A.trim(t[n]));if(i&&i.offset)return this._normalizeOffset(i.offset)}return null}},{key:"_isValidColor",value:function(t){if(!t)return!1;if(/^#([a-fA-F0-9]{3,8})$/.test(t))return!0;if(/^rgba?\s*\(\s*\d{1,3}\s*,\s*\d{1,3}\s*,\s*\d{1,3}\s*(,\s*[\d.]+\s*)?\)$/i.test(t))return!0;return!!/^hsla?\s*\(\s*\d{1,3}\s*,\s*\d{1,3}%?\s*,\s*\d{1,3}%?\s*(,\s*[\d.]+\s*)?\)$/i.test(t)||(!!k[t.toLowerCase()]||!!/^[a-zA-Z]+$/.test(t))}},{key:"_normalizeOffset",value:function(t){if(!t)return null;if((t=A.trim(t)).endsWith("%"))return parseFloat(t)/100;t=parseFloat(t);return isNaN(t)?null:1<t?t/100:t}},{key:"_hasAngleUnit",value:function(t){return/^-?\d+(\.\d+)?\s*(deg|rad|grad|turn)$/i.test(t)}},{key:"_parseAngle",value:function(t){t=(t=A.trim(t)).match(/^(-?\d+(\.\d+)?)\s*(deg|rad|grad|turn)?$/i);if(!t)return 0;var e=parseFloat(t[1]);switch((t[3]||"deg").toLowerCase()){case"deg":return e*Math.PI/180;case"rad":return e;case"grad":return e*Math.PI/200;case"turn":return 2*e*Math.PI;default:return e*Math.PI/180}}},{key:"_angleToCoords",value:function(t){var e=Math.cos(t),t=-Math.sin(t);return{x1:Math.round(1e3*(.5-.5*e))/1e3,y1:Math.round(1e3*(.5+.5*t))/1e3,x2:Math.round(1e3*(.5+.5*e))/1e3,y2:Math.round(1e3*(.5-.5*t))/1e3}}},{key:"_directionToAngle",value:function(t){var e={"to top":{angle:0,x1:"50%",y1:"100%",x2:"50%",y2:"0%"},"to bottom":{angle:Math.PI,x1:"50%",y1:"0%",x2:"50%",y2:"100%"},"to left":{angle:-Math.PI/2,x1:"100%",y1:"50%",x2:"0%",y2:"50%"},"to right":{angle:Math.PI/2,x1:"0%",y1:"50%",x2:"100%",y2:"50%"},"to top left":{angle:3*-Math.PI/4,x1:"100%",y1:"100%",x2:"0%",y2:"0%"},"to top right":{angle:-Math.PI/4,x1:"0%",y1:"100%",x2:"100%",y2:"0%"},"to bottom left":{angle:3*Math.PI/4,x1:"100%",y1:"0%",x2:"0%",y2:"100%"},"to bottom right":{angle:Math.PI/4,x1:"0%",y1:"0%",x2:"100%",y2:"100%"},top:{angle:0,x1:"50%",y1:"100%",x2:"50%",y2:"0%"},bottom:{angle:Math.PI,x1:"50%",y1:"0%",x2:"50%",y2:"100%"},left:{angle:-Math.PI/2,x1:"100%",y1:"50%",x2:"0%",y2:"50%"},right:{angle:Math.PI/2,x1:"0%",y1:"50%",x2:"100%",y2:"50%"}},n=e[t];if(n)return n;var i=t.match(/to\s+(top|bottom|left|right)/i);if(i){n=i[1].toLowerCase(),i=t.replace(i[0],"").trim();if(i){i="to ".concat(n," ").concat(i);if(e[i])return e[i]}}return{angle:0,x1:"50%",y1:"100%",x2:"50%",y2:"0%"}}},{key:"toString",value:function(){var n=this.type+"-gradient(";return"linear"==this.type?n+=this.x1+" "+this.y1+" "+this.x2+" "+this.y2:n+=this.x1+" "+this.y1+" "+this.r1+" "+this.x2+" "+this.y2+" "+this.r2,this.stops.each(function(t,e){n+=","+e.color+" "+e.offset}),n+")"}}]),i}(),M=function(){function n(t){if(h(this,n),this.filters=[],"string"==typeof t)this.fromString(t);else if(t&&"object"===d(t))for(var e in t)"constructor"!==e&&"filters"!==e&&this.addFilter(e,t[e])}return l(n,[{key:"addFilter",value:function(t,e){var n;t=t.toLowerCase().trim(),"string"==typeof e&&(e=parseFloat(e)),isNaN(e)||(n={blur:"blur",grayscale:"grayscale",greyscale:"grayscale",sepia:"sepia",brightness:"brightness",contrast:"contrast",saturate:"saturate","hue-rotate":"hueRotate",hueRotate:"hueRotate",invert:"invert",opacity:"opacity"}[t])&&((t=this.filters.find(function(t){return t.name===n}))?t.value=e:this.filters.push({name:n,value:e}))}},{key:"fromString",value:function(t){if(t&&"string"==typeof t)for(var e=/([a-zA-Z-]+)\s*\(\s*([^)]+)\s*\)/g;null!==(i=e.exec(t));){var n=i[1],i=i[2].replace(/[a-z%]+$/i,"").trim(),i=parseFloat(i);isNaN(i)||this.addFilter(n,i)}}},{key:"toString",value:function(){return this.filters.map(function(t){switch(t.name){case"blur":return"blur(".concat(t.value,"px)");case"hueRotate":return"hue-rotate(".concat(t.value,"deg)");default:return"".concat(t.name,"(").concat(t.value,")")}}).join(" ")}},{key:"toCanvasFilter",value:function(){return 0===this.filters.length?"none":this.toString()}},{key:"has",value:function(e){return this.filters.some(function(t){return t.name===e})}},{key:"get",value:function(e){var t=this.filters.find(function(t){return t.name===e});return t?t.value:void 0}},{key:"remove",value:function(e){var t=this.filters.findIndex(function(t){return t.name===e});-1<t&&this.filters.splice(t,1)}},{key:"clear",value:function(){this.filters=[]}}]),n}(),N=function(){function n(t,e){h(this,n),this.container=t,this.target=e||t,this.mouseHandler=new F(this,t,e),this.keyHandler=new B(this,t,e)}return l(n,[{key:"touchStart",value:function(t){if((t=t||window.event).eventName="touchstart",this.container.raiseEvent("touchstart",t),(t.target||t.srcElement)==this.target)return!1}},{key:"touchMove",value:function(t){if((t=t||window.event).eventName="touchmove",this.container.raiseEvent("touchmove",t),(t.target||t.srcElement)==this.target)return!1}},{key:"touchEnd",value:function(t){if((t=t||window.event).eventName="touchend",this.container.raiseEvent("touchend",t),(t.target||t.srcElement)==this.target)return!1}},{key:"touchCancel",value:function(t){if((t=t||window.event).eventName="touchcancel",this.container.raiseEvent("touchcancel",t),(t.target||t.srcElement)==this.target)return!1}},{key:"tap",value:function(t){if((t=t||window.event).eventName="tap",this.container.raiseEvent("tap",t),(t.target||t.srcElement)==this.target)return!1}},{key:"destroy",value:function(){this.mouseHandler.destroy(),this.keyHandler.destroy()}}]),n}(),F=function(){function i(t,e,n){h(this,i),this.instance=t,this.container=e,this.target=n||e,this.eventEvents={},this.init(t,e,n)}return l(i,[{key:"init",value:function(e,n,t){var i=this.target,r="undefined"!=typeof document?document:null;this.eventEvents.mousedown=A.bindEvent(this.target,"mousedown",function(t){(t=t||window.event).eventName="mousedown",n.raiseEvent("mousedown",t)}),this.eventEvents.mousemove=A.bindEvent(this.target,"mousemove",function(t){if((t=t||window.event).eventName="mousemove",(t.target||t.srcElement)==i)return n.raiseEvent("mousemove",t),t.preventDefault&&t.preventDefault(),!1}),this.eventEvents.mouseover=A.bindEvent(this.target,"mouseover",function(t){(t=t||window.event).eventName="mouseover",n.raiseEvent("mouseover",t)}),this.eventEvents.mouseleave=A.bindEvent(this.target,"mouseleave",function(t){(t=t||window.event).eventName="mouseleave",n.raiseEvent("mouseleave",t)}),this.eventEvents.mouseout=A.bindEvent(this.target,"mouseout",function(t){(t=t||window.event).eventName="mouseout",n.raiseEvent("mouseout",t)}),r&&(this.eventEvents.mouseup=A.bindEvent(r,"mouseup",function(t){if(!((t=t||window.event).eventName="mouseup")===n.raiseEvent("mouseup",t))return t.preventDefault&&t.preventDefault(),!1})),this.eventEvents.dblclick=A.bindEvent(this.target,"dblclick",function(t){(t=t||window.event).eventName="dblclick",n.raiseEvent("dblclick",t)}),this.eventEvents.click=A.bindEvent(this.target,"click",function(t){(t=t||window.event).eventName="click",n.raiseEvent("click",t)}),r&&(this.eventEvents.resize=A.bindEvent(r,"resize",function(t){return(t=t||window.event).eventName="resize",n.raiseEvent("resize",t)})),this.eventEvents.touchstart=A.bindEvent(this.target,"touchstart",function(t){return t.eventName="touchstart",e.touchStart(t)},{passive:!1}),this.eventEvents.touchmove=A.bindEvent(this.target,"touchmove",function(t){return t.eventName="touchmove",e.touchMove(t)},{passive:!1}),r&&(this.eventEvents.touchend=A.bindEvent(r,"touchend",function(t){return t.eventName="touchend",e.touchEnd(t)},{passive:!1})),r&&(this.eventEvents.touchcancel=A.bindEvent(r,"touchcancel",function(t){return t.eventName="touchcancel",e.touchCancel(t)},{passive:!1}))}},{key:"destroy",value:function(){for(var t in this.eventEvents){var e=this.eventEvents[t];e&&e.fun&&A.removeEvent(e.target,t,e.fun)}}}]),i}(),B=function(){function i(t,e,n){h(this,i),this.instance=t,this.container=e,this.target=n||e,this.eventEvents={},this.init(e,n)}return l(i,[{key:"init",value:function(n,t){function i(t){return!(t=t.srcElement||t.target)||"INPUT"!=t.tagName&&"TEXTAREA"!=t.tagName&&"ANCHOR"!=t.tagName&&"FORM"!=t.tagName&&"FILE"!=t.tagName&&"IMG"!=t.tagName&&"HIDDEN"!=t.tagName&&"RADIO"!=t.tagName&&"TEXT"!=t.tagName}var e="undefined"!=typeof document?document:null;e&&(this.eventEvents.keypress=A.bindEvent(e,"keypress",function(t){if(t=t||window.event,i(t)){var e=n.raiseEvent("keypress",t);return!1===e&&t.preventDefault&&t.preventDefault(),e}})),e&&(this.eventEvents.keydown=A.bindEvent(e,"keydown",function(t){if(t=t||window.event,i(t)){var e=n.raiseEvent("keydown",t);return!1===e&&t.preventDefault&&t.preventDefault(),e}})),e&&(this.eventEvents.keyup=A.bindEvent(e,"keyup",function(t){if(t=t||window.event,i(t)){var e=n.raiseEvent("keyup",t);return!1===e&&t.preventDefault&&t.preventDefault(),e}}))}},{key:"destroy",value:function(){for(var t in this.eventEvents){var e=this.eventEvents[t];e&&e.fun&&A.removeEvent(e.target,t,e.fun)}}}]),i}();function O(t,e,n){n=n||2;var i,r,o,s,a,h=e&&e.length,l=h?e[0]*n:t.length,u=D(t,0,l,n,!0),c=[];if(!u||u.next===u.prev)return c;if(h&&(u=function(t,e,n,i){var r,o,s,a,h=[];for(r=0,o=e.length;r<o;r++)s=e[r]*i,a=r<o-1?e[r+1]*i:t.length,(a=D(t,s,a,i,!1))===a.next&&(a.steiner=!0),h.push(function(t){var e=t,n=t;for(;(e.x<n.x||e.x===n.x&&e.y<n.y)&&(n=e),e=e.next,e!==t;);return n}(a));for(h.sort(j),r=0;r<h.length;r++)n=function(t,e){var n=function(t,e){var n,i=e,r=t.x,o=t.y,s=-1/0;do{if(o<=i.y&&o>=i.next.y&&i.next.y!==i.y){var a=i.x+(o-i.y)*(i.next.x-i.x)/(i.next.y-i.y);if(a<=r&&s<a&&(s=a,n=i.x<i.next.x?i:i.next,a===r))return n}}while(i=i.next,i!==e);if(!n)return null;var h,l=n,u=n.x,c=n.y,f=1/0;i=n;for(;r>=i.x&&i.x>=u&&r!==i.x&&U(o<c?r:s,o,u,c,o<c?s:r,o,i.x,i.y)&&(h=Math.abs(o-i.y)/(r-i.x),V(i,t)&&(h<f||h===f&&(i.x>n.x||i.x===n.x&&function(t,e){return G(t.prev,t,e.prev)<0&&G(e.next,t,t.next)<0}(n,i)))&&(n=i,f=h)),i=i.next,i!==l;);return n}(t,e);if(!n)return e;t=H(n,t);return I(t,t.next),I(n,n.next)}(h[r],n);return n}(t,e,u,n)),t.length>80*n){for(var f=i=t[0],d=r=t[1],p=n;p<l;p+=n)(o=t[p])<f&&(f=o),(s=t[p+1])<d&&(d=s),i<o&&(i=o),r<s&&(r=s);a=0!==(a=Math.max(i-f,r-d))?32767/a:0}return L(u,c,n,f,d,a,0),c}function D(t,e,n,i,r){var o,s;if(r===0<J(t,e,n,i))for(o=e;o<n;o+=i)s=Z(o,t[o],t[o+1],s);else for(o=n-i;e<=o;o-=i)s=Z(o,t[o],t[o+1],s);return s&&Y(s,s.next)&&($(s),s=s.next),s}function I(t,e){if(!t)return t;e=e||t;var n,i=t;do{if(n=!1,i.steiner||!Y(i,i.next)&&0!==G(i.prev,i,i.next))i=i.next;else{if($(i),(i=e=i.prev)===i.next)break;n=!0}}while(n||i!==e);return e}function L(t,e,n,i,r,o,s){if(t){!s&&o&&function(t,e,n,i){var r=t;for(;0===r.z&&(r.z=z(r.x,r.y,e,n,i)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next,r!==t;);r.prevZ.nextZ=null,r.prevZ=null,function(t){var e,n,i,r,o,s,a,h,l=1;do{for(n=t,o=t=null,s=0;n;){for(s++,i=n,e=a=0;e<l&&(a++,i=i.nextZ);e++);for(h=l;0<a||0<h&&i;)0!==a&&(0===h||!i||n.z<=i.z)?(n=(r=n).nextZ,a--):(i=(r=i).nextZ,h--),o?o.nextZ=r:t=r,r.prevZ=o,o=r;n=i}}while(o.nextZ=null,l*=2,1<s)}(r)}(t,i,r,o);for(var a,h,l=t;t.prev!==t.next;)if(a=t.prev,h=t.next,o?function(t,e,n,i){var r=t.prev,o=t,s=t.next;if(0<=G(r,o,s))return!1;var a=r.x,h=o.x,l=s.x,u=r.y,c=o.y,f=s.y,d=a<h?a<l?a:l:h<l?h:l,p=u<c?u<f?u:f:c<f?c:f,v=h<a?l<a?a:l:l<h?h:l,y=c<u?f<u?u:f:f<c?c:f,g=z(d,p,e,n,i),m=z(v,y,e,n,i),x=t.prevZ,b=t.nextZ;for(;x&&x.z>=g&&b&&b.z<=m;){if(x.x>=d&&x.x<=v&&x.y>=p&&x.y<=y&&x!==r&&x!==s&&U(a,u,h,c,l,f,x.x,x.y)&&0<=G(x.prev,x,x.next))return!1;if(x=x.prevZ,b.x>=d&&b.x<=v&&b.y>=p&&b.y<=y&&b!==r&&b!==s&&U(a,u,h,c,l,f,b.x,b.y)&&0<=G(b.prev,b,b.next))return!1;b=b.nextZ}for(;x&&x.z>=g;){if(x.x>=d&&x.x<=v&&x.y>=p&&x.y<=y&&x!==r&&x!==s&&U(a,u,h,c,l,f,x.x,x.y)&&0<=G(x.prev,x,x.next))return!1;x=x.prevZ}for(;b&&b.z<=m;){if(b.x>=d&&b.x<=v&&b.y>=p&&b.y<=y&&b!==r&&b!==s&&U(a,u,h,c,l,f,b.x,b.y)&&0<=G(b.prev,b,b.next))return!1;b=b.nextZ}return!0}(t,i,r,o):function(t){var e=t.prev,n=t,t=t.next;if(0<=G(e,n,t))return!1;var i=e.x,r=n.x,o=t.x,s=e.y,a=n.y,h=t.y,l=i<r?i<o?i:o:r<o?r:o,u=s<a?s<h?s:h:a<h?a:h,c=r<i?o<i?i:o:o<r?r:o,f=a<s?h<s?s:h:h<a?a:h,d=t.next;for(;d!==e;){if(d.x>=l&&d.x<=c&&d.y>=u&&d.y<=f&&U(i,s,r,a,o,h,d.x,d.y)&&0<=G(d.prev,d,d.next))return!1;d=d.next}return!0}(t))e.push(a.i/n|0),e.push(t.i/n|0),e.push(h.i/n|0),$(t),t=h.next,l=h.next;else if((t=h)===l){s?1===s?L(t=function(t,e,n){var i=t;do{var r=i.prev,o=i.next.next}while(!Y(r,o)&&X(r,i,i.next,o)&&V(r,o)&&V(o,r)&&(e.push(r.i/n|0),e.push(i.i/n|0),e.push(o.i/n|0),$(i),$(i.next),i=t=o),i=i.next,i!==t);return I(i)}(I(t),e,n),e,n,i,r,o,2):2===s&&function(t,e,n,i,r,o){var s=t;do{for(var a=s.next.next;a!==s.prev;){if(s.i!==a.i&&function(t,e){return t.next.i!==e.i&&t.prev.i!==e.i&&!function(t,e){var n=t;do{if(n.i!==t.i&&n.next.i!==t.i&&n.i!==e.i&&n.next.i!==e.i&&X(n,n.next,t,e))return!0}while(n=n.next,n!==t);return!1}(t,e)&&(V(t,e)&&V(e,t)&&function(t,e){var n=t,i=!1,r=(t.x+e.x)/2,o=(t.y+e.y)/2;for(;n.y>o!=n.next.y>o&&n.next.y!==n.y&&r<(n.next.x-n.x)*(o-n.y)/(n.next.y-n.y)+n.x&&(i=!i),n=n.next,n!==t;);return i}(t,e)&&(G(t.prev,t,e.prev)||G(t,e.prev,e))||Y(t,e)&&0<G(t.prev,t,t.next)&&0<G(e.prev,e,e.next))}(s,a)){var h=H(s,a);return s=I(s,s.next),h=I(h,h.next),L(s,e,n,i,r,o,0),L(h,e,n,i,r,o,0)}a=a.next}}while(s=s.next,s!==t)}(t,e,n,i,r,o):L(I(t),e,n,i,r,o,1);break}}}function j(t,e){return t.x-e.x}function z(t,e,n,i,r){return(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=(t-n)*r|0)|t<<8))|t<<4))|t<<2))|t<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-i)*r|0)|e<<8))|e<<4))|e<<2))|e<<1))<<1}function U(t,e,n,i,r,o,s,a){return(t-s)*(o-a)<=(r-s)*(e-a)&&(n-s)*(e-a)<=(t-s)*(i-a)&&(r-s)*(i-a)<=(n-s)*(o-a)}function G(t,e,n){return(e.y-t.y)*(n.x-e.x)-(e.x-t.x)*(n.y-e.y)}function Y(t,e){return t.x===e.x&&t.y===e.y}function X(t,e,n,i){var r=q(G(t,e,n)),o=q(G(t,e,i)),s=q(G(n,i,t)),a=q(G(n,i,e));return r!==o&&s!==a||(0===r&&W(t,n,e)||(0===o&&W(t,i,e)||(0===s&&W(n,t,i)||!(0!==a||!W(n,e,i)))))}function W(t,e,n){return e.x<=Math.max(t.x,n.x)&&e.x>=Math.min(t.x,n.x)&&e.y<=Math.max(t.y,n.y)&&e.y>=Math.min(t.y,n.y)}function q(t){return 0<t?1:t<0?-1:0}function V(t,e){return G(t.prev,t,t.next)<0?0<=G(t,e,t.next)&&0<=G(t,t.prev,e):G(t,e,t.prev)<0||G(t,t.next,e)<0}function H(t,e){var n=new K(t.i,t.x,t.y),i=new K(e.i,e.x,e.y),r=t.next,o=e.prev;return(t.next=e).prev=t,(n.next=r).prev=n,(i.next=n).prev=i,(o.next=i).prev=o,i}function Z(t,e,n,i){n=new K(t,e,n);return i?(n.next=i.next,(n.prev=i).next.prev=n,i.next=n):(n.prev=n).next=n,n}function $(t){t.next.prev=t.prev,t.prev.next=t.next,t.prevZ&&(t.prevZ.nextZ=t.nextZ),t.nextZ&&(t.nextZ.prevZ=t.prevZ)}function K(t,e,n){this.i=t,this.x=e,this.y=n,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}function J(t,e,n,i){for(var r=0,o=e,s=n-i;o<n;o+=i)r+=(t[s]-t[o])*(t[o+1]+t[s+1]),s=o;return r}O.deviation=function(t,e,n,i){var r=e&&e.length,o=r?e[0]*n:t.length,s=Math.abs(J(t,0,o,n));if(r)for(var a=0,h=e.length;a<h;a++){var l=e[a]*n,u=a<h-1?e[a+1]*n:t.length;s-=Math.abs(J(t,l,u,n))}for(var c=0,a=0;a<i.length;a+=3){var f=i[a]*n,d=i[a+1]*n,p=i[a+2]*n;c+=Math.abs((t[f]-t[p])*(t[1+d]-t[1+f])-(t[f]-t[d])*(t[1+p]-t[1+f]))}return 0===s&&0===c?0:Math.abs((c-s)/s)},O.flatten=function(t){for(var e=t[0][0].length,n={vertices:[],holes:[],dimensions:e},i=0,r=0;r<t.length;r++){for(var o=0;o<t[r].length;o++)for(var s=0;s<e;s++)n.vertices.push(t[r][o][s]);0<r&&(i+=t[r-1].length,n.holes.push(i))}return n};var Q=function(){function n(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:"linear",e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{};h(this,n),this.type=t||"linear",this.x1=e.x1||0,this.y1=e.y1||0,this.r1=e.r1||0,this.x2=e.x2||0,this.y2=e.y2||0,this.r2=e.r2||0,this.bounds=e.bounds||{left:0,top:0,width:0,height:0},this.control=e.control,this.stops=[],this._sortedStops=null,this._paramsHash=null}return l(n,[{key:"addColorStop",value:function(t,e){this.stops.push({offset:Math.max(0,Math.min(1,t)),color:e}),this._sortedStops=null,this._paramsHash=null}},{key:"_getSortedStops",value:function(){if(this._sortedStops)return this._sortedStops;var i=this.control&&this.control.graph&&this.control.graph.utils;return this._sortedStops=this.stops.map(function(t){var e=t.color;if("object"!==d(e=i&&"string"==typeof e?i.hexToRGBA(e):e)||null===e)return{offset:t.offset,r:0,g:0,b:0,a:1};var n=1<e.r||1<e.g||1<e.b?255:1;return{offset:t.offset,r:(void 0!==e.r?e.r:0)/n,g:(void 0!==e.g?e.g:0)/n,b:(void 0!==e.b?e.b:0)/n,a:void 0!==e.a?e.a:1}}).sort(function(t,e){return t.offset-e.offset}),this._sortedStops}},{key:"toUniformParams",value:function(){for(var t=this._getSortedStops(),e=Math.min(t.length,16),n=new Float32Array(5*e),i=0;i<e;i++){var r=t[i];n[5*i+0]=r.offset,n[5*i+1]=r.r,n[5*i+2]=r.g,n[5*i+3]=r.b,n[5*i+4]=r.a}return{gradientType:"radial"===this.type?2:1,gradientStart:new Float32Array([this.x1,this.y1,"radial"===this.type?Math.max(0,this.r1):0,0]),gradientEnd:new Float32Array([this.x2,this.y2,"radial"===this.type?Math.max(0,this.r2):0,0]),stopCount:e,stops:n}}},{key:"invalidateCache",value:function(){this._sortedStops=null,this._paramsHash=null}},{key:"toString",value:function(){var e=this.type+"-gradient(";return"linear"==this.type?e+=this.x1+" "+this.y1+" "+this.x2+" "+this.y2:e+=this.x1+" "+this.y1+" "+this.r1+" "+this.x2+" "+this.y2+" "+this.r2,this.stops.forEach(function(t){e+=","+t.color+" "+t.offset}),e+")"}}]),n}();function tt(t,e,n){e=t.createShader(e);return t.shaderSource(e,n),t.compileShader(e),e}var et={float:1,vec2:2,vec3:3,vec4:4,int:1,ivec2:2,ivec3:3,ivec4:4,bool:1,bvec2:2,bvec3:3,bvec4:4,mat2:4,mat3:9,mat4:16,sampler2D:1},nt=function(t){return et[t]},it=null,rt={FLOAT:"float",FLOAT_VEC2:"vec2",FLOAT_VEC3:"vec3",FLOAT_VEC4:"vec4",INT:"int",INT_VEC2:"ivec2",INT_VEC3:"ivec3",INT_VEC4:"ivec4",BOOL:"bool",BOOL_VEC2:"bvec2",BOOL_VEC3:"bvec3",BOOL_VEC4:"bvec4",FLOAT_MAT2:"mat2",FLOAT_MAT3:"mat3",FLOAT_MAT4:"mat4",SAMPLER_2D:"sampler2D"},ot=function(t,e){if(!it){var n=Object.keys(rt);it={};for(var i=0;i<n.length;++i){var r=n[i];it[t[r]]=rt[r]}}return it[e]};function st(t,e,n){var i=tt(t,t.VERTEX_SHADER,e),e=tt(t,t.FRAGMENT_SHADER,n),n=t.createProgram();return t.attachShader(n,i),t.attachShader(n,e),t.linkProgram(n),t.getProgramParameter(n,t.LINK_STATUS)||(console.error("PError: Could not initialize shader."),console.error("gl.VALIDATE_STATUS",t.getProgramParameter(n,t.VALIDATE_STATUS)),console.error("gl.getError()",t.getError()),""!==t.getProgramInfoLog(n)&&console.warn("Warning: gl.getProgramInfoLog()",t.getProgramInfoLog(n)),t.deleteProgram(n)),at(t,n),t.deleteShader(i),t.deleteShader(e),{program:n,attrs:function(t,e){for(var n={},i=t.getProgramParameter(e,t.ACTIVE_ATTRIBUTES),r=0;r<i;r++){var o=t.getActiveAttrib(e,r),s=ot(t,o.type);n[o.name]={attribData:o,size:nt(s),type:s,location:t.getAttribLocation(e,o.name)}}return n}(t,n),uniforms:function(t,e){for(var n={},i=t.getProgramParameter(e,t.ACTIVE_UNIFORMS),r=0;r<i;r++){var o=t.getActiveUniform(e,r),s=o.name.replace(/\[.*?\]/,""),a=ot(t,o.type);n[s]={uniformData:o,type:a,size:o.size,location:t.getUniformLocation(e,s)}}return n}(t,n)}}function at(t,e){return t.useProgram(e)}function ht(t,e,n,i){var r=2<arguments.length&&void 0!==n?n:t.ARRAY_BUFFER,n=3<arguments.length&&void 0!==i?i:t.STATIC_DRAW,i=t.createBuffer();if(!i)throw Error("创建缓冲区对象失败");return t.bindBuffer(r,i),t.bufferData(r,e.buffer||e,n),{type:r,drawType:n,buffer:i,unitSize:e.BYTES_PER_ELEMENT}}function lt(t){var e=t.createTexture();return t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,1),t.activeTexture(t.TEXTURE0),t.bindTexture(t.TEXTURE_2D,e),t.texParameterf(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,t.NEAREST),t.texParameterf(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameterf(t.TEXTURE_2D,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameterf(t.TEXTURE_2D,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE),e}var ut="\n attribute vec4 a_position;\n attribute vec4 a_color;\n attribute vec2 a_text_coord;\n uniform vec2 a_center_point; // 当前canvas的中心位置\n uniform float a_point_size; // 点的大小\n uniform int a_type;\n varying vec4 v_color;\n varying vec2 v_text_coord;\n varying float v_type;\n\n ".concat("\n vec4 translatePosition(vec4 point, float x, float y) {\n point.x = (point.x-x)/x;\n point.y = (y-point.y)/y;\n return point;\n }","\n\n void main() {\n gl_PointSize = a_point_size == 0.0? 1.0 : a_point_size;\n v_type = float(a_type);\n vec4 pos = translatePosition(a_position, a_center_point.x, a_center_point.y);\n gl_Position = pos;\n v_color = a_color;\n if(a_type == 2 || a_type == 5) {\n v_text_coord = a_position.xy;\n }\n }\n"),ct="\n precision mediump float;\n uniform sampler2D u_sample;\n uniform vec4 v_texture_bounds; // 纹理的左上坐标和大小 x,y,z,w\n uniform vec4 v_single_color;\n // GLSL 渐变 uniforms\n uniform int u_gradient_type; // 0=无 1=线性 2=径向\n uniform vec4 u_gradient_start; // 线性:{x1,y1,0,0} 径向:{cx,cy,r1,0}\n uniform vec4 u_gradient_end; // 线性:{x2,y2,0,0} 径向:{cx,cy,r2,0}\n uniform int u_gradient_stop_count;\n uniform float u_gradient_offsets[".concat(16,"];\n uniform vec4 u_gradient_colors[").concat(16,"]; // {r, g, b, a} 0~1 范围\n varying float v_type;\n varying vec4 v_color;\n varying vec2 v_text_coord;\n\n ").concat("\n vec2 translateTexturePosition(in vec2 point, vec4 bounds) {\n point.x = (point.x-bounds.x)/bounds.z; // 离左上角位置的X长比上纹理宽 0-1\n point.y = 1.0-(point.y-bounds.y)/bounds.w; // 离左上角位置的Y长比上高,因为纹理坐标是左下角起,所以要用1-\n return point;\n }","\n\n // 在 sorted stops 中按 t 值采样颜色\n // 兼容 GLSL ES 1.0:循环仅与常量比较,无 break/continue\n vec4 sampleGradient(float t) {\n t = clamp(t, 0.0, 1.0);\n // 正向扫描:始终遍历 MAX_STOPS-1 次,找到 t 所在段并覆盖结果\n float localT = 0.0;\n vec4 c0 = u_gradient_colors[0];\n vec4 c1 = u_gradient_colors[0];\n for(int i = 0; i < ").concat(15,"; i++) {\n float s0 = u_gradient_offsets[i];\n float s1 = u_gradient_offsets[i + 1];\n if(t >= s0) {\n float range = s1 - s0;\n localT = range > 0.0001 ? clamp((t - s0) / range, 0.0, 1.0) : 0.0;\n c0 = u_gradient_colors[i];\n c1 = u_gradient_colors[i + 1];\n }\n }\n return mix(c0, c1, localT);\n }\n\n void main() {\n // 如果是fill,则直接填充颜色\n if(v_type == 1.0) {\n gl_FragColor = v_single_color;\n }\n // 渐变色 (旧方式,顶点颜色插值)\n else if(v_type == 3.0) {\n gl_FragColor = v_color;\n }\n // GLSL 渐变填充 (type=5)\n else if(v_type == 5.0) {\n float t;\n if(u_gradient_type == 2) {\n // 径向渐变\n vec2 d = v_text_coord - u_gradient_start.xy;\n float dist = length(d);\n float r1 = u_gradient_start.z;\n float r2 = u_gradient_end.z;\n float range = r2 - r1;\n t = range > 0.001 ? (dist - r1) / range : 0.0;\n } else {\n // 线性渐变\n vec2 dir = u_gradient_end.xy - u_gradient_start.xy;\n float lenSq = dot(dir, dir);\n if(lenSq > 0.001) {\n vec2 pos = v_text_coord - u_gradient_start.xy;\n t = dot(pos, dir) / lenSq;\n } else {\n t = 0.0;\n }\n }\n gl_FragColor = sampleGradient(t) * v_single_color.a;\n }\n else if(v_type == 2.0) {\n vec2 pos = translateTexturePosition(v_text_coord, v_texture_bounds);\n gl_FragColor = texture2D(u_sample, pos);\n }\n else {\n float r = distance(gl_PointCoord, vec2(0.5, 0.5));\n //根据距离设置片元\n if(r <= 0.5){\n // 方形区域片元距离几何中心半径小于0.5,像素颜色设置红色\n gl_FragColor = v_single_color;\n }else {\n // 方形区域距离几何中心半径不小于0.5的片元剪裁舍弃掉:\n discard;\n }\n }\n }\n"),ft=function(){function n(t,e){h(this,n),this.graph=t,this.option=e||{},this.style={globalAlpha:1},this.stateStack=[],this.transformMatrix=[1,0,0,1,0,0]}return l(n,[{key:"context",get:function(){if(this.graph)return this.graph.context}},{key:"save",value:function(){this.stateStack.push({transformMatrix:x(this.transformMatrix),style:s({},this.style)})}},{key:"restore",value:function(){var t;0<this.stateStack.length&&(t=this.stateStack.pop(),this.transformMatrix=t.transformMatrix,this.style=t.style)}},{key:"translate",value:function(t,e){this.transformMatrix[4]+=t*this.transformMatrix[0]+e*this.transformMatrix[2],this.transformMatrix[5]+=t*this.transformMatrix[1]+e*this.transformMatrix[3]}},{key:"scale",value:function(t,e){this.transformMatrix[0]*=t,this.transformMatrix[1]*=t,this.transformMatrix[2]*=e,this.transformMatrix[3]*=e}},{key:"rotate",value:function(t){var e=Math.cos(t),n=Math.sin(t),i=g(this.transformMatrix,4),r=i[0],o=i[1],t=i[2],i=i[3];this.transformMatrix[0]=r*e-o*n,this.transformMatrix[1]=r*n+o*e,this.transformMatrix[2]=t*e-i*n,this.transformMatrix[3]=t*n+i*e}},{key:"transform",value:function(t,e,n,i,r,o){var s=g(this.transformMatrix,6),a=s[0],h=s[1],l=s[2],u=s[3],c=s[4],s=s[5];this.transformMatrix[0]=t*a+e*l,this.transformMatrix[1]=t*h+e*u,this.transformMatrix[2]=n*a+i*l,this.transformMatrix[3]=n*h+i*u,this.transformMatrix[4]=r*a+o*l+c,this.transformMatrix[5]=r*h+o*u+s}},{key:"applyTransform",value:function(t){var e=g(this.transformMatrix,6),n=e[0],i=e[1],r=e[2],o=e[3],s=e[4],e=e[5];return{x:n*t.x+r*t.y+s,y:i*t.x+o*t.y+e}}},{key:"_measureCtx",get:function(){if(!this.__measureCtx)try{var t;"undefined"!=typeof document&&((t=document.createElement("canvas")).width=t.height=1,this.__measureCtx=t.getContext("2d"))}catch(t){this.__measureCtx=null}return this.__measureCtx}},{key:"program",get:function(){return this.graph.context.pathProgram||(this.graph.context.pathProgram=this.createProgram(ut,ct))}},{key:"setStyle",value:function(){var t,e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:this.style;"string"==typeof e&&((t={})[e]=1<arguments.length&&void 0!==arguments[1]?arguments[1]:"",e=t),this.style=s(s({},this.style),e)}},{key:"convertColor",value:function(t){return!this.isGradient(t)&&"object"===d(t="string"==typeof t&&"string"==typeof(t=this.graph.utils.hexToRGBA(t))?this.__parseCSSColor(t):t)&&void 0!==t.r?this.graph.utils.rgbToDecimal(t):t}},{key:"__parseCSSColor",value:function(t){var e=this._measureCtx;if(!e)return{r:0,g:0,b:0,a:0};try{e.clearRect(0,0,1,1),e.fillStyle="#000000",e.fillStyle=t,e.fillRect(0,0,1,1);var n=g(e.getImageData(0,0,1,1).data,4),i=n[0],r=n[1],o=n[2],s=n[3];return"#000000"===e.fillStyle&&"#000000"!==t&&"black"!==t?{r:0,g:0,b:0,a:0}:{r:i,g:r,b:o,a:s/255}}catch(t){return{r:0,g:0,b:0,a:0}}}},{key:"createProgram",value:function(t,e){return st(this.context,t,e)}},{key:"useProgram",value:function(){var t=(t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:this.program).program||t;return this.context.__curent_program===t?t:(at(this.context,t.program||t),this.context.__curent_program=t)}},{key:"getAttribLocation",value:function(t){return this.context.getAttribLocation(this.program.program,t)}},{key:"getUniformLocation",value:function(t){return this.context.getUniformLocation(this.program.program,t)}},{key:"writeVertexAttrib",value:function(t,e){var n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:2,i=3<arguments.length&&void 0!==arguments[3]?arguments[3]:0,r=4<arguments.length&&void 0!==arguments[4]?arguments[4]:0,o=5<arguments.length&&void 0!==arguments[5]?arguments[5]:this.context.FLOAT;return t.attr=e,function(t,e,n,i,r,o,s){return i=3<arguments.length&&void 0!==i?i:2,r=4<arguments.length&&void 0!==r?r:0,o=5<arguments.length&&void 0!==o?o:0,s=6<arguments.length&&void 0!==s?s:t.FLOAT,t.bindBuffer(e.type,e.buffer),t.vertexAttribPointer(n.location,i,s,!1,r*e.unitSize,o),t.enableVertexAttribArray(n.location),e}(this.context,t,e,n,i,r,o)}},{key:"disableVertexAttribArray",value:function(t){try{return t?this.context.disableVertexAttribArray(t.location):t}catch(t){console.error(t)}return t}},{key:"createFloat32Buffer",value:function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:this.context.ARRAY_BUFFER,n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:this.context.STATIC_DRAW;return s({data:t},function(t,e,n,i){return n=2<arguments.length&&void 0!==n?n:t.ARRAY_BUFFER,i=3<arguments.length&&void 0!==i?i:t.STATIC_DRAW,ht(t,new Float32Array(e),n,i)}(this.context,t,e,n))}},{key:"createUint16Buffer",value:function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:this.context.ARRAY_BUFFER,n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:this.context.STATIC_DRAW;return s({data:t},function(t,e,n,i){return n=2<arguments.length&&void 0!==n?n:t.ARRAY_BUFFER,i=3<arguments.length&&void 0!==i?i:t.STATIC_DRAW,ht(t,new Uint16Array(e),n,i)}(this.context,t,e,n))}},{key:"deleteBuffer",value:function(e){try{if(!e)return;var t=e.buffer||e;if(t)return n=this.context,i=t,void n.deleteBuffer(i.buffer||i)}catch(t){console.log(e),console.error(t)}var n,i;return e}},{key:"create2DTexture",value:function(){return lt(this.context)}},{key:"createImgTexture",value:function(t){return e=this.context,n=t,t=lt(e),e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,n),{texture:t};var e,n}},{key:"createDataTexture",value:function(t){return e=this.context,n=t,i=new Uint8Array(n.data||n),t=lt(e),e.texImage2D(e.TEXTURE_2D,0,e.RGBA,n.width||1,n.height||1,0,e.RGBA,e.UNSIGNED_BYTE,i),{texture:t};var e,n,i}},{key:"deleteTexture",value:function(t){try{return e=this.context,n=t.texture||t,e.deleteTexture(n)}catch(t){console.error(t)}var e,n;return t}},{key:"earCutPoints",value:function(t){return O(this.pointsToArray(t))}},{key:"earCutPointsToTriangles",value:function(t){this.earCutCache=this.earCutCache||(this.earCutCache={});var e=t.length,e=e+"_"+t[0].x+"_"+t[0].y+"_"+t[e-1].x+"_"+t[e-1].y;if(this.earCutCache[e])return this.earCutCache[e];for(var n=this.earCutPoints(t),i=[],r=0;r<n.length;r+=3){var o=t[n[r]],s=t[n[r+1]],a=t[n[r+2]];i.push([o,s,a])}return this.earCutCache[e]=i}},{key:"pointsToArray",value:function(t){var e;return(e=[]).concat.apply(e,x(t.map(function(t){return[t.x,t.y]})))}},{key:"arrayToPoints",value:function(t){for(var e=[],n=0;n<t.length;n+=2)e.push({x:t[n],y:t[n+1]});return e}},{key:"createLinearGradient",value:function(t,e,n,i,r){return new Q("linear",{x1:t,y1:e,x2:n,y2:i,bounds:r,control:this})}},{key:"createRadialGradient",value:function(t,e,n,i,r,o,s){return new Q("radial",{x1:t,y1:e,r1:n,x2:i,y2:r,r2:o,bounds:s,control:this})}},{key:"isGradient",value:function(t){return t&&t instanceof Q}},{key:"testSize",value:function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:this.style,n=this._measureCtx;if(!n)return{width:15,height:e.fontSize||15};n.save&&n.save(),(e.font||e.fontSize)&&(n.font=e.font||e.fontSize+"px "+e.fontFamily);t=n.measureText?n.measureText(t):{width:15};return n.restore&&n.restore(),t.height=e.fontSize?parseInt(e.fontSize):15,t}}]),n}(),dt=function(){u(i,ft);var n=v(i);function i(t,e){return h(this,i),(t=n.call(this,t,e)).isRegular=e.isRegular||!1,t.needCut=e.needCut||!1,t.control=e.control,t.points=[],t.__cachedBuffers=[],t.__cachedTexture=null,t.__cachedTextureKey=null,t}return l(i,[{key:"dispose",value:function(){var t,e=_(this.__cachedBuffers);try{for(e.s();!(t=e.n()).done;){var n=t.value;this.deleteBuffer(n)}}catch(t){e.e(t)}finally{e.f()}this.__cachedBuffers=[],this.__cachedTexture&&(this.deleteTexture(this.__cachedTexture),this.__cachedTexture=null,this.__cachedTextureKey=null)}},{key:"getOrCreateBuffer",value:function(t,e){var n=this.__cachedBuffers.find(function(t){return t.attr===e});if(n){var i=this.context,r=new Float32Array(t);return i.bindBuffer(i.ARRAY_BUFFER,n.buffer),i.bufferData(i.ARRAY_BUFFER,r,i.DYNAMIC_DRAW),n.data=t,n}return(n=this.createFloat32Buffer(t)).attr=e,this.__cachedBuffers.push(n),n}},{key:"applyTransform",value:function(t){return y(r(i.prototype),"applyTransform",this).call(this,t)}},{key:"setParentBounds",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:this.parentAbsoluteBounds;t&&(this.parentAbsoluteBounds=t);var e=this.graph.width/2,t=this.graph.height/2;this.__lastCenterX===e&&this.__lastCenterY===t||(this.context.uniform2f(this.program.uniforms.a_center_point.location,e,t),this.__lastCenterX=e,this.__lastCenterY=t)}},{key:"setFragColor",value:function(t){if(!Array.isArray(t))return void 0===(t=this.convertColor(t)).a&&(t.a=1),this.context.uniform4f(this.program.uniforms.v_single_color.location,t.r,t.g,t.b,t.a*this.style.globalAlpha),null;var e,n=[],i=_(t);try{for(i.s();!(e=i.n()).done;){var r=e.value;void 0===(r=this.convertColor(r)).a&&(r.a=1),n.push(r.r,r.g,r.b,r.a*this.style.globalAlpha)}}catch(t){i.e(t)}finally{i.f()}t=this.createFloat32Buffer(n);return this.writeVertexAttrib(t,this.program.attrs.a_color,4,0,0),t.attr=this.program.attrs.a_color,t}},{key:"beginDraw",value:function(){this.useProgram()}},{key:"draw",value:function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:this.parentAbsoluteBounds;this.setParentBounds(e),this.points=t}},{key:"endDraw",value:function(){this.points&&delete this.points,this.pathPoints&&delete this.pathPoints,this.needClose=!1}},{key:"closePath",value:function(){this.needClose=!0}},{key:"writePoints",value:function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:this.program.attrs.a_position,n=[],i=g(this.transformMatrix,6),r=i[0],o=i[1],s=i[2],a=i[3],h=i[4],i=i[5],l=this.parentAbsoluteBounds.left,u=this.parentAbsoluteBounds.top;if(1===r&&0===o&&0===s&&1===a&&0===h&&0===i)for(var c=0;c<t.length;c++)n.push(t[c].x+l,t[c].y+u);else{var f,d=_(t);try{for(d.s();!(f=d.n()).done;){var p=f.value,v=this.applyTransform(p);n.push(v.x+l,v.y+u)}}catch(t){d.e(t)}finally{d.f()}}a=new Float32Array(n),h=this.context;if(0<this.__cachedBuffers.length){i=this.__cachedBuffers.find(function(t){return t.attr===e});if(i)return h.bindBuffer(h.ARRAY_BUFFER,i.buffer),h.bufferData(h.ARRAY_BUFFER,a,h.DYNAMIC_DRAW),i.data=n,this.writeVertexAttrib(i,e,2,0,0),i}h=this.createFloat32Buffer(a,h.ARRAY_BUFFER,h.DYNAMIC_DRAW);return this.writeVertexAttrib(h,e,2,0,0),h.attr=e,this.__cachedBuffers.push(h),h}},{key:"genLinePoints",value:function(t,e){var n=[t],i=e.x-t.x,r=e.y-t.y;if(0!=i||0!=r)for(var o=Math.sqrt(Math.pow(i,2)+Math.pow(r,2)),s=i/o,a=r/o,h=.5;h<o;h+=.5){var l=t.x+s*h,u=t.y+a*h;n.push({x:l,y:u})}return n.push(e),n}},{key:"pathToPoints",value:function(){for(var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:this.points,e=null,n=[],i=0;i<t.length;i++){var r,o=t[i];e&&!o.m?(r=this.genLinePoints(e,o),n.push.apply(n,x(r))):e&&!n.includes(e)&&n.push(e),e=o}return n.includes(e)||n.push(e),n}},{key:"equalPoint",value:function(t,e){return t.x===e.x&&t.y===e.y}},{key:"splitSubPaths",value:function(t){for(var e=[],n=[],i=0;i<t.length;i++){var r=t[i];r.m&&0<n.length&&(e.push(n),n=[]),n.push(r)}0<n.length&&e.push(n);for(var o=-1,s=0,a=0;a<e.length;a++){var h=Math.abs(this.polygonArea(e[a]));o<h&&(o=h,s=a)}for(var l=e[s],u=[],c=0;c<e.length;c++)c!==s&&u.push(e[c]);return{outerPoints:l,holes:u}}},{key:"polygonArea",value:function(t){for(var e=0,n=t.length,i=0;i<n;i++){var r=(i+1)%n;e+=t[i].x*t[r].y,e-=t[r].x*t[i].y}return e/2}},{key:"fillWithHoles",value:function(t,e){var n,i=this,r=2<arguments.length&&void 0!==arguments[2]&&arguments[2],o=x(t),s=[],a=_(e);try{for(a.s();!(n=a.n()).done;){var h=n.value;s.push(o.length),o.push.apply(o,x(h))}}catch(t){a.e(t)}finally{a.f()}var l,u=[],c=_(o);try{for(c.s();!(l=c.n()).done;){var f=l.value;u.push(f.x,f.y)}}catch(t){c.e(t)}finally{c.f()}var d=O(u,s,2);if(d&&!(d.length<3)){for(var p=[],v=[],y=0;y<d.length;y++){var g=o[d[y]];p.push(g.x,g.y),r&&v.push(g.x,g.y)}var m=this.context,t=new Float32Array(p),e=this.__cachedBuffers.find(function(t){return t.attr===i.program.attrs.a_position});e?(m.bindBuffer(m.ARRAY_BUFFER,e.buffer),m.bufferData(m.ARRAY_BUFFER,t,m.DYNAMIC_DRAW)):((e=this.createFloat32Buffer(t,m.ARRAY_BUFFER,m.DYNAMIC_DRAW)).attr=this.program.attrs.a_position,this.__cachedBuffers.push(e)),this.writeVertexAttrib(e,this.program.attrs.a_position,2,0,0),r&&v.length&&(t=new Float32Array(v),(e=this.__cachedBuffers.find(function(t){return t.attr===i.program.attrs.a_text_coord}))?(m.bindBuffer(m.ARRAY_BUFFER,e.buffer),m.bufferData(m.ARRAY_BUFFER,t,m.DYNAMIC_DRAW)):((e=this.createFloat32Buffer(t,m.ARRAY_BUFFER,m.DYNAMIC_DRAW)).attr=this.program.attrs.a_text_coord,this.__cachedBuffers.push(e)),this.writeVertexAttrib(e,this.program.attrs.a_text_coord,2,0,0)),m.drawArrays(m.TRIANGLES,0,p.length/2)}}},{key:"pathToLines",value:function(t){for(var e=null,n=[],i=0;i<t.length;i++){var r=t[i];!e||r.m||e.x==r.x&&e.y==r.y||n.push({start:e,end:r}),e=r}return n}},{key:"cutLines",value:function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:0,n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:0;if(t&&t.length<3)return t;for(n=Math.max(e+1,n);e<t.length;){for(var i=t[e];n<t.length;){var r=t[n];if(this.equalPoint(i.start,r.start)||this.equalPoint(i.end,r.end)||this.equalPoint(i.start,r.end)||this.equalPoint(i.end,r.start))n++;else{var o,s,a=!1,h=this.getIntersection(i,r);if(h&&(this.equalPoint(i.start,h)||this.equalPoint(i.end,h)||(o={start:i.start,end:h},s={start:h,end:i.end},t.splice(e,1,o,s),a=!0,n++),this.equalPoint(r.start,h)||this.equalPoint(r.end,h)||(s={start:r.start,end:h},r={start:h,end:r.end},t.splice(n,1,s,r),n++)),n++,a)return this.cutLines(t,e,n)}}n=++e+1}return t}},{key:"getIntersection",value:function(t,e){if(this.equalPoint(t.start,e.start)||this.equalPoint(t.start,e.end))return t.start;if(this.equalPoint(t.end,e.start)||this.equalPoint(t.end,e.end))return t.end;var n=(t.start.x-e.start.x)*(t.end.y-e.start.y)-(t.start.y-e.start.y)*(t.end.x-e.start.x),i=(t.start.x-e.end.x)*(t.end.y-e.end.y)-(t.start.y-e.end.y)*(t.end.x-e.end.x);if(0<n*i)return null;e=(e.start.x-t.start.x)*(e.end.y-t.start.y)-(e.start.y-t.start.y)*(e.end.x-t.start.x);if(0<e*(e+n-i))return null;if(i==n)return null;i=e/(i-n),n=i*(t.end.x-t.start.x),i*=t.end.y-t.start.y;return{x:t.start.x+n,y:t.start.y+i}}},{key:"getIntersectionLines",value:function(t,e,n){var i=3<arguments.length&&void 0!==arguments[3]?arguments[3]:t.end,r=4<arguments.length&&void 0!==arguments[4]?arguments[4]:[],o=5<arguments.length&&void 0!==arguments[5]?arguments[5]:null,s={line:t,polygons:[]};if(r.push(i),o&&this.equalPoint(o.line.start,i))return r.unshift(o.line.start),o.polygons.push(r),s;for(;n<e.length;n++){var a=e[n];this.equalPoint(i,a.start)?r.includes(a.end)||this.getIntersectionLines(a,e,n+1,a.end,x(r),o||s):this.equalPoint(i,a.end)&&(r.includes(a.start)||this.getIntersectionLines(a,e,n+1,a.start,x(r),o||s))}return s}},{key:"getPolygon",value:function(t){var e=[];if((n=this.pathToLines(t))&&2<n.length)for(var n=this.cutLines(n),i=0;i<n.length-1;i++){var r=n[i],r=this.getIntersectionLines(r,n,i+1);r.polygons.length&&e.push.apply(e,x(r.polygons))}return e}},{key:"getTriangles",value:function(t){this.trianglesCache=this.trianglesCache||(this.trianglesCache={});var e=t.length,e=e+"_"+t[0].x+"_"+t[0].y+"_"+t[e-1].x+"_"+t[e-1].y;if(this.trianglesCache[e])return this.trianglesCache[e];var n=[],t=this.getPolygon(t);if(t.length){var i,r=_(t);try{for(r.s();!(i=r.n()).done;){var o=i.value,s=this.earCutPointsToTriangles(o);n.push.apply(n,x(s))}}catch(t){r.e(t)}finally{r.f()}}return this.trianglesCache[e]=n}},{key:"stroke",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:this.points,e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:this.style.strokeStyle,n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:this.style.lineWidth;if(t&&t.length){var i=null;if(e&&(i=this.setFragColor(e)),n&&this.context.uniform1f(this.program.uniforms.a_point_size.location,n),this.program.uniforms.a_type&&this.context.uniform1i(this.program.uniforms.a_type.location,1===t.length?4:1),t&&t.length){var r=n<=1.2,e=t.some&&t.some(function(t){return t.m}),n=!e&&this.needCut;if(r&&(e||n))if(e){for(var o=[],s=0;s<t.length;s++)t[s].m&&0<o.length&&(this.writePoints(o),this.context.drawArrays(this.context.LINE_LOOP,0,o.length),o=[]),o.push(t[s]);1<o.length&&(this.writePoints(o),this.context.drawArrays(this.context.LINE_LOOP,0,o.length))}else n&&(e=Math.floor(t.length/2),n=t.slice(0,e),e=t.slice(e),1<n.length&&(this.writePoints(n),this.context.drawArrays(this.context.LINE_LOOP,0,n.length)),1<e.length&&(this.writePoints(e),this.context.drawArrays(this.context.LINE_LOOP,0,e.length)));else t=r?t:this.pathToPoints(t),this.writePoints(t),this.context.drawArrays(r?this.context.LINE_LOOP:this.context.POINTS,0,t.length)}i&&this.disableVertexAttribArray(i&&i.attr)}}},{key:"fill",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{left:0,top:0,width:0,height:0},e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:1;this.points&&this.points.length&&(this.style.fillStyle&&this.fillColor(this.style.fillStyle,this.points,t,e),this.style.fillImage&&this.fillImage(this.style.fillImage,this.points,t,e))}},{key:"fillColor",value:function(t,e,n){var i=3<arguments.length&&void 0!==arguments[3]?arguments[3]:1;if(this.isGradient(t))return this.fillGradient(t,e,n);this.context.uniform1i(this.program.uniforms.a_type.location,i);t=this.setFragColor(t);this.fillPolygons(e),t&&this.disableVertexAttribArray(t&&t.attr)}},{key:"fillGradient",value:function(t,e,n){var i=t.toUniformParams();if(i){if(this.context.uniform1i(this.program.uniforms.a_type.location,5),this.context.uniform4f(this.program.uniforms.v_single_color.location,1,1,1,this.style.globalAlpha),this.program.uniforms.u_gradient_type&&this.context.uniform1i(this.program.uniforms.u_gradient_type.location,i.gradientType),this.program.uniforms.u_gradient_start&&this.context.uniform4fv(this.program.uniforms.u_gradient_start.location,i.gradientStart),this.program.uniforms.u_gradient_end&&this.context.uniform4fv(this.program.uniforms.u_gradient_end.location,i.gradientEnd),this.program.uniforms.u_gradient_stop_count&&this.context.uniform1i(this.program.uniforms.u_gradient_stop_count.location,i.stopCount),this.program.uniforms.u_gradient_offsets){for(var r=new Float32Array(16),o=0;o<i.stopCount;o++)r[o]=i.stops[5*o];for(var s=i.stopCount;s<16;s++)r[s]=2;this.context.uniform1fv(this.program.uniforms.u_gradient_offsets.location,r)}if(this.program.uniforms.u_gradient_colors){for(var a=new Float32Array(64),h=0;h<i.stopCount;h++)a[4*h+0]=i.stops[5*h+1],a[4*h+1]=i.stops[5*h+2],a[4*h+2]=i.stops[5*h+3],a[4*h+3]=i.stops[5*h+4];if(0<i.stopCount)for(var l=i.stops[5*(i.stopCount-1)+1],u=i.stops[5*(i.stopCount-1)+2],c=i.stops[5*(i.stopCount-1)+3],f=i.stops[5*(i.stopCount-1)+4],d=i.stopCount;d<16;d++)a[4*d+0]=l,a[4*d+1]=u,a[4*d+2]=c,a[4*d+3]=f;this.context.uniform4fv(this.program.uniforms.u_gradient_colors.location,a)}this.fillPolygons(e,!0),this.disableVertexAttribArray(this.program.attrs.a_text_coord)}}},{key:"fillImage",value:function(t,e,n){var i,r;t&&(i=null,t instanceof ImageData?(r="".concat(t.width,"_").concat(t.height,"_").concat(n.width,"_").concat(n.height,"_").concat(n.left,"_").concat(n.top),this.__cachedTexture&&this.__cachedTextureKey===r?i=this.__cachedTexture:(i=this.createDataTexture(t),this.__cachedTexture&&this.deleteTexture(this.__cachedTexture),this.__cachedTexture=i,this.__cachedTextureKey=r)):i=this.createImgTexture(t),this.context.uniform1i(this.program.uniforms.u_sample.location,0),this.context.uniform4f(this.program.uniforms.v_texture_bounds.location,n.left+this.parentAbsoluteBounds.left,n.top+this.parentAbsoluteBounds.top,n.width,n.height),this.fillTexture(e),t instanceof ImageData||this.deleteTexture(i))}},{key:"fillTexture",value:function(t){t&&t.length&&(this.context.uniform1i(this.program.uniforms.a_type.location,2),this.fillPolygons(t,!0),this.disableVertexAttribArray(this.program.attrs.a_text_coord))}},{key:"fillPolygons",value:function(t){var e=this,n=1<arguments.length&&void 0!==arguments[1]&&arguments[1];if(t.length<=3)return this.writePoints(t),n&&this.writePoints(t,this.program.attrs.a_text_coord),void this.context.drawArrays(this.context.TRIANGLE_FAN,0,t.length);if(this.isRegular){if(t.some&&t.some(function(t){return t.m})){var i=this.splitSubPaths(t),r=i.outerPoints,i=i.holes;return void this.fillWithHoles(r,i,n)}if(this.needCut&&6<=t.length){var o=Math.floor(t.length/2),s=t.slice(0,o),o=t.slice(o);return void(Math.abs(this.polygonArea(s))<=Math.abs(this.polygonArea(o))?this.fillWithHoles(o,[s],n):this.fillWithHoles(s,[o],n))}return this.writePoints(t),n&&this.writePoints(t,this.program.attrs.a_text_coord),void this.context.drawArrays(this.context.TRIANGLE_FAN,0,t.length)}s=this.needCut?this.earCutPointsToTriangles(t):this.getTriangles(t);if(s.length){var a,h=[],l=[],u=_(s);try{for(u.s();!(a=u.n()).done;){var c,f=_(a.value);try{for(f.s();!(c=f.n()).done;){var d=c.value;h.push(d.x,d.y),n&&l.push(d.x,d.y)}}catch(t){f.e(t)}finally{f.f()}}}catch(t){u.e(t)}finally{u.f()}o=new Float32Array(h),t=this.context,s=this.__cachedBuffers.find(function(t){return t.attr===e.program.attrs.a_position});s?(t.bindBuffer(t.ARRAY_BUFFER,s.buffer),t.bufferData(t.ARRAY_BUFFER,o,t.DYNAMIC_DRAW)):((s=this.createFloat32Buffer(o,t.ARRAY_BUFFER,t.DYNAMIC_DRAW)).attr=this.program.attrs.a_position,this.__cachedBuffers.push(s)),this.writeVertexAttrib(s,this.program.attrs.a_position,2,0,0),n&&l.length&&(o=new Float32Array(l),(s=this.__cachedBuffers.find(function(t){return t.attr===e.program.attrs.a_text_coord}))?(t.bindBuffer(t.ARRAY_BUFFER,s.buffer),t.bufferData(t.ARRAY_BUFFER,o,t.DYNAMIC_DRAW)):((s=this.createFloat32Buffer(o,t.ARRAY_BUFFER,t.DYNAMIC_DRAW)).attr=this.program.attrs.a_text_coord,this.__cachedBuffers.push(s)),this.writeVertexAttrib(s,this.program.attrs.a_text_coord,2,0,0)),t.drawArrays(t.TRIANGLES,0,h.length/2)}}},{key:"drawImage",value:function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:0,n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:0,i=3<arguments.length&&void 0!==arguments[3]?arguments[3]:t.width,r=4<arguments.length&&void 0!==arguments[4]?arguments[4]:t.height,i=i||t.width,r=r||t.height;this.fillImage(t,this.points,{left:e,top:n,width:i,height:r})}},{key:"drawText",value:function(t,e,n,i){if(!i.width||!i.height)return null;if("undefined"==typeof document)return null;var r=this.__textCanvas;r||(r=document.createElement("canvas"),this.__textCanvas=r),r.width=i.width,r.height=i.height;var o=r.getContext("2d",{willReadFrequently:!0});o.clearRect(0,0,r.width,r.height),o.font=this.style.font||this.style.fontSize+"px "+this.style.fontFamily,e-=i.left,n-=i.top,this.style.fillStyle&&(o.fillStyle=this.graph.utils.toColor(this.style.fillStyle)),this.style.strokeStyle&&(o.strokeStyle=this.graph.utils.toColor(this.style.strokeStyle)),this.style.shadowColor&&(o.shadowColor=this.graph.utils.toColor(this.style.shadowColor)),this.style.shadowBlur&&(o.shadowBlur=this.style.shadowBlur),void 0!==this.style.shadowOffsetX&&(o.shadowOffsetX=this.style.shadowOffsetX),void 0!==this.style.shadowOffsetY&&(o.shadowOffsetY=this.style.shadowOffsetY),this.style.textAlign&&(o.textAlign=this.style.textAlign),this.style.textBaseline&&(o.textBaseline=this.style.textBaseline),this.style.fillStyle&&o.fillText&&(this.style.maxWidth?o.fillText(t,e,n,this.style.maxWidth):o.fillText(t,e,n)),this.style.strokeStyle&&o.strokeText&&(this.style.maxWidth?o.strokeText(t,e,n,this.style.maxWidth):o.strokeText(t,e,n));r=o.getImageData(0,0,r.width,r.height);this.fillImage(r,this.points,i)}}]),i}(),pt={fill:"fillStyle",fillImage:"fillImage",stroke:"strokeStyle","shadow.blur":"shadowBlur","shadow.x":"shadowOffsetX","shadow.y":"shadowOffsetY","shadow.color":"shadowColor",lineWidth:"lineWidth",miterLimit:"miterLimit",fillStyle:"fillStyle",strokeStyle:"strokeStyle",font:"font",opacity:"globalAlpha",textAlign:"textAlign",textBaseline:"textBaseline",shadowBlur:"shadowBlur",shadowOffsetX:"shadowOffsetX",shadowOffsetY:"shadowOffsetY",shadowColor:"shadowColor",lineJoin:"lineJoin",lineCap:"lineCap",lineDashOffset:"lineDashOffset",globalCompositeOperation:"globalCompositeOperation"},vt=function(){u(r,P);var i=v(r);function r(t,e){var n;return h(this,r),(n=i.call(this,t=t||{})).property("type",e||(this instanceof r?this.constructor:void 0).name),n.style=t&&t.style?t.style:{},n.width=t.width||0,n.height=t.height||0,n.hitArea=t.hitArea||null,t.position&&(n.position=t.position),n.graph=t.graph||null,n.zIndex=t.zIndex||0,n.interactive=void 0!==t.interactive&&t.interactive,"webgl"===n.mode&&(n.webglControl=new dt(n.graph,{style:n.style,control:f(n),isRegular:t.isRegular,needCut:t.needCut})),n.initializing(),n.on=n.bind,n.option=t,n}return l(r,[{key:"type",get:function(){return this.property("type")}},{key:"context",get:function(){var t=this.property("context");if(t)return t;if(this.is("jmGraph")&&this.canvas&&this.canvas.getContext)return this.context=this.canvas.getContext(this.mode||"2d");t=this.graph;return t?t.context:t.canvas.getContext(this.mode||"2d")},set:function(t){return this.property("context",t)}},{key:"style",get:function(){return this.property("style")||this.property("style",{})},set:function(t){return this.needUpdate=!0,this.property("style",t)}},{key:"visible",get:function(){var t=this.property("visible");return t=void 0===t?this.property("visible",!0):t},set:function(t){return this.needUpdate=!0,this.property("visible",t)}},{key:"interactive",get:function(){return this.property("interactive")},set:function(t){return this.property("interactive",t)}},{key:"hitArea",get:function(){return this.property("hitArea")},set:function(t){return this.property("hitArea",t)}},{key:"children",get:function(){return this.property("children")||this.property("children",new w)},set:function(t){return this.needUpdate=!0,this.property("children",t)}},{key:"width",get:function(){var t=this.property("width");return t=void 0===t?this.property("width",0):t},set:function(t){return this.needUpdate=!0,this.property("width",t)}},{key:"height",get:function(){var t=this.property("height");return t=void 0===t?this.property("height",0):t},set:function(t){return this.needUpdate=!0,this.property("height",t)}},{key:"zIndex",get:function(){return this.property("zIndex")||this.property("zIndex",0)},set:function(t){return this.property("zIndex",t),this.children.sort(),this.needUpdate=!0,t}},{key:"cursor",get:function(){var t=this.graph;if(t)return t.css("cursor")},set:function(t){var e=this.graph;e&&e.css("cursor",t)}},{key:"initializing",value:function(){var e=this;this.children=this.children||new w;var n=this.children.add;this.children.add=function(t){if("object"===d(t))return t.parent&&t.parent!=e&&t.parent.children&&t.parent.children.remove(t),t.parent=e,this.contain(t)&&this.oremove(t),n.call(this,t),t.emit("add",t),e.needUpdate=!0,e.graph&&(t.graph=e.graph),this.sort(),t},this.children.oremove=this.children.remove,this.children.remove=function(t){"object"===d(t)&&(t.parent=null,t.graph=null,t.remove(!0),this.oremove(t),e.needUpdate=!0)},this.children.sort=function(){var t,i={};for(t in this.each(function(t,e){var n;e&&(!(n=e.zIndex)&&e.style&&e.style.zIndex&&(n=Number(e.style.zIndex),isNaN(n)&&(n=e.style.zIndex||0)),(i[n]||(i[n]=[])).push(e))}),this.splice(0,this.length),i)n.call(this,i[t])},this.children.clear=function(){this.each(function(t,e){this.remove(e)},!0)},this.needUpdate=!0}},{key:"setStyle",value:function(t){var u=this;if(t=t||this.style){var e,n,i=function t(e,n,i){if(e){var r=e;if("function"==typeof r)try{r=r.call(u)}catch(t){return void console.warn(t)}var o,s=d(r),i=pt[i||n];if(r instanceof R||"string"==s&&-1<r.indexOf("-gradient"))t((r="string"==s&&-1<r.indexOf("-gradient")?new R(r):r).toGradient(u),i||n);else if(i)u.webglControl?u.webglControl.setStyle(i,r):("string"==s&&-1<["fillStyle","strokeStyle","shadowColor"].indexOf(i)&&(r=A.toColor(r)),u.context[i]=r);else switch(n){case"shadow":if("string"==s){t(new S(r),n);break}for(var a in r)t(r[a],a,n+"."+a);break;case"translate":break;case"rotation":if(void 0===r.angle||isNaN(r.angle))break;r=u.getRotation(r),u.__translateAbsolutePosition=u.toAbsolutePoint({x:r.x,y:r.y}),u.context.translate&&u.context.translate(u.__translateAbsolutePosition.x,u.__translateAbsolutePosition.y),u.context.rotate&&u.context.rotate(r.angle),u.context.translate&&u.context.translate(-u.__translateAbsolutePosition.x,-u.__translateAbsolutePosition.y);break;case"transform":if(!u.context.transform)break;Array.isArray(r)?u.context.transform.apply(u.context,r):"object"==d(r)&&u.context.transform(r.scaleX||1,r.skewX||0,r.skewY||0,r.scaleY||1,r.offsetX||0,r.offsetY||0);break;case"cursor":u.cursor=r;break;case"lineDash":if(!u.context.setLineDash)break;"string"==typeof r?o=r.split(",").map(function(t){return parseFloat(t.trim())}).filter(function(t){return!isNaN(t)}):Array.isArray(r)&&(o=r.map(function(t){return parseFloat(t)}).filter(function(t){return!isNaN(t)})),o&&o.length?u.context.setLineDash(o):u.context.setLineDash([]);break;case"lineDashOffset":if(!u.context.setLineDash)break;u.context.lineDashOffset=Number(r)||0;break;case"filter":if(void 0===u.context.filter)break;r instanceof M?u.context.filter=r.toCanvasFilter():"string"==typeof r?u.context.filter=r||"none":"object"===d(r)&&(u.context.filter=new M(r).toCanvasFilter());break;case"globalCompositeOperation":if(!u.context.globalCompositeOperation)break;u.context.globalCompositeOperation=r;break;case"clipPath":if(!u.context.clip)break;if(r&&r.points&&0<r.points.length){var h=(u.parent&&u.parent.absoluteBounds?u.parent:u).absoluteBounds;u.context.beginPath(),u.context.moveTo(r.points[0].x+(h?h.left:0),r.points[0].y+(h?h.top:0));for(var l=1;l<r.points.length;l++)r.points[l].m?u.context.moveTo(r.points[l].x+(h?h.left:0),r.points[l].y+(h?h.top:0)):u.context.lineTo(r.points[l].x+(h?h.left:0),r.points[l].y+(h?h.top:0));r.style&&r.style.close&&u.context.closePath(),u.context.clip()}break;case"mask":if(!u.context.globalCompositeOperation)break;u.__mask=r;break;case"shadowColor":u.webglControl?u.webglControl.setStyle("shadowColor",r):u.context.shadowColor=A.toColor(r);break;case"shadowBlur":u.webglControl?u.webglControl.setStyle("shadowBlur",r):u.context.shadowBlur=Number(r)||0;break;case"shadowOffsetX":u.webglControl?u.webglControl.setStyle("shadowOffsetX",r):u.context.shadowOffsetX=Number(r)||0;break;case"shadowOffsetY":u.webglControl?u.webglControl.setStyle("shadowOffsetY",r):u.context.shadowOffsetY=Number(r)||0}}};for(e in this.translate&&i(this.translate,"translate"),this.transform&&i(this.transform,"transform"),t)"constructor"!==e&&("string"==(n=d(t[e]))&&-1<t[e].indexOf("-gradient")?t[e]=new R(t[e]):"string"==n&&"shadow"==e?t[e]=new S(t[e]):"string"==n&&"filter"==e&&(t[e]=new M(t[e])),i(t[e],e))}}},{key:"getBounds",value:function(t){if(this.bounds&&!t)return this.bounds;var e={};if("jmGraph"==this.type&&this.canvas)"function"==typeof this.canvas.width?e.right=this.canvas.width():this.width&&(e.right=this.width),"function"==typeof this.canvas.height?e.bottom=this.canvas.height():this.height&&(e.bottom=this.height);else if(this.points&&0<this.points.length){var n,i=_(this.points);try{for(i.s();!(n=i.n()).done;){var r=n.value;(void 0===e.left||e.left>r.x)&&(e.left=r.x),(void 0===e.top||e.top>r.y)&&(e.top=r.y),(void 0===e.right||e.right<r.x)&&(e.right=r.x),(void 0===e.bottom||e.bottom<r.y)&&(e.bottom=r.y)}}catch(t){i.e(t)}finally{i.f()}}else!this.getLocation||(t=this.getLocation())&&(e.left=t.left,e.top=t.top,e.right=t.left+t.width,e.bottom=t.top+t.height);return void 0===e.left&&(e.left=0),void 0===e.top&&(e.top=0),void 0===e.right&&(e.right=0),void 0===e.bottom&&(e.bottom=0),e.width=e.right-e.left,e.height=e.bottom-e.top,this.bounds=e}},{key:"getRotationBounds",value:function(){var t=(t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:null)||this.getRotation(),e=this.getBounds();if(!t||!t.angle)return e;var n,i={width:0,height:0,oldBounds:e},r=[];this.points&&0<this.points.length?r=A.clone(this.points,!0):!this.getLocation||(n=this.getLocation())&&r.push({x:n.left,y:n.top},{x:n.left+n.width,y:n.top},{x:n.left+n.width,y:n.top+n.height},{x:n.left,y:n.top+n.height});var o,s=_(r=A.rotatePoints(r,{x:t.x+e.left,y:t.y+e.top},t.angle));try{for(s.s();!(o=s.n()).done;){var a=o.value;(void 0===i.left||i.left>a.x)&&(i.left=a.x),(void 0===i.top||i.top>a.y)&&(i.top=a.y),(void 0===i.right||i.right<a.x)&&(i.right=a.x),(void 0===i.bottom||i.bottom<a.y)&&(i.bottom=a.y)}}catch(t){s.e(t)}finally{s.f()}return i.left||(i.left=0),i.top||(i.top=0),i.right||(i.right=0),i.bottom||(i.bottom=0),i.width=i.right-i.left,i.height=i.bottom-i.top,i}},{key:"getLocation",value:function(){var t=this.location={left:0,top:0,width:0,height:0},e=this.parent&&(A.checkPercent(this.width)||A.checkPercent(this.height)||this.position&&A.checkPercent(this.position.x)||this.position&&A.checkPercent(this.position.y));t.position="function"==typeof this.position?this.position():e?A.clone(this.position):this.position,t.center=this.center&&"function"==typeof this.center?this.center():e?A.clone(this.center):this.center,t.start=this.start&&"function"==typeof this.start?this.start():e?A.clone(this.start):this.start,t.end=this.end&&"function"==typeof this.end?this.end():e?A.clone(this.end):this.end,t.radius=this.radius,t.width=this.width,t.height=this.height;var n=this.style.margin,n=e&&n?A.clone(n,{}):n||{};return n.left=n.left||0,n.top=n.top||0,n.right=n.right||0,n.bottom=n.bottom||0,t.position?(t.left=t.position.x,t.top=t.position.y):(t.left=n.left,t.top=n.top),this.parent&&(n=this.parent.getBounds(),A.checkPercent(t.left)&&(t.left=A.percentToNumber(t.left)*n.width),A.checkPercent(t.top)&&(t.top=A.percentToNumber(t.top)*n.height),A.checkPercent(t.width)&&(t.width=A.percentToNumber(t.width)*n.width),A.checkPercent(t.height)&&(t.height=A.percentToNumber(t.height)*n.height),t.center&&(A.checkPercent(t.center.x)&&(t.center.x=A.percentToNumber(t.center.x)*n.width),A.checkPercent(t.center.y)&&(t.center.y=A.percentToNumber(t.center.y)*n.height)),t.radius&&A.checkPercent(t.radius)&&(t.radius=A.percentToNumber(t.radius)*Math.min(n.width,n.height))),t}},{key:"getRotation",value:function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:null;return(t=t||A.clone(this.style.rotation))?(e=e||this.getBounds(),void 0===t.x&&(t.x="50%"),void 0===t.y&&(t.y="50%"),A.checkPercent(t.x)&&(t.x=A.percentToNumber(t.x)*e.width),A.checkPercent(t.y)&&(t.y=A.percentToNumber(t.y)*e.height)):(t=this.parent&&this.parent.getRotation?this.parent.getRotation():null)&&(e=e||this.getBounds(),t.x-=e.left,t.y-=e.top),s(s({},t),{},{bounds:e})}},{key:"getTranslate",value:function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:null;if(!(t=t||this.style.translate))return{x:0,y:0};t={x:t.x||0,y:t.y||0};return A.checkPercent(t.x)&&(!e&&this.parent&&(e=this.parent.getBounds()),t.x=A.percentToNumber(t.x)*e.width),A.checkPercent(t.y)&&(!e&&this.parent&&(e=this.parent.getBounds()),t.y=A.percentToNumber(t.y)*e.height),t}},{key:"remove",value:function(){this.parent&&this.parent.children.remove(this)}},{key:"offset",value:function(t,e,n,i){n=!1!==n;var r=this.getLocation(!0),o=!1;if(r.position&&(r.left+=t,r.top+=e,this.position.x=r.left,this.position.y=r.top,o=!0),r.center&&(this.center.x=r.center.x+t,this.center.y=r.center.y+e,o=!0),r.start&&"object"==d(r.start)&&(this.start.x=r.start.x+t,this.start.y=r.start.y+e,o=!0),r.end&&"object"==d(r.end)&&(this.end.x=r.end.x+t,this.end.y=r.end.y+e,o=!0),0==o&&this.cpoints){var s=(this.cpoints,this.cpoints);if(s){for(var a=s.length,h=0;h<a;h++)s[h].x+=t,s[h].y+=e;o=!0}}if(0==o&&this.points){for(var l=this.points.length,u=0;u<l;u++)this.points[u].x+=t,this.points[u].y+=e;o=!0}this.emit("move",{offsetX:t,offsetY:e,trans:n,evt:i}),this.needUpdate=!0}},{key:"getAbsoluteBounds",value:function(){var t=this.getBounds();if(this.parent&&this.parent.absoluteBounds){var e=this.parent.absoluteBounds||this.parent.getAbsoluteBounds();return{left:e.left+t.left,top:e.top+t.top,right:e.left+t.right,bottom:e.top+t.bottom,width:t.width,height:t.height}}return t}},{key:"toAbsolutePoint",value:function(t){var e;return(t.x||t.y)&&(e=this.absoluteBounds||this.getAbsoluteBounds(),t.x=(t.x||0)+e.left,t.y=(t.y||0)+e.top),t}},{key:"toLocalPosition",value:function(t){var e=this.absoluteBounds||this.getAbsoluteBounds();return!!e&&{x:t.x-e.left,y:t.y-e.top}}},{key:"beginDraw",value:function(){this.getLocation(!0),this.context.beginPath&&this.context.beginPath(),this.webglControl&&this.webglControl.beginDraw&&this.webglControl.beginDraw()}},{key:"endDraw",value:function(){var t,e;this.style.close&&(this.webglControl&&this.webglControl.closePath(),this.context.closePath&&this.context.closePath()),this.webglControl?((e=this.style.fill||this.style.fillStyle)&&(t=this.getBounds(),this.webglControl.fill(t)),!this.style.stroke&&(e||this.is("jmGraph"))||this.webglControl.stroke(),this.webglControl.endDraw&&this.webglControl.endDraw()):((e=this.style.fill||this.style.fillStyle)&&this.context.fill&&this.context.fill(),(this.style.stroke||!e&&!this.is("jmGraph"))&&this.context.stroke&&this.context.stroke()),this.needUpdate=!1}},{key:"draw",value:function(){if(this.points&&0<this.points.length){var t=(this.parent&&this.parent.absoluteBounds?this.parent:this).absoluteBounds;if(this.webglControl)this.webglControl.setParentBounds(t),this.webglControl.draw(this.points);else if(this.context&&this.context.moveTo){this.context.moveTo(this.points[0].x+t.left,this.points[0].y+t.top);for(var e=this.points.length,n=1;n<e;n++){var i=this.points[n];i.m?this.context.moveTo(i.x+t.left,i.y+t.top):this.context.lineTo(i.x+t.left,i.y+t.top)}}}}},{key:"paint",value:function(t){if(!1!==t&&!1!==this.visible){this.initPoints&&this.initPoints(),this.bounds=null,this.absoluteBounds=this.getAbsoluteBounds();t=!0;!this.is("jmGraph")&&this.graph&&(this.absoluteBounds.left>=this.graph.width||this.absoluteBounds.top>=this.graph.height||this.absoluteBounds.right<=0||this.absoluteBounds.bottom<=0)&&(t=!1),this.context.save&&this.context.save(),this.emit("beginDraw",this),this.setStyle();var e=this.style.mask||this.__mask;if(e&&e.points&&this.context.globalCompositeOperation){t&&this.beginDraw&&this.beginDraw(),t&&this.draw&&this.draw(),t&&this.endDraw&&this.endDraw(),this.context.globalCompositeOperation="destination-in",e.initPoints&&e.initPoints();var n=(e.parent&&e.parent.absoluteBounds?e.parent:this).absoluteBounds;if(this.context.beginPath(),e.points&&0<e.points.length){this.context.moveTo(e.points[0].x+(n?n.left:0),e.points[0].y+(n?n.top:0));for(var i=1;i<e.points.length;i++)e.points[i].m?this.context.moveTo(e.points[i].x+(n?n.left:0),e.points[i].y+(n?n.top:0)):this.context.lineTo(e.points[i].x+(n?n.left:0),e.points[i].y+(n?n.top:0));e.style&&e.style.close&&this.context.closePath()}this.context.fillStyle="#ffffff",this.context.fill(),this.context.globalCompositeOperation="source-over"}else t&&this.beginDraw&&this.beginDraw(),t&&this.draw&&this.draw(),t&&this.endDraw&&this.endDraw();this.children&&this.children.each(function(t,e){e&&e.paint&&e.paint()}),this.emit("endDraw",this),this.context.restore&&this.context.restore(),this.needUpdate=!1}}},{key:"getEvent",value:function(t){return this.__events?this.__events[t]:null}},{key:"bind",value:function(t,e){if(t&&-1<t.indexOf(" ")){var n,i=_(t=t.split(" "));try{for(i.s();!(n=i.n()).done;){var r=n.value;r&&this.bind(r,e)}}catch(t){i.e(t)}finally{i.f()}}else{t=this.getEvent(t)||function(t,e){return this.__events||(this.__events={}),this.__events[t]=e}.call(this,t,new w);t.contain(e)||t.add(e)}}},{key:"unbind",value:function(t,e){if(t&&-1<t.indexOf(" ")){var n,i=_(t=t.split(" "));try{for(i.s();!(n=i.n()).done;){var r=n.value;r&&this.unbind(r,e)}}catch(t){i.e(t)}finally{i.f()}}else{t=this.getEvent(t);t&&(e?t.remove(e):t.clear())}}},{key:"emit",value:function(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];return 2<e.length?this.runEventHandle(e[0],e.slice(1)):2===e.length?this.runEventHandle(e[0],[e[1]]):this.runEventHandle(e[0],[]),this}},{key:"runEventHandle",value:function(t,n){var i,t=this.getEvent(t);return t&&(i=this,Array.isArray(n)||(n=[n]),t.each(function(t,e){!1===e.apply(i,n)&&(n.cancel=!0)})),n.cancel}},{key:"checkPoint",value:function(t,e){if("jmGraph"==this.type){var n=this.getPosition();return t.pageX>n.right||t.pageX<n.left?!1:!(t.pageY>n.bottom||t.pageY<n.top)}var i=this.getBounds();if(this.hitArea){var r=this.hitArea.x+i.left,o=this.hitArea.y+i.top,s=this.hitArea.width+i.left,n=this.hitArea.height+i.top;return t.x>s||t.x<r?!1:!(t.y>n||t.y<o)}var a=this.points;if(a&&a.length||((a=[]).push({x:i.left,y:i.top}),a.push({x:i.right,y:i.top}),a.push({x:i.right,y:i.bottom}),a.push({x:i.left,y:i.bottom}),a.push({x:i.left,y:i.top})),e=Number(e||this.style.touchPadding||this.style.lineWidth||1),a&&a.length){o=this.getRotation(null,i);if(o&&o.angle&&(a=A.clone(a,!0),a=A.rotatePoints(a,{x:o.x+i.left,y:o.y+i.top},o.angle||0)),2<a.length&&(!this.style.fill||this.style.stroke)){for(var h=0,l=a.length,u=h+1;u<=l;u=++h+1)if(u==l){if(this.style.close)if(A.pointInPolygon(t,[a[h],a[0]],e))return!0}else if(A.pointInPolygon(t,[a[h],a[u]],e))return!0;if(!this.style.fill)return!1}return A.pointInPolygon(t,a,e)}return!(t.x>i.right||t.x<i.left)&&!(t.y>i.bottom||t.y<i.top)}},{key:"raiseEvent",value:function(n,i){if(!1!==this.visible){var t;i.position||(o=this.graph,i.isWXMiniApp=o.isWXMiniApp,e=i.srcElement||i.target,t=A.getEventPosition(i),i={position:t,button:0==i.button||t.isTouch?1:i.button,keyCode:i.keyCode||i.charCode||i.which,ctrlKey:i.ctrlKey,cancel:!1,event:i,srcElement:e,isWXMiniApp:o.isWXMiniApp}),i.path=i.path||[];var r=!1;if(this.children&&this.children.each(function(t,e){if(!0!==i.cancel&&(r=!1===e.raiseEvent(n,i)||r))return!1},!0),r)return!1;var e=(this.parent&&this.parent.absoluteBounds?this.parent:this).absoluteBounds;if(!e)return!1;i.position.x=i.position.offsetX-e.left,i.position.y=i.position.offsetY-e.top;var o=!1!==this.interactive&&this.checkPoint(i.position);return"mousemove"!==n||"jmGraph"!=this.type||o||console.log("mousemove out",i.position,e),o?(i.target||(i.target=this),this.runEventAndPopEvent(n,i),this.focused||"mousemove"!==n&&"touchmove"!==n||(this.focused=!0,this.raiseEvent("mousemove"===n?"mouseover":"touchover",i))):!1===this.interactive||o||!this.focused||"mousemove"!==n&&"touchmove"!==n||(this.focused=!1,this.runEventHandle("mousemove"===n?"mouseleave":"touchleave",i)),!1===i.cancel}}},{key:"runEventAndPopEvent",value:function(t,e){!0!==e.cancel&&(e.path.push(this),this.runEventHandle(t,e))}},{key:"clearEvents",value:function(t){t=this.getEvent(t);t&&t.clear()}},{key:"findParent",value:function(t){if("string"==typeof t){if(this.type==t)return this}else if(this.is(t))return this;return this.parent?this.parent.findParent(t):null}},{key:"canMove",value:function(t,e){var o;return this.__mvMonitor||(this.__mvMonitor={},this.__mvMonitor.mouseDown=!1,this.__mvMonitor.curposition={x:0,y:0},(o=this).__mvMonitor.mv=function(t){var e=o;if(e.__mvMonitor.mouseDown){e.parent.bounds=null;var n,i=t.position.offsetX-e.__mvMonitor.curposition.x,r=t.position.offsetY-e.__mvMonitor.curposition.y;return e.option.lockSide&&(n=e.bounds||e.getAbsoluteBounds(),((n=A.checkOutSide(e.option.lockSide,n,{x:i,y:r})).left<0&&i<0||0<n.right&&0<i)&&(i=0),(n.top<0&&r<0||0<n.bottom&&0<r)&&(r=0)),(i||r)&&(e.offset(i,r,!0,t),i&&(e.__mvMonitor.curposition.x=t.position.offsetX),r&&(e.__mvMonitor.curposition.y=t.position.offsetY)),!1}},this.__mvMonitor.mu=function(t){var e=o;e.__mvMonitor.mouseDown&&(e.__mvMonitor.mouseDown=!1,e.emit("moveend",{position:e.__mvMonitor.curposition}))},this.__mvMonitor.ml=function(){var t=o;if(t.__mvMonitor.mouseDown)return t.__mvMonitor.mouseDown=!1,t.emit("moveend",{position:t.__mvMonitor.curposition}),!1},this.__mvMonitor.md=function(t){if(!this.__mvMonitor.mouseDown)return 0==t.button||1==t.button?(this.__mvMonitor.mouseDown=!0,this.__mvMonitor.curposition.x=t.position.offsetX,this.__mvMonitor.curposition.y=t.position.offsetY,this.emit("movestart",{position:this.__mvMonitor.curposition}),!(t.cancel=!0)):void 0}),e=e||this.graph,!1!==t?(e.bind("mousemove",this.__mvMonitor.mv),e.bind("mouseup",this.__mvMonitor.mu),e.bind("mouseleave",this.__mvMonitor.ml),this.bind("mousedown",this.__mvMonitor.md),e.bind("touchmove",this.__mvMonitor.mv),e.bind("touchend",this.__mvMonitor.mu),this.bind("touchstart",this.__mvMonitor.md)):(e.unbind("mousemove",this.__mvMonitor.mv),e.unbind("mouseup",this.__mvMonitor.mu),e.unbind("mouseleave",this.__mvMonitor.ml),this.unbind("mousedown",this.__mvMonitor.md),e.unbind("touchmove",this.__mvMonitor.mv),e.unbind("touchend",this.__mvMonitor.mu),this.unbind("touchstart",this.__mvMonitor.md)),this.interactive=!0,this}}]),r}(),yt=function(){u(i,vt);var n=v(i);function i(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:"jmPath";return h(this,i),(e=n.call(this,t,e)).points=t&&t.points?t.points:[],e}return l(i,[{key:"points",get:function(){return this.property("points")},set:function(t){return this.needUpdate=!0,this.property("points",t)}},{key:"toSVG",value:function(){if(!this.points||0===this.points.length)return"";var t="",e=this.points;t+="M ".concat(e[0].x," ").concat(e[0].y);for(var n=1;n<e.length;n++){var i=e[n];i.m?t+=" M ".concat(i.x," ").concat(i.y):t+=" L ".concat(i.x," ").concat(i.y)}this.style&&this.style.close&&(t+=" Z");var r='<path d="'+t+'"';return this.style&&(this.style.fill&&(r+=' fill="'+this.style.fill+'"'),this.style.stroke&&(r+=' stroke="'+this.style.stroke+'"'),this.style.lineWidth&&(r+=' stroke-width="'+this.style.lineWidth+'"'),this.style.opacity&&(r+=' opacity="'+this.style.opacity+'"')),r+="/>"}}]),i}(),gt=function(){u(o,vt);var r=v(o);function o(t,e,n){var i;return h(this,o),"function"==typeof e&&(n=e,e={}),(e=e||{}).interactive=!0,e.isRegular=!0,(i=r.call(this,e,"jmGraph")).option=e||{},i.devicePixelRatio=1,i.util=i.utils=A,i.mode=e.mode||"2d",i.scaleFactor=1,i.translation={x:0,y:0},"undefined"!=typeof wx&&wx.canIUse&&wx.canIUse("canvas")?("string"==typeof t&&(t=wx.createSelectorQuery().select("#"+t)),i.isWXMiniApp=!0,i.container=t):("string"==typeof t&&"undefined"!=typeof document?t=document.getElementById(t):t.length&&(t=t[0]),t.getContext||"undefined"==typeof document?i.container=t.parentElement:(i.container=t,e=document.createElement("canvas"),t.appendChild(e),e.width=t.offsetWidth||t.clientWidth,e.height=t.offsetHeight||t.clientHeight,t=e)),i.canvas=t,"webgl"===i.mode?i.context=t.getContext(i.mode,{preserveDrawingBuffer:!0}):i.context=t.getContext(i.mode),"webgl"===i.mode&&(i.context.enable(i.context.BLEND),i.context.blendFunc(i.context.SRC_ALPHA,i.context.ONE_MINUS_SRC_ALPHA),A.bindEvent(t,"webglcontextlost",function(t){console.log("canvas webglcontextlost",t),i.emit("webglcontextlost",t)}),A.bindEvent(t,"webglcontextrestored",function(t){console.log("canvas webglcontextrestored",t),i.emit("webglcontextrestored",t)})),i.__init(n),i}return l(o,[{key:"__init",value:function(t){this.shapes=Object.assign({path:yt},this.option.shapes),this.on("beginDraw",function(){this.context.translate&&this.context.translate(.5,.5),this.context.translate&&this.context.scale&&(this.context.translate(this.translation.x,this.translation.y),this.context.scale(this.scaleFactor,this.scaleFactor))}),this.on("endDraw",function(){this.context.translate&&this.context.translate(-.5,-.5),this.context.translate&&this.context.scale&&(this.context.scale(1/this.scaleFactor,1/this.scaleFactor),this.context.translate(-this.translation.x,-this.translation.y))});var e="undefined"!=typeof window&&1<window.devicePixelRatio?window.devicePixelRatio:1;this.isWXMiniApp&&(e=wx.getWindowInfo().pixelRatio||1),this.devicePixelRatio=e,this.dprScaleSize=1<this.devicePixelRatio?this.devicePixelRatio:2,0<this.option.width&&(this.width=this.option.width),0<this.option.height&&(this.height=this.option.height),this.resize(),this.eventHandler=new N(this,this.canvas.canvas||this.canvas),this.option.autoRefresh&&this.autoRefresh(),t&&t(this)}},{key:"resize",value:function(t,e){this.canvas&&(this.__normalSize=this.__normalSize||{width:0,height:0},t=t||this.__normalSize.width||this.width,e=e||this.__normalSize.height||this.height,t&&(this.__normalSize.width=t),e&&(this.__normalSize.height=e),this.css("width",t+"px"),this.css("height",e+"px"),"2d"===this.mode?(this.canvas.height=e*this.dprScaleSize,this.canvas.width=t*this.dprScaleSize,1!==this.dprScaleSize&&this.context.scale&&this.context.scale(this.dprScaleSize,this.dprScaleSize)):(this.canvas.width=t,this.canvas.height=e),this.context.viewport&&this.context.viewport(0,0,t,e),this.needUpdate=!0)}},{key:"width",get:function(){return this.__normalSize&&this.__normalSize.width?this.__normalSize.width:this.canvas?this.canvas.width:0},set:function(t){return this.needUpdate=!0,this.canvas&&this.resize(t),t}},{key:"height",get:function(){return this.__normalSize&&this.__normalSize.height?this.__normalSize.height:this.canvas?this.canvas.height:0},set:function(t){return this.needUpdate=!0,this.canvas&&this.resize(0,t),t}},{key:"getPosition",value:function(){var t=this.isWXMiniApp?{left:0,top:0}:A.getElementPosition(this.canvas.canvas||this.canvas);return t.width=this.width,t.height=this.height,t.right=t.left+t.width,t.bottom=t.top+t.height,t}},{key:"registerShape",value:function(t,e){this.shapes[t]=e}},{key:"createShape",value:function(t,e){if(t="string"==typeof t?this.shapes[t]:t)return(e=e||{}).graph=this,new t(e)}},{key:"createShadow",value:function(t,e,n,i){return new S(t,e,n,i)}},{key:"createLinearGradient",value:function(t,e,n,i){return new R({type:"linear",x1:t,y1:e,x2:n,y2:i,stops:4<arguments.length&&void 0!==arguments[4]?arguments[4]:[]})}},{key:"createRadialGradient",value:function(t,e,n,i,r,o){return new R({type:"radial",x1:t,y1:e,r1:n,x2:i,y2:r,r2:o,stops:6<arguments.length&&void 0!==arguments[6]?arguments[6]:[]})}},{key:"refresh",value:function(){this.redraw()}},{key:"redraw",value:function(t,e){this.clear(t||this.width,e||this.height),this.paint()}},{key:"clear",value:function(t,e){t&&e||(t=this.width,e=this.height),this.context.clearRect?(this.style&&this.style.fill&&(this.points=[{x:0,y:0},{x:t,y:0},{x:t,y:e},{x:0,y:e}],this.style.close=!0),this.context.clearRect(0,0,t,e)):"webgl"===this.mode&&this.context.clear&&(this.style&&this.style.fill?(e=this.utils.hexToRGBA(this.style.fill),this.__lastClearColor=e,this.context.clearColor(e.r,e.g,e.b,e.a)):this.__lastClearColor?this.context.clearColor(this.__lastClearColor.r,this.__lastClearColor.g,this.__lastClearColor.b,this.__lastClearColor.a):(this.__lastClearColor={r:0,g:0,b:0,a:0},this.context.clearColor(0,0,0,0)),this.context.clear(this.context.COLOR_BUFFER_BIT))}},{key:"css",value:function(t,e){if(this.canvas&&this.canvas.style)return void 0!==e&&(this.canvas.style[t]=e),this.canvas.style[t]}},{key:"createPath",value:function(t,e){return this.createShape("path",s({points:t,style:e},2<arguments.length&&void 0!==arguments[2]?arguments[2]:{}))}},{key:"createLine",value:function(t,e,n){return this.createShape("line",{start:t,end:e,style:n})}},{key:"zoomOut",value:function(){this.scale(.9,.9)}},{key:"zoomIn",value:function(){this.scale(1.1,1.1)}},{key:"zoomActual",value:function(){this.scaleSize?this.scale(1/this.scaleSize.x,1/this.scaleSize.y):this.scale(1,1)}},{key:"scale",value:function(t,e){this.normalSize||(this.normalSize={width:this.canvas.width,height:this.canvas.height}),this.scaleSize?this.scaleSize={x:t*this.scaleSize.x,y:e*this.scaleSize.y}:this.scaleSize={x:1,y:1},this.canvas.style&&(this.canvas.style.transform="scale(".concat(this.scaleSize.x,", ").concat(this.scaleSize.y,")"))}},{key:"setZoom",value:function(t,e,n){if("number"!=typeof t||isNaN(t))return console.warn("jmGraph: setZoom - 无效的缩放因子"),this;var i,r;return t=Math.max(.1,Math.min(10,t)),void 0!==e&&void 0!==n&&(i=this.scaleFactor,r=t,this.translation.x=e-(e-this.translation.x)*(r/i),this.translation.y=n-(n-this.translation.y)*(r/i)),this.scaleFactor=t,this.needUpdate=!0,this.redraw(),this}},{key:"pan",value:function(t,e){return"number"!=typeof t||"number"!=typeof e||isNaN(t)||isNaN(e)?console.warn("jmGraph: pan - 无效的平移参数"):(this.translation.x+=t,this.translation.y+=e,this.needUpdate=!0,this.redraw()),this}},{key:"resetTransform",value:function(){return this.scaleFactor=1,this.translation={x:0,y:0},this.needUpdate=!0,this.redraw(),this}},{key:"toDataURL",value:function(){return this.canvas.toDataURL?this.canvas.toDataURL():""}},{key:"exportToPNG",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:"jmgraph-export",e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:"image/png",n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:.9;try{this.redraw();var i=this.canvas.toDataURL(e,n);this.downloadFile(i,t,"png")}catch(t){console.error("jmGraph: exportToPNG - 导出失败",t)}}},{key:"exportToJPEG",value:function(){this.exportToPNG(0<arguments.length&&void 0!==arguments[0]?arguments[0]:"jmgraph-export","image/jpeg",1<arguments.length&&void 0!==arguments[1]?arguments[1]:.9)}},{key:"exportToSVG",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:"jmgraph-export";try{var e=this.toSVG(),n=new Blob([e],{type:"image/svg+xml;charset=utf-8"}),i=URL.createObjectURL(n);this.downloadFile(i,t,"svg"),setTimeout(function(){return URL.revokeObjectURL(i)},100)}catch(t){console.error("jmGraph: exportToSVG - 导出失败",t)}}},{key:"toSVG",value:function(){var n='<svg width="'.concat(this.width,'" height="').concat(this.height,'" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ').concat(this.width," ").concat(this.height,'">');return this.style&&this.style.fill&&(n+='<rect width="100%" height="100%" fill="'.concat(this.style.fill,'"/>')),this.children.each(function(t,e){e.toSVG&&(n+=e.toSVG())}),n+="</svg>"}},{key:"downloadFile",value:function(t,e,n){var i=document.createElement("a");i.href=t,i.download="".concat(e,".").concat(n),document.body.appendChild(i),i.click(),document.body.removeChild(i)}},{key:"autoRefresh",value:function(n){if(!this.___isAutoRefreshing){var i=this;this.___isAutoRefreshing=!0;var r=Date.now();return i.__requestAnimationFrameFunHandler&&this.cancelAnimationFrame(i.__requestAnimationFrameFunHandler),i.__requestAnimationFrameFunHandler=this.requestAnimationFrame(function t(){var e;i.destroyed?i.___isAutoRefreshing=!1:(i.needUpdate&&i.redraw(),e=Date.now()-r,i.emit("update",e),i.__requestAnimationFrameFunHandler=i.requestAnimationFrame(t),n&&n())}),this}}},{key:"destroy",value:function(){this.eventHandler.destroy(),this.destroyed=!0}}],[{key:"create",value:function(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];return c(o,e)}}]),o}();t.default=gt,t.jmControl=vt,t.jmEvents=N,t.jmFilter=M,t.jmGradient=R,t.jmGraph=gt,t.jmList=w,t.jmPath=yt,t.jmProperty=P,t.jmShadow=S,t.jmUtils=A,Object.defineProperty(t,"__esModule",{value:!0})});
|
|
2
2
|
//# sourceMappingURL=jmgraph.core.min.js.map
|