/*
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/4.24/esri/copyright.txt for details.
*/
define(["require","../../chunks/_rollupPluginBabelHelpers","../../chunks/tslib.es6","../../core/Logger","../../core/maybe","../../core/reactiveUtils","../../core/accessorSupport/decorators/property","../../core/arrayUtils","../../core/has","../../core/accessorSupport/ensureType","../../core/accessorSupport/interfaces","../../core/accessorSupport/tracking","../../core/accessorSupport/extensions/serializableProperty/reader","../../core/accessorSupport/extensions/serializableProperty/writer","../../geometry/projection","./LayerView"],(function(e,r,t,o,n,i,l,s,a,c,p,u,y,g,m,d){"use strict";const f=o.getLogger("esri.views.layers.SceneLayerView");let h=function(t){function o(){var e;return(e=t.apply(this,arguments)||this).layer=null,e.filter=null,e._geometryEngine=null,e._projectionEngineLoaded=!1,e}r._inheritsLoose(o,t);var l=o.prototype;return l.initialize=function(){var t=this;i.whenOnce((()=>!this._geometryEngine&&n.isSome(this.layer.filter)&&this.layer.filter.geometries.length)).then(r._asyncToGenerator((function*(){return t._geometryEngine=yield new Promise(((r,t)=>e(["../../geometry/geometryEngine"],r,t)))}))),this._projectionEngineLoaded=m.isLoaded(),i.whenOnce((()=>!this._projectionEngineLoaded&&this._filterNeedsProjectionEngine)).then(r._asyncToGenerator((function*(){yield m.load(),t._projectionEngineLoaded=!0})))},l.highlight=function(e){throw new Error("Not implemented")},l.queryFeatures=function(e,r){throw new Error("Not implemented")},l.queryObjectIds=function(e,r){throw new Error("Not implemented")},l.queryFeatureCount=function(e,r){throw new Error("Not implemented")},l.createQuery=function(){throw new Error("Not implemented")},l.queryExtent=function(e,r){throw new Error("Not implemented")},r._createClass(o,[{key:"availableFields",get:function(){return[]}},{key:"maximumNumberOfFeatures",get:function(){return 0},set:function(e){throw new Error("Not implemented")}},{key:"maximumNumberOfFeaturesExceeded",get:function(){return!1}},{key:"layerFilter",get:function(){const e=this.layer.filter;if(n.isNone(e)||e.geometries.length<1)return null;const r=this._geometryEngine;if(n.isNone(r)||!this._projectionEngineLoaded&&this._filterNeedsProjectionEngine)return null;try{let t=r.simplify(e.geometries.getItemAt(0));const o=t.spatialReference;for(let n=1;n<e.geometries.length;n++){let i=r.simplify(e.geometries.getItemAt(n));i.spatialReference.equals(o)||(i=m.project(i,o)),t=r.union(t,i)}return{spatialRelationship:e.spatialRelationship,geometry:t}}catch{return f.warnOncePerTick("Failed to merge scene filter geometries. Layer mask will be ignored."),null}}},{key:"_filterNeedsProjectionEngine",get:function(){const e=this.layer.filter;if(n.isNone(e)||e.geometries.length<=1)return!1;const r=e.geometries.getItemAt(0).spatialReference;return e.geometries.some((({spatialReference:e})=>!e.equals(r)&&!m.canProjectWithoutEngine(e,r)))}},{key:"layerFilterUpdating",get:function(){return n.isSome(this.layer.filter)&&this.layer.filter.geometries.length&&(!this._geometryEngine||!this._projectionEngineLoaded&&this._filterNeedsProjectionEngine)}}]),o}(d);return t.__decorate([l.property()],h.prototype,"layer",void 0),t.__decorate([l.property()],h.prototype,"availableFields",null),t.__decorate([l.property()],h.prototype,"maximumNumberOfFeatures",null),t.__decorate([l.property({readOnly:!0})],h.prototype,"maximumNumberOfFeaturesExceeded",null),t.__decorate([l.property()],h.prototype,"filter",void 0),t.__decorate([l.property({readOnly:!0})],h.prototype,"layerFilter",null),t.__decorate([l.property()],h.prototype,"_geometryEngine",void 0),t.__decorate([l.property()],h.prototype,"_projectionEngineLoaded",void 0),t.__decorate([l.property()],h.prototype,"_filterNeedsProjectionEngine",null),t.__decorate([l.property()],h.prototype,"layerFilterUpdating",null),h}));
