@arcgis/core 5.2.0-next.168 → 5.2.0-next.169
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/assets/esri/core/workers/RemoteClient.js +1 -1
- package/assets/esri/core/workers/chunks/546f5f57c9249627bb89.js +1 -0
- package/assets/esri/core/workers/chunks/{c0a956d57fa28fd31052.js → 8d86b0cb0e004ad72040.js} +1 -1
- package/config.js +1 -1
- package/form/elements/inputs/DynamicChoiceInput.d.ts +2 -2
- package/geometry/operators/containsOperator.d.ts +1 -1
- package/geometry/operators/densifyOperator.d.ts +1 -1
- package/geometry/operators/differenceOperator.d.ts +6 -4
- package/geometry/operators/distanceOperator.d.ts +1 -1
- package/geometry/operators/geodesicProximityOperator.d.ts +8 -8
- package/geometry/operators/graphicBufferOperator.d.ts +6 -6
- package/geometry/operators/integrateOperator.d.ts +2 -2
- package/geometry/operators/intersectsOperator.d.ts +3 -3
- package/geometry/operators/linesToPolygonsOperator.d.ts +2 -2
- package/geometry/operators/locateBetweenOperator.d.ts +2 -2
- package/geometry/operators/minimumBoundingCircleOperator.d.ts +1 -1
- package/geometry/operators/multiPartToSinglePartOperator.d.ts +2 -2
- package/geometry/operators/polygonSlicerOperator.d.ts +2 -2
- package/geometry/operators/projectOperator.d.ts +2 -2
- package/geometry/operators/proximityOperator.d.ts +15 -15
- package/geometry/operators/shapePreservingProjectOperator.d.ts +2 -2
- package/geometry/operators/simplifyOperator.d.ts +2 -2
- package/geometry/operators/support/GeographicTransformationStep.d.ts +3 -3
- package/geometry/operators/support/Transformation.d.ts +8 -8
- package/geometry/operators/support/geographicTransformationUtils.d.ts +3 -3
- package/geometry/operators/symmetricDifferenceOperator.d.ts +2 -2
- package/geometry/operators/withinOperator.d.ts +3 -3
- package/kernel.js +1 -1
- package/layers/GeospatialPDFLayer.d.ts +2 -2
- package/layers/ParquetLayer.d.ts +1 -1
- package/package.json +2 -2
- package/popup/FeaturesModel.js +1 -1
- package/popup/support/featureUtils.js +1 -1
- package/rest/featureService/FeatureService.d.ts +0 -5
- package/rest/networks/support/TraceLocation.d.ts +2 -1
- package/rest/networks/support/TraceResult.d.ts +0 -4
- package/rest/support/OutDistance.d.ts +0 -1
- package/smartMapping/statistics/histogramForTimeSeries.js +1 -1
- package/smartMapping/statistics/summaryStatisticsForTimeSeries.js +1 -1
- package/symbols/cim/types.d.ts +7 -9
- package/views/2d/engine/webgl/collisions/LabelMetric.js +1 -1
- package/views/2d/engine/webgl/collisions/LabelStore.js +1 -1
- package/views/2d/layers/features/FeatureContainer.js +1 -1
- package/views/2d/layers/support/visualVariableSimpleUtils.js +1 -1
- package/views/3d/environment/SunLighting.d.ts +15 -2
- package/views/3d/environment/VirtualLighting.d.ts +15 -2
- package/views/3d/interactive/editingTools/reshape/ReshapeOperation.js +1 -1
- package/views/3d/layers/support/FeatureTileFetcher3D.js +1 -1
- package/views/draw/DrawOperation.js +1 -1
- package/views/draw/DrawScreenTool.js +1 -1
- package/views/input/types.d.ts +2 -4
- package/views/interactive/options/LabelOptions.d.ts +5 -5
- package/views/interactive/options/SnappingOptions.d.ts +2 -2
- package/widgets/BatchAttributeForm/inputs/FieldInput.d.ts +0 -1
- package/widgets/Editor/VisibleElements.d.ts +4 -0
- package/widgets/Editor.d.ts +2 -0
- package/widgets/FeatureTable/FeatureTableViewModel.js +1 -1
- package/widgets/FeatureTable.js +1 -1
- package/widgets/Features/FeaturesViewModel.js +1 -1
- package/widgets/OrientedImageryViewer/OrientedImageryViewerViewModel.js +1 -1
- package/widgets/OrientedImageryViewer/support/NonPanoramicMedia.js +1 -1
- package/widgets/OrientedImageryViewer/support/dataCaptureUtils.js +1 -1
- package/widgets/PanoramicViewer/utils.js +1 -1
- package/widgets/Search/LayerSearchSource.d.ts +1 -1
- package/widgets/Sketch/VisibleElements.d.ts +4 -0
- package/widgets/Sketch.d.ts +2 -0
- package/widgets/support/iconUtils.js +1 -1
- package/assets/esri/core/workers/chunks/181b58bbbbfe4557ab5d.js +0 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
|
|
2
|
-
import{__decorate as e}from"tslib";import{onLocaleChange as t,substitute as n,fetchMessageBundle as r}from"../../intl.js";import{isSome as i}from"../../core/arrayUtils.js";import a from"../../core/Collection.js";import{referenceSetter as o}from"../../core/collectionUtils.js";import s from"../../core/Error.js";import c from"../../core/Logger.js";import{debounce as l,ignoreAbortErrors as u}from"../../core/promiseUtils.js";import{watch as d,initial as f,on as p,syncAndInitial as m}from"../../core/reactiveUtils.js";import{throttle as h}from"../../core/throttle.js";import{property as g,subclass as _}from"../../core/accessorSupport/decorators.js";import{getEffectiveFieldAlias as v}from"../../editing/fieldUtils.js";import{geometryTypes as y}from"../../geometry/support/typeUtils.js";import{getLowerCaseDefaultHiddenFields as b}from"../../layers/support/fieldUtils.js";import{getSubtypesFromLayer as x,isSubtypeGroupLayer as S}from"../../layers/support/layerUtils.js";import{createFieldInfos as C}from"../../support/popupUtils.js";import w from"../../tables/AttributeTableTemplate.js";import{syncAttributeTableTemplateWithColumns as T}from"../../tables/support/templateUtils.js";import E from"../../time/TimeExtent.js";import{isSelectableLayerWithObjectIds as D}from"../../views/support/selectionUtils.js";import O from"./ActionColumn.js";import k from"./AttachmentsColumn.js";import A from"./FieldColumn.js";import j from"./RelationshipColumn.js";import M from"./Grid/Column.js";import N from"./Grid/Grid.js";import P from"./Grid/GridViewModel.js";import F from"./Grid/GroupColumn.js";import I from"./support/AttachmentsColumnTemplate.js";import L from"./support/AttachmentsViewOptions.js";import{isAttachmentsColumn as R,isFieldColumn as z,isRelationshipColumn as B}from"./support/columnUtils.js";import{downloadAttachmentInfo as V,exportToCSV as H}from"./support/exportUtils.js";import U from"./support/FeatureStore.js";import W from"./support/FieldColumnTemplate.js";import G from"./support/RelationshipColumnTemplate.js";import K from"./support/TableTemplate.js";import{isIFeatureTableSupportedLayerWithFieldConfigurations as q,isIFeatureTableSupportedLayerWithRelationships as J,findRelatedLayerInSources as ee,findRelationship as te,uniqueColumnNames as Y,hasColumnForField as ne,findField as X,isIFeatureTableSupportedLayerWithAttachments as re,getRelationshipIdsToShow as ie}from"./support/tableUtils.js";import{goTo as ae}from"../support/goToUtils.js";import{messageBundle as Z}from"../support/widget.js";const Q=`80px`;let $=class extends P{constructor(e){super(e),this._refreshDebounced=l(()=>this._refresh()),this._syncTemplateThrottled=h(()=>this._syncAttributeTableTemplate()),this.attachmentsViewOptions=new L,this.attributeTableTemplate=null,this.autoRefreshEnabled=!0,this.columns=new a,this.dataProvider=async(e,t)=>{let{layer:n,store:r}=this;if(!t)return;if(!n||!r){t&&t([]);return}try{await n.load()}catch{return}let{objectIds:i}=this;if(this.filterBySelectionEnabled&&!this.highlightIds.length||i.length===1&&i.items[0]===-1){t([]);return}if(r.state!==`loaded`&&r.state!==`loading`)try{await r.load()}catch{return}let a=this.paginationEnabled?this.pageIndex:e.page;try{let n=await r.queryPage({...e,pageIndex:a});t?.(n)}catch{return}},this.grid=null,this.layers=null,this.menuConfig=null,this.messages=null,this.messagesCommon=null,this.messagesUnits=null,this.messagesURIUtils=null,this.prompt=null,this.relatedTables=new a,this.relationshipColumnConfigs=null,this.showRelatedTableCallback=null,this.store=null,this.syncTemplateOnChangesEnabled=!0,this.tableController=null,this.tableParent=null,this.tableTemplate=null,this.tableTemplateOverride=null,this._onLayerRefresh=this._onLayerRefresh.bind(this),this._onShowPromptCallback=this._onShowPromptCallback.bind(this),this._set(`store`,new U),this._set(`grid`,new N({viewModel:this}))}initialize(){let e=async()=>{this.messages=await r(`esri/widgets/FeatureTable/t9n/FeatureTable`),this.messagesCommon=await r(`esri/t9n/common`),this.messagesUnits=await r(`esri/core/t9n/Units`),this.messagesURIUtils=await r(`esri/widgets/support/t9n/uriUtils`)};e(),this.addHandles([t(()=>{e(),this._generateColumns()}),d(()=>[this.messages,this.messagesCommon,this.messagesURIUtils],()=>{let e=this.messages;this.grid&&(this.grid.messages=e),this.allColumns.forEach(t=>{t.messages=e,t.messagesCommon=this.messagesCommon,t.messagesURIUtils=this.messagesURIUtils}),this.refreshCellContent()},f),d(()=>this.attachmentsEnabled,()=>this.layer?.loaded&&this._generateColumns()),d(()=>this.layer,async(e,t)=>{let n=this.grid;n&&(n.clearSort(),e&&t&&await this.reset()),this.goToPage(0),this._drainColumns(),this.store.layer=e,e&&(e.loaded?this._onLayerLoad().catch(()=>{}):e.load().catch(()=>{})),this.syncViewSelection&&this._syncSelection(),t&&this.attachmentsViewOptions.objectId!=null&&(this.attachmentsViewOptions.objectId=null)}),d(()=>this.layer?.loaded,e=>{e&&this._onLayerLoad().catch(()=>{})}),d(()=>this.store.state,e=>{e===`loaded`&&(this.scrollToTop(),this.refreshCellContent())}),d(()=>this._effectiveTableTemplate,()=>{this.scrollLeft(),this.layer?.loaded&&this._generateColumns()}),d(()=>this.editingEnabled,()=>this.refreshCellContent()),d(()=>this.timeZone??this.view?.timeZone,()=>this.refreshCellContent()),d(()=>this.effectiveWhere,()=>{this.store.state===`loaded`&&this.reset().catch(()=>{})}),d(()=>this.effectiveTimeExtent,()=>void this.refresh()),p(()=>this.layer,`refresh`,e=>this._onLayerRefresh(e)),p(()=>this.grid,[`cell-click`,`cell-dblclick`,`cell-pointerover`,`cell-pointerout`,`cell-keydown`,`column-reorder`],({index:e,item:t,native:n,path:r,type:i})=>{let a=t?.feature,o=a?.getObjectId(),s=i===`cell-keydown`&&n&&n instanceof KeyboardEvent&&n.key===`Enter`;this.emit(i,{feature:a,index:e,native:n,type:i,fieldName:r??void 0,objectId:o}),(s||i===`cell-click`)&&this._onCellInteraction(o)}),d(()=>this.actionColumnConfig,e=>{let{actionColumn:t,columns:n}=this;t?e?t.set(e):n.remove(t):e&&n.length&&n.add(this._generateActionColumn(),e.frozenToEnd===!1?this._getIndexOfFirstFrozenToEndColumn():void 0)}),d(()=>this.relatedRecordsEnabled,()=>this.layer?.loaded&&this._generateColumns()),p(()=>this.objectIds,`change`,()=>this._onObjectIdsChange(),{onListenerAdd:()=>this._onObjectIdsChange()}),d(()=>[this.paginationEnabled,this.pageIndex],()=>this.refreshPageCache()),d(()=>this.activeSortOrders,e=>{this.store.sortOrders=e,this._syncTemplateThrottled()}),d(()=>this.allVisibleColumns,()=>this._syncTemplateThrottled()),d(()=>this.pageCount,()=>{this.pageIndex>=this.pageCount&&this.goToPage(0)}),d(()=>this.state,e=>{e===`disabled`&&this.relatedTables.length&&this.drainRelatedTables()}),p(()=>this.tableParent?.highlightIds,`change`,({added:e})=>{let{relationshipConfig:t}=this,n=e[0];if(n==null||!t)return;let{relatedLayer:r,relationshipId:i}=t;this.relationshipConfig={objectId:n,relatedLayer:r,relationshipId:i}}),p(()=>this.tableParent,`cell-click`,async e=>{let{objectId:t}=e;this.tableController&&this.hasPendingEdits?await this.tableController.discardPendingEdits(void 0,!0).then(e=>e&&this._syncTableParentSelection(t)):this._syncTableParentSelection(t)}),d(()=>this.attachmentsViewOptions.objectId,(e,t)=>{if(e==null){this.hideAttachmentsView();return}t??this.showAttachmentsView({objectId:e})}),d(()=>[this.layerFieldConfigurations,this.pendingEditsCount],()=>this.refreshCellContent()),p(()=>this.highlightIds,`change`,e=>this._onHighlightIdsChange(e),{onListenerAdd:()=>this._syncSelection(),onListenerRemove:()=>this.defaultSelectionManager.clear()}),d(()=>this.effectiveSelectionManager,()=>this._syncSelection(),m),p(()=>this.effectiveSelectionManager,`selection-change`,()=>this._syncSelection(),m)])}destroy(){this._drainColumns(),this.grid?.destroy(),this.columns.destroyed||this.columns.destroy(),this.layer=null,this.view=null}get _defaultHiddenFields(){return b(this.layer)}get _effectiveTableTemplate(){return this.tableTemplateOverride||this.tableTemplate}get _effectiveAttributeTableTemplate(){return this.attributeTableTemplate||this.layer?.attributeTableTemplate}get _subtypes(){return x(this.layer)}get actionColumn(){return super.actionColumn}get activeFilters(){let{filterGeometry:e,objectIds:t,filterBySelectionEnabled:n,highlightIds:r}=this,i=new a;return e&&i.push({type:`geometry`,geometry:e}),n?i.push({type:`selection`,objectIds:r.toArray()}):t.length&&i.push({type:`objectId`,objectIds:t.toArray()}),i}get activeSortOrders(){return this.grid?.sortOrders?this.grid.sortOrders.map(({path:e,direction:t})=>({fieldName:e,direction:t})).filter(e=>e.fieldName&&e.direction):[]}get allColumns(){return super.allColumns}get allRelatedTablesVisible(){return!!(this.relatedRecordsEnabled&&this.relatedTables.length&&this.showAllRelatedTables)}get allVisibleColumns(){return super.allVisibleColumns}get attachmentsColumns(){return this.allColumns.filter(e=>R(e))}get attachmentsEnabled(){return this.store.attachmentsEnabled}set attachmentsEnabled(e){this.store.attachmentsEnabled=e}get autoSaveEnabled(){return this.store.autoSaveEnabled}set autoSaveEnabled(e){this.store.autoSaveEnabled=e}get cachedPageCount(){return this.store.cachedPageCount}get canAddRelatedFeature(){return this.store.canAddRelatedFeature}get clearPrompt(){return()=>this.prompt=null}set clearPrompt(e){this._overrideIfSome(`clearPrompt`,e)}get defaultSelectionManager(){return this.store.defaultSelectionManager}get definitionExpression(){return this.store.where}set definitionExpression(e){this.store.where=e}get editingEnabled(){return super.editingEnabled}set editingEnabled(e){super.editingEnabled=e}get effectiveSelectionManager(){return this.store.effectiveSelectionManager}get effectiveMultipleSelectionEnabled(){return super.effectiveMultipleSelectionEnabled}get effectiveSize(){return super.effectiveSize}get effectiveTimeExtent(){return this.store.effectiveTimeExtent}get effectiveWhere(){return this.store.effectiveWhere}get fieldColumns(){return this.allColumns.filter(e=>z(e))}get filterByViewExtent(){return this.store.filterByViewExtent}set filterByViewExtent(e){this.store.filterByViewExtent=e}get filterByLayerScaleRange(){return this.store.filterByLayerScaleRange}set filterByLayerScaleRange(e){this.store.filterByLayerScaleRange=e}get filterGeometry(){return this.store.filterGeometry}set filterGeometry(e){this.store.filterGeometry=e}get filterBySelectionEnabled(){return!!this._get(`filterBySelectionEnabled`)}set filterBySelectionEnabled(e){let{objectIds:t}=this,n=t.length;e?(n&&(t.removeAll(),this._logWarning(`Selection filter has been applied with an objectID filter. Object ID filter has been removed.`)),this.filterGeometry&&this._logWarning(`Selection filter has been applied with a geometry filter. Results may appear inconsistent`),this._syncObjectIdsWithStore(this.highlightIds.toArray())):n||this._syncObjectIdsWithStore(null),this._set(`filterBySelectionEnabled`,e)}get groupColumns(){return super.groupColumns}get hasContingentValues(){return this.relatedTableHasContingentValues||this.store.hasContingentValues}get hasInvalidPendingEdits(){return this.relatedTableHasInvalidPendingEdits||this.store.hasInvalidPendingEdits}get hasPendingEdits(){return this.relatedTableHasPendingEdits||this.store.hasPendingEdits}get hiddenFields(){return this._get(`hiddenFields`)??new a}set hiddenFields(e){this._set(`hiddenFields`,o(e,this._get(`hiddenFields`),a))}get highlightEnabled(){return this.store.highlightEnabled}set highlightEnabled(e){this.store.highlightEnabled=e}get highlightIds(){return super.highlightIds}set highlightIds(e){super.highlightIds=e}get initialSize(){return this.store.initialSize}set initialSize(e){this.store.initialSize=e}get isEditing(){return super.isEditing}get isQuerying(){return super.isQuerying}get isSyncing(){return super.isSyncing}get isQueryingOrSyncing(){return this.isQuerying||this.isSyncing||this.relatedTables.some(e=>!!e.isQueryingOrSyncing)}get isSyncingAttachments(){return this.store.isSyncingAttachmentEdits||this.relatedTables.some(e=>!!e.isSyncingAttachments)}get layer(){return this._get(`layer`)}set layer(e){this.drainRelatedTables(),this._set(`layer`,e)}get layerFieldConfigurations(){let e=this.layer;return q(e)?e.fieldConfigurations:void 0}get layerView(){return this.store.layerView}get maxSize(){return super.maxSize}set maxSize(e){super.maxSize=e}get objectIds(){return super.objectIds}set objectIds(e){super.objectIds=e}get outFields(){return this.store.outFields}set outFields(e){this.store.outFields=e}get pageCount(){return super.pageCount}get pageIndex(){return super.pageIndex}set pageIndex(e){super.pageIndex=e}get pageSize(){return super.pageSize}set pageSize(e){super.pageSize=e}get paginationEnabled(){return super.paginationEnabled}set paginationEnabled(e){super.paginationEnabled=e}get pendingEditsCount(){return this.store.pendingEditsCount}get relatedRecordsEnabled(){return this.store.relatedRecordsEnabled}set relatedRecordsEnabled(e){this.store.relatedRecordsEnabled=e}get relatedTable(){return this.relatedTables.at(-1)}get relatedTableHasContingentValues(){return!!this.relatedTable?.hasContingentValues}get relatedTableHasInvalidPendingEdits(){return!!this.relatedTable?.hasInvalidPendingEdits}get relatedTableHasPendingEdits(){return!!this.relatedTable?.hasPendingEdits}get relationship(){return this.store.relationship}get relationshipColumns(){return this.allColumns.filter(e=>B(e))}get relationshipConfig(){return this.store.relationshipConfig}set relationshipConfig(e){this.highlightIds.removeAll(),this.objectIds.removeAll(),this.filterBySelectionEnabled=!1,this.store.relationshipConfig=e}get relationshipInfos(){let{layer:e,layers:t,relationships:n,tableController:r}=this,i=this.store.relationshipInfos;if(i.length||!J(e)||!n?.length)return i;let a=[],o=r?.layers||t||[];return n.forEach(t=>{let n=ee(e,o,t);n&&(n.load().catch(()=>{}),a.push({layer:e,relatedLayer:n,relationshipId:t.id}))}),a}get relationships(){return this.store.relationships}get returnGeometryEnabled(){return this.store.returnGeometry}set returnGeometryEnabled(e){this.store.returnGeometry=e}get returnMEnabled(){return this.store.returnM}set returnMEnabled(e){this.store.returnM=e}get returnZEnabled(){return this.store.returnZ}set returnZEnabled(e){this.store.returnZ=e}get rowHighlightIds(){return super.rowHighlightIds}set rowHighlightIds(e){super.rowHighlightIds=e}get selectionManager(){return this.store.selectionManager}set selectionManager(e){this.store.selectionManager=e}get selectionSource(){return`table`}set selectionSource(e){this.syncViewSelection=e===`view`,this._overrideIfSome(`selectionSource`,e)}get showAllRelatedTables(){return this._get(`showAllRelatedTables`)}set showAllRelatedTables(e){let{relatedTable:t}=this;this._set(`showAllRelatedTables`,e),t&&(e?this._showAllRelatedTables(t):this._hideAllRelatedTables(t))}get showPrompt(){return e=>{this.prompt?.cancel?.(),this.prompt=e}}set showPrompt(e){this._overrideIfSome(`showPrompt`,e)}get size(){return super.size}get state(){return super.state}get supportsAttachments(){return this.store.supportsAttachments}get supportsAddAttachments(){let{store:{supportsAddAttachments:e,supportsEditing:t}}=this;return this.editingEnabled&&t&&e}get supportsDeleteAttachments(){return this.supportsUpdateAttachments}get supportsResizeAttachments(){return this.store.supportsResizeAttachments}get supportsUpdateAttachments(){let{store:{supportsUpdateAttachments:e,supportsEditing:t}}=this;return this.editingEnabled&&t&&e}get syncViewSelection(){return this.store.syncViewSelection}set syncViewSelection(e){this.store.syncViewSelection=e}get timeExtent(){return this.store.timeExtent}set timeExtent(e){this.store.timeExtent=e}get timeZone(){return this.store.timeZone}set timeZone(e){this.store.timeZone=e}get view(){return this.store.view}set view(e){this.store.view=e,this.fieldColumns.forEach(t=>t.view=e),this.refreshCellContent()}get viewTimeEnabled(){return this.store.viewTimeEnabled}set viewTimeEnabled(e){this.store.viewTimeEnabled=e}get visibleColumns(){return super.visibleColumns}async addAttachment(e,t){let{attachmentsViewOptions:n,store:r}=this,i=n.objectId===e;await r.addAttachment(e,t).catch(e=>{i&&e&&typeof e==`object`&&`error`in e&&e.error instanceof s&&(this._logWarning(`Unable to add attachment. ${e.error.name} ${e.error.message}`),n.error=e.error)}),i&&!n.error&&(n.onEditComplete(),n.attachmentInfos=await r.getAttachmentsByObjectId(e,!0)),this.refreshCellContent()}addPendingEdits(e){this.store.addPendingEdits(e)}collapseRelatedTable(e,t){let{relatedLayer:n,objectId:r,relationshipId:i}=t,{objectIdField:o}=n,s=te(n,i),c=n.displayField||s?.keyField||o;e.set({highlightIds:new a([r]),multipleSelectionEnabledOverride:!1,tableTemplateOverride:this._getTableTemplateForRelatedTableView(e,c,i)});let l=e.hiddenFields;l.includes(Y.action)||l.add(Y.action),l.includes(Y.attachments)||l.add(Y.attachments),e.scrollLeft()}async deleteAttachments(e,t){let{attachmentsViewOptions:n,store:r}=this,i=n.objectId===e;await r.deleteAttachments(e,t).catch(e=>{i&&e&&typeof e==`object`&&`error`in e&&e.error instanceof s&&(this._logWarning(`Unable to delete attachment(s). ${e.error.name} ${e.error.message}`),n.error=e.error)}),i&&!n.error&&(n.onEditComplete(),n.attachmentInfos=await r.getAttachmentsByObjectId(e,!0)),this.refreshCellContent()}async deleteSelection(){let e=this.highlightIds.toArray();if(!e?.length)return;let{deleteFeatureResults:t}=await this.store.deleteRowsByObjectId(e),n=t.filter(e=>!e.error).map(e=>e.objectId);n.length&&(this.highlightIds.removeMany(n),await this.refresh())}async discardPendingEdits(e){return this.relatedTable&&this.relatedTableHasPendingEdits?this.relatedTable.discardPendingEdits(e):(this.store.discardPendingEdits(e),!0)}async downloadAttachmentById(e,t){let n=(await this.store.getAttachmentsByObjectId(e,!0)).find(e=>e.id===t);await V(n)}drainRelatedTables(){this.relatedTables.drain(e=>e.destroy()),this.set({multipleSelectionEnabledOverride:null,relationshipColumnConfigs:null,showAllRelatedTables:!1,tableTemplateOverride:null}),this.hiddenFields.removeMany([Y.action,Y.attachments])}drainRelatedTablesAboveIndex(e){let{relatedTables:t}=this,n=t.slice(e+1);t.removeMany(n).forEach(e=>e.destroy());let r=t.at(-1);r&&(r.attachmentsViewOptions.objectId=null,this.allRelatedTablesVisible?this._showAllRelatedTables(r):this._hideAllRelatedTables(r))}async exportSelectionToCSV(e){let{highlightIds:t,layer:n,outFields:r}=this;if(!n||!t.length){this._logWarning(`Export failed.`);return}await H({layer:n,objectIds:t.toArray(),outFields:r,includeGeometry:e})}getCachedFeaturesByPageIndex(e){return this.store.getCachedFeaturesByPageIndex(e)}getFeatureStoreItemByObjectId(e){return this.store.getItemByObjectId(e)}async getFeatureTitle(e,t){return this.store.getFeatureTitle(e,t)}getFeatureTitleSync(e){let t=this.layer;if(!t)return`${e}`;let n=`${t.objectIdField}: ${e}`;return e==null?n:this.store.featureTitleMap.get(e)??n}getObjectIdIndex(e){return this.store.getItemIndexByObjectId(e)}getValue(e,t){return this.getFeatureStoreItemByObjectId(e)?.feature?.attributes[t]}getVirtualPageIndex(){return this.grid?.getVirtualPageIndex()??0}goToPage(e){if(e==null||!Number.isInteger(e)){this._logWarning(`Invalid 'page' parameter provided to 'goToPage()'. Current page will remain the same.`);return}let{pageCount:t}=this;(e>=t||e===-1)&&(e=t-1),e<-1&&(e=0),e!==this.pageIndex&&(this.pageIndex=e),this.paginationEnabled||this.scrollToIndex(e*this.pageSize)}hideAttachmentsView(){this.attachmentsViewOptions.objectId=null,this.set({relationshipColumnConfigs:null,multipleSelectionEnabledOverride:null,tableTemplateOverride:null}),this.hiddenFields.remove(Y.action)}nextPage(){let e=this.paginationEnabled?this.pageIndex:this.getVirtualPageIndex();this.goToPage(e+1)}previousPage(){let e=this.paginationEnabled?this.pageIndex:this.getVirtualPageIndex();this.goToPage(e-1)}async refresh(){await Promise.all([...this.relatedTables.map(e=>e.refresh()),u(this._refreshDebounced())])}refreshCellContent(){this.grid?.requestContentUpdate()}refreshPageCache(){this.grid?.refreshPageCache()}async reset(){this.goToPage(0),await this.grid?.reset()}async savePendingEdits(){if(this.relatedTableHasPendingEdits&&!this.relatedTableHasInvalidPendingEdits){await this.relatedTable?.savePendingEdits();return}this.hasPendingEdits&&!this.relatedTable&&(await this.store.savePendingEdits(),await this.refresh())}scrollLeft(){this.grid?.scrollLeft(0)}scrollToBottom(){this.grid?.scrollToBottom()}scrollToIndex(e){this.grid?.scrollToIndex(e)}scrollToRow(e){let t=this.store.getItemIndexByObjectId(e);t>-1?this.grid?.scrollToIndex(t):this._logWarning(`Row not found. Associated data may not be loaded yet.`)}scrollToTop(){this.grid?.scrollToTop()}async saveAttachmentsViewForm(){let{attachmentId:e,form:t,objectId:n}=this.attachmentsViewOptions;n!=null&&t&&(e==null?await this.addAttachment(n,t):await this.updateAttachment(n,e,t))}async showAttachmentsView({objectId:e}){let{attachmentsViewOptions:t,hiddenFields:n,layer:r}=this;if(!this.attachmentsEnabled||!r){this._logWarning(`The 'attachmentsEnabled' property is currently false.`);return}await r.load();let i=this._getDefaultLayerDisplayField(r),o=await this.store.getAttachmentsByObjectId(e,!0),s=this.store.getItemIndexByObjectId(e);t.set({attachmentInfos:o,mode:o.length?`list`:`file`,objectId:e}),this.set({highlightIds:new a([e]),multipleSelectionEnabledOverride:!1,relationshipColumnConfigs:[],tableTemplateOverride:this._getTableTemplateForAttachmentsView(i)}),n.includes(Y.action)||n.add(Y.action),s!=null&&this.scrollToIndex(s)}syncAttributeTableTemplate(){this._syncAttributeTableTemplate(!0)}syncSelectionSources(){this.store.syncSelectionSources()}async updateAttachment(e,t,n){let{attachmentsViewOptions:r,store:i}=this,a=r.objectId===e;await i.updateAttachment(e,t,n).catch(e=>{a&&e&&typeof e==`object`&&`error`in e&&e.error instanceof s&&(this._logWarning(`Unable to update attachment. ${e.error.name} ${e.error.message}`),r.error=e.error)}),a&&!r.error&&(r.onEditComplete(),r.attachmentInfos=await i.getAttachmentsByObjectId(e,!0)),this.refreshCellContent()}async zoomToSelection(){let{layer:e,view:t}=this,n=this.highlightIds.toArray();if(!e||!t||!n.length)return;let r=e.createQuery();r.objectIds=n,r.returnGeometry=!0;let i=await e.queryFeatures(r);try{await ae(t,i.features)}catch(e){e.name!==`AbortError`&&console.error(e)}}_syncAttributeTableTemplate(e=!1){let{_effectiveAttributeTableTemplate:t,layer:n,tableTemplateOverride:r,syncTemplateOnChangesEnabled:i}=this;if(!n||!t||!i&&!e||r||this.tableParent||this.relatedTable||this.attachmentsViewOptions.objectId!==null)return;let a=JSON.stringify(t.toJSON());T(t,this.columns.toArray(),this.activeSortOrders),t===n.attributeTableTemplate&&JSON.stringify(t.toJSON())!==a&&(n.attributeTableTemplate=t.clone())}async _refresh(){await super.refresh();let e=this.highlightIds.toArray();e.length&&(await this.store.verifyFeaturesByObjectId(e)).forEach((t,n)=>{t||this.highlightIds.remove(e[n])}),this.refreshPageCache();let t=this.attachmentsViewOptions;t?.objectId!=null&&(t.attachmentInfos=await this.store.getAttachmentsByObjectId(t.objectId,!0))}async _onLayerLoad(){let{layer:e,pageSize:t}=this;if(!e)return;e.parent&&S(e.parent)&&await e.parent.loadAll();let n=e.capabilities.query?.maxRecordCount,r=n&&n<t,i=r?n:t;r&&(this._logWarning(`The value for 'pageSize' has been adjusted due to the provided layer's max record count.`),this.pageSize=i),this.grid?.set(`pageSize`,i);try{this._generateColumns(),await this.store.load(),this.refreshPageCache()}catch{c.getLogger(this).error(`Unable to load the provided layer.`)}}_onLayerRefresh(e){this.autoRefreshEnabled&&e.dataChanged&&this.refresh()}_generateColumns(){this._drainColumns();let{_effectiveTableTemplate:e,_effectiveAttributeTableTemplate:t,layer:n}=this,r=e?.columnTemplates;if(!n)return;let i=this._generateColumnsFromColumnTemplates(n,r)??this._generateColumnsFromAttributeTableTemplate(n,t)??this._generateDefaultFieldColumns(n);i.length&&(this.attachmentsEnabled&&!i.some(e=>R(e))&&i.push(this._generateDefaultAttachmentsColumn(n)),this.relatedRecordsEnabled&&this.relationshipInfos.length&&!i.some(e=>B(e))&&i.push(...this._generateDefaultRelationshipColumns()),this.actionColumnConfig&&i.push(this._generateActionColumn()),i.sort((e,t)=>e.frozen&&t.frozen||e.frozenToEnd&&t.frozenToEnd?0:e.frozen||t.frozenToEnd?-1:0),this.columns.addMany(i))}_generateColumnsFromAttributeTableTemplate(e,t){if(!t)return null;let{elements:n,orderByFields:r}=t,a=C(e),o=[];o.push(...this._generateColumnsFromAttributeTableElements(e,n,r));let s=a.map(t=>{if(!t.fieldName||ne(t.fieldName,o))return null;let{fieldName:n}=t,i=X(e,n);return i?this._generateDefaultFieldColumn(e,i,{hidden:!0,orderByFields:r}):(this._logTemplateWarning(`A valid 'field' could not be found for the provided template.`),null)}).filter(i);return o.push(...s),this.attachmentsEnabled&&re(e)&&!o.some(e=>R(e))&&o.push(this._generateDefaultAttachmentsColumn(e,{hidden:!0})),this.relatedRecordsEnabled&&J(e)&&e.relationships?.forEach(({id:e},t)=>{let n=this.relationshipInfos.find(t=>t.relationshipId===e);n&&!o.some(t=>B(t)&&t.relationshipId===e)&&o.push(this._generateDefaultRelationshipColumn({hidden:!0,info:n,index:t}))}),o.length?o:null}_generateColumnsFromAttributeTableElements(e,t,n){return t?.map((t,r)=>{switch(t.type){case`field`:return this._createFieldColumnFromElement({layer:e,element:t,orderByFields:n});case`group`:return this._createGroupColumnFromElement({layer:e,element:t,orderByFields:n});case`attachment`:return this._createAttachmentColumnFromElement({layer:e,element:t,index:r});case`relationship`:return this._createRelationshipColumnFromElement({element:t,index:r})}}).filter(e=>!!e)??[]}_createFieldColumnFromElement(e){let{layer:t,element:n,orderByFields:r}=e,{fieldName:i}=n;if(i==null)return this._logTemplateWarning(`A valid 'fieldName' must be provided.`),null;let a=X(t,i);if(!a)return this._logTemplateWarning(`A valid 'field' could not be found for the provided template.`),null;let{description:o,label:s}=n,c=r?.findIndex(({field:e})=>e&&e===i)??-1,l=c>-1?r?.at(c)?.order:void 0,u=c>-1?c:void 0,{grid:d,messages:f,messagesCommon:p,messagesURIUtils:m,store:h,view:g}=this;return new A({description:o,direction:l,field:a,fieldName:i,grid:d,initialSortPriority:u,label:s,layer:t,messages:f,messagesCommon:p,messagesURIUtils:m,store:h,view:g,onShowPromptCallback:this._onShowPromptCallback})}_createGroupColumnFromElement(e){let{layer:t,element:n,orderByFields:r}=e,{description:i,label:a}=n;if(!a)return this._logTemplateWarning(`Group columns require a label.`),null;if(!n.elements.length)return this._logTemplateWarning(`Group columns require child columns.`),null;let{grid:o,messages:s,messagesCommon:c,messagesURIUtils:l,store:u}=this;return new F({columns:this._generateColumnsFromAttributeTableElements(t,n.elements,r),description:i,grid:o,label:a,messages:s,messagesCommon:c,messagesURIUtils:l,store:u})}_createAttachmentColumnFromElement(e){if(!this.attachmentsEnabled){this._logTemplateWarning(`The 'attachmentsEnabled' property is currently false.`);return}let{layer:t,element:n,index:r}=e,{description:i,label:a}=n,{grid:o,messages:s,messagesCommon:c,messagesURIUtils:l,store:u}=this;return new k({description:i,fieldName:`${Y.attachments}-${r}`,grid:o,label:a,layer:t,messages:s,messagesCommon:c,messagesURIUtils:l,store:u,onShowAttachments:e=>this._onShowAttachments(e)})}_createRelationshipColumnFromElement(e){if(!this.relatedRecordsEnabled){this._logTemplateWarning(`Relationship columns require related records to be enabled on the table.`);return}let{element:t,index:n}=e,{description:r,label:i,relationshipId:a}=t,o=this.relationshipInfos.find(e=>e.relationshipId===a);if(!o)return this._logTemplateWarning(`Unable to find valid related layer target based on the provided relationship id.`),null;let{grid:s,messages:c,messagesCommon:l,messagesURIUtils:u,store:d}=this;return new j({description:r,fieldName:`${Y.relationship}-${a}-${n}`,grid:s,label:i,messages:c,messagesCommon:l,messagesURIUtils:u,relationshipId:a,store:d,layer:o.relatedLayer,relatedLayer:o.layer,showRelatedTableCallback:e=>this._onShowRelatedTable(e)})}_generateColumnsFromColumnTemplates(e,t){let{grid:n,messages:r,messagesCommon:i,messagesURIUtils:a,store:o,view:s}=this;if(!t?.length)return null;let c=[];return t.forEach((t,l)=>{let{autoWidth:u,description:d,direction:f,flexGrow:p,fieldName:m,formatFunction:h,frozen:g,frozenToEnd:_,icon:v,iconText:y,initialSortPriority:b,invalid:x,label:S,labelTooltipText:C,menuConfig:w,resizable:T,sortable:E,textAlign:D,textWrap:O,timeZone:k,type:j,width:N}=t;if(!j){this._logTemplateWarning(`Property 'type' is missing from the provided template.`);return}if(g&&_){this._logTemplateWarning(`Properties 'frozen' and 'frozenToEnd' cannot both be true for the same column.`);return}let P=t.visible===!1;if(j===`group`){if(!t.columnTemplates?.length){this._logTemplateWarning(`Group columns must contain column templates.`);return}if(!t.label){this._logTemplateWarning(`Group columns require a label.`);return}let o=this._generateColumnsFromColumnTemplates(e,t.columnTemplates),s=P||this._isFieldHidden(t.label);c.push(new F({autoWidth:u,columns:o,description:d,flexGrow:p,frozen:g,frozenToEnd:_,grid:n,hidden:s,icon:v,iconText:y,invalid:x,label:S,labelTooltipText:C,menuConfig:w,messages:r,messagesCommon:i,messagesURIUtils:a,resizable:T,textAlign:D,textWrap:O,timeZone:k,width:N}))}else if(j===`attachment`){if(!this.attachmentsEnabled){this._logTemplateWarning(`Attachment columns require attachments to be enabled on the table.`);return}c.push(this._generateAttachmentsColumnFromTemplate(e,t,l))}else if(j===`relationship`){if(!this.relatedRecordsEnabled){this._logTemplateWarning(`Relationship columns require related records to be enabled on the table.`);return}let{relationshipId:e}=t;if(e==null){this._logTemplateWarning(`Property 'relationshipId' is missing from the provided template.`);return}let n=this.relationshipInfos.find(t=>t.relationshipId===e);if(!n){this._logTemplateWarning(`Unable to find valid related layer target based on the provided relationship id.`);return}c.push(this._generateRelationshipColumnFromTemplate(n,t,l))}else if(!m){this._logTemplateWarning(`Value for 'fieldName' property was missing from the provided template.`);return}let I=P||this._isFieldHidden(m);if(j===`column`)c.push(new M({autoWidth:u,description:d,direction:f,fieldName:m,flexGrow:p,formatFunction:h,frozen:g,frozenToEnd:_,grid:n,hidden:I,icon:v,iconText:y,initialSortPriority:b,invalid:x,label:S,labelTooltipText:C,menuConfig:w,messages:r,messagesCommon:i,messagesURIUtils:a,resizable:T,sortable:E,store:o,textAlign:D,textWrap:O,timeZone:k,width:N}));else if(j===`field`){let l=X(e,t.fieldName);if(!l){this._logTemplateWarning(`A valid 'field' could not be found for the provided template.`);return}let{editable:m,required:j}=t;c.push(new A({autoWidth:u,description:d,direction:f,editable:m,field:l,fieldName:l.name,flexGrow:p,formatFunction:h,frozen:g,frozenToEnd:_,grid:n,hidden:I,icon:v,iconText:y,initialSortPriority:b,invalid:x,label:S,labelTooltipText:C,layer:e,messages:r,messagesCommon:i,messagesURIUtils:a,menuConfig:w,required:j,resizable:T,sortable:E,store:o,template:t,textAlign:D,textWrap:O,timeZone:k,width:N,view:s,onShowPromptCallback:this._onShowPromptCallback}))}}),c.length?c:null}_generateDefaultFieldColumns(e){return e.fields?.map(t=>this._generateDefaultFieldColumn(e,t)).filter(i)??[]}_generateDefaultFieldColumn(e,t,n){let{grid:r,messages:i,messagesCommon:a,messagesURIUtils:o,store:s,view:c}=this;if(!t.visible||t.type===`geometry`)return null;let l=n?.orderByFields,u=t.name,d=l?.findIndex(({field:e})=>e&&e===u)??-1,f=d>-1?l?.at(d)?.order:void 0,p=d>-1?d:void 0;return new A({direction:f,field:t,fieldName:u,grid:r,hidden:n?.hidden||this._isFieldHidden(u),initialSortPriority:p,layer:e,messages:i,messagesCommon:a,messagesURIUtils:o,store:s,view:c,onShowPromptCallback:this._onShowPromptCallback})}_generateAttachmentsColumnFromTemplate(e,t,n){let{grid:r,messages:i,messagesCommon:a,messagesURIUtils:o,store:s}=this,{attachmentsViewEnabled:c,autoWidth:l,description:u,flexGrow:d,fieldName:f,formatFunction:p,frozen:m,frozenToEnd:h,icon:g,iconText:_,invalid:v,label:y,labelTooltipText:b,menuConfig:x,resizable:S,textAlign:C,textWrap:w,thumbnailAppearance:T,thumbnailCount:E,thumbnailIconScale:D,thumbnailsEnabled:O,timeZone:A,width:j}=t;return new k({attachmentsViewEnabled:c,autoWidth:l,description:u,fieldName:`${Y.attachments}-${n}`,flexGrow:d,formatFunction:p,frozen:m,frozenToEnd:h,grid:r,hidden:t.visible===!1||this._isFieldHidden(y)||this._isFieldHidden(f),icon:g,iconText:_,invalid:v,label:y,labelTooltipText:b,layer:e,menuConfig:x,messages:i,messagesCommon:a,messagesURIUtils:o,resizable:S,store:s,textAlign:C,textWrap:w,thumbnailAppearance:T,thumbnailCount:E,thumbnailIconScale:D,thumbnailsEnabled:O,timeZone:A,width:j,onShowAttachments:e=>this._onShowAttachments(e)})}_generateDefaultAttachmentsColumn(e,t){let{grid:n,messages:r,messagesCommon:i,messagesURIUtils:a,store:o}=this,s=Y.attachments;return new k({fieldName:s,grid:n,hidden:t?.hidden||this._isFieldHidden(s),layer:e,messages:r,messagesCommon:i,messagesURIUtils:a,store:o,onShowAttachments:e=>this._onShowAttachments(e)})}_generateRelationshipColumnFromTemplate(e,t,n){let{grid:r,messages:i,messagesCommon:a,messagesURIUtils:o,store:s}=this,{autoWidth:c,collapsed:l,description:u,flexGrow:d,fieldName:f,formatFunction:p,frozen:m,frozenToEnd:h,icon:g,iconText:_,invalid:v,label:y,labelTooltipText:b,menuConfig:x,relationshipId:S,resizable:C,textAlign:w,textWrap:T,timeZone:E,width:D}=t;return new j({autoWidth:c,collapsed:l,description:u,fieldName:`${Y.relationship}-${S}-${n}`,flexGrow:d,formatFunction:p,frozen:m,frozenToEnd:h,grid:r,hidden:t.visible===!1||this._isFieldHidden(y)||this._isFieldHidden(f),icon:g,iconText:_,invalid:v,label:y,labelTooltipText:b,menuConfig:x,messages:i,messagesCommon:a,messagesURIUtils:o,relationshipId:S,resizable:C,store:s,textAlign:w,textWrap:T,timeZone:E,width:D,layer:e.relatedLayer,relatedLayer:e.layer,showRelatedTableCallback:e=>this._onShowRelatedTable(e)})}_generateDefaultRelationshipColumns(){let{relationshipInfos:e,relationshipColumnConfigs:t}=this,n=[];return e?.length&&(t?t.forEach((t,r)=>{let{relationshipId:i}=t,a=e.find(e=>e.relationshipId===i);a&&n.push(this._generateDefaultRelationshipColumn({config:t,index:r,info:a}))}):e.forEach((e,t)=>n.push(this._generateDefaultRelationshipColumn({index:t,info:e})))),n}_generateDefaultRelationshipColumn(e){let{config:t,hidden:n,index:r,info:i}=e,{grid:a,messages:o,messagesCommon:s,messagesURIUtils:c,store:l}=this,{relationshipId:u}=i;return new j({...t,fieldName:`${Y.relationship}-${u}-${r}`,grid:a,hidden:!!n,messages:o,messagesCommon:s,messagesURIUtils:c,layer:i.relatedLayer,relatedLayer:i.layer,relationshipId:u,store:l,showRelatedTableCallback:e=>this._onShowRelatedTable(e)})}_generateActionColumn(){let e=this.actionColumnConfig,t=e?.frozen===!0?!1:e?.frozenToEnd??!0;return new O({hidden:this._isFieldHidden(Y.action),store:this.store,...e,frozenToEnd:t})}_isFieldHidden(e){let t=e?.toLowerCase();return(this.hiddenFields??this._defaultHiddenFields).some(e=>e.toLowerCase()===t)}_syncSelection(){let{layer:e}=this;D(e)?this.highlightIds.items=this.effectiveSelectionManager.getSelection(e)??[]:this.highlightIds.removeAll()}_addToSelection(e){let t=this.layer;D(t)&&this.effectiveSelectionManager.add(t,e)}_removeFromSelection(e){let t=this.layer;D(t)&&this.effectiveSelectionManager.remove(t,e)}async _onHighlightIdsChange(e){let{added:t,removed:n}=e,{attachmentsViewOptions:r}=this;if(this._removeFromSelection(n),this._addToSelection(t),this.filterBySelectionEnabled&&this._syncObjectIdsWithStore(this.highlightIds.toArray()),r.objectId!=null){let e=this.highlightIds.at(0);if(e!=null){let t=await this.store.getAttachmentsByObjectId(e,!0);r.set({attachmentInfos:t,objectId:e,mode:t.length?`list`:`file`}),this.getFeatureTitle(e)}}}_syncTableParentSelection(e){let{tableParent:t}=this;t&&e!=null&&t.highlightIds.add(e)}_onShowRelatedTable(e){let{highlightIds:t}=this,{objectId:n}=e;if(t.removeAll(),t.add(n),this.showRelatedTableCallback){this.showRelatedTableCallback(e);return}this.emit(`show-related-table`,e)}_onObjectIdsChange(){let e=this.objectIds.toArray();e.length&&this.filterBySelectionEnabled&&(this.filterBySelectionEnabled=!1,this._logWarning(`Object ID filter was applied while a selection filter was applied. Selection filter has been removed.`)),this._syncObjectIdsWithStore(e)}_syncObjectIdsWithStore(e){this.store.objectIds=e,this.refreshPageCache()}_drainColumns(){this.columns.drain(e=>!e.destroyed&&e.destroy())}_showAllRelatedTables(e){let t=e.layer;if(!t)return;let n=this._getDefaultLayerDisplayField(t);e.set({relationshipColumnConfigs:[],tableTemplateOverride:this._getTableTemplateForShowAllTablesView(e,n)});let r=e.hiddenFields;r.includes(Y.action)||r.add(Y.action),r.includes(Y.attachments)||r.add(Y.attachments)}_hideAllRelatedTables(e){let{layer:t,relationship:n}=e;if(t&&n?.id!=null){if(e.attachmentsViewOptions.objectId!=null){let n=this._getDefaultLayerDisplayField(t);e.set({multipleSelectionEnabledOverride:!1,relationshipColumnConfigs:[],showAllRelatedTables:!1,tableTemplateOverride:this._getTableTemplateForAttachmentsView(n)})}else e.set({multipleSelectionEnabledOverride:null,relationshipColumnConfigs:ie(t,n.id),showAllRelatedTables:!1,tableTemplateOverride:null}),e.hiddenFields.removeMany([Y.action,Y.attachments])}}_getTableTemplateForRelatedTableView(e,t,n){return new K({columnTemplates:[new W({fieldName:t,editable:!1,menuConfig:{selectionMode:`single`,icon:`chevron-down`,items:this._extractFieldColumnInfosFromTableTemplate(e.viewModel).map(([r,i])=>({selected:r===t,label:i||r,clickFunction:()=>{e.tableTemplateOverride=this._getTableTemplateForRelatedTableView(e,r,n)}}))},resizable:!1}),new G({autoWidth:!1,collapsed:!0,flexGrow:0,label:``,resizable:!1,relationshipId:n,width:Q})]})}_getTableTemplateForShowAllTablesView(e,t){let n=[new W({fieldName:t,editable:!1,menuConfig:{selectionMode:`single`,icon:`chevron-down`,items:this._extractFieldColumnInfosFromTableTemplate(e.viewModel).map(([n,r])=>({selected:n===t,label:r||n,clickFunction:()=>{e.tableTemplateOverride=this._getTableTemplateForShowAllTablesView(e,n)}}))},resizable:!1})];return e.attachmentsViewOptions.objectId!=null&&n.push(new I({attachmentsViewEnabled:!1,autoWidth:!1,flexGrow:0,label:``,resizable:!1,thumbnailsEnabled:!1,width:Q})),new K({columnTemplates:n})}async _onShowPromptCallback(e){let{column:t,objectId:n,oldValue:r,value:i}=e,{_subtypes:a,layer:o}=this;if(!o||!a.length){t.cancel();return}let s=a.find(e=>e.code===i);if(!s){t.cancel();return}let c=Promise.withResolvers(),l=this._createSubtypeEditPrompt(r,s,c),u=!!o.parent&&this.autoSaveEnabled;try{this.showPrompt(l);let e=await c.promise,r=[{fieldName:t.fieldName,value:i}];switch(e){case`update-fields`:for(let[e,t]of Object.entries(s.defaultValues))t!=null&&r.push({fieldName:e,value:t});await t.updateItems({objectId:n,updates:r}),u&&this.refresh();break;case`keep-existing`:await t.updateItems({objectId:n,updates:r}),u&&this.refresh();break;case`undo`:t.cancel()}}finally{this.clearPrompt()}}_createSubtypeEditPrompt(e,t,r){let{_subtypes:i,messages:a,messagesCommon:o}=this,s=i.find(t=>t.code===e)?.name??`${e}`,c=`update-fields`,l=[{label:a.subtypes.useDefaultValuesOption,value:`update-fields`},{label:a.subtypes.keepCurrentValuesOption,value:`keep-existing`}];return{context:`info`,title:a.subtypes.changeWarningTitle,message:n(a.subtypes.changeWarning,{originalType:s,newType:t.name}),radios:l,defaultRadioSelection:`update-fields`,onRadioSelection:e=>{c=e},actions:{primary:{label:o.apply,action:()=>r.resolve(c),type:`positive`},secondary:{label:o.cancel,type:`neutral`,action:()=>r.resolve(`undo`)}},cancel:()=>r.reject()}}_onShowAttachments({objectId:e}){this.hasPendingEdits||(this.attachmentsViewOptions.objectId=e)}_getTableTemplateForAttachmentsView(e){return new K({columnTemplates:[new W({fieldName:e,editable:!1,menuConfig:{selectionMode:`single`,icon:`chevron-down`,items:this._extractFieldColumnInfosFromTableTemplate(this).map(([t,n])=>({selected:t===e,label:n||t,clickFunction:()=>{this.tableTemplateOverride=this._getTableTemplateForAttachmentsView(t)}}))},resizable:!1}),new I({attachmentsViewEnabled:!1,autoWidth:!1,flexGrow:0,label:``,resizable:!1,thumbnailsEnabled:!1,width:Q})]})}_extractFieldColumnInfosFromTableTemplate(e){let{layer:t,tableTemplate:n}=e??this;return n?n.columnTemplates.filter(({type:e})=>e===`field`||e===`column`).map(({fieldName:e,label:n})=>{if(n!=null&&n!==``)return[e,n];let r=t?.fieldsIndex.get(e);return[e,r&&v(r,t)]}):t?.fields.map(e=>[e.name,v(e,t)])??[]}_getDefaultLayerDisplayField(e){let{displayField:t,objectIdField:n}=e;return t&&t.trim()!==``?t:n||(e.fields.length?e.fields[0].name:``)}_getIndexOfFirstFrozenToEndColumn(){let e=this.columns.findIndex(e=>e.frozenToEnd);return e>-1?e:void 0}_logWarning(e,t){t?c.getLogger(this).warnOnce(e):c.getLogger(this).warn(e)}_logTemplateWarning(e){this._logWarning(`${e} Skipped generating a column using the provided template.`,!0)}_onCellInteraction(e){e!=null&&this.attachmentsViewOptions.objectId!=null&&this.highlightIds.add(e)}};e([g()],$.prototype,`_defaultHiddenFields`,null),e([g()],$.prototype,`_effectiveTableTemplate`,null),e([g()],$.prototype,`_effectiveAttributeTableTemplate`,null),e([g()],$.prototype,`_subtypes`,null),e([g()],$.prototype,`activeFilters`,null),e([g({readOnly:!0})],$.prototype,`activeSortOrders`,null),e([g()],$.prototype,`allRelatedTablesVisible`,null),e([g()],$.prototype,`attachmentsColumns`,null),e([g()],$.prototype,`attachmentsEnabled`,null),e([g()],$.prototype,`attachmentsViewOptions`,void 0),e([g({type:w})],$.prototype,`attributeTableTemplate`,void 0),e([g()],$.prototype,`autoRefreshEnabled`,void 0),e([g()],$.prototype,`autoSaveEnabled`,null),e([g()],$.prototype,`cachedPageCount`,null),e([g()],$.prototype,`canAddRelatedFeature`,null),e([g()],$.prototype,`clearPrompt`,null),e([g({readOnly:!0})],$.prototype,`columns`,void 0),e([g()],$.prototype,`dataProvider`,void 0),e([g()],$.prototype,`defaultSelectionManager`,null),e([g()],$.prototype,`definitionExpression`,null),e([g()],$.prototype,`effectiveSelectionManager`,null),e([g()],$.prototype,`effectiveTimeExtent`,null),e([g()],$.prototype,`effectiveWhere`,null),e([g()],$.prototype,`fieldColumns`,null),e([g()],$.prototype,`filterByViewExtent`,null),e([g()],$.prototype,`filterByLayerScaleRange`,null),e([g({types:y})],$.prototype,`filterGeometry`,null),e([g()],$.prototype,`filterBySelectionEnabled`,null),e([g({readOnly:!0})],$.prototype,`grid`,void 0),e([g()],$.prototype,`hasContingentValues`,null),e([g()],$.prototype,`hasInvalidPendingEdits`,null),e([g()],$.prototype,`hasPendingEdits`,null),e([g()],$.prototype,`hiddenFields`,null),e([g()],$.prototype,`highlightEnabled`,null),e([g()],$.prototype,`initialSize`,null),e([g()],$.prototype,`isQueryingOrSyncing`,null),e([g()],$.prototype,`isSyncingAttachments`,null),e([g()],$.prototype,`layer`,null),e([g()],$.prototype,`layers`,void 0),e([g()],$.prototype,`layerFieldConfigurations`,null),e([g()],$.prototype,`layerView`,null),e([g()],$.prototype,`menuConfig`,void 0),e([g()],$.prototype,`messages`,void 0),e([g(),Z(`esri/t9n/common`)],$.prototype,`messagesCommon`,void 0),e([g(),Z(`esri/core/t9n/Units`)],$.prototype,`messagesUnits`,void 0),e([g(),Z(`esri/widgets/support/t9n/uriUtils`)],$.prototype,`messagesURIUtils`,void 0),e([g()],$.prototype,`outFields`,null),e([g()],$.prototype,`pendingEditsCount`,null),e([g()],$.prototype,`prompt`,void 0),e([g()],$.prototype,`relatedRecordsEnabled`,null),e([g()],$.prototype,`relatedTable`,null),e([g()],$.prototype,`relatedTableHasContingentValues`,null),e([g()],$.prototype,`relatedTables`,void 0),e([g()],$.prototype,`relationship`,null),e([g()],$.prototype,`relationshipColumnConfigs`,void 0),e([g()],$.prototype,`relationshipColumns`,null),e([g()],$.prototype,`relationshipConfig`,null),e([g()],$.prototype,`relationshipInfos`,null),e([g()],$.prototype,`relationships`,null),e([g()],$.prototype,`returnGeometryEnabled`,null),e([g()],$.prototype,`returnMEnabled`,null),e([g()],$.prototype,`returnZEnabled`,null),e([g()],$.prototype,`selectionManager`,null),e([g()],$.prototype,`selectionSource`,null),e([g()],$.prototype,`showAllRelatedTables`,null),e([g()],$.prototype,`showPrompt`,null),e([g()],$.prototype,`showRelatedTableCallback`,void 0),e([g({readOnly:!0,type:U})],$.prototype,`store`,void 0),e([g()],$.prototype,`supportsAttachments`,null),e([g()],$.prototype,`supportsAddAttachments`,null),e([g()],$.prototype,`supportsDeleteAttachments`,null),e([g()],$.prototype,`supportsResizeAttachments`,null),e([g()],$.prototype,`supportsUpdateAttachments`,null),e([g()],$.prototype,`syncTemplateOnChangesEnabled`,void 0),e([g()],$.prototype,`syncViewSelection`,null),e([g()],$.prototype,`tableController`,void 0),e([g()],$.prototype,`tableParent`,void 0),e([g({type:K})],$.prototype,`tableTemplate`,void 0),e([g()],$.prototype,`tableTemplateOverride`,void 0),e([g({type:E})],$.prototype,`timeExtent`,null),e([g()],$.prototype,`timeZone`,null),e([g()],$.prototype,`view`,null),e([g()],$.prototype,`viewTimeEnabled`,null),$=e([_(`esri.widgets.FeatureTable.FeatureTableViewModel`)],$);const oe=$;export{oe as default};
|
|
2
|
+
import{__decorate as e}from"tslib";import{onLocaleChange as t,substitute as n,fetchMessageBundle as r}from"../../intl.js";import{isSome as i}from"../../core/arrayUtils.js";import a from"../../core/Collection.js";import{referenceSetter as o}from"../../core/collectionUtils.js";import s from"../../core/Error.js";import c from"../../core/Logger.js";import{debounce as l,ignoreAbortErrors as u}from"../../core/promiseUtils.js";import{watch as d,initial as f,on as p,syncAndInitial as m}from"../../core/reactiveUtils.js";import{throttle as h}from"../../core/throttle.js";import{property as g,subclass as _}from"../../core/accessorSupport/decorators.js";import{getEffectiveFieldAlias as v}from"../../editing/fieldUtils.js";import{geometryTypes as y}from"../../geometry/support/typeUtils.js";import{getLowerCaseDefaultHiddenFields as b}from"../../layers/support/fieldUtils.js";import{getSubtypesFromLayer as x,isSubtypeGroupLayer as S}from"../../layers/support/layerUtils.js";import{createFieldInfos as C}from"../../support/popupUtils.js";import w from"../../tables/AttributeTableTemplate.js";import{syncAttributeTableTemplateWithColumns as T}from"../../tables/support/templateUtils.js";import E from"../../time/TimeExtent.js";import{isSelectableLayerWithObjectIds as D}from"../../views/support/selectionUtils.js";import O from"./ActionColumn.js";import k from"./AttachmentsColumn.js";import A from"./FieldColumn.js";import j from"./RelationshipColumn.js";import M from"./Grid/Column.js";import N from"./Grid/Grid.js";import P from"./Grid/GridViewModel.js";import F from"./Grid/GroupColumn.js";import I from"./support/AttachmentsColumnTemplate.js";import L from"./support/AttachmentsViewOptions.js";import{isAttachmentsColumn as R,isFieldColumn as z,isRelationshipColumn as B}from"./support/columnUtils.js";import{downloadAttachmentInfo as V,exportToCSV as H}from"./support/exportUtils.js";import U from"./support/FeatureStore.js";import W from"./support/FieldColumnTemplate.js";import G from"./support/RelationshipColumnTemplate.js";import K from"./support/TableTemplate.js";import{isIFeatureTableSupportedLayerWithFieldConfigurations as q,isIFeatureTableSupportedLayerWithRelationships as J,findRelatedLayerInSources as ee,findRelationship as te,uniqueColumnNames as Y,hasColumnForField as ne,findField as X,isIFeatureTableSupportedLayerWithAttachments as re,getRelationshipIdsToShow as ie}from"./support/tableUtils.js";import{goTo as ae}from"../support/goToUtils.js";import{messageBundle as Z}from"../support/widget.js";const Q=`80px`;let $=class extends P{constructor(e){super(e),this._refreshDebounced=l(()=>this._refresh()),this._syncTemplateThrottled=h(()=>this._syncAttributeTableTemplate()),this.attachmentsViewOptions=new L,this.attributeTableTemplate=null,this.autoRefreshEnabled=!0,this.columns=new a,this.dataProvider=async(e,t)=>{let{layer:n,store:r}=this;if(!t)return;if(!n||!r){t&&t([]);return}try{await n.load()}catch{return}let{objectIds:i}=this;if(this.filterBySelectionEnabled&&!this.highlightIds.length||i.length===1&&i.items[0]===-1){t([]);return}if(r.state!==`loaded`&&r.state!==`loading`)try{await r.load()}catch{return}let a=this.paginationEnabled?this.pageIndex:e.page;try{let n=await r.queryPage({...e,pageIndex:a});t?.(n)}catch{return}},this.grid=null,this.layers=null,this.menuConfig=null,this.messages=null,this.messagesCommon=null,this.messagesUnits=null,this.messagesURIUtils=null,this.prompt=null,this.relatedTables=new a,this.relationshipColumnConfigs=null,this.showRelatedTableCallback=null,this.store=null,this.syncTemplateOnChangesEnabled=!0,this.tableController=null,this.tableParent=null,this.tableTemplate=null,this.tableTemplateOverride=null,this._onLayerRefresh=this._onLayerRefresh.bind(this),this._onShowPromptCallback=this._onShowPromptCallback.bind(this),this._set(`store`,new U),this._set(`grid`,new N({viewModel:this}))}initialize(){let e=async()=>{this.messages=await r(`esri/widgets/FeatureTable/t9n/FeatureTable`),this.messagesCommon=await r(`esri/t9n/common`),this.messagesUnits=await r(`esri/core/t9n/Units`),this.messagesURIUtils=await r(`esri/widgets/support/t9n/uriUtils`)};e(),this.addHandles([t(()=>{e(),this._generateColumns()}),d(()=>[this.messages,this.messagesCommon,this.messagesURIUtils],()=>{let e=this.messages;this.grid&&(this.grid.messages=e),this.allColumns.forEach(t=>{t.messages=e,t.messagesCommon=this.messagesCommon,t.messagesURIUtils=this.messagesURIUtils}),this.refreshCellContent()},f),d(()=>this.attachmentsEnabled,()=>this.layer?.loaded&&this._generateColumns()),d(()=>this.layer,async(e,t)=>{let n=this.grid;n&&(n.clearSort(),e&&t&&await this.reset()),this.goToPage(0),this._drainColumns(),this.store.layer=e,e&&(e.loaded?this._onLayerLoad().catch(()=>{}):e.load().catch(()=>{})),this.syncViewSelection&&this._syncSelection(),t&&this.attachmentsViewOptions.objectId!=null&&(this.attachmentsViewOptions.objectId=null)}),d(()=>this.layer?.loaded,e=>{e&&this._onLayerLoad().catch(()=>{})}),d(()=>this.store.state,e=>{e===`loaded`&&(this.scrollToTop(),this.refreshCellContent())}),d(()=>this._effectiveTableTemplate,()=>{this.scrollLeft(),this.layer?.loaded&&this._generateColumns()}),d(()=>this.editingEnabled,()=>this.refreshCellContent()),d(()=>this.timeZone??this.view?.timeZone,()=>this.refreshCellContent()),d(()=>this.effectiveWhere,()=>{this.store.state===`loaded`&&this.reset().catch(()=>{})}),d(()=>this.effectiveTimeExtent,()=>void this.refresh()),p(()=>this.layer,`refresh`,e=>this._onLayerRefresh(e)),p(()=>this.grid,[`cell-click`,`cell-dblclick`,`cell-pointerover`,`cell-pointerout`,`cell-keydown`,`column-reorder`],({index:e,item:t,native:n,path:r,type:i})=>{let a=t?.feature,o=a?.getObjectId(),s=i===`cell-keydown`&&n&&n instanceof KeyboardEvent&&n.key===`Enter`;this.emit(i,{feature:a,index:e,native:n,type:i,fieldName:r??void 0,objectId:o}),(s||i===`cell-click`)&&this._onCellInteraction(o)}),d(()=>this.actionColumnConfig,e=>{let{actionColumn:t,columns:n}=this;t?e?t.set(e):n.remove(t):e&&n.length&&n.add(this._generateActionColumn(),e.frozenToEnd===!1?this._getIndexOfFirstFrozenToEndColumn():void 0)}),d(()=>this.relatedRecordsEnabled,()=>this.layer?.loaded&&this._generateColumns()),p(()=>this.objectIds,`change`,()=>this._onObjectIdsChange(),{onListenerAdd:()=>this._onObjectIdsChange()}),d(()=>[this.paginationEnabled,this.pageIndex],()=>this.refreshPageCache()),d(()=>this.activeSortOrders,e=>{this.store.sortOrders=e,this._syncTemplateThrottled()}),d(()=>this.allVisibleColumns,()=>this._syncTemplateThrottled()),d(()=>this.pageCount,()=>{this.pageIndex>=this.pageCount&&this.goToPage(0)}),d(()=>this.state,e=>{e===`disabled`&&this.relatedTables.length&&this.drainRelatedTables()}),p(()=>this.tableParent?.highlightIds,`change`,({added:e})=>{let{relationshipConfig:t}=this,n=e[0];if(n==null||!t)return;let{relatedLayer:r,relationshipId:i}=t;this.relationshipConfig={objectId:n,relatedLayer:r,relationshipId:i}}),p(()=>this.tableParent,`cell-click`,async e=>{let{objectId:t}=e;this.tableController&&this.hasPendingEdits?await this.tableController.discardPendingEdits(void 0,!0).then(e=>e&&this._syncTableParentSelection(t)):this._syncTableParentSelection(t)}),d(()=>this.attachmentsViewOptions.objectId,(e,t)=>{if(e==null){this.hideAttachmentsView();return}t??this.showAttachmentsView({objectId:e})}),d(()=>[this.layerFieldConfigurations,this.pendingEditsCount],()=>this.refreshCellContent()),p(()=>this.highlightIds,`change`,e=>this._onHighlightIdsChange(e),{onListenerAdd:()=>this._syncSelection(),onListenerRemove:()=>this.defaultSelectionManager.clear()}),d(()=>this.effectiveSelectionManager,()=>this._syncSelection(),m),p(()=>this.effectiveSelectionManager,`selection-change`,()=>this._syncSelection(),m)])}destroy(){this._drainColumns(),this.grid?.destroy(),this.columns.destroyed||this.columns.destroy(),this.layer=null,this.view=null}get _defaultHiddenFields(){return b(this.layer)}get _effectiveTableTemplate(){return this.tableTemplateOverride||this.tableTemplate}get _effectiveAttributeTableTemplate(){return this.attributeTableTemplate||this.layer?.attributeTableTemplate}get _subtypes(){return x(this.layer)}get actionColumn(){return super.actionColumn}get activeFilters(){let{filterGeometry:e,objectIds:t,filterBySelectionEnabled:n,highlightIds:r}=this,i=new a;return e&&i.push({type:`geometry`,geometry:e}),n?i.push({type:`selection`,objectIds:r.toArray()}):t.length&&i.push({type:`objectId`,objectIds:t.toArray()}),i}get activeSortOrders(){return this.grid?.sortOrders?this.grid.sortOrders.map(({path:e,direction:t})=>({fieldName:e,direction:t})).filter(e=>e.fieldName&&e.direction):[]}get allColumns(){return super.allColumns}get allRelatedTablesVisible(){return!!(this.relatedRecordsEnabled&&this.relatedTables.length&&this.showAllRelatedTables)}get allVisibleColumns(){return super.allVisibleColumns}get attachmentsColumns(){return this.allColumns.filter(e=>R(e))}get attachmentsEnabled(){return this.store.attachmentsEnabled}set attachmentsEnabled(e){this.store.attachmentsEnabled=e}get autoSaveEnabled(){return this.store.autoSaveEnabled}set autoSaveEnabled(e){this.store.autoSaveEnabled=e}get cachedPageCount(){return this.store.cachedPageCount}get canAddRelatedFeature(){return this.store.canAddRelatedFeature}get clearPrompt(){return()=>this.prompt=null}set clearPrompt(e){this._overrideIfSome(`clearPrompt`,e)}get defaultSelectionManager(){return this.store.defaultSelectionManager}get definitionExpression(){return this.store.where}set definitionExpression(e){this.store.where=e}get editingEnabled(){return super.editingEnabled}set editingEnabled(e){super.editingEnabled=e}get effectiveSelectionManager(){return this.store.effectiveSelectionManager}get effectiveMultipleSelectionEnabled(){return super.effectiveMultipleSelectionEnabled}get effectiveSize(){return super.effectiveSize}get effectiveTimeExtent(){return this.store.effectiveTimeExtent}get effectiveWhere(){return this.store.effectiveWhere}get fieldColumns(){return this.allColumns.filter(e=>z(e))}get filterByViewExtent(){return this.store.filterByViewExtent}set filterByViewExtent(e){this.store.filterByViewExtent=e}get filterByLayerScaleRange(){return this.store.filterByLayerScaleRange}set filterByLayerScaleRange(e){this.store.filterByLayerScaleRange=e}get filterGeometry(){return this.store.filterGeometry}set filterGeometry(e){this.store.filterGeometry=e}get filterBySelectionEnabled(){return!!this._get(`filterBySelectionEnabled`)}set filterBySelectionEnabled(e){let{objectIds:t}=this,n=t.length;e?(n&&(t.removeAll(),this._logWarning(`Selection filter has been applied with an objectID filter. Object ID filter has been removed.`)),this.filterGeometry&&this._logWarning(`Selection filter has been applied with a geometry filter. Results may appear inconsistent`),this._syncObjectIdsWithStore(this.highlightIds.toArray())):n||this._syncObjectIdsWithStore(null),this._set(`filterBySelectionEnabled`,e)}get groupColumns(){return super.groupColumns}get hasContingentValues(){return this.relatedTableHasContingentValues||this.store.hasContingentValues}get hasInvalidPendingEdits(){return this.relatedTableHasInvalidPendingEdits||this.store.hasInvalidPendingEdits}get hasPendingEdits(){return this.relatedTableHasPendingEdits||this.store.hasPendingEdits}get hiddenFields(){return this._get(`hiddenFields`)??new a}set hiddenFields(e){this._set(`hiddenFields`,o(e,this._get(`hiddenFields`),a))}get highlightEnabled(){return this.store.highlightEnabled}set highlightEnabled(e){this.store.highlightEnabled=e}get highlightIds(){return super.highlightIds}set highlightIds(e){super.highlightIds=e}get initialSize(){return this.store.initialSize}set initialSize(e){this.store.initialSize=e}get isEditing(){return super.isEditing}get isQuerying(){return super.isQuerying}get isSyncing(){return super.isSyncing}get isQueryingOrSyncing(){return this.isQuerying||this.isSyncing||this.relatedTables.some(e=>!!e.isQueryingOrSyncing)}get isSyncingAttachments(){return this.store.isSyncingAttachmentEdits||this.relatedTables.some(e=>!!e.isSyncingAttachments)}get layer(){return this._get(`layer`)}set layer(e){this.drainRelatedTables(),this._set(`layer`,e)}get layerFieldConfigurations(){let e=this.layer;return q(e)?e.fieldConfigurations:void 0}get layerView(){return this.store.layerView}get maxSize(){return super.maxSize}set maxSize(e){super.maxSize=e}get objectIds(){return super.objectIds}set objectIds(e){super.objectIds=e}get outFields(){return this.store.outFields}set outFields(e){this.store.outFields=e}get pageCount(){return super.pageCount}get pageIndex(){return super.pageIndex}set pageIndex(e){super.pageIndex=e}get pageSize(){return super.pageSize}set pageSize(e){super.pageSize=e}get paginationEnabled(){return super.paginationEnabled}set paginationEnabled(e){super.paginationEnabled=e}get pendingEditsCount(){return this.store.pendingEditsCount}get relatedRecordsEnabled(){return this.store.relatedRecordsEnabled}set relatedRecordsEnabled(e){this.store.relatedRecordsEnabled=e}get relatedTable(){return this.relatedTables.at(-1)}get relatedTableHasContingentValues(){return!!this.relatedTable?.hasContingentValues}get relatedTableHasInvalidPendingEdits(){return!!this.relatedTable?.hasInvalidPendingEdits}get relatedTableHasPendingEdits(){return!!this.relatedTable?.hasPendingEdits}get relationship(){return this.store.relationship}get relationshipColumns(){return this.allColumns.filter(e=>B(e))}get relationshipConfig(){return this.store.relationshipConfig}set relationshipConfig(e){this.highlightIds.removeAll(),this.objectIds.removeAll(),this.filterBySelectionEnabled=!1,this.store.relationshipConfig=e}get relationshipInfos(){let{layer:e,layers:t,relationships:n,tableController:r}=this,i=this.store.relationshipInfos;if(i.length||!J(e)||!n?.length)return i;let a=[],o=r?.layers||t||[];return n.forEach(t=>{let n=ee(e,o,t);n&&(n.load().catch(()=>{}),a.push({layer:e,relatedLayer:n,relationshipId:t.id}))}),a}get relationships(){return this.store.relationships}get returnGeometryEnabled(){return this.store.returnGeometry}set returnGeometryEnabled(e){this.store.returnGeometry=e}get returnMEnabled(){return this.store.returnM}set returnMEnabled(e){this.store.returnM=e}get returnZEnabled(){return this.store.returnZ}set returnZEnabled(e){this.store.returnZ=e}get rowHighlightIds(){return super.rowHighlightIds}set rowHighlightIds(e){super.rowHighlightIds=e}get selectionManager(){return this.store.selectionManager}set selectionManager(e){this.store.selectionManager=e}get selectionSource(){return`table`}set selectionSource(e){this.syncViewSelection=e===`view`,this._overrideIfSome(`selectionSource`,e)}get showAllRelatedTables(){return this._get(`showAllRelatedTables`)}set showAllRelatedTables(e){let{relatedTable:t}=this;this._set(`showAllRelatedTables`,e),t&&(e?this._showAllRelatedTables(t):this._hideAllRelatedTables(t))}get showPrompt(){return e=>{this.prompt?.cancel?.(),this.prompt=e}}set showPrompt(e){this._overrideIfSome(`showPrompt`,e)}get size(){return super.size}get state(){return super.state}get supportsAttachments(){return this.store.supportsAttachments}get supportsAddAttachments(){let{store:{supportsAddAttachments:e,supportsEditing:t}}=this;return this.editingEnabled&&t&&e}get supportsDeleteAttachments(){return this.supportsUpdateAttachments}get supportsResizeAttachments(){return this.store.supportsResizeAttachments}get supportsUpdateAttachments(){let{store:{supportsUpdateAttachments:e,supportsEditing:t}}=this;return this.editingEnabled&&t&&e}get syncViewSelection(){return this.store.syncViewSelection}set syncViewSelection(e){this.store.syncViewSelection=e}get timeExtent(){return this.store.timeExtent}set timeExtent(e){this.store.timeExtent=e}get timeZone(){return this.store.timeZone}set timeZone(e){this.store.timeZone=e}get view(){return this.store.view}set view(e){this.store.view=e,this.fieldColumns.forEach(t=>t.view=e),this.refreshCellContent()}get viewTimeEnabled(){return this.store.viewTimeEnabled}set viewTimeEnabled(e){this.store.viewTimeEnabled=e}get visibleColumns(){return super.visibleColumns}async addAttachment(e,t){let{attachmentsViewOptions:n,store:r}=this,i=n.objectId===e;await r.addAttachment(e,t).catch(e=>{i&&e&&typeof e==`object`&&`error`in e&&e.error instanceof s&&(this._logWarning(`Unable to add attachment. ${e.error.name} ${e.error.message}`),n.error=e.error)}),i&&!n.error&&(n.onEditComplete(),n.attachmentInfos=await r.getAttachmentsByObjectId(e,!0)),this.refreshCellContent()}addPendingEdits(e){this.store.addPendingEdits(e)}collapseRelatedTable(e,t){let{relatedLayer:n,objectId:r,relationshipId:i}=t,{objectIdField:o}=n,s=te(n,i),c=n.displayField||s?.keyField||o;e.set({highlightIds:new a([r]),multipleSelectionEnabledOverride:!1,tableTemplateOverride:this._getTableTemplateForRelatedTableView(e,c,i)});let l=e.hiddenFields;l.includes(Y.action)||l.add(Y.action),l.includes(Y.attachments)||l.add(Y.attachments),e.scrollLeft()}async deleteAttachments(e,t){let{attachmentsViewOptions:n,store:r}=this,i=n.objectId===e;await r.deleteAttachments(e,t).catch(e=>{i&&e&&typeof e==`object`&&`error`in e&&e.error instanceof s&&(this._logWarning(`Unable to delete attachment(s). ${e.error.name} ${e.error.message}`),n.error=e.error)}),i&&!n.error&&(n.onEditComplete(),n.attachmentInfos=await r.getAttachmentsByObjectId(e,!0)),this.refreshCellContent()}async deleteSelection(){let e=this.highlightIds.toArray();if(!e?.length)return;let{deleteFeatureResults:t}=await this.store.deleteRowsByObjectId(e),n=t.filter(e=>!e.error).map(e=>e.objectId);n.length&&(this.highlightIds.removeMany(n),await this.refresh())}async discardPendingEdits(e){return this.relatedTable&&this.relatedTableHasPendingEdits?this.relatedTable.discardPendingEdits(e):(this.store.discardPendingEdits(e),!0)}async downloadAttachmentById(e,t){let n=(await this.store.getAttachmentsByObjectId(e,!0)).find(e=>e.id===t);await V(n)}drainRelatedTables(){this.relatedTables.drain(e=>e.destroy()),this.set({multipleSelectionEnabledOverride:null,relationshipColumnConfigs:null,showAllRelatedTables:!1,tableTemplateOverride:null}),this.hiddenFields.removeMany([Y.action,Y.attachments])}drainRelatedTablesAboveIndex(e){let{relatedTables:t}=this,n=t.slice(e+1);t.removeMany(n).forEach(e=>e.destroy());let r=t.at(-1);r&&(r.attachmentsViewOptions.objectId=null,this.allRelatedTablesVisible?this._showAllRelatedTables(r):this._hideAllRelatedTables(r))}async exportSelectionToCSV(e){let{highlightIds:t,layer:n,outFields:r}=this;if(!n||!t.length){this._logWarning(`Export failed.`);return}await H({layer:n,objectIds:t.toArray(),outFields:r,includeGeometry:e})}getCachedFeaturesByPageIndex(e){return this.store.getCachedFeaturesByPageIndex(e)}getFeatureStoreItemByObjectId(e){return this.store.getItemByObjectId(e)}async getFeatureTitle(e,t){return this.store.getFeatureTitle(e,t)}getFeatureTitleSync(e){let t=this.layer;if(!t)return`${e}`;let n=`${t.objectIdField}: ${e}`;return e==null?n:this.store.featureTitleMap.get(e)??n}getObjectIdIndex(e){return this.store.getItemIndexByObjectId(e)}getValue(e,t){return this.getFeatureStoreItemByObjectId(e)?.feature?.attributes[t]}getVirtualPageIndex(){return this.grid?.getVirtualPageIndex()??0}goToPage(e){if(e==null||!Number.isInteger(e)){this._logWarning(`Invalid 'page' parameter provided to 'goToPage()'. Current page will remain the same.`);return}let{pageCount:t}=this;(e>=t||e===-1)&&(e=t-1),e<-1&&(e=0),e!==this.pageIndex&&(this.pageIndex=e),this.paginationEnabled||this.scrollToIndex(e*this.pageSize)}hideAttachmentsView(){this.attachmentsViewOptions.objectId=null,this.set({relationshipColumnConfigs:null,multipleSelectionEnabledOverride:null,tableTemplateOverride:null}),this.hiddenFields.remove(Y.action)}nextPage(){let e=this.paginationEnabled?this.pageIndex:this.getVirtualPageIndex();this.goToPage(e+1)}previousPage(){let e=this.paginationEnabled?this.pageIndex:this.getVirtualPageIndex();this.goToPage(e-1)}async refresh(){await Promise.all([...this.relatedTables.map(e=>e.refresh()),u(this._refreshDebounced())])}refreshCellContent(){this.grid?.requestContentUpdate()}refreshPageCache(){this.grid?.refreshPageCache()}async reset(){this.goToPage(0),await this.grid?.reset()}async savePendingEdits(){if(this.relatedTableHasPendingEdits&&!this.relatedTableHasInvalidPendingEdits){await this.relatedTable?.savePendingEdits();return}this.hasPendingEdits&&!this.relatedTable&&(await this.store.savePendingEdits(),await this.refresh())}scrollLeft(){this.grid?.scrollLeft(0)}scrollToBottom(){this.grid?.scrollToBottom()}scrollToIndex(e){this.grid?.scrollToIndex(e)}scrollToRow(e){let t=this.store.getItemIndexByObjectId(e);t>-1?this.grid?.scrollToIndex(t):this._logWarning(`Row not found. Associated data may not be loaded yet.`)}scrollToTop(){this.grid?.scrollToTop()}async saveAttachmentsViewForm(){let{attachmentId:e,form:t,objectId:n}=this.attachmentsViewOptions;n!=null&&t&&(e==null?await this.addAttachment(n,t):await this.updateAttachment(n,e,t))}async showAttachmentsView({objectId:e}){let{attachmentsViewOptions:t,hiddenFields:n,layer:r}=this;if(!this.attachmentsEnabled||!r){this._logWarning(`The 'attachmentsEnabled' property is currently false.`);return}await r.load();let i=this._getDefaultLayerDisplayField(r),o=await this.store.getAttachmentsByObjectId(e,!0),s=this.store.getItemIndexByObjectId(e);t.set({attachmentInfos:o,mode:o.length?`list`:`file`,objectId:e}),this.set({highlightIds:new a([e]),multipleSelectionEnabledOverride:!1,relationshipColumnConfigs:[],tableTemplateOverride:this._getTableTemplateForAttachmentsView(i)}),n.includes(Y.action)||n.add(Y.action),s!=null&&this.scrollToIndex(s)}syncAttributeTableTemplate(){this._syncAttributeTableTemplate(!0)}syncSelectionSources(){this.store.syncSelectionSources()}async updateAttachment(e,t,n){let{attachmentsViewOptions:r,store:i}=this,a=r.objectId===e;await i.updateAttachment(e,t,n).catch(e=>{a&&e&&typeof e==`object`&&`error`in e&&e.error instanceof s&&(this._logWarning(`Unable to update attachment. ${e.error.name} ${e.error.message}`),r.error=e.error)}),a&&!r.error&&(r.onEditComplete(),r.attachmentInfos=await i.getAttachmentsByObjectId(e,!0)),this.refreshCellContent()}async zoomToSelection(){let{layer:e,view:t}=this,n=this.highlightIds.toArray();if(!e||!t||!n.length)return;let r=e.createQuery();r.objectIds=n,r.returnGeometry=!0;let i=await e.queryFeatures(r);try{await ae(t,i.features)}catch(e){e.name!==`AbortError`&&console.error(e)}}_syncAttributeTableTemplate(e=!1){let{_effectiveAttributeTableTemplate:t,layer:n,tableTemplateOverride:r,syncTemplateOnChangesEnabled:i}=this;if(!n||!t||!i&&!e||r||this.tableParent||this.relatedTable||this.attachmentsViewOptions.objectId!==null)return;let a=JSON.stringify(t.toJSON());T(t,this.columns.toArray(),this.activeSortOrders),t===n.attributeTableTemplate&&JSON.stringify(t.toJSON())!==a&&(n.attributeTableTemplate=t.clone())}async _refresh(){await super.refresh();let e=this.highlightIds.toArray();e.length&&(await this.store.verifyFeaturesByObjectId(e)).forEach((t,n)=>{t||this.highlightIds.remove(e[n])}),this.refreshPageCache();let t=this.attachmentsViewOptions;t?.objectId!=null&&(t.attachmentInfos=await this.store.getAttachmentsByObjectId(t.objectId,!0))}async _onLayerLoad(){let{layer:e,pageSize:t}=this;if(!e)return;e.parent&&S(e.parent)&&await e.parent.loadAll();let n=e.capabilities.query?.maxRecordCount,r=n&&n<t,i=r?n:t;r&&(this._logWarning(`The value for 'pageSize' has been adjusted due to the provided layer's max record count.`),this.pageSize=i),this.grid?.set(`pageSize`,i);try{this._generateColumns(),await this.store.load(),this.refreshPageCache()}catch{c.getLogger(this).error(`Unable to load the provided layer.`)}}_onLayerRefresh(e){this.autoRefreshEnabled&&e.dataChanged&&this.refresh()}_generateColumns(){this._drainColumns();let{_effectiveTableTemplate:e,_effectiveAttributeTableTemplate:t,layer:n}=this,r=e?.columnTemplates;if(!n)return;let i=this._generateColumnsFromColumnTemplates(n,r)??this._generateColumnsFromAttributeTableTemplate(n,t)??this._generateDefaultFieldColumns(n);i.length&&(this.attachmentsEnabled&&!i.some(e=>R(e))&&i.push(this._generateDefaultAttachmentsColumn(n)),this.relatedRecordsEnabled&&this.relationshipInfos.length&&!i.some(e=>B(e))&&i.push(...this._generateDefaultRelationshipColumns()),this.actionColumnConfig&&i.push(this._generateActionColumn()),i.sort((e,t)=>e.frozen&&t.frozen||e.frozenToEnd&&t.frozenToEnd?0:e.frozen||t.frozenToEnd?-1:0),this.columns.addMany(i))}_generateColumnsFromAttributeTableTemplate(e,t){if(!t)return null;let{elements:n,orderByFields:r}=t,a=C(e),o=[];o.push(...this._generateColumnsFromAttributeTableElements(e,n,r));let s=a.map(t=>{if(!t.fieldName||ne(t.fieldName,o))return null;let{fieldName:n}=t,i=X(e,n);return i?this._generateDefaultFieldColumn(e,i,{hidden:!0,orderByFields:r}):(this._logTemplateWarning(`A valid 'field' could not be found for the provided template.`),null)}).filter(i);return o.push(...s),this.attachmentsEnabled&&re(e)&&!o.some(e=>R(e))&&o.push(this._generateDefaultAttachmentsColumn(e,{hidden:!0})),this.relatedRecordsEnabled&&J(e)&&e.relationships?.forEach(({id:e},t)=>{let n=this.relationshipInfos.find(t=>t.relationshipId===e);n&&!o.some(t=>B(t)&&t.relationshipId===e)&&o.push(this._generateDefaultRelationshipColumn({hidden:!0,info:n,index:t}))}),o.length?o:null}_generateColumnsFromAttributeTableElements(e,t,n){return t?.map((t,r)=>{switch(t.type){case`field`:return this._createFieldColumnFromElement({layer:e,element:t,orderByFields:n});case`group`:return this._createGroupColumnFromElement({layer:e,element:t,orderByFields:n});case`attachment`:return this._createAttachmentColumnFromElement({layer:e,element:t,index:r});case`relationship`:return this._createRelationshipColumnFromElement({element:t,index:r})}}).filter(e=>!!e)??[]}_createFieldColumnFromElement(e){let{layer:t,element:n,orderByFields:r}=e,{fieldName:i}=n;if(i==null)return this._logTemplateWarning(`A valid 'fieldName' must be provided.`),null;let a=X(t,i);if(!a)return this._logTemplateWarning(`A valid 'field' could not be found for the provided template.`),null;let{description:o,label:s}=n,c=r?.findIndex(({field:e})=>e&&e===i)??-1,l=c>-1?r?.at(c)?.order:void 0,u=c>-1?c:void 0,{grid:d,messages:f,messagesCommon:p,messagesURIUtils:m,store:h,view:g}=this;return new A({description:o,direction:l,field:a,fieldName:i,grid:d,initialSortPriority:u,label:s,layer:t,messages:f,messagesCommon:p,messagesURIUtils:m,store:h,view:g,onShowPromptCallback:this._onShowPromptCallback})}_createGroupColumnFromElement(e){let{layer:t,element:n,orderByFields:r}=e,{description:i,label:a}=n;if(!a)return this._logTemplateWarning(`Group columns require a label.`),null;if(!n.elements.length)return this._logTemplateWarning(`Group columns require child columns.`),null;let{grid:o,messages:s,messagesCommon:c,messagesURIUtils:l,store:u}=this;return new F({columns:this._generateColumnsFromAttributeTableElements(t,n.elements,r),description:i,grid:o,label:a,messages:s,messagesCommon:c,messagesURIUtils:l,store:u})}_createAttachmentColumnFromElement(e){if(!this.attachmentsEnabled){this._logTemplateWarning(`The 'attachmentsEnabled' property is currently false.`);return}let{layer:t,element:n,index:r}=e,{description:i,label:a}=n,{grid:o,messages:s,messagesCommon:c,messagesURIUtils:l,store:u}=this;return new k({description:i,fieldName:`${Y.attachments}-${r}`,grid:o,label:a,layer:t,messages:s,messagesCommon:c,messagesURIUtils:l,store:u,onShowAttachments:e=>this._onShowAttachments(e)})}_createRelationshipColumnFromElement(e){if(!this.relatedRecordsEnabled){this._logTemplateWarning(`Relationship columns require related records to be enabled on the table.`);return}let{element:t,index:n}=e,{description:r,label:i,relationshipId:a}=t,o=this.relationshipInfos.find(e=>e.relationshipId===a);if(!o)return this._logTemplateWarning(`Unable to find valid related layer target based on the provided relationship id.`),null;let{grid:s,messages:c,messagesCommon:l,messagesURIUtils:u,store:d}=this;return new j({description:r,fieldName:`${Y.relationship}-${a}-${n}`,grid:s,label:i,messages:c,messagesCommon:l,messagesURIUtils:u,relationshipId:a,store:d,layer:o.relatedLayer,relatedLayer:o.layer,showRelatedTableCallback:e=>this._onShowRelatedTable(e)})}_generateColumnsFromColumnTemplates(e,t){let{grid:n,messages:r,messagesCommon:i,messagesURIUtils:a,store:o,view:s}=this;if(!t?.length)return null;let c=[];return t.forEach((t,l)=>{let{autoWidth:u,description:d,direction:f,flexGrow:p,fieldName:m,formatFunction:h,frozen:g,frozenToEnd:_,icon:v,iconText:y,initialSortPriority:b,invalid:x,label:S,labelTooltipText:C,menuConfig:w,resizable:T,sortable:E,textAlign:D,textWrap:O,timeZone:k,type:j,width:N}=t;if(!j){this._logTemplateWarning(`Property 'type' is missing from the provided template.`);return}if(g&&_){this._logTemplateWarning(`Properties 'frozen' and 'frozenToEnd' cannot both be true for the same column.`);return}let P=t.visible===!1;if(j===`group`){if(!t.columnTemplates?.length){this._logTemplateWarning(`Group columns must contain column templates.`);return}if(!t.label){this._logTemplateWarning(`Group columns require a label.`);return}let o=this._generateColumnsFromColumnTemplates(e,t.columnTemplates),s=P||this._isFieldHidden(t.label);c.push(new F({autoWidth:u,columns:o,description:d,flexGrow:p,frozen:g,frozenToEnd:_,grid:n,hidden:s,icon:v,iconText:y,invalid:x,label:S,labelTooltipText:C,menuConfig:w,messages:r,messagesCommon:i,messagesURIUtils:a,resizable:T,textAlign:D,textWrap:O,timeZone:k,width:N}))}else if(j===`attachment`){if(!this.attachmentsEnabled){this._logTemplateWarning(`Attachment columns require attachments to be enabled on the table.`);return}c.push(this._generateAttachmentsColumnFromTemplate(e,t,l))}else if(j===`relationship`){if(!this.relatedRecordsEnabled){this._logTemplateWarning(`Relationship columns require related records to be enabled on the table.`);return}let{relationshipId:e}=t;if(e==null){this._logTemplateWarning(`Property 'relationshipId' is missing from the provided template.`);return}let n=this.relationshipInfos.find(t=>t.relationshipId===e);if(!n){this._logTemplateWarning(`Unable to find valid related layer target based on the provided relationship id.`);return}c.push(this._generateRelationshipColumnFromTemplate(n,t,l))}else if(!m){this._logTemplateWarning(`Value for 'fieldName' property was missing from the provided template.`);return}let I=P||this._isFieldHidden(m);if(j===`column`)c.push(new M({autoWidth:u,description:d,direction:f,fieldName:m,flexGrow:p,formatFunction:h,frozen:g,frozenToEnd:_,grid:n,hidden:I,icon:v,iconText:y,initialSortPriority:b,invalid:x,label:S,labelTooltipText:C,menuConfig:w,messages:r,messagesCommon:i,messagesURIUtils:a,resizable:T,sortable:E,store:o,textAlign:D,textWrap:O,timeZone:k,width:N}));else if(j===`field`){let l=X(e,t.fieldName);if(!l){this._logTemplateWarning(`A valid 'field' could not be found for the provided template.`);return}let{editable:m,required:j}=t;c.push(new A({autoWidth:u,description:d,direction:f,editable:m,field:l,fieldName:l.name,flexGrow:p,formatFunction:h,frozen:g,frozenToEnd:_,grid:n,hidden:I,icon:v,iconText:y,initialSortPriority:b,invalid:x,label:S,labelTooltipText:C,layer:e,messages:r,messagesCommon:i,messagesURIUtils:a,menuConfig:w,required:j,resizable:T,sortable:E,store:o,template:t,textAlign:D,textWrap:O,timeZone:k,width:N,view:s,onShowPromptCallback:this._onShowPromptCallback}))}}),c.length?c:null}_generateDefaultFieldColumns(e){return e.fields?.map(t=>this._generateDefaultFieldColumn(e,t)).filter(i)??[]}_generateDefaultFieldColumn(e,t,n){let{grid:r,messages:i,messagesCommon:a,messagesURIUtils:o,store:s,view:c}=this;if(!t.visible||t.type===`geometry`)return null;let l=n?.orderByFields,u=t.name,d=l?.findIndex(({field:e})=>e&&e===u)??-1,f=d>-1?l?.at(d)?.order:void 0,p=d>-1?d:void 0;return new A({direction:f,field:t,fieldName:u,grid:r,hidden:n?.hidden||this._isFieldHidden(u),initialSortPriority:p,layer:e,messages:i,messagesCommon:a,messagesURIUtils:o,store:s,view:c,onShowPromptCallback:this._onShowPromptCallback})}_generateAttachmentsColumnFromTemplate(e,t,n){let{grid:r,messages:i,messagesCommon:a,messagesURIUtils:o,store:s}=this,{attachmentsViewEnabled:c,autoWidth:l,description:u,flexGrow:d,fieldName:f,formatFunction:p,frozen:m,frozenToEnd:h,icon:g,iconText:_,invalid:v,label:y,labelTooltipText:b,menuConfig:x,resizable:S,textAlign:C,textWrap:w,thumbnailAppearance:T,thumbnailCount:E,thumbnailIconScale:D,thumbnailsEnabled:O,timeZone:A,width:j}=t;return new k({attachmentsViewEnabled:c,autoWidth:l,description:u,fieldName:`${Y.attachments}-${n}`,flexGrow:d,formatFunction:p,frozen:m,frozenToEnd:h,grid:r,hidden:t.visible===!1||this._isFieldHidden(y)||this._isFieldHidden(f),icon:g,iconText:_,invalid:v,label:y,labelTooltipText:b,layer:e,menuConfig:x,messages:i,messagesCommon:a,messagesURIUtils:o,resizable:S,store:s,textAlign:C,textWrap:w,thumbnailAppearance:T,thumbnailCount:E,thumbnailIconScale:D,thumbnailsEnabled:O,timeZone:A,width:j,onShowAttachments:e=>this._onShowAttachments(e)})}_generateDefaultAttachmentsColumn(e,t){let{grid:n,messages:r,messagesCommon:i,messagesURIUtils:a,store:o}=this,s=Y.attachments;return new k({fieldName:s,grid:n,hidden:t?.hidden||this._isFieldHidden(s),layer:e,messages:r,messagesCommon:i,messagesURIUtils:a,store:o,onShowAttachments:e=>this._onShowAttachments(e)})}_generateRelationshipColumnFromTemplate(e,t,n){let{grid:r,messages:i,messagesCommon:a,messagesURIUtils:o,store:s}=this,{autoWidth:c,collapsed:l,description:u,flexGrow:d,fieldName:f,formatFunction:p,frozen:m,frozenToEnd:h,icon:g,iconText:_,invalid:v,label:y,labelTooltipText:b,menuConfig:x,relationshipId:S,resizable:C,textAlign:w,textWrap:T,timeZone:E,width:D}=t;return new j({autoWidth:c,collapsed:l,description:u,fieldName:`${Y.relationship}-${S}-${n}`,flexGrow:d,formatFunction:p,frozen:m,frozenToEnd:h,grid:r,hidden:t.visible===!1||this._isFieldHidden(y)||this._isFieldHidden(f),icon:g,iconText:_,invalid:v,label:y,labelTooltipText:b,menuConfig:x,messages:i,messagesCommon:a,messagesURIUtils:o,relationshipId:S,resizable:C,store:s,textAlign:w,textWrap:T,timeZone:E,width:D,layer:e.relatedLayer,relatedLayer:e.layer,showRelatedTableCallback:e=>this._onShowRelatedTable(e)})}_generateDefaultRelationshipColumns(){let{relationshipInfos:e,relationshipColumnConfigs:t}=this,n=[];return e?.length&&(t?t.forEach((t,r)=>{let{relationshipId:i}=t,a=e.find(e=>e.relationshipId===i);a&&n.push(this._generateDefaultRelationshipColumn({config:t,index:r,info:a}))}):e.forEach((e,t)=>n.push(this._generateDefaultRelationshipColumn({index:t,info:e})))),n}_generateDefaultRelationshipColumn(e){let{config:t,hidden:n,index:r,info:i}=e,{grid:a,messages:o,messagesCommon:s,messagesURIUtils:c,store:l}=this,{relationshipId:u}=i;return new j({...t,fieldName:`${Y.relationship}-${u}-${r}`,grid:a,hidden:!!n,messages:o,messagesCommon:s,messagesURIUtils:c,layer:i.relatedLayer,relatedLayer:i.layer,relationshipId:u,store:l,showRelatedTableCallback:e=>this._onShowRelatedTable(e)})}_generateActionColumn(){let e=this.actionColumnConfig,t=e?.frozen===!0?!1:e?.frozenToEnd??!0;return new O({hidden:this._isFieldHidden(Y.action),store:this.store,...e,frozenToEnd:t})}_isFieldHidden(e){let t=e?.toLowerCase();return(this.hiddenFields??this._defaultHiddenFields).some(e=>e.toLowerCase()===t)}_syncSelection(){let{layer:e}=this;D(e)?this.highlightIds.items=this.effectiveSelectionManager.getSelection(e)??[]:this.highlightIds.removeAll()}_addToSelection(e){let t=this.layer;D(t)&&this.effectiveSelectionManager.add(t,e)}_removeFromSelection(e){let t=this.layer;D(t)&&this.effectiveSelectionManager.remove(t,e)}async _onHighlightIdsChange(e){let{added:t,removed:n}=e,{attachmentsViewOptions:r}=this;if(this._removeFromSelection(n),this._addToSelection(t),this.filterBySelectionEnabled&&this._syncObjectIdsWithStore(this.highlightIds.toArray()),r.objectId!=null){let e=this.highlightIds.at(0);if(e!=null){let t=await this.store.getAttachmentsByObjectId(e,!0);r.set({attachmentInfos:t,objectId:e,mode:t.length?`list`:`file`}),this.getFeatureTitle(e)}}}_syncTableParentSelection(e){let{tableParent:t}=this;t&&e!=null&&t.highlightIds.add(e)}_onShowRelatedTable(e){let{highlightIds:t}=this,{objectId:n}=e;if(t.removeAll(),t.add(n),this.showRelatedTableCallback){this.showRelatedTableCallback(e);return}this.emit(`show-related-table`,e)}_onObjectIdsChange(){let e=this.objectIds.toArray();e.length&&this.filterBySelectionEnabled&&(this.filterBySelectionEnabled=!1,this._logWarning(`Object ID filter was applied while a selection filter was applied. Selection filter has been removed.`)),this._syncObjectIdsWithStore(e)}_syncObjectIdsWithStore(e){this.store.objectIds=e,this.refreshPageCache()}_drainColumns(){this.columns.drain(e=>!e.destroyed&&e.destroy())}_showAllRelatedTables(e){let t=e.layer;if(!t)return;let n=this._getDefaultLayerDisplayField(t);e.set({relationshipColumnConfigs:[],tableTemplateOverride:this._getTableTemplateForShowAllTablesView(e,n)});let r=e.hiddenFields;r.includes(Y.action)||r.add(Y.action),r.includes(Y.attachments)||r.add(Y.attachments)}_hideAllRelatedTables(e){let{layer:t,relationship:n}=e;if(t&&n?.id!=null){if(e.attachmentsViewOptions.objectId!=null){let n=this._getDefaultLayerDisplayField(t);e.set({multipleSelectionEnabledOverride:!1,relationshipColumnConfigs:[],showAllRelatedTables:!1,tableTemplateOverride:this._getTableTemplateForAttachmentsView(n)})}else e.set({multipleSelectionEnabledOverride:null,relationshipColumnConfigs:ie(t,n.id),showAllRelatedTables:!1,tableTemplateOverride:null}),e.hiddenFields.removeMany([Y.action,Y.attachments])}}_getTableTemplateForRelatedTableView(e,t,n){return new K({columnTemplates:[new W({fieldName:t,editable:!1,menuConfig:{selectionMode:`single`,icon:`chevron-down`,items:this._extractFieldColumnInfosFromTableTemplate(e.viewModel).map(([r,i])=>({selected:r===t,label:i||r,clickFunction:()=>{e.tableTemplateOverride=this._getTableTemplateForRelatedTableView(e,r,n)}}))},resizable:!1}),new G({autoWidth:!1,collapsed:!0,flexGrow:0,label:``,resizable:!1,relationshipId:n,width:Q})]})}_getTableTemplateForShowAllTablesView(e,t){let n=[new W({fieldName:t,editable:!1,menuConfig:{selectionMode:`single`,icon:`chevron-down`,items:this._extractFieldColumnInfosFromTableTemplate(e.viewModel).map(([n,r])=>({selected:n===t,label:r||n,clickFunction:()=>{e.tableTemplateOverride=this._getTableTemplateForShowAllTablesView(e,n)}}))},resizable:!1})];return e.attachmentsViewOptions.objectId!=null&&n.push(new I({attachmentsViewEnabled:!1,autoWidth:!1,flexGrow:0,label:``,resizable:!1,thumbnailsEnabled:!1,width:Q})),new K({columnTemplates:n})}async _onShowPromptCallback(e){let{column:t,objectId:n,oldValue:r,value:i}=e,{_subtypes:a,layer:o}=this;if(!o||!a.length){t.cancel();return}let s=a.find(e=>e.code===i);if(!s){t.cancel();return}let c=Promise.withResolvers(),l=this._createSubtypeEditPrompt(r,s,c),u=!!o.parent&&this.autoSaveEnabled;try{this.showPrompt(l);let e=await c.promise,r=[{fieldName:t.fieldName,value:i}];switch(e){case`update-fields`:for(let[e,t]of Object.entries(s.defaultValues))t!=null&&r.push({fieldName:e,value:t});await t.updateItems({objectId:n,updates:r}),u&&this.refresh();break;case`keep-existing`:await t.updateItems({objectId:n,updates:r}),u&&this.refresh();break;case`undo`:t.cancel()}}finally{this.clearPrompt()}}_createSubtypeEditPrompt(e,t,r){let{_subtypes:i,messages:a,messagesCommon:o}=this,s=i.find(t=>t.code===e)?.name??`${e}`,c=`update-fields`,l=[{label:a.subtypes.useDefaultValuesOption,value:`update-fields`},{label:a.subtypes.keepCurrentValuesOption,value:`keep-existing`}];return{context:`info`,title:a.subtypes.changeWarningTitle,message:n(a.subtypes.changeWarning,{originalType:s,newType:t.name}),radios:l,defaultRadioSelection:`update-fields`,onRadioSelection:e=>{c=e},actions:{primary:{label:o.apply,action:()=>r.resolve(c),type:`positive`},secondary:{label:o.cancel,type:`neutral`,action:()=>r.resolve(`undo`)}},cancel:()=>r.reject()}}_onShowAttachments({objectId:e}){this.hasPendingEdits||(this.attachmentsViewOptions.objectId=e)}_getTableTemplateForAttachmentsView(e){return new K({columnTemplates:[new W({fieldName:e,editable:!1,menuConfig:{selectionMode:`single`,icon:`chevron-down`,items:this._extractFieldColumnInfosFromTableTemplate(this).map(([t,n])=>({selected:t===e,label:n||t,clickFunction:()=>{this.tableTemplateOverride=this._getTableTemplateForAttachmentsView(t)}}))},resizable:!1}),new I({attachmentsViewEnabled:!1,autoWidth:!1,flexGrow:0,label:``,resizable:!1,thumbnailsEnabled:!1,width:Q})]})}_extractFieldColumnInfosFromTableTemplate(e){let{layer:t,tableTemplate:n}=e??this;return n?n.columnTemplates.filter(({type:e})=>e===`field`||e===`column`).map(({fieldName:e,label:n})=>{if(n!=null&&n!==``)return[e,n];let r=t?.fieldsIndex.get(e);return[e,r&&v(r,t)]}):t?.fields.map(e=>[e.name,v(e,t)])??[]}_getDefaultLayerDisplayField(e){let{displayField:t,objectIdField:n}=e;return e.fieldsIndex.get(t)?.name||n||(e.fields.length?e.fields[0].name:``)}_getIndexOfFirstFrozenToEndColumn(){let e=this.columns.findIndex(e=>e.frozenToEnd);return e>-1?e:void 0}_logWarning(e,t){t?c.getLogger(this).warnOnce(e):c.getLogger(this).warn(e)}_logTemplateWarning(e){this._logWarning(`${e} Skipped generating a column using the provided template.`,!0)}_onCellInteraction(e){e!=null&&this.attachmentsViewOptions.objectId!=null&&this.highlightIds.add(e)}};e([g()],$.prototype,`_defaultHiddenFields`,null),e([g()],$.prototype,`_effectiveTableTemplate`,null),e([g()],$.prototype,`_effectiveAttributeTableTemplate`,null),e([g()],$.prototype,`_subtypes`,null),e([g()],$.prototype,`activeFilters`,null),e([g({readOnly:!0})],$.prototype,`activeSortOrders`,null),e([g()],$.prototype,`allRelatedTablesVisible`,null),e([g()],$.prototype,`attachmentsColumns`,null),e([g()],$.prototype,`attachmentsEnabled`,null),e([g()],$.prototype,`attachmentsViewOptions`,void 0),e([g({type:w})],$.prototype,`attributeTableTemplate`,void 0),e([g()],$.prototype,`autoRefreshEnabled`,void 0),e([g()],$.prototype,`autoSaveEnabled`,null),e([g()],$.prototype,`cachedPageCount`,null),e([g()],$.prototype,`canAddRelatedFeature`,null),e([g()],$.prototype,`clearPrompt`,null),e([g({readOnly:!0})],$.prototype,`columns`,void 0),e([g()],$.prototype,`dataProvider`,void 0),e([g()],$.prototype,`defaultSelectionManager`,null),e([g()],$.prototype,`definitionExpression`,null),e([g()],$.prototype,`effectiveSelectionManager`,null),e([g()],$.prototype,`effectiveTimeExtent`,null),e([g()],$.prototype,`effectiveWhere`,null),e([g()],$.prototype,`fieldColumns`,null),e([g()],$.prototype,`filterByViewExtent`,null),e([g()],$.prototype,`filterByLayerScaleRange`,null),e([g({types:y})],$.prototype,`filterGeometry`,null),e([g()],$.prototype,`filterBySelectionEnabled`,null),e([g({readOnly:!0})],$.prototype,`grid`,void 0),e([g()],$.prototype,`hasContingentValues`,null),e([g()],$.prototype,`hasInvalidPendingEdits`,null),e([g()],$.prototype,`hasPendingEdits`,null),e([g()],$.prototype,`hiddenFields`,null),e([g()],$.prototype,`highlightEnabled`,null),e([g()],$.prototype,`initialSize`,null),e([g()],$.prototype,`isQueryingOrSyncing`,null),e([g()],$.prototype,`isSyncingAttachments`,null),e([g()],$.prototype,`layer`,null),e([g()],$.prototype,`layers`,void 0),e([g()],$.prototype,`layerFieldConfigurations`,null),e([g()],$.prototype,`layerView`,null),e([g()],$.prototype,`menuConfig`,void 0),e([g()],$.prototype,`messages`,void 0),e([g(),Z(`esri/t9n/common`)],$.prototype,`messagesCommon`,void 0),e([g(),Z(`esri/core/t9n/Units`)],$.prototype,`messagesUnits`,void 0),e([g(),Z(`esri/widgets/support/t9n/uriUtils`)],$.prototype,`messagesURIUtils`,void 0),e([g()],$.prototype,`outFields`,null),e([g()],$.prototype,`pendingEditsCount`,null),e([g()],$.prototype,`prompt`,void 0),e([g()],$.prototype,`relatedRecordsEnabled`,null),e([g()],$.prototype,`relatedTable`,null),e([g()],$.prototype,`relatedTableHasContingentValues`,null),e([g()],$.prototype,`relatedTables`,void 0),e([g()],$.prototype,`relationship`,null),e([g()],$.prototype,`relationshipColumnConfigs`,void 0),e([g()],$.prototype,`relationshipColumns`,null),e([g()],$.prototype,`relationshipConfig`,null),e([g()],$.prototype,`relationshipInfos`,null),e([g()],$.prototype,`relationships`,null),e([g()],$.prototype,`returnGeometryEnabled`,null),e([g()],$.prototype,`returnMEnabled`,null),e([g()],$.prototype,`returnZEnabled`,null),e([g()],$.prototype,`selectionManager`,null),e([g()],$.prototype,`selectionSource`,null),e([g()],$.prototype,`showAllRelatedTables`,null),e([g()],$.prototype,`showPrompt`,null),e([g()],$.prototype,`showRelatedTableCallback`,void 0),e([g({readOnly:!0,type:U})],$.prototype,`store`,void 0),e([g()],$.prototype,`supportsAttachments`,null),e([g()],$.prototype,`supportsAddAttachments`,null),e([g()],$.prototype,`supportsDeleteAttachments`,null),e([g()],$.prototype,`supportsResizeAttachments`,null),e([g()],$.prototype,`supportsUpdateAttachments`,null),e([g()],$.prototype,`syncTemplateOnChangesEnabled`,void 0),e([g()],$.prototype,`syncViewSelection`,null),e([g()],$.prototype,`tableController`,void 0),e([g()],$.prototype,`tableParent`,void 0),e([g({type:K})],$.prototype,`tableTemplate`,void 0),e([g()],$.prototype,`tableTemplateOverride`,void 0),e([g({type:E})],$.prototype,`timeExtent`,null),e([g()],$.prototype,`timeZone`,null),e([g()],$.prototype,`view`,null),e([g()],$.prototype,`viewTimeEnabled`,null),$=e([_(`esri.widgets.FeatureTable.FeatureTableViewModel`)],$);const oe=$;export{oe as default};
|
package/widgets/FeatureTable.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
|
|
2
|
-
import{__decorate as e}from"tslib";import{substitute as t}from"../intl.js";import{isSome as n}from"../core/arrayUtils.js";import{deprecateWidget as r}from"../core/deprecate.js";import i from"../core/Logger.js";import{watch as a,sync as o,syncAndInitial as s,initial as c,on as l}from"../core/reactiveUtils.js";import{renderingSanitizer as u}from"../core/sanitizerUtils.js";import{formatFileSize as d}from"../core/unitFormatUtils.js";import{property as f,subclass as p}from"../core/accessorSupport/decorators.js";import{geometryTypes as m}from"../geometry/support/typeUtils.js";import{isLayerFromCatalog as h}from"../layers/catalog/catalogUtils.js";import{isKnowledgeGraphLayer as g,isMapImageLayer as _,isSubtypeGroupLayer as v}from"../layers/support/layerUtils.js";import y from"../tables/AttributeTableTemplate.js";import b from"../time/TimeExtent.js";import x from"./Widget.js";import{isSupportedImage as S,getCalciteIconForAttachment as C,getAttachmentTypeCategory as w}from"./Attachments/support/attachmentUtils.js";import{loadPromptComponents as T,Prompt as E}from"./Editor/components/Prompt.js";import D from"./FeatureTable/ColumnMenuVisibleElements.js";import O from"./FeatureTable/FeatureTableViewModel.js";import k from"./FeatureTable/VisibleElements.js";import{isGroupColumn as A,isFieldColumn as j}from"./FeatureTable/support/columnUtils.js";import M from"./FeatureTable/support/TableTemplate.js";import{loadFieldColumnComponents as N,isIFeatureTableSupportedLayer as P,isIFeatureTableSupportedLayerWithAttachments as F,getRelationshipIdsToShow as I}from"./FeatureTable/support/tableUtils.js";import{loadCalciteComponents as L}from"./support/componentsUtils.js";import{globalCss as R}from"./support/globalCss.js";import{getIconForLayer as z}from"./support/iconUtils.js";import{messageBundle as B,vmEvent as V,tsx as H,tsxFragment as U}from"./support/widget.js";import{storeNode as W,discardNode as G}from"./support/widgetUtils.js";var K;const q=`esri-feature-table`,J=`${q}__dialog`,Y=`${q}__table-navigation`,X=`${q}__attachments-view`,Z={base:q,content:`${q}__content`,menuPopover:`${q}__menu-popover`,layerDropdownMenu:`${q}__layer-switcher-menu`,tableContainer:`${q}__table-container`,tableContainerWithAttachments:`${q}__table-container--attachments`,tableNavigation:Y,attachmentsView:X,attachmentsViewContent:`${X}__content`,attachmentsViewDetails:`${X}__details`,attachmentsViewDropArea:`${X}__drop-area`,attachmentsViewDropAreaLabel:`${X}__drop-area__label`,attachmentsViewDropAreaMessage:`${X}__drop-area__message`,attachmentsViewIcon:`${X}__icon`,attachmentsViewInformation:`${X}__information`,attachmentsViewInformationData:`${X}__information__data`,attachmentsViewInformationLabel:`${X}__information__label`,attachmentsViewList:`${X}__list`,attachmentsViewListFileSize:`${X}__list__filesize`,attachmentsViewListThumbnail:`${X}__list__thumbnail`,expanded:`${q}__expanded`,collapsed:`${q}__collapsed`,dialog:`${J}`,dialogContent:`${J}__content`,dialogHeader:`${J}__header`,footerMessage:`${q}__footer__message`,footerIconDanger:`${q}__footer__icon--danger`,footerIconSuccess:`${q}__footer__icon--success`},Q={checkCircle:`check-circle`,chevronRight:`chevron-right`,clearSelection:`clear-selection`,downloadTo:`download-to`,exclamationMarkTriangle:`exclamation-mark-triangle`,expand:`expand`,exportToCSV:`file-csv`,folderOpen:`folder-open`,delete:`trash`,layers:`layers`,moveUp:`move-up`,plus:`plus`,refresh:`refresh`,reset:`reset`,save:`save`,showAll:`selection-x`,showColumn:`show-column`,showSelected:`selection-filter`,table:`table`,upload:`upload`,zoomToSelection:`zoom-to-object`};let $=K=class extends x{constructor(e,t){super(e,t),this._attachmentsDialogPreviewLoading=!1,this._attachmentsInput=null,this._columnVisibilityActions=new Map,this._columnVisibilityList=null,this.attachmentsList=null,this.closed=!1,this.collapsed=!1,this.columnVisibilityMenuConfig=null,this.description=null,this.disabled=!1,this.messagesEditor=null,this.navigationScale=`m`,this.title=null,this.viewModel=new O,this.visibleElements=new k,this.announceDeprecation=()=>{r(i.getLogger(this),`Feature Table`,`arcgis-feature-table`,{version:`5.0`})},this._showDeleteSelectionPrompt=this._showDeleteSelectionPrompt.bind(this),this._showDiscardEditsPrompt=this._showDiscardEditsPrompt.bind(this),this._resetNestedViews=this._resetNestedViews.bind(this)}initialize(){this.addHandles([a(()=>[this.isQueryingOrSyncing,this.editingEnabled],()=>this.scheduleRender()),a(()=>[this._effectiveVisibleElements,this._effectiveVisibleElements.columnDescriptions,this._effectiveVisibleElements.columnMenus,this._effectiveVisibleElements.columnMenuItems,this.columns.length],()=>{this.columns.forEach(e=>e.visibleElements=this._effectiveVisibleElements),this.refreshCellContent()},o),a(()=>[this.topLayerDisabled,this.columns],()=>this.columns.forEach(e=>e.topLayerDisabled=this.topLayerDisabled),s),a(()=>this._effectiveVisibleElements.selectionColumn,e=>{this.grid&&(this.grid.selectionColumnEnabled=e)},c),l(()=>this.viewModel,`show-related-table`,e=>this._onShowRelatedTable(e)),a(()=>this.editingEnabled,()=>{let{attachmentsViewOptions:e}=this;this.clearPrompt(),e&&(e.form?.reset(),e.candidates=null)}),l(()=>this.effectiveTable,`column-reorder`,()=>this.scheduleRender())])}loadDependencies(){return Promise.all([L({action:()=>import(`@esri/calcite-components/dist/components/calcite-action`),alert:()=>import(`@esri/calcite-components/dist/components/calcite-alert`),button:()=>import(`@esri/calcite-components/dist/components/calcite-button`),chip:()=>import(`@esri/calcite-components/dist/components/calcite-chip`),dialog:()=>import(`@esri/calcite-components/dist/components/calcite-dialog`),dropdown:()=>import(`@esri/calcite-components/dist/components/calcite-dropdown`),"dropdown-group":()=>import(`@esri/calcite-components/dist/components/calcite-dropdown-group`),"dropdown-item":()=>import(`@esri/calcite-components/dist/components/calcite-dropdown-item`),icon:()=>import(`@esri/calcite-components/dist/components/calcite-icon`),label:()=>import(`@esri/calcite-components/dist/components/calcite-label`),list:()=>import(`@esri/calcite-components/dist/components/calcite-list`),"list-item":()=>import(`@esri/calcite-components/dist/components/calcite-list-item`),notice:()=>import(`@esri/calcite-components/dist/components/calcite-notice`),pagination:()=>import(`@esri/calcite-components/dist/components/calcite-pagination`),panel:()=>import(`@esri/calcite-components/dist/components/calcite-panel`),popover:()=>import(`@esri/calcite-components/dist/components/calcite-popover`),progress:()=>import(`@esri/calcite-components/dist/components/calcite-progress`),switch:()=>import(`@esri/calcite-components/dist/components/calcite-switch`),tooltip:()=>import(`@esri/calcite-components/dist/components/calcite-tooltip`)}),T(),N()])}destroy(){this.drainRelatedTables(),this.clearPrompt()}get _attachmentsViewIsVisible(){return!!(this.attachmentsViewOptions.objectId!=null||this.relatedTables.some(e=>e.attachmentsViewOptions.objectId!=null))}get _columnVisibilityActionDisabled(){let e=this.effectiveTable;return e.menuConfig?.disabled??e.columns.length===0}get _dialogIsOpen(){return!!this.attachmentsViewOptions.dialogInfo}get _effectiveDescription(){let{description:e}=this;return e==null?void 0:u.sanitize(typeof e==`function`?e():e)}get _effectiveLayers(){let{layer:e,layers:t}=this,n=t?.length?t.filter(P):[],r=n.length?n:[...this._viewLayers];return e&&!r.includes(e)&&r.push(e),r}get _effectiveTitle(){let{layer:e,messages:n,state:r,highlightIds:i,title:a,size:o}=this;if(a)return u.sanitize(typeof a==`function`?a():a);if(!n)return``;if(!e)return n.noLayer;switch(r){case`disabled`:return n.errorLayer;case`ready`:case`loading`:return n.loading;case`error`:return n.errorData}return t(n.header,{title:u.sanitize(e.title),count:o,selected:i.length})}get _effectiveVisibleElements(){return this.visibleElementsOverride??this.visibleElements}get _filteredTables(){let e=this.relatedTables.toArray(),t=e.length===1;return this.allRelatedTablesVisible?e:t?[e[0]]:this._attachmentsViewIsVisible?e.slice(-1):e.slice(-2)}get _hasAttachmentsViewError(){return this.attachmentsViewOptions.error!=null}get _hasCustomMenuItems(){return!!this.menuConfig?.items?.length}get _hasDefaultMenuItems(){return!!(this._showClearSelectionAction||this._showDeleteSelectionAction||this._showExportSelectionToCSVAction||this._showRefreshDataAction||this._showZoomToSelectionAction||this._showSelectedRecordsShowSelectedAction||this._showSelectedRecordsShowAllAction||this._showColumnVisibilityAction)}get _shouldShowGrid(){return this.allRelatedTablesVisible||this.relatedTables.length===1&&!this._attachmentsViewIsVisible}get _shouldShowMenu(){let{header:e,menu:t}=this._effectiveVisibleElements;return!!(e&&t&&(this._hasDefaultMenuItems||this._hasCustomMenuItems))}get _showClearSelectionAction(){return!!(this.effectiveTable.highlightIds.length&&this._effectiveVisibleElements.menuItems?.clearSelection&&!this._attachmentsViewIsVisible)}get _showColumnVisibilityAction(){let{columnVisibilityMenu:e,header:t,menu:n,menuItems:r}=this._effectiveVisibleElements;return!(!t||!n||!e||r?.toggleColumns===!1||this.showRelatedTableCallback||this.allRelatedTablesVisible||this._attachmentsViewIsVisible)}get _showDeleteSelectionAction(){return!!(this.editingEnabled&&this.highlightIds.length&&this._effectiveVisibleElements.menuItems?.deleteSelection&&this.layer?.capabilities?.operations?.supportsDelete&&!this.relatedTables.length&&!this._attachmentsViewIsVisible)}get _showExportSelectionToCSVAction(){return!!(this._effectiveVisibleElements.menuItems.exportSelectionToCSV&&this.layer&&this.highlightIds.length&&!this.relatedTables.length)}get _showLayerDropdown(){return!!(this._effectiveLayers.length&&this._effectiveVisibleElements.layerDropdown)}get _shouldShowNavigationBar(){let e=!!this.relatedTable||this._attachmentsViewIsVisible;return!this.tableParent&&e}get _showRefreshDataAction(){return!!this._effectiveVisibleElements.menuItems?.refreshData}get _showSelectedRecordsShowSelectedAction(){let e=this.objectIds.length,t=this.highlightIds.length;return!(!t||!this._effectiveVisibleElements.menuItems?.selectedRecordsShowSelectedToggle||e&&t===e||this.relatedTables.length||this._attachmentsViewIsVisible)}get _showSelectedRecordsShowAllAction(){return!!(this._effectiveVisibleElements.menuItems?.selectedRecordsShowAllToggle&&this.objectIds.length&&!this.relatedTables.length)}get _showZoomToSelectionAction(){let e=this.effectiveTable;return!!(e.view&&e.highlightIds.length&&!e.layer?.isTable&&this._effectiveVisibleElements.menuItems?.zoomToSelection)}get _viewLayers(){let e=this.view?.map;if(!e)return[];let t=new Set,n=e=>{P(e)&&!v(e)&&!t.has(e)&&(e.type!==`sublayer`||e.capabilities?.operations?.supportsQuery)&&(e.load().catch(()=>{}),t.add(e))},r=e=>{h(e)||e.type===`catalog-footprint`||(g(e)?(e.load().catch(()=>{}),e.layers?.forEach(n),e.tables?.forEach(n)):_(e)?(e.loadAll().catch(()=>{}),e.allSublayers?.forEach(n),e.subtables?.forEach(n)):v(e)?(e.loadAll().catch(()=>{}),e.sublayers?.forEach(n)):n(e))};return e.allLayers.forEach(r),e.allTables.forEach(r),[...t.values()]}get direction(){return this.viewModel.direction}set direction(e){this.viewModel.direction=e}get grid(){return this.viewModel.grid}get actionColumn(){return this.viewModel.actionColumn}get actionColumnConfig(){return this.viewModel.actionColumnConfig}set actionColumnConfig(e){this.viewModel.actionColumnConfig=e}get activeFilters(){return this.viewModel.activeFilters}get activeSortOrders(){return this.viewModel.activeSortOrders}get allColumns(){return this.viewModel.allColumns}get allColumnsVisible(){return this.viewModel.allColumnsVisible}get allRelatedTablesVisible(){return this.viewModel.allRelatedTablesVisible}get allVisibleColumns(){return this.viewModel.allVisibleColumns}get attachmentsColumns(){return this.viewModel.attachmentsColumns}get attachmentsEnabled(){return this.viewModel.attachmentsEnabled}set attachmentsEnabled(e){this.viewModel.attachmentsEnabled=e}get attachmentsViewOptions(){return this.viewModel.attachmentsViewOptions}set attachmentsViewOptions(e){this.viewModel.attachmentsViewOptions=e}get attributeTableTemplate(){return this.viewModel.attributeTableTemplate}set attributeTableTemplate(e){this.viewModel.attributeTableTemplate=e}get autoRefreshEnabled(){return this.viewModel.autoRefreshEnabled}set autoRefreshEnabled(e){this.viewModel.autoRefreshEnabled=e}get autoSaveEnabled(){return this.viewModel.autoSaveEnabled}set autoSaveEnabled(e){this.viewModel.autoSaveEnabled=e}get canAddRelatedFeature(){return this.viewModel.canAddRelatedFeature}get clearPrompt(){return this.viewModel.clearPrompt}set clearPrompt(e){this.viewModel.clearPrompt=e}get columnPerformanceModeEnabled(){return this.viewModel.columnPerformanceModeEnabled}set columnPerformanceModeEnabled(e){this.viewModel.columnPerformanceModeEnabled=e}get columnReorderingEnabled(){return this.viewModel.columnReorderingEnabled}set columnReorderingEnabled(e){this.viewModel.columnReorderingEnabled=e}get columns(){return this.viewModel.columns}get defaultSelectionManager(){return this.viewModel.defaultSelectionManager}get definitionExpression(){return this.viewModel.definitionExpression}set definitionExpression(e){this.viewModel.definitionExpression=e}get container(){return super.container}set container(e){super.container=e}get editingEnabled(){return this.viewModel.editingEnabled}set editingEnabled(e){this.viewModel.editingEnabled=e}get effectiveSelectionManager(){return this.viewModel.effectiveSelectionManager}get effectiveSize(){return this.viewModel.effectiveSize}get effectiveTable(){return this.relatedTable||this}get effectiveTimeExtent(){return this.viewModel.effectiveTimeExtent}get fieldColumns(){return this.viewModel.fieldColumns}get filterGeometry(){return this.viewModel.filterGeometry}set filterGeometry(e){this.viewModel.filterGeometry=e}get filterBySelectionEnabled(){return this.viewModel.filterBySelectionEnabled}set filterBySelectionEnabled(e){this.viewModel.filterBySelectionEnabled=e}get filterByViewExtent(){return this.viewModel.filterByViewExtent}set filterByViewExtent(e){this.viewModel.filterByViewExtent=e}get filterByLayerScaleRange(){return this.viewModel.filterByLayerScaleRange}set filterByLayerScaleRange(e){this.viewModel.filterByLayerScaleRange=e}get groupColumns(){return this.viewModel.groupColumns}get hasContingentValues(){return this.viewModel.hasContingentValues}get hasInvalidPendingEdits(){return this.viewModel.hasInvalidPendingEdits}get hasPendingEdits(){return this.viewModel.hasPendingEdits}get hiddenFields(){return this.viewModel.hiddenFields}set hiddenFields(e){this.viewModel.hiddenFields=e}get highlightEnabled(){return this.viewModel.highlightEnabled}set highlightEnabled(e){this.viewModel.highlightEnabled=e}get highlightIds(){return this.viewModel.highlightIds}set highlightIds(e){this.viewModel.highlightIds=e}get icon(){return Q.table}set icon(e){this._overrideIfSome(`icon`,e)}get initialSize(){return this.viewModel.initialSize}set initialSize(e){this.viewModel.initialSize=e}get isQueryingOrSyncing(){return this.viewModel.isQueryingOrSyncing}get isSyncing(){return this.viewModel.isSyncing}get isSyncingAttachments(){return this.viewModel.isSyncingAttachments}get label(){return this.messages?.widgetLabel??``}set label(e){this._overrideIfSome(`label`,e)}get layer(){return this.viewModel.layer}set layer(e){this.viewModel.layer=e}get layers(){return this.viewModel.layers}set layers(e){this.viewModel.layers=e}get layerView(){return this.viewModel.layerView}get maxSize(){return this.viewModel.maxSize}set maxSize(e){this.viewModel.maxSize=e}get messages(){return this.viewModel.messages}set messages(e){this.viewModel.messages=e}get messagesCommon(){return this.viewModel.messagesCommon}set messagesCommon(e){this.viewModel.messagesCommon=e}get messagesUnits(){return this.viewModel.messagesUnits}set messagesUnits(e){this.viewModel.messagesUnits=e}get messagesURIUtils(){return this.viewModel.messagesURIUtils}set messagesURIUtils(e){this.viewModel.messagesURIUtils=e}get menuConfig(){return this.viewModel.menuConfig}set menuConfig(e){this.viewModel.menuConfig=e}get multipleSelectionEnabled(){return this.viewModel.multipleSelectionEnabled}set multipleSelectionEnabled(e){this.viewModel.multipleSelectionEnabled=e}get multipleSelectionEnabledOverride(){return this.viewModel.multipleSelectionEnabledOverride}set multipleSelectionEnabledOverride(e){this.viewModel.multipleSelectionEnabledOverride=e}get multiSortEnabled(){return this.viewModel.multiSortEnabled}set multiSortEnabled(e){this.viewModel.multiSortEnabled=e}get multipleSortPriority(){return this.viewModel.multipleSortPriority}set multipleSortPriority(e){this.viewModel.multipleSortPriority=e}get noDataMessage(){return this.viewModel.noDataMessage}set noDataMessage(e){this.viewModel.noDataMessage=e}get objectIds(){return this.viewModel.objectIds}set objectIds(e){this.viewModel.objectIds=e}get outFields(){return this.viewModel.outFields}set outFields(e){this.viewModel.outFields=e}get pageCount(){return this.viewModel.pageCount}get pageIndex(){return this.viewModel.pageIndex}set pageIndex(e){this.viewModel.pageIndex=e}get pageSize(){return this.viewModel.pageSize}set pageSize(e){this.viewModel.pageSize=e}get paginationEnabled(){return this.viewModel.paginationEnabled}set paginationEnabled(e){this.viewModel.paginationEnabled=e}get pendingEditsCount(){return this.viewModel.pendingEditsCount}get prompt(){return this.viewModel.prompt}set prompt(e){this.viewModel.prompt=e}get relatedRecordsEnabled(){return this.viewModel.relatedRecordsEnabled}set relatedRecordsEnabled(e){this.viewModel.relatedRecordsEnabled=e}get relatedTable(){return this.viewModel.relatedTable}get relatedTableHasContingentValues(){return this.viewModel.relatedTableHasContingentValues}get relatedTableHasInvalidPendingEdits(){return this.viewModel.relatedTableHasInvalidPendingEdits}get relatedTableHasPendingEdits(){return this.viewModel.relatedTableHasPendingEdits}get relatedTables(){return this.viewModel.relatedTables}get relationship(){return this.viewModel.relationship}get relationshipColumnConfigs(){return this.viewModel.relationshipColumnConfigs}set relationshipColumnConfigs(e){this.viewModel.relationshipColumnConfigs=e}get relationshipColumns(){return this.viewModel.relationshipColumns}get relationshipConfig(){return this.viewModel.relationshipConfig}set relationshipConfig(e){this.viewModel.relationshipConfig=e}get relationshipInfos(){return this.viewModel.relationshipInfos}get returnGeometryEnabled(){return this.viewModel.returnGeometryEnabled}set returnGeometryEnabled(e){this.viewModel.returnGeometryEnabled=e}get returnMEnabled(){return this.viewModel.returnMEnabled}set returnMEnabled(e){this.viewModel.returnMEnabled=e}get returnZEnabled(){return this.viewModel.returnZEnabled}set returnZEnabled(e){this.viewModel.returnZEnabled=e}get rowHighlightIds(){return this.viewModel.rowHighlightIds}set rowHighlightIds(e){this.viewModel.rowHighlightIds=e}get selectionManager(){return this.viewModel.selectionManager}set selectionManager(e){this.viewModel.selectionManager=e}get selectionSource(){return this.viewModel.selectionSource}set selectionSource(e){this.viewModel.selectionSource=e}get showAllRelatedTables(){return this.viewModel.showAllRelatedTables}set showAllRelatedTables(e){this.viewModel.showAllRelatedTables=e}get showPrompt(){return this.viewModel.showPrompt}set showPrompt(e){this.viewModel.showPrompt=e}get showRelatedTableCallback(){return this.viewModel.showRelatedTableCallback}set showRelatedTableCallback(e){this.viewModel.showRelatedTableCallback=e}get size(){return this.viewModel.size}get state(){return this.viewModel.state}get supportsAddAttachments(){return this.viewModel.supportsAddAttachments}get supportsAttachments(){return this.viewModel.supportsAttachments}get supportsDeleteAttachments(){return this.viewModel.supportsDeleteAttachments}get supportsResizeAttachments(){return this.viewModel.supportsResizeAttachments}get supportsUpdateAttachments(){return this.viewModel.supportsUpdateAttachments}get syncTemplateOnChangesEnabled(){return this.viewModel.syncTemplateOnChangesEnabled}set syncTemplateOnChangesEnabled(e){this.viewModel.syncTemplateOnChangesEnabled=e}get syncViewSelection(){return this.viewModel.syncViewSelection}set syncViewSelection(e){this.viewModel.syncViewSelection=e}get syncWithViewSelectionManager(){return this.syncViewSelection}set syncWithViewSelectionManager(e){this.syncViewSelection=e}get tableController(){return this.viewModel.tableController}set tableController(e){this.viewModel.tableController=e}get tableParent(){return this.viewModel.tableParent}set tableParent(e){this.viewModel.tableParent=e}get tableTemplate(){return this.viewModel.tableTemplate}set tableTemplate(e){this.viewModel.tableTemplate=e}get tableTemplateOverride(){return this.viewModel.tableTemplateOverride}set tableTemplateOverride(e){this.viewModel.tableTemplateOverride=e}get timeExtent(){return this.viewModel.timeExtent}set timeExtent(e){this.viewModel.timeExtent=e}get timeZone(){return this.viewModel.timeZone}set timeZone(e){this.viewModel.timeZone=e}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}get viewTimeEnabled(){return this.viewModel.viewTimeEnabled}set viewTimeEnabled(e){this.viewModel.viewTimeEnabled=e}get visibleColumns(){return this.viewModel.visibleColumns}get visibleElementsOverride(){let{attachmentsViewOptions:e,relatedTable:t,tableController:n,visibleElements:r}=this,{columnDescriptions:i,columnMenus:a,tooltips:o}=r,s=e.objectId!=null;if(t)return new k({columnDescriptions:i,columnMenus:a,tooltips:o,close:r.close,header:r.header,layerDropdown:r.layerDropdown,layerDropdownIcons:r.layerDropdownIcons,menu:r.menu,menuItems:r.menuItems,progress:r.progress,selectionColumn:!1,columnMenuItems:new D({sortAscending:!1,sortDescending:!1})});if(n){let e=n.relatedTable===this,t=n.allRelatedTablesVisible,c=e&&r.selectionColumn&&!t&&!s,l=e&&!t&&!s;return new k({columnDescriptions:i,columnMenus:a,tooltips:o,selectionColumn:c,close:!1,header:!1,layerDropdown:!1,menu:!1,pendingEditsFooter:!1,progress:!1,columnMenuItems:new D({sortAscending:l,sortDescending:l})})}return s?new k({columnDescriptions:i,columnMenus:a,tooltips:o,close:r.close,header:r.header,layerDropdown:r.layerDropdown,layerDropdownIcons:r.layerDropdownIcons,menu:r.menu,menuItems:r.menuItems,progress:r.progress,selectionColumn:!1,columnMenuItems:new D({sortAscending:!1,sortDescending:!1})}):null}addPendingEdits(e){this.viewModel.addPendingEdits(e)}clearSelection(){this.effectiveTable.viewModel.clearSelection()}async deleteAttachments(e,t,n){if(e!=null&&t?.length){if(n){this._showDeleteAttachmentPrompt(e,t);return}await this.viewModel.deleteAttachments(e,t)}}async deleteSelection(e){if(this.highlightIds.length){if(e){this._showDeleteSelectionPrompt();return}await this.viewModel.deleteSelection()}}async discardPendingEdits(e,t){return t?this._showDiscardEditsPrompt(e):this.viewModel.discardPendingEdits(e)}async downloadAttachmentById(e,t){return this.viewModel.downloadAttachmentById(e,t)}drainRelatedTables(){this.viewModel.drainRelatedTables()}async exportSelectionToCSV(e){return this.viewModel.exportSelectionToCSV(e)}findColumn(e){return this.viewModel.findColumn(e)}getFeatureStoreItemByObjectId(e){return this.viewModel.getFeatureStoreItemByObjectId(e)}goToPage(e){this.viewModel.goToPage(e)}hideAllColumns(){this.viewModel.hideAllColumns()}hideColumn(e){this.grid?.hideColumn(e)}nextPage(){this.viewModel.nextPage()}previousPage(){this.viewModel.previousPage()}async refresh(){await this.viewModel.refresh()}refreshCellContent(){this.viewModel.refreshCellContent()}async saveAttachmentsViewForm(){await this.viewModel.saveAttachmentsViewForm()}async savePendingEdits(){await this.viewModel.savePendingEdits()}showAllColumns(){this.viewModel.showAllColumns()}showColumn(e){this.grid?.showColumn(e)}sortColumn(e,t){this.viewModel.sortColumn(e,t)}scrollLeft(){this.viewModel.scrollLeft()}scrollToBottom(){this.viewModel.scrollToBottom()}scrollToIndex(e){this.viewModel.scrollToIndex(e)}scrollToRow(e){this.viewModel.scrollToRow(e)}scrollToTop(){this.viewModel.scrollToTop()}toggleColumnVisibility(e){this.viewModel.toggleColumnVisibility(e)}get visibilityMenuColumns(){let e=this.effectiveTable.columns;return this.columnVisibilityMenuConfig?.frozenColumnsExcluded?e.filter(e=>!e.frozen&&!e.frozenToEnd).toArray():e.toArray()}async zoomToSelection(){return this.effectiveTable.viewModel.zoomToSelection()}render(){let{_effectiveVisibleElements:e,isQueryingOrSyncing:t,menuConfig:n,state:r}=this;return H(`div`,{bind:this,class:this.classes(Z.base,R.widget)},H(`calcite-panel`,{bind:this,class:Z.content,closable:e.close,closed:this.closed,collapsed:this.collapsed,collapsible:e.collapse,description:this._effectiveDescription,dir:this.direction,disabled:this.disabled||r===`disabled`&&!this._effectiveLayers?.length,heading:e.header?this._effectiveTitle:void 0,key:`table-content`,loading:r===`loading`,menuOpen:!!n?.open,overlayPositioning:`fixed`,onCalcitePanelClose:()=>{this.closed=!0,this.emit(`close`)},onCalcitePanelToggle:e=>{this.collapsed=e.target.collapsed,this.emit(`toggle`)}},e.progress?H(`calcite-progress`,{type:t?`indeterminate`:`determinate`}):null,this._showLayerDropdown?this._renderLayerDropdown():null,this._renderColumnVisibilityAction(),this._renderHeaderMenuActions(),this._renderNavigationBar(),this._renderTables(),this._renderError(),this._renderFooterContent()),this._renderColumnVisibilityPopover(),this._renderPrompt(),this._renderDialog())}_renderTables(){let{grid:e,relatedTables:t}=this,n=this.classes(Z.tableContainer);if(t.length){let r=this.classes(Z.base,this.allRelatedTablesVisible?Z.expanded:Z.collapsed,this._attachmentsViewIsVisible?Z.tableContainerWithAttachments:void 0);return H(`div`,{class:n},H(`calcite-panel`,{overlayPositioning:`fixed`},H(`div`,null,[this._shouldShowGrid?H(`div`,{class:r},e?.render(),this._renderPagination()):void 0,...this._filteredTables.map(e=>{let n=t.indexOf(e);return H(`div`,{class:r,key:`related-${n}`},e.render())}),,])))}return this.attachmentsViewOptions.objectId==null?[H(`div`,{class:n},e?.render()),this._renderPagination()]:H(`div`,{class:n},H(`calcite-panel`,{overlayPositioning:`fixed`},H(`div`,null,[H(`div`,{class:this.classes(Z.base,Z.collapsed)},e?.render(),this._renderPagination()),this._renderAttachmentsView()])))}_renderPagination(){if(this.paginationEnabled)return H(`calcite-pagination`,{pageSize:1,startItem:this.pageIndex+1,totalItems:this.pageCount,onCalcitePaginationChange:e=>{this._attachmentsDialogPreviewLoading=!1,this.goToPage(e.currentTarget.startItem-1)}})}_renderError(){let{messages:e}=this;return H(`calcite-alert`,{autoClose:!0,autoCloseDuration:`fast`,icon:Q.exclamationMarkTriangle,kind:`danger`,label:e.errorOccured,open:this._hasAttachmentsViewError,slot:`alerts`,topLayerDisabled:this.topLayerDisabled,onCalciteAlertClose:()=>{this.attachmentsViewOptions.error=null}},H(`span`,{slot:`message`},e.errorOccured))}_renderFooterContent(){if(!this.hasPendingEdits||!this._effectiveVisibleElements.pendingEditsFooter)return;let{hasInvalidPendingEdits:e,isQueryingOrSyncing:t,messages:n,messagesCommon:r}=this,i=e||t,a=this.hasContingentValues,o=[H(`calcite-button`,{appearance:`outline`,disabled:t,iconStart:Q.reset,key:`footer-reset-button`,slot:`footer-end`,width:`auto`,onclick:()=>void this.discardPendingEdits()},r.reset),H(`calcite-button`,{disabled:i,iconStart:Q.save,key:`footer-save-button`,loading:this.isSyncing,slot:`footer-end`,width:`auto`,onclick:()=>{this.savePendingEdits()}},r.save)];if(a){let t=e?n.contingentValues.hasInvalidValues:n.contingentValues.hasValidValues,r=e?Q.exclamationMarkTriangle:Q.checkCircle,i=e?Z.footerIconDanger:Z.footerIconSuccess;o.push(H(`div`,{class:Z.footerMessage,key:`footer-message`,slot:`footer-start`},H(`calcite-icon`,{class:i,icon:r,scale:`s`,slot:`footer-start`}),t))}return o}_renderPrompt(){return this.prompt?H(E,{...this.prompt,headingLevel:2}):void 0}_showDeleteSelectionPrompt(){let{messages:e,messagesCommon:n}=this,r=t(e.deleteSelectionCount,{count:this.highlightIds.length});this.showPrompt({title:r,message:e.deleteRecordsRemoved,context:`danger`,actions:{primary:{label:n.delete,action:async()=>{try{await this.viewModel.deleteSelection()}finally{this.clearPrompt()}}},secondary:{label:e.keepRecords,action:()=>this.clearPrompt()}}})}_showDeleteAttachmentPrompt(e,n){let{messages:r,messagesCommon:i}=this,a=t(r.deleteAttachmentCount,{count:n.length});this.showPrompt({title:a,message:r.deleteAttachmentConfirmation,context:`danger`,actions:{primary:{label:i.delete,action:async()=>{try{await this.deleteAttachments(e,n,!1)}finally{this.clearPrompt()}}},secondary:{label:i.cancel,action:()=>this.clearPrompt()}}})}async _showDiscardEditsPrompt(e){let t=Promise.withResolvers(),{messagesEditor:n}=this;return this.showPrompt({title:n.cancelEditTitle,message:n.cancelEditWarningMessage,context:`danger`,actions:{primary:{label:n.discardEdits,action:async()=>{try{await this.discardPendingEdits(e)}finally{t.resolve(!0)}}},secondary:{label:n.continueEditing,action:()=>t.resolve(!1)}}}),t.promise.finally(()=>this.clearPrompt())}_onTableViewChange(e){this.hasPendingEdits?this._showDiscardEditsPrompt().then(t=>t&&e()):e()}_resetNestedViews(){this.relatedTable&&this.drainRelatedTables(),this.effectiveTable.attachmentsViewOptions.objectId=null}_renderDialog(){let{attachmentsViewOptions:e,messages:t}=this,{objectId:n}=e;return H(`calcite-dialog`,{class:Z.dialog,description:this.viewModel.getFeatureTitleSync(n),heading:t.attachments,modal:!0,open:this._dialogIsOpen,placement:`cover`,width:`l`,onCalciteDialogClose:()=>this._onDialogClose()},this._renderDialogContent())}_renderDialogContent(){let e=this.attachmentsViewOptions.dialogInfo;if(e)return this._renderAttachmentsDialogContent(e)}_renderAttachmentsDialogContent(e){let{attachmentsViewOptions:t,messages:n}=this,{attachmentInfos:r}=t,i=r.indexOf(e);return H(U,null,H(`div`,{class:Z.dialogHeader,key:`header`,slot:`content-top`},H(`span`,null,e.name),H(`calcite-button`,{appearance:`outline`,onclick:()=>{t.attachmentId=e.id,t.dialogId=null}},n.viewDetails)),H(`calcite-progress`,{type:this._attachmentsDialogPreviewLoading?`indeterminate`:`determinate`}),H(`div`,{class:Z.dialogContent,key:`content`},this._renderAttachmentsViewDetailsImage(e)),H(`calcite-pagination`,{pageSize:1,slot:`footer`,startItem:i+1,totalItems:r.length,onCalcitePaginationChange:e=>{let n=e.currentTarget.startItem-1,i=r[n]?.id;t.dialogId=i}}))}_onDialogClose(){let e=this.attachmentsViewOptions;e.dialogId!=null&&(e.dialogId=null),this._attachmentsDialogPreviewLoading=!1}_renderHeaderMenuAction(e){let{disabled:t,hidden:n,icon:r,text:i,clickFunction:a}=e;if(!n)return H(`calcite-action`,{disabled:t??this.menuConfig?.disabled,icon:r??void 0,key:i,slot:`header-menu-actions`,text:i,textEnabled:!0,title:i,onclick:()=>a()})}_renderHeaderMenuActions(){return this._shouldShowMenu?[this._renderDefaultHeaderMenuActions(),this._renderCustomHeaderMenuActions()]:[]}_renderDefaultHeaderMenuActions(){if(!this._hasDefaultMenuItems)return[];let{messages:e}=this;return[this._showRefreshDataAction&&{icon:Q.refresh,text:e.refreshData,clickFunction:()=>this.refresh()},this._showDeleteSelectionAction&&{icon:Q.delete,text:e.deleteSelection,clickFunction:()=>this.deleteSelection(!0)},this._showClearSelectionAction&&{icon:Q.clearSelection,text:e.clearSelection,clickFunction:()=>this.clearSelection()},this._showZoomToSelectionAction&&{icon:Q.zoomToSelection,text:e.zoomToSelection,clickFunction:()=>this.zoomToSelection()},this._showSelectedRecordsShowSelectedAction&&{icon:Q.showSelected,text:e.showSelected,clickFunction:()=>{let{objectIds:e}=this;e.removeAll(),e.addMany(this.highlightIds.toArray())}},this._showSelectedRecordsShowAllAction&&{icon:Q.showAll,text:e.showAllRecords,clickFunction:()=>this.objectIds.removeAll()},this._showExportSelectionToCSVAction&&{icon:Q.exportToCSV,text:e.exportSelectionCSV,clickFunction:()=>this.exportSelectionToCSV()}].filter(n).map(e=>e&&this._renderHeaderMenuAction(e))}_renderCustomHeaderMenuActions(){return this.menuConfig?.items?.map(({disabled:e,hidden:t,icon:n,label:r,clickFunction:i})=>this._renderHeaderMenuAction({hidden:typeof t==`function`?t():t,icon:n,text:r,disabled:typeof e==`function`?e():e,clickFunction:e=>i(e)}))??[]}_renderColumnVisibilityAction(){if(!this._showColumnVisibilityAction)return[];let{_columnVisibilityActions:e,id:t}=this,n=this.messages.menuText.columnVisibility;return H(`calcite-action`,{afterCreate:n=>e.set(t,n),afterRemoved:()=>e.delete(t),bind:this,disabled:this._columnVisibilityActionDisabled,icon:Q.showColumn,id:`${t}__toggle-columns-action`,slot:`header-actions-end`,text:n},this._effectiveVisibleElements.tooltips?H(`calcite-tooltip`,{closeOnClick:!0,overlayPositioning:`fixed`,placement:`bottom-end`,referenceElement:e.get(t),topLayerDisabled:this.topLayerDisabled},n):null)}_renderColumnVisibilityPopover(){if(!this._showColumnVisibilityAction||this._columnVisibilityActionDisabled)return;let e=this.visibleElements.columnVisibilityMenuItems.header,t=this.messages.menuText.columnVisibility;return H(`calcite-popover`,{autoClose:!0,class:Z.menuPopover,closable:e,heading:e?t:void 0,label:t,overlayPositioning:`fixed`,placement:this.columnVisibilityMenuConfig?.placement,referenceElement:this._columnVisibilityActions.get(this.id),topLayerDisabled:this.topLayerDisabled},this._renderColumnVisibilityList())}_renderColumnVisibilityList(){let{visibilityMenuColumns:e,messages:{menuText:t}}=this;if(e.length!==0)return H(`calcite-list`,{afterCreate:W,afterRemoved:G.bind(this),afterUpdate:W,bind:this,"data-node-ref":`_columnVisibilityList`,dir:this.direction,displayMode:`nested`,filterEnabled:this.visibleElements.columnVisibilityMenuItems.filter,filterPlaceholder:t.searchFields,label:t.fieldVisibility,selectionMode:`multiple`,onCalciteListChange:()=>this._syncColumnVisibility(),onCalciteListFilter:()=>this.scheduleRender()},this._renderColumnToggleAll(),e.map(e=>{let t=A(e)?e.columns?.map(e=>this._renderColumnListItem({column:e})):void 0;return this._renderColumnListItem({column:e,items:t})}),H(`calcite-notice`,{appearance:`transparent`,kind:`neutral`,open:!0,slot:`filter-no-results`},H(`div`,{slot:`message`},t.noMatchesFound)))}_syncColumnVisibility(){let{effectiveTable:e,_columnVisibilityList:t}=this;if(!t)return;let n=new Set(t.selectedItems.map(e=>e.value)),r=!!this.columnVisibilityMenuConfig?.frozenColumnsExcluded;e.allColumns.forEach(t=>{r&&(t.frozen||t.frozenToEnd)||(n.has(t.fieldName)?e.showColumn(t.fieldName):e.hideColumn(t.fieldName))})}_renderColumnToggleAll(){if(!this.visibleElements.columnVisibilityMenuItems.toggleAll)return;let{_columnVisibilityList:e}=this;if(e&&e.filteredItems?.length)return H(`calcite-button`,{appearance:`transparent`,width:`full`,onclick:()=>this._toggleAllColumns()},this._getColumnToggleAllText())}_getColumnToggleAllText(){let{_columnVisibilityList:e,effectiveTable:t,messages:{menuText:n}}=this;return e?e.filterText===``?t.allColumnsVisible?n.deselectAll:n.selectAll:this._allColumnsAreVisible(e.filteredItems.map(e=>e.value))?n.deselectAll:n.selectAll:``}_renderColumnListItem(e){let{column:t,items:n}=e,{effectiveLabel:r,fieldName:i,hidden:a}=t,o=!(!n?.length||a)||void 0;return H(`calcite-list-item`,{expanded:o,key:`toggle-columns__item-${i}`,label:r,metadata:{description:t.effectiveDescription,type:j(t)?t.field.type:void 0},selected:!a,value:i},n)}_renderLayerDropdown(){let e=this.messages.selectALayer;return H(`div`,{class:Z.layerDropdownMenu,key:`${this.id}-layerDropdown`,slot:`header-actions-start`},H(`calcite-dropdown`,{bind:this,maxItems:5,overlayPositioning:`fixed`,placement:`bottom-start`,topLayerDisabled:this.topLayerDisabled},H(`calcite-action`,{icon:Q.layers,slot:`trigger`,text:e,title:e}),H(`calcite-dropdown-group`,{selectionMode:`single`},this._effectiveLayers.map((e,t)=>this._renderLayerDropdownItem(e,t))??null)))}_renderLayerDropdownItem(e,t){let n=this.visibleElements.layerDropdownIcons;return H(`calcite-dropdown-item`,{iconStart:n?z(e):void 0,key:`dropdown-item-${t}`,label:e.title??``,selected:e===this.layer,value:e.id,onCalciteDropdownItemSelect:()=>this._onTableViewChange(()=>this.layer=e)},e.title)}_onRelatedNavigationItemClick(e){this.viewModel.drainRelatedTablesAboveIndex(e)}_collapseRelatedTable(e){this.viewModel.collapseRelatedTable(this.effectiveTable,e)}_onShowRelatedTable(e){this.showRelatedTableCallback||this.hasPendingEdits||(this._collapseRelatedTable(e),this._createRelatedTable(e))}async _createRelatedTable(e){let{autoRefreshEnabled:t,autoSaveEnabled:n,direction:r,editingEnabled:i,effectiveTable:a,multipleSelectionEnabled:o,paginationEnabled:s,pageSize:c,view:l,viewModel:u}=this,{layer:d,objectId:f,relatedLayer:p,relationshipId:m}=e;await d.load();let h=this.attachmentsEnabled&&F(d),g=new K({layer:d,autoRefreshEnabled:t,autoSaveEnabled:n,attachmentsEnabled:h,direction:r,editingEnabled:i,multipleSelectionEnabled:o,paginationEnabled:s,pageSize:c,relatedRecordsEnabled:!0,relationshipConfig:{objectId:f,relatedLayer:p,relationshipId:m},relationshipColumnConfigs:I(d,m),tableController:this,tableParent:a,view:l,showRelatedTableCallback:e=>u.emit(`show-related-table`,e)});this.relatedTables.add(g),this.scheduleRender()}_renderAttachmentsView(){switch(this.attachmentsViewOptions.effectiveMode){case`list`:return this._renderAttachmentsViewList();case`details`:return this._renderAttachmentsViewDetails();case`file`:return this._renderAttachmentsViewFile()}}_renderAttachmentsViewFile(){let e=this.attachmentsViewOptions,{objectId:t}=e;if(t!=null)return[H(`div`,{class:Z.attachmentsView,key:`attachments-view`},this._renderAttachmentsViewInformation(),H(`div`,{class:Z.attachmentsViewContent,key:`attachments-view-content`},H(`div`,{bind:this,class:Z.attachmentsViewDropArea,ondragover:e=>e.preventDefault(),ondrop:this._onAttachmentsViewDrop},H(`calcite-icon`,{class:Z.attachmentsViewIcon,icon:Q.upload,scale:`l`}),this._renderAttachmentsViewFileLabelNode(),this._renderAttachmentsViewFileMessageNode(),H(`form`,{afterCreate:t=>e.form=t,afterRemoved:()=>e.form=null,bind:this,key:`attachments-form`},H(`fieldset`,null,this._renderAttachmentsViewFileNameNode(),H(`input`,{afterCreate:W,afterRemoved:G,afterUpdate:W,bind:this,"data-node-ref":`_attachmentsInput`,files:e.candidates,hidden:!0,name:`attachment`,type:`file`,onchange:e=>this._onAttachmentsViewCandidateChange(e)}),this._renderAttachmentsViewFileSelectNode(),this._renderAttachmentsViewFileSaveNode(),this._renderAttachmentsViewFileCancelNode())))))]}_renderAttachmentsViewFileLabelNode(){if(this.attachmentsViewOptions.fileMode===`replace`)return H(`span`,{class:Z.attachmentsViewDropAreaLabel,key:`replace-file-node`},this.messages.replaceFile)}_renderAttachmentsViewFileMessageNode(){let e=this.attachmentsViewOptions;if(e.hasCandidates)return;let{messages:t}=this,n=this.supportsAddAttachments?e.objectId==null?t.noFeature:t.dragAndDropToUpload:t.editingRestricted;return H(`span`,{class:Z.attachmentsViewDropAreaMessage,key:`message-node`},n)}_renderAttachmentsViewFileNameNode(){let e=this.attachmentsViewOptions.candidates,t=Array.from(e??[]).at(-1);if(t)return H(`span`,{class:Z.attachmentsViewDropAreaMessage,key:`filename-node`},t.name)}_renderAttachmentsViewFileSelectNode(){if(this.supportsAddAttachments)return H(`calcite-button`,{appearance:`outline-fill`,disabled:this.isSyncingAttachments,iconStart:Q.folderOpen,key:`select-node`,onclick:()=>{this._resetAttachmentsInput(),this._attachmentsInput?.click()}},this.messages.selectFile)}_renderAttachmentsViewFileSaveNode(){let{isSyncingAttachments:e,messages:t}=this,{attachmentInfo:n,hasCandidates:r}=this.attachmentsViewOptions;if(this.supportsAddAttachments&&r)return H(`calcite-button`,{appearance:`solid`,disabled:e,iconStart:Q.save,key:`save-node`,loading:e,onclick:()=>{this.saveAttachmentsViewForm()}},n?t.updateAttachment:t.addAttachment)}_renderAttachmentsViewFileCancelNode(){let{hasAttachments:e,hasCandidates:t}=this.attachmentsViewOptions;if(e||t)return H(`calcite-button`,{appearance:`transparent`,bind:this,disabled:this.isSyncingAttachments,key:`cancel-node`,onclick:()=>{this._resetAttachmentsInput(),this.attachmentsViewOptions.cancel()}},this.messagesCommon.cancel)}_renderAttachmentsViewDetails(){let{attachmentInfo:e}=this.attachmentsViewOptions;if(e)return[H(`div`,{class:Z.attachmentsView,key:`attachments-view`},this._renderAttachmentsViewInformation(),H(`div`,{class:Z.attachmentsViewContent,key:`attachments-view-content`},H(`div`,{class:Z.attachmentsViewDetails},this._renderAttachmentsViewDetailsPreview(e))))]}_renderAttachmentsViewDetailsPreview(e){let t=[this._renderAttachmentsViewDetailsImage(e)];if(S(e.contentType)){let n=this.messages.maximize;t.push(H(`calcite-action`,{icon:Q.expand,label:n,text:n,textEnabled:!0,title:n,onclick:t=>{t.preventDefault(),this.attachmentsViewOptions.dialogId=e.id}}))}return t}_renderAttachmentsViewDetailsImage(e){let{contentType:t,name:n,size:r,url:i}=e,{messages:a}=this;return S(t)?H(`img`,{afterCreate:()=>this._attachmentsDialogPreviewLoading=!0,alt:n,key:`thumbnail-image-${n}`,src:`${i}${i?.includes(`?`)?`&`:`?`}s=${r}`,title:n,onerror:()=>this._attachmentsDialogPreviewLoading=!1,onload:()=>this._attachmentsDialogPreviewLoading=!1}):[H(`calcite-icon`,{icon:C(t),key:`thumbnail-icon-${n}`,scale:`l`,textLabel:n,title:n}),a.noPreviewAvailable]}_renderAttachmentsViewInformation(){let{attachmentsViewOptions:e,messages:t,messagesUnits:n}=this,{attachmentInfo:r,objectId:i}=e;if(r&&i!=null)return H(`div`,{class:Z.attachmentsViewInformation,key:`information`},this._renderAttachmentViewInformationButtons(r,i),H(`span`,{class:Z.attachmentsViewInformationLabel,key:`file-label`},t.fileName),H(`span`,{class:Z.attachmentsViewInformationData,key:`file-value`},r.name),H(`span`,{class:Z.attachmentsViewInformationLabel,key:`type-label`},t.attachmentType),H(`span`,{class:Z.attachmentsViewInformationData,key:`type-value`},this._getLabelForAttachmentType(r)),this._renderAttachmentKeywordDetails(r),H(`span`,{class:Z.attachmentsViewInformationLabel,key:`size-label`},t.size),H(`span`,{class:Z.attachmentsViewInformationData,key:`size-span`},d(n,r.size??0)))}_renderAttachmentViewInformationButtons(e,t){let{attachmentsViewOptions:n,messages:r,messagesCommon:i}=this,a=n.effectiveMode!==`details`,o=e.id,s=[H(`calcite-button`,{appearance:`outline`,disabled:a,key:`download-button`,width:`full`,onclick:e=>{e.preventDefault(),this.downloadAttachmentById(t,o)}},r.download)];return this.supportsUpdateAttachments&&s.push(H(`calcite-button`,{appearance:`outline`,disabled:a,key:`replace-button`,width:`full`,onclick:()=>{n.mode=`file`,n.attachmentId=o}},r.replace)),this.supportsDeleteAttachments&&s.push(H(`calcite-button`,{appearance:`outline`,disabled:a,key:`delete-button`,width:`full`,onclick:()=>{this.deleteAttachments(t,[o],!0)}},i.delete)),s}_renderAttachmentKeywordDetails({keywords:e}){if(e&&e!==``)return[H(`span`,{class:Z.attachmentsViewInformationLabel,key:`keyword-label`},this.messages.keyword),H(`span`,{class:Z.attachmentsViewInformationData,key:`keyword-value`},e)]}_renderAttachmentsViewList(){let{attachmentsViewOptions:e,isSyncingAttachments:t,messages:n,messagesUnits:r}=this,{attachmentInfos:i,objectId:a}=e;return H(`calcite-list`,{afterCreate:W,afterRemoved:G,afterUpdate:W,bind:this,class:Z.attachmentsViewList,"data-node-ref":`attachmentsList`,key:`attachments-list-${a}`,label:n?.attachments,loading:t,selectionMode:this.supportsDeleteAttachments?`multiple`:`none`,onCalciteListChange:()=>this.scheduleRender(),ondragover:e=>e.preventDefault(),ondrop:this._onAttachmentsViewDrop},...i?.map(t=>{let{id:i,name:o,size:s}=t,c=d(r,s??0);return H(`calcite-list-item`,{afterRemoved:()=>this.scheduleRender(),key:`attachment-${i}`,label:o,value:i},this._renderAttachmentsViewListPreview(t),H(`span`,{class:Z.attachmentsViewListFileSize,slot:`actions-end`,title:c},c),H(`calcite-action`,{icon:Q.downloadTo,key:`download`,label:o,slot:`actions-end`,text:n.downloadAttachment,title:n.downloadAttachment,onclick:e=>{e.preventDefault(),this.downloadAttachmentById(a??-1,i)}}),H(`calcite-action`,{icon:Q.chevronRight,iconFlipRtl:!0,key:`details`,label:o,slot:`actions-end`,text:n.viewAttachment,title:n.viewAttachment,onclick:()=>{e.mode=`details`,e.attachmentId=i}}))}))}_renderAttachmentsViewListPreview(e){return H(`div`,{class:Z.attachmentsViewListThumbnail,slot:`content-start`},H(`span`,null,this._renderAttachmentsViewListImage(e)))}_renderAttachmentsViewListImage(e,t=64){let{contentType:n,name:r,size:i,url:a}=e,o=`${a}${a?.includes(`?`)?`&`:`?`}w=${t}&s=${i}`;return this.supportsResizeAttachments&&S(n)?H(`img`,{alt:r,key:`thumbnail-image-${r}`,src:o,title:r}):H(`calcite-icon`,{icon:C(n),key:`thumbnail-icon-${r}`,scale:`l`,textLabel:r,title:r})}_onAttachmentsViewCandidateChange({target:e}){this.attachmentsViewOptions.candidates=e?.files}_onAttachmentsViewDrop(e){e.preventDefault(),(this.supportsAddAttachments||this.supportsUpdateAttachments)&&(this.attachmentsViewOptions.mode=`file`,this.attachmentsViewOptions.candidates=e.dataTransfer?.files)}_resetAttachmentsInput(){this._attachmentsInput&&(this._attachmentsInput.value=``)}_getLabelForAttachmentType({contentType:e}){let t=this.messages,n=w(e);return t.attachmentTypes[n]}_renderNavigationBar(){let{effectiveTable:e,messages:n,messagesCommon:r,navigationScale:i,relatedTable:a,relatedTables:o}=this;if(!this._shouldShowNavigationBar)return;let{attachmentsList:s,attachmentsViewOptions:c,layer:l,supportsAddAttachments:u,supportsDeleteAttachments:d}=e;if(!l)return;let{attachmentInfos:f,objectId:p}=c,m=p!=null,h=f.length,g=s?.selectedItems?.length??0,_=`${l.objectIdField}: ${p}`,v=t(n.selectedCount,{count:g}),y=t(n.attachmentsCount,{count:h}),b=m?H(`calcite-action`,{bind:this,icon:Q.chevronRight,iconFlipRtl:!0,key:`navigation-feature`,scale:i,text:_,textEnabled:!0,title:_,onclick:()=>e.scrollToRow(p)}):void 0,x=m?H(`calcite-action`,{icon:Q.chevronRight,iconFlipRtl:!0,key:`navigation-attachments-label`,label:y,scale:i,text:y,textEnabled:!0,title:y,onclick:()=>{h>0&&(c.mode=`list`)}}):void 0,S=m?H(`calcite-chip`,{closable:!0,closed:g===0,key:`navigation-chip`,kind:`inverse`,label:v,scale:`s`,selected:!0,title:v,value:`selected`,onCalciteChipClose:()=>s?.selectedItems?.forEach(e=>e.selected=!1)},v):void 0,C=a?H(`calcite-label`,{layout:`inline`,scale:i},n.showAllTables,H(`calcite-switch`,{checked:this.allRelatedTablesVisible,scale:i,onCalciteSwitchChange:e=>this.showAllRelatedTables=!!e.currentTarget.checked})):void 0,w=m&&c.effectiveMode===`list`&&p!=null&&g&&d?H(`calcite-action`,{icon:Q.delete,iconFlipRtl:!0,key:`attachments-trash-all`,scale:i,text:r.delete,textEnabled:!0,title:t(n.deleteAttachmentCount,{count:g}),onclick:()=>{e.deleteAttachments(p,s?.selectedItems?.map(e=>e.value)??[],!0)}}):void 0,T=m&&c.effectiveMode===`list`&&u?H(`calcite-action`,{bind:this,icon:Q.plus,iconFlipRtl:!0,key:`attachments-add`,scale:i,text:n.addAttachment,textEnabled:!0,title:n.addAttachment,onclick:()=>{c.objectId=p,c.attachmentId=null,c.mode=`file`}}):void 0;return H(`div`,{class:Z.tableNavigation,key:`table-nav`},H(`calcite-action`,{icon:Q.moveUp,iconFlipRtl:!0,key:`go-back`,scale:i,text:this.layer?.title??``,textEnabled:!1,title:a?n.exitRelatedRecords:n.exitAttachments,onclick:()=>this._onTableViewChange(this._resetNestedViews)}),o.toArray().map((e,t)=>this._renderRelatedTableNavigationAction(e,t)),b,x,H(`div`,null,S,C,w,T))}_renderRelatedTableNavigationAction(e,t){let n=this._getLabelForRelatedTableNavigationAction(e);return H(`calcite-action`,{icon:Q.chevronRight,iconFlipRtl:!0,key:t,scale:this.navigationScale,text:n,textEnabled:!0,title:e.layer?.title||``,onclick:()=>{(t!==this.relatedTables.length-1||this._attachmentsViewIsVisible)&&this._onTableViewChange(()=>this._onRelatedNavigationItemClick(t))}})}_getLabelForRelatedTableNavigationAction(e){let t=e.layer?.title;if(!t)return``;let{relatedTables:n}=this;return n.length<=1?t:n.indexOf(e)!==n.length-1&&t.length>20?`${t.slice(0,20)}...`:t}_allColumnsAreVisible(e){let t=this.columnVisibilityMenuConfig;return e.every(e=>{let n=this.findColumn(e);return n?t?.frozenColumnsExcluded&&(n.frozen||n.frozenToEnd)?!0:n.effectiveVisible:!1})}_toggleAllColumns(){let{_columnVisibilityList:e,effectiveTable:t}=this,n=e?.filteredItems.map(e=>e.value);e?.filterText!==``&&n?.length?this._allColumnsAreVisible(n)?n.forEach(e=>this.hideColumn(e)):n.forEach(e=>this.showColumn(e)):t.allColumnsVisible?t.visibilityMenuColumns.forEach(e=>t.hideColumn(e.fieldName)):t.visibilityMenuColumns.forEach(e=>t.showColumn(e.fieldName))}};e([f()],$.prototype,`_attachmentsDialogPreviewLoading`,void 0),e([f()],$.prototype,`_attachmentsInput`,void 0),e([f()],$.prototype,`_attachmentsViewIsVisible`,null),e([f()],$.prototype,`_columnVisibilityActions`,void 0),e([f()],$.prototype,`_columnVisibilityActionDisabled`,null),e([f()],$.prototype,`_columnVisibilityList`,void 0),e([f()],$.prototype,`_dialogIsOpen`,null),e([f()],$.prototype,`_effectiveDescription`,null),e([f()],$.prototype,`_effectiveLayers`,null),e([f()],$.prototype,`_effectiveTitle`,null),e([f()],$.prototype,`_effectiveVisibleElements`,null),e([f()],$.prototype,`_filteredTables`,null),e([f()],$.prototype,`_hasAttachmentsViewError`,null),e([f()],$.prototype,`_hasCustomMenuItems`,null),e([f()],$.prototype,`_hasDefaultMenuItems`,null),e([f()],$.prototype,`_shouldShowGrid`,null),e([f()],$.prototype,`_shouldShowMenu`,null),e([f()],$.prototype,`_showClearSelectionAction`,null),e([f()],$.prototype,`_showColumnVisibilityAction`,null),e([f()],$.prototype,`_showDeleteSelectionAction`,null),e([f()],$.prototype,`_showExportSelectionToCSVAction`,null),e([f()],$.prototype,`_showLayerDropdown`,null),e([f()],$.prototype,`_shouldShowNavigationBar`,null),e([f()],$.prototype,`_showRefreshDataAction`,null),e([f()],$.prototype,`_showSelectedRecordsShowSelectedAction`,null),e([f()],$.prototype,`_showSelectedRecordsShowAllAction`,null),e([f()],$.prototype,`_showZoomToSelectionAction`,null),e([f()],$.prototype,`_viewLayers`,null),e([f()],$.prototype,`attachmentsList`,void 0),e([f()],$.prototype,`direction`,null),e([f({readOnly:!0})],$.prototype,`grid`,null),e([f()],$.prototype,`actionColumn`,null),e([f()],$.prototype,`actionColumnConfig`,null),e([f({readOnly:!0})],$.prototype,`activeFilters`,null),e([f({readOnly:!0})],$.prototype,`activeSortOrders`,null),e([f()],$.prototype,`allColumns`,null),e([f()],$.prototype,`allColumnsVisible`,null),e([f({readOnly:!0})],$.prototype,`allRelatedTablesVisible`,null),e([f()],$.prototype,`allVisibleColumns`,null),e([f()],$.prototype,`attachmentsColumns`,null),e([f()],$.prototype,`attachmentsEnabled`,null),e([f()],$.prototype,`attachmentsViewOptions`,null),e([f({type:y})],$.prototype,`attributeTableTemplate`,null),e([f()],$.prototype,`autoRefreshEnabled`,null),e([f()],$.prototype,`autoSaveEnabled`,null),e([f()],$.prototype,`canAddRelatedFeature`,null),e([f()],$.prototype,`clearPrompt`,null),e([f()],$.prototype,`closed`,void 0),e([f()],$.prototype,`collapsed`,void 0),e([f()],$.prototype,`columnPerformanceModeEnabled`,null),e([f()],$.prototype,`columnReorderingEnabled`,null),e([f({readOnly:!0})],$.prototype,`columns`,null),e([f()],$.prototype,`columnVisibilityMenuConfig`,void 0),e([f()],$.prototype,`defaultSelectionManager`,null),e([f()],$.prototype,`definitionExpression`,null),e([f()],$.prototype,`description`,void 0),e([f()],$.prototype,`disabled`,void 0),e([f()],$.prototype,`editingEnabled`,null),e([f()],$.prototype,`effectiveSelectionManager`,null),e([f()],$.prototype,`effectiveSize`,null),e([f()],$.prototype,`effectiveTable`,null),e([f()],$.prototype,`effectiveTimeExtent`,null),e([f()],$.prototype,`fieldColumns`,null),e([f({types:m})],$.prototype,`filterGeometry`,null),e([f()],$.prototype,`filterBySelectionEnabled`,null),e([f()],$.prototype,`filterByViewExtent`,null),e([f()],$.prototype,`filterByLayerScaleRange`,null),e([f()],$.prototype,`groupColumns`,null),e([f()],$.prototype,`hasContingentValues`,null),e([f()],$.prototype,`hasInvalidPendingEdits`,null),e([f()],$.prototype,`hasPendingEdits`,null),e([f()],$.prototype,`hiddenFields`,null),e([f()],$.prototype,`highlightEnabled`,null),e([f()],$.prototype,`highlightIds`,null),e([f()],$.prototype,`icon`,null),e([f()],$.prototype,`initialSize`,null),e([f()],$.prototype,`isQueryingOrSyncing`,null),e([f()],$.prototype,`isSyncing`,null),e([f()],$.prototype,`isSyncingAttachments`,null),e([f()],$.prototype,`label`,null),e([f()],$.prototype,`layer`,null),e([f()],$.prototype,`layers`,null),e([f()],$.prototype,`layerView`,null),e([f()],$.prototype,`maxSize`,null),e([f(),B(`esri/widgets/FeatureTable/t9n/FeatureTable`)],$.prototype,`messages`,null),e([f(),B(`esri/t9n/common`)],$.prototype,`messagesCommon`,null),e([f(),B(`esri/widgets/Editor/t9n/Editor`)],$.prototype,`messagesEditor`,void 0),e([f(),B(`esri/core/t9n/Units`)],$.prototype,`messagesUnits`,null),e([f(),B(`esri/widgets/support/t9n/uriUtils`)],$.prototype,`messagesURIUtils`,null),e([f()],$.prototype,`menuConfig`,null),e([f()],$.prototype,`multipleSelectionEnabled`,null),e([f()],$.prototype,`multipleSelectionEnabledOverride`,null),e([f()],$.prototype,`multiSortEnabled`,null),e([f()],$.prototype,`multipleSortPriority`,null),e([f()],$.prototype,`navigationScale`,void 0),e([f()],$.prototype,`noDataMessage`,null),e([f()],$.prototype,`objectIds`,null),e([f()],$.prototype,`outFields`,null),e([f()],$.prototype,`pageCount`,null),e([f()],$.prototype,`pageIndex`,null),e([f()],$.prototype,`pageSize`,null),e([f()],$.prototype,`paginationEnabled`,null),e([f()],$.prototype,`pendingEditsCount`,null),e([f()],$.prototype,`prompt`,null),e([f()],$.prototype,`relatedRecordsEnabled`,null),e([f()],$.prototype,`relatedTable`,null),e([f()],$.prototype,`relatedTableHasContingentValues`,null),e([f()],$.prototype,`relatedTableHasInvalidPendingEdits`,null),e([f()],$.prototype,`relatedTableHasPendingEdits`,null),e([f()],$.prototype,`relatedTables`,null),e([f()],$.prototype,`relationship`,null),e([f()],$.prototype,`relationshipColumnConfigs`,null),e([f()],$.prototype,`relationshipColumns`,null),e([f()],$.prototype,`relationshipConfig`,null),e([f()],$.prototype,`relationshipInfos`,null),e([f()],$.prototype,`returnGeometryEnabled`,null),e([f()],$.prototype,`returnMEnabled`,null),e([f()],$.prototype,`returnZEnabled`,null),e([f()],$.prototype,`rowHighlightIds`,null),e([f()],$.prototype,`selectionManager`,null),e([f()],$.prototype,`selectionSource`,null),e([f()],$.prototype,`showAllRelatedTables`,null),e([f()],$.prototype,`showPrompt`,null),e([f()],$.prototype,`showRelatedTableCallback`,null),e([f()],$.prototype,`size`,null),e([f({readOnly:!0})],$.prototype,`state`,null),e([f()],$.prototype,`supportsAddAttachments`,null),e([f()],$.prototype,`supportsAttachments`,null),e([f()],$.prototype,`supportsDeleteAttachments`,null),e([f()],$.prototype,`supportsResizeAttachments`,null),e([f()],$.prototype,`supportsUpdateAttachments`,null),e([f()],$.prototype,`syncTemplateOnChangesEnabled`,null),e([f()],$.prototype,`syncViewSelection`,null),e([f()],$.prototype,`syncWithViewSelectionManager`,null),e([f({constructOnly:!0})],$.prototype,`tableController`,null),e([f({constructOnly:!0})],$.prototype,`tableParent`,null),e([f({type:M})],$.prototype,`tableTemplate`,null),e([f()],$.prototype,`tableTemplateOverride`,null),e([f()],$.prototype,`title`,void 0),e([f({type:b})],$.prototype,`timeExtent`,null),e([f()],$.prototype,`timeZone`,null),e([f()],$.prototype,`view`,null),e([f({type:O}),V([`cell-click`,`cell-dblclick`,`cell-pointerover`,`cell-pointerout`,`cell-keydown`,`column-reorder`,`show-related-table`])],$.prototype,`viewModel`,void 0),e([f()],$.prototype,`viewTimeEnabled`,null),e([f()],$.prototype,`visibleColumns`,null),e([f({type:k,nonNullable:!0})],$.prototype,`visibleElements`,void 0),e([f({type:k})],$.prototype,`visibleElementsOverride`,null),e([f()],$.prototype,`visibilityMenuColumns`,null),$=K=e([p(`esri.widgets.FeatureTable`)],$);const ee=$;export{ee as default};
|
|
2
|
+
import{__decorate as e}from"tslib";import{substitute as t}from"../intl.js";import{isSome as n}from"../core/arrayUtils.js";import{deprecateWidget as r}from"../core/deprecate.js";import i from"../core/Logger.js";import{watch as a,sync as o,syncAndInitial as s,initial as c,on as l}from"../core/reactiveUtils.js";import{renderingSanitizer as u}from"../core/sanitizerUtils.js";import{formatFileSize as d}from"../core/unitFormatUtils.js";import{property as f,subclass as p}from"../core/accessorSupport/decorators.js";import{geometryTypes as m}from"../geometry/support/typeUtils.js";import{isLayerFromCatalog as h}from"../layers/catalog/catalogUtils.js";import{isKnowledgeGraphLayer as g,isMapImageLayer as _,isSubtypeGroupLayer as v}from"../layers/support/layerUtils.js";import y from"../tables/AttributeTableTemplate.js";import b from"../time/TimeExtent.js";import x from"./Widget.js";import{isSupportedImage as S,getCalciteIconForAttachment as C,getAttachmentTypeCategory as w}from"./Attachments/support/attachmentUtils.js";import{loadPromptComponents as T,Prompt as E}from"./Editor/components/Prompt.js";import D from"./FeatureTable/ColumnMenuVisibleElements.js";import O from"./FeatureTable/FeatureTableViewModel.js";import k from"./FeatureTable/VisibleElements.js";import{isGroupColumn as A,isFieldColumn as j}from"./FeatureTable/support/columnUtils.js";import M from"./FeatureTable/support/TableTemplate.js";import{loadFieldColumnComponents as N,isIFeatureTableSupportedLayer as P,isIFeatureTableSupportedLayerWithAttachments as F,getRelationshipIdsToShow as I}from"./FeatureTable/support/tableUtils.js";import{loadCalciteComponents as L}from"./support/componentsUtils.js";import{globalCss as R}from"./support/globalCss.js";import{getIconForLayer as z}from"./support/iconUtils.js";import{messageBundle as B,vmEvent as V,tsx as H,tsxFragment as U}from"./support/widget.js";import{storeNode as W,discardNode as G}from"./support/widgetUtils.js";var K;const q=`esri-feature-table`,J=`${q}__dialog`,Y=`${q}__table-navigation`,X=`${q}__attachments-view`,Z={base:q,content:`${q}__content`,menuPopover:`${q}__menu-popover`,layerDropdownMenu:`${q}__layer-switcher-menu`,tableContainer:`${q}__table-container`,tableContainerWithAttachments:`${q}__table-container--attachments`,tableNavigation:Y,attachmentsView:X,attachmentsViewContent:`${X}__content`,attachmentsViewDetails:`${X}__details`,attachmentsViewDropArea:`${X}__drop-area`,attachmentsViewDropAreaLabel:`${X}__drop-area__label`,attachmentsViewDropAreaMessage:`${X}__drop-area__message`,attachmentsViewIcon:`${X}__icon`,attachmentsViewInformation:`${X}__information`,attachmentsViewInformationData:`${X}__information__data`,attachmentsViewInformationLabel:`${X}__information__label`,attachmentsViewList:`${X}__list`,attachmentsViewListFileSize:`${X}__list__filesize`,attachmentsViewListThumbnail:`${X}__list__thumbnail`,expanded:`${q}__expanded`,collapsed:`${q}__collapsed`,dialog:`${J}`,dialogContent:`${J}__content`,dialogHeader:`${J}__header`,footerMessage:`${q}__footer__message`,footerIconDanger:`${q}__footer__icon--danger`,footerIconSuccess:`${q}__footer__icon--success`},Q={checkCircle:`check-circle`,chevronRight:`chevron-right`,clearSelection:`clear-selection`,downloadTo:`download-to`,exclamationMarkTriangle:`exclamation-mark-triangle`,expand:`expand`,exportToCSV:`file-csv`,folderOpen:`folder-open`,delete:`trash`,layers:`layers`,moveUp:`move-up`,plus:`plus`,refresh:`refresh`,reset:`reset`,save:`save`,showAll:`selection-x`,showColumn:`show-column`,showSelected:`selection-filter`,table:`table`,upload:`upload`,zoomToSelection:`zoom-to-object`};let $=K=class extends x{constructor(e,t){super(e,t),this._attachmentsDialogPreviewLoading=!1,this._attachmentsInput=null,this._columnVisibilityActions=new Map,this._columnVisibilityList=null,this.attachmentsList=null,this.closed=!1,this.collapsed=!1,this.columnVisibilityMenuConfig=null,this.description=null,this.disabled=!1,this.messagesEditor=null,this.navigationScale=`m`,this.title=null,this.viewModel=new O,this.visibleElements=new k,this.announceDeprecation=()=>{r(i.getLogger(this),`Feature Table`,`arcgis-feature-table`,{version:`5.0`})},this._showDeleteSelectionPrompt=this._showDeleteSelectionPrompt.bind(this),this._showDiscardEditsPrompt=this._showDiscardEditsPrompt.bind(this),this._resetNestedViews=this._resetNestedViews.bind(this)}initialize(){this.addHandles([a(()=>[this.isQueryingOrSyncing,this.editingEnabled],()=>this.scheduleRender()),a(()=>[this._effectiveVisibleElements,this._effectiveVisibleElements.columnDescriptions,this._effectiveVisibleElements.columnMenus,this._effectiveVisibleElements.columnMenuItems,this.allColumns.length],()=>{this.allColumns.forEach(e=>e.visibleElements=this._effectiveVisibleElements),this.refreshCellContent()},o),a(()=>[this.topLayerDisabled,this.columns],()=>this.columns.forEach(e=>e.topLayerDisabled=this.topLayerDisabled),s),a(()=>this._effectiveVisibleElements.selectionColumn,e=>{this.grid&&(this.grid.selectionColumnEnabled=e)},c),l(()=>this.viewModel,`show-related-table`,e=>this._onShowRelatedTable(e)),a(()=>this.editingEnabled,()=>{let{attachmentsViewOptions:e}=this;this.clearPrompt(),e&&(e.form?.reset(),e.candidates=null)}),l(()=>this.effectiveTable,`column-reorder`,()=>this.scheduleRender())])}loadDependencies(){return Promise.all([L({action:()=>import(`@esri/calcite-components/dist/components/calcite-action`),alert:()=>import(`@esri/calcite-components/dist/components/calcite-alert`),button:()=>import(`@esri/calcite-components/dist/components/calcite-button`),chip:()=>import(`@esri/calcite-components/dist/components/calcite-chip`),dialog:()=>import(`@esri/calcite-components/dist/components/calcite-dialog`),dropdown:()=>import(`@esri/calcite-components/dist/components/calcite-dropdown`),"dropdown-group":()=>import(`@esri/calcite-components/dist/components/calcite-dropdown-group`),"dropdown-item":()=>import(`@esri/calcite-components/dist/components/calcite-dropdown-item`),icon:()=>import(`@esri/calcite-components/dist/components/calcite-icon`),label:()=>import(`@esri/calcite-components/dist/components/calcite-label`),list:()=>import(`@esri/calcite-components/dist/components/calcite-list`),"list-item":()=>import(`@esri/calcite-components/dist/components/calcite-list-item`),notice:()=>import(`@esri/calcite-components/dist/components/calcite-notice`),pagination:()=>import(`@esri/calcite-components/dist/components/calcite-pagination`),panel:()=>import(`@esri/calcite-components/dist/components/calcite-panel`),popover:()=>import(`@esri/calcite-components/dist/components/calcite-popover`),progress:()=>import(`@esri/calcite-components/dist/components/calcite-progress`),switch:()=>import(`@esri/calcite-components/dist/components/calcite-switch`),tooltip:()=>import(`@esri/calcite-components/dist/components/calcite-tooltip`)}),T(),N()])}destroy(){this.drainRelatedTables(),this.clearPrompt()}get _attachmentsViewIsVisible(){return!!(this.attachmentsViewOptions.objectId!=null||this.relatedTables.some(e=>e.attachmentsViewOptions.objectId!=null))}get _columnVisibilityActionDisabled(){let e=this.effectiveTable;return e.menuConfig?.disabled??e.columns.length===0}get _dialogIsOpen(){return!!this.attachmentsViewOptions.dialogInfo}get _effectiveDescription(){let{description:e}=this;return e==null?void 0:u.sanitize(typeof e==`function`?e():e)}get _effectiveLayers(){let{layer:e,layers:t}=this,n=t?.length?t.filter(P):[],r=n.length?n:[...this._viewLayers];return e&&!r.includes(e)&&r.push(e),r}get _effectiveTitle(){let{layer:e,messages:n,state:r,highlightIds:i,title:a,size:o}=this;if(a)return u.sanitize(typeof a==`function`?a():a);if(!n)return``;if(!e)return n.noLayer;switch(r){case`disabled`:return n.errorLayer;case`ready`:case`loading`:return n.loading;case`error`:return n.errorData}return t(n.header,{title:u.sanitize(e.title),count:o,selected:i.length})}get _effectiveVisibleElements(){return this.visibleElementsOverride??this.visibleElements}get _filteredTables(){let e=this.relatedTables.toArray(),t=e.length===1;return this.allRelatedTablesVisible?e:t?[e[0]]:this._attachmentsViewIsVisible?e.slice(-1):e.slice(-2)}get _hasAttachmentsViewError(){return this.attachmentsViewOptions.error!=null}get _hasCustomMenuItems(){return!!this.menuConfig?.items?.length}get _hasDefaultMenuItems(){return!!(this._showClearSelectionAction||this._showDeleteSelectionAction||this._showExportSelectionToCSVAction||this._showRefreshDataAction||this._showZoomToSelectionAction||this._showSelectedRecordsShowSelectedAction||this._showSelectedRecordsShowAllAction||this._showColumnVisibilityAction)}get _shouldShowGrid(){return this.allRelatedTablesVisible||this.relatedTables.length===1&&!this._attachmentsViewIsVisible}get _shouldShowMenu(){let{header:e,menu:t}=this._effectiveVisibleElements;return!!(e&&t&&(this._hasDefaultMenuItems||this._hasCustomMenuItems))}get _showClearSelectionAction(){return!!(this.effectiveTable.highlightIds.length&&this._effectiveVisibleElements.menuItems?.clearSelection&&!this._attachmentsViewIsVisible)}get _showColumnVisibilityAction(){let{columnVisibilityMenu:e,header:t,menu:n,menuItems:r}=this._effectiveVisibleElements;return!(!t||!n||!e||r?.toggleColumns===!1||this.showRelatedTableCallback||this.allRelatedTablesVisible||this._attachmentsViewIsVisible)}get _showDeleteSelectionAction(){return!!(this.editingEnabled&&this.highlightIds.length&&this._effectiveVisibleElements.menuItems?.deleteSelection&&this.layer?.capabilities?.operations?.supportsDelete&&!this.relatedTables.length&&!this._attachmentsViewIsVisible)}get _showExportSelectionToCSVAction(){return!!(this._effectiveVisibleElements.menuItems.exportSelectionToCSV&&this.layer&&this.highlightIds.length&&!this.relatedTables.length)}get _showLayerDropdown(){return!!(this._effectiveLayers.length&&this._effectiveVisibleElements.layerDropdown)}get _shouldShowNavigationBar(){let e=!!this.relatedTable||this._attachmentsViewIsVisible;return!this.tableParent&&e}get _showRefreshDataAction(){return!!this._effectiveVisibleElements.menuItems?.refreshData}get _showSelectedRecordsShowSelectedAction(){let e=this.objectIds.length,t=this.highlightIds.length;return!(!t||!this._effectiveVisibleElements.menuItems?.selectedRecordsShowSelectedToggle||e&&t===e||this.relatedTables.length||this._attachmentsViewIsVisible)}get _showSelectedRecordsShowAllAction(){return!!(this._effectiveVisibleElements.menuItems?.selectedRecordsShowAllToggle&&this.objectIds.length&&!this.relatedTables.length)}get _showZoomToSelectionAction(){let e=this.effectiveTable;return!!(e.view&&e.highlightIds.length&&!e.layer?.isTable&&this._effectiveVisibleElements.menuItems?.zoomToSelection)}get _viewLayers(){let e=this.view?.map;if(!e)return[];let t=new Set,n=e=>{P(e)&&!v(e)&&!t.has(e)&&(e.type!==`sublayer`||e.capabilities?.operations?.supportsQuery)&&(e.load().catch(()=>{}),t.add(e))},r=e=>{h(e)||e.type===`catalog-footprint`||(g(e)?(e.load().catch(()=>{}),e.layers?.forEach(n),e.tables?.forEach(n)):_(e)?(e.loadAll().catch(()=>{}),e.allSublayers?.forEach(n),e.subtables?.forEach(n)):v(e)?(e.loadAll().catch(()=>{}),e.sublayers?.forEach(n)):n(e))};return e.allLayers.forEach(r),e.allTables.forEach(r),[...t.values()]}get direction(){return this.viewModel.direction}set direction(e){this.viewModel.direction=e}get grid(){return this.viewModel.grid}get actionColumn(){return this.viewModel.actionColumn}get actionColumnConfig(){return this.viewModel.actionColumnConfig}set actionColumnConfig(e){this.viewModel.actionColumnConfig=e}get activeFilters(){return this.viewModel.activeFilters}get activeSortOrders(){return this.viewModel.activeSortOrders}get allColumns(){return this.viewModel.allColumns}get allColumnsVisible(){return this.viewModel.allColumnsVisible}get allRelatedTablesVisible(){return this.viewModel.allRelatedTablesVisible}get allVisibleColumns(){return this.viewModel.allVisibleColumns}get attachmentsColumns(){return this.viewModel.attachmentsColumns}get attachmentsEnabled(){return this.viewModel.attachmentsEnabled}set attachmentsEnabled(e){this.viewModel.attachmentsEnabled=e}get attachmentsViewOptions(){return this.viewModel.attachmentsViewOptions}set attachmentsViewOptions(e){this.viewModel.attachmentsViewOptions=e}get attributeTableTemplate(){return this.viewModel.attributeTableTemplate}set attributeTableTemplate(e){this.viewModel.attributeTableTemplate=e}get autoRefreshEnabled(){return this.viewModel.autoRefreshEnabled}set autoRefreshEnabled(e){this.viewModel.autoRefreshEnabled=e}get autoSaveEnabled(){return this.viewModel.autoSaveEnabled}set autoSaveEnabled(e){this.viewModel.autoSaveEnabled=e}get canAddRelatedFeature(){return this.viewModel.canAddRelatedFeature}get clearPrompt(){return this.viewModel.clearPrompt}set clearPrompt(e){this.viewModel.clearPrompt=e}get columnPerformanceModeEnabled(){return this.viewModel.columnPerformanceModeEnabled}set columnPerformanceModeEnabled(e){this.viewModel.columnPerformanceModeEnabled=e}get columnReorderingEnabled(){return this.viewModel.columnReorderingEnabled}set columnReorderingEnabled(e){this.viewModel.columnReorderingEnabled=e}get columns(){return this.viewModel.columns}get defaultSelectionManager(){return this.viewModel.defaultSelectionManager}get definitionExpression(){return this.viewModel.definitionExpression}set definitionExpression(e){this.viewModel.definitionExpression=e}get container(){return super.container}set container(e){super.container=e}get editingEnabled(){return this.viewModel.editingEnabled}set editingEnabled(e){this.viewModel.editingEnabled=e}get effectiveSelectionManager(){return this.viewModel.effectiveSelectionManager}get effectiveSize(){return this.viewModel.effectiveSize}get effectiveTable(){return this.relatedTable||this}get effectiveTimeExtent(){return this.viewModel.effectiveTimeExtent}get fieldColumns(){return this.viewModel.fieldColumns}get filterGeometry(){return this.viewModel.filterGeometry}set filterGeometry(e){this.viewModel.filterGeometry=e}get filterBySelectionEnabled(){return this.viewModel.filterBySelectionEnabled}set filterBySelectionEnabled(e){this.viewModel.filterBySelectionEnabled=e}get filterByViewExtent(){return this.viewModel.filterByViewExtent}set filterByViewExtent(e){this.viewModel.filterByViewExtent=e}get filterByLayerScaleRange(){return this.viewModel.filterByLayerScaleRange}set filterByLayerScaleRange(e){this.viewModel.filterByLayerScaleRange=e}get groupColumns(){return this.viewModel.groupColumns}get hasContingentValues(){return this.viewModel.hasContingentValues}get hasInvalidPendingEdits(){return this.viewModel.hasInvalidPendingEdits}get hasPendingEdits(){return this.viewModel.hasPendingEdits}get hiddenFields(){return this.viewModel.hiddenFields}set hiddenFields(e){this.viewModel.hiddenFields=e}get highlightEnabled(){return this.viewModel.highlightEnabled}set highlightEnabled(e){this.viewModel.highlightEnabled=e}get highlightIds(){return this.viewModel.highlightIds}set highlightIds(e){this.viewModel.highlightIds=e}get icon(){return Q.table}set icon(e){this._overrideIfSome(`icon`,e)}get initialSize(){return this.viewModel.initialSize}set initialSize(e){this.viewModel.initialSize=e}get isQueryingOrSyncing(){return this.viewModel.isQueryingOrSyncing}get isSyncing(){return this.viewModel.isSyncing}get isSyncingAttachments(){return this.viewModel.isSyncingAttachments}get label(){return this.messages?.widgetLabel??``}set label(e){this._overrideIfSome(`label`,e)}get layer(){return this.viewModel.layer}set layer(e){this.viewModel.layer=e}get layers(){return this.viewModel.layers}set layers(e){this.viewModel.layers=e}get layerView(){return this.viewModel.layerView}get maxSize(){return this.viewModel.maxSize}set maxSize(e){this.viewModel.maxSize=e}get messages(){return this.viewModel.messages}set messages(e){this.viewModel.messages=e}get messagesCommon(){return this.viewModel.messagesCommon}set messagesCommon(e){this.viewModel.messagesCommon=e}get messagesUnits(){return this.viewModel.messagesUnits}set messagesUnits(e){this.viewModel.messagesUnits=e}get messagesURIUtils(){return this.viewModel.messagesURIUtils}set messagesURIUtils(e){this.viewModel.messagesURIUtils=e}get menuConfig(){return this.viewModel.menuConfig}set menuConfig(e){this.viewModel.menuConfig=e}get multipleSelectionEnabled(){return this.viewModel.multipleSelectionEnabled}set multipleSelectionEnabled(e){this.viewModel.multipleSelectionEnabled=e}get multipleSelectionEnabledOverride(){return this.viewModel.multipleSelectionEnabledOverride}set multipleSelectionEnabledOverride(e){this.viewModel.multipleSelectionEnabledOverride=e}get multiSortEnabled(){return this.viewModel.multiSortEnabled}set multiSortEnabled(e){this.viewModel.multiSortEnabled=e}get multipleSortPriority(){return this.viewModel.multipleSortPriority}set multipleSortPriority(e){this.viewModel.multipleSortPriority=e}get noDataMessage(){return this.viewModel.noDataMessage}set noDataMessage(e){this.viewModel.noDataMessage=e}get objectIds(){return this.viewModel.objectIds}set objectIds(e){this.viewModel.objectIds=e}get outFields(){return this.viewModel.outFields}set outFields(e){this.viewModel.outFields=e}get pageCount(){return this.viewModel.pageCount}get pageIndex(){return this.viewModel.pageIndex}set pageIndex(e){this.viewModel.pageIndex=e}get pageSize(){return this.viewModel.pageSize}set pageSize(e){this.viewModel.pageSize=e}get paginationEnabled(){return this.viewModel.paginationEnabled}set paginationEnabled(e){this.viewModel.paginationEnabled=e}get pendingEditsCount(){return this.viewModel.pendingEditsCount}get prompt(){return this.viewModel.prompt}set prompt(e){this.viewModel.prompt=e}get relatedRecordsEnabled(){return this.viewModel.relatedRecordsEnabled}set relatedRecordsEnabled(e){this.viewModel.relatedRecordsEnabled=e}get relatedTable(){return this.viewModel.relatedTable}get relatedTableHasContingentValues(){return this.viewModel.relatedTableHasContingentValues}get relatedTableHasInvalidPendingEdits(){return this.viewModel.relatedTableHasInvalidPendingEdits}get relatedTableHasPendingEdits(){return this.viewModel.relatedTableHasPendingEdits}get relatedTables(){return this.viewModel.relatedTables}get relationship(){return this.viewModel.relationship}get relationshipColumnConfigs(){return this.viewModel.relationshipColumnConfigs}set relationshipColumnConfigs(e){this.viewModel.relationshipColumnConfigs=e}get relationshipColumns(){return this.viewModel.relationshipColumns}get relationshipConfig(){return this.viewModel.relationshipConfig}set relationshipConfig(e){this.viewModel.relationshipConfig=e}get relationshipInfos(){return this.viewModel.relationshipInfos}get returnGeometryEnabled(){return this.viewModel.returnGeometryEnabled}set returnGeometryEnabled(e){this.viewModel.returnGeometryEnabled=e}get returnMEnabled(){return this.viewModel.returnMEnabled}set returnMEnabled(e){this.viewModel.returnMEnabled=e}get returnZEnabled(){return this.viewModel.returnZEnabled}set returnZEnabled(e){this.viewModel.returnZEnabled=e}get rowHighlightIds(){return this.viewModel.rowHighlightIds}set rowHighlightIds(e){this.viewModel.rowHighlightIds=e}get selectionManager(){return this.viewModel.selectionManager}set selectionManager(e){this.viewModel.selectionManager=e}get selectionSource(){return this.viewModel.selectionSource}set selectionSource(e){this.viewModel.selectionSource=e}get showAllRelatedTables(){return this.viewModel.showAllRelatedTables}set showAllRelatedTables(e){this.viewModel.showAllRelatedTables=e}get showPrompt(){return this.viewModel.showPrompt}set showPrompt(e){this.viewModel.showPrompt=e}get showRelatedTableCallback(){return this.viewModel.showRelatedTableCallback}set showRelatedTableCallback(e){this.viewModel.showRelatedTableCallback=e}get size(){return this.viewModel.size}get state(){return this.viewModel.state}get supportsAddAttachments(){return this.viewModel.supportsAddAttachments}get supportsAttachments(){return this.viewModel.supportsAttachments}get supportsDeleteAttachments(){return this.viewModel.supportsDeleteAttachments}get supportsResizeAttachments(){return this.viewModel.supportsResizeAttachments}get supportsUpdateAttachments(){return this.viewModel.supportsUpdateAttachments}get syncTemplateOnChangesEnabled(){return this.viewModel.syncTemplateOnChangesEnabled}set syncTemplateOnChangesEnabled(e){this.viewModel.syncTemplateOnChangesEnabled=e}get syncViewSelection(){return this.viewModel.syncViewSelection}set syncViewSelection(e){this.viewModel.syncViewSelection=e}get syncWithViewSelectionManager(){return this.syncViewSelection}set syncWithViewSelectionManager(e){this.syncViewSelection=e}get tableController(){return this.viewModel.tableController}set tableController(e){this.viewModel.tableController=e}get tableParent(){return this.viewModel.tableParent}set tableParent(e){this.viewModel.tableParent=e}get tableTemplate(){return this.viewModel.tableTemplate}set tableTemplate(e){this.viewModel.tableTemplate=e}get tableTemplateOverride(){return this.viewModel.tableTemplateOverride}set tableTemplateOverride(e){this.viewModel.tableTemplateOverride=e}get timeExtent(){return this.viewModel.timeExtent}set timeExtent(e){this.viewModel.timeExtent=e}get timeZone(){return this.viewModel.timeZone}set timeZone(e){this.viewModel.timeZone=e}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}get viewTimeEnabled(){return this.viewModel.viewTimeEnabled}set viewTimeEnabled(e){this.viewModel.viewTimeEnabled=e}get visibleColumns(){return this.viewModel.visibleColumns}get visibleElementsOverride(){let{attachmentsViewOptions:e,relatedTable:t,tableController:n,visibleElements:r}=this,{columnDescriptions:i,columnMenus:a,tooltips:o}=r,s=e.objectId!=null;if(t)return new k({columnDescriptions:i,tooltips:o,close:r.close,header:r.header,layerDropdown:r.layerDropdown,layerDropdownIcons:r.layerDropdownIcons,menu:r.menu,menuItems:r.menuItems,progress:r.progress,columnMenus:!0,selectionColumn:!1,columnMenuItems:new D({sortAscending:!1,sortDescending:!1})});if(n){let e=n.relatedTable===this,t=n.allRelatedTablesVisible,c=e&&r.selectionColumn&&!t&&!s,l=e&&!t&&!s;return new k({columnDescriptions:i,tooltips:o,selectionColumn:c,close:!1,header:!1,layerDropdown:!1,menu:!1,pendingEditsFooter:!1,progress:!1,columnMenus:a||!e,columnMenuItems:new D({sortAscending:l,sortDescending:l})})}return s?new k({columnDescriptions:i,columnMenus:a,tooltips:o,close:r.close,header:r.header,layerDropdown:r.layerDropdown,layerDropdownIcons:r.layerDropdownIcons,menu:r.menu,menuItems:r.menuItems,progress:r.progress,selectionColumn:!1,columnMenuItems:new D({sortAscending:!1,sortDescending:!1})}):null}addPendingEdits(e){this.viewModel.addPendingEdits(e)}clearSelection(){this.effectiveTable.viewModel.clearSelection()}async deleteAttachments(e,t,n){if(e!=null&&t?.length){if(n){this._showDeleteAttachmentPrompt(e,t);return}await this.viewModel.deleteAttachments(e,t)}}async deleteSelection(e){if(this.highlightIds.length){if(e){this._showDeleteSelectionPrompt();return}await this.viewModel.deleteSelection()}}async discardPendingEdits(e,t){return t?this._showDiscardEditsPrompt(e):this.viewModel.discardPendingEdits(e)}async downloadAttachmentById(e,t){return this.viewModel.downloadAttachmentById(e,t)}drainRelatedTables(){this.viewModel.drainRelatedTables()}async exportSelectionToCSV(e){return this.viewModel.exportSelectionToCSV(e)}findColumn(e){return this.viewModel.findColumn(e)}getFeatureStoreItemByObjectId(e){return this.viewModel.getFeatureStoreItemByObjectId(e)}goToPage(e){this.viewModel.goToPage(e)}hideAllColumns(){this.viewModel.hideAllColumns()}hideColumn(e){this.grid?.hideColumn(e)}nextPage(){this.viewModel.nextPage()}previousPage(){this.viewModel.previousPage()}async refresh(){await this.viewModel.refresh()}refreshCellContent(){this.viewModel.refreshCellContent()}async saveAttachmentsViewForm(){await this.viewModel.saveAttachmentsViewForm()}async savePendingEdits(){await this.viewModel.savePendingEdits()}showAllColumns(){this.viewModel.showAllColumns()}showColumn(e){this.grid?.showColumn(e)}sortColumn(e,t){this.viewModel.sortColumn(e,t)}scrollLeft(){this.viewModel.scrollLeft()}scrollToBottom(){this.viewModel.scrollToBottom()}scrollToIndex(e){this.viewModel.scrollToIndex(e)}scrollToRow(e){this.viewModel.scrollToRow(e)}scrollToTop(){this.viewModel.scrollToTop()}toggleColumnVisibility(e){this.viewModel.toggleColumnVisibility(e)}get visibilityMenuColumns(){let e=this.effectiveTable.columns;return this.columnVisibilityMenuConfig?.frozenColumnsExcluded?e.filter(e=>!e.frozen&&!e.frozenToEnd).toArray():e.toArray()}async zoomToSelection(){return this.effectiveTable.viewModel.zoomToSelection()}render(){let{_effectiveVisibleElements:e,isQueryingOrSyncing:t,menuConfig:n,state:r}=this;return H(`div`,{bind:this,class:this.classes(Z.base,R.widget)},H(`calcite-panel`,{bind:this,class:Z.content,closable:e.close,closed:this.closed,collapsed:this.collapsed,collapsible:e.collapse,description:this._effectiveDescription,dir:this.direction,disabled:this.disabled||r===`disabled`&&!this._effectiveLayers?.length,heading:e.header?this._effectiveTitle:void 0,key:`table-content`,loading:r===`loading`,menuOpen:!!n?.open,overlayPositioning:`fixed`,onCalcitePanelClose:()=>{this.closed=!0,this.emit(`close`)},onCalcitePanelToggle:e=>{this.collapsed=e.target.collapsed,this.emit(`toggle`)}},e.progress?H(`calcite-progress`,{type:t?`indeterminate`:`determinate`}):null,this._showLayerDropdown?this._renderLayerDropdown():null,this._renderColumnVisibilityAction(),this._renderHeaderMenuActions(),this._renderNavigationBar(),this._renderTables(),this._renderError(),this._renderFooterContent()),this._renderColumnVisibilityPopover(),this._renderPrompt(),this._renderDialog())}_renderTables(){let{grid:e,relatedTables:t}=this,n=this.classes(Z.tableContainer);if(t.length){let r=this.classes(Z.base,this.allRelatedTablesVisible?Z.expanded:Z.collapsed,this._attachmentsViewIsVisible?Z.tableContainerWithAttachments:void 0);return H(`div`,{class:n},H(`calcite-panel`,{overlayPositioning:`fixed`},H(`div`,null,[this._shouldShowGrid?H(`div`,{class:r},e?.render(),this._renderPagination()):void 0,...this._filteredTables.map(e=>{let n=t.indexOf(e);return H(`div`,{class:r,key:`related-${n}`},e.render())}),,])))}return this.attachmentsViewOptions.objectId==null?[H(`div`,{class:n},e?.render()),this._renderPagination()]:H(`div`,{class:n},H(`calcite-panel`,{overlayPositioning:`fixed`},H(`div`,null,[H(`div`,{class:this.classes(Z.base,Z.collapsed)},e?.render(),this._renderPagination()),this._renderAttachmentsView()])))}_renderPagination(){if(this.paginationEnabled)return H(`calcite-pagination`,{pageSize:1,startItem:this.pageIndex+1,totalItems:this.pageCount,onCalcitePaginationChange:e=>{this._attachmentsDialogPreviewLoading=!1,this.goToPage(e.currentTarget.startItem-1)}})}_renderError(){let{messages:e}=this;return H(`calcite-alert`,{autoClose:!0,autoCloseDuration:`fast`,icon:Q.exclamationMarkTriangle,kind:`danger`,label:e.errorOccured,open:this._hasAttachmentsViewError,slot:`alerts`,topLayerDisabled:this.topLayerDisabled,onCalciteAlertClose:()=>{this.attachmentsViewOptions.error=null}},H(`span`,{slot:`message`},e.errorOccured))}_renderFooterContent(){if(!this.hasPendingEdits||!this._effectiveVisibleElements.pendingEditsFooter)return;let{hasInvalidPendingEdits:e,isQueryingOrSyncing:t,messages:n,messagesCommon:r}=this,i=e||t,a=this.hasContingentValues,o=[H(`calcite-button`,{appearance:`outline`,disabled:t,iconStart:Q.reset,key:`footer-reset-button`,slot:`footer-end`,width:`auto`,onclick:()=>void this.discardPendingEdits()},r.reset),H(`calcite-button`,{disabled:i,iconStart:Q.save,key:`footer-save-button`,loading:this.isSyncing,slot:`footer-end`,width:`auto`,onclick:()=>{this.savePendingEdits()}},r.save)];if(a){let t=e?n.contingentValues.hasInvalidValues:n.contingentValues.hasValidValues,r=e?Q.exclamationMarkTriangle:Q.checkCircle,i=e?Z.footerIconDanger:Z.footerIconSuccess;o.push(H(`div`,{class:Z.footerMessage,key:`footer-message`,slot:`footer-start`},H(`calcite-icon`,{class:i,icon:r,scale:`s`,slot:`footer-start`}),t))}return o}_renderPrompt(){return this.prompt?H(E,{...this.prompt,headingLevel:2}):void 0}_showDeleteSelectionPrompt(){let{messages:e,messagesCommon:n}=this,r=t(e.deleteSelectionCount,{count:this.highlightIds.length});this.showPrompt({title:r,message:e.deleteRecordsRemoved,context:`danger`,actions:{primary:{label:n.delete,action:async()=>{try{await this.viewModel.deleteSelection()}finally{this.clearPrompt()}}},secondary:{label:e.keepRecords,action:()=>this.clearPrompt()}}})}_showDeleteAttachmentPrompt(e,n){let{messages:r,messagesCommon:i}=this,a=t(r.deleteAttachmentCount,{count:n.length});this.showPrompt({title:a,message:r.deleteAttachmentConfirmation,context:`danger`,actions:{primary:{label:i.delete,action:async()=>{try{await this.deleteAttachments(e,n,!1)}finally{this.clearPrompt()}}},secondary:{label:i.cancel,action:()=>this.clearPrompt()}}})}async _showDiscardEditsPrompt(e){let t=Promise.withResolvers(),{messagesEditor:n}=this;return this.showPrompt({title:n.cancelEditTitle,message:n.cancelEditWarningMessage,context:`danger`,actions:{primary:{label:n.discardEdits,action:async()=>{try{await this.discardPendingEdits(e)}finally{t.resolve(!0)}}},secondary:{label:n.continueEditing,action:()=>t.resolve(!1)}}}),t.promise.finally(()=>this.clearPrompt())}_onTableViewChange(e){this.hasPendingEdits?this._showDiscardEditsPrompt().then(t=>t&&e()):e()}_resetNestedViews(){this.relatedTable&&this.drainRelatedTables(),this.effectiveTable.attachmentsViewOptions.objectId=null}_renderDialog(){let{attachmentsViewOptions:e,messages:t}=this,{objectId:n}=e;return H(`calcite-dialog`,{class:Z.dialog,description:this.viewModel.getFeatureTitleSync(n),heading:t.attachments,modal:!0,open:this._dialogIsOpen,placement:`cover`,width:`l`,onCalciteDialogClose:()=>this._onDialogClose()},this._renderDialogContent())}_renderDialogContent(){let e=this.attachmentsViewOptions.dialogInfo;if(e)return this._renderAttachmentsDialogContent(e)}_renderAttachmentsDialogContent(e){let{attachmentsViewOptions:t,messages:n}=this,{attachmentInfos:r}=t,i=r.indexOf(e);return H(U,null,H(`div`,{class:Z.dialogHeader,key:`header`,slot:`content-top`},H(`span`,null,e.name),H(`calcite-button`,{appearance:`outline`,onclick:()=>{t.attachmentId=e.id,t.dialogId=null}},n.viewDetails)),H(`calcite-progress`,{type:this._attachmentsDialogPreviewLoading?`indeterminate`:`determinate`}),H(`div`,{class:Z.dialogContent,key:`content`},this._renderAttachmentsViewDetailsImage(e)),H(`calcite-pagination`,{pageSize:1,slot:`footer`,startItem:i+1,totalItems:r.length,onCalcitePaginationChange:e=>{let n=e.currentTarget.startItem-1,i=r[n]?.id;t.dialogId=i}}))}_onDialogClose(){let e=this.attachmentsViewOptions;e.dialogId!=null&&(e.dialogId=null),this._attachmentsDialogPreviewLoading=!1}_renderHeaderMenuAction(e){let{disabled:t,hidden:n,icon:r,text:i,clickFunction:a}=e;if(!n)return H(`calcite-action`,{disabled:t??this.menuConfig?.disabled,icon:r??void 0,key:i,slot:`header-menu-actions`,text:i,textEnabled:!0,title:i,onclick:()=>a()})}_renderHeaderMenuActions(){return this._shouldShowMenu?[this._renderDefaultHeaderMenuActions(),this._renderCustomHeaderMenuActions()]:[]}_renderDefaultHeaderMenuActions(){if(!this._hasDefaultMenuItems)return[];let{messages:e}=this;return[this._showRefreshDataAction&&{icon:Q.refresh,text:e.refreshData,clickFunction:()=>this.refresh()},this._showDeleteSelectionAction&&{icon:Q.delete,text:e.deleteSelection,clickFunction:()=>this.deleteSelection(!0)},this._showClearSelectionAction&&{icon:Q.clearSelection,text:e.clearSelection,clickFunction:()=>this.clearSelection()},this._showZoomToSelectionAction&&{icon:Q.zoomToSelection,text:e.zoomToSelection,clickFunction:()=>this.zoomToSelection()},this._showSelectedRecordsShowSelectedAction&&{icon:Q.showSelected,text:e.showSelected,clickFunction:()=>{let{objectIds:e}=this;e.removeAll(),e.addMany(this.highlightIds.toArray())}},this._showSelectedRecordsShowAllAction&&{icon:Q.showAll,text:e.showAllRecords,clickFunction:()=>this.objectIds.removeAll()},this._showExportSelectionToCSVAction&&{icon:Q.exportToCSV,text:e.exportSelectionCSV,clickFunction:()=>this.exportSelectionToCSV()}].filter(n).map(e=>e&&this._renderHeaderMenuAction(e))}_renderCustomHeaderMenuActions(){return this.menuConfig?.items?.map(({disabled:e,hidden:t,icon:n,label:r,clickFunction:i})=>this._renderHeaderMenuAction({hidden:typeof t==`function`?t():t,icon:n,text:r,disabled:typeof e==`function`?e():e,clickFunction:e=>i(e)}))??[]}_renderColumnVisibilityAction(){if(!this._showColumnVisibilityAction)return[];let{_columnVisibilityActions:e,id:t}=this,n=this.messages.menuText.columnVisibility;return H(`calcite-action`,{afterCreate:n=>e.set(t,n),afterRemoved:()=>e.delete(t),bind:this,disabled:this._columnVisibilityActionDisabled,icon:Q.showColumn,id:`${t}__toggle-columns-action`,slot:`header-actions-end`,text:n},this._effectiveVisibleElements.tooltips?H(`calcite-tooltip`,{closeOnClick:!0,overlayPositioning:`fixed`,placement:`bottom-end`,referenceElement:e.get(t),topLayerDisabled:this.topLayerDisabled},n):null)}_renderColumnVisibilityPopover(){if(!this._showColumnVisibilityAction||this._columnVisibilityActionDisabled)return;let e=this.visibleElements.columnVisibilityMenuItems.header,t=this.messages.menuText.columnVisibility;return H(`calcite-popover`,{autoClose:!0,class:Z.menuPopover,closable:e,heading:e?t:void 0,label:t,overlayPositioning:`fixed`,placement:this.columnVisibilityMenuConfig?.placement,referenceElement:this._columnVisibilityActions.get(this.id),topLayerDisabled:this.topLayerDisabled},this._renderColumnVisibilityList())}_renderColumnVisibilityList(){let{visibilityMenuColumns:e,messages:{menuText:t}}=this;if(e.length!==0)return H(`calcite-list`,{afterCreate:W,afterRemoved:G.bind(this),afterUpdate:W,bind:this,"data-node-ref":`_columnVisibilityList`,dir:this.direction,displayMode:`nested`,filterEnabled:this.visibleElements.columnVisibilityMenuItems.filter,filterPlaceholder:t.searchFields,label:t.fieldVisibility,selectionMode:`multiple`,onCalciteListChange:()=>this._syncColumnVisibility(),onCalciteListFilter:()=>this.scheduleRender()},this._renderColumnToggleAll(),e.map(e=>{let t=A(e)?e.columns?.map(e=>this._renderColumnListItem({column:e})):void 0;return this._renderColumnListItem({column:e,items:t})}),H(`calcite-notice`,{appearance:`transparent`,kind:`neutral`,open:!0,slot:`filter-no-results`},H(`div`,{slot:`message`},t.noMatchesFound)))}_syncColumnVisibility(){let{effectiveTable:e,_columnVisibilityList:t}=this;if(!t)return;let n=new Set(t.selectedItems.map(e=>e.value)),r=!!this.columnVisibilityMenuConfig?.frozenColumnsExcluded;e.allColumns.forEach(t=>{r&&(t.frozen||t.frozenToEnd)||(n.has(t.fieldName)?e.showColumn(t.fieldName):e.hideColumn(t.fieldName))})}_renderColumnToggleAll(){if(!this.visibleElements.columnVisibilityMenuItems.toggleAll)return;let{_columnVisibilityList:e}=this;if(e&&e.filteredItems?.length)return H(`calcite-button`,{appearance:`transparent`,width:`full`,onclick:()=>this._toggleAllColumns()},this._getColumnToggleAllText())}_getColumnToggleAllText(){let{_columnVisibilityList:e,effectiveTable:t,messages:{menuText:n}}=this;return e?e.filterText===``?t.allColumnsVisible?n.deselectAll:n.selectAll:this._allColumnsAreVisible(e.filteredItems.map(e=>e.value))?n.deselectAll:n.selectAll:``}_renderColumnListItem(e){let{column:t,items:n}=e,{effectiveLabel:r,fieldName:i,hidden:a}=t,o=!(!n?.length||a)||void 0;return H(`calcite-list-item`,{expanded:o,key:`toggle-columns__item-${i}`,label:r,metadata:{description:t.effectiveDescription,type:j(t)?t.field.type:void 0},selected:!a,value:i},n)}_renderLayerDropdown(){let e=this.messages.selectALayer;return H(`div`,{class:Z.layerDropdownMenu,key:`${this.id}-layerDropdown`,slot:`header-actions-start`},H(`calcite-dropdown`,{bind:this,maxItems:5,overlayPositioning:`fixed`,placement:`bottom-start`,topLayerDisabled:this.topLayerDisabled},H(`calcite-action`,{icon:Q.layers,slot:`trigger`,text:e,title:e}),H(`calcite-dropdown-group`,{selectionMode:`single`},this._effectiveLayers.map((e,t)=>this._renderLayerDropdownItem(e,t))??null)))}_renderLayerDropdownItem(e,t){let n=this.visibleElements.layerDropdownIcons;return H(`calcite-dropdown-item`,{iconStart:n?z(e):void 0,key:`dropdown-item-${t}`,label:e.title??``,selected:e===this.layer,value:e.id,onCalciteDropdownItemSelect:()=>this._onTableViewChange(()=>this.layer=e)},e.title)}_onRelatedNavigationItemClick(e){this.viewModel.drainRelatedTablesAboveIndex(e)}_collapseRelatedTable(e){this.viewModel.collapseRelatedTable(this.effectiveTable,e)}_onShowRelatedTable(e){this.showRelatedTableCallback||this.hasPendingEdits||(this._collapseRelatedTable(e),this._createRelatedTable(e))}async _createRelatedTable(e){let{autoRefreshEnabled:t,autoSaveEnabled:n,direction:r,editingEnabled:i,effectiveTable:a,multipleSelectionEnabled:o,paginationEnabled:s,pageSize:c,view:l,viewModel:u,visibleElements:d}=this,{layer:f,objectId:p,relatedLayer:m,relationshipId:h}=e;await f.load();let g=this.attachmentsEnabled&&F(f),_=new K({layer:f,autoRefreshEnabled:t,autoSaveEnabled:n,attachmentsEnabled:g,direction:r,editingEnabled:i,multipleSelectionEnabled:o,paginationEnabled:s,pageSize:c,relatedRecordsEnabled:!0,relationshipConfig:{objectId:p,relatedLayer:m,relationshipId:h},relationshipColumnConfigs:I(f,h),tableController:this,tableParent:a,view:l,visibleElements:d,showRelatedTableCallback:e=>u.emit(`show-related-table`,e)});this.relatedTables.add(_),this.scheduleRender()}_renderAttachmentsView(){switch(this.attachmentsViewOptions.effectiveMode){case`list`:return this._renderAttachmentsViewList();case`details`:return this._renderAttachmentsViewDetails();case`file`:return this._renderAttachmentsViewFile()}}_renderAttachmentsViewFile(){let e=this.attachmentsViewOptions,{objectId:t}=e;if(t!=null)return[H(`div`,{class:Z.attachmentsView,key:`attachments-view`},this._renderAttachmentsViewInformation(),H(`div`,{class:Z.attachmentsViewContent,key:`attachments-view-content`},H(`div`,{bind:this,class:Z.attachmentsViewDropArea,ondragover:e=>e.preventDefault(),ondrop:this._onAttachmentsViewDrop},H(`calcite-icon`,{class:Z.attachmentsViewIcon,icon:Q.upload,scale:`l`}),this._renderAttachmentsViewFileLabelNode(),this._renderAttachmentsViewFileMessageNode(),H(`form`,{afterCreate:t=>e.form=t,afterRemoved:()=>e.form=null,bind:this,key:`attachments-form`},H(`fieldset`,null,this._renderAttachmentsViewFileNameNode(),H(`input`,{afterCreate:W,afterRemoved:G,afterUpdate:W,bind:this,"data-node-ref":`_attachmentsInput`,files:e.candidates,hidden:!0,name:`attachment`,type:`file`,onchange:e=>this._onAttachmentsViewCandidateChange(e)}),this._renderAttachmentsViewFileSelectNode(),this._renderAttachmentsViewFileSaveNode(),this._renderAttachmentsViewFileCancelNode())))))]}_renderAttachmentsViewFileLabelNode(){if(this.attachmentsViewOptions.fileMode===`replace`)return H(`span`,{class:Z.attachmentsViewDropAreaLabel,key:`replace-file-node`},this.messages.replaceFile)}_renderAttachmentsViewFileMessageNode(){let e=this.attachmentsViewOptions;if(e.hasCandidates)return;let{messages:t}=this,n=this.supportsAddAttachments?e.objectId==null?t.noFeature:t.dragAndDropToUpload:t.editingRestricted;return H(`span`,{class:Z.attachmentsViewDropAreaMessage,key:`message-node`},n)}_renderAttachmentsViewFileNameNode(){let e=this.attachmentsViewOptions.candidates,t=Array.from(e??[]).at(-1);if(t)return H(`span`,{class:Z.attachmentsViewDropAreaMessage,key:`filename-node`},t.name)}_renderAttachmentsViewFileSelectNode(){if(this.supportsAddAttachments)return H(`calcite-button`,{appearance:`outline-fill`,disabled:this.isSyncingAttachments,iconStart:Q.folderOpen,key:`select-node`,onclick:()=>{this._resetAttachmentsInput(),this._attachmentsInput?.click()}},this.messages.selectFile)}_renderAttachmentsViewFileSaveNode(){let{isSyncingAttachments:e,messages:t}=this,{attachmentInfo:n,hasCandidates:r}=this.attachmentsViewOptions;if(this.supportsAddAttachments&&r)return H(`calcite-button`,{appearance:`solid`,disabled:e,iconStart:Q.save,key:`save-node`,loading:e,onclick:()=>{this.saveAttachmentsViewForm()}},n?t.updateAttachment:t.addAttachment)}_renderAttachmentsViewFileCancelNode(){let{hasAttachments:e,hasCandidates:t}=this.attachmentsViewOptions;if(e||t)return H(`calcite-button`,{appearance:`transparent`,bind:this,disabled:this.isSyncingAttachments,key:`cancel-node`,onclick:()=>{this._resetAttachmentsInput(),this.attachmentsViewOptions.cancel()}},this.messagesCommon.cancel)}_renderAttachmentsViewDetails(){let{attachmentInfo:e}=this.attachmentsViewOptions;if(e)return[H(`div`,{class:Z.attachmentsView,key:`attachments-view`},this._renderAttachmentsViewInformation(),H(`div`,{class:Z.attachmentsViewContent,key:`attachments-view-content`},H(`div`,{class:Z.attachmentsViewDetails},this._renderAttachmentsViewDetailsPreview(e))))]}_renderAttachmentsViewDetailsPreview(e){let t=[this._renderAttachmentsViewDetailsImage(e)];if(S(e.contentType)){let n=this.messages.maximize;t.push(H(`calcite-action`,{icon:Q.expand,label:n,text:n,textEnabled:!0,title:n,onclick:t=>{t.preventDefault(),this.attachmentsViewOptions.dialogId=e.id}}))}return t}_renderAttachmentsViewDetailsImage(e){let{contentType:t,name:n,size:r,url:i}=e,{messages:a}=this;return S(t)?H(`img`,{afterCreate:()=>this._attachmentsDialogPreviewLoading=!0,alt:n,key:`thumbnail-image-${n}`,src:`${i}${i?.includes(`?`)?`&`:`?`}s=${r}`,title:n,onerror:()=>this._attachmentsDialogPreviewLoading=!1,onload:()=>this._attachmentsDialogPreviewLoading=!1}):[H(`calcite-icon`,{icon:C(t),key:`thumbnail-icon-${n}`,scale:`l`,textLabel:n,title:n}),a.noPreviewAvailable]}_renderAttachmentsViewInformation(){let{attachmentsViewOptions:e,messages:t,messagesUnits:n}=this,{attachmentInfo:r,objectId:i}=e;if(r&&i!=null)return H(`div`,{class:Z.attachmentsViewInformation,key:`information`},this._renderAttachmentViewInformationButtons(r,i),H(`span`,{class:Z.attachmentsViewInformationLabel,key:`file-label`},t.fileName),H(`span`,{class:Z.attachmentsViewInformationData,key:`file-value`},r.name),H(`span`,{class:Z.attachmentsViewInformationLabel,key:`type-label`},t.attachmentType),H(`span`,{class:Z.attachmentsViewInformationData,key:`type-value`},this._getLabelForAttachmentType(r)),this._renderAttachmentKeywordDetails(r),H(`span`,{class:Z.attachmentsViewInformationLabel,key:`size-label`},t.size),H(`span`,{class:Z.attachmentsViewInformationData,key:`size-span`},d(n,r.size??0)))}_renderAttachmentViewInformationButtons(e,t){let{attachmentsViewOptions:n,messages:r,messagesCommon:i}=this,a=n.effectiveMode!==`details`,o=e.id,s=[H(`calcite-button`,{appearance:`outline`,disabled:a,key:`download-button`,width:`full`,onclick:e=>{e.preventDefault(),this.downloadAttachmentById(t,o)}},r.download)];return this.supportsUpdateAttachments&&s.push(H(`calcite-button`,{appearance:`outline`,disabled:a,key:`replace-button`,width:`full`,onclick:()=>{n.mode=`file`,n.attachmentId=o}},r.replace)),this.supportsDeleteAttachments&&s.push(H(`calcite-button`,{appearance:`outline`,disabled:a,key:`delete-button`,width:`full`,onclick:()=>{this.deleteAttachments(t,[o],!0)}},i.delete)),s}_renderAttachmentKeywordDetails({keywords:e}){if(e&&e!==``)return[H(`span`,{class:Z.attachmentsViewInformationLabel,key:`keyword-label`},this.messages.keyword),H(`span`,{class:Z.attachmentsViewInformationData,key:`keyword-value`},e)]}_renderAttachmentsViewList(){let{attachmentsViewOptions:e,isSyncingAttachments:t,messages:n,messagesUnits:r}=this,{attachmentInfos:i,objectId:a}=e;return H(`calcite-list`,{afterCreate:W,afterRemoved:G,afterUpdate:W,bind:this,class:Z.attachmentsViewList,"data-node-ref":`attachmentsList`,key:`attachments-list-${a}`,label:n?.attachments,loading:t,selectionMode:this.supportsDeleteAttachments?`multiple`:`none`,onCalciteListChange:()=>this.scheduleRender(),ondragover:e=>e.preventDefault(),ondrop:this._onAttachmentsViewDrop},...i?.map(t=>{let{id:i,name:o,size:s}=t,c=d(r,s??0);return H(`calcite-list-item`,{afterRemoved:()=>this.scheduleRender(),key:`attachment-${i}`,label:o,value:i},this._renderAttachmentsViewListPreview(t),H(`span`,{class:Z.attachmentsViewListFileSize,slot:`actions-end`,title:c},c),H(`calcite-action`,{icon:Q.downloadTo,key:`download`,label:o,slot:`actions-end`,text:n.downloadAttachment,title:n.downloadAttachment,onclick:e=>{e.preventDefault(),this.downloadAttachmentById(a??-1,i)}}),H(`calcite-action`,{icon:Q.chevronRight,iconFlipRtl:!0,key:`details`,label:o,slot:`actions-end`,text:n.viewAttachment,title:n.viewAttachment,onclick:()=>{e.mode=`details`,e.attachmentId=i}}))}))}_renderAttachmentsViewListPreview(e){return H(`div`,{class:Z.attachmentsViewListThumbnail,slot:`content-start`},H(`span`,null,this._renderAttachmentsViewListImage(e)))}_renderAttachmentsViewListImage(e,t=64){let{contentType:n,name:r,size:i,url:a}=e,o=`${a}${a?.includes(`?`)?`&`:`?`}w=${t}&s=${i}`;return this.supportsResizeAttachments&&S(n)?H(`img`,{alt:r,key:`thumbnail-image-${r}`,src:o,title:r}):H(`calcite-icon`,{icon:C(n),key:`thumbnail-icon-${r}`,scale:`l`,textLabel:r,title:r})}_onAttachmentsViewCandidateChange({target:e}){this.attachmentsViewOptions.candidates=e?.files}_onAttachmentsViewDrop(e){e.preventDefault(),(this.supportsAddAttachments||this.supportsUpdateAttachments)&&(this.attachmentsViewOptions.mode=`file`,this.attachmentsViewOptions.candidates=e.dataTransfer?.files)}_resetAttachmentsInput(){this._attachmentsInput&&(this._attachmentsInput.value=``)}_getLabelForAttachmentType({contentType:e}){let t=this.messages,n=w(e);return t.attachmentTypes[n]}_renderNavigationBar(){let{effectiveTable:e,messages:n,messagesCommon:r,navigationScale:i,relatedTable:a,relatedTables:o}=this;if(!this._shouldShowNavigationBar)return;let{attachmentsList:s,attachmentsViewOptions:c,layer:l,supportsAddAttachments:u,supportsDeleteAttachments:d}=e;if(!l)return;let{attachmentInfos:f,objectId:p}=c,m=p!=null,h=f.length,g=s?.selectedItems?.length??0,_=`${l.objectIdField}: ${p}`,v=t(n.selectedCount,{count:g}),y=t(n.attachmentsCount,{count:h}),b=m?H(`calcite-action`,{bind:this,icon:Q.chevronRight,iconFlipRtl:!0,key:`navigation-feature`,scale:i,text:_,textEnabled:!0,title:_,onclick:()=>e.scrollToRow(p)}):void 0,x=m?H(`calcite-action`,{icon:Q.chevronRight,iconFlipRtl:!0,key:`navigation-attachments-label`,label:y,scale:i,text:y,textEnabled:!0,title:y,onclick:()=>{h>0&&(c.mode=`list`)}}):void 0,S=m?H(`calcite-chip`,{closable:!0,closed:g===0,key:`navigation-chip`,kind:`inverse`,label:v,scale:`s`,selected:!0,title:v,value:`selected`,onCalciteChipClose:()=>s?.selectedItems?.forEach(e=>e.selected=!1)},v):void 0,C=a?H(`calcite-label`,{layout:`inline`,scale:i},n.showAllTables,H(`calcite-switch`,{checked:this.allRelatedTablesVisible,scale:i,onCalciteSwitchChange:e=>this.showAllRelatedTables=!!e.currentTarget.checked})):void 0,w=m&&c.effectiveMode===`list`&&p!=null&&g&&d?H(`calcite-action`,{icon:Q.delete,iconFlipRtl:!0,key:`attachments-trash-all`,scale:i,text:r.delete,textEnabled:!0,title:t(n.deleteAttachmentCount,{count:g}),onclick:()=>{e.deleteAttachments(p,s?.selectedItems?.map(e=>e.value)??[],!0)}}):void 0,T=m&&c.effectiveMode===`list`&&u?H(`calcite-action`,{bind:this,icon:Q.plus,iconFlipRtl:!0,key:`attachments-add`,scale:i,text:n.addAttachment,textEnabled:!0,title:n.addAttachment,onclick:()=>{c.objectId=p,c.attachmentId=null,c.mode=`file`}}):void 0;return H(`div`,{class:Z.tableNavigation,key:`table-nav`},H(`calcite-action`,{icon:Q.moveUp,iconFlipRtl:!0,key:`go-back`,scale:i,text:this.layer?.title??``,textEnabled:!1,title:a?n.exitRelatedRecords:n.exitAttachments,onclick:()=>this._onTableViewChange(this._resetNestedViews)}),o.toArray().map((e,t)=>this._renderRelatedTableNavigationAction(e,t)),b,x,H(`div`,null,S,C,w,T))}_renderRelatedTableNavigationAction(e,t){let n=this._getLabelForRelatedTableNavigationAction(e);return H(`calcite-action`,{icon:Q.chevronRight,iconFlipRtl:!0,key:t,scale:this.navigationScale,text:n,textEnabled:!0,title:e.layer?.title||``,onclick:()=>{(t!==this.relatedTables.length-1||this._attachmentsViewIsVisible)&&this._onTableViewChange(()=>this._onRelatedNavigationItemClick(t))}})}_getLabelForRelatedTableNavigationAction(e){let t=e.layer?.title;if(!t)return``;let{relatedTables:n}=this;return n.length<=1?t:n.indexOf(e)!==n.length-1&&t.length>20?`${t.slice(0,20)}...`:t}_allColumnsAreVisible(e){let t=this.columnVisibilityMenuConfig;return e.every(e=>{let n=this.findColumn(e);return n?t?.frozenColumnsExcluded&&(n.frozen||n.frozenToEnd)?!0:n.effectiveVisible:!1})}_toggleAllColumns(){let{_columnVisibilityList:e,effectiveTable:t}=this,n=e?.filteredItems.map(e=>e.value);e?.filterText!==``&&n?.length?this._allColumnsAreVisible(n)?n.forEach(e=>this.hideColumn(e)):n.forEach(e=>this.showColumn(e)):t.allColumnsVisible?t.visibilityMenuColumns.forEach(e=>t.hideColumn(e.fieldName)):t.visibilityMenuColumns.forEach(e=>t.showColumn(e.fieldName))}};e([f()],$.prototype,`_attachmentsDialogPreviewLoading`,void 0),e([f()],$.prototype,`_attachmentsInput`,void 0),e([f()],$.prototype,`_attachmentsViewIsVisible`,null),e([f()],$.prototype,`_columnVisibilityActions`,void 0),e([f()],$.prototype,`_columnVisibilityActionDisabled`,null),e([f()],$.prototype,`_columnVisibilityList`,void 0),e([f()],$.prototype,`_dialogIsOpen`,null),e([f()],$.prototype,`_effectiveDescription`,null),e([f()],$.prototype,`_effectiveLayers`,null),e([f()],$.prototype,`_effectiveTitle`,null),e([f()],$.prototype,`_effectiveVisibleElements`,null),e([f()],$.prototype,`_filteredTables`,null),e([f()],$.prototype,`_hasAttachmentsViewError`,null),e([f()],$.prototype,`_hasCustomMenuItems`,null),e([f()],$.prototype,`_hasDefaultMenuItems`,null),e([f()],$.prototype,`_shouldShowGrid`,null),e([f()],$.prototype,`_shouldShowMenu`,null),e([f()],$.prototype,`_showClearSelectionAction`,null),e([f()],$.prototype,`_showColumnVisibilityAction`,null),e([f()],$.prototype,`_showDeleteSelectionAction`,null),e([f()],$.prototype,`_showExportSelectionToCSVAction`,null),e([f()],$.prototype,`_showLayerDropdown`,null),e([f()],$.prototype,`_shouldShowNavigationBar`,null),e([f()],$.prototype,`_showRefreshDataAction`,null),e([f()],$.prototype,`_showSelectedRecordsShowSelectedAction`,null),e([f()],$.prototype,`_showSelectedRecordsShowAllAction`,null),e([f()],$.prototype,`_showZoomToSelectionAction`,null),e([f()],$.prototype,`_viewLayers`,null),e([f()],$.prototype,`attachmentsList`,void 0),e([f()],$.prototype,`direction`,null),e([f({readOnly:!0})],$.prototype,`grid`,null),e([f()],$.prototype,`actionColumn`,null),e([f()],$.prototype,`actionColumnConfig`,null),e([f({readOnly:!0})],$.prototype,`activeFilters`,null),e([f({readOnly:!0})],$.prototype,`activeSortOrders`,null),e([f()],$.prototype,`allColumns`,null),e([f()],$.prototype,`allColumnsVisible`,null),e([f({readOnly:!0})],$.prototype,`allRelatedTablesVisible`,null),e([f()],$.prototype,`allVisibleColumns`,null),e([f()],$.prototype,`attachmentsColumns`,null),e([f()],$.prototype,`attachmentsEnabled`,null),e([f()],$.prototype,`attachmentsViewOptions`,null),e([f({type:y})],$.prototype,`attributeTableTemplate`,null),e([f()],$.prototype,`autoRefreshEnabled`,null),e([f()],$.prototype,`autoSaveEnabled`,null),e([f()],$.prototype,`canAddRelatedFeature`,null),e([f()],$.prototype,`clearPrompt`,null),e([f()],$.prototype,`closed`,void 0),e([f()],$.prototype,`collapsed`,void 0),e([f()],$.prototype,`columnPerformanceModeEnabled`,null),e([f()],$.prototype,`columnReorderingEnabled`,null),e([f({readOnly:!0})],$.prototype,`columns`,null),e([f()],$.prototype,`columnVisibilityMenuConfig`,void 0),e([f()],$.prototype,`defaultSelectionManager`,null),e([f()],$.prototype,`definitionExpression`,null),e([f()],$.prototype,`description`,void 0),e([f()],$.prototype,`disabled`,void 0),e([f()],$.prototype,`editingEnabled`,null),e([f()],$.prototype,`effectiveSelectionManager`,null),e([f()],$.prototype,`effectiveSize`,null),e([f()],$.prototype,`effectiveTable`,null),e([f()],$.prototype,`effectiveTimeExtent`,null),e([f()],$.prototype,`fieldColumns`,null),e([f({types:m})],$.prototype,`filterGeometry`,null),e([f()],$.prototype,`filterBySelectionEnabled`,null),e([f()],$.prototype,`filterByViewExtent`,null),e([f()],$.prototype,`filterByLayerScaleRange`,null),e([f()],$.prototype,`groupColumns`,null),e([f()],$.prototype,`hasContingentValues`,null),e([f()],$.prototype,`hasInvalidPendingEdits`,null),e([f()],$.prototype,`hasPendingEdits`,null),e([f()],$.prototype,`hiddenFields`,null),e([f()],$.prototype,`highlightEnabled`,null),e([f()],$.prototype,`highlightIds`,null),e([f()],$.prototype,`icon`,null),e([f()],$.prototype,`initialSize`,null),e([f()],$.prototype,`isQueryingOrSyncing`,null),e([f()],$.prototype,`isSyncing`,null),e([f()],$.prototype,`isSyncingAttachments`,null),e([f()],$.prototype,`label`,null),e([f()],$.prototype,`layer`,null),e([f()],$.prototype,`layers`,null),e([f()],$.prototype,`layerView`,null),e([f()],$.prototype,`maxSize`,null),e([f(),B(`esri/widgets/FeatureTable/t9n/FeatureTable`)],$.prototype,`messages`,null),e([f(),B(`esri/t9n/common`)],$.prototype,`messagesCommon`,null),e([f(),B(`esri/widgets/Editor/t9n/Editor`)],$.prototype,`messagesEditor`,void 0),e([f(),B(`esri/core/t9n/Units`)],$.prototype,`messagesUnits`,null),e([f(),B(`esri/widgets/support/t9n/uriUtils`)],$.prototype,`messagesURIUtils`,null),e([f()],$.prototype,`menuConfig`,null),e([f()],$.prototype,`multipleSelectionEnabled`,null),e([f()],$.prototype,`multipleSelectionEnabledOverride`,null),e([f()],$.prototype,`multiSortEnabled`,null),e([f()],$.prototype,`multipleSortPriority`,null),e([f()],$.prototype,`navigationScale`,void 0),e([f()],$.prototype,`noDataMessage`,null),e([f()],$.prototype,`objectIds`,null),e([f()],$.prototype,`outFields`,null),e([f()],$.prototype,`pageCount`,null),e([f()],$.prototype,`pageIndex`,null),e([f()],$.prototype,`pageSize`,null),e([f()],$.prototype,`paginationEnabled`,null),e([f()],$.prototype,`pendingEditsCount`,null),e([f()],$.prototype,`prompt`,null),e([f()],$.prototype,`relatedRecordsEnabled`,null),e([f()],$.prototype,`relatedTable`,null),e([f()],$.prototype,`relatedTableHasContingentValues`,null),e([f()],$.prototype,`relatedTableHasInvalidPendingEdits`,null),e([f()],$.prototype,`relatedTableHasPendingEdits`,null),e([f()],$.prototype,`relatedTables`,null),e([f()],$.prototype,`relationship`,null),e([f()],$.prototype,`relationshipColumnConfigs`,null),e([f()],$.prototype,`relationshipColumns`,null),e([f()],$.prototype,`relationshipConfig`,null),e([f()],$.prototype,`relationshipInfos`,null),e([f()],$.prototype,`returnGeometryEnabled`,null),e([f()],$.prototype,`returnMEnabled`,null),e([f()],$.prototype,`returnZEnabled`,null),e([f()],$.prototype,`rowHighlightIds`,null),e([f()],$.prototype,`selectionManager`,null),e([f()],$.prototype,`selectionSource`,null),e([f()],$.prototype,`showAllRelatedTables`,null),e([f()],$.prototype,`showPrompt`,null),e([f()],$.prototype,`showRelatedTableCallback`,null),e([f()],$.prototype,`size`,null),e([f({readOnly:!0})],$.prototype,`state`,null),e([f()],$.prototype,`supportsAddAttachments`,null),e([f()],$.prototype,`supportsAttachments`,null),e([f()],$.prototype,`supportsDeleteAttachments`,null),e([f()],$.prototype,`supportsResizeAttachments`,null),e([f()],$.prototype,`supportsUpdateAttachments`,null),e([f()],$.prototype,`syncTemplateOnChangesEnabled`,null),e([f()],$.prototype,`syncViewSelection`,null),e([f()],$.prototype,`syncWithViewSelectionManager`,null),e([f({constructOnly:!0})],$.prototype,`tableController`,null),e([f({constructOnly:!0})],$.prototype,`tableParent`,null),e([f({type:M})],$.prototype,`tableTemplate`,null),e([f()],$.prototype,`tableTemplateOverride`,null),e([f()],$.prototype,`title`,void 0),e([f({type:b})],$.prototype,`timeExtent`,null),e([f()],$.prototype,`timeZone`,null),e([f()],$.prototype,`view`,null),e([f({type:O}),V([`cell-click`,`cell-dblclick`,`cell-pointerover`,`cell-pointerout`,`cell-keydown`,`column-reorder`,`show-related-table`])],$.prototype,`viewModel`,void 0),e([f()],$.prototype,`viewTimeEnabled`,null),e([f()],$.prototype,`visibleColumns`,null),e([f({type:k,nonNullable:!0})],$.prototype,`visibleElements`,void 0),e([f({type:k})],$.prototype,`visibleElementsOverride`,null),e([f()],$.prototype,`visibilityMenuColumns`,null),$=K=e([p(`esri.widgets.FeatureTable`)],$);const ee=$;export{ee as default};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
|
|
2
|
-
import{__decorate as e}from"tslib";import t from"../../Graphic.js";import{isSome as n}from"../../core/arrayUtils.js";import{deprecatedModule as r}from"../../core/deprecate.js";import i from"../../core/Error.js";import{EventedAccessor as a}from"../../core/Evented.js";import o from"../../core/Logger.js";import{debounce as s,isAbortError as c}from"../../core/promiseUtils.js";import l from"../../core/ReactiveSet.js";import{watch as u,when as d,sync as f}from"../../core/reactiveUtils.js";import{property as p,subclass as m}from"../../core/accessorSupport/decorators.js";import h from"../../geometry/Point.js";import{initializeProjection as g,project as _}from"../../geometry/projectionUtils.js";import v from"../../geometry/SpatialReference.js";import{geographicToWebMercator as y}from"../../geometry/support/webMercatorUtils.js";import{fallbackObjectIDAttribute as b}from"../../layers/LayerConstants.js";import x from"../../symbols/SimpleFillSymbol.js";import{getDisplayedSymbol as S}from"../../symbols/support/symbolUtils.js";import{system as C}from"../../time/constants.js";import{highlightsSupported as w}from"../../views/support/layerViewUtils.js";import{createScreenPointFromEvent as T}from"../../views/support/screenUtils.js";import E from"../Feature/FeatureViewModel.js";import{ActionsCollection as D,zoomToFeature as O,zoomToClusteredFeatures as k,browseClusteredFeatures as A}from"../Popup/actions.js";import{triggerAction as j,isClusterFeature as M,getSelectedTarget as N,removeClusteredFeaturesForBrowsing as P,displayClusterExtent as F,browseAggregateFeatures as I}from"../Popup/actionUtils.js";import{AnchorElementViewModelMixin as L}from"../support/AnchorElementViewModel.js";import{GoTo as R}from"../support/GoTo.js";const z=`location-scale-handle`,B=()=>[O.clone()],V=()=>[k.clone(),A.clone()];let H=null;function U(e,t){return e===`building-scene`||e===`map-image`||e===`tile`||e===`imagery`||t===`2d`&&e===`imagery-tile`}let W=class extends R(L(a)){constructor(e){super(e),this._pendingPromises=new l,this._fetchFeaturesController=null,this._centerAtLocationController=null,this._locationUpdateController=null,this._highlightPromises={"highlight-active-feature":null,"highlight-selected-feature":null},this._selectedClusterFeature=null,this._featureStreamVersion=0,this._activeFeatureStream=null,this.actions=new D,this.activeFeature=null,this.autoCloseEnabled=!1,this.browseClusterEnabled=!1,this.content=null,this.defaultPopupTemplateEnabled=!1,this.featurePage=null,this.featuresPerPage=20,this.featureMenuOpen=!1,this.featureMenuTitle=null,this.featureViewModelAbilities=null,this.featureViewModels=[],this.highlightEnabled=!0,this.includeDefaultActions=!0,this.initialDisplayMode=`feature`,this.streamingFeatures=!1,this.selectedClusterBoundaryFeature=new t({symbol:new x({outline:{width:1.5,color:`cyan`},style:`none`})}),this.title=null,this.updateLocationEnabled=!1,this.view=null,this.visible=!1,this.zoomFactor=4,this.zoomToLocation=null,this._debouncedLocationUpdate=s(async e=>{this._cancelLocationUpdate();let t=new AbortController,{signal:n}=t;this._locationUpdateController=t,await this._locationUpdate(e,{signal:n}).catch(()=>{}).finally(()=>{this._locationUpdateController===t&&(this._locationUpdateController=null)})}),e?.suppressDeprecationWarning||r(o.getLogger(this),`esri.widgets.Features.FeaturesViewModel`,{version:`5.2`,replacement:`Use the Features (Next) component or the @arcgis/core/popup/FeaturesModel module instead.`,warnOnce:!0})}normalizeCtorArgs(e){let{suppressDeprecationWarning:t,...n}=e??{};return n}initialize(){this.addHandles([this.on(`view-change`,()=>this._autoClose()),u(()=>[this.highlightEnabled,this.selectedFeature,this.visible,this.view],()=>this._highlightSelectedFeature()),u(()=>[this.highlightEnabled,this.activeFeature,this.visible,this.view],()=>this._highlightActiveFeature()),u(()=>this.view?.animation?.state,e=>this._animationStateChange(e)),u(()=>this.location,e=>this._locationChange(e)),u(()=>this.selectedFeature,e=>this._selectedFeatureChange(e).catch(()=>{})),u(()=>[this.selectedFeatureIndex,this.featureCount,this.featuresPerPage],()=>this._selectedFeatureIndexChange()),u(()=>[this.featurePage,this.selectedFeatureIndex,this.featureCount,this.featuresPerPage,this.featureViewModels],()=>this._setGraphicOnFeatureViewModels()),u(()=>this.featureViewModels,()=>this._featureViewModelsChange()),this.on(`trigger-action`,e=>j({event:e,viewModel:this,view:this.view}).catch(()=>{})),d(()=>!this.waitingForResult,()=>this._waitingForResultChange(),f),u(()=>[this.features,this.map,this.spatialReference,this.timeZone],()=>this._updateFeatureVMs()),u(()=>this.view?.scale,()=>this._viewScaleChange()),d(()=>!this.visible,()=>this.browseClusterEnabled=!1),u(()=>this.browseClusterEnabled,e=>e?this.enableClusterBrowsing():this.disableClusterBrowsing())])}destroy(){this._cancelLocationUpdate(),this._cancelFetchingFeatures(),this._cancelCenterAtLocation(),this._cancelFeatureStream(),this._pendingPromises.clear(),this.browseClusterEnabled=!1,this.view=null,this.map=null,this.spatialReference=null,this.timeZone=null}get active(){return!(!this.visible||this.waitingForResult)}get allActions(){let e=this._get(`allActions`)||new D;e.removeAll();let{actions:t,defaultActions:n,defaultPopupTemplateEnabled:r,includeDefaultActions:i,selectedFeature:a}=this,o=i?n.concat(t):t,s=a&&(typeof a.getEffectivePopupTemplate==`function`&&a.getEffectivePopupTemplate(r)||a.popupTemplate),c=s?.actions;return(s?.overwriteActions?c:c?.concat(o)??o)?.filter(Boolean).forEach(t=>e.add(t)),e}get defaultActions(){let e=this._get(`defaultActions`)||new D;return e.removeAll(),e.addMany(M(this.selectedFeature)?V():B()),e}get featureCount(){return this.features.length}set features(e){if(this._get(`features`)===e)return;let t=e||[];this._set(`features`,t);let{pendingPromisesCount:n,promiseCount:r,selectedFeatureIndex:i}=this,a=r>0&&t.length>0,o=this._activeFeatureStream!=null&&t.length>0,s=a||o;if(this.initialDisplayMode===`list`){(!s||a&&n===r)&&(this.selectedFeatureIndex=-1);return}if(s&&i===-1){this.selectedFeatureIndex=0;return}s&&i!==-1||(this.selectedFeatureIndex=t.length?0:-1)}get featureStream(){return this._get(`featureStream`)||null}set featureStream(e){if(this._get(`featureStream`)===e||(this._set(`featureStream`,e),this._cancelFeatureStream(),!e))return;this.promises=[];let t=this._featureStreamVersion;this._activeFeatureStream=e,this._setStreamingFeatures(!0),this._consumeFeatureStream(e,t).catch(()=>{})}set location(e){let t=e,n=this.spatialReference?.isWebMercator;e?.spatialReference?.isWGS84&&n&&(t=y(e)),this._set(`location`,t)}get map(){return this.view?.map??null}set map(e){this._override(`map`,e)}get pendingPromisesCount(){return this._pendingPromises.size}get promiseCount(){return this.promises.length}get promises(){return this._get(`promises`)||[]}set promises(e){if(this._get(`promises`)!==e){if(this._cancelFeatureStream(),this._pendingPromises.clear(),this.features=[],!Array.isArray(e)||!e.length){this._set(`promises`,[]);return}this._set(`promises`,e),e=e.slice(),e.forEach(e=>this._pendingPromises.add(e)),e.reduce((e,t)=>e.finally(()=>t.then(e=>{this._pendingPromises.has(t)&&this._updateFeatures(e)}).finally(()=>this._pendingPromises.delete(t)).catch(()=>{})),Promise.resolve())}}get screenLocation(){return super.screenLocation}get selectedFeature(){let{features:e,selectedFeatureIndex:t}=this;return t===-1?null:e[t]||null}get selectedFeatureIndex(){let e=this._get(`selectedFeatureIndex`);return typeof e==`number`?e:-1}set selectedFeatureIndex(e){let{featureCount:t}=this;(isNaN(e)||e<0||!t)&&(e=-1),this.activeFeature=null,this._set(`selectedFeatureIndex`,e)}get selectedFeatureViewModel(){return this.featureViewModels[this.selectedFeatureIndex]||null}get spatialReference(){return this.view?.spatialReference??null}set spatialReference(e){this._override(`spatialReference`,e)}get state(){let{view:e,map:t}=this;return e?e.ready?`ready`:`disabled`:t?`ready`:`disabled`}get timeZone(){return this.view?.timeZone??C}set timeZone(e){this._overrideIfSome(`timeZone`,e)}get waitingForContents(){return this.featureViewModels.some(e=>e.waitingForContent)}get waitingForResult(){return!!((this._fetchFeaturesController||this.streamingFeatures||this.pendingPromisesCount>0)&&this.featureCount===0)}centerAtLocation(){let{view:e}=this,t=N(this);this._cancelCenterAtLocation();let n=new AbortController,{signal:r}=n;return this._centerAtLocationController=n,!t||!e?Promise.reject(new i(`center-at-location:invalid-target-or-view`,`Cannot center at a location without a target and view.`,{target:t,view:e})):this.callGoTo({target:{target:t,scale:e.scale},options:{signal:r}}).catch(e=>{c(e)||o.getLogger(this).error(e)})}zoomTo(e){return this.callGoTo(e)}clear(){this._cancelFeatureStream(),this.set({featureStream:null,promises:[],features:[],content:null,title:null,location:null,activeFeature:null})}fetchFeatures(e,t){let{view:n}=this;if(!n||!e)throw new i(`fetch-features:invalid-screenpoint-or-view`,`Cannot fetch features without a screenPoint and view.`,{screenPoint:e,view:n});return n.fetchPopupFeaturesLegacy(e,{pointerType:t?.event?.pointerType,defaultPopupTemplateEnabled:this.defaultPopupTemplateEnabled,signal:t?.signal})}open(e){this._cancelFeatureStream();let t={updateLocationEnabled:!1,promises:[],fetchFeatures:!1,...e,visible:!0},{fetchFeatures:n}=t;delete t.fetchFeatures,n&&!t.featureStream&&this._setFetchFeaturesPromises(t.location).catch(()=>{});for(let e of[`actionsMenuOpen`,`collapsed`,`shouldFocus`])delete t[e];this.set(t)}triggerAction(e){let t=this.allActions.at(e);t&&!t.disabled&&this.emit(`trigger-action`,{action:t})}next(){return this.selectedFeatureIndex=this._getRoundRobinIndex(this.selectedFeatureIndex+1,this.featureCount),this}previous(){return this.selectedFeatureIndex=this._getRoundRobinIndex(this.selectedFeatureIndex-1,this.featureCount),this}disableClusterBrowsing(){P(this),this._clearBrowsedClusterGraphics()}async enableClusterBrowsing(){let{view:e,selectedFeature:t}=this;if(e?.type!==`2d`){o.getLogger(this).warn(`enableClusterBrowsing:invalid-view: View must be 2d MapView.`,t);return}if(!M(t)){o.getLogger(this).warn(`enableClusterBrowsing:invalid-selectedFeature: Selected feature must represent an aggregate/cluster graphic.`,t);return}await F(this),await I(this)}async handleViewClick(e){return this._fetchFeaturesAndOpen(e)}_setStreamingFeatures(e){this._set(`streamingFeatures`,e)}_getRoundRobinIndex(e,t){return(e+t)%t}_animationStateChange(e){this.zoomToLocation||(O.disabled=e===`waiting-for-target`)}_clearBrowsedClusterGraphics(){let e=[this.selectedClusterBoundaryFeature,this._selectedClusterFeature].filter(n);this.view?.graphics?.removeMany(e),this._selectedClusterFeature=null,this.selectedClusterBoundaryFeature.geometry=null}_viewScaleChange(){if(M(this.selectedFeature)){this.browseClusterEnabled=!1,this.visible=!1,this.clear();return}this.browseClusterEnabled&&(this.features=this.selectedFeature?[this.selectedFeature]:[])}_locationChange(e){let{selectedFeature:t,updateLocationEnabled:n,view:r}=this;r&&!this._locationUpdateController&&n&&e&&(!t||t.geometry)&&this.centerAtLocation()}_selectedFeatureIndexChange(){this.featurePage=this.featureCount>0?Math.floor(this.selectedFeatureIndex/this.featuresPerPage)+1:null}_featureViewModelsChange(){this.featurePage=this.featureCount>0?1:null}_setGraphicOnFeatureViewModels(){let{features:e,featureCount:t,featurePage:n,featuresPerPage:r,featureViewModels:i}=this;if(n==null)return;let a=((n-1)*r+t)%t,o=a+r;i.slice(a,o).forEach((t,n)=>{t&&(t.graphic??=e[a+n])})}async _selectedFeatureChange(e){let{location:t,updateLocationEnabled:n,view:r}=this;if(!e||!r)return;if(this.browseClusterEnabled){if(this._selectedClusterFeature&&=(r.graphics.remove(this._selectedClusterFeature),null),M(e))return;e.symbol=await S(e),this._selectedClusterFeature=e,r.graphics.add(this._selectedClusterFeature);return}let i=e.sourceLayer?.type;if((i===`map-image`||i===`imagery`||i===`imagery-tile`)&&(e.symbol=await S(e)),(n||!t)&&e.geometry){if(e.geometry.type===`point`){this.location=e.geometry;return}let{labelPointExecute:t}=await import(`../../geometry/operators/labelPointOperator.js`);this.location=t(e.geometry);return}if(n&&!e.geometry){await this.centerAtLocation();let e=r.center?.clone();e&&(this.location=e)}}_waitingForResultChange(){!this.featureCount&&(this.promises.length>0||this.featureStream)&&(this.visible=!1)}async _setFetchFeaturesPromises(e){let{pendingFeatures:t}=await this._fetchFeaturesWithController({mapPoint:e});this.promises=t}_destroyFeatureVMs(){this.featureViewModels.forEach(e=>e&&!e.destroyed&&e.destroy()),this._set(`featureViewModels`,[])}_updateFeatureVMs(){let{selectedFeature:e,features:t,featureViewModels:n,view:r,spatialReference:i,map:a,timeZone:o,location:s}=this;if(M(t[0])||(this.browseClusterEnabled=!1),this._destroyFeatureVMs(),!t?.length)return;let c=n.slice(),l=[];t.forEach((t,n)=>{if(!t)return;let u=null;if(c.some((e,n)=>(e&&e.graphic===t&&(u=e,c.splice(n,1)),!!u)),u)l[n]=u;else{let c=new E({abilities:this.featureViewModelAbilities,defaultPopupTemplateEnabled:this.defaultPopupTemplateEnabled,spatialReference:i,graphic:t===e?t:null,location:s,map:a,view:r,timeZone:o,suppressDeprecationWarning:!0});l[n]=c}}),c.forEach(e=>e&&!e.destroyed&&e.destroy()),this._set(`featureViewModels`,l)}async _getScreenPoint(e,t){let{spatialReference:n,view:r}=this;if(!r)return null;await r?.when();let i=e?.spatialReference;return!i||!n?null:(await g(i,n,null,t),r.toScreen(e))}_cancelCenterAtLocation(){this._centerAtLocationController?.abort(),this._centerAtLocationController=null}_cancelFeatureStream(){this._featureStreamVersion++,this._setStreamingFeatures(!1);let e=this._activeFeatureStream;this._activeFeatureStream=null,this._get(`featureStream`)===e&&this._set(`featureStream`,null),e?.return&&e.return(void 0).catch(()=>{})}_cancelFetchingFeatures(){this._fetchFeaturesController?.abort(),this._fetchFeaturesController=null}async _consumeFeatureStream(e,t){try{for await(let n of e){if(t!==this._featureStreamVersion)return;this._updateFeatures([n])}}finally{this._activeFeatureStream===e&&(this._activeFeatureStream=null,this._setStreamingFeatures(!1),this._waitingForResultChange())}}async _projectScreenPointAndFetchFeatures({mapPoint:e,screenPoint:t,event:n,signal:r}){return this.fetchFeatures(t??await this._getScreenPoint(e??this.location,{signal:r}),{signal:r,event:n})}_fetchFeaturesWithController({mapPoint:e,screenPoint:t,event:n}){this._cancelFetchingFeatures();let r=new AbortController,{signal:i}=r;this._fetchFeaturesController=r;let a=this._projectScreenPointAndFetchFeatures({mapPoint:e,screenPoint:t,signal:i,event:n});return a.catch(()=>{}).finally(()=>{this._fetchFeaturesController===r&&(this._fetchFeaturesController=null)}),a}async _fetchFeaturesAndOpen(e){let{mapPoint:t}=e;this.removeHandles(z),this.addHandles([u(()=>this.view?.scale,()=>this._debouncedLocationUpdate(t).catch(e=>{c(e)||o.getLogger(this).error(e)})),d(()=>!this.visible,()=>{this.removeHandles(z)},{once:!0})],z);let{pendingFeatures:n}=await this._fetchFeaturesWithController({mapPoint:t,screenPoint:T(e),event:e});return{location:t??void 0,promises:n}}async _locationUpdate(e,t){let{spatialReference:n}=this,r=this.selectedFeature?.geometry?.type,i=this.location??e;if(r&&r!==`mesh`&&n&&i&&this.selectedFeature){if(r===`point`){let{labelPointExecute:e}=await import(`../../geometry/operators/labelPointOperator.js`);this.location=e(this.selectedFeature.geometry);return}try{let e=this.selectedFeature,r=e.geometry,a=this._getHighlightLayer(e),o=e.getObjectId();if(!a||!this.view)return;if(o){let e=this.view?.allLayerViews.find(e=>e.layer.uid===a.uid);if(!e||!(`queryFeatures`in e))return;let i=e.createQuery();i.outSpatialReference=n,i.objectIds=[o],i.returnGeometry=!0;let{features:s}=await e.queryFeatures(i,t);r=s[0]?.geometry}if(!r||r.type===`mesh`)return;r=_(r,n),H||=await Promise.all([import(`../../geometry/operators/intersectsOperator.js`),import(`../../geometry/operators/proximityOperator.js`)]);let[{intersectsExecute:s},{proximityGetNearestCoordinate:c}]=H;if(!s(r,i)){let t=c(r,i).coordinate??i;this.selectedFeature===e&&(this.location=t)}}catch(e){c(e)||o.getLogger(this).error(e)}}}_cancelLocationUpdate(){this._locationUpdateController?.abort(),this._locationUpdateController=null}_autoClose(){this.autoCloseEnabled&&(this.visible=!1)}async _getLayerView(e,t){return await e.when(),e.whenLayerView(t)}_getHighlightLayer(e){let{layer:t,sourceLayer:n}=e;return n&&`layer`in n&&n.layer?n.layer:n?.type===`map-notes`||n?.type===`sketch`||n?.type===`subtype-group`?n:t??n}_getHighlightLayerView(e,t){return t.type===`subtype-sublayer`&&t.parent&&this._mapIncludesLayer(t.parent)?this._getLayerView(e,t.parent):t&&this._mapIncludesLayer(t)?this._getLayerView(e,t):null}_getHighlightTarget(e,t,n){if(U(t.type,n))return e;let r=e.getObjectId();if(r!=null)return r;let i=t.type===`imagery`?void 0:`objectIdField`in t?t.objectIdField||b:null,a=e.attributes;return a&&i&&a[i]||e}_mapIncludesLayer(e){return!!this.map?.allLayers?.includes(e)}async _highlightFeature(e,t){this.removeHandles(e);let n=this[t];if(!n)return;let{highlightEnabled:r,view:i,visible:a}=this;if(!i||!r||!a)return;let o=this._getHighlightLayer(n);if(!o)return;let s=this._getHighlightLayerView(i,o);if(!s)return;this._highlightPromises[e]=s;let c=await s;if(!c||!w(c)||this._highlightPromises[e]!==s||!this[t]||!this.highlightEnabled)return;let l=c.highlight(this._getHighlightTarget(n,o,i.type));this.addHandles(l,e)}async _highlightActiveFeature(){return this._highlightFeature(`highlight-active-feature`,`activeFeature`)}async _highlightSelectedFeature(){return this._highlightFeature(`highlight-selected-feature`,`selectedFeature`)}_updateFeatures(e){let{features:t}=this,n=e.filter(e=>!t.includes(e));n?.length&&(this.features=t.concat(n))}};e([p()],W.prototype,`_fetchFeaturesController`,void 0),e([p({type:D})],W.prototype,`actions`,void 0),e([p({readOnly:!0})],W.prototype,`active`,null),e([p()],W.prototype,`activeFeature`,void 0),e([p({readOnly:!0})],W.prototype,`allActions`,null),e([p()],W.prototype,`autoCloseEnabled`,void 0),e([p()],W.prototype,`browseClusterEnabled`,void 0),e([p()],W.prototype,`content`,void 0),e([p({type:D,readOnly:!0})],W.prototype,`defaultActions`,null),e([p({type:Boolean})],W.prototype,`defaultPopupTemplateEnabled`,void 0),e([p({readOnly:!0})],W.prototype,`featureCount`,null),e([p()],W.prototype,`featurePage`,void 0),e([p({value:[]})],W.prototype,`features`,null),e([p()],W.prototype,`featuresPerPage`,void 0),e([p()],W.prototype,`featureStream`,null),e([p()],W.prototype,`featureMenuOpen`,void 0),e([p()],W.prototype,`featureMenuTitle`,void 0),e([p()],W.prototype,`featureViewModelAbilities`,void 0),e([p({readOnly:!0})],W.prototype,`featureViewModels`,void 0),e([p()],W.prototype,`highlightEnabled`,void 0),e([p()],W.prototype,`includeDefaultActions`,void 0),e([p()],W.prototype,`initialDisplayMode`,void 0),e([p({type:h})],W.prototype,`location`,null),e([p()],W.prototype,`map`,null),e([p({readOnly:!0})],W.prototype,`streamingFeatures`,void 0),e([p({readOnly:!0})],W.prototype,`pendingPromisesCount`,null),e([p({readOnly:!0})],W.prototype,`promiseCount`,null),e([p()],W.prototype,`promises`,null),e([p({readOnly:!0})],W.prototype,`selectedClusterBoundaryFeature`,void 0),e([p({value:null,readOnly:!0})],W.prototype,`selectedFeature`,null),e([p({value:-1})],W.prototype,`selectedFeatureIndex`,null),e([p({readOnly:!0})],W.prototype,`selectedFeatureViewModel`,null),e([p({type:v})],W.prototype,`spatialReference`,null),e([p({readOnly:!0})],W.prototype,`state`,null),e([p()],W.prototype,`timeZone`,null),e([p()],W.prototype,`title`,void 0),e([p()],W.prototype,`updateLocationEnabled`,void 0),e([p()],W.prototype,`view`,void 0),e([p()],W.prototype,`visible`,void 0),e([p({readOnly:!0})],W.prototype,`waitingForContents`,null),e([p({readOnly:!0})],W.prototype,`waitingForResult`,null),e([p()],W.prototype,`zoomFactor`,void 0),e([p()],W.prototype,`zoomToLocation`,void 0),e([p()],W.prototype,`centerAtLocation`,null),W=e([m(`esri.widgets.Features.FeaturesViewModel`)],W);export{W as default};
|
|
2
|
+
import{__decorate as e}from"tslib";import t from"../../Graphic.js";import{isSome as n}from"../../core/arrayUtils.js";import{deprecatedModule as r}from"../../core/deprecate.js";import i from"../../core/Error.js";import{EventedAccessor as a}from"../../core/Evented.js";import o from"../../core/Logger.js";import{debounce as s,isAbortError as c}from"../../core/promiseUtils.js";import l from"../../core/ReactiveSet.js";import{watch as u,when as d,sync as f}from"../../core/reactiveUtils.js";import{property as p,subclass as m}from"../../core/accessorSupport/decorators.js";import h from"../../geometry/Point.js";import{initializeProjection as g,project as _}from"../../geometry/projectionUtils.js";import v from"../../geometry/SpatialReference.js";import{geographicToWebMercator as y}from"../../geometry/support/webMercatorUtils.js";import{fallbackObjectIDAttribute as b}from"../../layers/LayerConstants.js";import{getHighlightLayer as x,getHighlightLayerView as S}from"../../popup/support/featureUtils.js";import C from"../../symbols/SimpleFillSymbol.js";import{getDisplayedSymbol as w}from"../../symbols/support/symbolUtils.js";import{system as T}from"../../time/constants.js";import{highlightsSupported as E}from"../../views/support/layerViewUtils.js";import{createScreenPointFromEvent as D}from"../../views/support/screenUtils.js";import O from"../Feature/FeatureViewModel.js";import{ActionsCollection as k,zoomToFeature as A,zoomToClusteredFeatures as j,browseClusteredFeatures as M}from"../Popup/actions.js";import{triggerAction as N,isClusterFeature as P,getSelectedTarget as F,removeClusteredFeaturesForBrowsing as I,displayClusterExtent as L,browseAggregateFeatures as R}from"../Popup/actionUtils.js";import{AnchorElementViewModelMixin as z}from"../support/AnchorElementViewModel.js";import{GoTo as B}from"../support/GoTo.js";const V=`location-scale-handle`,H=()=>[A.clone()],U=()=>[j.clone(),M.clone()];let W=null;function G(e,t){return e===`building-scene`||e===`map-image`||e===`tile`||e===`imagery`||t===`2d`&&e===`imagery-tile`}let K=class extends B(z(a)){constructor(e){super(e),this._pendingPromises=new l,this._fetchFeaturesController=null,this._centerAtLocationController=null,this._locationUpdateController=null,this._highlightPromises={"highlight-active-feature":null,"highlight-selected-feature":null},this._selectedClusterFeature=null,this._featureStreamVersion=0,this._activeFeatureStream=null,this.actions=new k,this.activeFeature=null,this.autoCloseEnabled=!1,this.browseClusterEnabled=!1,this.content=null,this.defaultPopupTemplateEnabled=!1,this.featurePage=null,this.featuresPerPage=20,this.featureMenuOpen=!1,this.featureMenuTitle=null,this.featureViewModelAbilities=null,this.featureViewModels=[],this.highlightEnabled=!0,this.includeDefaultActions=!0,this.initialDisplayMode=`feature`,this.streamingFeatures=!1,this.selectedClusterBoundaryFeature=new t({symbol:new C({outline:{width:1.5,color:`cyan`},style:`none`})}),this.title=null,this.updateLocationEnabled=!1,this.view=null,this.visible=!1,this.zoomFactor=4,this.zoomToLocation=null,this._debouncedLocationUpdate=s(async e=>{this._cancelLocationUpdate();let t=new AbortController,{signal:n}=t;this._locationUpdateController=t,await this._locationUpdate(e,{signal:n}).catch(()=>{}).finally(()=>{this._locationUpdateController===t&&(this._locationUpdateController=null)})}),e?.suppressDeprecationWarning||r(o.getLogger(this),`esri.widgets.Features.FeaturesViewModel`,{version:`5.2`,replacement:`Use the Features (Next) component or the @arcgis/core/popup/FeaturesModel module instead.`,warnOnce:!0})}normalizeCtorArgs(e){let{suppressDeprecationWarning:t,...n}=e??{};return n}initialize(){this.addHandles([this.on(`view-change`,()=>this._autoClose()),u(()=>[this.highlightEnabled,this.selectedFeature,this.visible,this.view],()=>this._highlightSelectedFeature()),u(()=>[this.highlightEnabled,this.activeFeature,this.visible,this.view],()=>this._highlightActiveFeature()),u(()=>this.view?.animation?.state,e=>this._animationStateChange(e)),u(()=>this.location,e=>this._locationChange(e)),u(()=>this.selectedFeature,e=>this._selectedFeatureChange(e).catch(()=>{})),u(()=>[this.selectedFeatureIndex,this.featureCount,this.featuresPerPage],()=>this._selectedFeatureIndexChange()),u(()=>[this.featurePage,this.selectedFeatureIndex,this.featureCount,this.featuresPerPage,this.featureViewModels],()=>this._setGraphicOnFeatureViewModels()),u(()=>this.featureViewModels,()=>this._featureViewModelsChange()),this.on(`trigger-action`,e=>N({event:e,viewModel:this,view:this.view}).catch(()=>{})),d(()=>!this.waitingForResult,()=>this._waitingForResultChange(),f),u(()=>[this.features,this.map,this.spatialReference,this.timeZone],()=>this._updateFeatureVMs()),u(()=>this.view?.scale,()=>this._viewScaleChange()),d(()=>!this.visible,()=>this.browseClusterEnabled=!1),u(()=>this.browseClusterEnabled,e=>e?this.enableClusterBrowsing():this.disableClusterBrowsing())])}destroy(){this._cancelLocationUpdate(),this._cancelFetchingFeatures(),this._cancelCenterAtLocation(),this._cancelFeatureStream(),this._pendingPromises.clear(),this.browseClusterEnabled=!1,this.view=null,this.map=null,this.spatialReference=null,this.timeZone=null}get active(){return!(!this.visible||this.waitingForResult)}get allActions(){let e=this._get(`allActions`)||new k;e.removeAll();let{actions:t,defaultActions:n,defaultPopupTemplateEnabled:r,includeDefaultActions:i,selectedFeature:a}=this,o=i?n.concat(t):t,s=a&&(typeof a.getEffectivePopupTemplate==`function`&&a.getEffectivePopupTemplate(r)||a.popupTemplate),c=s?.actions;return(s?.overwriteActions?c:c?.concat(o)??o)?.filter(Boolean).forEach(t=>e.add(t)),e}get defaultActions(){let e=this._get(`defaultActions`)||new k;return e.removeAll(),e.addMany(P(this.selectedFeature)?U():H()),e}get featureCount(){return this.features.length}set features(e){if(this._get(`features`)===e)return;let t=e||[];this._set(`features`,t);let{pendingPromisesCount:n,promiseCount:r,selectedFeatureIndex:i}=this,a=r>0&&t.length>0,o=this._activeFeatureStream!=null&&t.length>0,s=a||o;if(this.initialDisplayMode===`list`){(!s||a&&n===r)&&(this.selectedFeatureIndex=-1);return}if(s&&i===-1){this.selectedFeatureIndex=0;return}s&&i!==-1||(this.selectedFeatureIndex=t.length?0:-1)}get featureStream(){return this._get(`featureStream`)||null}set featureStream(e){if(this._get(`featureStream`)===e||(this._set(`featureStream`,e),this._cancelFeatureStream(),!e))return;this.promises=[];let t=this._featureStreamVersion;this._activeFeatureStream=e,this._setStreamingFeatures(!0),this._consumeFeatureStream(e,t).catch(()=>{})}set location(e){let t=e,n=this.spatialReference?.isWebMercator;e?.spatialReference?.isWGS84&&n&&(t=y(e)),this._set(`location`,t)}get map(){return this.view?.map??null}set map(e){this._override(`map`,e)}get pendingPromisesCount(){return this._pendingPromises.size}get promiseCount(){return this.promises.length}get promises(){return this._get(`promises`)||[]}set promises(e){if(this._get(`promises`)!==e){if(this._cancelFeatureStream(),this._pendingPromises.clear(),this.features=[],!Array.isArray(e)||!e.length){this._set(`promises`,[]);return}this._set(`promises`,e),e=e.slice(),e.forEach(e=>this._pendingPromises.add(e)),e.reduce((e,t)=>e.finally(()=>t.then(e=>{this._pendingPromises.has(t)&&this._updateFeatures(e)}).finally(()=>this._pendingPromises.delete(t)).catch(()=>{})),Promise.resolve())}}get screenLocation(){return super.screenLocation}get selectedFeature(){let{features:e,selectedFeatureIndex:t}=this;return t===-1?null:e[t]||null}get selectedFeatureIndex(){let e=this._get(`selectedFeatureIndex`);return typeof e==`number`?e:-1}set selectedFeatureIndex(e){let{featureCount:t}=this;(isNaN(e)||e<0||!t)&&(e=-1),this.activeFeature=null,this._set(`selectedFeatureIndex`,e)}get selectedFeatureViewModel(){return this.featureViewModels[this.selectedFeatureIndex]||null}get spatialReference(){return this.view?.spatialReference??null}set spatialReference(e){this._override(`spatialReference`,e)}get state(){let{view:e,map:t}=this;return e?e.ready?`ready`:`disabled`:t?`ready`:`disabled`}get timeZone(){return this.view?.timeZone??T}set timeZone(e){this._overrideIfSome(`timeZone`,e)}get waitingForContents(){return this.featureViewModels.some(e=>e.waitingForContent)}get waitingForResult(){return!!((this._fetchFeaturesController||this.streamingFeatures||this.pendingPromisesCount>0)&&this.featureCount===0)}centerAtLocation(){let{view:e}=this,t=F(this);this._cancelCenterAtLocation();let n=new AbortController,{signal:r}=n;return this._centerAtLocationController=n,!t||!e?Promise.reject(new i(`center-at-location:invalid-target-or-view`,`Cannot center at a location without a target and view.`,{target:t,view:e})):this.callGoTo({target:{target:t,scale:e.scale},options:{signal:r}}).catch(e=>{c(e)||o.getLogger(this).error(e)})}zoomTo(e){return this.callGoTo(e)}clear(){this._cancelFeatureStream(),this.set({featureStream:null,promises:[],features:[],content:null,title:null,location:null,activeFeature:null})}fetchFeatures(e,t){let{view:n}=this;if(!n||!e)throw new i(`fetch-features:invalid-screenpoint-or-view`,`Cannot fetch features without a screenPoint and view.`,{screenPoint:e,view:n});return n.fetchPopupFeaturesLegacy(e,{pointerType:t?.event?.pointerType,defaultPopupTemplateEnabled:this.defaultPopupTemplateEnabled,signal:t?.signal})}open(e){this._cancelFeatureStream();let t={updateLocationEnabled:!1,promises:[],fetchFeatures:!1,...e,visible:!0},{fetchFeatures:n}=t;delete t.fetchFeatures,n&&!t.featureStream&&this._setFetchFeaturesPromises(t.location).catch(()=>{});for(let e of[`actionsMenuOpen`,`collapsed`,`shouldFocus`])delete t[e];this.set(t)}triggerAction(e){let t=this.allActions.at(e);t&&!t.disabled&&this.emit(`trigger-action`,{action:t})}next(){return this.selectedFeatureIndex=this._getRoundRobinIndex(this.selectedFeatureIndex+1,this.featureCount),this}previous(){return this.selectedFeatureIndex=this._getRoundRobinIndex(this.selectedFeatureIndex-1,this.featureCount),this}disableClusterBrowsing(){I(this),this._clearBrowsedClusterGraphics()}async enableClusterBrowsing(){let{view:e,selectedFeature:t}=this;if(e?.type!==`2d`){o.getLogger(this).warn(`enableClusterBrowsing:invalid-view: View must be 2d MapView.`,t);return}if(!P(t)){o.getLogger(this).warn(`enableClusterBrowsing:invalid-selectedFeature: Selected feature must represent an aggregate/cluster graphic.`,t);return}await L(this),await R(this)}async handleViewClick(e){return this._fetchFeaturesAndOpen(e)}_setStreamingFeatures(e){this._set(`streamingFeatures`,e)}_getRoundRobinIndex(e,t){return(e+t)%t}_animationStateChange(e){this.zoomToLocation||(A.disabled=e===`waiting-for-target`)}_clearBrowsedClusterGraphics(){let e=[this.selectedClusterBoundaryFeature,this._selectedClusterFeature].filter(n);this.view?.graphics?.removeMany(e),this._selectedClusterFeature=null,this.selectedClusterBoundaryFeature.geometry=null}_viewScaleChange(){if(P(this.selectedFeature)){this.browseClusterEnabled=!1,this.visible=!1,this.clear();return}this.browseClusterEnabled&&(this.features=this.selectedFeature?[this.selectedFeature]:[])}_locationChange(e){let{selectedFeature:t,updateLocationEnabled:n,view:r}=this;r&&!this._locationUpdateController&&n&&e&&(!t||t.geometry)&&this.centerAtLocation()}_selectedFeatureIndexChange(){this.featurePage=this.featureCount>0?Math.floor(this.selectedFeatureIndex/this.featuresPerPage)+1:null}_featureViewModelsChange(){this.featurePage=this.featureCount>0?1:null}_setGraphicOnFeatureViewModels(){let{features:e,featureCount:t,featurePage:n,featuresPerPage:r,featureViewModels:i}=this;if(n==null)return;let a=((n-1)*r+t)%t,o=a+r;i.slice(a,o).forEach((t,n)=>{t&&(t.graphic??=e[a+n])})}async _selectedFeatureChange(e){let{location:t,updateLocationEnabled:n,view:r}=this;if(!e||!r)return;if(this.browseClusterEnabled){if(this._selectedClusterFeature&&=(r.graphics.remove(this._selectedClusterFeature),null),P(e))return;e.symbol=await w(e),this._selectedClusterFeature=e,r.graphics.add(this._selectedClusterFeature);return}let i=e.sourceLayer?.type;if((i===`map-image`||i===`imagery`||i===`imagery-tile`)&&(e.symbol=await w(e)),(n||!t)&&e.geometry){if(e.geometry.type===`point`){this.location=e.geometry;return}let{labelPointExecute:t}=await import(`../../geometry/operators/labelPointOperator.js`);this.location=t(e.geometry);return}if(n&&!e.geometry){await this.centerAtLocation();let e=r.center?.clone();e&&(this.location=e)}}_waitingForResultChange(){!this.featureCount&&(this.promises.length>0||this.featureStream)&&(this.visible=!1)}async _setFetchFeaturesPromises(e){let{pendingFeatures:t}=await this._fetchFeaturesWithController({mapPoint:e});this.promises=t}_destroyFeatureVMs(){this.featureViewModels.forEach(e=>e&&!e.destroyed&&e.destroy()),this._set(`featureViewModels`,[])}_updateFeatureVMs(){let{selectedFeature:e,features:t,featureViewModels:n,view:r,spatialReference:i,map:a,timeZone:o,location:s}=this;if(P(t[0])||(this.browseClusterEnabled=!1),this._destroyFeatureVMs(),!t?.length)return;let c=n.slice(),l=[];t.forEach((t,n)=>{if(!t)return;let u=null;if(c.some((e,n)=>(e&&e.graphic===t&&(u=e,c.splice(n,1)),!!u)),u)l[n]=u;else{let c=new O({abilities:this.featureViewModelAbilities,defaultPopupTemplateEnabled:this.defaultPopupTemplateEnabled,spatialReference:i,graphic:t===e?t:null,location:s,map:a,view:r,timeZone:o,suppressDeprecationWarning:!0});l[n]=c}}),c.forEach(e=>e&&!e.destroyed&&e.destroy()),this._set(`featureViewModels`,l)}async _getScreenPoint(e,t){let{spatialReference:n,view:r}=this;if(!r)return null;await r?.when();let i=e?.spatialReference;return!i||!n?null:(await g(i,n,null,t),r.toScreen(e))}_cancelCenterAtLocation(){this._centerAtLocationController?.abort(),this._centerAtLocationController=null}_cancelFeatureStream(){this._featureStreamVersion++,this._setStreamingFeatures(!1);let e=this._activeFeatureStream;this._activeFeatureStream=null,this._get(`featureStream`)===e&&this._set(`featureStream`,null),e?.return&&e.return(void 0).catch(()=>{})}_cancelFetchingFeatures(){this._fetchFeaturesController?.abort(),this._fetchFeaturesController=null}async _consumeFeatureStream(e,t){try{for await(let n of e){if(t!==this._featureStreamVersion)return;this._updateFeatures([n])}}finally{this._activeFeatureStream===e&&(this._activeFeatureStream=null,this._setStreamingFeatures(!1),this._waitingForResultChange())}}async _projectScreenPointAndFetchFeatures({mapPoint:e,screenPoint:t,event:n,signal:r}){return this.fetchFeatures(t??await this._getScreenPoint(e??this.location,{signal:r}),{signal:r,event:n})}_fetchFeaturesWithController({mapPoint:e,screenPoint:t,event:n}){this._cancelFetchingFeatures();let r=new AbortController,{signal:i}=r;this._fetchFeaturesController=r;let a=this._projectScreenPointAndFetchFeatures({mapPoint:e,screenPoint:t,signal:i,event:n});return a.catch(()=>{}).finally(()=>{this._fetchFeaturesController===r&&(this._fetchFeaturesController=null)}),a}async _fetchFeaturesAndOpen(e){let{mapPoint:t}=e;this.removeHandles(V),this.addHandles([u(()=>this.view?.scale,()=>this._debouncedLocationUpdate(t).catch(e=>{c(e)||o.getLogger(this).error(e)})),d(()=>!this.visible,()=>{this.removeHandles(V)},{once:!0})],V);let{pendingFeatures:n}=await this._fetchFeaturesWithController({mapPoint:t,screenPoint:D(e),event:e});return{location:t??void 0,promises:n}}async _locationUpdate(e,t){let{spatialReference:n}=this,r=this.selectedFeature?.geometry?.type,i=this.location??e;if(r&&r!==`mesh`&&n&&i&&this.selectedFeature){if(r===`point`){let{labelPointExecute:e}=await import(`../../geometry/operators/labelPointOperator.js`);this.location=e(this.selectedFeature.geometry);return}try{let e=this.selectedFeature,r=e.geometry,a=this._getHighlightLayer(e),o=e.getObjectId();if(!a||!this.view)return;if(o){let e=this.view?.allLayerViews.find(e=>e.layer.uid===a.uid);if(!e||!(`queryFeatures`in e))return;let i=e.createQuery();i.outSpatialReference=n,i.objectIds=[o],i.returnGeometry=!0;let{features:s}=await e.queryFeatures(i,t);r=s[0]?.geometry}if(!r||r.type===`mesh`)return;r=_(r,n),W||=await Promise.all([import(`../../geometry/operators/intersectsOperator.js`),import(`../../geometry/operators/proximityOperator.js`)]);let[{intersectsExecute:s},{proximityGetNearestCoordinate:c}]=W;if(!s(r,i)){let t=c(r,i).coordinate??i;this.selectedFeature===e&&(this.location=t)}}catch(e){c(e)||o.getLogger(this).error(e)}}}_cancelLocationUpdate(){this._locationUpdateController?.abort(),this._locationUpdateController=null}_autoClose(){this.autoCloseEnabled&&(this.visible=!1)}_getHighlightLayer(e){return x(e,this.map)}_getHighlightTarget(e,t,n){if(G(t.type,n))return e;let r=e.getObjectId();if(r!=null)return r;let i=t.type===`imagery`?void 0:`objectIdField`in t?t.objectIdField||b:null,a=e.attributes;return a&&i&&a[i]||e}async _highlightFeature(e,t){this.removeHandles(e);let n=this[t];if(!n)return;let{highlightEnabled:r,view:i,visible:a}=this;if(!i||!r||!a)return;let o=this._getHighlightLayer(n);if(!o)return;let s=S(i,o,this.map);if(!s)return;this._highlightPromises[e]=s;let c=await s;if(!c||!E(c)||this._highlightPromises[e]!==s||!this[t]||!this.highlightEnabled)return;let l=c.highlight(this._getHighlightTarget(n,o,i.type));this.addHandles(l,e)}async _highlightActiveFeature(){return this._highlightFeature(`highlight-active-feature`,`activeFeature`)}async _highlightSelectedFeature(){return this._highlightFeature(`highlight-selected-feature`,`selectedFeature`)}_updateFeatures(e){let{features:t}=this,n=e.filter(e=>!t.includes(e));n?.length&&(this.features=t.concat(n))}};e([p()],K.prototype,`_fetchFeaturesController`,void 0),e([p({type:k})],K.prototype,`actions`,void 0),e([p({readOnly:!0})],K.prototype,`active`,null),e([p()],K.prototype,`activeFeature`,void 0),e([p({readOnly:!0})],K.prototype,`allActions`,null),e([p()],K.prototype,`autoCloseEnabled`,void 0),e([p()],K.prototype,`browseClusterEnabled`,void 0),e([p()],K.prototype,`content`,void 0),e([p({type:k,readOnly:!0})],K.prototype,`defaultActions`,null),e([p({type:Boolean})],K.prototype,`defaultPopupTemplateEnabled`,void 0),e([p({readOnly:!0})],K.prototype,`featureCount`,null),e([p()],K.prototype,`featurePage`,void 0),e([p({value:[]})],K.prototype,`features`,null),e([p()],K.prototype,`featuresPerPage`,void 0),e([p()],K.prototype,`featureStream`,null),e([p()],K.prototype,`featureMenuOpen`,void 0),e([p()],K.prototype,`featureMenuTitle`,void 0),e([p()],K.prototype,`featureViewModelAbilities`,void 0),e([p({readOnly:!0})],K.prototype,`featureViewModels`,void 0),e([p()],K.prototype,`highlightEnabled`,void 0),e([p()],K.prototype,`includeDefaultActions`,void 0),e([p()],K.prototype,`initialDisplayMode`,void 0),e([p({type:h})],K.prototype,`location`,null),e([p()],K.prototype,`map`,null),e([p({readOnly:!0})],K.prototype,`streamingFeatures`,void 0),e([p({readOnly:!0})],K.prototype,`pendingPromisesCount`,null),e([p({readOnly:!0})],K.prototype,`promiseCount`,null),e([p()],K.prototype,`promises`,null),e([p({readOnly:!0})],K.prototype,`selectedClusterBoundaryFeature`,void 0),e([p({value:null,readOnly:!0})],K.prototype,`selectedFeature`,null),e([p({value:-1})],K.prototype,`selectedFeatureIndex`,null),e([p({readOnly:!0})],K.prototype,`selectedFeatureViewModel`,null),e([p({type:v})],K.prototype,`spatialReference`,null),e([p({readOnly:!0})],K.prototype,`state`,null),e([p()],K.prototype,`timeZone`,null),e([p()],K.prototype,`title`,void 0),e([p()],K.prototype,`updateLocationEnabled`,void 0),e([p()],K.prototype,`view`,void 0),e([p()],K.prototype,`visible`,void 0),e([p({readOnly:!0})],K.prototype,`waitingForContents`,null),e([p({readOnly:!0})],K.prototype,`waitingForResult`,null),e([p()],K.prototype,`zoomFactor`,void 0),e([p()],K.prototype,`zoomToLocation`,void 0),e([p()],K.prototype,`centerAtLocation`,null),K=e([m(`esri.widgets.Features.FeaturesViewModel`)],K);export{K as default};
|