/* @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(){}function o(t){return t instanceof Array}function i(t){return t instanceof p.Arr}function n(t){return t instanceof Function}function r(t){return t instanceof ClipboardEvent}function s(t){return t instanceof p.Surface.Element}function h(t){return null!=t}function l(t){return null==t}function a(t,e,o){return l(t)?~~o:p.s2F(t,e)}function u(t){if(t&&t.isExpanded&&t.isExpanded()){var e=null,o=this.Lyt().rgVO;this.oSE.dscn(t).forEach(function(t){e=p.URt(e,o.get(t))}),this.EnsureVisibleClient(e)}}var c,p=p||window.exontrol,f=p.G,g=p.UR,y=Math.round,d=p.ToS,S=Math.max,v=Math.min,C="pos",O="imageSize",m="client",L=p.IsS,A=p.IsI;p.Shapes.Surface={};var E={dir:0,dx:36,dy:36,align:1,compact:!0},R={type:void 0,dir:void 0,width:void 0,color:void 0,arrow:void 0,arrowSize:void 0,arrowShape:void 0,style:void 0,startPos:void 0,endPos:void 0},w={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},b={visible:!0,key:null,caption:null,captionAlign:null,captionFormat:null,from:null,to:null,link:null,collapsedLink:null,allowControlPoint:null,customPath:void 0};p.Mrg(p,function(){function t(t,e){p.host.call(this,arguments)}return t.prototype.init=function(t,e){var o=new p.Surface.SV(this);if(this.oSV=o,this.oVS=new p.ScrollBar(null,null),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.drawP;this.oVS.drawP=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(null,null),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.drawP;this.oHS.drawP=function(t,e,i,r){n.call(this,t,e,i,r),o.onDrawPartScroll(this,t,e,i,r)}}this.Listeners=this.oLts=this.oSV.oLts,this.oCW=new p.CW(t,{AllowXChg:0,ScrollBars:this.defOpt().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.prototype.defOpt=function(){return p[this.constructor.type].Options},p.Lts.Onf(t.prototype),t.version="5.5",t.type="Surface",t.LinkControlPointEnum={exNoControlPoint:0,exStartControlPoint:1,exEndControlPoint:2,exControlPoint:4,exMiddleControlPoint:8,exOrthoArrange:16,exAllowChangeFrom:32,exAllowChangeTo:64},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={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,allowUndoRedo:null,undoRedoQueueLength:null,focusLink:null},g&&(t.blockUR=function(t){return function(){var e=this,o=arguments;(this.oSV||this).blockUR(function(){t.apply(e,o)})}}),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(p.Mrg({Canvas:null},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){s(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.BlockUndoRedo=function(t,e){n(t)&&(this.StartBlockUndoRedo(),t.call(e||this),this.EndBlockUndoRedo())},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)},t.prototype.feE=function(t,e){return this.oSV.oSE.forEach(t,e||this)},t.prototype.feEU=function(t,e){return this.oSV.oSE.forEachU(t,e||this)},t.prototype.feL=function(t,e){return this.oSV.oSL.forEach(t,e||this)},t.prototype.feLU=function(t,e){return this.oSV.oSL.forEachU(t,e||this)},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 y(t,e){this.init(t,e)}function U(t){this.init(t)}function G(t,e){this.init(t,e)}function P(){this.mIO=new Map}function k(t){this.init(t)}function x(t){this.Elements=new p.Arr,this.Out=new Map,this.In=new Map,this.Build(t)}function I(){this.Group=null,this.In=new p.Arr,this.InAll=new p.Arr,this.Out=new p.Arr,this.OutAll=new p.Arr}function T(){this.rgGroups=[],this.rgCache=new Map}function V(t){var e=new p.Arr;Object.getOwnPropertyNames(e).forEach(function(t){this[t]=e[t]},this),this.oArrangement=t,this.nAdding=0}function D(t,e,o){this.Elements=new p.Arr,this.Start=e||0,this.End=o||0,h(t)&&this.Elements.add(t)}function F(){var t=new p.M1;Object.getOwnPropertyNames(t).forEach(function(e){this[e]=t[e]},this)}function M(){var t=new p.M1;Object.getOwnPropertyNames(t).forEach(function(e){this[e]=t[e]},this)}function B(t,e){this.oSurfaceElementsArrange=t,this.Origin=e,this.Elements=new p.Arr,this.Groups=new T,this.Size=new Map,this.Input=new V(this),this.Loc=new M,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 z(t){this.oSurfaceElementsArrange=t,this.Links=new x(this.oSurfaceElementsArrange.oSL),this.rgElementCache=new Map,this.rgArrangementCache=[]}function H(t,e,o){this.oSE=t,this.oSL=e,this.oDefArrange=p.Mrg(p.Surface.Options.defArrange,o),this.Cache=new z(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","forEachU","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:s(t)?e=this.rgE.has(t)?t:null:l(e=function(t){var e=t.mK2I;return l(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,n=p.Arr.empty;if(t&&(e=t,s(t)?e=[t]:i(t)&&(e=t.rgE),o(e))){n=new p.Arr,e.forEach(function(t){n.ann(this.Item(t))},this);for(var r=0;r1&&t!=e-1&&this.SetPosition(e-1),t},y.prototype.BringForward=function(){var t=this.GetPosition(),e=this.oSE.GetCount();return e>1&&t+11&&t>0&&this.SetPosition(0),t},y.prototype.SendBackward=function(){var t=this.GetPosition();return this.oSE.GetCount()>1&&t>0&&this.SetPosition(t-1),t},y.prototype.GetKey=function(){return this.oO.key},y.prototype.SetKey=function(t){this.bU(),this.oSE.resK2I(),this.oO.key=t,this.eU()},y.prototype.getKey=function(){var t=this.GetKey();return(t=h(t)?t.toString():"")||this.getPlainCaption()},y.prototype.GetVisible=function(){return this.oO.visible},y.prototype.SetVisible=function(t){this.bU(),this.oO.visible=t,this.eU(!0)},y.prototype.getVisible=function(){return l(this.GetVisible())||this.GetVisible()},y.prototype.isVisible=function(){return this.GetVisible()||l(this.GetVisible())},y.prototype.GetEnabled=function(){return this.oO.enabled},y.prototype.SetEnabled=function(t){this.bU(),this.oO.enabled=t,this.eU()},y.prototype.getEnabled=function(){return l(this.GetEnabled())||this.GetEnabled()},y.prototype.isEnabled=function(){return!!this.getEnabled()&&(!this.oP||this.oP.isEnabled())},y.prototype.GetSelectable=function(){return this.oO.selectable},y.prototype.SetSelectable=function(t){this.bU(),this.oO.selectable=t,this.eU()},y.prototype.getSelectable=function(){return l(this.GetSelectable())||this.GetSelectable()},y.prototype.isSelectable=function(){return this.getSelectable()},y.prototype.GetCaption=function(){return this.oO.caption},y.prototype.SetCaption=function(t){this.bU(),this.oSE.resK2I(),this.oO.caption=t,this.eU(!0)},y.prototype.getCaption=function(){return this.GetCaption()},y.prototype.getPlainCaption=function(){return p.H.TextNoHTML(this.getCaption())},y.prototype.GetFormatText=function(){return this.oO.formatText},y.prototype.SetFormatText=function(t){this.bU(),this.oO.formatText=t,this.eU()},y.prototype.getFormatText=function(){var t=this.GetFormatText();return h(t)?~~t:this.getView().getFormatText()},y.prototype.GetPad=function(){return this.oO.pad},y.prototype.SetPad=function(t){this.bU(),this.oO.pad=t,this.eU()},y.prototype.getPad=function(){var t=this.GetPad();return h(t)?p.pad2A(t):this.getView().getPad()},y.prototype.GetImage=function(){return this.oO.image},y.prototype.SetImage=function(t){this.bU(),this.oO.image=t,this.eU(!0)},y.prototype.getImage=function(){var t=this.GetImage();return h(t)?t.toString():""},y.prototype.GetImageSize=function(){return this.oO.imageSize},y.prototype.SetImageSize=function(t){this.bU(),this.oO.imageSize=t,this.eU(!0)},y.prototype.getImageSize=function(){var t=this.GetImageSize();return void 0!==t?t:this.getView().getImageSize()},y.prototype.GetImageAlign=function(){return this.oO.imageAlign},y.prototype.SetImageAlign=function(t){this.bU(),this.oO.imageAlign=t,this.eU(!0)},y.prototype.getImageAlign=function(){var t=this.GetImageAlign();return h(t)?p.ToI(t,2):this.getView().getImageAlign()},y.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(h(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}},y.prototype.draw=function(t,e,o){var i,n=!this.isEnabled();n&&p.H.lA++,t.selClip(e),i=this.gCnt(t,e),t.drawHTMLPicture(this.getImage(),i.rtImage,this.getImageSize()),t.drawHTMLText(this.getCaption(),i.rtCaption,o&&o.formatText||this.getFormatText(),o&&o.tfi&&p.ToTFI(o.tfi)),t.resClip(),n&&--p.H.lA},y.prototype.GetShape=function(){return this.oO.shape},y.prototype.SetShape=function(t){this.bU(),this.oO.shape=t,this.eU(!0)},y.prototype.GetCursor=function(){return this.oO.cursor},y.prototype.SetCursor=function(t){this.bU(),this.oO.cursor=t,this.eU()},y.prototype.GetClient=function(){return this.oO.client},y.prototype.SetClient=function(t){this.bU(),this.oO.client=t,this.eU(!0)},y.prototype.getContentSize=function(t){var e={width:0,height:0},o=this.getPad(),i=this.getView().toShape(this),n=p.H.Measure(t,this.getCaption(),null,this.getFormatText(),i.tfi&&p.ToTFI(i.tfi)),r=p.HP.Measure(this.getImage(),this.getImageSize(),t);return h(n)&&(e.width+=n.width+1,e.height+=n.height+1),h(r)&&(this.getImageAlign()>=2?(e.width=S(e.width,r.width),e.height&&(e.height+=o[1]),e.height+=r.height):(e.height=S(e.height,r.height),e.width&&(e.width+=o[0]),e.width+=r.width)),e.width+=o[0]<<1,e.height+=o[1]<<1,e},y.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},y.prototype.GetParent=function(){return this.oP},y.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);h(o)&&(o.remove(this),this.resOwnCol()),(this.oP=e)&&this.ownCol(!0).add(this),this.eU(!0)}}},y.prototype.canParent=function(t){return!(t==this.oP||t&&t.isChildOf(this))},y.prototype.isChildOf=function(t){for(var e=this;e&&e!=t;)e=e.oP;return e==t},y.prototype.hasOptsP=function(){var t=null,e=this.oO.parent;return e&&(e=this.oSE.Item(e))&&this.canParent(e)&&(t=e),t},y.prototype.ownCol=function(t){var e=null;return this.oP&&(e=this.oP.rgC,t&&!e&&(this.oP.rgC=e=new p.Arr)),e},y.prototype.resOwnCol=function(){h(this.oP)&&h(this.oP.rgC)&&0==this.oP.rgC.len()&&(this.oP.rgC=null)},y.prototype.dscn=function(){return this.oSE.dscn(this)},y.prototype.GetExpand=function(){return this.oO.expand},y.prototype.SetExpand=function(t){t!=this.isExpanded()&&(this.bU(),this.oO.expand=t,this.eU(!0))},y.prototype.isExpanded=function(){return!(!l(this.GetExpand())&&!this.GetExpand())},y.prototype.ToggleExpand=function(){this.SetExpand(!this.isExpanded())},y.prototype.GetAutoSize=function(){return this.oO.autoSize},y.prototype.SetAutoSize=function(t){this.bU(),this.oO.autoSize=t,this.eU(!0)},y.prototype.getAutoSize=function(){return this.GetAutoSize()},y.prototype.GetResizable=function(){return this.oO.resizable},y.prototype.SetResizable=function(t){this.bU(),this.oO.resizable=t,this.eU(!0)},y.prototype.getResizable=function(){return!(!l(this.GetResizable())&&!this.GetResizable())},y.prototype.isResizable=function(){return this.getResizable()&&!this.getAutoSize()},y.prototype.GetMovable=function(){return this.oO.movable},y.prototype.SetMovable=function(t){this.bU(),this.oO.movable=t,this.eU(!0)},y.prototype.getMovable=function(){return!(!l(this.GetMovable())&&!this.GetMovable())},y.prototype.isMovable=function(){return this.getMovable()},y.prototype.hasVisibleChild=function(){var t=null;return this.rgC&&this.rgC.forEachU(function(e){return e.getVisible()&&(t=e),t}),t},y.prototype.getVisibleChild=function(){var t;return this.rgC&&this.isExpanded()&&this.rgC.forEach(function(e){e.getVisible()&&(t=t||[]).push(e)}),t},y.prototype.hasChild=function(){return this.rgC&&this.rgC.len()},y.prototype.getRoot=function(){for(var t=this;t.oP;)t=t.oP;return t},y.prototype.getLevel=function(){for(var t=0,e=this;e=e.oP;)t++;return t},y.prototype.getCollapsedParent=function(){for(var t=null,e=this;e.oP;)(e=e.oP).isExpanded()||(t=e);return t||this},y.prototype.getExpandGlyph=function(){return this.eG=this.eG||{expand:this}},y.prototype.IsArrangeGroup=function(){var t;return(this.oP||this.rgC)&&(t=this.getRoot().dscn()),t},y.prototype.isVisibleEx=function(){return this.isVisible()&&(!this.oP||this.oP.isExpanded()&&this.oP.isVisibleEx())},y.prototype.ArrangeLoc=function(){var t=[0,0,0,0];return this.isVisibleEx()&&(t=this.getClient()),t},y.prototype.ArrangeSize=function(){var t=this.ArrangeLoc();return{cx:t[2],cy:t[3]}},y.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)},y.prototype.toString=function(){return this.getKey()||this.oSE.indexOf(this)},y.prototype.EnsureVisible=function(){for(var t=this;t=t.oP;)t.SetExpand(!0);this.getView().EnsureVisibleClient(this)},y.prototype.genID=function(){var t=this.GetKey();return l(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},y.prototype.coO=function(){var t=p.Cpy(this.oO);return t[m]=this.getClient(),t.position=this.GetPosition(),s(t.parent)&&(t.parent=t.parent.genID()),t},g&&(y.prototype.scUR=function(t){t.o=this.oSE,t.i=this.genID()},y.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()}}},y.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())})},y.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())})},y.prototype.StartUpdateElement=function(){return this.getView().gUR()&&this.coO()},y.prototype.suo=y.prototype.StartUpdateElement,y.prototype.EndUpdateElement=function(t){t&&this.getView().nUR(c.UpdateElement,function(e){this.uUR(e,t,this.coO())},this)},y.prototype.euo=y.prototype.EndUpdateElement,y.prototype.UpdateElement=function(t,e){if(n(t)){var o=this.StartUpdateElement();t.call(e||this),this.EndUpdateElement(o)}}),U.prototype.init=function(t){this.oSV=t,this.rgL=new p.Arr,this.rgL.onRemove=this.onDelLink.bind(this),this.import()},U.prototype.import=function(){var t=this.oSV;["bU","eU"].forEach(function(e){this[e]=t[e].bind(t)},this),["forEach","forEachU","add","indexOf"].forEach(function(t){this[t]=this.rgL[t].bind(this.rgL)},this)},U.prototype.onRL=function(){this.oSV.onRL()},U.prototype.resK2I=function(){this.mK2I=null},U.prototype.onDelElement=function(t){this.oIOL&&this.RemoveRange(this.oIOL.linksOf(t))},U.prototype.onAddLink=function(t){(this.oIOL=this.oIOL||new P).add(t),this.oSV.onAddLink(t)},U.prototype.onDelLink=function(t){this.oFL=null,this.oIOL&&this.oIOL.remove(t),this.oSV.onDelLink(t)},U.prototype.toE=function(t){return this.oSV.oSE.Item(t)},U.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))},U.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},U.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},U.prototype.OnCreate=function(t){},U.prototype.GetCount=function(){return this.rgL.len()},U.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 l(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},U.prototype.Remove=function(t){var e=this.Item(t);e&&(this.bU(),this.resK2I(),this.rgL.remove(e),this.eU())},U.prototype.RemoveRange=function(t){this.bU(),this.resK2I(),this.rgL.removeRange(t),this.eU()},U.prototype.Clear=function(){this.bU(),this.oIOL=null,this.resK2I(),this.rgL.clear(),this.eU()},U.prototype.linksOf=function(t){return this.oIOL?this.oIOL.linksOf(t):p.Arr.empty},U.prototype.linkOf=function(t,e){return this.oIOL&&this.oIOL.get(t,e)||null},U.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()},U.prototype.Save=function(){function t(t){var e=t.GetKey();return l(e)&&(e=t.getPlainCaption()),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)},U.prototype.nextID=function(t){function e(){for(var t="";this.Item(t=o+ ++this.__nextID););return t}this.__nextID=this.__nextID||0;var o="_l",i=e.call(this);if(h(t)){i=[i],t=S(0,p.ToI(t,1)-1);for(var n=0;ns;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;a--)"E"==r.lO(l,n[a])&&(n.splice(i,a-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},G.prototype.cp2P=function(t,e,o){var i,n=[];if(t){i=new G.PCONVP(e,o),n.push(e);for(var r=0,s=t.length;r1&&this.isSelected(C)&&(T=this.getSelCount()),p.EyO(A)&&(A=null);function D(t,e,o,i){V=V||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(){A?e.drawShape(n,A.normal||A):C?this.drawE(e,n,C):e.drawFrameRect(n)}),T&&e.drawHTMLText(T,o,p.DrawTextFormatEnum.exTextAlignCenter|p.DrawTextFormatEnum.exTextAlignVCenter)}e.rurEFPaint=D,e.rurEFOpts=function(t,e){e.visible=!1,e.limitClient=!1},e.rurDrag=function(t){V&&V.SetVisible(t.from!=t.to);var i={dx:t.to.x-t.from.x,dy:t.to.y-t.from.y};r.call(this,i,b),t.frame=this.htR(I,i.dx,i.dy,x),!e.rurEFPaint&&D.call(this,t,this.gCtx(),this.rtCA(t.frame,!1)),o(t)},e.rurCancel=function(t){n(!0)},e.rurDrop=function(t){n();var e=r.call(this,{dx:t.to.x-t.from.x,dy:t.to.y-t.from.y},b),o=this.htR(I,e.dx,e.dy,x);if(O)p.EyR(o)||this.onRURChange(this.orurDC=this.onRURCreate(o,g));else if(C){var h=s(C)?i(t):void 0,c="Smoothless";void 0!==h&&w.forEach(function(t){s(t)&&t.oP!=h&&(c="Smooth")}),this[c].call(this,function(){this.bU();var t=null;R&&(t=new p.M1,w.forEach(function(e){t.set(e,e.getClient())})),w.forEach(function(t){(!R||C==t||s(C)&&this.isSelected(t))&&(!E&&s(t)&&(t=t.getRoot()),this.onRURApplyClient(t,this.htR(I,e.dx,e.dy,t.getClient()))),void 0!==h&&(a=a||l.call(this,w)).get(t)&&this.onRURApplyParent(t,h)},this),s(h)&&(h.SetExpand(!0),u.call(this,C)),R&&this.onRURResize(C,t),this.onRURChange(C,b),this.eU()},this)}}}}else if(L=O||this.rurAllowMove(C,g)){var F=this.Lyt().rgVO,M=this.getExpandGlyphSize(),B=null;e.rurOnlyAO=C,e.rurDragStart=function(t){B=this.p2O,this.p2O=function(t){var e=this.ptCA(t,!0);return F.p2O(f.X(e),this.Lyt().y2C(f.Y(e)),C)}},e.rurDragEnd=function(t){this.p2O=B||this.p2O},e.rurDrag=function(t){function e(t){var e,o,i,n=t,r=b.get(t);if(r){for(;!e&&(n=n.oP);)e=b.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]]))}}O&&!b.len()&&(O=!!(C=this.orurDC=this.onRURCreate(f.C2R(this.ptCA(y,!0),0,0),g)))&&(d={o:C,ht:68,new:!0},b.set(C,C.getClient()));var i=this.Lyt(),n={dx:t.to.x-t.from.x,dy:t.to.y-t.from.y},h=function(){},l=this.onRL;this.getAlignObjectsToGridLines()||(e=h),r.call(this,n,b),F=i.rgVO,this.onRL=h,this.bU(),s(C)&&F.setZOrd(C,F.len()),b.forEach(function(t,o){if(!R||C==o||s(C)&&this.isSelected(o)){var r;(function(t,e,o,i,n){e&&t.SetClient(this.htR(e,o,i,n))}).call(this,o,d.ht,n.dx,n.dy,t),o.oP&&e(o),F.set(o,i.r2C(o.getClient())),M>0&&F.get(r=o.getExpandGlyph())&&F.set(r,i.r2C(k.Layout.expandGlyphRect(o.getClient(),M)))}},this),!O&&R&&this.onRURResize(C,b,F),this.resVO(),this.eU(),this.onRL=l,o(t)},e.rurDrop=function(t){n();var e=i(t),o="Smoothless";void 0!==e&&w.forEach(function(t){s(t)&&t.oP!=e&&(o="Smooth")}),this[o].call(this,function(){this.bU(),w.forEach(function(t){this.onRURApplyClient(t,t.getClient()),void 0===e||t!=C&&!this.isSelected(t)||(a=a||l.call(this,w)).get(t)&&(s(t)&&!t.isMovable()||this.onRURApplyParent(t,e))},this),s(e)&&(e.SetExpand(!0),u.call(this,C)),!O&&R&&this.onRURResize(C,b),this.onRURChange(C,O?null:b),this.eU()},this)},e.rurCancel=function(t){n(!0),this.bU(),b.forEach(function(t,e){this.onRURApplyClient(e,t)},this),O&&C.Remove(),this.eU()}}L&&this.rurDrag(t,e)}},k.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()))}})},k.prototype.rurLink=function(t,e){var o=this.gPtr(t),i=this.p2O(o);s(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(),C=new p.Surface.Link.PCONVP(n[0],n[n.length-1]),O=h.rgCP;e.rurDrag=function(t){function e(t){var e=this.ptCA(t,!0),o=this.origin();return C.toPh([f.X(e)+f.X(o),this.Lyt().y2C(f.Y(e))+f.Y(o)])}o.call(this,0),!O&&(O=h.rgCP=h.p2CP(n)),O&&(a?function(){if(!S){function o(t,e){return"V"==k.lO(t,e)?y:d}var n,r,s,h,a,u,c,g,y=new p.Arr,d=new p.Arr,v=[0,0],C=[1,1];"m"==i?(u=~~l.substr(1))>0&&u0&&u=0&&c=0?(a=f.LPR(s,h,.5),O.splice(g,0,a.slice()),O.splice(g,0,a.slice()),r=o(s,h),c?(r.push(c,c+1),c-1>=0&&o(O[c-1],O[c]).push(c-1,c)):(r.push(c+1,c+2),c+30&&o=0&&h0&&(s=S(0,t.drag.current.x-p.ROf(r)));var l=t.drag.current.y-p.TOf(r);l>0&&(l=S(0,t.drag.current.y-p.BOf(r))),(s||l)&&this.rurScrollD(s,l),clearTimeout(R);var f=(this.p2O(t.drag.current)||{}).expand;if(f&&!f.isExpanded()){var y=this;R=setTimeout(function(){y.bU(),f.SetExpand(!0),i(),y.eU()},512)}a.to=this.ptCA(t.drag.current,!0),a.dx=a.to.x-a.from.x,a.dy=a.to.y-a.from.y,i(),h(A)&&A.SetClient(this.rtCA(a.frame,!1));break;case 4:case 5:clearTimeout(R),this.orurOnlyAO=null,o(this),h(m)&&m.call(L,a),m=null,h(C)&&C.call(L,t)}},this,{contiguously:!0,client:r})}},k.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))}},k.prototype.onRURDragEnd=function(t,e){e.drag.cancel||e.drag.click||this.orurDC&&this.onChange(t,this.orurDC),this.orurDC=null},k.prototype.getChange=function(t,e){return{element:e,action:t}},k.prototype.onChange=function(t,e){this.onchange(this.getChange(t,e))},k.prototype.onchange=function(t){this.oLts.onchange.do(t)},k.prototype.focusPointAbs=function(t){var e=this.ptCA(t,!0),o=this.p2O(t);return h(o)&&(e=f.R2C(this.Lyt().o2R(o))),e},k.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},k.prototype.onRURCreate=function(t,o){var i,n=this.onAddElement;return this.onAddElement=e,i=this.oSE.Create(t),this.onAddElement=n,i},k.prototype.rurAllowMove=function(t,e){return s(t)},k.prototype.allowRur=function(t,e){return h(t)},k.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?k.lO(n[n.length-1],[1,1]):k.lO(n[r-1],n[r]):k.lO([0,0],n[0]))&&(o+="-"+i.toLowerCase()))),o},k.prototype.p2O=function(t){return this.Lyt().p2O(this.ptCA(t,!0),0,0,this.getVO())||null},k.prototype.r2O=function(t){return this.Lyt().r2O(this.rtCA(t,!0))},k.prototype.p2A=function(t){return t=this.p2V(t),p.H.P2A(this,f.X(t),f.Y(t))},k.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;s(r)?e(r,o.indexOf(r)):(o.forEach(function(t,o){e(o)},this),this.onExtAO(t,o))}},k.prototype.onExtAO=function(t,e){},k.prototype.onimg=function(){this.Refresh()},k.prototype.onRL=function(){this.resVO(),this.oLyt=null},k.prototype.resVO=function(){this.rgVO=null,this.rgVL=null,this.mAS=null,this.resAO()},k.prototype.bU=function(){this.lI++},k.prototype.eU=function(){if(!--this.lI){var t=this.gCW();!t||this.oLyt?this.invAO():(this.resAO(),t.Render())}},k.prototype.beU=function(){this.bU(),this.eU()},k.prototype.Refresh=function(){this.bU(),this.onRL(),this.eU()},k.prototype.islow=function(){return this.getScale()<.5},k.prototype.Smooth=function(t,e){if(n(t))if(this.getSmooth()){var o=this.getSmooth(),i=null,r=null;if(o>0&&(p.A.Cancel(this.sSA),i=this.getVO(),r=this.Lyt(),this.bU()),h(this.rgVO)&&this.rgVO.clean(),t.call(e||this),o>0){var s=this.uSR;this.uSR(),this.uSR=function(){},this.rgVO=i,this.oLyt=r,this.eU(),this.oLyt=null,this.rgVO=null,this.uSR=s;var l=this.origin(),a=this.getVO(),u=this.Lyt();new p.Arr(i.diff(a)).rforEach(function(t){var e=i.get(t),o=a.get(t),n=t.expand||t;if((!e||!o)&&n.oP&&n.oSE.Item(n)){var s=n.oP;if(!e){for(;s&&!(e=i.get(s.getExpandGlyph()));)s=s.oP;e&&i.push(t,f.C2R(f.R2C(e)))}if(!o){for(;s&&!(o=a.get(s.getExpandGlyph()));)s=s.oP;o&&a.push(t,f.C2R(f.R2C(o)))}}!e&&i.push(t,r.o2R(t,l)||f.C2R(f.R2C(o))),!o&&a.push(t,u.o2R(t,l)||f.C2R(f.R2C(e)))}),this.rgVL=null,(this.rgVO=i).morph(a,{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)},k.prototype.Smoothless=function(t,e){n(t)&&t.call(e||this)},k.prototype.Lyt=function(){if(!this.oLyt){var t,e=this.gCtx();e&&(t=p.TFI.bCTX(e,this.getTfi())),this.oLyt=this.newLyt(),e&&p.TFI.eCTX(e,t)}return this.oLyt},k.prototype.newLyt=function(){return new k.Layout(this)},k.prototype.getVO=function(){return this.rgVO||(this.rgVO=this.Lyt().scroll(this.GetScrollRect(),this.origin()))},k.prototype.getVL=function(){if(l(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},k.prototype.rOrg=function(){var t=[0,0];return this.aPO()?this.isC()&&(t=[0,1]):this.aSR()&&(t=[.5,.5]),t},k.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]},k.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 l(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},k.prototype.rtCA=function(t,e){return f.Rect(this.ptCA(f.R2C(t,17),e),this.ptCA(f.R2C(t,68),e))},k.prototype.isExtSBS=function(){var t=this.gCW();return t&&12288==(12288&t.gSBs())},k.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().rtLyt,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,a=this.oW.GetSI(!0),u=this.oW.GetSI(!1);r=this.rOrg(),this.sR=i,[a,u].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(a,u),!this.lI&&this.invAO())}},k.prototype.aSR=function(){return!0},k.prototype.getScale=function(){return l(this.scale)&&(this.scale=this.getZoom()/100),this.scale},k.prototype.scaled=function(t){return t/this.getScale()},k.prototype.unscaled=function(t){return t*this.getScale()},k.prototype.GetZoom=function(){return this.oO.zoom},k.prototype.SetZoom=function(t){this.bU(),this.scale=null,this.oO.zoom=t,this.uSR(),this.eU()},k.prototype.getZoom=function(){var t=this.GetZoom(),e=this.getZoomLevels();return l(t)&&(t=100),S(e[0],v(e[e.length-1],t))},k.prototype.GetZoomLevels=function(){return this.oO.zoomLevels},k.prototype.SetZoomLevels=function(t){this.bU(),this.scale=null,this.oO.zoomLevels=t,this.uSR(),this.eU()},k.prototype.getZoomLevels=function(){var t=[100],e=new p.Arr;return d(this.GetZoomLevels(),"25,35,50,65,75,80,90,100,110,125,150,175,200,250,300,400,500").split(",").forEach(function(t){e.push(S(10,v(1e3,p.ToN(t,100))))}),e.isEmpty()||(t=e.byO()).sort(function(t,e){return t-e}),t},k.prototype.zoomOnWheel=function(t){var e=!1,o=p.WhelInc(t);if(o){var i=this.getZoomLevels(),n=100*this.getScale(),r=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:h(s)&&s.call(l,t)}},this)}},k.prototype.GetScrollBarsHome=function(){return this.oO.scrollBarsHome},k.prototype.SetScrollBarsHome=function(t){this.bU(),this.oO.scrollBarsHome=t,this.eU()},k.prototype.getScrollBarsHome=function(){var t=this.GetScrollBarsHome();return void 0===t&&(t="black"),t||null},k.prototype.GetScrollBarsLayout=function(){return this.oO.scrollBarsLayout},k.prototype.SetScrollBarsLayout=function(t){this.bU(),this.oO.scrollBarsLayout=t,this.eU()},k.prototype.getScrollBarsLayout=function(){var t=this.GetScrollBarsLayout();return void 0===t&&(t="black"),t||null},k.prototype.Soom=function(t,e,o){var i=h(t),n=h(e);if(i||n){o=o||this.rOrg();var r=100*this.getScale(),s=this.GetInsideRect(!0),l=this.ptCA(e,!1),a={x:s[0]+s[2]*o[0],y:s[1]+s[3]*o[1]};((i&=r!=t)||(n&=l.x!=a.x||l.y!=a.y))&&(p.A.Cancel("soom"),p.A.Progress(function(o){this.bU(),i&&this.SetZoom(r+(t-r)*o),n&&(l=this.ptCA(e,!1),this.rurScrollD((l.x-a.x)*o,(l.y-a.y)*o)),this.eU()},{name:"soom",thisArg:this,duration:this.getSmooth(),onXDoL:!1,transition:"swipe"}))}},k.prototype.Home=function(){this.Soom(100,[0,0])},k.prototype.FitToClient=function(t){function e(t,e){return{x:t[0]+t[2]*e[0],y:t[1]+t[3]*e[1]}}var o=l(t);if(t=t||this.Lyt().rtLyt,l(t))this.Home();else if(!p.EyR(t)){var i=this.GetInsideRect(!0),n=this.getScale(),r=v(i[2]/t[2],i[3]/t[3]),s=this.rOrg(),h=e(t,s);o&&r>n?r=null:r1),t.rgSel=null),r&&(t.rgSel=t.rgSel||new p.Arr).push(e)),i|=n!=t.isSelected(e);return i}var r=!1,s=!o&&(this.isToggleSel()||this.isToggleCtrlSel()&&2&this.oSelEv.modifier),a=this.valueToElements(t);i(a)?s?a.forEach(function(t){r|=n(this,t,s)},this):(r=!a.equal(this.rgSel))&&(this.isSingleSel()?n(this,a.last()):(this.rgSel=new p.Arr,a.forEach(function(t){this.isSable(t)&&this.rgSel.push(t)},this))):r=n(this,a,s),r&&(i(this.rgSel)&&0==this.rgSel.len()&&(this.rgSel=null),0==this.lI&&(void 0===e||e)&&this.invAO(),this.onSel())},k.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},k.prototype.onRurClick=function(t){this.EnsureVisibleClient(t)},k.prototype.onSel=function(){this.onselchange(this.GetSelection())},k.prototype.onselchange=function(t){this.oLts.onselchange.do(t)},k.prototype.onfocuslink=function(t){this.oLts.onfocuslink.do(t)},k.prototype.drawS=function(t,e){l(e)?this.drawO(t):(e?(this.drawO(t),this.drawL(t)):(this.drawL(t),this.drawO(t)),this.drawLCP(t))},k.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();(l(o)||o<0)&&(o=r.length);for(var s,h=e||0,a=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}))}},k.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}}},k.dGL=function(t,e,o,i){e&&p.ToI(e.width,1)&&(t.save(),h(e.width)&&(t.lineWidth=e.width),h(e.color)&&(t.strokeStyle=e.color),h(e.style)&&t.setLineDash(p.IsA(e.style)?e.style:[e.style]),h(e.cap)&&(t.lineCap=e.cap),h(e.join)&&(t.lineJoin=e.join),t.beginPath(),o.call(i,e),t.stroke(),t.restore())},k.prototype.drawA=function(t){if(this.getShowAxes()){var e=this.acTL();k.dGL(t,this.getAxes(),function(){var o=0,i=0;(o>=e.lA&&o=e.rA&&o=e.tA&&i=e.bA&&i1&&k.dGL(t,e,function(){for(t=f;t<=g;t+=p)c(h(t));for(var t=y;t<=d;t+=p)u(l(t))})}if(this.getShowGridLines()){var o=this.acTL(),i=o.lC,n=o.rC,r=o.tC,s=o.bC,h=o.x.bind(o),l=o.y.bind(o);!this.islow()&&e(this.getMinorGridLines()),e(this.getMajorGridLines())}},k.prototype.ftL=function(t){return this.ftcL(t)},k.prototype.ftDefLink=function(t){return t},k.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}},k.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,a,u=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(),m=c.getLink(),L=c.getCollapsedLink(),A=function(t,e){return e},E=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)&&(A=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&&(a=a||new Map).set(t,f.C2R(e,6,6))}var s=n.link,h=s.getCustomPath(),u=n.p||t,c=o&&s.rgCP;if(h&&(s.oSL.oFL==s&&s.oSL.oSV.orurDC==s&&(h=s.sCP(h)),u=s.cp2P(h,u[0],u[u.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&&k.lO(e,o)&&(i&=-13)),i}(y,(l=u)[0],l[l.length-1]),v=0,C=l.length;v1){for(var r=0;r<4;r++)t[r]=e(t[r]);t[2]=S(i,t[2]),t[3]=S(i,t[3])}return t}.call(this,p.HitTest.Resize(t,e,o,i,n))},k.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}},k.prototype.offP=function(t){return this.getPad()},k.prototype.onPaste=function(t){var e,i,n,r,s=t.e;o(s)&&(i=this.oSE.nextID(s.length),n=new Map,s.forEach(function(t,e){n.set(t.key,t.key=i[e])},this),s.forEach(function(t){h(t.parent)&&(t.parent=n.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),o(r=t.l)&&r.forEach(function(t,e){t.key=this.oSL.nextID(),t.from=n.get(t.from),t.to=n.get(t.to),this.oSL.Add(t)},this))},k.prototype.aCCP=function(){return p.EVis(this.GetCanvas())},k.prototype.Cut=function(){this.aCCP()&&(this.Copy(),this.RemoveSelection())},k.prototype.Copy=function(){if(this.aCCP()){var t=p.win.event,e=JSON.stringify(this.onCopy());r(t)?(p.SEP(t),t.clipboardData.setData("text/plain",e)):p.nav.clipboard.writeText(e)}},k.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)},D.prototype.UnionWith=function(t){var e=this.IntersectWith(t);return e&&(this.Start=v(this.Start,t.Start),this.End=S(this.End,t.End),this.Elements.push(t.Elements)),e},Object.addPrototypeOf(F.prototype,p.M1.prototype),F.prototype.isEmpty=function(){return 0==this.len()},F.prototype.MinX=function(){var t=null;return this.forEach(function(e){(!t||e[0]=i)},M.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)},M.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(a))<0&&(s=c);break;case 1:var f=p.ROf(l)-p.LOf(h);l[0]=a[0]=h[0],l[2]=f,a[2]=0,this.Intersect(l,i,u)&&(a=this.Union(u.rgO));var g=p.LOf(r)-p.ROf(a);g>0?s=g:(g=p.ROf(r)-p.LOf(a))<0&&(s=g)}if(s)switch(e){case 0:case 1:n=-s}}return n},M.prototype.Shift=function(t,e,o){var i=null;t.forEach(function(t){(i=this.get(t))&&p.ORt(i,e,o)},this)},M.orderElementRectByStart=function(t,e){return t.Start-e.Start},M.prototype.ToBlocks=function(t,e,o){var i=[];switch(t){case 0:this.forEach(function(t,o){e&&!e.has(o)||i.push(new D(o,p.LOf(t),p.ROf(t)))},this);break;case 1:this.forEach(function(t,o){e&&!e.has(o)||i.push(new D(o,p.TOf(t),p.BOf(t)))},this)}return n(o)&&i.sort(o),i},B.prototype.GetCache=function(t){return this.oSurfaceElementsArrange.Cache.GetCache(t)},B.ToVector=function(t,e,o){return t=t.slice(),n(e)&&t.sort(function(t,i){return e.call(o,t,i)}),t},B.prototype.orderElementByOutAll=function(t,e){return this.GetCache(e).OutAll.len()-this.GetCache(t).OutAll.len()},B.prototype.showTemp=function(t){t.forEach(function(t,e){t.Caption=""+e,t.Shape={normal:{fillColor:"rgba(255,0,0,0.5)"}}},this)},B.prototype.Init=function(){if(this.Input.clear(),!this.Elements.isEmpty()){this.Elements.forEach(function(t){this.GetCache(t).collectAll(this)},this);var t=B.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},B.prototype.PreArrange=function(){this.preArrange(this.Input,this.Loc),this.getArrangeCompact()&&this.compact(),this.getArrangeAlign()&&this.align(),this.optimize()},B.toRect=function(t,e){return[t[0],t[1],e.cx,e.cy]},B.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)})},B.prototype.getArrangeCount=function(t){var e=new p.Arr;return t.forEach(function(t){e.push(t,this.GetCache(t).OutAll)},this),e.len()},B.prototype.addElementGroup=function(t,e){e.add(t);var o=this.GetCache(t).Group;o&&e.push(o)},B.prototype.nextLoc=function(t,e){switch(this.getArrangeDir()){case 0:t[1]+=e.cy;break;case 1:t[0]+=e.cx}},B.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},B.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]}},B.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},B.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,B.toRect(o,i),e),this.nextLoc(o,i)}},this);var i=e.union();return{cx:i[2],cy:i[3]}},B.prototype.preArrange=function(t,e){e.clear();if(h(C=t.first())){var o=new p.Arr,i=new p.Arr;for(this.setArrangeLoc(C,B.toRect([0,0],this.Size.get(C)),e,o),C=t.next(C);C;C=t.next(C))this.setArrangeLoc(C,null,null,i);for(var n=this.getArrangeCount(o),r=0,s=n*(n-1),l=this.getArrangeDir(),a=!0;a;){a=!1;for(var u=0;u1){for(var l=[],s=0;sa.End){for(var c=new D(null,a.End,u.Start),n=s+1;n1&&this.rgArrangementCache.push(e.Init())}}},z.prototype.PreArrange=function(){this.rgArrangementCache.forEach(function(t){t.PreArrange()})},z.prototype.DoArrange=function(){this.rgArrangementCache.forEach(function(t){t.DoArrange()})},H.prototype.getArrangeDir=function(){return this.oDefArrange.dir||0},H.prototype.getArrangeDX=function(){return this.oDefArrange.dx||0},H.prototype.getArrangeDY=function(){return this.oDefArrange.dy||0},H.prototype.getArrangeAlign=function(){return h(this.oDefArrange.align)?~~this.oDefArrange.align:1},H.prototype.getArrangeCompact=function(){return this.oDefArrange.compact},H.prototype.onArranging=function(){this.Cache.ResetCache()},H.prototype.onArrange=function(){this.Cache.ResetCache()},H.prototype.Arrange=function(t){var e=null;-2&this.getArrangeDir()||!l(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},w),y.prototype),p.expO({Count:null},U.prototype),p.expO(p.Mrg({Options:null,Index:null},b),G.prototype),{DefArrange:E,DisplayLinkType:R,ElementOptions:w,LinkOptions:b,Elements:t,Element:y,Links:U,Link:G,SV:k,CSurfaceElementsArrange:H}}()),p.Mrg(p.Surface.SV,function(){function t(t){this.oSV=t,this.rgVO=new p.M1,this.mP2O=new Map,this.rtLyt=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,a){n.push(i,e((a=a||i.getClient()).slice()));var u,c,p,f=a[1]+(r?0:a[3]),g=i.getVisibleChild();return l>0&&(g||i.hasVisibleChild())&&n.set(i.getExpandGlyph(),e(t.expandGlyphRect(a,l))),g&&(u=a[0]+s,g.forEach(function(t){c=(p=t.getClient())[3],f=o(t,t.oO.client=[u,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