/*
All material copyright Esri, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/5.0/esri/copyright.txt for details.
*/
import{destroyMaybe as e}from"../../../../core/maybe.js";import{createFeatureTileQuery3D as t}from"./featureTileQuery3D.js";class r{constructor(e){this._memoryCache=null;const{layerView:r,returnZ:i,returnM:a}=e,s=r.layer;this._layerView=r,this.objectIdField=s.objectIdField,this.globalIdField="globalIdField"in s?s.globalIdField:null,this._returnZ=i,this._returnM=a;const l=r.view.resourceController;this.query=t(r,l.normal),this._memoryCacheEnabled&&(this._memoryCache=l.memoryController.newCache(`fl-${s.uid}`))}get _memoryCacheEnabled(){switch(this._layerView.layer.source.type){case"feature-layer":case"ogc-feature":case"oriented-imagery":return!0;case"csv":case"parquet":case"geojson":case"memory":case"wfs":return!1}}destroy(){this._memoryCache=e(this._memoryCache),this.query.destroy()}createQuery(){const e=this._layerView.layer.createQuery();return e.outFields=this._layerView.availableFieldsForQuery,e.returnZ=this._returnZ,e.returnM=this._returnM,e.outSpatialReference=this.tilingScheme?.spatialReference??this._layerView.view.spatialReference,e}get memoryCache(){return this._memoryCache}get viewingMode(){return this._layerView.view.state.viewingMode}get tilingScheme(){return this._layerView.view.featureTiles?.tilingScheme}get scheduler(){return this._layerView.view.resourceController?.scheduler}get geometryType(){return this._layerView.layer.geometryType}get fullExtent(){return this._layerView.layer.fullExtent}get tileMaxRecordCount(){return this._layerView.layer.capabilities.query.tileMaxRecordCount}get standardMaxRecordCount(){return this._layerView.layer.capabilities.query.standardMaxRecordCount}get maxRecordCount(){return this._layerView.layer.capabilities.query.maxRecordCount}get isDraped(){return"on-the-ground"===this._layerView.layer.elevationInfo?.mode}get effectiveDisplayFilter(){return this._layerView.displayFilterEnabled?this._layerView.effectiveDisplayFilter:null}get highlightIds(){return this._layerView.displayFilterEnabled?this._layerView.highlightIds:null}get capabilities(){return this._capabilities??=i(this._layerView.layer),this._capabilities}logFetchError(e,t){e.error("#fetchTile()",this._layerView.layer,t?.message??t)}}function i(e){const t=e.capabilities.query;return{supportsMultipleResolutions:a(e),supportsPagination:!(!t||!t.supportsPagination),supportsResultType:!(!t||!t.supportsResultType),supportsCacheHint:!(!t||!t.supportsCacheHint),supportsQuantization:!(!t||!t.supportsQuantization),supportsQuantizationEditMode:!(!t||!t.supportsQuantizationEditMode),supportsMaxRecordCountFactor:!(!t||!t.supportsMaxRecordCountFactor),supportsFormatPBF:!(!t||!t.supportsFormatPBF)}}function a(e){switch(e.geometryType){case"polyline":return!0;case"polygon":return e.capabilities&&e.capabilities.query&&e.capabilities.query.supportsQuantization;default:return!1}}export{r as FeatureTileFetcher3DContext,i as contextCapabilitiesFromLayer};
