import{__decorate as e}from"tslib";import{InvalidOperationError as r}from"../InvalidOperationError.js";import{_isMapNotesLayerJson as t}from"../json/FeatureLayerJson.js";import{applyJsonToLayer as a,layerToJson as o}from"../json/LayerJson.js";import{serializable as s}from"../support/Serializable.js";import{isMapNotesLayer as n}from"../utilities/_layers.js";import{checkArg as i}from"../utilities/checkArg.js";import{LayerExtension as l}from"./_LayerExtension.js";import{SublayerExtension as p}from"./_SublayerExtension.js";import{SublayerExtensionCollectionBase as y}from"./support/_SublayerExtensionCollection.js";const u="SublayerExtension collection for MapNotesLayerExtension is readonly";export const MAP_NOTES_LAYER_TYPE="map-notes-layer";let c=class extends l{get layer(){return super.layer}get supportsSublayers(){return!0}_createSublayerExtension(e){return p.factory.create(e,"MapNotesSublayer")}_getProjectWebmapJSON(){const e=super._getProjectWebmapJSON(),r=o(this.layer);return e.featureCollection={layers:r.featureCollection.layers.map((e=>({layerDefinition:{name:e.layerDefinition.name}})))},e.visibleLayers=r?.visibleLayers,e.featureCollectionType="notes",e}_applyLayerProperties(e,r){return e.hasOwnProperty("featureCollection")&&i("layerJson",e).satisfies(t),super._applyLayerProperties(e,r)}_getSerializableProperties(){const e=super._getSerializableProperties();return{...e,layer:{...this._toPropertyDef(e.layer),default:{layerType:"ArcGISFeatureLayer",featureCollectionType:"notes"}}}}_isSupportedLayer(e){return n(e)}async _applyPortalItemProperties(e){if("Feature Collection"!==e.type)throw new Error(`Cannot create Map Notes Layer from Portal item that has type: ${e.type}`);const r=await e.fetchData();if(!t({layerType:"ArcGISFeatureLayer",featureCollection:r}))throw new Error("Cannot create Map Notes Layer from Portal item that contains a non map notes layer feature collection");return a({layerType:"ArcGISFeatureLayer",featureCollection:r},this.layer)}_capabilities(){return{supportsAdd:!1,supportsDelete:!1,supportsEditing:!1,supportsQuery:!1,supportsUpdate:!1,supportsAttachmentEditing:!1,supportsStandardizedQueries:!0}}_getSerializableLayerType(){return"map-notes-layer"}_getSerializableRefLayerProperties(){return this.layer?.featureCollectionType?{featureCollectionType:this.layer.featureCollectionType}:{}}_createSublayerExtensionCollection(){return new f(this)}};c=e([s],c);export{c as MapNotesLayerExtension};class f extends y{_layerExtension;constructor(e){super(e,"layer.sublayers"),this._layerExtension=e}add(e,t){if(i("sublayerX",e).isNotMissing(),e.sublayer&&this._parent.layer.sublayers&&!this._parent.layer.sublayers.includes(e.sublayer))throw new r(u);return super.add(e,t)}removeAt(e){throw new r(u)}reorder(e,t){throw new r(u)}reverse(){throw new r(u)}sort(e){throw new r(u)}splice(e,t,...a){throw new r(u)}_createClone(){return new f(this._layerExtension)}_createSublayerExtension(e){return this._parent._createSublayerExtension(e)}}