/* COPYRIGHT Esri - https://js.arcgis.com/5.1.0/LICENSE.txt */
import{clone as e}from"../../../../../core/lang.js";import{isHostedAgolService as r}from"../../../../../layers/support/arcgisLayerUrl.js";import{getServiceGeometryType as t}from"./geometryUtils.js";import{createLabelVVEvaluator as i}from"./labelingUtils.js";import{ExceedsLimitCache as s}from"../schema/ExceedsLimitCache.js";import{createFeatureSourceSchema as a}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 s}getLabelingDeconflictionInfo(){return[{vvEvaluators:{0:i(this.layer.renderer)}}]}async createSourceSchema(e,r){const t=this._createServiceInfo(e);return a(t,null,{definitionExpression:this.layer.definitionExpression,returnZ:e.returnZ,returnM:e.returnM,queryScaleRanges:[],displayFilterEnabled:e.displayFilterEnabled,displayFilterInfo:this.layer.displayFilterInfo,customParameters:this.layer.customParameters,gdbVersion:null,historicMoment:null,postQueryFilter:null,timeExtent:this.layer.timeExtent,apiKey:this.layer.apiKey,sourceRefreshVersion:r,availableFields:e.availableFields,cache:this._cache})}createProcessorSchema(e,r,t){const{fields:i,geometryType:s,orderBy:a,objectIdField:l,renderer:n,labelingInfo:u,labelsVisible:d}=this.layer,p={featureReduction:null,labelingInfoSource:this.layer.id,fields:i.map(e=>e.toJSON()),geometryType:s,labelingInfo:u,labelsVisible:d,objectIdField:l,orderBy:a??"default",renderer:n?.clone()};return o(e,r,p,t)}get hasRequiredSupport(){return l(this.layer.renderer)}get timeOptions(){return this.layer}getUpdateHashProperties(e){return[()=>this.layer.apiKey,()=>this.layer.customParameters,()=>this.layer.definitionExpression,()=>this.layer.outFields,()=>this.layer.renderer,()=>this.layer.labelsVisible?this.layer.labelingInfo:null,()=>this.layer.orderBy]}getRenderer(){return this.layer.renderer}setGraphicOrigin(e){e.origin=this.layer.graphicOrigin}_createServiceInfo(i){const s=this.layer,{capabilities:a,editingInfo:o,objectIdField:l,globalIdField:n,datesInUnknownTimezone:u,dateFieldsTimeZone:d,orderBy:p,parsedUrl:c,hasZ:y,hasM:m}=s,h=s.fieldsIndex.toJSON(),f=t(s),g=s.timeInfo?.toJSON(),b=s.spatialReference.toJSON(),F=e(c);let I=l;if(p?.length){const e=!p[0].valueExpression&&p[0].field;e&&(I=e)}const S=r(F.path),R=i.spatialReference.toJSON();return{type:"feature-service",source:F,isSourceHosted:S,orderByFields:I,outSpatialReference:R,metadata:{timeReferenceUnknownClient:u,dateFieldsTimeZone:d,globalIdField:n,fieldsIndex:h,geometryType:f,hasZ:y??!1,hasM:m??!1,featureIdInfo:{type:"object-id",fieldName:l},timeInfo:g,spatialReference:b,outSpatialReference:R,subtypeField:null,subtypes:null,typeIdField:null,types:null},queryMetadata:{maxRecordCount:a.query.maxRecordCount,tileMaxRecordCount:a.query.tileMaxRecordCount,supportsCompactGeometry:a.query.supportsCompactGeometry,supportsDefaultSpatialReference:a.query.supportsDefaultSpatialReference,supportsFormatPBF:a.query.supportsFormatPBF,supportsMaxRecordCountFactor:a.query.supportsMaxRecordCountFactor,supportsQuantization:a.query.supportsQuantization,supportsCentroidOnDegeneratedQuantizedGeometry:a.query.supportsCentroidOnDegeneratedQuantizedGeometry,supportsDegeneratedQuantizedGeometry:a.query.supportsDegeneratedQuantizedGeometry,supportsReturnExceededLimitGeometries:a.query.supportsReturnExceededLimitGeometries,lastEditDate:o?.lastEditDate?.getTime()}}}}export{n as CatalogFootprintLayerAdapter};
