import{executeQueryJSON as r,executeForCount as e}from"@arcgis/core/rest/query";import t from"@arcgis/core/rest/support/Query";import{InvalidOperationError as u}from"../../InvalidOperationError.js";import{executeQuery as s,executeCount as o}from"../../support/_query.js";import{isImageryLayer as i}from"../../utilities/_layers.js";import{QueryProviderBase as n}from"./QueryProviderBase.js";export class ImageryLayerQueryProvider extends n{isSupported(r){const{layer:e}=r;return i(e)&&r.capabilities.supportsQuery}_query(r,e,t){const u=this._getQueryable(r),o=a();return o.where=e,o.outFields=t.outFields,o.num=t.maxResults,s(o,r,u,t.cancelToken)}async _count(r,e,t){const u=this._getQueryable(r),s=a();return s.where=e,s.outFields=t.outFields,s.num=t.maxResults,o(s,r,u,t.cancelToken)}_getQueryable(t){return{queryFeatures(e,s){const o=r(t.layer.url,e??a(),s);if(!t.capabilities.supportsQuery)throw new u("Querying features not supported");return o},queryFeatureCount(r,s){const o=e(t.layer.url,r??a(),s);if(!t.capabilities.supportsQuery)throw new u("Querying features not supported");return o}}}}function a(){return new t({where:"1=1",outFields:["*"],returnGeometry:!0})}