/* COPYRIGHT Esri - https://js.arcgis.com/5.1.0/LICENSE.txt */
import{clone as e}from"../../../../../core/lang.js";import{getEffectiveFeatureReduction as r}from"./featureReductionUtils.js";import{getServiceGeometryType as t}from"./geometryUtils.js";import{createLabelVVEvaluator as i}from"./labelingUtils.js";import{ExceedsLimitCache as a}from"../schema/ExceedsLimitCache.js";import{createFeatureSourceSchema as s}from"../schema/SourceSchema.js";import{createSimpleProcessorSchema as o}from"../schema/processor/SimpleProcessorSchema.js";import{isRendererSupported as l}from"../support/rendererUtils.js";class n{constructor(e){this.layer=e,this._cache=new a}getLabelingDeconflictionInfo(){return[{vvEvaluators:{0:i(this.layer.renderer)}}]}async createSourceSchema(e,r){const t=this._createServiceInfo(e);return s(t,null,{definitionExpression:null,returnZ:e.returnZ,returnM:e.returnM,queryScaleRanges:[],displayFilterEnabled:e.displayFilterEnabled,displayFilterInfo:null,customParameters:this.layer.customParameters,gdbVersion:null,historicMoment:null,timeExtent:this.layer.timeExtent,apiKey:this.layer.apiKey,sourceRefreshVersion:r,availableFields:e.availableFields,cache:this._cache,postQueryFilter:null})}createProcessorSchema(e,t,i){const{fields:a,renderer:s,geometryType:l,labelingInfo:n,labelsVisible:u,orderBy:c,objectIdField:p}=this.layer,d={fields:a.map(e=>e.toJSON()),renderer:s?.clone(),labelingInfoSource:this.layer.id,featureReduction:r(this.layer,t),geometryType:l,labelingInfo:n,labelsVisible:u,objectIdField:p,orderBy:c??"default"};return o(e,t,d,i)}get hasRequiredSupport(){return l(this.layer.renderer)}get timeOptions(){return this.layer}getUpdateHashProperties(e){return[()=>this.layer.apiKey,()=>this.layer.customParameters,()=>r(this.layer,e),()=>this.layer.labelsVisible?this.layer.labelingInfo:null,()=>this.layer.orderBy,()=>this.layer.renderer]}getRenderer(){return this.layer.renderer}setGraphicOrigin(e){e.origin=this.layer.graphicOrigin}setAggregateGraphicOrigin(e){e.origin=this.layer.aggregateGraphicOrigin}setTrackGraphicOrigin(e){e.origin=this.layer.trackGraphicOrigin}_createServiceInfo(r){const i=this.layer,{capabilities:a}=i,s=i.fieldsIndex.toJSON(),o=t(i),l=i.timeInfo?.toJSON(),n=i.spatialReference.toJSON(),u=i.source.getSource(),c=this.layer.objectIdField,p=e(a);p.query.maxRecordCount=u.maxRecordCount;const d=r.spatialReference.toJSON();return{type:"ogc",source:u,orderByFields:c,outSpatialReference:d,metadata:{fieldsIndex:s,geometryType:o,hasZ:this.layer.hasZ??!1,hasM:!1,featureIdInfo:{type:"object-id",fieldName:i.objectIdField},timeInfo:l,spatialReference:n,outSpatialReference:d,globalIdField:null,subtypeField:null,subtypes:null,timeReferenceUnknownClient:null,dateFieldsTimeZone:null,typeIdField:null,types:null},queryMetadata:{maxRecordCount:p.query.maxRecordCount,tileMaxRecordCount:p.query.tileMaxRecordCount,supportsCompactGeometry:p.query.supportsCompactGeometry,supportsDefaultSpatialReference:p.query.supportsDefaultSpatialReference,supportsFormatPBF:p.query.supportsFormatPBF,supportsMaxRecordCountFactor:p.query.supportsMaxRecordCountFactor,supportsQuantization:p.query.supportsQuantization,supportsCentroidOnDegeneratedQuantizedGeometry:p.query.supportsCentroidOnDegeneratedQuantizedGeometry,supportsDegeneratedQuantizedGeometry:p.query.supportsDegeneratedQuantizedGeometry,supportsReturnExceededLimitGeometries:p.query.supportsReturnExceededLimitGeometries,lastEditDate:null}}}}export{n as OGCFeatureLayerAdapter};
