@arcgis/core 5.0.0-next.4 → 5.0.0-next.6
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/Map.js +1 -1
- package/analysis/ElevationProfileAnalysis.js +1 -1
- package/analysis/VolumeMeasurement/volumeMeasurementConfiguration.js +1 -1
- package/applications/KnowledgeStudio/generalSdkInternalAccess.d.ts +4 -0
- package/applications/KnowledgeStudio/generalSdkInternalAccess.js +5 -0
- package/applications/KnowledgeStudio/generalSharedKgUtils.d.ts +1 -0
- package/applications/KnowledgeStudio/generalSharedKgUtils.js +1 -1
- package/applications/KnowledgeStudio/layerInternalAccessUtils.d.ts +2 -0
- package/applications/KnowledgeStudio/layerInternalAccessUtils.js +1 -1
- package/applications/KnowledgeStudio/resourceSerializationUtils.js +1 -1
- package/assets/components/assets/sort-handle/t9n/messages.uk.json +1 -1
- package/assets/esri/core/workers/RemoteClient.js +1 -1
- package/assets/esri/core/workers/chunks/020c8913d8e35d63080b.js +1 -0
- package/assets/esri/core/workers/chunks/02e69f0c63d97661da60.js +1 -0
- package/assets/esri/core/workers/chunks/06ba43843e9c4988049b.js +1 -0
- package/assets/esri/core/workers/chunks/087973e7c4fea5fcfa5e.js +1 -0
- package/assets/esri/core/workers/chunks/{388482cea4b9fdeaf06e.js → 0f30a9514571c7be9978.js} +1 -1
- package/assets/esri/core/workers/chunks/{929ece362604dc301229.js → 17acde0245ecd956306c.js} +1 -1
- package/assets/esri/core/workers/chunks/{14ace5dc4b8984212a57.js → 17d5f8dba6ebb1184506.js} +1 -1
- package/assets/esri/core/workers/chunks/{651b9144abb1895cc510.js → 1e848d9da1c61a27cf18.js} +1 -1
- package/assets/esri/core/workers/chunks/{8cea114168d849c38b1b.js → 20278683bddc8c2d8136.js} +1 -1
- package/assets/esri/core/workers/chunks/{00aa85ae6419aad183ea.js → 22d6b8102e75bdef204c.js} +1 -1
- package/assets/esri/core/workers/chunks/279366e6b743f9680603.js +1 -0
- package/assets/esri/core/workers/chunks/285762ff92d5388b6024.js +1 -0
- package/assets/esri/core/workers/chunks/{4f01be74dd26e639330f.js → 2f24017e72d41c259faa.js} +1 -1
- package/assets/esri/core/workers/chunks/36b1f47d70b57d79df7b.js +1 -0
- package/assets/esri/core/workers/chunks/{3d65b8a2fbe1df050a25.js → 377a66034e7c1bad5599.js} +1 -1
- package/assets/esri/core/workers/chunks/37f2ef14399546e697e6.js +1 -0
- package/assets/esri/core/workers/chunks/{0f9bb3187306f89e3d63.js → 398f356b11fd33bd3831.js} +1 -1
- package/assets/esri/core/workers/chunks/3a457e718a901a45902e.js.LICENSE.txt +1 -1
- package/assets/esri/core/workers/chunks/{f7c99e9c8d19352af38d.js → 3ac7562ea90f91a9f30c.js} +1 -1
- package/assets/esri/core/workers/chunks/3f3d492f1093b7832aab.js +1 -0
- package/assets/esri/core/workers/chunks/4442817beb7a76c95770.js +1 -0
- package/assets/esri/core/workers/chunks/464d42bebb365287808d.js +1 -0
- package/assets/esri/core/workers/chunks/4c5a7249a311070d8f43.js +1 -0
- package/assets/esri/core/workers/chunks/{d570c75a425aa29672c8.js → 4d599008e1ea42321b37.js} +1 -1
- package/assets/esri/core/workers/chunks/{c0feec6e2f0e45900ae0.js → 53bd8996e8812f1ad7b2.js} +1 -1
- package/assets/esri/core/workers/chunks/{9a723d739ac44b45432c.js → 557960763695abee4a83.js} +1 -1
- package/assets/esri/core/workers/chunks/5bd36dbf46c25bd961c8.js +1 -0
- package/assets/esri/core/workers/chunks/{b7a17927e14f502006b4.js → 5ea0c62016d56990787b.js} +1 -1
- package/assets/esri/core/workers/chunks/{2ea6985da4eb0107bb9d.js → 5fc7b61f467f1d60a284.js} +1 -1
- package/assets/esri/core/workers/chunks/{a87521ebe632bf783ef4.js → 62a49cfd9a2508950e9f.js} +1 -1
- package/assets/esri/core/workers/chunks/67d9cfe02613cb73ee37.js.LICENSE.txt +1 -1
- package/assets/esri/core/workers/chunks/{ec13053af1999701464a.js → 6826fe54562dcdc054d7.js} +1 -1
- package/assets/esri/core/workers/chunks/6c3b99209d542efa64d4.js +1 -0
- package/assets/esri/core/workers/chunks/{8215015f11221a354273.js → 6d049182bec34a22abcd.js} +1 -1
- package/assets/esri/core/workers/chunks/{309c5f69ea06f3081d83.js → 73487b9d85e726e9c012.js} +1 -1
- package/assets/esri/core/workers/chunks/7413e582bc2b16af6a0f.js +1 -0
- package/assets/esri/core/workers/chunks/{3d22fe2f2c40abbc246e.js → 7461124454bfb4fb6474.js} +1 -1
- package/assets/esri/core/workers/chunks/{147ad5fdd02f46b6da24.js → 7544316a75dbd981aea6.js} +1 -1
- package/assets/esri/core/workers/chunks/75bf27271a31e26e1b21.js +1 -0
- package/assets/esri/core/workers/chunks/{630efe10c871425b6a95.js → 76ae1702fecc7ad7017c.js} +1 -1
- package/assets/esri/core/workers/chunks/{de1f75c907152df7e788.js → 794748fd1edc29a621cd.js} +1 -1
- package/assets/esri/core/workers/chunks/79dbfa2b9b332ca0002f.js +1 -0
- package/assets/esri/core/workers/chunks/7a23ab84e1144f081c92.js +1 -0
- package/assets/esri/core/workers/chunks/7aaaebbabee27690283c.js +1 -0
- package/assets/esri/core/workers/chunks/7c4a63aeead2505d6f02.js +1 -0
- package/assets/esri/core/workers/chunks/{2a5f331c0f18d8574b4e.js → 811d4c46c75cf6a63e78.js} +1 -1
- package/assets/esri/core/workers/chunks/8372f142c4d7a65c7954.js +1 -0
- package/assets/esri/core/workers/chunks/{d84373a6ec94dcfec8c2.js → 88074189fa10c335370b.js} +1 -1
- package/assets/esri/core/workers/chunks/{dc31865edea480f0ebba.js → 8833c3d168951be4bf20.js} +1 -1
- package/assets/esri/core/workers/chunks/883ffaa69b3e6eb158bf.js +1 -0
- package/assets/esri/core/workers/chunks/{85622fe99f4d08afe875.js → 8a314b3790313e6dc5db.js} +1 -1
- package/assets/esri/core/workers/chunks/{b0b2670596d6d8c32b5e.js → 8c056eac35d05d9524b7.js} +1 -1
- package/assets/esri/core/workers/chunks/{0086a09441627842d34a.js → 8f3503b2fb6cd38757b9.js} +1 -1
- package/assets/esri/core/workers/chunks/{1a713dcc9971e1935401.js → 8f56f298e7c1a283f407.js} +1 -1
- package/assets/esri/core/workers/chunks/{dabc5a38a472c9719df9.js → 8ffd4710d168c2fcfd96.js} +1 -1
- package/assets/esri/core/workers/chunks/{b2add7338258ca7c24dd.js → 90250e9239c173aace88.js} +1 -1
- package/assets/esri/core/workers/chunks/90b2b43b8b54c9a1ec35.js +1 -0
- package/assets/esri/core/workers/chunks/90f8b4bda28af43ea019.js +1 -0
- package/assets/esri/core/workers/chunks/{89027f6800e17fab8973.js → 9486032af3e934d85582.js} +1 -1
- package/assets/esri/core/workers/chunks/95c594a87b732f5c4979.js +1 -0
- package/assets/esri/core/workers/chunks/9786f91455350eaae493.js +1 -0
- package/assets/esri/core/workers/chunks/99859dce1925b406ccd0.js +1 -0
- package/assets/esri/core/workers/chunks/9c5cbf8810f37b1a4718.js +1 -0
- package/assets/esri/core/workers/chunks/9e8dceef4c961f56940d.js +1 -0
- package/assets/esri/core/workers/chunks/9fac5a12e878cd745354.js +1 -0
- package/assets/esri/core/workers/chunks/a06bac9b8f9e18874de8.js +316 -0
- package/assets/esri/core/workers/chunks/a091623bbfb3d771c8d8.js +1 -0
- package/assets/esri/core/workers/chunks/{01642fe19e81bfa33eb5.js → a395373e3173e6458a56.js} +1 -1
- package/assets/esri/core/workers/chunks/a3991ae8caa713d4ddcd.js +1 -0
- package/assets/esri/core/workers/chunks/{135e270b4f03c4270870.js → a4db5c9a90107e097df8.js} +1 -1
- package/assets/esri/core/workers/chunks/a712cdff78fc826acd8c.js +1 -0
- package/assets/esri/core/workers/chunks/a8f998b8ec8c56150479.js.LICENSE.txt +1 -1
- package/assets/esri/core/workers/chunks/aa54b6f2aba6952af149.js +1 -0
- package/assets/esri/core/workers/chunks/aa78b69219d9a0ef1c54.js.LICENSE.txt +1 -1
- package/assets/esri/core/workers/chunks/ac26e3e77df4302f47a2.js +1 -0
- package/assets/esri/core/workers/chunks/af5fc5d6c1d072a27df1.js +1 -0
- package/assets/esri/core/workers/chunks/{46ef545d2b3b3f4e6d32.js → b017bac40dc8328013e3.js} +2 -2
- package/assets/esri/core/workers/chunks/{46ef545d2b3b3f4e6d32.js.LICENSE.txt → b017bac40dc8328013e3.js.LICENSE.txt} +1 -1
- package/assets/esri/core/workers/chunks/{bc3bcf88b252760e2574.js → b3028b1ff75eafd0c358.js} +1 -1
- package/assets/esri/core/workers/chunks/b59f9c3f7a149214256f.js +1 -0
- package/assets/esri/core/workers/chunks/b96eb0ea506379182d62.js +2 -0
- package/assets/esri/core/workers/chunks/{24921d31efa8d222ad2d.js.LICENSE.txt → b96eb0ea506379182d62.js.LICENSE.txt} +1 -1
- package/assets/esri/core/workers/chunks/{b5863afafd3a7d2d5c05.js → bb5484b5eeacc9ad2ceb.js} +3 -3
- package/assets/esri/core/workers/chunks/bb56717c4e36f28d4c08.js +1 -0
- package/assets/esri/core/workers/chunks/bb7976e2f883b544add6.js +1 -0
- package/assets/esri/core/workers/chunks/{5875a51b97ee9bd438a0.js → bc241c7735e4efba734a.js} +1 -1
- package/assets/esri/core/workers/chunks/{56916e56c20465428dd4.js → be3b874f86f627f4fa98.js} +1 -1
- package/assets/esri/core/workers/chunks/{0eaa4dccba0d844b9da3.js → c3ddcf9148dd2640c402.js} +1 -1
- package/assets/esri/core/workers/chunks/c476643002387f60ea42.js +1 -0
- package/assets/esri/core/workers/chunks/c4e4da69969499a89a2c.js +1 -0
- package/assets/esri/core/workers/chunks/c8733cd621105afab2ac.js +1 -0
- package/assets/esri/core/workers/chunks/ccc0da0e01f023c8aa1f.js +1 -0
- package/assets/esri/core/workers/chunks/cd1930f08e1fc8b30b14.js +1 -0
- package/assets/esri/core/workers/chunks/ce16489cf7eb0d78c741.js.LICENSE.txt +1 -1
- package/assets/esri/core/workers/chunks/d048e4926e78458afa3e.js +1 -0
- package/assets/esri/core/workers/chunks/d1fe816b6990918c13c7.js +1 -0
- package/assets/esri/core/workers/chunks/d305a21666b1ed5bf33d.js +1 -0
- package/assets/esri/core/workers/chunks/d39a10155317e6f7a21c.js +1 -0
- package/assets/esri/core/workers/chunks/d40f57f9fc47f9a9f97c.js +1 -0
- package/assets/esri/core/workers/chunks/d6e0528eacee7ea4c1ce.js.LICENSE.txt +1 -1
- package/assets/esri/core/workers/chunks/d97fadbc69e055d183a0.js +1 -0
- package/assets/esri/core/workers/chunks/dedc4583b5f32a278124.js +1 -0
- package/assets/esri/core/workers/chunks/e31192ae920e3e19b6aa.js +1 -0
- package/assets/esri/core/workers/chunks/{e5bcc44f3dc6fc90835a.js → e5a06ce0ef6a9a90e100.js} +1 -1
- package/assets/esri/core/workers/chunks/e82f5437bd66779c6740.js +1 -0
- package/assets/esri/core/workers/chunks/f0e0a63962784acb4ba1.js +1 -0
- package/assets/esri/core/workers/chunks/{039ec0fbe3b4b398b8c6.js → f26dc1d83beed63b6045.js} +1 -1
- package/assets/esri/core/workers/chunks/{fa5c87889c2f0bef896b.js → f35aaa04cca676c2d3f8.js} +1 -1
- package/assets/esri/core/workers/chunks/f4d0ae6be1b3984228d0.js +1 -0
- package/assets/esri/core/workers/chunks/{7c5c272612198db83851.js → f5e47eea8720ba84665b.js} +1 -1
- package/assets/esri/core/workers/chunks/f651c05604eab83aef5f.js.LICENSE.txt +1 -1
- package/assets/esri/core/workers/chunks/{fa4411e0a5ac3fcba365.js → f65c0102af17390a50ac.js} +1 -1
- package/assets/esri/core/workers/chunks/f6c11c8ac687de3ef1ab.js +1 -0
- package/assets/esri/core/workers/chunks/f6c8beb60f6d29945a2e.js +1 -0
- package/assets/esri/core/workers/chunks/f746e3f7ebff2bbdf333.js +1 -0
- package/assets/esri/core/workers/chunks/f9324e88c359c03f35aa.js +1 -0
- package/assets/esri/core/workers/chunks/{cfa3164e7fa1884dc2b9.js → facb3886714222772ab2.js} +1 -1
- package/assets/esri/core/workers/chunks/fd2efd1d1cf9d95a87e6.js +1 -0
- package/assets/esri/core/workers/chunks/{fe3f95fda29e4844b153.js → fe77ae6cf232a7a3298e.js} +1 -1
- package/assets/esri/core/workers/chunks/{2ce4a0fe4fae63c43a81.js → ff35a077ac6776469805.js} +1 -1
- package/assets/esri/libs/parquet/pkg/bundle_bg.wasm +0 -0
- package/assets/esri/themes/base/widgets/_Directions.scss +17 -18
- package/assets/esri/themes/base/widgets/_UtilityNetworkTrace.scss +14 -4
- package/assets/esri/themes/dark/main.css +1 -1
- package/assets/esri/themes/light/main.css +1 -1
- package/assets/esri/themes/light/view.css +1 -1
- package/chunks/ComponentShader.glsl.js +72 -39
- package/chunks/OITBlend.glsl.js +3 -3
- package/chunks/bundle.js +1 -1
- package/config.js +1 -1
- package/core/Identifiable.js +1 -1
- package/core/MultiOriginJSONSupport.js +1 -1
- package/core/NumericIdentifiable.js +5 -0
- package/core/QueueProcessor.js +1 -1
- package/core/WriteableMultiOriginJSONMixin.js +5 -0
- package/core/has.js +1 -1
- package/core/performance.js +5 -0
- package/core/sanitizerUtils.js +1 -1
- package/core/scheduling.js +1 -1
- package/core/workers/Connection.js +1 -1
- package/core/workers/WorkerHandle.js +1 -1
- package/core/workers/utils.js +1 -1
- package/editing/sharedTemplates/executor/support/createFeatureServiceEdit.js +1 -1
- package/geohash/GeohashCell.js +1 -1
- package/geohash/geohashUtils.js +1 -1
- package/geometry/GeometryCursor.js +1 -1
- package/geometry/geometryCursorCollectUtils.js +1 -1
- package/geometry/libtess.js +1 -1
- package/geometry/support/jsonUtils.js +1 -1
- package/geometry/support/normalizeUtilsSync.js +1 -1
- package/geometry/support/triangulationUtils.js +1 -1
- package/interfaces.d.ts +444 -349
- package/intl/date.js +1 -1
- package/intl.d.ts +2 -0
- package/intl.js +1 -1
- package/kernel.js +1 -1
- package/layers/FeatureLayer.js +1 -1
- package/layers/graphics/OptimizedFeature.js +1 -1
- package/layers/graphics/OptimizedGeometry.js +1 -1
- package/layers/graphics/centroid.js +1 -1
- package/layers/graphics/contains.js +1 -1
- package/layers/graphics/data/AttributesBuilder.js +1 -1
- package/layers/graphics/data/FeatureStore.js +1 -1
- package/layers/graphics/data/QueryEngine.js +1 -1
- package/layers/graphics/data/QueryEngineResult.js +1 -1
- package/layers/graphics/data/geometryUtils.js +1 -1
- package/layers/graphics/data/spatialQuerySupport.js +1 -1
- package/layers/graphics/featureConversionUtils.js +1 -1
- package/layers/graphics/sources/OGCFeatureSource.js +1 -1
- package/layers/graphics/sources/geojson/GeoJSONSourceWorker.js +1 -1
- package/layers/graphics/sources/geojson/geojson.js +1 -1
- package/layers/graphics/sources/support/MemorySourceWorker.js +1 -1
- package/layers/graphics/sources/support/ParquetSourceWorker.js +1 -1
- package/layers/graphics/sources/support/clientSideDefaults.js +1 -1
- package/layers/knowledgeGraph/layerUtils.js +1 -1
- package/layers/mixins/ArcGISImageService.js +1 -1
- package/layers/mixins/ImageryTileMixin.js +1 -1
- package/layers/support/MediaElementBase.js +1 -1
- package/layers/support/PixelBlock.js +1 -1
- package/layers/support/RasterInfo.js +1 -1
- package/layers/support/RasterJobHandler.js +1 -1
- package/layers/support/RasterSensorInfo.js +1 -1
- package/layers/support/RasterStorageInfo.js +1 -1
- package/layers/support/RasterWorker.js +1 -1
- package/layers/support/TitleCreator.js +1 -1
- package/layers/support/arcgisLayerUrl.js +1 -1
- package/layers/support/capabilities.js +1 -1
- package/layers/support/fieldUtils.js +1 -1
- package/layers/support/rasterDatasets/BaseRaster.js +1 -1
- package/layers/support/rasterDatasets/pixelReader.js +1 -1
- package/layers/support/rasterFieldUtils.js +1 -1
- package/layers/support/rasterFunctions/pixelUtils.js +1 -1
- package/layers/support/serviceCapabilitiesUtils.js +1 -1
- package/package.json +5 -5
- package/request.js +1 -1
- package/rest/print.js +1 -1
- package/rest/query/operations/pbfDehydratedFeatureSet.js +1 -1
- package/rest/query/operations/pbfJSONFeatureSet.js +1 -1
- package/rest/query/operations/query.js +1 -1
- package/rest/query/operations/queryZScale.js +1 -1
- package/rest/versionManagement/getVersionInfos.js +1 -1
- package/smartMapping/statistics/histogram.js +1 -1
- package/smartMapping/support/adapters/FeatureLayerAdapter.js +1 -1
- package/smartMapping/support/utils.js +1 -1
- package/support/basemapDefinitions.js +1 -1
- package/support/elevationInfoUtils.js +1 -1
- package/support/requestImageUtils.js +1 -1
- package/support/revision.js +1 -1
- package/symbols/cim/effects/EffectTaperedPolygon.js +1 -1
- package/undoredo/support/Services.js +1 -1
- package/views/2d/GoToManager.js +1 -1
- package/views/2d/analysis/ElevationProfile/ElevationProfileLineVisualization2D.js +1 -1
- package/views/2d/constraints/GeometryConstraint.js +1 -1
- package/views/2d/constraints/RotationConstraint.js +1 -1
- package/views/2d/constraints/ZoomConstraint.js +1 -1
- package/views/2d/engine/vectorTiles/decluttering/SymbolFader.js +1 -1
- package/views/2d/engine/vectorTiles/shaders/sources/shaderRepository.js +1 -1
- package/views/2d/engine/webgl/Mesh2D.js +1 -1
- package/views/2d/engine/webgl/brushes/WGLBrushVTLSymbol.js +1 -1
- package/views/2d/engine/webgl/mesh/templates/templateUtils.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/animated/AnimatedMarkerMeshWriter.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/fill/AFillMeshWriter.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/labels/LabelMeshWriter.js +1 -1
- package/views/2d/layers/FeatureLayerView2D.js +1 -1
- package/views/2d/layers/features/aggregation/GridCell.js +1 -1
- package/views/2d/layers/features/processor/AAggregateStrategy.js +1 -1
- package/views/2d/layers/features/processor/BinningStrategy.js +1 -1
- package/views/2d/layers/features/processor/FeatureUpdateStrategy.js +1 -1
- package/views/2d/layers/features/processor/TrackStrategy.js +1 -1
- package/views/2d/layers/features/schema/SourceSchema.js +1 -1
- package/views/2d/layers/features/sources/FeatureSource.js +1 -1
- package/views/2d/layers/features/sources/strategies/ParquetTileLoadStrategy.js +1 -1
- package/views/2d/layers/features/sources/strategies/chunks/Overrides.js +1 -1
- package/views/2d/layers/features/sources/strategies/chunks/SourceChunkStore.js +1 -1
- package/views/2d/layers/features/support/AttributeStore.js +1 -1
- package/views/2d/layers/features/support/FeatureFilterEvaluator.js +1 -1
- package/views/2d/layers/features/support/FeatureSetReader.js +1 -1
- package/views/2d/layers/features/support/FeatureSetReaderIndirect.js +1 -1
- package/views/2d/layers/features/support/FeatureSetReaderPBF.js +1 -1
- package/views/2d/layers/features/support/FeatureSetReaderParquet.js +1 -1
- package/views/2d/layers/features/support/GraphicsReader.js +1 -1
- package/views/2d/layers/imagery/ImageryTileView2D.js +1 -1
- package/views/3d/FocusAreasView.js +1 -1
- package/views/3d/GroundView3D.js +1 -1
- package/views/3d/analysis/ElevationProfile/ElevationProfileLineSceneComputation.js +1 -1
- package/views/3d/analysis/VolumeMeasurement/VolumeMeasurementCutFillController.js +1 -1
- package/views/3d/analysis/VolumeMeasurement/VolumeMeasurementCutFillVisualization.js +1 -1
- package/views/3d/glTF/DefaultLoadingContext.js +1 -1
- package/views/3d/layers/FeatureLayerViewBase3D.js +1 -1
- package/views/3d/layers/FlowSubView3D.js +1 -1
- package/views/3d/layers/IntegratedMesh3DTilesLayerView3D.js +1 -1
- package/views/3d/layers/PointCloudLayerView3D.js +1 -1
- package/views/3d/layers/graphics/Graphics3DExtrudeSymbolLayer.js +1 -1
- package/views/3d/layers/graphics/Graphics3DFeatureStore.js +1 -1
- package/views/3d/layers/graphics/Graphics3DIconSymbolLayer.js +1 -1
- package/views/3d/layers/graphics/Graphics3DLineSymbolLayer.js +1 -1
- package/views/3d/layers/graphics/Graphics3DPolygonFillSymbolLayer.js +1 -1
- package/views/3d/layers/graphics/Graphics3DWaterSymbolLayer.js +1 -1
- package/views/3d/layers/graphics/pipeline/featureSet/PBFPointFeatureSetView.js +1 -1
- package/views/3d/layers/graphics/pipeline/featureSet/TiledFeatureStore.js +1 -1
- package/views/3d/layers/i3s/I3SIndex.js +1 -1
- package/views/3d/layers/i3s/I3SOverrides.js +1 -1
- package/views/3d/layers/i3s/I3SQueryFeatureAdapter.js +1 -1
- package/views/3d/layers/support/FeatureTileFetcher3D.js +1 -1
- package/views/3d/layers/support/FeatureTileFetcher3DContext.js +1 -1
- package/views/3d/layers/support/HeatmapFeatureProcessor.js +1 -1
- package/views/3d/layers/support/ImageHighlightHelper3D.js +1 -1
- package/views/3d/layers/support/featureTileQuery3D.js +1 -1
- package/views/3d/layers/support/lyr3dTypeConversions.js +1 -1
- package/views/3d/state/ViewStateManager.js +1 -1
- package/views/3d/state/controllers/PinchAndPanControllerGlobal.js +1 -1
- package/views/3d/state/controllers/PinchAndPanControllerLocal.js +1 -1
- package/views/3d/state/controllers/RotateController.js +1 -1
- package/views/3d/state/controllers/ZoomControllerGlobal.js +1 -1
- package/views/3d/state/controllers/ZoomControllerLocal.js +1 -1
- package/views/3d/state/controllers/ZoomStepControllerGlobal.js +1 -1
- package/views/3d/state/controllers/ZoomStepControllerLocal.js +1 -1
- package/views/3d/state/utils/navigationUtils.js +1 -1
- package/views/3d/support/DisplayQualityProfile.js +1 -1
- package/views/3d/support/QualitySettings.js +1 -1
- package/views/3d/support/StreamDataLoader.js +1 -1
- package/views/3d/support/engineContent/line.js +1 -1
- package/views/3d/support/flow/FlowSubViewExtent3D.js +1 -1
- package/views/3d/support/flow/FlowSubViewTiles3D.js +1 -1
- package/views/3d/support/flow/FlowWorker.js +1 -1
- package/views/3d/support/flow/StreamlineResources3D.js +1 -1
- package/views/3d/support/flow/StreamlineResources3DOverlay.js +1 -1
- package/views/3d/support/flow/StreamlineResources3DShape.js +1 -1
- package/views/3d/support/flow/constants.js +1 -1
- package/views/3d/support/hitTest.js +1 -1
- package/views/3d/support/renderInfoUtils/polygon.js +1 -1
- package/views/3d/terrain/OverlayRenderer.js +1 -1
- package/views/3d/terrain/Tile.js +1 -1
- package/views/3d/terrain/TileOverlayData.js +1 -1
- package/views/3d/webgl-engine/collections/Component/ComponentObject.js +1 -1
- package/views/3d/webgl-engine/collections/Component/ComponentObjectCollection.js +1 -1
- package/views/3d/webgl-engine/collections/Component/Material/ComponentMaterial.js +1 -1
- package/views/3d/webgl-engine/collections/Component/Material/ComponentTechniqueConfiguration.js +1 -1
- package/views/3d/webgl-engine/collections/Component/Material/shader/ComponentShader.glsl.js +1 -1
- package/views/3d/webgl-engine/core/shaderLibrary/terrain/Overlay.glsl.js +7 -7
- package/views/3d/webgl-engine/core/shaderModules/BooleanDrawUniform.js +5 -0
- package/views/3d/webgl-engine/core/shaderTechnique/ShaderTechniqueConstructionContext.js +1 -1
- package/views/3d/webgl-engine/lib/CutFillDepth.js +1 -1
- package/views/3d/webgl-engine/lib/Object3D.js +1 -1
- package/views/3d/webgl-engine/lib/Renderer.js +1 -1
- package/views/3d/webgl-engine/parts/RenderView.js +1 -1
- package/views/3d/webgl-engine/shaders/AnimatedLine.glsl.js +4 -4
- package/views/3d/webgl-engine/statistics/RendererPerformanceInfo.js +1 -1
- package/views/analysis/ElevationProfile/ElevationProfileController.js +1 -1
- package/views/analysis/ElevationProfile/ElevationProfileLineInputComputation.js +1 -1
- package/views/analysis/ElevationProfile/ElevationProfileResult.js +1 -1
- package/views/analysis/ElevationProfile/ElevationProfileTool.js +1 -1
- package/views/analysis/ElevationProfile/constants.js +1 -1
- package/views/analysis/ElevationProfile/elevationProfileGenerationUtils.js +1 -1
- package/views/draw/support/Reshape.js +1 -1
- package/views/draw/support/reshapeUtils.js +1 -1
- package/views/interactive/dragEventPipeline.js +1 -1
- package/views/interactive/snapping/featureSources/featureServiceSource/FeatureServiceTileStore.js +1 -1
- package/views/support/Scheduler.js +1 -1
- package/views/webgl/ShaderBuilder.js +1 -1
- package/views/webgl/Texture.js +1 -1
- package/widgets/Attachments/AttachmentsViewModel.js +1 -1
- package/widgets/BatchAttributeForm/BatchAttributeFormViewModel.js +1 -1
- package/widgets/BatchAttributeForm.js +1 -1
- package/widgets/Directions/css.js +1 -1
- package/widgets/Directions.js +1 -1
- package/widgets/Editor/AddAssociationWorkflow.js +1 -1
- package/widgets/Editor/CreateFeaturesWorkflow.js +1 -1
- package/widgets/Editor/EditorViewModel.js +1 -1
- package/widgets/Editor/Edits.js +1 -1
- package/widgets/Editor/MergeFeaturesWorkflow.d.ts +4 -0
- package/widgets/Editor/MergeFeaturesWorkflow.js +5 -0
- package/widgets/Editor/MergeFeaturesWorkflowData.d.ts +4 -0
- package/widgets/Editor/MergeFeaturesWorkflowData.js +5 -0
- package/widgets/Editor/SplitFeatureWorkflow.js +1 -1
- package/widgets/Editor/UpdateFeaturesWorkflow.js +1 -1
- package/widgets/Editor/UpdateFeaturesWorkflowData.js +1 -1
- package/widgets/Editor/UpdateRecordWorkflow.js +1 -1
- package/widgets/Editor/components/UploadDetails.js +1 -1
- package/widgets/Editor/support/EditorItem.js +1 -1
- package/widgets/Editor/support/mergeFeaturesUtils.js +5 -0
- package/widgets/Editor/workflowUtils.js +1 -1
- package/widgets/Editor.js +1 -1
- package/widgets/Feature/FeatureExpression.js +1 -1
- package/widgets/Feature/FeatureFields/FeatureFieldsViewModel.js +1 -1
- package/widgets/Feature/FeatureFields.js +1 -1
- package/widgets/Feature/FeatureMedia/FeatureMediaViewModel.js +1 -1
- package/widgets/Feature/FeatureMedia.js +1 -1
- package/widgets/Feature/FeatureViewModel.js +1 -1
- package/widgets/Feature/support/featureUtils.js +1 -1
- package/widgets/Feature.js +1 -1
- package/widgets/FeatureTable/Grid/GridViewModel.js +1 -1
- package/widgets/OrientedImageryViewer/OrientedImageryViewerViewModel.js +1 -1
- package/widgets/OrientedImageryViewer/components/SequentialNavigationUI.js +1 -1
- package/widgets/OrientedImageryViewer/components/SketchTools.js +1 -1
- package/widgets/Print.js +1 -1
- package/widgets/Search/LayerSearchSource.js +1 -1
- package/widgets/UtilityNetworkTrace.js +1 -1
- package/widgets/support/ColorPicker.js +1 -1
- package/widgets/support/SelectionList/LayerItem.js +1 -1
- package/widgets/support/jsxWidgetSupport.js +1 -1
- package/assets/esri/core/workers/chunks/0429c1a3690f20647c9f.js +0 -1
- package/assets/esri/core/workers/chunks/065f2bbcaeef1f13fd48.js +0 -1
- package/assets/esri/core/workers/chunks/0731e588afd1f561ec3b.js +0 -1
- package/assets/esri/core/workers/chunks/188272af9a6470ccfe31.js +0 -1
- package/assets/esri/core/workers/chunks/18da83afbc324fef9fd8.js +0 -316
- package/assets/esri/core/workers/chunks/1a9f544f20f643161a36.js +0 -1
- package/assets/esri/core/workers/chunks/1cfcadaa98ac528fea37.js +0 -1
- package/assets/esri/core/workers/chunks/1db0bf570a04687b3130.js +0 -1
- package/assets/esri/core/workers/chunks/24921d31efa8d222ad2d.js +0 -2
- package/assets/esri/core/workers/chunks/2a900a632a1231deb713.js +0 -1
- package/assets/esri/core/workers/chunks/31c6e951b99315e8e68a.js +0 -1
- package/assets/esri/core/workers/chunks/35491fbdd287470d40a4.js +0 -1
- package/assets/esri/core/workers/chunks/36247c6f6fc2891df2cf.js +0 -1
- package/assets/esri/core/workers/chunks/3d53307efbc3f07d7bf2.js +0 -1
- package/assets/esri/core/workers/chunks/40b81d1c2d53cf598b8e.js +0 -1
- package/assets/esri/core/workers/chunks/42a72e1d963e4636323b.js +0 -1
- package/assets/esri/core/workers/chunks/456161a323be7d640c61.js +0 -1
- package/assets/esri/core/workers/chunks/500d09d2191127371081.js +0 -1
- package/assets/esri/core/workers/chunks/50864c1924030e62497d.js +0 -1
- package/assets/esri/core/workers/chunks/5707713c2f27588b9194.js +0 -1
- package/assets/esri/core/workers/chunks/5713f96bade5ebb54c81.js +0 -1
- package/assets/esri/core/workers/chunks/5718cf135e105e1e026b.js +0 -1
- package/assets/esri/core/workers/chunks/5c585b338a9e9aa0e205.js +0 -1
- package/assets/esri/core/workers/chunks/5d1d909354c90cb8eb60.js +0 -1
- package/assets/esri/core/workers/chunks/5ea03f53d4d64d9e7cae.js +0 -1
- package/assets/esri/core/workers/chunks/63019a7eb5222dc5e420.js +0 -1
- package/assets/esri/core/workers/chunks/64629ddcf008349eaf41.js +0 -1
- package/assets/esri/core/workers/chunks/64ee8d2acae2d6fce608.js +0 -1
- package/assets/esri/core/workers/chunks/6fcacfcb3d83515c37c9.js +0 -1
- package/assets/esri/core/workers/chunks/72ecf49d03bb24bf0998.js +0 -1
- package/assets/esri/core/workers/chunks/7421f9575487cdc9e28e.js +0 -1
- package/assets/esri/core/workers/chunks/77a11d7d53325d108ed8.js +0 -1
- package/assets/esri/core/workers/chunks/7a05b1f6163112bc9db2.js +0 -1
- package/assets/esri/core/workers/chunks/7d9882ddfa6495f72baa.js +0 -1
- package/assets/esri/core/workers/chunks/7fffad8ff6878fa1fd56.js +0 -1
- package/assets/esri/core/workers/chunks/81bbe5251ed13c0d91cc.js +0 -1
- package/assets/esri/core/workers/chunks/8b16aa50d879b92a5375.js +0 -1
- package/assets/esri/core/workers/chunks/8bc64fc7c4b9eb8fca4d.js +0 -1
- package/assets/esri/core/workers/chunks/8bfa19c24be0e3f3fd74.js +0 -1
- package/assets/esri/core/workers/chunks/8eefa133c36a004c054c.js +0 -1
- package/assets/esri/core/workers/chunks/9834bc11586a2d8d6f35.js +0 -1
- package/assets/esri/core/workers/chunks/9c6fc4fe2c46f40d63d9.js +0 -1
- package/assets/esri/core/workers/chunks/a5f25104938ab33e7a85.js +0 -1
- package/assets/esri/core/workers/chunks/a7bd294996e6c8b8354a.js +0 -1
- package/assets/esri/core/workers/chunks/abf4f018c692c18c3320.js +0 -1
- package/assets/esri/core/workers/chunks/b1f667006cba60ef4aa7.js +0 -1
- package/assets/esri/core/workers/chunks/b2d9f4e057af26a538fb.js +0 -1
- package/assets/esri/core/workers/chunks/b62807c6fcfb70a87cd4.js +0 -1
- package/assets/esri/core/workers/chunks/b8339c1d60847a9eed3e.js +0 -1
- package/assets/esri/core/workers/chunks/bc6619307f312f9241bf.js +0 -1
- package/assets/esri/core/workers/chunks/bfc1e8aec7aace3ff30e.js +0 -1
- package/assets/esri/core/workers/chunks/c362fbbafec91c44eeb2.js +0 -1
- package/assets/esri/core/workers/chunks/c368a8e8d2f1535af446.js +0 -1
- package/assets/esri/core/workers/chunks/c941d15190fc08523d0d.js +0 -1
- package/assets/esri/core/workers/chunks/cc70a4a915b0b2ccb2a0.js +0 -1
- package/assets/esri/core/workers/chunks/d121045cddbe55c2ecb2.js +0 -1
- package/assets/esri/core/workers/chunks/d2120a623b1bd91b9ed9.js +0 -1
- package/assets/esri/core/workers/chunks/d78c2833cdc4730a88a3.js +0 -1
- package/assets/esri/core/workers/chunks/df438b62702007267798.js +0 -1
- package/assets/esri/core/workers/chunks/f4eb090bcc3eca64306a.js +0 -1
- package/assets/esri/core/workers/chunks/f7846523adacbfe5047e.js +0 -1
- package/assets/esri/core/workers/chunks/f839b86bee15deaf84e4.js +0 -1
package/views/webgl/Texture.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 t from"../../core/Error.js";import has from"../../core/has.js";import e from"../../core/Logger.js";import{abortMaybe as i}from"../../core/maybe.js";import{hasValue as r}from"../../core/object.js";import{throwIfAborted as s,isAbortError as o}from"../../core/promiseUtils.js";import{checkWebGLError as a}from"./checkWebGLError.js";import{ResourceType as n,CompressedTextureFormat as p}from"./enums.js";import{estimateMemory as l}from"./TextureDescriptor.js";import{isCompressedData as m,deriveInternalFormat as h,isTexImageSource as d,is3DTarget as c,validateTexture as _,isCompressedFormat as u,getDimensions as g,calcMipmapLevels as x,isSizedPixelFormat as T,isSizedDepthFormat as M,isSizedDepthStencilFormat as b}from"./textureUtils.js";import{ValidatedTextureDescriptor as f}from"./ValidatedTextureDescriptor.js";const w=null,D=!!has("esri-tests-disable-gpu-memory-measurements"),E=()=>e.getLogger("esri/views/webgl/Texture");let A=class e{static{this.TEXTURE_UNIT_FOR_UPDATES=0}static{this.compressionWorkerHandle=null}constructor(e,i=null,r=null){if(this.type=1,this._glName=null,this._samplingModeDirty=!1,this._wrapModeDirty=!1,this._shadowFilterDirty=!1,this._wasImmutablyAllocated=!1,"context"in e)this._descriptor=e,r=i;else{const r=f.validate(e,i);if(!r)throw new t("texture:invalid-descriptor","Texture descriptor invalid");this._descriptor=r}34067===this._descriptor.target?this._setDataCubeMap(r):this.setData(r)}get glName(){return this._glName}get descriptor(){return this._descriptor}get usedMemory(){return D?0:l(this._descriptor)}get isDirty(){return this._samplingModeDirty||this._wrapModeDirty||this._shadowFilterDirty}get hasWebGLTextureObject(){return!!this._glName}dispose(){this.abortCompression(),this.hasWebGLTextureObject&&this._descriptor.context?.gl&&(this._descriptor.context.instanceCounter.decrement(n.Texture,this),this._descriptor.context.unbindTexture(this),this._descriptor.context.gl.deleteTexture(this._glName),this._glName=null,this._descriptor=null)}release(){this.dispose()}[Symbol.dispose](){this.dispose()}resize(e,i){const r=this._descriptor;if(r.width!==e||r.height!==i){if(this._wasImmutablyAllocated)throw new t("texture:immutable-resize","Immutable textures can't be resized!");r.width=e,r.height=i,34067===this._descriptor.target?this._setDataCubeMap(null):this.setData(null)}}enableCompression(t){this._descriptor.compress=t}disableCompression(){this._descriptor.compress=void 0}setData(t){this.abortCompression(),!m(t)&&this._descriptor.internalFormat&&r(p,this._descriptor.internalFormat)&&(this._descriptor.internalFormat=void 0),this._setData(t),!m(t)&&this._descriptor.compress&&this._compressOnWorker(t)}updateData(i,r,s,o,a,n,p=0){n||E().error("An attempt to use uninitialized data!"),this.hasWebGLTextureObject||E().error("An attempt to update uninitialized texture!");const l=this._descriptor;l.internalFormat=h(l);const{context:c,pixelFormat:_,dataType:u,target:g,isImmutable:x}=l;if(x&&!this._wasImmutablyAllocated)throw new t("texture:uninitialized","Cannot update immutable texture before allocation!");const T=c.bindTexture(this,e.TEXTURE_UNIT_FOR_UPDATES,!0);(r<0||s<0||r+o>l.width||s+a>l.height)&&E().error("An attempt to update out of bounds of the texture!"),this._configurePixelStorage();const{gl:M}=c;p&&(o&&a||E().warn("Must pass width and height if `UNPACK_SKIP_ROWS` is used"),M.pixelStorei(M.UNPACK_SKIP_ROWS,p)),d(n)?M.texSubImage2D(g,i,r,s,o,a,_,u,n):m(n)?M.compressedTexSubImage2D(g,i,r,s,o,a,l.internalFormat,n.levels[i]):M.texSubImage2D(g,i,r,s,o,a,_,u,n),p&&M.pixelStorei(M.UNPACK_SKIP_ROWS,0),c.bindTexture(T,e.TEXTURE_UNIT_FOR_UPDATES)}updateData3D(i,r,s,o,a,n,p,l){l||E().error("An attempt to use uninitialized data!"),this.hasWebGLTextureObject||E().error("An attempt to update an uninitialized texture!");const d=this._descriptor;d.internalFormat=h(d);const{context:_,pixelFormat:u,dataType:g,isImmutable:x,target:T}=d;if(x&&!this._wasImmutablyAllocated)throw new t("texture:uninitialized","Cannot update immutable texture before allocation!");c(T)||E().warn("Attempting to set 3D texture data on a non-3D texture");const M=_.bindTexture(this,e.TEXTURE_UNIT_FOR_UPDATES);_.setActiveTexture(e.TEXTURE_UNIT_FOR_UPDATES),(r<0||s<0||o<0||r+a>d.width||s+n>d.height||o+p>d.depth)&&E().error("An attempt to update out of bounds of the texture!"),this._configurePixelStorage();const{gl:b}=_;if(m(l))l=l.levels[i],b.compressedTexSubImage3D(T,i,r,s,o,a,n,p,d.internalFormat,l);else{const t=l;b.texSubImage3D(T,i,r,s,o,a,n,p,u,g,t)}_.bindTexture(M,e.TEXTURE_UNIT_FOR_UPDATES)}generateMipmap(){const i=this._descriptor;if(0===i.width||0===i.height)return;if(!i.hasMipmap){if(this._wasImmutablyAllocated)throw new t("texture:immutable-change","Cannot add mipmaps to immutable texture after allocation");i.hasMipmap=!0,this._samplingModeDirty=!0,_(i)}9729===i.samplingMode?(this._samplingModeDirty=!0,i.samplingMode=9985):9728===i.samplingMode&&(this._samplingModeDirty=!0,i.samplingMode=9984);const r=this._descriptor.context.bindTexture(this,e.TEXTURE_UNIT_FOR_UPDATES);this._descriptor.context.setActiveTexture(e.TEXTURE_UNIT_FOR_UPDATES),this._descriptor.context.gl.generateMipmap(i.target),this._descriptor.context.bindTexture(r,e.TEXTURE_UNIT_FOR_UPDATES)}clearMipmap(){const e=this._descriptor;if(e.hasMipmap){if(this._wasImmutablyAllocated)throw new t("texture:immutable-change","Cannot delete mipmaps to immutable texture after allocation");e.hasMipmap=!1,this._samplingModeDirty=!0,_(e)}9985===e.samplingMode?(this._samplingModeDirty=!0,e.samplingMode=9729):9984===e.samplingMode&&(this._samplingModeDirty=!0,e.samplingMode=9728)}setSamplingMode(t){t!==this._descriptor.samplingMode&&(this._descriptor.samplingMode=t,this._samplingModeDirty=!0)}setWrapMode(t){t!==this._descriptor.wrapMode&&(this._descriptor.wrapMode=t,_(this._descriptor),this._wrapModeDirty=!0)}setShadowFiltering(t){t!==this._descriptor.linearFilterDepth&&(this._descriptor.linearFilterDepth=this._descriptor.compareEnabled=t,this.setSamplingMode(t?9729:9728),_(this._descriptor),this._shadowFilterDirty=!0)}applyChanges(){this._samplingModeDirty&&(this._applySamplingMode(),this._samplingModeDirty=!1),this._wrapModeDirty&&(this._applyWrapMode(),this._wrapModeDirty=!1),this._shadowFilterDirty&&(this._applyShadowMode(),this._shadowFilterDirty=!1)}abortCompression(){this._compressionAbortController=i(this._compressionAbortController)}_setData(i,r){const s=this._descriptor,o=s.context?.gl;if(!o)return;a(o),this.hasWebGLTextureObject||(this._glName=o.createTexture(),s.context.instanceCounter.increment(n.Texture,this)),_(s);const p=s.context.bindTexture(this,e.TEXTURE_UNIT_FOR_UPDATES);s.context.setActiveTexture(e.TEXTURE_UNIT_FOR_UPDATES),this._configurePixelStorage(),a(o);const l=r??s.target,g=c(l);if(d(i))this._setDataFromTexImageSource(i,l);else{const{width:e,height:r,depth:n}=s;if(null==e||null==r)throw new t("texture:missing-size","Width and height must be specified!");if(g&&null==n)throw new t("texture:missing-depth","Depth must be specified!");if(s.internalFormat=h(s),s.isImmutable&&!this._wasImmutablyAllocated&&this._texStorage(l,s.internalFormat,s.hasMipmap,e,r,n),m(i)){if(!u(s.internalFormat))throw new t("texture:format-mismatch","Attempting to use compressed data with an uncompressed format!");this._setDataFromCompressedSource(i,s.internalFormat,l)}else this._texImage(l,0,s.internalFormat,e,r,n,i),a(o),s.hasMipmap&&this.generateMipmap()}this._applySamplingMode(),this._applyWrapMode(),this._applyAnisotropicFilteringParameters(),this._applyShadowMode(),a(o),s.context.bindTexture(p,e.TEXTURE_UNIT_FOR_UPDATES)}_setDataCubeMap(t=null){for(let e=34069;e<=34074;e++)this._setData(t,e)}_configurePixelStorage(){const t=this._descriptor.context.gl,{unpackAlignment:e,flipped:i,preMultiplyAlpha:r}=this._descriptor;t.pixelStorei(t.UNPACK_ALIGNMENT,e),t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,i?1:0),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,r?1:0)}_setDataFromTexImageSource(t,e){const{gl:i}=this._descriptor.context,r=this._descriptor;r.internalFormat=h(r);const s=c(e),{width:o,height:n,depth:p}=g(t);r.width&&r.height,r.width||(r.width=o),r.height||(r.height=n),s&&r.depth,s&&(r.depth=p),r.isImmutable&&!this._wasImmutablyAllocated&&this._texStorage(e,r.internalFormat,r.hasMipmap,o,n,p),this._texImage(e,0,r.internalFormat,o,n,p,t),a(i),r.hasMipmap&&(this.generateMipmap(),a(i))}_setDataFromCompressedSource(t,e,i){const r=this._descriptor,{width:s,height:o,depth:a}=r,n=t.levels,p=x(i,s,o,a),l=Math.min(p,n.length)-1;this._descriptor.context.gl.texParameteri(r.target,33085,l),this._forEachMipmapLevel((t,r,s,o)=>{const a=n[Math.min(t,n.length-1)];this._compressedTexImage(i,t,e,r,s,o,a)},l)}_texStorage(e,i,r,s,o,a){const{gl:n}=this._descriptor.context;if(!T(i)&&!M(i)&&!b(i))throw new t("texture:missing-format","Immutable textures must have a sized internal format");if(!this._descriptor.isImmutable)return;const p=r?x(e,s,o,a):1;if(c(e)){if(null==a)throw new t("texture:missing-depth","Missing depth dimension for 3D texture upload");n.texStorage3D(e,p,i,s,o,a)}else n.texStorage2D(e,p,i,s,o);this._wasImmutablyAllocated=!0}_texImage(e,i,r,s,o,a,n){const p=this._descriptor.context.gl,l=c(e),{isImmutable:m,pixelFormat:h,dataType:d}=this._descriptor;if(m){if(null!=n){const r=n;if(l){if(null==a)throw new t("texture:missing-depth","Missing depth dimension for 3D texture upload");p.texSubImage3D(e,i,0,0,0,s,o,a,h,d,r)}else p.texSubImage2D(e,i,0,0,s,o,h,d,r)}}else{const m=n;if(l){if(null==a)throw new t("texture:missing-depth","Missing depth dimension for 3D texture upload");p.texImage3D(e,i,r,s,o,a,0,h,d,m)}else p.texImage2D(e,i,r,s,o,0,h,d,m)}}_compressedTexImage(e,i,r,s,o,a,n){const p=this._descriptor.context.gl,l=c(e);if(this._descriptor.isImmutable){if(null!=n)if(l){if(null==a)throw new t("texture:missing-depth","Missing depth dimension for 3D texture upload");p.compressedTexSubImage3D(e,i,0,0,0,s,o,a,r,n)}else p.compressedTexSubImage2D(e,i,0,0,s,o,r,n)}else if(l){if(null==a)throw new t("texture:missing-depth","Missing depth dimension for 3D texture upload");p.compressedTexImage3D(e,i,r,s,o,a,0,n)}else p.compressedTexImage2D(e,i,r,s,o,0,n)}async _compressOnWorker(t){const{width:i,height:r,context:a,flipped:n,preMultiplyAlpha:p,hasMipmap:l}=this._descriptor,m=this._descriptor.compress?.compressionTracker,h=this._descriptor.compress?.compressionCallback,{compressedTextureETC:d,compressedTextureS3TC:c}=a.capabilities;if(!e.compressionWorkerHandle?.isCompressible(t,this._descriptor)||!d&&!c)return;this.abortCompression();const _=new AbortController;this._compressionAbortController=_,m?.increment();try{let o;t instanceof Uint8Array?o=t.buffer:(o=await createImageBitmap(t,{imageOrientation:n?"flipY":"none"}),s(_));const a={data:o,width:i,height:r,needsFlip:t instanceof Uint8Array&&this.descriptor.flipped,components:6408===this._descriptor.pixelFormat?4:3,preMultiplyAlpha:p,hasMipmap:l,hasETC:!!d,hasS3TC:!!c},m=await e.compressionWorkerHandle.invoke(a,_.signal,"low");if(s(_),m.compressedTexture&&this.hasWebGLTextureObject){const t=this.usedMemory;this._descriptor.internalFormat=m.internalFormat,this._setData(m.compressedTexture),h?.(t-this.usedMemory)}}catch(u){o(u)||E().error("Texture compression failed!")}finally{m?.decrement(),this._compressionAbortController?.signal.aborted&&(this._compressionAbortController=null)}}_forEachMipmapLevel(e,i=1/0){let{width:r,height:s,depth:o,hasMipmap:a,target:n}=this._descriptor;const p=32879===n;if(null==r||null==s||p&&null==o)throw new t("texture:missing-size","Missing texture dimensions for mipmap calculation");for(let t=0;e(t,r,s,o),a&&(1!==r||1!==s||p&&1!==o)&&!(t>=i);++t)r=Math.max(1,r>>1),s=Math.max(1,s>>1),p&&(o=Math.max(1,o>>1))}_applySamplingMode(){const t=this._descriptor,e=t.context?.gl;let i=t.samplingMode,r=t.samplingMode;9985===i||9987===i?(i=9729,t.hasMipmap||(r=9729)):9984!==i&&9986!==i||(i=9728,t.hasMipmap||(r=9728)),e.texParameteri(t.target,e.TEXTURE_MAG_FILTER,i),e.texParameteri(t.target,e.TEXTURE_MIN_FILTER,r)}_applyWrapMode(){const t=this._descriptor,e=t.context?.gl;"number"==typeof t.wrapMode?(e.texParameteri(t.target,e.TEXTURE_WRAP_S,t.wrapMode),e.texParameteri(t.target,e.TEXTURE_WRAP_T,t.wrapMode)):(e.texParameteri(t.target,e.TEXTURE_WRAP_S,t.wrapMode.s),e.texParameteri(t.target,e.TEXTURE_WRAP_T,t.wrapMode.t))}_applyShadowMode(){const t=this._descriptor,e=t.context?.gl,i=t.compareEnabled?e.COMPARE_REF_TO_TEXTURE:e.NONE;e.texParameteri(t.target,e.TEXTURE_COMPARE_MODE,i),t.compareEnabled&&e.texParameteri(t.target,e.TEXTURE_COMPARE_FUNC,e.GREATER),a(e)}_applyAnisotropicFilteringParameters(){const t=this._descriptor,e=t.context.capabilities.textureFilterAnisotropic;if(!e)return;t.context.gl.texParameterf(t.target,e.TEXTURE_MAX_ANISOTROPY,t.maxAnisotropy??1)}};export{A as Texture,w as tracer};
|
|
5
|
+
import t from"../../core/Error.js";import has from"../../core/has.js";import e from"../../core/Logger.js";import{abortMaybe as i}from"../../core/maybe.js";import{hasValue as r}from"../../core/object.js";import{throwIfAborted as s,isAbortError as o}from"../../core/promiseUtils.js";import{checkWebGLError as a}from"./checkWebGLError.js";import{ResourceType as n,CompressedTextureFormat as p}from"./enums.js";import{estimateMemory as l}from"./TextureDescriptor.js";import{isCompressedData as m,deriveInternalFormat as h,isTexImageSource as d,is3DTarget as c,validateTexture as _,isCompressedFormat as u,getDimensions as g,calcMipmapLevels as x,isSizedPixelFormat as T,isSizedDepthFormat as M,isSizedDepthStencilFormat as b}from"./textureUtils.js";import{ValidatedTextureDescriptor as f}from"./ValidatedTextureDescriptor.js";const w=null,D=!!has("esri-tests-disable-gpu-memory-measurements"),E=()=>e.getLogger("esri/views/webgl/Texture");let A=class e{static{this.TEXTURE_UNIT_FOR_UPDATES=0}static{this.compressionWorkerHandle=null}constructor(e,i=null,r=null){if(this.type=1,this._glName=null,this._samplingModeDirty=!1,this._wrapModeDirty=!1,this._shadowFilterDirty=!1,this._wasImmutablyAllocated=!1,"context"in e)this._descriptor=e,r=i;else{const r=f.validate(e,i);if(!r)throw new t("texture:invalid-descriptor","Texture descriptor invalid");this._descriptor=r}34067===this._descriptor.target?this._setDataCubeMap(r):this.setData(r)}get glName(){return this._glName}get descriptor(){return this._descriptor}get usedMemory(){return D?0:l(this._descriptor)}get isDirty(){return this._samplingModeDirty||this._wrapModeDirty||this._shadowFilterDirty}get hasWebGLTextureObject(){return!!this._glName}dispose(){this.abortCompression(),this.hasWebGLTextureObject&&this._descriptor.context?.gl&&(this._descriptor.context.instanceCounter.decrement(n.Texture,this),this._descriptor.context.unbindTexture(this),this._descriptor.context.gl.deleteTexture(this._glName),this._glName=null,this._descriptor=null)}release(){this.dispose()}[Symbol.dispose](){this.dispose()}resize(e,i){const r=this._descriptor;if(r.width!==e||r.height!==i){if(this._wasImmutablyAllocated)throw new t("texture:immutable-resize","Immutable textures can't be resized!");r.width=e,r.height=i,34067===this._descriptor.target?this._setDataCubeMap(null):this.setData(null)}}enableCompression(t){this._descriptor.compress=t}disableCompression(){this._descriptor.compress=void 0}setData(t){this.abortCompression(),!m(t)&&this._descriptor.internalFormat&&r(p,this._descriptor.internalFormat)&&(this._descriptor.internalFormat=void 0),this._setData(t),!m(t)&&this._descriptor.compress&&this._compressOnWorker(t)}updateData(i,r,s,o,a,n,p=0){n||E().error("An attempt to use uninitialized data!"),this.hasWebGLTextureObject||E().error("An attempt to update uninitialized texture!");const l=this._descriptor;l.internalFormat=h(l);const{context:c,pixelFormat:_,dataType:u,target:g,isImmutable:x}=l;if(x&&!this._wasImmutablyAllocated)throw new t("texture:uninitialized","Cannot update immutable texture before allocation!");const T=c.bindTexture(this,e.TEXTURE_UNIT_FOR_UPDATES,!0);(r<0||s<0||r+o>l.width||s+a>l.height)&&E().error("An attempt to update out of bounds of the texture!"),this._configurePixelStorage();const{gl:M}=c;p&&(o&&a||E().warn("Must pass width and height if `UNPACK_SKIP_ROWS` is used"),M.pixelStorei(M.UNPACK_SKIP_ROWS,p)),d(n)?M.texSubImage2D(g,i,r,s,o,a,_,u,n):m(n)?M.compressedTexSubImage2D(g,i,r,s,o,a,l.internalFormat,n.levels[i]):M.texSubImage2D(g,i,r,s,o,a,_,u,n),p&&M.pixelStorei(M.UNPACK_SKIP_ROWS,0),c.bindTexture(T,e.TEXTURE_UNIT_FOR_UPDATES)}updateData3D(i,r,s,o,a,n,p,l){l||E().error("An attempt to use uninitialized data!"),this.hasWebGLTextureObject||E().error("An attempt to update an uninitialized texture!");const d=this._descriptor;d.internalFormat=h(d);const{context:_,pixelFormat:u,dataType:g,isImmutable:x,target:T}=d;if(x&&!this._wasImmutablyAllocated)throw new t("texture:uninitialized","Cannot update immutable texture before allocation!");c(T)||E().warn("Attempting to set 3D texture data on a non-3D texture");const M=_.bindTexture(this,e.TEXTURE_UNIT_FOR_UPDATES);_.setActiveTexture(e.TEXTURE_UNIT_FOR_UPDATES),(r<0||s<0||o<0||r+a>d.width||s+n>d.height||o+p>d.depth)&&E().error("An attempt to update out of bounds of the texture!"),this._configurePixelStorage();const{gl:b}=_;if(m(l))l=l.levels[i],b.compressedTexSubImage3D(T,i,r,s,o,a,n,p,d.internalFormat,l);else{const t=l;b.texSubImage3D(T,i,r,s,o,a,n,p,u,g,t)}_.bindTexture(M,e.TEXTURE_UNIT_FOR_UPDATES)}generateMipmap(){const i=this._descriptor;if(0===i.width||0===i.height)return;if(!i.hasMipmap){if(this._wasImmutablyAllocated)throw new t("texture:immutable-change","Cannot add mipmaps to immutable texture after allocation");i.hasMipmap=!0,this._samplingModeDirty=!0,_(i)}9729===i.samplingMode?(this._samplingModeDirty=!0,i.samplingMode=9985):9728===i.samplingMode&&(this._samplingModeDirty=!0,i.samplingMode=9984);const r=this._descriptor.context.bindTexture(this,e.TEXTURE_UNIT_FOR_UPDATES);this._descriptor.context.setActiveTexture(e.TEXTURE_UNIT_FOR_UPDATES),this._descriptor.context.gl.generateMipmap(i.target),this._descriptor.context.bindTexture(r,e.TEXTURE_UNIT_FOR_UPDATES)}clearMipmap(){const e=this._descriptor;if(e.hasMipmap){if(this._wasImmutablyAllocated)throw new t("texture:immutable-change","Cannot delete mipmaps to immutable texture after allocation");e.hasMipmap=!1,this._samplingModeDirty=!0,_(e)}9985===e.samplingMode?(this._samplingModeDirty=!0,e.samplingMode=9729):9984===e.samplingMode&&(this._samplingModeDirty=!0,e.samplingMode=9728)}setSamplingMode(t){t!==this._descriptor.samplingMode&&(this._descriptor.samplingMode=t,this._samplingModeDirty=!0)}setWrapMode(t){t!==this._descriptor.wrapMode&&(this._descriptor.wrapMode=t,_(this._descriptor),this._wrapModeDirty=!0)}setShadowFiltering(t){t!==this._descriptor.linearFilterDepth&&(this._descriptor.linearFilterDepth=this._descriptor.compareEnabled=t,this.setSamplingMode(t?9729:9728),_(this._descriptor),this._shadowFilterDirty=!0)}applyChanges(){this._samplingModeDirty&&(this._applySamplingMode(),this._samplingModeDirty=!1),this._wrapModeDirty&&(this._applyWrapMode(),this._wrapModeDirty=!1),this._shadowFilterDirty&&(this._applyShadowMode(),this._shadowFilterDirty=!1)}abortCompression(){this._compressionAbortController=i(this._compressionAbortController)}_setData(i,r){const s=this._descriptor,o=s.context?.gl;if(!o)return;a(o),this.hasWebGLTextureObject||(this._glName=o.createTexture(),s.context.instanceCounter.increment(n.Texture,this)),_(s);const p=s.context.bindTexture(this,e.TEXTURE_UNIT_FOR_UPDATES);s.context.setActiveTexture(e.TEXTURE_UNIT_FOR_UPDATES),this._configurePixelStorage(),a(o);const l=r??s.target,g=c(l);if(d(i))this._setDataFromTexImageSource(i,l);else{const{width:e,height:r,depth:n}=s;if(null==e||null==r)throw new t("texture:missing-size","Width and height must be specified!");if(g&&null==n)throw new t("texture:missing-depth","Depth must be specified!");if(s.internalFormat=h(s),s.isImmutable&&!this._wasImmutablyAllocated&&this._texStorage(l,s.internalFormat,s.hasMipmap,e,r,n),m(i)){if(!u(s.internalFormat))throw new t("texture:format-mismatch","Attempting to use compressed data with an uncompressed format!");this._setDataFromCompressedSource(i,s.internalFormat,l)}else this._texImage(l,0,s.internalFormat,e,r,n,i),a(o),s.hasMipmap&&this.generateMipmap()}this._applySamplingMode(),this._applyWrapMode(),this._applyAnisotropicFilteringParameters(),this._applyShadowMode(),a(o),s.context.bindTexture(p,e.TEXTURE_UNIT_FOR_UPDATES)}_setDataCubeMap(t=null){for(let e=34069;e<=34074;e++)this._setData(t,e)}_configurePixelStorage(){const t=this._descriptor.context.gl,{unpackAlignment:e,flipped:i,preMultiplyAlpha:r}=this._descriptor;t.pixelStorei(t.UNPACK_ALIGNMENT,e),t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,i?1:0),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,r?1:0)}_setDataFromTexImageSource(t,e){const{gl:i}=this._descriptor.context,r=this._descriptor;r.internalFormat=h(r);const s=c(e),{width:o,height:n,depth:p}=g(t);r.width&&r.height,r.width||(r.width=o),r.height||(r.height=n),s&&r.depth,s&&(r.depth=p),r.isImmutable&&!this._wasImmutablyAllocated&&this._texStorage(e,r.internalFormat,r.hasMipmap,o,n,p),this._texImage(e,0,r.internalFormat,o,n,p,t),a(i),r.hasMipmap&&(this.generateMipmap(),a(i))}_setDataFromCompressedSource(t,e,i){const r=this._descriptor,{width:s,height:o,depth:a}=r,n=t.levels,p=x(i,s,o,a),l=Math.min(p,n.length)-1;this._descriptor.context.gl.texParameteri(r.target,33085,l),this._forEachMipmapLevel((t,r,s,o)=>{const a=n[Math.min(t,n.length-1)];this._compressedTexImage(i,t,e,r,s,o,a)},l)}_texStorage(e,i,r,s,o,a){const{gl:n}=this._descriptor.context;if(!T(i)&&!M(i)&&!b(i))throw new t("texture:missing-format","Immutable textures must have a sized internal format");if(!this._descriptor.isImmutable)return;const p=r?x(e,s,o,a):1;if(c(e)){if(null==a)throw new t("texture:missing-depth","Missing depth dimension for 3D texture upload");n.texStorage3D(e,p,i,s,o,a)}else n.texStorage2D(e,p,i,s,o);this._wasImmutablyAllocated=!0}_texImage(e,i,r,s,o,a,n){const p=this._descriptor.context.gl,l=c(e),{isImmutable:m,pixelFormat:h,dataType:d}=this._descriptor;if(m){if(null!=n){const r=n;if(l){if(null==a)throw new t("texture:missing-depth","Missing depth dimension for 3D texture upload");p.texSubImage3D(e,i,0,0,0,s,o,a,h,d,r)}else p.texSubImage2D(e,i,0,0,s,o,h,d,r)}}else{const m=n;if(l){if(null==a)throw new t("texture:missing-depth","Missing depth dimension for 3D texture upload");p.texImage3D(e,i,r,s,o,a,0,h,d,m)}else p.texImage2D(e,i,r,s,o,0,h,d,m)}}_compressedTexImage(e,i,r,s,o,a,n){const p=this._descriptor.context.gl,l=c(e);if(this._descriptor.isImmutable){if(null!=n)if(l){if(null==a)throw new t("texture:missing-depth","Missing depth dimension for 3D texture upload");p.compressedTexSubImage3D(e,i,0,0,0,s,o,a,r,n)}else p.compressedTexSubImage2D(e,i,0,0,s,o,r,n)}else if(l){if(null==a)throw new t("texture:missing-depth","Missing depth dimension for 3D texture upload");p.compressedTexImage3D(e,i,r,s,o,a,0,n)}else p.compressedTexImage2D(e,i,r,s,o,0,n)}async _compressOnWorker(t){const{width:i,height:r,context:a,flipped:n,preMultiplyAlpha:p,hasMipmap:l}=this._descriptor,m=this._descriptor.compress?.compressionTracker,h=this._descriptor.compress?.compressionCallback,{compressedTextureETC:d,compressedTextureS3TC:c}=a.capabilities;if(!e.compressionWorkerHandle?.isCompressible(t,this._descriptor)||!d&&!c)return;this.abortCompression();const _=new AbortController;this._compressionAbortController=_,m?.increment();try{let o;t instanceof Uint8Array?o=t.buffer:(o=await createImageBitmap(t,{imageOrientation:n?"flipY":"none"}),s(_));const a={data:o,width:i,height:r,needsFlip:t instanceof Uint8Array&&this.descriptor.flipped,components:6408===this._descriptor.pixelFormat?4:3,preMultiplyAlpha:p,hasMipmap:l,hasETC:!!d,hasS3TC:!!c},m=await e.compressionWorkerHandle.invoke(a,_.signal,1);if(s(_),m.compressedTexture&&this.hasWebGLTextureObject){const t=this.usedMemory;this._descriptor.internalFormat=m.internalFormat,this._setData(m.compressedTexture),h?.(t-this.usedMemory)}}catch(u){o(u)||E().error("Texture compression failed!")}finally{m?.decrement(),this._compressionAbortController?.signal.aborted&&(this._compressionAbortController=null)}}_forEachMipmapLevel(e,i=1/0){let{width:r,height:s,depth:o,hasMipmap:a,target:n}=this._descriptor;const p=32879===n;if(null==r||null==s||p&&null==o)throw new t("texture:missing-size","Missing texture dimensions for mipmap calculation");for(let t=0;e(t,r,s,o),a&&(1!==r||1!==s||p&&1!==o)&&!(t>=i);++t)r=Math.max(1,r>>1),s=Math.max(1,s>>1),p&&(o=Math.max(1,o>>1))}_applySamplingMode(){const t=this._descriptor,e=t.context?.gl;let i=t.samplingMode,r=t.samplingMode;9985===i||9987===i?(i=9729,t.hasMipmap||(r=9729)):9984!==i&&9986!==i||(i=9728,t.hasMipmap||(r=9728)),e.texParameteri(t.target,e.TEXTURE_MAG_FILTER,i),e.texParameteri(t.target,e.TEXTURE_MIN_FILTER,r)}_applyWrapMode(){const t=this._descriptor,e=t.context?.gl;"number"==typeof t.wrapMode?(e.texParameteri(t.target,e.TEXTURE_WRAP_S,t.wrapMode),e.texParameteri(t.target,e.TEXTURE_WRAP_T,t.wrapMode)):(e.texParameteri(t.target,e.TEXTURE_WRAP_S,t.wrapMode.s),e.texParameteri(t.target,e.TEXTURE_WRAP_T,t.wrapMode.t))}_applyShadowMode(){const t=this._descriptor,e=t.context?.gl,i=t.compareEnabled?e.COMPARE_REF_TO_TEXTURE:e.NONE;e.texParameteri(t.target,e.TEXTURE_COMPARE_MODE,i),t.compareEnabled&&e.texParameteri(t.target,e.TEXTURE_COMPARE_FUNC,e.GREATER),a(e)}_applyAnisotropicFilteringParameters(){const t=this._descriptor,e=t.context.capabilities.textureFilterAnisotropic;if(!e)return;t.context.gl.texParameterf(t.target,e.TEXTURE_MAX_ANISOTROPY,t.maxAnisotropy??1)}};export{A as Texture,w as tracer};
|
|
@@ -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 a from"../../core/Accessor.js";import i from"../../core/Collection.js";import n from"../../core/Error.js";import{watch as r,initial as s}from"../../core/reactiveUtils.js";import{property as o}from"../../core/accessorSupport/decorators/property.js";import{cast as c}from"../../core/accessorSupport/decorators/cast.js";import"../../core/has.js";import"../../core/RandomLCG.js";import{subclass as h}from"../../core/accessorSupport/decorators/subclass.js";import d from"../../popup/support/AttachmentsOrderByInfo.js";import l from"../../rest/query/support/AttachmentInfo.js";import p from"../../rest/support/AttachmentQuery.js";import{getSourceLayer as m}from"../Feature/support/featureUtils.js";const u={editing:!1,operations:{add:!0,update:!0,delete:!0}},f=i.ofType(l);let y=class extends a{constructor(t){super(t),this._getAttachmentsPromise=null,this._attachmentLayer=null,this.attachmentKeywords=null,this.attachmentTypes=null,this.capabilities={...u},this.activeAttachmentInfo=null,this.activeFileInfo=null,this.attachmentInfos=new f,this.fileInfos=new i,this.graphic=null,this.mode="view",this.orderByFields=null,this.filesEnabled=!1,this.addHandles(r(()=>this.graphic,()=>this._graphicChanged(),s))}destroy(){this._attachmentLayer=null,this.graphic=null}castCapabilities(t){return{...u,...t}}get state(){return this._getAttachmentsPromise?"loading":this.graphic?"ready":"disabled"}get supportsResizeAttachments(){const{graphic:t}=this;if(!t)return!1;const e=t.layer||t.sourceLayer;return e?.loaded&&"capabilities"in e&&e.capabilities&&"attachment"in e.capabilities&&e.capabilities.attachment&&"supportsResize"in e.capabilities.attachment&&e.capabilities.attachment.supportsResize||!1}get supportsTypeWildcard(){const{graphic:t}=this;if(!t)return!1;const e=t.layer||t.sourceLayer;return e?.loaded&&"capabilities"in e&&e.capabilities&&"attachment"in e.capabilities&&e.capabilities.attachment&&"supportsResize"in e.capabilities.attachment&&e.capabilities.attachment.supportsTypeWildcard||!1}async getAttachments(){const{_attachmentLayer:t,attachmentInfos:e,orderByFields:a,attachmentTypes:i,attachmentKeywords:r,supportsTypeWildcard:s}=this;if(!t||"function"!=typeof t.queryAttachments)throw new n("invalid-layer","getAttachments(): A valid layer is required.");const o=this._getObjectId();if("number"!=typeof o)throw new n("invalid-object-id","getAttachments(): Numeric object id is required");const c=a?.map(t=>`${t.field} ${"descending"===t.order?"DESC":"ASC"}`),h=new p({objectIds:[o],returnMetadata:!0,orderByFields:c,attachmentTypes:s?i?.map(t=>`${t}/*`):void 0,keywords:r}),d=[],l=t.queryAttachments(h).then(t=>t[o]||d).catch(()=>d);this._getAttachmentsPromise=l,this.notifyChange("state");const m=await l;return e.destroyAll(),m.length&&e.addMany(m),this._getAttachmentsPromise=null,this.notifyChange("state"),m}async addAttachment(t,e=this.graphic){const{_attachmentLayer:a,attachmentInfos:i,capabilities:r}=this;if(!e)throw new n("invalid-graphic","addAttachment(): A valid graphic is required.",{graphic:e});if(!t)throw new n("invalid-attachment","addAttachment(): An attachment is required.",{attachment:t});if(!r.operations?.add)throw new n("invalid-capabilities","addAttachment(): add capabilities are required.");if(!a||"function"!=typeof a.addAttachment)throw new n("invalid-layer","addAttachment(): A valid layer is required.");const s=a.addAttachment(e,t).then(t=>this._queryAttachment(t.objectId,e)),o=await s;return i.add(o),o}async deleteAttachment(t){const{_attachmentLayer:e,attachmentInfos:a,graphic:i,capabilities:r}=this;if(!t)throw new n("invalid-attachment-info","deleteAttachment(): An attachmentInfo is required.",{attachmentInfo:t});if(!r.operations?.delete)throw new n("invalid-capabilities","deleteAttachment(): delete capabilities are required.");if(!e||"function"!=typeof e.deleteAttachments)throw new n("invalid-layer","deleteAttachment(): A valid layer is required.");if(!i)throw new n("invalid-graphic","deleteAttachment(): A graphic is required.");const s=e.deleteAttachments(i,[t.id]).then(()=>t),o=await s;return a.remove(o),o.destroy(),o}async updateAttachment(t,e=this.activeAttachmentInfo){const{_attachmentLayer:a,attachmentInfos:i,graphic:r,capabilities:s}=this;if(!t)throw new n("invalid-attachment","updateAttachment(): An attachment is required.",{attachment:t});if(!e)throw new n("invalid-attachment-info","updateAttachment(): An attachmentInfo is required.",{attachmentInfo:e});if(!s.operations?.update)throw new n("invalid-capabilities","updateAttachment(): Update capabilities are required.");const o=i.indexOf(e);if(!a||"function"!=typeof a.updateAttachment)throw new n("invalid-layer","updateAttachment(): A valid layer is required.");if(!r)throw new n("invalid-graphic","updateAttachment(): A graphic is required.");const c=a.updateAttachment(r,e.id,t).then(t=>this._queryAttachment(t.objectId)),h=await c;return i.splice(o,1,h),h}async commitFiles(){return await Promise.all(this.fileInfos.items.map(t=>this.addAttachment(t.form))),this.fileInfos.removeAll(),this.getAttachments()}addFile(t,e){if(!t||!e)return null;const a={file:t,form:e};return this.fileInfos.add(a),a}updateFile(t,e,a=this.activeFileInfo){if(!t||!e||!a)return null;const i=this.fileInfos.indexOf(a);return i>-1&&this.fileInfos.splice(i,1,{file:t,form:e}),this.fileInfos.items[i]}deleteFile(t){const e=this.fileInfos.find(e=>e.file===t);return e?(this.fileInfos.remove(e),e):null}async _queryAttachment(t,e){const{_attachmentLayer:a}=this;if(!t||!a?.queryAttachments)throw new n("invalid-attachment-id","Could not query attachment.");const i=this._getObjectId(e);if("number"!=typeof i)throw new n("invalid-object-id","getAttachments(): Numeric object id is required");const r=new p({objectIds:[i],attachmentsWhere:`AttachmentId=${t}`,returnMetadata:!0});return a.queryAttachments(r).then(t=>t[i][0])}_getObjectId(t=this.graphic){return t?.getObjectId()??null}_graphicChanged(){this.graphic&&(this._setAttachmentLayer(),this.getAttachments().catch(()=>this.attachmentInfos.destroyAll()))}_setAttachmentLayer(){const{graphic:t}=this,e=m(t);this._attachmentLayer=e?"scene"===e.type&&null!=e.associatedLayer?e.associatedLayer:e:null}};t([o({type:[String]})],y.prototype,"attachmentKeywords",void 0),t([o({type:[["application","audio","image","model","text","video"]]})],y.prototype,"attachmentTypes",void 0),t([o()],y.prototype,"capabilities",void 0),t([c("capabilities")],y.prototype,"castCapabilities",null),t([o()],y.prototype,"activeAttachmentInfo",void 0),t([o()],y.prototype,"activeFileInfo",void 0),t([o({readOnly:!0,type:f})],y.prototype,"attachmentInfos",void 0),t([o()],y.prototype,"fileInfos",void 0),t([o({type:e})],y.prototype,"graphic",void 0),t([o()],y.prototype,"mode",void 0),t([o({type:[d]})],y.prototype,"orderByFields",void 0),t([o({readOnly:!0})],y.prototype,"state",null),t([o()],y.prototype,"filesEnabled",void 0),t([o({readOnly:!0})],y.prototype,"supportsResizeAttachments",null),t([o({readOnly:!0})],y.prototype,"supportsTypeWildcard",null),y=t([h("esri.widgets.Attachments.AttachmentsViewModel")],y);export{y as default};
|
|
5
|
+
import{__decorate as t}from"tslib";import e from"../../Graphic.js";import a from"../../core/Accessor.js";import i from"../../core/Collection.js";import n from"../../core/Error.js";import{watch as r,initial as s}from"../../core/reactiveUtils.js";import{property as o}from"../../core/accessorSupport/decorators/property.js";import{cast as c}from"../../core/accessorSupport/decorators/cast.js";import"../../core/has.js";import"../../core/RandomLCG.js";import{subclass as h}from"../../core/accessorSupport/decorators/subclass.js";import d from"../../popup/support/AttachmentsOrderByInfo.js";import l from"../../rest/query/support/AttachmentInfo.js";import p from"../../rest/support/AttachmentQuery.js";import{getSourceLayer as m}from"../Feature/support/featureUtils.js";const u={editing:!1,operations:{add:!0,update:!0,delete:!0}},f=i.ofType(l);let y=class extends a{constructor(t){super(t),this._getAttachmentsPromise=null,this._attachmentLayer=null,this.attachmentKeywords=null,this.attachmentTypes=null,this.capabilities={...u},this.activeAttachmentInfo=null,this.activeFileInfo=null,this.attachmentInfos=new f,this.fileInfos=new i,this.graphic=null,this.mode="view",this.orderByFields=null,this.filesEnabled=!1,this.addHandles(r(()=>this.graphic,()=>this._graphicChanged(),s))}destroy(){this._attachmentLayer=null,this.graphic=null}castCapabilities(t){return{...u,...t}}get state(){return this._getAttachmentsPromise?"loading":this.graphic?"ready":"disabled"}get supportsResizeAttachments(){const{graphic:t}=this;if(!t)return!1;const e=t.layer||t.sourceLayer;return e?.loaded&&"capabilities"in e&&e.capabilities&&"attachment"in e.capabilities&&e.capabilities.attachment&&"supportsResize"in e.capabilities.attachment&&e.capabilities.attachment.supportsResize||!1}get supportsTypeWildcard(){const{graphic:t}=this;if(!t)return!1;const e=t.layer||t.sourceLayer;return e?.loaded&&"capabilities"in e&&e.capabilities&&"attachment"in e.capabilities&&e.capabilities.attachment&&"supportsResize"in e.capabilities.attachment&&e.capabilities.attachment.supportsTypeWildcard||!1}async getAttachments(){const{_attachmentLayer:t,attachmentInfos:e,orderByFields:a,attachmentTypes:i,attachmentKeywords:r,supportsTypeWildcard:s}=this;if(!t||"function"!=typeof t.queryAttachments)throw new n("invalid-layer","getAttachments(): A valid layer is required.");const o=this._getObjectId();if("number"!=typeof o)throw new n("invalid-object-id","getAttachments(): Numeric object id is required");const c=a?.map(t=>`${t.field} ${"descending"===t.order?"DESC":"ASC"}`),h=new p({objectIds:[o],returnMetadata:!0,orderByFields:c,attachmentTypes:s?i?.filter(Boolean).map(t=>`${t}/*`):void 0,keywords:r}),d=[],l=t.queryAttachments(h).then(t=>t[o]||d).catch(()=>d);this._getAttachmentsPromise=l,this.notifyChange("state");const m=await l;return e.destroyAll(),m.length&&e.addMany(m),this._getAttachmentsPromise=null,this.notifyChange("state"),m}async addAttachment(t,e=this.graphic){const{_attachmentLayer:a,attachmentInfos:i,capabilities:r}=this;if(!e)throw new n("invalid-graphic","addAttachment(): A valid graphic is required.",{graphic:e});if(!t)throw new n("invalid-attachment","addAttachment(): An attachment is required.",{attachment:t});if(!r.operations?.add)throw new n("invalid-capabilities","addAttachment(): add capabilities are required.");if(!a||"function"!=typeof a.addAttachment)throw new n("invalid-layer","addAttachment(): A valid layer is required.");const s=a.addAttachment(e,t).then(t=>this._queryAttachment(t.objectId,e)),o=await s;return i.add(o),o}async deleteAttachment(t){const{_attachmentLayer:e,attachmentInfos:a,graphic:i,capabilities:r}=this;if(!t)throw new n("invalid-attachment-info","deleteAttachment(): An attachmentInfo is required.",{attachmentInfo:t});if(!r.operations?.delete)throw new n("invalid-capabilities","deleteAttachment(): delete capabilities are required.");if(!e||"function"!=typeof e.deleteAttachments)throw new n("invalid-layer","deleteAttachment(): A valid layer is required.");if(!i)throw new n("invalid-graphic","deleteAttachment(): A graphic is required.");const s=e.deleteAttachments(i,[t.id]).then(()=>t),o=await s;return a.remove(o),o.destroy(),o}async updateAttachment(t,e=this.activeAttachmentInfo){const{_attachmentLayer:a,attachmentInfos:i,graphic:r,capabilities:s}=this;if(!t)throw new n("invalid-attachment","updateAttachment(): An attachment is required.",{attachment:t});if(!e)throw new n("invalid-attachment-info","updateAttachment(): An attachmentInfo is required.",{attachmentInfo:e});if(!s.operations?.update)throw new n("invalid-capabilities","updateAttachment(): Update capabilities are required.");const o=i.indexOf(e);if(!a||"function"!=typeof a.updateAttachment)throw new n("invalid-layer","updateAttachment(): A valid layer is required.");if(!r)throw new n("invalid-graphic","updateAttachment(): A graphic is required.");const c=a.updateAttachment(r,e.id,t).then(t=>this._queryAttachment(t.objectId)),h=await c;return i.splice(o,1,h),h}async commitFiles(){return await Promise.all(this.fileInfos.items.map(t=>this.addAttachment(t.form))),this.fileInfos.removeAll(),this.getAttachments()}addFile(t,e){if(!t||!e)return null;const a={file:t,form:e};return this.fileInfos.add(a),a}updateFile(t,e,a=this.activeFileInfo){if(!t||!e||!a)return null;const i=this.fileInfos.indexOf(a);return i>-1&&this.fileInfos.splice(i,1,{file:t,form:e}),this.fileInfos.items[i]}deleteFile(t){const e=this.fileInfos.find(e=>e.file===t);return e?(this.fileInfos.remove(e),e):null}async _queryAttachment(t,e){const{_attachmentLayer:a}=this;if(!t||!a?.queryAttachments)throw new n("invalid-attachment-id","Could not query attachment.");const i=this._getObjectId(e);if("number"!=typeof i)throw new n("invalid-object-id","getAttachments(): Numeric object id is required");const r=new p({objectIds:[i],attachmentsWhere:`AttachmentId=${t}`,returnMetadata:!0});return a.queryAttachments(r).then(t=>t[i][0])}_getObjectId(t=this.graphic){return t?.getObjectId()??null}_graphicChanged(){this.graphic&&(this._setAttachmentLayer(),this.getAttachments().catch(()=>this.attachmentInfos.destroyAll()))}_setAttachmentLayer(){const{graphic:t}=this,e=m(t);this._attachmentLayer=e?"scene"===e.type&&null!=e.associatedLayer?e.associatedLayer:e:null}};t([o({type:[String]})],y.prototype,"attachmentKeywords",void 0),t([o({type:[["application","audio","image","model","text","video"]]})],y.prototype,"attachmentTypes",void 0),t([o()],y.prototype,"capabilities",void 0),t([c("capabilities")],y.prototype,"castCapabilities",null),t([o()],y.prototype,"activeAttachmentInfo",void 0),t([o()],y.prototype,"activeFileInfo",void 0),t([o({readOnly:!0,type:f})],y.prototype,"attachmentInfos",void 0),t([o()],y.prototype,"fileInfos",void 0),t([o({type:e})],y.prototype,"graphic",void 0),t([o()],y.prototype,"mode",void 0),t([o({type:[d]})],y.prototype,"orderByFields",void 0),t([o({readOnly:!0})],y.prototype,"state",null),t([o()],y.prototype,"filesEnabled",void 0),t([o({readOnly:!0})],y.prototype,"supportsResizeAttachments",null),t([o({readOnly:!0})],y.prototype,"supportsTypeWildcard",null),y=t([h("esri.widgets.Attachments.AttachmentsViewModel")],y);export{y 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{createTask as t}from"../../core/asyncUtils.js";import s from"../../core/Collection.js";import r from"../../core/Error.js";import{EventedAccessor as i}from"../../core/Evented.js";import a from"../../core/Logger.js";import{abortMaybe as o}from"../../core/maybe.js";import{throwIfAborted as n}from"../../core/promiseUtils.js";import p from"../../core/ReactiveMap.js";import{on as l,watch as u,sync as h,whenOnce as m}from"../../core/reactiveUtils.js";import{property as d}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/RandomLCG.js";import{subclass as c}from"../../core/accessorSupport/decorators/subclass.js";import{UpdatingHandles as f}from"../../core/support/UpdatingHandles.js";import y from"../../geometry/SpatialReference.js";import{system as v}from"../../time/constants.js";import{createReactiveGraphic as g}from"./batchAttributeFormUtils.js";import{ArcadeExecutorProvider as F}from"./expressions/ArcadeExecutorProvider.js";import{ExpressionsManager as _}from"./expressions/ExpressionsManager.js";import{ExpressionsModel as x}from"./expressions/ExpressionsModel.js";import w from"./inputs/BatchFormInputs.js";import{createBatchFormInputsFromBatchFormTemplate as b}from"./inputs/support/createBatchFormInputs.js";import{isGroupInput as I,isFieldInput as M}from"./inputs/support/inputUtils.js";import A from"./templates/BatchFormTemplate.js";import{getLayerContingentValuesMetaData as E}from"./templates/support/contingentValuesUtils.js";import{createBatchFormTemplate as k}from"./templates/support/createBatchFormTemplate.js";let T=class extends i{constructor(e){super(e),this.activeFeatureIndex=-1,this.disabled=!1,this.editType="NA",this.features=new s,this._hasAsyncArcadeExpressions=!1,this.maximumFeatureCountWithComplexForms=50,this.maximumFeatureCount=2e3,this.map=null,this.readOnly=!1,this.spatialReference=null,this.submitHasBeenAttempted=!1,this.timeZone=null,this.userHasChangedValues=!1,this._arcadeExecutorProvider=new F,this._activeFormInputsByElementId=new Map,this._emptyForm=new w({inputs:[]}),this._emptyFormTemplate=new A({elements:[]}),this._featureFormMap=new Map,this._prepareTask=null,this._reactiveGraphicLookup=new p,this._updatingHandles=new f,this._layerTemplateMap=new p,this._layerContingentValuesMap=new p,this._workingFeatures=new s,this._expressionsManager=new _({arcadeContext:{editType:"NA",spatialReference:null,map:null,timeZone:v}}),this.sharedForm=this._emptyForm,this.sharedFormTemplate=this._emptyFormTemplate}initialize(){this.addHandles([l(()=>this.features,"after-changes",()=>this._prepare(),{sync:!0}),u(()=>[this.features,this.map,this.timeZone,this.editType],()=>this._prepare(),h),u(()=>this.activeForm,()=>this._activeFormInputsByElementId.clear(),h)]),this._prepare()}destroy(){this._prepareTask=o(this._prepareTask),this._workingFeatures.destroyAll(),this._expressionsManager&&this._expressionsManager.abort(),this._reactiveGraphicLookup=new p,this._emptyForm.destroy(),this._emptyFormTemplate.destroy()}get _effectiveTimeZone(){return this.timeZone??"system"}get activeFeature(){const e=this.activeFeatureIndex;return e<0?null:this.features.at(e)}get activeForm(){if("batch"===this.mode)return this.sharedForm;const e=this._workingFeatures.at(this.activeFeatureIndex);if(!e)return this._emptyForm;const t=this._featureFormMap.get(e);if(t)return t;const s=this._makeBatchFormInputsForFeature(e);return s!==this._emptyForm&&this._featureFormMap.set(e,s),s}get calculating(){return this._expressionsManager.calculating}get expressionEvaluationFailed(){return this._expressionsManager.expressionEvaluationFailed}get hasNonActiveInvalidFeatures(){if("batch"===this.mode)return!1;const{activeFeature:e}=this;return this.invalidFeatures.some(t=>t!==e)}get hasAsyncArcadeExpressions(){return this._hasAsyncArcadeExpressions}get hasTooManyFeatures(){return this._workingFeatures.length>this.maximumFeatureCount}get hasTooManyComplexFeatures(){return this._workingFeatures.length>this.maximumFeatureCountWithComplexForms&&this.hasAsyncArcadeExpressions}get invalidFeatures(){return this.sharedForm.invalidFeatures}get hasVisibleInputs(){return this.visibleInputs.length>0}get hasLayersWithContingentValues(){for(const e of this.layers){const t=this._layerContingentValuesMap.get(e);if(t&&t.size>0)return!0}return!1}get visibleInputs(){return this.activeForm.inputs.filter(e=>e.visible)}get noVisibleElementsReason(){if(this.hasVisibleInputs)return null;if(0===this.activeForm.inputs.length)return"noElements";const e=new Set;for(const t of this.activeForm.inputs)switch(t.visibilityCode){case"hidden:not-in-all-layers":case"hidden:no-domain-in-common":e.add("noElementsInCommon");break;case"hidden:field-definition":case"hidden:group-visibility-expression:all-features":case"hidden:visibility-expression:all-features":e.add("allElementsHidden");break;case"hidden:group-visibility-expression:some-features":case"hidden:visibility-expression:some-features":return"elementsHiddenInSome"}return e.has("allElementsHidden")?"allElementsHidden":"noElementsInCommon"}get status(){const e=this._prepareTask;return null==e?"not-loaded":e.finished?null!=e.error?"failed":"loaded":"loading"}get submittable(){return this.valid,!0}get updating(){return this._updatingHandles.updating||this.calculating}get valid(){return this.sharedForm.valid}get layers(){const e=new Set;return this.features.forEach(t=>{const s=t.sourceLayer??t.layer;e.add(s)}),Array.from(e)}get mode(){return this.activeFeatureIndex>-1?"single":"batch"}submit(){this.submitHasBeenAttempted=!0,this.emit("submit",{name:"submit",results:this._makeSubmitResults(),valid:this.valid})}findFieldInput(e){if(null==e)return;const t=this._activeFormInputsByElementId;if(t.has(e))return t.get(e);const s=this.activeForm.allFieldInputs.find(t=>t.template.elementId===e);return void 0!==s?(t.set(e,s),s):void 0}getFirstVisibleInvalidFieldInput(){if(this.hasVisibleInputs&&!this.activeForm.valid)for(const e of this.visibleInputs){if(I(e)){const t=e.inputs.find(e=>!e.valid);if(t)return{input:t,groupInput:e}}if(M(e)&&!e.valid)return{input:e}}}getFieldInputValue(e){return this.findFieldInput(e)?.value}getValues(e){const t=this._reactiveGraphicLookup.get(e);if(!t)throw new r("feature-not-found","The given feature is not present in the BatchAttributeForm");return{...t.attributes}}notifyGeometriesChanged(e){const t=[];for(const s of e){const e=this._reactiveGraphicLookup.get(s);e&&(t.push(e),e.geometry=s.geometry)}this._expressionsManager.runGeometryDependentExpressions(t)}async setFieldInputValue(e,t){const s=new Set(this.invalidFeatures);await e.setValueFromUser(t),this.userHasChangedValues=!0,this._trackValidityChange(s),this.emit("value-change",{features:e.features.toArray().map(e=>e.source),fieldName:e.fieldName,name:"value-change",value:t})}async setValue(e,t){const s=this.findFieldInput(e);if(null==s)throw new r("no-FieldInput-found",`Cannot set the value of FieldInput with ID: ${e} because none was found in the active form`);await this.setFieldInputValue(s,t)}userChangesHaveMadeFeatureInvalid(e){return!!this._reactiveGraphicLookup.get(e)?.userChangesHaveMadeInvalid}async _trackValidityChange(e){await m(()=>!1===this.calculating);const t=this.invalidFeatures;for(const s of t)!1===e.has(s)&&this._reactiveGraphicLookup.has(s)&&(this._reactiveGraphicLookup.get(s).userChangesHaveMadeInvalid=!0)}validate(){return!1}_makeBatchFormInputsForFeature(e){const t=this._layerTemplateMap.get(e.layer);return t?b(t,new s([e]),this._expressionsManager):this._emptyForm}_makeSubmitResults(){const e=new Map;for(const[t,s]of this._reactiveGraphicLookup)e.set(t,{feature:t,values:{...s.attributes},invalidFields:[]});for(const t of this.sharedForm.allFieldInputs)for(const s of t.invalidFeatures)e.get(s)?.invalidFields.push(t.fieldName);return Array.from(e.values())}_prepare(){this._hasAsyncArcadeExpressions=!1,this._prepareTask=o(this._prepareTask),this._updateWorkingFeatures(),o(this._expressionsManager),this.userHasChangedValues=!1,this._expressionsManager=new _({arcadeContext:{editType:this.editType,spatialReference:this.spatialReference??y.WebMercator,map:this.map,timeZone:this._effectiveTimeZone}});const{layers:e}=this;if(0===e.length)return;const s=t(async t=>{try{n(t);const s=new Map;for(const t of e){const e=await E(t);if(e){const s=e.fieldGroups.flatMap(e=>e.fields);this._layerContingentValuesMap.set(t,new Set(s))}else this._layerContingentValuesMap.set(t,new Set);const r=await k(t,{arcadeExecutorProvider:this._arcadeExecutorProvider,formTimeZone:this._effectiveTimeZone});this._layerTemplateMap.set(t,r);const i=r.getExpressionExecutorsForLayer(t);if(this._expressionsManager.layerExpressionsModelMap.set(t,new x({preserveFieldValuesWhenHidden:r.preserveFieldValuesWhenHidden,executorMap:i})),!this._hasAsyncArcadeExpressions)for(const t of i.keys()){const e=i.get(t);if(this._hasAsyncArcadeExpressions=!0===(e.editableExpression?.isAsync||e.requiredExpression?.isAsync||e.valueExpression?.isAsync||e.visibilityExpression?.isAsync),this._hasAsyncArcadeExpressions)break}for(const t of r.elements){const{elementId:e}=t;s.has(e)?s.get(e).foldIn(t):s.set(e,t.clone())}}if(this.hasTooManyComplexFeatures)throw new r("too-many-features-with-complex-forms","There are too many features to load into the form with the configured complexity");if(this.hasTooManyFeatures)throw new r("too-many-features","There are too many features to load into the form.");const i=new A({elements:Array.from(s.values())});this.sharedFormTemplate=i,this.sharedForm=b(i,this._workingFeatures,this._expressionsManager),await this._expressionsManager.runAllExpressions(this._workingFeatures.toArray())}catch(s){throw a.getLogger(this).error("Failed preparing form",s),s}});this._updatingHandles.addPromise(s.promise),this._prepareTask=s}_updateWorkingFeatures(){this._workingFeatures.destroyAll();const{features:e}=this;if(this._reactiveGraphicLookup=new p,0!==e.length){this._workingFeatures.addMany(e.map(g));for(const e of this._workingFeatures)this._reactiveGraphicLookup.set(e.source,e)}}};e([d()],T.prototype,"_effectiveTimeZone",null),e([d({readOnly:!0})],T.prototype,"activeFeature",null),e([d()],T.prototype,"activeFeatureIndex",void 0),e([d({readOnly:!0})],T.prototype,"activeForm",null),e([d()],T.prototype,"disabled",void 0),e([d()],T.prototype,"calculating",null),e([d()],T.prototype,"editType",void 0),e([d()],T.prototype,"features",void 0),e([d()],T.prototype,"expressionEvaluationFailed",null),e([d()],T.prototype,"hasNonActiveInvalidFeatures",null),e([d()],T.prototype,"hasAsyncArcadeExpressions",null),e([d()],T.prototype,"_hasAsyncArcadeExpressions",void 0),e([d()],T.prototype,"invalidFeatures",null),e([d()],T.prototype,"hasVisibleInputs",null),e([d()],T.prototype,"hasLayersWithContingentValues",null),e([d()],T.prototype,"maximumFeatureCountWithComplexForms",void 0),e([d()],T.prototype,"maximumFeatureCount",void 0),e([d()],T.prototype,"visibleInputs",null),e([d()],T.prototype,"map",void 0),e([d()],T.prototype,"noVisibleElementsReason",null),e([d()],T.prototype,"readOnly",void 0),e([d()],T.prototype,"spatialReference",void 0),e([d()],T.prototype,"submitHasBeenAttempted",void 0),e([d()],T.prototype,"timeZone",void 0),e([d()],T.prototype,"updating",null),e([d()],T.prototype,"valid",null),e([d()],T.prototype,"layers",null),e([d()],T.prototype,"mode",null),e([d()],T.prototype,"sharedForm",void 0),e([d()],T.prototype,"sharedFormTemplate",void 0),e([d()],T.prototype,"userHasChangedValues",void 0),e([d()],T.prototype,"_arcadeExecutorProvider",void 0),e([d()],T.prototype,"_prepareTask",void 0),e([d()],T.prototype,"_reactiveGraphicLookup",void 0),e([d()],T.prototype,"_layerTemplateMap",void 0),e([d()],T.prototype,"_layerContingentValuesMap",void 0),e([d()],T.prototype,"_workingFeatures",void 0),e([d()],T.prototype,"_expressionsManager",void 0),T=e([c("esri.widgets.BatchAttributeForm.BatchAttributeFormViewModel")],T);const C=T;export{C as default};
|
|
5
|
+
import{__decorate as e}from"tslib";import{createTask as t}from"../../core/asyncUtils.js";import s from"../../core/Collection.js";import r from"../../core/Error.js";import{EventedAccessor as i}from"../../core/Evented.js";import a from"../../core/Logger.js";import{abortMaybe as o}from"../../core/maybe.js";import{throwIfAborted as n}from"../../core/promiseUtils.js";import p from"../../core/ReactiveMap.js";import{on as l,watch as u,sync as h,whenOnce as m}from"../../core/reactiveUtils.js";import{property as d}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/RandomLCG.js";import{subclass as c}from"../../core/accessorSupport/decorators/subclass.js";import{UpdatingHandles as f}from"../../core/support/UpdatingHandles.js";import y from"../../geometry/SpatialReference.js";import{system as v}from"../../time/constants.js";import{createReactiveGraphic as g}from"./batchAttributeFormUtils.js";import{ArcadeExecutorProvider as F}from"./expressions/ArcadeExecutorProvider.js";import{ExpressionsManager as _}from"./expressions/ExpressionsManager.js";import{ExpressionsModel as x}from"./expressions/ExpressionsModel.js";import w from"./inputs/BatchFormInputs.js";import{createBatchFormInputsFromBatchFormTemplate as b}from"./inputs/support/createBatchFormInputs.js";import{isGroupInput as I,isFieldInput as M}from"./inputs/support/inputUtils.js";import A from"./templates/BatchFormTemplate.js";import{getLayerContingentValuesMetaData as E}from"./templates/support/contingentValuesUtils.js";import{createBatchFormTemplate as k}from"./templates/support/createBatchFormTemplate.js";let T=class extends i{constructor(e){super(e),this.activeFeatureIndex=-1,this.disabled=!1,this.editType="NA",this.features=new s,this._hasAsyncArcadeExpressions=!1,this.maximumFeatureCount=2e3,this.maximumFeatureCountWithComplexForms=50,this.map=null,this.readOnly=!1,this.spatialReference=null,this.submitHasBeenAttempted=!1,this.timeZone=null,this.userHasChangedValues=!1,this._arcadeExecutorProvider=new F,this._activeFormInputsByElementId=new Map,this._emptyForm=new w({inputs:[]}),this._emptyFormTemplate=new A({elements:[]}),this._featureFormMap=new Map,this._prepareTask=null,this._reactiveGraphicLookup=new p,this._updatingHandles=new f,this._layerTemplateMap=new p,this._layerContingentValuesMap=new p,this._workingFeatures=new s,this._expressionsManager=new _({arcadeContext:{editType:"NA",spatialReference:null,map:null,timeZone:v}}),this.sharedForm=this._emptyForm,this.sharedFormTemplate=this._emptyFormTemplate}initialize(){this.addHandles([l(()=>this.features,"after-changes",()=>this._prepare(),{sync:!0}),u(()=>[this.features,this.map,this.timeZone,this.editType],()=>this._prepare(),h),u(()=>this.activeForm,()=>this._activeFormInputsByElementId.clear(),h)]),this._prepare()}destroy(){this._prepareTask=o(this._prepareTask),this._workingFeatures.destroyAll(),this._expressionsManager&&this._expressionsManager.abort(),this._reactiveGraphicLookup=new p,this._emptyForm.destroy(),this._emptyFormTemplate.destroy()}get _effectiveTimeZone(){return this.timeZone??"system"}get activeFeature(){const e=this.activeFeatureIndex;return e<0?null:this.features.at(e)}get activeForm(){if("batch"===this.mode)return this.sharedForm;const e=this._workingFeatures.at(this.activeFeatureIndex);if(!e)return this._emptyForm;const t=this._featureFormMap.get(e);if(t)return t;const s=this._makeBatchFormInputsForFeature(e);return s!==this._emptyForm&&this._featureFormMap.set(e,s),s}get calculating(){return this._expressionsManager.calculating}get expressionEvaluationFailed(){return this._expressionsManager.expressionEvaluationFailed}get hasNonActiveInvalidFeatures(){if("batch"===this.mode)return!1;const{activeFeature:e}=this;return this.invalidFeatures.some(t=>t!==e)}get hasAsyncArcadeExpressions(){return this._hasAsyncArcadeExpressions}get hasTooManyFeatures(){return this._workingFeatures.length>this.maximumFeatureCount}get hasTooManyComplexFeatures(){return this._workingFeatures.length>this.maximumFeatureCountWithComplexForms&&this.hasAsyncArcadeExpressions}get invalidFeatures(){return this.sharedForm.invalidFeatures}get hasVisibleInputs(){return this.visibleInputs.length>0}get hasLayersWithContingentValues(){for(const e of this.layers){const t=this._layerContingentValuesMap.get(e);if(t&&t.size>0)return!0}return!1}get visibleInputs(){return this.activeForm.inputs.filter(e=>e.visible)}get noVisibleElementsReason(){if(this.hasVisibleInputs)return null;if(0===this.activeForm.inputs.length)return"noElements";const e=new Set;for(const t of this.activeForm.inputs)switch(t.visibilityCode){case"hidden:not-in-all-layers":case"hidden:no-domain-in-common":e.add("noElementsInCommon");break;case"hidden:field-definition":case"hidden:group-visibility-expression:all-features":case"hidden:visibility-expression:all-features":e.add("allElementsHidden");break;case"hidden:group-visibility-expression:some-features":case"hidden:visibility-expression:some-features":return"elementsHiddenInSome"}return e.has("allElementsHidden")?"allElementsHidden":"noElementsInCommon"}get status(){const e=this._prepareTask;return null==e?"not-loaded":e.finished?null!=e.error?"failed":"loaded":"loading"}get submittable(){return this.valid,!0}get updating(){return this._updatingHandles.updating||this.calculating}get valid(){return this.sharedForm.valid}get layers(){const e=new Set;return this.features.forEach(t=>{const s=t.sourceLayer??t.layer;e.add(s)}),Array.from(e)}get mode(){return this.activeFeatureIndex>-1?"single":"batch"}submit(){this.submitHasBeenAttempted=!0,this.emit("submit",{name:"submit",results:this._makeSubmitResults(),valid:this.valid})}findFieldInput(e){if(null==e)return;const t=this._activeFormInputsByElementId;if(t.has(e))return t.get(e);const s=this.activeForm.allFieldInputs.find(t=>t.template.elementId===e);return void 0!==s?(t.set(e,s),s):void 0}getFirstVisibleInvalidFieldInput(){if(this.hasVisibleInputs&&!this.activeForm.valid)for(const e of this.visibleInputs){if(I(e)){const t=e.inputs.find(e=>!e.valid);if(t)return{input:t,groupInput:e}}if(M(e)&&!e.valid)return{input:e}}}getFieldInputValue(e){return this.findFieldInput(e)?.value}getValues(e){const t=this._reactiveGraphicLookup.get(e);if(!t)throw new r("feature-not-found","The given feature is not present in the BatchAttributeForm");return{...t.attributes}}notifyGeometriesChanged(e){const t=[];for(const s of e){const e=this._reactiveGraphicLookup.get(s);e&&(t.push(e),e.geometry=s.geometry)}this._expressionsManager.runGeometryDependentExpressions(t)}async setFieldInputValue(e,t){const s=new Set(this.invalidFeatures);await e.setValueFromUser(t),this.userHasChangedValues=!0,this._trackValidityChange(s),this.emit("value-change",{features:e.features.toArray().map(e=>e.source),fieldName:e.fieldName,name:"value-change",value:t})}async setValue(e,t){const s=this.findFieldInput(e);if(null==s)throw new r("no-FieldInput-found",`Cannot set the value of FieldInput with ID: ${e} because none was found in the active form`);await this.setFieldInputValue(s,t)}userChangesHaveMadeFeatureInvalid(e){return!!this._reactiveGraphicLookup.get(e)?.userChangesHaveMadeInvalid}async _trackValidityChange(e){await m(()=>!1===this.calculating);const t=this.invalidFeatures;for(const s of t)!1===e.has(s)&&this._reactiveGraphicLookup.has(s)&&(this._reactiveGraphicLookup.get(s).userChangesHaveMadeInvalid=!0)}validate(){return!1}_makeBatchFormInputsForFeature(e){const t=this._layerTemplateMap.get(e.layer);return t?b(t,new s([e]),this._expressionsManager):this._emptyForm}_makeSubmitResults(){const e=new Map;for(const[t,s]of this._reactiveGraphicLookup)e.set(t,{feature:t,values:{...s.attributes},invalidFields:[]});for(const t of this.sharedForm.allFieldInputs)for(const s of t.invalidFeatures)e.get(s)?.invalidFields.push(t.fieldName);return Array.from(e.values())}_prepare(){this._hasAsyncArcadeExpressions=!1,this._prepareTask=o(this._prepareTask),this._updateWorkingFeatures(),o(this._expressionsManager),this.userHasChangedValues=!1,this._expressionsManager=new _({arcadeContext:{editType:this.editType,spatialReference:this.spatialReference??y.WebMercator,map:this.map,timeZone:this._effectiveTimeZone}});const{layers:e}=this;if(0===e.length)return;const s=t(async t=>{try{n(t);const s=new Map;for(const t of e){const e=await E(t);if(e){const s=e.fieldGroups.flatMap(e=>e.fields);this._layerContingentValuesMap.set(t,new Set(s))}else this._layerContingentValuesMap.set(t,new Set);const r=await k(t,{arcadeExecutorProvider:this._arcadeExecutorProvider,formTimeZone:this._effectiveTimeZone});this._layerTemplateMap.set(t,r);const i=r.getExpressionExecutorsForLayer(t);if(this._expressionsManager.layerExpressionsModelMap.set(t,new x({preserveFieldValuesWhenHidden:r.preserveFieldValuesWhenHidden,executorMap:i})),!this._hasAsyncArcadeExpressions)for(const t of i.keys()){const e=i.get(t);if(this._hasAsyncArcadeExpressions=!0===(e.editableExpression?.isAsync||e.requiredExpression?.isAsync||e.valueExpression?.isAsync||e.visibilityExpression?.isAsync),this._hasAsyncArcadeExpressions)break}for(const t of r.elements){const{elementId:e}=t;s.has(e)?s.get(e).foldIn(t):s.set(e,t.clone())}}if(this.hasTooManyComplexFeatures)throw new r("too-many-features-with-complex-forms","There are too many features to load into the form with the configured complexity");if(this.hasTooManyFeatures)throw new r("too-many-features","There are too many features to load into the form.");const i=new A({elements:Array.from(s.values())});this.sharedFormTemplate=i,this.sharedForm=b(i,this._workingFeatures,this._expressionsManager),await this._expressionsManager.runAllExpressions(this._workingFeatures.toArray())}catch(s){throw a.getLogger(this).error("Failed preparing form",s),s}});this._updatingHandles.addPromise(s.promise),this._prepareTask=s}_updateWorkingFeatures(){this._workingFeatures.destroyAll();const{features:e}=this;if(this._reactiveGraphicLookup=new p,0!==e.length){this._workingFeatures.addMany(e.map(g));for(const e of this._workingFeatures)this._reactiveGraphicLookup.set(e.source,e)}}};e([d()],T.prototype,"_effectiveTimeZone",null),e([d({readOnly:!0})],T.prototype,"activeFeature",null),e([d()],T.prototype,"activeFeatureIndex",void 0),e([d({readOnly:!0})],T.prototype,"activeForm",null),e([d()],T.prototype,"disabled",void 0),e([d()],T.prototype,"calculating",null),e([d()],T.prototype,"editType",void 0),e([d()],T.prototype,"features",void 0),e([d()],T.prototype,"expressionEvaluationFailed",null),e([d()],T.prototype,"hasNonActiveInvalidFeatures",null),e([d()],T.prototype,"hasAsyncArcadeExpressions",null),e([d()],T.prototype,"_hasAsyncArcadeExpressions",void 0),e([d()],T.prototype,"invalidFeatures",null),e([d()],T.prototype,"hasVisibleInputs",null),e([d()],T.prototype,"hasLayersWithContingentValues",null),e([d()],T.prototype,"maximumFeatureCount",void 0),e([d()],T.prototype,"maximumFeatureCountWithComplexForms",void 0),e([d()],T.prototype,"visibleInputs",null),e([d()],T.prototype,"map",void 0),e([d()],T.prototype,"noVisibleElementsReason",null),e([d()],T.prototype,"readOnly",void 0),e([d()],T.prototype,"spatialReference",void 0),e([d()],T.prototype,"submitHasBeenAttempted",void 0),e([d()],T.prototype,"timeZone",void 0),e([d()],T.prototype,"updating",null),e([d()],T.prototype,"valid",null),e([d()],T.prototype,"layers",null),e([d()],T.prototype,"mode",null),e([d()],T.prototype,"sharedForm",void 0),e([d()],T.prototype,"sharedFormTemplate",void 0),e([d()],T.prototype,"userHasChangedValues",void 0),e([d()],T.prototype,"_arcadeExecutorProvider",void 0),e([d()],T.prototype,"_prepareTask",void 0),e([d()],T.prototype,"_reactiveGraphicLookup",void 0),e([d()],T.prototype,"_layerTemplateMap",void 0),e([d()],T.prototype,"_layerContingentValuesMap",void 0),e([d()],T.prototype,"_workingFeatures",void 0),e([d()],T.prototype,"_expressionsManager",void 0),T=e([c("esri.widgets.BatchAttributeForm.BatchAttributeFormViewModel")],T);const C=T;export{C 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"../intl.js";import"../core/has.js";import{getOrCreateMapValue as t}from"../core/MapUtils.js";import{watch as i,on as o}from"../core/reactiveUtils.js";import{property as n}from"../core/accessorSupport/decorators/property.js";import"../core/Logger.js";import"../core/RandomLCG.js";import{subclass as a}from"../core/accessorSupport/decorators/subclass.js";import{isIntegerField as s}from"../layers/support/fieldUtils.js";import{isString as r}from"../support/guards.js";import l from"./Widget.js";import{getHiddenFieldsValidationErrorMessage as d,getVisibleFieldInputValidationErrorMessage as p,isElementTemplateWithInputType as u}from"./BatchAttributeForm/batchAttributeFormUtils.js";import c from"./BatchAttributeForm/BatchAttributeFormViewModel.js";import{css as m}from"./BatchAttributeForm/css.js";import{VisibleElements as h}from"./BatchAttributeForm/VisibleElements.js";import{isGroupInput as v,isFieldInput as b,differentValuesString as f}from"./BatchAttributeForm/inputs/support/inputUtils.js";import{loadCalciteComponents as C}from"./support/componentsUtils.js";import{getLabelForDateFieldValue as g,getIntlOptionsForField as _,prepareISOFieldValueForDateComponents as y,prepareUnixFieldValueForDateComponents as F,normalizeTimeOnlyString as w,getISOFieldValueFromDateComponents as I,getUnixFieldValueFromDateComponents as M}from"./support/dateUtils.js";import{globalCss as x}from"./support/globalCss.js";import{setFocus as k}from"./support/widgetUtils.js";import{messageBundle as O}from"./support/decorators/messageBundle.js";import{vmEvent as T}from"./support/decorators/vmEvent.js";import{tsx as V}from"./support/jsxFactory.js";import"@arcgis/toolkit/dom";import{isEmptyValue as D}from"./support/forms/formUtils.js";import{substitute as S}from"../intl/substitute.js";const U="data-element-id";let E=class extends l{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 h,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([i(()=>this.features,()=>{this._dateComponentMap.clear()}),i(()=>this.viewModel.activeForm,()=>{this._batchSwitchInputInitialValues.clear()}),o(()=>this.viewModel,"submit",()=>{this.valid||this.goToClosestError()})])}loadDependencies(){return C({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 spatialReference(){return this.viewModel.spatialReference}set spatialReference(e){this.viewModel.spatialReference=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(S(this.messages.formFailedToLoadTooManyComplexFeatures,{num:this.viewModel.maximumFeatureCountWithComplexForms})):this.viewModel.hasTooManyFeatures?this._renderErrorNotice(S(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(m.base,x.widget,x.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:i,elementId:o}=e.dataset,n=t(this._dateComponentMap,`${o}`,()=>({}));switch(i){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(m.base,x.widget,x.panel)},V("calcite-notice",{class:m.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=d(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:m.noticeError,icon:!0,kind:"danger",open:!0},V("div",{slot:"message"},o)):null}_renderContent(){if(!this.viewModel.hasVisibleInputs)return[V("calcite-notice",{class:m.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 v(e)?this._renderGroupInput(e):b(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(m.group,"sequential"===this.groupDisplay?m.groupSequential:null,this.disabled?m.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{label:t,elementId:i}=e.template,{required:o,dataType:n}=e,a=o?S(this.messages.requiredFieldLabel,{name:t}):t;return V("calcite-label",{"aria-label":a,class:m.label,key:`field--${i}`},V("div",{class:m.labelTextContent,key:"labelTextContainer"},t,o?V("span",{"aria-hidden":"true",title:this.messagesCommon.required},"*"):void 0),"unsupported"!==n?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:m.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)===f||e.value===f)&&"batch"===this.viewModel.mode){const i={dropdown:{afterCreate:this._afterComponentCreateOrUpdate,afterUpdate:this._afterComponentCreateOrUpdate,disabled:t.readOnly,open:!1,[U]:t[U]},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:f,disabled:!0},...e.codedValueDomainOptions]})}return this._renderSwitchComponent({input:e,props:t})}_renderSwitchComponent({input:e,props:t}){return V("calcite-switch",{...t,checked:!!u(e.template,"switch")&&e.value===e.template.input.onValue,class:m.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===f?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?f:String(i.value),onCalciteComboboxChange:({currentTarget:e})=>{e.value!==f&&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&&D(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:f,selected:!0,textLabel:this.messages.differentValuesPlaceholder,value:f})),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=D(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:m.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:m.placeholderRadio,key:i.label,layout:"inline"},V("calcite-radio-button",{checked:!0,class:m.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:m.inputRadioLabel,key:o.label,layout:"inline"},V("calcite-radio-button",{...o,afterCreate:void 0,afterUpdate:void 0,checked:t,class:m.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):i.input&&"text-area"===i.input.type?V("calcite-text-area",{...t,class:this.classes(m.individualElement),resize:"vertical",value:t.value?String(t.value):"",onCalciteTextAreaInput:({currentTarget:e})=>this._saveInput(e)}):V("calcite-input",{...t,class:this.classes(m.individualElement),type:"text",value:t.value?String(t.value):"",onCalciteInputInput:({currentTarget:e})=>this._saveInput(e)})}_renderNumberComponent(e,t){const i=s(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(m.fieldInput,m.inputDisabled,m.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,g(i,t.value,{timeZone:e.effectiveTimeZone,..._(e.template.field)}))}return e.value===f?[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[U],key:`${o}-date-input`,max:r(a)?a:void 0,min:r(s)?s:void 0,onblur:()=>{this._focusedFieldInput=null},onfocus:this._onComponentFocus,overlayPositioning:"fixed",readOnly:n,value:e.value===f?"":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[U],key:`${o}-time-input`,onblur:()=>{this._focusedFieldInput=null},onfocus:this._onComponentFocus,overlayPositioning:"fixed",readOnly:n,value:e.value===f?"":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=y(a),l=y(s),d=y(e.value===f?"":e.value),p=e.includeTimeOffset,u={afterCreate:this._afterDateComponentCreate,afterUpdate:this._afterComponentCreateOrUpdate,overlayPositioning:"fixed",readOnly:n,[U]:t[U],onfocus:this._onComponentFocus};return V("div",{class:m.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===f||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=F(e.value===f?"":e.value,r),d=F(s,r),p=F(a,r),u=e.includeTime,c={afterCreate:this._afterDateComponentCreate,afterUpdate:this._afterComponentCreateOrUpdate,overlayPositioning:"fixed",readOnly:n,[U]:t[U],onfocus:this._onComponentFocus};return V("div",{class:m.dateInputContainer,key:`${o}-date-time-container`},V("calcite-input-date-picker",{...c,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",{...c,"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,c=!l||this.readOnly,h=!c&&this._effectiveDisabled;let v=t.hint??void 0,b=!1;return o===f&&(v=this.messages.differentValuesPlaceholder,b=!0),{afterCreate:this._afterComponentCreateOrUpdate,afterUpdate:this._afterComponentCreateOrUpdate,"aria-invalid":i?"false":"true",class:this.classes(m.fieldInput,c?m.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:h,readOnly:c,onblur:this._onComponentBlur,required:s,placeholder:v,value:b?"":o??"",[U]:t.elementId,onfocus:this._onComponentFocus}}_onFormSubmit(e){e.preventDefault()}_getFieldInputFromHTMLElement(e){return this.viewModel.findFieldInput(e.getAttribute(U))}_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,k(e))}_onComponentBlur(){this._focusedFieldInput=null}_parseValue(e,t){if(u(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 i=this._getFieldInputFromHTMLElement(e),{elementId:o}=i.template;if(!i)return;const n=i?.value;if(u(i.template,"switch")&&"single"!==this.viewModel.mode){const e=t(this._batchSwitchInputInitialValues,i,()=>i.value);this._batchSwitchInputInitialValues.set(i,null===e?n:e)}const a=this._parseValue(e,i);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===f?void 0:e.value,r=null;"date-only"===o?r=Array.isArray(t.value)?t.value[0]:t.value:"time-only"===o?(s=w(s),r=w(t.value)):r="timestamp-offset"===o?null!=t.value?I({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===f?void 0:n.time}):null,s!==r&&(null!==r&&t.value?this.viewModel.setValue(`${i}`,r):this.viewModel.setValue(`${i}`,null))}};e([n()],E.prototype,"activeFeatureIndex",null),e([n()],E.prototype,"disabled",null),e([n()],E.prototype,"_effectiveDisabled",null),e([n()],E.prototype,"features",null),e([n()],E.prototype,"map",null),e([n()],E.prototype,"spatialReference",null),e([n()],E.prototype,"timeZone",null),e([n()],E.prototype,"headingLevel",void 0),e([n()],E.prototype,"icon",null),e([n(),O("esri/t9n/common")],E.prototype,"messagesCommon",void 0),e([n(),O("esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm")],E.prototype,"messages",void 0),e([n(),O("esri/widgets/FeatureForm/t9n/FeatureForm")],E.prototype,"featureFormMessages",void 0),e([n()],E.prototype,"readOnly",null),e([n()],E.prototype,"valid",null),e([n(),T(["value-change","submit"])],E.prototype,"viewModel",void 0),e([n({type:h,nonNullable:!0})],E.prototype,"visibleElements",void 0),e([n()],E.prototype,"groupDisplay",void 0),E=e([a("esri.widgets.BatchAttributeForm")],E);const R=E;export{R as default};
|
|
5
|
+
import{__decorate as e}from"tslib";import"../intl.js";import"../core/has.js";import{getOrCreateMapValue as t}from"../core/MapUtils.js";import{watch as i,on as o}from"../core/reactiveUtils.js";import{property as n}from"../core/accessorSupport/decorators/property.js";import"../core/Logger.js";import"../core/RandomLCG.js";import{subclass as a}from"../core/accessorSupport/decorators/subclass.js";import{isIntegerField as s}from"../layers/support/fieldUtils.js";import{isString as r}from"../support/guards.js";import l from"./Widget.js";import{getHiddenFieldsValidationErrorMessage as d,getVisibleFieldInputValidationErrorMessage as p,isElementTemplateWithInputType as u}from"./BatchAttributeForm/batchAttributeFormUtils.js";import m from"./BatchAttributeForm/BatchAttributeFormViewModel.js";import{css as c}from"./BatchAttributeForm/css.js";import{VisibleElements as h}from"./BatchAttributeForm/VisibleElements.js";import{isGroupInput as v,isFieldInput as b,differentValuesString as f}from"./BatchAttributeForm/inputs/support/inputUtils.js";import{loadCalciteComponents as C}from"./support/componentsUtils.js";import{getLabelForDateFieldValue as g,getIntlOptionsForField as _,prepareISOFieldValueForDateComponents as F,prepareUnixFieldValueForDateComponents as y,normalizeTimeOnlyString as w,getISOFieldValueFromDateComponents as I,getUnixFieldValueFromDateComponents as x}from"./support/dateUtils.js";import{globalCss as M}from"./support/globalCss.js";import{setFocus as k}from"./support/widgetUtils.js";import{messageBundle as O}from"./support/decorators/messageBundle.js";import{vmEvent as T}from"./support/decorators/vmEvent.js";import{tsx as V}from"./support/jsxFactory.js";import"@arcgis/toolkit/dom";import{isEmptyValue as D}from"./support/forms/formUtils.js";import{substitute as S}from"../intl/substitute.js";const U="data-element-id";let E=class extends l{constructor(e,t){super(e,t),this.headingLevel=2,this.messagesCommon=null,this.messages=null,this.featureFormMessages=null,this.viewModel=new m,this.visibleElements=new h,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([i(()=>this.features,()=>{this._dateComponentMap.clear()}),i(()=>this.viewModel.activeForm,()=>{this._batchSwitchInputInitialValues.clear()}),o(()=>this.viewModel,"submit",()=>{this.valid||this.goToClosestError()})])}loadDependencies(){return C({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 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(S(this.messages.formFailedToLoadTooManyComplexFeatures,{num:this.viewModel.maximumFeatureCountWithComplexForms})):this.viewModel.hasTooManyFeatures?this._renderErrorNotice(S(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(c.base,M.widget,M.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:i,elementId:o}=e.dataset,n=t(this._dateComponentMap,`${o}`,()=>({}));switch(i){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(c.base,M.widget,M.panel)},V("calcite-notice",{class:c.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=d(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:c.noticeError,icon:!0,kind:"danger",open:!0},V("div",{slot:"message"},o)):null}_renderContent(){if(!this.viewModel.hasVisibleInputs)return[V("calcite-notice",{class:c.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 v(e)?this._renderGroupInput(e):b(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(c.group,"sequential"===this.groupDisplay?c.groupSequential:null,this.disabled?c.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{label:t,elementId:i}=e.template,{required:o,dataType:n}=e,a=o?S(this.messages.requiredFieldLabel,{name:t}):t;return V("calcite-label",{"aria-label":a,class:c.label,key:`field--${i}`},V("div",{class:c.labelTextContent,key:"labelTextContainer"},t,o?V("span",{"aria-hidden":"true",title:this.messagesCommon.required},"*"):void 0),"unsupported"!==n?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:c.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)===f||e.value===f)&&"batch"===this.viewModel.mode){const i={dropdown:{afterCreate:this._afterComponentCreateOrUpdate,afterUpdate:this._afterComponentCreateOrUpdate,disabled:t.readOnly,open:!1,[U]:t[U]},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:f,disabled:!0},...e.codedValueDomainOptions]})}return this._renderSwitchComponent({input:e,props:t})}_renderSwitchComponent({input:e,props:t}){return V("calcite-switch",{...t,checked:!!u(e.template,"switch")&&e.value===e.template.input.onValue,class:c.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===f?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?f:String(i.value),onCalciteComboboxChange:({currentTarget:e})=>{e.value!==f&&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&&D(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:f,selected:!0,textLabel:this.messages.differentValuesPlaceholder,value:f})),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=D(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:c.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:c.placeholderRadio,key:i.label,layout:"inline"},V("calcite-radio-button",{checked:!0,class:c.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:c.inputRadioLabel,key:o.label,layout:"inline"},V("calcite-radio-button",{...o,afterCreate:void 0,afterUpdate:void 0,checked:t,class:c.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):i.input&&"text-area"===i.input.type?V("calcite-text-area",{...t,class:this.classes(c.individualElement),resize:"vertical",value:t.value?String(t.value):"",onCalciteTextAreaInput:({currentTarget:e})=>this._saveInput(e)}):V("calcite-input",{...t,class:this.classes(c.individualElement),type:"text",value:t.value?String(t.value):"",onCalciteInputInput:({currentTarget:e})=>this._saveInput(e)})}_renderNumberComponent(e,t){const i=s(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(c.fieldInput,c.inputDisabled,c.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,g(i,t.value,{timeZone:e.effectiveTimeZone,..._(e.template.field)}))}return e.value===f?[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[U],key:`${o}-date-input`,max:r(a)?a:void 0,min:r(s)?s:void 0,onblur:()=>{this._focusedFieldInput=null},onfocus:this._onComponentFocus,overlayPositioning:"fixed",readOnly:n,value:e.value===f?"":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[U],key:`${o}-time-input`,onblur:()=>{this._focusedFieldInput=null},onfocus:this._onComponentFocus,overlayPositioning:"fixed",readOnly:n,value:e.value===f?"":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===f?"":e.value),p=e.includeTimeOffset,u={afterCreate:this._afterDateComponentCreate,afterUpdate:this._afterComponentCreateOrUpdate,overlayPositioning:"fixed",readOnly:n,[U]:t[U],onfocus:this._onComponentFocus};return V("div",{class:c.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===f||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=y(e.value===f?"":e.value,r),d=y(s,r),p=y(a,r),u=e.includeTime,m={afterCreate:this._afterDateComponentCreate,afterUpdate:this._afterComponentCreateOrUpdate,overlayPositioning:"fixed",readOnly:n,[U]:t[U],onfocus:this._onComponentFocus};return V("div",{class:c.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,h=!m&&this._effectiveDisabled;let v=t.hint??void 0,b=!1;return o===f&&(v=this.messages.differentValuesPlaceholder,b=!0),{afterCreate:this._afterComponentCreateOrUpdate,afterUpdate:this._afterComponentCreateOrUpdate,"aria-invalid":i?"false":"true",class:this.classes(c.fieldInput,m?c.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:h,readOnly:m,onblur:this._onComponentBlur,required:s,placeholder:v,value:b?"":o??"",[U]:t.elementId,onfocus:this._onComponentFocus}}_onFormSubmit(e){e.preventDefault()}_getFieldInputFromHTMLElement(e){return this.viewModel.findFieldInput(e.getAttribute(U))}_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,k(e))}_onComponentBlur(){this._focusedFieldInput=null}_parseValue(e,t){if(u(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 i=this._getFieldInputFromHTMLElement(e),{elementId:o}=i.template;if(!i)return;const n=i?.value;if(u(i.template,"switch")&&"single"!==this.viewModel.mode){const e=t(this._batchSwitchInputInitialValues,i,()=>i.value);this._batchSwitchInputInitialValues.set(i,null===e?n:e)}const a=this._parseValue(e,i);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===f?void 0:e.value,r=null;"date-only"===o?r=Array.isArray(t.value)?t.value[0]:t.value:"time-only"===o?(s=w(s),r=w(t.value)):r="timestamp-offset"===o?null!=t.value?I({dateComponent:n.date,timeComponent:n.time,oldValue:s,timeZoneComponent:n.timeZone,defaultTimeZone:a}):null:null!=t.value?x({oldValue:s,dateComponent:n.date,timeZone:a,timeComponent:n.time?.value===f?void 0:n.time}):null,s!==r&&(null!==r&&t.value?this.viewModel.setValue(`${i}`,r):this.viewModel.setValue(`${i}`,null))}};e([n()],E.prototype,"activeFeatureIndex",null),e([n()],E.prototype,"disabled",null),e([n()],E.prototype,"_effectiveDisabled",null),e([n()],E.prototype,"features",null),e([n()],E.prototype,"map",null),e([n()],E.prototype,"maximumFeatureCount",null),e([n()],E.prototype,"maximumFeatureCountWithComplexForms",null),e([n()],E.prototype,"spatialReference",null),e([n()],E.prototype,"timeZone",null),e([n()],E.prototype,"headingLevel",void 0),e([n()],E.prototype,"icon",null),e([n(),O("esri/t9n/common")],E.prototype,"messagesCommon",void 0),e([n(),O("esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm")],E.prototype,"messages",void 0),e([n(),O("esri/widgets/FeatureForm/t9n/FeatureForm")],E.prototype,"featureFormMessages",void 0),e([n()],E.prototype,"readOnly",null),e([n()],E.prototype,"valid",null),e([n(),T(["value-change","submit"])],E.prototype,"viewModel",void 0),e([n({type:h,nonNullable:!0})],E.prototype,"visibleElements",void 0),e([n()],E.prototype,"groupDisplay",void 0),E=e([a("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
|
-
const e="esri-directions",
|
|
5
|
+
const e="esri-directions",r={base:e,accordion:`${e}__accordion`,actionContainer:`${e}__action-container`,addStopButton:`${e}__add-stop-button`,departureTime:`${e}__departure-time`,departureTimeOptions:`${e}__departure-time-options`,directionsHeader:`${e}__directions-header`,directionsHeaderStopName:`${e}__directions-header-stop-name`,editFooter:`${e}__edit-footer`,editRouteButton:`${e}__edit-route-button`,editToolbar:`${e}__edit-toolbar`,editToolbarContainer:`${e}__edit-toolbar-container`,flexColumn:`${e}__flex-column`,flexRow:`${e}__flex-row`,folder:`${e}__folder`,folderHome:`${e}__folder-home`,headerStops:`${e}__header-stops`,labelEmphasize:`${e}__label-emphasize`,labelNoBottomMargin:`${e}__label-no-bottom-margin`,marginInlineMedium:`${e}__margin-inline-medium`,optimizeSection:`${e}__optimize-section`,optimizeSwitches:`${e}__optimize-switches`,paddingMedium:`${e}__padding-medium`,primaryFlowItem:`${e}__primary-flow-item`,primaryFooter:`${e}__primary-footer`,primaryFooterCentered:`${e}__primary-footer-centered`,primaryFooterLoader:`${e}__primary-footer-loader`,printPreviewAvoidPageBreak:`${e}__print-preview--avoid-page-break`,printPreviewContent:`${e}__print-preview-content`,printPreviewDialog:`${e}__print-preview-dialog`,printPreviewDialogClose:`${e}__print-preview-dialog-close`,printPreviewDialogPrint:`${e}__print-preview-dialog-print`,printPreviewHeader:`${e}__print-preview-header`,printPreviewHeaderButtons:`${e}__print-preview-header-buttons`,printPreviewHeaderLabel:`${e}__print-preview-header-label`,printPreviewHideOnPrint:`${e}__print-preview--hide-on-print`,printPreviewMedia:`${e}__print-preview-media`,printPreviewSection:`${e}__print-preview-section`,routeItem:`${e}__route-item`,routeItemButton:`${e}__route-item-button`,routeItemButtonContent:`${e}__route-item-button-content`,routeItemDescription:`${e}__route-item-description`,routeItemLabel:`${e}__route-item-label`,saveError:`${e}__save-error`,saveErrorIcon:`${e}__save-error-icon`,saveErrorLabel:`${e}__save-error-label`,saveProcessLoader:`${e}__save-process-loader`,selectedFeatureContainer:`${e}__selected-feature-container`,separator:`${e}__separator`,solveRoute:`${e}__solve-route`,stopContainer:`${e}__stop-container`,stopItem:`${e}__stop-item`,stopList:`${e}__stop-list`};export{r as css};
|
package/widgets/Directions.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{isSome as t}from"../core/arrayUtils.js";import i from"../core/Collection.js";import{addEventListener as s}from"../core/events.js";import{makeHandle as o}from"../core/handleUtils.js";import{destroyMaybe as r}from"../core/maybe.js";import{debounce as n,isAbortError as a}from"../core/promiseUtils.js";import{watch as l,initial as c,on as d}from"../core/reactiveUtils.js";import{escapeRegExpString as h}from"../core/string.js";import{property as p}from"../core/accessorSupport/decorators/property.js";import"../core/has.js";import"../core/Logger.js";import{subclass as m}from"../core/accessorSupport/decorators/subclass.js";import{onLocaleChange as u,getLocaleLanguage as v}from"../intl/locale.js";import _ from"../portal/Portal.js";import{defaultUnitPropertyMetadata as g}from"../properties/defaultUnit.js";import w from"../rest/support/Stop.js";import y from"../symbols/SimpleMarkerSymbol.js";import b from"./Search.js";import S from"./Widget.js";import{css as f}from"./Directions/css.js";import{DirectionsSearchTool as k}from"./Directions/DirectionsSearchTool.js";import C from"./Directions/DirectionsViewModel.js";import D from"./Directions/DirectionsVisibleElements.js";import{formatDistance as M,formatDuration as I,DepartureTimeOption as T,getIconName as F}from"./Directions/support/directionsUtils.js";import{isArcGISWorldGeocoder as P,meteredArcGISLocatorUrl as x}from"./Search/support/locatorUtils.js";import{loadCalciteComponents as E}from"./support/componentsUtils.js";import{globalCss as R}from"./support/globalCss.js";import"./support/widgetUtils.js";import{messageBundle as L}from"./support/decorators/messageBundle.js";import{tsx as A}from"./support/jsxFactory.js";import"@arcgis/toolkit/dom";function O(e){const{branchName:i,displayText:s,exitName:o,intersectingName:r,name:n,towardName:a}=e;if(null==s)return null;const l=[i,o,r,n,a].filter(t).sort((e,t)=>t.length-e.length).map(e=>h(e));if(!l.length)return s;const c=new RegExp(l.join("|"),"g"),d=s.matchAll(c);let p=0;const m=[];for(const{0:t,index:h}of d)m.push(s.slice(p,h),A("span",{class:f.labelEmphasize,key:`maneuver-${h}`},t)),p=h+t.length;return m.push(s.slice(p)),A("span",null,m)}let N=class extends S{constructor(e,t){super(e,t),this._activeManeuver=null,this._placeholderStops=new i([new w,new w]),this._portalFolderCombobox=null,this._portalFolders=null,this._portalItemNameInput=null,this._portalUserName=null,this._printDocument=null,this._printDocumentParent=null,this._sections=null,this._stopsToSearches=new Map,this._printDocumentOpen=!1,this._currentFlowItem="primary",this._parentFlowItem="primary",this._saveState="initialized",this._searchTool=null,this.headingLevel=2,this.messages=null,this.messagesUnits=null,this.searchProperties={popupEnabled:!1,resultGraphicEnabled:!1},this.viewModel=new C,this.visibleElements=new D,this._solveRouteDebounced=n(()=>this._solveRoute())}initialize(){this.addHandles([l(()=>this.viewModel.layer,()=>{try{this.viewModel.load()}catch{}},c),l(()=>this.viewModel.layer?.routeInfo,()=>{this._sections=this._getStopSections()},c),l(()=>this.viewModel.layer?.stops.toArray(),e=>{e&&this.view?.activeTool&&this._searchTool&&this.view.activeTool===this._searchTool&&!e.includes(this._searchTool.stop)&&(this.view.tools.remove(this._searchTool),this._searchTool=null)}),s(window,"beforeprint",this._beforePrint.bind(this)),s(window,"afterprint",this._afterPrint.bind(this))])}loadDependencies(){return E({accordion:()=>import("@esri/calcite-components/dist/components/calcite-accordion"),"accordion-item":()=>import("@esri/calcite-components/dist/components/calcite-accordion-item"),action:()=>import("@esri/calcite-components/dist/components/calcite-action"),"action-menu":()=>import("@esri/calcite-components/dist/components/calcite-action-menu"),"block-section":()=>import("@esri/calcite-components/dist/components/calcite-block-section"),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"),flow:()=>import("@esri/calcite-components/dist/components/calcite-flow"),"flow-item":()=>import("@esri/calcite-components/dist/components/calcite-flow-item"),icon:()=>import("@esri/calcite-components/dist/components/calcite-icon"),input:()=>import("@esri/calcite-components/dist/components/calcite-input"),"input-date-picker":()=>import("@esri/calcite-components/dist/components/calcite-input-date-picker"),"input-time-picker":()=>import("@esri/calcite-components/dist/components/calcite-input-time-picker"),label:()=>import("@esri/calcite-components/dist/components/calcite-label"),list:()=>import("@esri/calcite-components/dist/components/calcite-list"),"list-item":()=>import("@esri/calcite-components/dist/components/calcite-list-item"),loader:()=>import("@esri/calcite-components/dist/components/calcite-loader"),notice:()=>import("@esri/calcite-components/dist/components/calcite-notice"),panel:()=>import("@esri/calcite-components/dist/components/calcite-panel"),switch:()=>import("@esri/calcite-components/dist/components/calcite-switch")})}destroy(){this._stopsToSearches.forEach(r)}get apiKey(){return this.viewModel.apiKey}set apiKey(e){this.viewModel.apiKey=e}get goToOverride(){return this.viewModel.goToOverride}set goToOverride(e){this.viewModel.goToOverride=e}get icon(){return"right"}set icon(e){this._overrideIfSome("icon",e)}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get lastRoute(){return this.viewModel.lastRoute}get layer(){return this.viewModel.layer}set layer(e){this.viewModel.layer=e}get maxStops(){return this.viewModel.maxStops}set maxStops(e){this.viewModel.maxStops=e}get unit(){return this.defaultUnit}set unit(e){this._overrideIfSome("unit",e)}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}acquireSearch(e){const{view:t}=this.viewModel;if(this._stopsToSearches.has(e)){const i=this._stopsToSearches.get(e);return i.view=t,this._overrideDefaultSources(i),i}const i=new b({icon:"",popupEnabled:!1,resultGraphicEnabled:!1,view:t,...this.searchProperties});return this._normalizeSearchSources(i),this.addHandles([d(()=>i.allSources,"change",()=>this._normalizeSearchSources(i)),i.on("search-clear",()=>{e.geometry=null,e.name=null,this.viewModel.layer?.removeResult()}),i.on("select-result",()=>{const t=i.selectedResult;e.geometry=t?.feature.geometry,e.name=t?.name,this._solveRouteDebounced()}),l(()=>i.searchTerm,t=>{e.name=t}),u(()=>this._normalizeSearchSources(i))],i),this._stopsToSearches.set(e,i),i}getDirections(){return this.viewModel.getDirections()}render(){return A("div",{class:this.classes(f.base,R.widget,R.panel)},A("calcite-flow",null,this._renderPrimaryFlowItem(),this._renderDirectionsFlowItem(),this._renderEditFlowItem(),this._renderSaveFlowItem()),this._renderPrintDocument())}save(){return this.viewModel.save()}saveAs(e,t={}){return this.viewModel.saveAs(e,t)}zoomToRoute(){return this.viewModel.zoomToRoute()}_afterPrint(){this._printDocumentOpen&&this._printDocument&&this._printDocumentParent?.appendChild(this._printDocument)}_applyLocatorSourceOverrides({allSources:e}){for(const t of e)"url"in t&&t.url&&(t.language=v(),t.locationType??="street",P(t.url)&&this.apiKey&&null==t.apiKey&&(t.apiKey=this.apiKey,t.url=x))}_beforePrint(){this._printDocumentOpen&&this._printDocument&&document.body.appendChild(this._printDocument)}_disposeSearch(e){if(!e||!this._stopsToSearches.has(e))return;const t=this._stopsToSearches.get(e);this.removeHandles(t),t.destroy(),this._stopsToSearches.delete(e)}_getEffectiveStops(){return this.viewModel.layer?.stops??this._placeholderStops}_getErrorDescription(){switch(this.viewModel.lastError?.name){case"directions-view-model:unable-to-route":return this.messages.errors.unableToRoute;case"directions-view-model:service-metadata-unavailable":return this.messages.errors.unableToLoadServiceMetadata;default:return this.messages.errors.unknownError}}_getNetworkFeatureName(e){switch(e.type){case"stop":switch(e.locationType){case"stop":default:return this.messages.networkFeatures.stops.stop;case"waypoint":return this.messages.networkFeatures.stops.waypoint;case"break":return this.messages.networkFeatures.stops.break}case"point-barrier":return this.messages.networkFeatures.pointBarrier;case"polyline-barrier":return this.messages.networkFeatures.polylineBarrier;case"polygon-barrier":return this.messages.networkFeatures.polygonBarrier}}_getRouteCostSummary(){const e=this.viewModel.layer?.routeInfo;if(!e)return null;const t=e.totalDistance??0,i=e.totalDuration??0,{messagesUnits:s,unit:o}=this;return{distance:M(s,t,o),duration:I(i)}}_getStopCostDescription(e){if(!e.directions.length)return;const{totalDistance:t,totalDuration:i}=e.directions.reduce((e,{lines:t})=>{for(const{distance:i,duration:s}of t)e.totalDistance+=i??0,e.totalDuration+=s??0;return e},{totalDistance:0,totalDuration:0}),{messagesUnits:s,unit:o}=this,r=M(s,t,o);return`${I(i)} (${r})`}_getStopSections(){if(!this.viewModel.layer)return null;const{directionPoints:e,directionLines:t,stops:i}=this.viewModel.layer;if(!e||!t)return null;const s=[];let o=null;for(const r of e){const{objectId:e,stopId:n}=r;if(null!=n){const e=i.find(({objectId:e})=>e===n);o&&o.stop===e||(o={stop:e,directions:[]},s.push(o));continue}if(null==o)continue;const a=t.toArray().filter(({directionPointId:t})=>t===e);0!==a.length&&o.directions.push({directionPoint:r,lines:a})}return s}_handleAddStopClick(){const e=new y;this.viewModel.layer?.stops.add(new w({symbol:e}))}_handleAutoSolveChange({target:e}){this.viewModel.autoSolve=e.checked}_handleCreatePolylineBarrierClick(){this.viewModel.create("polyline-barrier")}_handleClearRouteClick(){this._currentFlowItem="primary",this.viewModel.reset()}_handleCreateStopClick(){this.viewModel.create("stop")}_handleDeleteNetworkFeatureClick(e){this.viewModel.remove(e),this.viewModel.autoSolve&&this._solveRouteDebounced()}_handleDeleteStopClick(e){this._getEffectiveStops().remove(e),this._disposeSearch(e),this._solveRouteDebounced()}_handleDepartureDateChange({currentTarget:{value:e}}){Array.isArray(e)||(this.viewModel.departureIsoDate=e,this._solveRouteDebounced())}_handleDepartureTimeChange({currentTarget:{value:e}}){this.viewModel.departureIsoTime=e,this._solveRouteDebounced()}_handleDepartureTimeOptionChange({currentTarget:e}){const{selectedItems:t}=e;t.length&&(this.viewModel.departureOption=t[0].value,this._solveRouteDebounced())}_handleDirectionsFlowItemBackClick(e){e.stopPropagation(),this._currentFlowItem="primary"}_handleDirectionTurnItemSelect(e){this._activeManeuver===e?this.zoomToRoute():(this._activeManeuver=e,this.viewModel.centerAt(e.geometry))}_handleDirectionTurnPointerEnter(e){this.viewModel.highlight(e)}_handleDirectionTurnPointerLeave(){this.viewModel.clearHighlights()}_handleEditFlowItemBackClick(e){e.stopPropagation(),this.viewModel.stopEditing(),this._currentFlowItem="primary"}_handleEditingDoneClick(){this.viewModel.stopEditing(),this._currentFlowItem="primary"}_handleEditRouteClick(){this._currentFlowItem="edit",this.viewModel.startEditing()}_handleItemDetailsClick(){const e=this.viewModel.layer?.portalItem;e&&window.open(`${e.portal.url}/home/item.html?id=${e.id}`,"_blank")}_handleLocateStopClick(e){const{view:t}=this;if(!t)return;const i="directions-search-tool";this.removeHandles(i),this._searchTool=new k({stop:e,view:t}),this.addHandles([this._searchTool.on("click",async t=>{if(t.mapPoint&&this._stopsToSearches.has(e)){const i=this._stopsToSearches.get(e),s=await i.search(t.mapPoint),o=s?.results?.[0].results?.[0];if(o){const{feature:t,name:s}=o;i.searchTerm=s,e.geometry=t.geometry}}this.removeHandles(i)}),o(()=>{this._searchTool&&(this.view?.tools.remove(this._searchTool),this._searchTool=null)})],i),t.addAndActivateTool(this._searchTool)}_handleOptimizeStopOrderToggle({target:{expanded:e}}){this.viewModel.routeParameters.findBestSequence=e,this._solveRouteDebounced()}_handlePanToStopClick(e){this.viewModel.centerAt(e)}_handlePreserveFirstStopChange({target:{checked:e}}){this.viewModel.routeParameters.preserveFirstStop=e,this._solveRouteDebounced()}_handlePreserveLastStopChange({target:{checked:e}}){this.viewModel.routeParameters.preserveLastStop=e,this._solveRouteDebounced()}_handlePrintDocumentAfterCreate(e){e.focus(),this._printDocument=e,this._printDocumentParent=e.parentElement}_handlePrintDocumentClick(){this._printDocumentOpen=!0}_handlePrintDocumentCloseClick(){this._printDocumentOpen=!1}_handlePrintDocumentKeyDown(e){"Escape"===e.key&&(this._printDocumentOpen=!1)}_handlePrintDocumentPrintClick(){document.body.classList.add(f.printMedia),window.print(),document.body.classList.remove(f.printMedia)}_handleResolveRouteClick(){this._solveRouteDebounced()}_handleReverseStopOrderClick(){this._getEffectiveStops().reverse(),this._solveRouteDebounced()}_handleSaveErrorCloseClick(){this._currentFlowItem=this._parentFlowItem}_handleSaveFlowItemBackClick(e){e.stopPropagation(),this._currentFlowItem=this._parentFlowItem}async _handleSaveLayerAs(){const e=_.getDefault();try{await e.signIn()}catch(t){if(a(t)||"identity-manager:user-aborted"===t.name)return;return this._parentFlowItem=this._currentFlowItem,this._currentFlowItem="save",void(this._saveState="connect-to-portal-error")}this._saveState="fetch-portal-information",this._parentFlowItem=this._currentFlowItem,this._currentFlowItem="save",this._portalUserName=e.user?.username;try{this._portalFolders=await(e.user?.fetchFolders())}catch{return void(this._saveState="fetch-portal-information-error")}this._saveState="save-layer"}_handleSaveLayerClick(){this.viewModel.layer?.save()}_handleSaveLayerButtonClick(){this._saveState="saving";const{layer:e}=this;if(!e||!this._portalFolders)return;const t=this._portalItemNameInput?.value,i=this._portalFolderCombobox?.value,s=this._portalFolders.find(({id:e})=>e===i);e.saveAs({title:t},{folder:s}).then(()=>{e.title=t,this._currentFlowItem=this._parentFlowItem}).catch(()=>{this._saveState="saving-error"})}_handleSaveLayerCancelClick(){this._currentFlowItem=this._parentFlowItem}_handleSaveLayerFolderCreate(e){this._portalFolderCombobox=e}_handleSaveLayerNameCreate(e){this._portalItemNameInput=e}_handleSignInClick(){this.viewModel.load().catch(()=>{})}_handleStopListReorder({detail:{dragEl:e,newIndex:t}}){this._getEffectiveStops().reorder(e.value,t),this._solveRouteDebounced()}_handleTravelModeChange({currentTarget:{selectedItems:e}}){e.length&&(this.viewModel.selectedTravelMode=e[0].value,this._solveRouteDebounced())}_handleViewDrivingDirectionsClick(){this._currentFlowItem="directions"}_normalizeSearchSources(e){this._overrideDefaultSources(e),this._applyLocatorSourceOverrides(e)}_overrideDefaultSources(e){for(const t of e.viewModel.defaultSources)t.autoNavigate=!1}_renderClearRouteAction(e){return A("calcite-action",{bind:this,icon:"trash",key:"clear-route",onclick:this._handleClearRouteClick,...e,text:this.messages.common.clear,textEnabled:!0})}_renderDeleteStopAction(e){return A("calcite-action",{icon:"trash",onclick:this._handleDeleteStopClick.bind(this,e),scale:"s",slot:"actions-end",text:this.messages.deleteStop,title:this.messages.deleteStop})}_renderDepartureTime(){const{DEPART_AT:e,NOW:t,UNSPECIFIED:i}=T;return A("calcite-label",{class:f.departureTime,key:"departure-time"},this.messages.departureTime,A("calcite-combobox",{bind:this,clearDisabled:!0,label:this.messages.departureTime,overlayPositioning:"fixed",selectionMode:"single-persist",onCalciteComboboxChange:this._handleDepartureTimeOptionChange},A("calcite-combobox-item",{heading:this.messages.leaveNow,key:t,label:this.messages.leaveNow,selected:this.viewModel.departureOption===t,value:t}),A("calcite-combobox-item",{heading:this.messages.departAt,key:e,label:this.messages.departAt,selected:this.viewModel.departureOption===e,value:e}),A("calcite-combobox-item",{heading:this.messages.timeUnspecified,key:i,label:this.messages.timeUnspecified,selected:this.viewModel.departureOption===i,value:i})))}_renderDepartureTimeOptions(){return this.viewModel.departureOption!==T.DEPART_AT?null:A("div",{class:f.departureTimeOptions},A("calcite-input-date-picker",{bind:this,scale:"s",value:this.viewModel.departureIsoDate,onCalciteInputDatePickerChange:this._handleDepartureDateChange}),A("calcite-input-time-picker",{bind:this,scale:"s",value:this.viewModel.departureIsoTime,onCalciteInputTimePickerClose:this._handleDepartureTimeChange}))}_renderDirectionsFlowItem(){if("directions"!==this._currentFlowItem)return null;const e=this._getRouteCostSummary();if(!this._sections||!e)return null;const{distance:t,duration:i}=e,{formattedEta:s}=this.viewModel,o=this._sections.at(0)?.stop.name??"",r=this._sections.at(-1)?.stop.name??"";return A("calcite-flow-item",{bind:this,key:"directions-flow-item",overlayPositioning:"fixed",selected:"directions"===this._currentFlowItem,onCalciteFlowItemBack:this._handleDirectionsFlowItemBackClick},A("div",{class:f.directionsHeader,slot:"header-content"},A("div",{class:f.headerStops},A("span",null,this.messages.from)," ",A("span",{class:f.directionsHeaderStopName},o),A("span",null,this.messages.to)," ",A("span",{class:f.directionsHeaderStopName},r)),A("div",{class:f.flexColumn},A("span",null,`${i} (${t})`),s?A("span",null,s):null)),this._renderRouteLayerActions({slot:"header-menu-actions"}),A("calcite-accordion",{class:f.accordion,iconPosition:"start",selectionMode:"single"},this._sections.map((e,t)=>this._renderDirectionSection(e,t))))}_renderDirectionSection(e,t){const{stop:i,directions:s}=e,{name:o}=i,r=0===t,n=this._getStopCostDescription(e);return A("calcite-accordion-item",{description:n,expanded:r,heading:o??"",key:`stop-${t}`},A("calcite-action",{icon:"zoom-to-object",onclick:this._handlePanToStopClick.bind(this,i),slot:"actions-end",text:this.messages.panToStop,title:this.messages.panToStop}),this._renderDirectionTurns(s))}_renderDirectionTurns(e){return A("calcite-list",{label:this.messages.drivingDirections,selectionMode:"none"},e.map((e,t)=>{const{directionPoint:i,lines:s}=e,o=s[0],{distance:r,duration:n}=o,a=M(this.messagesUnits,r??0,this.unit),l=I(n??0),c=a&&l?`${a} | ${l}`:`${a||l}`,d=O(i),h=F(i.directionPointType);return A("calcite-list-item",{class:f.labelNoBottomMargin,key:`driving-direction-${t}`,onpointerenter:this._handleDirectionTurnPointerEnter.bind(this,o),onpointerleave:this._handleDirectionTurnPointerLeave.bind(this),onCalciteListItemSelect:this._handleDirectionTurnItemSelect.bind(this,o)},A("calcite-icon",{icon:h,slot:"content-start"}),A("div",{slot:"content"},A("calcite-label",{layout:"inline",scale:"s"},d),A("calcite-label",{layout:"inline",scale:"s"},c)))}))}_renderEditFlowItem(){return"edit"!==this._currentFlowItem?null:A("calcite-flow-item",{bind:this,heading:this.messages.editRoute,headingLevel:this.headingLevel,key:"edit-flow-item",loading:"routing"===this.viewModel.state,selected:"edit"===this._currentFlowItem,onCalciteFlowItemBack:this._handleEditFlowItemBackClick},A("div",{class:f.flexColumn,key:"edit-container"},A("div",{class:f.editToolbarContainer},A("calcite-label",{layout:"inline",scale:"s"},this.messages.automaticallySolve,A("calcite-switch",{bind:this,checked:this.viewModel.autoSolve,scale:"s",onCalciteSwitchChange:this._handleAutoSolveChange})),A("div",{class:f.editToolbar},A("calcite-action",{bind:this,disabled:!this.viewModel.layer||this.viewModel.layer.stops.length>=this.maxStops,icon:"flag",onclick:this._handleCreateStopClick,scale:"s",text:this.messages.networkFeatures.stops.stop,textEnabled:!0}),A("calcite-action",{bind:this,icon:"line",onclick:this._handleCreatePolylineBarrierClick,scale:"s",text:this.messages.barrier,textEnabled:!0}),A("calcite-action",{bind:this,class:f.solveRoute,disabled:this.viewModel.autoSolve,icon:"refresh",onclick:this._handleResolveRouteClick,scale:"s",text:this.messages.solve,textEnabled:!0}))),A("div",{class:f.selectedFeatureContainer},A("calcite-list",{label:this.messages.selectedNetworkFeatures,scale:"s",selectionMode:"none"},this.viewModel.selectedNetworkFeatures?.toArray().map((e,t)=>A("calcite-list-item",{description:this._getNetworkFeatureName(e),key:`network-feature-${t}`,label:e.name??e.objectId?.toString()??this.messages.unnamed},A("calcite-action",{icon:"trash",onclick:this._handleDeleteNetworkFeatureClick.bind(this,e),scale:"s",slot:"actions-end",text:this.messages.common.delete}))))),A("div",{class:f.editFooter},this._renderEditFooterContent())))}_renderEditFooterContent(){return this.viewModel.lastError?this._renderErrorNotice():A("calcite-button",{appearance:"outline-fill",bind:this,onclick:this._handleEditingDoneClick,width:"full"},this.messages.common.done)}_renderErrorNotice(){return A("calcite-notice",{icon:"exclamation-mark-circle",kind:"danger",open:!0},A("calcite-label",{class:f.labelNoBottomMargin,slot:"message"},this._getErrorDescription()))}_renderFooter(){if(!this.viewModel.layer)return A("div",{class:f.primaryFooter,key:"footer-missing-layer"},A("calcite-notice",{icon:"information",open:!0},A("calcite-label",{class:f.labelNoBottomMargin,slot:"message"},this.messages.missingLayer)));if("unauthenticated"===this.viewModel.state)return A("div",{class:f.primaryFooterCentered,key:"footer-sign-in"},A("calcite-label",null,this.messages.signInRequired),A("calcite-button",{bind:this,onclick:this._handleSignInClick},this.messages.common.auth.signIn));if("routing"===this.viewModel.state)return A("div",{class:this.classes(f.primaryFooter,f.primaryFooterLoader),key:"footer-routing"},A("calcite-loader",{label:this.messages.solve,scale:"s"}));if("error"===this.viewModel.state)return A("div",{class:f.primaryFooter,key:"footer-service-error"},this._renderErrorNotice());if(!this.viewModel.layer?.routeInfo)return A("div",{class:f.primaryFooter,key:"footer-unsolved-route"},A("calcite-notice",{icon:"information",open:!0},A("calcite-label",{class:f.labelNoBottomMargin,slot:"message"},this.messages.directionsPlaceholder)));const e=this._getRouteCostSummary();if(!e||!this.viewModel.layer?.directionPoints)return A("div",{class:f.primaryFooter,key:"footer-invalid-route"},A("calcite-notice",{icon:"exclamation-mark-triangle",kind:"danger",open:!0},A("calcite-label",{class:f.labelNoBottomMargin,slot:"message"},this.messages.invalidRoute)));const{distance:t,duration:i}=e,{formattedEta:s}=this.viewModel;return A("div",{class:f.routeItem,key:"footer-directions-summary"},A("button",{"aria-busy":"false","aria-label":this.messages.viewDrivingDirections,"aria-live":"polite",bind:this,class:f.routeItemButton,onclick:this._handleViewDrivingDirectionsClick,title:this.messages.viewDrivingDirections,type:"button"},A("div",{class:f.routeItemButtonContent},A("span",{class:f.routeItemLabel},`${i} (${t})`),A("span",{class:f.routeItemDescription},s)),A("calcite-icon",{flipRtl:!0,icon:"chevron-right",scale:"s"})),A("calcite-action-menu",{label:"test"},A("calcite-action",{icon:"ellipsis",key:"route-actions",slot:"trigger",text:"Route actions"}),this._renderRouteLayerActions()))}_renderInteractiveRouteActions(){return A("div",{class:f.actionContainer,key:f.actionContainer},A("calcite-button",{appearance:"outline",bind:this,class:f.addStopButton,disabled:this._getEffectiveStops().length>=this.maxStops,iconStart:"plus",kind:"neutral",label:this.messages.addStop,onclick:this._handleAddStopClick,title:this.messages.addStop,width:"half"},this.messages.addStop),this.visibleElements.editRouteButton?A("calcite-button",{appearance:"outline",bind:this,class:f.editRouteButton,disabled:"2d"!==this.viewModel.view?.type,iconStart:"pencil",kind:"neutral",label:this.messages.editRoute,onclick:this._handleEditRouteClick,title:this.messages.editRoute,width:"half"},this.messages.editRoute):null)}_renderLocateStopAction(e){if(null!=e.name||null!=e.geometry)return null;const t=this._getEffectiveStops().indexOf(e),i=!!this.view?.activeTool&&this.view.activeTool===this._searchTool&&this._searchTool.stop===e;return A("calcite-action",{active:i,icon:"crosshair",key:`stop-location-action-${t}`,onclick:this._handleLocateStopClick.bind(this,e),scale:"s",slot:"actions-end",text:this.messages.pickALocationOnTheMap,title:this.messages.pickALocationOnTheMap})}_renderOptimizeStopOrder(){const{routeParameters:e}=this.viewModel,{findBestSequence:t,preserveFirstStop:i,preserveLastStop:s}=e;return A("calcite-block-section",{bind:this,class:f.optimizeSection,text:this.messages.optimizeOrder,toggleDisplay:"switch",onCalciteBlockSectionToggle:this._handleOptimizeStopOrderToggle},t?[A("calcite-label",{class:f.optimizeSwitches,key:"preserve-first-stop",layout:"inline-space-between"},this.messages.preserveFirstStop,A("calcite-switch",{bind:this,checked:i,scale:"s",onCalciteSwitchChange:this._handlePreserveFirstStopChange})),A("calcite-label",{class:f.optimizeSwitches,key:"preserve-last-stop",layout:"inline-space-between"},this.messages.preserveLastStop,A("calcite-switch",{bind:this,checked:s,scale:"s",onCalciteSwitchChange:this._handlePreserveLastStopChange}))]:null)}_renderPrimaryFlowItem(){return A("calcite-flow-item",{key:"primary-flow-item",loading:"initializing"===this.viewModel.state,selected:"primary"===this._currentFlowItem},A("calcite-panel",{class:f.primaryFlowItem,disabled:!this.viewModel.layer||"unauthenticated"===this.viewModel.state||"error"===this.viewModel.state&&!this.viewModel.serviceDescription},this._renderStops(),this._renderInteractiveRouteActions(),this._renderSeparator(),this._renderRouteSolveOptions()),this._renderFooter())}_renderPrintDocument(){if(!this._printDocumentOpen)return null;const e=this._getRouteCostSummary();if(!this._sections||!e)return null;const{distance:t,duration:i}=e,{formattedEta:s}=this.viewModel,o=this._sections.at(0)?.stop.name??"",r=this._sections.at(-1)?.stop.name??"";return A("div",{afterCreate:this._handlePrintDocumentAfterCreate,bind:this,class:f.printDocument,onkeydown:this._handlePrintDocumentKeyDown,tabindex:0},A("div",{class:f.printBody},A("div",{class:f.printHeader},A("div",{class:f.printHeaderLabel},A("div",{class:f.headerStops},A("span",null,this.messages.from)," ",A("span",{class:f.directionsHeaderStopName},o),A("span",null,this.messages.to)," ",A("span",{class:f.directionsHeaderStopName},r))),A("div",{class:this.classes(f.printHeaderButtons,f.printHideOnPrint)},A("calcite-button",{class:f.printDocumentPrint,iconStart:"print",onclick:this._handlePrintDocumentPrintClick},this.messages.common.print),A("calcite-button",{appearance:"outline",bind:this,class:f.printDocumentClose,iconStart:"x-circle",onclick:this._handlePrintDocumentCloseClick},this.messages.common.close))),A("div",{class:f.directionsHeader},A("span",null,`${i} (${t})`),s?A("span",null,s):null),this._sections.map((e,t)=>this._renderPrintSection(e,t))))}_renderPrintManuever(e,t){const{directionPoint:i,lines:s}=e,{distance:o,duration:r}=s.at(0)??{},n=M(this.messagesUnits,o??0,this.unit),a=I(r??0),l=n&&a?`${n} | ${a}`:`${n||a}`,c=O(i),d=F(i.directionPointType);return A("div",{class:this.classes(f.flexRow,f.printAvoidPageBreak),key:`direction-${t}`},A("calcite-icon",{icon:d}),A("div",{class:f.flexColumn},A("span",null,c),A("span",null,l)))}_renderPrintRouteAction(e){if(!this.visibleElements.printButton)return null;const t=!this.viewModel.layer?.routeInfo;return A("calcite-action",{bind:this,disabled:t,icon:"print",key:"print-route",onclick:this._handlePrintDocumentClick,...e,text:this.messages.common.print,textEnabled:!0})}_renderPrintSection({stop:e,directions:t},i){return A("div",{class:f.printSection,key:`section-${i}`},A("span",{class:f.directionsHeaderStopName},e.name??""),t.map((e,t)=>this._renderPrintManuever(e,t)))}_renderRouteLayerActions(e){return[this._renderClearRouteAction(e),this._renderSaveLayerAction(e),this._renderSaveLayerAsAction(e),this._renderPrintRouteAction(e),this._renderViewItemDetailsAction(e)]}_renderRouteSolveOptions(){return A("div",{class:f.marginInlineMedium,key:"route-solve-options"},this._renderTravelModes(),this._renderDepartureTime(),this._renderDepartureTimeOptions(),this._renderOptimizeStopOrder())}_renderSaveContent(){switch(this._saveState){case"initialized":return this._renderSaveInitialized();case"connect-to-portal":return this._renderSaveProcessing(this.messages.identity.lblSigning);case"connect-to-portal-error":return this._renderSaveError(this.messages.errors.authenticating);case"fetch-portal-information":return this._renderSaveProcessing(this.messages.processing.fetching);case"fetch-portal-information-error":return this._renderSaveError(this.messages.errors.fetching);case"save-layer":return this._renderSaveLayerSettings();case"saving":return this._renderSaveProcessing(this.messages.processing.saving);case"saving-error":return this._renderSaveError(this.messages.errors.saving)}}_renderSaveError(e){return A("calcite-panel",{class:f.paddingMedium,key:"save-layer-error"},A("div",{class:f.saveError},A("calcite-icon",{class:f.saveErrorIcon,icon:"exclamation-mark-triangle",scale:"l",textLabel:this.messages.common.errorMessage}),A("calcite-label",{class:f.saveErrorLabel},e)),A("calcite-button",{appearance:"outline",bind:this,onclick:this._handleSaveErrorCloseClick,slot:"footer-actions",width:"full"},this.messages.common.close))}_renderSaveInitialized(){return A("calcite-panel",{class:f.paddingMedium,key:"save-layer-initialized"})}_renderSaveFlowItem(){return"save"!==this._currentFlowItem?null:A("calcite-flow-item",{bind:this,heading:this.messages.saveLayer,headingLevel:this.headingLevel,key:"save-layer-flow-item",selected:"save"===this._currentFlowItem,onCalciteFlowItemBack:this._handleSaveFlowItemBackClick},this._renderSaveContent())}_renderSaveLayerAction(e){if(!this.visibleElements.saveButton)return null;const t=this.viewModel.layer,i=t?.routeInfo,s=t?.portalItem?.itemControl;return A("calcite-action",{bind:this,disabled:!(!!i&&("admin"===s||"update"===s)),icon:"save",key:"save-route",onclick:this._handleSaveLayerClick,...e,text:this.messages.common.save,textEnabled:!0})}_renderSaveLayerAsAction(e){if(!this.visibleElements.saveAsButton)return null;const t=!this.viewModel.layer?.routeInfo;return A("calcite-action",{disabled:t,icon:"save-as",key:"save-as-route",onclick:()=>{this._handleSaveLayerAs()},...e,text:this.messages.common.saveAs,textEnabled:!0})}_renderSaveLayerSettings(){if(null==this.layer||null==this._portalFolders||null==this._portalUserName)return this._renderSaveInitialized();const{stops:e}=this.layer,t=`${e.at(0).name} - ${e.at(-1).name}`,i=[A("calcite-combobox-item",{heading:`${this._portalUserName} (${this.messages.common.home})`,key:f.folderHome,selected:!0,value:f.folderHome}),...this._portalFolders.map(e=>A("calcite-combobox-item",{heading:e.title??"",key:`${f.folder}-${e.id}`,value:e.id}))];return A("calcite-panel",{key:"save-layer-panel"},A("div",{class:f.paddingMedium},A("calcite-label",null,this.messages.layerName,A("calcite-input",{afterCreate:this._handleSaveLayerNameCreate,bind:this,label:this.messages.layerName,value:t})),A("calcite-label",null,this.messages.saveInFolder,A("calcite-combobox",{afterCreate:this._handleSaveLayerFolderCreate,bind:this,clearDisabled:!0,label:this.messages.saveInFolder,overlayPositioning:"fixed",selectionMode:"single-persist"},i))),A("calcite-button",{bind:this,onclick:this._handleSaveLayerButtonClick,slot:"footer-actions",width:"full"},this.messages.common.save),A("calcite-button",{appearance:"outline",bind:this,onclick:this._handleSaveLayerCancelClick,slot:"footer-actions",width:"full"},this.messages.common.cancel))}_renderSaveProcessing(e){return A("calcite-panel",{class:f.marginInlineMedium,key:"save-layer-processing"},A("calcite-loader",{class:f.saveProcessLoader,label:e,text:e}))}_renderSeparator(){return A("div",{class:f.separator})}_renderStop(e){const t=this.acquireSearch(e);null!=e.name&&(t.searchTerm=e.name);const i=this._getEffectiveStops(),s=this._renderLocateStopAction(e),o=i.length>2&&this._renderDeleteStopAction(e);return A("calcite-list-item",{key:e,value:e},s,o,A("div",{class:f.stopItem,slot:"content"},t.render()))}_renderStops(){const e=this._getEffectiveStops();for(const t of this._stopsToSearches.keys())e.includes(t)||this._disposeSearch(t);return A("div",{class:f.stopContainer,key:f.stopContainer},A("calcite-list",{bind:this,class:f.stopList,dragEnabled:!0,label:this.messages.widgetLabel,scale:"s",onCalciteListOrderChange:this._handleStopListReorder},e.toArray().map(e=>this._renderStop(e))),2===e.length&&A("calcite-action",{bind:this,icon:"arrow-up-down",onclick:this._handleReverseStopOrderClick,scale:"s",text:this.messages.reverseStops,title:this.messages.reverseStops}))}_renderTravelMode(e){const{id:t,name:i}=e;return A("calcite-combobox-item",{heading:i,key:t,label:i,selected:this.viewModel.selectedTravelMode?.id===t,value:e})}_renderTravelModes(){return this.viewModel.travelModes.length?A("calcite-label",{key:"travel-modes"},this.messages.mode,A("calcite-combobox",{bind:this,clearDisabled:!0,label:this.messages.mode,overlayPositioning:"fixed",selectionMode:"single-persist",onCalciteComboboxChange:this._handleTravelModeChange},this.viewModel.travelModes.map(e=>this._renderTravelMode(e)))):null}_renderViewItemDetailsAction(e){return this.visibleElements.layerDetails?A("calcite-action",{bind:this,disabled:!this.viewModel.layer?.portalItem,icon:"launch",key:"open-route-details-link",onclick:this._handleItemDetailsClick,...e,text:this.messages.viewLayerDetails,textEnabled:!0}):null}async _solveRoute(){this.viewModel.updateDepartureTime();if(!((this.viewModel.layer?.stops.filter(({geometry:e})=>!!e).length??0)<2))try{await this.viewModel.getDirections()}catch{}}};e([p()],N.prototype,"_printDocumentOpen",void 0),e([p()],N.prototype,"_currentFlowItem",void 0),e([p()],N.prototype,"_saveState",void 0),e([p()],N.prototype,"_searchTool",void 0),e([p()],N.prototype,"apiKey",null),e([p(g)],N.prototype,"defaultUnit",void 0),e([p()],N.prototype,"goToOverride",null),e([p()],N.prototype,"headingLevel",void 0),e([p()],N.prototype,"icon",null),e([p()],N.prototype,"label",null),e([p({readOnly:!0})],N.prototype,"lastRoute",null),e([p()],N.prototype,"layer",null),e([p()],N.prototype,"maxStops",null),e([p(),L("esri/widgets/Directions/t9n/Directions")],N.prototype,"messages",void 0),e([p(),L("esri/core/t9n/Units")],N.prototype,"messagesUnits",void 0),e([p()],N.prototype,"searchProperties",void 0),e([p()],N.prototype,"unit",null),e([p()],N.prototype,"view",null),e([p({type:C})],N.prototype,"viewModel",void 0),e([p({type:D,nonNullable:!0})],N.prototype,"visibleElements",void 0),N=e([m("esri.widgets.Directions")],N);const j=N;export{j as default};
|
|
5
|
+
import{__decorate as e}from"tslib";import{isSome as t}from"../core/arrayUtils.js";import i from"../core/Collection.js";import{addEventListener as s}from"../core/events.js";import{makeHandle as o}from"../core/handleUtils.js";import{destroyMaybe as r}from"../core/maybe.js";import{debounce as a,isAbortError as n}from"../core/promiseUtils.js";import{watch as l,initial as c,on as d}from"../core/reactiveUtils.js";import{escapeRegExpString as h}from"../core/string.js";import{property as p}from"../core/accessorSupport/decorators/property.js";import"../core/has.js";import"../core/Logger.js";import{subclass as m}from"../core/accessorSupport/decorators/subclass.js";import{onLocaleChange as u,getLocaleLanguage as v}from"../intl/locale.js";import g from"../portal/Portal.js";import{defaultUnitPropertyMetadata as _}from"../properties/defaultUnit.js";import w from"../rest/support/Stop.js";import y from"../symbols/SimpleMarkerSymbol.js";import b from"./Search.js";import S from"./Widget.js";import{css as f}from"./Directions/css.js";import{DirectionsSearchTool as k}from"./Directions/DirectionsSearchTool.js";import C from"./Directions/DirectionsViewModel.js";import D from"./Directions/DirectionsVisibleElements.js";import{formatDistance as M,formatDuration as I,DepartureTimeOption as P,getIconName as T}from"./Directions/support/directionsUtils.js";import{isArcGISWorldGeocoder as F,meteredArcGISLocatorUrl as x}from"./Search/support/locatorUtils.js";import{loadCalciteComponents as E}from"./support/componentsUtils.js";import{globalCss as R}from"./support/globalCss.js";import"./support/widgetUtils.js";import{messageBundle as L}from"./support/decorators/messageBundle.js";import{tsx as A}from"./support/jsxFactory.js";import"@arcgis/toolkit/dom";function N(e){const{branchName:i,displayText:s,exitName:o,intersectingName:r,name:a,towardName:n}=e;if(null==s)return null;const l=[i,o,r,a,n].filter(t).sort((e,t)=>t.length-e.length).map(e=>h(e));if(!l.length)return s;const c=new RegExp(l.join("|"),"g"),d=s.matchAll(c);let p=0;const m=[];for(const{0:t,index:h}of d)m.push(s.slice(p,h),A("span",{class:f.labelEmphasize,key:`maneuver-${h}`},t)),p=h+t.length;return m.push(s.slice(p)),A("span",null,m)}const O="print-preview-closed";let j=class extends S{constructor(e,t){super(e,t),this._activeManeuver=null,this._placeholderStops=new i([new w,new w]),this._portalFolderCombobox=null,this._portalFolders=null,this._portalItemNameInput=null,this._portalUserName=null,this._printPreviewDialog=null,this._sections=null,this._stopsToSearches=new Map,this._printPreviewDialogOpen=!1,this._currentFlowItem="primary",this._parentFlowItem="primary",this._saveState="initialized",this._searchTool=null,this.headingLevel=2,this.messages=null,this.messagesUnits=null,this.searchProperties={popupEnabled:!1,resultGraphicEnabled:!1},this.viewModel=new C,this.visibleElements=new D,this._solveRouteDebounced=a(()=>this._solveRoute())}initialize(){this.addHandles([l(()=>this.viewModel.layer,()=>{try{this.viewModel.load()}catch{}},c),l(()=>this.viewModel.layer?.routeInfo,()=>{this._sections=this._getStopSections()},c),l(()=>this.viewModel.layer?.stops.toArray(),e=>{e&&this.view?.activeTool&&this._searchTool&&this.view.activeTool===this._searchTool&&!e.includes(this._searchTool.stop)&&(this.view.tools.remove(this._searchTool),this._searchTool=null)})])}loadDependencies(){return E({accordion:()=>import("@esri/calcite-components/dist/components/calcite-accordion"),"accordion-item":()=>import("@esri/calcite-components/dist/components/calcite-accordion-item"),action:()=>import("@esri/calcite-components/dist/components/calcite-action"),"action-menu":()=>import("@esri/calcite-components/dist/components/calcite-action-menu"),"block-section":()=>import("@esri/calcite-components/dist/components/calcite-block-section"),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"),flow:()=>import("@esri/calcite-components/dist/components/calcite-flow"),"flow-item":()=>import("@esri/calcite-components/dist/components/calcite-flow-item"),icon:()=>import("@esri/calcite-components/dist/components/calcite-icon"),input:()=>import("@esri/calcite-components/dist/components/calcite-input"),"input-date-picker":()=>import("@esri/calcite-components/dist/components/calcite-input-date-picker"),"input-time-picker":()=>import("@esri/calcite-components/dist/components/calcite-input-time-picker"),label:()=>import("@esri/calcite-components/dist/components/calcite-label"),list:()=>import("@esri/calcite-components/dist/components/calcite-list"),"list-item":()=>import("@esri/calcite-components/dist/components/calcite-list-item"),loader:()=>import("@esri/calcite-components/dist/components/calcite-loader"),notice:()=>import("@esri/calcite-components/dist/components/calcite-notice"),panel:()=>import("@esri/calcite-components/dist/components/calcite-panel"),switch:()=>import("@esri/calcite-components/dist/components/calcite-switch")})}destroy(){this._stopsToSearches.forEach(r)}get apiKey(){return this.viewModel.apiKey}set apiKey(e){this.viewModel.apiKey=e}get goToOverride(){return this.viewModel.goToOverride}set goToOverride(e){this.viewModel.goToOverride=e}get icon(){return"right"}set icon(e){this._overrideIfSome("icon",e)}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get lastRoute(){return this.viewModel.lastRoute}get layer(){return this.viewModel.layer}set layer(e){this.viewModel.layer=e}get maxStops(){return this.viewModel.maxStops}set maxStops(e){this.viewModel.maxStops=e}get unit(){return this.defaultUnit}set unit(e){this._overrideIfSome("unit",e)}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}acquireSearch(e){const{view:t}=this.viewModel;if(this._stopsToSearches.has(e)){const i=this._stopsToSearches.get(e);return i.view=t,this._overrideDefaultSources(i),i}const i=new b({icon:"",popupEnabled:!1,resultGraphicEnabled:!1,view:t,...this.searchProperties});return this._normalizeSearchSources(i),this.addHandles([d(()=>i.allSources,"change",()=>this._normalizeSearchSources(i)),i.on("search-clear",()=>{e.geometry=null,e.name=null,this.viewModel.layer?.removeResult()}),i.on("select-result",()=>{const t=i.selectedResult;e.geometry=t?.feature.geometry,e.name=t?.name,this._solveRouteDebounced()}),l(()=>i.searchTerm,t=>{e.name=t}),u(()=>this._normalizeSearchSources(i))],i),this._stopsToSearches.set(e,i),i}getDirections(){return this.viewModel.getDirections()}render(){return A("div",{class:this.classes(f.base,R.widget,R.panel)},A("calcite-flow",null,this._renderPrimaryFlowItem(),this._renderDirectionsFlowItem(),this._renderEditFlowItem(),this._renderSaveFlowItem()),this._renderPrintDocument())}save(){return this.viewModel.save()}saveAs(e,t={}){return this.viewModel.saveAs(e,t)}zoomToRoute(){return this.viewModel.zoomToRoute()}_applyLocatorSourceOverrides({allSources:e}){for(const t of e)"url"in t&&t.url&&(t.language=v(),t.locationType??="street",F(t.url)&&this.apiKey&&null==t.apiKey&&(t.apiKey=this.apiKey,t.url=x))}_disposeSearch(e){if(!e||!this._stopsToSearches.has(e))return;const t=this._stopsToSearches.get(e);this.removeHandles(t),t.destroy(),this._stopsToSearches.delete(e)}_getEffectiveStops(){return this.viewModel.layer?.stops??this._placeholderStops}_getErrorDescription(){switch(this.viewModel.lastError?.name){case"directions-view-model:unable-to-route":return this.messages.errors.unableToRoute;case"directions-view-model:service-metadata-unavailable":return this.messages.errors.unableToLoadServiceMetadata;default:return this.messages.errors.unknownError}}_getNetworkFeatureName(e){switch(e.type){case"stop":switch(e.locationType){case"stop":default:return this.messages.networkFeatures.stops.stop;case"waypoint":return this.messages.networkFeatures.stops.waypoint;case"break":return this.messages.networkFeatures.stops.break}case"point-barrier":return this.messages.networkFeatures.pointBarrier;case"polyline-barrier":return this.messages.networkFeatures.polylineBarrier;case"polygon-barrier":return this.messages.networkFeatures.polygonBarrier}}_getRouteCostSummary(){const e=this.viewModel.layer?.routeInfo;if(!e)return null;const t=e.totalDistance??0,i=e.totalDuration??0,{messagesUnits:s,unit:o}=this;return{distance:M(s,t,o),duration:I(i)}}_getStopCostDescription(e){if(!e.directions.length)return;const{totalDistance:t,totalDuration:i}=e.directions.reduce((e,{lines:t})=>{for(const{distance:i,duration:s}of t)e.totalDistance+=i??0,e.totalDuration+=s??0;return e},{totalDistance:0,totalDuration:0}),{messagesUnits:s,unit:o}=this,r=M(s,t,o);return`${I(i)} (${r})`}_getStopSections(){if(!this.viewModel.layer)return null;const{directionPoints:e,directionLines:t,stops:i}=this.viewModel.layer;if(!e||!t)return null;const s=[];let o=null;for(const r of e){const{objectId:e,stopId:a}=r;if(null!=a){const e=i.find(({objectId:e})=>e===a);o&&o.stop===e||(o={stop:e,directions:[]},s.push(o));continue}if(null==o)continue;const n=t.toArray().filter(({directionPointId:t})=>t===e);0!==n.length&&o.directions.push({directionPoint:r,lines:n})}return s}_handleAddStopClick(){const e=new y;this.viewModel.layer?.stops.add(new w({symbol:e}))}_handleAutoSolveChange({target:e}){this.viewModel.autoSolve=e.checked}_handleCreatePolylineBarrierClick(){this.viewModel.create("polyline-barrier")}_handleClearRouteClick(){this._currentFlowItem="primary",this.viewModel.reset()}_handleCreateStopClick(){this.viewModel.create("stop")}_handleDeleteNetworkFeatureClick(e){this.viewModel.remove(e),this.viewModel.autoSolve&&this._solveRouteDebounced()}_handleDeleteStopClick(e){this._getEffectiveStops().remove(e),this._disposeSearch(e),this._solveRouteDebounced()}_handleDepartureDateChange({currentTarget:{value:e}}){Array.isArray(e)||(this.viewModel.departureIsoDate=e,this._solveRouteDebounced())}_handleDepartureTimeChange({currentTarget:{value:e}}){this.viewModel.departureIsoTime=e,this._solveRouteDebounced()}_handleDepartureTimeOptionChange({currentTarget:e}){const{selectedItems:t}=e;t.length&&(this.viewModel.departureOption=t[0].value,this._solveRouteDebounced())}_handleDirectionsFlowItemBackClick(e){e.stopPropagation(),this._currentFlowItem="primary"}_handleDirectionTurnItemSelect(e){this._activeManeuver===e?this.zoomToRoute():(this._activeManeuver=e,this.viewModel.centerAt(e.geometry))}_handleDirectionTurnPointerEnter(e){this.viewModel.highlight(e)}_handleDirectionTurnPointerLeave(){this.viewModel.clearHighlights()}_handleEditFlowItemBackClick(e){e.stopPropagation(),this.viewModel.stopEditing(),this._currentFlowItem="primary"}_handleEditingDoneClick(){this.viewModel.stopEditing(),this._currentFlowItem="primary"}_handleEditRouteClick(){this._currentFlowItem="edit",this.viewModel.startEditing()}_handleItemDetailsClick(){const e=this.viewModel.layer?.portalItem;e&&window.open(`${e.portal.url}/home/item.html?id=${e.id}`,"_blank")}_handleLocateStopClick(e){const{view:t}=this;if(!t)return;const i="directions-search-tool";this.removeHandles(i),this._searchTool=new k({stop:e,view:t}),this.addHandles([this._searchTool.on("click",async t=>{if(t.mapPoint&&this._stopsToSearches.has(e)){const i=this._stopsToSearches.get(e),s=await i.search(t.mapPoint),o=s?.results?.[0].results?.[0];if(o){const{feature:t,name:s}=o;i.searchTerm=s,e.geometry=t.geometry}}this.removeHandles(i)}),o(()=>{this._searchTool&&(this.view?.tools.remove(this._searchTool),this._searchTool=null)})],i),t.addAndActivateTool(this._searchTool)}_handleOptimizeStopOrderToggle({target:{expanded:e}}){this.viewModel.routeParameters.findBestSequence=e,this._solveRouteDebounced()}_handlePanToStopClick(e){this.viewModel.centerAt(e)}_handlePreserveFirstStopChange({target:{checked:e}}){this.viewModel.routeParameters.preserveFirstStop=e,this._solveRouteDebounced()}_handlePreserveLastStopChange({target:{checked:e}}){this.viewModel.routeParameters.preserveLastStop=e,this._solveRouteDebounced()}_handlePrintPreviewDialogAfterCreate(e){document.body.appendChild(e),e.showModal(),this._printPreviewDialog=e,this.removeHandles(O),this.addHandles([s(e,"close",this._handlePrintPreviewDialogClosed.bind(this)),o(()=>{this._printPreviewDialog&&(document.body.removeChild(this._printPreviewDialog),this._printPreviewDialog=null,this._printPreviewDialogOpen=!1)})],O)}_handlePrintPreviewDialogClick(){this._printPreviewDialogOpen=!0}_handlePrintPreviewDialogCloseClick(){this._printPreviewDialog?.close()}_handlePrintPreviewDialogClosed(){this.removeHandles(O)}_handlePrintPreviewDialogPrintClick(){document.body.classList.add(f.printPreviewMedia),window.print(),document.body.classList.remove(f.printPreviewMedia),this._printPreviewDialog?.close()}_handleResolveRouteClick(){this._solveRouteDebounced()}_handleReverseStopOrderClick(){this._getEffectiveStops().reverse(),this._solveRouteDebounced()}_handleSaveErrorCloseClick(){this._currentFlowItem=this._parentFlowItem}_handleSaveFlowItemBackClick(e){e.stopPropagation(),this._currentFlowItem=this._parentFlowItem}async _handleSaveLayerAs(){const e=g.getDefault();try{await e.signIn()}catch(t){if(n(t)||"identity-manager:user-aborted"===t.name)return;return this._parentFlowItem=this._currentFlowItem,this._currentFlowItem="save",void(this._saveState="connect-to-portal-error")}this._saveState="fetch-portal-information",this._parentFlowItem=this._currentFlowItem,this._currentFlowItem="save",this._portalUserName=e.user?.username;try{this._portalFolders=await(e.user?.fetchFolders())}catch{return void(this._saveState="fetch-portal-information-error")}this._saveState="save-layer"}_handleSaveLayerClick(){this.viewModel.layer?.save()}_handleSaveLayerButtonClick(){this._saveState="saving";const{layer:e}=this;if(!e||!this._portalFolders)return;const t=this._portalItemNameInput?.value,i=this._portalFolderCombobox?.value,s=this._portalFolders.find(({id:e})=>e===i);e.saveAs({title:t},{folder:s}).then(()=>{e.title=t,this._currentFlowItem=this._parentFlowItem}).catch(()=>{this._saveState="saving-error"})}_handleSaveLayerCancelClick(){this._currentFlowItem=this._parentFlowItem}_handleSaveLayerFolderCreate(e){this._portalFolderCombobox=e}_handleSaveLayerNameCreate(e){this._portalItemNameInput=e}_handleSignInClick(){this.viewModel.load().catch(()=>{})}_handleStopListReorder({detail:{dragEl:e,newIndex:t}}){this._getEffectiveStops().reorder(e.value,t),this._solveRouteDebounced()}_handleTravelModeChange({currentTarget:{selectedItems:e}}){e.length&&(this.viewModel.selectedTravelMode=e[0].value,this._solveRouteDebounced())}_handleViewDrivingDirectionsClick(){this._currentFlowItem="directions"}_normalizeSearchSources(e){this._overrideDefaultSources(e),this._applyLocatorSourceOverrides(e)}_overrideDefaultSources(e){for(const t of e.viewModel.defaultSources)t.autoNavigate=!1}_renderClearRouteAction(e){return A("calcite-action",{bind:this,icon:"trash",key:"clear-route",onclick:this._handleClearRouteClick,...e,text:this.messages.common.clear,textEnabled:!0})}_renderDeleteStopAction(e){return A("calcite-action",{icon:"trash",onclick:this._handleDeleteStopClick.bind(this,e),scale:"s",slot:"actions-end",text:this.messages.deleteStop,title:this.messages.deleteStop})}_renderDepartureTime(){const{DEPART_AT:e,NOW:t,UNSPECIFIED:i}=P;return A("calcite-label",{class:f.departureTime,key:"departure-time"},this.messages.departureTime,A("calcite-combobox",{bind:this,clearDisabled:!0,label:this.messages.departureTime,overlayPositioning:"fixed",selectionMode:"single-persist",onCalciteComboboxChange:this._handleDepartureTimeOptionChange},A("calcite-combobox-item",{heading:this.messages.leaveNow,key:t,label:this.messages.leaveNow,selected:this.viewModel.departureOption===t,value:t}),A("calcite-combobox-item",{heading:this.messages.departAt,key:e,label:this.messages.departAt,selected:this.viewModel.departureOption===e,value:e}),A("calcite-combobox-item",{heading:this.messages.timeUnspecified,key:i,label:this.messages.timeUnspecified,selected:this.viewModel.departureOption===i,value:i})))}_renderDepartureTimeOptions(){return this.viewModel.departureOption!==P.DEPART_AT?null:A("div",{class:f.departureTimeOptions},A("calcite-input-date-picker",{bind:this,scale:"s",value:this.viewModel.departureIsoDate,onCalciteInputDatePickerChange:this._handleDepartureDateChange}),A("calcite-input-time-picker",{bind:this,scale:"s",value:this.viewModel.departureIsoTime,onCalciteInputTimePickerClose:this._handleDepartureTimeChange}))}_renderDirectionsFlowItem(){if("directions"!==this._currentFlowItem)return null;const e=this._getRouteCostSummary();if(!this._sections||!e)return null;const{distance:t,duration:i}=e,{formattedEta:s}=this.viewModel,o=this._sections.at(0)?.stop.name??"",r=this._sections.at(-1)?.stop.name??"";return A("calcite-flow-item",{bind:this,key:"directions-flow-item",overlayPositioning:"fixed",selected:"directions"===this._currentFlowItem,onCalciteFlowItemBack:this._handleDirectionsFlowItemBackClick},A("div",{class:f.directionsHeader,slot:"header-content"},A("div",{class:f.headerStops},A("span",null,this.messages.from)," ",A("span",{class:f.directionsHeaderStopName},o),A("span",null,this.messages.to)," ",A("span",{class:f.directionsHeaderStopName},r)),A("div",{class:f.flexColumn},A("span",null,`${i} (${t})`),s?A("span",null,s):null)),this._renderRouteLayerActions({slot:"header-menu-actions"}),A("calcite-accordion",{class:f.accordion,iconPosition:"start",selectionMode:"single"},this._sections.map((e,t)=>this._renderDirectionSection(e,t))))}_renderDirectionSection(e,t){const{stop:i,directions:s}=e,{name:o}=i,r=0===t,a=this._getStopCostDescription(e);return A("calcite-accordion-item",{description:a,expanded:r,heading:o??"",key:`stop-${t}`},A("calcite-action",{icon:"zoom-to-object",onclick:this._handlePanToStopClick.bind(this,i),slot:"actions-end",text:this.messages.panToStop,title:this.messages.panToStop}),this._renderDirectionTurns(s))}_renderDirectionTurns(e){return A("calcite-list",{label:this.messages.drivingDirections,selectionMode:"none"},e.map((e,t)=>{const{directionPoint:i,lines:s}=e,o=s[0],{distance:r,duration:a}=o,n=M(this.messagesUnits,r??0,this.unit),l=I(a??0),c=n&&l?`${n} | ${l}`:`${n||l}`,d=N(i),h=T(i.directionPointType);return A("calcite-list-item",{class:f.labelNoBottomMargin,key:`driving-direction-${t}`,onpointerenter:this._handleDirectionTurnPointerEnter.bind(this,o),onpointerleave:this._handleDirectionTurnPointerLeave.bind(this),onCalciteListItemSelect:this._handleDirectionTurnItemSelect.bind(this,o)},A("calcite-icon",{icon:h,slot:"content-start"}),A("div",{slot:"content"},A("calcite-label",{layout:"inline",scale:"s"},d),A("calcite-label",{layout:"inline",scale:"s"},c)))}))}_renderEditFlowItem(){return"edit"!==this._currentFlowItem?null:A("calcite-flow-item",{bind:this,heading:this.messages.editRoute,headingLevel:this.headingLevel,key:"edit-flow-item",loading:"routing"===this.viewModel.state,selected:"edit"===this._currentFlowItem,onCalciteFlowItemBack:this._handleEditFlowItemBackClick},A("div",{class:f.flexColumn,key:"edit-container"},A("div",{class:f.editToolbarContainer},A("calcite-label",{layout:"inline",scale:"s"},this.messages.automaticallySolve,A("calcite-switch",{bind:this,checked:this.viewModel.autoSolve,scale:"s",onCalciteSwitchChange:this._handleAutoSolveChange})),A("div",{class:f.editToolbar},A("calcite-action",{bind:this,disabled:!this.viewModel.layer||this.viewModel.layer.stops.length>=this.maxStops,icon:"flag",onclick:this._handleCreateStopClick,scale:"s",text:this.messages.networkFeatures.stops.stop,textEnabled:!0}),A("calcite-action",{bind:this,icon:"line",onclick:this._handleCreatePolylineBarrierClick,scale:"s",text:this.messages.barrier,textEnabled:!0}),A("calcite-action",{bind:this,class:f.solveRoute,disabled:this.viewModel.autoSolve,icon:"refresh",onclick:this._handleResolveRouteClick,scale:"s",text:this.messages.solve,textEnabled:!0}))),A("div",{class:f.selectedFeatureContainer},A("calcite-list",{label:this.messages.selectedNetworkFeatures,scale:"s",selectionMode:"none"},this.viewModel.selectedNetworkFeatures?.toArray().map((e,t)=>A("calcite-list-item",{description:this._getNetworkFeatureName(e),key:`network-feature-${t}`,label:e.name??e.objectId?.toString()??this.messages.unnamed},A("calcite-action",{icon:"trash",onclick:this._handleDeleteNetworkFeatureClick.bind(this,e),scale:"s",slot:"actions-end",text:this.messages.common.delete}))))),A("div",{class:f.editFooter},this._renderEditFooterContent())))}_renderEditFooterContent(){return this.viewModel.lastError?this._renderErrorNotice():A("calcite-button",{appearance:"outline-fill",bind:this,onclick:this._handleEditingDoneClick,width:"full"},this.messages.common.done)}_renderErrorNotice(){return A("calcite-notice",{icon:"exclamation-mark-circle",kind:"danger",open:!0},A("calcite-label",{class:f.labelNoBottomMargin,slot:"message"},this._getErrorDescription()))}_renderFooter(){if(!this.viewModel.layer)return A("div",{class:f.primaryFooter,key:"footer-missing-layer"},A("calcite-notice",{icon:"information",open:!0},A("calcite-label",{class:f.labelNoBottomMargin,slot:"message"},this.messages.missingLayer)));if("unauthenticated"===this.viewModel.state)return A("div",{class:f.primaryFooterCentered,key:"footer-sign-in"},A("calcite-label",null,this.messages.signInRequired),A("calcite-button",{bind:this,onclick:this._handleSignInClick},this.messages.common.auth.signIn));if("routing"===this.viewModel.state)return A("div",{class:this.classes(f.primaryFooter,f.primaryFooterLoader),key:"footer-routing"},A("calcite-loader",{label:this.messages.solve,scale:"s"}));if("error"===this.viewModel.state)return A("div",{class:f.primaryFooter,key:"footer-service-error"},this._renderErrorNotice());if(!this.viewModel.layer?.routeInfo)return A("div",{class:f.primaryFooter,key:"footer-unsolved-route"},A("calcite-notice",{icon:"information",open:!0},A("calcite-label",{class:f.labelNoBottomMargin,slot:"message"},this.messages.directionsPlaceholder)));const e=this._getRouteCostSummary();if(!e||!this.viewModel.layer?.directionPoints)return A("div",{class:f.primaryFooter,key:"footer-invalid-route"},A("calcite-notice",{icon:"exclamation-mark-triangle",kind:"danger",open:!0},A("calcite-label",{class:f.labelNoBottomMargin,slot:"message"},this.messages.invalidRoute)));const{distance:t,duration:i}=e,{formattedEta:s}=this.viewModel;return A("div",{class:f.routeItem,key:"footer-directions-summary"},A("button",{"aria-busy":"false","aria-label":this.messages.viewDrivingDirections,"aria-live":"polite",bind:this,class:f.routeItemButton,onclick:this._handleViewDrivingDirectionsClick,title:this.messages.viewDrivingDirections,type:"button"},A("div",{class:f.routeItemButtonContent},A("span",{class:f.routeItemLabel},`${i} (${t})`),A("span",{class:f.routeItemDescription},s)),A("calcite-icon",{flipRtl:!0,icon:"chevron-right",scale:"s"})),A("calcite-action-menu",{label:"test"},A("calcite-action",{icon:"ellipsis",key:"route-actions",slot:"trigger",text:"Route actions"}),this._renderRouteLayerActions()))}_renderInteractiveRouteActions(){return A("div",{class:f.actionContainer,key:f.actionContainer},A("calcite-button",{appearance:"outline",bind:this,class:f.addStopButton,disabled:this._getEffectiveStops().length>=this.maxStops,iconStart:"plus",kind:"neutral",label:this.messages.addStop,onclick:this._handleAddStopClick,title:this.messages.addStop,width:"half"},this.messages.addStop),this.visibleElements.editRouteButton?A("calcite-button",{appearance:"outline",bind:this,class:f.editRouteButton,disabled:"2d"!==this.viewModel.view?.type,iconStart:"pencil",kind:"neutral",label:this.messages.editRoute,onclick:this._handleEditRouteClick,title:this.messages.editRoute,width:"half"},this.messages.editRoute):null)}_renderLocateStopAction(e){if(null!=e.name||null!=e.geometry)return null;const t=this._getEffectiveStops().indexOf(e),i=!!this.view?.activeTool&&this.view.activeTool===this._searchTool&&this._searchTool.stop===e;return A("calcite-action",{active:i,icon:"crosshair",key:`stop-location-action-${t}`,onclick:this._handleLocateStopClick.bind(this,e),scale:"s",slot:"actions-end",text:this.messages.pickALocationOnTheMap,title:this.messages.pickALocationOnTheMap})}_renderOptimizeStopOrder(){const{routeParameters:e}=this.viewModel,{findBestSequence:t,preserveFirstStop:i,preserveLastStop:s}=e;return A("calcite-block-section",{bind:this,class:f.optimizeSection,text:this.messages.optimizeOrder,toggleDisplay:"switch",onCalciteBlockSectionToggle:this._handleOptimizeStopOrderToggle},t?[A("calcite-label",{class:f.optimizeSwitches,key:"preserve-first-stop",layout:"inline-space-between"},this.messages.preserveFirstStop,A("calcite-switch",{bind:this,checked:i,scale:"s",onCalciteSwitchChange:this._handlePreserveFirstStopChange})),A("calcite-label",{class:f.optimizeSwitches,key:"preserve-last-stop",layout:"inline-space-between"},this.messages.preserveLastStop,A("calcite-switch",{bind:this,checked:s,scale:"s",onCalciteSwitchChange:this._handlePreserveLastStopChange}))]:null)}_renderPrimaryFlowItem(){return A("calcite-flow-item",{key:"primary-flow-item",loading:"initializing"===this.viewModel.state,selected:"primary"===this._currentFlowItem},A("calcite-panel",{class:f.primaryFlowItem,disabled:!this.viewModel.layer||"unauthenticated"===this.viewModel.state||"error"===this.viewModel.state&&!this.viewModel.serviceDescription},this._renderStops(),this._renderInteractiveRouteActions(),this._renderSeparator(),this._renderRouteSolveOptions()),this._renderFooter())}_renderPrintDocument(){if(!this._printPreviewDialogOpen)return null;const e=this._getRouteCostSummary();if(!this._sections||!e)return null;const{distance:t,duration:i}=e,{formattedEta:s}=this.viewModel,o=this._sections.at(0)?.stop.name??"",r=this._sections.at(-1)?.stop.name??"";return A("dialog",{afterCreate:this._handlePrintPreviewDialogAfterCreate,bind:this,class:f.printPreviewDialog},A("div",{class:f.printPreviewContent},A("div",{class:f.printPreviewHeader},A("div",{class:f.printPreviewHeaderLabel},A("div",{class:f.headerStops},A("span",null,this.messages.from)," ",A("span",{class:f.directionsHeaderStopName},o),A("span",null,this.messages.to)," ",A("span",{class:f.directionsHeaderStopName},r))),A("div",{class:this.classes(f.printPreviewHeaderButtons,f.printPreviewHideOnPrint)},A("calcite-button",{autofocus:!0,bind:this,class:f.printPreviewDialogPrint,iconStart:"print",onclick:this._handlePrintPreviewDialogPrintClick},this.messages.common.print),A("calcite-button",{appearance:"outline",bind:this,class:f.printPreviewDialogClose,iconStart:"x-circle",onclick:this._handlePrintPreviewDialogCloseClick},this.messages.common.close))),A("div",{class:f.directionsHeader},A("span",null,`${i} (${t})`),s?A("span",null,s):null),this._sections.map((e,t)=>this._renderPrintSection(e,t))))}_renderPrintManeuver(e,t){const{directionPoint:i,lines:s}=e,{distance:o,duration:r}=s.at(0)??{},a=M(this.messagesUnits,o??0,this.unit),n=I(r??0),l=a&&n?`${a} | ${n}`:`${a||n}`,c=N(i),d=T(i.directionPointType);return A("div",{class:this.classes(f.flexRow,f.printPreviewAvoidPageBreak),key:`direction-${t}`},A("calcite-icon",{icon:d}),A("div",{class:f.flexColumn},A("span",null,c),A("span",null,l)))}_renderPrintRouteAction(e){if(!this.visibleElements.printButton)return null;const t=!this.viewModel.layer?.routeInfo;return A("calcite-action",{bind:this,disabled:t,icon:"print",key:"print-route",onclick:this._handlePrintPreviewDialogClick,...e,text:this.messages.common.print,textEnabled:!0})}_renderPrintSection({stop:e,directions:t},i){return A("div",{class:f.printPreviewSection,key:`section-${i}`},A("span",{class:f.directionsHeaderStopName},e.name??""),t.map((e,t)=>this._renderPrintManeuver(e,t)))}_renderRouteLayerActions(e){return[this._renderClearRouteAction(e),this._renderSaveLayerAction(e),this._renderSaveLayerAsAction(e),this._renderPrintRouteAction(e),this._renderViewItemDetailsAction(e)]}_renderRouteSolveOptions(){return A("div",{class:f.marginInlineMedium,key:"route-solve-options"},this._renderTravelModes(),this._renderDepartureTime(),this._renderDepartureTimeOptions(),this._renderOptimizeStopOrder())}_renderSaveContent(){switch(this._saveState){case"initialized":return this._renderSaveInitialized();case"connect-to-portal":return this._renderSaveProcessing(this.messages.identity.lblSigning);case"connect-to-portal-error":return this._renderSaveError(this.messages.errors.authenticating);case"fetch-portal-information":return this._renderSaveProcessing(this.messages.processing.fetching);case"fetch-portal-information-error":return this._renderSaveError(this.messages.errors.fetching);case"save-layer":return this._renderSaveLayerSettings();case"saving":return this._renderSaveProcessing(this.messages.processing.saving);case"saving-error":return this._renderSaveError(this.messages.errors.saving)}}_renderSaveError(e){return A("calcite-panel",{class:f.paddingMedium,key:"save-layer-error"},A("div",{class:f.saveError},A("calcite-icon",{class:f.saveErrorIcon,icon:"exclamation-mark-triangle",scale:"l",textLabel:this.messages.common.errorMessage}),A("calcite-label",{class:f.saveErrorLabel},e)),A("calcite-button",{appearance:"outline",bind:this,onclick:this._handleSaveErrorCloseClick,slot:"footer-actions",width:"full"},this.messages.common.close))}_renderSaveInitialized(){return A("calcite-panel",{class:f.paddingMedium,key:"save-layer-initialized"})}_renderSaveFlowItem(){return"save"!==this._currentFlowItem?null:A("calcite-flow-item",{bind:this,heading:this.messages.saveLayer,headingLevel:this.headingLevel,key:"save-layer-flow-item",selected:"save"===this._currentFlowItem,onCalciteFlowItemBack:this._handleSaveFlowItemBackClick},this._renderSaveContent())}_renderSaveLayerAction(e){if(!this.visibleElements.saveButton)return null;const t=this.viewModel.layer,i=t?.routeInfo,s=t?.portalItem?.itemControl;return A("calcite-action",{bind:this,disabled:!(!!i&&("admin"===s||"update"===s)),icon:"save",key:"save-route",onclick:this._handleSaveLayerClick,...e,text:this.messages.common.save,textEnabled:!0})}_renderSaveLayerAsAction(e){if(!this.visibleElements.saveAsButton)return null;const t=!this.viewModel.layer?.routeInfo;return A("calcite-action",{disabled:t,icon:"save-as",key:"save-as-route",onclick:()=>{this._handleSaveLayerAs()},...e,text:this.messages.common.saveAs,textEnabled:!0})}_renderSaveLayerSettings(){if(null==this.layer||null==this._portalFolders||null==this._portalUserName)return this._renderSaveInitialized();const{stops:e}=this.layer,t=`${e.at(0).name} - ${e.at(-1).name}`,i=[A("calcite-combobox-item",{heading:`${this._portalUserName} (${this.messages.common.home})`,key:f.folderHome,selected:!0,value:f.folderHome}),...this._portalFolders.map(e=>A("calcite-combobox-item",{heading:e.title??"",key:`${f.folder}-${e.id}`,value:e.id}))];return A("calcite-panel",{key:"save-layer-panel"},A("div",{class:f.paddingMedium},A("calcite-label",null,this.messages.layerName,A("calcite-input",{afterCreate:this._handleSaveLayerNameCreate,bind:this,label:this.messages.layerName,value:t})),A("calcite-label",null,this.messages.saveInFolder,A("calcite-combobox",{afterCreate:this._handleSaveLayerFolderCreate,bind:this,clearDisabled:!0,label:this.messages.saveInFolder,overlayPositioning:"fixed",selectionMode:"single-persist"},i))),A("calcite-button",{bind:this,onclick:this._handleSaveLayerButtonClick,slot:"footer-actions",width:"full"},this.messages.common.save),A("calcite-button",{appearance:"outline",bind:this,onclick:this._handleSaveLayerCancelClick,slot:"footer-actions",width:"full"},this.messages.common.cancel))}_renderSaveProcessing(e){return A("calcite-panel",{class:f.marginInlineMedium,key:"save-layer-processing"},A("calcite-loader",{class:f.saveProcessLoader,label:e,text:e}))}_renderSeparator(){return A("div",{class:f.separator})}_renderStop(e){const t=this.acquireSearch(e);null!=e.name&&(t.searchTerm=e.name);const i=this._getEffectiveStops(),s=this._renderLocateStopAction(e),o=i.length>2&&this._renderDeleteStopAction(e);return A("calcite-list-item",{key:e,value:e},s,o,A("div",{class:f.stopItem,slot:"content"},t.render()))}_renderStops(){const e=this._getEffectiveStops();for(const t of this._stopsToSearches.keys())e.includes(t)||this._disposeSearch(t);return A("div",{class:f.stopContainer,key:f.stopContainer},A("calcite-list",{bind:this,class:f.stopList,dragEnabled:!0,label:this.messages.widgetLabel,scale:"s",onCalciteListOrderChange:this._handleStopListReorder},e.toArray().map(e=>this._renderStop(e))),2===e.length&&A("calcite-action",{bind:this,icon:"arrow-up-down",onclick:this._handleReverseStopOrderClick,scale:"s",text:this.messages.reverseStops,title:this.messages.reverseStops}))}_renderTravelMode(e){const{id:t,name:i}=e;return A("calcite-combobox-item",{heading:i,key:t,label:i,selected:this.viewModel.selectedTravelMode?.id===t,value:e})}_renderTravelModes(){return this.viewModel.travelModes.length?A("calcite-label",{key:"travel-modes"},this.messages.mode,A("calcite-combobox",{bind:this,clearDisabled:!0,label:this.messages.mode,overlayPositioning:"fixed",selectionMode:"single-persist",onCalciteComboboxChange:this._handleTravelModeChange},this.viewModel.travelModes.map(e=>this._renderTravelMode(e)))):null}_renderViewItemDetailsAction(e){return this.visibleElements.layerDetails?A("calcite-action",{bind:this,disabled:!this.viewModel.layer?.portalItem,icon:"launch",key:"open-route-details-link",onclick:this._handleItemDetailsClick,...e,text:this.messages.viewLayerDetails,textEnabled:!0}):null}async _solveRoute(){this.viewModel.updateDepartureTime();if(!((this.viewModel.layer?.stops.filter(({geometry:e})=>!!e).length??0)<2))try{await this.viewModel.getDirections()}catch{}}};e([p()],j.prototype,"_printPreviewDialogOpen",void 0),e([p()],j.prototype,"_currentFlowItem",void 0),e([p()],j.prototype,"_saveState",void 0),e([p()],j.prototype,"_searchTool",void 0),e([p()],j.prototype,"apiKey",null),e([p(_)],j.prototype,"defaultUnit",void 0),e([p()],j.prototype,"goToOverride",null),e([p()],j.prototype,"headingLevel",void 0),e([p()],j.prototype,"icon",null),e([p()],j.prototype,"label",null),e([p({readOnly:!0})],j.prototype,"lastRoute",null),e([p()],j.prototype,"layer",null),e([p()],j.prototype,"maxStops",null),e([p(),L("esri/widgets/Directions/t9n/Directions")],j.prototype,"messages",void 0),e([p(),L("esri/core/t9n/Units")],j.prototype,"messagesUnits",void 0),e([p()],j.prototype,"searchProperties",void 0),e([p()],j.prototype,"unit",null),e([p()],j.prototype,"view",null),e([p({type:C})],j.prototype,"viewModel",void 0),e([p({type:D,nonNullable:!0})],j.prototype,"visibleElements",void 0),j=e([m("esri.widgets.Directions")],j);const B=j;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 e from"../../core/Error.js";import{makeHandle as i,abortHandle as o}from"../../core/handleUtils.js";import{isAborted as s}from"../../core/promiseUtils.js";import{watch as r}from"../../core/reactiveUtils.js";import{property as a}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import"../../core/RandomLCG.js";import{subclass as l}from"../../core/accessorSupport/decorators/subclass.js";import{isSubtypeSublayer as n}from"../../layers/support/layerUtils.js";import{createFeatureServices as d}from"../../rest/featureService/utils.js";import c from"../../views/draw/support/HighlightHelper.js";import{temporaryHighlightName as u}from"../../views/support/HighlightDefaults.js";import p from"./AddAssociationWorkflowData.js";import w from"./Workflow.js";import{fetchFullFeatures as h}from"./workflowUtils.js";import
|
|
5
|
+
import{__decorate as t}from"tslib";import e from"../../core/Error.js";import{makeHandle as i,abortHandle as o}from"../../core/handleUtils.js";import{isAborted as s}from"../../core/promiseUtils.js";import{watch as r}from"../../core/reactiveUtils.js";import{property as a}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import"../../core/RandomLCG.js";import{subclass as l}from"../../core/accessorSupport/decorators/subclass.js";import{isSubtypeSublayer as n}from"../../layers/support/layerUtils.js";import{createFeatureServices as d}from"../../rest/featureService/utils.js";import c from"../../views/draw/support/HighlightHelper.js";import{temporaryHighlightName as u}from"../../views/support/HighlightDefaults.js";import p from"./AddAssociationWorkflowData.js";import w from"./Workflow.js";import{fetchFullFeatures as h}from"./workflowUtils.js";import m from"../FeatureForm/UtilityNetworkAssociationAddAssociationViewModel.js";import{getFeatureTitle as y}from"../support/UtilityNetworkAssociations/utils/getFeatureTitle.js";var A;const f={exit:Symbol()};let g=class extends w{static{A=this}constructor(t){super(t),this._utilityNetworkAssociationAddAssociationViewModel=new m,this._highlightHelper=null,this.sourceFeatureItem=null,this.type="add-association"}initialize(){const{data:t}=this,{view:e}=t.viewModel;e&&(this._highlightHelper=new c({view:e,highlightName:u}),this.addHandles(i(()=>this._highlightHelper?.removeAll())));const s=new AbortController;this.addHandles(o(s)),this._updatingHandles.addPromise(this._setup(s))}get editorItem(){return this.data.editorItem}get featureFormViewModel(){return this._featureFormViewModel}get utilityNetworkAssociationAddAssociationViewModel(){return this._utilityNetworkAssociationAddAssociationViewModel}get hasPendingEdits(){return!!this._utilityNetworkAssociationAddAssociationViewModel.selectedFeature}get layer(){return this.data.editorItem.layer}get parent(){return this.data.parent}get reliesOnOwnerAdminPrivileges(){return this.editorItem.capabilities.create.reliesOnOwnerAdminPrivileges}async enter(){this._addHandles()}exit(){this.removeHandles(f.exit)}async start(){return await super.start(),null}async _setup(t){const{data:i}=this,{feature:o}=i;try{const[e]=await h([o],o.sourceLayer,i.viewModel.view.spatialReference,t.signal);if(s(t))return;const r=e.sourceLayer&&"getFeatureTitle"in e.sourceLayer?await e.sourceLayer.getFeatureTitle(e):y(e);if(s(t))return;this.sourceFeatureItem={feature:o,label:r},this._initializeUtilityNetworkAssociationAddAssociationViewModel()}catch(r){await this.cancel({force:!0,error:new e("editor:failed-to-fetch-full-feature","Failed to retrieve all information for this feature. The update cannot proceed.",{detail:{error:r}})})}}_initializeUtilityNetworkAssociationAddAssociationViewModel(){const{viewModel:{view:t},utilityNetwork:e,associationType:i}=this.data,o=this._utilityNetworkAssociationAddAssociationViewModel;o.graphic=this.sourceFeatureItem.feature,o.map=t?.map,o.utilityNetwork=e,o.layer=this.layer,o.associationType=i,o.highlightHelper=this._highlightHelper,e.networkSystemLayers.loadAssociationsTable()}_addHandles(){const t=this._utilityNetworkAssociationAddAssociationViewModel;this.addHandles([r(()=>t.selectedLayer,t=>{t&&this.go("add-association-select-feature")}),r(()=>t.selectedFeature,t=>{t&&this.go("add-association-create-association")})],f.exit)}static async create(t){const e=new A({data:await p.create(t),onCommit:this._onCommitFactory(t.applyEditsFeatureService)});return e._set("steps",this._createWorkflowSteps(e)),e}static _createWorkflowSteps(t){return[{id:"add-association-select-layer",async setUp(){const{utilityNetworkAssociationAddAssociationViewModel:e}=t.data.viewModel;e&&(e.selectedLayer=null,e.selectedFeature=null,e.association=null)},async tearDown(){}},{id:"add-association-select-feature",async setUp(){const{utilityNetworkAssociationAddAssociationViewModel:e}=t.data.viewModel;e&&(e.selectedFeature=null,e.association=null)},async tearDown(){}},{id:"add-association-create-association",async setUp(){},async tearDown(){}}]}static{this._onCommitFactory=t=>async i=>{const{feature:o,utilityNetwork:s,associationInput:r}=i,{utilityNetworkAssociationAddAssociationViewModel:a}=i.viewModel,{association:l}=a;await s.networkSystemLayers.loadAssociationsTable();const c=s?.generateAddAssociations([l]);if(!c)throw new e("editor:failed-to-add-association","Could not create payload needed to add association");const u=o.sourceLayer,p=n(u)&&u.parent?u.parent:u,w=d([p]),h=w.values().next().value?.featureService;if(!h)throw new e("editor:failed-to-delete-association","Could not retrieve feature service needed to delete association");await(h?.load());const m=s?.gdbVersion??void 0;await t(h,[c],{gdbVersion:m}),await r.refresh()}}};t([a()],g.prototype,"_utilityNetworkAssociationAddAssociationViewModel",void 0),t([a()],g.prototype,"_featureFormViewModel",void 0),t([a()],g.prototype,"editorItem",null),t([a()],g.prototype,"featureFormViewModel",null),t([a()],g.prototype,"utilityNetworkAssociationAddAssociationViewModel",null),t([a()],g.prototype,"sourceFeatureItem",void 0),t([a()],g.prototype,"hasPendingEdits",null),t([a()],g.prototype,"layer",null),t([a()],g.prototype,"parent",null),t([a()],g.prototype,"reliesOnOwnerAdminPrivileges",null),g=A=t([l("esri.widgets.Editor.AddAssociationWorkflow")],g);export{g as AddAssociationWorkflow};
|