@arcgis/core 5.0.0-next.43 → 5.0.0-next.44
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/applications/Components/imageryUtils.js +1 -1
- package/assets/esri/core/workers/RemoteClient.js +1 -1
- package/assets/esri/core/workers/chunks/{f97a7cb367634353177d.js → 001a7a4cf6fe74432ed6.js} +1 -1
- package/assets/esri/core/workers/chunks/{324d66962aeec17d3e28.js → 1e0e7cef7ef947894bbe.js} +1 -1
- package/assets/esri/core/workers/chunks/20ad34f9d45c64392022.js +1 -0
- package/assets/esri/core/workers/chunks/23396a6318edf9264c1f.js +1 -0
- package/assets/esri/core/workers/chunks/{ad891ac388fa6c1c9b94.js → 2b34a010f76e5f289868.js} +1 -1
- package/assets/esri/core/workers/chunks/2ef4c0092c59a98a5532.js +1 -0
- package/assets/esri/core/workers/chunks/35272810c2ed04eb403d.js +1 -0
- package/assets/esri/core/workers/chunks/{d1f4152b2b8d47cbf586.js → 72fbee59d5d909615408.js} +1 -1
- package/assets/esri/core/workers/chunks/75c66e38bdc1c786c599.js +1 -0
- package/assets/esri/core/workers/chunks/7d3c2a063598bdd015e2.js +1 -0
- package/assets/esri/core/workers/chunks/897ce6fc9cefb1e14a64.js +1 -0
- package/assets/esri/core/workers/chunks/992e9bbdf9d3787ddb0e.js +1 -0
- package/assets/esri/core/workers/chunks/a2442549c5daf3653eb4.js +1 -0
- package/assets/esri/core/workers/chunks/a7cd795042ebb8585906.js +1 -0
- package/assets/esri/core/workers/chunks/{385cfd3087f00dbd1146.js → ca1c65eb7f5900c60170.js} +1 -1
- package/assets/esri/core/workers/chunks/cddce67919e13e2f365e.js +1 -0
- package/assets/esri/core/workers/chunks/e6784251bbb8b71ead93.js +1 -0
- package/assets/esri/core/workers/chunks/{96f798ee286b59396131.js → ea3cba01c60d9bc72719.js} +1 -1
- package/assets/esri/libs/lyr3d/lyr3DMain.wasm +0 -0
- package/assets/esri/libs/lyr3d/lyr3DWorker.wasm +0 -0
- package/config.js +1 -1
- package/interfaces.d.ts +78 -2
- package/kernel.js +1 -1
- package/layers/ImageryTileLayer.js +1 -1
- package/layers/Lyr3DWasmPerSceneView.js +1 -1
- package/layers/WCSLayer.js +1 -1
- package/layers/mixins/ArcGISImageService.js +1 -1
- package/layers/mixins/ImageryTileMixin.js +1 -1
- package/layers/mixins/RasterJobHandlerMixin.js +1 -1
- package/layers/ogc/wcsUtils.js +1 -1
- package/layers/raster/datasets/BaseRaster.js +5 -0
- package/layers/raster/datasets/CovJSONRaster.js +5 -0
- package/layers/raster/datasets/FunctionRaster.js +5 -0
- package/layers/raster/datasets/ImageAuxRaster.js +5 -0
- package/layers/raster/datasets/ImageServerRaster.js +5 -0
- package/layers/raster/datasets/InMemoryRaster.js +5 -0
- package/layers/raster/datasets/MRFRaster.js +5 -0
- package/layers/raster/datasets/RawBlockCache.js +5 -0
- package/layers/raster/datasets/TIFFRaster.js +5 -0
- package/layers/raster/datasets/WCSRaster.js +5 -0
- package/layers/raster/datasets/covJSONParser.js +5 -0
- package/layers/raster/datasets/multidimensionalUtils.js +5 -0
- package/layers/raster/datasets/pamParser.js +5 -0
- package/layers/raster/datasets/pixelReader.js +5 -0
- package/layers/raster/datasets/wcsCoverageParser.js +5 -0
- package/layers/raster/formats/Lerc.js +5 -0
- package/layers/raster/formats/Qb3.js +5 -0
- package/layers/raster/formats/RasterCodec.js +5 -0
- package/layers/raster/formats/TiffDecoder.js +5 -0
- package/layers/raster/functions/ArithmeticFunction.js +5 -0
- package/layers/{support/rasterFunctions → raster/functions}/ArithmeticFunctionArguments.js +1 -1
- package/layers/{support/rasterFunctions → raster/functions}/AspectFunction.js +1 -1
- package/layers/{support/rasterFunctions → raster/functions}/AspectFunctionArguments.js +1 -1
- package/layers/raster/functions/BandArithmeticFunction.js +5 -0
- package/layers/{support/rasterFunctions → raster/functions}/BandArithmeticFunctionArguments.js +1 -1
- package/layers/{support/rasterFunctions → raster/functions}/BaseFunctionArguments.js +1 -1
- package/layers/raster/functions/BaseRasterFunction.js +5 -0
- package/layers/{support/rasterFunctions → raster/functions}/ClipFunction.js +1 -1
- package/layers/{support/rasterFunctions → raster/functions}/ClipFunctionArguments.js +1 -1
- package/layers/raster/functions/ColormapFunction.js +5 -0
- package/layers/{support/rasterFunctions → raster/functions}/ColormapFunctionArguments.js +1 -1
- package/layers/raster/functions/ColormapToRGBFunction.js +5 -0
- package/layers/{support/rasterFunctions → raster/functions}/ColormapToRGBFunctionArguments.js +1 -1
- package/layers/raster/functions/CompositeBandFunction.js +5 -0
- package/layers/raster/functions/CompositeBandFunctionArguments.js +5 -0
- package/layers/raster/functions/ComputeChangeFunction.js +5 -0
- package/layers/{support/rasterFunctions → raster/functions}/ComputeChangeFunctionArguments.js +1 -1
- package/layers/{support/rasterFunctions → raster/functions}/ContrastBrightnessFunction.js +1 -1
- package/layers/{support/rasterFunctions → raster/functions}/ContrastBrightnessFunctionArguments.js +1 -1
- package/layers/raster/functions/ConvolutionFunction.js +5 -0
- package/layers/raster/functions/ConvolutionFunctionArguments.js +5 -0
- package/layers/{support/rasterFunctions → raster/functions}/CurvatureFunction.js +1 -1
- package/layers/{support/rasterFunctions → raster/functions}/CurvatureFunctionArguments.js +1 -1
- package/layers/{support/rasterFunctions → raster/functions}/ExtractBandFunction.js +1 -1
- package/layers/{support/rasterFunctions → raster/functions}/ExtractBandFunctionArguments.js +1 -1
- package/layers/{support/rasterFunctions → raster/functions}/GrayscaleFunction.js +1 -1
- package/layers/{support/rasterFunctions → raster/functions}/GrayscaleFunctionArguments.js +1 -1
- package/layers/raster/functions/HillshadeFunction.js +5 -0
- package/layers/{support/rasterFunctions → raster/functions}/HillshadeFunctionArguments.js +1 -1
- package/layers/raster/functions/LocalFunction.js +5 -0
- package/layers/{support/rasterFunctions → raster/functions}/LocalFunctionArguments.js +1 -1
- package/layers/{support/rasterFunctions → raster/functions}/MaskFunction.js +1 -1
- package/layers/{support/rasterFunctions → raster/functions}/MaskFunctionArguments.js +1 -1
- package/layers/{support/rasterFunctions → raster/functions}/NDVIFunction.js +1 -1
- package/layers/{support/rasterFunctions → raster/functions}/NDVIFunctionArguments.js +1 -1
- package/layers/raster/functions/RemapFunction.js +5 -0
- package/layers/{support/rasterFunctions → raster/functions}/RemapFunctionArguments.js +1 -1
- package/layers/raster/functions/ShadedReliefFunction.js +5 -0
- package/layers/{support/rasterFunctions → raster/functions}/ShadedReliefFunctionArguments.js +1 -1
- package/layers/raster/functions/SlopeFunction.js +5 -0
- package/layers/{support/rasterFunctions → raster/functions}/SlopeFunctionArguments.js +1 -1
- package/layers/raster/functions/StatisticsFunction.js +5 -0
- package/layers/{support/rasterFunctions → raster/functions}/StatisticsFunctionArguments.js +1 -1
- package/layers/{support/rasterFunctions → raster/functions}/StatisticsHistogramFunction.js +1 -1
- package/layers/{support/rasterFunctions → raster/functions}/StatisticsHistogramFunctionArguments.js +1 -1
- package/layers/raster/functions/StretchFunction.js +5 -0
- package/layers/{support/rasterFunctions → raster/functions}/StretchFunctionArguments.js +1 -1
- package/layers/{support/rasterFunctions → raster/functions}/TableFunction.js +1 -1
- package/layers/{support/rasterFunctions → raster/functions}/TableFunctionArguments.js +1 -1
- package/layers/raster/functions/bandIndexUtils.js +5 -0
- package/layers/raster/functions/changeDetectionUtils.js +5 -0
- package/layers/raster/functions/clipUtils.js +5 -0
- package/layers/raster/functions/conversionUtils.js +5 -0
- package/layers/raster/functions/convolutionUtils.js +5 -0
- package/layers/raster/functions/creators/createDataManagementFunctions.js +5 -0
- package/layers/raster/functions/creators/utils.js +5 -0
- package/layers/raster/functions/focalStatUtils.js +5 -0
- package/layers/raster/functions/localUtils.js +5 -0
- package/layers/raster/functions/pixelTransformUtils.js +5 -0
- package/layers/raster/functions/pixelUtils.js +5 -0
- package/layers/raster/functions/stretchUtils.js +5 -0
- package/layers/raster/functions/surfaceUtils.js +5 -0
- package/layers/raster/functions/vectorFieldUtils.js +5 -0
- package/layers/raster/transforms/BaseRasterTransform.js +5 -0
- package/layers/{support/rasterTransforms → raster/transforms}/GCSShiftTransform.js +1 -1
- package/layers/{support/rasterTransforms → raster/transforms}/IdentityTransform.js +1 -1
- package/layers/{support/rasterTransforms → raster/transforms}/PolynomialTransform.js +1 -1
- package/layers/save/imageryUtils.js +1 -1
- package/layers/support/PixelBlock.js +1 -1
- package/layers/support/RasterWorker.js +1 -1
- package/layers/support/imageryRendererUtils.js +1 -1
- package/layers/support/rasterFunctionUtils.js +1 -1
- package/package.json +1 -1
- package/renderers/VectorFieldRenderer.js +1 -1
- package/renderers/support/RasterSymbolizer.js +1 -1
- package/renderers/support/rasterRendererHelper.js +1 -1
- package/rest/locator/addressToLocations.js +1 -1
- package/rest/locator/addressesToLocations.js +1 -1
- package/rest/locator/suggestLocations.js +1 -1
- package/rest/networks/support/Association.js +1 -1
- package/smartMapping/raster/support/adapters/ImageryLayerAdapter.js +1 -1
- package/smartMapping/raster/support/adapters/ImageryTileLayerAdapter.js +1 -1
- package/support/revision.js +1 -1
- package/views/2d/engine/imagery/RasterVFDisplayObject.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/shaders/raster/RasterRangeHighlightShader.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/shaders/raster/processor/MaskShader.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/shaders/raster/processor/RemapShader.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/shaders/raster/processor/math.js +1 -1
- package/views/2d/layers/ImageryLayerView2D.js +1 -1
- package/views/2d/layers/ImageryTileLayerView2D.js +1 -1
- package/views/2d/layers/imagery/BaseImageryTileSubView2D.js +1 -1
- package/views/2d/layers/imagery/ImageryTileView2D.js +1 -1
- package/views/2d/layers/imagery/ImageryView2D.js +1 -1
- package/views/2d/layers/imagery/VectorFieldTileView2D.js +1 -1
- package/views/2d/layers/imagery/VectorFieldView2D.js +1 -1
- package/views/3d/layers/ImageryTileLayerView3D.js +1 -1
- package/views/3d/layers/IntegratedMesh3DTilesLayerView3D.js +1 -1
- package/views/3d/layers/graphics/Graphics3DMeshFillSymbolLayer.js +1 -1
- package/views/3d/webgl-engine/collections/Component/Material/ComponentTechniqueConfiguration.js +1 -1
- package/views/3d/webgl-engine/core/shaderLibrary/ShaderOutput.js +1 -1
- package/views/3d/webgl-engine/lib/TextureBackedBuffer/TextureBackedBufferLayout.js +1 -1
- package/views/3d/webgl-engine/lib/TextureBackedBuffer/TextureBufferView.js +1 -1
- package/views/3d/webgl-engine/materials/ColorMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/DrawParameters.js +1 -1
- package/views/3d/webgl-engine/materials/HUDMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/ImageMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/LineMarkerMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/NativeLineMaterial.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/materials/WaterMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/renderers/Instance.js +1 -1
- package/views/3d/webgl-engine/materials/renderers/MergedBuffer.js +1 -1
- package/views/3d/webgl-engine/materials/renderers/PerBufferData.js +1 -1
- package/views/3d/webgl-engine/materials/renderers/PerOriginData.js +1 -1
- package/views/3d/webgl-engine/materials/renderers/VaoRenderer.js +1 -1
- package/views/3d/webgl-engine/materials/renderers/VaoWriter.js +1 -1
- package/views/DOMContainer.js +1 -1
- package/views/GroundView.js +1 -1
- package/views/layers/ImageryLayerViewMixin.js +1 -1
- package/views/layers/ImageryTileLayerViewMixin.js +1 -1
- package/views/support/imageReprojection.js +1 -1
- package/widgets/BatchAttributeForm.js +1 -1
- package/widgets/BuildingExplorer/BuildingExplorerViewModel.js +1 -1
- package/widgets/CoordinateConversion/CoordinateConversionViewModel.js +1 -1
- package/widgets/CoordinateConversion.js +1 -1
- package/widgets/DirectLineMeasurement3D.js +1 -1
- package/widgets/DistanceMeasurement2D.js +1 -1
- package/widgets/Editor/EditorViewModel.js +1 -1
- package/widgets/Editor.js +1 -1
- package/widgets/ElevationProfile.js +1 -1
- package/widgets/Feature.js +1 -1
- package/widgets/FeatureForm/FeatureFormViewModel.js +1 -1
- package/widgets/FeatureForm.js +1 -1
- package/widgets/FeatureTable/FeatureTableViewModel.js +1 -1
- package/widgets/FeatureTable/Grid/GridViewModel.js +1 -1
- package/widgets/FeatureTable/support/GroupColumnTemplate.js +1 -1
- package/widgets/FeatureTable/support/TableTemplate.js +1 -1
- package/widgets/FeatureTable.js +1 -1
- package/widgets/FeatureTemplates.js +1 -1
- package/widgets/Legend/support/ActiveLayerInfo.js +1 -1
- package/widgets/Legend.js +1 -1
- package/widgets/LineOfSight.js +1 -1
- package/widgets/Locate.js +1 -1
- package/widgets/OrientedImageryViewer/galleryUtils.js +1 -1
- package/widgets/OrientedImageryViewer/services/DepthImageService.js +1 -1
- package/widgets/PanoramicViewer/support/importUtils.js +1 -1
- package/widgets/Print.js +1 -1
- package/widgets/ScaleBar.js +1 -1
- package/widgets/ScaleRangeSlider.js +1 -1
- package/widgets/Search/SearchResultRenderer.js +1 -1
- package/widgets/Search/SearchViewModel.js +1 -1
- package/widgets/Search/types.js +1 -1
- package/widgets/Search.js +1 -1
- package/widgets/ShadowCast.js +1 -1
- package/widgets/Sketch/SketchViewModel.js +1 -1
- package/widgets/Sketch.js +1 -1
- package/assets/esri/core/workers/chunks/1f6ead46b723630db897.js +0 -1
- package/assets/esri/core/workers/chunks/3a16347e17312556e02c.js +0 -1
- package/assets/esri/core/workers/chunks/478def691ae6763686f3.js +0 -1
- package/assets/esri/core/workers/chunks/4c4a55be41ba105c091c.js +0 -1
- package/assets/esri/core/workers/chunks/4cbf5a97b2b3c6553f6f.js +0 -1
- package/assets/esri/core/workers/chunks/646f58b69d2354f1ef27.js +0 -1
- package/assets/esri/core/workers/chunks/93d11075f65a5b6625ea.js +0 -1
- package/assets/esri/core/workers/chunks/9f2a8445a5848502c7e7.js +0 -1
- package/assets/esri/core/workers/chunks/a1b08aab73747f4e7e25.js +0 -1
- package/assets/esri/core/workers/chunks/ba59568e748f0ba53b78.js +0 -1
- package/assets/esri/core/workers/chunks/f21cb5b34d4d1e3af1a9.js +0 -1
- package/assets/esri/core/workers/chunks/f93f0586ce10cb5d98b3.js +0 -1
- package/layers/support/rasterDatasets/BaseRaster.js +0 -5
- package/layers/support/rasterDatasets/CovJSONRaster.js +0 -5
- package/layers/support/rasterDatasets/FunctionRaster.js +0 -5
- package/layers/support/rasterDatasets/ImageAuxRaster.js +0 -5
- package/layers/support/rasterDatasets/ImageServerRaster.js +0 -5
- package/layers/support/rasterDatasets/InMemoryRaster.js +0 -5
- package/layers/support/rasterDatasets/MRFRaster.js +0 -5
- package/layers/support/rasterDatasets/RawBlockCache.js +0 -5
- package/layers/support/rasterDatasets/TIFFRaster.js +0 -5
- package/layers/support/rasterDatasets/WCSRaster.js +0 -5
- package/layers/support/rasterDatasets/covJSONParser.js +0 -5
- package/layers/support/rasterDatasets/multidimensionalUtils.js +0 -5
- package/layers/support/rasterDatasets/pamParser.js +0 -5
- package/layers/support/rasterDatasets/pixelReader.js +0 -5
- package/layers/support/rasterDatasets/wcsCoverageParser.js +0 -5
- package/layers/support/rasterFormats/Lerc.js +0 -5
- package/layers/support/rasterFormats/Qb3.js +0 -5
- package/layers/support/rasterFormats/RasterCodec.js +0 -5
- package/layers/support/rasterFormats/TiffDecoder.js +0 -5
- package/layers/support/rasterFunctions/ArithmeticFunction.js +0 -5
- package/layers/support/rasterFunctions/BandArithmeticFunction.js +0 -5
- package/layers/support/rasterFunctions/BaseRasterFunction.js +0 -5
- package/layers/support/rasterFunctions/ColormapFunction.js +0 -5
- package/layers/support/rasterFunctions/ColormapToRGBFunction.js +0 -5
- package/layers/support/rasterFunctions/CompositeBandFunction.js +0 -5
- package/layers/support/rasterFunctions/CompositeBandFunctionArguments.js +0 -5
- package/layers/support/rasterFunctions/ComputeChangeFunction.js +0 -5
- package/layers/support/rasterFunctions/ConvolutionFunction.js +0 -5
- package/layers/support/rasterFunctions/ConvolutionFunctionArguments.js +0 -5
- package/layers/support/rasterFunctions/HillshadeFunction.js +0 -5
- package/layers/support/rasterFunctions/LocalFunction.js +0 -5
- package/layers/support/rasterFunctions/RemapFunction.js +0 -5
- package/layers/support/rasterFunctions/ShadedReliefFunction.js +0 -5
- package/layers/support/rasterFunctions/SlopeFunction.js +0 -5
- package/layers/support/rasterFunctions/StatisticsFunction.js +0 -5
- package/layers/support/rasterFunctions/StretchFunction.js +0 -5
- package/layers/support/rasterFunctions/bandIndexUtils.js +0 -5
- package/layers/support/rasterFunctions/changeDetectionUtils.js +0 -5
- package/layers/support/rasterFunctions/clipUtils.js +0 -5
- package/layers/support/rasterFunctions/conversionUtils.js +0 -5
- package/layers/support/rasterFunctions/convolutionUtils.js +0 -5
- package/layers/support/rasterFunctions/creators/createDataManagementFunctions.js +0 -5
- package/layers/support/rasterFunctions/creators/utils.js +0 -5
- package/layers/support/rasterFunctions/focalStatUtils.js +0 -5
- package/layers/support/rasterFunctions/localUtils.js +0 -5
- package/layers/support/rasterFunctions/pixelTransformUtils.js +0 -5
- package/layers/support/rasterFunctions/pixelUtils.js +0 -5
- package/layers/support/rasterFunctions/stretchUtils.js +0 -5
- package/layers/support/rasterFunctions/surfaceUtils.js +0 -5
- package/layers/support/rasterFunctions/vectorFieldUtils.js +0 -5
- package/layers/support/rasterTransforms/BaseRasterTransform.js +0 -5
- /package/assets/esri/layers/{support/rasterFormats → raster/formats}/lerc-wasm.wasm +0 -0
- /package/assets/esri/layers/{support/rasterFormats → raster/formats}/qb3-wasm.wasm +0 -0
- /package/layers/{support/rasterDatasets → raster/datasets}/DBFParser.js +0 -0
- /package/layers/{support/rasterDatasets → raster/datasets}/EphemeralBlockCache.js +0 -0
- /package/layers/{support/rasterDatasets → raster/datasets}/RasterFactory.js +0 -0
- /package/layers/{support/rasterDatasets → raster/datasets}/byteStreamUtils.js +0 -0
- /package/layers/{support/rasterDatasets → raster/datasets}/datasetUtils.js +0 -0
- /package/layers/{support/rasterDatasets → raster/datasets}/multipartParser.js +0 -0
- /package/layers/{support/rasterDatasets → raster/datasets}/wcsCapabilitiesParser.js +0 -0
- /package/layers/{support/rasterDatasets → raster/datasets}/xmlUtilities.js +0 -0
- /package/layers/{support/rasterFormats → raster/formats}/ImageCanvasDecoder.js +0 -0
- /package/layers/{support/rasterFormats → raster/formats}/JpgPlus.js +0 -0
- /package/layers/{support/rasterFormats → raster/formats}/Lzw.js +0 -0
- /package/layers/{support/rasterFormats → raster/formats}/Raw.js +0 -0
- /package/layers/{support/rasterFormats → raster/formats}/pixelRangeUtils.js +0 -0
- /package/layers/{support/rasterFormats → raster/formats}/tiffTag.js +0 -0
- /package/layers/{support/rasterFormats → raster/formats}/utils.js +0 -0
- /package/layers/{support/rasterFunctions → raster/functions}/colormaps.js +0 -0
- /package/layers/{support/rasterFunctions → raster/functions}/creators/createAppearenceFunctions.js +0 -0
- /package/layers/{support/rasterFunctions → raster/functions}/creators/createBandIndexFunctions.js +0 -0
- /package/layers/{support/rasterFunctions → raster/functions}/creators/createChangeFunctions.js +0 -0
- /package/layers/{support/rasterFunctions → raster/functions}/creators/createConversionFunctions.js +0 -0
- /package/layers/{support/rasterFunctions → raster/functions}/creators/createLocalFunctions.js +0 -0
- /package/layers/{support/rasterFunctions → raster/functions}/creators/createMultiRasterAnalysisFunctions.js +0 -0
- /package/layers/{support/rasterFunctions → raster/functions}/creators/createStatisticsFunctions.js +0 -0
- /package/layers/{support/rasterFunctions → raster/functions}/creators/createSurfaceFunctions.js +0 -0
- /package/layers/{support/rasterFunctions → raster/functions}/customBandIndexUtils.js +0 -0
- /package/layers/{support/rasterFunctions → raster/functions}/mirror.js +0 -0
- /package/layers/{support/rasterFunctions → raster/functions}/rasterFunctionHelper.js +0 -0
- /package/layers/{support/rasterFunctions → raster/functions}/rasterFunctionSchema.js +0 -0
- /package/layers/{support/rasterFunctions → raster/functions}/rasterProjectionHelper.js +0 -0
- /package/layers/{support/rasterTransforms → raster/transforms}/utils.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/5.0/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{__decorate as e}from"tslib";import t from"../../../../../core/Accessor.js";import{removeUnordered as
|
|
5
|
+
import{__decorate as e}from"tslib";import t from"../../../../../core/Accessor.js";import{removeUnordered as n,filterInPlace as s}from"../../../../../core/arrayUtils.js";import"../../../../../core/has.js";import{getOrCreateMapValue as r}from"../../../../../core/MapUtils.js";import{NestedMap as o}from"../../../../../core/NestedMap.js";import a from"../../../../../core/PooledArray.js";import{nullUid as l}from"../../../../../core/uid.js";import{property as i,subclass as u}from"../../../../../core/accessorSupport/decorators.js";import{assert as c}from"../../lib/Util.js";import{BufferRange as d,mergeAdjacentRanges as f}from"./BufferRange.js";import{Instance as h}from"./Instance.js";import{PerBaseInstanceData as m}from"./PerBaseInstanceData.js";import{PerBufferData as p,getTargetBuffer as g,hasVao as y}from"./PerBufferData.js";import{PerOriginData as v}from"./PerOriginData.js";import{VaoWriter as x}from"./VaoWriter.js";let _=class extends t{constructor(e){super(e),this._vaoWriter=null,this._useMetalWorkaround=!1,this._hasOccludees=!1}destroy(){this.uninitializeRenderContext()}initializeRenderContext(e){this._useMetalWorkaround=e.renderContext.rctx.isAssumedMetalDriver,this._vaoWriter=new x(this.material,e.renderContext.rctx)}uninitializeRenderContext(){this._useMetalWorkaround=!1,this._vaoWriter=null}get hasOccludees(){return this._hasOccludees}modify(e,t){this._applyUpdates(e,t),this._applyAddsAndRemoves(e),this._updateDrawCommands()}get canCompact(){for(const e of this.dataByBaseInstance.values())for(const t of e.dataByOrigin.values())if(t.buffers.some(e=>e.holesVertex.length>1))return!0;return!1}compact(e){if(!this.canCompact)return!1;let t=!1;for(const s of this.dataByBaseInstance.values())for(const r of s.dataByOrigin.values()){const o=new Array;for(let t=0;t<r.buffers.length&&!e.done;){const s=r.buffers[t];s.holesVertex.length<=1?++t:(s.instances.forEach(({geometry:e})=>o.push(e)),this._vaoWriter?.deleteBuffer(s),n(r.buffers,s,void 0,{last:t}),e.madeProgress())}if(o.length>0){const{baseInstanceData:e}=s;r.buffers.forEach(t=>this._applyAdds(e,t,o));const n=g(null!=e);for(;o.length>0;)r.buffers.push(this._applyAndRebuild(e,new p(n),o,null));t=!0}}return t}updateHighlights(e){this.highlightOrderMap=e;for(const t of this.dataByBaseInstance.values())for(const n of t.dataByOrigin.values())for(const t of n.buffers)t.updateHighlights(e)}_applyUpdates(e,t){const s=this._vaoWriter;if(null==s)return void e.clearUpdates();let r;const o=this._useMetalWorkaround?(e,t)=>{r??=new Map;let n=r.get(t);n||(n=[],r.set(t,n)),n.push(e)}:(e,t)=>s.updateInstance(e,t);for(const a of e.updates){if(t.done)return;const{renderGeometry:s,updateType:r}=a;n(e.pending.updates,a),t.madeProgress();const i=this.dataByBaseInstance.get(s.geometry.baseGeometry?.id??l),u=i?.dataByOrigin.get(s.localOrigin.id)?.findBuffer(s.id);if(null==u)return;const c=u.instances.get(s.id);6&r&&o(c,u),25&r&&(u.drawCommandsDirty=!0)}r&&s.updateInstancesMetal(r)}_computeDeltas(e,t){const n=new Map;for(const s of e){const e=s.localOrigin;if(null==e)continue;const t=s.geometry.baseGeometry,o=r(n,t??null,E);let a=o.get(e,null);null==a&&(a=new B(e.vec3,t),o.set(e,null,a)),a.changes.push(s)}for(const s of t){const e=s.localOrigin;if(null==e)continue;const t=s.geometry.baseGeometry,o=this.dataByBaseInstance.get(t?.id??l),a=o?.dataByOrigin.get(e.id)?.findBuffer(s.id);if(null==a)continue;const i=r(n,t??null,E);let u=i.get(e,a);null==u&&(u=new B(e.vec3,t),i.set(e,a,u)),u.changes.push(s)}return n}_applyAddsAndRemoves(e){const{_vaoWriter:t,dataByBaseInstance:s}=this;if(null==t)return void e.clearAddsAndRemoves();const o=this._computeDeltas(e.adds,e.removes);for(const[a,i]of o){const e=r(s,a?.id??l,()=>new m(t.createBaseInstanceData(a))),o=null!=a;for(const[s,a]of i.outerMap()){const l=a.get(null),u=l?.changes??[];i.delete(s,null);const d=r(e.dataByOrigin,s.id,()=>new v(s.vec3,o));for(const[r,o]of a){if(i.delete(s,r),null==r&&c(!1,"No VAO for removed geometries"),r.instances.size===o.changes.length){t.deleteBuffer(r),n(d.buffers,r),0===d.buffers.length&&0===u.length&&e.dataByOrigin.delete(s.id);continue}const a=r.numElementsVertex;switch(t.evaluateBufferAllocation(a,u,o.changes,r)){case 0:o.changes.forEach(({id:e})=>r.deleteInstance(e)),r.instances.forEach(({geometry:e})=>u.push(e)),t.deleteBuffer(r),n(d.buffers,r);break;case 1:this._applyAndRebuild(e.baseInstanceData,r,u,o);break;case 2:this._applyRemoves(r,o)}}if(u.length>0){const{baseInstanceData:t}=e,n=g(o);for(const e of d.buffers)this._applyAdds(t,e,u);for(;u.length>0;)d.buffers.push(this._applyAndRebuild(t,new p(n),u,null))}}0===e.dataByOrigin.size&&(e.dispose(),s.delete(e.id))}e.clearAddsAndRemoves()}_updateDrawCommands(){this._hasOccludees=!1;for(const e of this.dataByBaseInstance.values())for(const t of e.dataByOrigin.values())for(const e of t.buffers)e.updateIfDrawCommandsDirty(this.highlightOrderMap),this._hasOccludees||=e.hasOccludees}_applyAndRebuild(e,t,n,s){if(s)for(const c of s.changes)t.deleteInstance(c.id);const r=this._vaoWriter,o=r.maxElements(t.targetBuffer),a=r.maxElements("texture");let l=t.numElementsVertex,i=t.numElementsTexture;for(;n.length>0;){const e=n.pop(),s=r.vertexElementCount(e.geometry),u=r.textureElementCount(e.geometry);if(l+s>o&&l>0||i+u>a&&i>0){n.push(e);break}l+=s,i+=u;const d=new h(e,0,0,0,0,this.highlightOrderMap);c(null==t.instances.get(e.id)),t.addInstance(e.id,d)}t.resetInstanceSummary(),t.vao=r.reallocateBuffer(e,t,l),t.textureBuffer=r.reallocateTextureBuffer(t,i),t.vaoEndElement=r.endVertexElement(t),t.textureEndElement=r.endTextureElement(t);const[u,d]=r.rebuildInstances(l,i,t.writeableInstances.values(),t);t.updateInstances(),t.holesVertex.clear();const f=t.holesVertex.pushNew(),m=t.holesTexture.pushNew();return f.from=u,f.to=t.vaoEndElement,m.from=d,m.to=t.textureEndElement,t.updateDrawCommands(this.highlightOrderMap),t}_applyRemoves(e,t){const{_vaoWriter:n}=this;if(0===t.changes.length||null==n)return;let s=1/0,r=-1/0,o=1/0,a=-1/0;for(const l of t.changes){const t=l.id,n=e.instances.get(t);if(!n)continue;const{vertexBufferRange:i,textureBufferRange:u}=n;e.deleteInstance(t),this._useMetalWorkaround&&(s=Math.min(s,i.from),r=Math.max(r,i.to),o=Math.min(o,u.from),a=Math.max(a,u.to));const c=b.back();if(c&&c.to===i.from)c.to=i.to;else if(c&&c.from===i.to)c.from=i.from;else{const e=b.pushNew();e.from=i.from,e.to=i.to}const d=M.back();if(d&&d.to===u.from)d.to=u.to;else if(d&&d.from===u.to)d.from=u.from;else{const e=M.pushNew();e.from=u.from,e.to=u.to}}f(b),f(M),this._useMetalWorkaround?n.clearHolesMetal(e.instances.values(),s,r,o,a,e):(n.clearVertexHoles(b,e),n.clearTextureHoles(M,e)),e.holesVertex.pushArray(b.data,b.length),e.holesTexture.pushArray(M.data,M.length),b.forAll((e,t)=>b.data[t]=null),b.clear(),M.forAll((e,t)=>b.data[t]=null),M.clear(),e.drawCommandsDirty=!0}_applyAdds(e,t,n){if(0===n.length||null==this._vaoWriter)return;if(!y(t))return void this._applyAndRebuild(e,t,n,null);const r=this._vaoWriter,o=t.numElementsVertex,a=n.reduce((e,{geometry:t})=>e+r.vertexElementCount(t),0),l=Math.min(o+a,r.maxElements(t.targetBuffer)),i=t.numElementsTexture,u=n.reduce((e,{geometry:t})=>e+r.textureElementCount(t),0),c=Math.min(i+u,r.maxElements("texture"));if(r.canGrow(t,l,c))return void this._applyAndRebuild(e,t,n,null);f(t.holesVertex),f(t.holesTexture);const d=new Array,h=new Array;let m=1/0,p=-1/0,g=1/0,v=-1/0;for(const{geometry:s}of n){const e=r.vertexElementCount(s),n=r.textureElementCount(s),o=w(t.holesVertex,e),a=w(t.holesTexture,n);null!=o&&null!=a?(d.push(o),h.push(a),this._useMetalWorkaround&&(m=Math.min(m,o),p=Math.max(p,o+e),g=Math.min(g,a),v=Math.max(v,a+n))):(d.push(null),h.push(null))}const x=this._addInstances(n,t,d,h);if(this._useMetalWorkaround){for(const e of x);r.writeInstanceRangeMetal(p,m,v,g,t.instances.values(),t)}else r.writeRandomInstances(l,c,x,t);s(n,(e,t)=>null==d[t]||null==h[t])}*_addInstances(e,t,n,s){const r=e.length,o=this._vaoWriter;for(let a=0;a<r;++a){const r=n[a],l=s[a];if(null==r||null==l)continue;const i=e[a],u=o.vertexElementCount(i.geometry),d=o.textureElementCount(i.geometry),f=new h(i,r,r+u,l,l+d,this.highlightOrderMap);c(null==t.instances.get(i.id)),t.addInstance(i.id,f),t.drawCommandsDirty=!0,yield f}}static prune(){x.prune()}get test(){}};e([i({constructOnly:!0})],_.prototype,"dataByBaseInstance",void 0),e([i({constructOnly:!0})],_.prototype,"material",void 0),e([i()],_.prototype,"highlightOrderMap",void 0),_=e([u("esri.views.3d.webgl-engine.materials.renderers.MergedBuffer")],_);class B{constructor(e,t){this.origin=e,this.baseInstance=t,this.changes=new Array}}function w(e,t){if(0===t)return 0;const n=e.find(e=>e.numElements>=t);if(null==n)return null;const s=n.from;return n.from+=t,n.numElements<=0&&e.removeUnordered(n),s}const b=new a({allocator:e=>e??new d,deallocator:null}),M=new a({allocator:e=>e??new d,deallocator:null});function E(){return new o}export{_ as MergedBuffer};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright Esri, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/5.0/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{getOrCreateMapValue as
|
|
5
|
+
import{getOrCreateMapValue as t}from"../../../../../core/MapUtils.js";import e from"../../../../../core/PooledArray.js";import{BufferRange as s}from"./BufferRange.js";import{DrawCommand as n}from"./DrawCommand.js";import{InstancedCommandVAO as a}from"./InstancedCommandVAO.js";import{InstancedCommandVAOs as i}from"./InstancedCommandVAOs.js";import{defaultHighlightName as r}from"../../../../support/HighlightDefaults.js";class o{constructor(t){this.targetBuffer=t,this.vao=null,this.textureBuffer=null,this.vaoEndElement=0,this.textureEndElement=0,this._numElementsVertex=0,this._numElementsTexture=0,this._instances=new Map,this.holesVertex=new e({allocator:t=>t??new s,deallocator:null}),this.holesTexture=new e({allocator:t=>t??new s,deallocator:null}),this.hasHiddenInstances=!1,this.hasOccludees=!1,this.drawCommandsDirty=!0,this.highlightNames=new Set,this.drawCommandsDefault=d(),this.drawCommandsHighlights=new Map,this.drawCommandsOccludees=d(),this.drawCommandsShadowHighlightRest=d(),this._instancedCommandVAOs=null}get numElementsVertex(){return this._numElementsVertex}get numElementsTexture(){return this._numElementsTexture}get instances(){return this._instances}get writeableInstances(){return this._instances}get hasHighlights(){return this.highlightNames.size>0}get instancedCommandVAOs(){return this._instancedCommandVAOs}resetInstanceSummary(){this.hasHiddenInstances=!1,this.hasOccludees=!1,this.highlightNames.clear()}updateIfDrawCommandsDirty(t){if(this.drawCommandsDirty){this.resetInstanceSummary();for(const t of this.instances.values())this.updateDrawState(t);this.updateDrawCommands(t)}}addInstance(t,e){this.deleteInstance(t),this._instances.set(t,e),this._numElementsVertex+=e.vertexBufferRange.numElements,this._numElementsTexture+=e.textureBufferRange.numElements}deleteInstance(t){const e=this._instances.get(t);e&&(this._numElementsVertex-=e.vertexBufferRange.numElements,this._numElementsTexture-=e.textureBufferRange.numElements,this._instances.delete(t))}updateInstances(){let t=0,e=0;for(const s of this._instances.values())t+=s.vertexBufferRange.numElements,e+=s.textureBufferRange.numElements,this.updateDrawState(s);this._numElementsVertex=t,this._numElementsTexture=e}updateDrawState(t){if(t.isVisible){const{highlightName:e}=t;e&&this.highlightNames.add(e),t.hasOccludees&&(this.hasOccludees=!0)}else this.hasHiddenInstances=!0}updateDrawCommands(t){this._updateDrawCommands(t),this._updateInstancedCommandVAOs()}_updateDrawCommands(t){if(this.drawCommandsDefault.clear(),this.drawCommandsOccludees.clear(),this.drawCommandsDirty=!1,0===this._instances.size)return;const{sortedInstances:e}=this;if(this._updateHighlightDrawCommands(t,e),!this.needsMultipleCommands){const t=this.drawCommandsDefault.pushNew(),e=this.holesVertex.front();return this.vao&&1===this.holesVertex.length&&e.to===this.vaoEndElement?(t.first=0,void(t.count=e.from)):(t.first=1/0,t.count=0,this._instances.forEach(e=>{t.first=Math.min(t.first,e.vertexBufferRange.from),t.count=Math.max(t.count,e.vertexBufferRange.to)}),void(t.count-=t.first))}for(const s of e)s.isVisible&&u(s.hasOccludees?this.drawCommandsOccludees:this.drawCommandsDefault,s)}get sortedInstances(){return Array.from(this._instances.values()).sort(({vertexBufferRange:t},{vertexBufferRange:e})=>t.from===e.from?t.to-e.to:t.from-e.from)}updateHighlights(t){this.highlightNames.clear();const e=this.sortedInstances;for(const s of e)s.updateHighlightOptions(t),s.isVisible&&s.highlightName&&this.highlightNames.add(s.highlightName);this._updateHighlightDrawCommands(t,e),this._updateInstancedCommandVAOs()}_updateHighlightDrawCommands(e,s){const{drawCommandsHighlights:n,drawCommandsShadowHighlightRest:a}=this;n.clear(),a.clear();for(const i of s){if(i.updateHighlightOptions(e),!i.isVisible)continue;const{highlightName:s}=i;if(s){this.highlightNames.add(s);u(t(n,s,d),i)}s&&s===r||u(a,i)}}_updateInstancedCommandVAOs(){const t=this.vao;if("geometry"===this.targetBuffer||null==t)return;this._instancedCommandVAOs??=new i;const e=this._instancedCommandVAOs,s=e.commandVAOs.copy();e.clear();const n=e.commandVAOs,r=(e,i)=>{for(const r of e){const{first:e,count:o}=r,h=n.get(e,o)??s.pop(e,o)??new a(t.shallowCloneWithBaseInstances(new Map([["instances",r.first]])),r.count);n.set(e,o,h),i.push(h)}};r(this.drawCommandsDefault,e.drawCommandsDefault);for(const[a,i]of this.drawCommandsHighlights){const t=new Array;r(i,t),e.drawCommandsHighlights.set(a,t)}r(this.drawCommandsOccludees,e.drawCommandsOccludees),r(this.drawCommandsShadowHighlightRest,e.drawCommandsShadowHighlightRest);for(const a of s.values())a.dispose();s.clear()}get needsMultipleCommands(){return this.hasOccludees||this.hasHighlights||this.hasHiddenInstances}}function h(t){return null!=t.vao}function m(t){return t?"instances":"geometry"}function d(){return new e({allocator:t=>t||new n,deallocator:t=>t})}function u(t,{vertexBufferRange:e}){const s=t.back();if(null==s){const s=t.pushNew();return s.first=e.from,void(s.count=e.numElements)}if(l(s,e)){const t=e.from-s.first+e.numElements;s.count=t}else{const s=t.pushNew();s.first=e.from,s.count=e.numElements}}function l(t,e){return t.first+t.count>=e.from}export{o as PerBufferData,m as getTargetBuffer,h as hasVao};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright Esri, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/5.0/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
class s{constructor(s,e){this.origin=s,this.isInstanced=e,this.buffers=new Array}dispose(){if(this.isInstanced)for(const s of this.buffers)s.vao.buffer("instances")?.dispose(),s.vao.disposeVAOOnly(),s.instancedCommandVAOs?.dispose();else for(const s of this.buffers)s.vao.dispose();this.buffers.length=0}findBuffer(s){return this.buffers.find(e=>e.instances.has(s))}}export{s as PerOriginData};
|
|
5
|
+
class s{constructor(s,e){this.origin=s,this.isInstanced=e,this.buffers=new Array}dispose(){if(this.isInstanced)for(const s of this.buffers)s.vao.buffer("instances")?.dispose(),s.vao.disposeVAOOnly(),s.instancedCommandVAOs?.dispose(),s.textureBuffer?.dispose();else for(const s of this.buffers)s.vao.dispose(),s.textureBuffer?.dispose();this.buffers.length=0}findBuffer(s){return this.buffers.find(e=>e.instances.has(s))}}export{s as PerOriginData};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright Esri, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/5.0/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{__decorate as t}from"tslib";import e from"../../../../../core/Accessor.js";import"../../../../../core/has.js";import{disposeMaybe as s}from"../../../../../core/maybe.js";import{property as i,subclass as a}from"../../../../../core/accessorSupport/decorators.js";import{GLMaterials as r}from"../../lib/GLMaterials.js";import{DrawParameters as n}from"../DrawParameters.js";import{defaultHighlightName as o}from"../../../../support/HighlightDefaults.js";let h=class extends e{constructor(t){super(t),this._glMaterials=null,this._drawParameters=new n,this._highlightNames=new Set,this._produces=new Map}initialize(){this._updateProduces()}destroy(){this.uninitializeRenderContext()}get _hasHighlights(){return this._highlightNames.size>0}hasHighlight(t){return this._highlightNames.has(t)}get produces(){return this._produces}_updateProduces(){this.material.produces.forEach((t,e)=>{this._produces.set(e,e=>!(0===this.dataByBaseInstance.size||!(8!==e&&4!==e||this._hasHighlights))&&t(e))})}initializeRenderContext(t){this._glMaterials=new r(this.material,t.materials)}uninitializeRenderContext(){this._glMaterials=s(this._glMaterials)}acquireTechniques(t){if(!this.material.shouldRender(t))return null;const{output:e,bind:s}=t,i=this.material.produces.get(s.slot);if(!i?.(e))return null;const{highlight:a,slot:r}=s,n=4===e,h=8===e,l=h||n,d=a?.name;if(l&&(0===this._highlightNames.size||h&&d&&!this._highlightNames.has(d)))return null;const u=t=>h&&!!d&&!t.has(d),c=5===e,g=!(l||c);for(const m of this.dataByBaseInstance.values())for(const i of m.dataByOrigin.values())for(const a of i.buffers){if(u(a.highlightNames))continue;const i=n?a.drawCommandsHighlights.get(o):l?d?a.drawCommandsHighlights.get(d):a.drawCommandsHighlights.size>0:((c&&a.needsMultipleCommands?a.drawCommandsShadowHighlightRest:a.drawCommandsDefault)||null)?.length??!1,h=g&&a.drawCommandsOccludees||null;if(i||h?.length){const i=this._glMaterials.load(t.rctx,r,e),a=i?.beginSlot(s);if(a)return a}}return null}render(t,e){const{output:s,bind:i}=t,{highlight:a}=i,r=8===s,n=a?.name??"";if(r&&!a)return;const h=4===s,g=r||h,m=5===s,w=!(g||m),{rctx:_}=t;_.runAppleAmdDriverHelper();const C=_.bindTechnique(e,i,this.material.parameters);for(const b of this.dataByBaseInstance.values()){const{baseInstanceData:t}=b,s=null!=t,a=s?c:u,y=s?d:l;for(const l of b.dataByOrigin.values()){this._drawParameters.origin=l.origin;for(const s of l.buffers){if(r&&(!s.hasHighlights||!s.drawCommandsHighlights.has(n)))continue;if(h&&(!s.hasHighlights||!s.drawCommandsHighlights.has(o)))continue;const l=y(s),d=f(l,s.needsMultipleCommands,n,h,g,m),u=p(l,w);(d?.length||u?.length)&&(C.bindDraw(i,this.material.parameters,this._drawParameters),a(_,s,t,e,d,u,i))}}}}updateHighlights(){const{_highlightNames:t}=this;t.clear();for(const e of this.dataByBaseInstance.values())for(const s of e.dataByOrigin.values())for(const e of s.buffers)for(const s of e.highlightNames)t.add(s);this._updateProduces()}get test(){}};t([i({constructOnly:!0})],h.prototype,"material",void 0),t([i({constructOnly:!0})],h.prototype,"dataByBaseInstance",void 0),h=t([a("esri.views.3d.webgl-engine.materials.renderers.VaoRenderer")],h);const l=t=>t,d=t=>t.instancedCommandVAOs,u=(t,{vao:e},s,i,a,r,n)=>{i.ensureAttributeLocations(e),t.bindVAO(e),g(t,i,a,n,!1),g(t,i,r,n,!0)},c=(t,e,{baseCommand:s},i,a,r,n)=>{m(t,i,s,a,n,!1),m(t,i,s,r,n,!0)};function g(t,e,s,i,a){if(s?.length){t.setPipelineState(e.getPipeline(i,a));for(const i of s)t.drawArrays(e.primitiveType,i.first,i.count)}}function m(t,e,{first:s,count:i},a,r,n){if(a?.length){t.setPipelineState(e.getPipeline(r,n));for(const{vao:r,instanceCount:n}of a)e.ensureAttributeLocations(r),t.bindVAO(r),t.drawArraysInstanced(e.primitiveType,s,i,n)}}function f(t,e,s,i,a,r){const n=a&&!i?t.drawCommandsHighlights.get(s)??null:null;return i?t.drawCommandsHighlights.get(o):a?n:r&&e?t.drawCommandsShadowHighlightRest:t.drawCommandsDefault}function p(t,e){return e&&t.drawCommandsOccludees||null}export{h as VaoRenderer};
|
|
5
|
+
import{__decorate as t}from"tslib";import e from"../../../../../core/Accessor.js";import"../../../../../core/has.js";import{disposeMaybe as s}from"../../../../../core/maybe.js";import{property as i,subclass as a}from"../../../../../core/accessorSupport/decorators.js";import{GLMaterials as r}from"../../lib/GLMaterials.js";import{DrawParameters as n}from"../DrawParameters.js";import{defaultHighlightName as o}from"../../../../support/HighlightDefaults.js";let h=class extends e{constructor(t){super(t),this._glMaterials=null,this._drawParameters=new n,this._highlightNames=new Set,this._produces=new Map}initialize(){this._updateProduces()}destroy(){this.uninitializeRenderContext()}get _hasHighlights(){return this._highlightNames.size>0}hasHighlight(t){return this._highlightNames.has(t)}get produces(){return this._produces}_updateProduces(){this.material.produces.forEach((t,e)=>{this._produces.set(e,e=>!(0===this.dataByBaseInstance.size||!(8!==e&&4!==e||this._hasHighlights))&&t(e))})}initializeRenderContext(t){this._glMaterials=new r(this.material,t.materials)}uninitializeRenderContext(){this._glMaterials=s(this._glMaterials)}acquireTechniques(t){if(!this.material.shouldRender(t))return null;const{output:e,bind:s}=t,i=this.material.produces.get(s.slot);if(!i?.(e))return null;const{highlight:a,slot:r}=s,n=4===e,h=8===e,l=h||n,d=a?.name;if(l&&(0===this._highlightNames.size||h&&d&&!this._highlightNames.has(d)))return null;const u=t=>h&&!!d&&!t.has(d),c=5===e,g=!(l||c);for(const m of this.dataByBaseInstance.values())for(const i of m.dataByOrigin.values())for(const a of i.buffers){if(u(a.highlightNames))continue;const i=n?a.drawCommandsHighlights.get(o):l?d?a.drawCommandsHighlights.get(d):a.drawCommandsHighlights.size>0:((c&&a.needsMultipleCommands?a.drawCommandsShadowHighlightRest:a.drawCommandsDefault)||null)?.length??!1,h=g&&a.drawCommandsOccludees||null;if(i||h?.length){const i=this._glMaterials.load(t.rctx,r,e),a=i?.beginSlot(s);if(a)return a}}return null}render(t,e){const{output:s,bind:i}=t,{highlight:a}=i,r=8===s,n=a?.name??"";if(r&&!a)return;const h=4===s,g=r||h,m=5===s,w=!(g||m),{rctx:_}=t;_.runAppleAmdDriverHelper();const C=_.bindTechnique(e,i,this.material.parameters);for(const b of this.dataByBaseInstance.values()){const{baseInstanceData:t}=b,s=null!=t,a=s?c:u,y=s?d:l;for(const l of b.dataByOrigin.values()){this._drawParameters.origin=l.origin;for(const s of l.buffers){if(r&&(!s.hasHighlights||!s.drawCommandsHighlights.has(n)))continue;if(h&&(!s.hasHighlights||!s.drawCommandsHighlights.has(o)))continue;this._drawParameters.textureBuffer=s.textureBuffer?.texture;const l=y(s),d=f(l,s.needsMultipleCommands,n,h,g,m),u=p(l,w);(d?.length||u?.length)&&(C.bindDraw(i,this.material.parameters,this._drawParameters),a(_,s,t,e,d,u,i)),this._drawParameters.textureBuffer=null}}}}updateHighlights(){const{_highlightNames:t}=this;t.clear();for(const e of this.dataByBaseInstance.values())for(const s of e.dataByOrigin.values())for(const e of s.buffers)for(const s of e.highlightNames)t.add(s);this._updateProduces()}get test(){}};t([i({constructOnly:!0})],h.prototype,"material",void 0),t([i({constructOnly:!0})],h.prototype,"dataByBaseInstance",void 0),h=t([a("esri.views.3d.webgl-engine.materials.renderers.VaoRenderer")],h);const l=t=>t,d=t=>t.instancedCommandVAOs,u=(t,{vao:e},s,i,a,r,n)=>{i.ensureAttributeLocations(e),t.bindVAO(e),g(t,i,a,n,!1),g(t,i,r,n,!0)},c=(t,e,{baseCommand:s},i,a,r,n)=>{m(t,i,s,a,n,!1),m(t,i,s,r,n,!0)};function g(t,e,s,i,a){if(s?.length){t.setPipelineState(e.getPipeline(i,a));for(const i of s)t.drawArrays(e.primitiveType,i.first,i.count)}}function m(t,e,{first:s,count:i},a,r,n){if(a?.length){t.setPipelineState(e.getPipeline(r,n));for(const{vao:r,instanceCount:n}of a)e.ensureAttributeLocations(r),t.bindVAO(r),t.drawArraysInstanced(e.primitiveType,s,i,n)}}function f(t,e,s,i,a,r){const n=a&&!i?t.drawCommandsHighlights.get(s)??null:null;return i?t.drawCommandsHighlights.get(o):a?n:r&&e?t.drawCommandsShadowHighlightRest:t.drawCommandsDefault}function p(t,e){return e&&t.drawCommandsOccludees||null}export{h as VaoRenderer};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright Esri, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/5.0/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{nextHighestPowerOfTwo as
|
|
5
|
+
import{nextHighestPowerOfTwo as e}from"../../../../../core/mathUtils.js";import{disposeMaybe as t}from"../../../../../core/maybe.js";import{copy as r,invert as u,transpose as a}from"../../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as f}from"../../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{glLayout as n}from"../../../support/buffer/glUtil.js";import{assert as s}from"../../lib/Util.js";import{VertexArrayObject as o}from"../../lib/VertexArrayObject.js";import{getMaxItemCount as i,getMaxByteSize as c}from"../../lib/TextureBackedBuffer/TextureBackedBufferUtils.js";import{TextureBuffer as l}from"../../lib/TextureBackedBuffer/TextureBuffer.js";import{DrawCommand as m}from"./DrawCommand.js";import{BaseInstanceData as g}from"./PerBaseInstanceData.js";import{VertexBuffer as h}from"../../../../webgl/VertexBuffer.js";class B{constructor(e,t){this._rctx=t,this._bufferWriter=e.createBufferWriter(),this._vaoCache=t.getVaoCache(n(this._bufferWriter.layout))}maxElements(e){if("texture"===e){const e=this._targetLayout("texture");return null==e?0:i(this._rctx,e)}return Math.floor(d/this._targetStrideBytes(e))}_targetStrideBytes(e){return this._targetLayout(e)?.stride??0}_targetLayout(e){return"geometry"===e?this._bufferWriter.layout:"instances"===e?this._bufferWriter.instanceLayout:this._bufferWriter.textureBufferLayout}endVertexElement(e){return Math.floor((e.vao?.getByteLength(e.targetBuffer)??0)/this._targetStrideBytes(e.targetBuffer))}endTextureElement({textureBuffer:e}){return e?.itemCount??0}evaluateBufferAllocation(e,t,r,u){const a=this._targetStrideBytes(u.targetBuffer),f=t.reduce((e,{geometry:t})=>e+this.vertexElementCount(t),0),n=r.reduce((e,{geometry:t})=>e+this.vertexElementCount(t),0),s=Math.min((e+f-n)*a,d),o=u.vao?.buffer(u.targetBuffer),i=o?.sizeBytes??0;return s>b&&s<i/2?0:s>i?1:2}deleteBuffer(e){if("instances"===e.targetBuffer)return e.instancedCommandVAOs?.dispose(),e.vao?.buffer("instances")?.dispose(),e.vao?.disposeVAOOnly(),void(e.vao=null);this._vaoCache.deleteVao(e.vao),e.vaoEndElement=0}deleteTextureBuffer(e){e.textureBuffer=t(e.textureBuffer),e.textureEndElement=0}createBaseInstanceData(e){const{_bufferWriter:t}=this;if(null==e||null==t.writeBaseInstance||null==t.elementCountBaseInstance)return null;const r=t.layout,u=t.elementCountBaseInstance(e.attributes),a=u*this._targetStrideBytes("geometry"),f=new h(this._rctx,n(r));f.setSize(Math.ceil(a));const s=S(a),o=r.createView(s.buffer);t.writeBaseInstance(e.attributes,o),f.setSubData(s,0,0,a);const i=new m;return i.first=0,i.count=u,new g(e,f,i)}_allocateInstanceBuffer(e){const t=this._bufferWriter.instanceLayout;s(null!=t,"Trying to allocate an instance buffer, but the BufferWriter does not support instancing");const r=e*this._targetStrideBytes("instances"),u=new h(this._rctx,n(t,1));return u.setSize(v(r)),u}_createInstancedVao(e,t){return new o(this._rctx,new Map([["geometry",e],["instances",t]]))}reallocateBuffer(e,t,r){if(this.deleteBuffer(t),null!=e){const t=e.baseInstanceBuffer,u=this._allocateInstanceBuffer(r);return this._createInstancedVao(t,u)}const u=r*this._targetStrideBytes("geometry");return this._vaoCache.newVao(v(u))}reallocateTextureBuffer(e,t){this.deleteTextureBuffer(e);const r=this._targetLayout("texture");return null!=r?new l(this._rctx,r,t):null}vertexElementCount(e){return this._bufferWriter.elementCount(e.attributes)}textureElementCount(e){return this._bufferWriter.elementCountTextureBuffer?.(e.attributes)??0}canGrow(e,t,r){const{targetBuffer:u,vao:a,textureBuffer:f}=e;if(null==a)return!0;const n=t*this._targetStrideBytes(u),s=a.getByteLength(u)<v(d-b)&&n>a.getByteLength(u),o=this._targetLayout("texture");if(!s||null==o||null==f)return s;const i=r*o.byteStride,l=f.byteLength;return l<c(this._rctx,o)&&i>l}clearVertexHoles(e,{vao:t,targetBuffer:r}){const u=this._targetStrideBytes(r),a=e.reduce((e,t)=>Math.max(e,t.numElements),0)*u,f=S(a);f.fill(0,0,a);const n=t.buffer(r);for(const s of e)n?.setSubData(f,s.from*u,0,s.numElements*u)}clearTextureHoles(e,{textureBuffer:t}){const r=this._targetLayout("texture");if(null==t||null==r)return;const u=r.byteStride,a=e.reduce((e,t)=>Math.max(e,t.numElements),0)*u,f=S(a);f.fill(0,0,a);for(const n of e)t.setSubData(f.buffer,n.from,0,n.numElements)}clearHolesMetal(e,t,r,u,a,{vao:f,targetBuffer:n,textureBuffer:s}){const o=this._targetLayout(n),i=this._targetStrideBytes(n),c=(r-t)*i,l=this._targetLayout("texture"),m=(a-u)*this._targetStrideBytes("texture"),g=c+m,h=c,B=S(g),y=o.createView(B.buffer),x=l?.createView(B.buffer,h);B.fill(0,0,g);for(const b of e){const{vertexBufferRange:e,textureBufferRange:a}=b;if(!(e.from>=t&&e.to<=r))continue;const f=e.from-t,n=a.from-u;this._writeGeometry(b.geometry,y,x,f,n,a)}f.buffer(n)?.setSubData(B,t*i,0,c),s?.setSubData(B.buffer,u,h,m)}writeRandomInstances(e,t,r,{vao:u,targetBuffer:a,textureBuffer:f}){const n=this._targetStrideBytes(a),s=e*n,o=t*this._targetStrideBytes("texture"),i=this._targetLayout(a),c=this._targetLayout("texture"),l=s,m=S(s+o),g=i.createView(m.buffer),h=c?.createView(m.buffer,l);let B=0,y=0,x=0,b=0,_=0,d=0;const w=u.buffer(a);for(const S of r){const{vertexBufferRange:e,textureBufferRange:t}=S;if(!(b===e.from)){const t=b-x;t>0&&w?.setSubData(m,x*n,0,t*n),x=e.from,B=0}if(!(d===t.from)&&null!=f){const e=d-_;e>0&&f.setSubData(m.buffer,_,l,e),_=t.from,y=0}this._writeGeometry(S.geometry,g,h,B,y,t),B+=e.numElements,b=e.to,y+=t.numElements,d=t.to}const v=b-x;v>0&&w?.setSubData(m,x*n,0,v*n);const p=d-_;p>0&&null!=f&&f.setSubData(m.buffer,_,l,p)}writeInstanceRangeMetal(e,t,r,u,a,{vao:f,targetBuffer:n,textureBuffer:s}){const o=this._targetLayout(n),i=this._targetStrideBytes(n),c=(e-t)*i,l=this._targetLayout("texture"),m=(r-u)*this._targetStrideBytes("texture"),g=c+m,h=c,B=S(g),y=o.createView(B.buffer),x=l?.createView(B.buffer,h);B.fill(0,0,g);for(const b of a){const{vertexBufferRange:r,textureBufferRange:a}=b;if(!(r.from>=t&&r.to<=e))continue;const f=r.from-t,n=a.from-u;this._writeGeometry(b.geometry,y,x,f,n,a)}c>0&&f.buffer(n)?.setSubData(B,t*i,0,c),m>0&&null!=s&&s.setSubData(B.buffer,u,h,m)}rebuildInstances(e,t,r,{vao:u,targetBuffer:a,textureBuffer:f}){const n=this._targetStrideBytes(a),s=e*n,o=s,i=S(s+t*this._targetStrideBytes("texture")),c=this._targetLayout(a).createView(i.buffer),l=this._targetLayout("texture")?.createView(i.buffer,o);let m=0,g=0;for(const h of r){const e=m,t=g;m+=this.vertexElementCount(h.geometry.geometry),g+=this.textureElementCount(h.geometry.geometry),h.vertexBufferRange.from=e,h.vertexBufferRange.to=m,h.textureBufferRange.from=t,h.textureBufferRange.to=g,this._writeGeometry(h.geometry,c,l,e,t,h.textureBufferRange)}return u?.buffer(a)?.setSubData(i,0,0,m*n),f?.setSubData(i.buffer,0,o,g),[m,g]}updateInstance(e,{vao:t,targetBuffer:r,textureBuffer:u}){const a=this._targetStrideBytes(r),f=this._targetStrideBytes("texture"),n=this.vertexElementCount(e.geometry.geometry)*a,s=n,o=S(n+this.textureElementCount(e.geometry.geometry)*f),i=this._targetLayout(r).createView(o.buffer),c=this._targetLayout("texture")?.createView(o.buffer,s);this._writeGeometry(e.geometry,i,c,0,0,e.textureBufferRange);const{vertexBufferRange:l,textureBufferRange:m}=e;t.buffer(r)?.setSubData(o,l.from*a,0,l.numElements*a),u?.setSubData(o.buffer,m.from,s,m.numElements)}updateInstancesMetal(e){for(const[t,r]of e){let e=1/0,u=-1/0,a=1/0,f=-1/0;for(const t of r){const{vertexBufferRange:r,textureBufferRange:n}=t;e=Math.min(e,r.from),u=Math.max(u,r.to),a=Math.min(a,n.from),f=Math.max(f,n.to)}this.writeInstanceRangeMetal(u,e,u,e,t.instances.values(),t)}}_writeGeometry(e,t,f,n,s,o){const{_bufferWriter:i}=this;null!=i&&(r(y,e.transformation),y[12]-=e.localOrigin.vec3[0],y[13]-=e.localOrigin.vec3[1],y[14]-=e.localOrigin.vec3[2],u(x,y),a(x,x),i.write(y,x,e.geometry.attributes,e.geometry.olidColor,t,n,o),null!=f&&i.writeTextureBuffer&&i.writeTextureBuffer(y,x,e.geometry.attributes,f,s))}static prune(){w=new Uint8Array(b)}}const y=f(),x=f(),b=262144,_=1024,d=16777216;let w=new Uint8Array(b);function S(e){return w.byteLength<e&&(w=new Uint8Array(e)),w}function v(t){return t<=_?_:t<b?e(t):Math.max(Math.min(Math.ceil(1.5*t/b)*b,d),t)}export{B as VaoWriter};
|
package/views/DOMContainer.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/5.0/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{__decorate as t}from"tslib";import{byId as e,reparent as i}from"../core/domUtils.js";import{on as s}from"../core/events.js";import{makeHandle as r}from"../core/handleUtils.js";import n from"../core/Logger.js";import{destroyMaybe as o,removeMaybe as a}from"../core/maybe.js";import{watch as h,initial as l,syncAndInitial as d,sync as u}from"../core/reactiveUtils.js";import{addFrameTask as c}from"../core/scheduling.js";import{property as p,subclass as m}from"../core/accessorSupport/decorators.js";import{Attribution as f}from"./Attribution.js";import _ from"./overlay/ViewOverlay.js";const y=[0,0];function g(t){const e=(t.ownerDocument||window.document).defaultView,i=t.getBoundingClientRect();return y[0]=i.left+(e?.pageXOffset??0),y[1]=i.top+(e?.pageYOffset??0),y}function v(t){t&&(t.textContent="",t.parentNode&&t.parentNode.removeChild(t))}const b=16,w=750,C=512,H=2,O=y=>{const O=y;let z=class extends O{constructor(...t){super(...t),this._freqInfo={freq:b,time:w},this._overlayRenderTaskHandle=null,this.aria={},this.height=0,this.messagesCommon=null,this.overlay=null,this.position=null,this.resizing=!1,this.root=null,this.surface=null,this.suspended=!0,this.userContent=null,this.width=0,this.widthBreakpoint=null,this.addHandles([h(()=>this.cursor,t=>{const{surface:e}=this;e&&e.setAttribute("data-cursor",t)}),h(()=>this.navigating,t=>{const{surface:e}=this;e&&e.setAttribute("data-navigating",t.toString())}),h(()=>[this.aria,this.surface],()=>this._updateAria(),{initial:!0})])}initialize(){const t=this;this.addHandles([h(()=>this.ui,(t,e)=>this._handleUIChange(t,e),l),t.on("focus",()=>this.notifyChange("focused")),t.on("blur",()=>this.notifyChange("focused"))])}destroy(){this.destroyed||(this.ui?.destroy(),this.container=null)}get container(){return this._get("container")??null}set container(t){const s=this._get("container"),r=e(t);if(r||"string"!=typeof t||n.getLogger(this).error("#container",`element with id '${t}' not found`),s===r)return;if(this._stopMeasuring(),this.removeHandles("container"),s&&(s.classList.remove("esri-view"),this._overlayRenderTaskHandle&&(this._overlayRenderTaskHandle.remove(),this._overlayRenderTaskHandle=null),this.overlay&&(this.overlay.destroy(),this._set("overlay",null)),this._attribution=o(this._attribution),this.root&&(v(this.root),this._set("root",null)),this.userContent&&(i(this.userContent,s),v(this.userContent),this._set("userContent",null))),!r)return this._set("width",0),this._set("height",0),this._set("position",null),this._set("suspended",!0),this._set("surface",null),void this._set("container",null);r.classList.add("esri-view");const l=document.createElement("div");l.className="esri-view-user-storage",i(r,l),r.appendChild(l),this._set("userContent",l);const p=document.createElement("div");p.className="esri-view-root",r.insertBefore(p,r.firstChild),this._set("root",p);const m=document.createElement("div");m.className="esri-view-surface",m.setAttribute("role","application"),m.tabIndex=0,p.appendChild(m),this._set("surface",m);const y=new _;p.appendChild(y.surface),this._set("overlay",y),this.addHandles(h(()=>y.needsRender,t=>{t&&!this._overlayRenderTaskHandle?this._overlayRenderTaskHandle=c({render:()=>this.overlay?.render()}):this._overlayRenderTaskHandle=a(this._overlayRenderTaskHandle)}),"container"),this.addHandles([h(()=>this.attributionVisible,t=>{t?!this._attribution&&t&&(this._attribution=new f({attributionItems:this.attributionItems}),p.appendChild(this._attribution.surface)):this._attribution=o(this._attribution)},d),h(()=>this.attributionItems,t=>{this._attribution&&(this._attribution.attributionItems=t)},u)],"container"),this.forceDOMReadyCycle(),this._set("container",r),this._startMeasuring()}get focused(){const t=document.activeElement===this.surface;return document.hasFocus()&&t}get size(){return[this.width,this.height]}set ui(t){const e=this._get("ui");e!==t&&e?.destroy(),this._set("ui",t)}blur(){this.surface?.blur()}focus(){this.surface?.focus()}pageToContainer(t,e,i){const s=this.position;return t-=s?s[0]:0,e-=s?s[1]:0,i?(i[0]=t,i[1]=e):i=[t,e],i}containerToPage(t,e,i){const s=this.position;return t+=s?s[0]:0,e+=s?s[1]:0,i?(i[0]=t,i[1]=e):i=[t,e],i}_updateAria(){const{surface:t,aria:e}=this;t&&(t.ariaLabelledByElements=e?.labelledByElements??null,t.ariaDescribedByElements=e?.describedByElements??null,t.ariaLabel=e?.label??null,t.ariaDescription=e?.description??null)}_handleUIChange(t,e){this.removeHandles("ui"),e&&e!==t&&e.destroy(),t&&(t.view=this,this.addHandles(h(()=>this.root,e=>{if(e){const i=document.createElement("div");e.insertBefore(i,this._attribution?.surface??null),t.container=i}else t.container=null},l),"ui")),this._set("ui",t)}_stopMeasuring(){this.removeHandles("measuring"),this._get("resizing")&&this._set("resizing",!1)}_startMeasuring(){const t=this._freqInfo;t.freq=b,t.time=w;const e=c({prepare:t=>{const i=this._measure(),s=this._freqInfo;if(s.time+=t.deltaTime,i&&(s.freq=b,this._get("resizing")||this._set("resizing",!0)),s.time<s.freq)return;s.time=0;const r=this._position();s.freq=r||i?b:Math.min(w,s.freq*H),!i&&s.freq>=C&&(e.pause(),this._get("resizing")&&this._set("resizing",!1))}}),i=new ResizeObserver(i=>{t.freq=b,t.time=w,e.resume()});null!=this.container&&i.observe(this.container);const n=r(()=>i.disconnect());this.addHandles([s(window,"resize",()=>{t.freq=b,t.time=w,e.resume()}),n,e],"measuring"),this._measure(),this._position()}_measure(){const t=this.container,e=t?t.clientWidth:0,i=t?t.clientHeight:0;if(0===e||0===i)return this.suspended||this._set("suspended",!0),!1;const s=this.width,r=this.height;if(e===s&&i===r)return this.suspended&&this._set("suspended",!1),!1;this._set("width",e),this._set("height",i),this.suspended&&this._set("suspended",!1);return this.emit("resize",{oldWidth:s,oldHeight:r,width:e,height:i}),!0}_position(){const t=this.container,e=this.position,i=t&&g(t);return!!i&&((!e||i[0]!==e[0]||i[1]!==e[1])&&(this._set("position",[i[0],i[1]]),!0))}forceDOMReadyCycle(){}};return t([p()],z.prototype,"aria",void 0),t([p()],z.prototype,"container",null),t([p({readOnly:!0})],z.prototype,"focused",null),t([p({readOnly:!0})],z.prototype,"height",void 0),t([p()],z.prototype,"messagesCommon",void 0),t([p({type:_})],z.prototype,"overlay",void 0),t([p({readOnly:!0})],z.prototype,"position",void 0),t([p({readOnly:!0})],z.prototype,"resizing",void 0),t([p({readOnly:!0})],z.prototype,"root",void 0),t([p({value:null,readOnly:!0})],z.prototype,"size",null),t([p({readOnly:!0})],z.prototype,"surface",void 0),t([p({readOnly:!0})],z.prototype,"suspended",void 0),t([p({nonNullable:!0})],z.prototype,"ui",null),t([p({readOnly:!0})],z.prototype,"userContent",void 0),t([p({readOnly:!0})],z.prototype,"width",void 0),t([p()],z.prototype,"widthBreakpoint",void 0),z=t([m("esri.views.DOMContainer")],z),z};export{O as DOMContainer};
|
|
5
|
+
import{__decorate as t}from"tslib";import{byId as e,reparent as i}from"../core/domUtils.js";import{on as s}from"../core/events.js";import{makeHandle as r}from"../core/handleUtils.js";import n from"../core/Logger.js";import{destroyMaybe as o,removeMaybe as a}from"../core/maybe.js";import{watch as h,initial as l,syncAndInitial as d,sync as u}from"../core/reactiveUtils.js";import{addFrameTask as c}from"../core/scheduling.js";import{property as p,subclass as m}from"../core/accessorSupport/decorators.js";import{Attribution as f}from"./Attribution.js";import _ from"./overlay/ViewOverlay.js";const y=[0,0];function g(t){const e=(t.ownerDocument||window.document).defaultView,i=t.getBoundingClientRect();return y[0]=i.left+(e?.pageXOffset??0),y[1]=i.top+(e?.pageYOffset??0),y}function v(t){t&&(t.textContent="",t.parentNode&&t.parentNode.removeChild(t))}const b=16,w=750,C=512,H=2,O=y=>{const O=y;let z=class extends O{constructor(...t){super(...t),this._freqInfo={freq:b,time:w},this._overlayRenderTaskHandle=null,this.aria={},this.height=0,this.messagesCommon=null,this.overlay=null,this.position=null,this.resizing=!1,this.root=null,this.surface=null,this.suspended=!0,this.userContent=null,this.width=0,this.widthBreakpoint=null,this.addHandles([h(()=>this.cursor,t=>{const{surface:e}=this;e&&e.setAttribute("data-cursor",t)}),h(()=>this.navigating,t=>{const{surface:e}=this;e&&e.setAttribute("data-navigating",t.toString())}),h(()=>[this.aria,this.surface],()=>this._updateAria(),{initial:!0})])}initialize(){const t=this;this.addHandles([h(()=>this.ui,(t,e)=>this._handleUIChange(t,e),l),t.on("focus",()=>this.notifyChange("focused")),t.on("blur",()=>this.notifyChange("focused"))])}destroy(){this.destroyed||(this.ui?.destroy(),this.container=null)}get container(){return this._get("container")??null}set container(t){const s=this._get("container"),r=e(t);if(r||"string"!=typeof t||n.getLogger(this).error("#container",`element with id '${t}' not found`),s===r)return;if(this._stopMeasuring(),this.removeHandles("container"),s&&(s.classList.remove("esri-view"),this._overlayRenderTaskHandle&&(this._overlayRenderTaskHandle.remove(),this._overlayRenderTaskHandle=null),this.overlay&&(this.overlay.destroy(),this._set("overlay",null)),this._attribution=o(this._attribution),this.root&&(v(this.root),this._set("root",null)),this.userContent&&(i(this.userContent,s),v(this.userContent),this._set("userContent",null))),!r)return this._set("width",0),this._set("height",0),this._set("position",null),this._set("suspended",!0),this._set("surface",null),void this._set("container",null);r.classList.add("esri-view");const l=document.createElement("div");l.className="esri-view-user-storage",i(r,l),r.appendChild(l),this._set("userContent",l);const p=document.createElement("div");p.className="esri-view-root",r.insertBefore(p,r.firstChild),this._set("root",p);const m=document.createElement("div");m.className="esri-view-surface",m.setAttribute("role","application"),m.tabIndex=0,p.appendChild(m),this._set("surface",m);const y=new _;p.appendChild(y.surface),this._set("overlay",y),this.addHandles(h(()=>y.needsRender,t=>{t&&!this._overlayRenderTaskHandle?this._overlayRenderTaskHandle=c({render:()=>this.overlay?.render()}):this._overlayRenderTaskHandle=a(this._overlayRenderTaskHandle)}),"container"),this.addHandles([h(()=>this.attributionVisible,t=>{t?!this._attribution&&t&&(this._attribution=new f({attributionItems:this.attributionItems}),p.appendChild(this._attribution.surface)):this._attribution=o(this._attribution)},d),h(()=>this.attributionItems,t=>{this._attribution&&(this._attribution.attributionItems=t)},u)],"container"),this.forceDOMReadyCycle(),this._set("container",r),this._startMeasuring()}get focused(){const t=document.activeElement===this.surface;return document.hasFocus()&&t}get size(){return[this.width,this.height]}get ui(){return this._get("ui")}set ui(t){const e=this._get("ui");e!==t&&e?.destroy(),this._set("ui",t)}blur(){this.surface?.blur()}focus(){this.surface?.focus()}pageToContainer(t,e,i){const s=this.position;return t-=s?s[0]:0,e-=s?s[1]:0,i?(i[0]=t,i[1]=e):i=[t,e],i}containerToPage(t,e,i){const s=this.position;return t+=s?s[0]:0,e+=s?s[1]:0,i?(i[0]=t,i[1]=e):i=[t,e],i}_updateAria(){const{surface:t,aria:e}=this;t&&(t.ariaLabelledByElements=e?.labelledByElements??null,t.ariaDescribedByElements=e?.describedByElements??null,t.ariaLabel=e?.label??null,t.ariaDescription=e?.description??null)}_handleUIChange(t,e){this.removeHandles("ui"),e&&e!==t&&e.destroy(),t&&(t.view=this,this.addHandles(h(()=>this.root,e=>{if(e){const i=document.createElement("div");e.insertBefore(i,this._attribution?.surface??null),t.container=i}else t.container=null},l),"ui")),this._set("ui",t)}_stopMeasuring(){this.removeHandles("measuring"),this._get("resizing")&&this._set("resizing",!1)}_startMeasuring(){const t=this._freqInfo;t.freq=b,t.time=w;const e=c({prepare:t=>{const i=this._measure(),s=this._freqInfo;if(s.time+=t.deltaTime,i&&(s.freq=b,this._get("resizing")||this._set("resizing",!0)),s.time<s.freq)return;s.time=0;const r=this._position();s.freq=r||i?b:Math.min(w,s.freq*H),!i&&s.freq>=C&&(e.pause(),this._get("resizing")&&this._set("resizing",!1))}}),i=new ResizeObserver(i=>{t.freq=b,t.time=w,e.resume()});null!=this.container&&i.observe(this.container);const n=r(()=>i.disconnect());this.addHandles([s(window,"resize",()=>{t.freq=b,t.time=w,e.resume()}),n,e],"measuring"),this._measure(),this._position()}_measure(){const t=this.container,e=t?t.clientWidth:0,i=t?t.clientHeight:0;if(0===e||0===i)return this.suspended||this._set("suspended",!0),!1;const s=this.width,r=this.height;if(e===s&&i===r)return this.suspended&&this._set("suspended",!1),!1;this._set("width",e),this._set("height",i),this.suspended&&this._set("suspended",!1);return this.emit("resize",{oldWidth:s,oldHeight:r,width:e,height:i}),!0}_position(){const t=this.container,e=this.position,i=t&&g(t);return!!i&&((!e||i[0]!==e[0]||i[1]!==e[1])&&(this._set("position",[i[0],i[1]]),!0))}forceDOMReadyCycle(){}};return t([p()],z.prototype,"aria",void 0),t([p()],z.prototype,"container",null),t([p({readOnly:!0})],z.prototype,"focused",null),t([p({readOnly:!0})],z.prototype,"height",void 0),t([p()],z.prototype,"messagesCommon",void 0),t([p({type:_})],z.prototype,"overlay",void 0),t([p({readOnly:!0})],z.prototype,"position",void 0),t([p({readOnly:!0})],z.prototype,"resizing",void 0),t([p({readOnly:!0})],z.prototype,"root",void 0),t([p({value:null,readOnly:!0})],z.prototype,"size",null),t([p({readOnly:!0})],z.prototype,"surface",void 0),t([p({readOnly:!0})],z.prototype,"suspended",void 0),t([p({nonNullable:!0})],z.prototype,"ui",null),t([p({readOnly:!0})],z.prototype,"userContent",void 0),t([p({readOnly:!0})],z.prototype,"width",void 0),t([p()],z.prototype,"widthBreakpoint",void 0),z=t([m("esri.views.DOMContainer")],z),z};export{O as DOMContainer};
|
package/views/GroundView.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/5.0/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{__decorate as e}from"tslib";import r from"../core/Accessor.js";import t from"../core/Collection.js";import{when as i,watch as
|
|
5
|
+
import{__decorate as e}from"tslib";import r from"../core/Accessor.js";import t from"../core/Collection.js";import{when as i,watch as n}from"../core/reactiveUtils.js";import{property as s,subclass as a}from"../core/accessorSupport/decorators.js";import o from"./3d/layers/IntegratedMesh3DTilesLayerView3D.js";import{toExtent as l}from"./3d/support/cameraUtils.js";import{GroundElevationSampler as p}from"./support/GroundElevationSampler.js";import{IntegratedMeshElevationSampler as d}from"./support/IntegratedMeshElevationSampler.js";let u=class extends r{constructor(e){super(e),this.view=null,this.layerViews=new t}initialize(){this.addHandles([i(()=>this.view?.map?.ground,async e=>e.load()),n(()=>!this.hasTerrainReplacement,e=>{this.view?.basemapTerrain?.enable(e)})])}get hasTerrainReplacement(){const{view:e}=this;if("3d"!==e?.type||!e.map?.basemap)return!1;return!!e.map.basemap.groundLayers.some(r=>(!!e.basemapView?.groundLayerViews.find(e=>e instanceof o&&e.ready&&(e.layer===r||e.canRecycleWith(r)))||e.layerViewManager.isRecyclingLayerViewForLayer(r))&&"replacesTerrain"in r&&r.replacesTerrain)}get ground(){return this.view?.map?.ground}destroy(){this._set("view",null),this.layerViews.destroyAll()}get elevationSampler(){return"3d"===this.view.type?new p({view:this.view}):null}get integratedMeshElevationSampler(){return this.view?new d({view:this.view}):null}get extent(){const{view:e}=this;return e?.ready?l(e,e.state.camera,e.pointsOfInterest.centerOnSurfaceFrequent.renderLocation):null}get updating(){return!this.suspended&&this.layerViews.some(({updating:e})=>e)}get suspended(){return this.view?.suspended??!0}};e([s()],u.prototype,"hasTerrainReplacement",null),e([s({readOnly:!0})],u.prototype,"elevationSampler",null),e([s({readOnly:!0})],u.prototype,"integratedMeshElevationSampler",null),e([s({readOnly:!0})],u.prototype,"extent",null),e([s({type:Boolean,readOnly:!0})],u.prototype,"updating",null),e([s({constructOnly:!0})],u.prototype,"view",void 0),e([s({type:t,readOnly:!0})],u.prototype,"layerViews",void 0),e([s({readOnly:!0})],u.prototype,"suspended",null),u=e([a("esri.views.GroundView")],u);const m=u;export{m 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/5.0/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{__decorate as e}from"tslib";import t from"../../core/Error.js";import{throwIfAborted as r}from"../../core/promiseUtils.js";import{property as s,subclass as o}from"../../core/accessorSupport/decorators.js";import i from"../../geometry/Point.js";import a from"../../layers/
|
|
5
|
+
import{__decorate as e}from"tslib";import t from"../../core/Error.js";import{throwIfAborted as r}from"../../core/promiseUtils.js";import{property as s,subclass as o}from"../../core/accessorSupport/decorators.js";import i from"../../geometry/Point.js";import{load as a,getSourceScale as n}from"../../layers/raster/functions/rasterProjectionHelper.js";import p from"../../layers/support/FieldsIndex.js";import{rasterFieldPrefix as l}from"../../layers/support/rasterFieldUtils.js";import{combineTimeExtent as m}from"../../layers/support/timeSupport.js";import u from"../../rest/support/Query.js";import{getFetchPopupTemplate as c}from"./support/popupUtils.js";const y=y=>{const d=y;let f=class extends d{constructor(...e){super(...e),this.view=null}get timeExtent(){return m(this.layer,this.view?.timeExtent,this._get("timeExtent"))}async fetchPopupFeaturesAtLocation(e,s){const{layer:o}=this;if(!e)throw new t("imagerylayerview:fetchPopupFeatures","Nothing to fetch without area",{layer:o});const{popupEnabled:a}=o,n=c(o,s);if(!a||null==n)return[];const m=await n.getRequiredFields(null,{index:new p(o.rasterFields),partitions:new Map([["$pixel",o.rasterFields.filter(e=>e.name.startsWith(l)).map(e=>e.name)],["$imageCollectionItem",o.fields.map(e=>e.name)]])});r(s);const y=new u;y.timeExtent=this.timeExtent,y.geometry=e,y.outFields=m,y.outSpatialReference=e.spatialReference;const{resolution:d,spatialReference:f}=this.view,w="2d"===this.view.type?new i(d,d,f):new i(.5*d,.5*d,f),{returnTopmostRaster:h,showNoDataRecords:R}=n.layerOptions||{returnTopmostRaster:!0,showNoDataRecords:!1},x={returnDomainValues:!0,returnTopmostRaster:h,pixelSize:w,showNoDataRecords:R,signal:s?.signal};return o.queryVisibleRasters(y,x)}async getSourceScale(){return await a(),await this.layer.load(),n(this.layer.serviceRasterInfo,this.view.spatialReference)}canResume(){return!!super.canResume()&&!this.timeExtent?.isEmpty}};return e([s()],f.prototype,"layer",void 0),e([s()],f.prototype,"suspended",void 0),e([s({readOnly:!0})],f.prototype,"timeExtent",null),e([s()],f.prototype,"view",void 0),f=e([o("esri.views.layers.ImageryLayerViewMixin")],f),f};export{y as ImageryLayerViewMixin};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright Esri, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/5.0/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{__decorate as t}from"tslib";import e from"../../Graphic.js";import r from"../../core/Error.js";import{property as i,subclass as a}from"../../core/accessorSupport/decorators.js";import{
|
|
5
|
+
import{__decorate as t}from"tslib";import e from"../../Graphic.js";import r from"../../core/Error.js";import{property as i,subclass as a}from"../../core/accessorSupport/decorators.js";import{isFunctionRaster as s}from"../../layers/raster/datasets/datasetUtils.js";import{getDefaultDatumTransformationForDataset as n,projectDatasetExtent as l,getSourceScale as o}from"../../layers/raster/functions/rasterProjectionHelper.js";import{addMultidimensionalFieldValues as u,commonRasterFieldNames as c,rasterFieldPrefix as p}from"../../layers/support/rasterFieldUtils.js";import{combineTimeExtent as m}from"../../layers/support/timeSupport.js";import{getFetchPopupTemplate as y}from"./support/popupUtils.js";const f=f=>{const h=f;let d=class extends h{constructor(...t){super(...t),this.layer=null,this.tileInfo=null}get fullExtent(){try{return this.layer.loaded?this._getFullExtent():null}catch{return null}}get timeExtent(){return m(this.layer,this.view?.timeExtent,this._get("timeExtent"))}get hasTilingEffects(){const{renderer:t}=this.layer;return!!("raster-stretch"===t?.type&&t.dynamicRangeAdjustment&&!("min-max"===t.stretchType||"standard-deviation"===t.stretchType))}get datumTransformation(){try{return this.layer.loaded?n(this.layer.fullExtent,this.view.spatialReference,!0):null}catch{return null}}supportsSpatialReference(t){try{return!this.layer.loaded||!!l(this.layer.serviceRasterInfo,t)}catch{return!1}}async fetchPopupFeaturesAtLocation(t,i){const{layer:a}=this;if(!t)throw new r("imageryTileLayerView:fetchPopupFeatures","Nothing to fetch without area",{layer:a});const{popupEnabled:n}=a,l=y(a,i);if(!n||null==l)return[];const o=[],{value:m,magdirValue:f,processedValue:h}=await a.identify(t,{timeExtent:this.timeExtent,signal:i?.signal});let d="";if(m?.length){d="imagery-tile"===a.type&&a.hasStandardTime()&&null!=m[0]?m.map(t=>a.getStandardTimeValue(t)).join(", "):m.join(", ");const t={ObjectId:0};t[c.servicePixelValue]="imagery-tile"===a.type&&s(a.raster)?h?.join(", "):d,t[c.rawServicePixelValue]=d;const r=a.raster?.rasterInfo??a.serviceRasterInfo,i=r?.attributeTable;if(null!=i){const{fields:e,features:r}=i,a=e.find(({name:t})=>"value"===t.toLowerCase()),s=t[c.servicePixelValue],n=a?r.find(t=>String(t.attributes[a.name])===s):null;if(n)for(const i in n.attributes)if(n.attributes.hasOwnProperty(i)){t[p+i]=n.attributes[i]}}const n=r?.dataType;"vector-magdir"!==n&&"vector-uv"!==n||(t[c.magnitude]=f?.[0],t[c.direction]=f?.[1]);const{multidimensionalDefinition:l}=this.layer.normalizeRasterFetchOptions({timeExtent:this.timeExtent});u(a.rasterFields,t,l);const{graphicOrigin:y}=a,g=new e({geometry:this.fullExtent?.clone(),attributes:t,layer:a,origin:y,sourceLayer:a});o.push(g)}return o}async getSourceScale(){return await this.layer.load(),o(this.layer.serviceRasterInfo,this.view.spatialReference)}_getFullExtent(){return l(this.layer.serviceRasterInfo,this.view.spatialReference)}};return t([i()],d.prototype,"fullExtent",null),t([i()],d.prototype,"layer",void 0),t([i({readOnly:!0})],d.prototype,"timeExtent",null),t([i()],d.prototype,"tileInfo",void 0),t([i({readOnly:!0})],d.prototype,"hasTilingEffects",null),t([i()],d.prototype,"datumTransformation",null),d=t([a("esri.views.layers.ImageryTileLayerViewMixin")],d),d};export{f as ImageryTileLayerViewMixin};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright Esri, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/5.0/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import t from"../../request.js";import e from"../../geometry/Point.js";import{execute as r}from"../../geometry/operators/projectOperator.js";import{projectResolution as i,getProjectionOffsetGrid as a,load as s}from"../../layers/
|
|
5
|
+
import t from"../../request.js";import e from"../../geometry/Point.js";import{execute as r}from"../../geometry/operators/projectOperator.js";import{projectResolution as i,getProjectionOffsetGrid as a,load as s}from"../../layers/raster/functions/rasterProjectionHelper.js";import{isImageSource as n,rasterize as o}from"../2d/engine/Bitmap.js";import m from"../2d/engine/webgl/VertexStream.js";import{createProgramTemplate as c}from"../2d/engine/webgl/shaders/MaterialPrograms.js";import{PixelType as p}from"../webgl/enums.js";import{FramebufferObject as h}from"../webgl/FramebufferObject.js";import{createTransformTexture as x}from"../webgl/rasterUtils.js";import{RenderingContext as d}from"../webgl/RenderingContext.js";import{RenderingContextOptions as u}from"../webgl/RenderingContextOptions.js";import{Texture as g}from"../webgl/Texture.js";import{TextureDescriptor as _}from"../webgl/TextureDescriptor.js";class f{static{this._instanceRefCount=0}constructor(t){if(this._ownsRctx=!1,t)this._ownsRctx=!1,this._rctx=t;else{if(f._instance)return f._instanceRefCount++,f._instance;f._instanceRefCount=1,f._instance=this,this._ownsRctx=!0;const t=document.createElement("canvas").getContext("webgl2");t.getExtension("OES_texture_float"),this._rctx=new d(t,new u)}this._quad=new m(this._rctx,[0,0,1,0,0,1,1,1]);const e=c("raster/reproject","raster/reproject",{applyProjection:!0,bilinear:!1,bicubic:!1});this._program=this._rctx.programCache.acquire(e.vertexShader,e.fragmentShader,this._quad.locations),this._rctx.useProgram(this._program),this._program.setUniform1f("u_opacity",1),this._program.setUniform1i("u_image",0),this._program.setUniform1i("u_flipY",0),this._program.setUniform1i("u_transformGrid",1)}reprojectTexture(t,s,n=!1){const o=r(t.extent,s),m=new e({x:(t.extent.xmax-t.extent.xmin)/t.texture.descriptor.width,y:(t.extent.ymax-t.extent.ymin)/t.texture.descriptor.height,spatialReference:t.extent.spatialReference}),{x:c,y:d}=i(m,s,t.extent);let u=(c+d)/2;const g=Math.round((o.xmax-o.xmin)/u),f=Math.round((o.ymax-o.ymin)/u);u=(o.width/g+o.height/f)/2;const l=new e({x:u,y:u,spatialReference:o.spatialReference}),w=a({projectedExtent:o,srcBufferExtent:t.extent,pixelSize:l,hasWrapAround:!0,spacing:[16,16]}),b=x(this._rctx,w),j=new _(g,f);j.wrapMode=33071;const D=new h(this._rctx,j);this._rctx.bindFramebuffer(D),this._rctx.setViewport(0,0,g,f),this._rctx.useProgram(this._program),this._rctx.bindTexture(t.texture,0),this._rctx.bindTexture(b,1),this._quad.bind();const{width:R=0,height:y=0}=t.texture.descriptor;if(this._program.setUniform2f("u_srcImageSize",R,y),this._program.setUniform2fv("u_transformSpacing",w.spacing),this._program.setUniform2fv("u_transformGridSize",w.size),this._program.setUniform2f("u_targetImageSize",g,f),this._quad.draw(),this._quad.unbind(),this._rctx.useProgram(null),this._rctx.bindFramebuffer(null),b.dispose(),n){const{width:t,height:e}=D,r=new ImageData(t??0,e??0);D.readPixels(0,0,t??0,e??0,6408,p.UNSIGNED_BYTE,r.data);const i=D.detachColorTexture();return D.dispose(),{texture:i,extent:o,imageData:r}}const C=D.detachColorTexture();return D.dispose(),{texture:C,extent:o}}reprojectBitmapData(t,e){const r=n(t.bitmapData)?o(t.bitmapData):t.bitmapData,i=new _(t.bitmapData.width,t.bitmapData.height);i.wrapMode=33071;const a=new g(this._rctx,i,r),s=this.reprojectTexture({texture:a,extent:t.extent},e,!0);s.texture.dispose();const m=document.createElement("canvas"),c=s.imageData;m.width=c.width,m.height=c.height;return m.getContext("2d").putImageData(c,0,0),{bitmapData:m,extent:s.extent}}async loadAndReprojectBitmapData(e,r,i){const[a]=await Promise.all([t(e,{responseType:"image"}).then(t=>t.data),s()]),n=document.createElement("canvas");n.width=a.width,n.height=a.height;const o=n.getContext("2d");o.drawImage(a,0,0);const m=o.getImageData(0,0,n.width,n.height);if(r.spatialReference.equals(i))return{bitmapData:m,extent:r};const c=this.reprojectBitmapData({bitmapData:m,extent:r},i);return{bitmapData:c.bitmapData,extent:c.extent}}destroy(){this._ownsRctx?(f._instanceRefCount--,0===f._instanceRefCount&&(this._quad.dispose(),this._program.dispose(),this._rctx.dispose(),f._instance=null)):(this._quad.dispose(),this._program.dispose())}}export{f as ImageReprojector};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright Esri, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/5.0/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{__decorate as e}from"tslib";import{substitute as t}from"../intl.js";import"../core/has.js";import{getOrCreateMapValue as i}from"../core/MapUtils.js";import{watch as o,on as n}from"../core/reactiveUtils.js";import{property as a,subclass as s}from"../core/accessorSupport/decorators.js";import{isIntegerField as r}from"../layers/support/fieldUtils.js";import{isString as l}from"../support/guards.js";import d from"./Widget.js";import{getHiddenFieldsValidationErrorMessage as u,getVisibleFieldInputValidationErrorMessage as p,isElementTemplateWithInputType as m}from"./BatchAttributeForm/batchAttributeFormUtils.js";import c from"./BatchAttributeForm/BatchAttributeFormViewModel.js";import{css as h}from"./BatchAttributeForm/css.js";import{VisibleElements as v}from"./BatchAttributeForm/VisibleElements.js";import{isGroupInput as b,isFieldInput as f,differentValuesString as C}from"./BatchAttributeForm/inputs/support/inputUtils.js";import{loadCalciteComponents as g}from"./support/componentsUtils.js";import{getLabelForDateFieldValue as _,getIntlOptionsForField as y,prepareISOFieldValueForDateComponents as F,prepareUnixFieldValueForDateComponents as w,normalizeTimeOnlyString as I,getISOFieldValueFromDateComponents as x,getUnixFieldValueFromDateComponents as M}from"./support/dateUtils.js";import{globalCss as k}from"./support/globalCss.js";import{messageBundle as O,vmEvent as T,tsx as V}from"./support/widget.js";import{setFocus as D}from"./support/widgetUtils.js";import{isEmptyValue as U}from"./support/forms/formUtils.js";const S="data-element-id";let E=class extends d{constructor(e,t){super(e,t),this.headingLevel=2,this.messagesCommon=null,this.messages=null,this.featureFormMessages=null,this.viewModel=new c,this.visibleElements=new v,this.groupDisplay="all",this._attemptFocusOnNextRender=!1,this._dateComponentMap=new Map,this._touchedInputs=new Set,this._focusedFieldInput=null,this._batchSwitchInputInitialValues=new Map,this._saveInput=this._saveInput.bind(this),this._onFormSubmit=this._onFormSubmit.bind(this),this._onComponentFocus=this._onComponentFocus.bind(this),this._onComponentBlur=this._onComponentBlur.bind(this),this._afterComponentCreateOrUpdate=this._afterComponentCreateOrUpdate.bind(this),this._afterDateComponentCreate=this._afterDateComponentCreate.bind(this),this._afterRadioGroupCreateOrUpdate=this._afterRadioGroupCreateOrUpdate.bind(this)}initialize(){this.addHandles([o(()=>this.features,()=>{this._dateComponentMap.clear()}),o(()=>this.viewModel.activeForm,()=>{this._batchSwitchInputInitialValues.clear()}),n(()=>this.viewModel,"submit",()=>{this.valid||this.goToClosestError()})])}loadDependencies(){return g({input:()=>import("@esri/calcite-components/dist/components/calcite-input"),block:()=>import("@esri/calcite-components/dist/components/calcite-block"),button:()=>import("@esri/calcite-components/dist/components/calcite-button"),combobox:()=>import("@esri/calcite-components/dist/components/calcite-combobox"),"combobox-item":()=>import("@esri/calcite-components/dist/components/calcite-combobox-item"),"combobox-item-group":()=>import("@esri/calcite-components/dist/components/calcite-combobox-item-group"),dropdown:()=>import("@esri/calcite-components/dist/components/calcite-dropdown"),"dropdown-group":()=>import("@esri/calcite-components/dist/components/calcite-dropdown-group"),"dropdown-item":()=>import("@esri/calcite-components/dist/components/calcite-dropdown-item"),"input-date-picker":()=>import("@esri/calcite-components/dist/components/calcite-input-date-picker"),"input-number":()=>import("@esri/calcite-components/dist/components/calcite-input-number"),"input-time-picker":()=>import("@esri/calcite-components/dist/components/calcite-input-time-picker"),"input-time-zone":()=>import("@esri/calcite-components/dist/components/calcite-input-time-zone"),label:()=>import("@esri/calcite-components/dist/components/calcite-label"),"input-message":()=>import("@esri/calcite-components/dist/components/calcite-input-message"),loader:()=>import("@esri/calcite-components/dist/components/calcite-loader"),notice:()=>import("@esri/calcite-components/dist/components/calcite-notice"),switch:()=>import("@esri/calcite-components/dist/components/calcite-switch"),"text-area":()=>import("@esri/calcite-components/dist/components/calcite-text-area"),"radio-button":()=>import("@esri/calcite-components/dist/components/calcite-radio-button"),"radio-button-group":()=>import("@esri/calcite-components/dist/components/calcite-radio-button-group")})}get activeFeatureIndex(){return this.viewModel.activeFeatureIndex}set activeFeatureIndex(e){this.viewModel.activeFeatureIndex=e}get disabled(){return this.viewModel.disabled}set disabled(e){this.viewModel.disabled=e}get _effectiveDisabled(){return this.disabled||this.viewModel.updating}get features(){return this.viewModel.features}set features(e){this.viewModel.features=e}get map(){return this.viewModel.map}set map(e){this.viewModel.map=e}get maximumFeatureCount(){return this.viewModel.maximumFeatureCount}set maximumFeatureCount(e){this.viewModel.maximumFeatureCount=e}get maximumFeatureCountWithComplexForms(){return this.viewModel.maximumFeatureCountWithComplexForms}set maximumFeatureCountWithComplexForms(e){this.viewModel.maximumFeatureCountWithComplexForms=e}get spatialReference(){return this.viewModel.spatialReference}set spatialReference(e){this.viewModel.spatialReference=e}get layerInfos(){return this.viewModel.layerInfos}set layerInfos(e){this.viewModel.layerInfos=e}get timeZone(){return this.viewModel.timeZone}set timeZone(e){this.viewModel.timeZone=e}get icon(){return"edit-attributes"}set icon(e){this._overrideIfSome("icon",e)}get readOnly(){return this.viewModel.readOnly}set readOnly(e){this.viewModel.readOnly=e}get valid(){return this.viewModel.valid}goToClosestError(){const e=this.viewModel.getFirstVisibleInvalidFieldInput();if(!e)return;const{groupInput:t}=e;t&&(t.open||(t.open=!0)),this._focusedFieldInput=e.input,this._attemptFocusOnNextRender=!0,this.scheduleRender()}render(){const{status:e}=this.viewModel;return"failed"===e?this.viewModel.hasTooManyComplexFeatures?this._renderErrorNotice(t(this.messages.formFailedToLoadTooManyComplexFeatures,{num:this.viewModel.maximumFeatureCountWithComplexForms})):this.viewModel.hasTooManyFeatures?this._renderErrorNotice(t(this.messages.formFailedToLoadTooManyFeatures,{num:this.viewModel.maximumFeatureCount})):this._renderErrorNotice(this.messages.formFailedToLoad):this.viewModel.expressionEvaluationFailed?this._renderErrorNotice(this.messages.expressionEvaluationFailed):this.viewModel.hasLayersWithContingentValues?this._renderErrorNotice(this.messages.unsupportedContingentValues):V("div",{class:this.classes(h.base,k.widget,k.panel)},"loaded"===e?this._renderForm():"loading"===e&&this.visibleElements.loadingIndicator?V("calcite-loader",{key:"loader",label:this.messagesCommon?.loading}):null)}submit(){this.viewModel.submit()}_setDateTimeTimeZoneMap(e){const{datePart:t,elementId:o}=e.dataset,n=i(this._dateComponentMap,`${o}`,()=>({}));switch(t){case"date":n.date=e;break;case"time":n.time=e;break;case"timeZone":n.timeZone=e}}_renderErrorNotice(e){return V("div",{class:this.classes(h.base,k.widget,k.panel)},V("calcite-notice",{class:h.noticeError,icon:!0,kind:"warning",open:!0},V("div",{slot:"message"},e)))}_renderForm(){return V("form",{onsubmit:this._onFormSubmit},this._renderInvisibleFieldsError(),this._renderContent())}_renderInvisibleFieldsError(){const{viewModel:e}=this,{hasNonActiveInvalidFeatures:t,activeForm:i}=e;let o;if(!e.submitHasBeenAttempted)return null;if(i.invalidHiddenInputs.length>0)if(o=u(i,e.mode,this.messages),"batch"===this.viewModel.mode){const e=i.invalidHiddenInputs.filter(e=>"hidden:group-visibility-expression:all-features"===e.effectiveVisibilityCode||"hidden:visibility-expression:all-features"===e.visibilityCode);e.length>0?o+=` (${e.map(e=>e.label).join(", ")})`:o=null}else o+=` (${i.invalidHiddenInputs.map(e=>e.label).join(", ")})`;else if(t)return null;return o?V("calcite-notice",{class:h.noticeError,icon:!0,kind:"danger",open:!0},V("div",{slot:"message"},o)):null}_renderContent(){if(!this.viewModel.hasVisibleInputs)return[V("calcite-notice",{class:h.noticeError,icon:!0,kind:"warning",open:!0},V("div",{slot:"message"},this.messages.noVisibleFields[this.viewModel.noVisibleElementsReason]))];const{inputs:e}=this.viewModel.activeForm;return e.filter(e=>e.visible).map(e=>this._renderInput(e))}_renderInput(e){return b(e)?this._renderGroupInput(e):f(e)?this._renderLabeledField(e):void 0}_renderGroupInput(e){const{inputs:t,template:i,open:o}=e,n=t.filter(e=>e.visible),a=i.label??"";return V("calcite-block",{class:this.classes(h.group,"sequential"===this.groupDisplay?h.groupSequential:null,this.disabled?h.inputDisabled:null),collapsible:!0,description:i.description??void 0,disabled:this._effectiveDisabled,expanded:o,heading:a,headingLevel:this.headingLevel,key:`{${i.elementId}-key}`,label:a,onCalciteBlockClose:()=>{e.open=!1},onCalciteBlockOpen:()=>{e.open=!0}},n.map(e=>this._renderInput(e)))}_renderLabeledField(e){const{elementId:i}=e.template,{label:o,required:n,dataType:a}=e,s=n?t(this.messages.requiredFieldLabel,{name:o}):o;return V("calcite-label",{"aria-label":s,class:h.label,key:`field--${i}`},V("div",{class:h.labelTextContent,key:"labelTextContainer"},o,n?V("span",{"aria-hidden":"true",title:this.messagesCommon.required},"*"):void 0),"unsupported"!==a?this._renderFieldInput(e):this._renderReadOnlyComponent(e),this._renderAuxiliaryText(e))}_renderFieldInput(e){const t=this.getCommonInputProps(e),{dataType:i}=e;return"date"===i?this._renderDateComponents(e,t):"coded-value"===e.domain?.type?this._renderCodedInputs({input:e,props:t}):"number"===i?this._renderNumberComponent(e,t):this._renderStringComponent(e,t)}_renderAuxiliaryText(e){const{compositeError:t,description:i,submittable:o}=e,n=!o&&t&&(this.viewModel.submitHasBeenAttempted||this._touchedInputs.has(e.template.elementId))?p(e,t,this.messages):null;return n?V("calcite-input-message",{icon:!0,status:"invalid"},n):i?V("calcite-input-message",{class:h.description,icon:!1,status:"idle"},i):null}_renderCodedInputs({input:e,props:t}){const i=e.template.input?.type??null,o=e.codedValueOptions;switch(i){case"switch":return this._renderSwitchField({input:e,props:t});case"radio-buttons":return this._renderRadioButtonGroupComponent({input:e,options:o.flat(),props:t});default:return this._renderComboBoxComponent({options:o,props:t,input:e})}}_renderSwitchField({input:e,props:t}){if((this._batchSwitchInputInitialValues.get(e)===C||e.value===C)&&"batch"===this.viewModel.mode){const i={dropdown:{afterCreate:this._afterComponentCreateOrUpdate,afterUpdate:this._afterComponentCreateOrUpdate,disabled:t.readOnly,open:!1,[S]:t[S]},trigger:{appearance:"transparent",iconEnd:"chevron-down",kind:"neutral",slot:"trigger",label:t.label},group:{mode:"single"}};return this._renderDropdownComponent({buttonValue:e.value,dropdownProps:i,options:[{name:this.messages.differentValuesPlaceholder,value:C,disabled:!0},...e.codedValueDomainOptions]})}return this._renderSwitchComponent({input:e,props:t})}_renderSwitchComponent({input:e,props:t}){return V("calcite-switch",{...t,checked:!!m(e.template,"switch")&&e.value===e.template.input.onValue,class:h.inputSwitch,disabled:t.readOnly,onblur:()=>{this._focusedFieldInput=null},onCalciteSwitchChange:({currentTarget:e})=>this._saveInput(e)})}_renderDropdownComponent({buttonValue:e,options:t,dropdownProps:i}){const{trigger:o,dropdown:n,group:a}=i;return V("calcite-dropdown",{...n,onblur:()=>{this._focusedFieldInput=null},onfocus:this._onComponentFocus,onCalciteDropdownSelect:({currentTarget:e})=>this._saveInput(e)},V("calcite-button",{...o},e===C?this.messages.differentValuesPlaceholder:e),V("calcite-dropdown-group",{selectionMode:a.mode},t.map(t=>V("calcite-dropdown-item",{disabled:t.disabled,label:String(t.name),selected:e===t.value},t.name))))}_renderComboBoxComponent({input:e,options:t,props:i}){const o="INSERT"===this.viewModel.editType,n=this._touchedInputs.has(e?.template?.elementId),a=o&&e.showNoValueOptionEnabled&&!n?()=>{}:i.onblur,s={...i,onblur:a};return V("calcite-combobox",{...s,selectionMode:"single",value:i.placeholder===this.messages.differentValuesPlaceholder?C:String(i.value),onCalciteComboboxChange:({currentTarget:e})=>{e.value!==C&&this._saveInput(e)}},this.renderComboboxOptionsList({input:e,options:t,props:i}))}renderComboboxOptionsList({input:e,options:t,props:i}){const[o,n]=t.map(e=>e.map(({name:e,value:t})=>V("calcite-combobox-item",{key:`#${t}`,selected:i.value===t,textLabel:e,value:`${t}`}))),a=[...o];n.length>0&&a.push(V("calcite-combobox-item-group",{key:"unsupported",label:this.featureFormMessages.subtypes.unsupportedDomainGroupTitle},n));const s=i.placeholder===this.messages.differentValuesPlaceholder,r=!s&&U(i.value);return e.showNoValueOptionEnabled&&a.unshift(V("calcite-combobox-item",{key:"empty-option",selected:r,textLabel:e.showNoValueLabel||this.messages.empty,value:""})),s&&a.unshift(V("calcite-combobox-item",{key:C,selected:!0,textLabel:this.messages.differentValuesPlaceholder,value:C})),a}_renderRadioButtonGroupComponent({input:e,options:t,props:i}){const o=t.map(({name:t,value:o})=>this._renderRadioButtons({label:t,value:o,selected:o===e.value,props:i}));if(e.showNoValueOptionEnabled){const t="",n=e.showNoValueLabel||this.messages.empty,a=U(e.value);o.unshift(this._renderRadioButtons({label:n,value:t,selected:a,props:i}))}return V("calcite-radio-button-group",{afterCreate:this._afterRadioGroupCreateOrUpdate,afterUpdate:this._afterRadioGroupCreateOrUpdate,class:h.inputRadioGroup,disabled:i.readOnly,key:`${i.key}-radio-group`,layout:"vertical",name:i.name,required:i.required},o,i.placeholder===this.messages.differentValuesPlaceholder?V("calcite-label",{class:h.placeholderRadio,key:i.label,layout:"inline"},V("calcite-radio-button",{checked:!0,class:h.inputRadio,disabled:!0,name:i.placeholder,value:i.placeholder}),i.placeholder):null)}_renderRadioButtons({value:e,selected:t,label:i,props:o}){return V("calcite-label",{class:h.inputRadioLabel,key:o.label,layout:"inline"},V("calcite-radio-button",{...o,afterCreate:void 0,afterUpdate:void 0,checked:t,class:h.inputRadio,disabled:o.readOnly,name:o.label,onblur:()=>{this._focusedFieldInput=null},value:e,onCalciteRadioButtonChange:({currentTarget:e})=>{e.checked&&this._saveInput(e)}}),i)}_renderStringComponent(e,t){const{template:i}=e;return!i.field.editable||this.readOnly?this._renderReadOnlyComponent(e):"text-area"===i.input?.type?V("calcite-text-area",{...t,class:this.classes(h.individualElement),resize:"vertical",value:t.value?String(t.value):"",onCalciteTextAreaInput:({currentTarget:e})=>this._saveInput(e)}):V("calcite-input",{...t,class:this.classes(h.individualElement),type:"text",value:t.value?String(t.value):"",onCalciteInputInput:({currentTarget:e})=>this._saveInput(e)})}_renderNumberComponent(e,t){const i=r(e.field);return V("calcite-input-number",{...t,integer:i,type:"number",value:i&&""!==t.value?Math.round(parseFloat(String(t.value))).toString():String(t.value),onCalciteInputNumberInput:({currentTarget:e})=>this._saveInput(e)})}_renderReadOnlyComponent(e,t){const i=this.getCommonInputProps(e);return V("calcite-input",{...i,class:this.classes(h.fieldInput,h.inputDisabled,h.individualElement),readOnly:!0,type:"text",value:String(t??i.value??"")})}_renderDateComponents(e,t){const{field:i}=e;let o;switch(i.type){case"date":o=this._renderDateFieldComponents(e,t);break;case"date-only":o=this._renderDateOnlyFieldComponent(e,t);break;case"time-only":o=this._renderTimeOnlyFieldComponent(e,t);break;case"timestamp-offset":o=this._renderTimestampOffsetFieldComponents(e,t);break;default:o=this._renderReadOnlyComponent(e,_(i,t.value,{timeZone:e.effectiveTimeZone,...y(e.template.field)}))}return e.value===C?[o,V("calcite-input-message",{icon:"information",key:"diff-values-message",status:"idle"},this.messages.differentValues)]:o}_renderDateOnlyFieldComponent(e,t){const{class:i,key:o,readOnly:n}=t,{rawMax:a,rawMin:s}=e.range;return V("calcite-input-date-picker",{afterCreate:this._afterDateComponentCreate,afterUpdate:this._afterComponentCreateOrUpdate,class:i,"data-date-part":"date","data-element-id":t[S],key:`${o}-date-input`,max:l(a)?a:void 0,min:l(s)?s:void 0,onblur:()=>{this._focusedFieldInput=null},onfocus:this._onComponentFocus,overlayPositioning:"fixed",readOnly:n,value:e.value===C?"":e.value?String(e.value):"",onCalciteInputDatePickerChange:t=>this._saveValueFromDateComponent(e,t.currentTarget)})}_renderTimeOnlyFieldComponent(e,t){const{class:i,key:o,readOnly:n}=t;return V("calcite-input-time-picker",{afterCreate:this._afterDateComponentCreate,afterUpdate:this._afterComponentCreateOrUpdate,class:i,"data-date-part":"time","data-element-id":t[S],key:`${o}-time-input`,onblur:()=>{this._focusedFieldInput=null},onfocus:this._onComponentFocus,overlayPositioning:"fixed",readOnly:n,value:e.value===C?"":e.value?String(e.value):"",onCalciteInputTimePickerChange:t=>this._saveValueFromDateComponent(e,t.currentTarget)})}_renderTimestampOffsetFieldComponents(e,t){const{class:i,key:o,readOnly:n}=t,{rawMax:a,rawMin:s}=e.range,r=F(a),l=F(s),d=F(e.value===C?"":e.value),u=e.includeTimeOffset,p={afterCreate:this._afterDateComponentCreate,afterUpdate:this._afterComponentCreateOrUpdate,overlayPositioning:"fixed",readOnly:n,[S]:t[S],onfocus:this._onComponentFocus};return V("div",{class:h.dateInputContainer,key:`${o}-date-time-container`},V("calcite-input-date-picker",{...p,class:i,"data-date-part":"date",key:`${o}-date-input`,max:r?.date??void 0,min:l?.date??void 0,onblur:()=>{this._focusedFieldInput=null},value:d.date??"",onCalciteInputDatePickerChange:t=>this._saveValueFromDateComponent(e,t.target)}),V("calcite-input-time-picker",{...p,class:i,"data-date-part":"time",key:`${o}-time-input`,onblur:()=>{this._focusedFieldInput=null},value:d.time??"",onCalciteInputTimePickerChange:t=>this._saveValueFromDateComponent(e,t.target)}),u?V("calcite-input-time-zone",{...p,class:i,clearable:e.value===C||null==e.value,"data-date-part":"timeZone",key:`${o}-timezone-input`,onblur:()=>{this._focusedFieldInput=null},value:d.timeZoneOffset||"",onCalciteInputTimeZoneChange:t=>this._saveValueFromDateComponent(e,t.target)}):null)}_renderDateFieldComponents(e,t){const{class:i,key:o,readOnly:n,min:a,max:s}=t,r=e.effectiveTimeZone,l=w(e.value===C?"":e.value,r),d=w(s,r),u=w(a,r),p=e.includeTime,m={afterCreate:this._afterDateComponentCreate,afterUpdate:this._afterComponentCreateOrUpdate,overlayPositioning:"fixed",readOnly:n,[S]:t[S],onfocus:this._onComponentFocus};return V("div",{class:h.dateInputContainer,key:`${o}-date-time-container`},V("calcite-input-date-picker",{...m,class:i,"data-date-part":"date",key:`${o}-date-input`,max:d?.date??void 0,min:u?.date??void 0,onblur:()=>{this._focusedFieldInput=null},value:l.date??"",onCalciteInputDatePickerChange:t=>this._saveValueFromDateComponent(e,t.target)}),p?V("calcite-input-time-picker",{...m,"data-date-part":"time",key:`${o}-time-input`,onblur:()=>{this._focusedFieldInput=null},step:1,value:l.time??"",onCalciteInputTimePickerChange:t=>{this._saveValueFromDateComponent(e,t.target)}}):null)}getCommonInputProps(e){const{template:t,valid:i,value:o,minLength:n,maxLength:a,required:s,fieldName:r,editable:l,userHasChangedValue:d,range:{max:u,min:p}}=e,m=!l||this.readOnly,c=!m&&this._effectiveDisabled;let v=t.hint??void 0,b=!1;return o===C&&(v=this.messages.differentValuesPlaceholder,b=!0),{afterCreate:this._afterComponentCreateOrUpdate,afterUpdate:this._afterComponentCreateOrUpdate,"aria-invalid":i?"false":"true",class:this.classes(h.fieldInput,m?h.inputDisabled:null),status:!d&&!this.viewModel.submitHasBeenAttempted||i?"idle":"invalid",maxLength:a&&a>-1?a:void 0,minLength:n&&n>-1?n:void 0,key:t.elementId,label:r,name:r,max:null!=u?u:void 0,min:null!=p?p:void 0,disabled:c,readOnly:m,onblur:this._onComponentBlur,required:s,placeholder:v,value:b?"":o??"",[S]:t.elementId,onfocus:this._onComponentFocus}}_onFormSubmit(e){e.preventDefault()}_getFieldInputFromHTMLElement(e){return this.viewModel.findFieldInput(e.getAttribute(S))}_afterRadioGroupCreateOrUpdate(e){const t=e.selectedItem,i=e.querySelector("calcite-radio-button"),o=t||i;o&&this._afterComponentCreateOrUpdate(o)}_onComponentFocus(e){const t=e.target,i=this._getFieldInputFromHTMLElement(t);this._touchedInputs.add(i.template.elementId),this._focusedFieldInput=i}_afterComponentCreateOrUpdate(e){const t=this._getFieldInputFromHTMLElement(e),i=this._focusedFieldInput;this._attemptFocusOnNextRender&&i===t&&(this._attemptFocusOnNextRender=!1,D(e))}_onComponentBlur(){this._focusedFieldInput=null}_parseValue(e,t){if(m(t.template,"switch")){if("calcite-dropdown"===e.localName&&t.domain)for(const i of t.domain.codedValues)if(i.name===e.selectedItems[0].textContent)return i.code;return e.checked?t.template.input.onValue:t.template.input.offValue}const i=e.value;return null==i||""===i?null:"number"===t.dataType?"-0"===i||"-0."===i||"-0,"===i?i:parseFloat(i):"date"===t.field.type?parseFloat(i):i}_saveInput(e){const t=this._getFieldInputFromHTMLElement(e),{elementId:o}=t.template;if(!t)return;const n=t?.value;if(m(t.template,"switch")&&"single"!==this.viewModel.mode){const e=i(this._batchSwitchInputInitialValues,t,()=>t.value);this._batchSwitchInputInitialValues.set(t,null===e?n:e)}const a=this._parseValue(e,t);a!==n&&this.viewModel.setValue(o,a)}_afterDateComponentCreate(e){this._setDateTimeTimeZoneMap(e),this._afterComponentCreateOrUpdate(e)}_saveValueFromDateComponent(e,t){const{elementId:i}=e.template,o=e.field.type,n=this._dateComponentMap.get(`${i}`);if(!n)return;const a=e.effectiveTimeZone;let s=e.value===C?void 0:e.value,r=null;"date-only"===o?r=Array.isArray(t.value)?t.value[0]:t.value:"time-only"===o?(s=I(s),r=I(t.value)):r="timestamp-offset"===o?null!=t.value?x({dateComponent:n.date,timeComponent:n.time,oldValue:s,timeZoneComponent:n.timeZone,defaultTimeZone:a}):null:null!=t.value?M({oldValue:s,dateComponent:n.date,timeZone:a,timeComponent:n.time?.value===C?void 0:n.time}):null,s!==r&&(null!==r&&t.value?this.viewModel.setValue(`${i}`,r):this.viewModel.setValue(`${i}`,null))}};e([a()],E.prototype,"activeFeatureIndex",null),e([a()],E.prototype,"disabled",null),e([a()],E.prototype,"_effectiveDisabled",null),e([a()],E.prototype,"features",null),e([a()],E.prototype,"map",null),e([a()],E.prototype,"maximumFeatureCount",null),e([a()],E.prototype,"maximumFeatureCountWithComplexForms",null),e([a()],E.prototype,"spatialReference",null),e([a()],E.prototype,"layerInfos",null),e([a()],E.prototype,"timeZone",null),e([a()],E.prototype,"headingLevel",void 0),e([a()],E.prototype,"icon",null),e([a(),O("esri/t9n/common")],E.prototype,"messagesCommon",void 0),e([a(),O("esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm")],E.prototype,"messages",void 0),e([a(),O("esri/widgets/FeatureForm/t9n/FeatureForm")],E.prototype,"featureFormMessages",void 0),e([a()],E.prototype,"readOnly",null),e([a()],E.prototype,"valid",null),e([a(),T(["value-change","submit"])],E.prototype,"viewModel",void 0),e([a({type:v,nonNullable:!0})],E.prototype,"visibleElements",void 0),e([a()],E.prototype,"groupDisplay",void 0),E=e([s("esri.widgets.BatchAttributeForm")],E);const R=E;export{R as default};
|
|
5
|
+
import{__decorate as e}from"tslib";import{substitute as t}from"../intl.js";import"../core/has.js";import{getOrCreateMapValue as i}from"../core/MapUtils.js";import{watch as o,on as n}from"../core/reactiveUtils.js";import{property as a,subclass as s}from"../core/accessorSupport/decorators.js";import{isIntegerField as r}from"../layers/support/fieldUtils.js";import{isString as l}from"../support/guards.js";import d from"./Widget.js";import{getHiddenFieldsValidationErrorMessage as p,getVisibleFieldInputValidationErrorMessage as u,isElementTemplateWithInputType as m}from"./BatchAttributeForm/batchAttributeFormUtils.js";import c from"./BatchAttributeForm/BatchAttributeFormViewModel.js";import{css as h}from"./BatchAttributeForm/css.js";import{VisibleElements as v}from"./BatchAttributeForm/VisibleElements.js";import{isGroupInput as b,isFieldInput as f,differentValuesString as C}from"./BatchAttributeForm/inputs/support/inputUtils.js";import{loadCalciteComponents as g}from"./support/componentsUtils.js";import{getLabelForDateFieldValue as _,getIntlOptionsForField as y,prepareISOFieldValueForDateComponents as F,prepareUnixFieldValueForDateComponents as w,normalizeTimeOnlyString as I,getISOFieldValueFromDateComponents as x,getUnixFieldValueFromDateComponents as M}from"./support/dateUtils.js";import{globalCss as k}from"./support/globalCss.js";import{messageBundle as O,vmEvent as T,tsx as V}from"./support/widget.js";import{setFocus as D}from"./support/widgetUtils.js";import{isEmptyValue as U}from"./support/forms/formUtils.js";const S="data-element-id";let E=class extends d{constructor(e,t){super(e,t),this.headingLevel=2,this.messagesCommon=null,this.messages=null,this.featureFormMessages=null,this.viewModel=new c,this.visibleElements=new v,this.groupDisplay="all",this._attemptFocusOnNextRender=!1,this._dateComponentMap=new Map,this._touchedInputs=new Set,this._focusedFieldInput=null,this._batchSwitchInputInitialValues=new Map,this._saveInput=this._saveInput.bind(this),this._onFormSubmit=this._onFormSubmit.bind(this),this._onComponentFocus=this._onComponentFocus.bind(this),this._onComponentBlur=this._onComponentBlur.bind(this),this._afterComponentCreateOrUpdate=this._afterComponentCreateOrUpdate.bind(this),this._afterDateComponentCreate=this._afterDateComponentCreate.bind(this),this._afterRadioGroupCreateOrUpdate=this._afterRadioGroupCreateOrUpdate.bind(this)}initialize(){this.addHandles([o(()=>this.features,()=>{this._dateComponentMap.clear()}),o(()=>this.viewModel.activeForm,()=>{this._batchSwitchInputInitialValues.clear()}),n(()=>this.viewModel,"submit",()=>{this.valid||this.goToClosestError()})])}loadDependencies(){return g({input:()=>import("@esri/calcite-components/dist/components/calcite-input"),block:()=>import("@esri/calcite-components/dist/components/calcite-block"),button:()=>import("@esri/calcite-components/dist/components/calcite-button"),combobox:()=>import("@esri/calcite-components/dist/components/calcite-combobox"),"combobox-item":()=>import("@esri/calcite-components/dist/components/calcite-combobox-item"),"combobox-item-group":()=>import("@esri/calcite-components/dist/components/calcite-combobox-item-group"),dropdown:()=>import("@esri/calcite-components/dist/components/calcite-dropdown"),"dropdown-group":()=>import("@esri/calcite-components/dist/components/calcite-dropdown-group"),"dropdown-item":()=>import("@esri/calcite-components/dist/components/calcite-dropdown-item"),"input-date-picker":()=>import("@esri/calcite-components/dist/components/calcite-input-date-picker"),"input-number":()=>import("@esri/calcite-components/dist/components/calcite-input-number"),"input-time-picker":()=>import("@esri/calcite-components/dist/components/calcite-input-time-picker"),"input-time-zone":()=>import("@esri/calcite-components/dist/components/calcite-input-time-zone"),label:()=>import("@esri/calcite-components/dist/components/calcite-label"),"input-message":()=>import("@esri/calcite-components/dist/components/calcite-input-message"),loader:()=>import("@esri/calcite-components/dist/components/calcite-loader"),notice:()=>import("@esri/calcite-components/dist/components/calcite-notice"),switch:()=>import("@esri/calcite-components/dist/components/calcite-switch"),"text-area":()=>import("@esri/calcite-components/dist/components/calcite-text-area"),"radio-button":()=>import("@esri/calcite-components/dist/components/calcite-radio-button"),"radio-button-group":()=>import("@esri/calcite-components/dist/components/calcite-radio-button-group")})}get activeFeatureIndex(){return this.viewModel.activeFeatureIndex}set activeFeatureIndex(e){this.viewModel.activeFeatureIndex=e}get disabled(){return this.viewModel.disabled}set disabled(e){this.viewModel.disabled=e}get _effectiveDisabled(){return this.disabled||this.viewModel.updating}get features(){return this.viewModel.features}set features(e){this.viewModel.features=e}get map(){return this.viewModel.map}set map(e){this.viewModel.map=e}get maximumFeatureCount(){return this.viewModel.maximumFeatureCount}set maximumFeatureCount(e){this.viewModel.maximumFeatureCount=e}get maximumFeatureCountWithComplexForms(){return this.viewModel.maximumFeatureCountWithComplexForms}set maximumFeatureCountWithComplexForms(e){this.viewModel.maximumFeatureCountWithComplexForms=e}get spatialReference(){return this.viewModel.spatialReference}set spatialReference(e){this.viewModel.spatialReference=e}get layerInfos(){return this.viewModel.layerInfos}set layerInfos(e){this.viewModel.layerInfos=e}get timeZone(){return this.viewModel.timeZone}set timeZone(e){this.viewModel.timeZone=e}get icon(){return"edit-attributes"}set icon(e){this._overrideIfSome("icon",e)}get readOnly(){return this.viewModel.readOnly}set readOnly(e){this.viewModel.readOnly=e}get valid(){return this.viewModel.valid}goToClosestError(){const e=this.viewModel.getFirstVisibleInvalidFieldInput();if(!e)return;const{groupInput:t}=e;t&&(t.open||(t.open=!0)),this._focusedFieldInput=e.input,this._attemptFocusOnNextRender=!0,this.scheduleRender()}render(){const{status:e}=this.viewModel;return"failed"===e?this.viewModel.hasTooManyComplexFeatures?this._renderErrorNotice(t(this.messages.formFailedToLoadTooManyComplexFeatures,{num:this.viewModel.maximumFeatureCountWithComplexForms})):this.viewModel.hasTooManyFeatures?this._renderErrorNotice(t(this.messages.formFailedToLoadTooManyFeatures,{num:this.viewModel.maximumFeatureCount})):this._renderErrorNotice(this.messages.formFailedToLoad):this.viewModel.expressionEvaluationFailed?this._renderErrorNotice(this.messages.expressionEvaluationFailed):this.viewModel.hasLayersWithContingentValues?this._renderErrorNotice(this.messages.unsupportedContingentValues):V("div",{class:this.classes(h.base,k.widget,k.panel)},"loaded"===e?this._renderForm():"loading"===e&&this.visibleElements.loadingIndicator?V("calcite-loader",{key:"loader",label:this.messagesCommon?.loading}):null)}submit(){this.viewModel.submit()}_setDateTimeTimeZoneMap(e){const{datePart:t,elementId:o}=e.dataset,n=i(this._dateComponentMap,`${o}`,()=>({}));switch(t){case"date":n.date=e;break;case"time":n.time=e;break;case"timeZone":n.timeZone=e}}_renderErrorNotice(e){return V("div",{class:this.classes(h.base,k.widget,k.panel)},V("calcite-notice",{class:h.noticeError,icon:!0,kind:"warning",open:!0},V("div",{slot:"message"},e)))}_renderForm(){return V("form",{onsubmit:this._onFormSubmit},this._renderInvisibleFieldsError(),this._renderContent())}_renderInvisibleFieldsError(){const{viewModel:e}=this,{hasNonActiveInvalidFeatures:t,activeForm:i}=e;let o;if(!e.submitHasBeenAttempted)return null;if(i.invalidHiddenInputs.length>0)if(o=p(i,e.mode,this.messages),"batch"===this.viewModel.mode){const e=i.invalidHiddenInputs.filter(e=>"hidden:group-visibility-expression:all-features"===e.effectiveVisibilityCode||"hidden:visibility-expression:all-features"===e.visibilityCode);e.length>0?o+=` (${e.map(e=>e.label).join(", ")})`:o=null}else o+=` (${i.invalidHiddenInputs.map(e=>e.label).join(", ")})`;else if(t)return null;return o?V("calcite-notice",{class:h.noticeError,icon:!0,kind:"danger",open:!0},V("div",{slot:"message"},o)):null}_renderContent(){if(!this.viewModel.hasVisibleInputs)return[V("calcite-notice",{class:h.noticeError,icon:!0,kind:"warning",open:!0},V("div",{slot:"message"},this.messages.noVisibleFields[this.viewModel.noVisibleElementsReason]))];const{inputs:e}=this.viewModel.activeForm;return e.filter(e=>e.visible).map(e=>this._renderInput(e))}_renderInput(e){return b(e)?this._renderGroupInput(e):f(e)?this._renderLabeledField(e):void 0}_renderGroupInput(e){const{inputs:t,template:i,open:o}=e,n=t.filter(e=>e.visible),a=i.label??"";return V("calcite-block",{class:this.classes(h.group,"sequential"===this.groupDisplay?h.groupSequential:null,this.disabled?h.inputDisabled:null),collapsible:!0,description:i.description??void 0,disabled:this._effectiveDisabled,expanded:o,heading:a,headingLevel:this.headingLevel,key:`{${i.elementId}-key}`,label:a,onCalciteBlockClose:()=>{e.open=!1},onCalciteBlockOpen:()=>{e.open=!0}},n.map(e=>this._renderInput(e)))}_renderLabeledField(e){const{elementId:i}=e.template,{label:o,required:n,dataType:a}=e,s=n?t(this.messages.requiredFieldLabel,{name:o}):o;return V("calcite-label",{"aria-label":s,class:h.label,key:`field--${i}`},V("div",{class:h.labelTextContent,key:"labelTextContainer"},o,n?V("span",{"aria-hidden":"true",title:this.messagesCommon.required},"*"):void 0),"unsupported"!==a?this._renderFieldInput(e):this._renderReadOnlyComponent(e),this._renderAuxiliaryText(e))}_renderFieldInput(e){const t=this.getCommonInputProps(e),{dataType:i}=e;return"date"===i?this._renderDateComponents(e,t):"coded-value"===e.domain?.type?this._renderCodedInputs({input:e,props:t}):"number"===i?this._renderNumberComponent(e,t):this._renderStringComponent(e,t)}_renderAuxiliaryText(e){const{compositeError:t,description:i,submittable:o}=e,n=!o&&t&&(this.viewModel.submitHasBeenAttempted||this._touchedInputs.has(e.template.elementId))?u(e,t,this.messages):null;return n?V("calcite-input-message",{icon:!0,status:"invalid"},n):i?V("calcite-input-message",{class:h.description,icon:!1,status:"idle"},i):null}_renderCodedInputs({input:e,props:t}){const i=e.template.input?.type??null,o=e.codedValueOptions;switch(i){case"switch":return this._renderSwitchField({input:e,props:t});case"radio-buttons":return this._renderRadioButtonGroupComponent({input:e,options:o.flat(),props:t});default:return this._renderComboBoxComponent({options:o,props:t,input:e})}}_renderSwitchField({input:e,props:t}){if((this._batchSwitchInputInitialValues.get(e)===C||e.value===C)&&"batch"===this.viewModel.mode){const i={dropdown:{afterCreate:this._afterComponentCreateOrUpdate,afterUpdate:this._afterComponentCreateOrUpdate,disabled:t.readOnly,open:!1,[S]:t[S]},trigger:{appearance:"transparent",iconEnd:"chevron-down",kind:"neutral",slot:"trigger",label:t.label},group:{mode:"single"}};return this._renderDropdownComponent({buttonValue:e.value,dropdownProps:i,options:[{name:this.messages.differentValuesPlaceholder,value:C,disabled:!0},...e.codedValueDomainOptions]})}return this._renderSwitchComponent({input:e,props:t})}_renderSwitchComponent({input:e,props:t}){return V("calcite-switch",{...t,checked:!!m(e.template,"switch")&&e.value===e.template.input.onValue,class:h.inputSwitch,disabled:t.readOnly,onblur:()=>{this._focusedFieldInput=null},onCalciteSwitchChange:({currentTarget:e})=>this._saveInput(e)})}_renderDropdownComponent({buttonValue:e,options:t,dropdownProps:i}){const{trigger:o,dropdown:n,group:a}=i;return V("calcite-dropdown",{...n,onblur:()=>{this._focusedFieldInput=null},onfocus:this._onComponentFocus,onCalciteDropdownSelect:({currentTarget:e})=>this._saveInput(e)},V("calcite-button",{...o},e===C?this.messages.differentValuesPlaceholder:e),V("calcite-dropdown-group",{selectionMode:a.mode},t.map(t=>V("calcite-dropdown-item",{disabled:t.disabled,label:String(t.name),selected:e===t.value},t.name))))}_renderComboBoxComponent({input:e,options:t,props:i}){const o="INSERT"===this.viewModel.editType,n=this._touchedInputs.has(e?.template?.elementId),a=o&&e.showNoValueOptionEnabled&&!n?()=>{}:i.onblur,s={...i,onblur:a};return V("calcite-combobox",{...s,selectionMode:"single",value:i.placeholder===this.messages.differentValuesPlaceholder?C:String(i.value),onCalciteComboboxChange:({currentTarget:e})=>{e.value!==C&&this._saveInput(e)}},this.renderComboboxOptionsList({input:e,options:t,props:i}))}renderComboboxOptionsList({input:e,options:t,props:i}){const[o,n]=t.map(e=>e.map(({name:e,value:t})=>V("calcite-combobox-item",{key:`#${t}`,selected:i.value===t,textLabel:e,value:`${t}`}))),a=[...o];n.length>0&&a.push(V("calcite-combobox-item-group",{key:"unsupported",label:this.featureFormMessages.subtypes.unsupportedDomainGroupTitle},n));const s=i.placeholder===this.messages.differentValuesPlaceholder,r=!s&&U(i.value);return e.showNoValueOptionEnabled&&a.unshift(V("calcite-combobox-item",{key:"empty-option",selected:r,textLabel:e.showNoValueLabel||this.messages.empty,value:""})),s&&a.unshift(V("calcite-combobox-item",{key:C,selected:!0,textLabel:this.messages.differentValuesPlaceholder,value:C})),a}_renderRadioButtonGroupComponent({input:e,options:t,props:i}){const o=t.map(({name:t,value:o})=>this._renderRadioButtons({label:t,value:o,selected:o===e.value,props:i}));if(e.showNoValueOptionEnabled){const t="",n=e.showNoValueLabel||this.messages.empty,a=U(e.value);o.unshift(this._renderRadioButtons({label:n,value:t,selected:a,props:i}))}return V("calcite-radio-button-group",{afterCreate:this._afterRadioGroupCreateOrUpdate,afterUpdate:this._afterRadioGroupCreateOrUpdate,class:h.inputRadioGroup,disabled:i.readOnly,key:`${i.key}-radio-group`,layout:"vertical",name:i.name,required:i.required},o,i.placeholder===this.messages.differentValuesPlaceholder?V("calcite-label",{class:h.placeholderRadio,key:i.label,layout:"inline"},V("calcite-radio-button",{checked:!0,class:h.inputRadio,disabled:!0,name:i.placeholder,value:i.placeholder}),i.placeholder):null)}_renderRadioButtons({value:e,selected:t,label:i,props:o}){return V("calcite-label",{class:h.inputRadioLabel,key:o.label,layout:"inline"},V("calcite-radio-button",{...o,afterCreate:void 0,afterUpdate:void 0,checked:t,class:h.inputRadio,disabled:o.readOnly,name:o.label,onblur:()=>{this._focusedFieldInput=null},value:e,onCalciteRadioButtonChange:({currentTarget:e})=>{e.checked&&this._saveInput(e)}}),i)}_renderStringComponent(e,t){const{template:i}=e;return!i.field.editable||this.readOnly?this._renderReadOnlyComponent(e):"text-area"===i.input?.type?V("calcite-text-area",{...t,class:this.classes(h.individualElement),resize:"vertical",value:t.value?String(t.value):"",onCalciteTextAreaInput:({currentTarget:e})=>this._saveInput(e)}):V("calcite-input",{...t,class:this.classes(h.individualElement),type:"text",value:t.value?String(t.value):"",onCalciteInputInput:({currentTarget:e})=>this._saveInput(e)})}_renderNumberComponent(e,t){const i=r(e.field);return V("calcite-input-number",{...t,integer:i,type:"number",value:i&&""!==t.value?Math.round(parseFloat(String(t.value))).toString():String(t.value),onCalciteInputNumberInput:({currentTarget:e})=>this._saveInput(e)})}_renderReadOnlyComponent(e,t){const i=this.getCommonInputProps(e);return V("calcite-input",{...i,class:this.classes(h.fieldInput,h.inputDisabled,h.individualElement),readOnly:!0,type:"text",value:String(t??i.value??"")})}_renderDateComponents(e,t){const{field:i}=e;let o;switch(i.type){case"date":o=this._renderDateFieldComponents(e,t);break;case"date-only":o=this._renderDateOnlyFieldComponent(e,t);break;case"time-only":o=this._renderTimeOnlyFieldComponent(e,t);break;case"timestamp-offset":o=this._renderTimestampOffsetFieldComponents(e,t);break;default:o=this._renderReadOnlyComponent(e,_(i,t.value,{timeZone:e.effectiveTimeZone,...y(e.template.field)}))}return e.value===C?[o,V("calcite-input-message",{icon:"information",key:"diff-values-message",status:"idle"},this.messages.differentValues)]:o}_renderDateOnlyFieldComponent(e,t){const{class:i,key:o,readOnly:n}=t,{rawMax:a,rawMin:s}=e.range;return V("calcite-input-date-picker",{afterCreate:this._afterDateComponentCreate,afterUpdate:this._afterComponentCreateOrUpdate,class:i,"data-date-part":"date","data-element-id":t[S],key:`${o}-date-input`,max:l(a)?a:void 0,min:l(s)?s:void 0,onblur:()=>{this._focusedFieldInput=null},onfocus:this._onComponentFocus,overlayPositioning:"fixed",readOnly:n,value:e.value===C?"":e.value?String(e.value):"",onCalciteInputDatePickerChange:t=>this._saveValueFromDateComponent(e,t.currentTarget)})}_renderTimeOnlyFieldComponent(e,t){const{class:i,key:o,readOnly:n}=t;return V("calcite-input-time-picker",{afterCreate:this._afterDateComponentCreate,afterUpdate:this._afterComponentCreateOrUpdate,class:i,"data-date-part":"time","data-element-id":t[S],key:`${o}-time-input`,onblur:()=>{this._focusedFieldInput=null},onfocus:this._onComponentFocus,overlayPositioning:"fixed",readOnly:n,value:e.value===C?"":e.value?String(e.value):"",onCalciteInputTimePickerChange:t=>this._saveValueFromDateComponent(e,t.currentTarget)})}_renderTimestampOffsetFieldComponents(e,t){const{class:i,key:o,readOnly:n}=t,{rawMax:a,rawMin:s}=e.range,r=F(a),l=F(s),d=F(e.value===C?"":e.value),p=e.includeTimeOffset,u={afterCreate:this._afterDateComponentCreate,afterUpdate:this._afterComponentCreateOrUpdate,overlayPositioning:"fixed",readOnly:n,[S]:t[S],onfocus:this._onComponentFocus};return V("div",{class:h.dateInputContainer,key:`${o}-date-time-container`},V("calcite-input-date-picker",{...u,class:i,"data-date-part":"date",key:`${o}-date-input`,max:r?.date??void 0,min:l?.date??void 0,onblur:()=>{this._focusedFieldInput=null},value:d.date??"",onCalciteInputDatePickerChange:t=>this._saveValueFromDateComponent(e,t.target)}),V("calcite-input-time-picker",{...u,class:i,"data-date-part":"time",key:`${o}-time-input`,onblur:()=>{this._focusedFieldInput=null},value:d.time??"",onCalciteInputTimePickerChange:t=>this._saveValueFromDateComponent(e,t.target)}),p?V("calcite-input-time-zone",{...u,class:i,clearable:e.value===C||null==e.value,"data-date-part":"timeZone",key:`${o}-timezone-input`,onblur:()=>{this._focusedFieldInput=null},value:d.timeZoneOffset||"",onCalciteInputTimeZoneChange:t=>this._saveValueFromDateComponent(e,t.target)}):null)}_renderDateFieldComponents(e,t){const{class:i,key:o,readOnly:n,min:a,max:s}=t,r=e.effectiveTimeZone,l=w(e.value===C?"":e.value,r),d=w(s,r),p=w(a,r),u=e.includeTime,m={afterCreate:this._afterDateComponentCreate,afterUpdate:this._afterComponentCreateOrUpdate,overlayPositioning:"fixed",readOnly:n,[S]:t[S],onfocus:this._onComponentFocus};return V("div",{class:h.dateInputContainer,key:`${o}-date-time-container`},V("calcite-input-date-picker",{...m,class:i,"data-date-part":"date",key:`${o}-date-input`,max:d?.date??void 0,min:p?.date??void 0,onblur:()=>{this._focusedFieldInput=null},value:l.date??"",onCalciteInputDatePickerChange:t=>this._saveValueFromDateComponent(e,t.target)}),u?V("calcite-input-time-picker",{...m,"data-date-part":"time",key:`${o}-time-input`,onblur:()=>{this._focusedFieldInput=null},step:1,value:l.time??"",onCalciteInputTimePickerChange:t=>{this._saveValueFromDateComponent(e,t.target)}}):null)}getCommonInputProps(e){const{template:t,valid:i,value:o,minLength:n,maxLength:a,required:s,fieldName:r,editable:l,userHasChangedValue:d,range:{max:p,min:u}}=e,m=!l||this.readOnly,c=!m&&this._effectiveDisabled;let v=t.hint??void 0,b=!1;return o===C&&(v=this.messages.differentValuesPlaceholder,b=!0),{afterCreate:this._afterComponentCreateOrUpdate,afterUpdate:this._afterComponentCreateOrUpdate,"aria-invalid":i?"false":"true",class:this.classes(h.fieldInput,m?h.inputDisabled:null),status:!d&&!this.viewModel.submitHasBeenAttempted||i?"idle":"invalid",maxLength:a&&a>-1?a:void 0,minLength:n&&n>-1?n:void 0,key:t.elementId,label:r,name:r,max:null!=p?p:void 0,min:null!=u?u:void 0,disabled:c,readOnly:m,onblur:this._onComponentBlur,required:s,placeholder:v,value:b?"":o??"",[S]:t.elementId,onfocus:this._onComponentFocus}}_onFormSubmit(e){e.preventDefault()}_getFieldInputFromHTMLElement(e){return this.viewModel.findFieldInput(e.getAttribute(S))}_afterRadioGroupCreateOrUpdate(e){const t=e.selectedItem,i=e.querySelector("calcite-radio-button"),o=t||i;o&&this._afterComponentCreateOrUpdate(o)}_onComponentFocus(e){const t=e.target,i=this._getFieldInputFromHTMLElement(t);this._touchedInputs.add(i.template.elementId),this._focusedFieldInput=i}_afterComponentCreateOrUpdate(e){const t=this._getFieldInputFromHTMLElement(e),i=this._focusedFieldInput;this._attemptFocusOnNextRender&&i===t&&(this._attemptFocusOnNextRender=!1,D(e))}_onComponentBlur(){this._focusedFieldInput=null}_parseValue(e,t){if(m(t.template,"switch")){if("calcite-dropdown"===e.localName&&t.domain)for(const i of t.domain.codedValues)if(i.name===e.selectedItems[0].textContent)return i.code;return e.checked?t.template.input.onValue:t.template.input.offValue}const i=e.value;return null==i||""===i?null:"number"===t.dataType?"-0"===i||"-0."===i||"-0,"===i?i:parseFloat(i):"date"===t.field.type?parseFloat(i):i}_saveInput(e){const t=this._getFieldInputFromHTMLElement(e),{elementId:o}=t.template;if(!t)return;const n=t?.value;if(m(t.template,"switch")&&"single"!==this.viewModel.mode){const e=i(this._batchSwitchInputInitialValues,t,()=>t.value);this._batchSwitchInputInitialValues.set(t,null===e?n:e)}const a=this._parseValue(e,t);a!==n&&this.viewModel.setValue(o,a)}_afterDateComponentCreate(e){this._setDateTimeTimeZoneMap(e),this._afterComponentCreateOrUpdate(e)}_saveValueFromDateComponent(e,t){const{elementId:i}=e.template,o=e.field.type,n=this._dateComponentMap.get(`${i}`);if(!n)return;const a=e.effectiveTimeZone;let s=e.value===C?void 0:e.value,r=null;"date-only"===o?r=Array.isArray(t.value)?t.value[0]:t.value:"time-only"===o?(s=I(s),r=I(t.value)):r="timestamp-offset"===o?null!=t.value?x({dateComponent:n.date,timeComponent:n.time,oldValue:s,timeZoneComponent:n.timeZone,defaultTimeZone:a}):null:null!=t.value?M({oldValue:s,dateComponent:n.date,timeZone:a,timeComponent:n.time?.value===C?void 0:n.time}):null,s!==r&&(null!==r&&t.value?this.viewModel.setValue(`${i}`,r):this.viewModel.setValue(`${i}`,null))}};e([a()],E.prototype,"activeFeatureIndex",null),e([a()],E.prototype,"disabled",null),e([a()],E.prototype,"_effectiveDisabled",null),e([a()],E.prototype,"features",null),e([a()],E.prototype,"map",null),e([a()],E.prototype,"maximumFeatureCount",null),e([a()],E.prototype,"maximumFeatureCountWithComplexForms",null),e([a()],E.prototype,"spatialReference",null),e([a()],E.prototype,"layerInfos",null),e([a()],E.prototype,"timeZone",null),e([a()],E.prototype,"headingLevel",void 0),e([a()],E.prototype,"icon",null),e([a(),O("esri/t9n/common")],E.prototype,"messagesCommon",void 0),e([a(),O("esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm")],E.prototype,"messages",void 0),e([a(),O("esri/widgets/FeatureForm/t9n/FeatureForm")],E.prototype,"featureFormMessages",void 0),e([a()],E.prototype,"readOnly",null),e([a()],E.prototype,"valid",null),e([a({type:c}),T(["value-change","submit"])],E.prototype,"viewModel",void 0),e([a({type:v,nonNullable:!0})],E.prototype,"visibleElements",void 0),e([a()],E.prototype,"groupDisplay",void 0),E=e([s("esri.widgets.BatchAttributeForm")],E);const R=E;export{R 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/5.0/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{__decorate as e}from"tslib";import t from"../../core/Accessor.js";import s from"../../core/Collection.js";import{referenceSetter as i}from"../../core/collectionUtils.js";import{deprecateUnnecessaryViewModel as r}from"../../core/deprecate.js";import l from"../../core/Logger.js";import{isAbortError as o}from"../../core/promiseUtils.js";import{watch as a,whenOnce as n}from"../../core/reactiveUtils.js";import{property as p,subclass as d}from"../../core/accessorSupport/decorators.js";import y from"../../layers/BuildingSceneLayer.js";import h from"../../layers/support/BuildingFilter.js";import c from"./BuildingDisciplinesViewModel.js";import u from"./BuildingLevel.js";import g from"./BuildingPhase.js";import{showFullModel as m}from"./support/buildingLayerUtils.js";import{setFilterOnLayers as f,getFilterBlockSolid as v,getFilterBlockXRay as w,generateFilterId as j}from"./support/filterUtils.js";import{createLoadLayersFunction as _}from"./support/layerUtils.js";let L=class extends t{constructor(e){super(e),this.view=null,this.state="disabled",this.level=new u({isDefaultViewModel:!0}),this.phase=new g({isDefaultViewModel:!0}),this.disciplines=new c,this._loadLayers=_(),e?.isDefaultViewModel||r(l.getLogger(this),"Building Explorer","arcgis-building-explorer",{version:"5.0"}),this.layers=new s}normalizeCtorArgs(e){const{isDefaultViewModel:t,...s}=e??{};return s}initialize(){this.addHandles([this.layers.on("change",()=>this._onLayersChange()),a(()=>({state:this.state,layers:this.layers,filter:this._filter}),({state:e,layers:t,filter:s})=>{"ready"===e&&f(t,s)},{initial:!0})]),this._onLayersChange()}destroy(){this.level.destroyed||this.level.destroy(),this.phase.destroyed||this.phase.destroy(),this.disciplines.destroyed||this.disciplines.destroy()}get isSupported(){return"3d"===this.view?.type}get layers(){return this._get("layers")}set layers(e){const t=e.filter(e=>e instanceof y);t.length!==e.length&&l.getLogger(this).error("Some layers are not BuildingSceneLayers but only BuildingSceneLayers can be passed to the widget."),this._set("layers",i(t,this._get("layers")))}get _filter(){const e=this.level.filterExpressions,t=this.phase.filterExpressions,s=[],i=v([e.solid,t.solid]);null!=i&&s.push(i);const r=w([e.xRay,t.xRay]);return null!=r&&s.push(r),0===s.length?null:new h({id:j(),name:"Building Explorer Filter",filterBlocks:s})}async _onLayersChange(){const e=this.layers;if(this.level.layers=e,this.phase.layers=e,this.disciplines.layers=e,0!==e.length){this._set("state","loading");try{await this._loadLayers(e),await Promise.all([n(()=>"ready"===this.level.state),n(()=>"ready"===this.phase.state),n(()=>"ready"===this.disciplines.state)]),e.forEach(m),this._set("state","ready")}catch(t){o(t)||this._set("state","failed")}}else this._set("state","disabled")}};e([p({value:null})],L.prototype,"view",void 0),e([p()],L.prototype,"isSupported",null),e([p({type:s,nonNullable:!0})],L.prototype,"layers",null),e([p({readOnly:!0})],L.prototype,"state",void 0),e([p({readOnly:!0,type:u})],L.prototype,"level",void 0),e([p({readOnly:!0,type:g})],L.prototype,"phase",void 0),e([p({readOnly:!0,type:c})],L.prototype,"disciplines",void 0),e([p()],L.prototype,"_filter",null),L=e([d("esri.widgets.BuildingExplorer.BuildingExplorerViewModel")],L);const B=L;export{B as default};
|
|
5
|
+
import{__decorate as e}from"tslib";import t from"../../core/Accessor.js";import s from"../../core/Collection.js";import{referenceSetter as i}from"../../core/collectionUtils.js";import{deprecateUnnecessaryViewModel as r}from"../../core/deprecate.js";import l from"../../core/Logger.js";import{isAbortError as o}from"../../core/promiseUtils.js";import{watch as a,whenOnce as n}from"../../core/reactiveUtils.js";import{property as p,subclass as d}from"../../core/accessorSupport/decorators.js";import y from"../../layers/BuildingSceneLayer.js";import h from"../../layers/support/BuildingFilter.js";import c from"./BuildingDisciplinesViewModel.js";import u from"./BuildingLevel.js";import g from"./BuildingPhase.js";import{showFullModel as m}from"./support/buildingLayerUtils.js";import{setFilterOnLayers as f,getFilterBlockSolid as v,getFilterBlockXRay as w,generateFilterId as j}from"./support/filterUtils.js";import{createLoadLayersFunction as _}from"./support/layerUtils.js";let L=class extends t{constructor(e){super(e),this.view=null,this.state="disabled",this.level=new u({isDefaultViewModel:!0}),this.phase=new g({isDefaultViewModel:!0}),this.disciplines=new c,this._loadLayers=_(),e?.isDefaultViewModel||r(l.getLogger(this),"Building Explorer","arcgis-building-explorer",{version:"5.0"}),this.layers=new s}normalizeCtorArgs(e){const{isDefaultViewModel:t,...s}=e??{};return s}initialize(){this.addHandles([this.layers.on("change",()=>this._onLayersChange()),a(()=>({state:this.state,layers:this.layers,filter:this._filter}),({state:e,layers:t,filter:s})=>{"ready"===e&&f(t,s)},{initial:!0})]),this._onLayersChange()}destroy(){this.level.destroyed||this.level.destroy(),this.phase.destroyed||this.phase.destroy(),this.disciplines.destroyed||this.disciplines.destroy()}get isSupported(){return"3d"===this.view?.type}get layers(){return this._get("layers")}set layers(e){const t=e.filter(e=>e instanceof y);t.length!==e.length&&l.getLogger(this).error("Some layers are not BuildingSceneLayers but only BuildingSceneLayers can be passed to the widget."),this._set("layers",i(t,this._get("layers")))}get _filter(){const e=this.level.filterExpressions,t=this.phase.filterExpressions,s=[],i=v([e.solid,t.solid]);null!=i&&s.push(i);const r=w([e.xRay,t.xRay]);return null!=r&&s.push(r),0===s.length?null:new h({id:j(),name:"Building Explorer Filter",filterBlocks:s})}async _onLayersChange(){const e=this.layers;if(this.level.layers=e,this.phase.layers=e,this.disciplines.layers=e,0!==e.length){this._set("state","loading");try{await this._loadLayers(e),await Promise.all([n(()=>"ready"===this.level.state),n(()=>"ready"===this.phase.state),n(()=>"ready"===this.disciplines.state)]),e.forEach(m),this._set("state","ready")}catch(t){o(t)||this._set("state","failed")}}else this._set("state","disabled")}};e([p({value:null})],L.prototype,"view",void 0),e([p()],L.prototype,"isSupported",null),e([p({type:s.ofType(y),nonNullable:!0})],L.prototype,"layers",null),e([p({readOnly:!0})],L.prototype,"state",void 0),e([p({readOnly:!0,type:u})],L.prototype,"level",void 0),e([p({readOnly:!0,type:g})],L.prototype,"phase",void 0),e([p({readOnly:!0,type:c})],L.prototype,"disciplines",void 0),e([p()],L.prototype,"_filter",null),L=e([d("esri.widgets.BuildingExplorer.BuildingExplorerViewModel")],L);const B=L;export{B 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/5.0/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{__decorate as t}from"tslib";import{getAssetUrl as e}from"../../assets.js";import o from"../../Graphic.js";import{fetchMessageBundle as i,onLocaleChange as s,getLocale as n}from"../../intl.js";import r from"../../core/Collection.js";import a from"../../core/Error.js";import{EventedAccessor as h}from"../../core/Evented.js";import c from"../../core/Logger.js";import{watch as d,initial as l,when as m}from"../../core/reactiveUtils.js";import{property as v,cast as p,subclass as u}from"../../core/accessorSupport/decorators.js";import f from"../../geometry/Point.js";import{load as g}from"../../geometry/projectionUtils.js";import w from"../../symbols/PictureMarkerSymbol.js";import{pointSymbolTypes as _}from"../../symbols/support/typeUtils.js";import y from"./support/Conversion.js";import{isValidPoint as C,isSupportedNotation as b}from"./support/coordinateConversionUtils.js";import L from"./support/Format.js";import{generateDefaultFormats as M,setDefaultPatterns as P}from"./support/formatUtils.js";import{GoTo as S}from"../support/GoTo.js";const j=new f([0,0,500]),H="xy",F=["mgrs","utm","usng","dd","dms","ddm"],G="esri__coordinateConversionWidgetState",x={conversions:"conversions",formats:"formats",view:"view",viewChange:"view-change",cursor:"cursor"},E="esri/images/search/search-symbol-32.png";let T=class extends(S(h)){constructor(t){super(t),this._conversionPromise=null,this._locationGraphic=null,this._pointerCount=0,this.conversions=new r,this.formats=new r,this.formatterAvailable=!1,this.messages=null,this.filteredFormats=new r,this.locationSymbol=new w({url:e(E),width:24,height:24}),this.storageEnabled=!0,this.storageType="session",this.view=null,this._saveWidgetState=this._saveWidgetState.bind(this),this._handleFormatChange=this._handleFormatChange.bind(this),this._handleConversionChange=this._handleConversionChange.bind(this),this._handleViewChange=this._handleViewChange.bind(this),this._onClick=this._onClick.bind(this),this._onPointerMove=this._onPointerMove.bind(this),this._onPointerDown=this._onPointerDown.bind(this),this._onPointerUp=this._onPointerUp.bind(this)}initialize(){const t=async()=>this.messages=await i("esri/widgets/CoordinateConversion/t9n/CoordinateConversion");this.formats.addMany(M()),t().then(()=>{if(!this.destroyed&&(P(this.messages,this.formats),this.storageEnabled&&this._loadWidgetState(),this.formats.forEach(t=>{t.viewModel=this,this.addHandles(d(()=>t.currentPattern,this._saveWidgetState),t.name??"unnamed-format")}),this.addHandles(this.conversions.on("change",this._handleConversionChange),x.conversions),this.addHandles(this.formats.on("change",this._handleFormatChange),x.formats),this.addHandles(s(()=>{t().then(()=>{P(this.messages,this.formats)})})),g().then(()=>{this.formatterAvailable=!0}).catch(t=>{c.getLogger(this).error(new a("coordinate-conversion:projection-load-failed","Failed to load the projection module.",{error:t})),this.formatterAvailable=!1,this._filterFormatsAndConversions()}).then(()=>this.addHandles(d(()=>this.view,this._handleViewChange,l),x.viewChange)),0===this.conversions.length)){const t=this.formats.find(t=>t.name===H)||this.formats.at(0);this.conversions.add(new y({format:t}))}})}destroy(){this.removeHandles(),this._cleanUpView(this.view),this.view=null}castConversions(t){return this._castToConversions(t)}set currentLocation(t){this._set("currentLocation",t),this._updateConversions()}get currentLocation(){return this._get("currentLocation")||null}set mode(t){switch(t){case"capture":this.currentLocation=null,this._startCaptureMode(),this._set("mode",t);break;case"live":this._startLiveMode(),this._set("mode",t)}}get mode(){return this._get("mode")||"live"}get state(){const{messages:t,view:e}=this,o=e?.ready;return t?o?"ready":e?"loading":"disabled":"disabled"}get storage(){const{storageType:t}=this;return"session"===t?sessionStorage:localStorage}get waitingForConversions(){return null!=this._conversionPromise}setLocation(t){if(this._locationGraphic&&this.view?.graphics.remove(this._locationGraphic),!t)return;const e=t.clone();e.hasZ&&(e.z=void 0),this._locationGraphic=new o({geometry:e,symbol:this.locationSymbol}),this.view?.graphics.add(this._locationGraphic)}async convert(t,e){if(!C(e))throw new a("coordinate-conversion:invalid-point","Invalid point cannot be converted.",{point:e});return Promise.resolve().then(()=>t.convert(e))}async goToLocation(t){const{view:e}=this;if(!e)throw new a("coordinate-conversion:go-to-failed","no view");const o="3d"===e.type?e.clippingArea:null,i=e.map?.basemap?.baseLayers;if(o||(i?.length??0)>0){const e=o??i?.at(0)?.fullExtent;if(null!=e&&!e.contains(t))throw new a("coordinate-conversion:go-to-failed","Point outside basemap extent.",{point:t})}return this.callGoTo({target:t})}pause(){this.currentLocation=null,this.removeHandles(x.view),this.view&&(this.removeHandles(x.cursor),this._locationGraphic&&this.view.graphics.remove(this._locationGraphic))}async previewConversion(t,e=this.currentLocation||j){return(await W(t,e)).displayCoordinate}resume(){"capture"===this.mode?this._startCaptureMode():this._startLiveMode()}reverseConvert(t,e){return e.reverseConvert(t)}async updateConversions(t,e){if("point"!==e?.type)throw this._clearConversions(this.conversions),new a("coordinate-conversion:invalid-input-point","Point is invalid, conversions cannot be updated.",{point:e});return this._convertMany(t,e)}_castToConversions(t){const e=new r;return t.forEach(t=>{let o=null;if(t instanceof y)o=t;else if("string"==typeof t){const e=this.formats.find(e=>e.name===t);e&&(o=new y({format:e}))}o&&e.add(o)}),e}_cleanUpView(t){t&&(this._locationGraphic&&t.graphics.remove(this._locationGraphic),this.removeHandles(x.view),this.removeHandles(x.cursor))}_clearConversions(t){t.forEach(t=>{t.position={location:null,coordinate:null}})}async _convertMany(t,e){return Promise.all(t.map(t=>W(t,e)))}_handleConversionChange(t){for(const e of t.added){const{format:t}=e;t&&(t.viewModel=this,this.currentLocation&&(this._set("waitingForConversions",!0),this.convert(t,this.currentLocation).then(t=>{e.position=t,this._set("waitingForConversions",!1)})))}this._saveWidgetState()}_handleFormatChange(t){t.added.forEach(t=>{this.addHandles(d(()=>t.currentPattern,this._saveWidgetState),t.name??"unnamed-format"),t.viewModel=this}),t.removed.forEach(t=>{t.viewModel=null;const e=this.conversions.filter(e=>e.format===t);this.conversions.removeMany(e),t.name&&this.removeHandles(t.name)})}_loadWidgetState(){try{const t=JSON.parse(this.storage.getItem(G));t&&this._setWidgetState(t)}catch(t){c.getLogger(this).error(new a("coordinate-conversion:invalid-session-storage-json","Could not read from storage.",{error:t}))}}_startCaptureMode(){this.removeHandles(x.view),this.view&&(this.currentLocation&&this.setLocation(this.currentLocation),this.removeHandles(x.cursor),this.addHandles(this.view.acquireCursor("crosshair","high"),x.cursor),this.addHandles(this.view.on("click",this._onClick),x.view))}_startLiveMode(){this._pointerCount=0,this.removeHandles(x.view),this.view&&(this.removeHandles(x.cursor),this._locationGraphic&&this.view.graphics.remove(this._locationGraphic),this.addHandles([this.view.on("pointer-down",this._onPointerDown),this.view.on("pointer-up",this._onPointerUp),this.view.on("pointer-move",this._onPointerMove)],x.view))}_handleViewChange(t,e){e&&e!==t&&this._cleanUpView(e),t&&("capture"===this.mode?this._startCaptureMode():this._startLiveMode(),e&&this._filterFormatsAndConversions())}_onClick(t){if(0===t.button){const e=this.view?.toMap(t),o=e?.normalize();this.setLocation(o),this.currentLocation=o}}_onPointerDown(t){const{pointerType:e}=t;if(this._pointerCount++,("touch"===e||"pen"===e)&&1===this._pointerCount){const e=this.view?.toMap(t);this.currentLocation=e?.normalize()}}_onPointerMove(t){const{pointerType:e}=t;if("mouse"===e||1===this._pointerCount){const e=this.view?.toMap(t);this.currentLocation=e?.normalize()}}_onPointerUp(){this._pointerCount--}_setWidgetState(t){try{t.formats.forEach(e=>{const o=this.formats.find(t=>t.name===e.name);o&&t.locale===n()&&e.currentPattern&&(o.currentPattern=e.currentPattern),o&&e.index>=0&&this.conversions.add(new y({format:o}))})}catch(e){c.getLogger(this).warn(new a("coordinate-conversion:session-storage-read-error","Could not get state from stored JSON.",{error:e}))}}_saveWidgetState(){if(!this.storageEnabled)return;const t=this._toJSON();try{this.storage.setItem(G,JSON.stringify({formats:t,locale:n()}))}catch(e){c.getLogger(this).error(new a("coordinate-conversion:local-storage-write-error","Could not write to localStorage.",{error:e}))}}async _updateConversions(){try{await this.updateConversions(this.conversions.toArray(),this.currentLocation)}catch{}}_toJSON(){return this.formats.filter(t=>{const e=t.name;return"xy"===e||"basemap"===e||b(e)}).map(t=>({name:t.name,currentPattern:t.currentPattern,defaultPattern:t.defaultPattern,index:this.conversions.findIndex(e=>e.format===t)})).sort((t,e)=>t.index-e.index).toArray()}_filterFormatsAndConversions(){const{formatterAvailable:t,conversions:e,formats:o}=this;t||this.addHandles(m(()=>this.view?.spatialReference,t=>{const i=t.isWebMercator||t.isWGS84,s=o.filter(t=>{const{name:e}=t;return!!U(e)||"xy"===e&&!i}),n=this.filteredFormats.filter(t=>"xy"===t.name&&i&&!this.formats.includes(t)),r=e.filter(t=>s.includes(t.format));o.removeMany(s),e.removeMany(r),this.filteredFormats.addMany(s.filter(t=>!this.filteredFormats.includes(t))),o.addMany(n)},{once:!0,initial:!0}),x.view)}};async function W(t,e){try{t.position=await(t.format?.convert(e))}catch(o){t.position=null}return t}function U(t){return F.includes(t)}t([v({type:r.ofType(y)})],T.prototype,"conversions",void 0),t([p("conversions")],T.prototype,"castConversions",null),t([v({type:f})],T.prototype,"currentLocation",null),t([v({type:r.ofType(L)})],T.prototype,"formats",void 0),t([v()],T.prototype,"messages",void 0),t([v()],T.prototype,"mode",null),t([v()],T.prototype,"filteredFormats",void 0),t([v({readOnly:!0})],T.prototype,"state",null),t([v({types:_})],T.prototype,"locationSymbol",void 0),t([v({readOnly:!0,dependsOn:["storageType"]})],T.prototype,"storage",null),t([v()],T.prototype,"storageEnabled",void 0),t([v()],T.prototype,"storageType",void 0),t([v({readOnly:!0})],T.prototype,"waitingForConversions",null),t([v()],T.prototype,"view",void 0),T=t([u("esri.widgets.CoordinateConversion.CoordinateConversionViewModel")],T);const A=T;export{A as default};
|
|
5
|
+
import{__decorate as t}from"tslib";import{getAssetUrl as e}from"../../assets.js";import o from"../../Graphic.js";import{fetchMessageBundle as i,onLocaleChange as s,getLocale as r}from"../../intl.js";import n from"../../core/Collection.js";import a from"../../core/Error.js";import{EventedAccessor as h}from"../../core/Evented.js";import c from"../../core/Logger.js";import{watch as d,initial as l,when as m}from"../../core/reactiveUtils.js";import{property as v,subclass as p}from"../../core/accessorSupport/decorators.js";import{ensureType as u}from"../../core/accessorSupport/ensureType.js";import g from"../../geometry/Point.js";import{load as f}from"../../geometry/projectionUtils.js";import w from"../../symbols/PictureMarkerSymbol.js";import{pointSymbolTypes as _}from"../../symbols/support/typeUtils.js";import y from"./support/Conversion.js";import{isValidPoint as C,isSupportedNotation as b}from"./support/coordinateConversionUtils.js";import L from"./support/Format.js";import{generateDefaultFormats as M,setDefaultPatterns as P}from"./support/formatUtils.js";import{GoTo as S}from"../support/GoTo.js";const j=new g([0,0,500]),H="xy",F=["mgrs","utm","usng","dd","dms","ddm"],G="esri__coordinateConversionWidgetState",x={conversions:"conversions",formats:"formats",view:"view",viewChange:"view-change",cursor:"cursor"},E="esri/images/search/search-symbol-32.png";let W=class extends(S(h)){constructor(t){super(t),this._conversionPromise=null,this._locationGraphic=null,this._pointerCount=0,this.formats=new n,this.formatterAvailable=!1,this.messages=null,this.filteredFormats=new n,this.locationSymbol=new w({url:e(E),width:24,height:24}),this.storageEnabled=!0,this.storageType="session",this.view=null,this._saveWidgetState=this._saveWidgetState.bind(this),this._handleFormatChange=this._handleFormatChange.bind(this),this._handleConversionChange=this._handleConversionChange.bind(this),this._handleViewChange=this._handleViewChange.bind(this),this._onClick=this._onClick.bind(this),this._onPointerMove=this._onPointerMove.bind(this),this._onPointerDown=this._onPointerDown.bind(this),this._onPointerUp=this._onPointerUp.bind(this),this.conversions=new n}initialize(){const t=async()=>this.messages=await i("esri/widgets/CoordinateConversion/t9n/CoordinateConversion");this.formats.addMany(M()),t().then(()=>{if(!this.destroyed&&(P(this.messages,this.formats),this.storageEnabled&&this._loadWidgetState(),this.formats.forEach(t=>{t.viewModel=this,this.addHandles(d(()=>t.currentPattern,this._saveWidgetState),t.name??"unnamed-format")}),this.addHandles(this.conversions.on("change",this._handleConversionChange),x.conversions),this.addHandles(this.formats.on("change",this._handleFormatChange),x.formats),this.addHandles(s(()=>{t().then(()=>{P(this.messages,this.formats)})})),f().then(()=>{this.formatterAvailable=!0}).catch(t=>{c.getLogger(this).error(new a("coordinate-conversion:projection-load-failed","Failed to load the projection module.",{error:t})),this.formatterAvailable=!1,this._filterFormatsAndConversions()}).then(()=>this.addHandles(d(()=>this.view,this._handleViewChange,l),x.viewChange)),0===this.conversions.length)){const t=this.formats.find(t=>t.name===H)||this.formats.at(0);this.conversions.add(new y({format:t}))}})}destroy(){this.removeHandles(),this._cleanUpView(this.view),this.view=null}get conversions(){return this._get("conversions")}set conversions(t){const e=new n;t.forEach(t=>{let o=null;if("string"==typeof t){const e=this.formats.find(e=>e.name===t);e&&(o=new y({format:e}))}else o=u(y,t);o&&e.add(o)}),this._set("conversions",e)}set currentLocation(t){this._set("currentLocation",t),this._updateConversions()}get currentLocation(){return this._get("currentLocation")||null}set mode(t){switch(t){case"capture":this.currentLocation=null,this._startCaptureMode(),this._set("mode",t);break;case"live":this._startLiveMode(),this._set("mode",t)}}get mode(){return this._get("mode")||"live"}get state(){const{messages:t,view:e}=this,o=e?.ready;return t?o?"ready":e?"loading":"disabled":"disabled"}get storage(){const{storageType:t}=this;return"session"===t?sessionStorage:localStorage}get waitingForConversions(){return null!=this._conversionPromise}setLocation(t){if(this._locationGraphic&&this.view?.graphics.remove(this._locationGraphic),!t)return;const e=t.clone();e.hasZ&&(e.z=void 0),this._locationGraphic=new o({geometry:e,symbol:this.locationSymbol}),this.view?.graphics.add(this._locationGraphic)}async convert(t,e){if(!C(e))throw new a("coordinate-conversion:invalid-point","Invalid point cannot be converted.",{point:e});return Promise.resolve().then(()=>t.convert(e))}async goToLocation(t){const{view:e}=this;if(!e)throw new a("coordinate-conversion:go-to-failed","no view");const o="3d"===e.type?e.clippingArea:null,i=e.map?.basemap?.baseLayers;if(o||(i?.length??0)>0){const e=o??i?.at(0)?.fullExtent;if(null!=e&&!e.contains(t))throw new a("coordinate-conversion:go-to-failed","Point outside basemap extent.",{point:t})}return this.callGoTo({target:t})}pause(){this.currentLocation=null,this.removeHandles(x.view),this.view&&(this.removeHandles(x.cursor),this._locationGraphic&&this.view.graphics.remove(this._locationGraphic))}async previewConversion(t,e=this.currentLocation||j){return(await U(t,e)).displayCoordinate}resume(){"capture"===this.mode?this._startCaptureMode():this._startLiveMode()}reverseConvert(t,e){return e.reverseConvert(t)}async updateConversions(t,e){if("point"!==e?.type)throw this._clearConversions(this.conversions),new a("coordinate-conversion:invalid-input-point","Point is invalid, conversions cannot be updated.",{point:e});return this._convertMany(t,e)}_cleanUpView(t){t&&(this._locationGraphic&&t.graphics.remove(this._locationGraphic),this.removeHandles(x.view),this.removeHandles(x.cursor))}_clearConversions(t){t.forEach(t=>{t.position={location:null,coordinate:null}})}async _convertMany(t,e){return Promise.all(t.map(t=>U(t,e)))}_handleConversionChange(t){for(const e of t.added){const{format:t}=e;t&&(t.viewModel=this,this.currentLocation&&(this._set("waitingForConversions",!0),this.convert(t,this.currentLocation).then(t=>{e.position=t,this._set("waitingForConversions",!1)})))}this._saveWidgetState()}_handleFormatChange(t){t.added.forEach(t=>{this.addHandles(d(()=>t.currentPattern,this._saveWidgetState),t.name??"unnamed-format"),t.viewModel=this}),t.removed.forEach(t=>{t.viewModel=null;const e=this.conversions.filter(e=>e.format===t);this.conversions.removeMany(e),t.name&&this.removeHandles(t.name)})}_loadWidgetState(){try{const t=JSON.parse(this.storage.getItem(G));t&&this._setWidgetState(t)}catch(t){c.getLogger(this).error(new a("coordinate-conversion:invalid-session-storage-json","Could not read from storage.",{error:t}))}}_startCaptureMode(){this.removeHandles(x.view),this.view&&(this.currentLocation&&this.setLocation(this.currentLocation),this.removeHandles(x.cursor),this.addHandles(this.view.acquireCursor("crosshair","high"),x.cursor),this.addHandles(this.view.on("click",this._onClick),x.view))}_startLiveMode(){this._pointerCount=0,this.removeHandles(x.view),this.view&&(this.removeHandles(x.cursor),this._locationGraphic&&this.view.graphics.remove(this._locationGraphic),this.addHandles([this.view.on("pointer-down",this._onPointerDown),this.view.on("pointer-up",this._onPointerUp),this.view.on("pointer-move",this._onPointerMove)],x.view))}_handleViewChange(t,e){e&&e!==t&&this._cleanUpView(e),t&&("capture"===this.mode?this._startCaptureMode():this._startLiveMode(),e&&this._filterFormatsAndConversions())}_onClick(t){if(0===t.button){const e=this.view?.toMap(t),o=e?.normalize();this.setLocation(o),this.currentLocation=o}}_onPointerDown(t){const{pointerType:e}=t;if(this._pointerCount++,("touch"===e||"pen"===e)&&1===this._pointerCount){const e=this.view?.toMap(t);this.currentLocation=e?.normalize()}}_onPointerMove(t){const{pointerType:e}=t;if("mouse"===e||1===this._pointerCount){const e=this.view?.toMap(t);this.currentLocation=e?.normalize()}}_onPointerUp(){this._pointerCount--}_setWidgetState(t){try{t.formats.forEach(e=>{const o=this.formats.find(t=>t.name===e.name);o&&t.locale===r()&&e.currentPattern&&(o.currentPattern=e.currentPattern),o&&e.index>=0&&this.conversions.add(new y({format:o}))})}catch(e){c.getLogger(this).warn(new a("coordinate-conversion:session-storage-read-error","Could not get state from stored JSON.",{error:e}))}}_saveWidgetState(){if(!this.storageEnabled)return;const t=this._toJSON();try{this.storage.setItem(G,JSON.stringify({formats:t,locale:r()}))}catch(e){c.getLogger(this).error(new a("coordinate-conversion:local-storage-write-error","Could not write to localStorage.",{error:e}))}}async _updateConversions(){try{await this.updateConversions(this.conversions.toArray(),this.currentLocation)}catch{}}_toJSON(){return this.formats.filter(t=>{const e=t.name;return"xy"===e||"basemap"===e||b(e)}).map(t=>({name:t.name,currentPattern:t.currentPattern,defaultPattern:t.defaultPattern,index:this.conversions.findIndex(e=>e.format===t)})).sort((t,e)=>t.index-e.index).toArray()}_filterFormatsAndConversions(){const{formatterAvailable:t,conversions:e,formats:o}=this;t||this.addHandles(m(()=>this.view?.spatialReference,t=>{const i=t.isWebMercator||t.isWGS84,s=o.filter(t=>{const{name:e}=t;return!!T(e)||"xy"===e&&!i}),r=this.filteredFormats.filter(t=>"xy"===t.name&&i&&!this.formats.includes(t)),n=e.filter(t=>s.includes(t.format));o.removeMany(s),e.removeMany(n),this.filteredFormats.addMany(s.filter(t=>!this.filteredFormats.includes(t))),o.addMany(r)},{once:!0,initial:!0}),x.view)}};async function U(t,e){try{t.position=await(t.format?.convert(e))}catch(o){t.position=null}return t}function T(t){return F.includes(t)}t([v()],W.prototype,"conversions",null),t([v({type:g})],W.prototype,"currentLocation",null),t([v({type:n.ofType(L)})],W.prototype,"formats",void 0),t([v()],W.prototype,"messages",void 0),t([v()],W.prototype,"mode",null),t([v()],W.prototype,"filteredFormats",void 0),t([v({readOnly:!0})],W.prototype,"state",null),t([v({types:_})],W.prototype,"locationSymbol",void 0),t([v({readOnly:!0,dependsOn:["storageType"]})],W.prototype,"storage",null),t([v()],W.prototype,"storageEnabled",void 0),t([v()],W.prototype,"storageType",void 0),t([v({readOnly:!0})],W.prototype,"waitingForConversions",null),t([v()],W.prototype,"view",void 0),W=t([p("esri.widgets.CoordinateConversion.CoordinateConversionViewModel")],W);const A=W;export{A as default};
|