/*
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/4.24/esri/copyright.txt for details.
*/
define(["exports","../../../chunks/_rollupPluginBabelHelpers","../../../chunks/tslib.es6","../../../core/Accessor","../../../core/maybe","../../../core/promiseUtils","../../../core/accessorSupport/decorators/property","../../../core/arrayUtils","../../../core/has","../../../core/accessorSupport/ensureType","../../../core/accessorSupport/decorators/subclass","../../support/Scheduler"],(function(e,t,r,o,n,a,s,i,p,l,c,u){"use strict";e.SnappingOperation=function(e){function r(r){var o;return(o=e.call(this,r)||this).stagedPoint=null,o._abortController=null,o._snap=a.debounce(function(){var e=t._asyncToGenerator((function*(e,t,r,n){const a=yield o._frameTask.schedule((()=>t.snap(e,r,n)),n);a.valid&&(yield o._frameTask.schedule((()=>{o.stagedPoint=a.apply(),e!==o._snapMapPoint&&(o.stagedPoint=t.update(o._snapMapPoint,r))}),n))}));return function(t,r,o,n){return e.apply(this,arguments)}}()),o}t._inheritsLoose(r,e);var o=r.prototype;return o.initialize=function(){var e,t;const r="3d"===this.view.type?null==(e=this.view)||null==(t=e.resourceController)?void 0:t.scheduler:null;this._frameTask=n.isSome(r)?r.registerTask(u.TaskPriority.SNAPPING):u.ImmediateTask},o.destroy=function(){this._abortController=n.abortMaybe(this._abortController),this._frameTask=n.removeMaybe(this._frameTask)},o.snap=function(){var e=t._asyncToGenerator((function*(e,t,r){return this.stagedPoint=t.update(e,r),this._snapMapPoint=e,n.isNone(this._abortController)&&(this._abortController=new AbortController),this._snap(e,t,r,this._abortController.signal)}));function r(t,r,o){return e.apply(this,arguments)}return r}(),o.abort=function(){this._abortController=n.abortMaybe(this._abortController)},r}(o),r.__decorate([s.property({constructOnly:!0})],e.SnappingOperation.prototype,"view",void 0),r.__decorate([s.property()],e.SnappingOperation.prototype,"stagedPoint",void 0),e.SnappingOperation=r.__decorate([c.subclass("esri.views.interactive.snapping.SnappingOperation")],e.SnappingOperation),Object.defineProperties(e,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
