@arcgis/core 6.0.0-next.13 → 6.0.0-next.15
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/arcade/containerUtils.js +1 -1
- package/arcade/featureset/sources/FeatureLayerDynamic.js +1 -1
- package/arcade/functions/feature.js +1 -1
- package/arcade/functions/featuresetstring.js +1 -1
- package/arcade/functions/geomasync.js +1 -1
- package/arcade/functions/portal.js +1 -1
- package/arcade/functions/string.js +1 -1
- package/assets/esri/core/workers/RemoteClient.js +1 -1
- package/assets/esri/core/workers/chunks/{5566f14afb63065e438f.js → 0050916e462e3c9e0627.js} +1 -1
- package/assets/esri/core/workers/chunks/02c5d027bdaee67869cf.js +1 -0
- package/assets/esri/core/workers/chunks/08fe248e412bb170210d.js +1 -0
- package/assets/esri/core/workers/chunks/0da6abe3ceabfe78f7a0.js +1 -0
- package/assets/esri/core/workers/chunks/0f617980c7dd9ad0444f.js +1 -0
- package/assets/esri/core/workers/chunks/{fb444954be74c1962ced.js → 10d80e793019dfb45ca2.js} +1 -1
- package/assets/esri/core/workers/chunks/{10445313d0d57b34511b.js → 2145a512d269d64036b0.js} +1 -1
- package/assets/esri/core/workers/chunks/21ddb26526bcb2b122c3.js +1 -0
- package/assets/esri/core/workers/chunks/25f19fc929f25ddd628c.js +1 -0
- package/assets/esri/core/workers/chunks/28b74bc77f7c13080074.js +1 -0
- package/assets/esri/core/workers/chunks/{2ef5237e4c876d6a4ee0.js → 2bd4ee083ca4ad221f8b.js} +1 -1
- package/assets/esri/core/workers/chunks/{f4f9d08b2df856e3b694.js → 2eae542fe7f0f6576ac1.js} +1 -1
- package/assets/esri/core/workers/chunks/{2aeb5cc32284dd3e4d22.js → 33e4ff228a8c81b99022.js} +1 -1
- package/assets/esri/core/workers/chunks/{42323093827adffe56d3.js → 3418877328f4f0830300.js} +1 -1
- package/assets/esri/core/workers/chunks/{8dc1c3042267618fd710.js → 34cbaf844730ac2d92c2.js} +2 -2
- package/assets/esri/core/workers/chunks/{96c50a0dda0f1503ef92.js → 3c301a689c7853c9fa67.js} +2 -2
- package/assets/esri/core/workers/chunks/{02253bdffbd580af22d8.js → 3ff6d1ed3c0f1285f3e7.js} +1 -1
- package/assets/esri/core/workers/chunks/{67e4b5651fd7ff7d8cf0.js → 4ac1d3e49e242e373a92.js} +1 -1
- package/assets/esri/core/workers/chunks/4df6cb1bee5d0720a43e.js +1 -0
- package/assets/esri/core/workers/chunks/{a4cab24af69260438ff4.js → 4e6f40cbdb8c508e6df1.js} +1 -1
- package/assets/esri/core/workers/chunks/5736feefa261589b6273.js +1 -0
- package/assets/esri/core/workers/chunks/601e1d020b8115497944.js +1 -0
- package/assets/esri/core/workers/chunks/{2686fe5b62dd0be699c0.js → 634523cc7757da9020e4.js} +1 -1
- package/assets/esri/core/workers/chunks/{a518ae5683367eeda74c.js → 70d3055f15d8b0cf4074.js} +1 -1
- package/assets/esri/core/workers/chunks/{1b946714ca4a1a7359d4.js → 76ab353d80d786777161.js} +2 -2
- package/assets/esri/core/workers/chunks/7f8e327acad48c9e75ea.js +1 -0
- package/assets/esri/core/workers/chunks/8052da8be251c3ff2176.js +1 -0
- package/assets/esri/core/workers/chunks/8e19629899a5becf8e19.js +1 -0
- package/assets/esri/core/workers/chunks/{f6e62d2d279a328cbed7.js → 90bdf86f553e2742d67c.js} +1 -1
- package/assets/esri/core/workers/chunks/91ebb2ccab1889eb7e81.js +1 -0
- package/assets/esri/core/workers/chunks/94e427040edb469d58ad.js +1 -0
- package/assets/esri/core/workers/chunks/{3d9d7d3a40b51eb7ee3d.js → 953ba13299e7aa92c1a0.js} +1 -1
- package/assets/esri/core/workers/chunks/{f46d9a19f79d4a4bd354.js → 9e1a3b6a08c96dcefdde.js} +1 -1
- package/assets/esri/core/workers/chunks/9f0a973a0dd28953ce25.js +1 -0
- package/assets/esri/core/workers/chunks/a2ad3e620c98e2b2eb06.js +1 -0
- package/assets/esri/core/workers/chunks/a34b3d2e11a777e1ff3f.js +1 -0
- package/assets/esri/core/workers/chunks/{140f2eeb11e39ab15734.js → aa36c3a9bbaa086e3757.js} +1 -1
- package/assets/esri/core/workers/chunks/ae31fd416bbb41a81392.js +1 -0
- package/assets/esri/core/workers/chunks/b49df4ebd4be1181b0f9.js +2 -0
- package/assets/esri/core/workers/chunks/{68d8ae42ab71d01a70a5.js → b557824bc1fa163d72a3.js} +2 -2
- package/assets/esri/core/workers/chunks/bc915fb182d463d804e6.js +1 -0
- package/assets/esri/core/workers/chunks/{992f102992c2bed7b34e.js → d5d0fe8e198ff5a902ee.js} +1 -1
- package/assets/esri/core/workers/chunks/e2190361247f35b02b32.js +1 -0
- package/assets/esri/core/workers/chunks/e2f42aec02bff33b25dd.js +1 -0
- package/assets/esri/core/workers/chunks/ebc1a2ef3aed8aa29424.js +1 -0
- package/assets/esri/core/workers/chunks/ed6e9d7f71bfd2691717.js +1 -0
- package/assets/esri/core/workers/chunks/ed8786fed345718ed684.js +1 -0
- package/assets/esri/core/workers/chunks/ee6679ef9efa1504e7eb.js +1 -0
- package/assets/esri/libs/lyr3d/lyr3DMain.wasm +0 -0
- package/assets/esri/libs/lyr3d/lyr3DWorker.wasm +0 -0
- package/assets/esri/libs/pdfjs/wasm/openjpeg_nowasm_fallback.js +1 -0
- package/chunks/BlendWeights.glsl.js +10 -10
- package/chunks/Blur.glsl.js +2 -2
- package/chunks/EdgeDetect.glsl.js +24 -19
- package/chunks/HUDMaterial.glsl.js +11 -1
- package/chunks/HighlightApply.glsl.js +4 -5
- package/chunks/HighlightBlur.glsl.js +5 -5
- package/chunks/HighlightDownsample.glsl.js +2 -2
- package/chunks/HighlightSharpApply.glsl.js +61 -0
- package/chunks/lyr3DMain.js +1 -1
- package/chunks/lyr3DWorker.js +2 -2
- package/chunks/portal.js +1 -1
- package/config.js +1 -1
- package/core/ObjectPool.js +1 -1
- package/core/PooledArray.js +1 -1
- package/core/accessorSupport/tracking/SimpleTrackingTarget.js +1 -1
- package/geometry/support/buffer/BufferPool.js +1 -1
- package/geometry/support/coordsUtils.js +1 -1
- package/geometry/support/curves/ellipticArc7Utils.js +1 -1
- package/geometry/support/curves/mathUtils.js +1 -1
- package/geometry/support/meshUtils.d.ts +5 -6
- package/interfaces.d.ts +18 -9
- package/kernel.js +1 -1
- package/layers/GeospatialPDFLayer.d.ts +154 -4
- package/layers/Layer.d.ts +2 -0
- package/layers/geospatialPDF/GeospatialPDFLayerWorker.js +1 -1
- package/layers/geospatialPDF/ViewportMeasureFrame.js +1 -1
- package/layers/geospatialPDF/geospatialPDFParserUtils.js +1 -1
- package/layers/geospatialPDF/projectionToWKTUtils.js +2 -2
- package/layers/graphics/controllers/FeatureTileController3D.js +1 -1
- package/layers/graphics/sources/GeoJSONSource.js +1 -1
- package/layers/graphics/sources/geojson/GeoJSONSourceWorker.js +1 -1
- package/layers/graphics/sources/support/MemorySourceWorker.js +1 -1
- package/layers/graphics/sources/support/clientSideDefaults.js +1 -1
- package/layers/graphics/sources/support/sourceUtils.js +1 -1
- package/layers/raster/datasets/TIFFRaster.js +1 -1
- package/layers/raster/datasets/pixelReader.js +1 -1
- package/layers/raster/functions/clipUtils.js +1 -1
- package/layers/support/LabelClass.d.ts +3 -2
- package/layers/support/PortalItemData.d.ts +31 -8
- package/layers/support/fieldUtils.js +1 -1
- package/layers/support/types.d.ts +4 -1
- package/package.json +2 -2
- package/portal/schemas/definitions.js +1 -1
- package/rest/knowledgeGraph/ObjectValue.js +1 -1
- package/symbols/cim/cimAnalyzer.js +1 -1
- package/views/2d/engine/webgl/GlyphWorker.js +1 -1
- package/views/2d/layers/features/schema/processor/symbols/ComplexSymbolSchema.js +1 -1
- package/views/3d/analysis/DirectLineMeasurementAnalysisView3D.js +1 -1
- package/views/3d/analysis/LineOfSight/LineOfSightItemTool.js +1 -1
- package/views/3d/analysis/LineOfSight/LineOfSightObserverPlugin.js +1 -1
- package/views/3d/analysis/LineOfSight/LineOfSightPlacementController.js +1 -1
- package/views/3d/analysis/LineOfSight/{LineOfSightRootPlugin.js → LineOfSightPlacementRootPlugin.js} +1 -1
- package/views/3d/analysis/LineOfSight/LineOfSightTargetPlugin.js +1 -1
- package/views/3d/analysis/LineOfSight/LineOfSightTool.js +1 -1
- package/views/3d/analysis/Viewshed/ViewshedPlacementPointPlugin.js +1 -1
- package/views/3d/analysis/Viewshed/ViewshedSubTool.js +1 -1
- package/views/3d/analysis/Viewshed/ViewshedTool.js +1 -1
- package/views/3d/interactive/editingTools/ManipulatedObject3DGraphic.js +1 -1
- package/views/3d/support/MemoryController.js +1 -1
- package/views/3d/terrain/TerrainData.js +1 -1
- package/views/3d/terrain/terrainUtils.js +1 -1
- package/views/3d/webgl-engine/core/shaderLibrary/HighlightCellGridScreenSpacePass.glsl.js +20 -6
- package/views/3d/webgl-engine/effects/RenderPluginManager.js +1 -1
- package/views/3d/webgl-engine/effects/geometry/RenderOccluded.js +1 -1
- package/views/3d/webgl-engine/effects/highlight/Highlight.js +1 -1
- package/views/3d/webgl-engine/effects/highlight/HighlightApply.glsl.js +1 -1
- package/views/3d/webgl-engine/effects/highlight/HighlightCellGridScreenSpacePassParameters.js +2 -0
- package/views/3d/webgl-engine/effects/highlight/HighlightDownsample.glsl.js +1 -1
- package/views/3d/webgl-engine/effects/highlight/HighlightPassParameters.js +1 -1
- package/views/3d/webgl-engine/effects/highlight/HighlightSharpApply.glsl.js +2 -0
- package/views/3d/webgl-engine/effects/highlight/HighlightSharpApplyTechnique.js +2 -0
- package/views/3d/webgl-engine/effects/smaa/BlendWeights.glsl.js +1 -1
- package/views/3d/webgl-engine/effects/smaa/Blur.glsl.js +1 -1
- package/views/3d/webgl-engine/effects/smaa/EdgeDetect.glsl.js +1 -1
- package/views/3d/webgl-engine/effects/smaa/SMAA.js +1 -1
- package/views/3d/webgl-engine/effects/smaa/SMAABlendWeightsTechnique.js +1 -1
- package/views/3d/webgl-engine/effects/smaa/SMAABlurTechnique.js +1 -1
- package/views/3d/webgl-engine/effects/smaa/SMAAEdgeDetectTechnique.js +1 -1
- package/views/3d/webgl-engine/effects/smaa/SMAAPassParameters.js +1 -1
- package/views/3d/webgl-engine/effects/smaa/SMAATechniqueConfiguration.js +2 -0
- package/views/3d/webgl-engine/lib/Compositor.js +1 -1
- package/views/3d/webgl-engine/lib/PathBuilder.js +1 -1
- package/views/3d/webgl-engine/lib/PathCapBuilder.js +1 -1
- package/views/3d/webgl-engine/lib/PathEvaluator.js +1 -1
- package/views/3d/webgl-engine/lib/PathExtruder.js +1 -1
- package/views/3d/webgl-engine/lib/PathProfile.js +1 -1
- package/views/3d/webgl-engine/lib/RenderFeature.js +1 -1
- package/views/3d/webgl-engine/lib/pathGeometryUtils.js +1 -1
- package/views/3d/webgl-engine/parts/RenderView.js +1 -1
- package/views/draw/DrawTool.js +1 -1
- package/views/draw/plugins/MultipointPlugin.js +1 -1
- package/views/draw/support/PluginContext.js +1 -1
- package/views/draw/support/managers/TooltipManager.js +1 -1
- package/views/draw/support/types.d.ts +5 -2
- package/views/support/HighlightDefaults.js +1 -1
- package/webdoc/applicationProperties/SearchLayerField.d.ts +7 -1
- package/webdoc/applicationProperties/SearchLayerField.js +1 -1
- package/webdoc/applicationProperties/SearchTableField.d.ts +7 -1
- package/webdoc/applicationProperties/SearchTableField.js +1 -1
- package/webdoc/applicationProperties/searchMode.js +2 -0
- package/widgets/BatchAttributeForm/batchAttributeFormUtils.js +1 -1
- package/widgets/BatchAttributeForm/inputs/support/DynamicChoiceController.js +1 -1
- package/widgets/BatchAttributeForm/inputs/support/inputUtils.js +1 -1
- package/widgets/BatchAttributeForm.js +1 -1
- package/widgets/Editor/EditorViewModel.d.ts +10 -1
- package/widgets/Editor.d.ts +10 -1
- package/widgets/FeatureTable/FeatureTableViewModel.js +1 -1
- package/widgets/FeatureTable/support/FeatureStore.js +1 -1
- package/widgets/HistogramRangeSlider.d.ts +2 -2
- package/widgets/HistogramRangeSlider.js +1 -1
- package/widgets/Legend.d.ts +1 -0
- package/widgets/OrientedImageryViewer/services/DepthImageService.js +1 -1
- package/widgets/ScaleRangeSlider/ScaleRangeSliderViewModel.d.ts +5 -2
- package/widgets/ScaleRangeSlider/ScaleRangeSliderViewModel.js +1 -1
- package/widgets/ScaleRangeSlider.js +1 -1
- package/widgets/Search/LayerSearchSource.d.ts +23 -1
- package/widgets/Search/LayerSearchSource.js +1 -1
- package/widgets/Search/support/layerSearchUtils.js +1 -1
- package/widgets/Search/types.d.ts +7 -0
- package/widgets/ValuePicker/ValuePickerBaseComponent.d.ts +5 -1
- package/widgets/ValuePicker/ValuePickerCollection.d.ts +2 -0
- package/widgets/ValuePicker/ValuePickerCombobox.d.ts +7 -1
- package/widgets/ValuePicker/ValuePickerLabel.d.ts +7 -1
- package/widgets/ValuePicker/ValuePickerSlider.d.ts +2 -0
- package/widgets/ValuePicker/ValuePickerSliderVisibleElements.d.ts +5 -1
- package/widgets/ValuePicker/ValuePickerVisibleElements.d.ts +5 -1
- package/widgets/ValuePicker/types.d.ts +2 -0
- package/widgets/support/forms/formUtils.js +1 -1
- package/widgets/support/forms/types.d.ts +1 -1
- package/assets/esri/core/workers/chunks/037a8cc19debbaaa4e10.js +0 -1
- package/assets/esri/core/workers/chunks/0dc66b03ff55d0ea5a09.js +0 -1
- package/assets/esri/core/workers/chunks/175c268e64ccd01f8c25.js +0 -1
- package/assets/esri/core/workers/chunks/1c65ab9ed611c322ce27.js +0 -1
- package/assets/esri/core/workers/chunks/2a1ec30f9ad305763f81.js +0 -2
- package/assets/esri/core/workers/chunks/3df5500a85345577480a.js +0 -1
- package/assets/esri/core/workers/chunks/3f7d583b676b23b3fadb.js +0 -1
- package/assets/esri/core/workers/chunks/408e81c8f1eff8a7b379.js +0 -1
- package/assets/esri/core/workers/chunks/4503b20ca6a80fb63d72.js +0 -1
- package/assets/esri/core/workers/chunks/4a640548032355e57acd.js +0 -1
- package/assets/esri/core/workers/chunks/53be85d04cd2da4f391d.js +0 -1
- package/assets/esri/core/workers/chunks/566e129f3d3805d7370a.js +0 -1
- package/assets/esri/core/workers/chunks/567a65f4203f6e81f4b4.js +0 -1
- package/assets/esri/core/workers/chunks/5982c6a8459c1237b298.js +0 -1
- package/assets/esri/core/workers/chunks/5eae5c29149f2429fe96.js +0 -1
- package/assets/esri/core/workers/chunks/6dc86e7496157c5e4d2c.js +0 -1
- package/assets/esri/core/workers/chunks/74b5c00f93cfc0d59029.js +0 -1
- package/assets/esri/core/workers/chunks/7c2c8f786a30267a5f05.js +0 -1
- package/assets/esri/core/workers/chunks/88e54449261ef94e390d.js +0 -1
- package/assets/esri/core/workers/chunks/9e142551163acf752618.js +0 -1
- package/assets/esri/core/workers/chunks/af75747b06d79446a855.js +0 -1
- package/assets/esri/core/workers/chunks/dba280c370df13196711.js +0 -1
- package/assets/esri/core/workers/chunks/dc486a3595b6d57018bb.js +0 -1
- package/assets/esri/core/workers/chunks/e3c1c9e6c62ba5cbcdb8.js +0 -1
- package/assets/esri/core/workers/chunks/f1f90adae13b04898008.js +0 -1
- package/assets/esri/core/workers/chunks/f47c7065da3b5001245f.js +0 -1
- /package/assets/esri/core/workers/chunks/{1b946714ca4a1a7359d4.js.LICENSE.txt → 34cbaf844730ac2d92c2.js.LICENSE.txt} +0 -0
- /package/assets/esri/core/workers/chunks/{96c50a0dda0f1503ef92.js.LICENSE.txt → 3c301a689c7853c9fa67.js.LICENSE.txt} +0 -0
- /package/assets/esri/core/workers/chunks/{8dc1c3042267618fd710.js.LICENSE.txt → 76ab353d80d786777161.js.LICENSE.txt} +0 -0
- /package/assets/esri/core/workers/chunks/{2a1ec30f9ad305763f81.js.LICENSE.txt → b49df4ebd4be1181b0f9.js.LICENSE.txt} +0 -0
- /package/assets/esri/core/workers/chunks/{68d8ae42ab71d01a70a5.js.LICENSE.txt → b557824bc1fa163d72a3.js.LICENSE.txt} +0 -0
- /package/views/3d/analysis/LineOfSight/{lineOfSightPlacementUtils.js → placementUtils.js} +0 -0
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/6.0/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)=>{e==null?this.hideAttachmentsView():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;!n||!t.length?this._logWarning(`Export failed.`):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(){this.relatedTableHasPendingEdits&&!this.relatedTableHasInvalidPendingEdits?await this.relatedTable?.savePendingEdits():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),this.store.load().catch(()=>{}),this._generateColumns()}_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;t.removeAll(),t.add(n),this.showRelatedTableCallback?this.showRelatedTableCallback(e):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)=>{e==null?this.hideAttachmentsView():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;!n||!t.length?this._logWarning(`Export failed.`):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(){this.relatedTableHasPendingEdits&&!this.relatedTableHasInvalidPendingEdits?await this.relatedTable?.savePendingEdits():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;t.removeAll(),t.add(n),this.showRelatedTableCallback?this.showRelatedTableCallback(e):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};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
|
|
2
|
-
import{__decorate as e}from"tslib";import t from"../../../Graphic.js";import n from"../../../core/Accessor.js";import{equals as r,isSome as i}from"../../../core/arrayUtils.js";import{createTask as a}from"../../../core/asyncUtils.js";import o from"../../../core/Collection.js";import s from"../../../core/Error.js";import{clone as c}from"../../../core/lang.js";import l from"../../../core/Logger.js";import{getOrCreateMapValue as u}from"../../../core/MapUtils.js";import{removeMaybe as d,abortMaybe as f}from"../../../core/maybe.js";import{debounce as p,ignoreAbortErrors as m,throwIfAborted as h}from"../../../core/promiseUtils.js";import g from"../../../core/ReactiveMap.js";import{watch as _,when as v,syncAndInitial as y,sync as b}from"../../../core/reactiveUtils.js";import{property as x,subclass as S}from"../../../core/accessorSupport/decorators.js";import{geometryTypes as C}from"../../../geometry/support/typeUtils.js";import{isFeatureLayer as w,isSubtypeGroupLayer as T,isSubtypeSublayer as E}from"../../../layers/support/layerUtils.js";import{combineTimeExtent as D}from"../../../layers/support/timeSupport.js";import O from"../../../rest/support/AttachmentQuery.js";import k from"../../../rest/support/RelationshipQuery.js";import A from"../../../time/TimeExtent.js";import j from"../../../views/SelectionManager.js";import{temporaryHighlightName as M}from"../../../views/support/HighlightDefaults.js";import{highlightsSupported as N}from"../../../views/support/layerViewUtils.js";import{isSelectableLayerWithObjectIds as P,isSelectableLayer as F}from"../../../views/support/selectionUtils.js";import{isIFeatureTableSupportedLayerWithAttachments as I,isIFeatureTableSupportedLayerWithAttachmentsEditing as L,isIFeatureTableSupportedLayerWithEditing as R,isIFeatureTableSupportedLayerWithRelationships as z,isPageIndexValid as B,findRelatedLayer as V}from"./tableUtils.js";import{ContingentValuesManager as H}from"../../support/ContingentValuesManager.js";let U=class extends n{constructor(e){super(e),this._attachmentsOperationQueue=new o,this._contingentValuesManager=new H,this._defaultOutFields=[`*`],this._editOperationQueue=new o,this.featureTitleMap=new g,this._loaded=!1,this._loadController=null,this._loadDebounced=p(()=>this._load()),this._loadError=!1,this._objectIdCache=new o,this._pendingEditsCache=new g,this._queryOperationInfos=new g,this._refreshDebounced=p(()=>this._refresh()),this._size=0,this._temporaryHighlight=null,this._temporaryHighlightAbortController=null,this.attachmentsEnabled=!1,this.autoSaveEnabled=!0,this.defaultSelectionManager=new j,this.editingEnabled=!1,this.failures=new o,this.filterByViewExtent=!1,this.filterByLayerScaleRange=!1,this.filterGeometry=null,this.highlightEnabled=!0,this.initialSize=null,this.layer=null,this.maxSize=null,this.objectIds=null,this.outFields=null,this.pageCache=new g,this.pageSize=50,this.paginationEnabled=!1,this.relationshipConfig=null,this.relatedRecordsEnabled=!1,this.returnGeometry=!1,this.returnZ=!1,this.returnM=!1,this.selectionManager=null,this.sortOrders=[],this.syncViewSelection=!1,this.temporaryHighlightId=void 0,this.timeExtent=null,this.timeZone=null,this.view=null,this.viewTimeEnabled=!1,this.where=null}initialize(){this.addHandles([_(()=>[this._visibleAtCurrentScale,this.effectiveTimeExtent,this.effectiveWhere,this.filterGeometry,this.layer,this.objectIds,this.outFields,this.pageSize,this.relationshipConfig,this.returnGeometry,this.returnM,this.returnZ],()=>this._reset()),_(()=>this.orderByFields,()=>this._clearCaches(),{equals:r}),v(()=>this.attachmentsEnabled,()=>this._reset()),v(()=>this.relatedRecordsEnabled,()=>this._reset()),_(()=>this._layerWithContingentValues,e=>{let t=this._contingentValuesManager;e&&!t.layers.includes(e)&&t.layers.add(e)}),_(()=>[this.view?.extent,this.view?.stationary,this.filterByViewExtent],([e,t,n])=>{n&&(e?t&&(this.filterGeometry=e):this.filterGeometry=null)},y),_(()=>this.maxSize,(e,t)=>{t===0&&this._reset()}),_(()=>[this.layer,this.view],()=>this.syncSelectionSources(),y),_(()=>this.highlightEnabled,e=>this.defaultSelectionManager.highlightEnabled=e,y),_(()=>this.temporaryHighlightId,e=>{this._temporaryHighlight=d(this._temporaryHighlight?.handle),this._temporaryHighlightAbortController?.abort(),this._temporaryHighlightAbortController=new AbortController;let t=this._syncTemporaryHighlight(e,this._temporaryHighlightAbortController.signal);m(this.view?.addUpdatingPromise(t)??t)},b)])}destroy(){this.layer=null,this.itemCache.destroy(),this.failures.destroy(),this.defaultSelectionManager.destroy(),this._temporaryHighlight=d(this._temporaryHighlight?.handle),this._temporaryHighlightAbortController=f(this._temporaryHighlightAbortController)}get _capabilities(){let{layer:e}=this;return e?.effectiveCapabilities??e?.capabilities}get _canSavePendingEdits(){return this.supportsEditing&&this.hasPendingEdits&&!this.hasInvalidPendingEdits}get _effectiveReturnZ(){return this.returnZ&&this.supportsZ}get _effectiveReturnM(){return this.returnM&&this.supportsM}get _layerWithAttachments(){let{layer:e}=this;return!e||!this._capabilities||!this.attachmentsEnabled||!this.supportsAttachments||!I(e)?null:e}get _layerWithAttachmentsEditing(){let{_layerWithAttachments:e}=this;return!e||!L(e)||!this.supportsEditing?null:e}get _layerWithContingentValues(){let{layer:e}=this;return w(e)||T(e)?e:null}get _layerWithEditing(){let e=this.layer;return R(e)&&this.supportsEditing?e:null}get _layerWithRelationships(){let e=this.layer;return z(e)&&this.supportsQueryRelated?e:null}get _pendingEditsAreInvalid(){let e=this._pendingEditsCache,t=this._layerWithContingentValues;if(!t)return!1;for(let n of e.keys()){let r=e.get(n),i=this._getFeatureWithPendingEdits(n,r);for(let e of r.changes.keys())if(this._contingentValuesManager.getViolationForField(t,i,e))return!0}return!1}get _relatedLayer(){return this.relationshipConfig?.relatedLayer}get _relatedLayerCapabilities(){let{_relatedLayer:e}=this;return e?.effectiveCapabilities??e?.capabilities}get _relatedLayerSupportsCacheHint(){return!!this._relatedLayerCapabilities?.queryRelated?.supportsCacheHint}get _relatedLayerSupportsQuery(){return!!this._relatedLayerCapabilities?.operations.supportsQuery}get _relatedLayerSupportsQueryRelated(){let{_relatedLayerCapabilities:e}=this;return!!e?.queryRelated?.supportsCount&&!!e?.queryRelated?.supportsPagination}get _sortedFieldNames(){return this.sortOrders.map(({fieldName:e})=>e)}get _subtypeCode(){return this.layer?.subtypeCode??null}get _subtypeField(){let{layer:e}=this;return T(e?.parent)?e.subtypeField:null}get _canUseRelatedLayer(){return!!(this._relatedLayerSupportsQuery&&this._relatedLayerSupportsQueryRelated)}get _shouldFilterByLayerScaleRange(){return!!(this.view&&this.filterByLayerScaleRange)}get _visibleAtCurrentScale(){return!!(this._shouldFilterByLayerScaleRange&&this.layerView?.visibleAtCurrentScale)}get cachedPageCount(){return this.pageCache.size}get canAddRelatedFeature(){let{state:e,relationship:t,supportsAdd:n,supportsEditing:r}=this;if(e!==`loaded`||!t||!n||!r)return!1;let{cardinality:i,role:a}=t,o=this.size>0;return!(i===`one-to-one`&&o||i===`one-to-many`&&a===`origin`&&o)}get effectiveOutFields(){let{layer:e,outFields:t}=this;if(!e||!t?.length)return this._defaultOutFields;let n=[];t.forEach(t=>{let r=e.fieldsIndex.normalizeFieldName(t);r&&n.push(r)});let{objectIdField:r}=e,i=e.fieldsIndex.normalizeFieldName(r)??r;return i&&!n.includes(i)&&n.unshift(i),n}get effectiveSelectionManager(){let{layer:e,view:t}=this;return e&&this.syncViewSelection&&P(e)&&t?.selectionManager?.sources.includes(e)?t.selectionManager:this.selectionManager??this.defaultSelectionManager}get effectiveSize(){let{_size:e,maxSize:t}=this;return t==null?e:Math.min(t,e)}get effectiveTimeExtent(){let{layer:e,timeExtent:t,view:n,viewTimeEnabled:r}=this;return t||!e?t??void 0:!n||!r?e.timeExtent??void 0:D({datesInUnknownTimezone:e.datesInUnknownTimezone??void 0,timeExtent:e.timeExtent,timeInfo:e.timeInfo,timeOffset:e.timeOffset,useViewTime:e.useViewTime},n.timeExtent,this._get(`effectiveTimeExtent`))??void 0}get effectiveWhere(){let{layer:e,where:t}=this;return t!=null&&t!==``?t:E(e)&&e.parent?.definitionExpression?e.parent.definitionExpression:e?.definitionExpression||`1=1`}get fieldsWithContingentValues(){return this._contingentValuesManager.getFieldsWithContingentValues(this.layer)}get hasContingentValues(){return this.fieldsWithContingentValues.size>0}get hasInvalidPendingEdits(){return this.hasPendingEdits&&this._pendingEditsAreInvalid}get hasPendingEdits(){return this.pendingEditsCount>0}get highlightableLayerView(){let e=this.layerView;return N(e)?e:null}get isQuerying(){return this._queryOperationInfos.size>0}get isSyncing(){return this.isSyncingFeatureEdits||this.isSyncingAttachmentEdits}get isSyncingAttachmentEdits(){return this._attachmentsOperationQueue.length>0}get isSyncingFeatureEdits(){return this._editOperationQueue.length>0}get itemCache(){return new o({items:[...this.pageCache.values()].flat()})}get layerView(){let{layer:e,view:t}=this;if(!e||!t)return null;let n=e.type===`sublayer`||E(e)?e.parent:e;return t.allLayerViews.find(e=>e.layer===n)}get orderByFields(){let{_sortedFieldNames:e,layer:t,sortOrders:n}=this,r=n.filter(({fieldName:t,direction:n},r)=>e.indexOf(t)===r&&n!=null).map(({fieldName:e,direction:t})=>`${e} ${t?.toUpperCase()}`);if(t&&!r.length&&!t.objectIdField&&t.fields?.length){let e=t.fields.find(e=>e.name);if(e){let n=t.fieldsIndex.normalizeFieldName(e.name);n&&r.push(`${n} ASC`)}}return r}get pageCount(){let{effectiveSize:e,pageSize:t}=this;return e===0||t===0?1:Math.ceil(e/t)}get pageIndex(){return this._get(`pageIndex`)||0}set pageIndex(e){let{pageCount:t}=this;B(e,t)&&this._set(`pageIndex`,e)}get pendingEditsCount(){let e=0;return this._pendingEditsCache.forEach(t=>e+=t.changes.size),e}get relationship(){let{relationshipConfig:e}=this;return e?.relationshipId==null?null:this.relationships?.find(t=>t.id===e.relationshipId)}get relationshipIds(){return this.relationships?.map(e=>e.id)??[]}get relationshipInfos(){let{_layerWithRelationships:e,relatedRecordsEnabled:t,relationships:n,view:r}=this,i=[];return!t||!e?.loaded||!r?.map||!n?.length||n.forEach(t=>{let n=V(e,r,t);n&&(n.load().catch(()=>{}),i.push({layer:e,relatedLayer:n,relationshipId:t.id}))}),i}get relationships(){return this._layerWithRelationships?.relationships}get size(){return this._size}get state(){let{layer:e,_loaded:t,_loadError:n}=this;return!e||e.destroyed?`disabled`:n||e.loadError?`error`:this._loadController?`loading`:e.loadStatus===`loaded`&&t?`loaded`:`ready`}get supportsAdd(){return!!this._capabilities?.operations.supportsAdd}get supportsAddAttachments(){return!!(this._layerWithAttachmentsEditing&&(this.supportsAdd||this.supportsUpdate))}get supportsAttachments(){let{_capabilities:e}=this;return!!(e?.data?.supportsAttachment&&e?.operations.supportsQueryAttachments)}get supportsCacheHint(){return!!this._capabilities?.query?.supportsCacheHint}get supportsCacheHintQueryRelated(){return!!this._capabilities?.queryRelated?.supportsCacheHint}get supportsDelete(){return!!this._capabilities?.operations.supportsDelete}get supportsEditing(){return!!this._capabilities?.operations.supportsEditing}get supportsM(){return!!this.layer?.hasM&&!!this._capabilities?.data?.supportsM}get supportsOrderBy(){return!!this._capabilities?.query?.supportsOrderBy}get supportsPagination(){return!!this._capabilities?.query?.supportsPagination}get supportsQuery(){return!!this._capabilities?.operations.supportsQuery}get supportsQueryRelated(){let{_capabilities:e}=this;return!!e?.queryRelated?.supportsCount&&!!e?.queryRelated?.supportsPagination}get supportsResizeAttachments(){let{_capabilities:e}=this;return!!(this.supportsAttachments&&e?.attachment?.supportsResize)}get supportsUpdate(){return!!this._capabilities?.operations.supportsUpdate}get supportsUpdateAttachments(){return!!(this._layerWithAttachmentsEditing&&(this.supportsAdd||this.supportsUpdate))}get supportsZ(){return!!this.layer?.hasZ&&!!this._capabilities?.data?.supportsZ}async addAttachment(e,t){let{_layerWithAttachmentsEditing:n}=this;if(!n||!this.supportsAddAttachments)return{};let r=await this._queueAttachmentsOperation(e,()=>n.addAttachment(this._createBaseGraphic(n,e),t));return this._ensureArrayContent(r)}addPendingEdits(e){let t=this._ensureLayerAndUpdateSupport();this.editingEnabled?(this.autoSaveEnabled&&this._logWarning(`store:pending-edit`,`Edit will be cached, but 'autoSaveEnabled' is true.`,!0),this._stashPendingEdits(t,e)):this._logWarning(`store:editing-disabled`,`Editing is disabled.`)}async deleteAttachments(e,t){let{_layerWithAttachmentsEditing:n}=this;if(!n||!this.supportsUpdateAttachments||!t.length)return[];let r=await this._queueAttachmentsOperation(e,()=>n.deleteAttachments(this._createBaseGraphic(n,e),t));return this._ensureArray(r)}async deleteRowsByObjectId(e){let{_layerWithEditing:t}=this;if(!this.supportsDelete||!t)throw new s(`store:delete-error`,`Delete is not supported.`);let n=e.map(e=>this.getItemByObjectId(e)?.feature).filter(i),r=this._queueEditOperation(()=>t.applyEdits({deleteFeatures:n}));return e.forEach(e=>{this.featureTitleMap.delete(e),this._discardPendingEdit({objectId:e})}),r}discardPendingEdits(e){if(e?.length)e.forEach(e=>this._discardPendingEdit(e));else{for(let[e,t]of this._pendingEditsCache){let n=this.getItemByObjectId(e);n&&(n.feature=t.originalFeature)}this._pendingEditsCache.clear(),this._clearOptionsAndViolations()}}itemHasInvalidPendingEdits(e,t){if(!this.hasInvalidPendingEdits)return!1;let n=this._layerWithContingentValues,r=this._pendingEditsCache.get(e);if(!n||!r)return!1;let i=this._getFeatureWithPendingEdits(e,r),a=this._contingentValuesManager;return t?!!a.getViolationForField(n,i,t):!!a.getAllViolations(n,i)}itemHasPendingEdits(e,t){let n=this._pendingEditsCache.get(e);return n?!t||n.changes.has(t):!1}async getAttachmentsByObjectId(e,t){let n=this.getItemByObjectId(e)?.attachments??[];return!n.length&&t?(await this._queryAttachments([e]))[e]??[]:n}getCachedFeaturesByPageIndex(e){return this.pageCache.get(e)}getFieldValueOptions(e){return this._contingentValuesManager.getFieldValueOptions(e)}async getFeatureTitle(e,n=!1){let{layer:r}=this,i=this.featureTitleMap.get(e),a=`${e}`;if(!r)return i||a;if(i&&!n)return i;if(!(`getFeatureTitle`in r)||!r.getFeatureTitle)return a;let o=this.getItemByObjectId(e)?.feature;o||=new t({attributes:{[r.objectIdField]:e},origin:r.graphicOrigin});let s=await r.getFeatureTitle(o,{fetchMissingFields:!0,removeHTML:!0});return s?(this.featureTitleMap.set(e,s),s):a}getItemByObjectId(e){for(let t of this.pageCache.values())for(let n of t)if(n.objectId===e)return n}getItemIndexByObjectId(e){let{pageCache:t,pageSize:n}=this,r=t.entries(),i=-1;for(let[t,a]of r)if(a.some((r,a)=>{let o=r.objectId===e;return o&&(i=t*n+a),o}),i>-1)break;return i}async load(){await m(this._loadDebounced())}async queryPage(e){let{layer:t,state:n}=this;if(!t||n!==`loaded`||!this.supportsQuery||this.size===0||this.maxSize===0)return[];let{pageIndex:r}=e;if(!B(r,this.pageCount))return[];let i=e.pageSize??this.pageSize,a=r*i,o=a+i;return await m(this._query({layer:t,start:a,num:o,pageIndex:r,pageSize:i}))??[]}async refresh(){await m(this._refreshDebounced())}reset(){this._reset()}async savePendingEdits(){let e=this._ensureLayerAndUpdateSupport();if(!this.editingEnabled){this._logWarning(`store:editing-disabled`,`Editing is disabled.`);return}if(this.autoSaveEnabled&&this._logWarning(`store:pending-edit`,`Edit will be cached, but 'autoSaveEnabled' is true.`,!0),!this._canSavePendingEdits){this._logError(`store:update-error`,`An error occurred. Unable to save pending edits.`);return}let t=[];for(let[e]of this._pendingEditsCache){let n=this.getItemByObjectId(e);n?.feature&&t.push(n.feature)}(await this._update(e,t,!0)).updateFeatureResults.find(e=>e.error)&&this.discardPendingEdits(),this._clearOptionsAndViolations()}syncSelectionSources(){let{defaultSelectionManager:e,layer:t,view:n}=this;e.view=n,e.sources.removeAll(),F(t)&&(e.sources.items=[t])}async updateAttachment(e,t,n){let{_layerWithAttachmentsEditing:r}=this;if(!r||!this.supportsUpdateAttachments)return{};let i=await this._queueAttachmentsOperation(e,()=>r.updateAttachment(this._createBaseGraphic(r,e),t,n));return this._ensureArrayContent(i)}async updateItem(e){let t=this._ensureLayerAndUpdateSupport();if(!this.editingEnabled){this._logWarning(`store:editing-disabled`,`Editing is disabled.`);return}if(this.hasContingentValues){let t=e.updates.some(e=>this.fieldsWithContingentValues.has(e.fieldName)),n=this.itemHasPendingEdits(e.objectId);if(n||t){let t=this._layerWithContingentValues,r=this.getItemByObjectId(e.objectId)?.feature?.clone();if(r){let i=this._contingentValuesManager.getAllViolations(t,r);if(e.updates.forEach(({fieldName:e,value:n})=>{let i=t.getField(e);i&&(r.attributes[i.name]=n)}),this._contingentValuesManager.validateContingencyConstraints(t,r).length||i.length||n){this._stashPendingEdits(t,[e]),this._contingentValuesManager.resetOptionsForLayer(t);return}}}}if(!this.autoSaveEnabled){this._stashPendingEdits(t,[e]);return}let{_sortedFieldNames:n}=this,r=e.updates.map(({fieldName:e})=>e),i=this._prepareEditsForUpdate([e]);!(await this._update(t,i)).updateFeatureResults.find(e=>e.error)&&r.some(e=>n.includes(e))&&this._clearCaches()}async verifyFeaturesByObjectId(e){let{layer:t,state:n}=this;if(!t||n!==`loaded`)return[];let{objectIdField:r}=t,i=await this._queryFeaturesByObjectId(e);return e.map(e=>i.some(t=>e===(t.getObjectId()??t.attributes[r])))}async _load(){let{layer:e}=this;if(this._reset(),!e)return;let t=new AbortController;this._loadController=t;try{if(await e.load(),e.parent&&T(e.parent)&&await e.parent.loadAll(),await e.when(),t.signal.aborted)return;let n=this.initialSize;if(this.initialSize=null,this._shouldFilterByLayerScaleRange&&(this._visibleAtCurrentScale||(n=0)),await m(this._refresh(t,n)),t.signal.aborted){this._loadController=null;return}this._loaded=!0,this._loadController=null}catch(e){throw this._reset(),this._loadError=!0,this._logError(`store:load-error`,`An error occurred.`),e}}async _refresh(e,t){this._clearCaches();let n=e?.signal,r=await this._getSize(n,t),i=await this._queryAllObjectIds(n);n?.aborted||(this._size=r,this._objectIdCache.removeAll(),i?.length&&this._objectIdCache.addMany(i),this._syncPendingEdits())}async _queryAllObjectIds(e){return this.supportsPagination?void 0:await this._queryObjectIds(e)}_clearCaches(){this.pageCache.clear(),this._objectIdCache.removeAll()}_createBaseGraphic(e,n){let r=new t({attributes:{[e.objectIdField]:n}});return this._subtypeField&&this._subtypeCode!=null&&(r.attributes[this._subtypeField]=this._subtypeCode),r}_ensureArray(e){return Array.isArray(e)?e:[e]}_ensureArrayContent(e){return Array.isArray(e)?e[0]:e}_getObjectIdsForFeatures(e,t){return e.map(e=>e.getObjectId()??e.attributes[t.objectIdField])}_getObjectIdsForPage(e,t){let n=this._objectIdCache.toArray();return n.length>=e+t?n.slice(e,e+t):n.slice(e)}_logError(e,t){l.getLogger(this).error(e,t)}_logWarning(e,t,n=!1){n?l.getLogger(this).warnOnce(e,t):l.getLogger(this).warn(e,t)}_reset(){this._clearCaches(),this._pendingEditsCache.clear(),this.failures.removeAll(),this._attachmentsOperationQueue.removeAll(),this._editOperationQueue.removeAll(),this.featureTitleMap.clear(),this._loadController=f(this._loadController),this._queryOperationInfos.forEach(e=>e.controller.abort()),this._queryOperationInfos.clear(),this._temporaryHighlight=d(this._temporaryHighlight?.handle),this._temporaryHighlightAbortController=f(this._temporaryHighlightAbortController),this._loaded=!1,this._loadError=!1,this._size=0}async _getSize(e,t){return this.maxSize===0?0:t??await this._queryCount(e)}async _queryFeaturesByObjectId(e){let{layer:t}=this;if(!t||!this.supportsQuery)throw new s(`store:query-error`,`Layer does not support query operation.`);let{effectiveTimeExtent:n,effectiveWhere:r,orderByFields:i,supportsCacheHint:a,supportsOrderBy:o}=this,c=t.createQuery();return c.where=r,c.timeExtent=n,c.returnGeometry=!1,c.objectIds=e.length?e:void 0,c.outFields=[t.objectIdField],o&&(c.orderByFields=i),a&&(c.cacheHint=!0),(await t.queryFeatures(c)).features}async _syncTemporaryHighlight(e,t){let{highlightEnabled:n,highlightableLayerView:r}=this;r&&n&&e!=null&&(h(t),this._temporaryHighlight={id:e,handle:r.highlight(e,{name:M})})}_ensureLayerAndUpdateSupport(){let e=this._layerWithEditing;if(!e||!this.supportsUpdate)throw new s(`store:update-error`,`Update is not supported.`);return e}_stashPendingEdits(e,t){t.forEach(({objectId:t,updates:n})=>{let r=this.getItemByObjectId(t)?.feature;if(!r)throw new s(`store:update-error`,`Feature with provided 'objectId' not found.`);let i=r.clone(),a=u(this._pendingEditsCache,t,()=>({originalFeature:i,changes:new g}));n.forEach(({fieldName:t,value:n})=>{let i=e.getField(t);i?(a.changes.set(i.name,n),r.attributes[i.name]=n):this._logWarning(`store:pending-edit-unknown-field`,`The provided field does not belong to this layer.`)}),a.changes.size>0&&this._pendingEditsCache.set(t,a)})}_syncPendingEdits(){for(let[e,t]of this._pendingEditsCache){let n=this.getItemByObjectId(e)?.feature;if(n){let e=n.clone();for(let[e,r]of t.changes)n.attributes[e]=r;t.originalFeature=e}}}_getFeatureWithPendingEdits(e,t){let n=this.getItemByObjectId(e)?.feature;if(!n){n=t.originalFeature.clone();for(let[e,r]of t.changes)n.attributes[e]=r}return n}_discardPendingEdit({objectId:e,fieldName:t}){let n=this._pendingEditsCache.get(e);if(!n){this._logWarning(`store:pending-edit-not-found`,`Could not find a pending edit with the given information`);return}let r=this.getItemByObjectId(e);t?(r&&(r.feature.attributes[t]=n.originalFeature.attributes[t]),n.changes.delete(t),n.changes.size===0&&this._pendingEditsCache.delete(e)):(r&&(r.feature=n.originalFeature),this._pendingEditsCache.delete(e))}_clearOptionsAndViolations(){let{_layerWithContingentValues:e,_contingentValuesManager:t}=this;e&&(t.resetOptionsForLayer(e),t.resetViolationsForLayer(e))}_prepareEditsForUpdate(e){let n=[];return e.forEach(({objectId:e,updates:r})=>{let i=this.getItemByObjectId(e)?.feature;if(!i)return;let a=c(i.attributes);r.forEach(({fieldName:e,value:t})=>a[e]=t),n.push(new t({attributes:a,sourceLayer:i.sourceLayer}))}),n}_update(e,t,n=!1){let r=e.applyEdits({updateFeatures:t}).then(n=>{let{updateFeatureResults:r}=n,i=r.find(e=>!!e.error);if(i)throw i.error;return t.forEach(t=>{let n=t.getObjectId()??t.attributes[e.objectIdField],r=this.getItemByObjectId(n)?.feature;r&&(r.attributes=t.attributes),this.featureTitleMap.has(n)&&this.getFeatureTitle(n,!0)}),n});return this._queueEditOperation(()=>r,n)}_createFeatureStoreItems(e){let{attachments:t,features:n,layer:r,relatedRecords:i}=e,a=r.objectIdField;return n.map(e=>{let n=e.getObjectId()??e.attributes[a],o=[];!e.layer&&!e.sourceLayer&&(e.layer=r,e.sourceLayer=r);let s=this._pendingEditsCache.get(n);if(s){let t=e.clone(),n=s.changes;for(let[t,r]of n)e.attributes[t]=r;s.originalFeature=t}return i.forEach((e,t)=>{o.push({relationshipId:t,count:e[n]??0})}),{objectId:n,feature:e,attachments:t[n]??null,relatedRecords:o}})}async _query(e){let{pageIndex:t,refresh:n}=e;n===!0&&await this._refresh();let r=this.pageCache.get(t);if(r)return r;let i=this._queryOperationInfos.get(t);if(i)return i.task.promise;let a=new AbortController,o=await this._queryPage(e,a);return a.signal.aborted||this.pageCache.set(t,o),o}_queryAttachments(e,t){let{_layerWithAttachments:n,effectiveWhere:r}=this;return n?e.some(e=>typeof e!=`number`)?Promise.reject(new s(`invalid-object-id`,`Only numeric object ids are valid to query attachments`)):n.queryAttachments(new O({objectIds:e,where:r,returnMetadata:!0}),{signal:t}):Promise.resolve({})}async _queryCount(e){let{_relatedLayerSupportsCacheHint:t,layer:n,relationshipConfig:r,supportsCacheHint:i}=this;if(!n)return 0;if(r&&this._canUseRelatedLayer){let{objectId:n,relatedLayer:i,relationshipId:a}=r;return(await i.queryRelatedFeaturesCount(new k({cacheHint:t,relationshipId:a,objectIds:[n]}),{signal:e}))[n]??0}let{effectiveTimeExtent:a,effectiveWhere:o,filterGeometry:s,objectIds:c}=this,l=n.createQuery();return l.geometry=s,l.returnGeometry=!1,l.where=o,l.timeExtent=a,l.objectIds=c?.length?c:void 0,i&&(l.cacheHint=!0),n.queryFeatureCount(l,{signal:e})}async _queryFeatures(e,t){let{relationshipConfig:n}=this;if(n&&this._canUseRelatedLayer)return this._queryRelatedFeatures(e,n);let{_effectiveReturnM:r,_effectiveReturnZ:i,effectiveOutFields:a,effectiveTimeExtent:o,effectiveWhere:s,filterGeometry:c,objectIds:l,orderByFields:u,pageSize:d,returnGeometry:f,supportsCacheHint:p,supportsOrderBy:m,supportsPagination:h}=this,{layer:g,start:_}=e,v=l?.length,y=g.createQuery();return y.returnGeometry=f,y.outFields=a,y.returnM=r,y.returnZ=i,h?(y.start=_,y.num=d,y.where=s,y.timeExtent=o,y.objectIds=v?l:void 0):y.objectIds=v?l:this._getObjectIdsForPage(_,d??0),m&&(y.orderByFields=u),c&&(y.geometry=c),p&&(y.cacheHint=!0),(await g.queryFeatures(y,{signal:t})).features}_queryObjectIds(e){let{effectiveTimeExtent:t,effectiveWhere:n,filterGeometry:r,layer:i,objectIds:a,orderByFields:o,supportsCacheHint:s,supportsOrderBy:c}=this;if(!i)return Promise.resolve([]);let l=i.createQuery();return l.geometry=r,l.outFields=[i.objectIdField],l.returnGeometry=!1,l.where=n,l.timeExtent=t,l.objectIds=a?.length?a:void 0,c&&(l.orderByFields=o),s&&(l.cacheHint=!0),i.queryObjectIds(l,{signal:e})}async _queryPage(e,t){return this._queueQueryOperation(e.pageIndex,{controller:t,task:a(async()=>this._queryPageData(e,t))})}async _queryPageData(e,t){let{layer:n}=e,{signal:r}=t,i=await this._queryFeatures(e,r);if(r.aborted)return[];let a=this._getObjectIdsForFeatures(i,n),[o,s]=await Promise.all([this._queryAttachments(a,r),this._queryRelatedCounts(a,r)]);return t.signal.aborted?[]:this._createFeatureStoreItems({layer:n,features:i,attachments:o,relatedRecords:s})||[]}async _queryRelatedCounts(e,t){let{_layerWithRelationships:n,relationshipIds:r,supportsCacheHintQueryRelated:i}=this,a=new Map;return!n||!e?.length||!r.length||await Promise.allSettled(r.map(async r=>{let o=await n.queryRelatedFeaturesCount(new k({cacheHint:i,relationshipId:r,objectIds:e}),{signal:t});a.set(r,o)})),a}async _queryRelatedFeatures(e,t){let{_defaultOutFields:n,_effectiveReturnM:r,_effectiveReturnZ:i,orderByFields:a,pageSize:o,returnGeometry:s,supportsCacheHint:c}=this,{layer:l,start:u}=e,{objectId:d,relatedLayer:f,relationshipId:p}=t,m=l.createQuery(),h=new k({cacheHint:c,num:o,objectIds:[d],orderByFields:a,outFields:n,relationshipId:p,returnGeometry:s,returnM:r,returnZ:i,start:u,where:m.where??void 0});return(await f.queryRelatedFeatures(h))[d]?.features||[]}_queueAttachmentsOperation(e,t){return this._attachmentsOperationQueue.push(t),t().then(async n=>{this._attachmentsOperationQueue.remove(t);let r=this._ensureArray(n),i=r.some(e=>e.error),a=this.getItemByObjectId(e);return a&&(!i||r.length>1)&&(a.attachments=(await this._queryAttachments([e]))[e]),n}).catch(async n=>{this._logError(`store:attachment-error`,`An error occurred.`);let r={error:n,retry:()=>{this.failures.remove(r),this._queueAttachmentsOperation(e,t)},cancel:()=>this.failures.remove(r)};throw this.failures.add(r),this._attachmentsOperationQueue.remove(t),n})}_queueEditOperation(e,t=!1){return this._editOperationQueue.push(e),e().then(n=>(this._editOperationQueue.remove(e),t&&this._pendingEditsCache.clear(),n)).catch(t=>{this._logError(`store:edit-error`,`An error occurred.`);let n={error:t,retry:()=>{this.failures.remove(n),this._queueEditOperation(e)},cancel:()=>this.failures.remove(n)};throw this.failures.add(n),this._editOperationQueue.remove(e),t})}async _queueQueryOperation(e,t){this._queryOperationInfos.set(e,t);let n=await t.task.promise;return this._queryOperationInfos.delete(e),n}};e([x()],U.prototype,`_attachmentsOperationQueue`,void 0),e([x({readOnly:!0})],U.prototype,`_capabilities`,null),e([x()],U.prototype,`_canSavePendingEdits`,null),e([x()],U.prototype,`_contingentValuesManager`,void 0),e([x()],U.prototype,`_defaultOutFields`,void 0),e([x()],U.prototype,`_editOperationQueue`,void 0),e([x()],U.prototype,`_effectiveReturnZ`,null),e([x()],U.prototype,`_effectiveReturnM`,null),e([x()],U.prototype,`featureTitleMap`,void 0),e([x({readOnly:!0})],U.prototype,`_layerWithAttachments`,null),e([x({readOnly:!0})],U.prototype,`_layerWithAttachmentsEditing`,null),e([x()],U.prototype,`_layerWithContingentValues`,null),e([x({readOnly:!0})],U.prototype,`_layerWithEditing`,null),e([x({readOnly:!0})],U.prototype,`_layerWithRelationships`,null),e([x()],U.prototype,`_loaded`,void 0),e([x()],U.prototype,`_loadController`,void 0),e([x()],U.prototype,`_loadError`,void 0),e([x()],U.prototype,`_objectIdCache`,void 0),e([x()],U.prototype,`_pendingEditsCache`,void 0),e([x()],U.prototype,`_pendingEditsAreInvalid`,null),e([x()],U.prototype,`_queryOperationInfos`,void 0),e([x({readOnly:!0})],U.prototype,`_relatedLayer`,null),e([x({readOnly:!0})],U.prototype,`_relatedLayerCapabilities`,null),e([x({readOnly:!0})],U.prototype,`_relatedLayerSupportsCacheHint`,null),e([x()],U.prototype,`_relatedLayerSupportsQuery`,null),e([x()],U.prototype,`_relatedLayerSupportsQueryRelated`,null),e([x()],U.prototype,`_size`,void 0),e([x()],U.prototype,`_sortedFieldNames`,null),e([x()],U.prototype,`_subtypeCode`,null),e([x()],U.prototype,`_subtypeField`,null),e([x()],U.prototype,`_canUseRelatedLayer`,null),e([x()],U.prototype,`_shouldFilterByLayerScaleRange`,null),e([x()],U.prototype,`_visibleAtCurrentScale`,null),e([x()],U.prototype,`attachmentsEnabled`,void 0),e([x()],U.prototype,`autoSaveEnabled`,void 0),e([x()],U.prototype,`cachedPageCount`,null),e([x()],U.prototype,`canAddRelatedFeature`,null),e([x()],U.prototype,`defaultSelectionManager`,void 0),e([x()],U.prototype,`editingEnabled`,void 0),e([x()],U.prototype,`effectiveOutFields`,null),e([x()],U.prototype,`effectiveSelectionManager`,null),e([x()],U.prototype,`effectiveSize`,null),e([x()],U.prototype,`effectiveTimeExtent`,null),e([x()],U.prototype,`effectiveWhere`,null),e([x({readOnly:!0})],U.prototype,`failures`,void 0),e([x()],U.prototype,`fieldsWithContingentValues`,null),e([x()],U.prototype,`filterByViewExtent`,void 0),e([x()],U.prototype,`filterByLayerScaleRange`,void 0),e([x({types:C})],U.prototype,`filterGeometry`,void 0),e([x()],U.prototype,`hasContingentValues`,null),e([x()],U.prototype,`hasInvalidPendingEdits`,null),e([x()],U.prototype,`hasPendingEdits`,null),e([x()],U.prototype,`highlightEnabled`,void 0),e([x()],U.prototype,`highlightableLayerView`,null),e([x()],U.prototype,`initialSize`,void 0),e([x({readOnly:!0})],U.prototype,`isQuerying`,null),e([x({readOnly:!0})],U.prototype,`isSyncing`,null),e([x({readOnly:!0})],U.prototype,`isSyncingAttachmentEdits`,null),e([x({readOnly:!0})],U.prototype,`isSyncingFeatureEdits`,null),e([x({readOnly:!0})],U.prototype,`itemCache`,null),e([x()],U.prototype,`layer`,void 0),e([x()],U.prototype,`layerView`,null),e([x()],U.prototype,`maxSize`,void 0),e([x()],U.prototype,`objectIds`,void 0),e([x()],U.prototype,`orderByFields`,null),e([x()],U.prototype,`outFields`,void 0),e([x({readOnly:!0})],U.prototype,`pageCache`,void 0),e([x()],U.prototype,`pageCount`,null),e([x()],U.prototype,`pageIndex`,null),e([x()],U.prototype,`pageSize`,void 0),e([x()],U.prototype,`paginationEnabled`,void 0),e([x()],U.prototype,`pendingEditsCount`,null),e([x()],U.prototype,`relationship`,null),e([x()],U.prototype,`relationshipConfig`,void 0),e([x()],U.prototype,`relationshipIds`,null),e([x()],U.prototype,`relationshipInfos`,null),e([x()],U.prototype,`relationships`,null),e([x()],U.prototype,`relatedRecordsEnabled`,void 0),e([x()],U.prototype,`returnGeometry`,void 0),e([x()],U.prototype,`returnZ`,void 0),e([x()],U.prototype,`returnM`,void 0),e([x()],U.prototype,`selectionManager`,void 0),e([x({readOnly:!0})],U.prototype,`size`,null),e([x()],U.prototype,`sortOrders`,void 0),e([x({readOnly:!0})],U.prototype,`state`,null),e([x()],U.prototype,`supportsAdd`,null),e([x()],U.prototype,`supportsAddAttachments`,null),e([x()],U.prototype,`supportsAttachments`,null),e([x()],U.prototype,`supportsCacheHint`,null),e([x()],U.prototype,`supportsCacheHintQueryRelated`,null),e([x()],U.prototype,`supportsDelete`,null),e([x()],U.prototype,`supportsEditing`,null),e([x()],U.prototype,`supportsM`,null),e([x()],U.prototype,`supportsOrderBy`,null),e([x()],U.prototype,`supportsPagination`,null),e([x()],U.prototype,`supportsQuery`,null),e([x()],U.prototype,`supportsQueryRelated`,null),e([x()],U.prototype,`supportsResizeAttachments`,null),e([x()],U.prototype,`supportsUpdate`,null),e([x()],U.prototype,`supportsUpdateAttachments`,null),e([x()],U.prototype,`supportsZ`,null),e([x()],U.prototype,`syncViewSelection`,void 0),e([x()],U.prototype,`temporaryHighlightId`,void 0),e([x({type:A})],U.prototype,`timeExtent`,void 0),e([x()],U.prototype,`timeZone`,void 0),e([x()],U.prototype,`view`,void 0),e([x()],U.prototype,`viewTimeEnabled`,void 0),e([x()],U.prototype,`where`,void 0),U=e([S(`esri.widgets.FeatureTable.support.FeatureStore`)],U);const W=U;export{W as default};
|
|
2
|
+
import{__decorate as e}from"tslib";import t from"../../../Graphic.js";import n from"../../../core/Accessor.js";import{equals as r,isSome as i}from"../../../core/arrayUtils.js";import{createTask as a}from"../../../core/asyncUtils.js";import o from"../../../core/Collection.js";import s from"../../../core/Error.js";import{clone as c}from"../../../core/lang.js";import l from"../../../core/Logger.js";import{getOrCreateMapValue as u}from"../../../core/MapUtils.js";import{removeMaybe as d,abortMaybe as f}from"../../../core/maybe.js";import{debounce as p,ignoreAbortErrors as m,throwIfAborted as h}from"../../../core/promiseUtils.js";import g from"../../../core/ReactiveMap.js";import{watch as _,when as v,syncAndInitial as y,sync as b}from"../../../core/reactiveUtils.js";import{property as x,subclass as S}from"../../../core/accessorSupport/decorators.js";import{isInEffectiveScaleRange as C}from"../../../geometry/support/scaleUtils.js";import{geometryTypes as w}from"../../../geometry/support/typeUtils.js";import{isFeatureLayer as T,isSubtypeGroupLayer as E,isSubtypeSublayer as D}from"../../../layers/support/layerUtils.js";import{combineTimeExtent as O}from"../../../layers/support/timeSupport.js";import k from"../../../rest/support/AttachmentQuery.js";import A from"../../../rest/support/RelationshipQuery.js";import j from"../../../time/TimeExtent.js";import M from"../../../views/SelectionManager.js";import{temporaryHighlightName as N}from"../../../views/support/HighlightDefaults.js";import{highlightsSupported as P}from"../../../views/support/layerViewUtils.js";import{isSelectableLayerWithObjectIds as F,isSelectableLayer as I}from"../../../views/support/selectionUtils.js";import{isIFeatureTableSupportedLayerWithAttachments as L,isIFeatureTableSupportedLayerWithAttachmentsEditing as R,isIFeatureTableSupportedLayerWithEditing as z,isIFeatureTableSupportedLayerWithRelationships as B,isPageIndexValid as V,findRelatedLayer as H}from"./tableUtils.js";import{ContingentValuesManager as U}from"../../support/ContingentValuesManager.js";let W=class extends n{constructor(e){super(e),this._attachmentsOperationQueue=new o,this._contingentValuesManager=new U,this._defaultOutFields=[`*`],this._editOperationQueue=new o,this.featureTitleMap=new g,this._loaded=!1,this._loadController=null,this._loadDebounced=p(()=>this._load()),this._loadError=!1,this._objectIdCache=new o,this._pendingEditsCache=new g,this._queryOperationInfos=new g,this._refreshDebounced=p(()=>this._refresh()),this._size=0,this._temporaryHighlight=null,this._temporaryHighlightAbortController=null,this.attachmentsEnabled=!1,this.autoSaveEnabled=!0,this.defaultSelectionManager=new M,this.editingEnabled=!1,this.failures=new o,this.filterByViewExtent=!1,this.filterByLayerScaleRange=!1,this.filterGeometry=null,this.highlightEnabled=!0,this.initialSize=null,this.layer=null,this.maxSize=null,this.objectIds=null,this.outFields=null,this.pageCache=new g,this.pageSize=50,this.paginationEnabled=!1,this.relationshipConfig=null,this.relatedRecordsEnabled=!1,this.returnGeometry=!1,this.returnZ=!1,this.returnM=!1,this.selectionManager=null,this.sortOrders=[],this.syncViewSelection=!1,this.temporaryHighlightId=void 0,this.timeExtent=null,this.timeZone=null,this.view=null,this.viewTimeEnabled=!1,this.where=null}initialize(){this.addHandles([_(()=>[this.effectiveTimeExtent,this.effectiveWhere,this.filterGeometry,this.layer,this.objectIds,this.outFields,this.pageSize,this.relationshipConfig,this.returnGeometry,this.returnM,this.returnZ,this.visibleAtCurrentScale],()=>this._reset()),_(()=>this.orderByFields,()=>this._clearCaches(),{equals:r}),v(()=>this.attachmentsEnabled,()=>this._reset()),v(()=>this.relatedRecordsEnabled,()=>this._reset()),_(()=>this._layerWithContingentValues,e=>{let t=this._contingentValuesManager;e&&!t.layers.includes(e)&&t.layers.add(e)}),_(()=>[this.view?.extent,this.view?.stationary,this.filterByViewExtent],([e,t,n])=>{n&&(e?t&&(this.filterGeometry=e):this.filterGeometry=null)},y),_(()=>this.maxSize,(e,t)=>{t===0&&this._reset()}),_(()=>[this.layer,this.view],()=>this.syncSelectionSources(),y),_(()=>this.highlightEnabled,e=>this.defaultSelectionManager.highlightEnabled=e,y),_(()=>this.temporaryHighlightId,e=>{this._temporaryHighlight=d(this._temporaryHighlight?.handle),this._temporaryHighlightAbortController?.abort(),this._temporaryHighlightAbortController=new AbortController;let t=this._syncTemporaryHighlight(e,this._temporaryHighlightAbortController.signal);m(this.view?.addUpdatingPromise(t)??t)},b)])}destroy(){this.layer=null,this.itemCache.destroy(),this.failures.destroy(),this.defaultSelectionManager.destroy(),this._temporaryHighlight=d(this._temporaryHighlight?.handle),this._temporaryHighlightAbortController=f(this._temporaryHighlightAbortController)}get _capabilities(){let{layer:e}=this;return e?.effectiveCapabilities??e?.capabilities}get _canSavePendingEdits(){return this.supportsEditing&&this.hasPendingEdits&&!this.hasInvalidPendingEdits}get _effectiveReturnZ(){return this.returnZ&&this.supportsZ}get _effectiveReturnM(){return this.returnM&&this.supportsM}get _layerWithAttachments(){let{layer:e}=this;return!e||!this._capabilities||!this.attachmentsEnabled||!this.supportsAttachments||!L(e)?null:e}get _layerWithAttachmentsEditing(){let{_layerWithAttachments:e}=this;return!e||!R(e)||!this.supportsEditing?null:e}get _layerWithContingentValues(){let{layer:e}=this;return T(e)||E(e)?e:null}get _layerWithEditing(){let e=this.layer;return z(e)&&this.supportsEditing?e:null}get _layerWithRelationships(){let e=this.layer;return B(e)&&this.supportsQueryRelated?e:null}get _pendingEditsAreInvalid(){let e=this._pendingEditsCache,t=this._layerWithContingentValues;if(!t)return!1;for(let n of e.keys()){let r=e.get(n),i=this._getFeatureWithPendingEdits(n,r);for(let e of r.changes.keys())if(this._contingentValuesManager.getViolationForField(t,i,e))return!0}return!1}get _relatedLayer(){return this.relationshipConfig?.relatedLayer}get _relatedLayerCapabilities(){let{_relatedLayer:e}=this;return e?.effectiveCapabilities??e?.capabilities}get _relatedLayerSupportsCacheHint(){return!!this._relatedLayerCapabilities?.queryRelated?.supportsCacheHint}get _relatedLayerSupportsQuery(){return!!this._relatedLayerCapabilities?.operations.supportsQuery}get _relatedLayerSupportsQueryRelated(){let{_relatedLayerCapabilities:e}=this;return!!e?.queryRelated?.supportsCount&&!!e?.queryRelated?.supportsPagination}get _sortedFieldNames(){return this.sortOrders.map(({fieldName:e})=>e)}get _subtypeCode(){return this.layer?.subtypeCode??null}get _subtypeField(){let{layer:e}=this;return E(e?.parent)?e.subtypeField:null}get _canUseRelatedLayer(){return!!(this._relatedLayerSupportsQuery&&this._relatedLayerSupportsQueryRelated)}get cachedPageCount(){return this.pageCache.size}get canAddRelatedFeature(){let{state:e,relationship:t,supportsAdd:n,supportsEditing:r}=this;if(e!==`loaded`||!t||!n||!r)return!1;let{cardinality:i,role:a}=t,o=this.size>0;return!(i===`one-to-one`&&o||i===`one-to-many`&&a===`origin`&&o)}get effectiveFilterByLayerScaleRange(){return!!(this.view&&this.filterByLayerScaleRange)}get effectiveOutFields(){let{layer:e,outFields:t}=this;if(!e||!t?.length)return this._defaultOutFields;let n=[];t.forEach(t=>{let r=e.fieldsIndex.normalizeFieldName(t);r&&n.push(r)});let{objectIdField:r}=e,i=e.fieldsIndex.normalizeFieldName(r)??r;return i&&!n.includes(i)&&n.unshift(i),n}get effectiveSelectionManager(){let{layer:e,view:t}=this;return e&&this.syncViewSelection&&F(e)&&t?.selectionManager?.sources.includes(e)?t.selectionManager:this.selectionManager??this.defaultSelectionManager}get effectiveSize(){let{_size:e,maxSize:t}=this;return t==null?e:Math.min(t,e)}get effectiveTimeExtent(){let{layer:e,timeExtent:t,view:n,viewTimeEnabled:r}=this;return t||!e?t??void 0:!n||!r?e.timeExtent??void 0:O({datesInUnknownTimezone:e.datesInUnknownTimezone??void 0,timeExtent:e.timeExtent,timeInfo:e.timeInfo,timeOffset:e.timeOffset,useViewTime:e.useViewTime},n.timeExtent,this._get(`effectiveTimeExtent`))??void 0}get effectiveWhere(){let{layer:e,where:t}=this;return t!=null&&t!==``?t:D(e)&&e.parent?.definitionExpression?e.parent.definitionExpression:e?.definitionExpression||`1=1`}get fieldsWithContingentValues(){return this._contingentValuesManager.getFieldsWithContingentValues(this.layer)}get hasContingentValues(){return this.fieldsWithContingentValues.size>0}get hasInvalidPendingEdits(){return this.hasPendingEdits&&this._pendingEditsAreInvalid}get hasPendingEdits(){return this.pendingEditsCount>0}get highlightableLayerView(){let e=this.layerView;return P(e)?e:null}get isQuerying(){return this._queryOperationInfos.size>0}get isSyncing(){return this.isSyncingFeatureEdits||this.isSyncingAttachmentEdits}get isSyncingAttachmentEdits(){return this._attachmentsOperationQueue.length>0}get isSyncingFeatureEdits(){return this._editOperationQueue.length>0}get itemCache(){return new o({items:[...this.pageCache.values()].flat()})}get layerView(){let{layer:e,view:t}=this;if(!e||!t)return null;let n=e.type===`sublayer`||D(e)?e.parent:e;return t.allLayerViews.find(e=>e.layer===n)}get orderByFields(){let{_sortedFieldNames:e,layer:t,sortOrders:n}=this,r=n.filter(({fieldName:t,direction:n},r)=>e.indexOf(t)===r&&n!=null).map(({fieldName:e,direction:t})=>`${e} ${t?.toUpperCase()}`);if(t&&!r.length&&!t.objectIdField&&t.fields?.length){let e=t.fields.find(e=>e.name);if(e){let n=t.fieldsIndex.normalizeFieldName(e.name);n&&r.push(`${n} ASC`)}}return r}get pageCount(){let{effectiveSize:e,pageSize:t}=this;return e===0||t===0?1:Math.ceil(e/t)}get pageIndex(){return this._get(`pageIndex`)||0}set pageIndex(e){let{pageCount:t}=this;V(e,t)&&this._set(`pageIndex`,e)}get pendingEditsCount(){let e=0;return this._pendingEditsCache.forEach(t=>e+=t.changes.size),e}get relationship(){let{relationshipConfig:e}=this;return e?.relationshipId==null?null:this.relationships?.find(t=>t.id===e.relationshipId)}get relationshipIds(){return this.relationships?.map(e=>e.id)??[]}get relationshipInfos(){let{_layerWithRelationships:e,relatedRecordsEnabled:t,relationships:n,view:r}=this,i=[];return!t||!e?.loaded||!r?.map||!n?.length||n.forEach(t=>{let n=H(e,r,t);n&&(n.load().catch(()=>{}),i.push({layer:e,relatedLayer:n,relationshipId:t.id}))}),i}get relationships(){return this._layerWithRelationships?.relationships}get size(){return this._size}get state(){let{layer:e,_loaded:t,_loadError:n}=this;return!e||e.destroyed?`disabled`:n||e.loadError?`error`:this._loadController?`loading`:e.loadStatus===`loaded`&&t?`loaded`:`ready`}get supportsAdd(){return!!this._capabilities?.operations.supportsAdd}get supportsAddAttachments(){return!!(this._layerWithAttachmentsEditing&&(this.supportsAdd||this.supportsUpdate))}get supportsAttachments(){let{_capabilities:e}=this;return!!(e?.data?.supportsAttachment&&e?.operations.supportsQueryAttachments)}get supportsCacheHint(){return!!this._capabilities?.query?.supportsCacheHint}get supportsCacheHintQueryRelated(){return!!this._capabilities?.queryRelated?.supportsCacheHint}get supportsDelete(){return!!this._capabilities?.operations.supportsDelete}get supportsEditing(){return!!this._capabilities?.operations.supportsEditing}get supportsM(){return!!this.layer?.hasM&&!!this._capabilities?.data?.supportsM}get supportsOrderBy(){return!!this._capabilities?.query?.supportsOrderBy}get supportsPagination(){return!!this._capabilities?.query?.supportsPagination}get supportsQuery(){return!!this._capabilities?.operations.supportsQuery}get supportsQueryRelated(){let{_capabilities:e}=this;return!!e?.queryRelated?.supportsCount&&!!e?.queryRelated?.supportsPagination}get supportsResizeAttachments(){let{_capabilities:e}=this;return!!(this.supportsAttachments&&e?.attachment?.supportsResize)}get supportsUpdate(){return!!this._capabilities?.operations.supportsUpdate}get supportsUpdateAttachments(){return!!(this._layerWithAttachmentsEditing&&(this.supportsAdd||this.supportsUpdate))}get supportsZ(){return!!this.layer?.hasZ&&!!this._capabilities?.data?.supportsZ}get visibleAtCurrentScale(){let{layer:e}=this;return!e||!this.effectiveFilterByLayerScaleRange?!1:C(e.effectiveScaleRange,this.view?.scale)}async addAttachment(e,t){let{_layerWithAttachmentsEditing:n}=this;if(!n||!this.supportsAddAttachments)return{};let r=await this._queueAttachmentsOperation(e,()=>n.addAttachment(this._createBaseGraphic(n,e),t));return this._ensureArrayContent(r)}addPendingEdits(e){let t=this._ensureLayerAndUpdateSupport();this.editingEnabled?(this.autoSaveEnabled&&this._logWarning(`store:pending-edit`,`Edit will be cached, but 'autoSaveEnabled' is true.`,!0),this._stashPendingEdits(t,e)):this._logWarning(`store:editing-disabled`,`Editing is disabled.`)}async deleteAttachments(e,t){let{_layerWithAttachmentsEditing:n}=this;if(!n||!this.supportsUpdateAttachments||!t.length)return[];let r=await this._queueAttachmentsOperation(e,()=>n.deleteAttachments(this._createBaseGraphic(n,e),t));return this._ensureArray(r)}async deleteRowsByObjectId(e){let{_layerWithEditing:t}=this;if(!this.supportsDelete||!t)throw new s(`store:delete-error`,`Delete is not supported.`);let n=e.map(e=>this.getItemByObjectId(e)?.feature).filter(i),r=this._queueEditOperation(()=>t.applyEdits({deleteFeatures:n}));return e.forEach(e=>{this.featureTitleMap.delete(e),this._discardPendingEdit({objectId:e})}),r}discardPendingEdits(e){if(e?.length)e.forEach(e=>this._discardPendingEdit(e));else{for(let[e,t]of this._pendingEditsCache){let n=this.getItemByObjectId(e);n&&(n.feature=t.originalFeature)}this._pendingEditsCache.clear(),this._clearOptionsAndViolations()}}itemHasInvalidPendingEdits(e,t){if(!this.hasInvalidPendingEdits)return!1;let n=this._layerWithContingentValues,r=this._pendingEditsCache.get(e);if(!n||!r)return!1;let i=this._getFeatureWithPendingEdits(e,r),a=this._contingentValuesManager;return t?!!a.getViolationForField(n,i,t):!!a.getAllViolations(n,i)}itemHasPendingEdits(e,t){let n=this._pendingEditsCache.get(e);return n?!t||n.changes.has(t):!1}async getAttachmentsByObjectId(e,t){let n=this.getItemByObjectId(e)?.attachments??[];return!n.length&&t?(await this._queryAttachments([e]))[e]??[]:n}getCachedFeaturesByPageIndex(e){return this.pageCache.get(e)}getFieldValueOptions(e){return this._contingentValuesManager.getFieldValueOptions(e)}async getFeatureTitle(e,n=!1){let{layer:r}=this,i=this.featureTitleMap.get(e),a=`${e}`;if(!r)return i||a;if(i&&!n)return i;if(!(`getFeatureTitle`in r)||!r.getFeatureTitle)return a;let o=this.getItemByObjectId(e)?.feature;o||=new t({attributes:{[r.objectIdField]:e},origin:r.graphicOrigin});let s=await r.getFeatureTitle(o,{fetchMissingFields:!0,removeHTML:!0});return s?(this.featureTitleMap.set(e,s),s):a}getItemByObjectId(e){for(let t of this.pageCache.values())for(let n of t)if(n.objectId===e)return n}getItemIndexByObjectId(e){let{pageCache:t,pageSize:n}=this,r=t.entries(),i=-1;for(let[t,a]of r)if(a.some((r,a)=>{let o=r.objectId===e;return o&&(i=t*n+a),o}),i>-1)break;return i}async load(){await m(this._loadDebounced())}async queryPage(e){let{layer:t,state:n}=this;if(!t||n!==`loaded`||!this.supportsQuery||this.size===0||this.maxSize===0)return[];let{pageIndex:r}=e;if(!V(r,this.pageCount))return[];let i=e.pageSize??this.pageSize,a=r*i,o=a+i;return await m(this._query({layer:t,start:a,num:o,pageIndex:r,pageSize:i}))??[]}async refresh(){await m(this._refreshDebounced())}reset(){this._reset()}async savePendingEdits(){let e=this._ensureLayerAndUpdateSupport();if(!this.editingEnabled){this._logWarning(`store:editing-disabled`,`Editing is disabled.`);return}if(this.autoSaveEnabled&&this._logWarning(`store:pending-edit`,`Edit will be cached, but 'autoSaveEnabled' is true.`,!0),!this._canSavePendingEdits){this._logError(`store:update-error`,`An error occurred. Unable to save pending edits.`);return}let t=[];for(let[e]of this._pendingEditsCache){let n=this.getItemByObjectId(e);n?.feature&&t.push(n.feature)}(await this._update(e,t,!0)).updateFeatureResults.find(e=>e.error)&&this.discardPendingEdits(),this._clearOptionsAndViolations()}syncSelectionSources(){let{defaultSelectionManager:e,layer:t,view:n}=this;e.view=n,e.sources.removeAll(),I(t)&&(e.sources.items=[t])}async updateAttachment(e,t,n){let{_layerWithAttachmentsEditing:r}=this;if(!r||!this.supportsUpdateAttachments)return{};let i=await this._queueAttachmentsOperation(e,()=>r.updateAttachment(this._createBaseGraphic(r,e),t,n));return this._ensureArrayContent(i)}async updateItem(e){let t=this._ensureLayerAndUpdateSupport();if(!this.editingEnabled){this._logWarning(`store:editing-disabled`,`Editing is disabled.`);return}if(this.hasContingentValues){let t=e.updates.some(e=>this.fieldsWithContingentValues.has(e.fieldName)),n=this.itemHasPendingEdits(e.objectId);if(n||t){let t=this._layerWithContingentValues,r=this.getItemByObjectId(e.objectId)?.feature?.clone();if(r){let i=this._contingentValuesManager.getAllViolations(t,r);if(e.updates.forEach(({fieldName:e,value:n})=>{let i=t.getField(e);i&&(r.attributes[i.name]=n)}),this._contingentValuesManager.validateContingencyConstraints(t,r).length||i.length||n){this._stashPendingEdits(t,[e]),this._contingentValuesManager.resetOptionsForLayer(t);return}}}}if(!this.autoSaveEnabled){this._stashPendingEdits(t,[e]);return}let{_sortedFieldNames:n}=this,r=e.updates.map(({fieldName:e})=>e),i=this._prepareEditsForUpdate([e]);!(await this._update(t,i)).updateFeatureResults.find(e=>e.error)&&r.some(e=>n.includes(e))&&this._clearCaches()}async verifyFeaturesByObjectId(e){let{layer:t,state:n}=this;if(!t||n!==`loaded`)return[];let{objectIdField:r}=t,i=await this._queryFeaturesByObjectId(e);return e.map(e=>i.some(t=>e===(t.getObjectId()??t.attributes[r])))}async _load(){let{layer:e}=this;if(this._reset(),!e)return;let t=new AbortController;this._loadController=t;try{if(await e.load(),e.parent&&E(e.parent)&&await e.parent.loadAll(),await e.when(),t.signal.aborted)return;let n=this.initialSize;if(this.initialSize=null,this.effectiveFilterByLayerScaleRange&&(this.visibleAtCurrentScale||(n=0)),await m(this._refresh(t,n)),t.signal.aborted){this._loadController=null;return}this._loaded=!0,this._loadController=null}catch(e){throw this._reset(),this._loadError=!0,this._logError(`store:load-error`,`An error occurred.`),e}}async _refresh(e,t){this._clearCaches();let n=e?.signal,r=await this._getSize(n,t),i=await this._queryAllObjectIds(n);n?.aborted||(this._size=r,this._objectIdCache.removeAll(),i?.length&&this._objectIdCache.addMany(i),this._syncPendingEdits())}async _queryAllObjectIds(e){return this.supportsPagination?void 0:await this._queryObjectIds(e)}_clearCaches(){this.pageCache.clear(),this._objectIdCache.removeAll()}_createBaseGraphic(e,n){let r=new t({attributes:{[e.objectIdField]:n}});return this._subtypeField&&this._subtypeCode!=null&&(r.attributes[this._subtypeField]=this._subtypeCode),r}_ensureArray(e){return Array.isArray(e)?e:[e]}_ensureArrayContent(e){return Array.isArray(e)?e[0]:e}_getObjectIdsForFeatures(e,t){return e.map(e=>e.getObjectId()??e.attributes[t.objectIdField])}_getObjectIdsForPage(e,t){let n=this._objectIdCache.toArray();return n.length>=e+t?n.slice(e,e+t):n.slice(e)}_logError(e,t){l.getLogger(this).error(e,t)}_logWarning(e,t,n=!1){n?l.getLogger(this).warnOnce(e,t):l.getLogger(this).warn(e,t)}_reset(){this._clearCaches(),this._pendingEditsCache.clear(),this.failures.removeAll(),this._attachmentsOperationQueue.removeAll(),this._editOperationQueue.removeAll(),this.featureTitleMap.clear(),this._loadController=f(this._loadController),this._queryOperationInfos.forEach(e=>e.controller.abort()),this._queryOperationInfos.clear(),this._temporaryHighlight=d(this._temporaryHighlight?.handle),this._temporaryHighlightAbortController=f(this._temporaryHighlightAbortController),this._loaded=!1,this._loadError=!1,this._size=0}async _getSize(e,t){return this.maxSize===0?0:t??await this._queryCount(e)}async _queryFeaturesByObjectId(e){let{layer:t}=this;if(!t||!this.supportsQuery)throw new s(`store:query-error`,`Layer does not support query operation.`);let{effectiveTimeExtent:n,effectiveWhere:r,orderByFields:i,supportsCacheHint:a,supportsOrderBy:o}=this,c=t.createQuery();return c.where=r,c.timeExtent=n,c.returnGeometry=!1,c.objectIds=e.length?e:void 0,c.outFields=[t.objectIdField],o&&(c.orderByFields=i),a&&(c.cacheHint=!0),(await t.queryFeatures(c)).features}async _syncTemporaryHighlight(e,t){let{highlightEnabled:n,highlightableLayerView:r}=this;r&&n&&e!=null&&(h(t),this._temporaryHighlight={id:e,handle:r.highlight(e,{name:N})})}_ensureLayerAndUpdateSupport(){let e=this._layerWithEditing;if(!e||!this.supportsUpdate)throw new s(`store:update-error`,`Update is not supported.`);return e}_stashPendingEdits(e,t){t.forEach(({objectId:t,updates:n})=>{let r=this.getItemByObjectId(t)?.feature;if(!r)throw new s(`store:update-error`,`Feature with provided 'objectId' not found.`);let i=r.clone(),a=u(this._pendingEditsCache,t,()=>({originalFeature:i,changes:new g}));n.forEach(({fieldName:t,value:n})=>{let i=e.getField(t);i?(a.changes.set(i.name,n),r.attributes[i.name]=n):this._logWarning(`store:pending-edit-unknown-field`,`The provided field does not belong to this layer.`)}),a.changes.size>0&&this._pendingEditsCache.set(t,a)})}_syncPendingEdits(){for(let[e,t]of this._pendingEditsCache){let n=this.getItemByObjectId(e)?.feature;if(n){let e=n.clone();for(let[e,r]of t.changes)n.attributes[e]=r;t.originalFeature=e}}}_getFeatureWithPendingEdits(e,t){let n=this.getItemByObjectId(e)?.feature;if(!n){n=t.originalFeature.clone();for(let[e,r]of t.changes)n.attributes[e]=r}return n}_discardPendingEdit({objectId:e,fieldName:t}){let n=this._pendingEditsCache.get(e);if(!n){this._logWarning(`store:pending-edit-not-found`,`Could not find a pending edit with the given information`);return}let r=this.getItemByObjectId(e);t?(r&&(r.feature.attributes[t]=n.originalFeature.attributes[t]),n.changes.delete(t),n.changes.size===0&&this._pendingEditsCache.delete(e)):(r&&(r.feature=n.originalFeature),this._pendingEditsCache.delete(e))}_clearOptionsAndViolations(){let{_layerWithContingentValues:e,_contingentValuesManager:t}=this;e&&(t.resetOptionsForLayer(e),t.resetViolationsForLayer(e))}_prepareEditsForUpdate(e){let n=[];return e.forEach(({objectId:e,updates:r})=>{let i=this.getItemByObjectId(e)?.feature;if(!i)return;let a=c(i.attributes);r.forEach(({fieldName:e,value:t})=>a[e]=t),n.push(new t({attributes:a,sourceLayer:i.sourceLayer}))}),n}_update(e,t,n=!1){let r=e.applyEdits({updateFeatures:t}).then(n=>{let{updateFeatureResults:r}=n,i=r.find(e=>!!e.error);if(i)throw i.error;return t.forEach(t=>{let n=t.getObjectId()??t.attributes[e.objectIdField],r=this.getItemByObjectId(n)?.feature;r&&(r.attributes=t.attributes),this.featureTitleMap.has(n)&&this.getFeatureTitle(n,!0)}),n});return this._queueEditOperation(()=>r,n)}_createFeatureStoreItems(e){let{attachments:t,features:n,layer:r,relatedRecords:i}=e,a=r.objectIdField;return n.map(e=>{let n=e.getObjectId()??e.attributes[a],o=[];!e.layer&&!e.sourceLayer&&(e.layer=r,e.sourceLayer=r);let s=this._pendingEditsCache.get(n);if(s){let t=e.clone(),n=s.changes;for(let[t,r]of n)e.attributes[t]=r;s.originalFeature=t}return i.forEach((e,t)=>{o.push({relationshipId:t,count:e[n]??0})}),{objectId:n,feature:e,attachments:t[n]??null,relatedRecords:o}})}async _query(e){let{pageIndex:t,refresh:n}=e;n===!0&&await this._refresh();let r=this.pageCache.get(t);if(r)return r;let i=this._queryOperationInfos.get(t);if(i)return i.task.promise;let a=new AbortController,o=await this._queryPage(e,a);return a.signal.aborted||this.pageCache.set(t,o),o}_queryAttachments(e,t){let{_layerWithAttachments:n,effectiveWhere:r}=this;return n?e.some(e=>typeof e!=`number`)?Promise.reject(new s(`invalid-object-id`,`Only numeric object ids are valid to query attachments`)):n.queryAttachments(new k({objectIds:e,where:r,returnMetadata:!0}),{signal:t}):Promise.resolve({})}async _queryCount(e){let{_relatedLayerSupportsCacheHint:t,layer:n,relationshipConfig:r,supportsCacheHint:i}=this;if(!n)return 0;if(r&&this._canUseRelatedLayer){let{objectId:n,relatedLayer:i,relationshipId:a}=r;return(await i.queryRelatedFeaturesCount(new A({cacheHint:t,relationshipId:a,objectIds:[n]}),{signal:e}))[n]??0}let{effectiveTimeExtent:a,effectiveWhere:o,filterGeometry:s,objectIds:c}=this,l=n.createQuery();return l.geometry=s,l.returnGeometry=!1,l.where=o,l.timeExtent=a,l.objectIds=c?.length?c:void 0,i&&(l.cacheHint=!0),n.queryFeatureCount(l,{signal:e})}async _queryFeatures(e,t){let{relationshipConfig:n}=this;if(n&&this._canUseRelatedLayer)return this._queryRelatedFeatures(e,n);let{_effectiveReturnM:r,_effectiveReturnZ:i,effectiveOutFields:a,effectiveTimeExtent:o,effectiveWhere:s,filterGeometry:c,objectIds:l,orderByFields:u,pageSize:d,returnGeometry:f,supportsCacheHint:p,supportsOrderBy:m,supportsPagination:h}=this,{layer:g,start:_}=e,v=l?.length,y=g.createQuery();return y.returnGeometry=f,y.outFields=a,y.returnM=r,y.returnZ=i,h?(y.start=_,y.num=d,y.where=s,y.timeExtent=o,y.objectIds=v?l:void 0):y.objectIds=v?l:this._getObjectIdsForPage(_,d??0),m&&(y.orderByFields=u),c&&(y.geometry=c),p&&(y.cacheHint=!0),(await g.queryFeatures(y,{signal:t})).features}_queryObjectIds(e){let{effectiveTimeExtent:t,effectiveWhere:n,filterGeometry:r,layer:i,objectIds:a,orderByFields:o,supportsCacheHint:s,supportsOrderBy:c}=this;if(!i)return Promise.resolve([]);let l=i.createQuery();return l.geometry=r,l.outFields=[i.objectIdField],l.returnGeometry=!1,l.where=n,l.timeExtent=t,l.objectIds=a?.length?a:void 0,c&&(l.orderByFields=o),s&&(l.cacheHint=!0),i.queryObjectIds(l,{signal:e})}async _queryPage(e,t){return this._queueQueryOperation(e.pageIndex,{controller:t,task:a(async()=>this._queryPageData(e,t))})}async _queryPageData(e,t){let{layer:n}=e,{signal:r}=t,i=await this._queryFeatures(e,r);if(r.aborted)return[];let a=this._getObjectIdsForFeatures(i,n),[o,s]=await Promise.all([this._queryAttachments(a,r),this._queryRelatedCounts(a,r)]);return t.signal.aborted?[]:this._createFeatureStoreItems({layer:n,features:i,attachments:o,relatedRecords:s})||[]}async _queryRelatedCounts(e,t){let{_layerWithRelationships:n,relationshipIds:r,supportsCacheHintQueryRelated:i}=this,a=new Map;return!n||!e?.length||!r.length||await Promise.allSettled(r.map(async r=>{let o=await n.queryRelatedFeaturesCount(new A({cacheHint:i,relationshipId:r,objectIds:e}),{signal:t});a.set(r,o)})),a}async _queryRelatedFeatures(e,t){let{_defaultOutFields:n,_effectiveReturnM:r,_effectiveReturnZ:i,orderByFields:a,pageSize:o,returnGeometry:s,supportsCacheHint:c}=this,{layer:l,start:u}=e,{objectId:d,relatedLayer:f,relationshipId:p}=t,m=l.createQuery(),h=new A({cacheHint:c,num:o,objectIds:[d],orderByFields:a,outFields:n,relationshipId:p,returnGeometry:s,returnM:r,returnZ:i,start:u,where:m.where??void 0});return(await f.queryRelatedFeatures(h))[d]?.features||[]}_queueAttachmentsOperation(e,t){return this._attachmentsOperationQueue.push(t),t().then(async n=>{this._attachmentsOperationQueue.remove(t);let r=this._ensureArray(n),i=r.some(e=>e.error),a=this.getItemByObjectId(e);return a&&(!i||r.length>1)&&(a.attachments=(await this._queryAttachments([e]))[e]),n}).catch(async n=>{this._logError(`store:attachment-error`,`An error occurred.`);let r={error:n,retry:()=>{this.failures.remove(r),this._queueAttachmentsOperation(e,t)},cancel:()=>this.failures.remove(r)};throw this.failures.add(r),this._attachmentsOperationQueue.remove(t),n})}_queueEditOperation(e,t=!1){return this._editOperationQueue.push(e),e().then(n=>(this._editOperationQueue.remove(e),t&&this._pendingEditsCache.clear(),n)).catch(t=>{this._logError(`store:edit-error`,`An error occurred.`);let n={error:t,retry:()=>{this.failures.remove(n),this._queueEditOperation(e)},cancel:()=>this.failures.remove(n)};throw this.failures.add(n),this._editOperationQueue.remove(e),t})}async _queueQueryOperation(e,t){this._queryOperationInfos.set(e,t);let n=await t.task.promise;return this._queryOperationInfos.delete(e),n}};e([x()],W.prototype,`_attachmentsOperationQueue`,void 0),e([x({readOnly:!0})],W.prototype,`_capabilities`,null),e([x()],W.prototype,`_canSavePendingEdits`,null),e([x()],W.prototype,`_contingentValuesManager`,void 0),e([x()],W.prototype,`_defaultOutFields`,void 0),e([x()],W.prototype,`_editOperationQueue`,void 0),e([x()],W.prototype,`_effectiveReturnZ`,null),e([x()],W.prototype,`_effectiveReturnM`,null),e([x()],W.prototype,`featureTitleMap`,void 0),e([x({readOnly:!0})],W.prototype,`_layerWithAttachments`,null),e([x({readOnly:!0})],W.prototype,`_layerWithAttachmentsEditing`,null),e([x()],W.prototype,`_layerWithContingentValues`,null),e([x({readOnly:!0})],W.prototype,`_layerWithEditing`,null),e([x({readOnly:!0})],W.prototype,`_layerWithRelationships`,null),e([x()],W.prototype,`_loaded`,void 0),e([x()],W.prototype,`_loadController`,void 0),e([x()],W.prototype,`_loadError`,void 0),e([x()],W.prototype,`_objectIdCache`,void 0),e([x()],W.prototype,`_pendingEditsCache`,void 0),e([x()],W.prototype,`_pendingEditsAreInvalid`,null),e([x()],W.prototype,`_queryOperationInfos`,void 0),e([x({readOnly:!0})],W.prototype,`_relatedLayer`,null),e([x({readOnly:!0})],W.prototype,`_relatedLayerCapabilities`,null),e([x({readOnly:!0})],W.prototype,`_relatedLayerSupportsCacheHint`,null),e([x()],W.prototype,`_relatedLayerSupportsQuery`,null),e([x()],W.prototype,`_relatedLayerSupportsQueryRelated`,null),e([x()],W.prototype,`_size`,void 0),e([x()],W.prototype,`_sortedFieldNames`,null),e([x()],W.prototype,`_subtypeCode`,null),e([x()],W.prototype,`_subtypeField`,null),e([x()],W.prototype,`_canUseRelatedLayer`,null),e([x()],W.prototype,`attachmentsEnabled`,void 0),e([x()],W.prototype,`autoSaveEnabled`,void 0),e([x()],W.prototype,`cachedPageCount`,null),e([x()],W.prototype,`canAddRelatedFeature`,null),e([x()],W.prototype,`defaultSelectionManager`,void 0),e([x()],W.prototype,`editingEnabled`,void 0),e([x()],W.prototype,`effectiveFilterByLayerScaleRange`,null),e([x()],W.prototype,`effectiveOutFields`,null),e([x()],W.prototype,`effectiveSelectionManager`,null),e([x()],W.prototype,`effectiveSize`,null),e([x()],W.prototype,`effectiveTimeExtent`,null),e([x()],W.prototype,`effectiveWhere`,null),e([x({readOnly:!0})],W.prototype,`failures`,void 0),e([x()],W.prototype,`fieldsWithContingentValues`,null),e([x()],W.prototype,`filterByViewExtent`,void 0),e([x()],W.prototype,`filterByLayerScaleRange`,void 0),e([x({types:w})],W.prototype,`filterGeometry`,void 0),e([x()],W.prototype,`hasContingentValues`,null),e([x()],W.prototype,`hasInvalidPendingEdits`,null),e([x()],W.prototype,`hasPendingEdits`,null),e([x()],W.prototype,`highlightEnabled`,void 0),e([x()],W.prototype,`highlightableLayerView`,null),e([x()],W.prototype,`initialSize`,void 0),e([x({readOnly:!0})],W.prototype,`isQuerying`,null),e([x({readOnly:!0})],W.prototype,`isSyncing`,null),e([x({readOnly:!0})],W.prototype,`isSyncingAttachmentEdits`,null),e([x({readOnly:!0})],W.prototype,`isSyncingFeatureEdits`,null),e([x({readOnly:!0})],W.prototype,`itemCache`,null),e([x()],W.prototype,`layer`,void 0),e([x()],W.prototype,`layerView`,null),e([x()],W.prototype,`maxSize`,void 0),e([x()],W.prototype,`objectIds`,void 0),e([x()],W.prototype,`orderByFields`,null),e([x()],W.prototype,`outFields`,void 0),e([x({readOnly:!0})],W.prototype,`pageCache`,void 0),e([x()],W.prototype,`pageCount`,null),e([x()],W.prototype,`pageIndex`,null),e([x()],W.prototype,`pageSize`,void 0),e([x()],W.prototype,`paginationEnabled`,void 0),e([x()],W.prototype,`pendingEditsCount`,null),e([x()],W.prototype,`relationship`,null),e([x()],W.prototype,`relationshipConfig`,void 0),e([x()],W.prototype,`relationshipIds`,null),e([x()],W.prototype,`relationshipInfos`,null),e([x()],W.prototype,`relationships`,null),e([x()],W.prototype,`relatedRecordsEnabled`,void 0),e([x()],W.prototype,`returnGeometry`,void 0),e([x()],W.prototype,`returnZ`,void 0),e([x()],W.prototype,`returnM`,void 0),e([x()],W.prototype,`selectionManager`,void 0),e([x({readOnly:!0})],W.prototype,`size`,null),e([x()],W.prototype,`sortOrders`,void 0),e([x({readOnly:!0})],W.prototype,`state`,null),e([x()],W.prototype,`supportsAdd`,null),e([x()],W.prototype,`supportsAddAttachments`,null),e([x()],W.prototype,`supportsAttachments`,null),e([x()],W.prototype,`supportsCacheHint`,null),e([x()],W.prototype,`supportsCacheHintQueryRelated`,null),e([x()],W.prototype,`supportsDelete`,null),e([x()],W.prototype,`supportsEditing`,null),e([x()],W.prototype,`supportsM`,null),e([x()],W.prototype,`supportsOrderBy`,null),e([x()],W.prototype,`supportsPagination`,null),e([x()],W.prototype,`supportsQuery`,null),e([x()],W.prototype,`supportsQueryRelated`,null),e([x()],W.prototype,`supportsResizeAttachments`,null),e([x()],W.prototype,`supportsUpdate`,null),e([x()],W.prototype,`supportsUpdateAttachments`,null),e([x()],W.prototype,`supportsZ`,null),e([x()],W.prototype,`syncViewSelection`,void 0),e([x()],W.prototype,`temporaryHighlightId`,void 0),e([x({type:j})],W.prototype,`timeExtent`,void 0),e([x()],W.prototype,`timeZone`,void 0),e([x()],W.prototype,`view`,void 0),e([x()],W.prototype,`viewTimeEnabled`,void 0),e([x()],W.prototype,`visibleAtCurrentScale`,null),e([x()],W.prototype,`where`,void 0),W=e([S(`esri.widgets.FeatureTable.support.FeatureStore`)],W);const G=W;export{G as default};
|
|
@@ -66,7 +66,7 @@ export interface HistogramRangeSliderProperties extends WidgetProperties, Partia
|
|
|
66
66
|
viewModel?: HistogramRangeSliderViewModelProperties;
|
|
67
67
|
}
|
|
68
68
|
|
|
69
|
-
/** @deprecated since version 5.0. Use the [
|
|
69
|
+
/** @deprecated since version 5.0. Use the [arcgis-slider-histogram-range](https://developers.arcgis.com/javascript/latest/references/common-components/components/arcgis-slider-histogram-range/) component instead. For information on widget deprecation, read about [Esri's move to web components](https://developers.arcgis.com/javascript/latest/components-transition-plan/). */
|
|
70
70
|
export interface HistogramRangeSliderEvents extends CommonSliderEvents {}
|
|
71
71
|
|
|
72
72
|
/**
|
|
@@ -84,7 +84,7 @@ export interface HistogramRangeSliderEvents extends CommonSliderEvents {}
|
|
|
84
84
|
*
|
|
85
85
|
* At a minimum, the slider's [container](https://developers.arcgis.com/javascript/latest/references/core/widgets/HistogramRangeSlider/#container) or parent container must have a `width` set in css for it to render.
|
|
86
86
|
*
|
|
87
|
-
* @deprecated since version 5.0. Use the [
|
|
87
|
+
* @deprecated since version 5.0. Use the [arcgis-slider-histogram-range](https://developers.arcgis.com/javascript/latest/references/common-components/components/arcgis-slider-histogram-range/) component instead. For information on widget deprecation, read about [Esri's move to web components](https://developers.arcgis.com/javascript/latest/components-transition-plan/).
|
|
88
88
|
* @since 4.12
|
|
89
89
|
* @see [Histogram](https://developers.arcgis.com/javascript/latest/references/core/widgets/Histogram/)
|
|
90
90
|
* @see [Slider](https://developers.arcgis.com/javascript/latest/references/core/widgets/Slider/)
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
|
|
2
|
-
import{__decorate as e}from"tslib";import t from"../Color.js";import{deprecatedModule as n}from"../core/deprecate.js";import r from"../core/Logger.js";import{watch as i}from"../core/reactiveUtils.js";import{property as a,subclass as o}from"../core/accessorSupport/decorators.js";import{Integer as s}from"../core/accessorSupport/ensureType.js";import c from"./Histogram.js";import l from"./Slider.js";import u from"./Widget.js";import d from"./HistogramRangeSlider/HistogramRangeSliderViewModel.js";import{getDeviationValues as f}from"./smartMapping/support/utils.js";import{globalCss as p}from"./support/globalCss.js";import{messageBundle as m,tsx as h}from"./support/widget.js";const g=`esri-histogram-range-slider`,_={base:g,sliderContainer:`${g}__slider-container`,histogramContainer:`${g}__histogram-container`,rangeTypePrefix:`${g}__range-type--`};let v=class extends u{constructor(e,i){super(e,i),this._barElements=[],this._histogram=null,this._slider=null,this.barCreatedFunction=null,this.dataLines=null,this.dataLineCreatedFunction=null,this.excludedBarColor=new t(`#d7e5f0`),this.includedBarColor=new t(`#599dd4`),this.messages=null,this.standardDeviationCount=1,this.viewModel=new d({suppressDeprecationWarning:!0}),n(r.getLogger(`esri.widgets.HistogramRangeSlider`),`esri.widgets.HistogramRangeSlider`,{replacement:`Use
|
|
2
|
+
import{__decorate as e}from"tslib";import t from"../Color.js";import{deprecatedModule as n}from"../core/deprecate.js";import r from"../core/Logger.js";import{watch as i}from"../core/reactiveUtils.js";import{property as a,subclass as o}from"../core/accessorSupport/decorators.js";import{Integer as s}from"../core/accessorSupport/ensureType.js";import c from"./Histogram.js";import l from"./Slider.js";import u from"./Widget.js";import d from"./HistogramRangeSlider/HistogramRangeSliderViewModel.js";import{getDeviationValues as f}from"./smartMapping/support/utils.js";import{globalCss as p}from"./support/globalCss.js";import{messageBundle as m,tsx as h}from"./support/widget.js";const g=`esri-histogram-range-slider`,_={base:g,sliderContainer:`${g}__slider-container`,histogramContainer:`${g}__histogram-container`,rangeTypePrefix:`${g}__range-type--`};let v=class extends u{constructor(e,i){super(e,i),this._barElements=[],this._histogram=null,this._slider=null,this.barCreatedFunction=null,this.dataLines=null,this.dataLineCreatedFunction=null,this.excludedBarColor=new t(`#d7e5f0`),this.includedBarColor=new t(`#599dd4`),this.messages=null,this.standardDeviationCount=1,this.viewModel=new d({suppressDeprecationWarning:!0}),n(r.getLogger(`esri.widgets.HistogramRangeSlider`),`esri.widgets.HistogramRangeSlider`,{replacement:`Use arcgis-slider-histogram-range from the Common Components package.`,version:`5.0`,see:`https://www.esriurl.com/common-components/`,warnOnce:!0})}initialize(){let{average:e,bins:t,hasTimeData:n,max:r,min:a,viewModel:o}=this;this._updateBarFill=this._updateBarFill.bind(this),this._histogram=new c({suppressDeprecationWarning:!0,average:e,bins:t,barCreatedFunction:(e,t)=>{e===0&&(this._barElements=[]),this._barElements.push(t),this._updateBarFill(e,t),this.barCreatedFunction?.(e,t)},dataLines:this._getDataLines(),dataLineCreatedFunction:(e,t)=>{this.dataLineCreatedFunction?.(e,t)},labelFormatFunction:this.labelFormatFunction,layout:`horizontal`,max:r,min:a}),this._slider=new l({labelFormatFunction:this.labelFormatFunction,layout:`horizontal`,visibleElements:{labels:!0,rangeLabels:!0},rangeLabelInputsEnabled:!n,viewModel:o,suppressDeprecationWarning:!0}),this.addHandles([this._slider.on(`max-change`,e=>this.emit(`max-change`,e)),this._slider.on(`min-change`,e=>this.emit(`min-change`,e)),this._slider.on(`segment-drag`,e=>{this._updateBarFills(),this.emit(`segment-drag`,e)}),this._slider.on(`thumb-change`,e=>{this._updateBarFills(),this.emit(`thumb-change`,e)}),this._slider.on(`thumb-drag`,e=>{this._updateBarFills(),this.emit(`thumb-drag`,e)}),i(()=>this.bins,e=>{if(!e||!this._histogram.bins)this._barElements=[];else{let t=this._histogram.bins.length-e.length;this._barElements.splice(-t,t)}this._histogram.set({bins:e}),this._updateBarFills(),this.scheduleRender()}),i(()=>[this.max,this.min,this.rangeType,this.values],([e,t])=>{this._histogram.set({max:e,min:t}),this._updateBarFills(),this.scheduleRender()}),i(()=>[this.average,this.dataLines,this.standardDeviation,this.standardDeviationCount],([e])=>{this._histogram.set({average:e,dataLines:this._getDataLines()})}),i(()=>this.labelFormatFunction,e=>{this._histogram.set({labelFormatFunction:e})}),i(()=>this.hasTimeData,e=>{this._slider.set({rangeLabelInputsEnabled:!e})})])}get average(){return this.viewModel.average}set average(e){this.viewModel.average=e}get bins(){return this.viewModel.bins}set bins(e){this.viewModel.bins=e}get hasTimeData(){return this.viewModel.hasTimeData}set hasTimeData(e){this.viewModel.hasTimeData=e}get icon(){return`arrow-double-horizontal`}set icon(e){this._overrideIfSome(`icon`,e)}get label(){return this.messages?.widgetLabel??``}set label(e){this._overrideIfSome(`label`,e)}get labelFormatFunction(){return this.viewModel.labelFormatFunction}set labelFormatFunction(e){this.viewModel.labelFormatFunction=e}get max(){return this.viewModel.max}set max(e){this.viewModel.max=e}get min(){return this.viewModel.min}set min(e){this.viewModel.min=e}get precision(){return this.viewModel.precision}set precision(e){this.viewModel.precision=e}get rangeType(){return this.viewModel.rangeType}set rangeType(e){this.viewModel.rangeType=e}get standardDeviation(){return this.viewModel.standardDeviation}set standardDeviation(e){this.viewModel.standardDeviation=e}get values(){return this.viewModel.values}set values(e){this.viewModel.values=e}generateWhereClause(e){return this.viewModel.generateWhereClause(e)}render(){let{rangeType:e,viewModel:t,label:n}=this,r=this.classes(_.base,p.widget,`${_.rangeTypePrefix}${e}`,t.state===`disabled`?p.disabled:null);return h(`div`,{"aria-label":n,class:r},t.state===`disabled`?null:this._renderContent())}_renderContent(){return[this._renderHistogram(),this._renderSlider()]}_renderSlider(){return h(`div`,{class:_.sliderContainer,key:`${this.id}-slider-container`},this._slider.render())}_renderHistogram(){return h(`div`,{class:_.histogramContainer},this._histogram.render())}_getDataLines(){return[...this._getStandardDeviationDataLines(),...this.dataLines||[]]}_getStandardDeviationDataLines(){let{average:e,standardDeviation:t,standardDeviationCount:n}=this;return f(t,e,n).map(e=>({value:e}))}_updateBarFills(){this._barElements.forEach((e,t)=>this._updateBarFill(t,e))}_updateBarFill(e,t){t.setAttribute(`fill`,this._getFillForBar(e)?.toHex()??``)}_getFillForBar(e){let{bins:t,rangeType:n,values:r}=this;if(e===-1||!t?.length||!n||!r?.length)return null;let i=t[e];if(!i)return null;let{maxValue:a,minValue:o}=i,s=a-o,c=r[0]>o&&r[0]<a;switch(n){case`equal`:case`not-equal`:return this.includedBarColor;case`less-than`:case`at-most`:return c?this._getBlendedColor((r[0]-o)/s):a<=r[0]?this.includedBarColor:this.excludedBarColor;case`greater-than`:case`at-least`:return c?this._getBlendedColor(1-(r[0]-o)/s):o>=r[0]?this.includedBarColor:this.excludedBarColor;case`between`:if(r.length===2)return r[0]>o&&r[0]<a?this._getBlendedColor(1-(r[0]-o)/s):r[1]>o&&r[1]<a?this._getBlendedColor((r[1]-o)/s):o>=r[0]&&a<=r[1]?this.includedBarColor:this.excludedBarColor;break;case`not-between`:if(r.length===2)return r[0]>o&&r[0]<a?this._getBlendedColor((r[0]-o)/s):r[1]>o&&r[1]<a?this._getBlendedColor(1-(r[1]-o)/s):o>r[0]&&a<r[1]?this.excludedBarColor:this.includedBarColor}return this.includedBarColor}_getBlendedColor(e){return t.blendColors(this.excludedBarColor,this.includedBarColor,e)}};e([a()],v.prototype,`average`,null),e([a()],v.prototype,`barCreatedFunction`,void 0),e([a()],v.prototype,`bins`,null),e([a()],v.prototype,`dataLines`,void 0),e([a()],v.prototype,`dataLineCreatedFunction`,void 0),e([a({type:t,json:{type:[s],write:!0}})],v.prototype,`excludedBarColor`,void 0),e([a()],v.prototype,`hasTimeData`,null),e([a({type:t,json:{type:[s],write:!0}})],v.prototype,`includedBarColor`,void 0),e([a()],v.prototype,`icon`,null),e([a()],v.prototype,`label`,null),e([a()],v.prototype,`labelFormatFunction`,null),e([a()],v.prototype,`max`,null),e([a(),m(`esri/widgets/HistogramRangeSlider/t9n/HistogramRangeSlider`)],v.prototype,`messages`,void 0),e([a()],v.prototype,`min`,null),e([a()],v.prototype,`precision`,null),e([a()],v.prototype,`rangeType`,null),e([a()],v.prototype,`standardDeviation`,null),e([a()],v.prototype,`standardDeviationCount`,void 0),e([a()],v.prototype,`values`,null),e([a({type:d})],v.prototype,`viewModel`,void 0),v=e([o(`esri.widgets.HistogramRangeSlider`)],v);const y=v;export{y as default};
|
package/widgets/Legend.d.ts
CHANGED
|
@@ -114,6 +114,7 @@ export type LegendStyle = CardView | ClassicView;
|
|
|
114
114
|
* >
|
|
115
115
|
* > Currently, the legend widget does not support the following layer types:
|
|
116
116
|
* > [ElevationLayer](https://developers.arcgis.com/javascript/latest/references/core/layers/ElevationLayer/),
|
|
117
|
+
* > [GeospatialPDFLayer](https://developers.arcgis.com/javascript/latest/references/core/layers/GeospatialPDFLayer/)
|
|
117
118
|
* > [GraphicsLayer](https://developers.arcgis.com/javascript/latest/references/core/layers/GraphicsLayer/),
|
|
118
119
|
* > [IntegratedMeshLayer](https://developers.arcgis.com/javascript/latest/references/core/layers/IntegratedMeshLayer/),
|
|
119
120
|
* > [KMLLayer](https://developers.arcgis.com/javascript/latest/references/core/layers/KMLLayer/),
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
|
|
2
|
-
import{__decorate as e}from"tslib";import t from"../../../core/Error.js";import{Loadable as n}from"../../../core/Loadable.js";import{throwIfAborted as r}from"../../../core/promiseUtils.js";import{property as i,subclass as a}from"../../../core/accessorSupport/decorators.js";import{RasterJobHandlerMixin as o}from"../../../layers/mixins/RasterJobHandlerMixin.js";import{isTiffRaster as s}from"../utils.js";let c=class extends o(n){constructor(e){super(e)}load(e){return this.addResolvingPromise(this._fetchPixels(e)),Promise.resolve(this)}destroy(){this._source=null,this._mask=null}get height(){return this._get(`height`)}get width(){return this._get(`width`)}async _fetchPixels(e){let n=await(await import(`../../../layers/raster/datasets/RasterFactory.js`)).default.open({url:this.url,ioConfig:{skipExtensions:[`jgw`,`aux.xml`],skipMapInfo:!0,interpolation:`bilinear`},signal:e?.signal});if(r(e),n==null)throw new t(`depth-image-service:open-error`,`Failed to open depth image raster.`,{url:this.url});if(s(n)){let e=n.
|
|
2
|
+
import{__decorate as e}from"tslib";import t from"../../../core/Error.js";import{Loadable as n}from"../../../core/Loadable.js";import{throwIfAborted as r}from"../../../core/promiseUtils.js";import{property as i,subclass as a}from"../../../core/accessorSupport/decorators.js";import{RasterJobHandlerMixin as o}from"../../../layers/mixins/RasterJobHandlerMixin.js";import{isTiffRaster as s}from"../utils.js";let c=class extends o(n){constructor(e){super(e)}load(e){return this.addResolvingPromise(this._fetchPixels(e)),Promise.resolve(this)}destroy(){this._source=null,this._mask=null}get height(){return this._get(`height`)}get width(){return this._get(`width`)}async _fetchPixels(e){let n=await(await import(`../../../layers/raster/datasets/RasterFactory.js`)).default.open({url:this.url,ioConfig:{skipExtensions:[`jgw`,`aux.xml`],skipMapInfo:!0,interpolation:`bilinear`},signal:e?.signal});if(r(e),n==null)throw new t(`depth-image-service:open-error`,`Failed to open depth image raster.`,{url:this.url});if(s(n)){let e=n.headerInfo?.metadata?.rawMetadata,t=parseFloat(e?.get(`coefficientA`)),r=parseFloat(e?.get(`coefficientB`));!Number.isNaN(t)&&!Number.isNaN(r)&&(this.minDepth=t,this.maxDepth=r)}let{width:i,height:a}=n.rasterInfo;await this._initJobHandler(),r(e),n.rasterJobHandler=this._rasterJobHandler;let{pixelBlock:o}=await n.fetchPixels(n.rasterInfo.nativeExtent.clone(),i,a,{noClip:!1,signal:e?.signal});if(r(e),o==null)throw new t(`depth-image-service:fetch-error`,`Failed to fetch depth image pixels.`);this._set(`width`,o.width),this._set(`height`,o.height),this._source=o.pixels[0],this._mask=o.mask}_getDepthValue(e,t){let n=Math.max(1,Math.min(this.width,e)),r=Math.max(1,Math.min(this.height,t));return this._source[(r-1)*this.width+(n-1)]}_getMaskValue(e,t){let n=Math.max(1,Math.min(this.width,e)),r=Math.max(1,Math.min(this.height,t));return this._mask?this._mask[(r-1)*this.width+(n-1)]:255}_getValdity(e,t){return+(this._getMaskValue(e,t)>0)}_decompressDepthValue(e){if(this.minDepth!==void 0&&this.maxDepth!==void 0){let t=e/255;return this.minDepth+(this.maxDepth-this.minDepth)*t**3}return e}_interpolateDepth(e,t){let n=Math.floor(t),r=Math.floor(e),i=[[n,r],[Math.ceil(t),Math.floor(e)],[Math.floor(t),Math.ceil(e)],[Math.ceil(t),Math.ceil(e)]],a=[],o=[],s=[];for(let[n,r]of i)a.push(this._getValdity(n,r)),o.push(this._getDepthValue(n,r)),s.push((1-Math.abs(t-n))*(1-Math.abs(e-r)));if(!a.every(Boolean)){let e=(e,t,n)=>e+t*s[n],t=o.reduce(e,0),n=a.reduce(e,0);return n>=.5?this._decompressDepthValue(t/n):null}let c=this._decompressDepthValue(o[0]),l=this._decompressDepthValue(o[1]),u=this._decompressDepthValue(o[2]),d=this._decompressDepthValue(o[3]),f=t-n,p=e-r,m=c*(1-f)+l*f,h=u*(1-f)+d*f;return m*(1-p)+h*p}depthAt(e,t){if(!this.loaded||!this._source)throw Error(`DepthImageService must be loaded before sampling depth.`);let n=e.x/t.width*this.width,r=e.y/t.height*this.height;return this._interpolateDepth(r,n)}};e([i({readOnly:!0,value:0})],c.prototype,`height`,null),e([i()],c.prototype,`url`,void 0),e([i({readOnly:!0,value:0})],c.prototype,`width`,null),e([i()],c.prototype,`minDepth`,void 0),e([i()],c.prototype,`maxDepth`,void 0),c=e([a(`esri.widgets.OrientedImageryViewer.services.DepthImageService`)],c);const l=c;export{l as default};
|
|
@@ -6,6 +6,7 @@ import type SliderViewModel from "../Slider/SliderViewModel.js";
|
|
|
6
6
|
import type { MapViewOrSceneView } from "../../views/MapViewOrSceneView.js";
|
|
7
7
|
import type { SliderViewModelProperties } from "../Slider/SliderViewModel.js";
|
|
8
8
|
|
|
9
|
+
/** @deprecated since 5.2. Use the [arcgis-slider-scale-range](https://developers.arcgis.com/javascript/latest/references/map-components/components/arcgis-slider-scale-range/) component instead. */
|
|
9
10
|
export interface ScaleRangeSliderViewModelProperties extends Partial<Pick<ScaleRangeSliderViewModel, "layer" | "maxScaleLimit" | "minScaleLimit" | "view">> {
|
|
10
11
|
/**
|
|
11
12
|
* The maximum scale of the active scale range. When the maxScale
|
|
@@ -26,14 +27,16 @@ export interface ScaleRangeSliderViewModelProperties extends Partial<Pick<ScaleR
|
|
|
26
27
|
sliderViewModel?: SliderViewModelProperties;
|
|
27
28
|
}
|
|
28
29
|
|
|
30
|
+
/** @deprecated since 5.2. Use the [state](https://developers.arcgis.com/javascript/latest/references/map-components/components/arcgis-slider-scale-range/#state) property instead. */
|
|
29
31
|
export type ScaleRangeSliderViewModelState = "disabled" | "ready";
|
|
30
32
|
|
|
31
33
|
/**
|
|
32
|
-
* Provides the logic for the [ScaleRangeSlider](https://developers.arcgis.com/javascript/latest/references/core/widgets/ScaleRangeSlider/) widget
|
|
34
|
+
* Provides the logic for the [ScaleRangeSlider](https://developers.arcgis.com/javascript/latest/references/core/widgets/ScaleRangeSlider/) widget.
|
|
33
35
|
*
|
|
36
|
+
* @deprecated since version 5.2. Use the [arcgis-slider-scale-range](https://developers.arcgis.com/javascript/latest/references/map-components/components/arcgis-slider-scale-range/) component instead.
|
|
34
37
|
* @since 4.13
|
|
35
38
|
* @see [ScaleRangeSlider](https://developers.arcgis.com/javascript/latest/references/core/widgets/ScaleRangeSlider/) widget
|
|
36
|
-
* @see [Scale Range Slider component](https://developers.arcgis.com/javascript/latest/references/map-components/components/arcgis-scale-range
|
|
39
|
+
* @see [Scale Range Slider component](https://developers.arcgis.com/javascript/latest/references/map-components/components/arcgis-slider-scale-range/)
|
|
37
40
|
* @see [ScaleRanges](https://developers.arcgis.com/javascript/latest/references/core/widgets/ScaleRangeSlider/ScaleRanges/)
|
|
38
41
|
* @see [Programming patterns: Widget viewModel pattern](https://developers.arcgis.com/javascript/latest/programming-patterns/#widget-viewmodel-pattern)
|
|
39
42
|
*/
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
|
|
2
|
-
import{__decorate as e}from"tslib";import t from"../../core/Accessor.js";import{watch as
|
|
2
|
+
import{__decorate as e}from"tslib";import t from"../../core/Accessor.js";import{deprecateUnnecessaryViewModel as n}from"../../core/deprecate.js";import r from"../../core/Logger.js";import{watch as i,initial as a}from"../../core/reactiveUtils.js";import{property as o,subclass as s}from"../../core/accessorSupport/decorators.js";import c from"./ScaleRanges.js";import l from"../Slider/SliderViewModel.js";let u=class extends t{constructor(e){super(e),this.layer=null,this.mode=`range`,this.scaleRanges=c.fromScaleRange({minScale:0,maxScale:0}),this.sliderViewModel=(()=>{let{max:e}=this._getSliderIndexRange(this.scaleRanges.length-1);return new l({suppressDeprecationWarning:!0,precision:10,min:0,max:e,values:[0,e]})})(),e?.suppressDeprecationWarning||n(r.getLogger(this),`Scale Range Slider`,`arcgis-slider-scale-range`,{version:`5.2`})}normalizeCtorArgs(e){let{suppressDeprecationWarning:t,...n}=e??{};return n}initialize(){this.addHandles([i(()=>this.layer,e=>e?.load().catch(()=>{})),i(()=>this.mode,e=>{e===`range`&&this.sliderViewModel.values?.length===1?this.sliderViewModel.values=[this.sliderViewModel.min,this.sliderViewModel.values[0]]:this.sliderViewModel.values?.length===2&&(e===`min-scale-only`?this.sliderViewModel.values=[this.sliderViewModel.values[0]]:e===`max-scale-only`&&(this.sliderViewModel.values=[this.sliderViewModel.values[1]]))}),i(()=>({loaded:this.layer?.loaded,ready:this.view?.ready}),({loaded:e,ready:t})=>{if(!e||!t)return;if(this._hasTiledLayer()){let e=this._getLayerResampling()?void 0:this.mapScaleToSlider(this._getTiledLayerMaxScale()),t=this.mapScaleToSlider(this._getTiledLayerMinScale());this.sliderViewModel.effectiveMax=e,this.sliderViewModel.effectiveMin=t}else{let{minScale:e=0,maxScale:t=0}=(this.layer&&`maxScaleRange`in this.layer?this.layer.maxScaleRange:null)??{};this.sliderViewModel.effectiveMax=t===0?void 0:this.mapScaleToSlider(t),this.sliderViewModel.effectiveMin=e===0?void 0:this.mapScaleToSlider(e)}let n=this.layer;n&&`minScale`in n&&`maxScale`in n?(this.minScale=n.minScale,this.maxScale=n.maxScale):(this.minScale=void 0,this.maxScale=void 0)},a)])}get effectiveMaxScale(){return this.maxScale===0?this.maxScaleLimit:this.maxScale}get effectiveMinScale(){return this.minScale===0?this.minScaleLimit:this.minScale}get effectiveMaxScaleLimit(){return this.mapSliderToScale(this.sliderViewModel.effectiveMax??this.sliderViewModel.max)}get effectiveMinScaleLimit(){return this.mapSliderToScale(this.sliderViewModel.effectiveMin??this.sliderViewModel.min)}get maxScale(){return this._getScale(`max`)}set maxScale(e){this._setMaxScaleOnSlider(e)}get maxScaleLimit(){return this.mapSliderToScale(this.sliderViewModel.max)}set maxScaleLimit(e){this._setSliderRange({maxScale:e,minScale:this.minScaleLimit})}get minScale(){return this._getScale(`min`)}set minScale(e){this._setMinScaleOnSlider(e)}get minScaleLimit(){return this.mapSliderToScale(this.sliderViewModel.min)}set minScaleLimit(e){this._setSliderRange({maxScale:this.maxScaleLimit,minScale:e})}get state(){let{view:e,layer:t}=this;return!e&&!t||!e&&t?.loaded||!t&&e?.ready||e&&e.ready&&t?.loaded?`ready`:`disabled`}set view(e){this._set(`view`,e)}mapScaleToSlider(e){let t=this.scaleRanges.scaleToRangeIndex(e),{maxScale:n,minScale:r}=this.scaleRanges.findScaleRangeByIndex(t),{max:i,min:a}=this._getSliderIndexRange(t);return this._mapToRange(e,r,n,a,i)}mapSliderToScale(e){let{maxScale:t,minScale:n}=this.scaleRanges.findScaleRangeByIndex(e),{max:r,min:i}=this._getSliderIndexRange(e);return this._mapToRange(e,i,r,n,t)}_setSliderRange(e){this.scaleRanges=c.fromScaleRange(e);let{max:t}=this._getSliderIndexRange(this.scaleRanges.length-1);this.sliderViewModel.max=t,this.sliderViewModel.min=0,this._set(`minScaleLimit`,this.mapSliderToScale(this.sliderViewModel.min)),this._set(`maxScaleLimit`,this.mapSliderToScale(this.sliderViewModel.max))}_getSliderIndexRange(e){let t=Math.floor(e);return{min:t,max:t+.99999}}_mapToRange(e,t,n,r,i){return r+(e-t)*(i-r)/(n-t)}_getSliderValue(e){let{min:t,max:n,values:r}=this.sliderViewModel;if(!r)return e===`min`?t:n;let[i,a]=r;switch(this.mode){case`max-scale-only`:return e===`min`?t:i;case`min-scale-only`:return e===`min`?i:n;default:return e===`min`?i??t:a??n}}_getScale(e){let t=this.mapSliderToScale(this._getSliderValue(e));return this._normalizeScale(e,t)}_setMaxScaleOnSlider(e){let{scaleRanges:t,sliderViewModel:n}=this;if(e!==void 0){let r=this.mapScaleToSlider(this._constrainMaxScaleToLayer(t.clampMaxScale(e)));switch(this.mode){case`range`:n.values=[n.values[0],r];break;case`max-scale-only`:n.values=[r]}}}_setMinScaleOnSlider(e){let{scaleRanges:t,sliderViewModel:n}=this;if(e!==void 0){let r=this.mapScaleToSlider(this._constrainMinScaleToLayer(t.clampMinScale(e)));switch(this.mode){case`range`:n.values=[r,n.values[1]];break;case`min-scale-only`:n.values=[r]}}}_constrainMinScaleToLayer(e){let{scaleRanges:t}=this;if(this._hasTiledLayer()){let{firstRange:n}=t,r=this._getTiledLayerMinScale();e=this._mapToRange(e,n.maxScale,n.minScale,0,1)>.85||e>r?r:e}return e}_constrainMaxScaleToLayer(e){if(this._hasTiledLayer()&&!this._getLayerResampling()){let t=this._getTiledLayerMaxScale();e=e<t?t:e}return e}_normalizeScale(e,t){let n=e===`max`?`maxScale`:`minScale`,r=this._hasTiledLayer()?e===`min`?this._getTiledLayerMinScale():this._getTiledLayerMaxScale():this.scaleRanges[n],i=this._hasTiledLayer()?e===`min`?this._getTiledLayerRealMinScale():this._getTiledLayerRealMaxScale():r,a=t===0||i===t||Math.abs(i-t)<=1e-6?0:t;return Number(a.toFixed(6))}_getLayerLODS(){let{layer:e}=this;return!e?.loaded||!(`tileInfo`in e)||e.type===`wcs`||e.type===`imagery-tile`&&e.raster?.tileType===`Raster`?null:e.tileInfo?.lods}_getLayerResampling(){return this.layer?.loaded?`resampling`in this.layer?this.layer.resampling:!0:!1}_getTiledLayerMinScale(){let e=this._getLayerLODS();return this.scaleRanges.clampMinScale(e[0].scale)}_getTiledLayerMaxScale(){let e=this._getLayerLODS();return e[e.length-1].scale}_getTiledLayerRealMinScale(){let e=this._getLayerLODS(),t=this.layer,n=t&&`sourceJSON`in t?t.sourceJSON?.tileInfo?.lods??e:e;return this.scaleRanges.clampMinScale(n[0].scale)}_getTiledLayerRealMaxScale(){let e=this._getLayerLODS(),t=this.layer,n=t&&`sourceJSON`in t?t.sourceJSON?.tileInfo?.lods??e:e;return n[n.length-1].scale}_hasTiledLayer(){return!!this._getLayerLODS()}};e([o({readOnly:!0})],u.prototype,`effectiveMaxScale`,null),e([o({readOnly:!0})],u.prototype,`effectiveMinScale`,null),e([o()],u.prototype,`effectiveMaxScaleLimit`,null),e([o()],u.prototype,`effectiveMinScaleLimit`,null),e([o()],u.prototype,`layer`,void 0),e([o()],u.prototype,`maxScale`,null),e([o()],u.prototype,`maxScaleLimit`,null),e([o()],u.prototype,`mode`,void 0),e([o()],u.prototype,`minScale`,null),e([o()],u.prototype,`minScaleLimit`,null),e([o()],u.prototype,`scaleRanges`,void 0),e([o({type:l})],u.prototype,`sliderViewModel`,void 0),e([o({readOnly:!0})],u.prototype,`state`,null),e([o()],u.prototype,`view`,null),u=e([s(`esri.widgets.ScaleRangeSlider.ScaleRangeSliderViewModel`)],u);const d=u;export{d as default};
|