@arcgis/core 4.34.0-next.56 → 4.34.0-next.57

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 (184) hide show
  1. package/analysis/VolumeMeasurement/VolumeMeasurementCutFillOptions.d.ts +4 -0
  2. package/analysis/VolumeMeasurement/{CutFillOptions.js → VolumeMeasurementCutFillOptions.js} +1 -1
  3. package/analysis/VolumeMeasurementAnalysis.js +1 -1
  4. package/assets/esri/core/workers/RemoteClient.js +1 -1
  5. package/assets/esri/core/workers/chunks/02902303e5585a16ebea.js +1 -0
  6. package/assets/esri/core/workers/chunks/02a31483e09652a1a1a2.js +1 -0
  7. package/assets/esri/core/workers/chunks/0390f3aa624e3f380ce2.js +1 -0
  8. package/assets/esri/core/workers/chunks/047d6f7b1677cc7ab271.js +1 -0
  9. package/assets/esri/core/workers/chunks/04e652df94790f5ca08a.js +1 -0
  10. package/assets/esri/core/workers/chunks/{9f178cf73c63caaea190.js → 06d2251d6f6b3e44800a.js} +1 -1
  11. package/assets/esri/core/workers/chunks/07d5e0633cc2f765037f.js +1 -0
  12. package/assets/esri/core/workers/chunks/{8fa50cac57b6e1ecec76.js → 08393d9cc2ed846dd5b4.js} +1 -1
  13. package/assets/esri/core/workers/chunks/{18ceea59e469a0f2721b.js → 094c741fa8139c3f40cf.js} +1 -1
  14. package/assets/esri/core/workers/chunks/0d946a226b846b3c0849.js +1 -0
  15. package/assets/esri/core/workers/chunks/0f51e51db83f303ce5a6.js +1 -0
  16. package/assets/esri/core/workers/chunks/{6530449cd1975deb61f1.js → 184d3c88ac2fc1d7e2c3.js} +1 -1
  17. package/assets/esri/core/workers/chunks/1cbd59918c60a1a21494.js +1 -0
  18. package/assets/esri/core/workers/chunks/2ded2446700f89155ccd.js +1 -0
  19. package/assets/esri/core/workers/chunks/{19391d60c76a1dc7c262.js → 2f7e192ee2066f863e1d.js} +1 -1
  20. package/assets/esri/core/workers/chunks/{6b11476b2004b4db576e.js → 3445ffd752262673fb13.js} +1 -1
  21. package/assets/esri/core/workers/chunks/38f09e36e174792646bd.js +1 -0
  22. package/assets/esri/core/workers/chunks/{adf11d31f95481f89a55.js → 3b51b61a7b8a1ef87c9b.js} +1 -1
  23. package/assets/esri/core/workers/chunks/3c57b2e13628b5c1f6de.js +1 -0
  24. package/assets/esri/core/workers/chunks/{65e1f5b20a585e04655a.js → 44dc7ec52c4abb700783.js} +1 -1
  25. package/assets/esri/core/workers/chunks/{c91217d977a6baaee74a.js → 4558f2e3e77831758fdc.js} +1 -1
  26. package/assets/esri/core/workers/chunks/4753793daf0b7ff8b5ff.js +1 -0
  27. package/assets/esri/core/workers/chunks/{853b9f29b4d62fa621b9.js → 4d2473e680324dc17cfa.js} +1 -1
  28. package/assets/esri/core/workers/chunks/52917b753c5ceab0c1f7.js +353 -0
  29. package/assets/esri/core/workers/chunks/{6940bb6524938894a246.js → 53873f26a2c24cd75e4a.js} +1 -1
  30. package/assets/esri/core/workers/chunks/561a2078458bc0339f83.js +1 -0
  31. package/assets/esri/core/workers/chunks/{6dc0009889f2b7cc8cff.js → 5691d504ffe5592bc40f.js} +1 -1
  32. package/assets/esri/core/workers/chunks/56b4dcd04c844eaacd60.js +1 -0
  33. package/assets/esri/core/workers/chunks/5f079be7f322768aef21.js +1 -0
  34. package/assets/esri/core/workers/chunks/61a294f9411bf884f2ab.js +1 -0
  35. package/assets/esri/core/workers/chunks/{ad93a2621f75270f06cb.js → 69fbe363bb130fdd8146.js} +1 -1
  36. package/assets/esri/core/workers/chunks/{722931d1a60be461e521.js → 70cf81ec5a901782d2db.js} +1 -1
  37. package/assets/esri/core/workers/chunks/{24ac204d8a045aa821be.js → 7388e8c905d93dea1c05.js} +1 -1
  38. package/assets/esri/core/workers/chunks/749c7159e0902388e828.js +1 -0
  39. package/assets/esri/core/workers/chunks/76ff7ccfe583927918f3.js +969 -0
  40. package/assets/esri/core/workers/chunks/{ae73ac81bd10614c2b53.js → 7714228825fb44d506df.js} +1 -1
  41. package/assets/esri/core/workers/chunks/{6130bc641aa7c1bcaaa8.js → 7c23be93d394f1bee941.js} +1 -1
  42. package/assets/esri/core/workers/chunks/7c86af4f60cea383ed96.js +1 -0
  43. package/assets/esri/core/workers/chunks/7eda1c400658b6a99be8.js +1 -0
  44. package/assets/esri/core/workers/chunks/{97ae2fdb6cb98249f5fa.js → 7f80bbbd0897082c1af3.js} +1 -1
  45. package/assets/esri/core/workers/chunks/80a69897fa3ce1eaa6e7.js +1 -0
  46. package/assets/esri/core/workers/chunks/80bd5988180f4618fd61.js +1 -0
  47. package/assets/esri/core/workers/chunks/{b47688e3263099540873.js → 81e518dd62bd95611d00.js} +1 -1
  48. package/assets/esri/core/workers/chunks/{10b46438885916d18425.js → 8257352421f453a669e9.js} +1 -1
  49. package/assets/esri/core/workers/chunks/8762928d10c3821738ad.js +1 -0
  50. package/assets/esri/core/workers/chunks/88a5e7415f8858c454f7.js +1 -0
  51. package/assets/esri/core/workers/chunks/893e5eb5c028c4704317.js +1 -0
  52. package/assets/esri/core/workers/chunks/8ead467a5af0d9bba804.js +1 -0
  53. package/assets/esri/core/workers/chunks/91e04d03b0013bcaad82.js +1 -0
  54. package/assets/esri/core/workers/chunks/{c7d4c296011c5393bcaa.js → 9275313e0f1f521b2658.js} +1 -1
  55. package/assets/esri/core/workers/chunks/{e666ca4d14b6490485d6.js → 92b60d4fb09711919601.js} +1 -1
  56. package/assets/esri/core/workers/chunks/977582cb3c8f17a2cb4c.js +1 -0
  57. package/assets/esri/core/workers/chunks/{5c556468e2a598ab793a.js → 9940e59033a8a1eff2a9.js} +1 -1
  58. package/assets/esri/core/workers/chunks/998c38974372720b1c52.js +1 -0
  59. package/assets/esri/core/workers/chunks/{9928e432b884c75c3436.js → 9d920f3488d59e7f276c.js} +1 -1
  60. package/assets/esri/core/workers/chunks/{d0124b0dd62b331afe58.js → 9fef330b241f958b55df.js} +1 -1
  61. package/assets/esri/core/workers/chunks/{a778a72456fefdf40115.js → a249e56a0be8cef33ba8.js} +1 -1
  62. package/assets/esri/core/workers/chunks/a3ee76b7e46d3fba7cf7.js +1 -0
  63. package/assets/esri/core/workers/chunks/a7530dcb08b43e37bbb2.js +1 -0
  64. package/assets/esri/core/workers/chunks/{2cda605c302176905e84.js → a96ac5c68d84122e7751.js} +1 -1
  65. package/assets/esri/core/workers/chunks/{e6bf4f3f6868dc9028e3.js → aab349d4624b78ef429f.js} +1 -1
  66. package/assets/esri/core/workers/chunks/acf13a64df2991a4cb6b.js +1 -0
  67. package/assets/esri/core/workers/chunks/b5640f9623a9c9ded92a.js +1 -0
  68. package/assets/esri/core/workers/chunks/{d42fd0effc560eefb14b.js → b6a201e86f9caef45ff0.js} +1 -1
  69. package/assets/esri/core/workers/chunks/bb67d491f62a5cce96cd.js +1 -0
  70. package/assets/esri/core/workers/chunks/{862fe2f96d4b777ff5b8.js → bbdbb618a18542f7a4a2.js} +1 -1
  71. package/assets/esri/core/workers/chunks/bc9f54a6b577c43189fd.js +1 -0
  72. package/assets/esri/core/workers/chunks/{6fe738748ce837811ff4.js → bd4125d163f372a7e978.js} +1 -1
  73. package/assets/esri/core/workers/chunks/bead38898c3f4d4d3569.js +1 -0
  74. package/assets/esri/core/workers/chunks/c51e2a048df152abd901.js +1 -0
  75. package/assets/esri/core/workers/chunks/{22334a464f798b5279b2.js → c80c032c5b7a11db177a.js} +1 -1
  76. package/assets/esri/core/workers/chunks/{3490d47cac7c8dec70cd.js → c9c109d43a1e5160955d.js} +2 -2
  77. package/assets/esri/core/workers/chunks/{4d5abcf57a6ded4750ba.js → cac060a187f3a27a19ba.js} +1 -1
  78. package/assets/esri/core/workers/chunks/cc748d4f4adb9c584aa4.js +1 -0
  79. package/assets/esri/core/workers/chunks/cf699b9bb530b87be14c.js +1 -0
  80. package/assets/esri/core/workers/chunks/d578c3880eaf2dd62324.js +1 -0
  81. package/assets/esri/core/workers/chunks/{5d331f7628514a572f82.js → d6ab4d55f1023ee6ec6a.js} +1 -1
  82. package/assets/esri/core/workers/chunks/d71836cf70b9604832f1.js +1 -0
  83. package/assets/esri/core/workers/chunks/{4874aabdb5c60ca66216.js → db2b8d8cf7131554cf7e.js} +1 -1
  84. package/assets/esri/core/workers/chunks/de4da985c398c8bcf2e7.js +1 -0
  85. package/assets/esri/core/workers/chunks/{cb57cdff976d2d4b0b41.js → e1b25b1ce3bd4f0f2cda.js} +1 -1
  86. package/assets/esri/core/workers/chunks/ef85cd0e82d59db8a26f.js +33 -0
  87. package/assets/esri/core/workers/chunks/{faf4002f9547a0cc4e33.js → fae6030a81cb91a91b69.js} +1 -1
  88. package/assets/esri/core/workers/chunks/fd1fdb97a294a1b7041d.js +1 -0
  89. package/assets/esri/core/workers/chunks/{ff42b24b48019a03d841.js → fe55833c80cf59df9c2b.js} +1 -1
  90. package/assets/esri/core/workers/chunks/{ff8a4bf1bceb362d67ab.js → ff7962063d132c1ec814.js} +1 -1
  91. package/config.js +1 -1
  92. package/geometry/Multipoint.js +1 -1
  93. package/geometry/support/boundsUtils.js +1 -1
  94. package/geometry/support/contains.js +1 -1
  95. package/geometry/support/curves/circleUtils.js +1 -1
  96. package/geometry/support/curves/circularArcUtils.js +1 -1
  97. package/geometry/support/curves/curveUtils.js +1 -1
  98. package/geometry/support/curves/ellipticArc7Utils.js +1 -1
  99. package/geometry/support/curves/rotate.js +5 -0
  100. package/geometry/support/extentUtils.js +1 -1
  101. package/geometry/support/rotate.js +1 -1
  102. package/graphic/ImageryGraphicOrigin.js +5 -0
  103. package/graphic/ImageryTileGraphicOrigin.js +5 -0
  104. package/graphic/WCSGraphicOrigin.js +5 -0
  105. package/graphic/isImageryGraphicOrigin.js +5 -0
  106. package/graphic/isImageryTileGraphicOrigin.js +5 -0
  107. package/graphic/isWCSGraphicOrigin.js +5 -0
  108. package/interfaces.d.ts +12 -15
  109. package/kernel.js +1 -1
  110. package/layers/CatalogLayer.js +1 -1
  111. package/layers/FeatureLayer.js +1 -1
  112. package/layers/GroundLayer.js +5 -0
  113. package/layers/ImageryLayer.js +1 -1
  114. package/layers/ImageryTileLayer.js +1 -1
  115. package/layers/WCSLayer.js +1 -1
  116. package/layers/catalog/CatalogFootprintLayer.js +1 -1
  117. package/layers/mixins/ArcGISImageService.js +1 -1
  118. package/package.json +1 -1
  119. package/support/revision.js +1 -1
  120. package/views/2d/layers/ImageryLayerView2D.js +1 -1
  121. package/views/2d/layers/ImageryTileLayerView2D.js +1 -1
  122. package/views/2d/layers/features/layerAdapters/CatalogFootprintLayerAdapter.js +1 -1
  123. package/views/2d/layers/imagery/ImageryTileView2D.js +1 -1
  124. package/views/3d/analysis/VolumeMeasurement/{CutFillVolumeMeasurementComputation.js → VolumeMeasurementCutFillComputation.js} +1 -1
  125. package/views/3d/analysis/VolumeMeasurement/{CutFillVolumeMeasurementController.js → VolumeMeasurementCutFillController.js} +1 -1
  126. package/views/3d/analysis/VolumeMeasurement/{CutFillVolumeMeasurementVisualization.js → VolumeMeasurementCutFillVisualization.js} +1 -1
  127. package/views/3d/analysis/VolumeMeasurementAnalysisView3D.js +1 -1
  128. package/views/3d/layers/CatalogFootprintLayerView3D.js +1 -1
  129. package/views/3d/layers/IntegratedMesh3DTilesLayerView3D.js +1 -1
  130. package/views/GroundView.js +1 -1
  131. package/views/draw/support/Box.js +1 -1
  132. package/views/draw/support/Reshape.js +1 -1
  133. package/views/draw/support/drawUtils.js +1 -1
  134. package/views/interactive/editGeometry/operations/RotateVertex.js +1 -1
  135. package/views/interactive/editGeometry/operations/curveOperationUtils.js +1 -1
  136. package/views/layers/ImageryLayerView.js +1 -1
  137. package/views/layers/ImageryTileLayerView.js +1 -1
  138. package/analysis/VolumeMeasurement/CutFillOptions.d.ts +0 -4
  139. package/assets/esri/core/workers/chunks/01e8b9dc77a57d1c2a52.js +0 -1
  140. package/assets/esri/core/workers/chunks/027cfcde29fe87aa2ffe.js +0 -1
  141. package/assets/esri/core/workers/chunks/03ee4d63aa8de44958ab.js +0 -1
  142. package/assets/esri/core/workers/chunks/0a4586e596413ef7a4b5.js +0 -1
  143. package/assets/esri/core/workers/chunks/0a6d33d013628f671aea.js +0 -1
  144. package/assets/esri/core/workers/chunks/1166ed298cf5ca7ad444.js +0 -1
  145. package/assets/esri/core/workers/chunks/13797036850dcc3671c3.js +0 -1
  146. package/assets/esri/core/workers/chunks/1a2278b9fe9666342728.js +0 -1
  147. package/assets/esri/core/workers/chunks/1e01aaebdeffdfc0c6bd.js +0 -1
  148. package/assets/esri/core/workers/chunks/222f981e876f60ae282f.js +0 -1
  149. package/assets/esri/core/workers/chunks/277941bec15525dbd3a0.js +0 -1
  150. package/assets/esri/core/workers/chunks/2cb14d040e67a261b31c.js +0 -1
  151. package/assets/esri/core/workers/chunks/31c088966ccfff2ea1db.js +0 -1
  152. package/assets/esri/core/workers/chunks/3245d20ea4bb779f87ef.js +0 -1
  153. package/assets/esri/core/workers/chunks/46a470bea2a3601182dc.js +0 -1
  154. package/assets/esri/core/workers/chunks/4b58da6cb91f7bf6af8b.js +0 -1
  155. package/assets/esri/core/workers/chunks/5900dde7a201a7d47469.js +0 -1
  156. package/assets/esri/core/workers/chunks/5b2ff220aebe464dac23.js +0 -1
  157. package/assets/esri/core/workers/chunks/5f518931a660b3c4f519.js +0 -1
  158. package/assets/esri/core/workers/chunks/66f3659ba18f92cd623e.js +0 -1
  159. package/assets/esri/core/workers/chunks/67355372ac5fd8a15d18.js +0 -1
  160. package/assets/esri/core/workers/chunks/6801b92bce7a918fda6f.js +0 -1
  161. package/assets/esri/core/workers/chunks/7b560ac0be93c6aa9940.js +0 -1
  162. package/assets/esri/core/workers/chunks/7bdfc7c7ce1d94c00745.js +0 -353
  163. package/assets/esri/core/workers/chunks/83737d86584bf1b32368.js +0 -1
  164. package/assets/esri/core/workers/chunks/854bfda25bb406814929.js +0 -1
  165. package/assets/esri/core/workers/chunks/855f25ce748aaef44b1a.js +0 -1
  166. package/assets/esri/core/workers/chunks/87f68c2b9361bd3f8cac.js +0 -1
  167. package/assets/esri/core/workers/chunks/9307108821d82c131654.js +0 -1
  168. package/assets/esri/core/workers/chunks/97a38d700f2cb8807d51.js +0 -1
  169. package/assets/esri/core/workers/chunks/9e9be7f6ea32957f1088.js +0 -33
  170. package/assets/esri/core/workers/chunks/af4412e79275c5a87539.js +0 -1
  171. package/assets/esri/core/workers/chunks/cbec768cd98caff212f2.js +0 -1
  172. package/assets/esri/core/workers/chunks/d3a7747f23e91d1f1b5e.js +0 -1
  173. package/assets/esri/core/workers/chunks/d3ae88fcde2d7fb3e2e2.js +0 -1
  174. package/assets/esri/core/workers/chunks/d81c4afad4abe2d1d0b9.js +0 -1
  175. package/assets/esri/core/workers/chunks/d87fdc64a5cc6be4bd69.js +0 -1
  176. package/assets/esri/core/workers/chunks/db5d3feeb61ccb5ede98.js +0 -1
  177. package/assets/esri/core/workers/chunks/dfb12f42b8d319ffa5fc.js +0 -1
  178. package/assets/esri/core/workers/chunks/ead1acf95c3385630da8.js +0 -1001
  179. package/assets/esri/core/workers/chunks/f3e3c2340452c1d60c95.js +0 -1
  180. package/assets/esri/core/workers/chunks/f4d7cbd33ef8710d7316.js +0 -1
  181. package/assets/esri/core/workers/chunks/f74b0cdc1c2b56bac5f0.js +0 -1
  182. package/assets/esri/core/workers/chunks/f807e7fc90e0e7ce6b67.js +0 -1
  183. package/assets/esri/core/workers/chunks/ff4e15a872de94d2b438.js +0 -1
  184. /package/assets/esri/core/workers/chunks/{3490d47cac7c8dec70cd.js.LICENSE.txt → c9c109d43a1e5160955d.js.LICENSE.txt} +0 -0
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.34/esri/copyright.txt for details.
4
4
  */
5
- import{__decorate as e}from"tslib";import has from"../../../core/has.js";import t from"../../../core/Logger.js";import{destroyMaybe as i}from"../../../core/maybe.js";import{initial as s,watch as r}from"../../../core/reactiveUtils.js";import{schedule as o}from"../../../core/scheduling.js";import{property as a}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/RandomLCG.js";import{subclass as n}from"../../../core/accessorSupport/decorators/subclass.js";import{fromMat4 as l,invert as c}from"../../../core/libs/gl-matrix-2/math/mat3.js";import{create as d,IDENTITY as m}from"../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{translate as h,getTranslation as u}from"../../../core/libs/gl-matrix-2/math/mat4.js";import{create as p}from"../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{fromValues as f}from"../../../core/libs/gl-matrix-2/factories/quatf64.js";import{f as g,o as b}from"../../../chunks/vec32.js";import{fromArray as y,create as _}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{fromValues as w}from"../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{SphericalECEFSpatialReferenceLike as v}from"../../../geometry/ellipsoidUtils.js";import{computeTranslationToOriginAndRotation as x}from"../../../geometry/projection/computeTranslationToOriginAndRotation.js";import{localLinearScaleFactors as C}from"../../../geometry/projection/localLinearScaleFactors.js";import{projectVectorToVector as j}from"../../../geometry/projection/projectVectorToVector.js";import{create as T}from"../../../geometry/support/aaBoundingRect.js";import{BufferViewVec2f as M,BufferViewVec4f as O,BufferViewVec4u8 as U,BufferViewVec4u16 as P,BufferViewVec3f as H,BufferViewVec3u8 as R,BufferViewVec3u16 as F,BufferViewInt16 as S,BufferViewUint32 as E,BufferViewUint16 as A}from"../../../geometry/support/buffer/BufferView.js";import k from"../../../layers/support/SceneModification.js";import{getElevationOffsetInMeters as V}from"../../../support/elevationInfoUtils.js";import{toWasmModification as I}from"./I3SMeshWorkerHandle.js";import{IntegratedMesh3DTilesViewPerformanceInfo as B}from"./IntegratedMesh3DTilesViewPerformanceInfo.js";import{LayerView3D as L}from"./LayerView3D.js";import{addLayerViewToWasm as D,removeLayerViewFromWasm as G,getLyr3DWasm as z}from"./Lyr3DWasm.js";import{LayerElevationProvider as N}from"./i3s/LayerElevationProvider.js";import{primTypeConversion as W,alphaModeConversion as $,faceCullingConversion as J,wrapModeConversion as q,lyr3DTypeToByteSize as K}from"./support/lyr3dTypeConversions.js";import{Tiles3DIntersectionHandler as Q}from"./support/Tiles3DIntersectionHandler.js";import{ElevationRange as X}from"../support/ElevationRange.js";import{toBoundingRect as Y}from"../support/extentUtils.js";import{Obb as Z,compute as ee}from"../support/orientedBoundingBox.js";import{ObjectParameters as te}from"../webgl-engine/collections/Component/ObjectParameters.js";import{GeometryParameters as ie,createVertexBufferLayout as se}from"../webgl-engine/collections/Component/SourceGeometry.js";import{Transform as re}from"../webgl-engine/collections/Component/Transform.js";import{RenderTexture as oe}from"../webgl-engine/core/material/RenderTexture.js";import{getEllipsoidMode as ae}from"../webgl-engine/core/shaderLibrary/util/EllipsoidMode.js";import{Attribute as ne}from"../webgl-engine/lib/Attribute.js";import{compressAndTransformNormals as le}from"../webgl-engine/lib/Normals.js";import{Texture as ce}from"../webgl-engine/lib/Texture.js";import{writeAttribute as de,writeBufferVec2 as me}from"../webgl-engine/materials/internal/bufferWriterUtils.js";import he from"../../layers/LayerView.js";import{spatialReferenceIncompatibleError as ue,isInEffectiveScaleRange as pe}from"../../support/layerViewUtils.js";import{TextureCompressionTracker as fe}from"../../support/TextureCompressionTracker.js";import{alphaCutoff as ge}from"../../../webscene/support/AlphaCutoff.js";class be{constructor(){this.handle=0,this.isVisible=!1,this.components=[],this.textureMemoryUsage=0,this.vboMemoryUsage=0,this.cpuMemoryUsage=0,this.textures=[]}get usedMemory(){return this.textureMemoryUsage+this.vboMemoryUsage+this.cpuMemoryUsage}get cachedMemory(){return this.usedMemory}}function ye(e){return Math.round(e/1048.576)/1e3}let _e=class extends(L(he)){constructor(){super(...arguments),this.type="integrated-mesh-3dtiles",this._compressionTracker=new fe,this._modifications=new Array,this._visibleGeometryChangedSchedulerHandle=null,this._wasmLayerId=-1,this.ignoresMemoryFactor=!1,this.drapeTargetType=1,this._applySSAO=!has("disable-feature:im-ssao"),this._shadeNormals=!!has("enable-feature:im-shading"),this._lyrHandleToObjects=new Map,this._initialCullFace=new Map,this._suspendedHandle=null,this._dbgFlags=new Set}get hasModifications(){return this._modifications&&this._modifications.length>0}initialize(){if(this._dbgFlags.add(3),this._dbg(2,"Tiles3DLayerView3D initialize() called"),this._updatingHandles.add(()=>this.layer.modifications,()=>this._loadModifications(),s),!this._canProjectWithoutEngine())throw ue("layer",this.layer.spatialReference.wkid,this.view.renderSpatialReference?.wkid);const e=D(this).then(e=>{this._wasmLayerId=e,this._intersectionHandler=new Q(this),this.view.sceneIntersectionHelper.addIntersectionHandler(this._intersectionHandler),this._updatingHandles.add(()=>this.slicePlaneEnabled,e=>this._slicePlaneEnabledChange(e)),this._updatingHandles.add(()=>this._modifications,()=>this._modificationsChanged(),s),this._updatingHandles.add(()=>this.fullOpacity,e=>this._opacityChange(e)),this._updatingHandles.add(()=>this.view.clippingArea,()=>this._clippingAreaChanged(),s),this._elevationProvider=new N({view:this.view,layerElevationSource:this,intersectionHandler:this._intersectionHandler}),this.view.elevationProvider.register("im",this._elevationProvider),this.view.basemapTerrain.overlayManager.registerDrapeTarget(this);const t=this.view.resourceController.memoryController.newCache(`t3d-${this.uid}`,e=>this._onRemoveFromCache(e));this._memCache=t,this.addHandles([r(()=>this.layer.elevationInfo,e=>this._elevationInfoChanged(e))]),this._suspendedHandle=r(()=>this.suspended,e=>this._wasm?.setEnabled(this,!e),s)});this.addResolvingPromise(e)}_opacityChange(e){this.objects.forEach(t=>{this._collection.getMaterial(t).objectOpacity=e})}destroy(){this._dbg(2,"Tiles3DLayerView3D destroy() called"),G(this),this._suspendedHandle&&(this._suspendedHandle.remove(),this._suspendedHandle=null),this._intersectionHandler&&(this.view.sceneIntersectionHelper.removeIntersectionHandler(this._intersectionHandler),this._intersectionHandler=null),this._elevationProvider&&(this._elevationProvider.objectsChanged(this._obbs),this.view.elevationProvider.unregister(this._elevationProvider),this._elevationProvider=null),this.view.basemapTerrain.overlayManager.unregisterDrapeTarget(this),this._lyrHandleToObjects.forEach(e=>this.freeObject(e)),this._lyrHandleToObjects.clear(),this._initialCullFace.clear(),this._memCache=i(this._memCache),this._updatingHandles=i(this._updatingHandles),this.emit("visible-geometry-changed"),this._visibleGeometryChangedSchedulerHandle&&(this._visibleGeometryChangedSchedulerHandle.remove(),this._visibleGeometryChangedSchedulerHandle=null)}_modificationsChanged(){const e=this.layer.spatialReference,t=I(this._layerClippingArea,this._modifications,e);this._wasm?.setMeshModifications(this,t,e.wkid)}_clippingAreaChanged(){const e=this.layer.spatialReference,t=T();this._layerClippingArea=Y(this.view.clippingArea,t,e)?t:null,this._modificationsChanged()}_visibleGeometryChanged(){this._visibleGeometryChangedSchedulerHandle??=o(()=>{this.emit("visible-geometry-changed"),this._visibleGeometryChangedSchedulerHandle=null})}_slicePlaneEnabledChange(e){this._intersectionHandler&&(this._intersectionHandler.slicePlaneEnabled=e),this.objects.forEach(t=>{const i=this._collection.getMaterial(t);i.commonMaterialParameters.hasSlicePlane=e,i.commonMaterialParameters.cullFace=e?0:this._initialCullFace.get(t)})}_elevationInfoChanged(e){this._wasm?.setLayerOffset(this,V(e))}get _obbs(){return this.objects.map(e=>this._collection.getComponentObb(e))}get _wasm(){return z(this.view)}get wasmLayerId(){return this._wasmLayerId}get usedMemory(){let e=0;return this._lyrHandleToObjects.forEach(t=>{t.isVisible&&(e+=t.usedMemory)}),e}get unloadedMemory(){return 0}get cachedMemory(){let e=0;return this._lyrHandleToObjects.forEach(t=>{t.isVisible||(e+=t.usedMemory)}),e}get visibleAtCurrentScale(){return pe(this.layer.effectiveScaleRange,this.view.scale)}get performanceInfo(){let e=0,t=0,i=0,s=0,r=0,o=0;return this._lyrHandleToObjects.forEach(a=>{a.isVisible?(e+=a.textureMemoryUsage,t+=a.vboMemoryUsage,r++):(i+=a.textureMemoryUsage,s+=a.vboMemoryUsage,o++)}),new B(this.usedMemory,r,o,ye(t),ye(e),ye(s),ye(i))}_canProjectWithoutEngine(){if(2===this.view.state.viewingMode){const e=this.view.renderSpatialReference?.isWebMercator?3857:this.view.renderSpatialReference?.wkid??-1;if(3857!==e&&32662!==e)return!1}return!0}get _stage(){return this.view.stage}get _collection(){return this._stage.renderView.componentObjectCollection}get elevationOffset(){return V(this.layer.elevationInfo)}get elevationRange(){const e=this.fullExtent;return e?.zmin&&e?.zmax?new X(e.zmin,e.zmax):null}getElevationRange(e){return null}get fullExtent(){return this.layer.fullExtent}get objects(){return Array.from(this._lyrHandleToObjects.values()).reduce((e,t)=>e.concat(t.components),new Array)}isUpdating(){const e=this._wasm;return!(this._wasmLayerId<0||null==e)&&(e.isUpdating(this._wasmLayerId)||this._compressionTracker.compressing)}updatingFlagChanged(){this.notifyChange("updating")}async createRenderable(e){const t=e.meshData;if(null==t.data)throw new Error("meshData.data undefined");if(t.desc=JSON.parse(t.desc),null==t.desc)throw new Error("meshData.desc undefined");const i=y(t.desc.origin),s=new Array,r=new Map,o=new be;o.handle=e.handle,this._lyrHandleToObjects.set(e.handle,o);const a=this.view.basemapTerrain.spatialReference;let n,T;if("global"===this.view.viewingMode){const e=p();x(v,i,e,a),n=l(d(),e),T=c(d(),n)}else n=m,T=m;const O=p();h(O,O,i);const U=u(_(),O);let P=null;const H=_();if(t.desc.obb){const e=t.desc.obb.quaternion;P=new Z(t.desc.obb.center,t.desc.obb.halfSize,f(e[0],e[1],e[2],e[3]))}for(let l=0;l<t.desc.prims.length;l++){const e=t.desc.prims[l];this._dbg(2,JSON.stringify(e));if(null==W[e.ptype]||null==t.data){this._dbg(2,"[Unsupported Feature] Unsupported primitive mode ("+e.ptype+"). Skipping primitive.");continue}const c=t.desc?.materials&&null!=e.materialId?t.desc.materials[e.materialId]:null,d=null!=c?c.lightingModel:"Unlit",{positionView:h,positionAttr:u,normalsView:p,normalsAttr:f,colorAttr:y,texCoord0Attr:v,indicesView:x}=this.getBufferViews(e,t.data.buffer,n);if(null==u||null==h||null==x)continue;const O=new ie(null!=y,v?1:0,null!=p,this._shadeNormals,this._applySSAO),R=u.data.length/u.size,F=(e,t)=>!e||e.data.length/e.size===R||(this._dbg(3,`${t} !== numPos. Skipping primitive.`),!1);if(!F(v,"numTexcoord")||!F(y,"numColors")||!F(f,"normals"))continue;const S=se(O);if(null!=P?P=P.clone():(P=ee(u),g(H,P.center,i),P.center=H),n!==m)for(let t=0;t<h.count;t++)h.getVec(t,H),b(H,H,n),h.setVec(t,H);const E=S.createBuffer(u.data.length);if(de("position",u,null,null,E,0),null!=v){const e=E.getField("uv0",M);me(v,e,0)}null!=y&&de("color",u,null,null,E,0),null!=f&&de("normalCompressed",f,null,null,E,0);const A=new Uint32Array([0,x.typedBuffer.length]),k={vertices:{data:E.buffer,count:E.byteLength/S.stride,layoutParameters:O},positionData:{positions:h.typedBuffer,indices:x.typedBuffer},indices:x.typedBuffer,componentOffsets:A};o.cpuMemoryUsage+=h.count,o.cpuMemoryUsage+=x.count;const V=this.view.renderSpatialReference,I=_(),B=[1,1,1];C(U,V,B,a)||this._dbg(3,"Unsupported coordinate system for IM overlay"),j(U,V,I,a);const L=this._collection.createObject(new te(w(I[0],I[1],B[0],B[1]),new re(U,T),P,k));c&&this._collection.updateMaterial(L,e=>{e.baseColor=c.baseColorFactor,e.usePBR="Pbr"===d,e.hasParametersFromSource=!1,e.baseColorTexture=this._getTexture(c.baseColorTex,t,r,o),e.usePBR&&(e.mrrFactors=[c.metallicFactor,c.roughnessFactor,0],e.emissiveBaseColor=c.emissiveFactor??[0,0,0],e.metallicRoughnessTexture=this._getTexture(c.metalTex,t,r,o),e.emissionTexture=this._getTexture(c.emissiveTex,t,r,o),e.occlusionTexture=this._getTexture(c.occlusionTex,t,r,o),e.normalTexture=this._getTexture(c.normalTex,t,r,o)),e.objectOpacity=0,e.alphaDiscardMode=2;const i=[];e.baseColorTexture&&i.push(e.baseColorTexture.loadPromise),e.usePBR&&e.metallicRoughnessTexture&&i.push(e.metallicRoughnessTexture.loadPromise),e.usePBR&&e.emissionTexture&&i.push(e.emissionTexture.loadPromise),e.usePBR&&e.occlusionTexture&&i.push(e.occlusionTexture.loadPromise),e.usePBR&&e.normalTexture&&i.push(e.normalTexture.loadPromise);const a=Promise.all(i);s.push(a),a.then(()=>{e.alphaDiscardMode=$[c.alphaMode],e.objectOpacity=this.fullOpacity,o.textureMemoryUsage+=e.baseColorTexture?.glTexture?.usedMemory||0,e.usePBR&&(o.textureMemoryUsage+=e.metallicRoughnessTexture?.glTexture?.usedMemory||0,o.textureMemoryUsage+=e.emissionTexture?.glTexture?.usedMemory||0,o.textureMemoryUsage+=e.occlusionTexture?.glTexture?.usedMemory||0,o.textureMemoryUsage+=e.normalTexture?.glTexture?.usedMemory||0)}),e.commonMaterialParameters.doubleSided=c.isDoubleSided,e.commonMaterialParameters.cullFace=c.faceCulling?J[c.faceCulling]:2,this._initialCullFace.set(L,e.commonMaterialParameters.cullFace),e.commonMaterialParameters.hasSlicePlane=this.slicePlaneEnabled,e.componentParameters.castShadows=0,e.textureAlphaCutoff=c.alphaCutoff??ge,e.alphaDiscardMode=$[c.alphaMode],e.isIntegratedMesh=!0,e.polygonOffsetEnabled=!1,e.hasOccludees=!1,e.ellipsoidMode=ae(this.view.spatialReference)}),o.components.push(L),o.vboMemoryUsage+=this._collection.getObjectGPUMemoryUsage(L)}if(await Promise.all(s),r.forEach(e=>{o.textures.push(e)}),!this._memCache)throw new Error("no memCache");return this._memCache.put(`${o.handle}`,o),{memUsageBytes:o.usedMemory}}freeRenderable(e){const t=this._lyrHandleToObjects.get(e);t&&(this.freeObject(t),this._lyrHandleToObjects.delete(e))}freeObject(e){this._memCache&&this._memCache.pop(`${e.handle}`),e.components.forEach(t=>{e.textures.forEach(e=>{this._stage.removeTexture(e)}),this._collection.destroyObject(t),this._initialCullFace.delete(t)})}setRenderableVisibility(e,t,i){if(this._memCache){for(let s=0;s<i;++s){const i=e[s],r=t[s];if(!r)continue;const o=this._lyrHandleToObjects.get(i);o&&(this._visibleGeometryChanged(),o.isVisible=r,o.components.forEach(e=>{this._collection.setObjectVisibility(e,r),this._elevationProvider.objectChanged(this._collection.getComponentObb(e))}),this._memCache.pop(`${i}`))}for(let s=0;s<i;++s){const i=e[s],r=t[s];if(r)continue;const o=this._lyrHandleToObjects.get(i);o&&(this._visibleGeometryChanged(),o.isVisible=r,o.components.forEach(e=>{this._collection.setObjectVisibility(e,r),this._elevationProvider.objectChanged(this._collection.getComponentObb(e))}),this._memCache.put(`${i}`,o))}}}_getTexture(e,t,i,s){let r=null;if(e&&t.desc?.images&&t.data?.buffer){const o=t.desc.images[e?.imageId];if(r=i.get(o),!r&&o){const a=this._stage.renderView.renderingContext.parameters.maxMaxAnisotropy,n=!!o.mipCount||a>1,l=q[e.wrapMode??"None"];let c=o.alpha?4:3;const d=new Uint8Array(t.data.buffer,o.data.byteOffset,o.data.byteCount);let m=null,h=null,u=null;switch(o.format){case"Raw":"R8"===o.pixelFormat?(m=d,c=1,h=""):"Rgb8"===o.pixelFormat?(m=d,c=3,h=""):"Rgba8"===o.pixelFormat&&(m=d,c=4,h="");break;case"Dxt1":m=d,c=3,h="image/vnd-ms.dds";break;case"Dxt5":m=d,c=4,h="image/vnd-ms.dds";break;case"Basis":m=d,c=3,h="image/ktx2";break;case"Png":h="image/png",u=document.createElement("img");break;case"Jpeg":h="image/jpeg",u=document.createElement("img");break;case"Etc2":h="image/ktx",u=document.createElement("img");break;case"Astc":this._dbg(3,"Astc texture not supported");break;case"Pvrtc":this._dbg(3,"Pvrtc texture not supported")}if(u&&h){const e=new Blob([d],{type:h});u.src=URL.createObjectURL(e),m=u}if(m&&null!=h){const e=has("enable-feature:esri-compress-IM-textures")?{compressionTracker:this._compressionTracker,compressionCallback:e=>{e&&e>0&&(s.textureMemoryUsage-=e)}}:void 0;r=new ce(m,{mipmap:n,maxAnisotropy:a,encoding:h,wrap:l,components:c,compressionOptions:e,noUnpackFlip:!0,width:o.mip0Width,height:o.mip0Height}),this._stage.addTexture(r),i.set(o,r)}}}return r?new oe(this.view.stage.renderView.textures,r.id):null}getBufferViews(e,t,i){let s,r,o,a,n,l,c,d=null;for(let h=0;h<e.atrbs.length;h++){const c=e.atrbs[h],u=c.view,p=void 0,f=u.byteOffset+u.byteCount,g=u.byteCount/K[u.type],b=[...Array(g).keys()].map(e=>e);try{switch(c.sem){case"Position":3!==u.ncomp||"F32"!==u.type?this._dbg(3,"[Unsupported Feature] Unsupported view for Position ("+u+")"):(s=new H(t,u.byteOffset,p,f),r=new ne(s.typedBuffer,b,3));break;case"Normal":if(3!==u.ncomp||"F32"!==u.type)this._dbg(3,"[Unsupported Feature] Unsupported view for Normal ("+u+")");else{const e=new H(t,u.byteOffset,p,f),s=le(e.typedBuffer,i);n=new S(s.buffer),l=new ne(n.typedBuffer,b,2)}break;case"TexCoord":2!==u.ncomp||"F32"!==u.type?this._dbg(3,"[Unsupported Feature] Unsupported view for Texcoord ("+u+")"):void 0===a&&(a=new ne(new M(t,u.byteOffset,p,f).typedBuffer,b,2));break;case"Color":4===u.ncomp?("F32"===u.type&&(d=new O(t,u.byteOffset,p,f)),"U8"===u.type&&(d=new U(t,u.byteOffset,p,f)),"U16"===u.type&&(d=new P(t,u.byteOffset,p,f))):3===u.ncomp&&("F32"===u.type&&(d=new H(t,u.byteOffset,p,f)),"U8"===u.type&&(d=new R(t,u.byteOffset,p,f)),"U16"===u.type&&(d=new F(t,u.byteOffset,p,f))),null==d?this._dbg(2,"[Unsupported Feature] Unsupported view for Color ("+u+")"):o=new ne(d.typedBuffer,b,u.ncomp);break;case"FeatureIndex":break;default:this._dbg(2,"[Unsupported Feature] Unsupported semantic ("+c.sem+"). Skipping vertex attribute.")}}catch(m){this._dbg(2,"Error Creating buffer ("+m+"). Skipping vertex attribute.")}}if(e.index){const i=e.index.view,s=void 0,r=i.byteOffset+i.byteCount;switch(e.index.view.type){case"U16":c=new A(t,i.byteOffset,s,r);break;case"U32":c=new E(t,i.byteOffset,s,r);break;default:this._dbg(3,"[Unsupported Feature] index type not supported ("+i.type+").")}}if(null==c&&null!=s){const e=s.count;if(e<65535){const t=new Uint16Array(e);c=new A(t.buffer)}else{const t=new Uint32Array(e);c=new E(t.buffer)}for(let t=0;t<e;t++)c.set(t,t)}return{positionView:s,positionAttr:r,colorAttr:o,texCoord0Attr:a,indicesView:c,normalsView:n,normalsAttr:l}}_loadModifications(){if(this.removeHandles("modifications"),null==this.layer.modifications)return void(this._modifications=[]);const e=this.layer.modifications;this.addHandles(this._updatingHandles.addOnCollectionChange(()=>e,()=>this._modifications=e.toArray(),s),"modifications")}_onRemoveFromCache(e){this._wasm?.onRenderableEvicted(this,e.handle,e.usedMemory),this.freeRenderable(e.handle)}_dbg(e,i){this._dbgFlags.has(e)&&(3===e?t.getLogger(this).error(i):t.getLogger(this).warn(i))}};e([a({type:[k]})],_e.prototype,"_modifications",void 0),e([a()],_e.prototype,"_visibleGeometryChangedSchedulerHandle",void 0),e([a()],_e.prototype,"layer",void 0),e([a({readOnly:!0})],_e.prototype,"visibleAtCurrentScale",null),e([a()],_e.prototype,"elevationOffset",null),_e=e([n("esri.views.3d.layers.IntegratedMesh3DTilesLayerView3D")],_e);const we=_e;export{we as default};
5
+ import{__decorate as e}from"tslib";import has from"../../../core/has.js";import t from"../../../core/Logger.js";import{destroyMaybe as i}from"../../../core/maybe.js";import{initial as s,watch as r,when as o}from"../../../core/reactiveUtils.js";import{schedule as a}from"../../../core/scheduling.js";import{property as n}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/RandomLCG.js";import{subclass as l}from"../../../core/accessorSupport/decorators/subclass.js";import{fromMat4 as c,invert as d}from"../../../core/libs/gl-matrix-2/math/mat3.js";import{create as m,IDENTITY as h}from"../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{translate as u,getTranslation as p}from"../../../core/libs/gl-matrix-2/math/mat4.js";import{create as f}from"../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{fromValues as g}from"../../../core/libs/gl-matrix-2/factories/quatf64.js";import{f as y,o as b}from"../../../chunks/vec32.js";import{fromArray as _,create as w}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{fromValues as v}from"../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{SphericalECEFSpatialReferenceLike as x}from"../../../geometry/ellipsoidUtils.js";import{computeTranslationToOriginAndRotation as C}from"../../../geometry/projection/computeTranslationToOriginAndRotation.js";import{localLinearScaleFactors as j}from"../../../geometry/projection/localLinearScaleFactors.js";import{projectVectorToVector as T}from"../../../geometry/projection/projectVectorToVector.js";import{create as M}from"../../../geometry/support/aaBoundingRect.js";import{BufferViewVec2f as U,BufferViewVec4f as O,BufferViewVec4u8 as P,BufferViewVec4u16 as H,BufferViewVec3f as R,BufferViewVec3u8 as F,BufferViewVec3u16 as A,BufferViewInt16 as S,BufferViewUint32 as E,BufferViewUint16 as k}from"../../../geometry/support/buffer/BufferView.js";import{isLayerGroundReplacement as V}from"../../../layers/GroundLayer.js";import I from"../../../layers/support/SceneModification.js";import{getElevationOffsetInMeters as B}from"../../../support/elevationInfoUtils.js";import{toWasmModification as L}from"./I3SMeshWorkerHandle.js";import{IntegratedMesh3DTilesViewPerformanceInfo as D}from"./IntegratedMesh3DTilesViewPerformanceInfo.js";import{LayerView3D as G}from"./LayerView3D.js";import{addLayerViewToWasm as z,removeLayerViewFromWasm as N,getLyr3DWasm as W}from"./Lyr3DWasm.js";import{LayerElevationProvider as $}from"./i3s/LayerElevationProvider.js";import{primTypeConversion as J,alphaModeConversion as q,faceCullingConversion as K,wrapModeConversion as Q,lyr3DTypeToByteSize as X}from"./support/lyr3dTypeConversions.js";import{Tiles3DIntersectionHandler as Y}from"./support/Tiles3DIntersectionHandler.js";import{ElevationRange as Z}from"../support/ElevationRange.js";import{toBoundingRect as ee}from"../support/extentUtils.js";import{Obb as te,compute as ie}from"../support/orientedBoundingBox.js";import{ObjectParameters as se}from"../webgl-engine/collections/Component/ObjectParameters.js";import{GeometryParameters as re,createVertexBufferLayout as oe}from"../webgl-engine/collections/Component/SourceGeometry.js";import{Transform as ae}from"../webgl-engine/collections/Component/Transform.js";import{RenderTexture as ne}from"../webgl-engine/core/material/RenderTexture.js";import{getEllipsoidMode as le}from"../webgl-engine/core/shaderLibrary/util/EllipsoidMode.js";import{Attribute as ce}from"../webgl-engine/lib/Attribute.js";import{compressAndTransformNormals as de}from"../webgl-engine/lib/Normals.js";import{Texture as me}from"../webgl-engine/lib/Texture.js";import{writeAttribute as he,writeBufferVec2 as ue}from"../webgl-engine/materials/internal/bufferWriterUtils.js";import pe from"../../layers/LayerView.js";import{spatialReferenceIncompatibleError as fe,isInEffectiveScaleRange as ge}from"../../support/layerViewUtils.js";import{TextureCompressionTracker as ye}from"../../support/TextureCompressionTracker.js";import{alphaCutoff as be}from"../../../webscene/support/AlphaCutoff.js";class _e{constructor(){this.handle=0,this.isVisible=!1,this.components=[],this.textureMemoryUsage=0,this.vboMemoryUsage=0,this.cpuMemoryUsage=0,this.textures=[]}get usedMemory(){return this.textureMemoryUsage+this.vboMemoryUsage+this.cpuMemoryUsage}get cachedMemory(){return this.usedMemory}}function we(e){return Math.round(e/1048.576)/1e3}let ve=class extends(G(pe)){constructor(){super(...arguments),this.type="integrated-mesh-3dtiles",this._compressionTracker=new ye,this._modifications=new Array,this._visibleGeometryChangedSchedulerHandle=null,this._wasmLayerId=-1,this.ignoresMemoryFactor=!1,this.drapeTargetType=1,this._applySSAO=!has("disable-feature:im-ssao"),this._shadeNormals=!!has("enable-feature:im-shading"),this._lyrHandleToObjects=new Map,this._initialCullFace=new Map,this._suspendedHandle=null,this._dbgFlags=new Set}get hasModifications(){return this._modifications&&this._modifications.length>0}initialize(){if(this._dbgFlags.add(3),this._dbg(2,"Tiles3DLayerView3D initialize() called"),this._updatingHandles.add(()=>this.layer.modifications,()=>this._loadModifications(),s),!this._canProjectWithoutEngine())throw fe("layer",this.layer.spatialReference.wkid,this.view.renderSpatialReference?.wkid);const e=z(this).then(e=>{this._wasmLayerId=e,this._intersectionHandler=new Y(this),this.view.sceneIntersectionHelper.addIntersectionHandler(this._intersectionHandler),this._updatingHandles.add(()=>this.slicePlaneEnabled,e=>this._slicePlaneEnabledChange(e)),this._updatingHandles.add(()=>this._modifications,()=>this._modificationsChanged(),s),this._updatingHandles.add(()=>this.fullOpacity,()=>this._opacityChange()),this._updatingHandles.add(()=>this.view.clippingArea,()=>this._clippingAreaChanged(),s),this._elevationProvider=new $({view:this.view,layerElevationSource:this,intersectionHandler:this._intersectionHandler}),this.view.elevationProvider.register("im",this._elevationProvider),this.view.basemapTerrain.overlayManager.registerDrapeTarget(this);const t=this.view.resourceController.memoryController.newCache(`t3d-${this.uid}`,e=>this._onRemoveFromCache(e));this._memCache=t,this.addHandles([r(()=>this.layer.elevationInfo,e=>this._elevationInfoChanged(e))]),this._suspendedHandle=r(()=>this.suspended,e=>this._wasm?.setEnabled(this,!e),s)});this.addResolvingPromise(e),this._isUsedAsGround&&this.addHandles(o(()=>this.view.map.ground.opacity,()=>{this._opacityChange()}))}get _isUsedAsGround(){return V(this.layer)&&!!this.view.map.basemap?.groundLayers.includes(this.layer)}_opacityChange(){const e=this.fullOpacity*(this._isUsedAsGround?this.view.map.ground.opacity:1);this.objects.forEach(t=>{this._collection.getMaterial(t).objectOpacity=e})}destroy(){this._dbg(2,"Tiles3DLayerView3D destroy() called"),N(this),this._suspendedHandle&&(this._suspendedHandle.remove(),this._suspendedHandle=null),this._intersectionHandler&&(this.view.sceneIntersectionHelper.removeIntersectionHandler(this._intersectionHandler),this._intersectionHandler=null),this._elevationProvider&&(this._elevationProvider.objectsChanged(this._obbs),this.view.elevationProvider.unregister(this._elevationProvider),this._elevationProvider=null),this.view.basemapTerrain.overlayManager.unregisterDrapeTarget(this),this._lyrHandleToObjects.forEach(e=>this.freeObject(e)),this._lyrHandleToObjects.clear(),this._initialCullFace.clear(),this._memCache=i(this._memCache),this._updatingHandles=i(this._updatingHandles),this.emit("visible-geometry-changed"),this._visibleGeometryChangedSchedulerHandle&&(this._visibleGeometryChangedSchedulerHandle.remove(),this._visibleGeometryChangedSchedulerHandle=null)}_modificationsChanged(){const e=this.layer.spatialReference,t=L(this._layerClippingArea,this._modifications,e);this._wasm?.setMeshModifications(this,t,e.wkid)}_clippingAreaChanged(){const e=this.layer.spatialReference,t=M();this._layerClippingArea=ee(this.view.clippingArea,t,e)?t:null,this._modificationsChanged()}_visibleGeometryChanged(){this._visibleGeometryChangedSchedulerHandle??=a(()=>{this.emit("visible-geometry-changed"),this._visibleGeometryChangedSchedulerHandle=null})}_slicePlaneEnabledChange(e){this._intersectionHandler&&(this._intersectionHandler.slicePlaneEnabled=e),this.objects.forEach(t=>{const i=this._collection.getMaterial(t);i.commonMaterialParameters.hasSlicePlane=e,i.commonMaterialParameters.cullFace=e?0:this._initialCullFace.get(t)})}_elevationInfoChanged(e){this._wasm?.setLayerOffset(this,B(e))}get _obbs(){return this.objects.map(e=>this._collection.getComponentObb(e))}get _wasm(){return W(this.view)}get wasmLayerId(){return this._wasmLayerId}get usedMemory(){let e=0;return this._lyrHandleToObjects.forEach(t=>{t.isVisible&&(e+=t.usedMemory)}),e}get unloadedMemory(){return 0}get cachedMemory(){let e=0;return this._lyrHandleToObjects.forEach(t=>{t.isVisible||(e+=t.usedMemory)}),e}get visibleAtCurrentScale(){return ge(this.layer.effectiveScaleRange,this.view.scale)}get performanceInfo(){let e=0,t=0,i=0,s=0,r=0,o=0;return this._lyrHandleToObjects.forEach(a=>{a.isVisible?(e+=a.textureMemoryUsage,t+=a.vboMemoryUsage,r++):(i+=a.textureMemoryUsage,s+=a.vboMemoryUsage,o++)}),new D(this.usedMemory,r,o,we(t),we(e),we(s),we(i))}_canProjectWithoutEngine(){if(2===this.view.state.viewingMode){const e=this.view.renderSpatialReference?.isWebMercator?3857:this.view.renderSpatialReference?.wkid??-1;if(3857!==e&&32662!==e)return!1}return!0}get _stage(){return this.view.stage}get _collection(){return this._stage.renderView.componentObjectCollection}get elevationOffset(){return B(this.layer.elevationInfo)}get elevationRange(){const e=this.fullExtent;return e?.zmin&&e?.zmax?new Z(e.zmin,e.zmax):null}getElevationRange(e){return null}get fullExtent(){return this.layer.fullExtent}get objects(){return Array.from(this._lyrHandleToObjects.values()).reduce((e,t)=>e.concat(t.components),new Array)}isUpdating(){const e=this._wasm;return!(this._wasmLayerId<0||null==e)&&(e.isUpdating(this._wasmLayerId)||this._compressionTracker.compressing)}updatingFlagChanged(){this.notifyChange("updating")}async createRenderable(e){const t=e.meshData;if(null==t.data)throw new Error("meshData.data undefined");if(t.desc=JSON.parse(t.desc),null==t.desc)throw new Error("meshData.desc undefined");const i=_(t.desc.origin),s=new Array,r=new Map,o=new _e;o.handle=e.handle,this._lyrHandleToObjects.set(e.handle,o);const a=this.view.basemapTerrain.spatialReference;let n,l;if("global"===this.view.viewingMode){const e=f();C(x,i,e,a),n=c(m(),e),l=d(m(),n)}else n=h,l=h;const M=f();u(M,M,i);const O=p(w(),M);let P=null;const H=w();if(t.desc.obb){const e=t.desc.obb.quaternion;P=new te(t.desc.obb.center,t.desc.obb.halfSize,g(e[0],e[1],e[2],e[3]))}for(let c=0;c<t.desc.prims.length;c++){const e=t.desc.prims[c];this._dbg(2,JSON.stringify(e));if(null==J[e.ptype]||null==t.data){this._dbg(2,"[Unsupported Feature] Unsupported primitive mode ("+e.ptype+"). Skipping primitive.");continue}const d=t.desc?.materials&&null!=e.materialId?t.desc.materials[e.materialId]:null,m=null!=d?d.lightingModel:"Unlit",{positionView:u,positionAttr:p,normalsView:f,normalsAttr:g,colorAttr:_,texCoord0Attr:x,indicesView:C}=this.getBufferViews(e,t.data.buffer,n);if(null==p||null==u||null==C)continue;const M=new re(null!=_,x?1:0,null!=f,this._shadeNormals,this._applySSAO),R=p.data.length/p.size,F=(e,t)=>!e||e.data.length/e.size===R||(this._dbg(3,`${t} !== numPos. Skipping primitive.`),!1);if(!F(x,"numTexcoord")||!F(_,"numColors")||!F(g,"normals"))continue;const A=oe(M);if(null!=P?P=P.clone():(P=ie(p),y(H,P.center,i),P.center=H),n!==h)for(let t=0;t<u.count;t++)u.getVec(t,H),b(H,H,n),u.setVec(t,H);const S=A.createBuffer(p.data.length);if(he("position",p,null,null,S,0),null!=x){const e=S.getField("uv0",U);ue(x,e,0)}null!=_&&he("color",p,null,null,S,0),null!=g&&he("normalCompressed",g,null,null,S,0);const E=new Uint32Array([0,C.typedBuffer.length]),k={vertices:{data:S.buffer,count:S.byteLength/A.stride,layoutParameters:M},positionData:{positions:u.typedBuffer,indices:C.typedBuffer},indices:C.typedBuffer,componentOffsets:E};o.cpuMemoryUsage+=u.count,o.cpuMemoryUsage+=C.count;const V=this.view.renderSpatialReference,I=w(),B=[1,1,1];j(O,V,B,a)||this._dbg(3,"Unsupported coordinate system for IM overlay"),T(O,V,I,a);const L=this._collection.createObject(new se(v(I[0],I[1],B[0],B[1]),new ae(O,l),P,k));d&&this._collection.updateMaterial(L,e=>{e.baseColor=d.baseColorFactor,e.usePBR="Pbr"===m,e.hasParametersFromSource=!1,e.baseColorTexture=this._getTexture(d.baseColorTex,t,r,o),e.usePBR&&(e.mrrFactors=[d.metallicFactor,d.roughnessFactor,0],e.emissiveBaseColor=d.emissiveFactor??[0,0,0],e.metallicRoughnessTexture=this._getTexture(d.metalTex,t,r,o),e.emissionTexture=this._getTexture(d.emissiveTex,t,r,o),e.occlusionTexture=this._getTexture(d.occlusionTex,t,r,o),e.normalTexture=this._getTexture(d.normalTex,t,r,o)),e.objectOpacity=0,e.alphaDiscardMode=2;const i=[];e.baseColorTexture&&i.push(e.baseColorTexture.loadPromise),e.usePBR&&e.metallicRoughnessTexture&&i.push(e.metallicRoughnessTexture.loadPromise),e.usePBR&&e.emissionTexture&&i.push(e.emissionTexture.loadPromise),e.usePBR&&e.occlusionTexture&&i.push(e.occlusionTexture.loadPromise),e.usePBR&&e.normalTexture&&i.push(e.normalTexture.loadPromise);const a=Promise.all(i);s.push(a),a.then(()=>{e.alphaDiscardMode=q[d.alphaMode],e.objectOpacity=this.fullOpacity,o.textureMemoryUsage+=e.baseColorTexture?.glTexture?.usedMemory||0,e.usePBR&&(o.textureMemoryUsage+=e.metallicRoughnessTexture?.glTexture?.usedMemory||0,o.textureMemoryUsage+=e.emissionTexture?.glTexture?.usedMemory||0,o.textureMemoryUsage+=e.occlusionTexture?.glTexture?.usedMemory||0,o.textureMemoryUsage+=e.normalTexture?.glTexture?.usedMemory||0)}),e.commonMaterialParameters.doubleSided=d.isDoubleSided,e.commonMaterialParameters.cullFace=d.faceCulling?K[d.faceCulling]:2,this._initialCullFace.set(L,e.commonMaterialParameters.cullFace),e.commonMaterialParameters.hasSlicePlane=this.slicePlaneEnabled,e.componentParameters.castShadows=0,e.textureAlphaCutoff=d.alphaCutoff??be,e.alphaDiscardMode=q[d.alphaMode],e.isIntegratedMesh=!0,e.polygonOffsetEnabled=!1,e.hasOccludees=!1,e.ellipsoidMode=le(this.view.spatialReference)}),o.components.push(L),o.vboMemoryUsage+=this._collection.getObjectGPUMemoryUsage(L)}if(await Promise.all(s),r.forEach(e=>{o.textures.push(e)}),!this._memCache)throw new Error("no memCache");return this._memCache.put(`${o.handle}`,o),{memUsageBytes:o.usedMemory}}freeRenderable(e){const t=this._lyrHandleToObjects.get(e);t&&(this.freeObject(t),this._lyrHandleToObjects.delete(e))}freeObject(e){this._memCache&&this._memCache.pop(`${e.handle}`),e.components.forEach(t=>{e.textures.forEach(e=>{this._stage.removeTexture(e)}),this._collection.destroyObject(t),this._initialCullFace.delete(t)})}setRenderableVisibility(e,t,i){if(this._memCache){for(let s=0;s<i;++s){const i=e[s],r=t[s];if(!r)continue;const o=this._lyrHandleToObjects.get(i);o&&(this._visibleGeometryChanged(),o.isVisible=r,o.components.forEach(e=>{this._collection.setObjectVisibility(e,r),this._elevationProvider.objectChanged(this._collection.getComponentObb(e))}),this._memCache.pop(`${i}`))}for(let s=0;s<i;++s){const i=e[s],r=t[s];if(r)continue;const o=this._lyrHandleToObjects.get(i);o&&(this._visibleGeometryChanged(),o.isVisible=r,o.components.forEach(e=>{this._collection.setObjectVisibility(e,r),this._elevationProvider.objectChanged(this._collection.getComponentObb(e))}),this._memCache.put(`${i}`,o))}}}_getTexture(e,t,i,s){let r=null;if(e&&t.desc?.images&&t.data?.buffer){const o=t.desc.images[e?.imageId];if(r=i.get(o),!r&&o){const a=this._stage.renderView.renderingContext.parameters.maxMaxAnisotropy,n=!!o.mipCount||a>1,l=Q[e.wrapMode??"None"];let c=o.alpha?4:3;const d=new Uint8Array(t.data.buffer,o.data.byteOffset,o.data.byteCount);let m=null,h=null,u=null;switch(o.format){case"Raw":"R8"===o.pixelFormat?(m=d,c=1,h=""):"Rgb8"===o.pixelFormat?(m=d,c=3,h=""):"Rgba8"===o.pixelFormat&&(m=d,c=4,h="");break;case"Dxt1":m=d,c=3,h="image/vnd-ms.dds";break;case"Dxt5":m=d,c=4,h="image/vnd-ms.dds";break;case"Basis":m=d,c=3,h="image/ktx2";break;case"Png":h="image/png",u=document.createElement("img");break;case"Jpeg":h="image/jpeg",u=document.createElement("img");break;case"Etc2":h="image/ktx",u=document.createElement("img");break;case"Astc":this._dbg(3,"Astc texture not supported");break;case"Pvrtc":this._dbg(3,"Pvrtc texture not supported")}if(u&&h){const e=new Blob([d],{type:h});u.src=URL.createObjectURL(e),m=u}if(m&&null!=h){const e=has("enable-feature:esri-compress-IM-textures")?{compressionTracker:this._compressionTracker,compressionCallback:e=>{e&&e>0&&(s.textureMemoryUsage-=e)}}:void 0;r=new me(m,{mipmap:n,maxAnisotropy:a,encoding:h,wrap:l,components:c,compressionOptions:e,noUnpackFlip:!0,width:o.mip0Width,height:o.mip0Height}),this._stage.addTexture(r),i.set(o,r)}}}return r?new ne(this.view.stage.renderView.textures,r.id):null}getBufferViews(e,t,i){let s,r,o,a,n,l,c,d=null;for(let h=0;h<e.atrbs.length;h++){const c=e.atrbs[h],u=c.view,p=void 0,f=u.byteOffset+u.byteCount,g=u.byteCount/X[u.type],y=[...Array(g).keys()].map(e=>e);try{switch(c.sem){case"Position":3!==u.ncomp||"F32"!==u.type?this._dbg(3,"[Unsupported Feature] Unsupported view for Position ("+u+")"):(s=new R(t,u.byteOffset,p,f),r=new ce(s.typedBuffer,y,3));break;case"Normal":if(3!==u.ncomp||"F32"!==u.type)this._dbg(3,"[Unsupported Feature] Unsupported view for Normal ("+u+")");else{const e=new R(t,u.byteOffset,p,f),s=de(e.typedBuffer,i);n=new S(s.buffer),l=new ce(n.typedBuffer,y,2)}break;case"TexCoord":2!==u.ncomp||"F32"!==u.type?this._dbg(3,"[Unsupported Feature] Unsupported view for Texcoord ("+u+")"):void 0===a&&(a=new ce(new U(t,u.byteOffset,p,f).typedBuffer,y,2));break;case"Color":4===u.ncomp?("F32"===u.type&&(d=new O(t,u.byteOffset,p,f)),"U8"===u.type&&(d=new P(t,u.byteOffset,p,f)),"U16"===u.type&&(d=new H(t,u.byteOffset,p,f))):3===u.ncomp&&("F32"===u.type&&(d=new R(t,u.byteOffset,p,f)),"U8"===u.type&&(d=new F(t,u.byteOffset,p,f)),"U16"===u.type&&(d=new A(t,u.byteOffset,p,f))),null==d?this._dbg(2,"[Unsupported Feature] Unsupported view for Color ("+u+")"):o=new ce(d.typedBuffer,y,u.ncomp);break;case"FeatureIndex":break;default:this._dbg(2,"[Unsupported Feature] Unsupported semantic ("+c.sem+"). Skipping vertex attribute.")}}catch(m){this._dbg(2,"Error Creating buffer ("+m+"). Skipping vertex attribute.")}}if(e.index){const i=e.index.view,s=void 0,r=i.byteOffset+i.byteCount;switch(e.index.view.type){case"U16":c=new k(t,i.byteOffset,s,r);break;case"U32":c=new E(t,i.byteOffset,s,r);break;default:this._dbg(3,"[Unsupported Feature] index type not supported ("+i.type+").")}}if(null==c&&null!=s){const e=s.count;if(e<65535){const t=new Uint16Array(e);c=new k(t.buffer)}else{const t=new Uint32Array(e);c=new E(t.buffer)}for(let t=0;t<e;t++)c.set(t,t)}return{positionView:s,positionAttr:r,colorAttr:o,texCoord0Attr:a,indicesView:c,normalsView:n,normalsAttr:l}}_loadModifications(){if(this.removeHandles("modifications"),null==this.layer.modifications)return void(this._modifications=[]);const e=this.layer.modifications;this.addHandles(this._updatingHandles.addOnCollectionChange(()=>e,()=>this._modifications=e.toArray(),s),"modifications")}_onRemoveFromCache(e){this._wasm?.onRenderableEvicted(this,e.handle,e.usedMemory),this.freeRenderable(e.handle)}_dbg(e,i){this._dbgFlags.has(e)&&(3===e?t.getLogger(this).error(i):t.getLogger(this).warn(i))}};e([n({type:[I]})],ve.prototype,"_modifications",void 0),e([n()],ve.prototype,"_visibleGeometryChangedSchedulerHandle",void 0),e([n()],ve.prototype,"layer",void 0),e([n({readOnly:!0})],ve.prototype,"visibleAtCurrentScale",null),e([n()],ve.prototype,"elevationOffset",null),ve=e([l("esri.views.3d.layers.IntegratedMesh3DTilesLayerView3D")],ve);const xe=ve;export{xe as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.34/esri/copyright.txt for details.
4
4
  */
5
- import{__decorate as e}from"tslib";import t from"../core/Accessor.js";import r from"../core/Collection.js";import{when as s}from"../core/reactiveUtils.js";import{property as o}from"../core/accessorSupport/decorators/property.js";import"../core/has.js";import"../core/Logger.js";import"../core/RandomLCG.js";import{subclass as i}from"../core/accessorSupport/decorators/subclass.js";import{toExtent as n}from"./3d/support/cameraUtils.js";import a from"./support/GroundViewElevationSampler.js";let p=class extends t{constructor(e){super(e),this.view=null,this.layerViews=new r}initialize(){this.addHandles(s(()=>this.view?.map?.ground,async e=>e.load())),"3d"===this.view.type&&this.addHandles([s(()=>this.view.map?.basemap,e=>{e.groundLayers.on("after-changes",()=>this._groundLayersChanged())},{initial:!0}),s(()=>"3d"===this.view.type&&(this.view?.basemapTerrain??!1),async()=>{this._groundLayersChanged()})])}_groundLayersChanged(){const e=this.view.map.basemap?.groundLayers.some(e=>"isGroundReplacement"in e&&e.isGroundReplacement),{view:t}=this;if("3d"===t?.type){const r=t.basemapTerrain;r&&r.enable(!e)}}get ground(){return this.view?.map?.ground}destroy(){this._set("view",null);for(const e of this.layerViews)e.destroy();this.layerViews.length=0}get elevationSampler(){return"2d"!==this.view?.type&&this.view?.ready&&this.view?.basemapTerrain?.ready?new a({view:this.view}):null}get extent(){const e=this.view;return e&&"2d"!==e.type&&e.ready?n(e,e.state.camera,e.pointsOfInterest.centerOnSurfaceFrequent.renderLocation):null}get updating(){return!this.suspended&&this.layerViews.some(e=>e.updating)}get suspended(){return this.view?.suspended??!0}};e([o({readOnly:!0})],p.prototype,"elevationSampler",null),e([o({readOnly:!0})],p.prototype,"extent",null),e([o({type:Boolean,readOnly:!0})],p.prototype,"updating",null),e([o({constructOnly:!0})],p.prototype,"view",void 0),e([o({type:r,readOnly:!0})],p.prototype,"layerViews",void 0),e([o({readOnly:!0})],p.prototype,"suspended",null),p=e([i("esri.views.GroundView")],p);const d=p;export{d as default};
5
+ import{__decorate as e}from"tslib";import r from"../core/Accessor.js";import t from"../core/Collection.js";import{when as s}from"../core/reactiveUtils.js";import{property as o}from"../core/accessorSupport/decorators/property.js";import"../core/has.js";import"../core/Logger.js";import"../core/RandomLCG.js";import{subclass as i}from"../core/accessorSupport/decorators/subclass.js";import{isLayerGroundReplacement as a}from"../layers/GroundLayer.js";import{toExtent as n}from"./3d/support/cameraUtils.js";import p from"./support/GroundViewElevationSampler.js";let d=class extends r{constructor(e){super(e),this.view=null,this.layerViews=new t}initialize(){this.addHandles(s(()=>this.view?.map?.ground,async e=>e.load())),"3d"===this.view.type&&this.addHandles([s(()=>this.view.map?.basemap,e=>{e.groundLayers.on("after-changes",()=>this._groundLayersChanged())},{initial:!0}),s(()=>"3d"===this.view.type&&(this.view?.basemapTerrain??!1),async()=>{this._groundLayersChanged()})])}_groundLayersChanged(){const e=this.view.map.basemap?.groundLayers.some(a),{view:r}=this;if("3d"===r?.type){const t=r.basemapTerrain;t&&t.enable(!e)}}get ground(){return this.view?.map?.ground}destroy(){this._set("view",null);for(const e of this.layerViews)e.destroy();this.layerViews.length=0}get elevationSampler(){return"2d"!==this.view?.type&&this.view?.ready&&this.view?.basemapTerrain?.ready?new p({view:this.view}):null}get extent(){const e=this.view;return e&&"2d"!==e.type&&e.ready?n(e,e.state.camera,e.pointsOfInterest.centerOnSurfaceFrequent.renderLocation):null}get updating(){return!this.suspended&&this.layerViews.some(e=>e.updating)}get suspended(){return this.view?.suspended??!0}};e([o({readOnly:!0})],d.prototype,"elevationSampler",null),e([o({readOnly:!0})],d.prototype,"extent",null),e([o({type:Boolean,readOnly:!0})],d.prototype,"updating",null),e([o({constructOnly:!0})],d.prototype,"view",void 0),e([o({type:t,readOnly:!0})],d.prototype,"layerViews",void 0),e([o({readOnly:!0})],d.prototype,"suspended",null),d=e([i("esri.views.GroundView")],d);const l=d;export{l as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.34/esri/copyright.txt for details.
4
4
  */
5
- import{__decorate as t}from"tslib";import e from"../../../Graphic.js";import{EventedAccessor as i}from"../../../core/Evented.js";import{destroyMaybe as s}from"../../../core/maybe.js";import{zeroMeters as o}from"../../../core/quantityUtils.js";import{when as r,watch as a,syncAndInitial as h,initial as c}from"../../../core/reactiveUtils.js";import{property as n}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as l}from"../../../core/accessorSupport/decorators/subclass.js";import p from"../../../geometry/Point.js";import _ from"../../../geometry/Polygon.js";import d from"../../../geometry/Polyline.js";import{create as m}from"../../../geometry/support/aaBoundingRect.js";import{getRingsOrPathsBounds as g}from"../../../geometry/support/boundsUtils.js";import{geometryToCoordinates as u}from"../../../geometry/support/coordsUtils.js";import y from"../../../geometry/support/rotate.js";import v from"../../../symbols/SimpleFillSymbol.js";import f from"../../../symbols/SimpleLineSymbol.js";import G from"../../../symbols/SimpleMarkerSymbol.js";import{cloneMove as b,scale as x,getScaleRatio as w,getRotationAngle as S}from"./drawUtils.js";import k from"./GraphicMover.js";import R from"./HighlightHelper.js";import{addUniqueLayer as C}from"./layerUtils.js";import{settings as M}from"./settings.js";import H from"../../interactive/sketch/SketchOptions.js";import{makeTooltip as I}from"../../interactive/tooltip/tooltipCommonUtils.js";import{ExtentRotateTooltipInfo as O}from"../../interactive/tooltip/infos/ExtentRotateTooltipInfo.js";import{ExtentScaleTooltipInfo as j}from"../../interactive/tooltip/infos/ExtentScaleTooltipInfo.js";import{TranslateTooltipInfo as T}from"../../interactive/tooltip/infos/TranslateTooltipInfo.js";import{autoSize2D as L}from"../../support/extentUtils.js";const E=M.transformGraphics,z={centerIndicator:new G({style:"cross",size:E.center.size,color:E.center.color}),fill:{default:new v({color:E.fill.color,outline:{color:E.fill.outlineColor,join:"round",width:1}}),active:new v({color:E.fill.stagedColor,outline:{color:E.fill.outlineColor,join:"round",style:"dash",width:1}})},handles:{default:new G({style:"square",size:E.vertex.size,color:E.vertex.color,outline:{color:E.vertex.outlineColor,width:1}}),hover:new G({style:"square",size:E.vertex.hoverSize,color:E.vertex.hoverColor,outline:{color:E.vertex.hoverOutlineColor,width:1}})},rotator:{default:new G({style:"circle",size:E.vertex.size,color:E.vertex.color,outline:{color:E.vertex.outlineColor,width:1}}),hover:new G({style:"circle",size:E.vertex.hoverSize,color:E.vertex.hoverColor,outline:{color:E.vertex.hoverOutlineColor,width:1}})},rotatorLine:new f({color:E.line.color,width:1})},B=Symbol();let N=class extends i{constructor(t){super(t),this._activeHandleGraphic=null,this._graphicAttributes={esriSketchTool:"box"},this._mover=null,this._centerGraphic=null,this._backgroundGraphic=null,this._vertexGraphics=[],this._rotateHandleGraphic=null,this._rotateGraphicOffset=20,this._angleOfRotation=0,this._rotateLineGraphic=null,this._startInfo=null,this._totalDx=0,this._totalDy=0,this._xScale=1,this._yScale=1,this.tooltip=null,this.type="box",this.callbacks={onMoveStart(){},onMove(){},onMoveStop(){},onScaleStart(){},onScale(){},onScaleStop(){},onRotateStart(){},onRotate(){},onRotateStop(){},onGraphicClick(){}},this.enableMovement=!0,this.enableRotation=!0,this.enableScaling=!0,this.graphics=[],this.highlightName=null,this.highlightsEnabled=!0,this.layer=null,this.preserveAspectRatio=!1,this.showCenterGraphic=!0,this.symbols=z,this.sketchOptions=new H,this.view=null,this._getBounds=(()=>{const t=m();return(e,i)=>{e[0]=Number.POSITIVE_INFINITY,e[1]=Number.POSITIVE_INFINITY,e[2]=Number.NEGATIVE_INFINITY,e[3]=Number.NEGATIVE_INFINITY;for(const s of i){if(!s)continue;let i,o,r,a;if("point"===s.type)i=r=s.x,o=a=s.y;else if("extent"===s.type)[i,o,r,a]=[s.xmin,s.ymin,s.xmax,s.ymax];else{const e=u(s);[i,o,r,a]=g(t,e)}e[0]=Math.min(i,e[0]),e[1]=Math.min(o,e[1]),e[2]=Math.max(r,e[2]),e[3]=Math.max(a,e[3])}return e}})()}initialize(){const t=this.view;this._highlightHelper=new R({view:t}),this._setup(),this.addHandles([r(()=>t?.ready,()=>{const{layer:t,view:e}=this;C(e,t)},{once:!0,initial:!0}),a(()=>this.preserveAspectRatio,()=>{this._activeHandleGraphic&&(this._scaleGraphic(this._activeHandleGraphic),this._updateGraphics(),this._updateTooltip(this._activeHandleGraphic))}),a(()=>t?.scale,()=>{this._updateRotateGraphic(),this._updateRotateLineGraphic()}),a(()=>this.graphics,()=>this.refresh()),a(()=>this.layer,(t,e)=>{e&&this._resetGraphics(e),this.refresh()}),a(()=>[this.highlightsEnabled,this.highlightName],()=>{this._highlightHelper?.removeAll(),this._setUpHighlights()}),a(()=>this.sketchOptions.tooltips.effectiveEnabled,e=>{this.tooltip=e?I(()=>({view:t,options:this.sketchOptions.tooltips})):s(this.tooltip)},h),a(()=>this.view.effectiveTheme.accentColor,()=>this._updateSymbolsForTheme(),c),this.on("move-start",t=>this.callbacks?.onMoveStart?.(t)),this.on("move",t=>this.callbacks?.onMove?.(t)),this.on("move-stop",t=>this.callbacks?.onMoveStop?.(t)),this.on("rotate-start",t=>this.callbacks?.onRotateStart?.(t)),this.on("rotate",t=>this.callbacks?.onRotate?.(t)),this.on("rotate-stop",t=>this.callbacks?.onRotateStop?.(t)),this.on("scale-start",t=>this.callbacks?.onScaleStart?.(t)),this.on("scale",t=>this.callbacks?.onScale?.(t)),this.on("scale-stop",t=>this.callbacks?.onScaleStop?.(t))])}destroy(){this._reset(),this.tooltip=s(this.tooltip)}get state(){const t=this.view?.ready??!1,e=this.graphics.length&&this.layer;return t&&e?"active":t?"ready":"disabled"}isUIGraphic(t){return this._vertexGraphics.includes(t)||t===this._backgroundGraphic||t===this._centerGraphic||t===this._rotateHandleGraphic||t===this._rotateLineGraphic}move(t,e){if(this._mover&&this.graphics.length){for(const i of this.graphics){const s=i.geometry,o=b(s,t,e,this.view);i.geometry=o}this.refresh(),this.emit("move-stop",{graphics:this.graphics,mover:null,dx:t,dy:e,type:"move-stop"})}}scale(t,e){if(this._mover&&this.graphics.length){for(const i of this.graphics){const s=i.geometry,o=x(s,t,e);i.geometry=o}this.refresh(),this.emit("scale-stop",{graphics:this.graphics,mover:null,xScale:t,yScale:e,type:"scale-stop"})}}rotate(t,e){if(this._mover&&this.graphics.length){if(!e){const t=this._vertexGraphics[1].geometry.x,i=this._vertexGraphics[3].geometry.y;e=new p(t,i,this.view.spatialReference)}for(const i of this.graphics){const s=i.geometry,o=y(s,t,e);i.geometry=o}this.refresh(),this.emit("rotate-stop",{graphics:this.graphics,mover:null,angle:t,type:"rotate-stop"})}}refresh(){this._reset(),this._setup()}reset(){this.graphics=[]}_setup(){"active"===this.state&&(this._setUpHighlights(),this._setupGraphics(),this._setupMover(),this._updateGraphics())}_reset(){this._highlightHelper?.removeAll(),this._resetGraphicStateVars(),this._resetGraphics(),this._updateTooltip(),this._mover?.destroy(),this._mover=null,this.removeHandles(B)}_resetGraphicStateVars(){this._startInfo=null,this._activeHandleGraphic=null,this._totalDx=0,this._totalDy=0,this._xScale=1,this._yScale=1,this._angleOfRotation=0}_resetGraphics(t){(t=t||this.layer)&&(t.removeMany(this._vertexGraphics),t.remove(this._backgroundGraphic),t.remove(this._centerGraphic),t.remove(this._rotateHandleGraphic),t.remove(this._rotateLineGraphic)),this._vertexGraphics.forEach(t=>!t.destroyed&&t.destroy()),!this._backgroundGraphic.destroyed&&this._backgroundGraphic.destroy(),!this._centerGraphic.destroyed&&this._centerGraphic.destroy(),!this._rotateHandleGraphic.destroyed&&this._rotateHandleGraphic.destroy(),!this._rotateLineGraphic.destroyed&&this._rotateLineGraphic.destroy(),this._vertexGraphics=[],this._backgroundGraphic=null,this._centerGraphic=null,this._rotateHandleGraphic=null,this._rotateLineGraphic=null}_setupMover(){let t=[];this.enableScaling&&(t=t.concat(this._vertexGraphics)),this.enableRotation&&t.push(this._rotateHandleGraphic),this.enableMovement&&(t=t.concat(this.graphics,this._backgroundGraphic)),this.showCenterGraphic&&t.push(this._centerGraphic),this._mover=new k({enableMoveAllGraphics:!1,highlightsEnabled:!1,indicatorsEnabled:!1,view:this.view,graphics:t,callbacks:{onGraphicClick:t=>this._onGraphicClickCallback(t),onGraphicMoveStart:t=>this._onGraphicMoveStartCallback(t),onGraphicMove:t=>this._onGraphicMoveCallback(t),onGraphicMoveStop:t=>this._onGraphicMoveStopCallback(t),onGraphicPointerOver:t=>this._onGraphicPointerOverCallback(t),onGraphicPointerOut:t=>this._onGraphicPointerOutCallback(t)}})}_setCursor(t){this.addHandles(this.view.acquireCursor(t,"high"),B)}_getStartInfo(t){const[e,i,s,o]=this._getBoxBounds(m()),r=Math.abs(s-e),a=Math.abs(o-i),h=(s+e)/2,c=(o+i)/2,{x:n,y:l}=t.geometry;return{width:r,height:a,centerX:h,centerY:c,startX:n,startY:l,graphicInfos:this._getGraphicInfos(),box:this._backgroundGraphic.geometry,rotate:this._rotateHandleGraphic.geometry}}_getGraphicInfos(){return this.graphics.map(t=>this._getGraphicInfo(t))}_getGraphicInfo(t){const e=t.geometry,[i,s,o,r]=this._getBounds(m(),[e]);return{width:Math.abs(o-i),height:Math.abs(r-s),centerX:(o+i)/2,centerY:(r+s)/2,geometry:e}}_onGraphicClickCallback(t){t.viewEvent.stopPropagation(),this.emit("graphic-click",t),this.callbacks.onGraphicClick&&this.callbacks.onGraphicClick(t)}_onGraphicMoveStartCallback(t){const{_angleOfRotation:e,_xScale:i,_yScale:s,_backgroundGraphic:o,_vertexGraphics:r,_rotateHandleGraphic:a,symbols:h,graphics:c}=this,{graphic:n,dx:l,dy:p,viewEvent:_}=t;this._resetGraphicStateVars(),this._hideGraphicsBeforeUpdate(),o.symbol=h.fill.active,this._startInfo=this._getStartInfo(n),this._updateTooltip(n,_),n===a?(this._setCursor("grabbing"),this.emit("rotate-start",{type:"rotate-start",mover:n,graphics:c,angle:e})):r.includes(n)?(this._activeHandleGraphic=n,this.emit("scale-start",{type:"scale-start",mover:n,graphics:c,xScale:i,yScale:s})):this.emit("move-start",{type:"move-start",graphics:c,mover:n,dx:l,dy:p})}_onGraphicMoveCallback(t){const e=t.graphic;if(!this._startInfo)return;const{_xScale:i,_yScale:s,_angleOfRotation:o,graphics:r}=this;if(this._vertexGraphics.includes(e))this._scaleGraphic(e),this._updateTooltip(e,t.viewEvent),this.emit("scale",{type:"scale",graphics:r,mover:e,xScale:i,yScale:s});else if(e===this._rotateHandleGraphic)this._rotateGraphic(e),this._updateTooltip(e,t.viewEvent),this.emit("rotate",{type:"rotate",graphics:r,mover:e,angle:o});else{const{dx:i,dy:s}=t;this._totalDx+=i,this._totalDy+=s,this._moveGraphic(e,i,s),this._updateTooltip(e,t.viewEvent),this.emit("move",{type:"move",graphics:r,mover:e,dx:i,dy:s})}}_onGraphicMoveStopCallback(t){const e=t.graphic;if(!this._startInfo)return void this.refresh();const{_angleOfRotation:i,_totalDx:s,_totalDy:o,_xScale:r,_yScale:a,_vertexGraphics:h,_rotateHandleGraphic:c,graphics:n}=this;this.refresh(),e===c?(this._setCursor("pointer"),this.emit("rotate-stop",{type:"rotate-stop",graphics:n,mover:e,angle:i})):h.includes(e)?this.emit("scale-stop",{type:"scale-stop",mover:e,graphics:n,xScale:r,yScale:a}):this.emit("move-stop",{type:"move-stop",graphics:n,mover:e,dx:s,dy:o})}_onGraphicPointerOverCallback(t){const{_backgroundGraphic:e,_vertexGraphics:i,graphics:s,_rotateHandleGraphic:o,symbols:r,view:a}=this,h=t.graphic;if(this._hoveredGraphic=h,h===o)return o.symbol=r.rotator.hover,this._setCursor("pointer"),void this._updateTooltip(h);if(s.includes(h)||h===e)return void this._setCursor("move");if(!i.includes(h))return void this._setCursor("pointer");this._updateTooltip(h),t.graphic.symbol=r.handles.hover;const c=a.rotation;let n,l=t.index;switch(l<8&&(c>=0&&c<45?l%=8:l=c>=45&&c<90?(l+1)%8:c>=90&&c<135?(l+2)%8:c>=135&&c<180?(l+3)%8:c>=180&&c<225?(l+4)%8:c>=225&&c<270?(l+5)%8:c>=270&&c<315?(l+6)%8:(l+7)%8),l){case 0:case 4:n="nwse-resize";break;case 1:case 5:n="ns-resize";break;case 2:case 6:n="nesw-resize";break;case 3:case 7:n="ew-resize";break;default:n="pointer"}this._setCursor(n)}_onGraphicPointerOutCallback(t){const{_vertexGraphics:e,_rotateHandleGraphic:i,symbols:s}=this;this._hoveredGraphic=null,t.graphic===i?i.symbol=s.rotator.default:e.includes(t.graphic)&&(t.graphic.symbol=s.handles.default),this.removeHandles(B),this._updateTooltip()}_scaleGraphic(t){const{_startInfo:e,_vertexGraphics:i,preserveAspectRatio:s,view:o}=this,{centerX:r,centerY:a,graphicInfos:h,height:c,startX:n,startY:l,width:_}=e,{resolution:d,transform:m}=o.state,g=i.indexOf(t);1!==g&&5!==g||this._updateX(t,r),3!==g&&7!==g||this._updateY(t,a);const{x:u,y}=t.geometry,v=m[0]*u+m[2]*y+m[4],f=m[1]*u+m[3]*y+m[5],G=h?.map(t=>t.geometry)??[],S=G.every(t=>"point"===t.type);if((0===_||0===c)&&S){const t=U((u-n)/d),i=U((l-y)/d);for(let e=0;e<G.length;e++)this.graphics[e].geometry=b(G[e],t,i,o,!0);return this._centerGraphic.geometry=new p(u,y,o.spatialReference),void(this._backgroundGraphic.geometry=b(e.box,t,i,o,!0))}if(s){const t=U(m[0]*r+m[2]*a+m[4],2),e=U(m[1]*r+m[3]*a+m[5],2),i=U(m[0]*n+m[2]*l+m[4],2),s=U(m[1]*n+m[3]*l+m[5],2);let o=w(t,e,i,s,v,f);0!==o&&Math.abs(o)!==1/0||(o=1),this._xScale=this._yScale=o;for(const h of G){const t=G.indexOf(h);this.graphics[t].geometry=x(h,this._xScale,this._yScale,[r,a])}this._updateBackgroundGraphic()}else{let t=u-n,i=l-y;if(1===g||5===g?t=0:3!==g&&7!==g||(i=0),0===t&&0===i)return;const s=r+t/2,h=a+i/2;let m=(_+(n>r?t:-1*t))/_,v=(c+(l<a?i:-1*i))/c;1!==g&&5!==g&&0!==m&&Math.abs(m)!==1/0||(m=1),3!==g&&7!==g&&0!==v&&Math.abs(v)!==1/0||(v=1),this._xScale=m,this._yScale=v;const f=(s-r)/d,w=(h-a)/d,S=x(e.box,this._xScale,this._yScale);this._backgroundGraphic.geometry=b(S,f,w,o,!0);const{centerX:k,centerY:R}=this._getGraphicInfo(this._backgroundGraphic),C=(k-r)/d,M=-1*(R-a)/d;for(const e of G){const t=G.indexOf(e),i=x(e,this._xScale,this._yScale,[r,a]);this.graphics[t].geometry=b(i,C,M,o,!0)}this._centerGraphic.geometry=new p(k,R,o.spatialReference)}}_rotateGraphic(t){const{centerX:e,centerY:i,startX:s,startY:o,box:r,rotate:a}=this._startInfo,h=this.view.spatialReference,c=new p(s,o,h),n=new p(e,i,h),l=t.geometry;this._angleOfRotation=S(c,l,n);const _=this._startInfo.graphicInfos?.map(t=>t.geometry)??[];for(const p of _){const t=_.indexOf(p),e=y(p,this._angleOfRotation,n);this.graphics[t].geometry=e}this._backgroundGraphic.geometry=y(r,this._angleOfRotation,n),this._rotateHandleGraphic.geometry=y(a,this._angleOfRotation,n)}_moveGraphic(t,e,i){if(this.graphics.includes(t)){const s=this._backgroundGraphic.geometry;this._backgroundGraphic.geometry=b(s,e,i,this.view);for(const o of this.graphics)o!==t&&(o.geometry=b(o.geometry,e,i,this.view))}else if(t===this._centerGraphic){const t=this._backgroundGraphic.geometry;this._backgroundGraphic.geometry=b(t,e,i,this.view)}if(t===this._backgroundGraphic||t===this._centerGraphic)for(const s of this.graphics)s.geometry=b(s.geometry,e,i,this.view)}_setUpHighlights(){this.highlightsEnabled&&this.graphics.length&&this._highlightHelper?.add(this.graphics,this.highlightName)}_setupGraphics(){const{_graphicAttributes:t,symbols:i}=this;this._centerGraphic=new e({symbol:i.centerIndicator,attributes:t}),this.showCenterGraphic&&this.layer.add(this._centerGraphic),this._backgroundGraphic=new e({symbol:i.fill.default,attributes:t}),this.layer.add(this._backgroundGraphic),this._rotateLineGraphic=new e({symbol:i.rotatorLine,attributes:t}),this._rotateHandleGraphic=new e({symbol:i.rotator.default,attributes:t}),this.enableRotation&&!this._hasExtentGraphic()&&this.layer.addMany([this._rotateLineGraphic,this._rotateHandleGraphic]);for(let s=0;s<8;s++)this._vertexGraphics.push(new e({symbol:i.handles.default,attributes:t}));this.enableScaling&&this.layer.addMany(this._vertexGraphics)}_updateSymbolsForTheme(){const t=this.view.effectiveTheme.accentColor;this.symbols={...this.symbols,fill:{active:this.symbols.fill.active?.clone().set("outline.color",t),default:this.symbols.fill.default?.clone().set("outline.color",t)},handles:{...this.symbols.handles,default:this.symbols.handles.default.clone().set("outline.color",t)},rotator:{...this.symbols.rotator,default:this.symbols.rotator.default.clone().set("outline.color",t)},rotatorLine:this.symbols.rotatorLine.clone().set("color",t)};for(const e of this._vertexGraphics)e.symbol=e===this._hoveredGraphic?this.symbols.handles.hover:this.symbols.handles.default;this._backgroundGraphic.symbol=this.symbols.fill.default,this._rotateHandleGraphic.symbol=this._rotateHandleGraphic===this._hoveredGraphic?this.symbols.rotator.hover:this.symbols.rotator.default,this._rotateLineGraphic.symbol=this.symbols.rotatorLine}_updateGraphics(){this._updateBackgroundGraphic(),this._updateHandleGraphics(),this._updateCenterGraphic(),this._updateRotateGraphic(),this._updateRotateLineGraphic()}_hideGraphicsBeforeUpdate(){this._centerGraphic.visible=!1,this._rotateHandleGraphic.visible=!1,this._rotateLineGraphic.visible=!1,this._vertexGraphics.forEach(t=>t.visible=!1)}_updateHandleGraphics(){const t=this._getCoordinates(!0);this._vertexGraphics.forEach((e,i)=>{const[s,o]=t[i];this._updateXY(e,s,o)})}_updateBackgroundGraphic(){const t=this._getCoordinates().map(([t,e])=>[t,e]);this._backgroundGraphic.geometry=new _({rings:[t],spatialReference:this.view.spatialReference})}_updateCenterGraphic(){const[t,e,i,s]=this._getBoxBounds(m()),o=(i+t)/2,r=(s+e)/2;this._centerGraphic.geometry=new p(o,r,this.view.spatialReference)}_updateRotateGraphic(){if(!this._vertexGraphics.length)return;const{x:t,y:e}=this._vertexGraphics[1].geometry,i=e+this.view.state.resolution*this._rotateGraphicOffset;this._rotateHandleGraphic.geometry=new p(t,i,this.view.spatialReference)}_updateRotateLineGraphic(){if(!this._vertexGraphics.length||!this._rotateHandleGraphic?.geometry)return;const t=this._vertexGraphics[1].geometry,e=this._rotateHandleGraphic.geometry;this._rotateLineGraphic.geometry=new d({paths:[[[t.x,t.y],[e.x,e.y]]],spatialReference:this.view.spatialReference})}_updateXY(t,e,i){t.geometry=new p(e,i,this.view.spatialReference)}_updateX(t,e){const i=t.geometry.y;t.geometry=new p(e,i,this.view.spatialReference)}_updateY(t,e){const i=t.geometry.x;t.geometry=new p(i,e,this.view.spatialReference)}_hasExtentGraphic(){return this.graphics.some(t=>null!=t?.geometry&&"extent"===t.geometry.type)}_getBoxBounds(t){const e=this.graphics.map(t=>t.geometry);return this._getBounds(t,e)}_getCoordinates(t){const[e,i,s,o]=this._getBoxBounds(m());if(t){const t=(e+s)/2,r=(o+i)/2;return[[e,o],[t,o],[s,o],[s,r],[s,i],[t,i],[e,i],[e,r]]}return[[e,o],[s,o],[s,i],[e,i]]}_updateTooltip(t,e){if(null==this.tooltip)return;if(!t)return void this.tooltip.clear();const{_backgroundGraphic:i,graphics:s,_vertexGraphics:o,_rotateHandleGraphic:r}=this;t===r?this._updateRotateTooltip():o.includes(t)?this._updateScaleTooltip():(s.includes(t)||t===i)&&this._updateMoveTooltip(e)}_updateRotateTooltip(){null!=this.tooltip&&(this.tooltip.info=new O({sketchOptions:this.sketchOptions,angle:-this._angleOfRotation}))}_updateScaleTooltip(){const{tooltip:t,_xScale:e,_yScale:i,sketchOptions:s,view:o,automaticLengthMeasurementUtils:r}=this;if(null==t)return;const a=this._getCoordinates(),h=L({topLeft:a[0],topRight:a[1],bottomRight:a[2],bottomLeft:a[3],spatialReference:o.spatialReference,automaticLengthMeasurementUtils:r});if(null==h)return;const{xSize:c,ySize:n}=h,l=Math.abs(e),p=Math.abs(i);t.info=new j({sketchOptions:s,xScale:l,yScale:p,xSize:c,ySize:n})}_updateMoveTooltip(t){const{tooltip:e,sketchOptions:i,view:s,automaticLengthMeasurementUtils:r}=this;if(null==e)return;const a=new T({sketchOptions:i});if(t){const{x:e,y:i}=t.origin,h=s.toMap(t),c=s.toMap({x:e,y:i}),n=r.autoDistanceBetweenPoints2D(c,h);a.distance=null!=n?n:o}e.info=a}};function U(t,e=2){return Number.parseFloat(t.toFixed(e))}t([n()],N.prototype,"tooltip",void 0),t([n({readOnly:!0})],N.prototype,"type",void 0),t([n()],N.prototype,"callbacks",void 0),t([n()],N.prototype,"enableMovement",void 0),t([n()],N.prototype,"enableRotation",void 0),t([n()],N.prototype,"enableScaling",void 0),t([n()],N.prototype,"graphics",void 0),t([n()],N.prototype,"highlightName",void 0),t([n()],N.prototype,"highlightsEnabled",void 0),t([n()],N.prototype,"layer",void 0),t([n()],N.prototype,"preserveAspectRatio",void 0),t([n()],N.prototype,"showCenterGraphic",void 0),t([n({readOnly:!0})],N.prototype,"state",null),t([n()],N.prototype,"symbols",void 0),t([n({type:H})],N.prototype,"sketchOptions",void 0),t([n({constructOnly:!0})],N.prototype,"view",void 0),t([n({constructOnly:!0})],N.prototype,"automaticLengthMeasurementUtils",void 0),N=t([l("esri.views.draw.support.Box")],N);const Y=N;export{Y as default};
5
+ import{__decorate as t}from"tslib";import e from"../../../Graphic.js";import{EventedAccessor as i}from"../../../core/Evented.js";import{destroyMaybe as s}from"../../../core/maybe.js";import{zeroMeters as o}from"../../../core/quantityUtils.js";import{when as r,watch as a,syncAndInitial as h,initial as c}from"../../../core/reactiveUtils.js";import{property as n}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as l}from"../../../core/accessorSupport/decorators/subclass.js";import p from"../../../geometry/Point.js";import _ from"../../../geometry/Polygon.js";import d from"../../../geometry/Polyline.js";import{create as m,center as g}from"../../../geometry/support/aaBoundingRect.js";import{getBoundsXY as u}from"../../../geometry/support/boundsUtils.js";import y from"../../../geometry/support/rotate.js";import v from"../../../symbols/SimpleFillSymbol.js";import f from"../../../symbols/SimpleLineSymbol.js";import G from"../../../symbols/SimpleMarkerSymbol.js";import{cloneMove as b,scale as x,getScaleRatio as w,getRotationAngle as S}from"./drawUtils.js";import k from"./GraphicMover.js";import R from"./HighlightHelper.js";import{addUniqueLayer as C}from"./layerUtils.js";import{settings as M}from"./settings.js";import H from"../../interactive/sketch/SketchOptions.js";import{makeTooltip as I}from"../../interactive/tooltip/tooltipCommonUtils.js";import{ExtentRotateTooltipInfo as O}from"../../interactive/tooltip/infos/ExtentRotateTooltipInfo.js";import{ExtentScaleTooltipInfo as T}from"../../interactive/tooltip/infos/ExtentScaleTooltipInfo.js";import{TranslateTooltipInfo as j}from"../../interactive/tooltip/infos/TranslateTooltipInfo.js";import{autoSize2D as L}from"../../support/extentUtils.js";const E=M.transformGraphics,B={centerIndicator:new G({style:"cross",size:E.center.size,color:E.center.color}),fill:{default:new v({color:E.fill.color,outline:{color:E.fill.outlineColor,join:"round",width:1}}),active:new v({color:E.fill.stagedColor,outline:{color:E.fill.outlineColor,join:"round",style:"dash",width:1}})},handles:{default:new G({style:"square",size:E.vertex.size,color:E.vertex.color,outline:{color:E.vertex.outlineColor,width:1}}),hover:new G({style:"square",size:E.vertex.hoverSize,color:E.vertex.hoverColor,outline:{color:E.vertex.hoverOutlineColor,width:1}})},rotator:{default:new G({style:"circle",size:E.vertex.size,color:E.vertex.color,outline:{color:E.vertex.outlineColor,width:1}}),hover:new G({style:"circle",size:E.vertex.hoverSize,color:E.vertex.hoverColor,outline:{color:E.vertex.hoverOutlineColor,width:1}})},rotatorLine:new f({color:E.line.color,width:1})},z=Symbol();let N=class extends i{constructor(t){super(t),this._activeHandleGraphic=null,this._graphicAttributes={esriSketchTool:"box"},this._mover=null,this._centerGraphic=null,this._backgroundGraphic=null,this._vertexGraphics=[],this._rotateHandleGraphic=null,this._rotateGraphicOffset=20,this._angleOfRotation=0,this._rotateLineGraphic=null,this._startInfo=null,this._totalDx=0,this._totalDy=0,this._xScale=1,this._yScale=1,this.tooltip=null,this.type="box",this.callbacks={onMoveStart(){},onMove(){},onMoveStop(){},onScaleStart(){},onScale(){},onScaleStop(){},onRotateStart(){},onRotate(){},onRotateStop(){},onGraphicClick(){}},this.enableMovement=!0,this.enableRotation=!0,this.enableScaling=!0,this.graphics=[],this.highlightName=null,this.highlightsEnabled=!0,this.layer=null,this.preserveAspectRatio=!1,this.showCenterGraphic=!0,this.symbols=B,this.sketchOptions=new H,this.view=null,this._getBounds=(()=>{const t=m();return(e,i)=>{e[0]=Number.POSITIVE_INFINITY,e[1]=Number.POSITIVE_INFINITY,e[2]=Number.NEGATIVE_INFINITY,e[3]=Number.NEGATIVE_INFINITY;for(const s of i){if(!s)continue;let i,o,r,a;if("point"===s.type)i=r=s.x,o=a=s.y;else if("extent"===s.type)[i,o,r,a]=[s.xmin,s.ymin,s.xmax,s.ymax];else{const e=u(t,s);[i,o,r,a]=e}e[0]=Math.min(i,e[0]),e[1]=Math.min(o,e[1]),e[2]=Math.max(r,e[2]),e[3]=Math.max(a,e[3])}return e}})()}initialize(){const t=this.view;this._highlightHelper=new R({view:t}),this._setup(),this.addHandles([r(()=>t?.ready,()=>{const{layer:t,view:e}=this;C(e,t)},{once:!0,initial:!0}),a(()=>this.preserveAspectRatio,()=>{this._activeHandleGraphic&&(this._scaleGraphic(this._activeHandleGraphic),this._updateGraphics(),this._updateTooltip(this._activeHandleGraphic))}),a(()=>t?.scale,()=>{this._updateRotateGraphic(),this._updateRotateLineGraphic()}),a(()=>this.graphics,()=>this.refresh()),a(()=>this.layer,(t,e)=>{e&&this._resetGraphics(e),this.refresh()}),a(()=>[this.highlightsEnabled,this.highlightName],()=>{this._highlightHelper?.removeAll(),this._setUpHighlights()}),a(()=>this.sketchOptions.tooltips.effectiveEnabled,e=>{this.tooltip=e?I(()=>({view:t,options:this.sketchOptions.tooltips})):s(this.tooltip)},h),a(()=>this.view.effectiveTheme.accentColor,()=>this._updateSymbolsForTheme(),c),this.on("move-start",t=>this.callbacks?.onMoveStart?.(t)),this.on("move",t=>this.callbacks?.onMove?.(t)),this.on("move-stop",t=>this.callbacks?.onMoveStop?.(t)),this.on("rotate-start",t=>this.callbacks?.onRotateStart?.(t)),this.on("rotate",t=>this.callbacks?.onRotate?.(t)),this.on("rotate-stop",t=>this.callbacks?.onRotateStop?.(t)),this.on("scale-start",t=>this.callbacks?.onScaleStart?.(t)),this.on("scale",t=>this.callbacks?.onScale?.(t)),this.on("scale-stop",t=>this.callbacks?.onScaleStop?.(t))])}destroy(){this._reset(),this.tooltip=s(this.tooltip)}get state(){const t=this.view?.ready??!1,e=this.graphics.length&&this.layer;return t&&e?"active":t?"ready":"disabled"}isUIGraphic(t){return this._vertexGraphics.includes(t)||t===this._backgroundGraphic||t===this._centerGraphic||t===this._rotateHandleGraphic||t===this._rotateLineGraphic}move(t,e){if(this._mover&&this.graphics.length){for(const i of this.graphics){const s=i.geometry,o=b(s,t,e,this.view);i.geometry=o}this.refresh(),this.emit("move-stop",{graphics:this.graphics,mover:null,dx:t,dy:e,type:"move-stop"})}}scale(t,e){if(!this._mover||!this.graphics.length)return;const i=this._getBoxBounds(m()),s=g(i);for(const o of this.graphics){const i=o.geometry,r=x(i,t,e,s);o.geometry=r}this.refresh(),this.emit("scale-stop",{graphics:this.graphics,mover:null,xScale:t,yScale:e,type:"scale-stop"})}rotate(t,e){if(this._mover&&this.graphics.length){if(!e){const t=this._vertexGraphics[1].geometry.x,i=this._vertexGraphics[3].geometry.y;e=new p(t,i,this.view.spatialReference)}for(const i of this.graphics){const s=i.geometry,o=y(s,t,e);i.geometry=o}this.refresh(),this.emit("rotate-stop",{graphics:this.graphics,mover:null,angle:t,type:"rotate-stop"})}}refresh(){this._reset(),this._setup()}reset(){this.graphics=[]}_setup(){"active"===this.state&&(this._setUpHighlights(),this._setupGraphics(),this._setupMover(),this._updateGraphics())}_reset(){this._highlightHelper?.removeAll(),this._resetGraphicStateVars(),this._resetGraphics(),this._updateTooltip(),this._mover?.destroy(),this._mover=null,this.removeHandles(z)}_resetGraphicStateVars(){this._startInfo=null,this._activeHandleGraphic=null,this._totalDx=0,this._totalDy=0,this._xScale=1,this._yScale=1,this._angleOfRotation=0}_resetGraphics(t){(t=t||this.layer)&&(t.removeMany(this._vertexGraphics),t.remove(this._backgroundGraphic),t.remove(this._centerGraphic),t.remove(this._rotateHandleGraphic),t.remove(this._rotateLineGraphic)),this._vertexGraphics.forEach(t=>!t.destroyed&&t.destroy()),!this._backgroundGraphic.destroyed&&this._backgroundGraphic.destroy(),!this._centerGraphic.destroyed&&this._centerGraphic.destroy(),!this._rotateHandleGraphic.destroyed&&this._rotateHandleGraphic.destroy(),!this._rotateLineGraphic.destroyed&&this._rotateLineGraphic.destroy(),this._vertexGraphics=[],this._backgroundGraphic=null,this._centerGraphic=null,this._rotateHandleGraphic=null,this._rotateLineGraphic=null}_setupMover(){let t=[];this.enableScaling&&(t=t.concat(this._vertexGraphics)),this.enableRotation&&t.push(this._rotateHandleGraphic),this.enableMovement&&(t=t.concat(this.graphics,this._backgroundGraphic)),this.showCenterGraphic&&t.push(this._centerGraphic),this._mover=new k({enableMoveAllGraphics:!1,highlightsEnabled:!1,indicatorsEnabled:!1,view:this.view,graphics:t,callbacks:{onGraphicClick:t=>this._onGraphicClickCallback(t),onGraphicMoveStart:t=>this._onGraphicMoveStartCallback(t),onGraphicMove:t=>this._onGraphicMoveCallback(t),onGraphicMoveStop:t=>this._onGraphicMoveStopCallback(t),onGraphicPointerOver:t=>this._onGraphicPointerOverCallback(t),onGraphicPointerOut:t=>this._onGraphicPointerOutCallback(t)}})}_setCursor(t){this.addHandles(this.view.acquireCursor(t,"high"),z)}_getStartInfo(t){const[e,i,s,o]=this._getBoxBounds(m()),r=Math.abs(s-e),a=Math.abs(o-i),h=(s+e)/2,c=(o+i)/2,{x:n,y:l}=t.geometry;return{width:r,height:a,centerX:h,centerY:c,startX:n,startY:l,graphicInfos:this._getGraphicInfos(),box:this._backgroundGraphic.geometry,rotate:this._rotateHandleGraphic.geometry}}_getGraphicInfos(){return this.graphics.map(t=>this._getGraphicInfo(t))}_getGraphicInfo(t){const e=t.geometry,[i,s,o,r]=this._getBounds(m(),[e]);return{width:Math.abs(o-i),height:Math.abs(r-s),centerX:(o+i)/2,centerY:(r+s)/2,geometry:e}}_onGraphicClickCallback(t){t.viewEvent.stopPropagation(),this.emit("graphic-click",t),this.callbacks.onGraphicClick&&this.callbacks.onGraphicClick(t)}_onGraphicMoveStartCallback(t){const{_angleOfRotation:e,_xScale:i,_yScale:s,_backgroundGraphic:o,_vertexGraphics:r,_rotateHandleGraphic:a,symbols:h,graphics:c}=this,{graphic:n,dx:l,dy:p,viewEvent:_}=t;this._resetGraphicStateVars(),this._hideGraphicsBeforeUpdate(),o.symbol=h.fill.active,this._startInfo=this._getStartInfo(n),this._updateTooltip(n,_),n===a?(this._setCursor("grabbing"),this.emit("rotate-start",{type:"rotate-start",mover:n,graphics:c,angle:e})):r.includes(n)?(this._activeHandleGraphic=n,this.emit("scale-start",{type:"scale-start",mover:n,graphics:c,xScale:i,yScale:s})):this.emit("move-start",{type:"move-start",graphics:c,mover:n,dx:l,dy:p})}_onGraphicMoveCallback(t){const e=t.graphic;if(!this._startInfo)return;const{_xScale:i,_yScale:s,_angleOfRotation:o,graphics:r}=this;if(this._vertexGraphics.includes(e))this._scaleGraphic(e),this._updateTooltip(e,t.viewEvent),this.emit("scale",{type:"scale",graphics:r,mover:e,xScale:i,yScale:s});else if(e===this._rotateHandleGraphic)this._rotateGraphic(e),this._updateTooltip(e,t.viewEvent),this.emit("rotate",{type:"rotate",graphics:r,mover:e,angle:o});else{const{dx:i,dy:s}=t;this._totalDx+=i,this._totalDy+=s,this._moveGraphic(e,i,s),this._updateTooltip(e,t.viewEvent),this.emit("move",{type:"move",graphics:r,mover:e,dx:i,dy:s})}}_onGraphicMoveStopCallback(t){const e=t.graphic;if(!this._startInfo)return void this.refresh();const{_angleOfRotation:i,_totalDx:s,_totalDy:o,_xScale:r,_yScale:a,_vertexGraphics:h,_rotateHandleGraphic:c,graphics:n}=this;this.refresh(),e===c?(this._setCursor("pointer"),this.emit("rotate-stop",{type:"rotate-stop",graphics:n,mover:e,angle:i})):h.includes(e)?this.emit("scale-stop",{type:"scale-stop",mover:e,graphics:n,xScale:r,yScale:a}):this.emit("move-stop",{type:"move-stop",graphics:n,mover:e,dx:s,dy:o})}_onGraphicPointerOverCallback(t){const{_backgroundGraphic:e,_vertexGraphics:i,graphics:s,_rotateHandleGraphic:o,symbols:r,view:a}=this,h=t.graphic;if(this._hoveredGraphic=h,h===o)return o.symbol=r.rotator.hover,this._setCursor("pointer"),void this._updateTooltip(h);if(s.includes(h)||h===e)return void this._setCursor("move");if(!i.includes(h))return void this._setCursor("pointer");this._updateTooltip(h),t.graphic.symbol=r.handles.hover;const c=a.rotation;let n,l=t.index;switch(l<8&&(c>=0&&c<45?l%=8:l=c>=45&&c<90?(l+1)%8:c>=90&&c<135?(l+2)%8:c>=135&&c<180?(l+3)%8:c>=180&&c<225?(l+4)%8:c>=225&&c<270?(l+5)%8:c>=270&&c<315?(l+6)%8:(l+7)%8),l){case 0:case 4:n="nwse-resize";break;case 1:case 5:n="ns-resize";break;case 2:case 6:n="nesw-resize";break;case 3:case 7:n="ew-resize";break;default:n="pointer"}this._setCursor(n)}_onGraphicPointerOutCallback(t){const{_vertexGraphics:e,_rotateHandleGraphic:i,symbols:s}=this;this._hoveredGraphic=null,t.graphic===i?i.symbol=s.rotator.default:e.includes(t.graphic)&&(t.graphic.symbol=s.handles.default),this.removeHandles(z),this._updateTooltip()}_scaleGraphic(t){const{_startInfo:e,_vertexGraphics:i,preserveAspectRatio:s,view:o}=this,{centerX:r,centerY:a,graphicInfos:h,height:c,startX:n,startY:l,width:_}=e,{resolution:d,transform:m}=o.state,g=i.indexOf(t);1!==g&&5!==g||this._updateX(t,r),3!==g&&7!==g||this._updateY(t,a);const{x:u,y}=t.geometry,v=m[0]*u+m[2]*y+m[4],f=m[1]*u+m[3]*y+m[5],G=h?.map(t=>t.geometry)??[],S=G.every(t=>"point"===t.type);if((0===_||0===c)&&S){const t=U((u-n)/d),i=U((l-y)/d);for(let e=0;e<G.length;e++)this.graphics[e].geometry=b(G[e],t,i,o,!0);return this._centerGraphic.geometry=new p(u,y,o.spatialReference),void(this._backgroundGraphic.geometry=b(e.box,t,i,o,!0))}if(s){const t=U(m[0]*r+m[2]*a+m[4],2),e=U(m[1]*r+m[3]*a+m[5],2),i=U(m[0]*n+m[2]*l+m[4],2),s=U(m[1]*n+m[3]*l+m[5],2);let o=w(t,e,i,s,v,f);0!==o&&Math.abs(o)!==1/0||(o=1),this._xScale=this._yScale=o;for(const h of G){const t=G.indexOf(h);this.graphics[t].geometry=x(h,this._xScale,this._yScale,[r,a])}this._updateBackgroundGraphic()}else{let t=u-n,i=l-y;if(1===g||5===g?t=0:3!==g&&7!==g||(i=0),0===t&&0===i)return;const s=r+t/2,h=a+i/2;let m=(_+(n>r?t:-1*t))/_,v=(c+(l<a?i:-1*i))/c;1!==g&&5!==g&&0!==m&&Math.abs(m)!==1/0||(m=1),3!==g&&7!==g&&0!==v&&Math.abs(v)!==1/0||(v=1),this._xScale=m,this._yScale=v;const f=(s-r)/d,w=(h-a)/d,S=x(e.box,this._xScale,this._yScale);this._backgroundGraphic.geometry=b(S,f,w,o,!0);const{centerX:k,centerY:R}=this._getGraphicInfo(this._backgroundGraphic),C=(k-r)/d,M=-1*(R-a)/d;for(const e of G){const t=G.indexOf(e),i=x(e,this._xScale,this._yScale,[r,a]);this.graphics[t].geometry=b(i,C,M,o,!0)}this._centerGraphic.geometry=new p(k,R,o.spatialReference)}}_rotateGraphic(t){const{centerX:e,centerY:i,startX:s,startY:o,box:r,rotate:a}=this._startInfo,h=this.view.spatialReference,c=new p(s,o,h),n=new p(e,i,h),l=t.geometry;this._angleOfRotation=S(c,l,n);const _=this._startInfo.graphicInfos?.map(t=>t.geometry)??[];for(const p of _){const t=_.indexOf(p),e=y(p,this._angleOfRotation,n);this.graphics[t].geometry=e}this._backgroundGraphic.geometry=y(r,this._angleOfRotation,n),this._rotateHandleGraphic.geometry=y(a,this._angleOfRotation,n)}_moveGraphic(t,e,i){if(this.graphics.includes(t)){const s=this._backgroundGraphic.geometry;this._backgroundGraphic.geometry=b(s,e,i,this.view);for(const o of this.graphics)o!==t&&(o.geometry=b(o.geometry,e,i,this.view))}else if(t===this._centerGraphic){const t=this._backgroundGraphic.geometry;this._backgroundGraphic.geometry=b(t,e,i,this.view)}if(t===this._backgroundGraphic||t===this._centerGraphic)for(const s of this.graphics)s.geometry=b(s.geometry,e,i,this.view)}_setUpHighlights(){this.highlightsEnabled&&this.graphics.length&&this._highlightHelper?.add(this.graphics,this.highlightName)}_setupGraphics(){const{_graphicAttributes:t,symbols:i}=this;this._centerGraphic=new e({symbol:i.centerIndicator,attributes:t}),this.showCenterGraphic&&this.layer.add(this._centerGraphic),this._backgroundGraphic=new e({symbol:i.fill.default,attributes:t}),this.layer.add(this._backgroundGraphic),this._rotateLineGraphic=new e({symbol:i.rotatorLine,attributes:t}),this._rotateHandleGraphic=new e({symbol:i.rotator.default,attributes:t}),this.enableRotation&&!this._hasExtentGraphic()&&this.layer.addMany([this._rotateLineGraphic,this._rotateHandleGraphic]);for(let s=0;s<8;s++)this._vertexGraphics.push(new e({symbol:i.handles.default,attributes:t}));this.enableScaling&&this.layer.addMany(this._vertexGraphics)}_updateSymbolsForTheme(){const t=this.view.effectiveTheme.accentColor;this.symbols={...this.symbols,fill:{active:this.symbols.fill.active?.clone().set("outline.color",t),default:this.symbols.fill.default?.clone().set("outline.color",t)},handles:{...this.symbols.handles,default:this.symbols.handles.default.clone().set("outline.color",t)},rotator:{...this.symbols.rotator,default:this.symbols.rotator.default.clone().set("outline.color",t)},rotatorLine:this.symbols.rotatorLine.clone().set("color",t)};for(const e of this._vertexGraphics)e.symbol=e===this._hoveredGraphic?this.symbols.handles.hover:this.symbols.handles.default;this._backgroundGraphic.symbol=this.symbols.fill.default,this._rotateHandleGraphic.symbol=this._rotateHandleGraphic===this._hoveredGraphic?this.symbols.rotator.hover:this.symbols.rotator.default,this._rotateLineGraphic.symbol=this.symbols.rotatorLine}_updateGraphics(){this._updateBackgroundGraphic(),this._updateHandleGraphics(),this._updateCenterGraphic(),this._updateRotateGraphic(),this._updateRotateLineGraphic()}_hideGraphicsBeforeUpdate(){this._centerGraphic.visible=!1,this._rotateHandleGraphic.visible=!1,this._rotateLineGraphic.visible=!1,this._vertexGraphics.forEach(t=>t.visible=!1)}_updateHandleGraphics(){const t=this._getCoordinates(!0);this._vertexGraphics.forEach((e,i)=>{const[s,o]=t[i];this._updateXY(e,s,o)})}_updateBackgroundGraphic(){const t=this._getCoordinates().map(([t,e])=>[t,e]);this._backgroundGraphic.geometry=new _({rings:[t],spatialReference:this.view.spatialReference})}_updateCenterGraphic(){const[t,e,i,s]=this._getBoxBounds(m()),o=(i+t)/2,r=(s+e)/2;this._centerGraphic.geometry=new p(o,r,this.view.spatialReference)}_updateRotateGraphic(){if(!this._vertexGraphics.length)return;const{x:t,y:e}=this._vertexGraphics[1].geometry,i=e+this.view.state.resolution*this._rotateGraphicOffset;this._rotateHandleGraphic.geometry=new p(t,i,this.view.spatialReference)}_updateRotateLineGraphic(){if(!this._vertexGraphics.length||!this._rotateHandleGraphic?.geometry)return;const t=this._vertexGraphics[1].geometry,e=this._rotateHandleGraphic.geometry;this._rotateLineGraphic.geometry=new d({paths:[[[t.x,t.y],[e.x,e.y]]],spatialReference:this.view.spatialReference})}_updateXY(t,e,i){t.geometry=new p(e,i,this.view.spatialReference)}_updateX(t,e){const i=t.geometry.y;t.geometry=new p(e,i,this.view.spatialReference)}_updateY(t,e){const i=t.geometry.x;t.geometry=new p(i,e,this.view.spatialReference)}_hasExtentGraphic(){return this.graphics.some(t=>null!=t?.geometry&&"extent"===t.geometry.type)}_getBoxBounds(t){const e=this.graphics.map(t=>t.geometry);return this._getBounds(t,e)}_getCoordinates(t){const[e,i,s,o]=this._getBoxBounds(m());if(t){const t=(e+s)/2,r=(o+i)/2;return[[e,o],[t,o],[s,o],[s,r],[s,i],[t,i],[e,i],[e,r]]}return[[e,o],[s,o],[s,i],[e,i]]}_updateTooltip(t,e){if(null==this.tooltip)return;if(!t)return void this.tooltip.clear();const{_backgroundGraphic:i,graphics:s,_vertexGraphics:o,_rotateHandleGraphic:r}=this;t===r?this._updateRotateTooltip():o.includes(t)?this._updateScaleTooltip():(s.includes(t)||t===i)&&this._updateMoveTooltip(e)}_updateRotateTooltip(){null!=this.tooltip&&(this.tooltip.info=new O({sketchOptions:this.sketchOptions,angle:-this._angleOfRotation}))}_updateScaleTooltip(){const{tooltip:t,_xScale:e,_yScale:i,sketchOptions:s,view:o,automaticLengthMeasurementUtils:r}=this;if(null==t)return;const a=this._getCoordinates(),h=L({topLeft:a[0],topRight:a[1],bottomRight:a[2],bottomLeft:a[3],spatialReference:o.spatialReference,automaticLengthMeasurementUtils:r});if(null==h)return;const{xSize:c,ySize:n}=h,l=Math.abs(e),p=Math.abs(i);t.info=new T({sketchOptions:s,xScale:l,yScale:p,xSize:c,ySize:n})}_updateMoveTooltip(t){const{tooltip:e,sketchOptions:i,view:s,automaticLengthMeasurementUtils:r}=this;if(null==e)return;const a=new j({sketchOptions:i});if(t){const{x:e,y:i}=t.origin,h=s.toMap(t),c=s.toMap({x:e,y:i}),n=r.autoDistanceBetweenPoints2D(c,h);a.distance=null!=n?n:o}e.info=a}};function U(t,e=2){return Number.parseFloat(t.toFixed(e))}t([n()],N.prototype,"tooltip",void 0),t([n({readOnly:!0})],N.prototype,"type",void 0),t([n()],N.prototype,"callbacks",void 0),t([n()],N.prototype,"enableMovement",void 0),t([n()],N.prototype,"enableRotation",void 0),t([n()],N.prototype,"enableScaling",void 0),t([n()],N.prototype,"graphics",void 0),t([n()],N.prototype,"highlightName",void 0),t([n()],N.prototype,"highlightsEnabled",void 0),t([n()],N.prototype,"layer",void 0),t([n()],N.prototype,"preserveAspectRatio",void 0),t([n()],N.prototype,"showCenterGraphic",void 0),t([n({readOnly:!0})],N.prototype,"state",null),t([n()],N.prototype,"symbols",void 0),t([n({type:H})],N.prototype,"sketchOptions",void 0),t([n({constructOnly:!0})],N.prototype,"view",void 0),t([n({constructOnly:!0})],N.prototype,"automaticLengthMeasurementUtils",void 0),N=t([l("esri.views.draw.support.Box")],N);const Y=N;export{Y as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.34/esri/copyright.txt for details.
4
4
  */
5
- import{__decorate as e}from"tslib";import t from"../../../Graphic.js";import{createTask as i}from"../../../core/asyncUtils.js";import s from"../../../core/Collection.js";import o from"../../../core/Error.js";import{EventedAccessor as r}from"../../../core/Evented.js";import n from"../../../core/Logger.js";import{destroyMaybe as a,assertIsSome as h,abortMaybe as p}from"../../../core/maybe.js";import{pausable as c,when as l,watch as d,initial as m,sync as v}from"../../../core/reactiveUtils.js";import{property as y}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/RandomLCG.js";import{subclass as _}from"../../../core/accessorSupport/decorators/subclass.js";import g from"../../../geometry/Point.js";import{closeRingsAndFixWinding as u,getMidpoint as f,geometryToCoordinates as x}from"../../../geometry/support/coordsUtils.js";import G from"../../../layers/GraphicsLayer.js";import M from"../../../symbols/SimpleMarkerSymbol.js";import{SnappingVisualizer2D as b}from"../../2d/interactive/SnappingVisualizer2D.js";import{ConnectedReshapeManager as V}from"./ConnectedReshapeManager.js";import{cloneMove as S}from"./drawUtils.js";import w from"./GraphicMover.js";import E from"./HighlightHelper.js";import{addUniqueLayer as I,isConnectedReshapeSupportedLayer as O}from"./layerUtils.js";import{createTooltipInfos as C,connectTooltip as k,updateTranslateTooltipInfo as T,updateTranslateVertexTooltipInfo as H}from"./reshapeTooltipUtils.js";import{settings as R}from"./settings.js";import{ViewEventPriorities as j}from"../../input/InputManager.js";import{createCoordinateHelper as A}from"../../interactive/coordinateHelper.js";import{sketchKeys as U}from"../../interactive/keybindings.js";import{EditGeometryOperations as L}from"../../interactive/editGeometry/EditGeometryOperations.js";import z from"../../interactive/sketch/SketchOptions.js";import{SnappingContext as D}from"../../interactive/snapping/SnappingContext.js";import{makeTooltip as F,enterInputModeIfAvailable as P}from"../../interactive/tooltip/tooltipCommonUtils.js";const N=R.reshapeGraphics,Z={vertices:{default:new M({style:"circle",size:N.vertex.size,color:N.vertex.color,outline:{color:N.vertex.outlineColor,width:1}}),hover:new M({style:"circle",size:N.vertex.hoverSize,color:N.vertex.hoverColor,outline:{color:N.vertex.hoverOutlineColor,width:1}}),selected:new M({style:"circle",size:N.selected.size,color:N.selected.color,outline:{color:N.selected.outlineColor,width:1}})},midpoints:{default:new M({style:"circle",size:N.midpoint.size,color:N.midpoint.color,outline:{color:N.midpoint.outlineColor,width:1}}),hover:new M({style:"circle",size:N.midpoint.size,color:N.midpoint.color,outline:{color:N.midpoint.outlineColor,width:1}})}},X=Symbol();let Y=class extends r{constructor(e){super(e),this._updateHandlesOnExternalGeometryChange=null,this._activeOperationInfo=null,this._connectedReshapeManager=null,this._editGeometryOperations=null,this._graphicAttributes={esriSketchTool:"box"},this._mover=null,this._snappingContext=null,this._snappingGraphicsLayer=null,this._hoverGraphic=null,this._snappingTask=null,this._stagedVertex=null,this.tooltip=null,this.activeTooltipInfo=null,this.callbacks={onReshapeStart(){},onReshape(){},onReshapeStop(){},onMoveStart(){},onMove(){},onMoveStop(){},onGraphicClick(){}},this.connectedReshapeProviders=[],this.enableMidpoints=!0,this.enableMovement=!0,this.enableVertices=!0,this.graphic=null,this.highlightName=null,this.highlightsEnabled=!0,this.layer=null,this.midpointGraphics=new s,this.midpointSymbol=new M({style:"circle",size:6,color:[200,200,200],outline:{color:[100,100,100],width:1}}),this.selectedVertices=new s,this.snappingManager=null,this.symbols=Z,this.sketchOptions=new z,this.type="reshape",this.vertexGraphics=new s,this.view=null}initialize(){const e=this.view;this._highlightHelper=new E({view:e}),this._setup(),this._updateHandlesOnExternalGeometryChange=c(()=>this.graphic?.geometry,e=>{if(!e)return;const t=new Set(this.selectedVertices.map(e=>e.attributes?.pointIndex));this._highlightHelper.removeAll(),this._setUpHighlights(),this._setupGraphics(),this._clearSelection(),this.vertexGraphics.filter(e=>t.has(e.attributes.pointIndex)).forEach(e=>this._addToSelection(e));const{enableMovement:i,_mover:s,graphic:o,midpointGraphics:r,vertexGraphics:n}=this,a=n.concat(r).items;i&&a.push(o),s?.set("graphics",a)},v),this.tooltip=F(()=>({view:e,options:this.sketchOptions.tooltips})),this.tooltipInfos=C(this.sketchOptions),this.addHandles([l(()=>e?.ready,()=>{const{layer:e,view:t}=this;I(t,e),this.addHandles(t.on("key-down",e=>this._keyDownHandler(e),j.TOOL))},{once:!0,initial:!0}),d(()=>this.graphic,()=>this.refresh()),d(()=>this.layer,(e,t)=>{t&&(this._clearSelection(),this._resetGraphics(t)),this.refresh()}),d(()=>[this.highlightsEnabled,this.highlightName],()=>{this._highlightHelper?.removeAll(),this._setUpHighlights()}),d(()=>this.enableMidpoints,()=>this.refresh()),k(this.tooltip,()=>this._tooltipsContext),d(()=>this.view.effectiveTheme.accentColor,()=>this._updateSymbolsForTheme(),m),this._updateHandlesOnExternalGeometryChange]),this._updateTooltip()}destroy(){this._reset(),this._mover?.destroy(),this._mover=null,this._connectedReshapeManager=a(this._connectedReshapeManager),this.tooltip=a(this.tooltip)}get _coordinateHelper(){return this._editGeometryOperations?.data.coordinateHelper??A(!!this.graphic.geometry?.hasZ,!!this.graphic.geometry?.hasM,this.view.spatialReference)}get _selectedVertex(){return 1===this.selectedVertices.length?this.selectedVertices.at(0):void 0}get _tooltipsContext(){const{automaticAreaMeasurementUtils:e,automaticLengthMeasurementUtils:t,sketchOptions:i,activeTooltipInfo:s,graphic:o}=this;return{sketchOptions:i,activeTooltipInfo:s,graphic:o,selectedVertex:this._selectedVertex,automaticAreaMeasurementUtils:e,automaticLengthMeasurementUtils:t,updateGeometry:(e,t,i,s,o)=>{this._setUpGeometryHelper();const r=e===this.graphic;r?this._emitMoveStartEvent(0,0):this._emitReshapeStartEvent(e);const n=!0;if(this._syncGeometryAfterVertexMove(e,t,s,o,n),r){const{view:e}=this,s=e.toScreen(i),o=e.toScreen(t),r=(o?.x??0)-(s?.x??0),n=(o?.y??0)-(s?.y??0);this._emitMoveEvent(r,n),this._emitMoveStopEvent(r,n)}else this._emitReshapeEvent(e),this._emitReshapeStopEvent(e);this._editGeometryOperations=a(this._editGeometryOperations)}}}get state(){const e=this.view.ready,t=!(!this.graphic||!this.layer);return e&&t?"active":e?"ready":"disabled"}isUIGraphic(e){const t=[];return this.graphic&&t.push(this.graphic),t.concat(this.vertexGraphics.items,this.midpointGraphics.items),t.length>0&&t.includes(e)}refresh(){this._reset(),this._setup()}reset(){this.graphic=null}clearSelection(){this._clearSelection()}removeSelectedVertices(){const{selectedVertices:e}=this;e.length&&this._removeVertices(e)}_setup(){const{graphic:e,layer:t}=this;if(!t||null==e?.geometry)return;const i=e.geometry;"mesh"!==i.type&&"extent"!==i.type?("polygon"===i.type&&u(i),this._setUpHighlights(),this._setupGraphics(),this._setupMover(),this._setupConnectedReshapeManager()):this._logGeometryTypeError()}_setUpHighlights(){this.highlightsEnabled&&this.graphic&&this._highlightHelper?.add(this.graphic,this.highlightName)}_setUpGeometryHelper(){const e=this.graphic.geometry;null!=e&&"mesh"!==e.type&&"extent"!==e.type?this._editGeometryOperations=L.fromGeometry(e,2):this._logGeometryTypeError()}_saveSnappingContextForHandle(e,t){this._snappingGraphicsLayer=new G({listMode:"hide",internal:!0,title:"Reshape snapping layer"}),this.view.map.layers.add(this._snappingGraphicsLayer);const i=this._editGeometryOperations;h(i),this._snappingContext=new D({editGeometryOperations:i,elevationInfo:{mode:"on-the-ground",offset:0},pointer:t.viewEvent?.pointerType||"mouse",excludeFeature:this.graphic,feature:this.graphic,visualizer:new b(this._snappingGraphicsLayer),vertexHandle:this._getVertexFromEditGeometry(e)})}_reset(){this._clearSelection(),this._highlightHelper?.removeAll(),this._updateTooltip(),this._resetGraphics(),this._resetSnappingStateVars(),this._activeOperationInfo=null,this._mover?.destroy(),this._mover=null,this.removeHandles(X)}_resetSnappingStateVars(){null!=this.snappingManager&&this.snappingManager.doneSnapping(),null!=this._snappingGraphicsLayer&&(this.view?.map&&this.view.map.layers.remove(this._snappingGraphicsLayer),this._snappingGraphicsLayer.destroy()),this._editGeometryOperations=a(this._editGeometryOperations),this._snappingTask=p(this._snappingTask),this._snappingTask=null,this._snappingContext=null,this._stagedVertex=null}_resetGraphics(e){this._removeMidpointGraphics(e),this._removeVertexGraphics(e),this.selectedVertices.removeAll(),this._updateTooltip()}_removeMidpointGraphics(e){const t=e||this.layer;t&&t.removeMany(this.midpointGraphics.items),this.midpointGraphics.items.forEach(e=>e.destroy()),this.midpointGraphics.removeAll()}_removeVertexGraphics(e){const t=e||this.layer;t&&t.removeMany(this.vertexGraphics.items),this.vertexGraphics.items.forEach(e=>e.destroy()),this.vertexGraphics.removeAll()}_setupGraphics(){const e=this.graphic.geometry;if(null!=e&&("polyline"===e.type||"polygon"===e.type||"multipoint"===e.type)){const t=q(e);this.enableMidpoints&&"multipoint"!==e.type&&this._setUpMidpointGraphics(t),this.enableVertices&&this._setUpVertexGraphics(t)}}_setUpMidpointGraphics(e){this._removeMidpointGraphics();const t=this._createMidpointGraphics(e);this.midpointGraphics.addMany(t),this.layer.addMany(t)}_setUpVertexGraphics(e){this._removeVertexGraphics();const t=this._createVertexGraphics(e);this.vertexGraphics.addMany(t),this._storeRelatedVertexIndices(),this.layer.addMany(t)}_createVertexGraphics(e){const{_graphicAttributes:i,symbols:s}=this,o=[];return e?.forEach((e,r)=>{e.forEach((e,n)=>{o.push(new t({geometry:this._coordinateHelper.arrayToPoint(e),symbol:s?.vertices?.default,attributes:{...i,pathIndex:r,pointIndex:n}}))})}),o}_createMidpointGraphics(e){const{_graphicAttributes:i,symbols:s}=this,o=[];for(let r=0;r<e.length;r++){const n=e[r];for(let e=0;e<n.length;e++){const a=(e+1)%n.length;if("polyline"===this.graphic.geometry?.type&&0===a)continue;const h=n[e],p=n[a],c=this._getMidpoint(h,p);o.push(new t({geometry:c,symbol:s.midpoints.default,attributes:{...i,pathIndex:r,pointIndexStart:e,pointIndexEnd:a}}))}}return o}_updateSymbolsForTheme(){const e=this.view.effectiveTheme.accentColor;this.symbols={vertices:{...this.symbols.vertices,default:this.symbols.vertices.default.clone().set("color",e),hover:this.symbols.vertices.hover?.clone().set("color",e)},midpoints:{...this.symbols.midpoints}};for(const t of this.vertexGraphics)this._isSelected(t)?t.symbol=this.symbols.vertices.selected:this._hoverGraphic===t?t.symbol=this.symbols.vertices.hover:t.symbol=this.symbols.vertices.default}_storeRelatedVertexIndices(){const e=this.vertexGraphics.items;if(!e)return;const t=e.map(({geometry:e})=>({x:e.x,y:e.y}));for(let i=0;i<t.length;i++){const s=[];for(let e=0;e<t.length;e++){if(i===e)continue;const o=t[i],r=t[e];o.x===r.x&&o.y===r.y&&s.push(e)}e[i].attributes.relatedGraphicIndices=s}}_setupMover(){const{enableMovement:e,graphic:t,midpointGraphics:i,vertexGraphics:s,view:o}=this,r=s.concat(i).items;e&&"multipoint"!==t.geometry?.type&&r.push(t),this._mover=new w({enableMoveAllGraphics:!1,highlightsEnabled:!1,indicatorsEnabled:!1,graphics:r,view:o,callbacks:{onGraphicClick:e=>this._onGraphicClickCallback(e),onGraphicMoveStart:e=>this._onGraphicMoveStartCallback(e),onGraphicMove:e=>this._onGraphicMoveCallback(e),onGraphicMoveStop:e=>this._onGraphicMoveStopCallback(e),onGraphicPointerOver:e=>this._onGraphicPointerOverCallback(e),onGraphicPointerOut:e=>this._onGraphicPointerOutCallback(e)}})}_setupConnectedReshapeManager(){const{connectedReshapeProviders:e}=this;0!==e.length&&(this._connectedReshapeManager=new V({providerFactories:e,view:this.view}))}_onGraphicClickCallback(e){e.viewEvent.stopPropagation();const t=e.graphic;if(t===this.graphic)this.clearSelection(),this.emit("graphic-click",e),this.callbacks.onGraphicClick?.(e);else if(this._isMidpoint(t)){if(2===e.viewEvent.button)return;const i=this.graphic.clone(),s=this._createVertexFromMidpoint(t);this.refresh(),this._emitVertexAddEvent([t],i,s)}else if(this._isVertex(t))if(e.viewEvent.stopPropagation(),2===e.viewEvent.button)this._removeVertices(t);else{e.viewEvent.native.shiftKey||this._clearSelection(),this.selectedVertices.includes(t)?this._removeFromSelection(t,!0):this._addToSelection(t)}}_setUpOperation(e){const{graphic:t,dx:i,dy:s}=e,o=t===this.graphic;this._resetSnappingStateVars(),this._setUpGeometryHelper(),this._saveSnappingContextForHandle(t,e),this._activeOperationInfo={target:this.graphic,mover:t,operationType:o?"move":"reshape",totalDx:i,totalDy:s}}_onGraphicMoveStartCallback(e){const{dx:t,dy:i,graphic:s}=e,o=this._connectedReshapeManager,r=o?J(this.graphic):null;if(s===this.graphic){const{geometry:n}=s;return this._setUpOperation(e),this._emitMoveStartEvent(t,i),r&&o?.startFeatureMove([r]),void(null!=n&&"point"===n.type&&this._onHandleMove(s,t,i,e,()=>{this._updateTooltip(this.graphic,e.viewEvent),this._emitMoveEvent(t,i)}))}const{selectedVertices:n}=this;if(!n.includes(s)){if(this._clearSelection(),this._isMidpoint(s)){const e=this.graphic.clone(),t=this._createVertexFromMidpoint(s);this._emitVertexAddEvent([s],e,t)}this._addToSelection(s)}this._setUpOperation(e),r&&o?.startVertexMove(r,Q(n)),this._emitReshapeStartEvent(s),this._onHandleMove(s,t,i,e,()=>{this._updateTooltip(s,e.viewEvent),this._emitReshapeEvent(s)})}_onGraphicMoveCallback(e){const t=this._activeOperationInfo;if(!t)return;const{dx:i,dy:s,graphic:o}=e;t.totalDx+=i,t.totalDy+=s;const{operationType:r}=t,{geometry:n}=o;if(null!=n)if("move"!==r)this._onHandleMove(o,i,s,e,()=>{this._updateTooltip(o,e.viewEvent),this._emitReshapeEvent(o)});else if("point"===n.type)this._onHandleMove(o,i,s,e,()=>{this._updateTooltip(this.graphic,e.viewEvent),this._emitMoveEvent(i,s)});else if("polyline"===n.type||"polygon"===n.type){const t=q(n);this._updateVertexGraphicLocations(t);const{dxMap:o,dyMap:r}=W(i,s,this.view);this._connectedReshapeManager?.translate(o,r,0),this._updateTooltip(this.graphic,e.viewEvent),this._emitMoveEvent(i,s)}}_onGraphicMoveStopCallback(e){const t=this._activeOperationInfo;if(!t)return;const{dx:i,dy:s,graphic:o}=e,{operationType:r}=t;t.totalDx+=i,t.totalDy+=s,this._onHandleMove(o,i,s,e,()=>"move"===r?this._emitMoveStopEvent():this._emitReshapeStopEvent(o)),this._isMidpoint(o)?this.refresh():(this._updateTooltip(this._isVertex(o)?o:null),this._resetSnappingStateVars(),this._connectedReshapeManager?.finish(),this._activeOperationInfo=null)}_updateVertexGraphicLocations(e){const{_coordinateHelper:t}=this;for(const i of this.vertexGraphics){const{pathIndex:s,pointIndex:o}=i.attributes;i.geometry=t.arrayToPoint(e[s][o])}this._updateMidpointGraphicLocations(e)}_updateMidpointGraphicLocations(e){for(const t of this.midpointGraphics){const{pathIndex:i,pointIndexStart:s,pointIndexEnd:o}=t.attributes,r=e[i];t.geometry=this._getMidpoint(r[s],r[o])}}_getMidpoint(e,t){const{_coordinateHelper:i}=this,s=i.arrayToVector(e),o=i.arrayToVector(t),r=i.toXYZ(s),n=i.toXYZ(o),[a,h,p]=f(r,n),c=i.hasM()?0:void 0;return new g({x:a,y:h,z:p,m:c,spatialReference:i.spatialReference})}_getVertexFromEditGeometry(e){const[t,i]=K(e);return h(this._editGeometryOperations),this._editGeometryOperations.data.parts[t].vertices[i]}_onHandleMove(e,t,s,o,r){p(this._snappingTask);const n=this._snappingContext;if(!n)return;const a=e.geometry,h="graphic-move-stop"===o.type;if(null!=this.snappingManager&&this.selectedVertices.length<2&&!h){const o=this.snappingManager;this._stagedVertex=o.update({point:a,context:n}),this._syncGeometryAfterVertexMove(e,new g(this._stagedVertex),t,s,h),r(),this._snappingTask=i(async i=>{const p=await o.snap({point:a,context:n,signal:i});p.valid&&(this._stagedVertex=p.apply(),this._syncGeometryAfterVertexMove(e,new g(this._stagedVertex),t,s,h),r())})}else{const i=null!=this._stagedVertex?new g(this._stagedVertex):a;this._syncGeometryAfterVertexMove(e,i,t,s,h),r()}}_syncGeometryAfterVertexMove(e,t,i,s,o=!1){const r=this._editGeometryOperations?.data.geometry;if(r)if("point"===r.type)e.geometry=t;else if("mesh"===r.type)e.geometry=r.centerAt(t);else{const{_coordinateHelper:n}=this,[a,h]=K(e);let p=x(r);const c=p[a].length-1,l=n.pointToArray(t);if(p[a][h]=l,"polygon"===r.type&&(0===h?p[a][c]=l:h===c&&(p[a][0]=l)),this._isVertex(e)&&(p=this._moveRelatedCoordinates(p,e,l),p=this._moveSelectedHandleCoordinates(p,e,i,s,"polygon"===r.type),this._updateMidpointGraphicLocations(p)),"multipoint"===r.type&&r.points)for(let e=0;e<p.length;e++)r.points[e]=p[e][0];this._updateGraphicGeometry(r.clone());const d=n.pointToVector(t),m=this._getVertexFromEditGeometry(e),v=n.getZ(d),y=d[0]-m.pos[0],_=d[1]-m.pos[1],g=null!=v?v-m.pos[2]:0;this._editGeometryOperations?.moveVertices([m],y,_,g),this._connectedReshapeManager?.translate(y,_,g),o&&(this._mover?this._mover.updateGeometry(this._mover.graphics.indexOf(e),t):e.geometry=t)}}_moveRelatedCoordinates(e,t,i){const{relatedGraphicIndices:s}=t.attributes;for(const o of s){const s=this.vertexGraphics.at(o),{pathIndex:r,pointIndex:n}=s.attributes;e[r][n]=i,s.geometry=t.geometry}return e}_moveSelectedHandleCoordinates(e,t,i,s,o){for(const r of this.selectedVertices)if(r!==t){const{pathIndex:t,pointIndex:n,relatedGraphicIndices:a}=r.attributes,h=S(r.geometry,i,s,this.view),p=x(h),c=e[t].length-1;e[t][n]=p,r.geometry=h,o&&(0===n?e[t][c]=p:n===c&&(e[t][0]=p));for(const i of a){const t=this.vertexGraphics.at(i),{pathIndex:s,pointIndex:o}=t.attributes;e[s][o]=p,t.geometry=h}}return e}_onGraphicPointerOverCallback(e){const t=e.graphic;this._hoverGraphic=t;const i=this._isVertex(t);i&&!this._isSelected(t)&&(t.symbol=this.symbols.vertices.hover),this._updateTooltip(i?t:null),this._updateHoverCursor(t)}_onGraphicPointerOutCallback(e){const t=e.graphic;this._hoverGraphic=null,this._isVertex(t)&&!this._isSelected(t)&&(t.symbol=this.symbols.vertices.default),this.removeHandles(X),this._updateTooltip()}_createVertexFromMidpoint(e){const{_graphicAttributes:t,graphic:i}=this,s=i.geometry;if(null==s||"polygon"!==s.type&&"polyline"!==s.type)return[];const o=s.clone(),r=[],{pathIndex:n,pointIndexStart:a,pointIndexEnd:h}=e.attributes,p=x(e.geometry),c=0===h?a+1:h,l=x(o);return l[n].splice(c,0,p),e.attributes={...t,pathIndex:n,pointIndex:c,relatedGraphicIndices:[]},r.push({coordinates:l[n][c],componentIndex:n,vertexIndex:c}),this._updateGraphicGeometry(o),r}_addToSelection(e){const t=B(e);for(const i of t)i.symbol=this.symbols.vertices.selected,this.selectedVertices.add(i),this._updateTooltip(i);this._emitSelectEvent(t)}_removeFromSelection(e,t){const{vertices:i}=this.symbols,s=t?i.hover:i.default;this.selectedVertices.remove(e),e.symbol=s,this._emitDeselectEvent([e]),this._updateTooltip()}_clearSelection(){const e=this.selectedVertices.toArray();if(e.length>0){for(const t of e)t.set("symbol",this.symbols.vertices.default);this.selectedVertices.removeAll(),this._emitDeselectEvent(e),this._updateTooltip()}}_keyDownHandler(e){null==this._activeOperationInfo&&P(e,this.tooltip)||U.delete.includes(e.key)&&!e.repeat&&this.selectedVertices.length&&this._removeVertices(this.selectedVertices)}_removeVertices(e){const t=this.graphic.geometry,i=this.vertexGraphics.length;if(null==t||"polygon"!==t.type&&"polyline"!==t.type&&"multipoint"!==t.type)return;if("polygon"===t.type&&i<4||"multipoint"===t.type&&i<2||"polyline"===t.type&&i<3)return;const s=this.graphic.clone(),o=t.clone();let r=x(o);const n=[],a=B(e);for(const h of a){const{x:e,y:t}=h.geometry;for(let i=0;i<r.length;i++){const s=r[i];for(let o=0;o<s.length;o++){const[a,h]=s[o];e===a&&t===h&&(n.push({coordinates:r[i][o],componentIndex:i,vertexIndex:o}),r[i].splice(Number(o),1))}}}if("polygon"===o.type)r=r.filter(e=>{if(e.length<2)return!1;const[t,i]=e[0],[s,o]=e[e.length-1];return(2!==e.length||t!==s||i!==o)&&(t===s&&i===o||e.push(e[0]),!0)}),o.rings=r;else if("polyline"===o.type){for(const e of r)1===e.length&&r.splice(r.indexOf(e),1);o.paths=r}else o.points=r.flat();this._updateGraphicGeometry(o),this.refresh(),this._emitVertexRemoveEvent(a,s,n)}_isVertex(e){return this.vertexGraphics.includes(e)}_isSelected(e){return this._isVertex(e)&&this.selectedVertices.includes(e)}_isMidpoint(e){return this.midpointGraphics.includes(e)}_updateHoverCursor(e){const t=this._isMidpoint(e)?"copy":"move";this.addHandles(this.view.acquireCursor(t,"high"),X)}_updateTooltip(e,t){let i=null;const{graphic:s,view:o,tooltipInfos:r}=this,n=s?.geometry;"point"===n?.type?i=r.movePoint:this._selectedVertex?i=r.selectedVertex:e===this.graphic?(i=r.translateGraphic,T(i,o,this._tooltipsContext,t)):e&&this.selectedVertices.length>1&&(i=r.translateVertices,H(i,o,n,this._tooltipsContext,t)),this.activeTooltipInfo=i}_updateGraphicGeometry(e){this._updateHandlesOnExternalGeometryChange?.pause(),this.graphic.geometry=e,this._updateHandlesOnExternalGeometryChange?.resume()}_emitMoveStartEvent(e,t){const i={type:"move-start",mover:this.graphic,dx:e,dy:t};this.emit("move-start",i),this.callbacks.onMoveStart?.(i)}_emitMoveEvent(e,t){const i={type:"move",mover:this.graphic,dx:e,dy:t};this.emit("move",i),this.callbacks.onMove?.(i)}_emitMoveStopEvent(e,t){if(null==e||null==t){const i=this._activeOperationInfo;if(!i)return;e=i.totalDx,t=i.totalDy}const i={type:"move-stop",mover:this.graphic,dx:e,dy:t};this.emit("move-stop",i),this.callbacks.onMoveStop?.(i)}_emitReshapeStartEvent(e){const t={type:"reshape-start",graphic:this.graphic,mover:e,selected:this.selectedVertices.toArray()};this.emit("reshape-start",t),this.callbacks.onReshapeStart?.(t)}_emitReshapeEvent(e){const t={type:"reshape",graphic:this.graphic,mover:e,selected:this.selectedVertices.toArray()};this.emit("reshape",t),this.callbacks.onReshape?.(t)}_emitReshapeStopEvent(e){const t={type:"reshape-stop",graphic:this.graphic,mover:e,selected:this.selectedVertices.toArray()};this.emit("reshape-stop",t),this.callbacks.onReshapeStop?.(t)}_emitSelectEvent(e){const t={type:"vertex-select",added:e};this.emit("select",t),this.callbacks.onVertexSelect?.(t)}_emitDeselectEvent(e){const t={type:"vertex-deselect",removed:e};this.emit("deselect",t),this.callbacks.onVertexDeselect?.(t)}_emitVertexAddEvent(e,t,i){const s={type:"vertex-add",added:e,graphic:this.graphic,oldGraphic:t,vertices:i};this.emit("vertex-add",s),this.callbacks.onVertexAdd?.(s)}_emitVertexRemoveEvent(e,t,i){const s={type:"vertex-remove",removed:e,graphic:this.graphic,oldGraphic:t,vertices:i};this.emit("vertex-remove",s),this.callbacks.onVertexRemove?.(s)}_logGeometryTypeError(){n.getLogger(this).error(new o("reshape:invalid-geometry","Reshape operation not supported for the provided graphic. The geometry type is not supported."))}};function q(e){const t=x(e.clone());if("polygon"===e.type)for(const i of t){const e=i[i.length-1];i[0][0]===e[0]&&i[0][1]===e[1]&&i.length>2&&i.pop()}return t}function K({attributes:e}){return[e?.pathIndex||0,e?.pointIndex||0]}function B(e){return e instanceof t?[e]:[...e]}function J(e){const t=e.sourceLayer??e.layer;return O(t)?{graphic:e,layer:t}:null}function Q(e){return e.toArray().map(e=>({pathIndex:e.attributes.pathIndex,vertexIndex:e.attributes.pointIndex}))}function W(e,t,i){const s=i.state.inverseTransform;return{dxMap:s[0]*e+s[2]*t,dyMap:s[1]*e+s[3]*t}}e([y()],Y.prototype,"_activeOperationInfo",void 0),e([y()],Y.prototype,"_connectedReshapeManager",void 0),e([y()],Y.prototype,"_coordinateHelper",null),e([y()],Y.prototype,"_editGeometryOperations",void 0),e([y()],Y.prototype,"tooltip",void 0),e([y()],Y.prototype,"tooltipInfos",void 0),e([y()],Y.prototype,"activeTooltipInfo",void 0),e([y({constructOnly:!0})],Y.prototype,"automaticAreaMeasurementUtils",void 0),e([y({constructOnly:!0})],Y.prototype,"automaticLengthMeasurementUtils",void 0),e([y()],Y.prototype,"_selectedVertex",null),e([y()],Y.prototype,"_tooltipsContext",null),e([y()],Y.prototype,"callbacks",void 0),e([y()],Y.prototype,"connectedReshapeProviders",void 0),e([y()],Y.prototype,"enableMidpoints",void 0),e([y()],Y.prototype,"enableMovement",void 0),e([y()],Y.prototype,"enableVertices",void 0),e([y()],Y.prototype,"graphic",void 0),e([y()],Y.prototype,"highlightName",void 0),e([y()],Y.prototype,"highlightsEnabled",void 0),e([y()],Y.prototype,"layer",void 0),e([y({readOnly:!0})],Y.prototype,"midpointGraphics",void 0),e([y()],Y.prototype,"midpointSymbol",void 0),e([y({readOnly:!0})],Y.prototype,"selectedVertices",void 0),e([y()],Y.prototype,"snappingManager",void 0),e([y({readOnly:!0})],Y.prototype,"state",null),e([y()],Y.prototype,"symbols",void 0),e([y({type:z})],Y.prototype,"sketchOptions",void 0),e([y({readOnly:!0})],Y.prototype,"type",void 0),e([y({readOnly:!0})],Y.prototype,"vertexGraphics",void 0),e([y()],Y.prototype,"view",void 0),Y=e([_("esri.views.draw.support.Reshape")],Y);const $=Y;export{$ as default};
5
+ import{__decorate as e}from"tslib";import t from"../../../Graphic.js";import{createTask as i}from"../../../core/asyncUtils.js";import s from"../../../core/Collection.js";import o from"../../../core/Error.js";import{EventedAccessor as r}from"../../../core/Evented.js";import n from"../../../core/Logger.js";import{destroyMaybe as a,assertIsSome as h,abortMaybe as p}from"../../../core/maybe.js";import{pausable as c,when as l,watch as d,initial as m,sync as v}from"../../../core/reactiveUtils.js";import{property as y}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/RandomLCG.js";import{subclass as _}from"../../../core/accessorSupport/decorators/subclass.js";import g from"../../../geometry/Point.js";import{closeRingsAndFixWinding as u,getMidpoint as f,geometryToCoordinates as x}from"../../../geometry/support/coordsUtils.js";import G from"../../../layers/GraphicsLayer.js";import M from"../../../symbols/SimpleMarkerSymbol.js";import{SnappingVisualizer2D as b}from"../../2d/interactive/SnappingVisualizer2D.js";import{ConnectedReshapeManager as V}from"./ConnectedReshapeManager.js";import{screenDeltaToMapDelta as S,cloneMove as w}from"./drawUtils.js";import E from"./GraphicMover.js";import I from"./HighlightHelper.js";import{addUniqueLayer as O,isConnectedReshapeSupportedLayer as C}from"./layerUtils.js";import{createTooltipInfos as k,connectTooltip as T,updateTranslateTooltipInfo as H,updateTranslateVertexTooltipInfo as R}from"./reshapeTooltipUtils.js";import{settings as j}from"./settings.js";import{ViewEventPriorities as A}from"../../input/InputManager.js";import{createCoordinateHelper as U}from"../../interactive/coordinateHelper.js";import{sketchKeys as L}from"../../interactive/keybindings.js";import{EditGeometryOperations as z}from"../../interactive/editGeometry/EditGeometryOperations.js";import D from"../../interactive/sketch/SketchOptions.js";import{SnappingContext as F}from"../../interactive/snapping/SnappingContext.js";import{makeTooltip as P,enterInputModeIfAvailable as N}from"../../interactive/tooltip/tooltipCommonUtils.js";const Z=j.reshapeGraphics,X={vertices:{default:new M({style:"circle",size:Z.vertex.size,color:Z.vertex.color,outline:{color:Z.vertex.outlineColor,width:1}}),hover:new M({style:"circle",size:Z.vertex.hoverSize,color:Z.vertex.hoverColor,outline:{color:Z.vertex.hoverOutlineColor,width:1}}),selected:new M({style:"circle",size:Z.selected.size,color:Z.selected.color,outline:{color:Z.selected.outlineColor,width:1}})},midpoints:{default:new M({style:"circle",size:Z.midpoint.size,color:Z.midpoint.color,outline:{color:Z.midpoint.outlineColor,width:1}}),hover:new M({style:"circle",size:Z.midpoint.size,color:Z.midpoint.color,outline:{color:Z.midpoint.outlineColor,width:1}})}},Y=Symbol();let q=class extends r{constructor(e){super(e),this._updateHandlesOnExternalGeometryChange=null,this._activeOperationInfo=null,this._connectedReshapeManager=null,this._editGeometryOperations=null,this._graphicAttributes={esriSketchTool:"box"},this._mover=null,this._snappingContext=null,this._snappingGraphicsLayer=null,this._hoverGraphic=null,this._snappingTask=null,this._stagedVertex=null,this.tooltip=null,this.activeTooltipInfo=null,this.callbacks={onReshapeStart(){},onReshape(){},onReshapeStop(){},onMoveStart(){},onMove(){},onMoveStop(){},onGraphicClick(){}},this.connectedReshapeProviders=[],this.enableMidpoints=!0,this.enableMovement=!0,this.enableVertices=!0,this.graphic=null,this.highlightName=null,this.highlightsEnabled=!0,this.layer=null,this.midpointGraphics=new s,this.midpointSymbol=new M({style:"circle",size:6,color:[200,200,200],outline:{color:[100,100,100],width:1}}),this.selectedVertices=new s,this.snappingManager=null,this.symbols=X,this.sketchOptions=new D,this.type="reshape",this.vertexGraphics=new s,this.view=null}initialize(){const e=this.view;this._highlightHelper=new I({view:e}),this._setup(),this._updateHandlesOnExternalGeometryChange=c(()=>this.graphic?.geometry,e=>{if(!e)return;const t=new Set(this.selectedVertices.map(e=>e.attributes?.pointIndex));this._highlightHelper.removeAll(),this._setUpHighlights(),this._setupGraphics(),this._clearSelection(),this.vertexGraphics.filter(e=>t.has(e.attributes.pointIndex)).forEach(e=>this._addToSelection(e));const{enableMovement:i,_mover:s,graphic:o,midpointGraphics:r,vertexGraphics:n}=this,a=n.concat(r).items;i&&a.push(o),s?.set("graphics",a)},v),this.tooltip=P(()=>({view:e,options:this.sketchOptions.tooltips})),this.tooltipInfos=k(this.sketchOptions),this.addHandles([l(()=>e?.ready,()=>{const{layer:e,view:t}=this;O(t,e),this.addHandles(t.on("key-down",e=>this._keyDownHandler(e),A.TOOL))},{once:!0,initial:!0}),d(()=>this.graphic,()=>this.refresh()),d(()=>this.layer,(e,t)=>{t&&(this._clearSelection(),this._resetGraphics(t)),this.refresh()}),d(()=>[this.highlightsEnabled,this.highlightName],()=>{this._highlightHelper?.removeAll(),this._setUpHighlights()}),d(()=>this.enableMidpoints,()=>this.refresh()),T(this.tooltip,()=>this._tooltipsContext),d(()=>this.view.effectiveTheme.accentColor,()=>this._updateSymbolsForTheme(),m),this._updateHandlesOnExternalGeometryChange]),this._updateTooltip()}destroy(){this._reset(),this._mover?.destroy(),this._mover=null,this._connectedReshapeManager=a(this._connectedReshapeManager),this.tooltip=a(this.tooltip)}get _coordinateHelper(){return this._editGeometryOperations?.data.coordinateHelper??U(!!this.graphic.geometry?.hasZ,!!this.graphic.geometry?.hasM,this.view.spatialReference)}get _selectedVertex(){return 1===this.selectedVertices.length?this.selectedVertices.at(0):void 0}get _tooltipsContext(){const{automaticAreaMeasurementUtils:e,automaticLengthMeasurementUtils:t,sketchOptions:i,activeTooltipInfo:s,graphic:o}=this;return{sketchOptions:i,activeTooltipInfo:s,graphic:o,selectedVertex:this._selectedVertex,automaticAreaMeasurementUtils:e,automaticLengthMeasurementUtils:t,updateGeometry:(e,t,i,s,o)=>{this._setUpGeometryHelper();const r=e===this.graphic;r?this._emitMoveStartEvent(0,0):this._emitReshapeStartEvent(e);const n=!0;if(this._syncGeometryAfterVertexMove(e,t,s,o,n),r){const{view:e}=this,s=e.toScreen(i),o=e.toScreen(t),r=(o?.x??0)-(s?.x??0),n=(o?.y??0)-(s?.y??0);this._emitMoveEvent(r,n),this._emitMoveStopEvent(r,n)}else this._emitReshapeEvent(e),this._emitReshapeStopEvent(e);this._editGeometryOperations=a(this._editGeometryOperations)}}}get state(){const e=this.view.ready,t=!(!this.graphic||!this.layer);return e&&t?"active":e?"ready":"disabled"}isUIGraphic(e){const t=[];return this.graphic&&t.push(this.graphic),t.concat(this.vertexGraphics.items,this.midpointGraphics.items),t.length>0&&t.includes(e)}refresh(){this._reset(),this._setup()}reset(){this.graphic=null}clearSelection(){this._clearSelection()}removeSelectedVertices(){const{selectedVertices:e}=this;e.length&&this._removeVertices(e)}_setup(){const{graphic:e,layer:t}=this;if(!t||null==e?.geometry)return;const i=e.geometry;"mesh"!==i.type&&"extent"!==i.type?("polygon"===i.type&&u(i),this._setUpHighlights(),this._setupGraphics(),this._setupMover(),this._setupConnectedReshapeManager()):this._logGeometryTypeError()}_setUpHighlights(){this.highlightsEnabled&&this.graphic&&this._highlightHelper?.add(this.graphic,this.highlightName)}_setUpGeometryHelper(){const e=this.graphic.geometry;null!=e&&"mesh"!==e.type&&"extent"!==e.type?this._editGeometryOperations=z.fromGeometry(e,2):this._logGeometryTypeError()}_saveSnappingContextForHandle(e,t){this._snappingGraphicsLayer=new G({listMode:"hide",internal:!0,title:"Reshape snapping layer"}),this.view.map.layers.add(this._snappingGraphicsLayer);const i=this._editGeometryOperations;h(i),this._snappingContext=new F({editGeometryOperations:i,elevationInfo:{mode:"on-the-ground",offset:0},pointer:t.viewEvent?.pointerType||"mouse",excludeFeature:this.graphic,feature:this.graphic,visualizer:new b(this._snappingGraphicsLayer),vertexHandle:this._getVertexFromEditGeometry(e)})}_reset(){this._clearSelection(),this._highlightHelper?.removeAll(),this._updateTooltip(),this._resetGraphics(),this._resetSnappingStateVars(),this._activeOperationInfo=null,this._mover?.destroy(),this._mover=null,this.removeHandles(Y)}_resetSnappingStateVars(){null!=this.snappingManager&&this.snappingManager.doneSnapping(),null!=this._snappingGraphicsLayer&&(this.view?.map&&this.view.map.layers.remove(this._snappingGraphicsLayer),this._snappingGraphicsLayer.destroy()),this._editGeometryOperations=a(this._editGeometryOperations),this._snappingTask=p(this._snappingTask),this._snappingTask=null,this._snappingContext=null,this._stagedVertex=null}_resetGraphics(e){this._removeMidpointGraphics(e),this._removeVertexGraphics(e),this.selectedVertices.removeAll(),this._updateTooltip()}_removeMidpointGraphics(e){const t=e||this.layer;t&&t.removeMany(this.midpointGraphics.items),this.midpointGraphics.items.forEach(e=>e.destroy()),this.midpointGraphics.removeAll()}_removeVertexGraphics(e){const t=e||this.layer;t&&t.removeMany(this.vertexGraphics.items),this.vertexGraphics.items.forEach(e=>e.destroy()),this.vertexGraphics.removeAll()}_setupGraphics(){const e=this.graphic.geometry;if(null!=e&&("polyline"===e.type||"polygon"===e.type||"multipoint"===e.type)){const t=K(e);this.enableMidpoints&&"multipoint"!==e.type&&this._setUpMidpointGraphics(t),this.enableVertices&&this._setUpVertexGraphics(t)}}_setUpMidpointGraphics(e){this._removeMidpointGraphics();const t=this._createMidpointGraphics(e);this.midpointGraphics.addMany(t),this.layer.addMany(t)}_setUpVertexGraphics(e){this._removeVertexGraphics();const t=this._createVertexGraphics(e);this.vertexGraphics.addMany(t),this._storeRelatedVertexIndices(),this.layer.addMany(t)}_createVertexGraphics(e){const{_graphicAttributes:i,symbols:s}=this,o=[];return e?.forEach((e,r)=>{e.forEach((e,n)=>{o.push(new t({geometry:this._coordinateHelper.arrayToPoint(e),symbol:s?.vertices?.default,attributes:{...i,pathIndex:r,pointIndex:n}}))})}),o}_createMidpointGraphics(e){const{_graphicAttributes:i,symbols:s}=this,o=[];for(let r=0;r<e.length;r++){const n=e[r];for(let e=0;e<n.length;e++){const a=(e+1)%n.length;if("polyline"===this.graphic.geometry?.type&&0===a)continue;const h=n[e],p=n[a],c=this._getMidpoint(h,p);o.push(new t({geometry:c,symbol:s.midpoints.default,attributes:{...i,pathIndex:r,pointIndexStart:e,pointIndexEnd:a}}))}}return o}_updateSymbolsForTheme(){const e=this.view.effectiveTheme.accentColor;this.symbols={vertices:{...this.symbols.vertices,default:this.symbols.vertices.default.clone().set("color",e),hover:this.symbols.vertices.hover?.clone().set("color",e)},midpoints:{...this.symbols.midpoints}};for(const t of this.vertexGraphics)this._isSelected(t)?t.symbol=this.symbols.vertices.selected:this._hoverGraphic===t?t.symbol=this.symbols.vertices.hover:t.symbol=this.symbols.vertices.default}_storeRelatedVertexIndices(){const e=this.vertexGraphics.items;if(!e)return;const t=e.map(({geometry:e})=>({x:e.x,y:e.y}));for(let i=0;i<t.length;i++){const s=[];for(let e=0;e<t.length;e++){if(i===e)continue;const o=t[i],r=t[e];o.x===r.x&&o.y===r.y&&s.push(e)}e[i].attributes.relatedGraphicIndices=s}}_setupMover(){const{enableMovement:e,graphic:t,midpointGraphics:i,vertexGraphics:s,view:o}=this,r=s.concat(i).items;e&&"multipoint"!==t.geometry?.type&&r.push(t),this._mover=new E({enableMoveAllGraphics:!1,highlightsEnabled:!1,indicatorsEnabled:!1,graphics:r,view:o,callbacks:{onGraphicClick:e=>this._onGraphicClickCallback(e),onGraphicMoveStart:e=>this._onGraphicMoveStartCallback(e),onGraphicMove:e=>this._onGraphicMoveCallback(e),onGraphicMoveStop:e=>this._onGraphicMoveStopCallback(e),onGraphicPointerOver:e=>this._onGraphicPointerOverCallback(e),onGraphicPointerOut:e=>this._onGraphicPointerOutCallback(e)}})}_setupConnectedReshapeManager(){const{connectedReshapeProviders:e}=this;0!==e.length&&(this._connectedReshapeManager=new V({providerFactories:e,view:this.view}))}_onGraphicClickCallback(e){e.viewEvent.stopPropagation();const t=e.graphic;if(t===this.graphic)this.clearSelection(),this.emit("graphic-click",e),this.callbacks.onGraphicClick?.(e);else if(this._isMidpoint(t)){if(2===e.viewEvent.button)return;const i=this.graphic.clone(),s=this._createVertexFromMidpoint(t);this.refresh(),this._emitVertexAddEvent([t],i,s)}else if(this._isVertex(t))if(e.viewEvent.stopPropagation(),2===e.viewEvent.button)this._removeVertices(t);else{e.viewEvent.native.shiftKey||this._clearSelection(),this.selectedVertices.includes(t)?this._removeFromSelection(t,!0):this._addToSelection(t)}}_setUpOperation(e){const{graphic:t,dx:i,dy:s}=e,o=t===this.graphic;this._resetSnappingStateVars(),this._setUpGeometryHelper(),this._saveSnappingContextForHandle(t,e),this._activeOperationInfo={target:this.graphic,mover:t,operationType:o?"move":"reshape",totalDx:i,totalDy:s}}_onGraphicMoveStartCallback(e){const{dx:t,dy:i,graphic:s}=e,o=this._connectedReshapeManager,r=o?Q(this.graphic):null;if(s===this.graphic){const{geometry:n}=s;return this._setUpOperation(e),this._emitMoveStartEvent(t,i),r&&o?.startFeatureMove([r]),void(null!=n&&"point"===n.type&&this._onHandleMove(s,t,i,e,()=>{this._updateTooltip(this.graphic,e.viewEvent),this._emitMoveEvent(t,i)}))}const{selectedVertices:n}=this;if(!n.includes(s)){if(this._clearSelection(),this._isMidpoint(s)){const e=this.graphic.clone(),t=this._createVertexFromMidpoint(s);this._emitVertexAddEvent([s],e,t)}this._addToSelection(s)}this._setUpOperation(e),r&&o?.startVertexMove(r,W(n)),this._emitReshapeStartEvent(s),this._onHandleMove(s,t,i,e,()=>{this._updateTooltip(s,e.viewEvent),this._emitReshapeEvent(s)})}_onGraphicMoveCallback(e){const t=this._activeOperationInfo;if(!t)return;const{dx:i,dy:s,graphic:o}=e;t.totalDx+=i,t.totalDy+=s;const{operationType:r}=t,{geometry:n}=o;if(null!=n)if("move"!==r)this._onHandleMove(o,i,s,e,()=>{this._updateTooltip(o,e.viewEvent),this._emitReshapeEvent(o)});else if("point"===n.type)this._onHandleMove(o,i,s,e,()=>{this._updateTooltip(this.graphic,e.viewEvent),this._emitMoveEvent(i,s)});else if("polyline"===n.type||"polygon"===n.type){const t=K(n);this._updateVertexGraphicLocations(t);const{dxMap:o,dyMap:r}=S(i,s,this.view);this._connectedReshapeManager?.translate(o,r,0),this._updateTooltip(this.graphic,e.viewEvent),this._emitMoveEvent(i,s)}}_onGraphicMoveStopCallback(e){const t=this._activeOperationInfo;if(!t)return;const{dx:i,dy:s,graphic:o}=e,{operationType:r}=t;t.totalDx+=i,t.totalDy+=s,this._onHandleMove(o,i,s,e,()=>"move"===r?this._emitMoveStopEvent():this._emitReshapeStopEvent(o)),this._isMidpoint(o)?this.refresh():(this._updateTooltip(this._isVertex(o)?o:null),this._resetSnappingStateVars(),this._connectedReshapeManager?.finish(),this._activeOperationInfo=null)}_updateVertexGraphicLocations(e){const{_coordinateHelper:t}=this;for(const i of this.vertexGraphics){const{pathIndex:s,pointIndex:o}=i.attributes;i.geometry=t.arrayToPoint(e[s][o])}this._updateMidpointGraphicLocations(e)}_updateMidpointGraphicLocations(e){for(const t of this.midpointGraphics){const{pathIndex:i,pointIndexStart:s,pointIndexEnd:o}=t.attributes,r=e[i];t.geometry=this._getMidpoint(r[s],r[o])}}_getMidpoint(e,t){const{_coordinateHelper:i}=this,s=i.arrayToVector(e),o=i.arrayToVector(t),r=i.toXYZ(s),n=i.toXYZ(o),[a,h,p]=f(r,n),c=i.hasM()?0:void 0;return new g({x:a,y:h,z:p,m:c,spatialReference:i.spatialReference})}_getVertexFromEditGeometry(e){const[t,i]=B(e);return h(this._editGeometryOperations),this._editGeometryOperations.data.parts[t].vertices[i]}_onHandleMove(e,t,s,o,r){p(this._snappingTask);const n=this._snappingContext;if(!n)return;const a=e.geometry,h="graphic-move-stop"===o.type;if(null!=this.snappingManager&&this.selectedVertices.length<2&&!h){const o=this.snappingManager;this._stagedVertex=o.update({point:a,context:n}),this._syncGeometryAfterVertexMove(e,new g(this._stagedVertex),t,s,h),r(),this._snappingTask=i(async i=>{const p=await o.snap({point:a,context:n,signal:i});p.valid&&(this._stagedVertex=p.apply(),this._syncGeometryAfterVertexMove(e,new g(this._stagedVertex),t,s,h),r())})}else{const i=null!=this._stagedVertex?new g(this._stagedVertex):a;this._syncGeometryAfterVertexMove(e,i,t,s,h),r()}}_syncGeometryAfterVertexMove(e,t,i,s,o=!1){const r=this._editGeometryOperations?.data.geometry;if(r)if("point"===r.type)e.geometry=t;else if("mesh"===r.type)e.geometry=r.centerAt(t);else{const{_coordinateHelper:n}=this,[a,h]=B(e);let p=x(r);const c=p[a].length-1,l=n.pointToArray(t);if(p[a][h]=l,"polygon"===r.type&&(0===h?p[a][c]=l:h===c&&(p[a][0]=l)),this._isVertex(e)&&(p=this._moveRelatedCoordinates(p,e,l),p=this._moveSelectedHandleCoordinates(p,e,i,s,"polygon"===r.type),this._updateMidpointGraphicLocations(p)),"multipoint"===r.type&&r.points)for(let e=0;e<p.length;e++)r.points[e]=p[e][0];this._updateGraphicGeometry(r.clone());const d=n.pointToVector(t),m=this._getVertexFromEditGeometry(e),v=n.getZ(d),y=d[0]-m.pos[0],_=d[1]-m.pos[1],g=null!=v?v-m.pos[2]:0;this._editGeometryOperations?.moveVertices([m],y,_,g),this._connectedReshapeManager?.translate(y,_,g),o&&(this._mover?this._mover.updateGeometry(this._mover.graphics.indexOf(e),t):e.geometry=t)}}_moveRelatedCoordinates(e,t,i){const{relatedGraphicIndices:s}=t.attributes;for(const o of s){const s=this.vertexGraphics.at(o),{pathIndex:r,pointIndex:n}=s.attributes;e[r][n]=i,s.geometry=t.geometry}return e}_moveSelectedHandleCoordinates(e,t,i,s,o){for(const r of this.selectedVertices)if(r!==t){const{pathIndex:t,pointIndex:n,relatedGraphicIndices:a}=r.attributes,h=w(r.geometry,i,s,this.view),p=x(h),c=e[t].length-1;e[t][n]=p,r.geometry=h,o&&(0===n?e[t][c]=p:n===c&&(e[t][0]=p));for(const i of a){const t=this.vertexGraphics.at(i),{pathIndex:s,pointIndex:o}=t.attributes;e[s][o]=p,t.geometry=h}}return e}_onGraphicPointerOverCallback(e){const t=e.graphic;this._hoverGraphic=t;const i=this._isVertex(t);i&&!this._isSelected(t)&&(t.symbol=this.symbols.vertices.hover),this._updateTooltip(i?t:null),this._updateHoverCursor(t)}_onGraphicPointerOutCallback(e){const t=e.graphic;this._hoverGraphic=null,this._isVertex(t)&&!this._isSelected(t)&&(t.symbol=this.symbols.vertices.default),this.removeHandles(Y),this._updateTooltip()}_createVertexFromMidpoint(e){const{_graphicAttributes:t,graphic:i}=this,s=i.geometry;if(null==s||"polygon"!==s.type&&"polyline"!==s.type)return[];const o=s.clone(),r=[],{pathIndex:n,pointIndexStart:a,pointIndexEnd:h}=e.attributes,p=x(e.geometry),c=0===h?a+1:h,l=x(o);return l[n].splice(c,0,p),e.attributes={...t,pathIndex:n,pointIndex:c,relatedGraphicIndices:[]},r.push({coordinates:l[n][c],componentIndex:n,vertexIndex:c}),this._updateGraphicGeometry(o),r}_addToSelection(e){const t=J(e);for(const i of t)i.symbol=this.symbols.vertices.selected,this.selectedVertices.add(i),this._updateTooltip(i);this._emitSelectEvent(t)}_removeFromSelection(e,t){const{vertices:i}=this.symbols,s=t?i.hover:i.default;this.selectedVertices.remove(e),e.symbol=s,this._emitDeselectEvent([e]),this._updateTooltip()}_clearSelection(){const e=this.selectedVertices.toArray();if(e.length>0){for(const t of e)t.set("symbol",this.symbols.vertices.default);this.selectedVertices.removeAll(),this._emitDeselectEvent(e),this._updateTooltip()}}_keyDownHandler(e){null==this._activeOperationInfo&&N(e,this.tooltip)||L.delete.includes(e.key)&&!e.repeat&&this.selectedVertices.length&&this._removeVertices(this.selectedVertices)}_removeVertices(e){const t=this.graphic.geometry,i=this.vertexGraphics.length;if(null==t||"polygon"!==t.type&&"polyline"!==t.type&&"multipoint"!==t.type)return;if("polygon"===t.type&&i<4||"multipoint"===t.type&&i<2||"polyline"===t.type&&i<3)return;const s=this.graphic.clone(),o=t.clone();let r=x(o);const n=[],a=J(e);for(const h of a){const{x:e,y:t}=h.geometry;for(let i=0;i<r.length;i++){const s=r[i];for(let o=0;o<s.length;o++){const[a,h]=s[o];e===a&&t===h&&(n.push({coordinates:r[i][o],componentIndex:i,vertexIndex:o}),r[i].splice(Number(o),1))}}}if("polygon"===o.type)r=r.filter(e=>{if(e.length<2)return!1;const[t,i]=e[0],[s,o]=e[e.length-1];return(2!==e.length||t!==s||i!==o)&&(t===s&&i===o||e.push(e[0]),!0)}),o.rings=r;else if("polyline"===o.type){for(const e of r)1===e.length&&r.splice(r.indexOf(e),1);o.paths=r}else o.points=r.flat();this._updateGraphicGeometry(o),this.refresh(),this._emitVertexRemoveEvent(a,s,n)}_isVertex(e){return this.vertexGraphics.includes(e)}_isSelected(e){return this._isVertex(e)&&this.selectedVertices.includes(e)}_isMidpoint(e){return this.midpointGraphics.includes(e)}_updateHoverCursor(e){const t=this._isMidpoint(e)?"copy":"move";this.addHandles(this.view.acquireCursor(t,"high"),Y)}_updateTooltip(e,t){let i=null;const{graphic:s,view:o,tooltipInfos:r}=this,n=s?.geometry;"point"===n?.type?i=r.movePoint:this._selectedVertex?i=r.selectedVertex:e===this.graphic?(i=r.translateGraphic,H(i,o,this._tooltipsContext,t)):e&&this.selectedVertices.length>1&&(i=r.translateVertices,R(i,o,n,this._tooltipsContext,t)),this.activeTooltipInfo=i}_updateGraphicGeometry(e){this._updateHandlesOnExternalGeometryChange?.pause(),this.graphic.geometry=e,this._updateHandlesOnExternalGeometryChange?.resume()}_emitMoveStartEvent(e,t){const i={type:"move-start",mover:this.graphic,dx:e,dy:t};this.emit("move-start",i),this.callbacks.onMoveStart?.(i)}_emitMoveEvent(e,t){const i={type:"move",mover:this.graphic,dx:e,dy:t};this.emit("move",i),this.callbacks.onMove?.(i)}_emitMoveStopEvent(e,t){if(null==e||null==t){const i=this._activeOperationInfo;if(!i)return;e=i.totalDx,t=i.totalDy}const i={type:"move-stop",mover:this.graphic,dx:e,dy:t};this.emit("move-stop",i),this.callbacks.onMoveStop?.(i)}_emitReshapeStartEvent(e){const t={type:"reshape-start",graphic:this.graphic,mover:e,selected:this.selectedVertices.toArray()};this.emit("reshape-start",t),this.callbacks.onReshapeStart?.(t)}_emitReshapeEvent(e){const t={type:"reshape",graphic:this.graphic,mover:e,selected:this.selectedVertices.toArray()};this.emit("reshape",t),this.callbacks.onReshape?.(t)}_emitReshapeStopEvent(e){const t={type:"reshape-stop",graphic:this.graphic,mover:e,selected:this.selectedVertices.toArray()};this.emit("reshape-stop",t),this.callbacks.onReshapeStop?.(t)}_emitSelectEvent(e){const t={type:"vertex-select",added:e};this.emit("select",t),this.callbacks.onVertexSelect?.(t)}_emitDeselectEvent(e){const t={type:"vertex-deselect",removed:e};this.emit("deselect",t),this.callbacks.onVertexDeselect?.(t)}_emitVertexAddEvent(e,t,i){const s={type:"vertex-add",added:e,graphic:this.graphic,oldGraphic:t,vertices:i};this.emit("vertex-add",s),this.callbacks.onVertexAdd?.(s)}_emitVertexRemoveEvent(e,t,i){const s={type:"vertex-remove",removed:e,graphic:this.graphic,oldGraphic:t,vertices:i};this.emit("vertex-remove",s),this.callbacks.onVertexRemove?.(s)}_logGeometryTypeError(){n.getLogger(this).error(new o("reshape:invalid-geometry","Reshape operation not supported for the provided graphic. The geometry type is not supported."))}};function K(e){const t=x(e.clone());if("polygon"===e.type)for(const i of t){const e=i[i.length-1];i[0][0]===e[0]&&i[0][1]===e[1]&&i.length>2&&i.pop()}return t}function B({attributes:e}){return[e?.pathIndex||0,e?.pointIndex||0]}function J(e){return e instanceof t?[e]:[...e]}function Q(e){const t=e.sourceLayer??e.layer;return C(t)?{graphic:e,layer:t}:null}function W(e){return e.toArray().map(e=>({pathIndex:e.attributes.pathIndex,vertexIndex:e.attributes.pointIndex}))}e([y()],q.prototype,"_activeOperationInfo",void 0),e([y()],q.prototype,"_connectedReshapeManager",void 0),e([y()],q.prototype,"_coordinateHelper",null),e([y()],q.prototype,"_editGeometryOperations",void 0),e([y()],q.prototype,"tooltip",void 0),e([y()],q.prototype,"tooltipInfos",void 0),e([y()],q.prototype,"activeTooltipInfo",void 0),e([y({constructOnly:!0})],q.prototype,"automaticAreaMeasurementUtils",void 0),e([y({constructOnly:!0})],q.prototype,"automaticLengthMeasurementUtils",void 0),e([y()],q.prototype,"_selectedVertex",null),e([y()],q.prototype,"_tooltipsContext",null),e([y()],q.prototype,"callbacks",void 0),e([y()],q.prototype,"connectedReshapeProviders",void 0),e([y()],q.prototype,"enableMidpoints",void 0),e([y()],q.prototype,"enableMovement",void 0),e([y()],q.prototype,"enableVertices",void 0),e([y()],q.prototype,"graphic",void 0),e([y()],q.prototype,"highlightName",void 0),e([y()],q.prototype,"highlightsEnabled",void 0),e([y()],q.prototype,"layer",void 0),e([y({readOnly:!0})],q.prototype,"midpointGraphics",void 0),e([y()],q.prototype,"midpointSymbol",void 0),e([y({readOnly:!0})],q.prototype,"selectedVertices",void 0),e([y()],q.prototype,"snappingManager",void 0),e([y({readOnly:!0})],q.prototype,"state",null),e([y()],q.prototype,"symbols",void 0),e([y({type:D})],q.prototype,"sketchOptions",void 0),e([y({readOnly:!0})],q.prototype,"type",void 0),e([y({readOnly:!0})],q.prototype,"vertexGraphics",void 0),e([y()],q.prototype,"view",void 0),q=e([_("esri.views.draw.support.Reshape")],q);const $=q;export{$ as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.34/esri/copyright.txt for details.
4
4
  */
5
- import{rad2deg as t}from"../../../core/mathUtils.js";import{create as n}from"../../../geometry/support/aaBoundingRect.js";import{getRingsOrPathsBounds as e}from"../../../geometry/support/boundsUtils.js";import{geometryToCoordinates as o}from"../../../geometry/support/coordsUtils.js";function s(t,n,e,s){if(null==s||t.hasZ||(s=void 0),"point"===t.type)return t.x+=n,t.y+=e,t.hasZ&&null!=s&&(t.z+=s),t;if("multipoint"===t.type){const o=t.points;for(let t=0;t<o.length;t++)o[t]=l(o[t],n,e,s);return t}if("extent"===t.type)return t.xmin+=n,t.xmax+=n,t.ymin+=e,t.ymax+=e,null!=s&&(t.zmin??=0,t.zmin+=s,t.zmax??=0,t.zmax+=s),t;const i=o(t),r="polyline"===t.type?t.paths:t.rings;for(let o=0;o<i.length;o++){const t=i[o];for(let o=0;o<t.length;o++)t[o]=l(t[o],n,e,s)}return"paths"in t?t.paths=r:t.rings=r,t}function i(t,n,e,i,r){const a=t.clone(),m=i.resolution;if("point"===a.type){if(r)s(a,n*m,-e*m);else{const t=i.state.transform,o=i.state.inverseTransform,s=t[0]*a.x+t[2]*a.y+t[4],r=t[1]*a.x+t[3]*a.y+t[5];a.x=o[0]*(s+n)+o[2]*(r+e)+o[4],a.y=o[1]*(s+n)+o[3]*(r+e)+o[5]}return a}if("multipoint"===a.type){if(r)s(a,n*m,-e*m);else{const t=a.points,o=i.state.transform,s=i.state.inverseTransform;for(let i=0;i<t.length;i++){const r=t[i],a=o[0]*r[0]+o[2]*r[1]+o[4],m=o[1]*r[0]+o[3]*r[1]+o[5],l=s[0]*(a+n)+s[2]*(m+e)+s[4],p=s[1]*(a+n)+s[3]*(m+e)+s[5];t[i]=x(r,l,p,void 0)}}return a}if("extent"===a.type){if(r)s(a,n*m,-e*m);else{const t=i.state.transform,o=i.state.inverseTransform,s=t[0]*a.xmin+t[2]*a.ymin+t[4],r=t[1]*a.xmin+t[3]*a.ymin+t[5],m=t[0]*a.xmax+t[2]*a.ymax+t[4],l=t[1]*a.xmax+t[3]*a.ymax+t[5];a.xmin=o[0]*(s+n)+o[2]*(r+e)+o[4],a.ymin=o[1]*(s+n)+o[3]*(r+e)+o[5],a.xmax=o[0]*(m+n)+o[2]*(l+e)+o[4],a.ymax=o[1]*(m+n)+o[3]*(l+e)+o[5]}return a}if(r)s(a,n*m,-e*m);else{const t=o(a),s="polyline"===a.type?a.paths:a.rings,r=i.state.transform,m=i.state.inverseTransform;for(let o=0;o<t.length;o++){const s=t[o];for(let t=0;t<s.length;t++){const o=s[t],i=r[0]*o[0]+r[2]*o[1]+r[4],a=r[1]*o[0]+r[3]*o[1]+r[5],l=m[0]*(i+n)+m[2]*(a+e)+m[4],p=m[1]*(i+n)+m[3]*(a+e)+m[5];s[t]=x(o,l,p,void 0)}}"paths"in a?a.paths=s:a.rings=s}return a}function r(t,s,i,r){if("point"===t.type){const{x:n,y:e}=t,o=r?r[0]:n,a=r?r[1]:e,m=t.clone(),l=(n-o)*s+o,x=(e-a)*i+a;return m.x=l,m.y=x,m}if("extent"===t.type){const{xmin:n,xmax:e,ymin:o,ymax:a}=t,m=r?r[0]:(n+e)/2,l=r?r[1]:(a+o)/2,x=t.clone();if(x.xmin=(n-m)*s+m,x.ymax=(a-l)*i+l,x.xmax=(e-m)*s+m,x.ymin=(o-l)*i+l,x.xmin>x.xmax){const t=x.xmin,n=x.xmax;x.xmin=n,x.xmax=t}if(x.ymin>x.ymax){const t=x.ymin,n=x.ymax;x.ymin=n,x.ymax=t}return x}let a=null;if(!r){a=o(t);const s=n(),[i,m,l,x]=e(s,a);r=[(i+l)/2,(m+x)/2]}const[m,l]=r;if("multipoint"===t.type){const n=t.clone(),e=n.points;for(let t=0;t<e.length;t++){const n=e[t],[o,r]=n,a=(o-m)*s+m,p=(r-l)*i+l;e[t]=x(n,a,p,void 0)}return n.points=e,n}const p=t.clone(),y="polyline"===p.type?p.paths:p.rings;a??=o(t);for(let n=0;n<a.length;n++){const t=a[n];for(let e=0;e<t.length;e++){const o=t[e],[r,a]=o,p=(r-m)*s+m,f=(a-l)*i+l;y[n][e]=x(o,p,f,void 0)}}return"paths"in p?p.paths=y:p.rings=y,p}function a(t,n,e,o,s,i){const r=Math.sqrt((e-t)*(e-t)+(o-n)*(o-n));return Math.sqrt((s-t)*(s-t)+(i-n)*(i-n))/r}function m(n,e,o,s=!1){const i=Math.atan2(e.y-o.y,e.x-o.x)-Math.atan2(n.y-o.y,n.x-o.x),r=Math.atan2(Math.sin(i),Math.cos(i));return s?r:t(r)}function l(t,n,e,o){return x(t,t[0]+n,t[1]+e,null!=t[2]&&null!=o?t[2]+o:void 0)}function x(t,n,e,o){const s=[n,e];return t.length>2&&s.push(null!=o?o:t[2]),t.length>3&&s.push(t[3]),s}export{i as cloneMove,m as getRotationAngle,a as getScaleRatio,s as move,r as scale};
5
+ import{rad2deg as t}from"../../../core/mathUtils.js";import{create as n,center as r}from"../../../geometry/support/aaBoundingRect.js";import{getRingsOrPathsBounds as o}from"../../../geometry/support/boundsUtils.js";import{geometryToCoordinates as e}from"../../../geometry/support/coordsUtils.js";import{toEllipticArc7 as i}from"../../../geometry/support/curves/circularArcUtils.js";import{isCurvedGeometry as s,isCoordinate as c,isBezierCurve as u,getEndpoint as m,isCircularArc as a}from"../../../geometry/support/curves/curveUtils.js";import{transformEllipticArc as l}from"../../../geometry/support/curves/ellipticArc7Utils.js";import{getScaleTransform as p}from"../../interactive/editGeometry/operations/curveOperationUtils.js";function f(t,n,r,o){if(null==o||t.hasZ||(o=void 0),"point"===t.type)return t.x+=n,t.y+=r,t.hasZ&&null!=o&&(t.z+=o),t;if("multipoint"===t.type){const e=t.points;for(let t=0;t<e.length;t++)e[t]=h(e[t],n,r,o);return t}if("extent"===t.type)return t.xmin+=n,t.xmax+=n,t.ymin+=r,t.ymax+=r,null!=o&&(t.zmin??=0,t.zmin+=o,t.zmax??=0,t.zmax+=o),t;const e="polyline"===t.type?t.curvePaths??t.paths:t.curveRings??t.rings,i=s(t);for(let s=0;s<e.length;s++){const t=e[s];for(let e=0;e<t.length;e++)t[e]=g(t[e],n,r,o)}return"paths"in t?i?t.curvePaths=e:t.paths=e:i?t.curveRings=e:t.rings=e,t}function y(t,n,r,o,e){const i=t.clone();if(e){const{resolution:t}=o;f(i,n*t,-r*t)}else{const{dxMap:t,dyMap:e}=x(n,r,o);f(i,t,e)}return i}function x(t,n,r){const o=r.state.inverseTransform;return{dxMap:o[0]*t+o[2]*n,dyMap:o[1]*t+o[3]*n}}function h(t,n,r,o){return b(t,t[0]+n,t[1]+r,null!=t[2]&&null!=o?t[2]+o:void 0)}function g(t,n,r,o){const e=h(m(t),n,r,o);if(c(t))return e;if(u(t)){const[,o,i]=t.b;return{b:[e,[o[0]+n,o[1]+r],[i[0]+n,i[1]+r]]}}if(a(t)){const[,o]=t.c;return{c:[e,[o[0]+n,o[1]+r]]}}const[,i,...s]=t.a;return{a:[e,[i[0]+n,i[1]+r],...s]}}function v(t,i,s,c){if("point"===t.type){const{x:n,y:r}=t,o=c?c[0]:n,e=c?c[1]:r,u=t.clone(),m=(n-o)*i+o,a=(r-e)*s+e;return u.x=m,u.y=a,u}if("extent"===t.type){const{xmin:n,xmax:r,ymin:o,ymax:e}=t,u=c?c[0]:(n+r)/2,m=c?c[1]:(e+o)/2,a=t.clone();if(a.xmin=(n-u)*i+u,a.ymax=(e-m)*s+m,a.xmax=(r-u)*i+u,a.ymin=(o-m)*s+m,a.xmin>a.xmax){const t=a.xmin,n=a.xmax;a.xmin=n,a.xmax=t}if(a.ymin>a.ymax){const t=a.ymin,n=a.ymax;a.ymin=n,a.ymax=t}return a}let u=null;if(!c){u=e(t);const r=n(),i=o(r,u);if(!i)return t.clone();const[s,m,a,l]=i;c=[(s+a)/2,(m+l)/2]}const[m,a]=c;if("multipoint"===t.type){const n=t.clone(),r=n.points;for(let t=0;t<r.length;t++){const n=r[t],[o,e]=n,c=(o-m)*i+m,u=(e-a)*s+a;r[t]=b(n,c,u,void 0)}return n.points=r,n}const l=t.clone();u??=e(t);const p="polygon"===l.type?l.curveRings??l.rings:l.curvePaths??l.paths;if(!c){const t=n(),e=o(t,p,!1,!1);if(!e)return l;c=r(e)}for(const n of p){let t=null;for(let r=0;r<n.length;r++){const o=n[r];n[r]=d(o,i,s,m,a,t),t=o}}return l}function M(t,n,r,o,e){const[i,s,...c]=t;return[(i-o)*n+o,(s-e)*r+e,...c]}function d(t,n,r,o,e,s){if(c(t))return M(t,n,r,o,e);if(u(t)){const[i,s,c]=t.b.map(t=>M(t,n,r,o,e));return{b:[i,s,c]}}if(!s)return t;const f=m(s),y=a(t)?i(f,t):t,[x,h,g,v,d,j,U]=y.a,b=d??0,z=j??Math.hypot(x[0]-h[0],x[1]-h[1]),R=U??1,P=p(o,e,1,0,0,1,n,r);return l(f,{a:[[...x],[...h],g,v,b,z,R]},P)}function j(t,n,r,o,e,i){const s=Math.sqrt((r-t)*(r-t)+(o-n)*(o-n));return Math.sqrt((e-t)*(e-t)+(i-n)*(i-n))/s}function U(n,r,o,e=!1){const i=Math.atan2(r.y-o.y,r.x-o.x)-Math.atan2(n.y-o.y,n.x-o.x),s=Math.atan2(Math.sin(i),Math.cos(i));return e?s:t(s)}function b(t,n,r,o){const e=[n,r];return t.length>2&&e.push(null!=o?o:t[2]),t.length>3&&e.push(t[3]),e}export{y as cloneMove,U as getRotationAngle,j as getScaleRatio,f as move,v as scale,x as screenDeltaToMapDelta};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.34/esri/copyright.txt for details.
4
4
  */
5
- import{equals as t}from"../../../../core/arrayUtils.js";import{rotate as i}from"../../../../core/libs/gl-matrix-2/math/vec2.js";import{rotateArc as e}from"./curveOperationUtils.js";class o{constructor(t,i,e=0){this.origin=t,this.angle=i,this._accumulationType=e}_rotate(t,e){i(t.pos,t.pos,this.origin,e),n(t.leftSegment,this.origin,e)}apply(t){this._rotate(t,this.angle)}undo(t){this._rotate(t,-this.angle)}canAccumulate(i){return i instanceof o&&t(this.origin,i.origin)}accumulate(t,i){const e=1===i._accumulationType;this._rotate(t,e?i.angle-this.angle:i.angle)}accumulateParams(t){const i=1===t._accumulationType;this.angle=i?t.angle:this.angle+t.angle}}function n(t,o,n){switch(t?.type){case null:case void 0:case"line":return;case"bezier":{const{controlPoint1:e,controlPoint2:r}=t.curveDefinition;return i(e,e,o,n),void i(r,r,o,n)}case"circular-arc":{const{interiorPoint:e}=t.curveDefinition;return void i(e,e,o,n)}case"elliptic-arc-4":case"elliptic-arc-7":{const r=t.leftVertex.pos,a=i([0,0],[r[0],r[1]],o,-n),c=t.toCurveOrCoordinate(),[,s,l,u,p,g,m]=e(a,c,o,n).a;if("elliptic-arc-4"===t.type){const i=t.curveDefinition;i.centerPoint=[...s],i.sweep=l,i.orientation=u}else{const i=t.curveDefinition;i.centerPoint=[...s],i.sweep=l,i.orientation=u,i.rotation=p,i.semiMajorAxisLength=g,i.minorMajorAxisRatio=m}}}}export{o as RotateVertex};
5
+ import{equals as t}from"../../../../core/arrayUtils.js";import{rotate as e}from"../../../../core/libs/gl-matrix-2/math/vec2.js";import{rotateEllipticArc as i}from"../../../../geometry/support/curves/rotate.js";class o{constructor(t,e,i=0){this.origin=t,this.angle=e,this._accumulationType=i}_rotate(t,i){e(t.pos,t.pos,this.origin,i),n(t.leftSegment,this.origin,i)}apply(t){this._rotate(t,this.angle)}undo(t){this._rotate(t,-this.angle)}canAccumulate(e){return e instanceof o&&t(this.origin,e.origin)}accumulate(t,e){const i=1===e._accumulationType;this._rotate(t,i?e.angle-this.angle:e.angle)}accumulateParams(t){const e=1===t._accumulationType;this.angle=e?t.angle:this.angle+t.angle}}function n(t,o,n){switch(t?.type){case null:case void 0:case"line":return;case"bezier":{const{controlPoint1:i,controlPoint2:r}=t.curveDefinition;return e(i,i,o,n),void e(r,r,o,n)}case"circular-arc":{const{interiorPoint:i}=t.curveDefinition;return void e(i,i,o,n)}case"elliptic-arc-4":case"elliptic-arc-7":{const r=t.leftVertex.pos,a=e([0,0],[r[0],r[1]],o,-n),c=t.toCurveOrCoordinate(),[,s,l,u,p,g,m]=i(a,c,o,n).a;if("elliptic-arc-4"===t.type){const e=t.curveDefinition;e.centerPoint=[...s],e.sweep=l,e.orientation=u}else{const e=t.curveDefinition;e.centerPoint=[...s],e.sweep=l,e.orientation=u,e.rotation=p,e.semiMajorAxisLength=g,e.minorMajorAxisRatio=m}}}}export{o as RotateVertex};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.34/esri/copyright.txt for details.
4
4
  */
5
- import{fromValues as t,create as r}from"../../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{mul as o}from"../../../../core/libs/gl-matrix-2/math/mat3.js";import{deriveCircleFromCircularArc as a}from"../../../../geometry/support/curves/circularArcUtils.js";import{isCircularArc as e}from"../../../../geometry/support/curves/curveUtils.js";import{transformEllipticArc as s}from"../../../../geometry/support/curves/ellipticArc7Utils.js";function c(t,r){const[o]=r.c,e=a(t,r);return{a:[o,[e.cx,e.cy],Math.abs(e.thetaEnd-e.thetaStart)<Math.PI?1:0,e.thetaStart>e.thetaEnd?1:0,0,e.radius,1]}}function i(r,o,a,i){const n=e(o)?c(r,o):o,[m,u,p,h,f,l,y]=n.a,M=f??0,g=l??Math.hypot(m[0]-u[0],m[1]-u[1]),j=y??1,x=Math.cos(i),v=Math.sin(i),[b,d]=a,U=t(x,v,0,-v,x,0,b-x*b+v*d,d-v*b-x*d,1);return s(r,{a:[m,u,p,h,M,g,j]},U)}function n(t,r,o,a,i,n,u,p){const h=r??o.leftVertex.pos,f=e(t)?c(h,t):t,[l,y,M,g,j,x,v]=f.a,b=j??0,d=x??Math.hypot(l[0]-y[0],l[1]-y[1]),U=v??1,A=m(a[0],a[1],i[0],i[1],n[0],n[1],u,p);return s(h,{a:[l,y,M,g,b,d,U]},A)}function m(a,e,s,c,i,n,m,u){const p=t(1,0,0,0,1,0,-a,-e,1),h=m-1,f=t(s*s*h+1,c*s*h,0,s*c*h,c*c*h+1,0,0,0,1),l=u-1,y=t(i*i*l+1,n*i*l,0,i*n*l,n*n*l+1,0,0,0,1),M=t(1,0,0,0,1,0,a,e,1),g=r();return o(g,f,p),o(g,y,g),o(g,M,g),g}export{m as getScaleTransform,i as rotateArc,n as scaleArc,c as toEllipticArc7};
5
+ import{fromValues as r,create as t}from"../../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{mul as o}from"../../../../core/libs/gl-matrix-2/math/mat3.js";import{toEllipticArc7 as e}from"../../../../geometry/support/curves/circularArcUtils.js";import{isCircularArc as s}from"../../../../geometry/support/curves/curveUtils.js";import{transformEllipticArc as i}from"../../../../geometry/support/curves/ellipticArc7Utils.js";function m(r,t,o,m,p,u,l,a){const f=t??o.leftVertex.pos,n=s(r)?e(f,r):r,[g,j,v,x,y,h,U]=n.a,b=y??0,A=h??Math.hypot(g[0]-j[0],g[1]-j[1]),M=U??1,V=c(m[0],m[1],p[0],p[1],u[0],u[1],l,a);return i(f,{a:[g,j,v,x,b,A,M]},V)}function c(e,s,i,m,c,p,u,l){const a=r(1,0,0,0,1,0,-e,-s,1),f=u-1,n=r(i*i*f+1,m*i*f,0,i*m*f,m*m*f+1,0,0,0,1),g=l-1,j=r(c*c*g+1,p*c*g,0,c*p*g,p*p*g+1,0,0,0,1),v=r(1,0,0,0,1,0,e,s,1),x=t();return o(x,n,a),o(x,j,x),o(x,v,x),x}export{c as getScaleTransform,m as scaleArc};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.34/esri/copyright.txt for details.
4
4
  */
5
- import{__decorate as e}from"tslib";import t from"../../core/Error.js";import{throwIfAborted as r}from"../../core/promiseUtils.js";import{property as o}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import"../../core/RandomLCG.js";import{subclass as s}from"../../core/accessorSupport/decorators/subclass.js";import i from"../../geometry/Point.js";import{combineTimeExtent as a}from"../../layers/support/timeSupport.js";import{load as p,getSourceScale as n}from"../../layers/support/rasterFunctions/rasterProjectionHelper.js";import c from"../../rest/support/Query.js";import{getFetchPopupTemplate as m}from"./support/popupUtils.js";const u=u=>{const l=u;let y=class extends l{constructor(...e){super(...e),this.view=null}get timeExtent(){return a(this.layer,this.view?.timeExtent,this._get("timeExtent"))}async fetchPopupFeaturesAtLocation(e,o){const{layer:s}=this;if(!e)throw new t("imagerylayerview:fetchPopupFeatures","Nothing to fetch without area",{layer:s});const{popupEnabled:a}=s,p=m(s,o);if(!a||null==p)return[];const n=await p.getRequiredFields();r(o);const u=new c;u.timeExtent=this.timeExtent,u.geometry=e,u.outFields=n,u.outSpatialReference=e.spatialReference;const{resolution:l,spatialReference:y}=this.view,h="2d"===this.view.type?new i(l,l,y):new i(.5*l,.5*l,y),{returnTopmostRaster:f,showNoDataRecords:w}=p.layerOptions||{returnTopmostRaster:!0,showNoDataRecords:!1},d={returnDomainValues:!0,returnTopmostRaster:f,pixelSize:h,showNoDataRecords:w,signal:o?.signal};return s.queryVisibleRasters(u,d).then(e=>e)}async getSourceScale(){return await p(),await this.layer.load(),n(this.layer.serviceRasterInfo,this.view.spatialReference)}canResume(){return!!super.canResume()&&!this.timeExtent?.isEmpty}};return e([o()],y.prototype,"layer",void 0),e([o()],y.prototype,"suspended",void 0),e([o({readOnly:!0})],y.prototype,"timeExtent",null),e([o()],y.prototype,"view",void 0),y=e([s("esri.views.layers.ImageryLayerView")],y),y};export{u as default};
5
+ import{__decorate as e}from"tslib";import t from"../../core/Error.js";import{throwIfAborted as r}from"../../core/promiseUtils.js";import{property as o}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import"../../core/RandomLCG.js";import{subclass as s}from"../../core/accessorSupport/decorators/subclass.js";import i from"../../geometry/Point.js";import{combineTimeExtent as a}from"../../layers/support/timeSupport.js";import{load as p,getSourceScale as n}from"../../layers/support/rasterFunctions/rasterProjectionHelper.js";import c from"../../rest/support/Query.js";import{getFetchPopupTemplate as m}from"./support/popupUtils.js";const u=u=>{const l=u;let y=class extends l{constructor(...e){super(...e),this.view=null}get timeExtent(){return a(this.layer,this.view?.timeExtent,this._get("timeExtent"))}async fetchPopupFeaturesAtLocation(e,o){const{layer:s}=this;if(!e)throw new t("imagerylayerview:fetchPopupFeatures","Nothing to fetch without area",{layer:s});const{popupEnabled:a}=s,p=m(s,o);if(!a||null==p)return[];const n=await p.getRequiredFields();r(o);const u=new c;u.timeExtent=this.timeExtent,u.geometry=e,u.outFields=n,u.outSpatialReference=e.spatialReference;const{resolution:l,spatialReference:y}=this.view,h="2d"===this.view.type?new i(l,l,y):new i(.5*l,.5*l,y),{returnTopmostRaster:f,showNoDataRecords:w}=p.layerOptions||{returnTopmostRaster:!0,showNoDataRecords:!1},d={returnDomainValues:!0,returnTopmostRaster:f,pixelSize:h,showNoDataRecords:w,signal:o?.signal};return s.queryVisibleRasters(u,d)}async getSourceScale(){return await p(),await this.layer.load(),n(this.layer.serviceRasterInfo,this.view.spatialReference)}canResume(){return!!super.canResume()&&!this.timeExtent?.isEmpty}};return e([o()],y.prototype,"layer",void 0),e([o()],y.prototype,"suspended",void 0),e([o({readOnly:!0})],y.prototype,"timeExtent",null),e([o()],y.prototype,"view",void 0),y=e([s("esri.views.layers.ImageryLayerView")],y),y};export{u as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.34/esri/copyright.txt for details.
4
4
  */
5
- import{__decorate as e}from"tslib";import t from"../../Graphic.js";import r from"../../core/Error.js";import{property as i}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import"../../core/RandomLCG.js";import{subclass as s}from"../../core/accessorSupport/decorators/subclass.js";import{addMultidimensionalFieldValues as a,commonRasterFieldNames as o,rasterFieldPrefix as n}from"../../layers/support/rasterFieldUtils.js";import{combineTimeExtent as l}from"../../layers/support/timeSupport.js";import{isFunctionRaster as u}from"../../layers/support/rasterDatasets/datasetUtils.js";import{getDefaultDatumTransformationForDataset as p,projectDatasetExtent as c,getSourceScale as m}from"../../layers/support/rasterFunctions/rasterProjectionHelper.js";import{getFetchPopupTemplate as y}from"./support/popupUtils.js";const f=f=>{const d=f;let h=class extends d{constructor(...e){super(...e),this.layer=null,this.tileInfo=null}get fullExtent(){try{return this.layer.loaded?this._getFullExtent():null}catch{return null}}get timeExtent(){return l(this.layer,this.view?.timeExtent,this._get("timeExtent"))}get hasTilingEffects(){return!!(this.layer.renderer&&"dynamicRangeAdjustment"in this.layer.renderer&&this.layer.renderer.dynamicRangeAdjustment)}get datumTransformation(){try{return this.layer.loaded?p(this.layer.fullExtent,this.view.spatialReference,!0):null}catch{return null}}supportsSpatialReference(e){try{return!this.layer.loaded||!!c(this.layer.serviceRasterInfo,e)}catch{return!1}}async fetchPopupFeaturesAtLocation(e,i){const{layer:s}=this;if(!e)throw new r("imageryTileLayerView:fetchPopupFeatures","Nothing to fetch without area",{layer:s});const{popupEnabled:l}=s,p=y(s,i);if(!l||null==p)return[];const c=[],{value:m,magdirValue:f,processedValue:d}=await s.identify(e,{timeExtent:this.timeExtent,signal:i?.signal});let h="";if(m?.length){h="imagery-tile"===s.type&&s.hasStandardTime()&&null!=m[0]?m.map(e=>s.getStandardTimeValue(e)).join(", "):m.join(", ");const e={ObjectId:0};e[o.servicePixelValue]="imagery-tile"===s.type&&u(s.raster)?d?.join(", "):h,e[o.rawServicePixelValue]=h;const r=s.raster?.rasterInfo??s.serviceRasterInfo,i=r?.attributeTable;if(null!=i){const{fields:t,features:r}=i,s=t.find(({name:e})=>"value"===e.toLowerCase()),a=e[o.servicePixelValue],l=s?r.find(e=>String(e.attributes[s.name])===a):null;if(l)for(const i in l.attributes)if(l.attributes.hasOwnProperty(i)){e[n+i]=l.attributes[i]}}const l=r?.dataType;"vector-magdir"!==l&&"vector-uv"!==l||(e[o.magnitude]=f?.[0],e[o.direction]=f?.[1]);const{multidimensionalDefinition:p}=this.layer.normalizeRasterFetchOptions({timeExtent:this.timeExtent});a(s.rasterFields,e,p);const y=new t({geometry:this.fullExtent?.clone(),attributes:e,layer:s,sourceLayer:s});c.push(y)}return c}async getSourceScale(){return await this.layer.load(),m(this.layer.serviceRasterInfo,this.view.spatialReference)}_getFullExtent(){return c(this.layer.serviceRasterInfo,this.view.spatialReference)}};return e([i()],h.prototype,"fullExtent",null),e([i()],h.prototype,"layer",void 0),e([i({readOnly:!0})],h.prototype,"timeExtent",null),e([i()],h.prototype,"tileInfo",void 0),e([i({readOnly:!0})],h.prototype,"hasTilingEffects",null),e([i()],h.prototype,"datumTransformation",null),h=e([s("esri.views.layers.ImageryTileLayerView")],h),h};export{f as default};
5
+ import{__decorate as e}from"tslib";import t from"../../Graphic.js";import r from"../../core/Error.js";import{property as i}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import"../../core/RandomLCG.js";import{subclass as s}from"../../core/accessorSupport/decorators/subclass.js";import{addMultidimensionalFieldValues as a,commonRasterFieldNames as o,rasterFieldPrefix as n}from"../../layers/support/rasterFieldUtils.js";import{combineTimeExtent as l}from"../../layers/support/timeSupport.js";import{isFunctionRaster as u}from"../../layers/support/rasterDatasets/datasetUtils.js";import{getDefaultDatumTransformationForDataset as p,projectDatasetExtent as c,getSourceScale as m}from"../../layers/support/rasterFunctions/rasterProjectionHelper.js";import{getFetchPopupTemplate as y}from"./support/popupUtils.js";const f=f=>{const d=f;let h=class extends d{constructor(...e){super(...e),this.layer=null,this.tileInfo=null}get fullExtent(){try{return this.layer.loaded?this._getFullExtent():null}catch{return null}}get timeExtent(){return l(this.layer,this.view?.timeExtent,this._get("timeExtent"))}get hasTilingEffects(){return!!(this.layer.renderer&&"dynamicRangeAdjustment"in this.layer.renderer&&this.layer.renderer.dynamicRangeAdjustment)}get datumTransformation(){try{return this.layer.loaded?p(this.layer.fullExtent,this.view.spatialReference,!0):null}catch{return null}}supportsSpatialReference(e){try{return!this.layer.loaded||!!c(this.layer.serviceRasterInfo,e)}catch{return!1}}async fetchPopupFeaturesAtLocation(e,i){const{layer:s}=this;if(!e)throw new r("imageryTileLayerView:fetchPopupFeatures","Nothing to fetch without area",{layer:s});const{popupEnabled:l}=s,p=y(s,i);if(!l||null==p)return[];const c=[],{value:m,magdirValue:f,processedValue:d}=await s.identify(e,{timeExtent:this.timeExtent,signal:i?.signal});let h="";if(m?.length){h="imagery-tile"===s.type&&s.hasStandardTime()&&null!=m[0]?m.map(e=>s.getStandardTimeValue(e)).join(", "):m.join(", ");const e={ObjectId:0};e[o.servicePixelValue]="imagery-tile"===s.type&&u(s.raster)?d?.join(", "):h,e[o.rawServicePixelValue]=h;const r=s.raster?.rasterInfo??s.serviceRasterInfo,i=r?.attributeTable;if(null!=i){const{fields:t,features:r}=i,s=t.find(({name:e})=>"value"===e.toLowerCase()),a=e[o.servicePixelValue],l=s?r.find(e=>String(e.attributes[s.name])===a):null;if(l)for(const i in l.attributes)if(l.attributes.hasOwnProperty(i)){e[n+i]=l.attributes[i]}}const l=r?.dataType;"vector-magdir"!==l&&"vector-uv"!==l||(e[o.magnitude]=f?.[0],e[o.direction]=f?.[1]);const{multidimensionalDefinition:p}=this.layer.normalizeRasterFetchOptions({timeExtent:this.timeExtent});a(s.rasterFields,e,p);const{graphicOrigin:y}=s,g=new t({geometry:this.fullExtent?.clone(),attributes:e,layer:s,origin:y,sourceLayer:s});c.push(g)}return c}async getSourceScale(){return await this.layer.load(),m(this.layer.serviceRasterInfo,this.view.spatialReference)}_getFullExtent(){return c(this.layer.serviceRasterInfo,this.view.spatialReference)}};return e([i()],h.prototype,"fullExtent",null),e([i()],h.prototype,"layer",void 0),e([i({readOnly:!0})],h.prototype,"timeExtent",null),e([i()],h.prototype,"tileInfo",void 0),e([i({readOnly:!0})],h.prototype,"hasTilingEffects",null),e([i()],h.prototype,"datumTransformation",null),h=e([s("esri.views.layers.ImageryTileLayerView")],h),h};export{f as default};
@@ -1,4 +0,0 @@
1
- import "../../interfaces";
2
-
3
- import CutFillOptions = __esri.CutFillOptions;
4
- export default CutFillOptions;
@@ -1 +0,0 @@
1
- "use strict";(self.webpackChunkRemoteClient=self.webpackChunkRemoteClient||[]).push([[4304],{21015:(e,t,r)=>{r.d(t,{R:()=>u});var n=r(78888),o=r(60999),s=r(49186),i=r(74887),a=r(84952);class u{constructor(e){this._streamDataRequester=e}async loadJSON(e,t){return this._load(0,e,t)}async loadBinary(e,t){return(0,a.DB)(e)?((0,i.Te)(t),(0,a.lJ)(e)):this._load(1,e,t)}async loadImage(e,t){return this._load(2,e,t)}async _load(e,t,r){if(null==this._streamDataRequester)return(await(0,n.A)(t,{responseType:l[e]})).data;const a=await(0,o.Ke)(this._streamDataRequester.request(t,e,r));if(!0===a.ok)return a.value;throw(0,i.QP)(a.error),new s.A("glt-loader-request-error",`Request for resource failed: ${a.error}`)}}const l={2:"image",1:"array-buffer",0:"json",3:void 0}},43609:(e,t,r)=>{r.d(t,{a:()=>s,f:()=>i,n:()=>o});var n=r(34275);function o(e,t){s(e.typedBuffer,t.typedBuffer,e.typedBufferStride,t.typedBufferStride)}function s(e,t,r=2,o=r){const s=t.length/2;let i=0,a=0;if(!(0,n.iu)(t)||(0,n.dk)(t)){for(let n=0;n<s;++n)e[i]=t[a],e[i+1]=t[a+1],i+=r,a+=o;return}const u=(0,n.a3)(t);if((0,n.JI)(t))for(let n=0;n<s;++n)e[i]=Math.max(t[a]/u,-1),e[i+1]=Math.max(t[a+1]/u,-1),i+=r,a+=o;else for(let n=0;n<s;++n)e[i]=t[a]/u,e[i+1]=t[a+1]/u,i+=r,a+=o}function i(e,t,r,n){const o=e.typedBuffer,s=e.typedBufferStride,i=n?.count??e.count;let a=(n?.dstIndex??0)*s;for(let e=0;e<i;++e)o[a]=t,o[a+1]=r,a+=s}Object.freeze(Object.defineProperty({__proto__:null,fill:i,normalizeIntegerBuffer:s,normalizeIntegerBufferView:o},Symbol.toStringTag,{value:"Module"}))},51530:(e,t,r)=>{r.d(t,{KB:()=>i,Xi:()=>o,pn:()=>a,x3:()=>s});var n=r(44208);class o{constructor(e){this.data=e,this.type="encoded-mesh-texture",this.encoding="image/ktx2"}}function s(e){return"encoded-mesh-texture"===e?.type}async function i(e){const t=new Blob([e]),r=await t.text();return JSON.parse(r)}async function a(e,t){if("image/ktx2"===t)return new o(e);const r=new Blob([e],{type:t});let s=URL.createObjectURL(r);switch(t){case"image/jpeg":s+="#.jpg";break;case"image/png":s+="#.png"}const i=new Image;if((0,n.A)("esri-iPhone"))return new Promise((e,t)=>{const r=()=>{o(),e(i)},n=e=>{o(),t(e)},o=()=>{URL.revokeObjectURL(s),i.removeEventListener("load",r),i.removeEventListener("error",n)};i.addEventListener("load",r),i.addEventListener("error",n),i.src=s});try{i.src=s,await i.decode()}catch(e){console.warn("Failed decoding HTMLImageElement")}return URL.revokeObjectURL(s),i}},61473:(e,t,r)=>{function n(e){return e=e||globalThis.location.hostname,l.some(t=>null!=e?.match(t))}function o(e,t){return e?(t=t||globalThis.location.hostname)?null!=t.match(s)||null!=t.match(a)?e.replace("static.arcgis.com","staticdev.arcgis.com"):null!=t.match(i)||null!=t.match(u)?e.replace("static.arcgis.com","staticqa.arcgis.com"):e:e:null}r.d(t,{EM:()=>o,b5:()=>n});const s=/^devext\.arcgis\.com$/,i=/^qaext\.arcgis\.com$/,a=/^[\w-]*\.mapsdevext\.arcgis\.com$/,u=/^[\w-]*\.mapsqa\.arcgis\.com$/,l=[/^([\w-]*\.)?[\w-]*\.zrh-dev-local\.esri\.com$/,s,i,/^jsapps\.esri\.com$/,a,u]},64304:(e,t,r)=>{r.d(t,{fetch:()=>J});var n=r(40876),o=r(61473),s=r(34727),i=r(77690),a=r(29242),u=r(58083),l=r(9093),c=r(48163),f=r(38954),d=r(51850),m=r(70328),p=r(11868),h=r(13030),y=r(73354),g=r(65686),x=r(43609),w=r(21015),b=r(84498),v=r(51530),T=r(88340);function B(e){if(null==e)return null;const t=null!=e.offset?e.offset:T.uY,r=null!=e.rotation?e.rotation:0,n=null!=e.scale?e.scale:T.Un,o=(0,a.fA)(1,0,0,0,1,0,t[0],t[1],1),s=(0,a.fA)(Math.cos(r),-Math.sin(r),0,Math.sin(r),Math.cos(r),0,0,0,1),u=(0,a.fA)(n[0],0,0,0,n[1],0,0,0,1),l=(0,a.vt)();return(0,i.lw)(l,s,u),(0,i.lw)(l,o,l),l}class S{constructor(){this.geometries=new Array,this.materials=new Array,this.textures=new Array}}class M{constructor(e,t,r){this.name=e,this.lodThreshold=t,this.pivotOffset=r,this.stageResources=new S,this.numberOfVertices=0}}var R=r(78888),A=r(60999),_=r(49186),E=r(53966),I=r(69397);class P{constructor(){this._outer=new Map}clear(){this._outer.clear()}get empty(){return 0===this._outer.size}get outerSize(){return this._outer.size}get(e,t){return this._outer.get(e)?.get(t)}getInner(e){return this._outer.get(e)}set(e,t,r){const n=this._outer.get(e);n?n.set(t,r):this._outer.set(e,new Map([[t,r]]))}delete(e,t){const r=this._outer.get(e);r&&(r.delete(t),0===r.size&&this._outer.delete(e))}forEach(e){this._outer.forEach((t,r)=>e(t,r))}forAll(e){this._outer.forEach((t,r)=>t.forEach((t,n)=>e(t,r,n)))}}var O=r(74887),U=r(46140),L=r(97146),j=r(99677),k=r(46610),C=r(87170),F=r(48833),V=r(2495);const q=()=>E.A.getLogger("esri.views.3d.layers.graphics.objectResourceUtils");class z{constructor(e,t,r){this.resource=e,this.textures=t,this.cachedMemory=r}}function $(e){throw new _.A("",`Request for object resource failed: ${e}`)}function D(e){const t=e.params,r=t.topology;let n=!0;switch(t.vertexAttributes||(q().warn("Geometry must specify vertex attributes"),n=!1),t.topology){case"PerAttributeArray":break;case"Indexed":case null:case void 0:{const e=t.faces;if(e){if(t.vertexAttributes)for(const r in t.vertexAttributes){const t=e[r];t?.values?(null!=t.valueType&&"UInt32"!==t.valueType&&(q().warn(`Unsupported indexed geometry indices type '${t.valueType}', only UInt32 is currently supported`),n=!1),null!=t.valuesPerElement&&1!==t.valuesPerElement&&(q().warn(`Unsupported indexed geometry values per element '${t.valuesPerElement}', only 1 is currently supported`),n=!1)):(q().warn(`Indexed geometry does not specify face indices for '${r}' attribute`),n=!1)}}else q().warn("Indexed geometries must specify faces"),n=!1;break}default:q().warn(`Unsupported topology '${r}'`),n=!1}e.params.material||(q().warn("Geometry requires material"),n=!1);const o=e.params.vertexAttributes;for(const e in o)o[e].values||(q().warn("Geometries with externally defined attributes are not yet supported"),n=!1);return n}function G(e){const t=(0,m.Ie)();return e.forEach(e=>{const r=e.boundingInfo;null!=r&&((0,m.iT)(t,r.bbMin),(0,m.iT)(t,r.bbMax))}),t}function N(e){switch(e){case"mask":return 2;case"maskAndTransparency":return 3;case"none":return 1;default:return 0}}function Q(e){const t=e.params;return{id:1,material:t.material,texture:t.texture,region:t.texture}}const K=new U.R(1,2,"wosr");var W=r(74810);async function J(e,t){const a=function(e){const t=e.match(/(.*\.(gltf|glb))(\?lod=([0-9]+))?$/);return t?{fileType:"gltf",url:t[1],specifiedLodIndex:null!=t[4]?Number(t[4]):null}:e.match(/(.*\.(json|json\.gz))$/)?{fileType:"wosr",url:e,specifiedLodIndex:null}:{fileType:"unknown",url:e,specifiedLodIndex:null}}((0,o.EM)(e));if("wosr"===a.fileType){const e=await(t.cache?t.cache.loadWOSR(a.url,t):async function(e,t){const r=await async function(e,t){const r=t?.streamDataRequester;if(r)return async function(e,t,r){const n=await(0,A.Ke)(t.request(e,0,r));if(!0===n.ok)return n.value;(0,O.QP)(n.error),$(n.error.details.url)}(e,r,t);const n=await(0,A.Ke)((0,R.A)(e,t));if(!0===n.ok)return n.value.data;(0,O.QP)(n.error),$(n.error)}(e,t),n=await async function(e,t){const r=new Array;for(const n in e){const o=e[n],s=o.images[0].data;if(!s){q().warn("Externally referenced texture data is not yet supported");continue}const i=o.encoding+";base64,"+s,a="/textureDefinitions/"+n,u="rgba"===o.channels?o.alphaChannelUsage||"transparency":"none",l={noUnpackFlip:!0,wrap:{s:10497,t:10497},preMultiplyAlpha:1!==N(u)},c=t?.disableTextures?Promise.resolve(null):(0,j.D)(i,t);r.push(c.then(e=>({refId:a,image:e,parameters:l,alphaChannelUsage:u})))}const n=await Promise.all(r),o={};for(const e of n)o[e.refId]=e;return o}(r.textureDefinitions??{},t);let o=0;for(const e in n)if(n.hasOwnProperty(e)){const t=n[e];o+=t?.image?t.image.width*t.image.height*4:0}return new z(r,n,o+(0,I.Qh)(r))}(a.url,t)),{engineResources:r,referenceBoundingBox:n}=function(e,t){const r=new Array,n=new Array,o=new Array,s=new P,i=e.resource,a=U.R.parse(i.version||"1.0","wosr");K.validate(a);const u=i.model.name,l=i.model.geometries,c=i.materialDefinitions??{},f=e.textures;let m=0;const p=new Map;for(let e=0;e<l.length;e++){const i=l[e];if(!D(i))continue;const a=Q(i),u=i.params.vertexAttributes,h=[],y=e=>{if("PerAttributeArray"===i.params.topology)return null;const t=i.params.faces;for(const r in t)if(r===e)return t[r].values;return null},g=u.position,x=g.values.length/g.valuesPerElement;for(const e in u){const t=u[e],r=t.values,n=y(e)??(0,L.tM)(x);h.push([e,new k.n(r,n,t.valuesPerElement,!0)])}const w=a.texture,b=f&&f[w];if(b&&!p.has(w)){const{image:e,parameters:t}=b,r=new F.g(e,t);n.push(r),p.set(w,r)}const v=p.get(w),T=v?v.id:void 0,B=a.material;let S=s.get(B,w);if(null==S){const e=c[B.slice(B.lastIndexOf("/")+1)].params;1===e.transparency&&(e.transparency=0);const r=b?N(b.alphaChannelUsage):void 0,n={ambient:(0,d.ci)(e.diffuse),diffuse:(0,d.ci)(e.diffuse),opacity:1-(e.transparency||0),textureAlphaMode:r,textureAlphaCutoff:.33,textureId:T,doubleSided:!0,cullFace:0,colorMixMode:e.externalColorMixMode||"tint",textureAlphaPremultiplied:b?.parameters.preMultiplyAlpha??!1};t?.materialParameters&&Object.assign(n,t.materialParameters),S=new V.$U(n,t),s.set(B,w,S)}o.push(S);const M=new C.V(S,h);m+=h.find(e=>"position"===e[0])?.[1]?.indices.length??0,r.push(M)}return{engineResources:[{name:u,stageResources:{textures:n,materials:o,geometries:r},pivotOffset:i.model.pivotOffset,numberOfVertices:m,lodThreshold:null}],referenceBoundingBox:G(r)}}(e,t);return{lods:r,referenceBoundingBox:n,isEsriSymbolResource:!1,isWosr:!0}}let T;if(t.cache)T=await t.cache.loadGLTF(a.url,t,!!t.usePBR);else{const{loadGLTF:e}=await r.e(9738).then(r.bind(r,99738));T=await e(new w.R(t.streamDataRequester),a.url,t,t.usePBR)}const S=T.model.meta?.ESRI_proxyEllipsoid,_=T.meta.isEsriSymbolResource&&null!=S&&"EsriRealisticTreesStyle"===T.meta.ESRI_webstyle;_&&!T.customMeta.esriTreeRendering&&(T.customMeta.esriTreeRendering=!0,function(e,t){for(let r=0;r<e.model.lods.length;++r){const o=e.model.lods[r];for(const s of o.parts){const o=s.attributes.normal;if(null==o)return;const i=s.attributes.position,a=i.count,c=(0,d.vt)(),m=(0,d.vt)(),p=(0,d.vt)(),y=new Float32Array(4*a),g=new Float32Array(3*a),x=(0,u.B8)((0,l.vt)(),s.transform);let w=0,b=0;for(let u=0;u<a;u++){i.getVec(u,m),o.getVec(u,c),(0,f.t)(m,m,s.transform),(0,f.d)(p,m,t.center),(0,f.D)(p,p,t.radius);const a=p[2],l=(0,f.l)(p),d=Math.min(.45+.55*l*l,1)**n.Tf;(0,f.D)(p,p,t.radius),null!==x&&(0,f.t)(p,p,x),(0,f.n)(p,p),r+1!==e.model.lods.length&&e.model.lods.length>1&&(0,f.m)(p,p,c,a>-1?.2:Math.min(-4*a-3.8,1)),g[w]=p[0],g[w+1]=p[1],g[w+2]=p[2],w+=3,y[b]=d,y[b+1]=d,y[b+2]=d,y[b+3]=1,b+=4}s.attributes.normal=new h.xs(g.buffer),s.attributes.color=new h.Eq(y.buffer)}}}(T,S));const E=!!t.usePBR,J=T.meta.isEsriSymbolResource?{usePBR:E,isSchematic:!1,treeRendering:_,mrrFactors:W.SY}:{usePBR:E,isSchematic:!1,treeRendering:!1,mrrFactors:W.mb},X={...t.materialParameters,treeRendering:_},{engineResources:H,referenceBoundingBox:Z}=function(e,t,r,o,a,u){const l=e.model,f=new Array,d=new Map,w=new Map,T=l.lods.length,S=(0,m.Ie)();return l.lods.forEach((e,R)=>{const A=!0===o.skipHighLods&&(T>1&&0===R||T>3&&1===R)||!1===o.skipHighLods&&null!=a&&R!==a;if(A&&0!==R)return;const _=new M(e.name,e.lodThreshold,[0,0,0]);e.parts.forEach(e=>{const a=A?new V.$U({},o):function(e,t,r,o,s,i,a,u,l){const f=e.materials.get(t.material);if(null==f)return null;const{normal:d,color:m,texCoord0:p,tangent:h}=t.attributes,y=t.material+(d?"_normal":"")+(m?"_color":"")+(p?"_texCoord0":"")+(h?"_tangent":""),g=null!=t.attributes.texCoord0,x=null!=t.attributes.normal,w=function(e){switch(e){case"BLEND":return 0;case"MASK":return 2;case"OPAQUE":case null:case void 0:return 1}}(f.alphaMode);if(!i.has(y)){if(g){const t=(t,r=!1,n=!1)=>{if(null!=t&&!a.has(t)){const o=e.textures.get(t);if(o){const e=o.data,s=r&&!(0,v.x3)(e)?u.compressionOptions:void 0;a.set(t,new F.g((0,v.x3)(e)?e.data:e,{...o.parameters,preMultiplyAlpha:!(0,v.x3)(e)&&n,encoding:(0,v.x3)(e)?e.encoding:void 0,compressionOptions:s}))}}},r=1!==w&&!l;t(f.colorTexture,r,1!==w),t(f.normalTexture),t(f.occlusionTexture,!0),t(f.emissiveTexture),t(f.metallicRoughnessTexture,!0)}const r=1/n.Tf,d=f.color[0]**r,m=f.color[1]**r,p=f.color[2]**r,h=f.emissiveFactor[0]**r,b=f.emissiveFactor[1]**r,T=f.emissiveFactor[2]**r,S=null!=f.colorTexture&&g?a.get(f.colorTexture):null,M=(0,W.Jr)(f),R=null!=f.normalTextureTransform?.scale?f.normalTextureTransform?.scale:c.Un;i.set(y,new V.$U({...o,customDepthTest:1,textureAlphaMode:w,textureAlphaCutoff:f.alphaCutoff,diffuse:[d,m,p],ambient:[d,m,p],opacity:"OPAQUE"===f.alphaMode?1:f.opacity,doubleSided:f.doubleSided,doubleSidedType:"winding-order",cullFace:f.doubleSided?0:2,hasVertexColors:!!t.attributes.color,hasVertexTangents:!!t.attributes.tangent,normalType:x?0:2,castShadows:!0,receiveShadows:f.receiveShadows,receiveAmbientOcclusion:f.receiveAmbientOcclusion,textureId:null!=S?S.id:void 0,colorMixMode:f.colorMixMode,normalTextureId:null!=f.normalTexture&&g?a.get(f.normalTexture).id:void 0,textureAlphaPremultiplied:null!=S&&!!S.parameters.preMultiplyAlpha,occlusionTextureId:null!=f.occlusionTexture&&g?a.get(f.occlusionTexture).id:void 0,emissiveTextureId:null!=f.emissiveTexture&&g?a.get(f.emissiveTexture).id:void 0,metallicRoughnessTextureId:null!=f.metallicRoughnessTexture&&g?a.get(f.metallicRoughnessTexture).id:void 0,emissiveBaseColor:[h,b,T],mrrFactors:M?W.Bt:[f.metallicFactor,f.roughnessFactor,o.mrrFactors[2]],isSchematic:M,colorTextureTransformMatrix:B(f.colorTextureTransform),normalTextureTransformMatrix:B(f.normalTextureTransform),scale:[R[0],R[1]],occlusionTextureTransformMatrix:B(f.occlusionTextureTransform),emissiveTextureTransformMatrix:B(f.emissiveTextureTransform),metallicRoughnessTextureTransformMatrix:B(f.metallicRoughnessTextureTransform),...s},u))}const b=i.get(y);if(r.stageResources.materials.push(b),g){const e=e=>{null!=e&&r.stageResources.textures.push(a.get(e))};e(f.colorTexture),e(f.normalTexture),e(f.occlusionTexture),e(f.emissiveTexture),e(f.metallicRoughnessTexture)}return b}(l,e,_,t,r,d,w,o,u),{geometry:f,vertexCount:T}=function(e,t){const r=e.attributes.position.count,n=(0,b.x)(e.indices||r,e.primitiveType),o=(0,p.oe)(3*r),{typedBuffer:a,typedBufferStride:u}=e.attributes.position;(0,y.t)(o,a,e.transform,3,u);const l=[["position",new k.n(o,n,3,!0)]];if(null!=e.attributes.normal){const t=(0,p.oe)(3*r),{typedBuffer:o,typedBufferStride:a}=e.attributes.normal;(0,i.Ge)(Y,e.transform),(0,y.b)(t,o,Y,3,a),(0,s.or)(Y)&&(0,y.n)(t,t),l.push(["normal",new k.n(t,n,3,!0)])}if(null!=e.attributes.tangent){const t=(0,p.oe)(4*r),{typedBuffer:o,typedBufferStride:a}=e.attributes.tangent;(0,i.z0)(Y,e.transform),(0,g.t)(t,o,Y,4,a),(0,s.or)(Y)&&(0,y.n)(t,t,4),l.push(["tangent",new k.n(t,n,4,!0)])}if(null!=e.attributes.texCoord0){const t=(0,p.oe)(2*r),{typedBuffer:o,typedBufferStride:s}=e.attributes.texCoord0;(0,x.a)(t,o,2,s),l.push(["uv0",new k.n(t,n,2,!0)])}const c=e.attributes.color;if(null!=c){const t=new Uint8Array(4*r);4===c.elementCount?c instanceof h.Eq?(0,g.b)(t,c,1,255):(c instanceof h.XP||c instanceof h.Uz)&&(0,g.b)(t,c,1/255,255):(t.fill(255),c instanceof h.xs?(0,y.f)(t,c.typedBuffer,1,255,4,c.typedBufferStride):(e.attributes.color instanceof h.eI||e.attributes.color instanceof h.nS)&&(0,y.f)(t,c.typedBuffer,1/255,255,4,e.attributes.color.typedBufferStride)),l.push(["color",new k.n(t,n,4,!0)])}return{geometry:new C.V(t,l),vertexCount:r}}(e,a??new V.$U({},o)),M=f.boundingInfo;null!=M&&0===R&&((0,m.iT)(S,M.bbMin),(0,m.iT)(S,M.bbMax)),null!=a&&(_.stageResources.geometries.push(f),_.numberOfVertices+=T)}),A||f.push(_)}),{engineResources:f,referenceBoundingBox:S}}(T,J,X,t,a.specifiedLodIndex,_);return{lods:H,referenceBoundingBox:Z,isEsriSymbolResource:T.meta.isEsriSymbolResource,isWosr:!1}}const Y=(0,a.vt)()},65686:(e,t,r)=>{r.d(t,{a:()=>s,b:()=>c,l:()=>l,n:()=>a,t:()=>i});var n=r(40876),o=(r(44208),r(53966));function s(e,t,r){i(e.typedBuffer,t.typedBuffer,r,e.typedBufferStride,t.typedBufferStride)}function i(e,t,r,n=4,o=n){if(e.length/n!==t.length/o)return;const s=e.length/n,i=r[0],a=r[1],u=r[2],l=r[3],c=r[4],f=r[5],d=r[6],m=r[7],p=r[8];let h=0,y=0;for(let r=0;r<s;r++){const r=t[h],s=t[h+1],g=t[h+2],x=t[h+3];e[y]=i*r+l*s+d*g,e[y+1]=a*r+c*s+m*g,e[y+2]=u*r+f*s+p*g,e[y+3]=x,h+=o,y+=n}}function a(e,t){const r=Math.min(e.count,t.count),n=e.typedBuffer,o=e.typedBufferStride,s=t.typedBuffer,i=t.typedBufferStride;for(let e=0;e<r;e++){const t=e*o,r=e*i,a=s[r],u=s[r+1],l=s[r+2],c=a*a+u*u+l*l;if(c>0){const e=1/Math.sqrt(c);n[t]=e*a,n[t+1]=e*u,n[t+2]=e*l}}}function u(e,t,r,n=4){const o=Math.min(e.length/n,t.count),s=t.typedBuffer,i=t.typedBufferStride;let a=0,u=0;for(let t=0;t<o;t++)e[u]=r*s[a],e[u+1]=r*s[a+1],e[u+2]=r*s[a+2],e[u+3]=r*s[a+3],a+=i,u+=n}function l(e,t,r,n){c(e.typedBuffer,t,r,n,e.typedBufferStride)}function c(e,t,r,o,s=4){const i=Math.min(e.length/s,t.count),a=t.typedBuffer,u=t.typedBufferStride;let l=0,c=0;const f=1/n.Tf;for(let t=0;t<i;t++)e[c]=o*(r*a[l])**f,e[c+1]=o*(r*a[l+1])**f,e[c+2]=o*(r*a[l+2])**f,e[c+3]=o*r*a[l+3],l+=u,c+=s}Object.freeze(Object.defineProperty({__proto__:null,linearToSRGB:c,linearToSRGBView:l,normalize:a,scale:u,scaleView:function(e,t,r){u(e.typedBuffer,t,r,e.typedBufferStride)},transformMat3:i,transformMat3View:s,transformMat4:function(e,t,r,n=4,s=n){if(e.length/n!==t.length/s)return void o.A.getLogger("esri.views.3d.support.buffer.math").error("source and destination buffers need to have the same number of elements");const i=e.length/n,a=r[0],u=r[1],l=r[2],c=r[3],f=r[4],d=r[5],m=r[6],p=r[7],h=r[8],y=r[9],g=r[10],x=r[11],w=r[12],b=r[13],v=r[14],T=r[15];let B=0,S=0;for(let r=0;r<i;r++){const r=t[B],o=t[B+1],i=t[B+2],M=t[B+3];e[S]=a*r+f*o+h*i+w*M,e[S+1]=u*r+d*o+y*i+b*M,e[S+2]=l*r+m*o+g*i+v*M,e[S+3]=c*r+p*o+x*i+T*M,B+=s,S+=n}},transformMat4View:function(e,t,r){if(e.count!==t.count)return;const n=e.count,o=r[0],s=r[1],i=r[2],a=r[3],u=r[4],l=r[5],c=r[6],f=r[7],d=r[8],m=r[9],p=r[10],h=r[11],y=r[12],g=r[13],x=r[14],w=r[15],b=e.typedBuffer,v=e.typedBufferStride,T=t.typedBuffer,B=t.typedBufferStride;for(let e=0;e<n;e++){const t=e*v,r=e*B,n=T[r],S=T[r+1],M=T[r+2],R=T[r+3];b[t]=o*n+u*S+d*M+y*R,b[t+1]=s*n+l*S+m*M+g*R,b[t+2]=i*n+c*S+p*M+x*R,b[t+3]=a*n+f*S+h*M+w*R}}},Symbol.toStringTag,{value:"Module"}))},69397:(e,t,r)=>{r.d(t,{$B:()=>o,Qf:()=>l,Qh:()=>a,RS:()=>s,ez:()=>d,lM:()=>i,qK:()=>f});var n=r(34275);function o(e){return 32+e.length}const s=16;function i(e){if(!e)return 0;let t=f;for(const r in e)e.hasOwnProperty(r)&&(t+=u(e[r],!1));return t}function a(e){if(!e)return 0;if("number"==typeof e[0])return l(e);if(Array.isArray(e))return function(e){const t=e.length;if(0===t||"number"==typeof e[0])return c(e,8);let r=d;for(let n=0;n<t;n++)r+=u(e[n]);return r}(e);let t=f;for(const r in e)e.hasOwnProperty(r)&&(t+=u(e[r]));return t}function u(e,t=!0){switch(typeof e){case"object":return t?a(e):f;case"string":return o(e);case"number":return s;case"boolean":return 4;default:return 8}}function l(...e){return e.reduce((e,t)=>e+(t?(0,n.iu)(t)?t.byteLength+m:Array.isArray(t)?c(t,s):0:0),0)}function c(e,t){return d+e.length*t}const f=32,d=16,m=145},73354:(e,t,r)=>{r.d(t,{a:()=>f,b:()=>a,c:()=>i,d:()=>o,e:()=>d,f:()=>c,l:()=>l,n:()=>m,t:()=>s});var n=r(40876);function o(e,t,r){s(e.typedBuffer,t.typedBuffer,r,e.typedBufferStride,t.typedBufferStride)}function s(e,t,r,n=3,o=n){if(e.length/n!==Math.ceil(t.length/o))return e;const s=e.length/n,i=r[0],a=r[1],u=r[2],l=r[4],c=r[5],f=r[6],d=r[8],m=r[9],p=r[10],h=r[12],y=r[13],g=r[14];let x=0,w=0;for(let r=0;r<s;r++){const r=t[x],s=t[x+1],b=t[x+2];e[w]=i*r+l*s+d*b+h,e[w+1]=a*r+c*s+m*b+y,e[w+2]=u*r+f*s+p*b+g,x+=o,w+=n}return e}function i(e,t,r){a(e.typedBuffer,t.typedBuffer,r,e.typedBufferStride,t.typedBufferStride)}function a(e,t,r,n=3,o=n){if(e.length/n!==Math.ceil(t.length/o))return;const s=e.length/n,i=r[0],a=r[1],u=r[2],l=r[3],c=r[4],f=r[5],d=r[6],m=r[7],p=r[8];let h=0,y=0;for(let r=0;r<s;r++){const r=t[h],s=t[h+1],g=t[h+2];e[y]=i*r+l*s+d*g,e[y+1]=a*r+c*s+m*g,e[y+2]=u*r+f*s+p*g,h+=o,y+=n}}function u(e,t,r,n=3,o=n){const s=Math.min(e.length/n,t.length/o);let i=0,a=0;for(let u=0;u<s;u++)e[a]=r*t[i],e[a+1]=r*t[i+1],e[a+2]=r*t[i+2],i+=o,a+=n;return e}function l(e,t,r,n){c(e.typedBuffer,t.typedBuffer,r,n,e.typedBufferStride,t.typedBufferStride)}function c(e,t,r,o,s=3,i=s){const a=Math.min(e.length/s,t.length/i);let u=0,l=0;const c=1/n.Tf;for(let n=0;n<a;n++)e[l]=o*(r*t[u])**c,e[l+1]=o*(r*t[u+1])**c,e[l+2]=o*(r*t[u+2])**c,u+=i,l+=s}function f(e,t,r,n=3,o=n){const s=e.length/n;if(s!==Math.ceil(t.length/o))return e;let i=0,a=0;for(let u=0;u<s;u++)e[a]=t[i]+r[0],e[a+1]=t[i+1]+r[1],e[a+2]=t[i+2]+r[2],i+=o,a+=n;return e}function d(e,t){m(e.typedBuffer,t.typedBuffer,e.typedBufferStride,t.typedBufferStride)}function m(e,t,r=3,n=r){const o=Math.min(e.length/r,t.length/n);let s=0,i=0;for(let a=0;a<o;a++){const o=t[s],a=t[s+1],u=t[s+2],l=o*o+a*a+u*u;if(l>0){const t=1/Math.sqrt(l);e[i]=t*o,e[i+1]=t*a,e[i+2]=t*u}s+=n,i+=r}}r(44208),r(53966),Object.freeze(Object.defineProperty({__proto__:null,linearToSRGB:c,linearToSRGBView:l,normalize:m,normalizeView:d,scale:u,scaleView:function(e,t,r){u(e.typedBuffer,t.typedBuffer,r,e.typedBufferStride,t.typedBufferStride)},shiftRight:function(e,t,r){const n=Math.min(e.count,t.count),o=e.typedBuffer,s=e.typedBufferStride,i=t.typedBuffer,a=t.typedBufferStride;let u=0,l=0;for(let e=0;e<n;e++)o[l]=i[u]>>r,o[l+1]=i[u+1]>>r,o[l+2]=i[u+2]>>r,u+=a,l+=s},transformMat3:a,transformMat3View:i,transformMat4:s,transformMat4View:o,translate:f},Symbol.toStringTag,{value:"Module"}))},84498:(e,t,r)=>{r.d(t,{x:()=>i});var n=r(34275),o=r(97146),s=r(63907);function i(e,t){switch(t){case s.WR.TRIANGLES:return function(e){return"number"==typeof e?(0,o.tM)(e):(0,n.mg)(e)?new Uint16Array(e):e}(e);case s.WR.TRIANGLE_STRIP:return function(e){const t="number"==typeof e?e:e.length;if(t<3)return[];const r=t-2,n=(0,o.my)(3*r);if("number"==typeof e){let e=0;for(let t=0;t<r;t+=1)t%2==0?(n[e++]=t,n[e++]=t+1,n[e++]=t+2):(n[e++]=t+1,n[e++]=t,n[e++]=t+2)}else{let t=0;for(let o=0;o<r;o+=1)o%2==0?(n[t++]=e[o],n[t++]=e[o+1],n[t++]=e[o+2]):(n[t++]=e[o+1],n[t++]=e[o],n[t++]=e[o+2])}return n}(e);case s.WR.TRIANGLE_FAN:return function(e){const t="number"==typeof e?e:e.length;if(t<3)return new Uint16Array(0);const r=t-2,n=r<=65536?new Uint16Array(3*r):new Uint32Array(3*r);if("number"==typeof e){let e=0;for(let t=0;t<r;++t)n[e++]=0,n[e++]=t+1,n[e++]=t+2;return n}const o=e[0];let s=e[1],i=0;for(let t=0;t<r;++t){const r=e[t+2];n[i++]=o,n[i++]=s,n[i++]=r,s=r}return n}(e)}}},88340:(e,t,r)=>{function n(){return new Float32Array(2)}function o(e,t){const r=new Float32Array(2);return r[0]=e,r[1]=t,r}function s(){return n()}function i(){return o(1,1)}function a(){return o(1,0)}function u(){return o(0,1)}r.d(t,{Un:()=>c,fA:()=>o,uY:()=>l,vt:()=>n});const l=s(),c=i(),f=a(),d=u();Object.freeze(Object.defineProperty({__proto__:null,ONES:c,UNIT_X:f,UNIT_Y:d,ZEROS:l,clone:function(e){const t=new Float32Array(2);return t[0]=e[0],t[1]=e[1],t},create:n,fromValues:o,ones:i,unitX:a,unitY:u,zeros:s},Symbol.toStringTag,{value:"Module"}))}}]);