/*
All material copyright Esri, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/5.0/esri/copyright.txt for details.
*/
import{__decorate as e}from"tslib";import r from"../../../../core/Accessor.js";import{isSome as t}from"../../../../core/arrayUtils.js";import{throwIfAborted as i}from"../../../../core/promiseUtils.js";import{property as s,subclass as o}from"../../../../core/accessorSupport/decorators.js";import{I3SSnappingSource as a}from"./I3SSnappingSource.js";let n=class extends r{get updating(){return this._i3sSources.some(e=>e.updating)}constructor(e){super(e),this.availability=1,this._i3sSources=[]}destroy(){this._i3sSources.forEach(e=>e.destroy()),this._i3sSources.length=0}initialize(){const{view:e}=this,r=this.layerSource.layer;this._i3sSources="building-scene"===r.type?this._getBuildingSceneI3SSources(e,r):[this._getSceneLayerI3SSource(e,r)]}async fetchCandidates(e,r){const t=await Promise.all(this._i3sSources.map(t=>t.fetchCandidates(e,r)));return i(r),t.flat()}refresh(){this._i3sSources.forEach(e=>e.refresh())}_getBuildingSceneI3SSources(e,r){return r.allSublayers.toArray().map(t=>"building-component"===t.type?new a({getLayerView:async()=>(await e.whenLayerView(r)).whenSublayerView(t),view:e}):null).filter(t)}_getSceneLayerI3SSource(e,r){return new a({getLayerView:async()=>{const t=await e.whenLayerView(r);return"scene-layer-graphics-3d"===t.type?void 0:t},view:e})}};e([s({constructOnly:!0})],n.prototype,"layerSource",void 0),e([s({constructOnly:!0})],n.prototype,"view",void 0),e([s({readOnly:!0})],n.prototype,"updating",null),e([s({readOnly:!0})],n.prototype,"availability",void 0),n=e([o("esri.views.interactive.snapping.featureSources.SceneLayerSnappingSource")],n);export{n as SceneLayerSnappingSource};
