@arcgis/core 4.34.0-next.57 → 4.34.0-next.58
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/assets/esri/core/workers/RemoteClient.js +1 -1
- package/assets/esri/core/workers/chunks/00ee6f84119bc55a222f.js +1 -0
- package/assets/esri/core/workers/chunks/06b65105b15abf4d0fbf.js +1 -0
- package/assets/esri/core/workers/chunks/{02902303e5585a16ebea.js → 0b53bc76d38e85902748.js} +1 -1
- package/assets/esri/core/workers/chunks/{9b5e04d87116ce2b68b2.js → 0e4976f92b66793137c4.js} +1 -1
- package/assets/esri/core/workers/chunks/{76ff7ccfe583927918f3.js → 0fb2dcbd54175e75d94d.js} +14 -12
- package/assets/esri/core/workers/chunks/14c6461ffd36319e1d74.js +1 -0
- package/assets/esri/core/workers/chunks/1612d1c1d78c122dfef6.js +1 -0
- package/assets/esri/core/workers/chunks/17abab49db1813d3e192.js +1 -0
- package/assets/esri/core/workers/chunks/182383fd00008606bfaa.js +1 -0
- package/assets/esri/core/workers/chunks/18f878ec695617650a96.js +1 -0
- package/assets/esri/core/workers/chunks/{d578c3880eaf2dd62324.js → 19e5e011f929b6b940fe.js} +1 -1
- package/assets/esri/core/workers/chunks/1c61cf137a989bc52bb8.js +1 -0
- package/assets/esri/core/workers/chunks/{dd2b5f115d156b5b212e.js → 22ec2b0a853911692dc8.js} +1 -1
- package/assets/esri/core/workers/chunks/232c76f122b1f519e099.js +1 -0
- package/assets/esri/core/workers/chunks/26975e5b3fb7f2ed45a4.js +1 -0
- package/assets/esri/core/workers/chunks/27334cda1b877abcba1b.js +1 -0
- package/assets/esri/core/workers/chunks/{9fef330b241f958b55df.js → 2cd27b06226e30aec5da.js} +1 -1
- package/assets/esri/core/workers/chunks/327b0da744426ce40e60.js +1 -0
- package/assets/esri/core/workers/chunks/373c9e17e2834dfc1839.js +1 -0
- package/assets/esri/core/workers/chunks/{70cf81ec5a901782d2db.js → 3e7c9a43e52ed6a1b018.js} +1 -1
- package/assets/esri/core/workers/chunks/{8257352421f453a669e9.js → 3f634580055b30dbfc8e.js} +1 -1
- package/assets/esri/core/workers/chunks/{0e8d3d38e9b1f6abf6f2.js → 3fd09a7c05583a57a317.js} +1 -1
- package/assets/esri/core/workers/chunks/{52917b753c5ceab0c1f7.js → 4050ddb580d364d9e205.js} +7 -7
- package/assets/esri/core/workers/chunks/462b30fc40a5f337ba10.js +1 -0
- package/assets/esri/core/workers/chunks/497214e9e82b936fc94e.js +1 -0
- package/assets/esri/core/workers/chunks/4ac127cefa3aa5e93e78.js +1 -0
- package/assets/esri/core/workers/chunks/4b1daffa97fd90a554a0.js +1 -0
- package/assets/esri/core/workers/chunks/4d7fcec769369c576847.js +1 -0
- package/assets/esri/core/workers/chunks/516864fb68025acc7db6.js +1 -0
- package/assets/esri/core/workers/chunks/54b43876ae6fb078eb38.js +1 -0
- package/assets/esri/core/workers/chunks/{9940e59033a8a1eff2a9.js → 55bb794bcdd9cc788322.js} +1 -1
- package/assets/esri/core/workers/chunks/{ef85cd0e82d59db8a26f.js → 5787101b2b814c5d2439.js} +1 -1
- package/assets/esri/core/workers/chunks/5b7e5ec6aea1f7f9b005.js +1 -0
- package/assets/esri/core/workers/chunks/{fe55833c80cf59df9c2b.js → 5cb238318a24b70d5ac3.js} +1 -1
- package/assets/esri/core/workers/chunks/5cfec58c7c31e6d8c6ea.js +1 -0
- package/assets/esri/core/workers/chunks/{88a5e7415f8858c454f7.js → 5de7c2a80bd9c81cefe2.js} +1 -1
- package/assets/esri/core/workers/chunks/5e1afea05b624b315d9f.js +1 -0
- package/assets/esri/core/workers/chunks/5ed7e139c72cd2b3ddba.js +1 -0
- package/assets/esri/core/workers/chunks/6531f33d6710960079e9.js +1 -0
- package/assets/esri/core/workers/chunks/{1cbd59918c60a1a21494.js → 700b5a536f97233bc4af.js} +1 -1
- package/assets/esri/core/workers/chunks/757717416d909059df2f.js +1 -0
- package/assets/esri/core/workers/chunks/7597ef10d1699e7088e5.js +1 -0
- package/assets/esri/core/workers/chunks/781e424a383c71ca904d.js +1 -0
- package/assets/esri/core/workers/chunks/79933271a76a1756584f.js +1 -0
- package/assets/esri/core/workers/chunks/{c2f184e9f579152aa29a.js → 7b17f52019762aa21af8.js} +1 -1
- package/assets/esri/core/workers/chunks/{a249e56a0be8cef33ba8.js → 81eb7785d626aa975033.js} +1 -1
- package/assets/esri/core/workers/chunks/8374d87176486c1fc90e.js +1 -0
- package/assets/esri/core/workers/chunks/{5691d504ffe5592bc40f.js → 897f9775f06ddbf6486f.js} +1 -1
- package/assets/esri/core/workers/chunks/8c0e11f781607239749d.js +1 -0
- package/assets/esri/core/workers/chunks/8c2fcfcfbb6b70f7bada.js +1 -0
- package/assets/esri/core/workers/chunks/90540fdfb0c5f68aa959.js +1 -0
- package/assets/esri/core/workers/chunks/9280edff80fd87860a5e.js +1 -0
- package/assets/esri/core/workers/chunks/944d1608f935516951c4.js +1 -0
- package/assets/esri/core/workers/chunks/94f1005222bff1870ef1.js +1 -0
- package/assets/esri/core/workers/chunks/{aab349d4624b78ef429f.js → 96102a9296afd1bfe1a9.js} +1 -1
- package/assets/esri/core/workers/chunks/{4d2473e680324dc17cfa.js → 997a2a1a51039ce7e4e3.js} +1 -1
- package/assets/esri/core/workers/chunks/{4e2b125e6e3945985a54.js → 9f93513037a6e87433c4.js} +1 -1
- package/assets/esri/core/workers/chunks/a16b471c3706ee37f9b6.js +1 -0
- package/assets/esri/core/workers/chunks/a2150baf0661e2f28011.js +1 -0
- package/assets/esri/core/workers/chunks/a244afea77127e54dd3a.js +1 -0
- package/assets/esri/core/workers/chunks/{ab3c018c406dcd81ef9e.js → a2f4b6d8da93f106852c.js} +1 -1
- package/assets/esri/core/workers/chunks/a532614aa65fb52dee7b.js +1 -0
- package/assets/esri/core/workers/chunks/{3b51b61a7b8a1ef87c9b.js → a700f57af6856cb5313c.js} +1 -1
- package/assets/esri/core/workers/chunks/{a7530dcb08b43e37bbb2.js → ae1cb4c65d72217ae4d4.js} +1 -1
- package/assets/esri/core/workers/chunks/af5ae7c36e1178077cbc.js +1 -0
- package/assets/esri/core/workers/chunks/{7f80bbbd0897082c1af3.js → b29144ee58b43f769d9a.js} +1 -1
- package/assets/esri/core/workers/chunks/b30de4936caa654d7817.js +1 -0
- package/assets/esri/core/workers/chunks/b6c6f82df3b60c2f831f.js +1 -0
- package/assets/esri/core/workers/chunks/{fae6030a81cb91a91b69.js → bafd9b0f6e817252cb31.js} +1 -1
- package/assets/esri/core/workers/chunks/{c80c032c5b7a11db177a.js → bb2ab663e3e5597f2104.js} +1 -1
- package/assets/esri/core/workers/chunks/bf6b76027c60b4ffa507.js +1 -0
- package/assets/esri/core/workers/chunks/c34a164a8ece4cb33e81.js +1 -0
- package/assets/esri/core/workers/chunks/c4ff5c78fc8668af9c05.js +1 -0
- package/assets/esri/core/workers/chunks/c696615cae5daefa2d98.js +1 -0
- package/assets/esri/core/workers/chunks/{07d5e0633cc2f765037f.js → c71dac67f95d694bf67e.js} +1 -1
- package/assets/esri/core/workers/chunks/{e982cf44906eb26164f2.js → c75b0243e5bb84738419.js} +1 -1
- package/assets/esri/core/workers/chunks/{80a69897fa3ce1eaa6e7.js → d707538b150d79050336.js} +1 -1
- package/assets/esri/core/workers/chunks/d83bdc13c3cad3eee7be.js +1 -0
- package/assets/esri/core/workers/chunks/{a96ac5c68d84122e7751.js → db7678104b18534482e3.js} +1 -1
- package/assets/esri/core/workers/chunks/dbcef57073075e9cfdfe.js +1 -0
- package/assets/esri/core/workers/chunks/e36d538915261ee0373f.js +1 -0
- package/assets/esri/core/workers/chunks/e97250ae8da4bd0d6bc9.js +1 -0
- package/assets/esri/core/workers/chunks/ed8863c3d334f438b625.js +1 -0
- package/assets/esri/core/workers/chunks/f636ca5c811c3a2a962f.js +1 -0
- package/assets/esri/core/workers/chunks/{a3ee76b7e46d3fba7cf7.js → f6d91256c4e5f8a0d5c0.js} +1 -1
- package/assets/esri/core/workers/chunks/f718f630a8b81496c646.js +1 -0
- package/assets/esri/core/workers/chunks/{cac060a187f3a27a19ba.js → fa0f94318173db2034de.js} +1 -1
- package/assets/esri/core/workers/chunks/{cf699b9bb530b87be14c.js → ff14b632f147cb68ed59.js} +1 -1
- package/assets/esri/core/workers/chunks/{b6a201e86f9caef45ff0.js → ff2614d96ca5228e9685.js} +1 -1
- package/assets/esri/themes/base/widgets/_Editor.scss +5 -3
- package/assets/esri/themes/base/widgets/_SelectionToolbar.scss +6 -0
- package/assets/esri/themes/dark/main.css +1 -1
- package/assets/esri/themes/light/main.css +1 -1
- package/assets/esri/themes/light/view.css +1 -1
- package/assets/esri/widgets/support/SelectionToolbar/t9n/SelectionToolbar.json +1 -1
- package/assets/esri/widgets/support/SelectionToolbar/t9n/SelectionToolbar_en.json +1 -1
- package/chunks/ColorMaterial.glsl.js +1 -1
- package/chunks/ComponentShader.glsl.js +2 -2
- package/chunks/CutFillDepth.glsl.js +15 -0
- package/chunks/CutFillReduction.glsl.js +12 -0
- package/chunks/CutFillTargetDepth.glsl.js +6 -0
- package/chunks/DefaultMaterial.glsl.js +1 -1
- package/chunks/HUDMaterial.glsl.js +4 -4
- package/chunks/ImageMaterial.glsl.js +2 -2
- package/chunks/NativeLine.glsl.js +1 -1
- package/chunks/Path.glsl.js +6 -6
- package/chunks/Pattern.glsl.js +1 -1
- package/chunks/RealisticTree.glsl.js +1 -1
- package/chunks/RibbonLine.glsl.js +2 -2
- package/chunks/ShadedColorMaterial.glsl.js +1 -1
- package/chunks/SimpleAtmosphere.glsl.js +1 -1
- package/chunks/Terrain.glsl.js +4 -4
- package/chunks/WaterSurface.glsl.js +3 -3
- package/chunks/offsetOperator.js +1 -1
- package/config.js +1 -1
- package/core/Clonable.js +1 -1
- package/effects/FocusArea.js +1 -1
- package/geometry/operators/offsetOperator.js +1 -1
- package/interfaces.d.ts +2 -2
- package/kernel.js +1 -1
- package/layers/IntegratedMesh3DTilesLayer.js +1 -1
- package/layers/IntegratedMeshLayer.js +1 -1
- package/layers/PointCloudLayer.js +1 -1
- package/layers/SceneLayer.js +1 -1
- package/layers/buildingSublayers/BuildingComponentSublayer.js +1 -1
- package/layers/graphics/hydratedFeatures.js +1 -1
- package/layers/support/SceneFilter.js +1 -1
- package/package.json +2 -2
- package/support/revision.js +1 -1
- package/views/2d/engine/Stage.js +1 -1
- package/views/2d/engine/webgl/Profiler.js +1 -1
- package/views/3d/layers/BuildingComponentSublayerView3D.js +1 -1
- package/views/3d/layers/CSVLayerView3D.js +1 -1
- package/views/3d/layers/FeatureLayerView3D.js +1 -1
- package/views/3d/layers/FeatureLikeLayerView3D.js +1 -1
- package/views/3d/layers/GeoJSONLayerView3D.js +1 -1
- package/views/3d/layers/GraphicsLayerView3D.js +1 -1
- package/views/3d/layers/GraphicsView3D.js +1 -1
- package/views/3d/layers/IntegratedMeshLayerView3D.js +1 -1
- package/views/3d/layers/OGCFeatureLayerView3D.js +1 -1
- package/views/3d/layers/PointCloudLayerView3D.js +1 -1
- package/views/3d/layers/RouteLayerView3D.js +1 -1
- package/views/3d/layers/SceneLayerGraphicsView3D.js +1 -1
- package/views/3d/layers/SceneLayerView3D.js +1 -1
- package/views/3d/layers/StreamLayerView3D.js +1 -1
- package/views/3d/layers/WFSLayerView3D.js +1 -1
- package/views/3d/layers/graphics/Graphics3DCore.js +1 -1
- package/views/3d/layers/graphics/GraphicsProcessor.js +1 -1
- package/views/3d/layers/graphics/Labeler.js +1 -1
- package/views/3d/layers/graphics/QueryEngine.js +1 -1
- package/views/3d/layers/graphics/StreamController.js +1 -1
- package/views/3d/layers/graphics/pipeline/Feature3DPipelineWorkerHandle.js +1 -1
- package/views/3d/layers/graphics/pipeline/rendering/DirectRenderer.js +1 -1
- package/views/3d/layers/i3s/PointCloudRenderer.js +1 -1
- package/views/3d/layers/support/Tiles3DIntersectionHandler.js +1 -1
- package/views/3d/terrain/OverlayRenderTargets.js +1 -1
- package/views/3d/terrain/OverlayRenderer.js +1 -1
- package/views/3d/terrain/TerrainRenderer.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/ComponentData.glsl.js +2 -2
- package/views/3d/webgl-engine/core/FBOCache.js +1 -1
- package/views/3d/webgl-engine/core/FBOCacheFormats.js +1 -1
- package/views/3d/webgl-engine/core/renderPasses/RenderPassManager.js +1 -1
- package/views/3d/webgl-engine/core/shaderLibrary/ShaderOutput.js +1 -1
- package/views/3d/webgl-engine/core/shaderLibrary/ShaderOutputConfiguration.js +1 -1
- package/views/3d/webgl-engine/core/shaderLibrary/attributes/ObjectAndLayerIdColor.glsl.js +1 -1
- package/views/3d/webgl-engine/core/shaderLibrary/default/DefaultMaterialAuxiliaryPasses.glsl.js +4 -4
- package/views/3d/webgl-engine/core/shaderLibrary/output/OutputDepth.glsl.js +2 -0
- package/views/3d/webgl-engine/core/shaderLibrary/output/OutputHighlight.glsl.js +1 -1
- package/views/3d/webgl-engine/core/shaderLibrary/output/OutputHighlightOverlay.js +1 -1
- package/views/3d/webgl-engine/core/shaderLibrary/terrain/Overlay.glsl.js +1 -1
- package/views/3d/webgl-engine/effects/focusArea/FocusAreaMaskNode.js +1 -1
- package/views/3d/webgl-engine/effects/geometry/ObjectAndLayerIDRenderNode.js +1 -1
- package/views/3d/webgl-engine/effects/geometry/RenderOccludedRenderNode.js +1 -1
- package/views/3d/webgl-engine/lib/BindParameters.js +1 -1
- package/views/3d/webgl-engine/lib/CutFillDepth.js +5 -0
- package/views/3d/webgl-engine/lib/DefaultVertexBufferLayouts.js +1 -1
- package/views/3d/webgl-engine/lib/MainFramebuffer.js +1 -1
- package/views/3d/webgl-engine/lib/Material.js +1 -1
- package/views/3d/webgl-engine/lib/Renderer.js +1 -1
- package/views/3d/webgl-engine/lib/ShadowMap.js +1 -1
- package/views/3d/webgl-engine/lib/SortedRenderGeometryRenderer.js +1 -1
- package/views/3d/webgl-engine/lib/ViewshedShadowMap.js +1 -1
- package/views/3d/webgl-engine/lib/lodRendering/LodRenderer.js +1 -1
- package/views/3d/webgl-engine/materials/ColorMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/DefaultTechniqueConfiguration.js +1 -1
- package/views/3d/webgl-engine/materials/LineMarkerMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/RibbonLineMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/ShadedColorMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/WaterTechnique.js +1 -1
- package/views/3d/webgl-engine/materials/renderers/VaoRenderer.js +1 -1
- package/views/3d/webgl-engine/shaders/CutFillDepth.glsl.js +5 -0
- package/views/3d/webgl-engine/shaders/CutFillDepthTechnique.js +5 -0
- package/views/3d/webgl-engine/shaders/CutFillReduction.glsl.js +5 -0
- package/views/3d/webgl-engine/shaders/CutFillReductionTechnique.js +5 -0
- package/views/3d/webgl-engine/shaders/CutFillTargetDepth.glsl.js +5 -0
- package/views/3d/webgl-engine/shaders/CutFillTargetDepthTechnique.js +5 -0
- package/views/3d/webgl-engine/shaders/HUDMaterialTechnique.js +1 -1
- package/views/3d/webgl-engine/shaders/OutputColorHighlightOID.glsl.js +1 -1
- package/views/3d/webgl.js +1 -1
- package/views/draw/support/Reshape.js +1 -1
- package/widgets/Editor/EditorViewModel.js +1 -1
- package/widgets/FeatureForm/FeatureFormUtilityNetworkAssociations/UtilityNetworkAssociationItemList.js +1 -1
- package/widgets/Sketch.js +1 -1
- package/widgets/support/SelectionToolbar/SelectionToolbarViewModel.js +1 -1
- package/widgets/support/SelectionToolbar/VisibleElements.js +1 -1
- package/widgets/support/SelectionToolbar.js +1 -1
- package/widgets/support/Selector2D/SelectionOperation.js +1 -1
- package/assets/esri/core/workers/chunks/0390f3aa624e3f380ce2.js +0 -1
- package/assets/esri/core/workers/chunks/06d2251d6f6b3e44800a.js +0 -1
- package/assets/esri/core/workers/chunks/07eea90733834313e9fa.js +0 -1
- package/assets/esri/core/workers/chunks/08393d9cc2ed846dd5b4.js +0 -1
- package/assets/esri/core/workers/chunks/094c741fa8139c3f40cf.js +0 -1
- package/assets/esri/core/workers/chunks/0f51e51db83f303ce5a6.js +0 -1
- package/assets/esri/core/workers/chunks/184d3c88ac2fc1d7e2c3.js +0 -1
- package/assets/esri/core/workers/chunks/1eee7cf11df01a52c1bf.js +0 -1
- package/assets/esri/core/workers/chunks/27197b0a2ffb2b6104ea.js +0 -1
- package/assets/esri/core/workers/chunks/2c0241a5958aef9cda61.js +0 -1
- package/assets/esri/core/workers/chunks/2ded2446700f89155ccd.js +0 -1
- package/assets/esri/core/workers/chunks/3264d58aeef8cf074b86.js +0 -1
- package/assets/esri/core/workers/chunks/3445ffd752262673fb13.js +0 -1
- package/assets/esri/core/workers/chunks/38f09e36e174792646bd.js +0 -1
- package/assets/esri/core/workers/chunks/3c57b2e13628b5c1f6de.js +0 -1
- package/assets/esri/core/workers/chunks/4162c633efefc63c5506.js +0 -1
- package/assets/esri/core/workers/chunks/435169b455fd2846799b.js +0 -1
- package/assets/esri/core/workers/chunks/44dc7ec52c4abb700783.js +0 -1
- package/assets/esri/core/workers/chunks/4558f2e3e77831758fdc.js +0 -1
- package/assets/esri/core/workers/chunks/4fc267552939583a81a0.js +0 -1
- package/assets/esri/core/workers/chunks/527557b603400189d49a.js +0 -1
- package/assets/esri/core/workers/chunks/53873f26a2c24cd75e4a.js +0 -1
- package/assets/esri/core/workers/chunks/554c789f4e875d7e6fd5.js +0 -1
- package/assets/esri/core/workers/chunks/561a2078458bc0339f83.js +0 -1
- package/assets/esri/core/workers/chunks/5f28470304b57e24d94c.js +0 -1
- package/assets/esri/core/workers/chunks/61a294f9411bf884f2ab.js +0 -1
- package/assets/esri/core/workers/chunks/719450ccd455f503d81a.js +0 -1
- package/assets/esri/core/workers/chunks/71cac356874b36f9a383.js +0 -1
- package/assets/esri/core/workers/chunks/7388e8c905d93dea1c05.js +0 -1
- package/assets/esri/core/workers/chunks/749c7159e0902388e828.js +0 -1
- package/assets/esri/core/workers/chunks/7714228825fb44d506df.js +0 -1
- package/assets/esri/core/workers/chunks/77ee4afaa4a1c7047940.js +0 -1
- package/assets/esri/core/workers/chunks/790e97ddbe318bc75415.js +0 -1
- package/assets/esri/core/workers/chunks/8762928d10c3821738ad.js +0 -1
- package/assets/esri/core/workers/chunks/8ead467a5af0d9bba804.js +0 -1
- package/assets/esri/core/workers/chunks/91e04d03b0013bcaad82.js +0 -1
- package/assets/esri/core/workers/chunks/92b60d4fb09711919601.js +0 -1
- package/assets/esri/core/workers/chunks/998c38974372720b1c52.js +0 -1
- package/assets/esri/core/workers/chunks/9b10e70f28873cff44f5.js +0 -1
- package/assets/esri/core/workers/chunks/9d920f3488d59e7f276c.js +0 -1
- package/assets/esri/core/workers/chunks/a999f804fc2f00b2e7ae.js +0 -1
- package/assets/esri/core/workers/chunks/acf13a64df2991a4cb6b.js +0 -1
- package/assets/esri/core/workers/chunks/b5640f9623a9c9ded92a.js +0 -1
- package/assets/esri/core/workers/chunks/b8158c681456d4cf2395.js +0 -1
- package/assets/esri/core/workers/chunks/bbdbb618a18542f7a4a2.js +0 -1
- package/assets/esri/core/workers/chunks/bead38898c3f4d4d3569.js +0 -1
- package/assets/esri/core/workers/chunks/c51e2a048df152abd901.js +0 -1
- package/assets/esri/core/workers/chunks/c86e339e45900c54c9f5.js +0 -1
- package/assets/esri/core/workers/chunks/ca7c9756802214e41c56.js +0 -1
- package/assets/esri/core/workers/chunks/cb8f2ce22274990b359c.js +0 -1
- package/assets/esri/core/workers/chunks/d6ab4d55f1023ee6ec6a.js +0 -1
- package/assets/esri/core/workers/chunks/db2b8d8cf7131554cf7e.js +0 -1
- package/assets/esri/core/workers/chunks/f1c50f37a81c672263a1.js +0 -1
- package/assets/esri/core/workers/chunks/ff323db554c9e09749e8.js +0 -1
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import t from"../../../../core/Logger.js";import{clamp as e}from"../../../../core/mathUtils.js";import{createRenderScreenPointArray3 as i}from"../../../../core/screenUtils.js";import{secondsFromMilliseconds as r}from"../../../../core/time.js";import{copy as s}from"../../../../core/libs/gl-matrix-2/math/vec2.js";import{i as a,d as o,e as n,g as l,f as h,c as p,l as m,j as c,t as u}from"../../../../chunks/vec32.js";import{create as f}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{ONES as d}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{makeFloat16Array as g}from"../../../../geometry/support/float16.js";import{distance2 as b,fromPoints as _,create as S,closestLineSegmentPoint as v}from"../../../../geometry/support/lineSegment.js";import{fromPoints as P,create as y,signedDistance as j,getNormal as E}from"../../../../geometry/support/plane.js";import{isHighlightOrOID as w,isColorOrColorEmission as A,isDepth as T,isColorEmissionHighlightOIDOrDepth as z,is2DGeometryOutput as C}from"../core/shaderLibrary/ShaderOutput.js";import{olidEnabled as L}from"../effects/geometry/olidUtils.js";import M from"../lib/GLMaterial.js";import{Material as O}from"../lib/Material.js";import{isTranslationMatrix as V}from"../lib/Util.js";import{VisualVariablePassParameters as R}from"./VisualVariablePassParameters.js";import{writeDeltaF16Vector as x}from"./internal/bufferWriterUtils.js";import{r as F}from"../../../../chunks/RibbonLine.glsl.js";import{getLayout as N,RibbonLineTechnique as k}from"../shaders/RibbonLineTechnique.js";import{RibbonLineTechniqueConfiguration as U}from"../shaders/RibbonLineTechniqueConfiguration.js";import{alphaCutoff as D}from"../../../../webscene/support/AlphaCutoff.js";class B extends O{constructor(t){super(t,J),this._configuration=new U,this.produces=new Map([[2,t=>w(t)||A(t)&&8===this.parameters.renderOccluded],[3,t=>T(t)],[10,t=>z(t)&&8===this.parameters.renderOccluded],[11,t=>z(t)&&8===this.parameters.renderOccluded],[4,t=>A(t)&&this.parameters.writeDepth&&8!==this.parameters.renderOccluded],[8,t=>A(t)&&!this.parameters.writeDepth&&8!==this.parameters.renderOccluded],[18,t=>C(t)]])}getConfiguration(t,e){super.getConfiguration(t,e,this._configuration),this._configuration.oitPass=e.oitPass,this._configuration.draped=18===e.slot;const i=null!=this.parameters.stipplePattern&&8!==t;return this._configuration.stippleEnabled=i,this._configuration.stippleOffColorEnabled=i&&null!=this.parameters.stippleOffColor,this._configuration.stipplePreferContinuous=i&&this.parameters.stipplePreferContinuous,this._configuration.hasSlicePlane=this.parameters.hasSlicePlane,this._configuration.roundJoins="round"===this.parameters.join,this._configuration.capType=this.parameters.cap,this._configuration.applyMarkerOffset=null!=this.parameters.markerParameters&&G(this.parameters.markerParameters),this._configuration.hasPolygonOffset=this.parameters.hasPolygonOffset,this._configuration.writeDepth=this.parameters.writeDepth,this._configuration.hasVVSize=this.parameters.hasVVSize,this._configuration.hasVVColor=this.parameters.hasVVColor,this._configuration.hasVVOpacity=this.parameters.hasVVOpacity,this._configuration.innerColorEnabled=this.parameters.innerWidth>0&&null!=this.parameters.innerColor,this._configuration.falloffEnabled=this.parameters.falloff>0,this._configuration.hasOccludees=e.hasOccludees,this._configuration.occluder=8===this.parameters.renderOccluded,this._configuration.terrainDepthTest=e.terrainDepthTest&&A(t),this._configuration.cullAboveTerrain=e.cullAboveTerrain,this._configuration.wireframe=this.parameters.wireframe,this._configuration.animation=this.parameters.animation,this._configuration.emissionSource=this.hasEmissions?1:0,this._configuration}get visible(){return this.parameters.color[3]>=D||null!=this.parameters.stipplePattern&&(this.parameters.stippleOffColor?.[3]??0)>D}setParameters(t,e){t.animation=this.parameters.animation,super.setParameters(t,e)}intersectDraped({attributes:t,screenToWorldRatio:i},r,s,a,o){if(!r.options.selectionMode)return;const n=t.get("size");let l=this.parameters.width;if(this.parameters.vvSize){const i=t.get("sizeFeatureAttribute").data[0];Number.isNaN(i)?l*=this.parameters.vvSize.fallback[0]:l*=e(this.parameters.vvSize.offset[0]+i*this.parameters.vvSize.factor[0],this.parameters.vvSize.minSize[0],this.parameters.vvSize.maxSize[0])}else n&&(l*=n.data[0]);const h=s[0],p=s[1],m=(l/2+4)*i;let c=Number.MAX_VALUE,u=0;const f=t.get("position").data,d=X(this.parameters,t)?f.length-2:f.length-5;for(let g=0;g<d;g+=3){const t=f[g],i=f[g+1],r=(g+3)%f.length,s=h-t,a=p-i,o=f[r]-t,n=f[r+1]-i,l=e((o*s+n*a)/(o*o+n*n),0,1),m=o*l-s,d=n*l-a,b=m*m+d*d;b<c&&(c=b,u=g/3)}c<m*m&&a(o.distance,o.normal,u)}intersect(i,r,u,f,d,g){const{options:S,camera:y,rayBegin:w,rayEnd:A}=u;if(!S.selectionMode||!i.visible||!y)return;if(!V(r))return void t.getLogger("esri.views.3d.webgl-engine.materials.RibbonLineMaterial").error("intersection assumes a translation-only matrix");const T=i.attributes,z=T.get("position").data;let C=this.parameters.width;if(this.parameters.vvSize){const t=T.get("sizeFeatureAttribute").data[0];Number.isNaN(t)||(C*=e(this.parameters.vvSize.offset[0]+t*this.parameters.vvSize.factor[0],this.parameters.vvSize.minSize[0],this.parameters.vvSize.maxSize[0]))}else T.has("size")&&(C*=T.get("size").data[0]);const L=Z;s(L,u.point);const M=C*y.pixelRatio/2+4*y.pixelRatio;a(ht[0],L[0]-M,L[1]+M,0),a(ht[1],L[0]+M,L[1]+M,0),a(ht[2],L[0]+M,L[1]-M,0),a(ht[3],L[0]-M,L[1]-M,0);for(let t=0;t<4;t++)if(!y.unprojectFromRenderScreen(ht[t],pt[t]))return;P(y.eye,pt[0],pt[1],mt),P(y.eye,pt[1],pt[2],ct),P(y.eye,pt[2],pt[3],ut),P(y.eye,pt[3],pt[0],ft);let O=Number.MAX_VALUE,R=0;const x=X(this.parameters,T)?z.length-2:z.length-5;for(let t=0;t<x;t+=3){H[0]=z[t]+r[12],H[1]=z[t+1]+r[13],H[2]=z[t+2]+r[14];const e=(t+3)%z.length;if(I[0]=z[e]+r[12],I[1]=z[e+1]+r[13],I[2]=z[e+2]+r[14],j(mt,H)<0&&j(mt,I)<0||j(ct,H)<0&&j(ct,I)<0||j(ut,H)<0&&j(ut,I)<0||j(ft,H)<0&&j(ft,I)<0)continue;if(y.projectToRenderScreen(H,$),y.projectToRenderScreen(I,tt),$[2]<0&&tt[2]>0){o(K,H,I);const t=y.frustum,e=-j(t[4],H)/n(K,E(t[4]));l(K,K,e),h(H,H,K),y.projectToRenderScreen(H,$)}else if($[2]>0&&tt[2]<0){o(K,I,H);const t=y.frustum,e=-j(t[4],I)/n(K,E(t[4]));l(K,K,e),h(I,I,K),y.projectToRenderScreen(I,tt)}else if($[2]<0&&tt[2]<0)continue;$[2]=0,tt[2]=0;const i=b(_($,tt,rt),L);i<O&&(O=i,p(et,H),p(it,I),R=t/3)}if(O<M*M){let t=Number.MAX_VALUE;if(v(_(et,it,rt),_(w,A,st),Q)){o(Q,Q,w);const e=m(Q);l(Q,Q,1/e),t=e/c(w,A)}g(t,Q,R)}}get hasEmissions(){return this.parameters.emissiveStrength>0}createBufferWriter(){return new Y(N(this.parameters),this.parameters)}createGLMaterial(t){return new W(t)}validateParameters(t){"miter"!==t.join&&(t.miterLimit=0),null!=t.markerParameters&&(t.markerScale=t.markerParameters.width/t.width)}update(t){const{hasAnimation:e,animationSpeed:i}=this.parameters;return!!e&&(this.setParameters({timeElapsed:r(t.time)*i},!1),0!==t.dt)}}class W extends M{constructor(){super(...arguments),this._stipplePattern=null}dispose(){super.dispose(),this._stippleTextures?.release(this._stipplePattern),this._stipplePattern=null}beginSlot(t){const e=this._material.parameters.stipplePattern;return this._stipplePattern!==e&&(this._material.setParameters({stippleTexture:this._stippleTextures.swap(e,this._stipplePattern)}),this._stipplePattern=e),this.getTechnique(k,t)}}class J extends R{constructor(){super(...arguments),this.width=0,this.color=d,this.join="miter",this.cap=0,this.miterLimit=5,this.writeDepth=!0,this.hasPolygonOffset=!1,this.stippleTexture=null,this.stipplePreferContinuous=!0,this.markerParameters=null,this.markerScale=1,this.hasSlicePlane=!1,this.vvFastUpdate=!1,this.isClosed=!1,this.falloff=0,this.innerWidth=0,this.wireframe=!1,this.timeElapsed=0,this.animation=0,this.animationSpeed=1,this.trailLength=1,this.emissiveStrength=0}get transparent(){return this.color[3]<1||this.hasAnimation||null!=this.stipplePattern&&(this.stippleOffColor?.[3]??0)<1}get hasAnimation(){return 0!==this.animation}}class Y{constructor(t,e){this.layout=t,this._parameters=e;const i=e.stipplePattern?1:0;switch(this._parameters.join){case"miter":case"bevel":this.numJoinSubdivisions=i;break;case"round":this.numJoinSubdivisions=F+i}}_isClosed(t){return X(this._parameters,t)}allocate(t){return this.layout.createBuffer(t)}elementCount(t){const e=2,i=t.get("position").indices.length/2+1,r=this._isClosed(t);let s=r?2:2*e;return s+=((r?i:i-1)-(r?0:1))*(2*this.numJoinSubdivisions+4),s+=2,this._parameters.wireframe&&(s=2+4*(s-2)),s}write(t,e,i,r,s,o){const n=i.get("position"),l=n.indices,h=n.data.length/3,m=i.get("distanceToStart")?.data;l&&l.length!==2*(h-1)&&console.warn("RibbonLineMaterial does not support indices");const f=(this.layout.fields.has("sizeFeatureAttribute")?i.get("sizeFeatureAttribute")?.data[0]:i.get("size")?.data[0])??1;let d=[1,1,1,1],b=0;const _=this.layout.fields.has("colorFeatureAttribute");_?b=i.get("colorFeatureAttribute").data[0]:i.has("color")&&(d=i.get("color").data);const S=i.get("timeStamps")?.data,v=S&&this.layout.fields.has("timeStamps"),P=this.layout.fields.has("opacityFeatureAttribute"),y=P?i.get("opacityFeatureAttribute").data[0]:0,j=new Float32Array(s.buffer),E=g(s.buffer),w=new Uint8Array(s.buffer),A=this.layout.stride/4;let T=o*A;const z=T;let C=0;const M=m?(t,e,i)=>C=m[i]:(t,e,i)=>C+=c(t,e),O=j.BYTES_PER_ELEMENT/E.BYTES_PER_ELEMENT,V=4/O,R=(t,e,i,s,a,o,n,l)=>{j[T++]=e[0],j[T++]=e[1],j[T++]=e[2],x(t,e,E,T*O),T+=V,x(i,e,E,T*O),T+=V,j[T++]=l;let h=T*O;if(E[h++]=a,E[h++]=o,T=Math.ceil(h/O),_)j[T]=b;else{const t=Math.min(4*n,d.length-4),e=4*T;w[e]=255*d[t],w[e+1]=255*d[t+1],w[e+2]=255*d[t+2],w[e+3]=255*d[t+3]}if(T++,j[T++]=f,P&&(j[T++]=y),L()){let t=4*T;r?(w[t++]=r[0],w[t++]=r[1],w[t++]=r[2],w[t++]=r[3]):(w[t++]=0,w[t++]=0,w[t++]=0,w[t++]=0),T=Math.ceil(.25*t)}v&&(h=T*O,E[h++]=s[0],E[h++]=s[1],E[h++]=s[2],T=Math.ceil(h/O))};T+=A,a(ot,n.data[0],n.data[1],n.data[2]),v&&a(lt,S[0],S[1],S[2]),t&&u(ot,ot,t);const F=this._isClosed(i);if(F){const e=n.data.length-3;a(at,n.data[e],n.data[e+1],n.data[e+2]),t&&u(at,at,t)}else a(nt,n.data[3],n.data[4],n.data[5]),t&&u(nt,nt,t),R(ot,ot,nt,lt,1,-4,0,0),R(ot,ot,nt,lt,1,4,0,0),p(at,ot),p(ot,nt),v&&a(lt,S[3],S[4],S[5]);const N=F?0:1,k=F?h:h-1;for(let c=N;c<k;c++){const e=(c+1)%h*3;a(nt,n.data[e],n.data[e+1],n.data[e+2]),t&&u(nt,nt,t),M(at,ot,c),R(at,ot,nt,lt,0,-1,c,C),R(at,ot,nt,lt,0,1,c,C);const i=this.numJoinSubdivisions;for(let t=0;t<i;++t){const e=(t+1)/(i+1);R(at,ot,nt,lt,e,-1,c,C),R(at,ot,nt,lt,e,1,c,C)}R(at,ot,nt,lt,1,-2,c,C),R(at,ot,nt,lt,1,2,c,C),p(at,ot),p(ot,nt),v&&a(lt,S[e],S[e+1],S[e+2])}F?(a(nt,n.data[3],n.data[4],n.data[5]),t&&u(nt,nt,t),C=M(at,ot,k),R(at,ot,nt,lt,0,-1,N,C),R(at,ot,nt,lt,0,1,N,C)):(C=M(at,ot,k),R(at,ot,ot,lt,0,-5,k,C),R(at,ot,ot,lt,0,5,k,C)),q(j,z+A,j,z,A);return T=q(j,T-A,j,T,A),this._parameters.wireframe&&this._addWireframeVertices(s,z,T,A),null}_addWireframeVertices(t,e,i,r){const s=new Float32Array(t.buffer,i*Float32Array.BYTES_PER_ELEMENT),a=new Float32Array(t.buffer,e*Float32Array.BYTES_PER_ELEMENT,i-e);let o=0;const n=t=>o=q(a,t,s,o,r);for(let l=0;l<a.length-1;l+=2*r)n(l),n(l+2*r),n(l+1*r),n(l+2*r),n(l+1*r),n(l+3*r)}}function q(t,e,i,r,s){for(let a=0;a<s;a++)i[r++]=t[e++];return r}function X(t,e){if(!t.isClosed)return!1;return e.get("position").indices.length>2}function G(t){return 1===t.anchor&&t.hideOnShortSegments&&"begin-end"===t.placement&&t.worldSpace}const H=f(),I=f(),K=f(),Q=f(),Z=f(),$=i(),tt=i(),et=f(),it=f(),rt=S(),st=S(),at=f(),ot=f(),nt=f(),lt=f(),ht=[i(),i(),i(),i()],pt=[f(),f(),f(),f()],mt=y(),ct=y(),ut=y(),ft=y();export{J as Parameters,B as RibbonLineMaterial};
|
|
5
|
+
import t from"../../../../core/Logger.js";import{clamp as e}from"../../../../core/mathUtils.js";import{createRenderScreenPointArray3 as i}from"../../../../core/screenUtils.js";import{secondsFromMilliseconds as r}from"../../../../core/time.js";import{copy as s}from"../../../../core/libs/gl-matrix-2/math/vec2.js";import{i as a,d as o,e as n,g as l,f as h,c as p,l as m,j as c,t as u}from"../../../../chunks/vec32.js";import{create as f}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{ONES as d}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{makeFloat16Array as g}from"../../../../geometry/support/float16.js";import{distance2 as b,fromPoints as _,create as S,closestLineSegmentPoint as v}from"../../../../geometry/support/lineSegment.js";import{fromPoints as P,create as y,signedDistance as j,getNormal as E}from"../../../../geometry/support/plane.js";import{isHighlightOrOID as w,isColorOrColorEmission as A,isDepth as T,isColorEmissionHighlightOIDOrDepth as z,is2DGeometryOutput as C}from"../core/shaderLibrary/ShaderOutput.js";import{olidEnabled as L}from"../effects/geometry/olidUtils.js";import M from"../lib/GLMaterial.js";import{Material as O}from"../lib/Material.js";import{isTranslationMatrix as V}from"../lib/Util.js";import{VisualVariablePassParameters as R}from"./VisualVariablePassParameters.js";import{writeDeltaF16Vector as x}from"./internal/bufferWriterUtils.js";import{r as F}from"../../../../chunks/RibbonLine.glsl.js";import{getLayout as N,RibbonLineTechnique as k}from"../shaders/RibbonLineTechnique.js";import{RibbonLineTechniqueConfiguration as U}from"../shaders/RibbonLineTechniqueConfiguration.js";import{alphaCutoff as D}from"../../../../webscene/support/AlphaCutoff.js";class B extends O{constructor(t){super(t,J),this._configuration=new U,this.produces=new Map([[2,t=>w(t)||A(t)&&8===this.parameters.renderOccluded],[3,t=>T(t)],[10,t=>z(t)&&8===this.parameters.renderOccluded],[11,t=>z(t)&&8===this.parameters.renderOccluded],[4,t=>A(t)&&this.parameters.writeDepth&&8!==this.parameters.renderOccluded],[8,t=>A(t)&&!this.parameters.writeDepth&&8!==this.parameters.renderOccluded],[18,t=>C(t)]])}getConfiguration(t,e){super.getConfiguration(t,e,this._configuration),this._configuration.oitPass=e.oitPass,this._configuration.draped=18===e.slot;const i=null!=this.parameters.stipplePattern&&9!==t;return this._configuration.stippleEnabled=i,this._configuration.stippleOffColorEnabled=i&&null!=this.parameters.stippleOffColor,this._configuration.stipplePreferContinuous=i&&this.parameters.stipplePreferContinuous,this._configuration.hasSlicePlane=this.parameters.hasSlicePlane,this._configuration.roundJoins="round"===this.parameters.join,this._configuration.capType=this.parameters.cap,this._configuration.applyMarkerOffset=null!=this.parameters.markerParameters&&G(this.parameters.markerParameters),this._configuration.hasPolygonOffset=this.parameters.hasPolygonOffset,this._configuration.writeDepth=this.parameters.writeDepth,this._configuration.hasVVSize=this.parameters.hasVVSize,this._configuration.hasVVColor=this.parameters.hasVVColor,this._configuration.hasVVOpacity=this.parameters.hasVVOpacity,this._configuration.innerColorEnabled=this.parameters.innerWidth>0&&null!=this.parameters.innerColor,this._configuration.falloffEnabled=this.parameters.falloff>0,this._configuration.hasOccludees=e.hasOccludees,this._configuration.occluder=8===this.parameters.renderOccluded,this._configuration.terrainDepthTest=e.terrainDepthTest&&A(t),this._configuration.cullAboveTerrain=e.cullAboveTerrain,this._configuration.wireframe=this.parameters.wireframe,this._configuration.animation=this.parameters.animation,this._configuration.emissionSource=this.hasEmissions?1:0,this._configuration}get visible(){return this.parameters.color[3]>=D||null!=this.parameters.stipplePattern&&(this.parameters.stippleOffColor?.[3]??0)>D}setParameters(t,e){t.animation=this.parameters.animation,super.setParameters(t,e)}intersectDraped({attributes:t,screenToWorldRatio:i},r,s,a,o){if(!r.options.selectionMode)return;const n=t.get("size");let l=this.parameters.width;if(this.parameters.vvSize){const i=t.get("sizeFeatureAttribute").data[0];Number.isNaN(i)?l*=this.parameters.vvSize.fallback[0]:l*=e(this.parameters.vvSize.offset[0]+i*this.parameters.vvSize.factor[0],this.parameters.vvSize.minSize[0],this.parameters.vvSize.maxSize[0])}else n&&(l*=n.data[0]);const h=s[0],p=s[1],m=(l/2+4)*i;let c=Number.MAX_VALUE,u=0;const f=t.get("position").data,d=X(this.parameters,t)?f.length-2:f.length-5;for(let g=0;g<d;g+=3){const t=f[g],i=f[g+1],r=(g+3)%f.length,s=h-t,a=p-i,o=f[r]-t,n=f[r+1]-i,l=e((o*s+n*a)/(o*o+n*n),0,1),m=o*l-s,d=n*l-a,b=m*m+d*d;b<c&&(c=b,u=g/3)}c<m*m&&a(o.distance,o.normal,u)}intersect(i,r,u,f,d,g){const{options:S,camera:y,rayBegin:w,rayEnd:A}=u;if(!S.selectionMode||!i.visible||!y)return;if(!V(r))return void t.getLogger("esri.views.3d.webgl-engine.materials.RibbonLineMaterial").error("intersection assumes a translation-only matrix");const T=i.attributes,z=T.get("position").data;let C=this.parameters.width;if(this.parameters.vvSize){const t=T.get("sizeFeatureAttribute").data[0];Number.isNaN(t)||(C*=e(this.parameters.vvSize.offset[0]+t*this.parameters.vvSize.factor[0],this.parameters.vvSize.minSize[0],this.parameters.vvSize.maxSize[0]))}else T.has("size")&&(C*=T.get("size").data[0]);const L=Z;s(L,u.point);const M=C*y.pixelRatio/2+4*y.pixelRatio;a(ht[0],L[0]-M,L[1]+M,0),a(ht[1],L[0]+M,L[1]+M,0),a(ht[2],L[0]+M,L[1]-M,0),a(ht[3],L[0]-M,L[1]-M,0);for(let t=0;t<4;t++)if(!y.unprojectFromRenderScreen(ht[t],pt[t]))return;P(y.eye,pt[0],pt[1],mt),P(y.eye,pt[1],pt[2],ct),P(y.eye,pt[2],pt[3],ut),P(y.eye,pt[3],pt[0],ft);let O=Number.MAX_VALUE,R=0;const x=X(this.parameters,T)?z.length-2:z.length-5;for(let t=0;t<x;t+=3){H[0]=z[t]+r[12],H[1]=z[t+1]+r[13],H[2]=z[t+2]+r[14];const e=(t+3)%z.length;if(I[0]=z[e]+r[12],I[1]=z[e+1]+r[13],I[2]=z[e+2]+r[14],j(mt,H)<0&&j(mt,I)<0||j(ct,H)<0&&j(ct,I)<0||j(ut,H)<0&&j(ut,I)<0||j(ft,H)<0&&j(ft,I)<0)continue;if(y.projectToRenderScreen(H,$),y.projectToRenderScreen(I,tt),$[2]<0&&tt[2]>0){o(K,H,I);const t=y.frustum,e=-j(t[4],H)/n(K,E(t[4]));l(K,K,e),h(H,H,K),y.projectToRenderScreen(H,$)}else if($[2]>0&&tt[2]<0){o(K,I,H);const t=y.frustum,e=-j(t[4],I)/n(K,E(t[4]));l(K,K,e),h(I,I,K),y.projectToRenderScreen(I,tt)}else if($[2]<0&&tt[2]<0)continue;$[2]=0,tt[2]=0;const i=b(_($,tt,rt),L);i<O&&(O=i,p(et,H),p(it,I),R=t/3)}if(O<M*M){let t=Number.MAX_VALUE;if(v(_(et,it,rt),_(w,A,st),Q)){o(Q,Q,w);const e=m(Q);l(Q,Q,1/e),t=e/c(w,A)}g(t,Q,R)}}get hasEmissions(){return this.parameters.emissiveStrength>0}createBufferWriter(){return new Y(N(this.parameters),this.parameters)}createGLMaterial(t){return new W(t)}validateParameters(t){"miter"!==t.join&&(t.miterLimit=0),null!=t.markerParameters&&(t.markerScale=t.markerParameters.width/t.width)}update(t){const{hasAnimation:e,animationSpeed:i}=this.parameters;return!!e&&(this.setParameters({timeElapsed:r(t.time)*i},!1),0!==t.dt)}}class W extends M{constructor(){super(...arguments),this._stipplePattern=null}dispose(){super.dispose(),this._stippleTextures?.release(this._stipplePattern),this._stipplePattern=null}beginSlot(t){const e=this._material.parameters.stipplePattern;return this._stipplePattern!==e&&(this._material.setParameters({stippleTexture:this._stippleTextures.swap(e,this._stipplePattern)}),this._stipplePattern=e),this.getTechnique(k,t)}}class J extends R{constructor(){super(...arguments),this.width=0,this.color=d,this.join="miter",this.cap=0,this.miterLimit=5,this.writeDepth=!0,this.hasPolygonOffset=!1,this.stippleTexture=null,this.stipplePreferContinuous=!0,this.markerParameters=null,this.markerScale=1,this.hasSlicePlane=!1,this.vvFastUpdate=!1,this.isClosed=!1,this.falloff=0,this.innerWidth=0,this.wireframe=!1,this.timeElapsed=0,this.animation=0,this.animationSpeed=1,this.trailLength=1,this.emissiveStrength=0}get transparent(){return this.color[3]<1||this.hasAnimation||null!=this.stipplePattern&&(this.stippleOffColor?.[3]??0)<1}get hasAnimation(){return 0!==this.animation}}class Y{constructor(t,e){this.layout=t,this._parameters=e;const i=e.stipplePattern?1:0;switch(this._parameters.join){case"miter":case"bevel":this.numJoinSubdivisions=i;break;case"round":this.numJoinSubdivisions=F+i}}_isClosed(t){return X(this._parameters,t)}allocate(t){return this.layout.createBuffer(t)}elementCount(t){const e=2,i=t.get("position").indices.length/2+1,r=this._isClosed(t);let s=r?2:2*e;return s+=((r?i:i-1)-(r?0:1))*(2*this.numJoinSubdivisions+4),s+=2,this._parameters.wireframe&&(s=2+4*(s-2)),s}write(t,e,i,r,s,o){const n=i.get("position"),l=n.indices,h=n.data.length/3,m=i.get("distanceToStart")?.data;l&&l.length!==2*(h-1)&&console.warn("RibbonLineMaterial does not support indices");const f=(this.layout.fields.has("sizeFeatureAttribute")?i.get("sizeFeatureAttribute")?.data[0]:i.get("size")?.data[0])??1;let d=[1,1,1,1],b=0;const _=this.layout.fields.has("colorFeatureAttribute");_?b=i.get("colorFeatureAttribute").data[0]:i.has("color")&&(d=i.get("color").data);const S=i.get("timeStamps")?.data,v=S&&this.layout.fields.has("timeStamps"),P=this.layout.fields.has("opacityFeatureAttribute"),y=P?i.get("opacityFeatureAttribute").data[0]:0,j=new Float32Array(s.buffer),E=g(s.buffer),w=new Uint8Array(s.buffer),A=this.layout.stride/4;let T=o*A;const z=T;let C=0;const M=m?(t,e,i)=>C=m[i]:(t,e,i)=>C+=c(t,e),O=j.BYTES_PER_ELEMENT/E.BYTES_PER_ELEMENT,V=4/O,R=(t,e,i,s,a,o,n,l)=>{j[T++]=e[0],j[T++]=e[1],j[T++]=e[2],x(t,e,E,T*O),T+=V,x(i,e,E,T*O),T+=V,j[T++]=l;let h=T*O;if(E[h++]=a,E[h++]=o,T=Math.ceil(h/O),_)j[T]=b;else{const t=Math.min(4*n,d.length-4),e=4*T;w[e]=255*d[t],w[e+1]=255*d[t+1],w[e+2]=255*d[t+2],w[e+3]=255*d[t+3]}if(T++,j[T++]=f,P&&(j[T++]=y),L()){let t=4*T;r?(w[t++]=r[0],w[t++]=r[1],w[t++]=r[2],w[t++]=r[3]):(w[t++]=0,w[t++]=0,w[t++]=0,w[t++]=0),T=Math.ceil(.25*t)}v&&(h=T*O,E[h++]=s[0],E[h++]=s[1],E[h++]=s[2],T=Math.ceil(h/O))};T+=A,a(ot,n.data[0],n.data[1],n.data[2]),v&&a(lt,S[0],S[1],S[2]),t&&u(ot,ot,t);const F=this._isClosed(i);if(F){const e=n.data.length-3;a(at,n.data[e],n.data[e+1],n.data[e+2]),t&&u(at,at,t)}else a(nt,n.data[3],n.data[4],n.data[5]),t&&u(nt,nt,t),R(ot,ot,nt,lt,1,-4,0,0),R(ot,ot,nt,lt,1,4,0,0),p(at,ot),p(ot,nt),v&&a(lt,S[3],S[4],S[5]);const N=F?0:1,k=F?h:h-1;for(let c=N;c<k;c++){const e=(c+1)%h*3;a(nt,n.data[e],n.data[e+1],n.data[e+2]),t&&u(nt,nt,t),M(at,ot,c),R(at,ot,nt,lt,0,-1,c,C),R(at,ot,nt,lt,0,1,c,C);const i=this.numJoinSubdivisions;for(let t=0;t<i;++t){const e=(t+1)/(i+1);R(at,ot,nt,lt,e,-1,c,C),R(at,ot,nt,lt,e,1,c,C)}R(at,ot,nt,lt,1,-2,c,C),R(at,ot,nt,lt,1,2,c,C),p(at,ot),p(ot,nt),v&&a(lt,S[e],S[e+1],S[e+2])}F?(a(nt,n.data[3],n.data[4],n.data[5]),t&&u(nt,nt,t),C=M(at,ot,k),R(at,ot,nt,lt,0,-1,N,C),R(at,ot,nt,lt,0,1,N,C)):(C=M(at,ot,k),R(at,ot,ot,lt,0,-5,k,C),R(at,ot,ot,lt,0,5,k,C)),q(j,z+A,j,z,A);return T=q(j,T-A,j,T,A),this._parameters.wireframe&&this._addWireframeVertices(s,z,T,A),null}_addWireframeVertices(t,e,i,r){const s=new Float32Array(t.buffer,i*Float32Array.BYTES_PER_ELEMENT),a=new Float32Array(t.buffer,e*Float32Array.BYTES_PER_ELEMENT,i-e);let o=0;const n=t=>o=q(a,t,s,o,r);for(let l=0;l<a.length-1;l+=2*r)n(l),n(l+2*r),n(l+1*r),n(l+2*r),n(l+1*r),n(l+3*r)}}function q(t,e,i,r,s){for(let a=0;a<s;a++)i[r++]=t[e++];return r}function X(t,e){if(!t.isClosed)return!1;return e.get("position").indices.length>2}function G(t){return 1===t.anchor&&t.hideOnShortSegments&&"begin-end"===t.placement&&t.worldSpace}const H=f(),I=f(),K=f(),Q=f(),Z=f(),$=i(),tt=i(),et=f(),it=f(),rt=S(),st=S(),at=f(),ot=f(),nt=f(),lt=f(),ht=[i(),i(),i(),i()],pt=[f(),f(),f(),f()],mt=y(),ct=y(),ut=y(),ft=y();export{J as Parameters,B as RibbonLineMaterial};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{n as e,i as t,g as r,f as s}from"../../../../chunks/vec32.js";import{fromValues as i,create as a}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{fromValues as n}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{center as o,scale as p}from"../../../../geometry/support/aaBoundingBox.js";import{BufferViewVec3f as c}from"../../../../geometry/support/buffer/BufferView.js";import{isColorOrOID as h,isColorOrColorEmission as l}from"../core/shaderLibrary/ShaderOutput.js";import u from"../lib/GLMaterial.js";import{Material as f,MaterialParameters as m}from"../lib/Material.js";import{intersectTriangleGeometry as g}from"../lib/RayIntersections.js";import{assert as d}from"../lib/Util.js";import{writeAttributes as b,writePosition as _}from"./internal/bufferWriterUtils.js";import{getLayout as S,ShadedColorMaterialTechnique as j}from"../shaders/ShadedColorMaterialTechnique.js";import{ShadedColorMaterialTechniqueConfiguration as w}from"../shaders/ShadedColorMaterialTechniqueConfiguration.js";import{alphaCutoff as T}from"../../../../webscene/support/AlphaCutoff.js";class x extends f{constructor(e){super(e,D),this._configuration=new w,this.supportsEdges=!0,this._pp0=i(0,0,1),this._pp1=i(0,0,0),this.produces=new Map([[2,e=>
|
|
5
|
+
import{n as e,i as t,g as r,f as s}from"../../../../chunks/vec32.js";import{fromValues as i,create as a}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{fromValues as n}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{center as o,scale as p}from"../../../../geometry/support/aaBoundingBox.js";import{BufferViewVec3f as c}from"../../../../geometry/support/buffer/BufferView.js";import{isColorOrOID as h,isColorOrColorEmission as l}from"../core/shaderLibrary/ShaderOutput.js";import u from"../lib/GLMaterial.js";import{Material as f,MaterialParameters as m}from"../lib/Material.js";import{intersectTriangleGeometry as g}from"../lib/RayIntersections.js";import{assert as d}from"../lib/Util.js";import{writeAttributes as b,writePosition as _}from"./internal/bufferWriterUtils.js";import{getLayout as S,ShadedColorMaterialTechnique as j}from"../shaders/ShadedColorMaterialTechnique.js";import{ShadedColorMaterialTechniqueConfiguration as w}from"../shaders/ShadedColorMaterialTechniqueConfiguration.js";import{alphaCutoff as T}from"../../../../webscene/support/AlphaCutoff.js";class x extends f{constructor(e){super(e,D),this._configuration=new w,this.supportsEdges=!0,this._pp0=i(0,0,1),this._pp1=i(0,0,0),this.produces=new Map([[2,e=>9===e||h(e)&&!this.parameters.transparent],[4,e=>h(e)&&this.parameters.transparent&&this.parameters.writeDepth],[8,e=>h(e)&&this.parameters.transparent&&!this.parameters.writeDepth]])}getConfiguration(e,t){return super.getConfiguration(e,t,this._configuration),this._configuration.cullFace=this.parameters.cullFace,this._configuration.hasSlicePlane=this.parameters.hasSlicePlane,this._configuration.transparent=this.parameters.transparent,this._configuration.writeDepth=this.parameters.writeDepth,this._configuration.screenSizeEnabled=this.parameters.screenSizeEnabled,this._configuration.shadingEnabled=this.parameters.shadingEnabled,this._configuration.oitPass=t.oitPass,this._configuration.terrainDepthTest=t.terrainDepthTest&&l(e),this._configuration.cullAboveTerrain=t.cullAboveTerrain,this._configuration}get visible(){return this.parameters.color[3]>=T}intersect(e,t,r,s,i,a){this._intersect(e,r,s,i,a)}intersectDraped(e,t,r,s){return this._pp0[0]=this._pp1[0]=r[0],this._pp0[1]=this._pp1[1]=r[1],this._intersect(e,t,this._pp0,this._pp1,s)}_intersect(e,i,a,n,c){if(this.parameters.screenSizeEnabled){const h=e.attributes.get("offset"),l={applyToVertex:(e,a,n,o)=>{const p=t(E,h.data[3*o],h.data[3*o+1],h.data[3*o+2]),c=t(M,e,a,n);return r(p,p,this.parameters.screenSizeScale*(i.camera?.computeScreenPixelSizeAt(p)??1)),s(c,c,p),[c[0],c[1],c[2]]},applyToAabb:e=>{const t=o(e,E);return p(e,this.parameters.screenSizeScale*(i.camera?.computeScreenPixelSizeAt(t)??1))}};g(e,i,a,n,l,c)}else g(e,i,a,n,void 0,c)}createGLMaterial(e){return new z(e)}createBufferWriter(){return new y(S(this.parameters))}}class z extends u{beginSlot(e){return this.getTechnique(j,e)}}class D extends m{constructor(){super(...arguments),this.color=n(1,1,1,1),this.shadingTint=n(0,0,0,.25),this.shadingDirection=e(a(),[.5,-.5,-.5]),this.screenSizeScale=14,this.forceTransparentMode=!1,this.writeDepth=!0,this.hasSlicePlane=!1,this.cullFace=0,this.screenSizeEnabled=!1,this.shadingEnabled=!0}get transparent(){return this.color[3]<1||this.forceTransparentMode}}class y{constructor(e){this.layout=e}elementCount(e){return e.get("position").indices.length}write(e,t,r,s,i,a){const n=b(r,s,this.layout,e,t,i,a),o=i.getField("offset",c);if(o&&r.has("offset")){const e=r.get("offset");d(3===e.size),_(e,t,o,a)}return n}}const E=a(),M=a();export{D as Parameters,x as ShadedColorMaterial};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{WaterDistortionPassParameters as e}from"../core/shaderLibrary/shading/WaterDistortion.glsl.js";import{ReloadableShaderModule as r}from"../core/shaderTechnique/ReloadableShaderModule.js";import{ShaderTechnique as t}from"../core/shaderTechnique/ShaderTechnique.js";import{olidEnabled as s}from"../effects/geometry/olidUtils.js";import{oitPolygonOffset as o,getDrawBuffers as a,depthWrite as i,oitDepthTest as n,blending as l}from"../lib/OrderIndependentTransparency.js";import{PositionUvf32OlidLayout as d,PositionUvf32Layout as c}from"./DefaultLayouts.js";import{W as p}from"../../../../chunks/WaterSurface.glsl.js";import{makePipelineState as f,defaultColorWrite as m}from"../../../webgl/renderState.js";class u extends e{}class h extends t{constructor(e,t){super(e,t,new r(p,()=>import("../shaders/WaterSurface.glsl.js")),s()?d.locations:c.locations)}initializePipeline(e){const{oitPass:r,output:t,transparent:s,draped:d}=e;return f({blending:3!==t&&
|
|
5
|
+
import{WaterDistortionPassParameters as e}from"../core/shaderLibrary/shading/WaterDistortion.glsl.js";import{ReloadableShaderModule as r}from"../core/shaderTechnique/ReloadableShaderModule.js";import{ShaderTechnique as t}from"../core/shaderTechnique/ShaderTechnique.js";import{olidEnabled as s}from"../effects/geometry/olidUtils.js";import{oitPolygonOffset as o,getDrawBuffers as a,depthWrite as i,oitDepthTest as n,blending as l}from"../lib/OrderIndependentTransparency.js";import{PositionUvf32OlidLayout as d,PositionUvf32Layout as c}from"./DefaultLayouts.js";import{W as p}from"../../../../chunks/WaterSurface.glsl.js";import{makePipelineState as f,defaultColorWrite as m}from"../../../webgl/renderState.js";class u extends e{}class h extends t{constructor(e,t){super(e,t,new r(p,()=>import("../shaders/WaterSurface.glsl.js")),s()?d.locations:c.locations)}initializePipeline(e){const{oitPass:r,output:t,transparent:s,draped:d}=e;return f({blending:3!==t&&9!==t&&10!==t&&s?l(r):null,depthTest:d?null:{func:n(r)},depthWrite:i(e),drawBuffers:a(r,t),colorWrite:m,polygonOffset:o(e)})}}export{u as WaterMaterialPassParameters,h as WaterTechnique};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{__decorate as t}from"tslib";import i from"../../../../../core/Accessor.js";import"../../../../../core/has.js";import{disposeMaybe as e}from"../../../../../core/maybe.js";import{property as s}from"../../../../../core/accessorSupport/decorators/property.js";import"../../../../../core/Logger.js";import"../../../../../core/RandomLCG.js";import{subclass as r}from"../../../../../core/accessorSupport/decorators/subclass.js";import{GLMaterials as a}from"../../lib/GLMaterials.js";import{DrawParameters as o}from"../DrawParameters.js";import{defaultHighlightName as n}from"../../../../support/HighlightDefaults.js";let h=class extends i{constructor(t){super(t),this._glMaterials=null,this._drawParameters=new o,this._highlightNames=new Set,this._produces=new Map}initialize(){this._updateProduces()}destroy(){this.uninitializeRenderContext()}get _hasHighlights(){return this._highlightNames.size>0}hasHighlight(t){return this._highlightNames.has(t)}get produces(){return this._produces}_updateProduces(){this.material.produces.forEach((t,i)=>{this._produces.set(i,i=>!(0===this.dataByOrigin.size||!(
|
|
5
|
+
import{__decorate as t}from"tslib";import i from"../../../../../core/Accessor.js";import"../../../../../core/has.js";import{disposeMaybe as e}from"../../../../../core/maybe.js";import{property as s}from"../../../../../core/accessorSupport/decorators/property.js";import"../../../../../core/Logger.js";import"../../../../../core/RandomLCG.js";import{subclass as r}from"../../../../../core/accessorSupport/decorators/subclass.js";import{GLMaterials as a}from"../../lib/GLMaterials.js";import{DrawParameters as o}from"../DrawParameters.js";import{defaultHighlightName as n}from"../../../../support/HighlightDefaults.js";let h=class extends i{constructor(t){super(t),this._glMaterials=null,this._drawParameters=new o,this._highlightNames=new Set,this._produces=new Map}initialize(){this._updateProduces()}destroy(){this.uninitializeRenderContext()}get _hasHighlights(){return this._highlightNames.size>0}hasHighlight(t){return this._highlightNames.has(t)}get produces(){return this._produces}_updateProduces(){this.material.produces.forEach((t,i)=>{this._produces.set(i,i=>!(0===this.dataByOrigin.size||!(9!==i&&5!==i||this._hasHighlights))&&t(i))})}initializeRenderContext(t){this._glMaterials=new a(this.material,t.materials)}uninitializeRenderContext(){this._glMaterials=e(this._glMaterials)}acquireTechniques(t){if(!this.material.shouldRender(t))return null;const{output:i,bind:e}=t,s=this.material.produces.get(e.slot);if(!s?.(i))return null;const{highlight:r,slot:a}=e,o=5===i,h=9===i,l=h||o,g=r?.name;if(l&&(0===this._highlightNames.size||h&&g&&!this._highlightNames.has(g)))return null;const d=t=>h&&!!g&&!t.has(g),m=6===i,u=!(l||m);for(const{buffers:c}of this.dataByOrigin.values())for(const s of c){if(d(s.highlightNames))continue;const r=o?s.drawCommandsHighlights.get(n):l?g?s.drawCommandsHighlights.get(g):s.drawCommandsHighlights.size>0:((m&&s.needsMultipleCommands?s.drawCommandsShadowHighlightRest:s.drawCommandsDefault)||null)?.length??!1,h=u&&s.drawCommandsOccludees||null;if(r||h?.length){const s=this._glMaterials.load(t.rctx,a,i),r=s?.beginSlot(e);if(r)return r}}return null}render(t,i){const{output:e,bind:s}=t,{slot:r,highlight:a}=s,o=9===e,h=a?.name??"";if(o&&!a)return;const l=5===e,g=o||l,d=6===e,m=!(g||d),u=10===r||11===r?r:null,{rctx:c}=t;c.runAppleAmdDriverHelper();const p=c.bindTechnique(i,s,this.material.parameters);for(const f of this.dataByOrigin.values())for(const t of f.buffers){if(o&&(!t.hasHighlights||!t.drawCommandsHighlights.has(h)))continue;if(l&&(!t.hasHighlights||!t.drawCommandsHighlights.has(n)))continue;const e=g&&!l?t.drawCommandsHighlights.get(h)??null:null,r=l?t.drawCommandsHighlights.get(n):g?e:d&&t.needsMultipleCommands?t.drawCommandsShadowHighlightRest:t.drawCommandsDefault,a=null!=r,w=m&&t.drawCommandsOccludees||null;if(a||w?.length){if(this._drawParameters.origin=f.origin,p.bindDraw(s,this.material.parameters,this._drawParameters),i.ensureAttributeLocations(t.vao),c.bindVAO(t.vao),a)for(const t of r)c.setPipelineState(i.getPipeline(!1,u)),c.drawArrays(i.primitiveType,t.first,t.count);if(w?.length){c.setPipelineState(i.getPipeline(!0,u));for(const t of w)c.drawArrays(i.primitiveType,t.first,t.count)}}}}updateHighlights(){const{_highlightNames:t}=this;t.clear();for(const i of this.dataByOrigin.values())for(const e of i.buffers)for(const i of e.highlightNames)t.add(i);this._updateProduces()}get test(){}};t([s({constructOnly:!0})],h.prototype,"material",void 0),t([s({constructOnly:!0})],h.prototype,"dataByOrigin",void 0),h=t([r("esri.views.3d.webgl-engine.materials.renderers.VaoRenderer")],h);export{h as VaoRenderer};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/*
|
|
2
|
+
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
|
+
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
|
+
*/
|
|
5
|
+
import"../core/shaderLibrary/ScreenSpacePass.glsl.js";import"../core/shaderLibrary/output/ReadDepth.glsl.js";import"../core/shaderModules/glsl.js";import"../core/shaderModules/Texture2DPassUniform.js";import"../../../webgl/NoParameters.js";import"../../../webgl/ShaderBuilder.js";export{C as CutFillDepthParameters,b as build}from"../../../../chunks/CutFillDepth.glsl.js";
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/*
|
|
2
|
+
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
|
+
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
|
+
*/
|
|
5
|
+
import{ReloadableShaderModule as e}from"../core/shaderTechnique/ReloadableShaderModule.js";import{ShaderTechnique as r}from"../core/shaderTechnique/ShaderTechnique.js";import{Pos2Locations as t}from"../lib/DefaultVertexBufferLayouts.js";import{a as o}from"../../../../chunks/CutFillDepth.glsl.js";import{makePipelineState as i,defaultColorWrite as l}from"../../../webgl/renderState.js";class s extends r{constructor(r,i){super(r,i,new e(o,()=>import("./CutFillDepth.glsl.js")),t)}initializePipeline(){return i({colorWrite:l})}}export{s as CutFillDepthTechnique};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/*
|
|
2
|
+
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
|
+
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
|
+
*/
|
|
5
|
+
import"../core/shaderLibrary/ScreenSpacePass.glsl.js";import"../core/shaderModules/glsl.js";import"../core/shaderModules/Texture2DPassUniform.js";import"../../../webgl/NoParameters.js";import"../../../webgl/ShaderBuilder.js";export{C as CutFillReductionParameters,b as build}from"../../../../chunks/CutFillReduction.glsl.js";
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/*
|
|
2
|
+
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
|
+
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
|
+
*/
|
|
5
|
+
import{ReloadableShaderModule as e}from"../core/shaderTechnique/ReloadableShaderModule.js";import{ShaderTechnique as r}from"../core/shaderTechnique/ShaderTechnique.js";import{Pos2Locations as o}from"../lib/DefaultVertexBufferLayouts.js";import{a as t}from"../../../../chunks/CutFillReduction.glsl.js";import{makePipelineState as i,defaultColorWrite as l}from"../../../webgl/renderState.js";class s extends r{constructor(r,i){super(r,i,new e(t,()=>import("./CutFillReduction.glsl.js")),o)}initializePipeline(){return i({colorWrite:l})}}export{s as CutFillReductionTechnique};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/*
|
|
2
|
+
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
|
+
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
|
+
*/
|
|
5
|
+
import"../../../../core/libs/gl-matrix-2/math/mat4.js";import"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import"../core/shaderLibrary/Transform.glsl.js";import"../core/shaderLibrary/output/OutputDepth.glsl.js";import"../core/shaderModules/Float2PassUniform.js";import"../core/shaderModules/glsl.js";import"../core/shaderModules/Matrix4PassUniform.js";import"../../../webgl/NoParameters.js";import"../../../webgl/ShaderBuilder.js";export{C as CutFillTargetDepthParameters,b as build}from"../../../../chunks/CutFillTargetDepth.glsl.js";
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/*
|
|
2
|
+
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
|
+
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
|
+
*/
|
|
5
|
+
import{ReloadableShaderModule as e}from"../core/shaderTechnique/ReloadableShaderModule.js";import{ShaderTechnique as r}from"../core/shaderTechnique/ShaderTechnique.js";import{Pos3Locations as t}from"../lib/DefaultVertexBufferLayouts.js";import{a as o}from"../../../../chunks/CutFillTargetDepth.glsl.js";import{makePipelineState as i,defaultDepthWrite as s,defaultColorWrite as l}from"../../../webgl/renderState.js";class a extends r{constructor(r,i){super(r,i,new e(o,()=>import("./CutFillTargetDepth.glsl.js")),t)}initializePipeline(){return i({colorWrite:l,depthWrite:s,depthTest:{func:519}})}}export{a as CutFillTargetDepthTechnique};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{newLayout as e}from"../../support/buffer/InterleavedLayout.js";import{isColorOrColorEmission as r}from"../core/shaderLibrary/ShaderOutput.js";import{ReloadableShaderModule as o}from"../core/shaderTechnique/ReloadableShaderModule.js";import{ShaderTechnique as t}from"../core/shaderTechnique/ShaderTechnique.js";import{olidEnabled as s}from"../effects/geometry/olidUtils.js";import{getDrawBuffers as i,oitBlending as n}from"../lib/OrderIndependentTransparency.js";import{H as l}from"../../../../chunks/HUDMaterial.glsl.js";import{PrimitiveType as a}from"../../../webgl/enums.js";import{makePipelineState as c,defaultColorWrite as f,defaultDepthWrite as u,premultipliedAlpha as p}from"../../../webgl/renderState.js";class d extends t{constructor(e,r){super(e,r,new o(l,()=>import("./HUDMaterial.glsl.js")),(s()?v:h).locations),this.primitiveType=r.occlusionPass?a.POINTS:a.TRIANGLES}initializePipeline(e){const{oitPass:o,hasPolygonOffset:t,draped:s,output:l,depthTestEnabled:a,occlusionPass:d}=e,h=0===o,v=a&&!s&&!(1===o)&&!d&&!(
|
|
5
|
+
import{newLayout as e}from"../../support/buffer/InterleavedLayout.js";import{isColorOrColorEmission as r}from"../core/shaderLibrary/ShaderOutput.js";import{ReloadableShaderModule as o}from"../core/shaderTechnique/ReloadableShaderModule.js";import{ShaderTechnique as t}from"../core/shaderTechnique/ShaderTechnique.js";import{olidEnabled as s}from"../effects/geometry/olidUtils.js";import{getDrawBuffers as i,oitBlending as n}from"../lib/OrderIndependentTransparency.js";import{H as l}from"../../../../chunks/HUDMaterial.glsl.js";import{PrimitiveType as a}from"../../../webgl/enums.js";import{makePipelineState as c,defaultColorWrite as f,defaultDepthWrite as u,premultipliedAlpha as p}from"../../../webgl/renderState.js";class d extends t{constructor(e,r){super(e,r,new o(l,()=>import("./HUDMaterial.glsl.js")),(s()?v:h).locations),this.primitiveType=r.occlusionPass?a.POINTS:a.TRIANGLES}initializePipeline(e){const{oitPass:o,hasPolygonOffset:t,draped:s,output:l,depthTestEnabled:a,occlusionPass:d}=e,h=0===o,v=a&&!s&&!(1===o)&&!d&&!(9===l);return c({blending:r(l)?h?p:n(o):null,depthTest:a&&!s?{func:515}:null,depthWrite:v?u:null,drawBuffers:i(o,l),colorWrite:f,polygonOffset:t?m:null})}}const m={factor:0,units:-4},h=e().vec3f("position").vec3f("normal").vec2i16("uvi").vec4u8("color").vec2f("size").f32("rotation").vec4f("centerOffsetAndDistance").vec4f("featureAttribute"),v=h.clone().vec4u8("olidColor");export{d as HUDMaterialTechnique,h as layout,v as olidLayout};
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{isColorOrColorEmission as o,isColorEmission as r}from"../core/shaderLibrary/ShaderOutput.js";import{Emissions as l}from"../core/shaderLibrary/output/Emissions.glsl.js";import{OutputHighlight as i}from"../core/shaderLibrary/output/OutputHighlight.glsl.js";import{ColorConversion as s}from"../core/shaderLibrary/util/ColorConversion.glsl.js";import{If as a,glsl as t}from"../core/shaderModules/glsl.js";import{alphaCutoff as e}from"../../../../webscene/support/AlphaCutoff.js";function n(n,u){n.include(i,u),n.include(l,u),n.fragment.include(s);const{output:f,oitPass:d,discardInvisibleFragments:m,snowCover:p}=u,c=
|
|
5
|
+
import{isColorOrColorEmission as o,isColorEmission as r}from"../core/shaderLibrary/ShaderOutput.js";import{Emissions as l}from"../core/shaderLibrary/output/Emissions.glsl.js";import{OutputHighlight as i}from"../core/shaderLibrary/output/OutputHighlight.glsl.js";import{ColorConversion as s}from"../core/shaderLibrary/util/ColorConversion.glsl.js";import{If as a,glsl as t}from"../core/shaderModules/glsl.js";import{alphaCutoff as e}from"../../../../webscene/support/AlphaCutoff.js";function n(n,u){n.include(i,u),n.include(l,u),n.fragment.include(s);const{output:f,oitPass:d,discardInvisibleFragments:m,snowCover:p}=u,c=10===f,g=r(f),C=o(f)&&1===d,h=o(f)&&1!==d;let v=0;(h||g||C)&&n.outputs.add("fragColor","vec4",v++),g&&n.outputs.add("fragEmission","vec4",v++),C&&n.outputs.add("fragAlpha","float",v++),n.fragment.code.add(t`
|
|
6
6
|
void outputColorHighlightOID(vec4 finalColor, const in vec3 vWorldPosition, vec3 emissiveSymbolColor ${a(p,", float snow")}) {
|
|
7
7
|
${a(c,"finalColor.a = 1.0;")}
|
|
8
8
|
|
package/views/3d/webgl.js
CHANGED
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import o from"../../Camera.js";import{rad2deg as e,deg2rad as r}from"../../core/mathUtils.js";import{create as t}from"../../core/libs/gl-matrix-2/factories/mat4f64.js";import{g as
|
|
5
|
+
import o from"../../Camera.js";import{rad2deg as e,deg2rad as r}from"../../core/mathUtils.js";import{create as t}from"../../core/libs/gl-matrix-2/factories/mat4f64.js";import{g as i,f as n}from"../../chunks/vec32.js";import{create as c}from"../../core/libs/gl-matrix-2/factories/vec3f64.js";import l from"../../geometry/Point.js";import a from"../../geometry/SpatialReference.js";import{computeTranslationToOriginAndRotation as s}from"../../geometry/projection/computeTranslationToOriginAndRotation.js";import{projectBuffer as p}from"../../geometry/projection/projectBuffer.js";import{projectPointToVector as m}from"../../geometry/projection/projectPointToVector.js";import{projectVectorToVector as f}from"../../geometry/projection/projectVectorToVector.js";import{cameraOnContentAlongViewDirection as u}from"./camera/intersectionUtils.js";import{directionToHeadingTilt as d,viewModeDependentUtil as R}from"./support/viewingModeUtils.js";const g={OPAQUE:"opaque-color",TRANSPARENT:"transparent-color",COMPOSITE:"composite-color",FINAL:"final-color"},j={SSAO:"ssao",LASERLINES:"laserline-color",ANTIALIASING:"aa-color",HIGHLIGHTS:"highlight-color",MAGNIFIER:"magnifier-color",OCCLUDED:"occluded-color",VIEWSHED:"viewshed-color",CUTFILL_DEPTH:"cutfill-depth",OPAQUE_TERRAIN:"opaque-terrain-color",OPAQUE_ENVIRONMENT:"opaque-environment-color",TRANSPARENT_ENVIRONMENT:"transparent-environment-color",FOCUSAREA:"focusarea",FOCUSAREA_COLOR:"focusarea-color"};function A(o,e,r,t,i,n,c){return t=t||o.spatialReference,p(e,t,r,i,o.renderCoordsHelper.spatialReference,n,c)?i:null}function E(o,e,r,t,i,n,c){return n=n||o.spatialReference,p(e,o.renderCoordsHelper.spatialReference,r,t,n,i,c)?t:null}function y(o,e,r,i){return i||(i=t()),r=r||o.spatialReference,s(r,e,i,o.renderCoordsHelper.spatialReference)?i:null}function T(r,t,i){const n=r.renderSpatialReference,c=d(r,t.eye,t.viewForward,t.up,I);let s=r.spatialReference;return f(t.eye,n,S,s)||(s=a.WGS84,f(t.eye,n,S,s)),null==i?i=new o(new l(S,s),c.heading,c.tilt,e(t.fov)):(i.position.x=S[0],i.position.y=S[1],i.position.z=S[2],i.position.spatialReference=s,i.heading=c.heading,i.tilt=c.tilt,i.fov=e(t.fov)),i.layout.row=t.row,i.layout.rows=t.rows,i.layout.column=t.column,i.layout.columns=t.columns,i}function N(o,e){if(!e)return null;const t=o.renderSpatialReference,l=R(o).headingTiltToDirectionUp,a=c();if(!m(e.position,a,t))return null;const s=l(a,e.heading,e.tilt);i(s.direction,s.direction,o.state.camera.distance),n(s.direction,s.direction,a);const p=u(o,a,s.direction,s.up);return p.fov=r(e.fov),p.row=e.layout.row,p.rows=e.layout.rows,p.column=e.layout.column,p.columns=e.layout.columns,p}const S=c(),I={heading:0,tilt:0};export{j as InternalRenderCategory,g as RenderCategory,T as fromRenderCamera,E as fromRenderCoordinates,y as renderCoordinateTransformAt,N as toRenderCamera,A as toRenderCoordinates};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{__decorate as e}from"tslib";import t from"../../../Graphic.js";import{createTask as i}from"../../../core/asyncUtils.js";import s from"../../../core/Collection.js";import o from"../../../core/Error.js";import{EventedAccessor as r}from"../../../core/Evented.js";import n from"../../../core/Logger.js";import{destroyMaybe as a,assertIsSome as h,abortMaybe as p}from"../../../core/maybe.js";import{pausable as c,when as l,watch as d,initial as m,sync as v}from"../../../core/reactiveUtils.js";import{property as y}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/RandomLCG.js";import{subclass as _}from"../../../core/accessorSupport/decorators/subclass.js";import g from"../../../geometry/Point.js";import{closeRingsAndFixWinding as u,getMidpoint as f,geometryToCoordinates as x}from"../../../geometry/support/coordsUtils.js";import G from"../../../layers/GraphicsLayer.js";import M from"../../../symbols/SimpleMarkerSymbol.js";import{SnappingVisualizer2D as b}from"../../2d/interactive/SnappingVisualizer2D.js";import{ConnectedReshapeManager as V}from"./ConnectedReshapeManager.js";import{screenDeltaToMapDelta as S,cloneMove as w}from"./drawUtils.js";import E from"./GraphicMover.js";import I from"./HighlightHelper.js";import{addUniqueLayer as O,isConnectedReshapeSupportedLayer as C}from"./layerUtils.js";import{createTooltipInfos as k,connectTooltip as T,updateTranslateTooltipInfo as H,updateTranslateVertexTooltipInfo as R}from"./reshapeTooltipUtils.js";import{settings as j}from"./settings.js";import{ViewEventPriorities as A}from"../../input/InputManager.js";import{createCoordinateHelper as U}from"../../interactive/coordinateHelper.js";import{sketchKeys as L}from"../../interactive/keybindings.js";import{EditGeometryOperations as z}from"../../interactive/editGeometry/EditGeometryOperations.js";import D from"../../interactive/sketch/SketchOptions.js";import{SnappingContext as F}from"../../interactive/snapping/SnappingContext.js";import{makeTooltip as P,enterInputModeIfAvailable as N}from"../../interactive/tooltip/tooltipCommonUtils.js";const Z=j.reshapeGraphics,X={vertices:{default:new M({style:"circle",size:Z.vertex.size,color:Z.vertex.color,outline:{color:Z.vertex.outlineColor,width:1}}),hover:new M({style:"circle",size:Z.vertex.hoverSize,color:Z.vertex.hoverColor,outline:{color:Z.vertex.hoverOutlineColor,width:1}}),selected:new M({style:"circle",size:Z.selected.size,color:Z.selected.color,outline:{color:Z.selected.outlineColor,width:1}})},midpoints:{default:new M({style:"circle",size:Z.midpoint.size,color:Z.midpoint.color,outline:{color:Z.midpoint.outlineColor,width:1}}),hover:new M({style:"circle",size:Z.midpoint.size,color:Z.midpoint.color,outline:{color:Z.midpoint.outlineColor,width:1}})}},Y=Symbol();let q=class extends r{constructor(e){super(e),this._updateHandlesOnExternalGeometryChange=null,this._activeOperationInfo=null,this._connectedReshapeManager=null,this._editGeometryOperations=null,this._graphicAttributes={esriSketchTool:"box"},this._mover=null,this._snappingContext=null,this._snappingGraphicsLayer=null,this._hoverGraphic=null,this._snappingTask=null,this._stagedVertex=null,this.tooltip=null,this.activeTooltipInfo=null,this.callbacks={onReshapeStart(){},onReshape(){},onReshapeStop(){},onMoveStart(){},onMove(){},onMoveStop(){},onGraphicClick(){}},this.connectedReshapeProviders=[],this.enableMidpoints=!0,this.enableMovement=!0,this.enableVertices=!0,this.graphic=null,this.highlightName=null,this.highlightsEnabled=!0,this.layer=null,this.midpointGraphics=new s,this.midpointSymbol=new M({style:"circle",size:6,color:[200,200,200],outline:{color:[100,100,100],width:1}}),this.selectedVertices=new s,this.snappingManager=null,this.symbols=X,this.sketchOptions=new D,this.type="reshape",this.vertexGraphics=new s,this.view=null}initialize(){const e=this.view;this._highlightHelper=new I({view:e}),this._setup(),this._updateHandlesOnExternalGeometryChange=c(()=>this.graphic?.geometry,e=>{if(!e)return;const t=new Set(this.selectedVertices.map(e=>e.attributes?.pointIndex));this._highlightHelper.removeAll(),this._setUpHighlights(),this._setupGraphics(),this._clearSelection(),this.vertexGraphics.filter(e=>t.has(e.attributes.pointIndex)).forEach(e=>this._addToSelection(e));const{enableMovement:i,_mover:s,graphic:o,midpointGraphics:r,vertexGraphics:n}=this,a=n.concat(r).items;i&&a.push(o),s?.set("graphics",a)},v),this.tooltip=P(()=>({view:e,options:this.sketchOptions.tooltips})),this.tooltipInfos=k(this.sketchOptions),this.addHandles([l(()=>e?.ready,()=>{const{layer:e,view:t}=this;O(t,e),this.addHandles(t.on("key-down",e=>this._keyDownHandler(e),A.TOOL))},{once:!0,initial:!0}),d(()=>this.graphic,()=>this.refresh()),d(()=>this.layer,(e,t)=>{t&&(this._clearSelection(),this._resetGraphics(t)),this.refresh()}),d(()=>[this.highlightsEnabled,this.highlightName],()=>{this._highlightHelper?.removeAll(),this._setUpHighlights()}),d(()=>this.enableMidpoints,()=>this.refresh()),T(this.tooltip,()=>this._tooltipsContext),d(()=>this.view.effectiveTheme.accentColor,()=>this._updateSymbolsForTheme(),m),this._updateHandlesOnExternalGeometryChange]),this._updateTooltip()}destroy(){this._reset(),this._mover?.destroy(),this._mover=null,this._connectedReshapeManager=a(this._connectedReshapeManager),this.tooltip=a(this.tooltip)}get _coordinateHelper(){return this._editGeometryOperations?.data.coordinateHelper??U(!!this.graphic.geometry?.hasZ,!!this.graphic.geometry?.hasM,this.view.spatialReference)}get _selectedVertex(){return 1===this.selectedVertices.length?this.selectedVertices.at(0):void 0}get _tooltipsContext(){const{automaticAreaMeasurementUtils:e,automaticLengthMeasurementUtils:t,sketchOptions:i,activeTooltipInfo:s,graphic:o}=this;return{sketchOptions:i,activeTooltipInfo:s,graphic:o,selectedVertex:this._selectedVertex,automaticAreaMeasurementUtils:e,automaticLengthMeasurementUtils:t,updateGeometry:(e,t,i,s,o)=>{this._setUpGeometryHelper();const r=e===this.graphic;r?this._emitMoveStartEvent(0,0):this._emitReshapeStartEvent(e);const n=!0;if(this._syncGeometryAfterVertexMove(e,t,s,o,n),r){const{view:e}=this,s=e.toScreen(i),o=e.toScreen(t),r=(o?.x??0)-(s?.x??0),n=(o?.y??0)-(s?.y??0);this._emitMoveEvent(r,n),this._emitMoveStopEvent(r,n)}else this._emitReshapeEvent(e),this._emitReshapeStopEvent(e);this._editGeometryOperations=a(this._editGeometryOperations)}}}get state(){const e=this.view.ready,t=!(!this.graphic||!this.layer);return e&&t?"active":e?"ready":"disabled"}isUIGraphic(e){const t=[];return this.graphic&&t.push(this.graphic),t.concat(this.vertexGraphics.items,this.midpointGraphics.items),t.length>0&&t.includes(e)}refresh(){this._reset(),this._setup()}reset(){this.graphic=null}clearSelection(){this._clearSelection()}removeSelectedVertices(){const{selectedVertices:e}=this;e.length&&this._removeVertices(e)}_setup(){const{graphic:e,layer:t}=this;if(!t||null==e?.geometry)return;const i=e.geometry;"mesh"!==i.type&&"extent"!==i.type?("polygon"===i.type&&u(i),this._setUpHighlights(),this._setupGraphics(),this._setupMover(),this._setupConnectedReshapeManager()):this._logGeometryTypeError()}_setUpHighlights(){this.highlightsEnabled&&this.graphic&&this._highlightHelper?.add(this.graphic,this.highlightName)}_setUpGeometryHelper(){const e=this.graphic.geometry;null!=e&&"mesh"!==e.type&&"extent"!==e.type?this._editGeometryOperations=z.fromGeometry(e,2):this._logGeometryTypeError()}_saveSnappingContextForHandle(e,t){this._snappingGraphicsLayer=new G({listMode:"hide",internal:!0,title:"Reshape snapping layer"}),this.view.map.layers.add(this._snappingGraphicsLayer);const i=this._editGeometryOperations;h(i),this._snappingContext=new F({editGeometryOperations:i,elevationInfo:{mode:"on-the-ground",offset:0},pointer:t.viewEvent?.pointerType||"mouse",excludeFeature:this.graphic,feature:this.graphic,visualizer:new b(this._snappingGraphicsLayer),vertexHandle:this._getVertexFromEditGeometry(e)})}_reset(){this._clearSelection(),this._highlightHelper?.removeAll(),this._updateTooltip(),this._resetGraphics(),this._resetSnappingStateVars(),this._activeOperationInfo=null,this._mover?.destroy(),this._mover=null,this.removeHandles(Y)}_resetSnappingStateVars(){null!=this.snappingManager&&this.snappingManager.doneSnapping(),null!=this._snappingGraphicsLayer&&(this.view?.map&&this.view.map.layers.remove(this._snappingGraphicsLayer),this._snappingGraphicsLayer.destroy()),this._editGeometryOperations=a(this._editGeometryOperations),this._snappingTask=p(this._snappingTask),this._snappingTask=null,this._snappingContext=null,this._stagedVertex=null}_resetGraphics(e){this._removeMidpointGraphics(e),this._removeVertexGraphics(e),this.selectedVertices.removeAll(),this._updateTooltip()}_removeMidpointGraphics(e){const t=e||this.layer;t&&t.removeMany(this.midpointGraphics.items),this.midpointGraphics.items.forEach(e=>e.destroy()),this.midpointGraphics.removeAll()}_removeVertexGraphics(e){const t=e||this.layer;t&&t.removeMany(this.vertexGraphics.items),this.vertexGraphics.items.forEach(e=>e.destroy()),this.vertexGraphics.removeAll()}_setupGraphics(){const e=this.graphic.geometry;if(null!=e&&("polyline"===e.type||"polygon"===e.type||"multipoint"===e.type)){const t=K(e);this.enableMidpoints&&"multipoint"!==e.type&&this._setUpMidpointGraphics(t),this.enableVertices&&this._setUpVertexGraphics(t)}}_setUpMidpointGraphics(e){this._removeMidpointGraphics();const t=this._createMidpointGraphics(e);this.midpointGraphics.addMany(t),this.layer.addMany(t)}_setUpVertexGraphics(e){this._removeVertexGraphics();const t=this._createVertexGraphics(e);this.vertexGraphics.addMany(t),this._storeRelatedVertexIndices(),this.layer.addMany(t)}_createVertexGraphics(e){const{_graphicAttributes:i,symbols:s}=this,o=[];return e?.forEach((e,r)=>{e.forEach((e,n)=>{o.push(new t({geometry:this._coordinateHelper.arrayToPoint(e),symbol:s?.vertices?.default,attributes:{...i,pathIndex:r,pointIndex:n}}))})}),o}_createMidpointGraphics(e){const{_graphicAttributes:i,symbols:s}=this,o=[];for(let r=0;r<e.length;r++){const n=e[r];for(let e=0;e<n.length;e++){const a=(e+1)%n.length;if("polyline"===this.graphic.geometry?.type&&0===a)continue;const h=n[e],p=n[a],c=this._getMidpoint(h,p);o.push(new t({geometry:c,symbol:s.midpoints.default,attributes:{...i,pathIndex:r,pointIndexStart:e,pointIndexEnd:a}}))}}return o}_updateSymbolsForTheme(){const e=this.view.effectiveTheme.accentColor;this.symbols={vertices:{...this.symbols.vertices,default:this.symbols.vertices.default.clone().set("color",e),hover:this.symbols.vertices.hover?.clone().set("color",e)},midpoints:{...this.symbols.midpoints}};for(const t of this.vertexGraphics)this._isSelected(t)?t.symbol=this.symbols.vertices.selected:this._hoverGraphic===t?t.symbol=this.symbols.vertices.hover:t.symbol=this.symbols.vertices.default}_storeRelatedVertexIndices(){const e=this.vertexGraphics.items;if(!e)return;const t=e.map(({geometry:e})=>({x:e.x,y:e.y}));for(let i=0;i<t.length;i++){const s=[];for(let e=0;e<t.length;e++){if(i===e)continue;const o=t[i],r=t[e];o.x===r.x&&o.y===r.y&&s.push(e)}e[i].attributes.relatedGraphicIndices=s}}_setupMover(){const{enableMovement:e,graphic:t,midpointGraphics:i,vertexGraphics:s,view:o}=this,r=s.concat(i).items;e&&"multipoint"!==t.geometry?.type&&r.push(t),this._mover=new E({enableMoveAllGraphics:!1,highlightsEnabled:!1,indicatorsEnabled:!1,graphics:r,view:o,callbacks:{onGraphicClick:e=>this._onGraphicClickCallback(e),onGraphicMoveStart:e=>this._onGraphicMoveStartCallback(e),onGraphicMove:e=>this._onGraphicMoveCallback(e),onGraphicMoveStop:e=>this._onGraphicMoveStopCallback(e),onGraphicPointerOver:e=>this._onGraphicPointerOverCallback(e),onGraphicPointerOut:e=>this._onGraphicPointerOutCallback(e)}})}_setupConnectedReshapeManager(){const{connectedReshapeProviders:e}=this;0!==e.length&&(this._connectedReshapeManager=new V({providerFactories:e,view:this.view}))}_onGraphicClickCallback(e){e.viewEvent.stopPropagation();const t=e.graphic;if(t===this.graphic)this.clearSelection(),this.emit("graphic-click",e),this.callbacks.onGraphicClick?.(e);else if(this._isMidpoint(t)){if(2===e.viewEvent.button)return;const i=this.graphic.clone(),s=this._createVertexFromMidpoint(t);this.refresh(),this._emitVertexAddEvent([t],i,s)}else if(this._isVertex(t))if(e.viewEvent.stopPropagation(),2===e.viewEvent.button)this._removeVertices(t);else{e.viewEvent.native.shiftKey||this._clearSelection(),this.selectedVertices.includes(t)?this._removeFromSelection(t,!0):this._addToSelection(t)}}_setUpOperation(e){const{graphic:t,dx:i,dy:s}=e,o=t===this.graphic;this._resetSnappingStateVars(),this._setUpGeometryHelper(),this._saveSnappingContextForHandle(t,e),this._activeOperationInfo={target:this.graphic,mover:t,operationType:o?"move":"reshape",totalDx:i,totalDy:s}}_onGraphicMoveStartCallback(e){const{dx:t,dy:i,graphic:s}=e,o=this._connectedReshapeManager,r=o?Q(this.graphic):null;if(s===this.graphic){const{geometry:n}=s;return this._setUpOperation(e),this._emitMoveStartEvent(t,i),r&&o?.startFeatureMove([r]),void(null!=n&&"point"===n.type&&this._onHandleMove(s,t,i,e,()=>{this._updateTooltip(this.graphic,e.viewEvent),this._emitMoveEvent(t,i)}))}const{selectedVertices:n}=this;if(!n.includes(s)){if(this._clearSelection(),this._isMidpoint(s)){const e=this.graphic.clone(),t=this._createVertexFromMidpoint(s);this._emitVertexAddEvent([s],e,t)}this._addToSelection(s)}this._setUpOperation(e),r&&o?.startVertexMove(r,W(n)),this._emitReshapeStartEvent(s),this._onHandleMove(s,t,i,e,()=>{this._updateTooltip(s,e.viewEvent),this._emitReshapeEvent(s)})}_onGraphicMoveCallback(e){const t=this._activeOperationInfo;if(!t)return;const{dx:i,dy:s,graphic:o}=e;t.totalDx+=i,t.totalDy+=s;const{operationType:r}=t,{geometry:n}=o;if(null!=n)if("move"!==r)this._onHandleMove(o,i,s,e,()=>{this._updateTooltip(o,e.viewEvent),this._emitReshapeEvent(o)});else if("point"===n.type)this._onHandleMove(o,i,s,e,()=>{this._updateTooltip(this.graphic,e.viewEvent),this._emitMoveEvent(i,s)});else if("polyline"===n.type||"polygon"===n.type){const t=K(n);this._updateVertexGraphicLocations(t);const{dxMap:o,dyMap:r}=S(i,s,this.view);this._connectedReshapeManager?.translate(o,r,0),this._updateTooltip(this.graphic,e.viewEvent),this._emitMoveEvent(i,s)}}_onGraphicMoveStopCallback(e){const t=this._activeOperationInfo;if(!t)return;const{dx:i,dy:s,graphic:o}=e,{operationType:r}=t;t.totalDx+=i,t.totalDy+=s,this._onHandleMove(o,i,s,e,()=>"move"===r?this._emitMoveStopEvent():this._emitReshapeStopEvent(o)),this._isMidpoint(o)?this.refresh():(this._updateTooltip(this._isVertex(o)?o:null),this._resetSnappingStateVars(),this._connectedReshapeManager?.finish(),this._activeOperationInfo=null)}_updateVertexGraphicLocations(e){const{_coordinateHelper:t}=this;for(const i of this.vertexGraphics){const{pathIndex:s,pointIndex:o}=i.attributes;i.geometry=t.arrayToPoint(e[s][o])}this._updateMidpointGraphicLocations(e)}_updateMidpointGraphicLocations(e){for(const t of this.midpointGraphics){const{pathIndex:i,pointIndexStart:s,pointIndexEnd:o}=t.attributes,r=e[i];t.geometry=this._getMidpoint(r[s],r[o])}}_getMidpoint(e,t){const{_coordinateHelper:i}=this,s=i.arrayToVector(e),o=i.arrayToVector(t),r=i.toXYZ(s),n=i.toXYZ(o),[a,h,p]=f(r,n),c=i.hasM()?0:void 0;return new g({x:a,y:h,z:p,m:c,spatialReference:i.spatialReference})}_getVertexFromEditGeometry(e){const[t,i]=B(e);return h(this._editGeometryOperations),this._editGeometryOperations.data.parts[t].vertices[i]}_onHandleMove(e,t,s,o,r){p(this._snappingTask);const n=this._snappingContext;if(!n)return;const a=e.geometry,h="graphic-move-stop"===o.type;if(null!=this.snappingManager&&this.selectedVertices.length<2&&!h){const o=this.snappingManager;this._stagedVertex=o.update({point:a,context:n}),this._syncGeometryAfterVertexMove(e,new g(this._stagedVertex),t,s,h),r(),this._snappingTask=i(async i=>{const p=await o.snap({point:a,context:n,signal:i});p.valid&&(this._stagedVertex=p.apply(),this._syncGeometryAfterVertexMove(e,new g(this._stagedVertex),t,s,h),r())})}else{const i=null!=this._stagedVertex?new g(this._stagedVertex):a;this._syncGeometryAfterVertexMove(e,i,t,s,h),r()}}_syncGeometryAfterVertexMove(e,t,i,s,o=!1){const r=this._editGeometryOperations?.data.geometry;if(r)if("point"===r.type)e.geometry=t;else if("mesh"===r.type)e.geometry=r.centerAt(t);else{const{_coordinateHelper:n}=this,[a,h]=B(e);let p=x(r);const c=p[a].length-1,l=n.pointToArray(t);if(p[a][h]=l,"polygon"===r.type&&(0===h?p[a][c]=l:h===c&&(p[a][0]=l)),this._isVertex(e)&&(p=this._moveRelatedCoordinates(p,e,l),p=this._moveSelectedHandleCoordinates(p,e,i,s,"polygon"===r.type),this._updateMidpointGraphicLocations(p)),"multipoint"===r.type&&r.points)for(let e=0;e<p.length;e++)r.points[e]=p[e][0];this._updateGraphicGeometry(r.clone());const d=n.pointToVector(t),m=this._getVertexFromEditGeometry(e),v=n.getZ(d),y=d[0]-m.pos[0],_=d[1]-m.pos[1],g=null!=v?v-m.pos[2]:0;this._editGeometryOperations?.moveVertices([m],y,_,g),this._connectedReshapeManager?.translate(y,_,g),o&&(this._mover?this._mover.updateGeometry(this._mover.graphics.indexOf(e),t):e.geometry=t)}}_moveRelatedCoordinates(e,t,i){const{relatedGraphicIndices:s}=t.attributes;for(const o of s){const s=this.vertexGraphics.at(o),{pathIndex:r,pointIndex:n}=s.attributes;e[r][n]=i,s.geometry=t.geometry}return e}_moveSelectedHandleCoordinates(e,t,i,s,o){for(const r of this.selectedVertices)if(r!==t){const{pathIndex:t,pointIndex:n,relatedGraphicIndices:a}=r.attributes,h=w(r.geometry,i,s,this.view),p=x(h),c=e[t].length-1;e[t][n]=p,r.geometry=h,o&&(0===n?e[t][c]=p:n===c&&(e[t][0]=p));for(const i of a){const t=this.vertexGraphics.at(i),{pathIndex:s,pointIndex:o}=t.attributes;e[s][o]=p,t.geometry=h}}return e}_onGraphicPointerOverCallback(e){const t=e.graphic;this._hoverGraphic=t;const i=this._isVertex(t);i&&!this._isSelected(t)&&(t.symbol=this.symbols.vertices.hover),this._updateTooltip(i?t:null),this._updateHoverCursor(t)}_onGraphicPointerOutCallback(e){const t=e.graphic;this._hoverGraphic=null,this._isVertex(t)&&!this._isSelected(t)&&(t.symbol=this.symbols.vertices.default),this.removeHandles(Y),this._updateTooltip()}_createVertexFromMidpoint(e){const{_graphicAttributes:t,graphic:i}=this,s=i.geometry;if(null==s||"polygon"!==s.type&&"polyline"!==s.type)return[];const o=s.clone(),r=[],{pathIndex:n,pointIndexStart:a,pointIndexEnd:h}=e.attributes,p=x(e.geometry),c=0===h?a+1:h,l=x(o);return l[n].splice(c,0,p),e.attributes={...t,pathIndex:n,pointIndex:c,relatedGraphicIndices:[]},r.push({coordinates:l[n][c],componentIndex:n,vertexIndex:c}),this._updateGraphicGeometry(o),r}_addToSelection(e){const t=J(e);for(const i of t)i.symbol=this.symbols.vertices.selected,this.selectedVertices.add(i),this._updateTooltip(i);this._emitSelectEvent(t)}_removeFromSelection(e,t){const{vertices:i}=this.symbols,s=t?i.hover:i.default;this.selectedVertices.remove(e),e.symbol=s,this._emitDeselectEvent([e]),this._updateTooltip()}_clearSelection(){const e=this.selectedVertices.toArray();if(e.length>0){for(const t of e)t.set("symbol",this.symbols.vertices.default);this.selectedVertices.removeAll(),this._emitDeselectEvent(e),this._updateTooltip()}}_keyDownHandler(e){null==this._activeOperationInfo&&N(e,this.tooltip)||L.delete.includes(e.key)&&!e.repeat&&this.selectedVertices.length&&this._removeVertices(this.selectedVertices)}_removeVertices(e){const t=this.graphic.geometry,i=this.vertexGraphics.length;if(null==t||"polygon"!==t.type&&"polyline"!==t.type&&"multipoint"!==t.type)return;if("polygon"===t.type&&i<4||"multipoint"===t.type&&i<2||"polyline"===t.type&&i<3)return;const s=this.graphic.clone(),o=t.clone();let r=x(o);const n=[],a=J(e);for(const h of a){const{x:e,y:t}=h.geometry;for(let i=0;i<r.length;i++){const s=r[i];for(let o=0;o<s.length;o++){const[a,h]=s[o];e===a&&t===h&&(n.push({coordinates:r[i][o],componentIndex:i,vertexIndex:o}),r[i].splice(Number(o),1))}}}if("polygon"===o.type)r=r.filter(e=>{if(e.length<2)return!1;const[t,i]=e[0],[s,o]=e[e.length-1];return(2!==e.length||t!==s||i!==o)&&(t===s&&i===o||e.push(e[0]),!0)}),o.rings=r;else if("polyline"===o.type){for(const e of r)1===e.length&&r.splice(r.indexOf(e),1);o.paths=r}else o.points=r.flat();this._updateGraphicGeometry(o),this.refresh(),this._emitVertexRemoveEvent(a,s,n)}_isVertex(e){return this.vertexGraphics.includes(e)}_isSelected(e){return this._isVertex(e)&&this.selectedVertices.includes(e)}_isMidpoint(e){return this.midpointGraphics.includes(e)}_updateHoverCursor(e){const t=this._isMidpoint(e)?"copy":"move";this.addHandles(this.view.acquireCursor(t,"high"),Y)}_updateTooltip(e,t){let i=null;const{graphic:s,view:o,tooltipInfos:r}=this,n=s?.geometry;"point"===n?.type?i=r.movePoint:this._selectedVertex?i=r.selectedVertex:e===this.graphic?(i=r.translateGraphic,H(i,o,this._tooltipsContext,t)):e&&this.selectedVertices.length>1&&(i=r.translateVertices,R(i,o,n,this._tooltipsContext,t)),this.activeTooltipInfo=i}_updateGraphicGeometry(e){this._updateHandlesOnExternalGeometryChange?.pause(),this.graphic.geometry=e,this._updateHandlesOnExternalGeometryChange?.resume()}_emitMoveStartEvent(e,t){const i={type:"move-start",mover:this.graphic,dx:e,dy:t};this.emit("move-start",i),this.callbacks.onMoveStart?.(i)}_emitMoveEvent(e,t){const i={type:"move",mover:this.graphic,dx:e,dy:t};this.emit("move",i),this.callbacks.onMove?.(i)}_emitMoveStopEvent(e,t){if(null==e||null==t){const i=this._activeOperationInfo;if(!i)return;e=i.totalDx,t=i.totalDy}const i={type:"move-stop",mover:this.graphic,dx:e,dy:t};this.emit("move-stop",i),this.callbacks.onMoveStop?.(i)}_emitReshapeStartEvent(e){const t={type:"reshape-start",graphic:this.graphic,mover:e,selected:this.selectedVertices.toArray()};this.emit("reshape-start",t),this.callbacks.onReshapeStart?.(t)}_emitReshapeEvent(e){const t={type:"reshape",graphic:this.graphic,mover:e,selected:this.selectedVertices.toArray()};this.emit("reshape",t),this.callbacks.onReshape?.(t)}_emitReshapeStopEvent(e){const t={type:"reshape-stop",graphic:this.graphic,mover:e,selected:this.selectedVertices.toArray()};this.emit("reshape-stop",t),this.callbacks.onReshapeStop?.(t)}_emitSelectEvent(e){const t={type:"vertex-select",added:e};this.emit("select",t),this.callbacks.onVertexSelect?.(t)}_emitDeselectEvent(e){const t={type:"vertex-deselect",removed:e};this.emit("deselect",t),this.callbacks.onVertexDeselect?.(t)}_emitVertexAddEvent(e,t,i){const s={type:"vertex-add",added:e,graphic:this.graphic,oldGraphic:t,vertices:i};this.emit("vertex-add",s),this.callbacks.onVertexAdd?.(s)}_emitVertexRemoveEvent(e,t,i){const s={type:"vertex-remove",removed:e,graphic:this.graphic,oldGraphic:t,vertices:i};this.emit("vertex-remove",s),this.callbacks.onVertexRemove?.(s)}_logGeometryTypeError(){n.getLogger(this).error(new o("reshape:invalid-geometry","Reshape operation not supported for the provided graphic. The geometry type is not supported."))}};function K(e){const t=x(e.clone());if("polygon"===e.type)for(const i of t){const e=i[i.length-1];i[0][0]===e[0]&&i[0][1]===e[1]&&i.length>2&&i.pop()}return t}function B({attributes:e}){return[e?.pathIndex||0,e?.pointIndex||0]}function J(e){return e instanceof t?[e]:[...e]}function Q(e){const t=e.sourceLayer??e.layer;return C(t)?{graphic:e,layer:t}:null}function W(e){return e.toArray().map(e=>({pathIndex:e.attributes.pathIndex,vertexIndex:e.attributes.pointIndex}))}e([y()],q.prototype,"_activeOperationInfo",void 0),e([y()],q.prototype,"_connectedReshapeManager",void 0),e([y()],q.prototype,"_coordinateHelper",null),e([y()],q.prototype,"_editGeometryOperations",void 0),e([y()],q.prototype,"tooltip",void 0),e([y()],q.prototype,"tooltipInfos",void 0),e([y()],q.prototype,"activeTooltipInfo",void 0),e([y({constructOnly:!0})],q.prototype,"automaticAreaMeasurementUtils",void 0),e([y({constructOnly:!0})],q.prototype,"automaticLengthMeasurementUtils",void 0),e([y()],q.prototype,"_selectedVertex",null),e([y()],q.prototype,"_tooltipsContext",null),e([y()],q.prototype,"callbacks",void 0),e([y()],q.prototype,"connectedReshapeProviders",void 0),e([y()],q.prototype,"enableMidpoints",void 0),e([y()],q.prototype,"enableMovement",void 0),e([y()],q.prototype,"enableVertices",void 0),e([y()],q.prototype,"graphic",void 0),e([y()],q.prototype,"highlightName",void 0),e([y()],q.prototype,"highlightsEnabled",void 0),e([y()],q.prototype,"layer",void 0),e([y({readOnly:!0})],q.prototype,"midpointGraphics",void 0),e([y()],q.prototype,"midpointSymbol",void 0),e([y({readOnly:!0})],q.prototype,"selectedVertices",void 0),e([y()],q.prototype,"snappingManager",void 0),e([y({readOnly:!0})],q.prototype,"state",null),e([y()],q.prototype,"symbols",void 0),e([y({type:D})],q.prototype,"sketchOptions",void 0),e([y({readOnly:!0})],q.prototype,"type",void 0),e([y({readOnly:!0})],q.prototype,"vertexGraphics",void 0),e([y()],q.prototype,"view",void 0),q=e([_("esri.views.draw.support.Reshape")],q);const $=q;export{$ as default};
|
|
5
|
+
import{__decorate as e}from"tslib";import t from"../../../Graphic.js";import{createTask as i}from"../../../core/asyncUtils.js";import s from"../../../core/Collection.js";import o from"../../../core/Error.js";import{EventedAccessor as r}from"../../../core/Evented.js";import n from"../../../core/Logger.js";import{destroyMaybe as a,assertIsSome as h,abortMaybe as p}from"../../../core/maybe.js";import{pausable as c,when as l,watch as d,initial as m,sync as v}from"../../../core/reactiveUtils.js";import{property as y}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/RandomLCG.js";import{subclass as _}from"../../../core/accessorSupport/decorators/subclass.js";import g from"../../../geometry/Point.js";import{closeRingsAndFixWinding as u,getMidpoint as f,geometryToCoordinates as x}from"../../../geometry/support/coordsUtils.js";import{isPoint as G}from"../../../geometry/support/typeUtils.js";import M from"../../../layers/GraphicsLayer.js";import b from"../../../symbols/SimpleMarkerSymbol.js";import{SnappingVisualizer2D as V}from"../../2d/interactive/SnappingVisualizer2D.js";import{ConnectedReshapeManager as S}from"./ConnectedReshapeManager.js";import{screenDeltaToMapDelta as w,cloneMove as E}from"./drawUtils.js";import I from"./GraphicMover.js";import O from"./HighlightHelper.js";import{addUniqueLayer as C,isConnectedReshapeSupportedLayer as k}from"./layerUtils.js";import{createTooltipInfos as T,connectTooltip as H,updateTranslateTooltipInfo as R,updateTranslateVertexTooltipInfo as j}from"./reshapeTooltipUtils.js";import{settings as A}from"./settings.js";import{ViewEventPriorities as U}from"../../input/InputManager.js";import{createCoordinateHelper as L}from"../../interactive/coordinateHelper.js";import{sketchKeys as z}from"../../interactive/keybindings.js";import{EditGeometryOperations as D}from"../../interactive/editGeometry/EditGeometryOperations.js";import F from"../../interactive/sketch/SketchOptions.js";import{SnappingContext as P}from"../../interactive/snapping/SnappingContext.js";import{makeTooltip as N,enterInputModeIfAvailable as Z}from"../../interactive/tooltip/tooltipCommonUtils.js";const X=A.reshapeGraphics,Y={vertices:{default:new b({style:"circle",size:X.vertex.size,color:X.vertex.color,outline:{color:X.vertex.outlineColor,width:1}}),hover:new b({style:"circle",size:X.vertex.hoverSize,color:X.vertex.hoverColor,outline:{color:X.vertex.hoverOutlineColor,width:1}}),selected:new b({style:"circle",size:X.selected.size,color:X.selected.color,outline:{color:X.selected.outlineColor,width:1}})},midpoints:{default:new b({style:"circle",size:X.midpoint.size,color:X.midpoint.color,outline:{color:X.midpoint.outlineColor,width:1}}),hover:new b({style:"circle",size:X.midpoint.size,color:X.midpoint.color,outline:{color:X.midpoint.outlineColor,width:1}})}},q=Symbol();let K=class extends r{constructor(e){super(e),this._updateHandlesOnExternalGeometryChange=null,this._activeOperationInfo=null,this._connectedReshapeManager=null,this._editGeometryOperations=null,this._graphicAttributes={esriSketchTool:"box"},this._mover=null,this._snappingContext=null,this._snappingGraphicsLayer=null,this._hoverGraphic=null,this._snappingTask=null,this._stagedVertex=null,this.tooltip=null,this.activeTooltipInfo=null,this.callbacks={onReshapeStart(){},onReshape(){},onReshapeStop(){},onMoveStart(){},onMove(){},onMoveStop(){},onGraphicClick(){}},this.connectedReshapeProviders=[],this.enableMidpoints=!0,this.enableMovement=!0,this.enableVertices=!0,this.graphic=null,this.highlightName=null,this.highlightsEnabled=!0,this.layer=null,this.midpointGraphics=new s,this.midpointSymbol=new b({style:"circle",size:6,color:[200,200,200],outline:{color:[100,100,100],width:1}}),this.selectedVertices=new s,this.snappingManager=null,this.symbols=Y,this.sketchOptions=new F,this.type="reshape",this.vertexGraphics=new s,this.view=null}initialize(){const e=this.view;this._highlightHelper=new O({view:e}),this._setup(),this._updateHandlesOnExternalGeometryChange=c(()=>this.graphic?.geometry,e=>{if(!e)return;const t=new Set(this.selectedVertices.map(e=>e.attributes?.pointIndex));this._highlightHelper.removeAll(),this._setUpHighlights(),this._setupGraphics(),this._clearSelection(),this.vertexGraphics.filter(e=>t.has(e.attributes.pointIndex)).forEach(e=>this._addToSelection(e));const{enableMovement:i,_mover:s,graphic:o,midpointGraphics:r,vertexGraphics:n}=this,a=n.concat(r).items;i&&a.push(o),s?.set("graphics",a)},v),this.tooltip=N(()=>({view:e,options:this.sketchOptions.tooltips})),this.tooltipInfos=T(this.sketchOptions),this.addHandles([l(()=>e?.ready,()=>{const{layer:e,view:t}=this;C(t,e),this.addHandles(t.on("key-down",e=>this._keyDownHandler(e),U.TOOL))},{once:!0,initial:!0}),d(()=>this.graphic,()=>this.refresh()),d(()=>this.layer,(e,t)=>{t&&(this._clearSelection(),this._resetGraphics(t)),this.refresh()}),d(()=>[this.highlightsEnabled,this.highlightName],()=>{this._highlightHelper?.removeAll(),this._setUpHighlights()}),d(()=>this.enableMidpoints,()=>this.refresh()),H(this.tooltip,()=>this._tooltipsContext),d(()=>this.view.effectiveTheme.accentColor,()=>this._updateSymbolsForTheme(),m),this._updateHandlesOnExternalGeometryChange]),this._updateTooltip()}destroy(){this._reset(),this._mover?.destroy(),this._mover=null,this._connectedReshapeManager=a(this._connectedReshapeManager),this.tooltip=a(this.tooltip)}get _coordinateHelper(){return this._editGeometryOperations?.data.coordinateHelper??L(!!this.graphic.geometry?.hasZ,!!this.graphic.geometry?.hasM,this.view.spatialReference)}get _selectedVertex(){return 1===this.selectedVertices.length?this.selectedVertices.at(0):void 0}get _tooltipsContext(){const{automaticAreaMeasurementUtils:e,automaticLengthMeasurementUtils:t,sketchOptions:i,activeTooltipInfo:s,graphic:o}=this;return{sketchOptions:i,activeTooltipInfo:s,graphic:o,selectedVertex:this._selectedVertex,automaticAreaMeasurementUtils:e,automaticLengthMeasurementUtils:t,updateGeometry:(e,t,i,s,o)=>{this._setUpGeometryHelper();const r=e===this.graphic;r?this._emitMoveStartEvent(0,0):this._emitReshapeStartEvent(e);const n=!0;if(this._syncGeometryAfterVertexMove(e,t,s,o,n),r){const{view:e}=this,s=e.toScreen(i),o=e.toScreen(t),r=(o?.x??0)-(s?.x??0),n=(o?.y??0)-(s?.y??0);this._emitMoveEvent(r,n),this._emitMoveStopEvent(r,n)}else this._emitReshapeEvent(e),this._emitReshapeStopEvent(e);this._editGeometryOperations=a(this._editGeometryOperations)}}}get state(){const e=this.view.ready,t=!(!this.graphic||!this.layer);return e&&t?"active":e?"ready":"disabled"}isUIGraphic(e){const t=[];return this.graphic&&t.push(this.graphic),t.concat(this.vertexGraphics.items,this.midpointGraphics.items),t.length>0&&t.includes(e)}refresh(){this._reset(),this._setup()}reset(){this.graphic=null}clearSelection(){this._clearSelection()}removeSelectedVertices(){const{selectedVertices:e}=this;e.length&&this._removeVertices(e)}_setup(){const{graphic:e,layer:t}=this;if(!t||null==e?.geometry)return;const i=e.geometry;"mesh"!==i.type&&"extent"!==i.type?("polygon"===i.type&&u(i),this._setUpHighlights(),this._setupGraphics(),this._setupMover(),this._setupConnectedReshapeManager()):this._logGeometryTypeError()}_setUpHighlights(){this.highlightsEnabled&&this.graphic&&this._highlightHelper?.add(this.graphic,this.highlightName)}_setUpGeometryHelper(){const e=this.graphic.geometry;null!=e&&"mesh"!==e.type&&"extent"!==e.type?this._editGeometryOperations=D.fromGeometry(e,2):this._logGeometryTypeError()}_saveSnappingContextForHandle(e,t){this._snappingGraphicsLayer=new M({listMode:"hide",internal:!0,title:"Reshape snapping layer"}),this.view.map.layers.add(this._snappingGraphicsLayer);const i=this._editGeometryOperations;h(i),this._snappingContext=new P({editGeometryOperations:i,elevationInfo:{mode:"on-the-ground",offset:0},pointer:t.viewEvent?.pointerType||"mouse",excludeFeature:this.graphic,feature:this.graphic,visualizer:new V(this._snappingGraphicsLayer),vertexHandle:this._getVertexFromEditGeometry(e)})}_reset(){this._clearSelection(),this._highlightHelper?.removeAll(),this._updateTooltip(),this._resetGraphics(),this._resetSnappingStateVars(),this._activeOperationInfo=null,this._mover?.destroy(),this._mover=null,this.removeHandles(q)}_resetSnappingStateVars(){null!=this.snappingManager&&this.snappingManager.doneSnapping(),null!=this._snappingGraphicsLayer&&(this.view?.map&&this.view.map.layers.remove(this._snappingGraphicsLayer),this._snappingGraphicsLayer.destroy()),this._editGeometryOperations=a(this._editGeometryOperations),this._snappingTask=p(this._snappingTask),this._snappingTask=null,this._snappingContext=null,this._stagedVertex=null}_resetGraphics(e){this._removeMidpointGraphics(e),this._removeVertexGraphics(e),this.selectedVertices.removeAll(),this._updateTooltip()}_removeMidpointGraphics(e){const t=e||this.layer;t&&t.removeMany(this.midpointGraphics.items),this.midpointGraphics.items.forEach(e=>e.destroy()),this.midpointGraphics.removeAll()}_removeVertexGraphics(e){const t=e||this.layer;t&&t.removeMany(this.vertexGraphics.items),this.vertexGraphics.items.forEach(e=>e.destroy()),this.vertexGraphics.removeAll()}_setupGraphics(){const e=this.graphic.geometry;if(null!=e&&("polyline"===e.type||"polygon"===e.type||"multipoint"===e.type)){const t=B(e);this.enableMidpoints&&"multipoint"!==e.type&&this._setUpMidpointGraphics(t),this.enableVertices&&this._setUpVertexGraphics(t)}}_setUpMidpointGraphics(e){this._removeMidpointGraphics();const t=this._createMidpointGraphics(e);this.midpointGraphics.addMany(t),this.layer.addMany(t)}_setUpVertexGraphics(e){this._removeVertexGraphics();const t=this._createVertexGraphics(e);this.vertexGraphics.addMany(t),this._storeRelatedVertexIndices(),this.layer.addMany(t)}_createVertexGraphics(e){const{_graphicAttributes:i,symbols:s}=this,o=[];return e?.forEach((e,r)=>{e.forEach((e,n)=>{o.push(new t({geometry:this._coordinateHelper.arrayToPoint(e),symbol:s?.vertices?.default,attributes:{...i,pathIndex:r,pointIndex:n}}))})}),o}_createMidpointGraphics(e){const{_graphicAttributes:i,symbols:s}=this,o=[];for(let r=0;r<e.length;r++){const n=e[r];for(let e=0;e<n.length;e++){const a=(e+1)%n.length;if("polyline"===this.graphic.geometry?.type&&0===a)continue;const h=n[e],p=n[a],c=this._getMidpoint(h,p);o.push(new t({geometry:c,symbol:s.midpoints.default,attributes:{...i,pathIndex:r,pointIndexStart:e,pointIndexEnd:a}}))}}return o}_updateSymbolsForTheme(){const e=this.view.effectiveTheme.accentColor;this.symbols={vertices:{...this.symbols.vertices,default:this.symbols.vertices.default.clone().set("color",e),hover:this.symbols.vertices.hover?.clone().set("color",e)},midpoints:{...this.symbols.midpoints}};for(const t of this.vertexGraphics)this._isSelected(t)?t.symbol=this.symbols.vertices.selected:this._hoverGraphic===t?t.symbol=this.symbols.vertices.hover:t.symbol=this.symbols.vertices.default}_storeRelatedVertexIndices(){const e=this.vertexGraphics.items;if(!e)return;const t=e.map(({geometry:e})=>({x:e.x,y:e.y}));for(let i=0;i<t.length;i++){const s=[];for(let e=0;e<t.length;e++){if(i===e)continue;const o=t[i],r=t[e];o.x===r.x&&o.y===r.y&&s.push(e)}e[i].attributes.relatedGraphicIndices=s}}_setupMover(){const{enableMovement:e,graphic:t,midpointGraphics:i,vertexGraphics:s,view:o}=this,r=s.concat(i).items;e&&"multipoint"!==t.geometry?.type&&r.push(t),this._mover=new I({enableMoveAllGraphics:!1,highlightsEnabled:!1,indicatorsEnabled:!1,graphics:r,view:o,callbacks:{onGraphicClick:e=>this._onGraphicClickCallback(e),onGraphicMoveStart:e=>this._onGraphicMoveStartCallback(e),onGraphicMove:e=>this._onGraphicMoveCallback(e),onGraphicMoveStop:e=>this._onGraphicMoveStopCallback(e),onGraphicPointerOver:e=>this._onGraphicPointerOverCallback(e),onGraphicPointerOut:e=>this._onGraphicPointerOutCallback(e)}})}_setupConnectedReshapeManager(){const{connectedReshapeProviders:e}=this;0!==e.length&&(this._connectedReshapeManager=new S({providerFactories:e,view:this.view}))}_onGraphicClickCallback(e){e.viewEvent.stopPropagation();const t=e.graphic;if(t===this.graphic)this.clearSelection(),this.emit("graphic-click",e),this.callbacks.onGraphicClick?.(e);else if(this._isMidpoint(t)){if(2===e.viewEvent.button)return;const i=this.graphic.clone(),s=this._createVertexFromMidpoint(t);this.refresh(),this._emitVertexAddEvent([t],i,s)}else if(this._isVertex(t))if(e.viewEvent.stopPropagation(),2===e.viewEvent.button)this._removeVertices(t);else{e.viewEvent.native.shiftKey||this._clearSelection(),this.selectedVertices.includes(t)?this._removeFromSelection(t,!0):this._addToSelection(t)}}_setUpOperation(e){const{graphic:t,dx:i,dy:s}=e,o=t===this.graphic;this._resetSnappingStateVars(),this._setUpGeometryHelper(),this._saveSnappingContextForHandle(t,e),this._activeOperationInfo={target:this.graphic,mover:t,operationType:o?"move":"reshape",totalDx:i,totalDy:s}}_onGraphicMoveStartCallback(e){const{dx:t,dy:i,graphic:s}=e,o=this._connectedReshapeManager,r=o?W(this.graphic):null;if(s===this.graphic){const{geometry:n}=s;return this._setUpOperation(e),this._emitMoveStartEvent(t,i),r&&o?.startFeatureMove([r]),void(null!=n&&"point"===n.type&&this._onHandleMove(s,t,i,e,()=>{this._updateTooltip(this.graphic,e.viewEvent),this._emitMoveEvent(t,i)}))}const{selectedVertices:n}=this;if(!n.includes(s)){if(this._clearSelection(),this._isMidpoint(s)){const e=this.graphic.clone(),t=this._createVertexFromMidpoint(s);this._emitVertexAddEvent([s],e,t)}this._addToSelection(s)}this._setUpOperation(e),r&&o?.startVertexMove(r,$(n)),this._emitReshapeStartEvent(s),this._onHandleMove(s,t,i,e,()=>{this._updateTooltip(s,e.viewEvent),this._emitReshapeEvent(s)})}_onGraphicMoveCallback(e){const t=this._activeOperationInfo;if(!t)return;const{dx:i,dy:s,graphic:o}=e;t.totalDx+=i,t.totalDy+=s;const{operationType:r}=t,{geometry:n}=o;if(null!=n)if("move"!==r)this._onHandleMove(o,i,s,e,()=>{this._updateTooltip(o,e.viewEvent),this._emitReshapeEvent(o)});else if("point"===n.type)this._onHandleMove(o,i,s,e,()=>{this._updateTooltip(this.graphic,e.viewEvent),this._emitMoveEvent(i,s)});else if("polyline"===n.type||"polygon"===n.type){const t=B(n);this._updateVertexGraphicLocations(t);const{dxMap:o,dyMap:r}=w(i,s,this.view);this._connectedReshapeManager?.translate(o,r,0),this._updateTooltip(this.graphic,e.viewEvent),this._emitMoveEvent(i,s)}}_onGraphicMoveStopCallback(e){const t=this._activeOperationInfo;if(!t)return;const{dx:i,dy:s,graphic:o}=e,{operationType:r}=t;t.totalDx+=i,t.totalDy+=s,this._onHandleMove(o,i,s,e,()=>"move"===r?this._emitMoveStopEvent():this._emitReshapeStopEvent(o)),this._isMidpoint(o)?this.refresh():(this._updateTooltip(this._isVertex(o)?o:null),this._resetSnappingStateVars(),this._connectedReshapeManager?.finish(),this._activeOperationInfo=null)}_updateVertexGraphicLocations(e){const{_coordinateHelper:t}=this;for(const i of this.vertexGraphics){const{pathIndex:s,pointIndex:o}=i.attributes;i.geometry=t.arrayToPoint(e[s][o])}this._updateMidpointGraphicLocations(e)}_updateMidpointGraphicLocations(e){for(const t of this.midpointGraphics){const{pathIndex:i,pointIndexStart:s,pointIndexEnd:o}=t.attributes,r=e[i];t.geometry=this._getMidpoint(r[s],r[o])}}_getMidpoint(e,t){const{_coordinateHelper:i}=this,s=i.arrayToVector(e),o=i.arrayToVector(t),r=i.toXYZ(s),n=i.toXYZ(o),[a,h,p]=f(r,n),c=i.hasM()?0:void 0;return new g({x:a,y:h,z:p,m:c,spatialReference:i.spatialReference})}_getVertexFromEditGeometry(e){const[t,i]=J(e);return h(this._editGeometryOperations),this._editGeometryOperations.data.parts[t].vertices[i]}_onHandleMove(e,t,s,o,r){p(this._snappingTask);const n=this._snappingContext;if(!n)return;const a=e.geometry,h="graphic-move-stop"===o.type;if(a&&G(a))if(null!=this.snappingManager&&this.selectedVertices.length<2&&!h){const o=this.snappingManager;this._stagedVertex=o.update({point:a,context:n}),this._syncGeometryAfterVertexMove(e,new g(this._stagedVertex),t,s,h),r(),this._snappingTask=i(async i=>{const p=await o.snap({point:a,context:n,signal:i});p.valid&&(this._stagedVertex=p.apply(),this._syncGeometryAfterVertexMove(e,new g(this._stagedVertex),t,s,h),r())})}else{const i=null!=this._stagedVertex?new g(this._stagedVertex):a;this._syncGeometryAfterVertexMove(e,i,t,s,h),r()}}_syncGeometryAfterVertexMove(e,t,i,s,o=!1){const r=this._editGeometryOperations?.data.geometry;if(r)if("point"===r.type)e.geometry=t;else if("mesh"===r.type)e.geometry=r.centerAt(t);else{const{_coordinateHelper:n}=this,[a,h]=J(e);let p=x(r);const c=p[a].length-1,l=n.pointToArray(t);if(p[a][h]=l,"polygon"===r.type&&(0===h?p[a][c]=l:h===c&&(p[a][0]=l)),this._isVertex(e)&&(p=this._moveRelatedCoordinates(p,e,l),p=this._moveSelectedHandleCoordinates(p,e,i,s,"polygon"===r.type),this._updateMidpointGraphicLocations(p)),"multipoint"===r.type&&r.points)for(let e=0;e<p.length;e++)r.points[e]=p[e][0];this._updateGraphicGeometry(r.clone());const d=n.pointToVector(t),m=this._getVertexFromEditGeometry(e),v=n.getZ(d),y=d[0]-m.pos[0],_=d[1]-m.pos[1],g=null!=v?v-m.pos[2]:0;this._editGeometryOperations?.moveVertices([m],y,_,g),this._connectedReshapeManager?.translate(y,_,g),o&&(this._mover?this._mover.updateGeometry(this._mover.graphics.indexOf(e),t):e.geometry=t)}}_moveRelatedCoordinates(e,t,i){const{relatedGraphicIndices:s}=t.attributes;for(const o of s){const s=this.vertexGraphics.at(o),{pathIndex:r,pointIndex:n}=s.attributes;e[r][n]=i,s.geometry=t.geometry}return e}_moveSelectedHandleCoordinates(e,t,i,s,o){for(const r of this.selectedVertices)if(r!==t){const{pathIndex:t,pointIndex:n,relatedGraphicIndices:a}=r.attributes,h=E(r.geometry,i,s,this.view),p=x(h),c=e[t].length-1;e[t][n]=p,r.geometry=h,o&&(0===n?e[t][c]=p:n===c&&(e[t][0]=p));for(const i of a){const t=this.vertexGraphics.at(i),{pathIndex:s,pointIndex:o}=t.attributes;e[s][o]=p,t.geometry=h}}return e}_onGraphicPointerOverCallback(e){const t=e.graphic;this._hoverGraphic=t;const i=this._isVertex(t);i&&!this._isSelected(t)&&(t.symbol=this.symbols.vertices.hover),this._updateTooltip(i?t:null),this._updateHoverCursor(t)}_onGraphicPointerOutCallback(e){const t=e.graphic;this._hoverGraphic=null,this._isVertex(t)&&!this._isSelected(t)&&(t.symbol=this.symbols.vertices.default),this.removeHandles(q),this._updateTooltip()}_createVertexFromMidpoint(e){const{_graphicAttributes:t,graphic:i}=this,s=i.geometry;if(null==s||"polygon"!==s.type&&"polyline"!==s.type)return[];const o=s.clone(),r=[],{pathIndex:n,pointIndexStart:a,pointIndexEnd:h}=e.attributes,p=x(e.geometry),c=0===h?a+1:h,l=x(o);return l[n].splice(c,0,p),e.attributes={...t,pathIndex:n,pointIndex:c,relatedGraphicIndices:[]},r.push({coordinates:l[n][c],componentIndex:n,vertexIndex:c}),this._updateGraphicGeometry(o),r}_addToSelection(e){const t=Q(e);for(const i of t)i.symbol=this.symbols.vertices.selected,this.selectedVertices.add(i),this._updateTooltip(i);this._emitSelectEvent(t)}_removeFromSelection(e,t){const{vertices:i}=this.symbols,s=t?i.hover:i.default;this.selectedVertices.remove(e),e.symbol=s,this._emitDeselectEvent([e]),this._updateTooltip()}_clearSelection(){const e=this.selectedVertices.toArray();if(e.length>0){for(const t of e)t.set("symbol",this.symbols.vertices.default);this.selectedVertices.removeAll(),this._emitDeselectEvent(e),this._updateTooltip()}}_keyDownHandler(e){null==this._activeOperationInfo&&Z(e,this.tooltip)||z.delete.includes(e.key)&&!e.repeat&&this.selectedVertices.length&&this._removeVertices(this.selectedVertices)}_removeVertices(e){const t=this.graphic.geometry,i=this.vertexGraphics.length;if(null==t||"polygon"!==t.type&&"polyline"!==t.type&&"multipoint"!==t.type)return;if("polygon"===t.type&&i<4||"multipoint"===t.type&&i<2||"polyline"===t.type&&i<3)return;const s=this.graphic.clone(),o=t.clone();let r=x(o);const n=[],a=Q(e);for(const h of a){const{x:e,y:t}=h.geometry;for(let i=0;i<r.length;i++){const s=r[i];for(let o=0;o<s.length;o++){const[a,h]=s[o];e===a&&t===h&&(n.push({coordinates:r[i][o],componentIndex:i,vertexIndex:o}),r[i].splice(Number(o),1))}}}if("polygon"===o.type)r=r.filter(e=>{if(e.length<2)return!1;const[t,i]=e[0],[s,o]=e[e.length-1];return(2!==e.length||t!==s||i!==o)&&(t===s&&i===o||e.push(e[0]),!0)}),o.rings=r;else if("polyline"===o.type){for(const e of r)1===e.length&&r.splice(r.indexOf(e),1);o.paths=r}else o.points=r.flat();this._updateGraphicGeometry(o),this.refresh(),this._emitVertexRemoveEvent(a,s,n)}_isVertex(e){return this.vertexGraphics.includes(e)}_isSelected(e){return this._isVertex(e)&&this.selectedVertices.includes(e)}_isMidpoint(e){return this.midpointGraphics.includes(e)}_updateHoverCursor(e){const t=this._isMidpoint(e)?"copy":"move";this.addHandles(this.view.acquireCursor(t,"high"),q)}_updateTooltip(e,t){let i=null;const{graphic:s,view:o,tooltipInfos:r}=this,n=s?.geometry;"point"===n?.type?i=r.movePoint:this._selectedVertex?i=r.selectedVertex:e===this.graphic?(i=r.translateGraphic,R(i,o,this._tooltipsContext,t)):e&&this.selectedVertices.length>1&&(i=r.translateVertices,j(i,o,n,this._tooltipsContext,t)),this.activeTooltipInfo=i}_updateGraphicGeometry(e){this._updateHandlesOnExternalGeometryChange?.pause(),this.graphic.geometry=e,this._updateHandlesOnExternalGeometryChange?.resume()}_emitMoveStartEvent(e,t){const i={type:"move-start",mover:this.graphic,dx:e,dy:t};this.emit("move-start",i),this.callbacks.onMoveStart?.(i)}_emitMoveEvent(e,t){const i={type:"move",mover:this.graphic,dx:e,dy:t};this.emit("move",i),this.callbacks.onMove?.(i)}_emitMoveStopEvent(e,t){if(null==e||null==t){const i=this._activeOperationInfo;if(!i)return;e=i.totalDx,t=i.totalDy}const i={type:"move-stop",mover:this.graphic,dx:e,dy:t};this.emit("move-stop",i),this.callbacks.onMoveStop?.(i)}_emitReshapeStartEvent(e){const t={type:"reshape-start",graphic:this.graphic,mover:e,selected:this.selectedVertices.toArray()};this.emit("reshape-start",t),this.callbacks.onReshapeStart?.(t)}_emitReshapeEvent(e){const t={type:"reshape",graphic:this.graphic,mover:e,selected:this.selectedVertices.toArray()};this.emit("reshape",t),this.callbacks.onReshape?.(t)}_emitReshapeStopEvent(e){const t={type:"reshape-stop",graphic:this.graphic,mover:e,selected:this.selectedVertices.toArray()};this.emit("reshape-stop",t),this.callbacks.onReshapeStop?.(t)}_emitSelectEvent(e){const t={type:"vertex-select",added:e};this.emit("select",t),this.callbacks.onVertexSelect?.(t)}_emitDeselectEvent(e){const t={type:"vertex-deselect",removed:e};this.emit("deselect",t),this.callbacks.onVertexDeselect?.(t)}_emitVertexAddEvent(e,t,i){const s={type:"vertex-add",added:e,graphic:this.graphic,oldGraphic:t,vertices:i};this.emit("vertex-add",s),this.callbacks.onVertexAdd?.(s)}_emitVertexRemoveEvent(e,t,i){const s={type:"vertex-remove",removed:e,graphic:this.graphic,oldGraphic:t,vertices:i};this.emit("vertex-remove",s),this.callbacks.onVertexRemove?.(s)}_logGeometryTypeError(){n.getLogger(this).error(new o("reshape:invalid-geometry","Reshape operation not supported for the provided graphic. The geometry type is not supported."))}};function B(e){const t=x(e.clone());if("polygon"===e.type)for(const i of t){const e=i[i.length-1];i[0][0]===e[0]&&i[0][1]===e[1]&&i.length>2&&i.pop()}return t}function J({attributes:e}){return[e?.pathIndex||0,e?.pointIndex||0]}function Q(e){return e instanceof t?[e]:[...e]}function W(e){const t=e.sourceLayer??e.layer;return k(t)?{graphic:e,layer:t}:null}function $(e){return e.toArray().map(e=>({pathIndex:e.attributes.pathIndex,vertexIndex:e.attributes.pointIndex}))}e([y()],K.prototype,"_activeOperationInfo",void 0),e([y()],K.prototype,"_connectedReshapeManager",void 0),e([y()],K.prototype,"_coordinateHelper",null),e([y()],K.prototype,"_editGeometryOperations",void 0),e([y()],K.prototype,"tooltip",void 0),e([y()],K.prototype,"tooltipInfos",void 0),e([y()],K.prototype,"activeTooltipInfo",void 0),e([y({constructOnly:!0})],K.prototype,"automaticAreaMeasurementUtils",void 0),e([y({constructOnly:!0})],K.prototype,"automaticLengthMeasurementUtils",void 0),e([y()],K.prototype,"_selectedVertex",null),e([y()],K.prototype,"_tooltipsContext",null),e([y()],K.prototype,"callbacks",void 0),e([y()],K.prototype,"connectedReshapeProviders",void 0),e([y()],K.prototype,"enableMidpoints",void 0),e([y()],K.prototype,"enableMovement",void 0),e([y()],K.prototype,"enableVertices",void 0),e([y()],K.prototype,"graphic",void 0),e([y()],K.prototype,"highlightName",void 0),e([y()],K.prototype,"highlightsEnabled",void 0),e([y()],K.prototype,"layer",void 0),e([y({readOnly:!0})],K.prototype,"midpointGraphics",void 0),e([y()],K.prototype,"midpointSymbol",void 0),e([y({readOnly:!0})],K.prototype,"selectedVertices",void 0),e([y()],K.prototype,"snappingManager",void 0),e([y({readOnly:!0})],K.prototype,"state",null),e([y()],K.prototype,"symbols",void 0),e([y({type:F})],K.prototype,"sketchOptions",void 0),e([y({readOnly:!0})],K.prototype,"type",void 0),e([y({readOnly:!0})],K.prototype,"vertexGraphics",void 0),e([y()],K.prototype,"view",void 0),K=e([_("esri.views.draw.support.Reshape")],K);const ee=K;export{ee as default};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{__decorate as e}from"tslib";import{unique as t,isSome as i}from"../../core/arrayUtils.js";import{createTask as a}from"../../core/asyncUtils.js";import r from"../../core/Collection.js";import{deprecatedFunction as o}from"../../core/deprecate.js";import s from"../../core/Error.js";import{EventedAccessor as n}from"../../core/Evented.js";import{makeHandle as l}from"../../core/handleUtils.js";import d from"../../core/Logger.js";import{destroyMaybe as p,abortMaybe as c,removeMaybe as u}from"../../core/maybe.js";import{throwIfAborted as h,createResolver as w}from"../../core/promiseUtils.js";import{watch as f,on as m,when as y,syncAndInitial as g,initial as k,sync as v,whenOnce as _}from"../../core/reactiveUtils.js";import{property as M}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import{subclass as W}from"../../core/accessorSupport/decorators/subclass.js";import{UpdatingHandles as F}from"../../core/support/UpdatingHandles.js";import{getTemplatesForLayers as b}from"../../editing/templateUtils.js";import E from"../../layers/GraphicsLayer.js";import{isEditableLayer as T}from"../../layers/support/editableLayers.js";import{isFeatureLayer as V,isSubtypeGroupLayer as S,getOwningPortalUrl as L}from"../../layers/support/layerUtils.js";import{parseKnownArcGISOnlineDomain as I}from"../../portal/support/urlUtils.js";import A from"../../views/SelectionManager.js";import U from"../../views/interactive/sketch/SketchOptions.js";import{SnappingManager as C}from"../../views/interactive/snapping/SnappingManager.js";import O from"../../views/interactive/snapping/SnappingOptions.js";import{isSelectableLayer as j}from"../../views/support/selectionUtils.js";import P from"../Attachments/AttachmentsViewModel.js";import R from"./CreateFeaturesWorkflow.js";import H from"./UpdateFeaturesWorkflow.js";import q from"./UpdateWorkflow.js";import{getLayersFromWorkflow as G,isCreateFeaturesWorkflow as x,isUpdateRecordWorkflow as D,isUpdateFeaturesWorkflow as B,isUpdateWorkflow as N,makeMultipleSourceLayersError as Q,whenEditorLayerView as z}from"./workflowUtils.js";import Z from"./support/EditorItem.js";import{makeTemplateGroupInfoForLayer as $}from"../FeatureTemplates/featureTemplatesUtils.js";import J from"../FeatureTemplates/FeatureTemplatesViewModel.js";import K from"../Sketch/SketchViewModel.js";import X from"../Spinner/SpinnerViewModel.js";import{goTo as Y}from"../support/goToUtils.js";import{isFeatureItem as ee,isLayerItem as te}from"../support/SelectionList/selectionListUtils.js";import ie from"../support/SelectionList/SelectionListViewModel.js";import ae from"../support/SelectionToolbar/SelectionToolbarViewModel.js";function re(e,t){return e?.find(e=>e.layer===t)}let oe=class extends n{constructor(e){super(e),this._queuedSelectionTool=null,this._sketchEventListenerHandle=null,this._sketchGraphicsLayer=new E({listMode:"hide",internal:!0,title:"Editor sketch layer"}),this._snappingManager=null,this._templatesByLayer=new Map,this._updateItemsTask=null,this._updateTemplatesTask=null,this._updatingHandles=new F,this._featureTemplatesViewModelIsRestricted=!1,this.activeWorkflow=null,this._activityQueue=new r,this.editorItems=new r,this.failures=[],this.hideTemplatesForInactiveLayers=!1,this.attachmentsViewModel=new P({capabilities:{editing:!0}}),this.featureTemplatesViewModel=new J({disabledItemFunction:({layer:e})=>this._itemIsSuspended(e)}),this.layerInfos=null,this.ownSketchViewModel=new K({layer:this._sketchGraphicsLayer}),this.selectionListViewModel=new ie,this.selectionManager=new A,this.selectionToolbarViewModel=new ae({continuousSelectionEnabled:!0,defaultOperationType:"replace",persistSelection:!1,returnGeometry:!1}),this.sketchOptions=new U,this.snappingOptions=new O({attributeRulesEnabled:!0}),this.spinnerViewModel=new X,this.pageStack=[],this.showDiscardEditsPrompt=()=>Promise.resolve(!0),this._candidateCommitted=!1,this.back=async()=>{if("viewing-selection-list"===this.state)return this.selectionListViewModel.filterText=void 0,void this.effectiveSelectionManager.clear();this.canGoBack&&(this.activeWorkflow?.hasPreviousStep?await this.activeWorkflow.back(this.showDiscardEditsPrompt):await this._cancelWorkflow({force:!this.hasPendingEdits}))},this.saveWorkflow=async()=>await(this.activeWorkflow?.save()),this.selectFeature=(e,t=!1)=>{const i=this.activeWorkflow;this._candidateCommitted||"update"!==i?.type||(i.data.rootFeature=e,t&&(i.next(),this._candidateCommitted=!0))}}initialize(){this.addHandles([f(()=>{const e=this.view,t=e?.map?.editableLayers.toArray(),i=e?.allLayerViews,a=i?.filter(e=>!!t?.includes(e.layer));return[t,a,this.layerInfos]},()=>this._updateEditorItems(),g),f(()=>this.hideTemplatesForInactiveLayers,()=>this.syncFeatureTemplates()),f(()=>this._selectionSources,()=>this._syncSelectionSources(),k),m(()=>this.activeWorkflow,"cancel",()=>this.emit("workflow-cancel")),m(()=>this.activeWorkflow,"commit",()=>this.emit("workflow-commit")),m(()=>this.activeWorkflow,"complete",()=>{this.emit("workflow-commit"),this._set("activeWorkflow",null)}),y(()=>!this.activeWorkflow&&this._queuedSelectionTool,()=>this._queuedSelectionTool&&this.selectionToolbarViewModel.activateTool(this._queuedSelectionTool)),f(()=>this.activeWorkflow,e=>this.selectionManager.showHighlight=!e),y(()=>this.view?.map,e=>e.add(this._sketchGraphicsLayer),k),m(()=>this.editorItems,"change",()=>this._afterEditorItemsChange()),f(()=>[this.canCreate,this.canUpdateVisible],()=>this._afterEditorItemsChange()),f(()=>this.page,(e,t)=>{const i=[...this.pageStack];if(-1===i.indexOf(e))i.push(e);else for(;i.length&&i.at(-1)!==e;)i.pop();this.pageStack=i},g),y(()=>"awaiting-update-feature-candidate"===this.state,()=>this._candidateCommitted=!1),m(()=>this.featureTemplatesViewModel,"select",async({item:e,oldItem:t})=>{const{activeWorkflow:i}=this;if(i){if("update"===i.type&&"awaiting-feature-creation-info"===i.activeWorkflow?.stepId)return;try{await this.cancelWorkflow({force:!this.hasPendingEdits})}catch{return void this.featureTemplatesViewModel.select(t,{emit:!1})}}if(!e)return;const a={layer:e.layer,template:e.template};if(e.supportsUpload)return this.featureTemplatesViewModel.select(t,{emit:!1}),this.startCreateFeaturesWorkflow(a);await this.startCreateFeaturesWorkflowAtFeatureCreation(a)}),f(()=>[this.view,this.featureTemplatesViewModel],([e,t])=>{t.view=e},g),m(()=>this.view,"key-down",e=>{"Escape"===e.key&&this.activeWorkflow?.keyboardCancellationEnabled&&(e.stopPropagation(),this.back())}),m(()=>this.sketchViewModel,["create","delete","update"],e=>{const{activeWorkflow:t}=this,i="update"===t?.type,a=G(t),r=i?t?.activeWorkflow?.parentLayer??void 0:void 0,o=`sketch-${e.type}`;this.emit(o,{type:o,detail:e,layer:a[0],layers:a,parentLayer:r})},v),f(()=>this.view,e=>{if(this._snappingManager=p(this._snappingManager),!e)return;const t=this.snappingOptions;this._snappingManager=new C({view:e,options:t}),this.ownSketchViewModel.snappingManager=this._snappingManager},g),f(()=>this.snappingOptions,e=>{this._snappingManager&&(this._snappingManager.options=e)},g),m(()=>this.selectionToolbarViewModel,"complete",e=>this._onSelectionComplete(e)),f(()=>({view:this.view,selectionManager:this.effectiveSelectionManager,selectionListViewModel:this.selectionListViewModel,selectionToolbarViewModel:this.selectionToolbarViewModel}),({view:e,selectionManager:t,selectionListViewModel:i,selectionToolbarViewModel:a})=>{t.view=e,i.view=e,a.view=e},g),f(()=>this.effectiveSelectionManager,e=>{this.selectionListViewModel.selectionManager=e,this.selectionToolbarViewModel.selectionManager=e},g)])}destroy(){this._cancelWorkflow({warnIfNoWorkflow:!1}).then(()=>{this.view?.map?.remove(this._sketchGraphicsLayer),this.view=null}),this._updateItemsTask=c(this._updateItemsTask),this._updatingHandles.destroy(),this._sketchEventListenerHandle=u(this._sketchEventListenerHandle),this.selectionListViewModel?.destroy(),this.selectionToolbarViewModel?.destroy(),this.selectionManager.destroy()}get _featureTemplatesLayersAndTables(){const e=new r;for(const t of this.editorItems){const i=this.hideTemplatesForInactiveLayers&&!t.visible;t.supportsCreateFeaturesWorkflow&&!i&&e.push(t.layer)}return e}get _selectionSources(){const e=new r;for(const t of this.editorItems)j(t.layer)&&t.supportsUpdateWorkflow&&t.visible&&e.push(t.layer);return e}get activeFeatureCount(){const e=this.activeLeafWorkflow;return x(e)?e.pendingFeatures.length:D(e)&&e.data.edits.feature?1:B(e)?e.data.features.length:0}get activeLeafWorkflow(){const e=this.activeWorkflow;return e&&N(e)?e.activeWorkflow??e:e}get canCreate(){return this.editorItems.some(e=>e.supportsCreateFeaturesWorkflow)}get canCreateVisible(){return!!this.featureTemplatesLayers.length}get canUpdate(){return this.editorItems.some(e=>e.supportsUpdateWorkflow)}get canUpdateVisible(){return this.editorItems.some(e=>e.supportsUpdateWorkflow&&e.visible)}get featureTemplatesLayers(){return this._featureTemplatesLayersAndTables.filter(e=>"scene"===e.type||!e.isTable)}get effectiveSelectionManager(){return this.selectionManager}get featureFormViewModel(){const{activeWorkflow:e}=this;return"update"===e?.type?e.activeFeatureFormViewModel:"create-features"===e?.type?e.featureFormViewModel:null}get formViewModel(){const{activeWorkflow:e}=this;return"update"===e?.type?e.activeFeatureFormViewModel:"create-features"===e?.type?e.featureFormViewModel:"update-features"===e?.type?e.formViewModel:null}get utilityNetworkAssociationAddAssociationViewModel(){const{activeWorkflow:e}=this;return"update"===e?.type?e.activeUtilityNetworkAssociationAddAssociationViewModel:null}get labelOptions(){return this.sketchOptions.labels}set labelOptions(e){this.sketchOptions.labels=e}get sketchViewModel(){const{activeWorkflow:e}=this;return"update"===e?.type?e.activeSketchViewModel:"create-features"===e?.type||"update-features"===e?.type?e.sketchViewModel:this.ownSketchViewModel}get state(){if(!this.view?.ready)return"disabled";const e=this.attachmentsViewModel.mode;if("add"===e)return"adding-attachment";if("edit"===e)return"editing-attachment";const{activeWorkflow:t}=this,i=!t?.stepId;return this.effectiveSelectionManager.count&&i?"viewing-selection-list":i?"ready":"update"===t.type&&t.activeWorkflow?.stepId?t.activeWorkflow.stepId:t.stepId}get syncing(){return this._activityQueue.length>0}get updating(){return this._updatingHandles.updating||!0===this.activeWorkflow?.updating}get tooltipOptions(){return this.sketchOptions.tooltips}set tooltipOptions(e){this.sketchOptions.tooltips=e}get valueOptions(){return this.sketchOptions.values}set valueOptions(e){this.sketchOptions.values=e}set view(e){this.ownSketchViewModel.view=e,this.spinnerViewModel.view=e,this._set("view",e)}get canZoomTo(){const e=this.sketchViewModel,t=e?.createGraphic?.geometry?.type;return!(!e?.updateGraphics?.length&&"multipoint"!==t)}get page(){const{activeWorkflow:e,state:t}=this;if("update"===e?.type&&null!=e?.activeWorkflow?.featureFormViewModel?.associatedLayer)return"viewing-associated-features";if("update"===e?.type&&null!=e?.activeWorkflow?.featureFormViewModel?.associationId)return"viewing-associated-layers";if("update"===e?.type&&"awaiting-feature-to-update"===e.stepId)return"ready";if("create-features"===e?.type&&0===e.numPendingFeatures){const t=e.data.upload;if(t)return"default"===t.state?"ready":"creating-features-upload-details"}return t??"disabled"}get featureFormDisabled(){const{activeLeafWorkflow:e}=this;if(D(e))return!1===e.data.editorItem?.capabilities.update.attributes||!0===e.featureFormViewModel.disabled;if(B(e)){const{formViewModel:t}=e;return t.disabled||t.readOnly}return!1}get featureFormHasAssociation(){return!!this.featureFormViewModel?.activeAssociation}get canGoBack(){return null!=this.activeWorkflow&&!this.syncing}get shouldShowDeleteButton(){const{activeLeafWorkflow:e}=this;if(D(e)){const{data:t}=e;return t.editorItem?.capabilities.delete.enabled&&!t.readOnly}return!!B(e)&&e.data.editorItems.every(e=>e.capabilities.delete.enabled)}get hasPendingEdits(){return this.activeWorkflow?.hasPendingEdits??!1}get snappingManager(){return this._snappingManager}getTemplatesForLayer(e){return this._templatesByLayer.get(e)??[]}async startCreateFeaturesWorkflowAtFeatureTypeSelection(){return this.startCreateFeaturesWorkflow()}async startCreateFeaturesWorkflowAtFeatureCreation(e){return this.startCreateFeaturesWorkflow(e,"creating-features")}async startCreateFeaturesWorkflow(e,t="awaiting-feature-creation-info"){if(await _(()=>!this.updating),!this.canCreate)throw new s("editing:unsupported-workflow","Creating features is unsupported or disabled.");const i=this._createUpdatingResolver();try{await this._cancelWorkflow();const i=this._createCreateFeaturesWorkflow(e,t);this._set("activeWorkflow",i),await i.start()}catch(a){this._logErrorAndCancelWorkflow(a)}finally{i.resolve()}}async startCreateFeaturesWorkflowAtFeatureEdit(e){await _(()=>!this.updating);const t=this._createUpdatingResolver();try{const{initialFeature:t}=e,i=t.sourceLayer=t.layer,a=i?this.findEditorItemForLayer(i):void 0;if(!a?.supportsCreateFeaturesWorkflow)throw new s("editing:unsupported-workflow","Creating features is unsupported or disabled for this layer.");await this._cancelWorkflow();const r=this._createCreateFeaturesWorkflow({initialFeature:t,layer:a.layer,maxFeatures:1},"creating-features");this._set("activeWorkflow",r),await r.start()}catch(i){this._logErrorAndCancelWorkflow(i)}finally{t.resolve()}}async startUpdateFeaturesWorkflow(e){if(await _(()=>!this.updating),!this.canUpdate)return void this._logError("editing:unsupported-workflow","Update features workflow is unsupported or disabled.");if(t(e.map(e=>e.sourceLayer??e.layer)).length>1)throw Q();const i=this._createUpdatingResolver();try{await this._cancelWorkflow();const t=this._createUpdateFeaturesWorkflow(e);this._set("activeWorkflow",t),await t.start()}catch(a){this._logErrorAndCancelWorkflow(a)}finally{i.resolve()}}async startUpdateWorkflowAtFeatureSelection(){if(await _(()=>!this.updating),!this.canUpdate)return void this._logError("editing:unsupported-workflow","Update workflow is unsupported or disabled.");const e=this._createUpdatingResolver();try{await this._cancelWorkflow();const e=this._createUpdateWorkflow();this._set("activeWorkflow",e),await e.start()}catch(t){this._logErrorAndCancelWorkflow(t)}finally{e.resolve()}}async startUpdateWorkflowAtMultipleFeatureSelection(e){if(await _(()=>!this.updating),!this.canUpdate)return void this._logError("editing:unsupported-workflow","Update workflow is unsupported or disabled.");const t=this._createUpdatingResolver();try{await this._cancelWorkflow();const t=this._createUpdateWorkflow("awaiting-update-feature-candidate");t.data.candidates=e,this._set("activeWorkflow",t),await t.start()}catch(i){this._logErrorAndCancelWorkflow(i)}finally{t.resolve()}}async startUpdateWorkflowAtFeatureEdit(e){if(await _(()=>!this.updating),!this.canUpdate)return void this._logError("editing:unsupported-workflow","Update workflow is unsupported or disabled.");const t=this._createUpdatingResolver();try{await this._cancelWorkflow();const t=this._createUpdateWorkflow("editing-existing-feature");t.data.rootFeature=e,t.addHandles(m(()=>t,"commit",()=>{t.destroy(),this.activeWorkflow===t&&this._set("activeWorkflow",null)})),this._set("activeWorkflow",t),await t.start()}catch(i){this._logErrorAndCancelWorkflow(i)}finally{t.resolve()}}async startUpdateWorkflowWithActiveSelection(){const{selectionListViewModel:e}=this;if(!e.visibleFeatureCount)throw new s("editing:missing-selection","Unable to determine visible selection.");if(e.visibleLayerCount>1)throw new s("editing:features-different-layers","Cannot start workflow with features from different layers.");const t=e.visibleFeatureItems.map(e=>e.graphic);1===t.length?await this.startUpdateWorkflowAtFeatureEdit(t[0]):await this.startUpdateFeaturesWorkflow(t)}async deleteFeatureFromWorkflow(){o(d.getLogger(this),"EditorViewModel.deleteFeatureFromWorkflow is deprecated. Use EditorViewModel.deleteFeatures instead.",{version:"4.33",replacement:"EditorViewModel.deleteFeatures",warnOnce:!0}),await this.deleteFeatures()}async deleteFeatures(){const e=this.activeWorkflow;return N(e)?e.deleteActiveFeature():B(e)?e.deleteAndCommit():void this._logError("editing:unsupported-workflow","Deleting features requires an active update workflow.")}async deleteAssociationFromWorkflow(){const{activeWorkflow:e}=this;e&&"update"===e.type?await e.deleteActiveAssociation():this._logError("editing:unsupported-workflow","Deleting an association requires an active update workflow.")}async cancelWorkflow(e){return this._cancelWorkflow({warnIfNoWorkflow:!0,...e})}findEditorItemForLayer(e){return this.editorItems.find(t=>t.layer===e)}itemHasInvalidFormTemplate(e){return null!=e&&!0===this.findEditorItemForLayer(e.layer)?.hasInvalidFormTemplate}syncFeatureTemplates(){this._featureTemplatesViewModelIsRestricted||this._updateTemplates()}zoomTo(e){const{view:t,sketchViewModel:a}=this;if(!t)return;const r=e??a?.createGraphic;if(r)"mesh"===r.geometry?.type?Y(t,r.geometry):Y(t,r);else{const e=a?.updateGraphics?.toArray();"3d"===t.type&&e?.some(e=>"mesh"===e.geometry?.type)?Y(t,e.map(e=>e.geometry).filter(i)):e&&Y(t,e)}}async toggleUpdateWorkflow(){this.canUpdate&&(this.hasPendingEdits&&!await this.showDiscardEditsPrompt()||(this.activeWorkflow&&"awaiting-feature-to-update"===this.state?await this.cancelWorkflow({force:!0}):await this.startUpdateWorkflowAtFeatureSelection()))}async onSelectionListItemSelect(e){ee(e)&&await this.startUpdateWorkflowAtFeatureEdit(e.graphic)}async onSelectionListMenuItemSelect(e){if(ee(e))await this.startUpdateWorkflowAtFeatureEdit(e.graphic);else if(te(e)){const t=e.featureItems.filter(e=>e.visible).map(e=>e.graphic);1===t.length?await this.startUpdateWorkflowAtFeatureEdit(t[0]):await this.startUpdateFeaturesWorkflow(t)}}restrictFeatureTemplatesViewModelToLayer(e){return this._featureTemplatesViewModelIsRestricted=!0,this._setFeatureTemplatesViewModelLayers([e]),l(()=>{this._featureTemplatesViewModelIsRestricted=!1,this._setFeatureTemplatesViewModelLayers(this.featureTemplatesLayers)})}async _getEditorItemCandidates(e){const{view:t}=this;if(!t?.map)return[];const{map:i}=t,a=i.editableLayers.toArray(),r=i.allTables.toArray().filter(e=>V(e)||S(e));return await Promise.allSettled([...a.flatMap(e=>this._getLayerLoadPromise(e)),...r.flatMap(e=>this._getLayerLoadPromise(e))]),h(e),[...a.reverse(),...r.reverse()].filter(e=>T(e)&&("mesh"!==e.geometryType||"3d"===t.type)).flatMap(e=>"subtype-group"===e.type?e.sublayers.toArray():e)}_getLayerLoadPromise(e){return S(e)?e.loadAll():e.load()}_drainEditorItems(){this.editorItems.drain(e=>e.destroy())}_updateEditorItems(){c(this._updateItemsTask);const{view:e}=this,t=a(async t=>{if(!e?.map||!e?.allLayerViews)return;const i=await this._getEditorItemCandidates(t);if(!i.length)return void this._drainEditorItems();const a=[],r=[],o=[],{layerInfos:s}=this;for(const l of i){const t=re(s,l),i=await z(e,l).catch(()=>null);(t?a:i?r:o).push(new Z({layer:l,layerInfo:t,layerView:i}))}s?.length&&a.sort((e,t)=>s.findIndex(({layer:t})=>t===e.layer)-s.findIndex(({layer:e})=>e===t.layer));const n=[...a,...r,...o];t.aborted||(this._drainEditorItems(),this.editorItems.addMany(n))});this._updatingHandles.addPromise(t.promise),this._updateItemsTask=t}_updateTemplates(){c(this._updateTemplatesTask);const e=a(async e=>{const t=this._templatesByLayer,i=this._featureTemplatesLayersAndTables.filter(e=>!t.has(e));if(i.length>0){const a=await b(i.toArray(),this.view,e);for(const{layer:e,templates:i}of a)t.set(e,i)}this._setFeatureTemplatesViewModelLayers(this.featureTemplatesLayers)});this._updatingHandles.addPromise(e.promise),this._updateTemplatesTask=e}_setFeatureTemplatesViewModelLayers(e){const t=this._templatesByLayer,i=[];for(const a of e){const e=t.get(a);e&&e.length>0&&i.push($(a,e))}this.featureTemplatesViewModel.templateInfos=i}_afterEditorItemsChange(){const{activeWorkflow:e}=this;if(this.syncFeatureTemplates(),!e)return;const{stepId:t}=e;"create-features"!==e.type?"update"===e.type&&("awaiting-feature-to-update"===t&&!this.canUpdateVisible||"awaiting-update-feature-candidate"===t&&!e.hasUpdatableCandidates)&&this._cancelWorkflow():"awaiting-feature-creation-info"!==t||this.canCreate||this._cancelWorkflow()}async _cancelWorkflow(e){const t=this.activeWorkflow;if(!t)return void(e?.warnIfNoWorkflow&&this._logError("editing:no-active-workflow","There is no active workflow to cancel."));if(!e||!1!==e.force){this.emit("workflow-cancel"),this._set("activeWorkflow",null);try{await t.cancel(e)}finally{t.destroy()}}else try{await t.cancel(e),this._set("activeWorkflow",null),t.destroy()}catch(i){}}_createCreateFeaturesWorkflow(e,t){return R.create({viewModel:this,creationInfo:e,sketchOptions:this.sketchOptions,snappingManager:this._snappingManager,startAt:t,applyEditsCallback:(e,t,i)=>this._applyEdits(e,t,i),applyEditsFeatureServiceCallback:(e,t,i)=>this._applyEditsFeatureService(e,t,i),addAttachmentsCallback:(e,t)=>this._addAttachments(e,t)})}_createUpdateFeaturesWorkflow(e){const t=H.create({viewModel:this,sketchOptions:this.sketchOptions,snappingManager:this._snappingManager,features:e,applyEdits:(e,t,i)=>this._applyEdits(e,t,i),applyEditsFeatureService:(e,t,i)=>this._applyEditsFeatureService(e,t,i)});return t.addHandles(m(()=>t,"commit",()=>{t.destroy(),this.activeWorkflow===t&&this._set("activeWorkflow",null)})),t}_createUpdateWorkflow(e){return q.create({viewModel:this,sketchOptions:this.sketchOptions,snappingManager:this._snappingManager,startAt:e,applyEditsCallback:(e,t,i)=>this._applyEdits(e,t,i),applyEditsFeatureServiceCallback:(e,t,i)=>this._applyEditsFeatureService(e,t,i),addAttachmentsCallback:(e,t)=>this._addAttachments(e,t)})}_addAttachments(e,t){const i=t.map(t=>this._addAttachment(e,t.feature,t.attachment))??[];return Promise.all(i)}async _addAttachment(e,t,i){let a=null;if(!("addAttachment"in e)||null==e.capabilities?.attachment)throw new s("editor:attachments-not-supported","Adding attachments is not supported for this layer type");return await this._queueOperation(async()=>(a=await(e.addAttachment?.(t,i).catch(e=>{throw e?.error||e}))??null,a)),a}async _applyEdits(e,t,i){let a=null;const r=e.url?await L(e.url):null,o={returnServiceEditsOption:(!r||!I(r))&&!/\/hosted\//i.test(e.url)?"original-and-current-features":void 0,...i};return await this._queueOperation(async()=>{const{view:i}=this;if(!i)return null;const r=await z(i,e).catch(()=>null);return a=await e.applyEdits(t,o),r&&await _(()=>!r.updating),a}),a}async _applyEditsFeatureService(e,t,i){let a=null;return await this._queueOperation(async()=>a=await e.applyEdits(t,i)),a}_queueOperation(e){this._activityQueue.push(e);const t=(e,t)=>{const i=t.indexOf(e);i>-1&&t.splice(i,1)};return e().then(e=>(Array.isArray(e)?e.forEach(e=>this._handleEditsResultError(e)):this._handleEditsResultError(e),e)).catch(i=>{this._logError("editing:operation-error","An error occurred.",{error:i});const a={error:i,retry:()=>(t(a,this.failures),this._queueOperation(e)),cancel:()=>{t(a,this.failures)}};this._set("failures",[...this.failures,a])}).then(()=>{t(e,this._activityQueue)})}_handleEditsResultError(e){if(null!=e&&"error"in e&&null!=e.error)throw e.error;if(null!=e&&"addFeatureResults"in e){const{addFeatureResults:t,deleteFeatureResults:i,updateFeatureResults:a}=e,r=t.find(e=>!!e.error)||a.find(e=>!!e.error)||i.find(e=>!!e.error);if(r)throw r.error}}_createUpdatingResolver(){const e=w();return this._updatingHandles.addPromise(e.promise),e}_logErrorAndCancelWorkflow(e){const{name:t,message:i,details:a}=e;this._logError(t??"editing:workflow-start-failed",i??void 0,a??e),this._cancelWorkflow({force:!0})}_itemIsSuspended(e){const t=this.findEditorItemForLayer(e);return null!=t&&(!t.visible||t.disabled)}_logError(e,t,i){d.getLogger(this).error(new s(e,t,i))}_syncSelectionSources(){this.selectionManager.sources.items=this._selectionSources.toArray()}async _onSelectionComplete(e){if(e.aborted)return;const{operationType:t,selection:i}=e,{effectiveSelectionManager:a}=this,r="ready"===this.state,o=1===i.length;if(this._queuedSelectionTool=void 0,r&&o&&(0===a.count&&"add"===t||"replace"===t))return this._queuedSelectionTool=e.toolName,this.startUpdateWorkflowAtFeatureEdit(i[0]);switch(t){case"remove":a.updateSelection({current:[],added:[],removed:i});break;case"replace":a.clear(),a.updateSelection({current:i,added:[],removed:[]});break;case"add":a.updateSelection({current:i,added:[],removed:[]})}}};e([M()],oe.prototype,"_featureTemplatesLayersAndTables",null),e([M()],oe.prototype,"_queuedSelectionTool",void 0),e([M()],oe.prototype,"_snappingManager",void 0),e([M()],oe.prototype,"_selectionSources",null),e([M()],oe.prototype,"activeFeatureCount",null),e([M({readOnly:!0})],oe.prototype,"activeWorkflow",void 0),e([M()],oe.prototype,"activeLeafWorkflow",null),e([M({readOnly:!0})],oe.prototype,"_activityQueue",void 0),e([M({readOnly:!0})],oe.prototype,"canCreate",null),e([M()],oe.prototype,"canCreateVisible",null),e([M({readOnly:!0})],oe.prototype,"canUpdate",null),e([M()],oe.prototype,"canUpdateVisible",null),e([M()],oe.prototype,"featureTemplatesLayers",null),e([M()],oe.prototype,"editorItems",void 0),e([M()],oe.prototype,"effectiveSelectionManager",null),e([M({readOnly:!0})],oe.prototype,"failures",void 0),e([M()],oe.prototype,"hideTemplatesForInactiveLayers",void 0),e([M({type:P})],oe.prototype,"attachmentsViewModel",void 0),e([M()],oe.prototype,"featureFormViewModel",null),e([M()],oe.prototype,"formViewModel",null),e([M()],oe.prototype,"utilityNetworkAssociationAddAssociationViewModel",null),e([M({type:J})],oe.prototype,"featureTemplatesViewModel",void 0),e([M()],oe.prototype,"labelOptions",null),e([M()],oe.prototype,"layerInfos",void 0),e([M()],oe.prototype,"ownSketchViewModel",void 0),e([M()],oe.prototype,"selectionListViewModel",void 0),e([M()],oe.prototype,"selectionManager",void 0),e([M()],oe.prototype,"selectionToolbarViewModel",void 0),e([M()],oe.prototype,"sketchOptions",void 0),e([M()],oe.prototype,"sketchViewModel",null),e([M({type:O,nonNullable:!0})],oe.prototype,"snappingOptions",void 0),e([M()],oe.prototype,"spinnerViewModel",void 0),e([M()],oe.prototype,"state",null),e([M({readOnly:!0})],oe.prototype,"syncing",null),e([M()],oe.prototype,"updating",null),e([M()],oe.prototype,"tooltipOptions",null),e([M()],oe.prototype,"valueOptions",null),e([M()],oe.prototype,"view",null),e([M()],oe.prototype,"canZoomTo",null),e([M()],oe.prototype,"pageStack",void 0),e([M()],oe.prototype,"showDiscardEditsPrompt",void 0),e([M()],oe.prototype,"_candidateCommitted",void 0),e([M()],oe.prototype,"page",null),e([M()],oe.prototype,"featureFormDisabled",null),e([M()],oe.prototype,"featureFormHasAssociation",null),e([M()],oe.prototype,"canGoBack",null),e([M()],oe.prototype,"shouldShowDeleteButton",null),e([M()],oe.prototype,"hasPendingEdits",null),e([M()],oe.prototype,"snappingManager",null),oe=e([W("esri.widgets.Editor.EditorViewModel")],oe);const se=oe;export{se as default};
|
|
5
|
+
import{__decorate as e}from"tslib";import{unique as t,isSome as i}from"../../core/arrayUtils.js";import{createTask as a}from"../../core/asyncUtils.js";import r from"../../core/Collection.js";import{deprecatedFunction as o}from"../../core/deprecate.js";import s from"../../core/Error.js";import{EventedAccessor as n}from"../../core/Evented.js";import{makeHandle as l}from"../../core/handleUtils.js";import d from"../../core/Logger.js";import{destroyMaybe as p,abortMaybe as c,removeMaybe as u}from"../../core/maybe.js";import{throwIfAborted as h,createResolver as w}from"../../core/promiseUtils.js";import{watch as f,on as m,when as y,syncAndInitial as g,initial as k,sync as v,whenOnce as _}from"../../core/reactiveUtils.js";import{property as M}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import{subclass as W}from"../../core/accessorSupport/decorators/subclass.js";import{UpdatingHandles as F}from"../../core/support/UpdatingHandles.js";import{getTemplatesForLayers as b}from"../../editing/templateUtils.js";import E from"../../layers/GraphicsLayer.js";import{isEditableLayer as T}from"../../layers/support/editableLayers.js";import{isFeatureLayer as V,isSubtypeGroupLayer as S,getOwningPortalUrl as L}from"../../layers/support/layerUtils.js";import{parseKnownArcGISOnlineDomain as I}from"../../portal/support/urlUtils.js";import A from"../../views/SelectionManager.js";import U from"../../views/interactive/sketch/SketchOptions.js";import{SnappingManager as C}from"../../views/interactive/snapping/SnappingManager.js";import O from"../../views/interactive/snapping/SnappingOptions.js";import{isSelectableLayer as j}from"../../views/support/selectionUtils.js";import P from"../Attachments/AttachmentsViewModel.js";import R from"./CreateFeaturesWorkflow.js";import H from"./UpdateFeaturesWorkflow.js";import q from"./UpdateWorkflow.js";import{getLayersFromWorkflow as G,isCreateFeaturesWorkflow as x,isUpdateRecordWorkflow as D,isUpdateFeaturesWorkflow as B,isUpdateWorkflow as N,makeMultipleSourceLayersError as Q,whenEditorLayerView as z}from"./workflowUtils.js";import Z from"./support/EditorItem.js";import{makeTemplateGroupInfoForLayer as $}from"../FeatureTemplates/featureTemplatesUtils.js";import J from"../FeatureTemplates/FeatureTemplatesViewModel.js";import K from"../Sketch/SketchViewModel.js";import X from"../Spinner/SpinnerViewModel.js";import{goTo as Y}from"../support/goToUtils.js";import{isFeatureItem as ee,isLayerItem as te}from"../support/SelectionList/selectionListUtils.js";import ie from"../support/SelectionList/SelectionListViewModel.js";import ae from"../support/SelectionToolbar/SelectionToolbarViewModel.js";function re(e,t){return e?.find(e=>e.layer===t)}let oe=class extends n{constructor(e){super(e),this._queuedSelectionTool=null,this._sketchEventListenerHandle=null,this._sketchGraphicsLayer=new E({listMode:"hide",internal:!0,title:"Editor sketch layer"}),this._snappingManager=null,this._templatesByLayer=new Map,this._updateItemsTask=null,this._updateTemplatesTask=null,this._updatingHandles=new F,this._featureTemplatesViewModelIsRestricted=!1,this.activeWorkflow=null,this._activityQueue=new r,this.editorItems=new r,this.failures=[],this.hideTemplatesForInactiveLayers=!1,this.attachmentsViewModel=new P({capabilities:{editing:!0}}),this.featureTemplatesViewModel=new J({disabledItemFunction:({layer:e})=>this._itemIsSuspended(e)}),this.layerInfos=null,this.ownSketchViewModel=new K({layer:this._sketchGraphicsLayer}),this.selectionListViewModel=new ie,this.selectionManager=new A,this.selectionToolbarViewModel=new ae({continuousSelectionEnabled:!0,defaultOperationType:"replace",persistSelection:!1,returnGeometry:!1}),this.sketchOptions=new U,this.snappingOptions=new O({attributeRulesEnabled:!0}),this.spinnerViewModel=new X,this.pageStack=[],this.showDiscardEditsPrompt=()=>Promise.resolve(!0),this._candidateCommitted=!1,this.back=async()=>{if("viewing-selection-list"===this.state)return this.selectionListViewModel.filterText=void 0,void this.effectiveSelectionManager.clear();this.canGoBack&&(this.activeWorkflow?.hasPreviousStep?await this.activeWorkflow.back(this.showDiscardEditsPrompt):await this._cancelWorkflow({force:!this.hasPendingEdits}))},this.saveWorkflow=async()=>await(this.activeWorkflow?.save()),this.selectFeature=(e,t=!1)=>{const i=this.activeWorkflow;this._candidateCommitted||"update"!==i?.type||(i.data.rootFeature=e,t&&(i.next(),this._candidateCommitted=!0))}}initialize(){this.addHandles([f(()=>{const e=this.view,t=e?.map?.editableLayers.toArray(),i=e?.allLayerViews,a=i?.filter(e=>!!t?.includes(e.layer));return[t,a,this.layerInfos]},()=>this._updateEditorItems(),g),f(()=>this.hideTemplatesForInactiveLayers,()=>this.syncFeatureTemplates()),f(()=>this._selectionSources,()=>this._syncSelectionSources(),k),m(()=>this.activeWorkflow,"cancel",()=>this.emit("workflow-cancel")),m(()=>this.activeWorkflow,"commit",()=>this.emit("workflow-commit")),m(()=>this.activeWorkflow,"complete",()=>{this.emit("workflow-commit"),this._set("activeWorkflow",null)}),y(()=>!this.activeWorkflow&&this._queuedSelectionTool,()=>this._queuedSelectionTool&&this.selectionToolbarViewModel.activateTool(this._queuedSelectionTool)),f(()=>this.activeWorkflow,e=>this.selectionManager.showHighlight=!e),y(()=>this.view?.map,e=>e.add(this._sketchGraphicsLayer),k),m(()=>this.editorItems,"change",()=>this._afterEditorItemsChange()),f(()=>[this.canCreate,this.canUpdateVisible],()=>this._afterEditorItemsChange()),f(()=>this.page,(e,t)=>{const i=[...this.pageStack];if(-1===i.indexOf(e))i.push(e);else for(;i.length&&i.at(-1)!==e;)i.pop();this.pageStack=i},g),y(()=>"awaiting-update-feature-candidate"===this.state,()=>this._candidateCommitted=!1),m(()=>this.featureTemplatesViewModel,"select",async({item:e,oldItem:t})=>{const{activeWorkflow:i}=this;if(i){if("update"===i.type&&"awaiting-feature-creation-info"===i.activeWorkflow?.stepId)return;try{await this.cancelWorkflow({force:!this.hasPendingEdits})}catch{return void this.featureTemplatesViewModel.select(t,{emit:!1})}}if(!e)return;const a={layer:e.layer,template:e.template};if(e.supportsUpload)return this.featureTemplatesViewModel.select(t,{emit:!1}),this.startCreateFeaturesWorkflow(a);await this.startCreateFeaturesWorkflowAtFeatureCreation(a)}),f(()=>[this.view,this.featureTemplatesViewModel],([e,t])=>{t.view=e},g),m(()=>this.view,"key-down",e=>{"Escape"===e.key&&this.activeWorkflow?.keyboardCancellationEnabled&&(e.stopPropagation(),this.back())}),m(()=>this.sketchViewModel,["create","delete","update"],e=>{const{activeWorkflow:t}=this,i="update"===t?.type,a=G(t),r=i?t?.activeWorkflow?.parentLayer??void 0:void 0,o=`sketch-${e.type}`;this.emit(o,{type:o,detail:e,layer:a[0],layers:a,parentLayer:r})},v),f(()=>this.view,e=>{if(this._snappingManager=p(this._snappingManager),!e)return;const t=this.snappingOptions;this._snappingManager=new C({view:e,options:t}),this.ownSketchViewModel.snappingManager=this._snappingManager},g),f(()=>this.snappingOptions,e=>{this._snappingManager&&(this._snappingManager.options=e)},g),m(()=>this.selectionToolbarViewModel,"complete",e=>this._onSelectionComplete(e)),f(()=>({view:this.view,selectionManager:this.effectiveSelectionManager,selectionListViewModel:this.selectionListViewModel,selectionToolbarViewModel:this.selectionToolbarViewModel}),({view:e,selectionManager:t,selectionListViewModel:i,selectionToolbarViewModel:a})=>{t.view=e,i.view=e,a.view=e},g),f(()=>this.effectiveSelectionManager,e=>{this.selectionListViewModel.selectionManager=e,this.selectionToolbarViewModel.selectionManager=e},g)])}destroy(){this._cancelWorkflow({warnIfNoWorkflow:!1}).then(()=>{this.view?.map?.remove(this._sketchGraphicsLayer),this.view=null}),this._updateItemsTask=c(this._updateItemsTask),this._updatingHandles.destroy(),this._sketchEventListenerHandle=u(this._sketchEventListenerHandle),this.selectionListViewModel?.destroy(),this.selectionToolbarViewModel?.destroy(),this.selectionManager.destroy()}get _featureTemplatesLayersAndTables(){const e=new r;for(const t of this.editorItems){const i=this.hideTemplatesForInactiveLayers&&!t.visible;t.supportsCreateFeaturesWorkflow&&!i&&e.push(t.layer)}return e}get _selectionSources(){const e=new r;for(const t of this.editorItems)j(t.layer)&&t.supportsUpdateWorkflow&&t.visible&&e.push(t.layer);return e}get activeFeatureCount(){const e=this.activeLeafWorkflow;return x(e)?e.pendingFeatures.length:D(e)&&e.data.edits.feature?1:B(e)?e.data.features.length:0}get activeLeafWorkflow(){const e=this.activeWorkflow;return e&&N(e)?e.activeWorkflow??e:e}get canCreate(){return this.editorItems.some(e=>e.supportsCreateFeaturesWorkflow)}get canCreateVisible(){return!!this.featureTemplatesLayers.length}get canUpdate(){return this.editorItems.some(e=>e.supportsUpdateWorkflow)}get canUpdateVisible(){return this.editorItems.some(e=>e.supportsUpdateWorkflow&&e.visible)}get featureTemplatesLayers(){return this._featureTemplatesLayersAndTables.filter(e=>"scene"===e.type||!e.isTable)}get effectiveSelectionManager(){return this.selectionManager}get featureFormViewModel(){const{activeWorkflow:e}=this;return"update"===e?.type?e.activeFeatureFormViewModel:"create-features"===e?.type?e.featureFormViewModel:null}get formViewModel(){const{activeWorkflow:e}=this;return"update"===e?.type?e.activeFeatureFormViewModel:"create-features"===e?.type?e.featureFormViewModel:"update-features"===e?.type?e.formViewModel:null}get utilityNetworkAssociationAddAssociationViewModel(){const{activeWorkflow:e}=this;return"update"===e?.type?e.activeUtilityNetworkAssociationAddAssociationViewModel:null}get labelOptions(){return this.sketchOptions.labels}set labelOptions(e){this.sketchOptions.labels=e}get sketchViewModel(){const{activeWorkflow:e}=this;return"update"===e?.type?e.activeSketchViewModel:"create-features"===e?.type||"update-features"===e?.type?e.sketchViewModel:this.ownSketchViewModel}get state(){if(!this.view?.ready)return"disabled";const e=this.attachmentsViewModel.mode;if("add"===e)return"adding-attachment";if("edit"===e)return"editing-attachment";const{activeWorkflow:t}=this,i=!t?.stepId;return this.effectiveSelectionManager.count&&i?"viewing-selection-list":i?"ready":"update"===t.type&&t.activeWorkflow?.stepId?t.activeWorkflow.stepId:t.stepId}get syncing(){return this._activityQueue.length>0}get updating(){return this._updatingHandles.updating||!0===this.activeWorkflow?.updating}get tooltipOptions(){return this.sketchOptions.tooltips}set tooltipOptions(e){this.sketchOptions.tooltips=e}get valueOptions(){return this.sketchOptions.values}set valueOptions(e){this.sketchOptions.values=e}set view(e){this.ownSketchViewModel.view=e,this.spinnerViewModel.view=e,this._set("view",e)}get canZoomTo(){const e=this.sketchViewModel,t=e?.createGraphic?.geometry?.type;return!(!e?.updateGraphics?.length&&"multipoint"!==t)}get page(){const{activeWorkflow:e,state:t}=this;if("update"===e?.type&&null!=e?.activeWorkflow?.featureFormViewModel?.associatedLayer)return"viewing-associated-features";if("update"===e?.type&&null!=e?.activeWorkflow?.featureFormViewModel?.associationId)return"viewing-associated-layers";if("update"===e?.type&&"awaiting-feature-to-update"===e.stepId)return"ready";if("create-features"===e?.type&&0===e.numPendingFeatures){const t=e.data.upload;if(t)return"default"===t.state?"ready":"creating-features-upload-details"}return t??"disabled"}get featureFormDisabled(){const{activeLeafWorkflow:e}=this;if(D(e))return!1===e.data.editorItem?.capabilities.update.attributes||!0===e.featureFormViewModel.disabled;if(B(e)){const{formViewModel:t}=e;return t.disabled||t.readOnly}return!1}get featureFormHasAssociation(){return!!this.featureFormViewModel?.activeAssociation}get canGoBack(){return null!=this.activeWorkflow&&!this.syncing}get shouldShowDeleteButton(){const{activeLeafWorkflow:e}=this;if(D(e)){const{data:t}=e;return t.editorItem?.capabilities.delete.enabled&&!t.readOnly}return!!B(e)&&e.data.editorItems.every(e=>e.capabilities.delete.enabled)}get hasPendingEdits(){return this.activeWorkflow?.hasPendingEdits??!1}get snappingManager(){return this._snappingManager}getTemplatesForLayer(e){return this._templatesByLayer.get(e)??[]}async startCreateFeaturesWorkflowAtFeatureTypeSelection(){return this.startCreateFeaturesWorkflow()}async startCreateFeaturesWorkflowAtFeatureCreation(e){return this.startCreateFeaturesWorkflow(e,"creating-features")}async startCreateFeaturesWorkflow(e,t="awaiting-feature-creation-info"){if(await _(()=>!this.updating),!this.canCreate)throw new s("editing:unsupported-workflow","Creating features is unsupported or disabled.");const i=this._createUpdatingResolver();try{await this._cancelWorkflow();const i=this._createCreateFeaturesWorkflow(e,t);this._set("activeWorkflow",i),await i.start()}catch(a){this._logErrorAndCancelWorkflow(a)}finally{i.resolve()}}async startCreateFeaturesWorkflowAtFeatureEdit(e){await _(()=>!this.updating);const t=this._createUpdatingResolver();try{const{initialFeature:t}=e,i=t.sourceLayer=t.layer,a=i?this.findEditorItemForLayer(i):void 0;if(!a?.supportsCreateFeaturesWorkflow)throw new s("editing:unsupported-workflow","Creating features is unsupported or disabled for this layer.");await this._cancelWorkflow();const r=this._createCreateFeaturesWorkflow({initialFeature:t,layer:a.layer,maxFeatures:1},"creating-features");this._set("activeWorkflow",r),await r.start()}catch(i){this._logErrorAndCancelWorkflow(i)}finally{t.resolve()}}async startUpdateFeaturesWorkflow(e){if(await _(()=>!this.updating),!this.canUpdate)return void this._logError("editing:unsupported-workflow","Update features workflow is unsupported or disabled.");if(t(e.map(e=>e.sourceLayer??e.layer)).length>1)throw Q();const i=this._createUpdatingResolver();try{await this._cancelWorkflow();const t=this._createUpdateFeaturesWorkflow(e);this._set("activeWorkflow",t),await t.start()}catch(a){this._logErrorAndCancelWorkflow(a)}finally{i.resolve()}}async startUpdateWorkflowAtFeatureSelection(){if(await _(()=>!this.updating),!this.canUpdate)return void this._logError("editing:unsupported-workflow","Update workflow is unsupported or disabled.");const e=this._createUpdatingResolver();try{await this._cancelWorkflow();const e=this._createUpdateWorkflow();this._set("activeWorkflow",e),await e.start()}catch(t){this._logErrorAndCancelWorkflow(t)}finally{e.resolve()}}async startUpdateWorkflowAtMultipleFeatureSelection(e){if(await _(()=>!this.updating),!this.canUpdate)return void this._logError("editing:unsupported-workflow","Update workflow is unsupported or disabled.");const t=this._createUpdatingResolver();try{await this._cancelWorkflow();const t=this._createUpdateWorkflow("awaiting-update-feature-candidate");t.data.candidates=e,this._set("activeWorkflow",t),await t.start()}catch(i){this._logErrorAndCancelWorkflow(i)}finally{t.resolve()}}async startUpdateWorkflowAtFeatureEdit(e){if(await _(()=>!this.updating),!this.canUpdate)return void this._logError("editing:unsupported-workflow","Update workflow is unsupported or disabled.");const t=this._createUpdatingResolver();try{await this._cancelWorkflow();const t=this._createUpdateWorkflow("editing-existing-feature");t.data.rootFeature=e,t.addHandles(m(()=>t,"commit",()=>{t.destroy(),this.activeWorkflow===t&&this._set("activeWorkflow",null)})),this._set("activeWorkflow",t),await t.start()}catch(i){this._logErrorAndCancelWorkflow(i)}finally{t.resolve()}}async startUpdateWorkflowWithActiveSelection(){const{selectionListViewModel:e}=this;if(!e.visibleFeatureCount)throw new s("editing:missing-selection","Unable to determine visible selection.");if(e.visibleLayerCount>1)throw new s("editing:features-different-layers","Cannot start workflow with features from different layers.");const t=e.visibleFeatureItems.map(e=>e.graphic);1===t.length?await this.startUpdateWorkflowAtFeatureEdit(t[0]):await this.startUpdateFeaturesWorkflow(t)}async deleteFeatureFromWorkflow(){o(d.getLogger(this),"EditorViewModel.deleteFeatureFromWorkflow is deprecated. Use EditorViewModel.deleteFeatures instead.",{version:"4.33",replacement:"EditorViewModel.deleteFeatures",warnOnce:!0}),await this.deleteFeatures()}async deleteFeatures(){const e=this.activeWorkflow;return N(e)?e.deleteActiveFeature():B(e)?e.deleteAndCommit():void this._logError("editing:unsupported-workflow","Deleting features requires an active update workflow.")}async deleteAssociationFromWorkflow(){const{activeWorkflow:e}=this;e&&"update"===e.type?await e.deleteActiveAssociation():this._logError("editing:unsupported-workflow","Deleting an association requires an active update workflow.")}async cancelWorkflow(e){return this._cancelWorkflow({warnIfNoWorkflow:!0,...e})}findEditorItemForLayer(e){return this.editorItems.find(t=>t.layer===e)}itemHasInvalidFormTemplate(e){return null!=e&&!0===this.findEditorItemForLayer(e.layer)?.hasInvalidFormTemplate}syncFeatureTemplates(){this._featureTemplatesViewModelIsRestricted||this._updateTemplates()}zoomTo(e){const{view:t,sketchViewModel:a}=this;if(!t)return;const r=e??a?.createGraphic;if(r)"mesh"===r.geometry?.type?Y(t,r.geometry):Y(t,r);else{const e=a?.updateGraphics?.toArray();"3d"===t.type&&e?.some(e=>"mesh"===e.geometry?.type)?Y(t,e.map(e=>e.geometry).filter(i)):e&&Y(t,e)}}async toggleUpdateWorkflow(){this.canUpdate&&(this.hasPendingEdits&&!await this.showDiscardEditsPrompt()||(this.activeWorkflow&&"awaiting-feature-to-update"===this.state?await this.cancelWorkflow({force:!0}):await this.startUpdateWorkflowAtFeatureSelection()))}async onSelectionListItemSelect(e){ee(e)&&await this.startUpdateWorkflowAtFeatureEdit(e.graphic)}async onSelectionListMenuItemSelect(e){if(ee(e))await this.startUpdateWorkflowAtFeatureEdit(e.graphic);else if(te(e)){const t=e.featureItems.filter(e=>e.visible).map(e=>e.graphic);1===t.length?await this.startUpdateWorkflowAtFeatureEdit(t[0]):await this.startUpdateFeaturesWorkflow(t)}}restrictFeatureTemplatesViewModelToLayer(e){return this._featureTemplatesViewModelIsRestricted=!0,this._setFeatureTemplatesViewModelLayers([e]),l(()=>{this._featureTemplatesViewModelIsRestricted=!1,this._setFeatureTemplatesViewModelLayers(this.featureTemplatesLayers)})}async _getEditorItemCandidates(e){const{view:t}=this;if(!t?.map)return[];const{map:i}=t,a=i.editableLayers.toArray(),r=i.allTables.toArray().filter(e=>V(e)||S(e));return await Promise.allSettled([...a.flatMap(e=>this._getLayerLoadPromise(e)),...r.flatMap(e=>this._getLayerLoadPromise(e))]),h(e),[...a.reverse(),...r.reverse()].filter(e=>T(e)&&("mesh"!==e.geometryType||"3d"===t.type)).flatMap(e=>"subtype-group"===e.type?e.sublayers.toArray():e)}_getLayerLoadPromise(e){return S(e)?e.loadAll():e.load()}_drainEditorItems(){this.editorItems.drain(e=>e.destroy())}_updateEditorItems(){c(this._updateItemsTask);const{view:e}=this,t=a(async t=>{if(!e?.map||!e?.allLayerViews)return;const i=await this._getEditorItemCandidates(t);if(!i.length)return void this._drainEditorItems();const a=[],r=[],o=[],{layerInfos:s}=this;for(const l of i){const t=re(s,l),i=await z(e,l).catch(()=>null);(t?a:i?r:o).push(new Z({layer:l,layerInfo:t,layerView:i}))}s?.length&&a.sort((e,t)=>s.findIndex(({layer:t})=>t===e.layer)-s.findIndex(({layer:e})=>e===t.layer));const n=[...a,...r,...o];t.aborted||(this._drainEditorItems(),this.editorItems.addMany(n))});this._updatingHandles.addPromise(t.promise),this._updateItemsTask=t}_updateTemplates(){c(this._updateTemplatesTask);const e=a(async e=>{const t=this._templatesByLayer,i=this._featureTemplatesLayersAndTables.filter(e=>!t.has(e));if(i.length>0){const a=await b(i.toArray(),this.view,e);for(const{layer:e,templates:i}of a)t.set(e,i)}this._setFeatureTemplatesViewModelLayers(this.featureTemplatesLayers)});this._updatingHandles.addPromise(e.promise),this._updateTemplatesTask=e}_setFeatureTemplatesViewModelLayers(e){const t=this._templatesByLayer,i=[];for(const a of e){const e=t.get(a);e&&e.length>0&&i.push($(a,e))}this.featureTemplatesViewModel.templateInfos=i}_afterEditorItemsChange(){const{activeWorkflow:e}=this;if(this.syncFeatureTemplates(),!e)return;const{stepId:t}=e;"create-features"!==e.type?"update"===e.type&&("awaiting-feature-to-update"===t&&!this.canUpdateVisible||"awaiting-update-feature-candidate"===t&&!e.hasUpdatableCandidates)&&this._cancelWorkflow():"awaiting-feature-creation-info"!==t||this.canCreate||this._cancelWorkflow()}async _cancelWorkflow(e){const t=this.activeWorkflow;if(!t)return void(e?.warnIfNoWorkflow&&this._logError("editing:no-active-workflow","There is no active workflow to cancel."));if(!e||!1!==e.force){this.emit("workflow-cancel"),this._set("activeWorkflow",null);try{await t.cancel(e)}finally{t.destroy()}}else try{await t.cancel(e),this._set("activeWorkflow",null),t.destroy()}catch(i){}}_createCreateFeaturesWorkflow(e,t){return R.create({viewModel:this,creationInfo:e,sketchOptions:this.sketchOptions,snappingManager:this._snappingManager,startAt:t,applyEditsCallback:(e,t,i)=>this._applyEdits(e,t,i),applyEditsFeatureServiceCallback:(e,t,i)=>this._applyEditsFeatureService(e,t,i),addAttachmentsCallback:(e,t)=>this._addAttachments(e,t)})}_createUpdateFeaturesWorkflow(e){const t=H.create({viewModel:this,sketchOptions:this.sketchOptions,snappingManager:this._snappingManager,features:e,applyEdits:(e,t,i)=>this._applyEdits(e,t,i),applyEditsFeatureService:(e,t,i)=>this._applyEditsFeatureService(e,t,i)});return t.addHandles(m(()=>t,"commit",()=>{t.destroy(),this.activeWorkflow===t&&this._set("activeWorkflow",null)})),t}_createUpdateWorkflow(e){return q.create({viewModel:this,sketchOptions:this.sketchOptions,snappingManager:this._snappingManager,startAt:e,applyEditsCallback:(e,t,i)=>this._applyEdits(e,t,i),applyEditsFeatureServiceCallback:(e,t,i)=>this._applyEditsFeatureService(e,t,i),addAttachmentsCallback:(e,t)=>this._addAttachments(e,t)})}_addAttachments(e,t){const i=t.map(t=>this._addAttachment(e,t.feature,t.attachment))??[];return Promise.all(i)}async _addAttachment(e,t,i){let a=null;if(!("addAttachment"in e)||null==e.capabilities?.attachment)throw new s("editor:attachments-not-supported","Adding attachments is not supported for this layer type");return await this._queueOperation(async()=>(a=await(e.addAttachment?.(t,i).catch(e=>{throw e?.error||e}))??null,a)),a}async _applyEdits(e,t,i){let a=null;const r=e.url?await L(e.url):null,o={returnServiceEditsOption:(!r||!I(r))&&!/\/hosted\//i.test(e.url)?"original-and-current-features":void 0,...i};return await this._queueOperation(async()=>{const{view:i}=this;if(!i)return null;const r=await z(i,e).catch(()=>null);return a=await e.applyEdits(t,o),r&&await _(()=>!r.updating),a}),a}async _applyEditsFeatureService(e,t,i){let a=null;return await this._queueOperation(async()=>a=await e.applyEdits(t,i)),a}_queueOperation(e){this._activityQueue.push(e);const t=(e,t)=>{const i=t.indexOf(e);i>-1&&t.splice(i,1)};return e().then(e=>(Array.isArray(e)?e.forEach(e=>this._handleEditsResultError(e)):this._handleEditsResultError(e),e)).catch(i=>{this._logError("editing:operation-error","An error occurred.",{error:i});const a={error:i,retry:()=>(t(a,this.failures),this._queueOperation(e)),cancel:()=>{t(a,this.failures)}};this._set("failures",[...this.failures,a])}).then(()=>{t(e,this._activityQueue)})}_handleEditsResultError(e){if(null!=e&&"error"in e&&null!=e.error)throw e.error;if(null!=e&&"addFeatureResults"in e){const{addFeatureResults:t,deleteFeatureResults:i,updateFeatureResults:a}=e,r=t.find(e=>!!e.error)||a.find(e=>!!e.error)||i.find(e=>!!e.error);if(r)throw r.error}}_createUpdatingResolver(){const e=w();return this._updatingHandles.addPromise(e.promise),e}_logErrorAndCancelWorkflow(e){const{name:t,message:i,details:a}=e;this._logError(t??"editing:workflow-start-failed",i??void 0,a??e),this._cancelWorkflow({force:!0})}_itemIsSuspended(e){const t=this.findEditorItemForLayer(e);return null!=t&&(!t.visible||t.disabled)}_logError(e,t,i){d.getLogger(this).error(new s(e,t,i))}_syncSelectionSources(){this.selectionManager.sources.items=this._selectionSources.toArray()}async _onSelectionComplete(e){if(e.aborted)return;const{operationType:t,selection:i}=e,{effectiveSelectionManager:a}=this,r="ready"===this.state,o=1===i.length;if(this._queuedSelectionTool=void 0,r&&o&&"replace"===t)return this._queuedSelectionTool=e.toolName,this.startUpdateWorkflowAtFeatureEdit(i[0]);switch(t){case"remove":a.updateSelection({current:[],added:[],removed:i});break;case"replace":a.clear(),a.updateSelection({current:i,added:[],removed:[]});break;case"add":a.updateSelection({current:i,added:[],removed:[]})}}};e([M()],oe.prototype,"_featureTemplatesLayersAndTables",null),e([M()],oe.prototype,"_queuedSelectionTool",void 0),e([M()],oe.prototype,"_snappingManager",void 0),e([M()],oe.prototype,"_selectionSources",null),e([M()],oe.prototype,"activeFeatureCount",null),e([M({readOnly:!0})],oe.prototype,"activeWorkflow",void 0),e([M()],oe.prototype,"activeLeafWorkflow",null),e([M({readOnly:!0})],oe.prototype,"_activityQueue",void 0),e([M({readOnly:!0})],oe.prototype,"canCreate",null),e([M()],oe.prototype,"canCreateVisible",null),e([M({readOnly:!0})],oe.prototype,"canUpdate",null),e([M()],oe.prototype,"canUpdateVisible",null),e([M()],oe.prototype,"featureTemplatesLayers",null),e([M()],oe.prototype,"editorItems",void 0),e([M()],oe.prototype,"effectiveSelectionManager",null),e([M({readOnly:!0})],oe.prototype,"failures",void 0),e([M()],oe.prototype,"hideTemplatesForInactiveLayers",void 0),e([M({type:P})],oe.prototype,"attachmentsViewModel",void 0),e([M()],oe.prototype,"featureFormViewModel",null),e([M()],oe.prototype,"formViewModel",null),e([M()],oe.prototype,"utilityNetworkAssociationAddAssociationViewModel",null),e([M({type:J})],oe.prototype,"featureTemplatesViewModel",void 0),e([M()],oe.prototype,"labelOptions",null),e([M()],oe.prototype,"layerInfos",void 0),e([M()],oe.prototype,"ownSketchViewModel",void 0),e([M()],oe.prototype,"selectionListViewModel",void 0),e([M()],oe.prototype,"selectionManager",void 0),e([M()],oe.prototype,"selectionToolbarViewModel",void 0),e([M()],oe.prototype,"sketchOptions",void 0),e([M()],oe.prototype,"sketchViewModel",null),e([M({type:O,nonNullable:!0})],oe.prototype,"snappingOptions",void 0),e([M()],oe.prototype,"spinnerViewModel",void 0),e([M()],oe.prototype,"state",null),e([M({readOnly:!0})],oe.prototype,"syncing",null),e([M()],oe.prototype,"updating",null),e([M()],oe.prototype,"tooltipOptions",null),e([M()],oe.prototype,"valueOptions",null),e([M()],oe.prototype,"view",null),e([M()],oe.prototype,"canZoomTo",null),e([M()],oe.prototype,"pageStack",void 0),e([M()],oe.prototype,"showDiscardEditsPrompt",void 0),e([M()],oe.prototype,"_candidateCommitted",void 0),e([M()],oe.prototype,"page",null),e([M()],oe.prototype,"featureFormDisabled",null),e([M()],oe.prototype,"featureFormHasAssociation",null),e([M()],oe.prototype,"canGoBack",null),e([M()],oe.prototype,"shouldShowDeleteButton",null),e([M()],oe.prototype,"hasPendingEdits",null),e([M()],oe.prototype,"snappingManager",null),oe=e([W("esri.widgets.Editor.EditorViewModel")],oe);const se=oe;export{se as default};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{__decorate as e}from"tslib";import"../../../intl.js";import{watch as t,on as r,initial as i}from"../../../core/reactiveUtils.js";import{stripHTML as s}from"../../../core/string.js";import{property as o}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{isSubtypeGroupLayer as a,isGroupLayer as n}from"../../../layers/support/layerUtils.js";import{defaultHighlightName as c,temporaryHighlightName as d}from"../../../views/support/HighlightDefaults.js";import p from"../../Widget.js";import u from"../UtilityNetworkAssociationAddAssociationViewModel.js";import{loadCalciteComponents as h}from"../../support/componentsUtils.js";import m from"../../support/FilterBuilder.js";import{globalCss as _}from"../../support/globalCss.js";import{Heading as v}from"../../support/Heading.js";import f from"../../support/SelectionToolbar.js";import"../../support/widgetUtils.js";import{messageBundle as g}from"../../support/decorators/messageBundle.js";import{tsx as y}from"../../support/jsxFactory.js";import b from"../../support/SelectionToolbar/VisibleElements.js";import{substitute as F}from"../../../intl/substitute.js";const w="esri-feature-form-utility-network-association-layers",C={base:w,header:`${w}__header`,headingContent:`${w}__heading-content`,featureObserver:`${w}__feature-observer`,filterContainer:`${w}__filter-container`,filterOptionsContainer:`${w}__filter-options-container`,filterOptionsHeader:`${w}__filter-options-header`,listContainer:`${w}__list-container`,spatialSelectContainer:`${w}__spatial-select-container`,spatialSelectToolbar:`${w}__spatial-select-toolbar`,stickySpinnerContainer:`${w}__sticky-loading-container`,loadingContainer:`${w}__loading-container`};let L=class extends p{constructor(e,t){super(e,t),this.headingLevel=5,this.messagesCommon=null,this.messagesEditor=null,this.messagesFeature=null,this.messagesFeatureForm=null,this.messagesFilterBuilder=null,this.viewModel=new u,this.view=null,this._filterBuilder=new m,this._featureFilterText="",this._layerFilterText="",this._observer=new IntersectionObserver(([e])=>{e?.isIntersecting&&this._increaseFeaturePage()},{root:window.document}),this._observerNode=null,this._selectionToolbar=new f({returnFeatureTitleFields:!0,layerViewPreferenceEnabled:!1,persistSelection:!1,visibleElements:new b({chip:!1,pan:!1})}),this._onSelectionComplete=async e=>{const{highlightHelper:t}=this.viewModel;await this.viewModel.onSelectionComplete(e),t?.removeAll(),this._featureSpatialGraphics.length>0&&t?.add(this._featureSpatialGraphics)}}initialize(){this._setupSelectionToolbar(),this.addHandles([t(()=>this.viewModel,()=>this.reset()),t(()=>[this.viewModel.state,this._observerNode],()=>this._onObserverChange()),t(()=>this.selectedLayer,e=>{this._filterBuilder.layer=e,e||(this.filterOptionsVisible=!1,this._featureFilterText="")})])}loadDependencies(){return h({action:()=>import("@esri/calcite-components/dist/components/calcite-action"),button:()=>import("@esri/calcite-components/dist/components/calcite-button"),icon:()=>import("@esri/calcite-components/dist/components/calcite-icon"),input:()=>import("@esri/calcite-components/dist/components/calcite-input"),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")})}destroy(){this._filterBuilder.destroy(),this._selectionToolbar.destroy()}get filterOptionsVisible(){return this.viewModel.filterOptionsVisible}set filterOptionsVisible(e){this.viewModel.filterOptionsVisible=e}get isSelecting(){return"active"===this._selectionToolbar.state}get selectedLayer(){return this.viewModel.selectedLayer}set selectedLayer(e){this.viewModel.selectedLayer=e}get selectedFeature(){return this.viewModel.selectedFeature}set selectedFeature(e){this.viewModel.selectedFeature=e}get filterWhereClause(){return this.viewModel.filterWhereClause}set filterWhereClause(e){this.viewModel.filterWhereClause=e,e||this._filterBuilder.reset()}get _featureSpatialGraphics(){return this.viewModel.featureSpatialItems.toArray().map(e=>e.feature)}get _filteredFeatureItems(){const{_featureFilterText:e}=this,{featureItems:t,featureSpatialItems:r}=this.viewModel;return(r.length?r:t).map(e=>({label:e.label,graphic:e.feature,layer:e.feature.sourceLayer})).filter(t=>t.label?.toLowerCase().includes(e)??!1)}get _filteredFeatureItemsPage(){const{featurePage:e,featuresPerPage:t}=this.viewModel,r=e*t;return this._filteredFeatureItems.toArray().slice(0,r)}render(){return y("div",{class:this.classes(C.base,_.widget)},this._renderContent())}applyFilterOptions(){const{selectedLayer:e}=this;this.filterOptionsVisible=!1,e&&(this.filterWhereClause=this._filterBuilder.whereClause)}cancelSelection(){this._selectionToolbar.cancel()}reset(){this.filterWhereClause=null,this._featureFilterText="",this._layerFilterText="",this.filterOptionsVisible=!1,this._filterBuilder.reset()}startSelection(e){this._selectionToolbar.activateTool(e)}_setupSelectionToolbar(){this.addHandles([t(()=>this.view,e=>{this.viewModel.reset(),this._selectionToolbar.view="2d"===e?.type?e:null},i),t(()=>[this.viewModel,this.viewModel.layerItems.length,this.viewModel.map?.allLayers.map(e=>e.visible),this.viewModel.map?.allLayers?.filter(e=>a(e)).toArray().flatMap(e=>e.sublayers.toArray()).map(e=>e.visible)],()=>this._updateToolbarSources()),r(()=>this._selectionToolbar,"before-activate",e=>this.emit("before-selection",e)),r(()=>this._selectionToolbar,"complete",this._onSelectionComplete)])}_updateToolbarSources(){const e=this.viewModel.layerItems.toArray().filter(e=>{const{parent:t}=e;return!(t&&(n(t)||a(t))&&!t.visible)&&e.visible});this._selectionToolbar.sources=e}_onObserverChange(){this._observerNode&&this._observer.unobserve(this._observerNode);const{state:e}=this.viewModel;this._observerNode&&"ready"===e&&this._observer.observe(this._observerNode)}_increaseFeaturePage(){const{featureCount:e,featurePage:t,featureSpatialItems:r,state:i}=this.viewModel;e||r.length||1===t?"ready"===i&&this.viewModel.featurePage++:this.viewModel.featurePage=1}_renderContent(){const{state:e,filterOptionsVisible:t}=this.viewModel;return"loading"===e?this._renderLoading():t?this._renderFilterOptions():[this._renderSelectionToolbar(),this._renderListContent()]}_renderListContent(){return this._selectionToolbar.activeOperation?.processingFinalSelection?this._renderLoading():this.selectedLayer||this.viewModel.featureSpatialItems.length?this._renderFeatures():this._renderLayers()}_renderSelectionToolbar(){const{messagesCommon:e,_selectionToolbar:t}=this,{featureSpatialItems:r,selectedLayer:i}=this.viewModel;if(i||!t.sources?.length)return null;const s=y("div",{class:C.spatialSelectToolbar},t.render()),o=y("calcite-button",{appearance:"transparent",disabled:!r.length,label:e.clear,onclick:()=>this.viewModel.reset()},e.clear);return y("div",{class:C.spatialSelectContainer,key:"spatial-select-toolbar"},s,o)}_renderStickyLoading(){return"querying"===this.viewModel.state?y("div",{class:C.stickySpinnerContainer,key:"sticky-loader"},this._renderLoadingIcon()):null}_renderLoading(){return y("div",{class:C.loadingContainer,key:"loading-container"},this._renderLoadingIcon())}_renderLoadingIcon(){return y("calcite-loader",{inline:!0,label:this.messagesCommon.loading})}_renderFilterOptions(){return y("div",{class:C.filterOptionsContainer},y("div",{class:C.filterOptionsHeader},y("span",null,this.messagesFilterBuilder.widgetLabel),y("calcite-button",{appearance:"transparent",onclick:()=>this._filterBuilder.reset()},this.messagesCommon.clear)),this._filterBuilder.render())}_renderLayers(){const e=this.messagesFeatureForm.associations,t=e.availableLayers,r=e.filterLayers;return y("div",null,this._renderHeader({heading:t,placeholder:r,renderFilterOptions:!1,renderTotal:!1}),y("div",{class:C.listContainer},y("calcite-list",{label:e.associatedFeatures},this._renderLayerItems(),this._renderStickyLoading())))}_renderLayerItems(){const{_layerFilterText:e,viewModel:t,messagesCommon:r}=this,{layerItems:i,tableItems:s}=t;return i.concat(s).map(e=>({label:e.title??r.untitled,layer:e})).filter(t=>t.label?.toLowerCase().includes(e)??!1).toArray().map(e=>this._renderLayerItem(e))}_renderLayerItem(e){const{label:t,layer:r}=e;return y("calcite-list-item",{key:`layer-item-${r.id}`,label:s(t),onCalciteListItemSelect:()=>{this.selectedLayer=r,this._filterBuilder.reset()}},y("calcite-icon",{flipRtl:!0,icon:"chevron-right",scale:"s",slot:"content-end"}))}_renderFeatures(){const{selectedLayer:e,viewModel:t}=this,r=t.featureSpatialItems.length>0,i=this.messagesFeatureForm.associations,s=r?void 0:e?.title||this.messagesCommon.untitled,o=i.filterFeatures;return y("div",null,this._renderHeader({heading:s,placeholder:o,renderFilterOptions:!r,renderTotal:!0}),y("div",{class:C.listContainer},y("calcite-list",{label:i.associatedFeatures},this._renderFeatureItems(),this._renderStickyLoading(),this._renderFeatureObserver())))}_renderFeatureItems(){return this._filteredFeatureItemsPage.map(e=>this._renderFeatureItem(e))}_renderFeatureItem(e){const{viewModel:t}=this,{highlightHelper:r}=t,{label:i,graphic:o}=e,l=t.featureSpatialItems.length>0?()=>r?.update(o,c):void 0,a=t.featureSpatialItems.length>0?()=>r?.update(o,d):void 0;return y("calcite-list-item",{key:`feature-item-${o.uid}`,label:s(i),onmouseenter:l,onmouseleave:a,onCalciteListItemSelect:()=>{this.selectedFeature={feature:o,label:i}}},y("calcite-icon",{flipRtl:!0,icon:"chevron-right",scale:"s",slot:"content-end"}))}_onObserverCreate(e){this._observerNode=e}_renderFeatureObserver(){return y("div",{afterCreate:this._onObserverCreate,bind:this,class:C.featureObserver,key:"feature-observer"})}_renderHeader(e){return y("div",{class:C.header,key:"filter"},this._renderHeading(e.heading),this._renderFilter(e.placeholder,e.renderFilterOptions),e.renderTotal?this._renderTotal():null)}_renderHeading(e){return e?y(v,{key:"title",level:this.headingLevel},y("div",{class:C.headingContent},y("calcite-icon",{icon:"layer"}),e)):null}_renderFilter(e,t){const r=!this.selectedLayer&&!this.viewModel.featureSpatialItems.length,i=r?this._layerFilterText:this._featureFilterText;return y("div",{class:C.filterContainer,key:"filter"},y("calcite-input",{icon:"search",placeholder:e,type:"search",value:i,onCalciteInputInput:e=>{r?this._layerFilterText=e.currentTarget.value.trim().toLowerCase():this._featureFilterText=e.currentTarget.value.trim().toLowerCase()}},t?this._renderFilterOptionsAction():null))}_renderFilterOptionsAction(){const e=this.messagesFeatureForm.associations.filterOptions;return y("calcite-action",{appearance:"transparent",icon:"sliders",indicator:!!this._filterBuilder.whereClause,onclick:()=>{this.viewModel.filterOptionsVisible=!this.viewModel.filterOptionsVisible},scale:"s",slot:"action",text:e,title:e})}_renderTotal(){const{messagesFeature:e,viewModel:t}=this,{featureCount:r,featureSpatialItems:i}=t,s=F(e.numberRecords,{number:i.length?i.length:r});return y("div",{key:"total"},s)}};e([o()],L.prototype,"filterOptionsVisible",null),e([o()],L.prototype,"headingLevel",void 0),e([o()],L.prototype,"isSelecting",null),e([o(),g("esri/t9n/common")],L.prototype,"messagesCommon",void 0),e([o(),g("esri/widgets/Editor/t9n/Editor")],L.prototype,"messagesEditor",void 0),e([o(),g("esri/widgets/Feature/t9n/Feature")],L.prototype,"messagesFeature",void 0),e([o(),g("esri/widgets/FeatureForm/t9n/FeatureForm")],L.prototype,"messagesFeatureForm",void 0),e([o(),g("esri/widgets/support/FilterBuilder/t9n/FilterBuilder")],L.prototype,"messagesFilterBuilder",void 0),e([o()],L.prototype,"selectedLayer",null),e([o({type:u})],L.prototype,"viewModel",void 0),e([o()],L.prototype,"selectedFeature",null),e([o()],L.prototype,"filterWhereClause",null),e([o()],L.prototype,"view",void 0),e([o()],L.prototype,"_filterBuilder",void 0),e([o()],L.prototype,"_featureFilterText",void 0),e([o()],L.prototype,"_layerFilterText",void 0),e([o()],L.prototype,"_observer",void 0),e([o()],L.prototype,"_featureSpatialGraphics",null),e([o()],L.prototype,"_filteredFeatureItems",null),e([o()],L.prototype,"_filteredFeatureItemsPage",null),e([o()],L.prototype,"_observerNode",void 0),L=e([l("esri.widgets.FeatureForm.FeatureFormUtilityNetworkAssociations.UtilityNetworkAssociationItemList")],L);const S=L;export{S as default};
|
|
5
|
+
import{__decorate as e}from"tslib";import"../../../intl.js";import{watch as t,on as r,initial as i}from"../../../core/reactiveUtils.js";import{stripHTML as s}from"../../../core/string.js";import{property as o}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{isSubtypeGroupLayer as a,isGroupLayer as n}from"../../../layers/support/layerUtils.js";import{defaultHighlightName as c,temporaryHighlightName as d}from"../../../views/support/HighlightDefaults.js";import p from"../../Widget.js";import u from"../UtilityNetworkAssociationAddAssociationViewModel.js";import{loadCalciteComponents as h}from"../../support/componentsUtils.js";import m from"../../support/FilterBuilder.js";import{globalCss as _}from"../../support/globalCss.js";import{Heading as v}from"../../support/Heading.js";import f from"../../support/SelectionToolbar.js";import"../../support/widgetUtils.js";import{messageBundle as g}from"../../support/decorators/messageBundle.js";import{tsx as y}from"../../support/jsxFactory.js";import b from"../../support/SelectionToolbar/VisibleElements.js";import{substitute as F}from"../../../intl/substitute.js";const w="esri-feature-form-utility-network-association-layers",C={base:w,header:`${w}__header`,headingContent:`${w}__heading-content`,featureObserver:`${w}__feature-observer`,filterContainer:`${w}__filter-container`,filterOptionsContainer:`${w}__filter-options-container`,filterOptionsHeader:`${w}__filter-options-header`,listContainer:`${w}__list-container`,spatialSelectContainer:`${w}__spatial-select-container`,spatialSelectToolbar:`${w}__spatial-select-toolbar`,stickySpinnerContainer:`${w}__sticky-loading-container`,loadingContainer:`${w}__loading-container`};let L=class extends p{constructor(e,t){super(e,t),this.headingLevel=5,this.messagesCommon=null,this.messagesEditor=null,this.messagesFeature=null,this.messagesFeatureForm=null,this.messagesFilterBuilder=null,this.viewModel=new u,this.view=null,this._filterBuilder=new m,this._featureFilterText="",this._layerFilterText="",this._observer=new IntersectionObserver(([e])=>{e?.isIntersecting&&this._increaseFeaturePage()},{root:window.document}),this._observerNode=null,this._selectionToolbar=new f({returnFeatureTitleFields:!0,layerViewPreferenceEnabled:!1,persistSelection:!1,visibleElements:new b({chip:!1,operationTypeControls:!1,pan:!1})}),this._onSelectionComplete=async e=>{const{highlightHelper:t}=this.viewModel;await this.viewModel.onSelectionComplete(e),t?.removeAll(),this._featureSpatialGraphics.length>0&&t?.add(this._featureSpatialGraphics)}}initialize(){this._setupSelectionToolbar(),this.addHandles([t(()=>this.viewModel,()=>this.reset()),t(()=>[this.viewModel.state,this._observerNode],()=>this._onObserverChange()),t(()=>this.selectedLayer,e=>{this._filterBuilder.layer=e,e||(this.filterOptionsVisible=!1,this._featureFilterText="")})])}loadDependencies(){return h({action:()=>import("@esri/calcite-components/dist/components/calcite-action"),button:()=>import("@esri/calcite-components/dist/components/calcite-button"),icon:()=>import("@esri/calcite-components/dist/components/calcite-icon"),input:()=>import("@esri/calcite-components/dist/components/calcite-input"),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")})}destroy(){this._filterBuilder.destroy(),this._selectionToolbar.destroy()}get filterOptionsVisible(){return this.viewModel.filterOptionsVisible}set filterOptionsVisible(e){this.viewModel.filterOptionsVisible=e}get isSelecting(){return"active"===this._selectionToolbar.state}get selectedLayer(){return this.viewModel.selectedLayer}set selectedLayer(e){this.viewModel.selectedLayer=e}get selectedFeature(){return this.viewModel.selectedFeature}set selectedFeature(e){this.viewModel.selectedFeature=e}get filterWhereClause(){return this.viewModel.filterWhereClause}set filterWhereClause(e){this.viewModel.filterWhereClause=e,e||this._filterBuilder.reset()}get _featureSpatialGraphics(){return this.viewModel.featureSpatialItems.toArray().map(e=>e.feature)}get _filteredFeatureItems(){const{_featureFilterText:e}=this,{featureItems:t,featureSpatialItems:r}=this.viewModel;return(r.length?r:t).map(e=>({label:e.label,graphic:e.feature,layer:e.feature.sourceLayer})).filter(t=>t.label?.toLowerCase().includes(e)??!1)}get _filteredFeatureItemsPage(){const{featurePage:e,featuresPerPage:t}=this.viewModel,r=e*t;return this._filteredFeatureItems.toArray().slice(0,r)}render(){return y("div",{class:this.classes(C.base,_.widget)},this._renderContent())}applyFilterOptions(){const{selectedLayer:e}=this;this.filterOptionsVisible=!1,e&&(this.filterWhereClause=this._filterBuilder.whereClause)}cancelSelection(){this._selectionToolbar.cancel()}reset(){this.filterWhereClause=null,this._featureFilterText="",this._layerFilterText="",this.filterOptionsVisible=!1,this._filterBuilder.reset()}startSelection(e){this._selectionToolbar.activateTool(e)}_setupSelectionToolbar(){this.addHandles([t(()=>this.view,e=>{this.viewModel.reset(),this._selectionToolbar.view="2d"===e?.type?e:null},i),t(()=>[this.viewModel,this.viewModel.layerItems.length,this.viewModel.map?.allLayers.map(e=>e.visible),this.viewModel.map?.allLayers?.filter(e=>a(e)).toArray().flatMap(e=>e.sublayers.toArray()).map(e=>e.visible)],()=>this._updateToolbarSources()),r(()=>this._selectionToolbar,"before-activate",e=>this.emit("before-selection",e)),r(()=>this._selectionToolbar,"complete",this._onSelectionComplete)])}_updateToolbarSources(){const e=this.viewModel.layerItems.toArray().filter(e=>{const{parent:t}=e;return!(t&&(n(t)||a(t))&&!t.visible)&&e.visible});this._selectionToolbar.sources=e}_onObserverChange(){this._observerNode&&this._observer.unobserve(this._observerNode);const{state:e}=this.viewModel;this._observerNode&&"ready"===e&&this._observer.observe(this._observerNode)}_increaseFeaturePage(){const{featureCount:e,featurePage:t,featureSpatialItems:r,state:i}=this.viewModel;e||r.length||1===t?"ready"===i&&this.viewModel.featurePage++:this.viewModel.featurePage=1}_renderContent(){const{state:e,filterOptionsVisible:t}=this.viewModel;return"loading"===e?this._renderLoading():t?this._renderFilterOptions():[this._renderSelectionToolbar(),this._renderListContent()]}_renderListContent(){return this._selectionToolbar.activeOperation?.processingFinalSelection?this._renderLoading():this.selectedLayer||this.viewModel.featureSpatialItems.length?this._renderFeatures():this._renderLayers()}_renderSelectionToolbar(){const{messagesCommon:e,_selectionToolbar:t}=this,{featureSpatialItems:r,selectedLayer:i}=this.viewModel;if(i||!t.sources?.length)return null;const s=y("div",{class:C.spatialSelectToolbar},t.render()),o=y("calcite-button",{appearance:"transparent",disabled:!r.length,label:e.clear,onclick:()=>this.viewModel.reset()},e.clear);return y("div",{class:C.spatialSelectContainer,key:"spatial-select-toolbar"},s,o)}_renderStickyLoading(){return"querying"===this.viewModel.state?y("div",{class:C.stickySpinnerContainer,key:"sticky-loader"},this._renderLoadingIcon()):null}_renderLoading(){return y("div",{class:C.loadingContainer,key:"loading-container"},this._renderLoadingIcon())}_renderLoadingIcon(){return y("calcite-loader",{inline:!0,label:this.messagesCommon.loading})}_renderFilterOptions(){return y("div",{class:C.filterOptionsContainer},y("div",{class:C.filterOptionsHeader},y("span",null,this.messagesFilterBuilder.widgetLabel),y("calcite-button",{appearance:"transparent",onclick:()=>this._filterBuilder.reset()},this.messagesCommon.clear)),this._filterBuilder.render())}_renderLayers(){const e=this.messagesFeatureForm.associations,t=e.availableLayers,r=e.filterLayers;return y("div",null,this._renderHeader({heading:t,placeholder:r,renderFilterOptions:!1,renderTotal:!1}),y("div",{class:C.listContainer},y("calcite-list",{label:e.associatedFeatures},this._renderLayerItems(),this._renderStickyLoading())))}_renderLayerItems(){const{_layerFilterText:e,viewModel:t,messagesCommon:r}=this,{layerItems:i,tableItems:s}=t;return i.concat(s).map(e=>({label:e.title??r.untitled,layer:e})).filter(t=>t.label?.toLowerCase().includes(e)??!1).toArray().map(e=>this._renderLayerItem(e))}_renderLayerItem(e){const{label:t,layer:r}=e;return y("calcite-list-item",{key:`layer-item-${r.id}`,label:s(t),onCalciteListItemSelect:()=>{this.selectedLayer=r,this._filterBuilder.reset()}},y("calcite-icon",{flipRtl:!0,icon:"chevron-right",scale:"s",slot:"content-end"}))}_renderFeatures(){const{selectedLayer:e,viewModel:t}=this,r=t.featureSpatialItems.length>0,i=this.messagesFeatureForm.associations,s=r?void 0:e?.title||this.messagesCommon.untitled,o=i.filterFeatures;return y("div",null,this._renderHeader({heading:s,placeholder:o,renderFilterOptions:!r,renderTotal:!0}),y("div",{class:C.listContainer},y("calcite-list",{label:i.associatedFeatures},this._renderFeatureItems(),this._renderStickyLoading(),this._renderFeatureObserver())))}_renderFeatureItems(){return this._filteredFeatureItemsPage.map(e=>this._renderFeatureItem(e))}_renderFeatureItem(e){const{viewModel:t}=this,{highlightHelper:r}=t,{label:i,graphic:o}=e,l=t.featureSpatialItems.length>0?()=>r?.update(o,c):void 0,a=t.featureSpatialItems.length>0?()=>r?.update(o,d):void 0;return y("calcite-list-item",{key:`feature-item-${o.uid}`,label:s(i),onmouseenter:l,onmouseleave:a,onCalciteListItemSelect:()=>{this.selectedFeature={feature:o,label:i}}},y("calcite-icon",{flipRtl:!0,icon:"chevron-right",scale:"s",slot:"content-end"}))}_onObserverCreate(e){this._observerNode=e}_renderFeatureObserver(){return y("div",{afterCreate:this._onObserverCreate,bind:this,class:C.featureObserver,key:"feature-observer"})}_renderHeader(e){return y("div",{class:C.header,key:"filter"},this._renderHeading(e.heading),this._renderFilter(e.placeholder,e.renderFilterOptions),e.renderTotal?this._renderTotal():null)}_renderHeading(e){return e?y(v,{key:"title",level:this.headingLevel},y("div",{class:C.headingContent},y("calcite-icon",{icon:"layer"}),e)):null}_renderFilter(e,t){const r=!this.selectedLayer&&!this.viewModel.featureSpatialItems.length,i=r?this._layerFilterText:this._featureFilterText;return y("div",{class:C.filterContainer,key:"filter"},y("calcite-input",{icon:"search",placeholder:e,type:"search",value:i,onCalciteInputInput:e=>{r?this._layerFilterText=e.currentTarget.value.trim().toLowerCase():this._featureFilterText=e.currentTarget.value.trim().toLowerCase()}},t?this._renderFilterOptionsAction():null))}_renderFilterOptionsAction(){const e=this.messagesFeatureForm.associations.filterOptions;return y("calcite-action",{appearance:"transparent",icon:"sliders",indicator:!!this._filterBuilder.whereClause,onclick:()=>{this.viewModel.filterOptionsVisible=!this.viewModel.filterOptionsVisible},scale:"s",slot:"action",text:e,title:e})}_renderTotal(){const{messagesFeature:e,viewModel:t}=this,{featureCount:r,featureSpatialItems:i}=t,s=F(e.numberRecords,{number:i.length?i.length:r});return y("div",{key:"total"},s)}};e([o()],L.prototype,"filterOptionsVisible",null),e([o()],L.prototype,"headingLevel",void 0),e([o()],L.prototype,"isSelecting",null),e([o(),g("esri/t9n/common")],L.prototype,"messagesCommon",void 0),e([o(),g("esri/widgets/Editor/t9n/Editor")],L.prototype,"messagesEditor",void 0),e([o(),g("esri/widgets/Feature/t9n/Feature")],L.prototype,"messagesFeature",void 0),e([o(),g("esri/widgets/FeatureForm/t9n/FeatureForm")],L.prototype,"messagesFeatureForm",void 0),e([o(),g("esri/widgets/support/FilterBuilder/t9n/FilterBuilder")],L.prototype,"messagesFilterBuilder",void 0),e([o()],L.prototype,"selectedLayer",null),e([o({type:u})],L.prototype,"viewModel",void 0),e([o()],L.prototype,"selectedFeature",null),e([o()],L.prototype,"filterWhereClause",null),e([o()],L.prototype,"view",void 0),e([o()],L.prototype,"_filterBuilder",void 0),e([o()],L.prototype,"_featureFilterText",void 0),e([o()],L.prototype,"_layerFilterText",void 0),e([o()],L.prototype,"_observer",void 0),e([o()],L.prototype,"_featureSpatialGraphics",null),e([o()],L.prototype,"_filteredFeatureItems",null),e([o()],L.prototype,"_filteredFeatureItemsPage",null),e([o()],L.prototype,"_observerNode",void 0),L=e([l("esri.widgets.FeatureForm.FeatureFormUtilityNetworkAssociations.UtilityNetworkAssociationItemList")],L);const S=L;export{S as default};
|