@arcgis/core 4.33.0-next.20250202 → 4.33.0-next.20250204
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/WebScene.js +1 -1
- package/assets/esri/core/workers/RemoteClient.js +1 -1
- package/assets/esri/core/workers/chunks/{d3a8aabdbfb59dd433e3.js → 01c3507d78398baaf61b.js} +1 -1
- package/assets/esri/core/workers/chunks/{c74441fbe0f63633796f.js → 04306c2760c1f5b19966.js} +1 -1
- package/assets/esri/core/workers/chunks/1a2e1a414e651e988435.js +2 -0
- package/assets/esri/core/workers/chunks/{bf9bc52a3c559108c19a.js.LICENSE.txt → 1a2e1a414e651e988435.js.LICENSE.txt} +1 -1
- package/assets/esri/core/workers/chunks/308ec51ff4a66f7fcb0d.js.LICENSE.txt +1 -1
- package/assets/esri/core/workers/chunks/354531dc2f0dea2ad96f.js +2 -0
- package/assets/esri/core/workers/chunks/{6e8905f20101c1f4509d.js.LICENSE.txt → 354531dc2f0dea2ad96f.js.LICENSE.txt} +1 -1
- package/assets/esri/core/workers/chunks/{448ee44c7f594e5b2551.js → 3ce826ebf0692363309d.js} +1 -1
- package/assets/esri/core/workers/chunks/44abd2cd17aae3299ede.js +1 -0
- package/assets/esri/core/workers/chunks/{e9f0402fa3ac5a249807.js → 5196c43dbce48d1b81ae.js} +1 -1
- package/assets/esri/core/workers/chunks/568bcf809fcfd4d9c713.js +1 -0
- package/assets/esri/core/workers/chunks/{3ec51b75d1a86dad6cb1.js → 60cd8f4bba3e682ba57e.js} +1 -1
- package/assets/esri/core/workers/chunks/61243217aed5de012e93.js +1 -0
- package/assets/esri/core/workers/chunks/69d307758262e5d7a32e.js +1 -0
- package/assets/esri/core/workers/chunks/{e444ec05a8a1dfbd21a8.js → 6dee40b94f94ee7bc4e4.js} +1 -1
- package/assets/esri/core/workers/chunks/72cf9192292e5c85c6df.js.LICENSE.txt +1 -1
- package/assets/esri/core/workers/chunks/77764ca90bdd13ee2167.js +2 -0
- package/assets/esri/core/workers/chunks/{25c8cc30faade043c8dc.js.LICENSE.txt → 77764ca90bdd13ee2167.js.LICENSE.txt} +1 -1
- package/assets/esri/core/workers/chunks/{f8367c21fa91435c7c53.js → 7a3e4cb5f64dac2cfe0e.js} +1 -1
- package/assets/esri/core/workers/chunks/7b11bf5799ecb3640b48.js +314 -0
- package/assets/esri/core/workers/chunks/{ba3c18d1efde46461231.js → 8438fba57e82e4cc7c11.js} +1 -1
- package/assets/esri/core/workers/chunks/{0ef5b0f8aa8a09acd6e0.js → 8e90c5fee4ad7c7275dc.js} +1 -1
- package/assets/esri/core/workers/chunks/{f2fae056a81f12b56b04.js → 8edae4ca2b18a219a43e.js} +1 -1
- package/assets/esri/core/workers/chunks/918bdba41fa470cf77fd.js +1 -0
- package/assets/esri/core/workers/chunks/a2409d4921c02614169a.js +1 -0
- package/assets/esri/core/workers/chunks/{7810579a5a780933cdc9.js → ad3e692681b50bd1acc2.js} +1 -1
- package/assets/esri/core/workers/chunks/{adfa126cea32298c28e9.js → b1269b51cef3e11c85e3.js} +1 -1
- package/assets/esri/core/workers/chunks/{692b3d03346f030aa649.js → b1f5344e57ee679a7e81.js} +44 -44
- package/assets/esri/core/workers/chunks/b21b152fa15896577242.js.LICENSE.txt +1 -1
- package/assets/esri/core/workers/chunks/b8a519d5d24b2e728ff8.js +2 -0
- package/assets/esri/core/workers/chunks/{7d3a441d2eb18d709ef9.js.LICENSE.txt → b8a519d5d24b2e728ff8.js.LICENSE.txt} +1 -1
- package/assets/esri/core/workers/chunks/b9ce0049e27a3e1ed9f9.js +1 -0
- package/assets/esri/core/workers/chunks/{79afe4674a0557eb26e4.js → bf26f58210755875748c.js} +1 -1
- package/assets/esri/core/workers/chunks/c032bcd25e2e7a57ad43.js +1 -0
- package/assets/esri/core/workers/chunks/{6e25742ceedea7fb1b97.js → c3f03ccabca691186aad.js} +1 -1
- package/assets/esri/core/workers/chunks/{5adeb979f178944b9ce5.js → c4c2b94e5cee7b824093.js} +1 -1
- package/assets/esri/core/workers/chunks/{3e872e5e528dca7bee0c.js → cc75bbfd779f409943a3.js} +1 -1
- package/assets/esri/core/workers/chunks/{4c5279fedf982a174706.js → d175953337fa655dc6b0.js} +1 -1
- package/assets/esri/core/workers/chunks/d35efcbe439500bf18bc.js +1 -0
- package/assets/esri/core/workers/chunks/{bc50585615f07d5ec1a9.js → e4f82b5b50996b1ae48e.js} +1 -1
- package/assets/esri/core/workers/chunks/{2345344be4b0e487d3a6.js → f198f4ba7d3d52882d98.js} +1 -1
- package/assets/esri/core/workers/chunks/{881ddbdeb40336208e90.js → f29715459ecd46180829.js} +1 -1
- package/assets/esri/core/workers/chunks/{d1678945cf6a58f76863.js → f48ef415b90edc7ccadd.js} +1 -1
- package/assets/esri/themes/base/_core.scss +0 -2
- package/assets/esri/themes/base/widgets/_Directions.scss +129 -425
- package/assets/esri/themes/base/widgets/_Editor.scss +31 -0
- package/assets/esri/themes/dark/main.css +1 -1
- package/assets/esri/themes/light/main.css +1 -1
- package/assets/esri/themes/light/view.css +1 -1
- package/assets/esri/widgets/Directions/t9n/Directions_ar.json +1 -1
- package/assets/esri/widgets/Directions/t9n/Directions_bg.json +1 -1
- package/assets/esri/widgets/Directions/t9n/Directions_bs.json +1 -1
- package/assets/esri/widgets/Directions/t9n/Directions_ca.json +1 -1
- package/assets/esri/widgets/Directions/t9n/Directions_cs.json +1 -1
- package/assets/esri/widgets/Directions/t9n/Directions_da.json +1 -1
- package/assets/esri/widgets/Directions/t9n/Directions_de.json +1 -1
- package/assets/esri/widgets/Directions/t9n/Directions_el.json +1 -1
- package/assets/esri/widgets/Directions/t9n/Directions_es.json +1 -1
- package/assets/esri/widgets/Directions/t9n/Directions_et.json +1 -1
- package/assets/esri/widgets/Directions/t9n/Directions_fi.json +1 -1
- package/assets/esri/widgets/Directions/t9n/Directions_fr.json +1 -1
- package/assets/esri/widgets/Directions/t9n/Directions_he.json +1 -1
- package/assets/esri/widgets/Directions/t9n/Directions_hr.json +1 -1
- package/assets/esri/widgets/Directions/t9n/Directions_hu.json +1 -1
- package/assets/esri/widgets/Directions/t9n/Directions_id.json +1 -1
- package/assets/esri/widgets/Directions/t9n/Directions_it.json +1 -1
- package/assets/esri/widgets/Directions/t9n/Directions_ja.json +1 -1
- package/assets/esri/widgets/Directions/t9n/Directions_ko.json +1 -1
- package/assets/esri/widgets/Directions/t9n/Directions_lt.json +1 -1
- package/assets/esri/widgets/Directions/t9n/Directions_lv.json +1 -1
- package/assets/esri/widgets/Directions/t9n/Directions_nl.json +1 -1
- package/assets/esri/widgets/Directions/t9n/Directions_no.json +1 -1
- package/assets/esri/widgets/Directions/t9n/Directions_pl.json +1 -1
- package/assets/esri/widgets/Directions/t9n/Directions_pt-BR.json +1 -1
- package/assets/esri/widgets/Directions/t9n/Directions_pt-PT.json +1 -1
- package/assets/esri/widgets/Directions/t9n/Directions_ro.json +1 -1
- package/assets/esri/widgets/Directions/t9n/Directions_ru.json +1 -1
- package/assets/esri/widgets/Directions/t9n/Directions_sk.json +1 -1
- package/assets/esri/widgets/Directions/t9n/Directions_sl.json +1 -1
- package/assets/esri/widgets/Directions/t9n/Directions_sr.json +1 -1
- package/assets/esri/widgets/Directions/t9n/Directions_sv.json +1 -1
- package/assets/esri/widgets/Directions/t9n/Directions_th.json +1 -1
- package/assets/esri/widgets/Directions/t9n/Directions_tr.json +1 -1
- package/assets/esri/widgets/Directions/t9n/Directions_uk.json +1 -1
- package/assets/esri/widgets/Directions/t9n/Directions_vi.json +1 -1
- package/assets/esri/widgets/Directions/t9n/Directions_zh-CN.json +1 -1
- package/assets/esri/widgets/Directions/t9n/Directions_zh-HK.json +1 -1
- package/assets/esri/widgets/Directions/t9n/Directions_zh-TW.json +1 -1
- package/chunks/ComponentShader.glsl.js +30 -30
- package/chunks/DefaultMaterial.glsl.js +19 -19
- package/chunks/HUDMaterial.glsl.js +34 -34
- package/chunks/MeasurementArrow.glsl.js +6 -6
- package/chunks/NativeLine.glsl.js +4 -4
- package/chunks/QuadraticBezier.js +1 -1
- package/chunks/RealisticTree.glsl.js +14 -14
- package/chunks/RibbonLine.glsl.js +32 -32
- package/chunks/Terrain.glsl.js +31 -31
- package/chunks/WaterSurface.glsl.js +15 -15
- package/copyright.txt +0 -29
- package/core/Collection.js +1 -1
- package/core/has.js +1 -1
- package/geometry/support/centroid.js +1 -1
- package/interfaces.d.ts +139 -13
- package/layers/graphics/controllers/FeatureTileController3D.js +1 -1
- package/layers/mixins/ArcGISImageService.js +1 -1
- package/layers/mixins/ImageryTileMixin.js +1 -1
- package/layers/support/labelUtils.js +1 -1
- package/layers/support/rasterDatasets/WCSRaster.js +1 -1
- package/layers/support/rasterDatasets/multidimensionalUtils.js +1 -1
- package/package.json +4 -5
- package/popup/content/AttachmentsContent.js +1 -1
- package/popup/support/AttachmentsOrderByInfo.d.ts +4 -0
- package/popup/support/AttachmentsOrderByInfo.js +5 -0
- package/portal/schemas/definitions.js +1 -1
- package/rest/imageService/fetchRasterInfo.js +1 -1
- package/support/revision.js +1 -1
- package/support/timeUtils.d.ts +0 -1
- package/support/timeUtils.js +1 -1
- package/symbols/cim/CIMSymbolDrawHelper.js +1 -1
- package/symbols/cim/animationUtils.js +1 -1
- package/symbols/cim/defaultCIMValues.js +1 -1
- package/views/2d/engine/webgl/animations/utils.js +1 -1
- package/views/2d/engine/webgl/mesh/factories/FeatureMeshFactory.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/animated/AnimatedShader.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/line/GradientStrokeTechnique.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/line/gradientStrokeConstants.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/shaders/GradientStrokeShader.js +1 -1
- package/views/2d/engine/webgl/util/LabelMatcher.js +1 -1
- package/views/2d/engine/webgl/util/createMatcher.js +1 -1
- package/views/2d/layers/features/layerAdapters/SubtypeGroupLayerAdapter.js +1 -1
- package/views/3d/interactive/snapping/featureSources/featureServiceSource/FeatureServiceTiles3D.js +1 -1
- package/views/3d/layers/IntegratedMesh3DTilesLayerView3D.js +1 -1
- package/views/3d/layers/graphics/Graphics3DCore.js +1 -1
- package/views/3d/layers/graphics/Graphics3DGraphicsPipeline.js +1 -1
- package/views/3d/layers/i3s/I3SClientMaterialUtil.js +1 -1
- package/views/3d/layers/i3s/I3SMaterialUtil.js +1 -1
- package/views/3d/layers/support/FeatureTileFetcher3D.js +1 -1
- package/views/3d/layers/support/FeatureTileFetcher3DContext.js +1 -1
- package/views/3d/layers/support/FeatureTileTree3D.js +1 -1
- package/views/3d/layers/support/FeatureVisibilityFilter.js +1 -1
- package/views/3d/terrain/PatchRenderData.js +1 -1
- package/views/3d/webgl-engine/collections/Component/Material/ComponentMaterial.js +1 -1
- package/views/3d/webgl-engine/collections/Component/Material/shader/ComponentShader.glsl.js +1 -1
- package/views/3d/webgl-engine/core/shaderLibrary/util/DiscardOrAdjustAlpha.glsl.js +3 -3
- package/views/3d/webgl-engine/effects/debug/RenderNodeVisualizerNode.js +1 -1
- package/views/3d/webgl-engine/materials/CheckerBoardMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/ColorMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/DefaultMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/HUDMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/LineCalloutMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/LineMarkerMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/MeasurementArrowMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/NativeLineMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/PathMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/PatternMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/RibbonLineMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/ShadedColorMaterial.js +1 -1
- package/views/3d/webgl-engine/shaders/DefaultMaterial.glsl.js +1 -1
- package/views/3d/webgl-engine/shaders/DefaultMaterialTechnique.js +1 -1
- package/views/3d/webgl-engine/shaders/HUDMaterial.glsl.js +1 -1
- package/views/3d/webgl-engine/shaders/MeasurementArrow.glsl.js +1 -1
- package/views/3d/webgl-engine/shaders/NativeLine.glsl.js +1 -1
- package/views/3d/webgl-engine/shaders/OutputColorHighlightOID.glsl.js +8 -8
- package/views/3d/webgl-engine/shaders/RealisticTree.glsl.js +1 -1
- package/views/3d/webgl-engine/shaders/RibbonLine.glsl.js +1 -1
- package/views/3d/webgl-engine/shaders/Terrain.glsl.js +1 -1
- package/views/3d/webgl-engine/shaders/WaterSurface.glsl.js +1 -1
- package/views/layers/FeatureLayerView.js +1 -1
- package/views/layers/ImageryTileLayerView.d.ts +4 -0
- package/views/layers/ImageryTileLayerView.js +1 -1
- package/webscene/spec-certification/index.js +1 -1
- package/widgets/BasemapLayerList.js +1 -1
- package/widgets/Directions/DirectionsSearchTool.js +5 -0
- package/widgets/Directions/DirectionsViewModel.js +1 -1
- package/widgets/Directions/DirectionsVisibleElements.js +5 -0
- package/widgets/Directions.js +1 -1
- package/widgets/Editor/CreateFeaturesWorkflow.js +1 -1
- package/widgets/Editor/CreateFeaturesWorkflowData.js +1 -1
- package/widgets/Editor/EditorViewModel.js +1 -1
- package/widgets/Editor/Edits.js +1 -1
- package/widgets/Editor/UpdateWorkflow.js +1 -1
- package/widgets/Editor/VisibleElements.js +1 -1
- package/widgets/Editor/components/CreateFeaturesPanelContent.js +1 -1
- package/widgets/Editor/components/PanelToolbar.js +1 -1
- package/widgets/Editor/components/PendingFeatureList.js +5 -0
- package/widgets/Editor/components/UpdateFeaturePanelContent.js +1 -1
- package/widgets/Editor/css.js +1 -1
- package/widgets/Editor/workflowUtils.js +1 -1
- package/widgets/Editor.js +1 -1
- package/widgets/FeatureForm/FeatureFormViewModel.js +1 -1
- package/widgets/FeatureForm/FieldInput.js +1 -1
- package/widgets/FeatureForm.js +1 -1
- package/widgets/LayerList.js +1 -1
- package/widgets/Legend/LegendViewModel.js +1 -1
- package/widgets/Legend/support/ActiveLayerInfo.js +1 -1
- package/widgets/Legend.js +1 -1
- package/widgets/OrientedImageryViewer/OrientedImageryViewerViewModel.js +1 -1
- package/widgets/Search.js +1 -1
- package/widgets/Sketch/SketchViewModel.js +1 -1
- package/widgets/Sketch/VisibleElements.js +1 -1
- package/widgets/Sketch.js +1 -1
- package/widgets/support/ItemList.js +1 -1
- package/assets/esri/core/workers/chunks/06d72622590dbd38c5de.js +0 -1
- package/assets/esri/core/workers/chunks/0a19e1aec6a5502e391a.js +0 -1
- package/assets/esri/core/workers/chunks/12964a4b16113cdc9c93.js +0 -1
- package/assets/esri/core/workers/chunks/25c8cc30faade043c8dc.js +0 -2
- package/assets/esri/core/workers/chunks/326a3f50e585e492b673.js +0 -1
- package/assets/esri/core/workers/chunks/34d464dacee52739c98c.js +0 -1
- package/assets/esri/core/workers/chunks/4cab082b8432ddc05345.js +0 -1
- package/assets/esri/core/workers/chunks/6e8905f20101c1f4509d.js +0 -2
- package/assets/esri/core/workers/chunks/6f796f2836f949ab7359.js +0 -1
- package/assets/esri/core/workers/chunks/7d3a441d2eb18d709ef9.js +0 -2
- package/assets/esri/core/workers/chunks/bf9bc52a3c559108c19a.js +0 -2
- package/assets/esri/core/workers/chunks/dd46ec81cebe1a0a7b9c.js +0 -1
- package/assets/esri/core/workers/chunks/fb1a89f753057f889971.js +0 -314
- package/assets/esri/core/workers/chunks/ffa2b9d70830aed03a8f.js +0 -1
- package/assets/esri/themes/base/widgets/_SaveLayer.scss +0 -40
- package/assets/esri/widgets/support/t9n/SaveLayer.json +0 -1
- package/assets/esri/widgets/support/t9n/SaveLayer_ar.json +0 -1
- package/assets/esri/widgets/support/t9n/SaveLayer_bg.json +0 -1
- package/assets/esri/widgets/support/t9n/SaveLayer_bs.json +0 -1
- package/assets/esri/widgets/support/t9n/SaveLayer_ca.json +0 -1
- package/assets/esri/widgets/support/t9n/SaveLayer_cs.json +0 -1
- package/assets/esri/widgets/support/t9n/SaveLayer_da.json +0 -1
- package/assets/esri/widgets/support/t9n/SaveLayer_de.json +0 -1
- package/assets/esri/widgets/support/t9n/SaveLayer_el.json +0 -1
- package/assets/esri/widgets/support/t9n/SaveLayer_en.json +0 -1
- package/assets/esri/widgets/support/t9n/SaveLayer_es.json +0 -1
- package/assets/esri/widgets/support/t9n/SaveLayer_et.json +0 -1
- package/assets/esri/widgets/support/t9n/SaveLayer_fi.json +0 -1
- package/assets/esri/widgets/support/t9n/SaveLayer_fr.json +0 -1
- package/assets/esri/widgets/support/t9n/SaveLayer_he.json +0 -1
- package/assets/esri/widgets/support/t9n/SaveLayer_hr.json +0 -1
- package/assets/esri/widgets/support/t9n/SaveLayer_hu.json +0 -1
- package/assets/esri/widgets/support/t9n/SaveLayer_id.json +0 -1
- package/assets/esri/widgets/support/t9n/SaveLayer_it.json +0 -1
- package/assets/esri/widgets/support/t9n/SaveLayer_ja.json +0 -1
- package/assets/esri/widgets/support/t9n/SaveLayer_ko.json +0 -1
- package/assets/esri/widgets/support/t9n/SaveLayer_lt.json +0 -1
- package/assets/esri/widgets/support/t9n/SaveLayer_lv.json +0 -1
- package/assets/esri/widgets/support/t9n/SaveLayer_nl.json +0 -1
- package/assets/esri/widgets/support/t9n/SaveLayer_no.json +0 -1
- package/assets/esri/widgets/support/t9n/SaveLayer_pl.json +0 -1
- package/assets/esri/widgets/support/t9n/SaveLayer_pt-BR.json +0 -1
- package/assets/esri/widgets/support/t9n/SaveLayer_pt-PT.json +0 -1
- package/assets/esri/widgets/support/t9n/SaveLayer_ro.json +0 -1
- package/assets/esri/widgets/support/t9n/SaveLayer_ru.json +0 -1
- package/assets/esri/widgets/support/t9n/SaveLayer_sk.json +0 -1
- package/assets/esri/widgets/support/t9n/SaveLayer_sl.json +0 -1
- package/assets/esri/widgets/support/t9n/SaveLayer_sr.json +0 -1
- package/assets/esri/widgets/support/t9n/SaveLayer_sv.json +0 -1
- package/assets/esri/widgets/support/t9n/SaveLayer_th.json +0 -1
- package/assets/esri/widgets/support/t9n/SaveLayer_tr.json +0 -1
- package/assets/esri/widgets/support/t9n/SaveLayer_uk.json +0 -1
- package/assets/esri/widgets/support/t9n/SaveLayer_vi.json +0 -1
- package/assets/esri/widgets/support/t9n/SaveLayer_zh-CN.json +0 -1
- package/assets/esri/widgets/support/t9n/SaveLayer_zh-HK.json +0 -1
- package/assets/esri/widgets/support/t9n/SaveLayer_zh-TW.json +0 -1
- package/widgets/Directions/components/SaveLayer.js +0 -5
- package/widgets/Directions/css.js +0 -5
- /package/{views/3d/webgl-engine/core/shaderLibrary/util → webscene/support}/AlphaCutoff.js +0 -0
|
@@ -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 i from"../../core/Accessor.js";import r from"../../core/Collection.js";import{watch as t,initial as s,when as a}from"../../core/reactiveUtils.js";import{property as n}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{get as l}from"../../core/accessorSupport/get.js";import{getEffectiveFeatureReduction as y}from"../../views/2d/layers/features/layerAdapters/featureReductionUtils.js";import d from"./support/ActiveLayerInfo.js";import{onLocaleChange as h}from"../../intl/locale.js";const c={state:"state",view:"view",allLayerViews:"all-layer-views",legendProperties:"legend-properties"},L=r.ofType(d),p=new Set(["esri.layers.BuildingSceneLayer","esri.layers.CatalogLayer","esri.layers.CSVLayer","esri.layers.FeatureLayer","esri.layers.GeoJSONLayer","esri.layers.GeoRSSLayer","esri.layers.GroupLayer","esri.layers.HeatmapLayer","esri.layers.ImageryLayer","esri.layers.ImageryTileLayer","esri.layers.MapImageLayer","esri.layers.OGCFeatureLayer","esri.layers.OrientedImageryLayer","esri.layers.ParquetLayer","esri.layers.PointCloudLayer","esri.layers.StreamLayer","esri.layers.SceneLayer","esri.layers.SubtypeGroupLayer","esri.layers.TileLayer","esri.layers.VoxelLayer","esri.layers.WFSLayer","esri.layers.WMSLayer","esri.layers.WMTSLayer","esri.layers.WCSLayer","esri.layers.LinkChartLayer","esri.layers.catalog.CatalogFootprintLayer","esri.layers.catalog.CatalogDynamicGroupLayer","esri.layers.knowledgeGraph.KnowledgeGraphSublayer","esri.layers.KnowledgeGraphLayer"]),u="view.basemapView.baseLayerViews",f="view.groundView.layerViews",v="view.basemapView.referenceLayerViews",_=[u,f,"view.layerViews",v];let w=class extends i{constructor(e){super(e),this._layerViewByLayerId={},this._layerInfosByLayerViewId={},this._activeLayerInfosByLayerViewId={},this._activeLayerInfosWithNoParent=new r,this.activeLayerInfos=new L,this.basemapLegendVisible=!1,this.groundLegendVisible=!1,this.hideLayersNotInCurrentView=!1,this.keepCacheOnDestroy=!1,this.respectLayerDefinitionExpression=!1,this.respectLayerVisibility=!0,this.layerInfos=[],this.view=null}initialize(){this.addHandles(t((()=>this.view),(()=>this._viewHandles()),s),c.view),this.addHandles(h((()=>this._refresh())))}destroy(){this._destroyViewActiveLayerInfos(),this.view=null}get state(){return this.view?.ready?"ready":"disabled"}_viewHandles(){this.removeHandles(c.state),this.view&&this.addHandles(t((()=>this.state),(()=>this._stateHandles()),s),c.state)}_stateHandles(){this._resetAll(),"ready"===this.state&&this._watchPropertiesAndAllLayerViews()}_resetAll(){this.removeHandles([c.allLayerViews,c.legendProperties]),this._destroyViewActiveLayerInfos(),this.activeLayerInfos.removeAll()}_destroyViewActiveLayerInfos(){Object.keys(this._activeLayerInfosByLayerViewId).forEach(this._destroyViewActiveLayerInfo,this)}_destroyViewActiveLayerInfo(e){this.removeHandles(e);const i=this._activeLayerInfosByLayerViewId[e];delete this._activeLayerInfosByLayerViewId[e],i?.parent&&i.parent.children.remove(i)}_watchPropertiesAndAllLayerViews(){const{view:e}=this;if(!e)return;const{allLayerViews:i}=e;i.length&&this._refresh(),this.addHandles(i.on("change",(e=>this._allLayerViewsChangeHandle(e))),c.allLayerViews),this.addHandles(t((()=>[this.layerInfos,this.basemapLegendVisible,this.groundLegendVisible]),(()=>this._propertiesChangeHandle())),c.legendProperties)}_allLayerViewsChangeHandle(e){e.moved.length?this._propertiesChangeHandle():(e.removed.forEach((e=>this._destroyViewActiveLayerInfo(e.uid))),this._refresh())}_propertiesChangeHandle(){this._destroyViewActiveLayerInfos(),this._refresh()}_refresh(){this._layerInfosByLayerViewId={},this.activeLayerInfos.removeAll(),this._generateLayerViews().filter(this._filterLayerViewsByLayerInfos,this).filter(this._isLayerViewSupported,this).forEach(this._generateActiveLayerInfo,this),this._sortActiveLayerInfos(this.activeLayerInfos)}_sortActiveLayerInfos(e){const i=this.view;if(e.length<2||!i)return;const r=[];e.forEach((i=>{if(!i.parent){const t=i.layer.parent,s=t&&"uid"in t&&this._layerViewByLayerId[t.uid],a=s&&this._activeLayerInfosByLayerViewId[s.uid];a&&e.includes(a)&&(r.push(i),i.parent=a,a.children.add(i),this._sortActiveLayerInfos(a.children))}})),e.removeMany(r);const t={};i.allLayerViews.forEach(((e,i)=>t[e.layer.uid]=i)),e.sort(((e,i)=>{const r=t[e.layer.uid]||0;return(t[i.layer.uid]||0)-r}))}_generateLayerViews(){const e=[];return _.filter(this._filterLayerViews,this).map((e=>l(this,e))).filter((e=>null!=e)).forEach(this._collectLayerViews("layerViews",e)),e}_filterLayerViews(e){const i=!this.basemapLegendVisible&&(e===u||e===v),r=!this.groundLegendVisible&&e===f;return!i&&!r}_collectLayerViews(e,i){const r=t=>(t&&t.forEach((t=>{i.push(t),r(t[e])})),i);return r}_filterLayerViewsByLayerInfos(e){const i=this.layerInfos;return!i||!i.length||i.some((i=>this._hasLayerInfo(i,e)))}_hasLayerInfo(e,i){const r=this._isLayerUIDMatching(e.layer,i.layer.uid);return r&&(this._layerInfosByLayerViewId[i.uid]=e),r}_isLayerUIDMatching(e,i){return e&&(e.uid===i||this._hasLayerUID(e.layers,i))}_hasLayerUID(e,i){return e&&e.some((e=>this._isLayerUIDMatching(e,i)))}_isLayerViewSupported(e){return!!p.has(e.layer.declaredClass)&&(this._layerViewByLayerId[e.layer.uid]=e,!0)}_generateActiveLayerInfo(e){this._isLayerActive(e)?this._buildActiveLayerInfo(e):(this.removeHandles(e.uid),this.addHandles(t((()=>[e.legendEnabled,e.layer?.legendEnabled]),(()=>this._layerActiveHandle(e))),e.uid))}_layerActiveHandle(e){this._isLayerActive(e)&&(this.removeHandles(e.uid),this._buildActiveLayerInfo(e))}_isLayerActive(e){return!this.respectLayerVisibility||e.legendEnabled&&e.layer?.legendEnabled}_buildActiveLayerInfo(e){const i=e.layer,r=e.uid,n=this._layerInfosByLayerViewId[r];let o=this._activeLayerInfosByLayerViewId[r];if(!o){const t=void 0!==n?.title&&n.layer.uid===i.uid;o=new d({layer:i,layerView:e,title:t?n.title:i.title,view:this.view??void 0,respectLayerDefinitionExpression:this.respectLayerDefinitionExpression,respectLayerVisibility:this.respectLayerVisibility,hideLayersNotInCurrentView:this.hideLayersNotInCurrentView,keepCacheOnDestroy:this.keepCacheOnDestroy,sublayerIds:n?.sublayerIds||[]}),this._activeLayerInfosByLayerViewId[r]=o}const l=i.parent&&"uid"in i.parent?this._layerViewByLayerId[i.parent?.uid]:null;if(o.parent=this._activeLayerInfosByLayerViewId[l?.uid],!this.hasHandles(r)){const n=[t((()=>i.title),(e=>this._titleHandle(e,o))),t((()=>[i.opacity,"renderer"in i&&i.renderer,"pointSymbol"in i&&i.pointSymbol,"lineSymbol"in i&&i.lineSymbol,"polygonSymbol"in i&&i.polygonSymbol]),(()=>this._constructLegendElements(o))),a((()=>!0===this.view?.stationary),(()=>this._scaleHandle(o)),s),t((()=>e.layer?y(e.layer,e.view):null),(()=>this._constructLegendElements(o))),t((()=>e.updating),(()=>{if(null==e.layer)return;null!=y(e.layer,e.view)&&this._constructLegendElements(o)})),t((()=>"effect"in i&&i.effect),(()=>this._constructLegendElements(o))),a((()=>this.view?.timeZone),(()=>this._constructLegendElements(o)),s)];if(this.respectLayerVisibility){const r=t((()=>e.legendEnabled),(e=>this._legendEnabledHandle(e,o))),s=t((()=>i.legendEnabled),(e=>this._legendEnabledHandle(e,o)));n.push(r,s)}if(this.respectLayerDefinitionExpression&&"definitionExpression"in i){const e=t((()=>[i.definitionExpression,this.respectLayerDefinitionExpression]),(()=>{o.respectLayerDefinitionExpression=this.respectLayerDefinitionExpression,this._constructLegendElements(o)}));n.push(e)}this.addHandles(n,r)}o.isScaleDriven||this._constructLegendElements(o),this._addActiveLayerInfo(o)}_titleHandle(e,i){i.title=e,this._constructLegendElements(i)}_legendEnabledHandle(e,i){e?this._addActiveLayerInfo(i):this._removeActiveLayerInfo(i)}_scaleHandle(e){(e.isScaleDriven||e.hideLayersNotInCurrentView)&&this._constructLegendElements(e)}_addActiveLayerInfo(e){const{layerView:i,layer:r}=e;if(this._isLayerActive(i)&&!this.activeLayerInfos.includes(e)){const i=e.parent;if(i)i.children.includes(e)||i.children.push(e),this._sortActiveLayerInfos(i.children);else{const i=this.layerInfos?.some((e=>e.layer.uid===r.uid)),t=r.parent;(t&&"uid"in t?this._layerViewByLayerId[t.uid]:null)&&!i?this._activeLayerInfosWithNoParent.add(e):(this.activeLayerInfos.add(e),this._sortActiveLayerInfos(this.activeLayerInfos))}if(this._activeLayerInfosWithNoParent.length){const e=[];this._activeLayerInfosWithNoParent.forEach((i=>{const r=i.layer.parent,t=r&&"uid"in r?this._layerViewByLayerId[r?.uid]:null,s=this._activeLayerInfosByLayerViewId[t?.uid];s&&(e.push(i),i.parent=s)})),e.length&&(this._activeLayerInfosWithNoParent.removeMany(e),e.forEach((e=>this._addActiveLayerInfo(e))))}}}_removeActiveLayerInfo(e){const i=e.parent;i?i.children.remove(e):this.activeLayerInfos.remove(e)}_constructLegendElements(e){const i=e.layer;"featureCollections"in i&&i.featureCollections?e.buildLegendElementsForFeatureCollections(i.featureCollections):"featureReduction"in i&&i.featureReduction&&"renderer"in i.featureReduction&&("binning"===i.featureReduction.type||"cluster"===i.featureReduction.type)&&(!this.view||i.featureReduction.maxScale<=this.view.scale)?e.buildLegendElementsForFeatureReduction(i.featureReduction):"renderer"in i&&i.renderer&&!("sublayers"in i)?e.buildLegendElementsForRenderer(i.renderer):"url"in i&&i.url&&"catalog"!==i.type&&"knowledge-graph"!==i.type?e.buildLegendElementsForTools():e.children.forEach((e=>this._constructLegendElements(e)))}};e([n({type:L})],w.prototype,"activeLayerInfos",void 0),e([n()],w.prototype,"basemapLegendVisible",void 0),e([n()],w.prototype,"groundLegendVisible",void 0),e([n()],w.prototype,"hideLayersNotInCurrentView",void 0),e([n()],w.prototype,"keepCacheOnDestroy",void 0),e([n()],w.prototype,"respectLayerDefinitionExpression",void 0),e([n()],w.prototype,"respectLayerVisibility",void 0),e([n()],w.prototype,"layerInfos",void 0),e([n({readOnly:!0})],w.prototype,"state",null),e([n()],w.prototype,"view",void 0),w=e([o("esri.widgets.Legend.LegendViewModel")],w);const I=w;export{I as default};
|
|
5
|
+
import{_ as e}from"../../chunks/tslib.es6.js";import"../../intl.js";import i from"../../core/Accessor.js";import r from"../../core/Collection.js";import{watch as t,initial as s,when as a}from"../../core/reactiveUtils.js";import{property as n}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{get as l}from"../../core/accessorSupport/get.js";import{getEffectiveFeatureReduction as y}from"../../views/2d/layers/features/layerAdapters/featureReductionUtils.js";import d from"./support/ActiveLayerInfo.js";import{onLocaleChange as c}from"../../intl/locale.js";const h={state:"state",view:"view",allLayerViews:"all-layer-views",legendProperties:"legend-properties"},L=r.ofType(d),p=new Set(["esri.layers.BuildingSceneLayer","esri.layers.CatalogLayer","esri.layers.CSVLayer","esri.layers.FeatureLayer","esri.layers.GeoJSONLayer","esri.layers.GeoRSSLayer","esri.layers.GroupLayer","esri.layers.HeatmapLayer","esri.layers.ImageryLayer","esri.layers.ImageryTileLayer","esri.layers.MapImageLayer","esri.layers.OGCFeatureLayer","esri.layers.OrientedImageryLayer","esri.layers.ParquetLayer","esri.layers.PointCloudLayer","esri.layers.StreamLayer","esri.layers.SceneLayer","esri.layers.SubtypeGroupLayer","esri.layers.TileLayer","esri.layers.VoxelLayer","esri.layers.WFSLayer","esri.layers.WMSLayer","esri.layers.WMTSLayer","esri.layers.WCSLayer","esri.layers.LinkChartLayer","esri.layers.catalog.CatalogFootprintLayer","esri.layers.catalog.CatalogDynamicGroupLayer","esri.layers.knowledgeGraph.KnowledgeGraphSublayer","esri.layers.KnowledgeGraphLayer"]),u="view.basemapView.baseLayerViews",f="view.groundView.layerViews",v="view.basemapView.referenceLayerViews",_=[u,f,"view.layerViews",v];let w=class extends i{constructor(e){super(e),this._layerViewByLayerId={},this._layerInfosByLayerViewId={},this._activeLayerInfosByLayerViewId={},this._activeLayerInfosWithNoParent=new r,this.activeLayerInfos=new L,this.basemapLegendVisible=!1,this.groundLegendVisible=!1,this.hideLayersNotInCurrentView=!1,this.keepCacheOnDestroy=!1,this.respectLayerDefinitionExpression=!1,this.respectLayerDisplayFilter=!1,this.respectLayerVisibility=!0,this.layerInfos=[],this.view=null}initialize(){this.addHandles(t((()=>this.view),(()=>this._viewHandles()),s),h.view),this.addHandles(c((()=>this._refresh())))}destroy(){this._destroyViewActiveLayerInfos(),this.view=null}get state(){return this.view?.ready?"ready":"disabled"}_viewHandles(){this.removeHandles(h.state),this.view&&this.addHandles(t((()=>this.state),(()=>this._stateHandles()),s),h.state)}_stateHandles(){this._resetAll(),"ready"===this.state&&this._watchPropertiesAndAllLayerViews()}_resetAll(){this.removeHandles([h.allLayerViews,h.legendProperties]),this._destroyViewActiveLayerInfos(),this.activeLayerInfos.removeAll()}_destroyViewActiveLayerInfos(){Object.keys(this._activeLayerInfosByLayerViewId).forEach(this._destroyViewActiveLayerInfo,this)}_destroyViewActiveLayerInfo(e){this.removeHandles(e);const i=this._activeLayerInfosByLayerViewId[e];delete this._activeLayerInfosByLayerViewId[e],i?.parent&&i.parent.children.remove(i)}_watchPropertiesAndAllLayerViews(){const{view:e}=this;if(!e)return;const{allLayerViews:i}=e;i.length&&this._refresh(),this.addHandles(i.on("change",(e=>this._allLayerViewsChangeHandle(e))),h.allLayerViews),this.addHandles(t((()=>[this.layerInfos,this.basemapLegendVisible,this.groundLegendVisible]),(()=>this._propertiesChangeHandle())),h.legendProperties)}_allLayerViewsChangeHandle(e){e.moved.length?this._propertiesChangeHandle():(e.removed.forEach((e=>this._destroyViewActiveLayerInfo(e.uid))),this._refresh())}_propertiesChangeHandle(){this._destroyViewActiveLayerInfos(),this._refresh()}_refresh(){this._layerInfosByLayerViewId={},this.activeLayerInfos.removeAll(),this._generateLayerViews().filter(this._filterLayerViewsByLayerInfos,this).filter(this._isLayerViewSupported,this).forEach(this._generateActiveLayerInfo,this),this._sortActiveLayerInfos(this.activeLayerInfos)}_sortActiveLayerInfos(e){const i=this.view;if(e.length<2||!i)return;const r=[];e.forEach((i=>{if(!i.parent){const t=i.layer.parent,s=t&&"uid"in t&&this._layerViewByLayerId[t.uid],a=s&&this._activeLayerInfosByLayerViewId[s.uid];a&&e.includes(a)&&(r.push(i),i.parent=a,a.children.add(i),this._sortActiveLayerInfos(a.children))}})),e.removeMany(r);const t={};i.allLayerViews.forEach(((e,i)=>t[e.layer.uid]=i)),e.sort(((e,i)=>{const r=t[e.layer.uid]||0;return(t[i.layer.uid]||0)-r}))}_generateLayerViews(){const e=[];return _.filter(this._filterLayerViews,this).map((e=>l(this,e))).filter((e=>null!=e)).forEach(this._collectLayerViews("layerViews",e)),e}_filterLayerViews(e){const i=!this.basemapLegendVisible&&(e===u||e===v),r=!this.groundLegendVisible&&e===f;return!i&&!r}_collectLayerViews(e,i){const r=t=>(t&&t.forEach((t=>{i.push(t),r(t[e])})),i);return r}_filterLayerViewsByLayerInfos(e){const i=this.layerInfos;return!i||!i.length||i.some((i=>this._hasLayerInfo(i,e)))}_hasLayerInfo(e,i){const r=this._isLayerUIDMatching(e.layer,i.layer.uid);return r&&(this._layerInfosByLayerViewId[i.uid]=e),r}_isLayerUIDMatching(e,i){return e&&(e.uid===i||this._hasLayerUID(e.layers,i))}_hasLayerUID(e,i){return e&&e.some((e=>this._isLayerUIDMatching(e,i)))}_isLayerViewSupported(e){return!!p.has(e.layer.declaredClass)&&(this._layerViewByLayerId[e.layer.uid]=e,!0)}_generateActiveLayerInfo(e){this._isLayerActive(e)?this._buildActiveLayerInfo(e):(this.removeHandles(e.uid),this.addHandles(t((()=>[e.legendEnabled,e.layer?.legendEnabled]),(()=>this._layerActiveHandle(e))),e.uid))}_layerActiveHandle(e){this._isLayerActive(e)&&(this.removeHandles(e.uid),this._buildActiveLayerInfo(e))}_isLayerActive(e){return!this.respectLayerVisibility||e.legendEnabled&&e.layer?.legendEnabled}_buildActiveLayerInfo(e){const i=e.layer,r=e.uid,n=this._layerInfosByLayerViewId[r];let o=this._activeLayerInfosByLayerViewId[r];if(!o){const t=void 0!==n?.title&&n.layer.uid===i.uid;o=new d({layer:i,layerView:e,title:t?n.title:i.title,view:this.view??void 0,respectLayerDefinitionExpression:this.respectLayerDefinitionExpression,respectLayerDisplayFilter:this.respectLayerDisplayFilter,respectLayerVisibility:this.respectLayerVisibility,hideLayersNotInCurrentView:this.hideLayersNotInCurrentView,keepCacheOnDestroy:this.keepCacheOnDestroy,sublayerIds:n?.sublayerIds||[]}),this._activeLayerInfosByLayerViewId[r]=o}const l=i.parent&&"uid"in i.parent?this._layerViewByLayerId[i.parent?.uid]:null;if(o.parent=this._activeLayerInfosByLayerViewId[l?.uid],!this.hasHandles(r)){const n=[t((()=>i.title),(e=>this._titleHandle(e,o))),t((()=>[i.opacity,"renderer"in i&&i.renderer,"pointSymbol"in i&&i.pointSymbol,"lineSymbol"in i&&i.lineSymbol,"polygonSymbol"in i&&i.polygonSymbol]),(()=>this._constructLegendElements(o))),a((()=>!0===this.view?.stationary),(()=>this._scaleHandle(o)),s),t((()=>e.layer?y(e.layer,e.view):null),(()=>this._constructLegendElements(o))),t((()=>e.updating),(()=>{if(null==e.layer)return;null!=y(e.layer,e.view)&&this._constructLegendElements(o)})),t((()=>"effect"in i&&i.effect),(()=>this._constructLegendElements(o))),a((()=>this.view?.timeZone),(()=>this._constructLegendElements(o)),s)];if(this.respectLayerVisibility){const r=t((()=>e.legendEnabled),(e=>this._legendEnabledHandle(e,o))),s=t((()=>i.legendEnabled),(e=>this._legendEnabledHandle(e,o)));n.push(r,s)}if(this.respectLayerDefinitionExpression&&"definitionExpression"in i){const e=t((()=>[i.definitionExpression,this.respectLayerDefinitionExpression]),(()=>{o.respectLayerDefinitionExpression=this.respectLayerDefinitionExpression,this._constructLegendElements(o)}));n.push(e)}if(this.respectLayerDisplayFilter&&"displayFilterInfo"in i){const e=t((()=>this.respectLayerDisplayFilter),(()=>{o.respectLayerDisplayFilter=this.respectLayerDisplayFilter,this._constructLegendElements(o)}));n.push(e)}this.addHandles(n,r)}o.isScaleDriven||this._constructLegendElements(o),this._addActiveLayerInfo(o)}_titleHandle(e,i){i.title=e,this._constructLegendElements(i)}_legendEnabledHandle(e,i){e?this._addActiveLayerInfo(i):this._removeActiveLayerInfo(i)}_scaleHandle(e){(e.isScaleDriven||e.hideLayersNotInCurrentView)&&this._constructLegendElements(e)}_addActiveLayerInfo(e){const{layerView:i,layer:r}=e;if(this._isLayerActive(i)&&!this.activeLayerInfos.includes(e)){const i=e.parent;if(i)i.children.includes(e)||i.children.push(e),this._sortActiveLayerInfos(i.children);else{const i=this.layerInfos?.some((e=>e.layer.uid===r.uid)),t=r.parent;(t&&"uid"in t?this._layerViewByLayerId[t.uid]:null)&&!i?this._activeLayerInfosWithNoParent.add(e):(this.activeLayerInfos.add(e),this._sortActiveLayerInfos(this.activeLayerInfos))}if(this._activeLayerInfosWithNoParent.length){const e=[];this._activeLayerInfosWithNoParent.forEach((i=>{const r=i.layer.parent,t=r&&"uid"in r?this._layerViewByLayerId[r?.uid]:null,s=this._activeLayerInfosByLayerViewId[t?.uid];s&&(e.push(i),i.parent=s)})),e.length&&(this._activeLayerInfosWithNoParent.removeMany(e),e.forEach((e=>this._addActiveLayerInfo(e))))}}}_removeActiveLayerInfo(e){const i=e.parent;i?i.children.remove(e):this.activeLayerInfos.remove(e)}_constructLegendElements(e){const i=e.layer;"featureCollections"in i&&i.featureCollections?e.buildLegendElementsForFeatureCollections(i.featureCollections):"featureReduction"in i&&i.featureReduction&&"renderer"in i.featureReduction&&("binning"===i.featureReduction.type||"cluster"===i.featureReduction.type)&&(!this.view||i.featureReduction.maxScale<=this.view.scale)?e.buildLegendElementsForFeatureReduction(i.featureReduction):"renderer"in i&&i.renderer&&!("sublayers"in i)?e.buildLegendElementsForRenderer(i.renderer):"url"in i&&i.url&&"catalog"!==i.type&&"knowledge-graph"!==i.type?e.buildLegendElementsForTools():e.children.forEach((e=>this._constructLegendElements(e)))}};e([n({type:L})],w.prototype,"activeLayerInfos",void 0),e([n()],w.prototype,"basemapLegendVisible",void 0),e([n()],w.prototype,"groundLegendVisible",void 0),e([n()],w.prototype,"hideLayersNotInCurrentView",void 0),e([n()],w.prototype,"keepCacheOnDestroy",void 0),e([n()],w.prototype,"respectLayerDefinitionExpression",void 0),e([n()],w.prototype,"respectLayerDisplayFilter",void 0),e([n()],w.prototype,"respectLayerVisibility",void 0),e([n()],w.prototype,"layerInfos",void 0),e([n({readOnly:!0})],w.prototype,"state",null),e([n()],w.prototype,"view",void 0),w=e([o("esri.widgets.Legend.LegendViewModel")],w);const I=w;export{I 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 f}from"../../../core/sql.js";import{addQueryParameters as p}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{ExportImageParameters as v}from"../../../layers/support/ExportImageParameters.js";import{getRendererFields as L}from"../../../layers/support/fieldUtils.js";import{isFeatureLayer as E}from"../../../layers/support/layerUtils.js";import{getPixelValueRange as C}from"../../../layers/support/rasterFormats/pixelRangeUtils.js";import{fromJSON as I}from"../../../renderers/support/jsonUtils.js";import{isSupportedRenderer3D as R}from"../../../renderers/support/rendererConversion.js";import F from"../../../renderers/visualVariables/SizeVariable.js";import V from"../../../renderers/visualVariables/support/SizeVariableLegendOptions.js";import{updateReferenceSizeSymbol as x}from"../../../smartMapping/renderers/support/referenceSizeUtils.js";import D from"../../../symbols/SimpleFillSymbol.js";import z from"../../../symbols/SimpleMarkerSymbol.js";import{applyCIMSymbolColor as T}from"../../../symbols/support/cimSymbolUtils.js";import{SymbolSizeDefaults as j}from"../../../symbols/support/previewUtils.js";import{renderSymbol as O}from"../../../symbols/support/renderUtils.js";import{renderColorRampPreviewHTML as P,renderDotDensityPreviewHTML as A,renderPieChartPreviewHTML as M,renderPreviewHTML as U}from"../../../symbols/support/symbolUtils.js";import{isVolumetricSymbol as k}from"../../../symbols/support/utils.js";import{getEffectiveClusterSizeVariable as B}from"./clusterUtils.js";import{getColorFromPointCloudStops as N,getRampStopsForPointCloud as q,getStretchRampStops as H,getRampStops as $}from"./colorRampUtils.js";import{getHeatmapRampStops as W}from"./heatmapRampUtils.js";import{getRotationAngleForFocus as G,getRelationshipRampElement as J}from"./relationshipRampUtils.js";import{getRampStops as Q,realWorldMaxSize as Z,realWorldMinSize as K}from"./sizeRampUtils.js";import{specialCharsLessThan as X,specialCharsGreaterThan as Y,getReferenceSizeAuthoringInfoVisualVariable as ee,getSymbolForFlowRenderer as te,getMedianColor as ie,rgbImgSource as se,getDateFormatOptions as le}from"./utils.js";import{formatNumberLabel as re}from"../../smartMapping/support/utils.js";import{fetchMessageBundle as ne}from"../../../intl/messages.js";import{substitute as ae}from"../../../intl/substitute.js";const oe=16,ue="https://utility.arcgis.com/sharing/tools/legend",ce="esri.layers.ImageryLayer",de="esri.layers.ImageryTileLayer",ye="esri.layers.WCSLayer",he=/^\s*(return\s+)?\$view\.scale\s*(;)?\s*$/i,me=new a({esriGeometryPoint:"point",esriGeometryMultipoint:"multipoint",esriGeometryPolyline:"polyline",esriGeometryPolygon:"polygon",esriGeometryMultiPatch:"multipatch"}),fe=new z({size:6,outline:{color:[128,128,128,.5],width:.5}}),pe=new D({style:"solid"});function ge(e){return"flow"===e.type}function be(e){return"vector-field"===e.type}function Se(e){return"raster-colormap"===e.type}function _e(e){return"raster-stretch"===e.type}function we(e){return"raster-shaded-relief"===e.type}function ve(e){return"esri.renderers.SimpleRenderer"===e.declaredClass}function Le(e){return"esri.renderers.ClassBreaksRenderer"===e.declaredClass}function Ee(e){return"esri.renderers.UniqueValueRenderer"===e.declaredClass}function Ce(e){return"esri.renderers.HeatmapRenderer"===e.declaredClass}function Ie(e){return Fe(e)||Ve(e)||xe(e)||Re(e)}function Re(e){return"esri.renderers.PointCloudRGBRenderer"===e.declaredClass}function Fe(e){return"esri.renderers.PointCloudClassBreaksRenderer"===e.declaredClass}function Ve(e){return"esri.renderers.PointCloudStretchRenderer"===e.declaredClass}function xe(e){return"esri.renderers.PointCloudUniqueValueRenderer"===e.declaredClass}function De(e){return"esri.renderers.DotDensityRenderer"===e.declaredClass}function ze(e){return"esri.renderers.PieChartRenderer"===e.declaredClass}function Te(e,t){return ve(e)||Le(e)||Ee(e)||Ce(e)||De(e)||ze(e)?"2d"===t.type||R(e):_e(e)||Se(e)||we(e)||Fe(e)||Ve(e)||xe(e)||be(e)||ge(e)}function je(e){return"esri.layers.BuildingSceneLayer"===e.declaredClass}function Oe(e){return"esri.layers.SubtypeGroupLayer"===e.declaredClass}function Pe(e){return"esri.layers.VoxelLayer"===e.declaredClass}function Ae(e){return"esri.layers.WMSLayer"===e.declaredClass}function Me(e){return"esri.layers.WMTSLayer"===e.declaredClass}function Ue(e){return"esri.layers.MapImageLayer"===e.declaredClass}function ke(e){return"esri.layers.TileLayer"===e.declaredClass}function Be(e){return e.declaredClass===ce}function Ne(e){return e.declaredClass===de}function qe(e){return e.declaredClass===ye}function He(e){return"stretch-ramp"===e.type}function $e(e){const t="authoringInfo"in e?e?.authoringInfo:null;return"univariate-color-size"===t?.type}function We(e){const t="authoringInfo"in e?e?.authoringInfo:null;return"univariate-color-size"===t?.type&&"above-and-below"===t?.univariateTheme}function Ge(e){return"sublayers"in e}async function Je(e,t){const i=await ne("esri/widgets/Legend/t9n/Legend");return"previewTemplateAriaLabel"!==e||t||(e="previewAriaLabel"),ae(i[e],{label:t})}function Qe(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 Ze=new z({style:"path",path:"M10,5 L5,0 0,5 M5,0 L5,15",size:15,outline:{width:1,color:[85,85,85,1]}});let Ke={},Xe=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.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||(Ke={})}destroy(){this._webStyleSymbolCache=null,this._dotDensityUrlCache=null,this._scaleDrivenSizeVariable=null,this.keepCacheOnDestroy||(Ke=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?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(E(e))return this._getRendererLegendElements(e.renderer,{title:e.title});if(e.featureSet?.features.length){const t=e.layerDefinition,i=t?.drawingInfo,s=i&&I(i.renderer),l=me.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(Pe(e))this._constructLegendElementsForVoxelLayer();else if(Me(e))this._constructLegendElementsForWMTSlayer();else if(Ae(e))await this._constructLegendElementsForWMSSublayers();else if(je(e))await this._constructLegendElementsForBuildingSceneLayer();else if(Ue(e)||ke(e)||Oe(e))await this._constructLegendElementsForSublayers();else{this.removeHandles("imageryLayers-watcher");let t="default";if(Be(e)){const i=e;t=(i?.rasterFunction?.functionName||"default")+"_"+(e.bandIds?.length?e.bandIds.join(""):"###")}if(Ne(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(Be(e)){const t=d((()=>[e.rasterFunction,e.bandIds]),(()=>u((async()=>{Ke.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&&(Be(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(he.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))||he.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&&Ue(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 D({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?X:Y} ${re(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:P(l.map((e=>e.color)),{ariaLabel:await Je("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=p(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=Ke&&Ke[e];return i?Promise.resolve(i):this._legendRequest(t).then((t=>{const i=t.layers;return Ke[e]=i,i}))}_legendRequest(e){const t=this.layer;let i={f:"json",dynamicLayers:e};if(Be(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=ue+"?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(Ue(e)||ke(e)||Oe(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=Oe(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=!Ge(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(Ge(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 v({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(!Te(e,this.view))return o.getLogger(this).warn(`Renderer of type '${e.type}' not supported!`),[];if(Ie(e))return this._constructPointCloudRendererLegendElements(e,t);if(De(e))return this._constructDotDensityRendererLegendElements(e);const i=await this._loadRenderer(e);return ze(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(Fe(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(Ve(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=N(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=q(e.stops??[])??[];r={type:"color-ramp",title:i||this._getPointCloudRendererTitle(e),infos:n,preview:P(n.map((e=>e.color)),{ariaLabel:await Je("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 Je("previewTemplateAriaLabel",s||l),y=a+"-"+i+"-"+r+"-"+(n&&JSON.stringify(n.toJSON()))+"-"+c,h=this._dotDensityUrlCache,m=h.has(y)?h.get(y):A(e,i,{ariaLabel:d});h.set(y,m);const f={shape:{type:"image",x:0,y:0,width:m.width,height:m.height,src:m.src},fill:null,stroke:null,offset:[0,0]},p=O([[f]],[m.width,m.height],{effectView:this.effectList,ariaLabel:d});return{opacity:1,src:m.src,preview:p,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 z({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 z({color:e.othersCategory.color,outline:l});s=e.othersCategory.label||"Other",i.push({label:s,symbol:t})}if(e.defaultColor?.a){const t=new z({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=M(t,{holePercentage:e.holePercentage,backgroundColor:e.backgroundFillSymbol?.color,effectList:this.effectList,outline:l,ariaLabel:await Je("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 _constructRendererLegendElements(e,t={}){const{title:i,sublayer:s}=t,l=s||this.layer,r=ee(e);if("definitionExpression"in l){const t=l.definitionExpression;if(t&&this.respectLayerDefinitionExpression&&Ee(e)){if(this._layerDefinitionExpression!==t){this._layerDefinitionExpressionClause=await f(t,l.fieldsIndex);const i=new Set((await L(e,l.fieldsIndex)).map((e=>e.toLowerCase()))),s=this._layerDefinitionExpressionClause?.fieldNames.map((e=>e.toLowerCase()));s?.every((e=>i.has(e)))||(this._layerDefinitionExpressionClause=null,s?.length&&o.getLogger(this).warn("Definition expression will be ignored in the Legend, as fields in the expression do not match with renderer fields"))}}else this._layerDefinitionExpressionClause=null;this._layerDefinitionExpression=t}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 u=null,c=!1;const d=new Set;if(ge(e)&&!this._hasSizeRamp){const t=await te(e);a.infos.push({label:null,symbol:t})}else if($e(e)){let t=i;const s=We(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(Ce(e)){const t=W(e);n.push({type:"heatmap-ramp",title:i||this._getRendererTitle(e,l),infos:t,preview:P(t.map((e=>e.color)),{effectList:this.effectList,ariaLabel:await Je("previewColorRampAriaLabel")})})}else if(Ee(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=G(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=Ze.clone();n.angle=u,a.infos.push({label:r,symbol:n}),d.add(n),u+=90}const c=J({focus:o,numClasses:i,infos:e.uniqueValueInfos??[]});n.unshift(c)}}else if(Be(this.layer)||Ne(this.layer))e.uniqueValueInfos?.forEach((t=>{t.symbol&&this._checkDefinitionExpressionForUVR(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:u,defaultSymbol:d}=e,y=!(!t&&!u||!s&&!n),h=[];if(e.uniqueValueGroups?.forEach((i=>{const a={type:"symbol-table",title:i.heading,infos:[]};i.classes?.forEach((i=>{const{symbol:c,values:d}=i;if(c){const h=[],m=[];for(const e of d??[]){const{value:i,value2:r,value3:a}=e,c=[],d=[];(t||u)&&(c.push(i),d.push(this._getDomainName(t,i,l))),s&&(c.push(r),d.push(this._getDomainName(s,r,l))),n&&(c.push(a),d.push(this._getDomainName(n,a,l))),h.push(y?c.join(o||""):c[0]),m.push(d.join(" - "))}const f=h.join(", ");let p=i.label;if(!p){const e=m.filter(Boolean);p=e.length?e.join(", "):f}const g=c.clone();"cim"===g.type&&r&&x(g,{innerDotSize:.5*oe,outerRingSize:oe}),h.some((t=>this._checkDefinitionExpressionForUVR(e,t)))&&a.infos.push({label:p,value:f,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}]}),c=!0),a.infos.push(...h)),i||e.legendOptions?.title||e.valueExpressionTitle||(a.title=null)}}e.defaultSymbol&&!c&&(a.infos.push({label:e.defaultLabel||"others",symbol:e.defaultSymbol}),c=!0)}else if(Le(e)){if(!r){u=this._isUnclassedRenderer(e);if(!u||!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||(u?null:`${s} - ${l}`),value:[s,l],symbol:r};i?a.infos.push(t):a.infos.unshift(t)}u&&(a.title=null),this._updateInfosForClassedSizeRenderer(e,a.infos)}e.defaultSymbol&&!u&&(a.infos.push({label:e.defaultLabel||"others",symbol:e.defaultSymbol}),c=!0)}}else if(_e(e))if(Ne(this.layer)||qe(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=C(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(Se(e))e.colormapInfos.forEach((e=>{a.infos.push({label:e.label,value:e.value,symbol:this._getAppliedCloneSymbol(pe,e.color)})}));else if(ve(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(be(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 we(e)&&n.push(await this._getStretchLegendElements(e,{min:0,max:255}));const y=e.defaultSymbol;!y||c||ve(e)||u&&!this._hasColorRamp&&!this._hasSizeRamp&&!this._hasOpacityRamp||n.push({type:"symbol-table",infos:[{label:e.defaultLabel||"others",symbol:y}]}),a.infos.length&&n.unshift(a);const h=null==t.opacity?this.opacity:t.opacity,m=this._isTallSymbol("visualVariables"in e?e.visualVariables:null),p=Be(this.layer)||Ne(this.layer),g=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,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(g),n}_checkDefinitionExpressionForUVR(e,t){if(!this._layerDefinitionExpressionClause)return!0;const i=Qe(e,t);return(i&&this._layerDefinitionExpressionClause.testFeature(i))??!0}_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=C(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:P(s.map((e=>e.color)),{ariaLabel:await Je("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 Q(i,t,await ie(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:se[s],opacity:this.opacity??1})})),t}_updateInfosForClassedSizeRenderer(e,t){const i=e.authoringInfo&&"class-breaks-size"===e.authoringInfo.type,s=e.classBreakInfos.some((e=>k(e.symbol)));if(i&&s){const i=Z,s=K,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(j.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 U(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 Je("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=B(e,this.layerView,this.view);if(s&&null!=i&&"visualVariables"in i){const t=i.visualVariables?.some((e=>"size"===e.type&&"outline"!==e.target&&!he.test(e.valueExpression)));if(!t){if("clusterMinSize"in e&&"clusterMaxSize"in e){const{clusterMinSize:t,clusterMaxSize:i}=e;s.legendOptions=new V({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 ie(i);if(Le(i)||Ee(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,ve(i))})).catch((()=>{this._applySymbolToRenderer(i,null,ve(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?T(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=ee(e);if(2===a?.sizeStops?.length&&(Le(e)||Ee(e))){const[e,t]=a.sizeStops;l.push(new F({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&&Le(e)&&e.classBreakInfos&&1===e.classBreakInfos.length){const t=e.classBreakInfos[0];u=t&&t.symbol}if(0===s.length&&ve(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=ge(e)?i.field:this._getRampTitle(i,t);let l=null;const r=le(t,i,this.view.timeZone);if("color"===i.type){const e=await $(i,null,r)??[];l={type:"color-ramp",title:s,infos:e,preview:P(e.map((e=>e.color)),{effectList:d,ariaLabel:await Je("previewColorRampAriaLabel")})},this._hasColorRamp||(this._hasColorRamp=e.length>0)}else if("size"===i.type&&"outline"!==i.target)he.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 $(i,c,r)??[];l={type:"opacity-ramp",title:s,infos:e,preview:P(e.map((e=>e.color)),{effectList:d,ariaLabel:await Je("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(Le(i)&&(l=i.normalizationField,r="percent-of-total"===i.normalizationType),s="function"==typeof s?null:s,l="function"==typeof l?null:l,Ee(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 Le(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()],Xe.prototype,"children",void 0),e([g({readOnly:!0})],Xe.prototype,"effectList",null),e([g()],Xe.prototype,"layerView",void 0),e([g()],Xe.prototype,"layer",void 0),e([g()],Xe.prototype,"legendElements",void 0),e([g({readOnly:!0})],Xe.prototype,"opacity",null),e([g()],Xe.prototype,"parent",void 0),e([g({readOnly:!0,dependsOn:[]})],Xe.prototype,"ready",null),e([g()],Xe.prototype,"hideLayersNotInCurrentView",void 0),e([g()],Xe.prototype,"keepCacheOnDestroy",void 0),e([g()],Xe.prototype,"respectLayerDefinitionExpression",void 0),e([g()],Xe.prototype,"respectLayerVisibility",void 0),e([g({readOnly:!0})],Xe.prototype,"scale",null),e([g()],Xe.prototype,"sublayerIds",void 0),e([g({readOnly:!0})],Xe.prototype,"isScaleDriven",null),e([g()],Xe.prototype,"title",void 0),e([g({readOnly:!0,dependsOn:["ready"],value:0})],Xe.prototype,"version",null),e([g()],Xe.prototype,"view",void 0),Xe=e([b("esri.widgets.Legend.support.ActiveLayerInfo")],Xe);const Ye=Xe;export{Ye 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 $,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 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 $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 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.respectLayerDisplayFilter=!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?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=$(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,i){const l=await p(e,s),r=await E(t,s),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(`${i} 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 s=e.definitionExpression;s&&this.respectLayerDefinitionExpression?this._layerDefinitionExpression!==s&&(this._layerDefinitionExpressionClause=await this._getWhereClause(s,t,e.fieldsIndex,"Definition Expression")):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;s?.where&&this.respectLayerDisplayFilter?this._layerDisplayFilterId!==s?.id&&(this._layerDisplayFilterClause=await this._getWhereClause(s.where,t,e.fieldsIndex,"Display Filter")):this._layerDisplayFilterClause=null,this._layerDisplayFilterId=s?.id}async _constructRendererLegendElements(e,t={}){const{title:s,sublayer:i}=t,l=i||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:s||this._getRendererTitle(e,l),infos:[]};let o=null,u=!1;const c=new Set;if(be(e)&&!this._hasSizeRamp){const t=await se(e);a.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=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:i,title:t,infos:u})}else if(Ie(e)){const t=G(e);n.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,o=t.focus;if(s&&i&&r){const t=[i,r];let u=J(o)||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,a.infos.push({label:r,symbol:n}),c.add(n),u+=90}const d=Q({focus:o,numClasses:s,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:i,field3:n,fieldDelimiter:o,valueExpression:c,defaultSymbol:d}=e,y=!(!t&&!c||!i&&!n),h=[];if(e.uniqueValueGroups?.forEach((s=>{const a={type:"symbol-table",title:s.heading,infos:[]};s.classes?.forEach((s=>{const{symbol:u,values:d}=s;if(u){const h=[],m=[];for(const e of d??[]){const{value:s,value2:r,value3:a}=e,u=[],d=[];(t||c)&&(u.push(s),d.push(this._getDomainName(t,s,l))),i&&(u.push(r),d.push(this._getDomainName(i,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=s.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)),s||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)),s="ascending-values"===e.legendOptions?.order;for(const{label:e,minValue:i,maxValue:l,symbol:r}of t){const t={label:e||(o?null:`${i} - ${l}`),value:[i,l],symbol:r};s?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 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 o=I(r.pixelType);if(1===r.bandCount){const l=t.bandIds?.[0]||0;s=null!=s?s:r.statistics?r.statistics[l].min:o[0],i=null!=i?i:r.statistics?r.statistics[l].max:o[1],s||i?n.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:o[0],i=null!=i?i:r.statistics?r.statistics[t.bandIds[0]].max:o[1],s||i?n.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)),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 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&&a.infos.push({label:e.label,symbol:s})}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:s}=e.symbol.data;if(t&&t<this.scale||s&&s>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 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=H(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,"respectLayerDisplayFilter",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};
|
package/widgets/Legend.js
CHANGED
|
@@ -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{on as t,watch as s,initial as i}from"../core/reactiveUtils.js";import{property as r}from"../core/accessorSupport/decorators/property.js";import{cast as o}from"../core/accessorSupport/decorators/cast.js";import"../core/has.js";import"../core/RandomLCG.js";import{subclass as n}from"../core/accessorSupport/decorators/subclass.js";import
|
|
5
|
+
import{_ as e}from"../chunks/tslib.es6.js";import{on as t,watch as s,initial as i}from"../core/reactiveUtils.js";import{property as r}from"../core/accessorSupport/decorators/property.js";import{cast as o}from"../core/accessorSupport/decorators/cast.js";import"../core/has.js";import"../core/RandomLCG.js";import{subclass as n}from"../core/accessorSupport/decorators/subclass.js";import l from"./Widget.js";import a from"./Legend/LegendViewModel.js";import d from"./Legend/styles/card/CardView.js";import p from"./Legend/styles/classic/ClassicView.js";import{globalCss as y}from"./support/globalCss.js";import"./support/widgetUtils.js";import{messageBundle as c}from"./support/decorators/messageBundle.js";import{tsx as h}from"./support/jsxFactory.js";const v={base:"esri-legend"};let g=class extends l{constructor(e,t){super(e,t),this.headingLevel=3,this.messages=null,this.style=new p,this.viewModel=new a}initialize(){this.addHandles([t((()=>this.view),"resize",(()=>this.scheduleRender())),t((()=>this.activeLayerInfos),"change",(()=>this._refreshActiveLayerInfos(this.activeLayerInfos))),s((()=>this.headingLevel),(e=>{const{style:t}=this;t&&(t.headingLevel=e)})),s((()=>this.style),((e,t)=>{t&&e!==t&&t.destroy(),e&&(e.activeLayerInfos=this.activeLayerInfos,"card"===e.type&&(e.view=this.view),e.headingLevel=this.headingLevel)}),i)])}get activeLayerInfos(){return this.viewModel.activeLayerInfos}set activeLayerInfos(e){this.viewModel.activeLayerInfos=e}get basemapLegendVisible(){return this.viewModel.basemapLegendVisible}set basemapLegendVisible(e){this.viewModel.basemapLegendVisible=e}get groundLegendVisible(){return this.viewModel.groundLegendVisible}set groundLegendVisible(e){this.viewModel.groundLegendVisible=e}get hideLayersNotInCurrentView(){return this.viewModel.hideLayersNotInCurrentView}set hideLayersNotInCurrentView(e){this.viewModel.hideLayersNotInCurrentView=e}get keepCacheOnDestroy(){return this.viewModel.keepCacheOnDestroy}set keepCacheOnDestroy(e){this.viewModel.keepCacheOnDestroy=e}get respectLayerDefinitionExpression(){return this.viewModel.respectLayerDefinitionExpression}set respectLayerDefinitionExpression(e){this.viewModel.respectLayerDefinitionExpression=e}get respectLayerDisplayFilter(){return this.viewModel.respectLayerDisplayFilter}set respectLayerDisplayFilter(e){this.viewModel.respectLayerDisplayFilter=e}get respectLayerVisibility(){return this.viewModel.respectLayerVisibility}set respectLayerVisibility(e){this.viewModel.respectLayerVisibility=e}get icon(){return"legend"}set icon(e){this._overrideIfSome("icon",e)}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get layerInfos(){return this.viewModel.layerInfos}set layerInfos(e){this.viewModel.layerInfos=e}castStyle(e){if(e instanceof d||e instanceof p)return e;if("string"==typeof e)return"card"===e?new d:new p;if(e&&"string"==typeof e.type){const t={...e};return delete t.type,"card"===e.type?new d(t):new p(t)}return new p}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}render(){return h("div",{class:this.classes(v.base,y.widget,this.style instanceof p?y.panel:null)},this.style.render())}_refreshActiveLayerInfos(e){e.forEach((e=>{this.removeHandles(`version_${e.layer.uid}`),this._renderOnActiveLayerInfoChange(e)})),this.scheduleRender()}_renderOnActiveLayerInfoChange(e){const r=s((()=>e.version),(()=>this.scheduleRender()));this.addHandles(r,`version_${e.layer.uid}`);const o=t((()=>e.children),"change",(()=>e.children.forEach((e=>this._renderOnActiveLayerInfoChange(e)))),i);this.addHandles(o,`version_${e.layer.uid}`),e.children.forEach((e=>this._renderOnActiveLayerInfoChange(e)))}};e([r()],g.prototype,"activeLayerInfos",null),e([r()],g.prototype,"basemapLegendVisible",null),e([r()],g.prototype,"groundLegendVisible",null),e([r()],g.prototype,"headingLevel",void 0),e([r()],g.prototype,"hideLayersNotInCurrentView",null),e([r()],g.prototype,"keepCacheOnDestroy",null),e([r()],g.prototype,"respectLayerDefinitionExpression",null),e([r()],g.prototype,"respectLayerDisplayFilter",null),e([r()],g.prototype,"respectLayerVisibility",null),e([r()],g.prototype,"icon",null),e([r()],g.prototype,"label",null),e([r()],g.prototype,"layerInfos",null),e([r(),c("esri/widgets/Legend/t9n/Legend")],g.prototype,"messages",void 0),e([r()],g.prototype,"style",void 0),e([o("style")],g.prototype,"castStyle",null),e([r()],g.prototype,"view",null),e([r()],g.prototype,"viewModel",void 0),g=e([n("esri.widgets.Legend")],g);const u=g;export{u as default};
|