@arcgis/core 5.2.0-next.61 → 5.2.0-next.63

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (253) hide show
  1. package/WebDocument2D.d.ts +17 -1
  2. package/WebDocument2D.js +1 -1
  3. package/WebLinkChart.js +1 -1
  4. package/WebMap.js +1 -1
  5. package/WebScene.js +1 -1
  6. package/applications/Components/imageryUtils.d.ts +10 -0
  7. package/applications/Components/imageryUtils.js +1 -1
  8. package/arcade/featureset/sources/FeatureLayerDynamic.js +1 -1
  9. package/arcgisGlobal.d.ts +7 -0
  10. package/assets/esri/core/workers/RemoteClient.js +1 -1
  11. package/assets/esri/core/workers/chunks/02dd79beb13eff6be85e.js +1 -0
  12. package/assets/esri/core/workers/chunks/04ffe788d2efc0a076dd.js +1 -0
  13. package/assets/esri/core/workers/chunks/0623acb2bd14a61b65c9.js +29 -0
  14. package/assets/esri/core/workers/chunks/08c2bf9defcece9e049a.js +1 -0
  15. package/assets/esri/core/workers/chunks/0d61c8d348b09179777a.js +1 -0
  16. package/assets/esri/core/workers/chunks/{3abc12d2407e4214963d.js → 13033178de9f637a2356.js} +1 -1
  17. package/assets/esri/core/workers/chunks/14cd8bb1ad4da8d1d2ca.js +1 -0
  18. package/assets/esri/core/workers/chunks/23a3d8f91caf3136b2aa.js +1 -0
  19. package/assets/esri/core/workers/chunks/{3157f85bb319294878ca.js → 2426601b8cae7f06af4d.js} +2 -2
  20. package/assets/esri/core/workers/chunks/2a1c6df073e6ca6a6365.js +1 -0
  21. package/assets/esri/core/workers/chunks/{a615a644086e98a90579.js → 3f775deea48e268411f1.js} +3 -3
  22. package/assets/esri/core/workers/chunks/{e3623e557ab463580fd2.js → 41e821ce229bc56dc1a1.js} +1 -1
  23. package/assets/esri/core/workers/chunks/{17acbf40e7c1cb42d9bd.js → 44b1cdf28269b4fa8a39.js} +1 -1
  24. package/assets/esri/core/workers/chunks/44e8cd4b3dad777ab0c9.js +1 -0
  25. package/assets/esri/core/workers/chunks/456e616f32e7de696d38.js +1 -0
  26. package/assets/esri/core/workers/chunks/{127b111ee53e4b9184f8.js → 4dcd4a052b40047a9230.js} +1 -1
  27. package/assets/esri/core/workers/chunks/54b9667450d066c6f6ce.js +1 -0
  28. package/assets/esri/core/workers/chunks/{aaa66a04b882b0ba2961.js → 5600fc334d20c4f0c83d.js} +1 -1
  29. package/assets/esri/core/workers/chunks/5dbd8ca7e7b8eb9a0bf7.js +1 -0
  30. package/assets/esri/core/workers/chunks/5e3d5347223f0111f40f.js +1 -0
  31. package/assets/esri/core/workers/chunks/62f3ca0719ac6bc76512.js +1 -0
  32. package/assets/esri/core/workers/chunks/{14c066c31fe37b7f6e63.js → 638ed1297efdb24f4711.js} +1 -1
  33. package/assets/esri/core/workers/chunks/63ede7295938f7010808.js +1 -0
  34. package/assets/esri/core/workers/chunks/687cf21e027f49b44d22.js +1 -0
  35. package/assets/esri/core/workers/chunks/6c98a64d92c9bca78203.js +1 -0
  36. package/assets/esri/core/workers/chunks/{e7402dfd683f82878360.js → 752343d92ed48e674351.js} +1 -1
  37. package/assets/esri/core/workers/chunks/7538a0fe0cec3156769e.js +1 -0
  38. package/assets/esri/core/workers/chunks/{42692a4ce3fb364e321e.js → 763cbb6716e398436a6d.js} +1 -1
  39. package/assets/esri/core/workers/chunks/{d6aad815fc0ee8e24bb5.js → 7ce52b850dd785bfa33f.js} +1 -1
  40. package/assets/esri/core/workers/chunks/{64247e439ef3e1f712e9.js → 7fdd6a5fa062778be55d.js} +1 -1
  41. package/assets/esri/core/workers/chunks/8369edafab7bdc59b95a.js +1 -0
  42. package/assets/esri/core/workers/chunks/{94e9cf8e729ec36de5be.js → 8c535c6a39d2be2ed655.js} +1 -1
  43. package/assets/esri/core/workers/chunks/8e1d4867406753c5483c.js +1 -0
  44. package/assets/esri/core/workers/chunks/92696cce2b980373f9ad.js +1 -0
  45. package/assets/esri/core/workers/chunks/{580451761cadfe308919.js → 9954149def644c371894.js} +1 -1
  46. package/assets/esri/core/workers/chunks/9f65cc6d9f7390bb1d5b.js +1 -0
  47. package/assets/esri/core/workers/chunks/a09ce34fc7c8abe64ed5.js +1 -0
  48. package/assets/esri/core/workers/chunks/{81659d121ed732bda907.js → a12803108c3b12808698.js} +2 -2
  49. package/assets/esri/core/workers/chunks/{83991475aa54fd5aa008.js → a965d151515b76dd7566.js} +1 -1
  50. package/assets/esri/core/workers/chunks/{128799741dd3c6fc69b9.js → ac4131121230cfc14f21.js} +1 -1
  51. package/assets/esri/core/workers/chunks/afeeb11b39e140303b5a.js +1 -0
  52. package/assets/esri/core/workers/chunks/b13d2da33ec07e9d41ff.js +1 -0
  53. package/assets/esri/core/workers/chunks/{33bd9785bd0b6ccef21b.js → b2cf1d3f0d48eac23a84.js} +1 -1
  54. package/assets/esri/core/workers/chunks/{498d29e8c8be4a12ba12.js → b958f87f23f984131d09.js} +1 -1
  55. package/assets/esri/core/workers/chunks/c53b2be005721591e29b.js +1 -0
  56. package/assets/esri/core/workers/chunks/{edf87407dd20685c82ab.js → c82ab4f0908290e70ee9.js} +1 -1
  57. package/assets/esri/core/workers/chunks/{4e2f3dd158a5228c87ba.js → c85ba0700eafdc8d6f9e.js} +1 -1
  58. package/assets/esri/core/workers/chunks/d456520e4b119a2816b6.js +1 -0
  59. package/assets/esri/core/workers/chunks/d83ea3e4e9ab45334068.js +1 -0
  60. package/assets/esri/core/workers/chunks/{4f59357f535f30a6b5cc.js → d9b83d7dd7d1f7729a91.js} +1 -1
  61. package/assets/esri/core/workers/chunks/dbcec48c4ba104a6d0b5.js +1 -0
  62. package/assets/esri/core/workers/chunks/e02f02040b63d9c2e654.js +1 -0
  63. package/assets/esri/core/workers/chunks/e08c64e4ae5a68eae2be.js +1 -0
  64. package/assets/esri/core/workers/chunks/e2ddfc96ddba92302e0c.js +1 -0
  65. package/assets/esri/core/workers/chunks/{61d3fcb419d6bf7e355e.js → e65ee26feca0564aeb9b.js} +1 -1
  66. package/assets/esri/core/workers/chunks/{35cbf00f0c37a86517af.js → ed1de8b7406269e217b9.js} +1 -1
  67. package/assets/esri/core/workers/chunks/ed4ac5568dc2815b066d.js +1 -0
  68. package/assets/esri/core/workers/chunks/f029c12f1afee0e9b2a1.js +1 -0
  69. package/assets/esri/core/workers/chunks/{461c2de938bf4c9b1442.js → f6715b8765cd36d81ec8.js} +1 -1
  70. package/assets/esri/core/workers/chunks/{4fb549f11e176fc2f24a.js → f7fa932ade85cb2847b6.js} +1 -1
  71. package/assets/esri/core/workers/chunks/f9a4f4efd63b8189a4eb.js +1 -0
  72. package/assets/esri/core/workers/chunks/{26a2d4b95cda0a41d980.js → fa1c58e5b582d61a03ab.js} +1 -1
  73. package/assets/esri/core/workers/chunks/fa377112ef3b78f6ed18.js +1 -0
  74. package/chunks/VolumeMask.glsl.js +3 -0
  75. package/chunks/persistableUrlUtils.js +1 -1
  76. package/config.js +1 -1
  77. package/core/Collection.d.ts +42 -6
  78. package/core/Collection.js +1 -1
  79. package/core/screenUtils.js +1 -1
  80. package/geometry/SpatialReference.d.ts +1 -4
  81. package/geometry/support/intersectsBase.js +1 -1
  82. package/interfaces.d.ts +14 -0
  83. package/kernel.js +1 -1
  84. package/layers/BaseElevationLayer.js +1 -1
  85. package/layers/ElevationLayer.js +1 -1
  86. package/layers/IntegratedMesh3DTilesLayer.js +1 -1
  87. package/layers/KnowledgeGraphLayer.js +1 -1
  88. package/layers/Lyr3DWasmPerSceneView.js +1 -1
  89. package/layers/StreamLayer.js +1 -1
  90. package/layers/VoxelWasmPerSceneView.js +1 -1
  91. package/layers/graphics/sources/connections/createConnection.js +1 -1
  92. package/layers/graphics/sources/parquet/ParquetFileStatistics.js +1 -1
  93. package/layers/graphics/sources/support/ParquetSourceWorker.js +1 -1
  94. package/layers/graphics/sources/support/QueryTask.js +1 -1
  95. package/layers/mixins/SceneService.js +1 -1
  96. package/layers/raster/datasets/BaseRaster.js +1 -1
  97. package/layers/save/groupLayerUtils.js +1 -1
  98. package/layers/save/mediaLayerUtils.js +1 -1
  99. package/layers/support/ElevationQueryTileCache.js +1 -1
  100. package/layers/video/types.d.ts +17 -1
  101. package/linkChart/LinkChartProperties.js +1 -1
  102. package/package.json +3 -3
  103. package/popup/FeatureContent.d.ts +311 -0
  104. package/popup/FeatureContent.js +2 -0
  105. package/popup/FeatureContentCollection.d.ts +569 -0
  106. package/popup/FeatureContentCollection.js +2 -0
  107. package/portal/support/jsonContext.js +1 -1
  108. package/support/persistableUrlUtils.js +1 -1
  109. package/support/revision.js +1 -1
  110. package/symbols/cim/CIMSymbolDrawHelper.js +1 -1
  111. package/views/2d/layers/BaseLayerView2D.d.ts +2 -2
  112. package/views/2d/layers/BaseLayerViewGL2D.d.ts +2 -2
  113. package/views/2d/layers/features/sources/strategies/AFeatureLoadStrategy.js +1 -1
  114. package/views/2d/layers/features/sources/strategies/FeatureHybridTileLoadStrategy.js +1 -1
  115. package/views/2d/layers/graphics/GraphicStore.js +1 -1
  116. package/views/2d/support/hitTestUtils.js +1 -1
  117. package/views/3d/GroundView3D.js +1 -1
  118. package/views/3d/analysis/VolumeMeasurement/VolumeMeasurementCutFillController.js +1 -1
  119. package/views/3d/layers/FlowSubView3D.js +1 -1
  120. package/views/3d/layers/I3SMeshView3D.js +1 -1
  121. package/views/3d/layers/IntegratedMesh3DTilesLayerView3D.js +1 -1
  122. package/views/3d/layers/MediaLayerView3D.js +1 -1
  123. package/views/3d/layers/PointCloudLayerView3D.js +1 -1
  124. package/views/3d/layers/graphics/Deconflictor.js +1 -1
  125. package/views/3d/layers/graphics/Graphics3DCore.js +1 -1
  126. package/views/3d/layers/i3s/I3SIntersectionHandler.js +1 -1
  127. package/views/3d/layers/i3s/PointCloudRenderer.js +1 -1
  128. package/views/3d/layers/support/FeatureTileFetcher3D.js +1 -1
  129. package/views/3d/layers/support/HeatmapFeatureProcessor.js +1 -1
  130. package/views/3d/layers/support/Tiles3DMeshIntersectionHandler.js +1 -1
  131. package/views/3d/state/controllers/ZoomStepControllerGlobal.js +1 -1
  132. package/views/3d/state/controllers/ZoomStepControllerLocal.js +1 -1
  133. package/views/3d/state/helpers/SceneIntersectionHelper.js +1 -1
  134. package/views/3d/support/buffer/glUtil.js +1 -1
  135. package/views/3d/support/flow/FlowSubViewTiles3D.js +1 -1
  136. package/views/3d/support/gaussianSplatting/GaussianSplatFadeHelper.js +1 -1
  137. package/views/3d/support/gaussianSplatting/GaussianSplatFadeTexture.js +1 -1
  138. package/views/3d/support/gaussianSplatting/GaussianSplatHeaderTexture.js +1 -1
  139. package/views/3d/support/gaussianSplatting/GaussianSplatIntersectionHandler.js +1 -1
  140. package/views/3d/support/gaussianSplatting/GaussianSplatOrderTexture.js +1 -1
  141. package/views/3d/support/hitTest.js +1 -1
  142. package/views/3d/support/pointsOfInterest/CameraOnSurface.js +1 -1
  143. package/views/3d/support/pointsOfInterest/PointsOfInterest.js +1 -1
  144. package/views/3d/support/pointsOfInterest/StableSurfaceCenter.js +1 -1
  145. package/views/3d/terrain/TerrainRenderer.js +1 -1
  146. package/views/3d/terrain/TerrainSurface.js +1 -1
  147. package/views/3d/webgl-engine/collections/Component/ComponentObjectElevationAgnosticBVH.js +1 -1
  148. package/views/3d/webgl-engine/collections/Component/ComponentObjectFixedBVH.js +1 -1
  149. package/views/3d/webgl-engine/collections/Component/IntersectionGeometry.js +1 -1
  150. package/views/3d/webgl-engine/core/FBOCache.js +1 -1
  151. package/views/3d/webgl-engine/core/FBOCacheUsage.js +1 -1
  152. package/views/3d/webgl-engine/core/shaderLibrary/TextureBackedBufferFields.glsl.js +11 -11
  153. package/views/3d/webgl-engine/effects/focusArea/FocusAreaMask.js +1 -1
  154. package/views/3d/webgl-engine/lib/CutFillVisualization.js +1 -1
  155. package/views/3d/webgl-engine/lib/Intersector.js +1 -1
  156. package/views/3d/webgl-engine/lib/IntersectorResult.js +1 -1
  157. package/views/3d/webgl-engine/lib/PathGeometry.js +1 -1
  158. package/views/3d/webgl-engine/lib/RayIntersections.js +1 -1
  159. package/views/3d/webgl-engine/lib/ShadowAccumulator.js +1 -1
  160. package/views/3d/webgl-engine/lib/SortedRenderGeometryRenderer.js +1 -1
  161. package/views/3d/webgl-engine/lib/TextureBackedBuffer/TextureBackedBuffer.js +1 -1
  162. package/views/3d/webgl-engine/lib/TextureBackedBuffer/TextureBackedBufferFieldCreation.js +1 -1
  163. package/views/3d/webgl-engine/lib/ViewshedShadowMap.js +1 -1
  164. package/views/3d/webgl-engine/lib/lodRendering/LodResources.js +1 -1
  165. package/views/3d/webgl-engine/lib/screenPolygonTriangleIntersections.js +1 -1
  166. package/views/3d/webgl-engine/materials/HUDMaterial.js +1 -1
  167. package/views/3d/webgl-engine/materials/HeatmapDensityMaterial.js +1 -1
  168. package/views/3d/webgl-engine/materials/NativeLineMaterial.js +1 -1
  169. package/views/3d/webgl-engine/materials/PathMaterial.js +1 -1
  170. package/views/3d/webgl-engine/materials/RibbonLineMaterial.js +1 -1
  171. package/views/3d/webgl-engine/materials/intersectWithPolygonOffset.js +1 -1
  172. package/views/3d/webgl-engine/shaders/ShadowCastMaskTechnique.js +1 -1
  173. package/views/3d/webgl-engine/shaders/{CutFillMask.glsl.js → VolumeMask.glsl.js} +1 -1
  174. package/views/3d/webgl-engine/shaders/VolumeMaskTechnique.js +2 -0
  175. package/views/View2D.d.ts +2 -2
  176. package/views/interactive/snapping/featureSources/WorkerTileTreeDebugger.js +1 -1
  177. package/views/webgl/FramebufferObject.js +1 -1
  178. package/webdoc/support/resourceUtils.js +1 -1
  179. package/webdoc/support/types.d.ts +2 -0
  180. package/webdoc/support/utils.js +2 -0
  181. package/webdoc/support/webdocLoadUtils.js +1 -1
  182. package/webdoc/support/webdocSaveUtils.js +1 -1
  183. package/widgets/BatchAttributeForm/BatchAttributeFormViewModel.js +1 -1
  184. package/widgets/BatchAttributeForm/batchAttributeFormUtils.js +1 -1
  185. package/widgets/BatchAttributeForm/expressions/ArcadeExecutorProvider.js +1 -1
  186. package/widgets/BatchAttributeForm/expressions/ExpressionsManager.js +1 -1
  187. package/widgets/BatchAttributeForm/expressions/ExpressionsModel.js +1 -1
  188. package/widgets/BatchAttributeForm/inputs/AttachmentElementInput.js +1 -1
  189. package/widgets/BatchAttributeForm/inputs/BatchFormInputs.js +1 -1
  190. package/widgets/BatchAttributeForm/inputs/FieldInput.js +1 -1
  191. package/widgets/BatchAttributeForm/inputs/RelationshipElementInput.js +1 -1
  192. package/widgets/BatchAttributeForm/inputs/support/inputUtils.js +1 -1
  193. package/widgets/BatchAttributeForm/rendered-content/RelationshipDetails.js +1 -1
  194. package/widgets/BatchAttributeForm/templates/support/createBatchFormTemplate.js +1 -1
  195. package/widgets/BatchAttributeForm.js +1 -1
  196. package/widgets/Editor/UpdateWorkflow.js +1 -1
  197. package/widgets/Editor.js +1 -1
  198. package/widgets/FeatureForm.js +1 -1
  199. package/widgets/FeatureTable/Grid/Column.d.ts +6 -0
  200. package/widgets/Legend/support/ActiveLayerInfo.js +1 -1
  201. package/widgets/Legend/support/heatmapRampUtils.js +1 -1
  202. package/widgets/Sketch/SketchViewModel.js +1 -1
  203. package/widgets/support/SelectionList/FeatureItem.d.ts +116 -0
  204. package/widgets/support/SelectionList/GroupLayerItem.d.ts +94 -0
  205. package/widgets/support/SelectionList/ItemBase.d.ts +70 -0
  206. package/widgets/support/SelectionList/LayerItem.d.ts +140 -0
  207. package/widgets/support/SelectionList/LayerItem.js +1 -1
  208. package/widgets/support/SelectionList/SelectionListViewModel.d.ts +265 -0
  209. package/widgets/support/SelectionList/SelectionListViewModel.js +1 -1
  210. package/widgets/support/SelectionList/types.d.ts +42 -0
  211. package/widgets/support/forms/formUtils.js +1 -1
  212. package/assets/esri/core/workers/chunks/003a87b16f8a4b476e14.js +0 -1
  213. package/assets/esri/core/workers/chunks/0a50efb07eee36237e21.js +0 -1
  214. package/assets/esri/core/workers/chunks/129fdd1636e67997337c.js +0 -1
  215. package/assets/esri/core/workers/chunks/12e0c5b7cc5c3f9e6f0f.js +0 -1
  216. package/assets/esri/core/workers/chunks/26f1fd3f2be5102aae1d.js +0 -1
  217. package/assets/esri/core/workers/chunks/34fbeeeeef4bd01672c6.js +0 -1
  218. package/assets/esri/core/workers/chunks/36fe6adf6517d8f80125.js +0 -1
  219. package/assets/esri/core/workers/chunks/403f08e0c1a9203f7fba.js +0 -1
  220. package/assets/esri/core/workers/chunks/4f2170609742b51bd7b8.js +0 -1
  221. package/assets/esri/core/workers/chunks/5133083222588799493f.js +0 -1
  222. package/assets/esri/core/workers/chunks/52993a9dc0c56e9bda19.js +0 -1
  223. package/assets/esri/core/workers/chunks/5527b2da4abe0faa98bb.js +0 -1
  224. package/assets/esri/core/workers/chunks/5e35828216020f33e26b.js +0 -1
  225. package/assets/esri/core/workers/chunks/5f0d6c853873a7f32527.js +0 -1
  226. package/assets/esri/core/workers/chunks/6121cd0264b6841a5bac.js +0 -1
  227. package/assets/esri/core/workers/chunks/6823ba1688dfedba0107.js +0 -1
  228. package/assets/esri/core/workers/chunks/705d6b108fd121cea887.js +0 -1
  229. package/assets/esri/core/workers/chunks/73aa1bfa6e1dc271c9d7.js +0 -1
  230. package/assets/esri/core/workers/chunks/825eb845216762a1ed2f.js +0 -1
  231. package/assets/esri/core/workers/chunks/88df19742edb0cdc3e67.js +0 -1
  232. package/assets/esri/core/workers/chunks/8977c85aecc7e08ab13c.js +0 -1
  233. package/assets/esri/core/workers/chunks/8bdca809dd88eab9e5d8.js +0 -29
  234. package/assets/esri/core/workers/chunks/8c5726c7ce40a92901e6.js +0 -1
  235. package/assets/esri/core/workers/chunks/8c5e65982c3f9295e844.js +0 -1
  236. package/assets/esri/core/workers/chunks/8ce649e55fefc8eca55c.js +0 -1
  237. package/assets/esri/core/workers/chunks/90ae80b797642bff0efa.js +0 -1
  238. package/assets/esri/core/workers/chunks/97c758f736f28c5dab84.js +0 -1
  239. package/assets/esri/core/workers/chunks/a8ade34612e73862de6f.js +0 -1
  240. package/assets/esri/core/workers/chunks/a9d391071803b1e9e8a0.js +0 -1
  241. package/assets/esri/core/workers/chunks/aa3abc07de2921ef6ca1.js +0 -1
  242. package/assets/esri/core/workers/chunks/b03f09ee2224f0cc526a.js +0 -1
  243. package/assets/esri/core/workers/chunks/b3f1a442d6b7826e917f.js +0 -1
  244. package/assets/esri/core/workers/chunks/b819a9187426d0c146df.js +0 -1
  245. package/assets/esri/core/workers/chunks/d205edd949f3e6e24eb9.js +0 -1
  246. package/assets/esri/core/workers/chunks/f0225829f7d941914815.js +0 -1
  247. package/assets/esri/core/workers/chunks/fb34d6d96c8c0d53fcf6.js +0 -1
  248. package/chunks/CutFillMask.glsl.js +0 -3
  249. package/chunks/FocusAreaMask.glsl.js +0 -3
  250. package/views/3d/webgl-engine/effects/focusArea/FocusAreaMask.glsl.js +0 -2
  251. package/views/3d/webgl-engine/effects/focusArea/FocusAreaMaskTechnique.js +0 -2
  252. package/views/3d/webgl-engine/shaders/CutFillMaskTechnique.js +0 -2
  253. /package/assets/esri/core/workers/chunks/{81659d121ed732bda907.js.LICENSE.txt → a12803108c3b12808698.js.LICENSE.txt} +0 -0
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import e from"../../../../core/Logger.js";import{clamp as r}from"../../../../core/mathUtils.js";import{createRenderScreenPointArray3 as t,createScreenPointArray as o}from"../../../../core/screenUtils.js";import{copy as i,set as s}from"../../../../core/libs/gl-matrix-2/math/vec2.js";import{create as n}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{set as a,subtract as c,dot as l,scale as f,add as m,copy as u,length as p,distance as g}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as h}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{ONES as d}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{distance2 as j,fromPoints as b,closestLineSegmentPoint as y,projectPoint as v,create as x}from"../../../../geometry/support/lineSegment.js";import{fromPoints as S,signedDistance as L,getNormal as w,create as M}from"../../../../geometry/support/plane.js";import{isColorHighlightOrOLID as P}from"../core/shaderLibrary/ShaderOutput.js";import T from"../lib/GLMaterial.js";import{Material as C,MaterialParameters as R}from"../lib/Material.js";import{projectWorldLineSegmentToRenderScreen as V,screenPolygonIntersectsBufferedSegment as _}from"../lib/screenPolygonOverlapUtils.js";import{Hit as A,DrapedHit as N}from"../lib/screenPolygonTriangleIntersections.js";import{isTranslationMatrix as U}from"../lib/Util.js";import{DefaultBufferWriter as D}from"./DefaultBufferWriter.js";import{PositionColorLayout as E,PositionLayout as O}from"./DefaultLayouts.js";import{NativeLineTechnique as q}from"../shaders/NativeLineTechnique.js";import{NativeLineTechniqueConfiguration as B}from"../shaders/NativeLineTechniqueConfiguration.js";import{alphaCutoff as W}from"../../../../webscene/support/AlphaCutoff.js";class X extends C{constructor(e){super(e,k),this._configuration=new B,this.produces=new Map([[2,e=>P(e)]])}updateConfiguration(e){super.updateConfiguration(e),this._configuration.hasSlicePlane=this.parameters.hasSlicePlane,this._configuration.hasVertexColors=this.parameters.hasVertexColors,this._configuration.transparent=this.parameters.color[3]<1||this.parameters.width<1,this._configuration.hasOccludees=e.hasOccludees}get visible(){return this.parameters.color[3]>=W}intersectRay(r,t,o,s,n,h){const{options:d,camera:v,rayBegin:x,rayEnd:M}=o;if(!d.selectionMode||!r.visible||!v)return;if(!U(t))return void e.getLogger("esri.views.3d.webgl-engine.materials.NativeLineMaterial").error("intersection assumes a translation-only matrix");const P=r.attributes.get("position").data,T=oe;i(T,o.point);const C=ge*v.pixelRatio;a(ce[0],T[0]-C,T[1]+C,0),a(ce[1],T[0]+C,T[1]+C,0),a(ce[2],T[0]+C,T[1]-C,0),a(ce[3],T[0]-C,T[1]-C,0);for(let e=0;e<4;e++)if(!v.unprojectFromRenderScreen(ce[e],le[e]))return;S(v.eye,le[0],le[1],fe),S(v.eye,le[1],le[2],me),S(v.eye,le[2],le[3],ue),S(v.eye,le[3],le[0],pe);let R=Number.MAX_VALUE,V=0;for(const e of G(H,J,P,t)){if(L(fe,H)<0&&L(fe,J)<0||L(me,H)<0&&L(me,J)<0||L(ue,H)<0&&L(ue,J)<0||L(pe,H)<0&&L(pe,J)<0)continue;const r=v.projectToRenderScreen(H,Y),t=v.projectToRenderScreen(J,Z);if(null==r||null==t)continue;if(r[2]<0&&t[2]>0){c(K,H,J);const e=v.frustum,t=-L(e[4],H)/l(K,w(e[4]));if(f(K,K,t),m(H,H,K),!v.projectToRenderScreen(H,r))continue}else if(r[2]>0&&t[2]<0){c(K,J,H);const e=v.frustum,r=-L(e[4],J)/l(K,w(e[4]));if(f(K,K,r),m(J,J,K),!v.projectToRenderScreen(J,t))continue}else if(r[2]<0&&t[2]<0)continue;r[2]=0,t[2]=0;const o=j(b(r,t,re),T);o<R&&(R=o,u($,H),u(ee,J),V=e)}if(R<C*C){let e=Number.MAX_VALUE;if(y(b($,ee,re),b(x,M,te),Q)){c(Q,Q,x);const r=p(Q);f(Q,Q,1/r),e=r/g(x,M)}h(e,Q,V)}}intersectScreenPolygon(r,t,o,i){const{options:s,camera:n,screenPolygonPrimitiveProcessor:a}=o;if(!s.selectionMode||!r.visible)return null;if(!U(t))return e.getLogger("esri.views.3d.webgl-engine.materials.NativeLineMaterial").error("intersection assumes a translation-only matrix"),null;const c=r.attributes.get("position").data,l=new A(4);for(const e of G(H,J,c,t))for(const[r,t]of a.processLineSegment(he,H,J))V(n,r,t,Y,Z)&&(n.renderToScreen(Y,ie),n.renderToScreen(Z,se),_(i,ie,se,ge)&&(v(b(r,t,te),n.eye,oe),l.updateIfCloserFromValues(g(n.eye,oe),e,oe,null)));return l}intersectRayDraped(e,t,o,i,s){if(!t.options.selectionMode)return;const n=o[0],a=o[1],c=I(e);let l=Number.MAX_VALUE,f=0;for(const m of z(ne,ae,e)){const e=n-ne[0],t=a-ne[1],o=ae[0]-ne[0],i=ae[1]-ne[1],s=r((o*e+i*t)/(o*o+i*i),0,1),c=o*s-e,u=i*s-t,p=c*c+u*u;p<l&&(l=p,f=m)}l<c*c&&i(s.distance,s.normal,f)}intersectScreenPolygonDraped(e,r,t,o){if(!t.options.selectionMode)return null;const i=I(e);for(const s of z(ne,ae,e,r))if(_(o,ne,ae,i))return new N(s);return null}createGLMaterial(e){return new F(e)}createBufferWriter(){const e=this.parameters.hasVertexColors?E:O;return new D(e)}}class F extends T{beginSlot(e){return this.getTechnique(q,e)}}function*G(e,r,t,o){for(let i=0;i<t.length-5;i+=3)e[0]=t[i]+o[12],e[1]=t[i+1]+o[13],e[2]=t[i+2]+o[14],r[0]=t[i+3]+o[12],r[1]=t[i+4]+o[13],r[2]=t[i+5]+o[14],yield i/3}function I(e){const r=e.attributes.get("size");return(((r?r.data[0]:0)+1)/2+4)*e.screenToWorldRatio}function*z(e,r,t,o){const n=t.attributes.get("position").data,a=o?.[0]??0,c=o?.[1]??0;s(e,n[0]+a,n[1]+c);for(let l=3;l<n.length-2;l+=3){const t=l%n.length;s(r,n[t]+a,n[t+1]+c),yield l/3,i(e,r)}}class k extends R{constructor(){super(...arguments),this.color=d,this.hasVertexColors=!1,this.hasSlicePlane=!1,this.width=1}}const H=h(),J=h(),K=h(),Q=h(),Y=t(),Z=t(),$=h(),ee=h(),re=x(),te=x(),oe=h(),ie=o(),se=o(),ne=n(),ae=n(),ce=[t(),t(),t(),t()],le=[h(),h(),h(),h()],fe=M(),me=M(),ue=M(),pe=M(),ge=2,he=[h(),h()];export{X as NativeLineMaterial,k as Parameters};
2
+ import e from"../../../../core/Logger.js";import{clamp as r}from"../../../../core/mathUtils.js";import{createRenderScreenPointArray3 as t,createScreenPointArray as o}from"../../../../core/screenUtils.js";import{copy as i,set as s}from"../../../../core/libs/gl-matrix-2/math/vec2.js";import{create as n}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{set as a,subtract as c,dot as l,scale as f,add as m,copy as u,length as p,distance as g}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as h}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{ONES as d}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{distance2 as j,fromPoints as b,closestLineSegmentPoint as y,projectPoint as v,create as x}from"../../../../geometry/support/lineSegment.js";import{fromPoints as S,signedDistance as L,getNormal as w,create as M}from"../../../../geometry/support/plane.js";import{isColorHighlightOrOLID as P}from"../core/shaderLibrary/ShaderOutput.js";import T from"../lib/GLMaterial.js";import{Material as C,MaterialParameters as R}from"../lib/Material.js";import{projectWorldLineSegmentToRenderScreen as V,screenPolygonIntersectsBufferedSegment as _}from"../lib/screenPolygonOverlapUtils.js";import{Hit as A,DrapedHit as N}from"../lib/screenPolygonTriangleIntersections.js";import{isTranslationMatrix as U}from"../lib/Util.js";import{DefaultBufferWriter as D}from"./DefaultBufferWriter.js";import{PositionColorLayout as E,PositionLayout as O}from"./DefaultLayouts.js";import{NativeLineTechnique as q}from"../shaders/NativeLineTechnique.js";import{NativeLineTechniqueConfiguration as B}from"../shaders/NativeLineTechniqueConfiguration.js";import{alphaCutoff as W}from"../../../../webscene/support/AlphaCutoff.js";class X extends C{constructor(e){super(e,k),this._configuration=new B,this.produces=new Map([[2,e=>P(e)]])}updateConfiguration(e){super.updateConfiguration(e),this._configuration.hasSlicePlane=this.parameters.hasSlicePlane,this._configuration.hasVertexColors=this.parameters.hasVertexColors,this._configuration.transparent=this.parameters.color[3]<1||this.parameters.width<1,this._configuration.hasOccludees=e.hasOccludees}get visible(){return this.parameters.color[3]>=W}intersectRay(r,t,o,s,n,h){const{options:d,camera:v,rayBegin:x,rayEnd:M}=o;if(!d.selectionMode||!r.visible||!v)return;if(!U(t))return void e.getLogger("esri.views.3d.webgl-engine.materials.NativeLineMaterial").error("intersection assumes a translation-only matrix");const P=r.attributes.get("position").data,T=oe;i(T,o.point);const C=ge*v.pixelRatio;a(ce[0],T[0]-C,T[1]+C,0),a(ce[1],T[0]+C,T[1]+C,0),a(ce[2],T[0]+C,T[1]-C,0),a(ce[3],T[0]-C,T[1]-C,0);for(let e=0;e<4;e++)if(!v.unprojectFromRenderScreen(ce[e],le[e]))return;S(v.eye,le[0],le[1],fe),S(v.eye,le[1],le[2],me),S(v.eye,le[2],le[3],ue),S(v.eye,le[3],le[0],pe);let R=Number.MAX_VALUE,V=0;for(const e of G(H,J,P,t)){if(L(fe,H)<0&&L(fe,J)<0||L(me,H)<0&&L(me,J)<0||L(ue,H)<0&&L(ue,J)<0||L(pe,H)<0&&L(pe,J)<0)continue;const r=v.projectToRenderScreen(H,Y),t=v.projectToRenderScreen(J,Z);if(null==r||null==t)continue;if(r[2]<0&&t[2]>0){c(K,H,J);const e=v.frustum,t=-L(e[4],H)/l(K,w(e[4]));if(f(K,K,t),m(H,H,K),!v.projectToRenderScreen(H,r))continue}else if(r[2]>0&&t[2]<0){c(K,J,H);const e=v.frustum,r=-L(e[4],J)/l(K,w(e[4]));if(f(K,K,r),m(J,J,K),!v.projectToRenderScreen(J,t))continue}else if(r[2]<0&&t[2]<0)continue;r[2]=0,t[2]=0;const o=j(b(r,t,re),T);o<R&&(R=o,u($,H),u(ee,J),V=e)}if(R<C*C){let e=Number.MAX_VALUE;if(y(b($,ee,re),b(x,M,te),Q)){c(Q,Q,x);const r=p(Q);f(Q,Q,1/r),e=r/g(x,M)}h(e,e,Q,V)}}intersectScreenPolygon(r,t,o,i){const{options:s,camera:n,screenPolygonPrimitiveProcessor:a}=o;if(!s.selectionMode||!r.visible)return null;if(!U(t))return e.getLogger("esri.views.3d.webgl-engine.materials.NativeLineMaterial").error("intersection assumes a translation-only matrix"),null;const c=r.attributes.get("position").data,l=new A(4);for(const e of G(H,J,c,t))for(const[r,t]of a.processLineSegment(he,H,J))V(n,r,t,Y,Z)&&(n.renderToScreen(Y,ie),n.renderToScreen(Z,se),_(i,ie,se,ge)&&(v(b(r,t,te),n.eye,oe),l.updateIfCloserFromValues(g(n.eye,oe),e,oe,null)));return l}intersectRayDraped(e,t,o,i,s){if(!t.options.selectionMode)return;const n=o[0],a=o[1],c=I(e);let l=Number.MAX_VALUE,f=0;for(const m of z(ne,ae,e)){const e=n-ne[0],t=a-ne[1],o=ae[0]-ne[0],i=ae[1]-ne[1],s=r((o*e+i*t)/(o*o+i*i),0,1),c=o*s-e,u=i*s-t,p=c*c+u*u;p<l&&(l=p,f=m)}l<c*c&&i(s.distance,s.renderDistance,s.normal,f)}intersectScreenPolygonDraped(e,r,t,o){if(!t.options.selectionMode)return null;const i=I(e);for(const s of z(ne,ae,e,r))if(_(o,ne,ae,i))return new N(s);return null}createGLMaterial(e){return new F(e)}createBufferWriter(){const e=this.parameters.hasVertexColors?E:O;return new D(e)}}class F extends T{beginSlot(e){return this.getTechnique(q,e)}}function*G(e,r,t,o){for(let i=0;i<t.length-5;i+=3)e[0]=t[i]+o[12],e[1]=t[i+1]+o[13],e[2]=t[i+2]+o[14],r[0]=t[i+3]+o[12],r[1]=t[i+4]+o[13],r[2]=t[i+5]+o[14],yield i/3}function I(e){const r=e.attributes.get("size");return(((r?r.data[0]:0)+1)/2+4)*e.screenToWorldRatio}function*z(e,r,t,o){const n=t.attributes.get("position").data,a=o?.[0]??0,c=o?.[1]??0;s(e,n[0]+a,n[1]+c);for(let l=3;l<n.length-2;l+=3){const t=l%n.length;s(r,n[t]+a,n[t+1]+c),yield l/3,i(e,r)}}class k extends R{constructor(){super(...arguments),this.color=d,this.hasVertexColors=!1,this.hasSlicePlane=!1,this.width=1}}const H=h(),J=h(),K=h(),Q=h(),Y=t(),Z=t(),$=h(),ee=h(),re=x(),te=x(),oe=h(),ie=o(),se=o(),ne=n(),ae=n(),ce=[t(),t(),t(),t()],le=[h(),h(),h(),h()],fe=M(),me=M(),ue=M(),pe=M(),ge=2,he=[h(),h()];export{X as NativeLineMaterial,k as Parameters};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{BufferViewUint32 as t,BufferViewVec3f as e,BufferViewVec2Snorm16 as i,BufferViewSnorm16 as r,BufferViewFloat16 as s,BufferViewFloat as o,BufferViewVec2f as a,BufferViewVec4Unorm8 as n,BufferViewUnorm8 as h}from"../../../../geometry/support/buffer/BufferView.js";import{maxPathFrameIndex as c}from"../../layers/graphics/Graphics3DPathSymbolLayerConstants.js";import{isShadowLike as u,is3DGeometry as f,isColor as p}from"../core/shaderLibrary/ShaderOutput.js";import{olidEnabled as l}from"../effects/geometry/olidUtils.js";import g from"../lib/GLMaterial.js";import{isPathGeometry as m}from"../lib/PathGeometry.js";import{offsetPathVertexInfoFrameIndex as d}from"../lib/PathVertexInfo.js";import{MeshIntersectionOptions as y,intersectAabbInvDir as b}from"../lib/RayIntersections.js";import{assert as _}from"../lib/Util.js";import{applyPolygonOffsetToHit as S}from"./intersectWithPolygonOffset.js";import{getLayout as w,getTextureLayout as F}from"./PathLayouts.js";import{PathPassParameters as P,PathTechnique as V}from"./PathTechnique.js";import{PathTechniqueConfiguration as x}from"./PathTechniqueConfiguration.js";import{TriangleMaterial as C}from"./TriangleMaterial.js";import{writeAttributes as R,writePosition as j,writeBufferVec2 as z,writeBufferInt16 as O,writeBufferFloat16 as B,writeBufferFloat as v,writeColor as A,writeBufferUint8 as T,writeOlidColor as M}from"./internal/bufferWriterUtils.js";import{hasShadowHighlights as I}from"../shaders/ReceiveShadowsConfiguration.js";import{alphaCutoff as U}from"../../../../webscene/support/AlphaCutoff.js";class L extends C{constructor(t,e){super(t,D),this.supportsEdges=!0,this.produces=new Map([[2,t=>(this.parameters.castShadows&&u(t)||f(t))&&!this.transparent],[4,t=>(this.parameters.castShadows&&u(t)||f(t))&&this.transparent]]),this._configuration=new x(e.spherical)}get emissions(){return this.parameters.emissiveStrength>0?this.transparent?2:1:0}updateConfiguration(t){super.updateConfiguration(t),this._configuration.hasVVSize=this.parameters.hasVVSize,this._configuration.hasVVColor=this.parameters.hasVVColor,this._configuration.hasVVOpacity=this.parameters.hasVVOpacity,this._configuration.hasSlicePlane=this.parameters.hasSlicePlane,this._configuration.transparent=this.transparent,this._configuration.hasOccludees=t.hasOccludees,this._configuration.cullFace=this.parameters.hasSlicePlane?0:this.parameters.cullFace,this._configuration.offsetBackfaces=this.transparent,p(t.output)?(this._configuration.receiveShadows=t.shadowMap.enabled,this._configuration.hasShadowHighlights=I(this._configuration,t),this._configuration.receiveAmbientOcclusion=null!=t.ssao):this._configuration.receiveShadows=this._configuration.hasShadowHighlights=this._configuration.receiveAmbientOcclusion=!1,this._configuration.pbrMode=this.parameters.usePBR?2:0,this._configuration.emissionSource=this.parameters.usePBR?1:0,this._configuration.snowCover=t.snowCover>0,this._configuration.upVectorAlignment=this.parameters.upVectorAlignment,this._configuration.pathCapType=this.parameters.pathCapType,this._configuration.pathProfileType=this.parameters.profile.type,this._configuration.hasPathSize=this.parameters.hasPathSize,this._configuration.hasPathColor=this.parameters.hasPathColor,this._configuration.hasPathOpacity=this.parameters.hasPathOpacity}isVisibleForOutput(t){return 5!==t&&7!==t&&6!==t||this.parameters.castShadows}get visible(){return this.parameters.opacity>=U}intersectRay(t,e,i,r,s,o){this._intersectRay(t,i,r,s,o)}intersectRayDraped(){}intersectScreenPolygonDraped(){return null}intersectScreenPolygon(t,e,i,r){return m(t)?S(t.intersectScreenPolygon(i,e,r),this._configuration,i.camera.eye):null}_intersectRay(t,e,i,r,s){if(!m(t))return;const o=new y(e.tolerance,!1,e.options.normalRequired),a=t.boundingInfo;if(null==a)return void t.intersectRay(i,r,o,s);const n=a.box,h=[r[0]-i[0],r[1]-i[1],r[2]-i[2]],c=Math.sqrt(h[0]*h[0]+h[1]*h[1]+h[2]*h[2]),u=[c/h[0],c/h[1],c/h[2]];b(n,i,u,e.tolerance)&&t.intersectRay(i,r,o,s)}createBufferWriter(){return new G(w(),F(this.parameters))}createGLMaterial(t){return new q(t)}get transparent(){const{parameters:t}=this;return t.drivenOpacity||t.opacity<1}}class q extends g{beginSlot(t){return this.getTechnique(V,t)}}class D extends P{constructor(){super(...arguments),this.polygonOffset=0,this.castShadows=!0,this.hasSlicePlane=!1,this.drivenOpacity=!1,this.usePBR=!1,this.upVectorAlignment=0,this.pathCapType=1,this.cullFace=2}}class G{constructor(t,e){this.layout=t,this.textureBufferLayout=e,this.maxTextureBufferItemIndex=c}elementCount(t){return t.get("pathVertexInfo")?.indices.length??0}elementCountTextureBuffer(t){return t.get("position")?.indices.length??0}write(t,e,i,r,s,o,a){null!=s&&this._writeVertexBuffer(t,e,i,s,o),null!=a&&this._writeTextureBuffer(t,i,r,a)}_writeVertexBuffer(e,i,r,s,o){R(r,null,this.layout,e,i,s);const a=o?.from??0,n=s.buffer.getField("pathVertexInfo",t),h=r.get("pathVertexInfo");if(n&&h){_(1===h.size);const{data:t,stride:e,indices:i}=h;for(let r=0;r<i.length;++r){const o=t[e*i[r]];n.set(s.offset+r,d(o,a))}}}_writeTextureBuffer(t,c,u,f){const p=f.offset,g=f.buffer.getField("position",e),m=c.get("position");g&&m&&(_(3===m.size),j(m,t,g,p));const d=f.buffer.getField("profileRight",i),y=c.get("profileRight");d&&y&&(_(2===y.size),z(y,d,p));const b=f.buffer.getField("profileUp",i),S=c.get("profileUp");b&&S&&(_(2===S.size),z(S,b,p));const w=f.buffer.getField("profileRotation",r),F=c.get("profileRotation");w&&F&&(_(1===F.size),O(F,w,p));const P=f.buffer.getField("pathRotationUp",i),V=c.get("pathRotationUp");P&&V&&(_(2===V.size),z(V,P,p));const x=f.buffer.getField("pathMaxStretchDistance",s),C=c.get("pathMaxStretchDistance");x&&C&&(_(1===C.size),B(C,x,p));const R=f.buffer.getField("sizeFeatureAttribute",o),I=c.get("sizeFeatureAttribute");R&&I&&v(I,R,p);const U=f.buffer.getField("size",a),L=c.get("size");U&&L&&(_(2===L.size),z(L,U,p));const q=f.buffer.getField("colorFeatureAttribute",o),D=c.get("colorFeatureAttribute");q&&D&&v(D,q,p);const G=f.buffer.getField("color",n),W=c.get("color");G&&W&&A(W,4,G,p);const H=f.buffer.getField("opacityFeatureAttribute",o),k=c.get("opacityFeatureAttribute");H&&k&&v(k,H,p);const E=f.buffer.getField("opacity",h),J=c.get("opacity");if(E&&J&&(_(1===J.size),T(J,E,p)),l()){const t=f.buffer.getField("olidColor",n),e=m?.indices.length??0;u&&t&&e&&M(u,t,e,p)}}}export{D as Parameters,G as PathBufferWriter,L as PathMaterial};
2
+ import{BufferViewUint32 as t,BufferViewVec3f as e,BufferViewVec2Snorm16 as i,BufferViewSnorm16 as r,BufferViewFloat16 as s,BufferViewFloat as o,BufferViewVec2f as a,BufferViewVec4Unorm8 as n,BufferViewUnorm8 as h}from"../../../../geometry/support/buffer/BufferView.js";import{maxPathFrameIndex as c}from"../../layers/graphics/Graphics3DPathSymbolLayerConstants.js";import{isShadowLike as u,is3DGeometry as f,isColor as p}from"../core/shaderLibrary/ShaderOutput.js";import{olidEnabled as l}from"../effects/geometry/olidUtils.js";import g from"../lib/GLMaterial.js";import{offsetPathVertexInfoFrameIndex as m}from"../lib/PathVertexInfo.js";import{intersectTriangleGeometry as d}from"../lib/RayIntersections.js";import{intersectTriangleGeometryScreenPolygon as b}from"../lib/screenPolygonTriangleIntersections.js";import{assert as y}from"../lib/Util.js";import{applyPolygonOffsetToHit as _}from"./intersectWithPolygonOffset.js";import{getLayout as S,getTextureLayout as F}from"./PathLayouts.js";import{PathPassParameters as w,PathTechnique as P}from"./PathTechnique.js";import{PathTechniqueConfiguration as V}from"./PathTechniqueConfiguration.js";import{TriangleMaterial as x}from"./TriangleMaterial.js";import{writeAttributes as C,writePosition as j,writeBufferVec2 as z,writeBufferInt16 as O,writeBufferFloat16 as B,writeBufferFloat as R,writeColor as T,writeBufferUint8 as A,writeOlidColor as v}from"./internal/bufferWriterUtils.js";import{hasShadowHighlights as I}from"../shaders/ReceiveShadowsConfiguration.js";import{alphaCutoff as M}from"../../../../webscene/support/AlphaCutoff.js";class U extends x{constructor(t,e){super(t,D),this.supportsEdges=!0,this.produces=new Map([[2,t=>(this.parameters.castShadows&&u(t)||f(t))&&!this.transparent],[4,t=>(this.parameters.castShadows&&u(t)||f(t))&&this.transparent]]),this._configuration=new V(e.spherical)}get emissions(){return this.parameters.emissiveStrength>0?this.transparent?2:1:0}updateConfiguration(t){super.updateConfiguration(t),this._configuration.hasVVSize=this.parameters.hasVVSize,this._configuration.hasVVColor=this.parameters.hasVVColor,this._configuration.hasVVOpacity=this.parameters.hasVVOpacity,this._configuration.hasSlicePlane=this.parameters.hasSlicePlane,this._configuration.transparent=this.transparent,this._configuration.hasOccludees=t.hasOccludees,this._configuration.cullFace=this.parameters.hasSlicePlane?0:this.parameters.cullFace,this._configuration.offsetBackfaces=this.transparent,p(t.output)?(this._configuration.receiveShadows=t.shadowMap.enabled,this._configuration.hasShadowHighlights=I(this._configuration,t),this._configuration.receiveAmbientOcclusion=null!=t.ssao):this._configuration.receiveShadows=this._configuration.hasShadowHighlights=this._configuration.receiveAmbientOcclusion=!1,this._configuration.pbrMode=this.parameters.usePBR?2:0,this._configuration.emissionSource=this.parameters.usePBR?1:0,this._configuration.snowCover=t.snowCover>0,this._configuration.upVectorAlignment=this.parameters.upVectorAlignment,this._configuration.pathCapType=this.parameters.pathCapType,this._configuration.pathProfileType=this.parameters.profile.type,this._configuration.hasPathSize=this.parameters.hasPathSize,this._configuration.hasPathColor=this.parameters.hasPathColor,this._configuration.hasPathOpacity=this.parameters.hasPathOpacity}isVisibleForOutput(t){return 5!==t&&7!==t&&6!==t||this.parameters.castShadows}get visible(){return this.parameters.opacity>=M}intersectRay(t,e,i,r,s,o){d(t,i,r,s,null,o)}intersectRayDraped(){}intersectScreenPolygonDraped(){return null}intersectScreenPolygon(t,e,i,r){return _(b(t,i,e,r,null),this._configuration,i.camera.eye)}createBufferWriter(){return new q(S(),F(this.parameters))}createGLMaterial(t){return new L(t)}get transparent(){const{parameters:t}=this;return t.drivenOpacity||t.opacity<1}}class L extends g{beginSlot(t){return this.getTechnique(P,t)}}class D extends w{constructor(){super(...arguments),this.polygonOffset=0,this.castShadows=!0,this.hasSlicePlane=!1,this.drivenOpacity=!1,this.usePBR=!1,this.upVectorAlignment=0,this.pathCapType=1,this.cullFace=2}}class q{constructor(t,e){this.layout=t,this.textureBufferLayout=e,this.maxTextureBufferItemIndex=c}elementCount(t){return t.get("pathVertexInfo")?.indices.length??0}elementCountTextureBuffer(t){return t.get("position")?.indices.length??0}write(t,e,i,r,s,o,a){null!=s&&this._writeVertexBuffer(t,e,i,s,o),null!=a&&this._writeTextureBuffer(t,i,r,a)}_writeVertexBuffer(e,i,r,s,o){C(r,null,this.layout,e,i,s);const a=o?.from??0,n=s.buffer.getField("pathVertexInfo",t),h=r.get("pathVertexInfo");if(n&&h){y(1===h.size);const{data:t,stride:e,indices:i}=h;for(let r=0;r<i.length;++r){const o=t[e*i[r]];n.set(s.offset+r,m(o,a))}}}_writeTextureBuffer(t,c,u,f){const p=f.offset,g=f.buffer.getField("position",e),m=c.get("position");g&&m&&(y(3===m.size),j(m,t,g,p));const d=f.buffer.getField("profileRight",i),b=c.get("profileRight");d&&b&&(y(2===b.size),z(b,d,p));const _=f.buffer.getField("profileUp",i),S=c.get("profileUp");_&&S&&(y(2===S.size),z(S,_,p));const F=f.buffer.getField("profileRotation",r),w=c.get("profileRotation");F&&w&&(y(1===w.size),O(w,F,p));const P=f.buffer.getField("pathRotationUp",i),V=c.get("pathRotationUp");P&&V&&(y(2===V.size),z(V,P,p));const x=f.buffer.getField("pathMaxStretchDistance",s),C=c.get("pathMaxStretchDistance");x&&C&&(y(1===C.size),B(C,x,p));const I=f.buffer.getField("sizeFeatureAttribute",o),M=c.get("sizeFeatureAttribute");I&&M&&R(M,I,p);const U=f.buffer.getField("size",a),L=c.get("size");U&&L&&(y(2===L.size),z(L,U,p));const D=f.buffer.getField("colorFeatureAttribute",o),q=c.get("colorFeatureAttribute");D&&q&&R(q,D,p);const G=f.buffer.getField("color",n),W=c.get("color");G&&W&&T(W,4,G,p);const H=f.buffer.getField("opacityFeatureAttribute",o),k=c.get("opacityFeatureAttribute");H&&k&&R(k,H,p);const E=f.buffer.getField("opacity",h),J=c.get("opacity");if(E&&J&&(y(1===J.size),A(J,E,p)),l()){const t=f.buffer.getField("olidColor",n),e=m?.indices.length??0;u&&t&&e&&v(u,t,e,p)}}}export{D as Parameters,q as PathBufferWriter,U as PathMaterial};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import e from"../../../../core/Logger.js";import{clamp as t}from"../../../../core/mathUtils.js";import{createRenderScreenPointArray3 as r,createScreenPointArray as i}from"../../../../core/screenUtils.js";import{secondsFromMilliseconds as s,Seconds as n}from"../../../../core/time.js";import{copy as o,set as a}from"../../../../core/libs/gl-matrix-2/math/vec2.js";import{create as l}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{set as c,subtract as p,dot as u,scale as m,add as h,copy as f,length as d,distance as g,lerp as _,transformMat4 as b,normalize as S}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as P}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{ONES as y}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{makeFloat16Array as v}from"../../../../geometry/support/float16.js";import{create as w,fromPoints as E,distance2 as x,closestLineSegmentPoint as T,projectPoint as j,projectPointFraction as L}from"../../../../geometry/support/lineSegment.js";import{create as z,fromPoints as C,signedDistance as A,getNormal as M}from"../../../../geometry/support/plane.js";import{BufferViewVec3f as R,BufferViewFloat as V,BufferViewVec4Unorm8 as F,BufferViewVec4f16 as O,BufferViewUint32 as B}from"../../../../geometry/support/buffer/BufferView.js";import{isHighlightOrOLID as U,isColor as I,isDepth as N,isColorHighlightOLIDOrDepth as W,is2DGeometryOutput as k}from"../core/shaderLibrary/ShaderOutput.js";import{olidEnabled as D}from"../effects/geometry/olidUtils.js";import Y from"../lib/GLMaterial.js";import{Material as J}from"../lib/Material.js";import{projectWorldLineSegmentToRenderScreen as q,screenPolygonIntersectsBufferedSegment as X}from"../lib/screenPolygonOverlapUtils.js";import{Hit as G,DrapedHit as H}from"../lib/screenPolygonTriangleIntersections.js";import{ScreenSizePerspectiveEvaluator as K}from"../lib/screenSizePerspectiveUtils.js";import{isTranslationMatrix as Q,assert as Z}from"../lib/Util.js";import{isImagePattern as $}from"./lineStippleUtils.js";import{VisualVariablePassParameters as ee}from"./VisualVariablePassParameters.js";import{writeOlidColor as te}from"./internal/bufferWriterUtils.js";import{r as re}from"../../../../chunks/RibbonLine.glsl.js";import{getLayout as ie,getTextureBufferLayout as se}from"../shaders/RibbonLineLayouts.js";import{RibbonLineTechnique as ne}from"../shaders/RibbonLineTechnique.js";import{RibbonLineTechniqueConfiguration as oe}from"../shaders/RibbonLineTechniqueConfiguration.js";import{alphaCutoff as ae}from"../../../../webscene/support/AlphaCutoff.js";class le extends J{constructor(e,t){super(e,pe),this.produces=new Map([[2,e=>U(e)||I(e)&&8===this.parameters.renderOccluded],[3,e=>N(e)],[10,e=>W(e)&&8===this.parameters.renderOccluded],[11,e=>W(e)&&8===this.parameters.renderOccluded],[4,e=>I(e)&&this.parameters.writeDepth&&8!==this.parameters.renderOccluded],[8,e=>I(e)&&!this.parameters.writeDepth&&8!==this.parameters.renderOccluded],[18,e=>k(e)]]),this._configuration=new oe(t)}updateConfiguration(e){super.updateConfiguration(e);const t=18===e.slot,r=null!=this.parameters.stipplePattern&&null!=this.parameters.stippleTexture&&10!==e.output,i=r&&t&&this.parameters.isImagePattern();this._configuration.draped=t,this._configuration.polygonOffset=this.parameters.polygonOffset,this._configuration.stippleEnabled=r,this._configuration.stippleOffColorEnabled=r&&null!=this.parameters.stippleOffColor,this._configuration.stipplePreferContinuous=r&&this.parameters.stipplePreferContinuous,this._configuration.numJoinSubdivisions=_e(this.parameters.join,r),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&&ge(this.parameters.markerParameters),this._configuration.polygonOffsetIndex=this.parameters.polygonOffsetIndex,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.wireframe=this.parameters.wireframe,this._configuration.animation=this.parameters.animation,this._configuration.emissionSource=this.emissions?1:0,this._configuration.hasScreenSizePerspective=!!this.parameters.screenSizePerspective&&!i,this._configuration.worldSizedImagePattern=i}get visible(){return this.parameters.color[3]>=ae||null!=this.parameters.stipplePattern&&(this.parameters.stippleOffColor?.[3]??0)>ae}get emissions(){return this.parameters.emissiveStrength>0?8!==this.parameters.renderOccluded?2:1:0}setParameters(e,t){e.animation=this.parameters.animation,super.setParameters(e,t)}intersectRayDraped({attributes:e,screenToWorldRatio:r},i,s,n,o){if(!i.options.selectionMode)return;const a=this._getLineSize(e,!0),l=s[0],c=s[1],p=fe(a,r);let u=Number.MAX_VALUE,m=0;for(const h of de(ye,ve,this.parameters,e)){const e=l-ye[0],r=c-ye[1],i=ve[0]-ye[0],s=ve[1]-ye[1],n=t((i*e+s*r)/(i*i+s*s),0,1),o=i*n-e,a=s*n-r,p=o*o+a*a;p<u&&(u=p,m=h)}u<p*p&&n(o.distance,o.normal,m)}intersectRay(t,r,i,s,n,a){const{options:l,camera:_,rayBegin:b,rayEnd:S}=i;if(!l.selectionMode||!t.visible||!_)return;if(!Q(r))return void e.getLogger("esri.views.3d.webgl-engine.materials.RibbonLineMaterial").error("intersection assumes a translation-only matrix");const P=t.attributes,y=P.get("position").data,v=this._getLineSize(P),w=Le;o(w,i.point);const j=v*_.pixelRatio,L=Je*_.pixelRatio,z=j/2+L;c(Ie[0],w[0]-z,w[1]+z,0),c(Ie[1],w[0]+z,w[1]+z,0),c(Ie[2],w[0]+z,w[1]-z,0),c(Ie[3],w[0]-z,w[1]-z,0);for(let e=0;e<4;e++)if(!_.unprojectFromRenderScreen(Ie[e],Ne[e]))return;C(_.eye,Ne[0],Ne[1],We),C(_.eye,Ne[1],Ne[2],ke),C(_.eye,Ne[2],Ne[3],De),C(_.eye,Ne[3],Ne[0],Ye);let R=Number.MAX_VALUE,V=0;for(const e of this._forEachTransformedLineSegment(Se,Pe,y,r,he(this.parameters,P))){if(A(We,Se)<0&&A(We,Pe)<0||A(ke,Se)<0&&A(ke,Pe)<0||A(De,Se)<0&&A(De,Pe)<0||A(Ye,Se)<0&&A(Ye,Pe)<0)continue;const t=_.projectToRenderScreen(Se,ze),r=_.projectToRenderScreen(Pe,Ce);if(null==t||null==r)continue;if(t[2]<0&&r[2]>0){p(Te,Se,Pe);const e=_.frustum,r=-A(e[4],Se)/u(Te,M(e[4]));if(m(Te,Te,r),h(Se,Se,Te),!_.projectToRenderScreen(Se,t))continue}else if(t[2]>0&&r[2]<0){p(Te,Pe,Se);const e=_.frustum,t=-A(e[4],Pe)/u(Te,M(e[4]));if(m(Te,Te,t),h(Pe,Pe,Te),!_.projectToRenderScreen(Pe,r))continue}else if(t[2]<0&&r[2]<0)continue;t[2]=0,r[2]=0;const i=E(t,r,Fe),s=x(i,w);if(!(s>=R)){if(this.parameters.screenSizePerspective){const e=this.computeScreenSizePerspectiveWidth(i,Se,Pe,w,_,v,L);if(s>=e*e)continue}R=s,f(Re,Se),f(Ve,Pe),V=e}}if(R<z*z){let e=Number.MAX_VALUE;if(T(E(Re,Ve,Fe),E(b,S,Oe),je)){p(je,je,b);const t=d(je);m(je,je,1/t),e=t/g(b,S)}a(e,je,V)}}intersectScreenPolygon(t,r,i,s){const{options:n,camera:o,screenPolygonPrimitiveProcessor:a}=i;if(!n.selectionMode||!t.visible)return null;if(!Q(r))return e.getLogger("esri.views.3d.webgl-engine.materials.RibbonLineMaterial").error("intersection assumes a translation-only matrix"),null;const l=t.attributes,c=l.get("position").data,p=this._getLineSize(l),u=Je,m=u*o.pixelRatio,h=new G(4);for(const e of this._forEachTransformedLineSegment(Se,Pe,c,r,he(this.parameters,l)))for(const[t,r]of a.processLineSegment(qe,Se,Pe)){if(!q(o,t,r,ze,Ce))continue;const i=E(ze,Ce,Fe);let n=p/2+u;this.parameters.screenSizePerspective&&(_(Le,ze,Ce,.5),n=Math.max(n,this.computeScreenSizePerspectiveWidth(i,t,r,Le,o,p,m)/o.pixelRatio)),o.renderToScreen(ze,Ae),o.renderToScreen(Ce,Me),X(s,Ae,Me,n)&&(j(E(t,r,Oe),o.eye,we),h.updateIfCloserFromValues(g(o.eye,we),e,we,null))}return h}intersectScreenPolygonDraped({attributes:e,screenToWorldRatio:t},r,i,s){if(!i.options.selectionMode)return null;const n=fe(this._getLineSize(e,!0),t);for(const o of de(ye,ve,this.parameters,e,r))if(X(s,ye,ve,n))return new H(o);return null}createBufferWriter(){return new ue(ie(this.parameters),se(this.parameters),this.parameters)}createGLMaterial(e){return new ce(e)}validateParameters(e){"miter"!==e.join&&(e.miterLimit=0),null!=e.markerParameters&&(e.markerScale=e.markerParameters.width/e.width)}update(e){return!!this.parameters.hasAnimation&&(this.setParameters({timeElapsed:s(e.time)},!1),0!==e.dt)}computeScreenSizePerspectiveWidth(e,t,r,i,s,n,o){const a=L(e,i);_(we,t,r,a),b(Ee,we,s.viewMatrix);const l=d(Ee),c=this.computeCameraAbsCosAngle(we,s,this._configuration.spherical);be.update(c,l,this.parameters.screenSizePerspective,this.parameters.screenSizePerspectiveMinPixelReferenceSize);return be.apply(n)*s.pixelRatio/2+o}computeCameraAbsCosAngle(e,t,r){return r?S(je,e):c(je,0,0,1),p(xe,e,t.eye),S(xe,xe),Math.abs(u(je,xe))}_getLineSize(e,r=!1){let i=this.parameters.width;if(this.parameters.vvSize){const s=e.get("sizeFeatureAttribute").data[0];Number.isNaN(s)?r&&(i*=this.parameters.vvSize.fallback[0]):i*=t(this.parameters.vvSize.offset[0]+s*this.parameters.vvSize.factor[0],this.parameters.vvSize.minSize[0],this.parameters.vvSize.maxSize[0])}else e.has("size")&&(i*=e.get("size").data[0]);return i}*_forEachTransformedLineSegment(e,t,r,i,s){const n=s?r.length-2:r.length-5;for(let o=0;o<n;o+=3){e[0]=r[o]+i[12],e[1]=r[o+1]+i[13],e[2]=r[o+2]+i[14];const s=(o+3)%r.length;t[0]=r[s]+i[12],t[1]=r[s+1]+i[13],t[2]=r[s+2]+i[14],yield o/3}}}class ce extends Y{constructor(){super(...arguments),this._stipplePattern=null}dispose(){super.dispose(),this._stippleTextures?.release(this._stipplePattern),this._stipplePattern=null}beginSlot(e){const{stipplePattern:t}=this._material.parameters;return this._stipplePattern!==t&&(this._material.setParameters({stippleTexture:this._stippleTextures.swap(t,this._stipplePattern)}),this._stipplePattern=t),this.getTechnique(ne,e)}}class pe extends ee{constructor(){super(...arguments),this._width=0,this.color=y,this.join="miter",this.cap=0,this.miterLimit=5,this.writeDepth=!0,this.polygonOffset=0,this.polygonOffsetIndex=0,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=n(0),this.animation=0,this.animationSpeed=1,this.trailLength=1,this.startTime=n(0),this.endTime=n(1/0),this.emissiveStrength=0}get width(){return this.isImagePattern()?this.stipplePattern.width:this._width}set width(e){this._width=e}get transparent(){return this.color[3]<1||this.hasAnimation||null!=this.stipplePattern&&(this.stippleOffColor?.[3]??0)<1}get hasAnimation(){return 0!==this.animation}isImagePattern(){return $(this.stipplePattern)&&null!=this.stippleTexture}}class ue{constructor(e,t,r){this.layout=e,this.textureBufferLayout=t,this._parameters=r,this.numJoinSubdivisions=_e(this._parameters.join,null!=this._parameters.stipplePattern)}_isClosed(e){return he(this._parameters,e)}allocate(e){return this.layout.createBuffer(e)}elementCountTextureBuffer(e){return e.get("position").data.length/3+(this._isClosed(e)?3:2)}elementCount(e){const t=2,r=e.get("position").indices.length/2+1,i=this._isClosed(e);let s=i?2:2*t;return s+=((i?r:r-1)-(i?0:1))*(2*this.numJoinSubdivisions+4),s+=2,this._parameters.wireframe&&(s=2+4*(s-2)),s}write(e,t,r,i,s,n,o){null!=o&&this._writeTextureBuffer(e,r,i,o),null!=s&&this._writeVertexBuffer(e,r,i,s,n)}_writeTextureBuffer(e,t,r,i){const s=t.get("position"),n=s.data.length/3,o=this._isClosed(t),{buffer:a,offset:l}=i,c=a.getField("position",R),p=a.getField("u0",V),u=a.getField("sizeFeatureAttribute",V),m=a.getField("size",V),h=a.getField("colorFeatureAttribute",V),d=a.getField("color",F),_=a.getField("olidColor",F),b=a.getField("timeStamps",O),S=a.getField("opacityFeatureAttribute",V),P=t.get("sizeFeatureAttribute")?.data,y=t.get("size")?.data,v=t.get("colorFeatureAttribute")?.data,w=t.get("color")?.data,E=t.get("opacityFeatureAttribute")?.data,x=t.get("distanceToStart")?.data,T=t.get("timeStamps");Z(null!==c,"Expected valid position field in texture buffer"),Z(null!==p,"Expected valid u0 field in texture buffer");let j=0;for(let L=0;L<n;++L){this._getTransformedPosition(Ue,s.data,L,e),L>0&&(null!=x?j=x[L]??j:j+=g(Be,Ue));const t=l+L+1;if(c.setVec(t,Ue),p.set(t,j),f(Be,Ue),u&&u.set(t,1===P?.length?P[0]:P?.[L]??0),m&&m.set(t,1===y?.length?y[0]:y?.[L]??1),h&&h.set(t,1===v?.length?v[0]:v?.[L]??0),d)if(null!=w){const e=Math.min(4*L,w.length-4);d.setValues(t,w[e],w[e+1],w[e+2],w[e+3])}else d.setValues(t,1,1,1,1);S&&S.set(t,1===E?.length?E[0]:E?.[L]??0)}if(null!=b&&null!=T){Z(4===T.size);const e=T.data;for(let t=0;t<n;++t){const r=4*t,i=l+t+1;b.set(i,0,e[r]),b.set(i,1,e[r+1]),b.set(i,2,e[r+2]),b.set(i,3,e[r+3])}}if(o){const e=l,t=l+1,r=l+2,i=l+n,s=i+1,o=i+2;a.copyItem(i,e),a.copyItem(t,s),a.copyItem(r,o),c.getVec(i,Be),c.getVec(t,Ue);const u=j+g(Be,Ue);p.set(s,u)}else{const e=l,t=l+1,r=l+n,i=r+1;a.copyItem(t,e),a.copyItem(r,i)}D()&&null!=r&&null!=_&&te(r,_,n+(o?3:2),l)}_writeVertexBuffer(e,t,r,i,s){const{buffer:n,offset:o}=i,{layout:a}=this,l=t.get("position"),c=l.indices,p=l.data.length/3,u=this._isClosed(t),m=p+(u?3:2);c&&c.length!==2*(p-1)&&console.warn("RibbonLineMaterial does not support indices");const h=n.getField("textureElementIndex",B);Z(null!=h,"Missing texture buffer index field"),Z(null!=s,"Using a texture layout, but the texture range for this instance was not provided");const f=s.from;Z(s.numElements===m,"Expected number of elements in TextureBuffer to equal number of points");const d=new Float32Array(n.buffer),g=v(n.buffer),_=new Uint32Array(n.buffer),b=a.stride/4;let S=o*b;const P=S,y=d.BYTES_PER_ELEMENT/g.BYTES_PER_ELEMENT,w=(e,t,r)=>{const i=r+1;_[S]=f+i,S++;let s=S*y;g[s++]=e,g[s++]=t,S=Math.ceil(s/y)};S+=b;let E=0,x=0;u?(E=0,x=p):(w(1,-4,0),w(1,4,0),E=1,x=p-1);for(let v=E;v<x;v++){w(0,-1,v),w(0,1,v);const e=this.numJoinSubdivisions;for(let t=0;t<e;++t){const r=(t+1)/(e+1);w(r,-1,v),w(r,1,v)}w(1,-2,v),w(1,2,v)}u?(w(0,-1,x),w(0,1,x)):(w(0,-5,x),w(0,5,x)),me(d,P+b,d,P,b);S=me(d,S-b,d,S,b),this._parameters.wireframe&&this._addWireframeVertices(n,P,S,b)}_getTransformedPosition(e,t,r,i){const s=3*r;c(e,t[s+0],t[s+1],t[s+2]),i&&b(e,e,i)}_addWireframeVertices(e,t,r,i){const s=new Uint8Array(e.buffer,r*Float32Array.BYTES_PER_ELEMENT),n=new Uint8Array(e.buffer,t*Float32Array.BYTES_PER_ELEMENT,(r-t)*Float32Array.BYTES_PER_ELEMENT),o=i*Float32Array.BYTES_PER_ELEMENT;let a=0;const l=e=>a=me(n,e,s,a,o);for(let c=0;c<=n.length-4*o;c+=2*o)l(c),l(c+2*o),l(c+1*o),l(c+2*o),l(c+1*o),l(c+3*o)}}function me(e,t,r,i,s){for(let n=0;n<s;n++)r[i++]=e[t++];return i}function he(e,t){if(!e.isClosed)return!1;return t.get("position").indices.length>2}function fe(e,t){return(e/2+Je)*t}function*de(e,t,r,i,s){const n=i.get("position").data,l=he(r,i)?n.length-2:n.length-5,c=s?.[0]??0,p=s?.[1]??0;a(e,n[0]+c,n[1]+p);for(let u=3;u<l+3;u+=3){const r=u%n.length;a(t,n[r]+c,n[r+1]+p),yield u/3,o(e,t)}}function ge(e){return 1===e.anchor&&e.hideOnShortSegments&&"begin-end"===e.placement&&e.worldSpace}function _e(e,t){const r=t?1:0;switch(e){case"miter":case"bevel":return r;case"round":return re+r}}const be=new K,Se=P(),Pe=P(),ye=l(),ve=l(),we=P(),Ee=P(),xe=P(),Te=P(),je=P(),Le=P(),ze=r(),Ce=r(),Ae=i(),Me=i(),Re=P(),Ve=P(),Fe=w(),Oe=w(),Be=P(),Ue=P(),Ie=[r(),r(),r(),r()],Ne=[P(),P(),P(),P()],We=z(),ke=z(),De=z(),Ye=z(),Je=4,qe=[P(),P()];export{pe as Parameters,le as RibbonLineMaterial};
2
+ import e from"../../../../core/Logger.js";import{clamp as t}from"../../../../core/mathUtils.js";import{createRenderScreenPointArray3 as r,createScreenPointArray as i}from"../../../../core/screenUtils.js";import{secondsFromMilliseconds as s,Seconds as n}from"../../../../core/time.js";import{copy as o,set as a}from"../../../../core/libs/gl-matrix-2/math/vec2.js";import{create as l}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{set as c,subtract as p,dot as u,scale as m,add as h,copy as f,length as d,distance as g,lerp as _,transformMat4 as b,normalize as S}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as P}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{ONES as y}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{makeFloat16Array as v}from"../../../../geometry/support/float16.js";import{create as w,fromPoints as E,distance2 as x,closestLineSegmentPoint as T,projectPoint as j,projectPointFraction as L}from"../../../../geometry/support/lineSegment.js";import{create as z,fromPoints as C,signedDistance as A,getNormal as M}from"../../../../geometry/support/plane.js";import{BufferViewVec3f as R,BufferViewFloat as V,BufferViewVec4Unorm8 as F,BufferViewVec4f16 as O,BufferViewUint32 as B}from"../../../../geometry/support/buffer/BufferView.js";import{isHighlightOrOLID as U,isColor as I,isDepth as N,isColorHighlightOLIDOrDepth as W,is2DGeometryOutput as k}from"../core/shaderLibrary/ShaderOutput.js";import{olidEnabled as D}from"../effects/geometry/olidUtils.js";import Y from"../lib/GLMaterial.js";import{Material as J}from"../lib/Material.js";import{projectWorldLineSegmentToRenderScreen as q,screenPolygonIntersectsBufferedSegment as X}from"../lib/screenPolygonOverlapUtils.js";import{Hit as G,DrapedHit as H}from"../lib/screenPolygonTriangleIntersections.js";import{ScreenSizePerspectiveEvaluator as K}from"../lib/screenSizePerspectiveUtils.js";import{isTranslationMatrix as Q,assert as Z}from"../lib/Util.js";import{isImagePattern as $}from"./lineStippleUtils.js";import{VisualVariablePassParameters as ee}from"./VisualVariablePassParameters.js";import{writeOlidColor as te}from"./internal/bufferWriterUtils.js";import{r as re}from"../../../../chunks/RibbonLine.glsl.js";import{getLayout as ie,getTextureBufferLayout as se}from"../shaders/RibbonLineLayouts.js";import{RibbonLineTechnique as ne}from"../shaders/RibbonLineTechnique.js";import{RibbonLineTechniqueConfiguration as oe}from"../shaders/RibbonLineTechniqueConfiguration.js";import{alphaCutoff as ae}from"../../../../webscene/support/AlphaCutoff.js";class le extends J{constructor(e,t){super(e,pe),this.produces=new Map([[2,e=>U(e)||I(e)&&8===this.parameters.renderOccluded],[3,e=>N(e)],[10,e=>W(e)&&8===this.parameters.renderOccluded],[11,e=>W(e)&&8===this.parameters.renderOccluded],[4,e=>I(e)&&this.parameters.writeDepth&&8!==this.parameters.renderOccluded],[8,e=>I(e)&&!this.parameters.writeDepth&&8!==this.parameters.renderOccluded],[18,e=>k(e)]]),this._configuration=new oe(t)}updateConfiguration(e){super.updateConfiguration(e);const t=18===e.slot,r=null!=this.parameters.stipplePattern&&null!=this.parameters.stippleTexture&&10!==e.output,i=r&&t&&this.parameters.isImagePattern();this._configuration.draped=t,this._configuration.polygonOffset=this.parameters.polygonOffset,this._configuration.stippleEnabled=r,this._configuration.stippleOffColorEnabled=r&&null!=this.parameters.stippleOffColor,this._configuration.stipplePreferContinuous=r&&this.parameters.stipplePreferContinuous,this._configuration.numJoinSubdivisions=_e(this.parameters.join,r),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&&ge(this.parameters.markerParameters),this._configuration.polygonOffsetIndex=this.parameters.polygonOffsetIndex,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.wireframe=this.parameters.wireframe,this._configuration.animation=this.parameters.animation,this._configuration.emissionSource=this.emissions?1:0,this._configuration.hasScreenSizePerspective=!!this.parameters.screenSizePerspective&&!i,this._configuration.worldSizedImagePattern=i}get visible(){return this.parameters.color[3]>=ae||null!=this.parameters.stipplePattern&&(this.parameters.stippleOffColor?.[3]??0)>ae}get emissions(){return this.parameters.emissiveStrength>0?8!==this.parameters.renderOccluded?2:1:0}setParameters(e,t){e.animation=this.parameters.animation,super.setParameters(e,t)}intersectRayDraped({attributes:e,screenToWorldRatio:r},i,s,n,o){if(!i.options.selectionMode)return;const a=this._getLineSize(e,!0),l=s[0],c=s[1],p=fe(a,r);let u=Number.MAX_VALUE,m=0;for(const h of de(ye,ve,this.parameters,e)){const e=l-ye[0],r=c-ye[1],i=ve[0]-ye[0],s=ve[1]-ye[1],n=t((i*e+s*r)/(i*i+s*s),0,1),o=i*n-e,a=s*n-r,p=o*o+a*a;p<u&&(u=p,m=h)}u<p*p&&n(o.distance,o.renderDistance,o.normal,m)}intersectRay(t,r,i,s,n,a){const{options:l,camera:_,rayBegin:b,rayEnd:S}=i;if(!l.selectionMode||!t.visible||!_)return;if(!Q(r))return void e.getLogger("esri.views.3d.webgl-engine.materials.RibbonLineMaterial").error("intersection assumes a translation-only matrix");const P=t.attributes,y=P.get("position").data,v=this._getLineSize(P),w=Le;o(w,i.point);const j=v*_.pixelRatio,L=Je*_.pixelRatio,z=j/2+L;c(Ie[0],w[0]-z,w[1]+z,0),c(Ie[1],w[0]+z,w[1]+z,0),c(Ie[2],w[0]+z,w[1]-z,0),c(Ie[3],w[0]-z,w[1]-z,0);for(let e=0;e<4;e++)if(!_.unprojectFromRenderScreen(Ie[e],Ne[e]))return;C(_.eye,Ne[0],Ne[1],We),C(_.eye,Ne[1],Ne[2],ke),C(_.eye,Ne[2],Ne[3],De),C(_.eye,Ne[3],Ne[0],Ye);let R=Number.MAX_VALUE,V=0;for(const e of this._forEachTransformedLineSegment(Se,Pe,y,r,he(this.parameters,P))){if(A(We,Se)<0&&A(We,Pe)<0||A(ke,Se)<0&&A(ke,Pe)<0||A(De,Se)<0&&A(De,Pe)<0||A(Ye,Se)<0&&A(Ye,Pe)<0)continue;const t=_.projectToRenderScreen(Se,ze),r=_.projectToRenderScreen(Pe,Ce);if(null==t||null==r)continue;if(t[2]<0&&r[2]>0){p(Te,Se,Pe);const e=_.frustum,r=-A(e[4],Se)/u(Te,M(e[4]));if(m(Te,Te,r),h(Se,Se,Te),!_.projectToRenderScreen(Se,t))continue}else if(t[2]>0&&r[2]<0){p(Te,Pe,Se);const e=_.frustum,t=-A(e[4],Pe)/u(Te,M(e[4]));if(m(Te,Te,t),h(Pe,Pe,Te),!_.projectToRenderScreen(Pe,r))continue}else if(t[2]<0&&r[2]<0)continue;t[2]=0,r[2]=0;const i=E(t,r,Fe),s=x(i,w);if(!(s>=R)){if(this.parameters.screenSizePerspective){const e=this.computeScreenSizePerspectiveWidth(i,Se,Pe,w,_,v,L);if(s>=e*e)continue}R=s,f(Re,Se),f(Ve,Pe),V=e}}if(R<z*z){let e=Number.MAX_VALUE;if(T(E(Re,Ve,Fe),E(b,S,Oe),je)){p(je,je,b);const t=d(je);m(je,je,1/t),e=t/g(b,S)}a(e,e,je,V)}}intersectScreenPolygon(t,r,i,s){const{options:n,camera:o,screenPolygonPrimitiveProcessor:a}=i;if(!n.selectionMode||!t.visible)return null;if(!Q(r))return e.getLogger("esri.views.3d.webgl-engine.materials.RibbonLineMaterial").error("intersection assumes a translation-only matrix"),null;const l=t.attributes,c=l.get("position").data,p=this._getLineSize(l),u=Je,m=u*o.pixelRatio,h=new G(4);for(const e of this._forEachTransformedLineSegment(Se,Pe,c,r,he(this.parameters,l)))for(const[t,r]of a.processLineSegment(qe,Se,Pe)){if(!q(o,t,r,ze,Ce))continue;const i=E(ze,Ce,Fe);let n=p/2+u;this.parameters.screenSizePerspective&&(_(Le,ze,Ce,.5),n=Math.max(n,this.computeScreenSizePerspectiveWidth(i,t,r,Le,o,p,m)/o.pixelRatio)),o.renderToScreen(ze,Ae),o.renderToScreen(Ce,Me),X(s,Ae,Me,n)&&(j(E(t,r,Oe),o.eye,we),h.updateIfCloserFromValues(g(o.eye,we),e,we,null))}return h}intersectScreenPolygonDraped({attributes:e,screenToWorldRatio:t},r,i,s){if(!i.options.selectionMode)return null;const n=fe(this._getLineSize(e,!0),t);for(const o of de(ye,ve,this.parameters,e,r))if(X(s,ye,ve,n))return new H(o);return null}createBufferWriter(){return new ue(ie(this.parameters),se(this.parameters),this.parameters)}createGLMaterial(e){return new ce(e)}validateParameters(e){"miter"!==e.join&&(e.miterLimit=0),null!=e.markerParameters&&(e.markerScale=e.markerParameters.width/e.width)}update(e){return!!this.parameters.hasAnimation&&(this.setParameters({timeElapsed:s(e.time)},!1),0!==e.dt)}computeScreenSizePerspectiveWidth(e,t,r,i,s,n,o){const a=L(e,i);_(we,t,r,a),b(Ee,we,s.viewMatrix);const l=d(Ee),c=this.computeCameraAbsCosAngle(we,s,this._configuration.spherical);be.update(c,l,this.parameters.screenSizePerspective,this.parameters.screenSizePerspectiveMinPixelReferenceSize);return be.apply(n)*s.pixelRatio/2+o}computeCameraAbsCosAngle(e,t,r){return r?S(je,e):c(je,0,0,1),p(xe,e,t.eye),S(xe,xe),Math.abs(u(je,xe))}_getLineSize(e,r=!1){let i=this.parameters.width;if(this.parameters.vvSize){const s=e.get("sizeFeatureAttribute").data[0];Number.isNaN(s)?r&&(i*=this.parameters.vvSize.fallback[0]):i*=t(this.parameters.vvSize.offset[0]+s*this.parameters.vvSize.factor[0],this.parameters.vvSize.minSize[0],this.parameters.vvSize.maxSize[0])}else e.has("size")&&(i*=e.get("size").data[0]);return i}*_forEachTransformedLineSegment(e,t,r,i,s){const n=s?r.length-2:r.length-5;for(let o=0;o<n;o+=3){e[0]=r[o]+i[12],e[1]=r[o+1]+i[13],e[2]=r[o+2]+i[14];const s=(o+3)%r.length;t[0]=r[s]+i[12],t[1]=r[s+1]+i[13],t[2]=r[s+2]+i[14],yield o/3}}}class ce extends Y{constructor(){super(...arguments),this._stipplePattern=null}dispose(){super.dispose(),this._stippleTextures?.release(this._stipplePattern),this._stipplePattern=null}beginSlot(e){const{stipplePattern:t}=this._material.parameters;return this._stipplePattern!==t&&(this._material.setParameters({stippleTexture:this._stippleTextures.swap(t,this._stipplePattern)}),this._stipplePattern=t),this.getTechnique(ne,e)}}class pe extends ee{constructor(){super(...arguments),this._width=0,this.color=y,this.join="miter",this.cap=0,this.miterLimit=5,this.writeDepth=!0,this.polygonOffset=0,this.polygonOffsetIndex=0,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=n(0),this.animation=0,this.animationSpeed=1,this.trailLength=1,this.startTime=n(0),this.endTime=n(1/0),this.emissiveStrength=0}get width(){return this.isImagePattern()?this.stipplePattern.width:this._width}set width(e){this._width=e}get transparent(){return this.color[3]<1||this.hasAnimation||null!=this.stipplePattern&&(this.stippleOffColor?.[3]??0)<1}get hasAnimation(){return 0!==this.animation}isImagePattern(){return $(this.stipplePattern)&&null!=this.stippleTexture}}class ue{constructor(e,t,r){this.layout=e,this.textureBufferLayout=t,this._parameters=r,this.numJoinSubdivisions=_e(this._parameters.join,null!=this._parameters.stipplePattern)}_isClosed(e){return he(this._parameters,e)}allocate(e){return this.layout.createBuffer(e)}elementCountTextureBuffer(e){return e.get("position").data.length/3+(this._isClosed(e)?3:2)}elementCount(e){const t=2,r=e.get("position").indices.length/2+1,i=this._isClosed(e);let s=i?2:2*t;return s+=((i?r:r-1)-(i?0:1))*(2*this.numJoinSubdivisions+4),s+=2,this._parameters.wireframe&&(s=2+4*(s-2)),s}write(e,t,r,i,s,n,o){null!=o&&this._writeTextureBuffer(e,r,i,o),null!=s&&this._writeVertexBuffer(e,r,i,s,n)}_writeTextureBuffer(e,t,r,i){const s=t.get("position"),n=s.data.length/3,o=this._isClosed(t),{buffer:a,offset:l}=i,c=a.getField("position",R),p=a.getField("u0",V),u=a.getField("sizeFeatureAttribute",V),m=a.getField("size",V),h=a.getField("colorFeatureAttribute",V),d=a.getField("color",F),_=a.getField("olidColor",F),b=a.getField("timeStamps",O),S=a.getField("opacityFeatureAttribute",V),P=t.get("sizeFeatureAttribute")?.data,y=t.get("size")?.data,v=t.get("colorFeatureAttribute")?.data,w=t.get("color")?.data,E=t.get("opacityFeatureAttribute")?.data,x=t.get("distanceToStart")?.data,T=t.get("timeStamps");Z(null!==c,"Expected valid position field in texture buffer"),Z(null!==p,"Expected valid u0 field in texture buffer");let j=0;for(let L=0;L<n;++L){this._getTransformedPosition(Ue,s.data,L,e),L>0&&(null!=x?j=x[L]??j:j+=g(Be,Ue));const t=l+L+1;if(c.setVec(t,Ue),p.set(t,j),f(Be,Ue),u&&u.set(t,1===P?.length?P[0]:P?.[L]??0),m&&m.set(t,1===y?.length?y[0]:y?.[L]??1),h&&h.set(t,1===v?.length?v[0]:v?.[L]??0),d)if(null!=w){const e=Math.min(4*L,w.length-4);d.setValues(t,w[e],w[e+1],w[e+2],w[e+3])}else d.setValues(t,1,1,1,1);S&&S.set(t,1===E?.length?E[0]:E?.[L]??0)}if(null!=b&&null!=T){Z(4===T.size);const e=T.data;for(let t=0;t<n;++t){const r=4*t,i=l+t+1;b.set(i,0,e[r]),b.set(i,1,e[r+1]),b.set(i,2,e[r+2]),b.set(i,3,e[r+3])}}if(o){const e=l,t=l+1,r=l+2,i=l+n,s=i+1,o=i+2;a.copyItem(i,e),a.copyItem(t,s),a.copyItem(r,o),c.getVec(i,Be),c.getVec(t,Ue);const u=j+g(Be,Ue);p.set(s,u)}else{const e=l,t=l+1,r=l+n,i=r+1;a.copyItem(t,e),a.copyItem(r,i)}D()&&null!=r&&null!=_&&te(r,_,n+(o?3:2),l)}_writeVertexBuffer(e,t,r,i,s){const{buffer:n,offset:o}=i,{layout:a}=this,l=t.get("position"),c=l.indices,p=l.data.length/3,u=this._isClosed(t),m=p+(u?3:2);c&&c.length!==2*(p-1)&&console.warn("RibbonLineMaterial does not support indices");const h=n.getField("textureElementIndex",B);Z(null!=h,"Missing texture buffer index field"),Z(null!=s,"Using a texture layout, but the texture range for this instance was not provided");const f=s.from;Z(s.numElements===m,"Expected number of elements in TextureBuffer to equal number of points");const d=new Float32Array(n.buffer),g=v(n.buffer),_=new Uint32Array(n.buffer),b=a.stride/4;let S=o*b;const P=S,y=d.BYTES_PER_ELEMENT/g.BYTES_PER_ELEMENT,w=(e,t,r)=>{const i=r+1;_[S]=f+i,S++;let s=S*y;g[s++]=e,g[s++]=t,S=Math.ceil(s/y)};S+=b;let E=0,x=0;u?(E=0,x=p):(w(1,-4,0),w(1,4,0),E=1,x=p-1);for(let v=E;v<x;v++){w(0,-1,v),w(0,1,v);const e=this.numJoinSubdivisions;for(let t=0;t<e;++t){const r=(t+1)/(e+1);w(r,-1,v),w(r,1,v)}w(1,-2,v),w(1,2,v)}u?(w(0,-1,x),w(0,1,x)):(w(0,-5,x),w(0,5,x)),me(d,P+b,d,P,b);S=me(d,S-b,d,S,b),this._parameters.wireframe&&this._addWireframeVertices(n,P,S,b)}_getTransformedPosition(e,t,r,i){const s=3*r;c(e,t[s+0],t[s+1],t[s+2]),i&&b(e,e,i)}_addWireframeVertices(e,t,r,i){const s=new Uint8Array(e.buffer,r*Float32Array.BYTES_PER_ELEMENT),n=new Uint8Array(e.buffer,t*Float32Array.BYTES_PER_ELEMENT,(r-t)*Float32Array.BYTES_PER_ELEMENT),o=i*Float32Array.BYTES_PER_ELEMENT;let a=0;const l=e=>a=me(n,e,s,a,o);for(let c=0;c<=n.length-4*o;c+=2*o)l(c),l(c+2*o),l(c+1*o),l(c+2*o),l(c+1*o),l(c+3*o)}}function me(e,t,r,i,s){for(let n=0;n<s;n++)r[i++]=e[t++];return i}function he(e,t){if(!e.isClosed)return!1;return t.get("position").indices.length>2}function fe(e,t){return(e/2+Je)*t}function*de(e,t,r,i,s){const n=i.get("position").data,l=he(r,i)?n.length-2:n.length-5,c=s?.[0]??0,p=s?.[1]??0;a(e,n[0]+c,n[1]+p);for(let u=3;u<l+3;u+=3){const r=u%n.length;a(t,n[r]+c,n[r+1]+p),yield u/3,o(e,t)}}function ge(e){return 1===e.anchor&&e.hideOnShortSegments&&"begin-end"===e.placement&&e.worldSpace}function _e(e,t){const r=t?1:0;switch(e){case"miter":case"bevel":return r;case"round":return re+r}}const be=new K,Se=P(),Pe=P(),ye=l(),ve=l(),we=P(),Ee=P(),xe=P(),Te=P(),je=P(),Le=P(),ze=r(),Ce=r(),Ae=i(),Me=i(),Re=P(),Ve=P(),Fe=w(),Oe=w(),Be=P(),Ue=P(),Ie=[r(),r(),r(),r()],Ne=[P(),P(),P(),P()],We=z(),ke=z(),De=z(),Ye=z(),Je=4,qe=[P(),P()];export{pe as Parameters,le as RibbonLineMaterial};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{direction as t,dot as n}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as o}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{polygonOffset as r}from"./PolygonOffset.js";import{TriangleTechniqueConfiguration as e}from"./TriangleTechniqueConfiguration.js";function f(n,o,e,f){c.output=o.transparent?1:0,c.polygonOffset=o.polygonOffset,c.enableOITOffset=o.enableOITOffset;const s=r(c);if(!s)return n;const i=t(m,f,e);return(t,o,r)=>n(a(s,i,t,o),o,r)}function s(n,o,e,f,s){const i=r(e);return i?a(i,t(m,s,f),n,o):n}function i(t,n,o){return null==t?null:(t.distance=s(t.distance,t.hasNormal?t.normal:null,n,o,t.point),t)}function a({units:t,factor:o},r,e,f){const s=u*t;return e+((f?1-Math.abs(n(r,f)):0)*o*l+s)}const c=new e,l=2e-5,u=2e-6,m=o();export{s as applyPolygonOffsetToDistance,i as applyPolygonOffsetToHit,f as intersectWithPolygonOffset};
2
+ import{direction as t,dot as n}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as o}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{polygonOffset as r}from"./PolygonOffset.js";import{TriangleTechniqueConfiguration as e}from"./TriangleTechniqueConfiguration.js";function s(o,e,s,f){c.output=e.transparent?1:0,c.polygonOffset=e.polygonOffset,c.enableOITOffset=e.enableOITOffset;const i=r(c);if(!i)return o;const a=l*i.units,p=t(m,f,s);return(t,r,e,s)=>{const f=(e?1-Math.abs(n(p,e)):0)*i.factor*u+a;return o(t,r+f,e,s)}}function f(n,o,e,s,f){const i=r(e);return i?a(i,t(m,f,s),n,o):n}function i(t,n,o){return null==t?null:(t.distance=f(t.distance,t.hasNormal?t.normal:null,n,o,t.point),t)}function a({units:t,factor:o},r,e,s){const f=l*t;return e+((s?1-Math.abs(n(r,s)):0)*o*u+f)}const c=new e,u=2e-5,l=2e-6,m=o();export{f as applyPolygonOffsetToDistance,i as applyPolygonOffsetToHit,s as intersectWithPolygonOffset};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{__decorate as e}from"tslib";import{subclass as s}from"../../../../core/accessorSupport/decorators.js";import{ReloadableShader as r}from"../core/shaderTechnique/ReloadableShader.js";import{ShaderTechnique as i}from"../core/shaderTechnique/ShaderTechnique.js";import{a as o}from"../../../../chunks/FocusAreaMask.glsl.js";import{PrimitiveType as a}from"../../../webgl/enums.js";import{makePipelineState as t,separateStencilTestParams as c}from"../../../webgl/renderState.js";let l=class extends i{constructor(){super(...arguments),this.shader=new r(o,()=>import("../effects/focusArea/FocusAreaMask.glsl.js")),this.ignoreUnused=!0,this.primitiveType=a.TRIANGLE_STRIP}initializePipeline(){return t({depthTest:{func:513},stencilTest:c(0,255,{compare:519,fail:7680,zFail:34055,zPass:7680},{compare:519,fail:7680,zFail:34056,zPass:7680}),stencilWrite:{mask:255}})}};l=e([s("esri.views.3d.webgl-engine.shaders.ShadowCastMaskTechnique")],l);export{l as ShadowCastMaskTechnique};
2
+ import{__decorate as e}from"tslib";import{subclass as s}from"../../../../core/accessorSupport/decorators.js";import{VolumeMaskTechnique as i}from"./VolumeMaskTechnique.js";import{PrimitiveType as r}from"../../../webgl/enums.js";import{makePipelineState as t,separateStencilTestParams as o}from"../../../webgl/renderState.js";let a=class extends i{constructor(){super(...arguments),this.ignoreUnused=!0,this.primitiveType=r.TRIANGLE_STRIP}initializePipeline(){return t({depthTest:{func:513},stencilTest:o(0,255,{compare:519,fail:7680,zFail:34055,zPass:7680},{compare:519,fail:7680,zFail:34056,zPass:7680}),stencilWrite:{mask:255}})}};a=e([s("esri.views.3d.webgl-engine.shaders.ShadowCastMaskTechnique")],a);export{a as ShadowCastMaskTechnique};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- 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/vec3f64.js";import"../core/shaderModules/glsl.js";import"../core/shaderModules/Matrix4BindUniform.js";import"../core/shaderModules/Matrix4DrawUniform.js";import"../../../webgl/NoParameters.js";import"../../../webgl/ShaderBuilder.js";export{C as CutFillMaskDrawParameters,b as build}from"../../../../chunks/CutFillMask.glsl.js";
2
+ 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/vec3f64.js";import"../core/shaderModules/glsl.js";import"../core/shaderModules/Matrix4BindUniform.js";import"../core/shaderModules/Matrix4DrawUniform.js";import"../../../webgl/NoParameters.js";import"../../../webgl/ShaderBuilder.js";export{V as VolumeMaskDrawParameters,b as build}from"../../../../chunks/VolumeMask.glsl.js";
@@ -0,0 +1,2 @@
1
+ /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
+ import{__decorate as e}from"tslib";import{subclass as r}from"../../../../core/accessorSupport/decorators.js";import{ReloadableShader as s}from"../core/shaderTechnique/ReloadableShader.js";import{ShaderTechnique as o}from"../core/shaderTechnique/ShaderTechnique.js";import{Pos3 as t}from"../lib/DefaultVertexBufferLayouts.js";import{a as i}from"../../../../chunks/VolumeMask.glsl.js";import{makePipelineState as a,defaultColorWrite as l}from"../../../webgl/renderState.js";let m=class extends o{constructor(e,r){super(e,r,t),this.shader=new s(i,()=>import("./VolumeMask.glsl.js"))}initializePipeline(){return a({colorWrite:l,depthTest:{func:515}})}};m=e([r("esri.views.3d.webgl-engine.shaders.VolumeMaskTechnique")],m);export{m as VolumeMaskTechnique};
package/views/View2D.d.ts CHANGED
@@ -16,7 +16,7 @@ import type LayerView from "./layers/LayerView.js";
16
16
  import type ColorBackground from "../webmap/background/ColorBackground.js";
17
17
  import type { ViewpointProperties } from "../Viewpoint.js";
18
18
  import type { ReadonlyArrayOrCollection } from "../core/Collection.js";
19
- import type { ScreenPoint, ScreenRect } from "../core/types.js";
19
+ import type { ScreenPoint, ScreenPolygon, ScreenRect } from "../core/types.js";
20
20
  import type { ExtentProperties } from "../geometry/Extent.js";
21
21
  import type { SpatialReferenceProperties } from "../geometry/SpatialReference.js";
22
22
  import type { TimeZone } from "../time/types.js";
@@ -958,7 +958,7 @@ export default abstract class View2D extends View2DSuperclass {
958
958
  * }
959
959
  * });
960
960
  */
961
- hitTest(hitTarget: ScreenPoint | ScreenRect | MouseEvent, options?: HitTestOptions): Promise<ViewHitTestResult>;
961
+ hitTest(hitTarget: ScreenPoint | ScreenRect | ScreenPolygon | MouseEvent, options?: HitTestOptions): Promise<ViewHitTestResult>;
962
962
  /**
963
963
  * Converts the given screen point to a [map point](https://developers.arcgis.com/javascript/latest/references/core/geometry/Point/).
964
964
  * The screen point represents a point in terms
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{__decorate as e}from"tslib";import{makeHandle as t}from"../../../../core/handleUtils.js";import{property as r,subclass as o}from"../../../../core/accessorSupport/decorators.js";import s from"../../../../geometry/Polygon.js";import{toExtent as i}from"../../../../geometry/support/aaBoundingRect.js";import{TileKey as n}from"../../../../layers/support/TileKey.js";import{TileTreeDebugger as l}from"../../../support/TileTreeDebugger.js";let a=class extends l{constructor(e){super(e)}initialize(){const e=setInterval(()=>this._fetchDebugInfo(),2e3);this.addHandles(t(()=>clearInterval(e)))}getTiles(){if(!this._debugInfo)return[];const e=new Map,t=new Map;this._debugInfo.storedTiles.forEach(t=>e.set(n.fromJSON(t.key).id,t.featureCount)),this._debugInfo.pendingTiles.forEach(r=>{e.set(r.key.id,r.featureCount),t.set(r.key.id,r.state)});const r=r=>{const o=t.get(r),s=e.get(r)??"?";return o?`${o}:${s}\n${r}`:`store:${s}\n${r}`},o=new Map;return this._debugInfo.storedTiles.forEach(e=>{const t=n.fromJSON(e.key);o.set(t.id,t)}),this._debugInfo.pendingTiles.forEach(e=>{o.set(e.key.id,e.key)}),Array.from(o.values()).map(e=>({lij:[e.level,e.row,e.col],level:e.level,geometry:s.fromExtent(i(e.extent,this.view.spatialReference)),label:r(e.id)}))}_fetchDebugInfo(){this.handle.getDebugInfo(null).then(e=>{this._debugInfo=e,this.update()})}};e([r({constructOnly:!0})],a.prototype,"handle",void 0),a=e([o("esri.views.interactive.snapping.featureSources.WorkerTileTreeDebugger")],a);export{a as WorkerTileTreeDebugger};
2
+ import{__decorate as e}from"tslib";import{makeHandle as t}from"../../../../core/handleUtils.js";import{property as r,subclass as o}from"../../../../core/accessorSupport/decorators.js";import s from"../../../../geometry/Polygon.js";import{toExtent as i}from"../../../../geometry/support/aaBoundingRect.js";import{TileKey as n}from"../../../../layers/support/TileKey.js";import{TileTreeDebugger as l}from"../../../support/TileTreeDebugger.js";let a=class extends l{constructor(e){super(e)}initialize(){const e=setInterval(()=>this._fetchDebugInfo(),2e3);this.addHandles(t(()=>clearInterval(e)))}getTiles(){if(!this._debugInfo)return[];const e=new Map,t=new Map;this._debugInfo.storedTiles.forEach(t=>e.set(n.fromJSON(t.key).id,t.featureCount)),this._debugInfo.pendingTiles.forEach(r=>{e.set(r.key.id,r.featureCount),t.set(r.key.id,r.state)});const r=r=>{const o=t.get(r),s=e.get(r)??"?";return o?`${o}:${s}\n${r}`:`store:${s}\n${r}`},o=new Map;return this._debugInfo.storedTiles.forEach(e=>{const t=n.fromJSON(e.key);o.set(t.id,t)}),this._debugInfo.pendingTiles.forEach(e=>{o.set(e.key.id,e.key)}),o.values().map(e=>({lij:[e.level,e.row,e.col],level:e.level,geometry:s.fromExtent(i(e.extent,this.view.spatialReference)),label:r(e.id)})).toArray()}_fetchDebugInfo(){this.handle.getDebugInfo(null).then(e=>{this._debugInfo=e,this.update()})}};e([r({constructOnly:!0})],a.prototype,"handle",void 0),a=e([o("esri.views.interactive.snapping.featureSources.WorkerTileTreeDebugger")],a);export{a as WorkerTileTreeDebugger};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import e from"../../core/Logger.js";import{disposeMaybe as t}from"../../core/maybe.js";import{BufferObject as r}from"./BufferObject.js";import{webglDebugEnabled as i}from"./checkWebGLError.js";import{ResourceType as s,ColorAttachment0 as n,PixelType as h,StencilAttachment as o,SizedDepthStencilFormat as c,DepthStencilAttachment as a,SizedDepthFormat as l,DepthAttachment as f}from"./enums.js";import{Renderbuffer as u}from"./Renderbuffer.js";import _ from"./Texture.js";const m=()=>e.getLogger("esri.views.webgl.FramebufferObject");class d{constructor(e,t,r){if(this._context=e,this._level=0,this._glName=null,this._colorAttachments=new Map,this._depthStencilBuffer=null,this._depthStencilTexture=null,e.instanceCounter.increment(s.FramebufferObject,this),null!=t){const r=N(e,t);null!=r&&(this._colorAttachments.set(n,r),T(r)?this._validateTextureDescriptor(r.descriptor):this._validateRenderbufferDescriptor(r.descriptor)),this._validateColorAttachmentPoint(n)}if(null!=r)if(x(r))this._depthStencilTexture=T(r)?r:new _(e,r),this._validateTextureDescriptor(this._depthStencilTexture.descriptor);else{const t=g(r)?r:new u(e,r);this._depthStencilBuffer=t,this._validateRenderbufferDescriptor(t.descriptor)}}get glName(){return this._glName}get colorTexture(){const e=this._colorAttachments.get(n);return T(e)?e:null}get depthStencil(){return this._depthStencilTexture||this._depthStencilBuffer}get depthStencilTexture(){return this._depthStencilTexture}get width(){const e=this._colorAttachments.get(n)??this._depthStencilTexture??this._depthStencilBuffer;return e?.descriptor?.width??0}get height(){const e=this._colorAttachments.get(n)??this._depthStencilTexture??this._depthStencilBuffer;return e?.descriptor?.height??0}get usedMemory(){return[...this._colorAttachments].reduce((e,[t,r])=>e+r.usedMemory,this.depthStencil?.usedMemory??0)}get level(){return this._level}set level(e){this._level!==e&&(this._level=e,this._glName&&this._context.temporaryBindFramebuffer(this,()=>this._initializeAttachments()))}static{this._MAX_COLOR_ATTACHMENTS=-1}getColorTexture(e){const t=this._colorAttachments.get(e);return t&&T(t)?t:null}get colorAttachments(){return Array.from(this._colorAttachments.keys())}attachColorTexture(e,t=n){if(!e)return;this._validateColorAttachmentPoint(t);const{descriptor:r}=e;this._validateTextureDescriptor(r),this.detachColorTexture(t)?.dispose(),this._colorAttachments.set(t,e),this._glName&&(this._context.bindFramebuffer(this),this._framebufferTexture2D(e.glName,t))}detachColorTexture(e=n){const t=this._colorAttachments.get(e);if(!t)return;const r=T(t);return this._glName&&this._context.temporaryBindFramebuffer(this,()=>{if(r)this._framebufferTexture2D(null,e);else{const t=this._context.gl;t.framebufferRenderbuffer(t.FRAMEBUFFER,e,t.RENDERBUFFER,null)}}),this._colorAttachments.delete(e),r?t:void 0}detachColorTextures(...e){if(0!==e.length){if(this._glName){const t=this._context.gl;this._context.temporaryBindFramebuffer(this,()=>{e.forEach(e=>{T(this._colorAttachments.get(e))?this._framebufferTexture2D(null,e):t.framebufferRenderbuffer(t.FRAMEBUFFER,e,t.RENDERBUFFER,null)})})}e.forEach(e=>this._colorAttachments.delete(e))}}setColorTextureTarget(e,t=n,r=0){const i=this._colorAttachments.get(t);i&&(35866===e?this._framebufferTextureLayer(i.glName,t,36160,r):this._framebufferTexture2D(i.glName,t,e,36160))}attachDepthStencil(e){if(e)switch(e.type){case 1:return this._attachDepthStencilTexture(e);case 2:return this._attachDepthStencilBuffer(e)}}_attachDepthStencilTexture(e){if(null==e)return;const{descriptor:t}=e,{pixelFormat:r,dataType:i}=t;34041===r||6402===r?34041!==r||i===h.UNSIGNED_INT_24_8?6402!==r||i===h.UNSIGNED_INT||i===h.UNSIGNED_SHORT?(this._validateTextureDescriptor(t),this._disposeDepthStencilAttachments(),this._glName&&(this._context.bindFramebuffer(this),this._framebufferTexture2D(e.glName,D(r))),this._depthStencilTexture?.dispose(),this._depthStencilTexture=e):console.error("Depth texture must have data type of UNSIGNED_INT or UNSIGNED_SHORT!"):console.error("Depth/Stencil texture must have data type of UNSIGNED_INT_24_8!"):console.error("Depth/Stencil texture must have a pixel type of DEPTH_STENCIL!")}detachDepthStencilTexture(){const e=this._depthStencilTexture;return e&&this._glName&&this._context.temporaryBindFramebuffer(this,()=>{this._framebufferTexture2D(null,D(e.descriptor.pixelFormat))}),this._depthStencilTexture=null,e}_attachDepthStencilBuffer(e){if(null==e)return;const t=e.descriptor;if(this._validateRenderbufferDescriptor(t),this._disposeDepthStencilAttachments(),this._glName){this._context.bindFramebuffer(this);const{gl:r}=this._context,i=this._getGLAttachmentPoint(t);r.framebufferRenderbuffer(36160,i,r.RENDERBUFFER,e.glName)}this._depthStencilBuffer=e}detachDepthStencilBuffer(){const e=this._depthStencilBuffer;if(e&&this._glName){const{_context:t}=this,r=t.boundFramebuffer;t.bindFramebuffer(this);const{gl:i}=t,s=this._getGLAttachmentPoint(e.descriptor);i.framebufferRenderbuffer(36160,s,i.RENDERBUFFER,null),t.bindFramebuffer(r)}return this._depthStencilBuffer=null,e}invalidateAttachments(e){const{_context:t}=this;t.temporaryBindFramebuffer(this,()=>t.gl.invalidateFramebuffer(36160,e),!0)}copyToTexture(e,t,r,i,s,n,h){(e<0||t<0||s<0||n<0)&&console.error("Offsets cannot be negative!"),(r<=0||i<=0)&&console.error("Copy width and height must be greater than zero!");const o=h.descriptor;3553!==h.descriptor.target&&console.error("Texture target must be TEXTURE_2D!"),(null==o?.width||null==o?.height||e+r>this.width||t+i>this.height||s+r>o.width||n+i>o.height)&&console.error("Bad dimensions, the current input values will attempt to read or copy out of bounds!");const c=this._context,a=c.bindTexture(h,_.TEXTURE_UNIT_FOR_UPDATES);c.setActiveTexture(_.TEXTURE_UNIT_FOR_UPDATES),c.bindFramebuffer(this),c.gl.copyTexSubImage2D(3553,0,s,n,e,t,r,i),c.bindTexture(a,_.TEXTURE_UNIT_FOR_UPDATES)}readPixels(e,t,r,i,s,n,h){(r<=0||i<=0)&&console.error("Copy width and height must be greater than zero!"),h||console.error("Target memory is not initialized!"),this._context.bindFramebuffer(this),this._context.gl.readPixels(e,t,r,i,s,n,h)}async readPixelsAsync(e,t,i,s,n,h,o,c){const{gl:a}=this._context,l=r.createPixelPack(this._context,35041,o.byteLength);this._context.bindBuffer(l);const f=this._context.boundFramebuffer;this._context.bindFramebuffer(this),a.readPixels(e,t,i,s,n,h,0),this._context.unbindBuffer(35051),this._context.bindFramebuffer(f);try{await l.getSubDataAsync(o,void 0,void 0,void 0,c)}finally{l.dispose()}}resize(e,t){if(this.width===e&&this.height===t)return;const r={width:e,height:t};if(F(r,this._context.parameters.maxTextureSize),this._colorAttachments.forEach(e=>e.resize(r.width,r.height)),this._depthStencilTexture?.resize(r.width,r.height),this._glName&&(F(r,this._context.parameters.maxRenderbufferSize),this._depthStencilBuffer?.resize(r.width,r.height),i())){const{gl:e}=this._context;e.checkFramebufferStatus(36160)!==e.FRAMEBUFFER_COMPLETE&&console.error("Framebuffer is incomplete!")}}initializeAndBind(e=36160){const{gl:t}=this._context;this._glName?t.bindFramebuffer(e,this._glName):(this._glName&&t.deleteFramebuffer(this._glName),this._glName=t.createFramebuffer(),t.bindFramebuffer(e,this._glName),this._initializeAttachments(e))}_initializeAttachments(e=36160){const{gl:t}=this._context;if(this._colorAttachments.forEach((t,r)=>{if(T(t)){const i=A(t);35866===i?this._framebufferTextureLayer(t.glName,r,e):this._framebufferTexture2D(t.glName,r,i,e)}else if(g(t)){const i=this._context.gl;i.framebufferRenderbuffer(e,r,i.RENDERBUFFER,t.glName)}}),this._depthStencilBuffer){const r=this._getGLAttachmentPoint(this._depthStencilBuffer.descriptor);t.framebufferRenderbuffer(e,r,t.RENDERBUFFER,this._depthStencilBuffer.glName)}else if(this._depthStencilTexture){const t=D(this._depthStencilTexture.descriptor.pixelFormat);this._framebufferTexture2D(this._depthStencilTexture.glName,t,A(this._depthStencilTexture),e)}if(i()){t.checkFramebufferStatus(e)!==t.FRAMEBUFFER_COMPLETE&&console.error("Framebuffer is incomplete!")}}_framebufferTexture2D(e,t=n,r=3553,i=36160){this._context.gl.framebufferTexture2D(i,t,r,e,this._level)}_framebufferTextureLayer(e,t=n,r=36160,i=0){this._context.gl.framebufferTextureLayer(r,t,e,this._level,i)}_disposeDepthStencilAttachments(){const e=this._context.gl;if(this._depthStencilBuffer){if(this._glName){this._context.bindFramebuffer(this);const t=this._getGLAttachmentPoint(this._depthStencilBuffer.descriptor);e.framebufferRenderbuffer(36160,t,e.RENDERBUFFER,null)}this._depthStencilBuffer=t(this._depthStencilBuffer)}this._depthStencilTexture&&(this._glName&&(this._context.bindFramebuffer(this),this._framebufferTexture2D(null,D(this._depthStencilTexture.descriptor.pixelFormat))),this._depthStencilTexture=t(this._depthStencilTexture))}_validateTextureDescriptor(e){3553!==e.target&&34067!==e.target&&35866!==e.target&&console.error("Texture type must be TEXTURE_2D, TEXTURE_2D_ARRAY or TEXTURE_CUBE_MAP!"),F(e,this._context.parameters.maxTextureSize),this._validateBufferDimensions(e)}_validateRenderbufferDescriptor(e){F(e,this._context.parameters.maxRenderbufferSize),this._validateBufferDimensions(e)}_validateBufferDimensions(e){e.width<=0&&(e.width=this.width),e.height<=0&&(e.height=this.height),this.width>0&&this.height>0&&(this.width===e.width&&this.height===e.height||console.error("Attachment size must match framebuffer size!"))}_getGLAttachmentPoint(e){switch(e.internalFormat){case l.DEPTH_COMPONENT16:case l.DEPTH_COMPONENT24:case l.DEPTH_COMPONENT32F:return f;case c.DEPTH24_STENCIL8:case c.DEPTH32F_STENCIL8:return a;case 36168:return o;default:return n}}_validateColorAttachmentPoint(t){if(-1===d._MAX_COLOR_ATTACHMENTS){const{gl:e}=this._context;d._MAX_COLOR_ATTACHMENTS=e.getParameter(e.MAX_COLOR_ATTACHMENTS)}const r=t-n;r+1>d._MAX_COLOR_ATTACHMENTS&&e.getLogger("esri.views.webgl.FrameBufferObject").error("esri.FrameBufferObject",`illegal attachment point for color attachment: ${r+1}. Implementation supports up to ${d._MAX_COLOR_ATTACHMENTS} color attachments`)}}class p extends d{constructor(e,t,r){super(e,t,r)}dispose(){const{_colorAttachments:e,_glName:t,_context:r}=this;if(r.instanceCounter.decrement(s.FramebufferObject,this),0===e.size&&!this._depthStencilBuffer&&!this._depthStencilTexture&&!t)return;const i=r.boundFramebuffer,n=Array.from(e.values());this.detachColorTextures(...e.keys()),n.forEach(e=>e.dispose()),this.detachDepthStencilBuffer()?.dispose(),this.detachDepthStencilTexture()?.dispose(),r.gl.deleteFramebuffer(this._glName),this._glName=null,r.bindFramebuffer(i===this?null:i)}}function T(e){return 1===E(e)}function g(e){return 2===E(e)}function x(e){return T(e)||b(e)}function b(e){return 0===E(e)}function S(e){return 3===E(e)||null!=e&&"samples"in e}function E(e){return null!=e&&"type"in e?e.type:null}function N(e,t){return T(t)||g(t)?t:b(t)?new _(e,t):S(t)?new u(e,t):null}function F(e,t){const r=Math.max(e.width,e.height);if(r>t){m().warnOnce(`Resizing FBO attachment size ${e.width}x${e.height} to device limit ${t}`);const i=t/r;return e.width=Math.round(e.width*i),e.height=Math.round(e.height*i),!1}return!0}function A(e){return 34067===e.descriptor.target?34069:35866===e.descriptor.target?35866:3553}function D(e){return 6402===e?f:a}export{p as DisposableFramebufferObject,d as FramebufferObject,F as ensureAttachmentMaxSize};
2
+ import e from"../../core/Logger.js";import{disposeMaybe as t}from"../../core/maybe.js";import{BufferObject as r}from"./BufferObject.js";import{webglDebugEnabled as i}from"./checkWebGLError.js";import{ResourceType as s,ColorAttachment0 as n,PixelType as h,StencilAttachment as o,SizedDepthStencilFormat as c,DepthStencilAttachment as a,SizedDepthFormat as l,DepthAttachment as f}from"./enums.js";import{Renderbuffer as u}from"./Renderbuffer.js";import _ from"./Texture.js";const m=()=>e.getLogger("esri.views.webgl.FramebufferObject");class d{constructor(e,t,r){if(this._context=e,this._level=0,this._glName=null,this._colorAttachments=new Map,this._depthStencilBuffer=null,this._depthStencilTexture=null,e.instanceCounter.increment(s.FramebufferObject,this),null!=t){const r=N(e,t);null!=r&&(this._colorAttachments.set(n,r),T(r)?this._validateTextureDescriptor(r.descriptor):this._validateRenderbufferDescriptor(r.descriptor)),this._validateColorAttachmentPoint(n)}if(null!=r)if(x(r))this._depthStencilTexture=T(r)?r:new _(e,r),this._validateTextureDescriptor(this._depthStencilTexture.descriptor);else{const t=g(r)?r:new u(e,r);this._depthStencilBuffer=t,this._validateRenderbufferDescriptor(t.descriptor)}}get glName(){return this._glName}get colorTexture(){const e=this._colorAttachments.get(n);return T(e)?e:null}get depthStencil(){return this._depthStencilTexture||this._depthStencilBuffer}get depthStencilTexture(){return this._depthStencilTexture}get width(){const e=this._colorAttachments.get(n)??this._depthStencilTexture??this._depthStencilBuffer;return e?.descriptor?.width??0}get height(){const e=this._colorAttachments.get(n)??this._depthStencilTexture??this._depthStencilBuffer;return e?.descriptor?.height??0}get usedMemory(){return this._colorAttachments.values().reduce((e,t)=>e+t.usedMemory,this.depthStencil?.usedMemory??0)}get level(){return this._level}set level(e){this._level!==e&&(this._level=e,this._glName&&this._context.temporaryBindFramebuffer(this,()=>this._initializeAttachments()))}static{this._MAX_COLOR_ATTACHMENTS=-1}getColorTexture(e){const t=this._colorAttachments.get(e);return t&&T(t)?t:null}get colorAttachments(){return Array.from(this._colorAttachments.keys())}attachColorTexture(e,t=n){if(!e)return;this._validateColorAttachmentPoint(t);const{descriptor:r}=e;this._validateTextureDescriptor(r),this.detachColorTexture(t)?.dispose(),this._colorAttachments.set(t,e),this._glName&&(this._context.bindFramebuffer(this),this._framebufferTexture2D(e.glName,t))}detachColorTexture(e=n){const t=this._colorAttachments.get(e);if(!t)return;const r=T(t);return this._glName&&this._context.temporaryBindFramebuffer(this,()=>{if(r)this._framebufferTexture2D(null,e);else{const t=this._context.gl;t.framebufferRenderbuffer(t.FRAMEBUFFER,e,t.RENDERBUFFER,null)}}),this._colorAttachments.delete(e),r?t:void 0}detachColorTextures(...e){if(0!==e.length){if(this._glName){const t=this._context.gl;this._context.temporaryBindFramebuffer(this,()=>{e.forEach(e=>{T(this._colorAttachments.get(e))?this._framebufferTexture2D(null,e):t.framebufferRenderbuffer(t.FRAMEBUFFER,e,t.RENDERBUFFER,null)})})}e.forEach(e=>this._colorAttachments.delete(e))}}setColorTextureTarget(e,t=n,r=0){const i=this._colorAttachments.get(t);i&&(35866===e?this._framebufferTextureLayer(i.glName,t,36160,r):this._framebufferTexture2D(i.glName,t,e,36160))}attachDepthStencil(e){if(e)switch(e.type){case 1:return this._attachDepthStencilTexture(e);case 2:return this._attachDepthStencilBuffer(e)}}_attachDepthStencilTexture(e){if(null==e)return;const{descriptor:t}=e,{pixelFormat:r,dataType:i}=t;34041===r||6402===r?34041!==r||i===h.UNSIGNED_INT_24_8?6402!==r||i===h.UNSIGNED_INT||i===h.UNSIGNED_SHORT?(this._validateTextureDescriptor(t),this._disposeDepthStencilAttachments(),this._glName&&(this._context.bindFramebuffer(this),this._framebufferTexture2D(e.glName,D(r))),this._depthStencilTexture?.dispose(),this._depthStencilTexture=e):console.error("Depth texture must have data type of UNSIGNED_INT or UNSIGNED_SHORT!"):console.error("Depth/Stencil texture must have data type of UNSIGNED_INT_24_8!"):console.error("Depth/Stencil texture must have a pixel type of DEPTH_STENCIL!")}detachDepthStencilTexture(){const e=this._depthStencilTexture;return e&&this._glName&&this._context.temporaryBindFramebuffer(this,()=>{this._framebufferTexture2D(null,D(e.descriptor.pixelFormat))}),this._depthStencilTexture=null,e}_attachDepthStencilBuffer(e){if(null==e)return;const t=e.descriptor;if(this._validateRenderbufferDescriptor(t),this._disposeDepthStencilAttachments(),this._glName){this._context.bindFramebuffer(this);const{gl:r}=this._context,i=this._getGLAttachmentPoint(t);r.framebufferRenderbuffer(36160,i,r.RENDERBUFFER,e.glName)}this._depthStencilBuffer=e}detachDepthStencilBuffer(){const e=this._depthStencilBuffer;if(e&&this._glName){const{_context:t}=this,r=t.boundFramebuffer;t.bindFramebuffer(this);const{gl:i}=t,s=this._getGLAttachmentPoint(e.descriptor);i.framebufferRenderbuffer(36160,s,i.RENDERBUFFER,null),t.bindFramebuffer(r)}return this._depthStencilBuffer=null,e}invalidateAttachments(e){const{_context:t}=this;t.temporaryBindFramebuffer(this,()=>t.gl.invalidateFramebuffer(36160,e),!0)}copyToTexture(e,t,r,i,s,n,h){(e<0||t<0||s<0||n<0)&&console.error("Offsets cannot be negative!"),(r<=0||i<=0)&&console.error("Copy width and height must be greater than zero!");const o=h.descriptor;3553!==h.descriptor.target&&console.error("Texture target must be TEXTURE_2D!"),(null==o?.width||null==o?.height||e+r>this.width||t+i>this.height||s+r>o.width||n+i>o.height)&&console.error("Bad dimensions, the current input values will attempt to read or copy out of bounds!");const c=this._context,a=c.bindTexture(h,_.TEXTURE_UNIT_FOR_UPDATES);c.setActiveTexture(_.TEXTURE_UNIT_FOR_UPDATES),c.bindFramebuffer(this),c.gl.copyTexSubImage2D(3553,0,s,n,e,t,r,i),c.bindTexture(a,_.TEXTURE_UNIT_FOR_UPDATES)}readPixels(e,t,r,i,s,n,h){(r<=0||i<=0)&&console.error("Copy width and height must be greater than zero!"),h||console.error("Target memory is not initialized!"),this._context.bindFramebuffer(this),this._context.gl.readPixels(e,t,r,i,s,n,h)}async readPixelsAsync(e,t,i,s,n,h,o,c){const{gl:a}=this._context,l=r.createPixelPack(this._context,35041,o.byteLength);this._context.bindBuffer(l);const f=this._context.boundFramebuffer;this._context.bindFramebuffer(this),a.readPixels(e,t,i,s,n,h,0),this._context.unbindBuffer(35051),this._context.bindFramebuffer(f);try{await l.getSubDataAsync(o,void 0,void 0,void 0,c)}finally{l.dispose()}}resize(e,t){if(this.width===e&&this.height===t)return;const r={width:e,height:t};if(F(r,this._context.parameters.maxTextureSize),this._colorAttachments.forEach(e=>e.resize(r.width,r.height)),this._depthStencilTexture?.resize(r.width,r.height),this._glName&&(F(r,this._context.parameters.maxRenderbufferSize),this._depthStencilBuffer?.resize(r.width,r.height),i())){const{gl:e}=this._context;e.checkFramebufferStatus(36160)!==e.FRAMEBUFFER_COMPLETE&&console.error("Framebuffer is incomplete!")}}initializeAndBind(e=36160){const{gl:t}=this._context;this._glName?t.bindFramebuffer(e,this._glName):(this._glName&&t.deleteFramebuffer(this._glName),this._glName=t.createFramebuffer(),t.bindFramebuffer(e,this._glName),this._initializeAttachments(e))}_initializeAttachments(e=36160){const{gl:t}=this._context;if(this._colorAttachments.forEach((t,r)=>{if(T(t)){const i=A(t);35866===i?this._framebufferTextureLayer(t.glName,r,e):this._framebufferTexture2D(t.glName,r,i,e)}else if(g(t)){const i=this._context.gl;i.framebufferRenderbuffer(e,r,i.RENDERBUFFER,t.glName)}}),this._depthStencilBuffer){const r=this._getGLAttachmentPoint(this._depthStencilBuffer.descriptor);t.framebufferRenderbuffer(e,r,t.RENDERBUFFER,this._depthStencilBuffer.glName)}else if(this._depthStencilTexture){const t=D(this._depthStencilTexture.descriptor.pixelFormat);this._framebufferTexture2D(this._depthStencilTexture.glName,t,A(this._depthStencilTexture),e)}if(i()){t.checkFramebufferStatus(e)!==t.FRAMEBUFFER_COMPLETE&&console.error("Framebuffer is incomplete!")}}_framebufferTexture2D(e,t=n,r=3553,i=36160){this._context.gl.framebufferTexture2D(i,t,r,e,this._level)}_framebufferTextureLayer(e,t=n,r=36160,i=0){this._context.gl.framebufferTextureLayer(r,t,e,this._level,i)}_disposeDepthStencilAttachments(){const e=this._context.gl;if(this._depthStencilBuffer){if(this._glName){this._context.bindFramebuffer(this);const t=this._getGLAttachmentPoint(this._depthStencilBuffer.descriptor);e.framebufferRenderbuffer(36160,t,e.RENDERBUFFER,null)}this._depthStencilBuffer=t(this._depthStencilBuffer)}this._depthStencilTexture&&(this._glName&&(this._context.bindFramebuffer(this),this._framebufferTexture2D(null,D(this._depthStencilTexture.descriptor.pixelFormat))),this._depthStencilTexture=t(this._depthStencilTexture))}_validateTextureDescriptor(e){3553!==e.target&&34067!==e.target&&35866!==e.target&&console.error("Texture type must be TEXTURE_2D, TEXTURE_2D_ARRAY or TEXTURE_CUBE_MAP!"),F(e,this._context.parameters.maxTextureSize),this._validateBufferDimensions(e)}_validateRenderbufferDescriptor(e){F(e,this._context.parameters.maxRenderbufferSize),this._validateBufferDimensions(e)}_validateBufferDimensions(e){e.width<=0&&(e.width=this.width),e.height<=0&&(e.height=this.height),this.width>0&&this.height>0&&(this.width===e.width&&this.height===e.height||console.error("Attachment size must match framebuffer size!"))}_getGLAttachmentPoint(e){switch(e.internalFormat){case l.DEPTH_COMPONENT16:case l.DEPTH_COMPONENT24:case l.DEPTH_COMPONENT32F:return f;case c.DEPTH24_STENCIL8:case c.DEPTH32F_STENCIL8:return a;case 36168:return o;default:return n}}_validateColorAttachmentPoint(t){if(-1===d._MAX_COLOR_ATTACHMENTS){const{gl:e}=this._context;d._MAX_COLOR_ATTACHMENTS=e.getParameter(e.MAX_COLOR_ATTACHMENTS)}const r=t-n;r+1>d._MAX_COLOR_ATTACHMENTS&&e.getLogger("esri.views.webgl.FrameBufferObject").error("esri.FrameBufferObject",`illegal attachment point for color attachment: ${r+1}. Implementation supports up to ${d._MAX_COLOR_ATTACHMENTS} color attachments`)}}class p extends d{constructor(e,t,r){super(e,t,r)}dispose(){const{_colorAttachments:e,_glName:t,_context:r}=this;if(r.instanceCounter.decrement(s.FramebufferObject,this),0===e.size&&!this._depthStencilBuffer&&!this._depthStencilTexture&&!t)return;const i=r.boundFramebuffer,n=Array.from(e.values());this.detachColorTextures(...e.keys()),n.forEach(e=>e.dispose()),this.detachDepthStencilBuffer()?.dispose(),this.detachDepthStencilTexture()?.dispose(),r.gl.deleteFramebuffer(this._glName),this._glName=null,r.bindFramebuffer(i===this?null:i)}}function T(e){return 1===E(e)}function g(e){return 2===E(e)}function x(e){return T(e)||b(e)}function b(e){return 0===E(e)}function S(e){return 3===E(e)||null!=e&&"samples"in e}function E(e){return null!=e&&"type"in e?e.type:null}function N(e,t){return T(t)||g(t)?t:b(t)?new _(e,t):S(t)?new u(e,t):null}function F(e,t){const r=Math.max(e.width,e.height);if(r>t){m().warnOnce(`Resizing FBO attachment size ${e.width}x${e.height} to device limit ${t}`);const i=t/r;return e.width=Math.round(e.width*i),e.height=Math.round(e.height*i),!1}return!0}function A(e){return 34067===e.descriptor.target?34069:35866===e.descriptor.target?35866:3553}function D(e){return 6402===e?f:a}export{p as DisposableFramebufferObject,d as FramebufferObject,F as ensureAttachmentMaxSize};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import e from"../../core/Error.js";import{allSettledErrors as t,throwIfAborted as r,eachAlways as o}from"../../core/promiseUtils.js";import{generateUUID as s}from"../../core/uuid.js";import{getSiblingOfSameTypeI as a,contentToBlob as c}from"../../portal/support/resourceUtils.js";async function p(e,t,r){const o=await u(e,t,r);await h(o,t,r)}async function n(e,t,r,o,s){const a=await u(r,o,s);await e.update({data:t}),await h(a,o,s)}async function u(o,p,n){if(!p?.resources)return;const u=p.portalItem===o.portalItem?new Set(o.paths):new Set;o.paths.length=0,o.portalItem=p.portalItem;const h=new Set(p.resources.toKeep.map(e=>e.resource.path)),i=new Set,m=[];h.forEach(e=>{u.delete(e),o.paths.push(e)});const f=[],l=[],w=[];for(const e of p.resources.toUpdate)if(u.delete(e.resource.path),h.has(e.resource.path)||i.has(e.resource.path)){const{resource:t,content:r,finish:p}=e,n=a(t,s());o.paths.push(n.path),f.push({resource:n,content:await c(r),compress:e.compress}),p&&w.push(()=>p(n))}else{o.paths.push(e.resource.path),l.push({resource:e.resource,content:await c(e.content),compress:e.compress});const t=e.finish;t&&w.push(()=>t(e.resource)),i.add(e.resource.path)}for(const e of p.resources.toAdd)if(o.paths.push(e.resource.path),u.has(e.resource.path))u.delete(e.resource.path);else{f.push({resource:e.resource,content:await c(e.content),compress:e.compress});const t=e.finish;t&&w.push(()=>t(e.resource))}if(f.length||l.length){const{addOrUpdateResources:e}=await import("../../portal/support/resourceUtils.js");await e(p.portalItem,f,"add",n),await e(p.portalItem,l,"update",n)}if(w.forEach(e=>e()),0===m.length)return u;const d=await t(m);if(r(n),d.length>0)throw new e("save:resources","Failed to save one or more resources",{errors:d});return u}async function h(e,t,r){if(!e||!t.portalItem)return;const s=[];for(const o of e){const e=t.portalItem.resourceFromPath(o);s.push(e.portalItem.removeResource(e,r))}await o(s)}export{p as saveResources,n as updateItemWithResources};
2
+ import e from"../../core/Error.js";import{allSettledErrors as t,throwIfAborted as r,eachAlways as o}from"../../core/promiseUtils.js";import{generateUUID as s}from"../../core/uuid.js";import{getSiblingOfSameTypeI as a,contentToBlob as c}from"../../portal/support/resourceUtils.js";async function p(e,t,r){const o=await u(e,t,r);await h(o,t,r)}async function n(e,t,r,o,s){const a=await u(r,o,s);await e.update({data:t}),await h(a,o,s)}async function u(o,p,n){if(!p?.resources)return;const u=i(o,p)?new Set(o.paths):new Set;o.paths.length=0,o.portalItem=p.portalItem,o.portalItemResourcePath=p.portalItemResourcePath;const h=new Set(p.resources.toKeep.map(e=>e.resource.path)),m=new Set,l=[];h.forEach(e=>{u.delete(e),o.paths.push(e)});const f=[],w=[],d=[];for(const e of p.resources.toUpdate)if(u.delete(e.resource.path),h.has(e.resource.path)||m.has(e.resource.path)){const{resource:t,content:r,finish:p}=e,n=a(t,s());o.paths.push(n.path),f.push({resource:n,content:await c(r),compress:e.compress}),p&&d.push(()=>p(n))}else{o.paths.push(e.resource.path),w.push({resource:e.resource,content:await c(e.content),compress:e.compress});const t=e.finish;t&&d.push(()=>t(e.resource)),m.add(e.resource.path)}for(const e of p.resources.toAdd)if(o.paths.push(e.resource.path),u.has(e.resource.path))u.delete(e.resource.path);else{f.push({resource:e.resource,content:await c(e.content),compress:e.compress});const t=e.finish;t&&d.push(()=>t(e.resource))}if(f.length||w.length){const{addOrUpdateResources:e}=await import("../../portal/support/resourceUtils.js");await e(p.portalItem,f,"add",n),await e(p.portalItem,w,"update",n)}if(d.forEach(e=>e()),0===l.length)return u;const I=await t(l);if(r(n),I.length>0)throw new e("save:resources","Failed to save one or more resources",{errors:I});return u}async function h(e,t,r){if(!e||!t.portalItem)return;const s=[];for(const o of e){const e=t.portalItem.resourceFromPath(o);s.push(e.portalItem.removeResource(e,r))}await o(s)}function i(e,t){const{portalItem:r,portalItemResourcePath:o}=e,{portalItem:s,portalItemResourcePath:a}=t;return r===s&&(!(o||a)||o===a)}export{p as saveResources,n as updateItemWithResources};
@@ -22,6 +22,8 @@ export interface SaveAsOptions extends SaveOptions {
22
22
  * @since 5.0
23
23
  */
24
24
  folder?: PortalFolder;
25
+ /** @internal */
26
+ portalItemResourcePath?: string;
25
27
  }
26
28
 
27
29
  /** @since 5.0 */
@@ -0,0 +1,2 @@
1
+ /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
+ const e="Knowledge Studio Project",t=new Set(["Web Link Chart","Web Map","Web Scene"]);function n(e){return!!e.type&&t.has(e.type)}function o(t){return t.type===e}export{n as hasWebDocumentAsPrimaryContent,o as hasWebDocumentAsResource};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import e from"../../Viewpoint.js";import t from"../../core/Error.js";import r from"../../core/Logger.js";import{geographicToWebMercator as o}from"../../geometry/support/webMercatorUtils.js";import n from"../../portal/Portal.js";import{createForItemRead as i}from"../../portal/support/jsonContext.js";import{project as a}from"../../rest/geometryService/project.js";import s from"../../rest/support/ProjectParameters.js";function p(e,t){return t.resourceInfo?l(t,t.resourceInfo,{origin:e.origin}):t.portalItem?.id?c(e,t,t.portalItem):Promise.resolve()}function l(e,t,r){const o={context:{...r,layerContainerType:"operational-layers"}};return e.portalItem&&(o.context.portal=e.portalItem.portal||n.getDefault()),import("../../layers/support/layersCreator.js").then(({populateOperationalLayers:r})=>{const n=[],i=t.operationalLayers;i?.length&&n.push(r(e.layers,i,o));const a={...o,context:{...o.context,layerContainerType:"tables"},defaultLayerType:"ArcGISFeatureLayer"},s=t.tables;return s?.length&&n.push(r(e.tables,s,a)),Promise.allSettled(n).then(()=>{})})}async function c(e,o,n){if(await n.load().catch(r=>{throw new t(`${e.name}:load-portal-item`,"Failed to load portal item",{error:r})}),n.type!==e.itemType)throw new t(`${e.name}:invalid-portal-item`,`Invalid portal item type '${n.type}', expected '${e.itemType}'`,{type:n.type});const a=await n.fetchData();o.resourceInfo=a;const s=i(n,e.origin);await m(e,o,a,s),o.resourceReferences={portalItem:n,paths:s.readResourcePaths};const p=await f(o.initialViewProperties,n,r.getLogger(o));if(p){const t=o.initialViewProperties?.clone()??e.createInitialViewProperties();t.viewpoint=p,o.initialViewProperties=t}}function m(e,t,r,o){const n=u(e,r);return t.read(n,o),l(t,n,o)}function u(e,t){const r=e.parseVersion(t.version||"",e.name);return e.currentVersion.validate(r),t.version=`${r.major}.${r.minor}`,t}async function f(t,r,o){const n=t?.viewpoint?.targetGeometry;if(n)return null;const i=await y(t,r,o);if(!i)return null;return new e({targetGeometry:i})}async function y(e,t,r){const n=e?.spatialReference,i=t?.extent;if(!n||!i)return null;if(n.isWGS84)return i.clone();if(n.isWebMercator)return o(i);const{getGeometryServiceURL:p}=await import("../../portal/support/geometryServiceUtils.js");try{const e=await p(t),r=new s({geometries:[i],outSpatialReference:n});return(await a(e,r))[0]}catch(l){r.error("Error projecting item's extent:",l)}return null}export{p as loadFromSource};
2
+ import e from"../../Viewpoint.js";import t from"../../core/Error.js";import r from"../../core/Logger.js";import{geographicToWebMercator as o}from"../../geometry/support/webMercatorUtils.js";import a from"../../portal/Portal.js";import{createForItemRead as i}from"../../portal/support/jsonContext.js";import{project as n}from"../../rest/geometryService/project.js";import s from"../../rest/support/ProjectParameters.js";import{hasWebDocumentAsPrimaryContent as p}from"./utils.js";function l(e,t){return t.resourceInfo?c(t,t.resourceInfo,{origin:e.origin}):t.portalItem?.id?m(e,t,t.portalItem):Promise.resolve()}function c(e,t,r){const o={context:{...r,layerContainerType:"operational-layers"}};return e.portalItem&&(o.context.portal=e.portalItem.portal||a.getDefault()),import("../../layers/support/layersCreator.js").then(({populateOperationalLayers:r})=>{const a=[],i=t.operationalLayers;i?.length&&a.push(r(e.layers,i,o));const n={...o,context:{...o.context,layerContainerType:"tables"},defaultLayerType:"ArcGISFeatureLayer"},s=t.tables;return s?.length&&a.push(r(e.tables,s,n)),Promise.allSettled(a).then(()=>{})})}async function m(e,o,a){await a.load().catch(r=>{throw new t(`${e.name}:load-portal-item`,"Failed to load portal item",{error:r})});const n=a.type,s=e.supportedItemTypes;if(!n||!s.has(n))throw new t(`${e.name}:invalid-portal-item`,`Invalid portal item type '${n}', expected one of: '${Array.from(s).join("', '")}'`,{type:n});let l;const{portalItemResourcePath:c}=o;if(p(a)){if(c)throw new t(`${e.name}:portal-item-resource-path-not-supported`,`'portalItemResourcePath' is not supported when loading a map from '${n}' item`);l=await a.fetchData()}else{if(!c)throw new t(`${e.name}:missing-portal-item-resource-path`,`'portalItemResourcePath' is required to load a map from '${n}' item`);const r=a.resourceFromPath(c);l=await r.fetch()}o.resourceInfo=l;const m=i(a,e.origin);await u(e,o,l,m),o.resourceReferences={portalItem:a,portalItemResourcePath:c,paths:m.readResourcePaths};const f=await w(o.initialViewProperties,a,r.getLogger(o));if(f){const t=o.initialViewProperties?.clone()??e.createInitialViewProperties();t.viewpoint=f,o.initialViewProperties=t}}function u(e,t,r,o){const a=f(e,r);return t.read(a,o),c(t,a,o)}function f(e,t){const r=e.parseVersion(t.version||"",e.name);return e.currentVersion.validate(r),t.version=`${r.major}.${r.minor}`,t}async function w(t,r,o){const a=t?.viewpoint?.targetGeometry;if(a)return null;const i=await y(t,r,o);if(!i)return null;return new e({targetGeometry:i})}async function y(e,t,r){const a=e?.spatialReference,i=t?.extent;if(!a||!i)return null;if(a.isWGS84)return i.clone();if(a.isWebMercator)return o(i);const{getGeometryServiceURL:p}=await import("../../portal/support/geometryServiceUtils.js");try{const e=await p(t),r=new s({geometries:[i],outSpatialReference:a});return(await n(e,r))[0]}catch(l){r.error("Error projecting item's extent:",l)}return null}export{l as loadFromSource};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import e from"../../core/Error.js";import{MultiOriginJSONSupport as t}from"../../core/MultiOriginJSONSupport.js";import{whenOnce as r}from"../../core/reactiveUtils.js";import{hasSameCanonicalPortal as o,urlToObject as a}from"../../core/urlUtils.js";import{updateOrigins as i}from"../../core/accessorSupport/originUtils.js";import n from"../../geometry/SpatialReference.js";import{webMercatorToGeographic as s}from"../../geometry/support/webMercatorUtils.js";import{isServerOrServicesAGOLUrl as l}from"../../layers/support/arcgisLayerUrl.js";import{isLayerWithFeatureLayerSource as p,isFeatureCollectionLayer as c}from"../../layers/support/layerUtils.js";import m from"../../portal/Portal.js";import u from"../../portal/PortalItem.js";import{createForItemWrite as d}from"../../portal/support/jsonContext.js";import{removeTypeKeyword as f,addTypeKeyword as y,typeKeyword as w,toggleTypeKeyword as g,hasTypeKeyword as h}from"../../portal/support/portalItemUtils.js";import{project as _}from"../../rest/geometryService/project.js";import b from"../../rest/support/ProjectParameters.js";import{hasDeveloperBasemapLayer as j,isDeveloperBasemapLayer as v}from"../../support/basemapUtils.js";import{saveResources as R}from"./resourceUtils.js";import{beforeSave as S,evaluateWriteErrors as W,hasCharts as I}from"./saveUtils.js";const P=["NatGeo_World_Map","Ocean_Basemap","USA_Topo_Maps","World_Imagery","World_Street_Map","World_Terrain_Base","World_Topo_Map","World_Hillshade","Canvas/World_Light_Gray_Base","Canvas/World_Light_Gray_Reference","Canvas/World_Dark_Gray_Base","Canvas/World_Dark_Gray_Reference","Ocean/World_Ocean_Base","Ocean/World_Ocean_Reference","Reference/World_Boundaries_and_Places","Reference/World_Reference_Overlay","Reference/World_Transportation"].map(e=>e.toLowerCase());async function A(e,t,o){o??={},U(e,t),await r(()=>!t.updatingFromView),await t.load(),await D(t),await S(t),await M(e,t);const a=t.portalItem,{json:i,jsonContext:n}=await O(t,a,e.origin);return W(n,{errorName:`${e.name}:save`},o),await k(t,a),await me(e,t,a,i,n),await Promise.all([t.updateItemThumbnail(),R(t.resourceReferences,n)]),a}async function O(e,t,r){const o=d(t,r,!0),a=e.write({},o);return await Promise.all(o.resources.pendingOperations),{json:a,jsonContext:o}}async function T(e,t,o,a){a??={};const i=t.portalItem,n=E(e,o);await r(()=>!t.updatingFromView),await t.load(),await D(t),await S(t),await M(e,t);const{json:s,jsonContext:l}=await O(t,n,e.origin);W(l,{errorName:`${e.name}:save`},a),await Y(t,n);const p=t.getThumbnailState();return await ue(e,t,n,s,l,a)&&(t.resourceReferences.portalItem=n),t.restoreThumbnailFromState(p),await Promise.all([t.updateItemThumbnail(i),R(t.resourceReferences,l)]),n}function U(t,r){if(!r.portalItem)throw new e(`${t.name}:portal-item-not-set`,"Portal item to save to has not been set on the WebMap");C(t,r.portalItem)}function C(t,r){if(r.type!==t.itemType)throw new e(`${t.name}:portal-item-wrong-type`,`Portal item needs to have type "${t.itemType}"`)}async function M(t,r){if("linkchart"!==t.name&&!r.basemap?.baseLayers.length)throw new e(`${t.name}:save`,"Map does not have a valid basemap with a base layer.")}function E(e,t){let r=u.from(t);return r.id&&(r=r.clone(),r.id=null),r.type||(r.type=e.itemType),r.portal||(r.portal=m.getDefault()),C(e,r),r}function D(e){const t=[];return e.basemap&&t.push(e.basemap.load()),e.ground&&t.push(e.ground.load()),Promise.allSettled(t).then(()=>{})}async function k(e,t){t.extent=await ae(e.portalItem,e.initialViewProperties.viewpoint.targetGeometry),await Z(e,t)}const x=w.JSAPI,G="CollectorDisabled",L="Collector",N="Data Editing",V="OfflineDisabled",B="Offline",$="Workforce Project",F="Workforce Worker",H="Workforce Dispatcher",K="Offline Map Areas",J="FieldMapsDisabled",q=w.DEVELOPER_BASEMAP,z="UtilityNetwork",Q="ParcelFabric",X="IPS";async function Y(e,t){f(t,G),f(t,J),f(t,w.METADATA),f(t,V),f(t,K),f(t,H),f(t,$),f(t,F),await k(e,t)}async function Z(e,t){y(t,x),await ee(e),g(t,L,!h(t,G)&&!h(t,$)&&!h(t,F)&&!h(t,H)&&re(e)),g(t,N,re(e)),g(t,B,!h(t,V)&&oe(e)),g(t,q,j(e.basemap)),g(t,z,!!e.utilityNetworks?.length),g(t,Q,!!e.parcelFabric),g(t,X,!!e.ipsInfo),g(t,w.CHARTS,I(e)),t.typeKeywords&&(t.typeKeywords=t.typeKeywords.filter((e,t,r)=>r.indexOf(e)===t))}function ee(e){const t=te(e).map(e=>e.load()).toArray();return Promise.allSettled(t).then(()=>{})}function te(e){return e.allLayers.concat(e.allTables)}function re(e){return te(e).some(e=>e.loaded&&p(e)&&e.capabilities.operations.supportsEditing&&"editingEnabled"in e&&e.editingEnabled&&("subtype-group"!==e.type||e.sublayers.some(e=>e.editingEnabled)))}function oe(e){return te(e).filter(e=>"group"!==e.type).every(t=>t.loaded&&se(e,t))}async function ae(e,t){const r=t.clone().normalize();let o;if(r.length>1)for(const a of r)o?a.width>o.width&&(o=a):o=a;else o=r[0];return ie(e,o)}async function ie(e,t){const r=t.spatialReference;if(r.isWGS84)return t.clone();if(r.isWebMercator)return s(t);const{getGeometryServiceURL:o}=await import("../../portal/support/geometryServiceUtils.js"),a=await o(e),i=new b({geometries:[t],outSpatialReference:n.WGS84});return(await _(a,i))[0]}function ne(e){return c(e)||"map-notes"===e.type||"route"===e.type}function se(e,t){return p(t)&&t.capabilities.operations.supportsSync||ne(t)&&!t.portalItem||le(t)&&!pe(t)&&t.spatialReference.equals(e.initialViewProperties.spatialReference)}function le(e){return"imagery-tile"===e.type?e.supportsExportMapTiles():("tile"===e.type||"vector-tile"===e.type)&&(e.capabilities.operations.supportsExportTiles||ce(e)||v(e))}function pe(e){return"vector-tile"===e.type&&Object.keys(e.sourceNameToSource).length>1}function ce(e){return"tile"===e.type&&(l(e.url)&&P.some(t=>e.url?.toLowerCase().includes("/"+t+"/")))}async function me(e,t,r,o,a){await r.update({data:o}),ye(e,t,r,o,a)}async function ue(t,r,o,a,i,n){const s=r.portalItem,l={item:s,authenticated:!(!s?.id||!s.portal.user)},p=o.portal;await p.signIn();const{copyAllowed:c,itemReloaded:m}=await de(l,p);if(l.authenticated||=m,!c)throw new e(`${t.name}:save-as-copy-not-allowed`,"Owner of this map does not allow others to save a copy");const u=await fe(o,l,a,n);return r.portalItem=o,ye(t,r,o,a,i),u}async function de(e,t){const{item:r,authenticated:o}=e;return r?.id&&r.typeKeywords?.includes("useOnly")?r.portal.portalHostname!==t.portalHostname?{copyAllowed:!1,itemReloaded:!1}:(o||await r.reload(),{copyAllowed:"admin"===r.itemControl||"update"===r.itemControl,itemReloaded:!0}):{copyAllowed:!0,itemReloaded:!1}}async function fe(e,t,r,a){const i=e.portal,{item:n}=t,{folder:s,copyAllResources:l}=a;let p=!1;if(l&&n?.id&&o(n.portal.url,i.url)&&parseInt(n.portal.currentVersion,10)>=2023){const{total:e}=await n.fetchResources();p=!!e}if(p){const t=await n.copy({copyResources:"all",folder:s});e.id=t.id,e.portal=t.portal;const o=e.toJSON();await e.load(),e.read(o),await e.update({data:r})}else await i.user.addItem({item:e,folder:s,data:r});return p}function ye(e,r,o,n,s){t.prototype.read.call(r,{version:n.version,authoringApp:n.authoringApp,authoringAppVersion:n.authoringAppVersion},{origin:e.origin,ignoreDefaults:!0,url:o.itemUrl?a(o.itemUrl):void 0}),i(s),r.resourceInfo=n}export{O as createJSON,fe as initializeNewItem,de as isCopyAllowed,A as save,T as saveAs};
2
+ import e from"../../core/Error.js";import{MultiOriginJSONSupport as t}from"../../core/MultiOriginJSONSupport.js";import{whenOnce as r}from"../../core/reactiveUtils.js";import{hasSameCanonicalPortal as o,urlToObject as a}from"../../core/urlUtils.js";import{updateOrigins as i}from"../../core/accessorSupport/originUtils.js";import n from"../../geometry/SpatialReference.js";import{webMercatorToGeographic as s}from"../../geometry/support/webMercatorUtils.js";import{isServerOrServicesAGOLUrl as l}from"../../layers/support/arcgisLayerUrl.js";import{isLayerWithFeatureLayerSource as p,isFeatureCollectionLayer as c}from"../../layers/support/layerUtils.js";import u from"../../portal/Portal.js";import m from"../../portal/PortalItem.js";import{createForItemWrite as d}from"../../portal/support/jsonContext.js";import{removeTypeKeyword as f,addTypeKeyword as w,typeKeyword as y,toggleTypeKeyword as h,hasTypeKeyword as g}from"../../portal/support/portalItemUtils.js";import{project as I}from"../../rest/geometryService/project.js";import R from"../../rest/support/ProjectParameters.js";import{hasDeveloperBasemapLayer as P,isDeveloperBasemapLayer as _}from"../../support/basemapUtils.js";import{saveResources as b}from"./resourceUtils.js";import{beforeSave as j,evaluateWriteErrors as v,hasCharts as S}from"./saveUtils.js";import{hasWebDocumentAsPrimaryContent as W,hasWebDocumentAsResource as A}from"./utils.js";const O=["NatGeo_World_Map","Ocean_Basemap","USA_Topo_Maps","World_Imagery","World_Street_Map","World_Terrain_Base","World_Topo_Map","World_Hillshade","Canvas/World_Light_Gray_Base","Canvas/World_Light_Gray_Reference","Canvas/World_Dark_Gray_Base","Canvas/World_Dark_Gray_Reference","Ocean/World_Ocean_Base","Ocean/World_Ocean_Reference","Reference/World_Boundaries_and_Places","Reference/World_Reference_Overlay","Reference/World_Transportation"].map(e=>e.toLowerCase());async function T(e,t,o){o??={},M(e,t),await r(()=>!t.updatingFromView),await t.load(),await k(t),await j(t),await $(e,t);const a=t.portalItem,{json:i,jsonContext:n}=await C(t,a,e.origin,t.portalItemResourcePath);return v(n,{errorName:`${e.name}:save`},o),await x(t,a),await de(e,t,a,i,n),await Promise.all([W(a)?t.updateItemThumbnail():null,b(t.resourceReferences,n)]),a}async function C(e,t,r,o){const a=A(t),i=a&&t.id===e.portalItem?.id&&o!==e.portalItemResourcePath,n=d(t,r,{withResources:!0,forceNewItemContext:i});n.portalItemResourcePath=a?o:null;const s=e.write({},n);return await Promise.all(n.resources.pendingOperations),{json:s,jsonContext:n}}async function U(e,t,o,a){a??={};const i=t.portalItem,n=await D(e,t,o,a);await r(()=>!t.updatingFromView),await t.load(),await k(t),await j(t),await $(e,t);const{json:s,jsonContext:l}=await C(t,n,e.origin,a.portalItemResourcePath);let p;v(l,{errorName:`${e.name}:save`},a),await ee(t,n);const c=W(n);c&&(p=t.getThumbnailState());return await fe(e,t,n,s,l,a)&&(t.resourceReferences.portalItem=n),p&&t.restoreThumbnailFromState(p),await Promise.all([c?t.updateItemThumbnail(i):null,b(t.resourceReferences,l)]),n}function M(t,r){if(!r.portalItem)throw new e(`${t.name}:portal-item-not-set`,"Portal item to save to has not been set on the WebMap");E(t,r.portalItem)}function E(t,r){const o=r.type,a=t.supportedItemTypes;if(!o||!a.has(o))throw new e(`${t.name}:portal-item-wrong-type`,`Portal item needs to have one of these types: '${Array.from(a).join("', '")}'`)}async function $(t,r){if("linkchart"!==t.name&&!r.basemap?.baseLayers.length)throw new e(`${t.name}:save`,"Map does not have a valid basemap with a base layer.")}async function D(t,r,o,a){let i=m.from(o);i.id&&await i.load();const{portalItemResourcePath:n}=a,{name:s,primaryItemType:l}=t;if(A(i)){if(!n)throw new e(`${s}:missing-portal-item-resource-path`,`'portalItemResourcePath' is required to save a map to '${i.type}' item`);if(n===r.portalItemResourcePath&&i.id===r.portalItem?.id)throw new e(`${s}:invalid-portal-item-resource-path`,`Target 'portalItemResourcePath' should be different from '${s}.portalItemResourcePath'`);return i}if(n)throw new e(`${s}:portal-item-resource-path-not-supported`,`'portalItemResourcePath' is not supported when saving a map to '${l}' item`);return i.id&&(i=i.clone(),i.id=null),i.type||(i.type=l),i.portal||(i.portal=u.getDefault()),E(t,i),i}function k(e){const t=[];return e.basemap&&t.push(e.basemap.load()),e.ground&&t.push(e.ground.load()),Promise.allSettled(t).then(()=>{})}async function x(e,t){A(t)||(t.extent=await ne(e.portalItem,e.initialViewProperties.viewpoint.targetGeometry),await te(e,t))}const N=y.JSAPI,G="CollectorDisabled",L="Collector",B="Data Editing",F="OfflineDisabled",V="Offline",H="Workforce Project",J="Workforce Worker",K="Workforce Dispatcher",q="Offline Map Areas",z="FieldMapsDisabled",Q=y.DEVELOPER_BASEMAP,X="UtilityNetwork",Y="ParcelFabric",Z="IPS";async function ee(e,t){A(t)||(f(t,G),f(t,z),f(t,y.METADATA),f(t,F),f(t,q),f(t,K),f(t,H),f(t,J),await x(e,t))}async function te(e,t){w(t,N),await re(e),h(t,L,!g(t,G)&&!g(t,H)&&!g(t,J)&&!g(t,K)&&ae(e)),h(t,B,ae(e)),h(t,V,!g(t,F)&&ie(e)),h(t,Q,P(e.basemap)),h(t,X,!!e.utilityNetworks?.length),h(t,Y,!!e.parcelFabric),h(t,Z,!!e.ipsInfo),h(t,y.CHARTS,S(e)),t.typeKeywords&&(t.typeKeywords=t.typeKeywords.filter((e,t,r)=>r.indexOf(e)===t))}function re(e){const t=oe(e).map(e=>e.load()).toArray();return Promise.allSettled(t).then(()=>{})}function oe(e){return e.allLayers.concat(e.allTables)}function ae(e){return oe(e).some(e=>e.loaded&&p(e)&&e.capabilities.operations.supportsEditing&&"editingEnabled"in e&&e.editingEnabled&&("subtype-group"!==e.type||e.sublayers.some(e=>e.editingEnabled)))}function ie(e){return oe(e).filter(e=>"group"!==e.type).every(t=>t.loaded&&pe(e,t))}async function ne(e,t){const r=t.clone().normalize();let o;if(r.length>1)for(const a of r)o?a.width>o.width&&(o=a):o=a;else o=r[0];return se(e,o)}async function se(e,t){const r=t.spatialReference;if(r.isWGS84)return t.clone();if(r.isWebMercator)return s(t);const{getGeometryServiceURL:o}=await import("../../portal/support/geometryServiceUtils.js"),a=await o(e),i=new R({geometries:[t],outSpatialReference:n.WGS84});return(await I(a,i))[0]}function le(e){return c(e)||"map-notes"===e.type||"route"===e.type}function pe(e,t){return p(t)&&t.capabilities.operations.supportsSync||le(t)&&!t.portalItem||ce(t)&&!ue(t)&&t.spatialReference.equals(e.initialViewProperties.spatialReference)}function ce(e){return"imagery-tile"===e.type?e.supportsExportMapTiles():("tile"===e.type||"vector-tile"===e.type)&&(e.capabilities.operations.supportsExportTiles||me(e)||_(e))}function ue(e){return"vector-tile"===e.type&&Object.keys(e.sourceNameToSource).length>1}function me(e){return"tile"===e.type&&(l(e.url)&&O.some(t=>e.url?.toLowerCase().includes("/"+t+"/")))}async function de(e,t,r,o,a){if(W(r))await r.update({data:o});else{await r.portal.signIn();const e=r.resourceFromPath(t.portalItemResourcePath);await e.update(ge(o))}he(e,t,r,o,a)}async function fe(t,r,o,a,i,n){const s=r.portalItem,l={item:s,authenticated:!(!s?.id||!s.portal.user)},p=o.portal;await p.signIn();const{copyAllowed:c,itemReloaded:u}=await we(l,p);if(l.authenticated||=u,!c)throw new e(`${t.name}:save-as-copy-not-allowed`,"Owner of this map does not allow others to save a copy");let m=!1;if(W(o))m=await ye(o,l,a,n);else{const e=o.resourceFromPath(n.portalItemResourcePath);await o.addResource(e,ge(a))}return r.portalItem=o,r.portalItemResourcePath=n.portalItemResourcePath,he(t,r,o,a,i),m}async function we(e,t){const{item:r,authenticated:o}=e;return r&&W(r)&&r.id&&r.typeKeywords?.includes("useOnly")?r.portal.portalHostname!==t.portalHostname?{copyAllowed:!1,itemReloaded:!1}:(o||await r.reload(),{copyAllowed:"admin"===r.itemControl||"update"===r.itemControl,itemReloaded:!0}):{copyAllowed:!0,itemReloaded:!1}}async function ye(e,t,r,a){const i=e.portal,{item:n}=t,{folder:s,copyAllResources:l}=a;let p=!1;if(l&&n?.id&&n.type===e.type&&o(n.portal.url,i.url)&&parseInt(n.portal.currentVersion,10)>=2023){const{total:e}=await n.fetchResources();p=!!e}if(p){const t=await n.copy({copyResources:"all",folder:s});e.id=t.id,e.portal=t.portal;const o=e.toJSON();await e.load(),e.read(o),await e.update({data:r})}else await i.user.addItem({item:e,folder:s,data:r});return p}function he(e,r,o,n,s){t.prototype.read.call(r,{version:n.version,authoringApp:n.authoringApp,authoringAppVersion:n.authoringAppVersion},{origin:e.origin,ignoreDefaults:!0,url:o.itemUrl?a(o.itemUrl):void 0}),i(s),r.resourceInfo=n}function ge(e){return new Blob([JSON.stringify(e)],{type:"application/json"})}export{C as createJSON,ye as initializeNewItem,we as isCopyAllowed,T as save,U as saveAs};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{__decorate as e}from"tslib";import{pushIfSome as t}from"../../core/arrayUtils.js";import{createTask as s}from"../../core/asyncUtils.js";import a from"../../core/Collection.js";import i from"../../core/Error.js";import{EventedAccessor as n}from"../../core/Evented.js";import r from"../../core/Logger.js";import{getOrCreateMapValue as o}from"../../core/MapUtils.js";import{destroyMaybe as l,abortMaybe as h}from"../../core/maybe.js";import{throwIfAborted as c,whenOrAbort as p,ignoreAbortErrors as u,isAbortError as m}from"../../core/promiseUtils.js";import d from"../../core/ReactiveMap.js";import{on as g,sync as y,watch as f,syncAndInitial as v,initial as _,whenOnce as A}from"../../core/reactiveUtils.js";import{property as F,subclass as I}from"../../core/accessorSupport/decorators.js";import{UpdatingHandles as w}from"../../core/support/UpdatingHandles.js";import E from"../../geometry/SpatialReference.js";import{getGraphicLayer as x}from"../../graphic/graphicOriginUtils.js";import{isSubtypeGroupLayer as C,isSubtypeSublayer as T,isFeatureLayer as M,getSubtypesFromLayer as k}from"../../layers/support/layerUtils.js";import{system as b}from"../../time/constants.js";import{getAttachmentKey as V}from"./attachmentUtils.js";import{getLayerTimeZone as S,getEffectiveTimeZone as L,createReactiveGraphic as R,isAttributeFormSupportedLayerWithAttachments as H,layerSupportsAttachments as P,queryAttachmentsForElements as j}from"./batchAttributeFormUtils.js";import{ReactiveContingentValuesManager as U}from"./ReactiveContingentValuesManager.js";import{parseFormTemplateString as O}from"./stringUtils.js";import{ValueChangeTransaction as G}from"./ValueChangeTransaction.js";import{ArcadeExecutorProvider as B}from"./expressions/ArcadeExecutorProvider.js";import{ExpressionsManager as D}from"./expressions/ExpressionsManager.js";import{ExpressionsModel as N}from"./expressions/ExpressionsModel.js";import W from"./inputs/BatchFormInputs.js";import{createBatchFormInputsFromBatchFormTemplate as Z,mergeBatchFormInputsFromNewTemplate as $}from"./inputs/support/createBatchFormInputs.js";import{isGroupInput as K,isFieldInput as z}from"./inputs/support/inputUtils.js";import q from"./templates/BatchFormTemplate.js";import{createBatchFormTemplate as J}from"./templates/support/createBatchFormTemplate.js";import{isExcludedFromSharedForm as Q,isGroupElementTemplate as X}from"./templates/support/templateUtils.js";import{ContingentValuesManager as Y,isLayerWithContingentValues as ee}from"../support/ContingentValuesManager.js";import{isEmptyValue as te}from"../support/forms/formUtils.js";function se(e,t){return e?.find(e=>e.layer===t)}let ae=class extends n{constructor(e){super(e),this._attachmentCache=new d,this.activeFeatureIndex=-1,this.attachmentsEnabled=!1,this.callbacks=null,this.disabled=!1,this.editType="NA",this.features=new a,this._hasAsyncArcadeExpressions=!1,this.highlightHelper=null,this.maximumFeatureCount=2e3,this.maximumFeatureCountWithComplexForms=50,this.map=null,this.pageStack=[],this.readOnly=!1,this.pendingSubtypeChoice=null,this.spatialReference=null,this.submitHasBeenAttempted=!1,this.timeZone=null,this.userHasChangedValues=!1,this.layerInfos=null,this._arcadeExecutorProvider=new B,this._activeAssociation=null,this._activeAssociationsInput=null,this._activeRelationshipInput=null,this._ownContingentValuesManager=null,this._activeFormInputsByElementId=new Map,this._emptyForm=new W({inputs:[]}),this._emptyFormTemplate=new q({elements:[]}),this._featureFormMap=new d,this._prepareTask=null,this._layerTemplateUpdateTask=null,this._syncAttachmentsTask=null,this._reactiveGraphicLookup=new d,this._updatingHandles=new w,this._submitTask=null,this._layerTemplateMap=new d,this._workingFeatures=new a,this._expressionsManager=new D({arcadeContext:{editType:"NA",spatialReference:null,map:null,timeZone:b}}),this._getExternalErrorForFeature=(e,t)=>this._reactiveContingentValuesManager.getViolationTypeForField(e,t),this._getFieldValueOptionsForFeature=e=>this._reactiveContingentValuesManager.getAndWatchFieldValueOptions(e),this.sharedForm=this._emptyForm,this.sharedFormTemplate=this._emptyFormTemplate}initialize(){this.contingentValuesManager||(this.contingentValuesManager=this._ownContingentValuesManager=new Y),this.addHandles([g(()=>this.features,"after-changes",()=>{this.goHome(),this.notifyChange("layers"),this._prepare()},y),f(()=>[this.attachmentsEnabled,this.features,this.map,this.timeZone,this.editType],()=>this._prepare(),y),f(()=>this.activeForm,()=>{this.goHome(),this._activeFormInputsByElementId.clear(),this._syncAttachments()},y),f(()=>this.activeFeature,()=>{this.goHome()},y),f(()=>this.page,e=>{const t=[...this.pageStack];if(t.includes(e))for(;t.length&&t.at(-1)!==e;)t.pop();else t.push(e);this.pageStack=t},v),f(()=>this.contingentValuesManager,e=>{l(this._reactiveContingentValuesManager),this._reactiveContingentValuesManager=new U({manager:e})},_)]),this._prepare()}destroy(){this._prepareTask=h(this._prepareTask),this.pendingSubtypeChoice?.reject(),this._layerTemplateUpdateTask=h(this._layerTemplateUpdateTask),this._syncAttachmentsTask=h(this._syncAttachmentsTask),this._workingFeatures.destroyAll(),l(this._expressionsManager),l(this._reactiveContingentValuesManager),this._updatingHandles.destroy(),this._reactiveGraphicLookup=new d,this._emptyForm.destroy(),this._emptyFormTemplate.destroy(),this._ownContingentValuesManager=l(this._ownContingentValuesManager),this.highlightHelper?.removeAll()}get activeFeature(){const e=this.activeFeatureIndex;return e<0?null:this.features.at(e)}get activeForm(){if("batch"===this.mode)return this.sharedForm;const e=this._workingFeatures.at(this.activeFeatureIndex);if(!e)return this._emptyForm;const t=this._featureFormMap.get(e);if(t)return t;const s=this._makeBatchFormInputsForFeature(e);return s!==this._emptyForm&&this._featureFormMap.set(e,s),s}get activeLayer(){const{activeFeature:e}=this;if(!e)return null;return x(e)??null}get activeAssociation(){return this._activeAssociation}get activeAssociationsInput(){return this._activeAssociationsInput}get activeAssociationType(){return this.activeAssociationsInput?.activeAssociationType}get activeRelationshipInput(){return this._activeRelationshipInput}get calculating(){return this._expressionsManager.calculating}get expressionsManager(){return this._expressionsManager}get canGoBack(){return this.pageStack.length>1}get expressionEvaluationFailed(){return this._expressionsManager.expressionEvaluationFailed}get hasNonActiveInvalidFeatures(){if("batch"===this.mode)return!1;const{activeFeature:e}=this;return this.invalidFeatures.some(t=>t!==e)}get hasAsyncArcadeExpressions(){return this._hasAsyncArcadeExpressions}get hasTooManyFeatures(){return this._workingFeatures.length>this.maximumFeatureCount}get hasTooManyComplexFeatures(){return this._workingFeatures.length>this.maximumFeatureCountWithComplexForms&&this.hasAsyncArcadeExpressions}get invalidFeatures(){return this.sharedForm.invalidFeatures}get hasVisibleInputs(){return this.visibleInputs.length>0}get hasLayersWithContingentValues(){const e=this.contingentValuesManager;for(const t of this.layers)if(e.getFieldsWithContingentValues(t).size>0)return!0;return!1}get formDescription(){return this._computeFormHeaderField(this.activeForm?.description)}get formTitle(){return this._computeFormHeaderField(this.activeForm?.title)}get effectiveTimeZone(){const{activeLayer:e,timeZone:t}=this;if(!e)return t??"system";const s=S(e);return L(t,s)}get visibleInputs(){return this.activeForm.inputs.filter(e=>e.visible)}get noVisibleElementsReason(){if(this.hasVisibleInputs)return null;if(0===this.activeForm.inputs.length)return"noElements";const e=new Set;for(const t of this.activeForm.inputs)switch(t.visibilityCode){case"hidden:not-in-all-layers":case"hidden:no-domain-in-common":e.add("noElementsInCommon");break;case"hidden:field-definition":case"hidden:group-visibility-expression:all-features":case"hidden:visibility-expression:all-features":e.add("allElementsHidden");break;case"hidden:group-visibility-expression:some-features":case"hidden:visibility-expression:some-features":return"elementsHiddenInSome"}return e.has("allElementsHidden")?"allElementsHidden":"noElementsInCommon"}get page(){return this.showingSelectedAttachmentReplacePage&&this.selectedAttachmentDetails?"replacing-attachment":this.selectedAttachmentDetails?"viewing-attachment-details":this.selectedAttachmentAddInput?"adding-attachments":this.selectedAttachmentListInput?"viewing-attachments":this.activeAssociationsInput?.associatedLayer?"viewing-associated-features":this.activeAssociationsInput?"viewing-associated-layers":this.activeRelationshipInput?.showAllRelatedRecords?"viewing-related-records":this.activeRelationshipInput?.showAllCategories?"viewing-related-categories":"default"}get subtypes(){const e=this.activeLayer;return C(e)||T(e)||M(e)?k(e):[]}get status(){const e=this._prepareTask;return null==e?"not-loaded":e.finished?null!=e.error?"failed":"loaded":"loading"}get updating(){return this._updatingHandles.updating||this.calculating}get valid(){return this.sharedForm.valid&&Array.from(this._featureFormMap.values()).every(e=>e.valid)}get layers(){return Array.from(this._layersSet)}get mode(){return this.activeFeatureIndex>-1?"single":"batch"}submit(){if(this.submitHasBeenAttempted=!0,this.validateContingentValues(this._workingFeatures),!this._hasPendingAttachmentHydration)return this._emitSubmit(),Promise.resolve();if(this._submitTask)return this._submitTask.promise;const e=s(async()=>{await Promise.all(this._allAttachmentInputs.map(e=>e.waitForPendingAttachmentUpdateData())),this._emitSubmit()});return this._submitTask=e,e.promise.finally(()=>{this._submitTask===e&&(this._submitTask=null)}),e.promise}get selectedAttachment(){return this._get("selectedAttachment")??null}set selectedAttachment(e){this.showingSelectedAttachmentReplacePage=!1,this._set("selectedAttachment",e),null!=e&&(this.selectedAttachmentAddElementId=null)}get selectedAttachmentAddElementId(){return this._get("selectedAttachmentAddElementId")??null}set selectedAttachmentAddElementId(e){this.showingSelectedAttachmentReplacePage=!1,this._set("selectedAttachmentAddElementId",e),null!=e&&(this.selectedAttachment=null,this.selectedAttachmentListElementId=null)}get selectedAttachmentListElementId(){return this._get("selectedAttachmentListElementId")??null}set selectedAttachmentListElementId(e){this._set("selectedAttachmentListElementId",e),null!=e&&(this.selectedAttachment=null,this.selectedAttachmentAddElementId=null)}get selectedAttachmentListInput(){const e=this.selectedAttachmentListElementId,t=this.activeForm;return e&&t&&t.allAttachmentElementInputs.find(t=>t.template.elementId===e)||null}get showingSelectedAttachmentReplacePage(){return this._get("showingSelectedAttachmentReplacePage")??!1}set showingSelectedAttachmentReplacePage(e){this._set("showingSelectedAttachmentReplacePage",e&&null!=this.selectedAttachmentDetails)}get selectedAttachmentAddInput(){const e=this.selectedAttachmentAddElementId,t=this.activeForm;return e&&t&&t.allAttachmentElementInputs.find(t=>t.template.elementId===e)||null}get selectedAttachmentDetails(){const e=this.selectedAttachment,t=this.activeForm;if(!e||!t)return null;const s=t.allAttachmentElementInputs.find(t=>t.template.elementId===e.elementId);if(!s)return null;const a=s.attachments.findIndex(t=>V(t)===e.attachmentKey);if(-1===a)return null;return{attachment:s.attachments[a],input:s}}get _allAttachmentInputs(){const e=[...this.sharedForm.allAttachmentElementInputs];for(const t of this._featureFormMap.values())e.push(...t.allAttachmentElementInputs);return e}get _hasPendingAttachmentHydration(){return this._allAttachmentInputs.some(e=>e.hasPendingAttachmentUpdateData)}get _layersSet(){const e=new Set;for(const t of this._workingFeatures){const s=x(t.plainGraphic);s&&e.add(s)}return e}applyStashedAttachmentEdits(e){const t=this._allAttachmentInputs;for(const s of e){const e=t.find(e=>e.label===s.label&&e.attachmentKeyword===s.keywords);e&&e.applyStashedEdits(s)}}findFieldInput(e){if(null==e)return;const t=this._activeFormInputsByElementId;if(t.has(e))return t.get(e);const s=this.activeForm.allFieldInputs.find(t=>t.template.elementId===e);return void 0!==s?(t.set(e,s),s):void 0}getFirstVisibleInvalidFieldInput(){if(this.hasVisibleInputs&&!this.activeForm.valid)for(const e of this.visibleInputs){if(K(e)){const t=e.inputs.find(e=>z(e)&&!e.valid);if(t)return{input:t,groupInput:e}}if(z(e)&&!e.valid)return{input:e}}}getFieldInputValue(e){return this.findFieldInput(e)?.value}getValues(e){const t=this._reactiveGraphicLookup.get(e);if(!t)throw new i("feature-not-found","The given feature is not present in the BatchAttributeForm");return{...t.attributes}}async goBack(){switch(this.page){case"replacing-attachment":return void this.setShowingSelectedAttachmentReplacePage(!1);case"viewing-attachment-details":return void this.setSelectedAttachment(null);case"adding-attachments":return void this.setSelectedAttachmentAddElementId(null);case"viewing-attachments":return void this.setSelectedAttachmentListElementId(null);case"viewing-associated-features":return void this.setActiveAssociationsLayer(null);case"viewing-associated-layers":return void this.setActiveAssociationsInput(null);case"viewing-related-categories":case"viewing-related-records":return void this.clearActiveRelationshipCategoryOrInput();default:return}}async goHome(){this.setShowingSelectedAttachmentReplacePage(!1),this.setSelectedAttachment(null),this.setSelectedAttachmentAddElementId(null),this.setSelectedAttachmentListElementId(null),this.setActiveAssociationsLayer(null),this.setActiveAssociationsInput(null),this.clearAllRelationshipSettings()}notifyGeometriesChanged(e){const t=[];for(const s of e){const e=this._reactiveGraphicLookup.get(s);e&&(t.push(e),e.geometry=s.geometry)}this._updatingHandles.consumePromise(this._valueChangeTransaction(async e=>this._expressionsManager.runGeometryDependentExpressions(t,e),"user"))}async overrideOriginalFeature(e,t){await(this._prepareTask?.promise);const s=this._reactiveGraphicLookup.get(e);s&&(s.original=t,this._updatingHandles.consumePromise(this._valueChangeTransaction(e=>this._expressionsManager.runOriginalFeatureDependentExpressions(s,e),"expression")))}async setFieldInputValue(e,t){const{fieldName:s}=e;await this._updatingHandles.addPromise(this._valueChangeTransaction(async a=>{for(const i of e.features)a.setValue(i,s,t)},"user",e))}async setFieldInputValuePerFeature(e,t){await this._updatingHandles.addPromise(this._valueChangeTransaction(async s=>{for(const[a,i]of t)s.setValue(a,e.fieldName,i);s.hasChanges&&(e.userHasChangedValue=!0)},"user",e))}async setValueForFieldName(e,t,s){await this._updatingHandles.addPromise(this._valueChangeTransaction(async a=>{for(const i of s){const s=this._reactiveGraphicLookup.get(i);s&&a.setValue(s,e,t)}},"user",e))}async setValuePerFeatureForFieldName(e,t){await this._updatingHandles.addPromise(this._valueChangeTransaction(async s=>{for(const[a,i]of t){const t=this._reactiveGraphicLookup.get(a);t&&s.setValue(t,e,i)}},"user",e))}async setFieldValue(e,t){const s=this.activeForm.allFieldInputs.find(t=>t.fieldName===e);if(null==s)throw new i("no-field-input-found",`Cannot set the value of FieldInput with field name: ${e} because none was found in the active form`);await this.setFieldInputValue(s,t)}async setValue(e,t){const s=this.findFieldInput(e);if(null==s)throw new i("no-FieldInput-found",`Cannot set the value of FieldInput with ID: ${e} because none was found in the active form`);await this.setFieldInputValue(s,t)}async applySubtypeDefaults(e){const{defaultValues:t}=e,{allFieldInputs:s}=this.activeForm;await this._updatingHandles.addPromise(this._valueChangeTransaction(async e=>{for(const a of s){const{fieldName:s}=a,i=t[s];if(null!=i)for(const t of a.features)e.setValue(t,s,i)}},"user"))}async handleSubtypeChanged(e){const t=this._workingFeatures.at(e);if(t)return this._updatingHandles.addPromise(this._handleSubtypeChanged(t))}async stageAddAttachments(e,t){if(0===t.length)return[];const s=this._findAttachmentInput(e);if(!s)return[];const a=await this._updatingHandles.addPromise(s.stageAddAttachments(t,this._expressionsManager.arcadeContext));return 0===a.length||(this.userHasChangedValues=!0,this._emitAttachmentsChange(s)),a}stageDeleteAttachment(e,t){const s=this._findAttachmentInput(e);if(!s)return;const a=this._findAttachment(s,t);a&&(s.stageDeleteAttachment(a),this.userHasChangedValues=!0,this._emitAttachmentsChange(s))}async stageRenameAttachment(e,t,s){const a=this._findAttachmentInput(e);if(!a)return;const i=this._findAttachment(a,t);i&&(a.stageRenameAttachment(i,s.trim()),this.userHasChangedValues=!0,await a.ensureStagedUpdateData(i),this._emitAttachmentsChange(a))}async stageReplaceAttachment(e,t,s){const a=this._findAttachmentInput(e);if(!a)return!1;const i=this._findAttachment(a,t);if(!i)return!1;return!!await this._updatingHandles.addPromise(a.stageReplaceAttachment(i,s,this._expressionsManager.arcadeContext))&&(this.userHasChangedValues=!0,this._emitAttachmentsChange(a),!0)}clearAttachmentChanges(e){const t=this._findAttachmentInput(e);t&&(t.clearAttachmentChanges(),this._emitAttachmentsChange(t))}setActiveAssociation(e){this._activeAssociation=e}setActiveAssociationsInput(e){this._activeAssociationsInput=e}setActiveAssociationsLayer(e){this._activeAssociationsInput?.setAssociatedLayer(e)}setActiveAssociationType(e){this._activeAssociationsInput?.setActiveAssociationType(e)}setActiveRelationshipInput(e){e||this._activeRelationshipInput?.setActiveCategory(null),this._activeRelationshipInput=e}setActiveRelationshipCategory(e,t){t.setActiveCategory(e),this.setActiveRelationshipInput(t)}clearAllRelationshipSettings(){const e=this.activeRelationshipInput;e&&(e.setActiveCategory(null),e.setShowAllCategories(!1),e.setShowAllRelatedRecords(!1),this._activeRelationshipInput=null)}clearActiveRelationshipCategoryOrInput(){const e=this.activeRelationshipInput;e&&(e.showAllRelatedRecords?e.showAllCategories?e.setActiveCategory(null):this.setActiveRelationshipInput(null):e.showAllCategories&&(e.setShowAllCategories(!1),this.setActiveRelationshipInput(null)))}resetAttachmentChanges(e,t){const s=this._findAttachmentInput(e);if(!s||!s.editable)return;const a=this._findAttachment(s,t);a&&(s.discardStagedEdits(a),this._emitAttachmentsChange(s))}setSelectedAttachment(e){this.selectedAttachment=e??null}setShowingSelectedAttachmentReplacePage(e){this.showingSelectedAttachmentReplacePage=e}setSelectedAttachmentAddElementId(e){this.selectedAttachmentAddElementId=e??null}setSelectedAttachmentListElementId(e){this.selectedAttachmentListElementId=e??null}userChangesHaveMadeFeatureInvalid(e){return!!this._reactiveGraphicLookup.get(e)?.userChangesHaveMadeInvalid}validate(){return!1}validateContingentValues(e,t=!1){if(t&&!this.submitHasBeenAttempted)for(const s of e)this._reactiveContingentValuesManager.validateContingenciesForNonNullFields(s);else for(const s of e)this._reactiveContingentValuesManager.validateContingencyConstraints(s,{includeIncompleteViolations:!0})}_makeBatchFormInputsForFeature(e){const t=this._layerTemplateMap.get(e.layer);return t?Z(t,{allFeatures:new a([e]),expressionsManager:this._expressionsManager,getExternalErrorForFeature:this._getExternalErrorForFeature,getFieldValueOptionsForFeature:this._getFieldValueOptionsForFeature,map:this.map}):this._emptyForm}async _ensureLayerTemplate(e,t){const{_layersSet:s,contingentValuesManager:a}=this,i=e.layer;let n=!1;for(const r of this._layerTemplateMap.keys())s.has(r)||(this._layerTemplateMap.delete(r),this._expressionsManager.layerExpressionsModelMap.delete(r),a.resetOptionsForLayer(r),ee(r)&&a.resetViolationsForLayer(r),n=!0);this._layerTemplateMap.has(i)||(await this._prepareLayer(i,t),c(t),a.layers.add(i),n=!0),n&&(this._prepareSharedFormTemplate(),$(this.sharedForm,this.sharedFormTemplate,{allFeatures:this._workingFeatures,expressionsManager:this._expressionsManager,getFieldValueOptionsForFeature:this._getFieldValueOptionsForFeature,map:this.map}),this._recomputeHasAsyncArcadeExpressions(),await A(()=>!a.updating,t))}_recomputeHasAsyncArcadeExpressions(){this._hasAsyncArcadeExpressions=!1;for(const e of this._expressionsManager.layerExpressionsModelMap.values())for(const t of e.arcadeExecutorUses.keys())if(t.isAsync)return void(this._hasAsyncArcadeExpressions=!0)}_computeFormHeaderField(e){const{activeFeature:t,activeLayer:s}=this;return e&&s&&t?O({attributes:t?.attributes,label:e,layer:s,timeZone:this.effectiveTimeZone}):null}_makeSubmitResults(){const e=new Map;for(const[s,a]of this._reactiveGraphicLookup){const i=[],n=[],r=this._featureFormMap.get(a)?.allAttachmentElementInputs??[];for(const e of r)t(i,e.toSubmitEdits()),e.valid||n.push(e.template.elementId);e.set(s,{feature:s,values:{...a.attributes},invalidFields:[],attachmentEdits:i,invalidAttachmentElementIds:n})}for(const t of this.sharedForm.allFieldInputs)for(const s of t.invalidFeatures)e.get(s)?.invalidFields.push(t.fieldName);return Array.from(e.values())}async _handleSubtypeChanged(e){const t=e.layer;if(this.contingentValuesManager.resetOptionsForFeature(t,e.plainGraphic),ee(t)&&this.contingentValuesManager.resetViolationsForFeature(t,e.plainGraphic),!T(t))return;const a=t.parent?.findSublayerForFeature(e.plainGraphic);if(!a)return;this._layerTemplateUpdateTask=h(this._layerTemplateUpdateTask);const i=s(async t=>{c(t),e.source.sourceLayer=a,e.source.origin=a.graphicOrigin,await this._ensureLayerTemplate(e,t),c(t),this._featureFormMap.get(e)?.destroy(),this._featureFormMap.set(e,this._makeBatchFormInputsForFeature(e)),await p(this._valueChangeTransaction(t=>this._expressionsManager.runAllExpressions([e],t),"user"),t),c(t)});this._layerTemplateUpdateTask=i,await u(this._updatingHandles.addPromise(i.promise))}_emitSubmit(){this.emit("submit",{name:"submit",results:this._makeSubmitResults(),valid:this.valid})}_findAttachmentInput(e){const t=this.activeForm.allAttachmentElementInputs.find(t=>t.template.elementId===e);return t||r.getLogger(this).error(`Attachment input not found for elementId '${e}'`),t}_findAttachment(e,t){const s=e.findAttachment(t);return s||r.getLogger(this).error(`Attachment '${t}' not found for attachment element '${e.template.elementId}'`),s}_makeAttachmentEdits(e){const s=[];for(const a of e.allAttachmentElementInputs)t(s,a.toSubmitEdits());return s}_emitAttachmentsChange(e){const t=e.single.feature;if(!t)return;const s=this._featureFormMap.get(t);this.emit("attachments-change",{name:"attachments-change",feature:t.source,attachmentEdits:this._makeAttachmentEdits(s??this.activeForm),valid:this.valid})}async _valueChangeTransaction(e,t,s){const a=new G(this,t,"string"==typeof s?s:s?.fieldName);if(await e(a),"user"===t&&await this._expressionsManager.runExpressionsDependentOnChangedFields(a),await a.close(),a.hasChanges&&s){const e="string"==typeof s?this.activeForm.allFieldInputs.find(e=>e.fieldName===s):s;e&&(e.userHasChangedValue=!0)}}_prepare(){this.pendingSubtypeChoice?.reject(),this._hasAsyncArcadeExpressions=!1,this._prepareTask=h(this._prepareTask),this._layerTemplateUpdateTask=h(this._layerTemplateUpdateTask),this._layerTemplateMap.clear(),this._updateWorkingFeatures(),l(this._expressionsManager),this.userHasChangedValues=!1,this._expressionsManager=new D({arcadeContext:{editType:this.editType,spatialReference:this.spatialReference??E.WebMercator,map:this.map,timeZone:this.timeZone||"system"}});const{layers:e}=this;if(0===e.length)return;const t=s(async t=>{try{c(t),this._updateWorkingFeatures(),this.contingentValuesManager.layers.addMany(e),await Promise.all(e.map(e=>e.load()));for(const s of e)await this._prepareLayer(s,t);if(this.hasTooManyComplexFeatures)throw new i("too-many-features-with-complex-forms","There are too many features to load into the form with the configured complexity");if(this.hasTooManyFeatures)throw new i("too-many-features","There are too many features to load into the form.");this._prepareSharedFormTemplate(),this.sharedForm=Z(this.sharedFormTemplate,{allFeatures:this._workingFeatures,expressionsManager:this._expressionsManager,getExternalErrorForFeature:this._getExternalErrorForFeature,getFieldValueOptionsForFeature:this._getFieldValueOptionsForFeature,map:this.map}),await this._valueChangeTransaction(async e=>await this._expressionsManager.runAllExpressions(this._workingFeatures.toArray(),e),"expression"),await A(()=>!this.contingentValuesManager.updating)}catch(s){throw m(s)||r.getLogger(this).error("Failed preparing form",s),s}});this._updatingHandles.consumePromise(t.promise),this._prepareTask=t}async _prepareLayer(e,t){const s=se(this.layerInfos,e),a=await J(e,{arcadeExecutorProvider:this._arcadeExecutorProvider,formTimeZone:this.timeZone,attachmentsEnabled:this.attachmentsEnabled},s?.formTemplate);c(t),this._layerTemplateMap.set(e,a);const i=a.getExpressionExecutorsForLayer(e);if(this._expressionsManager.layerExpressionsModelMap.set(e,new N({preserveFieldValuesWhenHidden:a.preserveFieldValuesWhenHidden,executorMap:i})),!this._hasAsyncArcadeExpressions)for(const n of i.values())if(n&&(this._hasAsyncArcadeExpressions=!0===(n.editableExpression?.isAsync||n.requiredExpression?.isAsync||n.valueExpression?.isAsync||n.visibilityExpression?.isAsync),this._hasAsyncArcadeExpressions))break}_prepareSharedFormTemplate(){const e=new Map;for(const t of this._layerTemplateMap.values())for(const s of t.elements){if(Q(s))continue;const t=s.clone();X(t)&&(t.elements=t.elements.filter(e=>!Q(e)));const{elementId:a}=t;e.has(a)?e.get(a).foldIn(t):e.set(a,t)}this.sharedFormTemplate=new q({elements:Array.from(e.values())})}_updateWorkingFeatures(){this._workingFeatures.destroyAll(),this._reactiveContingentValuesManager.reset();for(const t of this._featureFormMap.values())t.destroy();this._featureFormMap.clear(),this._attachmentCache.clear();const{features:e}=this;if(this._reactiveGraphicLookup=new d,0!==e.length){this._workingFeatures.addMany(e.map(R));for(const e of this._workingFeatures)this._reactiveGraphicLookup.set(e.source,e)}}async _syncAttachments(){const{activeFeature:e,activeLayer:t,activeForm:a}=this;if(!(e&&a&&H(t)&&P(t)))return;const i=e.getObjectId();if(null==i)return;const n=this._attachmentCache.get(t),r=a.allAttachmentElementInputs;if(!r.length)return;const l=s(async e=>{let s;if(n){const e=n.get(i);e&&(s=e)}if(!s){s=await j(t,i,r,e);o(this._attachmentCache,t,()=>new d).set(i,s)}for(const t of r)t.applyFetchedAttachments(oe(t,s))});this._syncAttachmentsTask=l,await u(l.promise)}get test(){return{expressionsManager:this._expressionsManager,reactiveGraphicLookup:this._reactiveGraphicLookup,syncAttachmentsTask:this._syncAttachmentsTask}}};e([F()],ae.prototype,"_attachmentCache",void 0),e([F({readOnly:!0})],ae.prototype,"activeFeature",null),e([F()],ae.prototype,"activeFeatureIndex",void 0),e([F({readOnly:!0})],ae.prototype,"activeForm",null),e([F({readOnly:!0})],ae.prototype,"activeLayer",null),e([F()],ae.prototype,"activeAssociation",null),e([F()],ae.prototype,"activeAssociationsInput",null),e([F()],ae.prototype,"activeAssociationType",null),e([F()],ae.prototype,"activeRelationshipInput",null),e([F()],ae.prototype,"attachmentsEnabled",void 0),e([F()],ae.prototype,"callbacks",void 0),e([F()],ae.prototype,"disabled",void 0),e([F()],ae.prototype,"calculating",null),e([F()],ae.prototype,"canGoBack",null),e([F()],ae.prototype,"contingentValuesManager",void 0),e([F()],ae.prototype,"editType",void 0),e([F()],ae.prototype,"features",void 0),e([F()],ae.prototype,"expressionEvaluationFailed",null),e([F()],ae.prototype,"hasNonActiveInvalidFeatures",null),e([F()],ae.prototype,"hasAsyncArcadeExpressions",null),e([F()],ae.prototype,"_hasAsyncArcadeExpressions",void 0),e([F()],ae.prototype,"invalidFeatures",null),e([F()],ae.prototype,"hasVisibleInputs",null),e([F()],ae.prototype,"hasLayersWithContingentValues",null),e([F()],ae.prototype,"formDescription",null),e([F()],ae.prototype,"formTitle",null),e([F()],ae.prototype,"effectiveTimeZone",null),e([F()],ae.prototype,"highlightHelper",void 0),e([F()],ae.prototype,"maximumFeatureCount",void 0),e([F()],ae.prototype,"maximumFeatureCountWithComplexForms",void 0),e([F()],ae.prototype,"visibleInputs",null),e([F()],ae.prototype,"map",void 0),e([F()],ae.prototype,"noVisibleElementsReason",null),e([F()],ae.prototype,"page",null),e([F()],ae.prototype,"pageStack",void 0),e([F()],ae.prototype,"readOnly",void 0),e([F()],ae.prototype,"pendingSubtypeChoice",void 0),e([F()],ae.prototype,"subtypes",null),e([F()],ae.prototype,"spatialReference",void 0),e([F()],ae.prototype,"submitHasBeenAttempted",void 0),e([F()],ae.prototype,"timeZone",void 0),e([F()],ae.prototype,"updating",null),e([F()],ae.prototype,"valid",null),e([F()],ae.prototype,"layers",null),e([F()],ae.prototype,"mode",null),e([F()],ae.prototype,"sharedForm",void 0),e([F()],ae.prototype,"sharedFormTemplate",void 0),e([F()],ae.prototype,"selectedAttachment",null),e([F()],ae.prototype,"selectedAttachmentAddElementId",null),e([F()],ae.prototype,"selectedAttachmentListElementId",null),e([F()],ae.prototype,"selectedAttachmentListInput",null),e([F()],ae.prototype,"showingSelectedAttachmentReplacePage",null),e([F()],ae.prototype,"selectedAttachmentAddInput",null),e([F()],ae.prototype,"selectedAttachmentDetails",null),e([F()],ae.prototype,"userHasChangedValues",void 0),e([F()],ae.prototype,"layerInfos",void 0),e([F()],ae.prototype,"_arcadeExecutorProvider",void 0),e([F()],ae.prototype,"_activeAssociation",void 0),e([F()],ae.prototype,"_activeAssociationsInput",void 0),e([F()],ae.prototype,"_activeRelationshipInput",void 0),e([F()],ae.prototype,"_prepareTask",void 0),e([F()],ae.prototype,"_reactiveGraphicLookup",void 0),e([F()],ae.prototype,"_allAttachmentInputs",null),e([F()],ae.prototype,"_hasPendingAttachmentHydration",null),e([F()],ae.prototype,"_layerTemplateMap",void 0),e([F()],ae.prototype,"_layersSet",null),e([F()],ae.prototype,"_workingFeatures",void 0),e([F()],ae.prototype,"_expressionsManager",void 0),ae=e([I("esri.widgets.BatchAttributeForm.BatchAttributeFormViewModel")],ae);const ie=ae;function ne(e){return null!=e&&e.trim().length>0}function re(e,t){const s=e.keywords;return ne(s)&&s.toLowerCase()===t}function oe(e,t){const s="attachment"===e.input?.type?e.input.attachmentAssociationType:"exact",a=e.attachmentKeyword;if("any"===s)return t;if("exactOrNone"===s){if(te(a))return t.filter(e=>!ne(e.keywords));const e=a.toLowerCase();return t.filter(t=>!ne(t.keywords)||re(t,e))}if(te(a))return t;const i=a.toLowerCase();return t.filter(e=>re(e,i))}export{ie as default};
2
+ import{__decorate as e}from"tslib";import{pushIfSome as t}from"../../core/arrayUtils.js";import{createTask as s}from"../../core/asyncUtils.js";import a from"../../core/Collection.js";import i from"../../core/Error.js";import{EventedAccessor as n}from"../../core/Evented.js";import r from"../../core/Logger.js";import{getOrCreateMapValue as o}from"../../core/MapUtils.js";import{destroyMaybe as l,abortMaybe as h}from"../../core/maybe.js";import{throwIfAborted as c,whenOrAbort as p,ignoreAbortErrors as u,isAbortError as m}from"../../core/promiseUtils.js";import d from"../../core/ReactiveMap.js";import{on as g,sync as y,watch as f,syncAndInitial as v,initial as _,whenOnce as A}from"../../core/reactiveUtils.js";import{property as F,subclass as I}from"../../core/accessorSupport/decorators.js";import{UpdatingHandles as w}from"../../core/support/UpdatingHandles.js";import E from"../../geometry/SpatialReference.js";import{getGraphicLayer as x}from"../../graphic/graphicOriginUtils.js";import{isSubtypeGroupLayer as C,isSubtypeSublayer as T,isFeatureLayer as M,getSubtypesFromLayer as k}from"../../layers/support/layerUtils.js";import{system as b}from"../../time/constants.js";import{getAttachmentKey as V}from"./attachmentUtils.js";import{getLayerTimeZone as S,getEffectiveTimeZone as L,createReactiveGraphic as R,isAttributeFormSupportedLayerWithAttachments as H,layerSupportsAttachments as P,queryAttachmentsForElements as j}from"./batchAttributeFormUtils.js";import{ReactiveContingentValuesManager as U}from"./ReactiveContingentValuesManager.js";import{parseFormTemplateString as O}from"./stringUtils.js";import{ValueChangeTransaction as G}from"./ValueChangeTransaction.js";import{ArcadeExecutorProvider as B}from"./expressions/ArcadeExecutorProvider.js";import{ExpressionsManager as D}from"./expressions/ExpressionsManager.js";import{ExpressionsModel as N}from"./expressions/ExpressionsModel.js";import W from"./inputs/BatchFormInputs.js";import{createBatchFormInputsFromBatchFormTemplate as Z,mergeBatchFormInputsFromNewTemplate as $}from"./inputs/support/createBatchFormInputs.js";import{isGroupInput as K,isFieldInput as z}from"./inputs/support/inputUtils.js";import q from"./templates/BatchFormTemplate.js";import{createBatchFormTemplate as J}from"./templates/support/createBatchFormTemplate.js";import{isExcludedFromSharedForm as Q,isGroupElementTemplate as X}from"./templates/support/templateUtils.js";import{ContingentValuesManager as Y,isLayerWithContingentValues as ee}from"../support/ContingentValuesManager.js";import{isEmptyValue as te}from"../support/forms/formUtils.js";function se(e,t){return e?.find(e=>e.layer===t)}let ae=class extends n{constructor(e){super(e),this._attachmentCache=new d,this.activeFeatureIndex=-1,this.attachmentsEnabled=!1,this.callbacks=null,this.disabled=!1,this.editType="NA",this.features=new a,this._hasAsyncArcadeExpressions=!1,this.highlightHelper=null,this.maximumFeatureCount=2e3,this.maximumFeatureCountWithComplexForms=50,this.map=null,this.pageStack=[],this.readOnly=!1,this.pendingSubtypeChoice=null,this.spatialReference=null,this.submitHasBeenAttempted=!1,this.timeZone=null,this.userHasChangedValues=!1,this.layerInfos=null,this._arcadeExecutorProvider=new B,this._activeAssociation=null,this._activeAssociationsInput=null,this._activeRelationshipInput=null,this._ownContingentValuesManager=null,this._activeFormInputsByElementId=new Map,this._emptyForm=new W({inputs:[]}),this._emptyFormTemplate=new q({elements:[]}),this._featureFormMap=new d,this._prepareTask=null,this._layerTemplateUpdateTask=null,this._syncAttachmentsTask=null,this._reactiveGraphicLookup=new d,this._updatingHandles=new w,this._submitTask=null,this._layerTemplateMap=new d,this._workingFeatures=new a,this._expressionsManager=new D({arcadeContext:{editType:"NA",spatialReference:null,map:null,timeZone:b}}),this._getExternalErrorForFeature=(e,t)=>this._reactiveContingentValuesManager.getViolationTypeForField(e,t),this._getFieldValueOptionsForFeature=e=>this._reactiveContingentValuesManager.getAndWatchFieldValueOptions(e),this.sharedForm=this._emptyForm,this.sharedFormTemplate=this._emptyFormTemplate}initialize(){this.contingentValuesManager||(this.contingentValuesManager=this._ownContingentValuesManager=new Y),this.addHandles([g(()=>this.features,"after-changes",()=>{this.goHome(),this.notifyChange("layers"),this._prepare()},y),f(()=>[this.attachmentsEnabled,this.features,this.map,this.timeZone,this.editType],()=>this._prepare(),y),f(()=>this.activeForm,()=>{this.goHome(),this._activeFormInputsByElementId.clear(),this._syncAttachments()},y),f(()=>this.activeFeature,()=>{this.goHome()},y),f(()=>this.page,e=>{const t=[...this.pageStack];if(t.includes(e))for(;t.length&&t.at(-1)!==e;)t.pop();else t.push(e);this.pageStack=t},v),f(()=>this.contingentValuesManager,e=>{l(this._reactiveContingentValuesManager),this._reactiveContingentValuesManager=new U({manager:e})},_)]),this._prepare()}destroy(){this._prepareTask=h(this._prepareTask),this.pendingSubtypeChoice?.reject(),this._layerTemplateUpdateTask=h(this._layerTemplateUpdateTask),this._syncAttachmentsTask=h(this._syncAttachmentsTask),this._workingFeatures.destroyAll(),l(this._expressionsManager),l(this._reactiveContingentValuesManager),this._updatingHandles.destroy(),this._reactiveGraphicLookup=new d,this._emptyForm.destroy(),this._emptyFormTemplate.destroy(),this._ownContingentValuesManager=l(this._ownContingentValuesManager),this.highlightHelper?.removeAll()}get activeFeature(){const e=this.activeFeatureIndex;return e<0?null:this.features.at(e)}get activeForm(){if("batch"===this.mode)return this.sharedForm;const e=this._workingFeatures.at(this.activeFeatureIndex);if(!e)return this._emptyForm;const t=this._featureFormMap.get(e);if(t)return t;const s=this._makeBatchFormInputsForFeature(e);return s!==this._emptyForm&&this._featureFormMap.set(e,s),s}get activeLayer(){const{activeFeature:e}=this;if(!e)return null;return x(e)??null}get activeAssociation(){return this._activeAssociation}get activeAssociationsInput(){return this._activeAssociationsInput}get activeAssociationType(){return this.activeAssociationsInput?.activeAssociationType}get activeRelationshipInput(){return this._activeRelationshipInput}get calculating(){return this._expressionsManager.calculating}get expressionsManager(){return this._expressionsManager}get canGoBack(){return this.pageStack.length>1}get expressionEvaluationFailed(){return this._expressionsManager.expressionEvaluationFailed}get hasNonActiveInvalidFeatures(){if("batch"===this.mode)return!1;const{activeFeature:e}=this;return this.invalidFeatures.some(t=>t!==e)}get hasAsyncArcadeExpressions(){return this._hasAsyncArcadeExpressions}get hasTooManyFeatures(){return this._workingFeatures.length>this.maximumFeatureCount}get hasTooManyComplexFeatures(){return this._workingFeatures.length>this.maximumFeatureCountWithComplexForms&&this.hasAsyncArcadeExpressions}get invalidFeatures(){return this.sharedForm.invalidFeatures}get hasVisibleInputs(){return this.visibleInputs.length>0}get hasLayersWithContingentValues(){const e=this.contingentValuesManager;for(const t of this.layers)if(e.getFieldsWithContingentValues(t).size>0)return!0;return!1}get formDescription(){return this._computeFormHeaderField(this.activeForm?.description)}get formTitle(){return this._computeFormHeaderField(this.activeForm?.title)}get effectiveTimeZone(){const{activeLayer:e,timeZone:t}=this;if(!e)return t??"system";const s=S(e);return L(t,s)}get visibleInputs(){return this.activeForm.inputs.filter(e=>e.visible)}get noVisibleElementsReason(){if(this.hasVisibleInputs)return null;if(0===this.activeForm.inputs.length)return"noElements";const e=new Set;for(const t of this.activeForm.inputs)switch(t.visibilityCode){case"hidden:not-in-all-layers":case"hidden:no-domain-in-common":e.add("noElementsInCommon");break;case"hidden:field-definition":case"hidden:group-visibility-expression:all-features":case"hidden:visibility-expression:all-features":e.add("allElementsHidden");break;case"hidden:group-visibility-expression:some-features":case"hidden:visibility-expression:some-features":return"elementsHiddenInSome"}return e.has("allElementsHidden")?"allElementsHidden":"noElementsInCommon"}get page(){return this.showingSelectedAttachmentReplacePage&&this.selectedAttachmentDetails?"replacing-attachment":this.selectedAttachmentDetails?"viewing-attachment-details":this.selectedAttachmentAddInput?"adding-attachments":this.selectedAttachmentListInput?"viewing-attachments":this.activeAssociationsInput?.associatedLayer?"viewing-associated-features":this.activeAssociationsInput?"viewing-associated-layers":this.activeRelationshipInput?.showAllRelatedRecords?"viewing-related-records":this.activeRelationshipInput?.showAllCategories?"viewing-related-categories":"default"}get subtypes(){const e=this.activeLayer;return C(e)||T(e)||M(e)?k(e):[]}get status(){const e=this._prepareTask;return null==e?"not-loaded":e.finished?null!=e.error?"failed":"loaded":"loading"}get updating(){return this._updatingHandles.updating||this.calculating}get valid(){return this.sharedForm.valid&&Array.from(this._featureFormMap.values()).every(e=>e.valid)}get layers(){return Array.from(this._layersSet)}get mode(){return this.activeFeatureIndex>-1?"single":"batch"}submit(){if(this.submitHasBeenAttempted=!0,this.validateContingentValues(this._workingFeatures),!this._hasPendingAttachmentHydration)return this._emitSubmit(),Promise.resolve();if(this._submitTask)return this._submitTask.promise;const e=s(async()=>{await Promise.all(this._allAttachmentInputs.map(e=>e.waitForPendingAttachmentUpdateData())),this._emitSubmit()});return this._submitTask=e,e.promise.finally(()=>{this._submitTask===e&&(this._submitTask=null)}),e.promise}get selectedAttachment(){return this._get("selectedAttachment")??null}set selectedAttachment(e){this.showingSelectedAttachmentReplacePage=!1,this._set("selectedAttachment",e),null!=e&&(this.selectedAttachmentAddElementId=null)}get selectedAttachmentAddElementId(){return this._get("selectedAttachmentAddElementId")??null}set selectedAttachmentAddElementId(e){this.showingSelectedAttachmentReplacePage=!1,this._set("selectedAttachmentAddElementId",e),null!=e&&(this.selectedAttachment=null,this.selectedAttachmentListElementId=null)}get selectedAttachmentListElementId(){return this._get("selectedAttachmentListElementId")??null}set selectedAttachmentListElementId(e){this._set("selectedAttachmentListElementId",e),null!=e&&(this.selectedAttachment=null,this.selectedAttachmentAddElementId=null)}get selectedAttachmentListInput(){const e=this.selectedAttachmentListElementId,t=this.activeForm;if(!e||!t)return null;const s=t.allAttachmentElementInputs.find(t=>t.template.elementId===e)||null;return s?.attachments.length?s:null}get showingSelectedAttachmentReplacePage(){return this._get("showingSelectedAttachmentReplacePage")??!1}set showingSelectedAttachmentReplacePage(e){this._set("showingSelectedAttachmentReplacePage",e&&null!=this.selectedAttachmentDetails)}get selectedAttachmentAddInput(){const e=this.selectedAttachmentAddElementId,t=this.activeForm;return e&&t&&t.allAttachmentElementInputs.find(t=>t.template.elementId===e)||null}get selectedAttachmentDetails(){const e=this.selectedAttachment,t=this.activeForm;if(!e||!t)return null;const s=t.allAttachmentElementInputs.find(t=>t.template.elementId===e.elementId);if(!s)return null;const a=s.attachments.findIndex(t=>V(t)===e.attachmentKey);if(-1===a)return null;return{attachment:s.attachments[a],input:s}}get _allAttachmentInputs(){const e=[...this.sharedForm.allAttachmentElementInputs];for(const t of this._featureFormMap.values())e.push(...t.allAttachmentElementInputs);return e}get _hasPendingAttachmentHydration(){return this._allAttachmentInputs.some(e=>e.hasPendingAttachmentUpdateData)}get _layersSet(){const e=new Set;for(const t of this._workingFeatures){const s=x(t.plainGraphic);s&&e.add(s)}return e}applyStashedAttachmentEdits(e){const t=this._allAttachmentInputs;for(const s of e){const e=t.find(e=>e.label===s.label&&e.attachmentKeyword===s.keywords);e&&e.applyStashedEdits(s)}}findFieldInput(e){if(null==e)return;const t=this._activeFormInputsByElementId;if(t.has(e))return t.get(e);const s=this.activeForm.allFieldInputs.find(t=>t.template.elementId===e);return void 0!==s?(t.set(e,s),s):void 0}getFirstVisibleInvalidFieldInput(){if(this.hasVisibleInputs&&!this.activeForm.valid)for(const e of this.visibleInputs){if(K(e)){const t=e.inputs.find(e=>z(e)&&!e.valid);if(t)return{input:t,groupInput:e}}if(z(e)&&!e.valid)return{input:e}}}getFieldInputValue(e){return this.findFieldInput(e)?.value}getValues(e){const t=this._reactiveGraphicLookup.get(e);if(!t)throw new i("feature-not-found","The given feature is not present in the BatchAttributeForm");return{...t.attributes}}async goBack(){switch(this.page){case"replacing-attachment":return void this.setShowingSelectedAttachmentReplacePage(!1);case"viewing-attachment-details":return void this.setSelectedAttachment(null);case"adding-attachments":return void this.setSelectedAttachmentAddElementId(null);case"viewing-attachments":return void this.setSelectedAttachmentListElementId(null);case"viewing-associated-features":return void this.setActiveAssociationsLayer(null);case"viewing-associated-layers":return void this.setActiveAssociationsInput(null);case"viewing-related-categories":case"viewing-related-records":return void this.clearActiveRelationshipCategoryOrInput();default:return}}async goHome(){this.setShowingSelectedAttachmentReplacePage(!1),this.setSelectedAttachment(null),this.setSelectedAttachmentAddElementId(null),this.setSelectedAttachmentListElementId(null),this.setActiveAssociationsLayer(null),this.setActiveAssociationsInput(null),this.clearAllRelationshipSettings()}notifyGeometriesChanged(e){const t=[];for(const s of e){const e=this._reactiveGraphicLookup.get(s);e&&(t.push(e),e.geometry=s.geometry)}this._updatingHandles.consumePromise(this._valueChangeTransaction(async e=>this._expressionsManager.runGeometryDependentExpressions(t,e),"user"))}async overrideOriginalFeature(e,t){await(this._prepareTask?.promise);const s=this._reactiveGraphicLookup.get(e);s&&(s.original=t,this._updatingHandles.consumePromise(this._valueChangeTransaction(e=>this._expressionsManager.runOriginalFeatureDependentExpressions(s,e),"expression")))}async setFieldInputValue(e,t){const{fieldName:s}=e;await this._updatingHandles.addPromise(this._valueChangeTransaction(async a=>{for(const i of e.features)a.setValue(i,s,t)},"user",e))}async setFieldInputValuePerFeature(e,t){await this._updatingHandles.addPromise(this._valueChangeTransaction(async s=>{for(const[a,i]of t)s.setValue(a,e.fieldName,i);s.hasChanges&&(e.userHasChangedValue=!0)},"user",e))}async setValueForFieldName(e,t,s){await this._updatingHandles.addPromise(this._valueChangeTransaction(async a=>{for(const i of s){const s=this._reactiveGraphicLookup.get(i);s&&a.setValue(s,e,t)}},"user",e))}async setValuePerFeatureForFieldName(e,t){await this._updatingHandles.addPromise(this._valueChangeTransaction(async s=>{for(const[a,i]of t){const t=this._reactiveGraphicLookup.get(a);t&&s.setValue(t,e,i)}},"user",e))}async setFieldValue(e,t){const s=this.activeForm.allFieldInputs.find(t=>t.fieldName===e);if(null==s)throw new i("no-field-input-found",`Cannot set the value of FieldInput with field name: ${e} because none was found in the active form`);await this.setFieldInputValue(s,t)}async setValue(e,t){const s=this.findFieldInput(e);if(null==s)throw new i("no-FieldInput-found",`Cannot set the value of FieldInput with ID: ${e} because none was found in the active form`);await this.setFieldInputValue(s,t)}async applySubtypeDefaults(e){const{defaultValues:t}=e,{allFieldInputs:s}=this.activeForm;await this._updatingHandles.addPromise(this._valueChangeTransaction(async e=>{for(const a of s){const{fieldName:s}=a,i=t[s];if(null!=i)for(const t of a.features)e.setValue(t,s,i)}},"user"))}async handleSubtypeChanged(e){const t=this._workingFeatures.at(e);if(t)return this._updatingHandles.addPromise(this._handleSubtypeChanged(t))}async stageAddAttachments(e,t){if(0===t.length)return[];const s=this._findAttachmentInput(e);if(!s)return[];const a=await this._updatingHandles.addPromise(s.stageAddAttachments(t,this._expressionsManager.arcadeContext));return 0===a.length||(this.userHasChangedValues=!0,this._emitAttachmentsChange(s)),a}stageDeleteAttachment(e,t){const s=this._findAttachmentInput(e);if(!s)return;const a=this._findAttachment(s,t);a&&(s.stageDeleteAttachment(a),this.userHasChangedValues=!0,this._emitAttachmentsChange(s))}async stageRenameAttachment(e,t,s){const a=this._findAttachmentInput(e);if(!a)return;const i=this._findAttachment(a,t);i&&(a.stageRenameAttachment(i,s.trim()),this.userHasChangedValues=!0,await a.ensureStagedUpdateData(i),this._emitAttachmentsChange(a))}async stageReplaceAttachment(e,t,s){const a=this._findAttachmentInput(e);if(!a)return!1;const i=this._findAttachment(a,t);if(!i)return!1;return!!await this._updatingHandles.addPromise(a.stageReplaceAttachment(i,s,this._expressionsManager.arcadeContext))&&(this.userHasChangedValues=!0,this._emitAttachmentsChange(a),!0)}clearAttachmentChanges(e){const t=this._findAttachmentInput(e);t&&(t.clearAttachmentChanges(),this._emitAttachmentsChange(t))}setActiveAssociation(e){this._activeAssociation=e}setActiveAssociationsInput(e){this._activeAssociationsInput=e}setActiveAssociationsLayer(e){this._activeAssociationsInput?.setAssociatedLayer(e)}setActiveAssociationType(e){this._activeAssociationsInput?.setActiveAssociationType(e)}setActiveRelationshipInput(e){e||this._activeRelationshipInput?.setActiveCategory(null),this._activeRelationshipInput=e}setActiveRelationshipCategory(e,t){t.setActiveCategory(e),this.setActiveRelationshipInput(t)}clearAllRelationshipSettings(){const e=this.activeRelationshipInput;e&&(e.setActiveCategory(null),e.setShowAllCategories(!1),e.setShowAllRelatedRecords(!1),this._activeRelationshipInput=null)}clearActiveRelationshipCategoryOrInput(){const e=this.activeRelationshipInput;e&&(e.showAllRelatedRecords?e.showAllCategories?e.setActiveCategory(null):this.setActiveRelationshipInput(null):e.showAllCategories&&(e.setShowAllCategories(!1),this.setActiveRelationshipInput(null)))}resetAttachmentChanges(e,t){const s=this._findAttachmentInput(e);if(!s||!s.editable)return;const a=this._findAttachment(s,t);a&&(s.discardStagedEdits(a),this._emitAttachmentsChange(s))}setSelectedAttachment(e){this.selectedAttachment=e??null}setShowingSelectedAttachmentReplacePage(e){this.showingSelectedAttachmentReplacePage=e}setSelectedAttachmentAddElementId(e){this.selectedAttachmentAddElementId=e??null}setSelectedAttachmentListElementId(e){this.selectedAttachmentListElementId=e??null}userChangesHaveMadeFeatureInvalid(e){return!!this._reactiveGraphicLookup.get(e)?.userChangesHaveMadeInvalid}validate(){return!1}validateContingentValues(e,t=!1){if(t&&!this.submitHasBeenAttempted)for(const s of e)this._reactiveContingentValuesManager.validateContingenciesForNonNullFields(s);else for(const s of e)this._reactiveContingentValuesManager.validateContingencyConstraints(s,{includeIncompleteViolations:!0})}_makeBatchFormInputsForFeature(e){const t=this._layerTemplateMap.get(e.layer);return t?Z(t,{allFeatures:new a([e]),expressionsManager:this._expressionsManager,getExternalErrorForFeature:this._getExternalErrorForFeature,getFieldValueOptionsForFeature:this._getFieldValueOptionsForFeature,map:this.map}):this._emptyForm}async _ensureLayerTemplate(e,t){const{_layersSet:s,contingentValuesManager:a}=this,i=e.layer;let n=!1;for(const r of this._layerTemplateMap.keys())s.has(r)||(this._layerTemplateMap.delete(r),this._expressionsManager.layerExpressionsModelMap.delete(r),a.resetOptionsForLayer(r),ee(r)&&a.resetViolationsForLayer(r),n=!0);this._layerTemplateMap.has(i)||(await this._prepareLayer(i,t),c(t),a.layers.add(i),n=!0),n&&(this._prepareSharedFormTemplate(),$(this.sharedForm,this.sharedFormTemplate,{allFeatures:this._workingFeatures,expressionsManager:this._expressionsManager,getFieldValueOptionsForFeature:this._getFieldValueOptionsForFeature,map:this.map}),this._recomputeHasAsyncArcadeExpressions(),await A(()=>!a.updating,t))}_recomputeHasAsyncArcadeExpressions(){this._hasAsyncArcadeExpressions=!1;for(const e of this._expressionsManager.layerExpressionsModelMap.values())for(const t of e.arcadeExecutorUses.keys())if(t.isAsync)return void(this._hasAsyncArcadeExpressions=!0)}_computeFormHeaderField(e){const{activeFeature:t,activeLayer:s}=this;return e&&s&&t?O({attributes:t?.attributes,label:e,layer:s,timeZone:this.effectiveTimeZone}):null}_makeSubmitResults(){const e=new Map;for(const[s,a]of this._reactiveGraphicLookup){const i=[],n=[],r=this._featureFormMap.get(a)?.allAttachmentElementInputs??[];for(const e of r)t(i,e.toSubmitEdits()),e.valid||n.push(e.template.elementId);e.set(s,{feature:s,values:{...a.attributes},invalidFields:[],attachmentEdits:i,invalidAttachmentElementIds:n})}for(const t of this.sharedForm.allFieldInputs)for(const s of t.invalidFeatures)e.get(s)?.invalidFields.push(t.fieldName);return Array.from(e.values())}async _handleSubtypeChanged(e){const t=e.layer;if(this.contingentValuesManager.resetOptionsForFeature(t,e.plainGraphic),ee(t)&&this.contingentValuesManager.resetViolationsForFeature(t,e.plainGraphic),!T(t))return;const a=t.parent?.findSublayerForFeature(e.plainGraphic);if(!a)return;this._layerTemplateUpdateTask=h(this._layerTemplateUpdateTask);const i=s(async t=>{c(t),e.source.sourceLayer=a,e.source.origin=a.graphicOrigin,await this._ensureLayerTemplate(e,t),c(t),this._featureFormMap.get(e)?.destroy(),this._featureFormMap.set(e,this._makeBatchFormInputsForFeature(e)),await p(this._valueChangeTransaction(t=>this._expressionsManager.runAllExpressions([e],t),"user"),t),c(t)});this._layerTemplateUpdateTask=i,await u(this._updatingHandles.addPromise(i.promise))}_emitSubmit(){this.emit("submit",{name:"submit",results:this._makeSubmitResults(),valid:this.valid})}_findAttachmentInput(e){const t=this.activeForm.allAttachmentElementInputs.find(t=>t.template.elementId===e);return t||r.getLogger(this).error(`Attachment input not found for elementId '${e}'`),t}_findAttachment(e,t){const s=e.findAttachment(t);return s||r.getLogger(this).error(`Attachment '${t}' not found for attachment element '${e.template.elementId}'`),s}_makeAttachmentEdits(e){const s=[];for(const a of e.allAttachmentElementInputs)t(s,a.toSubmitEdits());return s}_emitAttachmentsChange(e){const t=e.single.feature;if(!t)return;const s=this._featureFormMap.get(t);this.emit("attachments-change",{name:"attachments-change",feature:t.source,attachmentEdits:this._makeAttachmentEdits(s??this.activeForm),valid:this.valid})}async _valueChangeTransaction(e,t,s){const a=new G(this,t,"string"==typeof s?s:s?.fieldName);if(await e(a),"user"===t&&await this._expressionsManager.runExpressionsDependentOnChangedFields(a),await a.close(),a.hasChanges&&s){const e="string"==typeof s?this.activeForm.allFieldInputs.find(e=>e.fieldName===s):s;e&&(e.userHasChangedValue=!0)}}_prepare(){this.pendingSubtypeChoice?.reject(),this._hasAsyncArcadeExpressions=!1,this._prepareTask=h(this._prepareTask),this._layerTemplateUpdateTask=h(this._layerTemplateUpdateTask),this._layerTemplateMap.clear(),this._updateWorkingFeatures(),l(this._expressionsManager),this.userHasChangedValues=!1,this._expressionsManager=new D({arcadeContext:{editType:this.editType,spatialReference:this.spatialReference??E.WebMercator,map:this.map,timeZone:this.timeZone||"system"}});const{layers:e}=this;if(0===e.length)return;const t=s(async t=>{try{c(t),this._updateWorkingFeatures(),this.contingentValuesManager.layers.addMany(e),await Promise.all(e.map(e=>e.load()));for(const s of e)await this._prepareLayer(s,t);if(this.hasTooManyComplexFeatures)throw new i("too-many-features-with-complex-forms","There are too many features to load into the form with the configured complexity");if(this.hasTooManyFeatures)throw new i("too-many-features","There are too many features to load into the form.");this._prepareSharedFormTemplate(),this.sharedForm=Z(this.sharedFormTemplate,{allFeatures:this._workingFeatures,expressionsManager:this._expressionsManager,getExternalErrorForFeature:this._getExternalErrorForFeature,getFieldValueOptionsForFeature:this._getFieldValueOptionsForFeature,map:this.map}),await this._valueChangeTransaction(async e=>await this._expressionsManager.runAllExpressions(this._workingFeatures.toArray(),e),"expression"),await A(()=>!this.contingentValuesManager.updating)}catch(s){throw m(s)||r.getLogger(this).error("Failed preparing form",s),s}});this._updatingHandles.consumePromise(t.promise),this._prepareTask=t}async _prepareLayer(e,t){const s=se(this.layerInfos,e),a=await J(e,{arcadeExecutorProvider:this._arcadeExecutorProvider,formTimeZone:this.timeZone,attachmentsEnabled:this.attachmentsEnabled},s?.formTemplate);c(t),this._layerTemplateMap.set(e,a);const i=a.getExpressionExecutorsForLayer(e);if(this._expressionsManager.layerExpressionsModelMap.set(e,new N({preserveFieldValuesWhenHidden:a.preserveFieldValuesWhenHidden,executorMap:i})),!this._hasAsyncArcadeExpressions)for(const n of i.values())if(n&&(this._hasAsyncArcadeExpressions=!0===(n.editableExpression?.isAsync||n.requiredExpression?.isAsync||n.valueExpression?.isAsync||n.visibilityExpression?.isAsync),this._hasAsyncArcadeExpressions))break}_prepareSharedFormTemplate(){const e=new Map;for(const t of this._layerTemplateMap.values())for(const s of t.elements){if(Q(s))continue;const t=s.clone();X(t)&&(t.elements=t.elements.filter(e=>!Q(e)));const{elementId:a}=t;e.has(a)?e.get(a).foldIn(t):e.set(a,t)}this.sharedFormTemplate=new q({elements:Array.from(e.values())})}_updateWorkingFeatures(){this._workingFeatures.destroyAll(),this._reactiveContingentValuesManager.reset();for(const t of this._featureFormMap.values())t.destroy();this._featureFormMap.clear(),this._attachmentCache.clear();const{features:e}=this;if(this._reactiveGraphicLookup=new d,0!==e.length){this._workingFeatures.addMany(e.map(R));for(const e of this._workingFeatures)this._reactiveGraphicLookup.set(e.source,e)}}async _syncAttachments(){const{activeFeature:e,activeLayer:t,activeForm:a}=this;if(!(e&&a&&H(t)&&P(t)))return;const i=e.getObjectId();if(null==i)return;const n=this._attachmentCache.get(t),r=a.allAttachmentElementInputs;if(!r.length)return;const l=s(async e=>{let s;if(n){const e=n.get(i);e&&(s=e)}if(!s){s=await j(t,i,r,e);o(this._attachmentCache,t,()=>new d).set(i,s)}for(const t of r)t.applyFetchedAttachments(oe(t,s))});this._syncAttachmentsTask=l,await u(l.promise)}get test(){return{expressionsManager:this._expressionsManager,reactiveGraphicLookup:this._reactiveGraphicLookup,syncAttachmentsTask:this._syncAttachmentsTask}}};e([F()],ae.prototype,"_attachmentCache",void 0),e([F({readOnly:!0})],ae.prototype,"activeFeature",null),e([F()],ae.prototype,"activeFeatureIndex",void 0),e([F({readOnly:!0})],ae.prototype,"activeForm",null),e([F({readOnly:!0})],ae.prototype,"activeLayer",null),e([F()],ae.prototype,"activeAssociation",null),e([F()],ae.prototype,"activeAssociationsInput",null),e([F()],ae.prototype,"activeAssociationType",null),e([F()],ae.prototype,"activeRelationshipInput",null),e([F()],ae.prototype,"attachmentsEnabled",void 0),e([F()],ae.prototype,"callbacks",void 0),e([F()],ae.prototype,"disabled",void 0),e([F()],ae.prototype,"calculating",null),e([F()],ae.prototype,"canGoBack",null),e([F()],ae.prototype,"contingentValuesManager",void 0),e([F()],ae.prototype,"editType",void 0),e([F()],ae.prototype,"features",void 0),e([F()],ae.prototype,"expressionEvaluationFailed",null),e([F()],ae.prototype,"hasNonActiveInvalidFeatures",null),e([F()],ae.prototype,"hasAsyncArcadeExpressions",null),e([F()],ae.prototype,"_hasAsyncArcadeExpressions",void 0),e([F()],ae.prototype,"invalidFeatures",null),e([F()],ae.prototype,"hasVisibleInputs",null),e([F()],ae.prototype,"hasLayersWithContingentValues",null),e([F()],ae.prototype,"formDescription",null),e([F()],ae.prototype,"formTitle",null),e([F()],ae.prototype,"effectiveTimeZone",null),e([F()],ae.prototype,"highlightHelper",void 0),e([F()],ae.prototype,"maximumFeatureCount",void 0),e([F()],ae.prototype,"maximumFeatureCountWithComplexForms",void 0),e([F()],ae.prototype,"visibleInputs",null),e([F()],ae.prototype,"map",void 0),e([F()],ae.prototype,"noVisibleElementsReason",null),e([F()],ae.prototype,"page",null),e([F()],ae.prototype,"pageStack",void 0),e([F()],ae.prototype,"readOnly",void 0),e([F()],ae.prototype,"pendingSubtypeChoice",void 0),e([F()],ae.prototype,"subtypes",null),e([F()],ae.prototype,"spatialReference",void 0),e([F()],ae.prototype,"submitHasBeenAttempted",void 0),e([F()],ae.prototype,"timeZone",void 0),e([F()],ae.prototype,"updating",null),e([F()],ae.prototype,"valid",null),e([F()],ae.prototype,"layers",null),e([F()],ae.prototype,"mode",null),e([F()],ae.prototype,"sharedForm",void 0),e([F()],ae.prototype,"sharedFormTemplate",void 0),e([F()],ae.prototype,"selectedAttachment",null),e([F()],ae.prototype,"selectedAttachmentAddElementId",null),e([F()],ae.prototype,"selectedAttachmentListElementId",null),e([F()],ae.prototype,"selectedAttachmentListInput",null),e([F()],ae.prototype,"showingSelectedAttachmentReplacePage",null),e([F()],ae.prototype,"selectedAttachmentAddInput",null),e([F()],ae.prototype,"selectedAttachmentDetails",null),e([F()],ae.prototype,"userHasChangedValues",void 0),e([F()],ae.prototype,"layerInfos",void 0),e([F()],ae.prototype,"_arcadeExecutorProvider",void 0),e([F()],ae.prototype,"_activeAssociation",void 0),e([F()],ae.prototype,"_activeAssociationsInput",void 0),e([F()],ae.prototype,"_activeRelationshipInput",void 0),e([F()],ae.prototype,"_prepareTask",void 0),e([F()],ae.prototype,"_reactiveGraphicLookup",void 0),e([F()],ae.prototype,"_allAttachmentInputs",null),e([F()],ae.prototype,"_hasPendingAttachmentHydration",null),e([F()],ae.prototype,"_layerTemplateMap",void 0),e([F()],ae.prototype,"_layersSet",null),e([F()],ae.prototype,"_workingFeatures",void 0),e([F()],ae.prototype,"_expressionsManager",void 0),ae=e([I("esri.widgets.BatchAttributeForm.BatchAttributeFormViewModel")],ae);const ie=ae;function ne(e){return null!=e&&e.trim().length>0}function re(e,t){const s=e.keywords;return ne(s)&&s.toLowerCase()===t}function oe(e,t){const s="attachment"===e.input?.type?e.input.attachmentAssociationType:"exact",a=e.attachmentKeyword;if("any"===s)return t;if("exactOrNone"===s){if(te(a))return t.filter(e=>!ne(e.keywords));const e=a.toLowerCase();return t.filter(t=>!ne(t.keywords)||re(t,e))}if(te(a))return t;const i=a.toLowerCase();return t.filter(e=>re(e,i))}export{ie as default};