import{__decorate as e}from"tslib";import{InvalidOperationError as t}from"../InvalidOperationError.js";import{applyJsonToSublayer as i}from"../json/SublayerJson.js";import{serializable as s}from"../support/Serializable.js";import{notifyChange as r,onWatch as a,watch as l}from"../support/observableUtils.js";import{ReadOnlyCollection as n}from"../utilities/ReadOnlyCollection.js";import{isBuildingComponentSublayer as o}from"../utilities/_layers.js";import{BuildingSublayerExtension as u,BuildingSublayerSchema as p}from"./BuildingSublayerExtension.js";import{SublayerExtension as d}from"./_SublayerExtension.js";import{ArrayWrappedCollection as y}from"./support/ArrayWrappedCollection.js";import{ExtensionBaseLayerListSettings as h}from"./support/LayerListSettings.js";import{PopupTemplateFeatureSettings as c}from"./support/PopupTemplateFeatureSettings.js";import{addOutFields as b}from"./support/layers.js";const m=Object.freeze({supportsAdd:!1,supportsUpdate:!1,supportsDelete:!1,supportsEditing:!1,supportsQuery:!1,supportsAttachmentEditing:!1,supportsStandardizedQueries:!0}),_="This schema property is read-only.";let f=class extends u{_enableClientSideData;_capabilitiesField;constructor(e){super(e),this._capabilitiesField=m}get enableClientSideData(){return this._enableClientSideData}set enableClientSideData(e){this._enableClientSideData=e,this._updateClientSideFields()}get renderer(){return this.sublayer?.renderer}get sublayer(){return super.sublayer}get hasFeatures(){return!0}get canChangeDefinitionExpression(){return!0}get _layerView(){return this.sublayer&&this.layerExtension?._layerView?.sublayerViews?.find((e=>e.sublayer===this.sublayer))}_createSublayerExtension(e){return d.factory.create(e,"BuildingComponentSublayer")}async _createSublayer(e){const t=new((await import("@arcgis/core/layers/buildingSublayers/BuildingComponentSublayer")).default);return await i(e,t),t}_isSupportedSublayer(e){return o(e)}_createSchema(){return new g(this)}_getSerializableProperties(){return{...super._getSerializableProperties(),enableClientSideData:{serializeModes:["initial"],default:!1}}}_capabilities(){return this._capabilitiesField}async _onInitialize(){await super._onInitialize(),this._capabilitiesField={...m,supportsQuery:!!this.sublayer.capabilities?.data},this._updateClientSideFields(),this._watchHandles.push(l(this,"sublayer",(()=>{this._updateClientSideFields()}),{sync:!0}))}async _postInitialize(){await super._postInitialize(),this.sublayer.fields?.length||l(this.sublayer,"fields",(async()=>{const{popupTemplate:e}=this.featureSettings;await Promise.all(this.schema.fieldExtensions.toArray().map((e=>e.initialize()))),!e.title&&this.schema.displayField&&(e.title=`{${this.schema.displayField}}`),this.featureSettings._isDefaultPopupTemplate&&!this.featureSettings.popupTemplate.fieldInfos?.length&&(this.featureSettings.popupTemplate.fieldInfos=this.schema.createAllFieldInfos())}),{once:!0})}_createLayerListSettings(e){return new C(e,this)}_watchSublayerProperties(){this._watchHandles.push(a(this,"effectiveMinScale",(()=>l(this.sublayer,"layer.minScale",(()=>r(this,"effectiveMinScale")),{sync:!0}))),a(this,"effectiveMaxScale",(()=>l(this.sublayer,"layer.maxScale",(()=>r(this,"effectiveMaxScale")),{sync:!0}))))}_createFeatureSettings(){return new S(this)}_updateClientSideFields(){this.sublayer&&this._enableClientSideData&&b(this.sublayer,this.featureSettings.outFields)}};f=e([s],f);export{f as BuildingComponentSublayerExtension};let S=class extends c{};S=e([s],S);let g=class extends p{_fieldCollection;constructor(e){super(e),this._fieldCollection=this._createFieldCollection(),r(this,"_fields")}get _fields(){return this._fieldCollection}get primaryKeyField(){return this._sublayerExtension.sublayer?.objectIdField}set primaryKeyField(e){throw new t(_)}get geometryType(){return this._sublayerExtension.sublayer?.geometryType}set geometryType(e){throw new t(_)}_createFieldCollection(){return new n(new y({parent:this._sublayerExtension,targetProperty:"sublayer",arrayProperty:"fields"}))}};g=e([s],g);export{g as BuildingComponentSublayerSchema};let C=class extends h{get _layerSupportsHideChildren(){return!1}get _esriLayer(){return this._extension.sublayer}get _listModePath(){return"sublayer.listMode"}get _supportsChildren(){return!1}};C=e([s],C);