/*
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/HandleOwner","../../../../core/handleUtils","../../../../core/maybe","../../../../core/accessorSupport/decorators/property","../../../../core/arrayUtils","../../../../core/has","../../../../core/accessorSupport/ensureType","../../../../core/accessorSupport/decorators/subclass","../../../3d/webgl-engine/lib/edgeRendering/EdgeWorkerHandle","./sceneLayerSource/SceneLayerSnappingSourceWorkerHandle"],(function(e,r,n,t,o,a,i,s,c,d,l,u,p){"use strict";e.SceneLayerSnappingSource=function(e){function n(r){var n;return(n=e.call(this,r)||this).availability=1,n.abortController=new AbortController,n}r._inheritsLoose(n,e);var t=n.prototype;return t.destroy=function(){this.abortController=a.abortMaybe(this.abortController)},t.initialize=function(){var e=this;const n=this.view.resourceController;var t;this.edgeWorker=new u((e=>n.schedule(e))),this.workerHandle=new p.SceneLayerSnappingSourceWorkerHandle({view:this.view,schedule:e=>n.schedule(e),fetchEdgeLocations:(t=r._asyncToGenerator((function*(r,n){if(a.isNone(e.tracker))throw new Error("tracker-not-initialized");return e.tracker.fetchEdgeLocations(r,e.edgeWorker,n)})),function(e,r){return t.apply(this,arguments)})}),this.updatingHandles.addPromise(this._setupLayerView()),this.handles.add([o.destroyHandle(this.workerHandle),o.destroyHandle(this.edgeWorker)])},t.fetchCandidates=function(){var e=r._asyncToGenerator((function*(e,r){return this.workerHandle.fetchCandidates(e,r)}));function n(r,n){return e.apply(this,arguments)}return n}(),t.refresh=function(){},t._setupLayerView=function(){var e=r._asyncToGenerator((function*(){const e=yield this.view.whenLayerView(this.layer);if("scene-layer-graphics-3d"===e.type)return;const r={add:(e,r)=>this.updatingHandles.addPromise(this.workerHandle.add({id:e,bounds:r},this.abortController.signal)),remove:e=>this.updatingHandles.addPromise(this.workerHandle.remove({id:e},this.abortController.signal))};this.tracker=e.trackSnappingSources(r),this.handles.add(this.tracker)}));function n(){return e.apply(this,arguments)}return n}(),r._createClass(n,[{key:"updating",get:function(){return this.updatingHandles.updating}},{key:"layer",get:function(){return this.layerSource.layer}}]),n}(t.HandleOwner),n.__decorate([i.property({constructOnly:!0})],e.SceneLayerSnappingSource.prototype,"layerSource",void 0),n.__decorate([i.property({constructOnly:!0})],e.SceneLayerSnappingSource.prototype,"view",void 0),n.__decorate([i.property({readOnly:!0})],e.SceneLayerSnappingSource.prototype,"updating",null),n.__decorate([i.property({readOnly:!0})],e.SceneLayerSnappingSource.prototype,"availability",void 0),e.SceneLayerSnappingSource=n.__decorate([l.subclass("esri.views.interactive.snapping.featureSources.SceneLayerSnappingSource")],e.SceneLayerSnappingSource),Object.defineProperties(e,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
