!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):e.svgEditor=t()}(this,function(){"use strict";function e(e){var t=e.changedTouches,n=t[0],i="";switch(e.type){case"touchstart":i="mousedown";break;case"touchmove":i="mousemove";break;case"touchend":i="mouseup";break;default:return}var r=document.createEvent("MouseEvent");r.initMouseEvent(i,!0,!0,window,1,n.screenX,n.screenY,n.clientX,n.clientY,!1,!1,!1,!1,0,null),t.length<2&&(n.target.dispatchEvent(r),e.preventDefault())}document.addEventListener("touchstart",e,!0),document.addEventListener("touchmove",e,!0),document.addEventListener("touchend",e,!0),document.addEventListener("touchcancel",e,!0);var t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},n=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")},i=function(){function e(e,t){for(var n=0;nt.getTotalLength())break;n--}while(n>0);return n}),window.SVGPathSeg=e,window.SVGPathSegClosePath=t,window.SVGPathSegMovetoAbs=o,window.SVGPathSegMovetoRel=s,window.SVGPathSegLinetoAbs=l,window.SVGPathSegLinetoRel=u,window.SVGPathSegCurvetoCubicAbs=c,window.SVGPathSegCurvetoCubicRel=h,window.SVGPathSegCurvetoQuadraticAbs=d,window.SVGPathSegCurvetoQuadraticRel=f,window.SVGPathSegArcAbs=p,window.SVGPathSegArcRel=g,window.SVGPathSegLinetoHorizontalAbs=v,window.SVGPathSegLinetoHorizontalRel=m,window.SVGPathSegLinetoVerticalAbs=y,window.SVGPathSegLinetoVerticalRel=_,window.SVGPathSegCurvetoCubicSmoothAbs=b,window.SVGPathSegCurvetoCubicSmoothRel=x,window.SVGPathSegCurvetoQuadraticSmoothAbs=w,window.SVGPathSegCurvetoQuadraticSmoothRel=S}if(!("SVGPathSegList"in window&&"appendItem"in SVGPathSegList.prototype)){var k=function(){function e(t){n(this,e),this._pathElement=t,this._list=this._parsePath(this._pathElement.getAttribute("d")),this._mutationObserverConfig={attributes:!0,attributeFilter:["d"]},this._pathElementMutationObserver=new MutationObserver(this._updateListFromPathMutations.bind(this)),this._pathElementMutationObserver.observe(this._pathElement,this._mutationObserverConfig)}return i(e,[{key:"_checkPathSynchronizedToList",value:function(){this._updateListFromPathMutations(this._pathElementMutationObserver.takeRecords())}},{key:"_updateListFromPathMutations",value:function(e){if(this._pathElement){var t=!1;e.forEach(function(e){"d"===e.attributeName&&(t=!0)}),t&&(this._list=this._parsePath(this._pathElement.getAttribute("d")))}}},{key:"_writeListToPath",value:function(){this._pathElementMutationObserver.disconnect(),this._pathElement.setAttribute("d",e._pathSegArrayAsString(this._list)),this._pathElementMutationObserver.observe(this._pathElement,this._mutationObserverConfig)}},{key:"segmentChanged",value:function(e){this._writeListToPath()}},{key:"clear",value:function(){this._checkPathSynchronizedToList(),this._list.forEach(function(e){e._owningPathSegList=null}),this._list=[],this._writeListToPath()}},{key:"initialize",value:function(e){return this._checkPathSynchronizedToList(),this._list=[e],e._owningPathSegList=this,this._writeListToPath(),e}},{key:"_checkValidIndex",value:function(e){if(isNaN(e)||e<0||e>=this.numberOfItems)throw new Error("INDEX_SIZE_ERR")}},{key:"getItem",value:function(e){return this._checkPathSynchronizedToList(),this._checkValidIndex(e),this._list[e]}},{key:"insertItemBefore",value:function(e,t){return this._checkPathSynchronizedToList(),t>this.numberOfItems&&(t=this.numberOfItems),e._owningPathSegList&&(e=e.clone()),this._list.splice(t,0,e),e._owningPathSegList=this,this._writeListToPath(),e}},{key:"replaceItem",value:function(e,t){return this._checkPathSynchronizedToList(),e._owningPathSegList&&(e=e.clone()),this._checkValidIndex(t),this._list[t]=e,e._owningPathSegList=this,this._writeListToPath(),e}},{key:"removeItem",value:function(e){this._checkPathSynchronizedToList(),this._checkValidIndex(e);var t=this._list[e];return this._list.splice(e,1),this._writeListToPath(),t}},{key:"appendItem",value:function(e){return this._checkPathSynchronizedToList(),e._owningPathSegList&&(e=e.clone()),this._list.push(e),e._owningPathSegList=this,this._writeListToPath(),e}},{key:"_parsePath",value:function(e){if(!e||!e.length)return[];var t=this,r=function(){function e(){n(this,e),this.pathSegList=[]}return i(e,[{key:"appendSegment",value:function(e){this.pathSegList.push(e)}}]),e}(),a=function(){function e(t){n(this,e),this._string=t,this._currentIndex=0,this._endIndex=this._string.length,this._previousCommand=SVGPathSeg.PATHSEG_UNKNOWN,this._skipOptionalSpaces()}return i(e,[{key:"_isCurrentSpace",value:function(){var e=this._string[this._currentIndex];return e<=" "&&(" "===e||"\n"===e||"\t"===e||"\r"===e||"\f"===e)}},{key:"_skipOptionalSpaces",value:function(){for(;this._currentIndex="0"&&e<="9")&&t!==SVGPathSeg.PATHSEG_CLOSEPATH?t===SVGPathSeg.PATHSEG_MOVETO_ABS?SVGPathSeg.PATHSEG_LINETO_ABS:t===SVGPathSeg.PATHSEG_MOVETO_REL?SVGPathSeg.PATHSEG_LINETO_REL:t:SVGPathSeg.PATHSEG_UNKNOWN}},{key:"initialCommandIsMoveTo",value:function(){if(!this.hasMoreData())return!0;var e=this.peekSegmentType();return e===SVGPathSeg.PATHSEG_MOVETO_ABS||e===SVGPathSeg.PATHSEG_MOVETO_REL}},{key:"_parseNumber",value:function(){var e=0,t=0,n=1,i=0,r=1,a=1,o=this._currentIndex;if(this._skipOptionalSpaces(),this._currentIndex"9")&&"."!==this._string.charAt(this._currentIndex))){for(var s=this._currentIndex;this._currentIndex="0"&&this._string.charAt(this._currentIndex)<="9";)this._currentIndex++;if(this._currentIndex!==s)for(var l=this._currentIndex-1,u=1;l>=s;)t+=u*(this._string.charAt(l--)-"0"),u*=10;if(this._currentIndex=this._endIndex||this._string.charAt(this._currentIndex)<"0"||this._string.charAt(this._currentIndex)>"9")return;for(;this._currentIndex="0"&&this._string.charAt(this._currentIndex)<="9";)n*=10,i+=(this._string.charAt(this._currentIndex)-"0")/n,this._currentIndex+=1}if(this._currentIndex!==o&&this._currentIndex+1=this._endIndex||this._string.charAt(this._currentIndex)<"0"||this._string.charAt(this._currentIndex)>"9")return;for(;this._currentIndex="0"&&this._string.charAt(this._currentIndex)<="9";)e*=10,e+=this._string.charAt(this._currentIndex)-"0",this._currentIndex++}var c=t+i;if(c*=r,e&&(c*=Math.pow(10,a*e)),o!==this._currentIndex)return this._skipOptionalSpacesOrDelimiter(),c}}},{key:"_parseArcFlag",value:function(){if(!(this._currentIndex>=this._endIndex)){var e=!1,t=this._string.charAt(this._currentIndex++);if("0"===t)e=!1;else{if("1"!==t)return;e=!0}return this._skipOptionalSpacesOrDelimiter(),e}}},{key:"parseSegment",value:function(){var e=this._string[this._currentIndex],n=this._pathSegTypeFromChar(e);if(n===SVGPathSeg.PATHSEG_UNKNOWN){if(this._previousCommand===SVGPathSeg.PATHSEG_UNKNOWN)return null;if((n=this._nextCommandHelper(e,this._previousCommand))===SVGPathSeg.PATHSEG_UNKNOWN)return null}else this._currentIndex++;switch(this._previousCommand=n,n){case SVGPathSeg.PATHSEG_MOVETO_REL:return new SVGPathSegMovetoRel(t,this._parseNumber(),this._parseNumber());case SVGPathSeg.PATHSEG_MOVETO_ABS:return new SVGPathSegMovetoAbs(t,this._parseNumber(),this._parseNumber());case SVGPathSeg.PATHSEG_LINETO_REL:return new SVGPathSegLinetoRel(t,this._parseNumber(),this._parseNumber());case SVGPathSeg.PATHSEG_LINETO_ABS:return new SVGPathSegLinetoAbs(t,this._parseNumber(),this._parseNumber());case SVGPathSeg.PATHSEG_LINETO_HORIZONTAL_REL:return new SVGPathSegLinetoHorizontalRel(t,this._parseNumber());case SVGPathSeg.PATHSEG_LINETO_HORIZONTAL_ABS:return new SVGPathSegLinetoHorizontalAbs(t,this._parseNumber());case SVGPathSeg.PATHSEG_LINETO_VERTICAL_REL:return new SVGPathSegLinetoVerticalRel(t,this._parseNumber());case SVGPathSeg.PATHSEG_LINETO_VERTICAL_ABS:return new SVGPathSegLinetoVerticalAbs(t,this._parseNumber());case SVGPathSeg.PATHSEG_CLOSEPATH:return this._skipOptionalSpaces(),new SVGPathSegClosePath(t);case SVGPathSeg.PATHSEG_CURVETO_CUBIC_REL:var i={x1:this._parseNumber(),y1:this._parseNumber(),x2:this._parseNumber(),y2:this._parseNumber(),x:this._parseNumber(),y:this._parseNumber()};return new SVGPathSegCurvetoCubicRel(t,i.x,i.y,i.x1,i.y1,i.x2,i.y2);case SVGPathSeg.PATHSEG_CURVETO_CUBIC_ABS:var r={x1:this._parseNumber(),y1:this._parseNumber(),x2:this._parseNumber(),y2:this._parseNumber(),x:this._parseNumber(),y:this._parseNumber()};return new SVGPathSegCurvetoCubicAbs(t,r.x,r.y,r.x1,r.y1,r.x2,r.y2);case SVGPathSeg.PATHSEG_CURVETO_CUBIC_SMOOTH_REL:var a={x2:this._parseNumber(),y2:this._parseNumber(),x:this._parseNumber(),y:this._parseNumber()};return new SVGPathSegCurvetoCubicSmoothRel(t,a.x,a.y,a.x2,a.y2);case SVGPathSeg.PATHSEG_CURVETO_CUBIC_SMOOTH_ABS:var o={x2:this._parseNumber(),y2:this._parseNumber(),x:this._parseNumber(),y:this._parseNumber()};return new SVGPathSegCurvetoCubicSmoothAbs(t,o.x,o.y,o.x2,o.y2);case SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_REL:var s={x1:this._parseNumber(),y1:this._parseNumber(),x:this._parseNumber(),y:this._parseNumber()};return new SVGPathSegCurvetoQuadraticRel(t,s.x,s.y,s.x1,s.y1);case SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_ABS:var l={x1:this._parseNumber(),y1:this._parseNumber(),x:this._parseNumber(),y:this._parseNumber()};return new SVGPathSegCurvetoQuadraticAbs(t,l.x,l.y,l.x1,l.y1);case SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL:return new SVGPathSegCurvetoQuadraticSmoothRel(t,this._parseNumber(),this._parseNumber());case SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS:return new SVGPathSegCurvetoQuadraticSmoothAbs(t,this._parseNumber(),this._parseNumber());case SVGPathSeg.PATHSEG_ARC_REL:var u={x1:this._parseNumber(),y1:this._parseNumber(),arcAngle:this._parseNumber(),arcLarge:this._parseArcFlag(),arcSweep:this._parseArcFlag(),x:this._parseNumber(),y:this._parseNumber()};return new SVGPathSegArcRel(t,u.x,u.y,u.x1,u.y1,u.arcAngle,u.arcLarge,u.arcSweep);case SVGPathSeg.PATHSEG_ARC_ABS:var c={x1:this._parseNumber(),y1:this._parseNumber(),arcAngle:this._parseNumber(),arcLarge:this._parseArcFlag(),arcSweep:this._parseArcFlag(),x:this._parseNumber(),y:this._parseNumber()};return new SVGPathSegArcAbs(t,c.x,c.y,c.x1,c.y1,c.arcAngle,c.arcLarge,c.arcSweep);default:throw new Error("Unknown path seg type.")}}}]),e}(),o=new r,s=new a(e);if(!s.initialCommandIsMoveTo())return[];for(;s.hasMoreData();){var l=s.parseSegment();if(!l)return[];o.appendSegment(l)}return o.pathSegList}}]),e}();k.prototype.classname="SVGPathSegList",Object.defineProperty(k.prototype,"numberOfItems",{get:function(){return this._checkPathSynchronizedToList(),this._list.length},enumerable:!0}),k._pathSegArrayAsString=function(e){var t="",n=!0;return e.forEach(function(e){n?(n=!1,t+=e._asPathString()):t+=" "+e._asPathString()}),t},Object.defineProperties(SVGPathElement.prototype,{pathSegList:{get:function(){return this._pathSegList||(this._pathSegList=new k(this)),this._pathSegList},enumerable:!0},normalizedPathSegList:{get:function(){return this.pathSegList},enumerable:!0},animatedPathSegList:{get:function(){return this.pathSegList},enumerable:!0},animatedNormalizedPathSegList:{get:function(){return this.pathSegList},enumerable:!0}}),window.SVGPathSegList=k}}();var c,h=jQuery,d=(!!document.createElementNS&&document.createElementNS(l.SVG,"svg").createSVGRect,navigator.userAgent),f=document.createElementNS(l.SVG,"svg"),p=!!window.opera,g=d.includes("AppleWebKit"),v=d.includes("Gecko/"),m=d.includes("MSIE"),y=d.includes("Chrome/"),_=(d.includes("Windows"),d.includes("Macintosh")),b="ontouchstart"in window,x=!!f.querySelector,w=!!document.evaluate,S=function(){var e=document.createElementNS(l.SVG,"path");e.setAttribute("d","M0,0 10,10");var t=e.pathSegList,n=e.createSVGPathSegLinetoAbs(5,5);try{return t.replaceItem(n,1),!0}catch(e){}return!1}(),k=function(){var e=document.createElementNS(l.SVG,"path");e.setAttribute("d","M0,0 10,10");var t=e.pathSegList,n=e.createSVGPathSegLinetoAbs(5,5);try{return t.insertItemBefore(n,1),!0}catch(e){}return!1}(),C=function(){var e=document.createElementNS(l.SVG,"svg"),t=document.createElementNS(l.SVG,"svg");document.documentElement.appendChild(e),t.setAttribute("x",5),e.appendChild(t);var n=document.createElementNS(l.SVG,"text");n.textContent="a",t.appendChild(n);var i=n.getStartPositionOfChar(0).x;return document.documentElement.removeChild(e),0===i}(),P=function(){var e=document.createElementNS(l.SVG,"svg");document.documentElement.appendChild(e);var t=document.createElementNS(l.SVG,"path");t.setAttribute("d","M0,0 C0,0 10,10 10,0"),e.appendChild(t);var n=t.getBBox();return document.documentElement.removeChild(e),n.height>4&&n.height<5}(),A=function(){var e=document.createElementNS(l.SVG,"svg");document.documentElement.appendChild(e);var t=document.createElementNS(l.SVG,"path");t.setAttribute("d","M0,0 10,0");var n=document.createElementNS(l.SVG,"path");n.setAttribute("d","M5,0 15,0");var i=document.createElementNS(l.SVG,"g");i.appendChild(t),i.appendChild(n),e.appendChild(i);var r=i.getBBox();return document.documentElement.removeChild(e),15===r.width}(),E=(function(){var e=document.createElementNS(l.SVG,"rect");e.setAttribute("x",.1);var t=!e.cloneNode(!1).getAttribute("x").includes(",");t||h.alert('NOTE: This version of Opera is known to contain bugs in SVG-edit.\nPlease upgrade to the latest version in which the problems have been fixed.')}(),(c=document.createElementNS(l.SVG,"rect")).setAttribute("style","vector-effect:non-scaling-stroke"),"non-scaling-stroke"===c.style.vectorEffect),T=function(){var e=document.createElementNS(l.SVG,"rect").transform.baseVal,t=f.createSVGTransform();e.appendItem(t);var n=e.getItem(0);return n instanceof SVGTransform&&t instanceof SVGTransform&&n.type===t.type&&n.angle===t.angle&&n.matrix.a===t.matrix.a&&n.matrix.b===t.matrix.b&&n.matrix.c===t.matrix.c&&n.matrix.d===t.matrix.d&&n.matrix.e===t.matrix.e&&n.matrix.f===t.matrix.f}(),G=function(){return p},N=function(){return g},I=function(){return v},M=function(){return m},L=function(){return y},O=function(){return _},V=function(){return b},j=function(){return A},B=function(){return E};function R(e){this.ok=!1,"#"===e.charAt(0)&&(e=e.substr(1,6)),e=(e=e.replace(/ /g,"")).toLowerCase();var t={aliceblue:"f0f8ff",antiquewhite:"faebd7",aqua:"00ffff",aquamarine:"7fffd4",azure:"f0ffff",beige:"f5f5dc",bisque:"ffe4c4",black:"000000",blanchedalmond:"ffebcd",blue:"0000ff",blueviolet:"8a2be2",brown:"a52a2a",burlywood:"deb887",cadetblue:"5f9ea0",chartreuse:"7fff00",chocolate:"d2691e",coral:"ff7f50",cornflowerblue:"6495ed",cornsilk:"fff8dc",crimson:"dc143c",cyan:"00ffff",darkblue:"00008b",darkcyan:"008b8b",darkgoldenrod:"b8860b",darkgray:"a9a9a9",darkgreen:"006400",darkkhaki:"bdb76b",darkmagenta:"8b008b",darkolivegreen:"556b2f",darkorange:"ff8c00",darkorchid:"9932cc",darkred:"8b0000",darksalmon:"e9967a",darkseagreen:"8fbc8f",darkslateblue:"483d8b",darkslategray:"2f4f4f",darkturquoise:"00ced1",darkviolet:"9400d3",deeppink:"ff1493",deepskyblue:"00bfff",dimgray:"696969",dodgerblue:"1e90ff",feldspar:"d19275",firebrick:"b22222",floralwhite:"fffaf0",forestgreen:"228b22",fuchsia:"ff00ff",gainsboro:"dcdcdc",ghostwhite:"f8f8ff",gold:"ffd700",goldenrod:"daa520",gray:"808080",green:"008000",greenyellow:"adff2f",honeydew:"f0fff0",hotpink:"ff69b4",indianred:"cd5c5c",indigo:"4b0082",ivory:"fffff0",khaki:"f0e68c",lavender:"e6e6fa",lavenderblush:"fff0f5",lawngreen:"7cfc00",lemonchiffon:"fffacd",lightblue:"add8e6",lightcoral:"f08080",lightcyan:"e0ffff",lightgoldenrodyellow:"fafad2",lightgrey:"d3d3d3",lightgreen:"90ee90",lightpink:"ffb6c1",lightsalmon:"ffa07a",lightseagreen:"20b2aa",lightskyblue:"87cefa",lightslateblue:"8470ff",lightslategray:"778899",lightsteelblue:"b0c4de",lightyellow:"ffffe0",lime:"00ff00",limegreen:"32cd32",linen:"faf0e6",magenta:"ff00ff",maroon:"800000",mediumaquamarine:"66cdaa",mediumblue:"0000cd",mediumorchid:"ba55d3",mediumpurple:"9370d8",mediumseagreen:"3cb371",mediumslateblue:"7b68ee",mediumspringgreen:"00fa9a",mediumturquoise:"48d1cc",mediumvioletred:"c71585",midnightblue:"191970",mintcream:"f5fffa",mistyrose:"ffe4e1",moccasin:"ffe4b5",navajowhite:"ffdead",navy:"000080",oldlace:"fdf5e6",olive:"808000",olivedrab:"6b8e23",orange:"ffa500",orangered:"ff4500",orchid:"da70d6",palegoldenrod:"eee8aa",palegreen:"98fb98",paleturquoise:"afeeee",palevioletred:"d87093",papayawhip:"ffefd5",peachpuff:"ffdab9",peru:"cd853f",pink:"ffc0cb",plum:"dda0dd",powderblue:"b0e0e6",purple:"800080",red:"ff0000",rosybrown:"bc8f8f",royalblue:"4169e1",saddlebrown:"8b4513",salmon:"fa8072",sandybrown:"f4a460",seagreen:"2e8b57",seashell:"fff5ee",sienna:"a0522d",silver:"c0c0c0",skyblue:"87ceeb",slateblue:"6a5acd",slategray:"708090",snow:"fffafa",springgreen:"00ff7f",steelblue:"4682b4",tan:"d2b48c",teal:"008080",thistle:"d8bfd8",tomato:"ff6347",turquoise:"40e0d0",violet:"ee82ee",violetred:"d02090",wheat:"f5deb3",white:"ffffff",whitesmoke:"f5f5f5",yellow:"ffff00",yellowgreen:"9acd32"};for(var n in t)t.hasOwnProperty(n)&&e===n&&(e=t[n]);for(var i=[{re:/^rgb\((\d{1,3}),\s*(\d{1,3}),\s*(\d{1,3})\)$/,example:["rgb(123, 234, 45)","rgb(255,234,245)"],process:function(e){return[parseInt(e[1],10),parseInt(e[2],10),parseInt(e[3],10)]}},{re:/^(\w{2})(\w{2})(\w{2})$/,example:["#00ff00","336699"],process:function(e){return[parseInt(e[1],16),parseInt(e[2],16),parseInt(e[3],16)]}},{re:/^(\w{1})(\w{1})(\w{1})$/,example:["#fb0","f0f"],process:function(e){return[parseInt(e[1]+e[1],16),parseInt(e[2]+e[2],16),parseInt(e[3]+e[3],16)]}}],r=0;r255?255:this.r,this.g=this.g<0||isNaN(this.g)?0:this.g>255?255:this.g,this.b=this.b<0||isNaN(this.b)?0:this.b>255?255:this.b,this.toRGB=function(){return"rgb("+this.r+", "+this.g+", "+this.b+")"},this.toHex=function(){var e=this.r.toString(16),t=this.g.toString(16),n=this.b.toString(16);return 1===e.length&&(e="0"+e),1===t.length&&(t="0"+t),1===n.length&&(n="0"+n),"#"+e+t+n},this.getHelpXML=function(){for(var e=[],n=0;n "+c.toRGB()+" -> "+c.toHex());u.appendChild(h),u.appendChild(d),s.appendChild(u)}catch(e){}return s}}function D(e){var n=e.fn.attr;return e.fn.attr=function(e,i){var r=this.length;if(!r)return n.apply(this,arguments);for(var a=0;a=0)return this._xforms[e];var t=new Error("DOMException with code=INDEX_SIZE_ERR");throw t.code=1,t},this.insertItemBefore=function(e,t){var n=null;if(t>=0)if(t=0&&(this._removeFromOtherLists(e),this._xforms[t]=e,n=e,this._list._update()),n},this.removeItem=function(e){if(e=0){var t=this._xforms[e],n=new Array(this.numberOfItems-1),i=void 0;for(i=0;i=0;t--)this.stack[t].unapply(e);e&&e.handleHistoryEvent(ae.AFTER_UNAPPLY,this)}},{key:"elements",value:function(){for(var e=[],t=this.stack.length;t--;)for(var n=this.stack[t].elements(),i=n.length;i--;)e.includes(n[i])||e.push(n[i]);return e}},{key:"addSubCommand",value:function(e){this.stack.push(e)}},{key:"isEmpty",value:function(){return!this.stack.length}}]),e}();ce.type=ce.prototype.type;var he=function(){function e(t){n(this,e),this.handler_=t||null,this.undoStackPointer=0,this.undoStack=[],this.undoChangeStackPointer=-1,this.undoableChangeStack=[]}return i(e,[{key:"resetUndoStack",value:function(){this.undoStack=[],this.undoStackPointer=0}},{key:"getUndoStackSize",value:function(){return this.undoStackPointer}},{key:"getRedoStackSize",value:function(){return this.undoStack.length-this.undoStackPointer}},{key:"getNextUndoCommandText",value:function(){return this.undoStackPointer>0?this.undoStack[this.undoStackPointer-1].getText():""}},{key:"getNextRedoCommandText",value:function(){return this.undoStackPointer0&&this.undoStack[--this.undoStackPointer].unapply(this.handler_)}},{key:"redo",value:function(){this.undoStackPointer0&&this.undoStack[this.undoStackPointer++].apply(this.handler_)}},{key:"addCommandToHistory",value:function(e){this.undoStackPointer0&&(this.undoStack=this.undoStack.splice(0,this.undoStackPointer)),this.undoStack.push(e),this.undoStackPointer=this.undoStack.length}},{key:"beginUndoableChange",value:function(e,t){for(var n=++this.undoChangeStackPointer,i=t.length,r=new Array(i),a=new Array(i);i--;){var o=t[i];null!=o&&(a[i]=o,r[i]=o.getAttribute(e))}this.undoableChangeStack[n]={attrName:e,oldValues:r,elements:a}}},{key:"finishUndoableChange",value:function(){for(var e=this.undoChangeStackPointer--,t=this.undoableChangeStack[e],n=t.attrName,i=new ce("Change "+n),r=t.elements.length;r--;){var a=t.elements[r];if(null!=a){var o={};o[n]=t.oldValues[r],o[n]!==a.getAttribute(n)&&i.addSubCommand(new ue(a,o,n))}}return this.undoableChangeStack[e]=null,i}}]),e}(),de=Object.freeze({HistoryEventTypes:ae,MoveElementCommand:oe,InsertElementCommand:se,RemoveElementCommand:le,ChangeElementCommand:ue,BatchCommand:ce,UndoManager:he}),fe=document.createElementNS(l.SVG,"svg"),pe=function(e,t,n){return{x:n.a*e+n.c*t+n.e,y:n.b*e+n.d*t+n.f}},ge=function(e){return 1===e.a&&0===e.b&&0===e.c&&1===e.d&&0===e.e&&0===e.f},ve=function(){for(var e=arguments.length,t=Array(e),n=0;n(n=parseInt(n,10))){var i=n;n=t,t=i}for(var r=fe.createSVGMatrix(),a=t;a<=n;++a){var o=a>=0&&ae.x&&t.ye.y},Se=jQuery,ke={2:["x","y"],4:["x","y"],6:["x","y","x1","y1","x2","y2"],8:["x","y","x1","y1"],10:["x","y","r1","r2","angle","largeArcFlag","sweepFlag"],12:["x"],14:["y"],16:["x","y","x2","y2"],18:["x","y"]},Ce={},Pe=function(e){Object.assign(Ce,e.ui)},Ae=[],Ee=!0,Te={},Ge=null,Ne=null,Ie=function(e){Ne=e,Ae=[0,"ClosePath"];Se.each(["Moveto","Lineto","CurvetoCubic","CurvetoQuadratic","Arc","LinetoHorizontal","LinetoVertical","CurvetoCubicSmooth","CurvetoQuadraticSmooth"],function(e,t){Ae.push(t+"Abs"),Ae.push(t+"Rel")})},Me=function(e,t,n){var i=e.pathSegList;if(k)i.insertItemBefore(t,n);else{for(var r=i.numberOfItems,a=[],o=0;o0?(g=f element");this.elem=t,this.segs=[],this.selected_pts=[],Ge=this,this.init()}return i(e,[{key:"init",value:function(){Se(je()).find("*").each(function(){Se(this).attr("display","none")});var e=this.elem.pathSegList,t=e.numberOfItems;this.segs=[],this.selected_pts=[],this.first_seg=null;for(var n=0;n=t?null:a[s+1],c=s-1<0?null:a[s-1];if(2===l.type){if(c&&1!==c.type){var h=a[o];h.next=a[o+1],h.next.prev=h,h.addGrip()}o=s}else if(u&&1===u.type)l.next=a[o+1],l.next.prev=l,l.mate=a[o],l.addGrip(),null==this.first_seg&&(this.first_seg=l);else if(u)1!==l.type&&(l.addGrip(),u&&2!==u.type&&(l.next=u,l.next.prev=l));else if(1!==l.type){var d=a[o];d.next=a[o+1],d.next.prev=d,d.addGrip(),l.addGrip(),this.first_seg||(this.first_seg=a[o])}}return this}},{key:"eachSeg",value:function(e){for(var t=this.segs.length,n=0;n=0&&this.selected_pts.push(n)}this.selected_pts.sort();var i=this.selected_pts.length,r=[];for(r.length=i;i--;){var a=this.selected_pts[i],o=this.segs[a];o.select(!0),r[i]=o.ptgrip}var s=this.subpathIsClosed(this.selected_pts[0]);Ne.addPtsToSelection({grips:r,closedSubpath:s})}}]),e}(),Xe=function(e){var t=Te[e.id];return t||(t=Te[e.id]=new qe(e)),t},Ye=function(e){e in Te&&delete Te[e]},We=void 0,Qe=void 0,$e=void 0,Ze=void 0,Ke=void 0,Je=function(e,t){var n=e-$e,i=t-Ze,r=Math.sqrt(n*n+i*i),a=Math.atan2(i,n)+Ke;return n=r*Math.cos(a)+$e,i=r*Math.sin(a)+Ze,n-=We,i-=Qe,r=Math.sqrt(n*n+i*i),a=Math.atan2(i,n)-Ke,{x:r*Math.cos(a)+We,y:r*Math.sin(a)+Qe}},et=function(){var e=Ge.elem;if(Ke=zt(e,!0)){var t=Ge.oldbbox;$e=t.x+t.width/2,Ze=t.y+t.height/2;var n=It(e);We=n.x+n.width/2,Qe=n.y+n.height/2;var i=We-$e,r=Qe-Ze,a=Math.sqrt(i*i+r*r),o=Math.atan2(r,i)+Ke;We=a*Math.cos(o)+$e,Qe=a*Math.sin(o)+Ze;for(var s=e.pathSegList,l=s.numberOfItems;l;){l-=1;var u=s.getItem(l),c=u.pathSegType;if(1!==c){var h=Je(u.x,u.y),d=[h.x,h.y];if(null!=u.x1&&null!=u.x2){var f=Je(u.x1,u.y1),p=Je(u.x2,u.y2);d.splice(d.length,0,f.x,f.y,p.x,p.y)}Fe(c,l,d)}}n=It(e);var g=Ne.getSVGRoot().createSVGTransform(),v=W(e);g.setRotate(180*Ke/Math.PI,We,Qe),v.replaceItem(g,0)}},tt=[0,"z","M","m","L","l","C","c","Q","q","A","a","H","h","V","v","S","s","T","t"],nt=function(e,t){for(var n=e.pathSegList,i=n.numberOfItems,r=0,a=0,o="",s=null,l=0;l=C-w&&g<=C+w&&v>=P-w&&v<=P+w){S=!0;break}}r=Ne.getId(),Ye(r);var A=qt(r),E=void 0,T=void 0,G=b.numberOfItems;if(S){if(x<=1&&G>=2){var N=b.getItem(0).x,I=b.getItem(0).y;E=4===(T=m.pathSegList.getItem(1)).pathSegType?_.createSVGPathSegLinetoAbs(N,I):_.createSVGPathSegCurvetoCubicAbs(N,I,T.x1/p,T.y1/p,N,I);var M=_.createSVGPathSegClosePath();b.appendItem(E),b.appendItem(M)}else if(G<3)return!1;if(Se(m).remove(),_=Ne.setDrawnPath(null),Ne.setStarted(!1),rt){Ge.matrix&&Ne.remapElement(A,{},Ge.matrix.inverse());var L=A.getAttribute("d"),O=Se(Ge.elem).attr("d");return Se(Ge.elem).attr("d",O+L),Se(A).remove(),Ge.matrix&&et(),Ie(),ut.toEditMode(Ge.elem),Ge.selectPt(),!1}}else{if(!Se.contains(Ne.getContainer(),Ne.getMouseTarget(e)))return console.log("Clicked outside canvas"),!1;var V=_.pathSegList.numberOfItems,j=_.pathSegList.getItem(V-1),B=j.x,R=j.y;if(e.shiftKey){var D=xe(B,R,g,v);g=D.x,v=D.y}E=4===(T=m.pathSegList.getItem(1)).pathSegType?_.createSVGPathSegLinetoAbs(Ne.round(g),Ne.round(v)):_.createSVGPathSegCurvetoCubicAbs(Ne.round(g),Ne.round(v),T.x1/p,T.y1/p,T.x2/p,T.y2/p),_.pathSegList.appendItem(E),g*=p,v*=p,m.setAttribute("d",["M",g,v,g,v].join(" ")),y=V,rt&&(y+=Ge.segs.length),Ve(y,g,v)}}else{var F="M"+g+","+v+" ";_=Ne.setDrawnPath(Ne.addSvgElementFromJson({element:"path",curStyles:!0,attr:{d:F,id:Ne.getNextId(),opacity:Ne.getOpacity()/2}})),m.setAttribute("d",["M",d,f,d,f].join(" ")),y=rt?Ge.segs.length:0,Ve(y,d,f)}}},mouseMove:function(e,t){var n=Ne.getCurrentZoom();lt=!0;var i=Ne.getDrawnPath();if("path"!==Ne.getCurrentMode())if(Ge.dragging){var r=Oe({x:Ge.dragging[0],y:Ge.dragging[1]},Ge),a=Oe({x:e,y:t},Ge),o=a.x-r.x,s=a.y-r.y;Ge.dragging=[e,t],Ge.dragctrl?Ge.moveCtrl(o,s):Ge.movePts(o,s)}else Ge.selected_pts=[],Ge.eachSeg(function(e){if(this.next||this.prev){var t=Ne.getRubberBox().getBBox(),n=Le(this),i={x:n.x,y:n.y,width:0,height:0},r=we(t,i);this.select(r),r&&Ge.selected_pts.push(this.index)}});else{if(!i)return;var l=i.pathSegList,u=l.numberOfItems-1;if(at){var c=Be("1c1"),h=Be("0c2");c.setAttribute("cx",e),c.setAttribute("cy",t),c.setAttribute("display","inline");var d=at[0],f=at[1],p=d+(d-e/n),g=f+(f-t/n);h.setAttribute("cx",p*n),h.setAttribute("cy",g*n),h.setAttribute("display","inline");var v=Re(1);if(Xt(v,{x1:e,y1:t,x2:p*n,y2:g*n,display:"inline"}),0===u)ot=[e,t];else{var m=l.getItem(u-1),y=m.x,_=m.y;6===m.pathSegType?(y+=y-m.x2,_+=_-m.y2):ot&&(y=ot[0]/n,_=ot[1]/n),Fe(6,u,[d,f,y,_,p,g],i)}}else{var b=qt("path_stretch_line");if(b){var x=l.getItem(u);if(6===x.pathSegType){var w=x.x+(x.x-x.x2),S=x.y+(x.y-x.y2);Fe(6,1,[e,t,w*n,S*n,e,t],b)}else ot?Fe(6,1,[e,t,ot[0],ot[1],e,t],b):Fe(4,1,[e,t],b)}}}},mouseUp:function(e,t,n,i){var r=Ne.getDrawnPath();if("path"===Ne.getCurrentMode())return at=null,r||(t=qt(Ne.getId()),Ne.setStarted(!1),ot=null),{keep:!0,element:t};var a=Ne.getRubberBox();if(Ge.dragging){var o=Ge.cur_pt;Ge.dragging=!1,Ge.dragctrl=!1,Ge.update(),lt&&Ge.endChanges("Move path point(s)"),e.shiftKey||lt||Ge.selectPt(o)}else a&&"none"!==a.getAttribute("display")?(a.setAttribute("display","none"),a.getAttribute("width")<=2&&a.getAttribute("height")<=2&&ut.toSelectMode(e.target)):ut.toSelectMode(e.target);lt=!1},toEditMode:function(e){Ge=Xe(e),Ne.setCurrentMode("pathedit"),Ne.clearSelection(),Ge.show(!0).update(),Ge.oldbbox=It(Ge.elem),rt=!1},toSelectMode:function(e){var t=e===Ge.elem;Ne.setCurrentMode("select"),Ge.show(!1),st=!1,Ne.clearSelection(),Ge.matrix&&et(),t&&(Ne.call("selected",[e]),Ne.addToSelection([e],!0))},addSubPath:function(e){e?(Ne.setCurrentMode("path"),rt=!0):(ut.clear(!0),ut.toEditMode(Ge.elem))},select:function(e){st===e?(ut.toEditMode(e),Ne.setCurrentMode("pathedit")):st=e},reorient:function(){var e=Ne.getSelectedElements()[0];if(e&&0!==zt(e)){var t=new ce("Reorient path"),n={d:e.getAttribute("d"),transform:e.getAttribute("transform")};t.addSubCommand(new ue(e,n)),Ne.clearSelection(),this.resetOrientation(e),Ne.addCommandToHistory(t),Xe(e).show(!1).matrix=null,this.clear(),Ne.addToSelection([e],!0),Ne.call("changed",Ne.getSelectedElements())}},clear:function(e){var t=Ne.getDrawnPath();if(st=null,t){var n=qt(Ne.getId());Se(qt("path_stretch_line")).remove(),Se(n).remove(),Se(qt("pathpointgrip_container")).find("*").attr("display","none"),ot=null,Ne.setDrawnPath(null),Ne.setStarted(!1)}else"pathedit"===Ne.getCurrentMode()&&this.toSelectMode();Ge&&Ge.init().show(!1)},resetOrientation:function(e){if(null==e||"path"!==e.nodeName)return!1;var t=W(e),n=_e(t).matrix;t.clear(),e.removeAttribute("transform");for(var i=e.pathSegList,r=i.numberOfItems,a=function(t){var r=i.getItem(t),a=r.pathSegType;if(1===a)return"continue";var o=[];Se.each(["",1,2],function(e,t){var i=r["x"+t],a=r["y"+t];if(void 0!==i&&void 0!==a){var s=pe(i,a,n);o.splice(o.length,0,s.x,s.y)}}),Fe(a,t,o,e)},o=0;o0){var s=t.getItem(n-1).pathSegType;if(2===s){i(n-1,1),e();break}if(1===s&&t.numberOfItems-1===n){i(n,1),e();break}}}return!1}(),Ge.elem.pathSegList.numberOfItems<=1)return ut.toSelectMode(Ge.elem),void Ne.canvas.deleteSelectedElements();if(Ge.init(),Ge.clearSelection(),window.opera){var i=Se(Ge.elem);i.attr("d",i.attr("d"))}Ge.endChanges("Delete path node(s)")}},smoothPolylineIntoPath:function(e){var t=void 0,n=e.points,i=n.numberOfItems;if(i>=4){var r=n.getItem(0),a=null,o=[];for(o.push(["M",r.x,",",r.y," C"].join("")),t=1;t<=i-4;t+=3){var s=n.getItem(t),l=n.getItem(t+1),u=n.getItem(t+2);if(a){var c=ze(a,s,r);if(c&&2===c.length){var h=o[o.length-1].split(",");h[2]=c[0].x,h[3]=c[0].y,o[o.length-1]=h.join(","),s=c[1]}}o.push([s.x,s.y,l.x,l.y,u.x,u.y].join(",")),r=u,a=l}for(o.push("L");t/g,">").replace(/"/g,""").replace(/'/,"'")},yt=function(e){if(e=xt(e),window.btoa)return window.btoa(e);var t=[];t.length=4*Math.floor((e.length+2)/3);var n=0,i=0;do{var r=e.charCodeAt(n++),a=e.charCodeAt(n++),o=e.charCodeAt(n++),s=r>>2,l=(3&r)<<4|a>>4,u=(15&a)<<2|o>>6,c=63&o;isNaN(a)?u=c=64:isNaN(o)&&(c=64),t[i++]=ht.charAt(s),t[i++]=ht.charAt(l),t[i++]=ht.charAt(u),t[i++]=ht.charAt(c)}while(n>4,l=(15&r)<<4|a>>2,u=(3&a)<<6|o;t+=String.fromCharCode(s),64!==a&&(t+=String.fromCharCode(l)),64!==o&&(t+=String.fromCharCode(u))}while(nSVG-edit "],{type:"text/html"});return wt(e)}(),kt=function(e){e.includes("0?t=t[0]:(t=e.ownerDocument.createElementNS(l.SVG,"defs"),e.firstChild?e.insertBefore(t,e.firstChild.nextSibling):e.appendChild(t)),t},Gt=function(e){for(var t=e.pathSegList,n=t.numberOfItems,i=[[],[]],r=t.getItem(0),a=[r.x,r.y],o=0;o0&&c<1&&i[r].push(o(c)),"continue"}var h=Math.pow(s,2)-4*u*l;if(h<0)return"continue";var d=(-s+Math.sqrt(h))/(2*l);d>0&&d<1&&i[r].push(o(d));var f=(-s-Math.sqrt(h))/(2*l);f>0&&f<1&&i[r].push(o(f))},o=0;o<2;o++)r(o);a=n}():(i[0].push(s.x),i[1].push(s.y)))}var l=Math.min.apply(null,i[0]),u=Math.max.apply(null,i[0])-l,c=Math.min.apply(null,i[1]);return{x:l,y:c,width:u,height:Math.max.apply(null,i[1])-c}};function Nt(e){if(j())try{return e.getBBox()}catch(e){}var t=ct.data(e,"ref"),n=null,i=void 0,r=void 0;t?(r=ct(t).children().clone().attr("visibility","hidden"),ct(vt).append(r),n=r.filter("line, path")):n=ct(e).find("line, path");var a=!1;if(n.length)if(n.each(function(){var e=this.getBBox();e.width&&e.height||(a=!0)}),a){var o=t?r:ct(e).children();i=Rt(o)}else i=e.getBBox();else i=e.getBBox();return t&&r.remove(),i}var It=function(e){var t=e||ft.geSelectedElements()[0];if(1!==e.nodeType)return null;var n,i=t.nodeName,r=null;switch(i){case"text":""===t.textContent?(t.textContent="a",r=t.getBBox(),t.textContent=""):t.getBBox&&(r=t.getBBox());break;case"path":P?t.getBBox&&(r=t.getBBox()):r=Gt(t);break;case"g":case"a":r=Nt(t);break;default:if("use"===i&&(r=Nt(t)),"use"===i||"foreignObject"===i&&N()){if(r||(r=t.getBBox()),!N()){var a={};a.width=r.width,a.height=r.height,a.x=r.x+parseFloat(t.getAttribute("x")||0),a.y=r.y+parseFloat(t.getAttribute("y")||0),r=a}}else if(dt.includes(i))if(t)try{r=t.getBBox()}catch(e){var o=t.getExtentOfChar(0),s=t.getComputedTextLength();r={x:o.x,y:o.y,width:s,height:o.height}}else{var l=ct(t).closest("foreignObject");l.length&&l[0].getBBox&&(r=l[0].getBBox())}}return r&&(r={x:(n=r).x,y:n.y,width:n.width,height:n.height}),r},Mt=function(e){var t="";return ct.each(e,function(e,n){var i=n[1];t+=n[0];for(var r=0;r-.001&&n<.001||n<-89.99||n>89.99)}(a,o)){if(["ellipse","path","line","polyline","polygon"].includes(e.tagName))i=s=Vt(e,t,n);else if("rect"===e.tagName){var l=e.getAttribute("rx"),u=e.getAttribute("ry");(l||u)&&(i=s=Vt(e,t,n))}}if(!s){var c=_e(r).matrix;i=ye(i.x,i.y,i.width,i.height,c).aabox}}return i};function Bt(e){var t=e.getAttribute("stroke-width");return isNaN(t)||"none"===e.getAttribute("stroke")?0:t/2}var Rt=function(e,t,n){if(!e||!e.length)return!1;var i=void 0;if(ct.each(e,function(){i||this.parentNode&&(i=jt(this,t,n))}),void 0===i)return null;var r=i.x+i.width,a=i.y+i.height,o=i.x,s=i.y;if(1===e.length){var l=Bt(e[0]);o-=l,s-=l,r+=l,a+=l}else ct.each(e,function(e,i){var l=jt(i,t,n);if(l){var u=Bt(i);o=Math.min(o,l.x-u),s=Math.min(s,l.y-u),1===i.nodeType&&(r=Math.max(r,l.x+l.width+u),a=Math.max(a,l.y+l.height+u))}});return i.x=o,i.y=s,i.width=r-o,i.height=a-s,i},Dt=function(e){e||(e=ct(ft.getSVGContent()).children());var t=[];return ct(e).children().each(function(e,n){n.getBBox&&t.push(n)}),t.reverse()},Ft=function(e){return e||(e=Dt()),Rt(e,ft.addSvgElementFromJson,ft.pathActions)},Ut=function(e,t){if(!e)return 0;for(var n=e.numberOfItems,i=0;i3&&void 0!==arguments[3]?arguments[3]:{globals:!1};return function(){var r=arguments;function a(){n.apply(null,r)}var o=!("svgEditor"in window&&window.svgEditor&&!1===window.svgEditor.modules);if(!0===Qt[e])a();else if(Array.isArray(Qt[e]))Qt[e].push(a);else{Qt[e]=[];var s=o&&!i.globals?U:F;t.reduce(function(e,t){return e.then(function(){return s(t)})},Promise.resolve()).then(function(){a(),Qt[e].forEach(function(e){e()}),Qt[e]=!0})()}}},Zt=function(e){return $t("canvg",["canvg/rgbcolor.js","canvg/canvg.js"],e)},Kt=function(e){ct(e).click(function(e){e.preventDefault()})},Jt=jQuery,en={},tn=function(e){Object.keys(en).length||Jt("#cmenu_canvas").append("
  • ");var t=e.shortcut||"";Jt("#cmenu_canvas").append("
  • "+e.label+""+t+"
  • ")};function nn(e,t,o){if(null!=e||null!=t||null!=o){"string"==typeof e&&(e=document.getElementById(e)),null!=e.svg&&e.svg.stop();var s=function(e){var t={opts:e,FRAMERATE:30,MAX_VIRTUAL_PIXELS:3e4,log:function(e){}};!0===t.opts.log&&"undefined"!=typeof console&&(t.log=function(e){console.log(e)});t.init=function(e){var n=0;t.UniqueId=function(){return"canvg"+ ++n},t.Definitions={},t.Styles={},t.Animations=[],t.Images=[],t.ctx=e,t.ViewPort=new function(){this.viewPorts=[],this.Clear=function(){this.viewPorts=[]},this.SetCurrent=function(e,t){this.viewPorts.push({width:e,height:t})},this.RemoveCurrent=function(){this.viewPorts.pop()},this.Current=function(){return this.viewPorts[this.viewPorts.length-1]},this.width=function(){return this.Current().width},this.height=function(){return this.Current().height},this.ComputeSize=function(e){return null!=e&&"number"==typeof e?e:"x"===e?this.width():"y"===e?this.height():Math.sqrt(Math.pow(this.width(),2)+Math.pow(this.height(),2))/Math.sqrt(2)}}},t.init(),t.ImagesLoaded=function(){for(var e=0;e]*>/,"");var n=new ActiveXObject("Microsoft.XMLDOM");return n.async="false",n.loadXML(e),n};var o={baseline:"alphabetic","before-edge":"top","text-before-edge":"top",middle:"middle",central:"middle","after-edge":"bottom","text-after-edge":"bottom",ideographic:"ideographic",alphabetic:"alphabetic",hanging:"hanging",mathematical:"alphabetic"};return t.Property=function(){function e(t,i){n(this,e),this.name=t,this.value=i}return i(e,[{key:"getValue",value:function(){return this.value}},{key:"hasValue",value:function(){return null!=this.value&&""!==this.value}},{key:"numValue",value:function(){if(!this.hasValue())return 0;var e=parseFloat(this.value);return(this.value+"").match(/%$/)&&(e/=100),e}},{key:"valueOrDefault",value:function(e){return this.hasValue()?this.value:e}},{key:"numValueOrDefault",value:function(e){return this.hasValue()?this.numValue():e}},{key:"addOpacity",value:function(e){var n=this.value;if(null!=e.value&&""!==e.value&&"string"==typeof this.value){var i=new R(this.value);i.ok&&(n="rgba("+i.r+", "+i.g+", "+i.b+", "+e.numValue()+")")}return new t.Property(this.name,n)}},{key:"getDefinition",value:function(){var e=this.value.match(/#([^)'"]+)/);return e&&(e=e[1]),e||(e=this.value),t.Definitions[e]}},{key:"isUrlDefinition",value:function(){return this.value.startsWith("url(")}},{key:"getFillStyleDefinition",value:function(e,n){var i=this.getDefinition();if(null!=i&&i.createGradient)return i.createGradient(t.ctx,e,n);if(null!=i&&i.createPattern){if(i.getHrefAttribute().hasValue()){var r=i.attribute("patternTransform");i=i.getHrefAttribute().getDefinition(),r.hasValue()&&(i.attribute("patternTransform",!0).value=r.value)}return i.createPattern(t.ctx,e)}return null}},{key:"getDPI",value:function(e){return 96}},{key:"getEM",value:function(e){var n=12,i=new t.Property("fontSize",t.Font.Parse(t.ctx.font).fontSize);return i.hasValue()&&(n=i.toPixels(e)),n}},{key:"getUnits",value:function(){return(this.value+"").replace(/[0-9.-]/g,"")}},{key:"toPixels",value:function(e,n){if(!this.hasValue())return 0;var i=this.value+"";if(i.match(/em$/))return this.numValue()*this.getEM(e);if(i.match(/ex$/))return this.numValue()*this.getEM(e)/2;if(i.match(/px$/))return this.numValue();if(i.match(/pt$/))return this.numValue()*this.getDPI(e)*(1/72);if(i.match(/pc$/))return 15*this.numValue();if(i.match(/cm$/))return this.numValue()*this.getDPI(e)/2.54;if(i.match(/mm$/))return this.numValue()*this.getDPI(e)/25.4;if(i.match(/in$/))return this.numValue()*this.getDPI(e);if(i.match(/%$/))return this.numValue()*t.ViewPort.ComputeSize(e);var r=this.numValue();return n&&r<1?r*t.ViewPort.ComputeSize(e):r}},{key:"toMilliseconds",value:function(){if(!this.hasValue())return 0;var e=this.value+"";return e.match(/s$/)?1e3*this.numValue():(e.match(/ms$/),this.numValue())}},{key:"toRadians",value:function(){if(!this.hasValue())return 0;var e=this.value+"";return e.match(/deg$/)?this.numValue()*(Math.PI/180):e.match(/grad$/)?this.numValue()*(Math.PI/200):e.match(/rad$/)?this.numValue():this.numValue()*(Math.PI/180)}},{key:"toTextBaseline",value:function(){return this.hasValue()?o[this.value]:null}}]),e}(),t.Font=new function(){this.Styles="normal|italic|oblique|inherit",this.Variants="normal|small-caps|inherit",this.Weights="normal|bold|bolder|lighter|100|200|300|400|500|600|700|800|900|inherit",this.CreateFont=function(e,n,i,r,a,o){var s=null!=o?this.Parse(o):this.CreateFont("","","","","",t.ctx.font);return{fontFamily:a||s.fontFamily,fontSize:r||s.fontSize,fontStyle:e||s.fontStyle,fontWeight:i||s.fontWeight,fontVariant:n||s.fontVariant,toString:function(){return[this.fontStyle,this.fontVariant,this.fontWeight,this.fontSize,this.fontFamily].join(" ")}}};var e=this;this.Parse=function(n){for(var i={},r=t.trim(t.compressSpaces(n||"")).split(" "),a={fontSize:!1,fontStyle:!1,fontWeight:!1,fontVariant:!1},o="",s=0;sthis.x2&&(this.x2=e)),null!=t&&((isNaN(this.y1)||isNaN(this.y2))&&(this.y1=t,this.y2=t),tthis.y2&&(this.y2=t))},this.addX=function(e){this.addPoint(e,null)},this.addY=function(e){this.addPoint(null,e)},this.addBoundingBox=function(e){this.addPoint(e.x1,e.y1),this.addPoint(e.x2,e.y2)},this.addQuadraticCurve=function(e,t,n,i,r,a){var o=e+2/3*(n-e),s=t+2/3*(i-t),l=o+1/3*(r-e),u=s+1/3*(a-t);this.addBezierCurve(e,t,o,l,s,u,r,a)},this.addBezierCurve=function(e,t,n,i,r,a,o,s){var l=this,u=[e,t],c=[n,i],h=[r,a],d=[o,s];this.addPoint(u[0],u[1]),this.addPoint(d[0],d[1]);for(var f=function(e){var t=function(t){return Math.pow(1-t,3)*u[e]+3*Math.pow(1-t,2)*t*c[e]+3*(1-t)*Math.pow(t,2)*h[e]+Math.pow(t,3)*d[e]},n=6*u[e]-12*c[e]+6*h[e],i=-3*u[e]+9*c[e]-9*h[e]+3*d[e],r=3*c[e]-3*u[e];if(0===i){if(0===n)return"continue";var a=-r/n;return a>0&&a<1&&(0===e&&l.addX(t(a)),1===e&&l.addY(t(a))),"continue"}var o=Math.pow(n,2)-4*r*i;if(o<0)return"continue";var s=(-n+Math.sqrt(o))/(2*i);s>0&&s<1&&(0===e&&l.addX(t(s)),1===e&&l.addY(t(s)));var f=(-n-Math.sqrt(o))/(2*i);f>0&&f<1&&(0===e&&l.addX(t(f)),1===e&&l.addY(t(f)))},p=0;p<=1;p++)f(p)},this.isPointInBox=function(e,t){return this.x1<=e&&e<=this.x2&&this.y1<=t&&t<=this.y2},this.addPoint(e,t),this.addPoint(n,i)},t.Transform=function(e){this.Type={},this.Type.translate=function(e){this.p=t.CreatePoint(e),this.apply=function(e){e.translate(this.p.x||0,this.p.y||0)},this.unapply=function(e){e.translate(-1*this.p.x||0,-1*this.p.y||0)},this.applyToPoint=function(e){e.applyTransform([1,0,0,1,this.p.x||0,this.p.y||0])}},this.Type.rotate=function(e){var n=t.ToNumberArray(e);this.angle=new t.Property("angle",n[0]),this.cx=n[1]||0,this.cy=n[2]||0,this.apply=function(e){e.translate(this.cx,this.cy),e.rotate(this.angle.toRadians()),e.translate(-this.cx,-this.cy)},this.unapply=function(e){e.translate(this.cx,this.cy),e.rotate(-1*this.angle.toRadians()),e.translate(-this.cx,-this.cy)},this.applyToPoint=function(e){var t=this.angle.toRadians();e.applyTransform([1,0,0,1,this.p.x||0,this.p.y||0]),e.applyTransform([Math.cos(t),Math.sin(t),-Math.sin(t),Math.cos(t),0,0]),e.applyTransform([1,0,0,1,-this.p.x||0,-this.p.y||0])}},this.Type.scale=function(e){this.p=t.CreatePoint(e),this.apply=function(e){e.scale(this.p.x||1,this.p.y||this.p.x||1)},this.unapply=function(e){e.scale(1/this.p.x||1,1/this.p.y||this.p.x||1)},this.applyToPoint=function(e){e.applyTransform([this.p.x||0,0,0,this.p.y||0,0,0])}},this.Type.matrix=function(e){this.m=t.ToNumberArray(e),this.apply=function(e){e.transform(this.m[0],this.m[1],this.m[2],this.m[3],this.m[4],this.m[5])},this.applyToPoint=function(e){e.applyTransform(this.m)}},this.Type.SkewBase=function(e){function i(e){n(this,i);var r=a(this,(i.__proto__||Object.getPrototypeOf(i)).call(this,e));return r.angle=new t.Property("angle",e),r}return r(i,e),i}(this.Type.matrix),this.Type.skewX=function(e){function t(e){n(this,t);var i=a(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e));return i.m=[1,0,Math.tan(i.angle.toRadians()),1,0,0],i}return r(t,e),t}(this.Type.SkewBase),this.Type.skewY=function(e){function t(e){n(this,t);var i=a(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e));return i.m=[1,Math.tan(i.angle.toRadians()),0,1,0,0],i}return r(t,e),t}(this.Type.SkewBase),this.transforms=[],this.apply=function(e){for(var t=0;t=0;t--)this.transforms[t].unapply(e)},this.applyToPoint=function(e){for(var t=0;t=this.tokens.length-1},this.isCommandOrEnd=function(){return!!this.isEnd()||null!=this.tokens[this.i+1].match(/^[A-Za-z]$/)},this.isRelativeCommand=function(){switch(this.command){case"m":case"l":case"h":case"v":case"c":case"s":case"q":case"t":case"a":case"z":return!0}return!1},this.getToken=function(){return this.i++,this.tokens[this.i]},this.getScalar=function(){return parseFloat(this.getToken())},this.nextCommand=function(){this.previousCommand=this.command,this.command=this.getToken()},this.getPoint=function(){var e=new t.Point(this.getScalar(),this.getScalar());return this.makeAbsolute(e)},this.getAsControlPoint=function(){var e=this.getPoint();return this.control=e,e},this.getAsCurrentPoint=function(){var e=this.getPoint();return this.current=e,e},this.getReflectedControlPoint=function(){return"c"!==this.previousCommand.toLowerCase()&&"s"!==this.previousCommand.toLowerCase()&&"q"!==this.previousCommand.toLowerCase()&&"t"!==this.previousCommand.toLowerCase()?this.current:new t.Point(2*this.current.x-this.control.x,2*this.current.y-this.control.y)},this.makeAbsolute=function(e){return this.isRelativeCommand()&&(e.x+=this.current.x,e.y+=this.current.y),e},this.addMarker=function(e,t,n){null!=n&&this.angles.length>0&&null==this.angles[this.angles.length-1]&&(this.angles[this.angles.length-1]=this.points[this.points.length-1].angleTo(n)),this.addMarkerAngle(e,null==t?null:t.angleTo(e))},this.addMarkerAngle=function(e,t){this.points.push(e),this.angles.push(t)},this.getMarkerPoints=function(){return this.points},this.getMarkerAngles=function(){for(var e=0;e1&&(a*=Math.sqrt(d),o*=Math.sqrt(d));var f=(l===u?-1:1)*Math.sqrt((Math.pow(a,2)*Math.pow(o,2)-Math.pow(a,2)*Math.pow(h.y,2)-Math.pow(o,2)*Math.pow(h.x,2))/(Math.pow(a,2)*Math.pow(h.y,2)+Math.pow(o,2)*Math.pow(h.x,2)));isNaN(f)&&(f=0);var p=new t.Point(f*a*h.y/o,f*-o*h.x/a),g=new t.Point((r.x+c.x)/2+Math.cos(s)*p.x-Math.sin(s)*p.y,(r.y+c.y)/2+Math.sin(s)*p.x+Math.cos(s)*p.y),v=function(e){return Math.sqrt(Math.pow(e[0],2)+Math.pow(e[1],2))},m=function(e,t){return(e[0]*t[0]+e[1]*t[1])/(v(e)*v(t))},y=function(e,t){return(e[0]*t[1]=1&&(w=0);var S=1-u?1:-1,k=_+S*(w/2),C=new t.Point(g.x+a*Math.cos(k),g.y+o*Math.sin(k));if(n.addMarkerAngle(C,k-S*Math.PI/2),n.addMarkerAngle(c,k-S*Math.PI),i.addPoint(c.x,c.y),null!=e){var P=a>o?a:o,A=a>o?1:a/o,E=a>o?o/a:1;e.translate(g.x,g.y),e.rotate(s),e.scale(A,E),e.arc(0,0,P,_,_+w,1-u),e.scale(1/A,1/E),e.rotate(-s),e.translate(-g.x,-g.y)}};!n.isCommandOrEnd();)k();break;case"Z":case"z":null!=e&&e.closePath(),n.current=n.start}return i},r.getMarkers=function(){for(var e=this.PathParser.getMarkerPoints(),t=this.PathParser.getMarkerAngles(),n=[],i=0;i1&&(i.offset=1);var r=i.style("stop-color");return i.style("stop-opacity").hasValue()&&(r=r.addOpacity(i.style("stop-opacity"))),i.color=r.value,i}return r(t,e),t}(t.Element.ElementBase),t.Element.AnimateBase=function(e){function i(e){n(this,i);var r=a(this,(i.__proto__||Object.getPrototypeOf(i)).call(this,e));return t.Animations.push(r),r.duration=0,r.begin=r.attribute("begin").toMilliseconds(),r.maxDuration=r.begin+r.attribute("dur").toMilliseconds(),r.getProperty=function(){var e=this.attribute("attributeType").value,t=this.attribute("attributeName").value;return"CSS"===e?this.parent.style(t,!0):this.parent.attribute(t,!0)},r.initialValue=null,r.initialUnits="",r.removed=!1,r.calcValue=function(){return""},r.update=function(e){if(null==this.initialValue&&(this.initialValue=this.getProperty().value,this.initialUnits=this.getProperty().getUnits()),this.duration>this.maxDuration){if("indefinite"===this.attribute("repeatCount").value||"indefinite"===this.attribute("repeatDur").value)this.duration=0;else if("freeze"!==this.attribute("fill").valueOrDefault("remove")||this.frozen){if("remove"===this.attribute("fill").valueOrDefault("remove")&&!this.removed)return this.removed=!0,this.getProperty().value=this.parent.animationFrozen?this.parent.animationFrozenValue:this.initialValue,!0}else this.frozen=!0,this.parent.animationFrozen=!0,this.parent.animationFrozenValue=this.getProperty().value;return!1}this.duration=this.duration+e;var t=!1;if(this.beginn&&o.attribute("x").hasValue())break;r+=o.measureTextRecursive(e)}return-1*("end"===i?r:r/2)}return 0},r.renderChild=function(e,t,n){var i=t.children[n];i.attribute("x").hasValue()?(i.x=i.attribute("x").toPixels("x")+this.getAnchorDelta(e,t,n),i.attribute("dx").hasValue()&&(i.x+=i.attribute("dx").toPixels("x"))):(this.attribute("dx").hasValue()&&(this.x+=this.attribute("dx").toPixels("x")),i.attribute("dx").hasValue()&&(this.x+=i.attribute("dx").toPixels("x")),i.x=this.x),this.x=i.x+i.measureText(e),i.attribute("y").hasValue()?(i.y=i.attribute("y").toPixels("y"),i.attribute("dy").hasValue()&&(i.y+=i.attribute("dy").toPixels("y"))):(this.attribute("dy").hasValue()&&(this.y+=this.attribute("dy").toPixels("y")),i.attribute("dy").hasValue()&&(this.y+=i.attribute("dy").toPixels("y")),i.y=this.y),this.y=i.y,i.render(e);for(var r=0;r0&&" "!==t[n-1]&&n0&&" "!==t[n-1]&&(n===t.length-1||" "===t[n+1])&&(a="initial"),void 0!==e.glyphs[i]&&null==(r=e.glyphs[i][a])&&"glyph"===e.glyphs[i].type&&(r=e.glyphs[i])}else r=e.glyphs[i];return null==r&&(r=e.missingGlyph),r},r.renderChildren=function(e){var n=this.parent.style("font-family").getDefinition();if(null==n)""!==e.fillStyle&&e.fillText(t.compressSpaces(this.getText()),this.x,this.y),""!==e.strokeStyle&&e.strokeText(t.compressSpaces(this.getText()),this.x,this.y);else{var i=this.parent.style("font-size").numValueOrDefault(t.Font.Parse(t.ctx.font).fontSize),r=this.parent.style("font-style").valueOrDefault(t.Font.Parse(t.ctx.font).fontStyle),a=this.getText();n.isRTL&&(a=a.split("").reverse().join(""));for(var o=t.ToNumberArray(this.parent.attribute("dx").value),s=0;s=0&&e<=1&&this.group_.setAttribute("opacity",e)}},{key:"appendChildren",value:function(e){for(var t=0;t element");this.svgElem_=t,this.obj_num=0,this.idPrefix=i||"svg_",this.releasedNums=[],this.all_layers=[],this.layer_map={},this.current_layer=null,this.nonce_="";var r=this.svgElem_.getAttributeNS(l.SE,"nonce");r&&hn!==cn.NEVER_RANDOMIZE?this.nonce_=r:hn===cn.ALWAYS_RANDOMIZE&&this.setNonce(Math.floor(100001*Math.random()))}return i(e,[{key:"getElem_",value:function(e){return this.svgElem_.querySelector?this.svgElem_.querySelector("#"+e):ln(this.svgElem_).find("[id="+e+"]")[0]}},{key:"getSvgElem",value:function(){return this.svgElem_}},{key:"getNonce",value:function(){return this.nonce_}},{key:"setNonce",value:function(e){this.svgElem_.setAttributeNS(l.XMLNS,"xmlns:se",l.SE),this.svgElem_.setAttributeNS(l.SE,"se:nonce",e),this.nonce_=e}},{key:"clearNonce",value:function(){this.nonce_=""}},{key:"getId",value:function(){return this.nonce_?this.idPrefix+this.nonce_+"_"+this.obj_num:this.idPrefix+this.obj_num}},{key:"getNextId",value:function(){var e=this.obj_num,t=!1;this.releasedNums.length>0?(this.obj_num=this.releasedNums.pop(),t=!0):this.obj_num++;for(var n=this.getId();this.getElem_(n);)t&&(this.obj_num=e,t=!1),this.obj_num++,n=this.getId();return t&&(this.obj_num=e),n}},{key:"releaseId",value:function(e){var t=this.idPrefix+(this.nonce_?this.nonce_+"_":"");if("string"!=typeof e||!e.startsWith(t))return!1;var n=parseInt(e.substr(t.length),10);return!("number"!=typeof n||n<=0||this.releasedNums.includes(n))&&(this.releasedNums.push(n),!0)}},{key:"getNumLayers",value:function(){return this.all_layers.length}},{key:"hasLayer",value:function(e){return void 0!==this.layer_map[e]}},{key:"getLayerName",value:function(e){return e>=0&&e=t)return null;var n=void 0;for(n=0;nn?e0){var s=this.current_layer.getName();this.current_layer=this.all_layers[o-1],this.all_layers.splice(o,1),delete this.layer_map[s]}e.endBatchCommand()}}},{key:"mergeAllLayers",value:function(e){for(this.current_layer=this.all_layers[this.all_layers.length-1],e.startBatchCommand("Merge all Layers");this.all_layers.length>1;)this.mergeLayer(e);e.endBatchCommand()}},{key:"setCurrentLayer",value:function(e){var t=this.layer_map[e];return!!t&&(this.current_layer&&this.current_layer.deactivate(),this.current_layer=t,this.current_layer.activate(),!0)}},{key:"deleteCurrentLayer",value:function(){if(this.current_layer&&this.getNumLayers()>1){var e=this.current_layer.removeGroup();return this.identifyLayers(),e}return null}},{key:"identifyLayers",value:function(){this.all_layers=[],this.layer_map={};for(var e,t=this.svgElem_.childNodes.length,n=[],i=[],r=null,a=!1,o=0;o0||!a?((r=new an(pn(i),null,this.svgElem_)).appendChildren(n),this.all_layers.push(r),this.layer_map[name]=r):r.activate(),this.current_layer=r}},{key:"createLayer",value:function(e,t){this.current_layer&&this.current_layer.deactivate(),(void 0===e||null===e||""===e||this.layer_map[e])&&(e=pn(Object.keys(this.layer_map)));var n=new an(e,null,this.svgElem_);return t&&(t.startBatchCommand("Create Layer"),t.insertElement(n.getGroup()),t.endBatchCommand()),this.all_layers.push(n),this.layer_map[e]=n,this.current_layer=n,n.getGroup()}},{key:"cloneLayer",value:function(e,t){if(!this.current_layer)return null;this.current_layer.deactivate(),(void 0===e||null===e||""===e||this.layer_map[e])&&(e=pn(Object.keys(this.layer_map)));for(var n=this.current_layer.getGroup(),i=new an(e,n,this.svgElem_),r=i.getGroup(),a=n.childNodes,o=0;o=0?this.all_layers.splice(l+1,0,i):this.all_layers.push(i),this.layer_map[e]=i,this.current_layer=i,r}},{key:"getLayerVisibility",value:function(e){var t=this.layer_map[e];return!!t&&t.isVisible()}},{key:"setLayerVisibility",value:function(e,t){if("boolean"!=typeof t)return null;var n=this.layer_map[e];return n?(n.setVisible(t),n.getGroup()):null}},{key:"getLayerOpacity",value:function(e){var t=this.layer_map[e];return t?t.getOpacity():null}},{key:"setLayerOpacity",value:function(e,t){if(!("number"!=typeof t||t<0||t>1)){var n=this.layer_map[e];n&&n.setOpacity(t)}}},{key:"copyElem",value:function(e){var t=this;return function e(t,n){var i=document.createElementNS(t.namespaceURI,t.nodeName);if(ct.each(t.attributes,function(e,t){"-moz-math-font-style"!==t.localName&&i.setAttributeNS(t.namespaceURI,t.nodeName,t.value)}),i.removeAttribute("id"),i.id=n(),N()&&"path"===t.nodeName){var r=nt(t);i.setAttribute("d",r)}if(ct.each(t.childNodes,function(t,r){switch(r.nodeType){case 1:i.appendChild(e(r,n));break;case 3:i.textContent=r.nodeValue}}),ct(t).data("gsvg"))ct(i).data("gsvg",i.firstChild);else if(ct(t).data("symbol")){var a=ct(t).data("symbol");ct(i).data("ref",a).data("symbol",a)}else"image"===i.tagName&&Kt(i);return i}(e,function(){return t.getNextId()})}}]),e}(),vn=function(e,t){(hn=!1===e?cn.NEVER_RANDOMIZE:cn.ALWAYS_RANDOMIZE)!==cn.ALWAYS_RANDOMIZE||t.getNonce()?hn===cn.NEVER_RANDOMIZE&&t.getNonce()&&t.clearNonce():t.setNonce(Math.floor(100001*Math.random()))},mn=void 0,yn=function(e){mn=e},_n=function(){bn(),mn.getCurrentDrawing().identifyLayers()},bn=function(){var e=dn.length;if(e){for(var t=0;t0){for(var r=i.numberOfItems,a=r;r--;){var o=i.getItem(r);if(0===o.type)i.removeItem(r);else if(1===o.type){if(ge(o.matrix)){if(1===a)return t.removeAttribute("transform"),null;i.removeItem(r)}}else 4===o.type&&0===o.angle&&i.removeItem(r)}if(1===i.numberOfItems&&zt(t))return null}if(!i||0===i.numberOfItems)return t.setAttribute("transform",""),t.removeAttribute("transform"),null;if(i){for(var s=[],u=i.numberOfItems;u--;){var c=i.getItem(u);1===c.type?s.push([c.matrix,u]):s.length&&(s=[])}if(2===s.length){var h=n.createSVGTransformFromMatrix(ve(s[1][0],s[0][0]));i.removeItem(s[0][1]),i.removeItem(s[1][1]),i.insertItemBefore(h,s[1][1])}if((u=i.numberOfItems)>=2&&1===i.getItem(u-2).type&&2===i.getItem(u-1).type){var d=n.createSVGTransform(),f=ve(i.getItem(u-2).matrix,i.getItem(u-1).matrix);d.setMatrix(f),i.removeItem(u-2),i.removeItem(u-2),i.appendItem(d)}}switch(t.tagName){case"line":case"polyline":case"polygon":case"path":break;default:if(1===i.numberOfItems&&1===i.getItem(0).type||2===i.numberOfItems&&1===i.getItem(0).type&&4===i.getItem(0).type)return null}var p=Nn(t).data("gsvg"),g=new ce("Transform"),v={},m=null,y=[];switch(t.tagName){case"line":y=["x1","y1","x2","y2"];break;case"circle":y=["cx","cy","r"];break;case"ellipse":y=["cx","cy","rx","ry"];break;case"foreignObject":case"rect":case"image":y=["width","height","x","y"];break;case"use":case"text":case"tspan":y=["x","y"];break;case"polygon":case"polyline":(m={}).points=t.getAttribute("points");var _=t.points,b=_.numberOfItems;v.points=new Array(b);for(var x=0;x1e-10?Math.sin(E)/(1-Math.cos(E)):2/E;for(var G=0;G=3&&3===i.getItem(L-2).type&&2===i.getItem(L-3).type&&2===i.getItem(L-1).type){j=3;for(var D=i.getItem(L-3).matrix,F=i.getItem(L-2).matrix,U=i.getItem(L-1).matrix,z=t.childNodes,H=z.length;H--;){var q=z.item(H);if(O=0,V=0,1===q.nodeType){var X=W(q);if(!X)continue;var Y=_e(X).matrix,Q=zt(q);if(R=In.getStartTransform(),In.setStartTransform(q.getAttribute("transform")),Q||me(X)){var $=n.createSVGTransform();$.setMatrix(ve(D,F,U,Y)),X.clear(),X.appendItem($)}else{var Z=ve(Y.inverse(),U,Y),K=n.createSVGMatrix();K.e=-Z.e,K.f=-Z.f;var J=ve(K.inverse(),Y.inverse(),D,F,U,Y,Z.inverse()),ee=n.createSVGTransform(),te=n.createSVGTransform(),ne=n.createSVGTransform();ee.setTranslate(Z.e,Z.f),te.setScale(J.a,J.d),ne.setTranslate(K.e,K.f),X.appendItem(ne),X.appendItem(te),X.appendItem(ee)}g.addSubCommand(e(q)),In.setStartTransform(R)}}i.removeItem(L-1),i.removeItem(L-2),i.removeItem(L-3)}else if(L>=3&&1===i.getItem(L-1).type){j=3,P=_e(i).matrix;var re=n.createSVGTransform();re.setMatrix(P),i.clear(),i.appendItem(re)}else if((1===L||L>1&&3!==i.getItem(1).type)&&2===i.getItem(0).type){j=2;var ae=_e(i).matrix;i.removeItem(0);var oe=_e(i).matrix.inverse(),se=ve(oe,ae);if(O=se.e,V=se.f,0!==O||0!==V){for(var le=t.childNodes,he=le.length,de=[];he--;){var fe=le.item(he);if(1===fe.nodeType){if(fe.getAttribute("clip-path")){var ye=fe.getAttribute("clip-path");de.includes(ye)||(Mn(ye,O,V),de.push(ye))}R=In.getStartTransform(),In.setStartTransform(fe.getAttribute("transform"));var be=W(fe);if(be){var xe=n.createSVGTransform();xe.setTranslate(O,V),be.numberOfItems?be.insertItemBefore(xe,0):be.appendItem(xe),g.addSubCommand(e(fe));for(var we=t.getElementsByTagNameNS(l.SVG,"use"),Se="#"+fe.id,ke=we.length;ke--;){var Ce=we.item(ke);if(Se===At(Ce)){var Pe=n.createSVGTransform();Pe.setTranslate(-O,-V),W(Ce).insertItemBefore(Pe,0),g.addSubCommand(e(Ce))}}In.setStartTransform(R)}}}de=[],In.setStartTransform(R)}}else{if(1!==L||1!==i.getItem(0).type||A){if(A){var Ae=n.createSVGTransform();Ae.setRotate(A,k.x,k.y),i.numberOfItems?i.insertItemBefore(Ae,0):i.appendItem(Ae)}return 0===i.numberOfItems&&t.removeAttribute("transform"),null}j=1;for(var Ee=i.getItem(0).matrix,Te=t.childNodes,Ge=Te.length;Ge--;){var Ne=Te.item(Ge);if(1===Ne.nodeType){R=In.getStartTransform(),In.setStartTransform(Ne.getAttribute("transform"));var Ie=W(Ne);if(!Ie)continue;var Me=ve(Ee,_e(Ie).matrix),Le=n.createSVGTransform();Le.setMatrix(Me),Ie.clear(),Ie.appendItem(Le,0),g.addSubCommand(e(Ne)),In.setStartTransform(R);var Oe=Ne.getAttribute("stroke-width");if("none"!==Ne.getAttribute("stroke")&&!isNaN(Oe)){var Ve=(Math.abs(Me.a)+Math.abs(Me.d))/2;Ne.setAttribute("stroke-width",Oe*Ve)}}}i.clear()}if(2===j){if(A){k={x:S.x+B.e,y:S.y+B.f};var je=n.createSVGTransform();je.setRotate(A,k.x,k.y),i.numberOfItems?i.insertItemBefore(je,0):i.appendItem(je)}}else if(3===j){var Be=_e(i).matrix,Re=n.createSVGTransform();Re.setRotate(A,S.x,S.y);var De=Re.matrix,Fe=n.createSVGTransform();Fe.setRotate(A,k.x,k.y);var Ue=Fe.matrix.inverse(),ze=Be.inverse(),He=ve(ze,Ue,De,Be);if(O=He.e,V=He.f,0!==O||0!==V)for(var qe=t.childNodes,Xe=qe.length;Xe--;){var Ye=qe.item(Xe);if(1===Ye.nodeType){R=In.getStartTransform(),In.setStartTransform(Ye.getAttribute("transform"));var We=W(Ye),Qe=n.createSVGTransform();Qe.setTranslate(O,V),We.numberOfItems?We.insertItemBefore(Qe,0):We.appendItem(Qe),g.addSubCommand(e(Ye)),In.setStartTransform(R)}}A&&(i.numberOfItems?i.insertItemBefore(Fe,0):i.appendItem(Fe))}}else{var $e=It(t);if(!$e&&"path"!==t.tagName)return null;var Ze=n.createSVGMatrix(),Ke=zt(t);if(Ke){S={x:$e.x+$e.width/2,y:$e.y+$e.height/2},k=pe($e.x+$e.width/2,$e.y+$e.height/2,_e(i).matrix);for(var Je=Ke*Math.PI/180,et=Math.abs(Je)>1e-10?Math.sin(Je)/(1-Math.cos(Je)):2/Je,tt=0;tt=3&&3===i.getItem(at-2).type&&2===i.getItem(at-3).type&&2===i.getItem(at-1).type)rt=3,Ze=_e(i,at-3,at-1).matrix,i.removeItem(at-1),i.removeItem(at-2),i.removeItem(at-3);else if(4===at&&1===i.getItem(at-1).type){rt=3,Ze=_e(i).matrix;var dt=n.createSVGTransform();dt.setMatrix(Ze),i.clear(),i.appendItem(dt),Ze=n.createSVGMatrix()}else if((1===at||at>1&&3!==i.getItem(1).type)&&2===i.getItem(0).type){rt=2;var ft=i.getItem(0).matrix,pt=_e(i,1).matrix,gt=pt.inverse();Ze=ve(gt,ft,pt),i.removeItem(0)}else{if(1!==at||1!==i.getItem(0).type||Ke){if(rt=4,Ke){var vt=n.createSVGTransform();vt.setRotate(Ke,k.x,k.y),i.numberOfItems?i.insertItemBefore(vt,0):i.appendItem(vt)}return 0===i.numberOfItems&&t.removeAttribute("transform"),null}switch(Ze=_e(i).matrix,t.tagName){case"line":v=Nn(t).attr(["x1","y1","x2","y2"]);case"polyline":case"polygon":if(v.points=t.getAttribute("points"),v.points){var mt=t.points,yt=mt.numberOfItems;v.points=new Array(yt);for(var _t=0;_t0;)n.push(n.shift()),i--;var r=0;for(t in Bn.selectorGrips)Bn.selectorGrips[t].setAttribute("style","cursor:"+n[r]+"-resize"),r++}},{key:"showGrips",value:function(e){var t=e?"inline":"none";Bn.selectorGripsGroup.setAttribute("display",t);var n=this.selectedElement;this.hasGrips=e,n&&e&&(this.selectorGroup.appendChild(Bn.selectorGripsGroup),this.updateGripCursors(zt(n)))}},{key:"resize",value:function(e){var t=this.selectorRect,n=Bn,i=n.selectorGrips,r=this.selectedElement,a=r.getAttribute("stroke-width"),o=Vn.getCurrentZoom(),s=1/o;"none"===r.getAttribute("stroke")||isNaN(a)||(s+=a/2);var l=r.tagName;"text"===l&&(s+=2/o);var u=W(r),c=_e(u).matrix;if(c.e*=o,c.f*=o,e||(e=It(r)),"g"===l&&!On.data(r,"gsvg")){var h=Rt([r.childNodes]);h&&(e=h)}var d=e.x,f=e.y,p=e.width,g=e.height;e={x:d,y:f,width:p,height:g},s*=o;var v=ye(d*o,f*o,p*o,g*o,c),m=v.aabox,y=m.x-s,_=m.y-s,b=m.width+2*s,x=m.height+2*s,w=y+b/2,S=_+x/2,k=zt(r);if(k){var C=Vn.svgRoot().createSVGTransform();C.setRotate(-k,w,S);var P=C.matrix;v.tl=pe(v.tl.x,v.tl.y,P),v.tr=pe(v.tr.x,v.tr.y,P),v.bl=pe(v.bl.x,v.bl.y,P),v.br=pe(v.br.x,v.br.y,P);var A=v.tl,E=A.x,T=A.y,G=A.x,N=A.y,I=Math.min,M=Math.max;y=E=I(E,I(v.tr.x,I(v.bl.x,v.br.x)))-s,_=T=I(T,I(v.tr.y,I(v.bl.y,v.br.y)))-s,b=(G=M(G,M(v.tr.x,M(v.bl.x,v.br.x)))+s)-E,x=(N=M(N,M(v.tr.y,M(v.bl.y,v.br.y)))+s)-T}var L="M"+y+","+_+" L"+(y+b)+","+_+" "+(y+b)+","+(_+x)+" "+y+","+(_+x)+"z";t.setAttribute("d",L);var O=k?"rotate("+[k,w,S].join(",")+")":"";for(var V in this.selectorGroup.setAttribute("transform",O),this.gripCoords={nw:[y,_],ne:[y+b,_],sw:[y,_+x],se:[y+b,_+x],n:[y+b/2,_],w:[y,_+x/2],e:[y+b,_+x/2],s:[y+b/2,_+x]},this.gripCoords){var j=this.gripCoords[V];i[V].setAttribute("cx",j[0]),i[V].setAttribute("cy",j[1])}n.rotateGripConnector.setAttribute("x1",y+b/2),n.rotateGripConnector.setAttribute("y1",_),n.rotateGripConnector.setAttribute("x2",y+b/2),n.rotateGripConnector.setAttribute("y2",_-5*Rn),n.rotateGrip.setAttribute("cx",y+b/2),n.rotateGrip.setAttribute("cy",_-5*Rn)}}]),e}(),Fn=function(){function e(){n(this,e),this.selectorParentGroup=null,this.rubberBandBox=null,this.selectors=[],this.selectorMap={},this.selectorGrips={nw:null,n:null,ne:null,e:null,se:null,s:null,sw:null,w:null},this.selectorGripsGroup=null,this.rotateGripConnector=null,this.rotateGrip=null,this.initGroup()}return i(e,[{key:"initGroup",value:function(){for(var e in this.selectorParentGroup&&this.selectorParentGroup.parentNode&&this.selectorParentGroup.parentNode.removeChild(this.selectorParentGroup),this.selectorParentGroup=Vn.createSVGElement({element:"g",attr:{id:"selectorParentGroup"}}),this.selectorGripsGroup=Vn.createSVGElement({element:"g",attr:{display:"none"}}),this.selectorParentGroup.appendChild(this.selectorGripsGroup),Vn.svgRoot().appendChild(this.selectorParentGroup),this.selectorMap={},this.selectors=[],this.rubberBandBox=null,this.selectorGrips){var t=Vn.createSVGElement({element:"circle",attr:{id:"selectorGrip_resize_"+e,fill:"#22C",r:Rn,style:"cursor:"+e+"-resize","stroke-width":2,"pointer-events":"all"}});On.data(t,"dir",e),On.data(t,"type","resize"),this.selectorGrips[e]=this.selectorGripsGroup.appendChild(t)}if(this.rotateGripConnector=this.selectorGripsGroup.appendChild(Vn.createSVGElement({element:"line",attr:{id:"selectorGrip_rotateconnector",stroke:"#22C","stroke-width":"1"}})),this.rotateGrip=this.selectorGripsGroup.appendChild(Vn.createSVGElement({element:"circle",attr:{id:"selectorGrip_rotate",fill:"lime",r:Rn,stroke:"#22C","stroke-width":2,style:"cursor:url("+jn.imgPath+"rotate.png) 12 12, auto;"}})),On.data(this.rotateGrip,"type","rotate"),!On("#canvasBackground").length){var n=jn.dimensions,i=Vn.createSVGElement({element:"svg",attr:{id:"canvasBackground",width:n[0],height:n[1],x:0,y:0,overflow:N()?"none":"visible",style:"pointer-events:none"}}),r=Vn.createSVGElement({element:"rect",attr:{width:"100%",height:"100%",x:0,y:0,"stroke-width":1,stroke:"#000",fill:"#FFF",style:"pointer-events:none"}});i.appendChild(r),Vn.svgRoot().insertBefore(i,Vn.svgContent())}}},{key:"requestSelector",value:function(e,n){if(null==e)return null;var i=this.selectors.length;if("object"===t(this.selectorMap[e.id]))return this.selectorMap[e.id].locked=!0,this.selectorMap[e.id];for(var r=0;r').documentElement,!0);i.appendChild(h);var d=c.createElementNS(l.SVG,"svg");(s.clearSvgContentElement=function(){Un(d).empty(),Un(d).attr({id:"svgcontent",width:o[0],height:o[1],x:o[0],y:o[1],overflow:a.show_outside_canvas?"visible":"hidden",xmlns:l.SVG,"xmlns:se":l.SE,"xmlns:xlink":l.XLINK}).appendTo(h);var e=c.createComment(" Created with SVG-edit - https://github.com/SVG-Edit/svgedit");d.appendChild(e)})();var f="svg_";s.setIdPrefix=function(e){f=e},s.current_drawing_=new gn(d,f);var p=s.getCurrentDrawing=function(){return s.current_drawing_},g=1,v=null,m={shape:{fill:("none"===a.initFill.color?"":"#")+a.initFill.color,fill_paint:null,fill_opacity:a.initFill.opacity,stroke:"#"+a.initStroke.color,stroke_paint:null,stroke_opacity:a.initStroke.opacity,stroke_width:a.initStroke.width,stroke_dasharray:"none",stroke_linejoin:"miter",stroke_linecap:"butt",opacity:a.initOpacity}};m.text=Un.extend(!0,{},m.shape),Un.extend(m.text,{fill:"#000000",stroke_width:a.text&&a.text.stroke_width,font_size:a.text&&a.text.font_size,font_family:a.text&&a.text.font_family});var y=m.shape,_=[],b=this.getJsonFromSvgElement=function(e){if(3===e.nodeType)return e.nodeValue;for(var t,n={element:e.tagName,attr:{},children:[]},i=0;t=e.attributes[i];i++)n.attr[t.name]=t.value;for(var r,a=0;r=e.childNodes[a];a++)n.children[a]=b(r);return n},x=this.addSvgElementFromJson=function(e){if("string"==typeof e)return c.createTextNode(e);var t=qt(e.attr.id),n=p().getCurrentLayer();if(t&&e.element!==t.tagName&&(n.removeChild(t),t=null),!t){var i=e.namespace||l.SVG;t=c.createElementNS(i,e.element),n&&(v||n).appendChild(t)}return e.curStyles&&Xt(t,{fill:y.fill,stroke:y.stroke,"stroke-width":y.stroke_width,"stroke-dasharray":y.stroke_dasharray,"stroke-linejoin":y.stroke_linejoin,"stroke-linecap":y.stroke_linecap,"stroke-opacity":y.stroke_opacity,"fill-opacity":y.fill_opacity,opacity:y.opacity/2,style:"pointer-events:inherit"},100),Xt(t,e.attr,100),Yt(t),e.children&&e.children.forEach(function(e){t.appendChild(x(e))}),t};s.getTransformList=W,s.matrixMultiply=ve,s.hasMatrixTransform=me,s.transformListToTransform=_e,function(e){K=e;var t=document.createElementNS(l.SVG,"svg");document.body.appendChild(t);var n=document.createElementNS(l.SVG,"rect");n.setAttribute("width","1em"),n.setAttribute("height","1ex"),n.setAttribute("x","1in"),t.appendChild(n);var i=n.getBBox();document.body.removeChild(t);var r=i.x;J={em:i.width,ex:i.height,in:r,cm:r/2.54,mm:r/25.4,pt:r/72,pc:r/6,px:1,"%":0}}({getBaseUnit:function(){return a.baseUnit},getElement:qt,getHeight:function(){return d.getAttribute("height")/g},getWidth:function(){return d.getAttribute("width")/g},getRoundDigits:function(){return ue.round_digits}}),s.convertToNum=ie;var w,S=function(){return d},k=this.getSelectedElems=function(){return _},P=ut;ft=w={pathActions:P,getSVGContent:S,addSvgElementFromJson:x,getSelectedElements:k,getDOMDocument:function(){return c},getDOMContainer:function(){return i},getSVGRoot:function(){return h},getBaseUnit:function(){return a.baseUnit},getSnappingStep:function(){return a.snappingStep}},pt=w.getDOMDocument(),gt=w.getDOMContainer(),vt=w.getSVGRoot(),s.findDefs=Tt,s.getUrlFromAttr=Pt,s.getHref=At,s.setHref=Et,s.getBBox=It,s.getRotationAngle=zt,s.getElem=qt,s.getRefElem=Ht,s.assignAttributes=Xt,this.cleanupElement=Yt;var A=function(){return a.gridSnapping};!function(e){Tn=e}({getDrawing:function(){return p()},getSVGRoot:function(){return h},getGridSnapping:A}),this.remapElement=Gn,function(e){In=e}({getSVGRoot:function(){return h},getStartTransform:function(){return Ae},setStartTransform:function(e){Ae=e}}),this.recalculateDimensions=Ln;var E=u();s.sanitizeSvg=Pn;var T=s.undoMgr=new Wn({handleHistoryEvent:function(e,t){var n=Qn;if(e===n.BEFORE_UNAPPLY||e===n.BEFORE_APPLY)s.clearSelection();else if(e===n.AFTER_APPLY||e===n.AFTER_UNAPPLY){var i=t.elements();s.pathActions.clear(),U("changed",i);var r=t.type(),a=e===n.AFTER_APPLY;if(r===zn.type())(a?t.newParent:t.oldParent)===d&&_n();else if(r===Hn.type()||r===qn.type())t.parent===d&&_n(),r===Hn.type()?a&&se(t.elem):a||se(t.elem),"use"===t.elem.tagName&&jt(t.elem);else if(r===Xn.type()){"title"===t.elem.tagName&&t.elem.parentNode.parentNode===d&&_n();var o=a?t.newValues:t.oldValues;o.stdDeviation&&s.setBlurOffsets(t.elem.parentNode,o.stdDeviation)}}}}),G=function(e){s.undoMgr.addCommandToHistory(e)},O=this.getZoom=function(){return g},V=this.round=function(e){return parseInt(e*g,10)/g};!function(e,t){jn=e,Vn=t,Bn=new Fn}(a,{createSVGElement:function(e){return s.addSvgElementFromJson(e)},svgRoot:function(){return h},svgContent:function(){return d},getCurrentZoom:O});var j=this.selectorManager=Bn,D=s.getNextId=function(){return p().getNextId()},F=s.getId=function(){return p().getId()},U=function(e,t){if(Ue[e])return Ue[e](window,t)},z=function(e){_.map(function(e){null!=e&&j.releaseSelector(e)}),_=[],e||U("selected",_)},H=function(e,t){if(e.length){for(var n=0;n<_.length&&null!=_[n];)++n;for(var i=e.length;i--;){var r=e[i];if(r){var a=It(r);if(a&&("a"===r.tagName&&1===r.childNodes.length&&(r=r.firstChild),!_.includes(r))){_[n]=r,n++;var o=j.requestSelector(r,a);_.length>1&&o.showGrips(!1)}}}for(U("selected",_),t||1===_.length?j.requestSelector(_[0]).showGrips(!0):j.requestSelector(_[0]).showGrips(!1),_.sort(function(e,t){return e&&t&&e.compareDocumentPosition?3-(6&t.compareDocumentPosition(e)):null==e?1:void 0});null==_[0];)_.shift(0)}},Y=function(){return y.opacity},Q=this.getMouseTarget=function(e){if(null==e)return null;var t=e.target;if(t.correspondingUseElement&&(t=t.correspondingUseElement),[l.MATH,l.HTML].includes(t.namespaceURI)&&"svgcanvas"!==t.id)for(;"foreignObject"!==t.nodeName;)if(!(t=t.parentNode))return h;var n=p().getCurrentLayer();if([h,i,d,n].includes(t))return h;if(Un(t).closest("#selectorParentGroup").length)return j.selectorParentGroup;for(;t.parentNode!==(v||n);)t=t.parentNode;return t};s.pathActions=P,Ie({selectorManager:j,canvas:s,call:U,resetD:function(e){e.setAttribute("d",P.convertPath(e))},round:V,clearSelection:z,addToSelection:H,addCommandToHistory:G,remapElement:Gn,addSvgElementFromJson:x,getGridSnapping:A,getOpacity:Y,getSelectedElements:k,getContainer:function(){return i},setStarted:function(e){Ce=e},getRubberBox:function(){return Oe},setRubberBox:function(e){return Oe=e},addPtsToSelection:function(e){var t=e.closedSubpath,n=e.grips;P.canDeleteNodes=!0,P.closed_subpath=t,U("pointsAdded",{closedSubpath:t,grips:n}),U("selected",n)},endChanges:function(e){var t=e.cmd,n=e.elem;G(t),U("changed",[n])},getCurrentZoom:O,getId:F,getNextId:D,getMouseTarget:Q,getCurrentMode:function(){return Ee},setCurrentMode:function(e){return Ee=e},getDrawnPath:function(){return bt},setDrawnPath:function(e){return bt=e},getSVGRoot:function(){return h}});var $={},Z="a,circle,ellipse,foreignObject,g,image,line,path,polygon,polyline,rect,svg,text,tspan,use",re=["clip-path","fill","filter","marker-end","marker-mid","marker-start","mask","stroke"],ae=Un.data,oe=document.createElementNS(l.SVG,"animate");Un(oe).attr({attributeName:"opacity",begin:"indefinite",dur:1,fill:"freeze"}).appendTo(h);var se=function e(t){var n=Un(t).attr(re);for(var i in n){var r=n[i];if(r&&r.startsWith("url(")){var a=Pt(r).substr(1);qt(a)||(Tt().appendChild(Se[a]),delete Se[a])}}var o=t.getElementsByTagName("*");if(o.length)for(var s=0,l=o.length;s0&&(4===s.getItem(0).type&&s.removeItem(0));if(0!==e){var l=pe(a,o,_e(s).matrix),u=h.createSVGTransform();u.setRotate(e,l.x,l.y),s.numberOfItems?s.insertItemBefore(u,0):s.appendItem(u)}else 0===s.numberOfItems&&n.removeAttribute("transform");if(!t){var c=n.getAttribute("transform");n.setAttribute("transform",i),rn("transform",c,_),U("changed",_)}var d=j.requestSelector(_[0]);d.resize(),d.updateGripCursors(e)};var He=this.recalculateAllSelectedDimensions=function(){for(var e=new Yn("none"===Ne?"position":"size"),t=_.length;t--;){var n=_[t],i=Ln(n);i&&e.addSubCommand(i)}e.isEmpty()||(G(e),U("changed",_))},qe=function(e){console.log([e.a,e.b,e.c,e.d,e.e,e.f])},Xe=null;this.clearSelection=z,this.addToSelection=H;var We=this.selectOnly=function(e,t){z(!0),H(e,t)};this.removeFromSelection=function(e){if(null!=_[0]&&e.length){var t=0,n=[],i=_.length;n.length=i;for(var r=0;r0&&s.removeFromSelection(E),T.length>0&&s.addToSelection(T);break;case"resize":k=W(f);var M=me(k),L=(d=M?tt:It(f)).x,O=d.y,V=d,B=V.width,R=V.height;if(o=x-Ze,l=S-Ke,a.gridSnapping&&(o=Wt(o),l=Wt(l),R=Wt(R),B=Wt(B)),c=zt(f)){var D=Math.sqrt(o*o+l*l),z=Math.atan2(l,o)-c*Math.PI/180;o=D*Math.cos(z),l=D*Math.sin(z)}Ne.includes("n")||Ne.includes("s")||(l=0),Ne.includes("e")||Ne.includes("w")||(o=0);var H=0,q=0,X=R?(R+l)/R:1,Y=B?(B+o)/B:1;Ne.includes("n")&&(X=R?(R-l)/R:1,q=R),Ne.includes("w")&&(Y=B?(B-o)/B:1,H=B);var Q=h.createSVGTransform(),$=h.createSVGTransform(),Z=h.createSVGTransform();if(a.gridSnapping&&(L=Wt(L),H=Wt(H),O=Wt(O),q=Wt(q)),Q.setTranslate(-(L+H),-(O+q)),e.shiftKey&&(1===Y?Y=X:X=Y),$.setScale(Y,X),Z.setTranslate(L+H,O+q),M){var K=c?1:0;k.replaceItem(Q,2+K),k.replaceItem($,1+K),k.replaceItem(Z,Number(K))}else{var J=k.numberOfItems;k.replaceItem(Z,J-3),k.replaceItem($,J-2),k.replaceItem(Q,J-1)}j.requestSelector(f).resize(),U("transition",_);break;case"zoom":b*=g,w*=g,Xt(Oe,{x:Math.min(Je*g,b),y:Math.min(et*g,w),width:Math.abs(b-Je*g),height:Math.abs(w-et*g)},100);break;case"text":Xt(y,{x:x,y:S},1e3);break;case"line":a.gridSnapping&&(x=Wt(x),S=Wt(S));var ee=x,te=S;e.shiftKey&&(ee=(n=xe(Ze,Ke,ee,te)).x,te=n.y),y.setAttributeNS(null,"x2",ee),y.setAttributeNS(null,"y2",te);break;case"foreignObject":case"square":case"rect":case"image":var ne="square"===Ee||e.shiftKey,ie=Math.abs(x-Ze),re=Math.abs(S-Ke),ae=void 0,oe=void 0;ne?(ie=re=Math.max(ie,re),ae=Ze.8&&($e+=+st.x+","+st.y+" ",y.setAttributeNS(null,"points",$e),nt-=.8);it={x:rt.x,y:rt.y},rt={x:at.x,y:at.y},at={x:ot.x,y:ot.y};break;case"path":case"pathedit":if(x*=g,S*=g,a.gridSnapping&&(x=Wt(x),S=Wt(S),Ze=Wt(Ze),Ke=Wt(Ke)),e.shiftKey){var he=Ge,de=void 0,fe=void 0;he?(de=he.dragging?he.dragging[0]:Ze,fe=he.dragging?he.dragging[1]:Ke):(de=Ze,fe=Ke);var ge=n=xe(de,fe,x,S);x=ge.x,S=ge.y}Oe&&"none"!==Oe.getAttribute("display")&&(b*=g,w*=g,Xt(Oe,{x:Math.min(Je*g,b),y:Math.min(et*g,w),width:Math.abs(b-Je*g),height:Math.abs(w-et*g)},100)),P.mouseMove(x,S);break;case"textedit":x*=g,S*=g,xt.mouseMove(v,m);break;case"rotate":i=(d=It(f)).x+d.width/2,r=d.y+d.height/2;var ve=be(f),ye=pe(i,r,ve);i=ye.x,r=ye.y,c=(Math.atan2(r-S,i-x)*(180/Math.PI)-90)%360,a.gridSnapping&&(c=Wt(c)),e.shiftKey&&(c=45*Math.round(c/45)),s.setRotationAngle(c<-180?360+c:c,!0),U("transition",_)}Be("mouseMove",{event:e,mouse_x:v,mouse_y:m,selected:f})}}).click(function(e){return e.preventDefault(),!1}).dblclick(function(e){var t=e.target.parentNode;if(t!==v){var n=Q(e),i=n.tagName;if("text"===i&&"textedit"!==Ee){var r=pe(e.pageX,e.pageY,Xe);xt.select(n,r.x,r.y)}"g"!==i&&"a"!==i||!zt(n)||(an(n),n=_[0],z(!0)),v&&bn(),"g"!==t.tagName&&"a"!==t.tagName||t===p().getCurrentLayer()||n===j.selectorParentGroup||xn(n)}}).mouseup(function(e){if(2!==e.button){var t=Le;if(Le=null,Ce){var n=pe(e.pageX,e.pageY,Xe),i=n.x*g,r=n.y*g,o=i/g,l=r/g,u=qt(F()),c=!1,h=o,d=l;Ce=!1;var f=void 0,v=void 0;switch(Ee){case"resize":case"multiselect":null!=Oe&&(Oe.setAttribute("display","none"),Ve=[]),Ee="select";case"select":if(null!=_[0]){if(null==_[1]){var m=_[0];switch(m.tagName){case"g":case"use":case"image":case"foreignObject":break;default:Me.fill=m.getAttribute("fill"),Me.fill_opacity=m.getAttribute("fill-opacity"),Me.stroke=m.getAttribute("stroke"),Me.stroke_opacity=m.getAttribute("stroke-opacity"),Me.stroke_width=m.getAttribute("stroke-width"),Me.stroke_dasharray=m.getAttribute("stroke-dasharray"),Me.stroke_linejoin=m.getAttribute("stroke-linejoin"),Me.stroke_linecap=m.getAttribute("stroke-linecap")}"text"===m.tagName&&(he.font_size=m.getAttribute("font-size"),he.font_family=m.getAttribute("font-family")),j.requestSelector(m).showGrips(!0)}if(He(),h!==Je||d!==et)for(var b=_.length,w=0;w=0?C.indexOf(",",A+1)>=0:C.indexOf(" ",C.indexOf(" ")+1)>=0)&&(u=P.smoothPolylineIntoPath(u));break;case"line":f=Un(u).attr(["x1","x2","y1","y2"]),c=f.x1!==f.x2||f.y1!==f.y2;break;case"foreignObject":case"square":case"rect":case"image":f=Un(u).attr(["width","height"]),c="0"!==f.width||"0"!==f.height||"image"===Ee;break;case"circle":c="0"!==u.getAttribute("r");break;case"ellipse":f=Un(u).attr(["rx","ry"]),c=null!=f.rx||null!=f.ry;break;case"fhellipse":Qe.maxx-Qe.minx>0&&Qe.maxy-Qe.miny>0&&(u=x({element:"ellipse",curStyles:!0,attr:{cx:(Qe.minx+Qe.maxx)/2,cy:(Qe.miny+Qe.maxy)/2,rx:(Qe.maxx-Qe.minx)/2,ry:(Qe.maxy-Qe.miny)/2,id:F()}}),U("changed",[u]),c=!0);break;case"fhrect":Qe.maxx-Qe.minx>0&&Qe.maxy-Qe.miny>0&&(u=x({element:"rect",curStyles:!0,attr:{x:Qe.minx,y:Qe.miny,width:Qe.maxx-Qe.minx,height:Qe.maxy-Qe.miny,id:F()}}),U("changed",[u]),c=!0);break;case"text":c=!0,We([u]),xt.start(u);break;case"path":u=null,Ce=!0;var E=P.mouseUp(e,u,i,r);u=E.element,c=E.keep;break;case"pathedit":c=!0,u=null,P.mouseUp(e);break;case"textedit":c=!1,u=null,xt.mouseUp(e,i,r);break;case"rotate":c=!0,u=null,Ee="select";var T=s.undoMgr.finishUndoableChange();T.isEmpty()||G(T),He(),U("changed",_)}var N=Be("mouseUp",{event:e,mouse_x:i,mouse_y:r},!0);if(Un.each(N,function(e,t){t&&(c=t.keep||c,u=t.element,Ce=t.started||Ce)}),c||null==u){if(null!=u){s.addedNew=!0;var I=.2,M=void 0;if(oe.beginElement&&parseFloat(u.getAttribute("opacity"))!==y.opacity){M=Un(oe).clone().attr({to:y.opacity,dur:I}).appendTo(u);try{M[0].beginElement()}catch(e){}}else I=0;setTimeout(function(){M&&M.remove(),u.setAttribute("opacity",y.opacity),u.setAttribute("style","pointer-events:inherit"),Yt(u),"path"===Ee?P.toEditMode(u):a.selectNew&&We([u],!0),G(new Hn(u)),U("changed",[u])},1e3*I)}}else{for(p().releaseId(F()),u.parentNode.removeChild(u),u=null,v=e.target;v&&v.parentNode&&v.parentNode.parentNode&&"g"===v.parentNode.parentNode.tagName;)v=v.parentNode;"path"===Ee&&bt||!v||!v.parentNode||"selectorParentGroup"===v.parentNode.id||"svgcanvas"===v.id||"svgroot"===v.id||(s.setMode("select"),We([v],!0))}Ae=null}}}),Un(i).bind("mousewheel DOMMouseScroll",function(e){if(e.shiftKey){e.preventDefault();var t=e.originalEvent;Xe=Un("#svgcontent g")[0].getScreenCTM().inverse();var n=Un("#workarea"),i=a.showRulers?16:0,r=pe(t.pageX,t.pageY,Xe),o=n.width(),l=n.height(),u=o-15-i,c=l-15-i,h=u*Xe.a,d=c*Xe.d,f=n.offset(),p=f.left+i,v=f.top+i,m=t.wheelDelta?t.wheelDelta:t.detail?-t.detail:0;if(m){var y=Math.max(.75,Math.min(4/3,m)),_=void 0,b=void 0;y>1?(_=Math.ceil(u/h*y*100)/100,b=Math.ceil(c/d*y*100)/100):(_=Math.floor(u/h*y*100)/100,b=Math.floor(c/d*y*100)/100);var x=Math.min(_,b);if((x=Math.min(10,Math.max(.01,x)))!==g){y=x/g;var w=pe(p,v,Xe),S={x:(r.x-(r.x-w.x)/y)*x-i+o/2,y:(r.y-(r.y-w.y)/y)*x-i+l/2};s.setZoom(x),Un("#zoom").val((100*x).toFixed(1)),U("updateCanvas",{center:!1,newCtr:S}),U("zoomDone")}}}});var xt=s.textActions=function(){var e=void 0,t=void 0,n=void 0,i=void 0,r=void 0,a=[],o=void 0,u=void 0,c=void 0,d=void 0,f=void 0;function p(e){var s=""===t.value;if(Un(t).focus(),!arguments.length)if(s)e=0;else{if(t.selectionEnd!==t.selectionStart)return;e=t.selectionEnd}var u=a[e];s||t.setSelectionRange(e,e),(n=qt("text_cursor"))||(n=document.createElementNS(l.SVG,"line"),Xt(n,{id:"text_cursor",stroke:"#333","stroke-width":1}),n=qt("selectorParentGroup").appendChild(n)),r||(r=setInterval(function(){var e="none"===n.getAttribute("display");n.setAttribute("display",e?"inline":"none")},600));var c=w(u.x,o.y),h=w(u.x,o.y+o.height);Xt(n,{x1:c.x,y1:c.y,x2:h.x,y2:h.y,visibility:"visible",display:"inline"}),i&&i.setAttribute("d","")}function v(e,r,s){if(e!==r){s||t.setSelectionRange(e,r),(i=qt("text_selectblock"))||(i=document.createElementNS(l.SVG,"path"),Xt(i,{id:"text_selectblock",fill:"green",opacity:.5,style:"pointer-events:none"}),qt("selectorParentGroup").appendChild(i));var u=a[e],c=a[r];n.setAttribute("visibility","hidden");var h=w(u.x,o.y),d=w(u.x+(c.x-u.x),o.y),f=w(u.x,o.y+o.height),g=w(u.x+(c.x-u.x),o.y+o.height),v="M"+h.x+","+h.y+" L"+d.x+","+d.y+" "+g.x+","+g.y+" "+f.x+","+f.y+"z";Xt(i,{d:v,display:"inline"})}else p(r)}function m(t,n){var i=h.createSVGPoint();if(i.x=t,i.y=n,1===a.length)return 0;var r=e.getCharNumAtPosition(i);r<0?(r=a.length-2,t<=a[0].x&&(r=0)):r>=a.length-2&&(r=a.length-2);var o=a[r];return t>o.x+o.width/2&&r++,r}function y(e,t){p(m(e,t))}function b(e,n,i){var r=t.selectionStart,a=m(e,n);v(Math.min(r,a),Math.max(r,a),!i)}function x(e,t){var n={x:e,y:t};if(n.x/=g,n.y/=g,u){var i=pe(n.x,n.y,u.inverse());n.x=i.x,n.y=i.y}return n}function w(e,t){var n={x:e,y:t};if(u){var i=pe(n.x,n.y,u);n.x=i.x,n.y=i.y}return n.x*=g,n.y*=g,n}function S(t){v(0,e.textContent.length),Un(this).unbind(t)}function k(t){if(f&&e){var n=pe(t.pageX,t.pageY,Xe),i=x(n.x*g,n.y*g),r=m(i.x,i.y),a=e.textContent,o=a.substr(0,r).replace(/[a-z0-9]+$/i,"").length,s=a.substr(r).match(/^[a-z0-9]+/i);v(o,(s?s[0].length:0)+r),Un(t.target).click(S),setTimeout(function(){Un(t.target).unbind("click",S)},300)}}return{select:function(t,n,i){e=t,xt.toEditMode(n,i)},start:function(t){e=t,xt.toEditMode()},mouseDown:function(e,n,i,r){var a=x(i,r);t.focus(),y(a.x,a.y),c=i,d=r},mouseMove:function(e,t){var n=x(e,t);b(n.x,n.y)},mouseUp:function(t,n,i){var r=x(n,i);b(r.x,r.y,!0),t.target!==e&&nc-2&&id-2&&xt.toSelectMode(!0)},setCursor:p,toEditMode:function(t,n){if(f=!1,Ee="textedit",j.requestSelector(e).showGrips(!1),j.requestSelector(e),xt.init(),Un(e).css("cursor","text"),arguments.length){var i=x(t,n);y(i.x,i.y)}else p();setTimeout(function(){f=!0},300)},toSelectMode:function(a){Ee="select",clearInterval(r),r=null,i&&Un(i).attr("display","none"),n&&Un(n).attr("visibility","hidden"),Un(e).css("cursor","move"),a&&(z(),Un(e).css("cursor","move"),U("selected",[e]),H([e],!0)),e&&!e.textContent.length&&s.deleteSelectedElements(),Un(t).blur(),e=!1},setInputElem:function(e){t=e},clear:function(){"textedit"===Ee&&xt.toSelectMode()},init:function(n){if(e){var i=void 0,r=void 0;e.parentNode||(e=_[0],j.requestSelector(e).showGrips(!1));var l=e.textContent.length,c=e.getAttribute("transform");for(o=It(e),u=c?be(e):null,(a=[]).length=l,t.focus(),Un(e).unbind("dblclick",k).dblclick(k),l||(r={x:o.x+o.width/2,width:0}),i=0;i0&&void 0!==arguments[0]?arguments[0]:{}).codesOnly,t=void 0!==e&&e;z();var n=[],i={feGaussianBlur:$.exportNoBlur,foreignObject:$.exportNoforeignObject,"[stroke-dasharray]":$.exportNoDashArray},r=Un(d);return"font"in Un("")[0].getContext("2d")||(i.text=$.exportNoText),Un.each(i,function(e,i){r.find(e).length&&n.push(t?e:i)}),n}this.svgCanvasToString=function(){for(;St()>0;);P.clear(!0),Un.each(d.childNodes,function(e,t){e&&8===t.nodeType&&t.data.includes("Created with")&&d.insertBefore(t,d.firstChild)}),v&&(bn(),We([v]));var e=[];Un(d).find("g:data(gsvg)").each(function(){for(var t=this.attributes,n=t.length,i=0;i=0;u--){s=o.item(u);var v=mt(s.value);if(!g.includes(s.localName)&&""!==v){if(v.startsWith("pointer-events"))continue;if("class"===s.localName&&v.startsWith("se_"))continue;if(n.push(" "),"d"===s.localName&&(v=P.convertPath(e,!0)),isNaN(v)?r.test(v)&&(v=te(v)+i):v=te(v),ue.apply&&"image"===e.nodeName&&"href"===s.localName&&ue.images&&"embed"===ue.images){var m=le[v];m&&(v=m)}s.namespaceURI&&s.namespaceURI!==l.SVG&&!E[s.namespaceURI]||(n.push(s.nodeName),n.push('="'),n.push(v),n.push('"'))}}}if(e.hasChildNodes()){n.push(">"),t++;var y=!1;for(u=0;u");break;case 8:n.push("\n"),n.push(new Array(t+1).join(" ")),n.push("\x3c!--"),n.push(_.data),n.push("--\x3e")}}if(t--,!y)for(n.push("\n"),u=0;u")}else n.push("/>")}return n.join("")},this.embedImage=function(e,t){Un(new Image).load(function(){var n=document.createElement("canvas");n.width=this.width,n.height=this.height,n.getContext("2d").drawImage(this,0,0);try{var i=";svgedit_url="+encodeURIComponent(e);i=n.toDataURL().replace(";base64",i+";base64"),le[e]=i}catch(t){le[e]=!1}ke=e,t&&t(le[e])}).attr("src",e)},this.setGoodImage=function(e){ke=e},this.open=function(){},this.save=function(e){z(),e&&Un.extend(ue,e),ue.apply=!0;var t=this.svgCanvasToString();U("saved",t)},this.rasterExport=function(e,t,n,i){var r="image/"+e.toLowerCase(),a=Nt(),o=Nt({codesOnly:!0}),l=this.svgCanvasToString();return new Promise(function(u,c){Zt(function(){var c=e||"PNG";Un("#export_canvas").length||Un("",{id:"export_canvas"}).hide().appendTo("body");var h=Un("#export_canvas")[0];h.width=s.contentW,h.height=s.contentH,nn(h,l,{renderCallback:function(){var s=("ICO"===c?"BMP":c).toLowerCase(),d=t?h.toDataURL("image/"+s,t):h.toDataURL("image/"+s),f=void 0;function p(){var s={datauri:d,bloburl:f,svg:l,issues:a,issueCodes:o,type:e,mimeType:r,quality:t,exportWindowName:n};U("exported",s),i&&i(s),u(s)}h.toBlob?h.toBlob(function(e){f=wt(e),p()},r,t):(f=function(e){if("undefined"==typeof Uint8Array||"undefined"==typeof Blob||"undefined"==typeof URL||!URL.createObjectURL)return"";for(var t=e.split(","),n=t[0].match(/:(.*?);/)[1],i=atob(t[1]),r=i.length,a=new Uint8Array(r);r--;)a[r]=i.charCodeAt(r);var o=new Blob([a],{type:n});return URL.createObjectURL(o)}(d),p())}})})()})},this.exportPDF=function(e,t,n){var i=this;return new Promise(function(r,a){var o;(o=function(){var a=Ut(),o=a.w>a.h?"landscape":"portrait",s=jsPDF({orientation:o,unit:"pt",format:[a.w,a.h]}),l=Qt();s.setProperties({title:l});var u=Nt(),c=Nt({codesOnly:!0}),h=i.svgCanvasToString();s.addSVG(h,0,0);var d={svg:h,issues:u,issueCodes:c,exportWindowName:e},f=t||"dataurlstring";d[f]=s.output(f),n&&n(d),r(d),U("exportedPDF",d)},$t("RGBColor",["canvg/rgbcolor.js"],function(){var e=[];R&&void 0!==R.ok||e.push("canvg/rgbcolor.js"),$t("jsPDF",[].concat(e,["jspdf/underscore-min.js","jspdf/jspdf.min.js","jspdf/jspdf.plugin.svgToPdf.js"]),o,{globals:!0})()}))()})},this.getSvgString=function(){return ue.apply=!1,this.svgCanvasToString()},this.randomizeIds=function(e){arguments.length>0&&!1===e?vn(!1,p()):vn(!0,p())};var Mt=this.uniquifyElems=function(e){var t={},n=["filter","linearGradient","pattern","radialGradient","symbol","textPath","use"];for(var i in Ct(e,function(e){if(1===e.nodeType){e.id&&(e.id in t||(t[e.id]={elem:null,attrs:[],hrefs:[]}),t[e.id].elem=e),Un.each(re,function(n,i){var r=e.getAttributeNode(i);if(r){var a=Pt(r.value),o=a?a.substr(1):null;o&&(o in t||(t[o]={elem:null,attrs:[],hrefs:[]}),t[o].attrs.push(r))}});var i=At(e);if(i&&n.includes(e.nodeName)){var r=i.substr(1);r&&(r in t||(t[r]={elem:null,attrs:[],hrefs:[]}),t[r].hrefs.push(e))}}}),t)if(i){var r=t[i].elem;if(r){var a=D();r.id=a;for(var o=t[i].attrs,s=o.length;s--;){var l=o[s];l.ownerElement.setAttribute(l.name,"url(#"+a+")")}for(var u=t[i].hrefs,c=u.length;c--;){var h=u[c];Et(h,"#"+a)}}}},jt=this.setUseData=function(e){var t=Un(e);"use"!==e.tagName&&(t=t.find("use")),t.each(function(){var e=At(this).substr(1),t=qt(e);t&&(Un(this).data("ref",t),"symbol"!==t.tagName&&"svg"!==t.tagName||Un(this).data("symbol",t).data("ref",t))})},Bt=this.convertGradients=function(e){var t=Un(e).find("linearGradient, radialGradient");!t.length&&N()&&(t=Un(e).find("*").filter(function(){return this.tagName.includes("Gradient")})),t.each(function(){if("userSpaceOnUse"===Un(this).attr("gradientUnits")){var e=Un(d).find('[fill="url(#'+this.id+')"],[stroke="url(#'+this.id+')"]');if(!e.length)return;var t=It(e[0]);if(!t)return;if("linearGradient"===this.tagName){var n=Un(this).attr(["x1","y1","x2","y2"]),i=this.gradientTransform.baseVal;if(i&&i.numberOfItems>0){var r=_e(i).matrix,a=pe(n.x1,n.y1,r),o=pe(n.x2,n.y2,r);n.x1=a.x,n.y1=a.y,n.x2=o.x,n.y2=o.y,this.removeAttribute("gradientTransform")}Un(this).attr({x1:(n.x1-t.x)/t.width,y1:(n.y1-t.y)/t.height,x2:(n.x2-t.x)/t.width,y2:(n.y2-t.y)/t.height}),this.removeAttribute("gradientUnits")}}})},Rt=this.convertToGroup=function(e){e||(e=_[0]);var t=Un(e),n=new Yn,i=void 0;if(t.data("gsvg")){var r=e.firstChild,a=Un(r).attr(["x","y"]);Un(e.firstChild.firstChild).unwrap(),Un(e).removeData("gsvg");var o=W(e),s=h.createSVGTransform();s.setTranslate(a.x,a.y),o.appendItem(s),Ln(e),U("selected",[e])}else if(t.data("symbol")){e=t.data("symbol"),i=t.attr("transform");var u=t.attr(["x","y"]),f=e.getAttribute("viewBox");if(f){var p=f.split(" ");u.x-=+p[0],u.y-=+p[1]}i+=" translate("+(u.x||0)+","+(u.y||0)+")";var g=t.prev();n.addSubCommand(new qn(t[0],t[0].nextSibling,t[0].parentNode)),t.remove();var v=Un(d).find("use:data(symbol)").length,m=c.createElementNS(l.SVG,"g"),y=e.childNodes,b=void 0;for(b=0;bf?"scale("+_/3/y[3]+")":"scale("+_/3/y[2]+")")+" translate(0)",s=c.createElementNS(l.SVG,"symbol");var b=Tt();for(I()&&Un(h).find("linearGradient, radialGradient, pattern").appendTo(b);h.firstChild;){var x=h.firstChild;s.appendChild(x)}for(var w=h.attributes,S=0;S0&&(n?tn(e,t,i):(rn(e,t,i),U("changed",i)))};var Jt=this.setGradient=function(e){if(Me[e+"_paint"]&&"solidColor"!==Me[e+"_paint"].type){var t=s[e+"Grad"],n=en(t),i=Tt();n?t=n:(t=i.appendChild(c.importNode(t,!0))).id=D(),s.setColor(e,"url(#"+t.id+")")}},en=function(e){for(var t=Tt(),n=Un(t).find("linearGradient, radialGradient"),i=n.length,r=["r","cx","cy","fx","fy"];i--;){var a=n[i];if("linearGradient"===e.tagName){if(e.getAttribute("x1")!==a.getAttribute("x1")||e.getAttribute("y1")!==a.getAttribute("y1")||e.getAttribute("x2")!==a.getAttribute("x2")||e.getAttribute("y2")!==a.getAttribute("y2"))continue}else if("continue"===function(){var t=Un(e).attr(r),n=Un(a).attr(r),i=!1;if(Un.each(r,function(e,r){t[r]!==n[r]&&(i=!0)}),i)return"continue"}())continue;var o=e.getElementsByTagNameNS(l.SVG,"stop"),s=a.getElementsByTagNameNS(l.SVG,"stop");if(o.length===s.length){for(var u=o.length;u--;){var c=o[u],h=s[u];if(c.getAttribute("offset")!==h.getAttribute("offset")||c.getAttribute("stop-opacity")!==h.getAttribute("stop-opacity")||c.getAttribute("stop-color")!==h.getAttribute("stop-color"))break}if(-1===u)return a}}return null};this.setPaint=function(e,t){var n=new Un.jGraduate.Paint(t);switch(this.setPaintOpacity(e,n.alpha/100,!0),Me[e+"_paint"]=n,n.type){case"solidColor":this.setColor(e,"none"!==n.solidColor?"#"+n.solidColor:"none");break;case"linearGradient":case"radialGradient":s[e+"Grad"]=n[n.type],Jt(e)}},this.setStrokePaint=function(e){this.setPaint("stroke",e)},this.setFillPaint=function(e){this.setPaint("fill",e)},this.getStrokeWidth=function(){return Me.stroke_width},this.setStrokeWidth=function(e){if(0===e&&["line","path"].includes(Ee))s.setStrokeWidth(1);else{Me.stroke_width=e;for(var t=[],n=_.length;n--;){var i=_[n];i&&("g"===i.tagName?Ct(i,r):t.push(i))}t.length>0&&(rn("stroke-width",e,t),U("changed",_))}function r(e){"g"!==e.nodeName&&t.push(e)}},this.setStrokeAttr=function(e,t){y[e.replace("-","_")]=t;for(var n=[],i=_.length;i--;){var r=_[i];r&&("g"===r.tagName?Ct(r,function(e){"g"!==e.nodeName&&n.push(e)}):n.push(r))}n.length>0&&(rn(e,t,n),U("changed",_))},this.getStyle=function(){return y},this.getOpacity=Y,this.setOpacity=function(e){y.opacity=e,rn("opacity",e)},this.getFillOpacity=function(){return y.fill_opacity},this.getStrokeOpacity=function(){return y.stroke_opacity},this.setPaintOpacity=function(e,t,n){y[e+"_opacity"]=t,n?tn(e+"-opacity",t):rn(e+"-opacity",t)},this.getPaintOpacity=function(e){return"fill"===e?this.getFillOpacity():this.getStrokeOpacity()},this.getBlur=function(e){var t=0;if(e&&e.getAttribute("filter")){var n=qt(e.id+"_blur");n&&(t=n.firstChild.getAttribute("stdDeviation"))}return t},function(){var e=null,t=null,n=!1;function i(){var n=s.undoMgr.finishUndoableChange();e.addSubCommand(n),G(e),e=null,t=null}s.setBlurNoUndo=function(e){if(t)if(0===e)tn("filter",""),n=!0;else{var i=_[0];n&&tn("filter","url(#"+i.id+"_blur)"),N()&&(console.log("e",i),i.removeAttribute("filter"),i.setAttribute("filter","url(#"+i.id+"_blur)")),tn("stdDeviation",e,[t.firstChild]),s.setBlurOffsets(t,e)}else s.setBlur(e)},s.setBlurOffsets=function(e,t){t>3?Xt(e,{x:"-50%",y:"-50%",width:"200%",height:"200%"},100):N()||(e.removeAttribute("x"),e.removeAttribute("y"),e.removeAttribute("width"),e.removeAttribute("height"))},s.setBlur=function(n,r){if(e)i();else{var a=_[0],o=a.id;t=qt(o+"_blur"),n-=0;var l=new Yn;if(t)0===n&&(t=null);else{var u=x({element:"feGaussianBlur",attr:{in:"SourceGraphic",stdDeviation:n}});(t=x({element:"filter",attr:{id:o+"_blur"}})).appendChild(u),Tt().appendChild(t),l.addSubCommand(new Hn(t))}var c={filter:a.getAttribute("filter")};if(0===n)return a.removeAttribute("filter"),void l.addSubCommand(new Xn(a,c));rn("filter","url(#"+o+"_blur)"),l.addSubCommand(new Xn(a,c)),s.setBlurOffsets(t,n),e=l,s.undoMgr.beginUndoableChange("stdDeviation",[t?t.firstChild:null]),r&&(s.setBlurNoUndo(n),i())}}}(),this.getBold=function(){var e=_[0];return null!=e&&"text"===e.tagName&&null==_[1]&&"bold"===e.getAttribute("font-weight")},this.setBold=function(e){var t=_[0];null!=t&&"text"===t.tagName&&null==_[1]&&rn("font-weight",e?"bold":"normal"),_[0].textContent||xt.setCursor()},this.getItalic=function(){var e=_[0];return null!=e&&"text"===e.tagName&&null==_[1]&&"italic"===e.getAttribute("font-style")},this.setItalic=function(e){var t=_[0];null!=t&&"text"===t.tagName&&null==_[1]&&rn("font-style",e?"italic":"normal"),_[0].textContent||xt.setCursor()},this.getFontFamily=function(){return he.font_family},this.setFontFamily=function(e){he.font_family=e,rn("font-family",e),_[0]&&!_[0].textContent&&xt.setCursor()},this.setFontColor=function(e){he.fill=e,rn("fill",e)},this.getFontColor=function(){return he.fill},this.getFontSize=function(){return he.font_size},this.setFontSize=function(e){he.font_size=e,rn("font-size",e),_[0].textContent||xt.setCursor()},this.getText=function(){var e=_[0];return null==e?"":e.textContent},this.setTextContent=function(e){rn("#text",e),xt.init(e),xt.setCursor()},this.setImageURL=function(e){var t=_[0];if(t){var n=Un(t).attr(["width","height"]),i=!n.width||!n.height,r=At(t);if(r!==e)i=!0;else if(!i)return;var a=new Yn("Change Image URL");Et(t,e),a.addSubCommand(new Xn(t,{"#href":r})),i?Un(new Image).load(function(){var e=Un(t).attr(["width","height"]);Un(t).attr({width:this.width,height:this.height}),j.requestSelector(t).resize(),a.addSubCommand(new Xn(t,e)),G(a),U("changed",[t])}).attr("src",e):G(a)}},this.setLinkURL=function(e){var t=_[0];if(t){if("a"!==t.tagName){var n=Un(t).parents("a");if(!n.length)return;t=n[0]}var i=At(t);if(i!==e){var r=new Yn("Change Link URL");Et(t,e),r.addSubCommand(new Xn(t,{"#href":i})),G(r)}}},this.setRectRadius=function(e){var t=_[0];if(null!=t&&"rect"===t.tagName){var n=t.getAttribute("rx");n!==String(e)&&(t.setAttribute("rx",e),t.setAttribute("ry",e),G(new Xn(t,{rx:n,ry:n},"Radius")),U("changed",[t]))}},this.makeHyperlink=function(e){s.groupSelectedElements("a",e)},this.removeHyperlink=function(){s.ungroupSelectedElement()},this.setSegType=function(e){P.setSegType(e)},this.convertToPath=function(e,t){if(null!=e){return t?Vt(e,x,P):function(e,t,n,i,r,a,o,s){var l=new o.BatchCommand("Convert element to Path"),u=n({element:"path",attr:t=ct.extend({},t,Ot(e))}),c=e.getAttribute("transform");c&&u.setAttribute("transform",c);var h=e.id,d=e.parentNode;e.nextSibling?d.insertBefore(u,e):d.appendChild(u);var f=Lt(e);if(f){if(u.setAttribute("d",f),c){var p=W(u);me(p)&&i.resetOrientation(u)}var g=e.nextSibling;return l.addSubCommand(new o.RemoveElementCommand(e,g,d)),l.addSubCommand(new o.InsertElementCommand(u)),r(),e.parentNode.removeChild(e),u.setAttribute("id",h),u.removeAttribute("visibility"),a([u],!0),s(l),u}return u.parentNode.removeChild(u),null}(e,{fill:y.fill,"fill-opacity":y.fill_opacity,stroke:y.stroke,"stroke-width":y.stroke_width,"stroke-dasharray":y.stroke_dasharray,"stroke-linejoin":y.stroke_linejoin,"stroke-linecap":y.stroke_linecap,"stroke-opacity":y.stroke_opacity,opacity:y.opacity,visibility:"hidden"},x,P,z,H,de,G)}else{var n=_;Un.each(n,function(e,t){t&&s.convertToPath(t)})}};var tn=function(e,t,n){"pathedit"===Ee&&P.moveNode(e,t);for(var i=(n=n||_).length,r=["g","polyline","path"],a=["transform","opacity","filter"],o=function(){var o=n[i];if(null==o)return"continue";if(("x"===e||"y"===e)&&r.includes(o.tagName)){var l=Ft([o]),u="x"===e?t-l.x:0,c="y"===e?t-l.y:0;return s.moveSelectedElements(u*g,c*g,!0),"continue"}"g"===o.tagName&&a.includes(e);var d="#text"===e?o.textContent:o.getAttribute(e);if(null==d&&(d=""),d!==String(t)){"#text"===e?(o.textContent=t,/rotate/.test(o.getAttribute("transform"))&&(o=ze(o))):"#href"===e?Et(o,t):o.setAttribute(e,t),"textedit"===Ee&&"#text"!==e&&o.textContent.length&&xt.toSelectMode(o),I()&&"text"===o.nodeName&&/rotate/.test(o.getAttribute("transform"))&&(String(t).startsWith("url")||["font-size","font-family","x","y"].includes(e)&&o.textContent)&&(o=ze(o)),_.includes(o)&&setTimeout(function(){o.parentNode&&j.requestSelector(o).resize()},0);var f=zt(o);if(0!==f&&"transform"!==e)for(var p=W(o),v=p.numberOfItems;v--;){if(4===p.getItem(v).type){p.removeItem(v);var m=It(o),y=pe(m.x+m.width/2,m.y+m.height/2,_e(p).matrix),b=y.x,x=y.y,w=h.createSVGTransform();w.setRotate(f,b,x),p.insertItemBefore(w,v);break}}}};i--;)o()},rn=this.changeSelectedAttribute=function(e,t,n){n=n||_,s.undoMgr.beginUndoableChange(e,n),tn(e,t,n);var i=s.undoMgr.finishUndoableChange();i.isEmpty()||G(i)};this.deleteSelectedElements=function(){for(var e=new Yn("Delete Elements"),t=_.length,n=[],i=0;i1&&(i=t);break;default:e="g",n="Group Elements"}var r=new Yn(n),a=x({element:e,attr:{id:D()}});"a"===e&&Et(a,i),r.addSubCommand(new Hn(a));for(var o=_.length;o--;){var s=_[o];if(null!=s){"a"===s.parentNode.tagName&&1===s.parentNode.childNodes.length&&(s=s.parentNode);var l=s.nextSibling,u=s.parentNode;a.appendChild(s),r.addSubCommand(new zn(s,l,u))}}r.isEmpty()||G(r),We([a],!0)};var an=this.pushGroupProperties=function(e,t){for(var n=e.childNodes,i=n.length,r=e.getAttribute("transform"),a=W(e),o=_e(a).matrix,l=new Yn("Push group properties"),u=zt(e),c=Un(e).attr(["filter","opacity"]),d=void 0,f=void 0,g=void 0,v=p(),m=0;mn[h].width)||("t"===e||"m"===e||"b"===e)&&(c===Number.MIN_VALUE||c>n[h].height))&&(r=n[h].x,o=n[h].y,a=n[h].x+n[h].width,l=n[h].y+n[h].height,u=n[h].width,c=n[h].height);break;case"largest":(("l"===e||"c"===e||"r"===e)&&(u===Number.MIN_VALUE||ua&&(a=n[h].x+n[h].width),n[h].y+n[h].height>l&&(l=n[h].y+n[h].height)}}"page"===t&&(r=0,o=0,a=s.contentW,l=s.contentH);for(var f=new Array(i),p=new Array(i),g=0;g=r.length?t=0:t<0&&(t=r.length-1),i=r[t];break}We([i],!0),U("selected",_)}},this.clear(),this.getPrivateMethods=function(){return{addCommandToHistory:G,setGradient:Jt,addSvgElementFromJson:x,assignAttributes:Xt,BatchCommand:Yn,buildCanvgCallback:Zt,call:U,canvg:nn,ChangeElementCommand:Xn,copyElem:function(e){return p().copyElem(e)},decode64:_t,encode64:yt,executeAfterLoads:$t,ffClone:ze,findDefs:Tt,findDuplicateGradient:en,getElem:qt,getId:F,getIntersectionList:Re,getMouseTarget:Q,getNextId:D,getPathBBox:Gt,getTypeMap:ee,getUrlFromAttr:Pt,hasMatrixTransform:me,identifyLayers:_n,InsertElementCommand:Hn,isChrome:L,isIdentity:ge,isIE:M,logMatrix:qe,matrixMultiply:ve,MoveElementCommand:zn,NS:l,preventClickDefault:Kt,recalculateAllSelectedDimensions:He,recalculateDimensions:Ln,remapElement:Gn,RemoveElementCommand:qn,removeUnusedDefElems:St,round:V,runExtensions:Be,sanitizeSvg:Pn,SVGEditTransformList:X,text2xml:kt,toString:toString,transformBox:ye,transformListToTransform:_e,transformPoint:pe,walkTree:Ct}}};var Zn={svg:"http://www.w3.org/2000/svg",xlink:"http://www.w3.org/1999/xlink"};window.console||(window.console={log:function(e){},dir:function(e){}}),Math.precision=function(e,t){return void 0===t&&(t=0),Math.round(e*Math.pow(10,t))/Math.pow(10,t)};var Kn=jQuery,Jn=void 0;function ei(e,t,n){var i=Kn("#svg_editor").parent();for(var r in t){var a=t[r];if(a||console.log(r),n&&(r="#"+r),i.find(r).length){var o=i.find(r)[0];switch(e){case"content":for(var s,l=0;s=o.childNodes[l];l++)if(3===s.nodeType&&s.textContent.trim()){s.textContent=a;break}break;case"title":o.title=a}}else console.log("Missing: "+r)}}var ti=void 0;var ni=[function(e){function t(t){if("string"==typeof t.data){var n=t.handler,i=t.data.toLowerCase().split(" ");t.handler=function(t){if(this===t.target||!/textarea|select/i.test(t.target.nodeName)&&"text"!==t.target.type){var r="keypress"!==t.type&&e.hotkeys.specialKeys[t.which],a=String.fromCharCode(t.which).toLowerCase(),o="",s={};t.altKey&&"alt"!==r&&(o+="alt+"),t.ctrlKey&&"ctrl"!==r&&(o+="ctrl+"),t.metaKey&&!t.ctrlKey&&"meta"!==r&&(o+="meta+"),t.shiftKey&&"shift"!==r&&(o+="shift+"),r?s[o+r]=!0:(s[o+a]=!0,s[o+e.hotkeys.shiftNums[a]]=!0,"shift+"===o&&(s[e.hotkeys.shiftNums[a]]=!0));for(var l=0,u=i.length;l","/":"?","\\":"|"}},e.each(["keydown","keyup","keypress"],function(){e.event.special[this]={add:t}}),e},function(e){return function(e,n){var i,r,a,o,s,l,u,c,h=Array.prototype.slice,d=decodeURIComponent,f=e.param,p=e.bbq=e.bbq||{},g=e.event.special,v="hashchange",m="querystring",y="fragment",_="elemUrlAttr",b="location",x="href",w="src",S=/^.*\?|#.*$/g,k=/^.*\#/,C={};function P(e){return"string"==typeof e}function A(e){var t=h.call(arguments,1);return function(){return e.apply(this,t.concat(h.call(arguments)))}}function E(t,r,o,s,l){var u,h,p,g,v;return s!==i?(v=(p=o.match(t?/^([^#]*)\#?(.*)$/:/^([^#?]*)\??([^#]*)(#?.*)/))[3]||"",2===l&&P(s)?h=s.replace(t?k:S,""):(g=a(p[2]),s=P(s)?a[t?y:m](s):s,h=2===l?s:1===l?e.extend({},s,g):e.extend({},g,s),h=f(h),t&&(h=h.replace(c,d))),u=p[1]+(t?"#":h||!p[1]?"?":"")+h+v):u=r(o!==i?o:n[b][x]),u}function T(e,t,n){return t===i||"boolean"==typeof t?(n=t,t=f[e?y:m]()):t=P(t)?t.replace(e?k:S,""):t,a(t,n)}function G(n,r,a,o){return P(a)||"object"===(void 0===a?"undefined":t(a))||(o=a,a=r,r=i),this.each(function(){var t=e(this),i=r||u()[(this.nodeName||"").toLowerCase()]||"",s=i&&t.attr(i)||"";t.attr(i,f[n](s,a,o))})}f[m]=A(E,0,function(e){return e.replace(/(?:^[^?#]*\?([^#]*).*$)?.*/,"$1")}),f[y]=r=A(E,1,function(e){return e.replace(/^[^#]*#?(.*)$/,"$1")}),r.noEscape=function(t){t=t||"";var n=e.map(t.split(""),encodeURIComponent);c=new RegExp(n.join("|"),"g")},r.noEscape(",/"),e.deparam=a=function(t,n){var r={},a={true:!0,false:!1,null:null};return e.each(t.replace(/\+/g," ").split("&"),function(t,o){var s,l=o.split("="),u=d(l[0]),c=r,h=0,f=u.split("]["),p=f.length-1;if(/\[/.test(f[0])&&/\]$/.test(f[p])?(f[p]=f[p].replace(/\]$/,""),p=(f=f.shift().split("[").concat(f)).length-1):p=0,2===l.length)if(s=d(l[1]),n&&(s=s&&!isNaN(s)?+s:"undefined"===s?i:a[s]!==i?a[s]:s),p)for(;h<=p;h++)c=c[u=""===f[h]?c.length:f[h]]=h').hide().insertAfter("body")[0].contentWindow,s=function(){return m(a.document[c][d])},(o=function(e,t){if(e!==t){var n=a.document;n.open().close(),n[c].hash="#"+e}})(m()))),function i(){var a=m(),l=s(n);a!==n?(o(n=a,l),e(t).trigger(h)):l!==n&&(t[c][d]=t[c][d].replace(/#.*/,"")+"#"+l),r=setTimeout(i,e[h+"Delay"])}()}},l.stop=function(){a||(r&&clearTimeout(r),r=0)},i=l}(e,window),e},function(e){var t={},n=void 0;return e.svgIcons=function(i,r){var a="http://www.w3.org/2000/svg",o="http://www.w3.org/1999/xlink",s=r.w||24,l=r.h||24,u=void 0,c=void 0,h=void 0,d=!1,f=!1,p=0,g=!!window.opera,v="data:image/svg+xml;charset=utf-8;base64,",m=void 0;if(r.svgz){m=e('').appendTo("body").hide();try{c=m[0].contentDocument,m.load(_),_(0,!0)}catch(e){k()}}else{var y=new DOMParser;e.ajax({url:i,dataType:"string",success:function(t){t?(c=y.parseFromString(t,"text/xml"),e(function(){_("ajax")})):e(k)},error:function(t){window.opera?e(function(){k()}):t.responseText?((c=y.parseFromString(t.responseText,"text/xml")).childNodes.length||e(k),e(function(){_("ajax")})):e(k)}})}function _(t,n){if("ajax"!==t){if(f)return;var i=(c=m[0].contentDocument)&&c.getElementById("svg_eof");if(!(i||n&&i))return void(++p<50?setTimeout(_,20):(k(),f=!0));f=!0}if(u=e(c.firstChild).children(),r.no_img)setTimeout(function(){d||S()},500);else{var a=v+"PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNzUiIGhlaWdodD0iMjc1Ij48L3N2Zz4%3D";h=e(new Image).attr({src:a,width:0,height:0}).appendTo("body").load(function(){S(!0)}).error(function(){S()})}}var b=function(e,t,n,i){if(g&&t.css("visibility","hidden"),r.replace){i&&t.attr("id",n);var a=e.attr("class");a&&t.attr("class","svg_icon "+a),e.replaceWith(t)}else e.append(t);g&&setTimeout(function(){t.removeAttr("style")},1)},x=void 0,w=function(e,n){void 0!==r.id_match&&!1===r.id_match||b(x,e,n,!0),t[n]=e};function S(i,c){if(!d){r.no_img&&(i=!1);var f=void 0;if(i&&(f=e(document.createElement("div"))).hide().appendTo("body"),c){var p=r.fallback_path||"";e.each(c,function(t,n){x=e("#"+t);var i=e(new Image).attr({class:"svg_icon",src:p+n,width:s,height:l,alt:"icon"});w(i,t)})}else for(var y=u.length,_=0;_0&&!i&&(o=n(o,r,!0)),b(e(this),o,a)})}),c||(i&&f.remove(),m&&m.remove(),h&&h.remove()),r.resize&&e.resizeSvgIcons(r.resize),d=!0,r.callback&&r.callback(t)}}function k(){if(i.includes(".svgz")){var t=i.replace(".svgz",".svg");window.console&&console.log(".svgz failed, trying with .svg"),e.svgIcons(t,r)}else r.fallback&&S(!1,r.fallback)}function C(e){if(window.btoa)return window.btoa(e);var t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",n=new Array(4*Math.floor((e.length+2)/3)),i=0,r=0;do{var a=e.charCodeAt(i++),o=e.charCodeAt(i++),s=e.charCodeAt(i++),l=a>>2,u=(3&a)<<4|o>>4,c=(15&o)<<2|s>>6,h=63&s;isNaN(o)?c=h=64:isNaN(s)&&(h=64),n[r++]=t.charAt(l),n[r++]=t.charAt(u),n[r++]=t.charAt(c),n[r++]=t.charAt(h)}while(i
  • Solid Color
  • Linear Gradient
  • Radial Gradient
  • ');var f=e(l+"> .jGraduate_colPick"),p=e(l+"> .jGraduate_gradPick");p.html('

    '+o.window.pickerTitle+'


    ');var g=256,v=g-0,m=g-0,y={};e(".jGraduate_SliderBar").width(145);var _=e("#"+s+"_jGraduate_GradContainer")[0],b=i("svg",{id:s+"_jgraduate_svg",width:g,height:g,xmlns:Zn.svg},_),x=a.paint.type,w=a.paint[x],S=w,k=a.paint.alpha,C="solidColor"===x;switch(x){case"solidColor":case"linearGradient":if(C||(S.id=s+"_lg_jgraduate_grad",w=S=b.appendChild(S)),i("radialGradient",{id:s+"_rg_jgraduate_grad"},b),"linearGradient"===x)break;case"radialGradient":C||(S.id=s+"_rg_jgraduate_grad",w=S=b.appendChild(S)),i("linearGradient",{id:s+"_lg_jgraduate_grad"},b)}var P=void 0;if(C){w=S=e("#"+s+"_lg_jgraduate_grad")[0],Ie(0,"#"+(h=a.paint[x]),1);var A=t(o.newstop);if("string"===A)switch(o.newstop){case"same":Ie(1,"#"+h,1);break;case"inverse":for(var E="",T=0;T<6;T+=2){var G=(255-parseInt(h.substr(T,2),16)).toString(16);G.length<2&&(G=0+G),E+=G}Ie(1,"#"+E,1);break;case"white":Ie(1,"#ffffff",1);break;case"black":Ie(1,"#000000",1)}else if("object"===A){var N="opac"in o.newstop?o.newstop.opac:1;Ie(1,o.newstop.color||"#"+h,N)}}var I=parseFloat(w.getAttribute("x1")||0),M=parseFloat(w.getAttribute("y1")||0),L=parseFloat(w.getAttribute("x2")||1),O=parseFloat(w.getAttribute("y2")||0),V=parseFloat(w.getAttribute("cx")||.5),j=parseFloat(w.getAttribute("cy")||.5),B=parseFloat(w.getAttribute("fx")||V),R=parseFloat(w.getAttribute("fy")||j),D=i("rect",{id:s+"_jgraduate_rect",x:0,y:0,width:v,height:m,fill:"url(#"+s+"_jgraduate_grad)","fill-opacity":k/100},b),F=e("
    ").attr({class:"grad_coord jGraduate_lg_field",title:"Begin Stop"}).text(1).css({top:M*g,left:I*g}).data("coord","start").appendTo(_),U=F.clone().text(2).css({top:O*g,left:L*g}).attr("title","End stop").data("coord","end").appendTo(_),z=e("
    ").attr({class:"grad_coord jGraduate_rg_field",title:"Center stop"}).text("C").css({top:j*g,left:V*g}).data("coord","center").appendTo(_),H=z.clone().text("F").css({top:R*g,left:B*g,display:"none"}).attr("title","Focus point").data("coord","focus").appendTo(_);H[0].id=s+"_jGraduate_focusCoord";var q=void 0;e.each(["x1","y1","x2","y2","cx","cy","fx","fy"],function(t,n){var i=isNaN(n[1]),r=S.getAttribute(n);r||(r=i?"0.5":"x2"===n?"1.0":"0.0"),y[n]=e("#"+s+"_jGraduate_"+n).val(r).change(function(){isNaN(parseFloat(this.value))||this.value<0?this.value=0:this.value>1&&(this.value=1),("f"!==n[0]||q)&&(i&&"radialGradient"===x||!i&&"linearGradient"===x)&&S.setAttribute(n,this.value);var e=i?"c"===n[0]?z:H:"1"===n[1]?F:U,t=n.includes("x")?"left":"top";e.css(t,this.value*g)}).change()});var X=e("#"+s+"_jGraduate_StopSlider"),Y=void 0,W=void 0,Q=void 0,$=i("path",{d:"m9.75,-6l-19.5,19.5m0,-19.5l19.5,19.5",fill:"none",stroke:"#D00","stroke-width":5,display:"none"},void 0),Z=void 0,K=1,J=1,ee=0,te=V,ne=j,ie=i("svg",{width:"100%",height:45},X[0]),re=i("image",{width:16,height:16},i("pattern",{width:16,height:16,patternUnits:"userSpaceOnUse",id:"jGraduate_trans"},ie)),ae=o.images.clientPath+"map-opacity.png";re.setAttributeNS(Zn.xlink,"xlink:href",ae),e(ie).click(function(e){if(Z=X.offset(),"path"!==e.target.tagName){var t=e.pageX-Z.left-8;Ie((t=t<10?10:t>g+10?g+10:t)/g,0,0,!0),e.stopPropagation()}}),e(ie).mouseover(function(){ie.appendChild($)}),P=i("g",{},ie),i("line",{x1:10,y1:15,x2:g+10,y2:15,"stroke-width":2,stroke:"#000"},ie);var oe=p.find(".jGraduate_spreadMethod").change(function(){S.setAttribute("spreadMethod",e(this).val())}),se=null,le=function(e){var t=e.pageX-de.left,n=e.pageY-de.top;t=t<0?0:t>g?g:t,n=n<0?0:n>g?g:n,se.css("left",t).css("top",n);var i=t/v,r=n/m,a=se.data("coord"),o=S;switch(a){case"start":y.x1.val(i),y.y1.val(r),o.setAttribute("x1",i),o.setAttribute("y1",r);break;case"end":y.x2.val(i),y.y2.val(r),o.setAttribute("x2",i),o.setAttribute("y2",r);break;case"center":y.cx.val(i),y.cy.val(r),o.setAttribute("cx",i),o.setAttribute("cy",r),te=i,ne=r,Oe();break;case"focus":y.fx.val(i),y.fy.val(r),o.setAttribute("fx",i),o.setAttribute("fy",r),Oe()}e.preventDefault()},ue=function e(){se=null,d.unbind("mousemove",le).unbind("mouseup",e)},ce=(Y=S.getElementsByTagNameNS(Zn.svg,"stop")).length;if(ce<2){for(;ce<2;)S.appendChild(document.createElementNS(Zn.svg,"stop")),++ce;Y=S.getElementsByTagNameNS(Zn.svg,"stop")}for(var he=0;he99.5&&(n=99.5),n>0?J=1-n/100:K=-n/100-1,r=(n+100)/2*145/100,e&&Oe();break;case"angle":r=(ee=n)/180,r+=.5,r*=145,e&&Oe()}r>145?r=145:r<0&&(r=0),i.css({"margin-left":r-5})}).change()});for(var Ae=function(e){!function(e){var t=ge.offset,n=ge.parent,i=e.pageX-t.left-parseInt(n.css("border-left-width"));i>145&&(i=145),i<=0&&(i=0);var r=i-5;switch(i/=145,ge.type){case"radius":(i=Math.pow(2*i,2.5))>.98&&i<1.02&&(i=1),i<=.01&&(i=.01),S.setAttribute("r",i);break;case"opacity":a.paint.alpha=parseInt(100*i),D.setAttribute("fill-opacity",i);break;case"ellip":K=1,J=1,i<.5?K=(i/=.5)<=0?.01:i:i>.5&&(J=(i=2-(i/=.5))<=0?.01:i),Oe(),J===1+(i-=1)&&(i=Math.abs(i));break;case"angle":i-=.5,ee=i*=180,Oe(),i/=100}ge.elem.css({"margin-left":r}),i=Math.round(100*i),ge.input.val(i)}(e),e.preventDefault()},Ee=function e(t){d.unbind("mousemove",Ae).unbind("mouseup",e),ge=null},Te=(255*a.paint.alpha/100).toString(16);Te.length<2;)Te="0"+Te;Te=Te.split(".")[0],h="none"===a.paint.solidColor?"":a.paint.solidColor+Te,C||(h=Y[0].getAttribute("stop-color")),e.extend(e.fn.jPicker.defaults.window,{alphaSupport:!0,effects:{type:"show",speed:0}}),f.jPicker({window:{title:o.window.pickerTitle},images:{clientPath:o.images.clientPath},color:{active:h,alphaSupport:!0}},function(e){a.paint.type="solidColor",a.paint.alpha=e.val("ahex")?Math.round(e.val("a")/255*100):100,a.paint.solidColor=e.val("hex")?e.val("hex"):"none",a.paint.radialGradient=null,u()},null,function(){c()});var Ge=e(l+" .jGraduate_tabs li");Ge.click(function(){Ge.removeClass("jGraduate_tab_current"),e(this).addClass("jGraduate_tab_current"),e(l+" > div").hide();var t=e(this).attr("data-type");if(e(l+" .jGraduate_gradPick").show(),"rg"===t||"lg"===t){e(".jGraduate_"+t+"_field").show(),e(".jGraduate_"+("lg"===t?"rg":"lg")+"_field").hide(),e("#"+s+"_jgraduate_rect")[0].setAttribute("fill","url(#"+s+"_"+t+"_jgraduate_grad)"),x="lg"===t?"linearGradient":"radialGradient",e("#"+s+"_jGraduate_OpacInput").val(a.paint.alpha).change();var n=e("#"+s+"_"+t+"_jgraduate_grad")[0];if(S!==n){var i=e(S).find("stop");e(n).empty().append(i),S=n;var r=oe.val();S.setAttribute("spreadMethod",r)}q="rg"===t&&null!=S.getAttribute("fx")&&!(V===B&&j===R),e("#"+s+"_jGraduate_focusCoord").toggle(q),q&&(e("#"+s+"_jGraduate_match_ctr")[0].checked=!1)}else e(l+" .jGraduate_gradPick").hide(),e(l+" .jGraduate_colPick").show()}),e(l+" > div").hide(),Ge.removeClass("jGraduate_tab_current");var Ne=void 0;switch(a.paint.type){case"linearGradient":Ne=e(l+" .jGraduate_tab_lingrad");break;case"radialGradient":Ne=e(l+" .jGraduate_tab_radgrad");break;default:Ne=e(l+" .jGraduate_tab_color")}a.show(),setTimeout(function(){Ne.addClass("jGraduate_tab_current").click()},10)}else alert("Container element must have an id attribute to maintain unique id strings for sub-elements.");function Ie(t,n,r,a,l){var u=l||i("stop",{"stop-color":n,"stop-opacity":r,offset:t},S);l?(n=l.getAttribute("stop-color"),r=l.getAttribute("stop-opacity"),t=l.getAttribute("offset")):S.appendChild(u),null===r&&(r=1);var c="M-6.2,0.9c3.6-4,6.7-4.3,6.7-12.4c-0.2,7.9,3.1,8.8,6.5,12.4c3.5,3.8,2.9,9.6,0,12.3c-3.1,2.8-10.4,2.7-13.2,0C-9.6,9.9-9.4,4.4-6.2,0.9z",h=i("path",{d:c,fill:"url(#jGraduate_trans)",transform:"translate("+(10+t*g)+", 26)"},P),f=i("path",{d:c,fill:n,"fill-opacity":r,transform:"translate("+(10+t*g)+", 26)",stroke:"#000","stroke-width":1.5},P);return e(f).mousedown(function(e){return Me(this),Q=W,d.mousemove(Ve).mouseup(Le),Z=X.offset(),e.preventDefault(),!1}).data("stop",u).data("bg",h).dblclick(function(){e("div.jGraduate_LightBox").show();for(var t=this,i=+u.getAttribute("stop-opacity")||1,r=u.getAttribute("stop-color")||1,a=(255*parseFloat(i)).toString(16);a.length<2;)a="0"+a;n=r.substr(1)+a,e("#"+s+"_jGraduate_stopPicker").css({left:100,bottom:15}).jPicker({window:{title:"Pick the start color and opacity for the gradient"},images:{clientPath:o.images.clientPath},color:{active:n,alphaSupport:!0}},function(n,a){r=n.val("hex")?"#"+n.val("hex"):"none",i=null!==n.val("a")?n.val("a")/256:1,t.setAttribute("fill",r),t.setAttribute("fill-opacity",i),u.setAttribute("stop-color",r),u.setAttribute("stop-opacity",i),e("div.jGraduate_LightBox").hide(),e("#"+s+"_jGraduate_stopPicker").hide()},null,function(){e("div.jGraduate_LightBox").hide(),e("#"+s+"_jGraduate_stopPicker").hide()})}),e(S).find("stop").each(function(){var i=e(this);if(+this.getAttribute("offset")>t){if(!n){var r=this.getAttribute("stop-color"),a=this.getAttribute("stop-opacity");u.setAttribute("stop-color",r),f.setAttribute("fill",r),u.setAttribute("stop-opacity",null===a?1:a),f.setAttribute("fill-opacity",null===a?1:a)}return i.before(u),!1}}),a&&Me(f),u}function Me(e){W&&W.setAttribute("stroke","#000"),e.setAttribute("stroke","blue"),(W=e).parentNode.appendChild(W)}function Le(){d.unbind("mousemove",Ve),"none"!==$.getAttribute("display")&&function(){$.setAttribute("display","none");var t=e(W),n=t.data("stop"),i=t.data("bg");e([W,n,i]).remove()}(),Q=null}function Oe(){var e=ee?"rotate("+ee+","+te+","+ne+") ":"";if(1===K&&1===J)S.removeAttribute("gradientTransform");else{var t=-te*(K-1),n=-ne*(J-1);S.setAttribute("gradientTransform",e+"translate("+t+","+n+") scale("+K+","+J+")")}}function Ve(t){var n=t.pageX-Z.left,i=t.pageY-Z.top,r="translate("+(n=n<10?10:n>g+10?g+10:n)+", 26)";i<-60||i>130?($.setAttribute("display","block"),$.setAttribute("transform",r)):$.setAttribute("display","none"),Q.setAttribute("transform",r),e.data(Q,"bg").setAttribute("transform",r);var a=e.data(Q,"stop"),o=(n-10)/g;a.setAttribute("offset",o);var s=0;e(S).find("stop").each(function(t){var n=this.getAttribute("offset"),i=e(this);nn(o,"offsetLeft")+o.offsetWidth*s-this.spinCfg._btn_width?a=120?this.adjustValue(this.spinCfg.step):e.wheelDelta<=-120&&this.adjustValue(-this.spinCfg.step),e.preventDefault()}).change(function(e){this.adjustValue(0)}),this.addEventListener&&this.addEventListener("DOMMouseScroll",function(e){e.detail>0?this.adjustValue(-this.spinCfg.step):e.detail<0&&this.adjustValue(this.spinCfg.step),e.preventDefault()},!1)})},e},D,function(e){var t=e(window),n=e(document);return e.extend(e.fn,{contextMenu:function(i,r){return void 0!==i.menu&&(void 0===i.inSpeed&&(i.inSpeed=150),void 0===i.outSpeed&&(i.outSpeed=75),0===i.inSpeed&&(i.inSpeed=-1),0===i.outSpeed&&(i.outSpeed=-1),e(this).each(function(){var a=e(this),o=e(a).offset(),s=e("#"+i.menu);s.addClass("contextMenu"),e(this).bind("mousedown",function(l){var u=l;e(this).mouseup(function(l){var c=e(this);if(c.unbind("mouseup"),2===u.button||i.allowLeft||u.ctrlKey&&O()){if(l.stopPropagation(),e(".contextMenu").hide(),a.hasClass("disabled"))return!1;var h=l.pageX,d=l.pageY,f=t.width()-s.width(),p=t.height()-s.height();h>f-15&&(h=f-15),d>p-30&&(d=p-30),n.unbind("click"),s.css({top:d,left:h}).fadeIn(i.inSpeed),s.find("A").mouseover(function(){s.find("LI.hover").removeClass("hover"),e(this).parent().addClass("hover")}).mouseout(function(){s.find("LI.hover").removeClass("hover")}),n.keypress(function(e){switch(e.keyCode){case 38:s.find("LI.hover").length?(s.find("LI.hover").removeClass("hover").prevAll("LI:not(.disabled)").eq(0).addClass("hover"),s.find("LI.hover").length||s.find("LI:last").addClass("hover")):s.find("LI:last").addClass("hover");break;case 40:s.find("LI.hover").length?(s.find("LI.hover").removeClass("hover").nextAll("LI:not(.disabled)").eq(0).addClass("hover"),s.find("LI.hover").length||s.find("LI:first").addClass("hover")):s.find("LI:first").addClass("hover");break;case 13:s.find("LI.hover A").trigger("click");break;case 27:n.trigger("click")}}),s.find("A").unbind("mouseup"),s.find("LI:not(.disabled) A").mouseup(function(){return n.unbind("click").unbind("keypress"),e(".contextMenu").hide(),r&&r(e(this).attr("href").substr(1),e(c),{x:h-o.left,y:d-o.top,docX:h,docY:d}),!1}),setTimeout(function(){n.click(function(){return n.unbind("click").unbind("keypress"),s.fadeOut(i.outSpeed),!1})},0)}})}),e.browser.mozilla?e("#"+i.menu).each(function(){e(this).css({MozUserSelect:"none"})}):e.browser.msie?e("#"+i.menu).each(function(){e(this).bind("selectstart.disableTextSelect",function(){return!1})}):e("#"+i.menu).each(function(){e(this).bind("mousedown.disableTextSelect",function(){return!1})}),e(a).add(e("UL.contextMenu")).bind("contextmenu",function(){return!1})}),e(this))},disableContextMenuItems:function(t){return void 0===t?(e(this).find("LI").addClass("disabled"),e(this)):(e(this).each(function(){if(void 0!==t)for(var n=t.split(","),i=0;in&&(a=n),o<0?o=0:o>r&&(o=r),l.call(i,"xy",{x:a/n*v+p,y:o/r*_+m})}function l(e,t,n){if(void 0===t)switch(void 0!==e&&null!=e||(e="xy"),e.toLowerCase()){case"x":return d;case"y":return f;case"xy":default:return{x:d,y:f}}if(null==n||n!==i){var r=!1,a=void 0,o=void 0;switch(null==e&&(e="xy"),e.toLowerCase()){case"x":a=t&&(t.x&&0|t.x||0|t)||0;break;case"y":o=t&&(t.y&&0|t.y||0|t)||0;break;case"xy":default:a=t&&t.x&&0|t.x||0,o=t&&t.y&&0|t.y||0}null!=a&&(ag&&(a=g),d!==a&&(d=a,r=!0)),null!=o&&(oy&&(o=y),f!==o&&(f=o,r=!0)),r&&function(e){for(var t=0;t0&&(a=d===g?e:d/v*e|0),_>0&&(o=f===y?n:f/_*n|0),i>=e?a=(e>>1)-(i>>1):a-=i>>1,r>=n?o=(n>>1)-(r>>1):o-=r>>1,b.css({left:a+"px",top:o+"px"})},0)})}e.loadingStylesheets.includes("jgraduate/css/jPicker.css")||e.loadingStylesheets.push("jgraduate/css/jPicker.css"),e.jPicker={List:[],Color:function t(i){n(this,t);var r=this;function a(e){for(var t=0;t255&&(_.r=255),l!==_.r&&(l=_.r,m=!0);break;case"g":if(x)continue;b=!0,_.g=t&&t.g&&0|t.g||t&&0|t||0,_.g<0?_.g=0:_.g>255&&(_.g=255),u!==_.g&&(u=_.g,m=!0);break;case"b":if(x)continue;b=!0,_.b=t&&t.b&&0|t.b||t&&0|t||0,_.b<0?_.b=0:_.b>255&&(_.b=255),c!==_.b&&(c=_.b,m=!0);break;case"a":_.a=t&&null!=t.a?0|t.a:null!=t?0|t:255,_.a<0?_.a=0:_.a>255&&(_.a=255),h!==_.a&&(h=_.a,m=!0);break;case"h":if(b)continue;x=!0,_.h=t&&t.h&&0|t.h||t&&0|t||0,_.h<0?_.h=0:_.h>360&&(_.h=360),d!==_.h&&(d=_.h,m=!0);break;case"s":if(b)continue;x=!0,_.s=t&&null!=t.s?0|t.s:null!=t?0|t:100,_.s<0?_.s=0:_.s>100&&(_.s=100),f!==_.s&&(f=_.s,m=!0);break;case"v":if(b)continue;x=!0,_.v=t&&null!=t.v?0|t.v:null!=t?0|t:100,_.v<0?_.v=0:_.v>100&&(_.v=100),p!==_.v&&(p=_.v,m=!0)}if(m){if(b){l=l||0,u=u||0,c=c||0;var S=s.rgbToHsv({r:l,g:u,b:c});d=S.h,f=S.s,p=S.v}else if(x){d=d||0,f=null!=f?f:100,p=null!=p?p:100;var k=s.hsvToRgb({h:d,s:f,v:p});l=k.r,u=k.g,c=k.b}h=null!=h?h:255,a.call(r,n||r)}}}}var l=void 0,u=void 0,c=void 0,h=void 0,d=void 0,f=void 0,p=void 0,g=[];e.extend(!0,r,{val:o,bind:function(e){"function"==typeof e&&g.push(e)},unbind:function(e){if("function"==typeof e)for(var t=void 0;t=g.includes(e);)g.splice(t,1)},destroy:function(){g=null}}),i&&(null!=i.ahex?o("ahex",i):null!=i.hex?o((null!=i.a?"a":"")+"hex",null!=i.a?{ahex:i.hex+s.intToHex(i.a)}:i):null!=i.r&&null!=i.g&&null!=i.b?o("rgb"+(null!=i.a?"a":""),i):null!=i.h&&null!=i.s&&null!=i.v&&o("hsv"+(null!=i.a?"a":""),i))},ColorMethods:{hexToRgba:function(e){if(""===e||"none"===e)return{r:null,g:null,b:null,a:null};var t="00",n="00",i="00",r="255";return 6===(e=this.validateHex(e)).length&&(e+="ff"),e.length>6?(t=e.substring(0,2),n=e.substring(2,4),i=e.substring(4,6),r=e.substring(6,e.length)):(e.length>4&&(t=e.substring(4,e.length),e=e.substring(0,4)),e.length>2&&(n=e.substring(2,e.length),e=e.substring(0,2)),e.length>0&&(i=e.substring(0,e.length))),{r:this.hexToInt(t),g:this.hexToInt(n),b:this.hexToInt(i),a:this.hexToInt(r)}},validateHex:function(e){return(e=e.toLowerCase().replace(/[^a-f0-9]/g,"")).length>8&&(e=e.substring(0,8)),e},rgbaToHex:function(e){return this.intToHex(e.r)+this.intToHex(e.g)+this.intToHex(e.b)+this.intToHex(e.a)},intToHex:function(e){var t=(0|e).toString(16);return 1===t.length&&(t="0"+t),t.toLowerCase()},hexToInt:function(e){return parseInt(e,16)},rgbToHsv:function(e){var t=e.r/255,n=e.g/255,i=e.b/255,r={h:0,s:0,v:0},a=0,o=0;t>=n&&t>=i?(o=t,a=n>i?i:n):n>=i&&n>=t?(o=n,a=t>i?i:t):(o=i,a=n>t?t:n),r.v=o,r.s=o?(o-a)/o:0;var s=void 0;return r.s?(s=o-a,r.h=t===o?(n-i)/s:n===o?2+(i-t)/s:4+(t-n)/s,r.h=parseInt(60*r.h),r.h<0&&(r.h+=360)):r.h=0,r.s=100*r.s|0,r.v=100*r.v|0,r},hsvToRgb:function(e){var t={r:0,g:0,b:0,a:100},n=e.h,i=e.s,r=e.v;if(0===i)t.r=t.g=t.b=0===r?0:255*r/100|0;else{360===n&&(n=0);var a=0|(n/=60),o=n-a,s=(r/=100)*(1-(i/=100)),l=r*(1-i*o),u=r*(1-i*(1-o));switch(a){case 0:t.r=r,t.g=u,t.b=s;break;case 1:t.r=l,t.g=r,t.b=s;break;case 2:t.r=s,t.g=r,t.b=u;break;case 3:t.r=s,t.g=l,t.b=r;break;case 4:t.r=u,t.g=s,t.b=r;break;case 5:t.r=r,t.g=s,t.b=l}t.r=255*t.r|0,t.g=255*t.g|0,t.b=255*t.b|0}return t}}};var r=e.jPicker,a=r.Color,o=r.List,s=r.ColorMethods;return e.fn.jPicker=function(n){var r=arguments;return this.each(function(){var l=this,u=e.extend(!0,{},e.fn.jPicker.defaults,n);"input"===e(l).get(0).nodeName.toLowerCase()&&(e.extend(!0,u,{window:{bindToInput:!0,expandable:!0,input:e(l)}}),""===e(l).val()?(u.color.active=new a({hex:null}),u.color.current=new a({hex:null})):s.validateHex(e(l).val())&&(u.color.active=new a({hex:e(l).val(),a:u.color.active.val("a")}),u.color.current=new a({hex:e(l).val(),a:u.color.active.val("a")}))),u.window.expandable?e(l).after('    '):u.window.liveUpdate=!1;var c=parseFloat(navigator.appVersion.split("MSIE")[1])<7&&document.body.filters;function h(e){var t=V.active,n=t.val("hex"),i=void 0,r=void 0;switch(u.color.mode=e,e){case"h":if(setTimeout(function(){g.call(l,U,"transparent"),m.call(l,H,0),y.call(l,H,100),m.call(l,q,260),y.call(l,q,100),g.call(l,z,"transparent"),m.call(l,Y,0),y.call(l,Y,100),m.call(l,W,260),y.call(l,W,100),m.call(l,Q,260),y.call(l,Q,100),m.call(l,$,260),y.call(l,$,100),m.call(l,K,260),y.call(l,K,100)},0),J.range("all",{minX:0,maxX:100,minY:0,maxY:100}),ee.range("rangeY",{minY:0,maxY:360}),null==t.val("ahex"))break;J.val("xy",{x:t.val("s"),y:100-t.val("v")},J),ee.val("y",360-t.val("h"),ee);break;case"s":if(setTimeout(function(){g.call(l,U,"transparent"),m.call(l,H,-260),m.call(l,q,-520),m.call(l,Y,-260),m.call(l,W,-520),m.call(l,K,260),y.call(l,K,100)},0),J.range("all",{minX:0,maxX:360,minY:0,maxY:100}),ee.range("rangeY",{minY:0,maxY:100}),null==t.val("ahex"))break;J.val("xy",{x:t.val("h"),y:100-t.val("v")},J),ee.val("y",100-t.val("s"),ee);break;case"v":if(setTimeout(function(){g.call(l,U,"000000"),m.call(l,H,-780),m.call(l,q,260),g.call(l,z,n),m.call(l,Y,-520),m.call(l,W,260),y.call(l,W,100),m.call(l,K,260),y.call(l,K,100)},0),J.range("all",{minX:0,maxX:360,minY:0,maxY:100}),ee.range("rangeY",{minY:0,maxY:100}),null==t.val("ahex"))break;J.val("xy",{x:t.val("h"),y:100-t.val("s")},J),ee.val("y",100-t.val("v"),ee);break;case"r":if(i=-1040,r=-780,J.range("all",{minX:0,maxX:255,minY:0,maxY:255}),ee.range("rangeY",{minY:0,maxY:255}),null==t.val("ahex"))break;J.val("xy",{x:t.val("b"),y:255-t.val("g")},J),ee.val("y",255-t.val("r"),ee);break;case"g":if(i=-1560,r=-1820,J.range("all",{minX:0,maxX:255,minY:0,maxY:255}),ee.range("rangeY",{minY:0,maxY:255}),null==t.val("ahex"))break;J.val("xy",{x:t.val("b"),y:255-t.val("r")},J),ee.val("y",255-t.val("g"),ee);break;case"b":if(i=-2080,r=-2860,J.range("all",{minX:0,maxX:255,minY:0,maxY:255}),ee.range("rangeY",{minY:0,maxY:255}),null==t.val("ahex"))break;J.val("xy",{x:t.val("r"),y:255-t.val("g")},J),ee.val("y",255-t.val("b"),ee);break;case"a":if(setTimeout(function(){g.call(l,U,"transparent"),m.call(l,H,-260),m.call(l,q,-520),m.call(l,Y,260),m.call(l,W,260),y.call(l,W,100),m.call(l,K,0),y.call(l,K,100)},0),J.range("all",{minX:0,maxX:360,minY:0,maxY:100}),ee.range("rangeY",{minY:0,maxY:255}),null==t.val("ahex"))break;J.val("xy",{x:t.val("h"),y:100-t.val("v")},J),ee.val("y",255-t.val("a"),ee);break;default:throw new Error("Invalid Mode")}switch(e){case"h":break;case"s":case"v":case"a":setTimeout(function(){y.call(l,H,100),y.call(l,Y,100),m.call(l,Q,260),y.call(l,Q,100),m.call(l,$,260),y.call(l,$,100)},0);break;case"r":case"g":case"b":setTimeout(function(){g.call(l,U,"transparent"),g.call(l,z,"transparent"),y.call(l,Y,100),y.call(l,H,100),m.call(l,H,i),m.call(l,q,i-260),m.call(l,Y,r-780),m.call(l,W,r-520),m.call(l,Q,r),m.call(l,$,r-260),m.call(l,K,260),y.call(l,K,100)},0)}null!=t.val("ahex")&&d.call(l,t)}function d(e,t){(null==t||t!==ee&&t!==J)&&function(e,t){if(t!==J)switch(u.color.mode){case"h":var n=e.val("sv");J.val("xy",{x:null!=n?n.s:100,y:100-(null!=n?n.v:100)},t);break;case"s":case"a":var i=e.val("hv");J.val("xy",{x:i&&i.h||0,y:100-(null!=i?i.v:100)},t);break;case"v":var r=e.val("hs");J.val("xy",{x:r&&r.h||0,y:100-(null!=r?r.s:100)},t);break;case"r":var a=e.val("bg");J.val("xy",{x:a&&a.b||0,y:255-(a&&a.g||0)},t);break;case"g":var o=e.val("br");J.val("xy",{x:o&&o.b||0,y:255-(o&&o.r||0)},t);break;case"b":var s=e.val("rg");J.val("xy",{x:s&&s.r||0,y:255-(s&&s.g||0)},t)}if(t!==ee)switch(u.color.mode){case"h":ee.val("y",360-(e.val("h")||0),t);break;case"s":var l=e.val("s");ee.val("y",100-(null!=l?l:100),t);break;case"v":var c=e.val("v");ee.val("y",100-(null!=c?c:100),t);break;case"r":ee.val("y",255-(e.val("r")||0),t);break;case"g":ee.val("y",255-(e.val("g")||0),t);break;case"b":ee.val("y",255-(e.val("b")||0),t);break;case"a":var h=e.val("a");ee.val("y",255-(null!=h?h:255),t)}}.call(l,e,t),setTimeout(function(){(function(e){try{var t=e.val("all");ne.css({backgroundColor:t&&"#"+t.hex||"transparent"}),y.call(l,ne,t&&Math.precision(100*t.a/255,4)||0)}catch(e){}}).call(l,e),function(e){switch(u.color.mode){case"h":g.call(l,U,new a({h:e.val("h")||0,s:100,v:100}).val("hex"));break;case"s":case"a":var t=e.val("s");y.call(l,q,100-(null!=t?t:100));break;case"v":var n=e.val("v");y.call(l,H,null!=n?n:100);break;case"r":y.call(l,q,Math.precision((e.val("r")||0)/255*100,4));break;case"g":y.call(l,q,Math.precision((e.val("g")||0)/255*100,4));break;case"b":y.call(l,q,Math.precision((e.val("b")||0)/255*100))}var i=e.val("a");y.call(l,X,Math.precision(100*(255-(i||0))/255,4))}.call(l,e),function(e){switch(u.color.mode){case"h":var t=e.val("a");y.call(l,Z,Math.precision(100*(255-(t||0))/255,4));break;case"s":var n=e.val("hva"),i=new a({h:n&&n.h||0,s:100,v:null!=n?n.v:100});g.call(l,z,i.val("hex")),y.call(l,W,100-(null!=n?n.v:100)),y.call(l,Z,Math.precision(100*(255-(n&&n.a||0))/255,4));break;case"v":var r=e.val("hsa"),o=new a({h:r&&r.h||0,s:null!=r?r.s:100,v:100});g.call(l,z,o.val("hex")),y.call(l,Z,Math.precision(100*(255-(r&&r.a||0))/255,4));break;case"r":case"g":case"b":var s=e.val("rgba"),c=0,h=0;"r"===u.color.mode?(c=s&&s.b||0,h=s&&s.g||0):"g"===u.color.mode?(c=s&&s.b||0,h=s&&s.r||0):"b"===u.color.mode&&(c=s&&s.r||0,h=s&&s.g||0);var d=h>c?c:h;y.call(l,W,c>h?Math.precision((c-h)/(255-h)*100,4):0),y.call(l,Q,h>c?Math.precision((h-c)/(255-c)*100,4):0),y.call(l,$,Math.precision(d/255*100,4)),y.call(l,Z,Math.precision(100*(255-(s&&s.a||0))/255,4));break;case"a":var f=e.val("a");g.call(l,z,e.val("hex")||"000000"),y.call(l,Z,null!=f?0:100),y.call(l,K,null!=f?100:0)}}.call(l,e)},0)}function f(e,t){var n=V.active;if(t===J||null!=n.val()){var i=e.val("all");switch(u.color.mode){case"h":n.val("sv",{s:i.x,v:100-i.y},t);break;case"s":case"a":n.val("hv",{h:i.x,v:100-i.y},t);break;case"v":n.val("hs",{h:i.x,s:100-i.y},t);break;case"r":n.val("gb",{g:255-i.y,b:i.x},t);break;case"g":n.val("rb",{r:255-i.y,b:i.x},t);break;case"b":n.val("rg",{r:i.x,g:255-i.y},t)}}}function p(e,t){var n=V.active;if(t===ee||null!=n.val())switch(u.color.mode){case"h":n.val("h",{h:360-e.val("y")},t);break;case"s":n.val("s",{s:100-e.val("y")},t);break;case"v":n.val("v",{v:100-e.val("y")},t);break;case"r":n.val("r",{r:255-e.val("y")},t);break;case"g":n.val("g",{g:255-e.val("y")},t);break;case"b":n.val("b",{b:255-e.val("y")},t);break;case"a":n.val("a",255-e.val("y"),t)}}function g(e,t){e.css({backgroundColor:t&&6===t.length&&"#"+t||"transparent"})}function v(e,t){c&&(t.includes("AlphaBar.png")||t.includes("Bars.png")||t.includes("Maps.png"))?(e.attr("pngSrc",t),e.css({backgroundImage:"none",filter:"progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+t+"', sizingMethod='scale')"})):e.css({backgroundImage:"url('"+t+"')"})}function m(e,t){e.css({top:t+"px"})}function y(e,t){if(e.css({visibility:t>0?"visible":"hidden"}),t>0&&t<100)if(c){var n=e.attr("pngSrc");null!=n&&(n.includes("AlphaBar.png")||n.includes("Bars.png")||n.includes("Maps.png"))?e.css({filter:"progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+n+"', sizingMethod='scale') progid:DXImageTransform.Microsoft.Alpha(opacity="+t+")"}):e.css({opacity:Math.precision(t/100,4)})}else e.css({opacity:Math.precision(t/100,4)});else if(0===t||100===t)if(c){var i=e.attr("pngSrc");null!=i&&(i.includes("AlphaBar.png")||i.includes("Bars.png")||i.includes("Maps.png"))?e.css({filter:"progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+i+"', sizingMethod='scale')"}):e.css({opacity:""})}else e.css({opacity:""})}function _(){V.active.val("ahex",V.current.val("ahex"))}function b(t){e(this).parents("tbody:first").find('input:radio[value!="'+t.target.value+'"]').removeAttr("checked"),h.call(l,t.target.value)}function x(){_.call(l)}function w(){_.call(l),u.window.expandable&&I.call(l),"function"==typeof fe&&fe.call(l,V.active,ae)}function S(){(function(){V.current.val("ahex",V.active.val("ahex"))}).call(l),u.window.expandable&&I.call(l),"function"==typeof he&&he.call(l,V.active,re)}function k(){N.call(l)}function C(e,t){var n=e.val("hex");ie.css({backgroundColor:n&&"#"+n||"transparent"}),y.call(l,ie,Math.precision(100*(e.val("a")||0)/255,4))}function P(e,t){var n=e.val("hex"),i=e.val("va");se.css({backgroundColor:n&&"#"+n||"transparent"}),y.call(l,le,Math.precision(100*(255-(i&&i.a||0))/255,4)),u.window.bindToInput&&u.window.updateInputColor&&u.window.input.css({backgroundColor:n&&"#"+n||"transparent",color:null==i||i.v>75?"#000000":"#ffffff"})}function A(t){j=parseInt(F.css("left")),B=parseInt(F.css("top")),R=t.pageX,D=t.pageY,e(document).bind("mousemove",E).bind("mouseup",T),t.preventDefault()}function E(t){return F.css({left:j-(R-t.pageX)+"px",top:B-(D-t.pageY)+"px"}),u.window.expandable&&!e.support.boxModel&&F.prev().css({left:F.css("left"),top:F.css("top")}),t.stopPropagation(),t.preventDefault(),!1}function T(t){return e(document).unbind("mousemove",E).unbind("mouseup",T),t.stopPropagation(),t.preventDefault(),!1}function G(t){return t.preventDefault(),t.stopPropagation(),V.active.val("ahex",e(this).attr("title")||null,t.target),!1}function N(){function t(){if(u.window.expandable&&!e.support.boxModel){var t=F.find("table:first");F.before("