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