@arcgis/core 5.0.0-next.33 → 5.0.0-next.34

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 (153) hide show
  1. package/assets/esri/core/workers/RemoteClient.js +1 -1
  2. package/assets/esri/core/workers/chunks/{9252854b512237b6a0ef.js → 0446562aee0639c61485.js} +1 -1
  3. package/assets/esri/core/workers/chunks/{b56c07c0b43cb1999070.js → 1fa55d4c4b092a98bdd7.js} +1 -1
  4. package/assets/esri/core/workers/chunks/{e7f4d135ef9665de1468.js → 33431e8131f6017de2f9.js} +1 -1
  5. package/assets/esri/core/workers/chunks/{096e5f94eaa226814569.js → 4356274cfa477eb6d749.js} +1 -1
  6. package/assets/esri/core/workers/chunks/{866a608d489bf56bc371.js → 486e69261aa2caf9ec3c.js} +1 -1
  7. package/assets/esri/core/workers/chunks/{3c1e50c3505e5e7c946a.js → 4d5591c1b4ef37075921.js} +1 -1
  8. package/assets/esri/core/workers/chunks/{d21ae4980741be98f948.js → 59889855d23baec1adf9.js} +1 -1
  9. package/assets/esri/core/workers/chunks/5f9e64f00329cb646f0c.js +1 -0
  10. package/assets/esri/core/workers/chunks/{c2596f48b37092dd566c.js → 61cb30e2e8edd18ebbf0.js} +1 -1
  11. package/assets/esri/core/workers/chunks/{d786b17cc9062b1450ac.js → 726a797f5df7eeee0b3d.js} +1 -1
  12. package/assets/esri/core/workers/chunks/{a2cee5ac0d4df0108425.js → 82cc758bddd9f8397b9f.js} +1 -1
  13. package/assets/esri/core/workers/chunks/{433d249c35c56bf15806.js → 97650ee3d0eecb69ccbb.js} +3 -3
  14. package/assets/esri/core/workers/chunks/{add17e95f47e6904bf6d.js → a59dab47a58695c639da.js} +1 -1
  15. package/assets/esri/core/workers/chunks/{f441fc74451330384fb0.js → abb05a903440d97a6a74.js} +1 -1
  16. package/assets/esri/core/workers/chunks/{5baef729beef0199c3d9.js → b536fdb655ad293d9024.js} +1 -1
  17. package/assets/esri/core/workers/chunks/{1d4ea8db272655c0608c.js → c7c721de93bc8688e13c.js} +1 -1
  18. package/assets/esri/core/workers/chunks/{446f76356fc116204ec3.js → c8d2cce4a426c72ab173.js} +1 -1
  19. package/assets/esri/core/workers/chunks/{14feb12826e0c8ba7fb8.js → d14bd320f72d8e8a0ad8.js} +1 -1
  20. package/assets/esri/core/workers/chunks/{4b6a44c6265c8959abd8.js → d3db7244fac7398cc700.js} +1 -1
  21. package/assets/esri/core/workers/chunks/{7aa730e5ac7b268e3c98.js → dd34d56caafa38d4b8e4.js} +1 -1
  22. package/assets/esri/core/workers/chunks/{2a17991923abc64c84c6.js → f55328aabf84770c8e6a.js} +1 -1
  23. package/assets/esri/core/workers/chunks/{e32fc0b2c6530d28ce85.js → fa01d1813fa78034526e.js} +1 -1
  24. package/assets/esri/libs/lyr3d/lyr3DMain.wasm +0 -0
  25. package/chunks/ComponentShader.glsl.js +19 -21
  26. package/chunks/Laserlines.glsl.js +1 -1
  27. package/chunks/Terrain.glsl.js +9 -11
  28. package/chunks/boundedPlane.js +1 -1
  29. package/chunks/cameraUtilsSpherical.js +1 -1
  30. package/chunks/lyr3DMain.js +1 -1
  31. package/chunks/vec32.js +1 -1
  32. package/config.js +1 -1
  33. package/core/deprecate.js +1 -1
  34. package/core/has.js +1 -1
  35. package/core/libs/gl-matrix-2/math/quat.js +1 -1
  36. package/core/libs/gl-matrix-2/math/vec3.js +1 -1
  37. package/geometry/operators/integrateOperator.js +1 -1
  38. package/geometry/support/lineSegment.js +1 -1
  39. package/geometry/support/meshUtils/merge.js +1 -1
  40. package/geometry/support/sphere.js +1 -1
  41. package/interfaces.d.ts +45 -25
  42. package/intl/locale.js +1 -1
  43. package/kernel.js +1 -1
  44. package/layers/Lyr3DWasmPerSceneView.js +1 -1
  45. package/layers/VoxelWasmPerSceneView.js +1 -1
  46. package/layers/orientedImagery/transformations/worldToImage.js +1 -1
  47. package/layers/support/layerOriginUtils.js +1 -1
  48. package/layers/voxel/VoxelVolume.js +1 -1
  49. package/package.json +3 -3
  50. package/request/config.js +1 -1
  51. package/request/process.js +1 -1
  52. package/support/revision.js +1 -1
  53. package/views/3d/analysis/AreaMeasurement/support/MeasurementData.js +1 -1
  54. package/views/3d/analysis/Dimension/lengthDimensionConstraintUtils.js +1 -1
  55. package/views/3d/analysis/Dimension/lengthDimensionUtils.js +1 -1
  56. package/views/3d/analysis/LineOfSight/LineOfSightController.js +1 -1
  57. package/views/3d/analysis/LineOfSight/LineOfSightIntersectionResult.js +1 -1
  58. package/views/3d/analysis/Slice/sliceToolUtils.js +1 -1
  59. package/views/3d/analysis/Viewshed/ViewshedScaleOrientManipulation.js +1 -1
  60. package/views/3d/analysis/Viewshed/ViewshedSubTool.js +1 -1
  61. package/views/3d/analysis/Viewshed/ViewshedSubVisualization.js +1 -1
  62. package/views/3d/analysis/Viewshed/ViewshedTool.js +1 -1
  63. package/views/3d/animation/pointToPoint/Camera.js +1 -1
  64. package/views/3d/camera/constraintUtils/distance.js +1 -1
  65. package/views/3d/camera/constraintUtils/tilt.js +1 -1
  66. package/views/3d/environment/ChapmanAtmosphere.js +1 -1
  67. package/views/3d/environment/CloudsParameters.js +1 -1
  68. package/views/3d/environment/EnvironmentManager.js +1 -1
  69. package/views/3d/environment/MarsAtmosphere.js +1 -1
  70. package/views/3d/interactive/editingTools/manipulations/MoveZManipulation.js +1 -1
  71. package/views/3d/interactive/editingTools/media/MediaElementManipulator3D.js +1 -1
  72. package/views/3d/interactive/editingTools/reshape/edgeOffsetUtils.js +1 -1
  73. package/views/3d/interactive/visualElements/MeasurementArrowVisualElement.js +1 -1
  74. package/views/3d/interactive/visualElements/RightAngleQuadVisualElement.js +1 -1
  75. package/views/3d/layers/I3SMeshView3D.js +1 -1
  76. package/views/3d/layers/IntegratedMesh3DTilesLayerView3D.js +1 -1
  77. package/views/3d/layers/graphics/objectResourceUtils.js +1 -1
  78. package/views/3d/layers/i3s/I3SViewportQueries.js +1 -1
  79. package/views/3d/layers/i3s/PointCloudRenderer.js +1 -1
  80. package/views/3d/layers/support/FeatureTileMeasurements3D.js +1 -1
  81. package/views/3d/layers/support/FeatureTileVisibility3D.js +1 -1
  82. package/views/3d/state/Frustum.js +1 -1
  83. package/views/3d/state/controllers/FovController.js +1 -1
  84. package/views/3d/state/controllers/GamepadKeyboardController.js +1 -1
  85. package/views/3d/state/controllers/momentum/ZoomPlanarMomentumController.js +1 -1
  86. package/views/3d/state/helpers/SceneIntersectionHelper.js +1 -1
  87. package/views/3d/support/FrustumExtentIntersection.js +1 -1
  88. package/views/3d/support/cameraUtils.js +1 -1
  89. package/views/3d/support/intersectionUtils.js +1 -1
  90. package/views/3d/support/pointsOfInterest/CameraOnSurface.js +1 -1
  91. package/views/3d/support/pointsOfInterest/CenterOnSurface.js +1 -1
  92. package/views/3d/support/pointsOfInterest/Focus.js +1 -1
  93. package/views/3d/support/viewpointUtils.js +1 -1
  94. package/views/3d/terrain/OverlayManager.js +1 -1
  95. package/views/3d/terrain/PatchRenderData.js +1 -1
  96. package/views/3d/terrain/SphericalPatch.js +1 -1
  97. package/views/3d/terrain/Tile.js +1 -1
  98. package/views/3d/webgl/RenderCamera.js +1 -1
  99. package/views/3d/webgl-engine/collections/Component/Material/{shader/ComponentData.glsl.js → ComponentData.glsl.js} +2 -2
  100. package/views/3d/webgl-engine/collections/Component/Material/ComponentMaterial.js +1 -1
  101. package/views/3d/webgl-engine/collections/Component/Material/ComponentShader.glsl.js +5 -0
  102. package/views/3d/webgl-engine/collections/Component/Material/ComponentTechnique.js +1 -1
  103. package/views/3d/webgl-engine/collections/Component/Material/ComponentTechniqueConfiguration.js +1 -1
  104. package/views/3d/webgl-engine/collections/Component/Material/{shader/DecodeSymbolColor.glsl.js → DecodeSymbolColor.glsl.js} +1 -1
  105. package/views/3d/webgl-engine/core/shaderLibrary/Slice.glsl.js +1 -1
  106. package/views/3d/webgl-engine/effects/haze/Haze.js +1 -1
  107. package/views/3d/webgl-engine/lib/GaussianSplatRenderNode.js +1 -1
  108. package/views/3d/webgl-engine/lib/Object3D.js +1 -1
  109. package/views/3d/webgl-engine/lib/ShadowAccumulator.js +1 -1
  110. package/views/3d/webgl-engine/lib/Viewshed.js +1 -1
  111. package/views/3d/webgl-engine/lib/edgeRendering/bufferLayouts.js +1 -1
  112. package/views/3d/webgl-engine/lib/edgeRendering/edgePreprocessing.js +1 -1
  113. package/views/3d/webgl-engine/lib/geometryDataUtils.js +1 -1
  114. package/views/3d/webgl-engine/lib/triangleIntersectionUtils.js +1 -1
  115. package/views/3d/webgl-engine/materials/DefaultLayouts.js +1 -1
  116. package/views/3d/webgl-engine/materials/HUDMaterial.js +1 -1
  117. package/views/3d/webgl-engine/materials/LineMarkerMaterial.js +1 -1
  118. package/views/3d/webgl-engine/materials/MeasurementArrowMaterial.js +1 -1
  119. package/views/3d/webgl-engine/materials/NativeLineMaterial.js +1 -1
  120. package/views/3d/webgl-engine/materials/RibbonLineMaterial.js +1 -1
  121. package/views/3d/webgl-engine/parts/RenderView.js +1 -1
  122. package/views/3d/webgl-engine/shaders/SphereDepthInterpolate.glsl.js +1 -1
  123. package/views/SelectionManager.js +1 -1
  124. package/views/interactive/GraphicManipulator.js +1 -1
  125. package/views/interactive/SegmentLabels.js +1 -1
  126. package/views/interactive/coordinateHelper.js +1 -1
  127. package/views/interactive/editGeometry/operations/OffsetEdgeVertex.js +1 -1
  128. package/views/interactive/sketch/constraints.js +1 -1
  129. package/views/interactive/snapping/featureSources/sceneLayerSource/SceneLayerSnappingSourceWorker.js +1 -1
  130. package/views/interactive/snapping/featureSources/sceneLayerSource/sceneLayerSnappingUtils.js +1 -1
  131. package/views/interactive/snapping/hints/LineSnappingHint.js +1 -1
  132. package/views/interactive/tooltip/tooltipCommonUtils.js +1 -1
  133. package/views/navigation/PanSphericalMomentumEstimator.js +1 -1
  134. package/views/support/euclideanAreaMeasurementUtils.js +1 -1
  135. package/views/support/euclideanLengthMeasurementUtils.js +1 -1
  136. package/views/support/geometry3dUtils.js +1 -1
  137. package/views/support/selectionUtils.js +1 -1
  138. package/widgets/Attachments/AttachmentsViewModel.js +1 -1
  139. package/widgets/BuildingExplorer/BuildingExplorerViewModel.js +1 -1
  140. package/widgets/BuildingExplorer/BuildingNumericFilterViewModel.js +1 -1
  141. package/widgets/BuildingExplorer.js +1 -1
  142. package/widgets/Editor/EditorViewModel.js +1 -1
  143. package/widgets/FeatureTable/FeatureTableViewModel.js +1 -1
  144. package/widgets/OrientedImageryViewer/OrientedImageryViewerViewModel.js +1 -1
  145. package/widgets/ShadowCast/DiscreteOptions.js +1 -1
  146. package/widgets/ShadowCast/DurationOptions.js +1 -1
  147. package/widgets/ShadowCast/ShadowCastViewModel.js +1 -1
  148. package/widgets/ShadowCast/ThresholdOptions.js +1 -1
  149. package/widgets/ShadowCast.js +1 -1
  150. package/widgets/support/SelectionList/SelectionListViewModel.js +1 -1
  151. package/assets/esri/core/workers/chunks/f3127bdf28a1d9b8db27.js +0 -1
  152. package/views/3d/webgl-engine/collections/Component/Material/shader/ComponentShader.glsl.js +0 -5
  153. /package/views/3d/webgl-engine/collections/Component/Material/{shader/ComponentDataConstants.js → ComponentDataConstants.js} +0 -0
@@ -2,4 +2,4 @@
2
2
  All material copyright Esri, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- import{__decorate as e}from"tslib";import t from"../../Graphic.js";import{equals as a,isSome as i}from"../../core/arrayUtils.js";import{createTask as r}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 c}from"../../core/Evented.js";import{makeHandle as l}from"../../core/handleUtils.js";import{equalsShallow as h}from"../../core/lang.js";import u from"../../core/Logger.js";import{clamp as d}from"../../core/mathUtils.js";import{abortMaybe as m,destroyMaybe as p}from"../../core/maybe.js";import{EsriPromise as g}from"../../core/Promise.js";import{isAbortError as y,throwIfAborted as v,waitTick as w}from"../../core/promiseUtils.js";import f from"../../core/ReactiveMap.js";import{whenOnce as F,on as _,watch as b,syncAndInitial as M,initial as I}from"../../core/reactiveUtils.js";import{sqlAnd as P}from"../../core/sql.js";import{getMetersPerUnitForSR as V}from"../../core/units.js";import{property as S,subclass as k}from"../../core/accessorSupport/decorators.js";import{isSerializable as A}from"../../core/support/jsonUtils.js";import{UpdatingHandles as C}from"../../core/support/UpdatingHandles.js";import L from"../../geometry/Extent.js";import{union as G}from"../../geometry/geometryEngineAsync.js";import R from"../../geometry/Multipoint.js";import T from"../../geometry/Point.js";import O from"../../geometry/Polygon.js";import j from"../../geometry/Polyline.js";import{projectWithZConversion as B}from"../../geometry/projectionUtils.js";import x from"../../geometry/SpatialReference.js";import{polygonCentroidPoint as H}from"../../geometry/support/centroid.js";import{isClockwise as E}from"../../geometry/support/coordsUtils.js";import{normalizeMapX as D}from"../../geometry/support/normalizeUtils.js";import{geographicToWebMercator as z}from"../../geometry/support/webMercatorUtils.js";import U from"../../layers/GraphicsLayer.js";import N from"../../layers/MediaLayer.js";import{searchImages as W,getSortedLayerFeatures as q}from"../../layers/orientedImagery/queries.js";import{calculateSuitabilities as $}from"../../layers/orientedImagery/core/bestImageUtils.js";import{createCoveragePolygon as J,computePolygonForInspection as Z,resizePolygon as K,checkIfPolygonContainsSelectedPoint as Q}from"../../layers/orientedImagery/core/coverageUtils.js";import{isElevationSource as X}from"../../layers/orientedImagery/core/ElevationSourceDefinitions.js";import{getMetersPerUnitOfSR as Y,convertGeographicToWebMercator as ee}from"../../layers/orientedImagery/core/utils.js";import{imageToWorld as te,imageToWorldPanoramic as ae}from"../../layers/orientedImagery/transformations/imageToWorld.js";import ie from"../../layers/orientedImagery/transformations/updateElevation.js";import{getElevationSampler as re}from"../../layers/orientedImagery/transformations/updateElevationUtils.js";import{or as se,getInitialAngle as oe,convertPixelToHeadingPitch as ne,convertHeadingPitchToSphereVertex as ce,getImageToWorldProperties as le,getUpdateElevationProps as he,getImageToWorldPanoramicProperties as ue,pointToArray as de,transformGraphicCoordinatesToPixel as me,getWorldToImageProperties as pe}from"../../layers/orientedImagery/transformations/utils.js";import{worldToImage as ge,worldToImagePanoramic as ye}from"../../layers/orientedImagery/transformations/worldToImage.js";import ve from"../../layers/support/ExtentAndRotationGeoreference.js";import{getFloorFilterClause as we}from"../../layers/support/floorFilterUtils.js";import fe from"../../layers/support/VideoElement.js";import Fe from"../../views/MapView.js";import _e from"../../views/draw/Draw.js";import{scale as be}from"../../views/draw/support/drawUtils.js";import{ViewEventPriorities as Me}from"../../views/input/InputManager.js";import Ie from"../PanoramicVideoViewer.js";import Pe from"../PanoramicViewer.js";import{defaultAngleThresholdInDegrees as Ve,videoExtent as Se,invalidCameraHeading as ke,sectorsInOrder as Ae,sampleExtent as Ce,sectorsRadii as Le}from"./constants.js";import{configureSketchTool as Ge,extractFieldsFromDataCaptureLayer as Re,isValidDataCaptureLayer as Te,constructGraphicFromImageGeometry as Oe}from"./dataCaptureUtils.js";import{isFeatureAttachment as je,getImageSourceFromAttachment as Be}from"./galleryUtils.js";import{getModeCorrectedPoint as xe,calculateCorrectedPixel as He,getUnitRateFromSpatialReference as Ee,calculateHeightFromTemporaryDistance as De,getModeCorrectedPoints as ze,computeTriangulatedVector as Ue,computeTriangulatedPoint as Ne}from"./imageMeasurementUtils.js";import{crossSymbol as We,crossSymbol3D as qe,measurementPolygonSymbol as $e,polylineSymbolPanoramic as Je,measurementPolylineSymbol as Ze,cameraOverlaySymbol3D as Ke,cameraOverlaySymbol as Qe,diamondSymbol as Xe,diamondSymbol3D as Ye,locationSymbol as et,locationSymbol3D as tt,activeSourcePointSymbol as at,sourcePointSymbol as it}from"./symbols.js";import{isNoAttachmentError as rt,getContentType as st,isTifOrMrf as ot,filterOILLayerView as nt,assignElevationSampleToFeatures as ct,calculateDirection as lt,calculateSegment as ht,isSceneView as ut,isGraphic as dt}from"./utils.js";import{disableVideoZoomAndPan as mt}from"./videoViewerUtils.js";import pt from"./components/ImageViewer.js";import gt from"./components/NavigationNode.js";import yt from"./components/OrientedImageryVideoViewModel.js";import{NoActiveViewerError as vt,NoFeatureFoundWithObjectIdError as wt}from"./navigation/errors.js";import{queryFeatureByObjectIds as ft}from"./navigation/queries.js";import{ImageMeasurementService as Ft}from"./services/ImageMeasurementService.js";import _t from"../Sketch/SketchViewModel.js";const bt={click:"view-click",imageClick:"image-click",triangularImageClick:"triangular-click",interactionHandles:"interaction-handles",hittestHandles:"hittest-handles",videoPlayerHandles:"video-handles",activeViewerCursorHandles:"active-viewer-cursor-handles",imageViewerCursorHandles:"image-viewer-cursor-handles"},Mt=new Set(["JPG","JPEG","TIFF","TIF","MRF"]),It=new Set(["MRF","TIFF","TIF"]),Pt=/\.(\w+)$/,Vt=()=>new n("orientedimageryviewer:sketch-not-initialized","Sketch property is not initialized, call loadSketch first");let St=class extends(c(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=Ve,this.cameraPitchThreshold=Ve,this.clickAction="hittest",this.videoViewModel=null,this.collectionId=null,this.conversionProps=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.directionMode="Relative",this.featureCache=[],this.navigationNodes=new s,this.determineWorkflowForFeature=async(e,t,a)=>{const{currentBestFeature:i,selectedPoint:r,view:s}=this;if(s?.closePopup(),i&&r){this._initialCurrentCoverageUpdate=!0,this._updateGroundElevation=!0;try{await this._updatePointsAndPolygons(a),await this._loadDepthImage(a),await this._loadImage(a)}catch(o){y(o)||(this.loadImageError(o),u.getLogger(this).error("#loadIImage()","error occured while loading image",o))}}},this.determineWorkflowForTriangularMeasurement=async(e,t,a)=>{if(this.view?.closePopup(),this.currentBestFeatureMeasurementImage&&this.selectedPoint)try{await this._loadMeasurementViewerImage(a)}catch(i){y(i)||(this.loadImageError(i),u.getLogger(this).error("#loadIImage()","error occured while loading image",i))}},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.heightMeasurementPixels=[],this.heightGraphic=null,this.heightMeasurementResult=0,this.heightMeasurementAccuracy=0,this.measurementAngle=null,this.tempDistance=null,this.imageGeometryField=null,this.imageLocationToolState=!1,this.imageMeasurementViewer=new pt,this.isAdditionalCoverageVisible=!1,this.isAdditionalPointSourcesVisible=!1,this.measurementVectors=[],this.layer=null,this.localPort=null,this.mapImageConversionToolState=!1,this.measureType=null,this.measurementGraphic=null,this.navigatorCurrentBestFeature=null,this.oiObjectIdField=null,this.overlayedCameraLocations=new s,this.overlayedMapFeatures=new f,this.pixelCoordinates=null,this.preserveAngle="none",this.pointSources=new s,this.previousFeatureAngle=0,this.selectedPoint=null,this.shouldShowSelectedImage=!1,this.sketch=null,this.sketchTriangular=null,this.sketchTriangularGraphicsLayer=null,this.draw=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,a)=>{"default"===this.mode&&"image-loaded"!==this.state||this.mode.includes("video")&&!this.videoElement?.content||await(this._adapter?.updateFootprint(e,t,a))},this.updateFootprintPanorama=async(e,t)=>{await(this._adapter?.updateFootprintPanorama(e,t))},this.updatingTriangularMeasurementState=!1,this.videoElement=null,this.videoLayer=null,this.videoMapView=new Fe({map:new Map}),this._adapter=null,this._highlightedFeatureHandle=null,this._imageViewer=new pt,this._initialCurrentCoverageUpdate=!0,this._locationPointOnImage=null,this._measurementService=null,this._correctedLocationPointOnImage=null,this._overlays=new U({listMode:"hide",internal:!0,elevationInfo:{mode:"absolute-height"},title:"OrentedImageryViewerViewModel overlays layer"}),this._panoramicVideoViewer=new Ie,this._panoramicViewer=new Pe,this._panoramicMeasurementViewer=new Pe,this._referencePointOnGround=null,this._referencePointOnImage=null,this._sectorData=null,this._featureToSector=null,this._updatingHandles=new C,this._clickTask=null,this._crossSymbol=null,this.footprintExtent=null,this._featureChangedTask=null,this._openPopupTask=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,a=this.layer?.imageReferenceField;if(!t||!e||!a)return;const i=this.overlayedMapFeatures.get(e);i?.forEach(e=>{const i=e.attributes??{},r=Object.keys(i).find(e=>e.toLowerCase()===a.toLowerCase());(r?i[r]: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:a}=await t;return v(e),this.sketchAdapter=new a({viewModel:this}),this.sketchAdapter},this.loadImageFromSource=async(e,t)=>this._updatingHandles.addPromise(this._loadImageFromSourceInternal(e,t)),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 a=this.additionalFeatures.find(({attributes:t})=>t.objectId===e);if(a)this.currentBestFeature=a;else{const{layer:a,layerFloorFilterClause:r}=this;if(!a)return void this.setMessage("noLayerSelected","info");this.beforeLoad();const s=this._updatingHandles.addPromise(this._queryAndLoadByObjectId(a,e,r,t));try{await s,await this.selectBestFeature(e,t)}catch(i){y(i)||(u.getLogger(this).error("oriented-imagery-viewer:show-image",i),"NoFeatureFoundWithObjectIdError"===i.name?this.setMessage("noFeatureFoundWithObjectId","error","",{objectId:e}):this.setMessage("imageLoadError","error",i.message))}}},this.imageToImageTransform=async(e,t,a)=>{const{updateElevationProps:i,...r}=t,{updateElevationProps:s,...o}=a,n=await te(e,r,i);return ge(n,o)},this.imageToImageTransformPanoramic=async(e,t,a)=>{const{updateElevationProps:i,...r}=t,{updateElevationProps:s,...o}=a,n=await ae(e,r,i);return ye(n,o)},this.getSectorFeatureById=e=>this._suitabilities?.find(({feature:{attributes:{objectId:t}}})=>t===e),this.getFeatureSectorById=e=>this._featureToSector?.[`${e}`],this.navigate=async(e,t)=>{const{activeViewer:a}=this;if(!a)throw new vt;return await a.navigate(e,t)},this.removeHighlight=()=>this._highlightedFeatureHandle?.remove(),this.revealImageGeometry=e=>{},this.selectBestFeature=async(e,t)=>(v(t),this.currentBestFeature=this.features?.find(({attributes:t})=>`${t.objectId}`==`${e}`),F(()=>"image-loaded"===this.state,t)),this.toggleImageAttributes=()=>{m(this._openPopupTask),this._openPopupTask=r(async e=>{const{currentBestFeature:a,popupEnabled:i,layer:r,view:s}=this;if(s?.closePopup(),!(s&&a&&i&&r))return;const{attributes:o,geometry:n}=a,c=new t({geometry:n,attributes:o.toJSON(),layer:r,sourceLayer:r});v(e),await s.openPopup({features:[c],location:o.location.clone()})})},this.updateSuitabilities=(e,t=!0)=>{e.sort((e,t)=>e.suitability-t.suitability),this._suitabilities=e;const a=this._suitabilities.map(({feature:e})=>e);this._initialCurrentCoverageUpdate=!0,this._updateFeatures(a,t),this._groupFeaturesBySectors()},this._createViewClickHandle=()=>{if(this.removeHandles(bt.click),this.disabled||null==this.view)return;const e=this.mapImageConversionToolState&&"image-loaded"===this.state?this._mapImageConversionToolViewClickHandler:this._viewClickHandler;this.addHandles(this.view.on("click",e,Me.WIDGET),bt.click)},this._createImageClickHandle=()=>{this.removeHandles(bt.imageClick);const{mapImageConversionToolState:e,mode:t,activeViewer:a,currentBestFeature:i,footprintExtent:s}=this,o=a?.imageSize;if(!(e&&"none"!==t&&o&&s&&i))return;const n=a.clickAction;this.clickAction="pixel-location";const c=l(()=>{this.clickAction=n});let h=null;const u=_(()=>a,"pixel-location",e=>{this.plotReferencePointOnImage(e),h?.abort(),h=r(async a=>{if(!e)return;const r=await this.getMapPoint(e,{feature:i,imageSize:o,mode:t}).then(e=>{const t=this.view?.spatialReference;return se(!t,e.spatialReference.equals(t))?e:B(e,t)});v(a),this.plotReferencePointOnGround(r)})});this.addHandles([u,c],bt.imageClick)},this._createTriangularImageClickHandle=()=>{this.removeHandles(bt.triangularImageClick),this.triangularMeasurementActive&&"none"!==this.mode&&this.currentBestFeature&&this.currentBestFeatureMeasurementImage&&this.activeTriangulatedViewer&&this.addHandles(this.activeTriangulatedViewer.imageRenderer.on("double-click",this._measurementImageClickHandler),bt.triangularImageClick)},this._createTriangularImageLocationHandle=()=>{this.removeHandles(bt.triangularImageClick);const{imageLocationToolState:e,mode:t,activeTriangulatedViewer:a}=this,i=a?.imageSize;if(!e||"none"===t||!i)return;this.clickAction="pixel-location";let s=null;const o=_(()=>a,"pixel-location",e=>{1===this.measurementVectors.length&&(this.plotLocationPointOnImage(e,!0),s?.abort(),s=r(async a=>{if(!e||this.triangulatedPoint||2===this.measurementVectors?.length||!this.currentBestFeatureMeasurementImage)return;let r=await this.getMapPoint(e,{feature:this.currentBestFeatureMeasurementImage,imageSize:i,mode:t});v(a);const s=this.view?.spatialReference;s&&!r.spatialReference.equals(s)&&(r=await B(r,s),v(a)),await this._calculateTriangulatedPointFromGroundPoint(r,{signal:a}),v(a)}))});this.addHandles(o,bt.triangularImageClick)},this._createImageLocationHandle=()=>{this.removeHandles(bt.imageClick);const{imageLocationToolState:e,mode:t,activeViewer:a,currentBestFeature:i,footprintExtent:s}=this,o=a?.imageSize;if(!(e&&"none"!==t&&o&&s&&i))return;this.clickAction="pixel-location";let n=null;const c=_(()=>a,"pixel-location",e=>{const{currentBestFeatureMeasurementImage:a,triangularMeasurementActive:s,activeTriangulatedViewer:c}=this;this.pixelCoordinates=e;const l=null!=a&&!c?.state.includes("loading");se(!s,l)&&this.plotLocationPointOnImage(e),n?.abort(),n=r(async a=>{if(!e)return;let r=await this.getMapPoint(e,{feature:i,imageSize:o,mode:t});v(a);const n=this.view?.spatialReference;n&&!r.spatialReference.equals(n)&&(r=await B(r,n),v(a)),this.groundCoordinates=r,s&&r&&l&&await this.triangulatedLocationWorkflow(r,a);const c=await this.calculateLocationAccuracy(e,r,t,a);v(a),c&&(this.groundCoordinatesAccuracy=c)})});this.addHandles(c,bt.imageClick)},this._handleImageHitTestResponse=async e=>{const{layer:t,overlayedCameraLocations:a}=this;if(!t)return;const i=e.results.find(({graphic:e,graphic:{attributes:i}})=>a.includes(e)&&i&&!i[t.imageReferenceField]&&!i[t.imageGeometryField]);if(!i)return;const r=i.graphic.attributes[t.objectIdField];await this.showImageByObjectId(r)},this._loadDepthImage=async e=>{const{currentBestFeature:t,layer:a,depthImageNotSupported:i}=this;if(this.depthImage?.destroy(),this.depthImage=null,!a||!t||i)return;const{depthImage:r}=t.attributes;if(!r)return;const s=(await import("./services/DepthImageService.js")).default;v(e),this.depthImage=new s({url:r});try{await this.depthImage.load(e)}catch(o){y(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:a,mode:i}=this;if(this.clearGraphics(),!a||!t||"none"===i||"video"===i||"panoramic-video"===i)return;const{attributes:r}=t,{imagePath:s,imageRotation:o,cameraHeading:n,cameraRoll:c,cameraPitch:l,objectId:h,cameraOrientation:d,location:m}=r,p=(c??0)+(o??0),g=m.spatialReference.isWGS84&&4!==d?.type?z(m):new T(m);let w=s;if(je(s))try{w=await Be(a,h,e)}catch(f){if(y(f))return;return rt(f)?(u.getLogger(this).error(f),void this.setMessage("noAttachment","error",`${a.objectIdField}: ${h}`)):(u.getLogger(this).error(f,{[a.objectIdField]:h,layer:a}),void this.setMessage("imageLoadError","error",`query-attachments-failed:${a.objectIdField} ${h}`))}try{await this.loadImageFromSource(w,{imageRotation:p,options:e,pitch:l,yaw:n,mode:i,cameraLocation:g}),v(e),await this.transformAndPlotSelectedLocation(e)}catch(f){y(f)||this.loadImageError(f)}},this._loadVideo=async e=>{const{currentBestFeature:t,layer:a,mode:i,selectedPoint:r}=this,s=t?.attributes.imagePath;if(!a||!t||"panoramic-video"!==i||!s)return;const{attributes:o}=t,{cameraHeading:n,cameraPitch:c,cameraOrientation:l,location:h}=o,u=h.spatialReference.isWGS84&&4!==l?.type?z(h):new T(h);try{this._panoramicVideoViewer.viewModel.video&&this._panoramicVideoViewer.viewModel.video.pause(),this._panoramicVideoViewer.videoSource=s;let t=n??0;u&&r&&(t=await oe(u,r)-t),this._panoramicVideoViewer.pitch=c??0,this._panoramicVideoViewer.yaw=t,await this._panoramicVideoViewer.loadVideo(e),v(e)}catch(d){y(d)||this.loadImageError(d)}},this._loadImageFromSourceInternal=async(e,t)=>{const{mode:a,imageRotation:i,options:r}=t,s="string"==typeof e,o=s?e:e.url,{pathname:n,searchParams:c}=new URL(o);let l=s?n.match(Pt)?.[1]:e.datasetFormat;if(!l)try{l=await st(o,{...t.options})}catch(h){y(h)||u.getLogger(this).error("#getContentType()",h)}switch(l??="UNKNOWN FORMAT",a){case"default":this.triangularMeasurementActive?await this._setImageSource(this.imageMeasurementViewer,l,o,c,i,r):await this._setImageSource(this._imageViewer,l,o,c,i,r);break;case"panoramic":if(Mt.has(l.toUpperCase())){const{selectedPoint:e}=this,{pitch:a,yaw:i,cameraLocation:s,viewAngle:n}=t,c=this.triangularMeasurementActive?this._panoramicMeasurementViewer:this._panoramicViewer;let h=i??0;"number"==typeof n?h=n-h:s&&e&&(h=await oe(s,e)-h),c.imageSource=o,c.pitch=a??0,c.yaw=h,It.has(l.toUpperCase())?await c.loadImageTiled(o,r):await c.loadImage(r)}else this.setMessage("unsupportedPanoramicImageryError","error",void 0,{datasetFormat:l});break}},this._loadMeasurementViewerImage=async e=>{const{currentBestFeatureMeasurementImage:t,layer:a,mode:i}=this;if(this.imageMeasurementViewer.clearGraphics(),this._panoramicMeasurementViewer.clearGraphics(),!a||!t||"none"===i||"video"===i||"panoramic-video"===i)return;const{attributes:r}=t,{imagePath:s,imageRotation:o,cameraHeading:n,cameraRoll:c,cameraPitch:l,objectId:h,cameraOrientation:d,location:m}=r,p=(c??0)+(o??0),g=m.spatialReference.isWGS84&&4!==d?.type?z(m):new T(m);let w=s;if(je(s))try{w=await Be(a,h,e)}catch(f){if(y(f))return;return rt(f)?(u.getLogger(this).error(f),void this.setMessage("noAttachment","error",`${a.objectIdField}: ${h}`)):(u.getLogger(this).error(f,{[a.objectIdField]:h,layer:a}),void this.setMessage("imageLoadError","error",`query-attachments-failed:${a.objectIdField} ${h}`))}try{await this.loadImageFromSource(w,{imageRotation:p,options:e,pitch:l,yaw:n,mode:i,cameraLocation:g}),v(e)}catch(f){y(f)||this.loadImageError(f)}},this._loadViewAdapter=async e=>{const{view:t}=this;if(t)switch(t.type){case"2d":{const{default:t}=await import("./adapters/view/MapViewAdapter.js");v(e),this._adapter=new t(this);break}case"3d":{const{default:t}=await import("./adapters/view/SceneViewAdapter.js");v(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=D(t.x,t.spatialReference),this.plotMapPoint(e.mapPoint)}},this._measurementImageClickHandler=e=>{e.stopPropagation(),e.preventDefault();const{sketchTriangular:t,triangularMeasurementActive:a,currentBestFeatureMeasurementImage:i,triangulatedMeasurementGraphic:r}=this;t&&a&&i&&r&&"active"!==t.state&&(t.update([r],{tool:"reshape"}),this.updatingTriangularMeasurementState=!0)},this._viewClickHandler=e=>{this._clickTask?.abort(),this._clickTask=r(async t=>{const{pointerType:a,button:i,mapPoint:r}=e;if(("mouse"!==a||0===i)&&r)return e.stopPropagation(),e.preventDefault(),this._updatingHandles.addPromise(this.loadBestImage(r,{signal:t}))})},this.plotSelectedPointOnImage=async(e,a)=>{if(await w(a),!e)return;const i=new T({...A(e)?e.toJSON():e});if("default"===this.mode)i.x-=.5,i.y=.5-i.y,i.spatialReference=this._imageViewer.imageRenderer.spatialReference.clone(),this._crossSymbol=new t({geometry:i,symbol:We}),this._imageViewer.addGraphic(this._crossSymbol,0);else if("panoramic"===this.mode){const{imageSize:a}=this._panoramicViewer;if(!a)return;const[i,r]=a,{heading:s,pitch:o}=ne(e,i,r),n=ce(s,o);this._crossSymbol=new t({geometry:new T(n,x.WebMercator),symbol:qe}),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)},I),b(()=>this.view?.map?.allLayers?.length,e=>{e&&this.view?.map?.layers.reorder(this._overlays,e-1)},I),b(()=>[this.state,this.mapImageConversionToolState,this.view,this.disabled],()=>{this._createViewClickHandle(),this._createImageClickHandle()},M),b(()=>[this.triangularMeasurementActive,this.currentBestFeatureMeasurementImage],()=>{this._createTriangularImageClickHandle()},M),b(()=>[this.state,this.imageLocationToolState,this.view],(e,t)=>{if(this._initializeMeasurementService(),this._createImageLocationHandle(),!this.imageLocationToolState)return this.clearPreviousGroundLocation(),void this._resetCursor();e[1]!==t?.[1]&&this._setMeasurementCursor()},M),b(()=>this.measureType,()=>{this.clearPreviousMeasurements(),this._initializeMeasurementService()},M),b(()=>this.bestFeatureAngle,(e,t)=>{this.previousFeatureAngle=t??0},M),b(()=>this.currentBestFeature,async(e,t)=>{m(this._featureChangedTask),this._featureChangedTask=r(async a=>this.determineWorkflowForFeature.apply(this,[e,t,{signal:a}])),await this._featureChangedTask.promise},{sync:!0}),b(()=>this.currentBestFeatureMeasurementImage,(e,t)=>{m(this._featureChangedTask),t&&e!==t&&(this.measurementVectors=[],this.triangulatedPoint=null,this.sketchTriangularGraphicsLayer?.graphics.destroyAll()),this._featureChangedTask=r(async a=>{await this.determineWorkflowForTriangularMeasurement(e,t,{signal:a}),v(a),this._reorderTriangularSketchLayer()})},M),b(()=>this.triangularMeasurementActive,(e,t)=>{t&&!e&&(this.measurementVectors=[],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(bt.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=r(async t=>{await this.updateFootprint(e,void 0,{signal:t})}))},{...M,equals:(e,t)=>a(e,t,h)}),bt.interactionHandles);break;case"video":this.addHandles(b(()=>{const{footprintExtent:e,videoElement:t,bestFeatureFootprint:a}=this;if(e&&t?.loaded&&a)return{videoExtent:Se,bestFeatureFootprint:a}},e=>{e?.videoExtent&&e?.bestFeatureFootprint&&(m(this._updateFootprintTask),this._updateFootprintTask=r(async t=>{await this.updateFootprint(e.videoExtent,void 0,{signal:t})}))},{...M,equals:(e,t)=>a(e?.videoExtent,t?.videoExtent,h)&&e?.bestFeatureFootprint===t?.bestFeatureFootprint}),bt.interactionHandles);break;case"panoramic":this.addHandles(b(()=>{const{currentBestFeature:e,state:t,_panoramicViewer:a}=this,{imageSize:i,vfov:r,hfov:s,pitch:o,yaw:n}=a;return e&&i&&!t.includes("loading")&&null!=r&&null!=s&&null!=o&&null!=n?[r,s,n,o]:null},e=>{if(!e||this.state.includes("loading"))return;const[t,a,i,s]=e;this.currentNode&&(this.currentNode.currentHeading=i+(this.currentNode.heading??0),this.currentNode.currentPitch=s+(this.currentNode.pitch??0)),m(this._updateFootprintTask),this._updateFootprintTask=r(async e=>{await this.updateFootprintPanorama({verticalFieldOfView:t,horizontalFieldOfView:a,yaw:i,pitch:s},{signal:e}),this._updateFootprintTask=null})},{equals:(e,t)=>a(e,t,h)}),bt.interactionHandles);break;case"panoramic-video":this.addHandles(b(()=>{const{currentBestFeature:e,state:t,_panoramicVideoViewer:a}=this,{imageSize:i,vfov:r,hfov:s,pitch:o,yaw:n,viewModel:c}=a,l=c.closestFeature??e;return l&&i&&!t.includes("loading")&&null!=r&&null!=s&&null!=o&&null!=n?[r,s,n,o,l]:null},e=>{if(!e)return;const[t,a,i,s,o]=e;m(this._updateFootprintTask),this._updateFootprintTask=r(async e=>{await this.updateFootprintPanorama({verticalFieldOfView:t,horizontalFieldOfView:a,yaw:i,pitch:s,feature:o},{signal:e}),v(e),this._updateFootprintTask=null})},{equals:(e,t)=>a(e,t,h)}),bt.interactionHandles)}},M),b(()=>[this.brightness,this.contrast,this.sharpness],()=>{const{_imageViewer:e,brightness:t,contrast:a,mode:i,sharpness:r}=this;"default"===i&&(e.brightness=t,e.contrast=a,e.sharpness=r)},M),b(()=>this.activeViewer?.imageRenderer,()=>{this.sketch&&(this.sketch.view=this.activeViewer?.imageRenderer)}),b(()=>this.activeViewer,e=>{this.removeHandles(bt.hittestHandles),e&&this.addHandles(_(()=>e,"hittest-response",this._handleImageHitTestResponse),bt.hittestHandles)})]),this.when().finally(()=>{this.notifyChange("state")})}destroy(){this.currentBestFeature=null,this._updateFootprintTask=m(this._updateFootprintTask),this._clickTask=m(this._clickTask),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._crossSymbol=p(this._crossSymbol),this._referencePointOnGround=p(this._referencePointOnGround),this._referencePointOnImage=p(this._referencePointOnImage),this._locationPointOnImage=p(this._locationPointOnImage),this._overlays&&this.view?.map?.remove(this._overlays),this._overlays.destroy(),this._imageViewer.destroy(),this.imageMeasurementViewer.destroy(),this._panoramicViewer.destroy(),this._panoramicMeasurementViewer.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:a}=this;switch(a){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",d(e,-10,10))}get contrast(){return this._get("contrast")??0}set contrast(e){this._set("contrast",d(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!ot(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 ot(t)||je(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===ke}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(nt(e))}get layerFloorFilterClause(){const{layerView:e}=this;return e?we(e):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:a,isSpherical:i}=e;return 360===a||i?"panoramic":"default"}get panoramicVideoLoaded(){const{mode:e,_panoramicVideoViewer:t}=this,{videoLoaded:a}=t.viewModel;return("panoramic-video"===e&&!0===a)??!1}get popupEnabled(){return!0===this.layer?.popupEnabled}get referencePoint(){return this._referencePointOnGround?.geometry}get sectorData(){const{_sectorData:e}=this;return e?Ae.map(t=>e[t]):null}get sharpness(){return this._get("sharpness")??0}set sharpness(e){this._set("sharpness",d(e,0,1))}get sketchGraphicsLayer(){const{sketch:e}=this;return"graphics"===e?.layer?.type?e.layer:void 0}get state(){const{mode:e,_updatingHandles:{updating:t},_featureChangedTask:a}=this;if(!this.isFulfilled()||t||!1===a?.finished)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:a,imageRotation:i}})=>{const r=e?.trim();return ot(r)||je(r)?{url:r,objectId:t,rotation:(a??0)+(i??0)}:null}).filter(i)):null}set view(e){this._set("view",e)}get _defaultGraphicsLayer(){const e={blendMode:"source-atop"};switch(this.mode){case"panoramic":return new U({...e,elevationInfo:{mode:"absolute-height"}});case"default":return new U({...e});default:return}}get _overlaysView(){return this.view?.layerViews.find(({layer:e})=>e===this._overlays)}beforeLoad(e=!0){this.view?.closePopup(),e&&(this.displayMessage=null),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._overlays?.removeAll()}async computeHeight(e,t,a=!0){return this._measurementService?.computeHeight(e,t,a)}async calculateAreaMeasurement(e,t,a){return this._measurementService?.calculateAreaMeasurement(e,t,a)}async calculateDistanceMeasurement(e,t,a){return this._measurementService?.calculateDistanceMeasurement(e,t,a)}async calculateAccuracy(e,t,a){return this._measurementService?.calculateAccuracy(e,t,a)}async calculateLocationAccuracy(e,t,a="default",i){return this._measurementService?.calculateLocationAccuracy(e,t,a,i)}async calculateAccuracyPanoramic(e,t,a=!1,i){return this._measurementService?.calculateAccuracyPanoramic(e,t,a,i)}async calculateHeightMeasurementInfo(e,t,a){return this._measurementService?.calculateHeightMeasurementInfo(e,t,a)}async calculateTriangulatedMeasurements(e){await(this._measurementService?.calculateTriangulatedMeasurements(e))}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:a,dataCaptureLayer:i}=this;if(!a)throw Vt();Ge(i,e,a),await a.create(e,{...t,defaultZ:0})}digitizeDelete(){if(!this.sketch)throw Vt();return this.sketch.delete()}digitizeDuplicate(){if(!this.sketch)throw Vt();return this.sketch.duplicate()}digitizePlace(e,t){if(!this.sketch)throw Vt();return this.sketch.place(e,t)}digitizeRedo(){if(!this.sketch)throw Vt();return this.sketch.redo()}digitizeUndo(){if(!this.sketch)throw Vt();return this.sketch.undo()}digitizeUpdate(e,t){if(!this.sketch)throw Vt();return this.sketch.update(e,t)}async displayHeightResults(){const{currentBestFeature:e,activeViewer:t,heightMeasurementPixels:a,mode:i}=this,r=t?.imageSize,s=e?.attributes;if(!s||!r)return;const o=await this.computeHeight(a,i);o?.value&&o?.accuracy&&(this.heightMeasurementResult=o.value,this.heightMeasurementAccuracy=o.accuracy)}filterByFootprints(e,t,a=!1){const i=[],r=[],s=[];return e.forEach(e=>{const{layer:{coveragePercent:o},attributes:n}=e;let c;const{polygon:l,frustum:h}=J(n);if(c=l.clone(),n.isInspection&&(c=Z(n)),o&&(c=K(c,o)),a||!t||Q(c,t)){s.push(e);const{geometry:t,objectId:a,cameraHeight:o,cameraHeading:c}=n,u=t.clone();u.z=o/Y(t.spatialReference),u.imageID=a,this.pointSources.push(u),c!==ke&&(i.push(l),h&&r.push(h))}}),{features:s,polygons:i,frustums:r}}getMeasurementProperties(e=this.currentBestFeature,t=this.activeViewer){if(!e||!t?.imageSize)return;const{elevationSample:a,attributes:i}=e,{elevationSource:r,cameraHeight:s}=i,o=le(i,t.imageSize[0],t.imageSize[1]);let n=o.cameraLocation;return(n.spatialReference.isGeographic?B(n,x.WebMercator):Promise.resolve(n)).then(e=>(n=e,he(n.spatialReference,n.z??0,s,{elevationSample:a,elevationSource:r,extent:this.footprintExtent}))).then(t=>("elevationSample"in t&&(e.elevationSample=t.elevationSample),{...o,cameraLocation:n,updateElevationProps:t}))}getMeasurementPropertiesPanoramic(e=this.currentBestFeature,t=this.activeViewer){if(!e||!t?.imageSize)return;const{elevationSample:a,attributes:i}=e,{elevationSource:r,cameraHeight:s}=i,o=ue(i,t.imageSize[0],t.imageSize[1]);let n=o.cameraLocation;return(n.spatialReference.isGeographic?B(n,x.WebMercator):Promise.resolve(n)).then(e=>(n=e,he(n.spatialReference,n.z??0,s,{elevationSample:a,elevationSource:r,extent:this.footprintExtent}))).then(t=>("elevationSample"in t&&(e.elevationSample=t.elevationSample),{...o,cameraLocation:n,updateElevationProps:t}))}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}).then(({features:e})=>t.applyEdits({deleteFeatures:e}))}handleSectorClick(e){if(isNaN(e))return;const t=this._sectorData?.[Ae[e]],a=t?.at(0);a&&(this.triangularMeasurementActive&&this.currentBestFeature?this._updateImageMeasurementBestFeature(a):this._updateCurrentBestFeature(a))}handleFeatureClick(e){const{sector:t,featureIndexInSector:a}=e;if(isNaN(a))return;const i=this._sectorData?.[t],r=i?.at(a);r&&(this.triangularMeasurementActive&&this.currentBestFeature?this._updateImageMeasurementBestFeature(r):this._updateCurrentBestFeature(r))}handleDrawCursorUpdateEvents(e){const{measurementAngle:t,tempDistance:a,heightMeasurementPixels:i,mode:r,activeViewer:s,currentBestFeature:o}=this,n=s?.imageSize;if(!e.vertices||!n||!o)return;const c=xe(e.vertices.at(-1),r,n);if(i.length<1||!c||!a||!t||"none"===r)return;const l=He(i[0],c,t);if(!l?.length)return;this.heightMeasurementPixels.push(l),"panoramic"===r?this.createPolylineGraphicPano():this.createPolylineGraphic();const h=Ee(o.attributes.location.spatialReference),u=De(this.heightMeasurementPixels,a,h);u&&(this.heightMeasurementResult=u)}async handleDrawVertexAddEvents(e,t){const{currentBestFeature:a,activeViewer:i,heightMeasurementPixels:r,mode:s}=this;if(!a||!i||!e.vertices?.length||"none"===s)return;const o=i?.imageSize;if(!r.length&&o){const a=xe(e.vertices.at(-1),s,o);this.heightMeasurementPixels.push(a);const i=await this.calculateHeightMeasurementInfo(a,s,t);if(!i?.measurementAngle||!i?.tempDistance)return;this.measurementAngle=i.measurementAngle,this.tempDistance=i.tempDistance}}load(e){return this.addResolvingPromise(this._loadViewAdapter(e).catch(e=>{if(!y(e))throw e})),this}async loadBestImage(e,t){return this.selectedPoint=ee(e),this.beforeLoad(),this._fetchFeaturesWithController(e,t)}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:a}=await t;v(e),this.sketch=new a({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:a}=await t;if(v(e),this.sketchAdapter=new a({viewModel:this}),!this.sketchAdapter.viewModel.isResolved())return}return this.sketchAdapter}async loadTriangulatedMeasurementAdapter(e){if(!this.triangulatedMeasurementAdapter){const t=import("./adapters/sketch/TriangulatedMeasurementAdapter.js"),{default:a}=await t;if(v(e),this.triangulatedMeasurementAdapter=new a({viewModel:this}),!this.triangulatedMeasurementAdapter.viewModel.isResolved())return}return this.triangulatedMeasurementAdapter}async processFeatureResponse(e,t,a){const{features:i}=e;if(this._clearFeatureGeometries(),!this._checkFeatures(i))return;const{features:r,polygons:s,frustums:o}=this.filterByFootprints(i,t,a?.skipFilter);if(!this._checkFeatures(r))return;this.coveragePolygons.addMany(s),this.coverageFrustums.addMany(o);const n=await this.processElevationSample(s,r,a);v(a),await this._updateElevationOfSelectedPointAndLocations(r,t,n),v(a),ct(r,n);const c=this._processSuitableFeatures(r,t);this.updateSuitabilities(c,a?.loadBestImage)}async processFeatureElevation(e,t,a){if(!t)return;const{features:i,polygons:r}=this.filterByFootprints(e,t,!0);if(!i?.length)return;const s=await this.processElevationSample(r,i,a);return v(a),s}async startMeasurement(e,t){this.sketch||await this.loadSketch(t),await this.loadMeasurementAdapter(t);const{sketch:a,sketchAdapter:i,activeViewer:r,mode:s}=this;if(!a||!i||!r||"none"===s)return;if(this.displayNewMeasurementButton=!1,"panoramic"===s&&(a.defaultCreateOptions.defaultZ=0),await a.create(e),"panoramic"===s){const{drawOperation:e}=a.view.activeTool;e.constraintsEnabled=!1,e._set("elevationDrawSurface",null)}const o=this.activeViewer?.imageRenderer.effectiveTheme.accentColor;o&&this.sketch&&(this.sketch.polygonSymbol=$e(o),this.sketch.polylineSymbol="panoramic"===s?Je:Ze(o,2.5))}startHeightMeasurement(){this.heightMeasurementPixels=[],this.displayNewMeasurementButton=!1,this.draw??=new _e({view:this.activeViewer?.imageRenderer});this.draw.create("polyline").on(["cursor-update","vertex-add","draw-complete"],e=>this.handleDrawEvents(e))}createPolylineGraphic(){const e=[this.heightMeasurementPixels[0],this.heightMeasurementPixels.at(-1)],a=this.activeViewer?.imageRenderer.spatialReference;if(this.heightGraphic)this.heightGraphic.geometry=new j({paths:[e],spatialReference:a});else{const i=new j({paths:[e],spatialReference:a}),r=this.activeViewer?.imageRenderer.effectiveTheme.accentColor;this.heightGraphic=new t({geometry:i,symbol:Ze(r,2.5)}),this.activeViewer?.addGraphic(this.heightGraphic)}}createPolylineGraphicPano(){const e=this.activeViewer?.imageRenderer.spatialReference,a=this.activeViewer?.imageSize;if(!a)return;const i={x:this.heightMeasurementPixels[0][0],y:this.heightMeasurementPixels[0][1]},r={x:this.heightMeasurementPixels.at(-1)[0],y:this.heightMeasurementPixels.at(-1)[1]},{heading:s,pitch:o}=ne(i,a[0],a[1]),{heading:n,pitch:c}=ne(r,a[0],a[1]),l=[[...ce(s,o)],[...ce(n,c)]];if(this.heightGraphic)this.heightGraphic.geometry=new j({paths:[l],spatialReference:e});else{const a=new j({paths:[l],spatialReference:e});this.heightGraphic=new t({geometry:a,symbol:Je}),this._panoramicViewer.addGraphic(this.heightGraphic,0)}}async editOverlayedGraphics(e){this.sketchTriangularGraphicsLayer||this._initializeSketchTriangularGraphicsLayer(),this.sketchTriangularGraphicsLayer?.destroyed&&this._handleDestroyedTriangularSketchLayer(),this.sketchTriangularGraphicsLayer.add(e),this.sketchTriangular||(this._initializeSketchTriangular(),await this.loadTriangulatedMeasurementAdapter()),this.updateOverlayedGeometry(e)}updateOverlayedGeometry(e){this.sketchTriangular?.update([e],{tool:"reshape"})}async processMeasurementVectors(e){this.triangularMeasurementActive&&this.currentBestFeature&&(this.measurementVectors?.length<2&&await this.updateMeasurementVectorsArray(e),2===this.measurementVectors.length&&await this.calculateTriangulatedMeasurements(e))}async updateMeasurementVectorsArray(e){const t=this.measurementVectors.length?this.currentBestFeatureMeasurementImage:this.currentBestFeature;if(t){const a=await this.computeMeasurementVector(e,t);a&&this.measurementVectors.push(a)}}async computeMeasurementVector(e,t){const{activeViewer:a,mode:i}=this,r=a?.imageSize;if(!e||!t||!r)return;const s=ze(e,i,r),o=this.view?.spatialReference,n=[];for(let c=0;c<s.length;c++){const e={x:s[c][0],y:s[c][1]};let a=await this.getMapPoint(e,{feature:t,imageSize:r,mode:i});o&&!a.spatialReference.equals(o)&&(a=await B(a,o)),n.push(a)}return Ue(n,t)}async handleDrawEvents(e,t){if(this.draw)switch(e.type){case"cursor-update":this.handleDrawCursorUpdateEvents(e);break;case"vertex-add":await this.handleDrawVertexAddEvents(e,t);break;case"draw-complete":await this.displayHeightResults()}}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:a,currentBestFeature:i,overlayedCameraLocations:r,layer:s,mode:o,state:n,layerFloorFilterClause:c}=this,l=a?.imageSize;if(!l||!i||!s||"none"===o||n.includes("loading"))return;const{polygon:h}=J(i.attributes);if(a.removeManyGraphics(r.toArray()),r.removeAll(),e){const{features:e}=await s.queryFeatures({where:P(`${s.objectIdField} <> ${i.attributes.objectId}`,P(s.definitionExpression,c)),geometry:h,returnGeometry:!0,outFields:[s.objectIdField]}),n=await Promise.all(e.map(async e=>{const{attributes:a,geometry:r}=e,s=await this.getPixels(r,{feature:i,imageSize:l,mode:o}),n="panoramic"===o?Ke():Qe();return new t({attributes:a,symbol:n,geometry:s})}));r.addMany(n),a.addManyGraphics(r.toArray())}}overlayGraphicsOnImage(e,t){this.removeOverlayedGraphicsOnImage(e),this.overlayedMapFeatures.set(e,t),this.activeViewer?.addManyGraphics(t.toArray())}async overlayMapFeatures(e,a=!1){const{activeViewer:r,currentBestFeature:o,mode:n,state:c,layer:l}=this,h=r?.imageSize;if(!h||!o||"none"===n||"video"===n||"panoramic-video"===n||c.includes("loading")||!l)return;const{polygon:d}=J(o.attributes);try{const{imageGeometryField:t,oiObjectIdField:a}=Re(e,l.imageGeometryField,l.imageReferenceField);this.imageGeometryField=t.name,this.oiObjectIdField=a.name}catch(g){u.getLogger(this).warn("oriented-imagery-viewer:overlay-map-features",g)}const{features:m}=await e.queryFeatures({geometry:d,returnGeometry:!0,outFields:["*"]}),p=new s((await Promise.all(m.map(async i=>{const r=i.symbol?.clone()??e.renderer?.getSymbol(i)?.clone(),{attributes:s,geometry:c}=i,l=c,{imageGeometryField:d,oiObjectIdField:m}=this;if(d&&m&&Te(e,d,m)&&`${s[m]}`==`${o.attributes.objectId}`)try{return Oe(s,d,e,a,h,n,r)}catch(g){u.getLogger(this).warn("oriented-imagery-viewer:overlay-map-features","couldn't create graphic from attributes, geometry will be used",{error:g,feature:i,layer:e,imageGeometryField:this.imageGeometryField,imageReferenceField:this.oiObjectIdField})}switch(l?.type){case"point":{const i=await this.getPixels(l,{feature:o,imageSize:h,mode:n});return new t({attributes:s,layer:e,symbol:r,geometry:i,visible:e.visible&&a})}case"polygon":{const{rings:i,spatialReference:c}=l,u=i.map(e=>e.map(([e,t,a])=>new T({x:e,y:t,z:a,spatialReference:c}))),d=await Promise.all(u.map(async e=>this.getPixels(e,{feature:o,imageSize:h,mode:n}).then(e=>e.map(de))));return new t({attributes:s,layer:e,symbol:r,geometry:new O({rings:d,spatialReference:x.WebMercator}),visible:e.visible&&a})}case"polyline":{const{paths:i,spatialReference:c}=l,u=i.map(e=>e.map(([e,t,a])=>new T({x:e,y:t,z:a,spatialReference:c}))),d=await Promise.all(u.map(async e=>this.getPixels(e,{feature:o,imageSize:h,mode:n}).then(e=>e.map(de))));return new t({attributes:s,layer:e,symbol:r,geometry:new j({paths:d,spatialReference:x.WebMercator}),visible:e.visible&&a})}case"multipoint":{const{points:i,spatialReference:c}=l,u=i.map(([e,t,a])=>new T({x:e,y:t,z:a,spatialReference:c})),d=await this.getPixels(u,{feature:o,imageSize:h,mode:n}).then(e=>e.map(de));return new t({attributes:s,layer:e,symbol:r,geometry:new R({points:d,spatialReference:x.WebMercator}),visible:e.visible&&a})}}return null}))).filter(i));this.overlayGraphicsOnImage(`${e.id}`,p)}getDepthAt(e){const{activeViewer:t,currentBestFeature:a,mode:i,state:r,depthImage:s}=this,o=t?.imageSize;if(!o||!a||"none"===i||r.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]}async getPixels(e,t){const{imageSize:a,mode:i,feature:r}=t,s=(await this.worldToImage(Array.isArray(e)?e:[e],r)).map(e=>{if("default"===i)return new T({x:e.x-.5,y:.5-e.y,spatialReference:x.WebMercator});const[t,r]=a,{heading:s,pitch:o}=ne(e,t,r),n=ce(s,o);return new T(n,x.WebMercator)});return Array.isArray(e)?s:s[0]}async getMapPoint(e,t){const{feature:a,mode:i,imageSize:r}=t,{elevationSample:s,attributes:o}=a,{elevationSource:n,location:c,cameraHeight:l}=o;let h=c.clone();h.spatialReference.isGeographic&&(h=await B(h,x.WebMercator));const u=await he(c.spatialReference,c.z??0,l,{elevationSample:s,elevationSource:n,extent:this.footprintExtent});let d;"elevationSample"in u&&(a.elevationSample=u.elevationSample);const m=Array.isArray(e)?e:[e];if(this.depthImage?.loaded)for(const p of m){const e=this.getDepthAt(p);null!=e&&(p.depth=e)}if("default"===i){const e=le(o,r[0],r[1]);d=await te(m,{...e,cameraLocation:h},u)}else{const e=ue(o,r[0],r[1]);d=await ae(m,{...e,cameraLocation:h},u)}return Array.isArray(e)?d:d[0]}getActiveSectors(){return Ae.filter(e=>this._sectorData?.[e]?.length)}async plotMapPoint(e){return this.plotReferencePoint(e),this.transformAndPlotReferencePointOnImage({feature:this.currentBestFeature,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 T({...e.toJSON()}),symbol:Xe}),this.view?this._overlays?.add(this._referencePointOnGround):this.emit("plot-ground-point",{data:{point:this._referencePointOnGround?.geometry}}))}plotReferencePointOnImage(e){if("image-loaded"===this.state)switch(this.clearReferencePointOnImage(),this.mode){case"default":{const a=A(e)?e.toJSON():e;a.x-=.5,a.y=.5-a.y,this._referencePointOnImage=new t({geometry:new T({spatialReference:this._imageViewer.imageRenderer.spatialReference,...a}),symbol:Xe}),this._imageViewer.addGraphic(this._referencePointOnImage,0);break}case"panoramic":{const{imageSize:a}=this._panoramicViewer;if(!a)return;const[i,r]=a,{heading:s,pitch:o}=ne(e,i,r),n=ce(s,o);this._referencePointOnImage=new t({geometry:new T(n,x.WebMercator),symbol:Ye}),this._panoramicViewer.addGraphic(this._referencePointOnImage,0);break}}}plotLocationPointOnImage(e,t=!1){if("image-loaded"===this.state)switch(this.clearLocationPointOnImage(t),this.mode){case"default":this._plotLocationPointOnDefaultImage(e,t);break;case"panoramic":this._plotLocationPointOnPanoramicImage(e,t)}}removeAllOverlayMapFeatures(){this.overlayedMapFeatures.forEach(e=>{this._imageViewer.removeManyGraphics(e.toArray())}),this.overlayedMapFeatures.clear()}removeOverlayedGraphicsOnImage(e){const t=this.overlayedMapFeatures.get(e);t?.length&&(this.activeViewer?.removeManyGraphics(t.toArray()),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.heightMeasurementPixels=[],this.measurementVectors=[],this.heightMeasurementResult=0,this.tempDistance=null,this.measurementAngle=null,this.heightMeasurementAccuracy=0,this.heightGraphic=null,this.triangulatedDistanceMeasurement=null,this.triangulatedDistanceAccuracy=null,this.triangulatedAreaMeasurement=null,this.triangulatedMeasurementGraphic=null,this.updatingTriangularMeasurementState=!1,this.triangulatedAreaAccuracy=0}async saveDrawing(){const{dataCaptureLayer:e,sketchAdapter:t}=this;if(!e||"data-capture"!==t?.type)return;const{pendingGraphics:a,savedGraphics:i}=t,r=a.get(e.id),s=r?.toArray();if(!r||!s?.length)return;const{addFeatureResults:o}=await this.saveDataCaptureFeatures(s),n=o.reduce((t,{objectId:a,globalId:i,error:r},o)=>{const n=s[o],{attributes:c}=n;return r?t.error.push(n):(a&&(c[e.objectIdField]=a),i&&e.globalIdField&&(c[e.globalIdField]=i),t.success.push(n)),t},{success:[],error:[]});i.addMany(n.success),r.removeAll(),r.addMany(n.error)}async saveDataCaptureFeatures(e){const{activeViewer:t,currentBestFeature:a,dataCaptureLayer:r,mode:s}=this,o=t?.imageSize;if(!o||!a||"none"===s||"video"===s||"panoramic-video"===s)throw new n("orientedimageryviewer:missing-input","Image size, current best feature and mode are required to save data capture features");if(!r)throw new n("orientedimageryviewer:missing-featurelayer","Data capture layer is not available");const c=await Promise.all(e.map(async e=>{const t=e.clone(),{geometry:i}=t;if(!i)return;const n=i.type,c=r.hasZ,l=r.geometryType,h=n!==l,u=h?await import("./transformers.js"):null,d=u?.default[l],m=h?d?.(i):i;if(m)switch(m.type){case"point":return t.geometry=await this.getMapPoint(me(s,m,o),{feature:a,imageSize:o,mode:s}),c||(delete t.geometry.z,t.geometry.hasZ=!1),t.geometry.hasM=!1,t;case"polygon":{const e=await Promise.all(m.rings.map(async e=>this.getMapPoint(e.map(([e,t,a])=>me(s,{x:e,y:t,z:a},o)),{feature:a,imageSize:o,mode:s})));return t.geometry=new O({spatialReference:e[0][0].spatialReference,hasZ:c,hasM:!1,rings:e.map(e=>e.map(de))}),t}case"polyline":{const e=await Promise.all(m.paths.map(async e=>this.getMapPoint(e.map(([e,t,a])=>me(s,{x:e,y:t,z:a},o)),{feature:a,imageSize:o,mode:s})));return t.geometry=new j({spatialReference:e[0][0].spatialReference,hasZ:c,hasM:!1,paths:e.map(e=>e.map(de))}),t}}})),l=c.filter(i);return r.applyEdits({addFeatures:l}).then(e=>{const{addFeatureResults:t}=e;let a=0;const i=c.map(e=>{const i=t[a++];return e?i:{error:new n("orientedimageryviewer:save-unsucccessful","Error in saving data capture features"),objectId:null,globalId:null}});return{...e,addFeatureResults:i}})}async searchBestImage(e,t){try{const a=await W(e,t);a&&await this.processFeatureResponse(a,e.point,t)}catch(a){y(a)||(this.setMessage("imageLoadError","error",a.message),u.getLogger(this).error("error occurred while finding best image",a))}}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 a=this.activeViewer?.imageRenderer,{oiObjectIdField:i,currentBestFeature:r}=this;if(!a||!r||!i)return;const{attributes:{objectId:o}}=r,n=this.overlayedMapFeatures.get(e.id)?.toArray()??[],c=[],l=[];for(const s of n)`${s.getAttribute(i)}`==`${o}`?c.push(s):l.push(s);this.overlayGraphicsOnImage(e.id,new s(l)),this.collectionId=e.id;const h=await this.loadSketch(t),u=await this.loadDataCaptureAdapter(t);v(t),h.addGraphics(c),u.savedGraphics.addMany(c);a.ui.find("zoom").visible=!1,a.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,a=this.activeViewer?.imageRenderer;if(!a||a.destroyed)return;a.map.layers.remove(this.sketchGraphicsLayer),e&&t&&await this.overlayMapFeatures(t,!0);const i=a.ui.find("zoom");i&&(i.visible=!0)}stopMeasurement(){this.heightMeasurementPixels=[],this.draw?.reset(),this.sketch?.cancel()}toggleAllOverlayMapFeatures(e){this.overlayedMapFeatures.forEach(t=>{this._toggleVisiblity(t,e)})}toggleOverlayMapFeatures(e,t,a){const i=this.overlayedMapFeatures.get(e);i&&a&&this._toggleVisiblity(i,t)}toggleSelection(e){const{sketch:t}=this;t&&(t.updateOnGraphicClick=e,t.cancel())}async transformAndPlotReferencePointOnImage(e){const{feature:t,selectedLocation:a,options:i}=e;let r=!1,s=!1;const o=this.bestFeatureFootprint?.geometry;switch(o?.type){case"polygon":{const e=a.spatialReference.equals(o.spatialReference)?a:await B(a,o.spatialReference);r=o.contains(e);break}case"mesh":{const e=a.spatialReference.equals(o.spatialReference)?a:await B(a,o.spatialReference);s=o.extent.contains(e);break}}if(!r&&!s)return void this.clearReferencePointOnImage();const n=await this.worldToImage(a,t,i);if(n)return v(i),this.plotReferencePointOnImage(n),{x:n.x,y:n.y};this.clearReferencePointOnImage()}async triangulatedLocationWorkflow(e,t){if(this.currentBestFeature&&e){const{currentBestFeature:a}=this;this.triangulatedPoint&&(this.measurementVectors=[],this.triangulatedPoint=null,this.clearLocationPointOnImage(!0));const i=Ue(e,a);if(!i)return;this.measurementVectors.push(i),await this.plotReferenceLocationPoint(e,t),v(t),this._createTriangularImageLocationHandle()}}async updateFeatureCache(e,t){const a=await q(e,t);a.features?.length&&(this.featureCache=a.features)}async _calculateTriangulatedPointFromGroundPoint(e,t){if(this.currentBestFeatureMeasurementImage&&e){const{currentBestFeatureMeasurementImage:a,view:i}=this,r=Ue(e,a);r&&this.measurementVectors.push(r);let s=await Ne(this.measurementVectors);v(t),s?.spatialReference&&i?.spatialReference&&!s.spatialReference.equals(i.spatialReference)&&(s=await B(s,i.spatialReference)),this.triangulatedPoint=s??this.triangulatedPoint}}async _fetchFeatures(e,t){if(!this.view)return;const a=this.layer;if(a){const i={include:a},r=this.view.toScreen(e);if(!r)return;const s=await this.view.hitTest(r,i);return this._processHitTestResults(a,s,t)}}async _fetchFeaturesWithController(e,t){try{await this._fetchFeatures(e,t)}catch(a){if(y(a))return;this.setMessage("imageLoadError","error"),u.getLogger(this).error("error occurred while fetching features",a)}}_groupFeaturesBySectors(){const{_suitabilities:e,additionalFeatures:t,features:a,invalidCameraHeading:i}=this,r=a.at(0);if(!e||!t||!r||!a||i)return void(this._sectorData=null);this._sectorData={};const o={};this._featureToSector=o;for(const h of Ae)this._sectorData[h]=new s;const n=e.map((e,t)=>({...e,featureIndex:t}));n.sort((e,t)=>e.trueSuitability-t.trueSuitability);const c=n.map(({distance:e})=>e),l=Math.max(...c);n.forEach(e=>{const{distance:t,angle:i,featureIndex:s}=e,n=t/l*Le[2],c=ht(t,l),h=lt(i);if(!this._sectorData)return;const u=Le[3]+n*Math.sin(i*Math.PI/180),d=Le[3]+n*Math.cos(i*Math.PI/180);let m;const p=a.at(s),g=p===r,{cameraPitch:y}=p.attributes,v=y<5;if(g&&v)m=-90;else{const e=u-Le[3],t=d-Le[3],a=t/Math.sqrt(e**2+t**2);let i=180*Math.acos(a)/Math.PI;(e<0&&t<0||e<0&&t>0)&&(i*=-1),m=i}const w=""===c?h:`${c}_${h}`;g&&(m===this.bestFeatureAngle?this.previousFeatureAngle=m:this.bestFeatureAngle=m,this.navigatorCurrentBestFeature=v?null:{x:u,y:d,direction:h}),o[`${p.attributes.objectId}`]=w;const f=this._sectorData[w];f.add({angle:i,featureIndex:s,x:u,y:d,objectID:p.attributes.objectId,sector:w,featureIndexInSector:f.length})})}_handleDestroyedTriangularSketchLayer(){this.sketchTriangularGraphicsLayer&&this.activeTriangulatedViewer&&(this.activeTriangulatedViewer.imageRenderer.map.layers.remove(this.sketchTriangularGraphicsLayer),this.sketchTriangularGraphicsLayer=new U,this.activeTriangulatedViewer.imageRenderer.map.layers.add(this.sketchTriangularGraphicsLayer),this.sketchTriangular&&(this.sketchTriangular.layer=this.sketchTriangularGraphicsLayer,this.sketchTriangular.view=this.activeTriangulatedViewer.imageRenderer))}_initializeMeasurementService(){this._measurementService||(this._measurementService=new Ft(this))}_initializeSketchTriangular(){if(!this.activeTriangulatedViewer)return;const e="panoramic"===this.mode;this.sketchTriangular=new _t({view:this.activeTriangulatedViewer.imageRenderer,layer:this.sketchTriangularGraphicsLayer,updateOnGraphicClick:!1,defaultUpdateOptions:{toggleToolOnClick:!1,enableZ:!e}}),e&&(this.sketchTriangular.defaultUpdateOptions.reshapeOptions={edgeOperation:"offset",shapeOperation:"move-xy",vertexOperation:"move-xy"})}_initializeSketchTriangularGraphicsLayer(){this.activeTriangulatedViewer&&(this.sketchTriangularGraphicsLayer=new U,this.activeTriangulatedViewer.imageRenderer.map.layers.add(this.sketchTriangularGraphicsLayer))}_initializeVideo(){if(this.videoElement||!this.currentBestFeature)return;this.removeHandles(bt.videoPlayerHandles),this.videoElement=new fe({video:this.currentBestFeature.attributes.imagePath,georeference:new ve({extent:new L(Ce)}),autoplay:!1}),this.videoElement.content?.loop&&(this.videoElement.content.loop=!1);const e=new N({source:this.videoElement,title:this.layer?.title,copyright:this.layer?.copyright});this.videoLayer=e,e&&this.videoMapView.map.layers.add(e),this.addHandles(mt(this.videoMapView),bt.videoPlayerHandles),this.videoViewModel=new yt({oiViewModel:this})}_plotLocationPointOnDefaultImage(e,a=!1){const i=A(e)?e.toJSON():e;i.x-=.5,i.y=.5-i.y,a?(this._correctedLocationPointOnImage=new t({geometry:new T({spatialReference:x.WebMercator,...i}),symbol:et}),this.imageMeasurementViewer.addGraphic(this._correctedLocationPointOnImage,0)):(this._locationPointOnImage=new t({geometry:new T({spatialReference:x.WebMercator,...i}),symbol:et}),this._imageViewer.addGraphic(this._locationPointOnImage,0))}_plotLocationPointOnPanoramicImage(e,a=!1){const i=a?this._panoramicMeasurementViewer:this._panoramicViewer,{imageSize:r}=i;if(!r)return;const[s,o]=r,{heading:n,pitch:c}=ne(e,s,o),l=ce(n,c),h=new t({geometry:new T(l,x.WebMercator),symbol:tt});a?this._correctedLocationPointOnImage=h:this._locationPointOnImage=h,i.addGraphic(h,0)}_clearFeatureGeometries(){this.coveragePolygons.removeAll(),this.coverageFrustums.removeAll(),this.pointSources.removeAll()}_checkFeatures(e){return!!e?.length||(this.setMessage("noImageError","error"),this.videoElement?.content?.pause(),this.currentBestFeature=null,!1)}async _getElevationSampleFromGround(e,t,a){if(!e[0])return;const i=await G(e);if(this._updateFootprintWithFeatures(t,i),"3d"===this.view?.type)try{return await this.view.map.ground.createElevationSampler(this.footprintExtent,a)}catch(r){y(r)||u.getLogger(this).error(r)}}async processElevationSample(e,t,a){const{elevationSource:i}=t[0].attributes,r=await this._getElevationSampleFromGround(e,t,a);return r||(i&&this.footprintExtent&&X(i)?await re({extent:this.footprintExtent,lod:i.lod,url:i.url,rasterFunction:i.rasterFunction}):void 0)}_processSuitableFeatures(e,t){return $({features:e,selectedPoint:t,camera:ut(this.view)?this.view.camera:null,currentImage:this.currentBestFeature})}async _processHitTestResults(e,t,a){const{screenPoint:i,results:[r]}=t,s="graphic"===r?.type&&this.shouldShowSelectedImage,o=r?.mapPoint??this.view?.toMap(i);if(!o)return;o.x=D(o.x,o.spatialReference);const{layerFloorFilterClause:n}=this,c=e.spatialReference.equals(o.spatialReference)?o:await B(o,e.spatialReference),l=c.spatialReference.isGeographic?z(c):c,h=P("1=1",P(e.definitionExpression,n)),u=l.spatialReference.isGeographic?1:V(l.spatialReference),d={layerInstanceOrURL:e,point:l,queryParams:{where:h,maximumDistance:e.maximumDistance?e.maximumDistance/u:void 0,objectIds:s?[r.graphic.getAttribute(e.objectIdField)]:void 0}};await this.searchBestImage(d,a)}async _queryAndLoadByObjectId(e,t,a,i){this.displayMessage=null;const{response:r}=await ft(e,t,a,i);if(v(i),!r?.features?.length)throw new wt(t);const s=J(r.features[0].attributes).polygon,o=T.fromJSON(H(s)),n=ee(o),c=V(n.spatialReference);this.selectedPoint=n;const l={layerInstanceOrURL:e,point:n,queryParams:{where:P(P("1=1",P(e.definitionExpression,a)),`${e.objectIdField} <> ${t}`),maximumDistance:e.maximumDistance?e.maximumDistance/c:void 0}},h=await W(l,i);v(i);const{features:u}=h;return u.push(r.features[0]),await this.processFeatureResponse(h,n,{...i,loadBestImage:!1})}_reorderTriangularSketchLayer(){const e=this.imageMeasurementViewer.imageRenderer.map.layers?.length;this.sketchTriangularGraphicsLayer&&e&&this.imageMeasurementViewer.imageRenderer.map.layers.reorder(this.sketchTriangularGraphicsLayer,e-1)}_resetCursor(){const{activeViewer:e,imageMeasurementViewer:t}=this;e&&this.removeHandles(bt.activeViewerCursorHandles),t&&this.removeHandles(bt.imageViewerCursorHandles)}async _setImageSource(e,t,a,i,r,s){e.imageSource={datasetFormat:t.toUpperCase(),url:a.split("?")[0]},e.customParameters=Object.fromEntries(i),e.imageRotation=r??0,await e.loadImage(s)}_setMeasurementCursor(){const{activeViewer:e,imageMeasurementViewer:t,triangularMeasurementActive:a}=this;e&&this.addHandles(e.imageRenderer.acquireCursor("crosshair","high"),bt.activeViewerCursorHandles),t&&a&&this.addHandles(t.imageRenderer.acquireCursor("crosshair","high"),bt.activeViewerCursorHandles)}_toggleVisiblity(e,t){e.forEach(e=>{e.visible=t})}async _updateElevationOfSelectedPointAndLocations(e,t,a,i){const{location:r,cameraHeight:s}=e[0].attributes,o=await he(r.spatialReference,r.z,s,{elevationSample:a,elevationSource:a?void 0:e[0].attributes.elevationSource,extent:this.footprintExtent},i);v(i);const[n,...c]=await ie([t,...e.map(e=>e.attributes.geometry.clone())],o);v(i),t.elevation=n.z,e.forEach((e,t)=>{e.attributes.elevation=c[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:a}=e,{isSpherical:i,cameraHeading:r,cameraPitch:s}=a;return new gt({geometry:t,attributes:a,currentHeading:i?0:r,currentPitch:i?0:s})})),e.length>1?this.additionalFeatures.addMany(e.slice(1)):this.additionalFeatures.removeAll(),this._updateGroundElevation=!0,t&&(this.currentBestFeature=e[0]),"video"===this.mode&&(this._initializeVideo(),this.videoElement?.loaded&&this.videoViewModel?.playVideoFromSelectedLocation(e[0])),"panoramic-video"===this.mode&&this._loadVideo()}_updateFootprintWithFeatures(e,t){const a=[];for(const{attributes:{geometry:i}}of e)t.contains(i)||a.push([i.x,i.y]);a.sort((e,t)=>+E([e,t])),t.addRing(a),this.footprintExtent=be(t.extent,2,2)}async _updatePointsAndPolygons(e){const{pointSources:a,currentBestFeature:i,currentCoverageVisible:r,isAdditionalPointSourcesVisible:s,mode:o,layer:n}=this;if(i&&(this.additionalFootprints.removeAll(),this.additionalCameraLocations.removeAll(),this.bestFeatureCurrentFootprint&&(this.bestFeatureCurrentFootprint.destroy(),this.bestFeatureCurrentFootprint=null,this.bestFeatureFootprint=null),!this.invalidCameraHeading)){await(this._adapter?.createFootprints(e)),v(e);for(const o of a){const a=this.view&&!this.view.spatialReference?.equals(o.spatialReference)?await B(o.clone(),this.view?.spatialReference,e):o.clone();o.imageID===i.attributes.objectId?this.currentBestFeatureLocation=new t({attributes:{imageID:o.imageID},geometry:a,symbol:at,visible:r}):this.additionalCameraLocations.push(new t({attributes:{imageID:o.imageID},geometry:a,symbol:it,visible:s}))}"video"!==o&&"panoramic-video"!==o||!n||this.featureCache.length||await this.updateFeatureCache(n,i.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 a;if(t)a=-90;else{const t=e.x-Le[3],i=e.y-Le[3],r=i/Math.sqrt(t**2+i**2);let s=180*Math.acos(r)/Math.PI;(t<0&&i<0||t<0&&i>0)&&(s*=-1),a=s}a===this.bestFeatureAngle?this.previousFeatureAngle=a:this.bestFeatureAngle=a,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._referencePointOnImage=p(this._referencePointOnImage))}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))}plotReferencePoint(e){"mapPoint"in e?this.plotReferencePointOnGround(e.mapPoint):this.plotReferencePointOnGround(e)}async plotReferenceLocationPoint(e,t){if(this.currentBestFeatureMeasurementImage){const a=await this.worldToImage(e,this.currentBestFeatureMeasurementImage,{signal:t});v(t),a&&this.plotLocationPointOnImage(a,!0)}}setMessage(e,t,a,i){this.displayMessage={key:e,type:t,data:a,map:i}}async transformAndPlotSelectedLocation(e){const{currentBestFeature:t,invalidCameraHeading:a,selectedPoint:i,activeViewer:r}=this;if(this._crossSymbol&&(this._panoramicViewer.removeGraphic(this._crossSymbol),this._imageViewer.removeGraphic(this._crossSymbol),this._crossSymbol=p(this._crossSymbol)),!i||!t||"image-loaded"!==r?.state||a)return;let s;try{s=await this.worldToImage(i,t,e),v(e),await this.plotSelectedPointOnImage(s,e)}catch(o){y(o)||u.getLogger(this).error("failed to transform map point to pixel, cross symbol will not be plotted on image",{error:o,selectedPoint:i,feature:t})}}async worldToImage(e,t,a){const{footprintExtent:i}=this,{imageSize:r}=this.activeViewer;if("none"===this.mode||!t||!r||!i)return;const{attributes:{location:s,elevationSource:o,cameraHeading:n,cameraHeight:c},elevationSample:l}=t;let h=s.clone();const u=await he(s.spatialReference,s.z??0,c,{elevationSample:l,elevationSource:o});t.elevationSample=u.elevationSample;const d=Array.isArray(e)?e:[e];let m,p=await Promise.all(d.map(e=>new Promise(t=>{if(!e.hasZ)return t(ie(e,u));t(e)})));if(s.spatialReference.isGeographic&&(h=await B(h,x.WebMercator,a)),p=await Promise.all(p.map(async e=>h.spatialReference.equals(e.spatialReference)?e:await B(e,h.spatialReference,a))),v(a),"panoramic"===this.mode)m=ye(p,{imageHeight:r[1],imageWidth:r[0],cameraHeading:n,cameraLocation:h});else{const e=pe(t.attributes,r[0],r[1]);m=ge(p,{...e,cameraLocation:h})}return Array.isArray(e)?m:m[0]}updateCurrentCoveragePolygon(e){const{additionalFootprints:a,additionalCameraLocations:i,currentBestFeature:r,currentBestFeatureLocation:s,currentCoverageVisible:o,selectedPoint:n,view:c,_adapter:l,mode:h}=this;if(!r)return;const{attributes:{objectId:u},elevationSample:d}=r;if(this._initialCurrentCoverageUpdate){if(this._overlays?.removeAll(),this._initialCurrentCoverageUpdate=!1,this.bestFeatureCurrentFootprint=p(this.bestFeatureCurrentFootprint),e&&!this.invalidCameraHeading&&(e.visible=o,this.bestFeatureCurrentFootprint=e),c){const e=[...a,...i,s].filter(dt);"3d"===c?.type&&d&&l?.updateGroundElevation&&(this._updateGroundElevation&&l.updateGroundElevation(e),"panoramic"===h&&l.updateGroundElevation([this.bestFeatureCurrentFootprint])),this._updateGroundElevation=!1,n&&(e.splice(-2,0,this.bestFeatureCurrentFootprint),e.push(new t({geometry:n.clone(),symbol:We.clone(),attributes:{imageID:u}}))),this._overlays.graphics.addMany(e)}}else if(c){if(this.invalidCameraHeading)return;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"===c?.type&&d&&l?.updateGroundElevation&&"panoramic"===h&&l.updateGroundElevation([e]),e.visible=this.currentCoverageVisible,this._overlays?.graphics.add(this.bestFeatureCurrentFootprint,t>=0?t:this._overlays.graphics.length-1))}}};e([S()],St.prototype,"activeLayer",null),e([S({readOnly:!0})],St.prototype,"activeViewer",null),e([S()],St.prototype,"activeTriangulatedViewer",null),e([S()],St.prototype,"accuracyParametersMissing",null),e([S()],St.prototype,"additionalFeatures",void 0),e([S({type:s.ofType(t)})],St.prototype,"additionalCameraLocations",void 0),e([S({type:s.ofType(t)})],St.prototype,"additionalFootprints",void 0),e([S()],St.prototype,"areaMeasurementResult",void 0),e([S()],St.prototype,"areaMeasurementAccuracy",void 0),e([S()],St.prototype,"bestFeatureAngle",void 0),e([S()],St.prototype,"bestFeatureCurrentFootprint",void 0),e([S({type:t})],St.prototype,"bestFeatureFootprint",void 0),e([S({type:Number})],St.prototype,"brightness",null),e([S()],St.prototype,"cameraHeadingThreshold",void 0),e([S()],St.prototype,"cameraPitchThreshold",void 0),e([S()],St.prototype,"clickAction",void 0),e([S()],St.prototype,"videoViewModel",void 0),e([S()],St.prototype,"collectionId",void 0),e([S({type:Number})],St.prototype,"contrast",null),e([S()],St.prototype,"conversionProps",void 0),e([S()],St.prototype,"coverageFrustums",void 0),e([S()],St.prototype,"coveragePolygons",void 0),e([S()],St.prototype,"currentBestFeature",void 0),e([S()],St.prototype,"currentBestFeatureMeasurementImage",void 0),e([S()],St.prototype,"currentBestFeatureLocation",void 0),e([S()],St.prototype,"currentCoverageVisible",void 0),e([S()],St.prototype,"currentNode",null),e([S()],St.prototype,"depthImage",void 0),e([S()],St.prototype,"depthImageNotSupported",null),e([S()],St.prototype,"directionMode",void 0),e([S()],St.prototype,"featureCache",void 0),e([S()],St.prototype,"navigationNodes",void 0),e([S({json:{write:!1}})],St.prototype,"determineWorkflowForFeature",void 0),e([S({json:{write:!1}})],St.prototype,"determineWorkflowForTriangularMeasurement",void 0),e([S()],St.prototype,"disabled",void 0),e([S()],St.prototype,"displayMessage",void 0),e([S()],St.prototype,"displayNewMeasurementButton",void 0),e([S()],St.prototype,"distanceMeasurementResult",void 0),e([S()],St.prototype,"distanceAccuracyArray",void 0),e([S()],St.prototype,"dataCaptureLayer",void 0),e([S({readOnly:!0})],St.prototype,"featureCount",null),e([S()],St.prototype,"features",void 0),e([S()],St.prototype,"groundCoordinates",void 0),e([S()],St.prototype,"groundCoordinatesAccuracy",void 0),e([S()],St.prototype,"heightMeasurementPixels",void 0),e([S()],St.prototype,"heightGraphic",void 0),e([S()],St.prototype,"heightMeasurementResult",void 0),e([S()],St.prototype,"heightMeasurementAccuracy",void 0),e([S()],St.prototype,"measurementAngle",void 0),e([S()],St.prototype,"tempDistance",void 0),e([S({readOnly:!0})],St.prototype,"imageGalleryEnabled",null),e([S()],St.prototype,"imageGeometryField",void 0),e([S({readOnly:!0})],St.prototype,"imageLoaded",null),e([S()],St.prototype,"imageLocationToolState",void 0),e([S({readOnly:!0})],St.prototype,"invalidCameraHeading",null),e([S()],St.prototype,"imagePointsInView",null),e([S()],St.prototype,"imageMeasurementViewer",void 0),e([S()],St.prototype,"isAdditionalCoverageVisible",void 0),e([S()],St.prototype,"isAdditionalPointSourcesVisible",void 0),e([S()],St.prototype,"measurementVectors",void 0),e([S()],St.prototype,"layer",void 0),e([S()],St.prototype,"layerView",null),e([S({readOnly:!0})],St.prototype,"layerFloorFilterClause",null),e([S({type:Number})],St.prototype,"localPort",void 0),e([S()],St.prototype,"mapImageConversionToolState",void 0),e([S()],St.prototype,"measureType",void 0),e([S()],St.prototype,"measurementGraphic",void 0),e([S({readOnly:!0,value:"none"})],St.prototype,"mode",null),e([S()],St.prototype,"navigationMode",void 0),e([S()],St.prototype,"navigatorCurrentBestFeature",void 0),e([S()],St.prototype,"oiObjectIdField",void 0),e([S({type:s.ofType(t)})],St.prototype,"overlayedCameraLocations",void 0),e([S()],St.prototype,"overlayedMapFeatures",void 0),e([S()],St.prototype,"panoramicVideoLoaded",null),e([S()],St.prototype,"pixelCoordinates",void 0),e([S()],St.prototype,"preserveAngle",void 0),e([S()],St.prototype,"pointSources",void 0),e([S({readOnly:!0})],St.prototype,"popupEnabled",null),e([S()],St.prototype,"previousFeatureAngle",void 0),e([S()],St.prototype,"referencePoint",null),e([S({readOnly:!0})],St.prototype,"sectorData",null),e([S()],St.prototype,"selectedPoint",void 0),e([S({type:Number})],St.prototype,"sharpness",null),e([S()],St.prototype,"shouldShowSelectedImage",void 0),e([S()],St.prototype,"sketch",void 0),e([S()],St.prototype,"sketchTriangular",void 0),e([S()],St.prototype,"sketchTriangularGraphicsLayer",void 0),e([S()],St.prototype,"draw",void 0),e([S()],St.prototype,"sketchAdapter",void 0),e([S({readOnly:!0})],St.prototype,"sketchGraphicsLayer",null),e([S({readOnly:!0})],St.prototype,"state",null),e([S({readOnly:!0})],St.prototype,"thumbnails",null),e([S()],St.prototype,"triangularMeasurementActive",void 0),e([S()],St.prototype,"triangulatedDistanceMeasurement",void 0),e([S()],St.prototype,"triangulatedDistanceAccuracy",void 0),e([S()],St.prototype,"triangulatedAreaMeasurement",void 0),e([S()],St.prototype,"triangulatedAreaAccuracy",void 0),e([S()],St.prototype,"triangulatedMeasurementGraphic",void 0),e([S()],St.prototype,"triangulatedPoint",void 0),e([S()],St.prototype,"triangulatedMeasurementAdapter",void 0),e([S()],St.prototype,"updateFootprint",void 0),e([S()],St.prototype,"updateFootprintPanorama",void 0),e([S()],St.prototype,"updatingTriangularMeasurementState",void 0),e([S({value:null})],St.prototype,"view",null),e([S()],St.prototype,"videoElement",void 0),e([S()],St.prototype,"videoLayer",void 0),e([S()],St.prototype,"videoMapView",void 0),e([S()],St.prototype,"_adapter",void 0),e([S()],St.prototype,"_defaultGraphicsLayer",null),e([S()],St.prototype,"_highlightedFeatureHandle",void 0),e([S()],St.prototype,"_imageViewer",void 0),e([S()],St.prototype,"_initialCurrentCoverageUpdate",void 0),e([S()],St.prototype,"_locationPointOnImage",void 0),e([S()],St.prototype,"_measurementService",void 0),e([S()],St.prototype,"_correctedLocationPointOnImage",void 0),e([S()],St.prototype,"_overlays",void 0),e([S({readOnly:!0})],St.prototype,"_overlaysView",null),e([S()],St.prototype,"_panoramicVideoViewer",void 0),e([S()],St.prototype,"_panoramicViewer",void 0),e([S()],St.prototype,"_panoramicMeasurementViewer",void 0),e([S()],St.prototype,"_referencePointOnGround",void 0),e([S()],St.prototype,"_referencePointOnImage",void 0),e([S()],St.prototype,"_sectorData",void 0),e([S()],St.prototype,"_featureToSector",void 0),e([S({readOnly:!0})],St.prototype,"_updatingHandles",void 0),e([S()],St.prototype,"footprintExtent",void 0),e([S()],St.prototype,"_featureChangedTask",void 0),St=e([k("esri.widgets.OrientedImageryViewer.OrientedImageryViewerViewModel")],St);const kt=St;export{kt as default};
5
+ import{__decorate as e}from"tslib";import t from"../../Graphic.js";import{equals as a,isSome as i}from"../../core/arrayUtils.js";import{createTask as r}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 c}from"../../core/Evented.js";import{makeHandle as l}from"../../core/handleUtils.js";import{equalsShallow as h}from"../../core/lang.js";import u from"../../core/Logger.js";import{clamp as d}from"../../core/mathUtils.js";import{abortMaybe as m,destroyMaybe as p}from"../../core/maybe.js";import{EsriPromise as g}from"../../core/Promise.js";import{isAbortError as y,throwIfAborted as v,waitTick as w}from"../../core/promiseUtils.js";import f from"../../core/ReactiveMap.js";import{whenOnce as F,on as _,watch as b,syncAndInitial as M,initial as I}from"../../core/reactiveUtils.js";import{sqlAnd as P}from"../../core/sql.js";import{getMetersPerUnitForSR as V}from"../../core/units.js";import{property as S,subclass as k}from"../../core/accessorSupport/decorators.js";import{isSerializable as C}from"../../core/support/jsonUtils.js";import{UpdatingHandles as A}from"../../core/support/UpdatingHandles.js";import L from"../../geometry/Extent.js";import G from"../../geometry/Multipoint.js";import R from"../../geometry/Point.js";import O from"../../geometry/Polygon.js";import T from"../../geometry/Polyline.js";import{projectWithZConversion as j}from"../../geometry/projectionUtils.js";import B from"../../geometry/SpatialReference.js";import{polygonCentroidPoint as x}from"../../geometry/support/centroid.js";import{isClockwise as H}from"../../geometry/support/coordsUtils.js";import{normalizeMapX as E}from"../../geometry/support/normalizeUtils.js";import{geographicToWebMercator as D}from"../../geometry/support/webMercatorUtils.js";import z from"../../layers/GraphicsLayer.js";import U from"../../layers/MediaLayer.js";import{searchImages as N,getSortedLayerFeatures as W}from"../../layers/orientedImagery/queries.js";import{calculateSuitabilities as q}from"../../layers/orientedImagery/core/bestImageUtils.js";import{createCoveragePolygon as $,computePolygonForInspection as J,resizePolygon as Z,checkIfPolygonContainsSelectedPoint as K}from"../../layers/orientedImagery/core/coverageUtils.js";import{isElevationSource as Q}from"../../layers/orientedImagery/core/ElevationSourceDefinitions.js";import{getMetersPerUnitOfSR as X,convertGeographicToWebMercator as Y}from"../../layers/orientedImagery/core/utils.js";import{imageToWorld as ee,imageToWorldPanoramic as te}from"../../layers/orientedImagery/transformations/imageToWorld.js";import ae from"../../layers/orientedImagery/transformations/updateElevation.js";import{getElevationSampler as ie}from"../../layers/orientedImagery/transformations/updateElevationUtils.js";import{or as re,getInitialAngle as se,convertPixelToHeadingPitch as oe,convertHeadingPitchToSphereVertex as ne,getImageToWorldProperties as ce,getUpdateElevationProps as le,getImageToWorldPanoramicProperties as he,pointToArray as ue,transformGraphicCoordinatesToPixel as de,getWorldToImageProperties as me}from"../../layers/orientedImagery/transformations/utils.js";import{worldToImage as pe,worldToImagePanoramic as ge}from"../../layers/orientedImagery/transformations/worldToImage.js";import ye from"../../layers/support/ExtentAndRotationGeoreference.js";import{getFloorFilterClause as ve}from"../../layers/support/floorFilterUtils.js";import we from"../../layers/support/VideoElement.js";import fe from"../../views/MapView.js";import Fe from"../../views/draw/Draw.js";import{scale as _e}from"../../views/draw/support/drawUtils.js";import{ViewEventPriorities as be}from"../../views/input/InputManager.js";import Me from"../PanoramicVideoViewer.js";import Ie from"../PanoramicViewer.js";import{defaultAngleThresholdInDegrees as Pe,videoExtent as Ve,invalidCameraHeading as Se,sectorsInOrder as ke,sampleExtent as Ce,sectorsRadii as Ae}from"./constants.js";import{configureSketchTool as Le,extractFieldsFromDataCaptureLayer as Ge,isValidDataCaptureLayer as Re,constructGraphicFromImageGeometry as Oe}from"./dataCaptureUtils.js";import{isFeatureAttachment as Te,getImageSourceFromAttachment as je}from"./galleryUtils.js";import{getModeCorrectedPoint as Be,calculateCorrectedPixel as xe,getUnitRateFromSpatialReference as He,calculateHeightFromTemporaryDistance as Ee,getModeCorrectedPoints as De,computeTriangulatedVector as ze,computeTriangulatedPoint as Ue}from"./imageMeasurementUtils.js";import{crossSymbol as Ne,crossSymbol3D as We,measurementPolygonSymbol as qe,polylineSymbolPanoramic as $e,measurementPolylineSymbol as Je,cameraOverlaySymbol3D as Ze,cameraOverlaySymbol as Ke,diamondSymbol as Qe,diamondSymbol3D as Xe,locationSymbol as Ye,locationSymbol3D as et,activeSourcePointSymbol as tt,sourcePointSymbol as at}from"./symbols.js";import{isNoAttachmentError as it,getContentType as rt,isTifOrMrf as st,filterOILLayerView as ot,assignElevationSampleToFeatures as nt,calculateDirection as ct,calculateSegment as lt,isSceneView as ht,isGraphic as ut}from"./utils.js";import{disableVideoZoomAndPan as dt}from"./videoViewerUtils.js";import mt from"./components/ImageViewer.js";import pt from"./components/NavigationNode.js";import gt from"./components/OrientedImageryVideoViewModel.js";import{NoActiveViewerError as yt,NoFeatureFoundWithObjectIdError as vt}from"./navigation/errors.js";import{queryFeatureByObjectIds as wt}from"./navigation/queries.js";import{ImageMeasurementService as ft}from"./services/ImageMeasurementService.js";import Ft from"../Sketch/SketchViewModel.js";const _t={click:"view-click",imageClick:"image-click",triangularImageClick:"triangular-click",interactionHandles:"interaction-handles",hittestHandles:"hittest-handles",videoPlayerHandles:"video-handles",activeViewerCursorHandles:"active-viewer-cursor-handles",imageViewerCursorHandles:"image-viewer-cursor-handles"},bt=new Set(["JPG","JPEG","TIFF","TIF","MRF"]),Mt=new Set(["MRF","TIFF","TIF"]),It=/\.(\w+)$/,Pt=()=>new n("orientedimageryviewer:sketch-not-initialized","Sketch property is not initialized, call loadSketch first");let Vt=class extends(c(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=Pe,this.cameraPitchThreshold=Pe,this.clickAction="hittest",this.videoViewModel=null,this.collectionId=null,this.conversionProps=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.directionMode="Relative",this.featureCache=[],this.navigationNodes=new s,this.determineWorkflowForFeature=async(e,t,a)=>{const{currentBestFeature:i,selectedPoint:r,view:s}=this;if(s?.closePopup(),i&&r){this._initialCurrentCoverageUpdate=!0,this._updateGroundElevation=!0;try{await this._updatePointsAndPolygons(a),await this._loadDepthImage(a),await this._loadImage(a)}catch(o){y(o)||(this.loadImageError(o),u.getLogger(this).error("#loadIImage()","error occured while loading image",o))}}},this.determineWorkflowForTriangularMeasurement=async(e,t,a)=>{if(this.view?.closePopup(),this.currentBestFeatureMeasurementImage&&this.selectedPoint)try{await this._loadMeasurementViewerImage(a)}catch(i){y(i)||(this.loadImageError(i),u.getLogger(this).error("#loadIImage()","error occured while loading image",i))}},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.heightMeasurementPixels=[],this.heightGraphic=null,this.heightMeasurementResult=0,this.heightMeasurementAccuracy=0,this.measurementAngle=null,this.tempDistance=null,this.imageGeometryField=null,this.imageLocationToolState=!1,this.imageMeasurementViewer=new mt,this.isAdditionalCoverageVisible=!1,this.isAdditionalPointSourcesVisible=!1,this.measurementVectors=[],this.layer=null,this.localPort=null,this.mapImageConversionToolState=!1,this.measureType=null,this.measurementGraphic=null,this.navigatorCurrentBestFeature=null,this.oiObjectIdField=null,this.overlayedCameraLocations=new s,this.overlayedMapFeatures=new f,this.pixelCoordinates=null,this.preserveAngle="none",this.pointSources=new s,this.previousFeatureAngle=0,this.selectedPoint=null,this.shouldShowSelectedImage=!1,this.sketch=null,this.sketchTriangular=null,this.sketchTriangularGraphicsLayer=null,this.draw=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,a)=>{"default"===this.mode&&"image-loaded"!==this.state||this.mode.includes("video")&&!this.videoElement?.content||await(this._adapter?.updateFootprint(e,t,a))},this.updateFootprintPanorama=async(e,t)=>{await(this._adapter?.updateFootprintPanorama(e,t))},this.updatingTriangularMeasurementState=!1,this.videoElement=null,this.videoLayer=null,this.videoMapView=new fe({map:new Map}),this._adapter=null,this._highlightedFeatureHandle=null,this._imageViewer=new mt,this._initialCurrentCoverageUpdate=!0,this._locationPointOnImage=null,this._measurementService=null,this._correctedLocationPointOnImage=null,this._overlays=new z({listMode:"hide",internal:!0,elevationInfo:{mode:"absolute-height"},title:"OrentedImageryViewerViewModel overlays layer"}),this._panoramicVideoViewer=new Me,this._panoramicViewer=new Ie,this._panoramicMeasurementViewer=new Ie,this._referencePointOnGround=null,this._referencePointOnImage=null,this._sectorData=null,this._featureToSector=null,this._updatingHandles=new A,this._clickTask=null,this._crossSymbol=null,this.footprintExtent=null,this._featureChangedTask=null,this._openPopupTask=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,a=this.layer?.imageReferenceField;if(!t||!e||!a)return;const i=this.overlayedMapFeatures.get(e);i?.forEach(e=>{const i=e.attributes??{},r=Object.keys(i).find(e=>e.toLowerCase()===a.toLowerCase());(r?i[r]: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:a}=await t;return v(e),this.sketchAdapter=new a({viewModel:this}),this.sketchAdapter},this.loadImageFromSource=async(e,t)=>this._updatingHandles.addPromise(this._loadImageFromSourceInternal(e,t)),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 a=this.additionalFeatures.find(({attributes:t})=>t.objectId===e);if(a)this.currentBestFeature=a;else{const{layer:a,layerFloorFilterClause:r}=this;if(!a)return void this.setMessage("noLayerSelected","info");this.beforeLoad();const s=this._updatingHandles.addPromise(this._queryAndLoadByObjectId(a,e,r,t));try{await s,await this.selectBestFeature(e,t)}catch(i){y(i)||(u.getLogger(this).error("oriented-imagery-viewer:show-image",i),"NoFeatureFoundWithObjectIdError"===i.name?this.setMessage("noFeatureFoundWithObjectId","error","",{objectId:e}):this.setMessage("imageLoadError","error",i.message))}}},this.imageToImageTransform=async(e,t,a)=>{const{updateElevationProps:i,...r}=t,{updateElevationProps:s,...o}=a,n=await ee(e,r,i);return pe(n,o)},this.imageToImageTransformPanoramic=async(e,t,a)=>{const{updateElevationProps:i,...r}=t,{updateElevationProps:s,...o}=a,n=await te(e,r,i);return ge(n,o)},this.getSectorFeatureById=e=>this._suitabilities?.find(({feature:{attributes:{objectId:t}}})=>t===e),this.getFeatureSectorById=e=>this._featureToSector?.[`${e}`],this.navigate=async(e,t)=>{const{activeViewer:a}=this;if(!a)throw new yt;return await a.navigate(e,t)},this.removeHighlight=()=>this._highlightedFeatureHandle?.remove(),this.revealImageGeometry=e=>{},this.selectBestFeature=async(e,t)=>(v(t),this.currentBestFeature=this.features?.find(({attributes:t})=>`${t.objectId}`==`${e}`),F(()=>"image-loaded"===this.state,t)),this.toggleImageAttributes=()=>{m(this._openPopupTask),this._openPopupTask=r(async e=>{const{currentBestFeature:a,popupEnabled:i,layer:r,view:s}=this;if(s?.closePopup(),!(s&&a&&i&&r))return;const{attributes:o,geometry:n}=a,c=new t({geometry:n,attributes:o.toJSON(),layer:r,sourceLayer:r});v(e),await s.openPopup({features:[c],location:o.location.clone()})})},this.updateSuitabilities=(e,t=!0)=>{e.sort((e,t)=>e.suitability-t.suitability),this._suitabilities=e;const a=this._suitabilities.map(({feature:e})=>e);this._initialCurrentCoverageUpdate=!0,this._updateFeatures(a,t),this._groupFeaturesBySectors()},this._createViewClickHandle=()=>{if(this.removeHandles(_t.click),this.disabled||null==this.view)return;const e=this.mapImageConversionToolState&&"image-loaded"===this.state?this._mapImageConversionToolViewClickHandler:this._viewClickHandler;this.addHandles(this.view.on("click",e,be.WIDGET),_t.click)},this._createImageClickHandle=()=>{this.removeHandles(_t.imageClick);const{mapImageConversionToolState:e,mode:t,activeViewer:a,currentBestFeature:i,footprintExtent:s}=this,o=a?.imageSize;if(!(e&&"none"!==t&&o&&s&&i))return;const n=a.clickAction;this.clickAction="pixel-location";const c=l(()=>{this.clickAction=n});let h=null;const u=_(()=>a,"pixel-location",e=>{this.plotReferencePointOnImage(e),h?.abort(),h=r(async a=>{if(!e)return;const r=await this.getMapPoint(e,{feature:i,imageSize:o,mode:t}).then(e=>{const t=this.view?.spatialReference;return re(!t,e.spatialReference.equals(t))?e:j(e,t)});v(a),this.plotReferencePointOnGround(r)})});this.addHandles([u,c],_t.imageClick)},this._createTriangularImageClickHandle=()=>{this.removeHandles(_t.triangularImageClick),this.triangularMeasurementActive&&"none"!==this.mode&&this.currentBestFeature&&this.currentBestFeatureMeasurementImage&&this.activeTriangulatedViewer&&this.addHandles(this.activeTriangulatedViewer.imageRenderer.on("double-click",this._measurementImageClickHandler),_t.triangularImageClick)},this._createTriangularImageLocationHandle=()=>{this.removeHandles(_t.triangularImageClick);const{imageLocationToolState:e,mode:t,activeTriangulatedViewer:a}=this,i=a?.imageSize;if(!e||"none"===t||!i)return;this.clickAction="pixel-location";let s=null;const o=_(()=>a,"pixel-location",e=>{1===this.measurementVectors.length&&(this.plotLocationPointOnImage(e,!0),s?.abort(),s=r(async a=>{if(!e||this.triangulatedPoint||2===this.measurementVectors?.length||!this.currentBestFeatureMeasurementImage)return;let r=await this.getMapPoint(e,{feature:this.currentBestFeatureMeasurementImage,imageSize:i,mode:t});v(a);const s=this.view?.spatialReference;s&&!r.spatialReference.equals(s)&&(r=await j(r,s),v(a)),await this._calculateTriangulatedPointFromGroundPoint(r,{signal:a}),v(a)}))});this.addHandles(o,_t.triangularImageClick)},this._createImageLocationHandle=()=>{this.removeHandles(_t.imageClick);const{imageLocationToolState:e,mode:t,activeViewer:a,currentBestFeature:i,footprintExtent:s}=this,o=a?.imageSize;if(!(e&&"none"!==t&&o&&s&&i))return;this.clickAction="pixel-location";let n=null;const c=_(()=>a,"pixel-location",e=>{const{currentBestFeatureMeasurementImage:a,triangularMeasurementActive:s,activeTriangulatedViewer:c}=this;this.pixelCoordinates=e;const l=null!=a&&!c?.state.includes("loading");re(!s,l)&&this.plotLocationPointOnImage(e),n?.abort(),n=r(async a=>{if(!e)return;let r=await this.getMapPoint(e,{feature:i,imageSize:o,mode:t});v(a);const n=this.view?.spatialReference;n&&!r.spatialReference.equals(n)&&(r=await j(r,n),v(a)),this.groundCoordinates=r,s&&r&&l&&await this.triangulatedLocationWorkflow(r,a);const c=await this.calculateLocationAccuracy(e,r,t,a);v(a),c&&(this.groundCoordinatesAccuracy=c)})});this.addHandles(c,_t.imageClick)},this._handleImageHitTestResponse=async e=>{const{layer:t,overlayedCameraLocations:a}=this;if(!t)return;const i=e.results.find(({graphic:e,graphic:{attributes:i}})=>a.includes(e)&&i&&!i[t.imageReferenceField]&&!i[t.imageGeometryField]);if(!i)return;const r=i.graphic.attributes[t.objectIdField];await this.showImageByObjectId(r)},this._loadDepthImage=async e=>{const{currentBestFeature:t,layer:a,depthImageNotSupported:i}=this;if(this.depthImage?.destroy(),this.depthImage=null,!a||!t||i)return;const{depthImage:r}=t.attributes;if(!r)return;const s=(await import("./services/DepthImageService.js")).default;v(e),this.depthImage=new s({url:r});try{await this.depthImage.load(e)}catch(o){y(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:a,mode:i}=this;if(this.clearGraphics(),!a||!t||"none"===i||"video"===i||"panoramic-video"===i)return;const{attributes:r}=t,{imagePath:s,imageRotation:o,cameraHeading:n,cameraRoll:c,cameraPitch:l,objectId:h,cameraOrientation:d,location:m}=r,p=(c??0)+(o??0),g=m.spatialReference.isWGS84&&4!==d?.type?D(m):new R(m);let w=s;if(Te(s))try{w=await je(a,h,e)}catch(f){if(y(f))return;return it(f)?(u.getLogger(this).error(f),void this.setMessage("noAttachment","error",`${a.objectIdField}: ${h}`)):(u.getLogger(this).error(f,{[a.objectIdField]:h,layer:a}),void this.setMessage("imageLoadError","error",`query-attachments-failed:${a.objectIdField} ${h}`))}try{await this.loadImageFromSource(w,{imageRotation:p,options:e,pitch:l,yaw:n,mode:i,cameraLocation:g}),v(e),await this.transformAndPlotSelectedLocation(e)}catch(f){y(f)||this.loadImageError(f)}},this._loadVideo=async e=>{const{currentBestFeature:t,layer:a,mode:i,selectedPoint:r}=this,s=t?.attributes.imagePath;if(!a||!t||"panoramic-video"!==i||!s)return;const{attributes:o}=t,{cameraHeading:n,cameraPitch:c,cameraOrientation:l,location:h}=o,u=h.spatialReference.isWGS84&&4!==l?.type?D(h):new R(h);try{this._panoramicVideoViewer.viewModel.video&&this._panoramicVideoViewer.viewModel.video.pause(),this._panoramicVideoViewer.videoSource=s;let t=n??0;u&&r&&(t=await se(u,r)-t),this._panoramicVideoViewer.pitch=c??0,this._panoramicVideoViewer.yaw=t,await this._panoramicVideoViewer.loadVideo(e),v(e)}catch(d){y(d)||this.loadImageError(d)}},this._loadImageFromSourceInternal=async(e,t)=>{const{mode:a,imageRotation:i,options:r}=t,s="string"==typeof e,o=s?e:e.url,{pathname:n,searchParams:c}=new URL(o);let l=s?n.match(It)?.[1]:e.datasetFormat;if(!l)try{l=await rt(o,{...t.options})}catch(h){y(h)||u.getLogger(this).error("#getContentType()",h)}switch(l??="UNKNOWN FORMAT",a){case"default":this.triangularMeasurementActive?await this._setImageSource(this.imageMeasurementViewer,l,o,c,i,r):await this._setImageSource(this._imageViewer,l,o,c,i,r);break;case"panoramic":if(bt.has(l.toUpperCase())){const{selectedPoint:e}=this,{pitch:a,yaw:i,cameraLocation:s,viewAngle:n}=t,c=this.triangularMeasurementActive?this._panoramicMeasurementViewer:this._panoramicViewer;let h=i??0;"number"==typeof n?h=n-h:s&&e&&(h=await se(s,e)-h),c.imageSource=o,c.pitch=a??0,c.yaw=h,Mt.has(l.toUpperCase())?await c.loadImageTiled(o,r):await c.loadImage(r)}else this.setMessage("unsupportedPanoramicImageryError","error",void 0,{datasetFormat:l});break}},this._loadMeasurementViewerImage=async e=>{const{currentBestFeatureMeasurementImage:t,layer:a,mode:i}=this;if(this.imageMeasurementViewer.clearGraphics(),this._panoramicMeasurementViewer.clearGraphics(),!a||!t||"none"===i||"video"===i||"panoramic-video"===i)return;const{attributes:r}=t,{imagePath:s,imageRotation:o,cameraHeading:n,cameraRoll:c,cameraPitch:l,objectId:h,cameraOrientation:d,location:m}=r,p=(c??0)+(o??0),g=m.spatialReference.isWGS84&&4!==d?.type?D(m):new R(m);let w=s;if(Te(s))try{w=await je(a,h,e)}catch(f){if(y(f))return;return it(f)?(u.getLogger(this).error(f),void this.setMessage("noAttachment","error",`${a.objectIdField}: ${h}`)):(u.getLogger(this).error(f,{[a.objectIdField]:h,layer:a}),void this.setMessage("imageLoadError","error",`query-attachments-failed:${a.objectIdField} ${h}`))}try{await this.loadImageFromSource(w,{imageRotation:p,options:e,pitch:l,yaw:n,mode:i,cameraLocation:g}),v(e)}catch(f){y(f)||this.loadImageError(f)}},this._loadViewAdapter=async e=>{const{view:t}=this;if(t)switch(t.type){case"2d":{const{default:t}=await import("./adapters/view/MapViewAdapter.js");v(e),this._adapter=new t(this);break}case"3d":{const{default:t}=await import("./adapters/view/SceneViewAdapter.js");v(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=E(t.x,t.spatialReference),this.plotMapPoint(e.mapPoint)}},this._measurementImageClickHandler=e=>{e.stopPropagation(),e.preventDefault();const{sketchTriangular:t,triangularMeasurementActive:a,currentBestFeatureMeasurementImage:i,triangulatedMeasurementGraphic:r}=this;t&&a&&i&&r&&"active"!==t.state&&(t.update([r],{tool:"reshape"}),this.updatingTriangularMeasurementState=!0)},this._viewClickHandler=e=>{this._clickTask?.abort(),this._clickTask=r(async t=>{const{pointerType:a,button:i,mapPoint:r}=e;if(("mouse"!==a||0===i)&&r)return e.stopPropagation(),e.preventDefault(),this._updatingHandles.addPromise(this.loadBestImage(r,{signal:t}))})},this.plotSelectedPointOnImage=async(e,a)=>{if(await w(a),!e)return;const i=new R({...C(e)?e.toJSON():e});if("default"===this.mode)i.x-=.5,i.y=.5-i.y,i.spatialReference=this._imageViewer.imageRenderer.spatialReference.clone(),this._crossSymbol=new t({geometry:i,symbol:Ne}),this._imageViewer.addGraphic(this._crossSymbol,0);else if("panoramic"===this.mode){const{imageSize:a}=this._panoramicViewer;if(!a)return;const[i,r]=a,{heading:s,pitch:o}=oe(e,i,r),n=ne(s,o);this._crossSymbol=new t({geometry:new R(n,B.WebMercator),symbol:We}),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)},I),b(()=>this.view?.map?.allLayers?.length,e=>{e&&this.view?.map?.layers.reorder(this._overlays,e-1)},I),b(()=>[this.state,this.mapImageConversionToolState,this.view,this.disabled],()=>{this._createViewClickHandle(),this._createImageClickHandle()},M),b(()=>[this.triangularMeasurementActive,this.currentBestFeatureMeasurementImage],()=>{this._createTriangularImageClickHandle()},M),b(()=>[this.state,this.imageLocationToolState,this.view],(e,t)=>{if(this._initializeMeasurementService(),this._createImageLocationHandle(),!this.imageLocationToolState)return this.clearPreviousGroundLocation(),void this._resetCursor();e[1]!==t?.[1]&&this._setMeasurementCursor()},M),b(()=>this.measureType,()=>{this.clearPreviousMeasurements(),this._initializeMeasurementService()},M),b(()=>this.bestFeatureAngle,(e,t)=>{this.previousFeatureAngle=t??0},M),b(()=>this.currentBestFeature,async(e,t)=>{m(this._featureChangedTask),this._featureChangedTask=r(async a=>this.determineWorkflowForFeature.apply(this,[e,t,{signal:a}])),await this._featureChangedTask.promise},{sync:!0}),b(()=>this.currentBestFeatureMeasurementImage,(e,t)=>{m(this._featureChangedTask),t&&e!==t&&(this.measurementVectors=[],this.triangulatedPoint=null,this.sketchTriangularGraphicsLayer?.graphics.destroyAll()),this._featureChangedTask=r(async a=>{await this.determineWorkflowForTriangularMeasurement(e,t,{signal:a}),v(a),this._reorderTriangularSketchLayer()})},M),b(()=>this.triangularMeasurementActive,(e,t)=>{t&&!e&&(this.measurementVectors=[],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(_t.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=r(async t=>{await this.updateFootprint(e,void 0,{signal:t})}))},{...M,equals:(e,t)=>a(e,t,h)}),_t.interactionHandles);break;case"video":this.addHandles(b(()=>{const{footprintExtent:e,videoElement:t,bestFeatureFootprint:a}=this;if(e&&t?.loaded&&a)return{videoExtent:Ve,bestFeatureFootprint:a}},e=>{e?.videoExtent&&e?.bestFeatureFootprint&&(m(this._updateFootprintTask),this._updateFootprintTask=r(async t=>{await this.updateFootprint(e.videoExtent,void 0,{signal:t})}))},{...M,equals:(e,t)=>a(e?.videoExtent,t?.videoExtent,h)&&e?.bestFeatureFootprint===t?.bestFeatureFootprint}),_t.interactionHandles);break;case"panoramic":this.addHandles(b(()=>{const{currentBestFeature:e,state:t,_panoramicViewer:a}=this,{imageSize:i,vfov:r,hfov:s,pitch:o,yaw:n}=a;return e&&i&&!t.includes("loading")&&null!=r&&null!=s&&null!=o&&null!=n?[r,s,n,o]:null},e=>{if(!e||this.state.includes("loading"))return;const[t,a,i,s]=e;this.currentNode&&(this.currentNode.currentHeading=i+(this.currentNode.heading??0),this.currentNode.currentPitch=s+(this.currentNode.pitch??0)),m(this._updateFootprintTask),this._updateFootprintTask=r(async e=>{await this.updateFootprintPanorama({verticalFieldOfView:t,horizontalFieldOfView:a,yaw:i,pitch:s},{signal:e}),this._updateFootprintTask=null})},{equals:(e,t)=>a(e,t,h)}),_t.interactionHandles);break;case"panoramic-video":this.addHandles(b(()=>{const{currentBestFeature:e,state:t,_panoramicVideoViewer:a}=this,{imageSize:i,vfov:r,hfov:s,pitch:o,yaw:n,viewModel:c}=a,l=c.closestFeature??e;return l&&i&&!t.includes("loading")&&null!=r&&null!=s&&null!=o&&null!=n?[r,s,n,o,l]:null},e=>{if(!e)return;const[t,a,i,s,o]=e;m(this._updateFootprintTask),this._updateFootprintTask=r(async e=>{await this.updateFootprintPanorama({verticalFieldOfView:t,horizontalFieldOfView:a,yaw:i,pitch:s,feature:o},{signal:e}),v(e),this._updateFootprintTask=null})},{equals:(e,t)=>a(e,t,h)}),_t.interactionHandles)}},M),b(()=>[this.brightness,this.contrast,this.sharpness],()=>{const{_imageViewer:e,brightness:t,contrast:a,mode:i,sharpness:r}=this;"default"===i&&(e.brightness=t,e.contrast=a,e.sharpness=r)},M),b(()=>this.activeViewer?.imageRenderer,()=>{this.sketch&&(this.sketch.view=this.activeViewer?.imageRenderer)}),b(()=>this.activeViewer,e=>{this.removeHandles(_t.hittestHandles),e&&this.addHandles(_(()=>e,"hittest-response",this._handleImageHitTestResponse),_t.hittestHandles)})]),this.when().finally(()=>{this.notifyChange("state")})}destroy(){this.currentBestFeature=null,this._updateFootprintTask=m(this._updateFootprintTask),this._clickTask=m(this._clickTask),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._crossSymbol=p(this._crossSymbol),this._referencePointOnGround=p(this._referencePointOnGround),this._referencePointOnImage=p(this._referencePointOnImage),this._locationPointOnImage=p(this._locationPointOnImage),this._overlays&&this.view?.map?.remove(this._overlays),this._overlays.destroy(),this._imageViewer.destroy(),this.imageMeasurementViewer.destroy(),this._panoramicViewer.destroy(),this._panoramicMeasurementViewer.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:a}=this;switch(a){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",d(e,-10,10))}get contrast(){return this._get("contrast")??0}set contrast(e){this._set("contrast",d(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!st(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 st(t)||Te(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===Se}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(ot(e))}get layerFloorFilterClause(){const{layerView:e}=this;return e?ve(e):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:a,isSpherical:i}=e;return 360===a||i?"panoramic":"default"}get panoramicVideoLoaded(){const{mode:e,_panoramicVideoViewer:t}=this,{videoLoaded:a}=t.viewModel;return("panoramic-video"===e&&!0===a)??!1}get popupEnabled(){return!0===this.layer?.popupEnabled}get referencePoint(){return this._referencePointOnGround?.geometry}get sectorData(){const{_sectorData:e}=this;return e?ke.map(t=>e[t]):null}get sharpness(){return this._get("sharpness")??0}set sharpness(e){this._set("sharpness",d(e,0,1))}get sketchGraphicsLayer(){const{sketch:e}=this;return"graphics"===e?.layer?.type?e.layer:void 0}get state(){const{mode:e,_updatingHandles:{updating:t},_featureChangedTask:a}=this;if(!this.isFulfilled()||t||!1===a?.finished)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:a,imageRotation:i}})=>{const r=e?.trim();return st(r)||Te(r)?{url:r,objectId:t,rotation:(a??0)+(i??0)}:null}).filter(i)):null}set view(e){this._set("view",e)}get _defaultGraphicsLayer(){const e={blendMode:"source-atop"};switch(this.mode){case"panoramic":return new z({...e,elevationInfo:{mode:"absolute-height"}});case"default":return new z({...e});default:return}}get _overlaysView(){return this.view?.layerViews.find(({layer:e})=>e===this._overlays)}beforeLoad(e=!0){this.view?.closePopup(),e&&(this.displayMessage=null),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._overlays?.removeAll()}async computeHeight(e,t,a=!0){return this._measurementService?.computeHeight(e,t,a)}async calculateAreaMeasurement(e,t,a){return this._measurementService?.calculateAreaMeasurement(e,t,a)}async calculateDistanceMeasurement(e,t,a){return this._measurementService?.calculateDistanceMeasurement(e,t,a)}async calculateAccuracy(e,t,a){return this._measurementService?.calculateAccuracy(e,t,a)}async calculateLocationAccuracy(e,t,a="default",i){return this._measurementService?.calculateLocationAccuracy(e,t,a,i)}async calculateAccuracyPanoramic(e,t,a=!1,i){return this._measurementService?.calculateAccuracyPanoramic(e,t,a,i)}async calculateHeightMeasurementInfo(e,t,a){return this._measurementService?.calculateHeightMeasurementInfo(e,t,a)}async calculateTriangulatedMeasurements(e){await(this._measurementService?.calculateTriangulatedMeasurements(e))}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:a,dataCaptureLayer:i}=this;if(!a)throw Pt();Le(i,e,a),await a.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)}async displayHeightResults(){const{currentBestFeature:e,activeViewer:t,heightMeasurementPixels:a,mode:i}=this,r=t?.imageSize,s=e?.attributes;if(!s||!r)return;const o=await this.computeHeight(a,i);o?.value&&o?.accuracy&&(this.heightMeasurementResult=o.value,this.heightMeasurementAccuracy=o.accuracy)}filterByFootprints(e,t,a=!1){const i=[],r=[],s=[];return e.forEach(e=>{const{layer:{coveragePercent:o},attributes:n}=e;let c;const{polygon:l,frustum:h}=$(n);if(c=l.clone(),n.isInspection&&(c=J(n)),o&&(c=Z(c,o)),a||!t||K(c,t)){s.push(e);const{geometry:t,objectId:a,cameraHeight:o,cameraHeading:c}=n,u=t.clone();u.z=o/X(t.spatialReference),u.imageID=a,this.pointSources.push(u),c!==Se&&(i.push(l),h&&r.push(h))}}),{features:s,polygons:i,frustums:r}}getMeasurementProperties(e=this.currentBestFeature,t=this.activeViewer){if(!e||!t?.imageSize)return;const{elevationSample:a,attributes:i}=e,{elevationSource:r,cameraHeight:s}=i,o=ce(i,t.imageSize[0],t.imageSize[1]);let n=o.cameraLocation;return(n.spatialReference.isGeographic?j(n,B.WebMercator):Promise.resolve(n)).then(e=>(n=e,le(n.spatialReference,n.z??0,s,{elevationSample:a,elevationSource:r,extent:this.footprintExtent}))).then(t=>("elevationSample"in t&&(e.elevationSample=t.elevationSample),{...o,cameraLocation:n,updateElevationProps:t}))}getMeasurementPropertiesPanoramic(e=this.currentBestFeature,t=this.activeViewer){if(!e||!t?.imageSize)return;const{elevationSample:a,attributes:i}=e,{elevationSource:r,cameraHeight:s}=i,o=he(i,t.imageSize[0],t.imageSize[1]);let n=o.cameraLocation;return(n.spatialReference.isGeographic?j(n,B.WebMercator):Promise.resolve(n)).then(e=>(n=e,le(n.spatialReference,n.z??0,s,{elevationSample:a,elevationSource:r,extent:this.footprintExtent}))).then(t=>("elevationSample"in t&&(e.elevationSample=t.elevationSample),{...o,cameraLocation:n,updateElevationProps:t}))}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}).then(({features:e})=>t.applyEdits({deleteFeatures:e}))}handleSectorClick(e){if(isNaN(e))return;const t=this._sectorData?.[ke[e]],a=t?.at(0);a&&(this.triangularMeasurementActive&&this.currentBestFeature?this._updateImageMeasurementBestFeature(a):this._updateCurrentBestFeature(a))}handleFeatureClick(e){const{sector:t,featureIndexInSector:a}=e;if(isNaN(a))return;const i=this._sectorData?.[t],r=i?.at(a);r&&(this.triangularMeasurementActive&&this.currentBestFeature?this._updateImageMeasurementBestFeature(r):this._updateCurrentBestFeature(r))}handleDrawCursorUpdateEvents(e){const{measurementAngle:t,tempDistance:a,heightMeasurementPixels:i,mode:r,activeViewer:s,currentBestFeature:o}=this,n=s?.imageSize;if(!e.vertices||!n||!o)return;const c=Be(e.vertices.at(-1),r,n);if(i.length<1||!c||!a||!t||"none"===r)return;const l=xe(i[0],c,t);if(!l?.length)return;this.heightMeasurementPixels.push(l),"panoramic"===r?this.createPolylineGraphicPano():this.createPolylineGraphic();const h=He(o.attributes.location.spatialReference),u=Ee(this.heightMeasurementPixels,a,h);u&&(this.heightMeasurementResult=u)}async handleDrawVertexAddEvents(e,t){const{currentBestFeature:a,activeViewer:i,heightMeasurementPixels:r,mode:s}=this;if(!a||!i||!e.vertices?.length||"none"===s)return;const o=i?.imageSize;if(!r.length&&o){const a=Be(e.vertices.at(-1),s,o);this.heightMeasurementPixels.push(a);const i=await this.calculateHeightMeasurementInfo(a,s,t);if(!i?.measurementAngle||!i?.tempDistance)return;this.measurementAngle=i.measurementAngle,this.tempDistance=i.tempDistance}}load(e){return this.addResolvingPromise(this._loadViewAdapter(e).catch(e=>{if(!y(e))throw e})),this}async loadBestImage(e,t){return this.selectedPoint=Y(e),this.beforeLoad(),this._fetchFeaturesWithController(e,t)}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:a}=await t;v(e),this.sketch=new a({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:a}=await t;if(v(e),this.sketchAdapter=new a({viewModel:this}),!this.sketchAdapter.viewModel.isResolved())return}return this.sketchAdapter}async loadTriangulatedMeasurementAdapter(e){if(!this.triangulatedMeasurementAdapter){const t=import("./adapters/sketch/TriangulatedMeasurementAdapter.js"),{default:a}=await t;if(v(e),this.triangulatedMeasurementAdapter=new a({viewModel:this}),!this.triangulatedMeasurementAdapter.viewModel.isResolved())return}return this.triangulatedMeasurementAdapter}async processFeatureResponse(e,t,a){const{features:i}=e;if(this._clearFeatureGeometries(),!this._checkFeatures(i))return;const{features:r,polygons:s,frustums:o}=this.filterByFootprints(i,t,a?.skipFilter);if(!this._checkFeatures(r))return;this.coveragePolygons.addMany(s),this.coverageFrustums.addMany(o);const n=await this.processElevationSample(s,r,a);v(a),await this._updateElevationOfSelectedPointAndLocations(r,t,n),v(a),nt(r,n);const c=this._processSuitableFeatures(r,t);this.updateSuitabilities(c,a?.loadBestImage)}async processFeatureElevation(e,t,a){if(!t)return;const{features:i,polygons:r}=this.filterByFootprints(e,t,!0);if(!i?.length)return;const s=await this.processElevationSample(r,i,a);return v(a),s}async startMeasurement(e,t){this.sketch||await this.loadSketch(t),await this.loadMeasurementAdapter(t);const{sketch:a,sketchAdapter:i,activeViewer:r,mode:s}=this;if(!a||!i||!r||"none"===s)return;if(this.displayNewMeasurementButton=!1,"panoramic"===s&&(a.defaultCreateOptions.defaultZ=0),await a.create(e),"panoramic"===s){const{drawOperation:e}=a.view.activeTool;e.constraintsEnabled=!1,e._set("elevationDrawSurface",null)}const o=this.activeViewer?.imageRenderer.effectiveTheme.accentColor;o&&this.sketch&&(this.sketch.polygonSymbol=qe(o),this.sketch.polylineSymbol="panoramic"===s?$e:Je(o,2.5))}startHeightMeasurement(){this.heightMeasurementPixels=[],this.displayNewMeasurementButton=!1,this.draw??=new Fe({view:this.activeViewer?.imageRenderer});this.draw.create("polyline").on(["cursor-update","vertex-add","draw-complete"],e=>this.handleDrawEvents(e))}createPolylineGraphic(){const e=[this.heightMeasurementPixels[0],this.heightMeasurementPixels.at(-1)],a=this.activeViewer?.imageRenderer.spatialReference;if(this.heightGraphic)this.heightGraphic.geometry=new T({paths:[e],spatialReference:a});else{const i=new T({paths:[e],spatialReference:a}),r=this.activeViewer?.imageRenderer.effectiveTheme.accentColor;this.heightGraphic=new t({geometry:i,symbol:Je(r,2.5)}),this.activeViewer?.addGraphic(this.heightGraphic)}}createPolylineGraphicPano(){const e=this.activeViewer?.imageRenderer.spatialReference,a=this.activeViewer?.imageSize;if(!a)return;const i={x:this.heightMeasurementPixels[0][0],y:this.heightMeasurementPixels[0][1]},r={x:this.heightMeasurementPixels.at(-1)[0],y:this.heightMeasurementPixels.at(-1)[1]},{heading:s,pitch:o}=oe(i,a[0],a[1]),{heading:n,pitch:c}=oe(r,a[0],a[1]),l=[[...ne(s,o)],[...ne(n,c)]];if(this.heightGraphic)this.heightGraphic.geometry=new T({paths:[l],spatialReference:e});else{const a=new T({paths:[l],spatialReference:e});this.heightGraphic=new t({geometry:a,symbol:$e}),this._panoramicViewer.addGraphic(this.heightGraphic,0)}}async editOverlayedGraphics(e){this.sketchTriangularGraphicsLayer||this._initializeSketchTriangularGraphicsLayer(),this.sketchTriangularGraphicsLayer?.destroyed&&this._handleDestroyedTriangularSketchLayer(),this.sketchTriangularGraphicsLayer.add(e),this.sketchTriangular||(this._initializeSketchTriangular(),await this.loadTriangulatedMeasurementAdapter()),this.updateOverlayedGeometry(e)}updateOverlayedGeometry(e){this.sketchTriangular?.update([e],{tool:"reshape"})}async processMeasurementVectors(e){this.triangularMeasurementActive&&this.currentBestFeature&&(this.measurementVectors?.length<2&&await this.updateMeasurementVectorsArray(e),2===this.measurementVectors.length&&await this.calculateTriangulatedMeasurements(e))}async updateMeasurementVectorsArray(e){const t=this.measurementVectors.length?this.currentBestFeatureMeasurementImage:this.currentBestFeature;if(t){const a=await this.computeMeasurementVector(e,t);a&&this.measurementVectors.push(a)}}async computeMeasurementVector(e,t){const{activeViewer:a,mode:i}=this,r=a?.imageSize;if(!e||!t||!r)return;const s=De(e,i,r),o=this.view?.spatialReference,n=[];for(let c=0;c<s.length;c++){const e={x:s[c][0],y:s[c][1]};let a=await this.getMapPoint(e,{feature:t,imageSize:r,mode:i});o&&!a.spatialReference.equals(o)&&(a=await j(a,o)),n.push(a)}return ze(n,t)}async handleDrawEvents(e,t){if(this.draw)switch(e.type){case"cursor-update":this.handleDrawCursorUpdateEvents(e);break;case"vertex-add":await this.handleDrawVertexAddEvents(e,t);break;case"draw-complete":await this.displayHeightResults()}}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:a,currentBestFeature:i,overlayedCameraLocations:r,layer:s,mode:o,state:n,layerFloorFilterClause:c}=this,l=a?.imageSize;if(!l||!i||!s||"none"===o||n.includes("loading"))return;const{polygon:h}=$(i.attributes);if(a.removeManyGraphics(r.toArray()),r.removeAll(),e){const{features:e}=await s.queryFeatures({where:P(`${s.objectIdField} <> ${i.attributes.objectId}`,P(s.definitionExpression,c)),geometry:h,returnGeometry:!0,outFields:[s.objectIdField]}),n=await Promise.all(e.map(async e=>{const{attributes:a,geometry:r}=e,s=await this.getPixels(r,{feature:i,imageSize:l,mode:o}),n="panoramic"===o?Ze():Ke();return new t({attributes:a,symbol:n,geometry:s})}));r.addMany(n),a.addManyGraphics(r.toArray())}}overlayGraphicsOnImage(e,t){this.removeOverlayedGraphicsOnImage(e),this.overlayedMapFeatures.set(e,t),this.activeViewer?.addManyGraphics(t.toArray())}async overlayMapFeatures(e,a=!1){const{activeViewer:r,currentBestFeature:o,mode:n,state:c,layer:l}=this,h=r?.imageSize;if(!h||!o||"none"===n||"video"===n||"panoramic-video"===n||c.includes("loading")||!l)return;const{polygon:d}=$(o.attributes);try{const{imageGeometryField:t,oiObjectIdField:a}=Ge(e,l.imageGeometryField,l.imageReferenceField);this.imageGeometryField=t.name,this.oiObjectIdField=a.name}catch(g){u.getLogger(this).warn("oriented-imagery-viewer:overlay-map-features",g)}const{features:m}=await e.queryFeatures({geometry:d,returnGeometry:!0,outFields:["*"]}),p=new s((await Promise.all(m.map(async i=>{const r=i.symbol?.clone()??e.renderer?.getSymbol(i)?.clone(),{attributes:s,geometry:c}=i,l=c,{imageGeometryField:d,oiObjectIdField:m}=this;if(d&&m&&Re(e,d,m)&&`${s[m]}`==`${o.attributes.objectId}`)try{return Oe(s,d,e,a,h,n,r)}catch(g){u.getLogger(this).warn("oriented-imagery-viewer:overlay-map-features","couldn't create graphic from attributes, geometry will be used",{error:g,feature:i,layer:e,imageGeometryField:this.imageGeometryField,imageReferenceField:this.oiObjectIdField})}switch(l?.type){case"point":{const i=await this.getPixels(l,{feature:o,imageSize:h,mode:n});return new t({attributes:s,layer:e,symbol:r,geometry:i,visible:e.visible&&a})}case"polygon":{const{rings:i,spatialReference:c}=l,u=i.map(e=>e.map(([e,t,a])=>new R({x:e,y:t,z:a,spatialReference:c}))),d=await Promise.all(u.map(async e=>this.getPixels(e,{feature:o,imageSize:h,mode:n}).then(e=>e.map(ue))));return new t({attributes:s,layer:e,symbol:r,geometry:new O({rings:d,spatialReference:B.WebMercator}),visible:e.visible&&a})}case"polyline":{const{paths:i,spatialReference:c}=l,u=i.map(e=>e.map(([e,t,a])=>new R({x:e,y:t,z:a,spatialReference:c}))),d=await Promise.all(u.map(async e=>this.getPixels(e,{feature:o,imageSize:h,mode:n}).then(e=>e.map(ue))));return new t({attributes:s,layer:e,symbol:r,geometry:new T({paths:d,spatialReference:B.WebMercator}),visible:e.visible&&a})}case"multipoint":{const{points:i,spatialReference:c}=l,u=i.map(([e,t,a])=>new R({x:e,y:t,z:a,spatialReference:c})),d=await this.getPixels(u,{feature:o,imageSize:h,mode:n}).then(e=>e.map(ue));return new t({attributes:s,layer:e,symbol:r,geometry:new G({points:d,spatialReference:B.WebMercator}),visible:e.visible&&a})}}return null}))).filter(i));this.overlayGraphicsOnImage(`${e.id}`,p)}getDepthAt(e){const{activeViewer:t,currentBestFeature:a,mode:i,state:r,depthImage:s}=this,o=t?.imageSize;if(!o||!a||"none"===i||r.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]}async getPixels(e,t){const{imageSize:a,mode:i,feature:r}=t,s=(await this.worldToImage(Array.isArray(e)?e:[e],r)).map(e=>{if("default"===i)return new R({x:e.x-.5,y:.5-e.y,spatialReference:B.WebMercator});const[t,r]=a,{heading:s,pitch:o}=oe(e,t,r),n=ne(s,o);return new R(n,B.WebMercator)});return Array.isArray(e)?s:s[0]}async getMapPoint(e,t){const{feature:a,mode:i,imageSize:r}=t,{elevationSample:s,attributes:o}=a,{elevationSource:n,location:c,cameraHeight:l}=o;let h=c.clone();h.spatialReference.isGeographic&&(h=await j(h,B.WebMercator));const u=await le(c.spatialReference,c.z??0,l,{elevationSample:s,elevationSource:n,extent:this.footprintExtent});let d;"elevationSample"in u&&(a.elevationSample=u.elevationSample);const m=Array.isArray(e)?e:[e];if(this.depthImage?.loaded)for(const p of m){const e=this.getDepthAt(p);null!=e&&(p.depth=e)}if("default"===i){const e=ce(o,r[0],r[1]);d=await ee(m,{...e,cameraLocation:h},u)}else{const e=he(o,r[0],r[1]);d=await te(m,{...e,cameraLocation:h},u)}return Array.isArray(e)?d:d[0]}getActiveSectors(){return ke.filter(e=>this._sectorData?.[e]?.length)}async plotMapPoint(e){return this.plotReferencePoint(e),this.transformAndPlotReferencePointOnImage({feature:this.currentBestFeature,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 R({...e.toJSON()}),symbol:Qe}),this.view?this._overlays?.add(this._referencePointOnGround):this.emit("plot-ground-point",{data:{point:this._referencePointOnGround?.geometry}}))}plotReferencePointOnImage(e){if("image-loaded"===this.state)switch(this.clearReferencePointOnImage(),this.mode){case"default":{const a=C(e)?e.toJSON():e;a.x-=.5,a.y=.5-a.y,this._referencePointOnImage=new t({geometry:new R({spatialReference:this._imageViewer.imageRenderer.spatialReference,...a}),symbol:Qe}),this._imageViewer.addGraphic(this._referencePointOnImage,0);break}case"panoramic":{const{imageSize:a}=this._panoramicViewer;if(!a)return;const[i,r]=a,{heading:s,pitch:o}=oe(e,i,r),n=ne(s,o);this._referencePointOnImage=new t({geometry:new R(n,B.WebMercator),symbol:Xe}),this._panoramicViewer.addGraphic(this._referencePointOnImage,0);break}}}plotLocationPointOnImage(e,t=!1){if("image-loaded"===this.state)switch(this.clearLocationPointOnImage(t),this.mode){case"default":this._plotLocationPointOnDefaultImage(e,t);break;case"panoramic":this._plotLocationPointOnPanoramicImage(e,t)}}removeAllOverlayMapFeatures(){this.overlayedMapFeatures.forEach(e=>{this._imageViewer.removeManyGraphics(e.toArray())}),this.overlayedMapFeatures.clear()}removeOverlayedGraphicsOnImage(e){const t=this.overlayedMapFeatures.get(e);t?.length&&(this.activeViewer?.removeManyGraphics(t.toArray()),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.heightMeasurementPixels=[],this.measurementVectors=[],this.heightMeasurementResult=0,this.tempDistance=null,this.measurementAngle=null,this.heightMeasurementAccuracy=0,this.heightGraphic=null,this.triangulatedDistanceMeasurement=null,this.triangulatedDistanceAccuracy=null,this.triangulatedAreaMeasurement=null,this.triangulatedMeasurementGraphic=null,this.updatingTriangularMeasurementState=!1,this.triangulatedAreaAccuracy=0}async saveDrawing(){const{dataCaptureLayer:e,sketchAdapter:t}=this;if(!e||"data-capture"!==t?.type)return;const{pendingGraphics:a,savedGraphics:i}=t,r=a.get(e.id),s=r?.toArray();if(!r||!s?.length)return;const{addFeatureResults:o}=await this.saveDataCaptureFeatures(s),n=o.reduce((t,{objectId:a,globalId:i,error:r},o)=>{const n=s[o],{attributes:c}=n;return r?t.error.push(n):(a&&(c[e.objectIdField]=a),i&&e.globalIdField&&(c[e.globalIdField]=i),t.success.push(n)),t},{success:[],error:[]});i.addMany(n.success),r.removeAll(),r.addMany(n.error)}async saveDataCaptureFeatures(e){const{activeViewer:t,currentBestFeature:a,dataCaptureLayer:r,mode:s}=this,o=t?.imageSize;if(!o||!a||"none"===s||"video"===s||"panoramic-video"===s)throw new n("orientedimageryviewer:missing-input","Image size, current best feature and mode are required to save data capture features");if(!r)throw new n("orientedimageryviewer:missing-featurelayer","Data capture layer is not available");const c=await Promise.all(e.map(async e=>{const t=e.clone(),{geometry:i}=t;if(!i)return;const n=i.type,c=r.hasZ,l=r.geometryType,h=n!==l,u=h?await import("./transformers.js"):null,d=u?.default[l],m=h?d?.(i):i;if(m)switch(m.type){case"point":return t.geometry=await this.getMapPoint(de(s,m,o),{feature:a,imageSize:o,mode:s}),c||(delete t.geometry.z,t.geometry.hasZ=!1),t.geometry.hasM=!1,t;case"polygon":{const e=await Promise.all(m.rings.map(async e=>this.getMapPoint(e.map(([e,t,a])=>de(s,{x:e,y:t,z:a},o)),{feature:a,imageSize:o,mode:s})));return t.geometry=new O({spatialReference:e[0][0].spatialReference,hasZ:c,hasM:!1,rings:e.map(e=>e.map(ue))}),t}case"polyline":{const e=await Promise.all(m.paths.map(async e=>this.getMapPoint(e.map(([e,t,a])=>de(s,{x:e,y:t,z:a},o)),{feature:a,imageSize:o,mode:s})));return t.geometry=new T({spatialReference:e[0][0].spatialReference,hasZ:c,hasM:!1,paths:e.map(e=>e.map(ue))}),t}}})),l=c.filter(i);return r.applyEdits({addFeatures:l}).then(e=>{const{addFeatureResults:t}=e;let a=0;const i=c.map(e=>{const i=t[a++];return e?i:{error:new n("orientedimageryviewer:save-unsucccessful","Error in saving data capture features"),objectId:null,globalId:null}});return{...e,addFeatureResults:i}})}async searchBestImage(e,t){try{const a=await N(e,t);a&&await this.processFeatureResponse(a,e.point,t)}catch(a){y(a)||(this.setMessage("imageLoadError","error",a.message),u.getLogger(this).error("error occurred while finding best image",a))}}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 a=this.activeViewer?.imageRenderer,{oiObjectIdField:i,currentBestFeature:r}=this;if(!a||!r||!i)return;const{attributes:{objectId:o}}=r,n=this.overlayedMapFeatures.get(e.id)?.toArray()??[],c=[],l=[];for(const s of n)`${s.getAttribute(i)}`==`${o}`?c.push(s):l.push(s);this.overlayGraphicsOnImage(e.id,new s(l)),this.collectionId=e.id;const h=await this.loadSketch(t),u=await this.loadDataCaptureAdapter(t);v(t),h.addGraphics(c),u.savedGraphics.addMany(c);a.ui.find("zoom").visible=!1,a.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,a=this.activeViewer?.imageRenderer;if(!a||a.destroyed)return;a.map.layers.remove(this.sketchGraphicsLayer),e&&t&&await this.overlayMapFeatures(t,!0);const i=a.ui.find("zoom");i&&(i.visible=!0)}stopMeasurement(){this.heightMeasurementPixels=[],this.draw?.reset(),this.sketch?.cancel()}toggleAllOverlayMapFeatures(e){this.overlayedMapFeatures.forEach(t=>{this._toggleVisiblity(t,e)})}toggleOverlayMapFeatures(e,t,a){const i=this.overlayedMapFeatures.get(e);i&&a&&this._toggleVisiblity(i,t)}toggleSelection(e){const{sketch:t}=this;t&&(t.updateOnGraphicClick=e,t.cancel())}async transformAndPlotReferencePointOnImage(e){const{feature:t,selectedLocation:a,options:i}=e;let r=!1,s=!1;const o=this.bestFeatureFootprint?.geometry;switch(o?.type){case"polygon":{const e=a.spatialReference.equals(o.spatialReference)?a:await j(a,o.spatialReference);r=o.contains(e);break}case"mesh":{const e=a.spatialReference.equals(o.spatialReference)?a:await j(a,o.spatialReference);s=o.extent.contains(e);break}}if(!r&&!s)return void this.clearReferencePointOnImage();const n=await this.worldToImage(a,t,i);if(n)return v(i),this.plotReferencePointOnImage(n),{x:n.x,y:n.y};this.clearReferencePointOnImage()}async triangulatedLocationWorkflow(e,t){if(this.currentBestFeature&&e){const{currentBestFeature:a}=this;this.triangulatedPoint&&(this.measurementVectors=[],this.triangulatedPoint=null,this.clearLocationPointOnImage(!0));const i=ze(e,a);if(!i)return;this.measurementVectors.push(i),await this.plotReferenceLocationPoint(e,t),v(t),this._createTriangularImageLocationHandle()}}async updateFeatureCache(e,t){const a=await W(e,t);a.features?.length&&(this.featureCache=a.features)}async _calculateTriangulatedPointFromGroundPoint(e,t){if(this.currentBestFeatureMeasurementImage&&e){const{currentBestFeatureMeasurementImage:a,view:i}=this,r=ze(e,a);r&&this.measurementVectors.push(r);let s=await Ue(this.measurementVectors);v(t),s?.spatialReference&&i?.spatialReference&&!s.spatialReference.equals(i.spatialReference)&&(s=await j(s,i.spatialReference)),this.triangulatedPoint=s??this.triangulatedPoint}}async _fetchFeatures(e,t){if(!this.view)return;const a=this.layer;if(a){const i={include:a},r=this.view.toScreen(e);if(!r)return;const s=await this.view.hitTest(r,i);return this._processHitTestResults(a,s,t)}}async _fetchFeaturesWithController(e,t){try{await this._fetchFeatures(e,t)}catch(a){if(y(a))return;this.setMessage("imageLoadError","error"),u.getLogger(this).error("error occurred while fetching features",a)}}_groupFeaturesBySectors(){const{_suitabilities:e,additionalFeatures:t,features:a,invalidCameraHeading:i}=this,r=a.at(0);if(!e||!t||!r||!a||i)return void(this._sectorData=null);this._sectorData={};const o={};this._featureToSector=o;for(const h of ke)this._sectorData[h]=new s;const n=e.map((e,t)=>({...e,featureIndex:t}));n.sort((e,t)=>e.trueSuitability-t.trueSuitability);const c=n.map(({distance:e})=>e),l=Math.max(...c);n.forEach(e=>{const{distance:t,angle:i,featureIndex:s}=e,n=t/l*Ae[2],c=lt(t,l),h=ct(i);if(!this._sectorData)return;const u=Ae[3]+n*Math.sin(i*Math.PI/180),d=Ae[3]+n*Math.cos(i*Math.PI/180);let m;const p=a.at(s),g=p===r,{cameraPitch:y}=p.attributes,v=y<5;if(g&&v)m=-90;else{const e=u-Ae[3],t=d-Ae[3],a=t/Math.sqrt(e**2+t**2);let i=180*Math.acos(a)/Math.PI;(e<0&&t<0||e<0&&t>0)&&(i*=-1),m=i}const w=""===c?h:`${c}_${h}`;g&&(m===this.bestFeatureAngle?this.previousFeatureAngle=m:this.bestFeatureAngle=m,this.navigatorCurrentBestFeature=v?null:{x:u,y:d,direction:h}),o[`${p.attributes.objectId}`]=w;const f=this._sectorData[w];f.add({angle:i,featureIndex:s,x:u,y:d,objectID:p.attributes.objectId,sector:w,featureIndexInSector:f.length})})}_handleDestroyedTriangularSketchLayer(){this.sketchTriangularGraphicsLayer&&this.activeTriangulatedViewer&&(this.activeTriangulatedViewer.imageRenderer.map.layers.remove(this.sketchTriangularGraphicsLayer),this.sketchTriangularGraphicsLayer=new z,this.activeTriangulatedViewer.imageRenderer.map.layers.add(this.sketchTriangularGraphicsLayer),this.sketchTriangular&&(this.sketchTriangular.layer=this.sketchTriangularGraphicsLayer,this.sketchTriangular.view=this.activeTriangulatedViewer.imageRenderer))}_initializeMeasurementService(){this._measurementService||(this._measurementService=new ft(this))}_initializeSketchTriangular(){if(!this.activeTriangulatedViewer)return;const e="panoramic"===this.mode;this.sketchTriangular=new Ft({view:this.activeTriangulatedViewer.imageRenderer,layer:this.sketchTriangularGraphicsLayer,updateOnGraphicClick:!1,defaultUpdateOptions:{toggleToolOnClick:!1,enableZ:!e}}),e&&(this.sketchTriangular.defaultUpdateOptions.reshapeOptions={edgeOperation:"offset",shapeOperation:"move-xy",vertexOperation:"move-xy"})}_initializeSketchTriangularGraphicsLayer(){this.activeTriangulatedViewer&&(this.sketchTriangularGraphicsLayer=new z,this.activeTriangulatedViewer.imageRenderer.map.layers.add(this.sketchTriangularGraphicsLayer))}_initializeVideo(){if(this.videoElement||!this.currentBestFeature)return;this.removeHandles(_t.videoPlayerHandles),this.videoElement=new we({video:this.currentBestFeature.attributes.imagePath,georeference:new ye({extent:new L(Ce)}),autoplay:!1}),this.videoElement.content?.loop&&(this.videoElement.content.loop=!1);const e=new U({source:this.videoElement,title:this.layer?.title,copyright:this.layer?.copyright});this.videoLayer=e,e&&this.videoMapView.map.layers.add(e),this.addHandles(dt(this.videoMapView),_t.videoPlayerHandles),this.videoViewModel=new gt({oiViewModel:this})}_plotLocationPointOnDefaultImage(e,a=!1){const i=C(e)?e.toJSON():e;i.x-=.5,i.y=.5-i.y,a?(this._correctedLocationPointOnImage=new t({geometry:new R({spatialReference:B.WebMercator,...i}),symbol:Ye}),this.imageMeasurementViewer.addGraphic(this._correctedLocationPointOnImage,0)):(this._locationPointOnImage=new t({geometry:new R({spatialReference:B.WebMercator,...i}),symbol:Ye}),this._imageViewer.addGraphic(this._locationPointOnImage,0))}_plotLocationPointOnPanoramicImage(e,a=!1){const i=a?this._panoramicMeasurementViewer:this._panoramicViewer,{imageSize:r}=i;if(!r)return;const[s,o]=r,{heading:n,pitch:c}=oe(e,s,o),l=ne(n,c),h=new t({geometry:new R(l,B.WebMercator),symbol:et});a?this._correctedLocationPointOnImage=h:this._locationPointOnImage=h,i.addGraphic(h,0)}_clearFeatureGeometries(){this.coveragePolygons.removeAll(),this.coverageFrustums.removeAll(),this.pointSources.removeAll()}_checkFeatures(e){return!!e?.length||(this.setMessage("noImageError","error"),this.videoElement?.content?.pause(),this.currentBestFeature=null,!1)}async _getElevationSampleFromGround(e,t,a){if(!e[0])return;const i=(await import("../../geometry/operators/unionOperator.js")).executeMany(e);if(this._updateFootprintWithFeatures(t,i),"3d"===this.view?.type)try{return await this.view.map.ground.createElevationSampler(this.footprintExtent,a)}catch(r){y(r)||u.getLogger(this).error(r)}}async processElevationSample(e,t,a){const{elevationSource:i}=t[0].attributes,r=await this._getElevationSampleFromGround(e,t,a);return r||(i&&this.footprintExtent&&Q(i)?await ie({extent:this.footprintExtent,lod:i.lod,url:i.url,rasterFunction:i.rasterFunction}):void 0)}_processSuitableFeatures(e,t){return q({features:e,selectedPoint:t,camera:ht(this.view)?this.view.camera:null,currentImage:this.currentBestFeature})}async _processHitTestResults(e,t,a){const{screenPoint:i,results:[r]}=t,s="graphic"===r?.type&&this.shouldShowSelectedImage,o=r?.mapPoint??this.view?.toMap(i);if(!o)return;o.x=E(o.x,o.spatialReference);const{layerFloorFilterClause:n}=this,c=e.spatialReference.equals(o.spatialReference)?o:await j(o,e.spatialReference),l=c.spatialReference.isGeographic?D(c):c,h=P("1=1",P(e.definitionExpression,n)),u=l.spatialReference.isGeographic?1:V(l.spatialReference),d={layerInstanceOrURL:e,point:l,queryParams:{where:h,maximumDistance:e.maximumDistance?e.maximumDistance/u:void 0,objectIds:s?[r.graphic.getAttribute(e.objectIdField)]:void 0}};await this.searchBestImage(d,a)}async _queryAndLoadByObjectId(e,t,a,i){this.displayMessage=null;const{response:r}=await wt(e,t,a,i);if(v(i),!r?.features?.length)throw new vt(t);const s=$(r.features[0].attributes).polygon,o=R.fromJSON(x(s)),n=Y(o),c=V(n.spatialReference);this.selectedPoint=n;const l={layerInstanceOrURL:e,point:n,queryParams:{where:P(P("1=1",P(e.definitionExpression,a)),`${e.objectIdField} <> ${t}`),maximumDistance:e.maximumDistance?e.maximumDistance/c:void 0}},h=await N(l,i);v(i);const{features:u}=h;return u.push(r.features[0]),await this.processFeatureResponse(h,n,{...i,loadBestImage:!1})}_reorderTriangularSketchLayer(){const e=this.imageMeasurementViewer.imageRenderer.map.layers?.length;this.sketchTriangularGraphicsLayer&&e&&this.imageMeasurementViewer.imageRenderer.map.layers.reorder(this.sketchTriangularGraphicsLayer,e-1)}_resetCursor(){const{activeViewer:e,imageMeasurementViewer:t}=this;e&&this.removeHandles(_t.activeViewerCursorHandles),t&&this.removeHandles(_t.imageViewerCursorHandles)}async _setImageSource(e,t,a,i,r,s){e.imageSource={datasetFormat:t.toUpperCase(),url:a.split("?")[0]},e.customParameters=Object.fromEntries(i),e.imageRotation=r??0,await e.loadImage(s)}_setMeasurementCursor(){const{activeViewer:e,imageMeasurementViewer:t,triangularMeasurementActive:a}=this;e&&this.addHandles(e.imageRenderer.acquireCursor("crosshair","high"),_t.activeViewerCursorHandles),t&&a&&this.addHandles(t.imageRenderer.acquireCursor("crosshair","high"),_t.activeViewerCursorHandles)}_toggleVisiblity(e,t){e.forEach(e=>{e.visible=t})}async _updateElevationOfSelectedPointAndLocations(e,t,a,i){const{location:r,cameraHeight:s}=e[0].attributes,o=await le(r.spatialReference,r.z,s,{elevationSample:a,elevationSource:a?void 0:e[0].attributes.elevationSource,extent:this.footprintExtent},i);v(i);const[n,...c]=await ae([t,...e.map(e=>e.attributes.geometry.clone())],o);v(i),t.elevation=n.z,e.forEach((e,t)=>{e.attributes.elevation=c[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:a}=e,{isSpherical:i,cameraHeading:r,cameraPitch:s}=a;return new pt({geometry:t,attributes:a,currentHeading:i?0:r,currentPitch:i?0:s})})),e.length>1?this.additionalFeatures.addMany(e.slice(1)):this.additionalFeatures.removeAll(),this._updateGroundElevation=!0,t&&(this.currentBestFeature=e[0]),"video"===this.mode&&(this._initializeVideo(),this.videoElement?.loaded&&this.videoViewModel?.playVideoFromSelectedLocation(e[0])),"panoramic-video"===this.mode&&this._loadVideo()}_updateFootprintWithFeatures(e,t){const a=[];for(const{attributes:{geometry:i}}of e)t.contains(i)||a.push([i.x,i.y]);a.sort((e,t)=>+H([e,t])),t.addRing(a),this.footprintExtent=_e(t.extent,2,2)}async _updatePointsAndPolygons(e){const{pointSources:a,currentBestFeature:i,currentCoverageVisible:r,isAdditionalPointSourcesVisible:s,mode:o,layer:n}=this;if(i&&(this.additionalFootprints.removeAll(),this.additionalCameraLocations.removeAll(),this.bestFeatureCurrentFootprint&&(this.bestFeatureCurrentFootprint.destroy(),this.bestFeatureCurrentFootprint=null,this.bestFeatureFootprint=null),!this.invalidCameraHeading)){await(this._adapter?.createFootprints(e)),v(e);for(const o of a){const a=this.view&&!this.view.spatialReference?.equals(o.spatialReference)?await j(o.clone(),this.view?.spatialReference,e):o.clone();o.imageID===i.attributes.objectId?this.currentBestFeatureLocation=new t({attributes:{imageID:o.imageID},geometry:a,symbol:tt,visible:r}):this.additionalCameraLocations.push(new t({attributes:{imageID:o.imageID},geometry:a,symbol:at,visible:s}))}"video"!==o&&"panoramic-video"!==o||!n||this.featureCache.length||await this.updateFeatureCache(n,i.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 a;if(t)a=-90;else{const t=e.x-Ae[3],i=e.y-Ae[3],r=i/Math.sqrt(t**2+i**2);let s=180*Math.acos(r)/Math.PI;(t<0&&i<0||t<0&&i>0)&&(s*=-1),a=s}a===this.bestFeatureAngle?this.previousFeatureAngle=a:this.bestFeatureAngle=a,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._referencePointOnImage=p(this._referencePointOnImage))}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))}plotReferencePoint(e){"mapPoint"in e?this.plotReferencePointOnGround(e.mapPoint):this.plotReferencePointOnGround(e)}async plotReferenceLocationPoint(e,t){if(this.currentBestFeatureMeasurementImage){const a=await this.worldToImage(e,this.currentBestFeatureMeasurementImage,{signal:t});v(t),a&&this.plotLocationPointOnImage(a,!0)}}setMessage(e,t,a,i){this.displayMessage={key:e,type:t,data:a,map:i}}async transformAndPlotSelectedLocation(e){const{currentBestFeature:t,invalidCameraHeading:a,selectedPoint:i,activeViewer:r}=this;if(this._crossSymbol&&(this._panoramicViewer.removeGraphic(this._crossSymbol),this._imageViewer.removeGraphic(this._crossSymbol),this._crossSymbol=p(this._crossSymbol)),!i||!t||"image-loaded"!==r?.state||a)return;let s;try{s=await this.worldToImage(i,t,e),v(e),await this.plotSelectedPointOnImage(s,e)}catch(o){y(o)||u.getLogger(this).error("failed to transform map point to pixel, cross symbol will not be plotted on image",{error:o,selectedPoint:i,feature:t})}}async worldToImage(e,t,a){const{footprintExtent:i}=this,{imageSize:r}=this.activeViewer;if("none"===this.mode||!t||!r||!i)return;const{attributes:{location:s,elevationSource:o,cameraHeading:n,cameraHeight:c},elevationSample:l}=t;let h=s.clone();const u=await le(s.spatialReference,s.z??0,c,{elevationSample:l,elevationSource:o});t.elevationSample=u.elevationSample;const d=Array.isArray(e)?e:[e];let m,p=await Promise.all(d.map(e=>new Promise(t=>{if(!e.hasZ)return t(ae(e,u));t(e)})));if(s.spatialReference.isGeographic&&(h=await j(h,B.WebMercator,a)),p=await Promise.all(p.map(async e=>h.spatialReference.equals(e.spatialReference)?e:await j(e,h.spatialReference,a))),v(a),"panoramic"===this.mode)m=ge(p,{imageHeight:r[1],imageWidth:r[0],cameraHeading:n,cameraLocation:h});else{const e=me(t.attributes,r[0],r[1]);m=pe(p,{...e,cameraLocation:h})}return Array.isArray(e)?m:m[0]}updateCurrentCoveragePolygon(e){const{additionalFootprints:a,additionalCameraLocations:i,currentBestFeature:r,currentBestFeatureLocation:s,currentCoverageVisible:o,selectedPoint:n,view:c,_adapter:l,mode:h}=this;if(!r)return;const{attributes:{objectId:u},elevationSample:d}=r;if(this._initialCurrentCoverageUpdate){if(this._overlays?.removeAll(),this._initialCurrentCoverageUpdate=!1,this.bestFeatureCurrentFootprint=p(this.bestFeatureCurrentFootprint),e&&!this.invalidCameraHeading&&(e.visible=o,this.bestFeatureCurrentFootprint=e),c){const e=[...a,...i,s].filter(ut);"3d"===c?.type&&d&&l?.updateGroundElevation&&(this._updateGroundElevation&&l.updateGroundElevation(e),"panoramic"===h&&l.updateGroundElevation([this.bestFeatureCurrentFootprint])),this._updateGroundElevation=!1,n&&(e.splice(-2,0,this.bestFeatureCurrentFootprint),e.push(new t({geometry:n.clone(),symbol:Ne.clone(),attributes:{imageID:u}}))),this._overlays.graphics.addMany(e)}}else if(c){if(this.invalidCameraHeading)return;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"===c?.type&&d&&l?.updateGroundElevation&&"panoramic"===h&&l.updateGroundElevation([e]),e.visible=this.currentCoverageVisible,this._overlays?.graphics.add(this.bestFeatureCurrentFootprint,t>=0?t:this._overlays.graphics.length-1))}}};e([S()],Vt.prototype,"activeLayer",null),e([S({readOnly:!0})],Vt.prototype,"activeViewer",null),e([S()],Vt.prototype,"activeTriangulatedViewer",null),e([S()],Vt.prototype,"accuracyParametersMissing",null),e([S()],Vt.prototype,"additionalFeatures",void 0),e([S({type:s.ofType(t)})],Vt.prototype,"additionalCameraLocations",void 0),e([S({type:s.ofType(t)})],Vt.prototype,"additionalFootprints",void 0),e([S()],Vt.prototype,"areaMeasurementResult",void 0),e([S()],Vt.prototype,"areaMeasurementAccuracy",void 0),e([S()],Vt.prototype,"bestFeatureAngle",void 0),e([S()],Vt.prototype,"bestFeatureCurrentFootprint",void 0),e([S({type:t})],Vt.prototype,"bestFeatureFootprint",void 0),e([S({type:Number})],Vt.prototype,"brightness",null),e([S()],Vt.prototype,"cameraHeadingThreshold",void 0),e([S()],Vt.prototype,"cameraPitchThreshold",void 0),e([S()],Vt.prototype,"clickAction",void 0),e([S()],Vt.prototype,"videoViewModel",void 0),e([S()],Vt.prototype,"collectionId",void 0),e([S({type:Number})],Vt.prototype,"contrast",null),e([S()],Vt.prototype,"conversionProps",void 0),e([S()],Vt.prototype,"coverageFrustums",void 0),e([S()],Vt.prototype,"coveragePolygons",void 0),e([S()],Vt.prototype,"currentBestFeature",void 0),e([S()],Vt.prototype,"currentBestFeatureMeasurementImage",void 0),e([S()],Vt.prototype,"currentBestFeatureLocation",void 0),e([S()],Vt.prototype,"currentCoverageVisible",void 0),e([S()],Vt.prototype,"currentNode",null),e([S()],Vt.prototype,"depthImage",void 0),e([S()],Vt.prototype,"depthImageNotSupported",null),e([S()],Vt.prototype,"directionMode",void 0),e([S()],Vt.prototype,"featureCache",void 0),e([S()],Vt.prototype,"navigationNodes",void 0),e([S({json:{write:!1}})],Vt.prototype,"determineWorkflowForFeature",void 0),e([S({json:{write:!1}})],Vt.prototype,"determineWorkflowForTriangularMeasurement",void 0),e([S()],Vt.prototype,"disabled",void 0),e([S()],Vt.prototype,"displayMessage",void 0),e([S()],Vt.prototype,"displayNewMeasurementButton",void 0),e([S()],Vt.prototype,"distanceMeasurementResult",void 0),e([S()],Vt.prototype,"distanceAccuracyArray",void 0),e([S()],Vt.prototype,"dataCaptureLayer",void 0),e([S({readOnly:!0})],Vt.prototype,"featureCount",null),e([S()],Vt.prototype,"features",void 0),e([S()],Vt.prototype,"groundCoordinates",void 0),e([S()],Vt.prototype,"groundCoordinatesAccuracy",void 0),e([S()],Vt.prototype,"heightMeasurementPixels",void 0),e([S()],Vt.prototype,"heightGraphic",void 0),e([S()],Vt.prototype,"heightMeasurementResult",void 0),e([S()],Vt.prototype,"heightMeasurementAccuracy",void 0),e([S()],Vt.prototype,"measurementAngle",void 0),e([S()],Vt.prototype,"tempDistance",void 0),e([S({readOnly:!0})],Vt.prototype,"imageGalleryEnabled",null),e([S()],Vt.prototype,"imageGeometryField",void 0),e([S({readOnly:!0})],Vt.prototype,"imageLoaded",null),e([S()],Vt.prototype,"imageLocationToolState",void 0),e([S({readOnly:!0})],Vt.prototype,"invalidCameraHeading",null),e([S()],Vt.prototype,"imagePointsInView",null),e([S()],Vt.prototype,"imageMeasurementViewer",void 0),e([S()],Vt.prototype,"isAdditionalCoverageVisible",void 0),e([S()],Vt.prototype,"isAdditionalPointSourcesVisible",void 0),e([S()],Vt.prototype,"measurementVectors",void 0),e([S()],Vt.prototype,"layer",void 0),e([S()],Vt.prototype,"layerView",null),e([S({readOnly:!0})],Vt.prototype,"layerFloorFilterClause",null),e([S({type:Number})],Vt.prototype,"localPort",void 0),e([S()],Vt.prototype,"mapImageConversionToolState",void 0),e([S()],Vt.prototype,"measureType",void 0),e([S()],Vt.prototype,"measurementGraphic",void 0),e([S({readOnly:!0,value:"none"})],Vt.prototype,"mode",null),e([S()],Vt.prototype,"navigationMode",void 0),e([S()],Vt.prototype,"navigatorCurrentBestFeature",void 0),e([S()],Vt.prototype,"oiObjectIdField",void 0),e([S({type:s.ofType(t)})],Vt.prototype,"overlayedCameraLocations",void 0),e([S()],Vt.prototype,"overlayedMapFeatures",void 0),e([S()],Vt.prototype,"panoramicVideoLoaded",null),e([S()],Vt.prototype,"pixelCoordinates",void 0),e([S()],Vt.prototype,"preserveAngle",void 0),e([S()],Vt.prototype,"pointSources",void 0),e([S({readOnly:!0})],Vt.prototype,"popupEnabled",null),e([S()],Vt.prototype,"previousFeatureAngle",void 0),e([S()],Vt.prototype,"referencePoint",null),e([S({readOnly:!0})],Vt.prototype,"sectorData",null),e([S()],Vt.prototype,"selectedPoint",void 0),e([S({type:Number})],Vt.prototype,"sharpness",null),e([S()],Vt.prototype,"shouldShowSelectedImage",void 0),e([S()],Vt.prototype,"sketch",void 0),e([S()],Vt.prototype,"sketchTriangular",void 0),e([S()],Vt.prototype,"sketchTriangularGraphicsLayer",void 0),e([S()],Vt.prototype,"draw",void 0),e([S()],Vt.prototype,"sketchAdapter",void 0),e([S({readOnly:!0})],Vt.prototype,"sketchGraphicsLayer",null),e([S({readOnly:!0})],Vt.prototype,"state",null),e([S({readOnly:!0})],Vt.prototype,"thumbnails",null),e([S()],Vt.prototype,"triangularMeasurementActive",void 0),e([S()],Vt.prototype,"triangulatedDistanceMeasurement",void 0),e([S()],Vt.prototype,"triangulatedDistanceAccuracy",void 0),e([S()],Vt.prototype,"triangulatedAreaMeasurement",void 0),e([S()],Vt.prototype,"triangulatedAreaAccuracy",void 0),e([S()],Vt.prototype,"triangulatedMeasurementGraphic",void 0),e([S()],Vt.prototype,"triangulatedPoint",void 0),e([S()],Vt.prototype,"triangulatedMeasurementAdapter",void 0),e([S()],Vt.prototype,"updateFootprint",void 0),e([S()],Vt.prototype,"updateFootprintPanorama",void 0),e([S()],Vt.prototype,"updatingTriangularMeasurementState",void 0),e([S({value:null})],Vt.prototype,"view",null),e([S()],Vt.prototype,"videoElement",void 0),e([S()],Vt.prototype,"videoLayer",void 0),e([S()],Vt.prototype,"videoMapView",void 0),e([S()],Vt.prototype,"_adapter",void 0),e([S()],Vt.prototype,"_defaultGraphicsLayer",null),e([S()],Vt.prototype,"_highlightedFeatureHandle",void 0),e([S()],Vt.prototype,"_imageViewer",void 0),e([S()],Vt.prototype,"_initialCurrentCoverageUpdate",void 0),e([S()],Vt.prototype,"_locationPointOnImage",void 0),e([S()],Vt.prototype,"_measurementService",void 0),e([S()],Vt.prototype,"_correctedLocationPointOnImage",void 0),e([S()],Vt.prototype,"_overlays",void 0),e([S({readOnly:!0})],Vt.prototype,"_overlaysView",null),e([S()],Vt.prototype,"_panoramicVideoViewer",void 0),e([S()],Vt.prototype,"_panoramicViewer",void 0),e([S()],Vt.prototype,"_panoramicMeasurementViewer",void 0),e([S()],Vt.prototype,"_referencePointOnGround",void 0),e([S()],Vt.prototype,"_referencePointOnImage",void 0),e([S()],Vt.prototype,"_sectorData",void 0),e([S()],Vt.prototype,"_featureToSector",void 0),e([S({readOnly:!0})],Vt.prototype,"_updatingHandles",void 0),e([S()],Vt.prototype,"footprintExtent",void 0),e([S()],Vt.prototype,"_featureChangedTask",void 0),Vt=e([k("esri.widgets.OrientedImageryViewer.OrientedImageryViewerViewModel")],Vt);const St=Vt;export{St as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright Esri, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- import{__decorate as o}from"tslib";import t from"../../Color.js";import s from"../../core/Accessor.js";import i from"../../core/Collection.js";import{referenceSetter as e}from"../../core/collectionUtils.js";import{convertTime as r}from"../../core/timeUtils.js";import{property as l,subclass as n}from"../../core/accessorSupport/decorators.js";let c=class extends s{constructor(o){super(o),this.color=new t([50,50,50,.7]),this.interval=r(1,"hours","milliseconds"),this.intervalOptions=new i([r(15,"minutes","milliseconds"),r(30,"minutes","milliseconds"),r(1,"hours","milliseconds"),r(2,"hours","milliseconds"),r(3,"hours","milliseconds")])}set intervalOptions(o){this._set("intervalOptions",e(o,this._get("intervalOptions")))}};o([l({type:t,nonNullable:!0})],c.prototype,"color",void 0),o([l({type:Number})],c.prototype,"interval",void 0),o([l({type:i})],c.prototype,"intervalOptions",null),c=o([n("esri.widgets.ShadowCast.DiscreteOptions")],c);const p=c;export{p as default};
5
+ import{__decorate as o}from"tslib";import t from"../../Color.js";import s from"../../core/Accessor.js";import e from"../../core/Collection.js";import{referenceSetter as r}from"../../core/collectionUtils.js";import{deprecateUnnecessaryViewModel as i}from"../../core/deprecate.js";import l from"../../core/Logger.js";import{convertTime as n}from"../../core/timeUtils.js";import{property as c,subclass as m}from"../../core/accessorSupport/decorators.js";let p=class extends s{constructor(o){super(o),this.color=new t([50,50,50,.7]),this.interval=n(1,"hours","milliseconds"),o?.isDefaultViewModel||i(l.getLogger(this),"Shadow Cast","arcgis-shadow-cast",{version:"5.0"}),this.intervalOptions=new e([n(15,"minutes","milliseconds"),n(30,"minutes","milliseconds"),n(1,"hours","milliseconds"),n(2,"hours","milliseconds"),n(3,"hours","milliseconds")])}normalizeCtorArgs(o){const{isDefaultViewModel:t,...s}=o??{};return s}set intervalOptions(o){this._set("intervalOptions",r(o,this._get("intervalOptions")))}};o([c({type:t,nonNullable:!0})],p.prototype,"color",void 0),o([c({type:Number})],p.prototype,"interval",void 0),o([c({type:e})],p.prototype,"intervalOptions",null),p=o([m("esri.widgets.ShadowCast.DiscreteOptions")],p);const a=p;export{a as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright Esri, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- import{__decorate as o}from"tslib";import t from"../../Color.js";import r from"../../core/Accessor.js";import{property as s,subclass as e}from"../../core/accessorSupport/decorators.js";let c=class extends r{constructor(o){super(o),this.color=new t([0,0,255,.7]),this.mode="continuous"}};o([s({type:t,nonNullable:!0})],c.prototype,"color",void 0),o([s({type:["continuous","hourly"]})],c.prototype,"mode",void 0),c=o([e("esri.widgets.ShadowCast.DurationOptions")],c);const i=c;export{i as default};
5
+ import{__decorate as o}from"tslib";import r from"../../Color.js";import t from"../../core/Accessor.js";import{deprecateUnnecessaryViewModel as e}from"../../core/deprecate.js";import s from"../../core/Logger.js";import{property as i,subclass as c}from"../../core/accessorSupport/decorators.js";let a=class extends t{constructor(o){super(o),this.color=new r([0,0,255,.7]),this.mode="continuous",o?.isDefaultViewModel||e(s.getLogger(this),"Shadow Cast","arcgis-shadow-cast",{version:"5.0"})}normalizeCtorArgs(o){const{isDefaultViewModel:r,...t}=o??{};return t}};o([i({type:r,nonNullable:!0})],a.prototype,"color",void 0),o([i({type:["continuous","hourly"]})],a.prototype,"mode",void 0),a=o([c("esri.widgets.ShadowCast.DurationOptions")],a);const p=a;export{p as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright Esri, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- import{__decorate as t}from"tslib";import e from"../../Color.js";import i from"../../core/Accessor.js";import{isSome as r}from"../../core/arrayUtils.js";import{createTask as s}from"../../core/asyncUtils.js";import"../../core/has.js";import{abortMaybe as o,destroyMaybe as n}from"../../core/maybe.js";import{after as a,throwIfAborted as l}from"../../core/promiseUtils.js";import{watch as u,syncAndInitial as p}from"../../core/reactiveUtils.js";import{createScreenPointArray as d,createRenderScreenPointArray as h}from"../../core/screenUtils.js";import{convertTime as c,offsetDateUTC as m}from"../../core/timeUtils.js";import{property as f,subclass as _}from"../../core/accessorSupport/decorators.js";import{create as g}from"../../core/libs/gl-matrix-2/factories/vec3f64.js";import{longitudeToTimezone as v}from"../../views/3d/support/earthUtils.js";import{computeDirectionsOverTime as y}from"../../views/3d/support/sunUtils.js";import w from"./DiscreteOptions.js";import D from"./DurationOptions.js";import{ShadowTooltipViewModel as T}from"./ShadowTooltipViewModel.js";import O from"./ThresholdOptions.js";import{breadthFirstBinaryPartitioning as P}from"../support/traversalUtils.js";const C=[],b=g(),z=[],U=255,V=c(1,"hours","milliseconds"),j=500;let x=class extends i{constructor(t){super(t),this.view=null,this.tooltip=new T({getDuration:t=>this.getDuration(t)}),this.startTimeOfDay=c(10,"hours","milliseconds"),this.endTimeOfDay=c(16,"hours","milliseconds"),this.visualizationType="threshold",this.thresholdOptions=new O,this.durationOptions=new D,this.discreteOptions=new w,this._running=!0,this._stopPreviewingTask=null,this._forcePreview=!1,this._autoRestoreForcePreviewEnabled=!0,this._utcOffset=null,this.date=new Date}initialize(){this.addHandles([u(()=>({view:this.view,tooltipEnabled:this._tooltipEnabled}),({view:t,tooltipEnabled:e})=>{this.tooltip.view=t,this.tooltip.enabled=e},p),u(()=>this._forcePreviewDependencies,()=>{o(this._stopPreviewingTask),this._forcePreview=!0,this._autoRestoreForcePreviewEnabled&&(this._stopPreviewingTask=s(async t=>{await a(j,t),l(t),this._forcePreview=!1}))},p),u(()=>({renderer:this.renderer,parameters:this._visualizationParameters}),t=>E(t.renderer,t.parameters),p),u(()=>({renderer:this.renderer,lightDirections:this._lightDirections,lightDirectionsContext:this._lightDirectionsContext}),t=>E(t.renderer,{lightDirections:t.lightDirections,lightDirectionsContext:t.lightDirectionsContext}),p),u(()=>({renderer:this.renderer,parameters:{enabled:this._running}}),t=>E(t.renderer,t.parameters),p),u(()=>({renderer:this.renderer,parameters:{previewing:this._previewing}}),t=>E(t.renderer,t.parameters),p)])}destroy(){this.stop(),E(this.renderer,{enabled:!1}),n(this.tooltip)}get state(){return null!=this.view&&this.view.ready&&null!=this._referencePosition?"ready":"disabled"}set date(t){const e=new Date(t);e.setHours(0,0,0,0),this._set("date",e)}get utcOffset(){return this._utcOffset??this._utcOffsetAuto}set utcOffset(t){this._utcOffset=t}get testData(){}get _previewing(){const{view:t}=this;if(null==t?.allLayerViews)return!0;const{stationary:e,allLayerViews:i,graphicsView:r}=t;return this._forcePreview||!e||i.some(t=>A(t)&&t.updating)||!r?.suspended&&!!r?.updating}get _utcOffsetAuto(){const t=this._referencePosition;return null!=t?v(t[0],!1):0}get _dateUTCOffset(){let t=this.date;return t=m(t,-t.getTimezoneOffset(),"minutes"),t=m(t,-this.utcOffset,"hours"),t}get _startDateTimeUTC(){return m(this._dateUTCOffset,this.startTimeOfDay)}get _endDateTimeUTC(){return m(this._dateUTCOffset,this.endTimeOfDay)}get _referencePosition(){return this.view?.environmentManager?.referencePositionGeographic}get _durationInterval(){return this._duration>0?Math.floor(this._duration/(U-1)):U}get _interval(){const t=this._durationInterval;switch(this.visualizationType){case"threshold":case"duration":return t;case"discrete":return this.discreteOptions.interval||t}}get _intervalContext(){const{contextEnabled:t,contextOptions:{interval:e}}=this.thresholdOptions;return"threshold"===this.visualizationType&&t?e||this._durationInterval:-1}get _durationSampleCount(){return this._lightDirections.length}get _duration(){return this.endTimeOfDay-this.startTimeOfDay}get _lightDirections(){return this._calculateLightDirections(this._interval)}get _lightDirectionsContext(){return this._calculateLightDirections(this._intervalContext)}_calculateLightDirections(t){const{view:e}=this;if(null==e||t<=0)return C;const i="global"===e.viewingMode?b:this._referencePosition;if(null==i)return C;const r=y(this._startDateTimeUTC,this._endDateTimeUTC,t,i,e.state.viewingMode,U),s=r.length;z.length=0;const o=P(0,s,z),n=new Array(s);for(let a=0;a<s;++a)n[a]=r[o[a]];return n}get _tooltipEnabled(){return"ready"===this.state&&"discrete"!==this.visualizationType&&this._running&&!this._previewing}get _visualizationParameters(){if(!this._running)return null;switch(this.visualizationType){case"threshold":return this._thresholdVisualizationParameters;case"duration":return this._durationVisualizationParameters;case"discrete":return this._discreteVisualizationParameters}}get _thresholdVisualizationParameters(){const{value:t,color:i}=this.thresholdOptions,r=this._duration;return{visualization:2,thresholdColor:e.toUnitRGBA(i),threshold:r>0?t/this._duration:0,...this._thresholdDiscreteVisualizationParameters}}get _thresholdDiscreteVisualizationParameters(){const{contextOptions:{color:t},contextEnabled:i}=this.thresholdOptions;return i?{visualization:3,gradientColor:e.toUnitRGBA(t)}:{}}get _durationVisualizationParameters(){const{color:t,mode:i}=this.durationOptions,r=this._duration,s=r>0&&"hourly"===i?V/r:0,o=e.toUnitRGBA(t);return 0===s?{...this._discreteVisualizationParameters,gradientColor:o}:{bandedGradientColor:o,visualization:1,bandSize:s}}get _discreteVisualizationParameters(){return{gradientColor:e.toUnitRGBA(this.discreteOptions.color),visualization:0}}get _forcePreviewDependencies(){const{view:t}=this;if(null==t)return null;const e=t.slice.plane,i=t.allLayerViews.toArray().filter(A),s=i.map(t=>t.layer).filter(r),o=i.map(t=>t.suspended),n=s.map(t=>t.visible),a=s.map(t=>t.opacity),l=!!t.graphicsView?.suspended,u=s.filter(t=>"definitionExpression"in t).map(t=>t.definitionExpression),p=i.filter(t=>"filter"in t).map(t=>t.filter);return{slicePlane:e,startDateUTC:this._startDateTimeUTC,endDateUTC:this._endDateTimeUTC,layerViewSuspended:o,graphicsViewSuspended:l,layerVisibilities:n,layerOpacities:a,filters:p,definitionExpressions:u}}get renderer(){const{view:t}=this;if(null==t)return null;const e=t.stage;return null==e?null:e.renderer}start(){this.setRunning(!0)}stop(){this.setRunning(!1)}setRunning(t){this._running=t}async getDuration(t){const{view:e,renderer:i,_durationSampleCount:r}=this;if(null==e||null==i||0===r)return 0;const s=e.state.camera.screenToRender(d(t.x,t.y),h());return i.readAccumulatedShadow(s)*this._duration}};function E(t,e){null!=t&&null!=e&&t.setParameters({shadowCast:e})}function A(t){if(t.suspended)return!1;switch(t.type){case"building-scene-3d":case"csv-3d":case"elevation-3d":case"feature-3d":case"geojson-3d":case"graphics-3d":case"integrated-mesh-3d":case"integrated-mesh-3dtiles":case"ogc-feature-3d":case"route-3d":case"scene-layer-3d":case"scene-layer-graphics-3d":case"stream-3d":case"wms-3d":case"catalog-footprint-3d":return!0;default:return!1}}t([f()],x.prototype,"state",null),t([f()],x.prototype,"view",void 0),t([f()],x.prototype,"tooltip",void 0),t([f({type:Date,nonNullable:!0})],x.prototype,"date",null),t([f({type:Number,nonNullable:!0})],x.prototype,"utcOffset",null),t([f({type:Number,nonNullable:!0})],x.prototype,"startTimeOfDay",void 0),t([f({type:Number,nonNullable:!0})],x.prototype,"endTimeOfDay",void 0),t([f({type:["threshold","duration","discrete"],nonNullable:!0})],x.prototype,"visualizationType",void 0),t([f({type:O,nonNullable:!0})],x.prototype,"thresholdOptions",void 0),t([f({type:D,nonNullable:!0})],x.prototype,"durationOptions",void 0),t([f({type:w,nonNullable:!0})],x.prototype,"discreteOptions",void 0),t([f()],x.prototype,"_running",void 0),t([f()],x.prototype,"_stopPreviewingTask",void 0),t([f()],x.prototype,"_forcePreview",void 0),t([f()],x.prototype,"_autoRestoreForcePreviewEnabled",void 0),t([f()],x.prototype,"_previewing",null),t([f()],x.prototype,"_utcOffset",void 0),t([f()],x.prototype,"_utcOffsetAuto",null),t([f()],x.prototype,"_dateUTCOffset",null),t([f()],x.prototype,"_startDateTimeUTC",null),t([f()],x.prototype,"_endDateTimeUTC",null),t([f()],x.prototype,"_referencePosition",null),t([f()],x.prototype,"_interval",null),t([f()],x.prototype,"_intervalContext",null),t([f()],x.prototype,"_durationSampleCount",null),t([f()],x.prototype,"_duration",null),t([f()],x.prototype,"_lightDirections",null),t([f()],x.prototype,"_lightDirectionsContext",null),t([f()],x.prototype,"_tooltipEnabled",null),t([f()],x.prototype,"_visualizationParameters",null),t([f()],x.prototype,"_thresholdVisualizationParameters",null),t([f()],x.prototype,"_thresholdDiscreteVisualizationParameters",null),t([f()],x.prototype,"_durationVisualizationParameters",null),t([f()],x.prototype,"_discreteVisualizationParameters",null),t([f()],x.prototype,"_forcePreviewDependencies",null),t([f()],x.prototype,"renderer",null),x=t([_("esri.widgets.ShadowCast.ShadowCastViewModel")],x);const N=x;export{N as default};
5
+ import{__decorate as t}from"tslib";import e from"../../Color.js";import i from"../../core/Accessor.js";import{isSome as r}from"../../core/arrayUtils.js";import{createTask as s}from"../../core/asyncUtils.js";import"../../core/has.js";import{deprecateUnnecessaryViewModel as o}from"../../core/deprecate.js";import n from"../../core/Logger.js";import{abortMaybe as a,destroyMaybe as l}from"../../core/maybe.js";import{after as u,throwIfAborted as d}from"../../core/promiseUtils.js";import{watch as p,syncAndInitial as h}from"../../core/reactiveUtils.js";import{createScreenPointArray as c,createRenderScreenPointArray as m}from"../../core/screenUtils.js";import{convertTime as f,offsetDateUTC as _}from"../../core/timeUtils.js";import{property as g,subclass as v}from"../../core/accessorSupport/decorators.js";import{create as y}from"../../core/libs/gl-matrix-2/factories/vec3f64.js";import{longitudeToTimezone as w}from"../../views/3d/support/earthUtils.js";import{computeDirectionsOverTime as D}from"../../views/3d/support/sunUtils.js";import T from"./DiscreteOptions.js";import O from"./DurationOptions.js";import{ShadowTooltipViewModel as P}from"./ShadowTooltipViewModel.js";import C from"./ThresholdOptions.js";import{breadthFirstBinaryPartitioning as b}from"../support/traversalUtils.js";const z=[],V=y(),U=[],j=255,x=f(1,"hours","milliseconds"),E=500;let A=class extends i{constructor(t){super(t),this.view=null,this.tooltip=new P({getDuration:t=>this.getDuration(t)}),this.startTimeOfDay=f(10,"hours","milliseconds"),this.endTimeOfDay=f(16,"hours","milliseconds"),this.visualizationType="threshold",this.thresholdOptions=new C({isDefaultViewModel:!0}),this.durationOptions=new O({isDefaultViewModel:!0}),this.discreteOptions=new T({isDefaultViewModel:!0}),this._running=!0,this._stopPreviewingTask=null,this._forcePreview=!1,this._autoRestoreForcePreviewEnabled=!0,this._utcOffset=null,t?.isDefaultViewModel||o(n.getLogger(this),"Shadow Cast","arcgis-shadow-cast",{version:"5.0"}),this.date=new Date}normalizeCtorArgs(t){const{isDefaultViewModel:e,...i}=t??{};return i}initialize(){this.addHandles([p(()=>({view:this.view,tooltipEnabled:this._tooltipEnabled}),({view:t,tooltipEnabled:e})=>{this.tooltip.view=t,this.tooltip.enabled=e},h),p(()=>this._forcePreviewDependencies,()=>{a(this._stopPreviewingTask),this._forcePreview=!0,this._autoRestoreForcePreviewEnabled&&(this._stopPreviewingTask=s(async t=>{await u(E,t),d(t),this._forcePreview=!1}))},h),p(()=>({renderer:this.renderer,parameters:this._visualizationParameters}),t=>S(t.renderer,t.parameters),h),p(()=>({renderer:this.renderer,lightDirections:this._lightDirections,lightDirectionsContext:this._lightDirectionsContext}),t=>S(t.renderer,{lightDirections:t.lightDirections,lightDirectionsContext:t.lightDirectionsContext}),h),p(()=>({renderer:this.renderer,parameters:{enabled:this._running}}),t=>S(t.renderer,t.parameters),h),p(()=>({renderer:this.renderer,parameters:{previewing:this._previewing}}),t=>S(t.renderer,t.parameters),h)])}destroy(){this.stop(),S(this.renderer,{enabled:!1}),l(this.tooltip)}get state(){return null!=this.view&&this.view.ready&&null!=this._referencePosition?"ready":"disabled"}set date(t){const e=new Date(t);e.setHours(0,0,0,0),this._set("date",e)}get utcOffset(){return this._utcOffset??this._utcOffsetAuto}set utcOffset(t){this._utcOffset=t}get testData(){}get _previewing(){const{view:t}=this;if(null==t?.allLayerViews)return!0;const{stationary:e,allLayerViews:i,graphicsView:r}=t;return this._forcePreview||!e||i.some(t=>M(t)&&t.updating)||!r?.suspended&&!!r?.updating}get _utcOffsetAuto(){const t=this._referencePosition;return null!=t?w(t[0],!1):0}get _dateUTCOffset(){let t=this.date;return t=_(t,-t.getTimezoneOffset(),"minutes"),t=_(t,-this.utcOffset,"hours"),t}get _startDateTimeUTC(){return _(this._dateUTCOffset,this.startTimeOfDay)}get _endDateTimeUTC(){return _(this._dateUTCOffset,this.endTimeOfDay)}get _referencePosition(){return this.view?.environmentManager?.referencePositionGeographic}get _durationInterval(){return this._duration>0?Math.floor(this._duration/(j-1)):j}get _interval(){const t=this._durationInterval;switch(this.visualizationType){case"threshold":case"duration":return t;case"discrete":return this.discreteOptions.interval||t}}get _intervalContext(){const{contextEnabled:t,contextOptions:{interval:e}}=this.thresholdOptions;return"threshold"===this.visualizationType&&t?e||this._durationInterval:-1}get _durationSampleCount(){return this._lightDirections.length}get _duration(){return this.endTimeOfDay-this.startTimeOfDay}get _lightDirections(){return this._calculateLightDirections(this._interval)}get _lightDirectionsContext(){return this._calculateLightDirections(this._intervalContext)}_calculateLightDirections(t){const{view:e}=this;if(null==e||t<=0)return z;const i="global"===e.viewingMode?V:this._referencePosition;if(null==i)return z;const r=D(this._startDateTimeUTC,this._endDateTimeUTC,t,i,e.state.viewingMode,j),s=r.length;U.length=0;const o=b(0,s,U),n=new Array(s);for(let a=0;a<s;++a)n[a]=r[o[a]];return n}get _tooltipEnabled(){return"ready"===this.state&&"discrete"!==this.visualizationType&&this._running&&!this._previewing}get _visualizationParameters(){if(!this._running)return null;switch(this.visualizationType){case"threshold":return this._thresholdVisualizationParameters;case"duration":return this._durationVisualizationParameters;case"discrete":return this._discreteVisualizationParameters}}get _thresholdVisualizationParameters(){const{value:t,color:i}=this.thresholdOptions,r=this._duration;return{visualization:2,thresholdColor:e.toUnitRGBA(i),threshold:r>0?t/this._duration:0,...this._thresholdDiscreteVisualizationParameters}}get _thresholdDiscreteVisualizationParameters(){const{contextOptions:{color:t},contextEnabled:i}=this.thresholdOptions;return i?{visualization:3,gradientColor:e.toUnitRGBA(t)}:{}}get _durationVisualizationParameters(){const{color:t,mode:i}=this.durationOptions,r=this._duration,s=r>0&&"hourly"===i?x/r:0,o=e.toUnitRGBA(t);return 0===s?{...this._discreteVisualizationParameters,gradientColor:o}:{bandedGradientColor:o,visualization:1,bandSize:s}}get _discreteVisualizationParameters(){return{gradientColor:e.toUnitRGBA(this.discreteOptions.color),visualization:0}}get _forcePreviewDependencies(){const{view:t}=this;if(null==t)return null;const e=t.slice.plane,i=t.allLayerViews.toArray().filter(M),s=i.map(t=>t.layer).filter(r),o=i.map(t=>t.suspended),n=s.map(t=>t.visible),a=s.map(t=>t.opacity),l=!!t.graphicsView?.suspended,u=s.filter(t=>"definitionExpression"in t).map(t=>t.definitionExpression),d=i.filter(t=>"filter"in t).map(t=>t.filter);return{slicePlane:e,startDateUTC:this._startDateTimeUTC,endDateUTC:this._endDateTimeUTC,layerViewSuspended:o,graphicsViewSuspended:l,layerVisibilities:n,layerOpacities:a,filters:d,definitionExpressions:u}}get renderer(){const{view:t}=this;if(null==t)return null;const e=t.stage;return null==e?null:e.renderer}start(){this.setRunning(!0)}stop(){this.setRunning(!1)}setRunning(t){this._running=t}async getDuration(t){const{view:e,renderer:i,_durationSampleCount:r}=this;if(null==e||null==i||0===r)return 0;const s=e.state.camera.screenToRender(c(t.x,t.y),m());return i.readAccumulatedShadow(s)*this._duration}};function S(t,e){null!=t&&null!=e&&t.setParameters({shadowCast:e})}function M(t){if(t.suspended)return!1;switch(t.type){case"building-scene-3d":case"csv-3d":case"elevation-3d":case"feature-3d":case"geojson-3d":case"graphics-3d":case"integrated-mesh-3d":case"integrated-mesh-3dtiles":case"ogc-feature-3d":case"route-3d":case"scene-layer-3d":case"scene-layer-graphics-3d":case"stream-3d":case"wms-3d":case"catalog-footprint-3d":return!0;default:return!1}}t([g()],A.prototype,"state",null),t([g()],A.prototype,"view",void 0),t([g()],A.prototype,"tooltip",void 0),t([g({type:Date,nonNullable:!0})],A.prototype,"date",null),t([g({type:Number,nonNullable:!0})],A.prototype,"utcOffset",null),t([g({type:Number,nonNullable:!0})],A.prototype,"startTimeOfDay",void 0),t([g({type:Number,nonNullable:!0})],A.prototype,"endTimeOfDay",void 0),t([g({type:["threshold","duration","discrete"],nonNullable:!0})],A.prototype,"visualizationType",void 0),t([g({type:C,nonNullable:!0})],A.prototype,"thresholdOptions",void 0),t([g({type:O,nonNullable:!0})],A.prototype,"durationOptions",void 0),t([g({type:T,nonNullable:!0})],A.prototype,"discreteOptions",void 0),t([g()],A.prototype,"_running",void 0),t([g()],A.prototype,"_stopPreviewingTask",void 0),t([g()],A.prototype,"_forcePreview",void 0),t([g()],A.prototype,"_autoRestoreForcePreviewEnabled",void 0),t([g()],A.prototype,"_previewing",null),t([g()],A.prototype,"_utcOffset",void 0),t([g()],A.prototype,"_utcOffsetAuto",null),t([g()],A.prototype,"_dateUTCOffset",null),t([g()],A.prototype,"_startDateTimeUTC",null),t([g()],A.prototype,"_endDateTimeUTC",null),t([g()],A.prototype,"_referencePosition",null),t([g()],A.prototype,"_interval",null),t([g()],A.prototype,"_intervalContext",null),t([g()],A.prototype,"_durationSampleCount",null),t([g()],A.prototype,"_duration",null),t([g()],A.prototype,"_lightDirections",null),t([g()],A.prototype,"_lightDirectionsContext",null),t([g()],A.prototype,"_tooltipEnabled",null),t([g()],A.prototype,"_visualizationParameters",null),t([g()],A.prototype,"_thresholdVisualizationParameters",null),t([g()],A.prototype,"_thresholdDiscreteVisualizationParameters",null),t([g()],A.prototype,"_durationVisualizationParameters",null),t([g()],A.prototype,"_discreteVisualizationParameters",null),t([g()],A.prototype,"_forcePreviewDependencies",null),t([g()],A.prototype,"renderer",null),A=t([v("esri.widgets.ShadowCast.ShadowCastViewModel")],A);const N=A;export{N as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright Esri, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- import{__decorate as o}from"tslib";import t from"../../Color.js";import e from"../../core/Accessor.js";import{convertTime as r}from"../../core/timeUtils.js";import{property as s,subclass as i}from"../../core/accessorSupport/decorators.js";import p from"./DiscreteOptions.js";let l=class extends e{constructor(o){super(o),this.color=new t([255,0,0,.7]),this.value=r(4,"hours","milliseconds"),this.minValue=0,this.maxValue=r(8,"hours","milliseconds"),this.contextEnabled=!1,this.contextOptions=new p}};o([s({type:t,nonNullable:!0})],l.prototype,"color",void 0),o([s({type:Number})],l.prototype,"value",void 0),o([s({type:Number})],l.prototype,"minValue",void 0),o([s({type:Number})],l.prototype,"maxValue",void 0),o([s({type:Boolean})],l.prototype,"contextEnabled",void 0),o([s({type:p,nonNullable:!0})],l.prototype,"contextOptions",void 0),l=o([i("esri.widgets.ShadowCast.ThresholdOptions")],l);const n=l;export{n as default};
5
+ import{__decorate as o}from"tslib";import e from"../../Color.js";import t from"../../core/Accessor.js";import{deprecateUnnecessaryViewModel as r}from"../../core/deprecate.js";import s from"../../core/Logger.js";import{convertTime as i}from"../../core/timeUtils.js";import{property as p,subclass as l}from"../../core/accessorSupport/decorators.js";import a from"./DiscreteOptions.js";let n=class extends t{constructor(o){super(o),this.color=new e([255,0,0,.7]),this.value=i(4,"hours","milliseconds"),this.minValue=0,this.maxValue=i(8,"hours","milliseconds"),this.contextEnabled=!1,this.contextOptions=new a,o?.isDefaultViewModel||r(s.getLogger(this),"Shadow Cast","arcgis-shadow-cast",{version:"5.0"})}normalizeCtorArgs(o){const{isDefaultViewModel:e,...t}=o??{};return t}};o([p({type:e,nonNullable:!0})],n.prototype,"color",void 0),o([p({type:Number})],n.prototype,"value",void 0),o([p({type:Number})],n.prototype,"minValue",void 0),o([p({type:Number})],n.prototype,"maxValue",void 0),o([p({type:Boolean})],n.prototype,"contextEnabled",void 0),o([p({type:a,nonNullable:!0})],n.prototype,"contextOptions",void 0),n=o([l("esri.widgets.ShadowCast.ThresholdOptions")],n);const c=n;export{c as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright Esri, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- import{__decorate as e}from"tslib";import{onLocaleChange as i,formatDate as t}from"../intl.js";import"../core/has.js";import{destroyMaybe as o}from"../core/maybe.js";import{watch as s,syncAndInitial as l}from"../core/reactiveUtils.js";import{convertTime as n}from"../core/timeUtils.js";import{property as a,subclass as r}from"../core/accessorSupport/decorators.js";import{substitute as d}from"../intl/substitute.js";import c from"./Slider.js";import m from"./Widget.js";import{css as p}from"./ShadowCast/css.js";import h from"./ShadowCast/ShadowCastViewModel.js";import u from"./ShadowCast/ShadowCastVisibleElements.js";import{DiscreteConfigurator as v}from"./ShadowCast/components/DiscreteConfigurator.js";import{DurationConfigurator as g}from"./ShadowCast/components/DurationConfigurator.js";import{ShadowTooltip as w}from"./ShadowCast/components/ShadowTooltip.js";import{ThresholdConfigurator as b}from"./ShadowCast/components/ThresholdConfigurator.js";import{loadCalciteComponents as f}from"./support/componentsUtils.js";import{globalCss as C}from"./support/globalCss.js";import{Heading as _}from"./support/Heading.js";import{onPrimaryTickCreated as y,onSecondaryTickCreated as S,formatSliderLabel as k,adjustTimeSliderForLocale as M,timeStringFormattingOptions as T}from"./support/timeWidgetUtils.js";import{TimezonePicker as V}from"./support/TimezonePicker.js";import{messageBundle as j,tsx as z}from"./support/widget.js";const D={labelFormatFunction:k,min:0,max:1439,steps:15,rangeLabelInputsEnabled:!1,visibleElements:{labels:!1,rangeLabels:!1},tickConfigs:[{mode:"position",values:[0,360,720,1080,1439],labelsVisible:!0,tickCreatedFunction:(e,i,t)=>y({tickElement:i,labelElement:t})},{mode:"position",values:[120,240,480,600,840,960,1200,1320],tickCreatedFunction:(e,i)=>S({tickElement:i})}]};let O=class extends m{constructor(e,i){super(e,i),this.viewModel=null,this.headingLevel=4,this.visibleElements=new u,this._defaultViewModel=null,this._timeSlider=new c({...D,container:document.createElement("div")}),this._tooltip=null,this._onTimezoneChange=e=>{this.viewModel.utcOffset=e},this._onDateChange=e=>{const i=e.currentTarget.valueAsDate;this.viewModel.date=Array.isArray(i)?i[0]:i},e?.viewModel||(this._defaultViewModel=new h({view:e?.view}),this.viewModel=this._defaultViewModel)}initialize(){this.addHandles([s(()=>({viewModel:this.viewModel,slider:this._timeSlider}),e=>this._connectTimeSlider(e),l),s(()=>({container:this.view?.surface,viewModel:this.viewModel,tooltipVisible:this.visibleElements.tooltip}),({container:e,viewModel:i,tooltipVisible:t})=>{this._tooltip=o(this._tooltip),null!=e&&t&&(this._tooltip=new w({viewModel:i,container:e}))},l),s(()=>({viewModel:this.viewModel,visible:this.visible}),({viewModel:e,visible:i})=>e.setRunning(i),l)])}destroy(){this._timeSlider=o(this._timeSlider),this._tooltip=o(this._tooltip),null!=this._defaultViewModel&&this.viewModel!==this._defaultViewModel&&this._defaultViewModel.destroy()}loadDependencies(){return f({"input-date-picker":()=>import("@esri/calcite-components/dist/components/calcite-input-date-picker"),option:()=>import("@esri/calcite-components/dist/components/calcite-option"),select:()=>import("@esri/calcite-components/dist/components/calcite-select")})}render(){const{visibleElements:e,viewModel:i}=this,t="disabled"===i.state;return z("div",{class:this.classes(p.base,C.widget,C.panel,{[C.widgetDisabled]:t}),key:this},this._renderTimeRangeSection(),e.visualizationOptions?this._renderVisualizationOptionsSection():null)}get view(){return this.viewModel?.view}set view(e){this.viewModel&&(this.viewModel.view=e)}get icon(){return"measure-building-height-shadow"}set icon(e){this._overrideIfSome("icon",e)}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get testData(){}_connectTimeSlider({viewModel:e,slider:t}){if(this.removeHandles("slider"),null==t)return;const o=e=>n(e,"milliseconds","minutes"),a=e=>n(e,"minutes","milliseconds"),r=({index:i,value:t})=>{0===i?e.startTimeOfDay=a(t):e.endTimeOfDay=a(t)},d=()=>M(t.domNode);d(),this.addHandles([s(()=>[e.startTimeOfDay,e.endTimeOfDay],e=>{t.values=e.map(o)},l),t.on("thumb-change",r),t.on("thumb-drag",r),t.on("segment-drag",()=>{[e.startTimeOfDay,e.endTimeOfDay]=t.values.map(a)}),i(d)],"slider")}_renderTimeRangeSection(){const{visibleElements:e}=this;return e.timeRangeSlider||e.datePicker?z("section",{class:p.timeRange,key:"time-range"},z(_,{level:this.headingLevel},this.messages.timeLabel),e.timeRangeSlider?this._renderTimeRange():null,e.datePicker?this._renderDatePicker():null):null}_renderTimeRange(){const{messages:e,viewModel:i,visibleElements:o}=this,{startTimeOfDay:s,endTimeOfDay:l}=i,[n,a]=[s,l].map(e=>t(new Date(e),T));return[z("div",{class:p.timeRangeIndicator,key:"time-range-indicator"},d(e.timeRange,{start:n,end:a}),o.timezone?z(V,{disabled:this._timeSlider?.disabled,value:i.utcOffset,onChange:this._onTimezoneChange}):null),z("div",{afterCreate:this._timeSliderContainerAfterCreate,afterRemoved:this._timeSliderContainerAfterRemoved,bind:this,key:"time-slider-container"})]}_timeSliderContainerAfterCreate(e){const i=this._timeSlider?.container;i&&e.appendChild(i)}_timeSliderContainerAfterRemoved(e){const i=this._timeSlider?.container;i&&e.removeChild(i)}_renderDatePicker(){return z("div",{class:p.datePickerContainer,key:p.datePickerContainer},z("calcite-input-date-picker",{class:p.datePicker,"data-testid":"date-picker",key:p.datePicker,overlayPositioning:"fixed",placement:"bottom",scale:"s",valueAsDate:this.viewModel.date,onCalciteInputDatePickerChange:this._onDateChange}))}_renderVisualizationOptionsSection(){const{headingLevel:e,messages:i,viewModel:t,visibleElements:o}=this,{colorPicker:s,thresholdContext:l,thresholdContextToggle:n,thresholdContextTimeInterval:a,thresholdContextColor:r}=o,d=e=>this.classes(t.visualizationType===e?null:p.visualizationConfigHidden);return z("section",{class:p.visualization,key:"visualization"},z(_,{level:e},i.visualizationLabel),this._renderVisualizationSelect(),z("div",{class:d("threshold"),key:"threshold-configurator"},z(b,{colorPickerVisible:s,contextColorPickerVisible:r,contextTimeIntervalVisible:a,contextToggleVisible:n,contextVisible:l,options:t.thresholdOptions})),z("div",{class:d("duration"),key:"duration-configurator"},z(g,{colorPickerVisible:s,options:t.durationOptions})),z("div",{class:d("discrete"),key:"discrete-configurator"},z(v,{colorPickerVisible:s,options:t.discreteOptions})))}_renderVisualizationSelect(){const e=this.messages,i=this.viewModel.visualizationType;return z("calcite-select",{bind:this,class:p.visualizationSelect,key:"visualization-select",label:e.visualizationLabel,scale:"s",onCalciteSelectChange:this._onVisualizationTypeChange},[{type:"threshold",label:e.threshold.label},{type:"duration",label:e.duration.label},{type:"discrete",label:e.discrete.label}].map(({type:e,label:t})=>z("calcite-option",{selected:e===i,value:e},t)))}_onVisualizationTypeChange(e){const i=e.currentTarget.selectedOption?.value;this.viewModel.visualizationType=i??"threshold"}};e([a()],O.prototype,"viewModel",void 0),e([a()],O.prototype,"view",null),e([a()],O.prototype,"headingLevel",void 0),e([a()],O.prototype,"icon",null),e([a()],O.prototype,"label",null),e([a({type:u,nonNullable:!0})],O.prototype,"visibleElements",void 0),e([a(),j("esri/widgets/ShadowCast/t9n/ShadowCast")],O.prototype,"messages",void 0),e([a()],O.prototype,"_defaultViewModel",void 0),e([a()],O.prototype,"_timeSlider",void 0),e([a()],O.prototype,"_tooltip",void 0),O=e([r("esri.widgets.ShadowCast")],O);const P=O;export{P as default};
5
+ import{__decorate as e}from"tslib";import{onLocaleChange as i,formatDate as t}from"../intl.js";import{deprecateWidget as o}from"../core/deprecate.js";import"../core/has.js";import s from"../core/Logger.js";import{destroyMaybe as l}from"../core/maybe.js";import{watch as n,syncAndInitial as r}from"../core/reactiveUtils.js";import{convertTime as a}from"../core/timeUtils.js";import{property as d,subclass as c}from"../core/accessorSupport/decorators.js";import{substitute as m}from"../intl/substitute.js";import p from"./Slider.js";import h from"./Widget.js";import{css as u}from"./ShadowCast/css.js";import v from"./ShadowCast/ShadowCastViewModel.js";import g from"./ShadowCast/ShadowCastVisibleElements.js";import{DiscreteConfigurator as w}from"./ShadowCast/components/DiscreteConfigurator.js";import{DurationConfigurator as f}from"./ShadowCast/components/DurationConfigurator.js";import{ShadowTooltip as b}from"./ShadowCast/components/ShadowTooltip.js";import{ThresholdConfigurator as C}from"./ShadowCast/components/ThresholdConfigurator.js";import{loadCalciteComponents as _}from"./support/componentsUtils.js";import{globalCss as y}from"./support/globalCss.js";import{Heading as S}from"./support/Heading.js";import{onPrimaryTickCreated as k,onSecondaryTickCreated as M,formatSliderLabel as T,adjustTimeSliderForLocale as V,timeStringFormattingOptions as j}from"./support/timeWidgetUtils.js";import{TimezonePicker as z}from"./support/TimezonePicker.js";import{messageBundle as D,tsx as O}from"./support/widget.js";const P={labelFormatFunction:T,min:0,max:1439,steps:15,rangeLabelInputsEnabled:!1,visibleElements:{labels:!1,rangeLabels:!1},tickConfigs:[{mode:"position",values:[0,360,720,1080,1439],labelsVisible:!0,tickCreatedFunction:(e,i,t)=>k({tickElement:i,labelElement:t})},{mode:"position",values:[120,240,480,600,840,960,1200,1320],tickCreatedFunction:(e,i)=>M({tickElement:i})}]};let E=class extends h{constructor(e,i){super(e,i),this.viewModel=null,this.headingLevel=4,this.visibleElements=new g,this._defaultViewModel=null,this._timeSlider=new p({...P,container:document.createElement("div")}),this._tooltip=null,this._onTimezoneChange=e=>{this.viewModel.utcOffset=e},this._onDateChange=e=>{const i=e.currentTarget.valueAsDate;this.viewModel.date=Array.isArray(i)?i[0]:i},o(s.getLogger(this),"Shadow Cast","arcgis-shadow-cast",{version:"5.0"}),e?.viewModel||(this._defaultViewModel=new v({view:e?.view,isDefaultViewModel:!0}),this.viewModel=this._defaultViewModel)}initialize(){this.addHandles([n(()=>({viewModel:this.viewModel,slider:this._timeSlider}),e=>this._connectTimeSlider(e),r),n(()=>({container:this.view?.surface,viewModel:this.viewModel,tooltipVisible:this.visibleElements.tooltip}),({container:e,viewModel:i,tooltipVisible:t})=>{this._tooltip=l(this._tooltip),null!=e&&t&&(this._tooltip=new b({viewModel:i,container:e}))},r),n(()=>({viewModel:this.viewModel,visible:this.visible}),({viewModel:e,visible:i})=>e.setRunning(i),r)])}destroy(){this._timeSlider=l(this._timeSlider),this._tooltip=l(this._tooltip),null!=this._defaultViewModel&&this.viewModel!==this._defaultViewModel&&this._defaultViewModel.destroy()}loadDependencies(){return _({"input-date-picker":()=>import("@esri/calcite-components/dist/components/calcite-input-date-picker"),option:()=>import("@esri/calcite-components/dist/components/calcite-option"),select:()=>import("@esri/calcite-components/dist/components/calcite-select")})}render(){const{visibleElements:e,viewModel:i}=this,t="disabled"===i.state;return O("div",{class:this.classes(u.base,y.widget,y.panel,{[y.widgetDisabled]:t}),key:this},this._renderTimeRangeSection(),e.visualizationOptions?this._renderVisualizationOptionsSection():null)}get view(){return this.viewModel?.view}set view(e){this.viewModel&&(this.viewModel.view=e)}get icon(){return"measure-building-height-shadow"}set icon(e){this._overrideIfSome("icon",e)}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get testData(){}_connectTimeSlider({viewModel:e,slider:t}){if(this.removeHandles("slider"),null==t)return;const o=e=>a(e,"milliseconds","minutes"),s=e=>a(e,"minutes","milliseconds"),l=({index:i,value:t})=>{0===i?e.startTimeOfDay=s(t):e.endTimeOfDay=s(t)},d=()=>V(t.domNode);d(),this.addHandles([n(()=>[e.startTimeOfDay,e.endTimeOfDay],e=>{t.values=e.map(o)},r),t.on("thumb-change",l),t.on("thumb-drag",l),t.on("segment-drag",()=>{[e.startTimeOfDay,e.endTimeOfDay]=t.values.map(s)}),i(d)],"slider")}_renderTimeRangeSection(){const{visibleElements:e}=this;return e.timeRangeSlider||e.datePicker?O("section",{class:u.timeRange,key:"time-range"},O(S,{level:this.headingLevel},this.messages.timeLabel),e.timeRangeSlider?this._renderTimeRange():null,e.datePicker?this._renderDatePicker():null):null}_renderTimeRange(){const{messages:e,viewModel:i,visibleElements:o}=this,{startTimeOfDay:s,endTimeOfDay:l}=i,[n,r]=[s,l].map(e=>t(new Date(e),j));return[O("div",{class:u.timeRangeIndicator,key:"time-range-indicator"},m(e.timeRange,{start:n,end:r}),o.timezone?O(z,{disabled:this._timeSlider?.disabled,value:i.utcOffset,onChange:this._onTimezoneChange}):null),O("div",{afterCreate:this._timeSliderContainerAfterCreate,afterRemoved:this._timeSliderContainerAfterRemoved,bind:this,key:"time-slider-container"})]}_timeSliderContainerAfterCreate(e){const i=this._timeSlider?.container;i&&e.appendChild(i)}_timeSliderContainerAfterRemoved(e){const i=this._timeSlider?.container;i&&e.removeChild(i)}_renderDatePicker(){return O("div",{class:u.datePickerContainer,key:u.datePickerContainer},O("calcite-input-date-picker",{class:u.datePicker,"data-testid":"date-picker",key:u.datePicker,overlayPositioning:"fixed",placement:"bottom",scale:"s",valueAsDate:this.viewModel.date,onCalciteInputDatePickerChange:this._onDateChange}))}_renderVisualizationOptionsSection(){const{headingLevel:e,messages:i,viewModel:t,visibleElements:o}=this,{colorPicker:s,thresholdContext:l,thresholdContextToggle:n,thresholdContextTimeInterval:r,thresholdContextColor:a}=o,d=e=>this.classes(t.visualizationType===e?null:u.visualizationConfigHidden);return O("section",{class:u.visualization,key:"visualization"},O(S,{level:e},i.visualizationLabel),this._renderVisualizationSelect(),O("div",{class:d("threshold"),key:"threshold-configurator"},O(C,{colorPickerVisible:s,contextColorPickerVisible:a,contextTimeIntervalVisible:r,contextToggleVisible:n,contextVisible:l,options:t.thresholdOptions})),O("div",{class:d("duration"),key:"duration-configurator"},O(f,{colorPickerVisible:s,options:t.durationOptions})),O("div",{class:d("discrete"),key:"discrete-configurator"},O(w,{colorPickerVisible:s,options:t.discreteOptions})))}_renderVisualizationSelect(){const e=this.messages,i=this.viewModel.visualizationType;return O("calcite-select",{bind:this,class:u.visualizationSelect,key:"visualization-select",label:e.visualizationLabel,scale:"s",onCalciteSelectChange:this._onVisualizationTypeChange},[{type:"threshold",label:e.threshold.label},{type:"duration",label:e.duration.label},{type:"discrete",label:e.discrete.label}].map(({type:e,label:t})=>O("calcite-option",{selected:e===i,value:e},t)))}_onVisualizationTypeChange(e){const i=e.currentTarget.selectedOption?.value;this.viewModel.visualizationType=i??"threshold"}};e([d()],E.prototype,"viewModel",void 0),e([d()],E.prototype,"view",null),e([d()],E.prototype,"headingLevel",void 0),e([d()],E.prototype,"icon",null),e([d()],E.prototype,"label",null),e([d({type:g,nonNullable:!0})],E.prototype,"visibleElements",void 0),e([d(),D("esri/widgets/ShadowCast/t9n/ShadowCast")],E.prototype,"messages",void 0),e([d()],E.prototype,"_defaultViewModel",void 0),e([d()],E.prototype,"_timeSlider",void 0),e([d()],E.prototype,"_tooltip",void 0),E=e([c("esri.widgets.ShadowCast")],E);const x=E;export{x as default};