import{__decorate as e}from"tslib";import t from"@arcgis/core/config";import r from"@arcgis/core/core/Collection";import s from"@arcgis/core/geometry/SpatialReference";import{jsonToLayer as i}from"../json/LayerJson.js";import{serializable as o}from"../support/Serializable.js";import{notifyChange as a,watch as l}from"../support/observableUtils.js";import{ReadOnlyCollection as n}from"../utilities/ReadOnlyCollection.js";import{isGeoRssLayer as p}from"../utilities/_layers.js";import{map as u}from"../utilities/promise.js";import{caseInsensitiveEquals as c}from"../utilities/string.js";import{FeatureCollectionLayerExtension as y}from"./FeatureCollectionLayerExtension.js";import{LayerExtension as f,LayerExtensionSchema as m}from"./_LayerExtension.js";export const DEFAULT_GEO_RSS_UTILITY="https://utility.arcgis.com/sharing/rss";let _=class extends f{get layer(){return super.layer}get _featureLayerExtensions(){return this._featureLayerXCache}_featureLayerXCache=[];get hasFeatures(){return!0}_capabilities(){return Object.freeze({supportsAdd:!1,supportsUpdate:!1,supportsDelete:!1,supportsEditing:!1,supportsQuery:!1,supportsAttachmentEditing:!1,supportsStandardizedQueries:!0})}_getSerializableProperties(){const e=super._getSerializableProperties();return{...e,layer:{...this._toPropertyDef(e.layer),default:{layerType:"GeoRSS"}}}}_isSupportedLayer(e){return p(e)}_createSchema(){return new d(this)}async _initializeLayer(){t.geoRSSServiceUrl||(t.geoRSSServiceUrl=DEFAULT_GEO_RSS_UTILITY)}async _onInitialize(){await super._onInitialize(),this.layer.featureCollections&&(this._featureLayerXCache=await u(this.layer.featureCollections,(async e=>{const t={layerType:"ArcGISFeatureLayer",featureCollection:{layers:[e]}};return new y({layer:await i(t)})})),a(this,"_featureLayerExtensions"))}};_=e([o],_);export{_ as GeoRSSLayerExtension};let d=class extends m{_fieldsCollection;constructor(e){super(e),this._fieldsCollection=new h(e),a(this,"_fields")}destroy(){this._fieldsCollection.destroy(),super.destroy()}_getPropertyBindings(){return{spatialReference:{value:s.WGS84}}}get _fields(){return this._fieldsCollection}};d=e([o],d);class h extends n{layerExtension;get _collection(){if(!this.layerExtension?.layer)return new r;let e=new r;return this.layerExtension._featureLayerExtensions.forEach((t=>{const r=t.layer.fields.filter((t=>!e.some((e=>this._fieldsEqual(t,e)))));e=e.concat(r)})),e}constructor(e){super(),this.layerExtension=e,this._handles.add(l(e,"_featureLayerExtensions",(()=>this.emit("after-changes")),{sync:!0}))}_fieldsEqual(e,t){return!(!c(e.alias,t.alias)||!c(e.name,t.name)||e.type!==t.type)}}