/* @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:p.s2F(t,e)}function n(){}function r(t){return t instanceof Array}function s(t){return t instanceof p.Arr}function h(t){return t instanceof Function}function l(t){return t instanceof ClipboardEvent}function u(t){return t instanceof p.Surface.Element}function a(t){return Math.round(t)}var c,p=p||window.exontrol,f=p.G,g=p.UR,y="pos",d="imageSize",S="client";p.Def.Surface={},p.Shapes.Surface={},p.Mrg(p,function(){function t(t,e){this.init(t,e)}return t.prototype.init=function(t,e){var o=new p.Surface.SV;if(this.oSV=o,this.oSV.oT=this,this.oVS=new p.ScrollBar,this.oVS.oSV=this.oSV,this.oVS.getWheelChange=function(){return this.oSV.getWheelChange()},this.oVS.getLocked=function(){return this.oSV.getLocked()},o.aSR()){var i=this.oVS.drawPart;this.oVS.drawPart=function(t,e,n,r){i.call(this,t,e,n,r),o.onDrawPartScroll(this,t,e,n,r)}}if(this.oHS=new p.ScrollBar,this.oHS.oSV=this.oSV,this.oHS.getWheelChange=function(){return this.oSV.getWheelChange()},this.oHS.getLocked=function(){return this.oSV.getLocked()},o.aSR()){var n=this.oHS.drawPart;this.oHS.drawPart=function(t,e,i,r){n.call(this,t,e,i,r),o.onDrawPartScroll(this,t,e,i,r)}}this.Listeners=this.oSV.oLts,this.oCW=new p.CW(t,{AllowXChg:0,ScrollBars:p.Def.Surface.scrollBars}),this.oCW.oT=this,this.Shortcuts=this.oCW.oSts,g&&(this.oUR=new g.M({oC:this,cU:c.Update,onUR:this.onundoredo}),this.oUR.oT=this,this.oUR.gUR=function(t){return function(){return!this.oT.isReadOnly()&&t.apply(this,arguments)||null}}(this.oUR.gUR),this.Shortcuts.Add("CTRL + Z",this.Undo,this,"undoes the last action or a sequence of actions"),this.Shortcuts.Add("CTRL + Y",this.Redo,this,"redoes the last action that was undone (reverses the Undo method)")),this.initCW(),this.exports(),this.SetOptions(e,!0),p.DPR.Reg(this),this.Refresh()},t.version="3.0",t.type="Surface",t.LinkControlPointEnum={exNoControlPoint:0,exStartControlPoint:1,exEndControlPoint:2,exControlPoint:4,exMiddleControlPoint:8,exOrthoArrange:16},t.CoordEnum={exDefCoord:0,exCartesian:1,exAllowPositiveOnly:16},t.SingleSelEnum={exDisableSel:0,exEnableSel:1,exSingleSel:2,exToggleSel:4,exDisableCtrlSel:8,exDisableShiftSel:16,exDisableDrag:32},t.Options={allowUndoRedo:null,undoRedoQueueLength:null,scrollBars:null,scrollBarsHome:void 0,scrollBarsLayout:void 0,tfi:null,locked:null,readOnly:null,wheelChange:null,smooth:null,margins:null,shapes:null,cursors:null,singleSel:null,zoom:null,zoomLevels:null,formatText:null,pad:null,imageSize:null,imageAlign:null,showLinks:null,showLinksOnCollapse:null,collapsedLink:null,link:null,linkStartFrom:null,linkEndTo:null,linkUnselected:null,allowActions:null,expandGlyphSize:null,allowChangeParent:null,selements:null,slinks:null,defArrange:{dir:0,dx:36,dy:36,align:1,compact:!0},allowLinkControlPoint:null,coord:null,showOrigin:null,origin:{size:null,width:null,color:null,style:null,cap:null},showGridLines:null,minorGridLines:{step:null,width:null,color:null,style:null,cap:null},majorGridLines:{step:null,width:null,color:null,style:null,cap:null},showAxes:null,axes:{width:null,color:null,style:null,cap:null},alignObjectsToGridLines:null,selection:null},g&&(t.blockUR=function(t){return function(){var e=this,o=arguments;(this.oSV||this).blockUR(function(){t.apply(e,o)})}}),t.ElementOptions={visible:!0,enabled:!0,selectable:!0,key:null,caption:null,formatText:null,pad:null,image:null,imageSize:void 0,imageAlign:null,shape:null,cursor:null,client:null,parent:null,expand:null,position:null,autoSize:null,resizable:null,movable:null},t.LinkOptions={visible:!0,key:null,caption:null,from:null,to:null,link:null,collapsedLink:null,allowControlPoint:null,customPath:void 0},t.prototype.initCW=function(){var t=this.oCW,e=(t=t.Add("control",{Dock:5})).Add("vertical",{Dock:4,Resizable:!1,Size:16,VisibleExtends:"vscroll,control",Opacity:0,HoverOpacity:1});e.Add("grip",{Dock:2,Size:16,SizeExtends:"grip,hscroll",VisibleExtends:"hscroll",AllowXChg:!1,Resizable:!1}),e.Add("vscroll",{Dock:5,AllowXChg:!1,Control:this.oVS}),t.Add("hscroll",{Dock:2,Resizable:!1,VisibleExtends:"control",Control:this.oHS,Opacity:0,HoverOpacity:1}),t.Add("main",{Dock:5,HoverExtends:"vertical,vscroll,hscroll,grip",Extends:"vertical,hscroll",Control:this.oSV,HScroll:"hscroll",VScroll:"vscroll"})},t.prototype.exports=function(){var e=this.oCW;e&&(["GetCanvas","SetCanvas","SetClientRect","GetClientRect","p2W","W","gPtr","inv"].forEach(function(t){t in this||(this[t]=e[t].bind(e))},this),this.GetScrollBars=e.GetSBs.bind(e),this.SetScrollBars=e.SetSBs.bind(e));var o=this.oSV;if(o){["SetOptions","GetOptions","opt","bU","eU","onRL","Refresh","Smooth","Smoothless","Home","FitToClient","EnsureVisibleClient","Soom","GetSelection","SetSelection","SelectAll","UnselectAll","RemoveSelection","EnsureVisibleSelection","getSelCount","GetElements","GetLinks","Clear","Arrange","e2V","isReadOnly","Cut","Copy","Paste"].forEach(function(t){t in this||(this[t]=o[t].bind(o))},this);var i=o.W();i&&["GetScroll","SetScroll","GetSI","SetSI","toEVP","toEVR","SSw"].forEach(function(t){t in o||(o[t]=i[t].bind(i))}),p.expO(t.Options,this,o)}},t.prototype.defAA=function(){return"fit(Shift+MButton,Ctrl+MButton,Alt+MButton),zoom(MButton),select(Shift,Ctrl),link(Alt)[toggle],create(Alt),move,scroll"},t.prototype.roAA=function(){return"scroll,zoom,fit,select,drag-drop"},t.prototype.lRA=function(t){this.oCW.lRA(t)},Object.defineProperty(t.prototype,"Elements",{get:function(){return this.GetElements()}}),Object.defineProperty(t.prototype,"Links",{get:function(){return this.GetLinks()}}),Object.defineProperty(t.prototype,"Selection",{get:function(){return this.GetSelection()},set:function(t){this.SetSelection(t)}}),t.prototype.GetLayout=function(t){return p.Lay.Save(this.onlayout,this,t)},t.prototype.SetLayout=function(t,e){p.Lay.Load(t,this.onlayout,this,e)},t.prototype.onlayout=function(t){this.oCW.onlayout(t)},t.prototype.GetStatistics=function(){function t(t,e){return p.Format(t,e||0)}var e="",o=p.C2R(this.GetClientRect()),i=this.oSV;return e+="Size: "+t(o[2])+"x"+t(o[3]),e+="\nZoom: "+t(i.getZoom())+"%",e+="\nElement: "+t(function(){var t=0;return i.getVO().forEach(function(e,o){u(o)&&t++}),t}())+"/"+t(i.oSE.GetCount()),e+="\nLink: "+t(i.getVL().len())+"/"+t(i.oSL.GetCount()),e+="\nSel: "+t(i.getSelCount())},Object.defineProperty(t.prototype,"Options",{get:function(){return this.GetOptions()},set:function(t){this.SetOptions(t)},configurable:!0}),c=p.Def.UR.Surface={Update:"Smooth",AddElement:"AddElement",RemoveElement:"RemoveElement",MoveElement:"MoveElement",UpdateElement:"UpdateElement",AddLink:"AddLink",RemoveLink:"RemoveLink",UpdateLink:"UpdateLink"},t.prototype.gUR=function(){return this.oUR&&this.oUR.gUR()},t.prototype.onundoredo=function(t){this.oSV.onChange("undo-redo",t)},t.prototype.GetAllowUndoRedo=n,t.prototype.SetAllowUndoRedo=n,t.prototype.GetUndoRedoQueueLength=n,t.prototype.SetUndoRedoQueueLength=n,t.prototype.CanUndo=n,t.prototype.CanRedo=n,t.prototype.StartBlockUndoRedo=n,t.prototype.EndBlockUndoRedo=n,t.prototype.BlockUndoRedo=function(t,e){h(t)&&(this.StartBlockUndoRedo(),t.call(e||this),this.EndBlockUndoRedo())},t.prototype.Undo=n,t.prototype.Redo=n,t.prototype.UndoListAction=function(t,e){},t.prototype.RedoListAction=function(t,e){},t.prototype.UndoRemoveAction=function(t,e){},t.prototype.RedoRemoveAction=function(t,e){},t.prototype.GroupUndoRedoActions=function(t){},t.prototype.BeginUpdate=function(){this.bU()},t.prototype.EndUpdate=function(){this.eU()},t.prototype.Update=function(t,e){this.bU(),t&&t.call(e||this),this.eU()},t.prototype.Element=function(t){return this.oSV.oSE.Item(t)},t.prototype.Link=function(t){return this.oSV.oSL.Item(t)},p.ComboBox&&(t.prototype.dCBl=function(t,e,o){var i=this.oSV,n=i.getSel(),r=n&&n.first();i.drawCS(t,e,i.getSelCount(),36),o.oO.label=r&&o.label(r.getImage(),r.getCaption())||""},t.prototype.cCB=function(e){var o=this.e2V(e);return!o||o instanceof t.SV},t.prototype.sCB=function(t){return t&&this.SetSelection(null),this.getSelCount()},p.CW.prototype.SetCanvas=function(t,e){return p.ComboBox.implExHost(t,"onselchange")}(p.CW.prototype.SetCanvas)),p.expO({Layout:null,Statistics:null},t.prototype),{Surface:t}}()),p.Mrg(p.Surface,function(){function t(t){this.init(t)}function a(t,e){this.init(t,e)}function v(t){this.init(t)}function C(t,e){this.init(t,e)}function O(){this.mIO=new Map}function m(t,e){this.init(t,e)}function L(t){this.Elements=new p.Arr,this.Out=new Map,this.In=new Map,this.Build(t)}function A(){this.Group=null,this.In=new p.Arr,this.InAll=new p.Arr,this.Out=new p.Arr,this.OutAll=new p.Arr}function E(){this.rgGroups=[],this.rgCache=new Map}function R(t){var e=new p.Arr;Object.getOwnPropertyNames(e).forEach(function(t){this[t]=e[t]},this),this.oArrangement=t,this.nAdding=0}function w(t,e,o){this.Elements=new p.Arr,this.Start=e||0,this.End=o||0,null!=t&&this.Elements.add(t)}function b(){var t=new p.M1;Object.getOwnPropertyNames(t).forEach(function(e){this[e]=t[e]},this)}function U(){var t=new p.M1;Object.getOwnPropertyNames(t).forEach(function(e){this[e]=t[e]},this)}function G(t,e){this.oSurfaceElementsArrange=t,this.Origin=e,this.Elements=new p.Arr,this.Groups=new E,this.Size=new Map,this.Input=new R(this),this.Loc=new U,this.spArrangeDX=null,this.spArrangeDY=null,this.nlipa=0,["getArrangeDir","getArrangeDX","getArrangeDY","getArrangeAlign","getArrangeCompact"].forEach(function(e){this[e]=t[e].bind(t)},this)}function P(t){this.oSurfaceElementsArrange=t,this.Links=new L(this.oSurfaceElementsArrange.oSL),this.rgElementCache=new Map,this.rgArrangementCache=[]}function k(t,e,o){this.oSE=t,this.oSL=e,this.oDefArrange=p.Mrg(p.Def.Surface.defArrange,o),this.Cache=new P(this)}return t.prototype.init=function(t){this.oSV=t,this.mK2I=null,this.rgE=new p.Arr,this.rgE.onRemove=t.onDelElement.bind(t),["bU","eU"].forEach(function(e){this[e]=t[e].bind(t)},this),["forEach","add","indexOf","getPos","setPos"].forEach(function(t){this[t]=this.rgE[t].bind(this.rgE)},this)},t.prototype.onRL=function(){this.oSV.onRL()},t.prototype.resK2I=function(){this.mK2I=null},t.prototype.Add=function(t){this.bU(),this.resK2I();var e=new p.Surface.Element(this,t);return this.oSV.onAddElement(e),this.eU(),e},t.prototype.Create=function(t){var e=null,o={client:t};return this.OnCreate&&!this.OnCreate(o)&&(e=this.Add(o)),e},t.prototype.OnCreate=function(t){},t.prototype.GetCount=function(){return this.rgE.len()},t.prototype.Item=function(t){var e=null;return~~t===t?e=this.rgE.at(t)||null:u(t)?e=this.rgE.has(t)?t:null:null==(e=function(t){var e=t.mK2I;return null==e&&(t.mK2I=e=new Map,t.forEach(function(t){var o=t.getKey();!e.has(o)&&e.set(o,t)})),e}(this).get(t))&&(e=this.rgE.at(t)||null),e},t.prototype.Remove=function(t){this.RemoveRange(this.Item(t))},t.prototype.RemoveRange=function(t){this.bU(),this.resK2I(),(t=this.dscn(t)).forEach(function(t){var e=t.ownCol(!1);e&&(e.remove(t),t.resOwnCol())}),this.rgE.removeRange(t.reverse()),this.eU()},t.prototype.Clear=function(){this.bU(),this.oSV.oSL.Clear(),this.oSV.rgSel=null,this.resK2I(),this.xE(),this.oSV.uSR(null),this.eU()},t.prototype.xE=function(){this.rgE.clear()},t.prototype.dscn=function(t){var e,o=p.Arr.empty;if(t&&(e=t,u(t)?e=[t]:s(t)&&(e=t.rgE),r(e))){o=new p.Arr,e.forEach(function(t){o.ann(this.Item(t))},this);for(var i=0;i1&&t!=e-1&&this.SetPosition(e-1),t},a.prototype.BringForward=function(){var t=this.GetPosition(),e=this.oSE.GetCount();return e>1&&t+11&&t>0&&this.SetPosition(0),t},a.prototype.SendBackward=function(){var t=this.GetPosition();return this.oSE.GetCount()>1&&t>0&&this.SetPosition(t-1),t},a.prototype.GetKey=function(){return this.oO.key},a.prototype.SetKey=function(t){this.bU(),this.oSE.resK2I(),this.oO.key=t,this.eU()},a.prototype.getKey=function(){var t=this.GetKey();return(t=null!=t?t.toString():"")||this.getPlainCaption()},a.prototype.GetVisible=function(){return this.oO.visible},a.prototype.SetVisible=function(t){this.bU(),this.oO.visible=t,this.eU(!0)},a.prototype.getVisible=function(){return null==this.GetVisible()||this.GetVisible()},a.prototype.isVisible=function(){return this.GetVisible()||null==this.GetVisible()},a.prototype.GetEnabled=function(){return this.oO.enabled},a.prototype.SetEnabled=function(t){this.bU(),this.oO.enabled=t,this.eU()},a.prototype.getEnabled=function(){return null==this.GetEnabled()||this.GetEnabled()},a.prototype.isEnabled=function(){return!!this.getEnabled()&&(!this.oP||this.oP.isEnabled())},a.prototype.GetSelectable=function(){return this.oO.selectable},a.prototype.SetSelectable=function(t){this.bU(),this.oO.selectable=t,this.eU()},a.prototype.getSelectable=function(){return null==this.GetSelectable()||this.GetSelectable()},a.prototype.isSelectable=function(){return this.getSelectable()},a.prototype.GetCaption=function(){return this.oO.caption},a.prototype.SetCaption=function(t){this.bU(),this.oSE.resK2I(),this.oO.caption=t,this.eU(!0)},a.prototype.getCaption=function(){return this.GetCaption()},a.prototype.getPlainCaption=function(){return p.H.TextNoHTML(this.getCaption())},a.prototype.GetFormatText=function(){return this.oO.formatText},a.prototype.SetFormatText=function(t){this.bU(),this.oO.formatText=t,this.eU()},a.prototype.getFormatText=function(){var t=this.GetFormatText();return null!=t?~~t:this.getView().getFormatText()},a.prototype.GetPad=function(){return this.oO.pad},a.prototype.SetPad=function(t){this.bU(),this.oO.pad=t,this.eU()},a.prototype.getPad=function(){var t=this.GetPad();return null!=t?p.pad2A(t):this.getView().getPad()},a.prototype.GetImage=function(){return this.oO.image},a.prototype.SetImage=function(t){this.bU(),this.oO.image=t,this.eU(!0)},a.prototype.getImage=function(){var t=this.GetImage();return null!=t?t.toString():""},a.prototype.GetImageSize=function(){return this.oO.imageSize},a.prototype.SetImageSize=function(t){this.bU(),this.oO.imageSize=t,this.eU(!0)},a.prototype.getImageSize=function(){var t=this.GetImageSize();return void 0!==t?t:this.getView().getImageSize()},a.prototype.GetImageAlign=function(){return this.oO.imageAlign},a.prototype.SetImageAlign=function(t){this.bU(),this.oO.imageAlign=t,this.eU(!0)},a.prototype.getImageAlign=function(){var t=this.GetImageAlign();return null!=t?p.ToI(t,2):this.getView().getImageAlign()},a.prototype.gCnt=function(t,e){var o=this.getPad(),i=p.HP.Measure(this.getImage(),this.getImageSize(),t),n=p.PRt(e.slice(),o,-1),r=null;if(null!=i)switch(this.getImageAlign()){case 3:(r=n.slice())[1]=p.BOf(n)-i.height,r[3]=i.height,r[0]+=(r[2]-i.width)/2,r[2]=i.width,n[3]-=i.height+o[1];break;case 2:(r=n.slice())[3]=i.height,r[0]+=(r[2]-i.width)/2,r[2]=i.width,n[1]+=i.height+o[1],n[3]-=i.height+o[1];break;case 1:(r=n.slice())[0]=p.ROf(n)-i.width,r[2]=i.width,r[1]+=(r[3]-i.height)/2,r[3]=i.height,n[2]-=i.width+o[0];break;default:(r=n.slice())[2]=i.width,r[1]+=(r[3]-i.height)/2,r[3]=i.height,n[0]+=i.width+o[0],n[2]-=i.width+o[0]}return{rtCaption:n,rtImage:r}},a.prototype.draw=function(t,e,o){var i,n=!this.isEnabled();n&&p.H.lA++,t.selClip(e),i=this.gCnt(t,e),t.drawHTMLText(this.getCaption(),i.rtCaption,o.formatText||this.getFormatText(),o.tfi&&p.ToTFI(o.tfi)),t.drawHTMLPicture(this.getImage(),i.rtImage,this.getImageSize()),t.resClip(),n&&--p.H.lA},a.prototype.GetShape=function(){return this.oO.shape},a.prototype.SetShape=function(t){this.bU(),this.oO.shape=t,this.eU(!0)},a.prototype.GetCursor=function(){return this.oO.cursor},a.prototype.SetCursor=function(t){this.bU(),this.oO.cursor=t,this.eU()},a.prototype.GetClient=function(){return this.oO.client},a.prototype.SetClient=function(t){this.bU(),this.oO.client=t,this.eU(!0)},a.prototype.getContentSize=function(t){var o={width:0,height:0},i=this.getPad(),n=this.getView().toShape(this),r=p.H.Measure(t,this.getCaption(),null,this.getFormatText(),n.tfi&&p.ToTFI(n.tfi)),s=p.HP.Measure(this.getImage(),this.getImageSize(),t);return null!=r&&(o.width+=r.width+1,o.height+=r.height+1),null!=s&&(this.getImageAlign()>=2?(o.width=e(o.width,s.width),o.height&&(o.height+=i[1]),o.height+=s.height):(o.height=e(o.height,s.height),o.width&&(o.width+=i[0]),o.width+=s.width)),o.width+=i[0]<<1,o.height+=i[1]<<1,o},a.prototype.getClient=function(){var t,e=p.C2R(this.GetClient()||32);return this.getAutoSize()&&(t=this.getView().gAS(this),e[2]=t.width,e[3]=t.height),e},a.prototype.GetParent=function(){return this.oP},a.prototype.SetParent=function(t){if(t!=this.oP){this.oO.parent=t;var e=this.hasOptsP();if(e!=this.oP){this.bU();var o=this.ownCol(!1);null!=o&&(o.remove(this),this.resOwnCol()),(this.oP=e)&&this.ownCol(!0).add(this),this.eU(!0)}}},a.prototype.canParent=function(t){return!(t==this.oP||t&&t.isChildOf(this))},a.prototype.isChildOf=function(t){for(var e=this;e&&e!=t;)e=e.oP;return e==t},a.prototype.hasOptsP=function(){var t=null,e=this.oO.parent;return e&&(e=this.oSE.Item(e))&&this.canParent(e)&&(t=e),t},a.prototype.ownCol=function(t){var e=null;return this.oP&&(e=this.oP.rgC,t&&!e&&(this.oP.rgC=e=new p.Arr)),e},a.prototype.resOwnCol=function(){null!=this.oP&&null!=this.oP.rgC&&0==this.oP.rgC.len()&&(this.oP.rgC=null)},a.prototype.dscn=function(){return this.oSE.dscn(this)},a.prototype.GetExpand=function(){return this.oO.expand},a.prototype.SetExpand=function(t){t!=this.isExpanded()&&(this.bU(),this.oO.expand=t,this.eU(!0))},a.prototype.isExpanded=function(){return!(null!=this.GetExpand()&&!this.GetExpand())},a.prototype.ToggleExpand=function(){this.SetExpand(!this.isExpanded())},a.prototype.GetAutoSize=function(){return this.oO.autoSize},a.prototype.SetAutoSize=function(t){this.bU(),this.oO.autoSize=t,this.eU(!0)},a.prototype.getAutoSize=function(){return this.GetAutoSize()},a.prototype.GetResizable=function(){return this.oO.resizable},a.prototype.SetResizable=function(t){this.bU(),this.oO.resizable=t,this.eU(!0)},a.prototype.getResizable=function(){return!(null!=this.GetResizable()&&!this.GetResizable())},a.prototype.isResizable=function(){return this.getResizable()&&!this.getAutoSize()},a.prototype.GetMovable=function(){return this.oO.movable},a.prototype.SetMovable=function(t){this.bU(),this.oO.movable=t,this.eU(!0)},a.prototype.getMovable=function(){return!(null!=this.GetMovable()&&!this.GetMovable())},a.prototype.isMovable=function(){return this.getMovable()},a.prototype.hasVisibleChild=function(){var t=null;return this.rgC&&this.rgC.forEachU(function(e){return e.getVisible()&&(t=e),t}),t},a.prototype.getVisibleChild=function(){var t;return this.rgC&&this.isExpanded()&&this.rgC.forEach(function(e){e.getVisible()&&(t=t||[]).push(e)}),t},a.prototype.hasChild=function(){return this.rgC&&this.rgC.len()},a.prototype.getRoot=function(){for(var t=this;t.oP;)t=t.oP;return t},a.prototype.getLevel=function(){for(var t=0,e=this;e=e.oP;)t++;return t},a.prototype.getCollapsedParent=function(){for(var t=null,e=this;e.oP;)(e=e.oP).isExpanded()||(t=e);return t||this},a.prototype.getExpandGlyph=function(){return this.eG=this.eG||{expand:this}},a.prototype.IsArrangeGroup=function(){var t;return(this.oP||this.rgC)&&(t=this.getRoot().dscn()),t},a.prototype.isVisibleEx=function(){return this.isVisible()&&(!this.oP||this.oP.isExpanded()&&this.oP.isVisibleEx())},a.prototype.ArrangeLoc=function(){var t=[0,0,0,0];return this.isVisibleEx()&&(t=this.getClient()),t},a.prototype.ArrangeSize=function(){var t=this.ArrangeLoc();return{cx:t[2],cy:t[3]}},a.prototype.ArrangeTo=function(t){var e=this.getClient(),o=e.slice();e[0]=f.X(t),e[1]=f.Y(t),this.SetClient(e),this.getView().onMoveElement(this,o)},a.prototype.toString=function(){return this.getKey()||this.oSE.indexOf(this)},a.prototype.EnsureVisible=function(){for(var t=this;t=t.oP;)t.SetExpand(!0);this.getView().EnsureVisibleClient(this)},a.prototype.genID=function(){var t=this.GetKey();return null==t&&this.SetKey(t=function(){var t=this.oSE,e=this.getKey();return e&&t.Item(e)==this||(e=t.nextID()),e}.call(this)),t},a.prototype.coO=function(){var t=p.Cpy(this.oO);return t[S]=this.getClient(),t.position=this.GetPosition(),u(t.parent)&&(t.parent=t.parent.genID()),t},g&&(a.prototype.scUR=function(t){t.o=this.oSE,t.i=this.genID()},a.prototype.arUR=function(t){this.scUR(t),t.d=this.coO(),t.Do=function(t){if(this.del?!t:t)this.o.Remove(this.i);else{var e=this.o.Add(this.d);e&&e.EnsureVisible()}}},a.prototype.mvUR=function(t,e){e&&(this.scUR(t,!0),t.d={from:p.C2R(e),to:this.getClient()},t.Do=function(t){var e=this.o.Item(this.i);e&&(e.SetClient(t?this.d.from:this.d.to),e.EnsureVisible())})},a.prototype.uUR=function(t,e,o){this.scUR(t,!0),(t.d=g.diff(e,o))&&("position"in e&&!("position"in t.d.from)&&(t.d.from.position=e.position),"position"in o&&!("position"in t.d.to)&&(t.d.to.position=o.position),t.Do=function(t){var e=this.o.Item(this.i);e&&(e.SetOptions(t?this.d.from:this.d.to),e.EnsureVisible())})},a.prototype.StartUpdateElement=function(){return this.getView().gUR()&&this.coO()},a.prototype.suo=a.prototype.StartUpdateElement,a.prototype.EndUpdateElement=function(t){t&&this.getView().nUR(c.UpdateElement,function(e){this.uUR(e,t,this.coO())},this)},a.prototype.euo=a.prototype.EndUpdateElement,a.prototype.UpdateElement=function(t,e){if(h(t)){var o=this.StartUpdateElement();t.call(e||this),this.EndUpdateElement(o)}}),v.prototype.init=function(t){this.oSV=t,this.rgL=new p.Arr,this.rgL.onRemove=this.onDelLink.bind(this),this.import()},v.prototype.import=function(){var t=this.oSV;["bU","eU"].forEach(function(e){this[e]=t[e].bind(t)},this),["forEach","add","indexOf"].forEach(function(t){this[t]=this.rgL[t].bind(this.rgL)},this)},v.prototype.onRL=function(){this.oSV.onRL()},v.prototype.resK2I=function(){this.mK2I=null},v.prototype.onDelElement=function(t){this.oIOL&&this.RemoveRange(this.oIOL.linksOf(t))},v.prototype.onAddLink=function(t){(this.oIOL=this.oIOL||new O).add(t),this.oSV.onAddLink(t)},v.prototype.onDelLink=function(t){this.oFL=null,this.oIOL&&this.oIOL.remove(t),this.oSV.onDelLink(t)},v.prototype.toE=function(t){return this.oSV.oSE.Item(t)},v.prototype.allowLink=function(t,e){return!(!(t=this.toE(t))||!(e=this.toE(e)))&&((!this.oIOL||this.oIOL.can(t,e))&&this.oSV.onAllowLink(t,e))},v.prototype.Add=function(t){var e=null;return t&&this.allowLink(t.from,t.to)&&(this.bU(),this.resK2I(),e=new p.Surface.Link(this,t),this.onAddLink(e),this.eU()),e},v.prototype.Create=function(t,e){var o,i=null;return this.allowLink(t,e)&&(o={from:t,to:e},this.OnCreate&&!this.OnCreate(o)&&(i=this.Add(o))),i},v.prototype.OnCreate=function(t){},v.prototype.GetCount=function(){return this.rgL.len()},v.prototype.Item=function(t){var e=null;return~~t===t?e=this.rgL.at(t)||null:!function(t){return t instanceof p.Surface.Link}(t)?(e=function(t){var e=t.mK2I;return null==e&&(t.mK2I=e=new Map,t.forEach(function(t){var o=t.getKey();!e.has(o)&&e.set(o,t)})),e}(this).get(t))||(e=this.rgL.at(t)||null):e=this.rgL.has(t)?t:null,e},v.prototype.Remove=function(t){var e=this.Item(t);e&&(this.bU(),this.resK2I(),this.rgL.remove(e),this.eU())},v.prototype.RemoveRange=function(t){this.bU(),this.resK2I(),this.rgL.removeRange(t),this.eU()},v.prototype.Clear=function(){this.bU(),this.oIOL=null,this.resK2I(),this.rgL.clear(),this.eU()},v.prototype.linksOf=function(t){return this.oIOL?this.oIOL.linksOf(t):p.Arr.empty},v.prototype.linkOf=function(t,e){return this.oIOL&&this.oIOL.get(t,e)||null},v.prototype.Load=function(t){var e=this;this.bU(),this.Clear(),p.B.split(t).forEach(function(t){!function(t,o){var i,n,r,s;o&&(i=o.get("link"))&&(n=i.split("-")).length>1&&(r={caption:t,from:n[0],to:n[1]},p.Surface.Link.F.f2o(o,function(t,e,o){p.Surface.Link.F.isF(o)&&(r[t]=e)}),p.Surface.Link.FLink.f2o(o,function(t,e,o){var i=o.sWith(p.Surface.Link.FCollapsedLink);if(i&&(o=o.substr(p.Surface.Link.FCollapsedLink.length),t=p.F.l1st(p.Surface.Link.FLink.toN(o))),p.Surface.Link.FLink.isF(o)){var n=i?"collapsedLink":"link";(r[n]=r[n]||{})[t]=e}}),s=e.Add(r),o.has("focus")&&(e.oFL=s))}(t.caption,t.flags)}),this.eU()},v.prototype.Save=function(){function t(t){var e=t.GetKey();return null==e&&(!(e=t.getPlainCaption()).trim()||p.IsI(e)||e.length>4)&&(e=t.GetIndex()),e}var e=[],o=this.oFL;return this.rgL.forEachI(function(i){i.oF&&i.oT&&e.push(function(e){var i=p.B.quoteC(e.getCaption()),n=p.Surface.Link.F.Save(e),r=e.GetLink(),s=e.GetCollapsedLink();if((n=n||new Map).set("link",t(e.oF)+"-"+t(e.oT)),r)for(var h in r)n.set(h,r[h]);if(s)for(var h in s)n.set(p.Surface.Link.FCollapsedLink+h,s[h]);return e==o&&n.set("focus",null),i+=p.B.quoteF(n)}(i))}),p.B.quoteS(e)},v.prototype.nextID=function(t){function o(){for(var t="";this.Item(t=i+ ++this.__nextID););return t}this.__nextID=this.__nextID||0;var i="_l",n=o.call(this);if(null!=t){n=[n],t=e(0,p.ToI(t,1)-1);for(var r=0;rs;o;){o=!1,t=!0;for(var i=0,h=n.length;t&&is,e=!0)}return e}function o(){for(var t,e=!1,o=n.length>s;o;){o=!1,t=!0;for(var i=0,h=n.length;t&&ii;u--)"E"==r.lO(l,n[u])&&(n.splice(i,u-i),o=n.length>s,t=!1,e=!0)}return e}function i(){for(var t,e=!1,o=n.length>s;o;){o=!1,t=!0;for(var i=0,h=n.length;t&&is,e=!0)}}return e}var n,r=p.Surface.SV,s=3;if(t){for((n=t.slice()).splice(0,0,[0,0]),n.push([1,1]);e()||o()||i(););n.splice(0,1),n.splice(n.length-1,1)}return n&&t&&n.length!=t.length?n:t},C.prototype.cp2P=function(t,e,o){var i,n=[];if(t){i=new C.PCONVP(e,o),n.push(e);for(var r=0,s=t.length;r1&&this.isSelected(S)&&(x=this.getSelCount()),p.EyO(L)&&(L=null);function T(t,e,o,i){I=I||i;var n=[this.scaled(o[0]),this.scaled(o[1]),this.scaled(o[2]),this.scaled(o[3])];this.ctxScale(e,[0,0,0,0],function(){L?e.drawShape(n,L.normal||L):S?this.drawE(e,n,S):e.drawFrameRect(n)}),x&&e.drawHTMLText(x,o,p.DrawTextFormatEnum.exTextAlignCenter|p.DrawTextFormatEnum.exTextAlignVCenter)}o.rurEFPaint=T,o.rurEFOpts=function(t,e){e.visible=!1,e.limitClient=!1},o.rurDrag=function(t){I&&I.SetVisible(t.from!=t.to);var e={dx:t.to.x-t.from.x,dy:t.to.y-t.from.y};s.call(this,e,w),t.frame=this.htR(k,e.dx,e.dy,P),!o.rurEFPaint&&T.call(this,t,this.gCtx(),this.rtCA(t.frame,!1)),i(t)},o.rurCancel=function(t){r(!0)},o.rurDrop=function(t){r();var e=s.call(this,{dx:t.to.x-t.from.x,dy:t.to.y-t.from.y},w),o=this.htR(k,e.dx,e.dy,P);if(v)p.EyR(o)||this.onRURChange(this.orurDC=this.onRURCreate(o,c));else if(S){var i=u(S)?n(t):void 0,a="Smoothless";void 0!==i&&R.forEach(function(t){u(t)&&t.oP!=i&&(a="Smooth")}),this[a].call(this,function(){this.bU();var t=null;E&&(t=new p.M1,R.forEach(function(e){t.set(e,e.getClient())})),R.forEach(function(t){(!E||S==t||u(S)&&this.isSelected(t))&&(!A&&u(t)&&(t=t.getRoot()),this.onRURApplyClient(t,this.htR(k,e.dx,e.dy,t.getClient()))),void 0!==i&&(l=l||h.call(this,R)).get(t)&&this.onRURApplyParent(t,i)},this),u(i)&&(i.SetExpand(!0),this.EnsureVisibleOnExpand(S)),E&&this.onRURResize(S,t),this.onRURChange(S,w),this.eU()},this)}}}}else if(O=v||this.rurAllowMove(S,c)){var V=this.Lyt().rgVO,D=this.getExpandGlyphSize(),F=null;o.rurOnlyAO=S,o.rurDragStart=function(t){F=this.p2O,this.p2O=function(t){var e=this.ptCA(t,!0);return V.p2O(f.X(e),this.Lyt().y2C(f.Y(e)),S)}},o.rurDragEnd=function(t){this.p2O=F||this.p2O},o.rurDrag=function(t){function e(t){var e,o,i,n=t,r=w.get(t);if(r){for(;!e&&(n=n.oP);)e=w.get(n);e&&(o=n.getClient(),i=t.getClient(),t.SetClient([o[0]-(e[0]-r[0]),o[1]-(e[1]-r[1]),i[2],i[3]]))}}v&&!w.len()&&(v=!!(S=this.orurDC=this.onRURCreate(f.C2R(this.ptCA(g,!0),0,0),c)))&&(y={o:S,ht:68,new:!0},w.set(S,S.getClient()));var o=this.Lyt(),n={dx:t.to.x-t.from.x,dy:t.to.y-t.from.y},r=function(){},h=this.onRL;this.getAlignObjectsToGridLines()||(e=r),s.call(this,n,w),V=o.rgVO,this.onRL=r,this.bU(),u(S)&&V.setZOrd(S,V.len()),w.forEach(function(t,i){if(!E||S==i||u(S)&&this.isSelected(i)){var r;(function(t,e,o,i,n){u(t)&&(!t.isResizable()&&34!=e||!t.isMovable()&&34==e)&&(e=0),e&&t.SetClient(this.htR(e,o,i,n))}).call(this,i,y.ht,n.dx,n.dy,t),i.oP&&e(i),V.set(i,o.r2C(i.getClient())),D>0&&V.get(r=i.getExpandGlyph())&&V.set(r,o.r2C(m.Layout.expandGlyphRect(i.getClient(),D)))}},this),!v&&E&&this.onRURResize(S,w,V),this.resVO(),this.eU(),this.onRL=h,i(t)},o.rurDrop=function(t){r();var e=n(t),o="Smoothless";void 0!==e&&R.forEach(function(t){u(t)&&t.oP!=e&&(o="Smooth")}),this[o].call(this,function(){this.bU(),R.forEach(function(t){this.onRURApplyClient(t,t.getClient()),void 0===e||t!=S&&!this.isSelected(t)||(l=l||h.call(this,R)).get(t)&&(u(t)&&!t.isMovable()||this.onRURApplyParent(t,e))},this),u(e)&&(e.SetExpand(!0),this.EnsureVisibleOnExpand(S)),!v&&E&&this.onRURResize(S,w),this.onRURChange(S,v?null:w),this.eU()},this)},o.rurCancel=function(t){r(!0),this.bU(),w.forEach(function(t,e){this.onRURApplyClient(e,t)},this),v&&S.Remove(),this.eU()}}O&&this.rurDrag(t,o)}},m.prototype.rurDragDrop=function(t,e){var o=this.p2O(this.gPtr(t));this.isSable(o)&&p.RUR.D3(t,{object:o,shape:this.getShape(o),client:this.rtCA(o.GetClient(),!1),source:this,onpaint:function(t,e){this.source.drawE(t,e,this.object)},onclick:function(t){e.rurStatus&&e.rurStatus.call(this,t)},onmove:function(t){t.drag.setCursor(p.GP.Get(e.rurName,this.getCursors()))}})},m.prototype.rurLink=function(t,e){var o=this.gPtr(t),i=this.p2O(o);u(i)&&(e.rurEFPaint=function(t,e,o,n){var r=this.p2O(this.ptCA(t.to,!1)),s=this.oSL.allowLink(i,r),h=t.from.x1){var d,S,v=h.GetCustomPath(),O=new p.Surface.Link.PCONVP(n[0],n[n.length-1]),L=h.rgCP;e.rurDrag=function(t){function e(t){var e=this.ptCA(t,!0),o=this.origin();return O.toPh([f.X(e)+f.X(o),this.Lyt().y2C(f.Y(e))+f.Y(o)])}o.call(this,0),!L&&(L=h.rgCP=h.p2CP(n)),L&&(u?function(){if(!S){function o(t,e){return"V"==m.lO(t,e)?y:d}var n,r,s,h,u,a,c,g,y=new p.Arr,d=new p.Arr,v=[0,0],C=[1,1];"m"==i?(a=~~l.substr(1))>0&&a0&&a=0&&c=0?(u=f.LPR(s,h,.5),L.splice(g,0,u.slice()),L.splice(g,0,u.slice()),r=o(s,h),c?(r.push(c,c+1),c-1>=0&&o(L[c-1],L[c]).push(c-1,c)):(r.push(c+1,c+2),c+30&&o=0&&h0&&(h=e(0,t.drag.current.x-p.ROf(r)));var l=t.drag.current.y-p.TOf(r);l>0&&(l=e(0,t.drag.current.y-p.BOf(r))),(h||l)&&this.rurScrollD(h,l),clearTimeout(E);var f=(this.p2O(t.drag.current)||{}).expand;if(f&&!f.isExpanded()){var y=this;E=setTimeout(function(){y.bU(),f.SetExpand(!0),n(),y.eU()},512)}u.to=this.ptCA(t.drag.current,!0),u.dx=u.to.x-u.from.x,u.dy=u.to.y-u.from.y,n(),null!=L&&L.SetClient(this.rtCA(u.frame,!1));break;case 4:case 5:clearTimeout(E),this.orurOnlyAO=null,i(this),null!=O&&O.call(m,u),O=null,null!=v&&v.call(m,t)}},this,{contiguously:!0,client:r})}},m.prototype.onRURDragStart=function(t,e){switch(this.orurDC=null,t){case"move":case"link":var o=this.p2HT(this.gPtr(e));o&&(this.orurDC=o.o);break;case"link-cp":this.orurDC=this.p2L(this.gPtr(e))}},m.prototype.onRURDragEnd=function(t,e){e.drag.cancel||e.drag.click||this.orurDC&&this.onChange(t,this.orurDC),this.orurDC=null},m.prototype.getChange=function(t,e){return{element:e,action:t}},m.prototype.onChange=function(t,e){this.onchange(this.getChange(t,e))},m.prototype.onchange=function(t){this.oLts.onchange.do(t)},m.prototype.focusPointAbs=function(t){var e=this.ptCA(t,!0),o=this.p2O(t);return null!=o&&(e=f.R2C(this.Lyt().o2R(o))),e},m.prototype.focusRectAbs=function(t){var e=f.Rect(t.from,t.to);if(!p.EyR(e)){var o=this.Lyt(),i=o.r2O(e);i.length&&i.forEach(function(t){e=p.URt(e,o.o2R(t))}),e=o.r2C(e)}return e},m.prototype.onRURCreate=function(t,e){var o,i=this.onAddElement;return this.onAddElement=n,o=this.oSE.Create(t),this.onAddElement=i,o},m.prototype.rurAllowMove=function(t,e){return u(t)},m.prototype.allowRur=function(t,e){return null!=t},m.prototype.rurAction=function(t,e,o){var i=this.gPtr(o),n={rurName:t,rurFlags:e,rurOnlyAO:this.p2O(i)||{},rurStatus:function(e){this.rurActionClick(t,e)}};if(this.allowRur(o,n)){var r="rur"+p.getP(function(t){for(var e,o="",i=0,n=t.length;i=0&&(n=h.gCP())&&r<=n.length&&(i=r?r==n.length?m.lO(n[n.length-1],[1,1]):m.lO(n[r-1],n[r]):m.lO([0,0],n[0]))&&(o+="-"+i.toLowerCase()))),o},m.prototype.p2O=function(t){return this.Lyt().p2O(this.ptCA(t,!0),0,0,this.getVO())||null},m.prototype.r2O=function(t){return this.Lyt().r2O(this.rtCA(t,!0))},m.prototype.p2A=function(t){return t=this.p2V(t),p.H.P2A(this,f.X(t),f.Y(t))},m.prototype.onSetAO=function(t){function e(e){var o=i.getShape(e);o&&(!p.EyO(o.hover)&&t.set({owner:i,id:e.idAOH||(e.idAOH={}),object:e,inv:i.inv,hitTest:function(t,o,n){return r?r===e:n.object==i.p2O([t,o])&&i.isAP(t,o)},duration:n}),!p.EyO(o.click)&&t.set({owner:i,id:e.idAOC||(e.idAOC={}),object:e,inv:i.inv,hitTest:function(t,o,n){return r?r===e:n.object==i.p2O([t,o])&&i.isAP(t,o)},actOn:r==e?1:4,duration:n}))}var o=null;if(this.isSelectable()&&!t.hasOf(this)&&(o=this.getVO())){var i=this,n=i.getSmooth(),r=i.orurOnlyAO;u(r)?e(r,o.indexOf(r)):(o.forEach(function(t,o){e(o)},this),this.onExtAO(t,o))}},m.prototype.onExtAO=function(t,e){},m.prototype.onimg=function(){this.Refresh()},m.prototype.onRL=function(){this.resVO(),this.oLyt=null},m.prototype.resVO=function(){this.rgVO=null,this.rgVL=null,this.mAS=null,this.resAO()},m.prototype.bU=function(){this.lI++},m.prototype.eU=function(){if(!--this.lI){var t=this.gCW();!t||this.oLyt?this.invAO():(this.resAO(),t.Render())}},m.prototype.beU=function(){this.bU(),this.eU()},m.prototype.Refresh=function(){this.bU(),this.onRL(),this.eU()},m.prototype.islow=function(){return this.getScale()<.5},m.prototype.Smooth=function(t,e){if(h(t))if(this.getSmooth()){var o=this.getSmooth(),i=null,n=null;if(o>0&&(p.A.Cancel(this.sSA),i=this.getVO(),n=this.Lyt(),this.bU()),null!=this.rgVO&&this.rgVO.clean(),t.call(e||this),o>0){var r=this.uSR;this.uSR(),this.uSR=function(){},this.rgVO=i,this.oLyt=n,this.eU(),this.oLyt=null,this.rgVO=null,this.uSR=r;var s=this.origin(),l=this.getVO(),u=this.Lyt();new p.Arr(i.diff(l)).rforEach(function(t){var e=i.get(t),o=l.get(t),r=t.expand||t;if((!e||!o)&&r.oP&&r.oSE.Item(r)){var h=r.oP;if(!e){for(;h&&!(e=i.get(h.getExpandGlyph()));)h=h.oP;e&&i.push(t,f.C2R(f.R2C(e)))}if(!o){for(;h&&!(o=l.get(h.getExpandGlyph()));)h=h.oP;o&&l.push(t,f.C2R(f.R2C(o)))}}!e&&i.push(t,n.o2R(t,s)||f.C2R(f.R2C(o))),!o&&l.push(t,u.o2R(t,s)||f.C2R(f.R2C(e)))}),this.rgVL=null,(this.rgVO=i).morph(l,{inv:this.invAO,refresh:this.Refresh,thisArg:this,name:this.sSA,onXDoL:!1,duration:o})}}else p.A.Cancel(this.sSA),t.call(e||this)},m.prototype.Smoothless=function(t,e){h(t)&&t.call(e||this)},m.prototype.Lyt=function(){if(!this.oLyt){var t,e=this.gCtx();e&&(t=p.TFI.bCTX(e,this.getTfi())),this.oLyt=new m.Layout(this),e&&p.TFI.eCTX(e,t)}return this.oLyt},m.prototype.getVO=function(){return this.rgVO||(this.rgVO=this.Lyt().scroll(this.GetScrollRect(),this.origin()))},m.prototype.getVL=function(){if(null==this.rgVL){var t=this.getVO(),e=this.Lyt(),o=this.origin(),i=this.GetScrollRect(),n=new p.Arr;this.getShowLinks()&&(p.ORt(i,-i[0],-i[1]),this.oSL.forEach(function(r){if(r.getVisible()){var s=this.ftL(r),h=t.get(s.oF)||e.o2R(s.oF,o),l=t.get(s.oT)||e.o2R(s.oT,o);h&&l&&p.NRt(i,p.URt(h,l))&&n.push(r)}},this)),this.rgVL=n}return this.rgVL},m.prototype.rOrg=function(){var t=[0,0];return this.aPO()?this.isC()&&(t=[0,1]):this.aSR()&&(t=[.5,.5]),t},m.prototype.origin=function(t){t=t||this.GetScroll();var e=this.getBorder();return[-(this.sR[0]+t.x)+e,-(this.sR[1]+t.y)+e]},m.prototype.ptCA=function(t,e){var o={x:f.X(t),y:f.Y(t)},i=this.GetScroll(),n=this.GetInsideRect(!0),r=this.sR;return null==e||e?(o.x-=n[0],o.y-=n[1],o.x=this.scaled(o.x),o.y=this.scaled(o.y),o.x+=r[0]+i.x,o.y+=r[1]+i.y,this.isC()&&(o.y=-o.y)):(this.isC()&&(o.y=-o.y),o.x-=r[0]+i.x,o.y-=r[1]+i.y,o.x=this.unscaled(o.x),o.y=this.unscaled(o.y),o.x+=n[0],o.y+=n[1]),o},m.prototype.rtCA=function(t,e){return f.Rect(this.ptCA(f.R2C(t,17),e),this.ptCA(f.R2C(t,68),e))},m.prototype.isExtSBS=function(){var t=this.gCW();return t&&12288==(12288&t.gSBs())},m.prototype.uSR=function(t){if(this.oW){var e,o=this.aSR(),i=this.sR,n=this.GetInsideRect(),r=this.rOrg(),s=[-n[2]*r[0],-n[3]*r[1],n[2],n[3]],h=[0,0,0,0];o&&p.IsA(t)?this.oT.GetScrollBars()!=p.ScrollBarsEnum.exNoScroll&&(i=t):(i=o?null===t?s:i?p.URt(i,s):s:h,i=p.URt(this.Lyt().rtLayout,i)),i=i||h,this.aPO()&&(e=[0,0,p.ROf(i),p.BOf(i)],this.isC()&&(e[3]=-(e[1]=p.TOf(i))),i=p.NRt(i,e)||h);var l=!1,u=this.oW.GetSI(!0),a=this.oW.GetSI(!1);r=this.rOrg(),this.sR=i,[u,a].forEach(function(t,e){if(t){var o=e+p.w;i[o]!=t.range&&(l=!0,t.range=i[o]),n[o]!=t.page&&(l=!0,t.pos+=(t.page-n[o])*r[e],t.page=n[o])}},this),l&&(this.resVO(),this.oW.SetSI(u,a),!this.lI&&this.invAO())}},m.prototype.aSR=function(){return!0},m.prototype.getScale=function(){return null==this.scale&&(this.scale=this.getZoom()/100),this.scale},m.prototype.scaled=function(t){return t/this.getScale()},m.prototype.unscaled=function(t){return t*this.getScale()},m.prototype.GetZoom=function(){return this.oO.zoom},m.prototype.SetZoom=function(t){this.bU(),this.scale=null,this.oO.zoom=t,this.uSR(),this.eU()},m.prototype.getZoom=function(){var t=this.GetZoom(),i=this.getZoomLevels();return null==t&&(t=100),e(i[0],o(i[i.length-1],t))},m.prototype.GetZoomLevels=function(){return this.oO.zoomLevels},m.prototype.SetZoomLevels=function(t){this.bU(),this.scale=null,this.oO.zoomLevels=t,this.uSR(),this.eU()},m.prototype.getZoomLevels=function(){var t=[100],i=new p.Arr;return p.ToS(this.GetZoomLevels(),"25,35,50,65,75,80,90,100,110,125,150,175,200,250,300,400,500").split(",").forEach(function(t){i.push(e(10,o(1e3,p.ToN(t,100))))}),i.isEmpty()||(t=i.byO()).sort(function(t,e){return t-e}),t},m.prototype.zoomOnWheel=function(t){var i=!1,n=p.WhelInc(t);if(n){var r=this.getZoomLevels(),s=100*this.getScale(),h=function(t,e){var o=0,i=e.length;if(t>=e[o])for(;t>=e[o+1]&&oMath.abs(t.drag.offset.dy)?t.drag.offset.dx:t.drag.offset.dy),t.drag.current);break;case 4:case 5:null!=r&&r.call(s,t)}},this)}},m.prototype.GetScrollBarsHome=function(){return this.oO.scrollBarsHome},m.prototype.SetScrollBarsHome=function(t){this.bU(),this.oO.scrollBarsHome=t,this.eU()},m.prototype.getScrollBarsHome=function(){var t=this.GetScrollBarsHome();return void 0===t&&(t="black"),t||null},m.prototype.GetScrollBarsLayout=function(){return this.oO.scrollBarsLayout},m.prototype.SetScrollBarsLayout=function(t){this.bU(),this.oO.scrollBarsLayout=t,this.eU()},m.prototype.getScrollBarsLayout=function(){var t=this.GetScrollBarsLayout();return void 0===t&&(t="black"),t||null},m.prototype.Soom=function(t,e,o){var i=null!=t,n=null!=e;if(i||n){o=o||this.rOrg();var r=100*this.getScale(),s=this.GetInsideRect(!0),h=this.ptCA(e,!1),l={x:s[0]+s[2]*o[0],y:s[1]+s[3]*o[1]};((i&=r!=t)||(n&=h.x!=l.x||h.y!=l.y))&&(p.A.Cancel("soom"),p.A.Progress(function(o){this.bU(),i&&this.SetZoom(r+(t-r)*o),n&&(h=this.ptCA(e,!1),this.rurScrollD((h.x-l.x)*o,(h.y-l.y)*o)),this.eU()},{name:"soom",thisArg:this,duration:this.getSmooth(),onXDoL:!1,transition:"swipe"}))}},m.prototype.Home=function(){this.Soom(100,[0,0])},m.prototype.FitToClient=function(t){function e(t,e){return{x:t[0]+t[2]*e[0],y:t[1]+t[3]*e[1]}}var i=null==t;if(null==(t=t||this.Lyt().rtLayout))this.Home();else if(!p.EyR(t)){var n=this.GetInsideRect(!0),r=this.getScale(),s=o(n[2]/t[2],n[3]/t[3]),h=this.rOrg(),l=e(t,h);i&&s>r?s=null:s1),t.rgSel=null),r&&(t.rgSel=t.rgSel||new p.Arr).push(e)),i|=n!=t.isSelected(e);return i}var n=!1,r=!o&&(this.isToggleSel()||this.isToggleCtrlSel()&&2&this.oSelEv.modifier),h=this.valueToElements(t);s(h)?r?h.forEach(function(t){n|=i(this,t,r)},this):(n=!h.equal(this.rgSel))&&(this.isSingleSel()?i(this,h.last()):(this.rgSel=new p.Arr,h.forEach(function(t){this.isSable(t)&&this.rgSel.push(t)},this))):n=i(this,h,r),n&&(s(this.rgSel)&&0==this.rgSel.len()&&(this.rgSel=null),0==this.lI&&(void 0===e||e)&&this.invAO(),this.onSel())},m.prototype.rurSelectClick=function(t){var e=this.allowSelect()&&t&&t.drag&&4==t.drag.status&&1==p.e2B(t);if(e){var o=this.p2O(t.drag.current);this.selectModifierEvent(t),this.select(o),this.selectModifierEvent(null),this.onRurClick(o)}return e},m.prototype.onRurClick=function(t){this.EnsureVisibleClient(t)},m.prototype.onSel=function(){this.onselchange(this.GetSelection())},m.prototype.onselchange=function(t){this.oLts.onselchange.do(t)},m.prototype.drawS=function(t,e){null==e?this.drawO(t):(e?(this.drawO(t),this.drawL(t)):(this.drawL(t),this.drawO(t)),this.drawLCP(t))},m.prototype.drawO=function(t,e,o){var i=this.getVO(),n=this.isSelectable()?t.gAO():null;if(i){n&&(n.hasOf(this)||(n=null));var r=i.toA();(null==o||o<0)&&(o=r.length);for(var s,h=e||0,l=r.length,u=0;h1){var n,r,s=this.toShape("multiSel");s&&(o=p.Format(o,0),n=t.sizeHTMLText(o),r=f.C2R(f.R2C(e,i),n.width+8,n.height+8,i),t.drawShape(r,s,{text:o}))}},m.prototype.acTL=function(){var t=this.GetClientRect(),e=this.rtCA(t),o=p.ORt(e.slice(),-e[0],-e[1]),i=this.isC(),n=e[1],r=p.BOf(e),s=e[3];return i&&(n=s+n,r-=s),{lA:e[0],tA:n,rA:p.ROf(e),bA:r,lC:o[0],tC:o[1],rC:p.ROf(o),bC:p.BOf(o),xR:o[2]/e[2],yR:o[3]/e[3],x:function(t){return this.lC+(t-this.lA)*this.xR},y:function(t){return this.tC+(t-this.tA)*this.yR}}},m.dGL=function(t,e,o,i){e&&p.ToI(e.width,1)&&(t.save(),null!=e.width&&(t.lineWidth=e.width),null!=e.color&&(t.strokeStyle=e.color),null!=e.style&&t.setLineDash(p.IsA(e.style)?e.style:[e.style]),null!=e.cap&&(t.lineCap=e.cap),null!=e.join&&(t.lineJoin=e.join),t.beginPath(),o.call(i,e),t.stroke(),t.restore())},m.prototype.drawA=function(t){if(this.getShowAxes()){var e=this.acTL();m.dGL(t,this.getAxes(),function(){var o=0,i=0;(o>=e.lA&&o=e.rA&&o=e.tA&&i=e.bA&&i1&&m.dGL(t,i,function(){for(t=y;t<=d;t+=g)f(u(t));for(var t=S;t<=v;t+=g)p(a(t))})}if(this.getShowGridLines()){var n=this.acTL(),r=n.lC,s=n.rC,h=n.tC,l=n.bC,u=n.x.bind(n),a=n.y.bind(n);!this.islow()&&i(this.getMinorGridLines()),i(this.getMajorGridLines())}},m.prototype.ftL=function(t){return this.ftcL(t)},m.prototype.ftDefLink=function(t){return t},m.prototype.ftcL=function(t){var e=t.oF.getCollapsedParent(),o=t.oT.getCollapsedParent();return e==t.oF&&o==t.oT?t:{oF:e,oT:o}},m.prototype.drawL=function(t){function e(t){var e=v.get(t);return void 0==e&&v.set(t,e=S.get(t)||C.o2R(t,O)),e}function o(t,e){return t?e?p.Inh(t,e):t:e}var i,n,r,s,h,l,u,a=p.L,c=this,g=c.oSL,y=!c.isReadOnly()&&g.oFL||null,d=c.getSel(),S=c.getVO(),v=new p.M1,C=c.Lyt(),O=c.origin(),L=c.getLink(),A=c.getCollapsedLink(),E=function(t,e){return e},R=t.drawDir;d.len()&&(i=c.getLinkStartFrom(),n=c.getLinkEndTo(),r=c.getLinkUnselected(),(i||n)&&d.forEach(function(t){g.linksOf(t).forEach(function(e){e.getFrom()==t&&i&&(s=s||new p.Arr).push(e),e.getTo()==t&&n&&(h=h||new p.Arr).push(e)})}),(s||h||r)&&(E=function(t,e){return s&&s.has(t)?e=o(i,e):h&&h.has(t)?e=o(n,e):r&&(e=o(r,e)),e})),t.drawDir=function(t,e,o,i,n){function r(t,e){t&&(u=u||new Map).set(t,f.C2R(e,6,6))}var s=n.link,h=s.getCustomPath(),a=n.p||t,c=o&&s.rgCP;if(h&&(s.oSL.oFL==s&&s.oSL.oSV.orurDC==s&&(h=s.sCP(h)),a=s.cp2P(h,a[0],a[a.length-1])),s==y)for(var p,g,d,S=function(t,e,o){var i=t.aCP();return i&&(2==(t.getLink()||{}).type&&(i&=-4),i&&m.lO(e,o)&&(i&=-13)),i}(y,(l=a)[0],l[l.length-1]),v=0,C=l.length;v1){for(var s=0;s<4;s++)t[s]=o(t[s]);t[2]=e(n,t[2]),t[3]=e(n,t[3])}return t}.call(this,p.HitTest.Resize(t,o,i,n,r))},m.prototype.onCopy=function(){var t,e=this.getSel(),o=[];return e.forEach(function(t){t.genID(),o.push(t.coO())}),this.oSL.linksOf(e).forEach(function(o){e.has(o.getFrom())&&e.has(o.getTo())&&(o.genID(),(t=t||[]).push(o.coO()))}),{e:o,l:t}},m.prototype.offP=function(t){return this.getPad()},m.prototype.onPaste=function(t){var e,o,i,n,s=t.e;r(s)&&(o=this.oSE.nextID(s.length),i=new Map,s.forEach(function(t,e){i.set(t.key,t.key=o[e])},this),s.forEach(function(t){null!=t.parent&&(t.parent=i.get(t.parent))},this),e=this.offP(t),s.forEach(function(t){e&&t.client&&p.ORt(t.client,e[0],e[1]),this.oSE.Add(t)},this),r(n=t.l)&&n.forEach(function(t,e){t.key=this.oSL.nextID(),t.from=i.get(t.from),t.to=i.get(t.to),this.oSL.Add(t)},this))},m.prototype.aCCP=function(){return p.EVis(this.GetCanvas())},m.prototype.Cut=function(){this.aCCP()&&(this.Copy(),this.RemoveSelection())},m.prototype.Copy=function(){if(this.aCCP()){var t=p.win.event,e=JSON.stringify(this.onCopy());l(t)?(p.SEP(t),t.clipboardData.setData("text/plain",e)):p.nav.clipboard.writeText(e)}},m.prototype.Paste=function(){function t(t){this.Smooth(function(){var e,o=this.oSE.GetCount();try{this.onPaste(JSON.parse(t))}catch(t){}if(o!=this.oSE.GetCount()){for(var i=o,n=this.oSE.GetCount();i=this.End)},w.prototype.UnionWith=function(t){var i=this.IntersectWith(t);return i&&(this.Start=o(this.Start,t.Start),this.End=e(this.End,t.End),this.Elements.push(t.Elements)),i},Object.addPrototypeOf(b.prototype,p.M1.prototype),b.prototype.isEmpty=function(){return 0==this.len()},b.prototype.MinX=function(){var t=null;return this.forEach(function(e){(!t||e[0]=i)},U.prototype.IntersectRightMin=function(t,e,o){return o.clear(),this.forEach(function(i,n){if(!e||!e.has(n)){var r=p.NRt(t,i);p.EyR(r)||o.set(n,i[0]=i)},U.prototype.IntersectDownMin=function(t,e,o){return o.clear(),this.forEach(function(i,n){if(!e||!e.has(n)){var r=p.NRt(t,i);p.EyR(r)||o.set(n,i[1]0?s=c:(c=p.BOf(r)-p.TOf(u))<0&&(s=c);break;case 1:var f=p.ROf(l)-p.LOf(h);l[0]=u[0]=h[0],l[2]=f,u[2]=0,this.Intersect(l,i,a)&&(u=this.Union(a.rgO));var g=p.LOf(r)-p.ROf(u);g>0?s=g:(g=p.ROf(r)-p.LOf(u))<0&&(s=g)}if(s)switch(e){case 0:case 1:n=-s}}return n},U.prototype.Shift=function(t,e,o){var i=null;t.forEach(function(t){(i=this.get(t))&&p.ORt(i,e,o)},this)},U.orderElementRectByStart=function(t,e){return t.Start-e.Start},U.prototype.ToBlocks=function(t,e,o){var i=[];switch(t){case 0:this.forEach(function(t,o){e&&!e.has(o)||i.push(new w(o,p.LOf(t),p.ROf(t)))},this);break;case 1:this.forEach(function(t,o){e&&!e.has(o)||i.push(new w(o,p.TOf(t),p.BOf(t)))},this)}return h(o)&&i.sort(o),i},G.prototype.GetCache=function(t){return this.oSurfaceElementsArrange.Cache.GetCache(t)},G.ToVector=function(t,e,o){return t=t.slice(),h(e)&&t.sort(function(t,i){return e.call(o,t,i)}),t},G.prototype.orderElementByOutAll=function(t,e){return this.GetCache(e).OutAll.len()-this.GetCache(t).OutAll.len()},G.prototype.showTemp=function(t){t.forEach(function(t,e){t.Caption=""+e,t.Shape={normal:{fillColor:"rgba(255,0,0,0.5)"}}},this)},G.prototype.Init=function(){if(this.Input.clear(),!this.Elements.isEmpty()){this.Elements.forEach(function(t){this.GetCache(t).collectAll(this)},this);var t=G.ToVector(this.Elements.byO(),this.orderElementByOutAll,this),e=new p.Arr;t.forEach(function(t){e.has(t)||(this.Input.add(t),e.push(this.GetCache(t).OutAll))},this)}return this},G.prototype.PreArrange=function(){this.preArrange(this.Input,this.Loc),this.getArrangeCompact()&&this.compact(),this.getArrangeAlign()&&this.align(),this.optimize()},G.toRect=function(t,e){return[t[0],t[1],e.cx,e.cy]},G.prototype.setArrangeLoc=function(t,e,o,i){(this.GetCache(t).Group||[t]).forEach(function(t){o&&e&&o.set(t,e.slice()),i&&i.add(t)})},G.prototype.getArrangeCount=function(t){var e=new p.Arr;return t.forEach(function(t){e.push(t,this.GetCache(t).OutAll)},this),e.len()},G.prototype.addElementGroup=function(t,e){e.add(t);var o=this.GetCache(t).Group;o&&e.push(o)},G.prototype.nextLoc=function(t,e){switch(this.getArrangeDir()){case 0:t[1]+=e.cy;break;case 1:t[0]+=e.cx}},G.prototype.nextDown=function(t,e){switch(this.getArrangeDir()){case 0:t[0]=p.ROf(t);break;case 1:t[1]=p.BOf(t)}t[2]=e.cx,t[3]=e.cy},G.prototype.nextRight=function(t,e){switch(this.getArrangeDir()){case 0:t[0]=p.ROf(t),t[2]=e[2],t[1]=e[1],t[3]=e[3];break;case 1:t[1]=p.BOf(t),t[3]=e[3],t[0]=e[0],t[2]=e[2]}},G.prototype.isArranged=function(t,e){var o=!0;switch(this.getArrangeDir()){case 0:o=t[0]>=e[0];break;case 1:o=t[1]>=e[1]}return o},G.prototype.preAllocateDownRight=function(t,e){var o=[0,0];t.forEach(function(t){if(!e.get(t)){var i=this.Size.get(t);this.setArrangeLoc(t,G.toRect(o,i),e),this.nextLoc(o,i)}},this);var i=e.union();return{cx:i[2],cy:i[3]}},G.prototype.preArrange=function(t,e){e.clear();if(null!=(v=t.first())){var o=new p.Arr,i=new p.Arr;for(this.setArrangeLoc(v,G.toRect([0,0],this.Size.get(v)),e,o),v=t.next(v);v;v=t.next(v))this.setArrangeLoc(v,null,null,i);for(var n=this.getArrangeCount(o),r=0,s=n*(n-1),h=this.getArrangeDir(),l=!0;l;){l=!1;for(var u=0;u1){for(var l=[],s=0;su.End){for(var c=new w(null,u.End,a.Start),n=s+1;n1&&this.rgArrangementCache.push(e.Init())}}},P.prototype.PreArrange=function(){this.rgArrangementCache.forEach(function(t){t.PreArrange()})},P.prototype.DoArrange=function(){this.rgArrangementCache.forEach(function(t){t.DoArrange()})},k.prototype.getArrangeDir=function(){return this.oDefArrange.dir||0},k.prototype.getArrangeDX=function(){return this.oDefArrange.dx||0},k.prototype.getArrangeDY=function(){return this.oDefArrange.dy||0},k.prototype.getArrangeAlign=function(){return null!=this.oDefArrange.align?~~this.oDefArrange.align:1},k.prototype.getArrangeCompact=function(){return this.oDefArrange.compact},k.prototype.onArranging=function(){this.Cache.ResetCache()},k.prototype.onArrange=function(){this.Cache.ResetCache()},k.prototype.Arrange=function(t){var e=null;-2&this.getArrangeDir()||null!=t&&!(e=this.oSE.Item(t))||(this.onArranging(),this.Cache.Collect(e),this.Cache.PreArrange(),this.Cache.DoArrange(),this.onArrange())},p.expO({Count:null},t.prototype),p.expO(p.Mrg({Options:null,Index:null,Position:null},p.Surface.ElementOptions),a.prototype),p.expO({Count:null},v.prototype),p.expO(p.Mrg({Options:null,Index:null},p.Surface.LinkOptions),C.prototype),{Elements:t,Element:a,Links:v,Link:C,SV:m,CSurfaceElementsArrange:k}}()),p.Mrg(p.Surface.SV,function(){function t(t){this.oSV=t,this.rgVO=new p.M1,this.mP2O=new Map,this.rtLayout=this.doL()}return t.expandGlyphRect=function(t,e){return[t[0]-e,t[1]+(t[3]-e)/2,e,e]},t.prototype.doL=function(){function e(t){return t}function o(i,u){n.push(i,e((u=u||i.getClient()).slice()));var a,c,p,f=u[1]+(r?0:u[3]),g=i.getVisibleChild();return l>0&&(g||i.hasVisibleChild())&&n.set(i.getExpandGlyph(),e(t.expandGlyphRect(u,l))),g&&(a=u[0]+s,g.forEach(function(t){c=(p=t.getClient())[3],f=o(t,t.oO.client=[a,r?f-c-h:f+h,p[2],c])})),f}var i=this.oSV,n=this.rgVO,r=i.isC(),s=i.getIndent(),h=i.getMarginY(),l=i.getExpandGlyphSize();return r&&(e=t.r2C),i.oSE.forEach(function(t){t.isVisible()&&!t.oP&&o(t)}),t.toR(n),n.union()},t.toR=function(t){t&&t.forEach(function(t){for(var e=0,o=t.length;e