@arcgis/core 4.33.0-next.20250225 → 4.33.0-next.20250227

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.
Files changed (97) hide show
  1. package/assets/esri/core/workers/RemoteClient.js +1 -1
  2. package/assets/esri/core/workers/chunks/4253438dd3045566892d.js +1 -0
  3. package/assets/esri/core/workers/chunks/823bf95f42cc42f20e22.js +1 -0
  4. package/assets/esri/core/workers/chunks/ae25c6108918d37e61bf.js +1 -0
  5. package/assets/esri/core/workers/chunks/{feb656f172ec9fe64752.js → af005704f23088db3ded.js} +1 -1
  6. package/assets/esri/core/workers/chunks/{dea40706ca4e37d5c6e2.js → d4d011eea16a89a5aad9.js} +1 -1
  7. package/core/sql/StandardizedFunctions.js +1 -1
  8. package/core/sql/WhereClause.js +1 -1
  9. package/core/sql/sqlCompareUtils.js +1 -1
  10. package/geometry/SpatialReference.js +1 -1
  11. package/layers/SubtypeGroupLayer.js +1 -1
  12. package/package.json +1 -1
  13. package/support/popupUtils.js +1 -1
  14. package/support/revision.js +1 -1
  15. package/symbols/cim/animationUtils.js +1 -1
  16. package/views/2d/engine/webgl/animations/utils.js +1 -1
  17. package/views/2d/engine/webgl/shaderGraph/GraphShaderModule.js +1 -1
  18. package/views/2d/engine/webgl/shaderGraph/techniques/animated/AnimatedMarkerShader.js +1 -1
  19. package/views/2d/engine/webgl/shaderGraph/techniques/dotDensity/DotDensityPointShader.js +1 -1
  20. package/views/2d/engine/webgl/shaderGraph/techniques/dotDensity/DotDensityPolygonShader.js +1 -1
  21. package/views/2d/engine/webgl/shaderGraph/techniques/markers/MarkerShader.js +1 -1
  22. package/views/2d/engine/webgl/shaderGraph/techniques/shaders/BitmapShader.js +1 -1
  23. package/views/2d/engine/webgl/shaderGraph/techniques/shaders/BlendShader.js +1 -1
  24. package/views/2d/engine/webgl/shaderGraph/techniques/shaders/ComplexFillShader.js +1 -1
  25. package/views/2d/engine/webgl/shaderGraph/techniques/shaders/ComplexOutlineFillShader.js +1 -1
  26. package/views/2d/engine/webgl/shaderGraph/techniques/shaders/FillShader.js +1 -1
  27. package/views/2d/engine/webgl/shaderGraph/techniques/shaders/GradientFillShader.js +1 -1
  28. package/views/2d/engine/webgl/shaderGraph/techniques/shaders/GradientStrokeShader.js +1 -1
  29. package/views/2d/engine/webgl/shaderGraph/techniques/shaders/GridShader.js +1 -1
  30. package/views/2d/engine/webgl/shaderGraph/techniques/shaders/HeatmapAccumulateShader.js +1 -1
  31. package/views/2d/engine/webgl/shaderGraph/techniques/shaders/HeatmapResolveShader.js +1 -1
  32. package/views/2d/engine/webgl/shaderGraph/techniques/shaders/LineShader.js +1 -1
  33. package/views/2d/engine/webgl/shaderGraph/techniques/shaders/MagnifierShader.js +1 -1
  34. package/views/2d/engine/webgl/shaderGraph/techniques/shaders/OpacityShader.js +1 -1
  35. package/views/2d/engine/webgl/shaderGraph/techniques/shaders/OutlineFillShader.js +1 -1
  36. package/views/2d/engine/webgl/shaderGraph/techniques/shaders/OverlayShader.js +1 -1
  37. package/views/2d/engine/webgl/shaderGraph/techniques/shaders/PatternFillShader.js +1 -1
  38. package/views/2d/engine/webgl/shaderGraph/techniques/shaders/PatternOutlineFillShader.js +1 -1
  39. package/views/2d/engine/webgl/shaderGraph/techniques/shaders/TestShader.js +1 -1
  40. package/views/2d/engine/webgl/shaderGraph/techniques/shaders/TexturedLineShader.js +1 -1
  41. package/views/2d/engine/webgl/shaderGraph/techniques/shaders/raster/RasterColorizerLUTShader.js +1 -1
  42. package/views/2d/engine/webgl/shaderGraph/techniques/shaders/raster/RasterColorizerShadedReliefShader.js +1 -1
  43. package/views/2d/engine/webgl/shaderGraph/techniques/shaders/raster/RasterColorizerStretchShader.js +1 -1
  44. package/views/2d/engine/webgl/shaderGraph/techniques/shaders/raster/processor/AspectShader.js +1 -1
  45. package/views/2d/engine/webgl/shaderGraph/techniques/shaders/raster/processor/BandArithmeticShader.js +1 -1
  46. package/views/2d/engine/webgl/shaderGraph/techniques/shaders/raster/processor/ColormapToRGBShader.js +1 -1
  47. package/views/2d/engine/webgl/shaderGraph/techniques/shaders/raster/processor/CompositeBandShader.js +1 -1
  48. package/views/2d/engine/webgl/shaderGraph/techniques/shaders/raster/processor/ComputeChangeShader.js +1 -1
  49. package/views/2d/engine/webgl/shaderGraph/techniques/shaders/raster/processor/ContrastBrightnessShader.js +1 -1
  50. package/views/2d/engine/webgl/shaderGraph/techniques/shaders/raster/processor/ConvolutionShader.js +1 -1
  51. package/views/2d/engine/webgl/shaderGraph/techniques/shaders/raster/processor/CurvatureShader.js +1 -1
  52. package/views/2d/engine/webgl/shaderGraph/techniques/shaders/raster/processor/ExtractBandShader.js +1 -1
  53. package/views/2d/engine/webgl/shaderGraph/techniques/shaders/raster/processor/FocalStatisticsShader.js +1 -1
  54. package/views/2d/engine/webgl/shaderGraph/techniques/shaders/raster/processor/GrayscaleShader.js +1 -1
  55. package/views/2d/engine/webgl/shaderGraph/techniques/shaders/raster/processor/HillshadeShader.js +1 -1
  56. package/views/2d/engine/webgl/shaderGraph/techniques/shaders/raster/processor/LocalShader.js +1 -1
  57. package/views/2d/engine/webgl/shaderGraph/techniques/shaders/raster/processor/MaskShader.js +1 -1
  58. package/views/2d/engine/webgl/shaderGraph/techniques/shaders/raster/processor/NDVIShader.js +1 -1
  59. package/views/2d/engine/webgl/shaderGraph/techniques/shaders/raster/processor/RemapShader.js +1 -1
  60. package/views/2d/engine/webgl/shaderGraph/techniques/shaders/raster/processor/ReprojectShader.js +1 -1
  61. package/views/2d/engine/webgl/shaderGraph/techniques/shaders/raster/processor/ShadedReliefShader.js +1 -1
  62. package/views/2d/engine/webgl/shaderGraph/techniques/shaders/raster/processor/SlopeShader.js +1 -1
  63. package/views/2d/engine/webgl/shaderGraph/techniques/shaders/raster/processor/StretchShader.js +1 -1
  64. package/views/2d/engine/webgl/shaderGraph/techniques/text/TextShader.js +1 -1
  65. package/views/3d/interactive/visualElements/OutlineVisualElement.js +1 -1
  66. package/views/3d/layers/support/FeatureTile.js +1 -1
  67. package/views/3d/layers/support/FeatureTileFetcher3D.js +1 -1
  68. package/views/3d/layers/support/FeatureTileFetcher3DContext.js +1 -1
  69. package/views/3d/layers/support/FeatureTileTree3D.js +1 -1
  70. package/views/3d/webgl-engine/lib/ComponentUtils.js +1 -1
  71. package/views/3d/webgl-engine/lib/Renderer.js +1 -1
  72. package/views/3d/webgl-engine/lib/RenderingContext.js +1 -1
  73. package/views/3d/webgl-engine/materials/renderers/MergedRenderer.js +1 -1
  74. package/views/View.js +1 -1
  75. package/views/support/TileTreeDebugger.js +1 -1
  76. package/views/webgl/capabilities/Capabilities.js +1 -1
  77. package/views/webgl/capabilities/DebugRendererInfo.js +1 -1
  78. package/views/webgl/capabilities.js +1 -1
  79. package/widgets/Feature/FeatureRelationship.js +1 -1
  80. package/widgets/Feature/FeatureUtilityNetworkAssociationList.js +1 -1
  81. package/widgets/Feature/FeatureUtilityNetworkAssociations.js +1 -1
  82. package/widgets/Feature.js +1 -1
  83. package/widgets/FeatureForm/FeatureFormUtilityNetworkAssociations/FeatureFormUtilityNetworkAssociationList.js +1 -1
  84. package/widgets/FeatureForm/FeatureFormUtilityNetworkAssociations/UtilityNetworkAssociationItemList.js +1 -1
  85. package/widgets/FeatureTable.js +1 -1
  86. package/widgets/Features/FeaturesDrillIn.js +1 -1
  87. package/widgets/Legend/support/ActiveLayerInfo.js +1 -1
  88. package/widgets/OrientedImageryViewer/OrientedImageryViewerViewModel.js +1 -1
  89. package/widgets/OrientedImageryViewer/adapters/sketch/DataCaptureAdapter.js +1 -1
  90. package/widgets/OrientedImageryViewer/components/ImageOverlays.js +1 -1
  91. package/widgets/OrientedImageryViewer/dataCaptureUtils.js +1 -1
  92. package/widgets/OrientedImageryViewer/symbols.js +1 -1
  93. package/widgets/OrientedImageryViewer.js +1 -1
  94. package/widgets/support/UtilityNetworkAssociations/utilityNetworkUtils.js +1 -1
  95. package/assets/esri/core/workers/chunks/66338f008ff0992ffca2.js +0 -1
  96. package/assets/esri/core/workers/chunks/69c13ca7b572ad2ca3ce.js +0 -1
  97. package/assets/esri/core/workers/chunks/d5ebe6b7cd9c8e40b386.js +0 -1
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../chunks/tslib.es6.js";import"../intl.js";import{isSome as t}from"../core/arrayUtils.js";import{watch as i,sync as l,initial as o,on as n}from"../core/reactiveUtils.js";import{formatFileSize as s}from"../core/unitFormatUtils.js";import{property as a}from"../core/accessorSupport/decorators/property.js";import"../core/has.js";import"../core/Logger.js";import{subclass as r}from"../core/accessorSupport/decorators/subclass.js";import{isLayerFromCatalog as c}from"../layers/catalog/catalogUtils.js";import{isKnowledgeGraphLayer as d,isSubtypeGroupLayer as h}from"../layers/support/layerUtils.js";import m from"../tables/AttributeTableTemplate.js";import p from"./Widget.js";import{isSupportedImage as u,getCalciteIconForAttachment as g}from"./Attachments/support/attachmentUtils.js";import{loadPromptComponents as b,Prompt as w}from"./Editor/components/Prompt.js";import v from"./FeatureTable/ColumnMenuVisibleElements.js";import y from"./FeatureTable/FeatureTableViewModel.js";import f from"./FeatureTable/VisibleElements.js";import{isGroupColumn as _}from"./FeatureTable/support/columnUtils.js";import{loadFieldColumnComponents as M,isIFeatureTableSupportedLayer as C,getIconForLayer as T,isIFeatureTableSupportedLayerWithAttachments as S,getRelationshipIdsToShow as A,isMapImageLayer as E}from"./FeatureTable/support/tableUtils.js";import{loadCalciteComponents as I}from"./support/componentsUtils.js";import{globalCss as V}from"./support/globalCss.js";import{renderingSanitizer as R,storeNode as k,discardNode as x}from"./support/widgetUtils.js";import{messageBundle as D}from"./support/decorators/messageBundle.js";import{vmEvent as P}from"./support/decorators/vmEvent.js";import{tsx as F}from"./support/jsxFactory.js";import{substitute as L}from"../intl/substitute.js";var j;const O="esri-feature-table",z=`${O}__prompt`,$=`${O}__attachments-view`,U={base:O,content:`${O}__content`,menuPopover:`${O}__menu-popover`,layerDropdownMenu:`${O}__layer-switcher-menu`,tableContainer:`${O}__table-container`,tableContainerWithAttachments:`${O}__table-container--attachments`,tableNavigation:`${O}__table-navigation`,attachmentsView:$,attachmentsViewContent:`${$}__content`,attachmentsViewDropArea:`${$}__drop-area`,attachmentsViewIcon:`${$}__icon`,attachmentsViewInformation:`${$}__information`,attachmentsViewList:`${$}__list`,attachmentsViewListFileSize:`${$}__list__filesize`,attachmentsViewListItemDelete:`${$}__list-item--delete`,attachmentsViewListThumbnail:`${$}__list__thumbnail`,expanded:`${O}__expanded`,collapsed:`${O}__collapsed`,promptContainer:z,promptHeader:`${z}__header`,promptHeading:`${z}__header__heading`,promptMessage:`${z}__message`,promptDivider:`${z}__divider`,promptActions:`${z}__actions`},B={attachment:"attachment",chevronDown:"chevron-down",chevronLeft:"chevron-left",chevronRight:"chevron-right",clearSelection:"clear-selection",downloadTo:"download-to",exclamationMarkTriangle:"exclamation-mark-triangle",exportToCSV:"file-csv",folderOpen:"folder-open",delete:"trash",launch:"launch",layers:"layers",moveUp:"move-up",plus:"plus",refresh:"refresh",replaceImage:"replace-image",save:"save",showAll:"selection-x",showColumn:"show-column",showSelected:"selection-filter",upload:"upload",zoomToSelection:"zoom-to-object"};let H=j=class extends p{constructor(e,t){super(e,t),this._attachmentsInput=null,this._columnVisibilityActions=new Map,this.attachmentsList=null,this.description=null,this.disabled=!1,this.menuConfig=null,this.title=null,this.viewModel=new y,this.visibleElements=new f,this._showDeletePrompt=this._showDeletePrompt.bind(this),this._onDeleteSelectionClick=this._onDeleteSelectionClick.bind(this)}initialize(){this.addHandles([i((()=>[this.viewModel.store.querying,this.viewModel.store.syncing,this.editingEnabled]),(()=>this.scheduleRender())),i((()=>[this._effectiveVisibleElements,this._effectiveVisibleElements.columnDescriptions,this._effectiveVisibleElements.columnMenus,this._effectiveVisibleElements.columnMenuItems,this.columns.length]),(()=>{this.columns.forEach((e=>e.visibleElements=this._effectiveVisibleElements)),this.refreshCellContent()}),l),i((()=>this._effectiveVisibleElements.selectionColumn),(e=>{this.grid&&(this.grid.selectionColumnEnabled=e)}),o),n((()=>this.viewModel),"show-related-table",(e=>this._onShowRelatedTable(e))),i((()=>this.editingEnabled),(()=>{const{attachmentsViewOptions:e}=this;this.clearPrompt(),e&&(e.form?.reset(),e.candidates=null)}))])}loadDependencies(){return Promise.all([I({action:()=>import("@esri/calcite-components/dist/components/calcite-action"),alert:()=>import("@esri/calcite-components/dist/components/calcite-alert"),button:()=>import("@esri/calcite-components/dist/components/calcite-button"),chip:()=>import("@esri/calcite-components/dist/components/calcite-chip"),dropdown:()=>import("@esri/calcite-components/dist/components/calcite-dropdown"),"dropdown-group":()=>import("@esri/calcite-components/dist/components/calcite-dropdown-group"),"dropdown-item":()=>import("@esri/calcite-components/dist/components/calcite-dropdown-item"),icon:()=>import("@esri/calcite-components/dist/components/calcite-icon"),label:()=>import("@esri/calcite-components/dist/components/calcite-label"),list:()=>import("@esri/calcite-components/dist/components/calcite-list"),"list-item":()=>import("@esri/calcite-components/dist/components/calcite-list-item"),pagination:()=>import("@esri/calcite-components/dist/components/calcite-pagination"),panel:()=>import("@esri/calcite-components/dist/components/calcite-panel"),popover:()=>import("@esri/calcite-components/dist/components/calcite-popover"),progress:()=>import("@esri/calcite-components/dist/components/calcite-progress"),switch:()=>import("@esri/calcite-components/dist/components/calcite-switch"),tooltip:()=>import("@esri/calcite-components/dist/components/calcite-tooltip")}),b(),M()])}destroy(){this.drainRelatedTables(),this.clearPrompt()}get _effectiveDescription(){const{description:e}=this;return null!=e?R.sanitize("function"==typeof e?e():e):void 0}get _effectiveLayers(){const{layer:e,layers:t}=this,i=t?.length?t.filter(C):[],l=i.length?i:[...this._viewLayers];return e&&!l.includes(e)&&l.push(e),l}get _effectiveTitle(){const{layer:e,messages:t,state:i,highlightIds:l,title:o,size:n}=this;if(o)return R.sanitize("function"==typeof o?o():o);if(!e)return t.noLayer;switch(i){case"disabled":return t.errorLayer;case"ready":case"loading":return t.loading;case"error":return t.errorData}return L(t.header,{title:R.sanitize(e.title),count:n,selected:l.length})}get _effectiveVisibleElements(){return this.visibleElementsOverride??this.visibleElements}get _filteredTables(){const e=this.relatedTables.toArray(),t=1===e.length;return this.allRelatedTablesVisible?e:t?[e[0]]:this._shouldShowAttachmentsView?e.slice(-1):e.slice(-2)}get _hasAttachmentsViewError(){return null!=this.attachmentsViewOptions.error}get _hasCustomMenuItems(){return!!this.menuConfig?.items?.length}get _hasDefaultMenuItems(){return!!(this._showClearSelectionAction||this._showDeleteSelectionAction||this._showExportSelectionToCSVAction||this._showRefreshDataAction||this._showZoomToSelectionAction||this._showSelectedRecordsShowSelectedAction||this._showSelectedRecordsShowAllAction||this._showColumnsVisibilityAction)}get _shouldShowGrid(){return this.allRelatedTablesVisible||1===this.relatedTables.length&&!this._shouldShowAttachmentsView}get _shouldShowMenu(){const{header:e,menu:t}=this._effectiveVisibleElements;return!(!e||!t||!this._hasDefaultMenuItems&&!this._hasCustomMenuItems)}get _shouldShowAttachmentsView(){return!(null==this.attachmentsViewOptions.objectId&&!this.relatedTables.some((e=>null!=e.attachmentsViewOptions.objectId)))}get _showClearSelectionAction(){return!(!this.highlightIds.length||!this._effectiveVisibleElements.menuItems?.clearSelection||this.relatedTables.length)}get _showColumnsVisibilityAction(){const{header:e,menu:t,menuItems:i}=this._effectiveVisibleElements;return!(!(e&&t&&i?.toggleColumns)||this.showRelatedTableCallback||this.allRelatedTablesVisible||this._shouldShowAttachmentsView)}get _showDeleteSelectionAction(){return!(!(this.editingEnabled&&this.highlightIds.length&&this._effectiveVisibleElements.menuItems?.deleteSelection&&this.layer?.capabilities?.operations?.supportsDelete)||this.relatedTables.length)}get _showExportSelectionToCSVAction(){return!(!(this._effectiveVisibleElements.menuItems.exportSelectionToCSV&&this.layer&&this.highlightIds.length)||this.relatedTables.length)}get _showLayerDropdown(){return!(!this._effectiveLayers.length||!this._effectiveVisibleElements.layerDropdown)}get _shouldShowNavigationBar(){const e=!!this.relatedTable||this._shouldShowAttachmentsView;return!this.tableParent&&e}get _showRefreshDataAction(){return!!this._effectiveVisibleElements.menuItems?.refreshData}get _showSelectedRecordsShowSelectedAction(){const e=this.objectIds.length,t=this.highlightIds.length;return!(!t||!this._effectiveVisibleElements.menuItems?.selectedRecordsShowSelectedToggle||e&&t===e||this.relatedTables.length)}get _showSelectedRecordsShowAllAction(){return!(!this._effectiveVisibleElements.menuItems?.selectedRecordsShowAllToggle||!this.objectIds.length||this.relatedTables.length)}get _showZoomToSelectionAction(){return!(!this.view||!this.highlightIds.length||this.effectiveTable.layer?.isTable||!this._effectiveVisibleElements.menuItems?.zoomToSelection)}get _viewLayers(){const e=this.view?.map;if(!e)return[];const t=new Set,i=e=>{!C(e)||h(e)||t.has(e)||t.add(e)},l=e=>{c(e)||"catalog-footprint"===e.type||(d(e)?(e.layers?.forEach(i),e.tables?.forEach(i)):E(e)?(e.sublayers?.forEach(i),e.subtables?.forEach(i)):h(e)?e.sublayers?.forEach(i):i(e))};return e.allLayers.forEach(l),e.allTables.forEach(l),[...t.values()]}get grid(){return this.viewModel.grid}get actionColumnConfig(){return this.viewModel.actionColumnConfig}set actionColumnConfig(e){this.viewModel.actionColumnConfig=e}get activeFilters(){return this.viewModel.activeFilters}get activeSortOrders(){return this.viewModel.activeSortOrders}get allColumns(){return this.viewModel.allColumns}get allRelatedTablesVisible(){return this.viewModel.allRelatedTablesVisible}get attachmentsEnabled(){return this.viewModel.attachmentsEnabled}set attachmentsEnabled(e){this.viewModel.attachmentsEnabled=e}get attachmentsViewOptions(){return this.viewModel.attachmentsViewOptions}set attachmentsViewOptions(e){this.viewModel.attachmentsViewOptions=e}get attributeTableTemplate(){return this.viewModel.attributeTableTemplate}set attributeTableTemplate(e){this.viewModel.attributeTableTemplate=e}get autoRefreshEnabled(){return this.viewModel.autoRefreshEnabled}set autoRefreshEnabled(e){this.viewModel.autoRefreshEnabled=e}get clearPrompt(){return this.viewModel.clearPrompt}set clearPrompt(e){this.viewModel.clearPrompt=e}get columnPerformanceModeEnabled(){return this.viewModel.columnPerformanceModeEnabled}set columnPerformanceModeEnabled(e){this.viewModel.columnPerformanceModeEnabled=e}get columnReorderingEnabled(){return this.viewModel.columnReorderingEnabled}set columnReorderingEnabled(e){this.viewModel.columnReorderingEnabled=e}get columns(){return this.viewModel.columns}get editingEnabled(){return this.viewModel.editingEnabled}set editingEnabled(e){this.viewModel.editingEnabled=e}get effectiveSize(){return this.viewModel.effectiveSize}get effectiveTable(){return this.relatedTable||this}get filterGeometry(){return this.viewModel.filterGeometry}set filterGeometry(e){this.viewModel.filterGeometry=e}get filterBySelectionEnabled(){return this.viewModel.filterBySelectionEnabled}set filterBySelectionEnabled(e){this.viewModel.filterBySelectionEnabled=e}get hiddenFields(){return this.viewModel.hiddenFields}set hiddenFields(e){this.viewModel.hiddenFields=e}get highlightEnabled(){return this.viewModel.highlightEnabled}set highlightEnabled(e){this.viewModel.highlightEnabled=e}get highlightIds(){return this.viewModel.highlightIds}set highlightIds(e){this.viewModel.highlightIds=e}get icon(){return"table"}set icon(e){this._overrideIfSome("icon",e)}get initialSize(){return this.viewModel.initialSize}set initialSize(e){this.viewModel.initialSize=e}get isQueryingOrSyncing(){return this.viewModel.isQueryingOrSyncing}get isSyncingAttachments(){return this.viewModel.isSyncingAttachments}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get layer(){return this.viewModel.layer}set layer(e){this.viewModel.layer=e}get layers(){return this.viewModel.layers}set layers(e){this.viewModel.layers=e}get layerView(){return this.viewModel.layerView}get maxSize(){return this.viewModel.maxSize}set maxSize(e){this.viewModel.maxSize=e}get messages(){return this.viewModel.messages}set messages(e){this.viewModel.messages=e}get messagesCommon(){return this.viewModel.messagesCommon}set messagesCommon(e){this.viewModel.messagesCommon=e}get messagesUnits(){return this.viewModel.messagesUnits}set messagesUnits(e){this.viewModel.messagesUnits=e}get messagesURIUtils(){return this.viewModel.messagesURIUtils}set messagesURIUtils(e){this.viewModel.messagesURIUtils=e}get multipleSelectionEnabled(){return this.viewModel.multipleSelectionEnabled}set multipleSelectionEnabled(e){this.viewModel.multipleSelectionEnabled=e}get multiSortEnabled(){return this.viewModel.multiSortEnabled}set multiSortEnabled(e){this.viewModel.multiSortEnabled=e}get objectIds(){return this.viewModel.objectIds}set objectIds(e){this.viewModel.objectIds=e}get outFields(){return this.viewModel.outFields}set outFields(e){this.viewModel.outFields=e}get pageCount(){return this.viewModel.pageCount}get pageIndex(){return this.viewModel.pageIndex}set pageIndex(e){this.viewModel.pageIndex=e}get pageSize(){return this.viewModel.pageSize}set pageSize(e){this.viewModel.pageSize=e}get paginationEnabled(){return this.viewModel.paginationEnabled}set paginationEnabled(e){this.viewModel.paginationEnabled=e}get prompt(){return this.viewModel.prompt}set prompt(e){this.viewModel.prompt=e}get relatedRecordsEnabled(){return this.viewModel.relatedRecordsEnabled}set relatedRecordsEnabled(e){this.viewModel.relatedRecordsEnabled=e}get relatedTable(){return this.viewModel.relatedTable}get relatedTables(){return this.viewModel.relatedTables}set relatedTables(e){this.viewModel.relatedTables=e}get relationship(){return this.viewModel.relationship}get relationshipColumnConfigs(){return this.viewModel.relationshipColumnConfigs}set relationshipColumnConfigs(e){this.viewModel.relationshipColumnConfigs=e}get relationshipConfig(){return this.viewModel.relationshipConfig}set relationshipConfig(e){this.viewModel.relationshipConfig=e}get relationshipInfos(){return this.viewModel.relationshipInfos}get returnGeometryEnabled(){return this.viewModel.returnGeometryEnabled}set returnGeometryEnabled(e){this.viewModel.returnGeometryEnabled=e}get returnMEnabled(){return this.viewModel.returnMEnabled}set returnMEnabled(e){this.viewModel.returnMEnabled=e}get returnZEnabled(){return this.viewModel.returnZEnabled}set returnZEnabled(e){this.viewModel.returnZEnabled=e}get rowHighlightIds(){return this.viewModel.rowHighlightIds}set rowHighlightIds(e){this.viewModel.rowHighlightIds=e}get selectionSource(){return this.viewModel.selectionSource}set selectionSource(e){this.viewModel.selectionSource=e}get showAllRelatedTables(){return this.viewModel.showAllRelatedTables}set showAllRelatedTables(e){this.viewModel.showAllRelatedTables=e}get showPrompt(){return this.viewModel.showPrompt}set showPrompt(e){this.viewModel.showPrompt=e}get showRelatedTableCallback(){return this.viewModel.showRelatedTableCallback}set showRelatedTableCallback(e){this.viewModel.showRelatedTableCallback=e}get size(){return this.viewModel.size}get state(){return this.viewModel.state}get tableController(){return this.viewModel.tableController}set tableController(e){this.viewModel.tableController=e}get tableParent(){return this.viewModel.tableParent}set tableParent(e){this.viewModel.tableParent=e}get tableTemplate(){return this.viewModel.tableTemplate}set tableTemplate(e){this.viewModel.tableTemplate=e}get tableTemplateOverride(){return this.viewModel.tableTemplateOverride}set tableTemplateOverride(e){this.viewModel.tableTemplateOverride=e}get timeExtent(){return this.viewModel.timeExtent}set timeExtent(e){this.viewModel.timeExtent=e}get timeZone(){return this.viewModel.timeZone}set timeZone(e){this.viewModel.timeZone=e}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}get visibleElementsOverride(){const{attachmentsViewOptions:e,relatedTable:t,tableController:i,visibleElements:l}=this,{columnDescriptions:o,columnMenus:n,tooltips:s}=l,a=null!=e.objectId;if(t)return new f({columnDescriptions:o,columnMenus:n,tooltips:s,close:l.close,header:l.header,layerDropdown:l.layerDropdown,layerDropdownIcons:l.layerDropdownIcons,menu:l.menu,menuItems:l.menuItems,progress:l.progress,selectionColumn:!1,columnMenuItems:new v({sortAscending:!1,sortDescending:!1})});if(i){const e=i.relatedTable===this,t=i.allRelatedTablesVisible,r=e&&l.selectionColumn&&!t&&!a,c=e&&!t&&!a;return new f({columnDescriptions:o,columnMenus:n,tooltips:s,selectionColumn:r,close:!1,header:!1,layerDropdown:!1,menu:!1,progress:!1,columnMenuItems:new v({sortAscending:c,sortDescending:c})})}return a?new f({columnDescriptions:o,columnMenus:n,tooltips:s,close:l.close,header:l.header,layerDropdown:l.layerDropdown,layerDropdownIcons:l.layerDropdownIcons,menu:l.menu,menuItems:l.menuItems,progress:l.progress,selectionColumn:!1,columnMenuItems:new v({sortAscending:!1,sortDescending:!1})}):null}clearSelectionFilter(){this.viewModel.clearSelectionFilter()}async deleteAttachments(e,t,i){null!=e&&t?.length&&(i?this._showDeleteAttachmentPrompt(e,t):await this.viewModel.deleteAttachments(e,t))}deleteSelection(e){return this.highlightIds.length?e?(this._showDeletePrompt(),this.scheduleRender(),Promise.resolve()):this.viewModel.deleteSelection():Promise.resolve()}async downloadAttachmentById(e,t){return this.viewModel.downloadAttachmentById(e,t)}drainRelatedTables(){this.viewModel.drainRelatedTables()}exportSelectionToCSV(e){return this.viewModel.exportSelectionToCSV(e)}filterBySelection(){this.viewModel.filterBySelection()}findColumn(e){return this.viewModel.findColumn(e)}goToPage(e){this.viewModel.goToPage(e)}hideColumn(e){this.grid?.hideColumn(e)}nextPage(){this.viewModel.nextPage()}previousPage(){this.viewModel.previousPage()}async refresh(){await this.viewModel.refresh()}refreshCellContent(){this.viewModel.refreshCellContent()}async saveAttachmentsViewForm(){await this.viewModel.saveAttachmentsViewForm()}showAllColumns(){this.viewModel.showAllColumns()}showColumn(e){this.grid?.showColumn(e)}sortColumn(e,t){this.viewModel.sortColumn(e,t)}scrollLeft(){this.viewModel.scrollLeft()}scrollToBottom(){this.viewModel.scrollToBottom()}scrollToIndex(e){this.viewModel.scrollToIndex(e)}scrollToRow(e){this.viewModel.scrollToRow(e)}scrollToTop(){this.viewModel.scrollToTop()}toggleColumnVisibility(e){this.viewModel.toggleColumnVisibility(e)}zoomToSelection(){this.effectiveTable.viewModel.zoomToSelection()}render(){const{_effectiveVisibleElements:e,isQueryingOrSyncing:t,menuConfig:i,state:l}=this;return F("div",{bind:this,class:this.classes(U.base,V.widget)},F("calcite-panel",{bind:this,class:U.content,closable:e.close,description:this._effectiveDescription,disabled:this.disabled||"disabled"===l&&!this._effectiveLayers?.length,heading:e.header?this._effectiveTitle:void 0,loading:"loading"===l,menuOpen:!!i?.open,overlayPositioning:"fixed",onCalcitePanelClose:e=>{e.currentTarget.closed=!1,this.emit("close")}},e.progress?F("calcite-progress",{type:t?"indeterminate":"determinate"}):null,this._showLayerDropdown?this._renderLayerDropdown():null,this._renderColumnVisibilityAction(),this._renderHeaderMenuActions(),this._renderNavigationBar(),this._renderTables(),this._renderError()),this._renderColumnVisibilityPopover(),this._renderPrompt())}_renderTables(){const{grid:e,relatedTables:t}=this,i=this.classes(U.tableContainer);if(t.length){const l=this.classes(U.base,this.allRelatedTablesVisible?U.expanded:U.collapsed,this._shouldShowAttachmentsView?U.tableContainerWithAttachments:void 0);return F("div",{class:i},F("calcite-panel",{overlayPositioning:"fixed"},F("div",null,[this._shouldShowGrid?F("div",{class:l},e?.render(),this._renderPagination()):void 0,...this._filteredTables.map((e=>{const i=t.indexOf(e);return F("div",{class:l,key:`related-${i}`},e.render())})),,])))}return null!=this.attachmentsViewOptions.objectId?F("div",{class:i},F("calcite-panel",{overlayPositioning:"fixed"},F("div",null,[F("div",{class:this.classes(U.base,U.collapsed)},e?.render(),this._renderPagination()),this._renderAttachmentsView()]))):[F("div",{class:i},e?.render()),this._renderPagination()]}_renderPagination(){if(this.paginationEnabled)return F("calcite-pagination",{pageSize:1,startItem:this.pageIndex+1,totalItems:this.pageCount,onCalcitePaginationChange:e=>this.goToPage(e.currentTarget.startItem-1)})}_renderError(){const{messages:e}=this;return F("calcite-alert",{autoClose:!0,autoCloseDuration:"fast",icon:B.exclamationMarkTriangle,kind:"danger",label:e.errorOccured,open:this._hasAttachmentsViewError,slot:"alerts",onCalciteAlertClose:()=>{this.attachmentsViewOptions.error=null}},F("span",{slot:"message"},e.errorOccured))}_renderPrompt(){return this.prompt?F(w,{...this.prompt,headingLevel:2}):void 0}_showDeletePrompt(){const{messages:e,messagesCommon:t}=this,i=L(e.deleteSelectionCount,{count:this.highlightIds.length});this.showPrompt({title:i,message:e.deleteRecordsRemoved,context:"danger",actions:{primary:{label:t.delete,action:this._onDeleteSelectionClick},secondary:{label:e.keepRecords,action:()=>this.clearPrompt()}}})}_showDeleteAttachmentPrompt(e,t){const{messages:i,messagesCommon:l}=this,o=L(i.deleteAttachmentCount,{count:t.length});this.showPrompt({title:o,message:i.deleteAttachmentConfirmation,context:"danger",actions:{primary:{label:l.delete,action:async()=>{try{await this.deleteAttachments(e,t,!1)}finally{this.clearPrompt()}}},secondary:{label:l.cancel,action:()=>this.clearPrompt()}}})}async _onDeleteSelectionClick(){try{await this.viewModel.deleteSelection()}finally{this.clearPrompt()}}_renderHeaderMenuAction(e){const{disabled:t,hidden:i,icon:l,text:o,clickFunction:n}=e;if(!i)return F("calcite-action",{disabled:t??this.menuConfig?.disabled,icon:l??void 0,key:o,onclick:()=>n(),slot:"header-menu-actions",text:o,textEnabled:!0,title:o})}_renderHeaderMenuActions(){return this._shouldShowMenu?[this._renderDefaultHeaderMenuActions(),this._renderCustomHeaderMenuActions()]:[]}_renderDefaultHeaderMenuActions(){if(!this._hasDefaultMenuItems)return[];const{messages:e}=this;return[this._showRefreshDataAction&&{icon:B.refresh,text:e.refreshData,clickFunction:()=>this.refresh()},this._showDeleteSelectionAction&&{icon:B.delete,text:e.deleteSelection,clickFunction:()=>this.deleteSelection(!0)},this._showClearSelectionAction&&{icon:B.clearSelection,text:e.clearSelection,clickFunction:()=>this.highlightIds?.removeAll()},this._showZoomToSelectionAction&&{icon:B.zoomToSelection,text:e.zoomToSelection,clickFunction:()=>this.zoomToSelection()},this._showSelectedRecordsShowSelectedAction&&{icon:B.showSelected,text:e.showSelected,clickFunction:()=>{const{objectIds:e}=this;e.removeAll(),e.addMany(this.highlightIds.toArray())}},this._showSelectedRecordsShowAllAction&&{icon:B.showAll,text:e.showAllRecords,clickFunction:()=>this.objectIds.removeAll()},this._showExportSelectionToCSVAction&&{icon:B.exportToCSV,text:e.exportSelectionCSV,clickFunction:()=>this.exportSelectionToCSV()}].filter(t).map((e=>e&&this._renderHeaderMenuAction(e)))}_renderCustomHeaderMenuActions(){return this.menuConfig?.items?.map((({disabled:e,hidden:t,icon:i,label:l,clickFunction:o})=>this._renderHeaderMenuAction({hidden:"function"==typeof t?t():t,icon:i,text:l,disabled:e,clickFunction:e=>o(e)})))??[]}_renderColumnVisibilityAction(){if(!this._showColumnsVisibilityAction)return[];const{_columnVisibilityActions:e,effectiveTable:t,id:i}=this,l=this.messages.toggleColumns;return F("calcite-action",{afterCreate:t=>e.set(i,t),afterRemoved:()=>e.delete(i),appearance:"transparent",bind:this,disabled:t.menuConfig?.disabled,icon:B.showColumn,id:`${i}__toggle-columns-action`,slot:"header-actions-end",text:l},this._effectiveVisibleElements.tooltips?F("calcite-tooltip",{closeOnClick:!0,overlayPositioning:"fixed",placement:"bottom-end",slot:"tooltip"},l):null)}_renderColumnVisibilityPopover(){if(!this._showColumnsVisibilityAction||this.effectiveTable.menuConfig?.disabled)return;const{effectiveTable:e}=this,t=this.messages.toggleColumns;return F("calcite-popover",{autoClose:!0,class:U.menuPopover,label:t,overlayPositioning:"fixed",placement:"top-end",pointerDisabled:!0,referenceElement:this._columnVisibilityActions.get(this.id)},F("calcite-list",{displayMode:"nested",filterEnabled:!0,filterPlaceholder:t,label:t,selectionMode:"multiple"},e.columns.toArray().map((t=>{const i=_(t)?t.columns?.map((t=>this._renderColumnListItem({column:t,table:e,ignoreSelect:!0}))):void 0;return this._renderColumnListItem({column:t,table:e,items:i})}))))}_renderColumnListItem(e){const{column:t,table:i,items:l,ignoreSelect:o}=e,{effectiveLabel:n,fieldName:s,hidden:a}=t;return F("calcite-list-item",{key:`toggle-columns__item-${s}`,label:n,open:!(!l?.length||a)||void 0,selected:!a,value:s,onCalciteListItemSelect:e=>{o&&e.stopPropagation(),i.toggleColumnVisibility(e.currentTarget.value)}},l)}_renderLayerDropdown(){const e=this.messages.selectALayer;return F("div",{class:U.layerDropdownMenu,key:`${this.id}-layerDropdown`,slot:"header-actions-start"},F("calcite-dropdown",{bind:this,maxItems:5,overlayPositioning:"fixed",placement:"bottom-start"},F("calcite-action",{icon:B.layers,slot:"trigger",text:e,title:e}),F("calcite-dropdown-group",{selectionMode:"single"},this._effectiveLayers.map(((e,t)=>this._renderLayerDropdownItem(e,t)))??null)))}_renderLayerDropdownItem(e,t){const i=this.visibleElements.layerDropdownIcons;return F("calcite-dropdown-item",{iconStart:i?T(e):void 0,key:`dropdown-item-${t}`,label:e.title??"",selected:e===this.layer,value:e.id,onCalciteDropdownItemSelect:()=>{this.layer=e}},e.title)}_onRelatedNavigationItemClick(e){this.viewModel.drainRelatedTablesAboveIndex(e)}_collapseRelatedTable(e){this.viewModel.collapseRelatedTable(this.effectiveTable,e)}_onShowRelatedTable(e){this.showRelatedTableCallback||(this._collapseRelatedTable(e),this._createRelatedTable(e))}async _createRelatedTable(e){const{editingEnabled:t,effectiveTable:i,paginationEnabled:l,pageSize:o,view:n,viewModel:s}=this,{layer:a,objectId:r,relatedLayer:c,relationshipId:d}=e;await a.load();const h=this.attachmentsEnabled&&S(a),m=new j({layer:a,attachmentsEnabled:h,editingEnabled:t,paginationEnabled:l,pageSize:o,relatedRecordsEnabled:!0,relationshipConfig:{objectId:r,relatedLayer:c,relationshipId:d},relationshipColumnConfigs:A(a,d),tableController:this,tableParent:i,view:n,showRelatedTableCallback:e=>s.emit("show-related-table",e)});this.relatedTables.add(m),this.scheduleRender()}_renderAttachmentsView(){const{attachmentInfos:e,mode:t,objectId:i}=this.attachmentsViewOptions;return"file"!==t&&e.length&&null!=i?this._renderAttachmentsViewList():this._renderAttachmentsViewFilePane()}_renderAttachmentsViewFilePane(){const{attachmentsViewOptions:e,isSyncingAttachments:t,messages:i,messagesUnits:l,viewModel:{supportsAddAttachments:o}}=this,{attachmentId:n,attachmentInfos:a,candidates:r,objectId:c}=e,d=a.find((e=>e.id===n)),h=a.length,m=r?.length,p=d?F("calcite-label",{alignment:"center",key:"replace-file-node",scale:"l"},i.replaceFile):void 0,u=m?void 0:F("calcite-label",{alignment:"center",key:"message-node",scale:"m"},o?null==c?i.noFeature:i.dragAndDropToUpload:i.editingRestricted),g=Array.from(r??[]).pop(),b=g?F("calcite-label",{key:"filename-node"},g.name):void 0,w=o&&null!=c,v=w&&m,y=F("input",{afterCreate:k,afterRemoved:x,afterUpdate:k,bind:this,"data-node-ref":"_attachmentsInput",files:r,hidden:!0,name:"attachment",onchange:e=>this._onAttachmentsViewCandidateChange(e),type:"file"}),f=w?F("calcite-button",{appearance:"outline-fill",bind:this,disabled:t,iconStart:B.folderOpen,key:"select-node",loading:!1,onclick:()=>{this._attachmentsInput?.click()},width:"full"},i.selectFile):void 0,_=v?F("calcite-button",{appearance:"outline-fill",bind:this,disabled:t,iconStart:B.save,key:"save-node",loading:t,onclick:()=>{this.saveAttachmentsViewForm()},width:"full"},d?i.updateAttachment:i.addAttachment):void 0,M=h||m?F("calcite-button",{appearance:"transparent",bind:this,disabled:t,key:"cancel-node",onclick:()=>{this._attachmentsInput&&(this._attachmentsInput.value=""),e.reset(),e.attachmentInfos?.length&&(e.mode="list")},width:"full"},this.messagesCommon.cancel):void 0;return[F("div",{class:U.attachmentsView,key:"attachments-view"},F("div",{class:U.attachmentsViewContent,key:"attachments-view-content"},F("div",{bind:this,class:U.attachmentsViewDropArea,ondragover:e=>e.preventDefault(),ondrop:this._onAttachmentsViewDrop},F("calcite-icon",{class:U.attachmentsViewIcon,icon:B.upload,scale:"l"}),p,u,F("form",{afterCreate:t=>e.form=t,afterRemoved:()=>e.form=null,bind:this,key:"attachments-form"},F("fieldset",null,b,y,f,_,M)))),null!=c&&null!=d?F("div",{class:U.attachmentsViewInformation,key:"information"},this._renderAttachmentsViewThumbnail(d,200),F("label",{key:"file-label"},i.fileName),F("span",{key:"file-span"},d.name),F("label",{key:"size-label"},i.size),F("span",{key:"size-span"},s(l,d.size??0))):void 0)]}_renderAttachmentsViewList(){const{attachmentsViewOptions:e,messages:t,messagesUnits:i,viewModel:{store:{syncingAttachmentEdits:l},supportsDeleteAttachments:o,supportsUpdateAttachments:n}}=this,{attachmentInfos:a,objectId:r}=e;return F("calcite-list",{afterCreate:k,afterRemoved:x,afterUpdate:k,bind:this,class:U.attachmentsViewList,"data-node-ref":"attachmentsList",key:`attachments-list-${r}`,label:t?.attachments,loading:l,ondragover:e=>e.preventDefault(),ondrop:this._onAttachmentsViewDrop,selectionMode:"multiple",onCalciteListChange:()=>this.scheduleRender()},...a?.map((l=>{const{id:a,name:c,size:d,url:h}=l,m=s(i,d??0);return F("calcite-list-item",{afterRemoved:()=>this.scheduleRender(),key:`attachment-${a}`,label:c,value:a},this._renderAttachmentsViewListThumbnail(l),F("span",{class:U.attachmentsViewListFileSize,slot:"actions-end",title:m},m),F("calcite-action",{appearance:"transparent",icon:B.downloadTo,key:`download-attachment-${a}`,label:`${c}`,onclick:e=>{e.preventDefault(),this.downloadAttachmentById(r??-1,a)},slot:"actions-end",text:t.downloadAttachment,title:t.downloadAttachment}),n&&null!=r?F("calcite-action",{appearance:"transparent",disabled:!n,icon:B.replaceImage,key:`replace-attachment-${a}`,label:`${c}`,onclick:()=>{e.mode="file",e.attachmentId=a},slot:"actions-end",text:t.updateAttachment,title:t.updateAttachment}):void 0,F("calcite-action",{appearance:"transparent",icon:B.launch,key:`launch-attachment-${a}`,label:`${c}`,onclick:()=>{h&&window.open(h,"_blank")},slot:"actions-end",text:t.viewAttachment,title:t.viewAttachment}),o&&null!=r?F("calcite-action",{appearance:"transparent",class:U.attachmentsViewListItemDelete,disabled:!o,icon:B.delete,key:`delete-attachment-${a}`,label:`${c}`,onclick:()=>{this.deleteAttachments(r,[a],!0)},slot:"actions-end",text:t.deleteAttachment,title:t.deleteAttachment}):void 0)})))}_renderAttachmentsViewListThumbnail(e){return F("div",{class:U.attachmentsViewListThumbnail,slot:"content-start"},F("a",{href:e.url??"",rel:"noreferrer",target:"_blank"},this._renderAttachmentsViewThumbnail(e)))}_renderAttachmentsViewThumbnail(e,t=64){const{contentType:i,name:l,size:o,url:n}=e,s=`${n}${n?.includes("?")?"&":"?"}w=${t}&s=${o}`;return this.viewModel.supportsResizeAttachments&&u(i)?F("img",{alt:l,key:`thumbnail-image-${l}`,src:s,title:l}):F("calcite-icon",{icon:g(i),key:`thumbnail-icon-${l}`,scale:"l",textLabel:l,title:l})}_onAttachmentsViewCandidateChange({target:e}){this.attachmentsViewOptions.candidates=e?.files}_onAttachmentsViewDrop(e){const{viewModel:t}=this;e.preventDefault(),(t.supportsAddAttachments||t.supportsUpdateAttachments)&&this.attachmentsViewOptions.set({mode:"file",candidates:e.dataTransfer?.files})}_renderNavigationBar(){const{effectiveTable:e,messages:t,messagesCommon:i,relatedTable:l,relatedTables:o}=this;if(!this._shouldShowNavigationBar)return;const{attachmentsList:n,attachmentsViewOptions:s,layer:a,viewModel:{supportsAddAttachments:r,supportsDeleteAttachments:c}}=e;if(!a)return;const{attachmentInfos:d,objectId:h}=s,m=null!=h,p=d.length,u=n?.selectedItems?.length??0,g=`${a.objectIdField}: ${h}`,b=L(t.selectedCount,{count:u}),w=L(t.attachmentsCount,{count:p}),v=m?F("calcite-action",{bind:this,icon:B.chevronRight,iconFlipRtl:!0,key:"navigation-feature",onclick:()=>e.scrollToRow(h),text:g,textEnabled:!0,title:g}):void 0,y=m?F("calcite-action",{icon:B.chevronRight,iconFlipRtl:!0,key:"navigation-attachments-label",label:w,onclick:()=>{p>0&&(s.mode="list")},text:w,textEnabled:!0,title:w}):void 0,f=m?F("calcite-chip",{closable:!0,closed:0===u,key:"navigation-chip",kind:"inverse",label:b,selected:!0,title:b,value:"selected",onCalciteChipClose:()=>n?.selectedItems?.forEach((e=>e.selected=!1))},b):void 0,_=l?F("calcite-label",{layout:"inline"},t.showAllTables,F("calcite-switch",{checked:this.allRelatedTablesVisible,onCalciteSwitchChange:e=>this.showAllRelatedTables=!!e.currentTarget.checked})):void 0,M=m&&"list"===s.mode&&null!=h&&u&&c?F("calcite-action",{icon:B.delete,iconFlipRtl:!0,key:"attachments-trash-all",onclick:()=>{e.deleteAttachments(h,n?.selectedItems?.map((e=>e.value))??[],!0)},text:i.delete,textEnabled:!0,title:L(t.deleteAttachmentCount,{count:u})}):void 0,C=m&&"list"===s.mode&&r?F("calcite-action",{bind:this,icon:B.plus,iconFlipRtl:!0,key:"attachments-add",onclick:()=>{s.attachmentId=null,s.mode="file"},text:t.addAttachment,textEnabled:!0,title:t.addAttachment}):void 0;return F("div",{class:U.tableNavigation,key:"table-nav"},F("calcite-action",{icon:B.moveUp,iconFlipRtl:!0,key:"go-back",onclick:()=>{l&&this.drainRelatedTables(),e.attachmentsViewOptions.objectId=null},text:this.layer?.title??"",textEnabled:!1,title:l?t.exitRelatedRecords:t.exitAttachments}),o.toArray().map(((e,t)=>this._renderRelatedTableNavigationAction(e,t))),v,y,F("div",null,f,_,M,C))}_renderRelatedTableNavigationAction(e,t){const i=this._getLabelForRelatedTableNavigationAction(e);return F("calcite-action",{icon:B.chevronRight,iconFlipRtl:!0,key:t,onclick:()=>this._onRelatedNavigationItemClick(t),text:i,textEnabled:!0,title:e.layer?.title||""})}_getLabelForRelatedTableNavigationAction(e){const t=e.layer?.title;if(!t)return"";const{relatedTables:i}=this;if(i.length<=1)return t;return i.indexOf(e)!==i.length-1&&t.length>20?`${t.slice(0,20)}...`:t}};e([a()],H.prototype,"_attachmentsInput",void 0),e([a()],H.prototype,"_columnVisibilityActions",void 0),e([a()],H.prototype,"_effectiveDescription",null),e([a()],H.prototype,"_effectiveLayers",null),e([a()],H.prototype,"_effectiveTitle",null),e([a()],H.prototype,"_effectiveVisibleElements",null),e([a()],H.prototype,"_filteredTables",null),e([a()],H.prototype,"_hasAttachmentsViewError",null),e([a()],H.prototype,"_hasCustomMenuItems",null),e([a()],H.prototype,"_hasDefaultMenuItems",null),e([a()],H.prototype,"_shouldShowGrid",null),e([a()],H.prototype,"_shouldShowMenu",null),e([a()],H.prototype,"_shouldShowAttachmentsView",null),e([a()],H.prototype,"_showClearSelectionAction",null),e([a()],H.prototype,"_showColumnsVisibilityAction",null),e([a()],H.prototype,"_showDeleteSelectionAction",null),e([a()],H.prototype,"_showExportSelectionToCSVAction",null),e([a()],H.prototype,"_showLayerDropdown",null),e([a()],H.prototype,"_shouldShowNavigationBar",null),e([a()],H.prototype,"_showRefreshDataAction",null),e([a()],H.prototype,"_showSelectedRecordsShowSelectedAction",null),e([a()],H.prototype,"_showSelectedRecordsShowAllAction",null),e([a()],H.prototype,"_showZoomToSelectionAction",null),e([a()],H.prototype,"_viewLayers",null),e([a()],H.prototype,"attachmentsList",void 0),e([a({readOnly:!0})],H.prototype,"grid",null),e([a()],H.prototype,"actionColumnConfig",null),e([a({readOnly:!0})],H.prototype,"activeFilters",null),e([a({readOnly:!0})],H.prototype,"activeSortOrders",null),e([a()],H.prototype,"allColumns",null),e([a({readOnly:!0})],H.prototype,"allRelatedTablesVisible",null),e([a()],H.prototype,"attachmentsEnabled",null),e([a()],H.prototype,"attachmentsViewOptions",null),e([a({type:m})],H.prototype,"attributeTableTemplate",null),e([a()],H.prototype,"autoRefreshEnabled",null),e([a()],H.prototype,"clearPrompt",null),e([a()],H.prototype,"columnPerformanceModeEnabled",null),e([a()],H.prototype,"columnReorderingEnabled",null),e([a({readOnly:!0})],H.prototype,"columns",null),e([a()],H.prototype,"description",void 0),e([a()],H.prototype,"disabled",void 0),e([a()],H.prototype,"editingEnabled",null),e([a()],H.prototype,"effectiveSize",null),e([a()],H.prototype,"effectiveTable",null),e([a()],H.prototype,"filterGeometry",null),e([a()],H.prototype,"filterBySelectionEnabled",null),e([a()],H.prototype,"hiddenFields",null),e([a()],H.prototype,"highlightEnabled",null),e([a()],H.prototype,"highlightIds",null),e([a()],H.prototype,"icon",null),e([a()],H.prototype,"initialSize",null),e([a()],H.prototype,"isQueryingOrSyncing",null),e([a()],H.prototype,"isSyncingAttachments",null),e([a()],H.prototype,"label",null),e([a()],H.prototype,"layer",null),e([a()],H.prototype,"layers",null),e([a()],H.prototype,"layerView",null),e([a()],H.prototype,"maxSize",null),e([a(),D("esri/widgets/FeatureTable/t9n/FeatureTable")],H.prototype,"messages",null),e([a(),D("esri/t9n/common")],H.prototype,"messagesCommon",null),e([a(),D("esri/core/t9n/Units")],H.prototype,"messagesUnits",null),e([a(),D("esri/widgets/support/t9n/uriUtils")],H.prototype,"messagesURIUtils",null),e([a()],H.prototype,"menuConfig",void 0),e([a()],H.prototype,"multipleSelectionEnabled",null),e([a()],H.prototype,"multiSortEnabled",null),e([a()],H.prototype,"objectIds",null),e([a()],H.prototype,"outFields",null),e([a()],H.prototype,"pageCount",null),e([a()],H.prototype,"pageIndex",null),e([a()],H.prototype,"pageSize",null),e([a()],H.prototype,"paginationEnabled",null),e([a()],H.prototype,"prompt",null),e([a()],H.prototype,"relatedRecordsEnabled",null),e([a()],H.prototype,"relatedTable",null),e([a()],H.prototype,"relatedTables",null),e([a()],H.prototype,"relationship",null),e([a()],H.prototype,"relationshipColumnConfigs",null),e([a()],H.prototype,"relationshipConfig",null),e([a()],H.prototype,"relationshipInfos",null),e([a()],H.prototype,"returnGeometryEnabled",null),e([a()],H.prototype,"returnMEnabled",null),e([a()],H.prototype,"returnZEnabled",null),e([a()],H.prototype,"rowHighlightIds",null),e([a()],H.prototype,"selectionSource",null),e([a()],H.prototype,"showAllRelatedTables",null),e([a()],H.prototype,"showPrompt",null),e([a()],H.prototype,"showRelatedTableCallback",null),e([a()],H.prototype,"size",null),e([a({readOnly:!0})],H.prototype,"state",null),e([a({constructOnly:!0})],H.prototype,"tableController",null),e([a({constructOnly:!0})],H.prototype,"tableParent",null),e([a()],H.prototype,"tableTemplate",null),e([a()],H.prototype,"tableTemplateOverride",null),e([a()],H.prototype,"title",void 0),e([a()],H.prototype,"timeExtent",null),e([a()],H.prototype,"timeZone",null),e([a()],H.prototype,"view",null),e([a({type:y}),P(["cell-click","cell-dblclick","cell-pointerover","cell-pointerout","cell-keydown","column-reorder","show-related-table"])],H.prototype,"viewModel",void 0),e([a({type:f,nonNullable:!0})],H.prototype,"visibleElements",void 0),e([a({type:f})],H.prototype,"visibleElementsOverride",null),H=j=e([r("esri.widgets.FeatureTable")],H);const N=H;export{N as default};
5
+ import{_ as e}from"../chunks/tslib.es6.js";import"../intl.js";import{isSome as t}from"../core/arrayUtils.js";import{watch as i,sync as l,initial as o,on as n}from"../core/reactiveUtils.js";import{formatFileSize as s}from"../core/unitFormatUtils.js";import{property as a}from"../core/accessorSupport/decorators/property.js";import"../core/has.js";import"../core/Logger.js";import{subclass as r}from"../core/accessorSupport/decorators/subclass.js";import{isLayerFromCatalog as c}from"../layers/catalog/catalogUtils.js";import{isKnowledgeGraphLayer as d,isSubtypeGroupLayer as h}from"../layers/support/layerUtils.js";import m from"../tables/AttributeTableTemplate.js";import p from"./Widget.js";import{isSupportedImage as u,getCalciteIconForAttachment as g}from"./Attachments/support/attachmentUtils.js";import{loadPromptComponents as b,Prompt as w}from"./Editor/components/Prompt.js";import v from"./FeatureTable/ColumnMenuVisibleElements.js";import y from"./FeatureTable/FeatureTableViewModel.js";import f from"./FeatureTable/VisibleElements.js";import{isGroupColumn as _}from"./FeatureTable/support/columnUtils.js";import{loadFieldColumnComponents as M,isIFeatureTableSupportedLayer as C,getIconForLayer as T,isIFeatureTableSupportedLayerWithAttachments as S,getRelationshipIdsToShow as A,isMapImageLayer as E}from"./FeatureTable/support/tableUtils.js";import{loadCalciteComponents as I}from"./support/componentsUtils.js";import{globalCss as V}from"./support/globalCss.js";import{renderingSanitizer as R,storeNode as k,discardNode as x}from"./support/widgetUtils.js";import{messageBundle as D}from"./support/decorators/messageBundle.js";import{vmEvent as P}from"./support/decorators/vmEvent.js";import{tsx as F}from"./support/jsxFactory.js";import{substitute as L}from"../intl/substitute.js";var j;const O="esri-feature-table",z=`${O}__prompt`,$=`${O}__attachments-view`,U={base:O,content:`${O}__content`,menuPopover:`${O}__menu-popover`,layerDropdownMenu:`${O}__layer-switcher-menu`,tableContainer:`${O}__table-container`,tableContainerWithAttachments:`${O}__table-container--attachments`,tableNavigation:`${O}__table-navigation`,attachmentsView:$,attachmentsViewContent:`${$}__content`,attachmentsViewDropArea:`${$}__drop-area`,attachmentsViewIcon:`${$}__icon`,attachmentsViewInformation:`${$}__information`,attachmentsViewList:`${$}__list`,attachmentsViewListFileSize:`${$}__list__filesize`,attachmentsViewListItemDelete:`${$}__list-item--delete`,attachmentsViewListThumbnail:`${$}__list__thumbnail`,expanded:`${O}__expanded`,collapsed:`${O}__collapsed`,promptContainer:z,promptHeader:`${z}__header`,promptHeading:`${z}__header__heading`,promptMessage:`${z}__message`,promptDivider:`${z}__divider`,promptActions:`${z}__actions`},B={attachment:"attachment",chevronDown:"chevron-down",chevronLeft:"chevron-left",chevronRight:"chevron-right",clearSelection:"clear-selection",downloadTo:"download-to",exclamationMarkTriangle:"exclamation-mark-triangle",exportToCSV:"file-csv",folderOpen:"folder-open",delete:"trash",launch:"launch",layers:"layers",moveUp:"move-up",plus:"plus",refresh:"refresh",replaceImage:"replace-image",save:"save",showAll:"selection-x",showColumn:"show-column",showSelected:"selection-filter",upload:"upload",zoomToSelection:"zoom-to-object"};let H=j=class extends p{constructor(e,t){super(e,t),this._attachmentsInput=null,this._columnVisibilityActions=new Map,this.attachmentsList=null,this.description=null,this.disabled=!1,this.menuConfig=null,this.title=null,this.viewModel=new y,this.visibleElements=new f,this._showDeletePrompt=this._showDeletePrompt.bind(this),this._onDeleteSelectionClick=this._onDeleteSelectionClick.bind(this)}initialize(){this.addHandles([i((()=>[this.viewModel.store.querying,this.viewModel.store.syncing,this.editingEnabled]),(()=>this.scheduleRender())),i((()=>[this._effectiveVisibleElements,this._effectiveVisibleElements.columnDescriptions,this._effectiveVisibleElements.columnMenus,this._effectiveVisibleElements.columnMenuItems,this.columns.length]),(()=>{this.columns.forEach((e=>e.visibleElements=this._effectiveVisibleElements)),this.refreshCellContent()}),l),i((()=>this._effectiveVisibleElements.selectionColumn),(e=>{this.grid&&(this.grid.selectionColumnEnabled=e)}),o),n((()=>this.viewModel),"show-related-table",(e=>this._onShowRelatedTable(e))),i((()=>this.editingEnabled),(()=>{const{attachmentsViewOptions:e}=this;this.clearPrompt(),e&&(e.form?.reset(),e.candidates=null)}))])}loadDependencies(){return Promise.all([I({action:()=>import("@esri/calcite-components/dist/components/calcite-action"),alert:()=>import("@esri/calcite-components/dist/components/calcite-alert"),button:()=>import("@esri/calcite-components/dist/components/calcite-button"),chip:()=>import("@esri/calcite-components/dist/components/calcite-chip"),dropdown:()=>import("@esri/calcite-components/dist/components/calcite-dropdown"),"dropdown-group":()=>import("@esri/calcite-components/dist/components/calcite-dropdown-group"),"dropdown-item":()=>import("@esri/calcite-components/dist/components/calcite-dropdown-item"),icon:()=>import("@esri/calcite-components/dist/components/calcite-icon"),label:()=>import("@esri/calcite-components/dist/components/calcite-label"),list:()=>import("@esri/calcite-components/dist/components/calcite-list"),"list-item":()=>import("@esri/calcite-components/dist/components/calcite-list-item"),pagination:()=>import("@esri/calcite-components/dist/components/calcite-pagination"),panel:()=>import("@esri/calcite-components/dist/components/calcite-panel"),popover:()=>import("@esri/calcite-components/dist/components/calcite-popover"),progress:()=>import("@esri/calcite-components/dist/components/calcite-progress"),switch:()=>import("@esri/calcite-components/dist/components/calcite-switch"),tooltip:()=>import("@esri/calcite-components/dist/components/calcite-tooltip")}),b(),M()])}destroy(){this.drainRelatedTables(),this.clearPrompt()}get _effectiveDescription(){const{description:e}=this;return null!=e?R.sanitize("function"==typeof e?e():e):void 0}get _effectiveLayers(){const{layer:e,layers:t}=this,i=t?.length?t.filter(C):[],l=i.length?i:[...this._viewLayers];return e&&!l.includes(e)&&l.push(e),l}get _effectiveTitle(){const{layer:e,messages:t,state:i,highlightIds:l,title:o,size:n}=this;if(o)return R.sanitize("function"==typeof o?o():o);if(!e)return t.noLayer;switch(i){case"disabled":return t.errorLayer;case"ready":case"loading":return t.loading;case"error":return t.errorData}return L(t.header,{title:R.sanitize(e.title),count:n,selected:l.length})}get _effectiveVisibleElements(){return this.visibleElementsOverride??this.visibleElements}get _filteredTables(){const e=this.relatedTables.toArray(),t=1===e.length;return this.allRelatedTablesVisible?e:t?[e[0]]:this._shouldShowAttachmentsView?e.slice(-1):e.slice(-2)}get _hasAttachmentsViewError(){return null!=this.attachmentsViewOptions.error}get _hasCustomMenuItems(){return!!this.menuConfig?.items?.length}get _hasDefaultMenuItems(){return!!(this._showClearSelectionAction||this._showDeleteSelectionAction||this._showExportSelectionToCSVAction||this._showRefreshDataAction||this._showZoomToSelectionAction||this._showSelectedRecordsShowSelectedAction||this._showSelectedRecordsShowAllAction||this._showColumnsVisibilityAction)}get _shouldShowGrid(){return this.allRelatedTablesVisible||1===this.relatedTables.length&&!this._shouldShowAttachmentsView}get _shouldShowMenu(){const{header:e,menu:t}=this._effectiveVisibleElements;return!(!e||!t||!this._hasDefaultMenuItems&&!this._hasCustomMenuItems)}get _shouldShowAttachmentsView(){return!(null==this.attachmentsViewOptions.objectId&&!this.relatedTables.some((e=>null!=e.attachmentsViewOptions.objectId)))}get _showClearSelectionAction(){return!(!this.highlightIds.length||!this._effectiveVisibleElements.menuItems?.clearSelection||this.relatedTables.length)}get _showColumnsVisibilityAction(){const{header:e,menu:t,menuItems:i}=this._effectiveVisibleElements;return!(!(e&&t&&i?.toggleColumns)||this.showRelatedTableCallback||this.allRelatedTablesVisible||this._shouldShowAttachmentsView)}get _showDeleteSelectionAction(){return!(!(this.editingEnabled&&this.highlightIds.length&&this._effectiveVisibleElements.menuItems?.deleteSelection&&this.layer?.capabilities?.operations?.supportsDelete)||this.relatedTables.length)}get _showExportSelectionToCSVAction(){return!(!(this._effectiveVisibleElements.menuItems.exportSelectionToCSV&&this.layer&&this.highlightIds.length)||this.relatedTables.length)}get _showLayerDropdown(){return!(!this._effectiveLayers.length||!this._effectiveVisibleElements.layerDropdown)}get _shouldShowNavigationBar(){const e=!!this.relatedTable||this._shouldShowAttachmentsView;return!this.tableParent&&e}get _showRefreshDataAction(){return!!this._effectiveVisibleElements.menuItems?.refreshData}get _showSelectedRecordsShowSelectedAction(){const e=this.objectIds.length,t=this.highlightIds.length;return!(!t||!this._effectiveVisibleElements.menuItems?.selectedRecordsShowSelectedToggle||e&&t===e||this.relatedTables.length)}get _showSelectedRecordsShowAllAction(){return!(!this._effectiveVisibleElements.menuItems?.selectedRecordsShowAllToggle||!this.objectIds.length||this.relatedTables.length)}get _showZoomToSelectionAction(){return!(!this.view||!this.highlightIds.length||this.effectiveTable.layer?.isTable||!this._effectiveVisibleElements.menuItems?.zoomToSelection)}get _viewLayers(){const e=this.view?.map;if(!e)return[];const t=new Set,i=e=>{!C(e)||h(e)||t.has(e)||(e.load(),t.add(e))},l=e=>{c(e)||"catalog-footprint"===e.type||(d(e)?(e.load(),e.layers?.forEach(i),e.tables?.forEach(i)):E(e)?(e.loadAll(),e.sublayers?.forEach(i),e.subtables?.forEach(i)):h(e)?(e.loadAll(),e.sublayers?.forEach(i)):i(e))};return e.allLayers.forEach(l),e.allTables.forEach(l),[...t.values()]}get grid(){return this.viewModel.grid}get actionColumnConfig(){return this.viewModel.actionColumnConfig}set actionColumnConfig(e){this.viewModel.actionColumnConfig=e}get activeFilters(){return this.viewModel.activeFilters}get activeSortOrders(){return this.viewModel.activeSortOrders}get allColumns(){return this.viewModel.allColumns}get allRelatedTablesVisible(){return this.viewModel.allRelatedTablesVisible}get attachmentsEnabled(){return this.viewModel.attachmentsEnabled}set attachmentsEnabled(e){this.viewModel.attachmentsEnabled=e}get attachmentsViewOptions(){return this.viewModel.attachmentsViewOptions}set attachmentsViewOptions(e){this.viewModel.attachmentsViewOptions=e}get attributeTableTemplate(){return this.viewModel.attributeTableTemplate}set attributeTableTemplate(e){this.viewModel.attributeTableTemplate=e}get autoRefreshEnabled(){return this.viewModel.autoRefreshEnabled}set autoRefreshEnabled(e){this.viewModel.autoRefreshEnabled=e}get clearPrompt(){return this.viewModel.clearPrompt}set clearPrompt(e){this.viewModel.clearPrompt=e}get columnPerformanceModeEnabled(){return this.viewModel.columnPerformanceModeEnabled}set columnPerformanceModeEnabled(e){this.viewModel.columnPerformanceModeEnabled=e}get columnReorderingEnabled(){return this.viewModel.columnReorderingEnabled}set columnReorderingEnabled(e){this.viewModel.columnReorderingEnabled=e}get columns(){return this.viewModel.columns}get editingEnabled(){return this.viewModel.editingEnabled}set editingEnabled(e){this.viewModel.editingEnabled=e}get effectiveSize(){return this.viewModel.effectiveSize}get effectiveTable(){return this.relatedTable||this}get filterGeometry(){return this.viewModel.filterGeometry}set filterGeometry(e){this.viewModel.filterGeometry=e}get filterBySelectionEnabled(){return this.viewModel.filterBySelectionEnabled}set filterBySelectionEnabled(e){this.viewModel.filterBySelectionEnabled=e}get hiddenFields(){return this.viewModel.hiddenFields}set hiddenFields(e){this.viewModel.hiddenFields=e}get highlightEnabled(){return this.viewModel.highlightEnabled}set highlightEnabled(e){this.viewModel.highlightEnabled=e}get highlightIds(){return this.viewModel.highlightIds}set highlightIds(e){this.viewModel.highlightIds=e}get icon(){return"table"}set icon(e){this._overrideIfSome("icon",e)}get initialSize(){return this.viewModel.initialSize}set initialSize(e){this.viewModel.initialSize=e}get isQueryingOrSyncing(){return this.viewModel.isQueryingOrSyncing}get isSyncingAttachments(){return this.viewModel.isSyncingAttachments}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get layer(){return this.viewModel.layer}set layer(e){this.viewModel.layer=e}get layers(){return this.viewModel.layers}set layers(e){this.viewModel.layers=e}get layerView(){return this.viewModel.layerView}get maxSize(){return this.viewModel.maxSize}set maxSize(e){this.viewModel.maxSize=e}get messages(){return this.viewModel.messages}set messages(e){this.viewModel.messages=e}get messagesCommon(){return this.viewModel.messagesCommon}set messagesCommon(e){this.viewModel.messagesCommon=e}get messagesUnits(){return this.viewModel.messagesUnits}set messagesUnits(e){this.viewModel.messagesUnits=e}get messagesURIUtils(){return this.viewModel.messagesURIUtils}set messagesURIUtils(e){this.viewModel.messagesURIUtils=e}get multipleSelectionEnabled(){return this.viewModel.multipleSelectionEnabled}set multipleSelectionEnabled(e){this.viewModel.multipleSelectionEnabled=e}get multiSortEnabled(){return this.viewModel.multiSortEnabled}set multiSortEnabled(e){this.viewModel.multiSortEnabled=e}get objectIds(){return this.viewModel.objectIds}set objectIds(e){this.viewModel.objectIds=e}get outFields(){return this.viewModel.outFields}set outFields(e){this.viewModel.outFields=e}get pageCount(){return this.viewModel.pageCount}get pageIndex(){return this.viewModel.pageIndex}set pageIndex(e){this.viewModel.pageIndex=e}get pageSize(){return this.viewModel.pageSize}set pageSize(e){this.viewModel.pageSize=e}get paginationEnabled(){return this.viewModel.paginationEnabled}set paginationEnabled(e){this.viewModel.paginationEnabled=e}get prompt(){return this.viewModel.prompt}set prompt(e){this.viewModel.prompt=e}get relatedRecordsEnabled(){return this.viewModel.relatedRecordsEnabled}set relatedRecordsEnabled(e){this.viewModel.relatedRecordsEnabled=e}get relatedTable(){return this.viewModel.relatedTable}get relatedTables(){return this.viewModel.relatedTables}set relatedTables(e){this.viewModel.relatedTables=e}get relationship(){return this.viewModel.relationship}get relationshipColumnConfigs(){return this.viewModel.relationshipColumnConfigs}set relationshipColumnConfigs(e){this.viewModel.relationshipColumnConfigs=e}get relationshipConfig(){return this.viewModel.relationshipConfig}set relationshipConfig(e){this.viewModel.relationshipConfig=e}get relationshipInfos(){return this.viewModel.relationshipInfos}get returnGeometryEnabled(){return this.viewModel.returnGeometryEnabled}set returnGeometryEnabled(e){this.viewModel.returnGeometryEnabled=e}get returnMEnabled(){return this.viewModel.returnMEnabled}set returnMEnabled(e){this.viewModel.returnMEnabled=e}get returnZEnabled(){return this.viewModel.returnZEnabled}set returnZEnabled(e){this.viewModel.returnZEnabled=e}get rowHighlightIds(){return this.viewModel.rowHighlightIds}set rowHighlightIds(e){this.viewModel.rowHighlightIds=e}get selectionSource(){return this.viewModel.selectionSource}set selectionSource(e){this.viewModel.selectionSource=e}get showAllRelatedTables(){return this.viewModel.showAllRelatedTables}set showAllRelatedTables(e){this.viewModel.showAllRelatedTables=e}get showPrompt(){return this.viewModel.showPrompt}set showPrompt(e){this.viewModel.showPrompt=e}get showRelatedTableCallback(){return this.viewModel.showRelatedTableCallback}set showRelatedTableCallback(e){this.viewModel.showRelatedTableCallback=e}get size(){return this.viewModel.size}get state(){return this.viewModel.state}get tableController(){return this.viewModel.tableController}set tableController(e){this.viewModel.tableController=e}get tableParent(){return this.viewModel.tableParent}set tableParent(e){this.viewModel.tableParent=e}get tableTemplate(){return this.viewModel.tableTemplate}set tableTemplate(e){this.viewModel.tableTemplate=e}get tableTemplateOverride(){return this.viewModel.tableTemplateOverride}set tableTemplateOverride(e){this.viewModel.tableTemplateOverride=e}get timeExtent(){return this.viewModel.timeExtent}set timeExtent(e){this.viewModel.timeExtent=e}get timeZone(){return this.viewModel.timeZone}set timeZone(e){this.viewModel.timeZone=e}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}get visibleElementsOverride(){const{attachmentsViewOptions:e,relatedTable:t,tableController:i,visibleElements:l}=this,{columnDescriptions:o,columnMenus:n,tooltips:s}=l,a=null!=e.objectId;if(t)return new f({columnDescriptions:o,columnMenus:n,tooltips:s,close:l.close,header:l.header,layerDropdown:l.layerDropdown,layerDropdownIcons:l.layerDropdownIcons,menu:l.menu,menuItems:l.menuItems,progress:l.progress,selectionColumn:!1,columnMenuItems:new v({sortAscending:!1,sortDescending:!1})});if(i){const e=i.relatedTable===this,t=i.allRelatedTablesVisible,r=e&&l.selectionColumn&&!t&&!a,c=e&&!t&&!a;return new f({columnDescriptions:o,columnMenus:n,tooltips:s,selectionColumn:r,close:!1,header:!1,layerDropdown:!1,menu:!1,progress:!1,columnMenuItems:new v({sortAscending:c,sortDescending:c})})}return a?new f({columnDescriptions:o,columnMenus:n,tooltips:s,close:l.close,header:l.header,layerDropdown:l.layerDropdown,layerDropdownIcons:l.layerDropdownIcons,menu:l.menu,menuItems:l.menuItems,progress:l.progress,selectionColumn:!1,columnMenuItems:new v({sortAscending:!1,sortDescending:!1})}):null}clearSelectionFilter(){this.viewModel.clearSelectionFilter()}async deleteAttachments(e,t,i){null!=e&&t?.length&&(i?this._showDeleteAttachmentPrompt(e,t):await this.viewModel.deleteAttachments(e,t))}deleteSelection(e){return this.highlightIds.length?e?(this._showDeletePrompt(),this.scheduleRender(),Promise.resolve()):this.viewModel.deleteSelection():Promise.resolve()}async downloadAttachmentById(e,t){return this.viewModel.downloadAttachmentById(e,t)}drainRelatedTables(){this.viewModel.drainRelatedTables()}exportSelectionToCSV(e){return this.viewModel.exportSelectionToCSV(e)}filterBySelection(){this.viewModel.filterBySelection()}findColumn(e){return this.viewModel.findColumn(e)}goToPage(e){this.viewModel.goToPage(e)}hideColumn(e){this.grid?.hideColumn(e)}nextPage(){this.viewModel.nextPage()}previousPage(){this.viewModel.previousPage()}async refresh(){await this.viewModel.refresh()}refreshCellContent(){this.viewModel.refreshCellContent()}async saveAttachmentsViewForm(){await this.viewModel.saveAttachmentsViewForm()}showAllColumns(){this.viewModel.showAllColumns()}showColumn(e){this.grid?.showColumn(e)}sortColumn(e,t){this.viewModel.sortColumn(e,t)}scrollLeft(){this.viewModel.scrollLeft()}scrollToBottom(){this.viewModel.scrollToBottom()}scrollToIndex(e){this.viewModel.scrollToIndex(e)}scrollToRow(e){this.viewModel.scrollToRow(e)}scrollToTop(){this.viewModel.scrollToTop()}toggleColumnVisibility(e){this.viewModel.toggleColumnVisibility(e)}zoomToSelection(){this.effectiveTable.viewModel.zoomToSelection()}render(){const{_effectiveVisibleElements:e,isQueryingOrSyncing:t,menuConfig:i,state:l}=this;return F("div",{bind:this,class:this.classes(U.base,V.widget)},F("calcite-panel",{bind:this,class:U.content,closable:e.close,description:this._effectiveDescription,disabled:this.disabled||"disabled"===l&&!this._effectiveLayers?.length,heading:e.header?this._effectiveTitle:void 0,loading:"loading"===l,menuOpen:!!i?.open,overlayPositioning:"fixed",onCalcitePanelClose:e=>{e.currentTarget.closed=!1,this.emit("close")}},e.progress?F("calcite-progress",{type:t?"indeterminate":"determinate"}):null,this._showLayerDropdown?this._renderLayerDropdown():null,this._renderColumnVisibilityAction(),this._renderHeaderMenuActions(),this._renderNavigationBar(),this._renderTables(),this._renderError()),this._renderColumnVisibilityPopover(),this._renderPrompt())}_renderTables(){const{grid:e,relatedTables:t}=this,i=this.classes(U.tableContainer);if(t.length){const l=this.classes(U.base,this.allRelatedTablesVisible?U.expanded:U.collapsed,this._shouldShowAttachmentsView?U.tableContainerWithAttachments:void 0);return F("div",{class:i},F("calcite-panel",{overlayPositioning:"fixed"},F("div",null,[this._shouldShowGrid?F("div",{class:l},e?.render(),this._renderPagination()):void 0,...this._filteredTables.map((e=>{const i=t.indexOf(e);return F("div",{class:l,key:`related-${i}`},e.render())})),,])))}return null!=this.attachmentsViewOptions.objectId?F("div",{class:i},F("calcite-panel",{overlayPositioning:"fixed"},F("div",null,[F("div",{class:this.classes(U.base,U.collapsed)},e?.render(),this._renderPagination()),this._renderAttachmentsView()]))):[F("div",{class:i},e?.render()),this._renderPagination()]}_renderPagination(){if(this.paginationEnabled)return F("calcite-pagination",{pageSize:1,startItem:this.pageIndex+1,totalItems:this.pageCount,onCalcitePaginationChange:e=>this.goToPage(e.currentTarget.startItem-1)})}_renderError(){const{messages:e}=this;return F("calcite-alert",{autoClose:!0,autoCloseDuration:"fast",icon:B.exclamationMarkTriangle,kind:"danger",label:e.errorOccured,open:this._hasAttachmentsViewError,slot:"alerts",onCalciteAlertClose:()=>{this.attachmentsViewOptions.error=null}},F("span",{slot:"message"},e.errorOccured))}_renderPrompt(){return this.prompt?F(w,{...this.prompt,headingLevel:2}):void 0}_showDeletePrompt(){const{messages:e,messagesCommon:t}=this,i=L(e.deleteSelectionCount,{count:this.highlightIds.length});this.showPrompt({title:i,message:e.deleteRecordsRemoved,context:"danger",actions:{primary:{label:t.delete,action:this._onDeleteSelectionClick},secondary:{label:e.keepRecords,action:()=>this.clearPrompt()}}})}_showDeleteAttachmentPrompt(e,t){const{messages:i,messagesCommon:l}=this,o=L(i.deleteAttachmentCount,{count:t.length});this.showPrompt({title:o,message:i.deleteAttachmentConfirmation,context:"danger",actions:{primary:{label:l.delete,action:async()=>{try{await this.deleteAttachments(e,t,!1)}finally{this.clearPrompt()}}},secondary:{label:l.cancel,action:()=>this.clearPrompt()}}})}async _onDeleteSelectionClick(){try{await this.viewModel.deleteSelection()}finally{this.clearPrompt()}}_renderHeaderMenuAction(e){const{disabled:t,hidden:i,icon:l,text:o,clickFunction:n}=e;if(!i)return F("calcite-action",{disabled:t??this.menuConfig?.disabled,icon:l??void 0,key:o,onclick:()=>n(),slot:"header-menu-actions",text:o,textEnabled:!0,title:o})}_renderHeaderMenuActions(){return this._shouldShowMenu?[this._renderDefaultHeaderMenuActions(),this._renderCustomHeaderMenuActions()]:[]}_renderDefaultHeaderMenuActions(){if(!this._hasDefaultMenuItems)return[];const{messages:e}=this;return[this._showRefreshDataAction&&{icon:B.refresh,text:e.refreshData,clickFunction:()=>this.refresh()},this._showDeleteSelectionAction&&{icon:B.delete,text:e.deleteSelection,clickFunction:()=>this.deleteSelection(!0)},this._showClearSelectionAction&&{icon:B.clearSelection,text:e.clearSelection,clickFunction:()=>this.highlightIds?.removeAll()},this._showZoomToSelectionAction&&{icon:B.zoomToSelection,text:e.zoomToSelection,clickFunction:()=>this.zoomToSelection()},this._showSelectedRecordsShowSelectedAction&&{icon:B.showSelected,text:e.showSelected,clickFunction:()=>{const{objectIds:e}=this;e.removeAll(),e.addMany(this.highlightIds.toArray())}},this._showSelectedRecordsShowAllAction&&{icon:B.showAll,text:e.showAllRecords,clickFunction:()=>this.objectIds.removeAll()},this._showExportSelectionToCSVAction&&{icon:B.exportToCSV,text:e.exportSelectionCSV,clickFunction:()=>this.exportSelectionToCSV()}].filter(t).map((e=>e&&this._renderHeaderMenuAction(e)))}_renderCustomHeaderMenuActions(){return this.menuConfig?.items?.map((({disabled:e,hidden:t,icon:i,label:l,clickFunction:o})=>this._renderHeaderMenuAction({hidden:"function"==typeof t?t():t,icon:i,text:l,disabled:e,clickFunction:e=>o(e)})))??[]}_renderColumnVisibilityAction(){if(!this._showColumnsVisibilityAction)return[];const{_columnVisibilityActions:e,effectiveTable:t,id:i}=this,l=this.messages.toggleColumns;return F("calcite-action",{afterCreate:t=>e.set(i,t),afterRemoved:()=>e.delete(i),appearance:"transparent",bind:this,disabled:t.menuConfig?.disabled,icon:B.showColumn,id:`${i}__toggle-columns-action`,slot:"header-actions-end",text:l},this._effectiveVisibleElements.tooltips?F("calcite-tooltip",{closeOnClick:!0,overlayPositioning:"fixed",placement:"bottom-end",slot:"tooltip"},l):null)}_renderColumnVisibilityPopover(){if(!this._showColumnsVisibilityAction||this.effectiveTable.menuConfig?.disabled)return;const{effectiveTable:e}=this,t=this.messages.toggleColumns;return F("calcite-popover",{autoClose:!0,class:U.menuPopover,label:t,overlayPositioning:"fixed",placement:"top-end",pointerDisabled:!0,referenceElement:this._columnVisibilityActions.get(this.id)},F("calcite-list",{displayMode:"nested",filterEnabled:!0,filterPlaceholder:t,label:t,selectionMode:"multiple"},e.columns.toArray().map((t=>{const i=_(t)?t.columns?.map((t=>this._renderColumnListItem({column:t,table:e,ignoreSelect:!0}))):void 0;return this._renderColumnListItem({column:t,table:e,items:i})}))))}_renderColumnListItem(e){const{column:t,table:i,items:l,ignoreSelect:o}=e,{effectiveLabel:n,fieldName:s,hidden:a}=t;return F("calcite-list-item",{key:`toggle-columns__item-${s}`,label:n,open:!(!l?.length||a)||void 0,selected:!a,value:s,onCalciteListItemSelect:e=>{o&&e.stopPropagation(),i.toggleColumnVisibility(e.currentTarget.value)}},l)}_renderLayerDropdown(){const e=this.messages.selectALayer;return F("div",{class:U.layerDropdownMenu,key:`${this.id}-layerDropdown`,slot:"header-actions-start"},F("calcite-dropdown",{bind:this,maxItems:5,overlayPositioning:"fixed",placement:"bottom-start"},F("calcite-action",{icon:B.layers,slot:"trigger",text:e,title:e}),F("calcite-dropdown-group",{selectionMode:"single"},this._effectiveLayers.map(((e,t)=>this._renderLayerDropdownItem(e,t)))??null)))}_renderLayerDropdownItem(e,t){const i=this.visibleElements.layerDropdownIcons;return F("calcite-dropdown-item",{iconStart:i?T(e):void 0,key:`dropdown-item-${t}`,label:e.title??"",selected:e===this.layer,value:e.id,onCalciteDropdownItemSelect:()=>{this.layer=e}},e.title)}_onRelatedNavigationItemClick(e){this.viewModel.drainRelatedTablesAboveIndex(e)}_collapseRelatedTable(e){this.viewModel.collapseRelatedTable(this.effectiveTable,e)}_onShowRelatedTable(e){this.showRelatedTableCallback||(this._collapseRelatedTable(e),this._createRelatedTable(e))}async _createRelatedTable(e){const{editingEnabled:t,effectiveTable:i,paginationEnabled:l,pageSize:o,view:n,viewModel:s}=this,{layer:a,objectId:r,relatedLayer:c,relationshipId:d}=e;await a.load();const h=this.attachmentsEnabled&&S(a),m=new j({layer:a,attachmentsEnabled:h,editingEnabled:t,paginationEnabled:l,pageSize:o,relatedRecordsEnabled:!0,relationshipConfig:{objectId:r,relatedLayer:c,relationshipId:d},relationshipColumnConfigs:A(a,d),tableController:this,tableParent:i,view:n,showRelatedTableCallback:e=>s.emit("show-related-table",e)});this.relatedTables.add(m),this.scheduleRender()}_renderAttachmentsView(){const{attachmentInfos:e,mode:t,objectId:i}=this.attachmentsViewOptions;return"file"!==t&&e.length&&null!=i?this._renderAttachmentsViewList():this._renderAttachmentsViewFilePane()}_renderAttachmentsViewFilePane(){const{attachmentsViewOptions:e,isSyncingAttachments:t,messages:i,messagesUnits:l,viewModel:{supportsAddAttachments:o}}=this,{attachmentId:n,attachmentInfos:a,candidates:r,objectId:c}=e,d=a.find((e=>e.id===n)),h=a.length,m=r?.length,p=d?F("calcite-label",{alignment:"center",key:"replace-file-node",scale:"l"},i.replaceFile):void 0,u=m?void 0:F("calcite-label",{alignment:"center",key:"message-node",scale:"m"},o?null==c?i.noFeature:i.dragAndDropToUpload:i.editingRestricted),g=Array.from(r??[]).pop(),b=g?F("calcite-label",{key:"filename-node"},g.name):void 0,w=o&&null!=c,v=w&&m,y=F("input",{afterCreate:k,afterRemoved:x,afterUpdate:k,bind:this,"data-node-ref":"_attachmentsInput",files:r,hidden:!0,name:"attachment",onchange:e=>this._onAttachmentsViewCandidateChange(e),type:"file"}),f=w?F("calcite-button",{appearance:"outline-fill",bind:this,disabled:t,iconStart:B.folderOpen,key:"select-node",loading:!1,onclick:()=>{this._attachmentsInput?.click()},width:"full"},i.selectFile):void 0,_=v?F("calcite-button",{appearance:"outline-fill",bind:this,disabled:t,iconStart:B.save,key:"save-node",loading:t,onclick:()=>{this.saveAttachmentsViewForm()},width:"full"},d?i.updateAttachment:i.addAttachment):void 0,M=h||m?F("calcite-button",{appearance:"transparent",bind:this,disabled:t,key:"cancel-node",onclick:()=>{this._attachmentsInput&&(this._attachmentsInput.value=""),e.reset(),e.attachmentInfos?.length&&(e.mode="list")},width:"full"},this.messagesCommon.cancel):void 0;return[F("div",{class:U.attachmentsView,key:"attachments-view"},F("div",{class:U.attachmentsViewContent,key:"attachments-view-content"},F("div",{bind:this,class:U.attachmentsViewDropArea,ondragover:e=>e.preventDefault(),ondrop:this._onAttachmentsViewDrop},F("calcite-icon",{class:U.attachmentsViewIcon,icon:B.upload,scale:"l"}),p,u,F("form",{afterCreate:t=>e.form=t,afterRemoved:()=>e.form=null,bind:this,key:"attachments-form"},F("fieldset",null,b,y,f,_,M)))),null!=c&&null!=d?F("div",{class:U.attachmentsViewInformation,key:"information"},this._renderAttachmentsViewThumbnail(d,200),F("label",{key:"file-label"},i.fileName),F("span",{key:"file-span"},d.name),F("label",{key:"size-label"},i.size),F("span",{key:"size-span"},s(l,d.size??0))):void 0)]}_renderAttachmentsViewList(){const{attachmentsViewOptions:e,messages:t,messagesUnits:i,viewModel:{store:{syncingAttachmentEdits:l},supportsDeleteAttachments:o,supportsUpdateAttachments:n}}=this,{attachmentInfos:a,objectId:r}=e;return F("calcite-list",{afterCreate:k,afterRemoved:x,afterUpdate:k,bind:this,class:U.attachmentsViewList,"data-node-ref":"attachmentsList",key:`attachments-list-${r}`,label:t?.attachments,loading:l,ondragover:e=>e.preventDefault(),ondrop:this._onAttachmentsViewDrop,selectionMode:"multiple",onCalciteListChange:()=>this.scheduleRender()},...a?.map((l=>{const{id:a,name:c,size:d,url:h}=l,m=s(i,d??0);return F("calcite-list-item",{afterRemoved:()=>this.scheduleRender(),key:`attachment-${a}`,label:c,value:a},this._renderAttachmentsViewListThumbnail(l),F("span",{class:U.attachmentsViewListFileSize,slot:"actions-end",title:m},m),F("calcite-action",{appearance:"transparent",icon:B.downloadTo,key:`download-attachment-${a}`,label:`${c}`,onclick:e=>{e.preventDefault(),this.downloadAttachmentById(r??-1,a)},slot:"actions-end",text:t.downloadAttachment,title:t.downloadAttachment}),n&&null!=r?F("calcite-action",{appearance:"transparent",disabled:!n,icon:B.replaceImage,key:`replace-attachment-${a}`,label:`${c}`,onclick:()=>{e.mode="file",e.attachmentId=a},slot:"actions-end",text:t.updateAttachment,title:t.updateAttachment}):void 0,F("calcite-action",{appearance:"transparent",icon:B.launch,key:`launch-attachment-${a}`,label:`${c}`,onclick:()=>{h&&window.open(h,"_blank")},slot:"actions-end",text:t.viewAttachment,title:t.viewAttachment}),o&&null!=r?F("calcite-action",{appearance:"transparent",class:U.attachmentsViewListItemDelete,disabled:!o,icon:B.delete,key:`delete-attachment-${a}`,label:`${c}`,onclick:()=>{this.deleteAttachments(r,[a],!0)},slot:"actions-end",text:t.deleteAttachment,title:t.deleteAttachment}):void 0)})))}_renderAttachmentsViewListThumbnail(e){return F("div",{class:U.attachmentsViewListThumbnail,slot:"content-start"},F("a",{href:e.url??"",rel:"noreferrer",target:"_blank"},this._renderAttachmentsViewThumbnail(e)))}_renderAttachmentsViewThumbnail(e,t=64){const{contentType:i,name:l,size:o,url:n}=e,s=`${n}${n?.includes("?")?"&":"?"}w=${t}&s=${o}`;return this.viewModel.supportsResizeAttachments&&u(i)?F("img",{alt:l,key:`thumbnail-image-${l}`,src:s,title:l}):F("calcite-icon",{icon:g(i),key:`thumbnail-icon-${l}`,scale:"l",textLabel:l,title:l})}_onAttachmentsViewCandidateChange({target:e}){this.attachmentsViewOptions.candidates=e?.files}_onAttachmentsViewDrop(e){const{viewModel:t}=this;e.preventDefault(),(t.supportsAddAttachments||t.supportsUpdateAttachments)&&this.attachmentsViewOptions.set({mode:"file",candidates:e.dataTransfer?.files})}_renderNavigationBar(){const{effectiveTable:e,messages:t,messagesCommon:i,relatedTable:l,relatedTables:o}=this;if(!this._shouldShowNavigationBar)return;const{attachmentsList:n,attachmentsViewOptions:s,layer:a,viewModel:{supportsAddAttachments:r,supportsDeleteAttachments:c}}=e;if(!a)return;const{attachmentInfos:d,objectId:h}=s,m=null!=h,p=d.length,u=n?.selectedItems?.length??0,g=`${a.objectIdField}: ${h}`,b=L(t.selectedCount,{count:u}),w=L(t.attachmentsCount,{count:p}),v=m?F("calcite-action",{bind:this,icon:B.chevronRight,iconFlipRtl:!0,key:"navigation-feature",onclick:()=>e.scrollToRow(h),text:g,textEnabled:!0,title:g}):void 0,y=m?F("calcite-action",{icon:B.chevronRight,iconFlipRtl:!0,key:"navigation-attachments-label",label:w,onclick:()=>{p>0&&(s.mode="list")},text:w,textEnabled:!0,title:w}):void 0,f=m?F("calcite-chip",{closable:!0,closed:0===u,key:"navigation-chip",kind:"inverse",label:b,selected:!0,title:b,value:"selected",onCalciteChipClose:()=>n?.selectedItems?.forEach((e=>e.selected=!1))},b):void 0,_=l?F("calcite-label",{layout:"inline"},t.showAllTables,F("calcite-switch",{checked:this.allRelatedTablesVisible,onCalciteSwitchChange:e=>this.showAllRelatedTables=!!e.currentTarget.checked})):void 0,M=m&&"list"===s.mode&&null!=h&&u&&c?F("calcite-action",{icon:B.delete,iconFlipRtl:!0,key:"attachments-trash-all",onclick:()=>{e.deleteAttachments(h,n?.selectedItems?.map((e=>e.value))??[],!0)},text:i.delete,textEnabled:!0,title:L(t.deleteAttachmentCount,{count:u})}):void 0,C=m&&"list"===s.mode&&r?F("calcite-action",{bind:this,icon:B.plus,iconFlipRtl:!0,key:"attachments-add",onclick:()=>{s.attachmentId=null,s.mode="file"},text:t.addAttachment,textEnabled:!0,title:t.addAttachment}):void 0;return F("div",{class:U.tableNavigation,key:"table-nav"},F("calcite-action",{icon:B.moveUp,iconFlipRtl:!0,key:"go-back",onclick:()=>{l&&this.drainRelatedTables(),e.attachmentsViewOptions.objectId=null},text:this.layer?.title??"",textEnabled:!1,title:l?t.exitRelatedRecords:t.exitAttachments}),o.toArray().map(((e,t)=>this._renderRelatedTableNavigationAction(e,t))),v,y,F("div",null,f,_,M,C))}_renderRelatedTableNavigationAction(e,t){const i=this._getLabelForRelatedTableNavigationAction(e);return F("calcite-action",{icon:B.chevronRight,iconFlipRtl:!0,key:t,onclick:()=>this._onRelatedNavigationItemClick(t),text:i,textEnabled:!0,title:e.layer?.title||""})}_getLabelForRelatedTableNavigationAction(e){const t=e.layer?.title;if(!t)return"";const{relatedTables:i}=this;if(i.length<=1)return t;return i.indexOf(e)!==i.length-1&&t.length>20?`${t.slice(0,20)}...`:t}};e([a()],H.prototype,"_attachmentsInput",void 0),e([a()],H.prototype,"_columnVisibilityActions",void 0),e([a()],H.prototype,"_effectiveDescription",null),e([a()],H.prototype,"_effectiveLayers",null),e([a()],H.prototype,"_effectiveTitle",null),e([a()],H.prototype,"_effectiveVisibleElements",null),e([a()],H.prototype,"_filteredTables",null),e([a()],H.prototype,"_hasAttachmentsViewError",null),e([a()],H.prototype,"_hasCustomMenuItems",null),e([a()],H.prototype,"_hasDefaultMenuItems",null),e([a()],H.prototype,"_shouldShowGrid",null),e([a()],H.prototype,"_shouldShowMenu",null),e([a()],H.prototype,"_shouldShowAttachmentsView",null),e([a()],H.prototype,"_showClearSelectionAction",null),e([a()],H.prototype,"_showColumnsVisibilityAction",null),e([a()],H.prototype,"_showDeleteSelectionAction",null),e([a()],H.prototype,"_showExportSelectionToCSVAction",null),e([a()],H.prototype,"_showLayerDropdown",null),e([a()],H.prototype,"_shouldShowNavigationBar",null),e([a()],H.prototype,"_showRefreshDataAction",null),e([a()],H.prototype,"_showSelectedRecordsShowSelectedAction",null),e([a()],H.prototype,"_showSelectedRecordsShowAllAction",null),e([a()],H.prototype,"_showZoomToSelectionAction",null),e([a()],H.prototype,"_viewLayers",null),e([a()],H.prototype,"attachmentsList",void 0),e([a({readOnly:!0})],H.prototype,"grid",null),e([a()],H.prototype,"actionColumnConfig",null),e([a({readOnly:!0})],H.prototype,"activeFilters",null),e([a({readOnly:!0})],H.prototype,"activeSortOrders",null),e([a()],H.prototype,"allColumns",null),e([a({readOnly:!0})],H.prototype,"allRelatedTablesVisible",null),e([a()],H.prototype,"attachmentsEnabled",null),e([a()],H.prototype,"attachmentsViewOptions",null),e([a({type:m})],H.prototype,"attributeTableTemplate",null),e([a()],H.prototype,"autoRefreshEnabled",null),e([a()],H.prototype,"clearPrompt",null),e([a()],H.prototype,"columnPerformanceModeEnabled",null),e([a()],H.prototype,"columnReorderingEnabled",null),e([a({readOnly:!0})],H.prototype,"columns",null),e([a()],H.prototype,"description",void 0),e([a()],H.prototype,"disabled",void 0),e([a()],H.prototype,"editingEnabled",null),e([a()],H.prototype,"effectiveSize",null),e([a()],H.prototype,"effectiveTable",null),e([a()],H.prototype,"filterGeometry",null),e([a()],H.prototype,"filterBySelectionEnabled",null),e([a()],H.prototype,"hiddenFields",null),e([a()],H.prototype,"highlightEnabled",null),e([a()],H.prototype,"highlightIds",null),e([a()],H.prototype,"icon",null),e([a()],H.prototype,"initialSize",null),e([a()],H.prototype,"isQueryingOrSyncing",null),e([a()],H.prototype,"isSyncingAttachments",null),e([a()],H.prototype,"label",null),e([a()],H.prototype,"layer",null),e([a()],H.prototype,"layers",null),e([a()],H.prototype,"layerView",null),e([a()],H.prototype,"maxSize",null),e([a(),D("esri/widgets/FeatureTable/t9n/FeatureTable")],H.prototype,"messages",null),e([a(),D("esri/t9n/common")],H.prototype,"messagesCommon",null),e([a(),D("esri/core/t9n/Units")],H.prototype,"messagesUnits",null),e([a(),D("esri/widgets/support/t9n/uriUtils")],H.prototype,"messagesURIUtils",null),e([a()],H.prototype,"menuConfig",void 0),e([a()],H.prototype,"multipleSelectionEnabled",null),e([a()],H.prototype,"multiSortEnabled",null),e([a()],H.prototype,"objectIds",null),e([a()],H.prototype,"outFields",null),e([a()],H.prototype,"pageCount",null),e([a()],H.prototype,"pageIndex",null),e([a()],H.prototype,"pageSize",null),e([a()],H.prototype,"paginationEnabled",null),e([a()],H.prototype,"prompt",null),e([a()],H.prototype,"relatedRecordsEnabled",null),e([a()],H.prototype,"relatedTable",null),e([a()],H.prototype,"relatedTables",null),e([a()],H.prototype,"relationship",null),e([a()],H.prototype,"relationshipColumnConfigs",null),e([a()],H.prototype,"relationshipConfig",null),e([a()],H.prototype,"relationshipInfos",null),e([a()],H.prototype,"returnGeometryEnabled",null),e([a()],H.prototype,"returnMEnabled",null),e([a()],H.prototype,"returnZEnabled",null),e([a()],H.prototype,"rowHighlightIds",null),e([a()],H.prototype,"selectionSource",null),e([a()],H.prototype,"showAllRelatedTables",null),e([a()],H.prototype,"showPrompt",null),e([a()],H.prototype,"showRelatedTableCallback",null),e([a()],H.prototype,"size",null),e([a({readOnly:!0})],H.prototype,"state",null),e([a({constructOnly:!0})],H.prototype,"tableController",null),e([a({constructOnly:!0})],H.prototype,"tableParent",null),e([a()],H.prototype,"tableTemplate",null),e([a()],H.prototype,"tableTemplateOverride",null),e([a()],H.prototype,"title",void 0),e([a()],H.prototype,"timeExtent",null),e([a()],H.prototype,"timeZone",null),e([a()],H.prototype,"view",null),e([a({type:y}),P(["cell-click","cell-dblclick","cell-pointerover","cell-pointerout","cell-keydown","column-reorder","show-related-table"])],H.prototype,"viewModel",void 0),e([a({type:f,nonNullable:!0})],H.prototype,"visibleElements",void 0),e([a({type:f})],H.prototype,"visibleElementsOverride",null),H=j=e([r("esri.widgets.FeatureTable")],H);const N=H;export{N as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../chunks/tslib.es6.js";import"../../intl.js";import{property as t}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import"../../core/RandomLCG.js";import{subclass as i}from"../../core/accessorSupport/decorators/subclass.js";import o from"../Widget.js";import{css as s}from"./css.js";import{zoomToFeature as a}from"../Popup/actions.js";import{loadCalciteComponents as r}from"../support/componentsUtils.js";import"../support/widgetUtils.js";import{messageBundle as c}from"../support/decorators/messageBundle.js";import{tsx as n,tsxFragment as l}from"../support/jsxFactory.js";import{substitute as p}from"../../intl/substitute.js";const d=a.clone();let u=class extends o{constructor(e,t){super(e,t),this.messages=null,this.closed=!1,this.closable=!0,this._handleOpenFeature=e=>{this.emit("open-feature",{feature:e})},this._handleZoomToFeature=e=>{this.emit("zoom-to-feature",{featureWidget:e})}}loadDependencies(){return r({action:()=>import("@esri/calcite-components/dist/components/calcite-action"),"action-bar":()=>import("@esri/calcite-components/dist/components/calcite-action-bar"),"action-group":()=>import("@esri/calcite-components/dist/components/calcite-action-group"),"flow-item":()=>import("@esri/calcite-components/dist/components/calcite-flow-item")})}render(){const{flowItems:e}=this,t=e?.toArray();return n(l,null,t?.map(((t,i)=>this._renderFlowItem(t,i===e.length-1))))}_handleCloseClick(){this.emit("close")}_handleExitClick(){this.emit("exit")}_handleDrillInBackClick(){const e=this.flowItems?.pop();e&&("showAllEnabled"in e.viewModel&&(e.viewModel.showAllEnabled=!1),e&&(e.viewModel=null,e.destroy()))}_getExitMessage(e){switch(e.flowType){case"feature":case"feature-association":return"";case"feature-relationship":return this.messages.exitRelatedRecords;case"feature-utility-network-associations":case"feature-utility-network-association-type":return this.messages.exitAssociations}}_renderFlowItem(e,t){const{messages:i,closable:o,closed:a}=this,r="graphic"in e&&!e.isTable,c="feature-association"===e.flowType,l=this._getExitMessage(e),p=i.selectFeature;return n("calcite-flow-item",{bind:this,closable:o,closed:a,description:this._getDrillInFlowItemDescription(e),heading:e.title??"",key:`flow-item-${e.viewModel.uid}`,selected:t,onCalciteFlowItemBack:e=>{e.preventDefault(),this._handleDrillInBackClick()},onCalciteFlowItemClose:this._handleCloseClick},n("calcite-action",{appearance:"transparent",bind:this,class:s.actionExit,icon:"move-up",key:"exit-action",onclick:this._handleExitClick,slot:"header-actions-start",text:l,title:l}),r?n("calcite-action",{appearance:"transparent",bind:this,icon:"zoom-to-object",key:"open-feature-action",onclick:()=>this._handleOpenFeature(e),slot:"header-actions-end",text:p,title:p}):null,c?n("calcite-action-bar",{expandDisabled:!0,expanded:!0,key:"header-action-bar",scale:"s",slot:"action-bar"},n("calcite-action-group",{overlayPositioning:"fixed",scale:"s"},this._renderDefaultActions(e))):null,n("div",{class:s.container},e.render()))}_renderDefaultActions(e){const t=this._getActionTitle(d);return n("calcite-action",{active:d.active,appearance:"solid",bind:this,"data-action-uid":d.uid,disabled:d.disabled,icon:d.icon??"question",indicator:d.indicator,key:`action-${d.uid}`,loading:d.active,onclick:()=>this._handleZoomToFeature(e),scale:"s",text:t,textEnabled:!0,title:t})}_getActionTitle(e){const{messages:t}=this,{id:i}=e,o=e.title??"";return"zoom-to-feature"===i?p(o,{messages:t}):o}_getDrillInFlowItemDescription(e){switch(e.flowType){case"feature":case"feature-association":case"feature-utility-network-associations":return e.viewModel.description??"";case"feature-relationship":return e.featureCountDescription;case"feature-utility-network-association-type":return e.description??""}}};e([t()],u.prototype,"flowItems",void 0),e([t(),c("esri/widgets/Features/t9n/Features")],u.prototype,"messages",void 0),e([t()],u.prototype,"closed",void 0),e([t()],u.prototype,"closable",void 0),u=e([i("esri.widgets.Features.FeaturesDrillIn")],u);const m=u;export{m as default};
5
+ import{_ as e}from"../../chunks/tslib.es6.js";import"../../intl.js";import{stripHTML as t}from"../../core/string.js";import{property as i}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import"../../core/RandomLCG.js";import{subclass as o}from"../../core/accessorSupport/decorators/subclass.js";import s from"../Widget.js";import{css as a}from"./css.js";import{zoomToFeature as r}from"../Popup/actions.js";import{loadCalciteComponents as c}from"../support/componentsUtils.js";import"../support/widgetUtils.js";import{messageBundle as n}from"../support/decorators/messageBundle.js";import{tsx as l,tsxFragment as p}from"../support/jsxFactory.js";import{substitute as d}from"../../intl/substitute.js";const u=r.clone();let m=class extends s{constructor(e,t){super(e,t),this.messages=null,this.closed=!1,this.closable=!0,this._handleOpenFeature=e=>{this.emit("open-feature",{feature:e})},this._handleZoomToFeature=e=>{this.emit("zoom-to-feature",{featureWidget:e})}}loadDependencies(){return c({action:()=>import("@esri/calcite-components/dist/components/calcite-action"),"action-bar":()=>import("@esri/calcite-components/dist/components/calcite-action-bar"),"action-group":()=>import("@esri/calcite-components/dist/components/calcite-action-group"),"flow-item":()=>import("@esri/calcite-components/dist/components/calcite-flow-item")})}render(){const{flowItems:e}=this,t=e?.toArray();return l(p,null,t?.map(((t,i)=>this._renderFlowItem(t,i===e.length-1))))}_handleCloseClick(){this.emit("close")}_handleExitClick(){this.emit("exit")}_handleDrillInBackClick(){const e=this.flowItems?.pop();e&&("showAllEnabled"in e.viewModel&&(e.viewModel.showAllEnabled=!1),e&&(e.viewModel=null,e.destroy()))}_getExitMessage(e){switch(e.flowType){case"feature":case"feature-association":return"";case"feature-relationship":return this.messages.exitRelatedRecords;case"feature-utility-network-associations":case"feature-utility-network-association-type":return this.messages.exitAssociations}}_renderFlowItem(e,i){const{messages:o,closable:s,closed:r}=this,c="graphic"in e&&!e.isTable,n="feature-association"===e.flowType,p=this._getExitMessage(e),d=o.selectFeature;return l("calcite-flow-item",{bind:this,closable:s,closed:r,description:t(this._getDrillInFlowItemDescription(e)??""),heading:t(e.title??""),key:`flow-item-${e.viewModel.uid}`,selected:i,onCalciteFlowItemBack:e=>{e.preventDefault(),this._handleDrillInBackClick()},onCalciteFlowItemClose:this._handleCloseClick},l("calcite-action",{appearance:"transparent",bind:this,class:a.actionExit,icon:"move-up",key:"exit-action",onclick:this._handleExitClick,slot:"header-actions-start",text:p,title:p}),c?l("calcite-action",{appearance:"transparent",bind:this,icon:"zoom-to-object",key:"open-feature-action",onclick:()=>this._handleOpenFeature(e),slot:"header-actions-end",text:d,title:d}):null,n?l("calcite-action-bar",{expandDisabled:!0,expanded:!0,key:"header-action-bar",scale:"s",slot:"action-bar"},l("calcite-action-group",{overlayPositioning:"fixed",scale:"s"},this._renderDefaultActions(e))):null,l("div",{class:a.container},e.render()))}_renderDefaultActions(e){const t=this._getActionTitle(u);return l("calcite-action",{active:u.active,appearance:"solid",bind:this,"data-action-uid":u.uid,disabled:u.disabled,icon:u.icon??"question",indicator:u.indicator,key:`action-${u.uid}`,loading:u.active,onclick:()=>this._handleZoomToFeature(e),scale:"s",text:t,textEnabled:!0,title:t})}_getActionTitle(e){const{messages:t}=this,{id:i}=e,o=e.title??"";return"zoom-to-feature"===i?d(o,{messages:t}):o}_getDrillInFlowItemDescription(e){switch(e.flowType){case"feature":case"feature-association":case"feature-utility-network-associations":return e.viewModel.description??"";case"feature-relationship":return e.featureCountDescription;case"feature-utility-network-association-type":return e.description??""}}};e([i()],m.prototype,"flowItems",void 0),e([i(),n("esri/widgets/Features/t9n/Features")],m.prototype,"messages",void 0),e([i()],m.prototype,"closed",void 0),e([i()],m.prototype,"closable",void 0),m=e([o("esri.widgets.Features.FeaturesDrillIn")],m);const h=m;export{h as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../Color.js";import"../../../intl.js";import{addTokenParameter as i}from"../../../kernel.js";import s from"../../../request.js";import l from"../../../core/Accessor.js";import{isSome as r}from"../../../core/arrayUtils.js";import n from"../../../core/Collection.js";import has from"../../../core/has.js";import{JSONMap as a}from"../../../core/jsonMap.js";import o from"../../../core/Logger.js";import{debounce as u}from"../../../core/promiseUtils.js";import{on as c,watch as d,whenOnce as y,initial as h}from"../../../core/reactiveUtils.js";import{px2pt as m}from"../../../core/screenUtils.js";import{parseWhereClause as p}from"../../../core/sql.js";import{addQueryParameters as f}from"../../../core/urlUtils.js";import{property as g}from"../../../core/accessorSupport/decorators/property.js";import{subclass as b}from"../../../core/accessorSupport/decorators/subclass.js";import{OriginId as S}from"../../../core/accessorSupport/PropertyOrigin.js";import{EffectView as _}from"../../../layers/effects/EffectView.js";import{effectFunctionsFromJSON as w}from"../../../layers/effects/jsonUtils.js";import{getEffectiveDisplayFilter as v}from"../../../layers/support/displayFilterUtils.js";import{ExportImageParameters as L}from"../../../layers/support/ExportImageParameters.js";import{getRendererFields as E}from"../../../layers/support/fieldUtils.js";import{isFeatureLayer as C}from"../../../layers/support/layerUtils.js";import{getPixelValueRange as I}from"../../../layers/support/rasterFormats/pixelRangeUtils.js";import{fromJSON as F}from"../../../renderers/support/jsonUtils.js";import{isSupportedRenderer3D as R}from"../../../renderers/support/rendererConversion.js";import V from"../../../renderers/visualVariables/SizeVariable.js";import D from"../../../renderers/visualVariables/support/SizeVariableLegendOptions.js";import{updateReferenceSizeSymbol as x}from"../../../smartMapping/renderers/support/referenceSizeUtils.js";import z from"../../../symbols/SimpleFillSymbol.js";import T from"../../../symbols/SimpleMarkerSymbol.js";import{applyCIMSymbolColor as j}from"../../../symbols/support/cimSymbolUtils.js";import{SymbolSizeDefaults as O}from"../../../symbols/support/previewUtils.js";import{renderSymbol as P}from"../../../symbols/support/renderUtils.js";import{renderColorRampPreviewHTML as A,renderDotDensityPreviewHTML as M,renderPieChartPreviewHTML as U,renderPreviewHTML as k}from"../../../symbols/support/symbolUtils.js";import{isVolumetricSymbol as B}from"../../../symbols/support/utils.js";import{getEffectiveClusterSizeVariable as N}from"./clusterUtils.js";import{getColorFromPointCloudStops as q,getRampStopsForPointCloud as $,getStretchRampStops as H,getRampStops as W}from"./colorRampUtils.js";import{getHeatmapRampStops as G}from"./heatmapRampUtils.js";import{getRotationAngleForFocus as J,getRelationshipRampElement as Q}from"./relationshipRampUtils.js";import{getRampStops as Z,realWorldMaxSize as K,realWorldMinSize as X}from"./sizeRampUtils.js";import{specialCharsLessThan as Y,specialCharsGreaterThan as ee,getReferenceSizeAuthoringInfoVisualVariable as te,getSymbolForFlowRenderer as ie,getMedianColor as se,rgbImgSource as le,getDateFormatOptions as re}from"./utils.js";import{formatNumberLabel as ne}from"../../smartMapping/support/utils.js";import{fetchMessageBundle as ae}from"../../../intl/messages.js";import{substitute as oe}from"../../../intl/substitute.js";const ue=16,ce="https://utility.arcgis.com/sharing/tools/legend",de="esri.layers.ImageryLayer",ye="esri.layers.ImageryTileLayer",he="esri.layers.WCSLayer",me=/^\s*(return\s+)?\$view\.scale\s*(;)?\s*$/i,pe=new a({esriGeometryPoint:"point",esriGeometryMultipoint:"multipoint",esriGeometryPolyline:"polyline",esriGeometryPolygon:"polygon",esriGeometryMultiPatch:"multipatch"}),fe=new T({size:6,outline:{color:[128,128,128,.5],width:.5}}),ge=new z({style:"solid"});function be(e){return"flow"===e.type}function Se(e){return"vector-field"===e.type}function _e(e){return"raster-colormap"===e.type}function we(e){return"raster-stretch"===e.type}function ve(e){return"raster-shaded-relief"===e.type}function Le(e){return"esri.renderers.SimpleRenderer"===e.declaredClass}function Ee(e){return"esri.renderers.ClassBreaksRenderer"===e.declaredClass}function Ce(e){return"esri.renderers.UniqueValueRenderer"===e.declaredClass}function Ie(e){return"esri.renderers.HeatmapRenderer"===e.declaredClass}function Fe(e){return Ve(e)||De(e)||xe(e)||Re(e)}function Re(e){return"esri.renderers.PointCloudRGBRenderer"===e.declaredClass}function Ve(e){return"esri.renderers.PointCloudClassBreaksRenderer"===e.declaredClass}function De(e){return"esri.renderers.PointCloudStretchRenderer"===e.declaredClass}function xe(e){return"esri.renderers.PointCloudUniqueValueRenderer"===e.declaredClass}function ze(e){return"esri.renderers.DotDensityRenderer"===e.declaredClass}function Te(e){return"esri.renderers.PieChartRenderer"===e.declaredClass}function je(e,t){return Le(e)||Ee(e)||Ce(e)||Ie(e)||ze(e)||Te(e)?"2d"===t.type||R(e):we(e)||_e(e)||ve(e)||Ve(e)||De(e)||xe(e)||Se(e)||be(e)}function Oe(e){return"esri.layers.BuildingSceneLayer"===e.declaredClass}function Pe(e){return"esri.layers.SubtypeGroupLayer"===e.declaredClass}function Ae(e){return"esri.layers.VoxelLayer"===e.declaredClass}function Me(e){return"esri.layers.WMSLayer"===e.declaredClass}function Ue(e){return"esri.layers.WMTSLayer"===e.declaredClass}function ke(e){return"esri.layers.MapImageLayer"===e.declaredClass}function Be(e){return"esri.layers.TileLayer"===e.declaredClass}function Ne(e){return e.declaredClass===de}function qe(e){return e.declaredClass===ye}function $e(e){return e.declaredClass===he}function He(e){return"stretch-ramp"===e.type}function We(e){const t="authoringInfo"in e?e?.authoringInfo:null;return"univariate-color-size"===t?.type}function Ge(e){const t="authoringInfo"in e?e?.authoringInfo:null;return"univariate-color-size"===t?.type&&"above-and-below"===t?.univariateTheme}function Je(e){return"sublayers"in e}async function Qe(e,t){const i=await ae("esri/widgets/Legend/t9n/Legend");return"previewTemplateAriaLabel"!==e||t||(e="previewAriaLabel"),oe(i[e],{label:t})}function Ze(e,t){const{field:i,field2:s,field3:l,fieldDelimiter:r,valueExpression:n}=e;if(!i)return null;const a=!(!i&&!n||!s&&!l)?t?.toString().split(r||""):[t],o=i?{[i]:a?.[0]}:null;return o&&(s&&(o[s]=a?.[1]),l&&(o[l]=a?.[2])),o}const Ke=new T({style:"path",path:"M10,5 L5,0 0,5 M5,0 L5,15",size:15,outline:{width:1,color:[85,85,85,1]}});let Xe={},Ye=class extends l{constructor(e){super(e),this._hasColorRamp=!1,this._hasOpacityRamp=!1,this._hasSizeRamp=!1,this._webStyleSymbolCache=new Map,this._dotDensityUrlCache=new Map,this._scaleDrivenSizeVariable=null,this._hasClusterSizeVariable=!1,this._layerDefinitionExpression=null,this._layerDefinitionExpressionClause=null,this._layerDisplayFilterId=null,this._layerDisplayFilterClause=null,this.children=new n,this.layerView=null,this.layer=null,this.legendElements=[],this.parent=null,this.hideLayersNotInCurrentView=!1,this.keepCacheOnDestroy=!1,this.respectLayerDefinitionExpression=!1,this.respectLayerVisibility=!0,this.sublayerIds=[],this.title=null,this.view=null}initialize(){const e=()=>this.notifyChange("ready");this.addHandles([c((()=>this.children),"change",(t=>{const{added:i,removed:s}=t;i.forEach((t=>{const i=`activeLayerInfo-ready-watcher-${t.layer.uid}`;this.addHandles(d((()=>t.ready),e,h),i)})),s.forEach((e=>this.removeHandles(e.layer.uid))),e()}))]),this.keepCacheOnDestroy||(Xe={})}destroy(){this._webStyleSymbolCache=null,this._dotDensityUrlCache=null,this._scaleDrivenSizeVariable=null,this.keepCacheOnDestroy||(Xe=null),this._layerDefinitionExpressionClause=null}get effectList(){const e=this.layer;let t=null;return"effect"in e&&e.effect&&(t=new _,t.effect=e.effect,t.endTransition(),t.scale=this.scale),t}get opacity(){const e=this.layer.opacity,t=this.parent?.opacity,i=this.layer.parent,s=i&&"uid"in i?this._getParentLayerOpacity(i):null;return null!=t?t*e:null!=s?s*e:e}get ready(){return null===this.layer||(this.children.length>0?this._isGroupActive():this.legendElements.length>0)}get scale(){return this.view?.scale??0}get isScaleDriven(){const e=this.layer;if(null===e)return!1;if("effect"in e&&e.effect&&Array.isArray(e.effect))return!0;if("featureReduction"in e&&e.featureReduction){if("cluster"===e.featureReduction.type)return!0;if("binning"===e.featureReduction.type&&"renderer"in e.featureReduction&&e.featureReduction.renderer)return this._isRendererScaleDriven(e.featureReduction.renderer)}return"renderer"in e&&e.renderer?!!("displayFilterInfo"in e&&e.displayFilterInfo&&Ce(e.renderer))||this._isRendererScaleDriven(e.renderer):this._isLayerScaleDriven(this.layer)}get version(){return this._get("version")+1}async buildLegendElementsForFeatureCollections(e){if(!(!this.hideLayersNotInCurrentView||await this._isLayerInCurrentView()))return this.legendElements=[],void this.notifyChange("ready");const t=Array.from(e,(e=>{if(C(e))return this._getRendererLegendElements(e.renderer,{title:e.title});if(e.featureSet?.features.length){const t=e.layerDefinition,i=t?.drawingInfo,s=i&&F(i.renderer),l=pe.read(t.geometryType);return s?this._getRendererLegendElements(s,{title:e.name,geometryType:l}):(o.getLogger(this).warn("drawingInfo not available!"),null)}return null}));try{const e=[],i=await Promise.allSettled(t);for(const t of i)if("fulfilled"===t.status)for(const i of t.value??[])e.push(i);this.legendElements=e,this.notifyChange("ready")}catch(i){o.getLogger(this).warn("error while building legend for layer!",i)}}async buildLegendElementsForRenderer(e){try{const t=!this.hideLayersNotInCurrentView||await this._isLayerInCurrentView();this.legendElements=t?await this._getRendererLegendElements(e):[],this.notifyChange("ready")}catch(t){o.getLogger(this).warn("error while building legend for layer!",t)}}async buildLegendElementsForFeatureReduction(e){try{const t=!this.hideLayersNotInCurrentView||await this._isLayerInCurrentView();this.legendElements=t?await this._getLegendElementsForFeatureReduction(e):[],this.notifyChange("ready")}catch(t){o.getLogger(this).warn("error while building legend for layer!",t)}}async buildLegendElementsForTools(){const e=this.layer;if(Ae(e))this._constructLegendElementsForVoxelLayer();else if(Ue(e))this._constructLegendElementsForWMTSlayer();else if(Me(e))await this._constructLegendElementsForWMSSublayers();else if(Oe(e))await this._constructLegendElementsForBuildingSceneLayer();else if(ke(e)||Be(e)||Pe(e))await this._constructLegendElementsForSublayers();else{this.removeHandles("imageryLayers-watcher");let t="default";if(Ne(e)){const i=e;t=(i?.rasterFunction?.functionName||"default")+"_"+(e.bandIds?.length?e.bandIds.join(""):"###")}if(qe(e)||"link-chart"===e.type)return;await this._getLegendLayers(`${e.uid}-${t}`).then((async t=>{this.legendElements=[],this.notifyChange("ready");const i=t.map((async t=>{if(Ne(e)){const t=d((()=>[e.rasterFunction,e.bandIds]),(()=>u((async()=>{Xe.default=null,e.renderer?await this.buildLegendElementsForRenderer(e.renderer):await this.buildLegendElementsForTools()}))()));this.addHandles(t,"imageryLayers-watcher")}const i=this._generateSymbolTableElementForLegendLayer(t);i?.infos.length&&(Ne(e)&&(i.title=e.title),this.legendElements.push(i)),this.notifyChange("ready")}));await Promise.allSettled(i)})).catch((e=>{o.getLogger(this).warn("Request to server for legend has failed!",e)}))}}async _isLayerInCurrentView(){const e=this.layer,t=this.layerView,i=t&&"createQuery"in t&&"queryFeatureCount"in t;if(!i&&!(t&&"createQuery"in e&&"queryFeatureCount"in e))return!0;await y((()=>!t.updating));const s=i?"createQuery"in t&&t.createQuery():"createQuery"in e&&e.createQuery();if(!s)return!0;s.geometry=this.view.extent;return 0!==(i?"queryFeatureCount"in t&&await t.queryFeatureCount(s):"queryFeatureCount"in e&&await e.queryFeatureCount(s))}_getParentLayerOpacity(e){let t=1;const i=e.parent;return i&&"uid"in i&&(t=this._getParentLayerOpacity(i)),e.opacity*t}_isGroupActive(){return this.children.some((e=>e.ready))}_isRendererScaleDriven(e){if("dot-density"===e.type)return!0;const t="valueExpression"in e?e.valueExpression:null;if(me.test(t))return!0;const i="visualVariables"in e?e.visualVariables:null;return!!i?.some((e=>this._isScaleDrivenSizeVariable(e)))||this._hasScaleDrivenSymbols(e)}_hasScaleDrivenSymbols(e){switch(e.type){case"simple":return this._isScaleDrivenSymbol(e.symbol);case"class-breaks":return this._isScaleDrivenSymbol(e.defaultSymbol)||e.classBreakInfos.some((e=>this._isScaleDrivenSymbol(e.symbol)));case"unique-value":return this._isScaleDrivenSymbol(e.defaultSymbol)||!!e.uniqueValueInfos?.some((e=>this._isScaleDrivenSymbol(e.symbol)))}return!1}_isScaleDrivenSymbol(e){if("cim"===e?.type){const{primitiveOverrides:t,minScale:i,maxScale:s}=e.data,l=t?.some((e=>/\$view\.scale/.test(e.valueExpressionInfo?.expression||"")))??!1;return null!=i||null!=s||l}return!1}_isScaleDrivenSizeVariable(e){if(e&&"size"!==e.type)return!1;const t=e,i=t.minSize,s=t.maxSize;return!("object"!=typeof i||!i||!this._isScaleDrivenSizeVariable(i))||(!("object"!=typeof s||!s||!this._isScaleDrivenSizeVariable(s))||me.test(t.valueExpression))}_isLayerScaleDriven(e){if("minScale"in e&&e.minScale>0||"maxScale"in e&&e.maxScale>0)return!0;if("sublayers"in e&&e.sublayers)return e.sublayers.some((e=>this._isLayerScaleDriven(e)));const t=e.parent;if(!1===e.loaded&&t&&ke(t)&&"source"in e&&e.source&&"map-layer"===e.source.type)for(const i of t.sourceJSON.layers??[])if(i.id===e.source.mapLayerId&&(i.minScale>0||i.maxScale>0))return!0;return!1}async _constructLegendElementsForVoxelLayer(){this.legendElements=[],this.removeHandles("voxel-style-watcher"),this.removeHandles("voxel-current-variable");const e=this.layer;this.addHandles(d((()=>e.currentVariableId),(()=>this._constructLegendElementsForVoxelLayer())),"voxel-current-variable"),this.addHandles(d((()=>e.getVariableStyles()),(()=>this._constructLegendElementsForVoxelLayer())),"voxel-style-watcher");const t=e.getVariableStyle(null),i=[];if(t)if(t.uniqueValues?.length){const e=[];t.uniqueValues.forEach((t=>{t.enabled&&e.push({label:t.label||`${t.value}`,value:t.value,symbol:new z({color:t.color,outline:null})})})),e.length&&i.push({type:"symbol-table",title:t.label,infos:e})}else if(t.transferFunction){const{colorStops:e,stretchRange:s}=t.transferFunction,l=e.toArray().reverse(),r=s.map(((e,t)=>`${0===t?Y:ee} ${ne(e)}`)).reverse(),n=l.map((e=>({color:e.color,value:null,label:null})));n[0].label=r[0],n[n.length-1].label=r[1],i.push({type:"color-ramp",title:t.label,infos:n,preview:A(l.map((e=>e.color)),{ariaLabel:await Qe("previewColorRampAriaLabel")})})}const s=e.opacity,l=i.reduce(((e,t)=>[...e,...this._getAllInfos(t)]),[]).filter((e=>!!e?.symbol)).map((e=>this._getSymbolPreview(e,s)));await Promise.allSettled(l),this.legendElements=i,this.notifyChange("ready")}_constructLegendElementsForWMTSlayer(){this.legendElements=[],this.removeHandles("wmts-activeLayer-watcher");const e=this.layer.activeLayer;this.addHandles(d((()=>{const{layer:e}=this;return e&&"activeLayer"in e&&e.activeLayer}),(()=>this._constructLegendElementsForWMTSlayer())),"wmts-activeLayer-watcher");const t=e.styleId?e.styles?.find((({id:t})=>t===e.styleId))?.legendUrl:void 0;t&&(this.legendElements=[{type:"symbol-table",title:e.title,infos:[{src:t,opacity:this.opacity}]}]),this.notifyChange("ready")}async _constructLegendElementsForWMSSublayers(){this.legendElements=[],this.removeHandles("wms-sublayers-watcher");const e=this.layer;let t=null;(e.customParameters||e.customLayerParameters)&&(t={...e.customParameters,...e.customLayerParameters}),this.addHandles(d((()=>{const{layer:e}=this;return e&&"sublayers"in e&&e.sublayers}),(()=>this._constructLegendElementsForWMSSublayers())),"wms-sublayers-watcher"),this.legendElements=await this._generateLegendElementsForWMSSublayers(e.sublayers,t),this.notifyChange("ready")}async _generateLegendElementsForWMSSublayers(e,t){const i=this.layer,s=[];this.addHandles(e.on("change",(()=>this._constructLegendElementsForWMSSublayers())),"wms-sublayers-watcher");const l=this.sublayerIds?.map((e=>i.findSublayerById(e)))?.filter(r)??[],n=l.length?l:e.toArray();for(const r of n){const e=d((()=>[r.title,r.visible,r.legendEnabled]),(()=>this._constructLegendElementsForWMSSublayers()));if(this.addHandles(e,"wms-sublayers-watcher"),!this.respectLayerVisibility||r.visible&&r.legendEnabled){const e=await this._generateSymbolTableElementForWMSSublayer(r,t);e?.infos.length&&s.unshift(e)}}return s}async _generateSymbolTableElementForWMSSublayer(e,t){if(!e.legendUrl&&e.sublayers){const i=(await this._generateLegendElementsForWMSSublayers(e.sublayers,t)).filter((e=>e));return{type:"symbol-table",title:e.title,infos:i}}return this._generateSymbolTableElementForLegendUrl(e,t)}async _generateSymbolTableElementForLegendUrl(e,t){let i=e.legendUrl;if(!i)return;const l={type:"symbol-table",title:e.title||e.name||String(e.id??""),infos:[]};t&&(i=f(i,t));let r=null;const n=e.layer?.opacity;try{r=(await s(i,{responseType:"image"})).data,r&&(r.style.opacity=n)}catch{}return l.infos.push({src:i,preview:r,opacity:n}),l}_getLegendLayers(e,t){const i=Xe&&Xe[e];return i?Promise.resolve(i):this._legendRequest(t).then((t=>{const i=t.layers;return Xe[e]=i,i}))}_legendRequest(e){const t=this.layer;let i={f:"json",dynamicLayers:e};if(Ne(t)){const e=t.exportImageServiceParameters.rasterFunction;if(e&&(i.renderingRule=JSON.stringify(e.functionDefinition?.toJSON()||e.toJSON())),t.bandIds&&(i.bandIds=t.bandIds.join()),t.raster||t.viewId||t.customParameters){const{raster:e,viewId:s,customParameters:l}=t;i={raster:e,viewId:s,...i,...l}}}let l=t.url.replace(/(\/)+$/,"");if("version"in t&&+t.version>=10.01){const e=l.indexOf("?");e>-1?l=l.slice(0,e)+"/legend"+l.slice(e):l+="/legend"}else{const e=l.toLowerCase().indexOf("/rest/"),t=-1===e?l:l.slice(0,e)+l.slice(e+5);l=ce+"?soapUrl="+encodeURI(t)+"&returnbytes=true"}return s(l,{query:i}).then((e=>e.data))}async _constructLegendElementsForBuildingSceneLayer(){this.legendElements=[],this.removeHandles("sublayers-watcher");const e=this.layer;this.addHandles(d((()=>e.sublayers),(()=>this._constructLegendElementsForBuildingSceneLayer())),"sublayers-watcher");try{this.legendElements=await this._generateLegendElementsForBuildingSublayers(e.sublayers,this.opacity),this.notifyChange("ready")}catch(t){o.getLogger(this).warn("Request to server for legend has failed!",t)}}async _generateLegendElementsForBuildingSublayers(e,t){let i=[];this.addHandles(e.on("change",(()=>this._constructLegendElementsForBuildingSceneLayer())),"sublayers-watcher");const s=e.toArray();for(const l of s){const e=d((()=>["renderer"in l&&l.renderer,l.opacity,l.title,l.visible]),(()=>this._constructLegendElementsForBuildingSceneLayer()));if(this.addHandles(e,"sublayers-watcher"),!this.respectLayerVisibility||l.visible){const e=null!=l?.opacity?l.opacity:null,s=null!=e?e*t:t;if("building-group"===l.type){const e={type:"symbol-table",title:l.title,infos:[]},t=await this._generateLegendElementsForBuildingSublayers(l.sublayers,s);e.infos.push(...t),i=[e,...i]}else if(l.renderer){i=[...await this._getRendererLegendElements(l.renderer,{title:l.title,opacity:s,sublayer:l}),...i]}}}return i.filter((e=>!!e&&(!("infos"in e)||!e.infos||e.infos.length>0)))}async _constructLegendElementsForSublayers(){this.legendElements=[],this.removeHandles("sublayers-watcher");const e=this.layer;if(ke(e)||Be(e)||Pe(e)){this.addHandles(d((()=>e.sublayers),(()=>this._constructLegendElementsForSublayers)),"sublayers-watcher");try{this.legendElements=await this._generateLegendElementsForSublayers(e.sublayers,this.opacity),this.notifyChange("ready")}catch(t){o.getLogger(this).warn("Request to server for legend has failed!",t)}}}async _generateLegendElementsForSublayers(e,t,i){const s=this.layer;let l=[];this.addHandles(e.on("change",(()=>this._constructLegendElementsForSublayers())),"sublayers-watcher");let n=e.toArray();!i&&this.sublayerIds&&this.sublayerIds.length&&(n=Pe(s)?this.sublayerIds.map((e=>s.findSublayerForSubtypeCode(e))).filter(r):this.sublayerIds.map((e=>s.findSublayerById(e))).filter(r));for(const r of n){const e=d((()=>[r.renderer,r.opacity,r.title,r.visible,r.legendEnabled]),(()=>this._constructLegendElementsForSublayers()));if(this.addHandles(e,"sublayers-watcher"),!this.respectLayerVisibility||r.visible&&r.legendEnabled&&this._isSublayerInScale(r)){const e=null!=r?.opacity?r.opacity:null,s=null!=e?e*t:t,n=!Je(r)||r.originIdOf("renderer")>S.SERVICE&&!r.sublayers;if(r.renderer&&n){await r.load();l=[...await this._getRendererLegendElements(r.renderer,{title:r.title,opacity:s,sublayer:r}),...l]}else if(Je(r)){const e=await this._generateSymbolTableElementForSublayer(r,s,i);e&&l.unshift(e)}}}return l.filter((e=>!!e&&(!("infos"in e)||!e.infos||e.infos.length>0)))}async _generateSymbolTableElementForSublayer(e,t,i){if(!i){i=new Map;const t=this.layer,s=e.source;let l=null;if(!(!s||"map-layer"===s.type&&s.mapLayerId===e.id&&(!s.gdbVersion||s.gdbVersion===("gdbVersion"in t&&t.gdbVersion)))||e.originIdOf("renderer")>S.SERVICE||e.originIdOf("labelingInfo")>S.SERVICE||e.originIdOf("labelsVisible")>S.SERVICE){const e=new L({layer:this.layer});l=e.hasDynamicLayers?e.dynamicLayers:null,e.destroy()}const r=l||`${t.uid}-default`;(await this._getLegendLayers(r,l)).forEach((e=>i.set(e.layerId,e)))}const s=i.get(e.id);if((!s||s?.subLayerIds&&s.defaultVisibility)&&e.sublayers){const s=await this._generateLegendElementsForSublayers(e.sublayers,t,i);return{type:"symbol-table",title:e.title,infos:s}}return this._generateSymbolTableElementForLegendLayer(s,e,t)}_generateSymbolTableElementForLegendLayer(e,t,i){if(!e?.legend||this.respectLayerVisibility&&!this._isLegendLayerInScale(e,t))return null;const s=t?.renderer;let l=t?.title||e.layerName;if(s&&(!t||t?.originIdOf("renderer")>S.SERVICE)){const e=t?.title||this._getRendererTitle(s,t);e&&(l&&"string"!=typeof e&&"title"in e&&(e.title=l),l=e)}const r={type:"symbol-table",title:l,legendType:e.legendType||null,infos:[]},n=t?this._sanitizeLegendForSublayer(e.legend.slice(),t):e.legend;return e.legendGroups&&e.legendGroups.length>0?e.legendGroups.forEach((t=>{const s={type:"symbol-table",title:t.heading,legendType:e.legendType||null,infos:this._generateSymbolTableElementInfosForLegendLayer(n.filter((e=>e.groupId===t.id)),e.layerId,i)};s.infos?.length>0&&r.infos.push(s)})):r.infos=this._generateSymbolTableElementInfosForLegendLayer(n,e.layerId,i),r.infos.length>0?r:null}_generateSymbolTableElementInfosForLegendLayer(e,t,s){return e.map((e=>{let l=e.url;if(e.imageData&&e.imageData.length>0)l=`data:image/png;base64,${e.imageData}`;else{if(0===l.indexOf("http"))return null;l=i(`${this.layer.url}/${t}/images/${l}`)}return{label:e.label,src:l,opacity:s??this.opacity,width:e.width,height:e.height}})).filter(r)}_isSublayerInScale(e){const t=e.minScale||0,i=e.maxScale||0;return!(t>0&&t<this.scale||i>this.scale)}_isLegendLayerInScale(e,t){const i=t||this.layer;let s=null,l=null,r=!0;return!i.minScale&&0!==i.minScale||!i.maxScale&&0!==i.maxScale?(0===e.minScale&&i.tileInfo&&(s=i.tileInfo.lods[0].scale),0===e.maxScale&&i.tileInfo&&(l=i.tileInfo.lods[i.tileInfo.lods.length-1].scale)):(s=Math.min(i.minScale,e.minScale)||i.minScale||e.minScale,l=Math.max(i.maxScale,e.maxScale)),(s>0&&s<this.scale||l>this.scale)&&(r=!1),r}_sanitizeLegendForSublayer(e,t){if("version"in this.layer&&+this.layer.version<10.1||0===e.length)return e;const i=t.renderer,s=e.some((e=>e.values));let l=0,r=null;return s&&e.some(((e,t)=>(e.values||(l=t,r=e,r.label||(r.label="others")),null!=r))),i?"unique-value"===i.type?r&&(e.splice(l,1),e.push(r)):"class-breaks"===i.type&&(r&&e.splice(l,1),i.legendOptions?.order||e.reverse(),r&&e.push(r)):r&&(e.splice(l,1),e.push(r)),e}async _getRendererLegendElements(e,t={}){if(!je(e,this.view))return o.getLogger(this).warn(`Renderer of type '${e.type}' not supported!`),[];if(Fe(e))return this._constructPointCloudRendererLegendElements(e,t);if(ze(e))return this._constructDotDensityRendererLegendElements(e);const i=await this._loadRenderer(e);return Te(i)?this._constructPieChartRendererLegendElements(i):this._constructRendererLegendElements(i,t)}async _getLegendElementsForFeatureReduction(e){let t=null;return"binning"===e.type?t=e.renderer:"cluster"===e.type&&(t=this._getClusterRenderer(e)),t?this._getRendererLegendElements(t):[]}_getPointCloudRendererTitle(e){return(e.legendOptions?.title||e.field)??""}async _constructPointCloudRendererLegendElements(e,t={}){const i=t.title,s=[];let l=null,r=null;if(Ve(e))l={type:"symbol-table",title:i||this._getPointCloudRendererTitle(e),infos:[]},e.colorClassBreakInfos.forEach((e=>{l.infos.unshift({label:e.label||e.minValue+" - "+e.maxValue,value:[e.minValue,e.maxValue],symbol:this._getAppliedCloneSymbol(fe,e.color)})}));else if(De(e)){const t=e.stops;let s=null;if(t?.length&&(1===t.length&&(s=t[0].color),!s)){const e=t[0].value,i=t[t.length-1].value;if(null!=e&&null!=i){s=q(e+(i-e)/2,t)}}l={type:"symbol-table",title:null,infos:[{label:null,value:null,symbol:this._getAppliedCloneSymbol(fe,s||fe.color)}]};const n=$(e.stops??[])??[];r={type:"color-ramp",title:i||this._getPointCloudRendererTitle(e),infos:n,preview:A(n.map((e=>e.color)),{ariaLabel:await Qe("previewColorRampAriaLabel")})}}else xe(e)&&(l={type:"symbol-table",title:i||this._getPointCloudRendererTitle(e),infos:[]},e.colorUniqueValueInfos?.forEach((e=>{l.infos.push({label:e.label||e.values.join(", "),value:e.values.join(", "),symbol:this._getAppliedCloneSymbol(fe,e.color)})})));l?.infos.length&&s.push(l),r?.infos.length&&s.push(r);const n=s.reduce(((e,t)=>[...e,...t.infos??[]]),[]).filter((e=>!!e.symbol)).map((t=>this._getSymbolPreview(t,this.opacity,{symbolConfig:{applyColorModulation:!!e.colorModulation}})));return await Promise.allSettled(n),s}async _getElementInfoForDotDensity(e,t){const{color:i,label:s,valueExpressionTitle:l}=t,{backgroundColor:r,outline:n,dotSize:a}=e,o=this.effectList,u=o?.effects.map((e=>e.toJSON())),c=w(u),d=await Qe("previewTemplateAriaLabel",s||l),y=a+"-"+i+"-"+r+"-"+(n&&JSON.stringify(n.toJSON()))+"-"+c,h=this._dotDensityUrlCache,m=h.has(y)?h.get(y):M(e,i,{ariaLabel:d});h.set(y,m);const p={shape:{type:"image",x:0,y:0,width:m.width,height:m.height,src:m.src},fill:null,stroke:null,offset:[0,0]},f=P([[p]],[m.width,m.height],{effectView:this.effectList,ariaLabel:d});return{opacity:1,src:m.src,preview:f,width:m.width,height:m.height}}async _constructDotDensityRendererLegendElements(e){const t=e.calculateDotValue(this.view.scale),i=e.legendOptions?.unit,s={type:"symbol-table",title:{value:t&&Math.round(t),unit:i||""},infos:[]};for(const l of e.attributes){const t=await this._getElementInfoForDotDensity(e,l);t.label=l.label||l.valueExpressionTitle||l.field,s.infos.push(t)}return[s]}async _constructPieChartRendererLegendElements(e){const t=this.layer.opacity,i=[];let s=null;const l=e.outline;e.attributes.forEach((e=>{const t=new T({color:e.color,outline:l}),s=e.label||e.valueExpressionTitle||e.field;i.push({label:s,symbol:t})}));const r=i.length?[...i]:[];if(e.othersCategory?.color&&0!==e.othersCategory?.threshold){const t=new T({color:e.othersCategory.color,outline:l});s=e.othersCategory.label||"Other",i.push({label:s,symbol:t})}if(e.defaultColor?.a){const t=new T({color:e.defaultColor,outline:l});i.push({label:e.defaultLabel,symbol:t})}const n=await this._getVisualVariableLegendElements(e,this.layer)||[];if(i.length){n.unshift({type:"symbol-table",title:null,infos:i});const t=r.filter((e=>e.label!==s)).map((e=>e.symbol.color)).filter(Boolean),a=U(t,{holePercentage:e.holePercentage,backgroundColor:e.backgroundFillSymbol?.color,effectList:this.effectList,outline:l,ariaLabel:await Qe("previewPieChartAriaLabel")});n.unshift({type:"pie-chart-ramp",title:this._getRendererTitle(e,this.layer),infos:i,preview:a})}const a=n.reduce(((e,t)=>[...e,...this._getAllInfos(t)]),[]).filter((e=>!!e?.symbol&&!e?.preview)).map((e=>this._getSymbolPreview(e,t,{effectList:this.effectList})));return await Promise.allSettled(a),n}async _getWhereClause(e,t,i,s){const l=await p(e,i),r=await E(t,i),n=new Set(r.map((e=>e.toLowerCase()))),a=l?.fieldNames.map((e=>e.toLowerCase()));return a?.some((e=>!n.has(e)))?(a?.length&&o.getLogger(this).warnOnce(`${s} will be ignored in the Legend, as fields in the expression do not match with renderer fields`),null):l}async _processDefinitionExpression(e,t){if(!("definitionExpression"in e))return;const i=e.definitionExpression;i&&this.respectLayerDefinitionExpression?this._layerDefinitionExpression!==i&&(this._layerDefinitionExpressionClause=await this._getWhereClause(i,t,e.fieldsIndex,"Definition Expression")):this._layerDefinitionExpressionClause=null,this._layerDefinitionExpression=i}async _processDisplayFilter(e,t){if(!("displayFilterInfo"in e))return;const i=e.displayFilterInfo?v(e.displayFilterInfo,this.view):null;i?.where?this._layerDisplayFilterId!==i?.id&&(this._layerDisplayFilterClause=await this._getWhereClause(i.where,t,e.fieldsIndex,"Display Filter")):this._layerDisplayFilterClause=null,this._layerDisplayFilterId=i?.id}async _constructRendererLegendElements(e,t={}){const{title:i,sublayer:s}=t,l=s||this.layer,r=te(e);Ce(e)&&(await this._processDefinitionExpression(l,e),await this._processDisplayFilter(l,e)),this._hasColorRamp=!1,this._hasOpacityRamp=!1,this._hasSizeRamp=!1,this._scaleDrivenSizeVariable=null;const n=await this._getVisualVariableLegendElements(e,l)||[],a={type:"symbol-table",title:i||this._getRendererTitle(e,l),infos:[]};let o=null,u=!1;const c=new Set;if(be(e)&&!this._hasSizeRamp){const t=await ie(e);a.infos.push({label:null,symbol:t})}else if(We(e)){let t=i;const s=Ge(e)?"univariate-above-and-below-ramp":"univariate-color-size-ramp",l=n.findIndex((e=>"color-ramp"===e.type)),r=-1!==l?n.splice(l,1)[0]:null,a=n.findIndex((e=>"size-ramp"===e.type)),o=-1!==a?n.splice(a,1)[0]:null,u=[];r&&(t=r.title,u.push(r)),o&&(t=o.title,u.push(o)),u.length>0&&n.push({type:s,title:t,infos:u})}else if(Ie(e)){const t=G(e);n.push({type:"heatmap-ramp",title:i||this._getRendererTitle(e,l),infos:t,preview:A(t.map((e=>e.color)),{effectList:this.effectList,ariaLabel:await Qe("previewColorRampAriaLabel")})})}else if(Ce(e)){const t=e.authoringInfo;if(t&&"relationship"===t.type){const{numClasses:i,field1:s,field2:r}=t,o=t.focus;if(i&&s&&r){const t=[s,r];let u=J(o)||0;for(const e of t){const{field:t,normalizationField:i,label:s}=e,r=s||{field:this._getFieldAlias(t,l),normField:i&&this._getFieldAlias(i,l)},n=Ke.clone();n.angle=u,a.infos.push({label:r,symbol:n}),c.add(n),u+=90}const d=Q({focus:o,numClasses:i,infos:e.uniqueValueInfos??[]});n.unshift(d)}}else if(Ne(this.layer)||qe(this.layer))e.uniqueValueInfos?.forEach((t=>{t.symbol&&this._checkClausesForUVR(e,t.value)&&a.infos.push({label:t.label||t.value,value:t.value,symbol:t.symbol})}));else{const{field:t,field2:s,field3:n,fieldDelimiter:o,valueExpression:c,defaultSymbol:d}=e,y=!(!t&&!c||!s&&!n),h=[];if(e.uniqueValueGroups?.forEach((i=>{const a={type:"symbol-table",title:("displayFilterInfo"in l&&l.displayFilterInfo?v(l.displayFilterInfo,this.view)?.title:null)||i.heading,infos:[]};i.classes?.forEach((i=>{const{symbol:u,values:d}=i;if(u){const h=[],m=[];for(const e of d??[]){const{value:i,value2:r,value3:a}=e,u=[],d=[];(t||c)&&(u.push(i),d.push(this._getDomainName(t,i,l))),s&&(u.push(r),d.push(this._getDomainName(s,r,l))),n&&(u.push(a),d.push(this._getDomainName(n,a,l))),h.push(y?u.join(o||""):u[0]),m.push(d.join(" - "))}const p=h.join(", ");let f=i.label;if(!f){const e=m.filter(Boolean);f=e.length?e.join(", "):p}const g=u.clone();"cim"===g.type&&r&&x(g,{innerDotSize:.5*ue,outerRingSize:ue}),h.some((t=>this._checkClausesForUVR(e,t)))&&a.infos.push({label:f,value:p,symbol:g})}})),a.infos.length&&h.push(a)})),h.length){const t=h[0];1===h.length&&"title"in t&&!t.title?a.infos.push(...t.infos??[]):(d&&(h.push({type:"symbol-table",infos:[{label:e.defaultLabel||"others",symbol:d}]}),u=!0),a.infos.push(...h)),i||e.legendOptions?.title||e.valueExpressionTitle||(a.title=null)}}e.defaultSymbol&&!u&&(a.infos.push({label:e.defaultLabel||"others",symbol:e.defaultSymbol}),u=!0)}else if(Ee(e)){if(!r){o=this._isUnclassedRenderer(e);if(!o||!this._hasSizeRamp){const t=e.classBreakInfos.filter((({symbol:e})=>e)),i="ascending-values"===e.legendOptions?.order;for(const{label:e,minValue:s,maxValue:l,symbol:r}of t){const t={label:e||(o?null:`${s} - ${l}`),value:[s,l],symbol:r};i?a.infos.push(t):a.infos.unshift(t)}o&&(a.title=null),this._updateInfosForClassedSizeRenderer(e,a.infos)}e.defaultSymbol&&!o&&(a.infos.push({label:e.defaultLabel||"others",symbol:e.defaultSymbol}),u=!0)}}else if(we(e))if(qe(this.layer)||$e(this.layer)){const t=await this._constructTileImageryStretchRendererElements(e);He(t)?n.push(t):a.infos=t}else{const t=this.layer;let i,s;e.customStatistics?.length&&({min:i,max:s}=e.customStatistics[0]);let l=[],r=t.serviceRasterInfo;if(t.rasterFunction)try{r=await t.generateRasterInfo(t.rasterFunction)}catch{}const o=I(r.pixelType);if(1===r.bandCount){const l=t.bandIds?.[0]||0;i=null!=i?i:r.statistics?r.statistics[l].min:o[0],s=null!=s?s:r.statistics?r.statistics[l].max:o[1],i||s?n.push(await this._getStretchLegendElements(e,{min:i,max:s})):this._getServerSideLegend()}else if(t.bandIds&&1===t.bandIds.length)i=null!=i?i:r.statistics?r.statistics[t.bandIds[0]].min:o[0],s=null!=s?s:r.statistics?r.statistics[t.bandIds[0]].max:o[1],i||s?n.push(await this._getStretchLegendElements(e,{min:i,max:s})):this._getServerSideLegend();else if(r.bandCount>=3){const{bandInfos:e}=r,{bandIds:i}=t;e.length>=r.bandCount?3===i?.length?(l=i.map((t=>e[t].name)),a.infos=this._createSymbolTableElementMultiBand(l)):"lerc"===t.format?(l=[0,1,2].map((t=>e[t].name)),a.infos=this._createSymbolTableElementMultiBand(l)):this._getServerSideLegend():"lerc"===t.format?(l=["band1","band2","band3"],a.infos=this._createSymbolTableElementMultiBand(l)):this._getServerSideLegend()}else this._getServerSideLegend()}else if(_e(e))e.colormapInfos.forEach((e=>{a.infos.push({label:e.label,value:e.value,symbol:this._getAppliedCloneSymbol(ge,e.color)})}));else if(Le(e)){let i=e.symbol;switch(t.geometryType){case"point":i="pointSymbol"in l?l.pointSymbol:null;break;case"polyline":i="lineSymbol"in l?l.lineSymbol:null;break;case"polygon":i="polygonSymbol"in l?l.polygonSymbol:null}const s=this._hasClusterSizeVariable&&this._getClusterSymbol()||!this._hasSizeRamp;e.symbol&&s&&a.infos.push({label:e.label,symbol:i})}else if(Se(e)){e.outputUnit&&(this.title="("+e.toJSON().outputUnit+")"),a.title=e.attributeField;const t=e.getClassBreakInfos();t?.length?t.forEach((e=>{a.infos.push({label:e.minValue+" - "+e.maxValue,symbol:e.symbol})})):a.infos.push({label:e.attributeField,symbol:e.getDefaultSymbol()})}else ve(e)&&n.push(await this._getStretchLegendElements(e,{min:0,max:255}));const d=e.defaultSymbol;!d||u||Le(e)||o&&!this._hasColorRamp&&!this._hasSizeRamp&&!this._hasOpacityRamp||n.push({type:"symbol-table",infos:[{label:e.defaultLabel||"others",symbol:d}]}),a.infos.length&&n.unshift(a);const y=null==t.opacity?this.opacity:t.opacity,h=this._isTallSymbol("visualVariables"in e?e.visualVariables:null),m=Ne(this.layer)||qe(this.layer),p=n.reduce(((e,t)=>[...e,...this._getAllInfos(t)]),[]).filter((e=>!!e?.symbol)).filter((e=>{if("cim"===e.symbol.type){const{minScale:t,maxScale:i}=e.symbol.data;if(t&&t<this.scale||i&&i>this.scale)return!1}return!0})).map((e=>this._getSymbolPreview(e,y,{isDefault:e.symbol===d,applyScaleDrivenSize:!c.has(e.symbol),symbolConfig:{isTall:h,isSquareFill:m},effectList:c.has(e.symbol)?null:this.effectList})));return e=null,await Promise.allSettled(p),n}_checkClausesForUVR(e,t){const i=Ze(e,t);return!i||(!this._layerDefinitionExpressionClause||this._layerDefinitionExpressionClause.testFeature(i))&&(!this._layerDisplayFilterClause||this._layerDisplayFilterClause.testFeature(i))}_getServerSideLegend(){setTimeout((()=>this.buildLegendElementsForTools()),0)}_getAllInfos(e){const t=e?.infos;return t?t.reduce(((e,t)=>e.concat(this._getAllInfos(t))),[]):[e]}async _constructTileImageryStretchRendererElements(e){const t=this.layer,i=t.symbolizer.rasterInfo??t.raster.rasterInfo;let s,l;const r=e?.customStatistics?.length?e.customStatistics:i?.statistics;if(r)({min:s,max:l}=r[0]);else{const e=I(i.pixelType);s=e[0],l=e[1]}if(t.hasStandardTime()&&(s=t.getStandardTimeValue(s),l=t.getStandardTimeValue(l)),1===i.bandCount||1===t.bandIds?.length)return this._getStretchLegendElements(e,{min:s,max:l});const n=(t?.bandIds?.length?t.bandIds:Array.from(Array(Math.min(i.bandCount,3)).keys())).map((e=>i.bandInfos[e].name));return n.length<3?n.push(n[1]):n.length>3&&n.splice(3),this._createSymbolTableElementMultiBand(n)}async _getStretchLegendElements(e,t){const i=e.colorRamp,s=H(i,t);return{type:"stretch-ramp",title:"",infos:s,preview:A(s.map((e=>e.color)),{ariaLabel:await Qe("previewColorRampAriaLabel")})}}_getClusterSymbol(){const e=this.layer,t="featureReduction"in e&&e.featureReduction,i=t&&"symbol"in t&&t.renderer;return i&&!0!==i?.authoringInfo?.isAutoGenerated?null:t&&"symbol"in t?t.symbol:null}async _getSizeLegendElement(e,t,i,s){return{type:"size-ramp",title:this._hasClusterSizeVariable?this._getClusterTitle(t):e,infos:await Z(i,t,await se(i),this.scale,this.view,s,this._hasClusterSizeVariable?this._getClusterSymbol():null)}}_createSymbolTableElementMultiBand(e){const t=[],i=["red","green","blue"];return e.forEach(((e,s)=>{t.push({label:{colorName:i[s],bandName:e},src:le[s],opacity:this.opacity??1})})),t}_updateInfosForClassedSizeRenderer(e,t){const i=e.authoringInfo&&"class-breaks-size"===e.authoringInfo.type,s=e.classBreakInfos.some((e=>B(e.symbol)));if(i&&s){const i=K,s=X,l=e.classBreakInfos.length,r=(i-s)/(l>1?l-1:l);t.forEach(((e,t)=>{e.size=i-r*t}))}}_isTallSymbol(e){let t=!1,i=!1;if(e)for(let s=0;s<e.length&&(!t||!i);s++){const l=e[s];"size"===l.type&&("height"===l.axis&&(t=!0),"width-and-depth"===l.axis&&(i=!0))}return t&&i}async _getSymbolPreview(e,t,i){let s=!i?.isDefault&&null==e.size&&this._hasSizeRamp?m(O.size):e.size;if(this._scaleDrivenSizeVariable&&i?.applyScaleDrivenSize){const{getSize:t}=await import("../../../renderers/visualVariables/support/visualVariableUtils.js");s=t(this._scaleDrivenSizeVariable,null,{view:this.view.type,scale:this.scale,shape:"simple-marker"===e.symbol.type?e.symbol.style:null})}const l=!i?.isDefault&&this._hasSizeRamp||!(!this._scaleDrivenSizeVariable||!i?.applyScaleDrivenSize);return k(e.symbol,{size:s,opacity:t,scale:!1,symbolConfig:i?.symbolConfig,effectView:i?.effectList,style:"legend",cimOptions:{allowScalingUp:l,viewParams:this.isScaleDriven?{viewingMode:"2d"===this.view?.type?"map":this.view?.viewingMode,scale:this.view?.scale}:null},ariaLabel:e.label&&"string"!=typeof e.label?null:await Qe("previewTemplateAriaLabel",e.label)}).then((t=>(e.preview=t,e))).catch((()=>(e.preview=null,e)))}_getClusterRenderer(e){this._hasClusterSizeVariable=!1;const t="renderer"in this.layer?this.layer.renderer:null,i=e.renderer?.clone()||t?.clone(),s=N(e,this.layerView,this.view);if(s&&null!=i&&"visualVariables"in i){const t=i.visualVariables?.some((e=>"size"===e.type&&"outline"!==e.target&&!me.test(e.valueExpression)));if(!t){if("clusterMinSize"in e&&"clusterMaxSize"in e){const{clusterMinSize:t,clusterMaxSize:i}=e;s.legendOptions=new D({showLegend:t!==i})}const t=i.visualVariables||[];i.visualVariables=t.concat([s]),this._hasClusterSizeVariable=!0}}return i}async _loadRenderer(e){const t=[],i=e.clone(),s=await se(i);if(Ee(i)||Ce(i)){const e=(i.classBreakInfos||i.uniqueValueInfos).map((e=>this._fetchSymbol(e.symbol,s).then((t=>{e.symbol=t})).catch((()=>{e.symbol=null}))));Array.prototype.push.apply(t,e)}return t.push(this._fetchSymbol(i.symbol||i.defaultSymbol,i.defaultSymbol?null:s).then((e=>{this._applySymbolToRenderer(i,e,Le(i))})).catch((()=>{this._applySymbolToRenderer(i,null,Le(i))}))),await Promise.allSettled(t),i}_applySymbolToRenderer(e,t,i){i?e.symbol=t:e.defaultSymbol=t}async _fetchSymbol(e,t){if(!e)throw new Error;if("web-style"===e.type){const i=this._webStyleSymbolCache;try{const s=await("2d"===this.view.type?e.fetchCIMSymbol({cache:i}):e.fetchSymbol({cache:i}));return this._getAppliedCloneSymbol(s,t)}catch{throw o.getLogger(this).warn("Fetching web-style failed!"),new Error}}return this._getAppliedCloneSymbol(e,t)}_getAppliedCloneSymbol(e,i){if(!e||!i)return e;const s=e.clone(),l=i&&i.toRgba();return s.type.includes("3d")?this._applyColorTo3dSymbol(s,l):"cim"===s.type?j(s,i):s.color&&(s.color=new t(l||s.color)),s}_applyColorTo3dSymbol(e,i){i&&e.symbolLayers.forEach((e=>{e&&(e.material||(e.material={}),e.material.color=new t(i))}))}async _getVisualVariableLegendElements(e,t){if(!("visualVariables"in e)||"vector-field"===e.type)return null;const i=e.visualVariables??[],s=[],l=[],n=[],a=te(e);if(2===a?.sizeStops?.length&&(Ee(e)||Ce(e))){const[e,t]=a.sizeStops;l.push(new V({field:a.field??void 0,normalizationField:a.normalizationField,minSize:e.size,maxSize:t.size,minDataValue:e.value,maxDataValue:t.value}))}for(const r of i)"color"===r.type?s.push(r):"size"===r.type?l.push(r):"opacity"===r.type&&n.push(r);const o=[...s,...l,...n];let u,c;if(0===s.length&&Ee(e)&&e.classBreakInfos&&1===e.classBreakInfos.length){const t=e.classBreakInfos[0];u=t&&t.symbol}if(0===s.length&&Le(e)&&(u=e.symbol),u)if(u.type.includes("3d")){const e=u.symbolLayers.at(0);"water"===e.type?null!=e.color&&(c=e.color):null!=e.material?.color&&(c=e.material.color)}else u.url||(c=u.color);const d=this.effectList;return(await Promise.all(o.map((async i=>{if(!i.legendOptions||!1!==i.legendOptions.showLegend){const s=be(e)?i.field:this._getRampTitle(i,t);let l=null;const r=re(t,i,this.view.timeZone);if("color"===i.type){const e=await W(i,null,r)??[];l={type:"color-ramp",title:s,infos:e,preview:A(e.map((e=>e.color)),{effectList:d,ariaLabel:await Qe("previewColorRampAriaLabel")})},this._hasColorRamp||(this._hasColorRamp=e.length>0)}else if("size"===i.type&&"outline"!==i.target)me.test(i.valueExpression)?this._hasClusterSizeVariable||(this._scaleDrivenSizeVariable=i):(l=await this._getSizeLegendElement(s,i,e,r),this._hasSizeRamp||(this._hasSizeRamp=!(null==l.infos||!l.infos.length)));else if("opacity"===i.type){const e=await W(i,c,r)??[];l={type:"opacity-ramp",title:s,infos:e,preview:A(e.map((e=>e.color)),{effectList:d,ariaLabel:await Qe("previewColorRampAriaLabel")})},this._hasOpacityRamp||(this._hasOpacityRamp=e.length>0)}return l?.infos?l:null}})))).filter(r)}_getDomainName(e,t,i){if(e&&"function"!=typeof e){const s="getField"in i&&i.getField?.(e),l=s&&"getFieldDomain"in i&&i.getFieldDomain?i.getFieldDomain(s.name,{excludeImpliedDomains:has("esri-widget-legacy-field-domain-calculation")}):null;return"coded-value"===l?.type?l.getName(t):null}return null}_getClusterTitle(e){const t=this.layer,i=e.field;if("featureReduction"in t&&t.featureReduction&&"cluster"===t.featureReduction.type){const e=t.featureReduction,s="popupTemplate"in e&&e.popupTemplate,l=s&&s.fieldInfos;if(l)for(const t of l)if(t.fieldName===i)return"cluster_count"===i?t.label||{showCount:!0}:t.label}return{showCount:!0}}_getRampTitle(e,t){let i=e.field,s=e.normalizationField,l=!1,r=!1,n=!1,a=null;i="function"==typeof i?null:i,s="function"==typeof s?null:s;const o=e.legendOptions?.title;if(null!=o)a=o;else if(e.valueExpressionTitle)a=e.valueExpressionTitle;else{if("renderer"in t&&t.renderer&&"authoringInfo"in t.renderer&&t.renderer.authoringInfo?.visualVariables){const e=t.renderer.authoringInfo.visualVariables;for(let t=0;t<e.length;t++){const i=e[t];if("color"===i.type){if("ratio"===i.style){l=!0;break}if("percent"===i.style){r=!0;break}if("percent-of-total"===i.style){n=!0;break}}}}a={field:i&&this._getFieldAlias(i,t),normField:s&&this._getFieldAlias(s,t),ratio:l,ratioPercent:r,ratioPercentTotal:n}}return a}_getRendererTitle(e,t){const i=e;if(i.legendOptions?.title)return i.legendOptions.title;if(i.valueExpressionTitle)return i.valueExpressionTitle;let s=i.field,l=null,r=null;if(Ee(i)&&(l=i.normalizationField,r="percent-of-total"===i.normalizationType),s="function"==typeof s?null:s,l="function"==typeof l?null:l,Ce(i)){const{field2:e,field3:l,fieldDelimiter:r}=i;let n=s&&this._getFieldAlias(s,t);return e&&(n=`<${n}>${r}<${this._getFieldAlias(e,t)}>`,l&&(n=`${n}${r}<${this._getFieldAlias(l,t)}>`)),n}let n=null;return(s||l)&&(n={field:s&&this._getFieldAlias(s,t),normField:l&&this._getFieldAlias(l,t),normByPct:r}),n}_getFieldAlias(e,t){const i="popupTemplate"in t?t.popupTemplate:null,s=i?.fieldInfos;let l=s?.find((t=>e===t.fieldName)),r=null;"getField"in t&&t.getField?r=t.getField(e):"fieldsIndex"in t&&t.fieldsIndex&&(r=t.fieldsIndex.get(e));let n=null;const a="featureReduction"in t&&t.featureReduction;a&&(l??="popupTemplate"in a?a.popupTemplate?.fieldInfos?.find((t=>e?.toLowerCase()===t.fieldName?.toLowerCase())):void 0,"fields"in a&&a.fields&&(n=a.fields.find((t=>t.name?.toLowerCase()===e?.toLowerCase()))));const o=l||r||n;let u=null;return o&&(u=l?.label||r?.alias||n?.alias||"name"in o&&o.name||"fieldName"in o&&o.fieldName||null),u}_isUnclassedRenderer(e){const t=e.visualVariables;let i=!1;return Ee(e)&&e.classBreakInfos&&1===e.classBreakInfos.length&&t&&(i=e.field?t.some((t=>!(!t||e.field!==t.field||(e.normalizationField||t.normalizationField)&&e.normalizationField!==t.normalizationField))):!!t.length),i}};e([g()],Ye.prototype,"children",void 0),e([g({readOnly:!0})],Ye.prototype,"effectList",null),e([g()],Ye.prototype,"layerView",void 0),e([g()],Ye.prototype,"layer",void 0),e([g()],Ye.prototype,"legendElements",void 0),e([g({readOnly:!0})],Ye.prototype,"opacity",null),e([g()],Ye.prototype,"parent",void 0),e([g({readOnly:!0,dependsOn:[]})],Ye.prototype,"ready",null),e([g()],Ye.prototype,"hideLayersNotInCurrentView",void 0),e([g()],Ye.prototype,"keepCacheOnDestroy",void 0),e([g()],Ye.prototype,"respectLayerDefinitionExpression",void 0),e([g()],Ye.prototype,"respectLayerVisibility",void 0),e([g({readOnly:!0})],Ye.prototype,"scale",null),e([g()],Ye.prototype,"sublayerIds",void 0),e([g({readOnly:!0})],Ye.prototype,"isScaleDriven",null),e([g()],Ye.prototype,"title",void 0),e([g({readOnly:!0,dependsOn:["ready"],value:0})],Ye.prototype,"version",null),e([g()],Ye.prototype,"view",void 0),Ye=e([b("esri.widgets.Legend.support.ActiveLayerInfo")],Ye);const et=Ye;export{et as default};
5
+ import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../Color.js";import"../../../intl.js";import{addTokenParameter as s}from"../../../kernel.js";import i from"../../../request.js";import l from"../../../core/Accessor.js";import{isSome as r}from"../../../core/arrayUtils.js";import n from"../../../core/Collection.js";import has from"../../../core/has.js";import{JSONMap as a}from"../../../core/jsonMap.js";import o from"../../../core/Logger.js";import{debounce as u}from"../../../core/promiseUtils.js";import{on as c,watch as d,whenOnce as y,initial as h}from"../../../core/reactiveUtils.js";import{px2pt as m}from"../../../core/screenUtils.js";import{parseWhereClause as p}from"../../../core/sql.js";import{addQueryParameters as f}from"../../../core/urlUtils.js";import{property as g}from"../../../core/accessorSupport/decorators/property.js";import{subclass as b}from"../../../core/accessorSupport/decorators/subclass.js";import{OriginId as S}from"../../../core/accessorSupport/PropertyOrigin.js";import{EffectView as _}from"../../../layers/effects/EffectView.js";import{effectFunctionsFromJSON as w}from"../../../layers/effects/jsonUtils.js";import{getEffectiveDisplayFilter as v}from"../../../layers/support/displayFilterUtils.js";import{ExportImageParameters as L}from"../../../layers/support/ExportImageParameters.js";import{getRendererFields as E}from"../../../layers/support/fieldUtils.js";import{isFeatureLayer as C}from"../../../layers/support/layerUtils.js";import{getPixelValueRange as I}from"../../../layers/support/rasterFormats/pixelRangeUtils.js";import{fromJSON as F}from"../../../renderers/support/jsonUtils.js";import{isSupportedRenderer3D as R}from"../../../renderers/support/rendererConversion.js";import V from"../../../renderers/visualVariables/SizeVariable.js";import D from"../../../renderers/visualVariables/support/SizeVariableLegendOptions.js";import{updateReferenceSizeSymbol as x}from"../../../smartMapping/renderers/support/referenceSizeUtils.js";import z from"../../../symbols/SimpleFillSymbol.js";import T from"../../../symbols/SimpleMarkerSymbol.js";import{applyCIMSymbolColor as j}from"../../../symbols/support/cimSymbolUtils.js";import{SymbolSizeDefaults as O}from"../../../symbols/support/previewUtils.js";import{renderSymbol as P}from"../../../symbols/support/renderUtils.js";import{renderColorRampPreviewHTML as A,renderDotDensityPreviewHTML as M,renderPieChartPreviewHTML as U,renderPreviewHTML as k}from"../../../symbols/support/symbolUtils.js";import{isVolumetricSymbol as B}from"../../../symbols/support/utils.js";import{getEffectiveClusterSizeVariable as N}from"./clusterUtils.js";import{getColorFromPointCloudStops as q,getRampStopsForPointCloud as H,getStretchRampStops as $,getRampStops as W}from"./colorRampUtils.js";import{getHeatmapRampStops as G}from"./heatmapRampUtils.js";import{getRotationAngleForFocus as J,getRelationshipRampElement as Q}from"./relationshipRampUtils.js";import{getRampStops as Z,realWorldMaxSize as K,realWorldMinSize as X}from"./sizeRampUtils.js";import{specialCharsLessThan as Y,specialCharsGreaterThan as ee,getReferenceSizeAuthoringInfoVisualVariable as te,getSymbolForFlowRenderer as se,getMedianColor as ie,rgbImgSource as le,getDateFormatOptions as re}from"./utils.js";import{formatNumberLabel as ne}from"../../smartMapping/support/utils.js";import{fetchMessageBundle as ae}from"../../../intl/messages.js";import{substitute as oe}from"../../../intl/substitute.js";const ue=16,ce="https://utility.arcgis.com/sharing/tools/legend",de="esri.layers.ImageryLayer",ye="esri.layers.ImageryTileLayer",he="esri.layers.WCSLayer",me=/^\s*(return\s+)?\$view\.scale\s*(;)?\s*$/i,pe=new a({esriGeometryPoint:"point",esriGeometryMultipoint:"multipoint",esriGeometryPolyline:"polyline",esriGeometryPolygon:"polygon",esriGeometryMultiPatch:"multipatch"}),fe=new T({size:6,outline:{color:[128,128,128,.5],width:.5}}),ge=new z({style:"solid"});function be(e){return"flow"===e.type}function Se(e){return"vector-field"===e.type}function _e(e){return"raster-colormap"===e.type}function we(e){return"raster-stretch"===e.type}function ve(e){return"raster-shaded-relief"===e.type}function Le(e){return"esri.renderers.SimpleRenderer"===e.declaredClass}function Ee(e){return"esri.renderers.ClassBreaksRenderer"===e.declaredClass}function Ce(e){return"esri.renderers.UniqueValueRenderer"===e.declaredClass}function Ie(e){return"esri.renderers.HeatmapRenderer"===e.declaredClass}function Fe(e){return Ve(e)||De(e)||xe(e)||Re(e)}function Re(e){return"esri.renderers.PointCloudRGBRenderer"===e.declaredClass}function Ve(e){return"esri.renderers.PointCloudClassBreaksRenderer"===e.declaredClass}function De(e){return"esri.renderers.PointCloudStretchRenderer"===e.declaredClass}function xe(e){return"esri.renderers.PointCloudUniqueValueRenderer"===e.declaredClass}function ze(e){return"esri.renderers.DotDensityRenderer"===e.declaredClass}function Te(e){return"esri.renderers.PieChartRenderer"===e.declaredClass}function je(e,t){return Le(e)||Ee(e)||Ce(e)||Ie(e)||ze(e)||Te(e)?"2d"===t.type||R(e):we(e)||_e(e)||ve(e)||Ve(e)||De(e)||xe(e)||Se(e)||be(e)}function Oe(e){return"esri.layers.BuildingSceneLayer"===e.declaredClass}function Pe(e){return"esri.layers.SubtypeGroupLayer"===e.declaredClass}function Ae(e){return"esri.layers.VoxelLayer"===e.declaredClass}function Me(e){return"esri.layers.WMSLayer"===e.declaredClass}function Ue(e){return"esri.layers.WMTSLayer"===e.declaredClass}function ke(e){return"esri.layers.MapImageLayer"===e.declaredClass}function Be(e){return"esri.layers.TileLayer"===e.declaredClass}function Ne(e){return e.declaredClass===de}function qe(e){return e.declaredClass===ye}function He(e){return e.declaredClass===he}function $e(e){return"stretch-ramp"===e.type}function We(e){const t="authoringInfo"in e?e?.authoringInfo:null;return"univariate-color-size"===t?.type}function Ge(e){const t="authoringInfo"in e?e?.authoringInfo:null;return"univariate-color-size"===t?.type&&"above-and-below"===t?.univariateTheme}function Je(e){return"sublayers"in e}async function Qe(e,t){const s=await ae("esri/widgets/Legend/t9n/Legend");return"previewTemplateAriaLabel"!==e||t||(e="previewAriaLabel"),oe(s[e],{label:t})}function Ze(e,t){const{field:s,field2:i,field3:l,fieldDelimiter:r,valueExpression:n}=e;if(!s)return null;const a=!(!s&&!n||!i&&!l)?t?.toString().split(r||""):[t],o=s?{[s]:a?.[0]}:null;return o&&(i&&(o[i]=a?.[1]),l&&(o[l]=a?.[2])),o}const Ke=new T({style:"path",path:"M10,5 L5,0 0,5 M5,0 L5,15",size:15,outline:{width:1,color:[85,85,85,1]}});let Xe={},Ye=class extends l{constructor(e){super(e),this._hasColorRamp=!1,this._hasOpacityRamp=!1,this._hasSizeRamp=!1,this._webStyleSymbolCache=new Map,this._dotDensityUrlCache=new Map,this._scaleDrivenSizeVariable=null,this._hasClusterSizeVariable=!1,this._layerDefinitionExpression=null,this._layerDefinitionExpressionClause=null,this._layerDisplayFilterId=null,this._layerDisplayFilterClause=null,this.children=new n,this.layerView=null,this.layer=null,this.legendElements=[],this.parent=null,this.hideLayersNotInCurrentView=!1,this.keepCacheOnDestroy=!1,this.respectLayerDefinitionExpression=!1,this.respectLayerVisibility=!0,this.sublayerIds=[],this.title=null,this.view=null}initialize(){const e=()=>this.notifyChange("ready");this.addHandles([c((()=>this.children),"change",(t=>{const{added:s,removed:i}=t;s.forEach((t=>{const s=`activeLayerInfo-ready-watcher-${t.layer.uid}`;this.addHandles(d((()=>t.ready),e,h),s)})),i.forEach((e=>this.removeHandles(e.layer.uid))),e()}))]),this.keepCacheOnDestroy||(Xe={})}destroy(){this._webStyleSymbolCache=null,this._dotDensityUrlCache=null,this._scaleDrivenSizeVariable=null,this.keepCacheOnDestroy||(Xe=null),this._layerDefinitionExpressionClause=null}get effectList(){const e=this.layer;let t=null;return"effect"in e&&e.effect&&(t=new _,t.effect=e.effect,t.endTransition(),t.scale=this.scale),t}get opacity(){const e=this.layer.opacity,t=this.parent?.opacity,s=this.layer.parent,i=s&&"uid"in s?this._getParentLayerOpacity(s):null;return null!=t?t*e:null!=i?i*e:e}get ready(){return null===this.layer||(this.children.length>0?this._isGroupActive():this.legendElements.length>0)}get scale(){return this.view?.scale??0}get isScaleDriven(){const e=this.layer;if(null===e)return!1;if("effect"in e&&e.effect&&Array.isArray(e.effect))return!0;if("featureReduction"in e&&e.featureReduction){if("cluster"===e.featureReduction.type)return!0;if("binning"===e.featureReduction.type&&"renderer"in e.featureReduction&&e.featureReduction.renderer)return this._isRendererScaleDriven(e.featureReduction.renderer)}return"renderer"in e&&e.renderer?!!("displayFilterInfo"in e&&e.displayFilterInfo&&Ce(e.renderer))||this._isRendererScaleDriven(e.renderer):this._isLayerScaleDriven(this.layer)}get version(){return this._get("version")+1}async buildLegendElementsForFeatureCollections(e){if(!(!this.hideLayersNotInCurrentView||await this._isLayerInCurrentView()))return this.legendElements=[],void this.notifyChange("ready");const t=Array.from(e,(e=>{if(C(e))return this._getRendererLegendElements(e.renderer,{title:e.title});if(e.featureSet?.features.length){const t=e.layerDefinition,s=t?.drawingInfo,i=s&&F(s.renderer),l=pe.read(t.geometryType);return i?this._getRendererLegendElements(i,{title:e.name,geometryType:l}):(o.getLogger(this).warn("drawingInfo not available!"),null)}return null}));try{const e=[],s=await Promise.allSettled(t);for(const t of s)if("fulfilled"===t.status)for(const s of t.value??[])e.push(s);this.legendElements=e,this.notifyChange("ready")}catch(s){o.getLogger(this).warn("error while building legend for layer!",s)}}async buildLegendElementsForRenderer(e){try{const t=!this.hideLayersNotInCurrentView||await this._isLayerInCurrentView();this.legendElements=t?await this._getRendererLegendElements(e):[],this.notifyChange("ready")}catch(t){o.getLogger(this).warn("error while building legend for layer!",t)}}async buildLegendElementsForFeatureReduction(e){try{const t=!this.hideLayersNotInCurrentView||await this._isLayerInCurrentView();this.legendElements=t?await this._getLegendElementsForFeatureReduction(e):[],this.notifyChange("ready")}catch(t){o.getLogger(this).warn("error while building legend for layer!",t)}}async buildLegendElementsForTools(){const e=this.layer;if(Ae(e))this._constructLegendElementsForVoxelLayer();else if(Ue(e))this._constructLegendElementsForWMTSlayer();else if(Me(e))await this._constructLegendElementsForWMSSublayers();else if(Oe(e))await this._constructLegendElementsForBuildingSceneLayer();else if(ke(e)||Be(e)||Pe(e))await this._constructLegendElementsForSublayers();else{this.removeHandles("imageryLayers-watcher");let t="default";if(Ne(e)){const s=e;t=(s?.rasterFunction?.functionName||"default")+"_"+(e.bandIds?.length?e.bandIds.join(""):"###")}if(qe(e)||"link-chart"===e.type)return;await this._getLegendLayers(`${e.uid}-${t}`).then((async t=>{this.legendElements=[],this.notifyChange("ready");const s=t.map((async t=>{if(Ne(e)){const t=d((()=>[e.rasterFunction,e.bandIds]),(()=>u((async()=>{Xe.default=null,e.renderer?await this.buildLegendElementsForRenderer(e.renderer):await this.buildLegendElementsForTools()}))()));this.addHandles(t,"imageryLayers-watcher")}const s=this._generateSymbolTableElementForLegendLayer(t);s?.infos.length&&(Ne(e)&&(s.title=e.title),this.legendElements.push(s)),this.notifyChange("ready")}));await Promise.allSettled(s)})).catch((e=>{o.getLogger(this).warn("Request to server for legend has failed!",e)}))}}async _isLayerInCurrentView(){const e=this.layer,t=this.layerView,s=t&&"createQuery"in t&&"queryFeatureCount"in t;if(!s&&!(t&&"createQuery"in e&&"queryFeatureCount"in e))return!0;await y((()=>!t.updating));const i=s?"createQuery"in t&&t.createQuery():"createQuery"in e&&e.createQuery();if(!i)return!0;i.geometry=this.view.extent;return 0!==(s?"queryFeatureCount"in t&&await t.queryFeatureCount(i):"queryFeatureCount"in e&&await e.queryFeatureCount(i))}_getParentLayerOpacity(e){let t=1;const s=e.parent;return s&&"uid"in s&&(t=this._getParentLayerOpacity(s)),e.opacity*t}_isGroupActive(){return this.children.some((e=>e.ready))}_isRendererScaleDriven(e){if("dot-density"===e.type)return!0;const t="valueExpression"in e?e.valueExpression:null;if(me.test(t))return!0;const s="visualVariables"in e?e.visualVariables:null;return!!s?.some((e=>this._isScaleDrivenSizeVariable(e)))||this._hasScaleDrivenSymbols(e)}_hasScaleDrivenSymbols(e){switch(e.type){case"simple":return this._isScaleDrivenSymbol(e.symbol);case"class-breaks":return this._isScaleDrivenSymbol(e.defaultSymbol)||e.classBreakInfos.some((e=>this._isScaleDrivenSymbol(e.symbol)));case"unique-value":return this._isScaleDrivenSymbol(e.defaultSymbol)||!!e.uniqueValueInfos?.some((e=>this._isScaleDrivenSymbol(e.symbol)))}return!1}_isScaleDrivenSymbol(e){if("cim"===e?.type){const{primitiveOverrides:t,minScale:s,maxScale:i}=e.data,l=t?.some((e=>/\$view\.scale/.test(e.valueExpressionInfo?.expression||"")))??!1;return null!=s||null!=i||l}return!1}_isScaleDrivenSizeVariable(e){if(e&&"size"!==e.type)return!1;const t=e,s=t.minSize,i=t.maxSize;return!("object"!=typeof s||!s||!this._isScaleDrivenSizeVariable(s))||(!("object"!=typeof i||!i||!this._isScaleDrivenSizeVariable(i))||me.test(t.valueExpression))}_isLayerScaleDriven(e){if("minScale"in e&&e.minScale>0||"maxScale"in e&&e.maxScale>0)return!0;if("sublayers"in e&&e.sublayers)return e.sublayers.some((e=>this._isLayerScaleDriven(e)));const t=e.parent;if(!1===e.loaded&&t&&ke(t)&&"source"in e&&e.source&&"map-layer"===e.source.type)for(const s of t.sourceJSON.layers??[])if(s.id===e.source.mapLayerId&&(s.minScale>0||s.maxScale>0))return!0;return!1}async _constructLegendElementsForVoxelLayer(){this.legendElements=[],this.removeHandles("voxel-style-watcher"),this.removeHandles("voxel-current-variable");const e=this.layer;this.addHandles(d((()=>e.currentVariableId),(()=>this._constructLegendElementsForVoxelLayer())),"voxel-current-variable"),this.addHandles(d((()=>e.getVariableStyles()),(()=>this._constructLegendElementsForVoxelLayer())),"voxel-style-watcher");const t=e.getVariableStyle(null),s=[];if(t)if(t.uniqueValues?.length){const e=[];t.uniqueValues.forEach((t=>{t.enabled&&e.push({label:t.label||`${t.value}`,value:t.value,symbol:new z({color:t.color,outline:null})})})),e.length&&s.push({type:"symbol-table",title:t.label,infos:e})}else if(t.transferFunction){const{colorStops:e,stretchRange:i}=t.transferFunction,l=e.toArray().reverse(),r=i.map(((e,t)=>`${0===t?Y:ee} ${ne(e)}`)).reverse(),n=l.map((e=>({color:e.color,value:null,label:null})));n[0].label=r[0],n[n.length-1].label=r[1],s.push({type:"color-ramp",title:t.label,infos:n,preview:A(l.map((e=>e.color)),{ariaLabel:await Qe("previewColorRampAriaLabel")})})}const i=e.opacity,l=s.reduce(((e,t)=>[...e,...this._getAllInfos(t)]),[]).filter((e=>!!e?.symbol)).map((e=>this._getSymbolPreview(e,i)));await Promise.allSettled(l),this.legendElements=s,this.notifyChange("ready")}_constructLegendElementsForWMTSlayer(){this.legendElements=[],this.removeHandles("wmts-activeLayer-watcher");const e=this.layer.activeLayer;this.addHandles(d((()=>{const{layer:e}=this;return e&&"activeLayer"in e&&e.activeLayer}),(()=>this._constructLegendElementsForWMTSlayer())),"wmts-activeLayer-watcher");const t=e.styleId?e.styles?.find((({id:t})=>t===e.styleId))?.legendUrl:void 0;t&&(this.legendElements=[{type:"symbol-table",title:e.title,infos:[{src:t,opacity:this.opacity}]}]),this.notifyChange("ready")}async _constructLegendElementsForWMSSublayers(){this.legendElements=[],this.removeHandles("wms-sublayers-watcher");const e=this.layer;let t=null;(e.customParameters||e.customLayerParameters)&&(t={...e.customParameters,...e.customLayerParameters}),this.addHandles(d((()=>{const{layer:e}=this;return e&&"sublayers"in e&&e.sublayers}),(()=>this._constructLegendElementsForWMSSublayers())),"wms-sublayers-watcher"),this.legendElements=await this._generateLegendElementsForWMSSublayers(e.sublayers,t),this.notifyChange("ready")}async _generateLegendElementsForWMSSublayers(e,t){const s=this.layer,i=[];this.addHandles(e.on("change",(()=>this._constructLegendElementsForWMSSublayers())),"wms-sublayers-watcher");const l=this.sublayerIds?.map((e=>s.findSublayerById(e)))?.filter(r)??[],n=l.length?l:e.toArray();for(const r of n){const e=d((()=>[r.title,r.visible,r.legendEnabled]),(()=>this._constructLegendElementsForWMSSublayers()));if(this.addHandles(e,"wms-sublayers-watcher"),!this.respectLayerVisibility||r.visible&&r.legendEnabled){const e=await this._generateSymbolTableElementForWMSSublayer(r,t);e?.infos.length&&i.unshift(e)}}return i}async _generateSymbolTableElementForWMSSublayer(e,t){if(!e.legendUrl&&e.sublayers){const s=(await this._generateLegendElementsForWMSSublayers(e.sublayers,t)).filter((e=>e));return{type:"symbol-table",title:e.title,infos:s}}return this._generateSymbolTableElementForLegendUrl(e,t)}async _generateSymbolTableElementForLegendUrl(e,t){let s=e.legendUrl;if(!s)return;const l={type:"symbol-table",title:e.title||e.name||String(e.id??""),infos:[]};t&&(s=f(s,t));let r=null;const n=e.layer?.opacity;try{r=(await i(s,{responseType:"image"})).data,r&&(r.style.opacity=n)}catch{}return l.infos.push({src:s,preview:r,opacity:n}),l}_getLegendLayers(e,t){const s=Xe&&Xe[e];return s?Promise.resolve(s):this._legendRequest(t).then((t=>{const s=t.layers;return Xe[e]=s,s}))}_legendRequest(e){const t=this.layer;let s={f:"json",dynamicLayers:e};if(Ne(t)){const e=t.exportImageServiceParameters.rasterFunction;if(e&&(s.renderingRule=JSON.stringify(e.functionDefinition?.toJSON()||e.toJSON())),t.bandIds&&(s.bandIds=t.bandIds.join()),t.raster||t.viewId||t.customParameters){const{raster:e,viewId:i,customParameters:l}=t;s={raster:e,viewId:i,...s,...l}}}let l=t.url.replace(/(\/)+$/,"");if("version"in t&&+t.version>=10.01){const e=l.indexOf("?");e>-1?l=l.slice(0,e)+"/legend"+l.slice(e):l+="/legend"}else{const e=l.toLowerCase().indexOf("/rest/"),t=-1===e?l:l.slice(0,e)+l.slice(e+5);l=ce+"?soapUrl="+encodeURI(t)+"&returnbytes=true"}return i(l,{query:s}).then((e=>e.data))}async _constructLegendElementsForBuildingSceneLayer(){this.legendElements=[],this.removeHandles("sublayers-watcher");const e=this.layer;this.addHandles(d((()=>e.sublayers),(()=>this._constructLegendElementsForBuildingSceneLayer())),"sublayers-watcher");try{this.legendElements=await this._generateLegendElementsForBuildingSublayers(e.sublayers,this.opacity),this.notifyChange("ready")}catch(t){o.getLogger(this).warn("Request to server for legend has failed!",t)}}async _generateLegendElementsForBuildingSublayers(e,t){let s=[];this.addHandles(e.on("change",(()=>this._constructLegendElementsForBuildingSceneLayer())),"sublayers-watcher");const i=e.toArray();for(const l of i){const e=d((()=>["renderer"in l&&l.renderer,l.opacity,l.title,l.visible]),(()=>this._constructLegendElementsForBuildingSceneLayer()));if(this.addHandles(e,"sublayers-watcher"),!this.respectLayerVisibility||l.visible){const e=null!=l?.opacity?l.opacity:null,i=null!=e?e*t:t;if("building-group"===l.type){const e={type:"symbol-table",title:l.title,infos:[]},t=await this._generateLegendElementsForBuildingSublayers(l.sublayers,i);e.infos.push(...t),s=[e,...s]}else if(l.renderer){s=[...await this._getRendererLegendElements(l.renderer,{title:l.title,opacity:i,sublayer:l}),...s]}}}return s.filter((e=>!!e&&(!("infos"in e)||!e.infos||e.infos.length>0)))}async _constructLegendElementsForSublayers(){this.legendElements=[],this.removeHandles("sublayers-watcher");const e=this.layer;if(ke(e)||Be(e)||Pe(e)){this.addHandles(d((()=>e.sublayers),(()=>this._constructLegendElementsForSublayers)),"sublayers-watcher");try{this.legendElements=await this._generateLegendElementsForSublayers(e.sublayers,this.opacity),this.notifyChange("ready")}catch(t){o.getLogger(this).warn("Request to server for legend has failed!",t)}}}async _generateLegendElementsForSublayers(e,t,s){const i=this.layer;let l=[];this.addHandles(e.on("change",(()=>this._constructLegendElementsForSublayers())),"sublayers-watcher");let n=e.toArray();!s&&this.sublayerIds&&this.sublayerIds.length&&(n=Pe(i)?this.sublayerIds.map((e=>i.findSublayerForSubtypeCode(e))).filter(r):this.sublayerIds.map((e=>i.findSublayerById(e))).filter(r));for(const r of n){const e=d((()=>[r.renderer,r.opacity,r.title,r.visible,r.legendEnabled]),(()=>this._constructLegendElementsForSublayers()));if(this.addHandles(e,"sublayers-watcher"),!this.respectLayerVisibility||r.visible&&r.legendEnabled&&this._isSublayerInScale(r)){const e=null!=r?.opacity?r.opacity:null,i=null!=e?e*t:t,n=!Je(r)||r.originIdOf("renderer")>S.SERVICE&&!r.sublayers;if(r.renderer&&n){await r.load();l=[...await this._getRendererLegendElements(r.renderer,{title:r.title,opacity:i,sublayer:r}),...l]}else if(Je(r)){const e=await this._generateSymbolTableElementForSublayer(r,i,s);e&&l.unshift(e)}}}return l.filter((e=>!!e&&(!("infos"in e)||!e.infos||e.infos.length>0)))}async _generateSymbolTableElementForSublayer(e,t,s){if(!s){s=new Map;const t=this.layer,i=e.source;let l=null;if(!(!i||"map-layer"===i.type&&i.mapLayerId===e.id&&(!i.gdbVersion||i.gdbVersion===("gdbVersion"in t&&t.gdbVersion)))||e.originIdOf("renderer")>S.SERVICE||e.originIdOf("labelingInfo")>S.SERVICE||e.originIdOf("labelsVisible")>S.SERVICE){const e=new L({layer:this.layer});l=e.hasDynamicLayers?e.dynamicLayers:null,e.destroy()}const r=l||`${t.uid}-default`;(await this._getLegendLayers(r,l)).forEach((e=>s.set(e.layerId,e)))}const i=s.get(e.id);if((!i||i?.subLayerIds&&i.defaultVisibility)&&e.sublayers){const i=await this._generateLegendElementsForSublayers(e.sublayers,t,s);return{type:"symbol-table",title:e.title,infos:i}}return this._generateSymbolTableElementForLegendLayer(i,e,t)}_generateSymbolTableElementForLegendLayer(e,t,s){if(!e?.legend||this.respectLayerVisibility&&!this._isLegendLayerInScale(e,t))return null;const i=t?.renderer;let l=t?.title||e.layerName;if(i&&(!t||t?.originIdOf("renderer")>S.SERVICE)){const e=t?.title||this._getRendererTitle(i,t);e&&(l&&"string"!=typeof e&&"title"in e&&(e.title=l),l=e)}const r={type:"symbol-table",title:l,legendType:e.legendType||null,infos:[]},n=t?this._sanitizeLegendForSublayer(e.legend.slice(),t):e.legend;return e.legendGroups&&e.legendGroups.length>0?e.legendGroups.forEach((t=>{const i={type:"symbol-table",title:t.heading,legendType:e.legendType||null,infos:this._generateSymbolTableElementInfosForLegendLayer(n.filter((e=>e.groupId===t.id)),e.layerId,s)};i.infos?.length>0&&r.infos.push(i)})):r.infos=this._generateSymbolTableElementInfosForLegendLayer(n,e.layerId,s),r.infos.length>0?r:null}_generateSymbolTableElementInfosForLegendLayer(e,t,i){return e.map((e=>{let l=e.url;if(e.imageData&&e.imageData.length>0)l=`data:image/png;base64,${e.imageData}`;else{if(0===l.indexOf("http"))return null;l=s(`${this.layer.url}/${t}/images/${l}`)}return{label:e.label,src:l,opacity:i??this.opacity,width:e.width,height:e.height}})).filter(r)}_isSublayerInScale(e){const t=e.minScale||0,s=e.maxScale||0;return!(t>0&&t<this.scale||s>this.scale)}_isLegendLayerInScale(e,t){const s=t||this.layer;let i=null,l=null,r=!0;return!s.minScale&&0!==s.minScale||!s.maxScale&&0!==s.maxScale?(0===e.minScale&&s.tileInfo&&(i=s.tileInfo.lods[0].scale),0===e.maxScale&&s.tileInfo&&(l=s.tileInfo.lods[s.tileInfo.lods.length-1].scale)):(i=Math.min(s.minScale,e.minScale)||s.minScale||e.minScale,l=Math.max(s.maxScale,e.maxScale)),(i>0&&i<this.scale||l>this.scale)&&(r=!1),r}_sanitizeLegendForSublayer(e,t){if("version"in this.layer&&+this.layer.version<10.1||0===e.length)return e;const s=t.renderer,i=e.some((e=>e.values));let l=0,r=null;return i&&e.some(((e,t)=>(e.values||(l=t,r=e,r.label||(r.label="others")),null!=r))),s?"unique-value"===s.type?r&&(e.splice(l,1),e.push(r)):"class-breaks"===s.type&&(r&&e.splice(l,1),s.legendOptions?.order||e.reverse(),r&&e.push(r)):r&&(e.splice(l,1),e.push(r)),e}async _getRendererLegendElements(e,t={}){if(!je(e,this.view))return o.getLogger(this).warn(`Renderer of type '${e.type}' not supported!`),[];if(Fe(e))return this._constructPointCloudRendererLegendElements(e,t);if(ze(e))return this._constructDotDensityRendererLegendElements(e);const s=await this._loadRenderer(e);return Te(s)?this._constructPieChartRendererLegendElements(s):this._constructRendererLegendElements(s,t)}async _getLegendElementsForFeatureReduction(e){let t=null;return"binning"===e.type?t=e.renderer:"cluster"===e.type&&(t=this._getClusterRenderer(e)),t?this._getRendererLegendElements(t):[]}_getPointCloudRendererTitle(e){return(e.legendOptions?.title||e.field)??""}async _constructPointCloudRendererLegendElements(e,t={}){const s=t.title,i=[];let l=null,r=null;if(Ve(e))l={type:"symbol-table",title:s||this._getPointCloudRendererTitle(e),infos:[]},e.colorClassBreakInfos.forEach((e=>{l.infos.unshift({label:e.label||e.minValue+" - "+e.maxValue,value:[e.minValue,e.maxValue],symbol:this._getAppliedCloneSymbol(fe,e.color)})}));else if(De(e)){const t=e.stops;let i=null;if(t?.length&&(1===t.length&&(i=t[0].color),!i)){const e=t[0].value,s=t[t.length-1].value;if(null!=e&&null!=s){i=q(e+(s-e)/2,t)}}l={type:"symbol-table",title:null,infos:[{label:null,value:null,symbol:this._getAppliedCloneSymbol(fe,i||fe.color)}]};const n=H(e.stops??[])??[];r={type:"color-ramp",title:s||this._getPointCloudRendererTitle(e),infos:n,preview:A(n.map((e=>e.color)),{ariaLabel:await Qe("previewColorRampAriaLabel")})}}else xe(e)&&(l={type:"symbol-table",title:s||this._getPointCloudRendererTitle(e),infos:[]},e.colorUniqueValueInfos?.forEach((e=>{l.infos.push({label:e.label||e.values.join(", "),value:e.values.join(", "),symbol:this._getAppliedCloneSymbol(fe,e.color)})})));l?.infos.length&&i.push(l),r?.infos.length&&i.push(r);const n=i.reduce(((e,t)=>[...e,...t.infos??[]]),[]).filter((e=>!!e.symbol)).map((t=>this._getSymbolPreview(t,this.opacity,{symbolConfig:{applyColorModulation:!!e.colorModulation}})));return await Promise.allSettled(n),i}async _getElementInfoForDotDensity(e,t){const{color:s,label:i,valueExpressionTitle:l}=t,{backgroundColor:r,outline:n,dotSize:a}=e,o=this.effectList,u=o?.effects.map((e=>e.toJSON())),c=w(u),d=await Qe("previewTemplateAriaLabel",i||l),y=a+"-"+s+"-"+r+"-"+(n&&JSON.stringify(n.toJSON()))+"-"+c,h=this._dotDensityUrlCache,m=h.has(y)?h.get(y):M(e,s,{ariaLabel:d});h.set(y,m);const p={shape:{type:"image",x:0,y:0,width:m.width,height:m.height,src:m.src},fill:null,stroke:null,offset:[0,0]},f=P([[p]],[m.width,m.height],{effectView:this.effectList,ariaLabel:d});return{opacity:1,src:m.src,preview:f,width:m.width,height:m.height}}async _constructDotDensityRendererLegendElements(e){const t=e.calculateDotValue(this.view.scale),s=e.legendOptions?.unit,i={type:"symbol-table",title:{value:t&&Math.round(t),unit:s||""},infos:[]};for(const l of e.attributes){const t=await this._getElementInfoForDotDensity(e,l);t.label=l.label||l.valueExpressionTitle||l.field,i.infos.push(t)}return[i]}async _constructPieChartRendererLegendElements(e){const t=this.layer.opacity,s=[];let i=null;const l=e.outline;e.attributes.forEach((e=>{const t=new T({color:e.color,outline:l}),i=e.label||e.valueExpressionTitle||e.field;s.push({label:i,symbol:t})}));const r=s.length?[...s]:[];if(e.othersCategory?.color&&0!==e.othersCategory?.threshold){const t=new T({color:e.othersCategory.color,outline:l});i=e.othersCategory.label||"Other",s.push({label:i,symbol:t})}if(e.defaultColor?.a){const t=new T({color:e.defaultColor,outline:l});s.push({label:e.defaultLabel,symbol:t})}const n=await this._getVisualVariableLegendElements(e,this.layer)||[];if(s.length){n.unshift({type:"symbol-table",title:null,infos:s});const t=r.filter((e=>e.label!==i)).map((e=>e.symbol.color)).filter(Boolean),a=U(t,{holePercentage:e.holePercentage,backgroundColor:e.backgroundFillSymbol?.color,effectList:this.effectList,outline:l,ariaLabel:await Qe("previewPieChartAriaLabel")});n.unshift({type:"pie-chart-ramp",title:this._getRendererTitle(e,this.layer),infos:s,preview:a})}const a=n.reduce(((e,t)=>[...e,...this._getAllInfos(t)]),[]).filter((e=>!!e?.symbol&&!e?.preview)).map((e=>this._getSymbolPreview(e,t,{effectList:this.effectList})));return await Promise.allSettled(a),n}async _getWhereClause(e,t,s){const i=await p(e,s),l=await E(t,s),r=new Set(l.map((e=>e.toLowerCase()))),n=i?.fieldNames.map((e=>e.toLowerCase()));return n?.some((e=>!r.has(e)))?null:i}async _processDefinitionExpression(e,t){if(!("definitionExpression"in e))return;const s=e.definitionExpression;s&&this.respectLayerDefinitionExpression?this._layerDefinitionExpression!==s&&(this._layerDefinitionExpressionClause=await this._getWhereClause(s,t,e.fieldsIndex)):this._layerDefinitionExpressionClause=null,this._layerDefinitionExpression=s}async _processDisplayFilter(e,t){if(!("displayFilterInfo"in e))return;const s=e.displayFilterInfo?v(e.displayFilterInfo,this.view):null;return s?.where?this._layerDisplayFilterId!==s?.id&&(this._layerDisplayFilterClause=await this._getWhereClause(s.where,t,e.fieldsIndex)):this._layerDisplayFilterClause=null,this._layerDisplayFilterId=s?.id,s}async _constructRendererLegendElements(e,t={}){const{title:s,sublayer:i}=t,l=i||this.layer,r=te(e);let n=null;Ce(e)&&(await this._processDefinitionExpression(l,e),n=await this._processDisplayFilter(l,e)),this._hasColorRamp=!1,this._hasOpacityRamp=!1,this._hasSizeRamp=!1,this._scaleDrivenSizeVariable=null;const a=await this._getVisualVariableLegendElements(e,l)||[],o={type:"symbol-table",title:s||this._getRendererTitle(e,l),infos:[]};let u=null,c=!1;const d=new Set;if(be(e)&&!this._hasSizeRamp){const t=await se(e);o.infos.push({label:null,symbol:t})}else if(We(e)){let t=s;const i=Ge(e)?"univariate-above-and-below-ramp":"univariate-color-size-ramp",l=a.findIndex((e=>"color-ramp"===e.type)),r=-1!==l?a.splice(l,1)[0]:null,n=a.findIndex((e=>"size-ramp"===e.type)),o=-1!==n?a.splice(n,1)[0]:null,u=[];r&&(t=r.title,u.push(r)),o&&(t=o.title,u.push(o)),u.length>0&&a.push({type:i,title:t,infos:u})}else if(Ie(e)){const t=G(e);a.push({type:"heatmap-ramp",title:s||this._getRendererTitle(e,l),infos:t,preview:A(t.map((e=>e.color)),{effectList:this.effectList,ariaLabel:await Qe("previewColorRampAriaLabel")})})}else if(Ce(e)){const t=e.authoringInfo;if(t&&"relationship"===t.type){const{numClasses:s,field1:i,field2:r}=t,n=t.focus;if(s&&i&&r){const t=[i,r];let u=J(n)||0;for(const e of t){const{field:t,normalizationField:s,label:i}=e,r=i||{field:this._getFieldAlias(t,l),normField:s&&this._getFieldAlias(s,l)},n=Ke.clone();n.angle=u,o.infos.push({label:r,symbol:n}),d.add(n),u+=90}const c=Q({focus:n,numClasses:s,infos:e.uniqueValueInfos??[]});a.unshift(c)}}else if(Ne(this.layer)||qe(this.layer))e.uniqueValueInfos?.forEach((t=>{t.symbol&&this._checkClausesForUVR(e,t.value)&&o.infos.push({label:t.label||t.value,value:t.value,symbol:t.symbol})}));else{const{field:t,field2:i,field3:a,fieldDelimiter:u,valueExpression:d,defaultSymbol:y}=e,h=!(!t&&!d||!i&&!a),m=this._layerDisplayFilterClause?n?.title:null,p=[];if(e.uniqueValueGroups?.forEach((s=>{const n={type:"symbol-table",title:m||s.heading,infos:[]};s.classes?.forEach((s=>{const{symbol:o,values:c}=s;if(o){const y=[],m=[];for(const e of c??[]){const{value:s,value2:r,value3:n}=e,o=[],c=[];(t||d)&&(o.push(s),c.push(this._getDomainName(t,s,l))),i&&(o.push(r),c.push(this._getDomainName(i,r,l))),a&&(o.push(n),c.push(this._getDomainName(a,n,l))),y.push(h?o.join(u||""):o[0]),m.push(c.join(" - "))}const p=y.join(", ");let f=s.label;if(!f){const e=m.filter(Boolean);f=e.length?e.join(", "):p}const g=o.clone();"cim"===g.type&&r&&x(g,{innerDotSize:.5*ue,outerRingSize:ue}),y.some((t=>this._checkClausesForUVR(e,t)))&&n.infos.push({label:f,value:p,symbol:g})}})),n.infos.length&&p.push(n)})),p.length){const t=p[0];1===p.length&&"title"in t&&!t.title?o.infos.push(...t.infos??[]):(y&&(p.push({type:"symbol-table",infos:[{label:e.defaultLabel||"others",symbol:y}]}),c=!0),o.infos.push(...p)),s||e.legendOptions?.title||e.valueExpressionTitle||(o.title=null)}}e.defaultSymbol&&!c&&(o.infos.push({label:e.defaultLabel||"others",symbol:e.defaultSymbol}),c=!0)}else if(Ee(e)){if(!r){u=this._isUnclassedRenderer(e);if(!u||!this._hasSizeRamp){const t=e.classBreakInfos.filter((({symbol:e})=>e)),s="ascending-values"===e.legendOptions?.order;for(const{label:e,minValue:i,maxValue:l,symbol:r}of t){const t={label:e||(u?null:`${i} - ${l}`),value:[i,l],symbol:r};s?o.infos.push(t):o.infos.unshift(t)}u&&(o.title=null),this._updateInfosForClassedSizeRenderer(e,o.infos)}e.defaultSymbol&&!u&&(o.infos.push({label:e.defaultLabel||"others",symbol:e.defaultSymbol}),c=!0)}}else if(we(e))if(qe(this.layer)||He(this.layer)){const t=await this._constructTileImageryStretchRendererElements(e);$e(t)?a.push(t):o.infos=t}else{const t=this.layer;let s,i;e.customStatistics?.length&&({min:s,max:i}=e.customStatistics[0]);let l=[],r=t.serviceRasterInfo;if(t.rasterFunction)try{r=await t.generateRasterInfo(t.rasterFunction)}catch{}const n=I(r.pixelType);if(1===r.bandCount){const l=t.bandIds?.[0]||0;s=null!=s?s:r.statistics?r.statistics[l].min:n[0],i=null!=i?i:r.statistics?r.statistics[l].max:n[1],s||i?a.push(await this._getStretchLegendElements(e,{min:s,max:i})):this._getServerSideLegend()}else if(t.bandIds&&1===t.bandIds.length)s=null!=s?s:r.statistics?r.statistics[t.bandIds[0]].min:n[0],i=null!=i?i:r.statistics?r.statistics[t.bandIds[0]].max:n[1],s||i?a.push(await this._getStretchLegendElements(e,{min:s,max:i})):this._getServerSideLegend();else if(r.bandCount>=3){const{bandInfos:e}=r,{bandIds:s}=t;e.length>=r.bandCount?3===s?.length?(l=s.map((t=>e[t].name)),o.infos=this._createSymbolTableElementMultiBand(l)):"lerc"===t.format?(l=[0,1,2].map((t=>e[t].name)),o.infos=this._createSymbolTableElementMultiBand(l)):this._getServerSideLegend():"lerc"===t.format?(l=["band1","band2","band3"],o.infos=this._createSymbolTableElementMultiBand(l)):this._getServerSideLegend()}else this._getServerSideLegend()}else if(_e(e))e.colormapInfos.forEach((e=>{o.infos.push({label:e.label,value:e.value,symbol:this._getAppliedCloneSymbol(ge,e.color)})}));else if(Le(e)){let s=e.symbol;switch(t.geometryType){case"point":s="pointSymbol"in l?l.pointSymbol:null;break;case"polyline":s="lineSymbol"in l?l.lineSymbol:null;break;case"polygon":s="polygonSymbol"in l?l.polygonSymbol:null}const i=this._hasClusterSizeVariable&&this._getClusterSymbol()||!this._hasSizeRamp;e.symbol&&i&&o.infos.push({label:e.label,symbol:s})}else if(Se(e)){e.outputUnit&&(this.title="("+e.toJSON().outputUnit+")"),o.title=e.attributeField;const t=e.getClassBreakInfos();t?.length?t.forEach((e=>{o.infos.push({label:e.minValue+" - "+e.maxValue,symbol:e.symbol})})):o.infos.push({label:e.attributeField,symbol:e.getDefaultSymbol()})}else ve(e)&&a.push(await this._getStretchLegendElements(e,{min:0,max:255}));const y=e.defaultSymbol;!y||c||Le(e)||u&&!this._hasColorRamp&&!this._hasSizeRamp&&!this._hasOpacityRamp||a.push({type:"symbol-table",infos:[{label:e.defaultLabel||"others",symbol:y}]}),o.infos.length&&a.unshift(o);const h=null==t.opacity?this.opacity:t.opacity,m=this._isTallSymbol("visualVariables"in e?e.visualVariables:null),p=Ne(this.layer)||qe(this.layer),f=a.reduce(((e,t)=>[...e,...this._getAllInfos(t)]),[]).filter((e=>!!e?.symbol)).filter((e=>{if("cim"===e.symbol.type){const{minScale:t,maxScale:s}=e.symbol.data;if(t&&t<this.scale||s&&s>this.scale)return!1}return!0})).map((e=>this._getSymbolPreview(e,h,{isDefault:e.symbol===y,applyScaleDrivenSize:!d.has(e.symbol),symbolConfig:{isTall:m,isSquareFill:p},effectList:d.has(e.symbol)?null:this.effectList})));return e=null,await Promise.allSettled(f),a}_checkClausesForUVR(e,t){const s=Ze(e,t);return!s||(!this._layerDefinitionExpressionClause||this._layerDefinitionExpressionClause.testFeature(s))&&(!this._layerDisplayFilterClause||this._layerDisplayFilterClause.testFeature(s))}_getServerSideLegend(){setTimeout((()=>this.buildLegendElementsForTools()),0)}_getAllInfos(e){const t=e?.infos;return t?t.reduce(((e,t)=>e.concat(this._getAllInfos(t))),[]):[e]}async _constructTileImageryStretchRendererElements(e){const t=this.layer,s=t.symbolizer.rasterInfo??t.raster.rasterInfo;let i,l;const r=e?.customStatistics?.length?e.customStatistics:s?.statistics;if(r)({min:i,max:l}=r[0]);else{const e=I(s.pixelType);i=e[0],l=e[1]}if(t.hasStandardTime()&&(i=t.getStandardTimeValue(i),l=t.getStandardTimeValue(l)),1===s.bandCount||1===t.bandIds?.length)return this._getStretchLegendElements(e,{min:i,max:l});const n=(t?.bandIds?.length?t.bandIds:Array.from(Array(Math.min(s.bandCount,3)).keys())).map((e=>s.bandInfos[e].name));return n.length<3?n.push(n[1]):n.length>3&&n.splice(3),this._createSymbolTableElementMultiBand(n)}async _getStretchLegendElements(e,t){const s=e.colorRamp,i=$(s,t);return{type:"stretch-ramp",title:"",infos:i,preview:A(i.map((e=>e.color)),{ariaLabel:await Qe("previewColorRampAriaLabel")})}}_getClusterSymbol(){const e=this.layer,t="featureReduction"in e&&e.featureReduction,s=t&&"symbol"in t&&t.renderer;return s&&!0!==s?.authoringInfo?.isAutoGenerated?null:t&&"symbol"in t?t.symbol:null}async _getSizeLegendElement(e,t,s,i){return{type:"size-ramp",title:this._hasClusterSizeVariable?this._getClusterTitle(t):e,infos:await Z(s,t,await ie(s),this.scale,this.view,i,this._hasClusterSizeVariable?this._getClusterSymbol():null)}}_createSymbolTableElementMultiBand(e){const t=[],s=["red","green","blue"];return e.forEach(((e,i)=>{t.push({label:{colorName:s[i],bandName:e},src:le[i],opacity:this.opacity??1})})),t}_updateInfosForClassedSizeRenderer(e,t){const s=e.authoringInfo&&"class-breaks-size"===e.authoringInfo.type,i=e.classBreakInfos.some((e=>B(e.symbol)));if(s&&i){const s=K,i=X,l=e.classBreakInfos.length,r=(s-i)/(l>1?l-1:l);t.forEach(((e,t)=>{e.size=s-r*t}))}}_isTallSymbol(e){let t=!1,s=!1;if(e)for(let i=0;i<e.length&&(!t||!s);i++){const l=e[i];"size"===l.type&&("height"===l.axis&&(t=!0),"width-and-depth"===l.axis&&(s=!0))}return t&&s}async _getSymbolPreview(e,t,s){let i=!s?.isDefault&&null==e.size&&this._hasSizeRamp?m(O.size):e.size;if(this._scaleDrivenSizeVariable&&s?.applyScaleDrivenSize){const{getSize:t}=await import("../../../renderers/visualVariables/support/visualVariableUtils.js");i=t(this._scaleDrivenSizeVariable,null,{view:this.view.type,scale:this.scale,shape:"simple-marker"===e.symbol.type?e.symbol.style:null})}const l=!s?.isDefault&&this._hasSizeRamp||!(!this._scaleDrivenSizeVariable||!s?.applyScaleDrivenSize);return k(e.symbol,{size:i,opacity:t,scale:!1,symbolConfig:s?.symbolConfig,effectView:s?.effectList,style:"legend",cimOptions:{allowScalingUp:l,viewParams:this.isScaleDriven?{viewingMode:"2d"===this.view?.type?"map":this.view?.viewingMode,scale:this.view?.scale}:null},ariaLabel:e.label&&"string"!=typeof e.label?null:await Qe("previewTemplateAriaLabel",e.label)}).then((t=>(e.preview=t,e))).catch((()=>(e.preview=null,e)))}_getClusterRenderer(e){this._hasClusterSizeVariable=!1;const t="renderer"in this.layer?this.layer.renderer:null,s=e.renderer?.clone()||t?.clone(),i=N(e,this.layerView,this.view);if(i&&null!=s&&"visualVariables"in s){const t=s.visualVariables?.some((e=>"size"===e.type&&"outline"!==e.target&&!me.test(e.valueExpression)));if(!t){if("clusterMinSize"in e&&"clusterMaxSize"in e){const{clusterMinSize:t,clusterMaxSize:s}=e;i.legendOptions=new D({showLegend:t!==s})}const t=s.visualVariables||[];s.visualVariables=t.concat([i]),this._hasClusterSizeVariable=!0}}return s}async _loadRenderer(e){const t=[],s=e.clone(),i=await ie(s);if(Ee(s)||Ce(s)){const e=(s.classBreakInfos||s.uniqueValueInfos).map((e=>this._fetchSymbol(e.symbol,i).then((t=>{e.symbol=t})).catch((()=>{e.symbol=null}))));Array.prototype.push.apply(t,e)}return t.push(this._fetchSymbol(s.symbol||s.defaultSymbol,s.defaultSymbol?null:i).then((e=>{this._applySymbolToRenderer(s,e,Le(s))})).catch((()=>{this._applySymbolToRenderer(s,null,Le(s))}))),await Promise.allSettled(t),s}_applySymbolToRenderer(e,t,s){s?e.symbol=t:e.defaultSymbol=t}async _fetchSymbol(e,t){if(!e)throw new Error;if("web-style"===e.type){const s=this._webStyleSymbolCache;try{const i=await("2d"===this.view.type?e.fetchCIMSymbol({cache:s}):e.fetchSymbol({cache:s}));return this._getAppliedCloneSymbol(i,t)}catch{throw o.getLogger(this).warn("Fetching web-style failed!"),new Error}}return this._getAppliedCloneSymbol(e,t)}_getAppliedCloneSymbol(e,s){if(!e||!s)return e;const i=e.clone(),l=s&&s.toRgba();return i.type.includes("3d")?this._applyColorTo3dSymbol(i,l):"cim"===i.type?j(i,s):i.color&&(i.color=new t(l||i.color)),i}_applyColorTo3dSymbol(e,s){s&&e.symbolLayers.forEach((e=>{e&&(e.material||(e.material={}),e.material.color=new t(s))}))}async _getVisualVariableLegendElements(e,t){if(!("visualVariables"in e)||"vector-field"===e.type)return null;const s=e.visualVariables??[],i=[],l=[],n=[],a=te(e);if(2===a?.sizeStops?.length&&(Ee(e)||Ce(e))){const[e,t]=a.sizeStops;l.push(new V({field:a.field??void 0,normalizationField:a.normalizationField,minSize:e.size,maxSize:t.size,minDataValue:e.value,maxDataValue:t.value}))}for(const r of s)"color"===r.type?i.push(r):"size"===r.type?l.push(r):"opacity"===r.type&&n.push(r);const o=[...i,...l,...n];let u,c;if(0===i.length&&Ee(e)&&e.classBreakInfos&&1===e.classBreakInfos.length){const t=e.classBreakInfos[0];u=t&&t.symbol}if(0===i.length&&Le(e)&&(u=e.symbol),u)if(u.type.includes("3d")){const e=u.symbolLayers.at(0);"water"===e.type?null!=e.color&&(c=e.color):null!=e.material?.color&&(c=e.material.color)}else u.url||(c=u.color);const d=this.effectList;return(await Promise.all(o.map((async s=>{if(!s.legendOptions||!1!==s.legendOptions.showLegend){const i=be(e)?s.field:this._getRampTitle(s,t);let l=null;const r=re(t,s,this.view.timeZone);if("color"===s.type){const e=await W(s,null,r)??[];l={type:"color-ramp",title:i,infos:e,preview:A(e.map((e=>e.color)),{effectList:d,ariaLabel:await Qe("previewColorRampAriaLabel")})},this._hasColorRamp||(this._hasColorRamp=e.length>0)}else if("size"===s.type&&"outline"!==s.target)me.test(s.valueExpression)?this._hasClusterSizeVariable||(this._scaleDrivenSizeVariable=s):(l=await this._getSizeLegendElement(i,s,e,r),this._hasSizeRamp||(this._hasSizeRamp=!(null==l.infos||!l.infos.length)));else if("opacity"===s.type){const e=await W(s,c,r)??[];l={type:"opacity-ramp",title:i,infos:e,preview:A(e.map((e=>e.color)),{effectList:d,ariaLabel:await Qe("previewColorRampAriaLabel")})},this._hasOpacityRamp||(this._hasOpacityRamp=e.length>0)}return l?.infos?l:null}})))).filter(r)}_getDomainName(e,t,s){if(e&&"function"!=typeof e){const i="getField"in s&&s.getField?.(e),l=i&&"getFieldDomain"in s&&s.getFieldDomain?s.getFieldDomain(i.name,{excludeImpliedDomains:has("esri-widget-legacy-field-domain-calculation")}):null;return"coded-value"===l?.type?l.getName(t):null}return null}_getClusterTitle(e){const t=this.layer,s=e.field;if("featureReduction"in t&&t.featureReduction&&"cluster"===t.featureReduction.type){const e=t.featureReduction,i="popupTemplate"in e&&e.popupTemplate,l=i&&i.fieldInfos;if(l)for(const t of l)if(t.fieldName===s)return"cluster_count"===s?t.label||{showCount:!0}:t.label}return{showCount:!0}}_getRampTitle(e,t){let s=e.field,i=e.normalizationField,l=!1,r=!1,n=!1,a=null;s="function"==typeof s?null:s,i="function"==typeof i?null:i;const o=e.legendOptions?.title;if(null!=o)a=o;else if(e.valueExpressionTitle)a=e.valueExpressionTitle;else{if("renderer"in t&&t.renderer&&"authoringInfo"in t.renderer&&t.renderer.authoringInfo?.visualVariables){const e=t.renderer.authoringInfo.visualVariables;for(let t=0;t<e.length;t++){const s=e[t];if("color"===s.type){if("ratio"===s.style){l=!0;break}if("percent"===s.style){r=!0;break}if("percent-of-total"===s.style){n=!0;break}}}}a={field:s&&this._getFieldAlias(s,t),normField:i&&this._getFieldAlias(i,t),ratio:l,ratioPercent:r,ratioPercentTotal:n}}return a}_getRendererTitle(e,t){const s=e;if(s.legendOptions?.title)return s.legendOptions.title;if(s.valueExpressionTitle)return s.valueExpressionTitle;let i=s.field,l=null,r=null;if(Ee(s)&&(l=s.normalizationField,r="percent-of-total"===s.normalizationType),i="function"==typeof i?null:i,l="function"==typeof l?null:l,Ce(s)){const{field2:e,field3:l,fieldDelimiter:r}=s;let n=i&&this._getFieldAlias(i,t);return e&&(n=`<${n}>${r}<${this._getFieldAlias(e,t)}>`,l&&(n=`${n}${r}<${this._getFieldAlias(l,t)}>`)),n}let n=null;return(i||l)&&(n={field:i&&this._getFieldAlias(i,t),normField:l&&this._getFieldAlias(l,t),normByPct:r}),n}_getFieldAlias(e,t){const s="popupTemplate"in t?t.popupTemplate:null,i=s?.fieldInfos;let l=i?.find((t=>e===t.fieldName)),r=null;"getField"in t&&t.getField?r=t.getField(e):"fieldsIndex"in t&&t.fieldsIndex&&(r=t.fieldsIndex.get(e));let n=null;const a="featureReduction"in t&&t.featureReduction;a&&(l??="popupTemplate"in a?a.popupTemplate?.fieldInfos?.find((t=>e?.toLowerCase()===t.fieldName?.toLowerCase())):void 0,"fields"in a&&a.fields&&(n=a.fields.find((t=>t.name?.toLowerCase()===e?.toLowerCase()))));const o=l||r||n;let u=null;return o&&(u=l?.label||r?.alias||n?.alias||"name"in o&&o.name||"fieldName"in o&&o.fieldName||null),u}_isUnclassedRenderer(e){const t=e.visualVariables;let s=!1;return Ee(e)&&e.classBreakInfos&&1===e.classBreakInfos.length&&t&&(s=e.field?t.some((t=>!(!t||e.field!==t.field||(e.normalizationField||t.normalizationField)&&e.normalizationField!==t.normalizationField))):!!t.length),s}};e([g()],Ye.prototype,"children",void 0),e([g({readOnly:!0})],Ye.prototype,"effectList",null),e([g()],Ye.prototype,"layerView",void 0),e([g()],Ye.prototype,"layer",void 0),e([g()],Ye.prototype,"legendElements",void 0),e([g({readOnly:!0})],Ye.prototype,"opacity",null),e([g()],Ye.prototype,"parent",void 0),e([g({readOnly:!0,dependsOn:[]})],Ye.prototype,"ready",null),e([g()],Ye.prototype,"hideLayersNotInCurrentView",void 0),e([g()],Ye.prototype,"keepCacheOnDestroy",void 0),e([g()],Ye.prototype,"respectLayerDefinitionExpression",void 0),e([g()],Ye.prototype,"respectLayerVisibility",void 0),e([g({readOnly:!0})],Ye.prototype,"scale",null),e([g()],Ye.prototype,"sublayerIds",void 0),e([g({readOnly:!0})],Ye.prototype,"isScaleDriven",null),e([g()],Ye.prototype,"title",void 0),e([g({readOnly:!0,dependsOn:["ready"],value:0})],Ye.prototype,"version",null),e([g()],Ye.prototype,"view",void 0),Ye=e([b("esri.widgets.Legend.support.ActiveLayerInfo")],Ye);const et=Ye;export{et as default};