/* COPYRIGHT Esri - https://js.arcgis.com/5.0.18/LICENSE.txt */
import{__decorate as e}from"tslib";import{isSome as r}from"../../../core/arrayUtils.js";import t from"../../../core/Collection.js";import{property as i,subclass as n}from"../../../core/accessorSupport/decorators.js";import o from"../../LayerList/ListItem.js";import{canDisplayLayer as s}from"../../LayerList/support/layerListUtils.js";import{isValidSnappingLayer as a}from"./snappingLayerListUtils.js";var l;let p=l=class extends o{constructor(e){super(e),this.children=new t,this.parent=null}get enabled(){const{children:e}=this;if(0===e.length)return null!=this.featureSource&&this.featureSource.enabled?"enabled":"disabled";let r=!1,t=!1;for(const i of e){if("indeterminate"===i.enabled)return i.enabled;if("enabled"===i.enabled?r=!0:"disabled"===i.enabled&&(t=!0),t&&r)return"indeterminate"}return t?"disabled":"enabled"}get childLayerIds(){return this.children.toArray().flatMap(e=>[e.layer?.id,...e.childLayerIds])}get featureSource(){const{layer:e,getFeatureSnappingSources:r}=this;return r().find(r=>r.layer===e)}_initializeChildLayers(e){if(!e)return;const r=e.filter(a);super._initializeChildLayers(r)}_createChildItems(e){return e.map(e=>s(e)?new l({layer:e,parent:this,view:this.view,getFeatureSnappingSources:this.getFeatureSnappingSources}):null).filter(r).reverse()}};e([i()],p.prototype,"enabled",null),e([i()],p.prototype,"children",void 0),e([i()],p.prototype,"childLayerIds",null),e([i()],p.prototype,"featureSource",null),e([i({constructOnly:!0})],p.prototype,"getFeatureSnappingSources",void 0),e([i()],p.prototype,"parent",void 0),p=l=e([n("esri.widgets.support.SnappingControls.SnappingListItem")],p);export{p as SnappingListItem};
