/* COPYRIGHT Esri - https://js.arcgis.com/5.0/LICENSE.txt */
import{__decorate as t}from"tslib";import e from"../../../../core/Accessor.js";import{property as s,subclass as i}from"../../../../core/accessorSupport/decorators.js";import{ExtentSet as r}from"../graphics/ExtentSet.js";import{TaskPriority as o}from"../../../support/Scheduler.js";let n=class extends e{constructor(t,e,s,i){super({}),this._updateExtent=e,this._updateNode=s,this._getElevationMode=i,this.readyToRun=!1,this._extentSet=new r,this._nodeSet=new Set;const o=this._taskPriority,n=t.registerTask(this._taskPriority,this);this.addHandles(n),this._task=n,this._lastTaskPriority=o}destroy(){this._extentSet.destroy()}get _taskPriority(){const t=this._getElevationMode();return t&&1===t?o.ELEVATION_ALIGNMENT_SCENE:o.ELEVATION_ALIGNMENT}_updateTaskPriority(){const t=this._taskPriority;t!==this._lastTaskPriority&&(this._task.priority=t,this._lastTaskPriority=t)}addExtent(t){this._extentSet.add(t),this._updateTaskPriority(),this.readyToRun=!0}schedule(t){this._nodeSet.add(t),this._updateTaskPriority(),this.readyToRun=!0}remove(t){this._nodeSet.delete(t),this._updateRunning()}runTask(t){const e=this._extentSet;for(t.run(()=>e.merge(t));!e.empty&&!t.done;){const s=this._updateExtent(e.pop());null!=s&&s.forAll(t=>this.schedule(t)),t.madeProgress()}if(t.done)return;const s=this._nodeSet;for(const i of s)if(s.delete(i),this._updateNode(i),t.madeProgress(),t.done)break;this._updateRunning()}_updateRunning(){this.readyToRun=this._nodeSet.size>0||this._extentSet.size>0}};t([s()],n.prototype,"readyToRun",void 0),n=t([i("esri.views.3d.layers.i3s.I3SAsyncElevationUpdater")],n);export{n as I3SAsyncElevationUpdater};
