/*
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 t from"../../../core/Accessor.js";import{difference as r}from"../../../core/arrayUtils.js";import o from"../../../core/Collection.js";import i from"../../../core/Logger.js";import{property as a,subclass as n}from"../../../core/accessorSupport/decorators.js";import s from"./FeatureSnappingLayerSource.js";import{defaults as l}from"./Settings.js";let u=class extends t{constructor(e){super(e),this.enabled=!1,this.enabledToggled=!1,this.forceDisabled=!1,this.selfEnabled=!0,this.featureEnabled=!0,this.gridEnabled=!1,this.attributeRulesEnabled=!1,this.featureSources=new o,this.distance=l.distance,this.touchSensitivityMultiplier=l.touchSensitivityMultiplier}get effectiveEnabled(){return!this.forceDisabled&&(this.enabledToggled?!this.enabled:this.enabled)}get effectiveGridEnabled(){return this.effectiveEnabled&&this.gridEnabled}get effectiveSelfEnabled(){return this.effectiveEnabled&&this.selfEnabled}get effectiveFeatureEnabled(){return this.effectiveEnabled&&this.featureEnabled}get _effectiveFeatureSources(){const e=this.featureSources;e.some(d)&&i.getLogger(this).warnOnce("Do not configure SubtypeGroupLayer sources in SnappingOptions.featureSources directly. Create a FeatureSnappingLayerSource for each SubtypeSublayer.");const t=e.filter(p),a=this._get("_effectiveFeatureSources")?.filter(d)??new o;for(const r of t){const e=a.find(e=>e.layer===r.layer.parent);if(e)e.sublayerSources.includes(r)||e.sublayerSources.add(r);else if(r.layer.parent){const e=new s({layer:r.layer.parent});e.sublayerSources.add(r),a.add(e)}}for(const r of a){const e=r.sublayerSources.filter(e=>!t.includes(e));r.sublayerSources.removeMany(e)}a.removeMany(a.filter(e=>0===e.sublayerSources.length));const n=e.filter(c),l=this._get("_effectiveFeatureSources")??new o,{added:u,removed:f}=r(l.toArray(),[...n,...a]);return l.removeMany(f),l.addMany(u),l}};function d(e){return"subtype-group"===e.layer.type}function c(e){return"subtype-group"!==e.layer.type}function p(e){return"subtype-sublayer"===e.layer.type}e([a()],u.prototype,"enabled",void 0),e([a()],u.prototype,"enabledToggled",void 0),e([a()],u.prototype,"forceDisabled",void 0),e([a()],u.prototype,"selfEnabled",void 0),e([a()],u.prototype,"featureEnabled",void 0),e([a()],u.prototype,"gridEnabled",void 0),e([a()],u.prototype,"attributeRulesEnabled",void 0),e([a({type:o.ofType(s)})],u.prototype,"featureSources",void 0),e([a()],u.prototype,"distance",void 0),e([a()],u.prototype,"touchSensitivityMultiplier",void 0),e([a({readOnly:!0})],u.prototype,"effectiveEnabled",null),e([a({readOnly:!0})],u.prototype,"effectiveGridEnabled",null),e([a({readOnly:!0})],u.prototype,"effectiveSelfEnabled",null),e([a({readOnly:!0})],u.prototype,"effectiveFeatureEnabled",null),e([a({readOnly:!0})],u.prototype,"_effectiveFeatureSources",null),u=e([n("esri.views.interactive.snapping.SnappingOptions")],u);export{u as default};
