svgedit/dist/index-es.min.js

187 lines
333 KiB
JavaScript

function e(e){const{changedTouches:t}=e,n=t[0];let i="";switch(e.type){case"touchstart":i="mousedown";break;case"touchmove":i="mousemove";break;case"touchend":i="mouseup";break;default:return}const{screenX:s,screenY:o,clientX:r,clientY:a}=n,l=new MouseEvent(i,{bubbles:!0,cancelable:!0,view:window,detail:1,screenX:s,screenY:o,clientX:r,clientY:a,ctrlKey:!1,altKey:!1,shiftKey:!1,metaKey:!1,button:0,relatedTarget:null});t.length<2&&(n.target.dispatchEvent(l),e.preventDefault())}document.addEventListener("touchstart",e,!0),document.addEventListener("touchmove",e,!0),document.addEventListener("touchend",e,!0),document.addEventListener("touchcancel",e,!0);
/**
* Namespaces or tools therefor.
* @module namespaces
* @license MIT
*/
const t={HTML:"http://www.w3.org/1999/xhtml",MATH:"http://www.w3.org/1998/Math/MathML",SE:"http://svg-edit.googlecode.com",SVG:"http://www.w3.org/2000/svg",XLINK:"http://www.w3.org/1999/xlink",XML:"http://www.w3.org/XML/1998/namespace",XMLNS:"http://www.w3.org/2000/xmlns/"},n=function(){const e={};return Object.entries(t).forEach(([t,n])=>{e[n]=t.toLowerCase()}),e};(()=>{if(!("SVGPathSeg"in window)){class e{constructor(e,t,n){this.pathSegType=e,this.pathSegTypeAsLetter=t,this._owningPathSegList=n}_segmentChanged(){this._owningPathSegList&&this._owningPathSegList.segmentChanged(this)}}e.prototype.classname="SVGPathSeg",e.PATHSEG_UNKNOWN=0,e.PATHSEG_CLOSEPATH=1,e.PATHSEG_MOVETO_ABS=2,e.PATHSEG_MOVETO_REL=3,e.PATHSEG_LINETO_ABS=4,e.PATHSEG_LINETO_REL=5,e.PATHSEG_CURVETO_CUBIC_ABS=6,e.PATHSEG_CURVETO_CUBIC_REL=7,e.PATHSEG_CURVETO_QUADRATIC_ABS=8,e.PATHSEG_CURVETO_QUADRATIC_REL=9,e.PATHSEG_ARC_ABS=10,e.PATHSEG_ARC_REL=11,e.PATHSEG_LINETO_HORIZONTAL_ABS=12,e.PATHSEG_LINETO_HORIZONTAL_REL=13,e.PATHSEG_LINETO_VERTICAL_ABS=14,e.PATHSEG_LINETO_VERTICAL_REL=15,e.PATHSEG_CURVETO_CUBIC_SMOOTH_ABS=16,e.PATHSEG_CURVETO_CUBIC_SMOOTH_REL=17,e.PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS=18,e.PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL=19;class t extends e{constructor(t){super(e.PATHSEG_CLOSEPATH,"z",t)}toString(){return"[object SVGPathSegClosePath]"}_asPathString(){return this.pathSegTypeAsLetter}clone(){return new t(void 0)}}class n extends e{constructor(t,n,i){super(e.PATHSEG_MOVETO_ABS,"M",t),this._x=n,this._y=i}toString(){return"[object SVGPathSegMovetoAbs]"}_asPathString(){return this.pathSegTypeAsLetter+" "+this._x+" "+this._y}clone(){return new n(void 0,this._x,this._y)}}Object.defineProperties(n.prototype,{x:{get(){return this._x},set(e){this._x=e,this._segmentChanged()},enumerable:!0},y:{get(){return this._y},set(e){this._y=e,this._segmentChanged()},enumerable:!0}});class i extends e{constructor(t,n,i){super(e.PATHSEG_MOVETO_REL,"m",t),this._x=n,this._y=i}toString(){return"[object SVGPathSegMovetoRel]"}_asPathString(){return this.pathSegTypeAsLetter+" "+this._x+" "+this._y}clone(){return new i(void 0,this._x,this._y)}}Object.defineProperties(i.prototype,{x:{get(){return this._x},set(e){this._x=e,this._segmentChanged()},enumerable:!0},y:{get(){return this._y},set(e){this._y=e,this._segmentChanged()},enumerable:!0}});class s extends e{constructor(t,n,i){super(e.PATHSEG_LINETO_ABS,"L",t),this._x=n,this._y=i}toString(){return"[object SVGPathSegLinetoAbs]"}_asPathString(){return this.pathSegTypeAsLetter+" "+this._x+" "+this._y}clone(){return new s(void 0,this._x,this._y)}}Object.defineProperties(s.prototype,{x:{get(){return this._x},set(e){this._x=e,this._segmentChanged()},enumerable:!0},y:{get(){return this._y},set(e){this._y=e,this._segmentChanged()},enumerable:!0}});class o extends e{constructor(t,n,i){super(e.PATHSEG_LINETO_REL,"l",t),this._x=n,this._y=i}toString(){return"[object SVGPathSegLinetoRel]"}_asPathString(){return this.pathSegTypeAsLetter+" "+this._x+" "+this._y}clone(){return new o(void 0,this._x,this._y)}}Object.defineProperties(o.prototype,{x:{get(){return this._x},set(e){this._x=e,this._segmentChanged()},enumerable:!0},y:{get(){return this._y},set(e){this._y=e,this._segmentChanged()},enumerable:!0}});class r extends e{constructor(t,n,i,s,o,r,a){super(e.PATHSEG_CURVETO_CUBIC_ABS,"C",t),this._x=n,this._y=i,this._x1=s,this._y1=o,this._x2=r,this._y2=a}toString(){return"[object SVGPathSegCurvetoCubicAbs]"}_asPathString(){return this.pathSegTypeAsLetter+" "+this._x1+" "+this._y1+" "+this._x2+" "+this._y2+" "+this._x+" "+this._y}clone(){return new r(void 0,this._x,this._y,this._x1,this._y1,this._x2,this._y2)}}Object.defineProperties(r.prototype,{x:{get(){return this._x},set(e){this._x=e,this._segmentChanged()},enumerable:!0},y:{get(){return this._y},set(e){this._y=e,this._segmentChanged()},enumerable:!0},x1:{get(){return this._x1},set(e){this._x1=e,this._segmentChanged()},enumerable:!0},y1:{get(){return this._y1},set(e){this._y1=e,this._segmentChanged()},enumerable:!0},x2:{get(){return this._x2},set(e){this._x2=e,this._segmentChanged()},enumerable:!0},y2:{get(){return this._y2},set(e){this._y2=e,this._segmentChanged()},enumerable:!0}});class a extends e{constructor(t,n,i,s,o,r,a){super(e.PATHSEG_CURVETO_CUBIC_REL,"c",t),this._x=n,this._y=i,this._x1=s,this._y1=o,this._x2=r,this._y2=a}toString(){return"[object SVGPathSegCurvetoCubicRel]"}_asPathString(){return this.pathSegTypeAsLetter+" "+this._x1+" "+this._y1+" "+this._x2+" "+this._y2+" "+this._x+" "+this._y}clone(){return new a(void 0,this._x,this._y,this._x1,this._y1,this._x2,this._y2)}}Object.defineProperties(a.prototype,{x:{get(){return this._x},set(e){this._x=e,this._segmentChanged()},enumerable:!0},y:{get(){return this._y},set(e){this._y=e,this._segmentChanged()},enumerable:!0},x1:{get(){return this._x1},set(e){this._x1=e,this._segmentChanged()},enumerable:!0},y1:{get(){return this._y1},set(e){this._y1=e,this._segmentChanged()},enumerable:!0},x2:{get(){return this._x2},set(e){this._x2=e,this._segmentChanged()},enumerable:!0},y2:{get(){return this._y2},set(e){this._y2=e,this._segmentChanged()},enumerable:!0}});class l extends e{constructor(t,n,i,s,o){super(e.PATHSEG_CURVETO_QUADRATIC_ABS,"Q",t),this._x=n,this._y=i,this._x1=s,this._y1=o}toString(){return"[object SVGPathSegCurvetoQuadraticAbs]"}_asPathString(){return this.pathSegTypeAsLetter+" "+this._x1+" "+this._y1+" "+this._x+" "+this._y}clone(){return new l(void 0,this._x,this._y,this._x1,this._y1)}}Object.defineProperties(l.prototype,{x:{get(){return this._x},set(e){this._x=e,this._segmentChanged()},enumerable:!0},y:{get(){return this._y},set(e){this._y=e,this._segmentChanged()},enumerable:!0},x1:{get(){return this._x1},set(e){this._x1=e,this._segmentChanged()},enumerable:!0},y1:{get(){return this._y1},set(e){this._y1=e,this._segmentChanged()},enumerable:!0}});class c extends e{constructor(t,n,i,s,o){super(e.PATHSEG_CURVETO_QUADRATIC_REL,"q",t),this._x=n,this._y=i,this._x1=s,this._y1=o}toString(){return"[object SVGPathSegCurvetoQuadraticRel]"}_asPathString(){return this.pathSegTypeAsLetter+" "+this._x1+" "+this._y1+" "+this._x+" "+this._y}clone(){return new c(void 0,this._x,this._y,this._x1,this._y1)}}Object.defineProperties(c.prototype,{x:{get(){return this._x},set(e){this._x=e,this._segmentChanged()},enumerable:!0},y:{get(){return this._y},set(e){this._y=e,this._segmentChanged()},enumerable:!0},x1:{get(){return this._x1},set(e){this._x1=e,this._segmentChanged()},enumerable:!0},y1:{get(){return this._y1},set(e){this._y1=e,this._segmentChanged()},enumerable:!0}});class u extends e{constructor(t,n,i,s,o,r,a,l){super(e.PATHSEG_ARC_ABS,"A",t),this._x=n,this._y=i,this._r1=s,this._r2=o,this._angle=r,this._largeArcFlag=a,this._sweepFlag=l}toString(){return"[object SVGPathSegArcAbs]"}_asPathString(){return this.pathSegTypeAsLetter+" "+this._r1+" "+this._r2+" "+this._angle+" "+(this._largeArcFlag?"1":"0")+" "+(this._sweepFlag?"1":"0")+" "+this._x+" "+this._y}clone(){return new u(void 0,this._x,this._y,this._r1,this._r2,this._angle,this._largeArcFlag,this._sweepFlag)}}Object.defineProperties(u.prototype,{x:{get(){return this._x},set(e){this._x=e,this._segmentChanged()},enumerable:!0},y:{get(){return this._y},set(e){this._y=e,this._segmentChanged()},enumerable:!0},r1:{get(){return this._r1},set(e){this._r1=e,this._segmentChanged()},enumerable:!0},r2:{get(){return this._r2},set(e){this._r2=e,this._segmentChanged()},enumerable:!0},angle:{get(){return this._angle},set(e){this._angle=e,this._segmentChanged()},enumerable:!0},largeArcFlag:{get(){return this._largeArcFlag},set(e){this._largeArcFlag=e,this._segmentChanged()},enumerable:!0},sweepFlag:{get(){return this._sweepFlag},set(e){this._sweepFlag=e,this._segmentChanged()},enumerable:!0}});class d extends e{constructor(t,n,i,s,o,r,a,l){super(e.PATHSEG_ARC_REL,"a",t),this._x=n,this._y=i,this._r1=s,this._r2=o,this._angle=r,this._largeArcFlag=a,this._sweepFlag=l}toString(){return"[object SVGPathSegArcRel]"}_asPathString(){return this.pathSegTypeAsLetter+" "+this._r1+" "+this._r2+" "+this._angle+" "+(this._largeArcFlag?"1":"0")+" "+(this._sweepFlag?"1":"0")+" "+this._x+" "+this._y}clone(){return new d(void 0,this._x,this._y,this._r1,this._r2,this._angle,this._largeArcFlag,this._sweepFlag)}}Object.defineProperties(d.prototype,{x:{get(){return this._x},set(e){this._x=e,this._segmentChanged()},enumerable:!0},y:{get(){return this._y},set(e){this._y=e,this._segmentChanged()},enumerable:!0},r1:{get(){return this._r1},set(e){this._r1=e,this._segmentChanged()},enumerable:!0},r2:{get(){return this._r2},set(e){this._r2=e,this._segmentChanged()},enumerable:!0},angle:{get(){return this._angle},set(e){this._angle=e,this._segmentChanged()},enumerable:!0},largeArcFlag:{get(){return this._largeArcFlag},set(e){this._largeArcFlag=e,this._segmentChanged()},enumerable:!0},sweepFlag:{get(){return this._sweepFlag},set(e){this._sweepFlag=e,this._segmentChanged()},enumerable:!0}});class h extends e{constructor(t,n){super(e.PATHSEG_LINETO_HORIZONTAL_ABS,"H",t),this._x=n}toString(){return"[object SVGPathSegLinetoHorizontalAbs]"}_asPathString(){return this.pathSegTypeAsLetter+" "+this._x}clone(){return new h(void 0,this._x)}}Object.defineProperty(h.prototype,"x",{get(){return this._x},set(e){this._x=e,this._segmentChanged()},enumerable:!0});class p extends e{constructor(t,n){super(e.PATHSEG_LINETO_HORIZONTAL_REL,"h",t),this._x=n}toString(){return"[object SVGPathSegLinetoHorizontalRel]"}_asPathString(){return this.pathSegTypeAsLetter+" "+this._x}clone(){return new p(void 0,this._x)}}Object.defineProperty(p.prototype,"x",{get(){return this._x},set(e){this._x=e,this._segmentChanged()},enumerable:!0});class g extends e{constructor(t,n){super(e.PATHSEG_LINETO_VERTICAL_ABS,"V",t),this._y=n}toString(){return"[object SVGPathSegLinetoVerticalAbs]"}_asPathString(){return this.pathSegTypeAsLetter+" "+this._y}clone(){return new g(void 0,this._y)}}Object.defineProperty(g.prototype,"y",{get(){return this._y},set(e){this._y=e,this._segmentChanged()},enumerable:!0});class f extends e{constructor(t,n){super(e.PATHSEG_LINETO_VERTICAL_REL,"v",t),this._y=n}toString(){return"[object SVGPathSegLinetoVerticalRel]"}_asPathString(){return this.pathSegTypeAsLetter+" "+this._y}clone(){return new f(void 0,this._y)}}Object.defineProperty(f.prototype,"y",{get(){return this._y},set(e){this._y=e,this._segmentChanged()},enumerable:!0});class m extends e{constructor(t,n,i,s,o){super(e.PATHSEG_CURVETO_CUBIC_SMOOTH_ABS,"S",t),this._x=n,this._y=i,this._x2=s,this._y2=o}toString(){return"[object SVGPathSegCurvetoCubicSmoothAbs]"}_asPathString(){return this.pathSegTypeAsLetter+" "+this._x2+" "+this._y2+" "+this._x+" "+this._y}clone(){return new m(void 0,this._x,this._y,this._x2,this._y2)}}Object.defineProperties(m.prototype,{x:{get(){return this._x},set(e){this._x=e,this._segmentChanged()},enumerable:!0},y:{get(){return this._y},set(e){this._y=e,this._segmentChanged()},enumerable:!0},x2:{get(){return this._x2},set(e){this._x2=e,this._segmentChanged()},enumerable:!0},y2:{get(){return this._y2},set(e){this._y2=e,this._segmentChanged()},enumerable:!0}});class _ extends e{constructor(t,n,i,s,o){super(e.PATHSEG_CURVETO_CUBIC_SMOOTH_REL,"s",t),this._x=n,this._y=i,this._x2=s,this._y2=o}toString(){return"[object SVGPathSegCurvetoCubicSmoothRel]"}_asPathString(){return this.pathSegTypeAsLetter+" "+this._x2+" "+this._y2+" "+this._x+" "+this._y}clone(){return new _(void 0,this._x,this._y,this._x2,this._y2)}}Object.defineProperties(_.prototype,{x:{get(){return this._x},set(e){this._x=e,this._segmentChanged()},enumerable:!0},y:{get(){return this._y},set(e){this._y=e,this._segmentChanged()},enumerable:!0},x2:{get(){return this._x2},set(e){this._x2=e,this._segmentChanged()},enumerable:!0},y2:{get(){return this._y2},set(e){this._y2=e,this._segmentChanged()},enumerable:!0}});class y extends e{constructor(t,n,i){super(e.PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS,"T",t),this._x=n,this._y=i}toString(){return"[object SVGPathSegCurvetoQuadraticSmoothAbs]"}_asPathString(){return this.pathSegTypeAsLetter+" "+this._x+" "+this._y}clone(){return new y(void 0,this._x,this._y)}}Object.defineProperties(y.prototype,{x:{get(){return this._x},set(e){this._x=e,this._segmentChanged()},enumerable:!0},y:{get(){return this._y},set(e){this._y=e,this._segmentChanged()},enumerable:!0}});class b extends e{constructor(t,n,i){super(e.PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL,"t",t),this._x=n,this._y=i}toString(){return"[object SVGPathSegCurvetoQuadraticSmoothRel]"}_asPathString(){return this.pathSegTypeAsLetter+" "+this._x+" "+this._y}clone(){return new b(void 0,this._x,this._y)}}Object.defineProperties(b.prototype,{x:{get(){return this._x},set(e){this._x=e,this._segmentChanged()},enumerable:!0},y:{get(){return this._y},set(e){this._y=e,this._segmentChanged()},enumerable:!0}}),SVGPathElement.prototype.createSVGPathSegClosePath=function(){return new t(void 0)},SVGPathElement.prototype.createSVGPathSegMovetoAbs=function(e,t){return new n(void 0,e,t)},SVGPathElement.prototype.createSVGPathSegMovetoRel=function(e,t){return new i(void 0,e,t)},SVGPathElement.prototype.createSVGPathSegLinetoAbs=function(e,t){return new s(void 0,e,t)},SVGPathElement.prototype.createSVGPathSegLinetoRel=function(e,t){return new o(void 0,e,t)},SVGPathElement.prototype.createSVGPathSegCurvetoCubicAbs=function(e,t,n,i,s,o){return new r(void 0,e,t,n,i,s,o)},SVGPathElement.prototype.createSVGPathSegCurvetoCubicRel=function(e,t,n,i,s,o){return new a(void 0,e,t,n,i,s,o)},SVGPathElement.prototype.createSVGPathSegCurvetoQuadraticAbs=function(e,t,n,i){return new l(void 0,e,t,n,i)},SVGPathElement.prototype.createSVGPathSegCurvetoQuadraticRel=function(e,t,n,i){return new c(void 0,e,t,n,i)},SVGPathElement.prototype.createSVGPathSegArcAbs=function(e,t,n,i,s,o,r){return new u(void 0,e,t,n,i,s,o,r)},SVGPathElement.prototype.createSVGPathSegArcRel=function(e,t,n,i,s,o,r){return new d(void 0,e,t,n,i,s,o,r)},SVGPathElement.prototype.createSVGPathSegLinetoHorizontalAbs=function(e){return new h(void 0,e)},SVGPathElement.prototype.createSVGPathSegLinetoHorizontalRel=function(e){return new p(void 0,e)},SVGPathElement.prototype.createSVGPathSegLinetoVerticalAbs=function(e){return new g(void 0,e)},SVGPathElement.prototype.createSVGPathSegLinetoVerticalRel=function(e){return new f(void 0,e)},SVGPathElement.prototype.createSVGPathSegCurvetoCubicSmoothAbs=function(e,t,n,i){return new m(void 0,e,t,n,i)},SVGPathElement.prototype.createSVGPathSegCurvetoCubicSmoothRel=function(e,t,n,i){return new _(void 0,e,t,n,i)},SVGPathElement.prototype.createSVGPathSegCurvetoQuadraticSmoothAbs=function(e,t){return new y(void 0,e,t)},SVGPathElement.prototype.createSVGPathSegCurvetoQuadraticSmoothRel=function(e,t){return new b(void 0,e,t)},"getPathSegAtLength"in SVGPathElement.prototype||(SVGPathElement.prototype.getPathSegAtLength=function(e){if(void 0===e||!isFinite(e))throw new Error("Invalid arguments.");const t=document.createElementNS("http://www.w3.org/2000/svg","path");t.setAttribute("d",this.getAttribute("d"));let n=t.pathSegList.numberOfItems-1;if(n<=0)return 0;do{if(t.pathSegList.removeItem(n),e>t.getTotalLength())break;n--}while(n>0);return n}),window.SVGPathSeg=e,window.SVGPathSegClosePath=t,window.SVGPathSegMovetoAbs=n,window.SVGPathSegMovetoRel=i,window.SVGPathSegLinetoAbs=s,window.SVGPathSegLinetoRel=o,window.SVGPathSegCurvetoCubicAbs=r,window.SVGPathSegCurvetoCubicRel=a,window.SVGPathSegCurvetoQuadraticAbs=l,window.SVGPathSegCurvetoQuadraticRel=c,window.SVGPathSegArcAbs=u,window.SVGPathSegArcRel=d,window.SVGPathSegLinetoHorizontalAbs=h,window.SVGPathSegLinetoHorizontalRel=p,window.SVGPathSegLinetoVerticalAbs=g,window.SVGPathSegLinetoVerticalRel=f,window.SVGPathSegCurvetoCubicSmoothAbs=m,window.SVGPathSegCurvetoCubicSmoothRel=_,window.SVGPathSegCurvetoQuadraticSmoothAbs=y,window.SVGPathSegCurvetoQuadraticSmoothRel=b}if(!("SVGPathSegList"in window)||!("appendItem"in window.SVGPathSegList.prototype)){class e{constructor(e){this._pathElement=e,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)}_checkPathSynchronizedToList(){this._updateListFromPathMutations(this._pathElementMutationObserver.takeRecords())}_updateListFromPathMutations(e){if(!this._pathElement)return;let t=!1;e.forEach(e=>{"d"===e.attributeName&&(t=!0)}),t&&(this._list=this._parsePath(this._pathElement.getAttribute("d")))}_writeListToPath(){this._pathElementMutationObserver.disconnect(),this._pathElement.setAttribute("d",e._pathSegArrayAsString(this._list)),this._pathElementMutationObserver.observe(this._pathElement,this._mutationObserverConfig)}segmentChanged(e){this._writeListToPath()}clear(){this._checkPathSynchronizedToList(),this._list.forEach(e=>{e._owningPathSegList=null}),this._list=[],this._writeListToPath()}initialize(e){return this._checkPathSynchronizedToList(),this._list=[e],e._owningPathSegList=this,this._writeListToPath(),e}_checkValidIndex(e){if(isNaN(e)||e<0||e>=this.numberOfItems)throw new Error("INDEX_SIZE_ERR")}getItem(e){return this._checkPathSynchronizedToList(),this._checkValidIndex(e),this._list[e]}insertItemBefore(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}replaceItem(e,t){return this._checkPathSynchronizedToList(),e._owningPathSegList&&(e=e.clone()),this._checkValidIndex(t),this._list[t]=e,e._owningPathSegList=this,this._writeListToPath(),e}removeItem(e){this._checkPathSynchronizedToList(),this._checkValidIndex(e);const t=this._list[e];return this._list.splice(e,1),this._writeListToPath(),t}appendItem(e){return this._checkPathSynchronizedToList(),e._owningPathSegList&&(e=e.clone()),this._list.push(e),e._owningPathSegList=this,this._writeListToPath(),e}_parsePath(e){if(!e||!e.length)return[];const t=this;const n=new class{constructor(){this.pathSegList=[]}appendSegment(e){this.pathSegList.push(e)}},i=new class{constructor(e){this._string=e,this._currentIndex=0,this._endIndex=this._string.length,this._previousCommand=SVGPathSeg.PATHSEG_UNKNOWN,this._skipOptionalSpaces()}_isCurrentSpace(){const e=this._string[this._currentIndex];return e<=" "&&(" "===e||"\n"===e||"\t"===e||"\r"===e||"\f"===e)}_skipOptionalSpaces(){for(;this._currentIndex<this._endIndex&&this._isCurrentSpace();)this._currentIndex++;return this._currentIndex<this._endIndex}_skipOptionalSpacesOrDelimiter(){return!(this._currentIndex<this._endIndex&&!this._isCurrentSpace()&&","!==this._string.charAt(this._currentIndex))&&(this._skipOptionalSpaces()&&this._currentIndex<this._endIndex&&","===this._string.charAt(this._currentIndex)&&(this._currentIndex++,this._skipOptionalSpaces()),this._currentIndex<this._endIndex)}hasMoreData(){return this._currentIndex<this._endIndex}peekSegmentType(){const e=this._string[this._currentIndex];return this._pathSegTypeFromChar(e)}_pathSegTypeFromChar(e){switch(e){case"Z":case"z":return SVGPathSeg.PATHSEG_CLOSEPATH;case"M":return SVGPathSeg.PATHSEG_MOVETO_ABS;case"m":return SVGPathSeg.PATHSEG_MOVETO_REL;case"L":return SVGPathSeg.PATHSEG_LINETO_ABS;case"l":return SVGPathSeg.PATHSEG_LINETO_REL;case"C":return SVGPathSeg.PATHSEG_CURVETO_CUBIC_ABS;case"c":return SVGPathSeg.PATHSEG_CURVETO_CUBIC_REL;case"Q":return SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_ABS;case"q":return SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_REL;case"A":return SVGPathSeg.PATHSEG_ARC_ABS;case"a":return SVGPathSeg.PATHSEG_ARC_REL;case"H":return SVGPathSeg.PATHSEG_LINETO_HORIZONTAL_ABS;case"h":return SVGPathSeg.PATHSEG_LINETO_HORIZONTAL_REL;case"V":return SVGPathSeg.PATHSEG_LINETO_VERTICAL_ABS;case"v":return SVGPathSeg.PATHSEG_LINETO_VERTICAL_REL;case"S":return SVGPathSeg.PATHSEG_CURVETO_CUBIC_SMOOTH_ABS;case"s":return SVGPathSeg.PATHSEG_CURVETO_CUBIC_SMOOTH_REL;case"T":return SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS;case"t":return SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL;default:return SVGPathSeg.PATHSEG_UNKNOWN}}_nextCommandHelper(e,t){return("+"===e||"-"===e||"."===e||e>="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}initialCommandIsMoveTo(){if(!this.hasMoreData())return!0;const e=this.peekSegmentType();return e===SVGPathSeg.PATHSEG_MOVETO_ABS||e===SVGPathSeg.PATHSEG_MOVETO_REL}_parseNumber(){let e=0,t=0,n=1,i=0,s=1,o=1;const r=this._currentIndex;if(this._skipOptionalSpaces(),this._currentIndex<this._endIndex&&"+"===this._string.charAt(this._currentIndex)?this._currentIndex++:this._currentIndex<this._endIndex&&"-"===this._string.charAt(this._currentIndex)&&(this._currentIndex++,s=-1),this._currentIndex===this._endIndex||(this._string.charAt(this._currentIndex)<"0"||this._string.charAt(this._currentIndex)>"9")&&"."!==this._string.charAt(this._currentIndex))return;const a=this._currentIndex;for(;this._currentIndex<this._endIndex&&this._string.charAt(this._currentIndex)>="0"&&this._string.charAt(this._currentIndex)<="9";)this._currentIndex++;if(this._currentIndex!==a){let e=this._currentIndex-1,n=1;for(;e>=a;)t+=n*(this._string.charAt(e--)-"0"),n*=10}if(this._currentIndex<this._endIndex&&"."===this._string.charAt(this._currentIndex)){if(this._currentIndex++,this._currentIndex>=this._endIndex||this._string.charAt(this._currentIndex)<"0"||this._string.charAt(this._currentIndex)>"9")return;for(;this._currentIndex<this._endIndex&&this._string.charAt(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!==r&&this._currentIndex+1<this._endIndex&&("e"===this._string.charAt(this._currentIndex)||"E"===this._string.charAt(this._currentIndex))&&"x"!==this._string.charAt(this._currentIndex+1)&&"m"!==this._string.charAt(this._currentIndex+1)){if(this._currentIndex++,"+"===this._string.charAt(this._currentIndex)?this._currentIndex++:"-"===this._string.charAt(this._currentIndex)&&(this._currentIndex++,o=-1),this._currentIndex>=this._endIndex||this._string.charAt(this._currentIndex)<"0"||this._string.charAt(this._currentIndex)>"9")return;for(;this._currentIndex<this._endIndex&&this._string.charAt(this._currentIndex)>="0"&&this._string.charAt(this._currentIndex)<="9";)e*=10,e+=this._string.charAt(this._currentIndex)-"0",this._currentIndex++}let l=t+i;return l*=s,e&&(l*=10**(o*e)),r!==this._currentIndex?(this._skipOptionalSpacesOrDelimiter(),l):void 0}_parseArcFlag(){if(this._currentIndex>=this._endIndex)return;let e=!1;const t=this._string.charAt(this._currentIndex++);if("0"===t)e=!1;else{if("1"!==t)return;e=!0}return this._skipOptionalSpacesOrDelimiter(),e}parseSegment(){const e=this._string[this._currentIndex];let n=this._pathSegTypeFromChar(e);if(n===SVGPathSeg.PATHSEG_UNKNOWN){if(this._previousCommand===SVGPathSeg.PATHSEG_UNKNOWN)return null;if(n=this._nextCommandHelper(e,this._previousCommand),n===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:{const e={x1:this._parseNumber(),y1:this._parseNumber(),x2:this._parseNumber(),y2:this._parseNumber(),x:this._parseNumber(),y:this._parseNumber()};return new SVGPathSegCurvetoCubicRel(t,e.x,e.y,e.x1,e.y1,e.x2,e.y2)}case SVGPathSeg.PATHSEG_CURVETO_CUBIC_ABS:{const e={x1:this._parseNumber(),y1:this._parseNumber(),x2:this._parseNumber(),y2:this._parseNumber(),x:this._parseNumber(),y:this._parseNumber()};return new SVGPathSegCurvetoCubicAbs(t,e.x,e.y,e.x1,e.y1,e.x2,e.y2)}case SVGPathSeg.PATHSEG_CURVETO_CUBIC_SMOOTH_REL:{const e={x2:this._parseNumber(),y2:this._parseNumber(),x:this._parseNumber(),y:this._parseNumber()};return new SVGPathSegCurvetoCubicSmoothRel(t,e.x,e.y,e.x2,e.y2)}case SVGPathSeg.PATHSEG_CURVETO_CUBIC_SMOOTH_ABS:{const e={x2:this._parseNumber(),y2:this._parseNumber(),x:this._parseNumber(),y:this._parseNumber()};return new SVGPathSegCurvetoCubicSmoothAbs(t,e.x,e.y,e.x2,e.y2)}case SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_REL:{const e={x1:this._parseNumber(),y1:this._parseNumber(),x:this._parseNumber(),y:this._parseNumber()};return new SVGPathSegCurvetoQuadraticRel(t,e.x,e.y,e.x1,e.y1)}case SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_ABS:{const e={x1:this._parseNumber(),y1:this._parseNumber(),x:this._parseNumber(),y:this._parseNumber()};return new SVGPathSegCurvetoQuadraticAbs(t,e.x,e.y,e.x1,e.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:{const e={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,e.x,e.y,e.x1,e.y1,e.arcAngle,e.arcLarge,e.arcSweep)}case SVGPathSeg.PATHSEG_ARC_ABS:{const e={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,e.x,e.y,e.x1,e.y1,e.arcAngle,e.arcLarge,e.arcSweep)}default:throw new Error("Unknown path seg type.")}}}(e);if(!i.initialCommandIsMoveTo())return[];for(;i.hasMoreData();){const e=i.parseSegment();if(!e)return[];n.appendSegment(e)}return n.pathSegList}static _pathSegArrayAsString(e){let t="",n=!0;return e.forEach(e=>{n?(n=!1,t+=e._asPathString()):t+=" "+e._asPathString()}),t}}e.prototype.classname="SVGPathSegList",Object.defineProperty(e.prototype,"numberOfItems",{get(){return this._checkPathSynchronizedToList(),this._list.length},enumerable:!0}),Object.defineProperties(SVGPathElement.prototype,{pathSegList:{get(){return this._pathSegList||(this._pathSegList=new e(this)),this._pathSegList},enumerable:!0},normalizedPathSegList:{get(){return this.pathSegList},enumerable:!0},animatedPathSegList:{get(){return this.pathSegList},enumerable:!0},animatedNormalizedPathSegList:{get(){return this.pathSegList},enumerable:!0}}),window.SVGPathSegList=e}})();const i=jQuery,{userAgent:s}=(Boolean(document.createElementNS&&document.createElementNS(t.SVG,"svg").createSVGRect),navigator),o=document.createElementNS(t.SVG,"svg"),r=Boolean(window.opera),a=s.includes("AppleWebKit"),l=s.includes("Gecko/"),c=s.includes("MSIE"),u=s.includes("Chrome/"),d=(s.includes("Windows"),s.includes("Macintosh")),h="ontouchstart"in window,p=Boolean(o.querySelector),g=Boolean(document.evaluate),f=function(){const e=document.createElementNS(t.SVG,"path");e.setAttribute("d","M0,0 10,10");const n=e.pathSegList,i=e.createSVGPathSegLinetoAbs(5,5);try{return n.replaceItem(i,1),!0}catch(e){}return!1}(),m=function(){const e=document.createElementNS(t.SVG,"path");e.setAttribute("d","M0,0 10,10");const n=e.pathSegList,i=e.createSVGPathSegLinetoAbs(5,5);try{return n.insertItemBefore(i,1),!0}catch(e){}return!1}(),_=function(){const e=document.createElementNS(t.SVG,"svg"),n=document.createElementNS(t.SVG,"svg");document.documentElement.append(e),n.setAttribute("x",5),e.append(n);const i=document.createElementNS(t.SVG,"text");i.textContent="a",n.append(i);try{return 0===i.getStartPositionOfChar(0).x}catch(e){return!1}finally{e.remove()}}(),y=function(){const e=document.createElementNS(t.SVG,"svg");document.documentElement.append(e);const n=document.createElementNS(t.SVG,"path");n.setAttribute("d","M0,0 C0,0 10,10 10,0"),e.append(n);const i=n.getBBox();return e.remove(),i.height>4&&i.height<5}(),b=function(){const e=document.createElementNS(t.SVG,"svg");document.documentElement.append(e);const n=document.createElementNS(t.SVG,"path");n.setAttribute("d","M0,0 10,0");const i=document.createElementNS(t.SVG,"path");i.setAttribute("d","M5,0 15,0");const s=document.createElementNS(t.SVG,"g");s.append(n,i),e.append(s);const o=s.getBBox();return e.remove(),15===o.width}(),v=(function(){const e=document.createElementNS(t.SVG,"rect");e.setAttribute("x",.1);const n=!e.cloneNode(!1).getAttribute("x").includes(",");n||i.alert('NOTE: This version of Opera is known to contain bugs in SVG-edit.\nPlease upgrade to the <a href="http://opera.com">latest version</a> in which the problems have been fixed.')}(),function(){const e=document.createElementNS(t.SVG,"rect");return e.setAttribute("style","vector-effect:non-scaling-stroke"),"non-scaling-stroke"===e.style.vectorEffect}());let x=function(){const e=document.createElementNS(t.SVG,"rect").transform.baseVal,n=o.createSVGTransform();e.appendItem(n);const i=e.getItem(0),s=e=>e&&"object"==typeof e&&"function"==typeof e.setMatrix&&"angle"in e;return s(i)&&s(n)&&i.type===n.type&&i.angle===n.angle&&i.matrix.a===n.matrix.a&&i.matrix.b===n.matrix.b&&i.matrix.c===n.matrix.c&&i.matrix.d===n.matrix.d&&i.matrix.e===n.matrix.e&&i.matrix.f===n.matrix.f}();const w=()=>a,S=()=>l,k=()=>c,C=()=>u,A=()=>d,E=()=>h,G=()=>v;
/**
* A jQuery module to work with SVG attributes.
* @module jQueryAttr
* @license MIT
*/
function P(e){const t=e.fn.attr;return e.fn.attr=function(e,n){const i=this.length;if(!i)return t.call(this,e,n);for(let s=0;s<i;++s){const i=this[s];if("http://www.w3.org/2000/svg"!==i.namespaceURI)return t.call(this,e,n);if(void 0!==n)i.setAttribute(e,n);else if(Array.isArray(e)){const t={};let n=e.length;for(;n--;){const s=e[n];let o=i.getAttribute(s);(o||"0"===o)&&(o=isNaN(o)?o:o-0),t[s]=o}return t}if("object"!=typeof e){let t=i.getAttribute(e);return(t||"0"===t)&&(t=isNaN(t)?t:t-0),t}for(const[t,n]of Object.entries(e))i.setAttribute(t,n)}return this},e}
/**
* Partial polyfill of `SVGTransformList`
* @module SVGTransformList
*
* @license MIT
*
* @copyright 2010 Alexis Deveria, 2010 Jeff Schiller
*/const N=document.createElementNS(t.SVG,"svg");function I(e){const t=e.matrix;let n="";switch(e.type){case 1:n="matrix("+[t.a,t.b,t.c,t.d,t.e,t.f].join(",")+")";break;case 2:n="translate("+t.e+","+t.f+")";break;case 3:n=t.a===t.d?"scale("+t.a+")":"scale("+t.a+","+t.d+")";break;case 4:{let i=0,s=0;if(0!==e.angle){const e=1-t.a;s=(e*t.f+t.b*t.e)/(e*e+t.b*t.b),i=(t.e-t.b*s)/e}n="rotate("+e.angle+" "+i+","+s+")";break}}return n}let T={};class L{constructor(e){this._elem=e||null,this._xforms=[],this._update=function(){let e="";for(let t=0;t<this.numberOfItems;++t){e+=I(this._list.getItem(t))+" "}this._elem.setAttribute("transform",e)},this._list=this,this._init=function(){let e=this._elem.getAttribute("transform");if(!e)return;const t=/\s*((scale|matrix|rotate|translate)\s*\(.*?\))\s*,?\s*/;let n=!0;for(;n;)if(n=e.match(t),e=e.replace(t,""),n&&n[1]){const e=n[1].split(/\s*\(/),t=e[0],i=e[1].match(/\s*(.*?)\s*\)/);i[1]=i[1].replace(/(\d)-/g,"$1 -");const s=i[1].split(/[, ]+/),o="abcdef".split(""),r=N.createSVGMatrix();Object.values(s).forEach((function(e,n){s[n]=Number.parseFloat(e),"matrix"===t&&(r[o[n]]=s[n])}));const a=N.createSVGTransform(),l="set"+t.charAt(0).toUpperCase()+t.slice(1),c="matrix"===t?[r]:s;"scale"===t&&1===c.length?c.push(c[0]):"translate"===t&&1===c.length?c.push(0):"rotate"===t&&1===c.length&&c.push(0,0),a[l](...c),this._list.appendItem(a)}},this._removeFromOtherLists=function(e){e&&Object.values(T).some(t=>{for(let n=0,i=t._xforms.length;n<i;++n)if(t._xforms[n]===e)return t.removeItem(n),!0;return!1})},this.numberOfItems=0}clear(){this.numberOfItems=0,this._xforms=[]}initialize(e){this.numberOfItems=1,this._removeFromOtherLists(e),this._xforms=[e]}getItem(e){if(e<this.numberOfItems&&e>=0)return this._xforms[e];const t=new Error("DOMException with code=INDEX_SIZE_ERR");throw t.code=1,t}insertItemBefore(e,t){let n=null;if(t>=0)if(t<this.numberOfItems){this._removeFromOtherLists(e);const i=new Array(this.numberOfItems+1);let s;for(s=0;s<t;++s)i[s]=this._xforms[s];i[s]=e;for(let e=s+1;s<this.numberOfItems;++e,++s)i[e]=this._xforms[s];this.numberOfItems++,this._xforms=i,n=e,this._list._update()}else n=this._list.appendItem(e);return n}replaceItem(e,t){let n=null;return t<this.numberOfItems&&t>=0&&(this._removeFromOtherLists(e),this._xforms[t]=e,n=e,this._list._update()),n}removeItem(e){if(e<this.numberOfItems&&e>=0){const t=this._xforms[e],n=new Array(this.numberOfItems-1);let i;for(i=0;i<e;++i)n[i]=this._xforms[i];for(let e=i;e<this.numberOfItems-1;++e,++i)n[e]=this._xforms[i+1];return this.numberOfItems--,this._xforms=n,this._list._update(),t}const t=new Error("DOMException with code=INDEX_SIZE_ERR");throw t.code=1,t}appendItem(e){return this._removeFromOtherLists(e),this._xforms.push(e),this.numberOfItems++,this._list._update(),e}}let M=function(e){e.id&&T[e.id]&&delete T[e.id]};const O=function(e){if(!x){const t=e.id||"temp";let n=T[t];return n&&"temp"!==t||(T[t]=new L(e),T[t]._init(),n=T[t]),n}return e.transform?e.transform.baseVal:e.gradientTransform?e.gradientTransform.baseVal:e.patternTransform?e.patternTransform.baseVal:null},j=["x","x1","cx","rx","width"],V=["y","y1","cy","ry","height"],R=["r","radius",...j,...V];
/**
* Tools for working with units.
* @module units
* @license MIT
*
* @copyright 2010 Alexis Deveria, 2010 Jeff Schiller
*/let B,U={};const D=function(){return U},F=function(e){const t=B.getRoundDigits();return isNaN(e)?Array.isArray(e)?F(e[0])+","+F(e[1]):Number.parseFloat(e).toFixed(t)-0:Number(Number(e).toFixed(t))},z=function(e,t){return t=t||B.getBaseUnit(),F(e/U[t])},H=function(e,t,n){e.setAttribute(t,n)},q=function(e,t){if(!isNaN(t))return t-0;if("%"===t.substr(-1)){const n=t.substr(0,t.length-1)/100,i=B.getWidth(),s=B.getHeight();return j.includes(e)?n*i:V.includes(e)?n*s:n*Math.sqrt(i*i+s*s)/Math.sqrt(2)}const n=t.substr(-2);return t.substr(0,t.length-2)*U[n]},X=function(e,t,n){if(R.includes(e))return!isNaN(t)||(t=t.toLowerCase(),Object.keys(U).some(e=>new RegExp("^-?[\\d\\.]+"+e+"$").test(t)));if("id"===e){let e=!1;try{const i=B.getElement(t);e=Qe(i)||i===n}catch(e){}return e}return!0},W=document.createElementNS(t.SVG,"svg"),$=function(e,t,n){return{x:n.a*e+n.c*t+n.e,y:n.b*e+n.d*t+n.f}},Y=function(e){return 1===e.a&&0===e.b&&0===e.c&&1===e.d&&0===e.e&&0===e.f},Q=function(...e){const t=e.reduceRight((e,t)=>t.multiply(e));return Math.abs(t.a)<1e-14&&(t.a=0),Math.abs(t.b)<1e-14&&(t.b=0),Math.abs(t.c)<1e-14&&(t.c=0),Math.abs(t.d)<1e-14&&(t.d=0),Math.abs(t.e)<1e-14&&(t.e=0),Math.abs(t.f)<1e-14&&(t.f=0),t},K=function(e){if(!e)return!1;let t=e.numberOfItems;for(;t--;){const n=e.getItem(t);if(1===n.type&&!Y(n.matrix))return!0}return!1},Z=function(e,t,n,i,s){const o=$(e,t,s),r=$(e+n,t,s),a=$(e,t+i,s),l=$(e+n,t+i,s),c=Math.min(o.x,r.x,a.x,l.x),u=Math.max(o.x,r.x,a.x,l.x),d=Math.min(o.y,r.y,a.y,l.y);return{tl:o,tr:r,bl:a,br:l,aabox:{x:c,y:d,width:u-c,height:Math.max(o.y,r.y,a.y,l.y)-d}}},J=function(e,t,n){if(Qe(e))return W.createSVGTransformFromMatrix(W.createSVGMatrix());if(t=t||0,n=n||e.numberOfItems-1,(t=Number.parseInt(t))>(n=Number.parseInt(n))){const e=n;n=t,t=e}let i=W.createSVGMatrix();for(let s=t;s<=n;++s){const t=s>=0&&s<e.numberOfItems?e.getItem(s).matrix:W.createSVGMatrix();i=Q(i,t)}return W.createSVGTransformFromMatrix(i)},ee=function(e){const t=O(e);return J(t).matrix},te=function(e,t,n,i){const s=Math.PI/4,o=n-e,r=i-t,a=Math.atan2(r,o),l=Math.sqrt(o*o+r*r),c=Math.round(a/s)*s;return{x:e+l*Math.cos(c),y:t+l*Math.sin(c),a:c}},ne=function(e,t){return t.x<e.x+e.width&&t.x+t.width>e.x&&t.y<e.y+e.height&&t.y+t.height>e.y},ie=P(jQuery),se="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",oe="a,circle,ellipse,foreignObject,g,image,line,path,polygon,polyline,rect,svg,text,tspan,use,clipPath".split(",");let re=null,ae=null,le=null,ce=null;const ue=function(e){re=e,ae=e.getDOMDocument(),le=e.getDOMContainer(),ce=e.getSVGRoot()},de=e=>e.replace(/(<!DOCTYPE\s+\w*\s*\[).*(\?]>)/,"$1$2"),he=function(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#x27;")};function pe(e){if(e=me(e),window.btoa)return window.btoa(e);const t=new Array(4*Math.floor((e.length+2)/3));let n=0,i=0;do{const s=e.charCodeAt(n++),o=e.charCodeAt(n++),r=e.charCodeAt(n++),a=s>>2,l=(3&s)<<4|o>>4;let c=(15&o)<<2|r>>6,u=63&r;Number.isNaN(o)?(c=64,u=64):Number.isNaN(r)&&(u=64),t[i++]=se.charAt(a),t[i++]=se.charAt(l),t[i++]=se.charAt(c),t[i++]=se.charAt(u)}while(n<e.length);return t.join("")}function ge(e){if(window.atob)return fe(window.atob(e));e=e.replace(/[^A-Za-z\d+/=]/g,"");let t="",n=0;do{const i=se.indexOf(e.charAt(n++)),s=se.indexOf(e.charAt(n++)),o=se.indexOf(e.charAt(n++)),r=se.indexOf(e.charAt(n++)),a=i<<2|s>>4,l=(15&s)<<4|o>>2,c=(3&o)<<6|r;t+=String.fromCharCode(a),64!==o&&(t+=String.fromCharCode(l)),64!==r&&(t+=String.fromCharCode(c))}while(n<e.length);return fe(t)}function fe(e){return decodeURIComponent(escape(e))}const me=function(e){return unescape(encodeURIComponent(e))},_e=function(e){if("undefined"==typeof Uint8Array||"undefined"==typeof Blob||"undefined"==typeof URL||!URL.createObjectURL)return"";const t=e.split(","),n=t[0].match(/:(.*?);/)[1],i=atob(t[1]);let s=i.length;const o=new Uint8Array(s);for(;s--;)o[s]=i.charCodeAt(s);const r=new Blob([o],{type:n});return URL.createObjectURL(r)},ye=function(e){return e&&"undefined"!=typeof URL&&URL.createObjectURL?URL.createObjectURL(e):""},be=function(){if("undefined"==typeof Blob)return"";const e=new Blob(["<html><head><title>SVG-edit</title></head><body>&nbsp;</body></html>"],{type:"text/html"});return ye(e)}(),ve=function(e){let t,n;e.includes("<svg:svg")&&(e=e.replace(/<(\/?)svg:/g,"<$1").replace("xmlns:svg","xmlns"));try{n=window.DOMParser?new DOMParser:new window.ActiveXObject("Microsoft.XMLDOM"),n.async=!1}catch(e){throw new Error("XML Parser could not be instantiated")}try{t=n.loadXML?!!n.loadXML(e)&&n:n.parseFromString(e,"text/xml")}catch(e){throw new Error("Error parsing XML string")}return t},xe=function({x:e,y:t,width:n,height:i}){return{x:e,y:t,width:n,height:i}},we=function(e,t){if(e&&1===e.nodeType){t(e);let n=e.childNodes.length;for(;n--;)we(e.childNodes.item(n),t)}},Se=function(e,t){if(e&&1===e.nodeType){let n=e.childNodes.length;for(;n--;)we(e.childNodes.item(n),t);t(e)}},ke=function(e){if(e){if(e.startsWith('url("'))return e.substring(5,e.indexOf('"',6));if(e.startsWith("url('"))return e.substring(5,e.indexOf("'",6));if(e.startsWith("url("))return e.substring(4,e.indexOf(")"))}return null};let Ce=function(e){return e.getAttributeNS(t.XLINK,"href")},Ae=function(e,n){e.setAttributeNS(t.XLINK,"xlink:href",n)};const Ee=function(){const e=re.getSVGContent();let n=e.getElementsByTagNameNS(t.SVG,"defs");return n.length>0?n=n[0]:(n=e.ownerDocument.createElementNS(t.SVG,"defs"),e.firstChild?e.insertBefore(n,e.firstChild.nextSibling):e.append(n)),n},Ge=function(e){const t=e.pathSegList,n=t.numberOfItems,i=[[],[]],s=t.getItem(0);let o=[s.x,s.y];const r=function(e,t,n,i){return function(s){return 1-s**3*o[e]+3-s**2*s*t[e]+3*(1-s)*s**2*n[e]+s**3*i[e]}};for(let e=0;e<n;e++){const n=t.getItem(e);if(void 0!==n.x)if(i[0].push(o[0]),i[1].push(o[1]),n.x1){const e=[n.x1,n.y1],t=[n.x2,n.y2],s=[n.x,n.y];for(let n=0;n<2;n++){const a=r(n,e,t,s),l=6*o[n]-12*e[n]+6*t[n],c=-3*o[n]+9*e[n]-9*t[n]+3*s[n],u=3*e[n]-3*o[n];if(0===c){if(0===l)continue;const e=-u/l;e>0&&e<1&&i[n].push(a(e));continue}const d=l**2-4*u*c;if(d<0)continue;const h=(-l+Math.sqrt(d))/(2*c);h>0&&h<1&&i[n].push(a(h));const p=(-l-Math.sqrt(d))/(2*c);p>0&&p<1&&i[n].push(a(p))}o=s}else i[0].push(n.x),i[1].push(n.y)}const a=Math.min.apply(null,i[0]),l=Math.max.apply(null,i[0])-a,c=Math.min.apply(null,i[1]);return{x:a,y:c,width:l,height:Math.max.apply(null,i[1])-c}};function Pe(e){if(b)try{return e.getBBox()}catch(e){}const t=ie.data(e,"ref");let n,i,s=null;t?(i=ie(t).children().clone().attr("visibility","hidden"),ie(ce).append(i),s=i.filter("line, path")):s=ie(e).find("line, path");let o=!1;if(s.length)if(s.each((function(){const e=this.getBBox();e.width&&e.height||(o=!0)})),o){const s=t?i:ie(e).children();n=Re(s)}else n=e.getBBox();else n=e.getBBox();return t&&i.remove(),n}const Ne=function(e){const t=e||re.geSelectedElements()[0];if(1!==e.nodeType)return null;const n=t.nodeName;let i=null;switch(n){case"text":""===t.textContent?(t.textContent="a",i=t.getBBox(),t.textContent=""):t.getBBox&&(i=t.getBBox());break;case"path":y?t.getBBox&&(i=t.getBBox()):i=Ge(t);break;case"g":case"a":i=Pe(t);break;default:if("use"===n&&(i=Pe(t)),"use"===n||"foreignObject"===n&&w()){if(i||(i=t.getBBox()),!w()){const{x:e,y:n,width:s,height:o}=i;i={width:s,height:o,x:e+Number.parseFloat(t.getAttribute("x")||0),y:n+Number.parseFloat(t.getAttribute("y")||0)}}}else if(oe.includes(n))if(t)try{i=t.getBBox()}catch(e){const n=t.getExtentOfChar(0),s=t.getComputedTextLength();i={x:n.x,y:n.y,width:s,height:n.height}}else{const e=ie(t).closest("foreignObject");e.length&&e[0].getBBox&&(i=e[0].getBBox())}}return i&&(i=xe(i)),i},Ie=function(e){let t="";return ie.each(e,(function(e,[n,i]){t+=n;for(let e=0;e<i.length;e+=2)t+=i[e]+","+i[e+1]+" "})),t},Te=function(e){let t,n,i,s,o=1.81;switch(e.tagName){case"ellipse":case"circle":{n=ie(e).attr(["rx","ry","cx","cy"]);const{cx:r,cy:a}=n;({rx:i,ry:s}=n),"circle"===e.tagName&&(s=ie(e).attr("r"),i=s),t=Ie([["M",[r-i,a]],["C",[r-i,a-s/o,r-i/o,a-s,r,a-s]],["C",[r+i/o,a-s,r+i,a-s/o,r+i,a]],["C",[r+i,a+s/o,r+i/o,a+s,r,a+s]],["C",[r-i/o,a+s,r-i,a+s/o,r-i,a]],["Z",[]]]);break}case"path":t=e.getAttribute("d");break;case"line":n=ie(e).attr(["x1","y1","x2","y2"]),t="M"+n.x1+","+n.y1+"L"+n.x2+","+n.y2;break;case"polyline":t="M"+e.getAttribute("points");break;case"polygon":t="M"+e.getAttribute("points")+" Z";break;case"rect":{const n=ie(e).attr(["rx","ry"]);({rx:i,ry:s}=n);const r=e.getBBox(),{x:a,y:l}=r,c=r.width,u=r.height;o=4-o,t=Ie(i||s?[["M",[a,l+s]],["C",[a,l+s/o,a+i/o,l,a+i,l]],["L",[a+c-i,l]],["C",[a+c-i/o,l,a+c,l+s/o,a+c,l+s]],["L",[a+c,l+u-s]],["C",[a+c,l+u-s/o,a+c-i/o,l+u,a+c-i,l+u]],["L",[a+i,l+u]],["C",[a+i/o,l+u,a,l+u-s/o,a,l+u-s]],["L",[a,l+s]],["Z",[]]]:[["M",[a,l]],["L",[a+c,l]],["L",[a+c,l+u]],["L",[a,l+u]],["L",[a,l]],["Z",[]]]);break}}return t},Le=function(e){const t={};return ie.each(["marker-start","marker-end","marker-mid","filter","clip-path"],(function(){const n=e.getAttribute(this);n&&(t[this]=n)})),t},Me=function(e,t,n){const i=t({element:"path",attr:Le(e)}),s=e.getAttribute("transform");s&&i.setAttribute("transform",s);const{parentNode:o}=e;e.nextSibling?e.before(i):o.append(i);const r=Te(e);r?i.setAttribute("d",r):i.remove(),n.resetOrientation(i);let a=!1;try{a=i.getBBox()}catch(e){}return i.remove(),a},Oe=function(e,t,n,i,s,o,r,a){const l=new r.BatchCommand("Convert element to Path"),c=n({element:"path",attr:t=ie.extend({},t,Le(e))}),u=e.getAttribute("transform");u&&c.setAttribute("transform",u);const{id:d}=e,{parentNode:h}=e;e.nextSibling?e.before(c):h.append(c);const p=Te(e);if(p){if(c.setAttribute("d",p),u){const e=O(c);K(e)&&i.resetOrientation(c)}const{nextSibling:t}=e;return l.addSubCommand(new r.RemoveElementCommand(e,t,parent)),l.addSubCommand(new r.InsertElementCommand(c)),s(),e.remove(),c.setAttribute("id",d),c.removeAttribute("visibility"),o([c],!0),a(l),c}return c.remove(),null};const je=function(e,t,n){let i=Ne(e);if(!i)return null;const s=O(e),o=De(s),r=K(s);if(o||r){let a=!1;if(function(e,t){const n=e%90;return t||!(n>-.001&&n<.001||(n<-89.99||n>89.99))}(o,r)){if(["ellipse","path","line","polyline","polygon"].includes(e.tagName))a=Me(e,t,n),i=a;else if("rect"===e.tagName){const s=e.getAttribute("rx"),o=e.getAttribute("ry");(s||o)&&(a=Me(e,t,n),i=a)}}if(!a){const{matrix:e}=J(s);i=Z(i.x,i.y,i.width,i.height,e).aabox}}return i};function Ve(e){const t=e.getAttribute("stroke-width");return isNaN(t)||"none"===e.getAttribute("stroke")?0:t/2}const Re=function(e,t,n){if(!e||!e.length)return!1;let i;if(ie.each(e,(function(){i||this.parentNode&&(i=je(this,t,n))})),void 0===i)return null;let s=i.x+i.width,o=i.y+i.height,r=i.x,a=i.y;if(1===e.length){const t=Ve(e[0]);r-=t,a-=t,s+=t,o+=t}else ie.each(e,(function(e,i){const l=je(i,t,n);if(l){const e=Ve(i);r=Math.min(r,l.x-e),a=Math.min(a,l.y-e),1===i.nodeType&&(s=Math.max(s,l.x+l.width+e),o=Math.max(o,l.y+l.height+e))}}));return i.x=r,i.y=a,i.width=s-r,i.height=o-a,i},Be=function(e){e||(e=ie(re.getSVGContent()).children());const t=[];return ie(e).children().each((function(e,n){n.getBBox&&t.push(n)})),t.reverse()},Ue=function(e){return e||(e=Be()),Re(e,re.addSVGElementFromJson,re.pathActions)},De=function(e,t){if(!e)return 0;const n=e.numberOfItems;for(let i=0;i<n;++i){const n=e.getItem(i);if(4===n.type)return t?n.angle*Math.PI/180:n.angle}return 0};let Fe=function(e,t){const n=e||re.getSelectedElements()[0],i=O(n);return De(i,t)};const ze=function(e){return He(ke(e).substr(1))},He=p?function(e){return ce.querySelector("#"+e)}:g?function(e){return ae.evaluate('svg:svg[@id="svgroot"]//svg:*[@id="'+e+'"]',le,(function(){return t.SVG}),9,null).singleNodeValue}:function(e){return ie(ce).find("[id="+e+"]")[0]},qe=function(e,n,i,s){for(const[i,o]of Object.entries(n)){const n="xml:"===i.substr(0,4)?t.XML:"xlink:"===i.substr(0,6)?t.XLINK:null;Qe(o)?n?e.removeAttributeNS(n,i):e.removeAttribute(i):n?e.setAttributeNS(n,i,o):s?H(e,i,o):e.setAttribute(i,o)}},Xe=function(e){const t={"fill-opacity":1,"stop-opacity":1,opacity:1,stroke:"none","stroke-dasharray":"none","stroke-linejoin":"miter","stroke-linecap":"butt","stroke-opacity":1,"stroke-width":1,rx:0,ry:0};"ellipse"===e.nodeName&&(delete t.rx,delete t.ry),Object.entries(t).forEach(([t,n])=>{e.getAttribute(t)===String(n)&&e.removeAttribute(t)})},We=function(e){const t=re.getBaseUnit();let n=re.getSnappingStep();return"px"!==t&&(n*=D()[t]),e=Math.round(e/n)*n},$e=function(e){return String(e).replace(/[.\\+*?[^\]$(){}=!<>|:-]/g,"\\$&")},Ye=function(e){ie(e).click((function(e){e.preventDefault()}))},Qe=e=>null==e;var Ke=Object.freeze({__proto__:null,init:ue,dropXMLInternalSubset:de,toXml:he,fromXml:function(e){return ie("<p/>").html(e).text()},encode64:pe,decode64:ge,decodeUTF8:fe,encodeUTF8:me,dataURLToObjectURL:_e,createObjectURL:ye,blankPageObjectURL:be,convertToXMLReferences:function(e){let t="";return[...e].forEach(e=>{const n=e.charCodeAt();t+=n<=127?e:`&#${n};`}),t},text2xml:ve,bboxToObj:xe,walkTree:we,walkTreePost:Se,getUrlFromAttr:ke,get getHref(){return Ce},get setHref(){return Ae},findDefs:Ee,getPathBBox:Ge,getBBox:Ne,getPathDFromSegments:Ie,getPathDFromElement:Te,getExtraAttributesForConvertToPath:Le,getBBoxOfElementAsPath:Me,convertToPath:Oe,getBBoxWithTransform:je,getStrokedBBox:Re,getVisibleElements:Be,getStrokedBBoxDefaultVisible:Ue,getRotationAngleFromTransformList:De,get getRotationAngle(){return Fe},getRefElem:ze,getElem:He,assignAttributes:qe,cleanupElement:Xe,snapToGrid:We,regexEscape:$e,preventClickDefault:Ye,isNullish:Qe,mock:({getHref:e,setHref:t,getRotationAngle:n})=>{Ce=e,Ae=t,Fe=n},$q:e=>document.querySelector(e),$qq:e=>[...document.querySelectorAll(e)]});
/**
* Adds context menu functionality.
* @module contextmenu
* @license Apache-2.0
* @author Adam Bender
*/const Ze=jQuery;let Je={};const et=function(){Object.values(Je).forEach(e=>{!function(e){Object.keys(Je).length||Ze("#cmenu_canvas").append("<li class='separator'>");const t=e.shortcut||"";Ze("#cmenu_canvas").append("<li class='disabled'><a href='#"+e.id+"'>"+e.label+"<span class='shortcut'>"+t+"</span></a></li>")}(e)})};function tt(){return(tt=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(e[i]=n[i])}return e}).apply(this,arguments)}
/**
* Adapted from {@link https://github.com/uupaa/dynamic-import-polyfill/blob/master/importModule.js}.
* @module importModule
* @license MIT
*/function nt(e,t){["id","class","type"].forEach(n=>{n in t&&(e[n]=t[n])})}function it(e,t){return st(e,tt({},t,{returnDefault:!0}))}async function st(e,{global:t,returnDefault:n}){return"svgEditor"in window&&window.svgEditor&&!1===window.svgEditor.modules?(await ot(e),window[t]):function e(t,n={},{returnDefault:i=!1}={}){if(Array.isArray(t))return Promise.all(t.map(t=>e(t,n)));return new Promise((e,s)=>{const o="$importModule$"+Math.random().toString(32).slice(2),r=document.createElement("script");function a(){s(new Error("Failed to import: "+t)),c()}function l(){e(window[o]),c()}const c=()=>{delete window[o],r.removeEventListener("error",a),r.removeEventListener("load",l),r.remove(),URL.revokeObjectURL(r.src),r.src=""};nt(r,n),r.defer="defer",r.type="module",r.addEventListener("error",a),r.addEventListener("load",l);const u=`import * as m from '${function(e){const t=document.createElement("a");return t.setAttribute("href",e),t.cloneNode(!1).href}(t).replace(/'/g,"\\'")}'; window.${o} = ${i?"m.default || ":""}m;`,d=new Blob([u],{type:"text/javascript"});r.src=URL.createObjectURL(d),document.head.append(r)})}(e,void 0,{returnDefault:n})}function ot(e,t={}){return Array.isArray(e)?Promise.all(e.map(e=>ot(e,t))):new Promise((n,i)=>{const s=document.createElement("script");function o(){i(new Error("Failed to import: "+e)),a()}function r(){n(),a()}const a=()=>{s.removeEventListener("error",o),s.removeEventListener("load",r),s.remove(),s.src=""};s.defer="defer",nt(s,t),s.addEventListener("error",o),s.addEventListener("load",r),s.src=e,document.head.append(s)})}const rt={true:!0,false:!1,null:null};function at(e,{ok:t="Ok",cancel:n="Cancel"}={}){e("#dialog_container").draggable({cancel:"#dialog_content, #dialog_buttons *",containment:"window"}).css("position","absolute");const i=e("#dialog_box"),s=e("#dialog_buttons"),o=e("#dialog_content");function r(r,a,l,c,u,d){o.html("<p>"+a.replace(/\n/g,"</p><p>")+"</p>").toggleClass("prompt","prompt"===r),s.empty();const h=e('<input type="button" data-ok="" value="'+t+'">').appendTo(s);return new Promise((t,p)=>{let g,f;if("alert"!==r&&e('<input type="button" value="'+n+'">').appendTo(s).click((function(){i.hide(),t(!1)})),"prompt"===r)g=e('<input type="text">').prependTo(s),g.val(l||""),g.bind("keydown","return",(function(){h.click()}));else if("select"===r){const t=e('<div style="text-align:center;">');if(g=e(`<select aria-label="${a}">`).appendTo(t),d){const n=e("<label>").text(d.label);f=e('<input type="checkbox">').appendTo(n),f.val(d.value),d.tooltip&&n.attr("title",d.tooltip),f.prop("checked",Boolean(d.checked)),t.append(e("<div>").append(n))}e.each(c||[],(function(t,n){"object"==typeof n?g.append(e("<option>").val(n.value).html(n.text)):g.append(e("<option>").html(n))})),o.append(t),l&&g.val(l),u&&g.bind("change","return",u),g.bind("keydown","return",(function(){h.click()}))}else"process"===r&&h.hide();i.show(),h.click((function(){i.hide();const e="prompt"!==r&&"select"!==r||g.val();t(f?{response:e,checked:f.prop("checked")}:e)})).focus(),"prompt"!==r&&"select"!==r||g.focus()})}return e.alert=function(e){return r("alert",e)},e.confirm=function(e){return r("confirm",e)},e.process_cancel=function(e){return r("process",e)},e.prompt=function(e,t=""){return r("prompt",e,t)},e.select=function(e,t,n,i,s){return r("select",e,i,t,n,s)},e}const lt={BEFORE_APPLY:"before_apply",AFTER_APPLY:"after_apply",BEFORE_UNAPPLY:"before_unapply",AFTER_UNAPPLY:"after_unapply"};class ct{getText(){return this.text}apply(e,t){e&&e.handleHistoryEvent(lt.BEFORE_APPLY,this),t(e),e&&e.handleHistoryEvent(lt.AFTER_APPLY,this)}unapply(e,t){e&&e.handleHistoryEvent(lt.BEFORE_UNAPPLY,this),t(),e&&e.handleHistoryEvent(lt.AFTER_UNAPPLY,this)}elements(){return[this.elem]}type(){return this.constructor.name}}class ut extends ct{constructor(e,t,n,i){super(),this.elem=e,this.text=i?"Move "+e.tagName+" to "+i:"Move "+e.tagName,this.oldNextSibling=t,this.oldParent=n,this.newNextSibling=e.nextSibling,this.newParent=e.parentNode}apply(e){super.apply(e,()=>{this.elem=this.newParent.insertBefore(this.elem,this.newNextSibling)})}unapply(e){super.unapply(e,()=>{this.elem=this.oldParent.insertBefore(this.elem,this.oldNextSibling)})}}class dt extends ct{constructor(e,t){super(),this.elem=e,this.text=t||"Create "+e.tagName,this.parent=e.parentNode,this.nextSibling=this.elem.nextSibling}apply(e){super.apply(e,()=>{this.elem=this.parent.insertBefore(this.elem,this.nextSibling)})}unapply(e){super.unapply(e,()=>{this.parent=this.elem.parentNode,this.elem.remove()})}}class ht extends ct{constructor(e,t,n,i){super(),this.elem=e,this.text=i||"Delete "+e.tagName,this.nextSibling=t,this.parent=n,M(e)}apply(e){super.apply(e,()=>{M(this.elem),this.parent=this.elem.parentNode,this.elem.remove()})}unapply(e){super.unapply(e,()=>{M(this.elem),Qe(this.nextSibling)&&window.console&&console.error("Reference element was lost"),this.parent.insertBefore(this.elem,this.nextSibling)})}}class pt extends ct{constructor(e,t,n){super(),this.elem=e,this.text=n?"Change "+e.tagName+" "+n:"Change "+e.tagName,this.newValues={},this.oldValues=t;for(const n in t)this.newValues[n]="#text"===n?e.textContent:"#href"===n?Ce(e):e.getAttribute(n)}apply(e){super.apply(e,()=>{let e=!1;if(Object.entries(this.newValues).forEach(([t,n])=>{n?"#text"===t?this.elem.textContent=n:"#href"===t?Ae(this.elem,n):this.elem.setAttribute(t,n):"#text"===t?this.elem.textContent="":(this.elem.setAttribute(t,""),this.elem.removeAttribute(t)),"transform"===t&&(e=!0)}),!e){const e=Fe(this.elem);if(e){const t=this.elem.getBBox(),n=["rotate(",e," ",t.x+t.width/2,",",t.y+t.height/2,")"].join("");n!==this.elem.getAttribute("transform")&&this.elem.setAttribute("transform",n)}}})}unapply(e){super.unapply(e,()=>{let e=!1;if(Object.entries(this.oldValues).forEach(([t,n])=>{n?"#text"===t?this.elem.textContent=n:"#href"===t?Ae(this.elem,n):this.elem.setAttribute(t,n):"#text"===t?this.elem.textContent="":this.elem.removeAttribute(t),"transform"===t&&(e=!0)}),!e){const e=Fe(this.elem);if(e){const t=this.elem.getBBox(),n=["rotate(",e," ",t.x+t.width/2,",",t.y+t.height/2,")"].join("");n!==this.elem.getAttribute("transform")&&this.elem.setAttribute("transform",n)}}M(this.elem)})}}class gt extends ct{constructor(e){super(),this.text=e||"Batch Command",this.stack=[]}apply(e){super.apply(e,()=>{this.stack.forEach(t=>{console.assert(t,"stack item should not be null"),t&&t.apply(e)})})}unapply(e){super.unapply(e,()=>{this.stack.forEach(t=>{console.assert(t,"stack item should not be null"),t&&t.unapply(e)})})}elements(){const e=[];let t=this.stack.length;for(;t--;){if(!this.stack[t])continue;const n=this.stack[t].elements();let i=n.length;for(;i--;)e.includes(n[i])||e.push(n[i])}return e}addSubCommand(e){console.assert(null!==e,"cmd should not be null"),this.stack.push(e)}isEmpty(){return!this.stack.length}}var ft=Object.freeze({__proto__:null,HistoryEventTypes:lt,MoveElementCommand:ut,InsertElementCommand:dt,RemoveElementCommand:ht,ChangeElementCommand:pt,BatchCommand:gt,UndoManager:class{constructor(e){this.handler_=e||null,this.undoStackPointer=0,this.undoStack=[],this.undoChangeStackPointer=-1,this.undoableChangeStack=[]}resetUndoStack(){this.undoStack=[],this.undoStackPointer=0}getUndoStackSize(){return this.undoStackPointer}getRedoStackSize(){return this.undoStack.length-this.undoStackPointer}getNextUndoCommandText(){return this.undoStackPointer>0?this.undoStack[this.undoStackPointer-1].getText():""}getNextRedoCommandText(){return this.undoStackPointer<this.undoStack.length?this.undoStack[this.undoStackPointer].getText():""}undo(){if(this.undoStackPointer>0){this.undoStack[--this.undoStackPointer].unapply(this.handler_)}}redo(){if(this.undoStackPointer<this.undoStack.length&&this.undoStack.length>0){this.undoStack[this.undoStackPointer++].apply(this.handler_)}}addCommandToHistory(e){this.undoStackPointer<this.undoStack.length&&this.undoStack.length>0&&(this.undoStack=this.undoStack.splice(0,this.undoStackPointer)),this.undoStack.push(e),this.undoStackPointer=this.undoStack.length}beginUndoableChange(e,t){const n=++this.undoChangeStackPointer;let i=t.length;const s=new Array(i),o=new Array(i);for(;i--;){const n=t[i];Qe(n)||(o[i]=n,s[i]=n.getAttribute(e))}this.undoableChangeStack[n]={attrName:e,oldValues:s,elements:o}}finishUndoableChange(){const e=this.undoChangeStackPointer--,t=this.undoableChangeStack[e],{attrName:n}=t,i=new gt("Change "+n);let s=t.elements.length;for(;s--;){const e=t.elements[s];if(Qe(e))continue;const o={};o[n]=t.oldValues[s],o[n]!==e.getAttribute(n)&&i.addSubCommand(new pt(e,o,n))}return this.undoableChangeStack[e]=null,i}}});const mt=jQuery,_t={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"]},yt={},bt=function(e){Object.assign(yt,e.ui)};let vt=[],xt=!0,wt={};const St=function(e){xt=e};let kt=null,Ct=null;const At=function(e){Ct=e,vt=[0,"ClosePath"];mt.each(["Moveto","Lineto","CurvetoCubic","CurvetoQuadratic","Arc","LinetoHorizontal","LinetoVertical","CurvetoCubicSmooth","CurvetoQuadraticSmooth"],(function(e,t){vt.push(t+"Abs"),vt.push(t+"Rel")}))},Et=function(e,t,n){const i=e.pathSegList;if(m)return void i.insertItemBefore(t,n);const s=i.numberOfItems,o=[];for(let e=0;e<s;e++){const t=i.getItem(e);o.push(t)}i.clear();for(let e=0;e<s;e++)e===n&&i.appendItem(t),i.appendItem(o[e])},Gt=function(e,t){return _t[e].map(e=>t[e])},Pt=function(e,t){const{path:n}=e;let i={x:t?t.x:e.item.x,y:t?t.y:e.item.y};if(n.matrix){i=$(i.x,i.y,n.matrix)}const s=Ct.getCurrentZoom();return i.x*=s,i.y*=s,i},Nt=function(e,t){const n={x:e.x,y:e.y};t.matrix&&(e=$(n.x,n.y,t.imatrix),n.x=e.x,n.y=e.y);const i=Ct.getCurrentZoom();return n.x/=i,n.y/=i,n},It=function(e,n,i){const s=Tt();let o=He("pathpointgrip_"+e);if(!o){o=document.createElementNS(t.SVG,"circle");const n={id:"pathpointgrip_"+e,display:"none",r:4,fill:"#0FF",stroke:"#00F","stroke-width":2,cursor:"move",style:"pointer-events:all"};"pathNodeTooltip"in yt&&(n["xlink:title"]=yt.pathNodeTooltip),qe(o,n),o=s.appendChild(o);mt("#pathpointgrip_"+e).dblclick((function(){kt&&kt.setSegType()}))}return n&&i&&qe(o,{cx:n,cy:i,display:"inline"}),o},Tt=function(){let e=He("pathpointgrip_container");if(!e){e=He("selectorParentGroup").appendChild(document.createElementNS(t.SVG,"g")),e.id="pathpointgrip_container"}return e},Lt=function(e){let n=He("ctrlpointgrip_"+e);if(n)return n;n=document.createElementNS(t.SVG,"circle");const i={id:"ctrlpointgrip_"+e,display:"none",r:4,fill:"#0FF",stroke:"#55F","stroke-width":1,cursor:"move",style:"pointer-events:all"};return"pathCtrlPtTooltip"in yt&&(i["xlink:title"]=yt.pathCtrlPtTooltip),qe(n,i),Tt().append(n),n},Mt=function(e){let n=He("ctrlLine_"+e);return n||(n=document.createElementNS(t.SVG,"line"),qe(n,{id:"ctrlLine_"+e,stroke:"#555","stroke-width":1,style:"pointer-events:none"}),Tt().append(n),n)},Ot=function(e,t){const{index:n}=e,i=It(n);if(t){const t=Pt(e);qe(i,{cx:t.x,cy:t.y,display:"inline"})}return i},jt=function(e){const{item:t,index:n}=e;if(!("x1"in t)||!("x2"in t))return null;const i={};Tt();const s=[kt.segs[n-1].item,t];for(let o=1;o<3;o++){const r=n+"c"+o,a=i["c"+o+"_line"]=Mt(r),l=Pt(e,{x:t["x"+o],y:t["y"+o]}),c=Pt(e,{x:s[o-1].x,y:s[o-1].y});qe(a,{x1:l.x,y1:l.y,x2:c.x,y2:c.y,display:"inline"}),i["c"+o+"_line"]=a;const u=i["c"+o]=Lt(r);qe(u,{cx:l.x,cy:l.y,display:"inline"}),i["c"+o]=u}return i},Vt=function(e,t,n,i){const s=i||kt.elem,o=s["createSVGPathSeg"+vt[e]](...n);if(f)s.pathSegList.replaceItem(o,t);else{const e=s.pathSegList,n=e.numberOfItems,i=[];for(let t=0;t<n;t++){const n=e.getItem(t);i.push(n)}e.clear();for(let s=0;s<n;s++)s===t?e.appendItem(o):e.appendItem(i[s])}},Rt=function(e,n){const{index:i}=e;let s=He("segline_"+i);if(!s){const e=Tt();s=document.createElementNS(t.SVG,"path"),qe(s,{id:"segline_"+i,display:"none",fill:"none",stroke:"#0FF","stroke-width":2,style:"pointer-events:none",d:"M0,0 0,0"}),e.append(s)}if(n){const{prev:t}=e;if(!t)return s.setAttribute("display","none"),s;const n=Pt(t);Vt(2,0,[n.x,n.y],s);const i=Gt(e.type,e.item);for(let t=0;t<i.length;t+=2){const n=Pt(e,{x:i[t],y:i[t+1]});i[t]=n.x,i[t+1]=n.y}Vt(e.type,1,i,s)}return s},Bt=function(e,t,n){const i=e.x-n.x,s=e.y-n.y,o=t.x-n.x,r=t.y-n.y;if(!(0===i&&0===s||0===o&&0===r)){const e=Math.sqrt(i*i+s*s),t=Math.sqrt(o*o+r*r),a=Ct.getSVGRoot().createSVGPoint(),l=Ct.getSVGRoot().createSVGPoint();let c=Math.atan2(s,i),u=Math.atan2(r,o);c<0&&(c+=2*Math.PI),u<0&&(u+=2*Math.PI);const d=Math.abs(c-u),h=Math.abs(Math.PI-d)/2;let p,g;return c-u>0?(p=d<Math.PI?c+h:c-h,g=d<Math.PI?u-h:u+h):(p=d<Math.PI?c-h:c+h,g=d<Math.PI?u+h:u-h),a.x=e*Math.cos(p)+n.x,a.y=e*Math.sin(p)+n.y,l.x=t*Math.cos(g)+n.x,l.y=t*Math.sin(g)+n.y,[a,l]}};class Ut{constructor(e,t){this.selected=!1,this.index=e,this.item=t,this.type=t.pathSegType,this.ctrlpts=[],this.ptgrip=null,this.segsel=null}showCtrlPts(e){for(const t in this.ctrlpts)({}).hasOwnProperty.call(this.ctrlpts,t)&&this.ctrlpts[t].setAttribute("display",e?"inline":"none")}selectCtrls(e){mt("#ctrlpointgrip_"+this.index+"c1, #ctrlpointgrip_"+this.index+"c2").attr("fill",e?"#0FF":"#EEE")}show(e){this.ptgrip&&(this.ptgrip.setAttribute("display",e?"inline":"none"),this.segsel.setAttribute("display",e?"inline":"none"),this.showCtrlPts(e))}select(e){this.ptgrip&&(this.ptgrip.setAttribute("stroke",e?"#0FF":"#00F"),this.segsel.setAttribute("display",e?"inline":"none"),this.ctrlpts&&this.selectCtrls(e),this.selected=e)}addGrip(){this.ptgrip=Ot(this,!0),this.ctrlpts=jt(this),this.segsel=Rt(this,!0)}update(e){if(this.ptgrip){const t=Pt(this);qe(this.ptgrip,{cx:t.x,cy:t.y}),Rt(this,!0),this.ctrlpts&&(e&&(this.item=kt.elem.pathSegList.getItem(this.index),this.type=this.item.pathSegType),jt(this))}}move(e,t){const{item:n}=this,i=this.ctrlpts?[n.x+=e,n.y+=t,n.x1,n.y1,n.x2+=e,n.y2+=t]:[n.x+=e,n.y+=t];if(Vt(this.type,this.index,10===this.type?Gt(this.type,n):i),this.next&&this.next.ctrlpts){const n=this.next.item,i=[n.x,n.y,n.x1+=e,n.y1+=t,n.x2,n.y2];Vt(this.next.type,this.next.index,i)}if(this.mate){const{item:n}=this.mate,i=[n.x+=e,n.y+=t];Vt(this.mate.type,this.mate.index,i)}this.update(!0),this.next&&this.next.update(!0)}setLinked(e){let t,n,i;if(2===e){if(n=1,t=this.next,!t)return;i=this.item}else{if(n=2,t=this.prev,!t)return;i=t.item}const{item:s}=t;s["x"+n]=i.x+(i.x-this.item["x"+e]),s["y"+n]=i.y+(i.y-this.item["y"+e]);const o=[s.x,s.y,s.x1,s.y1,s.x2,s.y2];Vt(t.type,t.index,o),t.update(!0)}moveCtrl(e,t,n){const{item:i}=this;i["x"+e]+=t,i["y"+e]+=n;const s=[i.x,i.y,i.x1,i.y1,i.x2,i.y2];Vt(this.type,this.index,s),this.update(!0)}setType(e,t){Vt(e,this.index,t),this.type=e,this.item=kt.elem.pathSegList.getItem(this.index),this.showCtrlPts(6===e),this.ctrlpts=jt(this),this.update(!0)}}class Dt{constructor(e){if(!e||"path"!==e.tagName)throw new Error("svgedit.path.Path constructed without a <path> element");this.elem=e,this.segs=[],this.selected_pts=[],kt=this,this.init()}init(){mt(Tt()).find("*").each((function(){mt(this).attr("display","none")}));const e=this.elem.pathSegList,t=e.numberOfItems;this.segs=[],this.selected_pts=[],this.first_seg=null;for(let n=0;n<t;n++){const t=e.getItem(n),i=new Ut(n,t);i.path=this,this.segs.push(i)}const{segs:n}=this;let i=null;for(let e=0;e<t;e++){const s=n[e],o=e+1>=t?null:n[e+1],r=e-1<0?null:n[e-1];if(2===s.type){if(r&&1!==r.type){const e=n[i];e.next=n[i+1],e.next.prev=e,e.addGrip()}i=e}else if(o&&1===o.type)s.next=n[i+1],s.next.prev=s,s.mate=n[i],s.addGrip(),Qe(this.first_seg)&&(this.first_seg=s);else if(o)1!==s.type&&(s.addGrip(),o&&2!==o.type&&(s.next=o,s.next.prev=s));else if(1!==s.type){const e=n[i];e.next=n[i+1],e.next.prev=e,e.addGrip(),s.addGrip(),this.first_seg||(this.first_seg=n[i])}}return this}eachSeg(e){const t=this.segs.length;for(let n=0;n<t;n++){if(!1===e.call(this.segs[n],n))break}}addSeg(e){const t=this.segs[e];if(!t.prev)return;const{prev:n}=t;let i,s,o;switch(t.item.pathSegType){case 4:s=(t.item.x+n.item.x)/2,o=(t.item.y+n.item.y)/2,i=this.elem.createSVGPathSegLinetoAbs(s,o);break;case 6:{const r=(n.item.x+t.item.x1)/2,a=(t.item.x1+t.item.x2)/2,l=(t.item.x2+t.item.x)/2,c=(r+a)/2,u=(a+l)/2;s=(c+u)/2;const d=(n.item.y+t.item.y1)/2,h=(t.item.y1+t.item.y2)/2,p=(t.item.y2+t.item.y)/2,g=(d+h)/2,f=(h+p)/2;o=(g+f)/2,i=this.elem.createSVGPathSegCurvetoCubicAbs(s,o,r,d,c,g);const m=[t.item.x,t.item.y,u,f,l,p];Vt(t.type,e,m);break}}Et(this.elem,i,e)}deleteSeg(e){const t=this.segs[e],n=this.elem.pathSegList;t.show(!1);const{next:i}=t;if(t.mate){const e=[i.item.x,i.item.y];Vt(2,i.index,e),Vt(4,t.index,e),n.removeItem(t.mate.index)}else if(t.prev)n.removeItem(e);else{const s=[i.item.x,i.item.y];Vt(2,t.next.index,s),n.removeItem(e)}}removePtFromSelection(e){const t=this.selected_pts.indexOf(e);-1!==t&&(this.segs[e].select(!1),this.selected_pts.splice(t,1))}clearSelection(){this.eachSeg((function(){this.select(!1)})),this.selected_pts=[]}storeD(){this.last_d=this.elem.getAttribute("d")}show(e){return this.eachSeg((function(){this.show(e)})),e&&this.selectPt(this.first_seg.index),this}movePts(e,t){let n=this.selected_pts.length;for(;n--;){this.segs[this.selected_pts[n]].move(e,t)}}moveCtrl(e,t){const n=this.segs[this.selected_pts[0]];n.moveCtrl(this.dragctrl,e,t),xt&&n.setLinked(this.dragctrl)}setSegType(e){this.storeD();let t,n=this.selected_pts.length;for(;n--;){const i=this.selected_pts[n],s=this.segs[i],{prev:o}=s;if(!o)continue;if(!e){t="Toggle Path Segment Type";e=6===s.type?4:6}e=Number(e);const r=s.item.x,a=s.item.y,l=o.item.x,c=o.item.y;let u;switch(e){case 6:if(s.olditem){const e=s.olditem;u=[r,a,e.x1,e.y1,e.x2,e.y2]}else{const e=r-l,t=a-c;u=[r,a,l+e/3,c+t/3,r-e/3,a-t/3]}break;case 4:u=[r,a],s.olditem=s.item}s.setType(e,u)}kt.endChanges(t)}selectPt(e,t){this.clearSelection(),Qe(e)&&this.eachSeg((function(t){this.prev&&(e=t)})),this.addPtsToSelection(e),t&&(this.dragctrl=t,xt&&this.segs[e].setLinked(t))}update(){const{elem:e}=this;return Fe(e)?(this.matrix=ee(e),this.imatrix=this.matrix.inverse()):(this.matrix=null,this.imatrix=null),this.eachSeg((function(t){this.item=e.pathSegList.getItem(t),this.update()})),this}endChanges(e){w()&&Ct.resetD(this.elem);const t=new pt(this.elem,{d:this.last_d},e);Ct.endChanges({cmd:t,elem:this.elem})}addPtsToSelection(e){Array.isArray(e)||(e=[e]),e.forEach(e=>{this.segs[e].ptgrip&&!this.selected_pts.includes(e)&&e>=0&&this.selected_pts.push(e)}),this.selected_pts.sort();let t=this.selected_pts.length;const n=[];for(n.length=t;t--;){const e=this.selected_pts[t],i=this.segs[e];i.select(!0),n[t]=i.ptgrip}const i=Dt.subpathIsClosed(this.selected_pts[0]);Ct.addPtsToSelection({grips:n,closedSubpath:i})}static subpathIsClosed(e){let t=!1;return kt.eachSeg((function(n){return n<=e||2!==this.type&&(1!==this.type||(t=!0,!1))})),t}}const Ft=function(e){let t=wt[e.id];return t||(t=wt[e.id]=new Dt(e)),t},zt=function(e){e in wt&&delete wt[e]};let Ht,qt,Xt,Wt,$t;const Yt=function(e,t){let n=e-Xt,i=t-Wt,s=Math.sqrt(n*n+i*i),o=Math.atan2(i,n)+$t;return n=s*Math.cos(o)+Xt,i=s*Math.sin(o)+Wt,n-=Ht,i-=qt,s=Math.sqrt(n*n+i*i),o=Math.atan2(i,n)-$t,{x:s*Math.cos(o)+Ht,y:s*Math.sin(o)+qt}},Qt=function(){const e=kt.elem;if($t=Fe(e,!0),!$t)return;const t=kt.oldbbox;Xt=t.x+t.width/2,Wt=t.y+t.height/2;const n=Ne(e);Ht=n.x+n.width/2,qt=n.y+n.height/2;const i=Ht-Xt,s=qt-Wt,o=Math.sqrt(i*i+s*s),r=Math.atan2(s,i)+$t;Ht=o*Math.cos(r)+Xt,qt=o*Math.sin(r)+Wt;const a=e.pathSegList;let l=a.numberOfItems;for(;l;){l-=1;const e=a.getItem(l),t=e.pathSegType;if(1===t)continue;const n=Yt(e.x,e.y),i=[n.x,n.y];if(!Qe(e.x1)&&!Qe(e.x2)){const t=Yt(e.x1,e.y1),n=Yt(e.x2,e.y2);i.splice(i.length,0,t.x,t.y,n.x,n.y)}Vt(t,l,i)}Ne(e);const c=Ct.getSVGRoot().createSVGTransform(),u=O(e);c.setRotate(180*$t/Math.PI,Ht,qt),u.replaceItem(c,0)},Kt=function(){wt={}},Zt=function(e,t){const n=Ne(e);for(let i=0;i<2;i++){const s=0===i?"fill":"stroke",o=e.getAttribute(s);if(o&&o.startsWith("url(")){const i=ze(o);if("linearGradient"===i.tagName){let o=i.getAttribute("x1")||0,r=i.getAttribute("y1")||0,a=i.getAttribute("x2")||1,l=i.getAttribute("y2")||0;o=n.width*o+n.x,r=n.height*r+n.y,a=n.width*a+n.x,l=n.height*l+n.y;const c=$(o,r,t),u=$(a,l,t),d={x1:(c.x-n.x)/n.width,y1:(c.y-n.y)/n.height,x2:(u.x-n.x)/n.width,y2:(u.y-n.y)/n.height},h=i.cloneNode(!0);mt(h).attr(d),h.id=Ct.getNextId(),Ee().append(h),e.setAttribute(s,"url(#"+h.id+")")}}}},Jt=[0,"z","M","m","L","l","C","c","Q","q","A","a","H","h","V","v","S","s","T","t"],en=function(e,t){const{pathSegList:n}=e,i=n.numberOfItems;let s=0,o=0,r="",a=null;for(let e=0;e<i;++e){const i=n.getItem(e);let l=i.x||0,c=i.y||0,u=i.x1||0,d=i.y1||0,h=i.x2||0,p=i.y2||0;const g=i.pathSegType;let f=Jt[g][t?"toLowerCase":"toUpperCase"]();switch(g){case 1:r+="z",a&&!t&&(s=a[0],o=a[1]);break;case 12:l-=s;case 13:t?(c=0,s+=l,f="l"):(c=o,l+=s,s=l,f="L"),r+=tn(f,[[l,c]]);break;case 14:c-=o;case 15:t?(l=0,o+=c,f="l"):(l=s,c+=o,o=c,f="L"),r+=tn(f,[[l,c]]);break;case 2:case 4:case 18:l-=s,c-=o;case 5:case 3:case 19:t?(s+=l,o+=c):(l+=s,c+=o,s=l,o=c),2!==g&&3!==g||(a=[s,o]),r+=tn(f,[[l,c]]);break;case 6:l-=s,u-=s,h-=s,c-=o,d-=o,p-=o;case 7:t?(s+=l,o+=c):(l+=s,u+=s,h+=s,c+=o,d+=o,p+=o,s=l,o=c),r+=tn(f,[[u,d],[h,p],[l,c]]);break;case 8:l-=s,u-=s,c-=o,d-=o;case 9:t?(s+=l,o+=c):(l+=s,u+=s,c+=o,d+=o,s=l,o=c),r+=tn(f,[[u,d],[l,c]]);break;case 10:l-=s,c-=o;case 11:t?(s+=l,o+=c):(l+=s,c+=o,s=l,o=c),r+=tn(f,[[i.r1,i.r2]],[i.angle,i.largeArcFlag?1:0,i.sweepFlag?1:0],[l,c]);break;case 16:l-=s,h-=s,c-=o,p-=o;case 17:t?(s+=l,o+=c):(l+=s,h+=s,c+=o,p+=o,s=l,o=c),r+=tn(f,[[h,p],[l,c]])}}return r};function tn(e,t,n,i){mt.each(t,(function(e,n){t[e]=F(n)}));let s=e+t.join(" ");return n&&(s+=" "+n.join(" ")),i&&(s+=" "+F(i)),s}const nn=function(){let e,n,i=!1,s=null,o=!1;return{mouseDown(n,s,o,r){let a,l;if("path"!==Ct.getCurrentMode()){if(kt){if(kt.storeD(),({id:a}=n.target),"pathpointgrip_"===a.substr(0,14)){l=kt.cur_pt=Number.parseInt(a.substr(14)),kt.dragging=[o,r];const e=kt.segs[l];n.shiftKey?e.selected?kt.removePtFromSelection(l):kt.addPtsToSelection(l):((kt.selected_pts.length<=1||!e.selected)&&kt.clearSelection(),kt.addPtsToSelection(l))}else if(a.startsWith("ctrlpointgrip_")){kt.dragging=[o,r];const e=a.split("_")[1].split("c");l=Number(e[0]);const t=Number(e[1]);kt.selectPt(l,t)}if(!kt.dragging){let e=Ct.getRubberBox();Qe(e)&&(e=Ct.setRubberBox(Ct.selectorManager.getRubberBandBox()));const t=Ct.getCurrentZoom();qe(e,{x:o*t,y:r*t,width:0,height:0,display:"inline"})}}}else{let s=o,l=r;const c=Ct.getCurrentZoom();let u=s/c,d=l/c,h=He("path_stretch_line");e=[u,d],Ct.getGridSnapping()&&(u=We(u),d=We(d),s=We(s),l=We(l)),h||(h=document.createElementNS(t.SVG,"path"),qe(h,{id:"path_stretch_line",stroke:"#22C","stroke-width":"0.5",fill:"none"}),h=He("selectorParentGroup").appendChild(h)),h.setAttribute("display","inline");let p,g=null;const f=Ct.getDrawnPath();if(f){const e=f.pathSegList;let t=e.numberOfItems;const s=6/c;let o=!1;for(;t;){t--;const n=e.getItem(t),i=n.x,r=n.y;if(u>=i-s&&u<=i+s&&d>=r-s&&d<=r+s){o=!0;break}}a=Ct.getId(),zt(a);const r=He(a);let l,m;const _=e.numberOfItems;if(o){if(t<=1&&_>=2){const t=e.getItem(0).x,n=e.getItem(0).y;m=h.pathSegList.getItem(1),l=4===m.pathSegType?f.createSVGPathSegLinetoAbs(t,n):f.createSVGPathSegCurvetoCubicAbs(t,n,m.x1/c,m.y1/c,t,n);const i=f.createSVGPathSegClosePath();e.appendItem(l),e.appendItem(i)}else if(_<3)return g=!1,g;if(mt(h).remove(),Ct.setDrawnPath(null),Ct.setStarted(!1),i){kt.matrix&&Ct.remapElement(r,{},kt.matrix.inverse());const e=r.getAttribute("d"),t=mt(kt.elem).attr("d");return mt(kt.elem).attr("d",t+e),mt(r).remove(),kt.matrix&&Qt(),At(),nn.toEditMode(kt.elem),kt.selectPt(),!1}}else{if(!mt.contains(Ct.getContainer(),Ct.getMouseTarget(n)))return!1;const e=f.pathSegList.numberOfItems,t=f.pathSegList.getItem(e-1),s=t.x,o=t.y;if(n.shiftKey){const e=te(s,o,u,d);({x:u,y:d}=e)}m=h.pathSegList.getItem(1),l=4===m.pathSegType?f.createSVGPathSegLinetoAbs(Ct.round(u),Ct.round(d)):f.createSVGPathSegCurvetoCubicAbs(Ct.round(u),Ct.round(d),m.x1/c,m.y1/c,m.x2/c,m.y2/c),f.pathSegList.appendItem(l),u*=c,d*=c,h.setAttribute("d",["M",u,d,u,d].join(" ")),p=e,i&&(p+=kt.segs.length),It(p,u,d)}}else{const e="M"+u+","+d+" ";Ct.setDrawnPath(Ct.addSVGElementFromJson({element:"path",curStyles:!0,attr:{d:e,id:Ct.getNextId(),opacity:Ct.getOpacity()/2}})),h.setAttribute("d",["M",s,l,s,l].join(" ")),p=i?kt.segs.length:0,It(p,s,l)}}},mouseMove(t,i){const s=Ct.getCurrentZoom();o=!0;const r=Ct.getDrawnPath();if("path"!==Ct.getCurrentMode())if(kt.dragging){const e=Nt({x:kt.dragging[0],y:kt.dragging[1]},kt),n=Nt({x:t,y:i},kt),s=n.x-e.x,o=n.y-e.y;kt.dragging=[t,i],kt.dragctrl?kt.moveCtrl(s,o):kt.movePts(s,o)}else kt.selected_pts=[],kt.eachSeg((function(e){const t=this;if(!t.next&&!t.prev)return;const n=Ct.getRubberBox().getBBox(),i=Pt(t),s={x:i.x,y:i.y,width:0,height:0},o=ne(n,s);this.select(o),o&&kt.selected_pts.push(t.index)}));else{if(!r)return;const o=r.pathSegList,a=o.numberOfItems-1;if(e){const l=Lt("1c1"),c=Lt("0c2");l.setAttribute("cx",t),l.setAttribute("cy",i),l.setAttribute("display","inline");const u=e[0],d=e[1],h=u+(u-t/s),p=d+(d-i/s);c.setAttribute("cx",h*s),c.setAttribute("cy",p*s),c.setAttribute("display","inline");const g=Mt(1);if(qe(g,{x1:t,y1:i,x2:h*s,y2:p*s,display:"inline"}),0===a)n=[t,i];else{const e=o.getItem(a-1);let t=e.x,i=e.y;6===e.pathSegType?(t+=t-e.x2,i+=i-e.y2):n&&(t=n[0]/s,i=n[1]/s),Vt(6,a,[u,d,t,i,h,p],r)}}else{const e=He("path_stretch_line");if(e){const r=o.getItem(a);if(6===r.pathSegType){const n=r.x+(r.x-r.x2),o=r.y+(r.y-r.y2);Vt(6,1,[t,i,n*s,o*s,t,i],e)}else n?Vt(6,1,[t,i,n[0],n[1],t,i],e):Vt(4,1,[t,i],e)}}}},mouseUp(t,i,s,r){const a=Ct.getDrawnPath();if("path"===Ct.getCurrentMode())return e=null,a||(i=He(Ct.getId()),Ct.setStarted(!1),n=null),{keep:!0,element:i};const l=Ct.getRubberBox();if(kt.dragging){const e=kt.cur_pt;kt.dragging=!1,kt.dragctrl=!1,kt.update(),o&&kt.endChanges("Move path point(s)"),t.shiftKey||o||kt.selectPt(e)}else l&&"none"!==l.getAttribute("display")?(l.setAttribute("display","none"),l.getAttribute("width")<=2&&l.getAttribute("height")<=2&&nn.toSelectMode(t.target)):nn.toSelectMode(t.target);o=!1},toEditMode(e){kt=Ft(e),Ct.setCurrentMode("pathedit"),Ct.clearSelection(),kt.show(!0).update(),kt.oldbbox=Ne(kt.elem),i=!1},toSelectMode(e){const t=e===kt.elem;Ct.setCurrentMode("select"),kt.show(!1),s=!1,Ct.clearSelection(),kt.matrix&&Qt(),t&&(Ct.call("selected",[e]),Ct.addToSelection([e],!0))},addSubPath(e){e?(Ct.setCurrentMode("path"),i=!0):(nn.clear(!0),nn.toEditMode(kt.elem))},select(e){s===e?(nn.toEditMode(e),Ct.setCurrentMode("pathedit")):s=e},reorient(){const e=Ct.getSelectedElements()[0];if(!e)return;if(0===Fe(e))return;const t=new gt("Reorient path"),n={d:e.getAttribute("d"),transform:e.getAttribute("transform")};t.addSubCommand(new pt(e,n)),Ct.clearSelection(),this.resetOrientation(e),Ct.addCommandToHistory(t),Ft(e).show(!1).matrix=null,this.clear(),Ct.addToSelection([e],!0),Ct.call("changed",Ct.getSelectedElements())},clear(e){const t=Ct.getDrawnPath();if(s=null,t){const e=He(Ct.getId());mt(He("path_stretch_line")).remove(),mt(e).remove(),mt(He("pathpointgrip_container")).find("*").attr("display","none"),n=null,Ct.setDrawnPath(null),Ct.setStarted(!1)}else"pathedit"===Ct.getCurrentMode()&&this.toSelectMode();kt&&kt.init().show(!1)},resetOrientation(e){if(Qe(e)||"path"!==e.nodeName)return!1;const t=O(e),n=J(t).matrix;t.clear(),e.removeAttribute("transform");const i=e.pathSegList,s=i.numberOfItems;for(let t=0;t<s;++t){const s=i.getItem(t),o=s.pathSegType;if(1===o)continue;const r=[];mt.each(["",1,2],(function(e,t){const i=s["x"+t],o=s["y"+t];if(void 0!==i&&void 0!==o){const e=$(i,o,n);r.splice(r.length,0,e.x,e.y)}})),Vt(o,t,r,e)}Zt(e,n)},zoomChange(){"pathedit"===Ct.getCurrentMode()&&kt.update()},getNodePoint(){const e=kt.selected_pts.length?kt.selected_pts[0]:1,t=kt.segs[e];return{x:t.item.x,y:t.item.y,type:t.type}},linkControlPoints(e){St(e)},clonePathNode(){kt.storeD();const e=kt.selected_pts;let t=e.length;const n=[];for(;t--;){const i=e[t];kt.addSeg(i),n.push(i+t),n.push(i+t+1)}kt.init().addPtsToSelection(n),kt.endChanges("Clone path node(s)")},opencloseSubPath(){const e=kt.selected_pts;if(1!==e.length)return;const{elem:t}=kt,n=t.pathSegList,i=e[0];let s=null,o=null;if(kt.eachSeg((function(e){return 2===this.type&&e<=i&&(o=this.item),e<=i||(2===this.type?(s=e,!1):1!==this.type||(s=!1,!1))})),Qe(s)&&(s=kt.segs.length-1),!1!==s){const e=t.createSVGPathSegLinetoAbs(o.x,o.y),i=t.createSVGPathSegClosePath();return s===kt.segs.length-1?(n.appendItem(e),n.appendItem(i)):(Et(t,i,s),Et(t,e,s)),void kt.init().selectPt(s+1)}if(kt.segs[i].mate)return n.removeItem(i),n.removeItem(i),void kt.init().selectPt(i-1);let r,a;for(let e=0;e<n.numberOfItems;e++){const t=n.getItem(e);if(2===t.pathSegType)r=e;else if(e===i)n.removeItem(r);else if(1===t.pathSegType&&i<e){a=e-1,n.removeItem(e);break}}let l=i-r-1;for(;l--;)Et(t,n.getItem(r),a);const c=n.getItem(r);Vt(2,r,[c.x,c.y]),kt.init().selectPt(0)},deletePathNode(){if(!nn.canDeleteNodes)return;kt.storeD();const e=kt.selected_pts;let t=e.length;for(;t--;){const n=e[t];kt.deleteSeg(n)}const n=function(){const e=kt.elem.pathSegList;let t=e.numberOfItems;const i=function(t,n){for(;n--;)e.removeItem(t)};if(t<=1)return!0;for(;t--;){const s=e.getItem(t);if(1===s.pathSegType){const s=e.getItem(t-1),o=e.getItem(t-2);if(2===s.pathSegType){i(t-1,2),n();break}if(2===o.pathSegType){i(t-2,3),n();break}}else if(2===s.pathSegType&&t>0){const s=e.getItem(t-1).pathSegType;if(2===s){i(t-1,1),n();break}if(1===s&&e.numberOfItems-1===t){i(t,1),n();break}}}return!1};if(n(),kt.elem.pathSegList.numberOfItems<=1)return nn.toSelectMode(kt.elem),void Ct.canvas.deleteSelectedElements();if(kt.init(),kt.clearSelection(),window.opera){const e=mt(kt.elem);e.attr("d",e.attr("d"))}kt.endChanges("Delete path node(s)")},smoothPolylineIntoPath:function(e){let t;const{points:n}=e,i=n.numberOfItems;if(i>=4){let s=n.getItem(0),o=null,r=[];for(r.push(["M",s.x,",",s.y," C"].join("")),t=1;t<=i-4;t+=3){let e=n.getItem(t);const i=n.getItem(t+1),a=n.getItem(t+2);if(o){const t=Bt(o,e,s);if(t&&2===t.length){const n=r[r.length-1].split(",");n[2]=t[0].x,n[3]=t[0].y,r[r.length-1]=n.join(","),e=t[1]}}r.push([e.x,e.y,i.x,i.y,a.x,a.y].join(",")),s=a,o=i}for(r.push("L");t<i;){const e=n.getItem(t);r.push([e.x,e.y].join(",")),t++}r=r.join(" "),e=Ct.addSVGElementFromJson({element:"path",curStyles:!0,attr:{id:Ct.getId(),d:r,fill:"none"}})}return e},setSegType(e){kt.setSegType(e)},moveNode(e,t){const n=kt.selected_pts;if(!n.length)return;kt.storeD();const i=kt.segs[n[0]],s={x:0,y:0};s[e]=t-i.item[e],i.move(s.x,s.y),kt.endChanges("Move path point")},fixEnd(e){const t=e.pathSegList,n=t.numberOfItems;let i;for(let s=0;s<n;++s){const n=t.getItem(s);if(2===n.pathSegType&&(i=n),1===n.pathSegType){const n=t.getItem(s-1);if(n.x!==i.x||n.y!==i.y){const t=e.createSVGPathSegLinetoAbs(i.x,i.y);Et(e,t,s),nn.fixEnd(e);break}}}w()&&Ct.resetD(e)},convertPath:en}}();var sn=Object.freeze({__proto__:null,setUiStrings:bt,setLinkControlPoints:St,get path(){return kt},init:At,insertItemBefore:Et,ptObjToArr:Gt,getGripPt:Pt,getPointFromGrip:Nt,addPointGrip:It,getGripContainer:Tt,addCtrlGrip:Lt,getCtrlLine:Mt,getPointGrip:Ot,getControlPoints:jt,replacePathSeg:Vt,getSegSelector:Rt,smoothControlPoints:Bt,Segment:Ut,Path:Dt,getPath_:Ft,removePath_:zt,recalcRotatedPath:Qt,clearData:Kt,reorientGrads:Zt,convertPath:en,pathActions:nn});const on=jQuery;class rn{constructor(e,n,i){if(this.name_=e,this.group_=i?null:n,i){const s=i.ownerDocument;this.group_=s.createElementNS(t.SVG,"g");const o=s.createElementNS(t.SVG,"title");o.textContent=e,this.group_.append(o),n?on(n).after(this.group_):i.append(this.group_)}!function(e){const t=e.getAttribute("class");Qe(t)||!t.length?e.setAttribute("class",rn.CLASS_NAME):rn.CLASS_REGEX.test(t)||e.setAttribute("class",t+" "+rn.CLASS_NAME)}
/**
* HistoryRecordingService component of history.
* @module history
* @license MIT
* @copyright 2016 Flint O'Brien
*/(this.group_),we(this.group_,(function(e){e.setAttribute("style","pointer-events:inherit")})),this.group_.setAttribute("style",i?"pointer-events:all":"pointer-events:none")}getName(){return this.name_}getGroup(){return this.group_}activate(){this.group_.setAttribute("style","pointer-events:all")}deactivate(){this.group_.setAttribute("style","pointer-events:none")}setVisible(e){const t=void 0===e||e?"inline":"none";this.group_.getAttribute("display")!==t&&this.group_.setAttribute("display",t)}isVisible(){return"none"!==this.group_.getAttribute("display")}getOpacity(){const e=this.group_.getAttribute("opacity");return Qe(e)?1:Number.parseFloat(e)}setOpacity(e){"number"==typeof e&&e>=0&&e<=1&&this.group_.setAttribute("opacity",e)}appendChildren(e){for(const t of e)this.group_.append(t)}getTitleElement(){const e=this.group_.childNodes.length;for(let t=0;t<e;++t){const e=this.group_.childNodes.item(t);if(e&&"title"===e.tagName)return e}return null}setName(e,t){const n=this.name_;e=he(e);const i=this.getTitleElement();return i?(on(i).empty(),i.textContent=e,this.name_=e,t&&t.changeElement(i,{"#text":n}),this.name_):null}removeGroup(){const e=this.group_;return this.group_.remove(),this.group_=void 0,e}}rn.CLASS_NAME="layer",rn.CLASS_REGEX=new RegExp("(\\s|^)"+rn.CLASS_NAME+"(\\s|$)");class an{constructor(e){this.undoManager_=e,this.currentBatchCommand_=null,this.batchCommandStack_=[]}startBatchCommand(e){return this.undoManager_?(this.currentBatchCommand_=new gt(e),this.batchCommandStack_.push(this.currentBatchCommand_),this):this}endBatchCommand(){if(!this.undoManager_)return this;if(this.currentBatchCommand_){const e=this.currentBatchCommand_;this.batchCommandStack_.pop();const{length:t}=this.batchCommandStack_;this.currentBatchCommand_=t?this.batchCommandStack_[t-1]:null,this.addCommand_(e)}return this}moveElement(e,t,n,i){return this.undoManager_?(this.addCommand_(new ut(e,t,n,i)),this):this}insertElement(e,t){return this.undoManager_?(this.addCommand_(new dt(e,t)),this):this}removeElement(e,t,n,i){return this.undoManager_?(this.addCommand_(new ht(e,t,n,i)),this):this}changeElement(e,t,n){return this.undoManager_?(this.addCommand_(new pt(e,t,n)),this):this}addCommand_(e){if(!this.undoManager_)return this;this.currentBatchCommand_?this.currentBatchCommand_.addSubCommand(e):this.undoManager_.addCommandToHistory(e)}}an.NO_HISTORY=new an;const ln=P(jQuery),cn=function(e,t){const n=document.createElementNS(e.namespaceURI,e.nodeName);if(ln.each(e.attributes,(function(e,t){"-moz-math-font-style"!==t.localName&&n.setAttributeNS(t.namespaceURI,t.nodeName,t.value)})),n.removeAttribute("id"),n.id=t(),w()&&"path"===e.nodeName){const t=en(e);n.setAttribute("d",t)}if(ln.each(e.childNodes,(function(e,i){switch(i.nodeType){case 1:n.append(cn(i,t));break;case 3:n.textContent=i.nodeValue}})),ln(e).data("gsvg"))ln(n).data("gsvg",n.firstChild);else if(ln(e).data("symbol")){const t=ln(e).data("symbol");ln(n).data("ref",t).data("symbol",t)}else"image"===n.tagName&&Ye(n);return n},un=jQuery,dn="a,circle,ellipse,foreignObject,g,image,line,path,polygon,polyline,rect,svg,text,tspan,use".split(","),hn=1,pn=2;let gn=0,fn=[];function mn(e){return e||new an(xn.undoMgr)}function _n(e){return un("title",e).text()||(r&&e.querySelectorAll?un(e.querySelectorAll("title")).text():"")}function yn(e){let t=1;for(;e.includes("Layer "+t);)t++;return"Layer "+t}class bn{constructor(e,n){if(!e||!e.tagName||!e.namespaceURI||"svg"!==e.tagName||e.namespaceURI!==t.SVG)throw new Error("Error: svgedit.draw.Drawing instance initialized without a <svg> element");this.svgElem_=e,this.obj_num=0,this.idPrefix=n||"svg_",this.releasedNums=[],this.all_layers=[],this.layer_map={},this.current_layer=null,this.nonce_="";const i=this.svgElem_.getAttributeNS(t.SE,"nonce");i&&gn!==pn?this.nonce_=i:gn===hn&&this.setNonce(Math.floor(100001*Math.random()))}getElem_(e){return this.svgElem_.querySelector?this.svgElem_.querySelector("#"+e):un(this.svgElem_).find("[id="+e+"]")[0]}getSvgElem(){return this.svgElem_}getNonce(){return this.nonce_}setNonce(e){this.svgElem_.setAttributeNS(t.XMLNS,"xmlns:se",t.SE),this.svgElem_.setAttributeNS(t.SE,"se:nonce",e),this.nonce_=e}clearNonce(){this.nonce_=""}getId(){return this.nonce_?this.idPrefix+this.nonce_+"_"+this.obj_num:this.idPrefix+this.obj_num}getNextId(){const e=this.obj_num;let t=!1;this.releasedNums.length>0?(this.obj_num=this.releasedNums.pop(),t=!0):this.obj_num++;let n=this.getId();for(;this.getElem_(n);)t&&(this.obj_num=e,t=!1),this.obj_num++,n=this.getId();return t&&(this.obj_num=e),n}releaseId(e){const t=this.idPrefix+(this.nonce_?this.nonce_+"_":"");if("string"!=typeof e||!e.startsWith(t))return!1;const n=Number.parseInt(e.substr(t.length));return!("number"!=typeof n||n<=0||this.releasedNums.includes(n))&&(this.releasedNums.push(n),!0)}getNumLayers(){return this.all_layers.length}hasLayer(e){return void 0!==this.layer_map[e]}getLayerName(e){return e>=0&&e<this.getNumLayers()?this.all_layers[e].getName():""}getCurrentLayer(){return this.current_layer?this.current_layer.getGroup():null}getLayerByName(e){const t=this.layer_map[e];return t?t.getGroup():null}getCurrentLayerName(){return this.current_layer?this.current_layer.getName():""}setCurrentLayerName(e,t){let n=null;if(this.current_layer){const i=this.current_layer.getName();n=this.current_layer.setName(e,t),n&&(delete this.layer_map[i],this.layer_map[n]=this.current_layer)}return n}setCurrentLayerPosition(e){const t=this.getNumLayers();if(!this.current_layer||e<0||e>=t)return null;let n;for(n=0;n<t&&this.all_layers[n]!==this.current_layer;++n);if(n===t)return null;if(n!==e){const i=this.current_layer.getGroup(),s=i.nextSibling;let o=null;return e>n?e<t-1&&(o=this.all_layers[e+1].getGroup()):o=this.all_layers[e].getGroup(),this.svgElem_.insertBefore(i,o),this.identifyLayers(),this.setCurrentLayer(this.getLayerName(e)),{currentGroup:i,oldNextSibling:s}}return null}mergeLayer(e){const t=this.current_layer.getGroup(),n=un(t).prev()[0];if(!n)return;e.startBatchCommand("Merge Layer");const i=t.nextSibling;for(e.removeElement(t,i,this.svgElem_);t.firstChild;){const i=t.firstChild;if("title"===i.localName){e.removeElement(i,i.nextSibling,t),i.remove();continue}const s=i.nextSibling;n.append(i),e.moveElement(i,s,t)}this.current_layer.removeGroup();const s=this.all_layers.indexOf(this.current_layer);if(s>0){const e=this.current_layer.getName();this.current_layer=this.all_layers[s-1],this.all_layers.splice(s,1),delete this.layer_map[e]}e.endBatchCommand()}mergeAllLayers(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()}setCurrentLayer(e){const t=this.layer_map[e];return!!t&&(this.current_layer&&this.current_layer.deactivate(),this.current_layer=t,this.current_layer.activate(),!0)}deleteCurrentLayer(){if(this.current_layer&&this.getNumLayers()>1){const e=this.current_layer.removeGroup();return this.identifyLayers(),e}return null}identifyLayers(){this.all_layers=[],this.layer_map={};const e=this.svgElem_.childNodes.length,t=[],n=[];let i=null,s=!1;for(let o=0;o<e;++o){const e=this.svgElem_.childNodes.item(o);if(e&&1===e.nodeType)if("g"===e.tagName){s=!0;const o=_n(e);o?(n.push(o),i=new rn(o,e),this.all_layers.push(i),this.layer_map[o]=i):t.push(e)}else dn.includes(e.nodeName)&&t.push(e)}t.length>0||!s?(i=new rn(yn(n),null,this.svgElem_),i.appendChildren(t),this.all_layers.push(i),this.layer_map[name]=i):i.activate(),this.current_layer=i}createLayer(e,t){this.current_layer&&this.current_layer.deactivate(),(null==e||""===e||this.layer_map[e])&&(e=yn(Object.keys(this.layer_map)));const n=new rn(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()}cloneLayer(e,t){if(!this.current_layer)return null;this.current_layer.deactivate(),(null==e||""===e||this.layer_map[e])&&(e=yn(Object.keys(this.layer_map)));const n=this.current_layer.getGroup(),i=new rn(e,n,this.svgElem_),s=i.getGroup();[...n.childNodes].forEach(e=>{"title"!==e.localName&&s.append(this.copyElem(e))}),t&&(t.startBatchCommand("Duplicate Layer"),t.insertElement(s),t.endBatchCommand());const o=this.all_layers.indexOf(this.current_layer);return o>=0?this.all_layers.splice(o+1,0,i):this.all_layers.push(i),this.layer_map[e]=i,this.current_layer=i,s}getLayerVisibility(e){const t=this.layer_map[e];return!!t&&t.isVisible()}setLayerVisibility(e,t){if("boolean"!=typeof t)return null;const n=this.layer_map[e];return n?(n.setVisible(t),n.getGroup()):null}getLayerOpacity(e){const t=this.layer_map[e];return t?t.getOpacity():null}setLayerOpacity(e,t){if("number"!=typeof t||t<0||t>1)return;const n=this.layer_map[e];n&&n.setOpacity(t)}copyElem(e){const t=this;return cn(e,(function(){return t.getNextId()}))}}const vn=function(e,t){gn=!1===e?pn:hn,gn!==hn||t.getNonce()?gn===pn&&t.getNonce()&&t.clearNonce():t.setNonce(Math.floor(100001*Math.random()))};let xn;const wn=function(){Ln(),xn.getCurrentDrawing().identifyLayers()},Sn=function(e,t){const n=xn.getCurrentDrawing().createLayer(e,mn(t));xn.clearSelection(),xn.call("changed",[n])},kn=function(e,t){const n=xn.getCurrentDrawing().cloneLayer(e,mn(t));xn.clearSelection(),Ln(),xn.call("changed",[n])},Cn=function(){let e=xn.getCurrentDrawing().getCurrentLayer();const{nextSibling:t}=e,n=e.parentNode;if(e=xn.getCurrentDrawing().deleteCurrentLayer(),e){const i=new gt("Delete Layer");return i.addSubCommand(new ht(e,t,n)),xn.addCommandToHistory(i),xn.clearSelection(),xn.call("changed",[n]),!0}return!1},An=function(e){const t=xn.getCurrentDrawing().setCurrentLayer(he(e));return t&&xn.clearSelection(),t},En=function(e){const t=xn.getCurrentDrawing(),n=t.getCurrentLayer();if(n){if(t.setCurrentLayerName(e,mn()))return xn.call("changed",[n]),!0}return!1},Gn=function(e){const t=xn.getCurrentDrawing().setCurrentLayerPosition(e);return!!t&&(xn.addCommandToHistory(new ut(t.currentGroup,t.oldNextSibling,xn.getSVGContent())),!0)},Pn=function(e,t){const n=xn.getCurrentDrawing(),i=n.getLayerVisibility(e),s=n.setLayerVisibility(e,t);if(!s)return!1;{const e=i?"inline":"none";xn.addCommandToHistory(new pt(s,{display:e},"Layer Visibility"))}return s===n.getCurrentLayer()&&(xn.clearSelection(),xn.pathActions.clear()),!0},Nn=function(e){const t=xn.getCurrentDrawing().getLayerByName(e);if(!t)return!1;const n=new gt("Move Elements to Layer"),i=xn.getSelectedElements();let s=i.length;for(;s--;){const e=i[s];if(!e)continue;const o=e.nextSibling,r=e.parentNode;t.append(e),n.addSubCommand(new ut(e,o,r))}return xn.addCommandToHistory(n),!0},In=function(e){xn.getCurrentDrawing().mergeLayer(mn(e)),xn.clearSelection(),Ln(),xn.changeSVGContent()},Tn=function(e){xn.getCurrentDrawing().mergeAllLayers(mn(e)),xn.clearSelection(),Ln(),xn.changeSVGContent()},Ln=function(){const e=fn.length;if(e){for(let t=0;t<e;t++){const e=fn[t],n=xn.elData(e,"orig_opac");1!==n?e.setAttribute("opacity",n):e.removeAttribute("opacity"),e.setAttribute("style","pointer-events: inherit")}fn=[],xn.clearSelection(!0),xn.call("contextset",null)}xn.setCurrentGroup(null)},Mn=function(e){Ln(),"string"==typeof e&&(e=He(e)),xn.setCurrentGroup(e),un(e).parentsUntil("#svgcontent").andSelf().siblings().each((function(){const e=this.getAttribute("opacity")||1;xn.elData(this,"orig_opac",e),this.setAttribute("opacity",.33*e),this.setAttribute("style","pointer-events: none"),fn.push(this)})),xn.clearSelection(),xn.call("contextset",xn.getCurrentGroup())},On=n(),jn={a:["class","clip-path","clip-rule","fill","fill-opacity","fill-rule","filter","id","mask","opacity","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","style","systemLanguage","transform","xlink:href","xlink:title"],circle:["class","clip-path","clip-rule","cx","cy","fill","fill-opacity","fill-rule","filter","id","mask","opacity","r","requiredFeatures","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","style","systemLanguage","transform"],clipPath:["class","clipPathUnits","id"],defs:[],style:["type"],desc:[],ellipse:["class","clip-path","clip-rule","cx","cy","fill","fill-opacity","fill-rule","filter","id","mask","opacity","requiredFeatures","rx","ry","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","style","systemLanguage","transform"],feGaussianBlur:["class","color-interpolation-filters","id","requiredFeatures","stdDeviation"],feMorphology:["class","in","operator","radius"],filter:["class","color-interpolation-filters","filterRes","filterUnits","height","id","primitiveUnits","requiredFeatures","width","x","xlink:href","y"],foreignObject:["class","font-size","height","id","opacity","requiredFeatures","style","transform","width","x","y"],g:["class","clip-path","clip-rule","id","display","fill","fill-opacity","fill-rule","filter","mask","opacity","requiredFeatures","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","style","systemLanguage","transform","font-family","font-size","font-style","font-weight","text-anchor"],image:["class","clip-path","clip-rule","filter","height","id","mask","opacity","requiredFeatures","style","systemLanguage","transform","width","x","xlink:href","xlink:title","y"],line:["class","clip-path","clip-rule","fill","fill-opacity","fill-rule","filter","id","marker-end","marker-mid","marker-start","mask","opacity","requiredFeatures","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","style","systemLanguage","transform","x1","x2","y1","y2"],linearGradient:["class","id","gradientTransform","gradientUnits","requiredFeatures","spreadMethod","systemLanguage","x1","x2","xlink:href","y1","y2"],marker:["id","class","markerHeight","markerUnits","markerWidth","orient","preserveAspectRatio","refX","refY","systemLanguage","viewBox"],mask:["class","height","id","maskContentUnits","maskUnits","width","x","y"],metadata:["class","id"],path:["class","clip-path","clip-rule","d","fill","fill-opacity","fill-rule","filter","id","marker-end","marker-mid","marker-start","mask","opacity","requiredFeatures","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","style","systemLanguage","transform"],pattern:["class","height","id","patternContentUnits","patternTransform","patternUnits","requiredFeatures","style","systemLanguage","viewBox","width","x","xlink:href","y"],polygon:["class","clip-path","clip-rule","id","fill","fill-opacity","fill-rule","filter","id","class","marker-end","marker-mid","marker-start","mask","opacity","points","requiredFeatures","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","style","systemLanguage","transform"],polyline:["class","clip-path","clip-rule","id","fill","fill-opacity","fill-rule","filter","marker-end","marker-mid","marker-start","mask","opacity","points","requiredFeatures","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","style","systemLanguage","transform"],radialGradient:["class","cx","cy","fx","fy","gradientTransform","gradientUnits","id","r","requiredFeatures","spreadMethod","systemLanguage","xlink:href"],rect:["class","clip-path","clip-rule","fill","fill-opacity","fill-rule","filter","height","id","mask","opacity","requiredFeatures","rx","ry","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","style","systemLanguage","transform","width","x","y"],stop:["class","id","offset","requiredFeatures","stop-color","stop-opacity","style","systemLanguage"],svg:["class","clip-path","clip-rule","filter","id","height","mask","preserveAspectRatio","requiredFeatures","style","systemLanguage","viewBox","width","x","xmlns","xmlns:se","xmlns:xlink","y"],switch:["class","id","requiredFeatures","systemLanguage"],symbol:["class","fill","fill-opacity","fill-rule","filter","font-family","font-size","font-style","font-weight","id","opacity","preserveAspectRatio","requiredFeatures","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","style","systemLanguage","transform","viewBox"],text:["class","clip-path","clip-rule","fill","fill-opacity","fill-rule","filter","font-family","font-size","font-style","font-weight","id","mask","opacity","requiredFeatures","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","style","systemLanguage","text-anchor","transform","x","xml:space","y"],textPath:["class","id","method","requiredFeatures","spacing","startOffset","style","systemLanguage","transform","xlink:href"],title:[],tspan:["class","clip-path","clip-rule","dx","dy","fill","fill-opacity","fill-rule","filter","font-family","font-size","font-style","font-weight","id","mask","opacity","requiredFeatures","rotate","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","style","systemLanguage","text-anchor","textLength","transform","x","xml:space","y"],use:["class","clip-path","clip-rule","fill","fill-opacity","fill-rule","filter","height","id","mask","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","style","transform","width","x","xlink:href","y"],annotation:["encoding"],"annotation-xml":["encoding"],maction:["actiontype","other","selection"],math:["class","id","display","xmlns"],menclose:["notation"],merror:[],mfrac:["linethickness"],mi:["mathvariant"],mmultiscripts:[],mn:[],mo:["fence","lspace","maxsize","minsize","rspace","stretchy"],mover:[],mpadded:["lspace","width","height","depth","voffset"],mphantom:[],mprescripts:[],mroot:[],mrow:["xlink:href","xlink:type","xmlns:xlink"],mspace:["depth","height","width"],msqrt:[],mstyle:["displaystyle","mathbackground","mathcolor","mathvariant","scriptlevel"],msub:[],msubsup:[],msup:[],mtable:["align","columnalign","columnlines","columnspacing","displaystyle","equalcolumns","equalrows","frame","rowalign","rowlines","rowspacing","width"],mtd:["columnalign","columnspan","rowalign","rowspan"],mtext:[],mtr:["columnalign","rowalign"],munder:[],munderover:[],none:[],semantics:[]},Vn={};Object.entries(jn).forEach((function([e,n]){const i={};Object.entries(n).forEach((function([e,n]){if(n.includes(":")){const e=n.split(":");i[e[1]]=t[e[0].toUpperCase()]}else i[n]="xmlns"===n?t.XMLNS:null})),Vn[e]=i}));const Rn=function(e){if(3===e.nodeType&&(e.nodeValue=e.nodeValue.replace(/^\s+|\s+$/g,""),e.nodeValue.length||e.remove()),1!==e.nodeType)return;const n=e.ownerDocument,i=e.parentNode;if(!n||!i)return;const s=jn[e.nodeName],o=Vn[e.nodeName];if(void 0!==s){const n=[];let i=e.attributes.length;for(;i--;){const r=e.attributes.item(i),a=r.nodeName,l=r.localName,c=r.namespaceURI;if({}.hasOwnProperty.call(o,l)&&c===o[l]&&c!==t.XMLNS||c===t.XMLNS&&On[r.value]||((a.startsWith("se:")||a.startsWith("data-"))&&n.push([a,r.value]),e.removeAttributeNS(c,l)),S())switch(a){case"transform":case"gradientTransform":case"patternTransform":{const t=r.value.replace(/(\d)-/g,"$1 -");e.setAttribute(a,t);break}}if("style"===a){const t=r.value.split(";");let n=t.length;for(;n--;){const[i,o]=t[n].split(":"),r=(i||"").trim(),a=(o||"").trim();s.includes(r)&&e.setAttribute(r,a)}e.removeAttribute("style")}}Object.values(n).forEach(([n,i])=>{e.setAttributeNS(t.SE,n,i)});const r=Ce(e);if(r&&["filter","linearGradient","pattern","radialGradient","textPath","use"].includes(e.nodeName)&&"#"!==r[0]&&(Ae(e,""),e.removeAttributeNS(t.XLINK,"href")),"use"===e.nodeName&&!Ce(e))return void e.remove();for(Object.values(["clip-path","fill","filter","marker-end","marker-mid","marker-start","mask","stroke"],(function(t){let n=e.getAttribute(t);n&&(n=ke(n),n&&"#"!==n[0]&&(e.setAttribute(t,""),e.removeAttribute(t)))})),i=e.childNodes.length;i--;)Rn(e.childNodes.item(i))}else{const t=[];for(;e.hasChildNodes();)t.push(i.insertBefore(e.firstChild,e));e.remove();let n=t.length;for(;n--;)Rn(t[n])}},Bn=jQuery,Un=[0,"z","M","m","L","l","C","c","Q","q","A","a","H","h","V","v","S","s","T","t"];let Dn=null;const Fn=function(e,t,n){const i=function(e,t){return $(e,t,n)},s=function(e){return n.a*e},o=function(e){return n.d*e},r=Dn.getGridSnapping()&&"svg"===e.parentNode.parentNode.localName,a=function(){r&&Object.entries(t).forEach(([e,n])=>{t[e]=We(n)}),qe(e,t,0,!0)},l=Ne(e);for(let t=0;t<2;t++){const i=0===t?"fill":"stroke",s=e.getAttribute(i);if(s&&s.startsWith("url(")&&(n.a<0||n.d<0)){const t=ze(s).cloneNode(!0);if(n.a<0){const e=t.getAttribute("x1"),n=t.getAttribute("x2");t.setAttribute("x1",-(e-1)),t.setAttribute("x2",-(n-1))}if(n.d<0){const e=t.getAttribute("y1"),n=t.getAttribute("y2");t.setAttribute("y1",-(e-1)),t.setAttribute("y2",-(n-1))}t.id=Dn.getDrawing().getNextId(),Ee().append(t),e.setAttribute(i,"url(#"+t.id+")")}}const c=e.tagName;if("g"===c||"text"===c||"tspan"===c||"use"===c)if(1!==n.a||0!==n.b||0!==n.c||1!==n.d||0===n.e&&0===n.f){const t=O(e),i=Dn.getSVGRoot().createSVGTransform();i.setMatrix(Q(J(t).matrix,n)),t.clear(),t.appendItem(i)}else{const i=J(e).matrix,s=Q(i.inverse(),n,i);t.x=Number.parseFloat(t.x)+s.e,t.y=Number.parseFloat(t.y)+s.f}switch(c){case"foreignObject":case"rect":case"image":if("image"===c&&(n.a<0||n.d<0)){const t=O(e),i=Dn.getSVGRoot().createSVGTransform();i.setMatrix(Q(J(t).matrix,n)),t.clear(),t.appendItem(i)}else{const e=i(t.x,t.y);t.width=s(t.width),t.height=o(t.height),t.x=e.x+Math.min(0,t.width),t.y=e.y+Math.min(0,t.height),t.width=Math.abs(t.width),t.height=Math.abs(t.height)}a();break;case"ellipse":{const e=i(t.cx,t.cy);t.cx=e.x,t.cy=e.y,t.rx=s(t.rx),t.ry=o(t.ry),t.rx=Math.abs(t.rx),t.ry=Math.abs(t.ry),a();break}case"circle":{const e=i(t.cx,t.cy);t.cx=e.x,t.cy=e.y;const s=Z(l.x,l.y,l.width,l.height,n),o=s.tr.x-s.tl.x,r=s.bl.y-s.tl.y;t.r=Math.min(o/2,r/2),t.r&&(t.r=Math.abs(t.r)),a();break}case"line":{const e=i(t.x1,t.y1),n=i(t.x2,t.y2);t.x1=e.x,t.y1=e.y,t.x2=n.x,t.y2=n.y}case"text":case"tspan":case"use":a();break;case"g":{const n=Bn(e).data("gsvg");n&&qe(n,t,0,!0);break}case"polyline":case"polygon":{const n=t.points.length;for(let e=0;e<n;++e){const n=t.points[e],{x:s,y:o}=i(n.x,n.y);t.points[e].x=s,t.points[e].y=o}let s="";for(let e=0;e<n;++e){const n=t.points[e];s+=n.x+","+n.y+" "}e.setAttribute("points",s);break}case"path":{const n=e.pathSegList;let r=n.numberOfItems;t.d=[];for(let e=0;e<r;++e){const i=n.getItem(e);t.d[e]={type:i.pathSegType,x:i.x,y:i.y,x1:i.x1,y1:i.y1,x2:i.x2,y2:i.y2,r1:i.r1,r2:i.r2,angle:i.angle,largeArcFlag:i.largeArcFlag,sweepFlag:i.sweepFlag}}r=t.d.length;const a=t.d[0],l=i(a.x,a.y);t.d[0].x=l.x,t.d[0].y=l.y;for(let e=1;e<r;++e){const n=t.d[e],{type:r}=n;if(r%2==0){const e=i(void 0!==n.x?n.x:l.x,void 0!==n.y?n.y:l.y),t=i(n.x1,n.y1),r=i(n.x2,n.y2);n.x=e.x,n.y=e.y,n.x1=t.x,n.y1=t.y,n.x2=r.x,n.y2=r.y,n.r1=s(n.r1),n.r2=o(n.r2)}else n.x=s(n.x),n.y=o(n.y),n.x1=s(n.x1),n.y1=o(n.y1),n.x2=s(n.x2),n.y2=o(n.y2),n.r1=s(n.r1),n.r2=o(n.r2)}let c="";r=t.d.length;for(let e=0;e<r;++e){const n=t.d[e],{type:i}=n;switch(c+=Un[i],i){case 13:case 12:c+=n.x+" ";break;case 15:case 14:c+=n.y+" ";break;case 3:case 5:case 19:case 2:case 4:case 18:c+=n.x+","+n.y+" ";break;case 7:case 6:c+=n.x1+","+n.y1+" "+n.x2+","+n.y2+" "+n.x+","+n.y+" ";break;case 9:case 8:c+=n.x1+","+n.y1+" "+n.x+","+n.y+" ";break;case 11:case 10:c+=n.r1+","+n.r2+" "+n.angle+" "+Number(n.largeArcFlag)+" "+Number(n.sweepFlag)+" "+n.x+","+n.y+" ";break;case 17:case 16:c+=n.x2+","+n.y2+" "+n.x+","+n.y+" "}}e.setAttribute("d",c);break}}},zn=P(jQuery);let Hn;const qn=function(e,t,n){const i=ze(e).firstChild,s=O(i),o=Hn.getSVGRoot().createSVGTransform();o.setTranslate(t,n),s.appendItem(o),Xn(i)},Xn=function(e){if(Qe(e))return null;if("svg"===e.nodeName&&navigator.userAgent.includes("Firefox/20"))return null;const n=Hn.getSVGRoot(),i=O(e);if(i&&i.numberOfItems>0){let t=i.numberOfItems;const n=t;for(;t--;){const s=i.getItem(t);if(0===s.type)i.removeItem(t);else if(1===s.type){if(Y(s.matrix)){if(1===n)return e.removeAttribute("transform"),null;i.removeItem(t)}}else 4===s.type&&0===s.angle&&i.removeItem(t)}if(1===i.numberOfItems&&Fe(e))return null}if(!i||0===i.numberOfItems)return e.setAttribute("transform",""),e.removeAttribute("transform"),null;if(i){let e=[],t=i.numberOfItems;for(;t--;){const n=i.getItem(t);1===n.type?e.push([n.matrix,t]):e.length&&(e=[])}if(2===e.length){const t=n.createSVGTransformFromMatrix(Q(e[1][0],e[0][0]));i.removeItem(e[0][1]),i.removeItem(e[1][1]),i.insertItemBefore(t,e[1][1])}if(t=i.numberOfItems,t>=2&&1===i.getItem(t-2).type&&2===i.getItem(t-1).type){const e=n.createSVGTransform(),s=Q(i.getItem(t-2).matrix,i.getItem(t-1).matrix);e.setMatrix(s),i.removeItem(t-2),i.removeItem(t-2),i.appendItem(e)}}switch(e.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}const s=zn(e).data("gsvg"),o=new gt("Transform");let r,a,l={},c=null,u=[];switch(e.tagName){case"line":u=["x1","y1","x2","y2"];break;case"circle":u=["cx","cy","r"];break;case"ellipse":u=["cx","cy","rx","ry"];break;case"foreignObject":case"rect":case"image":u=["width","height","x","y"];break;case"use":case"text":case"tspan":u=["x","y"];break;case"polygon":case"polyline":{c={},c.points=e.getAttribute("points");const t=e.points,n=t.numberOfItems;l.points=new Array(n);for(let e=0;e<n;++e){const n=t.getItem(e);l.points[e]={x:n.x,y:n.y}}break}case"path":c={},c.d=e.getAttribute("d"),l.d=e.getAttribute("d")}if(u.length?(l=zn(e).attr(u),zn.each(l,(function(e,t){l[e]=q(e,t)}))):s&&(l={x:zn(s).attr("x")||0,y:zn(s).attr("y")||0}),Qe(c)&&(c=zn.extend(!0,{},l),zn.each(c,(function(e,t){c[e]=q(e,t)}))),c.transform=Hn.getStartTransform()||"","g"===e.tagName&&!s||"a"===e.tagName){const s=Ne(e);r={x:s.x+s.width/2,y:s.y+s.height/2},a=$(s.x+s.width/2,s.y+s.height/2,J(i).matrix);const l=Fe(e);if(l){const e=l*Math.PI/180;let t;t=Math.abs(e)>1e-10?Math.sin(e)/(1-Math.cos(e)):2/e;for(let e=0;e<i.numberOfItems;++e){const n=i.getItem(e);if(4===n.type){const s=n.matrix;r.y=(t*s.e+s.f)/2,r.x=(s.e-t*s.f)/2,i.removeItem(e);break}}}const c=i.numberOfItems;let u,d,h=0,p=0,g=0;if(c&&(u=i.getItem(0).matrix),c>=3&&3===i.getItem(c-2).type&&2===i.getItem(c-3).type&&2===i.getItem(c-1).type){g=3;const t=i.getItem(c-3).matrix,s=i.getItem(c-2).matrix,r=i.getItem(c-1).matrix,a=e.childNodes;let l=a.length;for(;l--;){const e=a.item(l);if(h=0,p=0,1===e.nodeType){const i=O(e);if(!i)continue;const a=J(i).matrix,l=Fe(e);if(d=Hn.getStartTransform(),Hn.setStartTransform(e.getAttribute("transform")),l||K(i)){const e=n.createSVGTransform();e.setMatrix(Q(t,s,r,a)),i.clear(),i.appendItem(e)}else{const e=Q(a.inverse(),r,a),o=n.createSVGMatrix();o.e=-e.e,o.f=-e.f;const l=Q(o.inverse(),a.inverse(),t,s,r,a,e.inverse()),c=n.createSVGTransform(),u=n.createSVGTransform(),d=n.createSVGTransform();c.setTranslate(e.e,e.f),u.setScale(l.a,l.d),d.setTranslate(o.e,o.f),i.appendItem(d),i.appendItem(u),i.appendItem(c)}o.addSubCommand(Xn(e)),Hn.setStartTransform(d)}}i.removeItem(c-1),i.removeItem(c-2),i.removeItem(c-3)}else if(c>=3&&1===i.getItem(c-1).type){g=3;const e=J(i).matrix,t=n.createSVGTransform();t.setMatrix(e),i.clear(),i.appendItem(t)}else if((1===c||c>1&&3!==i.getItem(1).type)&&2===i.getItem(0).type){g=2;const s=J(i).matrix;i.removeItem(0);const r=J(i).matrix.inverse(),a=Q(r,s);if(h=a.e,p=a.f,0!==h||0!==p){const i=e.childNodes;let s=i.length;const r=[];for(;s--;){const a=i.item(s);if(1===a.nodeType){if(a.getAttribute("clip-path")){const e=a.getAttribute("clip-path");r.includes(e)||(qn(e,h,p),r.push(e))}d=Hn.getStartTransform(),Hn.setStartTransform(a.getAttribute("transform"));const i=O(a);if(i){const s=n.createSVGTransform();s.setTranslate(h,p),i.numberOfItems?i.insertItemBefore(s,0):i.appendItem(s),o.addSubCommand(Xn(a));const r=e.getElementsByTagNameNS(t.SVG,"use"),l="#"+a.id;let c=r.length;for(;c--;){const e=r.item(c);if(l===Ce(e)){const t=n.createSVGTransform();t.setTranslate(-h,-p),O(e).insertItemBefore(t,0),o.addSubCommand(Xn(e))}}Hn.setStartTransform(d)}}}Hn.setStartTransform(d)}}else{if(1!==c||1!==i.getItem(0).type||l){if(l){const e=n.createSVGTransform();e.setRotate(l,a.x,a.y),i.numberOfItems?i.insertItemBefore(e,0):i.appendItem(e)}return 0===i.numberOfItems&&e.removeAttribute("transform"),null}{g=1;const t=i.getItem(0).matrix,s=e.childNodes;let r=s.length;for(;r--;){const e=s.item(r);if(1===e.nodeType){d=Hn.getStartTransform(),Hn.setStartTransform(e.getAttribute("transform"));const i=O(e);if(!i)continue;const s=Q(t,J(i).matrix),r=n.createSVGTransform();r.setMatrix(s),i.clear(),i.appendItem(r,0),o.addSubCommand(Xn(e)),Hn.setStartTransform(d);const a=e.getAttribute("stroke-width");if("none"!==e.getAttribute("stroke")&&!isNaN(a)){const t=(Math.abs(s.a)+Math.abs(s.d))/2;e.setAttribute("stroke-width",a*t)}}}i.clear()}}if(2===g){if(l){a={x:r.x+u.e,y:r.y+u.f};const e=n.createSVGTransform();e.setRotate(l,a.x,a.y),i.numberOfItems?i.insertItemBefore(e,0):i.appendItem(e)}}else if(3===g){const t=J(i).matrix,s=n.createSVGTransform();s.setRotate(l,r.x,r.y);const c=s.matrix,u=n.createSVGTransform();u.setRotate(l,a.x,a.y);const g=u.matrix.inverse(),f=t.inverse(),m=Q(f,g,c,t);if(h=m.e,p=m.f,0!==h||0!==p){const t=e.childNodes;let i=t.length;for(;i--;){const e=t.item(i);if(1===e.nodeType){d=Hn.getStartTransform(),Hn.setStartTransform(e.getAttribute("transform"));const t=O(e),i=n.createSVGTransform();i.setTranslate(h,p),t.numberOfItems?t.insertItemBefore(i,0):t.appendItem(i),o.addSubCommand(Xn(e)),Hn.setStartTransform(d)}}}l&&(i.numberOfItems?i.insertItemBefore(u,0):i.appendItem(u))}}else{const t=Ne(e);if(!t&&"path"!==e.tagName)return null;let s;const o=Fe(e);if(o){r={x:t.x+t.width/2,y:t.y+t.height/2},a=$(t.x+t.width/2,t.y+t.height/2,J(i).matrix);const e=o*Math.PI/180,n=Math.abs(e)>1e-10?Math.sin(e)/(1-Math.cos(e)):2/e;for(let e=0;e<i.numberOfItems;++e){const t=i.getItem(e);if(4===t.type){const s=t.matrix;r.y=(n*s.e+s.f)/2,r.x=(s.e-n*s.f)/2,i.removeItem(e);break}}}let c=0;const u=i.numberOfItems;if(!w()){const t=e.getAttribute("fill");if(t&&t.startsWith("url(")){const e=ze(t);let n="pattern";e.tagName!==n&&(n="gradient");if("userSpaceOnUse"===e.getAttribute(n+"Units")){s=J(i).matrix;const t=O(e),o=J(t).matrix;s=Q(s,o);const r="matrix("+[s.a,s.b,s.c,s.d,s.e,s.f].join(",")+")";e.setAttribute(n+"Transform",r)}}}if(u>=3&&3===i.getItem(u-2).type&&2===i.getItem(u-3).type&&2===i.getItem(u-1).type)c=3,s=J(i,u-3,u-1).matrix,i.removeItem(u-1),i.removeItem(u-2),i.removeItem(u-3);else if(4===u&&1===i.getItem(u-1).type){c=3,s=J(i).matrix;const e=n.createSVGTransform();e.setMatrix(s),i.clear(),i.appendItem(e),s=n.createSVGMatrix()}else if((1===u||u>1&&3!==i.getItem(1).type)&&2===i.getItem(0).type){c=2;const e=i.getItem(0).matrix,t=J(i,1).matrix,n=t.inverse();s=Q(n,e,t),i.removeItem(0)}else{if(1!==u||1!==i.getItem(0).type||o){if(o){const e=n.createSVGTransform();e.setRotate(o,a.x,a.y),i.numberOfItems?i.insertItemBefore(e,0):i.appendItem(e)}return 0===i.numberOfItems&&e.removeAttribute("transform"),null}switch(s=J(i).matrix,e.tagName){case"line":l=zn(e).attr(["x1","y1","x2","y2"]);case"polyline":case"polygon":if(l.points=e.getAttribute("points"),l.points){const t=e.points,n=t.numberOfItems;l.points=new Array(n);for(let e=0;e<n;++e){const n=t.getItem(e);l.points[e]={x:n.x,y:n.y}}}case"path":l.d=e.getAttribute("d"),c=1,i.clear()}}if(1!==c&&2!==c&&3!==c||Fn(e,l,s),2===c){if(o){K(i)||(a={x:r.x+s.e,y:r.y+s.f});const e=n.createSVGTransform();e.setRotate(o,a.x,a.y),i.numberOfItems?i.insertItemBefore(e,0):i.appendItem(e)}if("text"===e.tagName){const t=e.childNodes;let n=t.length;for(;n--;){const e=t.item(n);if("tspan"===e.tagName){const t={x:zn(e).attr("x")||0,y:zn(e).attr("y")||0};Fn(e,t,s)}}}}else if(3===c&&o){const{matrix:t}=J(i),s=n.createSVGTransform();s.setRotate(o,r.x,r.y);const c=s.matrix,u=n.createSVGTransform();u.setRotate(o,a.x,a.y);const d=u.matrix.inverse(),h=t.inverse(),p=Q(h,d,c,t);Fn(e,l,p),o&&(i.numberOfItems?i.insertItemBefore(u,0):i.appendItem(u))}}return 0===i.numberOfItems&&e.removeAttribute("transform"),o.addSubCommand(new pt(e,c)),o},Wn=jQuery;let $n,Yn,Qn;const Kn=E()?10:4;class Zn{constructor(e,t,n){this.id=e,this.selectedElement=t,this.locked=!0,this.selectorGroup=$n.createSVGElement({element:"g",attr:{id:"selectorGroup"+this.id}}),this.selectorRect=this.selectorGroup.appendChild($n.createSVGElement({element:"path",attr:{id:"selectedBox"+this.id,fill:"none",stroke:"#22C","stroke-width":"1","stroke-dasharray":"5,5",style:"pointer-events:none"}})),this.gripCoords={nw:null,n:null,ne:null,e:null,se:null,s:null,sw:null,w:null},this.reset(this.selectedElement,n)}reset(e,t){this.locked=!0,this.selectedElement=e,this.resize(t),this.selectorGroup.setAttribute("display","inline")}showGrips(e){const t=e?"inline":"none";Qn.selectorGripsGroup.setAttribute("display",t);const n=this.selectedElement;this.hasGrips=e,n&&e&&(this.selectorGroup.append(Qn.selectorGripsGroup),Zn.updateGripCursors(Fe(n)))}resize(e){const t=this.selectorRect,n=Qn,i=n.selectorGrips,s=this.selectedElement,o=s.getAttribute("stroke-width"),r=$n.getCurrentZoom();let a=1/r;"none"===s.getAttribute("stroke")||isNaN(o)||(a+=o/2);const{tagName:l}=s;"text"===l&&(a+=2/r);const c=O(s),u=J(c).matrix;if(u.e*=r,u.f*=r,e||(e=Ne(s)),"g"===l&&!Wn.data(s,"gsvg")){const t=Re([s.childNodes]);t&&(e=t)}const d=e.x,h=e.y,p=e.width,g=e.height;a*=r;const f=Z(d*r,h*r,p*r,g*r,u),{aabox:m}=f;let _=m.x-a,y=m.y-a,b=m.width+2*a,v=m.height+2*a;const x=_+b/2,w=y+v/2,S=Fe(s);if(S){const e=$n.svgRoot().createSVGTransform();e.setRotate(-S,x,w);const t=e.matrix;f.tl=$(f.tl.x,f.tl.y,t),f.tr=$(f.tr.x,f.tr.y,t),f.bl=$(f.bl.x,f.bl.y,t),f.br=$(f.br.x,f.br.y,t);const{tl:n}=f;let i=n.x,s=n.y,o=n.x,r=n.y;const{min:l,max:c}=Math;i=l(i,l(f.tr.x,l(f.bl.x,f.br.x)))-a,s=l(s,l(f.tr.y,l(f.bl.y,f.br.y)))-a,o=c(o,c(f.tr.x,c(f.bl.x,f.br.x)))+a,r=c(r,c(f.tr.y,c(f.bl.y,f.br.y)))+a,_=i,y=s,b=o-i,v=r-s}const k="M"+_+","+y+" L"+(_+b)+","+y+" "+(_+b)+","+(y+v)+" "+_+","+(y+v)+"z";t.setAttribute("d",k);const C=S?"rotate("+[S,x,w].join(",")+")":"";this.selectorGroup.setAttribute("transform",C),this.gripCoords={nw:[_,y],ne:[_+b,y],sw:[_,y+v],se:[_+b,y+v],n:[_+b/2,y],w:[_,y+v/2],e:[_+b,y+v/2],s:[_+b/2,y+v]},Object.entries(this.gripCoords).forEach(([e,t])=>{i[e].setAttribute("cx",t[0]),i[e].setAttribute("cy",t[1])}),n.rotateGripConnector.setAttribute("x1",_+b/2),n.rotateGripConnector.setAttribute("y1",y),n.rotateGripConnector.setAttribute("x2",_+b/2),n.rotateGripConnector.setAttribute("y2",y-5*Kn),n.rotateGrip.setAttribute("cx",_+b/2),n.rotateGrip.setAttribute("cy",y-5*Kn)}static updateGripCursors(e){const t=Object.keys(Qn.selectorGrips);let n=Math.round(e/45);for(n<0&&(n+=8);n>0;)t.push(t.shift()),n--;Object.values(Qn.selectorGrips).forEach((e,n)=>{e.setAttribute("style","cursor:"+t[n]+"-resize")})}}class Jn{constructor(){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()}initGroup(){if(this.selectorParentGroup&&this.selectorParentGroup.parentNode&&this.selectorParentGroup.remove(),this.selectorParentGroup=$n.createSVGElement({element:"g",attr:{id:"selectorParentGroup"}}),this.selectorGripsGroup=$n.createSVGElement({element:"g",attr:{display:"none"}}),this.selectorParentGroup.append(this.selectorGripsGroup),$n.svgRoot().append(this.selectorParentGroup),this.selectorMap={},this.selectors=[],this.rubberBandBox=null,Object.keys(this.selectorGrips).forEach(e=>{const t=$n.createSVGElement({element:"circle",attr:{id:"selectorGrip_resize_"+e,fill:"#22C",r:Kn,style:"cursor:"+e+"-resize","stroke-width":2,"pointer-events":"all"}});Wn.data(t,"dir",e),Wn.data(t,"type","resize"),this.selectorGrips[e]=this.selectorGripsGroup.appendChild(t)}),this.rotateGripConnector=this.selectorGripsGroup.appendChild($n.createSVGElement({element:"line",attr:{id:"selectorGrip_rotateconnector",stroke:"#22C","stroke-width":"1"}})),this.rotateGrip=this.selectorGripsGroup.appendChild($n.createSVGElement({element:"circle",attr:{id:"selectorGrip_rotate",fill:"lime",r:Kn,stroke:"#22C","stroke-width":2,style:"cursor:url("+Yn.imgPath+"rotate.png) 12 12, auto;"}})),Wn.data(this.rotateGrip,"type","rotate"),Wn("#canvasBackground").length)return;const[e,t]=Yn.dimensions,n=$n.createSVGElement({element:"svg",attr:{id:"canvasBackground",width:e,height:t,x:0,y:0,overflow:w()?"none":"visible",style:"pointer-events:none"}}),i=$n.createSVGElement({element:"rect",attr:{width:"100%",height:"100%",x:0,y:0,"stroke-width":1,stroke:"#000",fill:"#FFF",style:"pointer-events:none"}});n.append(i),$n.svgRoot().insertBefore(n,$n.svgContent())}requestSelector(e,t){if(Qe(e))return null;const n=this.selectors.length;if("object"==typeof this.selectorMap[e.id])return this.selectorMap[e.id].locked=!0,this.selectorMap[e.id];for(let i=0;i<n;++i)if(this.selectors[i]&&!this.selectors[i].locked)return this.selectors[i].locked=!0,this.selectors[i].reset(e,t),this.selectorMap[e.id]=this.selectors[i],this.selectors[i];return this.selectors[n]=new Zn(n,e,t),this.selectorParentGroup.append(this.selectors[n].selectorGroup),this.selectorMap[e.id]=this.selectors[n],this.selectors[n]}releaseSelector(e){if(Qe(e))return;const t=this.selectors.length,n=this.selectorMap[e.id];n.locked||console.log("WARNING! selector was released but was already unlocked");for(let i=0;i<t;++i)if(this.selectors[i]&&this.selectors[i]===n){delete this.selectorMap[e.id],n.locked=!1,n.selectedElement=null,n.showGrips(!1);try{n.selectorGroup.setAttribute("display","none")}catch(e){}break}}getRubberBandBox(){return this.rubberBandBox||(this.rubberBandBox=this.selectorParentGroup.appendChild($n.createSVGElement({element:"rect",attr:{id:"selectorRubberBand",fill:"#22C","fill-opacity":.15,stroke:"#22C","stroke-width":.5,display:"none",style:"pointer-events:none"}}))),this.rubberBandBox}}let ei=P(jQuery);const{MoveElementCommand:ti,InsertElementCommand:ni,RemoveElementCommand:ii,ChangeElementCommand:si,BatchCommand:oi,UndoManager:ri,HistoryEventTypes:ai}=ft;window.console||(window.console={},window.console.log=function(e){},window.console.dir=function(e){}),window.opera&&(window.console.log=function(e){window.opera.postError(e)},window.console.dir=function(e){});class li{constructor(e,i){const s={show_outside_canvas:!0,selectNew:!0,dimensions:[640,480]};i&&ei.extend(s,i);const{dimensions:o}=s,r=this,a=e.ownerDocument,l=a.importNode(ve('<svg id="svgroot" xmlns="'+t.SVG+'" xlinkns="'+t.XLINK+'" width="'+o[0]+'" height="'+o[1]+'" x="'+o[0]+'" y="'+o[1]+'" overflow="visible"><defs><filter id="canvashadow" filterUnits="objectBoundingBox"><feGaussianBlur in="SourceAlpha" stdDeviation="4" result="blur"/><feOffset in="blur" dx="5" dy="5" result="offsetBlur"/><feMerge><feMergeNode in="offsetBlur"/><feMergeNode in="SourceGraphic"/></feMerge></filter></defs></svg>').documentElement,!0);e.append(l);let c=a.createElementNS(t.SVG,"svg");(r.clearSvgContentElement=function(){ei(c).empty(),ei(c).attr({id:"svgcontent",width:o[0],height:o[1],x:o[0],y:o[1],overflow:s.show_outside_canvas?"visible":"hidden",xmlns:t.SVG,"xmlns:se":t.SE,"xmlns:xlink":t.XLINK}).appendTo(l);const e=a.createComment(" Created with SVG-edit - https://github.com/SVG-Edit/svgedit");c.append(e)})();let u="svg_";r.setIdPrefix=function(e){u=e},r.current_drawing_=new bn(c,u);const d=r.getCurrentDrawing=function(){return r.current_drawing_};let h=1,p=null;const g={shape:{fill:("none"===s.initFill.color?"":"#")+s.initFill.color,fill_paint:null,fill_opacity:s.initFill.opacity,stroke:"#"+s.initStroke.color,stroke_paint:null,stroke_opacity:s.initStroke.opacity,stroke_width:s.initStroke.width,stroke_dasharray:"none",stroke_linejoin:"miter",stroke_linecap:"butt",opacity:s.initOpacity}};g.text=ei.extend(!0,{},g.shape),ei.extend(g.text,{fill:"#000000",stroke_width:s.text&&s.text.stroke_width,font_size:s.text&&s.text.font_size,font_family:s.text&&s.text.font_family});const f=g.shape;let m=[];const y=this.getJsonFromSvgElement=function(e){if(3===e.nodeType)return e.nodeValue;const t={element:e.tagName,attr:{},children:[]};for(let n,i=0;n=e.attributes[i];i++)t.attr[n.name]=n.value;for(let n,i=0;n=e.childNodes[i];i++)t.children[i]=y(n);return t},b=this.addSVGElementFromJson=function(e){if("string"==typeof e)return a.createTextNode(e);let n=He(e.attr.id);const i=d().getCurrentLayer();if(n&&e.element!==n.tagName&&(n.remove(),n=null),!n){const s=e.namespace||t.SVG;n=a.createElementNS(s,e.element),i&&(p||i).append(n)}return e.curStyles&&qe(n,{fill:f.fill,stroke:f.stroke,"stroke-width":f.stroke_width,"stroke-dasharray":f.stroke_dasharray,"stroke-linejoin":f.stroke_linejoin,"stroke-linecap":f.stroke_linecap,"stroke-opacity":f.stroke_opacity,"fill-opacity":f.fill_opacity,opacity:f.opacity/2,style:"pointer-events:inherit"}),qe(n,e.attr),Xe(n),e.children&&e.children.forEach(e=>{n.append(b(e))}),n};r.getTransformList=O,r.matrixMultiply=Q,r.hasMatrixTransform=K,r.transformListToTransform=J;const v=()=>s.baseUnit;!function(e){B=e;const n=document.createElementNS(t.SVG,"svg");document.body.append(n);const i=document.createElementNS(t.SVG,"rect");i.setAttribute("width","1em"),i.setAttribute("height","1ex"),i.setAttribute("x","1in"),n.append(i);const s=i.getBBox();n.remove();const o=s.x;U={em:s.width,ex:s.height,in:o,cm:o/2.54,mm:o/25.4,pt:o/72,pc:o/6,px:1,"%":0}}({getBaseUnit:v,getElement:He,getHeight:()=>c.getAttribute("height")/h,getWidth:()=>c.getAttribute("width")/h,getRoundDigits:()=>Ie.round_digits}),r.convertToNum=q;const x=()=>c,A=this.getSelectedElems=function(){return m},{pathActions:E}=sn,P=()=>l;ue({pathActions:E,getSVGContent:x,addSVGElementFromJson:b,getSelectedElements:A,getDOMDocument:()=>a,getDOMContainer:()=>e,getSVGRoot:P,getBaseUnit:v,getSnappingStep:()=>s.snappingStep}),r.findDefs=Ee,r.getUrlFromAttr=ke,r.getHref=Ce,r.setHref=Ae,r.getBBox=Ne,r.getRotationAngle=Fe,r.getElem=He,r.getRefElem=ze,r.assignAttributes=qe,this.cleanupElement=Xe;const N=()=>s.gridSnapping;Dn={getDrawing:()=>d(),getSVGRoot:P,getGridSnapping:N},this.remapElement=Fn,function(e){Hn=e}({getSVGRoot:P,getStartTransform:()=>$e,setStartTransform(e){$e=e}}),this.recalculateDimensions=Xn;const I=n();r.sanitizeSvg=Rn;const M=r.undoMgr=new ri({handleHistoryEvent(e,t){const n=ai;if(e===n.BEFORE_UNAPPLY||e===n.BEFORE_APPLY)r.clearSelection();else if(e===n.AFTER_APPLY||e===n.AFTER_UNAPPLY){const i=t.elements();r.pathActions.clear(),ie("changed",i);const s=t.type(),o=e===n.AFTER_APPLY;if("MoveElementCommand"===s){(o?t.newParent:t.oldParent)===c&&wn()}else if("InsertElementCommand"===s||"RemoveElementCommand"===s)t.parent===c&&wn(),"InsertElementCommand"===s?o&&xe(t.elem):o||xe(t.elem),t.elem&&"use"===t.elem.tagName&&Ct(t.elem);else if("ChangeElementCommand"===s){"title"===t.elem.tagName&&t.elem.parentNode.parentNode===c&&wn();const e=o?t.newValues:t.oldValues;e.stdDeviation&&r.setBlurOffsets(t.elem.parentNode,e.stdDeviation)}}}}),j=function(e){r.undoMgr.addCommandToHistory(e)},V=this.getZoom=function(){return h},R=this.round=function(e){return Number.parseInt(e*h)/h};!function(e,t){Yn=e,$n=t,Qn=new Jn}(s,{createSVGElement:e=>r.addSVGElementFromJson(e),svgRoot:()=>l,svgContent:()=>c,getCurrentZoom:V});const H=this.selectorManager=Qn,X=r.getNextId=function(){return d().getNextId()},W=r.getId=function(){return d().getId()},ie=function(e,t){if(dt[e])return dt[e](window,t)},se=this.clearSelection=function(e){m.forEach(e=>{Qe(e)||H.releaseSelector(e)}),m=[],e||ie("selected",m)},oe=this.addToSelection=function(e,t){if(!e.length)return;let n=0;for(;n<m.length&&!Qe(m[n]);)++n;let i=e.length;for(;i--;){let t=e[i];if(!t)continue;const s=Ne(t);if(s&&("a"===t.tagName&&1===t.childNodes.length&&(t=t.firstChild),!m.includes(t))){m[n]=t,n++;const e=H.requestSelector(t,s);m.length>1&&e.showGrips(!1)}}if(m.length)for(ie("selected",m),1===m.length&&H.requestSelector(m[0]).showGrips(t),m.sort((function(e,t){return e&&t&&e.compareDocumentPosition?3-(6&t.compareDocumentPosition(e)):Qe(e)?1:0}));Qe(m[0]);)m.shift(0)},re=function(){return f.opacity},ae=this.getMouseTarget=function(n){if(Qe(n))return null;let i=n.target;if(i.correspondingUseElement&&(i=i.correspondingUseElement),[t.MATH,t.HTML].includes(i.namespaceURI)&&"svgcanvas"!==i.id)for(;"foreignObject"!==i.nodeName;)if(i=i.parentNode,!i)return l;const s=d().getCurrentLayer();if([l,e,c,s].includes(i))return l;if(ei(i).closest("#selectorParentGroup").length)return H.selectorParentGroup;for(;i.parentNode!==(p||s);)i=i.parentNode;return i};r.pathActions=E,At({selectorManager:H,canvas:r,call:ie,resetD:function(e){e.setAttribute("d",E.convertPath(e))},round:R,clearSelection:se,addToSelection:oe,addCommandToHistory:j,remapElement:Fn,addSVGElementFromJson:b,getGridSnapping:N,getOpacity:re,getSelectedElements:A,getContainer:()=>e,setStarted(e){De=e},getRubberBox:()=>tt,setRubberBox:e=>(tt=e,tt),addPtsToSelection({closedSubpath:e,grips:t}){E.canDeleteNodes=!0,E.closed_subpath=e,ie("pointsAdded",{closedSubpath:e,grips:t}),ie("selected",t)},endChanges({cmd:e,elem:t}){j(e),ie("changed",[t])},getCurrentZoom:V,getId:W,getNextId:X,getMouseTarget:ae,getCurrentMode:()=>Ke,setCurrentMode:e=>(Ke=e,Ke),getDrawnPath:()=>yt,setDrawnPath:e=>(yt=e,yt),getSVGRoot:P});const le={},ce="a,circle,ellipse,foreignObject,g,image,line,path,polygon,polyline,rect,svg,text,tspan,use",fe=["clip-path","fill","filter","marker-end","marker-mid","marker-start","mask","stroke"],me=ei.data,be=document.createElementNS(t.SVG,"animate");ei(be).attr({attributeName:"opacity",begin:"indefinite",dur:1,fill:"freeze"}).appendTo(l);const xe=function(e){const t=ei(e).attr(fe);Object.values(t).forEach(e=>{if(e&&e.startsWith("url(")){const t=ke(e).substr(1);He(t)||(Ee().append(Ve[t]),delete Ve[t])}});const n=e.getElementsByTagName("*");if(n.length)for(let e=0,t=n.length;e<t;e++)xe(n[e])},Pe={},Ie={round_digits:5},Te={},Le=g.text,je={},Ve={};let Re=s.imgPath+"logo.png",De=!1,$e=null,Ke="select",Ze="none",Je=f,et=null,tt=null,nt=[],it=null;this.runExtension=function(e,t,n){return this.runExtensions(t,n,!1,t=>t===e)};const rt=this.runExtensions=function(e,t,n,i){let s=!!n&&[];return ei.each(je,(function(o,r){i&&!i(o)||r&&e in r&&("function"==typeof t&&(t=t(o)),n?s.push(r[e](t)):s=r[e](t))})),s};this.addExtension=async function(e,t,{$:n,importLocale:i}){if("function"!=typeof t)throw new TypeError("Function argument expected for `svgcanvas.addExtension`");if(e in je)throw new Error('Cannot add extension "'+e+'", an extension by that name already exists.');const s=ei.extend(r.getPrivateMethods(),{$:n,importLocale:i,svgroot:l,svgcontent:c,nonce:d().getNonce(),selectorManager:H}),o=await t(s);return o&&(o.name=e),je[e]=o,ie("extension_added",o)};const lt=this.getIntersectionList=function(e){if(Qe(tt))return null;const t=p||d().getCurrentLayer();let n;if(e)n=c.createSVGRect(),n.x=e.x,n.y=e.y,n.width=e.width,n.height=e.height;else{n=tt.getBBox();const e=c.createSVGRect();["x","y","width","height","top","right","bottom","left"].forEach(t=>{e[t]=n[t]/h}),n=e}let i=null;if(k()||"function"==typeof l.getIntersectionList&&(n.x+=Number.parseInt(c.getAttribute("x")),n.y+=Number.parseInt(c.getAttribute("y")),i=l.getIntersectionList(n,t)),Qe(i)||"function"!=typeof i.item){i=[],nt.length||(nt=ct(t));let e=nt.length;for(;e--;)n.width&&ne(n,nt[e].bbox)&&i.push(nt[e].elem)}return i};this.getStrokedBBox=Ue,this.getVisibleElements=Be;const ct=this.getVisibleElementsAndBBoxes=function(e){e||(e=ei(c).children());const t=[];return ei(e).children().each((function(e,n){n.getBBox&&t.push({elem:n,bbox:Ue([n])})})),t.reverse()},ut=this.groupSvgElem=function(e){const n=document.createElementNS(t.SVG,"g");e.replaceWith(n),ei(n).append(e).data("gsvg",e)[0].id=X()},dt={};r.call=ie,r.bind=function(e,t){const n=dt[e];return dt[e]=t,n},this.prepareSvg=function(e){this.sanitizeSvg(e.documentElement);[...e.getElementsByTagNameNS(t.SVG,"path")].forEach(e=>{e.setAttribute("d",E.convertPath(e)),E.fixEnd(e)})};const ht=function(e){if(!S())return e;const t=e.cloneNode(!0);return e.before(t),e.remove(),H.releaseSelector(e),m[0]=t,H.requestSelector(t).showGrips(!0),t};this.setRotationAngle=function(e,t){e=Number.parseFloat(e);const n=m[0],i=n.getAttribute("transform"),s=Ne(n),o=s.x+s.width/2,r=s.y+s.height/2,a=O(n);if(a.numberOfItems>0){4===a.getItem(0).type&&a.removeItem(0)}if(0!==e){const t=$(o,r,J(a).matrix),n=l.createSVGTransform();n.setRotate(e,t.x,t.y),a.numberOfItems?a.insertItemBefore(n,0):a.appendItem(n)}else 0===a.numberOfItems&&n.removeAttribute("transform");if(!t){const e=n.getAttribute("transform");n.setAttribute("transform",i),Ot("transform",e,m),ie("changed",m)}H.requestSelector(m[0]).resize(),Zn.updateGripCursors(e)};const pt=this.recalculateAllSelectedDimensions=function(){const e=new oi("none"===Ze?"position":"size");let t=m.length;for(;t--;){const n=m[t],i=Xn(n);i&&e.addSubCommand(i)}e.isEmpty()||(j(e),ie("changed",m))},gt=function(e){console.log([e.a,e.b,e.c,e.d,e.e,e.f])};let mt=null;const _t=this.selectOnly=function(e,t){se(!0),oe(e,t)};this.removeFromSelection=function(e){if(Qe(m[0]))return;if(!e.length)return;const t=[],n=m.length;for(let i=0;i<n;++i){const n=m[i];n&&(e.includes(n)?H.releaseSelector(n):t.push(n))}m=t},this.selectAllInCurrentLayer=function(){const e=d().getCurrentLayer();e&&(Ke="select",_t(ei(p||e).children()))};let yt=null;!function(){const t={minx:null,miny:null,maxx:null,maxy:null};let n,i,o=null,a=null,u=null,g=null,_=null,y={},v=0,x={x:0,y:0},S={x:0,y:0},k={x:0,y:0},C={x:0,y:0},A={x:0,y:0},P={x:0,y:0};const N=function(e){const t={x:0,y:0},n=x,i=S,s=k,o=C,r=e*e,a=r*e,l=[[-1,3,-3,1],[3,-6,3,0],[-3,0,3,0],[1,4,1,0]];return t.x=1/6*((n.x*l[0][0]+i.x*l[0][1]+s.x*l[0][2]+o.x*l[0][3])*a+(n.x*l[1][0]+i.x*l[1][1]+s.x*l[1][2]+o.x*l[1][3])*r+(n.x*l[2][0]+i.x*l[2][1]+s.x*l[2][2]+o.x*l[2][3])*e+(n.x*l[3][0]+i.x*l[3][1]+s.x*l[3][2]+o.x*l[3][3])),t.y=1/6*((n.y*l[0][0]+i.y*l[0][1]+s.y*l[0][2]+o.y*l[0][3])*a+(n.y*l[1][0]+i.y*l[1][1]+s.y*l[1][2]+o.y*l[1][3])*r+(n.y*l[2][0]+i.y*l[2][1]+s.y*l[2][2]+o.y*l[2][3])*e+(n.y*l[3][0]+i.y*l[3][1]+s.y*l[3][2]+o.y*l[3][3])),{x:t.x,y:t.y}};ei(e).mousedown((function(e){if(r.spaceKey||1===e.button)return;const n=2===e.button;e.altKey&&r.cloneSelectedElements(0,0),mt=ei("#svgcontent g")[0].getScreenCTM().inverse();const i=$(e.pageX,e.pageY,mt),c=i.x*h,d=i.y*h;e.preventDefault(),n&&(Ke="select",it=i);let p=c/h,v=d/h,C=ae(e);"a"===C.tagName&&1===C.childNodes.length&&(C=C.firstChild);const A=p;g=a=p;const P=v;if(_=u=v,s.gridSnapping&&(p=We(p),v=We(v),a=We(a),u=We(u)),C===H.selectorParentGroup&&!Qe(m[0])){const t=e.target,n=me(t,"type");"rotate"===n?Ke="rotate":"resize"===n&&(Ke="resize",Ze=me(t,"dir")),C=m[0]}$e=C.getAttribute("transform");const N=O(C);switch(Ke){case"select":if(De=!0,Ze="none",n&&(De=!1),C!==l){if(m.includes(C)||(e.shiftKey||se(!0),oe([C]),et=C,E.clear()),!n)for(const e of m){if(Qe(e))continue;const t=O(e);t.numberOfItems?t.insertItemBefore(l.createSVGTransform(),0):t.appendItem(l.createSVGTransform())}}else n||(se(),Ke="multiselect",Qe(tt)&&(tt=H.getRubberBandBox()),g*=h,_*=h,qe(tt,{x:g,y:_,width:0,height:0,display:"inline"}));break;case"zoom":De=!0,Qe(tt)&&(tt=H.getRubberBandBox()),qe(tt,{x:A*h,y:A*h,width:0,height:0,display:"inline"});break;case"resize":{De=!0,a=p,u=v,y=Ne(ei("#selectedBox0")[0]);const e={};ei.each(y,(function(t,n){e[t]=n/h})),y=e;const t=Fe(C)?1:0;if(K(N))N.insertItemBefore(l.createSVGTransform(),t),N.insertItemBefore(l.createSVGTransform(),t),N.insertItemBefore(l.createSVGTransform(),t);else if(N.appendItem(l.createSVGTransform()),N.appendItem(l.createSVGTransform()),N.appendItem(l.createSVGTransform()),G()){const e=w();let t;e&&(t=function(e){const t=e.getAttribute("stroke");e.removeAttribute("stroke"),null!==t&&setTimeout((function(){e.setAttribute("stroke",t)}),0)}),C.style.vectorEffect="non-scaling-stroke",e&&t(C);const n=C.getElementsByTagName("*"),i=n.length;for(let s=0;s<i;s++)n[s].style&&(n[s].style.vectorEffect="non-scaling-stroke",e&&t(n[s]))}break}case"fhellipse":case"fhrect":case"fhpath":k.x=A,k.y=P,S={x:0,y:0},x={x:0,y:0},De=!0,o=A+","+P+" ",b({element:"polyline",curStyles:!0,attr:{points:o,id:X(),fill:"none",opacity:f.opacity/2,"stroke-linecap":"round",style:"pointer-events:none"}}),t.minx=A,t.maxx=A,t.miny=P,t.maxy=P;break;case"image":{De=!0;const e=b({element:"image",attr:{x:p,y:v,width:0,height:0,id:X(),opacity:f.opacity/2,style:"pointer-events:inherit"}});Ae(e,Re),Ye(e);break}case"square":case"rect":De=!0,a=p,u=v,b({element:"rect",curStyles:!0,attr:{x:p,y:v,width:0,height:0,id:X(),opacity:f.opacity/2}});break;case"line":{De=!0;const e=0===Number(f.stroke_width)?1:f.stroke_width;b({element:"line",curStyles:!0,attr:{x1:p,y1:v,x2:p,y2:v,id:X(),stroke:f.stroke,"stroke-width":e,"stroke-dasharray":f.stroke_dasharray,"stroke-linejoin":f.stroke_linejoin,"stroke-linecap":f.stroke_linecap,"stroke-opacity":f.stroke_opacity,fill:"none",opacity:f.opacity/2,style:"pointer-events:none"}});break}case"circle":De=!0,b({element:"circle",curStyles:!0,attr:{cx:p,cy:v,r:0,id:X(),opacity:f.opacity/2}});break;case"ellipse":De=!0,b({element:"ellipse",curStyles:!0,attr:{cx:p,cy:v,rx:0,ry:0,id:X(),opacity:f.opacity/2}});break;case"text":De=!0,b({element:"text",curStyles:!0,attr:{x:p,y:v,id:X(),fill:Le.fill,"stroke-width":Le.stroke_width,"font-size":Le.font_size,"font-family":Le.font_family,"text-anchor":"middle","xml:space":"preserve",opacity:f.opacity}});break;case"path":case"pathedit":a*=h,u*=h,E.mouseDown(e,C,a,u),De=!0;break;case"textedit":a*=h,u*=h,vt.mouseDown(e,C,a,u),De=!0;break;case"rotate":De=!0,r.undoMgr.beginUndoableChange("transform",m)}const I=rt("mouseDown",{event:e,start_x:a,start_y:u,selectedElements:m},!0);ei.each(I,(function(e,t){t&&t.started&&(De=!0)}))})).mousemove((function(e){if(!De)return;if(1===e.button||r.spaceKey)return;let o,d,p,f,b,w,G,I,T,L,M=m[0];const j=$(e.pageX,e.pageY,mt),V=j.x*h,R=j.y*h,B=He(W());let U,D=V/h,F=D,z=R/h,q=z;switch(s.gridSnapping&&(F=We(F),q=We(q)),e.preventDefault(),Ke){case"select":if(null!==m[0]&&(w=F-a,G=q-u,s.gridSnapping&&(w=We(w),G=We(G)),0!==w||0!==G)){for(I=m.length,o=0;o<I&&(M=m[o],!Qe(M));++o){const e=l.createSVGTransform();U=O(M),e.setTranslate(w,G),U.numberOfItems?U.replaceItem(e,0):U.appendItem(e),H.requestSelector(M).resize()}ie("transition",m)}break;case"multiselect":{D*=h,z*=h,qe(tt,{x:Math.min(g,D),y:Math.min(_,z),width:Math.abs(D-g),height:Math.abs(z-_)});const e=m.slice(),t=[],n=lt();for(I=n.length,o=0;o<I;++o){const i=n[o];m.includes(i)||t.push(i);const s=e.indexOf(i);-1!==s&&e.splice(s,1)}e.length>0&&r.removeFromSelection(e),t.length>0&&r.addToSelection(t);break}case"resize":{U=O(M);const t=K(U);L=t?y:Ne(M);let n=L.x,i=L.y,{width:o,height:r}=L;if(w=F-a,G=q-u,s.gridSnapping&&(w=We(w),G=We(G),r=We(r),o=We(o)),T=Fe(M),T){const e=Math.sqrt(w*w+G*G),t=Math.atan2(G,w)-T*Math.PI/180;w=e*Math.cos(t),G=e*Math.sin(t)}Ze.includes("n")||Ze.includes("s")||(G=0),Ze.includes("e")||Ze.includes("w")||(w=0);let c=0,d=0,h=r?(r+G)/r:1,p=o?(o+w)/o:1;Ze.includes("n")&&(h=r?(r-G)/r:1,d=r),Ze.includes("w")&&(p=o?(o-w)/o:1,c=o);const g=l.createSVGTransform(),f=l.createSVGTransform(),_=l.createSVGTransform();if(s.gridSnapping&&(n=We(n),c=We(c),i=We(i),d=We(d)),g.setTranslate(-(n+c),-(i+d)),e.shiftKey&&(1===p?p=h:h=p),f.setScale(p,h),_.setTranslate(n+c,i+d),t){const e=T?1:0;U.replaceItem(g,2+e),U.replaceItem(f,1+e),U.replaceItem(_,Number(e))}else{const e=U.numberOfItems;U.replaceItem(_,e-3),U.replaceItem(f,e-2),U.replaceItem(g,e-1)}H.requestSelector(M).resize(),ie("transition",m);break}case"zoom":D*=h,z*=h,qe(tt,{x:Math.min(g*h,D),y:Math.min(_*h,z),width:Math.abs(D-g*h),height:Math.abs(z-_*h)});break;case"text":qe(B,{x:F,y:q});break;case"line":{s.gridSnapping&&(F=We(F),q=We(q));let t=F,n=q;e.shiftKey&&(d=te(a,u,t,n),t=d.x,n=d.y),B.setAttribute("x2",t),B.setAttribute("y2",n);break}case"foreignObject":case"square":case"rect":case"image":{const t="square"===Ke||e.shiftKey;let n,i,o=Math.abs(F-a),r=Math.abs(q-u);t?(o=r=Math.max(o,r),n=a<F?a:a-o,i=u<q?u:u-r):(n=Math.min(a,F),i=Math.min(u,q)),s.gridSnapping&&(o=We(o),r=We(r),n=We(n),i=We(i)),qe(B,{width:o,height:r,x:n,y:i});break}case"circle":{p=ei(B).attr(["cx","cy"]),({cx:f,cy:b}=p);let e=Math.sqrt((F-f)*(F-f)+(q-b)*(q-b));s.gridSnapping&&(e=We(e)),B.setAttribute("r",e);break}case"ellipse":{p=ei(B).attr(["cx","cy"]),({cx:f,cy:b}=p),s.gridSnapping&&(F=We(F),f=We(f),q=We(q),b=We(b)),B.setAttribute("rx",Math.abs(F-f));const t=Math.abs(e.shiftKey?F-f:q-b);B.setAttribute("ry",t);break}case"fhellipse":case"fhrect":t.minx=Math.min(D,t.minx),t.maxx=Math.max(D,t.maxx),t.miny=Math.min(z,t.miny),t.maxy=Math.max(z,t.maxy);case"fhpath":if(C.x=D,C.y=z,x.x&&x.y)for(o=0;o<9;o++)if(n=o/10,i=(o+1)/10,A=N(i),P=A,A=N(n),v+=Math.sqrt((P.x-A.x)*(P.x-A.x)+(P.y-A.y)*(P.y-A.y)),v>.8){v-=.8;const e=c.createSVGPoint();e.x=A.x,e.y=A.y,B.points.appendItem(e)}x={x:S.x,y:S.y},S={x:k.x,y:k.y},k={x:C.x,y:C.y};break;case"path":case"pathedit":if(F*=h,q*=h,s.gridSnapping&&(F=We(F),q=We(q),a=We(a),u=We(u)),e.shiftKey){const{path:e}=sn;let t,n;e?(t=e.dragging?e.dragging[0]:a,n=e.dragging?e.dragging[1]:u):(t=a,n=u),d=te(t,n,F,q),({x:F,y:q}=d)}tt&&"none"!==tt.getAttribute("display")&&(D*=h,z*=h,qe(tt,{x:Math.min(g*h,D),y:Math.min(_*h,z),width:Math.abs(D-g*h),height:Math.abs(z-_*h)})),E.mouseMove(F,q);break;case"textedit":F*=h,q*=h,vt.mouseMove(V,R);break;case"rotate":{L=Ne(M),f=L.x+L.width/2,b=L.y+L.height/2;const t=ee(M),n=$(f,b,t);if(f=n.x,b=n.y,T=(Math.atan2(b-q,f-F)*(180/Math.PI)-90)%360,s.gridSnapping&&(T=We(T)),e.shiftKey){const e=45;T=Math.round(T/e)*e}r.setRotationAngle(T<-180?360+T:T,!0),ie("transition",m);break}}rt("mouseMove",{event:e,mouse_x:V,mouse_y:R,selected:M})})).click((function(e){return e.preventDefault(),!1})).dblclick((function(e){const t=e.target.parentNode;let n=ae(e);const{tagName:i}=n;if("text"===i&&"textedit"!==Ke){const t=$(e.pageX,e.pageY,mt);vt.select(n,t.x,t.y)}t!==p&&("g"!==i&&"a"!==i||!Fe(n)||(Rt(n),n=m[0],se(!0)),p&&Ln(),"g"!==t.tagName&&"a"!==t.tagName||t===d().getCurrentLayer()||n===H.selectorParentGroup||Mn(n))})).mouseup((function(e){if(2===e.button)return;const n=et;if(et=null,!De)return;const i=$(e.pageX,e.pageY,mt),o=i.x*h,a=i.y*h,l=o/h,c=a/h;let u=He(W()),p=!1;const y=l,w=c;let A,P;switch(De=!1,Ke){case"resize":case"multiselect":Qe(tt)||(tt.setAttribute("display","none"),nt=[]),Ke="select";case"select":if(!Qe(m[0])){if(Qe(m[1])){const e=m[0];switch(e.tagName){case"g":case"use":case"image":case"foreignObject":break;default:Je.fill=e.getAttribute("fill"),Je.fill_opacity=e.getAttribute("fill-opacity"),Je.stroke=e.getAttribute("stroke"),Je.stroke_opacity=e.getAttribute("stroke-opacity"),Je.stroke_width=e.getAttribute("stroke-width"),Je.stroke_dasharray=e.getAttribute("stroke-dasharray"),Je.stroke_linejoin=e.getAttribute("stroke-linejoin"),Je.stroke_linecap=e.getAttribute("stroke-linecap")}"text"===e.tagName&&(Le.font_size=e.getAttribute("font-size"),Le.font_family=e.getAttribute("font-family")),H.requestSelector(e).showGrips(!0)}if(pt(),y!==g||w!==_){const e=m.length;for(let t=0;t<e&&!Qe(m[t]);++t)m[t].firstChild||H.requestSelector(m[t]).resize()}else P=e.target,"path"===m[0].nodeName&&Qe(m[1])?E.select(m[0]):e.shiftKey&&n!==P&&r.removeFromSelection([P]);if(G()){const e=m[0];e&&(e.removeAttribute("style"),we(e,(function(e){e.removeAttribute("style")})))}}return;case"zoom":{Qe(tt)||tt.setAttribute("display","none");const t=e.shiftKey?.5:2;return void ie("zoomed",{x:Math.min(g,y),y:Math.min(_,w),width:Math.abs(y-g),height:Math.abs(w-_),factor:t})}case"fhpath":{v=0,x={x:0,y:0},S={x:0,y:0},k={x:0,y:0},C={x:0,y:0};const e=u.getAttribute("points"),t=e.indexOf(",");p=t>=0?e.includes(",",t+1):e.includes(" ",e.indexOf(" ")+1),p&&(u=E.smoothPolylineIntoPath(u));break}case"line":A=ei(u).attr(["x1","x2","y1","y2"]),p=A.x1!==A.x2||A.y1!==A.y2;break;case"foreignObject":case"square":case"rect":case"image":A=ei(u).attr(["width","height"]),p=A.width||A.height||"image"===Ke;break;case"circle":p="0"!==u.getAttribute("r");break;case"ellipse":A=ei(u).attr(["rx","ry"]),p=A.rx||A.ry;break;case"fhellipse":t.maxx-t.minx>0&&t.maxy-t.miny>0&&(u=b({element:"ellipse",curStyles:!0,attr:{cx:(t.minx+t.maxx)/2,cy:(t.miny+t.maxy)/2,rx:(t.maxx-t.minx)/2,ry:(t.maxy-t.miny)/2,id:W()}}),ie("changed",[u]),p=!0);break;case"fhrect":t.maxx-t.minx>0&&t.maxy-t.miny>0&&(u=b({element:"rect",curStyles:!0,attr:{x:t.minx,y:t.miny,width:t.maxx-t.minx,height:t.maxy-t.miny,id:W()}}),ie("changed",[u]),p=!0);break;case"text":p=!0,_t([u]),vt.start(u);break;case"path":{u=null,De=!0;const t=E.mouseUp(e,u,o,a);({element:u}=t),({keep:p}=t);break}case"pathedit":p=!0,u=null,E.mouseUp(e);break;case"textedit":p=!1,u=null,vt.mouseUp(e,o,a);break;case"rotate":{p=!0,u=null,Ke="select";const e=r.undoMgr.finishUndoableChange();e.isEmpty()||j(e),pt(),ie("changed",m);break}}const N=rt("mouseUp",{event:e,mouse_x:o,mouse_y:a},!0);if(ei.each(N,(function(e,t){t&&(p=t.keep||p,({element:u}=t),De=t.started||De)})),p||Qe(u)){if(!Qe(u)){r.addedNew=!0;let e,t=.2;if(be.beginElement&&Number.parseFloat(u.getAttribute("opacity"))!==f.opacity){e=ei(be).clone().attr({to:f.opacity,dur:t}).appendTo(u);try{e[0].beginElement()}catch(e){}}else t=0;setTimeout((function(){e&&e.remove(),u.setAttribute("opacity",f.opacity),u.setAttribute("style","pointer-events:inherit"),Xe(u),"path"===Ke?E.toEditMode(u):s.selectNew&&_t([u],!0),j(new ni(u)),ie("changed",[u])}),1e3*t)}}else{for(d().releaseId(W()),u.remove(),u=null,P=e.target;P&&P.parentNode&&P.parentNode.parentNode&&"g"===P.parentNode.parentNode.tagName;)P=P.parentNode;"path"===Ke&&yt||!P||!P.parentNode||"selectorParentGroup"===P.parentNode.id||"svgcanvas"===P.id||"svgroot"===P.id||(r.setMode("select"),_t([P],!0))}$e=null})),ei(e).bind("mousewheel DOMMouseScroll",(function(e){if(!e.shiftKey)return;e.preventDefault();const t=e.originalEvent;mt=ei("#svgcontent g")[0].getScreenCTM().inverse();const n=ei("#workarea"),i=s.showRulers?16:0,o=$(t.pageX,t.pageY,mt),a=n.width(),l=n.height(),c=a-15-i,u=l-15-i,d=c*mt.a,p=u*mt.d,g=n.offset(),f=g.left+i,m=g.top+i,_=t.wheelDelta?t.wheelDelta:t.detail?-t.detail:0;if(!_)return;let y,b,v=Math.max(3/4,Math.min(4/3,_));v>1?(y=Math.ceil(c/d*v*100)/100,b=Math.ceil(u/p*v*100)/100):(y=Math.floor(c/d*v*100)/100,b=Math.floor(u/p*v*100)/100);let x=Math.min(y,b);if(x=Math.min(10,Math.max(.01,x)),x===h)return;v=x/h;const w=$(f,m,mt),S={x:(o.x-(o.x-w.x)/v)*x-i+a/2,y:(o.y-(o.y-w.y)/v)*x-i+l/2};r.setZoom(x),ei("#zoom").val((100*x).toFixed(1)),ie("updateCanvas",{center:!1,newCtr:S}),ie("zoomDone")}))}();const vt=r.textActions=function(){let e,n,i,s,o,a,c,u,d,p,g=[];function f(e){const r=""===n.value;if(ei(n).focus(),!arguments.length)if(r)e=0;else{if(n.selectionEnd!==n.selectionStart)return;e=n.selectionEnd}const l=g[e];r||n.setSelectionRange(e,e),i=He("text_cursor"),i||(i=document.createElementNS(t.SVG,"line"),qe(i,{id:"text_cursor",stroke:"#333","stroke-width":1}),i=He("selectorParentGroup").appendChild(i)),o||(o=setInterval((function(){const e="none"===i.getAttribute("display");i.setAttribute("display",e?"inline":"none")}),600));const c=S(l.x,a.y),u=S(l.x,a.y+a.height);qe(i,{x1:c.x,y1:c.y,x2:u.x,y2:u.y,visibility:"visible",display:"inline"}),s&&s.setAttribute("d","")}function y(e,o,r){if(e===o)return void f(o);r||n.setSelectionRange(e,o),s=He("text_selectblock"),s||(s=document.createElementNS(t.SVG,"path"),qe(s,{id:"text_selectblock",fill:"green",opacity:.5,style:"pointer-events:none"}),He("selectorParentGroup").append(s));const l=g[e],c=g[o];i.setAttribute("visibility","hidden");const u=S(l.x,a.y),d=S(l.x+(c.x-l.x),a.y),h=S(l.x,a.y+a.height),p=S(l.x+(c.x-l.x),a.y+a.height),m="M"+u.x+","+u.y+" L"+d.x+","+d.y+" "+p.x+","+p.y+" "+h.x+","+h.y+"z";qe(s,{d:m,display:"inline"})}function b(t,n){const i=l.createSVGPoint();if(i.x=t,i.y=n,1===g.length)return 0;let s=e.getCharNumAtPosition(i);s<0?(s=g.length-2,t<=g[0].x&&(s=0)):s>=g.length-2&&(s=g.length-2);const o=g[s];return t>o.x+o.width/2&&s++,s}function v(e,t){f(b(e,t))}function x(e,t,i){const s=n.selectionStart,o=b(e,t);y(Math.min(s,o),Math.max(s,o),!i)}function w(e,t){const n={x:e,y:t};if(n.x/=h,n.y/=h,c){const e=$(n.x,n.y,c.inverse());n.x=e.x,n.y=e.y}return n}function S(e,t){const n={x:e,y:t};if(c){const e=$(n.x,n.y,c);n.x=e.x,n.y=e.y}return n.x*=h,n.y*=h,n}function k(t){y(0,e.textContent.length),ei(this).unbind(t)}function C(t){if(!p||!e)return;const n=$(t.pageX,t.pageY,mt),i=w(n.x*h,n.y*h),s=b(i.x,i.y),o=e.textContent,r=o.substr(0,s).replace(/[a-z\d]+$/i,"").length,a=o.substr(s).match(/^[a-z\d]+/i);y(r,(a?a[0].length:0)+s),ei(t.target).click(k),setTimeout((function(){ei(t.target).unbind("click",k)}),300)}return{select(t,n,i){e=t,vt.toEditMode(n,i)},start(t){e=t,vt.toEditMode()},mouseDown(e,t,i,s){const o=w(i,s);n.focus(),v(o.x,o.y),u=i,d=s},mouseMove(e,t){const n=w(e,t);x(n.x,n.y)},mouseUp(t,n,i){const s=w(n,i);x(s.x,s.y,!0),t.target!==e&&n<u+2&&n>u-2&&i<d+2&&i>d-2&&vt.toSelectMode(!0)},setCursor:f,toEditMode(t,n){if(p=!1,Ke="textedit",H.requestSelector(e).showGrips(!1),H.requestSelector(e),vt.init(),ei(e).css("cursor","text"),arguments.length){const e=w(t,n);v(e.x,e.y)}else f();setTimeout((function(){p=!0}),300)},toSelectMode(t){Ke="select",clearInterval(o),o=null,s&&ei(s).attr("display","none"),i&&ei(i).attr("visibility","hidden"),ei(e).css("cursor","move"),t&&(se(),ei(e).css("cursor","move"),ie("selected",[e]),oe([e],!0)),e&&!e.textContent.length&&r.deleteSelectedElements(),ei(n).blur(),e=!1},setInputElem(e){n=e},clear(){"textedit"===Ke&&vt.toSelectMode()},init(t){if(!e)return;let i,s;e.parentNode||(e=m[0],H.requestSelector(e).showGrips(!1));const o=e.textContent.length,l=e.getAttribute("transform");for(a=Ne(e),c=l?ee(e):null,g=[],g.length=o,n.focus(),ei(e).unbind("dblclick",C).dblclick(C),o||(s={x:a.x+a.width/2,width:0}),i=0;i<o;i++){const t=e.getStartPositionOfChar(i);if(s=e.getEndPositionOfChar(i),!_){const e=r.contentW*h;t.x-=e,s.x-=e,t.x/=h,s.x/=h}g[i]={x:t.x,y:a.y,width:s.x-t.x,height:a.height}}g.push({x:s.x,width:0}),y(n.selectionStart,n.selectionEnd,!0)}}}(),xt=this.removeUnusedDefElems=function(){const e=c.getElementsByTagNameNS(t.SVG,"defs");if(!e||!e.length)return 0;const n=[];let i=0;const s=["fill","stroke","filter","marker-start","marker-mid","marker-end"],o=s.length,r=c.getElementsByTagNameNS(t.SVG,"*"),a=r.length;let l,u;for(l=0;l<a;l++){const e=r[l];for(u=0;u<o;u++){const t=ke(e.getAttribute(s[u]));t&&n.push(t.substr(1))}const t=Ce(e);t&&t.startsWith("#")&&n.push(t.substr(1))}const d=ei(e).find("linearGradient, radialGradient, filter, marker, svg, symbol");for(l=d.length;l--;){const e=d[l],{id:t}=e;n.includes(t)||(Ve[t]=e,e.remove(),i++)}return i};function wt(){se();const e=[],t=[],n={feGaussianBlur:le.exportNoBlur,foreignObject:le.exportNoforeignObject,"[stroke-dasharray]":le.exportNoDashArray},i=ei(c);return"font"in ei("<canvas>")[0].getContext("2d")||(n.text=le.exportNoText),ei.each(n,(function(n,s){i.find(n).length&&(t.push(n),e.push(s))})),{issues:e,issueCodes:t}}let St;this.svgCanvasToString=function(){for(;xt()>0;);E.clear(!0),ei.each(c.childNodes,(function(e,t){e&&8===t.nodeType&&t.data.includes("Created with")&&c.firstChild.before(t)})),p&&(Ln(),_t([p]));const e=[];ei(c).find("g:data(gsvg)").each((function(){const t=this.attributes;let n=t.length;for(let e=0;e<n;e++)"id"!==t[e].nodeName&&"style"!==t[e].nodeName||n--;if(n<=0){const t=this.firstChild;e.push(t),ei(this).replaceWith(t)}}));const t=this.svgToString(c,0);return e.length&&ei(e).each((function(){ut(this)})),t},this.svgToString=function(e,n){const i=[],o=s.baseUnit,r=new RegExp("^-?[\\d\\.]+"+o+"$");if(e){Xe(e);const s=[...e.attributes],a=e.childNodes;s.sort((e,t)=>e.name>t.name?-1:1);for(let e=0;e<n;e++)i.push(" ");if(i.push("<"),i.push(e.nodeName),"svgcontent"===e.id){const n=Nt(),r="";"px"!==o&&(n.w=z(n.w,o)+o,n.h=z(n.h,o)+o),i.push(' width="'+n.w+'" height="'+n.h+'"'+r+' xmlns="'+t.SVG+'"');const a={};ei(e).find("*").andSelf().each((function(){const e=this.namespaceURI;e&&!a[e]&&I[e]&&"xmlns"!==I[e]&&"xml"!==I[e]&&(a[e]=!0,i.push(" xmlns:"+I[e]+'="'+e+'"')),ei.each(this.attributes,(function(e,t){const n=t.namespaceURI;n&&!a[n]&&"xmlns"!==I[n]&&"xml"!==I[n]&&(a[n]=!0,i.push(" xmlns:"+I[n]+'="'+n+'"'))}))}));let l=s.length;const c=["width","height","xmlns","x","y","viewBox","id","overflow"];for(;l--;){const e=s[l],t=he(e.value);e.nodeName.startsWith("xmlns:")||(""===t||c.includes(e.localName)||e.namespaceURI&&!I[e.namespaceURI]||(i.push(" "),i.push(e.nodeName),i.push('="'),i.push(t),i.push('"')))}}else{if("defs"===e.nodeName&&!e.firstChild)return"";const n=["-moz-math-font-style","_moz-math-font-style"];for(let a=s.length-1;a>=0;a--){const l=s[a];let c=he(l.value);if(!n.includes(l.localName)){if("null"===c){const t=l.localName.replace(/-[a-z]/g,e=>e[1].toUpperCase());if(Object.prototype.hasOwnProperty.call(e.style,t))continue}if(""!==c){if(c.startsWith("pointer-events"))continue;if("class"===l.localName&&c.startsWith("se_"))continue;if(i.push(" "),"d"===l.localName&&(c=E.convertPath(e,!0)),isNaN(c)?r.test(c)&&(c=F(c)+o):c=F(c),Ie.apply&&"image"===e.nodeName&&"href"===l.localName&&Ie.images&&"embed"===Ie.images){const e=Pe[c];e&&(c=e)}l.namespaceURI&&l.namespaceURI!==t.SVG&&!I[l.namespaceURI]||(i.push(l.nodeName),i.push('="'),i.push(c),i.push('"'))}}}}if(e.hasChildNodes()){i.push(">"),n++;let t=!1;for(let e=0;e<a.length;e++){const s=a.item(e);switch(s.nodeType){case 1:i.push("\n"),i.push(this.svgToString(s,n));break;case 3:{const e=s.nodeValue.replace(/^\s+|\s+$/g,"");""!==e&&(t=!0,i.push(String(he(e))));break}case 4:i.push("\n"),i.push(new Array(n+1).join(" ")),i.push("<![CDATA["),i.push(s.nodeValue),i.push("]]>");break;case 8:i.push("\n"),i.push(new Array(n+1).join(" ")),i.push("\x3c!--"),i.push(s.data),i.push("--\x3e")}}if(n--,!t){i.push("\n");for(let e=0;e<n;e++)i.push(" ")}i.push("</"),i.push(e.nodeName),i.push(">")}else i.push("/>")}return i.join("")},this.embedImage=function(e){return new Promise((function(t,n){ei(new Image).load((function(i,s,o){if("error"===s)return void n(new Error("Error loading image: "+o.status+" "+o.statusText));const r=document.createElement("canvas");r.width=this.width,r.height=this.height,r.getContext("2d").drawImage(this,0,0);try{let t=";svgedit_url="+encodeURIComponent(e);t=r.toDataURL().replace(";base64",t+";base64"),Pe[e]=t}catch(t){Pe[e]=!1}Re=e,t(Pe[e])})).attr("src",e)}))},this.setGoodImage=function(e){Re=e},this.open=function(){},this.save=function(e){se(),e&&ei.extend(Ie,e),Ie.apply=!0;const t=this.svgCanvasToString();ie("saved",t)},this.rasterExport=async function(e,t,n,i={}){const o="ICO"===e?"BMP":e||"PNG",a="image/"+o.toLowerCase(),{issues:l,issueCodes:c}=wt(),u=this.svgCanvasToString();St||({canvg:St}=await st(s.canvgPath+"canvg.js",{global:"canvg"})),ei("#export_canvas").length||ei("<canvas>",{id:"export_canvas"}).hide().appendTo("body");const d=ei("#export_canvas")[0];return d.width=r.contentW,d.height=r.contentH,await St(d,u),new Promise((s,r)=>{const h=o.toLowerCase(),p=t?d.toDataURL("image/"+h,t):d.toDataURL("image/"+h);let g;function f(){const o={datauri:p,bloburl:g,svg:u,issues:l,issueCodes:c,type:e,mimeType:a,quality:t,exportWindowName:n};i.avoidEvent||ie("exported",o),s(o)}d.toBlob?d.toBlob(e=>{g=ye(e),f()},a,t):(g=_e(p),f())})},this.exportPDF=async function(e,t=(C()?"save":void 0)){if(!window.jsPDF){await ot(["jspdf/underscore-min.js","../../svgedit-myfix/editor/jspdf/jspdf-1.0.150.debug.js"]);const e=!("svgEditor"in window)||!window.svgEditor||!1!==window.svgEditor.modules;await ot(s.jspdfPath+"jspdf.plugin.svgToPdf.js",{type:e?"module":"text/javascript"})}const n=Nt(),i=n.w>n.h?"landscape":"portrait",o=jsPDF({orientation:i,unit:"pt",format:[n.w,n.h]}),r=It();o.setProperties({title:r});const{issues:a,issueCodes:l}=wt(),c=this.svgCanvasToString();o.addSVG(c,0,0);const u={svg:c,issues:a,issueCodes:l,exportWindowName:e,outputType:t=t||"dataurlstring"};return u.output=o.output(t,"save"===t?e||"svg.pdf":void 0),ie("exportedPDF",u),u},this.getSvgString=function(){return Ie.apply=!1,this.svgCanvasToString()},this.randomizeIds=function(e){vn(!(arguments.length>0&&!1===e),d())};const kt=this.uniquifyElems=function(e){const t={},n=["filter","linearGradient","pattern","radialGradient","symbol","textPath","use"];we(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),ei.each(fe,(function(n,i){const s=e.getAttributeNode(i);if(s){const e=ke(s.value),n=e?e.substr(1):null;n&&(n in t||(t[n]={elem:null,attrs:[],hrefs:[]}),t[n].attrs.push(s))}}));const i=Ce(e);if(i&&n.includes(e.nodeName)){const n=i.substr(1);n&&(n in t||(t[n]={elem:null,attrs:[],hrefs:[]}),t[n].hrefs.push(e))}}}));for(const e in t){if(!e)continue;const{elem:n}=t[e];if(n){const i=X();n.id=i;const{attrs:s}=t[e];let o=s.length;for(;o--;){const e=s[o];e.ownerElement.setAttribute(e.name,"url(#"+i+")")}const r=t[e].hrefs;let a=r.length;for(;a--;){const e=r[a];Ae(e,"#"+i)}}}},Ct=this.setUseData=function(e){let t=ei(e);"use"!==e.tagName&&(t=t.find("use")),t.each((function(){const e=Ce(this).substr(1),t=He(e);t&&(ei(this).data("ref",t),"symbol"!==t.tagName&&"svg"!==t.tagName||ei(this).data("symbol",t).data("ref",t))}))},Et=this.convertGradients=function(e){let t=ei(e).find("linearGradient, radialGradient");!t.length&&w()&&(t=ei(e).find("*").filter((function(){return this.tagName.includes("Gradient")}))),t.each((function(){const e=this;if("userSpaceOnUse"===ei(e).attr("gradientUnits")){const t=ei(c).find('[fill="url(#'+e.id+')"],[stroke="url(#'+e.id+')"]');if(!t.length)return;const n=Ne(t[0]);if(!n)return;if("linearGradient"===e.tagName){const t=ei(e).attr(["x1","y1","x2","y2"]),i=e.gradientTransform.baseVal;if(i&&i.numberOfItems>0){const n=J(i).matrix,s=$(t.x1,t.y1,n),o=$(t.x2,t.y2,n);t.x1=s.x,t.y1=s.y,t.x2=o.x,t.y2=o.y,e.removeAttribute("gradientTransform")}ei(e).attr({x1:(t.x1-n.x)/n.width,y1:(t.y1-n.y)/n.height,x2:(t.x2-n.x)/n.width,y2:(t.y2-n.y)/n.height}),e.removeAttribute("gradientUnits")}}}))},Gt=this.convertToGroup=function(e){e||(e=m[0]);const n=ei(e),i=new oi;let s;if(n.data("gsvg")){const t=e.firstChild,n=ei(t).attr(["x","y"]);ei(e.firstChild.firstChild).unwrap(),ei(e).removeData("gsvg");const i=O(e),s=l.createSVGTransform();s.setTranslate(n.x,n.y),i.appendItem(s),Xn(e),ie("selected",[e])}else if(n.data("symbol")){e=n.data("symbol"),s=n.attr("transform");const o=n.attr(["x","y"]),r=e.getAttribute("viewBox");if(r){const e=r.split(" ");o.x-=Number(e[0]),o.y-=Number(e[1])}s+=" translate("+(o.x||0)+","+(o.y||0)+")";const l=n.prev();i.addSubCommand(new ii(n[0],n[0].nextSibling,n[0].parentNode)),n.remove();const u=ei(c).find("use:data(symbol)").length,d=a.createElementNS(t.SVG,"g"),h=e.childNodes;let p;for(p=0;p<h.length;p++)d.append(h[p].cloneNode(!0));if(S()){const e=ei(Ee()).children("linearGradient,radialGradient,pattern").clone();ei(d).append(e)}s&&d.setAttribute("transform",s);const g=e.parentNode;if(kt(d),S()&&ei(Ee()).append(ei(d).find("linearGradient,radialGradient,pattern")),d.id=X(),l.after(d),g){if(!u){const{nextSibling:t}=e;e.remove(),i.addSubCommand(new ii(e,t,g))}i.addSubCommand(new ni(d))}Ct(d),S()?Et(Ee()):Et(d),Se(d,(function(e){try{Xn(e)}catch(e){console.log(e)}})),ei(d).find(ce).each((function(){this.id||(this.id=X())})),_t([d]);const f=Rt(d,!0);f&&i.addSubCommand(f),j(i)}else console.log("Unexpected element to ungroup:",e)};this.setSvgString=function(e,n){try{const i=ve(e);if(i.firstElementChild&&i.firstElementChild.namespaceURI!==t.SVG)return!1;this.prepareSvg(i);const o=new oi("Change Source"),{nextSibling:p}=c;c.remove();const g=c;o.addSubCommand(new ii(g,p,l)),c=a.adoptNode?a.adoptNode(i.documentElement):a.importNode(i.documentElement,!0),l.append(c);const f=ei(c);r.current_drawing_=new bn(c,u);const m=d().getNonce();m?ie("setnonce",m):ie("unsetnonce"),f.find("image").each((function(){const e=this;Ye(e);const n=Ce(this);if(n){if(n.startsWith("data:")){const i=n.match(/svgedit_url=(.*?);/);if(i){const n=decodeURIComponent(i[1]);ei(new Image).load((function(){e.setAttributeNS(t.XLINK,"xlink:href",n)})).attr("src",n)}}r.embedImage(n)}})),f.find("svg").each((function(){if(ei(this).closest("defs").length)return;kt(this);const e=this.parentNode;1===e.childNodes.length&&"g"===e.nodeName?(ei(e).data("gsvg",this),e.id=e.id||X()):ut(this)})),S()&&f.find("linearGradient, radialGradient, pattern").appendTo(Ee()),Ct(f),Et(f[0]);const _={id:"svgcontent",overflow:s.show_outside_canvas?"visible":"hidden"};let y=!1;if(f.attr("viewBox")){const e=f.attr("viewBox").split(" ");_.width=e[2],_.height=e[3]}else ei.each(["width","height"],(function(e,t){const n=f.attr(t)||"100%";"%"===String(n).substr(-1)?y=!0:_[t]=q(t,n)}));if(wn(),f.children().find(ce).each((function(){this.id||(this.id=X())})),y){const e=Ue();_.width=e.width+e.x,_.height=e.height+e.y}_.width<=0&&(_.width=100),_.height<=0&&(_.height=100),f.attr(_),this.contentW=_.width,this.contentH=_.height,o.addSubCommand(new ni(c));const b=f.attr(["width","height"]);o.addSubCommand(new si(l,b)),h=1,T={},se(),Kt(),l.append(H.selectorParentGroup),n||j(o),ie("changed",[c])}catch(e){return console.log(e),!1}return!0},this.importSvgString=function(e){let n,i,s;try{const o=pe(e.length+e).substr(0,32);let r=!1;Te[o]&&ei(Te[o].symbol).parents("#svgroot").length&&(r=!0);const l=new oi("Import Image");let u;if(r)({symbol:u}=Te[o]),i=Te[o].xform;else{const s=ve(e);let r;this.prepareSvg(s),r=a.adoptNode?a.adoptNode(s.documentElement):a.importNode(s.documentElement,!0),kt(r);const d=q("width",r.getAttribute("width")),h=q("height",r.getAttribute("height")),p=r.getAttribute("viewBox"),g=p?p.split(" "):[0,0,d,h];for(n=0;n<4;++n)g[n]=Number(g[n]);const f=Number(c.getAttribute("height"));i=h>d?"scale("+f/3/g[3]+")":"scale("+f/3/g[2]+")",i="translate(0) "+i+" translate(0)",u=a.createElementNS(t.SVG,"symbol");const m=Ee();for(S()&&ei(r).find("linearGradient, radialGradient, pattern").appendTo(m);r.firstChild;){const e=r.firstChild;u.append(e)}const _=r.attributes;for(const e of _)u.setAttribute(e.nodeName,e.value);u.id=X(),Te[o]={symbol:u,xform:i},Ee().append(u),l.addSubCommand(new ni(u))}s=a.createElementNS(t.SVG,"use"),s.id=X(),Ae(s,"#"+u.id),(p||d().getCurrentLayer()).append(s),l.addSubCommand(new ni(s)),se(),s.setAttribute("transform",i),Xn(s),ei(s).data("symbol",u).data("ref",u),oe([s]),j(l),ie("changed",[c])}catch(e){return console.log(e),null}return s};const Pt={identifyLayers:wn,createLayer:Sn,cloneLayer:kn,deleteCurrentLayer:Cn,setCurrentLayer:An,renameCurrentLayer:En,setCurrentLayerPosition:Gn,setLayerVisibility:Pn,moveSelectedToLayer:Nn,mergeLayer:In,mergeAllLayers:Tn,leaveContext:Ln,setContext:Mn};Object.entries(Pt).forEach(([e,t])=>{r[e]=t}),function(e){xn=e}({pathActions:E,getCurrentGroup:()=>p,setCurrentGroup(e){p=e},getSelectedElements:A,getSVGContent:x,undoMgr:M,elData:me,getCurrentDrawing:d,clearSelection:se,call:ie,addCommandToHistory:j,changeSVGContent(){ie("changed",[c])}}),this.clear=function(){E.clear(),se(),r.clearSvgContentElement(),r.current_drawing_=new bn(c),r.createLayer("Layer 1"),r.undoMgr.resetUndoStack(),H.initGroup(),tt=H.getRubberBandBox(),ie("cleared")},this.linkControlPoints=E.linkControlPoints,this.getContentElem=function(){return c},this.getRootElem=function(){return l};const Nt=this.getResolution=function(){return{w:c.getAttribute("width")/h,h:c.getAttribute("height")/h,zoom:h}};this.getSnapToGrid=function(){return s.gridSnapping},this.getVersion=function(){return"svgcanvas.js ($Rev$)"},this.setUiStrings=function(e){Object.assign(le,e.notification),ei=at(ei,e.common),bt(e)},this.setConfig=function(e){Object.assign(s,e)},this.getTitle=function(e){if(!(e=e||m[0]))return;const t=(e=ei(e).data("gsvg")||ei(e).data("symbol")||e).childNodes;for(const e of t)if("title"===e.nodeName)return e.textContent;return""},this.setGroupTitle=function(e){let n=m[0];n=ei(n).data("gsvg")||n;const i=ei(n).children("title"),s=new oi("Set Label");let o;if(e.length)i.length?(o=i[0],s.addSubCommand(new si(o,{"#text":o.textContent})),o.textContent=e):(o=a.createElementNS(t.SVG,"title"),o.textContent=e,ei(n).prepend(o),s.addSubCommand(new ni(o)));else{const e=i.nextSibling;s.addSubCommand(new ii(i[0],e,n)),i.remove()}j(s)};const It=this.getDocumentTitle=function(){return r.getTitle(c)};this.setDocumentTitle=function(e){const n=c.childNodes;let i=!1,s="";const o=new oi("Change Image Title");for(const e of n)if("title"===e.nodeName){i=e,s=i.textContent;break}i||(i=a.createElementNS(t.SVG,"title"),c.insertBefore(i,c.firstChild)),e.length?i.textContent=e:i.remove(),o.addSubCommand(new si(i,{"#text":s})),j(o)},this.getEditorNS=function(e){return e&&c.setAttribute("xmlns:se",t.SE),t.SE},this.setResolution=function(e,t){const n=Nt(),{w:i,h:s}=n;let o;if("fit"===e){const n=Ue();if(!n)return!1;{o=new oi("Fit Canvas to Content");const i=Be();oe(i);const s=[],a=[];ei.each(i,(function(e,t){s.push(-1*n.x),a.push(-1*n.y)}));const l=r.moveSelectedElements(s,a,!0);o.addSubCommand(l),se(),e=Math.round(n.width),t=Math.round(n.height)}}return e===i&&t===s||(o||(o=new oi("Change Image Dimensions")),e=q("width",e),t=q("height",t),c.setAttribute("width",e),c.setAttribute("height",t),this.contentW=e,this.contentH=t,o.addSubCommand(new si(c,{width:i,height:s})),c.setAttribute("viewBox",[0,0,e/h,t/h].join(" ")),o.addSubCommand(new si(c,{viewBox:["0 0",i,s].join(" ")})),j(o),ie("changed",[c])),!0},this.getOffset=function(){return ei(c).attr(["x","y"])},this.setBBoxZoom=function(e,t,n){let i,s=.85;const o=function(e){if(!e)return!1;const i=Math.round(t/e.width*100*s)/100,o=Math.round(n/e.height*100*s)/100,a=Math.min(i,o);return r.setZoom(a),{zoom:a,bbox:e}};if("object"==typeof e){if(i=e,0===i.width||0===i.height){const e=i.zoom?i.zoom:h*i.factor;return r.setZoom(e),{zoom:h,bbox:i}}return o(i)}switch(e){case"selection":{if(!m[0])return;const e=ei.map(m,(function(e){if(e)return e}));i=Ue(e);break}case"canvas":{const e=Nt();s=.95,i={width:e.w,height:e.h,x:0,y:0};break}case"content":i=Ue();break;case"layer":i=Ue(Be(d().getCurrentLayer()));break;default:return}return o(i)},this.setZoom=function(e){const t=Nt();c.setAttribute("viewBox","0 0 "+t.w/e+" "+t.h/e),h=e,ei.each(m,(function(e,t){t&&H.requestSelector(t).resize()})),E.zoomChange(),rt("zoomChanged",e)},this.getMode=function(){return Ke},this.setMode=function(e){E.clear(!0),vt.clear(),Je=m[0]&&"text"===m[0].nodeName?Le:f,Ke=e},this.getColor=function(e){return Je[e]},this.setColor=function(e,t,n){f[e]=t,Je[e+"_paint"]={type:"solidColor"};const i=[];function s(e){"g"!==e.nodeName&&i.push(e)}let o=m.length;for(;o--;){const t=m[o];t&&("g"===t.tagName?we(t,s):"fill"===e?"polyline"!==t.tagName&&"line"!==t.tagName&&i.push(t):i.push(t))}i.length>0&&(n?Mt(e,t,i):(Ot(e,t,i),ie("changed",i)))};const Tt=this.setGradient=function(e){if(!Je[e+"_paint"]||"solidColor"===Je[e+"_paint"].type)return;let t=r[e+"Grad"];const n=Lt(t),i=Ee();n?t=n:(t=i.appendChild(a.importNode(t,!0)),t.id=X()),r.setColor(e,"url(#"+t.id+")")},Lt=function(e){const n=Ee(),i=ei(n).find("linearGradient, radialGradient");let s=i.length;const o=["r","cx","cy","fx","fy"];for(;s--;){const n=i[s];if("linearGradient"===e.tagName){if(e.getAttribute("x1")!==n.getAttribute("x1")||e.getAttribute("y1")!==n.getAttribute("y1")||e.getAttribute("x2")!==n.getAttribute("x2")||e.getAttribute("y2")!==n.getAttribute("y2"))continue}else{const t=ei(e).attr(o),i=ei(n).attr(o);let s=!1;if(ei.each(o,(function(e,n){t[n]!==i[n]&&(s=!0)})),s)continue}const r=e.getElementsByTagNameNS(t.SVG,"stop"),a=n.getElementsByTagNameNS(t.SVG,"stop");if(r.length!==a.length)continue;let l=r.length;for(;l--;){const e=r[l],t=a[l];if(e.getAttribute("offset")!==t.getAttribute("offset")||e.getAttribute("stop-opacity")!==t.getAttribute("stop-opacity")||e.getAttribute("stop-color")!==t.getAttribute("stop-color"))break}if(-1===l)return n}return null};this.setPaint=function(e,t){const n=new ei.jGraduate.Paint(t);switch(this.setPaintOpacity(e,n.alpha/100,!0),Je[e+"_paint"]=n,n.type){case"solidColor":this.setColor(e,"none"!==n.solidColor?"#"+n.solidColor:"none");break;case"linearGradient":case"radialGradient":r[e+"Grad"]=n[n.type],Tt(e)}},this.setStrokePaint=function(e){this.setPaint("stroke",e)},this.setFillPaint=function(e){this.setPaint("fill",e)},this.getStrokeWidth=function(){return Je.stroke_width},this.setStrokeWidth=function(e){if(0===e&&["line","path"].includes(Ke))return void r.setStrokeWidth(1);Je.stroke_width=e;const t=[];function n(e){"g"!==e.nodeName&&t.push(e)}let i=m.length;for(;i--;){const e=m[i];e&&("g"===e.tagName?we(e,n):t.push(e))}t.length>0&&(Ot("stroke-width",e,t),ie("changed",m))},this.setStrokeAttr=function(e,t){f[e.replace("-","_")]=t;const n=[];let i=m.length;for(;i--;){const e=m[i];e&&("g"===e.tagName?we(e,(function(e){"g"!==e.nodeName&&n.push(e)})):n.push(e))}n.length>0&&(Ot(e,t,n),ie("changed",m))},this.getStyle=function(){return f},this.getOpacity=re,this.setOpacity=function(e){f.opacity=e,Ot("opacity",e)},this.getFillOpacity=function(){return f.fill_opacity},this.getStrokeOpacity=function(){return f.stroke_opacity},this.setPaintOpacity=function(e,t,n){f[e+"_opacity"]=t,n?Mt(e+"-opacity",t):Ot(e+"-opacity",t)},this.getPaintOpacity=function(e){return"fill"===e?this.getFillOpacity():this.getStrokeOpacity()},this.getBlur=function(e){let t=0;if(e){if(e.getAttribute("filter")){const n=He(e.id+"_blur");n&&(t=n.firstChild.getAttribute("stdDeviation"))}}return t},function(){let e=null,t=null,n=!1;function i(){const n=r.undoMgr.finishUndoableChange();e.addSubCommand(n),j(e),e=null,t=null}r.setBlurNoUndo=function(e){if(t)if(0===e)Mt("filter",""),n=!0;else{const i=m[0];n&&Mt("filter","url(#"+i.id+"_blur)"),w()&&(i.removeAttribute("filter"),i.setAttribute("filter","url(#"+i.id+"_blur)")),Mt("stdDeviation",e,[t.firstChild]),r.setBlurOffsets(t,e)}else r.setBlur(e)},r.setBlurOffsets=function(e,t){t>3?qe(e,{x:"-50%",y:"-50%",width:"200%",height:"200%"}):w()||(e.removeAttribute("x"),e.removeAttribute("y"),e.removeAttribute("width"),e.removeAttribute("height"))},r.setBlur=function(n,s){if(e)return void i();const o=m[0],a=o.id;t=He(a+"_blur"),n-=0;const l=new oi;if(t)0===n&&(t=null);else{const e=b({element:"feGaussianBlur",attr:{in:"SourceGraphic",stdDeviation:n}});t=b({element:"filter",attr:{id:a+"_blur"}}),t.append(e),Ee().append(t),l.addSubCommand(new ni(t))}const c={filter:o.getAttribute("filter")};if(0===n)return o.removeAttribute("filter"),void l.addSubCommand(new si(o,c));Ot("filter","url(#"+a+"_blur)"),l.addSubCommand(new si(o,c)),r.setBlurOffsets(t,n),e=l,r.undoMgr.beginUndoableChange("stdDeviation",[t?t.firstChild:null]),s&&(r.setBlurNoUndo(n),i())}}(),this.getBold=function(){const e=m[0];return!(Qe(e)||"text"!==e.tagName||!Qe(m[1]))&&"bold"===e.getAttribute("font-weight")},this.setBold=function(e){const t=m[0];!Qe(t)&&"text"===t.tagName&&Qe(m[1])&&Ot("font-weight",e?"bold":"normal"),m[0].textContent||vt.setCursor()},this.getItalic=function(){const e=m[0];return!(Qe(e)||"text"!==e.tagName||!Qe(m[1]))&&"italic"===e.getAttribute("font-style")},this.setItalic=function(e){const t=m[0];!Qe(t)&&"text"===t.tagName&&Qe(m[1])&&Ot("font-style",e?"italic":"normal"),m[0].textContent||vt.setCursor()},this.getFontFamily=function(){return Le.font_family},this.setFontFamily=function(e){Le.font_family=e,Ot("font-family",e),m[0]&&!m[0].textContent&&vt.setCursor()},this.setFontColor=function(e){Le.fill=e,Ot("fill",e)},this.getFontColor=function(){return Le.fill},this.getFontSize=function(){return Le.font_size},this.setFontSize=function(e){Le.font_size=e,Ot("font-size",e),m[0].textContent||vt.setCursor()},this.getText=function(){const e=m[0];return Qe(e)?"":e.textContent},this.setTextContent=function(e){Ot("#text",e),vt.init(e),vt.setCursor()},this.setImageURL=function(e){const t=m[0];if(!t)return;const n=ei(t).attr(["width","height"]),i=!n.width||!n.height,s=Ce(t);if(s===e&&!i)return;const o=new oi("Change Image URL");Ae(t,e),o.addSubCommand(new si(t,{"#href":s})),ei(new Image).load((function(){const e=ei(t).attr(["width","height"]);ei(t).attr({width:this.width,height:this.height}),H.requestSelector(t).resize(),o.addSubCommand(new si(t,e)),j(o),ie("changed",[t])})).attr("src",e)},this.setLinkURL=function(e){let t=m[0];if(!t)return;if("a"!==t.tagName){const e=ei(t).parents("a");if(!e.length)return;t=e[0]}const n=Ce(t);if(n===e)return;const i=new oi("Change Link URL");Ae(t,e),i.addSubCommand(new si(t,{"#href":n})),j(i)},this.setRectRadius=function(e){const t=m[0];if(!Qe(t)&&"rect"===t.tagName){const n=t.getAttribute("rx");n!==String(e)&&(t.setAttribute("rx",e),t.setAttribute("ry",e),j(new si(t,{rx:n,ry:n},"Radius")),ie("changed",[t]))}},this.makeHyperlink=function(e){r.groupSelectedElements("a",e)},this.removeHyperlink=function(){r.ungroupSelectedElement()},this.setSegType=function(e){E.setSegType(e)},this.convertToPath=function(e,t){if(Qe(e)){const e=m;return void ei.each(e,(function(e,t){t&&r.convertToPath(t)}))}if(t)return Me(e,b,E);const n={fill:f.fill,"fill-opacity":f.fill_opacity,stroke:f.stroke,"stroke-width":f.stroke_width,"stroke-dasharray":f.stroke_dasharray,"stroke-linejoin":f.stroke_linejoin,"stroke-linecap":f.stroke_linecap,"stroke-opacity":f.stroke_opacity,opacity:f.opacity,visibility:"hidden"};return Oe(e,n,b,E,se,oe,ft,j)};const Mt=function(e,t,n){"pathedit"===Ke&&E.moveNode(e,t);let i=(n=n||m).length;const s=["g","polyline","path"];for(;i--;){let o=n[i];if(Qe(o))continue;if(("x"===e||"y"===e)&&s.includes(o.tagName)){const n=Ue([o]),i="x"===e?t-n.x:0,s="y"===e?t-n.y:0;r.moveSelectedElements(i*h,s*h,!0);continue}let a="#text"===e?o.textContent:o.getAttribute(e);if(Qe(a)&&(a=""),a!==String(t)){"#text"===e?(o.textContent=t,/rotate/.test(o.getAttribute("transform"))&&(o=ht(o))):"#href"===e?Ae(o,t):o.setAttribute(e,t),"textedit"===Ke&&"#text"!==e&&o.textContent.length&&vt.toSelectMode(o),S()&&"text"===o.nodeName&&/rotate/.test(o.getAttribute("transform"))&&(String(t).startsWith("url")||["font-size","font-family","x","y"].includes(e)&&o.textContent)&&(o=ht(o)),m.includes(o)&&setTimeout((function(){o.parentNode&&H.requestSelector(o).resize()}),0);const n=Fe(o);if(0!==n&&"transform"!==e){const e=O(o);let t=e.numberOfItems;for(;t--;){if(4===e.getItem(t).type){e.removeItem(t);const i=Ne(o),s=$(i.x+i.width/2,i.y+i.height/2,J(e).matrix),r=s.x,a=s.y,c=l.createSVGTransform();c.setRotate(n,r,a),e.insertItemBefore(c,t);break}}}}}},Ot=this.changeSelectedAttribute=function(e,t,n){n=n||m,r.undoMgr.beginUndoableChange(e,n),Mt(e,t,n);const i=r.undoMgr.finishUndoableChange();i.isEmpty()||j(i)};this.deleteSelectedElements=function(){const e=new oi("Delete Elements"),t=m.length,n=[];for(let i=0;i<t;++i){const t=m[i];if(Qe(t))break;let s=t.parentNode,o=t;H.releaseSelector(o),zt(o.id),"a"===s.tagName&&1===s.childNodes.length&&(o=s,s=s.parentNode);const{nextSibling:r}=o;o.remove();const a=o;n.push(t),e.addSubCommand(new ii(a,r,s))}m=[],e.isEmpty()||j(e),ie("changed",n),se()},this.cutSelectedElements=function(){r.copySelectedElements(),r.deleteSelectedElements()};const jt="svgedit_clipboard";function Vt(){const e=sessionStorage.getItem(jt);localStorage.setItem(jt,e),setTimeout((function(){localStorage.removeItem(jt)}),1)}window.addEventListener("storage",(function(e){e.newValue&&(e.key===jt+"_startup"?(localStorage.removeItem(jt+"_startup"),Vt()):e.key===jt&&sessionStorage.setItem(jt,e.newValue))}),!1),localStorage.setItem(jt+"_startup",Math.random()),this.copySelectedElements=function(){const e=JSON.stringify(m.map(e=>y(e)));sessionStorage.setItem(jt,e),Vt();const t=ei("#cmenu_canvas");t.enableContextMenuItems&&t.enableContextMenuItems("#paste,#paste_in_place")},this.pasteElements=function(e,t,n){let i=JSON.parse(sessionStorage.getItem(jt));if(!i)return;let s=i.length;if(!s)return;const o=[],a=new oi("Paste elements"),l={};for(i.forEach((function e(t){t.attr&&t.attr.id&&(l[t.attr.id]=X(),t.attr.id=l[t.attr.id]),t.children&&t.children.forEach(e)})),rt("IDsUpdated",{elems:i,changes:l},!0).forEach((function(e){e&&"remove"in e&&e.remove.forEach((function(e){i=i.filter((function(t){return t.attr.id!==e}))}))}));s--;){const e=i[s];if(!e)continue;const t=b(e);o.push(t),a.addSubCommand(new ni(t)),xe(t)}if(_t(o),"in_place"!==e){let i,s;e?"point"===e&&(i=t,s=n):(i=it.x,s=it.y);const l=Ue(o),c=i-(l.x+l.width/2),u=s-(l.y+l.height/2),d=[],h=[];ei.each(o,(function(e,t){d.push(c),h.push(u)}));const p=r.moveSelectedElements(d,h,!1);p&&a.addSubCommand(p)}j(a),ie("changed",o)},this.groupSelectedElements=function(e,t){e||(e="g");let n,i="";switch(e){case"a":i="Make hyperlink",n=t||"";break;default:e="g",i="Group Elements"}const s=new oi(i),o=b({element:e,attr:{id:X()}});"a"===e&&Ae(o,n),s.addSubCommand(new ni(o));let r=m.length;for(;r--;){let e=m[r];if(Qe(e))continue;"a"===e.parentNode.tagName&&1===e.parentNode.childNodes.length&&(e=e.parentNode);const t=e.nextSibling,n=e.parentNode;o.append(e),s.addSubCommand(new ti(e,t,n))}s.isEmpty()||j(s),_t([o],!0)};const Rt=this.pushGroupProperties=function(e,t){const n=e.childNodes,i=n.length,s=e.getAttribute("transform"),o=O(e),a=J(o).matrix,c=new oi("Push group properties"),u=Fe(e),h=ei(e).attr(["filter","opacity"]);let p,g,f;const m=d();for(let t=0;t<i;t++){const i=n[t];if(1!==i.nodeType)continue;if(null!==h.opacity&&1!==h.opacity){const e=Math.round((i.getAttribute("opacity")||1)*h.opacity*100)/100;Ot("opacity",e,[i])}if(h.filter){let t=this.getBlur(i);const n=t;g||(g=this.getBlur(e)),t?t=Number(g)+Number(t):0===t&&(t=g),n?p=ze(i.getAttribute("filter")):p?(p=m.copyElem(p),Ee().append(p)):p=ze(h.filter);const s="feGaussianBlur"===p.firstChild.tagName?"blur":"filter";p.id=i.id+"_"+s,Ot("filter","url(#"+p.id+")",[i]),t&&(Ot("stdDeviation",t,[p.firstChild]),r.setBlurOffsets(p,t))}let s=O(i);if(i.tagName.includes("Gradient")&&(s=null),s&&"defs"!==i.tagName&&o.numberOfItems){if(u&&1===o.numberOfItems){const e=o.getItem(0).matrix;let t=l.createSVGMatrix();const n=Fe(i);n&&(t=s.getItem(0).matrix);const r=Ne(i),a=J(s).matrix,c=$(r.x+r.width/2,r.y+r.height/2,a),d=u+n,h=l.createSVGTransform();h.setRotate(d,c.x,c.y);const p=Q(e,t,h.matrix.inverse());if(n&&s.removeItem(0),d&&(s.numberOfItems?s.insertItemBefore(h,0):s.appendItem(h)),p.e||p.f){const e=l.createSVGTransform();e.setTranslate(p.e,p.f),s.numberOfItems?s.insertItemBefore(e,0):s.appendItem(e)}}else{const e=i.getAttribute("transform");f={},f.transform=e||"";const t=l.createSVGTransform(),n=J(s).matrix,o=n.inverse(),r=Q(o,a,n);t.setMatrix(r),s.appendItem(t)}const e=Xn(i);e&&c.addSubCommand(e)}}if(s&&(f={},f.transform=s,e.setAttribute("transform",""),e.removeAttribute("transform"),c.addSubCommand(new si(e,f))),t&&!c.isEmpty())return c};this.ungroupSelectedElement=function(){let e=m[0];if(!e)return;if(ei(e).data("gsvg")||ei(e).data("symbol"))return void Gt(e);if("use"===e.tagName){const t=He(Ce(e).substr(1));return ei(e).data("symbol",t).data("ref",t),void Gt(e)}const t=ei(e).parents("a");if(t.length&&(e=t[0]),"g"===e.tagName||"a"===e.tagName){const t=new oi("Ungroup Elements"),n=Rt(e,!0);n&&t.addSubCommand(n);const i=e.parentNode,s=e.nextSibling,o=new Array(e.childNodes.length);let r=0;for(;e.firstChild;){const n=e.firstChild,i=n.nextSibling,a=n.parentNode;if("title"!==n.tagName)s?s.before(n):e.after(n),o[r++]=n,t.addSubCommand(new ti(n,i,a));else{const{nextSibling:e}=n;t.addSubCommand(new ii(n,e,a)),n.remove()}}se();const a=e.nextSibling;e.remove(),t.addSubCommand(new ii(e,a,i)),t.isEmpty()||j(t),oe(o)}},this.moveToTopSelectedElement=function(){const[e]=m;if(!Qe(e)){let t=e;const n=t.parentNode,i=t.nextSibling;t=t.parentNode.appendChild(t),i!==t.nextSibling&&(j(new ti(t,i,n,"top")),ie("changed",[t]))}},this.moveToBottomSelectedElement=function(){const[e]=m;if(!Qe(e)){let t=e;const n=t.parentNode,i=t.nextSibling;let{firstChild:s}=t.parentNode;"title"===s.tagName&&(s=s.nextSibling),"defs"===s.tagName&&(s=s.nextSibling),t=t.parentNode.insertBefore(t,s),i!==t.nextSibling&&(j(new ti(t,i,n,"bottom")),ie("changed",[t]))}},this.moveUpDownSelected=function(e){const t=m[0];if(!t)return;let n,i;nt=[];const s=ei(lt(Ue([t]))).toArray();if("Down"===e&&s.reverse(),ei.each(s,(function(){return i?(n=this,!1):(this===t&&(i=!0),!0)})),!n)return;const o=t,r=o.parentNode,a=o.nextSibling;ei(n)["Down"===e?"before":"after"](o),a!==o.nextSibling&&(j(new ti(o,a,r,"Move "+e)),ie("changed",[o]))},this.moveSelectedElements=function(e,t,n){e.constructor!==Array&&(e/=h,t/=h),n=n||!0;const i=new oi("position");let s=m.length;for(;s--;){const n=m[s];if(!Qe(n)){const o=l.createSVGTransform(),r=O(n);e.constructor===Array?o.setTranslate(e[s],t[s]):o.setTranslate(e,t),r.numberOfItems?r.insertItemBefore(o,0):r.appendItem(o);const a=Xn(n);a&&i.addSubCommand(a),H.requestSelector(n).resize()}}if(!i.isEmpty())return n&&j(i),ie("changed",m),i},this.cloneSelectedElements=function(e,t){let n,i;const s=new oi("Clone Elements"),o=m.length;for(m.sort((function(e,t){return ei(t).index()-ei(e).index()})),n=0;n<o&&(i=m[n],!Qe(i));++n);const r=m.slice(0,n);this.clearSelection(!0);const a=d();for(n=r.length;n--;)i=r[n]=a.copyElem(r[n]),(p||a.getCurrentLayer()).append(i),s.addSubCommand(new ni(i));s.isEmpty()||(oe(r.reverse()),this.moveSelectedElements(e,t,!1),j(s))},this.alignSelectedElements=function(e,t){const n=[],i=m.length;if(!i)return;let s=Number.MAX_VALUE,o=Number.MIN_VALUE,a=Number.MAX_VALUE,l=Number.MIN_VALUE,c=Number.MIN_VALUE,u=Number.MIN_VALUE;for(let r=0;r<i&&!Qe(m[r]);++r){const i=m[r];switch(n[r]=Ue([i]),t){case"smallest":(("l"===e||"c"===e||"r"===e)&&(c===Number.MIN_VALUE||c>n[r].width)||("t"===e||"m"===e||"b"===e)&&(u===Number.MIN_VALUE||u>n[r].height))&&(s=n[r].x,a=n[r].y,o=n[r].x+n[r].width,l=n[r].y+n[r].height,c=n[r].width,u=n[r].height);break;case"largest":(("l"===e||"c"===e||"r"===e)&&(c===Number.MIN_VALUE||c<n[r].width)||("t"===e||"m"===e||"b"===e)&&(u===Number.MIN_VALUE||u<n[r].height))&&(s=n[r].x,a=n[r].y,o=n[r].x+n[r].width,l=n[r].y+n[r].height,c=n[r].width,u=n[r].height);break;default:n[r].x<s&&(s=n[r].x),n[r].y<a&&(a=n[r].y),n[r].x+n[r].width>o&&(o=n[r].x+n[r].width),n[r].y+n[r].height>l&&(l=n[r].y+n[r].height)}}"page"===t&&(s=0,a=0,o=r.contentW,l=r.contentH);const d=new Array(i),h=new Array(i);for(let t=0;t<i&&!Qe(m[t]);++t){const i=n[t];switch(d[t]=0,h[t]=0,e){case"l":d[t]=s-i.x;break;case"c":d[t]=(s+o)/2-(i.x+i.width/2);break;case"r":d[t]=o-(i.x+i.width);break;case"t":h[t]=a-i.y;break;case"m":h[t]=(a+l)/2-(i.y+i.height/2);break;case"b":h[t]=l-(i.y+i.height)}}this.moveSelectedElements(d,h)},this.contentW=Nt().w,this.contentH=Nt().h,this.updateCanvas=function(e,t){l.setAttribute("width",e),l.setAttribute("height",t);const n=ei("#canvasBackground")[0],i=c.getAttribute("x"),s=c.getAttribute("y"),o=(e-this.contentW*h)/2,r=(t-this.contentH*h)/2;qe(c,{width:this.contentW*h,height:this.contentH*h,x:o,y:r,viewBox:"0 0 "+this.contentW+" "+this.contentH}),qe(n,{width:c.getAttribute("width"),height:c.getAttribute("height"),x:o,y:r});const a=He("background_image");return a&&qe(a,{width:"100%",height:"100%"}),H.selectorParentGroup.setAttribute("transform","translate("+o+","+r+")"),rt("canvasUpdated",{new_x:o,new_y:r,old_x:i,old_y:s,d_x:o-i,d_y:r-s}),{x:o,y:r,old_x:i,old_y:s,d_x:o-i,d_y:r-s}},this.setBackground=function(e,n){const i=He("canvasBackground"),s=ei(i).find("rect")[0];let o=He("background_image"),r=He("background_pattern");if(s.setAttribute("fill","chessboard"===e?"#fff":e),"chessboard"===e){if(!r){r=a.createElementNS(t.SVG,"foreignObject"),qe(r,{id:"background_pattern",width:"100%",height:"100%",preserveAspectRatio:"xMinYMin",style:"pointer-events:none"});const e=document.createElement("div");qe(e,{style:"pointer-events:none;width:100%;height:100%;background-image:url(data:image/gif;base64,R0lGODlhEAAQAIAAAP///9bW1iH5BAAAAAAALAAAAAAQABAAAAIfjG+gq4jM3IFLJgpswNly/XkcBpIiVaInlLJr9FZWAQA7);"}),r.appendChild(e),i.append(r)}}else r&&r.remove();n?(o||(o=a.createElementNS(t.SVG,"image"),qe(o,{id:"background_image",width:"100%",height:"100%",preserveAspectRatio:"xMinYMin",style:"pointer-events:none"})),Ae(o,n),i.append(o)):o&&o.remove()},this.cycleElement=function(e){let t;const n=m[0];let i=!1;const s=Be(p||d().getCurrentLayer());if(s.length){if(Qe(n))t=e?s.length-1:0,i=s[t];else{let o=s.length;for(;o--;)if(s[o]===n){t=e?o-1:o+1,t>=s.length?t=0:t<0&&(t=s.length-1),i=s[t];break}}_t([i],!0),ie("selected",m)}},this.clear(),this.getPrivateMethods=function(){return{addCommandToHistory:j,BatchCommand:oi,ChangeElementCommand:si,decode64:ge,dropXMLInternalSubset:de,encode64:pe,ffClone:ht,findDefs:Ee,findDuplicateGradient:Lt,getElem:He,getPathBBox:Ge,getTypeMap:D,getUrlFromAttr:ke,identifyLayers:wn,InsertElementCommand:ni,isChrome:C,isIdentity:Y,isIE:k,logMatrix:gt,MoveElementCommand:ti,NS:t,preventClickDefault:Ye,RemoveElementCommand:ii,SVGEditTransformList:L,text2xml:ve,transformBox:Z,transformPoint:$,walkTree:we}}}}
/**
* @file SVG Icon Loader 2.0
*
* jQuery Plugin for loading SVG icons from a single file
*
* Adds {@link external:jQuery.svgIcons}, {@link external:jQuery.getSvgIcon}, {@link external:jQuery.resizeSvgIcons}
*
* How to use:
1. Create the SVG master file that includes all icons:
The master SVG icon-containing file is an SVG file that contains
`<g>` elements. Each `<g>` element should contain the markup of an SVG
icon. The `<g>` element has an ID that should
correspond with the ID of the HTML element used on the page that should contain
or optionally be replaced by the icon. Additionally, one empty element should be
added at the end with id "svg_eof".
2. Optionally create fallback raster images for each SVG icon.
3. Include the jQuery and the SVG Icon Loader scripts on your page.
4. Run `$.svgIcons()` when the document is ready. See its signature
5. To access an icon at a later point without using the callback, use this:
`$.getSvgIcon(id (string), uniqueClone (boolean))`;
This will return the icon (as jQuery object) with a given ID.
6. To resize icons at a later point without using the callback, use this:
`$.resizeSvgIcons(resizeOptions)` (use the same way as the "resize" parameter)
*
* @module jQuerySVGIcons
* @license MIT
* @copyright (c) 2009 Alexis Deveria
* {@link http://a.deveria.com}
* @example
$(function () {
$.svgIcons('my_icon_set.svg'); // The SVG file that contains all icons
// No options have been set, so all icons will automatically be inserted
// into HTML elements that match the same IDs.
});
* @example
$(function () {
// The SVG file that contains all icons
$.svgIcons('my_icon_set.svg', {
callback (icons) { // Custom callback function that sets click
// events for each icon
$.each(icons, function (id, icon) {
icon.click(function () {
alert('You clicked on the icon with id ' + id);
});
});
}
});
});
* @example
$(function () {
// The SVGZ file that contains all icons
$.svgIcons('my_icon_set.svgz', {
w: 32, // All icons will be 32px wide
h: 32, // All icons will be 32px high
fallback_path: 'icons/', // All fallback files can be found here
fallback: {
'#open_icon': 'open.png', // The "open.png" will be appended to the
// HTML element with ID "open_icon"
'#close_icon': 'close.png',
'#save_icon': 'save.png'
},
placement: {'.open_icon': 'open'}, // The "open" icon will be added
// to all elements with class "open_icon"
resize: {
'#save_icon .svg_icon': 64 // The "save" icon will be resized to 64 x 64px
},
callback (icons) { // Sets background color for "close" icon
icons.close.css('background', 'red');
},
svgz: true // Indicates that an SVGZ file is being used
});
});
*/
const ci=Boolean(window.opera),ui=function(e,t,n){const i=e.find("defs");if(!i.length)return e;let s;s=ci?i.find("*").filter((function(){return Boolean(this.id)})):i.find("[id]");const o=e[0].getElementsByTagName("*"),r=o.length;return s.each((function(e){const{id:n}=this,i="x"+n+t+e;this.id=i;const s="url(#"+n+")",a="url(#"+i+")";for(e=0;e<r;e++){const t=o[e];t.getAttribute("fill")===s&&t.setAttribute("fill",a),t.getAttribute("stroke")===s&&t.setAttribute("stroke",a),t.getAttribute("filter")===s&&t.setAttribute("filter",a)}})),e};
/**
* @file jGraduate 0.4
*
* jQuery Plugin for a gradient picker
*
* @module jGraduate
* @copyright 2010 Jeff Schiller {@link http://blog.codedread.com/}, 2010 Alexis Deveria {@link http://a.deveria.com/}
*
* @license Apache-2.0
* @example
* // The Paint object is described below.
* $.jGraduate.Paint(); // constructs a 'none' color
* @example $.jGraduate.Paint({copy: o}); // creates a copy of the paint o
* @example $.jGraduate.Paint({hex: '#rrggbb'}); // creates a solid color paint with hex = "#rrggbb"
* @example $.jGraduate.Paint({linearGradient: o, a: 50}); // creates a linear gradient paint with opacity=0.5
* @example $.jGraduate.Paint({radialGradient: o, a: 7}); // creates a radial gradient paint with opacity=0.07
* @example $.jGraduate.Paint({hex: '#rrggbb', linearGradient: o}); // throws an exception?
*/
const di="http://www.w3.org/2000/svg",hi="http://www.w3.org/1999/xlink";
/**
* @file jPicker (Adapted from version 1.1.6)
*
* jQuery Plugin for Photoshop style color picker
*
* @module jPicker
* @copyright (c) 2010 Christopher T. Tillman
* Digital Magic Productions, Inc. ({@link http://www.digitalmagicpro.com/})
* FREE to use, alter, copy, sell, and especially ENHANCE
* @license MIT
*
* Painstakingly ported from John Dyers' excellent work on his own color picker based on the Prototype framework.
*
* John Dyers' website: {@link http://johndyer.name}
* Color Picker page: {@link http://johndyer.name/photoshop-like-javascript-color-picker/}
*/
function pi(e,t){return void 0===t&&(t=0),Math.round(e*10**t)/10**t}window.console||(window.console={log(e){},dir(e){}});const gi=e=>null==e,fi=jQuery;let mi;const _i=function(e,t,n){const i=fi("#svg_editor").parent();Object.entries(t).forEach(([t,s])=>{if(!s)return void console.log(t);n&&(t="#"+t);const o=i.find(t);if(o.length){const t=o[0];switch(e){case"aria-label":t.setAttribute("aria-label",s);break;case"content":[...t.childNodes].some(e=>!(3!==e.nodeType||!e.textContent.trim())&&(e.textContent=s,!0));break;case"title":t.title=s}}else console.log("Missing element for localization: "+t)})};let yi;const bi=async function(e){const t=await yi.addLangData(mi);if(fi.each(t,(function(t,n){n.data&&(e=fi.merge(e,n.data))})),!e.tools)return;const{tools:n,properties:i,config:s,layers:o,common:r,ui:a}=e;_i("content",{curve_segments:i.curve_segments,fitToContent:n.fitToContent,fit_to_all:n.fit_to_all,fit_to_canvas:n.fit_to_canvas,fit_to_layer_content:n.fit_to_layer_content,fit_to_sel:n.fit_to_sel,icon_large:s.icon_large,icon_medium:s.icon_medium,icon_small:s.icon_small,icon_xlarge:s.icon_xlarge,image_opt_embed:s.image_opt_embed,image_opt_ref:s.image_opt_ref,includedImages:s.included_images,largest_object:n.largest_object,layersLabel:o.layers,page:n.page,relativeToLabel:n.relativeTo,selLayerLabel:o.move_elems_to,selectedPredefined:s.select_predefined,selected_objects:n.selected_objects,smallest_object:n.smallest_object,straight_segments:i.straight_segments,svginfo_bg_url:s.editor_img_url+":",svginfo_bg_note:s.editor_bg_note,svginfo_change_background:s.background,svginfo_dim:s.doc_dims,svginfo_editor_prefs:s.editor_prefs,svginfo_height:r.height,svginfo_icons:s.icon_size,svginfo_image_props:s.image_props,svginfo_lang:s.language,svginfo_title:s.doc_title,svginfo_width:r.width,tool_docprops_cancel:r.cancel,tool_docprops_save:r.ok,tool_source_cancel:r.cancel,tool_source_save:r.ok,tool_prefs_cancel:r.cancel,tool_prefs_save:r.ok,sidepanel_handle:o.layers.split("").join(" "),tool_clear:n.new_doc,tool_docprops:n.docprops,tool_export:n.export_img,tool_import:n.import_doc,tool_open:n.open_doc,tool_save:n.save_doc,tool_editor_prefs:s.editor_prefs,tool_editor_homepage:n.editor_homepage,svginfo_units_rulers:s.units_and_rulers,svginfo_rulers_onoff:s.show_rulers,svginfo_unit:s.base_unit,svginfo_grid_settings:s.grid,svginfo_snap_onoff:s.snapping_onoff,svginfo_snap_step:s.snapping_stepsize,svginfo_grid_color:s.grid_color},!0);const l={};["cut","copy","paste","paste_in_place","delete","group","ungroup","move_front","move_up","move_down","move_back"].forEach(e=>{l['#cmenu_canvas a[href="#'+e+'"]']=n[e]}),["dupe","merge_down","merge_all"].forEach(e=>{l['#cmenu_layers a[href="#'+e+'"]']=o[e]}),l['#cmenu_layers a[href="#delete"]']=o.del,_i("content",l);const c={};return Object.entries({tool_blur:i.blur,tool_position:n.align_to_page,tool_font_family:i.font_family,zoom_panel:a.zoom_level,stroke_linejoin:i.linejoin_miter,stroke_linecap:i.linecap_butt,tool_opacity:i.opacity}).forEach(([e,t])=>{c["#"+e+" button"]=t}),Object.entries({group_opacity:i.opacity,zoom:a.zoom_level}).forEach(([e,t])=>{c["#"+e]=t}),_i("aria-label",c),_i("title",{align_relative_to:n.align_relative_to,circle_cx:i.circle_cx,circle_cy:i.circle_cy,circle_r:i.circle_r,cornerRadiusLabel:i.corner_radius,ellipse_cx:i.ellipse_cx,ellipse_cy:i.ellipse_cy,ellipse_rx:i.ellipse_rx,ellipse_ry:i.ellipse_ry,fill_color:i.fill_color,font_family:i.font_family,idLabel:i.id,image_height:i.image_height,image_url:i.image_url,image_width:i.image_width,layer_delete:o.del,layer_down:o.move_down,layer_new:o.new,layer_rename:o.rename,layer_moreopts:r.more_opts,layer_up:o.move_up,line_x1:i.line_x1,line_x2:i.line_x2,line_y1:i.line_y1,line_y2:i.line_y2,linecap_butt:i.linecap_butt,linecap_round:i.linecap_round,linecap_square:i.linecap_square,linejoin_bevel:i.linejoin_bevel,linejoin_miter:i.linejoin_miter,linejoin_round:i.linejoin_round,main_icon:n.main_menu,palette:a.palette_info,zoom_panel:a.zoom_level,path_node_x:i.node_x,path_node_y:i.node_y,rect_height_tool:i.rect_height,rect_width_tool:i.rect_width,seg_type:i.seg_type,selLayerNames:o.move_selected,selected_x:i.pos_x,selected_y:i.pos_y,stroke_color:i.stroke_color,stroke_style:i.stroke_style,stroke_width:i.stroke_width,svginfo_title:s.doc_title,text:i.text_contents,toggle_stroke_tools:a.toggle_stroke_tools,tool_add_subpath:n.add_subpath,tool_alignbottom:n.align_bottom,tool_aligncenter:n.align_center,tool_alignleft:n.align_left,tool_alignmiddle:n.align_middle,tool_alignright:n.align_right,tool_aligntop:n.align_top,tool_angle:i.angle,tool_blur:i.blur,tool_bold:i.bold,tool_circle:n.mode_circle,tool_clone:n.clone,tool_clone_multi:n.clone,tool_delete:n.del,tool_delete_multi:n.del,tool_ellipse:n.mode_ellipse,tool_fhellipse:n.mode_fhellipse,tool_fhpath:n.mode_fhpath,tool_fhrect:n.mode_fhrect,tool_font_size:i.font_size,tool_group_elements:n.group_elements,tool_make_link:n.make_link,tool_link_url:n.set_link_url,tool_image:n.mode_image,tool_italic:i.italic,tool_line:n.mode_line,tool_move_bottom:n.move_bottom,tool_move_top:n.move_top,tool_node_clone:n.node_clone,tool_node_delete:n.node_delete,tool_node_link:n.node_link,tool_opacity:i.opacity,tool_openclose_path:n.openclose_path,tool_path:n.mode_path,tool_position:n.align_to_page,tool_rect:n.mode_rect,tool_redo:n.redo,tool_reorient:n.reorient_path,tool_select:n.mode_select,tool_source:n.source_save,tool_square:n.mode_square,tool_text:n.mode_text,tool_topath:n.to_path,tool_undo:n.undo,tool_ungroup:n.ungroup,tool_wireframe:n.wireframe_mode,tool_zoom:n.mode_zoom,url_notice:n.no_embed},!0),{langParam:mi,langData:e}};function vi(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){if(!(Symbol.iterator in Object(e))&&"[object Arguments]"!==Object.prototype.toString.call(e))return;var n=[],i=!0,s=!1,o=void 0;try{for(var r,a=e[Symbol.iterator]();!(i=(r=a.next()).done)&&(n.push(r.value),!t||n.length!==t);i=!0);}catch(e){s=!0,o=e}finally{try{i||null==a.return||a.return()}finally{if(s)throw o}}return n}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}()}const{$q:xi}=Ke,wi={},Si=[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||27===t.which||!/textarea|select/i.test(t.target.nodeName)&&"text"!==t.target.type){var s="keypress"!==t.type&&e.hotkeys.specialKeys[t.which],o=String.fromCharCode(t.which).toLowerCase(),r="",a={};t.altKey&&"alt"!==s&&(r+="alt+"),t.ctrlKey&&"ctrl"!==s&&(r+="ctrl+"),t.metaKey&&!t.ctrlKey&&"meta"!==s&&(r+="meta+"),t.shiftKey&&"shift"!==s&&(r+="shift+"),s?a[r+s]=!0:(a[r+o]=!0,a[r+e.hotkeys.shiftNums[o]]=!0,"shift+"===r&&(a[e.hotkeys.shiftNums[o]]=!0));for(var l=0,c=i.length;l<c;l++)if(a[i[l]])return n.apply(this,arguments)}}}}return e.hotkeys={version:"0.8",specialKeys:{8:"backspace",9:"tab",13:"return",16:"shift",17:"ctrl",18:"alt",19:"pause",20:"capslock",27:"esc",32:"space",33:"pageup",34:"pagedown",35:"end",36:"home",37:"left",38:"up",39:"right",40:"down",45:"insert",46:"del",96:"0",97:"1",98:"2",99:"3",100:"4",101:"5",102:"6",103:"7",104:"8",105:"9",106:"*",107:"+",109:"-",110:".",111:"/",112:"f1",113:"f2",114:"f3",115:"f4",116:"f5",117:"f6",118:"f7",119:"f8",120:"f9",121:"f10",122:"f11",123:"f12",144:"numlock",145:"scroll",191:"/",224:"meta",219:"[",221:"]"},shiftNums:{"`":"~",1:"!",2:"@",3:"#",4:"$",5:"%",6:"^",7:"&",8:"*",9:"(",0:")","-":"_","=":"+",";":": ","'":'"',",":"<",".":">","/":"?","\\":"|"}},e.each(["keydown","keyup","keypress"],(function(){e.event.special[this]={add:t}})),e},function(e){const t={};return e.svgIcons=function(n,i={}){const s="http://www.w3.org/2000/svg",o=i.w||24,r=i.h||24;let a,l,c,u=!1,d=!1,h=0;const p="data:image/svg+xml;charset=utf-8;base64,";let g,f;if(i.svgz){g=e('<object data="'+n+'" type=image/svg+xml>').appendTo("body").hide();try{l=g[0].contentDocument,g.load(m),m(0,!0)}catch(e){v()}}else{const t=new DOMParser;e.ajax({url:n,dataType:"string",success(n){n?(l=t.parseFromString(n,"text/xml"),e((function(){m("ajax")}))):e(v)},error(n){window.opera?e((function(){v()})):n.responseText?(l=t.parseFromString(n.responseText,"text/xml"),l.childNodes.length||e(v),e((function(){m("ajax")}))):e(v)}})}function m(t,n){if("ajax"!==t){if(d)return;l=g[0].contentDocument;const e=l&&l.getElementById("svg_eof");if(!(e||n&&e))return h++,void(h<50?setTimeout(m,20):(v(),d=!0));d=!0}if(a=e(l.firstChild).children(),i.no_img)setTimeout((function(){u||b()}),500);else{const t=p+"PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNzUiIGhlaWdodD0iMjc1Ij48L3N2Zz4%3D";c=e(new Image).attr({src:t,width:0,height:0,alt:i.testIconAlt||"icon"}).appendTo("body").load((function(){b(!0)})).error((function(){b()}))}}function _(e,t,n,s){if(ci&&t.css("visibility","hidden"),i.replace){s&&t.attr("id",n);const o=e.attr("class");if(o&&t.attr("class","svg_icon "+o),!e.alt){let e="icon";i.alts&&(e=i.alts[n]||e),t.attr("alt",e)}e.replaceWith(t)}else e.append(t);ci&&setTimeout((function(){t.removeAttr("style")}),1)}function y(e,n){void 0!==i.id_match&&!1===i.id_match||_(f,e,n,!0),t[n]=e}function b(n=!1,l=!1){if(u)return;let d;if(i.no_img&&(n=!1),n&&(d=e(document.createElement("div")),d.hide().appendTo("body")),l){const t=i.fallback_path||"";e.each(l,(function(n,s){f=e("#"+n);let a="icon";i.alts&&(a=i.alts[n]||a);y(e(new Image).attr({class:"svg_icon",src:t+s,width:o,height:r,alt:a}),n)}))}else{const t=a.length;for(let l=0;l<t;l++){const t=a[l],{id:c}=t;if("svg_eof"===c)break;f=e("#"+c);const u=document.createElementNS(s,"svg");u.setAttribute("viewBox",[0,0,o,r].join(" "));let h=t.getElementsByTagNameNS(s,"svg")[0];const g=h.getAttribute("width"),m=h.getAttribute("height");h.removeAttribute("width"),h.removeAttribute("height");let _;if(h.getAttribute("viewBox")||h.setAttribute("viewBox",[0,0,g,m].join(" ")),u.setAttribute("xmlns",s),u.setAttribute("width",o),u.setAttribute("height",r),u.setAttribute("xmlns:xlink","http://www.w3.org/1999/xlink"),u.setAttribute("class","svg_icon"),ci||(h=h.cloneNode(!0)),u.append(h),n){d.empty().append(u);const t=p+pe(unescape(encodeURIComponent((new XMLSerializer).serializeToString(u))));let n="icon";i.alts&&(n=i.alts[c]||n),_=e(new Image).attr({class:"svg_icon",src:t,alt:n})}else _=ui(e(u),l);y(_,c)}}i.placement&&e.each(i.placement,(function(i,s){t[s]&&e(i).each((function(i){let o=t[s].clone();i>0&&!n&&(o=ui(o,i)),_(e(this),o,s)}))})),l||(n&&d.remove(),g&&g.remove(),c&&c.remove()),i.resize&&e.resizeSvgIcons(i.resize),u=!0,i.callback&&i.callback(t)}function v(){if(n.includes(".svgz")){const t=n.replace(".svgz",".svg");window.console&&console.log(".svgz failed, trying with .svg"),e.svgIcons(t,i)}else i.fallback&&b(!1,i.fallback)}},e.getSvgIcon=function(e,n){let i=t[e];return n&&i&&(i=ui(i,0).clone(!0)),i},e.resizeSvgIcons=function(t){const n=!e(".svg_icon:first").length;e.each(t,(function(t,i){const s=Array.isArray(i),o=s?i[0]:i,r=s?i[1]:i;n&&(t=t.replace(/\.svg_icon/g,"svg")),e(t).each((function(){this.setAttribute("width",o),this.setAttribute("height",r),window.opera&&window.widget&&(this.parentNode.style.width=o+"px",this.parentNode.style.height=r+"px")}))}))},e},function(e){e.loadingStylesheets||(e.loadingStylesheets=[]),e.loadingStylesheets.includes("jgraduate/css/jGraduate.css")||e.loadingStylesheets.push("jgraduate/css/jGraduate.css"),e.jGraduate={Paint:class{constructor(e){const t=e||{};if(this.alpha=isNaN(t.alpha)?100:t.alpha,t.copy)switch(this.type=t.copy.type,this.alpha=t.copy.alpha,this.solidColor=null,this.linearGradient=null,this.radialGradient=null,this.type){case"none":break;case"solidColor":this.solidColor=t.copy.solidColor;break;case"linearGradient":this.linearGradient=t.copy.linearGradient.cloneNode(!0);break;case"radialGradient":this.radialGradient=t.copy.radialGradient.cloneNode(!0)}else t.linearGradient?(this.type="linearGradient",this.solidColor=null,this.radialGradient=null,this.linearGradient=t.linearGradient.cloneNode(!0)):t.radialGradient?(this.type="radialGradient",this.solidColor=null,this.linearGradient=null,this.radialGradient=t.radialGradient.cloneNode(!0)):t.solidColor?(this.type="solidColor",this.solidColor=t.solidColor):(this.type="none",this.solidColor=null,this.linearGradient=null,this.radialGradient=null)}}},e.fn.jGraduateDefaults={paint:new e.jGraduate.Paint,window:{pickerTitle:"Drag markers to pick a paint"},images:{clientPath:"images/"},newstop:"inverse"};const t=navigator.userAgent.includes("Gecko/");function n(e,n,i){const s=document.createElementNS(di,e);return function(e,n){t?Object.entries(n).forEach(([t,n])=>{e.setAttribute(t,n)}):Object.entries(n).forEach(([t,n])=>{const i=e[t];i&&"SVGLength"===i.constructor?i.baseVal.value=n:e.setAttribute(t,n)})}(s,n),i&&i.append(s),s}return e.fn.jGraduate=function(t,i,s){return this.each((function(){const o=e(this),r=e.extend(!0,{},e.fn.jGraduateDefaults,t||{}),a=o.attr("id"),l="#"+o.attr("id")+" ";if(!l)return void e.alert("Container element must have an id attribute to maintain unique id strings for sub-elements.");const c=function(){switch(o.paint.type){case"radialGradient":o.paint.linearGradient=null;break;case"linearGradient":o.paint.radialGradient=null;break;case"solidColor":o.paint.radialGradient=o.paint.linearGradient=null}"function"==typeof o.okCallback&&o.okCallback(o.paint),o.hide()},u=function(){"function"==typeof o.cancelCallback&&o.cancelCallback(),o.hide()};e.extend(!0,o,{paint:new e.jGraduate.Paint({copy:r.paint}),okCallback:"function"==typeof i?i:null,cancelCallback:"function"==typeof s?s:null});let d=null;const h=e(window);"none"===o.paint.type&&(o.paint=new e.jGraduate.Paint({solidColor:"ffffff"})),o.addClass("jGraduate_Picker"),o.html('<ul class="jGraduate_tabs"><li class="jGraduate_tab_color jGraduate_tab_current" data-type="col">Solid Color</li><li class="jGraduate_tab_lingrad" data-type="lg">Linear Gradient</li><li class="jGraduate_tab_radgrad" data-type="rg">Radial Gradient</li></ul><div class="jGraduate_colPick"></div><div class="jGraduate_gradPick"></div><div class="jGraduate_LightBox"></div><div id="'+a+'_jGraduate_stopPicker" class="jGraduate_stopPicker"></div>');const p=e(l+"> .jGraduate_colPick"),g=e(l+"> .jGraduate_gradPick");g.html('<div id="'+a+'_jGraduate_Swatch" class="jGraduate_Swatch"><h2 class="jGraduate_Title">'+r.window.pickerTitle+'</h2><div id="'+a+'_jGraduate_GradContainer" class="jGraduate_GradContainer"></div><div id="'+a+'_jGraduate_StopSlider" class="jGraduate_StopSlider"></div></div><div class="jGraduate_Form jGraduate_Points jGraduate_lg_field"><div class="jGraduate_StopSection"><label class="jGraduate_Form_Heading">Begin Point</label><div class="jGraduate_Form_Section"><label>x:</label><input type="text" id="'+a+'_jGraduate_x1" size="3" title="Enter starting x value between 0.0 and 1.0"/><label>y:</label><input type="text" id="'+a+'_jGraduate_y1" size="3" title="Enter starting y value between 0.0 and 1.0"/></div></div><div class="jGraduate_StopSection"><label class="jGraduate_Form_Heading">End Point</label><div class="jGraduate_Form_Section"><label>x:</label><input type="text" id="'+a+'_jGraduate_x2" size="3" title="Enter ending x value between 0.0 and 1.0"/><label>y:</label><input type="text" id="'+a+'_jGraduate_y2" size="3" title="Enter ending y value between 0.0 and 1.0"/></div></div></div><div class="jGraduate_Form jGraduate_Points jGraduate_rg_field"><div class="jGraduate_StopSection"><label class="jGraduate_Form_Heading">Center Point</label><div class="jGraduate_Form_Section"><label>x:</label><input type="text" id="'+a+'_jGraduate_cx" size="3" title="Enter x value between 0.0 and 1.0"/><label>y:</label><input type="text" id="'+a+'_jGraduate_cy" size="3" title="Enter y value between 0.0 and 1.0"/></div></div><div class="jGraduate_StopSection"><label class="jGraduate_Form_Heading">Focal Point</label><div class="jGraduate_Form_Section"><label>Match center: <input type="checkbox" checked="checked" id="'+a+'_jGraduate_match_ctr"/></label><br/><label>x:</label><input type="text" id="'+a+'_jGraduate_fx" size="3" title="Enter x value between 0.0 and 1.0"/><label>y:</label><input type="text" id="'+a+'_jGraduate_fy" size="3" title="Enter y value between 0.0 and 1.0"/></div></div></div><div class="jGraduate_StopSection jGraduate_SpreadMethod"><label class="jGraduate_Form_Heading">Spread method</label><div class="jGraduate_Form_Section"><select class="jGraduate_spreadMethod"><option value=pad selected>Pad</option><option value=reflect>Reflect</option><option value=repeat>Repeat</option></select></div></div><div class="jGraduate_Form"><div class="jGraduate_Slider jGraduate_RadiusField jGraduate_rg_field"><label class="prelabel">Radius:</label><div id="'+a+'_jGraduate_Radius" class="jGraduate_SliderBar jGraduate_Radius" title="Click to set radius"><img id="'+a+'_jGraduate_RadiusArrows" class="jGraduate_RadiusArrows" src="'+r.images.clientPath+'rangearrows2.gif"></div><label><input type="text" id="'+a+'_jGraduate_RadiusInput" size="3" value="100"/>%</label></div><div class="jGraduate_Slider jGraduate_EllipField jGraduate_rg_field"><label class="prelabel">Ellip:</label><div id="'+a+'_jGraduate_Ellip" class="jGraduate_SliderBar jGraduate_Ellip" title="Click to set Ellip"><img id="'+a+'_jGraduate_EllipArrows" class="jGraduate_EllipArrows" src="'+r.images.clientPath+'rangearrows2.gif"></div><label><input type="text" id="'+a+'_jGraduate_EllipInput" size="3" value="0"/>%</label></div><div class="jGraduate_Slider jGraduate_AngleField jGraduate_rg_field"><label class="prelabel">Angle:</label><div id="'+a+'_jGraduate_Angle" class="jGraduate_SliderBar jGraduate_Angle" title="Click to set Angle"><img id="'+a+'_jGraduate_AngleArrows" class="jGraduate_AngleArrows" src="'+r.images.clientPath+'rangearrows2.gif"></div><label><input type="text" id="'+a+'_jGraduate_AngleInput" size="3" value="0"/>deg</label></div><div class="jGraduate_Slider jGraduate_OpacField"><label class="prelabel">Opac:</label><div id="'+a+'_jGraduate_Opac" class="jGraduate_SliderBar jGraduate_Opac" title="Click to set Opac"><img id="'+a+'_jGraduate_OpacArrows" class="jGraduate_OpacArrows" src="'+r.images.clientPath+'rangearrows2.gif"></div><label><input type="text" id="'+a+'_jGraduate_OpacInput" size="3" value="100"/>%</label></div></div><div class="jGraduate_OkCancel"><input type="button" id="'+a+'_jGraduate_Ok" class="jGraduate_Ok" value="OK"/><input type="button" id="'+a+'_jGraduate_Cancel" class="jGraduate_Cancel" value="Cancel"/></div>');const f={};e(".jGraduate_SliderBar").width(145);const m=e("#"+a+"_jGraduate_GradContainer")[0],_=n("svg",{id:a+"_jgraduate_svg",width:256,height:256,xmlns:di},m);let y=o.paint.type,b=o.paint[y],v=b;const x=o.paint.alpha,w="solidColor"===y;switch(y){case"solidColor":case"linearGradient":if(w||(v.id=a+"_lg_jgraduate_grad",b=v=_.appendChild(v)),n("radialGradient",{id:a+"_rg_jgraduate_grad"},_),"linearGradient"===y)break;case"radialGradient":w||(v.id=a+"_rg_jgraduate_grad",b=v=_.appendChild(v)),n("linearGradient",{id:a+"_lg_jgraduate_grad"},_)}let S;if(w){b=v=e("#"+a+"_lg_jgraduate_grad")[0],d=o.paint[y],R(0,"#"+d,1);const t=typeof r.newstop;if("string"===t)switch(r.newstop){case"same":R(1,"#"+d,1);break;case"inverse":{let e="";for(let t=0;t<6;t+=2){let n=(255-Number.parseInt(d.substr(t,2),16)).toString(16);n.length<2&&(n=0+n),e+=n}R(1,"#"+e,1);break}case"white":R(1,"#ffffff",1);break;case"black":R(1,"#000000",1)}else if("object"===t){const e="opac"in r.newstop?r.newstop.opac:1;R(1,r.newstop.color||"#"+d,e)}}const k=Number.parseFloat(b.getAttribute("x1")||0),C=Number.parseFloat(b.getAttribute("y1")||0),A=Number.parseFloat(b.getAttribute("x2")||1),E=Number.parseFloat(b.getAttribute("y2")||0),G=Number.parseFloat(b.getAttribute("cx")||.5),P=Number.parseFloat(b.getAttribute("cy")||.5),N=Number.parseFloat(b.getAttribute("fx")||G),I=Number.parseFloat(b.getAttribute("fy")||P),T=n("rect",{id:a+"_jgraduate_rect",x:0,y:0,width:256,height:256,fill:"url(#"+a+"_jgraduate_grad)","fill-opacity":x/100},_),L=e("<div/>").attr({class:"grad_coord jGraduate_lg_field",title:"Begin Stop"}).text(1).css({top:256*C,left:256*k}).data("coord","start").appendTo(m),M=L.clone().text(2).css({top:256*E,left:256*A}).attr("title","End stop").data("coord","end").appendTo(m),O=e("<div/>").attr({class:"grad_coord jGraduate_rg_field",title:"Center stop"}).text("C").css({top:256*P,left:256*G}).data("coord","center").appendTo(m),j=O.clone().text("F").css({top:256*I,left:256*N,display:"none"}).attr("title","Focus point").data("coord","focus").appendTo(m);let V;function R(t,i,s,o,l){const c=l||n("stop",{"stop-color":i,"stop-opacity":s,offset:t},v);l?(i=l.getAttribute("stop-color"),s=l.getAttribute("stop-opacity"),t=l.getAttribute("offset")):v.append(c),null===s&&(s=1);const u="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",d=n("path",{d:u,fill:"url(#jGraduate_trans)",transform:"translate("+(10+256*t)+", 26)"},S),p=n("path",{d:u,fill:i,"fill-opacity":s,transform:"translate("+(10+256*t)+", 26)",stroke:"#000","stroke-width":1.5},S);return e(p).mousedown((function(e){return H(this),F=D,h.mousemove(J).mouseup(X),q=B.offset(),e.preventDefault(),!1})).data("stop",c).data("bg",d).dblclick((function(){e("div.jGraduate_LightBox").show();const t=this;let n=Number(c.getAttribute("stop-opacity"))||1,s=c.getAttribute("stop-color")||1,o=(255*Number.parseFloat(n)).toString(16);for(;o.length<2;)o="0"+o;i=s.substr(1)+o,e("#"+a+"_jGraduate_stopPicker").css({left:100,bottom:15}).jPicker({window:{title:"Pick the start color and opacity for the gradient"},images:{clientPath:r.images.clientPath},color:{active:i,alphaSupport:!0}},(function(i,o){s=i.val("hex")?"#"+i.val("hex"):"none",n=null!==i.val("a")?i.val("a")/256:1,t.setAttribute("fill",s),t.setAttribute("fill-opacity",n),c.setAttribute("stop-color",s),c.setAttribute("stop-opacity",n),e("div.jGraduate_LightBox").hide(),e("#"+a+"_jGraduate_stopPicker").hide()}),null,(function(){e("div.jGraduate_LightBox").hide(),e("#"+a+"_jGraduate_stopPicker").hide()}))})),e(v).find("stop").each((function(){const n=e(this);if(Number(this.getAttribute("offset"))>t){if(!i){const e=this.getAttribute("stop-color"),t=this.getAttribute("stop-opacity");c.setAttribute("stop-color",e),p.setAttribute("fill",e),c.setAttribute("stop-opacity",null===t?1:t),p.setAttribute("fill-opacity",null===t?1:t)}return n.before(c),!1}return!0})),o&&H(p),c}j[0].id=a+"_jGraduate_focusCoord",e.each(["x1","y1","x2","y2","cx","cy","fx","fy"],(function(t,n){const i=isNaN(n[1]);let s=v.getAttribute(n);s||(s=i?"0.5":"x2"===n?"1.0":"0.0"),f[n]=e("#"+a+"_jGraduate_"+n).val(s).change((function(){isNaN(Number.parseFloat(this.value))||this.value<0?this.value=0:this.value>1&&(this.value=1),("f"!==n[0]||V)&&(i&&"radialGradient"===y||!i&&"linearGradient"===y)&&v.setAttribute(n,this.value);const e=i?"c"===n[0]?O:j:"1"===n[1]?L:M,t=n.includes("x")?"left":"top";e.css(t,256*this.value)})).change()}));const B=e("#"+a+"_jGraduate_StopSlider");let U,D,F;const z=n("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);function H(e){D&&D.setAttribute("stroke","#000"),e.setAttribute("stroke","blue"),D=e}let q;function X(){h.unbind("mousemove",J),"none"!==z.getAttribute("display")&&function(){z.setAttribute("display","none");const t=e(D),n=t.data("stop"),i=t.data("bg");e([D,n,i]).remove()}(),F=null}let W=1,$=1,Y=0,Q=G,K=P;function Z(){const e=Y?"rotate("+Y+","+Q+","+K+") ":"";if(1===W&&1===$)v.removeAttribute("gradientTransform");else{const t=-Q*(W-1),n=-K*($-1);v.setAttribute("gradientTransform",e+"translate("+t+","+n+") scale("+W+","+$+")")}}function J(t){let n=t.pageX-q.left;const i=t.pageY-q.top;n=n<10?10:n>266?266:n;const s="translate("+n+", 26)";i<-60||i>130?(z.setAttribute("display","block"),z.setAttribute("transform",s)):z.setAttribute("display","none"),F.setAttribute("transform",s),e.data(F,"bg").setAttribute("transform",s);const o=(n-10)/256;e.data(F,"stop").setAttribute("offset",o);let r=0;e(v).find("stop").each((function(t){const n=this.getAttribute("offset"),i=e(this);n<r&&(i.prev().before(i),U=e(v).find("stop")),r=n}))}const ee=n("svg",{width:"100%",height:45},B[0]),te=n("pattern",{width:16,height:16,patternUnits:"userSpaceOnUse",id:"jGraduate_trans"},ee),ne=n("image",{width:16,height:16},te),ie=r.images.clientPath+"map-opacity.png";ne.setAttributeNS(hi,"xlink:href",ie),e(ee).click((function(e){q=B.offset();const{target:t}=e;if("path"===t.tagName)return;let n=e.pageX-q.left-8;n=n<10?10:n>266?266:n,R(n/256,0,0,!0),e.stopPropagation()})),e(ee).mouseover((function(){ee.append(z)})),S=n("g",{},ee),n("line",{x1:10,y1:15,x2:266,y2:15,"stroke-width":2,stroke:"#000"},ee);const se=g.find(".jGraduate_spreadMethod").change((function(){v.setAttribute("spreadMethod",e(this).val())}));let oe=null;const re=function(e){let t=e.pageX-le.left,n=e.pageY-le.top;t=t<0?0:t>256?256:t,n=n<0?0:n>256?256:n,oe.css("left",t).css("top",n);const i=t/256,s=n/256,o=oe.data("coord"),r=v;switch(o){case"start":f.x1.val(i),f.y1.val(s),r.setAttribute("x1",i),r.setAttribute("y1",s);break;case"end":f.x2.val(i),f.y2.val(s),r.setAttribute("x2",i),r.setAttribute("y2",s);break;case"center":f.cx.val(i),f.cy.val(s),r.setAttribute("cx",i),r.setAttribute("cy",s),Q=i,K=s,Z();break;case"focus":f.fx.val(i),f.fy.val(s),r.setAttribute("fx",i),r.setAttribute("fy",s),Z()}e.preventDefault()},ae=function(){oe=null,h.unbind("mousemove",re).unbind("mouseup",ae)};U=v.getElementsByTagNameNS(di,"stop");let le,ce,ue,de,he=U.length;if(he<2){for(;he<2;)v.append(document.createElementNS(di,"stop")),++he;U=v.getElementsByTagNameNS(di,"stop")}for(let e=0;e<he;e++)R(0,0,0,0,U[e]);if(se.val(v.getAttribute("spreadMethod")||"pad"),V=!1,T.setAttribute("fill-opacity",x/100),e("#"+a+" div.grad_coord").mousedown((function(t){t.preventDefault(),oe=e(this),le=oe.parent().offset(),h.mousemove(re).mouseup(ae)})),e("#"+a+"_jGraduate_Ok").bind("click",(function(){o.paint.type=y,o.paint[y]=v.cloneNode(!0),o.paint.solidColor=null,c()})),e("#"+a+"_jGraduate_Cancel").bind("click",(function(e){u()})),"radialGradient"===y&&(V?j.show():(j.hide(),f.fx.val(""),f.fy.val(""))),e("#"+a+"_jGraduate_match_ctr")[0].checked=!V,e("#"+a+"_jGraduate_match_ctr").change((function(){V=!this.checked,j.toggle(V),f.fx.val(""),f.fy.val("");const e=v;if(V){const t=ce||.5,n=ue||.5;e.setAttribute("fx",t),e.setAttribute("fy",n),f.fx.val(t),f.fy.val(n)}else ce=e.getAttribute("fx"),ue=e.getAttribute("fy"),e.removeAttribute("fx"),e.removeAttribute("fy")})),U=v.getElementsByTagNameNS(di,"stop"),he=U.length,he<2){for(;he<2;)v.append(document.createElementNS(di,"stop")),++he;U=v.getElementsByTagNameNS(di,"stop")}let pe=0,ge=0;if("radialGradient"===y){const e=v.gradientTransform.baseVal;if(2===e.numberOfItems){const t=e.getItem(0),n=e.getItem(1);if(2===t.type&&3===n.type){const e=n.matrix;1!==e.a?pe=Math.round(100*-(1-e.a)):1!==e.d&&(pe=Math.round(100*(1-e.d)))}}else if(3===e.numberOfItems){const t=e.getItem(0),n=e.getItem(1),i=e.getItem(2);if(4===t.type&&2===n.type&&3===i.type){ge=Math.round(t.angle);const e=i.matrix;1!==e.a?pe=Math.round(100*-(1-e.a)):1!==e.d&&(pe=Math.round(100*(1-e.d)))}}}const fe={radius:{handle:"#"+a+"_jGraduate_RadiusArrows",input:"#"+a+"_jGraduate_RadiusInput",val:100*(v.getAttribute("r")||.5)},opacity:{handle:"#"+a+"_jGraduate_OpacArrows",input:"#"+a+"_jGraduate_OpacInput",val:o.paint.alpha||100},ellip:{handle:"#"+a+"_jGraduate_EllipArrows",input:"#"+a+"_jGraduate_EllipInput",val:pe},angle:{handle:"#"+a+"_jGraduate_AngleArrows",input:"#"+a+"_jGraduate_AngleInput",val:ge}};e.each(fe,(function(t,n){const i=e(n.handle);i.mousedown((function(s){const o=i.parent();de={type:t,elem:i,input:e(n.input),parent:o,offset:o.offset()},h.mousemove(me).mouseup(_e),s.preventDefault()})),e(n.input).val(n.val).change((function(){const e="radialGradient"===y;let n=Number(this.value),s=0;switch(t){case"radius":e&&v.setAttribute("r",n/100),s=(n/100)**.4/2*145;break;case"opacity":o.paint.alpha=n,T.setAttribute("fill-opacity",n/100),s=1.45*n;break;case"ellip":if(W=$=1,0===n){s=72.5;break}n>99.5&&(n=99.5),n>0?$=1-n/100:W=-n/100-1,s=(n+100)/2*145/100,e&&Z();break;case"angle":Y=n,s=Y/180,s+=.5,s*=145,e&&Z()}s>145?s=145:s<0&&(s=0),i.css({"margin-left":s-5})})).change()}));const me=function(e){!function(e){const{offset:{left:t}}=de,n=de.parent;let i=e.pageX-t-Number.parseInt(n.css("border-left-width"));i>145&&(i=145),i<=0&&(i=0);const s=i-5;switch(i/=145,de.type){case"radius":i=(2*i)**2.5,i>.98&&i<1.02&&(i=1),i<=.01&&(i=.01),v.setAttribute("r",i);break;case"opacity":o.paint.alpha=Number.parseInt(100*i),T.setAttribute("fill-opacity",i);break;case"ellip":W=1,$=1,i<.5?(i/=.5,W=i<=0?.01:i):i>.5&&(i/=.5,i=2-i,$=i<=0?.01:i),Z(),i-=1,$===i+1&&(i=Math.abs(i));break;case"angle":i-=.5,Y=i*=180,Z(),i/=100}de.elem.css({"margin-left":s}),i=Math.round(100*i),de.input.val(i)}(e),e.preventDefault()},_e=function(e){h.unbind("mousemove",me).unbind("mouseup",_e),de=null};let ye=(255*o.paint.alpha/100).toString(16);for(;ye.length<2;)ye="0"+ye;ye=ye.split(".")[0],d="none"===o.paint.solidColor?"":o.paint.solidColor+ye,w||(d=U[0].getAttribute("stop-color")),e.extend(e.fn.jPicker.defaults.window,{alphaSupport:!0,effects:{type:"show",speed:0}}),p.jPicker({window:{title:r.window.pickerTitle},images:{clientPath:r.images.clientPath},color:{active:d,alphaSupport:!0}},(function(e){o.paint.type="solidColor",o.paint.alpha=e.val("ahex")?Math.round(e.val("a")/255*100):100,o.paint.solidColor=e.val("hex")?e.val("hex"):"none",o.paint.radialGradient=null,c()}),null,(function(){u()}));const be=e(l+" .jGraduate_tabs li");let ve;switch(be.click((function(){be.removeClass("jGraduate_tab_current"),e(this).addClass("jGraduate_tab_current"),e(l+" > div").hide();const 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("#"+a+"_jgraduate_rect")[0].setAttribute("fill","url(#"+a+"_"+t+"_jgraduate_grad)"),y="lg"===t?"linearGradient":"radialGradient",e("#"+a+"_jGraduate_OpacInput").val(o.paint.alpha).change();const n=e("#"+a+"_"+t+"_jgraduate_grad")[0];if(v!==n){const t=e(v).find("stop");e(n).empty().append(t),v=n;const i=se.val();v.setAttribute("spreadMethod",i)}V="rg"===t&&null!==v.getAttribute("fx")&&!(G===N&&P===I),e("#"+a+"_jGraduate_focusCoord").toggle(V),V&&(e("#"+a+"_jGraduate_match_ctr")[0].checked=!1)}else e(l+" .jGraduate_gradPick").hide(),e(l+" .jGraduate_colPick").show()})),e(l+" > div").hide(),be.removeClass("jGraduate_tab_current"),o.paint.type){case"linearGradient":ve=e(l+" .jGraduate_tab_lingrad");break;case"radialGradient":ve=e(l+" .jGraduate_tab_radgrad");break;default:ve=e(l+" .jGraduate_tab_color")}o.show(),setTimeout(()=>{ve.addClass("jGraduate_tab_current").click()},10)}))},e},function(e){return e.loadingStylesheets||(e.loadingStylesheets=[]),e.loadingStylesheets.includes("spinbtn/jQuery.SpinButton.css")||e.loadingStylesheets.push("spinbtn/jQuery.SpinButton.css"),e.fn.SpinButton=function(t){function n(t,n){const i=document.body;let s=t[n];for(;(t=t.offsetParent)&&t!==i;)e.browser.msie&&"relative"===t.currentStyle.position||(s+=t[n]);return s}return t=t||{},this.each((function(){this.repeating=!1,this.spinCfg={min:isNaN(Number.parseFloat(t.min))?null:Number(t.min),max:isNaN(Number.parseFloat(t.max))?null:Number(t.max),step:t.step?Number(t.step):1,stepfunc:t.stepfunc||!1,page:t.page?Number(t.page):10,upClass:t.upClass||"up",downClass:t.downClass||"down",reset:t.reset||this.value,delay:t.delay?Number(t.delay):500,interval:t.interval?Number(t.interval):100,_btn_width:20,_direction:null,_delay:null,_repeat:null,callback:t.callback||null},this.spinCfg.smallStep=t.smallStep||this.spinCfg.step/2,this.adjustValue=function(e){let t;t=isNaN(this.value)?this.spinCfg.reset:"function"==typeof this.spinCfg.stepfunc?this.spinCfg.stepfunc(this,e):Number((Number(this.value)+Number(e)).toFixed(5)),null!==this.spinCfg.min&&(t=Math.max(t,this.spinCfg.min)),null!==this.spinCfg.max&&(t=Math.min(t,this.spinCfg.max)),this.value=t,"function"==typeof this.spinCfg.callback&&this.spinCfg.callback(this)},e(this).addClass(t.spinClass||"spin-button").mousemove((function(i){const s=i.pageX||i.x,o=i.pageY||i.y,r=i.target,a=t.stateObj.tool_scale||1,l=e(r).height()/2,c=s>n(r,"offsetLeft")+r.offsetWidth*a-this.spinCfg._btn_width?o<n(r,"offsetTop")+l*a?1:-1:0;if(c!==this.spinCfg._direction){switch(c){case 1:e(this).removeClass(this.spinCfg.downClass).addClass(this.spinCfg.upClass);break;case-1:e(this).removeClass(this.spinCfg.upClass).addClass(this.spinCfg.downClass);break;default:e(this).removeClass(this.spinCfg.upClass).removeClass(this.spinCfg.downClass)}this.spinCfg._direction=c}})).mouseout((function(){e(this).removeClass(this.spinCfg.upClass).removeClass(this.spinCfg.downClass),this.spinCfg._direction=null,window.clearInterval(this.spinCfg._repeat),window.clearTimeout(this.spinCfg._delay)})).mousedown((function(e){if(0===e.button&&0!==this.spinCfg._direction){const t=e.shiftKey?this.spinCfg.smallStep:this.spinCfg.step,n=()=>{this.adjustValue(this.spinCfg._direction*t)};n(),this.spinCfg._delay=window.setTimeout(()=>{n(),this.spinCfg._repeat=window.setInterval(n,this.spinCfg.interval)},this.spinCfg.delay)}})).mouseup((function(e){window.clearInterval(this.spinCfg._repeat),window.clearTimeout(this.spinCfg._delay)})).dblclick((function(t){e.browser.msie&&this.adjustValue(this.spinCfg._direction*this.spinCfg.step)})).keydown((function(e){switch(e.keyCode){case 38:this.adjustValue(this.spinCfg.step);break;case 40:this.adjustValue(-this.spinCfg.step);break;case 33:this.adjustValue(this.spinCfg.page);break;case 34:this.adjustValue(-this.spinCfg.page)}})).keypress((function(e){if(this.repeating)switch(e.keyCode){case 38:this.adjustValue(this.spinCfg.step);break;case 40:this.adjustValue(-this.spinCfg.step);break;case 33:this.adjustValue(this.spinCfg.page);break;case 34:this.adjustValue(-this.spinCfg.page)}else this.repeating=!0})).keyup((function(e){switch(this.repeating=!1,e.keyCode){case 38:case 40:case 33:case 34:case 13:this.adjustValue(0)}})).bind("mousewheel",(function(e){e.wheelDelta>=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()}))}))},e}
/**
* @file jQuery Context Menu Plugin
* Cory S.N. LaViska
* A Beautiful Site ({@link https://abeautifulsite.net/})
* Modified by Alexis Deveria
*
* More info: {@link https://abeautifulsite.net/2008/09/jquery-context-menu-plugin/}
*
* @module jQueryContextMenu
* @todo Update to latest version and adapt (and needs jQuery update as well): {@link https://github.com/swisnl/jQuery-contextMenu}
* @version 1.0.1
*
* @license (MIT OR GPL-2.0-or-later)
*
* This plugin is dual-licensed under the GNU General Public License
* and the MIT License and is copyright A Beautiful Site, LLC.
*
*/,P,function(e){const t=e(window),n=e(document);return e.extend(e.fn,{contextMenu(i,s){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(){const o=e(this),r=e(o).offset(),a=e("#"+i.menu);a.addClass("contextMenu"),e(this).bind("mousedown",(function(l){e(this).mouseup((function(c){const u=e(this);if(u.unbind("mouseup"),!(2===l.button||i.allowLeft||l.ctrlKey&&A()))return;if(c.stopPropagation(),e(".contextMenu").hide(),o.hasClass("disabled"))return!1;let d=c.pageX,h=c.pageY;const p=t.width()-a.width(),g=t.height()-a.height();d>p-15&&(d=p-15),h>g-30&&(h=g-30),n.unbind("click"),a.css({top:h,left:d}).fadeIn(i.inSpeed),a.find("A").mouseover((function(){a.find("LI.hover").removeClass("hover"),e(this).parent().addClass("hover")})).mouseout((function(){a.find("LI.hover").removeClass("hover")})),n.keypress((function(e){switch(e.keyCode){case 38:a.find("LI.hover").length?(a.find("LI.hover").removeClass("hover").prevAll("LI:not(.disabled)").eq(0).addClass("hover"),a.find("LI.hover").length||a.find("LI:last").addClass("hover")):a.find("LI:last").addClass("hover");break;case 40:a.find("LI.hover").length?(a.find("LI.hover").removeClass("hover").nextAll("LI:not(.disabled)").eq(0).addClass("hover"),a.find("LI.hover").length||a.find("LI:first").addClass("hover")):a.find("LI:first").addClass("hover");break;case 13:a.find("LI.hover A").trigger("click");break;case 27:n.trigger("click")}})),a.find("A").unbind("mouseup"),a.find("LI:not(.disabled) A").mouseup((function(){return n.unbind("click").unbind("keypress"),e(".contextMenu").hide(),s&&s(e(this).attr("href").substr(1),e(u),{x:d-r.left,y:h-r.top,docX:d,docY:h}),!1})),setTimeout((function(){n.click((function(){return n.unbind("click").unbind("keypress"),a.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(o).add(e("UL.contextMenu")).bind("contextmenu",(function(){return!1}))})),e(this))},disableContextMenuItems(t){return void 0===t?(e(this).find("LI").addClass("disabled"),e(this)):(e(this).each((function(){if(void 0!==t){const n=t.split(",");for(const t of n)e(this).find('A[href="'+t+'"]').parent().addClass("disabled")}})),e(this))},enableContextMenuItems(t){return void 0===t?(e(this).find("LI.disabled").removeClass("disabled"),e(this)):(e(this).each((function(){if(void 0!==t){const n=t.split(",");for(const t of n)e(this).find('A[href="'+t+'"]').parent().removeClass("disabled")}})),e(this))},disableContextMenu(){return e(this).each((function(){e(this).addClass("disabled")})),e(this)},enableContextMenu(){return e(this).each((function(){e(this).removeClass("disabled")})),e(this)},destroyContextMenu(){return e(this).each((function(){e(this).unbind("mousedown").unbind("mouseup")})),e(this)}}),e},function(e){e.loadingStylesheets||(e.loadingStylesheets=[]);e.loadingStylesheets.includes("jgraduate/css/jPicker.css")||e.loadingStylesheets.push("jgraduate/css/jPicker.css");class t{constructor(t,n){const i=this;function s(e){w.forEach(t=>{t.call(i,i,e)})}function o(n){const s=t.offset();d={l:0|s.left,t:0|s.top},clearTimeout(h),h=setTimeout((function(){l.call(i,n)}),0),e(document).bind("mousemove",r).bind("mouseup",a),n.preventDefault()}function r(e){return clearTimeout(h),h=setTimeout((function(){l.call(i,e)}),0),e.stopPropagation(),e.preventDefault(),!1}function a(t){return e(document).unbind("mouseup",a).unbind("mousemove",r),t.stopPropagation(),t.preventDefault(),!1}function l(e){const n=t.w,s=t.h;let o=e.pageX-d.l,r=e.pageY-d.t;o<0?o=0:o>n&&(o=n),r<0?r=0:r>s&&(r=s),c.call(i,"xy",{x:o/n*_+f,y:r/s*v+y})}function c(e,t,n){if(!(void 0!==t))switch(gi(e)&&(e="xy"),e.toLowerCase()){case"x":return p;case"y":return g;case"xy":default:return{x:p,y:g}}if(!gi(n)&&n===i)return;let o,r,a=!1;switch(gi(e)&&(e="xy"),e.toLowerCase()){case"x":o=t&&(t.x&&0|t.x||0|t)||0;break;case"y":r=t&&(t.y&&0|t.y||0|t)||0;break;case"xy":default:o=t&&t.x&&0|t.x||0,r=t&&t.y&&0|t.y||0}gi(o)||(o<f?o=f:o>m&&(o=m),p!==o&&(p=o,a=!0)),gi(r)||(r<y?r=y:r>b&&(r=b),g!==r&&(g=r,a=!0)),a&&s.call(i,n||i)}function u(e){"function"==typeof e&&w.push(e)}let d,h,p=0,g=0,f=0,m=100,_=100,y=0,b=100,v=100,x=t.find("img:first"),w=[];e.extend(!0,i,{val:c,range:function(e,t){if(!(void 0!==t))switch(gi(e)&&(e="all"),e.toLowerCase()){case"minx":return f;case"maxx":return m;case"rangex":return{minX:f,maxX:m,rangeX:_};case"miny":return y;case"maxy":return b;case"rangey":return{minY:y,maxY:b,rangeY:v};case"all":default:return{minX:f,maxX:m,rangeX:_,minY:y,maxY:b,rangeY:v}}let n,i,s,o;switch(gi(e)&&(e="all"),e.toLowerCase()){case"minx":n=t&&(t.minX&&0|t.minX||0|t)||0;break;case"maxx":i=t&&(t.maxX&&0|t.maxX||0|t)||0;break;case"rangex":n=t&&t.minX&&0|t.minX||0,i=t&&t.maxX&&0|t.maxX||0;break;case"miny":s=t&&(t.minY&&0|t.minY||0|t)||0;break;case"maxy":o=t&&(t.maxY&&0|t.maxY||0|t)||0;break;case"rangey":s=t&&t.minY&&0|t.minY||0,o=t&&t.maxY&&0|t.maxY||0;break;case"all":default:n=t&&t.minX&&0|t.minX||0,i=t&&t.maxX&&0|t.maxX||0,s=t&&t.minY&&0|t.minY||0,o=t&&t.maxY&&0|t.maxY||0}gi(n)||f===n||(f=n,_=m-f),gi(i)||m===i||(m=i,_=m-f),gi(s)||y===s||(y=s,v=b-y),gi(o)||b===o||(b=o,v=b-y)},bind:u,unbind:function(e){if("function"!=typeof e)return;let t;for(;t=w.includes(e);)w.splice(t,1)},destroy:function(){e(document).unbind("mouseup",a).unbind("mousemove",r),t.unbind("mousedown",o),t=null,x=null,w=null}}),x.src=n.arrow&&n.arrow.image,x.w=n.arrow&&n.arrow.width||x.width(),x.h=n.arrow&&n.arrow.height||x.height(),t.w=n.map&&n.map.width||t.width(),t.h=n.map&&n.map.height||t.height(),t.bind("mousedown",o),u.call(i,(function(){const e=t.w,n=t.h,i=x.w,s=x.h;let o=0,r=0;setTimeout((function(){_>0&&(o=p===m?e:p/_*e|0),v>0&&(r=g===b?n:g/v*n|0),i>=e?o=(e>>1)-(i>>1):o-=i>>1,s>=n?r=(n>>1)-(s>>1):r-=s>>1,x.css({left:o+"px",top:r+"px"})}))}))}}class n{constructor(t,n,i,s){const o=this,r=t.find("td.Text input");function a(e){if(""!==e.target.value||e.target===v.get(0)||(gi(i)||e.target===i.get(0))&&!gi(i)){if(!u(e))return e;switch(e.target){case p.get(0):switch(e.keyCode){case 38:return p.val(d.call(o,1+(p.val()<<0),0,255)),n.val("r",p.val(),e.target),!1;case 40:return p.val(d.call(o,(p.val()<<0)-1,0,255)),n.val("r",p.val(),e.target),!1}break;case g.get(0):switch(e.keyCode){case 38:return g.val(d.call(o,1+(g.val()<<0),0,255)),n.val("g",g.val(),e.target),!1;case 40:return g.val(d.call(o,(g.val()<<0)-1,0,255)),n.val("g",g.val(),e.target),!1}break;case f.get(0):switch(e.keyCode){case 38:return f.val(d.call(o,1+(f.val()<<0),0,255)),n.val("b",f.val(),e.target),!1;case 40:return f.val(d.call(o,(f.val()<<0)-1,0,255)),n.val("b",f.val(),e.target),!1}break;case m&&m.get(0):switch(e.keyCode){case 38:return m.val(d.call(o,Number.parseFloat(m.val())+1,0,100)),n.val("a",pi(255*m.val()/100,s),e.target),!1;case 40:return m.val(d.call(o,Number.parseFloat(m.val())-1,0,100)),n.val("a",pi(255*m.val()/100,s),e.target),!1}break;case _.get(0):switch(e.keyCode){case 38:return _.val(d.call(o,1+(_.val()<<0),0,360)),n.val("h",_.val(),e.target),!1;case 40:return _.val(d.call(o,(_.val()<<0)-1,0,360)),n.val("h",_.val(),e.target),!1}break;case y.get(0):switch(e.keyCode){case 38:return y.val(d.call(o,1+(y.val()<<0),0,100)),n.val("s",y.val(),e.target),!1;case 40:return y.val(d.call(o,(y.val()<<0)-1,0,100)),n.val("s",y.val(),e.target),!1}break;case b.get(0):switch(e.keyCode){case 38:return b.val(d.call(o,1+(b.val()<<0),0,100)),n.val("v",b.val(),e.target),!1;case 40:return b.val(d.call(o,(b.val()<<0)-1,0,100)),n.val("v",b.val(),e.target),!1}}}}function l(e){if(""!==e.target.value||e.target===v.get(0)||(gi(i)||e.target===i.get(0))&&!gi(i)){if(!u(e))return e;switch(e.target){case p.get(0):p.val(d.call(o,p.val(),0,255)),n.val("r",p.val(),e.target);break;case g.get(0):g.val(d.call(o,g.val(),0,255)),n.val("g",g.val(),e.target);break;case f.get(0):f.val(d.call(o,f.val(),0,255)),n.val("b",f.val(),e.target);break;case m&&m.get(0):m.val(d.call(o,m.val(),0,100)),n.val("a",pi(255*m.val()/100,s),e.target);break;case _.get(0):_.val(d.call(o,_.val(),0,360)),n.val("h",_.val(),e.target);break;case y.get(0):y.val(d.call(o,y.val(),0,100)),n.val("s",y.val(),e.target);break;case b.get(0):b.val(d.call(o,b.val(),0,100)),n.val("v",b.val(),e.target);break;case v.get(0):v.val(v.val().replace(/[^a-fA-F\d]/g,"").toLowerCase().substring(0,6)),i&&i.val(v.val()),n.val("hex",""!==v.val()?v.val():null,e.target);break;case i&&i.get(0):i.val(i.val().replace(/[^a-fA-F\d]/g,"").toLowerCase().substring(0,6)),v.val(i.val()),n.val("hex",""!==i.val()?i.val():null,e.target);break;case x&&x.get(0):x.val(x.val().replace(/[^a-fA-F\d]/g,"").toLowerCase().substring(0,2)),n.val("a",gi(x.val())?null:Number.parseInt(x.val(),16),e.target)}}}function c(e){if(!gi(n.val()))switch(e.target){case p.get(0):p.val(n.val("r"));break;case g.get(0):g.val(n.val("g"));break;case f.get(0):f.val(n.val("b"));break;case m&&m.get(0):m.val(pi(100*n.val("a")/255,s));break;case _.get(0):_.val(n.val("h"));break;case y.get(0):y.val(n.val("s"));break;case b.get(0):b.val(n.val("v"));break;case v.get(0):case i&&i.get(0):v.val(n.val("hex")),i&&i.val(n.val("hex"));break;case x&&x.get(0):x.val(n.val("ahex").substring(6))}}function u(e){switch(e.keyCode){case 9:case 16:case 29:case 37:case 39:return!1;case"c".charCodeAt():case"v".charCodeAt():if(e.ctrlKey)return!1}return!0}function d(e,t,n){return""===e||isNaN(e)?t:e>n?n:e<t?t:e}function h(e,t){const n=e.val("all");t!==p.get(0)&&p.val(gi(n)?"":n.r),t!==g.get(0)&&g.val(gi(n)?"":n.g),t!==f.get(0)&&f.val(gi(n)?"":n.b),m&&t!==m.get(0)&&m.val(gi(n)?"":pi(100*n.a/255,s)),t!==_.get(0)&&_.val(gi(n)?"":n.h),t!==y.get(0)&&y.val(gi(n)?"":n.s),t!==b.get(0)&&b.val(gi(n)?"":n.v),t!==v.get(0)&&(i&&t!==i.get(0)||!i)&&v.val(gi(n)?"":n.hex),i&&t!==i.get(0)&&t!==v.get(0)&&i.val(gi(n)?"":n.hex),x&&t!==x.get(0)&&x.val(gi(n)?"":n.ahex.substring(6))}let p=r.eq(3),g=r.eq(4),f=r.eq(5),m=r.length>7?r.eq(6):null,_=r.eq(0),y=r.eq(1),b=r.eq(2),v=r.eq(r.length>7?7:6),x=r.length>7?r.eq(8):null;e.extend(!0,o,{destroy:function(){p.add(g).add(f).add(m).add(_).add(y).add(b).add(v).add(i).add(x).unbind("keyup",l).unbind("blur",c),p.add(g).add(f).add(m).add(_).add(y).add(b).unbind("keydown",a),n.unbind(h),p=null,g=null,f=null,m=null,_=null,y=null,b=null,v=null,x=null}}),p.add(g).add(f).add(m).add(_).add(y).add(b).add(v).add(i).add(x).bind("keyup",l).bind("blur",c),p.add(g).add(f).add(m).add(_).add(y).add(b).bind("keydown",a),n.bind(h)}}e.jPicker={List:[],Color:function(t){const n=this;function i(e){for(let t=0;t<p.length;t++)p[t].call(n,n,e)}function s(e,t,p){const g=Boolean(t);if(g&&""===t.ahex&&(t.ahex="00000000"),!g){let t;if((gi(e)||""===e)&&(e="all"),gi(r))return null;switch(e.toLowerCase()){case"ahex":return o.rgbaToHex({r:r,g:a,b:l,a:c});case"hex":return s("ahex").substring(0,6);case"all":return{r:r,g:a,b:l,a:c,h:u,s:d,v:h,hex:s.call(n,"hex"),ahex:s.call(n,"ahex")};default:{t={};const n=e.length;[...e].forEach(e=>{switch(e){case"r":1===n?t=r:t.r=r;break;case"g":1===n?t=a:t.g=a;break;case"b":1===n?t=l:t.b=l;break;case"a":1===n?t=c:t.a=c;break;case"h":1===n?t=u:t.h=u;break;case"s":1===n?t=d:t.s=d;break;case"v":1===n?t=h:t.v=h}})}}return"object"!=typeof t||Object.keys(t).length?t:s.call(n,"all")}if(!gi(p)&&p===n)return;gi(e)&&(e="");let f=!1;if(gi(t))return gi(r)||(r=null,f=!0),gi(a)||(a=null,f=!0),gi(l)||(l=null,f=!0),gi(c)||(c=null,f=!0),gi(u)||(u=null,f=!0),gi(d)||(d=null,f=!0),gi(h)||(h=null,f=!0),void(f&&i.call(n,p||n));switch(e.toLowerCase()){case"ahex":case"hex":{const i=o.hexToRgba(t&&(t.ahex||t.hex)||t||"none");s.call(n,"rgba",{r:i.r,g:i.g,b:i.b,a:"ahex"===e?i.a:gi(c)?255:c},p);break}default:{if(t&&(!gi(t.ahex)||!gi(t.hex)))return void s.call(n,"ahex",t.ahex||t.hex||"00000000",p);const g={};let m=!1,_=!1;if(void 0===t.r||e.includes("r")||(e+="r"),void 0===t.g||e.includes("g")||(e+="g"),void 0===t.b||e.includes("b")||(e+="b"),void 0===t.a||e.includes("a")||(e+="a"),void 0===t.h||e.includes("h")||(e+="h"),void 0===t.s||e.includes("s")||(e+="s"),void 0===t.v||e.includes("v")||(e+="v"),[...e].forEach(e=>{switch(e){case"r":if(_)return;m=!0,g.r=t.r&&0|t.r||0|t||0,g.r<0?g.r=0:g.r>255&&(g.r=255),r!==g.r&&(({r:r}=g),f=!0);break;case"g":if(_)return;m=!0,g.g=t&&t.g&&0|t.g||t&&0|t||0,g.g<0?g.g=0:g.g>255&&(g.g=255),a!==g.g&&(({g:a}=g),f=!0);break;case"b":if(_)return;m=!0,g.b=t&&t.b&&0|t.b||t&&0|t||0,g.b<0?g.b=0:g.b>255&&(g.b=255),l!==g.b&&(({b:l}=g),f=!0);break;case"a":g.a=t&&!gi(t.a)?0|t.a:0|t,g.a<0?g.a=0:g.a>255&&(g.a=255),c!==g.a&&(({a:c}=g),f=!0);break;case"h":if(m)return;_=!0,g.h=t&&t.h&&0|t.h||t&&0|t||0,g.h<0?g.h=0:g.h>360&&(g.h=360),u!==g.h&&(({h:u}=g),f=!0);break;case"s":if(m)return;_=!0,g.s=gi(t.s)?0|t:0|t.s,g.s<0?g.s=0:g.s>100&&(g.s=100),d!==g.s&&(({s:d}=g),f=!0);break;case"v":if(m)return;_=!0,g.v=gi(t.v)?0|t:0|t.v,g.v<0?g.v=0:g.v>100&&(g.v=100),h!==g.v&&(({v:h}=g),f=!0)}}),f){if(m){r=r||0,a=a||0,l=l||0;const e=o.rgbToHsv({r:r,g:a,b:l});({h:u,s:d,v:h}=e)}else if(_){u=u||0,d=gi(d)?100:d,h=gi(h)?100:h;const e=o.hsvToRgb({h:u,s:d,v:h});({r:r,g:a,b:l}=e)}c=gi(c)?255:c,i.call(n,p||n)}break}}}let r,a,l,c,u,d,h,p=[];e.extend(!0,n,{val:s,bind:function(e){"function"==typeof e&&p.push(e)},unbind:function(e){if("function"!=typeof e)return;let t;for(;t=p.includes(e);)p.splice(t,1)},destroy:function(){p=null}}),t&&(gi(t.ahex)?gi(t.hex)?gi(t.r)||gi(t.g)||gi(t.b)?gi(t.h)||gi(t.s)||gi(t.v)||s("hsv"+(gi(t.a)?"":"a"),t):s("rgb"+(gi(t.a)?"":"a"),t):s((gi(t.a)?"":"a")+"hex",gi(t.a)?t:{ahex:t.hex+o.intToHex(t.a)}):s("ahex",t))},ColorMethods:{hexToRgba(e){if(""===e||"none"===e)return{r:null,g:null,b:null,a:null};let t="00",n="00",i="00",s="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),s=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(s)}},validateHex:e=>((e=e.toLowerCase().replace(/[^a-f\d]/g,"")).length>8&&(e=e.substring(0,8)),e),rgbaToHex(e){return this.intToHex(e.r)+this.intToHex(e.g)+this.intToHex(e.b)+this.intToHex(e.a)},intToHex(e){let t=(0|e).toString(16);return 1===t.length&&(t="0"+t),t.toLowerCase()},hexToInt:e=>Number.parseInt(e,16),rgbToHsv(e){const t=e.r/255,n=e.g/255,i=e.b/255,s={h:0,s:0,v:0};let o,r=0,a=0;return t>=n&&t>=i?(a=t,r=n>i?i:n):n>=i&&n>=t?(a=n,r=t>i?i:t):(a=i,r=n>t?t:n),s.v=a,s.s=a?(a-r)/a:0,s.s?(o=a-r,s.h=t===a?(n-i)/o:n===a?2+(i-t)/o:4+(t-n)/o,s.h=Number.parseInt(60*s.h),s.h<0&&(s.h+=360)):s.h=0,s.s=100*s.s|0,s.v=100*s.v|0,s},hsvToRgb(e){const t={r:0,g:0,b:0,a:100};let{h:n,s:i,v:s}=e;if(0===i)t.r=t.g=t.b=0===s?0:255*s/100|0;else{360===n&&(n=0),n/=60,i/=100,s/=100;const e=0|n,o=n-e,r=s*(1-i),a=s*(1-i*o),l=s*(1-i*(1-o));switch(e){case 0:t.r=s,t.g=l,t.b=r;break;case 1:t.r=a,t.g=s,t.b=r;break;case 2:t.r=r,t.g=s,t.b=l;break;case 3:t.r=r,t.g=a,t.b=s;break;case 4:t.r=l,t.g=r,t.b=s;break;case 5:t.r=s,t.g=r,t.b=a}t.r=255*t.r|0,t.g=255*t.g|0,t.b=255*t.b|0}return t}}};const{Color:i,List:s,ColorMethods:o}=e.jPicker;return e.fn.jPicker=function(r,a,l,c){return this.each((function(){const u=this,d=e.extend(!0,{},e.fn.jPicker.defaults,r);"input"===e(u).get(0).nodeName.toLowerCase()&&(e.extend(!0,d,{window:{bindToInput:!0,expandable:!0,input:e(u)}}),""===e(u).val()?(d.color.active=new i({hex:null}),d.color.current=new i({hex:null})):o.validateHex(e(u).val())&&(d.color.active=new i({hex:e(u).val(),a:d.color.active.val("a")}),d.color.current=new i({hex:e(u).val(),a:d.color.active.val("a")}))),d.window.expandable?e(u).after('<span class="jPicker"><span class="Icon"><span class="Color">&nbsp;</span><span class="Alpha">&nbsp;</span><span class="Image" title="Click To Open Color Picker">&nbsp;</span><span class="Container">&nbsp;</span></span></span>'):d.window.liveUpdate=!1;const h=Number.parseFloat(navigator.appVersion.split("MSIE")[1])<7&&document.body.filters;function p(e){const{active:t}=z,n=t.val("hex");let i,s;switch(d.color.mode=e,e){case"h":if(setTimeout((function(){x.call(u,Y,"transparent"),S.call(u,K,0),k.call(u,K,100),S.call(u,Z,260),k.call(u,Z,100),x.call(u,Q,"transparent"),S.call(u,ee,0),k.call(u,ee,100),S.call(u,te,260),k.call(u,te,100),S.call(u,ne,260),k.call(u,ne,100),S.call(u,ie,260),k.call(u,ie,100),S.call(u,oe,260),k.call(u,oe,100)}),0),re.range("all",{minX:0,maxX:100,minY:0,maxY:100}),ae.range("rangeY",{minY:0,maxY:360}),gi(t.val("ahex")))break;re.val("xy",{x:t.val("s"),y:100-t.val("v")},re),ae.val("y",360-t.val("h"),ae);break;case"s":if(setTimeout((function(){x.call(u,Y,"transparent"),S.call(u,K,-260),S.call(u,Z,-520),S.call(u,ee,-260),S.call(u,te,-520),S.call(u,oe,260),k.call(u,oe,100)}),0),re.range("all",{minX:0,maxX:360,minY:0,maxY:100}),ae.range("rangeY",{minY:0,maxY:100}),gi(t.val("ahex")))break;re.val("xy",{x:t.val("h"),y:100-t.val("v")},re),ae.val("y",100-t.val("s"),ae);break;case"v":if(setTimeout((function(){x.call(u,Y,"000000"),S.call(u,K,-780),S.call(u,Z,260),x.call(u,Q,n),S.call(u,ee,-520),S.call(u,te,260),k.call(u,te,100),S.call(u,oe,260),k.call(u,oe,100)}),0),re.range("all",{minX:0,maxX:360,minY:0,maxY:100}),ae.range("rangeY",{minY:0,maxY:100}),gi(t.val("ahex")))break;re.val("xy",{x:t.val("h"),y:100-t.val("s")},re),ae.val("y",100-t.val("v"),ae);break;case"r":if(i=-1040,s=-780,re.range("all",{minX:0,maxX:255,minY:0,maxY:255}),ae.range("rangeY",{minY:0,maxY:255}),gi(t.val("ahex")))break;re.val("xy",{x:t.val("b"),y:255-t.val("g")},re),ae.val("y",255-t.val("r"),ae);break;case"g":if(i=-1560,s=-1820,re.range("all",{minX:0,maxX:255,minY:0,maxY:255}),ae.range("rangeY",{minY:0,maxY:255}),gi(t.val("ahex")))break;re.val("xy",{x:t.val("b"),y:255-t.val("r")},re),ae.val("y",255-t.val("g"),ae);break;case"b":if(i=-2080,s=-2860,re.range("all",{minX:0,maxX:255,minY:0,maxY:255}),ae.range("rangeY",{minY:0,maxY:255}),gi(t.val("ahex")))break;re.val("xy",{x:t.val("r"),y:255-t.val("g")},re),ae.val("y",255-t.val("b"),ae);break;case"a":if(setTimeout((function(){x.call(u,Y,"transparent"),S.call(u,K,-260),S.call(u,Z,-520),S.call(u,ee,260),S.call(u,te,260),k.call(u,te,100),S.call(u,oe,0),k.call(u,oe,100)}),0),re.range("all",{minX:0,maxX:360,minY:0,maxY:100}),ae.range("rangeY",{minY:0,maxY:255}),gi(t.val("ahex")))break;re.val("xy",{x:t.val("h"),y:100-t.val("v")},re),ae.val("y",255-t.val("a"),ae);break;default:throw new Error("Invalid Mode")}switch(e){case"h":break;case"s":case"v":case"a":setTimeout((function(){k.call(u,K,100),k.call(u,ee,100),S.call(u,ne,260),k.call(u,ne,100),S.call(u,ie,260),k.call(u,ie,100)}),0);break;case"r":case"g":case"b":setTimeout((function(){x.call(u,Y,"transparent"),x.call(u,Q,"transparent"),k.call(u,ee,100),k.call(u,K,100),S.call(u,K,i),S.call(u,Z,i-260),S.call(u,ee,s-780),S.call(u,te,s-520),S.call(u,ne,s),S.call(u,ie,s-260),S.call(u,oe,260),k.call(u,oe,100)}),0)}gi(t.val("ahex"))||g.call(u,t)}function g(e,t){(gi(t)||t!==ae&&t!==re)&&_.call(u,e,t),setTimeout((function(){y.call(u,e),b.call(u,e),v.call(u,e)}),0)}function f(e,t){const{active:n}=z;if(t!==re&&gi(n.val()))return;const i=e.val("all");switch(d.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 m(e,t){const{active:n}=z;if(t===ae||!gi(n.val()))switch(d.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 _(e,t){if(t!==re)switch(d.color.mode){case"h":{const n=e.val("sv");re.val("xy",{x:gi(n)?100:n.s,y:100-(gi(n)?100:n.v)},t);break}case"s":case"a":{const n=e.val("hv");re.val("xy",{x:n&&n.h||0,y:100-(gi(n)?100:n.v)},t);break}case"v":{const n=e.val("hs");re.val("xy",{x:n&&n.h||0,y:100-(gi(n)?100:n.s)},t);break}case"r":{const n=e.val("bg");re.val("xy",{x:n&&n.b||0,y:255-(n&&n.g||0)},t);break}case"g":{const n=e.val("br");re.val("xy",{x:n&&n.b||0,y:255-(n&&n.r||0)},t);break}case"b":{const n=e.val("rg");re.val("xy",{x:n&&n.r||0,y:255-(n&&n.g||0)},t);break}}if(t!==ae)switch(d.color.mode){case"h":ae.val("y",360-(e.val("h")||0),t);break;case"s":{const n=e.val("s");ae.val("y",100-(gi(n)?100:n),t);break}case"v":{const n=e.val("v");ae.val("y",100-(gi(n)?100:n),t);break}case"r":ae.val("y",255-(e.val("r")||0),t);break;case"g":ae.val("y",255-(e.val("g")||0),t);break;case"b":ae.val("y",255-(e.val("b")||0),t);break;case"a":{const n=e.val("a");ae.val("y",255-(gi(n)?255:n),t);break}}}function y(e){try{const t=e.val("all");ce.css({backgroundColor:t&&"#"+t.hex||"transparent"}),k.call(u,ce,t&&pi(100*t.a/255,4)||0)}catch(e){}}function b(e){switch(d.color.mode){case"h":x.call(u,Y,new i({h:e.val("h")||0,s:100,v:100}).val("hex"));break;case"s":case"a":{const t=e.val("s");k.call(u,Z,100-(gi(t)?100:t));break}case"v":{const t=e.val("v");k.call(u,K,gi(t)?100:t);break}case"r":k.call(u,Z,pi((e.val("r")||0)/255*100,4));break;case"g":k.call(u,Z,pi((e.val("g")||0)/255*100,4));break;case"b":k.call(u,Z,pi((e.val("b")||0)/255*100))}const t=e.val("a");k.call(u,J,pi(100*(255-(t||0))/255,4))}function v(e){switch(d.color.mode){case"h":{const t=e.val("a");k.call(u,se,pi(100*(255-(t||0))/255,4));break}case"s":{const t=e.val("hva"),n=new i({h:t&&t.h||0,s:100,v:gi(t)?100:t.v});x.call(u,Q,n.val("hex")),k.call(u,te,100-(gi(t)?100:t.v)),k.call(u,se,pi(100*(255-(t&&t.a||0))/255,4));break}case"v":{const t=e.val("hsa"),n=new i({h:t&&t.h||0,s:gi(t)?100:t.s,v:100});x.call(u,Q,n.val("hex")),k.call(u,se,pi(100*(255-(t&&t.a||0))/255,4));break}case"r":case"g":case"b":{const t=e.val("rgba");let n=0,i=0;"r"===d.color.mode?(n=t&&t.b||0,i=t&&t.g||0):"g"===d.color.mode?(n=t&&t.b||0,i=t&&t.r||0):"b"===d.color.mode&&(n=t&&t.r||0,i=t&&t.g||0);const s=i>n?n:i;k.call(u,te,n>i?pi((n-i)/(255-i)*100,4):0),k.call(u,ne,i>n?pi((i-n)/(255-n)*100,4):0),k.call(u,ie,pi(s/255*100,4)),k.call(u,se,pi(100*(255-(t&&t.a||0))/255,4));break}case"a":{const t=e.val("a");x.call(u,Q,e.val("hex")||"000000"),k.call(u,se,gi(t)?100:0),k.call(u,oe,gi(t)?0:100);break}}}function x(e,t){e.css({backgroundColor:t&&6===t.length&&"#"+t||"transparent"})}function w(e,t){h&&(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 S(e,t){e.css({top:t+"px"})}function k(e,t){if(e.css({visibility:t>0?"visible":"hidden"}),t>0&&t<100)if(h){const n=e.attr("pngSrc");!gi(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:pi(t/100,4)})}else e.css({opacity:pi(t/100,4)});else if(0===t||100===t)if(h){const t=e.attr("pngSrc");!gi(t)&&(t.includes("AlphaBar.png")||t.includes("Bars.png")||t.includes("Maps.png"))?e.css({filter:"progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+t+"', sizingMethod='scale')"}):e.css({opacity:""})}else e.css({opacity:""})}function C(){z.active.val("ahex",z.current.val("ahex"))}function A(){z.current.val("ahex",z.active.val("ahex"))}function E(t){e(this).parents("tbody:first").find('input:radio[value!="'+t.target.value+'"]').removeAttr("checked"),p.call(u,t.target.value)}function G(){C.call(u)}function P(){C.call(u),d.window.expandable&&B.call(u),"function"==typeof c&&c.call(u,z.active,he)}function N(){A.call(u),d.window.expandable&&B.call(u),"function"==typeof a&&a.call(u,z.active,de)}function I(){R.call(u)}function T(e){const t=e.val("hex");ue.css({backgroundColor:t&&"#"+t||"transparent"}),k.call(u,ue,pi(100*(e.val("a")||0)/255,4))}function L(e){const t=e.val("hex"),n=e.val("va");ge.css({backgroundColor:t&&"#"+t||"transparent"}),k.call(u,fe,pi(100*(255-(n&&n.a||0))/255,4)),d.window.bindToInput&&d.window.updateInputColor&&d.window.input.css({backgroundColor:t&&"#"+t||"transparent",color:gi(n)||n.v>75?"#000000":"#ffffff"})}function M(t){H=Number.parseInt($.css("left")),q=Number.parseInt($.css("top")),X=t.pageX,W=t.pageY,e(document).bind("mousemove",O).bind("mouseup",j),t.preventDefault()}function O(t){return $.css({left:H-(X-t.pageX)+"px",top:q-(W-t.pageY)+"px"}),d.window.expandable&&!e.support.boxModel&&$.prev().css({left:$.css("left"),top:$.css("top")}),t.stopPropagation(),t.preventDefault(),!1}function j(t){return e(document).unbind("mousemove",O).unbind("mouseup",j),t.stopPropagation(),t.preventDefault(),!1}function V(t){return t.preventDefault(),t.stopPropagation(),z.active.val("ahex",e(this).attr("title")||null,t.target),!1}function R(){function t(){if(!d.window.expandable||e.support.boxModel)return;const t=$.find("table:first");$.before("<iframe/>"),$.prev().css({width:t.width(),height:$.height(),opacity:0,position:"absolute",left:$.css("left"),top:$.css("top")})}switch(z.current.val("ahex",z.active.val("ahex")),d.window.expandable&&(e(document.body).children("div.jPicker.Container").css({zIndex:10}),$.css({zIndex:20})),d.window.effects.type){case"fade":$.fadeIn(d.window.effects.speed.show,t);break;case"slide":$.slideDown(d.window.effects.speed.show,t);break;case"show":default:$.show(d.window.effects.speed.show,t)}}function B(){function t(){d.window.expandable&&$.css({zIndex:10}),d.window.expandable&&!e.support.boxModel&&$.prev().remove()}switch(d.window.effects.type){case"fade":$.fadeOut(d.window.effects.speed.hide,t);break;case"slide":$.slideUp(d.window.effects.speed.hide,t);break;case"show":default:$.hide(d.window.effects.speed.hide,t)}}function U(){const s=d.window,o=s.expandable?e(u).next().find(".Container:first"):null;$=s.expandable?e("<div/>"):e(u),$.addClass("jPicker Container"),s.expandable&&$.hide(),$.get(0).onselectstart=function(e){return"input"===e.target.nodeName.toLowerCase()};const r=z.active.val("all");s.alphaPrecision<0?s.alphaPrecision=0:s.alphaPrecision>2&&(s.alphaPrecision=2);const a=`<table class="jPicker" cellpadding="0" cellspacing="0">\n <tbody>\n ${s.expandable?'<tr><td class="Move" colspan="5">&nbsp;</td></tr>':""}\n <tr>\n <td rowspan="9"><h2 class="Title">${s.title||F.text.title}</h2><div class="Map"><span class="Map1">&nbsp;</span><span class="Map2">&nbsp;</span><span class="Map3">&nbsp;</span><img src="${D.clientPath+D.colorMap.arrow.file}" class="Arrow"/></div></td>\n <td rowspan="9"><div class="Bar"><span class="Map1">&nbsp;</span><span class="Map2">&nbsp;</span><span class="Map3">&nbsp;</span><span class="Map4">&nbsp;</span><span class="Map5">&nbsp;</span><span class="Map6">&nbsp;</span><img src="${D.clientPath+D.colorBar.arrow.file}" class="Arrow"/></div></td>\n <td colspan="2" class="Preview">${F.text.newColor}<div><span class="Active" title="${F.tooltips.colors.newColor}">&nbsp;</span><span class="Current" title="${F.tooltips.colors.currentColor}">&nbsp;</span></div>${F.text.currentColor}</td>\n <td rowspan="9" class="Button"><input type="button" class="Ok" value="${F.text.ok}" title="${F.tooltips.buttons.ok}"/><input type="button" class="Cancel" value="${F.text.cancel}" title="${F.tooltips.buttons.cancel}"/><hr/><div class="Grid">&nbsp;</div></td>\n </tr>\n <tr class="Hue">\n <td class="Radio"><label title="${F.tooltips.hue.radio}"><input type="radio" value="h"${"h"===d.color.mode?' checked="checked"':""}/>H:</label></td>\n <td class="Text"><input type="text" maxlength="3" value="${gi(r)?"":r.h}" title="${F.tooltips.hue.textbox}"/>&nbsp;&deg;</td>\n </tr>\n <tr class="Saturation">\n <td class="Radio"><label title="${F.tooltips.saturation.radio}"><input type="radio" value="s"${"s"===d.color.mode?' checked="checked"':""}/>S:</label></td>\n <td class="Text"><input type="text" maxlength="3" value="${gi(r)?"":r.s}" title="${F.tooltips.saturation.textbox}"/>&nbsp;%</td>\n </tr>\n <tr class="Value">\n <td class="Radio"><label title="${F.tooltips.value.radio}"><input type="radio" value="v"${"v"===d.color.mode?' checked="checked"':""}/>V:</label><br/><br/></td>\n <td class="Text"><input type="text" maxlength="3" value="${gi(r)?"":r.v}" title="${F.tooltips.value.textbox}"/>&nbsp;%<br/><br/></td>\n </tr>\n <tr class="Red">\n <td class="Radio"><label title="${F.tooltips.red.radio}"><input type="radio" value="r"${"r"===d.color.mode?' checked="checked"':""}/>R:</label></td>\n <td class="Text"><input type="text" maxlength="3" value="${gi(r)?"":r.r}" title="${F.tooltips.red.textbox}"/></td>\n </tr>\n <tr class="Green">\n <td class="Radio"><label title="${F.tooltips.green.radio}"><input type="radio" value="g"${"g"===d.color.mode?' checked="checked"':""}/>G:</label></td>\n <td class="Text"><input type="text" maxlength="3" value="${gi(r)?"":r.g}" title="${F.tooltips.green.textbox}"/></td>\n </tr>\n <tr class="Blue">\n <td class="Radio"><label title="${F.tooltips.blue.radio}"><input type="radio" value="b"${"b"===d.color.mode?' checked="checked"':""}/>B:</label></td>\n <td class="Text"><input type="text" maxlength="3" value="${gi(r)?"":r.b}" title="${F.tooltips.blue.textbox}"/></td>\n </tr>\n <tr class="Alpha">\n <td class="Radio">${s.alphaSupport?`<label title="${F.tooltips.alpha.radio}"><input type="radio" value="a"${"a"===d.color.mode?' checked="checked"':""}/>A:</label>`:"&nbsp;"}</td>\n <td class="Text">${s.alphaSupport?`<input type="text" maxlength="${3+s.alphaPrecision}" value="${gi(r)?"":pi(100*r.a/255,s.alphaPrecision)}" title="${F.tooltips.alpha.textbox}"/>&nbsp;%`:"&nbsp;"}</td>\n </tr>\n <tr class="Hex">\n <td colspan="2" class="Text"><label title="${F.tooltips.hex.textbox}">#:<input type="text" maxlength="6" class="Hex" value="${gi(r)?"":r.hex}"/></label>${s.alphaSupport?`<input type="text" maxlength="2" class="AHex" value="${gi(r)?"":r.ahex.substring(6)}" title="${F.tooltips.hex.alpha}"/></td>`:"&nbsp;"}\n </tr>\n </tbody></table>`;s.expandable?($.html(a),e(document.body).children("div.jPicker.Container").length?e(document.body).children("div.jPicker.Container:last").after($):e(document.body).prepend($),$.mousedown((function(){e(document.body).children("div.jPicker.Container").css({zIndex:10}),$.css({zIndex:20})})),$.css({left:"left"===s.position.x?o.offset().left-530-("center"===s.position.y?25:0)+"px":"center"===s.position.x?o.offset().left-260+"px":"right"===s.position.x?o.offset().left-10+("center"===s.position.y?25:0)+"px":"screenCenter"===s.position.x?(e(document).width()>>1)-260+"px":o.offset().left+Number.parseInt(s.position.x)+"px",position:"absolute",top:"top"===s.position.y?o.offset().top-312+"px":"center"===s.position.y?o.offset().top-156+"px":"bottom"===s.position.y?o.offset().top+25+"px":o.offset().top+Number.parseInt(s.position.y)+"px"})):($=e(u),$.html(a));const c=$.find("tbody:first");Y=c.find("div.Map:first"),Q=c.find("div.Bar:first");const h=Y.find("span"),_=Q.find("span");K=h.filter(".Map1:first"),Z=h.filter(".Map2:first"),J=h.filter(".Map3:first"),ee=_.filter(".Map1:first"),te=_.filter(".Map2:first"),ne=_.filter(".Map3:first"),ie=_.filter(".Map4:first"),se=_.filter(".Map5:first"),oe=_.filter(".Map6:first"),re=new t(Y,{map:{width:D.colorMap.width,height:D.colorMap.height},arrow:{image:D.clientPath+D.colorMap.arrow.file,width:D.colorMap.arrow.width,height:D.colorMap.arrow.height}}),re.bind(f),ae=new t(Q,{map:{width:D.colorBar.width,height:D.colorBar.height},arrow:{image:D.clientPath+D.colorBar.arrow.file,width:D.colorBar.arrow.width,height:D.colorBar.arrow.height}}),ae.bind(m),le=new n(c,z.active,s.expandable&&s.bindToInput?s.input:null,s.alphaPrecision);const y=gi(r)?null:r.hex,b=c.find(".Preview"),v=c.find(".Button");if(ce=b.find(".Active:first").css({backgroundColor:y&&"#"+y||"transparent"}),ue=b.find(".Current:first").css({backgroundColor:y&&"#"+y||"transparent"}).bind("click",G),k.call(u,ue,pi(100*z.current.val("a")/255,4)),de=v.find(".Ok:first").bind("click",N),he=v.find(".Cancel:first").bind("click",P),pe=v.find(".Grid:first"),setTimeout((function(){w.call(u,K,D.clientPath+"Maps.png"),w.call(u,Z,D.clientPath+"Maps.png"),w.call(u,J,D.clientPath+"map-opacity.png"),w.call(u,ee,D.clientPath+"Bars.png"),w.call(u,te,D.clientPath+"Bars.png"),w.call(u,ne,D.clientPath+"Bars.png"),w.call(u,ie,D.clientPath+"Bars.png"),w.call(u,se,D.clientPath+"bar-opacity.png"),w.call(u,oe,D.clientPath+"AlphaBar.png"),w.call(u,b.find("div:first"),D.clientPath+"preview-opacity.png")}),0),c.find("td.Radio input").bind("click",E),z.quickList&&z.quickList.length>0){let e="";for(let t=0;t<z.quickList.length;t++){"string"===(typeof z.quickList[t]).toString().toLowerCase()&&(z.quickList[t]=new i({hex:z.quickList[t]}));const n=z.quickList[t].val("a");let o=z.quickList[t].val("ahex");!s.alphaSupport&&o&&(o=o.substring(0,6)+"ff");const r=z.quickList[t].val("hex");o||(o="00000000"),e+='<span class="QuickColor" title="#'+o+'" style="background-color:'+(r&&"#"+r||"")+";"+(r?"":"background-image:url("+D.clientPath+"NoColor.png)")+(s.alphaSupport&&n&&n<255?";opacity:"+pi(n/255,4)+";filter:Alpha(opacity="+pi(n/2.55,4)+")":"")+'">&nbsp;</span>'}w.call(u,pe,D.clientPath+"bar-opacity.png"),pe.html(e),pe.find(".QuickColor").click(V)}p.call(u,d.color.mode),z.active.bind(g),"function"==typeof l&&z.active.bind(l),z.current.bind(T),s.expandable?(u.icon=o.parents(".Icon:first"),ge=u.icon.find(".Color:first").css({backgroundColor:y&&"#"+y||"transparent"}),fe=u.icon.find(".Alpha:first"),w.call(u,fe,D.clientPath+"bar-opacity.png"),k.call(u,fe,pi(100*(255-(gi(r)?0:r.a))/255,4)),me=u.icon.find(".Image:first").css({backgroundImage:"url('"+D.clientPath+D.picker.file+"')"}).bind("click",I),s.bindToInput&&s.updateInputColor&&s.input.css({backgroundColor:y&&"#"+y||"transparent",color:gi(r)||r.v>75?"#000000":"#ffffff"}),_e=c.find(".Move:first").bind("mousedown",M),z.active.bind(L)):R.call(u)}const{images:D,localization:F}=d,z={active:"string"===(typeof d.color.active).toString().toLowerCase()?new i({ahex:!d.window.alphaSupport&&d.color.active?d.color.active.substring(0,6)+"ff":d.color.active}):new i({ahex:!d.window.alphaSupport&&d.color.active.val("ahex")?d.color.active.val("ahex").substring(0,6)+"ff":d.color.active.val("ahex")}),current:"string"===(typeof d.color.active).toString().toLowerCase()?new i({ahex:!d.window.alphaSupport&&d.color.active?d.color.active.substring(0,6)+"ff":d.color.active}):new i({ahex:!d.window.alphaSupport&&d.color.active.val("ahex")?d.color.active.val("ahex").substring(0,6)+"ff":d.color.active.val("ahex")}),quickList:d.color.quickList};"function"!=typeof a&&(a=null),"function"!=typeof l&&(l=null),"function"!=typeof c&&(c=null);let H=null,q=null,X=null,W=null,$=null,Y=null,Q=null,K=null,Z=null,J=null,ee=null,te=null,ne=null,ie=null,se=null,oe=null,re=null,ae=null,le=null,ce=null,ue=null,de=null,he=null,pe=null,ge=null,fe=null,me=null,_e=null;e.extend(!0,u,{commitCallback:a,liveCallback:l,cancelCallback:c,color:z,show:R,hide:B,destroy:function(){$.find("td.Radio input").unbind("click",E),ue.unbind("click",G),he.unbind("click",P),de.unbind("click",N),d.window.expandable&&(me.unbind("click",I),_e.unbind("mousedown",M),u.icon=null),$.find(".QuickColor").unbind("click",V),Y=null,Q=null,K=null,Z=null,J=null,ee=null,te=null,ne=null,ie=null,se=null,oe=null,re.destroy(),re=null,ae.destroy(),ae=null,le.destroy(),le=null,ce=null,ue=null,de=null,he=null,pe=null,a=null,c=null,l=null,$.html("");for(let e=0;e<s.length;e++)s[e]===u&&(s.splice(e,1),e--)}}),s.push(u),setTimeout((function(){U.call(u)}),0)}))},e.fn.jPicker.defaults={window:{title:null,effects:{type:"slide",speed:{show:"slow",hide:"fast"}},position:{x:"screenCenter",y:"top"},expandable:!1,liveUpdate:!0,alphaSupport:!1,alphaPrecision:0,updateInputColor:!0},color:{mode:"h",active:new i({ahex:"#ffcc00ff"}),quickList:[new i({h:360,s:33,v:100}),new i({h:360,s:66,v:100}),new i({h:360,s:100,v:100}),new i({h:360,s:100,v:75}),new i({h:360,s:100,v:50}),new i({h:180,s:0,v:100}),new i({h:30,s:33,v:100}),new i({h:30,s:66,v:100}),new i({h:30,s:100,v:100}),new i({h:30,s:100,v:75}),new i({h:30,s:100,v:50}),new i({h:180,s:0,v:90}),new i({h:60,s:33,v:100}),new i({h:60,s:66,v:100}),new i({h:60,s:100,v:100}),new i({h:60,s:100,v:75}),new i({h:60,s:100,v:50}),new i({h:180,s:0,v:80}),new i({h:90,s:33,v:100}),new i({h:90,s:66,v:100}),new i({h:90,s:100,v:100}),new i({h:90,s:100,v:75}),new i({h:90,s:100,v:50}),new i({h:180,s:0,v:70}),new i({h:120,s:33,v:100}),new i({h:120,s:66,v:100}),new i({h:120,s:100,v:100}),new i({h:120,s:100,v:75}),new i({h:120,s:100,v:50}),new i({h:180,s:0,v:60}),new i({h:150,s:33,v:100}),new i({h:150,s:66,v:100}),new i({h:150,s:100,v:100}),new i({h:150,s:100,v:75}),new i({h:150,s:100,v:50}),new i({h:180,s:0,v:50}),new i({h:180,s:33,v:100}),new i({h:180,s:66,v:100}),new i({h:180,s:100,v:100}),new i({h:180,s:100,v:75}),new i({h:180,s:100,v:50}),new i({h:180,s:0,v:40}),new i({h:210,s:33,v:100}),new i({h:210,s:66,v:100}),new i({h:210,s:100,v:100}),new i({h:210,s:100,v:75}),new i({h:210,s:100,v:50}),new i({h:180,s:0,v:30}),new i({h:240,s:33,v:100}),new i({h:240,s:66,v:100}),new i({h:240,s:100,v:100}),new i({h:240,s:100,v:75}),new i({h:240,s:100,v:50}),new i({h:180,s:0,v:20}),new i({h:270,s:33,v:100}),new i({h:270,s:66,v:100}),new i({h:270,s:100,v:100}),new i({h:270,s:100,v:75}),new i({h:270,s:100,v:50}),new i({h:180,s:0,v:10}),new i({h:300,s:33,v:100}),new i({h:300,s:66,v:100}),new i({h:300,s:100,v:100}),new i({h:300,s:100,v:75}),new i({h:300,s:100,v:50}),new i({h:180,s:0,v:0}),new i({h:330,s:33,v:100}),new i({h:330,s:66,v:100}),new i({h:330,s:100,v:100}),new i({h:330,s:100,v:75}),new i({h:330,s:100,v:50}),new i]},images:{clientPath:"/jPicker/images/",colorMap:{width:256,height:256,arrow:{file:"mappoint.gif",width:15,height:15}},colorBar:{width:20,height:256,arrow:{file:"rangearrows.gif",width:20,height:7}},picker:{file:"picker.gif",width:25,height:24}},localization:{text:{title:"Drag Markers To Pick A Color",newColor:"new",currentColor:"current",ok:"OK",cancel:"Cancel"},tooltips:{colors:{newColor:"New Color - Press &ldquo;OK&rdquo; To Commit",currentColor:"Click To Revert To Original Color"},buttons:{ok:"Commit To This Color Selection",cancel:"Cancel And Revert To Original Color"},hue:{radio:"Set To &ldquo;Hue&rdquo; Color Mode",textbox:"Enter A &ldquo;Hue&rdquo; Value (0-360&deg;)"},saturation:{radio:"Set To &ldquo;Saturation&rdquo; Color Mode",textbox:"Enter A &ldquo;Saturation&rdquo; Value (0-100%)"},value:{radio:"Set To &ldquo;Value&rdquo; Color Mode",textbox:"Enter A &ldquo;Value&rdquo; Value (0-100%)"},red:{radio:"Set To &ldquo;Red&rdquo; Color Mode",textbox:"Enter A &ldquo;Red&rdquo; Value (0-255)"},green:{radio:"Set To &ldquo;Green&rdquo; Color Mode",textbox:"Enter A &ldquo;Green&rdquo; Value (0-255)"},blue:{radio:"Set To &ldquo;Blue&rdquo; Color Mode",textbox:"Enter A &ldquo;Blue&rdquo; Value (0-255)"},alpha:{radio:"Set To &ldquo;Alpha&rdquo; Color Mode",textbox:"Enter A &ldquo;Alpha&rdquo; Value (0-100)"},hex:{textbox:"Enter A &ldquo;Hex&rdquo; Color Value (#000000-#ffffff)",alpha:"Enter A &ldquo;Alpha&rdquo; Value (#00-#ff)"}}}},e}].reduce((e,t)=>t(e),jQuery);Si.loadingStylesheets.includes("svg-editor.css")||Si.loadingStylesheets.push("svg-editor.css");Si.loadingStylesheets.some(e=>!Array.isArray(e)||"images/logo.png"!==e[0])&&Si.loadingStylesheets.push(["images/logo.png",{favicon:!0}]),wi.tool_scale=1,wi.exportWindowCt=0,wi.langChanged=!1,wi.showSaveWarning=!1,wi.storagePromptState="ignore";const ki=[],Ci={lang:"",iconsize:"",bkgd_color:"#FFF",bkgd_url:"",img_save:"embed",save_notice_done:!1,export_notice_done:!1},Ai=["ext-connector.js","ext-eyedropper.js","ext-grid.js","ext-imagelib.js","ext-markers.js","ext-overview_window.js","ext-panning.js","ext-polygon.js","ext-shapes.js","ext-star.js","ext-storage.js"],Ei={canvasName:"default",canvas_expansion:3,initFill:{color:"FF0000",opacity:1},initStroke:{width:5,color:"000000",opacity:1},text:{stroke_width:0,font_size:24,font_family:"serif"},initOpacity:1,colorPickerCSS:null,initTool:"select",exportWindowType:"new",wireframe:!1,showlayers:!1,no_save_warning:!1,langPath:"locale/",extPath:"extensions/",canvgPath:"canvg/",jspdfPath:"jspdf/",imgPath:"images/",jGraduatePath:"jgraduate/images/",extIconsPath:"extensions/",dimensions:[640,480],gridSnapping:!1,gridColor:"#000",baseUnit:"px",snappingStep:10,showRulers:!0,preventAllURLConfig:!1,preventURLContentLoading:!1,lockExtensions:!1,noDefaultExtensions:!1,showGrid:!1,noStorageOnLoad:!1,forceStorage:!1,emptyStorageOnDecline:!1,avoidClientSide:!1,avoidClientSideDownload:!1,avoidClientSideOpen:!1},Gi=wi.uiStrings={};let Pi,Ni={},Ii=!1,Ti=!1,Li=!1,Mi={},Oi={extensions:[],stylesheets:[],allowedOrigins:[]};async function ji(e,{noAlert:t}={}){if(!(!1!==Pi.setSvgString(e))){if(t)throw new Error("Error loading SVG");await Si.alert(Gi.notification.errorLoadingSVG)}}function Vi({defaultLang:e,defaultName:t}){return async function({name:n=t,lang:i=e}={}){function s(e){return it(`${Oi.extPath}ext-locale/${n}/${e}.js`,{global:`svgEditorExtensionLocale_${n}_${e.replace(/-/g,"_")}`})}try{return await s(i)}catch(e){return s("en")}}}wi.pref=function(e,t,n){return n||t?(Mi[e]=t,void(wi.curPrefs=Mi)):e in Mi?Mi[e]:Ci[e]},wi.putLocale=async function(e,t,n){e?mi=e:navigator.userLanguage?mi=navigator.userLanguage:navigator.language&&(mi=navigator.language),console.log("Lang: "+mi),t.includes(mi)||"test"===mi||(mi="en");const i=n.langPath+"lang."+mi+".js";return bi(await it(i,{global:"svgEditorLang_"+mi.replace(/-/g,"_")}))},wi.readLang=bi,wi.setStrings=_i,wi.loadContentAndPrefs=function(){if(Oi.forceStorage||!Oi.noStorageOnLoad&&document.cookie.match(/(?:^|;\s*)svgeditstore=(?:prefsAndContent|prefsOnly)/)){if(wi.storage&&(Oi.forceStorage||!Oi.noStorageOnLoad&&document.cookie.match(/(?:^|;\s*)svgeditstore=prefsAndContent/))){const e="svgedit-"+Oi.canvasName,t=wi.storage.getItem(e);t&&wi.loadFromString(t)}Object.keys(Ci).forEach(e=>{const t="svg-edit-"+e;if(wi.storage){const n=wi.storage.getItem(t);n&&(Ci[e]=String(n))}else if(window.widget)Ci[e]=window.widget.preferenceForKey(t);else{const n=document.cookie.match(new RegExp("(?:^|;\\s*)"+$e(encodeURIComponent(t))+"=([^;]+)"));Ci[e]=n?decodeURIComponent(n[1]):""}})}},wi.setConfig=function(e,t){function n(e,t,n){e[t]&&"object"==typeof e[t]?Si.extend(!0,e[t],n):e[t]=n}t=t||{},Object.entries(e).forEach((function([e,i]){if({}.hasOwnProperty.call(Ci,e)){if(!1===t.overwrite&&(Oi.preventAllURLConfig||{}.hasOwnProperty.call(Mi,e)))return;!0===t.allowInitialUserOverride?Ci[e]=i:wi.pref(e,i)}else if(["extensions","stylesheets","allowedOrigins"].includes(e)){if(!1===t.overwrite&&(Oi.preventAllURLConfig||["allowedOrigins","stylesheets"].includes(e)||"extensions"===e&&Oi.lockExtensions))return;Oi[e]=Oi[e].concat(i)}else if({}.hasOwnProperty.call(Ei,e)){if(!1===t.overwrite&&(Oi.preventAllURLConfig||{}.hasOwnProperty.call(Oi,e)))return;if({}.hasOwnProperty.call(Oi,e)){if(!1===t.overwrite)return;n(Oi,e,i)}else!0===t.allowInitialUserOverride?n(Ei,e,i):Ei[e]&&"object"==typeof Ei[e]?(Oi[e]=Array.isArray(Ei[e])?[]:{},Si.extend(!0,Oi[e],i)):Oi[e]=i}})),wi.curConfig=Oi},wi.setCustomHandlers=function(e){return wi.ready((function(){e.open&&(Si('#tool_open > input[type="file"]').remove(),Si("#tool_open").show(),Pi.open=e.open),e.save&&(wi.showSaveWarning=!1,Pi.bind("saved",e.save)),e.exportImage&&(Ti=e.exportImage,Pi.bind("exported",Ti)),e.exportPDF&&(Li=e.exportPDF,Pi.bind("exportedPDF",Li))}))},wi.randomizeIds=function(e){Pi.randomizeIds(e)},wi.init=function(){!("svgEditor"in window)||!window.svgEditor||!1!==window.svgEditor.modules||Object.assign(Ei,{langPath:"../dist/locale/",extPath:"../dist/extensions/",canvgPath:"../dist/",jspdfPath:"../dist/"});try{"localStorage"in window&&(wi.storage=localStorage)}catch(e){}const e=[];function n(){Oi=Si.extend(!0,{},Ei,Oi),Oi.noDefaultExtensions||(Oi.extensions=Oi.extensions.concat(Ai)),["extensions","stylesheets","allowedOrigins"].forEach((function(e){Oi[e]=Si.grep(Oi[e],(function(t,n){return n===Oi[e].indexOf(t)}))})),wi.curConfig=Oi}Si("#lang_select option").each((function(){e.push(this.value)})),(()=>{const{search:e,searchParams:t}=new URL(location);if(e){if(Ni=function(e,t){const n={};return e.replace(/\+/g," ").split("&").forEach((function(e){const i=e.split("=");let s=decodeURIComponent(i[0]),o=s.split("]["),r=o.length-1;if(/\[/.test(o[0])&&/\]$/.test(o[r])?(o[r]=o[r].replace(/\]$/,""),o=o.shift().split("[").concat(o),r=o.length-1):r=0,i.length>=2){let e=decodeURIComponent(i.slice(1).join("="));if(t&&(e=e&&!isNaN(e)?+e:"undefined"===e?void 0:void 0!==rt[e]?rt[e]:e),r){let t=n;for(let n=0;n<=r;n++)s=""===o[n]?t.length:o[n],t=t[s]=n<r?t[s]||(o[n+1]&&isNaN(o[n+1])?{}:[]):e}else Array.isArray(n[s])?n[s].push(e):void 0!==n[s]?n[s]=[n[s],e]:n[s]=e}else s&&(n[s]=t?void 0:"")})),n}(t.toString(),!0),["initStroke","initFill"].forEach(e=>{t.has(e+"[color]")&&(Ni[e].color=t.get(e+"[color]"))}),t.has("bkgd_color")&&(Ni.bkgd_color="#"+t.get("bkgd_color")),Ni.dimensions&&(Ni.dimensions=Ni.dimensions.split(",")),Ni.extensions&&(Ni.extensions=Ni.extensions.match(/[:/\\]/)?"":Ni.extensions.split(",")),["langPath","extPath","canvgPath","jspdfPath","imgPath","jGraduatePath","extIconsPath"].forEach((function(e){Ni[e]&&delete Ni[e]})),wi.setConfig(Ni,{overwrite:!1}),n(),!Oi.preventURLContentLoading){let{source:e}=Ni;if(!e){const n=t.get("source");n&&n.startsWith("data:")&&(e=n)}if(e)return void(e.startsWith("data:")?wi.loadFromDataURI(e):wi.loadFromString(e));if(Ni.url)return void wi.loadFromURL(Ni.url)}Ni.noStorageOnLoad&&!Oi.forceStorage||wi.loadContentAndPrefs()}else n(),wi.loadContentAndPrefs()})(),Mi=Si.extend(!0,{},Ci,Mi),wi.curPrefs=Mi;const i=wi.setIcon=function(e,t,n){const i="string"==typeof t?Si.getSvgIcon(t,!0):t.clone();i?Si(e).empty().append(i):console.log("NOTE: Icon image missing: "+t)},s=async function(){const{langParam:t,langData:n}=await wi.putLocale(wi.pref("lang"),e,Oi);await Qt(t,n);const{ok:i,cancel:s}=Gi.common;at(Si,{ok:i,cancel:s}),Si.svgIcons(Oi.imgPath+"svg_edit_icons.svg",{w:24,h:24,id_match:!1,no_img:!w(),fallback_path:Oi.imgPath,fallback:{logo:"logo.png",select:"select.png",select_node:"select_node.png",square:"square.png",rect:"rect.png",fh_rect:"freehand-square.png",circle:"circle.png",ellipse:"ellipse.png",fh_ellipse:"freehand-circle.png",pencil:"fhpath.png",pen:"line.png",text:"text.png",path:"path.png",add_subpath:"add_subpath.png",close_path:"closepath.png",open_path:"openpath.png",image:"image.png",zoom:"zoom.png",arrow_right:"flyouth.png",arrow_right_big:"arrow_right_big.png",arrow_down:"dropdown.gif",fill:"fill.png",stroke:"stroke.png",opacity:"opacity.png",new_image:"clear.png",save:"save.png",export:"export.png",open:"open.png",import:"import.png",docprops:"document-properties.png",source:"source.png",wireframe:"wireframe.png",undo:"undo.png",redo:"redo.png",clone:"clone.png",delete:"delete.png",go_up:"go-up.png",go_down:"go-down.png",context_menu:"context_menu.png",move_bottom:"move_bottom.png",move_top:"move_top.png",to_path:"to_path.png",link_controls:"link_controls.png",reorient:"reorient.png",group_elements:"shape_group_elements.png",ungroup:"shape_ungroup.png",unlink_use:"unlink_use.png",width:"width.png",height:"height.png",c_radius:"c_radius.png",angle:"angle.png",blur:"blur.png",fontsize:"fontsize.png",align:"align.png",align_left:"align-left.png",align_center:"align-center.png",align_right:"align-right.png",align_top:"align-top.png",align_middle:"align-middle.png",align_bottom:"align-bottom.png",linecap_butt:"linecap_butt.png",linecap_square:"linecap_square.png",linecap_round:"linecap_round.png",linejoin_miter:"linejoin_miter.png",linejoin_bevel:"linejoin_bevel.png",linejoin_round:"linejoin_round.png",eye:"eye.png",no_color:"no_color.png",ok:"save.png",cancel:"cancel.png",warning:"warning.png",node_delete:"node_delete.png",node_clone:"node_clone.png",globe_link:"globe_link.png",config:"config.png"},placement:{"#logo":"logo","#tool_clear div,#layer_new":"new_image","#tool_save div":"save","#tool_export div":"export","#tool_open div":"open","#tool_import div":"import","#tool_source":"source","#tool_docprops > div":"docprops","#tool_editor_prefs > div":"config","#tool_editor_homepage > div":"globe_link","#tool_wireframe":"wireframe","#tool_undo":"undo","#tool_redo":"redo","#tool_select":"select","#tool_fhpath":"pencil","#tool_line":"pen","#tool_rect,#tools_rect_show":"rect","#tool_square":"square","#tool_fhrect":"fh_rect","#tool_ellipse,#tools_ellipse_show":"ellipse","#tool_circle":"circle","#tool_fhellipse":"fh_ellipse","#tool_path":"path","#tool_text,#layer_rename":"text","#tool_image":"image","#tool_zoom":"zoom","#tool_clone,#tool_clone_multi":"clone","#tool_node_clone":"node_clone","#layer_delete,#tool_delete,#tool_delete_multi":"delete","#tool_node_delete":"node_delete","#tool_add_subpath":"add_subpath","#tool_openclose_path":"open_path","#tool_move_top":"move_top","#tool_move_bottom":"move_bottom","#tool_topath":"to_path","#tool_node_link":"link_controls","#tool_reorient":"reorient","#tool_group_elements":"group_elements","#tool_ungroup":"ungroup","#tool_unlink_use":"unlink_use","#tool_alignleft, #tool_posleft":"align_left","#tool_aligncenter, #tool_poscenter":"align_center","#tool_alignright, #tool_posright":"align_right","#tool_aligntop, #tool_postop":"align_top","#tool_alignmiddle, #tool_posmiddle":"align_middle","#tool_alignbottom, #tool_posbottom":"align_bottom","#cur_position":"align","#linecap_butt,#cur_linecap":"linecap_butt","#linecap_round":"linecap_round","#linecap_square":"linecap_square","#linejoin_miter,#cur_linejoin":"linejoin_miter","#linejoin_round":"linejoin_round","#linejoin_bevel":"linejoin_bevel","#url_notice":"warning","#layer_up":"go_up","#layer_down":"go_down","#layer_moreopts":"context_menu","#layerlist td.layervis":"eye","#tool_source_save,#tool_docprops_save,#tool_prefs_save":"ok","#tool_source_cancel,#tool_docprops_cancel,#tool_prefs_cancel":"cancel","#rwidthLabel, #iwidthLabel":"width","#rheightLabel, #iheightLabel":"height","#cornerRadiusLabel span":"c_radius","#angleLabel":"angle","#linkLabel,#tool_make_link,#tool_make_link_multi":"globe_link","#zoomLabel":"zoom","#tool_fill label":"fill","#tool_stroke .icon_label":"stroke","#group_opacityLabel":"opacity","#blurLabel":"blur","#font_sizeLabel":"fontsize",".flyout_arrow_horiz":"arrow_right",".dropdown button, #main_button .dropdown":"arrow_down","#palette .palette_item:first, #fill_bg, #stroke_bg":"no_color"},resize:{"#logo .svg_icon":28,".flyout_arrow_horiz .svg_icon":5,".layer_button .svg_icon, #layerlist td.layervis .svg_icon":14,".dropdown button .svg_icon":7,"#main_button .dropdown .svg_icon":9,".palette_item:first .svg_icon":15,"#fill_bg .svg_icon, #stroke_bg .svg_icon":16,".toolbar_button button .svg_icon":16,".stroke_tool div div .svg_icon":20,"#tools_bottom label .svg_icon":18},async callback(e){Si(".toolbar_button button > svg, .toolbar_button button > img").each((function(){Si(this).parent().prepend(this)}));const t=Si("#tools_left");let n;t.length&&(n=t.offset().top+t.outerHeight());const i=wi.pref("iconsize");function s(e){switch(e){case"jgraduate/css/jPicker.css":return 1;case"jgraduate/css/jGraduate.css":return 2;case"svg-editor.css":return 3;case"spinbtn/jQuery.SpinButton.css":return 4;default:return 1/0}}wi.setIconSize(i||(Si(window).height()<n?"s":"m")),Si(".tools_flyout").each((function(){const e=Si("#"+this.id+"_show"),t=e.attr("data-curopt");if(!e.children("svg, img").length){const n=Si(t).children().clone();n.length&&(n[0].removeAttribute("style"),e.append(n))}}));let o=Si.loadingStylesheets.sort((e,t)=>{const n=s(e),i=s(t);return n===i?0:n>i});if(Oi.stylesheets.length){o=[...new Set(Oi.stylesheets)];const e=o.indexOf("@default");e>-1&&o.splice(e,1,...Si.loadingStylesheets)}await function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=t.before,i=t.after,s=t.favicon,o=t.canvas,r=t.image,a=void 0===r||r,l=t.acceptErrors;function c(e){var t={};if(Array.isArray(e)){var r=vi(e,2);e=r[0];var c=r[1];t=void 0===c?{}:c}var u=t.favicon,d=void 0===u?s:u,h=t,p=h.before,g=void 0===p?n:p,f=h.after,m=void 0===f?i:f,_=h.canvas,y=void 0===_?o:_,b=h.image,v=void 0===b?a:b;function x(){g?g.before(w):m?m.after(w):document.head.appendChild(w)}var w=document.createElement("link");return new Promise((function(n,i){var s=i;if(l&&(s="function"==typeof l?function(s){l({error:s,stylesheetURL:e,options:t,resolve:n,reject:i})}:n),e.endsWith(".css")?d=!1:e.endsWith(".ico")&&(d=!0),d){if(w.rel="shortcut icon",w.type="image/x-icon",!1===v)return w.href=e,x(),void n(w);var o=document.createElement("canvas");o.width=16,o.height=16;var r=o.getContext("2d"),a=document.createElement("img");return a.addEventListener("error",(function(e){i(e)})),a.addEventListener("load",(function(){r.drawImage(a,0,0),w.href=y?o.toDataURL("image/x-icon"):e,x(),n(w)})),void(a.src=e)}w.rel="stylesheet",w.type="text/css",w.href=e,x(),w.addEventListener("error",(function(e){s(e)})),w.addEventListener("load",(function(){n(w)}))}))}return e=Array.isArray(e)?e:[e],Promise.all(e.map((function(e){return c(e)})))}(o,{acceptErrors({stylesheetURL:e,reject:t,resolve:n}){Si.loadingStylesheets.includes(e)?t(new Error("Missing expected stylesheet: "+e)):n()}}),Si("#svg_container")[0].style.visibility="visible",await wi.runCallbacks()}});try{await Promise.all(Oi.extensions.map(async e=>{const n=e.match(/^ext-(.+)\.js/);if(!n)return;const i=Oi.extPath+e;try{const e=await it(i,{global:"svgEditorExtension_"+n[1].replace(/-/g,"_")}),{name:s=n[1],init:o}=e,r=Vi({defaultLang:t,defaultName:s});return wi.addExtension(s,o&&o.bind(wi),{$:Si,importLocale:r})}catch(t){return console.log(t),void console.error("Extension failed to load: "+e+"; "+t)}})),Pi.bind("extensions_added",(e,t)=>{Ri=!0,Xt.setAll(),Si(".flyout_arrow_horiz:empty").each((function(){Si(this).append(Si.getSvgIcon("arrow_right",!0).width(5).height(5))})),"ignore"===wi.storagePromptState&&Y(!0),Bi.forEach(e=>{Pi.call("message",e)})}),Pi.call("extensions_added")}catch(e){console.log(e)}},o={tool_scale:wi.tool_scale},r=function(){Si(".tools_flyout").each((function(){const e=Si("#"+this.id+"_show"),{left:t,top:n}=e.offset(),i=e.outerWidth();Si(this).css({left:(t+i)*wi.tool_scale,top:n})}))},a=function(){const e=/^(?:Moz|Webkit|Khtml|O|ms|Icab)(?=[A-Z])/,t=document.getElementsByTagName("script")[0];for(const n in t.style)if(e.test(n))return n.match(e)[0];return"WebkitOpacity"in t.style?"Webkit":"KhtmlOpacity"in t.style?"Khtml":""}(),l=wi.setIconSize=function(e){const t="#tools_top .toolset, #editor_panel > *, #history_panel > *, #main_button, #tools_left > *, #path_node_panel > *, #multiselected_panel > *, #g_panel > *, #tool_font_size > *, .tools_flyout",n=Si(t);let i=1;if("number"==typeof e)i=e;else{i={s:.75,m:1,l:1.25,xl:1.5}[e]}o.tool_scale=wi.tool_scale=i,r();const s=n.parents(":hidden");s.css("visibility","hidden").show(),function(e,t){const n=["top","left","bottom","right"];e.each((function(){const e=Si(this),i=e.outerWidth()*(t-1),s=e.outerHeight()*(t-1);for(let o=0;o<4;o++){const r=n[o];let a=e.data("orig_margin-"+r);Qe(a)&&(a=Number.parseInt(e.css("margin-"+r)),e.data("orig_margin-"+r,a));let l=a*t;"right"===r?l+=i:"bottom"===r&&(l+=s),e.css("margin-"+r,l)}}))}(n,i),s.css("visibility","visible").hide(),wi.pref("iconsize",e),Si("#iconsize").val(e);const l={"#tools_top":{left:50+Si("#main_button").width(),height:72},"#tools_left":{width:31,top:74},"div#workarea":{left:38,top:74}};let c=Si("#tool_size_rules");if(c.length?c.empty():c=Si('<style id="tool_size_rules"></style>').appendTo("head"),"m"!==e){let n="";Si.each(l,(function(t,s){t="#svg_editor "+t.replace(/,/g,", #svg_editor"),n+=t+"{",Si.each(s,(function(t,s){let o;"number"==typeof s?o=s*i+"px":(s[e]||s.all)&&(o=s[e]||s.all),n+=t+":"+o+";"})),n+="}"}));const s="-"+a.toLowerCase()+"-";n+=t+"{"+s+"transform: scale("+i+");} #svg_editor div.toolset .toolset {"+s+"transform: scale(1); margin: 1px !important;} #svg_editor .ui-slider {"+s+"transform: scale("+1/i+");}",c.text(n)}r()};wi.canvas=Pi=new li(document.getElementById("svgcanvas"),Oi);const c=A()?"meta+":"ctrl+",u=Pi.pathActions,{undoMgr:d}=Pi,h=Si("#workarea"),p=Si("#cmenu_canvas"),g={fill:null,stroke:null};let f,m,_=null,y=Oi.imgPath+"logo.png",b="crosshair",v="crosshair",x="toolbars";!function(){const e=window.opener||window.parent;if(e)try{const t=new e.CustomEvent("svgEditorReady",{bubbles:!0,cancelable:!0});e.document.documentElement.dispatchEvent(t)}catch(e){}}();const G=function(){const e=Si(".tool_button_current");e.length&&"tool_select"!==e[0].id&&(e.removeClass("tool_button_current").addClass("tool_button"),Si("#tool_select").addClass("tool_button_current").removeClass("tool_button"),Si("#styleoverrides").text("\n #svgcanvas svg * {\n cursor: move;\n pointer-events: all;\n }\n #svgcanvas svg {\n cursor: default;\n }\n ")),Pi.setMode("select"),h.css("cursor","auto")},P=Si("title:first").text(),N=[];for(let e=.1;e<1e5;e*=10)N.push(e),N.push(2*e),N.push(5*e);const I=function(e){let t;const n=[],i=Pi.getCurrentDrawing().getNumLayers();for(t=0;t<i;t++)n[t]=Pi.getCurrentDrawing().getLayerName(t);e?n.forEach(t=>{t!==e&&Pi.getCurrentDrawing().setLayerOpacity(t,.5)}):n.forEach(e=>{Pi.getCurrentDrawing().setLayerOpacity(e,1)})},T=function(){Pi.clearSelection();const e=Si("#layerlist tbody").empty(),t=Si("#selLayerNames").empty(),n=Pi.getCurrentDrawing(),i=n.getCurrentLayerName(),s=Si.getSvgIcon("eye");let o=Pi.getCurrentDrawing().getNumLayers();for(;o--;){const s=n.getLayerName(o),r=Si('<tr class="layer">').toggleClass("layersel",s===i),a=Si('<td class="layervis">').toggleClass("layerinvis",!n.getLayerVisibility(s)),l=Si('<td class="layername">'+s+"</td>");e.append(r.append(a,l)),t.append('<option value="'+s+'">'+s+"</option>")}if(void 0!==s){const t=s.clone();Si("td.layervis",e).append(t),Si.resizeSvgIcons({"td.layervis .svg_icon":14})}Si("#layerlist td.layername").mouseup((function(e){Si("#layerlist tr.layer").removeClass("layersel"),Si(this.parentNode).addClass("layersel"),Pi.setCurrentLayer(this.textContent),e.preventDefault()})).mouseover((function(){I(this.textContent)})).mouseout((function(){I()})),Si("#layerlist td.layervis").click((function(){const e=Si(this.parentNode).prevAll().length,t=Si("#layerlist tr.layer:eq("+e+") td.layername").text(),n=Si(this).hasClass("layerinvis");Pi.setLayerVisibility(t,n),Si(this).toggleClass("layerinvis")}));let r=5-Si("#layerlist tr.layer").size();for(;r-- >0;)e.append('<tr><td style="color:white">_</td><td/></tr>')};let L=!1,M="";const O=function(e,t){L||(L=!0,M=Pi.getSvgString(),Si("#save_output_btns").toggle(Boolean(t)),Si("#tool_source_back").toggle(!t),Si("#svg_source_textarea").val(M),Si("#svg_source_editor").fadeIn(),Si("#svg_source_textarea").focus())};let j=null,V=!1;const R=function(){window.opera&&Si("<p/>").hide().appendTo("body").remove()};function B(e,t){const{id:n}=e,s=n.split("_"),[o,r]=s;t&&Pi.setStrokeAttr("stroke-"+o,r),R(),i("#cur_"+o,n,20),Si(e).addClass("current").siblings().removeClass("current")}const U=wi.toolButtonClick=function(e,t){if(Si(e).hasClass("disabled"))return!1;if(Si(e).parent().hasClass("tools_flyout"))return!0;return t||Si(".tools_flyout").fadeOut("normal"),Si("#styleoverrides").text(""),h.css("cursor","auto"),Si(".tool_button_current").removeClass("tool_button_current").addClass("tool_button"),Si(e).addClass("tool_button_current").removeClass("tool_button"),!0},F=wi.clickSelect=function(){U("#tool_select")&&(Pi.setMode("select"),Si("#styleoverrides").text("\n #svgcanvas svg * {\n cursor: move;\n pointer-events: all;\n }\n #svgcanvas svg {\n cursor: default;\n }\n "))},H=wi.setImageURL=function(e){e||(e=y),Pi.setImageURL(e),Si("#image_url").val(e),e.startsWith("data:")?(Si("#image_url").hide(),Si("#change_image_url").show()):(Pi.embedImage(e,(function(t){Si("#url_notice").toggle(!t),y=e})),Si("#image_url").show(),Si("#change_image_url").hide())};function q(e,t){wi.pref("bkgd_color",e),wi.pref("bkgd_url",t,!0),Pi.setBackground(e,t)}async function W({cancelDeletes:e=!1}={}){let t=Pi.getHref(j);t=t.startsWith("data:")?"":t;const n=await Si.prompt(Gi.notification.enterNewImgURL,t);n?H(n):e&&Pi.deleteSelectedElements()}function $(e,t){let n,i;t||(t=Pi.getZoom()),e||(e=Si("#svgcanvas"));const s=Pi.getContentElem(),o=D()[Oi.baseUnit];for(n=0;n<2;n++){const r=0===n,a=r?"x":"y",l=r?"width":"height",c=Number(s.getAttribute(a)),u=Si("#ruler_"+a+" canvas:first"),d=u.clone();u.replaceWith(d);const h=d[0];let p=e[l]();const g=p;h.parentNode.style[l]=g+"px";let f,m,_,y=h.getContext("2d");if(y.fillStyle="rgb(200,0,0)",y.fillRect(0,0,h.width,h.height),d.siblings().remove(),p>=3e4){let e;for(_=Number.parseInt(p/3e4)+1,f=[],f[0]=y,i=1;i<_;i++)h[l]=3e4,e=h.cloneNode(!0),h.parentNode.append(e),f[i]=e.getContext("2d");e[l]=p%3e4,p=3e4}h[l]=p;const b=o*t,v=50/b;let x=1;for(i=0;i<N.length&&(m=N[i],x=m,!(v<=m));i++);const w=x*b;y.font="9px sans-serif";let S=c/b%x*b,k=S-w,C=0;for(;S<g;){k+=w;const e=Math.round(S)+.5;let t;if(r?(y.moveTo(e,15),y.lineTo(e,0)):(y.moveTo(15,e),y.lineTo(0,e)),m=(k-c)/b,x>=1)t=Math.round(m);else{const e=String(x).split(".")[1].length;t=m.toFixed(e)}if(0!==t&&1e3!==t&&t%1e3==0&&(t=t/1e3+"K"),r)y.fillText(t,S+2,8);else{const e=String(t).split("");for(i=0;i<e.length;i++)y.fillText(e[i],1,S+9+9*i)}const n=w/10;for(i=1;i<10;i++){let e=Math.round(S+n*i)+.5;if(f&&e>p){if(C++,y.stroke(),C>=_){i=10,S=g;continue}y=f[C],S-=3e4,e=Math.round(S+n*i)+.5}const t=i%2?12:10;r?(y.moveTo(e,15),y.lineTo(e,t)):(y.moveTo(15,e),y.lineTo(t,e))}S+=w}y.strokeStyle="#000",y.stroke()}}const Y=wi.updateCanvas=function(e,t){const n=Pi.getZoom(),i=h,s=Si("#svgcanvas");let o=h.width(),r=h.height();const a=o,l=r,c=i[0].scrollLeft+a/2,u=i[0].scrollTop+l/2,d=Oi.canvas_expansion;o=Math.max(a,Pi.contentW*n*d),r=Math.max(l,Pi.contentH*n*d),o===a&&r===l?h.css("overflow","hidden"):h.css("overflow","scroll");const p=s.height()/2,g=s.width()/2;s.width(o).height(r);const f=r/2,m=o/2,_=Pi.updateCanvas(o,r),y=m/g,b=o/2-a/2,v=r/2-l/2;if(t)t.x+=_.x,t.y+=_.y;else{t={x:m+(c-g)*y,y:f+(u-p)*y}}e?Pi.contentW>i.width()?(h[0].scrollLeft=_.x-10,h[0].scrollTop=_.y-10):(i[0].scrollLeft=b,i[0].scrollTop=v):(i[0].scrollLeft=t.x-a/2,i[0].scrollTop=t.y-l/2),Oi.showRulers&&($(s,n),h.scroll()),!0!==Ni.storagePrompt&&"ignore"===wi.storagePromptState&&Si("#dialog_box").hide()},Q=function(){const e="none"===Pi.getColor("fill"),t="none"===Pi.getColor("stroke"),n=["#tool_fhpath","#tool_line"],i=["#tools_rect .tool_button","#tools_ellipse .tool_button","#tool_text","#tool_path"];t?n.forEach(e=>{Si(e).hasClass("tool_button_current")&&F(),Si(e).addClass("disabled")}):n.forEach(e=>{Si(e).removeClass("disabled")}),t&&e?i.forEach(e=>{Si(e).hasClass("tool_button_current")&&F(),Si(e).addClass("disabled")}):i.forEach(e=>{Si(e).removeClass("disabled")}),Pi.runExtensions("toolButtonStateUpdate",{nofill:e,nostroke:t}),Si(".tools_flyout").each((function(){const e=Si("#"+this.id+"_show");let t=!1;Si(this).children().each((function(){Si(this).hasClass("disabled")||(t=!0)})),e.toggleClass("disabled",!t)})),R()},K=function(){let e=j;Qe(e)||e.parentNode||(e=null);const t=Pi.getCurrentDrawing().getCurrentLayerName(),n=Pi.getMode(),s="px"!==Oi.baseUnit?Oi.baseUnit:null,o="pathedit"===n,r=Si("#cmenu_canvas li");if(Si("#selected_panel, #multiselected_panel, #g_panel, #rect_panel, #circle_panel,#ellipse_panel, #line_panel, #text_panel, #image_panel, #container_panel, #use_panel, #a_panel").hide(),Qe(e))V?(Si("#multiselected_panel").show(),r.enableContextMenuItems("#group").disableContextMenuItems("#ungroup")):r.disableContextMenuItems("#delete,#cut,#copy,#group,#ungroup,#move_front,#move_up,#move_down,#move_back");else{const t=e.nodeName,a=Pi.getRotationAngle(e);Si("#angle").val(a);const l=Pi.getBlur(e);if(Si("#blur").val(l),Si("#blur_slider").slider("option","value",l),Pi.addedNew&&"image"===t&&"image"===Pi.getMode()&&(Pi.getHref(e).startsWith("data:")||W({cancelDeletes:!0})),o||"pathedit"===n){const e=u.getNodePoint();if(Si("#tool_add_subpath").removeClass("push_button_pressed").addClass("tool_button"),Si("#tool_node_delete").toggleClass("disabled",!u.canDeleteNodes),i("#tool_openclose_path",u.closed_subpath?"open_path":"close_path"),e){const t=Si("#seg_type");s&&(e.x=z(e.x),e.y=z(e.y)),Si("#path_node_x").val(e.x),Si("#path_node_y").val(e.y),e.type?t.val(e.type).removeAttr("disabled"):t.val(4).attr("disabled","disabled")}return}{if(Si("#selected_panel").show(),["line","circle","ellipse"].includes(t))Si("#xy_panel").hide();else{let n,i;if(["g","polyline","path"].includes(t)){const t=Pi.getStrokedBBox([e]);t&&({x:n,y:i}=t)}else n=e.getAttribute("x"),i=e.getAttribute("y");s&&(n=z(n),i=z(i)),Si("#selected_x").val(n||0),Si("#selected_y").val(i||0),Si("#xy_panel").show()}const n=!["image","text","path","g","use"].includes(t);Si("#tool_topath").toggle(n),Si("#tool_reorient").toggle("path"===t),Si("#tool_reorient").toggleClass("disabled",0===a)}const c={g:[],a:[],rect:["rx","width","height"],image:["width","height"],circle:["cx","cy","r"],ellipse:["cx","cy","rx","ry"],line:["x1","y1","x2","y2"],text:[],use:[]},{tagName:d}=e;let h=null;if("a"===d&&(h=Pi.getHref(e),Si("#g_panel").show()),"a"===e.parentNode.tagName&&(Si(e).siblings().length||(Si("#a_panel").show(),h=Pi.getHref(e.parentNode))),Si("#tool_make_link, #tool_make_link").toggle(!h),h&&Si("#link_url").val(h),c[d]){const t=c[d];if(Si("#"+d+"_panel").show(),Si.each(t,(function(t,n){let i=e.getAttribute(n);if("px"!==Oi.baseUnit&&e[n]){const t=e[n].baseVal.value;i=z(t)}Si("#"+d+"_"+n).val(i||0)})),"text"===d)Si("#text_panel").css("display","inline"),Si("#tool_font_size").css("display","inline"),Pi.getItalic()?Si("#tool_italic").addClass("push_button_pressed").removeClass("tool_button"):Si("#tool_italic").removeClass("push_button_pressed").addClass("tool_button"),Pi.getBold()?Si("#tool_bold").addClass("push_button_pressed").removeClass("tool_button"):Si("#tool_bold").removeClass("push_button_pressed").addClass("tool_button"),Si("#font_family").val(e.getAttribute("font-family")),Si("#font_size").val(e.getAttribute("font-size")),Si("#text").val(e.textContent),Pi.addedNew&&setTimeout((function(){Si("#text").focus().select()}),100);else if("image"===d&&"image"===Pi.getMode())H(Pi.getHref(e));else if("g"===d||"use"===d){Si("#container_panel").show();const e=Pi.getTitle(),t=Si("#g_title")[0];t.value=e,function(e){const t=Math.min(Math.max(12+6*e.value.length,50),300);Si(e).width(t)}(t),Si("#g_title").prop("disabled","use"===d)}}r[("g"===d?"en":"dis")+"ableContextMenuItems"]("#ungroup"),r[("g"!==d&&V?"en":"dis")+"ableContextMenuItems"]("#group")}Si("#tool_undo").toggleClass("disabled",0===d.getUndoStackSize()),Si("#tool_redo").toggleClass("disabled",0===d.getRedoStackSize()),Pi.addedNew=!1,e&&!o||V?(Si("#selLayerNames").removeAttr("disabled").val(t),p.enableContextMenuItems("#delete,#cut,#copy,#move_front,#move_up,#move_down,#move_back")):Si("#selLayerNames").attr("disabled","disabled")},Z=function(){if(Ot)return;const e=`\n #workarea.wireframe #svgcontent * {\n stroke-width: ${1/Pi.getZoom()}px;\n }\n `;Si("#wireframe_rules").text(h.hasClass("wireframe")?e:"")};let J="";const ee=function(e){e=e||Pi.getDocumentTitle();const t=P+(e?": "+e:"");Si("title:first").text(t)};const te=function(){Z()},ne=Pi.zoomChanged=function(e,t,n){const i=h,s=Pi.setBBoxZoom(t,i.width()-15,i.height()-15);if(!s)return;const o=s.zoom,r=s.bbox;o<.001?ie({value:.1}):(Si("#zoom").val((100*o).toFixed(1)),n?Y():Y(!1,{x:r.x*o+r.width*o/2,y:r.y*o+r.height*o/2}),"zoom"===Pi.getMode()&&r.width&&G(),te())},ie=function(e){const t=e.value/100;if(t<.001)return void(e.value=.1);const n=Pi.getZoom(),i=h;ne(window,{width:0,height:0,x:(i[0].scrollLeft+i.width()/2)/n,y:(i[0].scrollTop+i.height()/2)/n,zoom:t},!0)};Si("#cur_context_panel").delegate("a","click",(function(){const e=Si(this);return e.attr("data-root")?Pi.leaveContext():Pi.setContext(e.text()),Pi.clearSelection(),!1}));const se=function(){g.fill.prep(),g.stroke.prep()},oe={},re=function(){Si(".tools_flyout").each((function(){const e=Si("#"+this.id+"_show");if(e.data("isLibrary"))return;const t=Si(this).children().map((function(){return this.title})).get();e[0].title=t.join(" / ")}))},ae={},le=function(e){Si.each(e,(function(t,n){ae[t]||(ae[t]=[]),ae[t].push(...n);const i=Si(t).children().not(".tool_button_evt_handled"),s=t+"_show",o=Si(s);let r,a=!1;i.addClass("tool_button tool_button_evt_handled").unbind("click mousedown mouseup").each((function(){const t="#"+this.getAttribute("id"),[i,r]=Object.entries(n).find(([e,{sel:n}])=>n===t);oe[r.sel]=r.fn,r.isDefault&&(a=i);const l=function(t){let n,i=r;if("keydown"===t.type){const n=Si(i.parent+"_show").hasClass("tool_button_current"),s=Si(i.parent+"_show").attr("data-curopt");Object.entries(e[r.parent]).some(([o,a])=>a.sel===s&&(t.shiftKey&&n?(o=Number.parseInt(o),i=ae[r.parent][o+1]||e[r.parent][0]):i=a,!0))}return!Si(this).hasClass("disabled")&&(U(s)&&i.fn(),n=i.icon?Si.getSvgIcon(i.icon,!0):Si(i.sel).children().eq(0).clone(),n[0].setAttribute("width",o.width()),n[0].setAttribute("height",o.height()),o.children(":not(.flyout_arrow_horiz)").remove(),o.append(n).attr("data-curopt",i.sel),!0)};return Si(this).mouseup(l),r.key&&Si(document).bind("keydown",r.key[0]+" shift+"+r.key[0],l),!0})),a?o.attr("data-curopt",n[a].sel):o.attr("data-curopt")||o.attr("data-curopt",n[0].sel),o.mousedown((function(e){if(o.hasClass("disabled"))return!1;const n=Si(t),i=Si(s).position().left+34,a=-1*n.width(),l=n.data("shown_popop")?200:0;return r=setTimeout((function(){o.data("isLibrary")?n.css("left",i).show():n.css("left",a).show().animate({left:i},150),n.data("shown_popop",!0)}),l),e.preventDefault(),!0})).mouseup((function(e){clearTimeout(r);const t=Si(this).attr("data-curopt");o.data("isLibrary")&&Si(s.replace("_show","")).is(":visible")?U(s,!0):U(s)&&oe[t]&&oe[t]()}))})),re(),r()},ce=function(e,t){return Si("<div>",{class:"tools_flyout",id:e}).appendTo("#svg_editor").append(t)},ue=function(e,t,n,s){const o=Si(e),{dropUp:r}=s,a=Si(t);r&&Si(e).addClass("dropup"),a.find("li").bind("mouseup",(function(...e){s.seticon&&(i("#cur_"+o[0].id,Si(this).children()),Si(this).addClass("current").siblings().removeClass("current")),n.apply(this,...e)}));let l=!1;Si(window).mouseup((function(e){l||(o.removeClass("down"),a.hide(),a.css({top:0,left:0})),l=!1})),o.bind("mousedown",(function(){const e=o.offset();r?(e.top-=a.height(),e.left+=8):e.top+=o.height(),a.offset(e),o.hasClass("down")?(a.hide(),a.css({top:0,left:0})):(a.show(),l=!0),o.toggleClass("down")})).hover((function(){l=!0})).mouseout((function(){l=!1})),s.multiclick&&a.mousedown((function(){l=!0}))},de=[];Pi.bind("selected",(function(e,t){const n=Pi.getMode();"select"===n&&G();const s="pathedit"===n;j=1===t.length||Qe(t[1])?t[0]:null,V=t.length>=2&&!Qe(t[1]),Qe(j)||s||function(){let e,t;if(!Qe(j))switch(j.tagName){case"use":case"image":case"foreignObject":break;case"g":case"a":{const n=j.getElementsByTagName("*");let i=null;for(e=0,t=n.length;e<t;e++){const t=n[e].getAttribute("stroke-width");0===e?i=t:i!==t&&(i=null)}Si("#stroke_width").val(null===i?"":i),g.fill.update(!0),g.stroke.update(!0);break}default:{g.fill.update(!0),g.stroke.update(!0),Si("#stroke_width").val(j.getAttribute("stroke-width")||1),Si("#stroke_style").val(j.getAttribute("stroke-dasharray")||"none");let e=j.getAttribute("stroke-linejoin")||"miter";Si("#linejoin_"+e).length&&B(Si("#linejoin_"+e)[0]),e=j.getAttribute("stroke-linecap")||"butt",Si("#linecap_"+e).length&&B(Si("#linecap_"+e)[0])}}if(!Qe(j)){const e=100*(j.getAttribute("opacity")||1);Si("#group_opacity").val(e),Si("#opac_slider").slider("option","value",e),Si("#elem_id").val(j.id),Si("#elem_class").val(j.getAttribute("class"))}Q()}(),function(e,t){Si("#path_node_panel").toggle(e),Si("#tools_bottom_2,#tools_bottom_3").toggle(!e),e?(Si(".tool_button_current").removeClass("tool_button_current").addClass("tool_button"),Si("#tool_select").addClass("tool_button_current").removeClass("tool_button"),i("#tool_select","select_node"),V=!1,t.length&&(j=t[0])):setTimeout(()=>{i("#tool_select","select")},1e3)}(s,t),K(),Pi.runExtensions("selectedChanged",{elems:t,selectedElement:j,multiselected:V})})),Pi.bind("transition",(function(e,t){const n=Pi.getMode(),i=t[0];if(i){if(V=t.length>=2&&!Qe(t[1]),!V)switch(n){case"rotate":{const e=Pi.getRotationAngle(i);Si("#angle").val(e),Si("#tool_reorient").toggleClass("disabled",0===e);break}}Pi.runExtensions("elementTransition",{elems:t})}})),Pi.bind("changed",(function(e,t){const n=Pi.getMode();"select"===n&&G(),t.forEach(e=>{const t=e&&"svg"===e.tagName;t||function(e){return e&&"g"===e.tagName&&rn.CLASS_REGEX.test(e.getAttribute("class"))}(e)?(T(),t&&Y()):e&&j&&Qe(j.parentNode)&&(j=e)}),wi.showSaveWarning=!0,K(),j&&"select"===n&&(g.fill.update(),g.stroke.update()),Pi.runExtensions("elementChanged",{elems:t})})),Pi.bind("saved",(function(e,t){if(wi.showSaveWarning=!1,t='<?xml version="1.0"?>\n'+t,k())return void O(0,!0);const n=document.createElement("a");n.href="data:image/svg+xml;base64,"+pe(t),n.download="icon.svg",n.style.display="none",document.body.append(n),n.click();let i=wi.pref("save_notice_done");if("all"!==i){let e=Gi.notification.saveFromBrowser.replace("%s","SVG");S()?t.includes("<defs")?(e+="\n\n"+Gi.notification.defsFailOnSave,wi.pref("save_notice_done","all"),i="all"):wi.pref("save_notice_done","part"):wi.pref("save_notice_done","all"),"part"!==i&&Si.alert(e)}})),Pi.bind("exported",(function(e,t){const{issues:n,exportWindowName:i}=t;if(_=window.open(be||"",i),!_||_.closed)return void Si.alert(Gi.notification.popupWindowBlocked);_.location.href=t.bloburl||t.datauri;if("all"!==wi.pref("export_notice_done")){let e=Gi.notification.saveFromBrowser.replace("%s",t.type);if(n.length){const t="\n • ";e+="\n\n"+Gi.notification.noteTheseIssues+t+n.join(t)}wi.pref("export_notice_done","all"),_.alert(e)}})),Pi.bind("exportedPDF",(function(e,t){if(!t.output)return;const{exportWindowName:n}=t;n&&(_=window.open("",n)),_&&!_.closed?_.location.href=t.output:Si.alert(Gi.notification.popupWindowBlocked)})),Pi.bind("zoomed",ne),Pi.bind("zoomDone",te),Pi.bind("updateCanvas",(function(e,{center:t,newCtr:n}){Y(t,n)})),Pi.bind("contextset",(function(e,t){let n="";if(t){let e="";n='<a href="#" data-root="y">'+Pi.getCurrentDrawing().getCurrentLayerName()+"</a>",Si(t).parentsUntil("#svgcontent > g").andSelf().each((function(){this.id&&(e+=" > "+this.id,n+=this!==t?' > <a href="#">'+this.id+"</a>":" > "+this.id)})),J=e}else J=null;Si("#cur_context_panel").toggle(Boolean(t)).html(n),ee()})),Pi.bind("extension_added",(async function(e,t){if(!t)return;let n=!1,i=!1;if(t.langReady)if(wi.langChanged){const e=wi.pref("lang");await t.langReady({lang:e,uiStrings:Gi,importLocale:Vi({defaultLang:e,defaultName:t.name})}),Yt.push(t.name)}else de.push(t);const s=function(){t.callback&&!n&&(n=!0,t.callback.call(wi))},o=[];t.context_tools&&Si.each(t.context_tools,(function(e,t){const n=t.container_id?' id="'+t.container_id+'"':"";let i,s=Si("#"+t.panel);switch(s.length||(s=Si("<div>",{id:t.panel}).appendTo("#tools_top")),t.type){case"tool_button":{i='<div class="tool_button">'+t.id+"</div>";const e=Si(i).appendTo(s);t.events&&Si.each(t.events,(function(t,n){Si(e).bind(t,n)}));break}case"select":{i="<label"+n+'><select id="'+t.id+'">',Si.each(t.options,(function(e,n){const s=e===t.defval?" selected":"";i+='<option value="'+e+'"'+s+">"+n+"</option>"})),i+="</select></label>";const e=Si(i).appendTo(s).find("select");Si.each(t.events,(function(t,n){Si(e).bind(t,n)}));break}case"button-select":{i='<div id="'+t.id+'" class="dropdown toolset" title="'+t.title+'"><div id="cur_'+t.id+'" class="icon_label"></div><button></button></div>';const e=Si('<ul id="'+t.id+'_opts"></ul>').appendTo("#option_lists");t.colnum&&e.addClass("optcols"+t.colnum),Si(i).appendTo(s).children(),o.push({elem:"#"+t.id,list:"#"+t.id+"_opts",title:t.title,callback:t.events.change,cur:"#cur_"+t.id});break}case"input":{i="<label"+n+'><span id="'+t.id+'_label">'+t.label+':</span><input id="'+t.id+'" title="'+t.title+'" size="'+(t.size||"4")+'" value="'+(t.defval||"")+'" type="text"/></label>';const e=Si(i).appendTo(s).find("input");t.spindata&&e.SpinButton(t.spindata),t.events&&Si.each(t.events,(function(t,n){e.bind(t,n)}));break}}}));const{svgicons:r}=t;if(t.buttons){const e={},n={},a={},c={};if(Si.each(t.buttons,(function(t,i){let s,o,l,u,d,h,p,{id:g}=i,f=t;for(;Si("#"+g).length;)g=i.id+"_"+ ++f;if(r){e[g]=i.icon,n[g]=i.title;const t=i.svgicon||i.id;"app_menu"===i.type?a["#"+g+" > div"]=t:a["#"+g]=t}else s=Si('<img src="'+i.icon+(i.title?'" alt="'+i.title:"")+'">');switch(i.type){case"mode_flyout":case"mode":o="tool_button",l="#tools_left";break;case"context":o="tool_button",l="#"+i.panel,Si(l).length||Si("<div>",{id:i.panel}).appendTo("#tools_top");break;case"app_menu":o="",l="#main_menu ul"}const m=Si(i.list||"app_menu"===i.type?"<li/>":"<div/>").attr("id",g).attr("title",i.title).addClass(o);if(i.includeWith||i.list){if(i.list){if(m.addClass("push_button"),Si("#"+i.list+"_opts").append(m),i.isDefault){Si("#cur_"+i.list).append(m.children().clone());const e=i.svgicon||i.id;a["#cur_"+i.list]=e}}else if(i.includeWith){const e=i.includeWith;let t;p=Si(e.button),u=p.parent(),p.parent().hasClass("tools_flyout")||(t=p[0].id.replace("tool_","tools_"),d=p.clone().attr("id",t+"_show").append(Si("<div>",{class:"flyout_arrow_horiz"})),p.before(d),u=ce(t,p)),h=Xt.getButtonData(e.button),e.isDefault&&(a["#"+t+"_show"]=i.id);const n=c["#"+u[0].id]=[{sel:"#"+g,fn:i.events.click,icon:i.id,key:i.key,isDefault:Boolean(i.includeWith&&i.includeWith.isDefault)},h],s="position"in e?e.position:"last",o=u.children().length;!isNaN(s)&&s>=0&&s<o?u.children().eq(s).before(m):(u.append(m),n.reverse())}}else if("position"in i?Si(l).children().eq(i.position).length?Si(l).children().eq(i.position).before(m):Si(l).children().last().after(m):m.appendTo(l),"mode_flyout"===i.type){let e;p=Si(m),u=p.parent(),p.parent().hasClass("tools_flyout")||(e=p[0].id.replace("tool_","tools_"),d=p.clone().attr("id",e+"_show").append(Si("<div>",{class:"flyout_arrow_horiz"})),p.before(d),u=ce(e,p),u.data("isLibrary",!0),d.data("isLibrary",!0)),a["#"+e+"_show"]=i.id,c["#"+u[0].id]=[{sel:"#"+g,fn:i.events.click,icon:i.id,isDefault:!0}]}else"app_menu"===i.type&&m.append("<div>").append(i.title);r||m.append(s),i.list||Si.each(i.events,(function(e,t){"click"===e&&"mode"===i.type?(E()&&"click"===e&&(e="mousedown"),i.includeWith?m.bind(e,t):m.bind(e,(function(){U(m)&&t()})),i.key&&(Si(document).bind("keydown",i.key,t),i.title&&m.attr("title",i.title+" ["+i.key+"]"))):m.bind(e,t)})),le(c)})),Si.each(o,(function(){ue(this.elem,this.list,this.callback,{seticon:!0})})),r)return new Promise((t,n)=>{Si.svgIcons(r,{w:24,h:24,id_match:!1,no_img:!w(),fallback:e,placement:a,callback(e){"m"!==wi.pref("iconsize")&&(f&&(clearTimeout(f),f=null),i||(f=setTimeout((function(){i=!0,l(wi.pref("iconsize"))}),50))),s(),t()}})})}return s()})),Pi.textActions.setInputElem(Si("#text")[0]);let he='<div class="palette_item" data-rgb="none"></div>';Si.each(["#000000","#3f3f3f","#7f7f7f","#bfbfbf","#ffffff","#ff0000","#ff7f00","#ffff00","#7fff00","#00ff00","#00ff7f","#00ffff","#007fff","#0000ff","#7f00ff","#ff00ff","#ff007f","#7f0000","#7f3f00","#7f7f00","#3f7f00","#007f00","#007f3f","#007f7f","#003f7f","#00007f","#3f007f","#7f007f","#7f003f","#ffaaaa","#ffd4aa","#ffffaa","#d4ffaa","#aaffaa","#aaffd4","#aaffff","#aad4ff","#aaaaff","#d4aaff","#ffaaff","#ffaad4"],(function(e,t){he+='<div class="palette_item" style="background-color: '+t+';" data-rgb="'+t+'"></div>'})),Si("#palette").append(he);he="",Si.each(["#FFF","#888","#000","chessboard"],(function(e,t){he+="chessboard"===t?'<div class="color_block" data-bgcolor="'+t+'" style="background-image:url(data:image/gif;base64,R0lGODlhEAAQAIAAAP///9bW1iH5BAAAAAAALAAAAAAQABAAAAIfjG+gq4jM3IFLJgpswNly/XkcBpIiVaInlLJr9FZWAQA7);"></div>':'<div class="color_block" data-bgcolor="'+t+'" style="background-color:'+t+';"></div>'})),Si("#bg_blocks").append(he);const ge=Si("#bg_blocks div"),fe="cur_background";ge.each((function(){Si(this).click((function(){ge.removeClass(fe),Si(this).addClass(fe)}))})),q(wi.pref("bkgd_color"),wi.pref("bkgd_url")),Si("#image_save_opts input").val([wi.pref("img_save")]);const me=function(e,t){Qe(t)&&(t=e.value),Si("#group_opacity").val(t),e&&e.handle||Si("#opac_slider").slider("option","value",t),Pi.setOpacity(t/100)},_e=function(e,t,n){Qe(t)&&(t=e.value),Si("#blur").val(t);let i=!1;e&&e.handle||(Si("#blur_slider").slider("option","value",t),i=!0),n?Pi.setBlurNoUndo(t):Pi.setBlur(t,i)};Si("#stroke_style").change((function(){Pi.setStrokeAttr("stroke-dasharray",Si(this).val()),R()})),Si("#stroke_linejoin").change((function(){Pi.setStrokeAttr("stroke-linejoin",Si(this).val()),R()})),Si("select").change((function(){Si(this).blur()}));let ye=!1;Si("#selLayerNames").change((async function(){const e=this.options[this.selectedIndex].value,t=Gi.notification.QmoveElemsToLayer.replace("%s",e),n=function(t){t&&(ye=!0,Pi.moveSelectedToLayer(e),Pi.clearSelection(),T())};if(e)if(ye)n(!0);else{if(!await Si.confirm(t))return;n(!0)}})),Si("#font_family").change((function(){Pi.setFontFamily(this.value)})),Si("#seg_type").change((function(){Pi.setSegType(Si(this).val())})),Si("#text").bind("keyup input",(function(){Pi.setTextContent(this.value)})),Si("#image_url").change((function(){H(this.value)})),Si("#link_url").change((function(){this.value.length?Pi.setLinkURL(this.value):Pi.removeHyperlink()})),Si("#g_title").change((function(){Pi.setGroupTitle(this.value)})),Si(".attr_changer").change((function(){const e=this.getAttribute("data-attr");let t=this.value;if(!X(e,t,j))return this.value=j.getAttribute(e),Si.alert(Gi.notification.invalidAttrValGiven),!1;if("id"!==e&&"class"!==e)if(isNaN(t))t=Pi.convertToNum(e,t);else if("px"!==Oi.baseUnit){const n=D();(j[e]||"pathedit"===Pi.getMode()||"x"===e||"y"===e)&&(t*=n[Oi.baseUnit])}if("id"===e){const e=j;Pi.clearSelection(),e.id=t,Pi.addToSelection([e],!0)}else Pi.changeSelectedAttribute(e,t);return this.blur(),!0})),Si("#palette").mouseover((function(){const e=Si('<input type="hidden">');Si(this).append(e),e.focus().remove()})),Si(".palette_item").mousedown((function(e){const t=e.shiftKey||2===e.button?"stroke":"fill";let n,i=Si(this).data("rgb");"none"===i||"transparent"===i||"initial"===i?(i="none",n=new Si.jGraduate.Paint):n=new Si.jGraduate.Paint({alpha:100,solidColor:i.substr(1)}),g[t].setPaint(n),Pi.setColor(t,i),"none"!==i&&1!==Pi.getPaintOpacity(t)&&Pi.setPaintOpacity(t,1),Q()})).bind("contextmenu",(function(e){e.preventDefault()})),Si("#toggle_stroke_tools").on("click",(function(){Si("#tools_bottom").toggleClass("expanded")})),function(){const e=h[0];let t=null,n=null,i=!1,s=!1;Si("#svgcanvas").bind("mousemove mouseup",(function(s){return!1===i||(e.scrollLeft-=s.clientX-t,e.scrollTop-=s.clientY-n,t=s.clientX,n=s.clientY,"mouseup"===s.type&&(i=!1),!1)})).mousedown((function(e){return 1!==e.button&&!0!==s||(i=!0,t=e.clientX,n=e.clientY,!1)})),Si(window).mouseup((function(){i=!1})),Si(document).bind("keydown","space",(function(e){Pi.spaceKey=s=!0,e.preventDefault()})).bind("keyup","space",(function(e){e.preventDefault(),Pi.spaceKey=s=!1})).bind("keydown","shift",(function(e){"zoom"===Pi.getMode()&&h.css("cursor",v)})).bind("keyup","shift",(function(e){"zoom"===Pi.getMode()&&h.css("cursor",b)})),wi.setPanning=function(e){Pi.spaceKey=s=e}}(),function(){const e=Si("#main_icon"),t=Si("#main_icon span"),n=Si("#main_menu");let i=!1,s=0,o=!0,r=!1;Si(window).mouseup((function(t){i||(e.removeClass("buttondown"),"INPUT"!==t.target.tagName?n.fadeOut(200):r||(r=!0,Si(t.target).click((function(){n.css("margin-left","-9999px").show()})))),i=!1})).mousedown((function(e){Si(e.target).closest("div.tools_flyout, .contextMenu").length||Si(".tools_flyout:visible,.contextMenu").fadeOut(250)})),t.bind("mousedown",(function(){e.hasClass("buttondown")?n.fadeOut(200):(n.css("margin-left",0).show(),s||(s=n.height()),n.css("height",0).animate({height:s},200),i=!0),e.toggleClass("buttondown buttonup")})).hover((function(){i=!0})).mouseout((function(){i=!1}));const a=Si("#main_menu li");a.mouseover((function(){o="rgba(0, 0, 0, 0)"===Si(this).css("background-color"),a.unbind("mouseover"),o&&a.mouseover((function(){this.style.backgroundColor="#FFC"})).mouseout((function(){return this.style.backgroundColor="transparent",!0}))}))}(),wi.addDropDown=function(e,t,n){if(!Si(e).length)return;const i=Si(e).find("button"),s=Si(e).find("ul").attr("id",Si(e)[0].id+"-list");n?Si(e).addClass("dropup"):Si("#option_lists").append(s),s.find("li").bind("mouseup",t);let o=!1;Si(window).mouseup((function(e){o||(i.removeClass("down"),s.hide()),o=!1})),i.bind("mousedown",(function(){if(i.hasClass("down"))s.hide();else{if(!n){const t=Si(e).position();s.css({top:t.top+24,left:t.left-10})}s.show(),o=!0}i.toggleClass("down")})).hover((function(){o=!0})).mouseout((function(){o=!1}))},wi.addDropDown("#font_family_dropdown",(function(){Si("#font_family").val(Si(this).text()).change()})),wi.addDropDown("#opacity_dropdown",(function(){if(Si(this).find("div").length)return;const e=Number.parseInt(Si(this).text().split("%")[0]);me(!1,e)}),!0),Si("#opac_slider").slider({start(){Si("#opacity_dropdown li:not(.special)").hide()},stop(){Si("#opacity_dropdown li").show(),Si(window).mouseup()},slide(e,t){me(t)}}),wi.addDropDown("#blur_dropdown",Si.noop);let ve=!1;Si("#blur_slider").slider({max:10,step:.1,stop(e,t){ve=!1,_e(t),Si("#blur_dropdown li").show(),Si(window).mouseup()},start(){ve=!0},slide(e,t){_e(t,null,ve)}}),wi.addDropDown("#zoom_dropdown",(function(){const e=Si(this),t=e.data("val");t?ne(window,t):ie({value:Number.parseFloat(e.text())})}),!0),ue("#stroke_linecap","#linecap_opts",(function(){B(this,!0)}),{dropUp:!0}),ue("#stroke_linejoin","#linejoin_opts",(function(){B(this,!0)}),{dropUp:!0}),ue("#tool_position","#position_opts",(function(){const e=this.id.replace("tool_pos","").charAt(0);Pi.alignSelectedElements(e,"page")}),{multiclick:!0}),function(){let e;const t=function(){Si(e).blur()};Si("#svg_editor").find("button, select, input:not(#text)").focus((function(){e=this,x="toolbars",h.mousedown(t)})).blur((function(){x="canvas",h.unbind("mousedown",t),"textedit"===Pi.getMode()&&Si("#text").focus()}))}();const xe=function(){U("#tool_fhpath")&&Pi.setMode("fhpath")},we=function(){U("#tool_line")&&Pi.setMode("line")},Se=function(){U("#tool_square")&&Pi.setMode("square")},ke=function(){U("#tool_rect")&&Pi.setMode("rect")},Ce=function(){U("#tool_fhrect")&&Pi.setMode("fhrect")},Ae=function(){U("#tool_circle")&&Pi.setMode("circle")},Ee=function(){U("#tool_ellipse")&&Pi.setMode("ellipse")},Ge=function(){U("#tool_fhellipse")&&Pi.setMode("fhellipse")},Pe=function(){U("#tool_image")&&Pi.setMode("image")},Ne=function(){U("#tool_zoom")&&(Pi.setMode("zoom"),h.css("cursor",b))},Ie=function(e){const t=Pi.getResolution();e=e?t.zoom*e:1,Si("#zoom").val(100*e),Pi.setZoom(e),te(),Y(!0)},Te=function(){U("#tool_zoom")&&(Ie(),G())},Le=function(){U("#tool_text")&&Pi.setMode("text")},Me=function(){U("#tool_path")&&Pi.setMode("path")},Oe=function(){Qe(j)&&!V||Pi.deleteSelectedElements()},je=function(){Qe(j)&&!V||Pi.cutSelectedElements()},Ve=function(){Qe(j)&&!V||Pi.copySelectedElements()},Re=function(){const e=Pi.getZoom(),t=(h[0].scrollLeft+h.width()/2)/e-Pi.contentW,n=(h[0].scrollTop+h.height()/2)/e-Pi.contentH;Pi.pasteElements("point",t,n)},Be=function(){Qe(j)||Pi.moveToTopSelectedElement()},Ue=function(){Qe(j)||Pi.moveToBottomSelectedElement()},De=function(e){Qe(j)||Pi.moveUpDownSelected(e)},Fe=function(){Qe(j)||Pi.convertToPath()},ze=function(){Qe(j)||u.reorient()},He=async function(){if(!Qe(j)||V){const e=await Si.prompt(Gi.notification.enterNewLinkURL,"http://");e&&Pi.makeHyperlink(e)}},qe=function(e,t){if(!Qe(j)||V){if(Oi.gridSnapping){const n=Pi.getZoom()*Oi.snappingStep;e*=n,t*=n}Pi.moveSelectedElements(e,t)}},Xe=function(){Si("#tool_node_link").toggleClass("push_button_pressed tool_button");const e=Si("#tool_node_link").hasClass("push_button_pressed");u.linkControlPoints(e)},We=function(){u.getNodePoint()&&u.clonePathNode()},$e=function(){u.getNodePoint()&&u.deletePathNode()},Ye=function(){const e=Si("#tool_add_subpath"),t=!e.hasClass("push_button_pressed");e.toggleClass("push_button_pressed tool_button"),u.addSubPath(t)},Ke=function(){u.opencloseSubPath()},Ze=function(){Pi.cycleElement(1)},et=function(){Pi.cycleElement(0)},tt=function(e,t){if(Qe(j)||V)return;e||(t*=-1);const n=Number.parseFloat(Si("#angle").val())+t;Pi.setRotationAngle(n),K()},nt=async function(){const[e,t]=Oi.dimensions;await Si.confirm(Gi.notification.QwantToClear)&&(G(),Pi.clear(),Pi.setResolution(e,t),Y(!0),Ie(),T(),K(),se(),Pi.runExtensions("onNewDocument"))},st=function(){return Pi.setBold(!Pi.getBold()),K(),!1},ot=function(){return Pi.setItalic(!Pi.getItalic()),K(),!1};let lt;const ct=async function(){const e=await Si.select("Select an image type for export: ",["PNG","JPEG","BMP","WEBP","PDF"],(function(){const e=Si(this);"JPEG"===e.val()||"WEBP"===e.val()?Si("#image-slider").length||Si(`<div><label>${Gi.ui.quality}\n <input id="image-slider"\n type="range" min="1" max="100" value="92" />\n </label></div>`).appendTo(e.parent()):Si("#image-slider").parent().remove()}));if(!e)return;let t;function n(){const{loadingImage:e}=Gi.notification;let n,i;if("new"===Oi.exportWindowType&&wi.exportWindowCt++,t=Oi.canvasName+wi.exportWindowCt,lt)i=lt;else{if(n=`<!DOCTYPE html><html>\n <head>\n <meta charset="utf-8">\n <title>${e}</title>\n </head>\n <body><h1>${e}</h1></body>\n <html>`,"undefined"!=typeof URL&&URL.createObjectURL){const e=new Blob([n],{type:"text/html"});i=URL.createObjectURL(e)}else i="data:text/html;base64;charset=utf-8,"+pe(n);lt=i}_=window.open(i,t)}const i=C();if("PDF"===e)Li||i||n(),Pi.exportPDF(t);else{Ti||n();const i=Number.parseInt(Si("#image-slider").val())/100;await Pi.rasterExport(e,i,t)}},ut=function(){Pi.open()},dt=function(){},ht=function(){d.getUndoStackSize()>0&&(d.undo(),T())},pt=function(){d.getRedoStackSize()>0&&(d.redo(),T())},gt=function(){V?Pi.groupSelectedElements():j&&Pi.ungroupSelectedElement()},ft=function(){Pi.cloneSelectedElements(20,20)},mt=function(){const e=this.id.replace("tool_align","").charAt(0);Pi.alignSelectedElements(e,Si("#align_relative_to").val())},_t=function(){if(Si("#tool_wireframe").toggleClass("push_button_pressed tool_button"),h.toggleClass("wireframe"),Ot)return;const e=Si("#wireframe_rules");e.length?e.empty():Si('<style id="wireframe_rules"></style>').appendTo("head"),Z()};Si("#svg_docprops_container, #svg_prefs_container").draggable({cancel:"button,fieldset",containment:"window"}).css("position","absolute");let yt=!1,bt=!1;const vt=function(){if(yt)return;yt=!0,Si("#image_save_opts input").val([wi.pref("img_save")]);const e=Pi.getResolution();"px"!==Oi.baseUnit&&(e.w=z(e.w)+Oi.baseUnit,e.h=z(e.h)+Oi.baseUnit),Si("#canvas_width").val(e.w),Si("#canvas_height").val(e.h),Si("#canvas_title").val(Pi.getDocumentTitle()),Si("#svg_docprops").show()},xt=function(){if(bt)return;bt=!0,Si("#main_menu").hide();const e=Mi.bkgd_color,t=wi.pref("bkgd_url");ge.each((function(){const t=Si(this),n=t.data("bgcolor")===e;t.toggleClass(fe,n)})),e||ge.eq(0).addClass(fe),t&&Si("#canvas_bg_url").val(t),Si("#grid_snapping_on").prop("checked",Oi.gridSnapping),Si("#grid_snapping_step").attr("value",Oi.snappingStep),Si("#grid_color").attr("value",Oi.gridColor),Si("#svg_prefs").show()},wt=function(){window.open("https://github.com/SVG-Edit/svgedit","_blank")},St=function(){Si("#svg_source_editor").hide(),L=!1,Si("#svg_source_textarea").blur()},kt=async function(){if(!L)return;const e=function(){Pi.clearSelection(),St(),Ie(),T(),ee(),se()};if(Pi.setSvgString(Si("#svg_source_textarea").val()))e(),G();else{if(!await Si.confirm(Gi.notification.QerrorsRevertToSource))return;e()}},Ct=function(){Si("#svg_docprops").hide(),Si("#canvas_width,#canvas_height").removeAttr("disabled"),Si("#resolution")[0].selectedIndex=0,Si("#image_save_opts input").val([wi.pref("img_save")]),yt=!1},At=function(){Si("#svg_prefs").hide(),bt=!1},Et=function(){const e=Si("#canvas_title").val();ee(e),Pi.setDocumentTitle(e);const t=Si("#canvas_width"),n=t.val(),i=Si("#canvas_height"),s=i.val();return"fit"===n||X("width",n)?(t.parent().removeClass("error"),"fit"===s||X("height",s)?(i.parent().removeClass("error"),Pi.setResolution(n,s)?(wi.pref("img_save",Si("#image_save_opts :checked").val()),Y(),Ct(),!0):(Si.alert(Gi.notification.noContentToFitTo),!1)):(i.parent().addClass("error"),Si.alert(Gi.notification.invalidAttrValGiven),!1)):(t.parent().addClass("error"),Si.alert(Gi.notification.invalidAttrValGiven),!1)},Gt=wi.savePreferences=async function(){q(Si("#bg_blocks div.cur_background").data("bgcolor")||"#FFF",Si("#canvas_bg_url").val());const t=Si("#lang_select").val();if(t&&t!==wi.pref("lang")){const{langParam:n,langData:i}=await wi.putLocale(t,e,Oi);await Qt(n,i)}l(Si("#iconsize").val()),Oi.gridSnapping=Si("#grid_snapping_on")[0].checked,Oi.snappingStep=Si("#grid_snapping_step").val(),Oi.gridColor=Si("#grid_color").val(),Oi.showRulers=Si("#show_rulers")[0].checked,Si("#rulers").toggle(Oi.showRulers),Oi.showRulers&&$(),Oi.baseUnit=Si("#base_unit").val(),Pi.setConfig(Oi),Y(),At()};let Pt=Si.noop;const Nt=async function(){if(Si("#dialog_box").hide(),L||yt||bt){if(L)if(M!==Si("#svg_source_textarea").val()){await Si.confirm(Gi.notification.QignoreSourceChanges)&&St()}else St();else yt?Ct():bt&&At();Pt()}else J&&Pi.leaveContext()},It={width:Si(window).width(),height:Si(window).height()};if(k()&&(Pt=function(){0===h[0].scrollLeft&&0===h[0].scrollTop&&(h[0].scrollLeft=m.left,h[0].scrollTop=m.top)},m={left:h[0].scrollLeft,top:h[0].scrollTop},Si(window).resize(Pt),wi.ready((function(){return new Promise((e,t)=>{setTimeout((function(){Pt(),e()}),500)})})),h.scroll((function(){m={left:h[0].scrollLeft,top:h[0].scrollTop}}))),Si(window).resize((function(e){Si.each(It,(function(e,t){const n=Si(window)[e]();h[0]["scroll"+("width"===e?"Left":"Top")]-=(n-t)/2,It[e]=n})),r()})),h.scroll((function(){Si("#ruler_x").length&&(Si("#ruler_x")[0].scrollLeft=h[0].scrollLeft),Si("#ruler_y").length&&(Si("#ruler_y")[0].scrollTop=h[0].scrollTop)})),Si("#url_notice").click((function(){Si.alert(this.title)})),Si("#change_image_url").click(W),function(){const e="tool_button_current";let t="";Si.each(["clear","open","save","source","delete","delete_multi","paste","clone","clone_multi","move_top","move_bottom"],(function(e,n){t+=(e?",":"")+"#tool_"+n})),Si(t).mousedown((function(){Si(this).addClass(e)})).bind("mousedown mouseout",(function(){Si(this).removeClass(e)})),Si("#tool_undo, #tool_redo").mousedown((function(){Si(this).hasClass("disabled")||Si(this).addClass(e)})).bind("mousedown mouseout",(function(){Si(this).removeClass(e)}))}(),A()&&!window.opera){const e=["tool_clear","tool_save","tool_source","tool_undo","tool_redo","tool_clone"];let t=e.length;for(;t--;){const n=document.getElementById(e[t]);if(n){const{title:e}=n,t=e.indexOf("Ctrl+");n.title=[e.substr(0,t),"Cmd+",e.substr(t+5)].join("")}}}const Tt=function(e){const t="stroke_color"===e.attr("id")?"stroke":"fill",n="stroke"===t?Gi.ui.pick_stroke_paint_opacity:Gi.ui.pick_fill_paint_opacity,i=e.offset();let{paint:s}=g[t];Si("#color_picker").draggable({cancel:".jGraduate_tabs, .jGraduate_colPick, .jGraduate_gradPick, .jPicker",containment:"window"}).css(Oi.colorPickerCSS||{left:i.left-140,bottom:40}).jGraduate({paint:s,window:{pickerTitle:n},images:{clientPath:Oi.jGraduatePath},newstop:"inverse"},(function(e){s=new Si.jGraduate.Paint(e),g[t].setPaint(s),Pi.setPaint(t,s),Si("#color_picker").hide()}),(function(){Si("#color_picker").hide()}))};class Lt{constructor(e,t){const n=Oi["fill"===t?"initFill":"initStroke"];let i=(new DOMParser).parseFromString(`<svg xmlns="http://www.w3.org/2000/svg">\n <rect width="16.5" height="16.5"\n fill="#${n.color}" opacity="${n.opacity}"/>\n <defs><linearGradient id="gradbox_${Lt.ctr++}"/></defs>\n </svg>`,"text/xml").documentElement;i=Si(e)[0].appendChild(document.importNode(i,!0)),i.setAttribute("width",16.5),this.rect=i.firstElementChild,this.defs=i.getElementsByTagName("defs")[0],this.grad=this.defs.firstElementChild,this.paint=new Si.jGraduate.Paint({solidColor:n.color}),this.type=t}setPaint(e,t){this.paint=e;const n=e.type,i=e.alpha/100;let s="none";switch(n){case"solidColor":s="none"!==e[n]?"#"+e[n]:e[n];break;case"linearGradient":case"radialGradient":this.grad.remove(),this.grad=this.defs.appendChild(e[n]);s="url(#"+(this.grad.id="gradbox_"+this.type)+")";break}this.rect.setAttribute("fill",s),this.rect.setAttribute("opacity",i),t&&(Pi.setColor(this.type,this._paintColor,!0),Pi.setPaintOpacity(this.type,this._paintOpacity,!0))}update(e){if(!j)return;const{type:t}=this;switch(j.tagName){case"use":case"image":case"foreignObject":return;case"g":case"a":{const e=j.getElementsByTagName("*");let n=null;for(let i=0,s=e.length;i<s;i++){const s=e[i].getAttribute(t);if(0===i)n=s;else if(n!==s){n=null;break}}if(null===n)return void(this._paintColor=null);this._paintColor=n,this._paintOpacity=1;break}default:{this._paintOpacity=Number.parseFloat(j.getAttribute(t+"-opacity")),Number.isNaN(this._paintOpacity)&&(this._paintOpacity=1);const e="fill"===t?"black":"none";this._paintColor=j.getAttribute(t)||e}}e&&(Pi.setColor(t,this._paintColor,!0),Pi.setPaintOpacity(t,this._paintOpacity,!0)),this._paintOpacity*=100;const n=function(e,t,n){const i={alpha:t};if(e.startsWith("url(#")){let t=Pi.getRefElem(e);t=t?t.cloneNode(!0):Si("#"+n+"_color defs *")[0],i[t.tagName]=t}else e.startsWith("#")?i.solidColor=e.substr(1):i.solidColor="none";return new Si.jGraduate.Paint(i)}(this._paintColor,this._paintOpacity,t);this.setPaint(n)}prep(){switch(this.paint.type){case"linearGradient":case"radialGradient":{const e=new Si.jGraduate.Paint({copy:this.paint});Pi.setPaint(this.type,e);break}}}}Lt.ctr=0,g.fill=new Lt("#fill_color","fill"),g.stroke=new Lt("#stroke_color","stroke"),Si("#stroke_width").val(Oi.initStroke.width),Si("#group_opacity").val(100*Oi.initOpacity);const Mt=g.fill.rect.cloneNode(!1);Mt.setAttribute("style","vector-effect:non-scaling-stroke");const Ot="non-scaling-stroke"===Mt.style.vectorEffect;Mt.removeAttribute("style");const jt=g.fill.rect.ownerDocument.createElementNS(t.SVG,"feGaussianBlur");function Vt(){Pi.deleteCurrentLayer()&&(K(),T(),Si("#layerlist tr.layer").removeClass("layersel"),Si("#layerlist tr.layer:first").addClass("layersel"))}function Rt(e){const t=Pi.getCurrentDrawing().getNumLayers();let n=Si("#layerlist tr.layersel").index();(n>0||n<t-1)&&(n+=e,Pi.setCurrentLayerPosition(t-n-1),T())}void 0===jt.stdDeviationX&&Si("#tool_blur").hide(),Si(jt).remove(),function(){const e="-"+a.toLowerCase()+"-zoom-",t=e+"in";h.css("cursor",t),h.css("cursor")===t&&(b=t,v=e+"out"),h.css("cursor","auto")}(),setTimeout((function(){Pi.embedImage("images/logo.png",(function(e){e||(Si("#image_save_opts [value=embed]").attr("disabled","disabled"),Si("#image_save_opts input").val(["ref"]),wi.pref("img_save","ref"),Si("#image_opt_embed").css("color","#666").attr("title",Gi.notification.featNotSupported))}))}),1e3),Si("#fill_color, #tool_fill .icon_label").click((function(){Tt(Si("#fill_color")),Q()})),Si("#stroke_color, #tool_stroke .icon_label").click((function(){Tt(Si("#stroke_color")),Q()})),Si("#group_opacityLabel").click((function(){Si("#opacity_dropdown button").mousedown(),Si(window).mouseup()})),Si("#zoomLabel").click((function(){Si("#zoom_dropdown button").mousedown(),Si(window).mouseup()})),Si("#tool_move_top").mousedown((function(e){Si("#tools_stacking").show(),e.preventDefault()})),Si(".layer_button").mousedown((function(){Si(this).addClass("layer_buttonpressed")})).mouseout((function(){Si(this).removeClass("layer_buttonpressed")})).mouseup((function(){Si(this).removeClass("layer_buttonpressed")})),Si(".push_button").mousedown((function(){Si(this).hasClass("disabled")||Si(this).addClass("push_button_pressed").removeClass("push_button")})).mouseout((function(){Si(this).removeClass("push_button_pressed").addClass("push_button")})).mouseup((function(){Si(this).removeClass("push_button_pressed").addClass("push_button")})),Si("#layer_new").click((async function(){let e,t=Pi.getCurrentDrawing().getNumLayers();do{e=Gi.layers.layer+" "+ ++t}while(Pi.getCurrentDrawing().hasLayer(e));const n=await Si.prompt(Gi.notification.enterUniqueLayerName,e);n&&(Pi.getCurrentDrawing().hasLayer(n)?Si.alert(Gi.notification.dupeLayerName):(Pi.createLayer(n),K(),T()))})),Si("#layer_delete").click(Vt),Si("#layer_up").click(()=>{Rt(-1)}),Si("#layer_down").click(()=>{Rt(1)}),Si("#layer_rename").click((async function(){const e=Si("#layerlist tr.layersel td.layername").text(),t=await Si.prompt(Gi.notification.enterNewLayerName,"");t&&(e===t||Pi.getCurrentDrawing().hasLayer(t)?Si.alert(Gi.notification.layerHasThatName):(Pi.renameCurrentLayer(t),T()))}));let Bt=-1,Ut=!1,Dt=!1;const Ft=function(e){const t=Si("#ruler_x");Si("#sidepanels").width("+="+e),Si("#layerpanel").width("+="+e),t.css("right",Number.parseInt(t.css("right"))+e),h.css("right",Number.parseInt(h.css("right"))+e),Pi.runExtensions("workareaResized")},zt=function(e){if(!Dt)return;if(-1===Bt)return;Ut=!0;let t=Bt-e.pageX;const n=Si("#sidepanels").width();n+t>300?t=300-n:n+t<2&&(t=2-n),0!==t&&(Bt-=t,Ft(t))},Ht=function(e){const t=window.devicePixelRatio||1,n=Si("#sidepanels").width();Ft(((t<1?n:n/t)>2||e?0:150*(t<1?1:t))-n)};Si("#sidepanel_handle").mousedown((function(e){Bt=e.pageX,Si(window).mousemove(zt),Dt=!1,setTimeout((function(){Dt=!0}),20)})).mouseup((function(e){Ut||Ht(),Bt=-1,Ut=!1})),Si(window).mouseup((function(){Bt=-1,Ut=!1,Si("#svg_editor").unbind("mousemove",zt)})),T();Si(window).bind("load resize",()=>{h.css("line-height",h.height()+"px")}),Si("#resolution").change((function(){const e=Si("#canvas_width,#canvas_height");if(this.selectedIndex)if("content"===this.value)e.val("fit").attr("disabled","disabled");else{const t=this.value.split("x");Si("#canvas_width").val(t[0]),Si("#canvas_height").val(t[1]),e.removeAttr("disabled")}else"fit"===Si("#canvas_width").val()&&e.removeAttr("disabled").val(100)})),Si("input,select").attr("autocomplete","off");const qt=["#tool_source_cancel","#tool_docprops_cancel","#tool_prefs_cancel",".overlay"],Xt=function(){const e=[{sel:"#tool_select",fn:F,evt:"click",key:["V",!0]},{sel:"#tool_fhpath",fn:xe,evt:"click",key:["Q",!0]},{sel:"#tool_line",fn:we,evt:"click",key:["L",!0],parent:"#tools_line",prepend:!0},{sel:"#tool_rect",fn:ke,evt:"mouseup",key:["R",!0],parent:"#tools_rect",icon:"rect"},{sel:"#tool_square",fn:Se,evt:"mouseup",parent:"#tools_rect",icon:"square"},{sel:"#tool_fhrect",fn:Ce,evt:"mouseup",parent:"#tools_rect",icon:"fh_rect"},{sel:"#tool_ellipse",fn:Ee,evt:"mouseup",key:["E",!0],parent:"#tools_ellipse",icon:"ellipse"},{sel:"#tool_circle",fn:Ae,evt:"mouseup",parent:"#tools_ellipse",icon:"circle"},{sel:"#tool_fhellipse",fn:Ge,evt:"mouseup",parent:"#tools_ellipse",icon:"fh_ellipse"},{sel:"#tool_path",fn:Me,evt:"click",key:["P",!0]},{sel:"#tool_text",fn:Le,evt:"click",key:["T",!0]},{sel:"#tool_image",fn:Pe,evt:"mouseup"},{sel:"#tool_zoom",fn:Ne,evt:"mouseup",key:["Z",!0]},{sel:"#tool_clear",fn:nt,evt:"mouseup",key:["N",!0]},{sel:"#tool_save",fn(){L?kt():function(){const e={images:wi.pref("img_save"),round_digits:6};Pi.save(e)}()},evt:"mouseup",key:["S",!0]},{sel:"#tool_export",fn:ct,evt:"mouseup"},{sel:"#tool_open",fn:ut,evt:"mouseup",key:["O",!0]},{sel:"#tool_import",fn:dt,evt:"mouseup"},{sel:"#tool_source",fn:O,evt:"click",key:["U",!0]},{sel:"#tool_wireframe",fn:_t,evt:"click",key:["F",!0]},{key:["esc",!1,!1],fn(){qt.every(e=>Si(e+":hidden").length)&&Pi.clearSelection()},hidekey:!0},{sel:qt.join(","),fn:Nt,evt:"click",key:["esc",!1,!1],hidekey:!0},{sel:"#tool_source_save",fn:kt,evt:"click"},{sel:"#tool_docprops_save",fn:Et,evt:"click"},{sel:"#tool_docprops",fn:vt,evt:"click"},{sel:"#tool_prefs_save",fn:Gt,evt:"click"},{sel:"#tool_editor_prefs",fn:xt,evt:"click"},{sel:"#tool_editor_homepage",fn:wt,evt:"click"},{sel:"#tool_open",fn(){window.dispatchEvent(new CustomEvent("openImage"))},evt:"click"},{sel:"#tool_import",fn(){window.dispatchEvent(new CustomEvent("importImage"))},evt:"click"},{sel:"#tool_delete,#tool_delete_multi",fn:Oe,evt:"click",key:["del/backspace",!0]},{sel:"#tool_reorient",fn:ze,evt:"click"},{sel:"#tool_node_link",fn:Xe,evt:"click"},{sel:"#tool_node_clone",fn:We,evt:"click"},{sel:"#tool_node_delete",fn:$e,evt:"click"},{sel:"#tool_openclose_path",fn:Ke,evt:"click"},{sel:"#tool_add_subpath",fn:Ye,evt:"click"},{sel:"#tool_move_top",fn:Be,evt:"click",key:"ctrl+shift+]"},{sel:"#tool_move_bottom",fn:Ue,evt:"click",key:"ctrl+shift+["},{sel:"#tool_topath",fn:Fe,evt:"click"},{sel:"#tool_make_link,#tool_make_link_multi",fn:He,evt:"click"},{sel:"#tool_undo",fn:ht,evt:"click"},{sel:"#tool_redo",fn:pt,evt:"click"},{sel:"#tool_clone,#tool_clone_multi",fn:ft,evt:"click",key:["D",!0]},{sel:"#tool_group_elements",fn:gt,evt:"click",key:["G",!0]},{sel:"#tool_ungroup",fn:gt,evt:"click"},{sel:"#tool_unlink_use",fn:gt,evt:"click"},{sel:"[id^=tool_align]",fn:mt,evt:"click"},{sel:"#tool_bold",fn:st,evt:"mousedown"},{sel:"#tool_italic",fn:ot,evt:"mousedown"},{sel:"#sidepanel_handle",fn:Ht,key:["X"]},{sel:"#copy_save_done",fn:Nt,evt:"click"},{key:"ctrl+left",fn(){tt(0,1)}},{key:"ctrl+right",fn(){tt(1,1)}},{key:"ctrl+shift+left",fn(){tt(0,5)}},{key:"ctrl+shift+right",fn(){tt(1,5)}},{key:"shift+O",fn:et},{key:"shift+P",fn:Ze},{key:[c+"up",!0],fn(){Ie(2)}},{key:[c+"down",!0],fn(){Ie(.5)}},{key:[c+"]",!0],fn(){De("Up")}},{key:[c+"[",!0],fn(){De("Down")}},{key:["up",!0],fn(){qe(0,-1)}},{key:["down",!0],fn(){qe(0,1)}},{key:["left",!0],fn(){qe(-1,0)}},{key:["right",!0],fn(){qe(1,0)}},{key:"shift+up",fn(){qe(0,-10)}},{key:"shift+down",fn(){qe(0,10)}},{key:"shift+left",fn(){qe(-10,0)}},{key:"shift+right",fn(){qe(10,0)}},{key:["alt+up",!0],fn(){Pi.cloneSelectedElements(0,-1)}},{key:["alt+down",!0],fn(){Pi.cloneSelectedElements(0,1)}},{key:["alt+left",!0],fn(){Pi.cloneSelectedElements(-1,0)}},{key:["alt+right",!0],fn(){Pi.cloneSelectedElements(1,0)}},{key:["alt+shift+up",!0],fn(){Pi.cloneSelectedElements(0,-10)}},{key:["alt+shift+down",!0],fn(){Pi.cloneSelectedElements(0,10)}},{key:["alt+shift+left",!0],fn(){Pi.cloneSelectedElements(-10,0)}},{key:["alt+shift+right",!0],fn(){Pi.cloneSelectedElements(10,0)}},{key:"a",fn(){Pi.selectAllInCurrentLayer()}},{key:c+"a",fn(){Pi.selectAllInCurrentLayer()}},{key:c+"z",fn:ht},{key:c+"shift+z",fn:pt},{key:c+"y",fn:pt},{key:c+"x",fn:je},{key:c+"c",fn:Ve},{key:c+"v",fn:Re}],t={"4/Shift+4":"#tools_rect_show","5/Shift+5":"#tools_ellipse_show"};return{setAll(){const n={},i={};e.forEach(e=>{let s;if(e.sel){if(s=xi(e.sel),null===s)return!0;if(e.evt&&(E()&&"click"===e.evt&&(e.evt="mousedown"),s.addEventListener(e.evt,e.fn)),e.parent&&Si(e.parent+"_show").length){let t=Si(e.parent);t.length||(t=ce(e.parent.substr(1))),e.prepend&&(s.style.margin="initial"),t[e.prepend?"prepend":"append"](s),Array.isArray(n[e.parent])||(n[e.parent]=[]),n[e.parent].push(e)}}if(e.key){let n=e.key,o=!1;Array.isArray(e.key)&&(n=e.key[0],e.key.length>1&&(o=e.key[1])),n=String(n);const{fn:r}=e;if(n.split("/").forEach(e=>{i[e]={fn:r,pd:o}}),e.sel&&!e.hidekey&&s.title){const i=`${s.title.split("[")[0]} (${n})`;t[n]=e.sel,null===s.closest("#main_menu")&&(s.title=i)}}return!0}),document.addEventListener("keydown",e=>{if("BODY"!==e.target.nodeName)return;const t=`${e.metaKey?"meta+":""}${e.ctrlKey?"ctrl+":""}${e.key.toLowerCase()}`;i[t]&&(i[t].fn(),i[t].pd&&e.preventDefault())}),le(n),Si(".attr_changer, #image_url").bind("keydown","return",(function(e){Si(this).change(),e.preventDefault()})),Si(window).bind("keydown","tab",(function(e){"canvas"===x&&(e.preventDefault(),Ze())})).bind("keydown","shift+tab",(function(e){"canvas"===x&&(e.preventDefault(),et())})),Si("#tool_zoom").dblclick(Te)},setTitles(){Si.each(t,(function(e,t){const n=Si(t).parents("#main_menu").length;Si(t).each((function(){let t;t=n?Si(this).text().split(" [")[0]:this.title.split(" [")[0];let i="";Si.each(e.split("/"),(function(e,t){const n=t.split("+");let s="";n.length>1&&(s=n[0]+"+",t=n[1]),i+=(e?"/":"")+s+(Gi["key_"+t]||t)})),n?this.lastChild.textContent=t+" ["+i+"]":this.title=t+" ["+i+"]"}))}))},getButtonData:t=>Object.values(e).find(e=>e.sel===t)}}();wi.ready((function(){let e;const t=Oi.initTool,n=Si("#tools_left, #svg_editor .tools_flyout"),i=n.find("#tool_"+t),s=n.find("#"+t);e=i.length?i:s.length?s:Si("#tool_select"),e.click().mouseup(),Oi.wireframe&&Si("#tool_wireframe").click(),Oi.showlayers&&Ht(),Si("#rulers").toggle(Boolean(Oi.showRulers)),Oi.showRulers&&(Si("#show_rulers")[0].checked=!0),Oi.baseUnit&&Si("#base_unit").val(Oi.baseUnit),Oi.gridSnapping&&(Si("#grid_snapping_on")[0].checked=!0),Oi.snappingStep&&Si("#grid_snapping_step").val(Oi.snappingStep),Oi.gridColor&&Si("#grid_color").val(Oi.gridColor)})),Si("#rect_rx").SpinButton({min:0,max:1e3,stateObj:o,callback:function(e){Pi.setRectRadius(e.value)}}),Si("#stroke_width").SpinButton({min:0,max:99,smallStep:.1,stateObj:o,callback:function(e){let t=e.value;0===t&&j&&["line","polyline"].includes(j.nodeName)&&(t=e.value=1),Pi.setStrokeWidth(t)}}),Si("#angle").SpinButton({min:-180,max:180,step:5,stateObj:o,callback:function(e){Pi.setRotationAngle(e.value),Si("#tool_reorient").toggleClass("disabled",0===Number.parseInt(e.value))}}),Si("#font_size").SpinButton({min:.001,stepfunc:function(e,t){const n=Number(e.value),i=n+t,s=i>=n;return 0===t?n:n>=24?s?Math.round(1.1*n):Math.round(n/1.1):n<=1?s?2*n:n/2:i},stateObj:o,callback:function(e){Pi.setFontSize(e.value)}}),Si("#group_opacity").SpinButton({min:0,max:100,step:5,stateObj:o,callback:me}),Si("#blur").SpinButton({min:0,max:10,step:.1,stateObj:o,callback:_e}),Si("#zoom").SpinButton({min:.001,max:1e4,step:50,stepfunc:function(e,t){const n=Number(e.value);if(0===n)return 100;const i=n+t;return 0===t?n:n>=100?i:i>=n?2*n:n/2},stateObj:o,callback:ie}).val(100*Pi.getZoom()),Si("#workarea").contextMenu({menu:"cmenu_canvas",inSpeed:0},(function(e,t,n){switch(e){case"delete":Oe();break;case"cut":je();break;case"copy":Ve();break;case"paste":Pi.pasteElements();break;case"paste_in_place":Pi.pasteElements("in_place");break;case"group":case"group_elements":Pi.groupSelectedElements();break;case"ungroup":Pi.ungroupSelectedElement();break;case"move_front":Be();break;case"move_up":De("Up");break;case"move_down":De("Down");break;case"move_back":Ue();break;default:Boolean(Je[e])&&function(e){return Je[e].action}(e).call()}}));const Wt=function(e,t,n){switch(e){case"dupe":!async function(){const e=Pi.getCurrentDrawing().getCurrentLayerName()+" copy",t=await Si.prompt(Gi.notification.enterUniqueLayerName,e);t&&(Pi.getCurrentDrawing().hasLayer(t)?Si.alert(Gi.notification.dupeLayerName):(Pi.cloneLayer(t),K(),T()))}();break;case"delete":Vt();break;case"merge_down":Si("#layerlist tr.layersel").index()!==Pi.getCurrentDrawing().getNumLayers()-1&&(Pi.mergeLayer(),K(),T());break;case"merge_all":Pi.mergeAllLayers(),K(),T()}};function $t(){let e;try{e=localStorage.getItem("svgedit_clipboard")}catch(e){}p[(e?"en":"dis")+"ableContextMenuItems"]("#paste,#paste_in_place")}if(Si("#layerlist").contextMenu({menu:"cmenu_layers",inSpeed:0},Wt),Si("#layer_moreopts").contextMenu({menu:"cmenu_layers",inSpeed:0,allowLeft:!0},Wt),Si(".contextMenu li").mousedown((function(e){e.preventDefault()})),Si("#cmenu_canvas li").disableContextMenu(),p.enableContextMenuItems("#delete,#cut,#copy"),$t(),window.addEventListener("storage",(function(e){"svgedit_clipboard"===e.key&&$t()})),window.addEventListener("beforeunload",(function(e){return 0===d.getUndoStackSize()&&(wi.showSaveWarning=!1),!(!Oi.no_save_warning&&wi.showSaveWarning)||(e.returnValue=Gi.notification.unsavedChanges,Gi.notification.unsavedChanges)})),wi.canvas.getUIStrings=function(){return Gi},wi.openPrep=function(){return Si("#main_menu").hide(),0===d.getUndoStackSize()||Si.confirm(Gi.notification.QwantToOpen)},window.FileReader){const e=function(e){Si.process_cancel(Gi.notification.loadingImage),e.stopPropagation(),e.preventDefault(),Si("#workarea").removeAttr("style"),Si("#main_menu").hide();const t="drop"===e.type?e.dataTransfer.files[0]:this.files[0];if(!t)return void Si("#dialog_box").hide();if(!t.type.includes("image"))return;let n;t.type.includes("svg")?(n=new FileReader,n.onloadend=function(e){const t=Pi.importSvgString(e.target.result,!0);Pi.ungroupSelectedElement(),Pi.ungroupSelectedElement(),Pi.groupSelectedElements(),Pi.alignSelectedElements("m","page"),Pi.alignSelectedElements("c","page"),Pi.selectOnly([t]),Si("#dialog_box").hide()},n.readAsText(t)):(n=new FileReader,n.onloadend=function({target:{result:e}}){let t=100,n=100;const i=new Image;i.style.opacity=0,i.addEventListener("load",(function(){t=i.offsetWidth||i.naturalWidth||i.width,n=i.offsetHeight||i.naturalHeight||i.height,function(t,n){const i=Pi.addSVGElementFromJson({element:"image",attr:{x:0,y:0,width:t,height:n,id:Pi.getNextId(),style:"pointer-events:inherit"}});Pi.setHref(i,e),Pi.selectOnly([i]),Pi.alignSelectedElements("m","page"),Pi.alignSelectedElements("c","page"),K(),Si("#dialog_box").hide()}(t,n)})),i.src=e},n.readAsDataURL(t))};h[0].addEventListener("dragenter",(function(e){e.stopPropagation(),e.preventDefault()})),h[0].addEventListener("dragover",(function(e){e.stopPropagation(),e.preventDefault()})),h[0].addEventListener("dragleave",(function(e){e.stopPropagation(),e.preventDefault()})),h[0].addEventListener("drop",e);const t=Si('<input type="file">').change((async function(e){if(await wi.openPrep()&&(Pi.clear(),1===this.files.length)){Si.process_cancel(Gi.notification.loadingImage);const e=new FileReader;e.onloadend=async function({target:e}){await ji(e.result),Y()},e.readAsText(this.files[0])}}));Si("#tool_open").show(),Si(window).on("openImage",()=>t.click());const n=Si('<input type="file">').change(e);Si("#tool_import").show(),Si(window).on("importImage",()=>n.click())}Y(!0);const Yt=[],Qt=wi.setLang=async function(e,t){if(wi.langChanged=!0,wi.pref("lang",e),Si("#lang_select").val(e),!t)return;document.documentElement.lang=t.lang,Si.extend(Gi,t);const n=Si("#layerlist tr.layersel td.layername").text()===Gi.common.layer+" 1";Pi.setUiStrings(t),Xt.setTitles(),n&&(Pi.renameCurrentLayer(Gi.common.layer+" 1"),T()),de.length?(await Promise.all(de.map(t=>(Yt.push(t.name),t.langReady({lang:e,uiStrings:Gi,importLocale:Vi({defaultLang:e,defaultName:t.name})})))),de.length=0):Yt.forEach(t=>{Pi.runExtension(t,"langReady",{lang:e,uiStrings:Gi,importLocale:Vi({defaultLang:e,defaultName:t})})}),Pi.runExtensions("langChanged",e),re();Si.each({"#stroke_color":"#tool_stroke .icon_label, #tool_stroke .color_block","#fill_color":"#tool_fill label, #tool_fill .color_block","#linejoin_miter":"#cur_linejoin","#linecap_butt":"#cur_linecap"},(function(e,t){Si(t).attr("title",Si(e)[0].title)})),Si("#multiselected_panel div[id^=tool_align]").each((function(){Si("#tool_pos"+this.id.substr(10))[0].title=this.title}))};(e=>{yi=e})({addLangData:e=>Pi.runExtensions("addLangData",t=>({lang:e,importLocale:Vi({defaultLang:e,defaultName:t})}),!0),curConfig:Oi}),"file:"===document.location.protocol?setTimeout(s,100):s()},wi.ready=function(e){return new Promise((t,n)=>{Ii?t(e()):ki.push([e,t,n])})},wi.runCallbacks=async function(){try{await Promise.all(ki.map(([e])=>e()))}catch(e){throw ki.forEach(([,,e])=>{e()}),e}ki.forEach(([,e])=>{e()}),Ii=!0},wi.loadFromString=function(e,{noAlert:t}={}){return wi.ready((async function(){try{await ji(e,{noAlert:t})}catch(e){if(t)throw e}}))},wi.disableUI=function(e){},wi.loadFromURL=function(e,{cache:t,noAlert:n}={}){return wi.ready((function(){return new Promise((i,s)=>{Si.ajax({url:e,dataType:"text",cache:Boolean(t),beforeSend(){Si.process_cancel(Gi.notification.loadingImage)},success(e){i(ji(e,{noAlert:n}))},error(e,t,o){404!==e.status&&e.responseText?i(ji(e.responseText,{noAlert:n})):n?s(new Error("URLLoadFail")):(Si.alert(Gi.notification.URLLoadFail+": \n"+o),i())},complete(){Si("#dialog_box").hide()}})})}))},wi.loadFromDataURI=function(e,{noAlert:t}={}){return wi.ready((function(){let n=!1,i=e.match(/^data:image\/svg\+xml;base64,/);i?n=!0:i=e.match(/^data:image\/svg\+xml(?:;|;utf8)?,/),i&&(i=i[0]);const s=e.slice(i.length);return ji(n?ge(s):decodeURIComponent(s),{noAlert:t})}))},wi.addExtension=function(e,t,n){if(!Pi)throw new Error("Extension added too early");return Pi.addExtension.call(this,e,t,n)},wi.ready(()=>{et()});let Ri=!1;const Bi=[];window.addEventListener("message",({data:e,origin:t})=>{const n={data:e,origin:t};Ri?Pi.call("message",n):Bi.push(n)}),(async()=>{try{await Promise.resolve(),wi.init()}catch(e){console.error(e)}})();export default wi;
//# sourceMappingURL=index-es.min.js.map