@arcgis/core 4.33.0-next.20250522 → 4.33.0-next.20250523

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 (356) hide show
  1. package/Map.js +1 -1
  2. package/WebScene.js +1 -1
  3. package/analysis/DimensionAnalysis.js +1 -1
  4. package/analysis/LineOfSightAnalysis.js +1 -1
  5. package/analysis/ViewshedAnalysis.js +1 -1
  6. package/arcade/Voxel.js +1 -1
  7. package/arcade/functions/knowledgegraph.js +1 -1
  8. package/assets/esri/core/workers/RemoteClient.js +1 -1
  9. package/assets/esri/core/workers/chunks/{253bcc3cc7bc4c2dc6ea.js → 03db109e9b695528c35d.js} +1 -1
  10. package/assets/esri/core/workers/chunks/{fa63b0f7fa799cb2f81d.js → 07e58dff44fcbb3b3539.js} +1 -1
  11. package/assets/esri/core/workers/chunks/{fc61d02286b6ff5447cc.js → 09da6b3085fc84cd69d5.js} +1 -1
  12. package/assets/esri/core/workers/chunks/{bf3555f91492a1a3b613.js → 09f76ca9b47b465c934f.js} +1 -1
  13. package/assets/esri/core/workers/chunks/0b70b2ee62904318a12c.js +1 -0
  14. package/assets/esri/core/workers/chunks/0fd826e7f64a37aaaa1e.js +1 -0
  15. package/assets/esri/core/workers/chunks/{1c86aa3802d9ae0230ae.js → 28e31ac00dc95a1318e9.js} +1 -1
  16. package/assets/esri/core/workers/chunks/{23f6e98ef22f099f846c.js → 330f1996cfc3e9c952cc.js} +1 -1
  17. package/assets/esri/core/workers/chunks/{0d23610475c85385fbff.js → 355e6bcdb401ada71f39.js} +1 -1
  18. package/assets/esri/core/workers/chunks/{bba6d7615d8f3862fe70.js → 36f0046ff6b46adce7b7.js} +1 -1
  19. package/assets/esri/core/workers/chunks/{42d9989b2aad3ac28d4d.js → 397b15d46f22718c9f38.js} +1 -1
  20. package/assets/esri/core/workers/chunks/{b0522dffa5600345c07e.js → 3e85e63148b5e93d3074.js} +1 -1
  21. package/assets/esri/core/workers/chunks/{14b3c18581b31c93af82.js → 41cbba9b286cf5558a9c.js} +1 -1
  22. package/assets/esri/core/workers/chunks/{d2ebb72a43d995ed368a.js → 42bb9bb6fe44a47d9b81.js} +1 -1
  23. package/assets/esri/core/workers/chunks/{6ee41e9c92ed8ba4c763.js → 4dd0a5f327fa5fc7249d.js} +1 -1
  24. package/assets/esri/core/workers/chunks/{36b0d6b4089a96475201.js → 51ba7345c31e6eb79060.js} +1 -1
  25. package/assets/esri/core/workers/chunks/{66e79aa02b3aa12b3778.js → 5200be8bce60fa831026.js} +1 -1
  26. package/assets/esri/core/workers/chunks/{6b23ca6570357f9fb724.js → 52a57106a41b8c9483d7.js} +1 -1
  27. package/assets/esri/core/workers/chunks/{585c7b485c42555ec554.js → 61f9747c960d959b571b.js} +2 -2
  28. package/assets/esri/core/workers/chunks/{9fc35ec8185beba96715.js → 632d1a1287dde980479e.js} +1 -1
  29. package/assets/esri/core/workers/chunks/{1d043965dcdc11b3aeaa.js → 63852887b3f07d50f7c9.js} +1 -1
  30. package/assets/esri/core/workers/chunks/{c16e0da7a19310c71e8b.js → 677af0281e4fc9f3bd98.js} +1 -1
  31. package/assets/esri/core/workers/chunks/{6ecc3a3737ae8622dfa4.js → 7b12607633bbdc318936.js} +1 -1
  32. package/assets/esri/core/workers/chunks/{d839a237d5edc243d645.js → 8aa8f9986b966ccb64e2.js} +1 -1
  33. package/assets/esri/core/workers/chunks/{12e99071f6582f6caeaf.js → 8b3d1973eb75b81b0fb4.js} +1 -1
  34. package/assets/esri/core/workers/chunks/{67338948e470c1251d8a.js → 8d14e957219364a81d5f.js} +3 -3
  35. package/assets/esri/core/workers/chunks/92a5dccb328229a9336b.js +1 -0
  36. package/assets/esri/core/workers/chunks/{631205dc4d73d49ec9ed.js → 95507ff0a243e451b99e.js} +1 -1
  37. package/assets/esri/core/workers/chunks/{1051a5a57b2fb843a555.js → 9cd55043f3d789f41815.js} +1 -1
  38. package/assets/esri/core/workers/chunks/{2b1486a466760d2152f5.js → a0f2df8ca7cd14bfa013.js} +1 -1
  39. package/assets/esri/core/workers/chunks/{06eb4832b6c86744e52e.js → aba19485b6cdcb70dac6.js} +1 -1
  40. package/assets/esri/core/workers/chunks/{9a06476b834584d00d5c.js → b160dcbea6256e0cf689.js} +1 -1
  41. package/assets/esri/core/workers/chunks/b2a6afa0cd537805b4b8.js +1 -0
  42. package/assets/esri/core/workers/chunks/{571252c9822d73cf7b01.js → b845586219f284a215b2.js} +1 -1
  43. package/assets/esri/core/workers/chunks/{97c148adf0347c69a79c.js → c9604f8df909ec4fad46.js} +1 -1
  44. package/assets/esri/core/workers/chunks/{b87fec1753f164c845c5.js → ca76950d81ab4ebb65e1.js} +1 -1
  45. package/assets/esri/core/workers/chunks/{faa40ef04604c7cce706.js → cb63ea6a53d3c2fc3179.js} +1 -1
  46. package/assets/esri/core/workers/chunks/{55f087bca75c3f2a4515.js → d3c0d7799c92c6f0e7d3.js} +1 -1
  47. package/assets/esri/core/workers/chunks/{ca60b34c3e1ed2ff5934.js → dd2b316baae02bbdddac.js} +1 -1
  48. package/assets/esri/core/workers/chunks/{80b596496800e8d60eb8.js → ed75e0962358523f4439.js} +1 -1
  49. package/assets/esri/core/workers/chunks/{0cf979a093e9744d1e80.js → ef7955a2509be0f03ca2.js} +1 -1
  50. package/assets/esri/core/workers/chunks/{b5d68d8460b7c15001dd.js → f1c6df5cf2ccb6ac47a1.js} +1 -1
  51. package/assets/esri/core/workers/chunks/{523046e04679e301797d.js → f3d97a4c4f433adbdab5.js} +1 -1
  52. package/assets/esri/themes/base/widgets/_Editor.scss +1 -0
  53. package/assets/esri/themes/dark/main.css +1 -1
  54. package/assets/esri/themes/light/main.css +1 -1
  55. package/assets/esri/themes/light/view.css +1 -1
  56. package/assets/esri/views/interactive/tooltip/t9n/Tooltip_no.json +1 -1
  57. package/assets/esri/widgets/Directions/t9n/Directions_de.json +1 -1
  58. package/assets/esri/widgets/Editor/t9n/Editor.json +1 -1
  59. package/assets/esri/widgets/Editor/t9n/Editor_ar.json +1 -1
  60. package/assets/esri/widgets/Editor/t9n/Editor_bg.json +1 -1
  61. package/assets/esri/widgets/Editor/t9n/Editor_bs.json +1 -1
  62. package/assets/esri/widgets/Editor/t9n/Editor_ca.json +1 -1
  63. package/assets/esri/widgets/Editor/t9n/Editor_cs.json +1 -1
  64. package/assets/esri/widgets/Editor/t9n/Editor_da.json +1 -1
  65. package/assets/esri/widgets/Editor/t9n/Editor_de.json +1 -1
  66. package/assets/esri/widgets/Editor/t9n/Editor_el.json +1 -1
  67. package/assets/esri/widgets/Editor/t9n/Editor_en.json +1 -1
  68. package/assets/esri/widgets/Editor/t9n/Editor_es.json +1 -1
  69. package/assets/esri/widgets/Editor/t9n/Editor_et.json +1 -1
  70. package/assets/esri/widgets/Editor/t9n/Editor_fi.json +1 -1
  71. package/assets/esri/widgets/Editor/t9n/Editor_fr.json +1 -1
  72. package/assets/esri/widgets/Editor/t9n/Editor_he.json +1 -1
  73. package/assets/esri/widgets/Editor/t9n/Editor_hr.json +1 -1
  74. package/assets/esri/widgets/Editor/t9n/Editor_hu.json +1 -1
  75. package/assets/esri/widgets/Editor/t9n/Editor_id.json +1 -1
  76. package/assets/esri/widgets/Editor/t9n/Editor_it.json +1 -1
  77. package/assets/esri/widgets/Editor/t9n/Editor_ja.json +1 -1
  78. package/assets/esri/widgets/Editor/t9n/Editor_ko.json +1 -1
  79. package/assets/esri/widgets/Editor/t9n/Editor_lt.json +1 -1
  80. package/assets/esri/widgets/Editor/t9n/Editor_lv.json +1 -1
  81. package/assets/esri/widgets/Editor/t9n/Editor_nl.json +1 -1
  82. package/assets/esri/widgets/Editor/t9n/Editor_no.json +1 -1
  83. package/assets/esri/widgets/Editor/t9n/Editor_pl.json +1 -1
  84. package/assets/esri/widgets/Editor/t9n/Editor_pt-BR.json +1 -1
  85. package/assets/esri/widgets/Editor/t9n/Editor_pt-PT.json +1 -1
  86. package/assets/esri/widgets/Editor/t9n/Editor_ro.json +1 -1
  87. package/assets/esri/widgets/Editor/t9n/Editor_ru.json +1 -1
  88. package/assets/esri/widgets/Editor/t9n/Editor_sk.json +1 -1
  89. package/assets/esri/widgets/Editor/t9n/Editor_sl.json +1 -1
  90. package/assets/esri/widgets/Editor/t9n/Editor_sr.json +1 -1
  91. package/assets/esri/widgets/Editor/t9n/Editor_sv.json +1 -1
  92. package/assets/esri/widgets/Editor/t9n/Editor_th.json +1 -1
  93. package/assets/esri/widgets/Editor/t9n/Editor_tr.json +1 -1
  94. package/assets/esri/widgets/Editor/t9n/Editor_uk.json +1 -1
  95. package/assets/esri/widgets/Editor/t9n/Editor_vi.json +1 -1
  96. package/assets/esri/widgets/Editor/t9n/Editor_zh-CN.json +1 -1
  97. package/assets/esri/widgets/Editor/t9n/Editor_zh-HK.json +1 -1
  98. package/assets/esri/widgets/Editor/t9n/Editor_zh-TW.json +1 -1
  99. package/assets/esri/widgets/FeatureForm/t9n/FeatureForm_ar.json +1 -1
  100. package/assets/esri/widgets/FeatureForm/t9n/FeatureForm_bg.json +1 -1
  101. package/assets/esri/widgets/FeatureForm/t9n/FeatureForm_bs.json +1 -1
  102. package/assets/esri/widgets/FeatureForm/t9n/FeatureForm_ca.json +1 -1
  103. package/assets/esri/widgets/FeatureForm/t9n/FeatureForm_cs.json +1 -1
  104. package/assets/esri/widgets/FeatureForm/t9n/FeatureForm_da.json +1 -1
  105. package/assets/esri/widgets/FeatureForm/t9n/FeatureForm_de.json +1 -1
  106. package/assets/esri/widgets/FeatureForm/t9n/FeatureForm_el.json +1 -1
  107. package/assets/esri/widgets/FeatureForm/t9n/FeatureForm_es.json +1 -1
  108. package/assets/esri/widgets/FeatureForm/t9n/FeatureForm_et.json +1 -1
  109. package/assets/esri/widgets/FeatureForm/t9n/FeatureForm_fi.json +1 -1
  110. package/assets/esri/widgets/FeatureForm/t9n/FeatureForm_fr.json +1 -1
  111. package/assets/esri/widgets/FeatureForm/t9n/FeatureForm_he.json +1 -1
  112. package/assets/esri/widgets/FeatureForm/t9n/FeatureForm_hr.json +1 -1
  113. package/assets/esri/widgets/FeatureForm/t9n/FeatureForm_hu.json +1 -1
  114. package/assets/esri/widgets/FeatureForm/t9n/FeatureForm_id.json +1 -1
  115. package/assets/esri/widgets/FeatureForm/t9n/FeatureForm_it.json +1 -1
  116. package/assets/esri/widgets/FeatureForm/t9n/FeatureForm_ja.json +1 -1
  117. package/assets/esri/widgets/FeatureForm/t9n/FeatureForm_ko.json +1 -1
  118. package/assets/esri/widgets/FeatureForm/t9n/FeatureForm_lt.json +1 -1
  119. package/assets/esri/widgets/FeatureForm/t9n/FeatureForm_lv.json +1 -1
  120. package/assets/esri/widgets/FeatureForm/t9n/FeatureForm_nl.json +1 -1
  121. package/assets/esri/widgets/FeatureForm/t9n/FeatureForm_no.json +1 -1
  122. package/assets/esri/widgets/FeatureForm/t9n/FeatureForm_pl.json +1 -1
  123. package/assets/esri/widgets/FeatureForm/t9n/FeatureForm_pt-BR.json +1 -1
  124. package/assets/esri/widgets/FeatureForm/t9n/FeatureForm_pt-PT.json +1 -1
  125. package/assets/esri/widgets/FeatureForm/t9n/FeatureForm_ro.json +1 -1
  126. package/assets/esri/widgets/FeatureForm/t9n/FeatureForm_ru.json +1 -1
  127. package/assets/esri/widgets/FeatureForm/t9n/FeatureForm_sk.json +1 -1
  128. package/assets/esri/widgets/FeatureForm/t9n/FeatureForm_sl.json +1 -1
  129. package/assets/esri/widgets/FeatureForm/t9n/FeatureForm_sr.json +1 -1
  130. package/assets/esri/widgets/FeatureForm/t9n/FeatureForm_sv.json +1 -1
  131. package/assets/esri/widgets/FeatureForm/t9n/FeatureForm_th.json +1 -1
  132. package/assets/esri/widgets/FeatureForm/t9n/FeatureForm_tr.json +1 -1
  133. package/assets/esri/widgets/FeatureForm/t9n/FeatureForm_uk.json +1 -1
  134. package/assets/esri/widgets/FeatureForm/t9n/FeatureForm_vi.json +1 -1
  135. package/assets/esri/widgets/FeatureForm/t9n/FeatureForm_zh-CN.json +1 -1
  136. package/assets/esri/widgets/FeatureForm/t9n/FeatureForm_zh-HK.json +1 -1
  137. package/assets/esri/widgets/FeatureForm/t9n/FeatureForm_zh-TW.json +1 -1
  138. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable.json +1 -1
  139. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_en.json +1 -1
  140. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer.json +1 -1
  141. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_ar.json +1 -1
  142. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_bg.json +1 -1
  143. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_bs.json +1 -1
  144. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_ca.json +1 -1
  145. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_cs.json +1 -1
  146. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_da.json +1 -1
  147. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_de.json +1 -1
  148. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_el.json +1 -1
  149. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_en.json +1 -1
  150. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_es.json +1 -1
  151. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_et.json +1 -1
  152. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_fi.json +1 -1
  153. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_fr.json +1 -1
  154. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_he.json +1 -1
  155. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_hr.json +1 -1
  156. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_hu.json +1 -1
  157. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_id.json +1 -1
  158. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_it.json +1 -1
  159. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_ja.json +1 -1
  160. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_ko.json +1 -1
  161. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_lt.json +1 -1
  162. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_lv.json +1 -1
  163. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_nl.json +1 -1
  164. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_no.json +1 -1
  165. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_pl.json +1 -1
  166. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_pt-BR.json +1 -1
  167. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_pt-PT.json +1 -1
  168. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_ro.json +1 -1
  169. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_ru.json +1 -1
  170. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_sk.json +1 -1
  171. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_sl.json +1 -1
  172. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_sr.json +1 -1
  173. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_sv.json +1 -1
  174. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_th.json +1 -1
  175. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_tr.json +1 -1
  176. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_uk.json +1 -1
  177. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_vi.json +1 -1
  178. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_zh-CN.json +1 -1
  179. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_zh-HK.json +1 -1
  180. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_zh-TW.json +1 -1
  181. package/chunks/FocusAreaColor.glsl.js +10 -8
  182. package/chunks/persistableUrlUtils.js +1 -1
  183. package/core/accessorSupport/decorators/persistable.js +1 -1
  184. package/geometry/projection/projectPointToVector.js +1 -1
  185. package/geometry/projection/projectVectorToPoint.js +1 -1
  186. package/geometry/projection/projectVectorToVector.js +1 -1
  187. package/geometry/projection.js +1 -1
  188. package/geometry/projectionUtils.js +5 -0
  189. package/geometry/support/meshUtils/elevation.js +1 -1
  190. package/geometry/support/meshUtils/extent.js +1 -1
  191. package/interfaces.d.ts +243 -69
  192. package/layers/IntegratedMesh3DTilesLayer.js +1 -1
  193. package/layers/IntegratedMeshLayer.js +1 -1
  194. package/layers/MapNotesLayer.js +1 -1
  195. package/layers/OrientedImageryLayer.js +1 -1
  196. package/layers/RouteLayer.js +1 -1
  197. package/layers/VideoLayer.js +1 -1
  198. package/layers/graphics/applyEditsUtils.js +1 -1
  199. package/layers/graphics/controllers/FeatureTileController3D.js +1 -1
  200. package/layers/graphics/data/QueryEngine.js +1 -1
  201. package/layers/graphics/data/projectionSupport.js +1 -1
  202. package/layers/graphics/data/queryUtils.js +1 -1
  203. package/layers/graphics/sources/support/CSVSourceWorker.js +1 -1
  204. package/layers/knowledgeGraph/KnowledgeGraphLayerDataManager.js +1 -1
  205. package/layers/knowledgeGraph/KnowledgeGraphSublayer.js +1 -1
  206. package/layers/ogc/wfsUtils.js +1 -1
  207. package/layers/orientedImagery/core/ExposurePoint.js +1 -1
  208. package/layers/orientedImagery/core/coverageUtils.js +1 -1
  209. package/layers/orientedImagery/core/utils.js +1 -1
  210. package/layers/orientedImagery/queries.js +1 -1
  211. package/layers/orientedImagery/transformations/updateElevationUtils.js +1 -1
  212. package/layers/orientedImagery/transformations/utils.js +1 -1
  213. package/layers/support/ControlPointsGeoreference.js +1 -1
  214. package/layers/support/CornersGeoreference.js +1 -1
  215. package/layers/support/ElevationQuery.js +1 -1
  216. package/layers/support/ExtentAndRotationGeoreference.js +1 -1
  217. package/layers/support/GeoreferenceBase.js +1 -1
  218. package/layers/support/LocalMediaElementSource.js +1 -1
  219. package/layers/support/MediaElementView.js +1 -1
  220. package/layers/support/PolygonCollection.js +1 -1
  221. package/layers/support/SceneModification.js +1 -1
  222. package/layers/support/Sublayer.js +1 -1
  223. package/layers/support/rasterFunctions/rasterProjectionHelper.js +1 -1
  224. package/layers/video/VideoController.js +1 -1
  225. package/package.json +1 -1
  226. package/portal/schemas/definitions.js +1 -1
  227. package/portal/schemas/webScene.js +1 -1
  228. package/portal/support/portalItemUtils.js +1 -1
  229. package/renderers/support/AuthoringInfoVisualVariable.js +1 -1
  230. package/smartMapping/renderers/size.js +1 -1
  231. package/smartMapping/renderers/support/spikeUtils.d.ts +4 -0
  232. package/smartMapping/renderers/support/spikeUtils.js +1 -1
  233. package/smartMapping/statistics/histogram.js +1 -1
  234. package/smartMapping/statistics/summaryStatistics.js +1 -1
  235. package/support/persistableUrlUtils.js +1 -1
  236. package/support/revision.js +1 -1
  237. package/views/2d/ViewStateManager.js +1 -1
  238. package/views/2d/constraints/GeometryConstraint.js +1 -1
  239. package/views/2d/engine/webgl/OverlayMultipoint.js +1 -1
  240. package/views/2d/grid/GridView2D.js +1 -1
  241. package/views/2d/interactive/editingTools/ControlPointsTransformTool.js +1 -1
  242. package/views/2d/interactive/editingTools/TransformTool.js +1 -1
  243. package/views/2d/layers/KMLLayerView2D.js +1 -1
  244. package/views/2d/layers/VideoLayerView2D.js +1 -1
  245. package/views/2d/viewpointUtils.js +1 -1
  246. package/views/3d/FocusAreasView.js +1 -1
  247. package/views/3d/analysis/AreaMeasurement/support/AreaMeasurementPathHelper.js +1 -1
  248. package/views/3d/analysis/AreaMeasurement/support/MeasurementData.js +1 -1
  249. package/views/3d/analysis/LineOfSight/LineOfSightController.js +1 -1
  250. package/views/3d/analysis/Slice/sliceToolUtils.js +1 -1
  251. package/views/3d/analysis/Viewshed/ViewshedSubTool.js +1 -1
  252. package/views/3d/analysis/ViewshedAnalysisView3D.js +1 -1
  253. package/views/3d/analysis/support/projectionUtils.js +1 -1
  254. package/views/3d/environment/EnvironmentManager.js +1 -1
  255. package/views/3d/interactive/Manipulator3D.js +1 -1
  256. package/views/3d/interactive/editingTools/dragEventPipeline3D.js +1 -1
  257. package/views/3d/interactive/editingTools/media/MediaElementControllerControlPoints.js +1 -1
  258. package/views/3d/interactive/editingTools/media/MediaElementControllerShape.js +1 -1
  259. package/views/3d/interactive/editingTools/reshape/edgeOffsetUtils.js +1 -1
  260. package/views/3d/interactive/visualElements/support/Segment.js +1 -1
  261. package/views/3d/layers/FeatureLayerView3D.js +1 -1
  262. package/views/3d/layers/FlowSubView3D.js +1 -1
  263. package/views/3d/layers/I3SMeshWorkerHandle.js +1 -1
  264. package/views/3d/layers/SceneLayerWorker.js +1 -1
  265. package/views/3d/layers/TileLayerView3D.js +1 -1
  266. package/views/3d/layers/graphics/Graphics3DCore.js +1 -1
  267. package/views/3d/layers/graphics/Graphics3DFeatureStore.js +1 -1
  268. package/views/3d/layers/graphics/Graphics3DMeshFillSymbolLayer.js +1 -1
  269. package/views/3d/layers/graphics/focusAreaStyle.js +1 -1
  270. package/views/3d/layers/graphics/graphicUtils.js +1 -1
  271. package/views/3d/layers/graphics/pipeline/Feature3DPipelineWorker.js +1 -1
  272. package/views/3d/layers/i3s/I3SMeshViewFilter.js +1 -1
  273. package/views/3d/layers/i3s/I3SUtil.js +1 -1
  274. package/views/3d/layers/support/FeatureTile.js +1 -1
  275. package/views/3d/layers/support/FeatureTileFetcher3D.js +1 -1
  276. package/views/3d/layers/support/FeatureTileFetcher3DDebugger.js +1 -1
  277. package/views/3d/layers/support/ImageHighlightHelper3D.js +1 -1
  278. package/views/3d/state/ViewStateManager.js +1 -1
  279. package/views/3d/support/cameraUtils.js +1 -1
  280. package/views/3d/support/viewpointUtils.js +1 -1
  281. package/views/3d/terrain/ExtentHelper.js +1 -1
  282. package/views/3d/terrain/TextureFader.js +1 -1
  283. package/views/3d/webgl-engine/core/FBOCache.js +1 -1
  284. package/views/3d/webgl-engine/effects/focusArea/FocusAreaColorNode.js +1 -1
  285. package/views/3d/webgl-engine/effects/focusArea/FocusAreaEffect.js +5 -0
  286. package/views/3d/webgl-engine/effects/focusArea/FocusAreaMaskNode.js +1 -1
  287. package/views/3d/webgl-engine/lib/ShadowAccumulator.js +1 -1
  288. package/views/3d/webgl-engine/materials/HUDMaterial.js +1 -1
  289. package/views/3d/webgl-engine/shaders/FocusAreaColor.glsl.js +1 -1
  290. package/views/FocusArea.js +1 -1
  291. package/views/FocusAreaOutline.js +1 -1
  292. package/views/FocusAreas.js +1 -1
  293. package/views/SceneView.js +1 -1
  294. package/views/VideoView.js +1 -1
  295. package/views/View2D.js +1 -1
  296. package/views/interactive/GraphicManipulator.js +1 -1
  297. package/views/interactive/dragEventPipeline.js +1 -1
  298. package/views/interactive/snapping/GridSnappingEngine.js +1 -1
  299. package/views/interactive/snapping/SnappingManager.js +1 -1
  300. package/views/interactive/snapping/featureSources/GraphicsSnappingSource.js +1 -1
  301. package/views/layers/SceneLayerView.js +1 -1
  302. package/views/support/geodesicAreaMeasurementUtils.js +1 -1
  303. package/views/support/projectionUtils.js +1 -1
  304. package/views/webgl/FramebufferObject.js +1 -1
  305. package/views/webgl/RenderingContext.js +1 -1
  306. package/webscene/Slide.js +1 -1
  307. package/webscene/support/analysisUtils.js +1 -1
  308. package/widgets/AreaMeasurement3D.js +1 -1
  309. package/widgets/BasemapGallery/BasemapGalleryViewModel.js +1 -1
  310. package/widgets/BasemapToggle/BasemapToggleViewModel.js +1 -1
  311. package/widgets/CoordinateConversion/CoordinateConversionViewModel.js +1 -1
  312. package/widgets/CoordinateConversion/support/Format.js +1 -1
  313. package/widgets/DirectLineMeasurement3D/DirectLineMeasurement3DViewModel.js +1 -1
  314. package/widgets/DirectLineMeasurement3D.js +1 -1
  315. package/widgets/Editor/EditorViewModel.js +1 -1
  316. package/widgets/Editor/UpdateWorkflow.js +1 -1
  317. package/widgets/Editor/Upload.js +1 -1
  318. package/widgets/Editor/components/Notices.js +1 -1
  319. package/widgets/Editor/components/UpdateFeaturePanelContent.js +1 -1
  320. package/widgets/Editor/workflowUtils.js +1 -1
  321. package/widgets/Editor.js +1 -1
  322. package/widgets/ElevationProfile/support/geometryUtils.js +1 -1
  323. package/widgets/FeatureForm/FeatureFormUtilityNetworkAssociations/UtilityNetworkAssociationItemList.js +1 -1
  324. package/widgets/FeatureTable/support/tableUtils.js +1 -1
  325. package/widgets/FeatureTable.js +1 -1
  326. package/widgets/Features/FeaturesViewModel.js +1 -1
  327. package/widgets/LineOfSight.js +1 -1
  328. package/widgets/OrientedImageryViewer/OrientedImageryViewerViewModel.js +1 -1
  329. package/widgets/OrientedImageryViewer/OrientedImageryViewerVisibleElements.js +1 -1
  330. package/widgets/OrientedImageryViewer/adapters/sketch/DataCaptureAdapter.js +1 -1
  331. package/widgets/OrientedImageryViewer/adapters/sketch/MeasurementAdapter.js +1 -1
  332. package/widgets/OrientedImageryViewer/adapters/sketch/TriangulatedMeasurementAdapter.js +1 -1
  333. package/widgets/OrientedImageryViewer/adapters/view/MapViewAdapter.js +1 -1
  334. package/widgets/OrientedImageryViewer/adapters/view/SceneViewAdapter.js +1 -1
  335. package/widgets/OrientedImageryViewer/components/ImageViewerViewModel.js +1 -1
  336. package/widgets/OrientedImageryViewer/components/NavigationAction.js +5 -0
  337. package/widgets/OrientedImageryViewer/components/NavigationActions.js +1 -1
  338. package/widgets/OrientedImageryViewer/components/OrientedImageryVideoViewModel.js +5 -0
  339. package/widgets/OrientedImageryViewer/constants.js +1 -1
  340. package/widgets/OrientedImageryViewer/imageMeasurementUtils.js +1 -1
  341. package/widgets/OrientedImageryViewer.js +1 -1
  342. package/widgets/PanoramicViewer/PanoramicViewerViewModel.js +1 -1
  343. package/widgets/Sketch/SketchViewModel.js +1 -1
  344. package/widgets/Sketch.js +1 -1
  345. package/widgets/Slice.js +1 -1
  346. package/widgets/UtilityNetworkTrace/support/GeometryHandler.js +1 -1
  347. package/widgets/support/AnalysisViewModel.js +1 -1
  348. package/widgets/support/AnchorElementViewModel.js +1 -1
  349. package/widgets/support/GridControls/GridControlsViewModel.js +1 -1
  350. package/widgets/support/SelectionToolbar/SelectionToolbarViewModel.js +1 -1
  351. package/widgets/support/SelectionToolbar.js +1 -1
  352. package/widgets/support/tests.js +1 -1
  353. package/assets/esri/core/workers/chunks/3a743653b786b010a57f.js +0 -1
  354. package/assets/esri/core/workers/chunks/6d1e1a4fcb90ea8b6848.js +0 -1
  355. package/assets/esri/core/workers/chunks/7e6141b5baae47682f97.js +0 -1
  356. package/assets/esri/core/workers/chunks/87fc7b6c3e2d4f7775e2.js +0 -1
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
4
  */
5
- import has from"../../core/has.js";import{disposeMaybe as t}from"../../core/maybe.js";import{after as e}from"../../core/promiseUtils.js";import{Milliseconds as s}from"../../core/time.js";import{webglDebugEnabled as i,checkWebGLError as a}from"./checkWebGLError.js";import{ContextState as r}from"./ContextState.js";import{SpecialDrawBuffers as n,ColorAttachment0 as l,BufferType as h,Face as f,baseTextureUnit as o,FramebufferBit as u,BufferContent as c,FramebufferTarget as _,TextureSamplingMode as d,SyncCondition as b,ResourceType as F,ClientWaitSyncStatus as g,BlendFactor as B,BlendOperation as p,CullMode as m,CompareFunction as E,StencilOperation as R,TextureType as T,PrimitiveType as A}from"./enums.js";import{InstanceCounter as O}from"./InstanceCounter.js";import{Parameters as C}from"./Parameters.js";import{ProgramCache as x}from"./ProgramCache.js";import{StateTracker as U}from"./renderState.js";import{Texture as k}from"./Texture.js";import{getErrorString as w}from"./Util.js";import{WebGLDriverTest as S}from"./WebGLDriverTest.js";import{Capabilities as y}from"./capabilities/Capabilities.js";let v=class{constructor(t,e){this.gl=t,this.instanceCounter=new O,this.programCache=new x(this),this._transformFeedbackRequestInfo=null,this._state=new r,this._numOfDrawCalls=0,this._numOfTriangles=0,this.configure(e)}configure(e){this._capabilities=new y(this.gl,e),this._parameters=new C(this.gl,this._capabilities,e),k.TEXTURE_UNIT_FOR_UPDATES=this._parameters.maxTextureImageUnits-1;const s=this.gl.getParameter(this.gl.VIEWPORT);this._state=new r,this._state.viewport={x:s[0],y:s[1],width:s[2],height:s[3]},this._stateTracker=new U({setBlending:t=>{if(t){this.setBlendingEnabled(!0),this.setBlendEquationSeparate(t.opRgb,t.opAlpha),this.setBlendFunctionSeparate(t.srcRgb,t.dstRgb,t.srcAlpha,t.dstAlpha);const e=t.color;this.setBlendColor(e.r,e.g,e.b,e.a)}else this.setBlendingEnabled(!1)},setCulling:t=>{t?(this.setFaceCullingEnabled(!0),this.setCullFace(t.face),this.setFrontFace(t.mode)):this.setFaceCullingEnabled(!1)},setPolygonOffset:t=>{t?(this.setPolygonOffsetFillEnabled(!0),this.setPolygonOffset(t.factor,t.units)):this.setPolygonOffsetFillEnabled(!1)},setDepthTest:t=>{t?(this.setDepthTestEnabled(!0),this.setDepthFunction(t.func)):this.setDepthTestEnabled(!1)},setStencilTest:t=>{if(t){this.setStencilTestEnabled(!0);const e=t.function;this.setStencilFunction(e.func,e.ref,e.mask);const s=t.operation;this.setStencilOp(s.fail,s.zFail,s.zPass)}else this.setStencilTestEnabled(!1)},setDepthWrite:t=>{t?(this.setDepthWriteEnabled(!0),this.setDepthRange(t.zNear,t.zFar)):this.setDepthWriteEnabled(!1)},setColorWrite:t=>{t?this.setColorMask(t.r,t.g,t.b,t.a):this.setColorMask(!1,!1,!1,!1)},setStencilWrite:t=>{t?this.setStencilWriteMask(t.mask):this.setStencilWriteMask(0)},setDrawBuffers:t=>{if(t)this.setDrawBuffers(t.buffers);else{const{drawFramebuffer:t}=this._state;null===t?this.setDrawBuffers([n.BACK]):0===t.colorAttachments.length?this.setDrawBuffers([n.NONE]):this.setDrawBuffers([l])}}}),this.enforceState(),t(this._driverTest),this._driverTest=new S(this)}updateOptions(t){this._parameters=new C(this.gl,this._capabilities,t)}dispose(){t(this._driverTest),this.programCache.dispose(),this.bindVAO(null),this.unbindBuffer(h.ARRAY_BUFFER),this.unbindBuffer(h.ELEMENT_ARRAY_BUFFER),this.unbindBuffer(h.UNIFORM_BUFFER),this._state.uniformBufferBindingPoints.length=0,this.unbindBuffer(h.PIXEL_PACK_BUFFER),this.unbindBuffer(h.PIXEL_UNPACK_BUFFER),this.unbindBuffer(h.COPY_READ_BUFFER),this.unbindBuffer(h.COPY_WRITE_BUFFER),this._state.textureUnitMap.length=0,i()&&console.log(this.instanceCounter.resourceInformation)}get driverTest(){return this._driverTest}get contextAttributes(){return this.gl.getContextAttributes()}get parameters(){return this._parameters}setPipelineState(t){this._stateTracker.setPipeline(t)}setBlendingEnabled(t){this._state.blend!==t&&(!0===t?this.gl.enable(this.gl.BLEND):this.gl.disable(this.gl.BLEND),this._state.blend=t,this._stateTracker.invalidateBlending())}externalProgramUpdate(){this._state.program?.stop(),this._state.program=null}externalTextureUnitUpdate(t,e){for(let s=0;s<t.length;++s)this._state.textureUnitMap[t[s]]=null;e>=0&&(this._state.activeTexture=e)}externalVertexArrayObjectUpdate(){this.gl.bindVertexArray(null),this._state.vertexArrayObject=null,this._state.vertexBuffer=null,this._state.indexBuffer=null}externalVertexBufferUpdate(){this._state.vertexBuffer=null}externalIndexBufferUpdate(){this._state.indexBuffer=null}setBlendColor(t,e,s,i){t===this._state.blendColor.r&&e===this._state.blendColor.g&&s===this._state.blendColor.b&&i===this._state.blendColor.a||(this.gl.blendColor(t,e,s,i),this._state.blendColor.r=t,this._state.blendColor.g=e,this._state.blendColor.b=s,this._state.blendColor.a=i,this._stateTracker.invalidateBlending())}setBlendFunction(t,e){t===this._state.blendFunction.srcRGB&&e===this._state.blendFunction.dstRGB||(this.gl.blendFunc(t,e),this._state.blendFunction.srcRGB=t,this._state.blendFunction.srcAlpha=t,this._state.blendFunction.dstRGB=e,this._state.blendFunction.dstAlpha=e,this._stateTracker.invalidateBlending())}setBlendFunctionSeparate(t,e,s,i){this._state.blendFunction.srcRGB===t&&this._state.blendFunction.srcAlpha===s&&this._state.blendFunction.dstRGB===e&&this._state.blendFunction.dstAlpha===i||(this.gl.blendFuncSeparate(t,e,s,i),this._state.blendFunction.srcRGB=t,this._state.blendFunction.srcAlpha=s,this._state.blendFunction.dstRGB=e,this._state.blendFunction.dstAlpha=i,this._stateTracker.invalidateBlending())}setBlendEquation(t){this._state.blendEquation.mode!==t&&(this.gl.blendEquation(t),this._state.blendEquation.mode=t,this._state.blendEquation.modeAlpha=t,this._stateTracker.invalidateBlending())}setBlendEquationSeparate(t,e){this._state.blendEquation.mode===t&&this._state.blendEquation.modeAlpha===e||(this.gl.blendEquationSeparate(t,e),this._state.blendEquation.mode=t,this._state.blendEquation.modeAlpha=e,this._stateTracker.invalidateBlending())}setColorMask(t,e,s,i){this._state.colorMask.r===t&&this._state.colorMask.g===e&&this._state.colorMask.b===s&&this._state.colorMask.a===i||(this.gl.colorMask(t,e,s,i),this._state.colorMask.r=t,this._state.colorMask.g=e,this._state.colorMask.b=s,this._state.colorMask.a=i,this._stateTracker.invalidateColorWrite())}setClearColor(t,e,s,i){this._state.clearColor.r===t&&this._state.clearColor.g===e&&this._state.clearColor.b===s&&this._state.clearColor.a===i||(this.gl.clearColor(t,e,s,i),this._state.clearColor.r=t,this._state.clearColor.g=e,this._state.clearColor.b=s,this._state.clearColor.a=i)}setFaceCullingEnabled(t){this._state.faceCulling!==t&&(!0===t?this.gl.enable(this.gl.CULL_FACE):this.gl.disable(this.gl.CULL_FACE),this._state.faceCulling=t,this._stateTracker.invalidateCulling())}setPolygonOffsetFillEnabled(t){this._state.polygonOffsetFill!==t&&(!0===t?this.gl.enable(this.gl.POLYGON_OFFSET_FILL):this.gl.disable(this.gl.POLYGON_OFFSET_FILL),this._state.polygonOffsetFill=t,this._stateTracker.invalidatePolygonOffset())}setPolygonOffset(t,e){this._state.polygonOffset[0]===t&&this._state.polygonOffset[1]===e||(this._state.polygonOffset[0]=t,this._state.polygonOffset[1]=e,this.gl.polygonOffset(t,e),this._stateTracker.invalidatePolygonOffset())}setCullFace(t){this._state.cullFace!==t&&(this.gl.cullFace(t),this._state.cullFace=t,this._stateTracker.invalidateCulling())}setFrontFace(t){this._state.frontFace!==t&&(this.gl.frontFace(t),this._state.frontFace=t,this._stateTracker.invalidateCulling())}setScissorTestEnabled(t){this._state.scissorTest!==t&&(!0===t?this.gl.enable(this.gl.SCISSOR_TEST):this.gl.disable(this.gl.SCISSOR_TEST),this._state.scissorTest=t)}setScissorRect(t,e,s,i){this._state.scissorRect.x===t&&this._state.scissorRect.y===e&&this._state.scissorRect.width===s&&this._state.scissorRect.height===i||(this.gl.scissor(t,e,s,i),this._state.scissorRect.x=t,this._state.scissorRect.y=e,this._state.scissorRect.width=s,this._state.scissorRect.height=i)}setDepthTestEnabled(t){this._state.depthTest!==t&&(!0===t?this.gl.enable(this.gl.DEPTH_TEST):this.gl.disable(this.gl.DEPTH_TEST),this._state.depthTest=t,this._stateTracker.invalidateDepthTest())}setClearDepth(t){this._state.clearDepth!==t&&(this.gl.clearDepth(t),this._state.clearDepth=t)}setDepthFunction(t){this._state.depthFunction!==t&&(this.gl.depthFunc(t),this._state.depthFunction=t,this._stateTracker.invalidateDepthTest())}setDepthWriteEnabled(t){this._state.depthWrite!==t&&(this.gl.depthMask(t),this._state.depthWrite=t,this._stateTracker.invalidateDepthWrite())}setDepthRange(t,e){this._state.depthRange.zNear===t&&this._state.depthRange.zFar===e||(this.gl.depthRange(t,e),this._state.depthRange.zNear=t,this._state.depthRange.zFar=e,this._stateTracker.invalidateDepthWrite())}setStencilTestEnabled(t){this._state.stencilTest!==t&&(!0===t?this.gl.enable(this.gl.STENCIL_TEST):this.gl.disable(this.gl.STENCIL_TEST),this._state.stencilTest=t,this._stateTracker.invalidateStencilTest())}setClearStencil(t){t!==this._state.clearStencil&&(this.gl.clearStencil(t),this._state.clearStencil=t)}setStencilFunction(t,e,s){this._state.stencilFunction.func===t&&this._state.stencilFunction.ref===e&&this._state.stencilFunction.mask===s||(this.gl.stencilFunc(t,e,s),this._state.stencilFunction.face=f.FRONT_AND_BACK,this._state.stencilFunction.func=t,this._state.stencilFunction.ref=e,this._state.stencilFunction.mask=s,this._stateTracker.invalidateStencilTest())}setStencilFunctionSeparate(t,e,s,i){this._state.stencilFunction.face===t&&this._state.stencilFunction.func===e&&this._state.stencilFunction.ref===s&&this._state.stencilFunction.mask===i||(this.gl.stencilFuncSeparate(t,e,s,i),this._state.stencilFunction.face=t,this._state.stencilFunction.func=e,this._state.stencilFunction.ref=s,this._state.stencilFunction.mask=i,this._stateTracker.invalidateStencilTest())}setStencilWriteMask(t){this._state.stencilWriteMask!==t&&(this.gl.stencilMask(t),this._state.stencilWriteMask=t,this._stateTracker.invalidateStencilWrite())}setStencilOp(t,e,s){this._state.stencilOperation.face===f.FRONT_AND_BACK&&this._state.stencilOperation.fail===t&&this._state.stencilOperation.zFail===e&&this._state.stencilOperation.zPass===s||(this.gl.stencilOp(t,e,s),this._state.stencilOperation.face=f.FRONT_AND_BACK,this._state.stencilOperation.fail=t,this._state.stencilOperation.zFail=e,this._state.stencilOperation.zPass=s,this._stateTracker.invalidateStencilTest())}setStencilOpSeparate(t,e,s,i){this._state.stencilOperation.face===t&&this._state.stencilOperation.fail===e&&this._state.stencilOperation.zFail===s&&this._state.stencilOperation.zPass===i||(this.gl.stencilOpSeparate(t,e,s,i),this._state.stencilOperation.face=t,this._state.stencilOperation.fail=e,this._state.stencilOperation.zFail=s,this._state.stencilOperation.zPass=i,this._stateTracker.invalidateStencilTest())}setActiveTexture(t,e=!1){const s=this._state.activeTexture;return t>=0&&(e||t!==this._state.activeTexture)&&(this.gl.activeTexture(o+t),this._state.activeTexture=t),s}setDrawBuffers(t){const{drawFramebuffer:e}=this._state,s=null===e,i=s?this._state.drawBuffers.defaultFramebuffer:this._state.drawBuffers.fbos.get(e);if(i?.length!==t.length||!i.every(((e,s)=>e===t[s])))if(t.length>this.parameters.maxDrawBuffers)console.error("Setting more active draw buffers than GL.MAX_DRAW_BUFFERS allows.");else{if(s){if(t.length>1)return void console.error("The default framebuffer can only have one active draw buffer.");if(t[0]!==n.BACK&&t[0]!==n.NONE)return void console.error("The default framebuffer can only use the constants GL.BACK or GL.NONE as draw buffers.")}s||!t.includes(n.BACK)?(this.gl.drawBuffers(t),s?this._state.drawBuffers.defaultFramebuffer=t:this._state.drawBuffers.fbos.set(e,t),this._stateTracker.invalidateDrawBuffers()):console.error("A framebuffer object can only use the constants GL.COLOR_ATTACHMENTi or GL.NONE as draw buffers.")}}clear(t,e=255){if(t){if(t&u.COLOR){const t=this._state.drawFramebuffer?.colorAttachments;t&&this.setDrawBuffers(t),this.setColorMask(!0,!0,!0,!0)}t&u.DEPTH&&this.setDepthWriteEnabled(!0),t&u.STENCIL&&this.setStencilWriteMask(e),this.gl.clear(t)}}clearFramebuffer(t,e=!1,s=!1){let i=0;if(t){const e=1e-13,s=Math.max(e,t[3]);this.setClearColor(t[0],t[1],t[2],s),i|=u.COLOR}e&&(i|=u.DEPTH),!1===s?s=0:(!0===s&&(s=255),i|=u.STENCIL),i&&this.clear(i,s)}clearBuffer(t,e,s=c.COLOR,i=void 0){this.gl.clearBufferfv(s,t,e,i)}clearBufferInteger(t,e,s=c.COLOR,i=void 0){this.gl.clearBufferiv(s,t,e,i)}clearBufferUnsignedInteger(t,e,s=c.COLOR,i=void 0){this.gl.clearBufferuiv(s,t,e,i)}drawArrays(t,e,s){if(this._transformFeedbackRequestInfo){if(t!==this._transformFeedbackRequestInfo.primitiveType)throw new Error("DrawArrays called during transform feedback, but primitiveType does not match that of the current transform feedback request");if(null==this._state.program?.hasTransformFeedbackVaryings)throw new Error("DrawArrays called during transform feedback, but the shader program was not linked with a transform feedback varying")}if(i()&&(this._numOfDrawCalls++,this._numOfTriangles+=D(t,s),has("enable-feature:webgl-debug:textureReadWrite"))){const t=this._state.textureUnitMap;for(let e=0;e<t.length;e++){const s=t[e];if(null!=s&&s===this._state.drawFramebuffer?.colorTexture)throw new Error(`Detected readWrite. Texture already bound at index ${e}`)}}this.gl.drawArrays(t,e,s),a(this.gl)}drawArraysInstanced(t,e,s,i){this.gl.drawArraysInstanced(t,e,s,i),a(this.gl)}drawElements(t,e,s,a){if(this._transformFeedbackRequestInfo)throw new Error("Cannot called drawElements during a transform feedback request");if(i()&&(this._numOfDrawCalls++,this._numOfTriangles+=D(t,e)),this.gl.drawElements(t,e,s,a),i()){const i=w(this);if(i){const r=this.getBoundVAO(),n=r?.indexBuffer,l=r?.vertexBuffers,h={indexBuffer:n,vertexBuffers:l},f={mode:t,count:e,type:s,offset:a},o=n?.size??0,u=a+e,c=o<u?`. Buffer is too small. Attempted to draw index ${u} of ${o}`:"";console.error(`drawElements: ${i}${c}`,{args:f,vao:h})}}}drawElementsInstanced(t,e,s,i,r){this.gl.drawElementsInstanced(t,e,s,i,r),a(this.gl)}logInfo(){i()&&console.log(`DrawCalls: ${this._numOfDrawCalls}, Triangles: ${this._numOfTriangles}`)}resetInfo(){i()&&(this._numOfDrawCalls=0,this._numOfTriangles=0)}get capabilities(){return this._capabilities}setViewport(t,e,s,i){s=Math.max(Math.round(s),1),i=Math.max(Math.round(i),1);const a=this._state.viewport;a.x===t&&a.y===e&&a.width===s&&a.height===i||(a.x=t,a.y=e,a.width=s,a.height=i,this.gl.viewport(t,e,s,i))}setViewport4fv(t){this.setViewport(t[0],t[1],t[2],t[3])}restoreViewport({x:t,y:e,width:s,height:i}){this.setViewport(t,e,s,i)}getViewport(){const t=this._state.viewport;return{x:t.x,y:t.y,width:t.width,height:t.height}}useProgram(t){this._state.program!==t&&(this._state.program?.stop(),this._state.program=t,this.gl.useProgram(t?.glName??null))}bindTexture(t,e,s=!1){(e>=this.parameters.maxTextureImageUnits||e<0)&&console.error("Input texture unit is out of range of available units!");const i=this._state.textureUnitMap[e];return null==t?.glName?(null!=i&&(this.setActiveTexture(e,s),this.gl.bindTexture(i.descriptor.target,null)),this._state.textureUnitMap[e]=null,i):s||i!==t?(this.setActiveTexture(e,s),this.gl.bindTexture(t.descriptor.target,t.glName),t.applyChanges(),this._state.textureUnitMap[e]=t,i):(t.isDirty&&(this.setActiveTexture(e,s),t.applyChanges()),i)}unbindTexture(t){if(null!=t)for(let e=0;e<this.parameters.maxTextureImageUnits;e++)this._state.textureUnitMap[e]===t&&(this.bindTexture(null,e),this._state.textureUnitMap[e]=null)}bindFramebuffer(t,e=!1){if(e||this._state.readFramebuffer!==t||this._state.drawFramebuffer!==t){if(this._stateTracker.invalidateDrawBuffers(),null==t)return this.gl.bindFramebuffer(_.FRAMEBUFFER,null),void(this._state.readFramebuffer=this._state.drawFramebuffer=null);t.initializeAndBind(_.FRAMEBUFFER),this._state.readFramebuffer=t,this._state.drawFramebuffer=t}}bindFramebufferSeparate(t,e,s=!1){const i=e===_.READ_FRAMEBUFFER,a=i?this._state.readFramebuffer:this._state.drawFramebuffer;(s||a!==t)&&(null==t?this.gl.bindFramebuffer(e,null):t.initializeAndBind(e),i?this._state.readFramebuffer=t??null:(this._stateTracker.invalidateDrawBuffers(),this._state.drawFramebuffer=t??null))}blitFramebuffer(t,e,s=u.COLOR,i=d.NEAREST,a=0,r=0,n=t.width,l=t.height,h=0,f=0,o=e.width,c=e.height){this.bindFramebufferSeparate(t,_.READ_FRAMEBUFFER,!0),this.bindFramebufferSeparate(e,_.DRAW_FRAMEBUFFER,!0),this.gl.blitFramebuffer(a,r,n,l,h,f,o,c,s,i)}bindBuffer(t,e){if(t)switch(e??=t.bufferType,e){case h.ARRAY_BUFFER:this._state.vertexBuffer=N(this.gl,t,e,this._state.vertexBuffer);break;case h.ELEMENT_ARRAY_BUFFER:this._state.indexBuffer=N(this.gl,t,e,this._state.indexBuffer);break;case h.UNIFORM_BUFFER:this._state.uniformBuffer=N(this.gl,t,e,this._state.uniformBuffer);break;case h.PIXEL_PACK_BUFFER:this._state.pixelPackBuffer=N(this.gl,t,e,this._state.pixelPackBuffer);break;case h.PIXEL_UNPACK_BUFFER:this._state.pixelUnpackBuffer=N(this.gl,t,e,this._state.pixelUnpackBuffer);break;case h.COPY_READ_BUFFER:this._state.copyReadBuffer=N(this.gl,t,e,this._state.copyReadBuffer);break;case h.COPY_WRITE_BUFFER:this._state.copyWriteBuffer=N(this.gl,t,e,this._state.copyWriteBuffer);break;case h.TRANSFORM_FEEDBACK_BUFFER:this._state.transformFeedbackBuffer=N(this.gl,t,e,this._state.transformFeedbackBuffer)}}bindRenderbuffer(t){const e=this.gl;t||(e.bindRenderbuffer(e.RENDERBUFFER,null),this._state.renderbuffer=null),this._state.renderbuffer!==t&&(e.bindRenderbuffer(e.RENDERBUFFER,t.glName),this._state.renderbuffer=t)}_getBufferBinding(t,e){if(e>=this.parameters.maxUniformBufferBindings||e<0)return console.error("Uniform buffer binding point is out of range!"),null;const s=t===h.UNIFORM_BUFFER?this._state.uniformBufferBindingPoints:this._state.transformBufferBindingPoints;let i=s[e];return null==i&&(i={buffer:null,offset:0,size:0},s[e]=i),i}bindBufferBase(t,e,s){const i=this._getBufferBinding(t,e);null!=i&&(i.buffer===s&&0===i.offset&&0===i.size||(this.gl.bindBufferBase(t,e,s?s.glName:null),i.buffer=s,i.offset=0,i.size=0))}bindBufferRange(t,e,s,i,a){const r=this._getBufferBinding(t,e);null!=r&&(r.buffer===s&&r.offset===i&&r.size===a||(i%this._parameters.uniformBufferOffsetAlignment===0?(this.gl.bindBufferRange(t,e,s.glName,i,a),r.buffer=s,r.offset=i,r.size=a):console.error("Uniform buffer binding offset is not a multiple of the context offset alignment")))}bindUBO(t,e,s,a){null!=e?(i()&&(a??e.byteLength)>this._parameters.maxUniformBlockSize&&console.error("Attempting to bind more data than the maximum uniform block size"),e.initialize(),void 0!==s&&void 0!==a?this.bindBufferRange(h.UNIFORM_BUFFER,t,e.buffer,s,a):this.bindBufferBase(h.UNIFORM_BUFFER,t,e.buffer)):this.bindBufferBase(h.UNIFORM_BUFFER,t,null)}unbindUBO(t){for(let e=0,s=this._state.uniformBufferBindingPoints.length;e<s;e++){const s=this._state.uniformBufferBindingPoints[e];null!=s&&s.buffer===t.buffer&&this.bindBufferBase(h.UNIFORM_BUFFER,e,null)}}unbindBuffer(t){switch(t){case h.ARRAY_BUFFER:this._state.vertexBuffer=N(this.gl,null,t,this._state.vertexBuffer);break;case h.ELEMENT_ARRAY_BUFFER:this._state.indexBuffer=N(this.gl,null,t,this._state.indexBuffer);break;case h.UNIFORM_BUFFER:this._state.uniformBuffer=N(this.gl,null,t,this._state.uniformBuffer);break;case h.PIXEL_PACK_BUFFER:this._state.pixelPackBuffer=N(this.gl,null,t,this._state.pixelPackBuffer);break;case h.PIXEL_UNPACK_BUFFER:this._state.pixelUnpackBuffer=N(this.gl,null,t,this._state.pixelUnpackBuffer);break;case h.COPY_READ_BUFFER:this._state.copyReadBuffer=N(this.gl,null,t,this._state.copyReadBuffer);break;case h.COPY_WRITE_BUFFER:this._state.copyWriteBuffer=N(this.gl,null,t,this._state.copyWriteBuffer)}}bindVAO(t=null){null!=t?this._state.vertexArrayObject!==t&&(t.bind(),this._state.vertexArrayObject=t):this._state.vertexArrayObject&&(this._state.vertexArrayObject.unbind(),this._state.vertexArrayObject=null)}bindTransformFeedback(t){const{gl:e}=this;e.bindTransformFeedback(e.TRANSFORM_FEEDBACK,t.glName)}beginTransformFeedback(t,e){if(this._transformFeedbackRequestInfo)throw new Error("Already in a transform feedback request");const{gl:s}=this;s.bindTransformFeedback(s.TRANSFORM_FEEDBACK,t.glName),s.beginTransformFeedback(e),this._transformFeedbackRequestInfo={primitiveType:e}}endTransformFeedback(){if(!this._transformFeedbackRequestInfo)throw new Error("Not in a transform feedback request");const{gl:t}=this;t.endTransformFeedback(),t.bindTransformFeedback(t.TRANSFORM_FEEDBACK,null),this._transformFeedbackRequestInfo=null}async clientWaitAsync(t=s(10)){const{gl:i}=this,a=i.fenceSync(b.SYNC_GPU_COMMANDS_COMPLETE,0);if(!a)throw new Error("Client wait failed, could not create sync object");let r;this.instanceCounter.increment(F.Sync,a),i.flush();do{await e(t),r=i.clientWaitSync(a,0,0)}while(r===g.TIMEOUT_EXPIRED);if(this.instanceCounter.decrement(F.Sync,a),i.deleteSync(a),r===g.WAIT_FAILED)throw new Error("Client wait failed")}getBoundFramebufferObject(t=_.FRAMEBUFFER){return t===_.READ_FRAMEBUFFER?this._state.readFramebuffer:this._state.drawFramebuffer}temporaryBindFramebufferObject(t,e){const s=this.getBoundFramebufferObject();try{t&&this.bindFramebuffer(t),e()}finally{this.bindFramebuffer(s)}}getBoundVAO(){return this._state.vertexArrayObject}resetState(){this.useProgram(null),this.bindVAO(null),this.bindFramebuffer(null,!0),this.unbindBuffer(h.ARRAY_BUFFER),this.unbindBuffer(h.ELEMENT_ARRAY_BUFFER),this.unbindBuffer(h.UNIFORM_BUFFER),this._state.uniformBufferBindingPoints.length=0,this.unbindBuffer(h.PIXEL_PACK_BUFFER),this.unbindBuffer(h.PIXEL_UNPACK_BUFFER),this.unbindBuffer(h.COPY_READ_BUFFER),this.unbindBuffer(h.COPY_WRITE_BUFFER);for(let t=0;t<this.parameters.maxTextureImageUnits;++t)this.bindTexture(null,t);this.setBlendingEnabled(!1),this.setBlendFunction(B.ONE,B.ZERO),this.setBlendEquation(p.ADD),this.setBlendColor(0,0,0,0),this.setFaceCullingEnabled(!1),this.setCullFace(f.BACK),this.setFrontFace(m.CCW),this.setPolygonOffsetFillEnabled(!1),this.setPolygonOffset(0,0),this.setScissorTestEnabled(!1),this.setScissorRect(0,0,this.gl.canvas.width,this.gl.canvas.height),this.setDepthTestEnabled(!1),this.setDepthFunction(E.LESS),this.setDepthRange(0,1),this.setStencilTestEnabled(!1),this.setStencilFunction(E.ALWAYS,0,0),this.setStencilOp(R.KEEP,R.KEEP,R.KEEP),this.setClearColor(0,0,0,0),this.setClearDepth(1),this.setClearStencil(0),this.setColorMask(!0,!0,!0,!0),this.setStencilWriteMask(4294967295),this.setDepthWriteEnabled(!0),this.setDrawBuffers([n.BACK]),this.setViewport(0,0,this.gl.canvas.width,this.gl.canvas.height)}enforceState(){const{gl:t}=this;t.bindVertexArray(null);for(let s=0;s<this.parameters.maxVertexAttributes;s++)t.disableVertexAttribArray(s);this._state.vertexBuffer?t.bindBuffer(this._state.vertexBuffer.bufferType,this._state.vertexBuffer.glName):t.bindBuffer(h.ARRAY_BUFFER,null),this._state.indexBuffer?t.bindBuffer(this._state.indexBuffer.bufferType,this._state.indexBuffer.glName):t.bindBuffer(h.ELEMENT_ARRAY_BUFFER,null),this._state.uniformBuffer?t.bindBuffer(this._state.uniformBuffer.bufferType,this._state.uniformBuffer.glName):t.bindBuffer(h.UNIFORM_BUFFER,null);for(let s=0;s<this._parameters.maxUniformBufferBindings;s++){const e=this._state.uniformBufferBindingPoints[s];if(null!=e){const{buffer:i,offset:a,size:r}=e;null!==i?0===a&&0===r?t.bindBufferBase(h.UNIFORM_BUFFER,s,i.glName):t.bindBufferRange(h.UNIFORM_BUFFER,s,i.glName,a,r):t.bindBufferBase(h.UNIFORM_BUFFER,s,null)}}if(this._state.pixelPackBuffer?t.bindBuffer(this._state.pixelPackBuffer.bufferType,this._state.pixelPackBuffer.glName):t.bindBuffer(h.PIXEL_PACK_BUFFER,null),this._state.pixelUnpackBuffer?t.bindBuffer(this._state.pixelUnpackBuffer.bufferType,this._state.pixelUnpackBuffer.glName):t.bindBuffer(h.PIXEL_UNPACK_BUFFER,null),this._state.copyReadBuffer?t.bindBuffer(this._state.copyReadBuffer.bufferType,this._state.copyReadBuffer.glName):t.bindBuffer(h.COPY_READ_BUFFER,null),this._state.copyWriteBuffer?t.bindBuffer(this._state.copyWriteBuffer.bufferType,this._state.copyWriteBuffer.glName):t.bindBuffer(h.COPY_WRITE_BUFFER,null),t.bindFramebuffer(_.READ_FRAMEBUFFER,null),t.readBuffer(t.BACK),this._state.readFramebuffer&&(t.bindFramebuffer(_.READ_FRAMEBUFFER,this._state.readFramebuffer.glName),t.readBuffer(l)),t.bindFramebuffer(_.DRAW_FRAMEBUFFER,this._state.drawFramebuffer?.glName??null),null===this._state.drawFramebuffer){const e=this._state.drawBuffers.defaultFramebuffer;t.drawBuffers(e??[n.BACK])}else{const e=this._state.drawBuffers.fbos.get(this._state.drawFramebuffer);t.drawBuffers(e??[l])}if(this._state.vertexArrayObject){const t=this._state.vertexArrayObject;this._state.vertexArrayObject&&(this._state.vertexArrayObject.unbind(),this._state.vertexArrayObject=null),this.bindVAO(t)}t.useProgram(this._state.program?.glName??null),t.blendColor(this._state.blendColor.r,this._state.blendColor.g,this._state.blendColor.b,this._state.blendColor.a),t.bindRenderbuffer(t.RENDERBUFFER,this._state.renderbuffer?.glName??null),!0===this._state.blend?t.enable(this.gl.BLEND):t.disable(this.gl.BLEND),t.blendEquationSeparate(this._state.blendEquation.mode,this._state.blendEquation.modeAlpha),t.blendFuncSeparate(this._state.blendFunction.srcRGB,this._state.blendFunction.dstRGB,this._state.blendFunction.srcAlpha,this._state.blendFunction.dstAlpha),t.clearColor(this._state.clearColor.r,this._state.clearColor.g,this._state.clearColor.b,this._state.clearColor.a),t.clearDepth(this._state.clearDepth),t.clearStencil(this._state.clearStencil),t.colorMask(this._state.colorMask.r,this._state.colorMask.g,this._state.colorMask.b,this._state.colorMask.a),t.cullFace(this._state.cullFace),t.depthFunc(this._state.depthFunction),t.depthRange(this._state.depthRange.zNear,this._state.depthRange.zFar),!0===this._state.depthTest?t.enable(t.DEPTH_TEST):t.disable(t.DEPTH_TEST),t.depthMask(this._state.depthWrite),t.frontFace(this._state.frontFace),t.lineWidth(1),!0===this._state.faceCulling?t.enable(t.CULL_FACE):t.disable(t.CULL_FACE),t.polygonOffset(this._state.polygonOffset[0],this._state.polygonOffset[1]),!0===this._state.polygonOffsetFill?t.enable(t.POLYGON_OFFSET_FILL):t.disable(t.POLYGON_OFFSET_FILL),t.scissor(this._state.scissorRect.x,this._state.scissorRect.y,this._state.scissorRect.width,this._state.scissorRect.height),!0===this._state.scissorTest?t.enable(t.SCISSOR_TEST):t.disable(t.SCISSOR_TEST),t.stencilFunc(this._state.stencilFunction.func,this._state.stencilFunction.ref,this._state.stencilFunction.mask),t.stencilOpSeparate(this._state.stencilOperation.face,this._state.stencilOperation.fail,this._state.stencilOperation.zFail,this._state.stencilOperation.zPass),!0===this._state.stencilTest?t.enable(t.STENCIL_TEST):t.disable(t.STENCIL_TEST),t.stencilMask(this._state.stencilWriteMask);for(let s=0;s<this.parameters.maxTextureImageUnits;s++){t.activeTexture(o+s),t.bindTexture(T.TEXTURE_2D,null),t.bindTexture(T.TEXTURE_CUBE_MAP,null),t.bindTexture(T.TEXTURE_3D,null),t.bindTexture(T.TEXTURE_2D_ARRAY,null);const e=this._state.textureUnitMap[s];null!=e&&t.bindTexture(e.descriptor.target,e.glName)}t.activeTexture(o+this._state.activeTexture);const e=this._state.viewport;t.viewport(e.x,e.y,e.width,e.height),this.resetInfo()}};function N(t,e,s,i){return e?i!==e&&t.bindBuffer(s,e.glName):t.bindBuffer(s,null),e}function D(t,e){switch(t){case A.POINTS:return 2*e;case A.TRIANGLES:return e/3;case A.TRIANGLE_STRIP:case A.TRIANGLE_FAN:return e-2;default:return 0}}export{v as RenderingContext};
5
+ import has from"../../core/has.js";import{disposeMaybe as t}from"../../core/maybe.js";import{after as e}from"../../core/promiseUtils.js";import{Milliseconds as s}from"../../core/time.js";import{webglDebugEnabled as i,checkWebGLError as a}from"./checkWebGLError.js";import{ContextState as r}from"./ContextState.js";import{SpecialDrawBuffers as n,ColorAttachment0 as l,BufferType as h,Face as f,baseTextureUnit as o,FramebufferBit as u,BufferContent as c,FramebufferTarget as _,TextureSamplingMode as d,SyncCondition as b,ResourceType as F,ClientWaitSyncStatus as g,BlendFactor as B,BlendOperation as p,CullMode as m,CompareFunction as E,StencilOperation as R,TextureType as T,PrimitiveType as A}from"./enums.js";import{InstanceCounter as O}from"./InstanceCounter.js";import{Parameters as C}from"./Parameters.js";import{ProgramCache as x}from"./ProgramCache.js";import{StateTracker as U}from"./renderState.js";import{Texture as k}from"./Texture.js";import{getErrorString as w}from"./Util.js";import{WebGLDriverTest as S}from"./WebGLDriverTest.js";import{Capabilities as y}from"./capabilities/Capabilities.js";let v=class{constructor(t,e){this.gl=t,this.instanceCounter=new O,this.programCache=new x(this),this._transformFeedbackRequestInfo=null,this._state=new r,this._numOfDrawCalls=0,this._numOfTriangles=0,this.configure(e)}configure(e){this._capabilities=new y(this.gl,e),this._parameters=new C(this.gl,this._capabilities,e),k.TEXTURE_UNIT_FOR_UPDATES=this._parameters.maxTextureImageUnits-1;const s=this.gl.getParameter(this.gl.VIEWPORT);this._state=new r,this._state.viewport={x:s[0],y:s[1],width:s[2],height:s[3]},this._stateTracker=new U({setBlending:t=>{if(t){this.setBlendingEnabled(!0),this.setBlendEquationSeparate(t.opRgb,t.opAlpha),this.setBlendFunctionSeparate(t.srcRgb,t.dstRgb,t.srcAlpha,t.dstAlpha);const e=t.color;this.setBlendColor(e.r,e.g,e.b,e.a)}else this.setBlendingEnabled(!1)},setCulling:t=>{t?(this.setFaceCullingEnabled(!0),this.setCullFace(t.face),this.setFrontFace(t.mode)):this.setFaceCullingEnabled(!1)},setPolygonOffset:t=>{t?(this.setPolygonOffsetFillEnabled(!0),this.setPolygonOffset(t.factor,t.units)):this.setPolygonOffsetFillEnabled(!1)},setDepthTest:t=>{t?(this.setDepthTestEnabled(!0),this.setDepthFunction(t.func)):this.setDepthTestEnabled(!1)},setStencilTest:t=>{if(t){this.setStencilTestEnabled(!0);const e=t.function;this.setStencilFunction(e.func,e.ref,e.mask);const s=t.operation;this.setStencilOp(s.fail,s.zFail,s.zPass)}else this.setStencilTestEnabled(!1)},setDepthWrite:t=>{t?(this.setDepthWriteEnabled(!0),this.setDepthRange(t.zNear,t.zFar)):this.setDepthWriteEnabled(!1)},setColorWrite:t=>{t?this.setColorMask(t.r,t.g,t.b,t.a):this.setColorMask(!1,!1,!1,!1)},setStencilWrite:t=>{t?this.setStencilWriteMask(t.mask):this.setStencilWriteMask(0)},setDrawBuffers:t=>{if(t)this.setDrawBuffers(t.buffers);else{const{drawFramebuffer:t}=this._state;null===t?this.setDrawBuffers([n.BACK]):0===t.colorAttachments.length?this.setDrawBuffers([n.NONE]):this.setDrawBuffers([l])}}}),this.enforceState(),t(this._driverTest),this._driverTest=new S(this)}updateOptions(t){this._parameters=new C(this.gl,this._capabilities,t)}dispose(){t(this._driverTest),this.programCache.dispose(),this.bindVAO(null),this.unbindBuffer(h.ARRAY_BUFFER),this.unbindBuffer(h.ELEMENT_ARRAY_BUFFER),this.unbindBuffer(h.UNIFORM_BUFFER),this._state.uniformBufferBindingPoints.length=0,this.unbindBuffer(h.PIXEL_PACK_BUFFER),this.unbindBuffer(h.PIXEL_UNPACK_BUFFER),this.unbindBuffer(h.COPY_READ_BUFFER),this.unbindBuffer(h.COPY_WRITE_BUFFER),this._state.textureUnitMap.length=0,i()&&console.log(this.instanceCounter.resourceInformation)}get driverTest(){return this._driverTest}get contextAttributes(){return this.gl.getContextAttributes()}get parameters(){return this._parameters}setPipelineState(t){this._stateTracker.setPipeline(t)}setBlendingEnabled(t){this._state.blend!==t&&(!0===t?this.gl.enable(this.gl.BLEND):this.gl.disable(this.gl.BLEND),this._state.blend=t,this._stateTracker.invalidateBlending())}externalProgramUpdate(){this._state.program?.stop(),this._state.program=null}externalTextureUnitUpdate(t,e){for(let s=0;s<t.length;++s)this._state.textureUnitMap[t[s]]=null;e>=0&&(this._state.activeTexture=e)}externalVertexArrayObjectUpdate(){this.gl.bindVertexArray(null),this._state.vertexArrayObject=null,this._state.vertexBuffer=null,this._state.indexBuffer=null}externalVertexBufferUpdate(){this._state.vertexBuffer=null}externalIndexBufferUpdate(){this._state.indexBuffer=null}setBlendColor(t,e,s,i){t===this._state.blendColor.r&&e===this._state.blendColor.g&&s===this._state.blendColor.b&&i===this._state.blendColor.a||(this.gl.blendColor(t,e,s,i),this._state.blendColor.r=t,this._state.blendColor.g=e,this._state.blendColor.b=s,this._state.blendColor.a=i,this._stateTracker.invalidateBlending())}setBlendFunction(t,e){t===this._state.blendFunction.srcRGB&&e===this._state.blendFunction.dstRGB||(this.gl.blendFunc(t,e),this._state.blendFunction.srcRGB=t,this._state.blendFunction.srcAlpha=t,this._state.blendFunction.dstRGB=e,this._state.blendFunction.dstAlpha=e,this._stateTracker.invalidateBlending())}setBlendFunctionSeparate(t,e,s,i){this._state.blendFunction.srcRGB===t&&this._state.blendFunction.srcAlpha===s&&this._state.blendFunction.dstRGB===e&&this._state.blendFunction.dstAlpha===i||(this.gl.blendFuncSeparate(t,e,s,i),this._state.blendFunction.srcRGB=t,this._state.blendFunction.srcAlpha=s,this._state.blendFunction.dstRGB=e,this._state.blendFunction.dstAlpha=i,this._stateTracker.invalidateBlending())}setBlendEquation(t){this._state.blendEquation.mode!==t&&(this.gl.blendEquation(t),this._state.blendEquation.mode=t,this._state.blendEquation.modeAlpha=t,this._stateTracker.invalidateBlending())}setBlendEquationSeparate(t,e){this._state.blendEquation.mode===t&&this._state.blendEquation.modeAlpha===e||(this.gl.blendEquationSeparate(t,e),this._state.blendEquation.mode=t,this._state.blendEquation.modeAlpha=e,this._stateTracker.invalidateBlending())}setColorMask(t,e,s,i){this._state.colorMask.r===t&&this._state.colorMask.g===e&&this._state.colorMask.b===s&&this._state.colorMask.a===i||(this.gl.colorMask(t,e,s,i),this._state.colorMask.r=t,this._state.colorMask.g=e,this._state.colorMask.b=s,this._state.colorMask.a=i,this._stateTracker.invalidateColorWrite())}setClearColor(t,e,s,i){this._state.clearColor.r===t&&this._state.clearColor.g===e&&this._state.clearColor.b===s&&this._state.clearColor.a===i||(this.gl.clearColor(t,e,s,i),this._state.clearColor.r=t,this._state.clearColor.g=e,this._state.clearColor.b=s,this._state.clearColor.a=i)}setFaceCullingEnabled(t){this._state.faceCulling!==t&&(!0===t?this.gl.enable(this.gl.CULL_FACE):this.gl.disable(this.gl.CULL_FACE),this._state.faceCulling=t,this._stateTracker.invalidateCulling())}setPolygonOffsetFillEnabled(t){this._state.polygonOffsetFill!==t&&(!0===t?this.gl.enable(this.gl.POLYGON_OFFSET_FILL):this.gl.disable(this.gl.POLYGON_OFFSET_FILL),this._state.polygonOffsetFill=t,this._stateTracker.invalidatePolygonOffset())}setPolygonOffset(t,e){this._state.polygonOffset[0]===t&&this._state.polygonOffset[1]===e||(this._state.polygonOffset[0]=t,this._state.polygonOffset[1]=e,this.gl.polygonOffset(t,e),this._stateTracker.invalidatePolygonOffset())}setCullFace(t){this._state.cullFace!==t&&(this.gl.cullFace(t),this._state.cullFace=t,this._stateTracker.invalidateCulling())}setFrontFace(t){this._state.frontFace!==t&&(this.gl.frontFace(t),this._state.frontFace=t,this._stateTracker.invalidateCulling())}setScissorTestEnabled(t){this._state.scissorTest!==t&&(!0===t?this.gl.enable(this.gl.SCISSOR_TEST):this.gl.disable(this.gl.SCISSOR_TEST),this._state.scissorTest=t)}setScissorRect(t,e,s,i){this._state.scissorRect.x===t&&this._state.scissorRect.y===e&&this._state.scissorRect.width===s&&this._state.scissorRect.height===i||(this.gl.scissor(t,e,s,i),this._state.scissorRect.x=t,this._state.scissorRect.y=e,this._state.scissorRect.width=s,this._state.scissorRect.height=i)}setDepthTestEnabled(t){this._state.depthTest!==t&&(!0===t?this.gl.enable(this.gl.DEPTH_TEST):this.gl.disable(this.gl.DEPTH_TEST),this._state.depthTest=t,this._stateTracker.invalidateDepthTest())}setClearDepth(t){this._state.clearDepth!==t&&(this.gl.clearDepth(t),this._state.clearDepth=t)}setDepthFunction(t){this._state.depthFunction!==t&&(this.gl.depthFunc(t),this._state.depthFunction=t,this._stateTracker.invalidateDepthTest())}setDepthWriteEnabled(t){this._state.depthWrite!==t&&(this.gl.depthMask(t),this._state.depthWrite=t,this._stateTracker.invalidateDepthWrite())}setDepthRange(t,e){this._state.depthRange.zNear===t&&this._state.depthRange.zFar===e||(this.gl.depthRange(t,e),this._state.depthRange.zNear=t,this._state.depthRange.zFar=e,this._stateTracker.invalidateDepthWrite())}setStencilTestEnabled(t){this._state.stencilTest!==t&&(!0===t?this.gl.enable(this.gl.STENCIL_TEST):this.gl.disable(this.gl.STENCIL_TEST),this._state.stencilTest=t,this._stateTracker.invalidateStencilTest())}setClearStencil(t){t!==this._state.clearStencil&&(this.gl.clearStencil(t),this._state.clearStencil=t)}setStencilFunction(t,e,s){this._state.stencilFunction.func===t&&this._state.stencilFunction.ref===e&&this._state.stencilFunction.mask===s||(this.gl.stencilFunc(t,e,s),this._state.stencilFunction.face=f.FRONT_AND_BACK,this._state.stencilFunction.func=t,this._state.stencilFunction.ref=e,this._state.stencilFunction.mask=s,this._stateTracker.invalidateStencilTest())}setStencilFunctionSeparate(t,e,s,i){this._state.stencilFunction.face===t&&this._state.stencilFunction.func===e&&this._state.stencilFunction.ref===s&&this._state.stencilFunction.mask===i||(this.gl.stencilFuncSeparate(t,e,s,i),this._state.stencilFunction.face=t,this._state.stencilFunction.func=e,this._state.stencilFunction.ref=s,this._state.stencilFunction.mask=i,this._stateTracker.invalidateStencilTest())}setStencilWriteMask(t){this._state.stencilWriteMask!==t&&(this.gl.stencilMask(t),this._state.stencilWriteMask=t,this._stateTracker.invalidateStencilWrite())}setStencilOp(t,e,s){this._state.stencilOperation.face===f.FRONT_AND_BACK&&this._state.stencilOperation.fail===t&&this._state.stencilOperation.zFail===e&&this._state.stencilOperation.zPass===s||(this.gl.stencilOp(t,e,s),this._state.stencilOperation.face=f.FRONT_AND_BACK,this._state.stencilOperation.fail=t,this._state.stencilOperation.zFail=e,this._state.stencilOperation.zPass=s,this._stateTracker.invalidateStencilTest())}setStencilOpSeparate(t,e,s,i){this._state.stencilOperation.face===t&&this._state.stencilOperation.fail===e&&this._state.stencilOperation.zFail===s&&this._state.stencilOperation.zPass===i||(this.gl.stencilOpSeparate(t,e,s,i),this._state.stencilOperation.face=t,this._state.stencilOperation.fail=e,this._state.stencilOperation.zFail=s,this._state.stencilOperation.zPass=i,this._stateTracker.invalidateStencilTest())}setActiveTexture(t,e=!1){const s=this._state.activeTexture;return t>=0&&(e||t!==this._state.activeTexture)&&(this.gl.activeTexture(o+t),this._state.activeTexture=t),s}setDrawBuffers(t){const{drawFramebuffer:e}=this._state,s=null===e,i=s?this._state.drawBuffers.defaultFramebuffer:this._state.drawBuffers.fbos.get(e);if(i?.length!==t.length||!i.every(((e,s)=>e===t[s])))if(t.length>this.parameters.maxDrawBuffers)console.error("Setting more active draw buffers than GL.MAX_DRAW_BUFFERS allows.");else{if(s){if(t.length>1)return void console.error("The default framebuffer can only have one active draw buffer.");if(t[0]!==n.BACK&&t[0]!==n.NONE)return void console.error("The default framebuffer can only use the constants GL.BACK or GL.NONE as draw buffers.")}s||!t.includes(n.BACK)?(this.gl.drawBuffers(t),s?this._state.drawBuffers.defaultFramebuffer=t:this._state.drawBuffers.fbos.set(e,t),this._stateTracker.invalidateDrawBuffers()):console.error("A framebuffer object can only use the constants GL.COLOR_ATTACHMENTi or GL.NONE as draw buffers.")}}clear(t,e=255){if(t){if(t&u.COLOR){const t=this._state.drawFramebuffer?.colorAttachments;t&&this.setDrawBuffers(t),this.setColorMask(!0,!0,!0,!0)}t&u.DEPTH&&this.setDepthWriteEnabled(!0),t&u.STENCIL&&this.setStencilWriteMask(e),this.gl.clear(t)}}clearFramebuffer(t,e=!1,s=!1){let i=0;if(t){const e=1e-13,s=Math.max(e,t[3]);this.setClearColor(t[0],t[1],t[2],s),i|=u.COLOR}e&&(i|=u.DEPTH),!1===s?s=0:(!0===s&&(s=255),i|=u.STENCIL),i&&this.clear(i,s)}clearBuffer(t,e,s=c.COLOR,i=void 0){this.gl.clearBufferfv(s,t,e,i)}clearBufferInteger(t,e,s=c.COLOR,i=void 0){this.gl.clearBufferiv(s,t,e,i)}clearBufferUnsignedInteger(t,e,s=c.COLOR,i=void 0){this.gl.clearBufferuiv(s,t,e,i)}drawArrays(t,e,s){if(this._transformFeedbackRequestInfo){if(t!==this._transformFeedbackRequestInfo.primitiveType)throw new Error("DrawArrays called during transform feedback, but primitiveType does not match that of the current transform feedback request");if(null==this._state.program?.hasTransformFeedbackVaryings)throw new Error("DrawArrays called during transform feedback, but the shader program was not linked with a transform feedback varying")}if(i()&&(this._numOfDrawCalls++,this._numOfTriangles+=D(t,s),has("enable-feature:webgl-debug:textureReadWrite"))){const t=this._state.textureUnitMap;for(let e=0;e<t.length;e++){const s=t[e];if(null!=s&&s===this._state.drawFramebuffer?.colorTexture)throw new Error(`Detected readWrite. Texture already bound at index ${e}`)}}this.gl.drawArrays(t,e,s),a(this.gl)}drawArraysInstanced(t,e,s,i){this.gl.drawArraysInstanced(t,e,s,i),a(this.gl)}drawElements(t,e,s,a){if(this._transformFeedbackRequestInfo)throw new Error("Cannot called drawElements during a transform feedback request");if(i()&&(this._numOfDrawCalls++,this._numOfTriangles+=D(t,e)),this.gl.drawElements(t,e,s,a),i()){const i=w(this);if(i){const r=this.getBoundVAO(),n=r?.indexBuffer,l=r?.vertexBuffers,h={indexBuffer:n,vertexBuffers:l},f={mode:t,count:e,type:s,offset:a},o=n?.size??0,u=a+e,c=o<u?`. Buffer is too small. Attempted to draw index ${u} of ${o}`:"";console.error(`drawElements: ${i}${c}`,{args:f,vao:h})}}}drawElementsInstanced(t,e,s,i,r){this.gl.drawElementsInstanced(t,e,s,i,r),a(this.gl)}logInfo(){i()&&console.log(`DrawCalls: ${this._numOfDrawCalls}, Triangles: ${this._numOfTriangles}`)}resetInfo(){i()&&(this._numOfDrawCalls=0,this._numOfTriangles=0)}get capabilities(){return this._capabilities}setViewport(t,e,s,i){s=Math.max(Math.round(s),1),i=Math.max(Math.round(i),1);const a=this._state.viewport;a.x===t&&a.y===e&&a.width===s&&a.height===i||(a.x=t,a.y=e,a.width=s,a.height=i,this.gl.viewport(t,e,s,i))}setViewport4fv(t){this.setViewport(t[0],t[1],t[2],t[3])}restoreViewport({x:t,y:e,width:s,height:i}){this.setViewport(t,e,s,i)}getViewport(){const t=this._state.viewport;return{x:t.x,y:t.y,width:t.width,height:t.height}}useProgram(t){this._state.program!==t&&(this._state.program?.stop(),this._state.program=t,this.gl.useProgram(t?.glName??null))}bindTexture(t,e,s=!1){(e>=this.parameters.maxTextureImageUnits||e<0)&&console.error("Input texture unit is out of range of available units!");const i=this._state.textureUnitMap[e];return null==t?.glName?(null!=i&&(this.setActiveTexture(e,s),this.gl.bindTexture(i.descriptor.target,null)),this._state.textureUnitMap[e]=null,i):s||i!==t?(this.setActiveTexture(e,s),this.gl.bindTexture(t.descriptor.target,t.glName),t.applyChanges(),this._state.textureUnitMap[e]=t,i):(t.isDirty&&(this.setActiveTexture(e,s),t.applyChanges()),i)}unbindTexture(t){if(null!=t)for(let e=0;e<this.parameters.maxTextureImageUnits;e++)this._state.textureUnitMap[e]===t&&(this.bindTexture(null,e),this._state.textureUnitMap[e]=null)}bindFramebuffer(t,e=!1){if(e||this._state.readFramebuffer!==t||this._state.drawFramebuffer!==t){if(this._stateTracker.invalidateDrawBuffers(),null==t)return this.gl.bindFramebuffer(_.FRAMEBUFFER,null),void(this._state.readFramebuffer=this._state.drawFramebuffer=null);t.initializeAndBind(_.FRAMEBUFFER),this._state.readFramebuffer=t,this._state.drawFramebuffer=t}}bindFramebufferSeparate(t,e,s=!1){const i=e===_.READ_FRAMEBUFFER,a=i?this._state.readFramebuffer:this._state.drawFramebuffer;(s||a!==t)&&(null==t?this.gl.bindFramebuffer(e,null):t.initializeAndBind(e),i?this._state.readFramebuffer=t??null:(this._stateTracker.invalidateDrawBuffers(),this._state.drawFramebuffer=t??null))}blitFramebuffer(t,e,s=u.COLOR,i=d.NEAREST,a=0,r=0,n=t.width,l=t.height,h=0,f=0,o=e.width,c=e.height){this.bindFramebufferSeparate(t,_.READ_FRAMEBUFFER,!0),this.bindFramebufferSeparate(e,_.DRAW_FRAMEBUFFER,!0),this.gl.blitFramebuffer(a,r,n,l,h,f,o,c,s,i)}bindBuffer(t,e){if(t)switch(e??=t.bufferType,e){case h.ARRAY_BUFFER:this._state.vertexBuffer=N(this.gl,t,e,this._state.vertexBuffer);break;case h.ELEMENT_ARRAY_BUFFER:this._state.indexBuffer=N(this.gl,t,e,this._state.indexBuffer);break;case h.UNIFORM_BUFFER:this._state.uniformBuffer=N(this.gl,t,e,this._state.uniformBuffer);break;case h.PIXEL_PACK_BUFFER:this._state.pixelPackBuffer=N(this.gl,t,e,this._state.pixelPackBuffer);break;case h.PIXEL_UNPACK_BUFFER:this._state.pixelUnpackBuffer=N(this.gl,t,e,this._state.pixelUnpackBuffer);break;case h.COPY_READ_BUFFER:this._state.copyReadBuffer=N(this.gl,t,e,this._state.copyReadBuffer);break;case h.COPY_WRITE_BUFFER:this._state.copyWriteBuffer=N(this.gl,t,e,this._state.copyWriteBuffer);break;case h.TRANSFORM_FEEDBACK_BUFFER:this._state.transformFeedbackBuffer=N(this.gl,t,e,this._state.transformFeedbackBuffer)}}bindRenderbuffer(t){const e=this.gl;t||(e.bindRenderbuffer(e.RENDERBUFFER,null),this._state.renderbuffer=null),this._state.renderbuffer!==t&&(e.bindRenderbuffer(e.RENDERBUFFER,t.glName),this._state.renderbuffer=t)}_getBufferBinding(t,e){if(e>=this.parameters.maxUniformBufferBindings||e<0)return console.error("Uniform buffer binding point is out of range!"),null;const s=t===h.UNIFORM_BUFFER?this._state.uniformBufferBindingPoints:this._state.transformBufferBindingPoints;let i=s[e];return null==i&&(i={buffer:null,offset:0,size:0},s[e]=i),i}bindBufferBase(t,e,s){const i=this._getBufferBinding(t,e);null!=i&&(i.buffer===s&&0===i.offset&&0===i.size||(this.gl.bindBufferBase(t,e,s?s.glName:null),i.buffer=s,i.offset=0,i.size=0))}bindBufferRange(t,e,s,i,a){const r=this._getBufferBinding(t,e);null!=r&&(r.buffer===s&&r.offset===i&&r.size===a||(i%this._parameters.uniformBufferOffsetAlignment===0?(this.gl.bindBufferRange(t,e,s.glName,i,a),r.buffer=s,r.offset=i,r.size=a):console.error("Uniform buffer binding offset is not a multiple of the context offset alignment")))}bindUBO(t,e,s,a){null!=e?(i()&&(a??e.byteLength)>this._parameters.maxUniformBlockSize&&console.error("Attempting to bind more data than the maximum uniform block size"),e.initialize(),void 0!==s&&void 0!==a?this.bindBufferRange(h.UNIFORM_BUFFER,t,e.buffer,s,a):this.bindBufferBase(h.UNIFORM_BUFFER,t,e.buffer)):this.bindBufferBase(h.UNIFORM_BUFFER,t,null)}unbindUBO(t){for(let e=0,s=this._state.uniformBufferBindingPoints.length;e<s;e++){const s=this._state.uniformBufferBindingPoints[e];null!=s&&s.buffer===t.buffer&&this.bindBufferBase(h.UNIFORM_BUFFER,e,null)}}unbindBuffer(t){switch(t){case h.ARRAY_BUFFER:this._state.vertexBuffer=N(this.gl,null,t,this._state.vertexBuffer);break;case h.ELEMENT_ARRAY_BUFFER:this._state.indexBuffer=N(this.gl,null,t,this._state.indexBuffer);break;case h.UNIFORM_BUFFER:this._state.uniformBuffer=N(this.gl,null,t,this._state.uniformBuffer);break;case h.PIXEL_PACK_BUFFER:this._state.pixelPackBuffer=N(this.gl,null,t,this._state.pixelPackBuffer);break;case h.PIXEL_UNPACK_BUFFER:this._state.pixelUnpackBuffer=N(this.gl,null,t,this._state.pixelUnpackBuffer);break;case h.COPY_READ_BUFFER:this._state.copyReadBuffer=N(this.gl,null,t,this._state.copyReadBuffer);break;case h.COPY_WRITE_BUFFER:this._state.copyWriteBuffer=N(this.gl,null,t,this._state.copyWriteBuffer)}}bindVAO(t=null){null!=t?this._state.vertexArrayObject!==t&&(t.bind(),this._state.vertexArrayObject=t):this._state.vertexArrayObject&&(this._state.vertexArrayObject.unbind(),this._state.vertexArrayObject=null)}bindTransformFeedback(t){const{gl:e}=this;e.bindTransformFeedback(e.TRANSFORM_FEEDBACK,t.glName)}beginTransformFeedback(t,e){if(this._transformFeedbackRequestInfo)throw new Error("Already in a transform feedback request");const{gl:s}=this;s.bindTransformFeedback(s.TRANSFORM_FEEDBACK,t.glName),s.beginTransformFeedback(e),this._transformFeedbackRequestInfo={primitiveType:e}}endTransformFeedback(){if(!this._transformFeedbackRequestInfo)throw new Error("Not in a transform feedback request");const{gl:t}=this;t.endTransformFeedback(),t.bindTransformFeedback(t.TRANSFORM_FEEDBACK,null),this._transformFeedbackRequestInfo=null}async clientWaitAsync(t=s(10)){const{gl:i}=this,a=i.fenceSync(b.SYNC_GPU_COMMANDS_COMPLETE,0);if(!a)throw new Error("Client wait failed, could not create sync object");let r;this.instanceCounter.increment(F.Sync,a),i.flush();do{await e(t),r=i.clientWaitSync(a,0,0)}while(r===g.TIMEOUT_EXPIRED);if(this.instanceCounter.decrement(F.Sync,a),i.deleteSync(a),r===g.WAIT_FAILED)throw new Error("Client wait failed")}getBoundFramebufferObject(t=_.FRAMEBUFFER){return t===_.READ_FRAMEBUFFER?this._state.readFramebuffer:this._state.drawFramebuffer}temporaryBindFramebufferObject(t,e,s=!1){const i=this.getBoundFramebufferObject();try{t&&this.bindFramebuffer(t,s),e()}finally{this.bindFramebuffer(i,s)}}getBoundVAO(){return this._state.vertexArrayObject}resetState(){this.useProgram(null),this.bindVAO(null),this.bindFramebuffer(null,!0),this.unbindBuffer(h.ARRAY_BUFFER),this.unbindBuffer(h.ELEMENT_ARRAY_BUFFER),this.unbindBuffer(h.UNIFORM_BUFFER),this._state.uniformBufferBindingPoints.length=0,this.unbindBuffer(h.PIXEL_PACK_BUFFER),this.unbindBuffer(h.PIXEL_UNPACK_BUFFER),this.unbindBuffer(h.COPY_READ_BUFFER),this.unbindBuffer(h.COPY_WRITE_BUFFER);for(let t=0;t<this.parameters.maxTextureImageUnits;++t)this.bindTexture(null,t);this.setBlendingEnabled(!1),this.setBlendFunction(B.ONE,B.ZERO),this.setBlendEquation(p.ADD),this.setBlendColor(0,0,0,0),this.setFaceCullingEnabled(!1),this.setCullFace(f.BACK),this.setFrontFace(m.CCW),this.setPolygonOffsetFillEnabled(!1),this.setPolygonOffset(0,0),this.setScissorTestEnabled(!1),this.setScissorRect(0,0,this.gl.canvas.width,this.gl.canvas.height),this.setDepthTestEnabled(!1),this.setDepthFunction(E.LESS),this.setDepthRange(0,1),this.setStencilTestEnabled(!1),this.setStencilFunction(E.ALWAYS,0,0),this.setStencilOp(R.KEEP,R.KEEP,R.KEEP),this.setClearColor(0,0,0,0),this.setClearDepth(1),this.setClearStencil(0),this.setColorMask(!0,!0,!0,!0),this.setStencilWriteMask(4294967295),this.setDepthWriteEnabled(!0),this.setDrawBuffers([n.BACK]),this.setViewport(0,0,this.gl.canvas.width,this.gl.canvas.height)}enforceState(){const{gl:t}=this;t.bindVertexArray(null);for(let s=0;s<this.parameters.maxVertexAttributes;s++)t.disableVertexAttribArray(s);this._state.vertexBuffer?t.bindBuffer(this._state.vertexBuffer.bufferType,this._state.vertexBuffer.glName):t.bindBuffer(h.ARRAY_BUFFER,null),this._state.indexBuffer?t.bindBuffer(this._state.indexBuffer.bufferType,this._state.indexBuffer.glName):t.bindBuffer(h.ELEMENT_ARRAY_BUFFER,null),this._state.uniformBuffer?t.bindBuffer(this._state.uniformBuffer.bufferType,this._state.uniformBuffer.glName):t.bindBuffer(h.UNIFORM_BUFFER,null);for(let s=0;s<this._parameters.maxUniformBufferBindings;s++){const e=this._state.uniformBufferBindingPoints[s];if(null!=e){const{buffer:i,offset:a,size:r}=e;null!==i?0===a&&0===r?t.bindBufferBase(h.UNIFORM_BUFFER,s,i.glName):t.bindBufferRange(h.UNIFORM_BUFFER,s,i.glName,a,r):t.bindBufferBase(h.UNIFORM_BUFFER,s,null)}}if(this._state.pixelPackBuffer?t.bindBuffer(this._state.pixelPackBuffer.bufferType,this._state.pixelPackBuffer.glName):t.bindBuffer(h.PIXEL_PACK_BUFFER,null),this._state.pixelUnpackBuffer?t.bindBuffer(this._state.pixelUnpackBuffer.bufferType,this._state.pixelUnpackBuffer.glName):t.bindBuffer(h.PIXEL_UNPACK_BUFFER,null),this._state.copyReadBuffer?t.bindBuffer(this._state.copyReadBuffer.bufferType,this._state.copyReadBuffer.glName):t.bindBuffer(h.COPY_READ_BUFFER,null),this._state.copyWriteBuffer?t.bindBuffer(this._state.copyWriteBuffer.bufferType,this._state.copyWriteBuffer.glName):t.bindBuffer(h.COPY_WRITE_BUFFER,null),t.bindFramebuffer(_.READ_FRAMEBUFFER,null),t.readBuffer(t.BACK),this._state.readFramebuffer&&(t.bindFramebuffer(_.READ_FRAMEBUFFER,this._state.readFramebuffer.glName),t.readBuffer(l)),t.bindFramebuffer(_.DRAW_FRAMEBUFFER,this._state.drawFramebuffer?.glName??null),null===this._state.drawFramebuffer){const e=this._state.drawBuffers.defaultFramebuffer;t.drawBuffers(e??[n.BACK])}else{const e=this._state.drawBuffers.fbos.get(this._state.drawFramebuffer);t.drawBuffers(e??[l])}if(this._state.vertexArrayObject){const t=this._state.vertexArrayObject;this._state.vertexArrayObject&&(this._state.vertexArrayObject.unbind(),this._state.vertexArrayObject=null),this.bindVAO(t)}t.useProgram(this._state.program?.glName??null),t.blendColor(this._state.blendColor.r,this._state.blendColor.g,this._state.blendColor.b,this._state.blendColor.a),t.bindRenderbuffer(t.RENDERBUFFER,this._state.renderbuffer?.glName??null),!0===this._state.blend?t.enable(this.gl.BLEND):t.disable(this.gl.BLEND),t.blendEquationSeparate(this._state.blendEquation.mode,this._state.blendEquation.modeAlpha),t.blendFuncSeparate(this._state.blendFunction.srcRGB,this._state.blendFunction.dstRGB,this._state.blendFunction.srcAlpha,this._state.blendFunction.dstAlpha),t.clearColor(this._state.clearColor.r,this._state.clearColor.g,this._state.clearColor.b,this._state.clearColor.a),t.clearDepth(this._state.clearDepth),t.clearStencil(this._state.clearStencil),t.colorMask(this._state.colorMask.r,this._state.colorMask.g,this._state.colorMask.b,this._state.colorMask.a),t.cullFace(this._state.cullFace),t.depthFunc(this._state.depthFunction),t.depthRange(this._state.depthRange.zNear,this._state.depthRange.zFar),!0===this._state.depthTest?t.enable(t.DEPTH_TEST):t.disable(t.DEPTH_TEST),t.depthMask(this._state.depthWrite),t.frontFace(this._state.frontFace),t.lineWidth(1),!0===this._state.faceCulling?t.enable(t.CULL_FACE):t.disable(t.CULL_FACE),t.polygonOffset(this._state.polygonOffset[0],this._state.polygonOffset[1]),!0===this._state.polygonOffsetFill?t.enable(t.POLYGON_OFFSET_FILL):t.disable(t.POLYGON_OFFSET_FILL),t.scissor(this._state.scissorRect.x,this._state.scissorRect.y,this._state.scissorRect.width,this._state.scissorRect.height),!0===this._state.scissorTest?t.enable(t.SCISSOR_TEST):t.disable(t.SCISSOR_TEST),t.stencilFunc(this._state.stencilFunction.func,this._state.stencilFunction.ref,this._state.stencilFunction.mask),t.stencilOpSeparate(this._state.stencilOperation.face,this._state.stencilOperation.fail,this._state.stencilOperation.zFail,this._state.stencilOperation.zPass),!0===this._state.stencilTest?t.enable(t.STENCIL_TEST):t.disable(t.STENCIL_TEST),t.stencilMask(this._state.stencilWriteMask);for(let s=0;s<this.parameters.maxTextureImageUnits;s++){t.activeTexture(o+s),t.bindTexture(T.TEXTURE_2D,null),t.bindTexture(T.TEXTURE_CUBE_MAP,null),t.bindTexture(T.TEXTURE_3D,null),t.bindTexture(T.TEXTURE_2D_ARRAY,null);const e=this._state.textureUnitMap[s];null!=e&&t.bindTexture(e.descriptor.target,e.glName)}t.activeTexture(o+this._state.activeTexture);const e=this._state.viewport;t.viewport(e.x,e.y,e.width,e.height),this.resetInfo()}};function N(t,e,s,i){return e?i!==e&&t.bindBuffer(s,e.glName):t.bindBuffer(s,null),e}function D(t,e){switch(t){case A.POINTS:return 2*e;case A.TRIANGLES:return e/3;case A.TRIANGLE_STRIP:case A.TRIANGLE_FAN:return e-2;default:return 0}}export{v as RenderingContext};
package/webscene/Slide.js CHANGED
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../chunks/tslib.es6.js";import t from"../Basemap.js";import i from"../Viewpoint.js";import{result as n}from"../core/asyncUtils.js";import r from"../core/Clonable.js";import s from"../core/Collection.js";import{referenceSetter as o}from"../core/collectionUtils.js";import a from"../core/JSONSupport.js";import l from"../core/Logger.js";import{moduloPositive as p}from"../core/mathUtils.js";import{destroyMaybe as m,removeMaybe as c}from"../core/maybe.js";import{onAbortOrThrow as h,createAbortError as d,isAbortError as u}from"../core/promiseUtils.js";import{whenOnce as y,when as g}from"../core/reactiveUtils.js";import{Milliseconds as b,Seconds as v}from"../core/time.js";import{property as w}from"../core/accessorSupport/decorators/property.js";import{cast as f}from"../core/accessorSupport/decorators/cast.js";import"../core/has.js";import"../core/RandomLCG.js";import{subclass as T}from"../core/accessorSupport/decorators/subclass.js";import{ensureType as j}from"../core/accessorSupport/ensureType.js";import{s as L}from"../chunks/vec32.js";import{create as C}from"../core/libs/gl-matrix-2/factories/vec3f64.js";import _ from"../layers/Layer.js";import{basemapEnsureType as E,clonePreservingTiledLayers as S}from"../support/basemapEnsureType.js";import{TaskPriority as A}from"../views/support/Scheduler.js";import{SlideThumbnail as k}from"../webdoc/support/SlideThumbnail.js";import{timeExtent as V}from"../webdoc/support/timeProperties.js";import U from"./SunLighting.js";import x from"./VirtualLighting.js";import F from"./support/Description.js";import I from"./support/SlideElements.js";import{SlideEnvironment as D}from"./support/SlideEnvironment.js";import R from"./support/SlideGround.js";import{SlideVisibleLayer as M}from"./support/SlideVisibleLayer.js";import O from"./support/Title.js";let P=0;const q=s.ofType(M),B=["caption","cover","none"];let G=class extends(r.ClonableMixin(a)){constructor(e){super(e),this.id=Date.now().toString(16)+"-slide-"+P++,this.title=new O,this.description=new F,this.hidden=!1,this.thumbnail=new k,this.viewpoint=null,this.basemap=null,this.ground=null,this.layout="caption",this.environment=new D,this.timeExtent=null,this.elements=new I,this.visibleLayers=new q,this.enabledFocusAreas=new s}destroy(){this.visibleLayers.removeAll(),this.enabledFocusAreas?.removeAll(),this.basemap=null,this.thumbnail=m(this.thumbnail),this.description=null,this.title=null,this.thumbnail=null,this.elements=null}castTitle(e){return"string"==typeof e?new O({text:e}):j(O,e)}castDescription(e){return"string"==typeof e?new F({text:e}):j(F,e)}castThumbnail(e){return"string"==typeof e?new k({url:e}):j(k,e)}castBasemap(e){return E(e)}set visibleLayers(e){this._set("visibleLayers",o(e,this._get("visibleLayers"),q))}castVisibleLayers(e){return e&&"function"==typeof e.map?e.map((e=>{if("string"==typeof e)return{id:e};if(e instanceof _){const t=H(e);return{id:e.id,sublayerIds:t}}return e.id?{id:e.id,sublayerIds:"sublayerIds"in e?e.sublayerIds:void 0}:(l.getLogger(this).warn('Invalid visible layer, expected { id }, Layer or "id"'),e)})):null}async _updateVisibleLayers(e){const t=[];await Promise.allSettled(this._getLayers(e.map).map((i=>e.whenLayerView(i).then((e=>{if(e.visible){const n=H(i);t.push(new M({id:e.layer.id,sublayerIds:n}))}})))).toArray()),this.visibleLayers.removeAll(),this.visibleLayers.addMany(t)}async updateFrom(e,t){const i={format:"png",quality:80,width:120,height:75,disableDecorations:!0,...t?.screenshot};await e.when(),this.viewpoint=e.viewpoint.clone(),this.environment.lighting="virtual"===e.environment.lighting.type?x.prototype.clone.apply(e.environment.lighting):U.prototype.clone.apply(e.environment.lighting),this.environment.weather=e.environment.weather.clone(),this.enabledFocusAreas=e.focusAreasView?.enabledAreas?new s(e.focusAreasView?.enabledAreas.map((({id:e})=>e))):null,this.basemap=e.map.basemap?.clone()||null,this.ground=e.map.ground?R.fromGround(e.map.ground):null,this.timeExtent=e.timeExtent?.clone()??null,this.elements.analyses.updateFrom(e),await this._updateVisibleLayers(e);const n=await e.takeScreenshot(i);return this.thumbnail=new k({url:n.dataUrl}),this}async applyTo(e,t){null!=this._applyToController&&this._applyToController.abort();let i=new AbortController;this._applyToController=i;const r=h(t,(()=>i?.abort())),s=()=>{this._applyToController===i&&(this._applyToController=null),i=null,r?.remove()};try{await y((()=>e.ready),i.signal)}catch(c){throw s(),c}if(i.signal.aborted)throw s(),d();const o=e.resourceController.scheduler.registerTask(A.SLIDE);let a=!1;const l={animate:!0,...t,signal:this._applyToController.signal},p=async()=>{await Promise.all([o.schedule((async()=>a=await this._setViewpointOfInterest(e,l))),o.schedule((()=>this._applyBasemap(e,l)),l.signal),o.schedule((()=>this._loadLayersWithSublayerVisibility(e)))]),await Promise.all([o.schedule((()=>this._applyLayerVisibility(e)),l.signal),o.schedule((()=>this._applyFocusAreaEnabled(e.map?.focusAreas.areas))),o.schedule((()=>this._applyGround(e)),l.signal),o.schedule((()=>this.elements.analyses.applyTo(e)),l.signal),o.schedule((()=>this._applyViewpoint(e,l)),l.signal),o.schedule((()=>e.timeExtent=this.timeExtent?.clone()??null),l.signal),o.schedule((()=>e.environment.weather=this.environment.weather.clone()))])},m=await n(e.addUpdatingPromise(p()));if(a&&(e.contentCamera=null),o.remove(),s(),!1===m.ok)throw m.error;return this}async _applyBasemap(e,t){if(this.basemap){try{await this.basemap.load(t)}catch(i){if(u(i))throw i}e.map.basemap=S(this.basemap,e.map.basemap)}}_applyGround(e){this.ground&&(e.map.ground=this.ground.cloneAndApplyTo(e.map.ground))}_applyFocusAreaEnabled(e){if(e&&this.enabledFocusAreas)for(const t of e)t.enabled=this.enabledFocusAreas.includes(t.id)}_getLayers(e){const t=new s;return this._collectLayers(e,t),this._collectLayers(e.ground,t),t}_collectLayers(e,t){e.layers.forEach((e=>{e.persistenceEnabled&&(t.add(e),"layers"in e&&this._collectLayers(e,t))}))}async _loadLayersWithSublayerVisibility(e){this.visibleLayers&&await Promise.allSettled(this._getLayers(e.map).items.map((e=>{const t=this.visibleLayers.find((t=>t.id===e.id))?.sublayerIds;return t?e.load():null})))}_applyLayerVisibility(e){if(!this.visibleLayers)return;this._getLayers(e.map).forEach((e=>{const t=this.visibleLayers.find((t=>t.id===e.id));e.visible=null!=t;const i=t?.sublayerIds,n=W(e);i&&n&&n.forEach((e=>e.visible=i.includes(e.id)))}))}async _setViewpointOfInterest(e,t){if(e.state.fixedContentCamera||!this.viewpoint||t?.ignoreViewpoint||!t?.useDestinationCamera)return!1;const{toCameraAsync:i}=await import("../views/3d/support/viewpointUtils.js"),n=await i(e,this.viewpoint);return e.contentCamera=n,null!=n}async _applyViewpoint(e,t){if(this._applyCachedCameraTrackingEnabled(e),this.viewpoint&&!t.ignoreViewpoint){const i=this.environment.lighting;if(t.animate&&"sun"===i.type&&i.date)return this._animateToLighting(e,t);t.animate&&(e.environment.applyLighting(i.clone()),await e.goTo(this.viewpoint,t)),e.viewpoint=this.viewpoint}e.environment.applyLighting(this.environment.lighting.clone())}async _animateToLighting(e,t){let i=null;"virtual"!==e.environment.lighting.type&&"virtual"!==this.environment.lighting.type&&("global"===e.viewingMode&&(i=this._animateLightingWithCamera(e,e.environment.lighting,this.environment.lighting)),e.environment.cachedCameraTrackingEnabled=e.environment.lighting.cameraTrackingEnabled,e.environment.lighting.cameraTrackingEnabled=!1),e.environment.lighting.directShadowsEnabled=this.environment.lighting.directShadowsEnabled,"virtual"===this.environment.lighting.type||"virtual"===e.environment.lighting.type?(e.environment.applyLighting(this.environment.lighting.clone()),"virtual"!==e.environment.lighting.type&&(e.environment.cachedCameraTrackingEnabled=e.environment.lighting.cameraTrackingEnabled,e.environment.lighting.cameraTrackingEnabled=!1)):null!=this.environment.lighting.displayUTCOffset&&(e.environment.lighting.displayUTCOffset=this.environment.lighting.displayUTCOffset);return e.goTo(this.viewpoint,t).then((()=>{this._applyCachedCameraTrackingEnabled(e),e.environment.applyLighting(this.environment.lighting.clone())})).catch((t=>{throw null==e.animation&&this._applyCachedCameraTrackingEnabled(e),t})).finally((()=>{c(i)}))}_applyCachedCameraTrackingEnabled(e){null!=e.environment.cachedCameraTrackingEnabled&&(e.environment.lighting.cameraTrackingEnabled=e.environment.cachedCameraTrackingEnabled,e.environment.cachedCameraTrackingEnabled=null)}_getTime(e){return[b(e.getTime()),v(3600*e.getUTCHours()+60*e.getUTCMinutes()+e.getUTCSeconds())]}_setTime(e,t,i){return e.setTime(t),e.setUTCHours(i/3600),e.setUTCMinutes(i%3600/60),e.setUTCSeconds(i%3600%60),e}_animateLightingWithCamera(e,t,i){const n=new Date(t.date.toString()),[r,s]=this._getTime(n),[o,a]=this._getTime(i.date),l=K(s,a),p=e.renderCoordsHelper,m=C();p.toRenderCoords(e.camera.position,m);const c=C(),h=C();null!=this.viewpoint.camera&&p.toRenderCoords(this.viewpoint.camera.position,c);const d=new Date;return g((()=>e.camera),(e=>{p.toRenderCoords(e.position,h);const i=L(m,h),n=L(c,h);let a=0;i+n!==0&&(a=i/(i+n));const u=r+(o-r)*a,y=Q(s,v(l*a));t.date=this._setTime(d,u,y)}))}write(e,t){const i=super.write(e,t);return i?.elements&&0===Object.keys(i.elements).length&&delete i.elements,i}static createFrom(e,t){return(new this).updateFrom(e,t)}};e([w({type:String,json:{write:{isRequired:!0}}})],G.prototype,"id",void 0),e([w({type:O,json:{default:()=>new O({text:""}),write:{isRequired:!0}}})],G.prototype,"title",void 0),e([f("title")],G.prototype,"castTitle",null),e([w({type:F,json:{write:{overridePolicy:e=>({enabled:!(!e||!e.text)})}}})],G.prototype,"description",void 0),e([f("description")],G.prototype,"castDescription",null),e([w({type:Boolean,nonNullable:!0,json:{write:!0,default:!1}})],G.prototype,"hidden",void 0),e([w({type:k,json:{default:()=>new k({url:""}),write:{isRequired:!0}}})],G.prototype,"thumbnail",void 0),e([f("thumbnail")],G.prototype,"castThumbnail",null),e([w({type:i,nonNullable:!0,json:{write:{isRequired:!0}}})],G.prototype,"viewpoint",void 0),e([w({type:t,json:{read:{source:"baseMap"},write:{target:"baseMap"}}})],G.prototype,"basemap",void 0),e([f("basemap")],G.prototype,"castBasemap",null),e([w({type:R,json:{write:!0}})],G.prototype,"ground",void 0),e([w({type:B,json:{write:!0,default:"caption"},nonNullable:!0})],G.prototype,"layout",void 0),e([w({type:q,json:{write:{isRequired:!0}}})],G.prototype,"visibleLayers",null),e([f("visibleLayers")],G.prototype,"castVisibleLayers",null),e([w({type:D,json:{write:!0}})],G.prototype,"environment",void 0),e([w({type:s,json:{write:!1}})],G.prototype,"enabledFocusAreas",void 0),e([w(V)],G.prototype,"timeExtent",void 0),e([w({type:I,nonNullable:!0,json:{write:!0}})],G.prototype,"elements",void 0),G=e([T("esri.webscene.Slide")],G);const N=G;function W(e){if("building-scene"===e.type||"map-image"===e.type)return e.allSublayers.toArray()}function H(e){const t=W(e);if(t)return t.filter((e=>e.visible)).map((e=>e.id))}const J=v(86400),z=v(43200);function K(e,t){let i=t-e;return i>z&&(i-=J),i<-z&&(i+=J),v(i)}function Q(e,t){return v(p(e+t,J))}export{N as default};
5
+ import{_ as e}from"../chunks/tslib.es6.js";import t from"../Basemap.js";import i from"../Viewpoint.js";import{result as n}from"../core/asyncUtils.js";import r from"../core/Clonable.js";import s from"../core/Collection.js";import{referenceSetter as o}from"../core/collectionUtils.js";import a from"../core/JSONSupport.js";import l from"../core/Logger.js";import{moduloPositive as p}from"../core/mathUtils.js";import{destroyMaybe as m,removeMaybe as c}from"../core/maybe.js";import{onAbortOrThrow as h,createAbortError as d,isAbortError as u}from"../core/promiseUtils.js";import{whenOnce as y,when as g}from"../core/reactiveUtils.js";import{Milliseconds as b,Seconds as v}from"../core/time.js";import{property as w}from"../core/accessorSupport/decorators/property.js";import{cast as f}from"../core/accessorSupport/decorators/cast.js";import"../core/has.js";import"../core/RandomLCG.js";import{subclass as T}from"../core/accessorSupport/decorators/subclass.js";import{ensureType as j}from"../core/accessorSupport/ensureType.js";import{s as L}from"../chunks/vec32.js";import{create as C}from"../core/libs/gl-matrix-2/factories/vec3f64.js";import _ from"../layers/Layer.js";import{basemapEnsureType as E,clonePreservingTiledLayers as S}from"../support/basemapEnsureType.js";import{TaskPriority as A}from"../views/support/Scheduler.js";import{SlideThumbnail as k}from"../webdoc/support/SlideThumbnail.js";import{timeExtent as V}from"../webdoc/support/timeProperties.js";import U from"./SunLighting.js";import x from"./VirtualLighting.js";import F from"./support/Description.js";import I from"./support/SlideElements.js";import{SlideEnvironment as D}from"./support/SlideEnvironment.js";import R from"./support/SlideGround.js";import{SlideVisibleLayer as M}from"./support/SlideVisibleLayer.js";import O from"./support/Title.js";let P=0;const q=s.ofType(M),B=["caption","cover","none"];let G=class extends(r.ClonableMixin(a)){constructor(e){super(e),this.id=Date.now().toString(16)+"-slide-"+P++,this.title=new O,this.description=new F,this.hidden=!1,this.thumbnail=new k,this.viewpoint=null,this.basemap=null,this.ground=null,this.layout="caption",this.environment=new D,this.timeExtent=null,this.elements=new I,this.visibleLayers=new q,this.enabledFocusAreas=new s}destroy(){this.visibleLayers.removeAll(),this.enabledFocusAreas?.removeAll(),this.basemap=null,this.thumbnail=m(this.thumbnail),this.description=null,this.title=null,this.thumbnail=null,this.elements=null}castTitle(e){return"string"==typeof e?new O({text:e}):j(O,e)}castDescription(e){return"string"==typeof e?new F({text:e}):j(F,e)}castThumbnail(e){return"string"==typeof e?new k({url:e}):j(k,e)}castBasemap(e){return E(e)}set visibleLayers(e){this._set("visibleLayers",o(e,this._get("visibleLayers"),q))}castVisibleLayers(e){return e&&"function"==typeof e.map?e.map((e=>{if("string"==typeof e)return{id:e};if(e instanceof _){const t=H(e);return{id:e.id,sublayerIds:t}}return e.id?{id:e.id,sublayerIds:"sublayerIds"in e?e.sublayerIds:void 0}:(l.getLogger(this).warn('Invalid visible layer, expected { id }, Layer or "id"'),e)})):null}async _updateVisibleLayers(e){const t=[];await Promise.allSettled(this._getLayers(e.map).map((i=>e.whenLayerView(i).then((e=>{if(e.visible){const n=H(i);t.push(new M({id:e.layer.id,sublayerIds:n}))}})))).toArray()),this.visibleLayers.removeAll(),this.visibleLayers.addMany(t)}async updateFrom(e,t){const i={format:"png",quality:80,width:120,height:75,disableDecorations:!0,...t?.screenshot};await e.when(),this.viewpoint=e.viewpoint.clone(),this.environment.lighting="virtual"===e.environment.lighting.type?x.prototype.clone.apply(e.environment.lighting):U.prototype.clone.apply(e.environment.lighting),this.environment.weather=e.environment.weather.clone(),this.enabledFocusAreas=e.focusAreasView?.enabledAreas?new s(e.focusAreasView?.enabledAreas.map((({id:e})=>e))):null,this.basemap=e.map.basemap?.clone()||null,this.ground=e.map.ground?R.fromGround(e.map.ground):null,this.timeExtent=e.timeExtent?.clone()??null,this.elements.analyses.updateFrom(e),await this._updateVisibleLayers(e);const n=await e.takeScreenshot(i);return this.thumbnail=new k({url:n.dataUrl}),this}async applyTo(e,t){null!=this._applyToController&&this._applyToController.abort();let i=new AbortController;this._applyToController=i;const r=h(t,(()=>i?.abort())),s=()=>{this._applyToController===i&&(this._applyToController=null),i=null,r?.remove()};try{await y((()=>e.ready),i.signal)}catch(c){throw s(),c}if(i.signal.aborted)throw s(),d();const o=e.resourceController.scheduler.registerTask(A.SLIDE);let a=!1;const l={animate:!0,...t,signal:this._applyToController.signal},p=async()=>{await Promise.all([o.schedule((async()=>a=await this._setViewpointOfInterest(e,l))),o.schedule((()=>this._applyBasemap(e,l)),l.signal),o.schedule((()=>this._loadLayersWithSublayerVisibility(e)))]),await Promise.all([o.schedule((()=>this._applyLayerVisibility(e)),l.signal),o.schedule((()=>this._applyFocusAreaEnabled(e.map?.focusAreas.areas))),o.schedule((()=>this._applyGround(e)),l.signal),o.schedule((()=>this.elements.analyses.applyTo(e)),l.signal),o.schedule((()=>this._applyViewpoint(e,l)),l.signal),o.schedule((()=>e.timeExtent=this.timeExtent?.clone()??null),l.signal),o.schedule((()=>e.environment.weather=this.environment.weather.clone()))])},m=await n(e.addUpdatingPromise(p()));if(a&&(e.contentCamera=null),o.remove(),s(),!1===m.ok)throw m.error;return this}async _applyBasemap(e,t){if(this.basemap){try{await this.basemap.load(t)}catch(i){if(u(i))throw i}e.map.basemap=S(this.basemap,e.map.basemap)}}_applyGround(e){this.ground&&(e.map.ground=this.ground.cloneAndApplyTo(e.map.ground))}_applyFocusAreaEnabled(e){if(e&&this.enabledFocusAreas)for(const t of e)t.enabled=this.enabledFocusAreas.includes(t.id)}_getLayers(e){const t=new s;return this._collectLayers(e,t),this._collectLayers(e.ground,t),t}_collectLayers(e,t){e.layers.forEach((e=>{e.persistenceEnabled&&(t.add(e),"layers"in e&&this._collectLayers(e,t))}))}async _loadLayersWithSublayerVisibility(e){this.visibleLayers&&await Promise.allSettled(this._getLayers(e.map).items.map((e=>{const t=this.visibleLayers.find((t=>t.id===e.id))?.sublayerIds;return t?e.load():null})))}_applyLayerVisibility(e){if(!this.visibleLayers)return;this._getLayers(e.map).forEach((e=>{const t=this.visibleLayers.find((t=>t.id===e.id));e.visible=null!=t;const i=t?.sublayerIds,n=W(e);i&&n&&n.forEach((e=>e.visible=i.includes(e.id)))}))}async _setViewpointOfInterest(e,t){if(e.state.fixedContentCamera||!this.viewpoint||t?.ignoreViewpoint||!t?.useDestinationCamera)return!1;const{toCameraAsync:i}=await import("../views/3d/support/viewpointUtils.js"),n=await i(e,this.viewpoint);return e.contentCamera=n,null!=n}async _applyViewpoint(e,t){if(this._applyCachedCameraTrackingEnabled(e),this.viewpoint&&!t.ignoreViewpoint){const i=this.environment.lighting;if(t.animate&&"sun"===i.type&&i.date)return this._animateToLighting(e,t);t.animate&&(e.environment.applyLighting(i.clone()),await e.goTo(this.viewpoint,t)),e.viewpoint=this.viewpoint}e.environment.applyLighting(this.environment.lighting.clone())}async _animateToLighting(e,t){let i=null;"virtual"!==e.environment.lighting.type&&"virtual"!==this.environment.lighting.type&&("global"===e.viewingMode&&(i=this._animateLightingWithCamera(e,e.environment.lighting,this.environment.lighting)),e.environment.cachedCameraTrackingEnabled=e.environment.lighting.cameraTrackingEnabled,e.environment.lighting.cameraTrackingEnabled=!1),e.environment.lighting.directShadowsEnabled=this.environment.lighting.directShadowsEnabled,"virtual"===this.environment.lighting.type||"virtual"===e.environment.lighting.type?(e.environment.applyLighting(this.environment.lighting.clone()),"virtual"!==e.environment.lighting.type&&(e.environment.cachedCameraTrackingEnabled=e.environment.lighting.cameraTrackingEnabled,e.environment.lighting.cameraTrackingEnabled=!1)):null!=this.environment.lighting.displayUTCOffset&&(e.environment.lighting.displayUTCOffset=this.environment.lighting.displayUTCOffset);return e.goTo(this.viewpoint,t).then((()=>{this._applyCachedCameraTrackingEnabled(e),e.environment.applyLighting(this.environment.lighting.clone())})).catch((t=>{throw null==e.animation&&this._applyCachedCameraTrackingEnabled(e),t})).finally((()=>{c(i)}))}_applyCachedCameraTrackingEnabled(e){null!=e.environment.cachedCameraTrackingEnabled&&(e.environment.lighting.cameraTrackingEnabled=e.environment.cachedCameraTrackingEnabled,e.environment.cachedCameraTrackingEnabled=null)}_getTime(e){return[b(e.getTime()),v(3600*e.getUTCHours()+60*e.getUTCMinutes()+e.getUTCSeconds())]}_setTime(e,t,i){return e.setTime(t),e.setUTCHours(i/3600),e.setUTCMinutes(i%3600/60),e.setUTCSeconds(i%3600%60),e}_animateLightingWithCamera(e,t,i){const n=new Date(t.date.toString()),[r,s]=this._getTime(n),[o,a]=this._getTime(i.date),l=K(s,a),p=e.renderCoordsHelper,m=C();p.toRenderCoords(e.camera.position,m);const c=C(),h=C();null!=this.viewpoint.camera&&p.toRenderCoords(this.viewpoint.camera.position,c);const d=new Date;return g((()=>e.camera),(e=>{p.toRenderCoords(e.position,h);const i=L(m,h),n=L(c,h);let a=0;i+n!==0&&(a=i/(i+n));const u=r+(o-r)*a,y=Q(s,v(l*a));t.date=this._setTime(d,u,y)}))}write(e,t){const i=super.write(e,t);return i?.elements&&0===Object.keys(i.elements).length&&delete i.elements,i}static createFrom(e,t){return(new this).updateFrom(e,t)}};e([w({type:String,json:{write:{isRequired:!0}}})],G.prototype,"id",void 0),e([w({type:O,json:{default:()=>new O({text:""}),write:{isRequired:!0}}})],G.prototype,"title",void 0),e([f("title")],G.prototype,"castTitle",null),e([w({type:F,json:{write:{overridePolicy:e=>({enabled:!(!e||!e.text)})}}})],G.prototype,"description",void 0),e([f("description")],G.prototype,"castDescription",null),e([w({type:Boolean,nonNullable:!0,json:{write:!0,default:!1}})],G.prototype,"hidden",void 0),e([w({type:k,json:{default:()=>new k({url:""}),write:{isRequired:!0}}})],G.prototype,"thumbnail",void 0),e([f("thumbnail")],G.prototype,"castThumbnail",null),e([w({type:i,nonNullable:!0,json:{write:{isRequired:!0}}})],G.prototype,"viewpoint",void 0),e([w({type:t,json:{read:{source:"baseMap"},write:{target:"baseMap"}}})],G.prototype,"basemap",void 0),e([f("basemap")],G.prototype,"castBasemap",null),e([w({type:R,json:{write:!0}})],G.prototype,"ground",void 0),e([w({type:B,json:{write:!0,default:"caption"},nonNullable:!0})],G.prototype,"layout",void 0),e([w({type:q,json:{write:{isRequired:!0}}})],G.prototype,"visibleLayers",null),e([f("visibleLayers")],G.prototype,"castVisibleLayers",null),e([w({type:s.ofType(String),json:{write:!0},clonable:e=>new s(e.items)})],G.prototype,"enabledFocusAreas",void 0),e([w({type:D,json:{write:!0}})],G.prototype,"environment",void 0),e([w(V)],G.prototype,"timeExtent",void 0),e([w({type:I,nonNullable:!0,json:{write:!0}})],G.prototype,"elements",void 0),G=e([T("esri.webscene.Slide")],G);const N=G;function W(e){if("building-scene"===e.type||"map-image"===e.type)return e.allSublayers.toArray()}function H(e){const t=W(e);if(t)return t.filter((e=>e.visible)).map((e=>e.id))}const J=v(86400),z=v(43200);function K(e,t){let i=t-e;return i>z&&(i-=J),i<-z&&(i+=J),v(i)}function Q(e,t){return v(p(e+t,J))}export{N as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../chunks/tslib.es6.js";import s from"../../analysis/support/AnalysisOriginWebScene.js";import t from"../../core/Collection.js";import{castForReferenceSetter as i,referenceSetter as o}from"../../core/collectionUtils.js";import"../../core/Logger.js";import"../../core/has.js";import"../../core/RandomLCG.js";import"../../core/Error.js";import{subclass as n}from"../../core/accessorSupport/decorators/subclass.js";const r=["slice"];let a=class extends t{constructor(e){super(e),this.addHandles([this.on("after-add",(e=>{this._setOrigin(e.item)})),this.on("before-remove",(e=>{const{origin:s}=e.item;"web-scene"===s?.type&&this._setOrigin(e.item,null)}))])}initialize(){for(const e of this.items)this._setOrigin(e)}_setOrigin(e,t=new s){e.origin=t}updateFrom(e){const t=e.analyses.filter((e=>c(e)));this.removeAll(),t.length&&this.addMany(t.map((e=>(e.origin=new s,e.clone()))))}applyTo(e){e.analyses.destroyMany(e.analyses.filter((({origin:e})=>"web-scene"===e?.type))),e.analyses.addMany(this.map((e=>e.clone())))}toJSON(e){return this.items.filter(c).map((s=>s.toJSON(e)))}};function l(e){return{type:a,cast:i,set(s){this._set(e,o(s,this._get(e),a))},json:{read(s,t,i){i?.hooks?.onAfterLoad((()=>p(this[e],s,i)))},write:{overridePolicy:e=>({enabled:e.length>0})}}}}function c(e){return r.includes(e.type)&&e.valid}async function p(e,s,t){if(!s)return;const i=await Promise.allSettled(s.map((e=>m(e,t))));for(const o of i)"fulfilled"===o.status&&e.add(o.value)}async function m(e,s){const t=new(await d[e.type]());return t.read(e,s),t}a=e([n("esri.webscene.support.analysisUtils.WebSceneAnalysesCollection")],a);const d={slice:async()=>{const{default:e}=await import("../../analysis/SliceAnalysis.js");return e}};export{a as WebSceneAnalysesCollection,l as webSceneAnalysisCollectionProperty,d as webSceneAnalysisRegistry};
5
+ import{_ as e}from"../../chunks/tslib.es6.js";import s from"../../analysis/support/AnalysisOriginWebScene.js";import t from"../../core/Collection.js";import{castForReferenceSetter as i,referenceSetter as o}from"../../core/collectionUtils.js";import"../../core/Logger.js";import"../../core/has.js";import"../../core/RandomLCG.js";import"../../core/Error.js";import{subclass as n}from"../../core/accessorSupport/decorators/subclass.js";const r=["slice"];let a=class extends t{constructor(e){super(e),this.addHandles([this.on("after-add",(e=>{this._setOrigin(e.item)})),this.on("before-remove",(e=>{const{origin:s}=e.item;"web-scene"===s?.type&&this._setOrigin(e.item,null)}))])}initialize(){for(const e of this.items)this._setOrigin(e)}_setOrigin(e,t=new s){e.origin=t}updateFrom(e){const t=e.analyses.filter((e=>c(e)));this.removeAll(),t.length&&this.addMany(t.map((e=>(e.origin=new s,e.clone()))))}applyTo(e){e.analyses.destroyMany(e.analyses.filter((({origin:e})=>"web-scene"===e?.type))),e.analyses.addMany(this.map((e=>e.clone())))}toJSON(e){return this.items.filter(c).map((s=>s.toJSON(e)))}};function l(e){return{type:a,cast:i,clonable:e=>new a({items:e.items.map((e=>e.clone()))}),set(s){this._set(e,o(s,this._get(e),a))},json:{read(s,t,i){i?.hooks?.onAfterLoad((()=>m(this[e],s,i)))},write:{overridePolicy:e=>({enabled:e.length>0})}}}}function c(e){return r.includes(e.type)&&e.valid}async function m(e,s,t){if(!s)return;const i=await Promise.allSettled(s.map((e=>p(e,t))));for(const o of i)"fulfilled"===o.status&&e.add(o.value)}async function p(e,s){const t=new(await d[e.type]());return t.read(e,s),t}a=e([n("esri.webscene.support.analysisUtils.WebSceneAnalysesCollection")],a);const d={slice:async()=>{const{default:e}=await import("../../analysis/SliceAnalysis.js");return e}};export{a as WebSceneAnalysesCollection,l as webSceneAnalysisCollectionProperty,d as webSceneAnalysisRegistry};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../chunks/tslib.es6.js";import{deprecateWidget as t}from"../core/deprecate.js";import s from"../core/Logger.js";import{ignoreAbortErrors as i}from"../core/promiseUtils.js";import{property as o}from"../core/accessorSupport/decorators/property.js";import"../core/has.js";import"../core/RandomLCG.js";import{subclass as r}from"../core/accessorSupport/decorators/subclass.js";import n from"./Widget.js";import a from"./AreaMeasurement3D/AreaMeasurement3DViewModel.js";import{globalCss as l}from"./support/globalCss.js";import{MeasurementWidgetContent as p}from"./support/MeasurementWidgetContent.js";import"./support/widgetUtils.js";import{messageBundle as u}from"./support/decorators/messageBundle.js";import{tsx as m}from"./support/jsxFactory.js";const d="esri-area-measurement-3d",c={base:d,newMeasurementButton:`${d}__clear-button`};let v=class extends n{constructor(e,i){super(e,i),this.messages=null,this.messagesCommon=null,this.messagesUnits=null,this.viewModel=new a({isDefaultViewModel:!0}),t(s.getLogger(this),"Area Measurement 3D","arcgis-area-measurement-3d",{version:"4.33"})}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}get visible(){return this.viewModel.visible}set visible(e){this.viewModel.visible=e}get active(){return this.viewModel.active}get analysis(){return this.viewModel.analysis}set analysis(e){this.viewModel.analysis=e}get icon(){return"measure-area"}set icon(e){this._overrideIfSome("icon",e)}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get unitOptions(){return this.viewModel.unitOptions}set unitOptions(e){this.viewModel.unitOptions=e}get unit(){return this.viewModel.unit}set unit(e){this.viewModel.unit=e}render(){const{messages:e,messagesCommon:t,messagesUnits:s,unit:o,unitOptions:r,viewModel:n}=this,{active:a,measurement:u,state:d,supported:v}=n;return m("div",{"aria-label":this.messages.widgetLabel,class:this.classes(c.base,l.widget,l.panel),key:this,role:"presentation"},this.visible?m(p,{active:a,measurementItems:[{key:"direct",title:s.measures.area,value:g(u?.area)},{key:"perimeter",title:e.perimeterLength,value:g(u?.perimeterLength)}],messages:{...e,notApplicable:t.notApplicable},newMeasurementButtonClass:c.newMeasurementButton,state:d,supported:v,unit:o,unitOptions:r,onNewMeasurementClick:()=>{i(this.viewModel.start())},onUnitChange:e=>{this.unit=e}}):null)}};function g(e){return"available"===e?.state?e.text:null}e([o()],v.prototype,"view",null),e([o()],v.prototype,"visible",null),e([o()],v.prototype,"active",null),e([o({constructOnly:!0,nonNullable:!0})],v.prototype,"analysis",null),e([o()],v.prototype,"icon",null),e([o()],v.prototype,"label",null),e([o(),u("esri/widgets/AreaMeasurement3D/t9n/AreaMeasurement3D")],v.prototype,"messages",void 0),e([o(),u("esri/t9n/common")],v.prototype,"messagesCommon",void 0),e([o(),u("esri/core/t9n/Units")],v.prototype,"messagesUnits",void 0),e([o()],v.prototype,"uiStrings",void 0),e([o({type:a})],v.prototype,"viewModel",void 0),e([o()],v.prototype,"unitOptions",null),e([o()],v.prototype,"unit",null),v=e([r("esri.widgets.AreaMeasurement3D")],v);const w=v;export{w as default};
5
+ import{_ as e}from"../chunks/tslib.es6.js";import{deprecateWidget as t}from"../core/deprecate.js";import s from"../core/Logger.js";import{ignoreAbortErrors as i}from"../core/promiseUtils.js";import{property as o}from"../core/accessorSupport/decorators/property.js";import"../core/has.js";import"../core/RandomLCG.js";import{subclass as r}from"../core/accessorSupport/decorators/subclass.js";import n from"./Widget.js";import a from"./AreaMeasurement3D/AreaMeasurement3DViewModel.js";import{globalCss as l}from"./support/globalCss.js";import{MeasurementWidgetContent as p}from"./support/MeasurementWidgetContent.js";import"./support/widgetUtils.js";import{messageBundle as u}from"./support/decorators/messageBundle.js";import{tsx as m}from"./support/jsxFactory.js";const d="esri-area-measurement-3d",c={base:d,newMeasurementButton:`${d}__clear-button`};let v=class extends n{constructor(e,i){super(e,i),this.messages=null,this.messagesCommon=null,this.messagesUnits=null,this.viewModel=new a({isDefaultViewModel:!0}),t(s.getLogger(this),"Area Measurement 3D","arcgis-area-measurement-3d",{version:"4.33"})}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}get visible(){return this.viewModel.visible}set visible(e){this.viewModel.visible=e}get active(){return this.viewModel.active}get analysis(){return this.viewModel.analysis}set analysis(e){this.viewModel.analysis=e}get icon(){return"measure-area"}set icon(e){this._overrideIfSome("icon",e)}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get unitOptions(){return this.viewModel.unitOptions}set unitOptions(e){this.viewModel.unitOptions=e}get unit(){return this.viewModel.unit}set unit(e){this.viewModel.unit=e}render(){const{messages:e,messagesCommon:t,messagesUnits:s,unit:o,unitOptions:r,viewModel:n}=this,{active:a,measurement:u,state:d,supported:v}=n;return m("div",{"aria-label":this.messages.widgetLabel,class:this.classes(c.base,l.widget,l.panel),key:this,role:"presentation"},this.visible?m(p,{active:a,measurementItems:[{key:"direct",title:s.measures.area,value:g(u?.area)},{key:"perimeter",title:e.perimeterLength,value:g(u?.perimeterLength)}],messages:{...e,notApplicable:t.notApplicable},newMeasurementButtonClass:c.newMeasurementButton,state:d,supported:v,unit:o,unitOptions:r,onNewMeasurementClick:()=>{i(this.viewModel.start())},onUnitChange:e=>{this.unit=e}}):null)}};function g(e){return"available"===e?.state?e.text:null}e([o()],v.prototype,"view",null),e([o()],v.prototype,"visible",null),e([o()],v.prototype,"active",null),e([o({nonNullable:!0})],v.prototype,"analysis",null),e([o()],v.prototype,"icon",null),e([o()],v.prototype,"label",null),e([o(),u("esri/widgets/AreaMeasurement3D/t9n/AreaMeasurement3D")],v.prototype,"messages",void 0),e([o(),u("esri/t9n/common")],v.prototype,"messagesCommon",void 0),e([o(),u("esri/core/t9n/Units")],v.prototype,"messagesUnits",void 0),e([o()],v.prototype,"uiStrings",void 0),e([o({type:a})],v.prototype,"viewModel",void 0),e([o()],v.prototype,"unitOptions",null),e([o()],v.prototype,"unit",null),v=e([r("esri.widgets.AreaMeasurement3D")],v);const w=v;export{w as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../Basemap.js";import s from"../../core/Collection.js";import i from"../../core/Loadable.js";import{watch as a,on as r,when as o}from"../../core/reactiveUtils.js";import{property as p}from"../../core/accessorSupport/decorators/property.js";import{cast as n}from"../../core/accessorSupport/decorators/cast.js";import"../../core/has.js";import"../../core/RandomLCG.js";import{subclass as c}from"../../core/accessorSupport/decorators/subclass.js";import{canProjectWithoutEngine as m,isLoaded as l,load as u}from"../../geometry/projection.js";import{equals as d}from"../../geometry/support/spatialReferenceUtils.js";import{isLinkChartView as h}from"../../linkChart/utils.js";import{basemapEnsureType as y}from"../../support/basemapEnsureType.js";import{contentEquals as f}from"../../support/basemapUtils.js";import{default3DCompatibility as v,default2DCompatibility as b}from"./support/basemapCompatibilityUtils.js";import j from"./support/BasemapGalleryItem.js";import w from"./support/LocalBasemapsSource.js";import B from"./support/PortalBasemapsSource.js";const g=s.ofType(j);function _(e){return e&&"esri.portal.Portal"===e.declaredClass}function I(e){return e&&!(e instanceof B)&&(!!e.portal||!!e.query)}function R(e){return e&&"basemaps"in e&&"state"in e&&"refresh"in e}let E=class extends i{constructor(e){super(e),this._loadingProjectionEngine=!1,this.items=new g,this.source=new B,this.view=null}initialize(){const e=()=>this._recreateItems();this.addHandles([a((()=>"ready"===this.state?this.compatibilityFunction:null),(()=>this._updateItems())),r((()=>this.source?.basemaps),"change",e,{onListenerAdd:e}),o((()=>this.view),(()=>{this.source instanceof B&&(this.source.viewType=this.view?.type)}),{once:!0})])}destroy(){const e=this.source.basemaps.find((e=>e===this.activeBasemap));e&&this.source.basemaps.remove(e),this.source?.destroy()}get activeBasemap(){return this.view?.map?.basemap??null}set activeBasemap(e){const t=this.view;if(!t?.map)return;if(!e||!t.ready)return t.map.basemap=e,void this._clearOverride("activeBasemap");const s=e.spatialReference||this.items?.find((t=>this.basemapEquals(e,t.basemap)))?.spatialReference;if(s&&"spatialReferenceLocked"in t&&!t.spatialReferenceLocked){const i=t.spatialReference;if(null!=s&&!d(i,s)&&!m(t.spatialReference,s)&&!l())return this._override("activeBasemap",e),this._loadingProjectionEngine=!0,void u().then((()=>{this._get("activeBasemap")===e&&(t.map.basemap=e,t.spatialReference=s,this._clearOverride("activeBasemap"))}),(()=>{})).then((()=>{this._loadingProjectionEngine=!1}));t.map.basemap=e,this._clearOverride("activeBasemap"),null==s||d(t.spatialReference,s)||(t.spatialReference=s)}else t.map.basemap=e,this._clearOverride("activeBasemap")}castActiveBasemap(e){return y(e)}get activeBasemapIndex(){const{state:e,activeBasemap:t}=this;return"ready"!==e?-1:this._findBasemapIndex(t)}get compatibilityFunction(){return"3d"===this.view?.type?v:b}set compatibilityFunction(e){this._overrideIfSome("compatibilityFunction",e)}castSource(e){return Array.isArray(e)||s.isCollection(e)?new w({basemaps:Array.isArray(e)?new s(e):e}):_(e)?new B({portal:e}):I(e)?new B(e):R(e)?e:null}get state(){return this.view?.ready&&this.source?h(this.view)&&!this.view.inGeographicLayout?"unsupported":this._loadingProjectionEngine?"loading":"ready":"disabled"}basemapEquals(e,t){return f(e,t)}refresh(){this._recreateItems()}load(){return this.loadSource()}loadSource(e){return this.addResolvingPromise(i.isLoadable(this.source)?this.source.load(e):null),Promise.resolve(this)}_findBasemapIndex(e){const{items:t}=this,s=t.findIndex((t=>t.basemap===e));return-1===s?t.findIndex((t=>this.basemapEquals(t.basemap,e))):s}_recreateItems(){const e=this.source?.basemaps??[],{view:t,compatibilityFunction:s}=this,i=new Map(this.items.map((e=>[e.basemap,e]))),a=e.map((e=>{const a=i.get(e);return a?(i.delete(e),a):new j({basemap:e,compatibilityFunction:s,view:t})}));this.items.removeAll(),this.items.addMany(a),i.forEach((e=>e.destroy()))}_updateItems(){for(const e of this.items)e.compatibilityFunction=this.compatibilityFunction,e.view=this.view}};e([p()],E.prototype,"_loadingProjectionEngine",void 0),e([p({type:t})],E.prototype,"activeBasemap",null),e([n("activeBasemap")],E.prototype,"castActiveBasemap",null),e([p({readOnly:!0})],E.prototype,"activeBasemapIndex",null),e([p()],E.prototype,"compatibilityFunction",null),e([p({readOnly:!0,type:g})],E.prototype,"items",void 0),e([p()],E.prototype,"source",void 0),e([n("source")],E.prototype,"castSource",null),e([p({readOnly:!0})],E.prototype,"state",null),e([p()],E.prototype,"view",void 0),E=e([c("esri.widgets.BasemapGallery.BasemapGalleryViewModel")],E);const S=E;export{S as default};
5
+ import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../Basemap.js";import s from"../../core/Collection.js";import i from"../../core/Loadable.js";import{watch as a,on as r,when as o}from"../../core/reactiveUtils.js";import{property as p}from"../../core/accessorSupport/decorators/property.js";import{cast as n}from"../../core/accessorSupport/decorators/cast.js";import"../../core/has.js";import"../../core/RandomLCG.js";import{subclass as c}from"../../core/accessorSupport/decorators/subclass.js";import{canProjectWithoutEngine as m,isLoaded as l,load as u}from"../../geometry/projectionUtils.js";import{equals as d}from"../../geometry/support/spatialReferenceUtils.js";import{isLinkChartView as h}from"../../linkChart/utils.js";import{basemapEnsureType as y}from"../../support/basemapEnsureType.js";import{contentEquals as f}from"../../support/basemapUtils.js";import{default3DCompatibility as v,default2DCompatibility as b}from"./support/basemapCompatibilityUtils.js";import j from"./support/BasemapGalleryItem.js";import w from"./support/LocalBasemapsSource.js";import B from"./support/PortalBasemapsSource.js";const g=s.ofType(j);function _(e){return e&&"esri.portal.Portal"===e.declaredClass}function I(e){return e&&!(e instanceof B)&&(!!e.portal||!!e.query)}function R(e){return e&&"basemaps"in e&&"state"in e&&"refresh"in e}let E=class extends i{constructor(e){super(e),this._loadingProjectionEngine=!1,this.items=new g,this.source=new B,this.view=null}initialize(){const e=()=>this._recreateItems();this.addHandles([a((()=>"ready"===this.state?this.compatibilityFunction:null),(()=>this._updateItems())),r((()=>this.source?.basemaps),"change",e,{onListenerAdd:e}),o((()=>this.view),(()=>{this.source instanceof B&&(this.source.viewType=this.view?.type)}),{once:!0})])}destroy(){const e=this.source.basemaps.find((e=>e===this.activeBasemap));e&&this.source.basemaps.remove(e),this.source?.destroy()}get activeBasemap(){return this.view?.map?.basemap??null}set activeBasemap(e){const t=this.view;if(!t?.map)return;if(!e||!t.ready)return t.map.basemap=e,void this._clearOverride("activeBasemap");const s=e.spatialReference||this.items?.find((t=>this.basemapEquals(e,t.basemap)))?.spatialReference;if(s&&"spatialReferenceLocked"in t&&!t.spatialReferenceLocked){const i=t.spatialReference;if(null!=s&&!d(i,s)&&!m(t.spatialReference,s)&&!l())return this._override("activeBasemap",e),this._loadingProjectionEngine=!0,void u().then((()=>{this._get("activeBasemap")===e&&(t.map.basemap=e,t.spatialReference=s,this._clearOverride("activeBasemap"))}),(()=>{})).then((()=>{this._loadingProjectionEngine=!1}));t.map.basemap=e,this._clearOverride("activeBasemap"),null==s||d(t.spatialReference,s)||(t.spatialReference=s)}else t.map.basemap=e,this._clearOverride("activeBasemap")}castActiveBasemap(e){return y(e)}get activeBasemapIndex(){const{state:e,activeBasemap:t}=this;return"ready"!==e?-1:this._findBasemapIndex(t)}get compatibilityFunction(){return"3d"===this.view?.type?v:b}set compatibilityFunction(e){this._overrideIfSome("compatibilityFunction",e)}castSource(e){return Array.isArray(e)||s.isCollection(e)?new w({basemaps:Array.isArray(e)?new s(e):e}):_(e)?new B({portal:e}):I(e)?new B(e):R(e)?e:null}get state(){return this.view?.ready&&this.source?h(this.view)&&!this.view.inGeographicLayout?"unsupported":this._loadingProjectionEngine?"loading":"ready":"disabled"}basemapEquals(e,t){return f(e,t)}refresh(){this._recreateItems()}load(){return this.loadSource()}loadSource(e){return this.addResolvingPromise(i.isLoadable(this.source)?this.source.load(e):null),Promise.resolve(this)}_findBasemapIndex(e){const{items:t}=this,s=t.findIndex((t=>t.basemap===e));return-1===s?t.findIndex((t=>this.basemapEquals(t.basemap,e))):s}_recreateItems(){const e=this.source?.basemaps??[],{view:t,compatibilityFunction:s}=this,i=new Map(this.items.map((e=>[e.basemap,e]))),a=e.map((e=>{const a=i.get(e);return a?(i.delete(e),a):new j({basemap:e,compatibilityFunction:s,view:t})}));this.items.removeAll(),this.items.addMany(a),i.forEach((e=>e.destroy()))}_updateItems(){for(const e of this.items)e.compatibilityFunction=this.compatibilityFunction,e.view=this.view}};e([p()],E.prototype,"_loadingProjectionEngine",void 0),e([p({type:t})],E.prototype,"activeBasemap",null),e([n("activeBasemap")],E.prototype,"castActiveBasemap",null),e([p({readOnly:!0})],E.prototype,"activeBasemapIndex",null),e([p()],E.prototype,"compatibilityFunction",null),e([p({readOnly:!0,type:g})],E.prototype,"items",void 0),e([p()],E.prototype,"source",void 0),e([n("source")],E.prototype,"castSource",null),e([p({readOnly:!0})],E.prototype,"state",null),e([p()],E.prototype,"view",void 0),E=e([c("esri.widgets.BasemapGallery.BasemapGalleryViewModel")],E);const S=E;export{S as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../chunks/tslib.es6.js";import a from"../../core/Accessor.js";import{watch as t,initial as s,whenOnce as i}from"../../core/reactiveUtils.js";import{property as r}from"../../core/accessorSupport/decorators/property.js";import{cast as p}from"../../core/accessorSupport/decorators/cast.js";import"../../core/has.js";import"../../core/RandomLCG.js";import{subclass as o}from"../../core/accessorSupport/decorators/subclass.js";import{isLoaded as n,canProjectWithoutEngine as c,load as l}from"../../geometry/projection.js";import{equals as m}from"../../geometry/support/spatialReferenceUtils.js";import{basemapEnsureType as h,destroyCache as f}from"../../support/basemapEnsureType.js";import{findSpatialReference as d,getBasemapThumbnailUrl as u}from"../../support/basemapUtils.js";let g=class extends a{constructor(e){super(e),this._basemapCache={},this._loadingProjectionEngine=!1,this.nextBasemap=h("hybrid",this._basemapCache),this.view=null}initialize(){t((()=>this.nextBasemap),(e=>{e&&!e.loaded&&e.load().catch((()=>{}))}),s)}destroy(){this.view=null,f(this._basemapCache),this._basemapCache=null}get _nextBasemapSpatialReferenceTask(){return d(this.view,this.nextBasemap)}get _viewSpatialReferenceLocked(){const{view:e}=this;return!e||!("spatialReferenceLocked"in e)||e.spatialReferenceLocked}get activeBasemap(){return h(this.view?.map?.basemap??"topo-vector",this._basemapCache)}castNextBasemap(e){return h(e,this._basemapCache)}get state(){const{view:e}=this;if(!e?.ready)return"disabled";if(this._nextBasemapSpatialReferenceTask.updating)return"disabled";const{spatialReference:a}=this._nextBasemapSpatialReferenceTask;return this._viewSpatialReferenceLocked&&null!=a&&!e.spatialReference.equals(a)?"incompatible-next-basemap":this._loadingProjectionEngine?"loading":"ready"}async toggle(){const{activeBasemap:e,nextBasemap:a,state:t,view:s}=this;if(!s||"disabled"===t||"incompatible-next-basemap"===t)return;const r=this._viewSpatialReferenceLocked;if(!r){if(await i((()=>!this._nextBasemapSpatialReferenceTask.updating)),a!==this.nextBasemap||e!==this.activeBasemap)return;const{spatialReference:t}=this._nextBasemapSpatialReferenceTask;if(null==t||m(s.spatialReference,t)||n()||c(s.spatialReference,t)||(this._loadingProjectionEngine=!0,await l(),this._loadingProjectionEngine=!1),a!==this.nextBasemap||e!==this.activeBasemap)return}s.map.basemap=a,r||null==this._nextBasemapSpatialReferenceTask.spatialReference||m(s.spatialReference,this._nextBasemapSpatialReferenceTask.spatialReference)||(s.spatialReference=this._nextBasemapSpatialReferenceTask.spatialReference),this.nextBasemap=e}static getThumbnailUrl(e){return u(e)}};e([r()],g.prototype,"_loadingProjectionEngine",void 0),e([r({readOnly:!0})],g.prototype,"_nextBasemapSpatialReferenceTask",null),e([r({readOnly:!0})],g.prototype,"_viewSpatialReferenceLocked",null),e([r({readOnly:!0})],g.prototype,"activeBasemap",null),e([r()],g.prototype,"nextBasemap",void 0),e([p("nextBasemap")],g.prototype,"castNextBasemap",null),e([r({readOnly:!0})],g.prototype,"state",null),e([r()],g.prototype,"view",void 0),e([r()],g.prototype,"toggle",null),g=e([o("esri.widgets.BasemapToggle.BasemapToggleViewModel")],g);const B=g;export{B as default};
5
+ import{_ as e}from"../../chunks/tslib.es6.js";import a from"../../core/Accessor.js";import{watch as t,initial as s,whenOnce as i}from"../../core/reactiveUtils.js";import{property as r}from"../../core/accessorSupport/decorators/property.js";import{cast as p}from"../../core/accessorSupport/decorators/cast.js";import"../../core/has.js";import"../../core/RandomLCG.js";import{subclass as o}from"../../core/accessorSupport/decorators/subclass.js";import{isLoaded as n,canProjectWithoutEngine as c,load as l}from"../../geometry/projectionUtils.js";import{equals as m}from"../../geometry/support/spatialReferenceUtils.js";import{basemapEnsureType as h,destroyCache as f}from"../../support/basemapEnsureType.js";import{findSpatialReference as d,getBasemapThumbnailUrl as u}from"../../support/basemapUtils.js";let g=class extends a{constructor(e){super(e),this._basemapCache={},this._loadingProjectionEngine=!1,this.nextBasemap=h("hybrid",this._basemapCache),this.view=null}initialize(){t((()=>this.nextBasemap),(e=>{e&&!e.loaded&&e.load().catch((()=>{}))}),s)}destroy(){this.view=null,f(this._basemapCache),this._basemapCache=null}get _nextBasemapSpatialReferenceTask(){return d(this.view,this.nextBasemap)}get _viewSpatialReferenceLocked(){const{view:e}=this;return!e||!("spatialReferenceLocked"in e)||e.spatialReferenceLocked}get activeBasemap(){return h(this.view?.map?.basemap??"topo-vector",this._basemapCache)}castNextBasemap(e){return h(e,this._basemapCache)}get state(){const{view:e}=this;if(!e?.ready)return"disabled";if(this._nextBasemapSpatialReferenceTask.updating)return"disabled";const{spatialReference:a}=this._nextBasemapSpatialReferenceTask;return this._viewSpatialReferenceLocked&&null!=a&&!e.spatialReference.equals(a)?"incompatible-next-basemap":this._loadingProjectionEngine?"loading":"ready"}async toggle(){const{activeBasemap:e,nextBasemap:a,state:t,view:s}=this;if(!s||"disabled"===t||"incompatible-next-basemap"===t)return;const r=this._viewSpatialReferenceLocked;if(!r){if(await i((()=>!this._nextBasemapSpatialReferenceTask.updating)),a!==this.nextBasemap||e!==this.activeBasemap)return;const{spatialReference:t}=this._nextBasemapSpatialReferenceTask;if(null==t||m(s.spatialReference,t)||n()||c(s.spatialReference,t)||(this._loadingProjectionEngine=!0,await l(),this._loadingProjectionEngine=!1),a!==this.nextBasemap||e!==this.activeBasemap)return}s.map.basemap=a,r||null==this._nextBasemapSpatialReferenceTask.spatialReference||m(s.spatialReference,this._nextBasemapSpatialReferenceTask.spatialReference)||(s.spatialReference=this._nextBasemapSpatialReferenceTask.spatialReference),this.nextBasemap=e}static getThumbnailUrl(e){return u(e)}};e([r()],g.prototype,"_loadingProjectionEngine",void 0),e([r({readOnly:!0})],g.prototype,"_nextBasemapSpatialReferenceTask",null),e([r({readOnly:!0})],g.prototype,"_viewSpatialReferenceLocked",null),e([r({readOnly:!0})],g.prototype,"activeBasemap",null),e([r()],g.prototype,"nextBasemap",void 0),e([p("nextBasemap")],g.prototype,"castNextBasemap",null),e([r({readOnly:!0})],g.prototype,"state",null),e([r()],g.prototype,"view",void 0),e([r()],g.prototype,"toggle",null),g=e([o("esri.widgets.BasemapToggle.BasemapToggleViewModel")],g);const B=g;export{B as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
4
  */
5
- import{_ as t}from"../../chunks/tslib.es6.js";import{getAssetUrl as e}from"../../assets.js";import o from"../../Graphic.js";import"../../intl.js";import i from"../../core/Collection.js";import s from"../../core/Error.js";import r from"../../core/Evented.js";import n from"../../core/Logger.js";import{watch as a,initial as h,when as c}from"../../core/reactiveUtils.js";import{property as d}from"../../core/accessorSupport/decorators/property.js";import{cast as l}from"../../core/accessorSupport/decorators/cast.js";import"../../core/has.js";import"../../core/RandomLCG.js";import{subclass as m}from"../../core/accessorSupport/decorators/subclass.js";import p from"../../geometry/Point.js";import{load as v}from"../../geometry/projection.js";import u from"../../symbols/PictureMarkerSymbol.js";import{pointSymbolTypes as f}from"../../symbols/support/typeUtils.js";import g from"./support/Conversion.js";import{isValidPoint as w,isSupportedNotation as _}from"./support/coordinateConversionUtils.js";import y from"./support/Format.js";import{generateDefaultFormats as C,setDefaultPatterns as b}from"./support/formatUtils.js";import L from"../support/GoTo.js";import{fetchMessageBundle as M}from"../../intl/messages.js";import{onLocaleChange as j,getLocale as P}from"../../intl/locale.js";const S={default:"default",crosshair:"crosshair"},F=new p([0,0,500]),G="xy",H=["mgrs","utm","usng","dd","dms","ddm"],E="esri__coordinateConversionWidgetState",x={conversions:"conversions",formats:"formats",view:"view",viewChange:"view-change"},T="esri/images/search/search-symbol-32.png";let W=class extends(L(r.EventedAccessor)){constructor(t){super(t),this._conversionPromise=null,this._locationGraphic=null,this._pointerCount=0,this.conversions=new i,this.formats=new i,this.formatterAvailable=!1,this.messages=null,this.filteredFormats=new i,this.locationSymbol=new u({url:e(T),width:24,height:24}),this.storageEnabled=!0,this.storageType="session",this.view=null,this._saveWidgetState=this._saveWidgetState.bind(this),this._handleFormatChange=this._handleFormatChange.bind(this),this._handleConversionChange=this._handleConversionChange.bind(this),this._handleViewChange=this._handleViewChange.bind(this),this._onClick=this._onClick.bind(this),this._onPointerMove=this._onPointerMove.bind(this),this._onPointerDown=this._onPointerDown.bind(this),this._onPointerUp=this._onPointerUp.bind(this)}initialize(){const t=async()=>this.messages=await M("esri/widgets/CoordinateConversion/t9n/CoordinateConversion");this.formats.addMany(C()),t().then((()=>{if(!this.destroyed&&(b(this.messages,this.formats),this.storageEnabled&&this._loadWidgetState(),this.formats.forEach((t=>{t.viewModel=this,this.addHandles(a((()=>t.currentPattern),this._saveWidgetState),t.name??"unnamed-format")})),this.addHandles(this.conversions.on("change",this._handleConversionChange),x.conversions),this.addHandles(this.formats.on("change",this._handleFormatChange),x.formats),this.addHandles(j((()=>{t().then((()=>{b(this.messages,this.formats)}))}))),v().then((()=>{this.formatterAvailable=!0})).catch((t=>{n.getLogger(this).error(new s("coordinate-conversion:projection-load-failed","Failed to load the projection module.",{error:t})),this.formatterAvailable=!1,this._filterFormatsAndConversions()})).then((()=>this.addHandles(a((()=>this.view),this._handleViewChange,h),x.viewChange))),0===this.conversions.length)){const t=this.formats.find((t=>t.name===G))||this.formats.at(0);this.conversions.add(new g({format:t}))}}))}destroy(){this.removeHandles(),this._cleanUpView(this.view),this.view=null}castConversions(t){return this._castToConversions(t)}set currentLocation(t){this._set("currentLocation",t),this._updateConversions()}get currentLocation(){return this._get("currentLocation")||null}set mode(t){switch(t){case"capture":this.currentLocation=null,this._startCaptureMode(),this._set("mode",t);break;case"live":this._startLiveMode(),this._set("mode",t)}}get mode(){return this._get("mode")||"live"}get state(){const{messages:t,view:e}=this,o=e?.ready;return t?o?"ready":e?"loading":"disabled":"disabled"}get storage(){const{storageType:t}=this;return"session"===t?sessionStorage:localStorage}get waitingForConversions(){return null!=this._conversionPromise}setLocation(t){if(this._locationGraphic&&this.view?.graphics.remove(this._locationGraphic),!t)return;const e=t.clone();e.hasZ&&(e.z=void 0),this._locationGraphic=new o({geometry:e,symbol:this.locationSymbol}),this.view?.graphics.add(this._locationGraphic)}async convert(t,e){if(!w(e))throw new s("coordinate-conversion:invalid-point","Invalid point cannot be converted.",{point:e});return Promise.resolve().then((()=>t.convert(e)))}async goToLocation(t){const{view:e}=this;if(!e)throw new s("coordinate-conversion:go-to-failed","no view");const o="3d"===e.type?e.clippingArea:null,i=e.map?.basemap?.baseLayers;if(o||(i?.length??0)>0){const e=o??i?.at(0)?.fullExtent;if(null!=e&&!e.contains(t))throw new s("coordinate-conversion:go-to-failed","Point outside basemap extent.",{point:t})}return this.callGoTo({target:t})}pause(){this.currentLocation=null,this.removeHandles(x.view),this.view&&(this.view.cursor=S.default,this._locationGraphic&&this.view.graphics.remove(this._locationGraphic))}async previewConversion(t,e=this.currentLocation||F){return(await A(t,e)).displayCoordinate}resume(){"capture"===this.mode?this._startCaptureMode():this._startLiveMode()}reverseConvert(t,e){return e.reverseConvert(t)}async updateConversions(t,e){if("point"!==e?.type)throw this._clearConversions(this.conversions),new s("coordinate-conversion:invalid-input-point","Point is invalid, conversions cannot be updated.",{point:e});return this._convertMany(t,e)}_castToConversions(t){const e=new i;return t.forEach((t=>{let o=null;if(t instanceof g)o=t;else if("string"==typeof t){const e=this.formats.find((e=>e.name===t));e&&(o=new g({format:e}))}o&&e.add(o)})),e}_cleanUpView(t){t&&(this._locationGraphic&&t.graphics.remove(this._locationGraphic),this.removeHandles(x.view),t.cursor=S.default)}_clearConversions(t){t.forEach((t=>{t.position={location:null,coordinate:null}}))}async _convertMany(t,e){return Promise.all(t.map((t=>A(t,e))))}_handleConversionChange(t){for(const e of t.added){const{format:t}=e;t&&(t.viewModel=this,this.currentLocation&&(this._set("waitingForConversions",!0),this.convert(t,this.currentLocation).then((t=>{e.position=t,this._set("waitingForConversions",!1)}))))}this._saveWidgetState()}_handleFormatChange(t){t.added.forEach((t=>{this.addHandles(a((()=>t.currentPattern),this._saveWidgetState),t.name??"unnamed-format"),t.viewModel=this})),t.removed.forEach((t=>{t.viewModel=null;const e=this.conversions.filter((e=>e.format===t));this.conversions.removeMany(e),t.name&&this.removeHandles(t.name)}))}_loadWidgetState(){try{const t=JSON.parse(this.storage.getItem(E));t&&this._setWidgetState(t)}catch(t){n.getLogger(this).error(new s("coordinate-conversion:invalid-session-storage-json","Could not read from storage.",{error:t}))}}_startCaptureMode(){this.removeHandles(x.view),this.view&&(this.view.cursor=S.crosshair,this.currentLocation&&this.setLocation(this.currentLocation),this.addHandles(this.view.on("click",this._onClick),x.view))}_startLiveMode(){this._pointerCount=0,this.removeHandles(x.view),this.view&&(this.view.cursor=S.default,this._locationGraphic&&this.view.graphics.remove(this._locationGraphic),this.addHandles([this.view.on("pointer-down",this._onPointerDown),this.view.on("pointer-up",this._onPointerUp),this.view.on("pointer-move",this._onPointerMove)],x.view))}_handleViewChange(t,e){e&&e!==t&&this._cleanUpView(e),t&&("capture"===this.mode?this._startCaptureMode():this._startLiveMode(),e&&this._filterFormatsAndConversions())}_onClick(t){if(0===t.button){const e=this.view?.toMap(t),o=e?.normalize();this.setLocation(o),this.currentLocation=o}}_onPointerDown(t){const{pointerType:e}=t;if(this._pointerCount++,("touch"===e||"pen"===e)&&1===this._pointerCount){const e=this.view?.toMap(t);this.currentLocation=e?.normalize()}}_onPointerMove(t){const{pointerType:e}=t;if("mouse"===e||1===this._pointerCount){const e=this.view?.toMap(t);this.currentLocation=e?.normalize()}}_onPointerUp(){this._pointerCount--}_setWidgetState(t){try{t.formats.forEach((e=>{const o=this.formats.find((t=>t.name===e.name));o&&t.locale===P()&&e.currentPattern&&(o.currentPattern=e.currentPattern),o&&e.index>=0&&this.conversions.add(new g({format:o}))}))}catch(e){n.getLogger(this).warn(new s("coordinate-conversion:session-storage-read-error","Could not get widget state from stored JSON.",{error:e}))}}_saveWidgetState(){if(!this.storageEnabled)return;const t=this._toJSON();try{this.storage.setItem(E,JSON.stringify({formats:t,locale:P()}))}catch(e){n.getLogger(this).error(new s("coordinate-conversion:local-storage-write-error","Could not write to localStorage.",{error:e}))}}async _updateConversions(){try{await this.updateConversions(this.conversions.toArray(),this.currentLocation)}catch{}}_toJSON(){return this.formats.filter((t=>{const e=t.name;return"xy"===e||"basemap"===e||_(e)})).map((t=>({name:t.name,currentPattern:t.currentPattern,defaultPattern:t.defaultPattern,index:this.conversions.findIndex((e=>e.format===t))}))).sort(((t,e)=>t.index-e.index)).toArray()}_filterFormatsAndConversions(){const{formatterAvailable:t,conversions:e,formats:o}=this;t||this.addHandles(c((()=>this.view?.spatialReference),(t=>{const i=t.isWebMercator||t.isWGS84,s=o.filter((t=>{const{name:e}=t;return!!U(e)||"xy"===e&&!i})),r=this.filteredFormats.filter((t=>"xy"===t.name&&i&&!this.formats.includes(t))),n=e.filter((t=>s.includes(t.format)));o.removeMany(s),e.removeMany(n),this.filteredFormats.addMany(s.filter((t=>!this.filteredFormats.includes(t)))),o.addMany(r)}),{once:!0,initial:!0}),x.view)}};async function A(t,e){try{t.position=await(t.format?.convert(e))}catch(o){t.position=null}return t}function U(t){return H.includes(t)}t([d({type:i.ofType(g)})],W.prototype,"conversions",void 0),t([l("conversions")],W.prototype,"castConversions",null),t([d({type:p})],W.prototype,"currentLocation",null),t([d({type:i.ofType(y)})],W.prototype,"formats",void 0),t([d()],W.prototype,"messages",void 0),t([d()],W.prototype,"mode",null),t([d()],W.prototype,"filteredFormats",void 0),t([d({readOnly:!0})],W.prototype,"state",null),t([d({types:f})],W.prototype,"locationSymbol",void 0),t([d({readOnly:!0,dependsOn:["storageType"]})],W.prototype,"storage",null),t([d()],W.prototype,"storageEnabled",void 0),t([d()],W.prototype,"storageType",void 0),t([d({readOnly:!0})],W.prototype,"waitingForConversions",null),t([d()],W.prototype,"view",void 0),W=t([m("esri.widgets.CoordinateConversion.CoordinateConversionViewModel")],W);const O=W;export{O as default};
5
+ import{_ as t}from"../../chunks/tslib.es6.js";import{getAssetUrl as e}from"../../assets.js";import o from"../../Graphic.js";import"../../intl.js";import i from"../../core/Collection.js";import s from"../../core/Error.js";import r from"../../core/Evented.js";import n from"../../core/Logger.js";import{watch as a,initial as h,when as c}from"../../core/reactiveUtils.js";import{property as d}from"../../core/accessorSupport/decorators/property.js";import{cast as l}from"../../core/accessorSupport/decorators/cast.js";import"../../core/has.js";import"../../core/RandomLCG.js";import{subclass as m}from"../../core/accessorSupport/decorators/subclass.js";import p from"../../geometry/Point.js";import{load as v}from"../../geometry/projectionUtils.js";import u from"../../symbols/PictureMarkerSymbol.js";import{pointSymbolTypes as f}from"../../symbols/support/typeUtils.js";import g from"./support/Conversion.js";import{isValidPoint as w,isSupportedNotation as _}from"./support/coordinateConversionUtils.js";import y from"./support/Format.js";import{generateDefaultFormats as C,setDefaultPatterns as b}from"./support/formatUtils.js";import L from"../support/GoTo.js";import{fetchMessageBundle as M}from"../../intl/messages.js";import{onLocaleChange as j,getLocale as P}from"../../intl/locale.js";const S={default:"default",crosshair:"crosshair"},F=new p([0,0,500]),G="xy",H=["mgrs","utm","usng","dd","dms","ddm"],E="esri__coordinateConversionWidgetState",x={conversions:"conversions",formats:"formats",view:"view",viewChange:"view-change"},T="esri/images/search/search-symbol-32.png";let W=class extends(L(r.EventedAccessor)){constructor(t){super(t),this._conversionPromise=null,this._locationGraphic=null,this._pointerCount=0,this.conversions=new i,this.formats=new i,this.formatterAvailable=!1,this.messages=null,this.filteredFormats=new i,this.locationSymbol=new u({url:e(T),width:24,height:24}),this.storageEnabled=!0,this.storageType="session",this.view=null,this._saveWidgetState=this._saveWidgetState.bind(this),this._handleFormatChange=this._handleFormatChange.bind(this),this._handleConversionChange=this._handleConversionChange.bind(this),this._handleViewChange=this._handleViewChange.bind(this),this._onClick=this._onClick.bind(this),this._onPointerMove=this._onPointerMove.bind(this),this._onPointerDown=this._onPointerDown.bind(this),this._onPointerUp=this._onPointerUp.bind(this)}initialize(){const t=async()=>this.messages=await M("esri/widgets/CoordinateConversion/t9n/CoordinateConversion");this.formats.addMany(C()),t().then((()=>{if(!this.destroyed&&(b(this.messages,this.formats),this.storageEnabled&&this._loadWidgetState(),this.formats.forEach((t=>{t.viewModel=this,this.addHandles(a((()=>t.currentPattern),this._saveWidgetState),t.name??"unnamed-format")})),this.addHandles(this.conversions.on("change",this._handleConversionChange),x.conversions),this.addHandles(this.formats.on("change",this._handleFormatChange),x.formats),this.addHandles(j((()=>{t().then((()=>{b(this.messages,this.formats)}))}))),v().then((()=>{this.formatterAvailable=!0})).catch((t=>{n.getLogger(this).error(new s("coordinate-conversion:projection-load-failed","Failed to load the projection module.",{error:t})),this.formatterAvailable=!1,this._filterFormatsAndConversions()})).then((()=>this.addHandles(a((()=>this.view),this._handleViewChange,h),x.viewChange))),0===this.conversions.length)){const t=this.formats.find((t=>t.name===G))||this.formats.at(0);this.conversions.add(new g({format:t}))}}))}destroy(){this.removeHandles(),this._cleanUpView(this.view),this.view=null}castConversions(t){return this._castToConversions(t)}set currentLocation(t){this._set("currentLocation",t),this._updateConversions()}get currentLocation(){return this._get("currentLocation")||null}set mode(t){switch(t){case"capture":this.currentLocation=null,this._startCaptureMode(),this._set("mode",t);break;case"live":this._startLiveMode(),this._set("mode",t)}}get mode(){return this._get("mode")||"live"}get state(){const{messages:t,view:e}=this,o=e?.ready;return t?o?"ready":e?"loading":"disabled":"disabled"}get storage(){const{storageType:t}=this;return"session"===t?sessionStorage:localStorage}get waitingForConversions(){return null!=this._conversionPromise}setLocation(t){if(this._locationGraphic&&this.view?.graphics.remove(this._locationGraphic),!t)return;const e=t.clone();e.hasZ&&(e.z=void 0),this._locationGraphic=new o({geometry:e,symbol:this.locationSymbol}),this.view?.graphics.add(this._locationGraphic)}async convert(t,e){if(!w(e))throw new s("coordinate-conversion:invalid-point","Invalid point cannot be converted.",{point:e});return Promise.resolve().then((()=>t.convert(e)))}async goToLocation(t){const{view:e}=this;if(!e)throw new s("coordinate-conversion:go-to-failed","no view");const o="3d"===e.type?e.clippingArea:null,i=e.map?.basemap?.baseLayers;if(o||(i?.length??0)>0){const e=o??i?.at(0)?.fullExtent;if(null!=e&&!e.contains(t))throw new s("coordinate-conversion:go-to-failed","Point outside basemap extent.",{point:t})}return this.callGoTo({target:t})}pause(){this.currentLocation=null,this.removeHandles(x.view),this.view&&(this.view.cursor=S.default,this._locationGraphic&&this.view.graphics.remove(this._locationGraphic))}async previewConversion(t,e=this.currentLocation||F){return(await U(t,e)).displayCoordinate}resume(){"capture"===this.mode?this._startCaptureMode():this._startLiveMode()}reverseConvert(t,e){return e.reverseConvert(t)}async updateConversions(t,e){if("point"!==e?.type)throw this._clearConversions(this.conversions),new s("coordinate-conversion:invalid-input-point","Point is invalid, conversions cannot be updated.",{point:e});return this._convertMany(t,e)}_castToConversions(t){const e=new i;return t.forEach((t=>{let o=null;if(t instanceof g)o=t;else if("string"==typeof t){const e=this.formats.find((e=>e.name===t));e&&(o=new g({format:e}))}o&&e.add(o)})),e}_cleanUpView(t){t&&(this._locationGraphic&&t.graphics.remove(this._locationGraphic),this.removeHandles(x.view),t.cursor=S.default)}_clearConversions(t){t.forEach((t=>{t.position={location:null,coordinate:null}}))}async _convertMany(t,e){return Promise.all(t.map((t=>U(t,e))))}_handleConversionChange(t){for(const e of t.added){const{format:t}=e;t&&(t.viewModel=this,this.currentLocation&&(this._set("waitingForConversions",!0),this.convert(t,this.currentLocation).then((t=>{e.position=t,this._set("waitingForConversions",!1)}))))}this._saveWidgetState()}_handleFormatChange(t){t.added.forEach((t=>{this.addHandles(a((()=>t.currentPattern),this._saveWidgetState),t.name??"unnamed-format"),t.viewModel=this})),t.removed.forEach((t=>{t.viewModel=null;const e=this.conversions.filter((e=>e.format===t));this.conversions.removeMany(e),t.name&&this.removeHandles(t.name)}))}_loadWidgetState(){try{const t=JSON.parse(this.storage.getItem(E));t&&this._setWidgetState(t)}catch(t){n.getLogger(this).error(new s("coordinate-conversion:invalid-session-storage-json","Could not read from storage.",{error:t}))}}_startCaptureMode(){this.removeHandles(x.view),this.view&&(this.view.cursor=S.crosshair,this.currentLocation&&this.setLocation(this.currentLocation),this.addHandles(this.view.on("click",this._onClick),x.view))}_startLiveMode(){this._pointerCount=0,this.removeHandles(x.view),this.view&&(this.view.cursor=S.default,this._locationGraphic&&this.view.graphics.remove(this._locationGraphic),this.addHandles([this.view.on("pointer-down",this._onPointerDown),this.view.on("pointer-up",this._onPointerUp),this.view.on("pointer-move",this._onPointerMove)],x.view))}_handleViewChange(t,e){e&&e!==t&&this._cleanUpView(e),t&&("capture"===this.mode?this._startCaptureMode():this._startLiveMode(),e&&this._filterFormatsAndConversions())}_onClick(t){if(0===t.button){const e=this.view?.toMap(t),o=e?.normalize();this.setLocation(o),this.currentLocation=o}}_onPointerDown(t){const{pointerType:e}=t;if(this._pointerCount++,("touch"===e||"pen"===e)&&1===this._pointerCount){const e=this.view?.toMap(t);this.currentLocation=e?.normalize()}}_onPointerMove(t){const{pointerType:e}=t;if("mouse"===e||1===this._pointerCount){const e=this.view?.toMap(t);this.currentLocation=e?.normalize()}}_onPointerUp(){this._pointerCount--}_setWidgetState(t){try{t.formats.forEach((e=>{const o=this.formats.find((t=>t.name===e.name));o&&t.locale===P()&&e.currentPattern&&(o.currentPattern=e.currentPattern),o&&e.index>=0&&this.conversions.add(new g({format:o}))}))}catch(e){n.getLogger(this).warn(new s("coordinate-conversion:session-storage-read-error","Could not get widget state from stored JSON.",{error:e}))}}_saveWidgetState(){if(!this.storageEnabled)return;const t=this._toJSON();try{this.storage.setItem(E,JSON.stringify({formats:t,locale:P()}))}catch(e){n.getLogger(this).error(new s("coordinate-conversion:local-storage-write-error","Could not write to localStorage.",{error:e}))}}async _updateConversions(){try{await this.updateConversions(this.conversions.toArray(),this.currentLocation)}catch{}}_toJSON(){return this.formats.filter((t=>{const e=t.name;return"xy"===e||"basemap"===e||_(e)})).map((t=>({name:t.name,currentPattern:t.currentPattern,defaultPattern:t.defaultPattern,index:this.conversions.findIndex((e=>e.format===t))}))).sort(((t,e)=>t.index-e.index)).toArray()}_filterFormatsAndConversions(){const{formatterAvailable:t,conversions:e,formats:o}=this;t||this.addHandles(c((()=>this.view?.spatialReference),(t=>{const i=t.isWebMercator||t.isWGS84,s=o.filter((t=>{const{name:e}=t;return!!A(e)||"xy"===e&&!i})),r=this.filteredFormats.filter((t=>"xy"===t.name&&i&&!this.formats.includes(t))),n=e.filter((t=>s.includes(t.format)));o.removeMany(s),e.removeMany(n),this.filteredFormats.addMany(s.filter((t=>!this.filteredFormats.includes(t)))),o.addMany(r)}),{once:!0,initial:!0}),x.view)}};async function U(t,e){try{t.position=await(t.format?.convert(e))}catch(o){t.position=null}return t}function A(t){return H.includes(t)}t([d({type:i.ofType(g)})],W.prototype,"conversions",void 0),t([l("conversions")],W.prototype,"castConversions",null),t([d({type:p})],W.prototype,"currentLocation",null),t([d({type:i.ofType(y)})],W.prototype,"formats",void 0),t([d()],W.prototype,"messages",void 0),t([d()],W.prototype,"mode",null),t([d()],W.prototype,"filteredFormats",void 0),t([d({readOnly:!0})],W.prototype,"state",null),t([d({types:f})],W.prototype,"locationSymbol",void 0),t([d({readOnly:!0,dependsOn:["storageType"]})],W.prototype,"storage",null),t([d()],W.prototype,"storageEnabled",void 0),t([d()],W.prototype,"storageType",void 0),t([d({readOnly:!0})],W.prototype,"waitingForConversions",null),t([d()],W.prototype,"view",void 0),W=t([m("esri.widgets.CoordinateConversion.CoordinateConversionViewModel")],W);const O=W;export{O as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../core/Accessor.js";import r from"../../../core/Error.js";import"../../../core/has.js";import{property as n}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as o}from"../../../core/accessorSupport/decorators/subclass.js";import{fromUsng as i,fromUtm as s,fromMgrs as a,fromLatitudeLongitude as l,toUtm as c,toUsng as p,toMgrs as u,toLatitudeLongitude as m}from"../../../geometry/coordinateFormatter.js";import{isLoaded as h,project as d}from"../../../geometry/projection.js";import f from"../../../geometry/SpatialReference.js";import{equals as v}from"../../../geometry/support/spatialReferenceUtils.js";import{project as g}from"../../../geometry/support/webMercatorUtils.js";import{isValidPoint as y,fromXY as w,pointToCoordinate as b,getDegreePrecision as S}from"./coordinateConversionUtils.js";let _=class extends t{constructor(e){super(e),this.conversionInfo=null,this.coordinateSegments=null,this._currentPattern=void 0,this.defaultPattern=null,this.name=null,this.viewModel=null}get currentPattern(){return(this._currentPattern||this.defaultPattern)??""}set currentPattern(e){this._currentPattern=e}get label(){return this.name??""}set label(e){this._overrideIfSome("label",e)}get hasDisplayProperties(){return!(!this.defaultPattern||!this.coordinateSegments)}get spatialReference(){return"basemap"===this.name?this._viewSpatialReference:this.conversionInfo?.spatialReference??f.WGS84}set spatialReference(e){this._overrideIfSome("spatialReference",e)}get _viewSpatialReference(){return this.viewModel?.view?.spatialReference??f.WGS84}get _additionalCharactersPattern(){const e=this.coordinateSegments;if(!e)return null;const t=e.map((e=>e.alias)),r=this.currentPattern.replaceAll(new RegExp(`["nsew${t.join()}]`,"gi"),"").replaceAll(" ","");return new RegExp(`[${r}]`,"g")}get test(){}async convert(e){if(!y(e))throw new r("format:invalid-point","Could not convert invalid point.",{point:e});const t=this.conversionInfo?.convert;if(t)return Promise.resolve().then((()=>t(e)));const n=await this._project(e,this.spatialReference);return{location:n,coordinate:await this._getCoordinate(n)}}getConversionStrategy(){const e=this._viewSpatialReference;return this.conversionInfo?.convert||this.viewModel?.formatterAvailable||"xy"===this.name&&(e.isWebMercator||e.isWGS84)||"basemap"===this.name?"client":"server"}getDisplayCoordinate(e){if(!e)return null;if(!this.coordinateSegments||!this.currentPattern)return e;let t=this.currentPattern;const r=this._getSegmentMatches(e,!1);for(let n=this.coordinateSegments.length-1;n>=0;n--){const e=this.coordinateSegments[n];t=t.replace(e.alias,r[n])}return t}_parseUserInput(e){const{defaultPattern:t,_additionalCharactersPattern:r,coordinateSegments:n}=this;if(!t||!r)return"";let o=t.replace(r,"");e=e.replace(r,"");const i=this._getSegmentMatches(e,!0);if(n)for(let s=n.length-1;s>=0;s--){const e=n[s];o=o.replace(e.alias,i[s])}return o}_getSegmentMatches(e,t){const r=new Array,{coordinateSegments:n}=this;if(!n)return r;for(let o=0;o<n.length;o++){const i=n[o],s=e.match(i.searchPattern);if(!s){r.push("");continue}let a=s[0];if(e=e.replace(a,"").trim(),i.substitution){const e=t?i.substitution.input(a):i.substitution.output(a);e&&(a=`${e}`)}r.push(a)}return r}async reverseConvert(e){const t=this._parseUserInput(e),n=this.conversionInfo?.reverseConvert;let o;if(n)o=n(t);else if("xy"===this.name||"basemap"===this.name)o=w(t,this.spatialReference);else if(this.viewModel?.formatterAvailable)switch(this.name){case"dd":case"ddm":case"dms":o=l(t,this.spatialReference);break;case"mgrs":{const e="automatic";o=a(t,this.spatialReference,e);break}case"utm":{const e="latitude-band-indicators";o=s(t,this.spatialReference,e);break}case"usng":o=i(t,this.spatialReference);break;default:o=null}if(!o)throw new r("format:invalid-input","Could not parse input into point.",{userInput:e});return this._project(o,this._viewSpatialReference)}async _getCoordinate(e){const t=this.viewModel?.view?.scale??0;if(!y(e))throw new r("format:invalid-point","Could not transform invalid point into coordinate.",{point:e});if(this.viewModel?.formatterAvailable||"basemap"===this.name||"xy"===this.name)switch(this.name){case"dd":case"ddm":case"dms":{const r=S(t);return m(e,this.name,r)}case"mgrs":return u(e,"automatic",5,!1);case"usng":return p(e,5,!1);case"utm":return c(e,"latitude-band-indicators",!0);default:return b(e,t)}return b(e,t)}async _project(e,t){if(v(e.spatialReference,t)||!t)return e;if(this.viewModel?.formatterAvailable&&h())return d(e,t);if(!this.viewModel?.formatterAvailable){const r=g(e,t);if(null!=r)return r}return null}};e([n()],_.prototype,"conversionInfo",void 0),e([n()],_.prototype,"coordinateSegments",void 0),e([n()],_.prototype,"currentPattern",null),e([n()],_.prototype,"_currentPattern",void 0),e([n()],_.prototype,"label",null),e([n()],_.prototype,"defaultPattern",void 0),e([n({readOnly:!0})],_.prototype,"hasDisplayProperties",null),e([n()],_.prototype,"name",void 0),e([n({type:f})],_.prototype,"spatialReference",null),e([n()],_.prototype,"viewModel",void 0),e([n({readOnly:!0})],_.prototype,"_viewSpatialReference",null),e([n({readOnly:!0})],_.prototype,"_additionalCharactersPattern",null),_=e([o("esri.widgets.CoordinateConversion.support.Format")],_);const R=_;export{R as default};
5
+ import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../core/Accessor.js";import r from"../../../core/Error.js";import"../../../core/has.js";import{property as n}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as o}from"../../../core/accessorSupport/decorators/subclass.js";import{fromUsng as i,fromUtm as s,fromMgrs as a,fromLatitudeLongitude as l,toUtm as c,toUsng as p,toMgrs as u,toLatitudeLongitude as m}from"../../../geometry/coordinateFormatter.js";import{isLoaded as h,project as d}from"../../../geometry/projectionUtils.js";import f from"../../../geometry/SpatialReference.js";import{equals as v}from"../../../geometry/support/spatialReferenceUtils.js";import{project as g}from"../../../geometry/support/webMercatorUtils.js";import{isValidPoint as y,fromXY as w,pointToCoordinate as b,getDegreePrecision as S}from"./coordinateConversionUtils.js";let _=class extends t{constructor(e){super(e),this.conversionInfo=null,this.coordinateSegments=null,this._currentPattern=void 0,this.defaultPattern=null,this.name=null,this.viewModel=null}get currentPattern(){return(this._currentPattern||this.defaultPattern)??""}set currentPattern(e){this._currentPattern=e}get label(){return this.name??""}set label(e){this._overrideIfSome("label",e)}get hasDisplayProperties(){return!(!this.defaultPattern||!this.coordinateSegments)}get spatialReference(){return"basemap"===this.name?this._viewSpatialReference:this.conversionInfo?.spatialReference??f.WGS84}set spatialReference(e){this._overrideIfSome("spatialReference",e)}get _viewSpatialReference(){return this.viewModel?.view?.spatialReference??f.WGS84}get _additionalCharactersPattern(){const e=this.coordinateSegments;if(!e)return null;const t=e.map((e=>e.alias)),r=this.currentPattern.replaceAll(new RegExp(`["nsew${t.join()}]`,"gi"),"").replaceAll(" ","");return new RegExp(`[${r}]`,"g")}get test(){}async convert(e){if(!y(e))throw new r("format:invalid-point","Could not convert invalid point.",{point:e});const t=this.conversionInfo?.convert;if(t)return Promise.resolve().then((()=>t(e)));const n=await this._project(e,this.spatialReference);return{location:n,coordinate:await this._getCoordinate(n)}}getConversionStrategy(){const e=this._viewSpatialReference;return this.conversionInfo?.convert||this.viewModel?.formatterAvailable||"xy"===this.name&&(e.isWebMercator||e.isWGS84)||"basemap"===this.name?"client":"server"}getDisplayCoordinate(e){if(!e)return null;if(!this.coordinateSegments||!this.currentPattern)return e;let t=this.currentPattern;const r=this._getSegmentMatches(e,!1);for(let n=this.coordinateSegments.length-1;n>=0;n--){const e=this.coordinateSegments[n];t=t.replace(e.alias,r[n])}return t}_parseUserInput(e){const{defaultPattern:t,_additionalCharactersPattern:r,coordinateSegments:n}=this;if(!t||!r)return"";let o=t.replace(r,"");e=e.replace(r,"");const i=this._getSegmentMatches(e,!0);if(n)for(let s=n.length-1;s>=0;s--){const e=n[s];o=o.replace(e.alias,i[s])}return o}_getSegmentMatches(e,t){const r=new Array,{coordinateSegments:n}=this;if(!n)return r;for(let o=0;o<n.length;o++){const i=n[o],s=e.match(i.searchPattern);if(!s){r.push("");continue}let a=s[0];if(e=e.replace(a,"").trim(),i.substitution){const e=t?i.substitution.input(a):i.substitution.output(a);e&&(a=`${e}`)}r.push(a)}return r}async reverseConvert(e){const t=this._parseUserInput(e),n=this.conversionInfo?.reverseConvert;let o;if(n)o=n(t);else if("xy"===this.name||"basemap"===this.name)o=w(t,this.spatialReference);else if(this.viewModel?.formatterAvailable)switch(this.name){case"dd":case"ddm":case"dms":o=l(t,this.spatialReference);break;case"mgrs":{const e="automatic";o=a(t,this.spatialReference,e);break}case"utm":{const e="latitude-band-indicators";o=s(t,this.spatialReference,e);break}case"usng":o=i(t,this.spatialReference);break;default:o=null}if(!o)throw new r("format:invalid-input","Could not parse input into point.",{userInput:e});return this._project(o,this._viewSpatialReference)}async _getCoordinate(e){const t=this.viewModel?.view?.scale??0;if(!y(e))throw new r("format:invalid-point","Could not transform invalid point into coordinate.",{point:e});if(this.viewModel?.formatterAvailable||"basemap"===this.name||"xy"===this.name)switch(this.name){case"dd":case"ddm":case"dms":{const r=S(t);return m(e,this.name,r)}case"mgrs":return u(e,"automatic",5,!1);case"usng":return p(e,5,!1);case"utm":return c(e,"latitude-band-indicators",!0);default:return b(e,t)}return b(e,t)}async _project(e,t){if(v(e.spatialReference,t)||!t)return e;if(this.viewModel?.formatterAvailable&&h())return d(e,t);if(!this.viewModel?.formatterAvailable){const r=g(e,t);if(null!=r)return r}return null}};e([n()],_.prototype,"conversionInfo",void 0),e([n()],_.prototype,"coordinateSegments",void 0),e([n()],_.prototype,"currentPattern",null),e([n()],_.prototype,"_currentPattern",void 0),e([n()],_.prototype,"label",null),e([n()],_.prototype,"defaultPattern",void 0),e([n({readOnly:!0})],_.prototype,"hasDisplayProperties",null),e([n()],_.prototype,"name",void 0),e([n({type:f})],_.prototype,"spatialReference",null),e([n()],_.prototype,"viewModel",void 0),e([n({readOnly:!0})],_.prototype,"_viewSpatialReference",null),e([n({readOnly:!0})],_.prototype,"_additionalCharactersPattern",null),_=e([o("esri.widgets.CoordinateConversion.support.Format")],_);const R=_;export{R as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
4
  */
5
- import{_ as t}from"../../chunks/tslib.es6.js";import e from"../../analysis/DirectLineMeasurementAnalysis.js";import{deprecateUnnecessaryViewModel as s}from"../../core/deprecate.js";import i from"../../core/Logger.js";import{watch as r,syncAndInitial as n}from"../../core/reactiveUtils.js";import{measurementLengthUnits as o}from"../../core/unitUtils.js";import{property as l}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/RandomLCG.js";import{subclass as a}from"../../core/accessorSupport/decorators/subclass.js";import{defaultUnitPropertyMetadata as u}from"../../properties/defaultUnit.js";import{AnalysisViewModel as p}from"../support/AnalysisViewModel.js";let c=class extends p{constructor(t){super(t),this.analysis=null,this._userUnitOptions=null,this._userUnit=null,this.supportedViewType="3d",this.unsupportedErrorMessage="DirectLineMeasurement3DViewModel is only supported in 3D views.",t?.isDefaultViewModel||s(i.getLogger(this),"Directline Measurement 3D","arcgis-directline-measurement-3d",{version:"4.33"})}initialize(){this.addHandles(r((()=>({analysis:this.analysis,unit:this.unit})),(({analysis:t,unit:e})=>{null!=t&&(t.unit=e)}),n))}get state(){return this.disabled||!this.ready?"disabled":null==this.tool?"ready":this.tool.state}get measurement(){const{tool:t}=this;if(null==t)return null;const e=()=>({text:null,state:"unavailable"}),s=t=>({text:t,state:"available"}),{analysisViewData:i}=t,r=null!=i.result;return{mode:i.result?.mode??"euclidean",directDistance:r&&"euclidean"===i.actualVisualizedMeasurement?s(i.directLabelText):e(),horizontalDistance:r?s(i.horizontalLabelText):e(),verticalDistance:r?s(i.verticalLabelText):e()}}get unitOptions(){const t=this._userUnitOptions?.filter((t=>o.includes(t)));return t&&t.length>0?t:o.slice()}set unitOptions(t){this._userUnitOptions=t}get unit(){const t=this._userUnit,e=this.unitOptions;if(t&&e.includes(t))return t;const s=this.defaultUnit;return s&&e.includes(s)?s:e[0]}set unit(t){this._userUnit=t}constructAnalysis(){return new e}};t([l({type:e})],c.prototype,"analysis",void 0),t([l({readOnly:!0})],c.prototype,"state",null),t([l({readOnly:!0})],c.prototype,"measurement",null),t([l()],c.prototype,"unitOptions",null),t([l()],c.prototype,"_userUnitOptions",void 0),t([l()],c.prototype,"unit",null),t([l()],c.prototype,"_userUnit",void 0),t([l(u)],c.prototype,"defaultUnit",void 0),c=t([a("esri.widgets.DirectLineMeasurement3D.DirectLineMeasurement3DViewModel")],c);const d=c;export{d as default};
5
+ import{_ as t}from"../../chunks/tslib.es6.js";import e from"../../analysis/DirectLineMeasurementAnalysis.js";import{deprecateUnnecessaryViewModel as s}from"../../core/deprecate.js";import i from"../../core/Logger.js";import{watch as r,syncAndInitial as n}from"../../core/reactiveUtils.js";import{measurementLengthUnits as o}from"../../core/unitUtils.js";import{property as l}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/RandomLCG.js";import{subclass as a}from"../../core/accessorSupport/decorators/subclass.js";import{defaultUnitPropertyMetadata as u}from"../../properties/defaultUnit.js";import{AnalysisViewModel as p}from"../support/AnalysisViewModel.js";let c=class extends p{constructor(t){super(t),this.analysis=null,this._userUnitOptions=null,this._userUnit=null,this.supportedViewType="3d",this.unsupportedErrorMessage="DirectLineMeasurement3DViewModel is only supported in 3D views.",t?.isDefaultViewModel||s(i.getLogger(this),"Direct Line Measurement 3D","arcgis-direct-line-measurement-3d",{version:"4.33"})}initialize(){this.addHandles(r((()=>({analysis:this.analysis,unit:this.unit})),(({analysis:t,unit:e})=>{null!=t&&(t.unit=e)}),n))}get state(){return this.disabled||!this.ready?"disabled":null==this.tool?"ready":this.tool.state}get measurement(){const{tool:t}=this;if(null==t)return null;const e=()=>({text:null,state:"unavailable"}),s=t=>({text:t,state:"available"}),{analysisViewData:i}=t,r=null!=i.result;return{mode:i.result?.mode??"euclidean",directDistance:r&&"euclidean"===i.actualVisualizedMeasurement?s(i.directLabelText):e(),horizontalDistance:r?s(i.horizontalLabelText):e(),verticalDistance:r?s(i.verticalLabelText):e()}}get unitOptions(){const t=this._userUnitOptions?.filter((t=>o.includes(t)));return t&&t.length>0?t:o.slice()}set unitOptions(t){this._userUnitOptions=t}get unit(){const t=this._userUnit,e=this.unitOptions;if(t&&e.includes(t))return t;const s=this.defaultUnit;return s&&e.includes(s)?s:e[0]}set unit(t){this._userUnit=t}constructAnalysis(){return new e}};t([l({type:e})],c.prototype,"analysis",void 0),t([l({readOnly:!0})],c.prototype,"state",null),t([l({readOnly:!0})],c.prototype,"measurement",null),t([l()],c.prototype,"unitOptions",null),t([l()],c.prototype,"_userUnitOptions",void 0),t([l()],c.prototype,"unit",null),t([l()],c.prototype,"_userUnit",void 0),t([l(u)],c.prototype,"defaultUnit",void 0),c=t([a("esri.widgets.DirectLineMeasurement3D.DirectLineMeasurement3DViewModel")],c);const d=c;export{d as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../chunks/tslib.es6.js";import{deprecateWidget as t}from"../core/deprecate.js";import s from"../core/Logger.js";import{ignoreAbortErrors as i}from"../core/promiseUtils.js";import{property as o}from"../core/accessorSupport/decorators/property.js";import"../core/has.js";import"../core/RandomLCG.js";import{subclass as r}from"../core/accessorSupport/decorators/subclass.js";import n from"./Widget.js";import l from"./DirectLineMeasurement3D/DirectLineMeasurement3DViewModel.js";import{globalCss as a}from"./support/globalCss.js";import{MeasurementWidgetContent as u}from"./support/MeasurementWidgetContent.js";import"./support/widgetUtils.js";import{messageBundle as p}from"./support/decorators/messageBundle.js";import{tsx as m}from"./support/jsxFactory.js";const c="esri-direct-line-measurement-3d",d={base:c,newMeasurementButton:`${c}__clear-button`};let v=class extends n{constructor(e,i){super(e,i),this.messages=null,this.messagesCommon=null,this.viewModel=new l({isDefaultViewModel:!0}),t(s.getLogger(this),"Directline Measurement 3D","arcgis-directline-measurement-3d",{version:"4.33"})}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}get visible(){return this.viewModel.visible}set visible(e){this.viewModel.visible=e}get active(){return this.viewModel.active}get analysis(){return this.viewModel.analysis}set analysis(e){this.viewModel.analysis=e}get icon(){return"measure-line"}set icon(e){this._overrideIfSome("icon",e)}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get unitOptions(){return this.viewModel.unitOptions}set unitOptions(e){this.viewModel.unitOptions=e}get unit(){return this.viewModel.unit}set unit(e){this.viewModel.unit=e}render(){const{messages:e,messagesCommon:t,unit:s,unitOptions:o,viewModel:r}=this,{active:n,measurement:l,state:p,supported:c}=r;return m("div",{"aria-label":this.messages.widgetLabel,class:this.classes(d.base,a.widget,a.panel),key:this,role:"presentation"},this.visible?m(u,{active:n,measurementItems:[{key:"direct",title:e.direct,value:g(l?.directDistance)},{key:"horizontal",title:e.horizontal,value:g(l?.horizontalDistance)},{key:"vertical",title:e.vertical,value:g(l?.verticalDistance)}],messages:{...e,notApplicable:t?.notApplicable},newMeasurementButtonClass:d.newMeasurementButton,state:p,supported:c,unit:s,unitOptions:o,onNewMeasurementClick:()=>{i(this.viewModel.start())},onUnitChange:e=>{this.unit=e}}):null)}};function g(e){return"available"===e?.state?e.text:null}e([o()],v.prototype,"view",null),e([o()],v.prototype,"visible",null),e([o()],v.prototype,"active",null),e([o({constructOnly:!0,nonNullable:!0})],v.prototype,"analysis",null),e([o()],v.prototype,"icon",null),e([o()],v.prototype,"label",null),e([o(),p("esri/widgets/DirectLineMeasurement3D/t9n/DirectLineMeasurement3D")],v.prototype,"messages",void 0),e([o(),p("esri/t9n/common")],v.prototype,"messagesCommon",void 0),e([o()],v.prototype,"uiStrings",void 0),e([o({type:l})],v.prototype,"viewModel",void 0),e([o()],v.prototype,"unitOptions",null),e([o()],v.prototype,"unit",null),v=e([r("esri.widgets.DirectLineMeasurement3D")],v);const w=v;export{w as default};
5
+ import{_ as e}from"../chunks/tslib.es6.js";import{deprecateWidget as t}from"../core/deprecate.js";import s from"../core/Logger.js";import{ignoreAbortErrors as i}from"../core/promiseUtils.js";import{property as o}from"../core/accessorSupport/decorators/property.js";import"../core/has.js";import"../core/RandomLCG.js";import{subclass as r}from"../core/accessorSupport/decorators/subclass.js";import n from"./Widget.js";import l from"./DirectLineMeasurement3D/DirectLineMeasurement3DViewModel.js";import{globalCss as a}from"./support/globalCss.js";import{MeasurementWidgetContent as u}from"./support/MeasurementWidgetContent.js";import"./support/widgetUtils.js";import{messageBundle as p}from"./support/decorators/messageBundle.js";import{tsx as m}from"./support/jsxFactory.js";const c="esri-direct-line-measurement-3d",d={base:c,newMeasurementButton:`${c}__clear-button`};let v=class extends n{constructor(e,i){super(e,i),this.messages=null,this.messagesCommon=null,this.viewModel=new l({isDefaultViewModel:!0}),t(s.getLogger(this),"Direct Line Measurement 3D","arcgis-direct-line-measurement-3d",{version:"4.33"})}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}get visible(){return this.viewModel.visible}set visible(e){this.viewModel.visible=e}get active(){return this.viewModel.active}get analysis(){return this.viewModel.analysis}set analysis(e){this.viewModel.analysis=e}get icon(){return"measure-line"}set icon(e){this._overrideIfSome("icon",e)}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get unitOptions(){return this.viewModel.unitOptions}set unitOptions(e){this.viewModel.unitOptions=e}get unit(){return this.viewModel.unit}set unit(e){this.viewModel.unit=e}render(){const{messages:e,messagesCommon:t,unit:s,unitOptions:o,viewModel:r}=this,{active:n,measurement:l,state:p,supported:c}=r;return m("div",{"aria-label":this.messages.widgetLabel,class:this.classes(d.base,a.widget,a.panel),key:this,role:"presentation"},this.visible?m(u,{active:n,measurementItems:[{key:"direct",title:e.direct,value:g(l?.directDistance)},{key:"horizontal",title:e.horizontal,value:g(l?.horizontalDistance)},{key:"vertical",title:e.vertical,value:g(l?.verticalDistance)}],messages:{...e,notApplicable:t?.notApplicable},newMeasurementButtonClass:d.newMeasurementButton,state:p,supported:c,unit:s,unitOptions:o,onNewMeasurementClick:()=>{i(this.viewModel.start())},onUnitChange:e=>{this.unit=e}}):null)}};function g(e){return"available"===e?.state?e.text:null}e([o()],v.prototype,"view",null),e([o()],v.prototype,"visible",null),e([o()],v.prototype,"active",null),e([o({nonNullable:!0})],v.prototype,"analysis",null),e([o()],v.prototype,"icon",null),e([o()],v.prototype,"label",null),e([o(),p("esri/widgets/DirectLineMeasurement3D/t9n/DirectLineMeasurement3D")],v.prototype,"messages",void 0),e([o(),p("esri/t9n/common")],v.prototype,"messagesCommon",void 0),e([o()],v.prototype,"uiStrings",void 0),e([o({type:l})],v.prototype,"viewModel",void 0),e([o()],v.prototype,"unitOptions",null),e([o()],v.prototype,"unit",null),v=e([r("esri.widgets.DirectLineMeasurement3D")],v);const w=v;export{w as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../chunks/tslib.es6.js";import{isSome as t}from"../../core/arrayUtils.js";import{createTask as i}from"../../core/asyncUtils.js";import a from"../../core/Collection.js";import r from"../../core/Error.js";import s from"../../core/Evented.js";import{makeHandle as o}from"../../core/handleUtils.js";import n from"../../core/Logger.js";import{destroyMaybe as l,abortMaybe as p,removeMaybe as c}from"../../core/maybe.js";import{throwIfAborted as d,createResolver as h}from"../../core/promiseUtils.js";import{watch as u,on as w,when as f,syncAndInitial as m,initial as y,sync as g,whenOnce as k}from"../../core/reactiveUtils.js";import{property as v}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import{subclass as _}from"../../core/accessorSupport/decorators/subclass.js";import{UpdatingHandles as W}from"../../core/support/UpdatingHandles.js";import{getTemplatesForLayers as M}from"../../editing/templateUtils.js";import F from"../../layers/GraphicsLayer.js";import{isEditableLayer as E}from"../../layers/support/editableLayers.js";import{isFeatureLayer as b,isSubtypeGroupLayer as V,getOwningPortalUrl as T}from"../../layers/support/layerUtils.js";import{parseKnownArcGISOnlineDomain as I}from"../../portal/support/urlUtils.js";import L from"../../views/SelectionManager.js";import A from"../../views/interactive/sketch/SketchOptions.js";import{SnappingManager as U}from"../../views/interactive/snapping/SnappingManager.js";import S from"../../views/interactive/snapping/SnappingOptions.js";import{isSelectableLayer as C}from"../../views/support/selectionUtils.js";import O from"../Attachments/AttachmentsViewModel.js";import j from"./CreateFeaturesWorkflow.js";import P from"./UpdateFeaturesWorkflow.js";import R from"./UpdateWorkflow.js";import{getLayersFromWorkflow as H,isUpdateWorkflow as G,whenEditorLayerView as x}from"./workflowUtils.js";import D from"./support/EditorItem.js";import{makeTemplateGroupInfoForLayer as B}from"../FeatureTemplates/featureTemplatesUtils.js";import q from"../FeatureTemplates/FeatureTemplatesViewModel.js";import N from"../Sketch/SketchViewModel.js";import Q from"../Spinner/SpinnerViewModel.js";import{goTo as z}from"../support/goToUtils.js";import{isFeatureItem as Z,isLayerItem as $}from"../support/SelectionList/selectionListUtils.js";import J from"../support/SelectionList/SelectionListViewModel.js";import K from"../support/SelectionToolbar/SelectionToolbarViewModel.js";function X(e,t){return e?.find((e=>e.layer===t))}let Y=class extends s.EventedAccessor{constructor(e){super(e),this._templatesByLayer=new Map,this._sketchEventListenerHandle=null,this._sketchGraphicsLayer=new F({listMode:"hide",internal:!0}),this._snappingManager=null,this._updateItemsTask=null,this._updateTemplatesTask=null,this._updatingHandles=new W,this._featureTemplatesViewModelIsRestricted=!1,this.activeWorkflow=null,this._activityQueue=new a,this.editorItems=new a,this.failures=[],this.hideTemplatesForInactiveLayers=!1,this.attachmentsViewModel=new O({capabilities:{editing:!0}}),this.featureTemplatesViewModel=new q({disabledItemFunction:({layer:e})=>this._itemIsSuspended(e)}),this.layerInfos=null,this.ownSketchViewModel=new N({layer:this._sketchGraphicsLayer}),this.selectionListViewModel=new J,this.selectionManager=new L,this.selectionToolbarViewModel=new K,this.sketchOptions=new A,this.snappingOptions=new S({attributeRulesEnabled:!0}),this.spinnerViewModel=new Q,this.pageStack=[],this.showDiscardEditsPrompt=()=>Promise.resolve(!0),this._candidateCommitted=!1,this.back=async()=>{this.selectionToolbarViewModel.cancel(),"viewing-selection-list"!==this.state?this.canGoBack&&(this.activeWorkflow?.hasPreviousStep?await this.activeWorkflow.back(this.showDiscardEditsPrompt):await this._cancelWorkflow({force:!this.hasPendingEdits})):this.effectiveSelectionManager.clear()},this.saveWorkflow=async()=>await(this.activeWorkflow?.save()),this.selectFeature=(e,t=!1)=>{const i=this.activeWorkflow;this._candidateCommitted||"update"!==i?.type||(i.data.rootFeature=e,t&&(i.next(),this._candidateCommitted=!0))}}initialize(){this.addHandles([u((()=>{const e=this.view,t=e?.map?.editableLayers.toArray(),i=e?.allLayerViews,a=i?.filter((e=>!!t?.includes(e.layer)));return[t,a,this.layerInfos]}),(()=>this._updateEditorItems()),m),u((()=>this.hideTemplatesForInactiveLayers),(()=>this.syncFeatureTemplates())),w((()=>this.activeWorkflow),"cancel",(()=>this.emit("workflow-cancel"))),w((()=>this.activeWorkflow),"commit",(()=>this.emit("workflow-commit"))),w((()=>this.activeWorkflow),"complete",(()=>{this.emit("workflow-commit"),this._set("activeWorkflow",null)})),f((()=>this.view?.map),(e=>e.add(this._sketchGraphicsLayer)),y),w((()=>this.editorItems),"change",(()=>this._afterEditorItemsChange())),u((()=>[this.canCreate,this.canUpdateVisible]),(()=>this._afterEditorItemsChange())),u((()=>this.page),((e,t)=>{const i=[...this.pageStack];if(-1===i.indexOf(e))i.push(e);else for(;i.length&&i.at(-1)!==e;)i.pop();this.pageStack=i}),m),f((()=>"awaiting-update-feature-candidate"===this.state),(()=>this._candidateCommitted=!1)),w((()=>this.featureTemplatesViewModel),"select",(async({item:e,oldItem:t})=>{const{activeWorkflow:i}=this;if(i){if("update"===i.type&&"awaiting-feature-creation-info"===i.activeWorkflow?.stepId)return;try{await this.cancelWorkflow({force:!this.hasPendingEdits})}catch{return void this.featureTemplatesViewModel.select(t,{emit:!1})}}if(!e)return;const a={layer:e.layer,template:e.template};if(e.supportsUpload)return this.featureTemplatesViewModel.select(t,{emit:!1}),this.startCreateFeaturesWorkflow(a);this.startCreateFeaturesWorkflowAtFeatureCreation(a)})),u((()=>[this.view,this.featureTemplatesViewModel]),(([e,t])=>{t.view=e}),m),w((()=>this.view),"key-down",(e=>{"Escape"===e.key&&this.activeWorkflow?.keyboardCancellationEnabled&&(e.stopPropagation(),this.back())})),w((()=>this.sketchViewModel),["create","delete","update"],(e=>{const{activeWorkflow:t}=this,i="update"===t?.type,a=H(t),r=i?t?.activeWorkflow?.parentLayer:void 0,s=`sketch-${e.type}`;this.emit(s,{type:s,detail:e,layer:a[0],layers:a,parentLayer:r})}),g),u((()=>this.view),(e=>{if(this._snappingManager=l(this._snappingManager),!e)return;const t=this.snappingOptions;this._snappingManager=new U({view:e,options:t}),this.ownSketchViewModel.snappingManager=this._snappingManager}),m),u((()=>this.snappingOptions),(e=>{this._snappingManager&&(this._snappingManager.options=e)}),m),w((()=>this.selectionToolbarViewModel),"complete",(e=>this._onSelectionComplete(e))),u((()=>({view:this.view,selectionManager:this.effectiveSelectionManager,selectionListViewModel:this.selectionListViewModel,selectionToolbarViewModel:this.selectionToolbarViewModel})),(({view:e,selectionManager:t,selectionListViewModel:i,selectionToolbarViewModel:a})=>{t.view=e,i.view=e,a.view=e}),m),u((()=>this.effectiveSelectionManager),(e=>{this.selectionListViewModel.selectionManager=e,this.selectionToolbarViewModel.selectionManager=e}),m)])}destroy(){this._cancelWorkflow({warnIfNoWorkflow:!1}).then((()=>{this.view?.map?.remove(this._sketchGraphicsLayer),this.view=null})),this._updateItemsTask=p(this._updateItemsTask),this._updatingHandles.destroy(),this._sketchEventListenerHandle=c(this._sketchEventListenerHandle)}get _featureTemplatesLayersAndTables(){const e=new a;for(const t of this.editorItems){const i=this.hideTemplatesForInactiveLayers&&!t.visible;t.supportsCreateFeaturesWorkflow&&!i&&e.push(t.layer)}return e}get activeLeafWorkflow(){const e=this.activeWorkflow;return e&&G(e)?e.activeWorkflow??e:e}get canCreate(){return this.editorItems.some((e=>e.supportsCreateFeaturesWorkflow))}get canCreateVisible(){return!!this.featureTemplatesLayers.length}get canUpdate(){return this.editorItems.some((e=>e.supportsUpdateWorkflow))}get canUpdateVisible(){return this.editorItems.some((e=>e.supportsUpdateWorkflow&&e.visible))}get featureTemplatesLayers(){return this._featureTemplatesLayersAndTables.filter((e=>"scene"===e.type||!e.isTable))}get effectiveSelectionManager(){return this.selectionManager}get featureFormViewModel(){const{activeWorkflow:e}=this;return"update"===e?.type?e.activeFeatureFormViewModel:"create-features"===e?.type?e.featureFormViewModel:null}get formViewModel(){const{activeWorkflow:e}=this;return"update"===e?.type?e.activeFeatureFormViewModel:"create-features"===e?.type?e.featureFormViewModel:"update-features"===e?.type?e.formViewModel:null}get utilityNetworkAssociationAddAssociationViewModel(){const{activeWorkflow:e}=this;return"update"===e?.type?e.activeUtilityNetworkAssociationAddAssociationViewModel:null}get labelOptions(){return this.sketchOptions.labels}set labelOptions(e){this.sketchOptions.labels=e}get sketchViewModel(){const{activeWorkflow:e}=this;return"update"===e?.type?e.activeSketchViewModel:"create-features"===e?.type?e.sketchViewModel:this.ownSketchViewModel}get state(){if(!this.view?.ready)return"disabled";const e=this.attachmentsViewModel.mode;if("add"===e)return"adding-attachment";if("edit"===e)return"editing-attachment";const{activeWorkflow:t}=this,i=!t?.stepId;return this.effectiveSelectionManager.count&&i?"viewing-selection-list":i?"ready":"update"===t.type&&t.activeWorkflow?.stepId?t.activeWorkflow.stepId:t.stepId}get syncing(){return this._activityQueue.length>0}get updating(){return this._updatingHandles.updating||!0===this.activeWorkflow?.updating}get tooltipOptions(){return this.sketchOptions.tooltips}set tooltipOptions(e){this.sketchOptions.tooltips=e}get valueOptions(){return this.sketchOptions.values}set valueOptions(e){this.sketchOptions.values=e}set view(e){this.ownSketchViewModel.view=e,this.spinnerViewModel.view=e,this._set("view",e)}get canZoomTo(){const e=this.sketchViewModel,t=e?.createGraphic?.geometry?.type;return!(!e?.updateGraphics?.length&&"multipoint"!==t)}get page(){const{activeWorkflow:e,state:t}=this;if("update"===e?.type&&null!=e?.activeWorkflow?.featureFormViewModel?.associatedLayer)return"viewing-associated-features";if("update"===e?.type&&null!=e?.activeWorkflow?.featureFormViewModel?.associationId)return"viewing-associated-layers";if("update"===e?.type&&"awaiting-feature-to-update"===e.stepId)return"ready";if("create-features"===e?.type&&0===e.numPendingFeatures){const t=e.data.upload;if(t)return"default"===t.state?"ready":"creating-features-upload-details"}return t??"disabled"}get featureFormDisabled(){const{activeWorkflow:e}=this;return"update"===e?.type&&(!1===e.activeEditorItem?.capabilities.update.attributes||!0===e.activeFeatureFormViewModel?.disabled)}get featureFormHasAssociation(){return!!this.featureFormViewModel?.activeAssociation}get canGoBack(){return null!=this.activeWorkflow&&!this.syncing}get shouldShowDeleteButton(){const{activeWorkflow:e}=this;return!!e&&"update"===e.type&&!!e.activeEditorItem?.capabilities.delete.enabled}get hasPendingEdits(){return this.activeWorkflow?.hasPendingEdits??!1}get snappingManager(){return this._snappingManager}getTemplatesForLayer(e){return this._templatesByLayer.get(e)??[]}async startCreateFeaturesWorkflowAtFeatureTypeSelection(){return this.startCreateFeaturesWorkflow()}async startCreateFeaturesWorkflowAtFeatureCreation(e){return this.startCreateFeaturesWorkflow(e,"creating-features")}async startCreateFeaturesWorkflow(e,t="awaiting-feature-creation-info"){if(await k((()=>!this.updating)),!this.canCreate)throw new r("editing:unsupported-workflow","Creating features is unsupported or disabled.");const i=this._createUpdatingResolver();try{await this._cancelWorkflow();const i=this._createCreateFeaturesWorkflow(e,t);this._set("activeWorkflow",i),await i.start()}catch(a){this._logErrorAndCancelWorkflow(a)}finally{i.resolve()}}async startCreateFeaturesWorkflowAtFeatureEdit(e){await k((()=>!this.updating));const t=this._createUpdatingResolver();try{const{initialFeature:t}=e,i=t.sourceLayer=t.layer,a=i?this.findEditorItemForLayer(i):void 0;if(!a?.supportsCreateFeaturesWorkflow)throw new r("editing:unsupported-workflow","Creating features is unsupported or disabled for this layer.");await this._cancelWorkflow();const s=this._createCreateFeaturesWorkflow({initialFeature:t,layer:a.layer,maxFeatures:1},"creating-features");this._set("activeWorkflow",s),await s.start()}catch(i){this._logErrorAndCancelWorkflow(i)}finally{t.resolve()}}async startUpdateFeaturesWorkflow(e){if(await k((()=>!this.updating)),!this.canUpdate)return void this._logError("editing:unsupported-workflow","Update features workflow is unsupported or disabled.");const t=this._createUpdatingResolver();try{await this._cancelWorkflow();const t=this._createUpdateFeaturesWorkflow(e);this._set("activeWorkflow",t),await t.start()}catch(i){this._logErrorAndCancelWorkflow(i)}finally{t.resolve()}}async startUpdateWorkflowAtFeatureSelection(){if(await k((()=>!this.updating)),!this.canUpdate)return void this._logError("editing:unsupported-workflow","Update workflow is unsupported or disabled.");const e=this._createUpdatingResolver();try{await this._cancelWorkflow();const e=this._createUpdateWorkflow();this._set("activeWorkflow",e),await e.start()}catch(t){this._logErrorAndCancelWorkflow(t)}finally{e.resolve()}}async startUpdateWorkflowAtMultipleFeatureSelection(e){if(await k((()=>!this.updating)),!this.canUpdate)return void this._logError("editing:unsupported-workflow","Update workflow is unsupported or disabled.");const t=this._createUpdatingResolver();try{await this._cancelWorkflow();const t=this._createUpdateWorkflow("awaiting-update-feature-candidate");t.data.candidates=e,this._set("activeWorkflow",t),await t.start()}catch(i){this._logErrorAndCancelWorkflow(i)}finally{t.resolve()}}async startUpdateWorkflowAtFeatureEdit(e){if(await k((()=>!this.updating)),!this.canUpdate)return void this._logError("editing:unsupported-workflow","Update workflow is unsupported or disabled.");const t=this._createUpdatingResolver();try{await this._cancelWorkflow();const t=this._createUpdateWorkflow("editing-existing-feature");t.data.rootFeature=e,t.addHandles(w((()=>t),"commit",(()=>{t.destroy(),this.activeWorkflow===t&&this._set("activeWorkflow",null)}))),this._set("activeWorkflow",t),await t.start()}catch(i){this._logErrorAndCancelWorkflow(i)}finally{t.resolve()}}async startUpdateWorkflowWithActiveSelection(){const{selectionListViewModel:e}=this;if(!e.visibleFeatureCount)throw new r("editing:missing-selection","Unable to determine visible selection.");if(e.visibleLayerCount>1)throw new r("editing:features-different-layers","Cannot start workflow with features from different layers.");const t=e.activeLayerItem??e.layerItems.find((e=>e.total>0));if(!t)throw new r("editing:no-layer-item","Unable to determine source layer of active selection.");const i=t.selection.map((e=>e.graphic));1===i.length?this.startUpdateWorkflowAtFeatureEdit(i[0]):this.startUpdateFeaturesWorkflow(i)}async deleteFeatureFromWorkflow(){const{activeWorkflow:e}=this;e&&"update"===e.type?await e.deleteActiveFeature():this._logError("editing:unsupported-workflow","Deleting a feature requires an active update workflow.")}async deleteAssociationFromWorkflow(){const{activeWorkflow:e}=this;e&&"update"===e.type?await e.deleteActiveAssociation():this._logError("editing:unsupported-workflow","Deleting an association requires an active update workflow.")}async cancelWorkflow(e){return this._cancelWorkflow({warnIfNoWorkflow:!0,...e})}findEditorItemForLayer(e){return this.editorItems.find((t=>t.layer===e))}itemHasInvalidFormTemplate(e){return null!=e&&!0===this.findEditorItemForLayer(e.layer)?.hasInvalidFormTemplate}syncFeatureTemplates(){this._featureTemplatesViewModelIsRestricted||this._updateTemplates()}zoomTo(e){const i=this.sketchViewModel,a=e?e.geometry:i?.updateGraphics.length?i?.updateGraphics.toArray().map((e=>e.geometry)).filter(t):i?.createGraphic?.geometry;a&&this.view&&z(this.view,a)}async toggleUpdateWorkflow(){this.canUpdate&&(this.hasPendingEdits&&!await this.showDiscardEditsPrompt()||(this.activeWorkflow&&"awaiting-feature-to-update"===this.state?await this.cancelWorkflow({force:!0}):await this.startUpdateWorkflowAtFeatureSelection()))}async onSelectionListItemSelect(e){Z(e)&&this.startUpdateWorkflowAtFeatureEdit(e.graphic)}async onSelectionListMenuItemSelect(e){if(Z(e))this.startUpdateWorkflowAtFeatureEdit(e.graphic);else if($(e)){const t=e.selection.map((e=>e.graphic));1===t.length?this.startUpdateWorkflowAtFeatureEdit(t[0]):this.startUpdateFeaturesWorkflow(t)}}restrictFeatureTemplatesViewModelToLayer(e){return this._featureTemplatesViewModelIsRestricted=!0,this._setFeatureTemplatesViewModelLayers([e]),o((()=>{this._featureTemplatesViewModelIsRestricted=!1,this._setFeatureTemplatesViewModelLayers(this.featureTemplatesLayers)}))}async _getEditorItemCandidates(e){const{view:t}=this;if(!t?.map)return[];const{map:i}=t,a=i.editableLayers.toArray(),r=i.allTables.toArray().filter((e=>b(e)||V(e)));return await Promise.allSettled([...a.flatMap((e=>this._getLayerLoadPromise(e))),...r.flatMap((e=>this._getLayerLoadPromise(e)))]),d(e),[...a.reverse(),...r.reverse()].filter((e=>E(e)&&("mesh"!==e.geometryType||"3d"===t.type))).flatMap((e=>"subtype-group"===e.type?e.sublayers.toArray():e))}_getLayerLoadPromise(e){return V(e)?e.loadAll():e.load()}_drainEditorItems(){this.editorItems.drain((e=>e.destroy()))}_updateEditorItems(){p(this._updateItemsTask);const{view:e}=this,t=i((async t=>{if(!e?.map||!e?.allLayerViews)return;const i=await this._getEditorItemCandidates(t);if(!i.length)return void this._drainEditorItems();const a=[],r=[],s=[],{layerInfos:o}=this;for(const l of i){const t=X(o,l),i=await x(e,l).catch((()=>null));(t?a:i?r:s).push(new D({layer:l,layerInfo:t,layerView:i}))}o?.length&&a.sort(((e,t)=>o.findIndex((({layer:t})=>t===e.layer))-o.findIndex((({layer:e})=>e===t.layer))));const n=[...a,...r,...s];t.aborted||(this._drainEditorItems(),this.editorItems.addMany(n))}));this._updatingHandles.addPromise(t.promise),this._updateItemsTask=t}_updateTemplates(){p(this._updateTemplatesTask);const e=i((async e=>{const t=this._templatesByLayer,i=this._featureTemplatesLayersAndTables.filter((e=>!t.has(e)));if(i.length>0){const a=await M(i.toArray(),this.view,e);for(const{layer:e,templates:i}of a)t.set(e,i)}this._setFeatureTemplatesViewModelLayers(this.featureTemplatesLayers)}));this._updatingHandles.addPromise(e.promise),this._updateTemplatesTask=e}_setFeatureTemplatesViewModelLayers(e){const t=this._templatesByLayer,i=[];for(const a of e){const e=t.get(a);e&&e.length>0&&i.push(B(a,e))}this.featureTemplatesViewModel.templateInfos=i}_afterEditorItemsChange(){const{activeWorkflow:e}=this;if(this.syncFeatureTemplates(),this._syncSelectionSources(),!e)return;const{stepId:t}=e;"create-features"!==e.type?"update"===e.type&&("awaiting-feature-to-update"===t&&!this.canUpdateVisible||"awaiting-update-feature-candidate"===t&&!e.hasUpdatableCandidates)&&this._cancelWorkflow():"awaiting-feature-creation-info"!==t||this.canCreate||this._cancelWorkflow()}async _cancelWorkflow(e){const t=this.activeWorkflow;if(!t)return void(e?.warnIfNoWorkflow&&this._logError("editing:no-active-workflow","There is no active workflow to cancel."));if(!e||!1!==e.force){this.emit("workflow-cancel"),this._set("activeWorkflow",null);try{await t.cancel(e)}finally{t.destroy()}}else try{await t.cancel(e),this._set("activeWorkflow",null),t.destroy()}catch(i){}}_createCreateFeaturesWorkflow(e,t){return j.create({viewModel:this,creationInfo:e,sketchOptions:this.sketchOptions,snappingManager:this._snappingManager,startAt:t,applyEditsCallback:(e,t,i)=>this._applyEdits(e,t,i),applyEditsFeatureServiceCallback:(e,t,i)=>this._applyEditsFeatureService(e,t,i),addAttachmentsCallback:(e,t)=>this._addAttachments(e,t)})}_createUpdateFeaturesWorkflow(e){const t=P.create({viewModel:this,sketchOptions:this.sketchOptions,snappingManager:this._snappingManager,features:e,applyEdits:(e,t,i)=>this._applyEdits(e,t,i),applyEditsFeatureService:(e,t,i)=>this._applyEditsFeatureService(e,t,i)});return t.addHandles(w((()=>t),"commit",(()=>{t.destroy(),this.activeWorkflow===t&&this._set("activeWorkflow",null)}))),t}_createUpdateWorkflow(e){return R.create({viewModel:this,sketchOptions:this.sketchOptions,snappingManager:this._snappingManager,startAt:e,applyEditsCallback:(e,t,i)=>this._applyEdits(e,t,i),applyEditsFeatureServiceCallback:(e,t,i)=>this._applyEditsFeatureService(e,t,i),addAttachmentsCallback:(e,t)=>this._addAttachments(e,t)})}_addAttachments(e,t){const i=t.map((t=>this._addAttachment(e,t.feature,t.attachment)))??[];return Promise.all(i)}async _addAttachment(e,t,i){let a=null;if(!("addAttachment"in e)||null==e.capabilities?.attachment)throw new r("editor:attachments-not-supported","Adding attachments is not supported for this layer type");return await this._queueOperation((async()=>(a=await(e.addAttachment?.(t,i).catch((e=>{throw e?.error||e})))??null,a))),a}async _applyEdits(e,t,i){let a=null;const r=e.url?await T(e.url):null,s={returnServiceEditsOption:(!r||!I(r))&&!RegExp("/hosted/","i").test(e.url)?"original-and-current-features":void 0,...i};return await this._queueOperation((async()=>{const{view:i}=this;if(!i)return null;const r=await x(i,e).catch((()=>null));return a=await e.applyEdits(t,s),r&&await k((()=>!r.updating)),a})),a}async _applyEditsFeatureService(e,t,i){let a=null;return await this._queueOperation((async()=>a=await e.applyEdits(t,i))),a}_queueOperation(e){this._activityQueue.push(e);const t=(e,t)=>{const i=t.indexOf(e);i>-1&&t.splice(i,1)};return e().then((e=>(Array.isArray(e)?e.forEach((e=>this._handleEditsResultError(e))):this._handleEditsResultError(e),e))).catch((i=>{this._logError("editing:operation-error","An error occurred.",{error:i});const a={error:i,retry:()=>(t(a,this.failures),this._queueOperation(e)),cancel:()=>{t(a,this.failures)}};this._set("failures",[...this.failures,a])})).then((()=>{t(e,this._activityQueue)}))}_handleEditsResultError(e){if(null!=e&&"error"in e&&null!=e.error)throw e.error;if(null!=e&&"addFeatureResults"in e){const{addFeatureResults:t,deleteFeatureResults:i,updateFeatureResults:a}=e,r=t.find((e=>!!e.error))||a.find((e=>!!e.error))||i.find((e=>!!e.error));if(r)throw r.error}}_createUpdatingResolver(){const e=h();return this._updatingHandles.addPromise(e.promise),e}_logErrorAndCancelWorkflow(e){const{name:t,message:i,details:a}=e;this._logError(t??"editing:workflow-start-failed",i??void 0,a??e),this._cancelWorkflow({force:!0})}_itemIsSuspended(e){const t=this.findEditorItemForLayer(e);return null!=t&&(!t.visible||t.disabled)}_logError(e,t,i){n.getLogger(this).error(new r(e,t,i))}_syncSelectionSources(){const{selectionManager:e}=this,t=[];this.editorItems.forEach((e=>{C(e.layer)&&e.supportsUpdateWorkflow&&t.push(e.layer)})),e.sources.removeAll(),e.sources.addMany(t)}async _onSelectionComplete(e){if(e.aborted)return;const{operationType:t,selection:i}=e,{effectiveSelectionManager:a}=this,r="ready"===this.state,s=1===i.length;if(r&&s&&(0===a.count&&"add"===t||"replace"===t))return this.startUpdateWorkflowAtFeatureEdit(i[0]);switch(t){case"remove":a.updateSelection({current:[],added:[],removed:i});break;case"replace":a.clear(),a.updateSelection({current:i,added:[],removed:[]});break;case"add":a.updateSelection({current:i,added:[],removed:[]})}}};e([v()],Y.prototype,"_featureTemplatesLayersAndTables",null),e([v()],Y.prototype,"_snappingManager",void 0),e([v({readOnly:!0})],Y.prototype,"activeWorkflow",void 0),e([v()],Y.prototype,"activeLeafWorkflow",null),e([v({readOnly:!0})],Y.prototype,"_activityQueue",void 0),e([v({readOnly:!0})],Y.prototype,"canCreate",null),e([v()],Y.prototype,"canCreateVisible",null),e([v({readOnly:!0})],Y.prototype,"canUpdate",null),e([v()],Y.prototype,"canUpdateVisible",null),e([v()],Y.prototype,"featureTemplatesLayers",null),e([v()],Y.prototype,"editorItems",void 0),e([v()],Y.prototype,"effectiveSelectionManager",null),e([v({readOnly:!0})],Y.prototype,"failures",void 0),e([v()],Y.prototype,"hideTemplatesForInactiveLayers",void 0),e([v({type:O})],Y.prototype,"attachmentsViewModel",void 0),e([v()],Y.prototype,"featureFormViewModel",null),e([v()],Y.prototype,"formViewModel",null),e([v()],Y.prototype,"utilityNetworkAssociationAddAssociationViewModel",null),e([v({type:q})],Y.prototype,"featureTemplatesViewModel",void 0),e([v()],Y.prototype,"labelOptions",null),e([v()],Y.prototype,"layerInfos",void 0),e([v()],Y.prototype,"ownSketchViewModel",void 0),e([v()],Y.prototype,"selectionListViewModel",void 0),e([v()],Y.prototype,"selectionManager",void 0),e([v()],Y.prototype,"selectionToolbarViewModel",void 0),e([v()],Y.prototype,"sketchOptions",void 0),e([v()],Y.prototype,"sketchViewModel",null),e([v({type:S,nonNullable:!0})],Y.prototype,"snappingOptions",void 0),e([v()],Y.prototype,"spinnerViewModel",void 0),e([v()],Y.prototype,"state",null),e([v({readOnly:!0})],Y.prototype,"syncing",null),e([v()],Y.prototype,"updating",null),e([v()],Y.prototype,"tooltipOptions",null),e([v()],Y.prototype,"valueOptions",null),e([v()],Y.prototype,"view",null),e([v()],Y.prototype,"canZoomTo",null),e([v()],Y.prototype,"pageStack",void 0),e([v()],Y.prototype,"showDiscardEditsPrompt",void 0),e([v()],Y.prototype,"_candidateCommitted",void 0),e([v()],Y.prototype,"page",null),e([v()],Y.prototype,"featureFormDisabled",null),e([v()],Y.prototype,"featureFormHasAssociation",null),e([v()],Y.prototype,"canGoBack",null),e([v()],Y.prototype,"shouldShowDeleteButton",null),e([v()],Y.prototype,"hasPendingEdits",null),e([v()],Y.prototype,"snappingManager",null),Y=e([_("esri.widgets.Editor.EditorViewModel")],Y);const ee=Y;export{ee as default};
5
+ import{_ as e}from"../../chunks/tslib.es6.js";import{isSome as t}from"../../core/arrayUtils.js";import{createTask as i}from"../../core/asyncUtils.js";import a from"../../core/Collection.js";import r from"../../core/Error.js";import s from"../../core/Evented.js";import{makeHandle as o}from"../../core/handleUtils.js";import n from"../../core/Logger.js";import{destroyMaybe as l,abortMaybe as p,removeMaybe as c}from"../../core/maybe.js";import{throwIfAborted as d,createResolver as u}from"../../core/promiseUtils.js";import{watch as h,on as w,when as f,syncAndInitial as m,initial as y,sync as g,whenOnce as k}from"../../core/reactiveUtils.js";import{property as v}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import{subclass as _}from"../../core/accessorSupport/decorators/subclass.js";import{UpdatingHandles as W}from"../../core/support/UpdatingHandles.js";import{getTemplatesForLayers as M}from"../../editing/templateUtils.js";import F from"../../layers/GraphicsLayer.js";import{isEditableLayer as E}from"../../layers/support/editableLayers.js";import{isFeatureLayer as b,isSubtypeGroupLayer as V,getOwningPortalUrl as T}from"../../layers/support/layerUtils.js";import{parseKnownArcGISOnlineDomain as I}from"../../portal/support/urlUtils.js";import L from"../../views/SelectionManager.js";import A from"../../views/interactive/sketch/SketchOptions.js";import{SnappingManager as U}from"../../views/interactive/snapping/SnappingManager.js";import S from"../../views/interactive/snapping/SnappingOptions.js";import{isSelectableLayer as C}from"../../views/support/selectionUtils.js";import O from"../Attachments/AttachmentsViewModel.js";import j from"./CreateFeaturesWorkflow.js";import P from"./UpdateFeaturesWorkflow.js";import R from"./UpdateWorkflow.js";import{getLayersFromWorkflow as H,isCreateFeaturesWorkflow as G,isUpdateRecordWorkflow as x,isUpdateFeaturesWorkflow as D,isUpdateWorkflow as B,whenEditorLayerView as q}from"./workflowUtils.js";import N from"./support/EditorItem.js";import{makeTemplateGroupInfoForLayer as Q}from"../FeatureTemplates/featureTemplatesUtils.js";import z from"../FeatureTemplates/FeatureTemplatesViewModel.js";import Z from"../Sketch/SketchViewModel.js";import $ from"../Spinner/SpinnerViewModel.js";import{goTo as J}from"../support/goToUtils.js";import{isFeatureItem as K,isLayerItem as X}from"../support/SelectionList/selectionListUtils.js";import Y from"../support/SelectionList/SelectionListViewModel.js";import ee from"../support/SelectionToolbar/SelectionToolbarViewModel.js";function te(e,t){return e?.find((e=>e.layer===t))}let ie=class extends s.EventedAccessor{constructor(e){super(e),this._templatesByLayer=new Map,this._sketchEventListenerHandle=null,this._sketchGraphicsLayer=new F({listMode:"hide",internal:!0}),this._snappingManager=null,this._updateItemsTask=null,this._updateTemplatesTask=null,this._updatingHandles=new W,this._featureTemplatesViewModelIsRestricted=!1,this.activeWorkflow=null,this._activityQueue=new a,this.editorItems=new a,this.failures=[],this.hideTemplatesForInactiveLayers=!1,this.attachmentsViewModel=new O({capabilities:{editing:!0}}),this.featureTemplatesViewModel=new z({disabledItemFunction:({layer:e})=>this._itemIsSuspended(e)}),this.layerInfos=null,this.ownSketchViewModel=new Z({layer:this._sketchGraphicsLayer}),this.selectionListViewModel=new Y,this.selectionManager=new L,this.selectionToolbarViewModel=new ee({persistSelection:!1,returnGeometry:!1}),this.sketchOptions=new A,this.snappingOptions=new S({attributeRulesEnabled:!0}),this.spinnerViewModel=new $,this.pageStack=[],this.showDiscardEditsPrompt=()=>Promise.resolve(!0),this._candidateCommitted=!1,this.back=async()=>{this.selectionToolbarViewModel.cancel(),"viewing-selection-list"!==this.state?this.canGoBack&&(this.activeWorkflow?.hasPreviousStep?await this.activeWorkflow.back(this.showDiscardEditsPrompt):await this._cancelWorkflow({force:!this.hasPendingEdits})):this.effectiveSelectionManager.clear()},this.saveWorkflow=async()=>await(this.activeWorkflow?.save()),this.selectFeature=(e,t=!1)=>{const i=this.activeWorkflow;this._candidateCommitted||"update"!==i?.type||(i.data.rootFeature=e,t&&(i.next(),this._candidateCommitted=!0))}}initialize(){this.addHandles([h((()=>{const e=this.view,t=e?.map?.editableLayers.toArray(),i=e?.allLayerViews,a=i?.filter((e=>!!t?.includes(e.layer)));return[t,a,this.layerInfos]}),(()=>this._updateEditorItems()),m),h((()=>this.hideTemplatesForInactiveLayers),(()=>this.syncFeatureTemplates())),w((()=>this.activeWorkflow),"cancel",(()=>this.emit("workflow-cancel"))),w((()=>this.activeWorkflow),"commit",(()=>this.emit("workflow-commit"))),w((()=>this.activeWorkflow),"complete",(()=>{this.emit("workflow-commit"),this._set("activeWorkflow",null)})),f((()=>this.view?.map),(e=>e.add(this._sketchGraphicsLayer)),y),w((()=>this.editorItems),"change",(()=>this._afterEditorItemsChange())),h((()=>[this.canCreate,this.canUpdateVisible]),(()=>this._afterEditorItemsChange())),h((()=>this.page),((e,t)=>{const i=[...this.pageStack];if(-1===i.indexOf(e))i.push(e);else for(;i.length&&i.at(-1)!==e;)i.pop();this.pageStack=i}),m),f((()=>"awaiting-update-feature-candidate"===this.state),(()=>this._candidateCommitted=!1)),w((()=>this.featureTemplatesViewModel),"select",(async({item:e,oldItem:t})=>{const{activeWorkflow:i}=this;if(i){if("update"===i.type&&"awaiting-feature-creation-info"===i.activeWorkflow?.stepId)return;try{await this.cancelWorkflow({force:!this.hasPendingEdits})}catch{return void this.featureTemplatesViewModel.select(t,{emit:!1})}}if(!e)return;const a={layer:e.layer,template:e.template};if(e.supportsUpload)return this.featureTemplatesViewModel.select(t,{emit:!1}),this.startCreateFeaturesWorkflow(a);this.startCreateFeaturesWorkflowAtFeatureCreation(a)})),h((()=>[this.view,this.featureTemplatesViewModel]),(([e,t])=>{t.view=e}),m),w((()=>this.view),"key-down",(e=>{"Escape"===e.key&&this.activeWorkflow?.keyboardCancellationEnabled&&(e.stopPropagation(),this.back())})),w((()=>this.sketchViewModel),["create","delete","update"],(e=>{const{activeWorkflow:t}=this,i="update"===t?.type,a=H(t),r=i?t?.activeWorkflow?.parentLayer:void 0,s=`sketch-${e.type}`;this.emit(s,{type:s,detail:e,layer:a[0],layers:a,parentLayer:r})}),g),h((()=>this.view),(e=>{if(this._snappingManager=l(this._snappingManager),!e)return;const t=this.snappingOptions;this._snappingManager=new U({view:e,options:t}),this.ownSketchViewModel.snappingManager=this._snappingManager}),m),h((()=>this.snappingOptions),(e=>{this._snappingManager&&(this._snappingManager.options=e)}),m),w((()=>this.selectionToolbarViewModel),"complete",(e=>this._onSelectionComplete(e))),h((()=>({view:this.view,selectionManager:this.effectiveSelectionManager,selectionListViewModel:this.selectionListViewModel,selectionToolbarViewModel:this.selectionToolbarViewModel})),(({view:e,selectionManager:t,selectionListViewModel:i,selectionToolbarViewModel:a})=>{t.view=e,i.view=e,a.view=e}),m),h((()=>this.effectiveSelectionManager),(e=>{this.selectionListViewModel.selectionManager=e,this.selectionToolbarViewModel.selectionManager=e}),m)])}destroy(){this._cancelWorkflow({warnIfNoWorkflow:!1}).then((()=>{this.view?.map?.remove(this._sketchGraphicsLayer),this.view=null})),this._updateItemsTask=p(this._updateItemsTask),this._updatingHandles.destroy(),this._sketchEventListenerHandle=c(this._sketchEventListenerHandle)}get _featureTemplatesLayersAndTables(){const e=new a;for(const t of this.editorItems){const i=this.hideTemplatesForInactiveLayers&&!t.visible;t.supportsCreateFeaturesWorkflow&&!i&&e.push(t.layer)}return e}get activeFeatureCount(){const e=this.activeLeafWorkflow;return G(e)?e.pendingFeatures.length:x(e)&&e.data.edits.feature?1:D(e)?e.data.features.length:0}get activeLeafWorkflow(){const e=this.activeWorkflow;return e&&B(e)?e.activeWorkflow??e:e}get canCreate(){return this.editorItems.some((e=>e.supportsCreateFeaturesWorkflow))}get canCreateVisible(){return!!this.featureTemplatesLayers.length}get canUpdate(){return this.editorItems.some((e=>e.supportsUpdateWorkflow))}get canUpdateVisible(){return this.editorItems.some((e=>e.supportsUpdateWorkflow&&e.visible))}get featureTemplatesLayers(){return this._featureTemplatesLayersAndTables.filter((e=>"scene"===e.type||!e.isTable))}get effectiveSelectionManager(){return this.selectionManager}get featureFormViewModel(){const{activeWorkflow:e}=this;return"update"===e?.type?e.activeFeatureFormViewModel:"create-features"===e?.type?e.featureFormViewModel:null}get formViewModel(){const{activeWorkflow:e}=this;return"update"===e?.type?e.activeFeatureFormViewModel:"create-features"===e?.type?e.featureFormViewModel:"update-features"===e?.type?e.formViewModel:null}get utilityNetworkAssociationAddAssociationViewModel(){const{activeWorkflow:e}=this;return"update"===e?.type?e.activeUtilityNetworkAssociationAddAssociationViewModel:null}get labelOptions(){return this.sketchOptions.labels}set labelOptions(e){this.sketchOptions.labels=e}get sketchViewModel(){const{activeWorkflow:e}=this;return"update"===e?.type?e.activeSketchViewModel:"create-features"===e?.type?e.sketchViewModel:this.ownSketchViewModel}get state(){if(!this.view?.ready)return"disabled";const e=this.attachmentsViewModel.mode;if("add"===e)return"adding-attachment";if("edit"===e)return"editing-attachment";const{activeWorkflow:t}=this,i=!t?.stepId;return this.effectiveSelectionManager.count&&i?"viewing-selection-list":i?"ready":"update"===t.type&&t.activeWorkflow?.stepId?t.activeWorkflow.stepId:t.stepId}get syncing(){return this._activityQueue.length>0}get updating(){return this._updatingHandles.updating||!0===this.activeWorkflow?.updating}get tooltipOptions(){return this.sketchOptions.tooltips}set tooltipOptions(e){this.sketchOptions.tooltips=e}get valueOptions(){return this.sketchOptions.values}set valueOptions(e){this.sketchOptions.values=e}set view(e){this.ownSketchViewModel.view=e,this.spinnerViewModel.view=e,this._set("view",e)}get canZoomTo(){const e=this.sketchViewModel,t=e?.createGraphic?.geometry?.type;return!(!e?.updateGraphics?.length&&"multipoint"!==t)}get page(){const{activeWorkflow:e,state:t}=this;if("update"===e?.type&&null!=e?.activeWorkflow?.featureFormViewModel?.associatedLayer)return"viewing-associated-features";if("update"===e?.type&&null!=e?.activeWorkflow?.featureFormViewModel?.associationId)return"viewing-associated-layers";if("update"===e?.type&&"awaiting-feature-to-update"===e.stepId)return"ready";if("create-features"===e?.type&&0===e.numPendingFeatures){const t=e.data.upload;if(t)return"default"===t.state?"ready":"creating-features-upload-details"}return t??"disabled"}get featureFormDisabled(){const{activeWorkflow:e}=this;return"update"===e?.type&&(!1===e.activeEditorItem?.capabilities.update.attributes||!0===e.activeFeatureFormViewModel?.disabled)}get featureFormHasAssociation(){return!!this.featureFormViewModel?.activeAssociation}get canGoBack(){return null!=this.activeWorkflow&&!this.syncing}get shouldShowDeleteButton(){const{activeWorkflow:e}=this;return!!e&&"update"===e.type&&!!e.activeEditorItem?.capabilities.delete.enabled}get hasPendingEdits(){return this.activeWorkflow?.hasPendingEdits??!1}get snappingManager(){return this._snappingManager}getTemplatesForLayer(e){return this._templatesByLayer.get(e)??[]}async startCreateFeaturesWorkflowAtFeatureTypeSelection(){return this.startCreateFeaturesWorkflow()}async startCreateFeaturesWorkflowAtFeatureCreation(e){return this.startCreateFeaturesWorkflow(e,"creating-features")}async startCreateFeaturesWorkflow(e,t="awaiting-feature-creation-info"){if(await k((()=>!this.updating)),!this.canCreate)throw new r("editing:unsupported-workflow","Creating features is unsupported or disabled.");const i=this._createUpdatingResolver();try{await this._cancelWorkflow();const i=this._createCreateFeaturesWorkflow(e,t);this._set("activeWorkflow",i),await i.start()}catch(a){this._logErrorAndCancelWorkflow(a)}finally{i.resolve()}}async startCreateFeaturesWorkflowAtFeatureEdit(e){await k((()=>!this.updating));const t=this._createUpdatingResolver();try{const{initialFeature:t}=e,i=t.sourceLayer=t.layer,a=i?this.findEditorItemForLayer(i):void 0;if(!a?.supportsCreateFeaturesWorkflow)throw new r("editing:unsupported-workflow","Creating features is unsupported or disabled for this layer.");await this._cancelWorkflow();const s=this._createCreateFeaturesWorkflow({initialFeature:t,layer:a.layer,maxFeatures:1},"creating-features");this._set("activeWorkflow",s),await s.start()}catch(i){this._logErrorAndCancelWorkflow(i)}finally{t.resolve()}}async startUpdateFeaturesWorkflow(e){if(await k((()=>!this.updating)),!this.canUpdate)return void this._logError("editing:unsupported-workflow","Update features workflow is unsupported or disabled.");const t=this._createUpdatingResolver();try{await this._cancelWorkflow();const t=this._createUpdateFeaturesWorkflow(e);this._set("activeWorkflow",t),await t.start()}catch(i){this._logErrorAndCancelWorkflow(i)}finally{t.resolve()}}async startUpdateWorkflowAtFeatureSelection(){if(await k((()=>!this.updating)),!this.canUpdate)return void this._logError("editing:unsupported-workflow","Update workflow is unsupported or disabled.");const e=this._createUpdatingResolver();try{await this._cancelWorkflow();const e=this._createUpdateWorkflow();this._set("activeWorkflow",e),await e.start()}catch(t){this._logErrorAndCancelWorkflow(t)}finally{e.resolve()}}async startUpdateWorkflowAtMultipleFeatureSelection(e){if(await k((()=>!this.updating)),!this.canUpdate)return void this._logError("editing:unsupported-workflow","Update workflow is unsupported or disabled.");const t=this._createUpdatingResolver();try{await this._cancelWorkflow();const t=this._createUpdateWorkflow("awaiting-update-feature-candidate");t.data.candidates=e,this._set("activeWorkflow",t),await t.start()}catch(i){this._logErrorAndCancelWorkflow(i)}finally{t.resolve()}}async startUpdateWorkflowAtFeatureEdit(e){if(await k((()=>!this.updating)),!this.canUpdate)return void this._logError("editing:unsupported-workflow","Update workflow is unsupported or disabled.");const t=this._createUpdatingResolver();try{await this._cancelWorkflow();const t=this._createUpdateWorkflow("editing-existing-feature");t.data.rootFeature=e,t.addHandles(w((()=>t),"commit",(()=>{t.destroy(),this.activeWorkflow===t&&this._set("activeWorkflow",null)}))),this._set("activeWorkflow",t),await t.start()}catch(i){this._logErrorAndCancelWorkflow(i)}finally{t.resolve()}}async startUpdateWorkflowWithActiveSelection(){const{selectionListViewModel:e}=this;if(!e.visibleFeatureCount)throw new r("editing:missing-selection","Unable to determine visible selection.");if(e.visibleLayerCount>1)throw new r("editing:features-different-layers","Cannot start workflow with features from different layers.");const t=e.activeLayerItem??e.layerItems.find((e=>e.total>0));if(!t)throw new r("editing:no-layer-item","Unable to determine source layer of active selection.");const i=t.selection.map((e=>e.graphic));1===i.length?this.startUpdateWorkflowAtFeatureEdit(i[0]):this.startUpdateFeaturesWorkflow(i)}async deleteFeatureFromWorkflow(){const{activeWorkflow:e}=this;e&&"update"===e.type?await e.deleteActiveFeature():this._logError("editing:unsupported-workflow","Deleting a feature requires an active update workflow.")}async deleteAssociationFromWorkflow(){const{activeWorkflow:e}=this;e&&"update"===e.type?await e.deleteActiveAssociation():this._logError("editing:unsupported-workflow","Deleting an association requires an active update workflow.")}async cancelWorkflow(e){return this._cancelWorkflow({warnIfNoWorkflow:!0,...e})}findEditorItemForLayer(e){return this.editorItems.find((t=>t.layer===e))}itemHasInvalidFormTemplate(e){return null!=e&&!0===this.findEditorItemForLayer(e.layer)?.hasInvalidFormTemplate}syncFeatureTemplates(){this._featureTemplatesViewModelIsRestricted||this._updateTemplates()}zoomTo(e){const i=this.sketchViewModel,a=e?e.geometry:i?.updateGraphics.length?i?.updateGraphics.toArray().map((e=>e.geometry)).filter(t):i?.createGraphic?.geometry;a&&this.view&&J(this.view,a)}async toggleUpdateWorkflow(){this.canUpdate&&(this.hasPendingEdits&&!await this.showDiscardEditsPrompt()||(this.activeWorkflow&&"awaiting-feature-to-update"===this.state?await this.cancelWorkflow({force:!0}):await this.startUpdateWorkflowAtFeatureSelection()))}async onSelectionListItemSelect(e){K(e)&&this.startUpdateWorkflowAtFeatureEdit(e.graphic)}async onSelectionListMenuItemSelect(e){if(K(e))this.startUpdateWorkflowAtFeatureEdit(e.graphic);else if(X(e)){const t=e.selection.map((e=>e.graphic));1===t.length?this.startUpdateWorkflowAtFeatureEdit(t[0]):this.startUpdateFeaturesWorkflow(t)}}restrictFeatureTemplatesViewModelToLayer(e){return this._featureTemplatesViewModelIsRestricted=!0,this._setFeatureTemplatesViewModelLayers([e]),o((()=>{this._featureTemplatesViewModelIsRestricted=!1,this._setFeatureTemplatesViewModelLayers(this.featureTemplatesLayers)}))}async _getEditorItemCandidates(e){const{view:t}=this;if(!t?.map)return[];const{map:i}=t,a=i.editableLayers.toArray(),r=i.allTables.toArray().filter((e=>b(e)||V(e)));return await Promise.allSettled([...a.flatMap((e=>this._getLayerLoadPromise(e))),...r.flatMap((e=>this._getLayerLoadPromise(e)))]),d(e),[...a.reverse(),...r.reverse()].filter((e=>E(e)&&("mesh"!==e.geometryType||"3d"===t.type))).flatMap((e=>"subtype-group"===e.type?e.sublayers.toArray():e))}_getLayerLoadPromise(e){return V(e)?e.loadAll():e.load()}_drainEditorItems(){this.editorItems.drain((e=>e.destroy()))}_updateEditorItems(){p(this._updateItemsTask);const{view:e}=this,t=i((async t=>{if(!e?.map||!e?.allLayerViews)return;const i=await this._getEditorItemCandidates(t);if(!i.length)return void this._drainEditorItems();const a=[],r=[],s=[],{layerInfos:o}=this;for(const l of i){const t=te(o,l),i=await q(e,l).catch((()=>null));(t?a:i?r:s).push(new N({layer:l,layerInfo:t,layerView:i}))}o?.length&&a.sort(((e,t)=>o.findIndex((({layer:t})=>t===e.layer))-o.findIndex((({layer:e})=>e===t.layer))));const n=[...a,...r,...s];t.aborted||(this._drainEditorItems(),this.editorItems.addMany(n))}));this._updatingHandles.addPromise(t.promise),this._updateItemsTask=t}_updateTemplates(){p(this._updateTemplatesTask);const e=i((async e=>{const t=this._templatesByLayer,i=this._featureTemplatesLayersAndTables.filter((e=>!t.has(e)));if(i.length>0){const a=await M(i.toArray(),this.view,e);for(const{layer:e,templates:i}of a)t.set(e,i)}this._setFeatureTemplatesViewModelLayers(this.featureTemplatesLayers)}));this._updatingHandles.addPromise(e.promise),this._updateTemplatesTask=e}_setFeatureTemplatesViewModelLayers(e){const t=this._templatesByLayer,i=[];for(const a of e){const e=t.get(a);e&&e.length>0&&i.push(Q(a,e))}this.featureTemplatesViewModel.templateInfos=i}_afterEditorItemsChange(){const{activeWorkflow:e}=this;if(this.syncFeatureTemplates(),this._syncSelectionSources(),!e)return;const{stepId:t}=e;"create-features"!==e.type?"update"===e.type&&("awaiting-feature-to-update"===t&&!this.canUpdateVisible||"awaiting-update-feature-candidate"===t&&!e.hasUpdatableCandidates)&&this._cancelWorkflow():"awaiting-feature-creation-info"!==t||this.canCreate||this._cancelWorkflow()}async _cancelWorkflow(e){const t=this.activeWorkflow;if(!t)return void(e?.warnIfNoWorkflow&&this._logError("editing:no-active-workflow","There is no active workflow to cancel."));if(!e||!1!==e.force){this.emit("workflow-cancel"),this._set("activeWorkflow",null);try{await t.cancel(e)}finally{t.destroy()}}else try{await t.cancel(e),this._set("activeWorkflow",null),t.destroy()}catch(i){}}_createCreateFeaturesWorkflow(e,t){return j.create({viewModel:this,creationInfo:e,sketchOptions:this.sketchOptions,snappingManager:this._snappingManager,startAt:t,applyEditsCallback:(e,t,i)=>this._applyEdits(e,t,i),applyEditsFeatureServiceCallback:(e,t,i)=>this._applyEditsFeatureService(e,t,i),addAttachmentsCallback:(e,t)=>this._addAttachments(e,t)})}_createUpdateFeaturesWorkflow(e){const t=P.create({viewModel:this,sketchOptions:this.sketchOptions,snappingManager:this._snappingManager,features:e,applyEdits:(e,t,i)=>this._applyEdits(e,t,i),applyEditsFeatureService:(e,t,i)=>this._applyEditsFeatureService(e,t,i)});return t.addHandles(w((()=>t),"commit",(()=>{t.destroy(),this.activeWorkflow===t&&this._set("activeWorkflow",null)}))),t}_createUpdateWorkflow(e){return R.create({viewModel:this,sketchOptions:this.sketchOptions,snappingManager:this._snappingManager,startAt:e,applyEditsCallback:(e,t,i)=>this._applyEdits(e,t,i),applyEditsFeatureServiceCallback:(e,t,i)=>this._applyEditsFeatureService(e,t,i),addAttachmentsCallback:(e,t)=>this._addAttachments(e,t)})}_addAttachments(e,t){const i=t.map((t=>this._addAttachment(e,t.feature,t.attachment)))??[];return Promise.all(i)}async _addAttachment(e,t,i){let a=null;if(!("addAttachment"in e)||null==e.capabilities?.attachment)throw new r("editor:attachments-not-supported","Adding attachments is not supported for this layer type");return await this._queueOperation((async()=>(a=await(e.addAttachment?.(t,i).catch((e=>{throw e?.error||e})))??null,a))),a}async _applyEdits(e,t,i){let a=null;const r=e.url?await T(e.url):null,s={returnServiceEditsOption:(!r||!I(r))&&!RegExp("/hosted/","i").test(e.url)?"original-and-current-features":void 0,...i};return await this._queueOperation((async()=>{const{view:i}=this;if(!i)return null;const r=await q(i,e).catch((()=>null));return a=await e.applyEdits(t,s),r&&await k((()=>!r.updating)),a})),a}async _applyEditsFeatureService(e,t,i){let a=null;return await this._queueOperation((async()=>a=await e.applyEdits(t,i))),a}_queueOperation(e){this._activityQueue.push(e);const t=(e,t)=>{const i=t.indexOf(e);i>-1&&t.splice(i,1)};return e().then((e=>(Array.isArray(e)?e.forEach((e=>this._handleEditsResultError(e))):this._handleEditsResultError(e),e))).catch((i=>{this._logError("editing:operation-error","An error occurred.",{error:i});const a={error:i,retry:()=>(t(a,this.failures),this._queueOperation(e)),cancel:()=>{t(a,this.failures)}};this._set("failures",[...this.failures,a])})).then((()=>{t(e,this._activityQueue)}))}_handleEditsResultError(e){if(null!=e&&"error"in e&&null!=e.error)throw e.error;if(null!=e&&"addFeatureResults"in e){const{addFeatureResults:t,deleteFeatureResults:i,updateFeatureResults:a}=e,r=t.find((e=>!!e.error))||a.find((e=>!!e.error))||i.find((e=>!!e.error));if(r)throw r.error}}_createUpdatingResolver(){const e=u();return this._updatingHandles.addPromise(e.promise),e}_logErrorAndCancelWorkflow(e){const{name:t,message:i,details:a}=e;this._logError(t??"editing:workflow-start-failed",i??void 0,a??e),this._cancelWorkflow({force:!0})}_itemIsSuspended(e){const t=this.findEditorItemForLayer(e);return null!=t&&(!t.visible||t.disabled)}_logError(e,t,i){n.getLogger(this).error(new r(e,t,i))}_syncSelectionSources(){const{selectionManager:e}=this,t=[];this.editorItems.forEach((e=>{C(e.layer)&&e.supportsUpdateWorkflow&&t.push(e.layer)})),e.sources.removeAll(),e.sources.addMany(t)}async _onSelectionComplete(e){if(e.aborted)return;const{operationType:t,selection:i}=e,{effectiveSelectionManager:a}=this,r="ready"===this.state,s=1===i.length;if(r&&s&&(0===a.count&&"add"===t||"replace"===t))return this.startUpdateWorkflowAtFeatureEdit(i[0]);switch(t){case"remove":a.updateSelection({current:[],added:[],removed:i});break;case"replace":a.clear(),a.updateSelection({current:i,added:[],removed:[]});break;case"add":a.updateSelection({current:i,added:[],removed:[]})}}};e([v()],ie.prototype,"_featureTemplatesLayersAndTables",null),e([v()],ie.prototype,"_snappingManager",void 0),e([v()],ie.prototype,"activeFeatureCount",null),e([v({readOnly:!0})],ie.prototype,"activeWorkflow",void 0),e([v()],ie.prototype,"activeLeafWorkflow",null),e([v({readOnly:!0})],ie.prototype,"_activityQueue",void 0),e([v({readOnly:!0})],ie.prototype,"canCreate",null),e([v()],ie.prototype,"canCreateVisible",null),e([v({readOnly:!0})],ie.prototype,"canUpdate",null),e([v()],ie.prototype,"canUpdateVisible",null),e([v()],ie.prototype,"featureTemplatesLayers",null),e([v()],ie.prototype,"editorItems",void 0),e([v()],ie.prototype,"effectiveSelectionManager",null),e([v({readOnly:!0})],ie.prototype,"failures",void 0),e([v()],ie.prototype,"hideTemplatesForInactiveLayers",void 0),e([v({type:O})],ie.prototype,"attachmentsViewModel",void 0),e([v()],ie.prototype,"featureFormViewModel",null),e([v()],ie.prototype,"formViewModel",null),e([v()],ie.prototype,"utilityNetworkAssociationAddAssociationViewModel",null),e([v({type:z})],ie.prototype,"featureTemplatesViewModel",void 0),e([v()],ie.prototype,"labelOptions",null),e([v()],ie.prototype,"layerInfos",void 0),e([v()],ie.prototype,"ownSketchViewModel",void 0),e([v()],ie.prototype,"selectionListViewModel",void 0),e([v()],ie.prototype,"selectionManager",void 0),e([v()],ie.prototype,"selectionToolbarViewModel",void 0),e([v()],ie.prototype,"sketchOptions",void 0),e([v()],ie.prototype,"sketchViewModel",null),e([v({type:S,nonNullable:!0})],ie.prototype,"snappingOptions",void 0),e([v()],ie.prototype,"spinnerViewModel",void 0),e([v()],ie.prototype,"state",null),e([v({readOnly:!0})],ie.prototype,"syncing",null),e([v()],ie.prototype,"updating",null),e([v()],ie.prototype,"tooltipOptions",null),e([v()],ie.prototype,"valueOptions",null),e([v()],ie.prototype,"view",null),e([v()],ie.prototype,"canZoomTo",null),e([v()],ie.prototype,"pageStack",void 0),e([v()],ie.prototype,"showDiscardEditsPrompt",void 0),e([v()],ie.prototype,"_candidateCommitted",void 0),e([v()],ie.prototype,"page",null),e([v()],ie.prototype,"featureFormDisabled",null),e([v()],ie.prototype,"featureFormHasAssociation",null),e([v()],ie.prototype,"canGoBack",null),e([v()],ie.prototype,"shouldShowDeleteButton",null),e([v()],ie.prototype,"hasPendingEdits",null),e([v()],ie.prototype,"snappingManager",null),ie=e([_("esri.widgets.Editor.EditorViewModel")],ie);const ae=ie;export{ae as default};