/*
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","../../../../geometry","../../../../Viewpoint","../../../../core/Accessor","../../../../core/reactiveUtils","../../../../core/screenUtils","../../../../core/accessorSupport/decorators/property","../../../../core/arrayUtils","../../../../core/has","../../../../core/accessorSupport/ensureType","../../../../core/accessorSupport/decorators/subclass","../../../../chunks/vec3","../../../../chunks/vec3f64","../../viewpointUtils","../../../navigation/PanPlanarMomentumEstimator","../../../../geometry/Point"],(function(t,e,i,n,o,s,m,a,r,u,c,h,p,l,d,v,g){"use strict";let y=function(e){function i(t){var i;return(i=e.call(this,t)||this).animationTime=0,i.momentumEstimator=new v.PanPlanarMomentumEstimator(500,6,.92),i.momentum=null,i.tmpMomentum=l.create(),i.momentumFinished=!1,i.viewpoint=new n({targetGeometry:new g,scale:0,rotation:0}),s.when((()=>i.momentumFinished),(()=>i.navigation.stop())),i}t._inheritsLoose(i,e);var o=i.prototype;return o.begin=function(t,e){this.navigation.begin(),this.momentumEstimator.reset(),this.addToEstimator(e),this.previousDrag=e},o.update=function(t,e){this.addToEstimator(e);let i=e.center.x,n=e.center.y;const o=this.previousDrag;i=o?o.center.x-i:-i,n=o?n-o.center.y:n,t.viewpoint=d.translateBy(this.viewpoint,t.viewpoint,[i||0,n||0]),this.previousDrag=e},o.end=function(t,e){this.addToEstimator(e);const i=t.navigation.momentumEnabled;this.momentum=i?this.momentumEstimator.evaluateMomentum():null,this.animationTime=0,this.momentum&&this.onAnimationUpdate(t),this.previousDrag=null,this.navigation.end()},o.addToEstimator=function(t){const e=t.center.x,i=t.center.y,n=m.createScreenPointArray(-e,i),o=l.fromValues(-e,i,0);this.momentumEstimator.add(n,o,.001*t.timestamp)},o.onAnimationUpdate=function(t){this.navigation.animationManager.animateContinous(t.viewpoint,((e,i)=>{this.momentumFinished=!this.momentum||this.momentum.isFinished(this.animationTime);const n=.001*i;if(!this.momentumFinished){const i=this.momentum.valueDelta(this.animationTime,n);p.scale(this.tmpMomentum,this.momentum.direction,i),d.translateBy(e,e,this.tmpMomentum),t.constraints.constrainByGeometry(e)}this.animationTime+=n}))},o.stopMomentumNavigation=function(){this.momentum&&(this.momentumEstimator.reset(),this.momentum=null,this.navigation.stop())},i}(o);e.__decorate([a.property()],y.prototype,"momentumFinished",void 0),e.__decorate([a.property()],y.prototype,"viewpoint",void 0),e.__decorate([a.property()],y.prototype,"navigation",void 0),y=e.__decorate([h.subclass("esri.views.2d.navigation.actions.Pan")],y);return y}));
