// All material copyright Esri, All Rights Reserved, unless otherwise specified. // See https://js.arcgis.com/4.30/esri/copyright.txt for details. //>>built define("exports ../../../chunks/tslib.es6 ../../../geometry ../../../core/Error ../../../core/has ../../../core/Loadable ../../../core/Logger ../../../core/promiseUtils ../../../core/workers/workers ../../../core/accessorSupport/decorators/property ../../../core/RandomLCG ../../../core/accessorSupport/decorators/subclass ../../../geometry/support/typeUtils ./support/clientSideDefaults ../../ogc/wfsUtils ../../../rest/support/FeatureSet ../../../time/timeZoneUtils ../../../geometry/Extent".split(" "), function(d,f,K,t,u,v,w,q,x,g,L,y,z,r,k,A,B,C){d.WFSSource=class extends v{constructor(){super(...arguments);this._workerHandler=this._connection=null;this.capabilities=r.createCapabilities(!1,!1);this.type="wfs";this.refresh=q.debounce(async()=>{await this.load();const {extent:a}=await this._workerHandler.refresh({customParameters:this.layer.customParameters,maxRecordCount:this.layer.maxRecordCount,maxTotalRecordCount:this.layer.maxTotalRecordCount,maxPageCount:this.layer.maxPageCount});a&&(this.sourceJSON.extent= a);return{dataChanged:!0,updates:{extent:this.sourceJSON.extent}}})}load(a){this.addResolvingPromise(this._startWorker({signal:null!=a?a.signal:null}));return Promise.resolve(this)}destroy(){this._connection?.close();this._workerHandler=this._connection=null}async openPorts(){await this.load();return this._connection.openPorts()}async queryFeatures(a,b={}){a=await this.queryFeaturesJSON(a,b);return A.fromJSON(a)}async queryFeaturesJSON(a,b={}){await this.load(b);return this._workerHandler.queryFeatures(a? a.toJSON():void 0,b)}async queryFeatureCount(a,b={}){await this.load(b);return this._workerHandler.queryFeatureCount(a?a.toJSON():void 0,b)}async queryObjectIds(a,b={}){await this.load(b);return this._workerHandler.queryObjectIds(a?a.toJSON():void 0,b)}async queryExtent(a,b={}){await this.load(b);a=await this._workerHandler.queryExtent(a?a.toJSON():void 0,b);return{count:a.count,extent:C.fromJSON(a.extent)}}async querySnapping(a,b={}){await this.load(b);return this._workerHandler.querySnapping(a, b)}async _createLoadOptions(a){const {url:b,customParameters:e,name:c,namespaceUri:h,fields:l,geometryType:D,maxRecordCount:E,maxPageCount:F,maxTotalRecordCount:G,swapXY:H}=this.layer;var m="defaults"===this.layer.originOf("spatialReference")?void 0:this.layer.spatialReference;if(!b)throw new t("wfs-layer:missing-url","WFSLayer must be created with a url");this.wfsCapabilities||(this.wfsCapabilities=await k.getCapabilities(b,{customParameters:e,...a}));a=["fields","geometryType","name","namespaceUri", "swapXY"].some(p=>null==this.layer[p])?await k.getWFSLayerInfo(this.wfsCapabilities,c,h,{spatialReference:m,customParameters:e,signal:a?.signal}):{...k.prepareWFSLayerFields(l??[]),geometryType:D,name:c,namespaceUri:h,spatialReference:m,swapXY:H};m=k.findFeatureType(this.wfsCapabilities.readFeatureTypes(),a.name,a.namespaceUri);const I=z.featureGeometryTypeKebabDictionary.toJSON(a.geometryType);var {operations:n}=this.wfsCapabilities;const J=n.GetFeature.url;n=n.GetFeature.outputFormat;return{customParameters:e, featureType:m,fields:a.fields?.map(p=>p.toJSON())??[],geometryField:a.geometryField,geometryType:I,getFeatureUrl:J,getFeatureOutputFormat:n,maxRecordCount:E,maxPageCount:F,maxTotalRecordCount:G,objectIdField:a.objectIdField,spatialReference:a.spatialReference?.toJSON(),swapXY:!!a.swapXY}}async _startWorker(a){const [b,e]=await q.eachAlways([this._createLoadOptions(a),x.open("WFSSourceWorker",{...a,strategy:u("feature-layers-workers")?"dedicated":"local",registryTarget:this})]);var c=b.error||e.error|| null;const h=e.value||null;if(c)throw h&&h.close(),c;c=b.value;this._connection=e.value;this._workerHandler=this._connection.createInvokeProxy();a=await this._workerHandler.load(c,a);for(const l of a.warnings)w.getLogger(this.layer).warn("#load()",`${l.message} (title: '${this.layer.title||"no title"}', id: '${this.layer.id??"no id"}')`,{warning:l});this.sourceJSON={dateFieldsTimeReference:{timeZoneIANA:B.utc},extent:a.extent,fields:c.fields,geometryType:c.geometryType,objectIdField:c.objectIdField, geometryField:c.geometryField,drawingInfo:r.createDrawingInfo(c.geometryType),name:c.featureType.title,wfsInfo:{name:c.featureType.name,featureUrl:c.getFeatureUrl,maxFeatures:c.maxRecordCount,swapXY:c.swapXY,supportedSpatialReferences:c.featureType.supportedSpatialReferences,version:"2.0.0",wfsNamespace:c.featureType.namespaceUri}}}};f.__decorate([g.property()],d.WFSSource.prototype,"capabilities",void 0);f.__decorate([g.property({constructOnly:!0})],d.WFSSource.prototype,"layer",void 0);f.__decorate([g.property()], d.WFSSource.prototype,"sourceJSON",void 0);f.__decorate([g.property()],d.WFSSource.prototype,"type",void 0);f.__decorate([g.property()],d.WFSSource.prototype,"wfsCapabilities",void 0);d.WFSSource=f.__decorate([y.subclass("esri.layers.graphics.sources.WFSSource")],d.WFSSource);Object.defineProperty(d,Symbol.toStringTag,{value:"Module"})});