/* @license Copyright (C) Exontrol. All rights reserved. */ !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):(t="undefined"!=typeof globalThis?globalThis:t||self,e(t.exontrol||{}))}(this,function(t){"use strict";function e(){return Math.max.apply(0,arguments)}function o(){return Math.min.apply(null,arguments)}function i(t,e,o){return null==t?~~o:n.s2F(t,e)}var n=n||window.exontrol,s=n.G;n.Def.Gauge={},n.Mrg(n,function(){function t(t,e){this.init(t,e)}function r(t){this.set(t)}function a(t){this.set(t)}function h(t){this.set(t)}function u(t){this.set(t)}function l(t){this.set(t)}function p(t){this.set(t)}function f(t){this.init(t)}function c(t,e){this.init(t,e)}function y(){this.nFlags=3}function g(t){this.oLayer=t,this.nVO=0,this.oOffsetXValid=new h,this.oOffsetYValid=new h,this.oValueToOffsetX=new r,this.oValueToOffsetY=new r,this.oOffsetToValue=new u,this.reset()}function d(t){this.oLayer=t,this.oRotateAngleValid=new C,this.oRotateCenterX=new l,this.oRotateCenterY=new l,this.oRotateAngleToValue=new r,this.oValueToRotateAngle=new r,this.nRotamoveOffset=0,this.reset()}function L(e){this.oLayer=e,this.oViewableLObj=new y,this.value=null,this.onDrag=t.OnDragLayerEnum.exDoNothing,this.oLeft=new a,this.oTop=new a,this.oWidth=new a,this.oHeight=new a,this.oLO=new g(this.oLayer),this.oLR=new d(this.oLayer)}function v(t){this.oLayer=t,this.type=null,this.p=null,this.value=null,this.oOffsetX=new p,this.oOffsetY=new p,this.oLeft=new p,this.oTop=new p,this.oWidth=new p,this.oHeight=new p,this.oRoundX=new p,this.oRoundY=new p,this.oRadiusX=new p,this.oRadiusY=new p,this.oCenterX=new p,this.oCenterY=new p,this.oStartAngle=new p,this.oSweepAngle=new p}function R(t){this.oLayer=t,this.oRed=new r,this.oGreen=new r,this.oBlue=new r}function O(t){this.oT=t,this.rgVO=new n.M1,this.oSize=this.doL()}function b(t,e){this.oLayer=t,this.bDebug=t.isDebug(),this.oSize={width:~~e.width,height:~~e.height},this.iCanvas(this.oSize)}function V(){this.rgLV=new Map}t.version="3.0",t.type="Gauge",t.states="DefaultOffsetX,OffsetX,DefaultOffsetY,OffsetY,DefaultRotateAngle,RotateAngle,Value",t.vAlpha=128,t.OnDragLayerEnum={exDoNothing:0,exDoMove:1,exDoRotate:2,exDoRotamove:3},t.Options={tfi:null,formatText:null,locked:null,readOnly:null,wheelChange:null,smooth:null,cursors:null,layers:null,layerAutoSize:null,layerOfValue:null,value:null,debug:null,showLayers:null,layerDragAny:null},t.prototype.init=function(e,o){this.lI=0,this.oLys=new f(this),this.sSA="smth-"+n.Rand(),this.iLts(),this.oO=n.Cpy(t.Options),this.SetClientRect(e),n.CC.GetCanvas(e)&&this.SetCanvas(e);var i=o||n.Def.Gauge;void 0===i.layers&&(i.layers=this.getLayers()),this.SetOptions(i,!0),n.DPR.Reg(this),this.Refresh()},n.SB.addProto(t.prototype),t.prototype.setTimeout=function(){return n.setTimeout.apply(this,arguments)},t.prototype.GetOptions=function(){return this.oO},t.prototype.SetOptions=function(t,e){var o=!1;if(null!=t){var i=[],s=this.GetOptions();if(null!=s){for(var r in s){var a=t[r];void 0!==a&&(i.push(r),s[r]!==a&&(s[r]=n.CpV(a)))}if(e)for(var r in t)r in s||(s[r]=n.CpV(t[r]));(o=0!=i.length)&&(this.bU(),i.forEach(function(t){var e=n.setM(t);e in this&&this[e].call(this,s[t])},this),this.eU())}}return o},t.prototype.opt=function(t,e){var o=this.oO[t];return null==o&&null==(o=n.Def.Gauge[t])&&(o=e),o},t.prototype.GetCanvas=function(){return this.canvas},t.prototype.SetCanvas=function(t,e){function o(t,e){if(t){var o=function(t){return t.exontrol=t.exontrol||{}}(t);o.l1x=(o.l1x||0)+(e?1:-1)}}o(this.gCtx(),!1),this.udefSts(this.oSts),this.oSts=null,this.resAO(),t=n.CC.GetCanvas(t),n.HP.removeEventListener("onchange",this,"onimg"),t&&n.HP.addEventListener("onchange",this,"onimg"),!e&&n.CC.SetCanvas(this,t),this.canvas=t,n.CC.GetCanvas(this.canvas)&&(this.Shortcuts=this.oSts=new n.Sts,this.defSts(this.oSts),o(this.gCtx(),!0))},n.ComboBox&&(t.prototype.dCBl=function(t,e,o){o.oO.label=this.GetValue()},t.prototype.sCB=function(t){return t&&this.SetValue(0),this.GetValue()},t.prototype.SetCanvas=function(t,e){return n.ComboBox.implExHost(t,"onchange")}(t.prototype.SetCanvas)),t.prototype.SetClientRect=function(t){var e=n.CC.GetCanvas(t);e&&(t=[0,0,e.width,e.height]),this.client=n.C2R(t),!this.visAO()&&this.resAO(),this.onRL()},t.prototype.GetClientRect=function(){return this.client.slice()},t.prototype.GetLayersClientRect=function(){return this.GetClientRect()},t.prototype.GetCanvasRect=function(){var t=this.GetClientRect(),e=this.GetCanvas();return null!=e&&(t=[0,0,e.width,e.height]),t},t.prototype.GetVisibleRect=function(){return n.NRt(this.GetClientRect(),this.GetCanvasRect())},t.prototype.GetViewRect=function(){return n.EArtC(this.GetCanvas())},t.prototype.c2V=function(t,e){var o=t,i=e,n=this.GetViewRect();if(1==arguments.length){var r=arguments[0];o=s.X(r),i=s.Y(r)}return{x:o+n[0],y:i+n[1]}},t.prototype.v2C=function(t,e){var o=t,i=e,n=this.GetViewRect();if(1==arguments.length){var r=arguments[0];o=s.X(r),i=s.Y(r)}return{x:o-n[0],y:i-n[1]}},t.prototype.c2Vrt=function(t){var e=this.c2V(t);return[e.x,e.y,t[2],t[3]]},t.prototype.v2Crt=function(t){var e=this.v2C(t);return[e.x,e.y,t[2],t[3]]},t.prototype.bCTX=function(t){return n.TFI.bCTX(t,this.getTfi())},t.prototype.eCTX=function(t,e){n.TFI.eCTX(t,e)},t.prototype.getCompatCanvas=function(t,e){var o=n.doc.createElement("canvas"),i=o.getContext("2d");return o.width=t,o.height=e,n.iCTX(i),this.bCTX(i),o},t.prototype.onmousemove=function(t){var e,o=this.gPtr(t),i=this.getCursor(o);return(e=this.GetCanvas())&&(e.style.cursor=i||"auto"),this.onHover(o),i},t.prototype.onmouseout=function(t){this.onHover(null)},t.prototype.onRURStart=function(t){},t.prototype.onRUREnd=function(t){},t.prototype.onHover=function(t){var e=this.p2L(t);e!=this.oHov&&(this.oHov&&this.onLayerOut(this.oHov),this.oHov=e,this.oHov&&this.onLayerIn(this.oHov))},t.prototype.onLayerIn=function(t){this.onlayerin(t)},t.prototype.onlayerin=function(t){this.oLts.onlayerin.do(t)},t.prototype.onLayerOut=function(t){this.onlayerout(t)},t.prototype.onlayerout=function(t){this.oLts.onlayerout.do(t)},t.prototype.onwheel=function(t){if(this.isSelectable()){var e=this.gPtr(t);if(null!=e&&n.PInR(e.x,e.y,this.GetClientRect()))return this.dowheel(t)}return!1},t.prototype.dowheel=function(t){var e=n.WhelInc(t);if(e){var o=this.getWheelChange();if(o){var i=this.getWheelValue(),s=this.getWheelValue(o*e),r=s-i;return r&&(Math.abs(r)<4||0==this.GetSmooth()?this.SetValue(s):this.Smooth(function(){this.SetValue(s)},this)),!0}}return!1},t.prototype.getWheelValue=function(t){var i=this,n=this.oLys,s=null!=this.wheelValue?this.wheelValue:this.GetValue(),r=s;if(this.wheelTimeout&&clearTimeout(this.wheelTimeout),this.wheelTimeout=null,null!=i.wheelValue&&(this.wheelTimeout=setTimeout(function(){i.wheelValue=null},500)),t){s-=t,this.lock();var a=S.Save(n),h=-Math.sign(t);if(s=this.SetValue(s),Math.sign(s-r)!=h){for(var u=r,l=r-t,p=r,f=u,c=l;Math.abs(f-c)>.005;){var y=(f+c)/2;s=this.SetValue(y),Math.sign(s-r)!=h?c=y:(f=y,p=s)}(se(u,l))&&(s=p)}S.Restore(n,a),this.unlock(),this.wheelValue=s}return s},t.prototype.ondown=function(t){var e=this.hitTest(this.gPtr(t));if(e)return e.callback&&e.callback.call(e.thisArg,t,e),!0},t.prototype.onkeydown=function(t){this.onkey(t,-1)},t.prototype.onkeyup=function(t){this.onkey(t,0)},t.prototype.onkeypress=function(t){this.onkey(t,1)},t.prototype.onkey=function(t,e){this.oSts&&this.oSts.onkey(t,e)},t.prototype.udefSts=function(t){t&&t.RemoveOf(this)},t.prototype.defSts=function(t){},t.prototype.iLts=function(){this.Listeners=this.oLts=new n.Lts,this.oLts.add("onchange"),this.oLts.add("onclick"),this.oLts.add("onanchorclick"),this.oLts.add("ondragstart"),this.oLts.add("ondrag"),this.oLts.add("ondragend"),this.oLts.add("onlayerin"),this.oLts.add("onlayerout")},t.prototype.onChange=function(t){this.onchange(t)},t.prototype.onchange=function(t){this.oLts.onchange.do(t)},t.prototype.onA=function(t,e){t&&(this.oLys.forEach(null,function(o){o.onA(t,e)}),this.Refresh(),this.onanchorclick(t))},t.prototype.onanchorclick=function(t){this.oLts.onanchorclick.do(t)},t.toClick=function(t){return{dblClick:t.drag&&(t.drag.long||1!=t.drag.click)||!1,button:n.e2B(t),modifiers:n.ModK(t)}},t.prototype.toClick=function(t,e){e.layer=this.e2HT(t)},t.prototype.onClick=function(e){var o=this.gPtr(e),i=t.toClick(e);return this.toClick(e,i),this.onA(this.p2A(o),i),this.onclick(i),i},t.prototype.onclick=function(t){this.oLts.onclick.do(t)},t.prototype.onDragStart=function(t){this.ondragstart(t)},t.prototype.ondragstart=function(t){this.oLts.ondragstart.do(t)},t.prototype.onDrag=function(t){this.ondrag(t)},t.prototype.ondrag=function(t){this.oLts.ondrag.do(t)},t.prototype.onDragEnd=function(t){this.ondragend(t)},t.prototype.ondragend=function(t){this.oLts.ondragend.do(t)},t.prototype.hitTest=function(t){var e;if(t&&this.isSelectable()&&(e=this.p2HT(t)))return{code:e,callback:function(t,e){this.onHTDown(e.code,t)},thisArg:this}},t.prototype.onHTDown=function(t,e){if(t&&t.isSable()){var o=t.oLObj,i=null;n.RUR.Do(e,function(e){switch(e.drag.status){case 1:this.onRURStart(e),t.isDable()&&(i={value:o.getDValue(),cumulativeRotateAngle:null,drag:null});var s={layer:t,cancel:!1,event:e};this.onDragStart(s),s.cancel&&n.RUR.Cancel();break;case 2:i&&(i.drag=e.drag,o.setDValue(i)&&t.refresh());var r={layer:t,event:e};this.onDrag(r);break;case 4:case 5:this.onClick(e);break;case 7:var a={layer:t,event:e};this.onDragEnd(a),this.onRUREnd(e);break;case 6:this.swipe(t,e.drag.swipe)}},this)}},t.prototype.onSwipe=function(t,e,o,i){},t.prototype.swipe=function(t,o){if(t&&o&&(o.dx||o.dy)){var i=[];switch(t.GetOnDrag()){case 1:o.dx&&i.push({f:t.GetOffsetX(),d:1.5*o.dx,c:t.SetOffsetX}),o.dy&&i.push({f:t.GetOffsetY(),d:1.5*o.dy,c:t.SetOffsetY});break;case 2:case 3:i.push({f:t.GetRotateAngle(),d:s.Angle(t.oLObj.oLR.getRotateCenter(!0),o,[o.x+1.5*o.dx,o.y+1.5*o.dy]),c:t.SetRotateAngle})}this.onSwipe(t,o,1.5,i),i.length&&(n.A.Cancel("gswipe"),n.A.Progress(function(e){this.bU(),i.forEach(function(o){o.c.call(t,o.f+e*o.d)}),this.eU()},{name:"gswipe",thisArg:this,duration:e(250,1.5*o.time),onXDoL:!1,transition:"swipe"}))}},t.prototype.onSetAO=function(t){},t.prototype.onimg=function(){this.Refresh()},t.prototype.onRL=function(){this.oLyt=null,this.resetLV()},t.prototype.BeginUpdate=function(){this.lI++},t.prototype.bU=t.prototype.BeginUpdate,t.prototype.EndUpdate=function(){--this.lI||this.rfhAO()},t.prototype.eU=t.prototype.EndUpdate,t.prototype.Update=function(t,e){this.bU(),t instanceof Function&&t.call(e||this),this.eU()},t.prototype.lock=function(){this.lI++,this.bU(),this.oLts.lock()},t.prototype.unlock=function(){this.eU(),this.oLts.unlock(),this.lI--},t.prototype.Refresh=function(){this.bU(),this.onRL(),this.eU()},t.prototype.Smooth=function(t,e){if(t instanceof Function){var o=this.getSmooth();if(o){var i=this.oLys,s=null,r=null;this.lock(),s=S.Save(i),t.call(e),r=S.Diff(S.Save(i),s),S.Restore(i,s),this.unlock(),null!=r&&(n.A.Cancel(this.sSA),n.A.Progress(function(t){this.bU(),r.forEach(function(e,o){var i=s.get(o);if(null!=i)for(var n in e)o["Set"+n].call(o,i[n]+t*(e[n]-i[n]))}),this.eU()},{name:this.sSA,thisArg:this,duration:o,onXDoL:!1,transition:"ease"}))}else t.call(e)}},t.prototype.getRLV=function(){return null==this.oRLV&&(this.oRLV=new V),this.oRLV},t.prototype.resetLV=function(t){null==t?(this.oLys.onResetLV(),this.oRLV=null):null!=this.oRLV&&this.oRLV.reset(t)},t.prototype.Lyt=function(){if(null==this.oLyt){var t=this.gCtx(),e=null;t&&(e=this.bCTX(t)),this.oLyt=new O(this),t&&this.eCTX(t,e)}return this.oLyt},t.prototype.getVO=function(){return this.Lyt().rgVO},t.prototype.draw=function(t,e){t.selClip(e),this.getVO().forEach(function(e,o){o.draw(t,e)}),t.resClip()},t.prototype.p2LV=function(t){var e;if(t){var o=s.X(t),i=s.Y(t);n.PInR(o,i,this.GetClientRect())&&this.getVO().rforEachU(function(t,s){if(n.PInR(o,i,t)&&s.oLayer.isSable()&&null!=s.getImage()&&s.isVisible(o-t[0],i-t[1]))return!!(e={oLayerView:s,rtView:t})},this)}return e},t.prototype.p2A=function(t){var e=this.p2AL(t);return e&&e.a},t.prototype.p2AL=function(t){return this.getVO().rforEachU(function(e,o){var i=o.oLayer,n=i.p2A(t,e);return n&&{a:n,l:i}})},t.prototype.p2L=function(t){var e,o,i=this.p2AL(t),r=i&&i.l;return r||this.isSelectable()&&(e=s.X(t),o=s.Y(t),n.PInR(e,o,this.GetClientRect())&&this.getVO().rforEachU(function(t,i){if(n.PInR(e,o,t)&&i.oLayer.isSable()&&null!=i.getImage()&&i.isVisible(e-t[0],o-t[1]))return!!(r=i.oLayer)},this)),r&&(r.isDable()||(r=this.oLys.getLayerDragAny()||r)),r},t.prototype.p2HT=function(t){var e=this.p2L(t);return e&&e.isSable()&&e||null},t.prototype.e2HT=function(t){return this.p2HT(this.gPtr(t))},t.prototype.GetTfi=function(){return this.oO.tfi},t.prototype.SetTfi=function(t){this.bU(),this.oO.tfi=t||null,this.onRL(),this.eU()},t.prototype.getTfi=function(){return this.opt("tfi")},t.prototype.GetFormatText=function(){return this.oO.formatText},t.prototype.SetFormatText=function(t){this.bU(),this.nFT=null,this.oO.formatText=t,this.onRL(),this.eU()},t.prototype.getFormatText=function(){return null==this.nFT&&(this.nFT=i(this.opt("formatText"),n.DrawTextFormatEnum,n.DrawTextFormatEnum.exTextAlignCenter|n.DrawTextFormatEnum.exTextAlignVCenter)),this.nFT},t.prototype.GetLocked=function(){return this.oO.locked},t.prototype.SetLocked=function(t){this.bU(),this.oO.locked=t,this.onRL(),this.eU()},t.prototype.getLocked=function(){return this.opt("locked",!1)||this.isReadOnly()},t.prototype.GetReadOnly=function(){return this.oO.readOnly},t.prototype.SetReadOnly=function(t){this.bU(),this.oO.readOnly=t,this.onRL(),this.eU()},t.prototype.isReadOnly=function(){return this.opt("readOnly",!1)},t.prototype.GetWheelChange=function(){return this.oO.wheelChange},t.prototype.SetWheelChange=function(t){this.bU(),this.oO.wheelChange=t,this.onRL(),this.eU()},t.prototype.getWheelChange=function(){return this.opt("wheelChange",1)},t.prototype.GetCursors=function(){return this.oO.cursors},t.prototype.SetCursors=function(t){this.bU(),this.sCrs=null,this.oO.cursors=t,this.onRL(),this.eU()},t.prototype.getCursors=function(){var t=this.sCrs;return null==t&&(null==(t=this.GetCursors())&&(t=n.Def.Gauge.cursors),t=n.ToS(t,"pointer(dable,anchor)"),this.sCrs=t),t},t.prototype.getCursor=function(t){var e,o,i;return this.isSelectable()&&(o=this.getCursors(),!n.H.lA&&this.p2A(t)?e=n.GP.Get("anchor",o):(i=this.p2L(t))&&(i.isDable()&&(e=n.GP.Get("dable",o)),null==e&&i.isSable()&&(e=n.GP.Get("sable",o)))),e||null},t.prototype.GetLayers=function(){return this.oLys},t.prototype.SetLayers=function(t){return this.bU(),this.oO.layers=t,this.oLys.Load(this.getLayers()),this.eU(),this.GetLayers()},t.prototype.defLayers=function(){return""},t.prototype.getLayers=function(){return this.opt("layers",this.defLayers())},t.prototype.GetLayerAutoSize=function(){return this.oO.layerAutoSize},t.prototype.SetLayerAutoSize=function(t){this.bU(),this.oO.layerAutoSize=t,this.Refresh(),this.eU()},t.prototype.getLayerAutoSize=function(){return this.opt("layerAutoSize",0)},t.prototype.GetLayerOfValue=function(){return this.oO.layerOfValue},t.prototype.SetLayerOfValue=function(t){this.bU(),this.oLys.oLVal=void 0,this.oO.layerOfValue=t,this.eU()},t.prototype.getLayerOfValue=function(){return this.opt("layerOfValue",-1)},t.prototype.GetValue=function(){return this.oLys.GetValue()},t.prototype.SetValue=function(t){return this.GetValue()!=t&&(this.bU(),this.oLys.SetValue(t),this.eU()),this.GetValue()},t.prototype.GetSmooth=function(){return this.oO.smooth},t.prototype.SetSmooth=function(t){this.oO.smooth=t},t.prototype.getSmooth=function(){return e(0,n.ToN(this.opt("smooth",125)))},t.prototype.Unshuffle=function(){this.Shuffle(0)},t.prototype.Shuffle=function(t){var e=this.getVO();if(null!=e){null==e.original&&(e.original=e.copy());var o=e.original;(t=null!=t?t:.5)&&(o=e.copy().shuffle(t)),e.morph(o,{inv:this.rfhAO,thisArg:this,duration:this.getSmooth(),name:"shuffle",transition:"ease"})}},t.prototype.GetDebug=function(){return this.oO.debug},t.prototype.SetDebug=function(t){this.bU(),this.bDebug=null,this.oO.debug=t,this.onRL(),this.eU()},t.prototype.isDebug=function(){return null==this.bDebug&&(this.bDebug=this.opt("debug",!1)),this.bDebug},t.prototype.GetShowLayers=function(){return this.oO.showLayers},t.prototype.SetShowLayers=function(t){this.bU(),this.oLys.rgSL=void 0,this.oO.showLayers=t,this.onRL(),this.eU()},t.prototype.GetLayerDragAny=function(){return this.oO.layerDragAny},t.prototype.SetLayerDragAny=function(t){this.bU(),this.oLys.oLAny=void 0,this.oO.layerDragAny=t,this.eU()},t.prototype.getLayerDragAny=function(){return this.opt("layerDragAny",-1)},t.prototype.Layer=function(t){return this.oLys.Item(t)},r.prototype.set=function(t){return this.oExpr=n.E.Create(t,"value")},r.prototype.get=function(){return this.oExpr.GetExpr()},r.prototype.isValid=function(){return this.oExpr.IsValid()},r.prototype.eval=function(t,e){var o=e||0;return this.isValid()&&(o=n.ToN(this.oExpr.Evaluate(function(e){return t}))),o},r.prototype.evalA=function(t,e){var o=e||"";return this.isValid()&&(o=this.oExpr.Evaluate(function(e){return t})),o},a.prototype.set=function(t){return this.oExpr=n.E.Create(t,"width,height")},a.prototype.get=function(){return this.oExpr.GetExpr()},a.prototype.isValid=function(){return this.oExpr.IsValid()},a.prototype.eval=function(t,e){var o=e||0;return this.isValid()&&(o=n.ToN(this.oExpr.Evaluate(function(e){return t[-e-1]}))),o},h.prototype.set=function(t){return this.oExpr=n.E.Create(t,"value,x,y,lwidth,lheight,width,height")},h.prototype.get=function(){return this.oExpr.GetExpr()},h.prototype.isValid=function(){return this.oExpr.IsValid()},h.prototype.eval=function(t,e){var o=e||0;return this.isValid()&&(o=n.ToN(this.oExpr.Evaluate(function(e){return t[-e-1]}))),o};var C=r;u.prototype.set=function(t){return this.oExpr=n.E.Create(t,"value,x,offsetx,y,offsety")},u.prototype.get=function(){return this.oExpr.GetExpr()},u.prototype.isValid=function(){return this.oExpr.IsValid()},u.prototype.eval=function(t,e){var o=e||0;return this.isValid()&&(o=n.ToN(this.oExpr.Evaluate(function(e){return t[-e-1<3?0:1]}))),o},l.prototype.set=function(t){return this.oExpr=n.E.Create(t,"lwidth,lheight,width,height")},l.prototype.get=function(){return this.oExpr.GetExpr()},l.prototype.isValid=function(){return this.oExpr.IsValid()},l.prototype.eval=function(t,e){var o=e||0;return this.isValid()&&(o=n.ToN(this.oExpr.Evaluate(function(e){return t[-e-1]}))),o},p.prototype.set=function(t){return this.oExpr=n.E.Create(t,"value,lwidth,width,lheight,height")},p.prototype.get=function(){return this.oExpr.GetExpr()},p.prototype.isValid=function(){return this.oExpr.IsValid()},p.prototype.eval=function(t,e,o){var i=o||0;return this.isValid()&&(i=n.ToN(this.oExpr.Evaluate(function(o){switch(o){case-1:return e;case-2:case-3:return t.width;case-4:case-5:return t.height}}))),i},f.prototype.init=function(t){this.oT=t,this.rgL=new n.Arr,this.lC=0},f.prototype.bU=function(){this.oT.bU()},f.prototype.eU=function(t){(null==t||t)&&this.oT.onRL(),this.oT.eU()},f.prototype.onResetLV=function(){this.forEach(null,function(t){t.oRmC=null})},f.prototype.getKeys=function(){if(null==this.rgK){var t=new Map;this.forEach(-1,function(e){var o=e.getKey();o&&void 0===t.get(o)&&t.set(o,e)}),this.rgK=t}return this.rgK},f.prototype.item=function(t){if(t||0==t){var e=this.getKeys().get(t);if(e)return e;if(n.IsI(t))return this.rgL.at(t);if(this.rgL.has(t))return t}return null},f.prototype.setKey=function(t,e){e&&null==this.item(e)&&(this.oLVal=void 0,this.oLAny=void 0,this.rgK=null,this.rgSL=void 0,t.key=e,this.onChangeLayers())},f.prototype.getPos=function(t){return this.rgL.getPos(t)},f.prototype.setPos=function(t,e){-1!=this.rgL.setPos(t,e)&&(this.bU(),this.eU())},f.prototype.onChange=function(t){var e=this.oT;this.forEach(1,function(t){t.isValued()&&e.resetLV(t)},this),e.onChange(t)},f.prototype.getIndex=function(t){return this.rgL.indexOf(t)},f.prototype.forEach=function(e,o,i){if(e&&0!=e)if(-1==e)this.rgL.forEachI(o,i);else{var n=this.getShowLayers();null==n?this.rgL.forEach(function(t){e==(e&t.oLObj.oViewableLObj.nFlags)&&o.call(i,t)},this):(e&=~t.ViewableLObjEnum.exVisible,this.rgL.forEach(function(t){e==(e&t.oLObj.oViewableLObj.nFlags)&&n.has(t)&&o.call(i,t)},this))}else this.rgL.forEach(o,i)},f.prototype.getVisibleLayers=function(){return this.oT.GetShowLayers()},f.prototype.getShowLayers=function(){if(void 0===this.rgSL){var t=null,e=this.getVisibleLayers();null!=e&&"all"!=(e=e.toString())&&(t=new n.Arr,e.split(",").forEach(function(e){var o=this.Item(e);o&&t.push(o)},this)),this.rgSL=t}return this.rgSL},f.prototype.getLayersClientRect=function(){return this.getLayersClientOffset(this.oT.GetLayersClientRect())},f.prototype.getLayerAutoSize=function(){return this.Item(this.oT.getLayerAutoSize())},f.prototype.getLayersClientOffset=function(t){var e=this.getLayerAutoSize(),o=null;if(null!=e)o=e.getAutoSize();else if(this.forEach(1,function(t){null==e&&(e=t)}),null!=e){var i=e.getBackSize();null!=i&&(o=n.HP.Scale(i,t[2],t[3]))}return null!=o&&(t[0]+=(t[2]-o.width)/2,t[2]=o.width,t[1]+=(t[3]-o.height)/2,t[3]=o.height),t},f.prototype.getLayerOfValue=function(){return void 0===this.oLVal&&(this.oLVal=this.Item(this.oT.getLayerOfValue())||null,null==this.oLVal&&this.rgL.rforEachU(function(t){if(t.GetVisible()&&t.oLObj.hasValue())return!!(this.oLVal=t)},this)),this.oLVal},f.prototype.getLayerDragAny=function(){return void 0===this.oLAny&&(this.oLAny=this.Item(this.oT.getLayerDragAny())||null),this.oLAny},f.prototype.onIdem=function(t){this.rgId=null},f.prototype.getIdem=function(t){var e=this.rgId,o=this;if(null==e){var i=new Map,s=new Map;if(this.forEach(-1,function(t){var e=function(t){var e=null,i=t.GetIdem();if(i)if(n.IsS(i))e=[],i.split(",").forEach(function(i){var n=o.item(i);n&&n!=t&&e.push(n)},this),0==e.length&&(e=null);else{var s=o.item(i);s&&s!=t&&(e=[s])}return e}(t);if(null!=e){var i=s.get(t);null==i&&s.set(t,i=new n.Arr),i.push(e)}},this),s.size){var r=new n.Arr;for(s.forEach(function(t,e){r.push(e,t)});!r.isEmpty();){for(var a=new n.Arr(r.first()),h=!0;h;)h=!1,s.forEach(function(t,e){var o=a.len();(a.has(e)||a.include(t).length||t.include(a).length)&&a.push(e,t),h||(h=o!=a.len())});a.len()>1&&a.forEach(function(t){var e=[];a.forEach(function(o){t!=o&&e.push(o)}),i.set(t,e)}),r.removeRange(a)}}this.rgId=e=i}return e.get(t)||null},f.prototype.GetCount=function(){return this.rgL.len()},f.prototype.SetCount=function(t){if(0==(t=e(0,~~t)))this.Clear();else{this.bU();for(var o=0;(o=this.GetCount())>t;)this.Remove(o-1);for(o=this.GetCount();o=0)for(var n=t.split("."),s=n.length,r=!0,a=0;r&&a180&&(r>0?r-=360:r=360+r),n=t.cumulativeRotateAngle=this.oLR.oRotateAngleValid.eval(s.D236(t.cumulativeRotateAngle)+r,n)}e=this.setRotateAngle(n)}return e},v.prototype.bU=function(){this.oLayer.bU()},v.prototype.eU=function(t){this.oLayer.eU(t)},v.prototype.isEmpty=function(){return!this.p},v.prototype.select=function(t,e){if(!this.isEmpty()){var o={width:e[2],height:e[3]};t.selClip(this.getClipRect(o),this.p,this.pArg(o))}},v.prototype.restore=function(t){this.isEmpty()||t.resClip()},v.prototype.getOffset=function(t){var e=[0,0],o=this.getValue();return e[0]=this.oOffsetX.eval(t,o,0),e[1]=this.oOffsetY.eval(t,o,0),e},v.prototype.getClipRect=function(t){var e=this.getValue(),o=this.oLeft.eval(t,e,0),i=this.oTop.eval(t,e,0),s=this.oWidth.eval(t,e,t.width),r=this.oHeight.eval(t,e,t.height);switch(this.p){case"Ellipse":case"Pie":this.oRadiusX.isValid()&&(s=2*this.oRadiusX.eval(t,e,s/2),o=(t.width-s)/2),this.oCenterX.isValid()&&(o=this.oCenterX.eval(t,e,s/2)-s/2),this.oRadiusY.isValid()&&(r=2*this.oRadiusY.eval(t,e,r/2),i=(t.height-r)/2),this.oCenterY.isValid()&&(i=this.oCenterY.eval(t,e,r/2)-r/2)}var a=[o,i,s,r],h=this.getOffset(t);return n.ORt(a,h[0],h[1]),a},v.prototype.pArg=function(t){var e=null,o=this.getValue();switch(this.p){case"Pie":e={startAngle:s.D2R(this.oStartAngle.eval(t,o,0)),sweepAngle:s.D2R(this.oSweepAngle.eval(t,o,0))};break;case"RoundRect":e={x:this.oRoundX.eval(t,o,0),y:this.oRoundY.eval(t,o,0)}}return e},v.Types=n.BiM.Split("rect(Rect),roundrect(RoundRect),ellipse(Ellipse),pie(Pie)"),v.prototype.GetType=function(){return this.type},v.prototype.SetType=function(t){this.bU(),this.type=t,this.p=t?v.Types.get(t.toString().toLowerCase()):null,this.eU()},v.prototype.GetValue=function(){return this.value},v.prototype.SetValue=function(t){this.bU(),this.value=t,this.eU()},v.prototype.getValue=function(){var t=this.value;return null==t&&(t=this.oLayer.oLys.GetValue()),t},v.prototype.GetOffsetX=function(){return this.oOffsetX.get()},v.prototype.SetOffsetX=function(t){this.bU(),this.oOffsetX.set(t),this.eU()},v.prototype.GetOffsetY=function(){return this.oOffsetY.get()},v.prototype.SetOffsetY=function(t){this.bU(),this.oOffsetY.set(t),this.eU()},v.prototype.GetLeft=function(){return this.oLeft.get()},v.prototype.SetLeft=function(t){this.bU(),this.oLeft.set(t),this.eU()},v.prototype.GetTop=function(){return this.oTop.get()},v.prototype.SetTop=function(t){this.bU(),this.oTop.set(t),this.eU()},v.prototype.GetWidth=function(){return this.oWidth.get()},v.prototype.SetWidth=function(t){this.bU(),this.oWidth.set(t),this.eU()},v.prototype.GetHeight=function(){return this.oHeight.get()},v.prototype.SetHeight=function(t){this.bU(),this.oHeight.set(t),this.eU()},v.prototype.GetRoundRadiusX=function(){return this.oRoundX.get()},v.prototype.SetRoundRadiusX=function(t){this.bU(),this.oRoundX.set(t),this.eU()},v.prototype.GetRoundRadiusY=function(){return this.oRoundY.get()},v.prototype.SetRoundRadiusY=function(t){this.bU(),this.oRoundY.set(t),this.eU()},v.prototype.GetRadiusX=function(){return this.oRadiusX.get()},v.prototype.SetRadiusX=function(t){this.bU(),this.oRadiusX.set(t),this.eU()},v.prototype.GetRadiusY=function(){return this.oRadiusY.get()},v.prototype.SetRadiusY=function(t){this.bU(),this.oRadiusY.set(t),this.eU()},v.prototype.GetCenterX=function(){return this.oCenterX.get()},v.prototype.SetCenterX=function(t){this.bU(),this.oCenterX.set(t),this.eU()},v.prototype.GetCenterY=function(){return this.oCenterY.get()},v.prototype.SetCenterY=function(t){this.bU(),this.oCenterY.set(t),this.eU()},v.prototype.GetStartAngle=function(){return this.oStartAngle.get()},v.prototype.SetStartAngle=function(t){this.bU(),this.oStartAngle.set(t),this.eU()},v.prototype.GetSweepAngle=function(){return this.oSweepAngle.get()},v.prototype.SetSweepAngle=function(t){this.bU(),this.oSweepAngle.set(t),this.eU()},R.prototype.bU=function(){this.oLayer.bU()},R.prototype.eU=function(t){this.oLayer.eU(t)},R.prototype.hasValid=function(){return this.oRed.isValid()||this.oGreen.isValid()||this.oBlue.isValid()},R.prototype.getValue=function(){return this.oLayer.oLys.GetValue()},R.prototype.byO=function(){var t=[.5,.5,.5];return this.oRed.isValid()&&(t[0]=this.oRed.eval(this.getValue(),100)/100),this.oGreen.isValid()&&(t[1]=this.oGreen.eval(this.getValue(),100)/100),this.oBlue.isValid()&&(t[2]=this.oBlue.eval(this.getValue(),100)/100),t},R.prototype.GetRed=function(){return this.oRed.get()},R.prototype.SetRed=function(t){this.bU(),this.oRed.set(t),this.eU()},R.prototype.GetGreen=function(){return this.oGreen.get()},R.prototype.SetGreen=function(t){this.bU(),this.oGreen.set(t),this.eU()},R.prototype.GetBlue=function(){return this.oBlue.get()},R.prototype.SetBlue=function(t){this.bU(),this.oBlue.set(t),this.eU()},O.prototype.doL=function(){var t=this.oT.oLys,e=t.getLayersClientRect(),i=this.oT.getRLV();t.forEach(1,function(t){if(!t.isEmpty()){var o=t.getLayerRect(e),n={width:o[2],height:o[3]};n.width>0&&n.height>0&&this.rgVO.push(i.get(t,n),o)}},this);var n=this.rgVO.union();if(this.oT.isDebug()&&null!=n){var s=this.rgVO.len();if(s>1){var r=this.oT.GetClientRect()[3]/2-8,a=o(r/4,r/(s-1)),h=a*s-o(r,a*(s-1))/2;this.rgVO.forEach(function(t){t[1]+=h-=a}),n=this.rgVO.union()}}return{width:n?n[2]:0,height:n?n[3]:0}},b.prototype.iCanvas=function(t){this.bReset=!0,this.oImage=null,this.oCanvas=this.oLayer.oLys.oT.getCompatCanvas(t.width,t.height),this.ctx=this.oCanvas.getContext("2d")},b.prototype.reset=function(){this.bReset=!0,this.oImage=null},b.prototype.getCanvas=function(){return this.bReset&&(this.bReset=!1,this.build()),this.oCanvas},b.prototype.build=function(){var t=this.ctx,e=this.oLayer,o=[0,0,this.oSize.width,this.oSize.height],i=e.oLObj,r=i.oLR,a=i.isRotamove(),h=a?0:s.D2R(r.doRotate());if(t.save(),t.clearRect.apply(t,o),this.bDebug){var u=s.R2C(o);t.setTransform(1,Math.sin(Math.PI/4/4),-Math.sin(Math.PI/2),1,u[0],u[1]),t.translate(-u[0],-u[1]),t.scale(.5,.5),t.translate(u[0],u[1]),t.drawHTMLText(""+e.getKey(),n.IRt(o.slice(),-16,0),n.DrawTextFormatEnum.exTextAlignRight|n.DrawTextFormatEnum.exTextNoClip);var l=t.getLineDash();t.setLineDash([3,3]),t.drawFrameRect(o,"rgba(128,128,128,0.40)"),t.setLineDash(l)}var p=e.getClip();if(p&&!e.bRc&&p.select(t,o),a){var f=r.getRotamoveOffset();t.translate(f[0],f[1])}else if(h){var c=r.getRotateCenter(),y=c[0],g=c[1];t.translate(y,g),t.rotate(h),t.translate(-y,-g)}p&&e.bRc&&p.select(t,o),this.drawLayer(e,t,o),p&&p.restore(t),t.restore()},b.prototype.drawLayer=function(t,e,o){t.draw(e,o)},b.prototype.getImage=function(){if(this.getCanvas(),null==this.oImage&&this.oSize.width&&this.oSize.height)try{this.oImage=this.ctx.getImageData(0,0,this.oSize.width,this.oSize.height)}catch(t){console.log(t)}return this.oImage},b.prototype.getPixel=function(t,e){return~~t+this.oSize.width*~~e<<2},b.prototype.isVisible=function(e,o,i){return(i=i||this.getImage().data)[this.getPixel(e,o)+3]>t.vAlpha},b.prototype.ToRect=function(){var t=this.oSize.width,e=this.oSize.height,o=[0,0,t,e],i=this.getImage();if(null!=i){for(var n=i.data,s=!1,r=0,a=0;!s&&r=0;r--)for(a=0;!s&&a=0;a--)for(r=0;!s&&r