/*
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/4.24/esri/copyright.txt for details.
*/
define(["../../../chunks/_rollupPluginBabelHelpers","../../../chunks/tslib.es6","../../../core/Accessor","../../../core/Handles","../../../core/reactiveUtils","../../../core/accessorSupport/decorators/property","../../../core/arrayUtils","../../../core/has","../../../core/accessorSupport/ensureType","../../../core/accessorSupport/decorators/subclass","./handlers/DoubleClickZoom","./handlers/DoubleTapDragZoom","./handlers/DragPan","./handlers/DragRotate","./handlers/GamepadNavigation","./handlers/KeyPan","./handlers/KeyRotate","./handlers/KeyZoom","./handlers/MouseWheelZoom","./handlers/PinchAction","../../input/BrowserEventSource","../../input/InputManager","../../input/handlers/PreventContextMenu","../../input/recognizers/DoubleTapDrag","../../input/recognizers/Drag","../../input/recognizers/ImmediateDoubleClick","../../input/recognizers/PointerClickHoldAndDrag","../../input/recognizers/SingleAndDoubleClick"],(function(e,n,t,o,i,r,s,a,c,l,u,h,p,w,d,v,g,_,y,D,m,P,b,k,M,A,C,f){"use strict";const T={counter:"Ctrl",pan:{left:"ArrowLeft",right:"ArrowRight",up:"ArrowUp",down:"ArrowDown"},zoom:{zoomIn:["=","+"],zoomOut:["-","_"]},rotate:{clockwiseOption1:"a",clockwiseOption2:"A",counterClockwiseOption1:"d",counterClockwiseOption2:"D",resetOption1:"n",resetOption2:"N"}};let z=function(n){function t(){var e;return(e=n.apply(this,arguments)||this)._handles=new o,e}e._inheritsLoose(t,n);var r=t.prototype;return r.initialize=function(){const e=()=>{var e;return null==(e=this.view)?void 0:e.ready};this._handles.add([i.when((()=>!e()),(()=>this._disconnect())),i.when(e,(()=>this._connect()))])},r.destroy=function(){this._handles&&(this._handles.removeAll(),this._handles=null),this._disconnect()},r._disconnect=function(){this._inputManager&&(this.view.viewEvents.disconnect(),this._inputManager.destroy(),this._inputManager=null,this._source.destroy(),this._source=null)},r._connect=function(){const e=this.view.surface,n=new m.BrowserEventSource(e,this.view.input),t=[new A.ImmediateDoubleClick,new C.PointerClickHoldAndDrag,new f.SingleAndDoubleClick,new M.Drag(this.view.navigation),new k.DoubleTapDrag],o=new P.InputManager({eventSource:n,recognizers:t});o.installHandlers("prevent-context-menu",[new b.PreventContextMenu],P.ViewEventPriorities.INTERNAL),o.installHandlers("navigation",[new D.PinchRotateAndZoom(this.view),new d.GamepadNavigation(this.view),new y.MouseWheelZoom(this.view),new u.DoubleClickZoom(this.view),new u.DoubleClickZoom(this.view,[T.counter]),new p.DragPan(this.view,"primary"),new v.KeyPan(this.view,T.pan),new _.KeyZoom(this.view,T.zoom),new g.KeyRotate(this.view,T.rotate),new w.DragRotate(this.view,"secondary"),new h.DoubleTapDragZoom(this.view,"touch")],P.ViewEventPriorities.INTERNAL),this.view.viewEvents.connect(o),this._source=n,this._inputManager=o,i.watch((()=>{var e,n;return null==(e=this.view)||null==(n=e.navigation)?void 0:n.browserTouchPanEnabled}),(e=>{this._source&&(this._source.browserTouchPanningEnabled=!e)}),i.initial)},e._createClass(t,[{key:"latestPointerType",get:function(){var e;return null==(e=this._inputManager)?void 0:e.latestPointerType}},{key:"latestPointerLocation",get:function(){var e;return null==(e=this._inputManager)?void 0:e.latestPointerLocation}},{key:"test",get:function(){return{inputManager:this._inputManager}}}]),t}(t);n.__decorate([r.property()],z.prototype,"view",void 0),n.__decorate([r.property()],z.prototype,"latestPointerType",null),n.__decorate([r.property()],z.prototype,"latestPointerLocation",null),z=n.__decorate([l.subclass("esri.views.2d.input.MapViewInputManager")],z);return z}));
