/* @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){return null!=t}function n(t){return null==t}function s(t,e,o){return n(t)?~~o:r.s2F(t,e)}var r=r||window.exontrol,a=r.G;r.Def.Gauge={},r.Mrg(r,function(){function t(t,e){this.init(t,e)}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.set(t)}function c(t){this.set(t)}function y(t){this.init(t)}function g(t,e){this.init(t,e)}function d(){this.nFlags=3}function L(t){this.oLayer=t,this.nVO=0,this.oOffsetXValid=new l,this.oOffsetYValid=new l,this.oValueToOffsetX=new h,this.oValueToOffsetY=new h,this.oOffsetToValue=new p,this.reset()}function v(t){this.oLayer=t,this.oRotateAngleValid=new w,this.oRotateCenterX=new f,this.oRotateCenterY=new f,this.oRotateAngleToValue=new h,this.oValueToRotateAngle=new h,this.nRotamoveOffset=0,this.reset()}function R(e){this.oLayer=e,this.oViewableLObj=new d,this.value=null,this.onDrag=t.OnDragLayerEnum.exDoNothing,this.oLeft=new u,this.oTop=new u,this.oWidth=new u,this.oHeight=new u,this.oLO=new L(this.oLayer),this.oLR=new v(this.oLayer)}function O(t){this.oLayer=t,this.type=null,this.p=null,this.value=null,this.oOffsetX=new c,this.oOffsetY=new c,this.oLeft=new c,this.oTop=new c,this.oWidth=new c,this.oHeight=new c,this.oRoundX=new c,this.oRoundY=new c,this.oRadiusX=new c,this.oRadiusY=new c,this.oCenterX=new c,this.oCenterY=new c,this.oStartAngle=new c,this.oSweepAngle=new c}function b(t){this.oLayer=t,this.oRed=new h,this.oGreen=new h,this.oBlue=new h}function V(t){this.oT=t,this.rgVO=new r.M1,this.oSize=this.doL()}function C(t,e){this.oLayer=t,this.bDebug=t.isDebug(),this.oSize={width:~~e.width,height:~~e.height},this.iCanvas(this.oSize)}function S(){this.rgLV=new Map}t.version="3.2",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 y(this),this.sSA="smth-"+r.Rand(),this.iLts(),this.oO=r.Cpy(t.Options),this.SetClientRect(e),r.CC.GetCanvas(e)&&this.SetCanvas(e);var i=o||r.Def.Gauge;void 0===i.layers&&(i.layers=this.getLayers()),this.SetOptions(i,!0),r.DPR.Reg(this),this.Refresh()},r.SB.addProto(t.prototype),t.prototype.setTimeout=function(){return r.setTimeout.apply(this,arguments)},t.prototype.GetOptions=function(){return this.oO},t.prototype.SetOptions=function(t,e){var o=!1;if(i(t)){var n=[],s=this.GetOptions();if(i(s)){for(var a in s){var h=t[a];void 0!==h&&(n.push(a),s[a]!==h&&(s[a]=r.CpV(h)))}if(e)for(var a in t)a in s||(s[a]=r.CpV(t[a]));(o=0!=n.length)&&(this.bU(),n.forEach(function(t){var e=r.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 n(o)&&n(o=r.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=r.CC.GetCanvas(t),r.HP.removeEventListener("onchange",this,"onimg"),t&&r.HP.addEventListener("onchange",this,"onimg"),!e&&r.CC.SetCanvas(this,t),this.canvas=t,r.CC.GetCanvas(this.canvas)&&(this.Shortcuts=this.oSts=new r.Sts,this.defSts(this.oSts),o(this.gCtx(),!0))},r.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 r.ComboBox.implExHost(t,"onchange")}(t.prototype.SetCanvas)),t.prototype.SetClientRect=function(t){var e=r.CC.GetCanvas(t);e&&(t=[0,0,e.width,e.height]),this.client=r.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 i(e)&&(t=[0,0,e.width,e.height]),t},t.prototype.GetVisibleRect=function(){return r.NRt(this.GetClientRect(),this.GetCanvasRect())},t.prototype.GetViewRect=function(){return r.EArtC(this.GetCanvas())},t.prototype.c2V=function(t,e){var o=this.GetViewRect();return n(e)&&(e=a.Y(t),t=a.X(t)),{x:t+o[0],y:e+o[1]}},t.prototype.v2C=function(t,e){var o=this.GetViewRect();return n(e)&&(e=a.Y(t),t=a.X(t)),{x:t-o[0],y:e-o[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 r.TFI.bCTX(t,this.getTfi())},t.prototype.eCTX=function(t,e){r.TFI.eCTX(t,e)},t.prototype.getCompatCanvas=function(t,e){var o=r.doc.createElement("canvas"),i=o.getContext("2d");return o.width=t,o.height=e,r.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(i(e)&&r.PInR(e.x,e.y,this.GetClientRect()))return this.dowheel(t)}return!1},t.prototype.dowheel=function(t){var e=r.WhelInc(t);if(e){var o=this.getWheelChange();if(o){var i=this.getWheelValue(),n=this.getWheelValue(o*e),s=n-i;return s&&(Math.abs(s)<4||0==this.GetSmooth()?this.SetValue(n):this.Smooth(function(){this.SetValue(n)},this)),!0}}return!1},t.prototype.getWheelValue=function(t){var n=this,s=this.oLys,r=i(this.wheelValue)?this.wheelValue:this.GetValue(),a=r;if(this.wheelTimeout&&clearTimeout(this.wheelTimeout),this.wheelTimeout=null,i(n.wheelValue)&&(this.wheelTimeout=setTimeout(function(){n.wheelValue=null},500)),t){r-=t,this.lock();var h=A.Save(s),u=-Math.sign(t);if(r=this.SetValue(r),Math.sign(r-a)!=u){for(var l=a,p=a-t,f=a,c=l,y=p;Math.abs(c-y)>.005;){var g=(c+y)/2;r=this.SetValue(g),Math.sign(r-a)!=u?y=g:(c=g,f=r)}(re(l,p))&&(r=f)}A.Restore(s,h),this.unlock(),this.wheelValue=r}return r},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 r.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:r.e2B(t),modifiers:r.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;r.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 n={layer:t,cancel:!1,event:e};this.onDragStart(n),n.cancel&&r.RUR.Cancel();break;case 2:i&&(i.drag=e.drag,o.setDValue(i)&&t.refresh());var s={layer:t,event:e};this.onDrag(s);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:a.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&&(r.A.Cancel("gswipe"),r.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 n=this.oLys,s=null,a=null;this.lock(),s=A.Save(n),t.call(e),a=A.Diff(A.Save(n),s),A.Restore(n,s),this.unlock(),i(a)&&(r.A.Cancel(this.sSA),r.A.Progress(function(t){this.bU(),a.forEach(function(e,o){var n=s.get(o);if(i(n))for(var r in e)o["Set"+r].call(o,n[r]+t*(e[r]-n[r]))}),this.eU()},{name:this.sSA,thisArg:this,duration:o,onXDoL:!1,transition:"ease"}))}else t.call(e)}},t.prototype.getRLV=function(){return n(this.oRLV)&&(this.oRLV=new S),this.oRLV},t.prototype.resetLV=function(t){n(t)?(this.oLys.onResetLV(),this.oRLV=null):i(this.oRLV)&&this.oRLV.reset(t)},t.prototype.Lyt=function(){if(n(this.oLyt)){var t=this.gCtx(),e=null;t&&(e=this.bCTX(t)),this.oLyt=new V(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=a.X(t),n=a.Y(t);r.PInR(o,n,this.GetClientRect())&&this.getVO().rforEachU(function(t,s){if(r.PInR(o,n,t)&&s.oLayer.isSable()&&i(s.getImage())&&s.isVisible(o-t[0],n-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,n=this.p2AL(t),s=n&&n.l;return s||this.isSelectable()&&(e=a.X(t),o=a.Y(t),r.PInR(e,o,this.GetClientRect())&&this.getVO().rforEachU(function(t,n){if(r.PInR(e,o,t)&&n.oLayer.isSable()&&i(n.getImage())&&n.isVisible(e-t[0],o-t[1]))return!!(s=n.oLayer)},this)),s&&(s.isDable()||(s=this.oLys.getLayerDragAny()||s)),s},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 n(this.nFT)&&(this.nFT=s(this.opt("formatText"),r.DrawTextFormatEnum,r.DrawTextFormatEnum.exTextAlignCenter|r.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 n(t)&&(n(t=this.GetCursors())&&(t=r.Def.Gauge.cursors),t=r.ToS(t,"pointer(dable,anchor)"),this.sCrs=t),t},t.prototype.getCursor=function(t){var e,o,i;return this.isSelectable()&&(o=this.getCursors(),!r.H.lA&&this.p2A(t)?e=r.GP.Get("anchor",o):(i=this.p2L(t))&&(i.isDable()&&(e=r.GP.Get("dable",o)),n(e)&&i.isSable()&&(e=r.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,r.ToN(this.opt("smooth",125)))},t.prototype.Unshuffle=function(){this.Shuffle(0)},t.prototype.Shuffle=function(t){var e=this.getVO();if(i(e)){n(e.original)&&(e.original=e.copy());var o=e.original;(t=i(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 n(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)},h.prototype.set=function(t){return this.oExpr=r.E.Create(t,"value")},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=r.ToN(this.oExpr.Evaluate(function(e){return t}))),o},h.prototype.evalA=function(t,e){var o=e||"";return this.isValid()&&(o=this.oExpr.Evaluate(function(e){return t})),o},u.prototype.set=function(t){return this.oExpr=r.E.Create(t,"width,height")},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=r.ToN(this.oExpr.Evaluate(function(e){return t[-e-1]}))),o},l.prototype.set=function(t){return this.oExpr=r.E.Create(t,"value,x,y,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=r.ToN(this.oExpr.Evaluate(function(e){return t[-e-1]}))),o};var w=h;p.prototype.set=function(t){return this.oExpr=r.E.Create(t,"value,x,offsetx,y,offsety")},p.prototype.get=function(){return this.oExpr.GetExpr()},p.prototype.isValid=function(){return this.oExpr.IsValid()},p.prototype.eval=function(t,e){var o=e||0;return this.isValid()&&(o=r.ToN(this.oExpr.Evaluate(function(e){return t[-e-1<3?0:1]}))),o},f.prototype.set=function(t){return this.oExpr=r.E.Create(t,"lwidth,lheight,width,height")},f.prototype.get=function(){return this.oExpr.GetExpr()},f.prototype.isValid=function(){return this.oExpr.IsValid()},f.prototype.eval=function(t,e){var o=e||0;return this.isValid()&&(o=r.ToN(this.oExpr.Evaluate(function(e){return t[-e-1]}))),o},c.prototype.set=function(t){return this.oExpr=r.E.Create(t,"value,lwidth,width,lheight,height")},c.prototype.get=function(){return this.oExpr.GetExpr()},c.prototype.isValid=function(){return this.oExpr.IsValid()},c.prototype.eval=function(t,e,o){var i=o||0;return this.isValid()&&(i=r.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},y.prototype.init=function(t){this.oT=t,this.rgL=new r.Arr,this.lC=0},y.prototype.bU=function(){this.oT.bU()},y.prototype.eU=function(t){(n(t)||t)&&this.oT.onRL(),this.oT.eU()},y.prototype.onResetLV=function(){this.forEach(null,function(t){t.oRmC=null})},y.prototype.getKeys=function(){if(n(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},y.prototype.item=function(t){if(t||0==t){var e=this.getKeys().get(t);if(e)return e;if(r.IsI(t))return this.rgL.at(t);if(this.rgL.has(t))return t}return null},y.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())},y.prototype.getPos=function(t){return this.rgL.getPos(t)},y.prototype.setPos=function(t,e){-1!=this.rgL.setPos(t,e)&&(this.bU(),this.eU())},y.prototype.onChange=function(t){var e=this.oT;this.forEach(1,function(t){t.isValued()&&e.resetLV(t)},this),e.onChange(t)},y.prototype.getIndex=function(t){return this.rgL.indexOf(t)},y.prototype.forEach=function(e,o,i){if(e&&0!=e)if(-1==e)this.rgL.forEachI(o,i);else{var s=this.getShowLayers();n(s)?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)&&s.has(t)&&o.call(i,t)},this))}else this.rgL.forEach(o,i)},y.prototype.getVisibleLayers=function(){return this.oT.GetShowLayers()},y.prototype.getShowLayers=function(){if(void 0===this.rgSL){var t=null,e=this.getVisibleLayers();i(e)&&"all"!=(e=e.toString())&&(t=new r.Arr,e.split(",").forEach(function(e){var o=this.Item(e);o&&t.push(o)},this)),this.rgSL=t}return this.rgSL},y.prototype.getLayersClientRect=function(){return this.getLayersClientOffset(this.oT.GetLayersClientRect())},y.prototype.getLayerAutoSize=function(){return this.Item(this.oT.getLayerAutoSize())},y.prototype.getLayersClientOffset=function(t){var e=this.getLayerAutoSize(),o=null;if(i(e))o=e.getAutoSize();else if(this.forEach(1,function(t){n(e)&&(e=t)}),i(e)){var s=e.getBackSize();i(s)&&(o=r.HP.Scale(s,t[2],t[3]))}return i(o)&&(t[0]+=(t[2]-o.width)/2,t[2]=o.width,t[1]+=(t[3]-o.height)/2,t[3]=o.height),t},y.prototype.getLayerOfValue=function(){return void 0===this.oLVal&&(this.oLVal=this.Item(this.oT.getLayerOfValue())||null,n(this.oLVal)&&this.rgL.rforEachU(function(t){if(t.GetVisible()&&t.oLObj.hasValue())return!!(this.oLVal=t)},this)),this.oLVal},y.prototype.getLayerDragAny=function(){return void 0===this.oLAny&&(this.oLAny=this.Item(this.oT.getLayerDragAny())||null),this.oLAny},y.prototype.onIdem=function(t){this.rgId=null},y.prototype.getIdem=function(t){var e=this.rgId,o=this;if(n(e)){var s=new Map,a=new Map;if(this.forEach(-1,function(t){var e=function(t){var e=null,i=t.GetIdem();if(i)if(r.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 n=o.item(i);n&&n!=t&&(e=[n])}return e}(t);if(i(e)){var s=a.get(t);n(s)&&a.set(t,s=new r.Arr),s.push(e)}},this),a.size){var h=new r.Arr;for(a.forEach(function(t,e){h.push(e,t)});!h.isEmpty();){for(var u=new r.Arr(h.first()),l=!0;l;)l=!1,a.forEach(function(t,e){var o=u.len();(u.has(e)||u.include(t).length||t.include(u).length)&&u.push(e,t),l||(l=o!=u.len())});u.len()>1&&u.forEach(function(t){var e=[];u.forEach(function(o){t!=o&&e.push(o)}),s.set(t,e)}),h.removeRange(u)}}this.rgId=e=s}return e.get(t)||null},y.prototype.GetCount=function(){return this.rgL.len()},y.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),s=t.cumulativeRotateAngle=this.oLR.oRotateAngleValid.eval(a.D236(t.cumulativeRotateAngle)+r,s)}e=this.setRotateAngle(s)}return e},O.prototype.bU=function(){this.oLayer.bU()},O.prototype.eU=function(t){this.oLayer.eU(t)},O.prototype.isEmpty=function(){return!this.p},O.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))}},O.prototype.restore=function(t){this.isEmpty()||t.resClip()},O.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},O.prototype.getClipRect=function(t){var e=this.getValue(),o=this.oLeft.eval(t,e,0),i=this.oTop.eval(t,e,0),n=this.oWidth.eval(t,e,t.width),s=this.oHeight.eval(t,e,t.height);switch(this.p){case"Ellipse":case"Pie":this.oRadiusX.isValid()&&(n=2*this.oRadiusX.eval(t,e,n/2),o=(t.width-n)/2),this.oCenterX.isValid()&&(o=this.oCenterX.eval(t,e,n/2)-n/2),this.oRadiusY.isValid()&&(s=2*this.oRadiusY.eval(t,e,s/2),i=(t.height-s)/2),this.oCenterY.isValid()&&(i=this.oCenterY.eval(t,e,s/2)-s/2)}var a=[o,i,n,s],h=this.getOffset(t);return r.ORt(a,h[0],h[1]),a},O.prototype.pArg=function(t){var e=null,o=this.getValue();switch(this.p){case"Pie":e={startAngle:a.D2R(this.oStartAngle.eval(t,o,0)),sweepAngle:a.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},O.Types=r.BiM.Split("rect(Rect),roundrect(RoundRect),ellipse(Ellipse),pie(Pie)"),O.prototype.GetType=function(){return this.type},O.prototype.SetType=function(t){this.bU(),this.type=t,this.p=t?O.Types.get(t.toString().toLowerCase()):null,this.eU()},O.prototype.GetValue=function(){return this.value},O.prototype.SetValue=function(t){this.bU(),this.value=t,this.eU()},O.prototype.getValue=function(){var t=this.value;return n(t)&&(t=this.oLayer.oLys.GetValue()),t},O.prototype.GetOffsetX=function(){return this.oOffsetX.get()},O.prototype.SetOffsetX=function(t){this.bU(),this.oOffsetX.set(t),this.eU()},O.prototype.GetOffsetY=function(){return this.oOffsetY.get()},O.prototype.SetOffsetY=function(t){this.bU(),this.oOffsetY.set(t),this.eU()},O.prototype.GetLeft=function(){return this.oLeft.get()},O.prototype.SetLeft=function(t){this.bU(),this.oLeft.set(t),this.eU()},O.prototype.GetTop=function(){return this.oTop.get()},O.prototype.SetTop=function(t){this.bU(),this.oTop.set(t),this.eU()},O.prototype.GetWidth=function(){return this.oWidth.get()},O.prototype.SetWidth=function(t){this.bU(),this.oWidth.set(t),this.eU()},O.prototype.GetHeight=function(){return this.oHeight.get()},O.prototype.SetHeight=function(t){this.bU(),this.oHeight.set(t),this.eU()},O.prototype.GetRoundRadiusX=function(){return this.oRoundX.get()},O.prototype.SetRoundRadiusX=function(t){this.bU(),this.oRoundX.set(t),this.eU()},O.prototype.GetRoundRadiusY=function(){return this.oRoundY.get()},O.prototype.SetRoundRadiusY=function(t){this.bU(),this.oRoundY.set(t),this.eU()},O.prototype.GetRadiusX=function(){return this.oRadiusX.get()},O.prototype.SetRadiusX=function(t){this.bU(),this.oRadiusX.set(t),this.eU()},O.prototype.GetRadiusY=function(){return this.oRadiusY.get()},O.prototype.SetRadiusY=function(t){this.bU(),this.oRadiusY.set(t),this.eU()},O.prototype.GetCenterX=function(){return this.oCenterX.get()},O.prototype.SetCenterX=function(t){this.bU(),this.oCenterX.set(t),this.eU()},O.prototype.GetCenterY=function(){return this.oCenterY.get()},O.prototype.SetCenterY=function(t){this.bU(),this.oCenterY.set(t),this.eU()},O.prototype.GetStartAngle=function(){return this.oStartAngle.get()},O.prototype.SetStartAngle=function(t){this.bU(),this.oStartAngle.set(t),this.eU()},O.prototype.GetSweepAngle=function(){return this.oSweepAngle.get()},O.prototype.SetSweepAngle=function(t){this.bU(),this.oSweepAngle.set(t),this.eU()},b.prototype.bU=function(){this.oLayer.bU()},b.prototype.eU=function(t){this.oLayer.eU(t)},b.prototype.hasValid=function(){return this.oRed.isValid()||this.oGreen.isValid()||this.oBlue.isValid()},b.prototype.getValue=function(){return this.oLayer.oLys.GetValue()},b.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},b.prototype.GetRed=function(){return this.oRed.get()},b.prototype.SetRed=function(t){this.bU(),this.oRed.set(t),this.eU()},b.prototype.GetGreen=function(){return this.oGreen.get()},b.prototype.SetGreen=function(t){this.bU(),this.oGreen.set(t),this.eU()},b.prototype.GetBlue=function(){return this.oBlue.get()},b.prototype.SetBlue=function(t){this.bU(),this.oBlue.set(t),this.eU()},V.prototype.doL=function(){var t=this.oT.oLys,e=t.getLayersClientRect(),n=this.oT.getRLV();t.forEach(1,function(t){if(!t.isEmpty()){var o=t.getLayerRect(e),i={width:o[2],height:o[3]};i.width>0&&i.height>0&&this.rgVO.push(n.get(t,i),o)}},this);var s=this.rgVO.union();if(this.oT.isDebug()&&i(s)){var r=this.rgVO.len();if(r>1){var a=this.oT.GetClientRect()[3]/2-8,h=o(a/4,a/(r-1)),u=h*r-o(a,h*(r-1))/2;this.rgVO.forEach(function(t){t[1]+=u-=h}),s=this.rgVO.union()}}return{width:s?s[2]:0,height:s?s[3]:0}},C.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")},C.prototype.reset=function(){this.bReset=!0,this.oImage=null},C.prototype.getCanvas=function(){return this.bReset&&(this.bReset=!1,this.build()),this.oCanvas},C.prototype.build=function(){var t=this.ctx,e=this.oLayer,o=[0,0,this.oSize.width,this.oSize.height],i=e.oLObj,n=i.oLR,s=i.isRotamove(),h=s?0:a.D2R(n.doRotate());if(t.save(),t.clearRect.apply(t,o),this.bDebug){var u=a.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(),r.IRt(o.slice(),-16,0),r.DrawTextFormatEnum.exTextAlignRight|r.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),s){var f=n.getRotamoveOffset();t.translate(f[0],f[1])}else if(h){var c=n.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()},C.prototype.drawLayer=function(t,e,o){t.draw(e,o)},C.prototype.getImage=function(){if(this.getCanvas(),n(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},C.prototype.getPixel=function(t,e){return~~t+this.oSize.width*~~e<<2},C.prototype.isVisible=function(e,o,i){return(i=i||this.getImage().data)[this.getPixel(e,o)+3]>t.vAlpha},C.prototype.ToRect=function(){var t=this.oSize.width,e=this.oSize.height,o=[0,0,t,e],n=this.getImage();if(i(n)){for(var s=n.data,r=!1,a=0,h=0;!r&&a=0;a--)for(h=0;!r&&h=0;h--)for(a=0;!r&&a