/*
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/4.24/esri/copyright.txt for details.
*/
define(["../chunks/_rollupPluginBabelHelpers","../chunks/tslib.es6","./Analysis","./LineOfSightAnalysisObserver","./LineOfSightAnalysisTarget","../core/Collection","../core/collectionUtils","../core/maybe","../core/reactiveUtils","../core/accessorSupport/decorators/property","../core/arrayUtils","../core/has","../core/accessorSupport/ensureType","../core/accessorSupport/decorators/subclass","../geometry/projection","../geometry/support/aaBoundingBox","../support/elevationInfoUtils"],(function(e,t,o,r,n,i,s,a,l,p,c,u,y,d,g,f,h){"use strict";const v=i.ofType(n);let _=function(t){function o(e){var o;return(o=t.call(this,e)||this).type="line-of-sight",o.observer=null,o.extent=null,o.nonEditableMessage="Assign an observer location to the analysis to allow editing.",o}e._inheritsLoose(o,t);var r=o.prototype;return r.initialize=function(){this.own(l.watch((()=>this._computeExtent()),(e=>{(a.isNone(e)||a.isNone(e.pending))&&this._set("extent",a.isSome(e)?e.extent:null)}),l.syncAndInitial))},r.waitComputeExtent=function(){var t=e._asyncToGenerator((function*(){const e=this._computeExtent();return a.isSome(e)?a.unwrap(e.pending):null}));function o(){return t.apply(this,arguments)}return o}(),r._computeExtent=function(){const e=this.spatialReference;if(a.isNone(this.observer)||a.isNone(this.observer.position)||a.isNone(e))return null;const t=e=>"absolute-height"===h.getGeometryEffectiveElevationMode(e.position,e.elevationInfo),o=this.observer.position,r=f.fromValues(o.x,o.y,o.z,o.x,o.y,o.z);for(const i of this.targets)if(a.isSome(i.position)){const t=g.projectOrLoad(i.position,e);if(a.isSome(t.pending))return{pending:t.pending,extent:null};if(a.isSome(t.geometry)){const{x:e,y:o,z:n}=t.geometry;f.expandWithVec3(r,[e,o,n])}}const n=f.toExtent(r,e);return t(this.observer)&&this.targets.every(t)||(n.zmin=null,n.zmax=null),{pending:null,extent:n}},r.clear=function(){this.observer=null,this.targets.removeAll()},e._createClass(o,[{key:"targets",get:function(){return this._get("targets")||new v},set:function(e){this._set("targets",s.referenceSetter(e,this.targets,v))}},{key:"spatialReference",get:function(){return a.isSome(this.observer)&&a.isSome(this.observer.position)?this.observer.position.spatialReference:null}},{key:"requiredPropertiesForEditing",get:function(){return[a.applySome(this.observer,(e=>e.position))]}}]),o}(o);t.__decorate([p.property({type:["line-of-sight"]})],_.prototype,"type",void 0),t.__decorate([p.property({type:r,json:{read:!0,write:!0}})],_.prototype,"observer",void 0),t.__decorate([p.property({cast:s.castForReferenceSetter,type:v,nonNullable:!0,json:{read:!0,write:!0}})],_.prototype,"targets",null),t.__decorate([p.property({value:null,readOnly:!0})],_.prototype,"extent",void 0),t.__decorate([p.property({readOnly:!0})],_.prototype,"spatialReference",null),t.__decorate([p.property({readOnly:!0})],_.prototype,"requiredPropertiesForEditing",null),t.__decorate([p.property({readOnly:!0})],_.prototype,"nonEditableMessage",void 0),_=t.__decorate([d.subclass("esri.analysis.LineOfSightAnalysis")],_);return _}));
