@arcgis/core 5.2.0-next.118 → 5.2.0-next.119

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 (41) hide show
  1. package/assets/esri/core/workers/RemoteClient.js +1 -1
  2. package/assets/esri/core/workers/chunks/{62b1f94f4fa978d4da48.js → 354912041363502c6a89.js} +1 -1
  3. package/assets/esri/core/workers/chunks/{4925d0b29a166cc8fee1.js → 3c3e5e952fd6740bb234.js} +1 -1
  4. package/assets/esri/core/workers/chunks/5938d5f6e37f49867d5a.js +1 -0
  5. package/assets/esri/core/workers/chunks/{0dc317d022807af92e3f.js → 723478607badcde5706b.js} +2 -2
  6. package/assets/esri/core/workers/chunks/{42c4d0c1c08bf111e5a4.js → 731ec5de16753e10b963.js} +1 -1
  7. package/assets/esri/core/workers/chunks/{5965a947f68b707eaa6b.js → 82ce034b5ba54de9b970.js} +1 -1
  8. package/assets/esri/core/workers/chunks/97fea852f8e93e1286e4.js +1 -0
  9. package/chunks/Water.glsl.js +36 -47
  10. package/config.js +1 -1
  11. package/kernel.js +1 -1
  12. package/layers/video/VideoController.js +1 -1
  13. package/package.json +3 -3
  14. package/support/revision.js +1 -1
  15. package/symbols/cim/animationUtils.js +1 -1
  16. package/views/2d/engine/webgl/animations/instructions.js +1 -1
  17. package/views/3d/analysis/LineOfSight/LineOfSightEditTool.js +1 -1
  18. package/views/3d/analysis/LineOfSight/LineOfSightItemTool.js +1 -1
  19. package/views/3d/analysis/LineOfSight/LineOfSightTool.js +1 -1
  20. package/views/3d/analysis/LineOfSightAnalysisView3D.js +1 -1
  21. package/views/3d/camera/constraintUtils.js +1 -1
  22. package/views/3d/state/controllers/GroundNavigationController.js +1 -1
  23. package/views/3d/state/controllers/InteractiveController.js +1 -1
  24. package/views/3d/state/controllers/momentum/GroundNavigationMomentumController.js +1 -1
  25. package/views/3d/state/controllers/momentum/MomentumController.js +1 -1
  26. package/views/3d/state/utils/OffsetCorrectionController.js +2 -0
  27. package/views/3d/webgl-engine/core/shaderLibrary/ShaderOutput.js +1 -1
  28. package/views/3d/webgl-engine/core/shaderLibrary/shading/NormalUtils.glsl.js +3 -3
  29. package/views/3d/webgl-engine/materials/Water.glsl.js +1 -1
  30. package/views/3d/webgl-engine/materials/WaterMaterial.js +1 -1
  31. package/views/3d/webgl-engine/materials/WaterTechniqueConfiguration.js +1 -1
  32. package/widgets/Measurement.d.ts +1 -2
  33. package/widgets/Measurement.js +1 -1
  34. package/widgets/OrientedImageryViewer/OrientedImageryViewerViewModel.js +1 -1
  35. package/widgets/Sketch/SketchViewModel.d.ts +13 -0
  36. package/widgets/Sketch/SketchViewModel.js +1 -1
  37. package/widgets/Sketch/VisibleElements.d.ts +8 -1
  38. package/widgets/Sketch/VisibleElements.js +1 -1
  39. package/widgets/Sketch/support/PluginManager.d.ts +11 -1
  40. package/assets/esri/core/workers/chunks/21c0743b2f612e7e7de3.js +0 -1
  41. package/assets/esri/core/workers/chunks/b961e0aaa6b3ea75315c.js +0 -1
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{__decorate as e}from"tslib";import t from"../../Graphic.js";import{equals as i,isSome as a}from"../../core/arrayUtils.js";import{createTask as r}from"../../core/asyncUtils.js";import o from"../../core/Collection.js";import{deprecatedProperty as s}from"../../core/deprecate.js";import n from"../../core/Error.js";import{EventedMixin as l}from"../../core/Evented.js";import{makeHandle as d}from"../../core/handleUtils.js";import{equalsShallow as c}from"../../core/lang.js";import h from"../../core/Logger.js";import{clamp as u,deg2rad as p}from"../../core/mathUtils.js";import{destroyMaybe as m,abortMaybe as g}from"../../core/maybe.js";import{EsriPromise as v}from"../../core/Promise.js";import{isAbortError as y,throwIfAborted as f,waitTick as w}from"../../core/promiseUtils.js";import _ from"../../core/ReactiveMap.js";import{whenOnce as F,on as V,watch as S,syncAndInitial as b,initial as M,when as P}from"../../core/reactiveUtils.js";import{sqlAnd as I}from"../../core/sql.js";import{getMetersPerUnitForSR as C}from"../../core/units.js";import{property as A,subclass as k}from"../../core/accessorSupport/decorators.js";import{isSerializable as T}from"../../core/support/jsonUtils.js";import{UpdatingHandles as O}from"../../core/support/UpdatingHandles.js";import L from"../../geometry/Extent.js";import E from"../../geometry/Point.js";import{projectAsync as G}from"../../geometry/projectionUtils.js";import j from"../../geometry/SpatialReference.js";import{polygonCentroidPoint as R}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 D}from"../../geometry/support/webMercatorUtils.js";import N from"../../layers/GraphicsLayer.js";import H from"../../layers/MediaLayer.js";import{searchImages as z,getSortedLayerFeatures as U}from"../../layers/orientedImagery/queries.js";import{calculateSuitabilities as q}from"../../layers/orientedImagery/core/bestImageUtils.js";import{createCoveragePolygon as W,computePolygonForInspection as $,resizePolygon as Z,checkIfPolygonContainsSelectedPoint as J}from"../../layers/orientedImagery/core/coverageUtils.js";import{isElevationSource as K}from"../../layers/orientedImagery/core/ElevationSourceDefinitions.js";import{getMetersPerUnitOfSR as Q,convertGeographicToWebMercator as X}from"../../layers/orientedImagery/core/utils.js";import Y from"../../layers/orientedImagery/transformations/updateElevation.js";import{getElevationSampler as ee}from"../../layers/orientedImagery/transformations/updateElevationUtils.js";import{or as te,getInitialAngle as ie,convertPixelLocationToSphereVertex as ae,getUpdateElevationProps as re,adjustHorizonAngles as oe,convertOrientationToPixelLocation as se,getImageToWorldProperties as ne,getImageToWorldPanoramicProperties as le}from"../../layers/orientedImagery/transformations/utils.js";import de from"../../layers/support/ExtentAndRotationGeoreference.js";import{getFloorFilterClause as ce}from"../../layers/support/floorFilterUtils.js";import he from"../../layers/support/VideoElement.js";import ue from"../../views/MapView.js";import pe from"../../views/draw/Draw.js";import{scale as me}from"../../views/draw/support/drawUtils.js";import{ViewEventPriorities as ge}from"../../views/input/InputManager.js";import ve from"../PanoramicVideoViewer.js";import ye from"../PanoramicViewer.js";import{defaultAngleThresholdInDegrees as fe,videoMapViewConstraint as we,fixedImageSize as _e,clockwiseDirections as Fe,videoFitScaleTolerance as Ve,videoExtent as Se,invalidCameraHeading as be,sectorsInOrder as Me,sampleExtent as Pe,sectorsRadii as Ie}from"./constants.js";import{isFeatureAttachment as Ce}from"./galleryUtils.js";import{crossSymbol as Ae,crossSymbol3D as ke,measurementPolygonSymbol as Te,polylineSymbolPanoramic as Oe,measurementPolylineSymbol as Le,cameraOverlaySymbol3D as Ee,cameraOverlaySymbol as Ge,diamondSymbol as je,diamondSymbol3D as Re,activeSourcePointSymbol as xe,sourcePointSymbol as Be}from"./symbols.js";import{registryKeys as De}from"./types.js";import{isNoAttachmentError as Ne,extractHorizonAnglesFromMedia as He,isTifOrMrf as ze,filterOILLayerView as Ue,assignElevationSampleToFeatures as qe,filterByZ as We,createPanoramicMedia as $e,createNonPanoramicMedia as Ze,isSceneView as Je,isGraphic as Ke,calculateSegment as Qe,calculateDirection as Xe}from"./utils.js";import{disableVideoZoomAndPan as Ye,getUpdatedConstraints as et,getUpdatedExtentPoints as tt,isSelectedPointWithinVideoFootprint as it,isVideoPixelWithinFrame as at}from"./videoViewerUtils.js";import rt from"./components/ImageViewer.js";import ot from"./components/NavigationNode.js";import st from"./components/OrientedImageryVideoViewModel.js";import{NoFeatureFoundWithObjectIdError as nt}from"./navigation/errors.js";import{queryFeatureByObjectIds as lt}from"./navigation/queries.js";import{ImageMeasurementService as dt}from"./services/ImageMeasurementService.js";import ct from"./services/SuperimposeService.js";import{configureSketchTool as ht,extractFieldsFromDataCaptureLayer as ut,constructGraphicFromImageGeometry as pt}from"./support/dataCaptureUtils.js";import{removeZFromGeometry as mt,imageSpaceToPoint as gt,pointToImageSpace as vt}from"./support/geometryUtils.js";import{restorePanoramicNavigationViewState as yt,restoreDefaultNavigationViewState as ft}from"./support/navigationViewStateUtils.js";import wt from"./support/resolveMediaProps.js";import{isValidDataCaptureLayer as _t}from"./support/typeUtils.js";const Ft=()=>new n("orientedimageryviewer:sketch-not-initialized","Sketch property is not initialized, call loadSketch first");let Vt=class extends(l(v)){constructor(e){super(e),this.additionalFeatures=new o,this.additionalCameraLocations=new o,this.additionalFootprints=new o,this.areaMeasurementResult=0,this.areaMeasurementAccuracy=0,this.bestFeatureAngle=0,this.bestFeatureCurrentFootprint=null,this.bestFeatureFootprint=null,this.cameraHeadingThreshold=fe,this.cameraPitchThreshold=fe,this.clickAction="hittest",this.correctedLocationPointOnImage=null,this.videoViewModel=null,this.collectionId=null,this.coverageFrustums=new o,this.coveragePolygons=new o,this.currentBestFeature=null,this.currentBestFeatureMeasurementImage=null,this.currentBestFeatureLocation=null,this.currentCoverageVisible=!0,this.depthImage=null,this.featureCache=[],this.navigationNodes=new o,this.determineWorkflowForFeature=async(e,t,i)=>{const{currentBestFeature:a,selectedPoint:r}=this;if(this.emit("popup-close"),a&&r){this.displayMessage=null,this._initialCurrentCoverageUpdate=!0,this._updateGroundElevation=!0;try{await this._updatePointsAndPolygons(i),await this._loadDepthImage(i),await this._loadCurrentFeatureMedia(a,i)}catch(o){y(o)||(this.loadImageError(o),h.getLogger(this).error("#loadIImage()","error occured while loading image",o))}}},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),h.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 o,this.groundCoordinates=null,this.groundCoordinatesAccuracy=null,this.groundCoordinatesAccuracyLoading=!1,this.heightGraphic=null,this.heightMeasurementResult=0,this.heightMeasurementAccuracy=0,this.imageGeometryField=null,this.imageLocationToolState=!1,this.initialVideoMapViewExtent=null,this.imageMeasurementViewer=new rt,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 o,this.overlayedMapFeatures=new _,this.pixelCoordinates=null,this.preserveAngle="none",this.pointSources=new o,this.preloadMedia=!1,this.preloadMediaSize=5,this.previousFeatureAngle=0,this.selectedPoint=null,this.shouldShowSelectedImage=!1,this.superimposeViewEnabled=!1,this.defaultSuperimposeCameraLockEnabled=!0,this.sketch=null,this.sketchTriangular=null,this.sketchTriangularGraphicsLayer=null,this.draw=null,this.drawAdapter=null,this.polylineDrawAction=null,this.scheduledFrameId=null,this.superimposeScheduledFrameId=null,this.superimposeDebounceTimeoutId=null,this.sketchAdapter=null,this.triangularMeasurementActive=!1,this.triangulatedDistanceMeasurement=null,this.triangulatedDistanceAccuracy=null,this.triangulatedAreaMeasurement=null,this.triangulatedAreaAccuracy=0,this.triangulatedMeasurementGraphic=null,this.triangulatedPoint=null,this.triangulatedMeasurementAdapter=null,this.updateFootprint=async(e,t,i)=>{"default"===this.mode&&"image-loaded"!==this.state||await(this._adapter?.updateFootprint(e,t,i))},this.updateVideoFootprint=async e=>{this.mode.includes("video")&&this.videoElement?.content&&await(this._adapter?.updateVideoFootprint(e))},this.updateFootprintPanorama=async(e,t)=>{await(this._adapter?.updateFootprintPanorama(e,t))},this.updatingTriangularMeasurementState=!1,this.videoElement=null,this.videoLayer=null,this.videoMapView=new ue({map:new Map,constraints:we}),this.verticalFilterEnabled=!1,this._adapter=null,this._highlightedFeatureHandle=null,this._imageViewer=new rt,this._initialCurrentCoverageUpdate=!0,this._locationViewModel=null,this._measurementService=null,this._mediaPrefetcher=null,this._navigationManager=null,this._overlays=new N({listMode:"hide",internal:!0,elevationInfo:{mode:"absolute-height"},title:"OrentedImageryViewerViewModel overlays layer"}),this._superimposePreviousCurrentCoverageVisible=null,this._superimposeService=new ct({getMapPoint:(e,t)=>this.getMapPoint(e,t),getPanoramicTransformationState:()=>{const{imageToWorldProperties:e,mode:t,updateElevationProps:i}=this._transformationService;return"panoramic"===t&&e?{imageToWorldProperties:e,updateElevationProps:i}:null},pointToPixel:(e,t)=>this._transformationService.pointToPixel(e,t),overlays:this._overlays,getPointAtDistance:(e,t,i)=>this._transformationService.pixelToPointAtDistance(e,t,i)}),this._panoramicVideoViewer=new ve,this._panoramicViewer=new ye,this._panoramicMeasurementViewer=new ye,this._referencePointOnGround=null,this._referencePointOnImage=null,this._referenceTransformationService=null,this._sectorData=null,this._transformationService=null,this._featureToSector=null,this._updatingHandles=new O,this._clickTask=null,this._crossSymbol=null,this.footprintExtent=null,this._featureChangedTask=null,this._mediaPrefetchTask=null,this._navigationViewStateTask=null,this._pendingPanoramicNavigationViewState=null,this._restoreSuperimposeMediaTask=null,this._superimposeScheduleController=null,this._suitabilities=null,this._pendingDefaultNavigationViewState=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 f(e),this.sketchAdapter=new i({viewModel:this}),this.sketchAdapter},this.loadImageFromFeature=(e,t,i)=>this._updatingHandles.addPromise(this._loadImageFromFeature(e,t,i)),this.storeImageMeasurementViewer=e=>{this.imageMeasurementViewer=e},this.storePanoramicMeasurementViewer=e=>{this._panoramicMeasurementViewer=e},this.loadImageViewer=e=>{this._imageViewer?.destroy(),this._imageViewer=e},this.loadPanoramicViewer=e=>{this._panoramicViewer?.destroy(),this._panoramicViewer=e},this.loadPanoramicVideoViewer=e=>{this._panoramicVideoViewer?.destroy(),this._panoramicVideoViewer=e},this.loadVideoViewer=e=>{this.videoMapView.container=e},this.showImageByObjectId=async(e,t)=>{const i=this.additionalFeatures.find(({attributes:t})=>t.objectId===e);if(i)this.currentBestFeature=i;else{const{layer:i,layerFloorFilterClause:r,layerTimeExtent:o}=this;if(!i)return void this.setMessage("noLayerSelected","info");this.beforeLoad();const s=this._updatingHandles.addPromise(this._queryAndLoadByObjectId(i,e,r,o,t));try{await s,await this.selectBestFeature(e,t)}catch(a){y(a)||(h.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.");this._pendingDefaultNavigationViewState=null,this._pendingPanoramicNavigationViewState=null;const a=e=>"default"===i&&e.declaredClass.endsWith("NavigationManager")||"panoramic"===i&&e.declaredClass.endsWith("NavigationManagerPanoramic");if(null==this._navigationManager||!a(this._navigationManager)){m(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)=>(f(t),this.currentBestFeature=this.features?.find(({attributes:t})=>`${t.objectId}`==`${e}`),F(()=>{switch(this.mode){case"video":return"video-loaded"===this.state;case"panoramic-video":return this.panoramicVideoLoaded;default:return"image-loaded"===this.state}},t)),this.toggleImageAttributes=()=>{const{currentBestFeature:e,popupEnabled:i,layer:a,view:r}=this;if(this.emit("popup-close"),!(r&&e&&i&&a))return;const{attributes:o,geometry:s}=e,n=new t({geometry:s,attributes:o.toJSON(),origin:a.graphicOrigin,sourceLayer:a});this.emit("popup-open",{features:[n],location:o.location.clone()})},this.updateSuitabilities=(e,t=!0)=>{e.sort((e,t)=>e.suitability-t.suitability),this._suitabilities=e;const i=this._suitabilities.map(({feature:e})=>e);this._initialCurrentCoverageUpdate=!0,this._updateFeatures(i,t),this._groupFeaturesBySectors()},this._computeOverlayImageSize=()=>{const{mode:e}=this;return"video"===e?_e:"panoramic-video"===e?this._panoramicVideoViewer.imageSize:this.activeViewer?.imageSize},this._geometryToOverlayImageGeometry=async(e,t,i)=>{const{mode:a,videoViewModel:r,_panoramicVideoViewer:o}=this;if("video"===a)return await(r?.geometryToOverlayGeometry(e,t))??null;if("panoramic-video"===a){const r={feature:t,mode:a,imageSize:i,footprintExtent:this.footprintExtent};return await this._transformationService.geometryToImageGeometryForFeature(e,r,o.horizonAngles)}return await this._transformationService.geometryToImageGeometry(e)},this._createViewClickHandle=()=>{if(this.removeHandles(De.click),this.disabled||null==this.view)return;const e=this.mapImageConversionToolState&&("image-loaded"===this.state||"video-loaded"===this.state&&"video"===this.mode&&!!this.videoViewModel?.videoPaused||this.panoramicVideoLoaded&&"panoramic-video"===this.mode&&this.panoramicVideoPaused)?this._mapImageConversionToolViewClickHandler:this._viewClickHandler;this.addHandles(this.view.on("click",e,ge.DEFAULT),De.click)},this._createImageClickHandle=()=>{this.removeHandles(De.imageClick),this.videoViewModel?.syncMapImageConversionHandle();const{mapImageConversionToolState:e,mode:t,footprintExtent:i,panoramicVideoLoaded:a}=this,o="panoramic-video"===t?this._panoramicVideoViewer:this.activeViewer,s=o?.imageSize;if(!e||"none"===t||"video"===t||!s||!i)return;const n="panoramic-video"===t,l=this._getActiveFeatureForCurrentMode(),c=!n||a&&this.panoramicVideoPaused;if(!l||!c)return;const h=o.clickAction;this.clickAction="pixel-location";const u=d(()=>{this.clickAction=h});let p=null;const m=V(()=>o,"pixel-location",e=>{this.plotReferencePointOnImage(e),p?.abort(),p=r(async a=>{if(!e)return;const r=this._getActiveFeatureForCurrentMode();if(!r)return;const o={feature:r,mode:t,imageSize:s,footprintExtent:i};let l=n?await this.getMapPointForFeature(e,o,{signal:a}):await this._transformationService.pixelToMapPoint(e);const d=this.view?.spatialReference;l&&!te(!d,l.spatialReference.equals(d))&&(l=await G(l,d,{signal:a})),f(a),this.plotReferencePointOnGround(l)})});this.addHandles([m,u],De.imageClick)},this._createTriangularImageClickHandle=()=>{this.removeHandles(De.triangularImageClick),this.triangularMeasurementActive&&"none"!==this.mode&&this.currentBestFeature&&this.currentBestFeatureMeasurementImage&&this.activeTriangulatedViewer&&this.addHandles(this.activeTriangulatedViewer.imageRenderer.on("double-click",this._measurementImageClickHandler),De.triangularImageClick)},this._enablePan=()=>{this.removeHandles(De.videoPanHandles)},this._disablePan=()=>{this.removeHandles(De.videoPanHandles),this.addHandles(Ye(this.videoMapView),De.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._loadCurrentFeatureMedia=async(e,t)=>{"video"!==this.mode?"panoramic-video"!==this.mode?await this._loadImage(t):await this._loadVideo(t):await this._loadFlatVideo(e,t)},this._loadFlatVideo=async(e,t)=>{this._initializeVideo(),this.videoViewModel?.playVideoFromSelectedLocation(e);const i=e.attributes.objectId;this._waitForFlatVideoAndPlotSelectedLocation(e,i,t)},this._waitForFlatVideoAndPlotSelectedLocation=async(e,t,i)=>{try{if(await F(()=>!0===this.videoElement?.loaded,i),`${this.currentBestFeature?.attributes.objectId}`!=`${t}`)return;await this.transformAndPlotSelectedLocation(i)}catch(a){y(a)||h.getLogger(this).error("failed to plot selected point on video",{error:a,selectedPoint:this.selectedPoint,feature:e})}},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 o=(await(import("./services/DepthImageService.js"))).default;f(e),this.depthImage=new o({url:r});try{await this.depthImage.load(e)}catch(s){y(s)||(h.getLogger(this).error("error occurred while loading depth image",s),this.depthImage?.destroy(),this.depthImage=null)}},this._loadImage=async e=>{const{currentBestFeature:t,layer:i,mode:a}=this,r=this._pendingDefaultNavigationViewState;if(this._pendingDefaultNavigationViewState=null,this.clearGraphics(),i&&t&&"none"!==a&&"video"!==a&&"panoramic-video"!==a)try{if(await this.loadImageFromFeature(i,t,e),f(e),r)try{await this._restoreNavigationViewState(r,e)}catch(o){if(y(o))throw o;h.getLogger(this).warn("oriented-imagery-viewer:failed-to-restore-navigation-view-state",o)}await this.transformAndPlotSelectedLocation(e)}catch(o){y(o)||this.loadImageError(o)}},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:o}=t,{cameraPitch:s,cameraOrientation:n,location:l}=o,d=l.spatialReference.isWGS84&&4!==n?.type?D(l):new E(l);try{this._panoramicVideoViewer.viewModel.video&&(this._panoramicVideoViewer.viewModel.video.pause(),this._panoramicVideoViewer.viewModel.videoPaused=!0),this._panoramicVideoViewer.videoSource=r;let t=0;d&&a&&(t=await ie(d,a)-t),this._panoramicVideoViewer.pitch=s??0,this._panoramicVideoViewer.yaw=t,await this._panoramicVideoViewer.loadVideo(e),f(e)}catch(c){y(c)||this.loadImageError(c)}},this._loadImageFromFeature=async(e,t,i)=>{const{mode:a}=this;if("default"!==a&&"panoramic"!==a)return;let r;try{r=await wt(t.attributes,e,i),f(i)}catch(v){if(y(v))return;return Ne(v)?(h.getLogger(this).error(v),void this.setMessage("noAttachment","error",`${e.objectIdField}: ${t.attributes.objectId}`)):(h.getLogger(this).error(v,{[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:o,datasetFormat:s,rotation:n,searchParams:l,location:d,cameraHeading:c,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 d&&this.selectedPoint&&(a=await ie(d,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&&h.getLogger(this).warn("error occurred while getting dataset format",m),"panoramic"===a?await this.loadPanoramicMediaSource({lookAt:{yaw:this.selectedPoint?await ie(d,this.selectedPoint):"viewAngle"in t.attributes&&Number.isFinite(t.attributes.viewAngle)?t.attributes.viewAngle:0,pitch:p},extension:s?.toUpperCase(),url:o,cameraHeading:c,matrix:u},i):await this.loadMediaSource({datasetFormat:s?.toUpperCase(),url:o,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),f(e)}catch(r){y(r)||this.loadImageError(r)}},this._loadMediaPrefetcher=async e=>{if(!this._mediaPrefetcher){const{default:t}=await(import("./support/MediaPrefetcher.js"));f(e),this._mediaPrefetcher=new t({maxEntries:this.preloadMediaSize*Fe.length})}return this._mediaPrefetcher},this._loadViewAdapter=async e=>{const{view:t}=this;if(this._adapter?.disableDefaultSuperimposeNavigation?.(),this._adapter?.disablePanoramicSuperimposeNavigation?.(),t)switch(t.type){case"2d":{const{default:t}=await(import("./adapters/view/MapViewAdapter.js"));f(e),this._adapter=new t(this);break}case"3d":{const{default:t}=await(import("./adapters/view/SceneViewAdapter.js"));f(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;const{minScale:t}=this.videoMapView.constraints,i=this.videoMapView.scale<t-Ve,a=et(e);i&&!!a?(this._enablePan(),this.videoMapView.constraints.geometry=a):i?(this._disablePan(),this.videoMapView.constraints.geometry=null):(this.initialVideoMapViewExtent&&!this.videoMapView.extent.equals(this.initialVideoMapViewExtent)&&(this.videoMapView.extent=this.initialVideoMapViewExtent),this._disablePan(),this.videoMapView.constraints.geometry=null)},this._viewClickHandler=e=>{this._clickTask?.abort(),this._clickTask=r(async t=>{const{pointerType:i,button:a,mapPoint:r}=e;if("mouse"===i&&0!==a||!r)return;e.stopPropagation(),e.preventDefault();const{view:o,layer:s}=this;if(o){if(s){if(this.shouldShowSelectedImage){const i=o.hitTest(e,{include:[s]});this._updatingHandles.addPromise(i);const a=await i;return f(t),await this._processHitTestResults(s,a,{signal:t})}return this._updatingHandles.addPromise(this.loadBestImage(r,{signal:t}))}this.setMessage("noLayerSelected","info")}})},this.plotSelectedPointOnImage=async(e,i)=>{if(await w(i),!e)return;const a=new E({...T(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:Ae}),this._imageViewer.addGraphic(this._crossSymbol,0);else if("video"===this.mode)this._crossSymbol=this.videoViewModel?.plotSelectedPointOnVideo(a)??null;else if("panoramic"===this.mode){const{imageSize:i,media:a}=this._panoramicViewer;if(!i||!a)return;const r=He(a),o=ae(e,...i,r);this._crossSymbol=new t({geometry:new E(o,j.WebMercator),symbol:ke}),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([S(()=>this.view,()=>this.load(),b),S(()=>this.view?.map,(e,t)=>{t?.layers.remove(this._overlays),e?.layers.add(this._overlays)},M),S(()=>this.view?.map?.allLayers?.length,e=>{e&&this.view?.map?.layers.reorder(this._overlays,e-1)},M),S(()=>[this.state,this.panoramicVideoLoaded,this.mapImageConversionToolState,this.view,this.disabled,this.panoramicVideoPaused,this.videoViewModel?.videoPaused],(e,t)=>{const i=e[2],a=t?.[2];a&&!i&&(this.plotReferencePointOnGround(null),this.clearReferencePointOnImage()),this._createViewClickHandle(),this._createImageClickHandle()},b),S(()=>[this.triangularMeasurementActive,this.currentBestFeatureMeasurementImage],()=>{this._createTriangularImageClickHandle()},b),S(()=>[this.state,this.imageLocationToolState,this.view],()=>{this._initializeMeasurementService(),this._initializeLocationViewModel()},b),S(()=>this.measureType,()=>{this.clearPreviousMeasurements(),this._initializeMeasurementService()},b),S(()=>this.bestFeatureAngle,(e,t)=>{this.previousFeatureAngle=t??0},b),S(()=>[this.superimposeViewEnabled,this.defaultSuperimposeCameraLockEnabled,this.superimposeViewSupported,this.currentBestFeature,this.mode,this.state,this.view?.type],()=>{this._shouldDisableUnsupportedSuperimposeView()?this.superimposeViewEnabled=!1:this._hasActiveSuperimposeCameraContext()?this._updateSuperimposedImage():this._resetInactiveSuperimposeState()},b),S(()=>this._getSuperimposeCameraWatchState(),()=>this._handleSuperimposeCameraChange(),b),S(()=>this.currentBestFeature,async(e,t)=>{g(this._featureChangedTask),this._featureChangedTask=r(async i=>this.determineWorkflowForFeature.apply(this,[e,t,{signal:i}])),await this._featureChangedTask.promise},{sync:!0}),S(()=>[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}),f(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),S(()=>this.currentBestFeatureMeasurementImage,(e,t)=>{g(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}),f(i),this._reorderTriangularSketchLayer()})},b),S(()=>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())}),S(()=>this.mode,e=>{switch(this.removeHandles(De.interactionHandles),e){case"default":this.addHandles(S(()=>{const{state:e}=this;return"image-loaded"===e?this._imageViewer.imagePointsInView:null},e=>{e&&(g(this._updateFootprintTask),this._updateFootprintTask=r(async t=>{await this.updateFootprint(e,void 0,{signal:t})}))},{...b,equals:(e,t)=>i(e,t,c)}),De.interactionHandles);break;case"video":this.addHandles(S(()=>{const{footprintExtent:e,videoElement:t,bestFeatureFootprint:i}=this;if(e&&t?.loaded&&i)return{videoExtent:Se,bestFeatureFootprint:i}},e=>{e?.videoExtent&&e?.bestFeatureFootprint&&(g(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,c)&&e?.bestFeatureFootprint===t?.bestFeatureFootprint}),De.interactionHandles);break;case"panoramic":this.addHandles(S(()=>{const{currentBestFeature:e,state:t,_panoramicViewer:i}=this,{imageSize:a,vfov:r,hfov:o,pitch:s,yaw:n}=i;return e&&a&&!t.includes("loading")&&null!=r&&null!=o&&null!=s&&null!=n?[r,o,n,s]:null},e=>{if(!e||this.state.includes("loading"))return;const[t,i,a,o]=e;this.currentNode&&(this.currentNode.currentHeading=a,this.currentNode.currentPitch=o),g(this._updateFootprintTask),this._updateFootprintTask=r(async e=>{await this.updateFootprintPanorama({verticalFieldOfView:t,horizontalFieldOfView:i,yaw:a,pitch:o},{signal:e}),this._updateFootprintTask=null})},{equals:(e,t)=>i(e,t,c)}),De.interactionHandles);break;case"panoramic-video":this.addHandles(S(()=>{const{currentBestFeature:e,state:t,_panoramicVideoViewer:i}=this,{imageSize:a,vfov:r,hfov:o,pitch:s,yaw:n,viewModel:l}=i,d=l.closestFeature??e;return d&&a&&!t.includes("loading")&&null!=r&&null!=o&&null!=s&&null!=n?[r,o,n,s,d]:null},e=>{if(!e)return;const[t,i,a,o,s]=e;g(this._updateFootprintTask),this._updateFootprintTask=r(async e=>{await this.updateFootprintPanorama({verticalFieldOfView:t,horizontalFieldOfView:i,yaw:a,pitch:o,feature:s,horizonAngles:this._panoramicVideoViewer.horizonAngles},{signal:e}),f(e),this._updateFootprintTask=null})},{equals:(e,t)=>i(e,t,c)}),De.interactionHandles)}},b),S(()=>[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),S(()=>this.activeViewer?.imageRenderer,()=>{this.sketch&&(this.sketch.view=this.activeViewer?.imageRenderer)}),S(()=>this.activeViewer,e=>{this.removeHandles(De.hittestHandles),e&&this.addHandles(V(()=>e,"hittest-response",this._handleImageHitTestResponse),De.hittestHandles)}),S(()=>this.videoMapView.extent,async()=>{this._scheduleVideoInteractionUpdate();const e=this.videoViewModel?.closestFeature;e&&(g(this._updateFootprintTask),this._updateFootprintTask=r(async t=>{const i={points:this.videoExtentPoints,feature:e,options:{signal:t}};await this.updateVideoFootprint(i)}))}),S(()=>[this.videoMapView.interacting,this.videoMapView.navigating,this.videoMapView.scale],()=>{this._scheduleVideoInteractionUpdate()},{initial:!0}),P(()=>null!=this.videoMapView.extent,()=>{this.initialVideoMapViewExtent=this.videoMapView.extent},{once:!0})]),this.when().finally(()=>{this.notifyChange("state")})}destroy(){this._adapter?.disableDefaultSuperimposeNavigation?.(),this._adapter?.disablePanoramicSuperimposeNavigation?.(),this._abortSuperimposeSchedule(),this.currentBestFeature=null,this._updateFootprintTask=g(this._updateFootprintTask),this._clickTask=g(this._clickTask),this._navigationViewStateTask=g(this._navigationViewStateTask),this._restoreSuperimposeMediaTask=g(this._restoreSuperimposeMediaTask),this.coverageFrustums.destroy(),this.coveragePolygons.destroy(),this.pointSources.destroy(),this.additionalFootprints.destroy(),this.additionalCameraLocations.destroy(),this.bestFeatureFootprint=m(this.bestFeatureFootprint),this.bestFeatureCurrentFootprint=m(this.bestFeatureCurrentFootprint),this.videoViewModel=m(this.videoViewModel),this._locationViewModel=m(this._locationViewModel),this.clearSelectedPointOnViewer(),this._referencePointOnGround=m(this._referencePointOnGround),this.clearReferencePointOnImage(),this._superimposeService.destroy(),this._overlays&&this.view?.map?.remove(this._overlays),this._overlays.destroy(),this._imageViewer.destroy(),this.imageMeasurementViewer.destroy(),this._panoramicViewer.destroy(),this._panoramicMeasurementViewer.destroy(),this._mediaPrefetcher?.destroy()}get activeLayer(){return s(h.getLogger(this),"activeLayer",{replacement:"layer"}),this.layer}set activeLayer(e){s(h.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!ze(this.currentBestFeature.attributes.depthImage)}get featureCount(){return this.features?.length??0}get hasPendingPanoramicNavigationViewState(){return null!=this._pendingPanoramicNavigationViewState}get imageGalleryEnabled(){const{currentBestFeature:e}=this;if(!e)return!1;const t=e.attributes.imagePath?.trim();return ze(t)||Ce(t)}get imageLoaded(){return s(h.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===be}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(Ue(e))}get layerFloorFilterClause(){const{layerView:e}=this;return e?ce(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 overlayGraphicsEnabled(){const{mode:e,state:t,panoramicVideoLoaded:i,videoViewModel:a,panoramicVideoPaused:r}=this;return"image-loaded"===t||"video"===e&&"video-loaded"===t&&!0===a?.videoPaused||"panoramic-video"===e&&i&&r}get panoramicVideoPaused(){return!!this._panoramicVideoViewer.viewModel.videoPaused}get popupEnabled(){return!0===this.layer?.popupEnabled}get referencePoint(){return this._referencePointOnGround?.geometry}get sectorData(){const{_sectorData:e}=this;return e?Me.map(t=>e[t]):null}get sharpness(){return this._get("sharpness")??0}set sharpness(e){this._set("sharpness",u(e,0,1))}get superimposeViewSupported(){return"default"===this.mode||"panoramic"===this.mode}get sketchGraphicsLayer(){const{sketch:e}=this;return"graphics"===e?.layer?.type?e.layer:void 0}get state(){const{mode:e,_updatingHandles:{updating:t},_featureChangedTask:i,_navigationManager:a}=this;if(!this.isFulfilled()||t||!1===i?.finished||a?.navigating)return"loading";if(this.isRejected())return"error";if("error"===this.displayMessage?.type)return"image-load-error";switch(e){case"default":return this._imageViewer.state;case"panoramic":return this._panoramicViewer.state;case"video":return this.videoElement?.loaded?"video-loaded":"video-not-loaded"}return"ready"}get thumbnails(){const{features:e}=this;return e?new o(e.map(({attributes:{imagePath:e,objectId:t,cameraRoll:i,imageRotation:a}})=>{const r=e?.trim();return ze(r)||Ce(r)?{url:r,objectId:t,rotation:(i??0)+(a??0)}:null}).filter(a)):null}get videoExtentPoints(){const e=tt(this.videoMapView.extent);return e.length?e:Se}set view(e){this._set("view",e)}get _defaultGraphicsLayer(){const e={blendMode:"source-atop"};switch(this.mode){case"panoramic":return new N({...e,elevationInfo:{mode:"absolute-height"}});case"default":return new N({...e});default:return}}get _overlaysView(){return this.view?.layerViews.find(({layer:e})=>e===this._overlays)}updatePanoramicSuperimposeRadiusOffset(e){this._superimposeService.updatePanoramicRadiusOffset(e)}setDefaultSuperimposeZOffsetPercentage(e){this._superimposeService.setDefaultZOffsetPercentage(e)}setPanoramicSuperimposeRadiusPercentage(e){this._superimposeService.setPanoramicRadiusPercentage(e)}updateDefaultSuperimposeCameraLock(e){this.defaultSuperimposeCameraLockEnabled=e,this.superimposeViewEnabled&&"default"===this.mode&&(e?this._adapter?.enableDefaultSuperimposeNavigation?.():this._adapter?.disableDefaultSuperimposeNavigation?.())}beforeLoad(e=!0){this.emit("popup-close"),e&&(this.displayMessage=null),this._pendingDefaultNavigationViewState=null,this._pendingPanoramicNavigationViewState=null,this._abortSuperimposeSchedule(),this._adapter?.disableDefaultSuperimposeNavigation?.(),this._adapter?.disablePanoramicSuperimposeNavigation?.(),this.clearPreviousGroundLocation(),this.triangularMeasurementActive=!1,this.currentBestFeatureMeasurementImage=null,this.measureType=null,this.imageLocationToolState=!1,this.features.removeAll(),this.currentBestFeature=null,this.additionalFeatures.removeAll(),this.additionalFootprints.removeAll(),this.additionalCameraLocations.removeAll(),this.bestFeatureCurrentFootprint=m(this.bestFeatureCurrentFootprint),this._restoreSuperimposeMediaTask=g(this._restoreSuperimposeMediaTask),this._superimposeService.clear(),this._overlays?.removeAll()}async calculateLocationAccuracy(e){return this._measurementService?.calculateLocationAccuracy(e)}clearLocationPointOnImage(e=!1){this.locationPointOnImage&&!e&&(this._imageViewer.removeGraphic(this.locationPointOnImage),this._panoramicViewer.removeGraphic(this.locationPointOnImage),this.locationPointOnImage=m(this.locationPointOnImage)),this.correctedLocationPointOnImage&&(this.imageMeasurementViewer.removeGraphic(this.correctedLocationPointOnImage),this._panoramicMeasurementViewer.removeGraphic(this.correctedLocationPointOnImage),this.correctedLocationPointOnImage=m(this.correctedLocationPointOnImage))}clearPreviousMeasurements(){this.clearMeasurementGraphics(),this.resetMeasurementData(),this.stopMeasurement()}clearPreviousGroundLocation(){this.groundCoordinates=null,this.groundCoordinatesAccuracy=null,this.groundCoordinatesAccuracyLoading=!1,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 Ft();ht(a,e,i),await i.create(e,{...t,defaultZ:0})}digitizeDelete(){if(!this.sketch)throw Ft();return this.sketch.delete()}digitizeDuplicate(){if(!this.sketch)throw Ft();return this.sketch.duplicate()}digitizePlace(e,t){if(!this.sketch)throw Ft();return this.sketch.place(e,t)}digitizeRedo(){if(!this.sketch)throw Ft();return this.sketch.redo()}digitizeUndo(){if(!this.sketch)throw Ft();return this.sketch.undo()}digitizeUpdate(e,t){if(!this.sketch)throw Ft();return this.sketch.update(e,t)}filterByFootprints(e,t,i=!1){const a=[],r=[],o=[];return e.forEach(e=>{const{layer:{coveragePercent:s},attributes:n}=e;let l;const{polygon:d,frustum:c}=W(n);if(l=d.clone(),n.isInspection&&(l=$(n)),s&&(l=Z(l,s)),i||!t||J(l,t)){o.push(e);const{geometry:t,objectId:i,cameraHeight:s,cameraHeading:l}=n,h=t.clone();h.z=s/Q(t.spatialReference),h.imageID=i,this.pointSources.push(h),l!==be&&(a.push(d),c&&r.push(c))}}),{features:o,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,outFields:[t.objectIdField]}).then(({features:e})=>t.applyEdits({deleteFeatures:e}))}handleSectorClick(e){if(isNaN(e))return;const t=this._sectorData?.[Me[e]],i=t?.at(0);i&&(this.triangularMeasurementActive&&this.currentBestFeature?this._updateImageMeasurementBestFeature(i):this._scheduleCurrentBestFeatureUpdate(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._scheduleCurrentBestFeatureUpdate(r))}load(e){return this.addResolvingPromise(this._loadViewAdapter(e).catch(e=>{if(!y(e))throw e})),this}async loadBestImage(e,t){return this.selectedPoint=X(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(f(e),this.drawAdapter=new i({viewModel:this,measurementService:this._measurementService}),!this.drawAdapter.viewModel.isResolved())return}return this.drawAdapter}loadImageError(e){h.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;f(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(f(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:o,frustums:s}=this.filterByFootprints(a,t,i?.skipFilter);if(!this._checkFeatures(r))return;this.coveragePolygons.addMany(o),this.coverageFrustums.addMany(s);const n=await this.processElevationSample(o,r,i);f(i),await this._updateElevationOfSelectedPointAndLocations(r,t,n),f(i),qe(r,n);let l=r;if(this.layer?.verticalSearchRange&&this.layer.hasZ&&this.verticalFilterEnabled&&(l=We(r,t,this.layer.verticalSearchRange),!l.length))return void this.setMessage("noImageAtElevation","info");const d=this._processSuitableFeatures(l,t);this.updateSuitabilities(d,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 o=await this.processElevationSample(r,a,i);return f(i),o}async startMeasurement(e,t){this.sketch||await this.loadSketch(t),await this.loadMeasurementAdapter(t);const{sketch:i,sketchAdapter:a,activeViewer:r,mode:o}=this;if(!i||!a||!r||"none"===o)return;if(this.displayNewMeasurementButton=!1,"panoramic"===o&&(i.defaultCreateOptions.defaultZ=0),await i.create(e),"panoramic"===o){const{drawOperation:e}=i.view.activeTool;e.constraintsEnabled=!1,e._set("elevationDrawSurface",null)}const s=this.activeViewer?.imageRenderer.effectiveTheme.accentColor;s&&this.sketch&&(this.sketch.polygonSymbol=Te(s),this.sketch.polylineSymbol="panoramic"===o?Oe:Le(s,2.5))}async startHeightMeasurement(){this.displayNewMeasurementButton=!1,this.draw??=new pe({view:this.activeViewer?.imageRenderer}),this.polylineDrawAction=this.draw.create("polyline"),await this.loadHeightMeasurementAdapter()}initializeMeasurement(e){switch(this.clearMeasurementGraphics(),this.resetMeasurementData(),e){case"distance":this.startMeasurement("polyline");break;case"area":this.startMeasurement("polygon");break;case"height":this.startHeightMeasurement()}}async overlayCameraLocations(e){const{activeViewer:i,overlayedCameraLocations:r,layer:o,mode:s,layerFloorFilterClause:n,layerTimeExtent:l,videoViewModel:d,_panoramicVideoViewer:c}=this,h="video"===s,u="panoramic-video"===s,p=this._getActiveFeatureForCurrentMode(),m=this._computeOverlayImageSize();if(!(m&&p&&o&&"none"!==s&&this.overlayGraphicsEnabled))return;const{polygon:g}=W(p.attributes);if(h?d?.removeOverlayGraphics(r.toArray()):u?c.removeManyGraphics(r.toArray()):i?.removeManyGraphics(r.toArray()),r.removeAll(),e){const{features:e}=await o.queryFeatures({where:I(`${o.objectIdField} <> ${p.attributes.objectId}`,I(o.definitionExpression,n)),geometry:g,returnGeometry:!0,outFields:[o.objectIdField],timeExtent:l}),v=await Promise.all(e.map(async e=>{const{attributes:i,geometry:a}=e;if("point"!==a?.type)return null;const r=await this._geometryToOverlayImageGeometry(a,p,m);if(!r)return null;const o="panoramic"===s||"panoramic-video"===s?Ee():Ge();return new t({attributes:i,symbol:o,geometry:r})}));r.addMany(v.filter(a)),h?d?.addOverlayGraphics(r.toArray()):u?c.addManyGraphics(r.toArray()):i?.addManyGraphics(r.toArray())}}overlayGraphicsOnImage(e,t){this.removeOverlayedGraphicsOnImage(e),this.overlayedMapFeatures.set(e,t),"video"!==this.mode?"panoramic-video"!==this.mode?this.activeViewer?.addManyGraphics(t.toArray()):this._panoramicVideoViewer.addManyGraphics(t.toArray()):this.videoViewModel?.addOverlayGraphics(t.toArray())}async overlayMapFeatures(e,i=!1){const{activeViewer:r,mode:s,layer:n,videoViewModel:l,_panoramicVideoViewer:d}=this,c="video"===s,u="panoramic-video"===s,p=this._getActiveFeatureForCurrentMode(),m=this._computeOverlayImageSize();if(!(m&&p&&"none"!==s&&this.overlayGraphicsEnabled&&n))return;const{polygon:g}=W(p.attributes);try{const{imageGeometryField:t,oiObjectIdField:i}=ut(e,n.imageGeometryField,n.imageReferenceField);this.imageGeometryField=t.name,this.oiObjectIdField=i.name}catch(w){h.getLogger(this).warn("oriented-imagery-viewer:overlay-map-features",w)}const{features:v}=await e.queryFeatures({geometry:g,returnGeometry:!0,outFields:["*"]}),y=await Promise.all(v.map(async a=>{const o=a.symbol?.clone()??e.renderer?.getSymbol(a)?.clone(),{attributes:n,geometry:g}=a,{imageGeometryField:v,oiObjectIdField:y}=this;if(v&&y&&_t(e,v,y)&&`${n[y]}`==`${p.attributes.objectId}`)try{const a=u?d.horizonAngles:He(r?.media),h=pt(n,v,e,i,m,c?"default":s,o,a);if(!c)return h;const p=h.geometry;if(!p)return null;const g=l?.imageGeometryToOverlayGeometry(p);return g?new t({attributes:n,layer:e,symbol:h.symbol,geometry:g,visible:h.visible}):null}catch(w){h.getLogger(this).warn("oriented-imagery-viewer:overlay-map-features","couldn't create graphic from attributes, geometry will be used",{error:w,feature:a,layer:e,imageGeometryField:this.imageGeometryField,imageReferenceField:this.oiObjectIdField})}if(!g)return null;const f={feature:p,imageSize:m,footprintExtent:this.footprintExtent},_=await this._geometryToOverlayImageGeometry(g,f.feature,f.imageSize);return _?new t({attributes:n,layer:e,symbol:o,geometry:_,visible:e.visible&&i}):null})),f=new o(y.filter(a));("video"!==s&&"panoramic-video"!==s||this.overlayGraphicsEnabled)&&this.overlayGraphicsOnImage(`${e.id}`,f)}getDepthAt(e){const{activeViewer:t,currentBestFeature:i,mode:a,state:r,depthImage:o}=this,s=t?.imageSize;if(!s||!i||"none"===a||r.includes("loading"))return h.getLogger(this).warnOnce("oriented-imagery-viewer:get-depth-at","Load an image to use depth"),null;if(!o?.loaded)return h.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=>o.depthAt(e,{width:s[0],height:s[1]})??null);return Array.isArray(e)?n:n[0]}getActiveSectors(){return Me.filter(e=>this._sectorData?.[e]?.length)}async getPixelLocationForFeature(e,t,i){return(await this._transformationService.pointToPixelForFeature([e],t,i))[0]}async getPixelLocationsForFeature(e,t,i){return await this._transformationService.pointToPixelForFeature(e,t,i)}async _getMapPointInViewSpatialReference(e,t){const i=await this.getMapPoint(e,t),a=this.view?.spatialReference;return await G(i,a,t)}async plotMapPoint(e){this.plotReferencePoint(e);const t=this._getActiveFeatureForCurrentMode();if(t)return this.transformAndPlotReferencePointOnImage({feature:t,selectedLocation:e,options:{signal:this._transformController?.signal}})}plotReferencePointOnGround(e){this._referencePointOnGround&&(this._overlays?.remove(this._referencePointOnGround),this._referencePointOnGround.destroy()),null!=e&&(this._referencePointOnGround=new t({geometry:new E({...e.toJSON()}),symbol:je}),this.view?this._overlays?.add(this._referencePointOnGround):this.emit("plot-ground-point",{data:{point:this._referencePointOnGround?.geometry}}))}plotReferencePointOnImage(e){switch(this.mode){case"video":return void this._plotReferencePointOnVideo(e);case"panoramic-video":return void this._plotReferencePointOnPanoramicVideo(e);case"default":return void this._plotReferencePointOnDefaultImage(e);case"panoramic":return void this._plotReferencePointOnPanoramicImage(e)}}removeAllOverlayMapFeatures(){const{mode:e}=this;this.overlayedMapFeatures.forEach(t=>{const i=t.toArray();switch(e){case"video":this.videoViewModel?.removeOverlayGraphics(i);break;case"panoramic-video":this._panoramicVideoViewer.removeManyGraphics(i);break;default:this.activeViewer?.removeManyGraphics(i)}}),this.overlayedMapFeatures.clear()}removeOverlayedGraphicsOnImage(e){const t=this.overlayedMapFeatures.get(e),{mode:i}=this;if(!t?.length)return;const a=t.toArray();switch(i){case"video":this.videoViewModel?.removeOverlayGraphics(a);break;case"panoramic-video":this._panoramicVideoViewer.removeManyGraphics(a);break;default:this.activeViewer?.removeManyGraphics(a)}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=g(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),o=r?.toArray();if(!r||!o?.length)return;const{addFeatureResults:s}=await this.saveDataCaptureFeatures(o),n=s.reduce((t,{objectId:i,globalId:a,error:r},s)=>{const n=o[s],{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:o,mode:s}=this,l=i?.imageSize;if(!l||!r||"none"===s||"video"===s||"panoramic-video"===s)throw new n("orientedimageryviewer:missing-input","Image size, current best feature and mode are required to save data capture features");if(!o)throw new n("orientedimageryviewer:missing-featurelayer","Data capture layer is not available");const d=await Promise.all(e.map(async e=>{const i=e.clone(),{geometry:a}=i;if(!a)return;const r=a.type,s=o.hasZ,n=o.geometryType,l=r!==n,d=l?await(import("./transformers.js")):null,c=d?.default[n],h=l?c?.(a):a;return h&&(i.geometry=await this._transformationService.imageGeometryToMapGeometry(h,t),i.geometry)?(s||mt(i.geometry),i):void 0})),c=d.filter(a);return o.applyEdits({addFeatures:c}).then(e=>{const{addFeatureResults:t}=e;let i=0;const a=d.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),h.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 restorePendingPanoramicNavigationViewState(e){const t=this._pendingPanoramicNavigationViewState;this._pendingPanoramicNavigationViewState=null,"panoramic"===this.mode&&await this._restoreNavigationViewState(t,e)}async startDataCapture(e,t){const i=this.activeViewer?.imageRenderer,{oiObjectIdField:a,currentBestFeature:r}=this;if(!i||!r||!a)return;const{attributes:{objectId:s}}=r,n=this.overlayedMapFeatures.get(e.id)?.toArray()??[],l=[],d=[];for(const o of n)`${o.getAttribute(a)}`==`${s}`?l.push(o):d.push(o);this.overlayGraphicsOnImage(e.id,new o(d)),this.collectionId=e.id;const c=await this.loadSketch(t),h=await this.loadDataCaptureAdapter(t);f(t),c.addGraphics(l),h.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=m(this.sketchAdapter),this.sketch=m(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{feature:t,selectedLocation:i,options:a}=e;let r=!1,o=!1;const s="video"===this.mode?this.bestFeatureCurrentFootprint?.geometry:this.bestFeatureFootprint?.geometry;switch(s?.type){case"polygon":{const e=i.spatialReference.equals(s.spatialReference)?i:await G(i,s.spatialReference);r=s.contains(e);break}case"mesh":{const e=i.spatialReference.equals(s.spatialReference)?i:await G(i,s.spatialReference);o=s.extent.contains(e);break}}if(!r&&!o)return void this.clearReferencePointOnImage();const n="video"===this.mode||"panoramic-video"===this.mode?await this.getPixelLocationForFeature(i,{feature:t,mode:this.mode,imageSize:_e,footprintExtent:this.footprintExtent},a):await this._transformationService.pointToPixel(i,a);if(n)return f(a),this.plotReferencePointOnImage(n),{x:n.x,y:n.y};this.clearReferencePointOnImage()}async updateFeatureCache(e,t){const i=await U(e,t);i.features?.length&&(this.featureCache=i.features)}_plotReferencePointOnVideo(e){"video-loaded"===this.state&&this.videoViewModel?.videoPaused&&(this.clearReferencePointOnImage(),this.videoViewModel.plotReferencePointOnVideo(e))}_plotReferencePointOnPanoramicVideo(e){const i=this._panoramicVideoViewer,{imageSize:a,media:r}=i.viewModel;if(!this.panoramicVideoLoaded||!this.panoramicVideoPaused||!a)return;this.clearReferencePointOnImage();const o=He(r),s=gt(e,"panoramic",a,o);this._referencePointOnImage=new t({geometry:s,symbol:Re.clone()}),i.addGraphic(this._referencePointOnImage,0)}_getActiveFeatureForCurrentMode(){switch(this.mode){case"video":return this.videoViewModel?.closestFeature??this.currentBestFeature;case"panoramic-video":return this._panoramicVideoViewer.viewModel.closestFeature??this.currentBestFeature;default:return this.currentBestFeature}}_plotReferencePointOnDefaultImage(e){const i=this._imageViewer,{imageSize:a}=i;if("image-loaded"!==this.state||!a)return;this.clearReferencePointOnImage();const r=gt(e,"default",a);this._referencePointOnImage=new t({geometry:r,symbol:je.clone()}),i.addGraphic(this._referencePointOnImage,0)}_plotReferencePointOnPanoramicImage(e){const i=this._panoramicViewer,{imageSize:a,media:r}=i;if("image-loaded"!==this.state||!a)return;this.clearReferencePointOnImage();const o=He(r),s=gt(e,"panoramic",a,o);this._referencePointOnImage=new t({geometry:s,symbol:Re.clone()}),i.addGraphic(this._referencePointOnImage,0)}async _fetchFeatures(e,t){const{layer:i,layerFloorFilterClause:a,layerTimeExtent:r,view:o}=this;if(!o)return;if(!i)return void this.setMessage("noLayerSelected","info");e.x=B(e.x,e.spatialReference);const s=i.spatialReference.equals(e.spatialReference)?e:await G(e,i.spatialReference),n=s.spatialReference.isGeographic?D(s):s,l=I("1=1",I(i.definitionExpression,a)),d=n.spatialReference.isGeographic?1:C(n.spatialReference),c={layerInstanceOrURL:i,point:n,queryParams:{where:l,maximumDistance:i.maximumDistance?i.maximumDistance/d:void 0,timeExtent:r}};return await this.searchBestImage(c,t)}async _fetchFeaturesWithController(e,t){try{await this._fetchFeatures(e,t)}catch(i){if(y(i))return;this.setMessage("imageLoadError","error"),h.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 s={};this._featureToSector=s;for(const c of Me)this._sectorData[c]=new o;const n=e.map((e,t)=>({...e,featureIndex:t}));n.sort((e,t)=>e.trueSuitability-t.trueSuitability);const l=n.map(({distance:e})=>e),d=Math.max(...l);n.forEach(e=>{const{distance:t,angle:a,featureIndex:o}=e,n=t/d*Ie[2],l=Qe(t,d),c=Xe(a);if(!this._sectorData)return;const h=Ie[3]+n*Math.sin(a*Math.PI/180),u=Ie[3]+n*Math.cos(a*Math.PI/180);let p;const m=i.at(o),g=m===r,{cameraPitch:v}=m.attributes,y=v<5;if(g&&y)p=-90;else{const e=h-Ie[3],t=u-Ie[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?c:`${l}_${c}`;g&&(p===this.bestFeatureAngle?this.previousFeatureAngle=p:this.bestFeatureAngle=p,this.navigatorCurrentBestFeature=y?null:{x:h,y:u,direction:c}),s[`${m.attributes.objectId}`]=f;const w=this._sectorData[f];w.add({angle:a,featureIndex:o,x:h,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;f(e),this._locationViewModel=new i({oiViewModel:this,referenceTransformationService:this._referenceTransformationService})}}_initializeMeasurementService(){this._measurementService||(this._measurementService=new dt({transformationService:this._transformationService,referenceTransformationService:this._referenceTransformationService}))}_initializeVideo(){if(this.videoElement||!this.currentBestFeature)return;this.removeHandles(De.videoPlayerHandles),this.videoElement=new he({video:this.currentBestFeature.attributes.imagePath,georeference:new de({extent:new L(Pe)}),autoplay:!1}),this.videoElement.content?.loop&&(this.videoElement.content.loop=!1);const e=new H({source:this.videoElement,title:this.layer?.title,copyright:this.layer?.copyright});this.videoLayer=e,e&&this.videoMapView.map.layers.add(e),this.videoViewModel=new st({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=$e(a);try{await r.load(t)}catch(s){if(y(s))return;if("unsupported-format"===s.name)return void this.setMessage("unsupportedPanoramicImageryError","error",void 0,{datasetFormat:r?.extension??"UNKNOWN FORMAT"})}const o=this.triangularMeasurementActive?this._panoramicMeasurementViewer:this._panoramicViewer;await o.loadMedia(r,t),i&&o.set(i)}async loadMediaSource(e,t){const i=Ze(e);await this._setImageSource(this.triangularMeasurementActive?this.imageMeasurementViewer:this._imageViewer,i,t)}_clearFeatureGeometries(){this.coveragePolygons.removeAll(),this.coverageFrustums.removeAll(),this.pointSources.removeAll()}_checkFeatures(e){return!!e?.length||(this.emit("no-image-found"),this.setMessage("noImageError","error"),this.videoElement?.content?.pause(),this.currentBestFeature=null,!1)}async _getElevationSampleFromGround(e,t,i){if(!e[0])return;const{unionExecuteMany:a}=await(import("../../geometry/operators/unionOperator.js")),r=a(e);if(this._updateFootprintWithFeatures(t,r),"3d"===this.view?.type)try{return await this.view.map.ground.createElevationSampler(this.footprintExtent,i)}catch(o){y(o)||h.getLogger(this).error(o)}}async processElevationSample(e,t,i){const{elevationSource:a}=t[0].attributes,r=await this._getElevationSampleFromGround(e,t,i);return r||(a&&this.footprintExtent&&K(a)?await ee({extent:this.footprintExtent,lod:a.lod,url:a.url,rasterFunction:a.rasterFunction}):void 0)}_processSuitableFeatures(e,t){return q({features:e,selectedPoint:t,camera:Je(this.view)?this.view.camera:null,currentImage:this.currentBestFeature})}async _processHitTestResults(e,t,i){const{results:[a]}=t;if("graphic"!==a?.type)return this.beforeLoad(!1),this.emit("no-image-found"),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:o}=await lt(e,t,i,a,r);if(f(r),!o?.features?.length)throw new nt(t);const{attributes:s}=o.features[0];let n,l;if(s.orientedImageryType?.includes("360")){n=X(s.geometry);const{cameraHeading:e,farDistance:t,nearDistance:i}=s,a=[Math.sin(p(e)),Math.cos(p(e))],r=(t+i)/2;l=C(n.spatialReference),n.x+=r*a[0]/l,n.y+=r*a[1]/l,n.z=void 0}else{const e=W(s).polygon,t=E.fromJSON(R(e));n=X(t),l=C(n.spatialReference)}this.selectedPoint=n;const d={layerInstanceOrURL:e,point:n,queryParams:{where:I(I("1=1",I(e.definitionExpression,i)),`${e.objectIdField} <> ${t}`),maximumDistance:e.maximumDistance?e.maximumDistance/l:void 0,timeExtent:a}},c=await z(d,r);f(r);const{features:h}=c;return h.push(o.features[0]),await this.processFeatureResponse(c,n,{...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)}async _restoreNavigationViewState(e,t){const i=e?.center?await this._transformationService.pointToPixel(e.center,t):null;if(f(t),"panoramic"===this.mode){const t=He(this._panoramicViewer.media);if(!t)return;yt({viewState:e,panoramicViewer:this._panoramicViewer,horizonAngles:t,imageCenter:i})}ft({viewState:e,imageViewer:this._imageViewer,imageCenter:i})}_toggleVisiblity(e,t){e.forEach(e=>{e.visible=t})}async _updateElevationOfSelectedPointAndLocations(e,t,i,a){const{location:r,cameraHeight:o}=e[0].attributes,s=await re(r.spatialReference,r.z,o,{elevationSample:i,elevationSource:i?void 0:e[0].attributes.elevationSource,extent:this.footprintExtent},a);f(a);const[n,...l]=await Y([t,...e.map(e=>e.attributes.geometry.clone())],s);f(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:o}=i;return new ot({geometry:t,attributes:i,currentHeading:a?0:r,currentPitch:a?0:o})})),e.length>1?this.additionalFeatures.addMany(e.slice(1)):this.additionalFeatures.removeAll(),this._updateGroundElevation=!0,t&&(this.currentBestFeature=e[0])}_updateFootprintWithFeatures(e,t){const i=[];for(const{attributes:{geometry:a}}of e)t.contains(a)||i.push([a.x,a.y]);i.sort((e,t)=>+x([e,t])),t.addRing(i),this.footprintExtent=me(t.extent,2,2)}_scheduleVideoInteractionUpdate(){this.scheduledFrameId||(this.scheduledFrameId=requestAnimationFrame(()=>{this.scheduledFrameId=null,this._updateInteraction()}))}async _updatePointsAndPolygons(e){const{pointSources:i,currentBestFeature:a,currentCoverageVisible:r,isAdditionalPointSourcesVisible:o,mode:s,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)),f(e);for(const s of i){const i=this.view&&!this.view.spatialReference?.equals(s.spatialReference)?await G(s.clone(),this.view?.spatialReference,e):s.clone();s.imageID===a.attributes.objectId?this.currentBestFeatureLocation=new t({attributes:{imageID:s.imageID},geometry:i,symbol:xe,visible:r}):this.additionalCameraLocations.push(new t({attributes:{imageID:s.imageID},geometry:i,symbol:Be,visible:o}))}"video"!==s&&"panoramic-video"!==s||(await this.initializeTransformationService(e),n&&!this.featureCache.length&&await this.updateFeatureCache(n,a.geometry.spatialReference))}}_scheduleCurrentBestFeatureUpdate(e){g(this._navigationViewStateTask);const t=r(async t=>{await this._updateCurrentBestFeature(e,{signal:t})});this._navigationViewStateTask=t,t.promise.catch(e=>{if(!y(e))throw e}).finally(()=>{this._navigationViewStateTask===t&&(this._navigationViewStateTask=null)})}async _updateCurrentBestFeature(e,t){if(!e)return;if(await this._capturePendingNavigationViewState(t),f(t),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 i=this.currentBestFeature?.attributes.cameraPitch&&this.currentBestFeature?.attributes.cameraPitch<5;let a;if(i)a=-90;else{const t=e.x-Ie[3],i=e.y-Ie[3],r=i/Math.sqrt(t**2+i**2);let o=180*Math.acos(r)/Math.PI;(t<0&&i<0||t<0&&i>0)&&(o*=-1),a=o}a===this.bestFeatureAngle?this.previousFeatureAngle=a:this.bestFeatureAngle=a,this.navigatorCurrentBestFeature=i?null:{x:e.x,y:e.y,direction:e.sector.includes("_")?e.sector.split("_")[1]:e.sector},"panoramic"===this.mode&&(await F(()=>"image-loaded"===this.state,t),f(t),await this.restorePendingPanoramicNavigationViewState(t))}async _capturePendingNavigationViewState(e){"default"!==this.mode?"panoramic"===this.mode&&await this._capturePendingPanoramicNavigationViewState(e):await this._capturePendingDefaultNavigationViewState(e)}async _capturePendingDefaultNavigationViewState(e){try{const{imageSize:t,imageRenderer:i}=this._imageViewer,a=i.center;if("image-loaded"!==this.state||!t[0]||!t[1]||!a)return void(this._pendingDefaultNavigationViewState=null);const r=vt(a,"default",t),o=await this._getMapPointInViewSpatialReference(r,e);f(e),this._pendingDefaultNavigationViewState={center:o,scale:i.scale}}catch(t){this._handlePendingNavigationViewStateCaptureError(t)}}async _capturePendingPanoramicNavigationViewState(e){const t=He(this._panoramicViewer.media);if(t)try{const{fov:i,imageSize:a,pitch:r,yaw:o}=this._panoramicViewer;if("image-loaded"!==this.state||!a||!i)return void(this._pendingPanoramicNavigationViewState=null);const[s,n]=oe(o,r,t),l=se(s,n,a[0],a[1]),d=await this._getMapPointInViewSpatialReference(l,e);f(e),this._pendingPanoramicNavigationViewState={center:d,fov:i}}catch(i){this._handlePendingNavigationViewStateCaptureError(i)}}_handlePendingNavigationViewStateCaptureError(e){if(y(e))throw e;h.getLogger(this).warn("oriented-imagery-viewer:failed-to-capture-navigation-view-state",e)}_updateImageMeasurementBestFeature(e){e&&(this.currentBestFeatureMeasurementImage=this.features?.at(e.featureIndex))}clearGraphics(){this._imageViewer.clearGraphics(),this._panoramicViewer.clearGraphics(),this.imageMeasurementViewer.clearGraphics(),this._panoramicMeasurementViewer.clearGraphics()}clearReferencePointOnImage(){this._referencePointOnImage&&(this._imageViewer.removeGraphic(this._referencePointOnImage),this._panoramicViewer.removeGraphic(this._referencePointOnImage),this._panoramicVideoViewer.removeGraphic(this._referencePointOnImage),this._referencePointOnImage=m(this._referencePointOnImage)),this.videoViewModel?.clearReferencePointOnVideo()}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:o,elevationSample:s}=t,{location:{spatialReference:n,z:l},cameraHeight:d,elevationSource:c}=o;let h=o.location;h.spatialReference.isGeographic&&(h=X(h));const u="default"===a?ne(o,r[0],r[1]):le(o,r[0],r[1]),p=await re(n,l??0,d,{elevationSample:s,elevationSource:c,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?_e:i?.imageSize;if(!t||!r||"none"===a)return;const{attributes:o,elevationSample:s}=t,{location:{spatialReference:n,z:l},cameraHeight:d,elevationSource:c}=o;let h=o.location;h.spatialReference.isGeographic&&(h=X(h));const u="default"===a||"video"===a?"default":"panoramic",p={..."default"===u?ne(o,r[0],r[1]):le(o,r[0],r[1]),cameraLocation:h},m=await re(n,l??0,d,{elevationSample:s,elevationSource:c,extent:this.footprintExtent},e),g=(await(import("./services/TransformationService.js"))).default,v={imageToWorldProperties:p,updateElevationProps:m,mode:u,imageSize:r,depthImageService:this.depthImage};this._transformationService=new g(v),this._measurementService&&(this._measurementService.transformationService=this._transformationService)}plotReferencePoint(e){"mapPoint"in e?this.plotReferencePointOnGround(e.mapPoint):this.plotReferencePointOnGround(e)}clearSelectedPointOnViewer(){if(this._crossSymbol){if("video"===this.mode)return this.videoViewModel?.clearSelectedPointOnVideo(),void(this._crossSymbol=null);this._panoramicViewer.removeGraphic(this._crossSymbol),this._imageViewer.removeGraphic(this._crossSymbol),this.videoMapView.graphics.remove(this._crossSymbol),this._crossSymbol=m(this._crossSymbol)}else this.videoViewModel?.clearSelectedPointOnVideo()}setMessage(e,t,i,a){this.displayMessage={key:e,type:t,data:i,map:a}}async transformAndPlotSelectedLocation(e){const{invalidCameraHeading:t,selectedPoint:i,activeViewer:a,videoElement:r}=this,o="video"===this.mode?this.videoViewModel?.closestFeature??this.currentBestFeature:this.currentBestFeature;this.clearSelectedPointOnViewer();const s="video"===this.mode?!0===r?.loaded&&!0===this.videoViewModel?.videoPaused:"image-loaded"===a?.state;if(!i||!o||!s||t)return;if("video"===this.mode){if(!await it(i,this.bestFeatureCurrentFootprint?.geometry,e))return}let n;try{if(n="video"===this.mode?await this.getPixelLocationForFeature(i,{feature:o,mode:this.mode,imageSize:_e,footprintExtent:this.footprintExtent},e):await this._transformationService.pointToPixel(i,{signal:e?.signal}),"video"===this.mode&&!at(n))return;f(e),await this.plotSelectedPointOnImage(n,e)}catch(l){y(l)||h.getLogger(this).error("failed to transform map point to pixel, cross symbol will not be plotted on image",{error:l,selectedPoint:i,feature:o})}}updateCurrentCoveragePolygon(e){const{additionalFootprints:i,additionalCameraLocations:a,currentBestFeature:r,currentBestFeatureLocation:o,currentCoverageVisible:s,selectedPoint:n,view:l,_adapter:d,mode:c}=this;if(!r)return;const{attributes:{objectId:h},elevationSample:u}=r;if(this._initialCurrentCoverageUpdate){if(this._overlays?.removeAll(),this._initialCurrentCoverageUpdate=!1,this.bestFeatureCurrentFootprint=m(this.bestFeatureCurrentFootprint),e&&!this.invalidCameraHeading&&(e.visible=s,this.bestFeatureCurrentFootprint=e),l){const e=[...i,...a,o].filter(Ke);"3d"===l?.type&&u&&d?.updateGroundElevation&&(this._updateGroundElevation&&d.updateGroundElevation(e),"panoramic"===c&&this.bestFeatureCurrentFootprint&&d.updateGroundElevation([this.bestFeatureCurrentFootprint])),this._updateGroundElevation=!1,n&&(this.bestFeatureCurrentFootprint&&e.splice(-2,0,this.bestFeatureCurrentFootprint),e.push(new t({geometry:n.clone(),symbol:Ae.clone(),attributes:{imageID:h}}))),this._overlays.graphics.addMany(e)}}else if(l){if(this.invalidCameraHeading)return void this._superimposeService.clear();this.bestFeatureCurrentFootprint&&(this._overlays?.remove(this.bestFeatureCurrentFootprint),this.bestFeatureCurrentFootprint=m(this.bestFeatureCurrentFootprint));const t=this.bestFeatureCurrentFootprint&&this._overlays?this._overlays.graphics.indexOf(this.bestFeatureCurrentFootprint):-1;e&&(this.bestFeatureCurrentFootprint=e,"3d"===l?.type&&u&&d?.updateGroundElevation&&"panoramic"===c&&d.updateGroundElevation([e]),e.visible=this.currentCoverageVisible,this._overlays?.graphics.add(this.bestFeatureCurrentFootprint,t>=0?t:this._overlays.graphics.length-1))}}_updateSuperimposedImage(){if(!this._hasActiveSuperimposeCameraContext())return;const e="panoramic"===this.mode?this._panoramicViewer:null,{currentBestFeature:t,defaultSuperimposeCameraLockEnabled:i,layer:a,mode:r,view:o,state:s,superimposeViewEnabled:n,superimposeViewSupported:l,activeViewer:d,depthImage:c}=this,h=this.coverageFrustums.find(({imageID:e})=>e===t?.attributes.objectId);this._superimposeService.update({activeImageSize:d?.imageSize||void 0,adapter:this._adapter,currentBestFeature:t,currentBestFeatureFrustum:h,defaultSuperimposeCameraLockEnabled:i,depthImageLoaded:c?.loaded??!1,layer:a,mode:r,panoramicCamera:e?.camera,state:s,superimposeViewEnabled:n&&l,view:o}),this.setMessage("superimposeImageDescription","info"),this._superimposePreviousCurrentCoverageVisible??=this.currentCoverageVisible,this.currentCoverageVisible=!1}_getSuperimposeCameraWatchState(){const e="3d"===this.view?.type?this.view:null,t=e?.camera;return[this.superimposeViewEnabled,this.superimposeViewSupported,this.mode,this.state,this.view?.type,this.view?.interacting,this.view?.navigating,t?.heading,t?.tilt,t?.fov,t?.position.x,t?.position.y,t?.position.z]}_handleSuperimposeCameraChange(){const e=this.view,t="3d"===e?.type?e:null;this._hasActiveSuperimposeCameraContext()?"panoramic"!==this.mode?!t||t.interacting||t.navigating?this._abortSuperimposeSchedule():this._scheduleDefaultSuperimposeUpdate():this._schedulePanoramicSuperimposeUpdate():this._abortSuperimposeSchedule()}_shouldDisableUnsupportedSuperimposeView(){return this.superimposeViewEnabled&&"panoramic"===this.mode&&!this.superimposeViewSupported}_hasActiveSuperimposeCameraContext(){return("default"===this.mode||"panoramic"===this.mode)&&this.superimposeViewEnabled&&this.superimposeViewSupported&&"image-loaded"===this.state&&"3d"===this.view?.type&&!!this.view.camera}_abortSuperimposeSchedule(){this._superimposeScheduleController?.abort(),this._superimposeScheduleController=null,this._clearSuperimposeDebounceTimeout(),this._clearSuperimposeScheduledFrame()}_resetInactiveSuperimposeState(){const e=null!=this._superimposePreviousCurrentCoverageVisible;this._abortSuperimposeSchedule(),this._adapter?.disableDefaultSuperimposeNavigation?.(),this._adapter?.disablePanoramicSuperimposeNavigation?.(),this._superimposeService.clear(),this._restoreCurrentCoverageVisibilityAfterSuperimpose(),this._restoreDefaultMessageAfterSuperimpose(),e&&this._restoreViewerMediaAfterSuperimpose()}_restoreCurrentCoverageVisibilityAfterSuperimpose(){null!=this._superimposePreviousCurrentCoverageVisible&&(this.currentCoverageVisible=this._superimposePreviousCurrentCoverageVisible,this._superimposePreviousCurrentCoverageVisible=null)}_restoreViewerMediaAfterSuperimpose(){const{currentBestFeature:e,mode:t}=this;if(!e||"default"!==t&&"panoramic"!==t)return;this._restoreSuperimposeMediaTask?.abort();const i=r(async t=>{await this._loadCurrentFeatureMedia(e,{signal:t})});this._restoreSuperimposeMediaTask=i,i.promise.finally(()=>{this._restoreSuperimposeMediaTask===i&&(this._restoreSuperimposeMediaTask=null)})}_restoreDefaultMessageAfterSuperimpose(){if("superimposeImageDescription"===this.displayMessage?.key){!!this.currentBestFeature&&("default"===this.mode||"panoramic"===this.mode)?this.displayMessage=null:this.setMessage("onLoadMessage","info")}}_clearSuperimposeDebounceTimeout(){null!=this.superimposeDebounceTimeoutId&&(clearTimeout(this.superimposeDebounceTimeoutId),this.superimposeDebounceTimeoutId=null)}_clearSuperimposeScheduledFrame(){null!=this.superimposeScheduledFrameId&&(cancelAnimationFrame(this.superimposeScheduledFrameId),this.superimposeScheduledFrameId=null)}_schedulePanoramicSuperimposeUpdate(){this._abortSuperimposeSchedule(),this.superimposeDebounceTimeoutId=window.setTimeout(()=>{this.superimposeDebounceTimeoutId=null,this._hasActiveSuperimposeCameraContext()&&"panoramic"===this.mode&&this._updateSuperimposedImage()},150)}_scheduleDefaultSuperimposeUpdate(){const e=this.view;if(!("3d"===e?.type?e:null))return;if(this.superimposeScheduledFrameId)return;this._superimposeScheduleController?.abort();const t=new AbortController,{signal:i}=t,a=()=>{this._clearSuperimposeDebounceTimeout(),this._clearSuperimposeScheduledFrame(),this._superimposeScheduleController===t&&(this._superimposeScheduleController=null),i.removeEventListener("abort",a)};this._superimposeScheduleController=t,i.addEventListener("abort",a),this.superimposeScheduledFrameId=requestAnimationFrame(()=>{if(i.removeEventListener("abort",a),this.superimposeScheduledFrameId=null,this._superimposeScheduleController===t&&(this._superimposeScheduleController=null),i.aborted)return;const e=this.view,r="3d"===e?.type?e:null;!this._hasActiveSuperimposeCameraContext()||null==r||r.interacting||r.navigating||this._updateSuperimposedImage()})}};e([A()],Vt.prototype,"activeLayer",null),e([A({readOnly:!0})],Vt.prototype,"activeViewer",null),e([A()],Vt.prototype,"activeTriangulatedViewer",null),e([A()],Vt.prototype,"accuracyParametersMissing",null),e([A()],Vt.prototype,"additionalFeatures",void 0),e([A({type:o.ofType(t)})],Vt.prototype,"additionalCameraLocations",void 0),e([A({type:o.ofType(t)})],Vt.prototype,"additionalFootprints",void 0),e([A()],Vt.prototype,"areaMeasurementResult",void 0),e([A()],Vt.prototype,"areaMeasurementAccuracy",void 0),e([A()],Vt.prototype,"bestFeatureAngle",void 0),e([A()],Vt.prototype,"bestFeatureCurrentFootprint",void 0),e([A({type:t})],Vt.prototype,"bestFeatureFootprint",void 0),e([A({type:Number})],Vt.prototype,"brightness",null),e([A()],Vt.prototype,"cameraHeadingThreshold",void 0),e([A()],Vt.prototype,"cameraPitchThreshold",void 0),e([A()],Vt.prototype,"clickAction",void 0),e([A()],Vt.prototype,"correctedLocationPointOnImage",void 0),e([A()],Vt.prototype,"videoViewModel",void 0),e([A()],Vt.prototype,"collectionId",void 0),e([A({type:Number})],Vt.prototype,"contrast",null),e([A()],Vt.prototype,"coverageFrustums",void 0),e([A()],Vt.prototype,"coveragePolygons",void 0),e([A()],Vt.prototype,"currentBestFeature",void 0),e([A()],Vt.prototype,"currentBestFeatureMeasurementImage",void 0),e([A()],Vt.prototype,"currentBestFeatureLocation",void 0),e([A()],Vt.prototype,"currentCoverageVisible",void 0),e([A()],Vt.prototype,"currentNode",null),e([A()],Vt.prototype,"depthImage",void 0),e([A()],Vt.prototype,"depthImageNotSupported",null),e([A()],Vt.prototype,"featureCache",void 0),e([A()],Vt.prototype,"navigationNodes",void 0),e([A({json:{write:!1}})],Vt.prototype,"determineWorkflowForFeature",void 0),e([A({json:{write:!1}})],Vt.prototype,"determineWorkflowForTriangularMeasurement",void 0),e([A()],Vt.prototype,"disabled",void 0),e([A()],Vt.prototype,"displayMessage",void 0),e([A()],Vt.prototype,"displayNewMeasurementButton",void 0),e([A()],Vt.prototype,"distanceMeasurementResult",void 0),e([A()],Vt.prototype,"distanceAccuracyArray",void 0),e([A()],Vt.prototype,"dataCaptureLayer",void 0),e([A({readOnly:!0})],Vt.prototype,"featureCount",null),e([A()],Vt.prototype,"features",void 0),e([A()],Vt.prototype,"groundCoordinates",void 0),e([A()],Vt.prototype,"groundCoordinatesAccuracy",void 0),e([A()],Vt.prototype,"groundCoordinatesAccuracyLoading",void 0),e([A()],Vt.prototype,"hasPendingPanoramicNavigationViewState",null),e([A()],Vt.prototype,"heightGraphic",void 0),e([A()],Vt.prototype,"heightMeasurementResult",void 0),e([A()],Vt.prototype,"heightMeasurementAccuracy",void 0),e([A({readOnly:!0})],Vt.prototype,"imageGalleryEnabled",null),e([A()],Vt.prototype,"imageGeometryField",void 0),e([A({readOnly:!0})],Vt.prototype,"imageLoaded",null),e([A()],Vt.prototype,"imageLocationToolState",void 0),e([A()],Vt.prototype,"initialVideoMapViewExtent",void 0),e([A({readOnly:!0})],Vt.prototype,"invalidCameraHeading",null),e([A()],Vt.prototype,"imagePointsInView",null),e([A()],Vt.prototype,"imageMeasurementViewer",void 0),e([A()],Vt.prototype,"isAdditionalCoverageVisible",void 0),e([A()],Vt.prototype,"isAdditionalPointSourcesVisible",void 0),e([A()],Vt.prototype,"layer",void 0),e([A()],Vt.prototype,"layerView",null),e([A({readOnly:!0})],Vt.prototype,"layerFloorFilterClause",null),e([A({readOnly:!0})],Vt.prototype,"layerTimeExtent",null),e([A({type:Number})],Vt.prototype,"localPort",void 0),e([A()],Vt.prototype,"locationPointOnImage",void 0),e([A()],Vt.prototype,"mapImageConversionToolState",void 0),e([A()],Vt.prototype,"measureType",void 0),e([A()],Vt.prototype,"measurementGraphic",void 0),e([A({readOnly:!0,value:"none"})],Vt.prototype,"mode",null),e([A()],Vt.prototype,"navigationMode",void 0),e([A()],Vt.prototype,"navigatorCurrentBestFeature",void 0),e([A()],Vt.prototype,"oiObjectIdField",void 0),e([A({type:o.ofType(t)})],Vt.prototype,"overlayedCameraLocations",void 0),e([A()],Vt.prototype,"overlayedMapFeatures",void 0),e([A()],Vt.prototype,"panoramicVideoLoaded",null),e([A()],Vt.prototype,"panoramicVideoPaused",null),e([A()],Vt.prototype,"pixelCoordinates",void 0),e([A()],Vt.prototype,"preserveAngle",void 0),e([A()],Vt.prototype,"pointSources",void 0),e([A({readOnly:!0})],Vt.prototype,"popupEnabled",null),e([A()],Vt.prototype,"preloadMedia",void 0),e([A()],Vt.prototype,"preloadMediaSize",void 0),e([A()],Vt.prototype,"previousFeatureAngle",void 0),e([A()],Vt.prototype,"referencePoint",null),e([A({readOnly:!0})],Vt.prototype,"sectorData",null),e([A()],Vt.prototype,"selectedPoint",void 0),e([A({type:Number})],Vt.prototype,"sharpness",null),e([A()],Vt.prototype,"shouldShowSelectedImage",void 0),e([A()],Vt.prototype,"superimposeViewEnabled",void 0),e([A()],Vt.prototype,"defaultSuperimposeCameraLockEnabled",void 0),e([A()],Vt.prototype,"superimposeViewSupported",null),e([A()],Vt.prototype,"sketch",void 0),e([A()],Vt.prototype,"sketchTriangular",void 0),e([A()],Vt.prototype,"sketchTriangularGraphicsLayer",void 0),e([A()],Vt.prototype,"draw",void 0),e([A()],Vt.prototype,"drawAdapter",void 0),e([A()],Vt.prototype,"polylineDrawAction",void 0),e([A()],Vt.prototype,"scheduledFrameId",void 0),e([A()],Vt.prototype,"superimposeScheduledFrameId",void 0),e([A()],Vt.prototype,"superimposeDebounceTimeoutId",void 0),e([A()],Vt.prototype,"sketchAdapter",void 0),e([A({readOnly:!0})],Vt.prototype,"sketchGraphicsLayer",null),e([A({readOnly:!0})],Vt.prototype,"state",null),e([A({readOnly:!0})],Vt.prototype,"thumbnails",null),e([A()],Vt.prototype,"videoExtentPoints",null),e([A()],Vt.prototype,"triangularMeasurementActive",void 0),e([A()],Vt.prototype,"triangulatedDistanceMeasurement",void 0),e([A()],Vt.prototype,"triangulatedDistanceAccuracy",void 0),e([A()],Vt.prototype,"triangulatedAreaMeasurement",void 0),e([A()],Vt.prototype,"triangulatedAreaAccuracy",void 0),e([A()],Vt.prototype,"triangulatedMeasurementGraphic",void 0),e([A()],Vt.prototype,"triangulatedPoint",void 0),e([A()],Vt.prototype,"triangulatedMeasurementAdapter",void 0),e([A()],Vt.prototype,"updateFootprint",void 0),e([A()],Vt.prototype,"updateVideoFootprint",void 0),e([A()],Vt.prototype,"updateFootprintPanorama",void 0),e([A()],Vt.prototype,"updatingTriangularMeasurementState",void 0),e([A({value:null})],Vt.prototype,"view",null),e([A()],Vt.prototype,"videoElement",void 0),e([A()],Vt.prototype,"videoLayer",void 0),e([A()],Vt.prototype,"videoMapView",void 0),e([A()],Vt.prototype,"verticalFilterEnabled",void 0),e([A()],Vt.prototype,"_adapter",void 0),e([A()],Vt.prototype,"_defaultGraphicsLayer",null),e([A()],Vt.prototype,"_highlightedFeatureHandle",void 0),e([A()],Vt.prototype,"_imageViewer",void 0),e([A()],Vt.prototype,"_initialCurrentCoverageUpdate",void 0),e([A()],Vt.prototype,"_locationViewModel",void 0),e([A()],Vt.prototype,"_measurementService",void 0),e([A()],Vt.prototype,"_mediaPrefetcher",void 0),e([A()],Vt.prototype,"_navigationManager",void 0),e([A()],Vt.prototype,"_overlays",void 0),e([A()],Vt.prototype,"_superimposePreviousCurrentCoverageVisible",void 0),e([A()],Vt.prototype,"_superimposeService",void 0),e([A({readOnly:!0})],Vt.prototype,"_overlaysView",null),e([A()],Vt.prototype,"_panoramicVideoViewer",void 0),e([A()],Vt.prototype,"_panoramicViewer",void 0),e([A()],Vt.prototype,"_panoramicMeasurementViewer",void 0),e([A()],Vt.prototype,"_referencePointOnGround",void 0),e([A()],Vt.prototype,"_referencePointOnImage",void 0),e([A()],Vt.prototype,"_referenceTransformationService",void 0),e([A()],Vt.prototype,"_sectorData",void 0),e([A()],Vt.prototype,"_transformationService",void 0),e([A()],Vt.prototype,"_featureToSector",void 0),e([A({readOnly:!0})],Vt.prototype,"_updatingHandles",void 0),e([A()],Vt.prototype,"footprintExtent",void 0),e([A()],Vt.prototype,"_featureChangedTask",void 0),Vt=e([k("esri.widgets.OrientedImageryViewer.OrientedImageryViewerViewModel")],Vt);const St=Vt;export{St 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 o from"../../core/Collection.js";import{deprecatedProperty as s}from"../../core/deprecate.js";import n from"../../core/Error.js";import{EventedMixin as l}from"../../core/Evented.js";import{makeHandle as d}from"../../core/handleUtils.js";import{equalsShallow as c}from"../../core/lang.js";import h from"../../core/Logger.js";import{clamp as u,deg2rad as p}from"../../core/mathUtils.js";import{destroyMaybe as m,abortMaybe as g}from"../../core/maybe.js";import{EsriPromise as v}from"../../core/Promise.js";import{isAbortError as y,throwIfAborted as f,waitTick as w}from"../../core/promiseUtils.js";import _ from"../../core/ReactiveMap.js";import{whenOnce as F,on as V,watch as S,syncAndInitial as b,initial as M,when as P}from"../../core/reactiveUtils.js";import{sqlAnd as I}from"../../core/sql.js";import{getMetersPerUnitForSR as C}from"../../core/units.js";import{property as A,subclass as k}from"../../core/accessorSupport/decorators.js";import{isSerializable as T}from"../../core/support/jsonUtils.js";import{UpdatingHandles as O}from"../../core/support/UpdatingHandles.js";import L from"../../geometry/Extent.js";import E from"../../geometry/Point.js";import{projectAsync as G}from"../../geometry/projectionUtils.js";import j from"../../geometry/SpatialReference.js";import{polygonCentroidPoint as R}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 D}from"../../geometry/support/webMercatorUtils.js";import N from"../../layers/GraphicsLayer.js";import H from"../../layers/MediaLayer.js";import{searchImages as z,getSortedLayerFeatures as U}from"../../layers/orientedImagery/queries.js";import{calculateSuitabilities as q}from"../../layers/orientedImagery/core/bestImageUtils.js";import{createCoveragePolygon as W,computePolygonForInspection as $,resizePolygon as Z,checkIfPolygonContainsSelectedPoint as J}from"../../layers/orientedImagery/core/coverageUtils.js";import{isElevationSource as K}from"../../layers/orientedImagery/core/ElevationSourceDefinitions.js";import{getMetersPerUnitOfSR as Q,convertGeographicToWebMercator as X}from"../../layers/orientedImagery/core/utils.js";import Y from"../../layers/orientedImagery/transformations/updateElevation.js";import{getElevationSampler as ee}from"../../layers/orientedImagery/transformations/updateElevationUtils.js";import{or as te,getInitialAngle as ie,convertPixelLocationToSphereVertex as ae,getUpdateElevationProps as re,adjustHorizonAngles as oe,convertOrientationToPixelLocation as se,getImageToWorldProperties as ne,getImageToWorldPanoramicProperties as le}from"../../layers/orientedImagery/transformations/utils.js";import de from"../../layers/support/ExtentAndRotationGeoreference.js";import{getFloorFilterClause as ce}from"../../layers/support/floorFilterUtils.js";import he from"../../layers/support/VideoElement.js";import ue from"../../views/MapView.js";import pe from"../../views/draw/Draw.js";import{scale as me}from"../../views/draw/support/drawUtils.js";import{ViewEventPriorities as ge}from"../../views/input/InputManager.js";import ve from"../PanoramicVideoViewer.js";import ye from"../PanoramicViewer.js";import{defaultAngleThresholdInDegrees as fe,videoMapViewConstraint as we,fixedImageSize as _e,clockwiseDirections as Fe,videoFitScaleTolerance as Ve,videoExtent as Se,invalidCameraHeading as be,sectorsInOrder as Me,sampleExtent as Pe,sectorsRadii as Ie}from"./constants.js";import{isFeatureAttachment as Ce}from"./galleryUtils.js";import{crossSymbol as Ae,crossSymbol3D as ke,measurementPolygonSymbol as Te,polylineSymbolPanoramic as Oe,measurementPolylineSymbol as Le,cameraOverlaySymbol3D as Ee,cameraOverlaySymbol as Ge,diamondSymbol as je,diamondSymbol3D as Re,activeSourcePointSymbol as xe,sourcePointSymbol as Be}from"./symbols.js";import{registryKeys as De}from"./types.js";import{isNoAttachmentError as Ne,extractHorizonAnglesFromMedia as He,isTifOrMrf as ze,filterOILLayerView as Ue,assignElevationSampleToFeatures as qe,filterByZ as We,createPanoramicMedia as $e,createNonPanoramicMedia as Ze,isSceneView as Je,isGraphic as Ke,calculateSegment as Qe,calculateDirection as Xe}from"./utils.js";import{disableVideoZoomAndPan as Ye,getUpdatedConstraints as et,getUpdatedExtentPoints as tt,isSelectedPointWithinVideoFootprint as it,isVideoPixelWithinFrame as at}from"./videoViewerUtils.js";import rt from"./components/ImageViewer.js";import ot from"./components/NavigationNode.js";import st from"./components/OrientedImageryVideoViewModel.js";import{NoFeatureFoundWithObjectIdError as nt}from"./navigation/errors.js";import{queryFeatureByObjectIds as lt}from"./navigation/queries.js";import{ImageMeasurementService as dt}from"./services/ImageMeasurementService.js";import ct from"./services/SuperimposeService.js";import{configureSketchTool as ht,extractFieldsFromDataCaptureLayer as ut,constructGraphicFromImageGeometry as pt}from"./support/dataCaptureUtils.js";import{removeZFromGeometry as mt,imageSpaceToPoint as gt,pointToImageSpace as vt}from"./support/geometryUtils.js";import{restorePanoramicNavigationViewState as yt,restoreDefaultNavigationViewState as ft}from"./support/navigationViewStateUtils.js";import wt from"./support/resolveMediaProps.js";import{isValidDataCaptureLayer as _t}from"./support/typeUtils.js";const Ft=()=>new n("orientedimageryviewer:sketch-not-initialized","Sketch property is not initialized, call loadSketch first");let Vt=class extends(l(v)){constructor(e){super(e),this.additionalFeatures=new o,this.additionalCameraLocations=new o,this.additionalFootprints=new o,this.areaMeasurementResult=0,this.areaMeasurementAccuracy=0,this.bestFeatureAngle=0,this.bestFeatureCurrentFootprint=null,this.bestFeatureFootprint=null,this.cameraHeadingThreshold=fe,this.cameraPitchThreshold=fe,this.clickAction="hittest",this.correctedLocationPointOnImage=null,this.videoViewModel=null,this.collectionId=null,this.coverageFrustums=new o,this.coveragePolygons=new o,this.currentBestFeature=null,this.currentBestFeatureMeasurementImage=null,this.currentBestFeatureLocation=null,this.currentCoverageVisible=!0,this.depthImage=null,this.featureCache=[],this.navigationNodes=new o,this.determineWorkflowForFeature=async(e,t,i)=>{const{currentBestFeature:a,selectedPoint:r}=this;if(this.emit("popup-close"),a&&r){this.displayMessage=null,this._initialCurrentCoverageUpdate=!0,this._updateGroundElevation=!0;try{await this._updatePointsAndPolygons(i),await this._loadDepthImage(i),await this._loadCurrentFeatureMedia(a,i)}catch(o){y(o)||(this.loadImageError(o),h.getLogger(this).error("#loadIImage()","error occured while loading image",o))}}},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),h.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 o,this.groundCoordinates=null,this.groundCoordinatesAccuracy=null,this.groundCoordinatesAccuracyLoading=!1,this.heightGraphic=null,this.heightMeasurementResult=0,this.heightMeasurementAccuracy=0,this.imageGeometryField=null,this.imageLocationToolState=!1,this.initialVideoMapViewExtent=null,this.imageMeasurementViewer=new rt,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 o,this.overlayedMapFeatures=new _,this.pixelCoordinates=null,this.preserveAngle="none",this.pointSources=new o,this.preloadMedia=!1,this.preloadMediaSize=5,this.previousFeatureAngle=0,this.selectedPoint=null,this.shouldShowSelectedImage=!1,this.superimposeViewEnabled=!1,this.defaultSuperimposeCameraLockEnabled=!0,this.sketch=null,this.sketchTriangular=null,this.sketchTriangularGraphicsLayer=null,this.draw=null,this.drawAdapter=null,this.polylineDrawAction=null,this.scheduledFrameId=null,this.superimposeScheduledFrameId=null,this.superimposeDebounceTimeoutId=null,this.sketchAdapter=null,this.triangularMeasurementActive=!1,this.triangulatedDistanceMeasurement=null,this.triangulatedDistanceAccuracy=null,this.triangulatedAreaMeasurement=null,this.triangulatedAreaAccuracy=0,this.triangulatedMeasurementGraphic=null,this.triangulatedPoint=null,this.triangulatedMeasurementAdapter=null,this.updateFootprint=async(e,t,i)=>{"default"===this.mode&&"image-loaded"!==this.state||await(this._adapter?.updateFootprint(e,t,i))},this.updateVideoFootprint=async e=>{this.mode.includes("video")&&this.videoElement?.content&&await(this._adapter?.updateVideoFootprint(e))},this.updateFootprintPanorama=async(e,t)=>{await(this._adapter?.updateFootprintPanorama(e,t))},this.updatingTriangularMeasurementState=!1,this.videoElement=null,this.videoLayer=null,this.videoMapView=new ue({map:new Map,attributionVisible:!1,constraints:we}),this.verticalFilterEnabled=!1,this._adapter=null,this._highlightedFeatureHandle=null,this._imageViewer=new rt,this._initialCurrentCoverageUpdate=!0,this._locationViewModel=null,this._measurementService=null,this._mediaPrefetcher=null,this._navigationManager=null,this._overlays=new N({listMode:"hide",internal:!0,elevationInfo:{mode:"absolute-height"},title:"OrentedImageryViewerViewModel overlays layer"}),this._superimposePreviousCurrentCoverageVisible=null,this._superimposeService=new ct({getMapPoint:(e,t)=>this.getMapPoint(e,t),getPanoramicTransformationState:()=>{const{imageToWorldProperties:e,mode:t,updateElevationProps:i}=this._transformationService;return"panoramic"===t&&e?{imageToWorldProperties:e,updateElevationProps:i}:null},pointToPixel:(e,t)=>this._transformationService.pointToPixel(e,t),overlays:this._overlays,getPointAtDistance:(e,t,i)=>this._transformationService.pixelToPointAtDistance(e,t,i)}),this._panoramicVideoViewer=new ve,this._panoramicViewer=new ye,this._panoramicMeasurementViewer=new ye,this._referencePointOnGround=null,this._referencePointOnImage=null,this._referenceTransformationService=null,this._sectorData=null,this._transformationService=null,this._featureToSector=null,this._updatingHandles=new O,this._clickTask=null,this._crossSymbol=null,this.footprintExtent=null,this._featureChangedTask=null,this._mediaPrefetchTask=null,this._navigationViewStateTask=null,this._pendingPanoramicNavigationViewState=null,this._restoreSuperimposeMediaTask=null,this._superimposeScheduleController=null,this._suitabilities=null,this._pendingDefaultNavigationViewState=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 f(e),this.sketchAdapter=new i({viewModel:this}),this.sketchAdapter},this.loadImageFromFeature=(e,t,i)=>this._updatingHandles.addPromise(this._loadImageFromFeature(e,t,i)),this.storeImageMeasurementViewer=e=>{this.imageMeasurementViewer=e},this.storePanoramicMeasurementViewer=e=>{this._panoramicMeasurementViewer=e},this.loadImageViewer=e=>{this._imageViewer?.destroy(),this._imageViewer=e},this.loadPanoramicViewer=e=>{this._panoramicViewer?.destroy(),this._panoramicViewer=e},this.loadPanoramicVideoViewer=e=>{this._panoramicVideoViewer?.destroy(),this._panoramicVideoViewer=e},this.loadVideoViewer=e=>{this.videoMapView.container=e},this.showImageByObjectId=async(e,t)=>{const i=this.additionalFeatures.find(({attributes:t})=>t.objectId===e);if(i)this.currentBestFeature=i;else{const{layer:i,layerFloorFilterClause:r,layerTimeExtent:o}=this;if(!i)return void this.setMessage("noLayerSelected","info");this.beforeLoad();const s=this._updatingHandles.addPromise(this._queryAndLoadByObjectId(i,e,r,o,t));try{await s,await this.selectBestFeature(e,t)}catch(a){y(a)||(h.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.");this._pendingDefaultNavigationViewState=null,this._pendingPanoramicNavigationViewState=null;const a=e=>"default"===i&&e.declaredClass.endsWith("NavigationManager")||"panoramic"===i&&e.declaredClass.endsWith("NavigationManagerPanoramic");if(null==this._navigationManager||!a(this._navigationManager)){m(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)=>(f(t),this.currentBestFeature=this.features?.find(({attributes:t})=>`${t.objectId}`==`${e}`),F(()=>{switch(this.mode){case"video":return"video-loaded"===this.state;case"panoramic-video":return this.panoramicVideoLoaded;default:return"image-loaded"===this.state}},t)),this.toggleImageAttributes=()=>{const{currentBestFeature:e,popupEnabled:i,layer:a,view:r}=this;if(this.emit("popup-close"),!(r&&e&&i&&a))return;const{attributes:o,geometry:s}=e,n=new t({geometry:s,attributes:o.toJSON(),origin:a.graphicOrigin,sourceLayer:a});this.emit("popup-open",{features:[n],location:o.location.clone()})},this.updateSuitabilities=(e,t=!0)=>{e.sort((e,t)=>e.suitability-t.suitability),this._suitabilities=e;const i=this._suitabilities.map(({feature:e})=>e);this._initialCurrentCoverageUpdate=!0,this._updateFeatures(i,t),this._groupFeaturesBySectors()},this._computeOverlayImageSize=()=>{const{mode:e}=this;return"video"===e?_e:"panoramic-video"===e?this._panoramicVideoViewer.imageSize:this.activeViewer?.imageSize},this._geometryToOverlayImageGeometry=async(e,t,i)=>{const{mode:a,videoViewModel:r,_panoramicVideoViewer:o}=this;if("video"===a)return await(r?.geometryToOverlayGeometry(e,t))??null;if("panoramic-video"===a){const r={feature:t,mode:a,imageSize:i,footprintExtent:this.footprintExtent};return await this._transformationService.geometryToImageGeometryForFeature(e,r,o.horizonAngles)}return await this._transformationService.geometryToImageGeometry(e)},this._createViewClickHandle=()=>{if(this.removeHandles(De.click),this.disabled||null==this.view)return;const e=this.mapImageConversionToolState&&("image-loaded"===this.state||"video-loaded"===this.state&&"video"===this.mode&&!!this.videoViewModel?.videoPaused||this.panoramicVideoLoaded&&"panoramic-video"===this.mode&&this.panoramicVideoPaused)?this._mapImageConversionToolViewClickHandler:this._viewClickHandler;this.addHandles(this.view.on("click",e,ge.DEFAULT),De.click)},this._createImageClickHandle=()=>{this.removeHandles(De.imageClick),this.videoViewModel?.syncMapImageConversionHandle();const{mapImageConversionToolState:e,mode:t,footprintExtent:i,panoramicVideoLoaded:a}=this,o="panoramic-video"===t?this._panoramicVideoViewer:this.activeViewer,s=o?.imageSize;if(!e||"none"===t||"video"===t||!s||!i)return;const n="panoramic-video"===t,l=this._getActiveFeatureForCurrentMode(),c=!n||a&&this.panoramicVideoPaused;if(!l||!c)return;const h=o.clickAction;this.clickAction="pixel-location";const u=d(()=>{this.clickAction=h});let p=null;const m=V(()=>o,"pixel-location",e=>{this.plotReferencePointOnImage(e),p?.abort(),p=r(async a=>{if(!e)return;const r=this._getActiveFeatureForCurrentMode();if(!r)return;const o={feature:r,mode:t,imageSize:s,footprintExtent:i};let l=n?await this.getMapPointForFeature(e,o,{signal:a}):await this._transformationService.pixelToMapPoint(e);const d=this.view?.spatialReference;l&&!te(!d,l.spatialReference.equals(d))&&(l=await G(l,d,{signal:a})),f(a),this.plotReferencePointOnGround(l)})});this.addHandles([m,u],De.imageClick)},this._createTriangularImageClickHandle=()=>{this.removeHandles(De.triangularImageClick),this.triangularMeasurementActive&&"none"!==this.mode&&this.currentBestFeature&&this.currentBestFeatureMeasurementImage&&this.activeTriangulatedViewer&&this.addHandles(this.activeTriangulatedViewer.imageRenderer.on("double-click",this._measurementImageClickHandler),De.triangularImageClick)},this._enablePan=()=>{this.removeHandles(De.videoPanHandles)},this._disablePan=()=>{this.removeHandles(De.videoPanHandles),this.addHandles(Ye(this.videoMapView),De.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._loadCurrentFeatureMedia=async(e,t)=>{"video"!==this.mode?"panoramic-video"!==this.mode?await this._loadImage(t):await this._loadVideo(t):await this._loadFlatVideo(e,t)},this._loadFlatVideo=async(e,t)=>{this._initializeVideo(),this.videoViewModel?.playVideoFromSelectedLocation(e);const i=e.attributes.objectId;this._waitForFlatVideoAndPlotSelectedLocation(e,i,t)},this._waitForFlatVideoAndPlotSelectedLocation=async(e,t,i)=>{try{if(await F(()=>!0===this.videoElement?.loaded,i),`${this.currentBestFeature?.attributes.objectId}`!=`${t}`)return;await this.transformAndPlotSelectedLocation(i)}catch(a){y(a)||h.getLogger(this).error("failed to plot selected point on video",{error:a,selectedPoint:this.selectedPoint,feature:e})}},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 o=(await(import("./services/DepthImageService.js"))).default;f(e),this.depthImage=new o({url:r});try{await this.depthImage.load(e)}catch(s){y(s)||(h.getLogger(this).error("error occurred while loading depth image",s),this.depthImage?.destroy(),this.depthImage=null)}},this._loadImage=async e=>{const{currentBestFeature:t,layer:i,mode:a}=this,r=this._pendingDefaultNavigationViewState;if(this._pendingDefaultNavigationViewState=null,this.clearGraphics(),i&&t&&"none"!==a&&"video"!==a&&"panoramic-video"!==a)try{if(await this.loadImageFromFeature(i,t,e),f(e),r)try{await this._restoreNavigationViewState(r,e)}catch(o){if(y(o))throw o;h.getLogger(this).warn("oriented-imagery-viewer:failed-to-restore-navigation-view-state",o)}await this.transformAndPlotSelectedLocation(e)}catch(o){y(o)||this.loadImageError(o)}},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:o}=t,{cameraPitch:s,cameraOrientation:n,location:l}=o,d=l.spatialReference.isWGS84&&4!==n?.type?D(l):new E(l);try{this._panoramicVideoViewer.viewModel.video&&(this._panoramicVideoViewer.viewModel.video.pause(),this._panoramicVideoViewer.viewModel.videoPaused=!0),this._panoramicVideoViewer.videoSource=r;let t=0;d&&a&&(t=await ie(d,a)-t),this._panoramicVideoViewer.pitch=s??0,this._panoramicVideoViewer.yaw=t,await this._panoramicVideoViewer.loadVideo(e),f(e)}catch(c){y(c)||this.loadImageError(c)}},this._loadImageFromFeature=async(e,t,i)=>{const{mode:a}=this;if("default"!==a&&"panoramic"!==a)return;let r;try{r=await wt(t.attributes,e,i),f(i)}catch(v){if(y(v))return;return Ne(v)?(h.getLogger(this).error(v),void this.setMessage("noAttachment","error",`${e.objectIdField}: ${t.attributes.objectId}`)):(h.getLogger(this).error(v,{[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:o,datasetFormat:s,rotation:n,searchParams:l,location:d,cameraHeading:c,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 d&&this.selectedPoint&&(a=await ie(d,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&&h.getLogger(this).warn("error occurred while getting dataset format",m),"panoramic"===a?await this.loadPanoramicMediaSource({lookAt:{yaw:this.selectedPoint?await ie(d,this.selectedPoint):"viewAngle"in t.attributes&&Number.isFinite(t.attributes.viewAngle)?t.attributes.viewAngle:0,pitch:p},extension:s?.toUpperCase(),url:o,cameraHeading:c,matrix:u},i):await this.loadMediaSource({datasetFormat:s?.toUpperCase(),url:o,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),f(e)}catch(r){y(r)||this.loadImageError(r)}},this._loadMediaPrefetcher=async e=>{if(!this._mediaPrefetcher){const{default:t}=await(import("./support/MediaPrefetcher.js"));f(e),this._mediaPrefetcher=new t({maxEntries:this.preloadMediaSize*Fe.length})}return this._mediaPrefetcher},this._loadViewAdapter=async e=>{const{view:t}=this;if(this._adapter?.disableDefaultSuperimposeNavigation?.(),this._adapter?.disablePanoramicSuperimposeNavigation?.(),t)switch(t.type){case"2d":{const{default:t}=await(import("./adapters/view/MapViewAdapter.js"));f(e),this._adapter=new t(this);break}case"3d":{const{default:t}=await(import("./adapters/view/SceneViewAdapter.js"));f(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;const{minScale:t}=this.videoMapView.constraints,i=this.videoMapView.scale<t-Ve,a=et(e);i&&!!a?(this._enablePan(),this.videoMapView.constraints.geometry=a):i?(this._disablePan(),this.videoMapView.constraints.geometry=null):(this.initialVideoMapViewExtent&&!this.videoMapView.extent.equals(this.initialVideoMapViewExtent)&&(this.videoMapView.extent=this.initialVideoMapViewExtent),this._disablePan(),this.videoMapView.constraints.geometry=null)},this._viewClickHandler=e=>{this._clickTask?.abort(),this._clickTask=r(async t=>{const{pointerType:i,button:a,mapPoint:r}=e;if("mouse"===i&&0!==a||!r)return;e.stopPropagation(),e.preventDefault();const{view:o,layer:s}=this;if(o){if(s){if(this.shouldShowSelectedImage){const i=o.hitTest(e,{include:[s]});this._updatingHandles.addPromise(i);const a=await i;return f(t),await this._processHitTestResults(s,a,{signal:t})}return this._updatingHandles.addPromise(this.loadBestImage(r,{signal:t}))}this.setMessage("noLayerSelected","info")}})},this.plotSelectedPointOnImage=async(e,i)=>{if(await w(i),!e)return;const a=new E({...T(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:Ae}),this._imageViewer.addGraphic(this._crossSymbol,0);else if("video"===this.mode)this._crossSymbol=this.videoViewModel?.plotSelectedPointOnVideo(a)??null;else if("panoramic"===this.mode){const{imageSize:i,media:a}=this._panoramicViewer;if(!i||!a)return;const r=He(a),o=ae(e,...i,r);this._crossSymbol=new t({geometry:new E(o,j.WebMercator),symbol:ke}),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([S(()=>this.view,()=>this.load(),b),S(()=>this.view?.map,(e,t)=>{t?.layers.remove(this._overlays),e?.layers.add(this._overlays)},M),S(()=>this.view?.map?.allLayers?.length,e=>{e&&this.view?.map?.layers.reorder(this._overlays,e-1)},M),S(()=>[this.state,this.panoramicVideoLoaded,this.mapImageConversionToolState,this.view,this.disabled,this.panoramicVideoPaused,this.videoViewModel?.videoPaused],(e,t)=>{const i=e[2],a=t?.[2];a&&!i&&(this.plotReferencePointOnGround(null),this.clearReferencePointOnImage()),this._createViewClickHandle(),this._createImageClickHandle()},b),S(()=>[this.triangularMeasurementActive,this.currentBestFeatureMeasurementImage],()=>{this._createTriangularImageClickHandle()},b),S(()=>[this.state,this.imageLocationToolState,this.view],()=>{this._initializeMeasurementService(),this._initializeLocationViewModel()},b),S(()=>this.measureType,()=>{this.clearPreviousMeasurements(),this._initializeMeasurementService()},b),S(()=>this.bestFeatureAngle,(e,t)=>{this.previousFeatureAngle=t??0},b),S(()=>[this.superimposeViewEnabled,this.defaultSuperimposeCameraLockEnabled,this.superimposeViewSupported,this.currentBestFeature,this.mode,this.state,this.view?.type],()=>{this._shouldDisableUnsupportedSuperimposeView()?this.superimposeViewEnabled=!1:this._hasActiveSuperimposeCameraContext()?this._updateSuperimposedImage():this._resetInactiveSuperimposeState()},b),S(()=>this._getSuperimposeCameraWatchState(),()=>this._handleSuperimposeCameraChange(),b),S(()=>this.currentBestFeature,async(e,t)=>{g(this._featureChangedTask),this._featureChangedTask=r(async i=>this.determineWorkflowForFeature.apply(this,[e,t,{signal:i}])),await this._featureChangedTask.promise},{sync:!0}),S(()=>[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}),f(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),S(()=>this.currentBestFeatureMeasurementImage,(e,t)=>{g(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}),f(i),this._reorderTriangularSketchLayer()})},b),S(()=>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())}),S(()=>this.mode,e=>{switch(this.removeHandles(De.interactionHandles),e){case"default":this.addHandles(S(()=>{const{state:e}=this;return"image-loaded"===e?this._imageViewer.imagePointsInView:null},e=>{e&&(g(this._updateFootprintTask),this._updateFootprintTask=r(async t=>{await this.updateFootprint(e,void 0,{signal:t})}))},{...b,equals:(e,t)=>i(e,t,c)}),De.interactionHandles);break;case"video":this.addHandles(S(()=>{const{footprintExtent:e,videoElement:t,bestFeatureFootprint:i}=this;if(e&&t?.loaded&&i)return{videoExtent:Se,bestFeatureFootprint:i}},e=>{e?.videoExtent&&e?.bestFeatureFootprint&&(g(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,c)&&e?.bestFeatureFootprint===t?.bestFeatureFootprint}),De.interactionHandles);break;case"panoramic":this.addHandles(S(()=>{const{currentBestFeature:e,state:t,_panoramicViewer:i}=this,{imageSize:a,vfov:r,hfov:o,pitch:s,yaw:n}=i;return e&&a&&!t.includes("loading")&&null!=r&&null!=o&&null!=s&&null!=n?[r,o,n,s]:null},e=>{if(!e||this.state.includes("loading"))return;const[t,i,a,o]=e;this.currentNode&&(this.currentNode.currentHeading=a,this.currentNode.currentPitch=o),g(this._updateFootprintTask),this._updateFootprintTask=r(async e=>{await this.updateFootprintPanorama({verticalFieldOfView:t,horizontalFieldOfView:i,yaw:a,pitch:o},{signal:e}),this._updateFootprintTask=null})},{equals:(e,t)=>i(e,t,c)}),De.interactionHandles);break;case"panoramic-video":this.addHandles(S(()=>{const{currentBestFeature:e,state:t,_panoramicVideoViewer:i}=this,{imageSize:a,vfov:r,hfov:o,pitch:s,yaw:n,viewModel:l}=i,d=l.closestFeature??e;return d&&a&&!t.includes("loading")&&null!=r&&null!=o&&null!=s&&null!=n?[r,o,n,s,d]:null},e=>{if(!e)return;const[t,i,a,o,s]=e;g(this._updateFootprintTask),this._updateFootprintTask=r(async e=>{await this.updateFootprintPanorama({verticalFieldOfView:t,horizontalFieldOfView:i,yaw:a,pitch:o,feature:s,horizonAngles:this._panoramicVideoViewer.horizonAngles},{signal:e}),f(e),this._updateFootprintTask=null})},{equals:(e,t)=>i(e,t,c)}),De.interactionHandles)}},b),S(()=>[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),S(()=>this.activeViewer?.imageRenderer,()=>{this.sketch&&(this.sketch.view=this.activeViewer?.imageRenderer)}),S(()=>this.activeViewer,e=>{this.removeHandles(De.hittestHandles),e&&this.addHandles(V(()=>e,"hittest-response",this._handleImageHitTestResponse),De.hittestHandles)}),S(()=>this.videoMapView.extent,async()=>{this._scheduleVideoInteractionUpdate();const e=this.videoViewModel?.closestFeature;e&&(g(this._updateFootprintTask),this._updateFootprintTask=r(async t=>{const i={points:this.videoExtentPoints,feature:e,options:{signal:t}};await this.updateVideoFootprint(i)}))}),S(()=>[this.videoMapView.interacting,this.videoMapView.navigating,this.videoMapView.scale],()=>{this._scheduleVideoInteractionUpdate()},{initial:!0}),P(()=>null!=this.videoMapView.extent,()=>{this.initialVideoMapViewExtent=this.videoMapView.extent},{once:!0})]),this.when().finally(()=>{this.notifyChange("state")})}destroy(){this._adapter?.disableDefaultSuperimposeNavigation?.(),this._adapter?.disablePanoramicSuperimposeNavigation?.(),this._abortSuperimposeSchedule(),this.currentBestFeature=null,this._updateFootprintTask=g(this._updateFootprintTask),this._clickTask=g(this._clickTask),this._navigationViewStateTask=g(this._navigationViewStateTask),this._restoreSuperimposeMediaTask=g(this._restoreSuperimposeMediaTask),this.coverageFrustums.destroy(),this.coveragePolygons.destroy(),this.pointSources.destroy(),this.additionalFootprints.destroy(),this.additionalCameraLocations.destroy(),this.bestFeatureFootprint=m(this.bestFeatureFootprint),this.bestFeatureCurrentFootprint=m(this.bestFeatureCurrentFootprint),this.videoViewModel=m(this.videoViewModel),this._locationViewModel=m(this._locationViewModel),this.clearSelectedPointOnViewer(),this._referencePointOnGround=m(this._referencePointOnGround),this.clearReferencePointOnImage(),this._superimposeService.destroy(),this._overlays&&this.view?.map?.remove(this._overlays),this._overlays.destroy(),this._imageViewer.destroy(),this.imageMeasurementViewer.destroy(),this._panoramicViewer.destroy(),this._panoramicMeasurementViewer.destroy(),this._mediaPrefetcher?.destroy()}get activeLayer(){return s(h.getLogger(this),"activeLayer",{replacement:"layer"}),this.layer}set activeLayer(e){s(h.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!ze(this.currentBestFeature.attributes.depthImage)}get featureCount(){return this.features?.length??0}get hasPendingPanoramicNavigationViewState(){return null!=this._pendingPanoramicNavigationViewState}get imageGalleryEnabled(){const{currentBestFeature:e}=this;if(!e)return!1;const t=e.attributes.imagePath?.trim();return ze(t)||Ce(t)}get imageLoaded(){return s(h.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===be}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(Ue(e))}get layerFloorFilterClause(){const{layerView:e}=this;return e?ce(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 overlayGraphicsEnabled(){const{mode:e,state:t,panoramicVideoLoaded:i,videoViewModel:a,panoramicVideoPaused:r}=this;return"image-loaded"===t||"video"===e&&"video-loaded"===t&&!0===a?.videoPaused||"panoramic-video"===e&&i&&r}get panoramicVideoPaused(){return!!this._panoramicVideoViewer.viewModel.videoPaused}get popupEnabled(){return!0===this.layer?.popupEnabled}get referencePoint(){return this._referencePointOnGround?.geometry}get sectorData(){const{_sectorData:e}=this;return e?Me.map(t=>e[t]):null}get sharpness(){return this._get("sharpness")??0}set sharpness(e){this._set("sharpness",u(e,0,1))}get superimposeViewSupported(){return"default"===this.mode||"panoramic"===this.mode}get sketchGraphicsLayer(){const{sketch:e}=this;return"graphics"===e?.layer?.type?e.layer:void 0}get state(){const{mode:e,_updatingHandles:{updating:t},_featureChangedTask:i,_navigationManager:a}=this;if(!this.isFulfilled()||t||!1===i?.finished||a?.navigating)return"loading";if(this.isRejected())return"error";if("error"===this.displayMessage?.type)return"image-load-error";switch(e){case"default":return this._imageViewer.state;case"panoramic":return this._panoramicViewer.state;case"video":return this.videoElement?.loaded?"video-loaded":"video-not-loaded"}return"ready"}get thumbnails(){const{features:e}=this;return e?new o(e.map(({attributes:{imagePath:e,objectId:t,cameraRoll:i,imageRotation:a}})=>{const r=e?.trim();return ze(r)||Ce(r)?{url:r,objectId:t,rotation:(i??0)+(a??0)}:null}).filter(a)):null}get videoExtentPoints(){const e=tt(this.videoMapView.extent);return e.length?e:Se}set view(e){this._set("view",e)}get _defaultGraphicsLayer(){const e={blendMode:"source-atop"};switch(this.mode){case"panoramic":return new N({...e,elevationInfo:{mode:"absolute-height"}});case"default":return new N({...e});default:return}}get _overlaysView(){return this.view?.layerViews.find(({layer:e})=>e===this._overlays)}updatePanoramicSuperimposeRadiusOffset(e){this._superimposeService.updatePanoramicRadiusOffset(e)}setDefaultSuperimposeZOffsetPercentage(e){this._superimposeService.setDefaultZOffsetPercentage(e)}setPanoramicSuperimposeRadiusPercentage(e){this._superimposeService.setPanoramicRadiusPercentage(e)}updateDefaultSuperimposeCameraLock(e){this.defaultSuperimposeCameraLockEnabled=e,this.superimposeViewEnabled&&"default"===this.mode&&(e?this._adapter?.enableDefaultSuperimposeNavigation?.():this._adapter?.disableDefaultSuperimposeNavigation?.())}beforeLoad(e=!0){this.emit("popup-close"),e&&(this.displayMessage=null),this._pendingDefaultNavigationViewState=null,this._pendingPanoramicNavigationViewState=null,this._abortSuperimposeSchedule(),this._adapter?.disableDefaultSuperimposeNavigation?.(),this._adapter?.disablePanoramicSuperimposeNavigation?.(),this.clearPreviousGroundLocation(),this.triangularMeasurementActive=!1,this.currentBestFeatureMeasurementImage=null,this.measureType=null,this.imageLocationToolState=!1,this.features.removeAll(),this.currentBestFeature=null,this.additionalFeatures.removeAll(),this.additionalFootprints.removeAll(),this.additionalCameraLocations.removeAll(),this.bestFeatureCurrentFootprint=m(this.bestFeatureCurrentFootprint),this._restoreSuperimposeMediaTask=g(this._restoreSuperimposeMediaTask),this._superimposeService.clear(),this._overlays?.removeAll()}async calculateLocationAccuracy(e){return this._measurementService?.calculateLocationAccuracy(e)}clearLocationPointOnImage(e=!1){this.locationPointOnImage&&!e&&(this._imageViewer.removeGraphic(this.locationPointOnImage),this._panoramicViewer.removeGraphic(this.locationPointOnImage),this.locationPointOnImage=m(this.locationPointOnImage)),this.correctedLocationPointOnImage&&(this.imageMeasurementViewer.removeGraphic(this.correctedLocationPointOnImage),this._panoramicMeasurementViewer.removeGraphic(this.correctedLocationPointOnImage),this.correctedLocationPointOnImage=m(this.correctedLocationPointOnImage))}clearPreviousMeasurements(){this.clearMeasurementGraphics(),this.resetMeasurementData(),this.stopMeasurement()}clearPreviousGroundLocation(){this.groundCoordinates=null,this.groundCoordinatesAccuracy=null,this.groundCoordinatesAccuracyLoading=!1,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 Ft();ht(a,e,i),await i.create(e,{...t,defaultZ:0})}digitizeDelete(){if(!this.sketch)throw Ft();return this.sketch.delete()}digitizeDuplicate(){if(!this.sketch)throw Ft();return this.sketch.duplicate()}digitizePlace(e,t){if(!this.sketch)throw Ft();return this.sketch.place(e,t)}digitizeRedo(){if(!this.sketch)throw Ft();return this.sketch.redo()}digitizeUndo(){if(!this.sketch)throw Ft();return this.sketch.undo()}digitizeUpdate(e,t){if(!this.sketch)throw Ft();return this.sketch.update(e,t)}filterByFootprints(e,t,i=!1){const a=[],r=[],o=[];return e.forEach(e=>{const{layer:{coveragePercent:s},attributes:n}=e;let l;const{polygon:d,frustum:c}=W(n);if(l=d.clone(),n.isInspection&&(l=$(n)),s&&(l=Z(l,s)),i||!t||J(l,t)){o.push(e);const{geometry:t,objectId:i,cameraHeight:s,cameraHeading:l}=n,h=t.clone();h.z=s/Q(t.spatialReference),h.imageID=i,this.pointSources.push(h),l!==be&&(a.push(d),c&&r.push(c))}}),{features:o,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,outFields:[t.objectIdField]}).then(({features:e})=>t.applyEdits({deleteFeatures:e}))}handleSectorClick(e){if(isNaN(e))return;const t=this._sectorData?.[Me[e]],i=t?.at(0);i&&(this.triangularMeasurementActive&&this.currentBestFeature?this._updateImageMeasurementBestFeature(i):this._scheduleCurrentBestFeatureUpdate(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._scheduleCurrentBestFeatureUpdate(r))}load(e){return this.addResolvingPromise(this._loadViewAdapter(e).catch(e=>{if(!y(e))throw e})),this}async loadBestImage(e,t){return this.selectedPoint=X(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(f(e),this.drawAdapter=new i({viewModel:this,measurementService:this._measurementService}),!this.drawAdapter.viewModel.isResolved())return}return this.drawAdapter}loadImageError(e){h.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;f(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(f(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:o,frustums:s}=this.filterByFootprints(a,t,i?.skipFilter);if(!this._checkFeatures(r))return;this.coveragePolygons.addMany(o),this.coverageFrustums.addMany(s);const n=await this.processElevationSample(o,r,i);f(i),await this._updateElevationOfSelectedPointAndLocations(r,t,n),f(i),qe(r,n);let l=r;if(this.layer?.verticalSearchRange&&this.layer.hasZ&&this.verticalFilterEnabled&&(l=We(r,t,this.layer.verticalSearchRange),!l.length))return void this.setMessage("noImageAtElevation","info");const d=this._processSuitableFeatures(l,t);this.updateSuitabilities(d,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 o=await this.processElevationSample(r,a,i);return f(i),o}async startMeasurement(e,t){this.sketch||await this.loadSketch(t),await this.loadMeasurementAdapter(t);const{sketch:i,sketchAdapter:a,activeViewer:r,mode:o}=this;if(!i||!a||!r||"none"===o)return;if(this.displayNewMeasurementButton=!1,"panoramic"===o&&(i.defaultCreateOptions.defaultZ=0),await i.create(e),"panoramic"===o){const{drawOperation:e}=i.view.activeTool;e.constraintsEnabled=!1,e._set("elevationDrawSurface",null)}const s=this.activeViewer?.imageRenderer.effectiveTheme.accentColor;s&&this.sketch&&(this.sketch.polygonSymbol=Te(s),this.sketch.polylineSymbol="panoramic"===o?Oe:Le(s,2.5))}async startHeightMeasurement(){this.displayNewMeasurementButton=!1,this.draw??=new pe({view:this.activeViewer?.imageRenderer}),this.polylineDrawAction=this.draw.create("polyline"),await this.loadHeightMeasurementAdapter()}initializeMeasurement(e){switch(this.clearMeasurementGraphics(),this.resetMeasurementData(),e){case"distance":this.startMeasurement("polyline");break;case"area":this.startMeasurement("polygon");break;case"height":this.startHeightMeasurement()}}async overlayCameraLocations(e){const{activeViewer:i,overlayedCameraLocations:r,layer:o,mode:s,layerFloorFilterClause:n,layerTimeExtent:l,videoViewModel:d,_panoramicVideoViewer:c}=this,h="video"===s,u="panoramic-video"===s,p=this._getActiveFeatureForCurrentMode(),m=this._computeOverlayImageSize();if(!(m&&p&&o&&"none"!==s&&this.overlayGraphicsEnabled))return;const{polygon:g}=W(p.attributes);if(h?d?.removeOverlayGraphics(r.toArray()):u?c.removeManyGraphics(r.toArray()):i?.removeManyGraphics(r.toArray()),r.removeAll(),e){const{features:e}=await o.queryFeatures({where:I(`${o.objectIdField} <> ${p.attributes.objectId}`,I(o.definitionExpression,n)),geometry:g,returnGeometry:!0,outFields:[o.objectIdField],timeExtent:l}),v=await Promise.all(e.map(async e=>{const{attributes:i,geometry:a}=e;if("point"!==a?.type)return null;const r=await this._geometryToOverlayImageGeometry(a,p,m);if(!r)return null;const o="panoramic"===s||"panoramic-video"===s?Ee():Ge();return new t({attributes:i,symbol:o,geometry:r})}));r.addMany(v.filter(a)),h?d?.addOverlayGraphics(r.toArray()):u?c.addManyGraphics(r.toArray()):i?.addManyGraphics(r.toArray())}}overlayGraphicsOnImage(e,t){this.removeOverlayedGraphicsOnImage(e),this.overlayedMapFeatures.set(e,t),"video"!==this.mode?"panoramic-video"!==this.mode?this.activeViewer?.addManyGraphics(t.toArray()):this._panoramicVideoViewer.addManyGraphics(t.toArray()):this.videoViewModel?.addOverlayGraphics(t.toArray())}async overlayMapFeatures(e,i=!1){const{activeViewer:r,mode:s,layer:n,videoViewModel:l,_panoramicVideoViewer:d}=this,c="video"===s,u="panoramic-video"===s,p=this._getActiveFeatureForCurrentMode(),m=this._computeOverlayImageSize();if(!(m&&p&&"none"!==s&&this.overlayGraphicsEnabled&&n))return;const{polygon:g}=W(p.attributes);try{const{imageGeometryField:t,oiObjectIdField:i}=ut(e,n.imageGeometryField,n.imageReferenceField);this.imageGeometryField=t.name,this.oiObjectIdField=i.name}catch(w){h.getLogger(this).warn("oriented-imagery-viewer:overlay-map-features",w)}const{features:v}=await e.queryFeatures({geometry:g,returnGeometry:!0,outFields:["*"]}),y=await Promise.all(v.map(async a=>{const o=a.symbol?.clone()??e.renderer?.getSymbol(a)?.clone(),{attributes:n,geometry:g}=a,{imageGeometryField:v,oiObjectIdField:y}=this;if(v&&y&&_t(e,v,y)&&`${n[y]}`==`${p.attributes.objectId}`)try{const a=u?d.horizonAngles:He(r?.media),h=pt(n,v,e,i,m,c?"default":s,o,a);if(!c)return h;const p=h.geometry;if(!p)return null;const g=l?.imageGeometryToOverlayGeometry(p);return g?new t({attributes:n,layer:e,symbol:h.symbol,geometry:g,visible:h.visible}):null}catch(w){h.getLogger(this).warn("oriented-imagery-viewer:overlay-map-features","couldn't create graphic from attributes, geometry will be used",{error:w,feature:a,layer:e,imageGeometryField:this.imageGeometryField,imageReferenceField:this.oiObjectIdField})}if(!g)return null;const f={feature:p,imageSize:m,footprintExtent:this.footprintExtent},_=await this._geometryToOverlayImageGeometry(g,f.feature,f.imageSize);return _?new t({attributes:n,layer:e,symbol:o,geometry:_,visible:e.visible&&i}):null})),f=new o(y.filter(a));("video"!==s&&"panoramic-video"!==s||this.overlayGraphicsEnabled)&&this.overlayGraphicsOnImage(`${e.id}`,f)}getDepthAt(e){const{activeViewer:t,currentBestFeature:i,mode:a,state:r,depthImage:o}=this,s=t?.imageSize;if(!s||!i||"none"===a||r.includes("loading"))return h.getLogger(this).warnOnce("oriented-imagery-viewer:get-depth-at","Load an image to use depth"),null;if(!o?.loaded)return h.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=>o.depthAt(e,{width:s[0],height:s[1]})??null);return Array.isArray(e)?n:n[0]}getActiveSectors(){return Me.filter(e=>this._sectorData?.[e]?.length)}async getPixelLocationForFeature(e,t,i){return(await this._transformationService.pointToPixelForFeature([e],t,i))[0]}async getPixelLocationsForFeature(e,t,i){return await this._transformationService.pointToPixelForFeature(e,t,i)}async _getMapPointInViewSpatialReference(e,t){const i=await this.getMapPoint(e,t),a=this.view?.spatialReference;return await G(i,a,t)}async plotMapPoint(e){this.plotReferencePoint(e);const t=this._getActiveFeatureForCurrentMode();if(t)return this.transformAndPlotReferencePointOnImage({feature:t,selectedLocation:e,options:{signal:this._transformController?.signal}})}plotReferencePointOnGround(e){this._referencePointOnGround&&(this._overlays?.remove(this._referencePointOnGround),this._referencePointOnGround.destroy()),null!=e&&(this._referencePointOnGround=new t({geometry:new E({...e.toJSON()}),symbol:je}),this.view?this._overlays?.add(this._referencePointOnGround):this.emit("plot-ground-point",{data:{point:this._referencePointOnGround?.geometry}}))}plotReferencePointOnImage(e){switch(this.mode){case"video":return void this._plotReferencePointOnVideo(e);case"panoramic-video":return void this._plotReferencePointOnPanoramicVideo(e);case"default":return void this._plotReferencePointOnDefaultImage(e);case"panoramic":return void this._plotReferencePointOnPanoramicImage(e)}}removeAllOverlayMapFeatures(){const{mode:e}=this;this.overlayedMapFeatures.forEach(t=>{const i=t.toArray();switch(e){case"video":this.videoViewModel?.removeOverlayGraphics(i);break;case"panoramic-video":this._panoramicVideoViewer.removeManyGraphics(i);break;default:this.activeViewer?.removeManyGraphics(i)}}),this.overlayedMapFeatures.clear()}removeOverlayedGraphicsOnImage(e){const t=this.overlayedMapFeatures.get(e),{mode:i}=this;if(!t?.length)return;const a=t.toArray();switch(i){case"video":this.videoViewModel?.removeOverlayGraphics(a);break;case"panoramic-video":this._panoramicVideoViewer.removeManyGraphics(a);break;default:this.activeViewer?.removeManyGraphics(a)}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=g(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),o=r?.toArray();if(!r||!o?.length)return;const{addFeatureResults:s}=await this.saveDataCaptureFeatures(o),n=s.reduce((t,{objectId:i,globalId:a,error:r},s)=>{const n=o[s],{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:o,mode:s}=this,l=i?.imageSize;if(!l||!r||"none"===s||"video"===s||"panoramic-video"===s)throw new n("orientedimageryviewer:missing-input","Image size, current best feature and mode are required to save data capture features");if(!o)throw new n("orientedimageryviewer:missing-featurelayer","Data capture layer is not available");const d=await Promise.all(e.map(async e=>{const i=e.clone(),{geometry:a}=i;if(!a)return;const r=a.type,s=o.hasZ,n=o.geometryType,l=r!==n,d=l?await(import("./transformers.js")):null,c=d?.default[n],h=l?c?.(a):a;return h&&(i.geometry=await this._transformationService.imageGeometryToMapGeometry(h,t),i.geometry)?(s||mt(i.geometry),i):void 0})),c=d.filter(a);return o.applyEdits({addFeatures:c}).then(e=>{const{addFeatureResults:t}=e;let i=0;const a=d.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),h.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 restorePendingPanoramicNavigationViewState(e){const t=this._pendingPanoramicNavigationViewState;this._pendingPanoramicNavigationViewState=null,"panoramic"===this.mode&&await this._restoreNavigationViewState(t,e)}async startDataCapture(e,t){const i=this.activeViewer?.imageRenderer,{oiObjectIdField:a,currentBestFeature:r}=this;if(!i||!r||!a)return;const{attributes:{objectId:s}}=r,n=this.overlayedMapFeatures.get(e.id)?.toArray()??[],l=[],d=[];for(const o of n)`${o.getAttribute(a)}`==`${s}`?l.push(o):d.push(o);this.overlayGraphicsOnImage(e.id,new o(d)),this.collectionId=e.id;const c=await this.loadSketch(t),h=await this.loadDataCaptureAdapter(t);f(t),c.addGraphics(l),h.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=m(this.sketchAdapter),this.sketch=m(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{feature:t,selectedLocation:i,options:a}=e;let r=!1,o=!1;const s="video"===this.mode?this.bestFeatureCurrentFootprint?.geometry:this.bestFeatureFootprint?.geometry;switch(s?.type){case"polygon":{const e=i.spatialReference.equals(s.spatialReference)?i:await G(i,s.spatialReference);r=s.contains(e);break}case"mesh":{const e=i.spatialReference.equals(s.spatialReference)?i:await G(i,s.spatialReference);o=s.extent.contains(e);break}}if(!r&&!o)return void this.clearReferencePointOnImage();const n="video"===this.mode||"panoramic-video"===this.mode?await this.getPixelLocationForFeature(i,{feature:t,mode:this.mode,imageSize:_e,footprintExtent:this.footprintExtent},a):await this._transformationService.pointToPixel(i,a);if(n)return f(a),this.plotReferencePointOnImage(n),{x:n.x,y:n.y};this.clearReferencePointOnImage()}async updateFeatureCache(e,t){const i=await U(e,t);i.features?.length&&(this.featureCache=i.features)}_plotReferencePointOnVideo(e){"video-loaded"===this.state&&this.videoViewModel?.videoPaused&&(this.clearReferencePointOnImage(),this.videoViewModel.plotReferencePointOnVideo(e))}_plotReferencePointOnPanoramicVideo(e){const i=this._panoramicVideoViewer,{imageSize:a,media:r}=i.viewModel;if(!this.panoramicVideoLoaded||!this.panoramicVideoPaused||!a)return;this.clearReferencePointOnImage();const o=He(r),s=gt(e,"panoramic",a,o);this._referencePointOnImage=new t({geometry:s,symbol:Re.clone()}),i.addGraphic(this._referencePointOnImage,0)}_getActiveFeatureForCurrentMode(){switch(this.mode){case"video":return this.videoViewModel?.closestFeature??this.currentBestFeature;case"panoramic-video":return this._panoramicVideoViewer.viewModel.closestFeature??this.currentBestFeature;default:return this.currentBestFeature}}_plotReferencePointOnDefaultImage(e){const i=this._imageViewer,{imageSize:a}=i;if("image-loaded"!==this.state||!a)return;this.clearReferencePointOnImage();const r=gt(e,"default",a);this._referencePointOnImage=new t({geometry:r,symbol:je.clone()}),i.addGraphic(this._referencePointOnImage,0)}_plotReferencePointOnPanoramicImage(e){const i=this._panoramicViewer,{imageSize:a,media:r}=i;if("image-loaded"!==this.state||!a)return;this.clearReferencePointOnImage();const o=He(r),s=gt(e,"panoramic",a,o);this._referencePointOnImage=new t({geometry:s,symbol:Re.clone()}),i.addGraphic(this._referencePointOnImage,0)}async _fetchFeatures(e,t){const{layer:i,layerFloorFilterClause:a,layerTimeExtent:r,view:o}=this;if(!o)return;if(!i)return void this.setMessage("noLayerSelected","info");e.x=B(e.x,e.spatialReference);const s=i.spatialReference.equals(e.spatialReference)?e:await G(e,i.spatialReference),n=s.spatialReference.isGeographic?D(s):s,l=I("1=1",I(i.definitionExpression,a)),d=n.spatialReference.isGeographic?1:C(n.spatialReference),c={layerInstanceOrURL:i,point:n,queryParams:{where:l,maximumDistance:i.maximumDistance?i.maximumDistance/d:void 0,timeExtent:r}};return await this.searchBestImage(c,t)}async _fetchFeaturesWithController(e,t){try{await this._fetchFeatures(e,t)}catch(i){if(y(i))return;this.setMessage("imageLoadError","error"),h.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 s={};this._featureToSector=s;for(const c of Me)this._sectorData[c]=new o;const n=e.map((e,t)=>({...e,featureIndex:t}));n.sort((e,t)=>e.trueSuitability-t.trueSuitability);const l=n.map(({distance:e})=>e),d=Math.max(...l);n.forEach(e=>{const{distance:t,angle:a,featureIndex:o}=e,n=t/d*Ie[2],l=Qe(t,d),c=Xe(a);if(!this._sectorData)return;const h=Ie[3]+n*Math.sin(a*Math.PI/180),u=Ie[3]+n*Math.cos(a*Math.PI/180);let p;const m=i.at(o),g=m===r,{cameraPitch:v}=m.attributes,y=v<5;if(g&&y)p=-90;else{const e=h-Ie[3],t=u-Ie[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?c:`${l}_${c}`;g&&(p===this.bestFeatureAngle?this.previousFeatureAngle=p:this.bestFeatureAngle=p,this.navigatorCurrentBestFeature=y?null:{x:h,y:u,direction:c}),s[`${m.attributes.objectId}`]=f;const w=this._sectorData[f];w.add({angle:a,featureIndex:o,x:h,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;f(e),this._locationViewModel=new i({oiViewModel:this,referenceTransformationService:this._referenceTransformationService})}}_initializeMeasurementService(){this._measurementService||(this._measurementService=new dt({transformationService:this._transformationService,referenceTransformationService:this._referenceTransformationService}))}_initializeVideo(){if(this.videoElement||!this.currentBestFeature)return;this.removeHandles(De.videoPlayerHandles),this.videoElement=new he({video:this.currentBestFeature.attributes.imagePath,georeference:new de({extent:new L(Pe)}),autoplay:!1}),this.videoElement.content?.loop&&(this.videoElement.content.loop=!1);const e=new H({source:this.videoElement,title:this.layer?.title,copyright:this.layer?.copyright});this.videoLayer=e,e&&this.videoMapView.map.layers.add(e),this.videoViewModel=new st({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=$e(a);try{await r.load(t)}catch(s){if(y(s))return;if("unsupported-format"===s.name)return void this.setMessage("unsupportedPanoramicImageryError","error",void 0,{datasetFormat:r?.extension??"UNKNOWN FORMAT"})}const o=this.triangularMeasurementActive?this._panoramicMeasurementViewer:this._panoramicViewer;await o.loadMedia(r,t),i&&o.set(i)}async loadMediaSource(e,t){const i=Ze(e);await this._setImageSource(this.triangularMeasurementActive?this.imageMeasurementViewer:this._imageViewer,i,t)}_clearFeatureGeometries(){this.coveragePolygons.removeAll(),this.coverageFrustums.removeAll(),this.pointSources.removeAll()}_checkFeatures(e){return!!e?.length||(this.emit("no-image-found"),this.setMessage("noImageError","error"),this.videoElement?.content?.pause(),this.currentBestFeature=null,!1)}async _getElevationSampleFromGround(e,t,i){if(!e[0])return;const{unionExecuteMany:a}=await(import("../../geometry/operators/unionOperator.js")),r=a(e);if(this._updateFootprintWithFeatures(t,r),"3d"===this.view?.type)try{return await this.view.map.ground.createElevationSampler(this.footprintExtent,i)}catch(o){y(o)||h.getLogger(this).error(o)}}async processElevationSample(e,t,i){const{elevationSource:a}=t[0].attributes,r=await this._getElevationSampleFromGround(e,t,i);return r||(a&&this.footprintExtent&&K(a)?await ee({extent:this.footprintExtent,lod:a.lod,url:a.url,rasterFunction:a.rasterFunction}):void 0)}_processSuitableFeatures(e,t){return q({features:e,selectedPoint:t,camera:Je(this.view)?this.view.camera:null,currentImage:this.currentBestFeature})}async _processHitTestResults(e,t,i){const{results:[a]}=t;if("graphic"!==a?.type)return this.beforeLoad(!1),this.emit("no-image-found"),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:o}=await lt(e,t,i,a,r);if(f(r),!o?.features?.length)throw new nt(t);const{attributes:s}=o.features[0];let n,l;if(s.orientedImageryType?.includes("360")){n=X(s.geometry);const{cameraHeading:e,farDistance:t,nearDistance:i}=s,a=[Math.sin(p(e)),Math.cos(p(e))],r=(t+i)/2;l=C(n.spatialReference),n.x+=r*a[0]/l,n.y+=r*a[1]/l,n.z=void 0}else{const e=W(s).polygon,t=E.fromJSON(R(e));n=X(t),l=C(n.spatialReference)}this.selectedPoint=n;const d={layerInstanceOrURL:e,point:n,queryParams:{where:I(I("1=1",I(e.definitionExpression,i)),`${e.objectIdField} <> ${t}`),maximumDistance:e.maximumDistance?e.maximumDistance/l:void 0,timeExtent:a}},c=await z(d,r);f(r);const{features:h}=c;return h.push(o.features[0]),await this.processFeatureResponse(c,n,{...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)}async _restoreNavigationViewState(e,t){const i=e?.center?await this._transformationService.pointToPixel(e.center,t):null;if(f(t),"panoramic"===this.mode){const t=He(this._panoramicViewer.media);if(!t)return;yt({viewState:e,panoramicViewer:this._panoramicViewer,horizonAngles:t,imageCenter:i})}ft({viewState:e,imageViewer:this._imageViewer,imageCenter:i})}_toggleVisiblity(e,t){e.forEach(e=>{e.visible=t})}async _updateElevationOfSelectedPointAndLocations(e,t,i,a){const{location:r,cameraHeight:o}=e[0].attributes,s=await re(r.spatialReference,r.z,o,{elevationSample:i,elevationSource:i?void 0:e[0].attributes.elevationSource,extent:this.footprintExtent},a);f(a);const[n,...l]=await Y([t,...e.map(e=>e.attributes.geometry.clone())],s);f(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:o}=i;return new ot({geometry:t,attributes:i,currentHeading:a?0:r,currentPitch:a?0:o})})),e.length>1?this.additionalFeatures.addMany(e.slice(1)):this.additionalFeatures.removeAll(),this._updateGroundElevation=!0,t&&(this.currentBestFeature=e[0])}_updateFootprintWithFeatures(e,t){const i=[];for(const{attributes:{geometry:a}}of e)t.contains(a)||i.push([a.x,a.y]);i.sort((e,t)=>+x([e,t])),t.addRing(i),this.footprintExtent=me(t.extent,2,2)}_scheduleVideoInteractionUpdate(){this.scheduledFrameId||(this.scheduledFrameId=requestAnimationFrame(()=>{this.scheduledFrameId=null,this._updateInteraction()}))}async _updatePointsAndPolygons(e){const{pointSources:i,currentBestFeature:a,currentCoverageVisible:r,isAdditionalPointSourcesVisible:o,mode:s,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)),f(e);for(const s of i){const i=this.view&&!this.view.spatialReference?.equals(s.spatialReference)?await G(s.clone(),this.view?.spatialReference,e):s.clone();s.imageID===a.attributes.objectId?this.currentBestFeatureLocation=new t({attributes:{imageID:s.imageID},geometry:i,symbol:xe,visible:r}):this.additionalCameraLocations.push(new t({attributes:{imageID:s.imageID},geometry:i,symbol:Be,visible:o}))}"video"!==s&&"panoramic-video"!==s||(await this.initializeTransformationService(e),n&&!this.featureCache.length&&await this.updateFeatureCache(n,a.geometry.spatialReference))}}_scheduleCurrentBestFeatureUpdate(e){g(this._navigationViewStateTask);const t=r(async t=>{await this._updateCurrentBestFeature(e,{signal:t})});this._navigationViewStateTask=t,t.promise.catch(e=>{if(!y(e))throw e}).finally(()=>{this._navigationViewStateTask===t&&(this._navigationViewStateTask=null)})}async _updateCurrentBestFeature(e,t){if(!e)return;if(await this._capturePendingNavigationViewState(t),f(t),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 i=this.currentBestFeature?.attributes.cameraPitch&&this.currentBestFeature?.attributes.cameraPitch<5;let a;if(i)a=-90;else{const t=e.x-Ie[3],i=e.y-Ie[3],r=i/Math.sqrt(t**2+i**2);let o=180*Math.acos(r)/Math.PI;(t<0&&i<0||t<0&&i>0)&&(o*=-1),a=o}a===this.bestFeatureAngle?this.previousFeatureAngle=a:this.bestFeatureAngle=a,this.navigatorCurrentBestFeature=i?null:{x:e.x,y:e.y,direction:e.sector.includes("_")?e.sector.split("_")[1]:e.sector},"panoramic"===this.mode&&(await F(()=>"image-loaded"===this.state,t),f(t),await this.restorePendingPanoramicNavigationViewState(t))}async _capturePendingNavigationViewState(e){"default"!==this.mode?"panoramic"===this.mode&&await this._capturePendingPanoramicNavigationViewState(e):await this._capturePendingDefaultNavigationViewState(e)}async _capturePendingDefaultNavigationViewState(e){try{const{imageSize:t,imageRenderer:i}=this._imageViewer,a=i.center;if("image-loaded"!==this.state||!t[0]||!t[1]||!a)return void(this._pendingDefaultNavigationViewState=null);const r=vt(a,"default",t),o=await this._getMapPointInViewSpatialReference(r,e);f(e),this._pendingDefaultNavigationViewState={center:o,scale:i.scale}}catch(t){this._handlePendingNavigationViewStateCaptureError(t)}}async _capturePendingPanoramicNavigationViewState(e){const t=He(this._panoramicViewer.media);if(t)try{const{fov:i,imageSize:a,pitch:r,yaw:o}=this._panoramicViewer;if("image-loaded"!==this.state||!a||!i)return void(this._pendingPanoramicNavigationViewState=null);const[s,n]=oe(o,r,t),l=se(s,n,a[0],a[1]),d=await this._getMapPointInViewSpatialReference(l,e);f(e),this._pendingPanoramicNavigationViewState={center:d,fov:i}}catch(i){this._handlePendingNavigationViewStateCaptureError(i)}}_handlePendingNavigationViewStateCaptureError(e){if(y(e))throw e;h.getLogger(this).warn("oriented-imagery-viewer:failed-to-capture-navigation-view-state",e)}_updateImageMeasurementBestFeature(e){e&&(this.currentBestFeatureMeasurementImage=this.features?.at(e.featureIndex))}clearGraphics(){this._imageViewer.clearGraphics(),this._panoramicViewer.clearGraphics(),this.imageMeasurementViewer.clearGraphics(),this._panoramicMeasurementViewer.clearGraphics()}clearReferencePointOnImage(){this._referencePointOnImage&&(this._imageViewer.removeGraphic(this._referencePointOnImage),this._panoramicViewer.removeGraphic(this._referencePointOnImage),this._panoramicVideoViewer.removeGraphic(this._referencePointOnImage),this._referencePointOnImage=m(this._referencePointOnImage)),this.videoViewModel?.clearReferencePointOnVideo()}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:o,elevationSample:s}=t,{location:{spatialReference:n,z:l},cameraHeight:d,elevationSource:c}=o;let h=o.location;h.spatialReference.isGeographic&&(h=X(h));const u="default"===a?ne(o,r[0],r[1]):le(o,r[0],r[1]),p=await re(n,l??0,d,{elevationSample:s,elevationSource:c,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?_e:i?.imageSize;if(!t||!r||"none"===a)return;const{attributes:o,elevationSample:s}=t,{location:{spatialReference:n,z:l},cameraHeight:d,elevationSource:c}=o;let h=o.location;h.spatialReference.isGeographic&&(h=X(h));const u="default"===a||"video"===a?"default":"panoramic",p={..."default"===u?ne(o,r[0],r[1]):le(o,r[0],r[1]),cameraLocation:h},m=await re(n,l??0,d,{elevationSample:s,elevationSource:c,extent:this.footprintExtent},e),g=(await(import("./services/TransformationService.js"))).default,v={imageToWorldProperties:p,updateElevationProps:m,mode:u,imageSize:r,depthImageService:this.depthImage};this._transformationService=new g(v),this._measurementService&&(this._measurementService.transformationService=this._transformationService)}plotReferencePoint(e){"mapPoint"in e?this.plotReferencePointOnGround(e.mapPoint):this.plotReferencePointOnGround(e)}clearSelectedPointOnViewer(){if(this._crossSymbol){if("video"===this.mode)return this.videoViewModel?.clearSelectedPointOnVideo(),void(this._crossSymbol=null);this._panoramicViewer.removeGraphic(this._crossSymbol),this._imageViewer.removeGraphic(this._crossSymbol),this.videoMapView.graphics.remove(this._crossSymbol),this._crossSymbol=m(this._crossSymbol)}else this.videoViewModel?.clearSelectedPointOnVideo()}setMessage(e,t,i,a){this.displayMessage={key:e,type:t,data:i,map:a}}async transformAndPlotSelectedLocation(e){const{invalidCameraHeading:t,selectedPoint:i,activeViewer:a,videoElement:r}=this,o="video"===this.mode?this.videoViewModel?.closestFeature??this.currentBestFeature:this.currentBestFeature;this.clearSelectedPointOnViewer();const s="video"===this.mode?!0===r?.loaded&&!0===this.videoViewModel?.videoPaused:"image-loaded"===a?.state;if(!i||!o||!s||t)return;if("video"===this.mode){if(!await it(i,this.bestFeatureCurrentFootprint?.geometry,e))return}let n;try{if(n="video"===this.mode?await this.getPixelLocationForFeature(i,{feature:o,mode:this.mode,imageSize:_e,footprintExtent:this.footprintExtent},e):await this._transformationService.pointToPixel(i,{signal:e?.signal}),"video"===this.mode&&!at(n))return;f(e),await this.plotSelectedPointOnImage(n,e)}catch(l){y(l)||h.getLogger(this).error("failed to transform map point to pixel, cross symbol will not be plotted on image",{error:l,selectedPoint:i,feature:o})}}updateCurrentCoveragePolygon(e){const{additionalFootprints:i,additionalCameraLocations:a,currentBestFeature:r,currentBestFeatureLocation:o,currentCoverageVisible:s,selectedPoint:n,view:l,_adapter:d,mode:c}=this;if(!r)return;const{attributes:{objectId:h},elevationSample:u}=r;if(this._initialCurrentCoverageUpdate){if(this._overlays?.removeAll(),this._initialCurrentCoverageUpdate=!1,this.bestFeatureCurrentFootprint=m(this.bestFeatureCurrentFootprint),e&&!this.invalidCameraHeading&&(e.visible=s,this.bestFeatureCurrentFootprint=e),l){const e=[...i,...a,o].filter(Ke);"3d"===l?.type&&u&&d?.updateGroundElevation&&(this._updateGroundElevation&&d.updateGroundElevation(e),"panoramic"===c&&this.bestFeatureCurrentFootprint&&d.updateGroundElevation([this.bestFeatureCurrentFootprint])),this._updateGroundElevation=!1,n&&(this.bestFeatureCurrentFootprint&&e.splice(-2,0,this.bestFeatureCurrentFootprint),e.push(new t({geometry:n.clone(),symbol:Ae.clone(),attributes:{imageID:h}}))),this._overlays.graphics.addMany(e)}}else if(l){if(this.invalidCameraHeading)return void this._superimposeService.clear();this.bestFeatureCurrentFootprint&&(this._overlays?.remove(this.bestFeatureCurrentFootprint),this.bestFeatureCurrentFootprint=m(this.bestFeatureCurrentFootprint));const t=this.bestFeatureCurrentFootprint&&this._overlays?this._overlays.graphics.indexOf(this.bestFeatureCurrentFootprint):-1;e&&(this.bestFeatureCurrentFootprint=e,"3d"===l?.type&&u&&d?.updateGroundElevation&&"panoramic"===c&&d.updateGroundElevation([e]),e.visible=this.currentCoverageVisible,this._overlays?.graphics.add(this.bestFeatureCurrentFootprint,t>=0?t:this._overlays.graphics.length-1))}}_updateSuperimposedImage(){if(!this._hasActiveSuperimposeCameraContext())return;const e="panoramic"===this.mode?this._panoramicViewer:null,{currentBestFeature:t,defaultSuperimposeCameraLockEnabled:i,layer:a,mode:r,view:o,state:s,superimposeViewEnabled:n,superimposeViewSupported:l,activeViewer:d,depthImage:c}=this,h=this.coverageFrustums.find(({imageID:e})=>e===t?.attributes.objectId);this._superimposeService.update({activeImageSize:d?.imageSize||void 0,adapter:this._adapter,currentBestFeature:t,currentBestFeatureFrustum:h,defaultSuperimposeCameraLockEnabled:i,depthImageLoaded:c?.loaded??!1,layer:a,mode:r,panoramicCamera:e?.camera,state:s,superimposeViewEnabled:n&&l,view:o}),this.setMessage("superimposeImageDescription","info"),this._superimposePreviousCurrentCoverageVisible??=this.currentCoverageVisible,this.currentCoverageVisible=!1}_getSuperimposeCameraWatchState(){const e="3d"===this.view?.type?this.view:null,t=e?.camera;return[this.superimposeViewEnabled,this.superimposeViewSupported,this.mode,this.state,this.view?.type,this.view?.interacting,this.view?.navigating,t?.heading,t?.tilt,t?.fov,t?.position.x,t?.position.y,t?.position.z]}_handleSuperimposeCameraChange(){const e=this.view,t="3d"===e?.type?e:null;this._hasActiveSuperimposeCameraContext()?"panoramic"!==this.mode?!t||t.interacting||t.navigating?this._abortSuperimposeSchedule():this._scheduleDefaultSuperimposeUpdate():this._schedulePanoramicSuperimposeUpdate():this._abortSuperimposeSchedule()}_shouldDisableUnsupportedSuperimposeView(){return this.superimposeViewEnabled&&"panoramic"===this.mode&&!this.superimposeViewSupported}_hasActiveSuperimposeCameraContext(){return("default"===this.mode||"panoramic"===this.mode)&&this.superimposeViewEnabled&&this.superimposeViewSupported&&"image-loaded"===this.state&&"3d"===this.view?.type&&!!this.view.camera}_abortSuperimposeSchedule(){this._superimposeScheduleController?.abort(),this._superimposeScheduleController=null,this._clearSuperimposeDebounceTimeout(),this._clearSuperimposeScheduledFrame()}_resetInactiveSuperimposeState(){const e=null!=this._superimposePreviousCurrentCoverageVisible;this._abortSuperimposeSchedule(),this._adapter?.disableDefaultSuperimposeNavigation?.(),this._adapter?.disablePanoramicSuperimposeNavigation?.(),this._superimposeService.clear(),this._restoreCurrentCoverageVisibilityAfterSuperimpose(),this._restoreDefaultMessageAfterSuperimpose(),e&&this._restoreViewerMediaAfterSuperimpose()}_restoreCurrentCoverageVisibilityAfterSuperimpose(){null!=this._superimposePreviousCurrentCoverageVisible&&(this.currentCoverageVisible=this._superimposePreviousCurrentCoverageVisible,this._superimposePreviousCurrentCoverageVisible=null)}_restoreViewerMediaAfterSuperimpose(){const{currentBestFeature:e,mode:t}=this;if(!e||"default"!==t&&"panoramic"!==t)return;this._restoreSuperimposeMediaTask?.abort();const i=r(async t=>{await this._loadCurrentFeatureMedia(e,{signal:t})});this._restoreSuperimposeMediaTask=i,i.promise.finally(()=>{this._restoreSuperimposeMediaTask===i&&(this._restoreSuperimposeMediaTask=null)})}_restoreDefaultMessageAfterSuperimpose(){if("superimposeImageDescription"===this.displayMessage?.key){!!this.currentBestFeature&&("default"===this.mode||"panoramic"===this.mode)?this.displayMessage=null:this.setMessage("onLoadMessage","info")}}_clearSuperimposeDebounceTimeout(){null!=this.superimposeDebounceTimeoutId&&(clearTimeout(this.superimposeDebounceTimeoutId),this.superimposeDebounceTimeoutId=null)}_clearSuperimposeScheduledFrame(){null!=this.superimposeScheduledFrameId&&(cancelAnimationFrame(this.superimposeScheduledFrameId),this.superimposeScheduledFrameId=null)}_schedulePanoramicSuperimposeUpdate(){this._abortSuperimposeSchedule(),this.superimposeDebounceTimeoutId=window.setTimeout(()=>{this.superimposeDebounceTimeoutId=null,this._hasActiveSuperimposeCameraContext()&&"panoramic"===this.mode&&this._updateSuperimposedImage()},150)}_scheduleDefaultSuperimposeUpdate(){const e=this.view;if(!("3d"===e?.type?e:null))return;if(this.superimposeScheduledFrameId)return;this._superimposeScheduleController?.abort();const t=new AbortController,{signal:i}=t,a=()=>{this._clearSuperimposeDebounceTimeout(),this._clearSuperimposeScheduledFrame(),this._superimposeScheduleController===t&&(this._superimposeScheduleController=null),i.removeEventListener("abort",a)};this._superimposeScheduleController=t,i.addEventListener("abort",a),this.superimposeScheduledFrameId=requestAnimationFrame(()=>{if(i.removeEventListener("abort",a),this.superimposeScheduledFrameId=null,this._superimposeScheduleController===t&&(this._superimposeScheduleController=null),i.aborted)return;const e=this.view,r="3d"===e?.type?e:null;!this._hasActiveSuperimposeCameraContext()||null==r||r.interacting||r.navigating||this._updateSuperimposedImage()})}};e([A()],Vt.prototype,"activeLayer",null),e([A({readOnly:!0})],Vt.prototype,"activeViewer",null),e([A()],Vt.prototype,"activeTriangulatedViewer",null),e([A()],Vt.prototype,"accuracyParametersMissing",null),e([A()],Vt.prototype,"additionalFeatures",void 0),e([A({type:o.ofType(t)})],Vt.prototype,"additionalCameraLocations",void 0),e([A({type:o.ofType(t)})],Vt.prototype,"additionalFootprints",void 0),e([A()],Vt.prototype,"areaMeasurementResult",void 0),e([A()],Vt.prototype,"areaMeasurementAccuracy",void 0),e([A()],Vt.prototype,"bestFeatureAngle",void 0),e([A()],Vt.prototype,"bestFeatureCurrentFootprint",void 0),e([A({type:t})],Vt.prototype,"bestFeatureFootprint",void 0),e([A({type:Number})],Vt.prototype,"brightness",null),e([A()],Vt.prototype,"cameraHeadingThreshold",void 0),e([A()],Vt.prototype,"cameraPitchThreshold",void 0),e([A()],Vt.prototype,"clickAction",void 0),e([A()],Vt.prototype,"correctedLocationPointOnImage",void 0),e([A()],Vt.prototype,"videoViewModel",void 0),e([A()],Vt.prototype,"collectionId",void 0),e([A({type:Number})],Vt.prototype,"contrast",null),e([A()],Vt.prototype,"coverageFrustums",void 0),e([A()],Vt.prototype,"coveragePolygons",void 0),e([A()],Vt.prototype,"currentBestFeature",void 0),e([A()],Vt.prototype,"currentBestFeatureMeasurementImage",void 0),e([A()],Vt.prototype,"currentBestFeatureLocation",void 0),e([A()],Vt.prototype,"currentCoverageVisible",void 0),e([A()],Vt.prototype,"currentNode",null),e([A()],Vt.prototype,"depthImage",void 0),e([A()],Vt.prototype,"depthImageNotSupported",null),e([A()],Vt.prototype,"featureCache",void 0),e([A()],Vt.prototype,"navigationNodes",void 0),e([A({json:{write:!1}})],Vt.prototype,"determineWorkflowForFeature",void 0),e([A({json:{write:!1}})],Vt.prototype,"determineWorkflowForTriangularMeasurement",void 0),e([A()],Vt.prototype,"disabled",void 0),e([A()],Vt.prototype,"displayMessage",void 0),e([A()],Vt.prototype,"displayNewMeasurementButton",void 0),e([A()],Vt.prototype,"distanceMeasurementResult",void 0),e([A()],Vt.prototype,"distanceAccuracyArray",void 0),e([A()],Vt.prototype,"dataCaptureLayer",void 0),e([A({readOnly:!0})],Vt.prototype,"featureCount",null),e([A()],Vt.prototype,"features",void 0),e([A()],Vt.prototype,"groundCoordinates",void 0),e([A()],Vt.prototype,"groundCoordinatesAccuracy",void 0),e([A()],Vt.prototype,"groundCoordinatesAccuracyLoading",void 0),e([A()],Vt.prototype,"hasPendingPanoramicNavigationViewState",null),e([A()],Vt.prototype,"heightGraphic",void 0),e([A()],Vt.prototype,"heightMeasurementResult",void 0),e([A()],Vt.prototype,"heightMeasurementAccuracy",void 0),e([A({readOnly:!0})],Vt.prototype,"imageGalleryEnabled",null),e([A()],Vt.prototype,"imageGeometryField",void 0),e([A({readOnly:!0})],Vt.prototype,"imageLoaded",null),e([A()],Vt.prototype,"imageLocationToolState",void 0),e([A()],Vt.prototype,"initialVideoMapViewExtent",void 0),e([A({readOnly:!0})],Vt.prototype,"invalidCameraHeading",null),e([A()],Vt.prototype,"imagePointsInView",null),e([A()],Vt.prototype,"imageMeasurementViewer",void 0),e([A()],Vt.prototype,"isAdditionalCoverageVisible",void 0),e([A()],Vt.prototype,"isAdditionalPointSourcesVisible",void 0),e([A()],Vt.prototype,"layer",void 0),e([A()],Vt.prototype,"layerView",null),e([A({readOnly:!0})],Vt.prototype,"layerFloorFilterClause",null),e([A({readOnly:!0})],Vt.prototype,"layerTimeExtent",null),e([A({type:Number})],Vt.prototype,"localPort",void 0),e([A()],Vt.prototype,"locationPointOnImage",void 0),e([A()],Vt.prototype,"mapImageConversionToolState",void 0),e([A()],Vt.prototype,"measureType",void 0),e([A()],Vt.prototype,"measurementGraphic",void 0),e([A({readOnly:!0,value:"none"})],Vt.prototype,"mode",null),e([A()],Vt.prototype,"navigationMode",void 0),e([A()],Vt.prototype,"navigatorCurrentBestFeature",void 0),e([A()],Vt.prototype,"oiObjectIdField",void 0),e([A({type:o.ofType(t)})],Vt.prototype,"overlayedCameraLocations",void 0),e([A()],Vt.prototype,"overlayedMapFeatures",void 0),e([A()],Vt.prototype,"panoramicVideoLoaded",null),e([A()],Vt.prototype,"panoramicVideoPaused",null),e([A()],Vt.prototype,"pixelCoordinates",void 0),e([A()],Vt.prototype,"preserveAngle",void 0),e([A()],Vt.prototype,"pointSources",void 0),e([A({readOnly:!0})],Vt.prototype,"popupEnabled",null),e([A()],Vt.prototype,"preloadMedia",void 0),e([A()],Vt.prototype,"preloadMediaSize",void 0),e([A()],Vt.prototype,"previousFeatureAngle",void 0),e([A()],Vt.prototype,"referencePoint",null),e([A({readOnly:!0})],Vt.prototype,"sectorData",null),e([A()],Vt.prototype,"selectedPoint",void 0),e([A({type:Number})],Vt.prototype,"sharpness",null),e([A()],Vt.prototype,"shouldShowSelectedImage",void 0),e([A()],Vt.prototype,"superimposeViewEnabled",void 0),e([A()],Vt.prototype,"defaultSuperimposeCameraLockEnabled",void 0),e([A()],Vt.prototype,"superimposeViewSupported",null),e([A()],Vt.prototype,"sketch",void 0),e([A()],Vt.prototype,"sketchTriangular",void 0),e([A()],Vt.prototype,"sketchTriangularGraphicsLayer",void 0),e([A()],Vt.prototype,"draw",void 0),e([A()],Vt.prototype,"drawAdapter",void 0),e([A()],Vt.prototype,"polylineDrawAction",void 0),e([A()],Vt.prototype,"scheduledFrameId",void 0),e([A()],Vt.prototype,"superimposeScheduledFrameId",void 0),e([A()],Vt.prototype,"superimposeDebounceTimeoutId",void 0),e([A()],Vt.prototype,"sketchAdapter",void 0),e([A({readOnly:!0})],Vt.prototype,"sketchGraphicsLayer",null),e([A({readOnly:!0})],Vt.prototype,"state",null),e([A({readOnly:!0})],Vt.prototype,"thumbnails",null),e([A()],Vt.prototype,"videoExtentPoints",null),e([A()],Vt.prototype,"triangularMeasurementActive",void 0),e([A()],Vt.prototype,"triangulatedDistanceMeasurement",void 0),e([A()],Vt.prototype,"triangulatedDistanceAccuracy",void 0),e([A()],Vt.prototype,"triangulatedAreaMeasurement",void 0),e([A()],Vt.prototype,"triangulatedAreaAccuracy",void 0),e([A()],Vt.prototype,"triangulatedMeasurementGraphic",void 0),e([A()],Vt.prototype,"triangulatedPoint",void 0),e([A()],Vt.prototype,"triangulatedMeasurementAdapter",void 0),e([A()],Vt.prototype,"updateFootprint",void 0),e([A()],Vt.prototype,"updateVideoFootprint",void 0),e([A()],Vt.prototype,"updateFootprintPanorama",void 0),e([A()],Vt.prototype,"updatingTriangularMeasurementState",void 0),e([A({value:null})],Vt.prototype,"view",null),e([A()],Vt.prototype,"videoElement",void 0),e([A()],Vt.prototype,"videoLayer",void 0),e([A()],Vt.prototype,"videoMapView",void 0),e([A()],Vt.prototype,"verticalFilterEnabled",void 0),e([A()],Vt.prototype,"_adapter",void 0),e([A()],Vt.prototype,"_defaultGraphicsLayer",null),e([A()],Vt.prototype,"_highlightedFeatureHandle",void 0),e([A()],Vt.prototype,"_imageViewer",void 0),e([A()],Vt.prototype,"_initialCurrentCoverageUpdate",void 0),e([A()],Vt.prototype,"_locationViewModel",void 0),e([A()],Vt.prototype,"_measurementService",void 0),e([A()],Vt.prototype,"_mediaPrefetcher",void 0),e([A()],Vt.prototype,"_navigationManager",void 0),e([A()],Vt.prototype,"_overlays",void 0),e([A()],Vt.prototype,"_superimposePreviousCurrentCoverageVisible",void 0),e([A()],Vt.prototype,"_superimposeService",void 0),e([A({readOnly:!0})],Vt.prototype,"_overlaysView",null),e([A()],Vt.prototype,"_panoramicVideoViewer",void 0),e([A()],Vt.prototype,"_panoramicViewer",void 0),e([A()],Vt.prototype,"_panoramicMeasurementViewer",void 0),e([A()],Vt.prototype,"_referencePointOnGround",void 0),e([A()],Vt.prototype,"_referencePointOnImage",void 0),e([A()],Vt.prototype,"_referenceTransformationService",void 0),e([A()],Vt.prototype,"_sectorData",void 0),e([A()],Vt.prototype,"_transformationService",void 0),e([A()],Vt.prototype,"_featureToSector",void 0),e([A({readOnly:!0})],Vt.prototype,"_updatingHandles",void 0),e([A()],Vt.prototype,"footprintExtent",void 0),e([A()],Vt.prototype,"_featureChangedTask",void 0),Vt=e([k("esri.widgets.OrientedImageryViewer.OrientedImageryViewerViewModel")],Vt);const St=Vt;export{St as default};
@@ -578,6 +578,12 @@ export default class SketchViewModel extends EventedAccessor {
578
578
  */
579
579
  get activeFillSymbol(): SimpleFillSymbol | CIMSymbol | null | undefined;
580
580
  set activeFillSymbol(value: (SimpleFillSymbolProperties & { type: "simple-fill" }) | (CIMSymbolProperties & { type: "cim" }) | null | undefined);
581
+ /**
582
+ * The configurations for plugins in the active DrawTool plugin stack.
583
+ *
584
+ * @internal
585
+ */
586
+ get activePluginConfigurations(): PluginConfiguration[];
581
587
  /**
582
588
  * When creating new graphics (for example after [create()](https://developers.arcgis.com/javascript/latest/references/core/widgets/Sketch/SketchViewModel/#create) has been called),
583
589
  * this property reflects the create tool being used. When updating graphics
@@ -1042,6 +1048,13 @@ export default class SketchViewModel extends EventedAccessor {
1042
1048
  * @param graphics
1043
1049
  */
1044
1050
  removeGraphics(graphics: Graphic[]): void;
1051
+ /**
1052
+ * Replaces the leaf plugin in the active DrawTool plugin stack.
1053
+ *
1054
+ * @param configurations - The configurations for the replacement plugins.
1055
+ * @internal
1056
+ */
1057
+ replaceLeaf(configurations: PluginConfiguration[]): void;
1045
1058
  /**
1046
1059
  * Incrementally undo actions recorded in the stack. Calling this method will fire the
1047
1060
  * [@undo](https://developers.arcgis.com/javascript/latest/references/core/widgets/Sketch/SketchViewModel/#event-undo) event.