/* COPYRIGHT Esri - https://js.arcgis.com/5.1.0/LICENSE.txt */
import{__decorate as e}from"tslib";import t from"../../core/Error.js";import{throwIfAborted as r}from"../../core/promiseUtils.js";import{property as s}from"../../core/accessorSupport/decorators.js";import o from"../../geometry/Point.js";import{load as i,getSourceScale as a}from"../../layers/raster/functions/rasterProjectionHelper.js";import p from"../../layers/support/FieldsIndex.js";import{rasterFieldPrefix as n}from"../../layers/support/rasterFieldUtils.js";import{combineTimeExtent as l}from"../../layers/support/timeSupport.js";import m from"../../rest/support/Query.js";import u from"./LayerView.js";import{getFetchPopupTemplate as c}from"./support/popupUtils.js";class y extends u{constructor(...e){super(...e),this.view=null}get timeExtent(){return l(this.layer,this.view?.timeExtent,this._get("timeExtent"))}async fetchPopupFeaturesAtTarget(e,s,i){const{layer:a}=this;if(!s)throw new t("imagerylayerview:fetchPopupFeatures","Nothing to fetch without area",{layer:a});const{popupEnabled:l}=a,u=c(a,i);if(!l||null==u)return[];const y=await u.getRequiredFields(null,{index:new p(a.rasterFields),partitions:new Map([["$pixel",a.rasterFields.filter(e=>e.name.startsWith(n)).map(e=>e.name)],["$imageCollectionItem",a.fields.map(e=>e.name)]])});r(i);const f=new m;f.timeExtent=this.timeExtent,f.geometry=s,f.outFields=y,f.outSpatialReference=s.spatialReference;const{resolution:d,spatialReference:h}=this.view,w="2d"===this.view.type?new o(d,d,h):new o(.5*d,.5*d,h),{returnTopmostRaster:R,showNoDataRecords:x}=u.layerOptions||{returnTopmostRaster:!0,showNoDataRecords:!1},g={returnDomainValues:!0,returnTopmostRaster:R,pixelSize:w,showNoDataRecords:x,signal:i?.signal};return a.queryVisibleRasters(f,g)}async getSourceScale(){return await i(),await this.layer.load(),a(this.layer.serviceRasterInfo,this.view.spatialReference)}canResume(){return!!super.canResume()&&!this.timeExtent?.isEmpty}}e([s()],y.prototype,"layer",void 0),e([s()],y.prototype,"suspended",void 0),e([s({readOnly:!0})],y.prototype,"timeExtent",null),e([s()],y.prototype,"view",void 0);export{y as default};
