Uint8Array.prototype.slice||Object.defineProperty(Uint8Array.prototype,"slice",{value:function(e,t){return new Uint8Array(Array.prototype.slice.call(this,e,t))}});var CreateAgentRemoteDesktop=function(e,t){var d={};"string"==typeof(d.CanvasId=e)&&(d.CanvasId=Q(e)),d.Canvas=d.CanvasId.getContext("2d"),d.scrolldiv=t,d.State=0,d.PendingOperations=[],d.tilesReceived=0,d.TilesDrawn=0,d.KillDraw=0,d.ipad=!1,d.tabletKeyboardVisible=!1,d.LastX=0,d.LastY=0,d.touchenabled=0,d.submenuoffset=0,d.touchtimer=null,d.TouchArray={},d.connectmode=0,d.connectioncount=0,d.rotation=0,d.protocol=2,d.debugmode=0,d.firstUpKeys=[],d.stopInput=!1,d.localKeyMap=!0,d.remoteKeyMap=!1,d.pressedKeys=[],d.sessionid=0,d.username,d.oldie=!1,d.CompressionLevel=50,d.ScalingLevel=1024,d.FrameRateTimer=100,d.SwapMouse=!1,d.FirstDraw=!1,d.ScreenWidth=960,d.ScreenHeight=701,d.width=960,d.height=960,d.displays=null,d.selectedDisplay=null,d.onScreenSizeChange=null,d.onMessage=null,d.onConnectCountChanged=null,d.onDebugMessage=null,d.onTouchEnabledChanged=null,d.onDisplayinfo=null;var h=!(d.accumulator=null),g="default";d.mouseCursorActive=function(e){h!=e&&(h=e,d.CanvasId.style.cursor=1==e?g:"default")};var p=["default","progress","crosshair","pointer","help","text","no-drop","move","nesw-resize","ns-resize","nwse-resize","w-resize","alias","wait","none","not-allowed","col-resize","row-resize","copy","zoom-in","zoom-out"];d.Start=function(){d.State=0,d.accumulator=null},d.Stop=function(){d.setRotation(0),d.UnGrabKeyInput(),d.UnGrabMouseInput(),d.touchenabled=0,null!=d.onScreenSizeChange&&d.onScreenSizeChange(d,d.ScreenWidth,d.ScreenHeight,d.CanvasId),d.Canvas.clearRect(0,0,d.CanvasId.width,d.CanvasId.height)},d.xxStateChange=function(e){d.State!=e&&(d.State=e,d.CanvasId.style.cursor="default",0===e&&d.Stop())},d.send=function(e){2>32)+d.intToStr(32&o)):(d.recordedSize+=n.length,d.shortToStr(e)+d.shortToStr(t)+d.intToStr(n.length)+d.intToStr(o>>32)+d.intToStr(32&o)+n)}return d.SendKeyMsg=function(e,t){var n;null!=e&&((t=t||window.event).code&&0==d.localKeyMap?null!=(n=(n=t).code.startsWith("Key")&&4==n.code.length?n.code.charCodeAt(3):n.code.startsWith("Digit")&&6==n.code.length?n.code.charCodeAt(5):n.code.startsWith("Numpad")&&7==n.code.length?n.code.charCodeAt(6)+48:o[n.code])&&d.SendKeyMsgKC(e,n):(59==(n=t.keyCode)?n=186:173==n?n=189:61==n&&(n=187),d.SendKeyMsgKC(e,n)))},d.SendMessage=function(e){3==d.State&&d.send(String.fromCharCode(0,17)+d.shortToStr(4+e.length)+e)},d.SendKeyMsgKC=function(e,t){if(3==d.State)if("object"==typeof e)for(var n in e)d.SendKeyMsgKC(e[n][0],e[n][1]);else 1==e?-1==d.pressedKeys.indexOf(t)&&d.pressedKeys.unshift(t):2==e&&-1!=(n=d.pressedKeys.indexOf(t))&&d.pressedKeys.splice(n,1),0>8),255-(255&Math.abs(r))):(s=r>>8,255&r),String.fromCharCode(0,d.InputType.MOUSE,0,12,0,0,n/256&255,255&n,o/256&255,255&o,s,t)):String.fromCharCode(0,d.InputType.MOUSE,0,10,0,e==d.KeyAction.DOWN?a:2*a&255,n/256&255,255&n,o/256&255,255&o),d.Action==d.KeyAction.NONE?0==d.Alternate||d.ipad?(d.send(i),d.Alternate=1):d.Alternate=0:d.send(i)))},d.GetDisplayNumbers=function(){d.send(String.fromCharCode(0,11,0,4))},d.SetDisplay=function(e){d.send(String.fromCharCode(0,12,0,6,e>>8,255&e))},d.intToStr=function(e){return String.fromCharCode(e>>24&255,e>>16&255,e>>8&255,255&e)},d.shortToStr=function(e){return String.fromCharCode(e>>8&255,255&e)},d.onResize=function(){0!=d.ScreenWidth&&0!=d.ScreenHeight&&(d.Canvas.canvas.width==d.ScreenWidth&&d.Canvas.canvas.height==d.ScreenHeight||(d.FirstDraw&&(d.Canvas.canvas.width=d.ScreenWidth,d.Canvas.canvas.height=d.ScreenHeight,d.Canvas.fillRect(0,0,d.ScreenWidth,d.ScreenHeight),null!=d.onScreenSizeChange&&d.onScreenSizeChange(d,d.ScreenWidth,d.ScreenHeight,d.CanvasId)),d.FirstDraw=!1,1