@arcgis/core 5.0.0-next.130 → 5.0.0-next.131

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 (134) hide show
  1. package/applications/Components/OrientedImageryViewer/galleryUtils.d.ts +45 -15
  2. package/applications/Components/QuantityFormatter.d.ts +11 -11
  3. package/applications/Components/SelectionOperation.d.ts +11 -11
  4. package/applications/Components/SketchTooltipControls.d.ts +9 -9
  5. package/applications/Components/actionUtils.d.ts +2 -1
  6. package/applications/Components/analysisUtils.d.ts +27 -26
  7. package/applications/Components/applySetUtils.d.ts +40 -40
  8. package/applications/Components/arcadeEditorUtils.d.ts +3 -3
  9. package/applications/Components/arcadeFeatureUtils.d.ts +12 -12
  10. package/applications/Components/baUtils.d.ts +8 -8
  11. package/applications/Components/basemapUtils.d.ts +2 -2
  12. package/applications/Components/clipboard.d.ts +14 -14
  13. package/applications/Components/drawUtils.d.ts +3 -3
  14. package/applications/Components/editUtils.d.ts +14 -14
  15. package/applications/Components/featureUtils.d.ts +10 -10
  16. package/applications/Components/fieldFormatUtils.d.ts +2 -2
  17. package/applications/Components/fontUtils.d.ts +2 -2
  18. package/applications/Components/formatUtils.d.ts +2 -2
  19. package/applications/Components/getDefaultUnits.d.ts +2 -2
  20. package/applications/Components/gfxUtils.d.ts +5 -1
  21. package/applications/Components/imageryUtils.d.ts +35 -35
  22. package/applications/Components/layerOriginUtils.d.ts +5 -5
  23. package/applications/Components/layersEffectsJsonUtils.d.ts +2 -2
  24. package/applications/Components/previewSymbol2D.d.ts +2 -2
  25. package/applications/Components/rasterFunctionEditorUtils.d.ts +40 -40
  26. package/applications/Components/reactiveUtils.d.ts +14 -13
  27. package/applications/Components/sanitizerUtils.d.ts +2 -2
  28. package/applications/Components/stringUtils.d.ts +5 -5
  29. package/applications/Components/styleUtils.d.ts +2 -2
  30. package/applications/Components/svgUtils.d.ts +4 -4
  31. package/applications/Components/symbolUtils.d.ts +47 -11
  32. package/applications/Components/templateUtils.d.ts +73 -17
  33. package/applications/Components/templateUtils.js +1 -1
  34. package/applications/Components/testUtils.d.ts +3 -3
  35. package/applications/Components/unitUtils.d.ts +1 -1
  36. package/applications/Components/viewUtils.d.ts +2 -2
  37. package/applications/Components/webStyleSymbolUtils.d.ts +2 -2
  38. package/applications/Excalibur/imageryLayerUtils.d.ts +3 -3
  39. package/applications/Excalibur/videoViewUtils.d.ts +8 -8
  40. package/applications/Excalibur/widgetUtils.d.ts +2 -2
  41. package/applications/ExperienceBuilder/sketchUtils.d.ts +7 -7
  42. package/applications/KnowledgeStudio/dataModelVisualization.d.ts +20 -8
  43. package/applications/KnowledgeStudio/generalSdkInternalAccess.d.ts +21 -21
  44. package/applications/KnowledgeStudio/generalSharedKgUtils.d.ts +35 -35
  45. package/applications/KnowledgeStudio/layerInternalAccessUtils.d.ts +9 -9
  46. package/applications/KnowledgeStudio/reshape.d.ts +40 -40
  47. package/applications/KnowledgeStudio/resourceSerializationUtils.d.ts +11 -11
  48. package/applications/MapViewer/layerUtils.d.ts +2 -2
  49. package/applications/MapViewer/mediaUtils.d.ts +13 -13
  50. package/applications/MapViewer/templateUtils.d.ts +20 -20
  51. package/applications/PortalApp/layerUtils.d.ts +2 -2
  52. package/applications/SceneViewer/colorUtils.d.ts +2 -2
  53. package/applications/SceneViewer/devEnvironmentUtils.d.ts +4 -3
  54. package/applications/SceneViewer/layerUtils.d.ts +3 -3
  55. package/applications/SceneViewer/sceneViewerUtils.d.ts +34 -34
  56. package/applications/SceneViewer/symbolUtils.d.ts +2 -2
  57. package/applications/Urban/LineImagePattern3D.d.ts +3 -2
  58. package/applications/Urban/imagePatternUtils.d.ts +4 -4
  59. package/applications/Urban/meshUtils.d.ts +2 -2
  60. package/applications/WebEditor/sketchUtils.d.ts +8 -8
  61. package/assets/esri/core/workers/RemoteClient.js +1 -1
  62. package/assets/esri/core/workers/chunks/1dcd057695f8db79eca2.js +1 -0
  63. package/assets/esri/core/workers/chunks/1f3074ab4dc6e2eff97e.js +1 -0
  64. package/assets/esri/core/workers/chunks/{5746140c33cb206ad4b8.js → 22181db586c6ccbcb279.js} +1 -1
  65. package/assets/esri/core/workers/chunks/58ef550435cef99d99ff.js +1 -0
  66. package/assets/esri/core/workers/chunks/{56e3c34ebdee61ff4b33.js → 75bf83c6367227712a11.js} +1 -1
  67. package/assets/esri/core/workers/chunks/844771d532b5352dc848.js +1 -0
  68. package/assets/esri/core/workers/chunks/{9332db133a0925d522fe.js → b9c9dd3621b92212b104.js} +1 -1
  69. package/assets/esri/core/workers/chunks/c3e4f8664988e50bda55.js +1 -0
  70. package/assets/esri/core/workers/chunks/cf100c80b75ba74b479c.js +1 -0
  71. package/assets/esri/core/workers/chunks/ef8cc520d3977759b80c.js +1 -0
  72. package/config.js +1 -1
  73. package/geometry/support/curves/curveUtils.js +1 -1
  74. package/geometry/support/curves/densifyCurvedGeometry.js +1 -1
  75. package/graphic/graphicOriginUtils.js +1 -1
  76. package/kernel.js +1 -1
  77. package/layers/WMTSLayer.js +1 -1
  78. package/layers/graphics/editingSupport.js +1 -1
  79. package/layers/support/Sublayer.d.ts +3 -0
  80. package/package.json +1 -1
  81. package/rest/featureService/FeatureService.js +1 -1
  82. package/smartMapping/support/utils.js +1 -1
  83. package/support/revision.js +1 -1
  84. package/symbols/cim/GeometryWalker.js +1 -1
  85. package/symbols/cim/effects/EffectDashes.js +1 -1
  86. package/symbols/cim/placements/PlacementAlongLineSameSize.js +1 -1
  87. package/symbols/cim/placements/PlacementAtRatioPositions.js +1 -1
  88. package/symbols/cim/rasterizingUtils.js +1 -1
  89. package/views/2d/engine/webgl/shaders/sources/shaderRepository.js +1 -1
  90. package/views/View.d.ts +13 -2
  91. package/views/draw/support/Reshape.js +1 -1
  92. package/views/draw/support/reshapeUtils.js +1 -1
  93. package/views/interactive/support/utils.js +1 -1
  94. package/widgets/Attribution/AttributionViewModel.d.ts +3 -1
  95. package/widgets/Attribution/AttributionViewModel.js +1 -1
  96. package/widgets/Attribution.d.ts +1 -1
  97. package/widgets/Attribution.js +1 -1
  98. package/widgets/Editor/CreateFeaturesWorkflow.js +1 -1
  99. package/widgets/Editor/EditorViewModel.d.ts +2 -22
  100. package/widgets/Editor/EditorViewModel.js +1 -1
  101. package/widgets/Editor/SplitFeatureWorkflow.js +1 -1
  102. package/widgets/Editor/UpdateWorkflow.js +1 -1
  103. package/widgets/Editor/Workflow.js +1 -1
  104. package/widgets/Editor/support/SketchController.js +1 -1
  105. package/widgets/Editor/workflowUtils.js +1 -1
  106. package/widgets/Editor.d.ts +10 -15
  107. package/widgets/Editor.js +1 -1
  108. package/widgets/FeatureTable/FeatureTableViewModel.d.ts +0 -15
  109. package/widgets/FeatureTable/FeatureTableViewModel.js +1 -1
  110. package/widgets/FeatureTable/support/types.d.ts +0 -1
  111. package/widgets/FeatureTable.d.ts +1 -19
  112. package/widgets/FeatureTable.js +1 -1
  113. package/widgets/HistogramRangeSlider.d.ts +1 -1
  114. package/widgets/OrientedImageryViewer/OrientedImageryViewerViewModel.js +1 -1
  115. package/widgets/OrientedImageryViewer/adapters/sketch/MeasurementAdapter.js +1 -1
  116. package/widgets/OrientedImageryViewer/adapters/view/MapViewAdapter.js +1 -1
  117. package/widgets/PanoramicVideoViewer.js +1 -1
  118. package/widgets/PanoramicViewer/PanoramicVideoViewerViewModel.js +1 -1
  119. package/widgets/PanoramicViewer/support/PanoramicMedia.js +1 -1
  120. package/widgets/PanoramicViewer/support/PanoramicTileNode.js +1 -1
  121. package/widgets/PanoramicViewer/support/PanoramicTilePyramid.js +1 -1
  122. package/widgets/PanoramicViewer/utils.js +1 -1
  123. package/widgets/Sketch/SketchViewModel.d.ts +4 -22
  124. package/widgets/Sketch/SketchViewModel.js +1 -1
  125. package/widgets/Sketch/support/PluginManager.js +1 -1
  126. package/widgets/Sketch.d.ts +10 -17
  127. package/widgets/Sketch.js +1 -1
  128. package/assets/esri/core/workers/chunks/5a8b3e5977c233d5c9d0.js +0 -1
  129. package/assets/esri/core/workers/chunks/71ad08a5b69cf2e6714e.js +0 -1
  130. package/assets/esri/core/workers/chunks/7ec83fc059325e207825.js +0 -1
  131. package/assets/esri/core/workers/chunks/a7d4d257f49f3b153c26.js +0 -1
  132. package/assets/esri/core/workers/chunks/bf2bfc0d78be8c185d58.js +0 -1
  133. package/assets/esri/core/workers/chunks/e081d6f21a2c01ccaf61.js +0 -1
  134. package/assets/esri/core/workers/chunks/eae1c098c16e2faaf90d.js +0 -1
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.0/LICENSE.txt */
2
- import{__decorate as e}from"tslib";import t from"../../Graphic.js";import{equals as i,isSome as a}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 l}from"../../core/Evented.js";import{makeHandle as c}from"../../core/handleUtils.js";import{equalsShallow as h}from"../../core/lang.js";import d from"../../core/Logger.js";import{clamp as u}from"../../core/mathUtils.js";import{destroyMaybe as p,abortMaybe as m}from"../../core/maybe.js";import{EsriPromise as g}from"../../core/Promise.js";import{isAbortError as y,throwIfAborted as v,waitTick as f}from"../../core/promiseUtils.js";import w from"../../core/ReactiveMap.js";import{whenOnce as F,on as _,watch as M,syncAndInitial as b,initial as I,when as V}from"../../core/reactiveUtils.js";import{sqlAnd as P}from"../../core/sql.js";import{getMetersPerUnitForSR as S}from"../../core/units.js";import{property as A,subclass as C}from"../../core/accessorSupport/decorators.js";import{isSerializable as k}from"../../core/support/jsonUtils.js";import{UpdatingHandles as T}from"../../core/support/UpdatingHandles.js";import L from"../../geometry/Extent.js";import j from"../../geometry/Point.js";import{projectAsync as G}from"../../geometry/projectionUtils.js";import O from"../../geometry/SpatialReference.js";import{polygonCentroidPoint as E}from"../../geometry/support/centroid.js";import{isClockwise as x}from"../../geometry/support/coordsUtils.js";import{normalizeMapX as B}from"../../geometry/support/normalizeUtils.js";import{geographicToWebMercator as R}from"../../geometry/support/webMercatorUtils.js";import H from"../../layers/GraphicsLayer.js";import D from"../../layers/MediaLayer.js";import{searchImages as z,getSortedLayerFeatures as N}from"../../layers/orientedImagery/queries.js";import{calculateSuitabilities as U}from"../../layers/orientedImagery/core/bestImageUtils.js";import{createCoveragePolygon as q,computePolygonForInspection as $,resizePolygon as W,checkIfPolygonContainsSelectedPoint as J}from"../../layers/orientedImagery/core/coverageUtils.js";import{isElevationSource as Z}from"../../layers/orientedImagery/core/ElevationSourceDefinitions.js";import{getMetersPerUnitOfSR as K,convertGeographicToWebMercator as Q}from"../../layers/orientedImagery/core/utils.js";import X from"../../layers/orientedImagery/transformations/updateElevation.js";import{getElevationSampler as Y}from"../../layers/orientedImagery/transformations/updateElevationUtils.js";import{or as ee,getInitialAngle as te,convertPixelLocationToSphereVertex as ie,getUpdateElevationProps as ae,getImageToWorldProperties as re,getImageToWorldPanoramicProperties as se}from"../../layers/orientedImagery/transformations/utils.js";import oe from"../../layers/support/ExtentAndRotationGeoreference.js";import{getFloorFilterClause as ne}from"../../layers/support/floorFilterUtils.js";import le from"../../layers/support/VideoElement.js";import ce from"../../views/MapView.js";import he from"../../views/draw/Draw.js";import{scale as de}from"../../views/draw/support/drawUtils.js";import{ViewEventPriorities as ue}from"../../views/input/InputManager.js";import pe from"../PanoramicVideoViewer.js";import me from"../PanoramicViewer.js";import{defaultAngleThresholdInDegrees as ge,videoMapViewConstraint as ye,clockwiseDirections as ve,sampleExtent as fe,videoExtent as we,invalidCameraHeading as Fe,sectorsInOrder as _e,sectorsRadii as Me,fixedImageSize as be}from"./constants.js";import{isFeatureAttachment as Ie}from"./galleryUtils.js";import{crossSymbol as Ve,crossSymbol3D as Pe,measurementPolygonSymbol as Se,polylineSymbolPanoramic as Ae,measurementPolylineSymbol as Ce,cameraOverlaySymbol3D as ke,cameraOverlaySymbol as Te,diamondSymbol as Le,diamondSymbol3D as je,activeSourcePointSymbol as Ge,sourcePointSymbol as Oe}from"./symbols.js";import{registryKeys as Ee}from"./types.js";import{isNoAttachmentError as xe,extractHorizonAnglesFromMedia as Be,isTifOrMrf as Re,filterOILLayerView as He,assignElevationSampleToFeatures as De,filterByZ as ze,createPanoramicMedia as Ne,createNonPanoramicMedia as Ue,isSceneView as qe,isGraphic as $e,calculateSegment as We,calculateDirection as Je}from"./utils.js";import{disableVideoZoomAndPan as Ze,getUpdatedConstraints as Ke,getUpdatedExtentPoints as Qe}from"./videoViewerUtils.js";import Xe from"./components/ImageViewer.js";import Ye from"./components/NavigationNode.js";import et from"./components/OrientedImageryVideoViewModel.js";import{NoFeatureFoundWithObjectIdError as tt}from"./navigation/errors.js";import{queryFeatureByObjectIds as it}from"./navigation/queries.js";import{ImageMeasurementService as at}from"./services/ImageMeasurementService.js";import{configureSketchTool as rt,extractFieldsFromDataCaptureLayer as st,constructGraphicFromImageGeometry as ot}from"./support/dataCaptureUtils.js";import{imageSpaceToPoint as nt,removeZFromGeometry as lt}from"./support/geometryUtils.js";import ct from"./support/resolveMediaProps.js";import{isValidDataCaptureLayer as ht}from"./support/typeUtils.js";const dt=()=>new n("orientedimageryviewer:sketch-not-initialized","Sketch property is not initialized, call loadSketch first");let ut=class extends(l(g)){constructor(e){super(e),this.additionalFeatures=new s,this.additionalCameraLocations=new s,this.additionalFootprints=new s,this.areaMeasurementResult=0,this.areaMeasurementAccuracy=0,this.bestFeatureAngle=0,this.bestFeatureCurrentFootprint=null,this.bestFeatureFootprint=null,this.cameraHeadingThreshold=ge,this.cameraPitchThreshold=ge,this.clickAction="hittest",this.correctedLocationPointOnImage=null,this.videoViewModel=null,this.collectionId=null,this.coverageFrustums=new s,this.coveragePolygons=new s,this.currentBestFeature=null,this.currentBestFeatureMeasurementImage=null,this.currentBestFeatureLocation=null,this.currentCoverageVisible=!0,this.depthImage=null,this.featureCache=[],this.navigationNodes=new s,this.determineWorkflowForFeature=async(e,t,i)=>{const{currentBestFeature:a,selectedPoint:r}=this;if(this.emit("popup-close"),a&&r){this._initialCurrentCoverageUpdate=!0,this._updateGroundElevation=!0;try{await this._updatePointsAndPolygons(i),await this._loadDepthImage(i),await this._loadImage(i)}catch(s){y(s)||(this.loadImageError(s),d.getLogger(this).error("#loadIImage()","error occured while loading image",s))}}},this.determineWorkflowForTriangularMeasurement=async(e,t,i)=>{if(this.emit("popup-close"),this.currentBestFeatureMeasurementImage&&this.selectedPoint)try{await this._loadMeasurementViewerImage(i)}catch(a){y(a)||(this.loadImageError(a),d.getLogger(this).error("#loadIImage()","error occured while loading image",a))}},this.disabled=!1,this.displayMessage={key:"onLoadMessage",type:"info"},this.displayNewMeasurementButton=!0,this.distanceMeasurementResult=0,this.distanceAccuracyArray=[],this.dataCaptureLayer=null,this.features=new s,this.groundCoordinates=null,this.groundCoordinatesAccuracy=null,this.heightGraphic=null,this.heightMeasurementResult=0,this.heightMeasurementAccuracy=0,this.imageGeometryField=null,this.imageLocationToolState=!1,this.initialVideoMapViewExtent=null,this.imageMeasurementViewer=new Xe,this.isAdditionalCoverageVisible=!1,this.isAdditionalPointSourcesVisible=!1,this.layer=null,this.localPort=null,this.locationPointOnImage=null,this.mapImageConversionToolState=!1,this.measureType=null,this.measurementGraphic=null,this.navigatorCurrentBestFeature=null,this.oiObjectIdField=null,this.overlayedCameraLocations=new s,this.overlayedMapFeatures=new w,this.pixelCoordinates=null,this.preserveAngle="none",this.pointSources=new s,this.preloadMedia=!1,this.preloadMediaSize=5,this.previousFeatureAngle=0,this.selectedPoint=null,this.shouldShowSelectedImage=!1,this.sketch=null,this.sketchTriangular=null,this.sketchTriangularGraphicsLayer=null,this.draw=null,this.drawAdapter=null,this.polylineDrawAction=null,this.scheduledFrameId=null,this.sketchAdapter=null,this.triangularMeasurementActive=!1,this.triangulatedDistanceMeasurement=null,this.triangulatedDistanceAccuracy=null,this.triangulatedAreaMeasurement=null,this.triangulatedAreaAccuracy=0,this.triangulatedMeasurementGraphic=null,this.triangulatedPoint=null,this.triangulatedMeasurementAdapter=null,this.updateFootprint=async(e,t,i)=>{"default"===this.mode&&"image-loaded"!==this.state||await(this._adapter?.updateFootprint(e,t,i))},this.updateVideoFootprint=async e=>{this.mode.includes("video")&&this.videoElement?.content&&await(this._adapter?.updateVideoFootprint(e))},this.updateFootprintPanorama=async(e,t)=>{await(this._adapter?.updateFootprintPanorama(e,t))},this.updatingTriangularMeasurementState=!1,this.videoElement=null,this.videoLayer=null,this.videoMapView=new ce({map:new Map,constraints:ye}),this.verticalFilterEnabled=!1,this._adapter=null,this._highlightedFeatureHandle=null,this._imageViewer=new Xe,this._initialCurrentCoverageUpdate=!0,this._locationViewModel=null,this._measurementService=null,this._mediaPrefetcher=null,this._navigationManager=null,this._overlays=new H({listMode:"hide",internal:!0,elevationInfo:{mode:"absolute-height"},title:"OrentedImageryViewerViewModel overlays layer"}),this._panoramicVideoViewer=new pe,this._panoramicViewer=new me,this._panoramicMeasurementViewer=new me,this._referencePointOnGround=null,this._referencePointOnImage=null,this._referenceTransformationService=null,this._sectorData=null,this._transformationService=null,this._featureToSector=null,this._updatingHandles=new T,this._clickTask=null,this._crossSymbol=null,this.footprintExtent=null,this._featureChangedTask=null,this._mediaPrefetchTask=null,this._suitabilities=null,this._transformController=new AbortController,this._updateFootprintTask=null,this._updateGroundElevation=!1,this.addUpdatingPromise=e=>this._updatingHandles.addPromise(e),this.filterCapturedFeatures=e=>{const t=this.currentBestFeature?.attributes.objectId,i=this.layer?.imageReferenceField;if(!t||!e||!i)return;const a=this.overlayedMapFeatures.get(e);a?.forEach(e=>{const a=e.attributes??{},r=Object.keys(a).find(e=>e.toLowerCase()===i.toLowerCase());(r?a[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:i}=await t;return v(e),this.sketchAdapter=new i({viewModel:this}),this.sketchAdapter},this.loadImageFromFeature=async(e,t,i)=>this._updatingHandles.addPromise(this._loadImageFromFeature(e,t,i)),this.storeImageMeasurementViewer=e=>{this.imageMeasurementViewer=e},this.storePanoramicMeasurementViewer=e=>{this._panoramicMeasurementViewer=e},this.loadImageViewer=e=>{this._imageViewer?.destroy(),this._imageViewer=e},this.loadPanoramicViewer=e=>{this._panoramicViewer?.destroy(),this._panoramicViewer=e},this.loadPanoramicVideoViewer=e=>{this._panoramicVideoViewer?.destroy(),this._panoramicVideoViewer=e},this.loadVideoViewer=e=>{this.videoMapView.container=e},this.showImageByObjectId=async(e,t)=>{const i=this.additionalFeatures.find(({attributes:t})=>t.objectId===e);if(i)this.currentBestFeature=i;else{const{layer:i,layerFloorFilterClause:r,layerTimeExtent:s}=this;if(!i)return void this.setMessage("noLayerSelected","info");this.beforeLoad();const o=this._updatingHandles.addPromise(this._queryAndLoadByObjectId(i,e,r,s,t));try{await o,await this.selectBestFeature(e,t)}catch(a){y(a)||(d.getLogger(this).error("oriented-imagery-viewer:show-image",a),"NoFeatureFoundWithObjectIdError"===a.name?this.setMessage("noFeatureFoundWithObjectId","error","",{objectId:e}):this.setMessage("imageLoadError","error",a.message))}}},this.getSectorFeatureById=e=>this._suitabilities?.find(({feature:{attributes:{objectId:t}}})=>t===e),this.getFeatureSectorById=e=>this._featureToSector?.[`${e}`],this.navigate=async(e,t)=>{const{mode:i}=this;if("default"!==i&&"panoramic"!==i)throw new n("NavigationError","Navigation is only supported in 'default' and 'panoramic' modes.");const a=e=>"default"===i&&e.declaredClass.endsWith("NavigationManager")||"panoramic"===i&&e.declaredClass.endsWith("NavigationManagerPanoramic");if(null==this._navigationManager||!a(this._navigationManager)){p(this._navigationManager);const e="default"===i?import("./navigation/NavigationManager.js"):import("./navigation/NavigationManagerPanoramic.js");this._navigationManager=new(await e).default({viewModel:this})}return this._navigationManager.navigate(e,t)},this.removeHighlight=()=>this._highlightedFeatureHandle?.remove(),this.revealImageGeometry=e=>{},this.selectBestFeature=async(e,t)=>(v(t),this.currentBestFeature=this.features?.find(({attributes:t})=>`${t.objectId}`==`${e}`),F(()=>"image-loaded"===this.state,t)),this.toggleImageAttributes=()=>{const{currentBestFeature:e,popupEnabled:i,layer:a,view:r}=this;if(this.emit("popup-close"),!(r&&e&&i&&a))return;const{attributes:s,geometry:o}=e,n=new t({geometry:o,attributes:s.toJSON(),origin:a.graphicOrigin});this.emit("popup-open",{features:[n],location:s.location.clone()})},this.updateSuitabilities=(e,t=!0)=>{e.sort((e,t)=>e.suitability-t.suitability),this._suitabilities=e;const i=this._suitabilities.map(({feature:e})=>e);this._initialCurrentCoverageUpdate=!0,this._updateFeatures(i,t),this._groupFeaturesBySectors()},this._createViewClickHandle=()=>{if(this.removeHandles(Ee.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,ue.DEFAULT),Ee.click)},this._createImageClickHandle=()=>{this.removeHandles(Ee.imageClick);const{mapImageConversionToolState:e,mode:t,activeViewer:i,currentBestFeature:a,footprintExtent:s}=this,o=i?.imageSize;if(!(e&&"none"!==t&&o&&s&&a))return;const n=i.clickAction;this.clickAction="pixel-location";const l=c(()=>{this.clickAction=n});let h=null;const d=_(()=>i,"pixel-location",e=>{this.plotReferencePointOnImage(e),h?.abort(),h=r(async t=>{if(!e)return;const i=await this._transformationService.pixelToMapPoint(e).then(e=>{const t=this.view?.spatialReference;return ee(!t,e.spatialReference.equals(t))?e:G(e,t)});v(t),this.plotReferencePointOnGround(i)})});this.addHandles([d,l],Ee.imageClick)},this._createTriangularImageClickHandle=()=>{this.removeHandles(Ee.triangularImageClick),this.triangularMeasurementActive&&"none"!==this.mode&&this.currentBestFeature&&this.currentBestFeatureMeasurementImage&&this.activeTriangulatedViewer&&this.addHandles(this.activeTriangulatedViewer.imageRenderer.on("double-click",this._measurementImageClickHandler),Ee.triangularImageClick)},this._enablePan=()=>{this.removeHandles(Ee.videoPanHandles)},this._disablePan=()=>{this.removeHandles(Ee.videoPanHandles),this.addHandles(Ze(this.videoMapView),Ee.videoPanHandles)},this._handleImageHitTestResponse=async e=>{const{layer:t,overlayedCameraLocations:i}=this;if(!t)return;const a=e.results.find(({graphic:e,graphic:{attributes:a}})=>i.includes(e)&&a&&!a[t.imageReferenceField]&&!a[t.imageGeometryField]);if(!a)return;const r=a.graphic.attributes[t.objectIdField];await this.showImageByObjectId(r)},this._loadDepthImage=async e=>{const{currentBestFeature:t,layer:i,depthImageNotSupported:a}=this;if(this.depthImage?.destroy(),this.depthImage=null,!i||!t||a)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)||(d.getLogger(this).error("error occurred while loading depth image",o),this.depthImage?.destroy(),this.depthImage=null)}},this._loadImage=async e=>{const{currentBestFeature:t,layer:i,mode:a}=this;if(this.clearGraphics(),i&&t&&"none"!==a&&"video"!==a&&"panoramic-video"!==a)try{await this.loadImageFromFeature(i,t,e),v(e),await this.transformAndPlotSelectedLocation(e)}catch(r){y(r)||this.loadImageError(r)}},this._loadVideo=async e=>{const{currentBestFeature:t,mode:i,selectedPoint:a}=this,r=t?.attributes.imagePath;if(!t||"panoramic-video"!==i||!r)return;const{attributes:s}=t,{cameraPitch:o,cameraOrientation:n,location:l}=s,c=l.spatialReference.isWGS84&&4!==n?.type?R(l):new j(l);try{this._panoramicVideoViewer.viewModel.video&&(this._panoramicVideoViewer.viewModel.video.pause(),this._panoramicVideoViewer.viewModel.videoPaused=!0),this._panoramicVideoViewer.videoSource=r;let t=0;c&&a&&(t=await te(c,a)-t),this._panoramicVideoViewer.pitch=o??0,this._panoramicVideoViewer.yaw=t,await this._panoramicVideoViewer.loadVideo(e),v(e)}catch(h){y(h)||this.loadImageError(h)}},this._loadImageFromFeature=async(e,t,i)=>{const{mode:a}=this;if("default"!==a&&"panoramic"!==a)return;let r;try{r=await ct(t.attributes,e,i),v(i)}catch(f){if(y(f))return;return xe(f)?(d.getLogger(this).error(f),void this.setMessage("noAttachment","error",`${e.objectIdField}: ${t.attributes.objectId}`)):(d.getLogger(this).error(f,{[e.objectIdField]:t.attributes.objectId,layer:e}),void this.setMessage("imageLoadError","error",`query-attachments-failed:${e.objectIdField} ${t.attributes.objectId}`))}if(!r)return;const{mediaUrl:s,datasetFormat:o,rotation:n,searchParams:l,location:c,cameraHeading:h,matrix:u,cameraPitch:p,getDataSetFormatError:m}=r,g=`${t.attributes.objectId}`;try{let r=this._mediaPrefetcher?.getCachedMedia(g);if(!r){const i=this.navigationNodes.find(e=>e.id===t.attributes.objectId);if(i){try{await(this._mediaPrefetcher?.startPrefetchForNode(i,e))}catch(w){}r=this._mediaPrefetcher?.getCachedMedia(g)}}if(r){if("panoramic"===a){const e=this.triangularMeasurementActive?this._panoramicMeasurementViewer:this._panoramicViewer;let a=0;return c&&this.selectedPoint&&(a=await te(c,this.selectedPoint)-a),await e.loadMedia(r,i),this.selectedPoint?e.set({yaw:a,pitch:p}):"viewAngle"in t.attributes&&Number.isFinite(t.attributes.viewAngle)&&e.set({yaw:t.attributes.viewAngle,pitch:p}),void(this.triangularMeasurementActive?await this.initializeReferenceTransformationService(i):await this.initializeTransformationService(i))}return await this._setImageSource(this.triangularMeasurementActive?this.imageMeasurementViewer:this._imageViewer,r,i),void(this.triangularMeasurementActive?await this.initializeReferenceTransformationService(i):await this.initializeTransformationService(i))}}catch(w){}m&&d.getLogger(this).warn("error occurred while getting dataset format",m),"panoramic"===a?await this.loadPanoramicMediaSource({lookAt:{yaw:this.selectedPoint?await te(c,this.selectedPoint):"viewAngle"in t.attributes&&Number.isFinite(t.attributes.viewAngle)?t.attributes.viewAngle:0,pitch:p},extension:o?.toUpperCase(),url:s,cameraHeading:h,matrix:u},i):await this.loadMediaSource({datasetFormat:o?.toUpperCase(),url:s,customParameters:l,rotation:n},i),this.triangularMeasurementActive?await this.initializeReferenceTransformationService(i):await this.initializeTransformationService(i)},this._loadMeasurementViewerImage=async e=>{const{currentBestFeatureMeasurementImage:t,layer:i,mode:a}=this;if(this.imageMeasurementViewer.clearGraphics(),this._panoramicMeasurementViewer.clearGraphics(),i&&t&&"none"!==a&&"video"!==a&&"panoramic-video"!==a)try{await this.loadImageFromFeature(i,t,e),v(e)}catch(r){y(r)||this.loadImageError(r)}},this._loadMediaPrefetcher=async e=>{if(!this._mediaPrefetcher){const{default:t}=await import("./support/MediaPrefetcher.js");v(e),this._mediaPrefetcher=new t({maxEntries:this.preloadMediaSize*ve.length})}return this._mediaPrefetcher},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=B(t.x,t.spatialReference),this.plotMapPoint(e.mapPoint)}},this._measurementImageClickHandler=e=>{e.stopPropagation(),e.preventDefault();const{sketchTriangular:t,triangularMeasurementActive:i,currentBestFeatureMeasurementImage:a,triangulatedMeasurementGraphic:r}=this;t&&i&&a&&r&&"active"!==t.state&&(t.update([r],{tool:"reshape"}),this.updatingTriangularMeasurementState=!0)},this._updateInteraction=()=>{const e=this.videoMapView.extent;if(!e)return;if(e.width<fe.xmax-fe.xmin&&e.height<fe.ymax-fe.ymin){this._enablePan();const t=Ke(e);t&&(this.videoMapView.constraints.geometry=t)}else this.initialVideoMapViewExtent&&!this.videoMapView.extent.equals(this.initialVideoMapViewExtent)&&(this.videoMapView.extent=this.initialVideoMapViewExtent),this._disablePan(),this.videoMapView.constraints.geometry=null},this._viewClickHandler=e=>{this._clickTask?.abort(),this._clickTask=r(async t=>{const{pointerType:i,button:a,mapPoint:r}=e;if("mouse"===i&&0!==a||!r)return;e.stopPropagation(),e.preventDefault();const{view:s,layer:o}=this;if(s&&o){if(this.shouldShowSelectedImage){const i=s.hitTest(e,{include:[o]});this._updatingHandles.addPromise(i);const a=await i;return v(t),await this._processHitTestResults(o,a,{signal:t})}return this._updatingHandles.addPromise(this.loadBestImage(r,{signal:t}))}})},this.plotSelectedPointOnImage=async(e,i)=>{if(await f(i),!e)return;const a=new j({...k(e)?e.toJSON():e});if("default"===this.mode)a.x-=.5,a.y=.5-a.y,a.spatialReference=this._imageViewer.imageRenderer.spatialReference.clone(),this._crossSymbol=new t({geometry:a,symbol:Ve}),this._imageViewer.addGraphic(this._crossSymbol,0);else if("panoramic"===this.mode){const{imageSize:i,media:a}=this._panoramicViewer;if(!i||!a)return;const r=Be(a),s=ie(e,...i,r);this._crossSymbol=new t({geometry:new j(s,O.WebMercator),symbol:Pe}),this._panoramicViewer.addGraphic(this._crossSymbol,0)}},this.handleSectorClick=this.handleSectorClick.bind(this),this.searchBestImage=this.searchBestImage.bind(this),this.transformAndPlotReferencePointOnImage=this.transformAndPlotReferencePointOnImage.bind(this)}initialize(){this.addHandles([M(()=>this.view,()=>this.load(),b),M(()=>this.view?.map,(e,t)=>{t?.layers.remove(this._overlays),e?.layers.add(this._overlays)},I),M(()=>this.view?.map?.allLayers?.length,e=>{e&&this.view?.map?.layers.reorder(this._overlays,e-1)},I),M(()=>[this.state,this.mapImageConversionToolState,this.view,this.disabled],()=>{this._createViewClickHandle(),this._createImageClickHandle()},b),M(()=>[this.triangularMeasurementActive,this.currentBestFeatureMeasurementImage],()=>{this._createTriangularImageClickHandle()},b),M(()=>[this.state,this.imageLocationToolState,this.view],()=>{this._initializeMeasurementService(),this._initializeLocationViewModel()},b),M(()=>this.measureType,()=>{this.clearPreviousMeasurements(),this._initializeMeasurementService()},b),M(()=>this.bestFeatureAngle,(e,t)=>{this.previousFeatureAngle=t??0},b),M(()=>this.currentBestFeature,async(e,t)=>{m(this._featureChangedTask),this._featureChangedTask=r(async i=>this.determineWorkflowForFeature.apply(this,[e,t,{signal:i}])),await this._featureChangedTask.promise},{sync:!0}),M(()=>[this.currentNode,this.preloadMedia,this.navigationMode],()=>{this._mediaPrefetchTask?.abort(),this._mediaPrefetchTask=r(async e=>{this.preloadMedia&&null!=this.navigationMode?(this._mediaPrefetcher??=await this._loadMediaPrefetcher({signal:e}),v(e),"directional"===this.navigationMode?this._mediaPrefetcher.enqueueDirectionalPrefetch(this.layer,this.currentNode,this.preloadMediaSize):this._mediaPrefetcher.enqueueSequentialPrefetch(this.layer,this.currentNode,this.preloadMediaSize)):this._mediaPrefetcher?.clear()})},b),M(()=>this.currentBestFeatureMeasurementImage,(e,t)=>{m(this._featureChangedTask),t&&e!==t&&(this.triangulatedPoint=null,this.sketchTriangularGraphicsLayer?.graphics.destroyAll(),this._measurementService?.resetMeasurementVectors()),this._featureChangedTask=r(async i=>{await this.determineWorkflowForTriangularMeasurement(e,t,{signal:i}),v(i),this._reorderTriangularSketchLayer()})},b),M(()=>this.triangularMeasurementActive,(e,t)=>{t&&!e&&(this._measurementService?.resetMeasurementVectors(),this.currentBestFeatureMeasurementImage=null,this.triangulatedDistanceMeasurement=null,this.triangulatedMeasurementGraphic=null,this.triangulatedPoint=null,this.updatingTriangularMeasurementState=!1,this.triangulatedAreaMeasurement=null,this.triangulatedDistanceAccuracy=null,this.triangulatedAreaAccuracy=0,this.sketchTriangularGraphicsLayer?.graphics.destroyAll(),this.clearReferencePointOnImage(),this.imageMeasurementViewer.clearImage(),this.imageMeasurementViewer.clearGraphics(),this._panoramicMeasurementViewer.clearImage(),this._panoramicMeasurementViewer.clearGraphics())}),M(()=>this.mode,e=>{switch(this.removeHandles(Ee.interactionHandles),e){case"default":this.addHandles(M(()=>{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})}))},{...b,equals:(e,t)=>i(e,t,h)}),Ee.interactionHandles);break;case"video":this.addHandles(M(()=>{const{footprintExtent:e,videoElement:t,bestFeatureFootprint:i}=this;if(e&&t?.loaded&&i)return{videoExtent:we,bestFeatureFootprint:i}},e=>{e?.videoExtent&&e?.bestFeatureFootprint&&(m(this._updateFootprintTask),this._updateFootprintTask=r(async t=>{const i={points:e.videoExtent,feature:void 0,scale:void 0,options:{signal:t}};await this.updateVideoFootprint(i)}))},{...b,equals:(e,t)=>i(e?.videoExtent,t?.videoExtent,h)&&e?.bestFeatureFootprint===t?.bestFeatureFootprint}),Ee.interactionHandles);break;case"panoramic":this.addHandles(M(()=>{const{currentBestFeature:e,state:t,_panoramicViewer:i}=this,{imageSize:a,vfov:r,hfov:s,pitch:o,yaw:n}=i;return e&&a&&!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,i,a,s]=e;this.currentNode&&(this.currentNode.currentHeading=a,this.currentNode.currentPitch=s),m(this._updateFootprintTask),this._updateFootprintTask=r(async e=>{await this.updateFootprintPanorama({verticalFieldOfView:t,horizontalFieldOfView:i,yaw:a,pitch:s},{signal:e}),this._updateFootprintTask=null})},{equals:(e,t)=>i(e,t,h)}),Ee.interactionHandles);break;case"panoramic-video":this.addHandles(M(()=>{const{currentBestFeature:e,state:t,_panoramicVideoViewer:i}=this,{imageSize:a,vfov:r,hfov:s,pitch:o,yaw:n,viewModel:l}=i,c=l.closestFeature??e;return c&&a&&!t.includes("loading")&&null!=r&&null!=s&&null!=o&&null!=n?[r,s,n,o,c]:null},e=>{if(!e)return;const[t,i,a,s,o]=e;m(this._updateFootprintTask),this._updateFootprintTask=r(async e=>{await this.updateFootprintPanorama({verticalFieldOfView:t,horizontalFieldOfView:i,yaw:a,pitch:s,feature:o},{signal:e}),v(e),this._updateFootprintTask=null})},{equals:(e,t)=>i(e,t,h)}),Ee.interactionHandles)}},b),M(()=>[this.brightness,this.contrast,this.sharpness],()=>{const{_imageViewer:e,brightness:t,contrast:i,mode:a,sharpness:r}=this;"default"===a&&(e.brightness=t,e.contrast=i,e.sharpness=r)},b),M(()=>this.activeViewer?.imageRenderer,()=>{this.sketch&&(this.sketch.view=this.activeViewer?.imageRenderer)}),M(()=>this.activeViewer,e=>{this.removeHandles(Ee.hittestHandles),e&&this.addHandles(_(()=>e,"hittest-response",this._handleImageHitTestResponse),Ee.hittestHandles)}),M(()=>this.videoMapView.extent,async()=>{const e=this.videoViewModel?.closestFeature;e&&(m(this._updateFootprintTask),this._updateFootprintTask=r(async t=>{const i={points:this.videoExtentPoints,feature:e,options:{signal:t}};await this.updateVideoFootprint(i)}))}),M(()=>[this.videoMapView.interacting,this.videoMapView.navigating,this.videoMapView.scale],()=>{this.scheduledFrameId||(this.scheduledFrameId=requestAnimationFrame(()=>{this.scheduledFrameId=null,this._updateInteraction()}))},{initial:!0}),V(()=>null!=this.videoMapView.extent,()=>{this.initialVideoMapViewExtent=this.videoMapView.extent},{once:!0})]),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._locationViewModel=p(this._locationViewModel),this._crossSymbol=p(this._crossSymbol),this._referencePointOnGround=p(this._referencePointOnGround),this._referencePointOnImage=p(this._referencePointOnImage),this._overlays&&this.view?.map?.remove(this._overlays),this._overlays.destroy(),this._imageViewer.destroy(),this.imageMeasurementViewer.destroy(),this._panoramicViewer.destroy(),this._panoramicMeasurementViewer.destroy(),this._mediaPrefetcher?.destroy()}get activeLayer(){return o(d.getLogger(this),"activeLayer",{replacement:"layer"}),this.layer}set activeLayer(e){o(d.getLogger(this),"activeLayer",{replacement:"layer"}),this.layer=e}get activeViewer(){const{_imageViewer:e,_panoramicViewer:t,mode:i}=this;switch(i){case"default":return e;case"panoramic":return t;default:return null}}get activeTriangulatedViewer(){switch(this.mode){case"default":return this.imageMeasurementViewer;case"panoramic":return this._panoramicMeasurementViewer;default:return null}}get accuracyParametersMissing(){return this.layer?.orientationAccuracy?.every(e=>0===e)??!0}get brightness(){return this._get("brightness")??0}set brightness(e){this._set("brightness",u(e,-10,10))}get contrast(){return this._get("contrast")??0}set contrast(e){this._set("contrast",u(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!Re(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 Re(t)||Ie(t)}get imageLoaded(){return o(d.getLogger(this),"imageLoaded",{replacement:'Use OrientedImageryViewer.state === "image-loaded"',version:"4.29",warnOnce:!0}),"image-loaded"===this.state}get invalidCameraHeading(){return this.currentBestFeature?.attributes?.cameraHeading===Fe}get imagePointsInView(){const{mode:e,_imageViewer:t}=this;return"default"===e?t.imagePointsInView:null}get layerView(){const{layer:e,view:t}=this;if(e&&t)return t.allLayerViews.find(He(e))}get layerFloorFilterClause(){const{layerView:e}=this;return e?ne(e):null}get layerTimeExtent(){return this.layerView?.timeExtent??null}get mode(){const e=this.currentBestFeature?.attributes;if(!e)return"none";const t=e.orientedImageryType;if(t?.includes("video"))return t.includes("360")?"panoramic-video":"video";const{horizontalFieldOfView:i,isSpherical:a}=e;return 360===i||a?"panoramic":"default"}get panoramicVideoLoaded(){const{mode:e,_panoramicVideoViewer:t}=this,{videoLoaded:i}=t.viewModel;return("panoramic-video"===e&&!0===i)??!1}get popupEnabled(){return!0===this.layer?.popupEnabled}get referencePoint(){return this._referencePointOnGround?.geometry}get sectorData(){const{_sectorData:e}=this;return e?_e.map(t=>e[t]):null}get sharpness(){return this._get("sharpness")??0}set sharpness(e){this._set("sharpness",u(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:i}=this;if(!this.isFulfilled()||t||!1===i?.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:i,imageRotation:a}})=>{const r=e?.trim();return Re(r)||Ie(r)?{url:r,objectId:t,rotation:(i??0)+(a??0)}:null}).filter(a)):null}get videoExtentPoints(){const e=Qe(this.videoMapView.extent);return e.length?e:we}set view(e){this._set("view",e)}get _defaultGraphicsLayer(){const e={blendMode:"source-atop"};switch(this.mode){case"panoramic":return new H({...e,elevationInfo:{mode:"absolute-height"}});case"default":return new H({...e});default:return}}get _overlaysView(){return this.view?.layerViews.find(({layer:e})=>e===this._overlays)}beforeLoad(e=!0){this.emit("popup-close"),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 calculateLocationAccuracy(e){return this._measurementService?.calculateLocationAccuracy(e)}clearLocationPointOnImage(e=!1){this.locationPointOnImage&&!e&&(this._imageViewer.removeGraphic(this.locationPointOnImage),this._panoramicViewer.removeGraphic(this.locationPointOnImage),this.locationPointOnImage=p(this.locationPointOnImage)),this.correctedLocationPointOnImage&&(this.imageMeasurementViewer.removeGraphic(this.correctedLocationPointOnImage),this._panoramicMeasurementViewer.removeGraphic(this.correctedLocationPointOnImage),this.correctedLocationPointOnImage=p(this.correctedLocationPointOnImage))}clearPreviousMeasurements(){this.clearMeasurementGraphics(),this.resetMeasurementData(),this.stopMeasurement()}clearPreviousGroundLocation(){this.groundCoordinates=null,this.groundCoordinatesAccuracy=null,this.pixelCoordinates=null,this.clearLocationPointOnImage()}clearMeasurementGraphics(){this.measurementGraphic&&(this.activeViewer?.removeGraphic(this.measurementGraphic),this.measurementGraphic=null),this.heightGraphic&&(this.activeViewer?.removeGraphic(this.heightGraphic),this.heightGraphic=null),this.triangularMeasurementActive&&this.sketchTriangularGraphicsLayer?.graphics.destroyAll()}digitizeCancel(){return this.sketch?.cancel()}digitizeCanRedo(){return this.sketch?.canRedo()??!1}digitizeCanUndo(){return this.sketch?.canUndo()??!1}digitizeComplete(){return this.sketch?.complete()}async digitizeCreate(e,t){const{sketch:i,dataCaptureLayer:a}=this;if(!i)throw dt();rt(a,e,i),await i.create(e,{...t,defaultZ:0})}digitizeDelete(){if(!this.sketch)throw dt();return this.sketch.delete()}digitizeDuplicate(){if(!this.sketch)throw dt();return this.sketch.duplicate()}digitizePlace(e,t){if(!this.sketch)throw dt();return this.sketch.place(e,t)}digitizeRedo(){if(!this.sketch)throw dt();return this.sketch.redo()}digitizeUndo(){if(!this.sketch)throw dt();return this.sketch.undo()}digitizeUpdate(e,t){if(!this.sketch)throw dt();return this.sketch.update(e,t)}filterByFootprints(e,t,i=!1){const a=[],r=[],s=[];return e.forEach(e=>{const{layer:{coveragePercent:o},attributes:n}=e;let l;const{polygon:c,frustum:h}=q(n);if(l=c.clone(),n.isInspection&&(l=$(n)),o&&(l=W(l,o)),i||!t||J(l,t)){s.push(e);const{geometry:t,objectId:i,cameraHeight:o,cameraHeading:l}=n,d=t.clone();d.z=o/K(t.spatialReference),d.imageID=i,this.pointSources.push(d),l!==Fe&&(a.push(c),h&&r.push(h))}}),{features:s,polygons:a,frustums:r}}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?.[_e[e]],i=t?.at(0);i&&(this.triangularMeasurementActive&&this.currentBestFeature?this._updateImageMeasurementBestFeature(i):this._updateCurrentBestFeature(i))}handleFeatureClick(e){const{sector:t,featureIndexInSector:i}=e;if(isNaN(i))return;const a=this._sectorData?.[t],r=a?.at(i);r&&(this.triangularMeasurementActive&&this.currentBestFeature?this._updateImageMeasurementBestFeature(r):this._updateCurrentBestFeature(r))}load(e){return this.addResolvingPromise(this._loadViewAdapter(e).catch(e=>{if(!y(e))throw e})),this}async loadBestImage(e,t){return this.selectedPoint=Q(e),this.beforeLoad(),this._fetchFeaturesWithController(e,t)}async loadHeightMeasurementAdapter(e){if(!this.drawAdapter){const t=import("./adapters/draw/HeightMeasurementAdapter.js"),{default:i}=await t;if(v(e),this.drawAdapter=new i({viewModel:this,measurementService:this._measurementService}),!this.drawAdapter.viewModel.isResolved())return}return this.drawAdapter}loadImageError(e){d.getLogger(this).error("oriented-imagery-viewer:load-image",e),this.setMessage("imageLoadError","error",e.message)}async loadSketch(e){if(!this.sketch){const t=import("../Sketch/SketchViewModel.js"),{default:i}=await t;v(e),this.sketch=new i({layer:this._defaultGraphicsLayer,view:this.activeViewer?.imageRenderer,updateOnGraphicClick:!1,defaultUpdateOptions:{reshapeOptions:{edgeOperation:"none",shapeOperation:"none",vertexOperation:void 0},enableMoveAllGraphics:!1,enableRotation:!1,enableScaling:!1,multipleSelectionEnabled:!1,toggleToolOnClick:!1,tool:"transform"}})}return this.sketch}async loadMeasurementAdapter(e){if(!this.sketchAdapter){const t=import("./adapters/sketch/MeasurementAdapter.js"),{default:i}=await t;if(v(e),this.sketchAdapter=new i({viewModel:this,measurementService:this._measurementService}),!this.sketchAdapter.viewModel.isResolved())return}return this.sketchAdapter}async processFeatureResponse(e,t,i){const{features:a}=e;if(this._clearFeatureGeometries(),!this._checkFeatures(a))return;const{features:r,polygons:s,frustums:o}=this.filterByFootprints(a,t,i?.skipFilter);if(!this._checkFeatures(r))return;this.coveragePolygons.addMany(s),this.coverageFrustums.addMany(o);const n=await this.processElevationSample(s,r,i);v(i),await this._updateElevationOfSelectedPointAndLocations(r,t,n),v(i),De(r,n);let l=r;if(this.layer?.verticalSearchRange&&this.layer.hasZ&&this.verticalFilterEnabled&&(l=ze(r,t,this.layer.verticalSearchRange),!l.length))return void this.setMessage("noImageAtElevation","info");const c=this._processSuitableFeatures(l,t);this.updateSuitabilities(c,i?.loadBestImage)}async processFeatureElevation(e,t,i){if(!t)return;const{features:a,polygons:r}=this.filterByFootprints(e,t,!0);if(!a?.length)return;const s=await this.processElevationSample(r,a,i);return v(i),s}async startMeasurement(e,t){this.sketch||await this.loadSketch(t),await this.loadMeasurementAdapter(t);const{sketch:i,sketchAdapter:a,activeViewer:r,mode:s}=this;if(!i||!a||!r||"none"===s)return;if(this.displayNewMeasurementButton=!1,"panoramic"===s&&(i.defaultCreateOptions.defaultZ=0),await i.create(e),"panoramic"===s){const{drawOperation:e}=i.view.activeTool;e.constraintsEnabled=!1,e._set("elevationDrawSurface",null)}const o=this.activeViewer?.imageRenderer.effectiveTheme.accentColor;o&&this.sketch&&(this.sketch.polygonSymbol=Se(o),this.sketch.polylineSymbol="panoramic"===s?Ae:Ce(o,2.5))}async startHeightMeasurement(){this.displayNewMeasurementButton=!1,this.draw??=new he({view:this.activeViewer?.imageRenderer}),this.polylineDrawAction=this.draw.create("polyline"),await this.loadHeightMeasurementAdapter()}initializeMeasurement(e){switch(this.clearMeasurementGraphics(),this.resetMeasurementData(),e){case"distance":this.startMeasurement("polyline");break;case"area":this.startMeasurement("polygon");break;case"height":this.startHeightMeasurement()}}async overlayCameraLocations(e){const{activeViewer:i,currentBestFeature:a,overlayedCameraLocations:r,layer:s,mode:o,state:n,layerFloorFilterClause:l,layerTimeExtent:c}=this,h=i?.imageSize;if(!h||!a||!s||"default"!==o&&"panoramic"!==o||n.includes("loading"))return;const{polygon:d}=q(a.attributes);if(i.removeManyGraphics(r.toArray()),r.removeAll(),e){const{features:e}=await s.queryFeatures({where:P(`${s.objectIdField} <> ${a.attributes.objectId}`,P(s.definitionExpression,l)),geometry:d,returnGeometry:!0,outFields:[s.objectIdField],timeExtent:c}),n=await Promise.all(e.map(async e=>{const{attributes:i,geometry:a}=e,r=await this._transformationService.pointToImageGeometry(a),s="panoramic"===o?ke():Te();return new t({attributes:i,symbol:s,geometry:r})}));r.addMany(n),i.addManyGraphics(r.toArray())}}overlayGraphicsOnImage(e,t){this.removeOverlayedGraphicsOnImage(e),this.overlayedMapFeatures.set(e,t),this.activeViewer?.addManyGraphics(t.toArray())}async overlayMapFeatures(e,i=!1){const{activeViewer:a,currentBestFeature:r,mode:o,state:n,layer:l}=this,c=a?.imageSize;if(!c||!r||"none"===o||"video"===o||"panoramic-video"===o||n.includes("loading")||!l)return;const{polygon:h}=q(r.attributes);try{const{imageGeometryField:t,oiObjectIdField:i}=st(e,l.imageGeometryField,l.imageReferenceField);this.imageGeometryField=t.name,this.oiObjectIdField=i.name}catch(m){d.getLogger(this).warn("oriented-imagery-viewer:overlay-map-features",m)}const{features:u}=await e.queryFeatures({geometry:h,returnGeometry:!0,outFields:["*"]}),p=new s(await Promise.all(u.map(async s=>{const n=s.symbol?.clone()??e.renderer?.getSymbol(s)?.clone(),{attributes:l,geometry:h}=s,{imageGeometryField:u,oiObjectIdField:p}=this;if(u&&p&&ht(e,u,p)&&`${l[p]}`==`${r.attributes.objectId}`)try{const t=Be(a?.media);return ot(l,u,e,i,c,o,n,t)}catch(m){d.getLogger(this).warn("oriented-imagery-viewer:overlay-map-features","couldn't create graphic from attributes, geometry will be used",{error:m,feature:s,layer:e,imageGeometryField:this.imageGeometryField,imageReferenceField:this.oiObjectIdField})}const g=await this._transformationService.geometryToImageGeometry(h);return new t({attributes:l,layer:e,symbol:n,geometry:g,visible:e.visible&&i})})));this.overlayGraphicsOnImage(`${e.id}`,p)}getDepthAt(e){const{activeViewer:t,currentBestFeature:i,mode:a,state:r,depthImage:s}=this,o=t?.imageSize;if(!o||!i||"none"===a||r.includes("loading"))return d.getLogger(this).warnOnce("oriented-imagery-viewer:get-depth-at","Load an image to use depth"),null;if(!s?.loaded)return d.getLogger(this).error("oriented-imagery-viewer:get-depth-at","Depth image is not loaded"),this.emit("depth-image-service:not-loaded"),null;const n=(Array.isArray(e)?e:[e]).map(e=>s.depthAt(e,{width:o[0],height:o[1]})??null);return Array.isArray(e)?n:n[0]}getActiveSectors(){return _e.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 j({...e.toJSON()}),symbol:Le}),this.view?this._overlays?.add(this._referencePointOnGround):this.emit("plot-ground-point",{data:{point:this._referencePointOnGround?.geometry}}))}plotReferencePointOnImage(e){const{state:i,mode:a,activeViewer:r}=this;if("image-loaded"!==i||!r?.imageSize||"default"!==a&&"panoramic"!==a)return;this.clearReferencePointOnImage();const s=Be(r.media),o=nt(e,a,r.imageSize,s);this._referencePointOnImage=new t({geometry:o,symbol:"panoramic"===a?je.clone():Le.clone()}),r.addGraphic(this._referencePointOnImage,0)}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.heightMeasurementResult=0,this.heightMeasurementAccuracy=0,this.heightGraphic=null,this.triangulatedDistanceMeasurement=null,this.triangulatedDistanceAccuracy=null,this.triangulatedAreaMeasurement=null,this.triangulatedMeasurementGraphic=null,this.updatingTriangularMeasurementState=!1,this.triangulatedAreaAccuracy=0,this._measurementService?.resetMeasurementVectors()}async saveDrawing(){const{dataCaptureLayer:e,sketchAdapter:t}=this;if(!e||"data-capture"!==t?.type)return;const{pendingGraphics:i,savedGraphics:a}=t,r=i.get(e.id),s=r?.toArray();if(!r||!s?.length)return;const{addFeatureResults:o}=await this.saveDataCaptureFeatures(s),n=o.reduce((t,{objectId:i,globalId:a,error:r},o)=>{const n=s[o],{attributes:l}=n;return r?t.error.push(n):(i&&(l[e.objectIdField]=i),a&&e.globalIdField&&(l[e.globalIdField]=a),t.success.push(n)),t},{success:[],error:[]});a.addMany(n.success),r.removeAll(),r.addMany(n.error)}async saveDataCaptureFeatures(e,t){const{activeViewer:i,currentBestFeature:r,dataCaptureLayer:s,mode:o}=this,l=i?.imageSize;if(!l||!r||"none"===o||"video"===o||"panoramic-video"===o)throw new n("orientedimageryviewer:missing-input","Image size, current best feature and mode are required to save data capture features");if(!s)throw new n("orientedimageryviewer:missing-featurelayer","Data capture layer is not available");const c=await Promise.all(e.map(async e=>{const i=e.clone(),{geometry:a}=i;if(!a)return;const r=a.type,o=s.hasZ,n=s.geometryType,l=r!==n,c=l?await import("./transformers.js"):null,h=c?.default[n],d=l?h?.(a):a;return d&&(i.geometry=await this._transformationService.imageGeometryToMapGeometry(d,t),i.geometry)?(o||lt(i.geometry),i):void 0})),h=c.filter(a);return s.applyEdits({addFeatures:h}).then(e=>{const{addFeatureResults:t}=e;let i=0;const a=c.map(e=>{const a=t[i++];return e?a:{error:new n("orientedimageryviewer:save-unsucccessful","Error in saving data capture features"),objectId:null,globalId:null}});return{...e,addFeatureResults:a}})}async searchBestImage(e,t){try{const i=await z(e,t);i&&await this.processFeatureResponse(i,e.point,t)}catch(i){y(i)||(this.setMessage("imageLoadError","error",i.message),d.getLogger(this).error("error occurred while finding best image",i))}}selectTriangularMeasurementFeature(e){this.currentBestFeatureMeasurementImage=this.features?.find(({attributes:t})=>t.objectId===Number(e))}setAdditionalCameraLocationsVisibility(e){this.additionalCameraLocations.forEach(t=>{t.visible=e})}setAdditionalCoverageVisibility(e){this.additionalFootprints.forEach(t=>{t.visible=e})}setCurrentCoverageVisibility(e){this.bestFeatureCurrentFootprint&&(this.bestFeatureCurrentFootprint.visible=e),this.currentBestFeatureLocation&&(this.currentBestFeatureLocation.visible=e)}setMapImageConversionToolState(e){this.mapImageConversionToolState=e}setCurrentPanoramaView(e,t){this._panoramicViewer?.set({yaw:e,pitch:t})}async startDataCapture(e,t){const i=this.activeViewer?.imageRenderer,{oiObjectIdField:a,currentBestFeature:r}=this;if(!i||!r||!a)return;const{attributes:{objectId:o}}=r,n=this.overlayedMapFeatures.get(e.id)?.toArray()??[],l=[],c=[];for(const s of n)`${s.getAttribute(a)}`==`${o}`?l.push(s):c.push(s);this.overlayGraphicsOnImage(e.id,new s(c)),this.collectionId=e.id;const h=await this.loadSketch(t),d=await this.loadDataCaptureAdapter(t);v(t),h.addGraphics(l),d.savedGraphics.addMany(l);i.ui.find("zoom").visible=!1,i.map.layers.add(this.sketchGraphicsLayer)}async stopDataCapture(e=!1){this.sketch?.cancel(),this.sketchGraphicsLayer?.removeAll(),this.sketchAdapter=p(this.sketchAdapter),this.sketch=p(this.sketch),this.collectionId=null;const{dataCaptureLayer:t}=this,i=this.activeViewer?.imageRenderer;if(!i||i.destroyed)return;i.map.layers.remove(this.sketchGraphicsLayer),e&&t&&await this.overlayMapFeatures(t,!0);const a=i.ui.find("zoom");a&&(a.visible=!0)}stopMeasurement(){this.draw?.reset(),this.sketch?.cancel()}async toggleAllOverlayMapFeatures(e){!e&&this.dataCaptureLayer&&(await this.stopDataCapture(!0),this.dataCaptureLayer=null),this.overlayedMapFeatures.forEach(t=>{this._toggleVisiblity(t,e)})}toggleOverlayMapFeatures(e,t,i){const a=this.overlayedMapFeatures.get(e);a&&i&&this._toggleVisiblity(a,t)}toggleSelection(e){const{sketch:t}=this;t&&(t.updateOnGraphicClick=e,t.cancel())}async transformAndPlotReferencePointOnImage(e){const{selectedLocation:t,options:i}=e;let a=!1,r=!1;const s=this.bestFeatureFootprint?.geometry;switch(s?.type){case"polygon":{const e=t.spatialReference.equals(s.spatialReference)?t:await G(t,s.spatialReference);a=s.contains(e);break}case"mesh":{const e=t.spatialReference.equals(s.spatialReference)?t:await G(t,s.spatialReference);r=s.extent.contains(e);break}}if(!a&&!r)return void this.clearReferencePointOnImage();const o=await this._transformationService.pointToPixel(t,i);if(o)return v(i),this.plotReferencePointOnImage(o),{x:o.x,y:o.y};this.clearReferencePointOnImage()}async updateFeatureCache(e,t){const i=await N(e,t);i.features?.length&&(this.featureCache=i.features)}async _fetchFeatures(e,t){const{layer:i,layerFloorFilterClause:a,layerTimeExtent:r,view:s}=this;if(!s||!i)return;e.x=B(e.x,e.spatialReference);const o=i.spatialReference.equals(e.spatialReference)?e:await G(e,i.spatialReference),n=o.spatialReference.isGeographic?R(o):o,l=P("1=1",P(i.definitionExpression,a)),c=n.spatialReference.isGeographic?1:S(n.spatialReference),h={layerInstanceOrURL:i,point:n,queryParams:{where:l,maximumDistance:i.maximumDistance?i.maximumDistance/c:void 0,timeExtent:r}};return await this.searchBestImage(h,t)}async _fetchFeaturesWithController(e,t){try{await this._fetchFeatures(e,t)}catch(i){if(y(i))return;this.setMessage("imageLoadError","error"),d.getLogger(this).error("error occurred while fetching features",i)}}_groupFeaturesBySectors(){const{_suitabilities:e,additionalFeatures:t,features:i,invalidCameraHeading:a}=this,r=i.at(0);if(!e||!t||!r||!i||a)return void(this._sectorData=null);this._sectorData={};const o={};this._featureToSector=o;for(const h of _e)this._sectorData[h]=new s;const n=e.map((e,t)=>({...e,featureIndex:t}));n.sort((e,t)=>e.trueSuitability-t.trueSuitability);const l=n.map(({distance:e})=>e),c=Math.max(...l);n.forEach(e=>{const{distance:t,angle:a,featureIndex:s}=e,n=t/c*Me[2],l=We(t,c),h=Je(a);if(!this._sectorData)return;const d=Me[3]+n*Math.sin(a*Math.PI/180),u=Me[3]+n*Math.cos(a*Math.PI/180);let p;const m=i.at(s),g=m===r,{cameraPitch:y}=m.attributes,v=y<5;if(g&&v)p=-90;else{const e=d-Me[3],t=u-Me[3],i=t/Math.sqrt(e**2+t**2);let a=180*Math.acos(i)/Math.PI;(e<0&&t<0||e<0&&t>0)&&(a*=-1),p=a}const f=""===l?h:`${l}_${h}`;g&&(p===this.bestFeatureAngle?this.previousFeatureAngle=p:this.bestFeatureAngle=p,this.navigatorCurrentBestFeature=v?null:{x:d,y:u,direction:h}),o[`${m.attributes.objectId}`]=f;const w=this._sectorData[f];w.add({angle:a,featureIndex:s,x:d,y:u,objectID:m.attributes.objectId,sector:f,featureIndexInSector:w.length})})}async _initializeLocationViewModel(e){if(!this._locationViewModel){const t=import("./components/ImageLocationViewModel.js"),{default:i}=await t;v(e),this._locationViewModel=new i({oiViewModel:this,referenceTransformationService:this._referenceTransformationService})}}_initializeMeasurementService(){this._measurementService||(this._measurementService=new at({transformationService:this._transformationService,referenceTransformationService:this._referenceTransformationService}))}_initializeVideo(){if(this.videoElement||!this.currentBestFeature)return;this.removeHandles(Ee.videoPlayerHandles),this.videoElement=new le({video:this.currentBestFeature.attributes.imagePath,georeference:new oe({extent:new L(fe)}),autoplay:!1}),this.videoElement.content?.loop&&(this.videoElement.content.loop=!1);const e=new D({source:this.videoElement,title:this.layer?.title,copyright:this.layer?.copyright});this.videoLayer=e,e&&this.videoMapView.map.layers.add(e),this.videoViewModel=new et({oiViewModel:this})}async getMapPoint(e,t){const i=await this._transformationService.pixelToMapPoint(Array.isArray(e)?e:[e],t);return Array.isArray(e)?i:i[0]}async getMapPointForFeature(e,t,i){const a=await this._transformationService.pixelToMapPointForFeature(Array.isArray(e)?e:[e],t,i);return Array.isArray(e)?a:a[0]}async loadPanoramicMediaSource(e,t){const{lookAt:i,...a}=e,r=Ne(a);try{await r.load(t)}catch(o){if(y(o))return;if("unsupported-format"===o.name)return void this.setMessage("unsupportedPanoramicImageryError","error",void 0,{datasetFormat:r?.extension??"UNKNOWN FORMAT"})}const s=this.triangularMeasurementActive?this._panoramicMeasurementViewer:this._panoramicViewer;await s.loadMedia(r,t),i&&s.set(i)}async loadMediaSource(e,t){const i=Ue(e);await this._setImageSource(this.triangularMeasurementActive?this.imageMeasurementViewer:this._imageViewer,i,t)}_clearFeatureGeometries(){this.coveragePolygons.removeAll(),this.coverageFrustums.removeAll(),this.pointSources.removeAll()}_checkFeatures(e){return!!e?.length||(this.setMessage("noImageError","error"),this.videoElement?.content?.pause(),this.currentBestFeature=null,!1)}async _getElevationSampleFromGround(e,t,i){if(!e[0])return;const a=(await import("../../geometry/operators/unionOperator.js")).executeMany(e);if(this._updateFootprintWithFeatures(t,a),"3d"===this.view?.type)try{return await this.view.map.ground.createElevationSampler(this.footprintExtent,i)}catch(r){y(r)||d.getLogger(this).error(r)}}async processElevationSample(e,t,i){const{elevationSource:a}=t[0].attributes,r=await this._getElevationSampleFromGround(e,t,i);return r||(a&&this.footprintExtent&&Z(a)?await Y({extent:this.footprintExtent,lod:a.lod,url:a.url,rasterFunction:a.rasterFunction}):void 0)}_processSuitableFeatures(e,t){return U({features:e,selectedPoint:t,camera:qe(this.view)?this.view.camera:null,currentImage:this.currentBestFeature})}async _processHitTestResults(e,t,i){const{results:[a]}=t;if("graphic"!==a?.type)return void this.setMessage("noImageError","error");const r=a.graphic.getAttribute(e.objectIdField);return await this.showImageByObjectId(r,i)}async _queryAndLoadByObjectId(e,t,i,a,r){this.displayMessage=null;const{response:s}=await it(e,t,i,a,r);if(v(r),!s?.features?.length)throw new tt(t);const o=q(s.features[0].attributes).polygon,n=j.fromJSON(E(o)),l=Q(n),c=S(l.spatialReference);this.selectedPoint=l;const h={layerInstanceOrURL:e,point:l,queryParams:{where:P(P("1=1",P(e.definitionExpression,i)),`${e.objectIdField} <> ${t}`),maximumDistance:e.maximumDistance?e.maximumDistance/c:void 0,timeExtent:a}},d=await z(h,r);v(r);const{features:u}=d;return u.push(s.features[0]),await this.processFeatureResponse(d,l,{...r,loadBestImage:!1})}_reorderTriangularSketchLayer(){const e=this.imageMeasurementViewer.imageRenderer.map.layers?.length;this.sketchTriangularGraphicsLayer&&e&&this.imageMeasurementViewer.imageRenderer.map.layers.reorder(this.sketchTriangularGraphicsLayer,e-1)}async _setImageSource(e,t,i){e.media=t,await e.loadMedia(t,i)}_toggleVisiblity(e,t){e.forEach(e=>{e.visible=t})}async _updateElevationOfSelectedPointAndLocations(e,t,i,a){const{location:r,cameraHeight:s}=e[0].attributes,o=await ae(r.spatialReference,r.z,s,{elevationSample:i,elevationSource:i?void 0:e[0].attributes.elevationSource,extent:this.footprintExtent},a);v(a);const[n,...l]=await X([t,...e.map(e=>e.attributes.geometry.clone())],o);v(a),t.elevation=n.z,e.forEach((e,t)=>{e.attributes.elevation=l[t].z})}_updateFeatures(e,t=!0){if(!e.length)return this.currentBestFeature=null,void this.additionalFeatures.removeAll();this.features.removeAll(),this.features.addMany(e),this.navigationNodes.removeAll(),this.navigationNodes.addMany(e.map(e=>{const{geometry:t,attributes:i}=e,{isSpherical:a,cameraHeading:r,cameraPitch:s}=i;return new Ye({geometry:t,attributes:i,currentHeading:a?0:r,currentPitch:a?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 i=[];for(const{attributes:{geometry:a}}of e)t.contains(a)||i.push([a.x,a.y]);i.sort((e,t)=>+x([e,t])),t.addRing(i),this.footprintExtent=de(t.extent,2,2)}async _updatePointsAndPolygons(e){const{pointSources:i,currentBestFeature:a,currentCoverageVisible:r,isAdditionalPointSourcesVisible:s,mode:o,layer:n}=this;if(a&&(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 i){const i=this.view&&!this.view.spatialReference?.equals(o.spatialReference)?await G(o.clone(),this.view?.spatialReference,e):o.clone();o.imageID===a.attributes.objectId?this.currentBestFeatureLocation=new t({attributes:{imageID:o.imageID},geometry:i,symbol:Ge,visible:r}):this.additionalCameraLocations.push(new t({attributes:{imageID:o.imageID},geometry:i,symbol:Oe,visible:s}))}"video"!==o&&"panoramic-video"!==o||(await this.initializeTransformationService(e),n&&!this.featureCache.length&&await this.updateFeatureCache(n,a.geometry.spatialReference))}}_updateCurrentBestFeature(e){if(!e)return;if(this.currentBestFeature=this.features?.at(e.featureIndex),"video"===this.mode)return void(this.currentBestFeature&&this.videoViewModel?.playVideoFromSelectedLocation(this.currentBestFeature));if("panoramic-video"===this.mode)return void(this.currentBestFeature&&this._panoramicVideoViewer.viewModel.playPanoramicVideoFromSelectedLocation(this.currentBestFeature));const t=this.currentBestFeature?.attributes.cameraPitch&&this.currentBestFeature?.attributes.cameraPitch<5;let i;if(t)i=-90;else{const t=e.x-Me[3],a=e.y-Me[3],r=a/Math.sqrt(t**2+a**2);let s=180*Math.acos(r)/Math.PI;(t<0&&a<0||t<0&&a>0)&&(s*=-1),i=s}i===this.bestFeatureAngle?this.previousFeatureAngle=i:this.bestFeatureAngle=i,this.navigatorCurrentBestFeature=t?null:{x:e.x,y:e.y,direction:e.sector.includes("_")?e.sector.split("_")[1]:e.sector}}_updateImageMeasurementBestFeature(e){e&&(this.currentBestFeatureMeasurementImage=this.features?.at(e.featureIndex))}clearGraphics(){this._imageViewer.clearGraphics(),this._panoramicViewer.clearGraphics(),this.imageMeasurementViewer.clearGraphics(),this._panoramicMeasurementViewer.clearGraphics()}clearReferencePointOnImage(){this._referencePointOnImage&&(this._imageViewer.removeGraphic(this._referencePointOnImage),this._panoramicViewer.removeGraphic(this._referencePointOnImage),this._referencePointOnImage=p(this._referencePointOnImage))}async initializeReferenceTransformationService(e){const{currentBestFeatureMeasurementImage:t,activeTriangulatedViewer:i,mode:a}=this;if(!t||!i||!i.imageSize||"panoramic"!==a&&"default"!==a)return;const{imageSize:r}=i,{attributes:s,elevationSample:o}=t,{location:{spatialReference:n,z:l},cameraHeight:c,elevationSource:h}=s;let d=s.location;d.spatialReference.isGeographic&&(d=Q(d));const u="default"===a?re(s,r[0],r[1]):se(s,r[0],r[1]),p=await ae(n,l??0,c,{elevationSample:o,elevationSource:h,extent:this.footprintExtent},e),m=(await import("./services/TransformationService.js")).default,g={imageToWorldProperties:u,updateElevationProps:p,mode:a,imageSize:r,depthImageService:this.depthImage};this._referenceTransformationService=new m(g),this._locationViewModel&&(this._locationViewModel.referenceTransformationService=this._referenceTransformationService),this._measurementService&&(this._measurementService.referenceTransformationService=this._referenceTransformationService)}async initializeTransformationService(e){const{currentBestFeature:t,activeViewer:i,mode:a}=this,r="video"===a||"panoramic-video"===a?be:i?.imageSize;if(!t||!r||"none"===a)return;const{attributes:s,elevationSample:o}=t,{location:{spatialReference:n,z:l},cameraHeight:c,elevationSource:h}=s;let d=s.location;d.spatialReference.isGeographic&&(d=Q(d));const u="default"===a||"video"===a?"default":"panoramic",p={..."default"===u?re(s,r[0],r[1]):se(s,r[0],r[1]),cameraLocation:d},m=await ae(n,l??0,c,{elevationSample:o,elevationSource:h,extent:this.footprintExtent},e),g=(await import("./services/TransformationService.js")).default,y={imageToWorldProperties:p,updateElevationProps:m,mode:u,imageSize:r,depthImageService:this.depthImage};this._transformationService=new g(y),this._measurementService&&(this._measurementService.transformationService=this._transformationService)}plotReferencePoint(e){"mapPoint"in e?this.plotReferencePointOnGround(e.mapPoint):this.plotReferencePointOnGround(e)}setMessage(e,t,i,a){this.displayMessage={key:e,type:t,data:i,map:a}}async transformAndPlotSelectedLocation(e){const{currentBestFeature:t,invalidCameraHeading:i,selectedPoint:a,activeViewer:r}=this;if(this._crossSymbol&&(this._panoramicViewer.removeGraphic(this._crossSymbol),this._imageViewer.removeGraphic(this._crossSymbol),this._crossSymbol=p(this._crossSymbol)),!a||!t||"image-loaded"!==r?.state||i)return;let s;try{s=await this._transformationService.pointToPixel(a,{signal:e?.signal}),v(e),await this.plotSelectedPointOnImage(s,e)}catch(o){y(o)||d.getLogger(this).error("failed to transform map point to pixel, cross symbol will not be plotted on image",{error:o,selectedPoint:a,feature:t})}}updateCurrentCoveragePolygon(e){const{additionalFootprints:i,additionalCameraLocations:a,currentBestFeature:r,currentBestFeatureLocation:s,currentCoverageVisible:o,selectedPoint:n,view:l,_adapter:c,mode:h}=this;if(!r)return;const{attributes:{objectId:d},elevationSample:u}=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),l){const e=[...i,...a,s].filter($e);"3d"===l?.type&&u&&c?.updateGroundElevation&&(this._updateGroundElevation&&c.updateGroundElevation(e),"panoramic"===h&&c.updateGroundElevation([this.bestFeatureCurrentFootprint])),this._updateGroundElevation=!1,n&&(e.splice(-2,0,this.bestFeatureCurrentFootprint),e.push(new t({geometry:n.clone(),symbol:Ve.clone(),attributes:{imageID:d}}))),this._overlays.graphics.addMany(e)}}else if(l){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"===l?.type&&u&&c?.updateGroundElevation&&"panoramic"===h&&c.updateGroundElevation([e]),e.visible=this.currentCoverageVisible,this._overlays?.graphics.add(this.bestFeatureCurrentFootprint,t>=0?t:this._overlays.graphics.length-1))}}};e([A()],ut.prototype,"activeLayer",null),e([A({readOnly:!0})],ut.prototype,"activeViewer",null),e([A()],ut.prototype,"activeTriangulatedViewer",null),e([A()],ut.prototype,"accuracyParametersMissing",null),e([A()],ut.prototype,"additionalFeatures",void 0),e([A({type:s.ofType(t)})],ut.prototype,"additionalCameraLocations",void 0),e([A({type:s.ofType(t)})],ut.prototype,"additionalFootprints",void 0),e([A()],ut.prototype,"areaMeasurementResult",void 0),e([A()],ut.prototype,"areaMeasurementAccuracy",void 0),e([A()],ut.prototype,"bestFeatureAngle",void 0),e([A()],ut.prototype,"bestFeatureCurrentFootprint",void 0),e([A({type:t})],ut.prototype,"bestFeatureFootprint",void 0),e([A({type:Number})],ut.prototype,"brightness",null),e([A()],ut.prototype,"cameraHeadingThreshold",void 0),e([A()],ut.prototype,"cameraPitchThreshold",void 0),e([A()],ut.prototype,"clickAction",void 0),e([A()],ut.prototype,"correctedLocationPointOnImage",void 0),e([A()],ut.prototype,"videoViewModel",void 0),e([A()],ut.prototype,"collectionId",void 0),e([A({type:Number})],ut.prototype,"contrast",null),e([A()],ut.prototype,"coverageFrustums",void 0),e([A()],ut.prototype,"coveragePolygons",void 0),e([A()],ut.prototype,"currentBestFeature",void 0),e([A()],ut.prototype,"currentBestFeatureMeasurementImage",void 0),e([A()],ut.prototype,"currentBestFeatureLocation",void 0),e([A()],ut.prototype,"currentCoverageVisible",void 0),e([A()],ut.prototype,"currentNode",null),e([A()],ut.prototype,"depthImage",void 0),e([A()],ut.prototype,"depthImageNotSupported",null),e([A()],ut.prototype,"featureCache",void 0),e([A()],ut.prototype,"navigationNodes",void 0),e([A({json:{write:!1}})],ut.prototype,"determineWorkflowForFeature",void 0),e([A({json:{write:!1}})],ut.prototype,"determineWorkflowForTriangularMeasurement",void 0),e([A()],ut.prototype,"disabled",void 0),e([A()],ut.prototype,"displayMessage",void 0),e([A()],ut.prototype,"displayNewMeasurementButton",void 0),e([A()],ut.prototype,"distanceMeasurementResult",void 0),e([A()],ut.prototype,"distanceAccuracyArray",void 0),e([A()],ut.prototype,"dataCaptureLayer",void 0),e([A({readOnly:!0})],ut.prototype,"featureCount",null),e([A()],ut.prototype,"features",void 0),e([A()],ut.prototype,"groundCoordinates",void 0),e([A()],ut.prototype,"groundCoordinatesAccuracy",void 0),e([A()],ut.prototype,"heightGraphic",void 0),e([A()],ut.prototype,"heightMeasurementResult",void 0),e([A()],ut.prototype,"heightMeasurementAccuracy",void 0),e([A({readOnly:!0})],ut.prototype,"imageGalleryEnabled",null),e([A()],ut.prototype,"imageGeometryField",void 0),e([A({readOnly:!0})],ut.prototype,"imageLoaded",null),e([A()],ut.prototype,"imageLocationToolState",void 0),e([A()],ut.prototype,"initialVideoMapViewExtent",void 0),e([A({readOnly:!0})],ut.prototype,"invalidCameraHeading",null),e([A()],ut.prototype,"imagePointsInView",null),e([A()],ut.prototype,"imageMeasurementViewer",void 0),e([A()],ut.prototype,"isAdditionalCoverageVisible",void 0),e([A()],ut.prototype,"isAdditionalPointSourcesVisible",void 0),e([A()],ut.prototype,"layer",void 0),e([A()],ut.prototype,"layerView",null),e([A({readOnly:!0})],ut.prototype,"layerFloorFilterClause",null),e([A({readOnly:!0})],ut.prototype,"layerTimeExtent",null),e([A({type:Number})],ut.prototype,"localPort",void 0),e([A()],ut.prototype,"locationPointOnImage",void 0),e([A()],ut.prototype,"mapImageConversionToolState",void 0),e([A()],ut.prototype,"measureType",void 0),e([A()],ut.prototype,"measurementGraphic",void 0),e([A({readOnly:!0,value:"none"})],ut.prototype,"mode",null),e([A()],ut.prototype,"navigationMode",void 0),e([A()],ut.prototype,"navigatorCurrentBestFeature",void 0),e([A()],ut.prototype,"oiObjectIdField",void 0),e([A({type:s.ofType(t)})],ut.prototype,"overlayedCameraLocations",void 0),e([A()],ut.prototype,"overlayedMapFeatures",void 0),e([A()],ut.prototype,"panoramicVideoLoaded",null),e([A()],ut.prototype,"pixelCoordinates",void 0),e([A()],ut.prototype,"preserveAngle",void 0),e([A()],ut.prototype,"pointSources",void 0),e([A({readOnly:!0})],ut.prototype,"popupEnabled",null),e([A()],ut.prototype,"preloadMedia",void 0),e([A()],ut.prototype,"preloadMediaSize",void 0),e([A()],ut.prototype,"previousFeatureAngle",void 0),e([A()],ut.prototype,"referencePoint",null),e([A({readOnly:!0})],ut.prototype,"sectorData",null),e([A()],ut.prototype,"selectedPoint",void 0),e([A({type:Number})],ut.prototype,"sharpness",null),e([A()],ut.prototype,"shouldShowSelectedImage",void 0),e([A()],ut.prototype,"sketch",void 0),e([A()],ut.prototype,"sketchTriangular",void 0),e([A()],ut.prototype,"sketchTriangularGraphicsLayer",void 0),e([A()],ut.prototype,"draw",void 0),e([A()],ut.prototype,"drawAdapter",void 0),e([A()],ut.prototype,"polylineDrawAction",void 0),e([A()],ut.prototype,"scheduledFrameId",void 0),e([A()],ut.prototype,"sketchAdapter",void 0),e([A({readOnly:!0})],ut.prototype,"sketchGraphicsLayer",null),e([A({readOnly:!0})],ut.prototype,"state",null),e([A({readOnly:!0})],ut.prototype,"thumbnails",null),e([A()],ut.prototype,"videoExtentPoints",null),e([A()],ut.prototype,"triangularMeasurementActive",void 0),e([A()],ut.prototype,"triangulatedDistanceMeasurement",void 0),e([A()],ut.prototype,"triangulatedDistanceAccuracy",void 0),e([A()],ut.prototype,"triangulatedAreaMeasurement",void 0),e([A()],ut.prototype,"triangulatedAreaAccuracy",void 0),e([A()],ut.prototype,"triangulatedMeasurementGraphic",void 0),e([A()],ut.prototype,"triangulatedPoint",void 0),e([A()],ut.prototype,"triangulatedMeasurementAdapter",void 0),e([A()],ut.prototype,"updateFootprint",void 0),e([A()],ut.prototype,"updateVideoFootprint",void 0),e([A()],ut.prototype,"updateFootprintPanorama",void 0),e([A()],ut.prototype,"updatingTriangularMeasurementState",void 0),e([A({value:null})],ut.prototype,"view",null),e([A()],ut.prototype,"videoElement",void 0),e([A()],ut.prototype,"videoLayer",void 0),e([A()],ut.prototype,"videoMapView",void 0),e([A()],ut.prototype,"verticalFilterEnabled",void 0),e([A()],ut.prototype,"_adapter",void 0),e([A()],ut.prototype,"_defaultGraphicsLayer",null),e([A()],ut.prototype,"_highlightedFeatureHandle",void 0),e([A()],ut.prototype,"_imageViewer",void 0),e([A()],ut.prototype,"_initialCurrentCoverageUpdate",void 0),e([A()],ut.prototype,"_locationViewModel",void 0),e([A()],ut.prototype,"_measurementService",void 0),e([A()],ut.prototype,"_mediaPrefetcher",void 0),e([A()],ut.prototype,"_navigationManager",void 0),e([A()],ut.prototype,"_overlays",void 0),e([A({readOnly:!0})],ut.prototype,"_overlaysView",null),e([A()],ut.prototype,"_panoramicVideoViewer",void 0),e([A()],ut.prototype,"_panoramicViewer",void 0),e([A()],ut.prototype,"_panoramicMeasurementViewer",void 0),e([A()],ut.prototype,"_referencePointOnGround",void 0),e([A()],ut.prototype,"_referencePointOnImage",void 0),e([A()],ut.prototype,"_referenceTransformationService",void 0),e([A()],ut.prototype,"_sectorData",void 0),e([A()],ut.prototype,"_transformationService",void 0),e([A()],ut.prototype,"_featureToSector",void 0),e([A({readOnly:!0})],ut.prototype,"_updatingHandles",void 0),e([A()],ut.prototype,"footprintExtent",void 0),e([A()],ut.prototype,"_featureChangedTask",void 0),ut=e([C("esri.widgets.OrientedImageryViewer.OrientedImageryViewerViewModel")],ut);const pt=ut;export{pt as default};
2
+ import{__decorate as e}from"tslib";import t from"../../Graphic.js";import{equals as i,isSome as a}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 l}from"../../core/Evented.js";import{makeHandle as c}from"../../core/handleUtils.js";import{equalsShallow as h}from"../../core/lang.js";import d from"../../core/Logger.js";import{clamp as u}from"../../core/mathUtils.js";import{destroyMaybe as p,abortMaybe as m}from"../../core/maybe.js";import{EsriPromise as g}from"../../core/Promise.js";import{isAbortError as y,throwIfAborted as v,waitTick as f}from"../../core/promiseUtils.js";import w from"../../core/ReactiveMap.js";import{whenOnce as F,on as _,watch as M,syncAndInitial as b,initial as I,when as V}from"../../core/reactiveUtils.js";import{sqlAnd as P}from"../../core/sql.js";import{getMetersPerUnitForSR as S}from"../../core/units.js";import{property as A,subclass as C}from"../../core/accessorSupport/decorators.js";import{isSerializable as k}from"../../core/support/jsonUtils.js";import{UpdatingHandles as T}from"../../core/support/UpdatingHandles.js";import L from"../../geometry/Extent.js";import j from"../../geometry/Point.js";import{projectAsync as G}from"../../geometry/projectionUtils.js";import O from"../../geometry/SpatialReference.js";import{polygonCentroidPoint as E}from"../../geometry/support/centroid.js";import{isClockwise as x}from"../../geometry/support/coordsUtils.js";import{normalizeMapX as B}from"../../geometry/support/normalizeUtils.js";import{geographicToWebMercator as R}from"../../geometry/support/webMercatorUtils.js";import H from"../../layers/GraphicsLayer.js";import D from"../../layers/MediaLayer.js";import{searchImages as z,getSortedLayerFeatures as N}from"../../layers/orientedImagery/queries.js";import{calculateSuitabilities as U}from"../../layers/orientedImagery/core/bestImageUtils.js";import{createCoveragePolygon as q,computePolygonForInspection as $,resizePolygon as W,checkIfPolygonContainsSelectedPoint as J}from"../../layers/orientedImagery/core/coverageUtils.js";import{isElevationSource as Z}from"../../layers/orientedImagery/core/ElevationSourceDefinitions.js";import{getMetersPerUnitOfSR as K,convertGeographicToWebMercator as Q}from"../../layers/orientedImagery/core/utils.js";import X from"../../layers/orientedImagery/transformations/updateElevation.js";import{getElevationSampler as Y}from"../../layers/orientedImagery/transformations/updateElevationUtils.js";import{or as ee,getInitialAngle as te,convertPixelLocationToSphereVertex as ie,getUpdateElevationProps as ae,getImageToWorldProperties as re,getImageToWorldPanoramicProperties as se}from"../../layers/orientedImagery/transformations/utils.js";import oe from"../../layers/support/ExtentAndRotationGeoreference.js";import{getFloorFilterClause as ne}from"../../layers/support/floorFilterUtils.js";import le from"../../layers/support/VideoElement.js";import ce from"../../views/MapView.js";import he from"../../views/draw/Draw.js";import{scale as de}from"../../views/draw/support/drawUtils.js";import{ViewEventPriorities as ue}from"../../views/input/InputManager.js";import pe from"../PanoramicVideoViewer.js";import me from"../PanoramicViewer.js";import{defaultAngleThresholdInDegrees as ge,videoMapViewConstraint as ye,clockwiseDirections as ve,sampleExtent as fe,videoExtent as we,invalidCameraHeading as Fe,sectorsInOrder as _e,sectorsRadii as Me,fixedImageSize as be}from"./constants.js";import{isFeatureAttachment as Ie}from"./galleryUtils.js";import{crossSymbol as Ve,crossSymbol3D as Pe,measurementPolygonSymbol as Se,polylineSymbolPanoramic as Ae,measurementPolylineSymbol as Ce,cameraOverlaySymbol3D as ke,cameraOverlaySymbol as Te,diamondSymbol as Le,diamondSymbol3D as je,activeSourcePointSymbol as Ge,sourcePointSymbol as Oe}from"./symbols.js";import{registryKeys as Ee}from"./types.js";import{isNoAttachmentError as xe,extractHorizonAnglesFromMedia as Be,isTifOrMrf as Re,filterOILLayerView as He,assignElevationSampleToFeatures as De,filterByZ as ze,createPanoramicMedia as Ne,createNonPanoramicMedia as Ue,isSceneView as qe,isGraphic as $e,calculateSegment as We,calculateDirection as Je}from"./utils.js";import{disableVideoZoomAndPan as Ze,getUpdatedConstraints as Ke,getUpdatedExtentPoints as Qe}from"./videoViewerUtils.js";import Xe from"./components/ImageViewer.js";import Ye from"./components/NavigationNode.js";import et from"./components/OrientedImageryVideoViewModel.js";import{NoFeatureFoundWithObjectIdError as tt}from"./navigation/errors.js";import{queryFeatureByObjectIds as it}from"./navigation/queries.js";import{ImageMeasurementService as at}from"./services/ImageMeasurementService.js";import{configureSketchTool as rt,extractFieldsFromDataCaptureLayer as st,constructGraphicFromImageGeometry as ot}from"./support/dataCaptureUtils.js";import{imageSpaceToPoint as nt,removeZFromGeometry as lt}from"./support/geometryUtils.js";import ct from"./support/resolveMediaProps.js";import{isValidDataCaptureLayer as ht}from"./support/typeUtils.js";const dt=()=>new n("orientedimageryviewer:sketch-not-initialized","Sketch property is not initialized, call loadSketch first");let ut=class extends(l(g)){constructor(e){super(e),this.additionalFeatures=new s,this.additionalCameraLocations=new s,this.additionalFootprints=new s,this.areaMeasurementResult=0,this.areaMeasurementAccuracy=0,this.bestFeatureAngle=0,this.bestFeatureCurrentFootprint=null,this.bestFeatureFootprint=null,this.cameraHeadingThreshold=ge,this.cameraPitchThreshold=ge,this.clickAction="hittest",this.correctedLocationPointOnImage=null,this.videoViewModel=null,this.collectionId=null,this.coverageFrustums=new s,this.coveragePolygons=new s,this.currentBestFeature=null,this.currentBestFeatureMeasurementImage=null,this.currentBestFeatureLocation=null,this.currentCoverageVisible=!0,this.depthImage=null,this.featureCache=[],this.navigationNodes=new s,this.determineWorkflowForFeature=async(e,t,i)=>{const{currentBestFeature:a,selectedPoint:r}=this;if(this.emit("popup-close"),a&&r){this._initialCurrentCoverageUpdate=!0,this._updateGroundElevation=!0;try{await this._updatePointsAndPolygons(i),await this._loadDepthImage(i),await this._loadImage(i)}catch(s){y(s)||(this.loadImageError(s),d.getLogger(this).error("#loadIImage()","error occured while loading image",s))}}},this.determineWorkflowForTriangularMeasurement=async(e,t,i)=>{if(this.emit("popup-close"),this.currentBestFeatureMeasurementImage&&this.selectedPoint)try{await this._loadMeasurementViewerImage(i)}catch(a){y(a)||(this.loadImageError(a),d.getLogger(this).error("#loadIImage()","error occured while loading image",a))}},this.disabled=!1,this.displayMessage={key:"onLoadMessage",type:"info"},this.displayNewMeasurementButton=!0,this.distanceMeasurementResult=0,this.distanceAccuracyArray=[],this.dataCaptureLayer=null,this.features=new s,this.groundCoordinates=null,this.groundCoordinatesAccuracy=null,this.heightGraphic=null,this.heightMeasurementResult=0,this.heightMeasurementAccuracy=0,this.imageGeometryField=null,this.imageLocationToolState=!1,this.initialVideoMapViewExtent=null,this.imageMeasurementViewer=new Xe,this.isAdditionalCoverageVisible=!1,this.isAdditionalPointSourcesVisible=!1,this.layer=null,this.localPort=null,this.locationPointOnImage=null,this.mapImageConversionToolState=!1,this.measureType=null,this.measurementGraphic=null,this.navigatorCurrentBestFeature=null,this.oiObjectIdField=null,this.overlayedCameraLocations=new s,this.overlayedMapFeatures=new w,this.pixelCoordinates=null,this.preserveAngle="none",this.pointSources=new s,this.preloadMedia=!1,this.preloadMediaSize=5,this.previousFeatureAngle=0,this.selectedPoint=null,this.shouldShowSelectedImage=!1,this.sketch=null,this.sketchTriangular=null,this.sketchTriangularGraphicsLayer=null,this.draw=null,this.drawAdapter=null,this.polylineDrawAction=null,this.scheduledFrameId=null,this.sketchAdapter=null,this.triangularMeasurementActive=!1,this.triangulatedDistanceMeasurement=null,this.triangulatedDistanceAccuracy=null,this.triangulatedAreaMeasurement=null,this.triangulatedAreaAccuracy=0,this.triangulatedMeasurementGraphic=null,this.triangulatedPoint=null,this.triangulatedMeasurementAdapter=null,this.updateFootprint=async(e,t,i)=>{"default"===this.mode&&"image-loaded"!==this.state||await(this._adapter?.updateFootprint(e,t,i))},this.updateVideoFootprint=async e=>{this.mode.includes("video")&&this.videoElement?.content&&await(this._adapter?.updateVideoFootprint(e))},this.updateFootprintPanorama=async(e,t)=>{await(this._adapter?.updateFootprintPanorama(e,t))},this.updatingTriangularMeasurementState=!1,this.videoElement=null,this.videoLayer=null,this.videoMapView=new ce({map:new Map,constraints:ye}),this.verticalFilterEnabled=!1,this._adapter=null,this._highlightedFeatureHandle=null,this._imageViewer=new Xe,this._initialCurrentCoverageUpdate=!0,this._locationViewModel=null,this._measurementService=null,this._mediaPrefetcher=null,this._navigationManager=null,this._overlays=new H({listMode:"hide",internal:!0,elevationInfo:{mode:"absolute-height"},title:"OrentedImageryViewerViewModel overlays layer"}),this._panoramicVideoViewer=new pe,this._panoramicViewer=new me,this._panoramicMeasurementViewer=new me,this._referencePointOnGround=null,this._referencePointOnImage=null,this._referenceTransformationService=null,this._sectorData=null,this._transformationService=null,this._featureToSector=null,this._updatingHandles=new T,this._clickTask=null,this._crossSymbol=null,this.footprintExtent=null,this._featureChangedTask=null,this._mediaPrefetchTask=null,this._suitabilities=null,this._transformController=new AbortController,this._updateFootprintTask=null,this._updateGroundElevation=!1,this.addUpdatingPromise=e=>this._updatingHandles.addPromise(e),this.filterCapturedFeatures=e=>{const t=this.currentBestFeature?.attributes.objectId,i=this.layer?.imageReferenceField;if(!t||!e||!i)return;const a=this.overlayedMapFeatures.get(e);a?.forEach(e=>{const a=e.attributes??{},r=Object.keys(a).find(e=>e.toLowerCase()===i.toLowerCase());(r?a[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:i}=await t;return v(e),this.sketchAdapter=new i({viewModel:this}),this.sketchAdapter},this.loadImageFromFeature=async(e,t,i)=>this._updatingHandles.addPromise(this._loadImageFromFeature(e,t,i)),this.storeImageMeasurementViewer=e=>{this.imageMeasurementViewer=e},this.storePanoramicMeasurementViewer=e=>{this._panoramicMeasurementViewer=e},this.loadImageViewer=e=>{this._imageViewer?.destroy(),this._imageViewer=e},this.loadPanoramicViewer=e=>{this._panoramicViewer?.destroy(),this._panoramicViewer=e},this.loadPanoramicVideoViewer=e=>{this._panoramicVideoViewer?.destroy(),this._panoramicVideoViewer=e},this.loadVideoViewer=e=>{this.videoMapView.container=e},this.showImageByObjectId=async(e,t)=>{const i=this.additionalFeatures.find(({attributes:t})=>t.objectId===e);if(i)this.currentBestFeature=i;else{const{layer:i,layerFloorFilterClause:r,layerTimeExtent:s}=this;if(!i)return void this.setMessage("noLayerSelected","info");this.beforeLoad();const o=this._updatingHandles.addPromise(this._queryAndLoadByObjectId(i,e,r,s,t));try{await o,await this.selectBestFeature(e,t)}catch(a){y(a)||(d.getLogger(this).error("oriented-imagery-viewer:show-image",a),"NoFeatureFoundWithObjectIdError"===a.name?this.setMessage("noFeatureFoundWithObjectId","error","",{objectId:e}):this.setMessage("imageLoadError","error",a.message))}}},this.getSectorFeatureById=e=>this._suitabilities?.find(({feature:{attributes:{objectId:t}}})=>t===e),this.getFeatureSectorById=e=>this._featureToSector?.[`${e}`],this.navigate=async(e,t)=>{const{mode:i}=this;if("default"!==i&&"panoramic"!==i)throw new n("NavigationError","Navigation is only supported in 'default' and 'panoramic' modes.");const a=e=>"default"===i&&e.declaredClass.endsWith("NavigationManager")||"panoramic"===i&&e.declaredClass.endsWith("NavigationManagerPanoramic");if(null==this._navigationManager||!a(this._navigationManager)){p(this._navigationManager);const e="default"===i?import("./navigation/NavigationManager.js"):import("./navigation/NavigationManagerPanoramic.js");this._navigationManager=new(await e).default({viewModel:this})}return this._navigationManager.navigate(e,t)},this.removeHighlight=()=>this._highlightedFeatureHandle?.remove(),this.revealImageGeometry=e=>{},this.selectBestFeature=async(e,t)=>(v(t),this.currentBestFeature=this.features?.find(({attributes:t})=>`${t.objectId}`==`${e}`),F(()=>"image-loaded"===this.state,t)),this.toggleImageAttributes=()=>{const{currentBestFeature:e,popupEnabled:i,layer:a,view:r}=this;if(this.emit("popup-close"),!(r&&e&&i&&a))return;const{attributes:s,geometry:o}=e,n=new t({geometry:o,attributes:s.toJSON(),origin:a.graphicOrigin});this.emit("popup-open",{features:[n],location:s.location.clone()})},this.updateSuitabilities=(e,t=!0)=>{e.sort((e,t)=>e.suitability-t.suitability),this._suitabilities=e;const i=this._suitabilities.map(({feature:e})=>e);this._initialCurrentCoverageUpdate=!0,this._updateFeatures(i,t),this._groupFeaturesBySectors()},this._createViewClickHandle=()=>{if(this.removeHandles(Ee.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,ue.DEFAULT),Ee.click)},this._createImageClickHandle=()=>{this.removeHandles(Ee.imageClick);const{mapImageConversionToolState:e,mode:t,activeViewer:i,currentBestFeature:a,footprintExtent:s}=this,o=i?.imageSize;if(!(e&&"none"!==t&&o&&s&&a))return;const n=i.clickAction;this.clickAction="pixel-location";const l=c(()=>{this.clickAction=n});let h=null;const d=_(()=>i,"pixel-location",e=>{this.plotReferencePointOnImage(e),h?.abort(),h=r(async t=>{if(!e)return;const i=await this._transformationService.pixelToMapPoint(e).then(e=>{const t=this.view?.spatialReference;return ee(!t,e.spatialReference.equals(t))?e:G(e,t)});v(t),this.plotReferencePointOnGround(i)})});this.addHandles([d,l],Ee.imageClick)},this._createTriangularImageClickHandle=()=>{this.removeHandles(Ee.triangularImageClick),this.triangularMeasurementActive&&"none"!==this.mode&&this.currentBestFeature&&this.currentBestFeatureMeasurementImage&&this.activeTriangulatedViewer&&this.addHandles(this.activeTriangulatedViewer.imageRenderer.on("double-click",this._measurementImageClickHandler),Ee.triangularImageClick)},this._enablePan=()=>{this.removeHandles(Ee.videoPanHandles)},this._disablePan=()=>{this.removeHandles(Ee.videoPanHandles),this.addHandles(Ze(this.videoMapView),Ee.videoPanHandles)},this._handleImageHitTestResponse=async e=>{const{layer:t,overlayedCameraLocations:i}=this;if(!t)return;const a=e.results.find(({graphic:e,graphic:{attributes:a}})=>i.includes(e)&&a&&!a[t.imageReferenceField]&&!a[t.imageGeometryField]);if(!a)return;const r=a.graphic.attributes[t.objectIdField];await this.showImageByObjectId(r)},this._loadDepthImage=async e=>{const{currentBestFeature:t,layer:i,depthImageNotSupported:a}=this;if(this.depthImage?.destroy(),this.depthImage=null,!i||!t||a)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)||(d.getLogger(this).error("error occurred while loading depth image",o),this.depthImage?.destroy(),this.depthImage=null)}},this._loadImage=async e=>{const{currentBestFeature:t,layer:i,mode:a}=this;if(this.clearGraphics(),i&&t&&"none"!==a&&"video"!==a&&"panoramic-video"!==a)try{await this.loadImageFromFeature(i,t,e),v(e),await this.transformAndPlotSelectedLocation(e)}catch(r){y(r)||this.loadImageError(r)}},this._loadVideo=async e=>{const{currentBestFeature:t,mode:i,selectedPoint:a}=this,r=t?.attributes.imagePath;if(!t||"panoramic-video"!==i||!r)return;const{attributes:s}=t,{cameraPitch:o,cameraOrientation:n,location:l}=s,c=l.spatialReference.isWGS84&&4!==n?.type?R(l):new j(l);try{this._panoramicVideoViewer.viewModel.video&&(this._panoramicVideoViewer.viewModel.video.pause(),this._panoramicVideoViewer.viewModel.videoPaused=!0),this._panoramicVideoViewer.videoSource=r;let t=0;c&&a&&(t=await te(c,a)-t),this._panoramicVideoViewer.pitch=o??0,this._panoramicVideoViewer.yaw=t,await this._panoramicVideoViewer.loadVideo(e),v(e)}catch(h){y(h)||this.loadImageError(h)}},this._loadImageFromFeature=async(e,t,i)=>{const{mode:a}=this;if("default"!==a&&"panoramic"!==a)return;let r;try{r=await ct(t.attributes,e,i),v(i)}catch(f){if(y(f))return;return xe(f)?(d.getLogger(this).error(f),void this.setMessage("noAttachment","error",`${e.objectIdField}: ${t.attributes.objectId}`)):(d.getLogger(this).error(f,{[e.objectIdField]:t.attributes.objectId,layer:e}),void this.setMessage("imageLoadError","error",`query-attachments-failed:${e.objectIdField} ${t.attributes.objectId}`))}if(!r)return;const{mediaUrl:s,datasetFormat:o,rotation:n,searchParams:l,location:c,cameraHeading:h,matrix:u,cameraPitch:p,getDataSetFormatError:m}=r,g=`${t.attributes.objectId}`;try{let r=this._mediaPrefetcher?.getCachedMedia(g);if(!r){const i=this.navigationNodes.find(e=>e.id===t.attributes.objectId);if(i){try{await(this._mediaPrefetcher?.startPrefetchForNode(i,e))}catch(w){}r=this._mediaPrefetcher?.getCachedMedia(g)}}if(r){if("panoramic"===a){const e=this.triangularMeasurementActive?this._panoramicMeasurementViewer:this._panoramicViewer;let a=0;return c&&this.selectedPoint&&(a=await te(c,this.selectedPoint)-a),await e.loadMedia(r,i),this.selectedPoint?e.set({yaw:a,pitch:p}):"viewAngle"in t.attributes&&Number.isFinite(t.attributes.viewAngle)&&e.set({yaw:t.attributes.viewAngle,pitch:p}),void(this.triangularMeasurementActive?await this.initializeReferenceTransformationService(i):await this.initializeTransformationService(i))}return await this._setImageSource(this.triangularMeasurementActive?this.imageMeasurementViewer:this._imageViewer,r,i),void(this.triangularMeasurementActive?await this.initializeReferenceTransformationService(i):await this.initializeTransformationService(i))}}catch(w){}m&&d.getLogger(this).warn("error occurred while getting dataset format",m),"panoramic"===a?await this.loadPanoramicMediaSource({lookAt:{yaw:this.selectedPoint?await te(c,this.selectedPoint):"viewAngle"in t.attributes&&Number.isFinite(t.attributes.viewAngle)?t.attributes.viewAngle:0,pitch:p},extension:o?.toUpperCase(),url:s,cameraHeading:h,matrix:u},i):await this.loadMediaSource({datasetFormat:o?.toUpperCase(),url:s,customParameters:l,rotation:n},i),this.triangularMeasurementActive?await this.initializeReferenceTransformationService(i):await this.initializeTransformationService(i)},this._loadMeasurementViewerImage=async e=>{const{currentBestFeatureMeasurementImage:t,layer:i,mode:a}=this;if(this.imageMeasurementViewer.clearGraphics(),this._panoramicMeasurementViewer.clearGraphics(),i&&t&&"none"!==a&&"video"!==a&&"panoramic-video"!==a)try{await this.loadImageFromFeature(i,t,e),v(e)}catch(r){y(r)||this.loadImageError(r)}},this._loadMediaPrefetcher=async e=>{if(!this._mediaPrefetcher){const{default:t}=await import("./support/MediaPrefetcher.js");v(e),this._mediaPrefetcher=new t({maxEntries:this.preloadMediaSize*ve.length})}return this._mediaPrefetcher},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=B(t.x,t.spatialReference),this.plotMapPoint(e.mapPoint)}},this._measurementImageClickHandler=e=>{e.stopPropagation(),e.preventDefault();const{sketchTriangular:t,triangularMeasurementActive:i,currentBestFeatureMeasurementImage:a,triangulatedMeasurementGraphic:r}=this;t&&i&&a&&r&&"active"!==t.state&&(t.update([r],{tool:"reshape"}),this.updatingTriangularMeasurementState=!0)},this._updateInteraction=()=>{const e=this.videoMapView.extent;if(!e)return;if(e.width<fe.xmax-fe.xmin&&e.height<fe.ymax-fe.ymin){this._enablePan();const t=Ke(e);t&&(this.videoMapView.constraints.geometry=t)}else this.initialVideoMapViewExtent&&!this.videoMapView.extent.equals(this.initialVideoMapViewExtent)&&(this.videoMapView.extent=this.initialVideoMapViewExtent),this._disablePan(),this.videoMapView.constraints.geometry=null},this._viewClickHandler=e=>{this._clickTask?.abort(),this._clickTask=r(async t=>{const{pointerType:i,button:a,mapPoint:r}=e;if("mouse"===i&&0!==a||!r)return;e.stopPropagation(),e.preventDefault();const{view:s,layer:o}=this;if(s&&o){if(this.shouldShowSelectedImage){const i=s.hitTest(e,{include:[o]});this._updatingHandles.addPromise(i);const a=await i;return v(t),await this._processHitTestResults(o,a,{signal:t})}return this._updatingHandles.addPromise(this.loadBestImage(r,{signal:t}))}})},this.plotSelectedPointOnImage=async(e,i)=>{if(await f(i),!e)return;const a=new j({...k(e)?e.toJSON():e});if("default"===this.mode)a.x-=.5,a.y=.5-a.y,a.spatialReference=this._imageViewer.imageRenderer.spatialReference.clone(),this._crossSymbol=new t({geometry:a,symbol:Ve}),this._imageViewer.addGraphic(this._crossSymbol,0);else if("panoramic"===this.mode){const{imageSize:i,media:a}=this._panoramicViewer;if(!i||!a)return;const r=Be(a),s=ie(e,...i,r);this._crossSymbol=new t({geometry:new j(s,O.WebMercator),symbol:Pe}),this._panoramicViewer.addGraphic(this._crossSymbol,0)}},this.handleSectorClick=this.handleSectorClick.bind(this),this.searchBestImage=this.searchBestImage.bind(this),this.transformAndPlotReferencePointOnImage=this.transformAndPlotReferencePointOnImage.bind(this)}initialize(){this.addHandles([M(()=>this.view,()=>this.load(),b),M(()=>this.view?.map,(e,t)=>{t?.layers.remove(this._overlays),e?.layers.add(this._overlays)},I),M(()=>this.view?.map?.allLayers?.length,e=>{e&&this.view?.map?.layers.reorder(this._overlays,e-1)},I),M(()=>[this.state,this.mapImageConversionToolState,this.view,this.disabled],()=>{this._createViewClickHandle(),this._createImageClickHandle()},b),M(()=>[this.triangularMeasurementActive,this.currentBestFeatureMeasurementImage],()=>{this._createTriangularImageClickHandle()},b),M(()=>[this.state,this.imageLocationToolState,this.view],()=>{this._initializeMeasurementService(),this._initializeLocationViewModel()},b),M(()=>this.measureType,()=>{this.clearPreviousMeasurements(),this._initializeMeasurementService()},b),M(()=>this.bestFeatureAngle,(e,t)=>{this.previousFeatureAngle=t??0},b),M(()=>this.currentBestFeature,async(e,t)=>{m(this._featureChangedTask),this._featureChangedTask=r(async i=>this.determineWorkflowForFeature.apply(this,[e,t,{signal:i}])),await this._featureChangedTask.promise},{sync:!0}),M(()=>[this.currentNode,this.preloadMedia,this.navigationMode],()=>{this._mediaPrefetchTask?.abort(),this._mediaPrefetchTask=r(async e=>{this.preloadMedia&&null!=this.navigationMode?(this._mediaPrefetcher??=await this._loadMediaPrefetcher({signal:e}),v(e),"directional"===this.navigationMode?this._mediaPrefetcher.enqueueDirectionalPrefetch(this.layer,this.currentNode,this.preloadMediaSize):this._mediaPrefetcher.enqueueSequentialPrefetch(this.layer,this.currentNode,this.preloadMediaSize)):this._mediaPrefetcher?.clear()})},b),M(()=>this.currentBestFeatureMeasurementImage,(e,t)=>{m(this._featureChangedTask),t&&e!==t&&(this.triangulatedPoint=null,this.sketchTriangularGraphicsLayer?.graphics.destroyAll(),this._measurementService?.resetMeasurementVectors()),this._featureChangedTask=r(async i=>{await this.determineWorkflowForTriangularMeasurement(e,t,{signal:i}),v(i),this._reorderTriangularSketchLayer()})},b),M(()=>this.triangularMeasurementActive,(e,t)=>{t&&!e&&(this._measurementService?.resetMeasurementVectors(),this.currentBestFeatureMeasurementImage=null,this.triangulatedDistanceMeasurement=null,this.triangulatedMeasurementGraphic=null,this.triangulatedPoint=null,this.updatingTriangularMeasurementState=!1,this.triangulatedAreaMeasurement=null,this.triangulatedDistanceAccuracy=null,this.triangulatedAreaAccuracy=0,this.sketchTriangularGraphicsLayer?.graphics.destroyAll(),this.clearReferencePointOnImage(),this.imageMeasurementViewer.clearImage(),this.imageMeasurementViewer.clearGraphics(),this._panoramicMeasurementViewer.clearImage(),this._panoramicMeasurementViewer.clearGraphics())}),M(()=>this.mode,e=>{switch(this.removeHandles(Ee.interactionHandles),e){case"default":this.addHandles(M(()=>{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})}))},{...b,equals:(e,t)=>i(e,t,h)}),Ee.interactionHandles);break;case"video":this.addHandles(M(()=>{const{footprintExtent:e,videoElement:t,bestFeatureFootprint:i}=this;if(e&&t?.loaded&&i)return{videoExtent:we,bestFeatureFootprint:i}},e=>{e?.videoExtent&&e?.bestFeatureFootprint&&(m(this._updateFootprintTask),this._updateFootprintTask=r(async t=>{const i={points:e.videoExtent,feature:void 0,scale:void 0,options:{signal:t}};await this.updateVideoFootprint(i)}))},{...b,equals:(e,t)=>i(e?.videoExtent,t?.videoExtent,h)&&e?.bestFeatureFootprint===t?.bestFeatureFootprint}),Ee.interactionHandles);break;case"panoramic":this.addHandles(M(()=>{const{currentBestFeature:e,state:t,_panoramicViewer:i}=this,{imageSize:a,vfov:r,hfov:s,pitch:o,yaw:n}=i;return e&&a&&!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,i,a,s]=e;this.currentNode&&(this.currentNode.currentHeading=a,this.currentNode.currentPitch=s),m(this._updateFootprintTask),this._updateFootprintTask=r(async e=>{await this.updateFootprintPanorama({verticalFieldOfView:t,horizontalFieldOfView:i,yaw:a,pitch:s},{signal:e}),this._updateFootprintTask=null})},{equals:(e,t)=>i(e,t,h)}),Ee.interactionHandles);break;case"panoramic-video":this.addHandles(M(()=>{const{currentBestFeature:e,state:t,_panoramicVideoViewer:i}=this,{imageSize:a,vfov:r,hfov:s,pitch:o,yaw:n,viewModel:l}=i,c=l.closestFeature??e;return c&&a&&!t.includes("loading")&&null!=r&&null!=s&&null!=o&&null!=n?[r,s,n,o,c]:null},e=>{if(!e)return;const[t,i,a,s,o]=e;m(this._updateFootprintTask),this._updateFootprintTask=r(async e=>{await this.updateFootprintPanorama({verticalFieldOfView:t,horizontalFieldOfView:i,yaw:a,pitch:s,feature:o,horizonAngles:this._panoramicVideoViewer.horizonAngles},{signal:e}),v(e),this._updateFootprintTask=null})},{equals:(e,t)=>i(e,t,h)}),Ee.interactionHandles)}},b),M(()=>[this.brightness,this.contrast,this.sharpness],()=>{const{_imageViewer:e,brightness:t,contrast:i,mode:a,sharpness:r}=this;"default"===a&&(e.brightness=t,e.contrast=i,e.sharpness=r)},b),M(()=>this.activeViewer?.imageRenderer,()=>{this.sketch&&(this.sketch.view=this.activeViewer?.imageRenderer)}),M(()=>this.activeViewer,e=>{this.removeHandles(Ee.hittestHandles),e&&this.addHandles(_(()=>e,"hittest-response",this._handleImageHitTestResponse),Ee.hittestHandles)}),M(()=>this.videoMapView.extent,async()=>{const e=this.videoViewModel?.closestFeature;e&&(m(this._updateFootprintTask),this._updateFootprintTask=r(async t=>{const i={points:this.videoExtentPoints,feature:e,options:{signal:t}};await this.updateVideoFootprint(i)}))}),M(()=>[this.videoMapView.interacting,this.videoMapView.navigating,this.videoMapView.scale],()=>{this.scheduledFrameId||(this.scheduledFrameId=requestAnimationFrame(()=>{this.scheduledFrameId=null,this._updateInteraction()}))},{initial:!0}),V(()=>null!=this.videoMapView.extent,()=>{this.initialVideoMapViewExtent=this.videoMapView.extent},{once:!0})]),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._locationViewModel=p(this._locationViewModel),this._crossSymbol=p(this._crossSymbol),this._referencePointOnGround=p(this._referencePointOnGround),this._referencePointOnImage=p(this._referencePointOnImage),this._overlays&&this.view?.map?.remove(this._overlays),this._overlays.destroy(),this._imageViewer.destroy(),this.imageMeasurementViewer.destroy(),this._panoramicViewer.destroy(),this._panoramicMeasurementViewer.destroy(),this._mediaPrefetcher?.destroy()}get activeLayer(){return o(d.getLogger(this),"activeLayer",{replacement:"layer"}),this.layer}set activeLayer(e){o(d.getLogger(this),"activeLayer",{replacement:"layer"}),this.layer=e}get activeViewer(){const{_imageViewer:e,_panoramicViewer:t,mode:i}=this;switch(i){case"default":return e;case"panoramic":return t;default:return null}}get activeTriangulatedViewer(){switch(this.mode){case"default":return this.imageMeasurementViewer;case"panoramic":return this._panoramicMeasurementViewer;default:return null}}get accuracyParametersMissing(){return this.layer?.orientationAccuracy?.every(e=>0===e)??!0}get brightness(){return this._get("brightness")??0}set brightness(e){this._set("brightness",u(e,-10,10))}get contrast(){return this._get("contrast")??0}set contrast(e){this._set("contrast",u(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!Re(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 Re(t)||Ie(t)}get imageLoaded(){return o(d.getLogger(this),"imageLoaded",{replacement:'Use OrientedImageryViewer.state === "image-loaded"',version:"4.29",warnOnce:!0}),"image-loaded"===this.state}get invalidCameraHeading(){return this.currentBestFeature?.attributes?.cameraHeading===Fe}get imagePointsInView(){const{mode:e,_imageViewer:t}=this;return"default"===e?t.imagePointsInView:null}get layerView(){const{layer:e,view:t}=this;if(e&&t)return t.allLayerViews.find(He(e))}get layerFloorFilterClause(){const{layerView:e}=this;return e?ne(e):null}get layerTimeExtent(){return this.layerView?.timeExtent??null}get mode(){const e=this.currentBestFeature?.attributes;if(!e)return"none";const t=e.orientedImageryType;if(t?.includes("video"))return t.includes("360")?"panoramic-video":"video";const{horizontalFieldOfView:i,isSpherical:a}=e;return 360===i||a?"panoramic":"default"}get panoramicVideoLoaded(){const{mode:e,_panoramicVideoViewer:t}=this,{videoLoaded:i}=t.viewModel;return("panoramic-video"===e&&!0===i)??!1}get popupEnabled(){return!0===this.layer?.popupEnabled}get referencePoint(){return this._referencePointOnGround?.geometry}get sectorData(){const{_sectorData:e}=this;return e?_e.map(t=>e[t]):null}get sharpness(){return this._get("sharpness")??0}set sharpness(e){this._set("sharpness",u(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:i}=this;if(!this.isFulfilled()||t||!1===i?.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:i,imageRotation:a}})=>{const r=e?.trim();return Re(r)||Ie(r)?{url:r,objectId:t,rotation:(i??0)+(a??0)}:null}).filter(a)):null}get videoExtentPoints(){const e=Qe(this.videoMapView.extent);return e.length?e:we}set view(e){this._set("view",e)}get _defaultGraphicsLayer(){const e={blendMode:"source-atop"};switch(this.mode){case"panoramic":return new H({...e,elevationInfo:{mode:"absolute-height"}});case"default":return new H({...e});default:return}}get _overlaysView(){return this.view?.layerViews.find(({layer:e})=>e===this._overlays)}beforeLoad(e=!0){this.emit("popup-close"),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 calculateLocationAccuracy(e){return this._measurementService?.calculateLocationAccuracy(e)}clearLocationPointOnImage(e=!1){this.locationPointOnImage&&!e&&(this._imageViewer.removeGraphic(this.locationPointOnImage),this._panoramicViewer.removeGraphic(this.locationPointOnImage),this.locationPointOnImage=p(this.locationPointOnImage)),this.correctedLocationPointOnImage&&(this.imageMeasurementViewer.removeGraphic(this.correctedLocationPointOnImage),this._panoramicMeasurementViewer.removeGraphic(this.correctedLocationPointOnImage),this.correctedLocationPointOnImage=p(this.correctedLocationPointOnImage))}clearPreviousMeasurements(){this.clearMeasurementGraphics(),this.resetMeasurementData(),this.stopMeasurement()}clearPreviousGroundLocation(){this.groundCoordinates=null,this.groundCoordinatesAccuracy=null,this.pixelCoordinates=null,this.clearLocationPointOnImage()}clearMeasurementGraphics(){this.measurementGraphic&&(this.activeViewer?.removeGraphic(this.measurementGraphic),this.measurementGraphic=null),this.heightGraphic&&(this.activeViewer?.removeGraphic(this.heightGraphic),this.heightGraphic=null),this.triangularMeasurementActive&&this.sketchTriangularGraphicsLayer?.graphics.destroyAll()}digitizeCancel(){return this.sketch?.cancel()}digitizeCanRedo(){return this.sketch?.canRedo()??!1}digitizeCanUndo(){return this.sketch?.canUndo()??!1}digitizeComplete(){return this.sketch?.complete()}async digitizeCreate(e,t){const{sketch:i,dataCaptureLayer:a}=this;if(!i)throw dt();rt(a,e,i),await i.create(e,{...t,defaultZ:0})}digitizeDelete(){if(!this.sketch)throw dt();return this.sketch.delete()}digitizeDuplicate(){if(!this.sketch)throw dt();return this.sketch.duplicate()}digitizePlace(e,t){if(!this.sketch)throw dt();return this.sketch.place(e,t)}digitizeRedo(){if(!this.sketch)throw dt();return this.sketch.redo()}digitizeUndo(){if(!this.sketch)throw dt();return this.sketch.undo()}digitizeUpdate(e,t){if(!this.sketch)throw dt();return this.sketch.update(e,t)}filterByFootprints(e,t,i=!1){const a=[],r=[],s=[];return e.forEach(e=>{const{layer:{coveragePercent:o},attributes:n}=e;let l;const{polygon:c,frustum:h}=q(n);if(l=c.clone(),n.isInspection&&(l=$(n)),o&&(l=W(l,o)),i||!t||J(l,t)){s.push(e);const{geometry:t,objectId:i,cameraHeight:o,cameraHeading:l}=n,d=t.clone();d.z=o/K(t.spatialReference),d.imageID=i,this.pointSources.push(d),l!==Fe&&(a.push(c),h&&r.push(h))}}),{features:s,polygons:a,frustums:r}}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?.[_e[e]],i=t?.at(0);i&&(this.triangularMeasurementActive&&this.currentBestFeature?this._updateImageMeasurementBestFeature(i):this._updateCurrentBestFeature(i))}handleFeatureClick(e){const{sector:t,featureIndexInSector:i}=e;if(isNaN(i))return;const a=this._sectorData?.[t],r=a?.at(i);r&&(this.triangularMeasurementActive&&this.currentBestFeature?this._updateImageMeasurementBestFeature(r):this._updateCurrentBestFeature(r))}load(e){return this.addResolvingPromise(this._loadViewAdapter(e).catch(e=>{if(!y(e))throw e})),this}async loadBestImage(e,t){return this.selectedPoint=Q(e),this.beforeLoad(),this._fetchFeaturesWithController(e,t)}async loadHeightMeasurementAdapter(e){if(!this.drawAdapter){const t=import("./adapters/draw/HeightMeasurementAdapter.js"),{default:i}=await t;if(v(e),this.drawAdapter=new i({viewModel:this,measurementService:this._measurementService}),!this.drawAdapter.viewModel.isResolved())return}return this.drawAdapter}loadImageError(e){d.getLogger(this).error("oriented-imagery-viewer:load-image",e),this.setMessage("imageLoadError","error",e.message)}async loadSketch(e){if(!this.sketch){const t=import("../Sketch/SketchViewModel.js"),{default:i}=await t;v(e),this.sketch=new i({layer:this._defaultGraphicsLayer,view:this.activeViewer?.imageRenderer,updateOnGraphicClick:!1,defaultUpdateOptions:{reshapeOptions:{edgeOperation:"none",shapeOperation:"none",vertexOperation:void 0},enableMoveAllGraphics:!1,enableRotation:!1,enableScaling:!1,multipleSelectionEnabled:!1,toggleToolOnClick:!1,tool:"transform"}})}return this.sketch}async loadMeasurementAdapter(e){if(!this.sketchAdapter){const t=import("./adapters/sketch/MeasurementAdapter.js"),{default:i}=await t;if(v(e),this.sketchAdapter=new i({viewModel:this,measurementService:this._measurementService}),!this.sketchAdapter.viewModel.isResolved())return}return this.sketchAdapter}async processFeatureResponse(e,t,i){const{features:a}=e;if(this._clearFeatureGeometries(),!this._checkFeatures(a))return;const{features:r,polygons:s,frustums:o}=this.filterByFootprints(a,t,i?.skipFilter);if(!this._checkFeatures(r))return;this.coveragePolygons.addMany(s),this.coverageFrustums.addMany(o);const n=await this.processElevationSample(s,r,i);v(i),await this._updateElevationOfSelectedPointAndLocations(r,t,n),v(i),De(r,n);let l=r;if(this.layer?.verticalSearchRange&&this.layer.hasZ&&this.verticalFilterEnabled&&(l=ze(r,t,this.layer.verticalSearchRange),!l.length))return void this.setMessage("noImageAtElevation","info");const c=this._processSuitableFeatures(l,t);this.updateSuitabilities(c,i?.loadBestImage)}async processFeatureElevation(e,t,i){if(!t)return;const{features:a,polygons:r}=this.filterByFootprints(e,t,!0);if(!a?.length)return;const s=await this.processElevationSample(r,a,i);return v(i),s}async startMeasurement(e,t){this.sketch||await this.loadSketch(t),await this.loadMeasurementAdapter(t);const{sketch:i,sketchAdapter:a,activeViewer:r,mode:s}=this;if(!i||!a||!r||"none"===s)return;if(this.displayNewMeasurementButton=!1,"panoramic"===s&&(i.defaultCreateOptions.defaultZ=0),await i.create(e),"panoramic"===s){const{drawOperation:e}=i.view.activeTool;e.constraintsEnabled=!1,e._set("elevationDrawSurface",null)}const o=this.activeViewer?.imageRenderer.effectiveTheme.accentColor;o&&this.sketch&&(this.sketch.polygonSymbol=Se(o),this.sketch.polylineSymbol="panoramic"===s?Ae:Ce(o,2.5))}async startHeightMeasurement(){this.displayNewMeasurementButton=!1,this.draw??=new he({view:this.activeViewer?.imageRenderer}),this.polylineDrawAction=this.draw.create("polyline"),await this.loadHeightMeasurementAdapter()}initializeMeasurement(e){switch(this.clearMeasurementGraphics(),this.resetMeasurementData(),e){case"distance":this.startMeasurement("polyline");break;case"area":this.startMeasurement("polygon");break;case"height":this.startHeightMeasurement()}}async overlayCameraLocations(e){const{activeViewer:i,currentBestFeature:a,overlayedCameraLocations:r,layer:s,mode:o,state:n,layerFloorFilterClause:l,layerTimeExtent:c}=this,h=i?.imageSize;if(!h||!a||!s||"default"!==o&&"panoramic"!==o||n.includes("loading"))return;const{polygon:d}=q(a.attributes);if(i.removeManyGraphics(r.toArray()),r.removeAll(),e){const{features:e}=await s.queryFeatures({where:P(`${s.objectIdField} <> ${a.attributes.objectId}`,P(s.definitionExpression,l)),geometry:d,returnGeometry:!0,outFields:[s.objectIdField],timeExtent:c}),n=await Promise.all(e.map(async e=>{const{attributes:i,geometry:a}=e,r=await this._transformationService.pointToImageGeometry(a),s="panoramic"===o?ke():Te();return new t({attributes:i,symbol:s,geometry:r})}));r.addMany(n),i.addManyGraphics(r.toArray())}}overlayGraphicsOnImage(e,t){this.removeOverlayedGraphicsOnImage(e),this.overlayedMapFeatures.set(e,t),this.activeViewer?.addManyGraphics(t.toArray())}async overlayMapFeatures(e,i=!1){const{activeViewer:a,currentBestFeature:r,mode:o,state:n,layer:l}=this,c=a?.imageSize;if(!c||!r||"none"===o||"video"===o||"panoramic-video"===o||n.includes("loading")||!l)return;const{polygon:h}=q(r.attributes);try{const{imageGeometryField:t,oiObjectIdField:i}=st(e,l.imageGeometryField,l.imageReferenceField);this.imageGeometryField=t.name,this.oiObjectIdField=i.name}catch(m){d.getLogger(this).warn("oriented-imagery-viewer:overlay-map-features",m)}const{features:u}=await e.queryFeatures({geometry:h,returnGeometry:!0,outFields:["*"]}),p=new s(await Promise.all(u.map(async s=>{const n=s.symbol?.clone()??e.renderer?.getSymbol(s)?.clone(),{attributes:l,geometry:h}=s,{imageGeometryField:u,oiObjectIdField:p}=this;if(u&&p&&ht(e,u,p)&&`${l[p]}`==`${r.attributes.objectId}`)try{const t=Be(a?.media);return ot(l,u,e,i,c,o,n,t)}catch(m){d.getLogger(this).warn("oriented-imagery-viewer:overlay-map-features","couldn't create graphic from attributes, geometry will be used",{error:m,feature:s,layer:e,imageGeometryField:this.imageGeometryField,imageReferenceField:this.oiObjectIdField})}const g=await this._transformationService.geometryToImageGeometry(h);return new t({attributes:l,layer:e,symbol:n,geometry:g,visible:e.visible&&i})})));this.overlayGraphicsOnImage(`${e.id}`,p)}getDepthAt(e){const{activeViewer:t,currentBestFeature:i,mode:a,state:r,depthImage:s}=this,o=t?.imageSize;if(!o||!i||"none"===a||r.includes("loading"))return d.getLogger(this).warnOnce("oriented-imagery-viewer:get-depth-at","Load an image to use depth"),null;if(!s?.loaded)return d.getLogger(this).error("oriented-imagery-viewer:get-depth-at","Depth image is not loaded"),this.emit("depth-image-service:not-loaded"),null;const n=(Array.isArray(e)?e:[e]).map(e=>s.depthAt(e,{width:o[0],height:o[1]})??null);return Array.isArray(e)?n:n[0]}getActiveSectors(){return _e.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 j({...e.toJSON()}),symbol:Le}),this.view?this._overlays?.add(this._referencePointOnGround):this.emit("plot-ground-point",{data:{point:this._referencePointOnGround?.geometry}}))}plotReferencePointOnImage(e){const{state:i,mode:a,activeViewer:r}=this;if("image-loaded"!==i||!r?.imageSize||"default"!==a&&"panoramic"!==a)return;this.clearReferencePointOnImage();const s=Be(r.media),o=nt(e,a,r.imageSize,s);this._referencePointOnImage=new t({geometry:o,symbol:"panoramic"===a?je.clone():Le.clone()}),r.addGraphic(this._referencePointOnImage,0)}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.heightMeasurementResult=0,this.heightMeasurementAccuracy=0,this.heightGraphic=null,this.triangulatedDistanceMeasurement=null,this.triangulatedDistanceAccuracy=null,this.triangulatedAreaMeasurement=null,this.triangulatedMeasurementGraphic=null,this.updatingTriangularMeasurementState=!1,this.triangulatedAreaAccuracy=0,this._measurementService?.resetMeasurementVectors()}async saveDrawing(){const{dataCaptureLayer:e,sketchAdapter:t}=this;if(!e||"data-capture"!==t?.type)return;const{pendingGraphics:i,savedGraphics:a}=t,r=i.get(e.id),s=r?.toArray();if(!r||!s?.length)return;const{addFeatureResults:o}=await this.saveDataCaptureFeatures(s),n=o.reduce((t,{objectId:i,globalId:a,error:r},o)=>{const n=s[o],{attributes:l}=n;return r?t.error.push(n):(i&&(l[e.objectIdField]=i),a&&e.globalIdField&&(l[e.globalIdField]=a),t.success.push(n)),t},{success:[],error:[]});a.addMany(n.success),r.removeAll(),r.addMany(n.error)}async saveDataCaptureFeatures(e,t){const{activeViewer:i,currentBestFeature:r,dataCaptureLayer:s,mode:o}=this,l=i?.imageSize;if(!l||!r||"none"===o||"video"===o||"panoramic-video"===o)throw new n("orientedimageryviewer:missing-input","Image size, current best feature and mode are required to save data capture features");if(!s)throw new n("orientedimageryviewer:missing-featurelayer","Data capture layer is not available");const c=await Promise.all(e.map(async e=>{const i=e.clone(),{geometry:a}=i;if(!a)return;const r=a.type,o=s.hasZ,n=s.geometryType,l=r!==n,c=l?await import("./transformers.js"):null,h=c?.default[n],d=l?h?.(a):a;return d&&(i.geometry=await this._transformationService.imageGeometryToMapGeometry(d,t),i.geometry)?(o||lt(i.geometry),i):void 0})),h=c.filter(a);return s.applyEdits({addFeatures:h}).then(e=>{const{addFeatureResults:t}=e;let i=0;const a=c.map(e=>{const a=t[i++];return e?a:{error:new n("orientedimageryviewer:save-unsucccessful","Error in saving data capture features"),objectId:null,globalId:null}});return{...e,addFeatureResults:a}})}async searchBestImage(e,t){try{const i=await z(e,t);i&&await this.processFeatureResponse(i,e.point,t)}catch(i){y(i)||(this.setMessage("imageLoadError","error",i.message),d.getLogger(this).error("error occurred while finding best image",i))}}selectTriangularMeasurementFeature(e){this.currentBestFeatureMeasurementImage=this.features?.find(({attributes:t})=>t.objectId===Number(e))}setAdditionalCameraLocationsVisibility(e){this.additionalCameraLocations.forEach(t=>{t.visible=e})}setAdditionalCoverageVisibility(e){this.additionalFootprints.forEach(t=>{t.visible=e})}setCurrentCoverageVisibility(e){this.bestFeatureCurrentFootprint&&(this.bestFeatureCurrentFootprint.visible=e),this.currentBestFeatureLocation&&(this.currentBestFeatureLocation.visible=e)}setMapImageConversionToolState(e){this.mapImageConversionToolState=e}setCurrentPanoramaView(e,t){this._panoramicViewer?.set({yaw:e,pitch:t})}async startDataCapture(e,t){const i=this.activeViewer?.imageRenderer,{oiObjectIdField:a,currentBestFeature:r}=this;if(!i||!r||!a)return;const{attributes:{objectId:o}}=r,n=this.overlayedMapFeatures.get(e.id)?.toArray()??[],l=[],c=[];for(const s of n)`${s.getAttribute(a)}`==`${o}`?l.push(s):c.push(s);this.overlayGraphicsOnImage(e.id,new s(c)),this.collectionId=e.id;const h=await this.loadSketch(t),d=await this.loadDataCaptureAdapter(t);v(t),h.addGraphics(l),d.savedGraphics.addMany(l);i.ui.find("zoom").visible=!1,i.map.layers.add(this.sketchGraphicsLayer)}async stopDataCapture(e=!1){this.sketch?.cancel(),this.sketchGraphicsLayer?.removeAll(),this.sketchAdapter=p(this.sketchAdapter),this.sketch=p(this.sketch),this.collectionId=null;const{dataCaptureLayer:t}=this,i=this.activeViewer?.imageRenderer;if(!i||i.destroyed)return;i.map.layers.remove(this.sketchGraphicsLayer),e&&t&&await this.overlayMapFeatures(t,!0);const a=i.ui.find("zoom");a&&(a.visible=!0)}stopMeasurement(){this.draw?.reset(),this.sketch?.cancel()}async toggleAllOverlayMapFeatures(e){!e&&this.dataCaptureLayer&&(await this.stopDataCapture(!0),this.dataCaptureLayer=null),this.overlayedMapFeatures.forEach(t=>{this._toggleVisiblity(t,e)})}toggleOverlayMapFeatures(e,t,i){const a=this.overlayedMapFeatures.get(e);a&&i&&this._toggleVisiblity(a,t)}toggleSelection(e){const{sketch:t}=this;t&&(t.updateOnGraphicClick=e,t.cancel())}async transformAndPlotReferencePointOnImage(e){const{selectedLocation:t,options:i}=e;let a=!1,r=!1;const s=this.bestFeatureFootprint?.geometry;switch(s?.type){case"polygon":{const e=t.spatialReference.equals(s.spatialReference)?t:await G(t,s.spatialReference);a=s.contains(e);break}case"mesh":{const e=t.spatialReference.equals(s.spatialReference)?t:await G(t,s.spatialReference);r=s.extent.contains(e);break}}if(!a&&!r)return void this.clearReferencePointOnImage();const o=await this._transformationService.pointToPixel(t,i);if(o)return v(i),this.plotReferencePointOnImage(o),{x:o.x,y:o.y};this.clearReferencePointOnImage()}async updateFeatureCache(e,t){const i=await N(e,t);i.features?.length&&(this.featureCache=i.features)}async _fetchFeatures(e,t){const{layer:i,layerFloorFilterClause:a,layerTimeExtent:r,view:s}=this;if(!s||!i)return;e.x=B(e.x,e.spatialReference);const o=i.spatialReference.equals(e.spatialReference)?e:await G(e,i.spatialReference),n=o.spatialReference.isGeographic?R(o):o,l=P("1=1",P(i.definitionExpression,a)),c=n.spatialReference.isGeographic?1:S(n.spatialReference),h={layerInstanceOrURL:i,point:n,queryParams:{where:l,maximumDistance:i.maximumDistance?i.maximumDistance/c:void 0,timeExtent:r}};return await this.searchBestImage(h,t)}async _fetchFeaturesWithController(e,t){try{await this._fetchFeatures(e,t)}catch(i){if(y(i))return;this.setMessage("imageLoadError","error"),d.getLogger(this).error("error occurred while fetching features",i)}}_groupFeaturesBySectors(){const{_suitabilities:e,additionalFeatures:t,features:i,invalidCameraHeading:a}=this,r=i.at(0);if(!e||!t||!r||!i||a)return void(this._sectorData=null);this._sectorData={};const o={};this._featureToSector=o;for(const h of _e)this._sectorData[h]=new s;const n=e.map((e,t)=>({...e,featureIndex:t}));n.sort((e,t)=>e.trueSuitability-t.trueSuitability);const l=n.map(({distance:e})=>e),c=Math.max(...l);n.forEach(e=>{const{distance:t,angle:a,featureIndex:s}=e,n=t/c*Me[2],l=We(t,c),h=Je(a);if(!this._sectorData)return;const d=Me[3]+n*Math.sin(a*Math.PI/180),u=Me[3]+n*Math.cos(a*Math.PI/180);let p;const m=i.at(s),g=m===r,{cameraPitch:y}=m.attributes,v=y<5;if(g&&v)p=-90;else{const e=d-Me[3],t=u-Me[3],i=t/Math.sqrt(e**2+t**2);let a=180*Math.acos(i)/Math.PI;(e<0&&t<0||e<0&&t>0)&&(a*=-1),p=a}const f=""===l?h:`${l}_${h}`;g&&(p===this.bestFeatureAngle?this.previousFeatureAngle=p:this.bestFeatureAngle=p,this.navigatorCurrentBestFeature=v?null:{x:d,y:u,direction:h}),o[`${m.attributes.objectId}`]=f;const w=this._sectorData[f];w.add({angle:a,featureIndex:s,x:d,y:u,objectID:m.attributes.objectId,sector:f,featureIndexInSector:w.length})})}async _initializeLocationViewModel(e){if(!this._locationViewModel){const t=import("./components/ImageLocationViewModel.js"),{default:i}=await t;v(e),this._locationViewModel=new i({oiViewModel:this,referenceTransformationService:this._referenceTransformationService})}}_initializeMeasurementService(){this._measurementService||(this._measurementService=new at({transformationService:this._transformationService,referenceTransformationService:this._referenceTransformationService}))}_initializeVideo(){if(this.videoElement||!this.currentBestFeature)return;this.removeHandles(Ee.videoPlayerHandles),this.videoElement=new le({video:this.currentBestFeature.attributes.imagePath,georeference:new oe({extent:new L(fe)}),autoplay:!1}),this.videoElement.content?.loop&&(this.videoElement.content.loop=!1);const e=new D({source:this.videoElement,title:this.layer?.title,copyright:this.layer?.copyright});this.videoLayer=e,e&&this.videoMapView.map.layers.add(e),this.videoViewModel=new et({oiViewModel:this})}async getMapPoint(e,t){const i=await this._transformationService.pixelToMapPoint(Array.isArray(e)?e:[e],t);return Array.isArray(e)?i:i[0]}async getMapPointForFeature(e,t,i){const a=await this._transformationService.pixelToMapPointForFeature(Array.isArray(e)?e:[e],t,i);return Array.isArray(e)?a:a[0]}async loadPanoramicMediaSource(e,t){const{lookAt:i,...a}=e,r=Ne(a);try{await r.load(t)}catch(o){if(y(o))return;if("unsupported-format"===o.name)return void this.setMessage("unsupportedPanoramicImageryError","error",void 0,{datasetFormat:r?.extension??"UNKNOWN FORMAT"})}const s=this.triangularMeasurementActive?this._panoramicMeasurementViewer:this._panoramicViewer;await s.loadMedia(r,t),i&&s.set(i)}async loadMediaSource(e,t){const i=Ue(e);await this._setImageSource(this.triangularMeasurementActive?this.imageMeasurementViewer:this._imageViewer,i,t)}_clearFeatureGeometries(){this.coveragePolygons.removeAll(),this.coverageFrustums.removeAll(),this.pointSources.removeAll()}_checkFeatures(e){return!!e?.length||(this.setMessage("noImageError","error"),this.videoElement?.content?.pause(),this.currentBestFeature=null,!1)}async _getElevationSampleFromGround(e,t,i){if(!e[0])return;const a=(await import("../../geometry/operators/unionOperator.js")).executeMany(e);if(this._updateFootprintWithFeatures(t,a),"3d"===this.view?.type)try{return await this.view.map.ground.createElevationSampler(this.footprintExtent,i)}catch(r){y(r)||d.getLogger(this).error(r)}}async processElevationSample(e,t,i){const{elevationSource:a}=t[0].attributes,r=await this._getElevationSampleFromGround(e,t,i);return r||(a&&this.footprintExtent&&Z(a)?await Y({extent:this.footprintExtent,lod:a.lod,url:a.url,rasterFunction:a.rasterFunction}):void 0)}_processSuitableFeatures(e,t){return U({features:e,selectedPoint:t,camera:qe(this.view)?this.view.camera:null,currentImage:this.currentBestFeature})}async _processHitTestResults(e,t,i){const{results:[a]}=t;if("graphic"!==a?.type)return void this.setMessage("noImageError","error");const r=a.graphic.getAttribute(e.objectIdField);return await this.showImageByObjectId(r,i)}async _queryAndLoadByObjectId(e,t,i,a,r){this.displayMessage=null;const{response:s}=await it(e,t,i,a,r);if(v(r),!s?.features?.length)throw new tt(t);const o=q(s.features[0].attributes).polygon,n=j.fromJSON(E(o)),l=Q(n),c=S(l.spatialReference);this.selectedPoint=l;const h={layerInstanceOrURL:e,point:l,queryParams:{where:P(P("1=1",P(e.definitionExpression,i)),`${e.objectIdField} <> ${t}`),maximumDistance:e.maximumDistance?e.maximumDistance/c:void 0,timeExtent:a}},d=await z(h,r);v(r);const{features:u}=d;return u.push(s.features[0]),await this.processFeatureResponse(d,l,{...r,loadBestImage:!1})}_reorderTriangularSketchLayer(){const e=this.imageMeasurementViewer.imageRenderer.map.layers?.length;this.sketchTriangularGraphicsLayer&&e&&this.imageMeasurementViewer.imageRenderer.map.layers.reorder(this.sketchTriangularGraphicsLayer,e-1)}async _setImageSource(e,t,i){e.media=t,await e.loadMedia(t,i)}_toggleVisiblity(e,t){e.forEach(e=>{e.visible=t})}async _updateElevationOfSelectedPointAndLocations(e,t,i,a){const{location:r,cameraHeight:s}=e[0].attributes,o=await ae(r.spatialReference,r.z,s,{elevationSample:i,elevationSource:i?void 0:e[0].attributes.elevationSource,extent:this.footprintExtent},a);v(a);const[n,...l]=await X([t,...e.map(e=>e.attributes.geometry.clone())],o);v(a),t.elevation=n.z,e.forEach((e,t)=>{e.attributes.elevation=l[t].z})}_updateFeatures(e,t=!0){if(!e.length)return this.currentBestFeature=null,void this.additionalFeatures.removeAll();this.features.removeAll(),this.features.addMany(e),this.navigationNodes.removeAll(),this.navigationNodes.addMany(e.map(e=>{const{geometry:t,attributes:i}=e,{isSpherical:a,cameraHeading:r,cameraPitch:s}=i;return new Ye({geometry:t,attributes:i,currentHeading:a?0:r,currentPitch:a?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 i=[];for(const{attributes:{geometry:a}}of e)t.contains(a)||i.push([a.x,a.y]);i.sort((e,t)=>+x([e,t])),t.addRing(i),this.footprintExtent=de(t.extent,2,2)}async _updatePointsAndPolygons(e){const{pointSources:i,currentBestFeature:a,currentCoverageVisible:r,isAdditionalPointSourcesVisible:s,mode:o,layer:n}=this;if(a&&(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 i){const i=this.view&&!this.view.spatialReference?.equals(o.spatialReference)?await G(o.clone(),this.view?.spatialReference,e):o.clone();o.imageID===a.attributes.objectId?this.currentBestFeatureLocation=new t({attributes:{imageID:o.imageID},geometry:i,symbol:Ge,visible:r}):this.additionalCameraLocations.push(new t({attributes:{imageID:o.imageID},geometry:i,symbol:Oe,visible:s}))}"video"!==o&&"panoramic-video"!==o||(await this.initializeTransformationService(e),n&&!this.featureCache.length&&await this.updateFeatureCache(n,a.geometry.spatialReference))}}_updateCurrentBestFeature(e){if(!e)return;if(this.currentBestFeature=this.features?.at(e.featureIndex),"video"===this.mode)return void(this.currentBestFeature&&this.videoViewModel?.playVideoFromSelectedLocation(this.currentBestFeature));if("panoramic-video"===this.mode)return void(this.currentBestFeature&&this._panoramicVideoViewer.viewModel.playPanoramicVideoFromSelectedLocation(this.currentBestFeature));const t=this.currentBestFeature?.attributes.cameraPitch&&this.currentBestFeature?.attributes.cameraPitch<5;let i;if(t)i=-90;else{const t=e.x-Me[3],a=e.y-Me[3],r=a/Math.sqrt(t**2+a**2);let s=180*Math.acos(r)/Math.PI;(t<0&&a<0||t<0&&a>0)&&(s*=-1),i=s}i===this.bestFeatureAngle?this.previousFeatureAngle=i:this.bestFeatureAngle=i,this.navigatorCurrentBestFeature=t?null:{x:e.x,y:e.y,direction:e.sector.includes("_")?e.sector.split("_")[1]:e.sector}}_updateImageMeasurementBestFeature(e){e&&(this.currentBestFeatureMeasurementImage=this.features?.at(e.featureIndex))}clearGraphics(){this._imageViewer.clearGraphics(),this._panoramicViewer.clearGraphics(),this.imageMeasurementViewer.clearGraphics(),this._panoramicMeasurementViewer.clearGraphics()}clearReferencePointOnImage(){this._referencePointOnImage&&(this._imageViewer.removeGraphic(this._referencePointOnImage),this._panoramicViewer.removeGraphic(this._referencePointOnImage),this._referencePointOnImage=p(this._referencePointOnImage))}async initializeReferenceTransformationService(e){const{currentBestFeatureMeasurementImage:t,activeTriangulatedViewer:i,mode:a}=this;if(!t||!i||!i.imageSize||"panoramic"!==a&&"default"!==a)return;const{imageSize:r}=i,{attributes:s,elevationSample:o}=t,{location:{spatialReference:n,z:l},cameraHeight:c,elevationSource:h}=s;let d=s.location;d.spatialReference.isGeographic&&(d=Q(d));const u="default"===a?re(s,r[0],r[1]):se(s,r[0],r[1]),p=await ae(n,l??0,c,{elevationSample:o,elevationSource:h,extent:this.footprintExtent},e),m=(await import("./services/TransformationService.js")).default,g={imageToWorldProperties:u,updateElevationProps:p,mode:a,imageSize:r,depthImageService:this.depthImage};this._referenceTransformationService=new m(g),this._locationViewModel&&(this._locationViewModel.referenceTransformationService=this._referenceTransformationService),this._measurementService&&(this._measurementService.referenceTransformationService=this._referenceTransformationService)}async initializeTransformationService(e){const{currentBestFeature:t,activeViewer:i,mode:a}=this,r="video"===a||"panoramic-video"===a?be:i?.imageSize;if(!t||!r||"none"===a)return;const{attributes:s,elevationSample:o}=t,{location:{spatialReference:n,z:l},cameraHeight:c,elevationSource:h}=s;let d=s.location;d.spatialReference.isGeographic&&(d=Q(d));const u="default"===a||"video"===a?"default":"panoramic",p={..."default"===u?re(s,r[0],r[1]):se(s,r[0],r[1]),cameraLocation:d},m=await ae(n,l??0,c,{elevationSample:o,elevationSource:h,extent:this.footprintExtent},e),g=(await import("./services/TransformationService.js")).default,y={imageToWorldProperties:p,updateElevationProps:m,mode:u,imageSize:r,depthImageService:this.depthImage};this._transformationService=new g(y),this._measurementService&&(this._measurementService.transformationService=this._transformationService)}plotReferencePoint(e){"mapPoint"in e?this.plotReferencePointOnGround(e.mapPoint):this.plotReferencePointOnGround(e)}setMessage(e,t,i,a){this.displayMessage={key:e,type:t,data:i,map:a}}async transformAndPlotSelectedLocation(e){const{currentBestFeature:t,invalidCameraHeading:i,selectedPoint:a,activeViewer:r}=this;if(this._crossSymbol&&(this._panoramicViewer.removeGraphic(this._crossSymbol),this._imageViewer.removeGraphic(this._crossSymbol),this._crossSymbol=p(this._crossSymbol)),!a||!t||"image-loaded"!==r?.state||i)return;let s;try{s=await this._transformationService.pointToPixel(a,{signal:e?.signal}),v(e),await this.plotSelectedPointOnImage(s,e)}catch(o){y(o)||d.getLogger(this).error("failed to transform map point to pixel, cross symbol will not be plotted on image",{error:o,selectedPoint:a,feature:t})}}updateCurrentCoveragePolygon(e){const{additionalFootprints:i,additionalCameraLocations:a,currentBestFeature:r,currentBestFeatureLocation:s,currentCoverageVisible:o,selectedPoint:n,view:l,_adapter:c,mode:h}=this;if(!r)return;const{attributes:{objectId:d},elevationSample:u}=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),l){const e=[...i,...a,s].filter($e);"3d"===l?.type&&u&&c?.updateGroundElevation&&(this._updateGroundElevation&&c.updateGroundElevation(e),"panoramic"===h&&c.updateGroundElevation([this.bestFeatureCurrentFootprint])),this._updateGroundElevation=!1,n&&(e.splice(-2,0,this.bestFeatureCurrentFootprint),e.push(new t({geometry:n.clone(),symbol:Ve.clone(),attributes:{imageID:d}}))),this._overlays.graphics.addMany(e)}}else if(l){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"===l?.type&&u&&c?.updateGroundElevation&&"panoramic"===h&&c.updateGroundElevation([e]),e.visible=this.currentCoverageVisible,this._overlays?.graphics.add(this.bestFeatureCurrentFootprint,t>=0?t:this._overlays.graphics.length-1))}}};e([A()],ut.prototype,"activeLayer",null),e([A({readOnly:!0})],ut.prototype,"activeViewer",null),e([A()],ut.prototype,"activeTriangulatedViewer",null),e([A()],ut.prototype,"accuracyParametersMissing",null),e([A()],ut.prototype,"additionalFeatures",void 0),e([A({type:s.ofType(t)})],ut.prototype,"additionalCameraLocations",void 0),e([A({type:s.ofType(t)})],ut.prototype,"additionalFootprints",void 0),e([A()],ut.prototype,"areaMeasurementResult",void 0),e([A()],ut.prototype,"areaMeasurementAccuracy",void 0),e([A()],ut.prototype,"bestFeatureAngle",void 0),e([A()],ut.prototype,"bestFeatureCurrentFootprint",void 0),e([A({type:t})],ut.prototype,"bestFeatureFootprint",void 0),e([A({type:Number})],ut.prototype,"brightness",null),e([A()],ut.prototype,"cameraHeadingThreshold",void 0),e([A()],ut.prototype,"cameraPitchThreshold",void 0),e([A()],ut.prototype,"clickAction",void 0),e([A()],ut.prototype,"correctedLocationPointOnImage",void 0),e([A()],ut.prototype,"videoViewModel",void 0),e([A()],ut.prototype,"collectionId",void 0),e([A({type:Number})],ut.prototype,"contrast",null),e([A()],ut.prototype,"coverageFrustums",void 0),e([A()],ut.prototype,"coveragePolygons",void 0),e([A()],ut.prototype,"currentBestFeature",void 0),e([A()],ut.prototype,"currentBestFeatureMeasurementImage",void 0),e([A()],ut.prototype,"currentBestFeatureLocation",void 0),e([A()],ut.prototype,"currentCoverageVisible",void 0),e([A()],ut.prototype,"currentNode",null),e([A()],ut.prototype,"depthImage",void 0),e([A()],ut.prototype,"depthImageNotSupported",null),e([A()],ut.prototype,"featureCache",void 0),e([A()],ut.prototype,"navigationNodes",void 0),e([A({json:{write:!1}})],ut.prototype,"determineWorkflowForFeature",void 0),e([A({json:{write:!1}})],ut.prototype,"determineWorkflowForTriangularMeasurement",void 0),e([A()],ut.prototype,"disabled",void 0),e([A()],ut.prototype,"displayMessage",void 0),e([A()],ut.prototype,"displayNewMeasurementButton",void 0),e([A()],ut.prototype,"distanceMeasurementResult",void 0),e([A()],ut.prototype,"distanceAccuracyArray",void 0),e([A()],ut.prototype,"dataCaptureLayer",void 0),e([A({readOnly:!0})],ut.prototype,"featureCount",null),e([A()],ut.prototype,"features",void 0),e([A()],ut.prototype,"groundCoordinates",void 0),e([A()],ut.prototype,"groundCoordinatesAccuracy",void 0),e([A()],ut.prototype,"heightGraphic",void 0),e([A()],ut.prototype,"heightMeasurementResult",void 0),e([A()],ut.prototype,"heightMeasurementAccuracy",void 0),e([A({readOnly:!0})],ut.prototype,"imageGalleryEnabled",null),e([A()],ut.prototype,"imageGeometryField",void 0),e([A({readOnly:!0})],ut.prototype,"imageLoaded",null),e([A()],ut.prototype,"imageLocationToolState",void 0),e([A()],ut.prototype,"initialVideoMapViewExtent",void 0),e([A({readOnly:!0})],ut.prototype,"invalidCameraHeading",null),e([A()],ut.prototype,"imagePointsInView",null),e([A()],ut.prototype,"imageMeasurementViewer",void 0),e([A()],ut.prototype,"isAdditionalCoverageVisible",void 0),e([A()],ut.prototype,"isAdditionalPointSourcesVisible",void 0),e([A()],ut.prototype,"layer",void 0),e([A()],ut.prototype,"layerView",null),e([A({readOnly:!0})],ut.prototype,"layerFloorFilterClause",null),e([A({readOnly:!0})],ut.prototype,"layerTimeExtent",null),e([A({type:Number})],ut.prototype,"localPort",void 0),e([A()],ut.prototype,"locationPointOnImage",void 0),e([A()],ut.prototype,"mapImageConversionToolState",void 0),e([A()],ut.prototype,"measureType",void 0),e([A()],ut.prototype,"measurementGraphic",void 0),e([A({readOnly:!0,value:"none"})],ut.prototype,"mode",null),e([A()],ut.prototype,"navigationMode",void 0),e([A()],ut.prototype,"navigatorCurrentBestFeature",void 0),e([A()],ut.prototype,"oiObjectIdField",void 0),e([A({type:s.ofType(t)})],ut.prototype,"overlayedCameraLocations",void 0),e([A()],ut.prototype,"overlayedMapFeatures",void 0),e([A()],ut.prototype,"panoramicVideoLoaded",null),e([A()],ut.prototype,"pixelCoordinates",void 0),e([A()],ut.prototype,"preserveAngle",void 0),e([A()],ut.prototype,"pointSources",void 0),e([A({readOnly:!0})],ut.prototype,"popupEnabled",null),e([A()],ut.prototype,"preloadMedia",void 0),e([A()],ut.prototype,"preloadMediaSize",void 0),e([A()],ut.prototype,"previousFeatureAngle",void 0),e([A()],ut.prototype,"referencePoint",null),e([A({readOnly:!0})],ut.prototype,"sectorData",null),e([A()],ut.prototype,"selectedPoint",void 0),e([A({type:Number})],ut.prototype,"sharpness",null),e([A()],ut.prototype,"shouldShowSelectedImage",void 0),e([A()],ut.prototype,"sketch",void 0),e([A()],ut.prototype,"sketchTriangular",void 0),e([A()],ut.prototype,"sketchTriangularGraphicsLayer",void 0),e([A()],ut.prototype,"draw",void 0),e([A()],ut.prototype,"drawAdapter",void 0),e([A()],ut.prototype,"polylineDrawAction",void 0),e([A()],ut.prototype,"scheduledFrameId",void 0),e([A()],ut.prototype,"sketchAdapter",void 0),e([A({readOnly:!0})],ut.prototype,"sketchGraphicsLayer",null),e([A({readOnly:!0})],ut.prototype,"state",null),e([A({readOnly:!0})],ut.prototype,"thumbnails",null),e([A()],ut.prototype,"videoExtentPoints",null),e([A()],ut.prototype,"triangularMeasurementActive",void 0),e([A()],ut.prototype,"triangulatedDistanceMeasurement",void 0),e([A()],ut.prototype,"triangulatedDistanceAccuracy",void 0),e([A()],ut.prototype,"triangulatedAreaMeasurement",void 0),e([A()],ut.prototype,"triangulatedAreaAccuracy",void 0),e([A()],ut.prototype,"triangulatedMeasurementGraphic",void 0),e([A()],ut.prototype,"triangulatedPoint",void 0),e([A()],ut.prototype,"triangulatedMeasurementAdapter",void 0),e([A()],ut.prototype,"updateFootprint",void 0),e([A()],ut.prototype,"updateVideoFootprint",void 0),e([A()],ut.prototype,"updateFootprintPanorama",void 0),e([A()],ut.prototype,"updatingTriangularMeasurementState",void 0),e([A({value:null})],ut.prototype,"view",null),e([A()],ut.prototype,"videoElement",void 0),e([A()],ut.prototype,"videoLayer",void 0),e([A()],ut.prototype,"videoMapView",void 0),e([A()],ut.prototype,"verticalFilterEnabled",void 0),e([A()],ut.prototype,"_adapter",void 0),e([A()],ut.prototype,"_defaultGraphicsLayer",null),e([A()],ut.prototype,"_highlightedFeatureHandle",void 0),e([A()],ut.prototype,"_imageViewer",void 0),e([A()],ut.prototype,"_initialCurrentCoverageUpdate",void 0),e([A()],ut.prototype,"_locationViewModel",void 0),e([A()],ut.prototype,"_measurementService",void 0),e([A()],ut.prototype,"_mediaPrefetcher",void 0),e([A()],ut.prototype,"_navigationManager",void 0),e([A()],ut.prototype,"_overlays",void 0),e([A({readOnly:!0})],ut.prototype,"_overlaysView",null),e([A()],ut.prototype,"_panoramicVideoViewer",void 0),e([A()],ut.prototype,"_panoramicViewer",void 0),e([A()],ut.prototype,"_panoramicMeasurementViewer",void 0),e([A()],ut.prototype,"_referencePointOnGround",void 0),e([A()],ut.prototype,"_referencePointOnImage",void 0),e([A()],ut.prototype,"_referenceTransformationService",void 0),e([A()],ut.prototype,"_sectorData",void 0),e([A()],ut.prototype,"_transformationService",void 0),e([A()],ut.prototype,"_featureToSector",void 0),e([A({readOnly:!0})],ut.prototype,"_updatingHandles",void 0),e([A()],ut.prototype,"footprintExtent",void 0),e([A()],ut.prototype,"_featureChangedTask",void 0),ut=e([C("esri.widgets.OrientedImageryViewer.OrientedImageryViewerViewModel")],ut);const pt=ut;export{pt as default};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.0/LICENSE.txt */
2
- import{__decorate as e}from"tslib";import t from"../../../../Graphic.js";import{createTask as a}from"../../../../core/asyncUtils.js";import{EsriPromise as i}from"../../../../core/Promise.js";import{throwIfAborted as r}from"../../../../core/promiseUtils.js";import{property as s,subclass as n}from"../../../../core/accessorSupport/decorators.js";import o from"../../../../geometry/Polygon.js";import l from"../../../../geometry/Polyline.js";import{load as c}from"../../../../geometry/projectionUtils.js";import u from"../../../../geometry/SpatialReference.js";import h from"../../../../layers/GraphicsLayer.js";import{convertSphereVertexToPixelLocation as m,convertPixelToHeadingPitch as d,convertHeadingPitchToSphereVertex as w}from"../../../../layers/orientedImagery/transformations/utils.js";import{getMeasurementProperties as p,getMeasurementPropertiesPanoramic as y,pixelAreaMeasurement2D as g,pixelAreaMeasurementPanoramic as v,pixelDistanceMeasurement2D as M,pixelDistanceMeasurementPanoramic as f,getPixelLocationFromSphereVertices as T,formatPixels as A,imageToImageTransform as V,imageToImageTransformPanoramic as k}from"../../imageMeasurementUtils.js";import{extractHorizonAnglesFromMedia as S}from"../../utils.js";import{SketchHandlerMixin as _}from"../../mixins/SketchHandlerMixin.js";import x from"../../../Sketch/SketchViewModel.js";let F=[],z=[],G=0,B=class extends(_(i)){constructor(e){super(e),this.type="measurement",this.measurementArray=[],this.pixelMeasurement=0,this.pixelAreaMeasurement=0,this.polygonVertices=[],this._calculationTask=null,this._distanceCalculation=0,this._areaCalculation=null}initialize(){this.addResolvingPromise(c())}async handleCreate(e){const t=e.toolEventInfo;switch(e.tool){case"polyline":await this.handlePolylineEvents(e,t);break;case"polygon":await this.handlePolygonEvents(e,t)}}handleDelete(e){this.resetDistanceMeasurements(),this.resetAreaMeasurements()}handleDestroy(){this.resetDistanceMeasurements(),this.resetAreaMeasurements()}async calculateAreaMeasurement(e,t,a){if(e.length<3||!this.viewModel.currentBestFeature||!this.viewModel.activeViewer?.imageSize||"none"===this.viewModel.mode)return null;const i="default"===t?await p(this.viewModel.currentBestFeature,this.viewModel.activeViewer?.imageSize,this.viewModel.footprintExtent):await y(this.viewModel.currentBestFeature,this.viewModel.activeViewer?.imageSize,this.viewModel.footprintExtent);return r(a),i?"default"===t?await g(e,i,!0):await v(e,i,!0,a):null}async calculateDistanceMeasurement(e,t,a){const{currentBestFeature:i,activeViewer:s}=this.viewModel;if(e.length<2||!i||!s?.imageSize||"none"===t)return null;const n="default"===t?await p(i,s?.imageSize,this.viewModel.footprintExtent):await y(i,s?.imageSize,this.viewModel.footprintExtent);return r(a),n?"default"===t?await M([e.at(0),e.at(-1)],n,!0):await f([e.at(0),e.at(-1)],n,!0):null}cursorUpdatePolylineHandler(e){const{mode:t,activeViewer:a}=this.viewModel;if("none"===t||!a?.imageSize)return;if("default"===t)this.measurementArray.push(e.coordinates);else{const t={x:e.coordinates[0],y:e.coordinates[1],z:e.coordinates[2]},i=m(t,a.imageSize[0],a.imageSize[1]);this.measurementArray.push([i.x,i.y])}const i=z.reduce((e,t)=>e+t,0)+this.pixelMeasurement;this.viewModel.distanceMeasurementResult=i}async cursorUpdatePolygonHandler(e){const{mode:t,activeViewer:a}=this.viewModel;if("none"===t||!a?.imageSize)return;const i=e.coordinates;if(F=[...this.polygonVertices],"default"===t)F.push(i);else{const e={x:i[0],y:i[1],z:i[2]},t=m(e,a?.imageSize[0],a?.imageSize[1]);F.push([t.x,t.y])}if(F.length<3||!this.viewModel.currentBestFeature||!this.viewModel.activeViewer?.imageSize)return;const r=F[0];F=F.filter((e,t)=>0===t||t===F.length-1||JSON.stringify(e)!==JSON.stringify(r));const s=await this._getAreaFromTask(F);s?.area&&s?.perimeter&&(G=s.area)}async handlePolylineEvents(e,t){const{currentBestFeature:a,activeViewer:i,mode:r,view:s}=this.viewModel,n=!this.viewModel.accuracyParametersMissing;if("cancel"===e.state)return this.resetDistanceMeasurements(),this.viewModel.distanceMeasurementResult=0,this.viewModel.distanceAccuracyArray=[],void(this.viewModel.displayNewMeasurementButton=!0);if("complete"===e.state&&e.graphic){if(this.viewModel.activeViewer?.addGraphic(e.graphic),this.viewModel.triangularMeasurementActive&&a){const t={pixels:e.graphic.geometry.paths[0],activeFeature:a,activeViewer:i,mode:r,spatialReference:s?.spatialReference};await(this.measurementService?.updateMeasurementVectorsArray(t)),await this._overlayFirstMeasurement(e.graphic,e.tool)}return this.viewModel.measurementGraphic=e.graphic,void this.resetDistanceMeasurements()}switch(t?.type){case"cursor-update":this.cursorUpdatePolylineHandler(t);break;case"vertex-add":if(this.measurementArray.length&&n){const e=await this._getAccuracyFromTask();e&&this.viewModel.distanceAccuracyArray.push(e)}this.vertexUpdatePolylineHandler()}const o=await this._getDistanceFromTask();this.pixelMeasurement=o??this.pixelMeasurement}async handlePolygonEvents(e,t){const{currentBestFeature:a,activeViewer:i,mode:r,view:s}=this.viewModel;if("cancel"===e.state)return this.resetAreaMeasurements(),this.viewModel.areaMeasurementResult=0,this.viewModel.areaMeasurementAccuracy=0,void(this.viewModel.displayNewMeasurementButton=!0);if("complete"===e.state&&e.graphic){if(this.viewModel.activeViewer?.addGraphic(e.graphic),this.viewModel.triangularMeasurementActive&&a){const t={pixels:e.graphic.geometry.rings[0],activeFeature:a,activeViewer:i,mode:r,spatialReference:s?.spatialReference};await(this.measurementService?.updateMeasurementVectorsArray(t)),await this._overlayFirstMeasurement(e.graphic,e.tool)}return this.viewModel.measurementGraphic=e.graphic,void this.resetAreaMeasurements()}switch(t?.type){case"vertex-add":await this.vertexAddPolygonHandler(t);break;case"cursor-update":await this.cursorUpdatePolygonHandler(t)}this.viewModel.areaMeasurementResult=G>0?G:this.pixelAreaMeasurement}async vertexAddPolygonHandler(e){const{mode:t,activeViewer:a,accuracyParametersMissing:i}=this.viewModel,r=!i,s=e.added,n=s[s.length-1];if(!Array.isArray(n)||"none"===t||!a?.imageSize)return;if("default"===t)this.polygonVertices.push(n);else{const e={x:n[0],y:n[1],z:n[2]},t=m(e,a?.imageSize[0],a?.imageSize[1]);this.polygonVertices.push([t.x,t.y])}if(this.polygonVertices.length<3||!this.viewModel.currentBestFeature||!this.viewModel.activeViewer?.imageSize)return;const o=this.polygonVertices[0];this.polygonVertices=this.polygonVertices.filter((e,t)=>0===t||t===this.polygonVertices.length-1||JSON.stringify(e)!==JSON.stringify(o));const l=await this._getAreaFromTask(this.polygonVertices);if(!l?.area||!l?.perimeter)return;if(r){const e=await this._getAreaAccuracyFromTask(this.polygonVertices);this.viewModel.areaMeasurementAccuracy=e&&e>this.viewModel.areaMeasurementAccuracy?e:this.viewModel.areaMeasurementAccuracy}const{area:c}=l;this.pixelAreaMeasurement=c}vertexUpdatePolylineHandler(){this.measurementArray=this.measurementArray.slice(-1);const e=z.reduce((e,t)=>e+t,0)+this.pixelMeasurement;this.viewModel.distanceMeasurementResult=e,this.pixelMeasurement>0&&z.push(this.pixelMeasurement)}resetDistanceMeasurements(){this.measurementArray=[],this.pixelMeasurement=0,z=[]}resetAreaMeasurements(){this.polygonVertices=[],this.pixelAreaMeasurement=0,G=0}async _editOverlayedGraphics(e){this.viewModel.sketchTriangularGraphicsLayer||this._initializeSketchTriangularGraphicsLayer(),this.viewModel.sketchTriangularGraphicsLayer?.destroyed&&this._handleDestroyedTriangularSketchLayer(),this.viewModel.sketchTriangularGraphicsLayer.add(e),this.viewModel.sketchTriangular||(this._initializeSketchTriangular(),await this._loadTriangulatedMeasurementAdapter()),this._updateOverlayedGeometry(e)}_handleDestroyedTriangularSketchLayer(){this.viewModel.sketchTriangularGraphicsLayer&&this.viewModel.activeTriangulatedViewer&&(this.viewModel.activeTriangulatedViewer.imageRenderer.map.layers.remove(this.viewModel.sketchTriangularGraphicsLayer),this.viewModel.sketchTriangularGraphicsLayer=new h,this.viewModel.activeTriangulatedViewer.imageRenderer.map.layers.add(this.viewModel.sketchTriangularGraphicsLayer),this.viewModel.sketchTriangular&&(this.viewModel.sketchTriangular.layer=this.viewModel.sketchTriangularGraphicsLayer,this.viewModel.sketchTriangular.view=this.viewModel.activeTriangulatedViewer.imageRenderer))}_initializeSketchTriangular(){if(!this.viewModel.activeTriangulatedViewer)return;const e="panoramic"===this.viewModel.mode;this.viewModel.sketchTriangular=new x({view:this.viewModel.activeTriangulatedViewer.imageRenderer,layer:this.viewModel.sketchTriangularGraphicsLayer,updateOnGraphicClick:!1,defaultUpdateOptions:{toggleToolOnClick:!1,enableZ:!e}}),e&&(this.viewModel.sketchTriangular.defaultUpdateOptions.reshapeOptions={edgeOperation:"offset",shapeOperation:"move-xy",vertexOperation:"move-xy"})}_initializeSketchTriangularGraphicsLayer(){this.viewModel.activeTriangulatedViewer&&(this.viewModel.sketchTriangularGraphicsLayer=new h,this.viewModel.activeTriangulatedViewer.imageRenderer.map.layers.add(this.viewModel.sketchTriangularGraphicsLayer))}async _overlayFirstMeasurement(e,t){switch(t){case"polyline":await this._overlayFirstDistanceMeasurement(e);break;case"polygon":await this._overlayFirstAreaGeometry(e)}}async _overlayFirstDistanceMeasurement(e){const{mode:a,activeTriangulatedViewer:i,currentBestFeature:r,activeViewer:s,footprintExtent:n,currentBestFeatureMeasurementImage:o}=this.viewModel,c=e.geometry?.clone(),h=e.symbol?.clone(),m=i?.imageSize,d=[...c.paths[0]],w=S(i?.media),g="default"===a;if(!("none"!==a&&"video"!==a&&m&&r&&s?.imageSize&&o))return;const v=g?d:T(d,m,w),M=g?A(v,!0):v,f=g?await p(r,s?.imageSize,n):await y(r,s?.imageSize,n),_=g?await p(o,this.viewModel.imageMeasurementViewer?.imageSize,n):await y(o,this.viewModel.activeTriangulatedViewer?.imageSize,n);if(M?.length&&f&&_){const e=g?await V(M,f,_):await k(M,f,_),a=e.map(e=>[e.x-.5,-.5-e.y]),i=e.slice(0,2).map(e=>R(e,m,w)),r=new l({paths:g?[a]:[i],spatialReference:u.WebMercator}),s=new t({geometry:r,symbol:h});await this._editOverlayedGraphics(s)}}async _overlayFirstAreaGeometry(e){const{mode:a,activeTriangulatedViewer:i,currentBestFeature:r,currentBestFeatureMeasurementImage:s,activeViewer:n,footprintExtent:l}=this.viewModel,c=e.geometry?.clone(),h=e.symbol?.clone(),m=i?.imageSize,d=S(i?.media),w=[...c.rings[0]],g="default"===a;if(!("none"!==a&&"video"!==a&&m&&r&&n?.imageSize&&s))return;const v=g?w:T(w,m,d),M=g?A(v,!0):v,f=g?await p(r,n?.imageSize,l):await y(r,n?.imageSize,l),_=g?await p(s,this.viewModel.imageMeasurementViewer?.imageSize,l):await y(s,this.viewModel.activeTriangulatedViewer?.imageSize,l);if(M?.length&&f&&_){const e=g?await V(M,f,_):await k(M,f,_),a=e.map(e=>[e.x-.5,-.5-e.y]),i=e.slice(0,g?2:e.length).map(e=>R(e,m,d)),r=new o({rings:g?[a]:[i],spatialReference:u.WebMercator}),s=new t({geometry:r,symbol:h});await this._editOverlayedGraphics(s)}}async _loadTriangulatedMeasurementAdapter(e){if(!this.viewModel.triangulatedMeasurementAdapter){const t=import("./TriangulatedMeasurementAdapter.js"),{default:a}=await t;if(r(e),this.viewModel.triangulatedMeasurementAdapter=new a({viewModel:this.viewModel,measurementService:this.measurementService}),!this.viewModel.triangulatedMeasurementAdapter.viewModel.isResolved())return}return this.viewModel.triangulatedMeasurementAdapter}async _getAreaFromTask(e){const{mode:t}=this.viewModel;return this._calculationTask?.abort(),this._calculationTask=a(async a=>{this._areaCalculation=null;const i=await this.calculateAreaMeasurement(e,t,a);r(a),this._areaCalculation=i}),await this._calculationTask.promise,this._areaCalculation}async _getDistanceFromTask(){const{mode:e}=this.viewModel;return this._calculationTask?.abort(),this._calculationTask=a(async t=>{this._distanceCalculation=0;const a=await this.calculateDistanceMeasurement(this.measurementArray,e,t);r(t),this._distanceCalculation=a}),await this._calculationTask.promise,this._distanceCalculation}async _getAccuracyFromTask(){const{mode:e,currentBestFeature:t,currentBestFeatureMeasurementImage:i,activeViewer:s,activeTriangulatedViewer:n,layer:o,footprintExtent:l}=this.viewModel,c=s?.imageSize;return"none"!==e&&c?(this._calculationTask?.abort(),this._calculationTask=a(async a=>{this._distanceCalculation=0;const u={measurementArray:this.measurementArray,measurementType:"distance",currentBestFeature:t,currentBestFeatureMeasurementImage:i,activeViewer:s,imageSize:c,layer:o,triangularMeasurementActive:!1,footprintExtent:l,signal:a},h={measurementArray:this.measurementArray,measurementType:"distance",secondaryViewer:!1,currentBestFeature:t,currentBestFeatureMeasurementImage:i,activeViewer:s,activeTriangulatedViewer:n,layer:o,footprintExtent:l,signal:a},m="default"===e?await(this.measurementService?.calculateAccuracy(u)):await(this.measurementService?.calculateAccuracyPanoramic(h));r(a),this._distanceCalculation=m}),await this._calculationTask.promise,this._distanceCalculation):null}async _getAreaAccuracyFromTask(e){const{mode:t,currentBestFeature:i,currentBestFeatureMeasurementImage:s,activeViewer:n,activeTriangulatedViewer:o,layer:l,footprintExtent:c}=this.viewModel,u=n?.imageSize;return"none"!==t&&u?(this._calculationTask?.abort(),this._calculationTask=a(async a=>{this._distanceCalculation=0;const h={measurementArray:e,measurementType:"area",currentBestFeature:i,currentBestFeatureMeasurementImage:s,activeViewer:n,imageSize:u,layer:l,triangularMeasurementActive:!1,footprintExtent:c,signal:a},m={measurementArray:e,measurementType:"area",secondaryViewer:!1,currentBestFeature:i,currentBestFeatureMeasurementImage:s,activeViewer:n,activeTriangulatedViewer:o,layer:l,footprintExtent:c,signal:a},d="default"===t?await(this.measurementService?.calculateAccuracy(h)):await(this.measurementService?.calculateAccuracyPanoramic(m));r(a),this._distanceCalculation=d}),await this._calculationTask.promise,this._distanceCalculation):null}_updateOverlayedGeometry(e){this.viewModel.sketchTriangular?.update([e],{tool:"reshape"})}};e([s()],B.prototype,"type",void 0),e([s()],B.prototype,"measurementArray",void 0),e([s()],B.prototype,"pixelMeasurement",void 0),e([s()],B.prototype,"pixelAreaMeasurement",void 0),e([s()],B.prototype,"polygonVertices",void 0),B=e([n("esri.widgets.OrientedImageryViewer.adapters.sketch.MeasurementAdapter")],B);const P=B,R=(e,t,a)=>{const{heading:i,pitch:r}=d(e,t[0],t[1]);return w(i,r,a)};export{P as default};
2
+ import{__decorate as e}from"tslib";import t from"../../../../Graphic.js";import{createTask as a}from"../../../../core/asyncUtils.js";import{EsriPromise as i}from"../../../../core/Promise.js";import{throwIfAborted as r}from"../../../../core/promiseUtils.js";import{property as s,subclass as n}from"../../../../core/accessorSupport/decorators.js";import o from"../../../../geometry/Polygon.js";import l from"../../../../geometry/Polyline.js";import{load as c}from"../../../../geometry/projectionUtils.js";import u from"../../../../geometry/SpatialReference.js";import h from"../../../../layers/GraphicsLayer.js";import{convertSphereVertexToPixelLocation as m,convertPixelToHeadingPitch as d,convertHeadingPitchToSphereVertex as w}from"../../../../layers/orientedImagery/transformations/utils.js";import{getMeasurementProperties as p,getMeasurementPropertiesPanoramic as g,pixelAreaMeasurement2D as y,pixelAreaMeasurementPanoramic as v,pixelDistanceMeasurement2D as M,pixelDistanceMeasurementPanoramic as f,getPixelLocationFromSphereVertices as T,formatPixels as A,imageToImageTransform as V,imageToImageTransformPanoramic as k}from"../../imageMeasurementUtils.js";import{extractHorizonAnglesFromMedia as S}from"../../utils.js";import{SketchHandlerMixin as _}from"../../mixins/SketchHandlerMixin.js";import x from"../../../Sketch/SketchViewModel.js";let F=[],z=[],G=0,B=class extends(_(i)){constructor(e){super(e),this.type="measurement",this.measurementArray=[],this.pixelMeasurement=0,this.pixelAreaMeasurement=0,this.polygonVertices=[],this._calculationTask=null,this._distanceCalculation=0,this._areaCalculation=null}initialize(){this.addResolvingPromise(c())}async handleCreate(e){const t=e.toolEventInfo;switch(e.tool){case"polyline":await this.handlePolylineEvents(e,t);break;case"polygon":await this.handlePolygonEvents(e,t)}}handleDelete(e){this.resetDistanceMeasurements(),this.resetAreaMeasurements()}handleDestroy(){this.resetDistanceMeasurements(),this.resetAreaMeasurements()}async calculateAreaMeasurement(e,t,a){if(e.length<3||!this.viewModel.currentBestFeature||!this.viewModel.activeViewer?.imageSize||"none"===this.viewModel.mode)return null;const i="default"===t?await p(this.viewModel.currentBestFeature,this.viewModel.activeViewer?.imageSize,this.viewModel.footprintExtent):await g(this.viewModel.currentBestFeature,this.viewModel.activeViewer?.imageSize,this.viewModel.footprintExtent);return r(a),i?"default"===t?await y(e,i,!0):await v(e,i,!0,a):null}async calculateDistanceMeasurement(e,t,a){const{currentBestFeature:i,activeViewer:s}=this.viewModel;if(e.length<2||!i||!s?.imageSize||"none"===t)return null;const n="default"===t?await p(i,s?.imageSize,this.viewModel.footprintExtent):await g(i,s?.imageSize,this.viewModel.footprintExtent);return r(a),n?"default"===t?await M([e.at(0),e.at(-1)],n,!0):await f([e.at(0),e.at(-1)],n,!0):null}cursorUpdatePolylineHandler(e){const{mode:t,activeViewer:a}=this.viewModel;if("none"===t||!a?.imageSize)return;if("default"===t)this.measurementArray.push(e.coordinates);else{const t={x:e.coordinates[0],y:e.coordinates[1],z:e.coordinates[2]},i=m(t,a.imageSize[0],a.imageSize[1]);this.measurementArray.push([i.x,i.y])}const i=z.reduce((e,t)=>e+t,0)+this.pixelMeasurement;this.viewModel.distanceMeasurementResult=i}async cursorUpdatePolygonHandler(e){const{mode:t,activeViewer:a}=this.viewModel;if("none"===t||!a?.imageSize)return;const i=e.coordinates;if(F=[...this.polygonVertices],"default"===t)F.push(i);else{const e={x:i[0],y:i[1],z:i[2]},t=m(e,a?.imageSize[0],a?.imageSize[1]);F.push([t.x,t.y])}if(F.length<3||!this.viewModel.currentBestFeature||!this.viewModel.activeViewer?.imageSize)return;const r=F[0];F=F.filter((e,t)=>0===t||t===F.length-1||JSON.stringify(e)!==JSON.stringify(r));const s=await this._getAreaFromTask(F);s?.area&&s?.perimeter&&(G=s.area)}async handlePolylineEvents(e,t){const{currentBestFeature:a,activeViewer:i,mode:r,view:s}=this.viewModel,n=!this.viewModel.accuracyParametersMissing;if("cancel"===e.state)return this.resetDistanceMeasurements(),this.viewModel.distanceMeasurementResult=0,this.viewModel.distanceAccuracyArray=[],void(this.viewModel.displayNewMeasurementButton=!0);if("complete"===e.state&&e.graphic){if(this.viewModel.activeViewer?.addGraphic(e.graphic),this.viewModel.triangularMeasurementActive&&a){const t={pixels:e.graphic.geometry.paths[0],activeFeature:a,activeViewer:i,mode:r,spatialReference:s?.spatialReference};await(this.measurementService?.updateMeasurementVectorsArray(t)),await this._overlayFirstMeasurement(e.graphic,e.tool)}return this.viewModel.measurementGraphic=e.graphic,void this.resetDistanceMeasurements()}switch(t?.type){case"cursor-update":this.cursorUpdatePolylineHandler(t);break;case"vertex-add":if(this.measurementArray.length&&n){const e=await this._getAccuracyFromTask();e&&this.viewModel.distanceAccuracyArray.push(e)}this.vertexUpdatePolylineHandler()}const o=await this._getDistanceFromTask();this.pixelMeasurement=o??this.pixelMeasurement}async handlePolygonEvents(e,t){const{currentBestFeature:a,activeViewer:i,mode:r,view:s,accuracyParametersMissing:n}=this.viewModel;if("cancel"===e.state)return this.resetAreaMeasurements(),this.viewModel.areaMeasurementResult=0,this.viewModel.areaMeasurementAccuracy=0,void(this.viewModel.displayNewMeasurementButton=!0);if("complete"===e.state&&e.graphic){this.viewModel.activeViewer?.addGraphic(e.graphic);if(!n&&!this.viewModel.triangularMeasurementActive){const e=await this._getAreaAccuracyFromTask(this.polygonVertices);this.viewModel.areaMeasurementAccuracy=e||this.viewModel.areaMeasurementAccuracy}if(this.viewModel.triangularMeasurementActive&&a){const t={pixels:e.graphic.geometry.rings[0],activeFeature:a,activeViewer:i,mode:r,spatialReference:s?.spatialReference};await(this.measurementService?.updateMeasurementVectorsArray(t)),await this._overlayFirstMeasurement(e.graphic,e.tool)}return this.viewModel.measurementGraphic=e.graphic,void this.resetAreaMeasurements()}switch(t?.type){case"vertex-add":await this.vertexAddPolygonHandler(t);break;case"cursor-update":await this.cursorUpdatePolygonHandler(t)}this.viewModel.areaMeasurementResult=G>0?G:this.pixelAreaMeasurement}async vertexAddPolygonHandler(e){const{mode:t,activeViewer:a}=this.viewModel,i=e.added,r=i[i.length-1];if(!Array.isArray(r)||"none"===t||!a?.imageSize)return;if("default"===t)this.polygonVertices.push(r);else{const e={x:r[0],y:r[1],z:r[2]},t=m(e,a?.imageSize[0],a?.imageSize[1]);this.polygonVertices.push([t.x,t.y])}if(this.polygonVertices.length<3||!this.viewModel.currentBestFeature||!this.viewModel.activeViewer?.imageSize)return;const s=this.polygonVertices[0];this.polygonVertices=this.polygonVertices.filter((e,t)=>0===t||t===this.polygonVertices.length-1||JSON.stringify(e)!==JSON.stringify(s));const n=await this._getAreaFromTask(this.polygonVertices);if(!n?.area||!n?.perimeter)return;const{area:o}=n;this.pixelAreaMeasurement=o}vertexUpdatePolylineHandler(){this.measurementArray=this.measurementArray.slice(-1);const e=z.reduce((e,t)=>e+t,0)+this.pixelMeasurement;this.viewModel.distanceMeasurementResult=e,this.pixelMeasurement>0&&z.push(this.pixelMeasurement)}resetDistanceMeasurements(){this.measurementArray=[],this.pixelMeasurement=0,z=[]}resetAreaMeasurements(){this.polygonVertices=[],this.pixelAreaMeasurement=0,G=0}async _editOverlayedGraphics(e){this.viewModel.sketchTriangularGraphicsLayer||this._initializeSketchTriangularGraphicsLayer(),this.viewModel.sketchTriangularGraphicsLayer?.destroyed&&this._handleDestroyedTriangularSketchLayer(),this.viewModel.sketchTriangularGraphicsLayer.add(e),this.viewModel.sketchTriangular||(this._initializeSketchTriangular(),await this._loadTriangulatedMeasurementAdapter()),this._updateOverlayedGeometry(e)}_handleDestroyedTriangularSketchLayer(){this.viewModel.sketchTriangularGraphicsLayer&&this.viewModel.activeTriangulatedViewer&&(this.viewModel.activeTriangulatedViewer.imageRenderer.map.layers.remove(this.viewModel.sketchTriangularGraphicsLayer),this.viewModel.sketchTriangularGraphicsLayer=new h,this.viewModel.activeTriangulatedViewer.imageRenderer.map.layers.add(this.viewModel.sketchTriangularGraphicsLayer),this.viewModel.sketchTriangular&&(this.viewModel.sketchTriangular.layer=this.viewModel.sketchTriangularGraphicsLayer,this.viewModel.sketchTriangular.view=this.viewModel.activeTriangulatedViewer.imageRenderer))}_initializeSketchTriangular(){if(!this.viewModel.activeTriangulatedViewer)return;const e="panoramic"===this.viewModel.mode;this.viewModel.sketchTriangular=new x({view:this.viewModel.activeTriangulatedViewer.imageRenderer,layer:this.viewModel.sketchTriangularGraphicsLayer,updateOnGraphicClick:!1,defaultUpdateOptions:{toggleToolOnClick:!1,enableZ:!e}}),e&&(this.viewModel.sketchTriangular.defaultUpdateOptions.reshapeOptions={edgeOperation:"offset",shapeOperation:"move-xy",vertexOperation:"move-xy"})}_initializeSketchTriangularGraphicsLayer(){this.viewModel.activeTriangulatedViewer&&(this.viewModel.sketchTriangularGraphicsLayer=new h,this.viewModel.activeTriangulatedViewer.imageRenderer.map.layers.add(this.viewModel.sketchTriangularGraphicsLayer))}async _overlayFirstMeasurement(e,t){switch(t){case"polyline":await this._overlayFirstDistanceMeasurement(e);break;case"polygon":await this._overlayFirstAreaGeometry(e)}}async _overlayFirstDistanceMeasurement(e){const{mode:a,activeTriangulatedViewer:i,currentBestFeature:r,activeViewer:s,footprintExtent:n,currentBestFeatureMeasurementImage:o}=this.viewModel,c=e.geometry?.clone(),h=e.symbol?.clone(),m=i?.imageSize,d=[...c.paths[0]],w=S(i?.media),y="default"===a;if(!("none"!==a&&"video"!==a&&m&&r&&s?.imageSize&&o))return;const v=y?d:T(d,m,w),M=y?A(v,!0):v,f=y?await p(r,s?.imageSize,n):await g(r,s?.imageSize,n),_=y?await p(o,this.viewModel.imageMeasurementViewer?.imageSize,n):await g(o,this.viewModel.activeTriangulatedViewer?.imageSize,n);if(M?.length&&f&&_){const e=y?await V(M,f,_):await k(M,f,_),a=e.map(e=>[e.x-.5,-.5-e.y]),i=e.slice(0,2).map(e=>R(e,m,w)),r=new l({paths:y?[a]:[i],spatialReference:u.WebMercator}),s=new t({geometry:r,symbol:h});await this._editOverlayedGraphics(s)}}async _overlayFirstAreaGeometry(e){const{mode:a,activeTriangulatedViewer:i,currentBestFeature:r,currentBestFeatureMeasurementImage:s,activeViewer:n,footprintExtent:l}=this.viewModel,c=e.geometry?.clone(),h=e.symbol?.clone(),m=i?.imageSize,d=S(i?.media),w=[...c.rings[0]],y="default"===a;if(!("none"!==a&&"video"!==a&&m&&r&&n?.imageSize&&s))return;const v=y?w:T(w,m,d),M=y?A(v,!0):v,f=y?await p(r,n?.imageSize,l):await g(r,n?.imageSize,l),_=y?await p(s,this.viewModel.imageMeasurementViewer?.imageSize,l):await g(s,this.viewModel.activeTriangulatedViewer?.imageSize,l);if(M?.length&&f&&_){const e=y?await V(M,f,_):await k(M,f,_),a=e.map(e=>[e.x-.5,-.5-e.y]),i=e.slice(0,y?2:e.length).map(e=>R(e,m,d)),r=new o({rings:y?[a]:[i],spatialReference:u.WebMercator}),s=new t({geometry:r,symbol:h});await this._editOverlayedGraphics(s)}}async _loadTriangulatedMeasurementAdapter(e){if(!this.viewModel.triangulatedMeasurementAdapter){const t=import("./TriangulatedMeasurementAdapter.js"),{default:a}=await t;if(r(e),this.viewModel.triangulatedMeasurementAdapter=new a({viewModel:this.viewModel,measurementService:this.measurementService}),!this.viewModel.triangulatedMeasurementAdapter.viewModel.isResolved())return}return this.viewModel.triangulatedMeasurementAdapter}async _getAreaFromTask(e){const{mode:t}=this.viewModel;return this._calculationTask?.abort(),this._calculationTask=a(async a=>{this._areaCalculation=null;const i=await this.calculateAreaMeasurement(e,t,a);r(a),this._areaCalculation=i}),await this._calculationTask.promise,this._areaCalculation}async _getDistanceFromTask(){const{mode:e}=this.viewModel;return this._calculationTask?.abort(),this._calculationTask=a(async t=>{this._distanceCalculation=0;const a=await this.calculateDistanceMeasurement(this.measurementArray,e,t);r(t),this._distanceCalculation=a}),await this._calculationTask.promise,this._distanceCalculation}async _getAccuracyFromTask(){const{mode:e,currentBestFeature:t,currentBestFeatureMeasurementImage:i,activeViewer:s,activeTriangulatedViewer:n,layer:o,footprintExtent:l}=this.viewModel,c=s?.imageSize;return"none"!==e&&c?(this._calculationTask?.abort(),this._calculationTask=a(async a=>{this._distanceCalculation=0;const u={measurementArray:this.measurementArray,measurementType:"distance",currentBestFeature:t,currentBestFeatureMeasurementImage:i,activeViewer:s,imageSize:c,layer:o,triangularMeasurementActive:!1,footprintExtent:l,signal:a},h={measurementArray:this.measurementArray,measurementType:"distance",secondaryViewer:!1,currentBestFeature:t,currentBestFeatureMeasurementImage:i,activeViewer:s,activeTriangulatedViewer:n,layer:o,footprintExtent:l,signal:a},m="default"===e?await(this.measurementService?.calculateAccuracy(u)):await(this.measurementService?.calculateAccuracyPanoramic(h));r(a),this._distanceCalculation=m}),await this._calculationTask.promise,this._distanceCalculation):null}async _getAreaAccuracyFromTask(e){const{mode:t,currentBestFeature:i,currentBestFeatureMeasurementImage:s,activeViewer:n,activeTriangulatedViewer:o,layer:l,footprintExtent:c}=this.viewModel,u=n?.imageSize;return"none"!==t&&u?(this._calculationTask?.abort(),this._calculationTask=a(async a=>{this._distanceCalculation=0;const h={measurementArray:e,measurementType:"area",currentBestFeature:i,currentBestFeatureMeasurementImage:s,activeViewer:n,imageSize:u,layer:l,triangularMeasurementActive:!1,footprintExtent:c,signal:a},m={measurementArray:e,measurementType:"area",secondaryViewer:!1,currentBestFeature:i,currentBestFeatureMeasurementImage:s,activeViewer:n,activeTriangulatedViewer:o,layer:l,footprintExtent:c,signal:a},d="default"===t?await(this.measurementService?.calculateAccuracy(h)):await(this.measurementService?.calculateAccuracyPanoramic(m));r(a),this._distanceCalculation=d}),await this._calculationTask.promise,this._distanceCalculation):null}_updateOverlayedGeometry(e){this.viewModel.sketchTriangular?.update([e],{tool:"reshape"})}};e([s()],B.prototype,"type",void 0),e([s()],B.prototype,"measurementArray",void 0),e([s()],B.prototype,"pixelMeasurement",void 0),e([s()],B.prototype,"pixelAreaMeasurement",void 0),e([s()],B.prototype,"polygonVertices",void 0),B=e([n("esri.widgets.OrientedImageryViewer.adapters.sketch.MeasurementAdapter")],B);const P=B,R=(e,t,a)=>{const{heading:i,pitch:r}=d(e,t[0],t[1]);return w(i,r,a)};export{P as default};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.0/LICENSE.txt */
2
- import e from"../../../../Graphic.js";import{isSome as t}from"../../../../core/arrayUtils.js";import i from"../../../../core/Logger.js";import{waitTick as o,throwIfAborted as r,isAbortError as a}from"../../../../core/promiseUtils.js";import s from"../../../../geometry/Polygon.js";import{projectAsync as n}from"../../../../geometry/projectionUtils.js";import{e as l}from"../../../../chunks/centroidOperator.js";import{adjustHorizonAngles as p,convertOrientationToPixelLocation as c}from"../../../../layers/orientedImagery/transformations/utils.js";import{fixedImageSize as u}from"../../constants.js";import{activePolygonSymbol as d,polygonSymbol as m}from"../../symbols.js";import{extractHorizonAnglesFromMedia as g}from"../../utils.js";class v{constructor(v){this.viewModel=v,this.createFootprints=async t=>{await o(t);const{coveragePolygons:i,currentBestFeature:r,isAdditionalCoverageVisible:a}=this.viewModel;for(const o of i)o?.imageID===r.attributes.objectId?this.viewModel.bestFeatureFootprint=new e({attributes:{imageID:o?.imageID},geometry:o,symbol:d,visible:!1}):this.viewModel.additionalFootprints.push(new e({attributes:{imageID:o?.imageID},geometry:o,symbol:m.clone(),visible:a}))},this.updateFootprint=async(o,l,p)=>{const{activeViewer:c,mode:m,currentBestFeature:g,currentCoverageVisible:v,footprintExtent:f}=this.viewModel,w=l??g;if(g&&("video"===m?u:c?.imageSize)&&f&&w)try{const i=await this.viewModel.getMapPoint(o);r(p);const a=i.filter(t);if(!a.length)return;const l=[a.map(({x:e,y:t})=>[e,t,1])];l[0].push(l[0][0]);const c=new s({rings:l,spatialReference:a[0].spatialReference}),u=this.viewModel.view?.spatialReference.equals(c.spatialReference)?c:await n(c,this.viewModel.view.spatialReference,p);this.viewModel.updateCurrentCoveragePolygon(new e({geometry:u,attributes:{imageID:w.attributes.objectId},symbol:d,visible:v}))}catch(h){a(h)||i.getLogger(this.viewModel).error("update-footprint",h)}else this.viewModel.updateCurrentCoveragePolygon(null)},this.updateVideoFootprint=async o=>{const{points:p,feature:c,scale:m,options:g}=o,{activeViewer:v,mode:f,currentBestFeature:w,currentCoverageVisible:h,footprintExtent:y}=this.viewModel,M="video"===f?u:v?.imageSize,b=c??w;if(w&&M&&y&&b&&"none"!==f)try{const i={feature:b,mode:f,imageSize:M,footprintExtent:y},o=await this.viewModel.getMapPointForFeature(p,i,g);r(g);const a=o.filter(t);if(!a.length)return;const c=[a.map(({x:e,y:t})=>[e,t,1])];c[0].push(c[0][0]);let u=new s({rings:c,spatialReference:a[0].spatialReference});if(m){const e=u.spatialReference,t=l(u),i=u.rings.map(e=>e.map(([e,i])=>[t.x+(e-t.x)*m,t.y+(i-t.y)*m]));u=new s({rings:i,spatialReference:e})}const v=this.viewModel.view?.spatialReference.equals(u.spatialReference)?u:await n(u,this.viewModel.view.spatialReference,g);this.viewModel.updateCurrentCoveragePolygon(new e({geometry:v,attributes:{imageID:b.attributes.objectId},symbol:d,visible:h}))}catch(C){a(C)||i.getLogger(this.viewModel).error("update-footprint",C)}else this.viewModel.updateCurrentCoveragePolygon(null)},this.updateFootprintPanorama=async(t,i)=>{const{horizontalFieldOfView:o,pitch:a,verticalFieldOfView:l,yaw:m,feature:v}=t,{activeViewer:f,currentBestFeature:w,currentCoverageVisible:h,footprintExtent:y,mode:M}=this.viewModel,b="video"===M||"panoramic-video"===M?u:f?.imageSize,C=v??w;if(!C||!b||!y||"none"===M)return void this.viewModel.updateCurrentCoveragePolygon(null);const{cameraPitch:F,objectId:R}=C.attributes;if(a+F-l/2>180)return void this.viewModel.updateCurrentCoveragePolygon(null);const j=[],P=l/2,I=o/2,x=a-P,V=a+P;if(x>90)return void this.viewModel.updateCurrentCoveragePolygon(null);const D=x<0,z=[-I,P],E=[I,P],S=[I,-P],B=[-I,-P];if(x<90&&V>90){j.push(D?S:B);const e=Math.floor(o/5),t=o/e;for(let i=0;i<=e;i++)j.push([i*t-I,90-a]);j.push(D?B:S)}V<90&&(j.push(z,E),D?j.push(B,S):j.push(S,B));const q=g(f?.media),L=j.map(([e,t])=>{const i=a+t,o=m+e,r=q?p(o,i,q):[o,i];return{...c(r[0],r[1],b[0],b[1]),heading:o,pitch:i}}),O={feature:C,mode:M,imageSize:b,footprintExtent:y},U=v?await this.viewModel.getMapPointForFeature(L,O):await this.viewModel.getMapPoint(L);r(i);const k=[U.map(({x:e,y:t})=>[e,t,1])];k[0].push(k[0][0]);const A=new s({rings:k,spatialReference:U[0].spatialReference}),G=this.viewModel.view?.spatialReference.equals(A.spatialReference)?A:await n(A,this.viewModel.view.spatialReference,i);this.viewModel.updateCurrentCoveragePolygon(new e({geometry:G,attributes:{imageID:R},symbol:d.clone(),visible:h}))}}}export{v as default};
2
+ import e from"../../../../Graphic.js";import{isSome as t}from"../../../../core/arrayUtils.js";import i from"../../../../core/Logger.js";import{waitTick as o,throwIfAborted as r,isAbortError as a}from"../../../../core/promiseUtils.js";import s from"../../../../geometry/Polygon.js";import{projectAsync as n}from"../../../../geometry/projectionUtils.js";import{e as l}from"../../../../chunks/centroidOperator.js";import{adjustHorizonAngles as p,convertOrientationToPixelLocation as c}from"../../../../layers/orientedImagery/transformations/utils.js";import{fixedImageSize as u}from"../../constants.js";import{activePolygonSymbol as d,polygonSymbol as m}from"../../symbols.js";import{extractHorizonAnglesFromMedia as g}from"../../utils.js";class v{constructor(v){this.viewModel=v,this.createFootprints=async t=>{await o(t);const{coveragePolygons:i,currentBestFeature:r,isAdditionalCoverageVisible:a}=this.viewModel;for(const o of i)o?.imageID===r.attributes.objectId?this.viewModel.bestFeatureFootprint=new e({attributes:{imageID:o?.imageID},geometry:o,symbol:d,visible:!1}):this.viewModel.additionalFootprints.push(new e({attributes:{imageID:o?.imageID},geometry:o,symbol:m.clone(),visible:a}))},this.updateFootprint=async(o,l,p)=>{const{activeViewer:c,mode:m,currentBestFeature:g,currentCoverageVisible:v,footprintExtent:f}=this.viewModel,w=l??g;if(g&&("video"===m?u:c?.imageSize)&&f&&w)try{const i=await this.viewModel.getMapPoint(o);r(p);const a=i.filter(t);if(!a.length)return;const l=[a.map(({x:e,y:t})=>[e,t,1])];l[0].push(l[0][0]);const c=new s({rings:l,spatialReference:a[0].spatialReference}),u=this.viewModel.view?.spatialReference.equals(c.spatialReference)?c:await n(c,this.viewModel.view.spatialReference,p);this.viewModel.updateCurrentCoveragePolygon(new e({geometry:u,attributes:{imageID:w.attributes.objectId},symbol:d,visible:v}))}catch(h){a(h)||i.getLogger(this.viewModel).error("update-footprint",h)}else this.viewModel.updateCurrentCoveragePolygon(null)},this.updateVideoFootprint=async o=>{const{points:p,feature:c,scale:m,options:g}=o,{activeViewer:v,mode:f,currentBestFeature:w,currentCoverageVisible:h,footprintExtent:y}=this.viewModel,M="video"===f?u:v?.imageSize,b=c??w;if(w&&M&&y&&b&&"none"!==f)try{const i={feature:b,mode:f,imageSize:M,footprintExtent:y},o=await this.viewModel.getMapPointForFeature(p,i,g);r(g);const a=o.filter(t);if(!a.length)return;const c=[a.map(({x:e,y:t})=>[e,t,1])];c[0].push(c[0][0]);let u=new s({rings:c,spatialReference:a[0].spatialReference});if(m){const e=u.spatialReference,t=l(u),i=u.rings.map(e=>e.map(([e,i])=>[t.x+(e-t.x)*m,t.y+(i-t.y)*m]));u=new s({rings:i,spatialReference:e})}const v=this.viewModel.view?.spatialReference.equals(u.spatialReference)?u:await n(u,this.viewModel.view.spatialReference,g);this.viewModel.updateCurrentCoveragePolygon(new e({geometry:v,attributes:{imageID:b.attributes.objectId},symbol:d,visible:h}))}catch(C){a(C)||i.getLogger(this.viewModel).error("update-footprint",C)}else this.viewModel.updateCurrentCoveragePolygon(null)},this.updateFootprintPanorama=async(t,i)=>{const{horizontalFieldOfView:o,pitch:a,verticalFieldOfView:l,yaw:m,feature:v,horizonAngles:f}=t,{activeViewer:w,currentBestFeature:h,currentCoverageVisible:y,footprintExtent:M,mode:b}=this.viewModel,C="video"===b||"panoramic-video"===b?u:w?.imageSize,F=v??h;if(!F||!C||!M||"none"===b)return void this.viewModel.updateCurrentCoveragePolygon(null);const{cameraPitch:R,objectId:j}=F.attributes;if(a+R-l/2>180)return void this.viewModel.updateCurrentCoveragePolygon(null);const P=[],I=l/2,x=o/2,V=a-I,D=a+I;if(V>90)return void this.viewModel.updateCurrentCoveragePolygon(null);const z=V<0,E=[-x,I],S=[x,I],B=[x,-I],q=[-x,-I];if(V<90&&D>90){P.push(z?B:q);const e=Math.floor(o/5),t=o/e;for(let i=0;i<=e;i++)P.push([i*t-x,90-a]);P.push(z?q:B)}D<90&&(P.push(E,S),z?P.push(q,B):P.push(B,q));const L=f??g(w?.media),O=P.map(([e,t])=>{const i=a+t,o=m+e,r=L?p(o,i,L):[o,i];return{...c(r[0],r[1],C[0],C[1]),heading:o,pitch:i}}),U={feature:F,mode:b,imageSize:C,footprintExtent:M},A=v?await this.viewModel.getMapPointForFeature(O,U):await this.viewModel.getMapPoint(O);r(i);const k=[A.map(({x:e,y:t})=>[e,t,1])];k[0].push(k[0][0]);const G=new s({rings:k,spatialReference:A[0].spatialReference}),H=this.viewModel.view?.spatialReference.equals(G.spatialReference)?G:await n(G,this.viewModel.view.spatialReference,i);this.viewModel.updateCurrentCoveragePolygon(new e({geometry:H,attributes:{imageID:j},symbol:d.clone(),visible:y}))}}}export{v as default};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.0/LICENSE.txt */
2
- import{__decorate as e}from"tslib";import i from"../Camera.js";import{property as t,subclass as o}from"../core/accessorSupport/decorators.js";import r from"./Widget.js";import a from"./PanoramicViewer/PanoramicVideoViewerViewModel.js";import{loadCalciteComponents as l}from"./support/componentsUtils.js";import{globalCss as n}from"./support/globalCss.js";import{tsx as s,messageBundle as c,vmEvent as d}from"./support/widget.js";const p="esri-panoramic-viewer";let u=class extends r{constructor(e){super(e),this.messagesCommon=null,this.viewModel=new a,this._afterContainerCreate=e=>{this.imageRenderer.container=e},this.addGraphic=(e,i)=>{this.viewModel.addGraphic(e,i)},this.addManyGraphics=e=>{this.viewModel.addManyGraphics(e)},this.clearGraphics=()=>{this.viewModel.clearGraphics()},this.clearImage=()=>{this.viewModel.clearImage()},this.loadVideo=e=>this.viewModel.loadVideo(e),this.removeGraphic=e=>{this.viewModel.removeGraphic(e)},this.removeManyGraphics=e=>{this.viewModel.removeManyGraphics(e)}}loadDependencies(){return l({panel:()=>import("@esri/calcite-components/dist/components/calcite-panel"),"action-bar":()=>import("@esri/calcite-components/dist/components/calcite-action-bar"),"action-group":()=>import("@esri/calcite-components/dist/components/calcite-action-group"),action:()=>import("@esri/calcite-components/dist/components/calcite-action"),slider:()=>import("@esri/calcite-components/dist/components/calcite-slider")})}get activeAudioIcon(){const{videoMuted:e}=this.viewModel;return e?"sound-off":"sound"}get activeVideoIcon(){const{videoPaused:e,videoLoaded:i}=this.viewModel;return i&&!1===e?"pause":"play"}get autoLoad(){return this.viewModel.autoLoad}set autoLoad(e){this.viewModel.autoLoad=e}get camera(){return this.viewModel.camera}set camera(e){e&&(this.viewModel.camera=e)}get clickAction(){return this.viewModel.clickAction}set clickAction(e){this.viewModel.clickAction=e}get fov(){return this.camera?.fov}set fov(e){this.viewModel.fov=e}get hfov(){return this.viewModel.hfov}get icon(){return"i360-view"}set icon(e){this._overrideIfSome("icon",e)}get imageRenderer(){return this.viewModel.imageRenderer}get imageSize(){return this.viewModel.imageSize}get oiViewModel(){return this.viewModel.oiViewModel}set oiViewModel(e){this.viewModel.oiViewModel=e}get video(){return this.viewModel.video}get videoSource(){return this.viewModel.videoSource}set videoSource(e){this.viewModel.videoSource=e}get pitch(){return this.viewModel.pitch}set pitch(e){this.viewModel.pitch=e}get state(){return this.viewModel.state}get ui(){return this.imageRenderer.ui}get vfov(){return this.viewModel.vfov}get yaw(){return this.viewModel.yaw}set yaw(e){this.viewModel.yaw=e}_handleVideoSeek(e){const i=this.viewModel?.video;i&&(i.currentTime=e.target.value,i.play())}render(){const{control:e,reset:i}=this.messagesCommon,{mute:t,unmute:o}=this.messages;return s("calcite-panel",null,s("calcite-panel",{loading:this.viewModel.updating},s("calcite-panel",{afterCreate:this._afterContainerCreate,bind:this,class:this.classes(n.widget,p)}),s("calcite-slider",{bind:this,labelHandles:!0,labelTicks:!0,max:this.viewModel?.videoDuration,minLabel:"0",value:this.viewModel.currentTime??0,onCalciteSliderChange:this._handleVideoSeek}),s("calcite-action-bar",{expandDisabled:!0,layout:"horizontal"},s("calcite-action-group",null,s("calcite-action",{bind:this,icon:this.activeVideoIcon,onclick:()=>this.viewModel.playPanoramicVideoHandler(),text:"Play",title:this.viewModel.videoPaused?e.play:e.pause})),s("calcite-action-group",null,s("calcite-action",{bind:this,icon:"refresh",onclick:()=>this.viewModel.rewindPanoramicVideoHandler(),text:"Rewind",title:i})),s("calcite-action-group",null,s("calcite-action",{bind:this,icon:this.activeAudioIcon,onclick:()=>this.viewModel.togglePanoramicAudio(),text:"Audio",title:this.viewModel.videoMuted?t:o})))))}static{this.vnodeSelector="calcite-panel"}};e([t()],u.prototype,"activeAudioIcon",null),e([t()],u.prototype,"activeVideoIcon",null),e([t({type:Boolean})],u.prototype,"autoLoad",null),e([t({type:i})],u.prototype,"camera",null),e([t()],u.prototype,"clickAction",null),e([t({type:Number})],u.prototype,"fov",null),e([t({readOnly:!0,type:Number})],u.prototype,"hfov",null),e([t()],u.prototype,"icon",null),e([t({readOnly:!0})],u.prototype,"imageRenderer",null),e([t({readOnly:!0})],u.prototype,"imageSize",null),e([t()],u.prototype,"oiViewModel",null),e([t(),c("esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer")],u.prototype,"messages",void 0),e([t(),c("esri/t9n/common")],u.prototype,"messagesCommon",void 0),e([t()],u.prototype,"video",null),e([t()],u.prototype,"videoSource",null),e([t({type:Number})],u.prototype,"pitch",null),e([t({readOnly:!0})],u.prototype,"state",null),e([t()],u.prototype,"ui",null),e([t({readOnly:!0,type:Number})],u.prototype,"vfov",null),e([d(["click","hittest-response","pixel-location"]),t({type:a})],u.prototype,"viewModel",void 0),e([t({type:Number})],u.prototype,"yaw",null),u=e([o("esri.widgets.PanoramicVideoViewer")],u);const h=u;export{h as default};
2
+ import{__decorate as e}from"tslib";import i from"../Camera.js";import{property as t,subclass as o}from"../core/accessorSupport/decorators.js";import r from"./Widget.js";import a from"./PanoramicViewer/PanoramicVideoViewerViewModel.js";import{loadCalciteComponents as l}from"./support/componentsUtils.js";import{globalCss as n}from"./support/globalCss.js";import{tsx as s,messageBundle as c,vmEvent as d}from"./support/widget.js";const p="esri-panoramic-viewer";let u=class extends r{constructor(e){super(e),this.messagesCommon=null,this.viewModel=new a,this._afterContainerCreate=e=>{this.imageRenderer.container=e},this.addGraphic=(e,i)=>{this.viewModel.addGraphic(e,i)},this.addManyGraphics=e=>{this.viewModel.addManyGraphics(e)},this.clearGraphics=()=>{this.viewModel.clearGraphics()},this.clearImage=()=>{this.viewModel.clearImage()},this.loadVideo=e=>this.viewModel.loadVideo(e),this.removeGraphic=e=>{this.viewModel.removeGraphic(e)},this.removeManyGraphics=e=>{this.viewModel.removeManyGraphics(e)}}loadDependencies(){return l({panel:()=>import("@esri/calcite-components/dist/components/calcite-panel"),"action-bar":()=>import("@esri/calcite-components/dist/components/calcite-action-bar"),"action-group":()=>import("@esri/calcite-components/dist/components/calcite-action-group"),action:()=>import("@esri/calcite-components/dist/components/calcite-action"),slider:()=>import("@esri/calcite-components/dist/components/calcite-slider")})}get activeAudioIcon(){const{videoMuted:e}=this.viewModel;return e?"sound-off":"sound"}get activeVideoIcon(){const{videoPaused:e,videoLoaded:i}=this.viewModel;return i&&!1===e?"pause":"play"}get autoLoad(){return this.viewModel.autoLoad}set autoLoad(e){this.viewModel.autoLoad=e}get camera(){return this.viewModel.camera}set camera(e){e&&(this.viewModel.camera=e)}get clickAction(){return this.viewModel.clickAction}set clickAction(e){this.viewModel.clickAction=e}get fov(){return this.camera?.fov}set fov(e){this.viewModel.fov=e}get hfov(){return this.viewModel.hfov}get horizonAngles(){return this.viewModel.horizonAngles}get icon(){return"i360-view"}set icon(e){this._overrideIfSome("icon",e)}get imageRenderer(){return this.viewModel.imageRenderer}get imageSize(){return this.viewModel.imageSize}get oiViewModel(){return this.viewModel.oiViewModel}set oiViewModel(e){this.viewModel.oiViewModel=e}get video(){return this.viewModel.video}get videoSource(){return this.viewModel.videoSource}set videoSource(e){this.viewModel.videoSource=e}get pitch(){return this.viewModel.pitch}set pitch(e){this.viewModel.pitch=e}get state(){return this.viewModel.state}get ui(){return this.imageRenderer.ui}get vfov(){return this.viewModel.vfov}get yaw(){return this.viewModel.yaw}set yaw(e){this.viewModel.yaw=e}_handleVideoSeek(e){const i=this.viewModel?.video;i&&(i.currentTime=e.target.value,i.play())}render(){const{control:e,reset:i}=this.messagesCommon,{mute:t,unmute:o}=this.messages;return s("calcite-panel",null,s("calcite-panel",{loading:this.viewModel.updating},s("calcite-panel",{afterCreate:this._afterContainerCreate,bind:this,class:this.classes(n.widget,p)}),s("calcite-slider",{bind:this,labelHandles:!0,labelTicks:!0,max:this.viewModel?.videoDuration,minLabel:"0",value:this.viewModel.currentTime??0,onCalciteSliderChange:this._handleVideoSeek}),s("calcite-action-bar",{expandDisabled:!0,layout:"horizontal"},s("calcite-action-group",null,s("calcite-action",{bind:this,icon:this.activeVideoIcon,onclick:()=>this.viewModel.playPanoramicVideoHandler(),text:"Play",title:this.viewModel.videoPaused?e.play:e.pause})),s("calcite-action-group",null,s("calcite-action",{bind:this,icon:"refresh",onclick:()=>this.viewModel.rewindPanoramicVideoHandler(),text:"Rewind",title:i})),s("calcite-action-group",null,s("calcite-action",{bind:this,icon:this.activeAudioIcon,onclick:()=>this.viewModel.togglePanoramicAudio(),text:"Audio",title:this.viewModel.videoMuted?t:o})))))}static{this.vnodeSelector="calcite-panel"}};e([t()],u.prototype,"activeAudioIcon",null),e([t()],u.prototype,"activeVideoIcon",null),e([t({type:Boolean})],u.prototype,"autoLoad",null),e([t({type:i})],u.prototype,"camera",null),e([t()],u.prototype,"clickAction",null),e([t({type:Number})],u.prototype,"fov",null),e([t({readOnly:!0,type:Number})],u.prototype,"hfov",null),e([t()],u.prototype,"horizonAngles",null),e([t()],u.prototype,"icon",null),e([t({readOnly:!0})],u.prototype,"imageRenderer",null),e([t({readOnly:!0})],u.prototype,"imageSize",null),e([t()],u.prototype,"oiViewModel",null),e([t(),c("esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer")],u.prototype,"messages",void 0),e([t(),c("esri/t9n/common")],u.prototype,"messagesCommon",void 0),e([t()],u.prototype,"video",null),e([t()],u.prototype,"videoSource",null),e([t({type:Number})],u.prototype,"pitch",null),e([t({readOnly:!0})],u.prototype,"state",null),e([t()],u.prototype,"ui",null),e([t({readOnly:!0,type:Number})],u.prototype,"vfov",null),e([d(["click","hittest-response","pixel-location"]),t({type:a})],u.prototype,"viewModel",void 0),e([t({type:Number})],u.prototype,"yaw",null),u=e([o("esri.widgets.PanoramicVideoViewer")],u);const h=u;export{h as default};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.0/LICENSE.txt */
2
- import{__decorate as e}from"tslib";import t from"../../Camera.js";import i from"../../Ground.js";import o from"../../Map.js";import a from"../../core/Collection.js";import r from"../../core/Error.js";import{EventedAccessor as s}from"../../core/Evented.js";import{addEventListener as n}from"../../core/events.js";import{JSONMap as d}from"../../core/jsonMap.js";import h from"../../core/Logger.js";import{rad2deg as l,deg2rad as m}from"../../core/mathUtils.js";import{destroyMaybe as c}from"../../core/maybe.js";import{waitTick as p}from"../../core/promiseUtils.js";import{watch as g,syncAndInitial as u,when as v,whenOnce as _}from"../../core/reactiveUtils.js";import{property as y,subclass as f}from"../../core/accessorSupport/decorators.js";import{UpdatingHandles as w}from"../../core/support/UpdatingHandles.js";import V from"../../geometry/SpatialReference.js";import M from"../../layers/GraphicsLayer.js";import{convertSphereVertexToPixelLocation as R}from"../../layers/orientedImagery/transformations/utils.js";import H from"../../views/SceneView.js";import{fixedImageSize as P}from"../OrientedImageryViewer/constants.js";import{logAndThrow as z,getMissingPropertyErrorName as b,getMissingPropertyErrorMessage as F}from"../OrientedImageryViewer/utils.js";import{defaultImageSphereCenter as C,maxPanoramicViewerHFOV as S,minPanoramicViewerHFOV as j,humanBinocularHFOV as O}from"./constants.js";import I from"./PanoramicZoomConditions.js";import x from"./PanoramicZoomViewModel.js";import{findDiagonalFOV as k,meshToGraphic as L,createImageSphere as A}from"./utils.js";import{enumeration as G}from"../../core/accessorSupport/decorators/enumeration.js";const T={default:"default",navigation:"navigation",fovConstraint:"fov-constraint",clickAction:"image-click-action",videoHandles:"video-handles"};let D=class extends s{constructor(e){super(e),this._startPosition=null,this._targetPosition=null,this._graphics=new M({elevationInfo:{mode:"relative-to-ground"}}),this._imageGraphic=null,this._loadController=null,this._map=new o({ground:new i({opacity:0,navigationConstraint:null}),layers:new a([this._graphics])}),this._zoomViewModel=null,this.autoLoad=!1,this.clickAction="none",this.closestFeature=null,this.currentTime=0,this.imageSize=null,this.oiViewModel=null,this.videoSource=null,this.videoDuration=void 0,this.videoLoaded=!1,this.videoPaused=null,this.videoMuted=null,this.pitch=90,this.state="ready",this.updatingHandles=new w,this.video=null,this.yaw=0,this._addNavigationHandles=()=>{this.imageRenderer.basemapTerrain.suspended=!0,this.imageRenderer.constraints.tilt.max=180,this.removeHandles(T.navigation),this.addHandles([this.imageRenderer.on("mouse-wheel",this._handleWheel),this.imageRenderer.on("double-click",this._handleDoubleClick),this.imageRenderer.on("drag",this._handleDrag),this.imageRenderer.on("key-down",e=>{const t=["+","-","Shift","_","=","ArrowUp","ArrowDown","ArrowRight","ArrowLeft"],i=e.key;t.includes(i)&&e.stopPropagation()})],T.navigation)},this._addHFOVHandles=()=>{this.removeHandles(T.fovConstraint),this.addHandles(g(()=>[this.maxHFOV,this.minHFOV],()=>{this._zoomViewModel&&(this._zoomViewModel.panoramicZoomConditions=new I({view:this.imageRenderer,maxFOV:this.maxHFOV,minFOV:this.minHFOV}))},u),T.fovConstraint)},this._addZoomHandles=()=>{this._zoomViewModel=new x({view:this.imageRenderer,panoramicZoomConditions:new I({maxFOV:this.maxHFOV,minFOV:this.minHFOV})});const e=this.imageRenderer.ui.find("zoom");e&&(e.viewModel=this._zoomViewModel),this._addHFOVHandles()},this._cancelLoadWithController=()=>{this._loadController?.abort(),this._loadController=null},this._handleDoubleClick=e=>{e.stopPropagation(),e.native.ctrlKey?this._zoomOut():this._zoomIn()},this._handleDrag=e=>{e.stopPropagation();const{action:t,x:i,y:o}=e;switch(t){case"start":this._startPosition=this._targetPosition={x:i,y:o};break;case"update":this._targetPosition={x:i,y:o},this._updateCameraHeadingAndTilt()}},this._handleImageClick=e=>{if("image-loaded"===this.state&&this.imageRenderer.ready)switch(this.clickAction){case"emit":e.stopPropagation(),this.emit("click",e);break;case"hittest":e.stopPropagation(),e.defer(async()=>{const t=await this.imageRenderer.hitTest(e.screenPoint,{include:this._graphics});t.results=t.results.filter(e=>"graphic"===e.type&&e.graphic!==this._imageGraphic),this.emit("hittest-response",t)});break;case"pixel-location":{if(e.stopPropagation(),!this.imageSize||!e.mapPoint)return void this.emit("pixel-location",null);const t=R(e.mapPoint,this.imageSize[0],this.imageSize[1]);this.emit("pixel-location",{...t,spatialReference:V.WebMercator});break}}},this._handleWheel=e=>{const t=e.deltaX??e.native.deltaX;e.stopPropagation(),t>0||e.deltaY>0?this._zoomOut():this._zoomIn()},this._loadWithController=()=>{this._cancelLoadWithController(),this._loadController=new AbortController,this.loadVideo(this._loadController)},this._zoomIn=()=>this._zoomViewModel?.zoomIn(),this._zoomOut=()=>this._zoomViewModel?.zoomOut(),this.addGraphic=(e,t)=>"image-loaded"===this.state&&!this._graphics.graphics.includes(e)&&(this._graphics.graphics.add(e,t),!0),this.addManyGraphics=e=>{if("image-loaded"!==this.state)return!1;const t=e.filter(e=>!this._graphics.graphics.includes(e));return this._graphics.graphics.addMany(t),!0},this.clearGraphics=()=>{this._graphics.graphics.removeAll()},this.clearImage=()=>{this.imageSize=null,this._removeImageSphere()},this.enableAudio=()=>{const{video:e}=this;e&&(e.muted=!1,this.videoMuted=!1)},this.removeGraphic=e=>!("image-loaded"!==this.state||!this._graphics.graphics.includes(e))&&(this._graphics.remove(e),!0),this.removeManyGraphics=e=>{if("image-loaded"!==this.state)return!1;const t=e.filter(e=>this._graphics.graphics.includes(e));return this._graphics.removeMany(t),!0},this.togglePanoramicAudio=()=>{if(this.video){const e=this.video.muted;this.video.muted=!e,this.videoMuted=!e}},this._imageRenderer=new H({map:this._map,viewingMode:"local",camera:{position:C},environment:{atmosphereEnabled:!1,starsEnabled:!1,lighting:{type:"virtual"}},popupEnabled:!1,spatialReference:V.WebMercator,attributionVisible:!1,ui:{components:["zoom"]}})}destroy(){this._imageRenderer.destroy()}initialize(){this.state="initialized",this.addHandles([g(()=>this.videoSource,()=>{this.videoSource&&this.autoLoad&&this._loadWithController()},u),g(()=>this.fov,()=>{this._reloadCamera()},u),g(()=>this.yaw,e=>{this.camera&&(this.camera.heading=e,this._reloadCamera())},u),g(()=>this.pitch,e=>{this.camera&&(this.camera.tilt=e,this._reloadCamera())},u),v(()=>this.imageRenderer.ready,()=>{this._addNavigationHandles(),this._addZoomHandles()},u),g(()=>this.clickAction,e=>{this.removeHandles(T.clickAction),"none"!==e&&this.addHandles(this.imageRenderer.on("click",this._handleImageClick))},u),g(()=>this.video,e=>{if(e instanceof HTMLVideoElement){this._startVideo();const t=async()=>{this.currentTime=Number(e.currentTime.toFixed(2)),e.currentTime&&await this._updateVidFootprint(e.currentTime)};this.removeHandles(T.videoHandles);const i=n(e,"timeupdate",t),o=n(e,"play",()=>this._updateVideoIcon(e.paused)),a=n(e,"pause",()=>this._pauseVideoHandler(e));this.addHandles([i,o,a],T.videoHandles)}},u)],T.default)}get camera(){return this.imageRenderer.destroying||this.imageRenderer.destroyed?null:this.imageRenderer.camera}set camera(e){!e||this.imageRenderer.destroying||this.imageRenderer.destroyed||(this.imageRenderer.camera=e.clone())}get fov(){return this.camera?.fov}set fov(e){Number.isFinite(e)&&this._zoomViewModel?.zoomTo(e)}get hfov(){if(!this.camera||!this.imageRenderer?.ready)return null;const{fov:e}=this.camera,{size:[t,i]}=this.imageRenderer,o=t/i,a=Math.atan(o);return 2*l(Math.atan(Math.tan(m(e/2))*Math.sin(a)))}get imageRenderer(){return this._imageRenderer}get maxHFOV(){const{size:[e,t]}=this.imageRenderer;return this.imageRenderer.ready?k(S,e/t):S}get minHFOV(){const{size:[e,t]}=this.imageRenderer;return this.imageRenderer.ready?k(j,e/t):j}get updating(){return this.updatingHandles.updating}get vfov(){if(!this.camera||!this.imageRenderer?.ready)return null;const{fov:e}=this.camera,{size:[t,i]}=this.imageRenderer,o=t/i,a=Math.atan(o);return 2*l(Math.atan(Math.tan(m(e/2))*Math.cos(a)))}async _loadVideoInternal(e,t){return this.state="image-loading",this.video=document.createElement("video"),this.video.src=e,this.video.addEventListener("loadedmetadata",()=>{this._setVideoDuration(),this.videoLoaded=!0}),this._updateImageSphere(this.video,t)}_pauseVideoHandler(e){this._updateVideoIcon(e.paused)}_setVideoDuration(){const{video:e}=this;e?.duration&&(this.videoDuration=e.duration)}_startVideo(){try{this.enableAudio();const e=this.oiViewModel.currentBestFeature;e&&this.playPanoramicVideoFromSelectedLocation(e)}catch(e){h.getLogger(this).error("oriented-imagery-viewer:video-load",e)}}_reloadCamera(){this.camera=this.camera?.clone()}_removeImageSphere(){this._imageGraphic&&(this._graphics.remove(this._imageGraphic),this._imageGraphic=c(this._imageGraphic)),this.state="ready",this.imageSize=null}_updateCameraHeadingAndTilt(){if(!this._startPosition||!this._targetPosition||!this.camera)return;const e=this.camera.heading+(this._startPosition.x-this._targetPosition.x)/this.imageRenderer.width*this.camera.fov;this.yaw=(e+360)%360;const t=this.camera.tilt-(this._startPosition.y-this._targetPosition.y)/this.imageRenderer.height*this.imageRenderer.camera.tilt;this.pitch=Math.min(179.5,Math.max(.5,t)),this._startPosition=this._targetPosition}async _updateImageSphere(e,t){return await p(t),this._imageGraphic=L(A({data:e})),this._graphics.add(this._imageGraphic),this.state="image-loaded",_(()=>this.imageRenderer.ready,t).then(()=>{const{size:[e,t]}=this.imageRenderer;this.fov=k(O,e/t)}),this.imageSize=P,this._imageGraphic.geometry}async _updateVidFootprint(e){const t=this.oiViewModel?.featureCache.find(t=>t.attributes.offsetFromStart===Math.floor(e)),{yaw:i,pitch:o,vfov:a,hfov:r}=this,s=!(t?.attributes.offsetFromStart&&a&&r&&i&&o),n=t?.attributes.objectId===this.closestFeature?.attributes.objectId;s||n||(this.closestFeature=t,await this.oiViewModel.updateFootprintPanorama({yaw:i,pitch:o,verticalFieldOfView:a,horizontalFieldOfView:r,feature:t}))}_updateVideoIcon(e){this.videoPaused=!!e}async loadVideo(e){return this._removeImageSphere(),this.videoSource?this._loadVideoInternal(this.videoSource,e):z(this.declaredClass,new r(b("panoramic-viewer"),F("PanoramicViewerViewModel","videoSource")))}playPanoramicVideoHandler(){const{video:e}=this;e&&(e.paused?e.play().catch(e=>{h.getLogger(this).error("error playing video",e)}):e.pause())}playPanoramicVideoFromSelectedLocation(e){const t=e.attributes.offsetFromStart;if(t){const e=this.video;e&&(e.currentTime=t,e.play().catch(e=>{h.getLogger(this).error("error playing video",e)}))}}rewindPanoramicVideoHandler(){const{video:e}=this;e&&(e.currentTime=0,e.play().catch(e=>{h.getLogger(this).error("error playing video",e)}))}};e([y()],D.prototype,"_graphics",void 0),e([y()],D.prototype,"_imageGraphic",void 0),e([y()],D.prototype,"_imageRenderer",void 0),e([y()],D.prototype,"_loadController",void 0),e([y()],D.prototype,"_map",void 0),e([y()],D.prototype,"_zoomViewModel",void 0),e([y({type:Boolean})],D.prototype,"autoLoad",void 0),e([y({type:t})],D.prototype,"camera",null),e([G(new d({emit:"emit",hittest:"hittest",none:"none","pixel-location":"pixel-location"}))],D.prototype,"clickAction",void 0),e([y()],D.prototype,"closestFeature",void 0),e([y()],D.prototype,"currentTime",void 0),e([y({type:Number})],D.prototype,"fov",null),e([y({readOnly:!0})],D.prototype,"hfov",null),e([y({readOnly:!0})],D.prototype,"imageRenderer",null),e([y()],D.prototype,"imageSize",void 0),e([y()],D.prototype,"oiViewModel",void 0),e([y()],D.prototype,"videoSource",void 0),e([y()],D.prototype,"videoDuration",void 0),e([y()],D.prototype,"videoLoaded",void 0),e([y()],D.prototype,"videoPaused",void 0),e([y()],D.prototype,"videoMuted",void 0),e([y({readOnly:!0})],D.prototype,"maxHFOV",null),e([y({readOnly:!0})],D.prototype,"minHFOV",null),e([y({type:Number})],D.prototype,"pitch",void 0),e([y()],D.prototype,"state",void 0),e([y()],D.prototype,"updatingHandles",void 0),e([y()],D.prototype,"updating",null),e([y({readOnly:!0})],D.prototype,"vfov",null),e([y()],D.prototype,"video",void 0),e([y({type:Number})],D.prototype,"yaw",void 0),D=e([f("esri.widgets.PanoramicViewer.PanoramicVideoViewerViewModel")],D);const E=D;export{E as default};
2
+ import{__decorate as e}from"tslib";import t from"../../Camera.js";import i from"../../Ground.js";import o from"../../Map.js";import a from"../../core/Collection.js";import r from"../../core/Error.js";import{EventedAccessor as s}from"../../core/Evented.js";import{addEventListener as n}from"../../core/events.js";import{JSONMap as d}from"../../core/jsonMap.js";import h from"../../core/Logger.js";import{rad2deg as l,deg2rad as m}from"../../core/mathUtils.js";import{destroyMaybe as c}from"../../core/maybe.js";import{waitTick as p}from"../../core/promiseUtils.js";import{watch as u,syncAndInitial as g,when as v,whenOnce as _}from"../../core/reactiveUtils.js";import{property as y,subclass as f}from"../../core/accessorSupport/decorators.js";import{UpdatingHandles as w}from"../../core/support/UpdatingHandles.js";import V from"../../geometry/SpatialReference.js";import M from"../../layers/GraphicsLayer.js";import{convertSphereVertexToPixelLocation as H}from"../../layers/orientedImagery/transformations/utils.js";import R from"../../views/SceneView.js";import{fixedImageSize as z}from"../OrientedImageryViewer/constants.js";import{createPanoramicMedia as b,extractHorizonAnglesFromMedia as P,logAndThrow as F,getMissingPropertyErrorName as S,getMissingPropertyErrorMessage as C}from"../OrientedImageryViewer/utils.js";import{defaultImageSphereCenter as j,maxPanoramicViewerHFOV as O,minPanoramicViewerHFOV as x,humanBinocularHFOV as I}from"./constants.js";import k from"./PanoramicZoomConditions.js";import A from"./PanoramicZoomViewModel.js";import{findDiagonalFOV as L,meshToGraphic as G,createImageSphere as T}from"./utils.js";import{enumeration as D}from"../../core/accessorSupport/decorators/enumeration.js";const E={default:"default",navigation:"navigation",fovConstraint:"fov-constraint",clickAction:"image-click-action",videoHandles:"video-handles"};let W=class extends s{constructor(e){super(e),this._startPosition=null,this._targetPosition=null,this._graphics=new M({elevationInfo:{mode:"relative-to-ground"}}),this._imageGraphic=null,this._loadController=null,this._map=new o({ground:new i({opacity:0,navigationConstraint:null}),layers:new a([this._graphics])}),this._zoomViewModel=null,this.autoLoad=!1,this.clickAction="none",this.closestFeature=null,this.currentTime=0,this.imageSize=null,this.media=null,this.oiViewModel=null,this.videoSource=null,this.videoDuration=void 0,this.videoLoaded=!1,this.videoPaused=null,this.videoMuted=null,this.pitch=90,this.state="ready",this.updatingHandles=new w,this.video=null,this.yaw=0,this._addNavigationHandles=()=>{this.imageRenderer.basemapTerrain.suspended=!0,this.imageRenderer.constraints.tilt.max=180,this.removeHandles(E.navigation),this.addHandles([this.imageRenderer.on("mouse-wheel",this._handleWheel),this.imageRenderer.on("double-click",this._handleDoubleClick),this.imageRenderer.on("drag",this._handleDrag),this.imageRenderer.on("key-down",e=>{const t=["+","-","Shift","_","=","ArrowUp","ArrowDown","ArrowRight","ArrowLeft"],i=e.key;t.includes(i)&&e.stopPropagation()})],E.navigation)},this._addHFOVHandles=()=>{this.removeHandles(E.fovConstraint),this.addHandles(u(()=>[this.maxHFOV,this.minHFOV],()=>{this._zoomViewModel&&(this._zoomViewModel.panoramicZoomConditions=new k({view:this.imageRenderer,maxFOV:this.maxHFOV,minFOV:this.minHFOV}))},g),E.fovConstraint)},this._addZoomHandles=()=>{this._zoomViewModel=new A({view:this.imageRenderer,panoramicZoomConditions:new k({maxFOV:this.maxHFOV,minFOV:this.minHFOV})});const e=this.imageRenderer.ui.find("zoom");e&&(e.viewModel=this._zoomViewModel),this._addHFOVHandles()},this._cancelLoadWithController=()=>{this._loadController?.abort(),this._loadController=null},this._createMedia=(e,t)=>{this.media=b({type:"video",url:e,matrix:t.attributes.matrix,cameraHeading:t.attributes.cameraHeading})},this._handleDoubleClick=e=>{e.stopPropagation(),e.native.ctrlKey?this._zoomOut():this._zoomIn()},this._handleDrag=e=>{e.stopPropagation();const{action:t,x:i,y:o}=e;switch(t){case"start":this._startPosition=this._targetPosition={x:i,y:o};break;case"update":this._targetPosition={x:i,y:o},this._updateCameraHeadingAndTilt()}},this._handleImageClick=e=>{if("image-loaded"===this.state&&this.imageRenderer.ready)switch(this.clickAction){case"emit":e.stopPropagation(),this.emit("click",e);break;case"hittest":e.stopPropagation(),e.defer(async()=>{const t=await this.imageRenderer.hitTest(e.screenPoint,{include:this._graphics});t.results=t.results.filter(e=>"graphic"===e.type&&e.graphic!==this._imageGraphic),this.emit("hittest-response",t)});break;case"pixel-location":{if(e.stopPropagation(),!this.imageSize||!e.mapPoint)return void this.emit("pixel-location",null);const t=H(e.mapPoint,this.imageSize[0],this.imageSize[1]);this.emit("pixel-location",{...t,spatialReference:V.WebMercator});break}}},this._handleWheel=e=>{const t=e.deltaX??e.native.deltaX;e.stopPropagation(),t>0||e.deltaY>0?this._zoomOut():this._zoomIn()},this._loadWithController=()=>{this._cancelLoadWithController(),this._loadController=new AbortController,this.loadVideo(this._loadController)},this._updateMedia=(e,t,i)=>{i.url=e,i.matrix=t.attributes.matrix,i.cameraHeading=t.attributes.cameraHeading},this._zoomIn=()=>this._zoomViewModel?.zoomIn(),this._zoomOut=()=>this._zoomViewModel?.zoomOut(),this.addGraphic=(e,t)=>"image-loaded"===this.state&&!this._graphics.graphics.includes(e)&&(this._graphics.graphics.add(e,t),!0),this.addManyGraphics=e=>{if("image-loaded"!==this.state)return!1;const t=e.filter(e=>!this._graphics.graphics.includes(e));return this._graphics.graphics.addMany(t),!0},this.clearGraphics=()=>{this._graphics.graphics.removeAll()},this.clearImage=()=>{this.imageSize=null,this._removeImageSphere()},this.enableAudio=()=>{const{video:e}=this;e&&(e.muted=!1,this.videoMuted=!1)},this.removeGraphic=e=>!("image-loaded"!==this.state||!this._graphics.graphics.includes(e))&&(this._graphics.remove(e),!0),this.removeManyGraphics=e=>{if("image-loaded"!==this.state)return!1;const t=e.filter(e=>this._graphics.graphics.includes(e));return this._graphics.removeMany(t),!0},this.togglePanoramicAudio=()=>{if(this.video){const e=this.video.muted;this.video.muted=!e,this.videoMuted=!e}},this._imageRenderer=new R({map:this._map,viewingMode:"local",camera:{position:j},environment:{atmosphereEnabled:!1,starsEnabled:!1,lighting:{type:"virtual"}},popupEnabled:!1,spatialReference:V.WebMercator,attributionVisible:!1,ui:{components:["zoom"]}})}destroy(){this._imageRenderer.destroy()}initialize(){this.state="initialized",this.addHandles([u(()=>this.videoSource,()=>{this.videoSource&&this.autoLoad&&this._loadWithController()},g),u(()=>this.fov,()=>{this._reloadCamera()},g),u(()=>this.yaw,e=>{this.camera&&(this.camera.heading=e,this._reloadCamera())},g),u(()=>this.pitch,e=>{this.camera&&(this.camera.tilt=e,this._reloadCamera())},g),v(()=>this.imageRenderer.ready,()=>{this._addNavigationHandles(),this._addZoomHandles()},g),u(()=>this.clickAction,e=>{this.removeHandles(E.clickAction),"none"!==e&&this.addHandles(this.imageRenderer.on("click",this._handleImageClick))},g),u(()=>this.video,e=>{if(e instanceof HTMLVideoElement){this._startVideo();const t=async()=>{this.currentTime=Number(e.currentTime.toFixed(2)),e.currentTime&&await this._updateVidFootprint(e.currentTime)};this.removeHandles(E.videoHandles);const i=n(e,"timeupdate",t),o=n(e,"play",()=>this._updateVideoIcon(e.paused)),a=n(e,"pause",()=>this._pauseVideoHandler(e));this.addHandles([i,o,a],E.videoHandles)}},g),u(()=>[this.videoSource,this.oiViewModel?.currentBestFeature,this.closestFeature],()=>{if(!this.videoSource||!this.oiViewModel.currentBestFeature)return;const e=this.closestFeature??this.oiViewModel.currentBestFeature;this.media?this._updateMedia(this.videoSource,e,this.media):this._createMedia(this.videoSource,e)},g)],E.default)}get camera(){return this.imageRenderer.destroying||this.imageRenderer.destroyed?null:this.imageRenderer.camera}set camera(e){!e||this.imageRenderer.destroying||this.imageRenderer.destroyed||(this.imageRenderer.camera=e.clone())}get fov(){return this.camera?.fov}set fov(e){Number.isFinite(e)&&this._zoomViewModel?.zoomTo(e)}get horizonAngles(){return P(this.media)}get hfov(){if(!this.camera||!this.imageRenderer?.ready)return null;const{fov:e}=this.camera,{size:[t,i]}=this.imageRenderer,o=t/i,a=Math.atan(o);return 2*l(Math.atan(Math.tan(m(e/2))*Math.sin(a)))}get imageRenderer(){return this._imageRenderer}get maxHFOV(){const{size:[e,t]}=this.imageRenderer;return this.imageRenderer.ready?L(O,e/t):O}get minHFOV(){const{size:[e,t]}=this.imageRenderer;return this.imageRenderer.ready?L(x,e/t):x}get updating(){return this.updatingHandles.updating}get vfov(){if(!this.camera||!this.imageRenderer?.ready)return null;const{fov:e}=this.camera,{size:[t,i]}=this.imageRenderer,o=t/i,a=Math.atan(o);return 2*l(Math.atan(Math.tan(m(e/2))*Math.cos(a)))}async _loadVideoInternal(e,t){return this.state="image-loading",this.video=document.createElement("video"),this.video.src=e,this.video.addEventListener("loadedmetadata",()=>{this._setVideoDuration(),this.videoLoaded=!0}),this._updateImageSphere(this.video,t)}_pauseVideoHandler(e){this._updateVideoIcon(e.paused)}_setVideoDuration(){const{video:e}=this;e?.duration&&(this.videoDuration=e.duration)}_startVideo(){try{this.enableAudio();const e=this.oiViewModel.currentBestFeature;e&&this.playPanoramicVideoFromSelectedLocation(e)}catch(e){h.getLogger(this).error("oriented-imagery-viewer:video-load",e)}}_reloadCamera(){this.camera=this.camera?.clone()}_removeImageSphere(){this._imageGraphic&&(this._graphics.remove(this._imageGraphic),this._imageGraphic=c(this._imageGraphic)),this.state="ready",this.imageSize=null}_updateCameraHeadingAndTilt(){if(!this._startPosition||!this._targetPosition||!this.camera)return;const e=this.camera.heading+(this._startPosition.x-this._targetPosition.x)/this.imageRenderer.width*this.camera.fov;this.yaw=(e+360)%360;const t=this.camera.tilt-(this._startPosition.y-this._targetPosition.y)/this.imageRenderer.height*this.imageRenderer.camera.tilt;this.pitch=Math.min(179.5,Math.max(.5,t)),this._startPosition=this._targetPosition}async _updateImageSphere(e,t){await p(t);const[i,o,a]=this.horizonAngles??[0,0,0];return this._imageGraphic=G(T({data:e,horizonPitch:i,horizonRoll:o,horizonYaw:a})),this._graphics.add(this._imageGraphic),this.state="image-loaded",_(()=>this.imageRenderer.ready,t).then(()=>{const{size:[e,t]}=this.imageRenderer;this.fov=L(I,e/t)}),this.imageSize=z,this._imageGraphic.geometry}async _updateVidFootprint(e){const t=this.oiViewModel?.featureCache.find(t=>t.attributes.offsetFromStart===Math.floor(e)),{yaw:i,pitch:o,vfov:a,hfov:r}=this,s=!(t?.attributes.offsetFromStart&&a&&r&&i&&o),n=t?.attributes.objectId===this.closestFeature?.attributes.objectId;s||n||(this.closestFeature=t)}_updateVideoIcon(e){this.videoPaused=!!e}async loadVideo(e){return this._removeImageSphere(),this.videoSource?this._loadVideoInternal(this.videoSource,e):F(this.declaredClass,new r(S("panoramic-viewer"),C("PanoramicViewerViewModel","videoSource")))}playPanoramicVideoHandler(){const{video:e}=this;e&&(e.paused?e.play().catch(e=>{h.getLogger(this).error("error playing video",e)}):e.pause())}playPanoramicVideoFromSelectedLocation(e){const t=e.attributes.offsetFromStart;if(t){const e=this.video;e&&(e.currentTime=t,e.play().catch(e=>{h.getLogger(this).error("error playing video",e)}))}}rewindPanoramicVideoHandler(){const{video:e}=this;e&&(e.currentTime=0,e.play().catch(e=>{h.getLogger(this).error("error playing video",e)}))}};e([y()],W.prototype,"_graphics",void 0),e([y()],W.prototype,"_imageGraphic",void 0),e([y()],W.prototype,"_imageRenderer",void 0),e([y()],W.prototype,"_loadController",void 0),e([y()],W.prototype,"_map",void 0),e([y()],W.prototype,"_zoomViewModel",void 0),e([y({type:Boolean})],W.prototype,"autoLoad",void 0),e([y({type:t})],W.prototype,"camera",null),e([D(new d({emit:"emit",hittest:"hittest",none:"none","pixel-location":"pixel-location"}))],W.prototype,"clickAction",void 0),e([y()],W.prototype,"closestFeature",void 0),e([y()],W.prototype,"currentTime",void 0),e([y({type:Number})],W.prototype,"fov",null),e([y()],W.prototype,"horizonAngles",null),e([y({readOnly:!0})],W.prototype,"hfov",null),e([y({readOnly:!0})],W.prototype,"imageRenderer",null),e([y()],W.prototype,"imageSize",void 0),e([y()],W.prototype,"media",void 0),e([y()],W.prototype,"oiViewModel",void 0),e([y()],W.prototype,"videoSource",void 0),e([y()],W.prototype,"videoDuration",void 0),e([y()],W.prototype,"videoLoaded",void 0),e([y()],W.prototype,"videoPaused",void 0),e([y()],W.prototype,"videoMuted",void 0),e([y({readOnly:!0})],W.prototype,"maxHFOV",null),e([y({readOnly:!0})],W.prototype,"minHFOV",null),e([y({type:Number})],W.prototype,"pitch",void 0),e([y()],W.prototype,"state",void 0),e([y()],W.prototype,"updatingHandles",void 0),e([y()],W.prototype,"updating",null),e([y({readOnly:!0})],W.prototype,"vfov",null),e([y()],W.prototype,"video",void 0),e([y({type:Number})],W.prototype,"yaw",void 0),W=e([f("esri.widgets.PanoramicViewer.PanoramicVideoViewerViewModel")],W);const N=W;export{N as default};