@arcgis/core 5.2.0-next.48 → 5.2.0-next.49

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 (190) hide show
  1. package/applications/Components/OrientedImageryViewer/PanoramicViewer/utils.d.ts +33 -0
  2. package/applications/Components/OrientedImageryViewer/PanoramicViewer/utils.js +2 -0
  3. package/arcgisGlobal.d.ts +2 -0
  4. package/assets/esri/core/workers/RemoteClient.js +1 -1
  5. package/assets/esri/core/workers/chunks/031ccf2e1583beebdf24.js +1 -0
  6. package/assets/esri/core/workers/chunks/0474af7687466d8befd2.js +1 -0
  7. package/assets/esri/core/workers/chunks/{f9b2727b41943d83d4ca.js → 0a413d917f3d19440fc1.js} +1 -1
  8. package/assets/esri/core/workers/chunks/0b2ca406761c63529a6a.js +1 -0
  9. package/assets/esri/core/workers/chunks/{c369d4266f38e9ea6592.js → 1119a33245138e7b3914.js} +1 -1
  10. package/assets/esri/core/workers/chunks/{6fbcf1b85461c6c6c127.js → 172571397c66f992d08c.js} +1 -1
  11. package/assets/esri/core/workers/chunks/18edf2846d7546285e5e.js +1 -0
  12. package/assets/esri/core/workers/chunks/{7759a489205a874e13bb.js → 1b0557fcb058fc450230.js} +1 -1
  13. package/assets/esri/core/workers/chunks/{7d0ff52748fd4eb0334d.js → 1bc45872d22d61dbd7d1.js} +1 -1
  14. package/assets/esri/core/workers/chunks/{835643f716f7058a2722.js → 1cf8fb704c48ac3d3b15.js} +1 -1
  15. package/assets/esri/core/workers/chunks/25cb56c3b538d00e7693.js +1 -0
  16. package/assets/esri/core/workers/chunks/{2c0d92c0e3511775401a.js → 35cbf00f0c37a86517af.js} +1 -1
  17. package/assets/esri/core/workers/chunks/382d9491c2a56c1925fe.js +1 -0
  18. package/assets/esri/core/workers/chunks/3af2b9d6d5466cb2b957.js +256 -0
  19. package/assets/esri/core/workers/chunks/{c3766d98f0a70897647f.js → 3bc2943035391b44d4cf.js} +1 -1
  20. package/assets/esri/core/workers/chunks/{bd8b180c61a80e60568c.js → 40f7bb0ebd918d76f078.js} +1 -1
  21. package/assets/esri/core/workers/chunks/43b39abd49c4a8ce891f.js +1 -0
  22. package/assets/esri/core/workers/chunks/{821176ee3be724621bb0.js → 461c2de938bf4c9b1442.js} +1 -1
  23. package/assets/esri/core/workers/chunks/4ee7232ea41fa41c5ed4.js +29 -0
  24. package/assets/esri/core/workers/chunks/50674ba5f24129d61d89.js +1 -0
  25. package/assets/esri/core/workers/chunks/547a2fe53139f705f95e.js +1 -0
  26. package/assets/esri/core/workers/chunks/5ce09c4d06e98b1e9251.js +1 -0
  27. package/assets/esri/core/workers/chunks/{4d9433f127aef76f3449.js → 5dbd28fce73751d2d1aa.js} +1 -1
  28. package/assets/esri/core/workers/chunks/5ec8b02e097cf6718462.js +1 -0
  29. package/assets/esri/core/workers/chunks/5f54d927dc77e92cf145.js +1 -0
  30. package/assets/esri/core/workers/chunks/63e3d338751240479335.js +1 -0
  31. package/assets/esri/core/workers/chunks/6ccd5fa5e35dc70fcd5d.js +1 -0
  32. package/assets/esri/core/workers/chunks/6e520ef645c5edcd499a.js +1 -0
  33. package/assets/esri/core/workers/chunks/{68d898037feb0aee3138.js → 78add8e6b54b51eaa299.js} +1 -1
  34. package/assets/esri/core/workers/chunks/7b61f56d0f766421eaef.js +1 -0
  35. package/assets/esri/core/workers/chunks/7f2f2a92dce3f68e579b.js +1 -0
  36. package/assets/esri/core/workers/chunks/{e7e3ea7af928b49b226c.js → 801a664f21e0218bc705.js} +1 -1
  37. package/assets/esri/core/workers/chunks/8d21e2dabc5165f1c8ca.js +1 -0
  38. package/assets/esri/core/workers/chunks/9008090a5d8431ddfa22.js +1 -0
  39. package/assets/esri/core/workers/chunks/{71ce1009dadcae8f8094.js → 95b3b8fe45ef4ac6b277.js} +1 -1
  40. package/assets/esri/core/workers/chunks/{78918035144c3c76df71.js → 96cec8a02ca96175d602.js} +1 -1
  41. package/assets/esri/core/workers/chunks/{bab71e1b8b93d09d4809.js → 99eccf9ce53582cfa5b5.js} +1 -1
  42. package/assets/esri/core/workers/chunks/9b7cb96acea388d86fa4.js +1 -0
  43. package/assets/esri/core/workers/chunks/{ff2c4f648f77850922d5.js → 9e474465d069cb9e94f5.js} +1 -1
  44. package/assets/esri/core/workers/chunks/{ae9f9e975d7a9d442fa5.js → ab5aa4280ed0cb7fcbe9.js} +1 -1
  45. package/assets/esri/core/workers/chunks/b49952541d189b4b9f7e.js +1 -0
  46. package/assets/esri/core/workers/chunks/{fed6c75485601cd3afa1.js → baac90da0703891d59c4.js} +1 -1
  47. package/assets/esri/core/workers/chunks/bb552089b34d6811fb03.js +1 -0
  48. package/assets/esri/core/workers/chunks/{b30237361d87cf982e41.js → d1af0bd611a3dc549858.js} +64 -59
  49. package/assets/esri/core/workers/chunks/d2cb3d5ef0a9285afb78.js +1 -0
  50. package/assets/esri/core/workers/chunks/d560ed96dde5ca3a5583.js +1 -0
  51. package/assets/esri/core/workers/chunks/dc1787d88b11ed985159.js +1 -0
  52. package/assets/esri/core/workers/chunks/{399e23d777a043efa9f1.js → dd95f50dac3f33cdb6d2.js} +1 -1
  53. package/assets/esri/core/workers/chunks/ddb92c815d17c67a45e6.js +1 -0
  54. package/assets/esri/core/workers/chunks/{52efa4ded11c1e71f04f.js → e2e2162adbfb9b46bede.js} +1 -1
  55. package/assets/esri/core/workers/chunks/e4353f0792f45aa6a62f.js +1 -0
  56. package/assets/esri/core/workers/chunks/eac8cae89da9ce2f4946.js +1 -0
  57. package/assets/esri/core/workers/chunks/edf87407dd20685c82ab.js +1 -0
  58. package/assets/esri/core/workers/chunks/{be6caade351e89f84251.js → ee7c8a7f384ea6393487.js} +107 -82
  59. package/assets/esri/core/workers/chunks/f1299b4fc760ccca1518.js +1 -0
  60. package/assets/esri/core/workers/chunks/f244632f7934a4b72c91.js +1 -0
  61. package/assets/esri/core/workers/chunks/fc639c730115e07a4a1a.js +1 -0
  62. package/assets/esri/libs/dxtEncoder/dxt_encoder.wasm +0 -0
  63. package/chunks/Component.glsl.js +104 -67
  64. package/chunks/LineMarker.glsl.js +31 -31
  65. package/chunks/RibbonLine.glsl.js +60 -49
  66. package/chunks/dxt_encoder.js +1 -1
  67. package/chunks/vec3.js +1 -1
  68. package/config.js +1 -1
  69. package/core/has.js +1 -1
  70. package/geometry/support/aaBoundingBox.js +1 -1
  71. package/geometry/support/buffer/math/vec3.js +1 -1
  72. package/geometry/support/frustum.js +1 -1
  73. package/geometry/support/meshUtils/extent.js +1 -1
  74. package/geometry/support/meshUtils/vertexSpaceConversion.js +1 -1
  75. package/kernel.js +1 -1
  76. package/layers/orientedImagery/transformations/imageToWorld.js +1 -1
  77. package/layers/orientedImagery/transformations/utils.js +1 -1
  78. package/package.json +1 -1
  79. package/support/revision.js +1 -1
  80. package/symbols/cim/CIMSymbolDrawHelper.js +1 -1
  81. package/symbols/cim/CIMSymbolHelper.js +1 -1
  82. package/symbols/cim/TextRasterizer.js +1 -1
  83. package/symbols/cim/cimAnalyzer.js +1 -1
  84. package/symbols/cim/richTextUtils.js +2 -0
  85. package/views/2d/engine/webgl/TextureManager.js +1 -1
  86. package/views/2d/engine/webgl/definitions.js +1 -1
  87. package/views/2d/engine/webgl/mesh/templates/shapingUtils.js +1 -1
  88. package/views/2d/engine/webgl/shaderGraph/techniques/labels/LabelMeshWriter.js +1 -1
  89. package/views/2d/engine/webgl/shaderGraph/techniques/text/TextMeshWriter.js +1 -1
  90. package/views/2d/engine/webgl/util/DimensionMatcher.js +1 -1
  91. package/views/2d/layers/FeatureLikeLayerView2D.js +1 -1
  92. package/views/2d/layers/features/schema/processor/symbols/SymbolSchema.js +1 -1
  93. package/views/2d/layers/support/annodime/DimensionInfo.js +1 -1
  94. package/views/2d/layers/support/annodime/dimensionUtils.js +1 -1
  95. package/views/3d/analysis/LineOfSight/LineOfSightReshapeTool3D.js +1 -1
  96. package/views/3d/analysis/Viewshed/ViewshedConfiguration.js +1 -1
  97. package/views/3d/analysis/Viewshed/ViewshedEditTool.js +1 -1
  98. package/views/3d/analysis/Viewshed/ViewshedSubTool.js +1 -1
  99. package/views/3d/analysis/Viewshed/ViewshedSubVisualization.js +1 -1
  100. package/views/3d/analysis/Viewshed/ViewshedTool.js +1 -1
  101. package/views/3d/analysis/ViewshedAnalysisView3D.js +1 -1
  102. package/views/3d/analysis/VolumeMeasurement/VolumeMeasurementCutFillController.js +1 -1
  103. package/views/3d/analysis/VolumeMeasurement/VolumeMeasurementCutFillVisualization.js +1 -1
  104. package/views/3d/focusAreaUtils.js +1 -1
  105. package/views/3d/layers/graphics/Graphics3DExtrudeSymbolLayer.js +1 -1
  106. package/views/3d/layers/graphics/Graphics3DMeshFillSymbolLayer.js +1 -1
  107. package/views/3d/layers/graphics/objectResourceUtils.js +1 -1
  108. package/views/3d/layers/graphics/wosrLoader.js +1 -1
  109. package/views/3d/layers/i3s/meshUtils.js +1 -1
  110. package/views/3d/webgl/RenderCamera.js +1 -1
  111. package/views/3d/webgl/RenderNode.js +1 -1
  112. package/views/3d/webgl-engine/collections/Component/Material/Component.glsl.js +1 -1
  113. package/views/3d/webgl-engine/core/shaderLibrary/TextureBackedBuffer.glsl.js +2 -2
  114. package/views/3d/webgl-engine/core/shaderLibrary/TextureBackedBufferFields.glsl.js +2 -2
  115. package/views/3d/webgl-engine/core/shaderLibrary/attributes/RibbonVertexPosition.glsl.js +36 -25
  116. package/views/3d/webgl-engine/core/shaderLibrary/terrain/Overlay.glsl.js +17 -10
  117. package/views/3d/webgl-engine/lib/BoundingInfo.js +1 -1
  118. package/views/3d/webgl-engine/lib/Object3D.js +1 -1
  119. package/views/3d/webgl-engine/lib/PolygonIntersections2D.js +1 -1
  120. package/views/3d/webgl-engine/lib/RayIntersections.js +1 -1
  121. package/views/3d/webgl-engine/lib/RenderGeometry.js +1 -1
  122. package/views/3d/webgl-engine/lib/depthRangeUtils.js +1 -1
  123. package/views/3d/webgl-engine/lib/lodRendering/LodLevel.js +1 -1
  124. package/views/3d/webgl-engine/lib/screenPolygonOverlapUtils.js +1 -1
  125. package/views/3d/webgl-engine/lib/screenPolygonTriangleIntersections.js +1 -1
  126. package/views/3d/webgl-engine/materials/PathMaterial.js +1 -1
  127. package/views/3d/webgl-engine/materials/RibbonLineMaterial.js +1 -1
  128. package/views/3d/webgl-engine/shaders/AnimatedLine.glsl.js +8 -5
  129. package/views/3d/webgl-engine/shaders/RibbonLine.glsl.js +1 -1
  130. package/views/3d/webgl-engine/shaders/RibbonLineLayouts.js +1 -1
  131. package/views/3d/webgl-engine/shaders/RibbonLineTechnique.js +1 -1
  132. package/views/3d/webgl-engine/shaders/RibbonLineTextureBuffer.glsl.js +1 -1
  133. package/views/SceneView.js +1 -1
  134. package/views/interactive/snapping/featureSources/FeatureServiceSnappingSource.js +1 -1
  135. package/views/interactive/snapping/featureSources/featureServiceSource/FeatureServiceSnappingSourceWorkerHandle.js +1 -1
  136. package/views/interactive/snapping/featureSources/featureServiceSource/FeatureServiceTiledFetcher.js +1 -1
  137. package/views/selection/SelectionOperation.js +1 -1
  138. package/views/support/DefaultsFromMap.js +1 -1
  139. package/views/support/LayerViewManager.js +1 -1
  140. package/views/support/TextureCompressionWorker.js +1 -1
  141. package/views/webgl/RenderingContext.js +1 -1
  142. package/widgets/Editor.js +1 -1
  143. package/widgets/OrientedImageryViewer/OrientedImageryViewerViewModel.js +1 -1
  144. package/widgets/OrientedImageryViewer/services/SuperimposeService.js +1 -1
  145. package/widgets/OrientedImageryViewer/support/superimposeUtils.js +1 -1
  146. package/widgets/PanoramicViewer/support/PanoramicTileNode.d.ts +63 -0
  147. package/widgets/PanoramicViewer/support/PanoramicTileNode.js +1 -1
  148. package/widgets/PanoramicViewer/support/PanoramicTilePyramid.d.ts +66 -0
  149. package/widgets/PanoramicViewer/support/PanoramicTilePyramid.js +1 -1
  150. package/widgets/PanoramicViewer/utils.js +1 -1
  151. package/widgets/Sketch/VisibleElements.d.ts +0 -10
  152. package/widgets/Sketch.js +1 -1
  153. package/widgets/support/SelectionToolbar/SelectionToolbarViewModel.js +1 -1
  154. package/widgets/support/SelectionToolbar.js +1 -1
  155. package/widgets/support/Selector3D/selectorUtils.js +2 -0
  156. package/assets/esri/core/workers/chunks/0e64e20fedfe01a1985f.js +0 -1
  157. package/assets/esri/core/workers/chunks/0f674c625f24ac73e25a.js +0 -1
  158. package/assets/esri/core/workers/chunks/15351354afcbf840a23d.js +0 -29
  159. package/assets/esri/core/workers/chunks/1843a762f7051f61af43.js +0 -1
  160. package/assets/esri/core/workers/chunks/1d1f5578c7d8619f7a46.js +0 -1
  161. package/assets/esri/core/workers/chunks/2015f4def2ef201bdab8.js +0 -1
  162. package/assets/esri/core/workers/chunks/20c363a113dc068de9e0.js +0 -1
  163. package/assets/esri/core/workers/chunks/24d936d459c538187af6.js +0 -1
  164. package/assets/esri/core/workers/chunks/272c8ab189217240d05f.js +0 -1
  165. package/assets/esri/core/workers/chunks/2e121eac97ae72a8b49a.js +0 -1
  166. package/assets/esri/core/workers/chunks/327899182a4dace428eb.js +0 -1
  167. package/assets/esri/core/workers/chunks/32ca15d928d51b380068.js +0 -1
  168. package/assets/esri/core/workers/chunks/3e1a7e4c674057807e3a.js +0 -1
  169. package/assets/esri/core/workers/chunks/4e2baa60c5d5197b2271.js +0 -1
  170. package/assets/esri/core/workers/chunks/519c0b51b1ba42fb71d7.js +0 -1
  171. package/assets/esri/core/workers/chunks/57fa3c0e7892c2eef3ee.js +0 -261
  172. package/assets/esri/core/workers/chunks/68b615bbd27fadcfcb66.js +0 -1
  173. package/assets/esri/core/workers/chunks/69d740ab18510156f5d6.js +0 -1
  174. package/assets/esri/core/workers/chunks/8d21f3d6edbcd7b335d0.js +0 -1
  175. package/assets/esri/core/workers/chunks/9a97f6cda2f36941efae.js +0 -1
  176. package/assets/esri/core/workers/chunks/9ceeae787dc7c194d60e.js +0 -1
  177. package/assets/esri/core/workers/chunks/a90f7b1c6c69b6033b4c.js +0 -1
  178. package/assets/esri/core/workers/chunks/b32bdf5730953c2fb16b.js +0 -1
  179. package/assets/esri/core/workers/chunks/b5d23efa584c74955d5b.js +0 -1
  180. package/assets/esri/core/workers/chunks/b83f2bbd634f57a5e8f9.js +0 -1
  181. package/assets/esri/core/workers/chunks/bb8e9b8343b83dd1ba3c.js +0 -1
  182. package/assets/esri/core/workers/chunks/bef1990159c0e49e7d27.js +0 -1
  183. package/assets/esri/core/workers/chunks/bf287f0e2ecb4532dc00.js +0 -1
  184. package/assets/esri/core/workers/chunks/c5e36544b2d1792e4c5f.js +0 -1
  185. package/assets/esri/core/workers/chunks/cba3316910ff088f4d77.js +0 -1
  186. package/assets/esri/core/workers/chunks/de9573871f64c01e9f01.js +0 -1
  187. package/assets/esri/core/workers/chunks/e232459f0b00110e07ac.js +0 -1
  188. package/assets/esri/core/workers/chunks/ee6bb6cd16f99421c76b.js +0 -1
  189. package/assets/esri/core/workers/chunks/fd2ba6f76645ba503cbb.js +0 -1
  190. package/views/3d/analysis/Viewshed/ViewshedTool2.js +0 -2
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{__decorate as e}from"tslib";import t from"../../Graphic.js";import{equals as i,isSome as r}from"../../core/arrayUtils.js";import{createTask as a}from"../../core/asyncUtils.js";import s from"../../core/Collection.js";import{deprecatedProperty as o}from"../../core/deprecate.js";import n from"../../core/Error.js";import{EventedMixin as l}from"../../core/Evented.js";import{makeHandle as c}from"../../core/handleUtils.js";import{equalsShallow as d}from"../../core/lang.js";import u from"../../core/Logger.js";import{clamp as h}from"../../core/mathUtils.js";import{destroyMaybe as p,abortMaybe as m}from"../../core/maybe.js";import{EsriPromise as g}from"../../core/Promise.js";import{isAbortError as v,throwIfAborted as y,waitTick as f}from"../../core/promiseUtils.js";import w from"../../core/ReactiveMap.js";import{whenOnce as _,on as F,watch as b,syncAndInitial as M,initial as V,when as S}from"../../core/reactiveUtils.js";import{sqlAnd as I}from"../../core/sql.js";import{getMetersPerUnitForSR as P}from"../../core/units.js";import{property as C,subclass as A}from"../../core/accessorSupport/decorators.js";import{isSerializable as k}from"../../core/support/jsonUtils.js";import{UpdatingHandles as T}from"../../core/support/UpdatingHandles.js";import O from"../../geometry/Extent.js";import L from"../../geometry/Point.js";import{projectAsync as G}from"../../geometry/projectionUtils.js";import E from"../../geometry/SpatialReference.js";import{polygonCentroidPoint as j}from"../../geometry/support/centroid.js";import{isClockwise as R}from"../../geometry/support/coordsUtils.js";import{normalizeMapX as x}from"../../geometry/support/normalizeUtils.js";import{geographicToWebMercator as B}from"../../geometry/support/webMercatorUtils.js";import D from"../../layers/GraphicsLayer.js";import H from"../../layers/MediaLayer.js";import{searchImages as z,getSortedLayerFeatures as N}from"../../layers/orientedImagery/queries.js";import{calculateSuitabilities as U}from"../../layers/orientedImagery/core/bestImageUtils.js";import{createCoveragePolygon as q,computePolygonForInspection as W,resizePolygon as $,checkIfPolygonContainsSelectedPoint as Z}from"../../layers/orientedImagery/core/coverageUtils.js";import{isElevationSource as J}from"../../layers/orientedImagery/core/ElevationSourceDefinitions.js";import{getMetersPerUnitOfSR as K,convertGeographicToWebMercator as Q}from"../../layers/orientedImagery/core/utils.js";import X from"../../layers/orientedImagery/transformations/updateElevation.js";import{getElevationSampler as Y}from"../../layers/orientedImagery/transformations/updateElevationUtils.js";import{or as ee,getInitialAngle as te,convertPixelLocationToSphereVertex as ie,getUpdateElevationProps as re,getImageToWorldProperties as ae,getImageToWorldPanoramicProperties as se}from"../../layers/orientedImagery/transformations/utils.js";import oe from"../../layers/support/ExtentAndRotationGeoreference.js";import{getFloorFilterClause as ne}from"../../layers/support/floorFilterUtils.js";import le from"../../layers/support/VideoElement.js";import ce from"../../views/MapView.js";import de from"../../views/draw/Draw.js";import{scale as ue}from"../../views/draw/support/drawUtils.js";import{ViewEventPriorities as he}from"../../views/input/InputManager.js";import pe from"../PanoramicVideoViewer.js";import me from"../PanoramicViewer.js";import{defaultAngleThresholdInDegrees as ge,videoMapViewConstraint as ve,fixedImageSize as ye,clockwiseDirections as fe,videoFitScaleTolerance as we,videoExtent as _e,invalidCameraHeading as Fe,sectorsInOrder as be,sampleExtent as Me,sectorsRadii as Ve}from"./constants.js";import{isFeatureAttachment as Se}from"./galleryUtils.js";import{crossSymbol as Ie,crossSymbol3D as Pe,measurementPolygonSymbol as Ce,polylineSymbolPanoramic as Ae,measurementPolylineSymbol as ke,cameraOverlaySymbol3D as Te,cameraOverlaySymbol as Oe,diamondSymbol as Le,diamondSymbol3D as Ge,activeSourcePointSymbol as Ee,sourcePointSymbol as je}from"./symbols.js";import{registryKeys as Re}from"./types.js";import{isNoAttachmentError as xe,extractHorizonAnglesFromMedia as Be,isTifOrMrf as De,filterOILLayerView as He,assignElevationSampleToFeatures as ze,filterByZ as Ne,createPanoramicMedia as Ue,createNonPanoramicMedia as qe,isSceneView as We,isGraphic as $e,calculateSegment as Ze,calculateDirection as Je}from"./utils.js";import{disableVideoZoomAndPan as Ke,getUpdatedConstraints as Qe,getUpdatedExtentPoints as Xe}from"./videoViewerUtils.js";import Ye from"./components/ImageViewer.js";import et from"./components/NavigationNode.js";import tt from"./components/OrientedImageryVideoViewModel.js";import{NoFeatureFoundWithObjectIdError as it}from"./navigation/errors.js";import{queryFeatureByObjectIds as rt}from"./navigation/queries.js";import{ImageMeasurementService as at}from"./services/ImageMeasurementService.js";import st from"./services/SuperimposeService.js";import{configureSketchTool as ot,extractFieldsFromDataCaptureLayer as nt,constructGraphicFromImageGeometry as lt}from"./support/dataCaptureUtils.js";import{removeZFromGeometry as ct,imageSpaceToPoint as dt}from"./support/geometryUtils.js";import ut from"./support/resolveMediaProps.js";import{isValidDataCaptureLayer as ht}from"./support/typeUtils.js";const pt=()=>new n("orientedimageryviewer:sketch-not-initialized","Sketch property is not initialized, call loadSketch first");let mt=class extends(l(g)){constructor(e){super(e),this.additionalFeatures=new s,this.additionalCameraLocations=new s,this.additionalFootprints=new s,this.areaMeasurementResult=0,this.areaMeasurementAccuracy=0,this.bestFeatureAngle=0,this.bestFeatureCurrentFootprint=null,this.bestFeatureFootprint=null,this.cameraHeadingThreshold=ge,this.cameraPitchThreshold=ge,this.clickAction="hittest",this.correctedLocationPointOnImage=null,this.videoViewModel=null,this.collectionId=null,this.coverageFrustums=new s,this.coveragePolygons=new s,this.currentBestFeature=null,this.currentBestFeatureMeasurementImage=null,this.currentBestFeatureLocation=null,this.currentCoverageVisible=!0,this.depthImage=null,this.featureCache=[],this.navigationNodes=new s,this.determineWorkflowForFeature=async(e,t,i)=>{const{currentBestFeature:r,selectedPoint:a}=this;if(this.emit("popup-close"),r&&a){this.displayMessage=null,this._initialCurrentCoverageUpdate=!0,this._updateGroundElevation=!0;try{await this._updatePointsAndPolygons(i),await this._loadDepthImage(i),await this._loadCurrentFeatureMedia(r,i)}catch(s){v(s)||(this.loadImageError(s),u.getLogger(this).error("#loadIImage()","error occured while loading image",s))}}},this.determineWorkflowForTriangularMeasurement=async(e,t,i)=>{if(this.emit("popup-close"),this.currentBestFeatureMeasurementImage&&this.selectedPoint)try{await this._loadMeasurementViewerImage(i)}catch(r){v(r)||(this.loadImageError(r),u.getLogger(this).error("#loadIImage()","error occured while loading image",r))}},this.disabled=!1,this.displayMessage={key:"onLoadMessage",type:"info"},this.displayNewMeasurementButton=!0,this.distanceMeasurementResult=0,this.distanceAccuracyArray=[],this.dataCaptureLayer=null,this.features=new s,this.groundCoordinates=null,this.groundCoordinatesAccuracy=null,this.heightGraphic=null,this.heightMeasurementResult=0,this.heightMeasurementAccuracy=0,this.imageGeometryField=null,this.imageLocationToolState=!1,this.initialVideoMapViewExtent=null,this.imageMeasurementViewer=new Ye,this.isAdditionalCoverageVisible=!1,this.isAdditionalPointSourcesVisible=!1,this.layer=null,this.localPort=null,this.locationPointOnImage=null,this.mapImageConversionToolState=!1,this.measureType=null,this.measurementGraphic=null,this.navigatorCurrentBestFeature=null,this.oiObjectIdField=null,this.overlayedCameraLocations=new s,this.overlayedMapFeatures=new w,this.pixelCoordinates=null,this.preserveAngle="none",this.pointSources=new s,this.preloadMedia=!1,this.preloadMediaSize=5,this.previousFeatureAngle=0,this.selectedPoint=null,this.shouldShowSelectedImage=!1,this.superimposeViewEnabled=!1,this.defaultSuperimposeCameraLockEnabled=!0,this.sketch=null,this.sketchTriangular=null,this.sketchTriangularGraphicsLayer=null,this.draw=null,this.drawAdapter=null,this.polylineDrawAction=null,this.scheduledFrameId=null,this.superimposeScheduledFrameId=null,this.superimposeDebounceTimeoutId=null,this.sketchAdapter=null,this.triangularMeasurementActive=!1,this.triangulatedDistanceMeasurement=null,this.triangulatedDistanceAccuracy=null,this.triangulatedAreaMeasurement=null,this.triangulatedAreaAccuracy=0,this.triangulatedMeasurementGraphic=null,this.triangulatedPoint=null,this.triangulatedMeasurementAdapter=null,this.updateFootprint=async(e,t,i)=>{"default"===this.mode&&"image-loaded"!==this.state||await(this._adapter?.updateFootprint(e,t,i))},this.updateVideoFootprint=async e=>{this.mode.includes("video")&&this.videoElement?.content&&await(this._adapter?.updateVideoFootprint(e))},this.updateFootprintPanorama=async(e,t)=>{await(this._adapter?.updateFootprintPanorama(e,t))},this.updatingTriangularMeasurementState=!1,this.videoElement=null,this.videoLayer=null,this.videoMapView=new ce({map:new Map,constraints:ve}),this.verticalFilterEnabled=!1,this._adapter=null,this._highlightedFeatureHandle=null,this._imageViewer=new Ye,this._initialCurrentCoverageUpdate=!0,this._locationViewModel=null,this._measurementService=null,this._mediaPrefetcher=null,this._navigationManager=null,this._overlays=new D({listMode:"hide",internal:!0,elevationInfo:{mode:"absolute-height"},title:"OrentedImageryViewerViewModel overlays layer"}),this._superimposePreviousCurrentCoverageVisible=null,this._superimposeService=new st({getMapPoint:(e,t)=>this.getMapPoint(e,t),pointToPixel:(e,t)=>this._transformationService.pointToPixel(e,t),overlays:this._overlays}),this._panoramicVideoViewer=new pe,this._panoramicViewer=new me,this._panoramicMeasurementViewer=new me,this._referencePointOnGround=null,this._referencePointOnImage=null,this._referenceTransformationService=null,this._sectorData=null,this._transformationService=null,this._featureToSector=null,this._updatingHandles=new T,this._clickTask=null,this._crossSymbol=null,this.footprintExtent=null,this._featureChangedTask=null,this._mediaPrefetchTask=null,this._restoreSuperimposeMediaTask=null,this._superimposeScheduleController=null,this._suitabilities=null,this._transformController=new AbortController,this._updateFootprintTask=null,this._updateGroundElevation=!1,this.addUpdatingPromise=e=>this._updatingHandles.addPromise(e),this.filterCapturedFeatures=e=>{const t=this.currentBestFeature?.attributes.objectId,i=this.layer?.imageReferenceField;if(!t||!e||!i)return;const r=this.overlayedMapFeatures.get(e);r?.forEach(e=>{const r=e.attributes??{},a=Object.keys(r).find(e=>e.toLowerCase()===i.toLowerCase());(a?r[a]:null)!==t&&(e.visible=!e.visible)})},this.hideImageGeometry=e=>{},this.highlight=e=>{if(!this._overlaysView)return;this.removeHighlight();const t=this.additionalFootprints.find(({attributes:{imageID:t}})=>t===Number(e));this._highlightedFeatureHandle=t?this._overlaysView?.highlight(t):null},this.loadDataCaptureAdapter=async e=>{await this.loadSketch(e);const t=import("./adapters/sketch/DataCaptureAdapter.js"),{default:i}=await t;return y(e),this.sketchAdapter=new i({viewModel:this}),this.sketchAdapter},this.loadImageFromFeature=(e,t,i)=>this._updatingHandles.addPromise(this._loadImageFromFeature(e,t,i)),this.storeImageMeasurementViewer=e=>{this.imageMeasurementViewer=e},this.storePanoramicMeasurementViewer=e=>{this._panoramicMeasurementViewer=e},this.loadImageViewer=e=>{this._imageViewer?.destroy(),this._imageViewer=e},this.loadPanoramicViewer=e=>{this._panoramicViewer?.destroy(),this._panoramicViewer=e},this.loadPanoramicVideoViewer=e=>{this._panoramicVideoViewer?.destroy(),this._panoramicVideoViewer=e},this.loadVideoViewer=e=>{this.videoMapView.container=e},this.showImageByObjectId=async(e,t)=>{const i=this.additionalFeatures.find(({attributes:t})=>t.objectId===e);if(i)this.currentBestFeature=i;else{const{layer:i,layerFloorFilterClause:a,layerTimeExtent:s}=this;if(!i)return void this.setMessage("noLayerSelected","info");this.beforeLoad();const o=this._updatingHandles.addPromise(this._queryAndLoadByObjectId(i,e,a,s,t));try{await o,await this.selectBestFeature(e,t)}catch(r){v(r)||(u.getLogger(this).error("oriented-imagery-viewer:show-image",r),"NoFeatureFoundWithObjectIdError"===r.name?this.setMessage("noFeatureFoundWithObjectId","error","",{objectId:e}):this.setMessage("imageLoadError","error",r.message))}}},this.getSectorFeatureById=e=>this._suitabilities?.find(({feature:{attributes:{objectId:t}}})=>t===e),this.getFeatureSectorById=e=>this._featureToSector?.[`${e}`],this.navigate=async(e,t)=>{const{mode:i}=this;if("default"!==i&&"panoramic"!==i)throw new n("NavigationError","Navigation is only supported in 'default' and 'panoramic' modes.");const r=e=>"default"===i&&e.declaredClass.endsWith("NavigationManager")||"panoramic"===i&&e.declaredClass.endsWith("NavigationManagerPanoramic");if(null==this._navigationManager||!r(this._navigationManager)){p(this._navigationManager);const e="default"===i?import("./navigation/NavigationManager.js"):import("./navigation/NavigationManagerPanoramic.js");this._navigationManager=new(await e).default({viewModel:this})}return this._navigationManager.navigate(e,t)},this.removeHighlight=()=>this._highlightedFeatureHandle?.remove(),this.revealImageGeometry=e=>{},this.selectBestFeature=async(e,t)=>(y(t),this.currentBestFeature=this.features?.find(({attributes:t})=>`${t.objectId}`==`${e}`),_(()=>{switch(this.mode){case"video":return"video-loaded"===this.state;case"panoramic-video":return this.panoramicVideoLoaded;default:return"image-loaded"===this.state}},t)),this.toggleImageAttributes=()=>{const{currentBestFeature:e,popupEnabled:i,layer:r,view:a}=this;if(this.emit("popup-close"),!(a&&e&&i&&r))return;const{attributes:s,geometry:o}=e,n=new t({geometry:o,attributes:s.toJSON(),origin:r.graphicOrigin,sourceLayer:r});this.emit("popup-open",{features:[n],location:s.location.clone()})},this.updateSuitabilities=(e,t=!0)=>{e.sort((e,t)=>e.suitability-t.suitability),this._suitabilities=e;const i=this._suitabilities.map(({feature:e})=>e);this._initialCurrentCoverageUpdate=!0,this._updateFeatures(i,t),this._groupFeaturesBySectors()},this._computeOverlayImageSize=()=>{const{mode:e}=this;return"video"===e?ye:"panoramic-video"===e?this._panoramicVideoViewer.imageSize:this.activeViewer?.imageSize},this._geometryToOverlayImageGeometry=async(e,t,i)=>{const{mode:r,videoViewModel:a,_panoramicVideoViewer:s}=this;if("video"===r)return await(a?.geometryToOverlayGeometry(e,t))??null;if("panoramic-video"===r){const a={feature:t,mode:r,imageSize:i,footprintExtent:this.footprintExtent};return await this._transformationService.geometryToImageGeometryForFeature(e,a,s.horizonAngles)}return await this._transformationService.geometryToImageGeometry(e)},this._createViewClickHandle=()=>{if(this.removeHandles(Re.click),this.disabled||null==this.view)return;const e=this.mapImageConversionToolState&&("image-loaded"===this.state||"video-loaded"===this.state&&"video"===this.mode&&!!this.videoViewModel?.videoPaused||this.panoramicVideoLoaded&&"panoramic-video"===this.mode&&this.panoramicVideoPaused)?this._mapImageConversionToolViewClickHandler:this._viewClickHandler;this.addHandles(this.view.on("click",e,he.DEFAULT),Re.click)},this._createImageClickHandle=()=>{this.removeHandles(Re.imageClick),this.videoViewModel?.syncMapImageConversionHandle();const{mapImageConversionToolState:e,mode:t,footprintExtent:i,panoramicVideoLoaded:r}=this,s="panoramic-video"===t?this._panoramicVideoViewer:this.activeViewer,o=s?.imageSize;if(!e||"none"===t||"video"===t||!o||!i)return;const n="panoramic-video"===t,l=this._getActiveFeatureForCurrentMode(),d=!n||r&&this.panoramicVideoPaused;if(!l||!d)return;const u=s.clickAction;this.clickAction="pixel-location";const h=c(()=>{this.clickAction=u});let p=null;const m=F(()=>s,"pixel-location",e=>{this.plotReferencePointOnImage(e),p?.abort(),p=a(async r=>{if(!e)return;const a=this._getActiveFeatureForCurrentMode();if(!a)return;const s={feature:a,mode:t,imageSize:o,footprintExtent:i};let l=n?await this.getMapPointForFeature(e,s,{signal:r}):await this._transformationService.pixelToMapPoint(e);const c=this.view?.spatialReference;l&&!ee(!c,l.spatialReference.equals(c))&&(l=await G(l,c,{signal:r})),y(r),this.plotReferencePointOnGround(l)})});this.addHandles([m,h],Re.imageClick)},this._createTriangularImageClickHandle=()=>{this.removeHandles(Re.triangularImageClick),this.triangularMeasurementActive&&"none"!==this.mode&&this.currentBestFeature&&this.currentBestFeatureMeasurementImage&&this.activeTriangulatedViewer&&this.addHandles(this.activeTriangulatedViewer.imageRenderer.on("double-click",this._measurementImageClickHandler),Re.triangularImageClick)},this._enablePan=()=>{this.removeHandles(Re.videoPanHandles)},this._disablePan=()=>{this.removeHandles(Re.videoPanHandles),this.addHandles(Ke(this.videoMapView),Re.videoPanHandles)},this._handleImageHitTestResponse=async e=>{const{layer:t,overlayedCameraLocations:i}=this;if(!t)return;const r=e.results.find(({graphic:e,graphic:{attributes:r}})=>i.includes(e)&&r&&!r[t.imageReferenceField]&&!r[t.imageGeometryField]);if(!r)return;const a=r.graphic.attributes[t.objectIdField];await this.showImageByObjectId(a)},this._loadCurrentFeatureMedia=async(e,t)=>{if("video"===this.mode)return this._initializeVideo(),void this.videoViewModel?.playVideoFromSelectedLocation(e);"panoramic-video"!==this.mode?await this._loadImage(t):await this._loadVideo(t)},this._loadDepthImage=async e=>{const{currentBestFeature:t,layer:i,depthImageNotSupported:r}=this;if(this.depthImage?.destroy(),this.depthImage=null,!i||!t||r)return;const{depthImage:a}=t.attributes;if(!a)return;const s=(await import("./services/DepthImageService.js")).default;y(e),this.depthImage=new s({url:a});try{await this.depthImage.load(e)}catch(o){v(o)||(u.getLogger(this).error("error occurred while loading depth image",o),this.depthImage?.destroy(),this.depthImage=null)}},this._loadImage=async e=>{const{currentBestFeature:t,layer:i,mode:r}=this;if(this.clearGraphics(),i&&t&&"none"!==r&&"video"!==r&&"panoramic-video"!==r)try{await this.loadImageFromFeature(i,t,e),y(e),await this.transformAndPlotSelectedLocation(e)}catch(a){v(a)||this.loadImageError(a)}},this._loadVideo=async e=>{const{currentBestFeature:t,mode:i,selectedPoint:r}=this,a=t?.attributes.imagePath;if(!t||"panoramic-video"!==i||!a)return;const{attributes:s}=t,{cameraPitch:o,cameraOrientation:n,location:l}=s,c=l.spatialReference.isWGS84&&4!==n?.type?B(l):new L(l);try{this._panoramicVideoViewer.viewModel.video&&(this._panoramicVideoViewer.viewModel.video.pause(),this._panoramicVideoViewer.viewModel.videoPaused=!0),this._panoramicVideoViewer.videoSource=a;let t=0;c&&r&&(t=await te(c,r)-t),this._panoramicVideoViewer.pitch=o??0,this._panoramicVideoViewer.yaw=t,await this._panoramicVideoViewer.loadVideo(e),y(e)}catch(d){v(d)||this.loadImageError(d)}},this._loadImageFromFeature=async(e,t,i)=>{const{mode:r}=this;if("default"!==r&&"panoramic"!==r)return;let a;try{a=await ut(t.attributes,e,i),y(i)}catch(f){if(v(f))return;return xe(f)?(u.getLogger(this).error(f),void this.setMessage("noAttachment","error",`${e.objectIdField}: ${t.attributes.objectId}`)):(u.getLogger(this).error(f,{[e.objectIdField]:t.attributes.objectId,layer:e}),void this.setMessage("imageLoadError","error",`query-attachments-failed:${e.objectIdField} ${t.attributes.objectId}`))}if(!a)return;const{mediaUrl:s,datasetFormat:o,rotation:n,searchParams:l,location:c,cameraHeading:d,matrix:h,cameraPitch:p,getDataSetFormatError:m}=a,g=`${t.attributes.objectId}`;try{let a=this._mediaPrefetcher?.getCachedMedia(g);if(!a){const i=this.navigationNodes.find(e=>e.id===t.attributes.objectId);if(i){try{await(this._mediaPrefetcher?.startPrefetchForNode(i,e))}catch(w){}a=this._mediaPrefetcher?.getCachedMedia(g)}}if(a){if("panoramic"===r){const e=this.triangularMeasurementActive?this._panoramicMeasurementViewer:this._panoramicViewer;let r=0;return c&&this.selectedPoint&&(r=await te(c,this.selectedPoint)-r),await e.loadMedia(a,i),this.selectedPoint?e.set({yaw:r,pitch:p}):"viewAngle"in t.attributes&&Number.isFinite(t.attributes.viewAngle)&&e.set({yaw:t.attributes.viewAngle,pitch:p}),void(this.triangularMeasurementActive?await this.initializeReferenceTransformationService(i):await this.initializeTransformationService(i))}return await this._setImageSource(this.triangularMeasurementActive?this.imageMeasurementViewer:this._imageViewer,a,i),void(this.triangularMeasurementActive?await this.initializeReferenceTransformationService(i):await this.initializeTransformationService(i))}}catch(w){}m&&u.getLogger(this).warn("error occurred while getting dataset format",m),"panoramic"===r?await this.loadPanoramicMediaSource({lookAt:{yaw:this.selectedPoint?await te(c,this.selectedPoint):"viewAngle"in t.attributes&&Number.isFinite(t.attributes.viewAngle)?t.attributes.viewAngle:0,pitch:p},extension:o?.toUpperCase(),url:s,cameraHeading:d,matrix:h},i):await this.loadMediaSource({datasetFormat:o?.toUpperCase(),url:s,customParameters:l,rotation:n},i),this.triangularMeasurementActive?await this.initializeReferenceTransformationService(i):await this.initializeTransformationService(i)},this._loadMeasurementViewerImage=async e=>{const{currentBestFeatureMeasurementImage:t,layer:i,mode:r}=this;if(this.imageMeasurementViewer.clearGraphics(),this._panoramicMeasurementViewer.clearGraphics(),i&&t&&"none"!==r&&"video"!==r&&"panoramic-video"!==r)try{await this.loadImageFromFeature(i,t,e),y(e)}catch(a){v(a)||this.loadImageError(a)}},this._loadMediaPrefetcher=async e=>{if(!this._mediaPrefetcher){const{default:t}=await import("./support/MediaPrefetcher.js");y(e),this._mediaPrefetcher=new t({maxEntries:this.preloadMediaSize*fe.length})}return this._mediaPrefetcher},this._loadViewAdapter=async e=>{const{view:t}=this;if(this._adapter?.disableDefaultSuperimposeNavigation?.(),this._adapter?.disablePanoramicSuperimposeNavigation?.(),t)switch(t.type){case"2d":{const{default:t}=await import("./adapters/view/MapViewAdapter.js");y(e),this._adapter=new t(this);break}case"3d":{const{default:t}=await import("./adapters/view/SceneViewAdapter.js");y(e),this._adapter=new t(this);break}}else this._adapter=null},this._mapImageConversionToolViewClickHandler=e=>{if(e.stopPropagation(),e.preventDefault(),e.mapPoint){const t=e.mapPoint;t.x=x(t.x,t.spatialReference),this.plotMapPoint(e.mapPoint)}},this._measurementImageClickHandler=e=>{e.stopPropagation(),e.preventDefault();const{sketchTriangular:t,triangularMeasurementActive:i,currentBestFeatureMeasurementImage:r,triangulatedMeasurementGraphic:a}=this;t&&i&&r&&a&&"active"!==t.state&&(t.update([a],{tool:"reshape"}),this.updatingTriangularMeasurementState=!0)},this._updateInteraction=()=>{const e=this.videoMapView.extent;if(!e)return;const{minScale:t}=this.videoMapView.constraints,i=this.videoMapView.scale<t-we,r=Qe(e);i&&!!r?(this._enablePan(),this.videoMapView.constraints.geometry=r):i?(this._disablePan(),this.videoMapView.constraints.geometry=null):(this.initialVideoMapViewExtent&&!this.videoMapView.extent.equals(this.initialVideoMapViewExtent)&&(this.videoMapView.extent=this.initialVideoMapViewExtent),this._disablePan(),this.videoMapView.constraints.geometry=null)},this._viewClickHandler=e=>{this._clickTask?.abort(),this._clickTask=a(async t=>{const{pointerType:i,button:r,mapPoint:a}=e;if("mouse"===i&&0!==r||!a)return;e.stopPropagation(),e.preventDefault();const{view:s,layer:o}=this;if(s){if(o){if(this.shouldShowSelectedImage){const i=s.hitTest(e,{include:[o]});this._updatingHandles.addPromise(i);const r=await i;return y(t),await this._processHitTestResults(o,r,{signal:t})}return this._updatingHandles.addPromise(this.loadBestImage(a,{signal:t}))}this.setMessage("noLayerSelected","info")}})},this.plotSelectedPointOnImage=async(e,i)=>{if(await f(i),!e)return;const r=new L({...k(e)?e.toJSON():e});if("default"===this.mode)r.x-=.5,r.y=.5-r.y,r.spatialReference=this._imageViewer.imageRenderer.spatialReference.clone(),this._crossSymbol=new t({geometry:r,symbol:Ie}),this._imageViewer.addGraphic(this._crossSymbol,0);else if("panoramic"===this.mode){const{imageSize:i,media:r}=this._panoramicViewer;if(!i||!r)return;const a=Be(r),s=ie(e,...i,a);this._crossSymbol=new t({geometry:new L(s,E.WebMercator),symbol:Pe}),this._panoramicViewer.addGraphic(this._crossSymbol,0)}},this.handleSectorClick=this.handleSectorClick.bind(this),this.searchBestImage=this.searchBestImage.bind(this),this.transformAndPlotReferencePointOnImage=this.transformAndPlotReferencePointOnImage.bind(this)}initialize(){this.addHandles([b(()=>this.view,()=>this.load(),M),b(()=>this.view?.map,(e,t)=>{t?.layers.remove(this._overlays),e?.layers.add(this._overlays)},V),b(()=>this.view?.map?.allLayers?.length,e=>{e&&this.view?.map?.layers.reorder(this._overlays,e-1)},V),b(()=>[this.state,this.panoramicVideoLoaded,this.mapImageConversionToolState,this.view,this.disabled,this.panoramicVideoPaused,this.videoViewModel?.videoPaused],(e,t)=>{const i=e[2],r=t?.[2];r&&!i&&(this.plotReferencePointOnGround(null),this.clearReferencePointOnImage()),this._createViewClickHandle(),this._createImageClickHandle()},M),b(()=>[this.triangularMeasurementActive,this.currentBestFeatureMeasurementImage],()=>{this._createTriangularImageClickHandle()},M),b(()=>[this.state,this.imageLocationToolState,this.view],()=>{this._initializeMeasurementService(),this._initializeLocationViewModel()},M),b(()=>this.measureType,()=>{this.clearPreviousMeasurements(),this._initializeMeasurementService()},M),b(()=>this.bestFeatureAngle,(e,t)=>{this.previousFeatureAngle=t??0},M),b(()=>[this.superimposeViewEnabled,this.defaultSuperimposeCameraLockEnabled,this.superimposeViewSupported,this.currentBestFeature,this.mode,this.state,this.view?.type],()=>{this._shouldDisableUnsupportedSuperimposeView()?this.superimposeViewEnabled=!1:this._hasActiveSuperimposeCameraContext()?this._updateSuperimposedImage():this._resetInactiveSuperimposeState()},M),b(()=>this._getSuperimposeCameraWatchState(),()=>this._handleSuperimposeCameraChange(),M),b(()=>this.currentBestFeature,async(e,t)=>{m(this._featureChangedTask),this._featureChangedTask=a(async i=>this.determineWorkflowForFeature.apply(this,[e,t,{signal:i}])),await this._featureChangedTask.promise},{sync:!0}),b(()=>[this.currentNode,this.preloadMedia,this.navigationMode],()=>{this._mediaPrefetchTask?.abort(),this._mediaPrefetchTask=a(async e=>{this.preloadMedia&&null!=this.navigationMode?(this._mediaPrefetcher??=await this._loadMediaPrefetcher({signal:e}),y(e),"directional"===this.navigationMode?this._mediaPrefetcher.enqueueDirectionalPrefetch(this.layer,this.currentNode,this.preloadMediaSize):this._mediaPrefetcher.enqueueSequentialPrefetch(this.layer,this.currentNode,this.preloadMediaSize)):this._mediaPrefetcher?.clear()})},M),b(()=>this.currentBestFeatureMeasurementImage,(e,t)=>{m(this._featureChangedTask),t&&e!==t&&(this.triangulatedPoint=null,this.sketchTriangularGraphicsLayer?.graphics.destroyAll(),this._measurementService?.resetMeasurementVectors()),this._featureChangedTask=a(async i=>{await this.determineWorkflowForTriangularMeasurement(e,t,{signal:i}),y(i),this._reorderTriangularSketchLayer()})},M),b(()=>this.triangularMeasurementActive,(e,t)=>{t&&!e&&(this._measurementService?.resetMeasurementVectors(),this.currentBestFeatureMeasurementImage=null,this.triangulatedDistanceMeasurement=null,this.triangulatedMeasurementGraphic=null,this.triangulatedPoint=null,this.updatingTriangularMeasurementState=!1,this.triangulatedAreaMeasurement=null,this.triangulatedDistanceAccuracy=null,this.triangulatedAreaAccuracy=0,this.sketchTriangularGraphicsLayer?.graphics.destroyAll(),this.clearReferencePointOnImage(),this.imageMeasurementViewer.clearImage(),this.imageMeasurementViewer.clearGraphics(),this._panoramicMeasurementViewer.clearImage(),this._panoramicMeasurementViewer.clearGraphics())}),b(()=>this.mode,e=>{switch(this.removeHandles(Re.interactionHandles),e){case"default":this.addHandles(b(()=>{const{state:e}=this;return"image-loaded"===e?this._imageViewer.imagePointsInView:null},e=>{e&&(m(this._updateFootprintTask),this._updateFootprintTask=a(async t=>{await this.updateFootprint(e,void 0,{signal:t})}))},{...M,equals:(e,t)=>i(e,t,d)}),Re.interactionHandles);break;case"video":this.addHandles(b(()=>{const{footprintExtent:e,videoElement:t,bestFeatureFootprint:i}=this;if(e&&t?.loaded&&i)return{videoExtent:_e,bestFeatureFootprint:i}},e=>{e?.videoExtent&&e?.bestFeatureFootprint&&(m(this._updateFootprintTask),this._updateFootprintTask=a(async t=>{const i={points:e.videoExtent,feature:void 0,scale:void 0,options:{signal:t}};await this.updateVideoFootprint(i)}))},{...M,equals:(e,t)=>i(e?.videoExtent,t?.videoExtent,d)&&e?.bestFeatureFootprint===t?.bestFeatureFootprint}),Re.interactionHandles);break;case"panoramic":this.addHandles(b(()=>{const{currentBestFeature:e,state:t,_panoramicViewer:i}=this,{imageSize:r,vfov:a,hfov:s,pitch:o,yaw:n}=i;return e&&r&&!t.includes("loading")&&null!=a&&null!=s&&null!=o&&null!=n?[a,s,n,o]:null},e=>{if(!e||this.state.includes("loading"))return;const[t,i,r,s]=e;this.currentNode&&(this.currentNode.currentHeading=r,this.currentNode.currentPitch=s),m(this._updateFootprintTask),this._updateFootprintTask=a(async e=>{await this.updateFootprintPanorama({verticalFieldOfView:t,horizontalFieldOfView:i,yaw:r,pitch:s},{signal:e}),this._updateFootprintTask=null})},{equals:(e,t)=>i(e,t,d)}),Re.interactionHandles);break;case"panoramic-video":this.addHandles(b(()=>{const{currentBestFeature:e,state:t,_panoramicVideoViewer:i}=this,{imageSize:r,vfov:a,hfov:s,pitch:o,yaw:n,viewModel:l}=i,c=l.closestFeature??e;return c&&r&&!t.includes("loading")&&null!=a&&null!=s&&null!=o&&null!=n?[a,s,n,o,c]:null},e=>{if(!e)return;const[t,i,r,s,o]=e;m(this._updateFootprintTask),this._updateFootprintTask=a(async e=>{await this.updateFootprintPanorama({verticalFieldOfView:t,horizontalFieldOfView:i,yaw:r,pitch:s,feature:o,horizonAngles:this._panoramicVideoViewer.horizonAngles},{signal:e}),y(e),this._updateFootprintTask=null})},{equals:(e,t)=>i(e,t,d)}),Re.interactionHandles)}},M),b(()=>[this.brightness,this.contrast,this.sharpness],()=>{const{_imageViewer:e,brightness:t,contrast:i,mode:r,sharpness:a}=this;"default"===r&&(e.brightness=t,e.contrast=i,e.sharpness=a)},M),b(()=>this.activeViewer?.imageRenderer,()=>{this.sketch&&(this.sketch.view=this.activeViewer?.imageRenderer)}),b(()=>this.activeViewer,e=>{this.removeHandles(Re.hittestHandles),e&&this.addHandles(F(()=>e,"hittest-response",this._handleImageHitTestResponse),Re.hittestHandles)}),b(()=>this.videoMapView.extent,async()=>{this._scheduleVideoInteractionUpdate();const e=this.videoViewModel?.closestFeature;e&&(m(this._updateFootprintTask),this._updateFootprintTask=a(async t=>{const i={points:this.videoExtentPoints,feature:e,options:{signal:t}};await this.updateVideoFootprint(i)}))}),b(()=>[this.videoMapView.interacting,this.videoMapView.navigating,this.videoMapView.scale],()=>{this._scheduleVideoInteractionUpdate()},{initial:!0}),S(()=>null!=this.videoMapView.extent,()=>{this.initialVideoMapViewExtent=this.videoMapView.extent},{once:!0})]),this.when().finally(()=>{this.notifyChange("state")})}destroy(){this._adapter?.disableDefaultSuperimposeNavigation?.(),this._adapter?.disablePanoramicSuperimposeNavigation?.(),this._abortSuperimposeSchedule(),this.currentBestFeature=null,this._updateFootprintTask=m(this._updateFootprintTask),this._clickTask=m(this._clickTask),this._restoreSuperimposeMediaTask=m(this._restoreSuperimposeMediaTask),this.coverageFrustums.destroy(),this.coveragePolygons.destroy(),this.pointSources.destroy(),this.additionalFootprints.destroy(),this.additionalCameraLocations.destroy(),this.bestFeatureFootprint=p(this.bestFeatureFootprint),this.bestFeatureCurrentFootprint=p(this.bestFeatureCurrentFootprint),this.videoViewModel=p(this.videoViewModel),this._locationViewModel=p(this._locationViewModel),this._crossSymbol=p(this._crossSymbol),this._referencePointOnGround=p(this._referencePointOnGround),this.clearReferencePointOnImage(),this._superimposeService.destroy(),this._overlays&&this.view?.map?.remove(this._overlays),this._overlays.destroy(),this._imageViewer.destroy(),this.imageMeasurementViewer.destroy(),this._panoramicViewer.destroy(),this._panoramicMeasurementViewer.destroy(),this._mediaPrefetcher?.destroy()}get activeLayer(){return o(u.getLogger(this),"activeLayer",{replacement:"layer"}),this.layer}set activeLayer(e){o(u.getLogger(this),"activeLayer",{replacement:"layer"}),this.layer=e}get activeViewer(){const{_imageViewer:e,_panoramicViewer:t,mode:i}=this;switch(i){case"default":return e;case"panoramic":return t;default:return null}}get activeTriangulatedViewer(){switch(this.mode){case"default":return this.imageMeasurementViewer;case"panoramic":return this._panoramicMeasurementViewer;default:return null}}get accuracyParametersMissing(){return this.layer?.orientationAccuracy?.every(e=>0===e)??!0}get brightness(){return this._get("brightness")??0}set brightness(e){this._set("brightness",h(e,-10,10))}get contrast(){return this._get("contrast")??0}set contrast(e){this._set("contrast",h(e,-10,10))}get currentNode(){const{currentBestFeature:e,navigationNodes:t}=this;return t.find(t=>t.id===e?.attributes.objectId)}get depthImageNotSupported(){if(this.currentBestFeature?.attributes.depthImage)return!De(this.currentBestFeature.attributes.depthImage)}get featureCount(){return this.features?.length??0}get imageGalleryEnabled(){const{currentBestFeature:e}=this;if(!e)return!1;const t=e.attributes.imagePath?.trim();return De(t)||Se(t)}get imageLoaded(){return o(u.getLogger(this),"imageLoaded",{replacement:'Use OrientedImageryViewer.state === "image-loaded"',version:"4.29",warnOnce:!0}),"image-loaded"===this.state}get invalidCameraHeading(){return this.currentBestFeature?.attributes?.cameraHeading===Fe}get imagePointsInView(){const{mode:e,_imageViewer:t}=this;return"default"===e?t.imagePointsInView:null}get layerView(){const{layer:e,view:t}=this;if(e&&t)return t.allLayerViews.find(He(e))}get layerFloorFilterClause(){const{layerView:e}=this;return e?ne(e):null}get layerTimeExtent(){return this.layerView?.timeExtent??null}get mode(){const e=this.currentBestFeature?.attributes;if(!e)return"none";const t=e.orientedImageryType;if(t?.includes("video"))return t.includes("360")?"panoramic-video":"video";const{horizontalFieldOfView:i,isSpherical:r}=e;return 360===i||r?"panoramic":"default"}get panoramicVideoLoaded(){const{mode:e,_panoramicVideoViewer:t}=this,{videoLoaded:i}=t.viewModel;return("panoramic-video"===e&&!0===i)??!1}get overlayGraphicsEnabled(){const{mode:e,state:t,panoramicVideoLoaded:i,videoViewModel:r,panoramicVideoPaused:a}=this;return"image-loaded"===t||"video"===e&&"video-loaded"===t&&!0===r?.videoPaused||"panoramic-video"===e&&i&&a}get panoramicVideoPaused(){return!!this._panoramicVideoViewer.viewModel.videoPaused}get popupEnabled(){return!0===this.layer?.popupEnabled}get referencePoint(){return this._referencePointOnGround?.geometry}get sectorData(){const{_sectorData:e}=this;return e?be.map(t=>e[t]):null}get sharpness(){return this._get("sharpness")??0}set sharpness(e){this._set("sharpness",h(e,0,1))}get superimposeViewSupported(){return"default"===this.mode||"panoramic"===this.mode}get sketchGraphicsLayer(){const{sketch:e}=this;return"graphics"===e?.layer?.type?e.layer:void 0}get state(){const{mode:e,_updatingHandles:{updating:t},_featureChangedTask:i,_navigationManager:r}=this;if(!this.isFulfilled()||t||!1===i?.finished||r?.navigating)return"loading";if(this.isRejected())return"error";if("error"===this.displayMessage?.type)return"image-load-error";switch(e){case"default":return this._imageViewer.state;case"panoramic":return this._panoramicViewer.state;case"video":return this.videoElement?.loaded?"video-loaded":"video-not-loaded"}return"ready"}get thumbnails(){const{features:e}=this;return e?new s(e.map(({attributes:{imagePath:e,objectId:t,cameraRoll:i,imageRotation:r}})=>{const a=e?.trim();return De(a)||Se(a)?{url:a,objectId:t,rotation:(i??0)+(r??0)}:null}).filter(r)):null}get videoExtentPoints(){const e=Xe(this.videoMapView.extent);return e.length?e:_e}set view(e){this._set("view",e)}get _defaultGraphicsLayer(){const e={blendMode:"source-atop"};switch(this.mode){case"panoramic":return new D({...e,elevationInfo:{mode:"absolute-height"}});case"default":return new D({...e});default:return}}get _overlaysView(){return this.view?.layerViews.find(({layer:e})=>e===this._overlays)}updateSuperimposeZOffset(e){this._superimposeService.updateZOffset(e)}setDefaultSuperimposeZOffsetPercentage(e){this._superimposeService.setDefaultZOffsetPercentage(e)}setPanoramicSuperimposeRadiusPercentage(e){this._superimposeService.setPanoramicRadiusPercentage(e)}updateDefaultSuperimposeCameraLock(e){this.defaultSuperimposeCameraLockEnabled=e,this.superimposeViewEnabled&&"default"===this.mode&&(e?this._adapter?.enableDefaultSuperimposeNavigation?.():this._adapter?.disableDefaultSuperimposeNavigation?.())}beforeLoad(e=!0){this.emit("popup-close"),e&&(this.displayMessage=null),this._abortSuperimposeSchedule(),this._adapter?.disableDefaultSuperimposeNavigation?.(),this._adapter?.disablePanoramicSuperimposeNavigation?.(),this.clearPreviousGroundLocation(),this.triangularMeasurementActive=!1,this.currentBestFeatureMeasurementImage=null,this.measureType=null,this.imageLocationToolState=!1,this.features.removeAll(),this.currentBestFeature=null,this.additionalFeatures.removeAll(),this.additionalFootprints.removeAll(),this.additionalCameraLocations.removeAll(),this.bestFeatureCurrentFootprint=p(this.bestFeatureCurrentFootprint),this._restoreSuperimposeMediaTask=m(this._restoreSuperimposeMediaTask),this._superimposeService.clear(),this._overlays?.removeAll()}async calculateLocationAccuracy(e){return this._measurementService?.calculateLocationAccuracy(e)}clearLocationPointOnImage(e=!1){this.locationPointOnImage&&!e&&(this._imageViewer.removeGraphic(this.locationPointOnImage),this._panoramicViewer.removeGraphic(this.locationPointOnImage),this.locationPointOnImage=p(this.locationPointOnImage)),this.correctedLocationPointOnImage&&(this.imageMeasurementViewer.removeGraphic(this.correctedLocationPointOnImage),this._panoramicMeasurementViewer.removeGraphic(this.correctedLocationPointOnImage),this.correctedLocationPointOnImage=p(this.correctedLocationPointOnImage))}clearPreviousMeasurements(){this.clearMeasurementGraphics(),this.resetMeasurementData(),this.stopMeasurement()}clearPreviousGroundLocation(){this.groundCoordinates=null,this.groundCoordinatesAccuracy=null,this.pixelCoordinates=null,this.clearLocationPointOnImage()}clearMeasurementGraphics(){this.measurementGraphic&&(this.activeViewer?.removeGraphic(this.measurementGraphic),this.measurementGraphic=null),this.heightGraphic&&(this.activeViewer?.removeGraphic(this.heightGraphic),this.heightGraphic=null),this.triangularMeasurementActive&&this.sketchTriangularGraphicsLayer?.graphics.destroyAll()}digitizeCancel(){return this.sketch?.cancel()}digitizeCanRedo(){return this.sketch?.canRedo()??!1}digitizeCanUndo(){return this.sketch?.canUndo()??!1}digitizeComplete(){return this.sketch?.complete()}async digitizeCreate(e,t){const{sketch:i,dataCaptureLayer:r}=this;if(!i)throw pt();ot(r,e,i),await i.create(e,{...t,defaultZ:0})}digitizeDelete(){if(!this.sketch)throw pt();return this.sketch.delete()}digitizeDuplicate(){if(!this.sketch)throw pt();return this.sketch.duplicate()}digitizePlace(e,t){if(!this.sketch)throw pt();return this.sketch.place(e,t)}digitizeRedo(){if(!this.sketch)throw pt();return this.sketch.redo()}digitizeUndo(){if(!this.sketch)throw pt();return this.sketch.undo()}digitizeUpdate(e,t){if(!this.sketch)throw pt();return this.sketch.update(e,t)}filterByFootprints(e,t,i=!1){const r=[],a=[],s=[];return e.forEach(e=>{const{layer:{coveragePercent:o},attributes:n}=e;let l;const{polygon:c,frustum:d}=q(n);if(l=c.clone(),n.isInspection&&(l=W(n)),o&&(l=$(l,o)),i||!t||Z(l,t)){s.push(e);const{geometry:t,objectId:i,cameraHeight:o,cameraHeading:l}=n,u=t.clone();u.z=o/K(t.spatialReference),u.imageID=i,this.pointSources.push(u),l!==Fe&&(r.push(c),d&&a.push(d))}}),{features:s,polygons:r,frustums:a}}async deleteDataCaptureFeatures(e){const{dataCaptureLayer:t}=this;if(!t)throw new n("orientedimageryviewer:missing-featurelayer","Data capture layer is not available");return t.queryFeatures({objectIds:e,outFields:[t.objectIdField]}).then(({features:e})=>t.applyEdits({deleteFeatures:e}))}handleSectorClick(e){if(isNaN(e))return;const t=this._sectorData?.[be[e]],i=t?.at(0);i&&(this.triangularMeasurementActive&&this.currentBestFeature?this._updateImageMeasurementBestFeature(i):this._updateCurrentBestFeature(i))}handleFeatureClick(e){const{sector:t,featureIndexInSector:i}=e;if(isNaN(i))return;const r=this._sectorData?.[t],a=r?.at(i);a&&(this.triangularMeasurementActive&&this.currentBestFeature?this._updateImageMeasurementBestFeature(a):this._updateCurrentBestFeature(a))}load(e){return this.addResolvingPromise(this._loadViewAdapter(e).catch(e=>{if(!v(e))throw e})),this}async loadBestImage(e,t){return this.selectedPoint=Q(e),this.beforeLoad(),this._fetchFeaturesWithController(e,t)}async loadHeightMeasurementAdapter(e){if(!this.drawAdapter){const t=import("./adapters/draw/HeightMeasurementAdapter.js"),{default:i}=await t;if(y(e),this.drawAdapter=new i({viewModel:this,measurementService:this._measurementService}),!this.drawAdapter.viewModel.isResolved())return}return this.drawAdapter}loadImageError(e){u.getLogger(this).error("oriented-imagery-viewer:load-image",e),this.setMessage("imageLoadError","error",e.message)}async loadSketch(e){if(!this.sketch){const t=import("../Sketch/SketchViewModel.js"),{default:i}=await t;y(e),this.sketch=new i({layer:this._defaultGraphicsLayer,view:this.activeViewer?.imageRenderer,updateOnGraphicClick:!1,defaultUpdateOptions:{reshapeOptions:{edgeOperation:"none",shapeOperation:"none",vertexOperation:void 0},enableMoveAllGraphics:!1,enableRotation:!1,enableScaling:!1,multipleSelectionEnabled:!1,toggleToolOnClick:!1,tool:"transform"}})}return this.sketch}async loadMeasurementAdapter(e){if(!this.sketchAdapter){const t=import("./adapters/sketch/MeasurementAdapter.js"),{default:i}=await t;if(y(e),this.sketchAdapter=new i({viewModel:this,measurementService:this._measurementService}),!this.sketchAdapter.viewModel.isResolved())return}return this.sketchAdapter}async processFeatureResponse(e,t,i){const{features:r}=e;if(this._clearFeatureGeometries(),!this._checkFeatures(r))return;const{features:a,polygons:s,frustums:o}=this.filterByFootprints(r,t,i?.skipFilter);if(!this._checkFeatures(a))return;this.coveragePolygons.addMany(s),this.coverageFrustums.addMany(o);const n=await this.processElevationSample(s,a,i);y(i),await this._updateElevationOfSelectedPointAndLocations(a,t,n),y(i),ze(a,n);let l=a;if(this.layer?.verticalSearchRange&&this.layer.hasZ&&this.verticalFilterEnabled&&(l=Ne(a,t,this.layer.verticalSearchRange),!l.length))return void this.setMessage("noImageAtElevation","info");const c=this._processSuitableFeatures(l,t);this.updateSuitabilities(c,i?.loadBestImage)}async processFeatureElevation(e,t,i){if(!t)return;const{features:r,polygons:a}=this.filterByFootprints(e,t,!0);if(!r?.length)return;const s=await this.processElevationSample(a,r,i);return y(i),s}async startMeasurement(e,t){this.sketch||await this.loadSketch(t),await this.loadMeasurementAdapter(t);const{sketch:i,sketchAdapter:r,activeViewer:a,mode:s}=this;if(!i||!r||!a||"none"===s)return;if(this.displayNewMeasurementButton=!1,"panoramic"===s&&(i.defaultCreateOptions.defaultZ=0),await i.create(e),"panoramic"===s){const{drawOperation:e}=i.view.activeTool;e.constraintsEnabled=!1,e._set("elevationDrawSurface",null)}const o=this.activeViewer?.imageRenderer.effectiveTheme.accentColor;o&&this.sketch&&(this.sketch.polygonSymbol=Ce(o),this.sketch.polylineSymbol="panoramic"===s?Ae:ke(o,2.5))}async startHeightMeasurement(){this.displayNewMeasurementButton=!1,this.draw??=new de({view:this.activeViewer?.imageRenderer}),this.polylineDrawAction=this.draw.create("polyline"),await this.loadHeightMeasurementAdapter()}initializeMeasurement(e){switch(this.clearMeasurementGraphics(),this.resetMeasurementData(),e){case"distance":this.startMeasurement("polyline");break;case"area":this.startMeasurement("polygon");break;case"height":this.startHeightMeasurement()}}async overlayCameraLocations(e){const{activeViewer:i,overlayedCameraLocations:a,layer:s,mode:o,layerFloorFilterClause:n,layerTimeExtent:l,videoViewModel:c,_panoramicVideoViewer:d}=this,u="video"===o,h="panoramic-video"===o,p=this._getActiveFeatureForCurrentMode(),m=this._computeOverlayImageSize();if(!(m&&p&&s&&"none"!==o&&this.overlayGraphicsEnabled))return;const{polygon:g}=q(p.attributes);if(u?c?.removeOverlayGraphics(a.toArray()):h?d.removeManyGraphics(a.toArray()):i?.removeManyGraphics(a.toArray()),a.removeAll(),e){const{features:e}=await s.queryFeatures({where:I(`${s.objectIdField} <> ${p.attributes.objectId}`,I(s.definitionExpression,n)),geometry:g,returnGeometry:!0,outFields:[s.objectIdField],timeExtent:l}),v=await Promise.all(e.map(async e=>{const{attributes:i,geometry:r}=e;if("point"!==r?.type)return null;const a=await this._geometryToOverlayImageGeometry(r,p,m);if(!a)return null;const s="panoramic"===o||"panoramic-video"===o?Te():Oe();return new t({attributes:i,symbol:s,geometry:a})}));a.addMany(v.filter(r)),u?c?.addOverlayGraphics(a.toArray()):h?d.addManyGraphics(a.toArray()):i?.addManyGraphics(a.toArray())}}overlayGraphicsOnImage(e,t){this.removeOverlayedGraphicsOnImage(e),this.overlayedMapFeatures.set(e,t),"video"!==this.mode?"panoramic-video"!==this.mode?this.activeViewer?.addManyGraphics(t.toArray()):this._panoramicVideoViewer.addManyGraphics(t.toArray()):this.videoViewModel?.addOverlayGraphics(t.toArray())}async overlayMapFeatures(e,i=!1){const{activeViewer:a,mode:o,layer:n,videoViewModel:l,_panoramicVideoViewer:c}=this,d="video"===o,h="panoramic-video"===o,p=this._getActiveFeatureForCurrentMode(),m=this._computeOverlayImageSize();if(!(m&&p&&"none"!==o&&this.overlayGraphicsEnabled&&n))return;const{polygon:g}=q(p.attributes);try{const{imageGeometryField:t,oiObjectIdField:i}=nt(e,n.imageGeometryField,n.imageReferenceField);this.imageGeometryField=t.name,this.oiObjectIdField=i.name}catch(w){u.getLogger(this).warn("oriented-imagery-viewer:overlay-map-features",w)}const{features:v}=await e.queryFeatures({geometry:g,returnGeometry:!0,outFields:["*"]}),y=await Promise.all(v.map(async r=>{const s=r.symbol?.clone()??e.renderer?.getSymbol(r)?.clone(),{attributes:n,geometry:g}=r,{imageGeometryField:v,oiObjectIdField:y}=this;if(v&&y&&ht(e,v,y)&&`${n[y]}`==`${p.attributes.objectId}`)try{const r=h?c.horizonAngles:Be(a?.media),u=lt(n,v,e,i,m,d?"default":o,s,r);if(!d)return u;const p=u.geometry;if(!p)return null;const g=l?.imageGeometryToOverlayGeometry(p);return g?new t({attributes:n,layer:e,symbol:u.symbol,geometry:g,visible:u.visible}):null}catch(w){u.getLogger(this).warn("oriented-imagery-viewer:overlay-map-features","couldn't create graphic from attributes, geometry will be used",{error:w,feature:r,layer:e,imageGeometryField:this.imageGeometryField,imageReferenceField:this.oiObjectIdField})}if(!g)return null;const f={feature:p,imageSize:m,footprintExtent:this.footprintExtent},_=await this._geometryToOverlayImageGeometry(g,f.feature,f.imageSize);return _?new t({attributes:n,layer:e,symbol:s,geometry:_,visible:e.visible&&i}):null})),f=new s(y.filter(r));("video"!==o&&"panoramic-video"!==o||this.overlayGraphicsEnabled)&&this.overlayGraphicsOnImage(`${e.id}`,f)}getDepthAt(e){const{activeViewer:t,currentBestFeature:i,mode:r,state:a,depthImage:s}=this,o=t?.imageSize;if(!o||!i||"none"===r||a.includes("loading"))return u.getLogger(this).warnOnce("oriented-imagery-viewer:get-depth-at","Load an image to use depth"),null;if(!s?.loaded)return u.getLogger(this).error("oriented-imagery-viewer:get-depth-at","Depth image is not loaded"),this.emit("depth-image-service:not-loaded"),null;const n=(Array.isArray(e)?e:[e]).map(e=>s.depthAt(e,{width:o[0],height:o[1]})??null);return Array.isArray(e)?n:n[0]}getActiveSectors(){return be.filter(e=>this._sectorData?.[e]?.length)}async getPixelLocationForFeature(e,t,i){return(await this._transformationService.pointToPixelForFeature([e],t,i))[0]}async getPixelLocationsForFeature(e,t,i){return await this._transformationService.pointToPixelForFeature(e,t,i)}async plotMapPoint(e){this.plotReferencePoint(e);const t=this._getActiveFeatureForCurrentMode();if(t)return this.transformAndPlotReferencePointOnImage({feature:t,selectedLocation:e,options:{signal:this._transformController?.signal}})}plotReferencePointOnGround(e){this._referencePointOnGround&&(this._overlays?.remove(this._referencePointOnGround),this._referencePointOnGround.destroy()),null!=e&&(this._referencePointOnGround=new t({geometry:new L({...e.toJSON()}),symbol:Le}),this.view?this._overlays?.add(this._referencePointOnGround):this.emit("plot-ground-point",{data:{point:this._referencePointOnGround?.geometry}}))}plotReferencePointOnImage(e){switch(this.mode){case"video":return void this._plotReferencePointOnVideo(e);case"panoramic-video":return void this._plotReferencePointOnPanoramicVideo(e);case"default":return void this._plotReferencePointOnDefaultImage(e);case"panoramic":return void this._plotReferencePointOnPanoramicImage(e)}}removeAllOverlayMapFeatures(){const{mode:e}=this;this.overlayedMapFeatures.forEach(t=>{const i=t.toArray();switch(e){case"video":this.videoViewModel?.removeOverlayGraphics(i);break;case"panoramic-video":this._panoramicVideoViewer.removeManyGraphics(i);break;default:this.activeViewer?.removeManyGraphics(i)}}),this.overlayedMapFeatures.clear()}removeOverlayedGraphicsOnImage(e){const t=this.overlayedMapFeatures.get(e),{mode:i}=this;if(!t?.length)return;const r=t.toArray();switch(i){case"video":this.videoViewModel?.removeOverlayGraphics(r);break;case"panoramic-video":this._panoramicVideoViewer.removeManyGraphics(r);break;default:this.activeViewer?.removeManyGraphics(r)}this.overlayedMapFeatures.delete(e)}reset(){const{mode:e}=this;"default"===e||"panoramic"===e?this.resetImage():"video"===e?this.resetVideo():"panoramic-video"===e&&this.resetVideoPanoramic(),this.beforeLoad(!1)}resetImage(){switch(this.setMessage("onLoadMessage","info"),this.mode){case"default":this._imageViewer.clearImage(),this._imageViewer.clearGraphics();break;case"panoramic":this._panoramicViewer.clearGraphics()}this._clickTask=m(this._clickTask)}resetVideo(){this.setMessage("onLoadMessage","info"),this.videoViewModel?.resetVideoHandler(),this._overlays?.removeAll(),this.videoViewModel=null,this.featureCache=[],this.currentBestFeature=null}resetVideoPanoramic(){this.setMessage("onLoadMessage","info"),this._overlays?.removeAll(),this.currentBestFeature=null}resetMeasurementData(){this.areaMeasurementResult=0,this.areaMeasurementAccuracy=0,this.distanceMeasurementResult=0,this.distanceAccuracyArray=[],this.heightMeasurementResult=0,this.heightMeasurementAccuracy=0,this.heightGraphic=null,this.triangulatedDistanceMeasurement=null,this.triangulatedDistanceAccuracy=null,this.triangulatedAreaMeasurement=null,this.triangulatedMeasurementGraphic=null,this.updatingTriangularMeasurementState=!1,this.triangulatedAreaAccuracy=0,this._measurementService?.resetMeasurementVectors()}async saveDrawing(){const{dataCaptureLayer:e,sketchAdapter:t}=this;if(!e||"data-capture"!==t?.type)return;const{pendingGraphics:i,savedGraphics:r}=t,a=i.get(e.id),s=a?.toArray();if(!a||!s?.length)return;const{addFeatureResults:o}=await this.saveDataCaptureFeatures(s),n=o.reduce((t,{objectId:i,globalId:r,error:a},o)=>{const n=s[o],{attributes:l}=n;return a?t.error.push(n):(i&&(l[e.objectIdField]=i),r&&e.globalIdField&&(l[e.globalIdField]=r),t.success.push(n)),t},{success:[],error:[]});r.addMany(n.success),a.removeAll(),a.addMany(n.error)}async saveDataCaptureFeatures(e,t){const{activeViewer:i,currentBestFeature:a,dataCaptureLayer:s,mode:o}=this,l=i?.imageSize;if(!l||!a||"none"===o||"video"===o||"panoramic-video"===o)throw new n("orientedimageryviewer:missing-input","Image size, current best feature and mode are required to save data capture features");if(!s)throw new n("orientedimageryviewer:missing-featurelayer","Data capture layer is not available");const c=await Promise.all(e.map(async e=>{const i=e.clone(),{geometry:r}=i;if(!r)return;const a=r.type,o=s.hasZ,n=s.geometryType,l=a!==n,c=l?await import("./transformers.js"):null,d=c?.default[n],u=l?d?.(r):r;return u&&(i.geometry=await this._transformationService.imageGeometryToMapGeometry(u,t),i.geometry)?(o||ct(i.geometry),i):void 0})),d=c.filter(r);return s.applyEdits({addFeatures:d}).then(e=>{const{addFeatureResults:t}=e;let i=0;const r=c.map(e=>{const r=t[i++];return e?r:{error:new n("orientedimageryviewer:save-unsucccessful","Error in saving data capture features"),objectId:null,globalId:null}});return{...e,addFeatureResults:r}})}async searchBestImage(e,t){try{const i=await z(e,t);i&&await this.processFeatureResponse(i,e.point,t)}catch(i){v(i)||(this.setMessage("imageLoadError","error",i.message),u.getLogger(this).error("error occurred while finding best image",i))}}selectTriangularMeasurementFeature(e){this.currentBestFeatureMeasurementImage=this.features?.find(({attributes:t})=>t.objectId===Number(e))}setAdditionalCameraLocationsVisibility(e){this.additionalCameraLocations.forEach(t=>{t.visible=e})}setAdditionalCoverageVisibility(e){this.additionalFootprints.forEach(t=>{t.visible=e})}setCurrentCoverageVisibility(e){this.bestFeatureCurrentFootprint&&(this.bestFeatureCurrentFootprint.visible=e),this.currentBestFeatureLocation&&(this.currentBestFeatureLocation.visible=e)}setMapImageConversionToolState(e){this.mapImageConversionToolState=e}setCurrentPanoramaView(e,t){this._panoramicViewer?.set({yaw:e,pitch:t})}async startDataCapture(e,t){const i=this.activeViewer?.imageRenderer,{oiObjectIdField:r,currentBestFeature:a}=this;if(!i||!a||!r)return;const{attributes:{objectId:o}}=a,n=this.overlayedMapFeatures.get(e.id)?.toArray()??[],l=[],c=[];for(const s of n)`${s.getAttribute(r)}`==`${o}`?l.push(s):c.push(s);this.overlayGraphicsOnImage(e.id,new s(c)),this.collectionId=e.id;const d=await this.loadSketch(t),u=await this.loadDataCaptureAdapter(t);y(t),d.addGraphics(l),u.savedGraphics.addMany(l);i.ui.find("zoom").visible=!1,i.map.layers.add(this.sketchGraphicsLayer)}async stopDataCapture(e=!1){this.sketch?.cancel(),this.sketchGraphicsLayer?.removeAll(),this.sketchAdapter=p(this.sketchAdapter),this.sketch=p(this.sketch),this.collectionId=null;const{dataCaptureLayer:t}=this,i=this.activeViewer?.imageRenderer;if(!i||i.destroyed)return;i.map.layers.remove(this.sketchGraphicsLayer),e&&t&&await this.overlayMapFeatures(t,!0);const r=i.ui.find("zoom");r&&(r.visible=!0)}stopMeasurement(){this.draw?.reset(),this.sketch?.cancel()}async toggleAllOverlayMapFeatures(e){!e&&this.dataCaptureLayer&&(await this.stopDataCapture(!0),this.dataCaptureLayer=null),this.overlayedMapFeatures.forEach(t=>{this._toggleVisiblity(t,e)})}toggleOverlayMapFeatures(e,t,i){const r=this.overlayedMapFeatures.get(e);r&&i&&this._toggleVisiblity(r,t)}toggleSelection(e){const{sketch:t}=this;t&&(t.updateOnGraphicClick=e,t.cancel())}async transformAndPlotReferencePointOnImage(e){const{feature:t,selectedLocation:i,options:r}=e;let a=!1,s=!1;const o="video"===this.mode?this.bestFeatureCurrentFootprint?.geometry:this.bestFeatureFootprint?.geometry;switch(o?.type){case"polygon":{const e=i.spatialReference.equals(o.spatialReference)?i:await G(i,o.spatialReference);a=o.contains(e);break}case"mesh":{const e=i.spatialReference.equals(o.spatialReference)?i:await G(i,o.spatialReference);s=o.extent.contains(e);break}}if(!a&&!s)return void this.clearReferencePointOnImage();const n="video"===this.mode||"panoramic-video"===this.mode?await this.getPixelLocationForFeature(i,{feature:t,mode:this.mode,imageSize:ye,footprintExtent:this.footprintExtent},r):await this._transformationService.pointToPixel(i,r);if(n)return y(r),this.plotReferencePointOnImage(n),{x:n.x,y:n.y};this.clearReferencePointOnImage()}async updateFeatureCache(e,t){const i=await N(e,t);i.features?.length&&(this.featureCache=i.features)}_plotReferencePointOnVideo(e){"video-loaded"===this.state&&this.videoViewModel?.videoPaused&&(this.clearReferencePointOnImage(),this.videoViewModel.plotReferencePointOnVideo(e))}_plotReferencePointOnPanoramicVideo(e){const i=this._panoramicVideoViewer,{imageSize:r,media:a}=i.viewModel;if(!this.panoramicVideoLoaded||!this.panoramicVideoPaused||!r)return;this.clearReferencePointOnImage();const s=Be(a),o=dt(e,"panoramic",r,s);this._referencePointOnImage=new t({geometry:o,symbol:Ge.clone()}),i.addGraphic(this._referencePointOnImage,0)}_getActiveFeatureForCurrentMode(){switch(this.mode){case"video":return this.videoViewModel?.closestFeature??this.currentBestFeature;case"panoramic-video":return this._panoramicVideoViewer.viewModel.closestFeature??this.currentBestFeature;default:return this.currentBestFeature}}_plotReferencePointOnDefaultImage(e){const i=this._imageViewer,{imageSize:r}=i;if("image-loaded"!==this.state||!r)return;this.clearReferencePointOnImage();const a=dt(e,"default",r);this._referencePointOnImage=new t({geometry:a,symbol:Le.clone()}),i.addGraphic(this._referencePointOnImage,0)}_plotReferencePointOnPanoramicImage(e){const i=this._panoramicViewer,{imageSize:r,media:a}=i;if("image-loaded"!==this.state||!r)return;this.clearReferencePointOnImage();const s=Be(a),o=dt(e,"panoramic",r,s);this._referencePointOnImage=new t({geometry:o,symbol:Ge.clone()}),i.addGraphic(this._referencePointOnImage,0)}async _fetchFeatures(e,t){const{layer:i,layerFloorFilterClause:r,layerTimeExtent:a,view:s}=this;if(!s)return;if(!i)return void this.setMessage("noLayerSelected","info");e.x=x(e.x,e.spatialReference);const o=i.spatialReference.equals(e.spatialReference)?e:await G(e,i.spatialReference),n=o.spatialReference.isGeographic?B(o):o,l=I("1=1",I(i.definitionExpression,r)),c=n.spatialReference.isGeographic?1:P(n.spatialReference),d={layerInstanceOrURL:i,point:n,queryParams:{where:l,maximumDistance:i.maximumDistance?i.maximumDistance/c:void 0,timeExtent:a}};return await this.searchBestImage(d,t)}async _fetchFeaturesWithController(e,t){try{await this._fetchFeatures(e,t)}catch(i){if(v(i))return;this.setMessage("imageLoadError","error"),u.getLogger(this).error("error occurred while fetching features",i)}}_groupFeaturesBySectors(){const{_suitabilities:e,additionalFeatures:t,features:i,invalidCameraHeading:r}=this,a=i.at(0);if(!e||!t||!a||!i||r)return void(this._sectorData=null);this._sectorData={};const o={};this._featureToSector=o;for(const d of be)this._sectorData[d]=new s;const n=e.map((e,t)=>({...e,featureIndex:t}));n.sort((e,t)=>e.trueSuitability-t.trueSuitability);const l=n.map(({distance:e})=>e),c=Math.max(...l);n.forEach(e=>{const{distance:t,angle:r,featureIndex:s}=e,n=t/c*Ve[2],l=Ze(t,c),d=Je(r);if(!this._sectorData)return;const u=Ve[3]+n*Math.sin(r*Math.PI/180),h=Ve[3]+n*Math.cos(r*Math.PI/180);let p;const m=i.at(s),g=m===a,{cameraPitch:v}=m.attributes,y=v<5;if(g&&y)p=-90;else{const e=u-Ve[3],t=h-Ve[3],i=t/Math.sqrt(e**2+t**2);let r=180*Math.acos(i)/Math.PI;(e<0&&t<0||e<0&&t>0)&&(r*=-1),p=r}const f=""===l?d:`${l}_${d}`;g&&(p===this.bestFeatureAngle?this.previousFeatureAngle=p:this.bestFeatureAngle=p,this.navigatorCurrentBestFeature=y?null:{x:u,y:h,direction:d}),o[`${m.attributes.objectId}`]=f;const w=this._sectorData[f];w.add({angle:r,featureIndex:s,x:u,y:h,objectID:m.attributes.objectId,sector:f,featureIndexInSector:w.length})})}async _initializeLocationViewModel(e){if(!this._locationViewModel){const t=import("./components/ImageLocationViewModel.js"),{default:i}=await t;y(e),this._locationViewModel=new i({oiViewModel:this,referenceTransformationService:this._referenceTransformationService})}}_initializeMeasurementService(){this._measurementService||(this._measurementService=new at({transformationService:this._transformationService,referenceTransformationService:this._referenceTransformationService}))}_initializeVideo(){if(this.videoElement||!this.currentBestFeature)return;this.removeHandles(Re.videoPlayerHandles),this.videoElement=new le({video:this.currentBestFeature.attributes.imagePath,georeference:new oe({extent:new O(Me)}),autoplay:!1}),this.videoElement.content?.loop&&(this.videoElement.content.loop=!1);const e=new H({source:this.videoElement,title:this.layer?.title,copyright:this.layer?.copyright});this.videoLayer=e,e&&this.videoMapView.map.layers.add(e),this.videoViewModel=new tt({oiViewModel:this})}async getMapPoint(e,t){const i=await this._transformationService.pixelToMapPoint(Array.isArray(e)?e:[e],t);return Array.isArray(e)?i:i[0]}async getMapPointForFeature(e,t,i){const r=await this._transformationService.pixelToMapPointForFeature(Array.isArray(e)?e:[e],t,i);return Array.isArray(e)?r:r[0]}async loadPanoramicMediaSource(e,t){const{lookAt:i,...r}=e,a=Ue(r);try{await a.load(t)}catch(o){if(v(o))return;if("unsupported-format"===o.name)return void this.setMessage("unsupportedPanoramicImageryError","error",void 0,{datasetFormat:a?.extension??"UNKNOWN FORMAT"})}const s=this.triangularMeasurementActive?this._panoramicMeasurementViewer:this._panoramicViewer;await s.loadMedia(a,t),i&&s.set(i)}async loadMediaSource(e,t){const i=qe(e);await this._setImageSource(this.triangularMeasurementActive?this.imageMeasurementViewer:this._imageViewer,i,t)}_clearFeatureGeometries(){this.coveragePolygons.removeAll(),this.coverageFrustums.removeAll(),this.pointSources.removeAll()}_checkFeatures(e){return!!e?.length||(this.emit("no-image-found"),this.setMessage("noImageError","error"),this.videoElement?.content?.pause(),this.currentBestFeature=null,!1)}async _getElevationSampleFromGround(e,t,i){if(!e[0])return;const r=(await import("../../geometry/operators/unionOperator.js")).executeMany(e);if(this._updateFootprintWithFeatures(t,r),"3d"===this.view?.type)try{return await this.view.map.ground.createElevationSampler(this.footprintExtent,i)}catch(a){v(a)||u.getLogger(this).error(a)}}async processElevationSample(e,t,i){const{elevationSource:r}=t[0].attributes,a=await this._getElevationSampleFromGround(e,t,i);return a||(r&&this.footprintExtent&&J(r)?await Y({extent:this.footprintExtent,lod:r.lod,url:r.url,rasterFunction:r.rasterFunction}):void 0)}_processSuitableFeatures(e,t){return U({features:e,selectedPoint:t,camera:We(this.view)?this.view.camera:null,currentImage:this.currentBestFeature})}async _processHitTestResults(e,t,i){const{results:[r]}=t;if("graphic"!==r?.type)return this.beforeLoad(!1),this.emit("no-image-found"),void this.setMessage("noImageError","error");const a=r.graphic.getAttribute(e.objectIdField);return await this.showImageByObjectId(a,i)}async _queryAndLoadByObjectId(e,t,i,r,a){this.displayMessage=null;const{response:s}=await rt(e,t,i,r,a);if(y(a),!s?.features?.length)throw new it(t);const o=q(s.features[0].attributes).polygon,n=L.fromJSON(j(o)),l=Q(n),c=P(l.spatialReference);this.selectedPoint=l;const d={layerInstanceOrURL:e,point:l,queryParams:{where:I(I("1=1",I(e.definitionExpression,i)),`${e.objectIdField} <> ${t}`),maximumDistance:e.maximumDistance?e.maximumDistance/c:void 0,timeExtent:r}},u=await z(d,a);y(a);const{features:h}=u;return h.push(s.features[0]),await this.processFeatureResponse(u,l,{...a,loadBestImage:!1})}_reorderTriangularSketchLayer(){const e=this.imageMeasurementViewer.imageRenderer.map.layers?.length;this.sketchTriangularGraphicsLayer&&e&&this.imageMeasurementViewer.imageRenderer.map.layers.reorder(this.sketchTriangularGraphicsLayer,e-1)}async _setImageSource(e,t,i){e.media=t,await e.loadMedia(t,i)}_toggleVisiblity(e,t){e.forEach(e=>{e.visible=t})}async _updateElevationOfSelectedPointAndLocations(e,t,i,r){const{location:a,cameraHeight:s}=e[0].attributes,o=await re(a.spatialReference,a.z,s,{elevationSample:i,elevationSource:i?void 0:e[0].attributes.elevationSource,extent:this.footprintExtent},r);y(r);const[n,...l]=await X([t,...e.map(e=>e.attributes.geometry.clone())],o);y(r),t.elevation=n.z,e.forEach((e,t)=>{e.attributes.elevation=l[t].z})}_updateFeatures(e,t=!0){if(!e.length)return this.currentBestFeature=null,void this.additionalFeatures.removeAll();this.features.removeAll(),this.features.addMany(e),this.navigationNodes.removeAll(),this.navigationNodes.addMany(e.map(e=>{const{geometry:t,attributes:i}=e,{isSpherical:r,cameraHeading:a,cameraPitch:s}=i;return new et({geometry:t,attributes:i,currentHeading:r?0:a,currentPitch:r?0:s})})),e.length>1?this.additionalFeatures.addMany(e.slice(1)):this.additionalFeatures.removeAll(),this._updateGroundElevation=!0,t&&(this.currentBestFeature=e[0])}_updateFootprintWithFeatures(e,t){const i=[];for(const{attributes:{geometry:r}}of e)t.contains(r)||i.push([r.x,r.y]);i.sort((e,t)=>+R([e,t])),t.addRing(i),this.footprintExtent=ue(t.extent,2,2)}_scheduleVideoInteractionUpdate(){this.scheduledFrameId||(this.scheduledFrameId=requestAnimationFrame(()=>{this.scheduledFrameId=null,this._updateInteraction()}))}async _updatePointsAndPolygons(e){const{pointSources:i,currentBestFeature:r,currentCoverageVisible:a,isAdditionalPointSourcesVisible:s,mode:o,layer:n}=this;if(r&&(this.additionalFootprints.removeAll(),this.additionalCameraLocations.removeAll(),this.bestFeatureCurrentFootprint&&(this.bestFeatureCurrentFootprint.destroy(),this.bestFeatureCurrentFootprint=null,this.bestFeatureFootprint=null),!this.invalidCameraHeading)){await(this._adapter?.createFootprints(e)),y(e);for(const o of i){const i=this.view&&!this.view.spatialReference?.equals(o.spatialReference)?await G(o.clone(),this.view?.spatialReference,e):o.clone();o.imageID===r.attributes.objectId?this.currentBestFeatureLocation=new t({attributes:{imageID:o.imageID},geometry:i,symbol:Ee,visible:a}):this.additionalCameraLocations.push(new t({attributes:{imageID:o.imageID},geometry:i,symbol:je,visible:s}))}"video"!==o&&"panoramic-video"!==o||(await this.initializeTransformationService(e),n&&!this.featureCache.length&&await this.updateFeatureCache(n,r.geometry.spatialReference))}}_updateCurrentBestFeature(e){if(!e)return;if(this.currentBestFeature=this.features?.at(e.featureIndex),"video"===this.mode)return void(this.currentBestFeature&&this.videoViewModel?.playVideoFromSelectedLocation(this.currentBestFeature));if("panoramic-video"===this.mode)return void(this.currentBestFeature&&this._panoramicVideoViewer.viewModel.playPanoramicVideoFromSelectedLocation(this.currentBestFeature));const t=this.currentBestFeature?.attributes.cameraPitch&&this.currentBestFeature?.attributes.cameraPitch<5;let i;if(t)i=-90;else{const t=e.x-Ve[3],r=e.y-Ve[3],a=r/Math.sqrt(t**2+r**2);let s=180*Math.acos(a)/Math.PI;(t<0&&r<0||t<0&&r>0)&&(s*=-1),i=s}i===this.bestFeatureAngle?this.previousFeatureAngle=i:this.bestFeatureAngle=i,this.navigatorCurrentBestFeature=t?null:{x:e.x,y:e.y,direction:e.sector.includes("_")?e.sector.split("_")[1]:e.sector}}_updateImageMeasurementBestFeature(e){e&&(this.currentBestFeatureMeasurementImage=this.features?.at(e.featureIndex))}clearGraphics(){this._imageViewer.clearGraphics(),this._panoramicViewer.clearGraphics(),this.imageMeasurementViewer.clearGraphics(),this._panoramicMeasurementViewer.clearGraphics()}clearReferencePointOnImage(){this._referencePointOnImage&&(this._imageViewer.removeGraphic(this._referencePointOnImage),this._panoramicViewer.removeGraphic(this._referencePointOnImage),this._panoramicVideoViewer.removeGraphic(this._referencePointOnImage),this._referencePointOnImage=p(this._referencePointOnImage)),this.videoViewModel?.clearReferencePointOnVideo()}async initializeReferenceTransformationService(e){const{currentBestFeatureMeasurementImage:t,activeTriangulatedViewer:i,mode:r}=this;if(!t||!i||!i.imageSize||"panoramic"!==r&&"default"!==r)return;const{imageSize:a}=i,{attributes:s,elevationSample:o}=t,{location:{spatialReference:n,z:l},cameraHeight:c,elevationSource:d}=s;let u=s.location;u.spatialReference.isGeographic&&(u=Q(u));const h="default"===r?ae(s,a[0],a[1]):se(s,a[0],a[1]),p=await re(n,l??0,c,{elevationSample:o,elevationSource:d,extent:this.footprintExtent},e),m=(await import("./services/TransformationService.js")).default,g={imageToWorldProperties:h,updateElevationProps:p,mode:r,imageSize:a,depthImageService:this.depthImage};this._referenceTransformationService=new m(g),this._locationViewModel&&(this._locationViewModel.referenceTransformationService=this._referenceTransformationService),this._measurementService&&(this._measurementService.referenceTransformationService=this._referenceTransformationService)}async initializeTransformationService(e){const{currentBestFeature:t,activeViewer:i,mode:r}=this,a="video"===r||"panoramic-video"===r?ye:i?.imageSize;if(!t||!a||"none"===r)return;const{attributes:s,elevationSample:o}=t,{location:{spatialReference:n,z:l},cameraHeight:c,elevationSource:d}=s;let u=s.location;u.spatialReference.isGeographic&&(u=Q(u));const h="default"===r||"video"===r?"default":"panoramic",p={..."default"===h?ae(s,a[0],a[1]):se(s,a[0],a[1]),cameraLocation:u},m=await re(n,l??0,c,{elevationSample:o,elevationSource:d,extent:this.footprintExtent},e),g=(await import("./services/TransformationService.js")).default,v={imageToWorldProperties:p,updateElevationProps:m,mode:h,imageSize:a,depthImageService:this.depthImage};this._transformationService=new g(v),this._measurementService&&(this._measurementService.transformationService=this._transformationService)}plotReferencePoint(e){"mapPoint"in e?this.plotReferencePointOnGround(e.mapPoint):this.plotReferencePointOnGround(e)}setMessage(e,t,i,r){this.displayMessage={key:e,type:t,data:i,map:r}}async transformAndPlotSelectedLocation(e){const{currentBestFeature:t,invalidCameraHeading:i,selectedPoint:r,activeViewer:a}=this;if(this._crossSymbol&&(this._panoramicViewer.removeGraphic(this._crossSymbol),this._imageViewer.removeGraphic(this._crossSymbol),this._crossSymbol=p(this._crossSymbol)),!r||!t||"image-loaded"!==a?.state||i)return;let s;try{s=await this._transformationService.pointToPixel(r,{signal:e?.signal}),y(e),await this.plotSelectedPointOnImage(s,e)}catch(o){v(o)||u.getLogger(this).error("failed to transform map point to pixel, cross symbol will not be plotted on image",{error:o,selectedPoint:r,feature:t})}}updateCurrentCoveragePolygon(e){const{additionalFootprints:i,additionalCameraLocations:r,currentBestFeature:a,currentBestFeatureLocation:s,currentCoverageVisible:o,selectedPoint:n,view:l,_adapter:c,mode:d}=this;if(!a)return;const{attributes:{objectId:u},elevationSample:h}=a;if(this._initialCurrentCoverageUpdate){if(this._overlays?.removeAll(),this._initialCurrentCoverageUpdate=!1,this.bestFeatureCurrentFootprint=p(this.bestFeatureCurrentFootprint),e&&!this.invalidCameraHeading&&(e.visible=o,this.bestFeatureCurrentFootprint=e),l){const e=[...i,...r,s].filter($e);"3d"===l?.type&&h&&c?.updateGroundElevation&&(this._updateGroundElevation&&c.updateGroundElevation(e),"panoramic"===d&&c.updateGroundElevation([this.bestFeatureCurrentFootprint])),this._updateGroundElevation=!1,n&&(e.splice(-2,0,this.bestFeatureCurrentFootprint),e.push(new t({geometry:n.clone(),symbol:Ie.clone(),attributes:{imageID:u}}))),this._overlays.graphics.addMany(e)}}else if(l){if(this.invalidCameraHeading)return void this._superimposeService.clear();this.bestFeatureCurrentFootprint&&(this._overlays?.remove(this.bestFeatureCurrentFootprint),this.bestFeatureCurrentFootprint=p(this.bestFeatureCurrentFootprint));const t=this.bestFeatureCurrentFootprint&&this._overlays?this._overlays.graphics.indexOf(this.bestFeatureCurrentFootprint):-1;e&&(this.bestFeatureCurrentFootprint=e,"3d"===l?.type&&h&&c?.updateGroundElevation&&"panoramic"===d&&c.updateGroundElevation([e]),e.visible=this.currentCoverageVisible,this._overlays?.graphics.add(this.bestFeatureCurrentFootprint,t>=0?t:this._overlays.graphics.length-1))}}_updateSuperimposedImage(){if(!this._hasActiveSuperimposeCameraContext())return;const e="panoramic"===this.mode?this._panoramicViewer:null,{currentBestFeature:t,defaultSuperimposeCameraLockEnabled:i,layer:r,mode:a,view:s,state:o,superimposeViewEnabled:n,superimposeViewSupported:l,activeViewer:c,depthImage:d}=this,u=this.coverageFrustums.find(({imageID:e})=>e===t?.attributes.objectId);this._superimposeService.update({activeImageSize:c?.imageSize||void 0,adapter:this._adapter,currentBestFeature:t,currentBestFeatureFrustum:u,defaultSuperimposeCameraLockEnabled:i,depthImageLoaded:d?.loaded??!1,layer:r,mode:a,panoramicCamera:e?.camera,panoramicHorizonAngles:Be(e?.media),state:o,superimposeViewEnabled:n&&l,view:s}),this.setMessage("superimposeImageDescription","info"),this._superimposePreviousCurrentCoverageVisible??=this.currentCoverageVisible,this.currentCoverageVisible=!1}_getSuperimposeCameraWatchState(){const e="3d"===this.view?.type?this.view:null,t=e?.camera;return[this.superimposeViewEnabled,this.superimposeViewSupported,this.mode,this.state,this.view?.type,this.view?.interacting,this.view?.navigating,t?.heading,t?.tilt,t?.fov,t?.position.x,t?.position.y,t?.position.z]}_handleSuperimposeCameraChange(){const e=this.view,t="3d"===e?.type?e:null;this._hasActiveSuperimposeCameraContext()?"panoramic"!==this.mode?!t||t.interacting||t.navigating?this._abortSuperimposeSchedule():this._scheduleDefaultSuperimposeUpdate():this._schedulePanoramicSuperimposeUpdate():this._abortSuperimposeSchedule()}_shouldDisableUnsupportedSuperimposeView(){return this.superimposeViewEnabled&&"panoramic"===this.mode&&!this.superimposeViewSupported}_hasActiveSuperimposeCameraContext(){return("default"===this.mode||"panoramic"===this.mode)&&this.superimposeViewEnabled&&this.superimposeViewSupported&&"image-loaded"===this.state&&"3d"===this.view?.type&&!!this.view.camera}_abortSuperimposeSchedule(){this._superimposeScheduleController?.abort(),this._superimposeScheduleController=null,this._clearSuperimposeDebounceTimeout(),this._clearSuperimposeScheduledFrame()}_resetInactiveSuperimposeState(){const e=null!=this._superimposePreviousCurrentCoverageVisible;this._abortSuperimposeSchedule(),this._adapter?.disableDefaultSuperimposeNavigation?.(),this._adapter?.disablePanoramicSuperimposeNavigation?.(),this._superimposeService.clear(),this._restoreCurrentCoverageVisibilityAfterSuperimpose(),this._restoreDefaultMessageAfterSuperimpose(),e&&this._restoreViewerMediaAfterSuperimpose()}_restoreCurrentCoverageVisibilityAfterSuperimpose(){null!=this._superimposePreviousCurrentCoverageVisible&&(this.currentCoverageVisible=this._superimposePreviousCurrentCoverageVisible,this._superimposePreviousCurrentCoverageVisible=null)}_restoreViewerMediaAfterSuperimpose(){const{currentBestFeature:e,mode:t}=this;if(!e||"default"!==t&&"panoramic"!==t)return;this._restoreSuperimposeMediaTask?.abort();const i=a(async t=>{await this._loadCurrentFeatureMedia(e,{signal:t})});this._restoreSuperimposeMediaTask=i,i.promise.finally(()=>{this._restoreSuperimposeMediaTask===i&&(this._restoreSuperimposeMediaTask=null)})}_restoreDefaultMessageAfterSuperimpose(){if("superimposeImageDescription"===this.displayMessage?.key){!!this.currentBestFeature&&("default"===this.mode||"panoramic"===this.mode)?this.displayMessage=null:this.setMessage("onLoadMessage","info")}}_clearSuperimposeDebounceTimeout(){null!=this.superimposeDebounceTimeoutId&&(clearTimeout(this.superimposeDebounceTimeoutId),this.superimposeDebounceTimeoutId=null)}_clearSuperimposeScheduledFrame(){null!=this.superimposeScheduledFrameId&&(cancelAnimationFrame(this.superimposeScheduledFrameId),this.superimposeScheduledFrameId=null)}_schedulePanoramicSuperimposeUpdate(){this._abortSuperimposeSchedule(),this.superimposeDebounceTimeoutId=window.setTimeout(()=>{this.superimposeDebounceTimeoutId=null,this._hasActiveSuperimposeCameraContext()&&"panoramic"===this.mode&&this._updateSuperimposedImage()},150)}_scheduleDefaultSuperimposeUpdate(){const e=this.view;if(!("3d"===e?.type?e:null))return;if(this.superimposeScheduledFrameId)return;this._superimposeScheduleController?.abort();const t=new AbortController,{signal:i}=t,r=()=>{this._clearSuperimposeDebounceTimeout(),this._clearSuperimposeScheduledFrame(),this._superimposeScheduleController===t&&(this._superimposeScheduleController=null),i.removeEventListener("abort",r)};this._superimposeScheduleController=t,i.addEventListener("abort",r),this.superimposeScheduledFrameId=requestAnimationFrame(()=>{if(i.removeEventListener("abort",r),this.superimposeScheduledFrameId=null,this._superimposeScheduleController===t&&(this._superimposeScheduleController=null),i.aborted)return;const e=this.view,a="3d"===e?.type?e:null;!this._hasActiveSuperimposeCameraContext()||null==a||a.interacting||a.navigating||this._updateSuperimposedImage()})}};e([C()],mt.prototype,"activeLayer",null),e([C({readOnly:!0})],mt.prototype,"activeViewer",null),e([C()],mt.prototype,"activeTriangulatedViewer",null),e([C()],mt.prototype,"accuracyParametersMissing",null),e([C()],mt.prototype,"additionalFeatures",void 0),e([C({type:s.ofType(t)})],mt.prototype,"additionalCameraLocations",void 0),e([C({type:s.ofType(t)})],mt.prototype,"additionalFootprints",void 0),e([C()],mt.prototype,"areaMeasurementResult",void 0),e([C()],mt.prototype,"areaMeasurementAccuracy",void 0),e([C()],mt.prototype,"bestFeatureAngle",void 0),e([C()],mt.prototype,"bestFeatureCurrentFootprint",void 0),e([C({type:t})],mt.prototype,"bestFeatureFootprint",void 0),e([C({type:Number})],mt.prototype,"brightness",null),e([C()],mt.prototype,"cameraHeadingThreshold",void 0),e([C()],mt.prototype,"cameraPitchThreshold",void 0),e([C()],mt.prototype,"clickAction",void 0),e([C()],mt.prototype,"correctedLocationPointOnImage",void 0),e([C()],mt.prototype,"videoViewModel",void 0),e([C()],mt.prototype,"collectionId",void 0),e([C({type:Number})],mt.prototype,"contrast",null),e([C()],mt.prototype,"coverageFrustums",void 0),e([C()],mt.prototype,"coveragePolygons",void 0),e([C()],mt.prototype,"currentBestFeature",void 0),e([C()],mt.prototype,"currentBestFeatureMeasurementImage",void 0),e([C()],mt.prototype,"currentBestFeatureLocation",void 0),e([C()],mt.prototype,"currentCoverageVisible",void 0),e([C()],mt.prototype,"currentNode",null),e([C()],mt.prototype,"depthImage",void 0),e([C()],mt.prototype,"depthImageNotSupported",null),e([C()],mt.prototype,"featureCache",void 0),e([C()],mt.prototype,"navigationNodes",void 0),e([C({json:{write:!1}})],mt.prototype,"determineWorkflowForFeature",void 0),e([C({json:{write:!1}})],mt.prototype,"determineWorkflowForTriangularMeasurement",void 0),e([C()],mt.prototype,"disabled",void 0),e([C()],mt.prototype,"displayMessage",void 0),e([C()],mt.prototype,"displayNewMeasurementButton",void 0),e([C()],mt.prototype,"distanceMeasurementResult",void 0),e([C()],mt.prototype,"distanceAccuracyArray",void 0),e([C()],mt.prototype,"dataCaptureLayer",void 0),e([C({readOnly:!0})],mt.prototype,"featureCount",null),e([C()],mt.prototype,"features",void 0),e([C()],mt.prototype,"groundCoordinates",void 0),e([C()],mt.prototype,"groundCoordinatesAccuracy",void 0),e([C()],mt.prototype,"heightGraphic",void 0),e([C()],mt.prototype,"heightMeasurementResult",void 0),e([C()],mt.prototype,"heightMeasurementAccuracy",void 0),e([C({readOnly:!0})],mt.prototype,"imageGalleryEnabled",null),e([C()],mt.prototype,"imageGeometryField",void 0),e([C({readOnly:!0})],mt.prototype,"imageLoaded",null),e([C()],mt.prototype,"imageLocationToolState",void 0),e([C()],mt.prototype,"initialVideoMapViewExtent",void 0),e([C({readOnly:!0})],mt.prototype,"invalidCameraHeading",null),e([C()],mt.prototype,"imagePointsInView",null),e([C()],mt.prototype,"imageMeasurementViewer",void 0),e([C()],mt.prototype,"isAdditionalCoverageVisible",void 0),e([C()],mt.prototype,"isAdditionalPointSourcesVisible",void 0),e([C()],mt.prototype,"layer",void 0),e([C()],mt.prototype,"layerView",null),e([C({readOnly:!0})],mt.prototype,"layerFloorFilterClause",null),e([C({readOnly:!0})],mt.prototype,"layerTimeExtent",null),e([C({type:Number})],mt.prototype,"localPort",void 0),e([C()],mt.prototype,"locationPointOnImage",void 0),e([C()],mt.prototype,"mapImageConversionToolState",void 0),e([C()],mt.prototype,"measureType",void 0),e([C()],mt.prototype,"measurementGraphic",void 0),e([C({readOnly:!0,value:"none"})],mt.prototype,"mode",null),e([C()],mt.prototype,"navigationMode",void 0),e([C()],mt.prototype,"navigatorCurrentBestFeature",void 0),e([C()],mt.prototype,"oiObjectIdField",void 0),e([C({type:s.ofType(t)})],mt.prototype,"overlayedCameraLocations",void 0),e([C()],mt.prototype,"overlayedMapFeatures",void 0),e([C()],mt.prototype,"panoramicVideoLoaded",null),e([C()],mt.prototype,"panoramicVideoPaused",null),e([C()],mt.prototype,"pixelCoordinates",void 0),e([C()],mt.prototype,"preserveAngle",void 0),e([C()],mt.prototype,"pointSources",void 0),e([C({readOnly:!0})],mt.prototype,"popupEnabled",null),e([C()],mt.prototype,"preloadMedia",void 0),e([C()],mt.prototype,"preloadMediaSize",void 0),e([C()],mt.prototype,"previousFeatureAngle",void 0),e([C()],mt.prototype,"referencePoint",null),e([C({readOnly:!0})],mt.prototype,"sectorData",null),e([C()],mt.prototype,"selectedPoint",void 0),e([C({type:Number})],mt.prototype,"sharpness",null),e([C()],mt.prototype,"shouldShowSelectedImage",void 0),e([C()],mt.prototype,"superimposeViewEnabled",void 0),e([C()],mt.prototype,"defaultSuperimposeCameraLockEnabled",void 0),e([C()],mt.prototype,"superimposeViewSupported",null),e([C()],mt.prototype,"sketch",void 0),e([C()],mt.prototype,"sketchTriangular",void 0),e([C()],mt.prototype,"sketchTriangularGraphicsLayer",void 0),e([C()],mt.prototype,"draw",void 0),e([C()],mt.prototype,"drawAdapter",void 0),e([C()],mt.prototype,"polylineDrawAction",void 0),e([C()],mt.prototype,"scheduledFrameId",void 0),e([C()],mt.prototype,"superimposeScheduledFrameId",void 0),e([C()],mt.prototype,"superimposeDebounceTimeoutId",void 0),e([C()],mt.prototype,"sketchAdapter",void 0),e([C({readOnly:!0})],mt.prototype,"sketchGraphicsLayer",null),e([C({readOnly:!0})],mt.prototype,"state",null),e([C({readOnly:!0})],mt.prototype,"thumbnails",null),e([C()],mt.prototype,"videoExtentPoints",null),e([C()],mt.prototype,"triangularMeasurementActive",void 0),e([C()],mt.prototype,"triangulatedDistanceMeasurement",void 0),e([C()],mt.prototype,"triangulatedDistanceAccuracy",void 0),e([C()],mt.prototype,"triangulatedAreaMeasurement",void 0),e([C()],mt.prototype,"triangulatedAreaAccuracy",void 0),e([C()],mt.prototype,"triangulatedMeasurementGraphic",void 0),e([C()],mt.prototype,"triangulatedPoint",void 0),e([C()],mt.prototype,"triangulatedMeasurementAdapter",void 0),e([C()],mt.prototype,"updateFootprint",void 0),e([C()],mt.prototype,"updateVideoFootprint",void 0),e([C()],mt.prototype,"updateFootprintPanorama",void 0),e([C()],mt.prototype,"updatingTriangularMeasurementState",void 0),e([C({value:null})],mt.prototype,"view",null),e([C()],mt.prototype,"videoElement",void 0),e([C()],mt.prototype,"videoLayer",void 0),e([C()],mt.prototype,"videoMapView",void 0),e([C()],mt.prototype,"verticalFilterEnabled",void 0),e([C()],mt.prototype,"_adapter",void 0),e([C()],mt.prototype,"_defaultGraphicsLayer",null),e([C()],mt.prototype,"_highlightedFeatureHandle",void 0),e([C()],mt.prototype,"_imageViewer",void 0),e([C()],mt.prototype,"_initialCurrentCoverageUpdate",void 0),e([C()],mt.prototype,"_locationViewModel",void 0),e([C()],mt.prototype,"_measurementService",void 0),e([C()],mt.prototype,"_mediaPrefetcher",void 0),e([C()],mt.prototype,"_navigationManager",void 0),e([C()],mt.prototype,"_overlays",void 0),e([C()],mt.prototype,"_superimposePreviousCurrentCoverageVisible",void 0),e([C()],mt.prototype,"_superimposeService",void 0),e([C({readOnly:!0})],mt.prototype,"_overlaysView",null),e([C()],mt.prototype,"_panoramicVideoViewer",void 0),e([C()],mt.prototype,"_panoramicViewer",void 0),e([C()],mt.prototype,"_panoramicMeasurementViewer",void 0),e([C()],mt.prototype,"_referencePointOnGround",void 0),e([C()],mt.prototype,"_referencePointOnImage",void 0),e([C()],mt.prototype,"_referenceTransformationService",void 0),e([C()],mt.prototype,"_sectorData",void 0),e([C()],mt.prototype,"_transformationService",void 0),e([C()],mt.prototype,"_featureToSector",void 0),e([C({readOnly:!0})],mt.prototype,"_updatingHandles",void 0),e([C()],mt.prototype,"footprintExtent",void 0),e([C()],mt.prototype,"_featureChangedTask",void 0),mt=e([A("esri.widgets.OrientedImageryViewer.OrientedImageryViewerViewModel")],mt);const gt=mt;export{gt as default};
2
+ import{__decorate as e}from"tslib";import t from"../../Graphic.js";import{equals as i,isSome as r}from"../../core/arrayUtils.js";import{createTask as a}from"../../core/asyncUtils.js";import s from"../../core/Collection.js";import{deprecatedProperty as o}from"../../core/deprecate.js";import n from"../../core/Error.js";import{EventedMixin as l}from"../../core/Evented.js";import{makeHandle as c}from"../../core/handleUtils.js";import{equalsShallow as d}from"../../core/lang.js";import u from"../../core/Logger.js";import{clamp as h}from"../../core/mathUtils.js";import{destroyMaybe as p,abortMaybe as m}from"../../core/maybe.js";import{EsriPromise as g}from"../../core/Promise.js";import{isAbortError as v,throwIfAborted as y,waitTick as f}from"../../core/promiseUtils.js";import w from"../../core/ReactiveMap.js";import{whenOnce as _,on as F,watch as b,syncAndInitial as M,initial as V,when as S}from"../../core/reactiveUtils.js";import{sqlAnd as I}from"../../core/sql.js";import{getMetersPerUnitForSR as P}from"../../core/units.js";import{property as C,subclass as A}from"../../core/accessorSupport/decorators.js";import{isSerializable as k}from"../../core/support/jsonUtils.js";import{UpdatingHandles as T}from"../../core/support/UpdatingHandles.js";import O from"../../geometry/Extent.js";import L from"../../geometry/Point.js";import{projectAsync as G}from"../../geometry/projectionUtils.js";import E from"../../geometry/SpatialReference.js";import{polygonCentroidPoint as j}from"../../geometry/support/centroid.js";import{isClockwise as R}from"../../geometry/support/coordsUtils.js";import{normalizeMapX as x}from"../../geometry/support/normalizeUtils.js";import{geographicToWebMercator as B}from"../../geometry/support/webMercatorUtils.js";import D from"../../layers/GraphicsLayer.js";import H from"../../layers/MediaLayer.js";import{searchImages as z,getSortedLayerFeatures as N}from"../../layers/orientedImagery/queries.js";import{calculateSuitabilities as U}from"../../layers/orientedImagery/core/bestImageUtils.js";import{createCoveragePolygon as q,computePolygonForInspection as W,resizePolygon as $,checkIfPolygonContainsSelectedPoint as Z}from"../../layers/orientedImagery/core/coverageUtils.js";import{isElevationSource as J}from"../../layers/orientedImagery/core/ElevationSourceDefinitions.js";import{getMetersPerUnitOfSR as K,convertGeographicToWebMercator as Q}from"../../layers/orientedImagery/core/utils.js";import X from"../../layers/orientedImagery/transformations/updateElevation.js";import{getElevationSampler as Y}from"../../layers/orientedImagery/transformations/updateElevationUtils.js";import{or as ee,getInitialAngle as te,convertPixelLocationToSphereVertex as ie,getUpdateElevationProps as re,getImageToWorldProperties as ae,getImageToWorldPanoramicProperties as se}from"../../layers/orientedImagery/transformations/utils.js";import oe from"../../layers/support/ExtentAndRotationGeoreference.js";import{getFloorFilterClause as ne}from"../../layers/support/floorFilterUtils.js";import le from"../../layers/support/VideoElement.js";import ce from"../../views/MapView.js";import de from"../../views/draw/Draw.js";import{scale as ue}from"../../views/draw/support/drawUtils.js";import{ViewEventPriorities as he}from"../../views/input/InputManager.js";import pe from"../PanoramicVideoViewer.js";import me from"../PanoramicViewer.js";import{defaultAngleThresholdInDegrees as ge,videoMapViewConstraint as ve,fixedImageSize as ye,clockwiseDirections as fe,videoFitScaleTolerance as we,videoExtent as _e,invalidCameraHeading as Fe,sectorsInOrder as be,sampleExtent as Me,sectorsRadii as Ve}from"./constants.js";import{isFeatureAttachment as Se}from"./galleryUtils.js";import{crossSymbol as Ie,crossSymbol3D as Pe,measurementPolygonSymbol as Ce,polylineSymbolPanoramic as Ae,measurementPolylineSymbol as ke,cameraOverlaySymbol3D as Te,cameraOverlaySymbol as Oe,diamondSymbol as Le,diamondSymbol3D as Ge,activeSourcePointSymbol as Ee,sourcePointSymbol as je}from"./symbols.js";import{registryKeys as Re}from"./types.js";import{isNoAttachmentError as xe,extractHorizonAnglesFromMedia as Be,isTifOrMrf as De,filterOILLayerView as He,assignElevationSampleToFeatures as ze,filterByZ as Ne,createPanoramicMedia as Ue,createNonPanoramicMedia as qe,isSceneView as We,isGraphic as $e,calculateSegment as Ze,calculateDirection as Je}from"./utils.js";import{disableVideoZoomAndPan as Ke,getUpdatedConstraints as Qe,getUpdatedExtentPoints as Xe}from"./videoViewerUtils.js";import Ye from"./components/ImageViewer.js";import et from"./components/NavigationNode.js";import tt from"./components/OrientedImageryVideoViewModel.js";import{NoFeatureFoundWithObjectIdError as it}from"./navigation/errors.js";import{queryFeatureByObjectIds as rt}from"./navigation/queries.js";import{ImageMeasurementService as at}from"./services/ImageMeasurementService.js";import st from"./services/SuperimposeService.js";import{configureSketchTool as ot,extractFieldsFromDataCaptureLayer as nt,constructGraphicFromImageGeometry as lt}from"./support/dataCaptureUtils.js";import{removeZFromGeometry as ct,imageSpaceToPoint as dt}from"./support/geometryUtils.js";import ut from"./support/resolveMediaProps.js";import{isValidDataCaptureLayer as ht}from"./support/typeUtils.js";const pt=()=>new n("orientedimageryviewer:sketch-not-initialized","Sketch property is not initialized, call loadSketch first");let mt=class extends(l(g)){constructor(e){super(e),this.additionalFeatures=new s,this.additionalCameraLocations=new s,this.additionalFootprints=new s,this.areaMeasurementResult=0,this.areaMeasurementAccuracy=0,this.bestFeatureAngle=0,this.bestFeatureCurrentFootprint=null,this.bestFeatureFootprint=null,this.cameraHeadingThreshold=ge,this.cameraPitchThreshold=ge,this.clickAction="hittest",this.correctedLocationPointOnImage=null,this.videoViewModel=null,this.collectionId=null,this.coverageFrustums=new s,this.coveragePolygons=new s,this.currentBestFeature=null,this.currentBestFeatureMeasurementImage=null,this.currentBestFeatureLocation=null,this.currentCoverageVisible=!0,this.depthImage=null,this.featureCache=[],this.navigationNodes=new s,this.determineWorkflowForFeature=async(e,t,i)=>{const{currentBestFeature:r,selectedPoint:a}=this;if(this.emit("popup-close"),r&&a){this.displayMessage=null,this._initialCurrentCoverageUpdate=!0,this._updateGroundElevation=!0;try{await this._updatePointsAndPolygons(i),await this._loadDepthImage(i),await this._loadCurrentFeatureMedia(r,i)}catch(s){v(s)||(this.loadImageError(s),u.getLogger(this).error("#loadIImage()","error occured while loading image",s))}}},this.determineWorkflowForTriangularMeasurement=async(e,t,i)=>{if(this.emit("popup-close"),this.currentBestFeatureMeasurementImage&&this.selectedPoint)try{await this._loadMeasurementViewerImage(i)}catch(r){v(r)||(this.loadImageError(r),u.getLogger(this).error("#loadIImage()","error occured while loading image",r))}},this.disabled=!1,this.displayMessage={key:"onLoadMessage",type:"info"},this.displayNewMeasurementButton=!0,this.distanceMeasurementResult=0,this.distanceAccuracyArray=[],this.dataCaptureLayer=null,this.features=new s,this.groundCoordinates=null,this.groundCoordinatesAccuracy=null,this.heightGraphic=null,this.heightMeasurementResult=0,this.heightMeasurementAccuracy=0,this.imageGeometryField=null,this.imageLocationToolState=!1,this.initialVideoMapViewExtent=null,this.imageMeasurementViewer=new Ye,this.isAdditionalCoverageVisible=!1,this.isAdditionalPointSourcesVisible=!1,this.layer=null,this.localPort=null,this.locationPointOnImage=null,this.mapImageConversionToolState=!1,this.measureType=null,this.measurementGraphic=null,this.navigatorCurrentBestFeature=null,this.oiObjectIdField=null,this.overlayedCameraLocations=new s,this.overlayedMapFeatures=new w,this.pixelCoordinates=null,this.preserveAngle="none",this.pointSources=new s,this.preloadMedia=!1,this.preloadMediaSize=5,this.previousFeatureAngle=0,this.selectedPoint=null,this.shouldShowSelectedImage=!1,this.superimposeViewEnabled=!1,this.defaultSuperimposeCameraLockEnabled=!0,this.sketch=null,this.sketchTriangular=null,this.sketchTriangularGraphicsLayer=null,this.draw=null,this.drawAdapter=null,this.polylineDrawAction=null,this.scheduledFrameId=null,this.superimposeScheduledFrameId=null,this.superimposeDebounceTimeoutId=null,this.sketchAdapter=null,this.triangularMeasurementActive=!1,this.triangulatedDistanceMeasurement=null,this.triangulatedDistanceAccuracy=null,this.triangulatedAreaMeasurement=null,this.triangulatedAreaAccuracy=0,this.triangulatedMeasurementGraphic=null,this.triangulatedPoint=null,this.triangulatedMeasurementAdapter=null,this.updateFootprint=async(e,t,i)=>{"default"===this.mode&&"image-loaded"!==this.state||await(this._adapter?.updateFootprint(e,t,i))},this.updateVideoFootprint=async e=>{this.mode.includes("video")&&this.videoElement?.content&&await(this._adapter?.updateVideoFootprint(e))},this.updateFootprintPanorama=async(e,t)=>{await(this._adapter?.updateFootprintPanorama(e,t))},this.updatingTriangularMeasurementState=!1,this.videoElement=null,this.videoLayer=null,this.videoMapView=new ce({map:new Map,constraints:ve}),this.verticalFilterEnabled=!1,this._adapter=null,this._highlightedFeatureHandle=null,this._imageViewer=new Ye,this._initialCurrentCoverageUpdate=!0,this._locationViewModel=null,this._measurementService=null,this._mediaPrefetcher=null,this._navigationManager=null,this._overlays=new D({listMode:"hide",internal:!0,elevationInfo:{mode:"absolute-height"},title:"OrentedImageryViewerViewModel overlays layer"}),this._superimposePreviousCurrentCoverageVisible=null,this._superimposeService=new st({getMapPoint:(e,t)=>this.getMapPoint(e,t),getPanoramicTransformationState:()=>{const{imageToWorldProperties:e,mode:t,updateElevationProps:i}=this._transformationService;return"panoramic"===t&&e?{imageToWorldProperties:e,updateElevationProps:i}:null},pointToPixel:(e,t)=>this._transformationService.pointToPixel(e,t),overlays:this._overlays}),this._panoramicVideoViewer=new pe,this._panoramicViewer=new me,this._panoramicMeasurementViewer=new me,this._referencePointOnGround=null,this._referencePointOnImage=null,this._referenceTransformationService=null,this._sectorData=null,this._transformationService=null,this._featureToSector=null,this._updatingHandles=new T,this._clickTask=null,this._crossSymbol=null,this.footprintExtent=null,this._featureChangedTask=null,this._mediaPrefetchTask=null,this._restoreSuperimposeMediaTask=null,this._superimposeScheduleController=null,this._suitabilities=null,this._transformController=new AbortController,this._updateFootprintTask=null,this._updateGroundElevation=!1,this.addUpdatingPromise=e=>this._updatingHandles.addPromise(e),this.filterCapturedFeatures=e=>{const t=this.currentBestFeature?.attributes.objectId,i=this.layer?.imageReferenceField;if(!t||!e||!i)return;const r=this.overlayedMapFeatures.get(e);r?.forEach(e=>{const r=e.attributes??{},a=Object.keys(r).find(e=>e.toLowerCase()===i.toLowerCase());(a?r[a]:null)!==t&&(e.visible=!e.visible)})},this.hideImageGeometry=e=>{},this.highlight=e=>{if(!this._overlaysView)return;this.removeHighlight();const t=this.additionalFootprints.find(({attributes:{imageID:t}})=>t===Number(e));this._highlightedFeatureHandle=t?this._overlaysView?.highlight(t):null},this.loadDataCaptureAdapter=async e=>{await this.loadSketch(e);const t=import("./adapters/sketch/DataCaptureAdapter.js"),{default:i}=await t;return y(e),this.sketchAdapter=new i({viewModel:this}),this.sketchAdapter},this.loadImageFromFeature=(e,t,i)=>this._updatingHandles.addPromise(this._loadImageFromFeature(e,t,i)),this.storeImageMeasurementViewer=e=>{this.imageMeasurementViewer=e},this.storePanoramicMeasurementViewer=e=>{this._panoramicMeasurementViewer=e},this.loadImageViewer=e=>{this._imageViewer?.destroy(),this._imageViewer=e},this.loadPanoramicViewer=e=>{this._panoramicViewer?.destroy(),this._panoramicViewer=e},this.loadPanoramicVideoViewer=e=>{this._panoramicVideoViewer?.destroy(),this._panoramicVideoViewer=e},this.loadVideoViewer=e=>{this.videoMapView.container=e},this.showImageByObjectId=async(e,t)=>{const i=this.additionalFeatures.find(({attributes:t})=>t.objectId===e);if(i)this.currentBestFeature=i;else{const{layer:i,layerFloorFilterClause:a,layerTimeExtent:s}=this;if(!i)return void this.setMessage("noLayerSelected","info");this.beforeLoad();const o=this._updatingHandles.addPromise(this._queryAndLoadByObjectId(i,e,a,s,t));try{await o,await this.selectBestFeature(e,t)}catch(r){v(r)||(u.getLogger(this).error("oriented-imagery-viewer:show-image",r),"NoFeatureFoundWithObjectIdError"===r.name?this.setMessage("noFeatureFoundWithObjectId","error","",{objectId:e}):this.setMessage("imageLoadError","error",r.message))}}},this.getSectorFeatureById=e=>this._suitabilities?.find(({feature:{attributes:{objectId:t}}})=>t===e),this.getFeatureSectorById=e=>this._featureToSector?.[`${e}`],this.navigate=async(e,t)=>{const{mode:i}=this;if("default"!==i&&"panoramic"!==i)throw new n("NavigationError","Navigation is only supported in 'default' and 'panoramic' modes.");const r=e=>"default"===i&&e.declaredClass.endsWith("NavigationManager")||"panoramic"===i&&e.declaredClass.endsWith("NavigationManagerPanoramic");if(null==this._navigationManager||!r(this._navigationManager)){p(this._navigationManager);const e="default"===i?import("./navigation/NavigationManager.js"):import("./navigation/NavigationManagerPanoramic.js");this._navigationManager=new(await e).default({viewModel:this})}return this._navigationManager.navigate(e,t)},this.removeHighlight=()=>this._highlightedFeatureHandle?.remove(),this.revealImageGeometry=e=>{},this.selectBestFeature=async(e,t)=>(y(t),this.currentBestFeature=this.features?.find(({attributes:t})=>`${t.objectId}`==`${e}`),_(()=>{switch(this.mode){case"video":return"video-loaded"===this.state;case"panoramic-video":return this.panoramicVideoLoaded;default:return"image-loaded"===this.state}},t)),this.toggleImageAttributes=()=>{const{currentBestFeature:e,popupEnabled:i,layer:r,view:a}=this;if(this.emit("popup-close"),!(a&&e&&i&&r))return;const{attributes:s,geometry:o}=e,n=new t({geometry:o,attributes:s.toJSON(),origin:r.graphicOrigin,sourceLayer:r});this.emit("popup-open",{features:[n],location:s.location.clone()})},this.updateSuitabilities=(e,t=!0)=>{e.sort((e,t)=>e.suitability-t.suitability),this._suitabilities=e;const i=this._suitabilities.map(({feature:e})=>e);this._initialCurrentCoverageUpdate=!0,this._updateFeatures(i,t),this._groupFeaturesBySectors()},this._computeOverlayImageSize=()=>{const{mode:e}=this;return"video"===e?ye:"panoramic-video"===e?this._panoramicVideoViewer.imageSize:this.activeViewer?.imageSize},this._geometryToOverlayImageGeometry=async(e,t,i)=>{const{mode:r,videoViewModel:a,_panoramicVideoViewer:s}=this;if("video"===r)return await(a?.geometryToOverlayGeometry(e,t))??null;if("panoramic-video"===r){const a={feature:t,mode:r,imageSize:i,footprintExtent:this.footprintExtent};return await this._transformationService.geometryToImageGeometryForFeature(e,a,s.horizonAngles)}return await this._transformationService.geometryToImageGeometry(e)},this._createViewClickHandle=()=>{if(this.removeHandles(Re.click),this.disabled||null==this.view)return;const e=this.mapImageConversionToolState&&("image-loaded"===this.state||"video-loaded"===this.state&&"video"===this.mode&&!!this.videoViewModel?.videoPaused||this.panoramicVideoLoaded&&"panoramic-video"===this.mode&&this.panoramicVideoPaused)?this._mapImageConversionToolViewClickHandler:this._viewClickHandler;this.addHandles(this.view.on("click",e,he.DEFAULT),Re.click)},this._createImageClickHandle=()=>{this.removeHandles(Re.imageClick),this.videoViewModel?.syncMapImageConversionHandle();const{mapImageConversionToolState:e,mode:t,footprintExtent:i,panoramicVideoLoaded:r}=this,s="panoramic-video"===t?this._panoramicVideoViewer:this.activeViewer,o=s?.imageSize;if(!e||"none"===t||"video"===t||!o||!i)return;const n="panoramic-video"===t,l=this._getActiveFeatureForCurrentMode(),d=!n||r&&this.panoramicVideoPaused;if(!l||!d)return;const u=s.clickAction;this.clickAction="pixel-location";const h=c(()=>{this.clickAction=u});let p=null;const m=F(()=>s,"pixel-location",e=>{this.plotReferencePointOnImage(e),p?.abort(),p=a(async r=>{if(!e)return;const a=this._getActiveFeatureForCurrentMode();if(!a)return;const s={feature:a,mode:t,imageSize:o,footprintExtent:i};let l=n?await this.getMapPointForFeature(e,s,{signal:r}):await this._transformationService.pixelToMapPoint(e);const c=this.view?.spatialReference;l&&!ee(!c,l.spatialReference.equals(c))&&(l=await G(l,c,{signal:r})),y(r),this.plotReferencePointOnGround(l)})});this.addHandles([m,h],Re.imageClick)},this._createTriangularImageClickHandle=()=>{this.removeHandles(Re.triangularImageClick),this.triangularMeasurementActive&&"none"!==this.mode&&this.currentBestFeature&&this.currentBestFeatureMeasurementImage&&this.activeTriangulatedViewer&&this.addHandles(this.activeTriangulatedViewer.imageRenderer.on("double-click",this._measurementImageClickHandler),Re.triangularImageClick)},this._enablePan=()=>{this.removeHandles(Re.videoPanHandles)},this._disablePan=()=>{this.removeHandles(Re.videoPanHandles),this.addHandles(Ke(this.videoMapView),Re.videoPanHandles)},this._handleImageHitTestResponse=async e=>{const{layer:t,overlayedCameraLocations:i}=this;if(!t)return;const r=e.results.find(({graphic:e,graphic:{attributes:r}})=>i.includes(e)&&r&&!r[t.imageReferenceField]&&!r[t.imageGeometryField]);if(!r)return;const a=r.graphic.attributes[t.objectIdField];await this.showImageByObjectId(a)},this._loadCurrentFeatureMedia=async(e,t)=>{if("video"===this.mode)return this._initializeVideo(),void this.videoViewModel?.playVideoFromSelectedLocation(e);"panoramic-video"!==this.mode?await this._loadImage(t):await this._loadVideo(t)},this._loadDepthImage=async e=>{const{currentBestFeature:t,layer:i,depthImageNotSupported:r}=this;if(this.depthImage?.destroy(),this.depthImage=null,!i||!t||r)return;const{depthImage:a}=t.attributes;if(!a)return;const s=(await import("./services/DepthImageService.js")).default;y(e),this.depthImage=new s({url:a});try{await this.depthImage.load(e)}catch(o){v(o)||(u.getLogger(this).error("error occurred while loading depth image",o),this.depthImage?.destroy(),this.depthImage=null)}},this._loadImage=async e=>{const{currentBestFeature:t,layer:i,mode:r}=this;if(this.clearGraphics(),i&&t&&"none"!==r&&"video"!==r&&"panoramic-video"!==r)try{await this.loadImageFromFeature(i,t,e),y(e),await this.transformAndPlotSelectedLocation(e)}catch(a){v(a)||this.loadImageError(a)}},this._loadVideo=async e=>{const{currentBestFeature:t,mode:i,selectedPoint:r}=this,a=t?.attributes.imagePath;if(!t||"panoramic-video"!==i||!a)return;const{attributes:s}=t,{cameraPitch:o,cameraOrientation:n,location:l}=s,c=l.spatialReference.isWGS84&&4!==n?.type?B(l):new L(l);try{this._panoramicVideoViewer.viewModel.video&&(this._panoramicVideoViewer.viewModel.video.pause(),this._panoramicVideoViewer.viewModel.videoPaused=!0),this._panoramicVideoViewer.videoSource=a;let t=0;c&&r&&(t=await te(c,r)-t),this._panoramicVideoViewer.pitch=o??0,this._panoramicVideoViewer.yaw=t,await this._panoramicVideoViewer.loadVideo(e),y(e)}catch(d){v(d)||this.loadImageError(d)}},this._loadImageFromFeature=async(e,t,i)=>{const{mode:r}=this;if("default"!==r&&"panoramic"!==r)return;let a;try{a=await ut(t.attributes,e,i),y(i)}catch(f){if(v(f))return;return xe(f)?(u.getLogger(this).error(f),void this.setMessage("noAttachment","error",`${e.objectIdField}: ${t.attributes.objectId}`)):(u.getLogger(this).error(f,{[e.objectIdField]:t.attributes.objectId,layer:e}),void this.setMessage("imageLoadError","error",`query-attachments-failed:${e.objectIdField} ${t.attributes.objectId}`))}if(!a)return;const{mediaUrl:s,datasetFormat:o,rotation:n,searchParams:l,location:c,cameraHeading:d,matrix:h,cameraPitch:p,getDataSetFormatError:m}=a,g=`${t.attributes.objectId}`;try{let a=this._mediaPrefetcher?.getCachedMedia(g);if(!a){const i=this.navigationNodes.find(e=>e.id===t.attributes.objectId);if(i){try{await(this._mediaPrefetcher?.startPrefetchForNode(i,e))}catch(w){}a=this._mediaPrefetcher?.getCachedMedia(g)}}if(a){if("panoramic"===r){const e=this.triangularMeasurementActive?this._panoramicMeasurementViewer:this._panoramicViewer;let r=0;return c&&this.selectedPoint&&(r=await te(c,this.selectedPoint)-r),await e.loadMedia(a,i),this.selectedPoint?e.set({yaw:r,pitch:p}):"viewAngle"in t.attributes&&Number.isFinite(t.attributes.viewAngle)&&e.set({yaw:t.attributes.viewAngle,pitch:p}),void(this.triangularMeasurementActive?await this.initializeReferenceTransformationService(i):await this.initializeTransformationService(i))}return await this._setImageSource(this.triangularMeasurementActive?this.imageMeasurementViewer:this._imageViewer,a,i),void(this.triangularMeasurementActive?await this.initializeReferenceTransformationService(i):await this.initializeTransformationService(i))}}catch(w){}m&&u.getLogger(this).warn("error occurred while getting dataset format",m),"panoramic"===r?await this.loadPanoramicMediaSource({lookAt:{yaw:this.selectedPoint?await te(c,this.selectedPoint):"viewAngle"in t.attributes&&Number.isFinite(t.attributes.viewAngle)?t.attributes.viewAngle:0,pitch:p},extension:o?.toUpperCase(),url:s,cameraHeading:d,matrix:h},i):await this.loadMediaSource({datasetFormat:o?.toUpperCase(),url:s,customParameters:l,rotation:n},i),this.triangularMeasurementActive?await this.initializeReferenceTransformationService(i):await this.initializeTransformationService(i)},this._loadMeasurementViewerImage=async e=>{const{currentBestFeatureMeasurementImage:t,layer:i,mode:r}=this;if(this.imageMeasurementViewer.clearGraphics(),this._panoramicMeasurementViewer.clearGraphics(),i&&t&&"none"!==r&&"video"!==r&&"panoramic-video"!==r)try{await this.loadImageFromFeature(i,t,e),y(e)}catch(a){v(a)||this.loadImageError(a)}},this._loadMediaPrefetcher=async e=>{if(!this._mediaPrefetcher){const{default:t}=await import("./support/MediaPrefetcher.js");y(e),this._mediaPrefetcher=new t({maxEntries:this.preloadMediaSize*fe.length})}return this._mediaPrefetcher},this._loadViewAdapter=async e=>{const{view:t}=this;if(this._adapter?.disableDefaultSuperimposeNavigation?.(),this._adapter?.disablePanoramicSuperimposeNavigation?.(),t)switch(t.type){case"2d":{const{default:t}=await import("./adapters/view/MapViewAdapter.js");y(e),this._adapter=new t(this);break}case"3d":{const{default:t}=await import("./adapters/view/SceneViewAdapter.js");y(e),this._adapter=new t(this);break}}else this._adapter=null},this._mapImageConversionToolViewClickHandler=e=>{if(e.stopPropagation(),e.preventDefault(),e.mapPoint){const t=e.mapPoint;t.x=x(t.x,t.spatialReference),this.plotMapPoint(e.mapPoint)}},this._measurementImageClickHandler=e=>{e.stopPropagation(),e.preventDefault();const{sketchTriangular:t,triangularMeasurementActive:i,currentBestFeatureMeasurementImage:r,triangulatedMeasurementGraphic:a}=this;t&&i&&r&&a&&"active"!==t.state&&(t.update([a],{tool:"reshape"}),this.updatingTriangularMeasurementState=!0)},this._updateInteraction=()=>{const e=this.videoMapView.extent;if(!e)return;const{minScale:t}=this.videoMapView.constraints,i=this.videoMapView.scale<t-we,r=Qe(e);i&&!!r?(this._enablePan(),this.videoMapView.constraints.geometry=r):i?(this._disablePan(),this.videoMapView.constraints.geometry=null):(this.initialVideoMapViewExtent&&!this.videoMapView.extent.equals(this.initialVideoMapViewExtent)&&(this.videoMapView.extent=this.initialVideoMapViewExtent),this._disablePan(),this.videoMapView.constraints.geometry=null)},this._viewClickHandler=e=>{this._clickTask?.abort(),this._clickTask=a(async t=>{const{pointerType:i,button:r,mapPoint:a}=e;if("mouse"===i&&0!==r||!a)return;e.stopPropagation(),e.preventDefault();const{view:s,layer:o}=this;if(s){if(o){if(this.shouldShowSelectedImage){const i=s.hitTest(e,{include:[o]});this._updatingHandles.addPromise(i);const r=await i;return y(t),await this._processHitTestResults(o,r,{signal:t})}return this._updatingHandles.addPromise(this.loadBestImage(a,{signal:t}))}this.setMessage("noLayerSelected","info")}})},this.plotSelectedPointOnImage=async(e,i)=>{if(await f(i),!e)return;const r=new L({...k(e)?e.toJSON():e});if("default"===this.mode)r.x-=.5,r.y=.5-r.y,r.spatialReference=this._imageViewer.imageRenderer.spatialReference.clone(),this._crossSymbol=new t({geometry:r,symbol:Ie}),this._imageViewer.addGraphic(this._crossSymbol,0);else if("panoramic"===this.mode){const{imageSize:i,media:r}=this._panoramicViewer;if(!i||!r)return;const a=Be(r),s=ie(e,...i,a);this._crossSymbol=new t({geometry:new L(s,E.WebMercator),symbol:Pe}),this._panoramicViewer.addGraphic(this._crossSymbol,0)}},this.handleSectorClick=this.handleSectorClick.bind(this),this.searchBestImage=this.searchBestImage.bind(this),this.transformAndPlotReferencePointOnImage=this.transformAndPlotReferencePointOnImage.bind(this)}initialize(){this.addHandles([b(()=>this.view,()=>this.load(),M),b(()=>this.view?.map,(e,t)=>{t?.layers.remove(this._overlays),e?.layers.add(this._overlays)},V),b(()=>this.view?.map?.allLayers?.length,e=>{e&&this.view?.map?.layers.reorder(this._overlays,e-1)},V),b(()=>[this.state,this.panoramicVideoLoaded,this.mapImageConversionToolState,this.view,this.disabled,this.panoramicVideoPaused,this.videoViewModel?.videoPaused],(e,t)=>{const i=e[2],r=t?.[2];r&&!i&&(this.plotReferencePointOnGround(null),this.clearReferencePointOnImage()),this._createViewClickHandle(),this._createImageClickHandle()},M),b(()=>[this.triangularMeasurementActive,this.currentBestFeatureMeasurementImage],()=>{this._createTriangularImageClickHandle()},M),b(()=>[this.state,this.imageLocationToolState,this.view],()=>{this._initializeMeasurementService(),this._initializeLocationViewModel()},M),b(()=>this.measureType,()=>{this.clearPreviousMeasurements(),this._initializeMeasurementService()},M),b(()=>this.bestFeatureAngle,(e,t)=>{this.previousFeatureAngle=t??0},M),b(()=>[this.superimposeViewEnabled,this.defaultSuperimposeCameraLockEnabled,this.superimposeViewSupported,this.currentBestFeature,this.mode,this.state,this.view?.type],()=>{this._shouldDisableUnsupportedSuperimposeView()?this.superimposeViewEnabled=!1:this._hasActiveSuperimposeCameraContext()?this._updateSuperimposedImage():this._resetInactiveSuperimposeState()},M),b(()=>this._getSuperimposeCameraWatchState(),()=>this._handleSuperimposeCameraChange(),M),b(()=>this.currentBestFeature,async(e,t)=>{m(this._featureChangedTask),this._featureChangedTask=a(async i=>this.determineWorkflowForFeature.apply(this,[e,t,{signal:i}])),await this._featureChangedTask.promise},{sync:!0}),b(()=>[this.currentNode,this.preloadMedia,this.navigationMode],()=>{this._mediaPrefetchTask?.abort(),this._mediaPrefetchTask=a(async e=>{this.preloadMedia&&null!=this.navigationMode?(this._mediaPrefetcher??=await this._loadMediaPrefetcher({signal:e}),y(e),"directional"===this.navigationMode?this._mediaPrefetcher.enqueueDirectionalPrefetch(this.layer,this.currentNode,this.preloadMediaSize):this._mediaPrefetcher.enqueueSequentialPrefetch(this.layer,this.currentNode,this.preloadMediaSize)):this._mediaPrefetcher?.clear()})},M),b(()=>this.currentBestFeatureMeasurementImage,(e,t)=>{m(this._featureChangedTask),t&&e!==t&&(this.triangulatedPoint=null,this.sketchTriangularGraphicsLayer?.graphics.destroyAll(),this._measurementService?.resetMeasurementVectors()),this._featureChangedTask=a(async i=>{await this.determineWorkflowForTriangularMeasurement(e,t,{signal:i}),y(i),this._reorderTriangularSketchLayer()})},M),b(()=>this.triangularMeasurementActive,(e,t)=>{t&&!e&&(this._measurementService?.resetMeasurementVectors(),this.currentBestFeatureMeasurementImage=null,this.triangulatedDistanceMeasurement=null,this.triangulatedMeasurementGraphic=null,this.triangulatedPoint=null,this.updatingTriangularMeasurementState=!1,this.triangulatedAreaMeasurement=null,this.triangulatedDistanceAccuracy=null,this.triangulatedAreaAccuracy=0,this.sketchTriangularGraphicsLayer?.graphics.destroyAll(),this.clearReferencePointOnImage(),this.imageMeasurementViewer.clearImage(),this.imageMeasurementViewer.clearGraphics(),this._panoramicMeasurementViewer.clearImage(),this._panoramicMeasurementViewer.clearGraphics())}),b(()=>this.mode,e=>{switch(this.removeHandles(Re.interactionHandles),e){case"default":this.addHandles(b(()=>{const{state:e}=this;return"image-loaded"===e?this._imageViewer.imagePointsInView:null},e=>{e&&(m(this._updateFootprintTask),this._updateFootprintTask=a(async t=>{await this.updateFootprint(e,void 0,{signal:t})}))},{...M,equals:(e,t)=>i(e,t,d)}),Re.interactionHandles);break;case"video":this.addHandles(b(()=>{const{footprintExtent:e,videoElement:t,bestFeatureFootprint:i}=this;if(e&&t?.loaded&&i)return{videoExtent:_e,bestFeatureFootprint:i}},e=>{e?.videoExtent&&e?.bestFeatureFootprint&&(m(this._updateFootprintTask),this._updateFootprintTask=a(async t=>{const i={points:e.videoExtent,feature:void 0,scale:void 0,options:{signal:t}};await this.updateVideoFootprint(i)}))},{...M,equals:(e,t)=>i(e?.videoExtent,t?.videoExtent,d)&&e?.bestFeatureFootprint===t?.bestFeatureFootprint}),Re.interactionHandles);break;case"panoramic":this.addHandles(b(()=>{const{currentBestFeature:e,state:t,_panoramicViewer:i}=this,{imageSize:r,vfov:a,hfov:s,pitch:o,yaw:n}=i;return e&&r&&!t.includes("loading")&&null!=a&&null!=s&&null!=o&&null!=n?[a,s,n,o]:null},e=>{if(!e||this.state.includes("loading"))return;const[t,i,r,s]=e;this.currentNode&&(this.currentNode.currentHeading=r,this.currentNode.currentPitch=s),m(this._updateFootprintTask),this._updateFootprintTask=a(async e=>{await this.updateFootprintPanorama({verticalFieldOfView:t,horizontalFieldOfView:i,yaw:r,pitch:s},{signal:e}),this._updateFootprintTask=null})},{equals:(e,t)=>i(e,t,d)}),Re.interactionHandles);break;case"panoramic-video":this.addHandles(b(()=>{const{currentBestFeature:e,state:t,_panoramicVideoViewer:i}=this,{imageSize:r,vfov:a,hfov:s,pitch:o,yaw:n,viewModel:l}=i,c=l.closestFeature??e;return c&&r&&!t.includes("loading")&&null!=a&&null!=s&&null!=o&&null!=n?[a,s,n,o,c]:null},e=>{if(!e)return;const[t,i,r,s,o]=e;m(this._updateFootprintTask),this._updateFootprintTask=a(async e=>{await this.updateFootprintPanorama({verticalFieldOfView:t,horizontalFieldOfView:i,yaw:r,pitch:s,feature:o,horizonAngles:this._panoramicVideoViewer.horizonAngles},{signal:e}),y(e),this._updateFootprintTask=null})},{equals:(e,t)=>i(e,t,d)}),Re.interactionHandles)}},M),b(()=>[this.brightness,this.contrast,this.sharpness],()=>{const{_imageViewer:e,brightness:t,contrast:i,mode:r,sharpness:a}=this;"default"===r&&(e.brightness=t,e.contrast=i,e.sharpness=a)},M),b(()=>this.activeViewer?.imageRenderer,()=>{this.sketch&&(this.sketch.view=this.activeViewer?.imageRenderer)}),b(()=>this.activeViewer,e=>{this.removeHandles(Re.hittestHandles),e&&this.addHandles(F(()=>e,"hittest-response",this._handleImageHitTestResponse),Re.hittestHandles)}),b(()=>this.videoMapView.extent,async()=>{this._scheduleVideoInteractionUpdate();const e=this.videoViewModel?.closestFeature;e&&(m(this._updateFootprintTask),this._updateFootprintTask=a(async t=>{const i={points:this.videoExtentPoints,feature:e,options:{signal:t}};await this.updateVideoFootprint(i)}))}),b(()=>[this.videoMapView.interacting,this.videoMapView.navigating,this.videoMapView.scale],()=>{this._scheduleVideoInteractionUpdate()},{initial:!0}),S(()=>null!=this.videoMapView.extent,()=>{this.initialVideoMapViewExtent=this.videoMapView.extent},{once:!0})]),this.when().finally(()=>{this.notifyChange("state")})}destroy(){this._adapter?.disableDefaultSuperimposeNavigation?.(),this._adapter?.disablePanoramicSuperimposeNavigation?.(),this._abortSuperimposeSchedule(),this.currentBestFeature=null,this._updateFootprintTask=m(this._updateFootprintTask),this._clickTask=m(this._clickTask),this._restoreSuperimposeMediaTask=m(this._restoreSuperimposeMediaTask),this.coverageFrustums.destroy(),this.coveragePolygons.destroy(),this.pointSources.destroy(),this.additionalFootprints.destroy(),this.additionalCameraLocations.destroy(),this.bestFeatureFootprint=p(this.bestFeatureFootprint),this.bestFeatureCurrentFootprint=p(this.bestFeatureCurrentFootprint),this.videoViewModel=p(this.videoViewModel),this._locationViewModel=p(this._locationViewModel),this._crossSymbol=p(this._crossSymbol),this._referencePointOnGround=p(this._referencePointOnGround),this.clearReferencePointOnImage(),this._superimposeService.destroy(),this._overlays&&this.view?.map?.remove(this._overlays),this._overlays.destroy(),this._imageViewer.destroy(),this.imageMeasurementViewer.destroy(),this._panoramicViewer.destroy(),this._panoramicMeasurementViewer.destroy(),this._mediaPrefetcher?.destroy()}get activeLayer(){return o(u.getLogger(this),"activeLayer",{replacement:"layer"}),this.layer}set activeLayer(e){o(u.getLogger(this),"activeLayer",{replacement:"layer"}),this.layer=e}get activeViewer(){const{_imageViewer:e,_panoramicViewer:t,mode:i}=this;switch(i){case"default":return e;case"panoramic":return t;default:return null}}get activeTriangulatedViewer(){switch(this.mode){case"default":return this.imageMeasurementViewer;case"panoramic":return this._panoramicMeasurementViewer;default:return null}}get accuracyParametersMissing(){return this.layer?.orientationAccuracy?.every(e=>0===e)??!0}get brightness(){return this._get("brightness")??0}set brightness(e){this._set("brightness",h(e,-10,10))}get contrast(){return this._get("contrast")??0}set contrast(e){this._set("contrast",h(e,-10,10))}get currentNode(){const{currentBestFeature:e,navigationNodes:t}=this;return t.find(t=>t.id===e?.attributes.objectId)}get depthImageNotSupported(){if(this.currentBestFeature?.attributes.depthImage)return!De(this.currentBestFeature.attributes.depthImage)}get featureCount(){return this.features?.length??0}get imageGalleryEnabled(){const{currentBestFeature:e}=this;if(!e)return!1;const t=e.attributes.imagePath?.trim();return De(t)||Se(t)}get imageLoaded(){return o(u.getLogger(this),"imageLoaded",{replacement:'Use OrientedImageryViewer.state === "image-loaded"',version:"4.29",warnOnce:!0}),"image-loaded"===this.state}get invalidCameraHeading(){return this.currentBestFeature?.attributes?.cameraHeading===Fe}get imagePointsInView(){const{mode:e,_imageViewer:t}=this;return"default"===e?t.imagePointsInView:null}get layerView(){const{layer:e,view:t}=this;if(e&&t)return t.allLayerViews.find(He(e))}get layerFloorFilterClause(){const{layerView:e}=this;return e?ne(e):null}get layerTimeExtent(){return this.layerView?.timeExtent??null}get mode(){const e=this.currentBestFeature?.attributes;if(!e)return"none";const t=e.orientedImageryType;if(t?.includes("video"))return t.includes("360")?"panoramic-video":"video";const{horizontalFieldOfView:i,isSpherical:r}=e;return 360===i||r?"panoramic":"default"}get panoramicVideoLoaded(){const{mode:e,_panoramicVideoViewer:t}=this,{videoLoaded:i}=t.viewModel;return("panoramic-video"===e&&!0===i)??!1}get overlayGraphicsEnabled(){const{mode:e,state:t,panoramicVideoLoaded:i,videoViewModel:r,panoramicVideoPaused:a}=this;return"image-loaded"===t||"video"===e&&"video-loaded"===t&&!0===r?.videoPaused||"panoramic-video"===e&&i&&a}get panoramicVideoPaused(){return!!this._panoramicVideoViewer.viewModel.videoPaused}get popupEnabled(){return!0===this.layer?.popupEnabled}get referencePoint(){return this._referencePointOnGround?.geometry}get sectorData(){const{_sectorData:e}=this;return e?be.map(t=>e[t]):null}get sharpness(){return this._get("sharpness")??0}set sharpness(e){this._set("sharpness",h(e,0,1))}get superimposeViewSupported(){return"default"===this.mode||"panoramic"===this.mode}get sketchGraphicsLayer(){const{sketch:e}=this;return"graphics"===e?.layer?.type?e.layer:void 0}get state(){const{mode:e,_updatingHandles:{updating:t},_featureChangedTask:i,_navigationManager:r}=this;if(!this.isFulfilled()||t||!1===i?.finished||r?.navigating)return"loading";if(this.isRejected())return"error";if("error"===this.displayMessage?.type)return"image-load-error";switch(e){case"default":return this._imageViewer.state;case"panoramic":return this._panoramicViewer.state;case"video":return this.videoElement?.loaded?"video-loaded":"video-not-loaded"}return"ready"}get thumbnails(){const{features:e}=this;return e?new s(e.map(({attributes:{imagePath:e,objectId:t,cameraRoll:i,imageRotation:r}})=>{const a=e?.trim();return De(a)||Se(a)?{url:a,objectId:t,rotation:(i??0)+(r??0)}:null}).filter(r)):null}get videoExtentPoints(){const e=Xe(this.videoMapView.extent);return e.length?e:_e}set view(e){this._set("view",e)}get _defaultGraphicsLayer(){const e={blendMode:"source-atop"};switch(this.mode){case"panoramic":return new D({...e,elevationInfo:{mode:"absolute-height"}});case"default":return new D({...e});default:return}}get _overlaysView(){return this.view?.layerViews.find(({layer:e})=>e===this._overlays)}updateSuperimposeZOffset(e){this._superimposeService.updateZOffset(e)}setDefaultSuperimposeZOffsetPercentage(e){this._superimposeService.setDefaultZOffsetPercentage(e)}setPanoramicSuperimposeRadiusPercentage(e){this._superimposeService.setPanoramicRadiusPercentage(e)}updateDefaultSuperimposeCameraLock(e){this.defaultSuperimposeCameraLockEnabled=e,this.superimposeViewEnabled&&"default"===this.mode&&(e?this._adapter?.enableDefaultSuperimposeNavigation?.():this._adapter?.disableDefaultSuperimposeNavigation?.())}beforeLoad(e=!0){this.emit("popup-close"),e&&(this.displayMessage=null),this._abortSuperimposeSchedule(),this._adapter?.disableDefaultSuperimposeNavigation?.(),this._adapter?.disablePanoramicSuperimposeNavigation?.(),this.clearPreviousGroundLocation(),this.triangularMeasurementActive=!1,this.currentBestFeatureMeasurementImage=null,this.measureType=null,this.imageLocationToolState=!1,this.features.removeAll(),this.currentBestFeature=null,this.additionalFeatures.removeAll(),this.additionalFootprints.removeAll(),this.additionalCameraLocations.removeAll(),this.bestFeatureCurrentFootprint=p(this.bestFeatureCurrentFootprint),this._restoreSuperimposeMediaTask=m(this._restoreSuperimposeMediaTask),this._superimposeService.clear(),this._overlays?.removeAll()}async calculateLocationAccuracy(e){return this._measurementService?.calculateLocationAccuracy(e)}clearLocationPointOnImage(e=!1){this.locationPointOnImage&&!e&&(this._imageViewer.removeGraphic(this.locationPointOnImage),this._panoramicViewer.removeGraphic(this.locationPointOnImage),this.locationPointOnImage=p(this.locationPointOnImage)),this.correctedLocationPointOnImage&&(this.imageMeasurementViewer.removeGraphic(this.correctedLocationPointOnImage),this._panoramicMeasurementViewer.removeGraphic(this.correctedLocationPointOnImage),this.correctedLocationPointOnImage=p(this.correctedLocationPointOnImage))}clearPreviousMeasurements(){this.clearMeasurementGraphics(),this.resetMeasurementData(),this.stopMeasurement()}clearPreviousGroundLocation(){this.groundCoordinates=null,this.groundCoordinatesAccuracy=null,this.pixelCoordinates=null,this.clearLocationPointOnImage()}clearMeasurementGraphics(){this.measurementGraphic&&(this.activeViewer?.removeGraphic(this.measurementGraphic),this.measurementGraphic=null),this.heightGraphic&&(this.activeViewer?.removeGraphic(this.heightGraphic),this.heightGraphic=null),this.triangularMeasurementActive&&this.sketchTriangularGraphicsLayer?.graphics.destroyAll()}digitizeCancel(){return this.sketch?.cancel()}digitizeCanRedo(){return this.sketch?.canRedo()??!1}digitizeCanUndo(){return this.sketch?.canUndo()??!1}digitizeComplete(){return this.sketch?.complete()}async digitizeCreate(e,t){const{sketch:i,dataCaptureLayer:r}=this;if(!i)throw pt();ot(r,e,i),await i.create(e,{...t,defaultZ:0})}digitizeDelete(){if(!this.sketch)throw pt();return this.sketch.delete()}digitizeDuplicate(){if(!this.sketch)throw pt();return this.sketch.duplicate()}digitizePlace(e,t){if(!this.sketch)throw pt();return this.sketch.place(e,t)}digitizeRedo(){if(!this.sketch)throw pt();return this.sketch.redo()}digitizeUndo(){if(!this.sketch)throw pt();return this.sketch.undo()}digitizeUpdate(e,t){if(!this.sketch)throw pt();return this.sketch.update(e,t)}filterByFootprints(e,t,i=!1){const r=[],a=[],s=[];return e.forEach(e=>{const{layer:{coveragePercent:o},attributes:n}=e;let l;const{polygon:c,frustum:d}=q(n);if(l=c.clone(),n.isInspection&&(l=W(n)),o&&(l=$(l,o)),i||!t||Z(l,t)){s.push(e);const{geometry:t,objectId:i,cameraHeight:o,cameraHeading:l}=n,u=t.clone();u.z=o/K(t.spatialReference),u.imageID=i,this.pointSources.push(u),l!==Fe&&(r.push(c),d&&a.push(d))}}),{features:s,polygons:r,frustums:a}}async deleteDataCaptureFeatures(e){const{dataCaptureLayer:t}=this;if(!t)throw new n("orientedimageryviewer:missing-featurelayer","Data capture layer is not available");return t.queryFeatures({objectIds:e,outFields:[t.objectIdField]}).then(({features:e})=>t.applyEdits({deleteFeatures:e}))}handleSectorClick(e){if(isNaN(e))return;const t=this._sectorData?.[be[e]],i=t?.at(0);i&&(this.triangularMeasurementActive&&this.currentBestFeature?this._updateImageMeasurementBestFeature(i):this._updateCurrentBestFeature(i))}handleFeatureClick(e){const{sector:t,featureIndexInSector:i}=e;if(isNaN(i))return;const r=this._sectorData?.[t],a=r?.at(i);a&&(this.triangularMeasurementActive&&this.currentBestFeature?this._updateImageMeasurementBestFeature(a):this._updateCurrentBestFeature(a))}load(e){return this.addResolvingPromise(this._loadViewAdapter(e).catch(e=>{if(!v(e))throw e})),this}async loadBestImage(e,t){return this.selectedPoint=Q(e),this.beforeLoad(),this._fetchFeaturesWithController(e,t)}async loadHeightMeasurementAdapter(e){if(!this.drawAdapter){const t=import("./adapters/draw/HeightMeasurementAdapter.js"),{default:i}=await t;if(y(e),this.drawAdapter=new i({viewModel:this,measurementService:this._measurementService}),!this.drawAdapter.viewModel.isResolved())return}return this.drawAdapter}loadImageError(e){u.getLogger(this).error("oriented-imagery-viewer:load-image",e),this.setMessage("imageLoadError","error",e.message)}async loadSketch(e){if(!this.sketch){const t=import("../Sketch/SketchViewModel.js"),{default:i}=await t;y(e),this.sketch=new i({layer:this._defaultGraphicsLayer,view:this.activeViewer?.imageRenderer,updateOnGraphicClick:!1,defaultUpdateOptions:{reshapeOptions:{edgeOperation:"none",shapeOperation:"none",vertexOperation:void 0},enableMoveAllGraphics:!1,enableRotation:!1,enableScaling:!1,multipleSelectionEnabled:!1,toggleToolOnClick:!1,tool:"transform"}})}return this.sketch}async loadMeasurementAdapter(e){if(!this.sketchAdapter){const t=import("./adapters/sketch/MeasurementAdapter.js"),{default:i}=await t;if(y(e),this.sketchAdapter=new i({viewModel:this,measurementService:this._measurementService}),!this.sketchAdapter.viewModel.isResolved())return}return this.sketchAdapter}async processFeatureResponse(e,t,i){const{features:r}=e;if(this._clearFeatureGeometries(),!this._checkFeatures(r))return;const{features:a,polygons:s,frustums:o}=this.filterByFootprints(r,t,i?.skipFilter);if(!this._checkFeatures(a))return;this.coveragePolygons.addMany(s),this.coverageFrustums.addMany(o);const n=await this.processElevationSample(s,a,i);y(i),await this._updateElevationOfSelectedPointAndLocations(a,t,n),y(i),ze(a,n);let l=a;if(this.layer?.verticalSearchRange&&this.layer.hasZ&&this.verticalFilterEnabled&&(l=Ne(a,t,this.layer.verticalSearchRange),!l.length))return void this.setMessage("noImageAtElevation","info");const c=this._processSuitableFeatures(l,t);this.updateSuitabilities(c,i?.loadBestImage)}async processFeatureElevation(e,t,i){if(!t)return;const{features:r,polygons:a}=this.filterByFootprints(e,t,!0);if(!r?.length)return;const s=await this.processElevationSample(a,r,i);return y(i),s}async startMeasurement(e,t){this.sketch||await this.loadSketch(t),await this.loadMeasurementAdapter(t);const{sketch:i,sketchAdapter:r,activeViewer:a,mode:s}=this;if(!i||!r||!a||"none"===s)return;if(this.displayNewMeasurementButton=!1,"panoramic"===s&&(i.defaultCreateOptions.defaultZ=0),await i.create(e),"panoramic"===s){const{drawOperation:e}=i.view.activeTool;e.constraintsEnabled=!1,e._set("elevationDrawSurface",null)}const o=this.activeViewer?.imageRenderer.effectiveTheme.accentColor;o&&this.sketch&&(this.sketch.polygonSymbol=Ce(o),this.sketch.polylineSymbol="panoramic"===s?Ae:ke(o,2.5))}async startHeightMeasurement(){this.displayNewMeasurementButton=!1,this.draw??=new de({view:this.activeViewer?.imageRenderer}),this.polylineDrawAction=this.draw.create("polyline"),await this.loadHeightMeasurementAdapter()}initializeMeasurement(e){switch(this.clearMeasurementGraphics(),this.resetMeasurementData(),e){case"distance":this.startMeasurement("polyline");break;case"area":this.startMeasurement("polygon");break;case"height":this.startHeightMeasurement()}}async overlayCameraLocations(e){const{activeViewer:i,overlayedCameraLocations:a,layer:s,mode:o,layerFloorFilterClause:n,layerTimeExtent:l,videoViewModel:c,_panoramicVideoViewer:d}=this,u="video"===o,h="panoramic-video"===o,p=this._getActiveFeatureForCurrentMode(),m=this._computeOverlayImageSize();if(!(m&&p&&s&&"none"!==o&&this.overlayGraphicsEnabled))return;const{polygon:g}=q(p.attributes);if(u?c?.removeOverlayGraphics(a.toArray()):h?d.removeManyGraphics(a.toArray()):i?.removeManyGraphics(a.toArray()),a.removeAll(),e){const{features:e}=await s.queryFeatures({where:I(`${s.objectIdField} <> ${p.attributes.objectId}`,I(s.definitionExpression,n)),geometry:g,returnGeometry:!0,outFields:[s.objectIdField],timeExtent:l}),v=await Promise.all(e.map(async e=>{const{attributes:i,geometry:r}=e;if("point"!==r?.type)return null;const a=await this._geometryToOverlayImageGeometry(r,p,m);if(!a)return null;const s="panoramic"===o||"panoramic-video"===o?Te():Oe();return new t({attributes:i,symbol:s,geometry:a})}));a.addMany(v.filter(r)),u?c?.addOverlayGraphics(a.toArray()):h?d.addManyGraphics(a.toArray()):i?.addManyGraphics(a.toArray())}}overlayGraphicsOnImage(e,t){this.removeOverlayedGraphicsOnImage(e),this.overlayedMapFeatures.set(e,t),"video"!==this.mode?"panoramic-video"!==this.mode?this.activeViewer?.addManyGraphics(t.toArray()):this._panoramicVideoViewer.addManyGraphics(t.toArray()):this.videoViewModel?.addOverlayGraphics(t.toArray())}async overlayMapFeatures(e,i=!1){const{activeViewer:a,mode:o,layer:n,videoViewModel:l,_panoramicVideoViewer:c}=this,d="video"===o,h="panoramic-video"===o,p=this._getActiveFeatureForCurrentMode(),m=this._computeOverlayImageSize();if(!(m&&p&&"none"!==o&&this.overlayGraphicsEnabled&&n))return;const{polygon:g}=q(p.attributes);try{const{imageGeometryField:t,oiObjectIdField:i}=nt(e,n.imageGeometryField,n.imageReferenceField);this.imageGeometryField=t.name,this.oiObjectIdField=i.name}catch(w){u.getLogger(this).warn("oriented-imagery-viewer:overlay-map-features",w)}const{features:v}=await e.queryFeatures({geometry:g,returnGeometry:!0,outFields:["*"]}),y=await Promise.all(v.map(async r=>{const s=r.symbol?.clone()??e.renderer?.getSymbol(r)?.clone(),{attributes:n,geometry:g}=r,{imageGeometryField:v,oiObjectIdField:y}=this;if(v&&y&&ht(e,v,y)&&`${n[y]}`==`${p.attributes.objectId}`)try{const r=h?c.horizonAngles:Be(a?.media),u=lt(n,v,e,i,m,d?"default":o,s,r);if(!d)return u;const p=u.geometry;if(!p)return null;const g=l?.imageGeometryToOverlayGeometry(p);return g?new t({attributes:n,layer:e,symbol:u.symbol,geometry:g,visible:u.visible}):null}catch(w){u.getLogger(this).warn("oriented-imagery-viewer:overlay-map-features","couldn't create graphic from attributes, geometry will be used",{error:w,feature:r,layer:e,imageGeometryField:this.imageGeometryField,imageReferenceField:this.oiObjectIdField})}if(!g)return null;const f={feature:p,imageSize:m,footprintExtent:this.footprintExtent},_=await this._geometryToOverlayImageGeometry(g,f.feature,f.imageSize);return _?new t({attributes:n,layer:e,symbol:s,geometry:_,visible:e.visible&&i}):null})),f=new s(y.filter(r));("video"!==o&&"panoramic-video"!==o||this.overlayGraphicsEnabled)&&this.overlayGraphicsOnImage(`${e.id}`,f)}getDepthAt(e){const{activeViewer:t,currentBestFeature:i,mode:r,state:a,depthImage:s}=this,o=t?.imageSize;if(!o||!i||"none"===r||a.includes("loading"))return u.getLogger(this).warnOnce("oriented-imagery-viewer:get-depth-at","Load an image to use depth"),null;if(!s?.loaded)return u.getLogger(this).error("oriented-imagery-viewer:get-depth-at","Depth image is not loaded"),this.emit("depth-image-service:not-loaded"),null;const n=(Array.isArray(e)?e:[e]).map(e=>s.depthAt(e,{width:o[0],height:o[1]})??null);return Array.isArray(e)?n:n[0]}getActiveSectors(){return be.filter(e=>this._sectorData?.[e]?.length)}async getPixelLocationForFeature(e,t,i){return(await this._transformationService.pointToPixelForFeature([e],t,i))[0]}async getPixelLocationsForFeature(e,t,i){return await this._transformationService.pointToPixelForFeature(e,t,i)}async plotMapPoint(e){this.plotReferencePoint(e);const t=this._getActiveFeatureForCurrentMode();if(t)return this.transformAndPlotReferencePointOnImage({feature:t,selectedLocation:e,options:{signal:this._transformController?.signal}})}plotReferencePointOnGround(e){this._referencePointOnGround&&(this._overlays?.remove(this._referencePointOnGround),this._referencePointOnGround.destroy()),null!=e&&(this._referencePointOnGround=new t({geometry:new L({...e.toJSON()}),symbol:Le}),this.view?this._overlays?.add(this._referencePointOnGround):this.emit("plot-ground-point",{data:{point:this._referencePointOnGround?.geometry}}))}plotReferencePointOnImage(e){switch(this.mode){case"video":return void this._plotReferencePointOnVideo(e);case"panoramic-video":return void this._plotReferencePointOnPanoramicVideo(e);case"default":return void this._plotReferencePointOnDefaultImage(e);case"panoramic":return void this._plotReferencePointOnPanoramicImage(e)}}removeAllOverlayMapFeatures(){const{mode:e}=this;this.overlayedMapFeatures.forEach(t=>{const i=t.toArray();switch(e){case"video":this.videoViewModel?.removeOverlayGraphics(i);break;case"panoramic-video":this._panoramicVideoViewer.removeManyGraphics(i);break;default:this.activeViewer?.removeManyGraphics(i)}}),this.overlayedMapFeatures.clear()}removeOverlayedGraphicsOnImage(e){const t=this.overlayedMapFeatures.get(e),{mode:i}=this;if(!t?.length)return;const r=t.toArray();switch(i){case"video":this.videoViewModel?.removeOverlayGraphics(r);break;case"panoramic-video":this._panoramicVideoViewer.removeManyGraphics(r);break;default:this.activeViewer?.removeManyGraphics(r)}this.overlayedMapFeatures.delete(e)}reset(){const{mode:e}=this;"default"===e||"panoramic"===e?this.resetImage():"video"===e?this.resetVideo():"panoramic-video"===e&&this.resetVideoPanoramic(),this.beforeLoad(!1)}resetImage(){switch(this.setMessage("onLoadMessage","info"),this.mode){case"default":this._imageViewer.clearImage(),this._imageViewer.clearGraphics();break;case"panoramic":this._panoramicViewer.clearGraphics()}this._clickTask=m(this._clickTask)}resetVideo(){this.setMessage("onLoadMessage","info"),this.videoViewModel?.resetVideoHandler(),this._overlays?.removeAll(),this.videoViewModel=null,this.featureCache=[],this.currentBestFeature=null}resetVideoPanoramic(){this.setMessage("onLoadMessage","info"),this._overlays?.removeAll(),this.currentBestFeature=null}resetMeasurementData(){this.areaMeasurementResult=0,this.areaMeasurementAccuracy=0,this.distanceMeasurementResult=0,this.distanceAccuracyArray=[],this.heightMeasurementResult=0,this.heightMeasurementAccuracy=0,this.heightGraphic=null,this.triangulatedDistanceMeasurement=null,this.triangulatedDistanceAccuracy=null,this.triangulatedAreaMeasurement=null,this.triangulatedMeasurementGraphic=null,this.updatingTriangularMeasurementState=!1,this.triangulatedAreaAccuracy=0,this._measurementService?.resetMeasurementVectors()}async saveDrawing(){const{dataCaptureLayer:e,sketchAdapter:t}=this;if(!e||"data-capture"!==t?.type)return;const{pendingGraphics:i,savedGraphics:r}=t,a=i.get(e.id),s=a?.toArray();if(!a||!s?.length)return;const{addFeatureResults:o}=await this.saveDataCaptureFeatures(s),n=o.reduce((t,{objectId:i,globalId:r,error:a},o)=>{const n=s[o],{attributes:l}=n;return a?t.error.push(n):(i&&(l[e.objectIdField]=i),r&&e.globalIdField&&(l[e.globalIdField]=r),t.success.push(n)),t},{success:[],error:[]});r.addMany(n.success),a.removeAll(),a.addMany(n.error)}async saveDataCaptureFeatures(e,t){const{activeViewer:i,currentBestFeature:a,dataCaptureLayer:s,mode:o}=this,l=i?.imageSize;if(!l||!a||"none"===o||"video"===o||"panoramic-video"===o)throw new n("orientedimageryviewer:missing-input","Image size, current best feature and mode are required to save data capture features");if(!s)throw new n("orientedimageryviewer:missing-featurelayer","Data capture layer is not available");const c=await Promise.all(e.map(async e=>{const i=e.clone(),{geometry:r}=i;if(!r)return;const a=r.type,o=s.hasZ,n=s.geometryType,l=a!==n,c=l?await import("./transformers.js"):null,d=c?.default[n],u=l?d?.(r):r;return u&&(i.geometry=await this._transformationService.imageGeometryToMapGeometry(u,t),i.geometry)?(o||ct(i.geometry),i):void 0})),d=c.filter(r);return s.applyEdits({addFeatures:d}).then(e=>{const{addFeatureResults:t}=e;let i=0;const r=c.map(e=>{const r=t[i++];return e?r:{error:new n("orientedimageryviewer:save-unsucccessful","Error in saving data capture features"),objectId:null,globalId:null}});return{...e,addFeatureResults:r}})}async searchBestImage(e,t){try{const i=await z(e,t);i&&await this.processFeatureResponse(i,e.point,t)}catch(i){v(i)||(this.setMessage("imageLoadError","error",i.message),u.getLogger(this).error("error occurred while finding best image",i))}}selectTriangularMeasurementFeature(e){this.currentBestFeatureMeasurementImage=this.features?.find(({attributes:t})=>t.objectId===Number(e))}setAdditionalCameraLocationsVisibility(e){this.additionalCameraLocations.forEach(t=>{t.visible=e})}setAdditionalCoverageVisibility(e){this.additionalFootprints.forEach(t=>{t.visible=e})}setCurrentCoverageVisibility(e){this.bestFeatureCurrentFootprint&&(this.bestFeatureCurrentFootprint.visible=e),this.currentBestFeatureLocation&&(this.currentBestFeatureLocation.visible=e)}setMapImageConversionToolState(e){this.mapImageConversionToolState=e}setCurrentPanoramaView(e,t){this._panoramicViewer?.set({yaw:e,pitch:t})}async startDataCapture(e,t){const i=this.activeViewer?.imageRenderer,{oiObjectIdField:r,currentBestFeature:a}=this;if(!i||!a||!r)return;const{attributes:{objectId:o}}=a,n=this.overlayedMapFeatures.get(e.id)?.toArray()??[],l=[],c=[];for(const s of n)`${s.getAttribute(r)}`==`${o}`?l.push(s):c.push(s);this.overlayGraphicsOnImage(e.id,new s(c)),this.collectionId=e.id;const d=await this.loadSketch(t),u=await this.loadDataCaptureAdapter(t);y(t),d.addGraphics(l),u.savedGraphics.addMany(l);i.ui.find("zoom").visible=!1,i.map.layers.add(this.sketchGraphicsLayer)}async stopDataCapture(e=!1){this.sketch?.cancel(),this.sketchGraphicsLayer?.removeAll(),this.sketchAdapter=p(this.sketchAdapter),this.sketch=p(this.sketch),this.collectionId=null;const{dataCaptureLayer:t}=this,i=this.activeViewer?.imageRenderer;if(!i||i.destroyed)return;i.map.layers.remove(this.sketchGraphicsLayer),e&&t&&await this.overlayMapFeatures(t,!0);const r=i.ui.find("zoom");r&&(r.visible=!0)}stopMeasurement(){this.draw?.reset(),this.sketch?.cancel()}async toggleAllOverlayMapFeatures(e){!e&&this.dataCaptureLayer&&(await this.stopDataCapture(!0),this.dataCaptureLayer=null),this.overlayedMapFeatures.forEach(t=>{this._toggleVisiblity(t,e)})}toggleOverlayMapFeatures(e,t,i){const r=this.overlayedMapFeatures.get(e);r&&i&&this._toggleVisiblity(r,t)}toggleSelection(e){const{sketch:t}=this;t&&(t.updateOnGraphicClick=e,t.cancel())}async transformAndPlotReferencePointOnImage(e){const{feature:t,selectedLocation:i,options:r}=e;let a=!1,s=!1;const o="video"===this.mode?this.bestFeatureCurrentFootprint?.geometry:this.bestFeatureFootprint?.geometry;switch(o?.type){case"polygon":{const e=i.spatialReference.equals(o.spatialReference)?i:await G(i,o.spatialReference);a=o.contains(e);break}case"mesh":{const e=i.spatialReference.equals(o.spatialReference)?i:await G(i,o.spatialReference);s=o.extent.contains(e);break}}if(!a&&!s)return void this.clearReferencePointOnImage();const n="video"===this.mode||"panoramic-video"===this.mode?await this.getPixelLocationForFeature(i,{feature:t,mode:this.mode,imageSize:ye,footprintExtent:this.footprintExtent},r):await this._transformationService.pointToPixel(i,r);if(n)return y(r),this.plotReferencePointOnImage(n),{x:n.x,y:n.y};this.clearReferencePointOnImage()}async updateFeatureCache(e,t){const i=await N(e,t);i.features?.length&&(this.featureCache=i.features)}_plotReferencePointOnVideo(e){"video-loaded"===this.state&&this.videoViewModel?.videoPaused&&(this.clearReferencePointOnImage(),this.videoViewModel.plotReferencePointOnVideo(e))}_plotReferencePointOnPanoramicVideo(e){const i=this._panoramicVideoViewer,{imageSize:r,media:a}=i.viewModel;if(!this.panoramicVideoLoaded||!this.panoramicVideoPaused||!r)return;this.clearReferencePointOnImage();const s=Be(a),o=dt(e,"panoramic",r,s);this._referencePointOnImage=new t({geometry:o,symbol:Ge.clone()}),i.addGraphic(this._referencePointOnImage,0)}_getActiveFeatureForCurrentMode(){switch(this.mode){case"video":return this.videoViewModel?.closestFeature??this.currentBestFeature;case"panoramic-video":return this._panoramicVideoViewer.viewModel.closestFeature??this.currentBestFeature;default:return this.currentBestFeature}}_plotReferencePointOnDefaultImage(e){const i=this._imageViewer,{imageSize:r}=i;if("image-loaded"!==this.state||!r)return;this.clearReferencePointOnImage();const a=dt(e,"default",r);this._referencePointOnImage=new t({geometry:a,symbol:Le.clone()}),i.addGraphic(this._referencePointOnImage,0)}_plotReferencePointOnPanoramicImage(e){const i=this._panoramicViewer,{imageSize:r,media:a}=i;if("image-loaded"!==this.state||!r)return;this.clearReferencePointOnImage();const s=Be(a),o=dt(e,"panoramic",r,s);this._referencePointOnImage=new t({geometry:o,symbol:Ge.clone()}),i.addGraphic(this._referencePointOnImage,0)}async _fetchFeatures(e,t){const{layer:i,layerFloorFilterClause:r,layerTimeExtent:a,view:s}=this;if(!s)return;if(!i)return void this.setMessage("noLayerSelected","info");e.x=x(e.x,e.spatialReference);const o=i.spatialReference.equals(e.spatialReference)?e:await G(e,i.spatialReference),n=o.spatialReference.isGeographic?B(o):o,l=I("1=1",I(i.definitionExpression,r)),c=n.spatialReference.isGeographic?1:P(n.spatialReference),d={layerInstanceOrURL:i,point:n,queryParams:{where:l,maximumDistance:i.maximumDistance?i.maximumDistance/c:void 0,timeExtent:a}};return await this.searchBestImage(d,t)}async _fetchFeaturesWithController(e,t){try{await this._fetchFeatures(e,t)}catch(i){if(v(i))return;this.setMessage("imageLoadError","error"),u.getLogger(this).error("error occurred while fetching features",i)}}_groupFeaturesBySectors(){const{_suitabilities:e,additionalFeatures:t,features:i,invalidCameraHeading:r}=this,a=i.at(0);if(!e||!t||!a||!i||r)return void(this._sectorData=null);this._sectorData={};const o={};this._featureToSector=o;for(const d of be)this._sectorData[d]=new s;const n=e.map((e,t)=>({...e,featureIndex:t}));n.sort((e,t)=>e.trueSuitability-t.trueSuitability);const l=n.map(({distance:e})=>e),c=Math.max(...l);n.forEach(e=>{const{distance:t,angle:r,featureIndex:s}=e,n=t/c*Ve[2],l=Ze(t,c),d=Je(r);if(!this._sectorData)return;const u=Ve[3]+n*Math.sin(r*Math.PI/180),h=Ve[3]+n*Math.cos(r*Math.PI/180);let p;const m=i.at(s),g=m===a,{cameraPitch:v}=m.attributes,y=v<5;if(g&&y)p=-90;else{const e=u-Ve[3],t=h-Ve[3],i=t/Math.sqrt(e**2+t**2);let r=180*Math.acos(i)/Math.PI;(e<0&&t<0||e<0&&t>0)&&(r*=-1),p=r}const f=""===l?d:`${l}_${d}`;g&&(p===this.bestFeatureAngle?this.previousFeatureAngle=p:this.bestFeatureAngle=p,this.navigatorCurrentBestFeature=y?null:{x:u,y:h,direction:d}),o[`${m.attributes.objectId}`]=f;const w=this._sectorData[f];w.add({angle:r,featureIndex:s,x:u,y:h,objectID:m.attributes.objectId,sector:f,featureIndexInSector:w.length})})}async _initializeLocationViewModel(e){if(!this._locationViewModel){const t=import("./components/ImageLocationViewModel.js"),{default:i}=await t;y(e),this._locationViewModel=new i({oiViewModel:this,referenceTransformationService:this._referenceTransformationService})}}_initializeMeasurementService(){this._measurementService||(this._measurementService=new at({transformationService:this._transformationService,referenceTransformationService:this._referenceTransformationService}))}_initializeVideo(){if(this.videoElement||!this.currentBestFeature)return;this.removeHandles(Re.videoPlayerHandles),this.videoElement=new le({video:this.currentBestFeature.attributes.imagePath,georeference:new oe({extent:new O(Me)}),autoplay:!1}),this.videoElement.content?.loop&&(this.videoElement.content.loop=!1);const e=new H({source:this.videoElement,title:this.layer?.title,copyright:this.layer?.copyright});this.videoLayer=e,e&&this.videoMapView.map.layers.add(e),this.videoViewModel=new tt({oiViewModel:this})}async getMapPoint(e,t){const i=await this._transformationService.pixelToMapPoint(Array.isArray(e)?e:[e],t);return Array.isArray(e)?i:i[0]}async getMapPointForFeature(e,t,i){const r=await this._transformationService.pixelToMapPointForFeature(Array.isArray(e)?e:[e],t,i);return Array.isArray(e)?r:r[0]}async loadPanoramicMediaSource(e,t){const{lookAt:i,...r}=e,a=Ue(r);try{await a.load(t)}catch(o){if(v(o))return;if("unsupported-format"===o.name)return void this.setMessage("unsupportedPanoramicImageryError","error",void 0,{datasetFormat:a?.extension??"UNKNOWN FORMAT"})}const s=this.triangularMeasurementActive?this._panoramicMeasurementViewer:this._panoramicViewer;await s.loadMedia(a,t),i&&s.set(i)}async loadMediaSource(e,t){const i=qe(e);await this._setImageSource(this.triangularMeasurementActive?this.imageMeasurementViewer:this._imageViewer,i,t)}_clearFeatureGeometries(){this.coveragePolygons.removeAll(),this.coverageFrustums.removeAll(),this.pointSources.removeAll()}_checkFeatures(e){return!!e?.length||(this.emit("no-image-found"),this.setMessage("noImageError","error"),this.videoElement?.content?.pause(),this.currentBestFeature=null,!1)}async _getElevationSampleFromGround(e,t,i){if(!e[0])return;const r=(await import("../../geometry/operators/unionOperator.js")).executeMany(e);if(this._updateFootprintWithFeatures(t,r),"3d"===this.view?.type)try{return await this.view.map.ground.createElevationSampler(this.footprintExtent,i)}catch(a){v(a)||u.getLogger(this).error(a)}}async processElevationSample(e,t,i){const{elevationSource:r}=t[0].attributes,a=await this._getElevationSampleFromGround(e,t,i);return a||(r&&this.footprintExtent&&J(r)?await Y({extent:this.footprintExtent,lod:r.lod,url:r.url,rasterFunction:r.rasterFunction}):void 0)}_processSuitableFeatures(e,t){return U({features:e,selectedPoint:t,camera:We(this.view)?this.view.camera:null,currentImage:this.currentBestFeature})}async _processHitTestResults(e,t,i){const{results:[r]}=t;if("graphic"!==r?.type)return this.beforeLoad(!1),this.emit("no-image-found"),void this.setMessage("noImageError","error");const a=r.graphic.getAttribute(e.objectIdField);return await this.showImageByObjectId(a,i)}async _queryAndLoadByObjectId(e,t,i,r,a){this.displayMessage=null;const{response:s}=await rt(e,t,i,r,a);if(y(a),!s?.features?.length)throw new it(t);const o=q(s.features[0].attributes).polygon,n=L.fromJSON(j(o)),l=Q(n),c=P(l.spatialReference);this.selectedPoint=l;const d={layerInstanceOrURL:e,point:l,queryParams:{where:I(I("1=1",I(e.definitionExpression,i)),`${e.objectIdField} <> ${t}`),maximumDistance:e.maximumDistance?e.maximumDistance/c:void 0,timeExtent:r}},u=await z(d,a);y(a);const{features:h}=u;return h.push(s.features[0]),await this.processFeatureResponse(u,l,{...a,loadBestImage:!1})}_reorderTriangularSketchLayer(){const e=this.imageMeasurementViewer.imageRenderer.map.layers?.length;this.sketchTriangularGraphicsLayer&&e&&this.imageMeasurementViewer.imageRenderer.map.layers.reorder(this.sketchTriangularGraphicsLayer,e-1)}async _setImageSource(e,t,i){e.media=t,await e.loadMedia(t,i)}_toggleVisiblity(e,t){e.forEach(e=>{e.visible=t})}async _updateElevationOfSelectedPointAndLocations(e,t,i,r){const{location:a,cameraHeight:s}=e[0].attributes,o=await re(a.spatialReference,a.z,s,{elevationSample:i,elevationSource:i?void 0:e[0].attributes.elevationSource,extent:this.footprintExtent},r);y(r);const[n,...l]=await X([t,...e.map(e=>e.attributes.geometry.clone())],o);y(r),t.elevation=n.z,e.forEach((e,t)=>{e.attributes.elevation=l[t].z})}_updateFeatures(e,t=!0){if(!e.length)return this.currentBestFeature=null,void this.additionalFeatures.removeAll();this.features.removeAll(),this.features.addMany(e),this.navigationNodes.removeAll(),this.navigationNodes.addMany(e.map(e=>{const{geometry:t,attributes:i}=e,{isSpherical:r,cameraHeading:a,cameraPitch:s}=i;return new et({geometry:t,attributes:i,currentHeading:r?0:a,currentPitch:r?0:s})})),e.length>1?this.additionalFeatures.addMany(e.slice(1)):this.additionalFeatures.removeAll(),this._updateGroundElevation=!0,t&&(this.currentBestFeature=e[0])}_updateFootprintWithFeatures(e,t){const i=[];for(const{attributes:{geometry:r}}of e)t.contains(r)||i.push([r.x,r.y]);i.sort((e,t)=>+R([e,t])),t.addRing(i),this.footprintExtent=ue(t.extent,2,2)}_scheduleVideoInteractionUpdate(){this.scheduledFrameId||(this.scheduledFrameId=requestAnimationFrame(()=>{this.scheduledFrameId=null,this._updateInteraction()}))}async _updatePointsAndPolygons(e){const{pointSources:i,currentBestFeature:r,currentCoverageVisible:a,isAdditionalPointSourcesVisible:s,mode:o,layer:n}=this;if(r&&(this.additionalFootprints.removeAll(),this.additionalCameraLocations.removeAll(),this.bestFeatureCurrentFootprint&&(this.bestFeatureCurrentFootprint.destroy(),this.bestFeatureCurrentFootprint=null,this.bestFeatureFootprint=null),!this.invalidCameraHeading)){await(this._adapter?.createFootprints(e)),y(e);for(const o of i){const i=this.view&&!this.view.spatialReference?.equals(o.spatialReference)?await G(o.clone(),this.view?.spatialReference,e):o.clone();o.imageID===r.attributes.objectId?this.currentBestFeatureLocation=new t({attributes:{imageID:o.imageID},geometry:i,symbol:Ee,visible:a}):this.additionalCameraLocations.push(new t({attributes:{imageID:o.imageID},geometry:i,symbol:je,visible:s}))}"video"!==o&&"panoramic-video"!==o||(await this.initializeTransformationService(e),n&&!this.featureCache.length&&await this.updateFeatureCache(n,r.geometry.spatialReference))}}_updateCurrentBestFeature(e){if(!e)return;if(this.currentBestFeature=this.features?.at(e.featureIndex),"video"===this.mode)return void(this.currentBestFeature&&this.videoViewModel?.playVideoFromSelectedLocation(this.currentBestFeature));if("panoramic-video"===this.mode)return void(this.currentBestFeature&&this._panoramicVideoViewer.viewModel.playPanoramicVideoFromSelectedLocation(this.currentBestFeature));const t=this.currentBestFeature?.attributes.cameraPitch&&this.currentBestFeature?.attributes.cameraPitch<5;let i;if(t)i=-90;else{const t=e.x-Ve[3],r=e.y-Ve[3],a=r/Math.sqrt(t**2+r**2);let s=180*Math.acos(a)/Math.PI;(t<0&&r<0||t<0&&r>0)&&(s*=-1),i=s}i===this.bestFeatureAngle?this.previousFeatureAngle=i:this.bestFeatureAngle=i,this.navigatorCurrentBestFeature=t?null:{x:e.x,y:e.y,direction:e.sector.includes("_")?e.sector.split("_")[1]:e.sector}}_updateImageMeasurementBestFeature(e){e&&(this.currentBestFeatureMeasurementImage=this.features?.at(e.featureIndex))}clearGraphics(){this._imageViewer.clearGraphics(),this._panoramicViewer.clearGraphics(),this.imageMeasurementViewer.clearGraphics(),this._panoramicMeasurementViewer.clearGraphics()}clearReferencePointOnImage(){this._referencePointOnImage&&(this._imageViewer.removeGraphic(this._referencePointOnImage),this._panoramicViewer.removeGraphic(this._referencePointOnImage),this._panoramicVideoViewer.removeGraphic(this._referencePointOnImage),this._referencePointOnImage=p(this._referencePointOnImage)),this.videoViewModel?.clearReferencePointOnVideo()}async initializeReferenceTransformationService(e){const{currentBestFeatureMeasurementImage:t,activeTriangulatedViewer:i,mode:r}=this;if(!t||!i||!i.imageSize||"panoramic"!==r&&"default"!==r)return;const{imageSize:a}=i,{attributes:s,elevationSample:o}=t,{location:{spatialReference:n,z:l},cameraHeight:c,elevationSource:d}=s;let u=s.location;u.spatialReference.isGeographic&&(u=Q(u));const h="default"===r?ae(s,a[0],a[1]):se(s,a[0],a[1]),p=await re(n,l??0,c,{elevationSample:o,elevationSource:d,extent:this.footprintExtent},e),m=(await import("./services/TransformationService.js")).default,g={imageToWorldProperties:h,updateElevationProps:p,mode:r,imageSize:a,depthImageService:this.depthImage};this._referenceTransformationService=new m(g),this._locationViewModel&&(this._locationViewModel.referenceTransformationService=this._referenceTransformationService),this._measurementService&&(this._measurementService.referenceTransformationService=this._referenceTransformationService)}async initializeTransformationService(e){const{currentBestFeature:t,activeViewer:i,mode:r}=this,a="video"===r||"panoramic-video"===r?ye:i?.imageSize;if(!t||!a||"none"===r)return;const{attributes:s,elevationSample:o}=t,{location:{spatialReference:n,z:l},cameraHeight:c,elevationSource:d}=s;let u=s.location;u.spatialReference.isGeographic&&(u=Q(u));const h="default"===r||"video"===r?"default":"panoramic",p={..."default"===h?ae(s,a[0],a[1]):se(s,a[0],a[1]),cameraLocation:u},m=await re(n,l??0,c,{elevationSample:o,elevationSource:d,extent:this.footprintExtent},e),g=(await import("./services/TransformationService.js")).default,v={imageToWorldProperties:p,updateElevationProps:m,mode:h,imageSize:a,depthImageService:this.depthImage};this._transformationService=new g(v),this._measurementService&&(this._measurementService.transformationService=this._transformationService)}plotReferencePoint(e){"mapPoint"in e?this.plotReferencePointOnGround(e.mapPoint):this.plotReferencePointOnGround(e)}setMessage(e,t,i,r){this.displayMessage={key:e,type:t,data:i,map:r}}async transformAndPlotSelectedLocation(e){const{currentBestFeature:t,invalidCameraHeading:i,selectedPoint:r,activeViewer:a}=this;if(this._crossSymbol&&(this._panoramicViewer.removeGraphic(this._crossSymbol),this._imageViewer.removeGraphic(this._crossSymbol),this._crossSymbol=p(this._crossSymbol)),!r||!t||"image-loaded"!==a?.state||i)return;let s;try{s=await this._transformationService.pointToPixel(r,{signal:e?.signal}),y(e),await this.plotSelectedPointOnImage(s,e)}catch(o){v(o)||u.getLogger(this).error("failed to transform map point to pixel, cross symbol will not be plotted on image",{error:o,selectedPoint:r,feature:t})}}updateCurrentCoveragePolygon(e){const{additionalFootprints:i,additionalCameraLocations:r,currentBestFeature:a,currentBestFeatureLocation:s,currentCoverageVisible:o,selectedPoint:n,view:l,_adapter:c,mode:d}=this;if(!a)return;const{attributes:{objectId:u},elevationSample:h}=a;if(this._initialCurrentCoverageUpdate){if(this._overlays?.removeAll(),this._initialCurrentCoverageUpdate=!1,this.bestFeatureCurrentFootprint=p(this.bestFeatureCurrentFootprint),e&&!this.invalidCameraHeading&&(e.visible=o,this.bestFeatureCurrentFootprint=e),l){const e=[...i,...r,s].filter($e);"3d"===l?.type&&h&&c?.updateGroundElevation&&(this._updateGroundElevation&&c.updateGroundElevation(e),"panoramic"===d&&c.updateGroundElevation([this.bestFeatureCurrentFootprint])),this._updateGroundElevation=!1,n&&(e.splice(-2,0,this.bestFeatureCurrentFootprint),e.push(new t({geometry:n.clone(),symbol:Ie.clone(),attributes:{imageID:u}}))),this._overlays.graphics.addMany(e)}}else if(l){if(this.invalidCameraHeading)return void this._superimposeService.clear();this.bestFeatureCurrentFootprint&&(this._overlays?.remove(this.bestFeatureCurrentFootprint),this.bestFeatureCurrentFootprint=p(this.bestFeatureCurrentFootprint));const t=this.bestFeatureCurrentFootprint&&this._overlays?this._overlays.graphics.indexOf(this.bestFeatureCurrentFootprint):-1;e&&(this.bestFeatureCurrentFootprint=e,"3d"===l?.type&&h&&c?.updateGroundElevation&&"panoramic"===d&&c.updateGroundElevation([e]),e.visible=this.currentCoverageVisible,this._overlays?.graphics.add(this.bestFeatureCurrentFootprint,t>=0?t:this._overlays.graphics.length-1))}}_updateSuperimposedImage(){if(!this._hasActiveSuperimposeCameraContext())return;const e="panoramic"===this.mode?this._panoramicViewer:null,{currentBestFeature:t,defaultSuperimposeCameraLockEnabled:i,layer:r,mode:a,view:s,state:o,superimposeViewEnabled:n,superimposeViewSupported:l,activeViewer:c,depthImage:d}=this,u=this.coverageFrustums.find(({imageID:e})=>e===t?.attributes.objectId);this._superimposeService.update({activeImageSize:c?.imageSize||void 0,adapter:this._adapter,currentBestFeature:t,currentBestFeatureFrustum:u,defaultSuperimposeCameraLockEnabled:i,depthImageLoaded:d?.loaded??!1,layer:r,mode:a,panoramicCamera:e?.camera,state:o,superimposeViewEnabled:n&&l,view:s}),this.setMessage("superimposeImageDescription","info"),this._superimposePreviousCurrentCoverageVisible??=this.currentCoverageVisible,this.currentCoverageVisible=!1}_getSuperimposeCameraWatchState(){const e="3d"===this.view?.type?this.view:null,t=e?.camera;return[this.superimposeViewEnabled,this.superimposeViewSupported,this.mode,this.state,this.view?.type,this.view?.interacting,this.view?.navigating,t?.heading,t?.tilt,t?.fov,t?.position.x,t?.position.y,t?.position.z]}_handleSuperimposeCameraChange(){const e=this.view,t="3d"===e?.type?e:null;this._hasActiveSuperimposeCameraContext()?"panoramic"!==this.mode?!t||t.interacting||t.navigating?this._abortSuperimposeSchedule():this._scheduleDefaultSuperimposeUpdate():this._schedulePanoramicSuperimposeUpdate():this._abortSuperimposeSchedule()}_shouldDisableUnsupportedSuperimposeView(){return this.superimposeViewEnabled&&"panoramic"===this.mode&&!this.superimposeViewSupported}_hasActiveSuperimposeCameraContext(){return("default"===this.mode||"panoramic"===this.mode)&&this.superimposeViewEnabled&&this.superimposeViewSupported&&"image-loaded"===this.state&&"3d"===this.view?.type&&!!this.view.camera}_abortSuperimposeSchedule(){this._superimposeScheduleController?.abort(),this._superimposeScheduleController=null,this._clearSuperimposeDebounceTimeout(),this._clearSuperimposeScheduledFrame()}_resetInactiveSuperimposeState(){const e=null!=this._superimposePreviousCurrentCoverageVisible;this._abortSuperimposeSchedule(),this._adapter?.disableDefaultSuperimposeNavigation?.(),this._adapter?.disablePanoramicSuperimposeNavigation?.(),this._superimposeService.clear(),this._restoreCurrentCoverageVisibilityAfterSuperimpose(),this._restoreDefaultMessageAfterSuperimpose(),e&&this._restoreViewerMediaAfterSuperimpose()}_restoreCurrentCoverageVisibilityAfterSuperimpose(){null!=this._superimposePreviousCurrentCoverageVisible&&(this.currentCoverageVisible=this._superimposePreviousCurrentCoverageVisible,this._superimposePreviousCurrentCoverageVisible=null)}_restoreViewerMediaAfterSuperimpose(){const{currentBestFeature:e,mode:t}=this;if(!e||"default"!==t&&"panoramic"!==t)return;this._restoreSuperimposeMediaTask?.abort();const i=a(async t=>{await this._loadCurrentFeatureMedia(e,{signal:t})});this._restoreSuperimposeMediaTask=i,i.promise.finally(()=>{this._restoreSuperimposeMediaTask===i&&(this._restoreSuperimposeMediaTask=null)})}_restoreDefaultMessageAfterSuperimpose(){if("superimposeImageDescription"===this.displayMessage?.key){!!this.currentBestFeature&&("default"===this.mode||"panoramic"===this.mode)?this.displayMessage=null:this.setMessage("onLoadMessage","info")}}_clearSuperimposeDebounceTimeout(){null!=this.superimposeDebounceTimeoutId&&(clearTimeout(this.superimposeDebounceTimeoutId),this.superimposeDebounceTimeoutId=null)}_clearSuperimposeScheduledFrame(){null!=this.superimposeScheduledFrameId&&(cancelAnimationFrame(this.superimposeScheduledFrameId),this.superimposeScheduledFrameId=null)}_schedulePanoramicSuperimposeUpdate(){this._abortSuperimposeSchedule(),this.superimposeDebounceTimeoutId=window.setTimeout(()=>{this.superimposeDebounceTimeoutId=null,this._hasActiveSuperimposeCameraContext()&&"panoramic"===this.mode&&this._updateSuperimposedImage()},150)}_scheduleDefaultSuperimposeUpdate(){const e=this.view;if(!("3d"===e?.type?e:null))return;if(this.superimposeScheduledFrameId)return;this._superimposeScheduleController?.abort();const t=new AbortController,{signal:i}=t,r=()=>{this._clearSuperimposeDebounceTimeout(),this._clearSuperimposeScheduledFrame(),this._superimposeScheduleController===t&&(this._superimposeScheduleController=null),i.removeEventListener("abort",r)};this._superimposeScheduleController=t,i.addEventListener("abort",r),this.superimposeScheduledFrameId=requestAnimationFrame(()=>{if(i.removeEventListener("abort",r),this.superimposeScheduledFrameId=null,this._superimposeScheduleController===t&&(this._superimposeScheduleController=null),i.aborted)return;const e=this.view,a="3d"===e?.type?e:null;!this._hasActiveSuperimposeCameraContext()||null==a||a.interacting||a.navigating||this._updateSuperimposedImage()})}};e([C()],mt.prototype,"activeLayer",null),e([C({readOnly:!0})],mt.prototype,"activeViewer",null),e([C()],mt.prototype,"activeTriangulatedViewer",null),e([C()],mt.prototype,"accuracyParametersMissing",null),e([C()],mt.prototype,"additionalFeatures",void 0),e([C({type:s.ofType(t)})],mt.prototype,"additionalCameraLocations",void 0),e([C({type:s.ofType(t)})],mt.prototype,"additionalFootprints",void 0),e([C()],mt.prototype,"areaMeasurementResult",void 0),e([C()],mt.prototype,"areaMeasurementAccuracy",void 0),e([C()],mt.prototype,"bestFeatureAngle",void 0),e([C()],mt.prototype,"bestFeatureCurrentFootprint",void 0),e([C({type:t})],mt.prototype,"bestFeatureFootprint",void 0),e([C({type:Number})],mt.prototype,"brightness",null),e([C()],mt.prototype,"cameraHeadingThreshold",void 0),e([C()],mt.prototype,"cameraPitchThreshold",void 0),e([C()],mt.prototype,"clickAction",void 0),e([C()],mt.prototype,"correctedLocationPointOnImage",void 0),e([C()],mt.prototype,"videoViewModel",void 0),e([C()],mt.prototype,"collectionId",void 0),e([C({type:Number})],mt.prototype,"contrast",null),e([C()],mt.prototype,"coverageFrustums",void 0),e([C()],mt.prototype,"coveragePolygons",void 0),e([C()],mt.prototype,"currentBestFeature",void 0),e([C()],mt.prototype,"currentBestFeatureMeasurementImage",void 0),e([C()],mt.prototype,"currentBestFeatureLocation",void 0),e([C()],mt.prototype,"currentCoverageVisible",void 0),e([C()],mt.prototype,"currentNode",null),e([C()],mt.prototype,"depthImage",void 0),e([C()],mt.prototype,"depthImageNotSupported",null),e([C()],mt.prototype,"featureCache",void 0),e([C()],mt.prototype,"navigationNodes",void 0),e([C({json:{write:!1}})],mt.prototype,"determineWorkflowForFeature",void 0),e([C({json:{write:!1}})],mt.prototype,"determineWorkflowForTriangularMeasurement",void 0),e([C()],mt.prototype,"disabled",void 0),e([C()],mt.prototype,"displayMessage",void 0),e([C()],mt.prototype,"displayNewMeasurementButton",void 0),e([C()],mt.prototype,"distanceMeasurementResult",void 0),e([C()],mt.prototype,"distanceAccuracyArray",void 0),e([C()],mt.prototype,"dataCaptureLayer",void 0),e([C({readOnly:!0})],mt.prototype,"featureCount",null),e([C()],mt.prototype,"features",void 0),e([C()],mt.prototype,"groundCoordinates",void 0),e([C()],mt.prototype,"groundCoordinatesAccuracy",void 0),e([C()],mt.prototype,"heightGraphic",void 0),e([C()],mt.prototype,"heightMeasurementResult",void 0),e([C()],mt.prototype,"heightMeasurementAccuracy",void 0),e([C({readOnly:!0})],mt.prototype,"imageGalleryEnabled",null),e([C()],mt.prototype,"imageGeometryField",void 0),e([C({readOnly:!0})],mt.prototype,"imageLoaded",null),e([C()],mt.prototype,"imageLocationToolState",void 0),e([C()],mt.prototype,"initialVideoMapViewExtent",void 0),e([C({readOnly:!0})],mt.prototype,"invalidCameraHeading",null),e([C()],mt.prototype,"imagePointsInView",null),e([C()],mt.prototype,"imageMeasurementViewer",void 0),e([C()],mt.prototype,"isAdditionalCoverageVisible",void 0),e([C()],mt.prototype,"isAdditionalPointSourcesVisible",void 0),e([C()],mt.prototype,"layer",void 0),e([C()],mt.prototype,"layerView",null),e([C({readOnly:!0})],mt.prototype,"layerFloorFilterClause",null),e([C({readOnly:!0})],mt.prototype,"layerTimeExtent",null),e([C({type:Number})],mt.prototype,"localPort",void 0),e([C()],mt.prototype,"locationPointOnImage",void 0),e([C()],mt.prototype,"mapImageConversionToolState",void 0),e([C()],mt.prototype,"measureType",void 0),e([C()],mt.prototype,"measurementGraphic",void 0),e([C({readOnly:!0,value:"none"})],mt.prototype,"mode",null),e([C()],mt.prototype,"navigationMode",void 0),e([C()],mt.prototype,"navigatorCurrentBestFeature",void 0),e([C()],mt.prototype,"oiObjectIdField",void 0),e([C({type:s.ofType(t)})],mt.prototype,"overlayedCameraLocations",void 0),e([C()],mt.prototype,"overlayedMapFeatures",void 0),e([C()],mt.prototype,"panoramicVideoLoaded",null),e([C()],mt.prototype,"panoramicVideoPaused",null),e([C()],mt.prototype,"pixelCoordinates",void 0),e([C()],mt.prototype,"preserveAngle",void 0),e([C()],mt.prototype,"pointSources",void 0),e([C({readOnly:!0})],mt.prototype,"popupEnabled",null),e([C()],mt.prototype,"preloadMedia",void 0),e([C()],mt.prototype,"preloadMediaSize",void 0),e([C()],mt.prototype,"previousFeatureAngle",void 0),e([C()],mt.prototype,"referencePoint",null),e([C({readOnly:!0})],mt.prototype,"sectorData",null),e([C()],mt.prototype,"selectedPoint",void 0),e([C({type:Number})],mt.prototype,"sharpness",null),e([C()],mt.prototype,"shouldShowSelectedImage",void 0),e([C()],mt.prototype,"superimposeViewEnabled",void 0),e([C()],mt.prototype,"defaultSuperimposeCameraLockEnabled",void 0),e([C()],mt.prototype,"superimposeViewSupported",null),e([C()],mt.prototype,"sketch",void 0),e([C()],mt.prototype,"sketchTriangular",void 0),e([C()],mt.prototype,"sketchTriangularGraphicsLayer",void 0),e([C()],mt.prototype,"draw",void 0),e([C()],mt.prototype,"drawAdapter",void 0),e([C()],mt.prototype,"polylineDrawAction",void 0),e([C()],mt.prototype,"scheduledFrameId",void 0),e([C()],mt.prototype,"superimposeScheduledFrameId",void 0),e([C()],mt.prototype,"superimposeDebounceTimeoutId",void 0),e([C()],mt.prototype,"sketchAdapter",void 0),e([C({readOnly:!0})],mt.prototype,"sketchGraphicsLayer",null),e([C({readOnly:!0})],mt.prototype,"state",null),e([C({readOnly:!0})],mt.prototype,"thumbnails",null),e([C()],mt.prototype,"videoExtentPoints",null),e([C()],mt.prototype,"triangularMeasurementActive",void 0),e([C()],mt.prototype,"triangulatedDistanceMeasurement",void 0),e([C()],mt.prototype,"triangulatedDistanceAccuracy",void 0),e([C()],mt.prototype,"triangulatedAreaMeasurement",void 0),e([C()],mt.prototype,"triangulatedAreaAccuracy",void 0),e([C()],mt.prototype,"triangulatedMeasurementGraphic",void 0),e([C()],mt.prototype,"triangulatedPoint",void 0),e([C()],mt.prototype,"triangulatedMeasurementAdapter",void 0),e([C()],mt.prototype,"updateFootprint",void 0),e([C()],mt.prototype,"updateVideoFootprint",void 0),e([C()],mt.prototype,"updateFootprintPanorama",void 0),e([C()],mt.prototype,"updatingTriangularMeasurementState",void 0),e([C({value:null})],mt.prototype,"view",null),e([C()],mt.prototype,"videoElement",void 0),e([C()],mt.prototype,"videoLayer",void 0),e([C()],mt.prototype,"videoMapView",void 0),e([C()],mt.prototype,"verticalFilterEnabled",void 0),e([C()],mt.prototype,"_adapter",void 0),e([C()],mt.prototype,"_defaultGraphicsLayer",null),e([C()],mt.prototype,"_highlightedFeatureHandle",void 0),e([C()],mt.prototype,"_imageViewer",void 0),e([C()],mt.prototype,"_initialCurrentCoverageUpdate",void 0),e([C()],mt.prototype,"_locationViewModel",void 0),e([C()],mt.prototype,"_measurementService",void 0),e([C()],mt.prototype,"_mediaPrefetcher",void 0),e([C()],mt.prototype,"_navigationManager",void 0),e([C()],mt.prototype,"_overlays",void 0),e([C()],mt.prototype,"_superimposePreviousCurrentCoverageVisible",void 0),e([C()],mt.prototype,"_superimposeService",void 0),e([C({readOnly:!0})],mt.prototype,"_overlaysView",null),e([C()],mt.prototype,"_panoramicVideoViewer",void 0),e([C()],mt.prototype,"_panoramicViewer",void 0),e([C()],mt.prototype,"_panoramicMeasurementViewer",void 0),e([C()],mt.prototype,"_referencePointOnGround",void 0),e([C()],mt.prototype,"_referencePointOnImage",void 0),e([C()],mt.prototype,"_referenceTransformationService",void 0),e([C()],mt.prototype,"_sectorData",void 0),e([C()],mt.prototype,"_transformationService",void 0),e([C()],mt.prototype,"_featureToSector",void 0),e([C({readOnly:!0})],mt.prototype,"_updatingHandles",void 0),e([C()],mt.prototype,"footprintExtent",void 0),e([C()],mt.prototype,"_featureChangedTask",void 0),mt=e([A("esri.widgets.OrientedImageryViewer.OrientedImageryViewerViewModel")],mt);const gt=mt;export{gt as default};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import e from"../../../Graphic.js";import{createTask as t}from"../../../core/asyncUtils.js";import a from"../../../core/Collection.js";import{destroyMaybe as r}from"../../../core/maybe.js";import{throwIfAborted as s}from"../../../core/promiseUtils.js";import i from"../../../geometry/Mesh.js";import{projectAsync as n}from"../../../geometry/projectionUtils.js";import o from"../../../geometry/support/MeshComponent.js";import c from"../../../geometry/support/MeshMaterial.js";import u from"../../../geometry/support/MeshTexture.js";import h from"../../../geometry/support/MeshVertexAttributes.js";import l from"../../../symbols/FillSymbol3DLayer.js";import m from"../../../symbols/MeshSymbol3D.js";import{calculateUpdatedWmsf as f}from"../imageMeasurementUtils.js";import{validateTifOrMrfExtension as p}from"../utils.js";import _ from"../support/resolveMediaProps.js";import{computeDefaultAreaOfInterest as x,getBaseRasterLevel as d,applySphereMeshOffsetInMeters as g,applyMeshOffsetInMeters as y,getRasterFetchParameters as v,getRasterLevelSize as w,computePanoramicAreasOfInterest as R,getViewDependentRasterLevel as M,clampRasterLevelForTextureSize as I,createSuperimposeSamplePixels as P,createSuperimposeGridVertexAttributes as O}from"../support/superimposeUtils.js";const b=2,T=2,F=2,D=2,Z=8,C=1,S=[255,255,255,255];class N{constructor(e){this._properties=e,this._cachedBaseTexture=null,this._cachedDefaultFrustumObjectId=null,this._cachedDefaultFrustumNearPlaneAverageZ=0,this._cachedPanoramicRadiusObjectId=null,this._defaultZOffsetInMeters=0,this._defaultZOffsetPercentage=0,this._defaultZOffsetRangeInMeters=0,this._defaultCameraFeature=null,this._graphics=[],this._panoramicZOffsetInMeters=0,this._panoramicZOffsetPercentage=0,this._panoramicZOffsetRangeInMeters=0,this._panoramicNavigationFeature=null,this._rasterTextureCacheFeature=null,this._rasterTextureFetchCache=new Map,this._task=null}clear(){this._destroyGraphics(this._graphics,!0),this._cachedBaseTexture=null,this._cachedDefaultFrustumObjectId=null,this._cachedDefaultFrustumNearPlaneAverageZ=0,this._cachedPanoramicRadiusObjectId=null,this._defaultZOffsetInMeters=0,this._defaultZOffsetRangeInMeters=0,this._defaultCameraFeature=null,this._graphics=[],this._panoramicZOffsetInMeters=0,this._panoramicZOffsetPercentage=0,this._panoramicZOffsetRangeInMeters=0,this._panoramicNavigationFeature=null,this._rasterTextureCacheFeature=null,this._rasterTextureFetchCache.clear()}destroy(){this._task=this._task?.abort()??null,this.clear()}update(e){this._task?.abort(),this._task=t(async t=>{if(!this._canUpdate(e))return void this._resetInactiveState(e.adapter);let a=!1,r=[];try{await this._updateDefaultCameraIfNeeded(e,t),this._resetRasterTextureCacheIfNeeded(e.currentBestFeature);const i=await this._resolveMedia(e,t);if(!i)return;if(({graphics:r}=await this._createGraphics(e,i,t)),!r.length)return;await this._updateNavigation(e,t),await this._applyPersistentZOffset(r,e,t),s(t),this._replaceGraphics(r,e.mode),a=!0}finally{a||this._destroyGraphics(r,!1)}})}_canUpdate(e){const t=["default","panoramic"];return e.superimposeViewEnabled&&"image-loaded"===e.state&&"3d"===e.view?.type&&!!e.currentBestFeature&&!!e.layer&&t.includes(e.mode)}_resetInactiveState(e){e?.disableDefaultSuperimposeNavigation?.(),e?.disablePanoramicSuperimposeNavigation?.(),this.clear()}async _updateDefaultCameraIfNeeded(e,t){const{currentBestFeature:a,mode:r}=e;if(a&&"default"===r)return this._shouldUpdateDefaultCamera(r,a)?(await(e.adapter?.updateDefaultSuperimposeCamera?.({currentBestFeature:a},{signal:t})),s(t),void(this._defaultCameraFeature=a)):void 0}async _resolveMedia(e,t){const{currentBestFeature:a,layer:r,mode:i,view:n}=e;if(!a||!r||!n||"default"!==i&&"panoramic"!==i)return null;const o=await _(a.attributes,r,{signal:t});if(s(t),!o?.mediaUrl)return null;if(!p(o.datasetFormat))return this._resolveNonRasterMedia(o);const c=await this._resolveRasterMedia(o,n,t);if(!c)return null;switch(i){case"default":{const a=await this._resolveDefaultAreaOfInterest(e,o,t);return this._resolveDefaultRasterMedia(c,a,n,t)}case"panoramic":return this._resolvePanoramicRasterMedia(c,e,t)}}_resolveNonRasterMedia(e){return{areaOfInterest:null,textureUrl:this._resolveTextureUrl(e)}}async _resolveDefaultAreaOfInterest(e,t,a){const{activeImageSize:r,currentBestFeature:i,mode:n,view:o}=e;if(!("default"===n&&r&&i&&o&&p(t.datasetFormat)))return null;const c=await x(i,o,r,this._properties.pointToPixel,{signal:a});return s(a),c}async _resolveRasterMedia(e,t,a){const r=await this._loadRaster(e,{signal:a});if(s(a),!r)return null;const i=d(r,t);let n=this._cachedBaseTexture;if(!n){const e=await this._createRasterTexture(r,null,i,{signal:a});s(a),e&&(n=e,this._cachedBaseTexture=e)}return n?{baseLevel:i,baseTexture:n,raster:r}:null}async _resolveDefaultRasterMedia(e,t,a,r){const{baseLevel:i,baseTexture:n,raster:o}=e;if(!t)return{areaOfInterest:null,baseTexture:n,raster:o,texture:n};const c=d(o,a,t),u=await this._createCompositedDefaultRasterTexture(o,t,c,i,{signal:r});return s(r),{areaOfInterest:t,baseTexture:n,overlayTexture:u,raster:o,texture:u??n}}async _resolvePanoramicRasterMedia(e,t,a){const{activeImageSize:r,currentBestFeature:i,view:n}=t,{baseTexture:o,raster:c}=e;if(!r||!i||!n)return{areaOfInterest:null,baseTexture:o,raster:c,texture:o};const u=await this._createPanoramicRasterTexture(c,i,n,r,{signal:a})??o;return s(a),{areaOfInterest:null,baseTexture:o,raster:c,texture:u}}async _createGraphics(e,t,a){switch(e.mode){case"default":return this._createDefaultGraphics(e,t,a);case"panoramic":return this._createPanoramicGraphics(e,t,a)}return{graphics:[]}}async _createDefaultGraphics(e,t,a){const r=await this._createAndDrapeDefaultGraphic(e,a,{texture:t.texture,textureUrl:t.textureUrl});return{graphics:r?[r]:[]}}async _createAndDrapeDefaultGraphic(e,t,a){const{activeImageSize:r,depthImageLoaded:i,view:n}=e,{areaOfInterest:o,texture:c,textureUrl:u}=a;if(!r||!n)return null;const h=await this._createDefaultGraphic({areaOfInterest:o,depthImageLoaded:i,imageSize:r,signal:t,texture:c,textureUrl:u,view:n});return h?(s(t),h):null}async _createPanoramicGraphics(e,t,a){const r=await this._createPanoramicSuperimposeGraphic(e,t,a);return{graphics:r?[r]:[]}}async _createPanoramicSuperimposeGraphic(e,t,a){const{activeImageSize:r,currentBestFeature:s,panoramicHorizonAngles:i,view:n}=e;return n?this._createPanoramicGraphic({currentBestFeature:s??void 0,horizonAngles:i,imageSize:r,signal:a,texture:t.texture,textureUrl:t.textureUrl,view:n}):null}async _updateNavigation(e,t){const{currentBestFeature:a,mode:r,view:s}=e;if(a&&s&&"3d"===s.type)switch(r){case"default":return void this._updateDefaultNavigation(e);case"panoramic":return void await this._updatePanoramicNavigation(e,a,s,t)}}_updateDefaultNavigation(e){this._updateDefaultSuperimposeNavigation(e.adapter,e.defaultSuperimposeCameraLockEnabled)}async _updatePanoramicNavigation(e,t,a,r){e.adapter?.disableDefaultSuperimposeNavigation?.();const i=t!==this._panoramicNavigationFeature?e.panoramicCamera??a.camera:a.camera;i&&this._shouldUpdatePanoramicCamera(e.mode,t)&&(e.adapter?.disablePanoramicSuperimposeNavigation?.(),await(e.adapter?.updatePanoramicSuperimposeCamera?.({camera:i,currentBestFeature:t},{signal:r})),s(r)),this._panoramicNavigationFeature=t}_replaceGraphics(e,t){if("panoramic"===t&&this._updatePanoramicGraphicInPlace(e))return;const a=this._graphics;this._graphics=e,this._properties.overlays.addMany(e),this._destroyGraphics(a,!0)}_updatePanoramicGraphicInPlace(e){if(1!==this._graphics.length||1!==e.length)return!1;const t=this._graphics[0],a=e[0];return!(!t||!a)&&(t.geometry=a.geometry,t.symbol=a.symbol,t.visible=a.visible,a.geometry=null,a.symbol=null,r(a),!0)}_destroyGraphics(e,t){e.length&&(t&&this._properties.overlays.removeMany(e),e.forEach(e=>r(e)))}_updateDefaultSuperimposeNavigation(e,t=!0){t?e?.enableDefaultSuperimposeNavigation?.():e?.disableDefaultSuperimposeNavigation?.(),this._panoramicNavigationFeature&&e?.disablePanoramicSuperimposeNavigation?.(),this._panoramicNavigationFeature=null}_shouldUpdateDefaultCamera(e,t){return"default"===e&&t!==this._defaultCameraFeature}_shouldUpdatePanoramicCamera(e,t){return"panoramic"===e&&t!==this._panoramicNavigationFeature}setDefaultZOffsetPercentage(e){const t=Math.max(0,Math.min(100,e)),a=this._defaultZOffsetRangeInMeters*t/100,r=a-this._defaultZOffsetInMeters;this._defaultZOffsetPercentage=t,this._defaultZOffsetInMeters=a,this._applyZOffset(this._graphics,"default",r)}setPanoramicRadiusPercentage(e){const t=Math.max(0,Math.min(100,e)),a=this._panoramicZOffsetRangeInMeters*t/100,r=a-this._panoramicZOffsetInMeters;this._panoramicZOffsetPercentage=t,this._panoramicZOffsetInMeters=a,this._applyZOffset(this._graphics,"panoramic",r)}updateZOffset(e){0!==e&&(this._panoramicZOffsetInMeters+=e,this._applyZOffset(this._graphics,"panoramic",e))}_applyZOffset(e,t,a){0!==a&&e.forEach(e=>{const r=e.geometry;"mesh"===r?.type&&("panoramic"!==t?y(r,{z:a}):g(r,{radiusOffset:a}))})}async _applyPersistentZOffset(e,t,a){if("panoramic"===t.mode)return this._panoramicZOffsetRangeInMeters=await this._resolvePanoramicZOffsetRangeInMeters(t.currentBestFeature,t.view,a),this._panoramicZOffsetInMeters=this._panoramicZOffsetRangeInMeters*this._panoramicZOffsetPercentage/100,void this._applyZOffset(e,"panoramic",this._panoramicZOffsetInMeters);this._defaultZOffsetRangeInMeters=await this._resolveDefaultZOffsetRangeInMeters(e,t.currentBestFeature,t.currentBestFeatureFrustum,t.view,a),this._defaultZOffsetInMeters=this._defaultZOffsetRangeInMeters*this._defaultZOffsetPercentage/100,this._applyZOffset(e,"default",this._defaultZOffsetInMeters)}async _resolveDefaultZOffsetRangeInMeters(e,t,a,r,i){const[o]=e,c=o?.geometry,u=t.attributes.objectId;if("mesh"!==c?.type||!a)return 0;if(this._cachedDefaultFrustumObjectId!==u){const e=a.spatialReference.equals(r.spatialReference)?a:await n(a.clone(),r.spatialReference,{signal:i});if(s(i),!e||"mesh"!==e.type)return this._cachedDefaultFrustumObjectId=u,this._cachedDefaultFrustumNearPlaneAverageZ=0,0;this._cachedDefaultFrustumObjectId=u,this._cachedDefaultFrustumNearPlaneAverageZ=this._getFrustumNearPlaneAverageZ(e)}return this._cachedDefaultFrustumNearPlaneAverageZ-this._getMeshAverageZ(c)}async _resolvePanoramicZOffsetRangeInMeters(e,t,a){const r=e.attributes.objectId;if(this._cachedPanoramicRadiusObjectId!==r){const i=e.attributes.farDistance,o=Math.max(Z,e.attributes.nearDistance??i);if(!(i>0&&o>=0))return this._cachedPanoramicRadiusObjectId=r,this._panoramicZOffsetRangeInMeters=0,0;const c=e.attributes.location,u=c.spatialReference.equals(t.spatialReference)?c:await n(c,t.spatialReference,{signal:a});if(s(a),!u)return this._cachedPanoramicRadiusObjectId=r,this._panoramicZOffsetRangeInMeters=0,0;const h=u.spatialReference.isWebMercator?f(u.y):1;this._cachedPanoramicRadiusObjectId=r,this._panoramicZOffsetRangeInMeters=(o-i)*h}return this._panoramicZOffsetRangeInMeters}_getFrustumNearPlaneAverageZ(e){const{position:t}=e.vertexAttributes;if(t.length<12)return this._getMeshAverageZ(e);let a=0;for(let r=0;r<4;r+=1)a+=t[3*r+2];return a/4}_getMeshAverageZ(e){const{position:t}=e.vertexAttributes,a=Math.floor(t.length/3);if(0===a)return 0;let r=0;for(let s=0;s<a;s+=1)r+=t[3*s+2];return r/a}_resolveTextureUrl(e){const t=new URL(e.mediaUrl);return Object.entries(e.searchParams).forEach(([e,a])=>{t.searchParams.has(e)||t.searchParams.set(e,a)}),t.toString()}_resetRasterTextureCacheIfNeeded(e){e&&e!==this._rasterTextureCacheFeature&&(this._cachedBaseTexture=null,this._rasterTextureFetchCache.clear(),this._rasterTextureCacheFeature=e)}_createImageDataFromPixelBlock(e){return new ImageData(e.getAsRGBA(),e.width,e.height)}_copyImageData(e,t,a,r,s=e.width,i=e.height){const n=e.data,o=t.data,c=e.width,u=e.height,h=t.width,l=t.height;for(let m=0;m<i;m+=1){const e=r+m;if(e<0||e>=l)continue;const t=Math.min(u-1,Math.floor(m*u/i));for(let r=0;r<s;r+=1){const i=a+r;if(i<0||i>=h)continue;const u=4*(t*c+Math.min(c-1,Math.floor(r*c/s))),l=4*(e*h+i);o[l]=n[u],o[l+1]=n[u+1],o[l+2]=n[u+2],o[l+3]=n[u+3]}}}_copyImageDataRegion(e,t,a,r,s,i,n,o){const c=e.data,u=t.data,h=e.width,l=t.width;for(let m=0;m<o;m+=1)for(let e=0;e<n;e+=1){const t=4*((r+m)*h+(a+e)),n=4*((i+m)*l+(s+e));u[n]=c[t],u[n+1]=c[t+1],u[n+2]=c[t+2],u[n+3]=c[t+3]}}async _fetchRasterTextureAtLevel(e,t,a,r){const{offset:i,size:n}=v(e,t,a),o=this._createRasterTextureExtent(i,n),c=this._createRasterTextureLevelCacheKey(e,t),u=this._getOrCreateRasterTextureLevelCache(c),h=this._getUncoveredRasterTextureExtents(o,u.patches);for(const l of h){const a=this._createRasterTextureExtentCacheKey(l);let i=u.inflight.get(a);i||(i=this._fetchRasterTexturePatch(e,t,l,r),u.inflight.set(a,i));try{const e=await i;s(r),e&&u.patches.push(e)}finally{u.inflight.delete(a)}}return this._composeRasterTextureFromCachedPatches(o,u.patches)}_getOrCreateRasterTextureLevelCache(e){let t=this._rasterTextureFetchCache.get(e);return t||(t={inflight:new Map,patches:[]},this._rasterTextureFetchCache.set(e,t)),t}_createRasterTextureLevelCacheKey(e,t){return[e.url,e.rasterInfo.width,e.rasterInfo.height,t].join(":")}_createRasterTextureExtentCacheKey(e){return[e.xmin,e.ymin,e.xmax,e.ymax].join(":")}_createRasterTextureExtent(e,t){return{xmin:e.x,ymin:e.y,xmax:e.x+t.width,ymax:e.y+t.height}}_getUncoveredRasterTextureExtents(e,t){let a=[e];for(const r of t)if(a=a.flatMap(e=>this._subtractRasterTextureExtent(e,r.extent)),!a.length)break;return a}_subtractRasterTextureExtent(e,t){const a=this._intersectRasterTextureExtents(e,t);if(!a)return[e];const r=[];return e.ymin<a.ymin&&r.push({xmin:e.xmin,ymin:e.ymin,xmax:e.xmax,ymax:a.ymin}),a.ymax<e.ymax&&r.push({xmin:e.xmin,ymin:a.ymax,xmax:e.xmax,ymax:e.ymax}),e.xmin<a.xmin&&r.push({xmin:e.xmin,ymin:a.ymin,xmax:a.xmin,ymax:a.ymax}),a.xmax<e.xmax&&r.push({xmin:a.xmax,ymin:a.ymin,xmax:e.xmax,ymax:a.ymax}),r.filter(({xmin:e,ymin:t,xmax:a,ymax:r})=>a>e&&r>t)}_intersectRasterTextureExtents(e,t){const a=Math.max(e.xmin,t.xmin),r=Math.max(e.ymin,t.ymin),s=Math.min(e.xmax,t.xmax),i=Math.min(e.ymax,t.ymax);return s>a&&i>r?{xmin:a,ymin:r,xmax:s,ymax:i}:null}async _fetchRasterTexturePatch(e,t,a,r){const{pixelBlock:i}=await e.fetchRawPixels(t,{x:a.xmin,y:a.ymin},{width:a.xmax-a.xmin,height:a.ymax-a.ymin},r);if(s(r),i)return{extent:a,imageData:this._createImageDataFromPixelBlock(i)}}_composeRasterTextureFromCachedPatches(e,t){const a=t.filter(t=>this._intersectRasterTextureExtents(e,t.extent));if(!a.length)return;const r=new ImageData(e.xmax-e.xmin,e.ymax-e.ymin);for(const s of a){const t=this._intersectRasterTextureExtents(e,s.extent);t&&this._copyImageDataRegion(s.imageData,r,t.xmin-s.extent.xmin,t.ymin-s.extent.ymin,t.xmin-e.xmin,t.ymin-e.ymin,t.xmax-t.xmin,t.ymax-t.ymin)}return r}async _loadRaster(e,t){const{loadRaster:a}=await import("../../PanoramicViewer/utils.js"),r=await a(this._resolveTextureUrl(e),t);return s(t),r}async _createCompositedDefaultRasterTexture(e,t,a,r,i){const{pyramidScalingFactor:n}=e.rasterInfo.storageInfo,o=n??b,c=w(e.rasterInfo.width,e.rasterInfo.height,a,o),h=await this._fetchRasterTextureAtLevel(e,r,null,i);if(s(i),!h)return;const l=await this._fetchRasterTextureAtLevel(e,a,t,i);if(s(i),!l)return new u({data:h});const m=new ImageData(c.width,c.height);this._copyImageData(h,m,0,0,c.width,c.height);const f=o**a,{x:p,y:_}=this._resolveRasterDrawOrigin(t,f);return this._copyImageData(l,m,p,_),new u({data:m})}async _createRasterTexture(e,t,a,r){const{maximumPyramidLevel:s}=e.rasterInfo.storageInfo,i=await this._fetchRasterTextureAtLevel(e,a??s,t,r);if(i)return new u({data:i})}async _createPanoramicRasterTexture(e,t,a,r,i){const n=await R(t,a,r,this._properties.pointToPixel,i);if(s(i),!n?.length)return this._createRasterTexture(e,null,void 0,i);const{baseLevel:o,level:c,scalingFactor:u}=this._resolvePanoramicRasterLevels(e,a,n);return o<=c?this._createRasterTexture(e,null,c,i):this._createCompositedPanoramicRasterTexture(e,n,{baseLevel:o,level:c,scalingFactor:u},i)}_resolvePanoramicRasterLevels(e,t,a){const{maximumPyramidLevel:r,pyramidScalingFactor:s}=e.rasterInfo.storageInfo,i=a.reduce((a,r)=>Math.min(a,M(e,t,r)),r),n=I(e,i),o=s??b;return{baseLevel:Math.min(r,n+T),level:n,scalingFactor:o}}async _createCompositedPanoramicRasterTexture(e,t,a,r){const{baseLevel:i,level:n,scalingFactor:o}=a,c=w(e.rasterInfo.width,e.rasterInfo.height,n,o),h=await this._fetchRasterTextureAtLevel(e,i,null,r);if(s(r),!h)return;const l=new ImageData(c.width,c.height);this._copyImageData(h,l,0,0,c.width,c.height);const m=o**n;for(const u of t){const t=await this._fetchRasterTextureAtLevel(e,n,u,r);if(s(r),!t)continue;const{x:a,y:i}=this._resolveRasterDrawOrigin(u,m);this._copyImageData(t,l,a,i)}return new u({data:l})}_resolveRasterDrawOrigin(e,t){return{x:Math.max(0,Math.floor(e.xmin/t)),y:Math.max(0,Math.floor(e.ymin/t))}}async _createFootprintMesh(e,t,a,r){if("3d"!==t.type)return null;const c=P(e,a),u=await this._properties.getMapPoint(c,r);s(r);const l=await Promise.all(u.map(e=>e.spatialReference.equals(t.spatialReference)?e:n(e,t.spatialReference,r)));if(s(r),l.some(e=>!e))return null;const{faces:m,position:f,uv:p}=O(l,e,a);return new i({vertexAttributes:new h({position:f,uv:p}),components:[new o({faces:m})],spatialReference:t.spatialReference.clone()})}async _createPanoramicGraphic(t){const{currentBestFeature:r,horizonAngles:i,signal:n,texture:o,textureUrl:c,view:u}=t;if(!t.imageSize||!r)return null;const h=this._createPanoramicMeshTexture(o,c),f=await this._resolvePanoramicMeshLocation(r,u,n);if(!f)return null;s(n);const{imageMesh:p,radiusOfSphericalMesh:_}=this._createPanoramicSphereMesh(r,f,h);return this._flipPanoramicMeshUv(p),this._rotatePanoramicMeshToHorizon(p,i),p.offset(0,0,-_),new e({geometry:p,symbol:new m({symbolLayers:new a([new l({})])})})}_createPanoramicMeshTexture(e,t){if(e)return e;if(!t)throw new Error("Missing texture URL or texture data.");return new u({url:t})}async _resolvePanoramicMeshLocation(e,t,a){const r=e.attributes.location,i=r.spatialReference.equals(t.spatialReference)?r.clone():await n(r,t.spatialReference,{signal:a});return s(a),i}_createPanoramicSphereMesh(e,t,a){const r=t.spatialReference.isWebMercator?f(t.y):1,s=e.attributes.farDistance*r,n=new c({colorTexture:a}),o=i.createSphere(t,{size:s*F,densificationFactor:D,vertexSpace:"georeferenced",material:n});return o.components?.forEach(e=>{e.material=n,e.trustSourceNormals=!0}),{imageMesh:o,radiusOfSphericalMesh:s}}_flipPanoramicMeshUv(e){const t=e.vertexAttributes,a=t.uv;if(!a)return;const r=a.length/2;for(let s=0;s<r;s++)a[2*s]=C-a[2*s];e.vertexAttributes=t}_rotatePanoramicMeshToHorizon(e,t){if(!t)return;const[a,r,s]=t;e.rotate(-a,-r,s,{origin:e.extent.center})}async _createDefaultGraphic(t){const{texture:r,textureUrl:s}=t;if(!r&&!s)throw new Error("Missing texture URL or texture data.");if(!t.imageSize)return null;const i=await this._createFootprintMesh(t.imageSize,t.view,t.areaOfInterest,{signal:t.signal});if(!i)return null;const n=i.vertexAttributes.position,o=[];for(let e=0;e<n.length;e+=3)o.push(...S);i.vertexAttributes.color=new Uint8Array(o);const h=new c({colorTexture:r??new u({url:s})});return i.components?.forEach(e=>{e.shading="source",e.material=h}),new e({geometry:i,symbol:new m({symbolLayers:new a([new l({})])})})}}export{N as default};
2
+ import e from"../../../Graphic.js";import{createTask as t}from"../../../core/asyncUtils.js";import a from"../../../core/Collection.js";import{destroyMaybe as r}from"../../../core/maybe.js";import{throwIfAborted as s}from"../../../core/promiseUtils.js";import i from"../../../geometry/Mesh.js";import{projectAsync as n}from"../../../geometry/projectionUtils.js";import o from"../../../geometry/support/MeshComponent.js";import c from"../../../geometry/support/MeshMaterial.js";import u from"../../../geometry/support/MeshTexture.js";import l from"../../../geometry/support/MeshVertexAttributes.js";import{imageToWorldPanoramic as h}from"../../../layers/orientedImagery/transformations/imageToWorld.js";import m from"../../../symbols/FillSymbol3DLayer.js";import f from"../../../symbols/MeshSymbol3D.js";import{calculateUpdatedWmsf as p}from"../imageMeasurementUtils.js";import{validateTifOrMrfExtension as _}from"../utils.js";import d from"../support/resolveMediaProps.js";import{computeDefaultAreaOfInterest as x,getBaseRasterLevel as g,computePanoramicAreasOfInterest as y,applySphereMeshOffsetInMeters as v,applyMeshOffsetInMeters as w,getRasterFetchParameters as I,getRasterLevelSize as R,getViewDependentRasterLevel as M,clampRasterLevelForTextureSize as O,createSuperimposeGridVertexAttributes as P,createSuperimposeSamplePixels as b}from"../support/superimposeUtils.js";const T=2,D=2,F=10,Z=128,C=[255,255,255,255];class j{constructor(e){this._properties=e,this._cachedBaseTexture=null,this._cachedDefaultFrustumObjectId=null,this._cachedDefaultFrustumNearPlaneAverageZ=0,this._cachedPanoramicRadiusObjectId=null,this._defaultZOffsetInMeters=0,this._defaultZOffsetPercentage=0,this._defaultZOffsetRangeInMeters=0,this._defaultCameraFeature=null,this._graphics=[],this._panoramicZOffsetInMeters=0,this._panoramicZOffsetPercentage=0,this._panoramicZOffsetRangeInMeters=0,this._panoramicNavigationFeature=null,this._rasterTextureCacheFeature=null,this._rasterTextureFetchCache=new Map,this._task=null}clear(){this._destroyGraphics(this._graphics,!0),this._cachedBaseTexture=null,this._cachedDefaultFrustumObjectId=null,this._cachedDefaultFrustumNearPlaneAverageZ=0,this._cachedPanoramicRadiusObjectId=null,this._defaultZOffsetInMeters=0,this._defaultZOffsetRangeInMeters=0,this._defaultCameraFeature=null,this._graphics=[],this._panoramicZOffsetInMeters=0,this._panoramicZOffsetPercentage=0,this._panoramicZOffsetRangeInMeters=0,this._panoramicNavigationFeature=null,this._rasterTextureCacheFeature=null,this._rasterTextureFetchCache.clear()}destroy(){this._task=this._task?.abort()??null,this.clear()}update(e){this._task?.abort(),this._task=t(async t=>{if(!this._canUpdate(e))return void this._resetInactiveState(e.adapter);let a=!1,r=[];try{await this._updateDefaultCameraIfNeeded(e,t),this._resetRasterTextureCacheIfNeeded(e.currentBestFeature);const i=await this._resolveMedia(e,t);if(!i)return;if(({graphics:r}=await this._createGraphics(e,i,t)),!r.length)return;await this._updateNavigation(e,t),await this._applyPersistentZOffset(r,e,t),s(t),this._replaceGraphics(r,e.mode),a=!0}finally{a||this._destroyGraphics(r,!1)}})}_canUpdate(e){const t=["default","panoramic"];return e.superimposeViewEnabled&&"image-loaded"===e.state&&"3d"===e.view?.type&&!!e.currentBestFeature&&!!e.layer&&t.includes(e.mode)}_resetInactiveState(e){e?.disableDefaultSuperimposeNavigation?.(),e?.disablePanoramicSuperimposeNavigation?.(),this.clear()}async _updateDefaultCameraIfNeeded(e,t){const{currentBestFeature:a,mode:r}=e;if(a&&"default"===r)return this._shouldUpdateDefaultCamera(r,a)?(await(e.adapter?.updateDefaultSuperimposeCamera?.({currentBestFeature:a},{signal:t})),s(t),void(this._defaultCameraFeature=a)):void 0}async _resolveMedia(e,t){const{currentBestFeature:a,layer:r,mode:i,view:n}=e;if(!a||!r||!n||"default"!==i&&"panoramic"!==i)return null;const o=await d(a.attributes,r,{signal:t});if(s(t),!o?.mediaUrl)return null;if(!_(o.datasetFormat))return this._resolveNonRasterMedia(o);const c=await this._resolveRasterMedia(o,n,t);if(!c)return null;switch(i){case"default":{const a=await this._resolveDefaultAreaOfInterest(e,o,t);return this._resolveDefaultRasterMedia(c,a,n,t)}case"panoramic":return this._resolvePanoramicRasterMedia(c,e,t)}}_resolveNonRasterMedia(e){return{areaOfInterest:null,textureUrl:this._resolveTextureUrl(e)}}async _resolveDefaultAreaOfInterest(e,t,a){const{activeImageSize:r,currentBestFeature:i,mode:n,view:o}=e;if(!("default"===n&&r&&i&&o&&_(t.datasetFormat)))return null;const c=await x(i,o,r,this._properties.pointToPixel,{signal:a});return s(a),c}async _resolveRasterMedia(e,t,a){const r=await this._loadRaster(e,{signal:a});if(s(a),!r)return null;const i=g(r,t);let n=this._cachedBaseTexture;if(!n){const e=await this._createRasterTexture(r,null,i,{signal:a});s(a),e&&(n=e,this._cachedBaseTexture=e)}return n?{baseLevel:i,baseTexture:n,raster:r}:null}async _resolveDefaultRasterMedia(e,t,a,r){const{baseLevel:i,baseTexture:n,raster:o}=e;if(!t)return{areaOfInterest:null,baseTexture:n,raster:o,texture:n};const c=g(o,a,t),u=await this._createCompositedDefaultRasterTexture(o,t,c,i,{signal:r});return s(r),{areaOfInterest:t,baseTexture:n,overlayTexture:u,raster:o,texture:u??n}}async _resolvePanoramicRasterMedia(e,t,a){const{activeImageSize:r,currentBestFeature:i,view:n}=t,{baseTexture:o,raster:c}=e;if(!r||!i||!n)return{areaOfInterest:null,baseTexture:o,panoramicAreasOfInterest:void 0,raster:c,texture:o};const u=await y(i,n,r,this._properties.pointToPixel,{signal:a});s(a);const l=await this._createPanoramicRasterTexture(c,i,n,r,u,{signal:a})??o;return s(a),{areaOfInterest:null,baseTexture:o,panoramicAreasOfInterest:u,raster:c,texture:l}}async _createGraphics(e,t,a){switch(e.mode){case"default":return this._createDefaultGraphics(e,t,a);case"panoramic":return this._createPanoramicGraphics(e,t,a)}return{graphics:[]}}async _createDefaultGraphics(e,t,a){const r=await this._createAndDrapeDefaultGraphic(e,a,{texture:t.texture,textureUrl:t.textureUrl});return{graphics:r?[r]:[]}}async _createAndDrapeDefaultGraphic(e,t,a){const{activeImageSize:r,depthImageLoaded:i,view:n}=e,{areaOfInterest:o,texture:c,textureUrl:u}=a;if(!r||!n)return null;const l=await this._createDefaultGraphic({areaOfInterest:o,depthImageLoaded:i,imageSize:r,signal:t,texture:c,textureUrl:u,view:n});return l?(s(t),l):null}async _createPanoramicGraphics(e,t,a){const r=await this._createPanoramicSuperimposeGraphic(e,t,a,null);return{graphics:r?[r]:[]}}async _createPanoramicSuperimposeGraphic(e,t,a,r){const{activeImageSize:s,currentBestFeature:i,view:n}=e;return n?this._createPanoramicGraphic({areaOfInterest:r,currentBestFeature:i??void 0,imageSize:s,signal:a,texture:t.texture,textureUrl:t.textureUrl,view:n}):null}async _updateNavigation(e,t){const{currentBestFeature:a,mode:r,view:s}=e;if(a&&s&&"3d"===s.type)switch(r){case"default":return void this._updateDefaultNavigation(e);case"panoramic":return void await this._updatePanoramicNavigation(e,a,s,t)}}_updateDefaultNavigation(e){this._updateDefaultSuperimposeNavigation(e.adapter,e.defaultSuperimposeCameraLockEnabled)}async _updatePanoramicNavigation(e,t,a,r){e.adapter?.disableDefaultSuperimposeNavigation?.();const i=t!==this._panoramicNavigationFeature?e.panoramicCamera??a.camera:a.camera;i&&this._shouldUpdatePanoramicCamera(e.mode,t)&&(e.adapter?.disablePanoramicSuperimposeNavigation?.(),await(e.adapter?.updatePanoramicSuperimposeCamera?.({camera:i,currentBestFeature:t},{signal:r})),s(r)),this._panoramicNavigationFeature=t}_replaceGraphics(e,t){if("panoramic"===t&&this._updatePanoramicGraphicInPlace(e))return;const a=this._graphics;this._graphics=e,this._properties.overlays.addMany(e),this._destroyGraphics(a,!0)}_updatePanoramicGraphicInPlace(e){if(1!==this._graphics.length||1!==e.length)return!1;const t=this._graphics[0],a=e[0];return!(!t||!a)&&(t.geometry=a.geometry,t.symbol=a.symbol,t.visible=a.visible,a.geometry=null,a.symbol=null,r(a),!0)}_destroyGraphics(e,t){e.length&&(t&&this._properties.overlays.removeMany(e),e.forEach(e=>r(e)))}_updateDefaultSuperimposeNavigation(e,t=!0){t?e?.enableDefaultSuperimposeNavigation?.():e?.disableDefaultSuperimposeNavigation?.(),this._panoramicNavigationFeature&&e?.disablePanoramicSuperimposeNavigation?.(),this._panoramicNavigationFeature=null}_shouldUpdateDefaultCamera(e,t){return"default"===e&&t!==this._defaultCameraFeature}_shouldUpdatePanoramicCamera(e,t){return"panoramic"===e&&t!==this._panoramicNavigationFeature}setDefaultZOffsetPercentage(e){const t=Math.max(0,Math.min(100,e)),a=this._defaultZOffsetRangeInMeters*t/100,r=a-this._defaultZOffsetInMeters;this._defaultZOffsetPercentage=t,this._defaultZOffsetInMeters=a,this._applyZOffset(this._graphics,"default",r)}setPanoramicRadiusPercentage(e){const t=Math.max(0,Math.min(100,e)),a=this._panoramicZOffsetRangeInMeters*t/100,r=a-this._panoramicZOffsetInMeters;this._panoramicZOffsetPercentage=t,this._panoramicZOffsetInMeters=a,this._applyZOffset(this._graphics,"panoramic",r)}updateZOffset(e){0!==e&&(this._panoramicZOffsetInMeters+=e,this._applyZOffset(this._graphics,"panoramic",e))}_applyZOffset(e,t,a){0!==a&&e.forEach(e=>{const r=e.geometry;"mesh"===r?.type&&("panoramic"!==t?w(r,{z:a}):v(r,{radiusOffset:a,minimumRadiusInMeters:F}))})}async _applyPersistentZOffset(e,t,a){if("panoramic"===t.mode)return this._panoramicZOffsetRangeInMeters=await this._resolvePanoramicZOffsetRangeInMeters(t.currentBestFeature,t.view,a),this._panoramicZOffsetInMeters=this._panoramicZOffsetRangeInMeters*this._panoramicZOffsetPercentage/100,void this._applyZOffset(e,"panoramic",this._panoramicZOffsetInMeters);this._defaultZOffsetRangeInMeters=await this._resolveDefaultZOffsetRangeInMeters(e,t.currentBestFeature,t.currentBestFeatureFrustum,t.view,a),this._defaultZOffsetInMeters=this._defaultZOffsetRangeInMeters*this._defaultZOffsetPercentage/100,this._applyZOffset(e,"default",this._defaultZOffsetInMeters)}async _resolveDefaultZOffsetRangeInMeters(e,t,a,r,i){const[o]=e,c=o?.geometry,u=t.attributes.objectId;if("mesh"!==c?.type||!a)return 0;if(this._cachedDefaultFrustumObjectId!==u){const e=a.spatialReference.equals(r.spatialReference)?a:await n(a.clone(),r.spatialReference,{signal:i});if(s(i),!e||"mesh"!==e.type)return this._cachedDefaultFrustumObjectId=u,this._cachedDefaultFrustumNearPlaneAverageZ=0,0;this._cachedDefaultFrustumObjectId=u,this._cachedDefaultFrustumNearPlaneAverageZ=this._getFrustumNearPlaneAverageZ(e)}return this._cachedDefaultFrustumNearPlaneAverageZ-this._getMeshAverageZ(c)}async _resolvePanoramicZOffsetRangeInMeters(e,t,a){const r=e.attributes.objectId;if(this._cachedPanoramicRadiusObjectId!==r){const i=e.attributes.farDistance,o=Math.max(F,e.attributes.nearDistance??i);if(!(i>0&&o>=0))return this._cachedPanoramicRadiusObjectId=r,this._panoramicZOffsetRangeInMeters=0,0;const c=e.attributes.location,u=c.spatialReference.equals(t.spatialReference)?c:await n(c,t.spatialReference,{signal:a});if(s(a),!u)return this._cachedPanoramicRadiusObjectId=r,this._panoramicZOffsetRangeInMeters=0,0;const l=u.spatialReference.isWebMercator?p(u.y):1;this._cachedPanoramicRadiusObjectId=r,this._panoramicZOffsetRangeInMeters=(o-i)*l}return this._panoramicZOffsetRangeInMeters}_getFrustumNearPlaneAverageZ(e){const{position:t}=e.vertexAttributes;if(t.length<12)return this._getMeshAverageZ(e);let a=0;for(let r=0;r<4;r+=1)a+=t[3*r+2];return a/4}_getMeshAverageZ(e){const{position:t}=e.vertexAttributes,a=Math.floor(t.length/3);if(0===a)return 0;let r=0;for(let s=0;s<a;s+=1)r+=t[3*s+2];return r/a}_resolveTextureUrl(e){const t=new URL(e.mediaUrl);return Object.entries(e.searchParams).forEach(([e,a])=>{t.searchParams.has(e)||t.searchParams.set(e,a)}),t.toString()}_resetRasterTextureCacheIfNeeded(e){e&&e!==this._rasterTextureCacheFeature&&(this._cachedBaseTexture=null,this._rasterTextureFetchCache.clear(),this._rasterTextureCacheFeature=e)}_createImageDataFromPixelBlock(e){return new ImageData(e.getAsRGBA(),e.width,e.height)}_copyImageData(e,t,a,r,s=e.width,i=e.height){const n=e.data,o=t.data,c=e.width,u=e.height,l=t.width,h=t.height;for(let m=0;m<i;m+=1){const e=r+m;if(e<0||e>=h)continue;const t=Math.min(u-1,Math.floor(m*u/i));for(let r=0;r<s;r+=1){const i=a+r;if(i<0||i>=l)continue;const u=4*(t*c+Math.min(c-1,Math.floor(r*c/s))),h=4*(e*l+i);o[h]=n[u],o[h+1]=n[u+1],o[h+2]=n[u+2],o[h+3]=n[u+3]}}}_copyImageDataRegion(e,t,a,r,s,i,n,o){const c=e.data,u=t.data,l=e.width,h=t.width;for(let m=0;m<o;m+=1)for(let e=0;e<n;e+=1){const t=4*((r+m)*l+(a+e)),n=4*((i+m)*h+(s+e));u[n]=c[t],u[n+1]=c[t+1],u[n+2]=c[t+2],u[n+3]=c[t+3]}}async _fetchRasterTextureAtLevel(e,t,a,r){const{offset:i,size:n}=I(e,t,a),o=this._createRasterTextureExtent(i,n),c=this._createRasterTextureLevelCacheKey(e,t),u=this._getOrCreateRasterTextureLevelCache(c),l=this._getUncoveredRasterTextureExtents(o,u.patches);for(const h of l){const a=this._createRasterTextureExtentCacheKey(h);let i=u.inflight.get(a);i||(i=this._fetchRasterTexturePatch(e,t,h,r),u.inflight.set(a,i));try{const e=await i;s(r),e&&u.patches.push(e)}finally{u.inflight.delete(a)}}return this._composeRasterTextureFromCachedPatches(o,u.patches)}_getOrCreateRasterTextureLevelCache(e){let t=this._rasterTextureFetchCache.get(e);return t||(t={inflight:new Map,patches:[]},this._rasterTextureFetchCache.set(e,t)),t}_createRasterTextureLevelCacheKey(e,t){return[e.url,e.rasterInfo.width,e.rasterInfo.height,t].join(":")}_createRasterTextureExtentCacheKey(e){return[e.xmin,e.ymin,e.xmax,e.ymax].join(":")}_createRasterTextureExtent(e,t){return{xmin:e.x,ymin:e.y,xmax:e.x+t.width,ymax:e.y+t.height}}_getUncoveredRasterTextureExtents(e,t){let a=[e];for(const r of t)if(a=a.flatMap(e=>this._subtractRasterTextureExtent(e,r.extent)),!a.length)break;return a}_subtractRasterTextureExtent(e,t){const a=this._intersectRasterTextureExtents(e,t);if(!a)return[e];const r=[];return e.ymin<a.ymin&&r.push({xmin:e.xmin,ymin:e.ymin,xmax:e.xmax,ymax:a.ymin}),a.ymax<e.ymax&&r.push({xmin:e.xmin,ymin:a.ymax,xmax:e.xmax,ymax:e.ymax}),e.xmin<a.xmin&&r.push({xmin:e.xmin,ymin:a.ymin,xmax:a.xmin,ymax:a.ymax}),a.xmax<e.xmax&&r.push({xmin:a.xmax,ymin:a.ymin,xmax:e.xmax,ymax:a.ymax}),r.filter(({xmin:e,ymin:t,xmax:a,ymax:r})=>a>e&&r>t)}_intersectRasterTextureExtents(e,t){const a=Math.max(e.xmin,t.xmin),r=Math.max(e.ymin,t.ymin),s=Math.min(e.xmax,t.xmax),i=Math.min(e.ymax,t.ymax);return s>a&&i>r?{xmin:a,ymin:r,xmax:s,ymax:i}:null}async _fetchRasterTexturePatch(e,t,a,r){const{pixelBlock:i}=await e.fetchRawPixels(t,{x:a.xmin,y:a.ymin},{width:a.xmax-a.xmin,height:a.ymax-a.ymin},r);if(s(r),i)return{extent:a,imageData:this._createImageDataFromPixelBlock(i)}}_composeRasterTextureFromCachedPatches(e,t){const a=t.filter(t=>this._intersectRasterTextureExtents(e,t.extent));if(!a.length)return;const r=new ImageData(e.xmax-e.xmin,e.ymax-e.ymin);for(const s of a){const t=this._intersectRasterTextureExtents(e,s.extent);t&&this._copyImageDataRegion(s.imageData,r,t.xmin-s.extent.xmin,t.ymin-s.extent.ymin,t.xmin-e.xmin,t.ymin-e.ymin,t.xmax-t.xmin,t.ymax-t.ymin)}return r}async _loadRaster(e,t){const{loadRaster:a}=await import("../../PanoramicViewer/utils.js"),r=await a(this._resolveTextureUrl(e),t);return s(t),r}async _createCompositedDefaultRasterTexture(e,t,a,r,i){const{pyramidScalingFactor:n}=e.rasterInfo.storageInfo,o=n??T,c=R(e.rasterInfo.width,e.rasterInfo.height,a,o),l=await this._fetchRasterTextureAtLevel(e,r,null,i);if(s(i),!l)return;const h=await this._fetchRasterTextureAtLevel(e,a,t,i);if(s(i),!h)return new u({data:l});const m=new ImageData(c.width,c.height);this._copyImageData(l,m,0,0,c.width,c.height);const f=o**a,{x:p,y:_}=this._resolveRasterDrawOrigin(t,f);return this._copyImageData(h,m,p,_),new u({data:m})}async _createRasterTexture(e,t,a,r){const{maximumPyramidLevel:s}=e.rasterInfo.storageInfo,i=await this._fetchRasterTextureAtLevel(e,a??s,t,r);if(i)return new u({data:i})}async _createPanoramicRasterTexture(e,t,a,r,i,n){if(i??=await y(t,a,r,this._properties.pointToPixel,n),s(n),!i?.length)return this._createRasterTexture(e,null,void 0,n);const{baseLevel:o,level:c,scalingFactor:u}=this._resolvePanoramicRasterLevels(e,a,i);return o<=c?this._createRasterTexture(e,null,c,n):this._createCompositedPanoramicRasterTexture(e,i,{baseLevel:o,level:c,scalingFactor:u},n)}_resolvePanoramicRasterLevels(e,t,a){const{maximumPyramidLevel:r,pyramidScalingFactor:s}=e.rasterInfo.storageInfo,i=a.reduce((a,r)=>Math.min(a,M(e,t,r)),r),n=O(e,i),o=s??T;return{baseLevel:Math.min(r,n+D),level:n,scalingFactor:o}}async _createCompositedPanoramicRasterTexture(e,t,a,r){const{baseLevel:i,level:n,scalingFactor:o}=a,c=R(e.rasterInfo.width,e.rasterInfo.height,n,o),l=await this._fetchRasterTextureAtLevel(e,i,null,r);if(s(r),!l)return;const h=new ImageData(c.width,c.height);this._copyImageData(l,h,0,0,c.width,c.height);const m=o**n;for(const u of t){const t=await this._fetchRasterTextureAtLevel(e,n,u,r);if(s(r),!t)continue;const{x:a,y:i}=this._resolveRasterDrawOrigin(u,m);this._copyImageData(t,h,a,i)}return new u({data:h})}_resolveRasterDrawOrigin(e,t){return{x:Math.max(0,Math.floor(e.xmin/t)),y:Math.max(0,Math.floor(e.ymin/t))}}async _createGridMesh(e,t,a,r,s,c){if("3d"!==t.type)return null;const u=await Promise.all(r.map(e=>e.spatialReference.equals(t.spatialReference)?e:n(e,t.spatialReference)));if(u.some(e=>!e))return null;const{faces:h,position:m,uv:f}=P(u,e,a,s);return c?.forEach((t,a)=>{const r=2*a;f[r]=t.x/e[0],f[r+1]=t.y/e[1]}),new i({vertexAttributes:new l({position:m,uv:f}),components:[new o({faces:h})],spatialReference:t.spatialReference.clone()})}async _createFootprintMesh(e,t,a,r){const i=b(e,a),n=await this._properties.getMapPoint(i,r);return s(r),this._createGridMesh(e,t,a,n)}async _createPanoramicGraphic(t){const{areaOfInterest:r,imageSize:s,signal:i,texture:n,textureUrl:o,view:l}=t;if(!n&&!o)throw new Error("Missing texture URL or texture data.");if(!s)return null;const h=await this._createPanoramicMesh(s,l,r,t.currentBestFeature,i);if(!h)return null;const p=h.vertexAttributes.position,_=[];for(let e=0;e<p.length;e+=3)_.push(...C);h.vertexAttributes.color=new Uint8Array(_);const d=new c({colorTexture:n??new u({url:o})});return h.components?.forEach(e=>{e.shading="source",e.material=d}),new e({geometry:h,symbol:new f({symbolLayers:new a([new m({})])})})}async _createPanoramicMesh(e,t,a,r,i){if("3d"!==t.type)return null;if(!r)return null;const{attributes:n}=r,{farDistance:o}=n;if("number"!=typeof o||!(o>0))return null;const c=b(e,a,Z),u=this._properties.getPanoramicTransformationState?.();if(!u)return null;const{imageToWorldProperties:l,updateElevationProps:m}=u,f=await h(c.map(e=>({...e,depth:o??l.farDistance})),l,m);return s(i),this._createGridMesh(e,t,a,f,Z,c)}async _createDefaultGraphic(t){const{texture:r,textureUrl:s}=t;if(!r&&!s)throw new Error("Missing texture URL or texture data.");if(!t.imageSize)return null;const i=await this._createFootprintMesh(t.imageSize,t.view,t.areaOfInterest,{signal:t.signal});if(!i)return null;const n=i.vertexAttributes.position,o=[];for(let e=0;e<n.length;e+=3)o.push(...C);i.vertexAttributes.color=new Uint8Array(o);const l=new c({colorTexture:r??new u({url:s})});return i.components?.forEach(e=>{e.shading="source",e.material=l}),new e({geometry:i,symbol:new f({symbolLayers:new a([new m({})])})})}}export{j as default};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{throwIfAborted as t}from"../../../core/promiseUtils.js";import{getMetersPerUnitForSR as a}from"../../../core/units.js";import n from"../../../geometry/Point.js";import r from"../../../geometry/Polygon.js";import e from"../../../geometry/SpatialReference.js";import{e as i}from"../../../chunks/intersectionOperator.js";import{computeFarplaneVertices as o,createRotationMatrixFromHPR as m}from"../../../layers/orientedImagery/transformations/utils.js";import{calculateUpdatedWmsf as h}from"../imageMeasurementUtils.js";const l=15,s=120,c=.9,M=1.1,f=1,x=179,u=3,y=2,g=1,p=150,d=16,w=32,I=8,b=.05,v=1,F=2,P=20,z=4096;function N(t,n){const{x:r=0,y:e=0,z:i=0}=n;if(0===r&&0===e&&0===i)return;const o=a(t.spatialReference),m=o?r/o:r,h=o?e/o:e,l=o?i/o:i,{position:s}=t.vertexAttributes,c=Math.floor(s.length/3);for(let a=0;a<c;a+=1)s[3*a]+=m,s[3*a+1]+=h,s[3*a+2]+=l;t.vertexAttributesChanged()}function R(t,n){const{radiusOffset:r=0}=n;if(0===r)return;const e=a(t.spatialReference),i=e?r/e:r,{position:o}=t.vertexAttributes,m=Math.floor(o.length/3);let h=0,l=0,s=0;for(let a=0;a<m;a++)h+=o[3*a],l+=o[3*a+1],s+=o[3*a+2];h/=m,l/=m,s/=m;let c=0;for(let a=0;a<m;a++){const t=o[3*a]-h,n=o[3*a+1]-l,r=o[3*a+2]-s;c+=Math.sqrt(t*t+n*n+r*r)}c/=m;const M=c>0?(c+i)/c:1;for(let a=0;a<m;a++){let t=o[3*a]-h,n=o[3*a+1]-l,r=o[3*a+2]-s;t*=M,n*=M,r*=M,o[3*a]=h+t,o[3*a+1]=l+n,o[3*a+2]=s+r}t.vertexAttributesChanged()}function j(t,a){const{columns:n,rows:r}=Q(t,a),[e,i]=t,o=a?.xmin??0,m=a?.ymin??0,h=a?Math.max(1,a.xmax-a.xmin):e,l=a?Math.max(1,a.ymax-a.ymin):i,s=new Array;for(let c=0;c<=r;c+=1){const t=m+c/r*l;for(let a=0;a<=n;a+=1)s.push({x:o+a/n*h,y:t})}return s}function A(t,a,n){const{columns:r,rows:e}=Q(a,n),i=r+1,o=new Float64Array(3*t.length),m=new Float32Array(2*t.length),h=new Array;t.forEach((t,a)=>{const n=3*a,h=2*a,l=a%i,s=Math.floor(a/i);o[n]=t.x,o[n+1]=t.y,o[n+2]=t.z??0,m[h]=l/r,m[h+1]=s/e});for(let l=0;l<e;l+=1)for(let t=0;t<r;t+=1){const a=l*i+t,n=a+1,r=a+i,e=r+1;h.push(a,n,e,a,e,r)}return{faces:h,position:o,uv:m}}function S(t,a,n,r=y){return{width:Math.ceil(t/r**n),height:Math.ceil(a/r**n)}}function L(t,a,n){const{width:r,height:e,storageInfo:i}=t.rasterInfo,{pyramidScalingFactor:o}=i,m=S(r,e,a,o??void 0);if(!n)return{offset:{x:0,y:0},size:m};const h=(o??y)**a,l={x:Math.max(0,Math.floor(n.xmin/h)),y:Math.max(0,Math.floor(n.ymin/h))},s=Math.min(m.width,Math.ceil(n.xmax/h)),c=Math.min(m.height,Math.ceil(n.ymax/h));return{offset:l,size:{width:Math.max(g,s-l.x),height:Math.max(g,c-l.y)}}}function O(t,a,n){const{maximumPyramidLevel:r,pyramidScalingFactor:e}=t.rasterInfo.storageInfo,i=e??y,o=Math.max(g,(n?.xmax??t.rasterInfo.width)-(n?.xmin??0)),m=Math.max(g,(n?.ymax??t.rasterInfo.height)-(n?.ymin??0)),h=Math.max(g,a.width),l=Math.max(g,a.height),s=Math.max(g,o/h,m/l),c=Math.ceil(Math.log(s)/Math.log(i));return Math.max(0,Math.min(r,Number.isFinite(c)?c:r))}function q(t,a,n){const{maximumPyramidLevel:r,pyramidScalingFactor:e}=t.rasterInfo.storageInfo,i=e??y,o=Math.max(g,(n?.xmax??t.rasterInfo.width)-(n?.xmin??0)),m=Math.max(g,(n?.ymax??t.rasterInfo.height)-(n?.ymin??0)),h=Math.max(g,a.width),l=Math.max(g,a.height);let s=r;for(let c=r;c>=0&&(s=c,!(0===c||o/i**c>h||m/i**c>l));c-=1);return s}function D(t,a,n=z){const{maximumPyramidLevel:r,pyramidScalingFactor:e}=t.rasterInfo.storageInfo,i=e??y;let o=Math.max(0,Math.min(r,a));for(;o<r;){const a=S(t.rasterInfo.width,t.rasterInfo.height,o,i);if(a.width<=n&&a.height<=n)break;o+=1}return o}function W(t){const{camera:a,width:n,height:r}=t;if(n<=0||r<=0)return{horizontal:a.fov,vertical:a.fov};const e=Math.sqrt(n*n+r*r);return{horizontal:2*Math.atan(Math.tan(a.fov*Math.PI/360)*n/e)*180/Math.PI,vertical:2*Math.atan(Math.tan(a.fov*Math.PI/360)*r/e)*180/Math.PI}}function k(t,a,n){if(null==t||null==a||!Number.isFinite(t)||!Number.isFinite(a))return{horizontal:t??null,vertical:a??null};const r=Math.sin(n*Math.PI/180),e=Math.cos(n*Math.PI/180),i=[[t,0],[t,a],[0,a]].map(([t,a])=>[e*t-r*a,r*t+e*a]),o=Math.min(0,...i.map(([t])=>t)),m=Math.max(0,...i.map(([t])=>t)),h=Math.min(0,...i.map(([,t])=>t)),l=Math.max(0,...i.map(([,t])=>t));return{horizontal:Math.min(Math.abs(m-o),p),vertical:Math.min(Math.abs(l-h),p)}}function C(t,a,n,r){const{width:e,height:i}=t,o=k(a,n,r),m=Math.sqrt(e*e+i*i);if(m<=0)return o.vertical??o.horizontal??null;if(e>=i){const t=o.vertical;return null==t||i<=0?null:2*Math.atan(Math.tan(t*Math.PI/360)*m/i)*180/Math.PI}const h=o.horizontal;return null==h||e<=0?null:2*Math.atan(Math.tan(h*Math.PI/360)*m/e)*180/Math.PI}function U(t,a,r=d,e=0){const i=t.camera.position,{horizontal:l,vertical:s}=W(t),c=i.spatialReference.isWebMercator?h(i.y):1,M=o({cameraLocation:i,farDistance:a,horizontalFieldOfView:l,rotationMatrix:m([t.camera.heading,t.camera.tilt,e]),scalingFactor:c,verticalFieldOfView:s}),f=[];for(let o=0;o<M.length;o+=1){const t=M[o],a=M[(o+1)%M.length];for(let e=0;e<r;e+=1){const o=e/r;f.push(new n({x:t[0]+(a[0]-t[0])*o,y:t[1]+(a[1]-t[1])*o,z:t[2]+(a[2]-t[2])*o,spatialReference:i.spatialReference}))}}return f}async function V(a,n,o,m,h){if("3d"!==n.type)return null;const{cameraRoll:l,farDistance:s}=a.attributes;if("number"!=typeof s||!Number.isFinite(s)||s<=0)return null;const c=U(n,s,w,l??0),M=await m(c,h);t(h);const f=M.filter(({x:t,y:a})=>Number.isFinite(t)&&Number.isFinite(a));if(f.length<4)return null;const[x,u]=o,y=new r({rings:[[[0,0],[x,0],[x,u],[0,u],[0,0]]],spatialReference:e.WebMercator}),g=new r({rings:[[...f.map(({x:t,y:a})=>[t,a]),[f[0].x,f[0].y]]],spatialReference:e.WebMercator}),p=i(g,y),d=p?p.rings.flatMap(t=>t.map(([t,a])=>({x:t,y:a}))):f;if(!d.length)return null;const I=d.map(({x:t})=>Math.max(0,Math.min(x,t))),b=d.map(({y:t})=>Math.max(0,Math.min(u,t)));return B({xmin:Math.floor(Math.max(0,Math.min(...I))),xmax:Math.ceil(Math.min(x,Math.max(...I))),ymin:Math.floor(Math.max(0,Math.min(...b))),ymax:Math.ceil(Math.min(u,Math.max(...b)))},x,u)}async function E(a,n,r,e,i){if("3d"!==n.type)return null;const{farDistance:o}=a.attributes;if("number"!=typeof o||!Number.isFinite(o)||o<=0)return null;const m=o,[h,l]=r,s=U(n,m),c=await e(s,i);t(i);const M=c.filter(({x:t,y:a})=>Number.isFinite(t)&&Number.isFinite(a));if(M.length<4)return null;const f=G(M,l);if(!f)return null;const x=J(M.map(({x:t})=>H(t,h)),h),u=h-x.gap;return u<=0?null:u>=h-v?[{xmin:0,xmax:h,ymin:f.ymin,ymax:f.ymax}]:K(x,h,f)}function B(t,a,n){const r=Math.max(g,t.xmax-t.xmin),e=Math.max(g,t.ymax-t.ymin),i=Math.max(I,Math.round(r*b)),o=Math.max(I,Math.round(e*b)),m=Math.floor(Math.max(0,t.xmin-i)),h=Math.ceil(Math.min(a,t.xmax+i)),l=Math.floor(Math.max(0,t.ymin-o)),s=Math.ceil(Math.min(n,t.ymax+o));return h>m&&s>l?{xmin:m,xmax:h,ymin:l,ymax:s}:null}function G(t,a){const n=t.map(({y:t})=>Math.max(0,Math.min(a,t))),r=Math.floor(Math.max(0,Math.min(...n))),e=Math.ceil(Math.min(a,Math.max(...n)));return e>r?{ymin:r,ymax:e}:null}function H(t,a){return(t%a+a)%a}function J(t,a){const n=t.slice().sort((t,a)=>t-a);let r=-1,e=0,i=0;for(let o=0;o<n.length;o+=1){const t=n[o],m=o===n.length-1?n[0]+a:n[o+1],h=m-t;h>r&&(r=h,e=t,i=m)}return{gap:r,start:e,end:i}}function K(t,a,n){const r=H(t.end,a),e=H(t.start,a);return r<=e?[{xmin:Math.floor(r),xmax:Math.ceil(e),...n}]:[{xmin:0,xmax:Math.ceil(e),...n},{xmin:Math.floor(r),xmax:a,...n}].filter(({xmin:t,xmax:a})=>a>t)}function Q(t,a){const[n,r]=t,e=a?Math.max(g,a.xmax-a.xmin):n,i=a?Math.max(g,a.ymax-a.ymin):r;if(e<=0||i<=0)return{columns:F,rows:F};const o=e/i;return o>=1?{columns:P,rows:Math.max(F,Math.round(P/o))}:{columns:Math.max(F,Math.round(P*o)),rows:P}}export{N as applyMeshOffsetInMeters,R as applySphereMeshOffsetInMeters,D as clampRasterLevelForTextureSize,V as computeDefaultAreaOfInterest,E as computePanoramicAreasOfInterest,U as createFarplaneSamplePoints,A as createSuperimposeGridVertexAttributes,j as createSuperimposeSamplePixels,q as getBaseRasterLevel,C as getDefaultSuperimposeFov,k as getEffectiveImageFieldOfView,L as getRasterFetchParameters,S as getRasterLevelSize,W as getViewCameraFieldOfView,O as getViewDependentRasterLevel,u as panoramicSuperimposeKeyboardAngleStep,s as panoramicSuperimposeMaxFov,x as panoramicSuperimposeMaxTilt,l as panoramicSuperimposeMinFov,f as panoramicSuperimposeMinTilt,c as panoramicSuperimposeZoomInFactor,M as panoramicSuperimposeZoomOutFactor};
2
+ import{throwIfAborted as t}from"../../../core/promiseUtils.js";import{getMetersPerUnitForSR as a}from"../../../core/units.js";import n from"../../../geometry/Point.js";import r from"../../../geometry/Polygon.js";import e from"../../../geometry/SpatialReference.js";import{e as i}from"../../../chunks/intersectionOperator.js";import{computeFarplaneVertices as o,createRotationMatrixFromHPR as m}from"../../../layers/orientedImagery/transformations/utils.js";import{calculateUpdatedWmsf as h}from"../imageMeasurementUtils.js";const l=15,s=120,c=.9,M=1.1,f=1,x=179,u=3,y=2,g=1,p=150,d=16,w=32,I=8,b=.05,v=1,F=2,P=20,z=4096;function R(t,n){const{x:r=0,y:e=0,z:i=0}=n;if(0===r&&0===e&&0===i)return;const o=a(t.spatialReference),m=o?r/o:r,h=o?e/o:e,l=o?i/o:i,{position:s}=t.vertexAttributes,c=Math.floor(s.length/3);for(let a=0;a<c;a+=1)s[3*a]+=m,s[3*a+1]+=h,s[3*a+2]+=l;t.vertexAttributesChanged()}function N(t,n){const{radiusOffset:r=0,minimumRadiusInMeters:e=0}=n;if(0===r)return;const i=a(t.spatialReference),o=i?r/i:r,{position:m}=t.vertexAttributes,h=Math.floor(m.length/3);let l=0,s=0,c=0;for(let a=0;a<h;a++)l+=m[3*a],s+=m[3*a+1],c+=m[3*a+2];l/=h,s/=h,c/=h;let M=0;for(let a=0;a<h;a++){const t=m[3*a]-l,n=m[3*a+1]-s,r=m[3*a+2]-c;M+=Math.sqrt(t*t+n*n+r*r)}M/=h;const f=i?e/i:e,x=Math.max(f,M+o),u=M>0?x/M:1;for(let a=0;a<h;a++){let t=m[3*a]-l,n=m[3*a+1]-s,r=m[3*a+2]-c;t*=u,n*=u,r*=u,m[3*a]=l+t,m[3*a+1]=s+n,m[3*a+2]=c+r}t.vertexAttributesChanged()}function j(t,a,n){const{columns:r,rows:e}=Q(t,a,n),[i,o]=t,m=a?.xmin??0,h=a?.ymin??0,l=a?Math.max(1,a.xmax-a.xmin):i,s=a?Math.max(1,a.ymax-a.ymin):o,c=new Array;for(let M=0;M<=e;M+=1){const t=h+M/e*s;for(let a=0;a<=r;a+=1)c.push({x:m+a/r*l,y:t})}return c}function A(t,a,n,r){const{columns:e,rows:i}=Q(a,n,r),o=e+1,m=new Float64Array(3*t.length),h=new Float32Array(2*t.length),l=new Array;t.forEach((t,a)=>{const n=3*a,r=2*a,l=a%o,s=Math.floor(a/o);m[n]=t.x,m[n+1]=t.y,m[n+2]=t.z??0,h[r]=l/e,h[r+1]=s/i});for(let s=0;s<i;s+=1)for(let t=0;t<e;t+=1){const a=s*o+t,n=a+1,r=a+o,e=r+1;l.push(a,n,e,a,e,r)}return{faces:l,position:m,uv:h}}function S(t,a,n,r=y){return{width:Math.ceil(t/r**n),height:Math.ceil(a/r**n)}}function L(t,a,n){const{width:r,height:e,storageInfo:i}=t.rasterInfo,{pyramidScalingFactor:o}=i,m=S(r,e,a,o??void 0);if(!n)return{offset:{x:0,y:0},size:m};const h=(o??y)**a,l={x:Math.max(0,Math.floor(n.xmin/h)),y:Math.max(0,Math.floor(n.ymin/h))},s=Math.min(m.width,Math.ceil(n.xmax/h)),c=Math.min(m.height,Math.ceil(n.ymax/h));return{offset:l,size:{width:Math.max(g,s-l.x),height:Math.max(g,c-l.y)}}}function O(t,a,n){const{maximumPyramidLevel:r,pyramidScalingFactor:e}=t.rasterInfo.storageInfo,i=e??y,o=Math.max(g,(n?.xmax??t.rasterInfo.width)-(n?.xmin??0)),m=Math.max(g,(n?.ymax??t.rasterInfo.height)-(n?.ymin??0)),h=Math.max(g,a.width),l=Math.max(g,a.height),s=Math.max(g,o/h,m/l),c=Math.ceil(Math.log(s)/Math.log(i));return Math.max(0,Math.min(r,Number.isFinite(c)?c:r))}function q(t,a,n){const{maximumPyramidLevel:r,pyramidScalingFactor:e}=t.rasterInfo.storageInfo,i=e??y,o=Math.max(g,(n?.xmax??t.rasterInfo.width)-(n?.xmin??0)),m=Math.max(g,(n?.ymax??t.rasterInfo.height)-(n?.ymin??0)),h=Math.max(g,a.width),l=Math.max(g,a.height);let s=r;for(let c=r;c>=0&&(s=c,!(0===c||o/i**c>h||m/i**c>l));c-=1);return s}function D(t,a,n=z){const{maximumPyramidLevel:r,pyramidScalingFactor:e}=t.rasterInfo.storageInfo,i=e??y;let o=Math.max(0,Math.min(r,a));for(;o<r;){const a=S(t.rasterInfo.width,t.rasterInfo.height,o,i);if(a.width<=n&&a.height<=n)break;o+=1}return o}function W(t){const{camera:a,width:n,height:r}=t;if(n<=0||r<=0)return{horizontal:a.fov,vertical:a.fov};const e=Math.sqrt(n*n+r*r);return{horizontal:2*Math.atan(Math.tan(a.fov*Math.PI/360)*n/e)*180/Math.PI,vertical:2*Math.atan(Math.tan(a.fov*Math.PI/360)*r/e)*180/Math.PI}}function k(t,a,n){if(null==t||null==a||!Number.isFinite(t)||!Number.isFinite(a))return{horizontal:t??null,vertical:a??null};const r=Math.sin(n*Math.PI/180),e=Math.cos(n*Math.PI/180),i=[[t,0],[t,a],[0,a]].map(([t,a])=>[e*t-r*a,r*t+e*a]),o=Math.min(0,...i.map(([t])=>t)),m=Math.max(0,...i.map(([t])=>t)),h=Math.min(0,...i.map(([,t])=>t)),l=Math.max(0,...i.map(([,t])=>t));return{horizontal:Math.min(Math.abs(m-o),p),vertical:Math.min(Math.abs(l-h),p)}}function C(t,a,n,r){const{width:e,height:i}=t,o=k(a,n,r),m=Math.sqrt(e*e+i*i);if(m<=0)return o.vertical??o.horizontal??null;if(e>=i){const t=o.vertical;return null==t||i<=0?null:2*Math.atan(Math.tan(t*Math.PI/360)*m/i)*180/Math.PI}const h=o.horizontal;return null==h||e<=0?null:2*Math.atan(Math.tan(h*Math.PI/360)*m/e)*180/Math.PI}function U(t,a,r=d,e=0){const i=t.camera.position,{horizontal:l,vertical:s}=W(t),c=i.spatialReference.isWebMercator?h(i.y):1,M=o({cameraLocation:i,farDistance:a,horizontalFieldOfView:l,rotationMatrix:m([t.camera.heading,t.camera.tilt,e]),scalingFactor:c,verticalFieldOfView:s}),f=[];for(let o=0;o<M.length;o+=1){const t=M[o],a=M[(o+1)%M.length];for(let e=0;e<r;e+=1){const o=e/r;f.push(new n({x:t[0]+(a[0]-t[0])*o,y:t[1]+(a[1]-t[1])*o,z:t[2]+(a[2]-t[2])*o,spatialReference:i.spatialReference}))}}return f}async function V(a,n,o,m,h){if("3d"!==n.type)return null;const{cameraRoll:l,farDistance:s}=a.attributes;if("number"!=typeof s||!Number.isFinite(s)||s<=0)return null;const c=U(n,s,w,l??0),M=await m(c,h);t(h);const f=M.filter(({x:t,y:a})=>Number.isFinite(t)&&Number.isFinite(a));if(f.length<4)return null;const[x,u]=o,y=new r({rings:[[[0,0],[x,0],[x,u],[0,u],[0,0]]],spatialReference:e.WebMercator}),g=new r({rings:[[...f.map(({x:t,y:a})=>[t,a]),[f[0].x,f[0].y]]],spatialReference:e.WebMercator}),p=i(g,y),d=p?p.rings.flatMap(t=>t.map(([t,a])=>({x:t,y:a}))):f;if(!d.length)return null;const I=d.map(({x:t})=>Math.max(0,Math.min(x,t))),b=d.map(({y:t})=>Math.max(0,Math.min(u,t)));return B({xmin:Math.floor(Math.max(0,Math.min(...I))),xmax:Math.ceil(Math.min(x,Math.max(...I))),ymin:Math.floor(Math.max(0,Math.min(...b))),ymax:Math.ceil(Math.min(u,Math.max(...b)))},x,u)}async function E(a,n,r,e,i){if("3d"!==n.type)return null;const{farDistance:o}=a.attributes;if("number"!=typeof o||!Number.isFinite(o)||o<=0)return null;const m=o,[h,l]=r,s=U(n,m),c=await e(s,i);t(i);const M=c.filter(({x:t,y:a})=>Number.isFinite(t)&&Number.isFinite(a));if(M.length<4)return null;const f=G(M,l);if(!f)return null;const x=J(M.map(({x:t})=>H(t,h)),h),u=h-x.gap;return u<=0?null:u>=h-v?[{xmin:0,xmax:h,ymin:f.ymin,ymax:f.ymax}]:K(x,h,f)}function B(t,a,n){const r=Math.max(g,t.xmax-t.xmin),e=Math.max(g,t.ymax-t.ymin),i=Math.max(I,Math.round(r*b)),o=Math.max(I,Math.round(e*b)),m=Math.floor(Math.max(0,t.xmin-i)),h=Math.ceil(Math.min(a,t.xmax+i)),l=Math.floor(Math.max(0,t.ymin-o)),s=Math.ceil(Math.min(n,t.ymax+o));return h>m&&s>l?{xmin:m,xmax:h,ymin:l,ymax:s}:null}function G(t,a){const n=t.map(({y:t})=>Math.max(0,Math.min(a,t))),r=Math.floor(Math.max(0,Math.min(...n))),e=Math.ceil(Math.min(a,Math.max(...n)));return e>r?{ymin:r,ymax:e}:null}function H(t,a){return(t%a+a)%a}function J(t,a){const n=t.slice().sort((t,a)=>t-a);let r=-1,e=0,i=0;for(let o=0;o<n.length;o+=1){const t=n[o],m=o===n.length-1?n[0]+a:n[o+1],h=m-t;h>r&&(r=h,e=t,i=m)}return{gap:r,start:e,end:i}}function K(t,a,n){const r=H(t.end,a),e=H(t.start,a);return r<=e?[{xmin:Math.floor(r),xmax:Math.ceil(e),...n}]:[{xmin:0,xmax:Math.ceil(e),...n},{xmin:Math.floor(r),xmax:a,...n}].filter(({xmin:t,xmax:a})=>a>t)}function Q(t,a,n=P){const[r,e]=t,i=a?Math.max(g,a.xmax-a.xmin):r,o=a?Math.max(g,a.ymax-a.ymin):e;if(i<=0||o<=0)return{columns:F,rows:F};const m=i/o;return m>=1?{columns:n,rows:Math.max(F,Math.round(n/m))}:{columns:Math.max(F,Math.round(n*m)),rows:n}}export{R as applyMeshOffsetInMeters,N as applySphereMeshOffsetInMeters,D as clampRasterLevelForTextureSize,V as computeDefaultAreaOfInterest,E as computePanoramicAreasOfInterest,U as createFarplaneSamplePoints,A as createSuperimposeGridVertexAttributes,j as createSuperimposeSamplePixels,q as getBaseRasterLevel,C as getDefaultSuperimposeFov,k as getEffectiveImageFieldOfView,L as getRasterFetchParameters,S as getRasterLevelSize,W as getViewCameraFieldOfView,O as getViewDependentRasterLevel,u as panoramicSuperimposeKeyboardAngleStep,s as panoramicSuperimposeMaxFov,x as panoramicSuperimposeMaxTilt,l as panoramicSuperimposeMinFov,f as panoramicSuperimposeMinTilt,c as panoramicSuperimposeZoomInFactor,M as panoramicSuperimposeZoomOutFactor};